Commit 88b558d
authored
Add atomic multi-file mode with write-ahead journal and recovery (#19)
* Add atomic multi-file two-phase commit with write-ahead journal
Implement --atomic flag for all-or-nothing multi-file operations using a
two-phase commit protocol with a JSON write-ahead journal. When enabled,
all file changes are first staged to temp files (phase 1), then atomically
renamed over originals (phase 2). If the process is interrupted, a
subsequent --recover run can roll back or --recover-forward to complete.
Key features:
- --atomic flag implies --backup via hard-links for safe rollback
- --no-backup opt-out with explicit warning about rollback limitations
- .toggle-atomic.journal WAL in CWD for crash recovery
- .toggle-atomic.lock advisory lock prevents concurrent --atomic runs
- Signal handling (SIGTERM/SIGINT) for graceful interrupt with journal preservation
- Platform helpers: macOS F_FULLFSYNC, Windows rename retry with backoff
- SHA-256 integrity verification for forward recovery
- into_temp_path() fd release pattern for large batch support (>500 files)
- CLI validation: --atomic rejects --dry-run, --no-backup requires --atomic
- 13 new integration tests covering happy path, recovery, validation, and edge cases
New files: src/journal.rs, src/platform.rs
New deps: sha2, signal-hook, fd-lock
https://claude.ai/code/session_01JTuqZjgo3pPPF5YUeGKarz
* Fix clippy warnings and formatting for CI compliance
- Replace io::Error::new(io::ErrorKind::Other, ...) with io::Error::other()
- Remove identical if/else branches in stage() encoding check
- Prefix unused encoding parameter with underscore
- Apply cargo fmt formatting
https://claude.ai/code/session_01JTuqZjgo3pPPF5YUeGKarz
* Add libc dependency for macOS F_FULLFSYNC support
The platform.rs macOS cfg block uses libc::fcntl and libc::F_FULLFSYNC
but libc was missing from Cargo.toml, causing macOS CI builds to fail.1 parent ec4ad31 commit 88b558d
9 files changed
Lines changed: 1738 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
39 | 49 | | |
40 | 50 | | |
41 | 51 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
96 | 115 | | |
0 commit comments