feat(round-recover): cross-process round recovery — RECOVER + STATUS + GoalLock (SHAPE-1, LD3-LD11)
What
Implements the round-recovery feature (SHAPE-1) per the locked decisions LD3–LD11
from flow/findings/round-recovery/2026-07-12-locked-decisions.yaml. Adds two new CLI
subcommands and an exclusive goal lock so that when jewilo is killed mid-round, its
already-spawned verifier orphans' verdicts can be harvested instead of discarded.
Closes the round-recovery exploration (10/10 threads resolved, 11 locked decisions).
Why
jewilo blocks at a gather barrier while m verifier backends run. If jewilo is killed
mid-round (TTY SIGINT, non-TTY SIGTERM, supervisor restart, OOM), the spawned verifier
children are orphaned. Today the only path is RESUME N+1, which increments the round,
re-captures the snapshot, re-renders the prompt, and mints fresh signing keys —
discarding any in-flight verdict the orphans are about to write. There is also no
machine-readable STATUS and no mutual exclusion to prevent two concurrent operations
from corrupting the same goal.
Changes
New module src/round_recover (95.60% line coverage):
GoalLock(LD5) — RAII guard over an exclusiveflockon
goals/<goalId>/.lock, held by NEW/RESUME/RECOVER for their full duration. Fail-fast
try_lock→ a concurrent op exits non-zero with agoal busymessage. Drop releases;
advisory locks survive no process crash.status(LD7) — read-only probe (no lock) emitting{goalId, round, state, needs, slots}JSON.state ∈ {new, in_progress, consensus_pass, consensus_fail};
needs ∈ {done, recover, resume}. Every slot always carries averdictfield (null
included). Distinguishes interrupted-pass (all-APPROVE, no completion →recover) from
decided-failed (below n →resume).recover(LD8/LD10/LD11) — wait-only: pollsverdict.jsonfor the current round,
reusesconsensus::evaluate+compute_hash+write_completionunchanged (the
verdict file is the resumption contract). NEVER spawns, kills, re-renders, or
re-captures (the signature takes no prompt/snapshot). Dead-null slot after timeout →
StillNullAfterwithRESUME N+1guidance (no key minted, fail-closed D9). Decided-
failed round returnsRoundDecidedNoConsensuspromptly without the full timeout.
CLI wiring (LD3):
RECOVER <goalId>andSTATUS <goalId>subcommands.- RECOVER on a complete round warns
use RESUME N+1and exits 0. - RESUME on a round with null verdicts warns about RECOVER (symmetric) but proceeds.
run_new/run_resume/run_recoverall acquireGoalLock.
Vocabulary (LD4): recover (cross-process, this module) vs compaction_recover
(within-round same-process, already in the spawn orchestrator).
No threat-model regression
Per-slot signing secrets stay unpersisted (live only in the original child env).
RECOVER never mints, reads, or needs them. No PID file (LD9). No snapshot TTL (LD11).
The frozen-snapshot-per-round invariant holds (LD10). See design.md §Threat model.
Verification
- Verifier loop: 2/2 unanimous APPROVE (round 2). Completion hash
071126-a9b37324,
fullDigest incompletion.jsonfor goaldfe264a1. Round 1 was a REJECT (3 findings
W1/W2/W3, all fixed ina6bd30e); round 2 approved. - Tests: 343 green (16 new: 12 lib in
tests/round_recover.rs+ 6 CLI e2e in
tests/round_recover_cli.rs[one shared with STATUS]). Includes the e2e-surfaced
STATUS interrupted-pass fix (ae87fe9). - Coverage:
cargo llvm-cov --fail-under-lines 80= EXIT 0;round_recover/mod.rs
95.60% lines. - jewilo-dev e2e kill/resume/pickup: built the worktree as
jewilo-dev, ranNEW
with a slow stub, killed mid-round via SIGTERM → orphan stubs survived (LD6) and wrote
signed APPROVE verdicts →STATUSreportedneeds: recover→RECOVERharvested
both verdicts and wrotecompletion.json(hash071126-f4ba80f6) →STATUSreported
done. The exact kill/RESUME/pickup cycle from the objective.
Spec
openspec/changes/add-round-recovery/ — proposal.md, design.md, tasks.md, and specs:
round-recovery, goal-status, goal-lifecycle (MODIFIED delta).
Out of scope
PID files (LD9), secret persistence (LD8 path-b rejected), snapshot TTL (LD11), re-render
in RECOVER (LD10), OT1/OT2/OT6 (existing non-goals).
Summary by cubic
Adds cross-process round recovery to verifier-loop so in-flight verdicts aren’t lost when jewilo is killed mid-round. Implements SHAPE-1 (LD3–LD11) with RECOVER, STATUS, and an exclusive goal lock; after an interruption run STATUS, then RECOVER or RESUME as directed.
-
New Features
GoalLock— exclusive lock atgoals/<goalId>/.lockheld byNEW/RESUME/RECOVER; concurrent commands fail fast with “goal busy”.STATUS <goalId>— read-only JSON:goalId,round,state,needs(done|recover|resume), andslots(each has averdict, null included). Distinguishes interrupted-pass from consensus-fail.RECOVER <goalId>— wait-only: polls per-slotverdict.json, reuses consensus + hash, never spawns/kills/re-renders/re-captures. If a slot stays null, exits withRESUME N+1guidance; if already decided-fail, exits quickly.
-
Bug Fixes
GoalLocknow maps only “WouldBlock” to “goal busy”; other lock errors surface their real I/O cause.GoalLockvalidates the goal exists before locking and returnsGoalNotFound(no phantom goal dir with only.lock).- Polling clamps sleep to remaining time before the deadline so timeouts aren’t overshot.
- CLI
RECOVERfails fast onneeds: "resume"(guidance + non-zero), warns and exits ondone, proceeds only onrecover.
Summary by CodeRabbit
- New Features
- Added
RECOVER <goalId>for wait-only same-round recovery by polling existing per-slot verdicts and re-running consensus evaluation. - Added
STATUS <goalId>returning read-only, machine-readable JSON (round/state, next action, and per-slot verdicts). - Added goal-lock concurrency protection to prevent simultaneous round-changing operations and return clear “busy” errors.
- Added guidance behavior to choose between
RECOVERandRESUMEbased on current slot status.
- Added
- Bug Fixes
- Fail-closed recovery: does not write incomplete completion output when verdicts remain unavailable.
- Tests
- Added end-to-end coverage for CLI NEW/STATUS/RECOVER/RESUME, locking, polling-based recovery, and failure scenarios.