Repository navigation
feat(round-recover): cross-process round recovery — RECOVER + STATUS + GoalLock (SHAPE-1, LD3-LD11) - #42
Conversation
Cross-process round recovery for when jewilo is killed mid-round. Implements
the locked decisions from flow/findings/round-recovery/2026-07-12-locked-decisions.yaml.
New module src/round_recover (95.48% line coverage):
- GoalLock: exclusive flock on goals/<goalId>/.lock held by NEW/RESUME/RECOVER
for their full duration (LD5). Fail-fast try_lock => second concurrent op exits
non-zero "goal busy". Drop releases; advisory lock survives no process crash.
- status: read-only probe (no lock) emitting {goalId, round, state, needs, slots}
JSON (LD7). needs in {done, recover, resume}; state in {new, in_progress,
consensus_pass, consensus_fail}.
- recover: SHAPE-1 wait-only (LD8/LD10/LD11). Polls verdict.json for the current
round, reuses consensus::evaluate + compute_hash + write_completion unchanged
(verdict file = resumption contract). NEVER spawns, kills, re-renders, or
re-captures (signature takes no prompt/snapshot). Dead-null slot after timeout
=> StillNullAfter with RESUME N+1 guidance (no key minted, fail-closed D9).
Decided-but-failed round returns RoundDecidedNoConsensus promptly without the
full timeout wait.
CLI wiring (LD3):
- RECOVER <goalId>, STATUS <goalId> subcommands.
- RECOVER on a complete round warns + exits 0 (use RESUME N+1).
- RESUME on a round with null verdicts warns about RECOVER (symmetric).
- run_new/run_resume take GoalLock for the whole round.
Vocabulary (LD4): recover (cross-process, this module) vs compaction_recover
(within-round same-process, already in spawn orchestrator).
No threat-model regression: per-slot signing secrets stay unpersisted; RECOVER
never mints, reads, or needs them. No PID file (LD9). No snapshot TTL (LD11).
Tests: 16 new (10 lib in tests/round_recover.rs + 6 CLI e2e in
tests/round_recover_cli.rs). Full suite 341 green. Coverage gate
cargo llvm-cov --fail-under-lines 80 = EXIT 0.
Specs: openspec/changes/add-round-recovery/{proposal,design,tasks}.md +
specs/{round-recovery,goal-status,goal-lifecycle}/spec.md.
W1 (spec violation, observable): SlotStatus.verdict was Option<VerdictStatus>
with skip_serializing_if=Option::is_none, so a null slot serialized as
{"id":"v2"} with NO verdict key — contradicting the goal-status spec
("STATUS shape": every slot has an id AND a verdict field, null included).
Fixed: verdict is now VerdictStatus (Null serializes to JSON null via the
custom Serialize), so a null slot emits {"id":"v2","verdict":null}. Added
status_null_slot_emits_verdict_null_key test asserting the key exists +
is null; strengthened the CLI e2e to assert the verdict key too.
W2 (dangling reference): design.md + AGENTS.md cited
flow/findings/round-recovery/2026-07-12-locked-decisions.yaml which was
absent from the worktree. Carried the round-recovery findings dir in so
the cited source-of-truth resolves.
W3 (spec-order deviation): run_new acquires GoalLock AFTER goal::new
(unavoidable — the .lock file lives under goals/<goalId>/ which goal::new
creates). Documented as an accepted deviation in design.md §4.1: safe
because goalId is a fresh random UUID so concurrent NEWs cannot collide;
the lock still serializes RESUME/RECOVER/second-NEW-on-same-goal against
the spawn phase (its LD5 job). Also documented needs=Recover for state=New
as a vacuous edge (RECOVER on a brand-new goal polls to StillNullAfter).
All 342 tests green; coverage gate --fail-under-lines 80 EXIT 0;
round_recover/mod.rs 95.48% lines.
…rfaced) The jewilo-dev e2e (kill mid-round → orphan verifiers write APPROVE → RECOVER harvests) surfaced a STATUS derivation bug: when every slot is non-null AND the raw APPROVE count already reaches n but completion.json is absent (the round was interrupted after verdicts landed but before the gather barrier wrote completion.json), STATUS reported needs="resume" / state="consensus_fail" — misdirecting the caller to start a fresh round and discard the already-landed verdicts. Fix: in the all-non-null-no-completion branch, distinguish APPROVE>=n (round WOULD pass — RECOVER can finish it → needs="recover", state="in_progress") from below-n (genuinely decided-failed → needs="resume", state="consensus_fail"). The APPROVE count is a heuristic (STATUS is read-only and does not run the signature gate); RECOVER authoritatively decides via consensus::evaluate. Updated the goal-status spec to document both recover sub-cases (null slot OR interrupted-pass). Added status_needs_recover_when_all_approve_but_no_completion test. Re-ran the full jewilo-dev e2e: kill → orphans write APPROVE → STATUS now correctly reports needs=recover → RECOVER harvests → completion hash 071126-f4ba80f6 → STATUS done. 343 tests green; coverage gate --fail-under-lines 80 EXIT 0; round_recover/mod.rs 95.60% lines.
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
📝 WalkthroughWalkthroughThis change adds SHAPE-1 round recovery with wait-only ChangesRound recovery
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant CLI
participant GoalLock
participant RoundRecover
participant VerdictFiles
participant Consensus
User->>CLI: RECOVER goalId
CLI->>GoalLock: acquire exclusive lock
CLI->>RoundRecover: recover goal
loop until consensus, decision, or timeout
RoundRecover->>VerdictFiles: read verdict.json files
RoundRecover->>Consensus: evaluate verdicts
end
Consensus-->>RoundRecover: pass or fail
RoundRecover-->>CLI: completion hash or guidance
CLI-->>User: result
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
Kilo Code Review could not run — your account is out of credits. Add credits or switch to a free model to enable reviews on this change. |
There was a problem hiding this comment.
Code Review
This pull request implements cross-process round recovery (SHAPE-1) by introducing the RECOVER and STATUS subcommands, along with an exclusive advisory GoalLock for mutual exclusion on goal directories. The recovery mechanism is wait-only, polling for existing verifier verdicts without spawning new processes or persisting secrets. Feedback on the implementation suggests improving error handling during lock acquisition by only mapping WouldBlock errors to GoalBusy, clamping the sleep interval in the polling loop to respect the timeout deadline precisely, and failing fast in the recovery command if the goal status already indicates that a resume is needed.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| file.try_lock_exclusive() | ||
| .map_err(|_| RoundRecoverError::GoalBusy)?; |
There was a problem hiding this comment.
Unconditionally mapping all try_lock_exclusive errors to GoalBusy can be highly misleading. If the lock fails due to other system or filesystem errors (e.g., permission denied, or locking operations not being supported on network filesystems like NFS), the operator will see a confusing "goal busy" error instead of the actual underlying system issue. We should inspect the error kind and only return GoalBusy if it is WouldBlock.
if let Err(err) = file.try_lock_exclusive() {
return Err(if err.kind() == std::io::ErrorKind::WouldBlock {
RoundRecoverError::GoalBusy
} else {
RoundRecoverError::Io(err)
});
}There was a problem hiding this comment.
Fixed in 2de4de4: only WouldBlock maps to GoalBusy now; any other error kind surfaces as Io with the real cause.
| return Ok(RecoverOutcome::StillNullAfter { | ||
| null_slots, | ||
| guidance: format!( | ||
| "round {round} still has null verdict slots after the recovery timeout; \ | ||
| run `jewilo RESUME {goal_id}` for fresh slots and fresh keys" | ||
| ), | ||
| }); | ||
| } | ||
|
|
||
| std::thread::sleep(poll_interval); | ||
| } |
There was a problem hiding this comment.
In recover_with_poll, if the remaining time before the deadline is less than poll_interval, the thread will still sleep for the full poll_interval, overshooting the configured timeout. Clamping the sleep duration to the remaining time ensures the function returns promptly once the timeout is reached.
let now = Instant::now();
if now >= deadline {
return Ok(RecoverOutcome::StillNullAfter {
null_slots,
guidance: format!(
"round {round} still has null verdict slots after the recovery timeout; \
run `jewilo RESUME {goal_id}` for fresh slots and fresh keys"
),
});
}
let remaining = deadline.duration_since(now);
std::thread::sleep(poll_interval.min(remaining));There was a problem hiding this comment.
Fixed in 2de4de4: the poll sleep is now clamped via deadline.saturating_duration_since(now) + min(remaining), so the configured timeout is never overshot.
| let st = round_recover::status(root, goal_id, config).map_err(|e| format!("STATUS: {e}"))?; | ||
| if matches!(st.needs, round_recover::GoalNeeds::Done) { | ||
| eprintln!( | ||
| "round {} already reached consensus; use `jewilo RESUME {goal_id}` to start a new round", | ||
| st.round | ||
| ); | ||
| return Ok(()); | ||
| } |
There was a problem hiding this comment.
If st.needs is GoalNeeds::Resume, the round is already decided but failed. Calling recover in this state is guaranteed to fail with RoundDecidedNoConsensus after acquiring the lock and performing redundant disk reads. We can fail-fast immediately in run_recover to avoid lock contention and unnecessary I/O.
let st = round_recover::status(root, goal_id, config).map_err(|e| format!("STATUS: {e}"))?;
match st.needs {
round_recover::GoalNeeds::Done => {
eprintln!(
"round {} already reached consensus; use `jewilo RESUME {goal_id}` to start a new round",
st.round
);
return Ok(());
}
round_recover::GoalNeeds::Resume => {
eprintln!(
"round {} is decided but did not reach {}/{} consensus; \
run `jewilo RESUME {goal_id}` for a fresh round",
st.round, config.n, config.m
);
return Err(format!("round {} rejected", st.round));
}
round_recover::GoalNeeds::Recover => {}
}There was a problem hiding this comment.
Fixed in 2de4de4: run_recover now dispatches on st.needs — Done warns + exits 0, Resume fails fast with guidance (no lock/redundant I/O), only Recover proceeds to poll.
1. GoalLock: only map WouldBlock -> GoalBusy. Previously ALL try_lock_exclusive errors were mapped to GoalBusy, so a permission-denied or NFS-unsupported-lock error would mislead the operator with "goal busy". Now only WouldBlock (lock held by a cooperating writer) is GoalBusy; everything else surfaces as Io with the real cause. (gemini comment 3565064711) 2. recover_with_poll: clamp the poll sleep to the remaining time before the deadline so the configured timeout is never overshot by up to one poll_interval. Uses deadline.saturating_duration_since(now) + min(remaining). (gemini comment 3565064713) 3. run_recover: fail fast when STATUS reports needs=Resume (round decided-failed) instead of acquiring the lock + doing redundant disk reads only to return RoundDecidedNoConsensus. Now the CLI dispatches on st.needs: Done -> warn + exit 0; Resume -> guidance + exit non-zero; Recover -> proceed to poll. (gemini comment 3565064715) 343 tests green; coverage gate --fail-under-lines 80 EXIT 0; round_recover/mod.rs 95.24% lines.
There was a problem hiding this comment.
Actionable comments posted: 18
🧹 Nitpick comments (2)
tests/round_recover_cli.rs (1)
208-214: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winUse a genuinely short timeout for dead-null coverage.
This test describes
verifierTimeoutSecas small but configures it to 10 seconds. Since RECOVER waits for the null slot, the test can consume the full timeout; the shared setup also slows the RESUME warning test. Use a 1-second test timeout or a dedicated test-only override.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/round_recover_cli.rs` around lines 208 - 214, Reduce the verifierTimeoutSec used by recover_dead_null_round_exits_nonzero_with_resume_guidance from 10 seconds to a genuinely short 1-second test value, or apply a dedicated test-only override. Keep the dead-null recovery and RESUME guidance assertions unchanged, and ensure the shared setup does not impose the longer timeout on the RESUME warning test.src/round_recover/mod.rs (1)
358-391: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
finish_pass/verifier_idduplicate logic already insrc/bin/verifier_loop.rs'srun_round.
finish_passintentionally mirrorsrun_round's success path (signature read,compute_hash,write_completion) "so RECOVER's hash is byte-identical," andverifier_idmirrors the bin's own id-formatting helper. Keeping two independent copies risks silent divergence (e.g. a future tweak to the hash inputs in one call site but not the other), which would directly undermine the byte-identical-hash guarantee this module relies on. Consider extracting the shared completion-writing logic (and the trivialverifier_idformatter) into a single function inconsensus/goalthat bothrun_roundandfinish_passcall.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/round_recover/mod.rs` around lines 358 - 391, Extract the shared completion-record/hash logic from finish_pass and verifier_loop::run_round into a single reusable function in the appropriate consensus or goal module, then update both callers to use it while preserving identical hash inputs and write behavior. Also centralize the v1/v2 formatting currently duplicated by verifier_id and the verifier loop’s helper, updating both call sites to use the shared formatter.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@flow/findings/round-recovery/2026-07-12-locked-decisions.yaml`:
- Around line 1-22: Resolve the authority conflict between LD1 and LD8 by
updating the decision metadata: either mark LD1 explicitly superseded by the
authorized LD8 decision, or record the required user relock instead of leaving
it locked. Update the affected decision entries consistently so implementers
cannot select the unsafe shape-2 recovery behavior.
- Around line 120-123: The STATUS slot schema is inconsistent because LD7
requires has_live_orphan while SlotStatus and goal-status/spec.md omit it. Add
has_live_orphan end-to-end in the SlotStatus implementation and specification,
ensure STATUS JSON populates it for every slot, and preserve the documented id
and verdict fields.
In
`@flow/findings/round-recovery/2026-07-12-path-b-resistance-secrets-persist.md`:
- Line 210: Update the fenced LOC summary block in the round-recovery document
to specify the text language, changing the opening fence to use text while
preserving the block’s contents.
- Around line 192-205: Update the scope classification in the “ADDITIONAL SCOPE
unlocked by secrets-persist” section so item 4.5, concurrent-RECOVER flocking,
is explicitly required under shape-1 rather than marked moot. Preserve its LD5
requirement for exclusive locking across NEW, RESUME, and RECOVER, including
wait-only recovery, and ensure the implementation plan retains the
goals/<goalId>/.lock coordination.
In `@flow/findings/round-recovery/2026-07-12-turn4-lock-shape2-recovery.md`:
- Around line 13-42: Mark the locked Shape 2 recovery contract in the
round-recovery record as superseded, and document that the final Shape 1
contract was selected instead. Replace the PID-kill, SID-resume, spawning,
re-rendering, recapture, and signing-secret behavior with wait-only polling that
performs none of those operations.
In `@flow/findings/round-recovery/2026-07-12-turn4a-gotcha-recovery-safety.md`:
- Around line 188-196: Add a resolution table to the round-recovery document
that explicitly records the disposition of G1–G11. Mark PID-kill and fresh-spawn
concerns as superseded, identify G3 and G9 as addressed by GoalLock/STATUS and
the machine contract, and label the remaining gotchas as deferred or covered;
update the surrounding claim that all gotchas block the proposal.
In `@flow/findings/round-recovery/references.md`:
- Line 25: Qualify the process-group statement in the round-recovery findings:
state only that direct children inherit jewilo’s foreground process group based
on the spawn-path evidence, and remove the implication that all backend
descendants receive TTY-generated SIGINT or necessarily terminate. Note that
grandchildren may detach, or require validation per adapter/supervisor path.
In `@openspec/changes/add-round-recovery/design.md`:
- Around line 65-70: Make the STATUS contract consistent across LD7 and the
GoalStatus/SlotStatus implementation: either add hasLiveOrphan to SlotStatus,
populate it in round_recover::status, serialize it in the CLI JSON, and update
tests, or remove the field from the documented schema everywhere. Apply the same
decision to the referenced proposal section and keep implementation,
serialization, and tests aligned.
- Around line 84-86: Update acquire_exclusive so concurrent NEW/RESUME/RECOVER
attempts on the same goal fail fast with GoalBusy and a non-zero result instead
of blocking indefinitely. Use a nonblocking or bounded-time lock acquisition
path, propagate GoalBusy through Result<GoalLock, RoundRecoverError>, and revise
the API documentation to describe this behavior.
In `@openspec/changes/add-round-recovery/specs/goal-status/spec.md`:
- Around line 11-17: The goal-status specification must explicitly define the
needs value for the new state. Update the needs derivation in the STATUS
requirement to document the mapping returned by status() when no slots exist,
preserving the existing behavior unless the intended value is changed
consistently in the implementation.
In `@openspec/changes/add-round-recovery/tasks.md`:
- Around line 17-19: Update task 1.3 to require the GoalLock RAII guard to use
fs4::fs_std::FileExt::try_lock_exclusive on goals/<goalId>/.lock, mapping lock
contention to RoundRecoverError::GoalBusy; do not specify the blocking
lock_exclusive API.
In `@src/bin/verifier_loop.rs`:
- Around line 121-168: The recovery messages in run_recover currently use the
pre-lock st.round, which may be stale. Update RecoverOutcome and
round_recover::recover so each recovery result carries the round actually used,
then use that returned round in the RoundDecidedNoConsensus and StillNullAfter
messages and errors instead of st.round; keep the initial Done check unchanged.
In `@src/round_recover/mod.rs`:
- Around line 209-222: The `!slots_populated` branch in the goal-state mapping
incorrectly requests `GoalNeeds::Recover`, causing an unnecessary timeout when
no verifier was ever spawned. Change this narrow `GoalState::New` path to bypass
recovery and immediately produce the existing `RESUME`-guidance outcome, while
preserving recovery for populated or partially populated rounds and the existing
`null_slots.is_empty()` fast path.
- Around line 269-277: Reword the documentation comment for the wait-only round
recovery description so the mid-sentence `+` continuation is removed and rustdoc
no longer parses it as a list item. Preserve the existing meaning and all LD/D9
recovery behavior references.
- Around line 93-96: Update the lock-acquisition flow around
file.try_lock_exclusive() to inspect its boolean result and return
RoundRecoverError::GoalBusy when it is Ok(false), while preserving the existing
error mapping for Err and constructing GoalLock only after a successful
Ok(true).
- Around line 83-92: Update acquire_exclusive to validate that the requested
goal already exists before calling create_dir_all on its derived gdir. Return
the established GoalNotFound error for missing goal_id values, while preserving
the existing lock acquisition flow for valid goals and avoiding creation of
phantom goal directories.
In `@tests/round_recover_cli.rs`:
- Around line 173-176: Update the assertion for the first slot in the round
recovery CLI test to validate that its verdict equals the canonical APPROVE
serialization, rather than only checking that the verdict key exists. Preserve
the existing slot selection and failure context while explicitly rejecting
reject or null values.
In `@tests/round_recover.rs`:
- Around line 276-279: Update both background writer spawns in the affected
tests to retain their JoinHandle values, return the register_signed_approve
result from each closure instead of discarding it, and join each handle before
the test returns so registration errors propagate and teardown cannot race with
the writer.
---
Nitpick comments:
In `@src/round_recover/mod.rs`:
- Around line 358-391: Extract the shared completion-record/hash logic from
finish_pass and verifier_loop::run_round into a single reusable function in the
appropriate consensus or goal module, then update both callers to use it while
preserving identical hash inputs and write behavior. Also centralize the v1/v2
formatting currently duplicated by verifier_id and the verifier loop’s helper,
updating both call sites to use the shared formatter.
In `@tests/round_recover_cli.rs`:
- Around line 208-214: Reduce the verifierTimeoutSec used by
recover_dead_null_round_exits_nonzero_with_resume_guidance from 10 seconds to a
genuinely short 1-second test value, or apply a dedicated test-only override.
Keep the dead-null recovery and RESUME guidance assertions unchanged, and ensure
the shared setup does not impose the longer timeout on the RESUME warning test.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 5ea19816-9cc5-451f-8f84-81a5cfbc16b3
📒 Files selected for processing (26)
AGENTS.mdflow/findings/round-recovery/2026-07-12-locked-decisions.yamlflow/findings/round-recovery/2026-07-12-open-threads.yamlflow/findings/round-recovery/2026-07-12-path-b-resistance-secrets-persist.mdflow/findings/round-recovery/2026-07-12-shape-1-resistance-evaluation.mdflow/findings/round-recovery/2026-07-12-turn1-verifier-survival-on-kill.mdflow/findings/round-recovery/2026-07-12-turn2-resume-current-round.mdflow/findings/round-recovery/2026-07-12-turn3-sid-early-persist-probe.mdflow/findings/round-recovery/2026-07-12-turn4-lock-shape2-recovery.mdflow/findings/round-recovery/2026-07-12-turn4a-gotcha-recovery-safety.mdflow/findings/round-recovery/2026-07-12-turn4b-gotcha-secret-lifecycle.mdflow/findings/round-recovery/README.mdflow/findings/round-recovery/references.mdopenspec/changes/add-round-recovery/.openspec.yamlopenspec/changes/add-round-recovery/design.mdopenspec/changes/add-round-recovery/proposal.mdopenspec/changes/add-round-recovery/specs/goal-lifecycle/spec.mdopenspec/changes/add-round-recovery/specs/goal-status/spec.mdopenspec/changes/add-round-recovery/specs/round-recovery/spec.mdopenspec/changes/add-round-recovery/tasks.mdsrc/bin/verifier_loop.rssrc/cli/mod.rssrc/lib.rssrc/round_recover/mod.rstests/round_recover.rstests/round_recover_cli.rs
| - id: LD1 | ||
| turn: turn4 | ||
| parts: ["Recovery primitive, final shape"] | ||
| user_quote: | | ||
| "2: OK; wrinkle: no problem ;" | ||
| decision: > | ||
| Round recovery uses shape 2: kill orphan (via persisted PID file) → resume by SID | ||
| (early-persisted on stdout line 1) → emit a <2KB verdict-nudge → gather. No round | ||
| increment, no fix-notes, no prompt re-render. Null slots with no live orphan spawn | ||
| fresh. consensus::evaluate stays unchanged; verdict file remains the resumption | ||
| contract. | ||
| status: locked | ||
| challenged_by: > | ||
| turn4b-gotcha-secret-lifecycle G5-1: INVALIDATED against landed tamper-hardening. | ||
| The per-slot signing secret is minted via mint_and_pin_pubkey (verdict/mod.rs:176), | ||
| returned to the orchestrator, injected into the child env only, and NEVER persisted | ||
| (verdict/mod.rs:172 comment). consensus::evaluate (mod.rs:177) requires the verdict's | ||
| signature to verify against the pinned pubkey. Killing the orphan destroys the only | ||
| valid signer; a resumed pi --session process carries no VERIFIER_LOOP_VERIFIER_SECRET; | ||
| a fresh spawn hits AlreadyPinned. So a pinned-but-null slot with no LIVE signer can | ||
| NEVER produce a countable verdict. Reopen required before drafting add-round-recovery. | ||
| DO NOT AUTO-SUPERSEDE (user-locked) — STOP + ASK user to relock. |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Resolve the contradictory LD1/LD8 authority metadata.
LD1 remains status: locked and says DO NOT AUTO-SUPERSEDE, while LD8 is auto_decided and supersedes LD1. Mark LD1 explicitly superseded by an authorized decision, or record the required user relock; otherwise implementers can legitimately select the unsafe shape-2 behavior.
Based on learnings, behavioral specs, design decisions, locked decisions, and the implementation roadmap are authoritative sources.
Also applies to: 137-153
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@flow/findings/round-recovery/2026-07-12-locked-decisions.yaml` around lines 1
- 22, Resolve the authority conflict between LD1 and LD8 by updating the
decision metadata: either mark LD1 explicitly superseded by the authorized LD8
decision, or record the required user relock instead of leaving it locked.
Update the affected decision entries consistently so implementers cannot select
the unsafe shape-2 recovery behavior.
Source: Learnings
| Add a `STATUS <goalId>` subcommand emitting machine-readable JSON: | ||
| `{round, state: "new"|"in_progress"|"consensus_pass"|"consensus_fail", | ||
| needs: "recover"|"resume"|"done", slots: [{id, verdict, has_live_orphan}]}`. | ||
| RECOVER/RESUME/NEW also emit structured terminal state on `--json`. |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Align the STATUS slot schema across decisions, specification, and implementation.
LD7 requires has_live_orphan, but the supplied SlotStatus implementation and goal-status/spec.md expose only id and verdict. Either add the field end-to-end or remove it from LD7; otherwise outer agents cannot rely on the documented JSON contract.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@flow/findings/round-recovery/2026-07-12-locked-decisions.yaml` around lines
120 - 123, The STATUS slot schema is inconsistent because LD7 requires
has_live_orphan while SlotStatus and goal-status/spec.md omit it. Add
has_live_orphan end-to-end in the SlotStatus implementation and specification,
ensure STATUS JSON populates it for every slot, and preserve the documented id
and verdict fields.
| ## 4. ADDITIONAL SCOPE unlocked by secrets-persist that MUST be handled | ||
|
|
||
| These are NOT optional — secrets-persist makes each of these live. Under shape-1, all | ||
| are MOOT (see OT2/OT3/OT7/OT9 in `2026-07-12-open-threads.yaml`). | ||
|
|
||
| | # | Item | Trigger | LOC | | ||
| |---|---|---|---| | ||
| | 4.1 | Snapshot TTL / staleness (gotcha-a G4/G5/G16) | Fresh-spawn reads a stale snapshot → semantically wrong APPROVE (undetectable from the hash). Must store `{git_ref, tree_hash, captured_at}` in meta and refuse fresh-spawn on drift | ~30–50 | | ||
| | 4.2 | Prompt re-render in RECOVER (G4, OT3) | Fresh-spawn requires a full prompt render from the frozen snapshot. Reuse the RESUME render path, but tag per-slot provenance (`source: "original"\|"resumed-sid"\|"fresh-spawn"`) in meta for audit coherence | ~15–25 | | ||
| | 4.3 | Kill-safety (G1/G2/G6/G10, OT7) | setsid + pgrp-kill + identity verify + escalation | ~125–165 (see §2) | | ||
| | 4.4 | PID identity file (G1/G10, OT2) | `{pid, starttime, cmdline_hash}` + `O_CREAT\|O_EXCL\|O_NOFOLLOW` | ~30–50 | | ||
| | 4.5 | Concurrent-RECOVER flock (G3, OT6/LD5) | Exclusive flock on `goals/<goalId>/.lock` for NEW/RESUME/RECOVER | ~15–25 | | ||
| | 4.6 | RECOVER command + orchestrator branch + cli wiring | The recovery command itself (drives round N to consensus; spawns only null slots) | ~40–60 | | ||
| | 4.7 | Spec change `verifier-identity` SHALL NOT → MAY | Permit `secret` under recovery; rewrite acceptance scenario | spec-only (gating) | |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Do not classify concurrent-RECOVER locking as moot under shape-1.
Item 4.5 is required by LD5 for NEW, RESUME, and RECOVER, including wait-only shape-1 recovery. Describing all listed items as moot can cause the implementation plan to omit the lock and reintroduce concurrent recovery/session corruption races.
Based on learnings, the locked decisions are authoritative for behavior and implementation scope.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@flow/findings/round-recovery/2026-07-12-path-b-resistance-secrets-persist.md`
around lines 192 - 205, Update the scope classification in the “ADDITIONAL SCOPE
unlocked by secrets-persist” section so item 4.5, concurrent-RECOVER flocking,
is explicitly required under shape-1 rather than marked moot. Preserve its LD5
requirement for exclusive locking across NEW, RESUME, and RECOVER, including
wait-only recovery, and ensure the implementation plan retains the
goals/<goalId>/.lock coordination.
Source: Learnings
|
|
||
| ### Combined LOC delta (secrets-persist path, end-to-end) | ||
|
|
||
| ``` |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Specify a language for the fenced block.
Use text for the LOC summary block to satisfy the repository’s markdown lint rule.
🧰 Tools
🪛 markdownlint-cli2 (0.22.1)
[warning] 210-210: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@flow/findings/round-recovery/2026-07-12-path-b-resistance-secrets-persist.md`
at line 210, Update the fenced LOC summary block in the round-recovery document
to specify the text language, changing the opening fence to use text while
preserving the block’s contents.
Source: Linters/SAST tools
| Solid. Shape 2 it is — kill orphan, resume by SID, nudge. | ||
|
|
||
| **Recovery primitive, final shape:** | ||
|
|
||
| ``` | ||
| RECOVER <goalId> | ||
| │ | ||
| ▼ | ||
| round = state.current_round ← NOT incremented | ||
| │ | ||
| ▼ | ||
| for each slot v1..vN in round: | ||
| ├─ verdict non-null → KEEP | ||
| └─ verdict null: | ||
| ├─ orphan alive (pid file)? → kill → resume by SID → verdict-nudge → gather | ||
| └─ no orphan → spawn fresh → gather | ||
| │ | ||
| ▼ | ||
| evaluate consensus (unchanged) | ||
| ├─ PASS → hash → done | ||
| └─ FAIL → "round complete, n/m not met; use RESUME for round N+1" | ||
| ``` | ||
|
|
||
| **New artifacts** (cheap): | ||
| - `rounds/N/vN/pid` — written at spawn time, before gather | ||
| - `meta.json` gets SID written immediately (already structured for it; just move the write earlier) | ||
|
|
||
| **What stays untouched:** `consensus::evaluate`, completion hash inputs, audit trail, fail-closed invariants. Verdict file remains the resumption contract. | ||
|
|
||
| **Boundary vs RESUME:** RECOVER = same round, salvage work, no new context. RESUME = round N+1, fresh snapshot, fix-notes. Clean split. |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Supersede this locked shape with the final SHAPE-1 contract.
This record freezes PID-kill and SID-resume recovery, but SHAPE-1 is wait-only and must not spawn, kill, re-render, recapture, or access signing secrets. Leaving this decision marked “locked” can cause future implementations to reintroduce unsafe process and session-file behavior.
Mark shape 2 as superseded and document that wait-only polling was selected instead.
Also applies to: 46-48
🧰 Tools
🪛 markdownlint-cli2 (0.22.1)
[warning] 17-17: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@flow/findings/round-recovery/2026-07-12-turn4-lock-shape2-recovery.md` around
lines 13 - 42, Mark the locked Shape 2 recovery contract in the round-recovery
record as superseded, and document that the final Shape 1 contract was selected
instead. Replace the PID-kill, SID-resume, spawning, re-rendering, recapture,
and signing-secret behavior with wait-only polling that performs none of those
operations.
| file.try_lock_exclusive() | ||
| .map_err(|_| RoundRecoverError::GoalBusy)?; | ||
| Ok(GoalLock { _file: file }) | ||
| } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🔴 Critical | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
rg -n '"fs4"' -A2 Cargo.lock Cargo.tomlRepository: buihongduc132/verifier-loop
Length of output: 389
🌐 Web query:
What does fs4 crate's FileExt::try_lock_exclusive return in version 0.12.0 — Result<()> or Result<bool>?
💡 Result:
In version 0.12.0 of the fs4 crate, the FileExt::try_lock_exclusive method returns std::io::Result [1][2][3]. In this version, a return value of Ok(true) indicates that the lock was successfully acquired, while Ok(false) indicates that the file is currently locked by another handle [4][5]. This return type was later changed in version 1.0.0 to Result<, TryLockError> to better align with the stabilized std::fs::File::try_lock API [1][6][7].
Citations:
- 1: https://docs.rs/crate/fs4/latest/source/CHANGELOG.md
- 2: suzuke/agend-terminal@0d330fd
- 3: chore(deps): bump fs4 from 0.12.0 to 1.0.1 koharu-rs/koharu#553
- 4: https://docs.rs/fs4/latest/fs4/fs_err3/trait.FileExt.html
- 5: https://docs.rs/fs4/latest/fs4/fs_err2/trait.FileExt.html
- 6: Release v1.0.0: match std file-lock API, fix platform bugs al8n/fs4#48
- 7: https://github.com/al8n/fs4/releases
🏁 Script executed:
#!/bin/bash
set -euo pipefail
file=src/round_recover/mod.rs
echo "== outline =="
ast-grep outline "$file" --view expanded || true
echo
echo "== relevant lines =="
sed -n '70,110p' "$file" | cat -n
echo
echo "== imports / trait use =="
rg -n 'fs4|try_lock_exclusive|GoalBusy|GoalLock' "$file"Repository: buihongduc132/verifier-loop
Length of output: 4397
Handle try_lock_exclusive’s Ok(false) case at src/round_recover/mod.rs:93-96. fs4::FileExt::try_lock_exclusive returns Ok(false) when another process already holds the lock, so this code currently treats contention as success and defeats the GoalBusy guard. Return GoalBusy on false instead of dropping it.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/round_recover/mod.rs` around lines 93 - 96, Update the lock-acquisition
flow around file.try_lock_exclusive() to inspect its boolean result and return
RoundRecoverError::GoalBusy when it is Ok(false), while preserving the existing
error mapping for Err and constructing GoalLock only after a successful
Ok(true).
There was a problem hiding this comment.
Not a bug — false positive against the wrong fs4 version. This repo pins fs4 = 0.12 (Cargo.lock). In 0.12.0 FileExt::try_lock_exclusive returns std::io::Result<()> (verified at registry src fs4-0.12.0/src/unix.rs:19 and the trait at file_ext/sync_impl.rs:55). The Result<bool> return type the comment cites was introduced in fs4 1.0.0 — not our version. So Ok(()) = acquired, Err(WouldBlock) = busy, exactly as the code assumes. The test goal_lock_second_concurrent_acquire_in_same_process_fails_busy exercises the WouldBlock→GoalBusy path and passes.
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n '"fs4"' -A2 Cargo.lock | head -20Length of output: 366
@buihongduc132, thanks for the correction — confirmed Cargo.lock pins fs4 = 0.12.0, and per the web search earlier, the Result<bool> return type was only introduced in fs4 1.0.0. In 0.12.0, Ok(()) = acquired and Err(WouldBlock) = busy, so the existing map_err(|_| GoalBusy) logic is correct as written. Withdrawing this comment.
| let (state, needs) = if completion_exists { | ||
| (GoalState::ConsensusPass, GoalNeeds::Done) | ||
| } else if !slots_populated { | ||
| (GoalState::New, GoalNeeds::Recover) | ||
| } else if any_null { | ||
| (GoalState::InProgress, GoalNeeds::Recover) | ||
| } else if raw_approve_count >= config.n { | ||
| // All slots decided, APPROVE count reaches n, but no completion yet (the round | ||
| // was interrupted before the gather barrier wrote completion.json). RECOVER can | ||
| // finish it — so this is recoverable, not a failed round. | ||
| (GoalState::InProgress, GoalNeeds::Recover) | ||
| } else { | ||
| (GoalState::ConsensusFail, GoalNeeds::Resume) | ||
| }; |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
GoalState::New maps straight to GoalNeeds::Recover, causing RECOVER to block the full timeout for nothing.
When !slots_populated (no verifier dirs exist — nothing was ever spawned for this round), needs is still Recover. Since nothing was spawned, there is no live orphan to harvest, so recover_with_poll will read all-null verdicts, find null_slots non-empty every iteration, and spin until the full verifier_timeout_sec elapses before finally emitting StillNullAfter guidance to run RESUME. A short-circuit for the "nothing populated" case (skip straight to the RESUME-guidance outcome, mirroring the existing null_slots.is_empty() fast path) would avoid the pointless wait in this narrow crash-recovery window (killed between goal::new and the first spawn).
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/round_recover/mod.rs` around lines 209 - 222, The `!slots_populated`
branch in the goal-state mapping incorrectly requests `GoalNeeds::Recover`,
causing an unnecessary timeout when no verifier was ever spawned. Change this
narrow `GoalState::New` path to bypass recovery and immediately produce the
existing `RESUME`-guidance outcome, while preserving recovery for populated or
partially populated rounds and the existing `null_slots.is_empty()` fast path.
There was a problem hiding this comment.
15 issues found and verified against the latest diff
You’re at about 94% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="flow/findings/round-recovery/2026-07-12-locked-decisions.yaml">
<violation number="1" location="flow/findings/round-recovery/2026-07-12-locked-decisions.yaml:122">
P1: LD7 mandates a `has_live_orphan` boolean in every slot of the STATUS JSON, but LD9 explicitly adopts a no-PID / no-liveness-detection design and states the system "cannot detect whether an orphan is alive vs dead." These two locked decisions contradict each other — the field required by LD7 is unimplementable under the constraints of LD9.
The divergence is confirmed by the actual implementation: `src/round_recover/mod.rs` defines `SlotStatus` with only `id` and `verdict`, and the entire codebase contains no reference to `has_live_orphan`. The PR description also omits it, describing slots only as `{verdict: possibly null}`.
This leaves the locked-decisions spec inconsistent with both itself and the code. Recommend updating the spec to remove `has_live_orphan` from the LD7 STATUS schema (or add a tri-state like `unknown` if the field is still desired) so the spec, design, and implementation are aligned.</violation>
<violation number="2" location="flow/findings/round-recovery/2026-07-12-locked-decisions.yaml:142">
P2: LD8 describes the RECOVER fallback as triggered by a liveness check on the signer ("if a null slot has no live signer…"), but this is architecturally inconsistent with the decisions in LD9 and the actual implementation. LD9 explicitly states: "we cannot detect whether an orphan is alive vs dead; we only observe whether verdict.json appears." The actual recovery flow uses a timeout-based `StillNullAfter` condition to decide when to suggest RESUME N+1. Please rephrase LD8 to describe the timeout/absence-of-verdict semantics instead of a nonexistent live-signer check, so the locked spec stays internally consistent with the architecture.</violation>
</file>
<file name="flow/findings/round-recovery/2026-07-12-turn4-lock-shape2-recovery.md">
<violation number="1" location="flow/findings/round-recovery/2026-07-12-turn4-lock-shape2-recovery.md:15">
P2: The turn4 exploration record presents a PID-file-based, kill-and-respawn recovery design as the "final recovery primitive frozen," but the actually implemented and locked design (LD8) superseded this with a wait-only approach that never kills signers or uses PID files. A future maintainer reading this file in isolation could reasonably reintroduce obsolete recovery behavior. If this historical transcript is retained, it should include a visible note that Shape 2 was superseded by LD8 and is no longer the active design.</violation>
</file>
<file name="tests/round_recover.rs">
<violation number="1" location="tests/round_recover.rs:77">
P3: The `signed_approve` and `signed_reject` helpers each end with `verdict::read_verdict(...).unwrap_or(...)` whose return value is never used by any of their 13 call sites. This means the read-back is dead code that adds an unnecessary filesystem read and, more importantly, uses `unwrap_or` to silently swallow any read error by substituting a dummy Null verdict. Since no caller captures the result, a failure in the read-back would be completely invisible — the test would pass when it shouldn't. Consider either (a) removing the `read_verdict` call entirely and returning `()` from both helpers, or (b) if you want the helpers to return the verdict for future callers, use `.unwrap()` instead of `.unwrap_or(...)` so that a read failure correctly propagates as a panic.</violation>
</file>
<file name="openspec/changes/add-round-recovery/proposal.md">
<violation number="1" location="openspec/changes/add-round-recovery/proposal.md:8">
P2: The proposal presents TTY `SIGINT` (Ctrl-C) as a kill scenario that leaves verifier children orphaned and recoverable. Under standard Unix semantics, a terminal-generated `SIGINT` is delivered to the entire foreground process group, and the codebase shows no process-group isolation or signal-handling logic that would exclude the children. In the default configuration the children are therefore likely terminated along with the parent, making a later `RECOVER` impossible for this case. Consider either removing TTY `SIGINT` from the listed recovery scenarios or explicitly documenting the prerequisite that children must run in a separate process group (and/or ignore `SIGINT`) for this scenario to apply.</violation>
<violation number="2" location="openspec/changes/add-round-recovery/proposal.md:35">
P1: The STATUS command is described as emitting 'per-slot verdict + liveness,' but the SHAPE-1 design explicitly excludes PID tracking and process-liveness detection (LD9). The actual STATUS implementation only provides `id` and `verdict` per slot, with no liveness field. This creates a misleading API contract in the proposal. Consider removing the 'liveness' claim and clarifying that STATUS reports verdict presence only, not actual process state.</violation>
</file>
<file name="openspec/changes/add-round-recovery/design.md">
<violation number="1" location="openspec/changes/add-round-recovery/design.md:84">
P2: The design document documents `GoalLock::acquire_exclusive` as being "built on `fs4::fs_std::FileExt::lock_exclusive`" with a comment stating it "blocks until held." This contradicts LD5's fail-fast requirement and the actual implementation, which uses `try_lock_exclusive()` — the non-blocking variant that returns `Err(GoalBusy)` immediately when contended. Since this design doc is a reference for future maintainers, it should align with the actual code: document `try_lock_exclusive` and describe the fail-fast behavior.</violation>
<violation number="2" location="openspec/changes/add-round-recovery/design.md:101">
P2: The documented NEW lock order leaves `goal::new`'s multi-file initialization unprotected. Because the `goals/<goalId>/` directory is visible before the lock is acquired, a concurrent `RESUME` or `RECOVER` can discover the UUID (by scanning) and win the lock race, reading or mutating a partially initialized goal while the original `NEW` blocks. Random UUIDs prevent two `NEW`s from colliding, but they do not serialize `NEW` against `RESUME`/`RECOVER`. Per-file atomicity does not make the overall initialization atomic.
Consider protecting `NEW` with a parent-level lock (e.g., a coarse lock on the `goals/` directory during initialization), or staging the new goal in a temporary directory and atomically publishing it only after the lock is acquired and all initial files are written.</violation>
<violation number="3" location="openspec/changes/add-round-recovery/design.md:124">
P2: The RECOVER algorithm specifies writing `completion.json` as soon as `consensus::evaluate` reports pass, while orphan verifier processes may still be running and can append to the receipt log. In the normal round path, a gather barrier ensures all children finish before completion is written, so the receipt head captured in the completion hash is stable. Under RECOVER, if quorum consensus passes before every slot has produced a verdict, still-running orphans can later extend the receipt log, making the completion's recorded head/hash stale and breaking audit reproducibility.
Consider documenting how RECOVER should handle this—either by waiting for all null slots to resolve before writing completion (to match the gather-barrier invariant), or by explicitly acknowledging that the receipt head may be extended post-completion during recovery and justifying why that is acceptable.</violation>
<violation number="4" location="openspec/changes/add-round-recovery/design.md:125">
P2: The RECOVER algorithm's 'every slot is non-null' check is vacuously true when no slots exist (a new goal), which would cause an immediate `RoundDecidedNoConsensus` return instead of the intended timeout/`StillNullAfter` path documented in §4.3. A literal Rust implementation using `iter().all(...)` on an empty collection returns `true`, so this branch needs an explicit guard for the zero-slot or `state == new` case.</violation>
</file>
<file name="openspec/changes/add-round-recovery/tasks.md">
<violation number="1" location="openspec/changes/add-round-recovery/tasks.md:30">
P2: The STATUS RED test matrix in `tasks.md` is missing the interrupted-pass case where every slot is a signed APPROVE (count reaches `n`) but `completion.json` is absent. This is a distinct state from 2.2 (null slots present) and 2.3 (all non-null but below `n`). Without documenting it here, a reader or future implementer might not realize the `all-APPROVE / no-completion` path must yield `needs="recover"` rather than `resume`. The actual code and tests already handle this correctly (see `status_needs_recover_when_all_approve_but_no_completion_interrupted` in `tests/round_recover.rs`), so this is a spec/documentation completeness issue. Consider adding an explicit RED task for the interrupted-pass state to keep the task list aligned with the real test coverage and the stated contract.</violation>
</file>
<file name="flow/findings/round-recovery/2026-07-12-path-b-resistance-secrets-persist.md">
<violation number="1" location="flow/findings/round-recovery/2026-07-12-path-b-resistance-secrets-persist.md:27">
P2: The security analysis document characterizes `fs::remove_file` as a "shred" operation and claims the secret file "exists only for `{spawn → first verdict}`" for slots that write a verdict, but this guarantee is not crash-safe. The atomic verdict write and the subsequent unlink are two separate, non-atomic operations — in a recovery scenario where abrupt termination is the primary concern, the process can be killed after the verdict is committed but before the secret is removed, leaving the secret on disk indefinitely for a completed slot. This undermines the "window-bounded" security claim that underpins the security score. Consider either acknowledging this as a best-effort bound (not a guarantee), describing a cleanup-on-read mechanism, or narrowing the threat-model claim to reflect the actual boundedness.</violation>
</file>
<file name="tests/round_recover_cli.rs">
<violation number="1" location="tests/round_recover_cli.rs:338">
P2: The test resume_warns_when_round_has_null_verdict checks that RESUME prints the 'recover' warning in stderr, but it omits an assertion that RESUME actually proceeds (exits 0). The comment documents that RESUME 'proceeds to round 2', and every other test in this file that has behavioral expectations about a command's exit code asserts on out.status.success() or !out.status.success(). Without this assertion, a regression that causes RESUME to exit non-zero (while still printing the warning) would pass the test undetected. Consider adding: assert!(out.status.success(), "RESUME should exit successfully after warning about RECOVER: {}", String::from_utf8_lossy(&out.stderr));</violation>
</file>
<file name="openspec/changes/add-round-recovery/specs/goal-status/spec.md">
<violation number="1" location="openspec/changes/add-round-recovery/specs/goal-status/spec.md:35">
P3: **Spec gap in state-field definitions**: The spec defines `in_progress` as requiring "at least one slot null and no completion", but this doesn't cover the scenario where all slots are non-null, the APPROVE count reaches the consensus threshold `n`, and `completion.json` doesn't exist (the round was interrupted after all verdicts landed but before the completion barrier). The actual `status()` implementation correctly maps this case to `GoalState::InProgress` with `needs: "recover"`, but the spec's state definitions are missing this case, leaving the four states non-exhaustive. Suggest updating the `in_progress` definition to something like: `"in_progress" — no completion.json, with at least one slot null OR all slots non-null but APPROVE count reaching n (round interrupted before gather barrier)`.</violation>
</file>
<file name="flow/findings/round-recovery/README.md">
<violation number="1" location="flow/findings/round-recovery/README.md:4">
P2: The findings directory README records an outdated exploration status (`explore-ongoing`, 10 open threads, step 50 blocked) that contradicts the actual resolved state in the co-located `2026-07-12-open-threads.yaml` (`status: closed`, all threads resolved) and the locked decisions (`2026-07-12-locked-decisions.yaml`, LD3–LD11). This could mislead future contributors into thinking the recovery design is unfinished or that LD1 still needs relocking when it has already been superseded. Update the README header and Topics section to reflect the final closed state, the shape-1 outcome, and the superseded status of LD1/LD2.</violation>
</file>
Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.
Re-trigger cubic
| decision: > | ||
| Add a `STATUS <goalId>` subcommand emitting machine-readable JSON: | ||
| `{round, state: "new"|"in_progress"|"consensus_pass"|"consensus_fail", | ||
| needs: "recover"|"resume"|"done", slots: [{id, verdict, has_live_orphan}]}`. |
There was a problem hiding this comment.
P1: LD7 mandates a has_live_orphan boolean in every slot of the STATUS JSON, but LD9 explicitly adopts a no-PID / no-liveness-detection design and states the system "cannot detect whether an orphan is alive vs dead." These two locked decisions contradict each other — the field required by LD7 is unimplementable under the constraints of LD9.
The divergence is confirmed by the actual implementation: src/round_recover/mod.rs defines SlotStatus with only id and verdict, and the entire codebase contains no reference to has_live_orphan. The PR description also omits it, describing slots only as {verdict: possibly null}.
This leaves the locked-decisions spec inconsistent with both itself and the code. Recommend updating the spec to remove has_live_orphan from the LD7 STATUS schema (or add a tri-state like unknown if the field is still desired) so the spec, design, and implementation are aligned.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At flow/findings/round-recovery/2026-07-12-locked-decisions.yaml, line 122:
<comment>LD7 mandates a `has_live_orphan` boolean in every slot of the STATUS JSON, but LD9 explicitly adopts a no-PID / no-liveness-detection design and states the system "cannot detect whether an orphan is alive vs dead." These two locked decisions contradict each other — the field required by LD7 is unimplementable under the constraints of LD9.
The divergence is confirmed by the actual implementation: `src/round_recover/mod.rs` defines `SlotStatus` with only `id` and `verdict`, and the entire codebase contains no reference to `has_live_orphan`. The PR description also omits it, describing slots only as `{verdict: possibly null}`.
This leaves the locked-decisions spec inconsistent with both itself and the code. Recommend updating the spec to remove `has_live_orphan` from the LD7 STATUS schema (or add a tri-state like `unknown` if the field is still desired) so the spec, design, and implementation are aligned.</comment>
<file context>
@@ -0,0 +1,213 @@
+ decision: >
+ Add a `STATUS <goalId>` subcommand emitting machine-readable JSON:
+ `{round, state: "new"|"in_progress"|"consensus_pass"|"consensus_fail",
+ needs: "recover"|"resume"|"done", slots: [{id, verdict, has_live_orphan}]}`.
+ RECOVER/RESUME/NEW also emit structured terminal state on `--json`.
+ status: locked
</file context>
| `RESUME N+1` for fresh slots and fresh keys." | ||
| - **`goal-status`** — a `STATUS <goalId>` top-level command (LD7) emitting | ||
| machine-readable JSON describing the goal's round, state, what it `needs` | ||
| (`recover`|`resume`|`done`), and per-slot verdict + liveness. |
There was a problem hiding this comment.
P1: The STATUS command is described as emitting 'per-slot verdict + liveness,' but the SHAPE-1 design explicitly excludes PID tracking and process-liveness detection (LD9). The actual STATUS implementation only provides id and verdict per slot, with no liveness field. This creates a misleading API contract in the proposal. Consider removing the 'liveness' claim and clarifying that STATUS reports verdict presence only, not actual process state.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At openspec/changes/add-round-recovery/proposal.md, line 35:
<comment>The STATUS command is described as emitting 'per-slot verdict + liveness,' but the SHAPE-1 design explicitly excludes PID tracking and process-liveness detection (LD9). The actual STATUS implementation only provides `id` and `verdict` per slot, with no liveness field. This creates a misleading API contract in the proposal. Consider removing the 'liveness' claim and clarifying that STATUS reports verdict presence only, not actual process state.</comment>
<file context>
@@ -0,0 +1,68 @@
+ `RESUME N+1` for fresh slots and fresh keys."
+- **`goal-status`** — a `STATUS <goalId>` top-level command (LD7) emitting
+ machine-readable JSON describing the goal's round, state, what it `needs`
+ (`recover`|`resume`|`done`), and per-slot verdict + liveness.
+
+### Modified capabilities
</file context>
| let goal_id = goal_id_from_new(&String::from_utf8_lossy(&out.stdout)).unwrap(); | ||
|
|
||
| // RESUME must warn (round 1 has a null v2). It then proceeds to round 2. | ||
| let out = run_vl_raw(home, home, &stub, &["RESUME", &goal_id, "--fix", "retry"]); |
There was a problem hiding this comment.
P2: The test resume_warns_when_round_has_null_verdict checks that RESUME prints the 'recover' warning in stderr, but it omits an assertion that RESUME actually proceeds (exits 0). The comment documents that RESUME 'proceeds to round 2', and every other test in this file that has behavioral expectations about a command's exit code asserts on out.status.success() or !out.status.success(). Without this assertion, a regression that causes RESUME to exit non-zero (while still printing the warning) would pass the test undetected. Consider adding: assert!(out.status.success(), "RESUME should exit successfully after warning about RECOVER: {}", String::from_utf8_lossy(&out.stderr));
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At tests/round_recover_cli.rs, line 338:
<comment>The test resume_warns_when_round_has_null_verdict checks that RESUME prints the 'recover' warning in stderr, but it omits an assertion that RESUME actually proceeds (exits 0). The comment documents that RESUME 'proceeds to round 2', and every other test in this file that has behavioral expectations about a command's exit code asserts on out.status.success() or !out.status.success(). Without this assertion, a regression that causes RESUME to exit non-zero (while still printing the warning) would pass the test undetected. Consider adding: assert!(out.status.success(), "RESUME should exit successfully after warning about RECOVER: {}", String::from_utf8_lossy(&out.stderr));</comment>
<file context>
@@ -0,0 +1,344 @@
+ let goal_id = goal_id_from_new(&String::from_utf8_lossy(&out.stdout)).unwrap();
+
+ // RESUME must warn (round 1 has a null v2). It then proceeds to round 2.
+ let out = run_vl_raw(home, home, &stub, &["RESUME", &goal_id, "--fix", "retry"]);
+ let stderr = String::from_utf8_lossy(&out.stderr);
+ assert!(
</file context>
| parts: ["G5-1", "G4-1", "G4-2", "shape-1 vs secrets-persist comparison"] | ||
| user_quote: "Self resolve it yourself by delegate sub agents to find the LEAST resistance approach THEN ensure to clearly note that into the decision" | ||
| decision: > | ||
| Round recovery uses SHAPE-1 (wait-only, never kill the signer, no fresh-spawn in |
There was a problem hiding this comment.
P2: LD8 describes the RECOVER fallback as triggered by a liveness check on the signer ("if a null slot has no live signer…"), but this is architecturally inconsistent with the decisions in LD9 and the actual implementation. LD9 explicitly states: "we cannot detect whether an orphan is alive vs dead; we only observe whether verdict.json appears." The actual recovery flow uses a timeout-based StillNullAfter condition to decide when to suggest RESUME N+1. Please rephrase LD8 to describe the timeout/absence-of-verdict semantics instead of a nonexistent live-signer check, so the locked spec stays internally consistent with the architecture.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At flow/findings/round-recovery/2026-07-12-locked-decisions.yaml, line 142:
<comment>LD8 describes the RECOVER fallback as triggered by a liveness check on the signer ("if a null slot has no live signer…"), but this is architecturally inconsistent with the decisions in LD9 and the actual implementation. LD9 explicitly states: "we cannot detect whether an orphan is alive vs dead; we only observe whether verdict.json appears." The actual recovery flow uses a timeout-based `StillNullAfter` condition to decide when to suggest RESUME N+1. Please rephrase LD8 to describe the timeout/absence-of-verdict semantics instead of a nonexistent live-signer check, so the locked spec stays internally consistent with the architecture.</comment>
<file context>
@@ -0,0 +1,213 @@
+ parts: ["G5-1", "G4-1", "G4-2", "shape-1 vs secrets-persist comparison"]
+ user_quote: "Self resolve it yourself by delegate sub agents to find the LEAST resistance approach THEN ensure to clearly note that into the decision"
+ decision: >
+ Round recovery uses SHAPE-1 (wait-only, never kill the signer, no fresh-spawn in
+ RECOVER). RECOVER polls live orphan processes for verdict.json; if a null slot has
+ no live signer (dead orphan, or child never finished), RECOVER falls through to the
</file context>
|
|
||
| Solid. Shape 2 it is — kill orphan, resume by SID, nudge. | ||
|
|
||
| **Recovery primitive, final shape:** |
There was a problem hiding this comment.
P2: The turn4 exploration record presents a PID-file-based, kill-and-respawn recovery design as the "final recovery primitive frozen," but the actually implemented and locked design (LD8) superseded this with a wait-only approach that never kills signers or uses PID files. A future maintainer reading this file in isolation could reasonably reintroduce obsolete recovery behavior. If this historical transcript is retained, it should include a visible note that Shape 2 was superseded by LD8 and is no longer the active design.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At flow/findings/round-recovery/2026-07-12-turn4-lock-shape2-recovery.md, line 15:
<comment>The turn4 exploration record presents a PID-file-based, kill-and-respawn recovery design as the "final recovery primitive frozen," but the actually implemented and locked design (LD8) superseded this with a wait-only approach that never kills signers or uses PID files. A future maintainer reading this file in isolation could reasonably reintroduce obsolete recovery behavior. If this historical transcript is retained, it should include a visible note that Shape 2 was superseded by LD8 and is no longer the active design.</comment>
<file context>
@@ -0,0 +1,48 @@
+
+Solid. Shape 2 it is — kill orphan, resume by SID, nudge.
+
+**Recovery primitive, final shape:**
+
+```
</file context>
| slot and no completion. | ||
| - [x] 2.3 RED: `status` returns `needs="resume"`, `state="consensus_fail"` when every | ||
| slot non-null and below `n`, no completion. | ||
| - [x] 2.4 RED: `status` returns `state="new"` before the round's slots exist. |
There was a problem hiding this comment.
P2: The STATUS RED test matrix in tasks.md is missing the interrupted-pass case where every slot is a signed APPROVE (count reaches n) but completion.json is absent. This is a distinct state from 2.2 (null slots present) and 2.3 (all non-null but below n). Without documenting it here, a reader or future implementer might not realize the all-APPROVE / no-completion path must yield needs="recover" rather than resume. The actual code and tests already handle this correctly (see status_needs_recover_when_all_approve_but_no_completion_interrupted in tests/round_recover.rs), so this is a spec/documentation completeness issue. Consider adding an explicit RED task for the interrupted-pass state to keep the task list aligned with the real test coverage and the stated contract.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At openspec/changes/add-round-recovery/tasks.md, line 30:
<comment>The STATUS RED test matrix in `tasks.md` is missing the interrupted-pass case where every slot is a signed APPROVE (count reaches `n`) but `completion.json` is absent. This is a distinct state from 2.2 (null slots present) and 2.3 (all non-null but below `n`). Without documenting it here, a reader or future implementer might not realize the `all-APPROVE / no-completion` path must yield `needs="recover"` rather than `resume`. The actual code and tests already handle this correctly (see `status_needs_recover_when_all_approve_but_no_completion_interrupted` in `tests/round_recover.rs`), so this is a spec/documentation completeness issue. Consider adding an explicit RED task for the interrupted-pass state to keep the task list aligned with the real test coverage and the stated contract.</comment>
<file context>
@@ -0,0 +1,73 @@
+ slot and no completion.
+- [x] 2.3 RED: `status` returns `needs="resume"`, `state="consensus_fail"` when every
+ slot non-null and below `n`, no completion.
+- [x] 2.4 RED: `status` returns `state="new"` before the round's slots exist.
+- [x] 2.5 GREEN: implement `status()` reading `state.json`, per-slot `verdict.json`, and
+ `completion.json`; derive `state`/`needs` per design §4.3. No lock taken.
</file context>
| | File / symbol | Current behavior | secrets-persist delta | LOC | | ||
| |---|---|---|---| | ||
| | `verdict::mint_and_pin_pubkey` (`src/verdict/mod.rs:176`) | Mints keypair, atomically pins pubkey, **returns SigningKey, never persists** (L172 docstring) | After pin, write `secret` 0600 atomically (tmp + rename, mirror `store::salt_in`); update docstring + remove the "NEVER persisted" comment | ~15 | | ||
| | `verdict::write_first_verdict` (`src/verdict/mod.rs`) | Atomic first-verdict write | After successful write, shred (`fs::remove_file`) the slot's `secret` so the vulnerable window closes | ~8 | |
There was a problem hiding this comment.
P2: The security analysis document characterizes fs::remove_file as a "shred" operation and claims the secret file "exists only for {spawn → first verdict}" for slots that write a verdict, but this guarantee is not crash-safe. The atomic verdict write and the subsequent unlink are two separate, non-atomic operations — in a recovery scenario where abrupt termination is the primary concern, the process can be killed after the verdict is committed but before the secret is removed, leaving the secret on disk indefinitely for a completed slot. This undermines the "window-bounded" security claim that underpins the security score. Consider either acknowledging this as a best-effort bound (not a guarantee), describing a cleanup-on-read mechanism, or narrowing the threat-model claim to reflect the actual boundedness.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At flow/findings/round-recovery/2026-07-12-path-b-resistance-secrets-persist.md, line 27:
<comment>The security analysis document characterizes `fs::remove_file` as a "shred" operation and claims the secret file "exists only for `{spawn → first verdict}`" for slots that write a verdict, but this guarantee is not crash-safe. The atomic verdict write and the subsequent unlink are two separate, non-atomic operations — in a recovery scenario where abrupt termination is the primary concern, the process can be killed after the verdict is committed but before the secret is removed, leaving the secret on disk indefinitely for a completed slot. This undermines the "window-bounded" security claim that underpins the security score. Consider either acknowledging this as a best-effort bound (not a guarantee), describing a cleanup-on-read mechanism, or narrowing the threat-model claim to reflect the actual boundedness.</comment>
<file context>
@@ -0,0 +1,256 @@
+| File / symbol | Current behavior | secrets-persist delta | LOC |
+|---|---|---|---|
+| `verdict::mint_and_pin_pubkey` (`src/verdict/mod.rs:176`) | Mints keypair, atomically pins pubkey, **returns SigningKey, never persists** (L172 docstring) | After pin, write `secret` 0600 atomically (tmp + rename, mirror `store::salt_in`); update docstring + remove the "NEVER persisted" comment | ~15 |
+| `verdict::write_first_verdict` (`src/verdict/mod.rs`) | Atomic first-verdict write | After successful write, shred (`fs::remove_file`) the slot's `secret` so the vulnerable window closes | ~8 |
+| `verdict::read_persisted_secret` (NEW) | — | Read + chmod-verify 0600 + hex-decode the signing key (mirror `read_pinned_pubkey`) | ~15 |
+| `spawn::mint_verifier_secret` (`orchestrator.rs:681`) | Always mints fresh; `AlreadyPinned` is fatal on a pinned-but-null slot | On `AlreadyPinned`, fall back to `read_persisted_secret` so RECOVER can re-sign without re-minting | ~10 |
</file context>
| | `verdict::write_first_verdict` (`src/verdict/mod.rs`) | Atomic first-verdict write | After successful write, shred (`fs::remove_file`) the slot's `secret` so the vulnerable window closes | ~8 | | |
| After successful write, delete (`fs::remove_file`) the slot's `secret` as a best-effort cleanup. Note: this is not atomic with the verdict write; a crash between write and delete leaves the secret on disk. |
| The `state` field SHALL be one of `"new"`, `"in_progress"`, `"consensus_pass"`, or `"consensus_fail"`: | ||
| - `"consensus_pass"` — `completion.json` exists. | ||
| - `"consensus_fail"` — every slot non-null AND below `n`. | ||
| - `"in_progress"` — at least one slot null and no completion. |
There was a problem hiding this comment.
P3: Spec gap in state-field definitions: The spec defines in_progress as requiring "at least one slot null and no completion", but this doesn't cover the scenario where all slots are non-null, the APPROVE count reaches the consensus threshold n, and completion.json doesn't exist (the round was interrupted after all verdicts landed but before the completion barrier). The actual status() implementation correctly maps this case to GoalState::InProgress with needs: "recover", but the spec's state definitions are missing this case, leaving the four states non-exhaustive. Suggest updating the in_progress definition to something like: "in_progress" — no completion.json, with at least one slot null OR all slots non-null but APPROVE count reaching n (round interrupted before gather barrier).
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At openspec/changes/add-round-recovery/specs/goal-status/spec.md, line 35:
<comment>**Spec gap in state-field definitions**: The spec defines `in_progress` as requiring "at least one slot null and no completion", but this doesn't cover the scenario where all slots are non-null, the APPROVE count reaches the consensus threshold `n`, and `completion.json` doesn't exist (the round was interrupted after all verdicts landed but before the completion barrier). The actual `status()` implementation correctly maps this case to `GoalState::InProgress` with `needs: "recover"`, but the spec's state definitions are missing this case, leaving the four states non-exhaustive. Suggest updating the `in_progress` definition to something like: `"in_progress" — no completion.json, with at least one slot null OR all slots non-null but APPROVE count reaching n (round interrupted before gather barrier)`.</comment>
<file context>
@@ -0,0 +1,44 @@
+The `state` field SHALL be one of `"new"`, `"in_progress"`, `"consensus_pass"`, or `"consensus_fail"`:
+- `"consensus_pass"` — `completion.json` exists.
+- `"consensus_fail"` — every slot non-null AND below `n`.
+- `"in_progress"` — at least one slot null and no completion.
+- `"new"` — the round directory or slots do not yet exist (before the first spawn).
+
</file context>
| ) -> verdict::VerdictRecord { | ||
| let sk = verdict::mint_and_pin_pubkey(root, goal_id, vid, round).unwrap(); | ||
| verdict::register_signed_approve(root, goal_id, vid, round, None, &sk).unwrap(); | ||
| verdict::read_verdict(root, goal_id, vid, round).unwrap_or(verdict::VerdictRecord { |
There was a problem hiding this comment.
P3: The signed_approve and signed_reject helpers each end with verdict::read_verdict(...).unwrap_or(...) whose return value is never used by any of their 13 call sites. This means the read-back is dead code that adds an unnecessary filesystem read and, more importantly, uses unwrap_or to silently swallow any read error by substituting a dummy Null verdict. Since no caller captures the result, a failure in the read-back would be completely invisible — the test would pass when it shouldn't. Consider either (a) removing the read_verdict call entirely and returning () from both helpers, or (b) if you want the helpers to return the verdict for future callers, use .unwrap() instead of .unwrap_or(...) so that a read failure correctly propagates as a panic.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At tests/round_recover.rs, line 77:
<comment>The `signed_approve` and `signed_reject` helpers each end with `verdict::read_verdict(...).unwrap_or(...)` whose return value is never used by any of their 13 call sites. This means the read-back is dead code that adds an unnecessary filesystem read and, more importantly, uses `unwrap_or` to silently swallow any read error by substituting a dummy Null verdict. Since no caller captures the result, a failure in the read-back would be completely invisible — the test would pass when it shouldn't. Consider either (a) removing the `read_verdict` call entirely and returning `()` from both helpers, or (b) if you want the helpers to return the verdict for future callers, use `.unwrap()` instead of `.unwrap_or(...)` so that a read failure correctly propagates as a panic.</comment>
<file context>
@@ -0,0 +1,398 @@
+) -> verdict::VerdictRecord {
+ let sk = verdict::mint_and_pin_pubkey(root, goal_id, vid, round).unwrap();
+ verdict::register_signed_approve(root, goal_id, vid, round, None, &sk).unwrap();
+ verdict::read_verdict(root, goal_id, vid, round).unwrap_or(verdict::VerdictRecord {
+ status: verdict::VerdictStatus::Null,
+ notes: None,
</file context>
- GoalLock::acquire_exclusive now validates the goal dir exists BEFORE locking and returns GoalNotFound for an unknown goalId, instead of create_dir_all'ing a phantom goal dir (holding only .lock). Added goal_lock_unknown_goal_returns_goal_not_found_without_phantom_dir test. (coderabbit 3565077196) - Reword a doc-comment to avoid a leading `+` that clippy/rustdoc parses as a markdown list item. (coderabbit 3565077206) - CLI STATUS test now asserts the canonical APPROVE value, not just key presence, so a regression serializing reject/null would fail it. (coderabbit 3565077211) - Both round_recover background-writer test threads are now joined so they do not leak across tests. (coderabbit 3565077218) - tasks.md: corrected the lock API name to try_lock_exclusive (fail-fast) and noted the WouldBlock-only GoalBusy mapping. (coderabbit 3565077188) 344 tests green; coverage gate --fail-under-lines 80 EXIT 0; round_recover/mod.rs 95.29% lines.
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 CLIsubcommands and an exclusive goal lock so that when
jewilois killed mid-round, itsalready-spawned verifier orphans' verdicts can be harvested instead of discarded.
Closes the round-recovery exploration (10/10 threads resolved, 11 locked decisions).
Why
jewiloblocks at a gather barrier whilemverifier backends run. If jewilo is killedmid-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
STATUSand no mutual exclusion to prevent two concurrent operationsfrom corrupting the same goal.
Changes
New module
src/round_recover(95.60% line coverage):GoalLock(LD5) — RAII guard over an exclusiveflockongoals/<goalId>/.lock, held by NEW/RESUME/RECOVER for their full duration. Fail-fasttry_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 (nullincluded). Distinguishes interrupted-pass (all-APPROVE, no completion →
recover) fromdecided-failed (below n →
resume).recover(LD8/LD10/LD11) — wait-only: pollsverdict.jsonfor the current round,reuses
consensus::evaluate+compute_hash+write_completionunchanged (theverdict 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 returns
RoundDecidedNoConsensuspromptly without the full timeout.CLI wiring (LD3):
RECOVER <goalId>andSTATUS <goalId>subcommands.use RESUME N+1and exits 0.run_new/run_resume/run_recoverall acquireGoalLock.Vocabulary (LD4):
recover(cross-process, this module) vscompaction_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
071126-a9b37324,fullDigest in
completion.jsonfor goaldfe264a1. Round 1 was a REJECT (3 findingsW1/W2/W3, all fixed in
a6bd30e); round 2 approved.tests/round_recover.rs+ 6 CLI e2e intests/round_recover_cli.rs[one shared with STATUS]). Includes the e2e-surfacedSTATUS interrupted-pass fix (
ae87fe9).cargo llvm-cov --fail-under-lines 80= EXIT 0;round_recover/mod.rs95.60% lines.
jewilo-dev, ranNEWwith a slow stub, killed mid-round via SIGTERM → orphan stubs survived (LD6) and wrote
signed APPROVE verdicts →
STATUSreportedneeds: recover→RECOVERharvestedboth verdicts and wrote
completion.json(hash071126-f4ba80f6) →STATUSreporteddone. 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-loopso in-flight verdicts aren’t lost whenjewilois killed mid-round. Implements SHAPE-1 (LD3–LD11) withRECOVER,STATUS, and an exclusive goal lock; after an interruption runSTATUS, thenRECOVERorRESUMEas 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).RECOVERfails fast onneeds: "resume"(guidance + non-zero), warns and exits ondone, proceeds only onrecover.Written for commit 81ff2e0. Summary will update on new commits.
Summary by CodeRabbit
RECOVER <goalId>for wait-only same-round recovery by polling existing per-slot verdicts and re-running consensus evaluation.STATUS <goalId>returning read-only, machine-readable JSON (round/state, next action, and per-slot verdicts).RECOVERandRESUMEbased on current slot status.