Skip to content

feat(cli): restore snapshots into bounded read-only mirrors - #172

Closed
tee8z wants to merge 6 commits into
tee8z/sandbox-snapshot-planfrom
tee8z/sandbox-snapshot-extract
Closed

tee8z wants to merge 6 commits into
tee8z/sandbox-snapshot-planfrom
tee8z/sandbox-snapshot-extract

Conversation

@tee8z

@tee8z tee8z commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Parked 2026-11-10: outside the core daemon slice.

Restore authorized snapshot plaintext into a fresh, owner-only, read-only Git mirror. The reader validates the archive before staging, reserves explicit work/store capacity, imports and verifies self-contained bundles, and publishes with atomic no-replacement semantics. Local history, branches, shallow boundaries and working diffs survive. Execute permission follows Git's owner-execute bit, preserving clean diffs for group-only permissions. Excluded tracked files stay absent without appearing deleted; genuine deletions remain visible.

This layer follows archive-plan #171. It exposes the library API needed by the next snapshot CLI consumer; it adds no user restore command. check_git().await refuses unsupported platforms or unavailable/denied Git before a request. Linux and macOS require Git 2.29+. Paseo keeps its host-tools=on prerequisite.

Restore uses a private staging area, fixed bounded Git commands, full object integrity/inventory checks, explicit cancellation with cleanup, and owner-only 0400/0500 output. Each store serializes restores. Filesystem free space and configured budgets both gate admission; free space does not reveal an emptyDir quota. Callers cancel the token and await completion instead of aborting the future. Delivered local copies remain after grant expiry.

Validation:

  • All 527 CLI tests pass; all-target Clippy, formatting, diff and three lockfile metadata checks pass.
  • Ten restore journeys pass in the hardened image with UID 10001, a read-only root, no network, dropped capabilities and a 1 GiB memory cap. They include restoration of the actual packaged producer archive.
  • Real SHA-1/SHA-256 repositories cover dirty files, genuine deletions, excluded tracked paths, executable files, internal links, local branches and shallow history.
  • Destination-creation races, existing-store/work limits, deep empty repository directory costs, malformed refs, cancellation and isolated Git process teardown are covered.
  • Seven production guard mutations fail: work admission, atomic publication, excluded-path index flags, Git integrity checks, deep-directory admission, null ref IDs and Git owner-execute semantics.
  • Native just ci passed full workspace all-target Clippy in 10m10s, then stopped at a noninteractive pnpm dependency refresh. Fresh worktree dependencies are installed. Desktop/web, security-review, file-size, Tauri formatting and mobile analysis checks pass. The remaining native broad gate phases are pending compiler availability. This draft does not claim the broad gate is green.

The PR carries two already-reviewed prerequisites without rewriting published history: #168 Docker-context fix 1a1d563de as 129d5f3f4, and #170 encrypted-frame fix 119b065cc as 5e471aa9a. It also carries the #168 producer owner-execute fix e094c955e as 6a3d89561. Their owning PRs remain authoritative.

The diff has 1,651 changed lines: 209 carried prerequisite lines, and 1,442 for this layer including 529 realistic test lines. The bounded archive parser was already split into #171. The remaining staging, Git validation, cleanup and atomic publication form one filesystem safety boundary; splitting them would expose an incomplete restore API.

Independent final-source and mode-fix reviews pass. A normal production image build and its complete packaging/scanner suite pass with the actual Sprig inspector and corrected producer. Human integrated testing remains pending. Draft status is preserved; no deployment or review attestation.

Loading
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