Skip to content

feat(review): structured repository state, and a verification that knows what it verified - #93

Merged
AetherAI3 merged 2 commits into
mainfrom
lane/aa-ship-02-s1-state
Aug 23, 2026
Merged

AetherAI3 merged 2 commits into
mainfrom
lane/aa-ship-02-s1-state

Conversation

@AetherAI3

Copy link
Copy Markdown
Owner

First of the AA-SHIP-02 stack (the review-and-ship rail). This PR adds no
command and changes no existing behaviour — it is the state layer the rest of
the rail is built on.

What is here

src/core/review_state.ts — one structured read of the repository:
repository root, remote identity, head branch/revision, base branch and the
revision it resolved to, ahead/behind against that base, and every changed path
with both halves of its porcelain-v2 status code. Every git call is an argv
array through an injected Runner; nothing builds a command string.

Three properties it exists to keep:

  • The push URL is read separately. git remote get-url --push can differ
    from the fetch URL via remote.<name>.pushurl. A rail that confirmed the
    fetch URL and published to the push URL would show one destination and use
    another, so both are read and the pull-request target follows the push URL.
  • Unknown stays unknown. An unresolvable base leaves ahead/behind null,
    not 0. A base read from a local tracking ref is never reported as fetched.
    A failed fetch carries git's own reason.
  • Renames are one file, not two. A porcelain-v2 rename entry spans two NUL
    fields; consuming the origin field is what keeps it from being parsed as a
    phantom changed path.

src/core/verification_record.ts — a verify-gate result stored with the
identity of the tree it verified (head commit + working-tree digest, with
untracked file content hashed, not merely listed). classifyVerification
compares identity before it looks at the exit code, so a stale green record
reads as stale and a stale red one does too. No path upgrades unknown or
stale to verified.

Evidence

  • npm run typecheck clean.
  • node --test dist/test/review_state.test.js dist/test/verification_record.test.js — 25/25 pass, including two real-git canaries.
  • Mutation check on the load-bearing invariant: disabling the head-identity
    comparison in classifyVerification fails three tests, including
    identity is checked before the exit code, so a stale RED record is stale too.

Not here

No CLI surface, no staging, no push, no gh call. Those are the next PRs in
the stack.

…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.
@AetherAI3
AetherAI3 merged commit bd05fa6 into main Aug 23, 2026
8 checks passed
@AetherAI3
AetherAI3 deleted the lane/aa-ship-02-s1-state branch August 23, 2026 00:50
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