Skip to content

Add strict no-clobber restore#30

Merged
frahlg merged 1 commit into
mainfrom
codex/m4-restore
Jul 21, 2026
Merged

Add strict no-clobber restore#30
frahlg merged 1 commit into
mainfrom
codex/m4-restore

Conversation

@frahlg

@frahlg frahlg commented Jul 21, 2026

Copy link
Copy Markdown
Member

Summary

  • add ftw restore <backup> <absent-target> with versioned JSON output
  • verify the source, hidden stage, and published target read-only
  • reject recovered raw tails, stale active rollups, corrupt selected files, symlinks, and special files
  • publish restore and backup directories with atomic no-clobber rename
  • roll back publication failures while the stage shared lock remains held
  • add a restore drill after the Linux NBD power-loss check

Safety contract

Restore copies only active.wlog, the selected manifest, and its active immutable rollups. It ignores orphan and older derived files. A deterministic CRC32 covers sorted relative paths, file lengths, and exact bytes.

An existing target, including an empty directory, remains unchanged. Linux and Apple builds use rustix::fs::renameat_with with RenameFlags::NOREPLACE; unsupported targets fail closed.

If the final parent sync or post-check fails, FTWDB verifies the published directory identity and rolls its own directory back while its shared store lock stays live. If rollback also fails, SnapshotPublication reports that state instead of hiding a visible target.

CRC32 checks byte equality, not authenticity. Restore does not repair or salvage corrupt input; salvage stays in the next PR.

Validation

  • cargo fmt --all -- --check
  • cargo clippy --all-targets --all-features --locked --offline -- -D warnings
  • cargo test --all-targets --all-features --locked --offline
  • cargo test --doc --locked --offline
  • emulator build, fmt, Clippy, and tests with locked offline dependencies
  • shell syntax checks and git diff --check
  • sanitized fixture restore: 889,978 points, 89 commits, snapshot CRC32 9ff1a95b
  • privileged OrbStack ARM64 Linux NBD power-loss and restore drill: passed
  • privileged 64 MiB NBD full-disk test: expected ENOSPC, checked 770,000-point/77-commit prefix

@frahlg
frahlg force-pushed the codex/m4-restore branch from f51d665 to 6071de9 Compare July 21, 2026 13:26
@frahlg
frahlg marked this pull request as ready for review July 21, 2026 13:29
@frahlg
frahlg merged commit 7c69d71 into main Jul 21, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant