Commit Graph
8 Commits
Author SHA1 Message Date
alex e15c86f007 Merge ticket/t4-step-mirrors: step schemas, whole-plan hash v2, record schemas (#24)
# Conflicts:
#	test/workflow-journal.test.ts
2026-12-01 11:26:53 +00:00
alex fa747145ce Hash whole plan steps under payload version 2
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).
2026-12-01 11:19:33 +00:00
alex 8bc08bd08a Project the workflow journal from run state
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.
2026-12-01 11:18:13 +00:00
alex 621f6e2579 Make the workflow supervisor host seam real
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.
2026-12-01 11:09:26 +00:00
alex 7114650aed Split workflow modules by concern: plan, run, command 2026-12-01 10:55:35 +00:00
alex c6dae27ec4 Journal each-step items as per-item rows
Each `pi-workflow-run-v1` step record now carries `items`: one row per
fanned-out child with its source line, a stable per-item input hash, status,
attempt count, bounded output, and timings, alongside the step's aggregate
record. The format has shipped nowhere, so it is extended in place.

Item identity (`itemValue`) now rides the task identity into the child's
snapshot instead of living only on the manager's internal task, so the
journal reads the line the child actually ran rather than re-deriving it
from the source output. Item hashes key the plan, step, args, and item line
— never prior outputs — so identical items hash alike across runs, and item
outputs use the same bound and truncation marker as step outputs.

Persistence validates the rows (one-based index, required fields) and the
optional item identity on job snapshots. Round-trip tests cover restore,
bounding, and hash stability, plus a property test for the hash inputs.
2026-11-26 20:09:54 +00:00
alex 5baa7f4508 Merge ticket/t6-journal: journal workflow runs as resume-ready entries
Resolve the t4/t6 overlap in index.ts by keeping the trust-gated workflow
start path and adding the journal persistence hook and entry renderer.

Adapt journal step lookup to the item engine: an each-step's item children
share their step's id, so the run journal records one row per plan step from
the coordinator's aggregate status and joined output. Per-item journal rows
remain a follow-up. Adds a regression test for the seam.
2026-11-26 19:30:47 +00:00
alex e6f062f402 Journal workflow runs as resume-ready entries 2026-11-26 19:24:14 +00:00