Repository navigation
feat(core): E5 — e2e crash-resume proof with golden-file comparison - #19
Merged
Merged
Conversation
- Layer 1: deterministic cut points — truncate reference JSONL to header+k lines (faithful crash state, one fsynced line per commit), reopen, resume, compare golden content for every k in 0..=10. - Layer 2: real SIGKILL — child process parks inside the effect window (intent durable, settlement not), parent kills it and resumes the same session file; recovered content equals the reference. - resume_turn: new public API for crash recovery; handles pc=ToolCall without pending intent (crash window) by legal replan. - state: (ToolCall, Planning) added to the transition table — decision not yet durable means replanning is the only honest exit. - Golden compare canonicalises wall-clock timestamps only; ids, seqs, kinds, payloads must match exactly.
Pre-commit cora review caught a MAJOR: Resume::ReExecute ignored the intent's recorded safety contract, so a Guarded (Write/Destructive) effect could double-fire when a crash landed before the effect ran (the intent was durable but the side effect had not happened yet). resume_turn now gates Guarded intents behind a fresh approval: - unregistered tool -> durable UnknownTool abort (wiring changed) - non-ReadOnly risk without a resolvable gate -> durable ApprovalRequired abort; the pending cell survives so the host may re-approve and resume again - ReadOnly tools replay freely (guard is trivially satisfied) Regression test: a Guarded bomb tool that panics if replayed must surface ApprovalRequired, and the pending cell must remain set.
| safety, | ||
| } => { | ||
| // The intent's recorded replay contract decides the guard: | ||
| // `Guarded` effects require a fresh approval before replay — |
🔍 Cora AI Code Review❌ Blocked — critical issues found. 🔴 Error (1)
Review powered by cora-code · BYOK · MIT |
Contributor
Author
|
Handled the CodeCora annotation — verified as a false positive:
The finding's own condition ("If |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What (description of the change)
Epic E5, the last of Phase 1b: prove that a turn interrupted by a real crash resumes to the exact same durable content as an uninterrupted run.
klines (k = 0..=10) — a faithful crash state since every commit is one fsynced line — reopen,resume_turn, and compare canonicalised content against the golden reference. Every cut point recovers identical content.--exactre-exec + env-controlled hang tool; parent SIGKILLs it, reopens the session, resumes, and the recovered content equals the reference.resume_turn: new public API driving the recovery protocol from durable state: pending cell → replay/settle per the intent's recordedReplaySafety; pcSettling→finish; pcPlanning→ continue; pcToolCallwithout pending (the crash window between the transition commit andbegin) → legal replan.(ToolCall, Planning)added to the transition table — a decision that never became durable has only one honest exit: replanning.Resume::ReExecutewithsafety = Guardedrequires a fresh approval before re-execution; otherwise durableApprovalRequiredabort with the pending cell preserved for a host re-approval + retry.Why (the problem you're solving)
The whole point of the durable log + effect sandwich design is crash safety, but until now it was only proven at the sandwich level (E2) — never end-to-end at the turn-loop level. E5 closes that gap with a golden-file proof: for every possible crash point, the recovered session content equals the reference run. This also surfaced two real bugs fixed here: the
Planning→ToolCallcrash window left the machine in a dead state (no legal exit), andresume_turnoriginally replayed Guarded effects blind (double-fire risk for Write/Destructive tools).Testing (how you verified this works)
k = 0..=10truncation recovers to golden-identical contentbombtool (panics if replayed) surfacesApprovalRequired, pending cell survives for host re-approvalsettle_errtransitions directly to Planning —machine.rs:185), dismissed with evidenceCloses #5