models.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. from __future__ import annotations
  2. from typing import Any, Literal
  3. from pydantic import BaseModel, ConfigDict
  4. class StrictModel(BaseModel):
  5. model_config = ConfigDict(extra="forbid")
  6. class Metric(StrictModel):
  7. label: str
  8. value: str
  9. class RecordEnvelope(StrictModel):
  10. model_name: str
  11. schema_version: str | None = None
  12. payload: dict[str, Any]
  13. class FlowNode(StrictModel):
  14. id: str
  15. node_type: Literal[
  16. "input",
  17. "contract",
  18. "operation",
  19. "worker",
  20. "attempt",
  21. "artifact",
  22. "validator",
  23. "validation",
  24. "decision",
  25. "checkpoint",
  26. "publication",
  27. "transaction",
  28. "readback",
  29. ]
  30. phase: Literal["phase-1", "phase-2", "phase-3", "delivery"]
  31. lane: str
  32. title: str
  33. subtitle: str
  34. status: str
  35. agent_role: str | None = None
  36. task_kind: str | None = None
  37. sequence: int
  38. x: int
  39. y: int
  40. width: int = 268
  41. tags: list[str]
  42. metrics: list[Metric]
  43. record: RecordEnvelope
  44. class FlowEdge(StrictModel):
  45. id: str
  46. source: str
  47. target: str
  48. label: str | None = None
  49. kind: Literal["control", "artifact", "validation", "publication"] = "control"
  50. animated: bool = False
  51. class PhaseFrame(StrictModel):
  52. id: str
  53. title: str
  54. subtitle: str
  55. x: int
  56. y: int
  57. width: int
  58. height: int
  59. tone: Literal["coral", "blue", "purple", "green"]
  60. class RunSummary(StrictModel):
  61. script_build_id: int
  62. title: str
  63. status: str
  64. checkpoint: str
  65. root_trace_id: str
  66. publication_state: str
  67. node_count: int
  68. created_at: str
  69. updated_at: str
  70. class RunGraph(StrictModel):
  71. schema_version: Literal["script-build-visualization/v1"]
  72. data_mode: Literal["fake"]
  73. generated_at: str
  74. run: RunSummary
  75. frames: list[PhaseFrame]
  76. nodes: list[FlowNode]
  77. edges: list[FlowEdge]
  78. schema_catalog: dict[str, list[str]]
  79. enum_catalog: dict[str, list[str]]
  80. declared_gaps: list[str]
  81. class NodeDetail(StrictModel):
  82. data_mode: Literal["fake"]
  83. run_id: int
  84. node: FlowNode
  85. incoming: list[FlowEdge]
  86. outgoing: list[FlowEdge]