Repository navigation
Managed recovery: real process-death cuts and recovery scenarios for M2-M8 - #140
Merged
Merged
Conversation
Observe a stage through a no-follow, non-blocking handle (regular single-link file, 1 MiB bound, SHA-256), move it with a no-replace rename into a private discarded/<key>/ slot of its namespace and unlink it there only while its identity still matches. Checkout claim and acknowledgement stages are fenced by their constructor lock and published records; file-copy cancellation-record stages are bound to their exact origin, the namespace lock and the owner's lifetime lock, and quarantined bytes keep counting toward the snapshot cap.
Review is read-only and fingerprints the stage and Session revision; confirm re-fences the Session and owner activity, records a durable session.snapshot.construction_discarded.1 intent, quarantines and unlinks the stage and completes the receipt. A repeated request ID resumes the frozen plan, lookup never acts and maintenance retries pending unlinks hourly. Review and confirm refuse bearer, peer, browser and MCP callers with 403.
cyber sessions recovery-discard lists, reviews and confirms one stage; recovery-discard-request looks a receipt up. sessions recovery, the TUI recovery panels and cyber doctor show construction evidence and discard pending requests with the exact command; the TUI has no discard action.
A SIGKILLed claim stage refuses discard while its preparation is unresolved and for a stale review, then is discarded and worktree removal is admitted. A cut table kills the service after the intent, after the quarantine move and after the unlink; each request resumes, maintenance finishes a moved stage and doctor reports it as pending meanwhile.
A binary-document activity can neither publish a snapshot origin nor pass snapshot recovery review, before or after launch, and the refused review appends nothing. The production guards already existed; this covers the M2 obligation that snapshot workers never reuse binary-document authority.
…ft open Add debug-only process-cut points after origin publication, after intent publication, after each progress record, after filesystem completion, after the paired recovery writer commit and after the ordinary and paired journal acknowledgements. Release builds compile them out. restore_cuts.rs drives the real CLI/service through each point and checks the durable state, keep/rollback or preparation cancellation, lookup-only retries and no transcript movement or inference. It also covers a staged undo beside an inactive branch, an interrupted keep/rollback retained as independent evidence, and replacement or aliasing of the private journal namespace between review and confirmation.
…idence docs/rewind.md explains how an interrupted resolution journal is resolved before the original. implementation.md updates the M8 cut matrix and records the increment; tasks.md notes per managed-recovery task (local macOS arm64 only, platform acceptance still open).
…recovery A code preview refused because a retained restore needs owned recovery shows the recovery hint, and C sends a recovery listing request instead of another preview.
…tion A separate maintenance process runs production reclamation and is SIGKILLed once any planned payload is unlinked; a fresh owner completes the identical frozen plan once, keeps intents and the cancellation record, and lookups return the same receipts. A debug-only point after image preparation gives a deterministic fully prepared cancellation.
…ade fixture The two path helpers are only used by the Unix implementation and broke the Windows -D warnings build. The doctor JSON test now expects the new construction discards check. The upgrade test archive is compressed at the fastest level, since a stored debug binary on Linux CI now exceeds the upgrader's 512 MiB download cap.
…rd' into feat/managed-recovery-resolution
The restore_cuts fixture can now be a tracked managed Git worktree, and the progress, completion, paired writer-commit, interrupted-resolution, staged undo with inactive branch, namespace swap and damaged-intent cases run there under native-git-acceptance. A corrupt or missing retained intent refuses listing, review and a reviewed confirmation without source effects on both backends. The native snapshot proof workflow runs restore_cuts and ordinary_cuts on the Linux and macOS matrix.
Every recovery route is called on the real service after a real partial restore: stale, foreign-Session, changed-content and unknown requests are refused without effects, and lookup, repeated confirmation and acknowledgement return the same receipt. A new SDK end-to-end test kills a real service mid-restore and resolves the journal through the SDK.
Paired cleanup deleted whatever inode the keep outcome had observed in the original journal slot. An owner write racing an exchange can leave the owner's file there; it is reviewed as foreign and keep is allowed, so after retention the owner's latest bytes were unlinked. The slot inode must now be the recorded original source or prepared target, as ordinary and resolution cleanup already required.
Every repeated explicit acknowledgement rewrote both intents and swapped their slot inodes, which breaks identities pinned by a planned metadata retirement and makes a resumed retirement refuse. Published metadata is now left untouched. A resolution is also admitted only when its journal is definitely absent, not on any metadata error.
leonardoaraujosantos
marked this pull request as ready for review
November 16, 2026 22:25
Contributor
Author
|
CI on
|
On Linux CI the debug binary with line tables is larger than the upgrader's per-member archive limit, so compression alone did not keep the fixture valid. A stripped copy still runs, which the test needs to check that the next start removes cyber.old.
…rd' into feat/managed-recovery-resolution
…-resolution # Conflicts: # openspec/changes/complete-daily-coding-surfaces/implementation.md
leonardoaraujosantos
changed the base branch from
feat/construction-evidence-discard
to
main
November 18, 2026 01:54
This was referenced Nov 18, 2026
Merged
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.
Advances #93.
Includes #138: this branch contains every commit of
feat/construction-evidence-discard(#138), including theupgrade_cliarchive-limit fix, and now targetsmaindirectly; #123 is already merged.What this does
Works through managed-recovery tasks M2–M8 in
openspec/changes/complete-daily-coding-surfaces/tasks.md. Each task was checked against its wording, and this PR fills the gaps that can be closed on one machine. No recovery protocol or product behaviour changes. The only production edits are debug-only process-cut points (cyber_core::process_cut::pause), which release builds compile out.New process-cut points
cyber-snapshotcopy/restore.rs:copy-restore-origin-publishedcopy-restore-intent-publishedcopy-restore-progress-recorded(after each progress record; also fires inside keep/rollback)copy-restore-filesystem-completedcyber-serverruntime/snapshot_work.rs:recovery-pair-writer-commitrecovery-journal-acknowledgedordinary-restore-journal-acknowledgedTests (
crates/cyber-cli/tests/support/restore_cuts.rs, part ofbranches_cli)Each test runs the real CLI and service and SIGKILLs the service at a cut point. Every case also checks that the transcript does not move and that no inference starts.
intent.json, and after the intent with no staged image. The exited preparation is cancelled throughsessions recovery-preparation.binary_document_activity_never_grants_snapshot_recovery_authority.journalsdirectory is replaced between review and confirm, first by an equal-content copy, then by a symlink alias. Both are refused before any source effect.resolved_by_another_requestafter the child is resolved).code_unavailable_preview_enters_journal_recovery_with_c: from a code preview refused by a retained restore, C opens journal recovery.Docs and specs
docs/rewind.md: how to resolve an interrupted keep/rollback.implementation.md: the M8 cut matrix is updated, and the increment is recorded.tasks.md: a note under each task.Second round
Payload cleanup (M6/M8). Keep, rollback and cancelled-preparation cleanup is killed mid-deletion (
restore_cuts::cleanup). A fresh owner completes the frozen plan exactly once. A new debug point,copy-restore-images-prepared, makes the fully prepared state deterministic.Git equivalents (M3/M4/M8).
restore_cuts::managed::git_*(requiresnative-git-acceptance) runs these cases in a managed Git worktree:intent.jsondamaged_retained_intent_refuses_recovery_without_effectscovers both backends.Routes and SDK (M7).
recovery_routes_refuse_stale_and_foreign_requests_without_effectscalls every recovery route on a real service.sdk/typescript/test/recovery.e2e.test.tskills a real service mid-restore, then resolves the journal through the SDK. It also checks that stale requests get 409, foreign requests get 409/404, and nothing triggers inference or moves the transcript.Review (M8). Findings are in implementation.md under "M8 substantive code and security review". Two defects were fixed, each with a regression test that failed before the fix:
copy/reclamation/paired.rs, testkept_recovery_cleanup_never_unlinks_an_unowned_slot_inode.copy/resolution.rs, testrepeated_acknowledgement_never_rewrites_acknowledged_intents.NotFound.CI.
non-git-snapshot-proof.ymlnow runsrestore_cuts::andordinary_cuts::on ubuntu-24.04, ubuntu-24.04-arm, macos-15 and macos-15-intel.Merged the updated base branch (
20734f45).Status
All local items requested for M2–M8 are done. Tasks are ticked only where everything except platform evidence is done. Platform results come only from this PR's CI runs; see the conversation. Open owner questions are listed in implementation.md.
Verification (local macOS arm64 only)
branches_cli(40 tests) under nextestciwith--test-threads 4.terminal_preparation_recovery_survives_client_kill_with_a_committed_reply_withheldfailed its first try under load, then passed on retry.CYBER_TEST_PROCESS_CUTis set.cyber-tuiview::rewindtests.cyber-serversnapshot_recoveryunit tests.cargo fmt --check.cargo clippy --all-targets -D warnings.openspec validate --all --strict,spec_lint(0 errors) andspec_inventory --check.docs/cli.md, OpenAPI and the SDK are unchanged.