feat(world): crash-safe saves (verify-readback + .bak snapshot)#120
Merged
Conversation
…e touching the real file A save is a user's level; half-written is unacceptable. No rename FFI exists, so instead of atomic replace: write <path>.tmp, READ IT BACK and byte-compare (the check that catches the historical 0-bytes-reported-ok writeFile failure), snapshot the current file to <path>.bak, then write <path>. A crash at any point leaves a verified copy in .tmp or the previous version in .bak. Applies to saveWorld and savePrefab. Verified by the editor's ui-smoke script: save produces the siblings and the saved file parses with the expected entity count. Claude-Session: https://claude.ai/code/session_01PmL9WgNMkAgvpYSHEZga8K
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesCrash-safe world and prefab saves
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant SaveOperation
participant safeWrite
participant Filesystem
SaveOperation->>safeWrite: JSON path and content
safeWrite->>Filesystem: Write temporary file
safeWrite->>Filesystem: Read back and compare content
safeWrite->>Filesystem: Snapshot existing file to .bak
safeWrite->>Filesystem: Write verified content to final path
safeWrite-->>SaveOperation: Success or error
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Editor production-readiness item 5.2 (editor PLAN.md Part 5):
saveWorld/savePrefabnow write<path>.tmp, read it back and byte-compare (catches the historical zero-byte-write-reports-success failure class), snapshot the previous file to<path>.bak, then write the real file — a crash at any point leaves a good copy on disk. True atomic replace needs a rename FFI (future).Verified by the editor's new
tools/ui-smoke.ps1interaction test.https://claude.ai/code/session_01PmL9WgNMkAgvpYSHEZga8K
Summary by CodeRabbit