Skip to content

feat(ship): publish HEAD and only HEAD, and bind the work to what carries it - #95

Merged
AetherAI3 merged 7 commits into
mainfrom
lane/aa-ship-02-s3-publish
Aug 23, 2026
Merged

AetherAI3 merged 7 commits into
mainfrom
lane/aa-ship-02-s3-publish

Conversation

@AetherAI3

Copy link
Copy Markdown
Owner

Third of the AA-SHIP-02 stack. Stacked on #94 (which is stacked on #93).
Strictly additive: two new core files and two new test files, nothing existing
is modified — src/core/ship.ts is imported, never touched.

src/core/publish.ts — the one place work leaves the machine

Written as refusals, because a push is the first irreversible step:

  • Only HEAD, only to its own name. The refspec is
    refs/heads/<b>:refs/heads/<b>, fully qualified on both sides. The short form
    resolves the source through git's ref lookup, where a tag or remote ref sharing
    the name is what actually travels.
  • The base is never a push target. main, master, HEAD, trunk,
    develop are refused as heads, and so is any head that equals the resolved
    base branch.
  • Nothing forces. No --force, --force-with-lease, --delete, --tags,
    --mirror, --all anywhere in the file; a test asserts the argv never grows
    one. A rejected non-fast-forward returns git's own message plus a hint that
    says this rail does not force.
  • The destination is re-read immediately before the push and compared with
    what the plan rendered. A remote that changed between confirmation and push is
    a different destination, and consent was for the old one.

planShip derives the pull request from the same state, using the remote's
push URL — so the PR opens against the repository the commits actually went
to. A non-GitHub remote is refused plainly rather than having a slug invented
for it.

src/core/ship_record.ts — session ↔ worktree ↔ branch ↔ commit ↔ PR

All five were recorded somewhere already and never joined up. Two rules:

  • A record whose commit no longer matches is rebound, not updated, so an old
    pull request never describes newer work.
  • A worktree may be cleaned up only when everything in it exists elsewhere:
    clean tree, published commit, a PR that carries it. Each failing condition
    names itself.

Branch names are hashed into the record path, never used as one (a branch called
../../../etc/passwd is a filename question otherwise).

Evidence

  • npm run typecheck clean.
  • 29/29 across test/publish.test.ts and test/ship_record.test.ts, including a
    real-git canary that clones a real bare repo, publishes a branch, and then
    asserts the branch landed at the published commit, the base ref on the server
    did not move
    , and no tags were pushed. A second canary drives
    openPullRequest through a fake gh, asserting a hostile title stays one argv
    element and no merge/--auto/--admin appears.
  • Mutation checks: dropping the protected-head list fails three tests; dropping
    the destination re-read fails the changed-remote test; carrying a stale record
    forward fails the new-commit test.

Registry

This PR registers nothing. No src/main.ts, no src/commands/cli_registry.ts,
no COMMANDS.md. The aether review / aether ship / /review / /ship
surfaces are the command layer, owned by a peer lane, and per AA-INT-05 they
should register through DISPATCH_COMMANDS rather than a new switch case.

…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.
…ries it

The third layer of the review/ship rail, and the one where work leaves the
machine. Everything before it is local and undoable; a push is neither, so
publish.ts is written as a list of refusals.

Only HEAD is pushed, to a branch of the same name, through a refspec that is
fully qualified on both sides — the short form resolves the source through
git's ref lookup, where a tag or a remote ref sharing the name is what actually
travels. A head named main, master, HEAD, trunk or develop is refused outright,
and so is a head that is also the resolved base: work committed to the base was
committed in the wrong place, and publishing it is not the fix. There is no
--force, --force-with-lease, --delete, --tags or --mirror anywhere in the file,
and a test asserts the argv never grows one. A rejected non-fast-forward push
returns git's own message plus a hint that says, in as many words, that this
rail does not force.

The destination is re-read immediately before the push and compared to what the
plan rendered. A remote that changed between the confirmation and the push is a
different destination, and the consent was for the old one.

planShip derives the pull request from the same state, using the remote's PUSH
url — so the pull request opens against the repository the commits actually went
to, which is the one thing a fetch-url slug cannot guarantee. It refuses a
non-GitHub remote plainly instead of inventing a slug.

ship_record.ts joins the five identities that were each recorded separately and
never together: session, worktree, branch, commit, pull request. Two rules carry
it. A record whose commit no longer matches is rebound rather than updated, so an
old pull request never describes newer work. And a worktree may only be cleaned
up when everything in it exists somewhere else — clean tree, published commit,
pull request that carries it. Branch names are hashed into the record path, never
used as one.

Evidence: 29/29 across test/publish.test.ts and test/ship_record.test.ts,
including a real-git canary that pushes into a real bare repository and then
asserts the base ref on the server did not move and no tags were pushed.
Mutation checks: dropping the protected-head list fails three tests; dropping
the destination re-read fails the changed-remote test; carrying a stale record
forward fails the new-commit test.
@AetherAI3

Copy link
Copy Markdown
Owner Author

CI evidence for this stacked branch (ci.yml triggers only on pull requests targeting main, so a stacked PR reports no checks of its own):

https://github.com/AetherAI3/aether-agent/actions/runs/32579889180 — success on lane/aa-ship-02-s3-publish @ 3f3a48a, via workflow_dispatch on the same workflow and the same ubuntu + windows matrix.

Base automatically changed from lane/aa-ship-02-s2b to main August 23, 2026 00:54
@AetherAI3
AetherAI3 merged commit 3fdf095 into main Aug 23, 2026
5 checks passed
@AetherAI3
AetherAI3 deleted the lane/aa-ship-02-s3-publish branch August 23, 2026 00:56
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