Repository navigation
feat(review): select, stage, unstage, revert and commit exactly what was chosen - #94
Merged
Merged
Conversation
…ows what it verified The review/ship rail needs one honest answer to "what is the state of this repository right now?" before it can offer to stage, commit or publish anything. This is that answer, plus the piece that keeps "verified" from becoming a label with no tree behind it. review_state.ts reads the whole state in one pass through an injected Runner: repository root, remote identity, head branch and revision, base branch and the revision it resolved to, commits ahead of and behind that base, and every changed path with both halves of its status code. Three things it refuses to round off: - The push URL is read with `git remote get-url --push`, separately from the fetch URL. A configured `remote.<name>.pushurl` makes them differ, and a rail that confirmed the fetch URL would then publish somewhere the user was never shown. The pull-request target follows the push URL for the same reason. - Unknown stays unknown. An unresolvable base leaves ahead/behind null rather than zero; a base read from a local tracking ref is never reported as fetched; a failed fetch carries git's own reason. - A rename entry in porcelain v2 spans two NUL fields. Reading each field as an entry turns the origin path of every rename into a phantom changed file, so the parser consumes it deliberately. verification_record.ts stores a verify-gate result together with the identity of what it verified: the head commit and a digest of the working tree, where untracked content is hashed rather than listed (a green run that depended on an untracked fixture must not survive an edit to that fixture). classify() compares identity BEFORE it consults the exit code, so neither a stale green record nor a stale red one can be rendered as current. There is no path that upgrades unknown or stale to verified. Tests cover the parser vectors, the pushurl-divergence case, unknown-not-zero, disk round-trip, corruption and a future schema version, plus two real-git canaries. Mutation check: disabling the head-identity comparison fails three tests, including the stale-red one.
…was chosen The second layer of the review/ship rail: the mutating half. It turns a selection over the repository state from the previous commit into index and worktree changes, and it is written so that four properties are structural rather than remembered. You may only act on a path the state reported. Every entry point takes the state and a selection of names, resolves the names against the paths git listed, and refuses the ones that do not match — so a crafted name never reaches git at all rather than being escaped on the way. Combined with `--` and core.literalPathspecs, there is no route from a name to a git option. Nothing is destroyed that a preview did not name. planRevert returns the exact patch text it would discard; applyRevert re-reads the diff and refuses if it no longer matches, so an edit landing between the preview and the confirmation cancels the revert instead of discarding whatever is there now. A file with staged content is described as restoring to "its staged state", because that is what `git restore` actually does. A commit contains the selection and nothing else. planCommit refuses an index that already holds paths the user did not select (selecting them is how you include them); commitSelected stages, verifies the index equals the selection, verifies the worktree still matches the index, and resets rather than committing if either check fails. Hunk selection is real: a patch is rebuilt from the selected hunks with git's own preamble and applied with `git apply --cached`, so half a file can be staged and the rest left in the worktree. Binary files are refused rather than half-handled. Evidence: 16/16 in test/review_actions.test.ts, eleven of them driving a real repository. Mutation checks — disabling the unrelated-staged refusal fails the "someone else's staged file" test; disabling the preview comparison fails the revert-race test.
This was referenced Aug 22, 2026
Owner
Author
|
CI evidence for this stacked branch. https://github.com/AetherAI3/aether-agent/actions/runs/32579887601 — success on |
This was referenced Aug 22, 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.
Second of the AA-SHIP-02 stack. Stacked on #93 — review that one first;
this diff is only
src/core/review_actions.tsplus its tests.The mutating half of the review rail. Four properties are structural here, not
remembered:
the
RepoStateand a selection of names, resolves them against the paths gitlisted, and refuses the rest — a crafted name never reaches git at all. With
--andcore.literalPathspecson top, there is no route from a name to agit option. (
a refused selection never reaches git at allasserts zerocalls were made.)
planRevertreturnsthe exact patch it would discard;
applyRevertre-reads and refuses if thefile moved since. A file with staged content is described as restoring to
its staged state, because that is what
git restoredoes.planCommitrefuses anindex already holding unselected paths;
commitSelectedstages, verifies theindex equals the selection, verifies the worktree still matches the index,
and resets rather than committing if either check fails.
git's own preamble and applied with
git apply --cached, so half a file canbe staged and the rest left in the worktree. Binary files are refused rather
than half-handled.
Evidence
npm run typecheckclean.node --test dist/test/review_actions.test.js— 16/16 pass; eleven drive areal repository (staging isolation, hunk stage/unstage round trip, revert
preview binding, revert race, staged-state revert, untracked refusal, commit
isolation, unrelated-staged refusal, empty message).
someone else's staged file is not swept into the commit; disabling thepreview comparison fails
a file that moved between preview and confirmation is not discarded.Note for the reviewer
A second agent began writing an overlapping review/ship surface into the shared
~/aa-ship-02-wtworktree while this was in progress (src/commands/review.ts,src/core/git_review.ts,src/core/review_hunks.ts). This stack was moved toits own worktree to stop the two from overwriting each other. If that work also
becomes a pull request, the two need reconciling before either command layer
lands — the core layers (#93, this) are the part that should survive.