TaskSnapshot, JobSnapshot, the workflow journal record, and their entry
envelopes are TypeBox schemas whose Static types are the persisted types.
persistence.ts restores with Value.Check, so the hand-written validators
(and their drift: validTask skipped step, validJob skipped timings and
errors) are gone. A fast-check property holds persist -> restore equal
over generated records.
workflowStepInputHash and workflowItemInputHash feed the canonical
serializer the plan with provenance stripped, so every step field is
hashed by default and a new one cannot vanish from the replay contract.
The payload marker moves 1 -> 2 to separate hash eras; nothing replays
today (ADR 0004).
Parse steps with Value.Check against a TypeBox WorkflowStepSchema, derive
the allowed field names from it, and keep full steps in the start plan:
model and cwd ride along, so ExpandedWorkflowStep has no shape to copy.
PreparedWorkflowStep projects the canonical step type instead of
re-declaring id, needs, and each.
The journal rebuilt the step/item graph from the flat job record: rows
were grouped by stepId, an each-step's coordinator row was picked out of
the collision with its item children, and a positional fallback covered
rows without step ids. After the seam (#22) the supervisor owns the DAG
index, so the record is a projection of that state instead.
- WorkflowSupervisor.journal(execution) projects the record from its
stepTasks/itemTasks index and the run spec while the run is live.
- journal.ts keeps the pure row builders, now over the shared InternalTask
record, and builds the record from plan order plus the index; itemsByStep,
the byStep collision handling, and the positional fallback are gone.
- The manager calls the run's projection at finalize and passes it to
onWorkflowJournal; interrupted runs project at shutdown as before.
- jobUsage() moves the usage summation into job-state.ts so the snapshot
and the journal read one number.
Journal tests that hand-built flat snapshots to exercise the
reverse-engineering are replaced by run-state-driven ones; a cancelled
run's journal is now covered too.
Part of #23.
Add a second WorkflowSupervisorHost adapter and drive release order, transitive skips, fail-soft items, zero-item failure, cancellation with pending items, stall detection, and injected cap limits without a manager or temp agent directories.
Move Execution, InternalTask, and the status predicates into job-state.ts; the supervisor now creates, schedules, and settles shared rows only through its host. Concentrate cancellation and shutdown settlement in one supervisor policy, make restored rows honest (no fabricated AgentConfig), and thread load-time cap limits through WorkflowRunSpec so release enforcement and the review card share one value. Agent discovery is memoized per cwd within a prepare call.