A canonical state module for the run
src/workflow.ts · src/workflow-supervisor.ts · src/manager.ts · src/journal.ts · src/dashboard.ts · src/job-format.ts · src/render.ts · src/types.ts
Before — one run, four shapes
flowchart TB
plan["WorkflowPlan — parse"] --> spec["WorkflowRunSpec — prepare"]
spec --> dag["WorkflowRunState — supervisor local, dies when run() returns"]
spec --> flat["Execution.tasks — flat TaskSnapshot[], the only shape that survives"]
dag --> flat
flat --> journal["journal — itemsByStep() rebuilds the step/item DAG"]
flat --> dash["dashboard"]
flat --> jf["job-format"]
flat --> rend["render"]
restore["restore() — fabricates AgentConfig, never restores the workflow"] -.-> flat
linkStyle 4,8 stroke:#dc2626,stroke-width:2px
After — one deep run module, thin projections
run module
stepTasks · itemTasks · pendingItems · itemCounts · attempts · restore identity — all inside
↓ projection · ↓ projection · ↓ projection
JobSnapshot
flat view for the job system
WorkflowJournal
audit record, built not rebuilt
presentTask
labels for display
Problem
One run exists as a plan, a prepared spec, a supervisor-local DAG, and a flat task array — and the journal plus three display modules reverse-engineer the step/item graph from rows that share a stepId, while restore fabricates agent configs and drops the workflow.
Solution
Promote the supervisor's run state to the run's canonical module, and make the snapshot, the journal, and task labels projections of it.
Wins
- locality: one run, one module
- retries get a home (attempts already anticipated)
- journal stops rebuilding the DAG
- restore keeps step identity, journal eligibility
- leverage: one interface, three projections
- tests: every projection from one state