Extract shared restore-or-orphan swap policy (#29) - #73
Merged
Merged
Conversation
Consolidate the tree, manifest, and binary double-failure paths behind paths::restore_or_orphan and orphan_or_retain_after_restore_failure. Call sites keep staging/publish mechanics and format errors at the edges. Observable behavior and characterization tests are unchanged. Co-authored-by: jon <jonathan10620.dev@gmail.com>
jon-devlapaz
marked this pull request as ready for review
September 9, 2026 18:14
jon-devlapaz
deleted the
cursor/issue-29-shared-restore-or-orphan-b0ab
branch
September 9, 2026 18:15
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.
Summary
Closes #29.
Three replace paths (
publish_staged_tree,manifest::write_atomic,update::replace_binary) previously duplicated the same restore-or-orphan failure policy. This PR extracts that policy intopaths::restore_or_orphanandpaths::orphan_or_retain_after_restore_failure, reusing existingorphan_recovery_path/move_file_to_orphan.What was unified vs what stayed separate
Unified (policy):
.tink-orphan-*beside destination rootkeep()fallback; error names recovery pathSeparate (mechanics at the edges):
rollback_or_retain_backup/publish_staged_tree):fs::renamerestore; stagingTempDir::keep()fallbackwrite_atomic): manifest backup restore;NamedTempFile::keep()fallback; no-backup path still usesremove_filereplace_binary): consumingpersist()restore;orphan_or_retain_after_restore_failureafter restore already failedStaging, publish, and backup capture remain with each owner — no leaky file/tree abstraction.
Proof
All passed locally (200 tests).
Docs
docs/RELIABILITY.md— notes shared helpersdocs/issue-29-verification-spike.md— matrix updated; shared helper → Done; removed stale "next PR = publish_staged_tree only" guidanceClose decision
Closes #29. Safety invariant, durable orphan naming (#72), and shared policy consolidation are complete. First-install-only staging (create paths with no prior live tree) remains intentionally out of scope — different shape, not #26-class.