Repository navigation
Stage reconcile restore copies so a failed rollback cannot wipe the workspace - #356
Merged
Merged
Conversation
…orkspace restore_workspace used to clear the live tree before copy_tree. If that copy failed, rollback returned false with the original files already gone. Stage under .arbiter-reconcile-snapshots first; only then replace contents. Co-authored-by: Tyler Reckart <tylerreckart@users.noreply.github.com>
This was referenced Sep 19, 2026
…-stage-first # Conflicts: # CHANGELOG.md
tylerreckart
marked this pull request as ready for review
September 21, 2026 12:58
tylerreckart
enabled auto-merge (squash)
September 21, 2026 12:58
…-stage-first Keep this PR's restore-workspace changelog bullet alongside the secret-file and --connect URL fixes that landed on main. Co-authored-by: Tyler Reckart <tylerreckart@users.noreply.github.com>
…-stage-first Keep this PR's restore-workspace changelog bullet alongside the LaTeX math depth cap that landed on main. Co-authored-by: Tyler Reckart <tylerreckart@users.noreply.github.com>
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.
Problem
restore_workspacecleared the live workspace withclear_dir_contentsbeforecopy_treefrom the snapshot.copy_treeis not atomic: an unreadable snapshot file, disk-full, or I/O error after the clear left the tree empty or partial while restore returnedfalse.run_reconcile'sfinish_failonly setsrolled_back=truewhen restore succeeds, so callers could seestatus=failed(notrolled_back) after the original files were already gone.rollback_on_failureis supposed to put the pre-run tree back, not wipe it.Fix
Copy the snapshot into
.arbiter-reconcile-snapshots/.restore-stagingfirst (that directory is already skipped byclear_dir_contents, same aspre). Only after that copy succeeds do we clear the live tree and install the staged files. A failed stage leaves the original files in place. A failed install into the live tree leaves staging on disk so the copy is still recoverable.Tests
unit_reconcile:keep.txtis still the original bytes.Suite 21/21 locally (73 assertions) + ASan + UBSan.
Independently mergeable against
main(0456350). Does not touch files owned by #321–#355 except CHANGELOG[Unreleased], which sibling-conflicts after the first of those merges, same as the rest of the series.Note
Medium Risk
Changes reconcile rollback I/O ordering on failure paths; behavior is safer but any bug in staging/clear could still affect workspace contents during
rollback_on_failure.Overview
Reconcile rollback no longer empties the workspace when
restore_workspacefails mid-copy. The snapshot is copied into.arbiter-reconcile-snapshots/.restore-stagingfirst (skipped byclear_dir_contents, same as thepresnapshot). Only after a successful stage does the live tree get cleared and replaced from staging; a failed stage leaves original files untouched. If install into the workspace root fails, staging is left on disk for manual recovery.include/reconcile.hdocuments this contract. CHANGELOG[Unreleased]records the fix. Tests cover unreadable snapshot files (restore returns false,keep.txtunchanged) and a happy-path restore (extras removed, staging cleaned up).Reviewed by Cursor Bugbot for commit 5680aa8. Bugbot is set up for automated code reviews on this repo. Configure here.