feat(checkpoints): shadow restoreFile service for per-file rollback (B3c v2-10, epic #1375) - #53
Open
easonLiangWorldedtech wants to merge 1 commit into
Conversation
Review statusThanks for contributing. This comment tracks the review sequence and the next action. Current step: Required CI passed. Waiting for automated review of the latest commit. If automated review does not start, a maintainer must restart it. Review-state labels are managed by this workflow; do not edit them manually. |
This was referenced Sep 6, 2026
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.
What this PR does
The service half of the per-file/per-step rollback feature (B3c, epic Zoo-Code-Org#1375), stacked on #52 (v2-9):
ShadowCheckpointService.restoreFile(commitHash, filePath): restores a single file to its state atcommitHashwithout moving the branch or truncating the checkpoint list (unlikerestoreCheckpoint). A file that did not exist at the checkpoint is removed from the working tree instead — rolling a file back to before it was created. Defensive behavior: lexical path-containment guard (plus arealpathre-check on the destructive branch to see through symlinked ancestors), Windows backslash normalization for git pathspecs, and an evidence-based commit-object check before the delete branch can run.fileExistsInCommit(private): verifies the commit object withrev-parse --verifyfirst (simple-git'scat-file -erejects silently on a bad hash, which the delete branch would misread as "file absent"), then probes the tree withcat-file -e <sha>:<path>.ShadowCheckpointService.spec: arestoreFiledescribe covering the happy path, file-absent-at-checkpoint delete, Windows separator normalization, path-escape rejection (..), symlink-escape rejection, invalid-hash rejection, and the uninitialized-shadow-git error path.Line count / split rationale
264 changed lines (264+/0-) across 2 files — pure additions, below the 400 soft design target.
Plan note: the approved v2 plan placed the rollback core at #v2-10 and this service at #v2-11 (rows B12/B13). The rollback core (
rollback.ts) callsservice.restoreFile(...)at compile time, so the service PR must land first; the two PRs' content is therefore swapped relative to the plan rows, with the slugs renamed to match. The plan's Stryker invariant — every killing test for a PR's diff lines stays in the same PR — is preserved: this PR's diff is exactly the service lines and the killingrestoreFiledescribe, and #v2-11 carries the rollback core with its full spec.Provenance
2500ab3e0..10fdd195bon the upstream rollback branch; both blobs are byte-identical to the B3c head (ShadowCheckpointService.tsa4d5a567…, spec32be9b67…).Not included here (later v2 PRs)
rollback.ts+ fullrollback.spec.ts+changeJournalENOENT-only journal delta) — v2-11.Local gates
tsc --noEmit(src): clean.services/checkpoints+core/checkpoints): 7 files, 108 tests passed.--prune-suppressions --max-warnings=0on the 2 touched files: clean;src/eslint-suppressions.jsoncounts unchanged.7ae24aff5= feat(settings): change card detail control in CheckpointSettings + webview default (B3a v2-9, epic #1375) #52 head; the branch was re-based onto the re-baselined v2-9 chain before push): 54 changed-code mutants, 54 Killed, 0 Survived, 0 NoCoverage (41 changed executable lines).