What a run snapshot contains, and that it never fails the run
A snapshot is a best-effort record of progress. It is precise about what it carries, and it is never allowed to be the reason a run breaks.
The rule
- A snapshot of a run MUST carry the workflow identifier, the structural workflow version (INT-7), the execution identifier, the caller-supplied status, the run's initial input, metadata naming the engine and the run, and one node snapshot per node that has a job, keyed by node identifier.
- A node snapshot MUST describe the node's latest terminal job, where it has one, and MUST list every job of the node that has not reached a terminal status, each with its stamp (SG-17), or without one for a job that has no round yet (SG-21), so that a resume finds every job still waiting, whatever its round.
- Where the run has no workflow, the workflow identifier MUST be the literal
unknownand the workflow version MUST be absent. - For each job a node snapshot describes, job status MUST map one-to-one onto node status, except that both
skippedandcancelledMUST becomeskipped,dispatchedMUST becomepending, and any unrecognised status MUST becomeidle. - A
pollingjob MUST staypolling. - A run resumed from the snapshot MUST NOT execute a polling node as new work, which would start its external work a second time.
- A node's output MUST be carried only for a completed job, and its error only for a failed one.
- Each node snapshot MUST also carry whether the node was injected, and, for each job it describes, its execution order and its job identifier.
- Snapshot generation MUST NOT fail the run: where no state is available, or generation raises an error, the result MUST be no snapshot, recorded in the log.
What it means
A snapshot's per-node status is not a direct copy of the job status behind it — two collapses are deliberate, and both go against the more intuitive guess. A cancelled job is recorded as skipped, not as failed and not with its own separate status: a cancelled node did not run, and a resume has no reason to treat "did not run because cancelled" any differently from "did not run because the workflow finished first." A status the reader does not recognise at all becomes idle, on the same reasoning: unrecognised means "not done yet," the only assumption that cannot make a resume worse. Output and error are gated the other way round from what a merge might suggest: a job's output is carried only when that job actually completed, and its error only when it actually failed — a failed job never carries stale output forward, and a completed one never carries a phantom error.
Two statuses are restored with care for what a resume would do with them. A
dispatched job was claimed by a worker that may be long gone, so it is
recorded as pending and claimed again. A polling job has already started
its outside work, so it stays polling: turning it into idle would have the
resumed run start that work a second time.
A node inside a loop can have a job per round, and several of them can still be open at once: a late job of round 0 and the jobs of rounds 1 and 2, all waiting. A snapshot keeps one entry per node, keyed by its identifier, and that entry lists every open job with its stamp, beside the node's latest finished job. Showing only the newest job would misreport an earlier round's job that is still interrupted, and a resume from it would lose the earlier rounds' jobs. A job made early that no edge has reached yet is listed without a stamp.
None of this is meant to cost the run anything. Where there is no state to read, or producing the snapshot itself raises an error, the result is simply no snapshot — recorded in the log, not thrown.
Example
Four jobs mid-pause, and what the snapshot records for each.
{ "n_done": "completed", "n_failed": "failed", "n_cancelled": "cancelled", "n_bogus": "not_a_status" }{
"n_done": { "status": "completed", "output": { "result": "ok" } },
"n_failed": { "status": "failed", "error": "it blew up" },
"n_cancelled": { "status": "skipped" },
"n_bogus": { "status": "idle" }
}A run with no workflow behind it still gets a snapshot, with a placeholder identity and no version at all. Leaving the version out, rather than writing an empty one, is what lets INT-8 skip the version check for it: an empty version would be compared.
{ "workflowId": "unknown" }