Browse the documentation
CAP-12: Step graph, checkpoints, resume, interrupts
- ID:
CAP-12 - Title: Step graph, checkpoints, resume, interrupts
- Lead:
seed - Touches:
bloom - Horizon:
later - Milestone:
M7 - CLI phase: none
- Status:
proposed - Claim:
planned - Depends on:
CAP-06,CAP-10
Why
Stage 1 src/resume.mjs handles linear in-process step lists (resumeSteps) with skipped completed IDs and abort codes, but multi-step workflows also need shared state merging across branches, conditional routing checked before execution, post-step checkpoints with parent links, fork from prior checkpoints, configurable durability modes, per-step retry policies by failure class, and clean interrupt/resume semantics that obey intent-first rule 3.
What it does
CAP-12 specifies a declarative step graph engine contract in seed and its runtime execution in bloom:
- Step graph over shared state with per-key merge rules:
- A graph declares named step nodes operating on a shared state object.
- Every key in the shared state schema declares a merge rule:
replace(single writer or deterministic last-in-plan-order overwrite),append(ordered list concatenation in deterministic branch order), or anamed reducer(identifier referencing a caller-supplied pure reducer function in a closed reducer table). - Conflicting concurrent writes to a
replacekey within the same parallel superstep fail validation unless ordered explicitly.
- Declarative conditional routes checked pre-run:
- Edges between steps are declarative route definitions (
from, optionalconditionname matching a caller-supplied pure predicate table,tostep ID or terminal state). - Before any step executes, the graph validates that every referenced step ID, reducer name, and route condition name exists, and that step bounds or loop limits are explicitly declared (failing closed pre-run if invalid).
- Edges between steps are declarative route definitions (
- Post-step checkpoints and parallel pending writes:
- After each step (or parallel superstep), the engine produces a checkpoint record containing
{ checkpointId, runId, attempt, stepId, parentCheckpointId, stateDigest, state, completedWrites, createdAt }. parentCheckpointIdlinks back to the prior checkpoint in an immutable chain;stateDigestholds the 64-hex SHA-256 digest of the canonical merged state.completedWritesrecords outputs from any peer branches in a parallel superstep that succeeded before another peer failed or interrupted, so partial progress in completed parallel branches is never lost or re-executed blindly.
- After each step (or parallel superstep), the engine produces a checkpoint record containing
- Interrupt pause and resume (intent-first rule 3):
- When a step hits an interrupt (an owner gate pause via
CAP-06or an operator pause), the graph records the latest checkpoint and pending intents and transitions cleanly towaiting_for_ownerorstopping. - On resume, any step without a completion checkpoint re-runs from the start of that step, reading
recordedIntentsfirst perdocs/contracts/run-model.mdrule 3 so any unclear non-idempotent intent goes to the owner rather than silently repeating a side effect.
- When a step hits an interrupt (an owner gate pause via
- Fork from an earlier checkpoint:
- A caller can fork a new attempt or objective starting from a prior
checkpointId. Forking copies the checkpoint’s state, records the fork’sparentCheckpointId, issues a fresh attempt and lease, and leaves the original checkpoint lineage untouched.
- A caller can fork a new attempt or objective starting from a prior
- Per-run durability mode:
- Each run selects a durability mode explicitly:
per-step(persist checkpoint after every step before advancing),on-interrupt(persist at interrupts, failures, and completion), ornone(in-memory only, matching Stage 1resumeSteps). The engine never silently downgrades durability.
- Each run selects a durability mode explicitly:
- Per-step retry policy by failure class:
- Steps may declare bounded retry rules keyed to
FAILURE_CLASSESindocs/contracts/run-model.md. - Transient external failures (
external-unavailable,external-exec-failed) may retry up to the declared cap using a caller-injected clock/scheduler; authority or contract errors (policy-denied,gate-denied,tool-unknown,tool-not-canonical,schema-invalid,external-incompatible) never auto-retry.
- Steps may declare bounded retry rules keyed to
Contract touchpoints
seed:docs/contracts/run-model.md(extends step execution from linearresumeStepsto declarative step graphs, checkpoints, interrupts, forks, durability modes, and failure-class retry rules while preserving rules 1-6).bloom:docs/architecture.md(executes step graphs withCAP-13persistence, checkpoint tool handlers, and interrupt/resume wiring).
Tool IDs and events
Tool IDs
| Tool ID | Effect | Third-party egress | Owner gate | Summary |
|---|---|---|---|---|
run.checkpoint.read |
read |
false |
false |
Read a recorded step checkpoint by ID or fetch the latest checkpoint for the active run. |
run.checkpoint.create |
write |
false |
false |
Record an explicit post-step checkpoint carrying parentCheckpointId, stateDigest, and completedWrites. |
run.step.cancel |
write |
false |
true |
Cancel a pending or paused step in the active run and transition cleanly toward stopping. |
Events
None defined in seed. Step graph lifecycle and checkpoint events emitted by bloom use the CAP-10 event stream.
| Event | Emitter | Payload summary |
|---|
Acceptance tests
graph-pre-run-validation-fails-closed: Missing step targets, unknown reducer names, or unregistered conditional route names throw before any step executes.state-merge-replace-append-reducer: Parallel and sequential step writes merge deterministically underreplace,append, andnamed reducerrules, yielding identicalstateDigestvalues on replay.checkpoint-parent-chain-and-parallel-writes: Every post-step checkpoint linksparentCheckpointId, recordsstateDigest, and preservescompletedWritesfrom parallel peers that succeeded before an interrupt or partial failure.interrupt-resume-respects-rule-3: Resuming from an interrupt re-runs the interrupted step from its start, skips prior checkpointed steps, and refuses to silently repeat an unresolved non-idempotent recorded intent.fork-preserves-prior-checkpoint-lineage: Forking from an earlier checkpoint starts a new attempt/branch without mutating any state or links in the original lineage.retry-policy-by-failure-class: Steps retry transientexternal-unavailableorexternal-exec-failedoutcomes up to their cap, and immediately stop without retryingpolicy-denied,gate-denied, orschema-invalid.durability-mode-honored:per-stepwrites checkpoints before advancing each step,on-interruptcheckpoints on pause/finish, andnonestays strictly in memory.
Slices
CAP-12.1(seed, milestoneM7, statusproposed): Step graph schema, pre-run route/reducer validation, per-key state merge (replace,append, named reducer), and failure-class retry policies (seed).CAP-12.2(seed, milestoneM7, statusproposed): Post-step checkpoint records withparentCheckpointIdandstateDigest, parallelcompletedWrites, fork, per-run durability modes, and interrupt pause/resume (seed).CAP-12.3(bloom, milestoneM7, statusproposed): Runtime graph executor,run.checkpoint.read/run.checkpoint.create/run.step.cancelhandlers, and interrupt/fork CLI/UI wiring (bloom).
Non-goals
- Writing directly to disk or SQLite from
seed(persistence belongs toCAP-13andbloom). - Executing arbitrary inline code strings in route conditions or reducer declarations (conditions and reducers are named lookups against caller-supplied pure JS maps).
Family rules and conflicts
- Intent-first rule 3: Checkpoints never authorize blind re-execution of non-idempotent recorded intents; unclear intents pause for the owner (
CAP-06). - One authority per fact: Checkpoints store run graph state and digests only, never duplicating
myosotismemory records orcapillarycontext packets.
Open owner decisions
- Checkpoint retention and built-in reducer set: Whether
seedships a small default table of named reducers alongside caller-supplied reducers, and whether checkpoint pruning/compaction policy lives inCAP-13store configuration or per-run options (pending owner guidance whenM7opens).
Evidence
The in-process resume rules are implemented and exercised by test/resume.test.mjs,
and by test/harness-run.test.mjs for the receipt-over-intent rule across a restart.
Step graphs, checkpoints, fork, and interrupts remain specified (CAP-12.2), so the
capability claim stays planned.
Changes
2026-11-24: Evidence section records the in-process resume coverage, including the receipt-over-intent rule across a restart (test/harness-run.test.mjs).2026-11-23: AddedM7slice milestones acrossCAP-12.1..CAP-12.3.2026-11-23: Initial capability specification created (CAP-01.2scaffold).