Revision: 1 Last modified: 2026-12-04T19:00:00Z
handoff.py writes, validates and re-validates a Handoff Record — the document an interrupted agent
leaves behind so a successor can resume without repeating effects that already happened.
The hard half is not writing the record; it is answering "is it still safe to resume?". A handoff says
"here is what I verified, here is what I did, here are my external dependencies". Between the handoff and
the resume, any of those can change. So resume-check re-hashes every external_dep, and on a mismatch
it lists both the verified facts that must be re-verified and the effects_performed that must not
be repeated.
That second list is the one that matters. Re-running an effect that already succeeded is how a resume double-charges, double-sends or double-deletes. The record exists so a successor can tell the difference between "I have not done this yet" and "my predecessor did this and I must not do it again".
Two documented dependents make this concrete: the project's own resume guidance and the DEC-34 "Safe to Resume?" framework. DEC-34 supplies no prescriptive fix, so the revalidation design here is original, extended by T126's five-class rule set rather than copied.
python3(stdlib only).scripts/fastcycle/lib/fc_entry.pybeside it — this tool routes its CLI through the shared entry primitive, so its exit status cannot be corrupted by a broken stdout pipe.- A handoff JSON document for
validate/verify/resume*. - No environment variables are read.
# write a handoff record
python3 scripts/fastcycle/orchestration/handoff.py write \
--item-id ATM-953 --agent-key agent-a \
--out handoff.json
# validate it (structural + self-integrity + partial-artefact hashes)
python3 scripts/fastcycle/orchestration/handoff.py validate \
--handoff handoff.json --out validate-result.json
# `verify` is the same operation under HO-002's own wording
python3 scripts/fastcycle/orchestration/handoff.py verify \
--handoff handoff.json --out verify-result.json
# the important one: is it still safe to resume?
python3 scripts/fastcycle/orchestration/handoff.py resume-check \
--handoff handoff.json --out resume-result.json
# `resume` is the same operation under T134's own wording
python3 scripts/fastcycle/orchestration/handoff.py resume \
--handoff handoff.json --out resume-result.json--item-id accepts the literal NONE for a handoff not bound to a workable item.
Per subcommand, verbatim from the contract's "Exit codes" line ("Handoff: 0 ok, 1 hash mismatch / missing field"):
| Subcommand | 0 |
1 |
2 |
|---|---|---|---|
write |
OK | A declared --partial-artefacts path does not exist ("missing field") |
Usage: bad/unreadable args, malformed --*-json |
validate / verify |
VALID |
INVALID — self-integrity mismatch, or a partial-artefact hash mismatch / missing file (HO-002: "exits 1 on any difference") |
Usage: --handoff missing, unreadable, or not a JSON object |
resume / resume-check |
Safe — safe_to_resume_without_reverification=true |
Unsafe — one or more unsafe_reasons |
Usage: --handoff missing, unreadable, or not a JSON object |
The resume* 1 is not an error: it is the tool doing its job, and unsafe_reasons is the payload the
successor needs.
verifyandvalidateare the same operation. They exist under two names because HO-002's own contract wording saysverifyand the implementation calls itvalidate. Both behave identically; this is documented rather than silently aliased (§11.4.6).resumeandresume-checkare likewise identical, for the same reason (contract Components-line wording vs. T134's task-line wording).- A
--partial-artefactspath that vanished after the record was written.validatereportsINVALIDwith a missing-file reason; do not resume past it. - An
external_depwhose content changed but whose path is unchanged. Detected by re-hash, which is precisely why the check re-hashes rather than comparing paths or mtimes. - A handoff that is valid JSON but not an object. Usage error (
2) — not aVALID/INVALIDverdict, because there is no record to judge. - A handoff with no external deps and no recorded effects. Trivially safe;
resume-checkreturns0rather than inventing a concern.
- Routes through
fc_entry.run_cli_main, so the exit status is set explicitly and the process exits without a shutdown flush that could corrupt it. - Dispatches on the subcommand.
write: assembles the record from the supplied fields, hashing each partial artefact, and writes it.validate/verify: parses the record and checks structural completeness, the record's own self-integrity hash, and every partial artefact's hash.resume-check/resume: re-hashes everyexternal_dep; on mismatch, assemblesunsafe_reasonsand the two consequence lists —verifiedfacts to re-verify, andeffects_performedthat must not be repeated.- Writes
--outand returns the subcommand's code.
Imports scripts/fastcycle/lib/fc_entry.py.
Guarded by scripts/fastcycle/tests/test_handoff_red.sh (T125, for write/validate/verify) and
scripts/fastcycle/tests/test_resume_revalidate_red.sh (T126, for resume/resume-check), with fixtures
under scripts/fastcycle/tests/fixtures/handoff/ and
scripts/fastcycle/tests/fixtures/resume_revalidate/. Round-6 and round-7 regression suites also cover
it.
Contracts: specs/004-fast-dev-cycles/contracts/agent-registry-and-handoff.md (HO-001, HO-002, HO-003);
data-model §9.2 "Handoff Record"; research.md DEC-34 (arXiv 2608.29381).
See also docs/scripts/fc_entry.py.md and docs/scripts/limit_class.py.md (a sibling orchestration tool
on the same entry primitive).
2026-12-04 — python3 -c "import ast;ast.parse(open('scripts/fastcycle/orchestration/handoff.py').read())"
→ exit 0. python3 scripts/fastcycle/orchestration/handoff.py with no subcommand exits 2 with a usage
message.