Skip to content

Make the ship queue fetch the latest main before it checks a pull request (GST-2232) - #4256

Merged
capy-ai[bot] merged 3 commits into
mainfrom
ready-fetches-base-before-receipt-check
Nov 10, 2026
Merged

capy-ai[bot] merged 3 commits into
mainfrom
ready-fetches-base-before-receipt-check

Conversation

@garrytan

@garrytan garrytan commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

What changed

gstack-ship-queue ready now fetches origin/<base> before it reads the base policy or checks any field of the PR's /ship receipt. Before this, it used whatever copy of the base the lane's clone last fetched. If that copy was a few landings old, ready measured the PR from an older merge base, counted excluded files that belong to PRs that had already landed, and refused a good receipt with a false RECEIPT_INVALID field=review_exclude. That stopped gbrain #8991, whose clone held origin/master at d253ec0f while the real master was 310da193.

  • When the fetch fails, ready refuses with a new code, QUEUE_BASE_UNFETCHED, and compares nothing. The stamp path of land used to ignore a failed fetch and keep going; it now refuses with the same code. land --pin (direct merges) already fetched and refused.
  • No change to how the review_exclude selection is measured. It was already the PR's own files, diffed from the merge base. A new test pins that: a file another PR lands on the base after this PR forked does not change the selection.

Why

This unblocks the gbrain merge queue (GBRA-108): lanes were being sent to rerun /ship's review for receipts that were correct.

Blast radius

ready makes one extra git fetch of the base branch per run. The new refusal only fires when that fetch fails, and in that case ready would otherwise have compared the receipt against a ref it couldn't refresh. The train paths are unchanged, because train ready already fetched.

Tests

  • New file test/ship-queue-ready-fresh-base.test.ts. In its first test, the lane's origin/main is behind the remote after a stacked parent landed. Before the fix, ready refused with RECEIPT_INVALID … source=origin/main@<stale tip>; after it, the receipt binds. The same test checks that an unreachable origin refuses with QUEUE_BASE_UNFETCHED. The second test checks that a base which moved under the exclusion leaves the selection unchanged; it fails if the selection is changed to a two-dot diff.
  • One test added to test/ship-queue-land.test.ts: an unfetchable base refuses before the receipt check, and nothing is pushed.

Review notes

Below the blocking floor; recorded here and not fixed in this PR. Review ran once at 620f102 (specialists, red team, adversarial and an outside voice); none of these would fail a test, break production or lose data under this repo's merge: direct policy.

  • lib/ship-queue-land.ts:344: the stamp path of land fetches with a bare git fetch -q origin <base>, which leaves origin/<base> stale in a single-branch or narrowed-refspec clone, and land() loads its policy before that fetch. Not reachable here: under merge: direct, land() refuses at line 330 before it fetches. A follow-up could use the same explicit refspec as ready.
  • bin/gstack-ship-queue:200: the CLI picks the train or plain ready route from the policy before ready fetches, so a repo whose train setting changed since its last fetch could take the wrong route. This repo has no train block.
  • Two ready runs in one clone can race on the origin/<base> ref lock and report QUEUE_BASE_UNFETCHED; a rerun clears it.
  • The refusal echoes git's first stderr line (capped at 200 characters); git redacts credentials there, and an existing path already prints it.
  • ready fetches origin and ignores ctx.remote, matching the rest of ready().

Exploratory QA

Pass. Two smoke probes against an isolated fixture: a stale origin/main is refreshed to the remote tip by ready, and an unreachable origin refuses with QUEUE_BASE_UNFETCHED (exit 3) and leaves the ref untouched.

Documentation

Status: current. The release docs match the code at 620f102, and no edits were needed.

Scope: 3 commits from a5bcbc4 across 10 files: lib/ship-queue.ts, lib/ship-queue-land.ts, lib/result-codes-release.ts, bin/gstack-doctor-components.sh, scripts/lib/windows-curation.ts, two tests, docs/ship-policy.md, docs/troubleshooting.md and a changelog.d fragment. Nothing is staged, unstaged or untracked.

Documentation health:

  • docs/ship-policy.md: current. It describes the base fetch in ready and the stamp-path refusal of land; land --pin still uses QUEUE_NOT_READY, which the code confirms.
  • docs/troubleshooting.md: current. The new queue-base-unfetched entry matches the anchor in the result code.
  • changelog.d/ship-queue-ready-fetches-base-gst-2232.md: current.
  • README.md, AGENTS.md, CLAUDE.md, docs/pregate.md: current, with no change needed.

Coverage debt: none. QUEUE_BASE_UNFETCHED has a reference entry and a fix entry. Diagram drift: none.

Approvals

No approvals recorded for branch ready-fetches-base-before-receipt-check.
Plan: exempt: bug fix
Plan check: exempt bug fix

Agent notes

GST-2232, lane GSTA-476. Docs: docs/ship-policy.md (ready's receipt checks and the review_exclude digest), and a new docs/troubleshooting.md#queue-base-unfetched anchor. Changelog fragment changelog.d/ship-queue-ready-fetches-base-gst-2232.md is marked important: blocker. Rebased onto #4235 (a5bcbc4), which owned lib/ship-queue.ts; GSTA-475's files (lib/ship-receipt.ts, review-plan) are untouched.

Pre-Landing Review: 2 issues — 0 auto-fixed, 1 asked (0 fixed, 1 skipped), 0 deferred, 1 noted
Gate edits: none detected (2 listed, 0 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)
REVIEW_LOOP: passes=1 blocking_found=0 deferred=0 noted=1 fixed=0 scope=frozen ledgers_read=3 dispatches=2 est_input_tokens=11013

Open in Capy

Agent notes
{
  "schema_version": 1,
  "pr": 4256,
  "head": "620f10244aca8f62024639186d77a91322409d7b",
  "version": "1.98.0.0",
  "base": "main",
  "ci_carried": [
    {
      "lane": "free",
      "run": 42724075987,
      "attempt": 1,
      "tree": "7e32c4b922d06a5a187d4b875ba6ff1cc907ae74"
    }
  ],
  "session_kind": "unattended",
  "head_tree": "7e32c4b922d06a5a187d4b875ba6ff1cc907ae74",
  "product_patch_id": "1949c60ad067f9b216ad6a2ef3ea88cf8851fe7e",
  "gstack_version": "1.98.0.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 25,
    "rules": "66e5174161eecc2c",
    "base": "7dace1fdeabc4ad5ebddcf9f5fa3b80279a68121",
    "registry": "7dace1fdeabc4ad5ebddcf9f5fa3b80279a68121",
    "gate_scan": {
      "tagged": 0,
      "head": "620f10244aca8f62024639186d77a91322409d7b"
    },
    "reasons": [
      "gate-class",
      "risk:security",
      "runtime=25"
    ],
    "risk": [
      "security"
    ],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @7e32c4b922d0 (8 checks, current for 620f10244aca)",
  "requires_remote": [
    "free-tests.yml/cso-macos-launcher: https://github.com/garrytan/gstack/actions/runs/42724075987/attempts/1",
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/42724075987/attempts/1",
    "windows-smoke.yml/windows-smoke: https://github.com/garrytan/gstack/actions/runs/42724080491/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=7e32c4b922d0 tests=36926 skipped=106 runs=42724075987/1 profiles=ci-reuse/free-tests heads=620f10244aca verified=2026-11-10T00:43:46.385Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "docs/, README.md, CLAUDE.md, AGENTS.md at 620f102 (read-only audit)"
  },
  "review_loop": {
    "passes": 1,
    "blocking_found": 0,
    "deferred": 0,
    "noted": 1,
    "fixed": 0,
    "scope": "frozen",
    "rounds": 1,
    "est_input_tokens": 11013,
    "ledgers_read": 3,
    "dispatches": {
      "specialist-batched": 1,
      "red-team": 1
    }
  }
}

…T-2232)

ready read origin/<base> as the clone last fetched it, so a lane a few landings behind measured the PR from an older merge base and refused a good receipt with a false RECEIPT_INVALID field=review_exclude. ready now fetches the base first and refuses QUEUE_BASE_UNFETCHED when it cannot; the stamp path of land refuses the same way instead of ignoring a failed fetch.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@trunk-io

trunk-io Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

…GST-2232)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai capy-ai Bot changed the title Make ship-queue ready fetch the base before it checks the receipt (GST-2232) Make the ship queue fetch the latest main before it checks a pull request (GST-2232) Nov 9, 2026
…ath uses the new refusal (GST-2232)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
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