Skip to content

/ship reruns the test gate when its record was taken against a different base branch (GST-3493) - #4706

Merged
capy-ai[bot] merged 5 commits into
mainfrom
test-gate-record-must-match-its-base
Nov 22, 2026
Merged

capy-ai[bot] merged 5 commits into
mainfrom
test-gate-record-must-match-its-base

Conversation

@garrytan

@garrytan garrytan commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

/ship no longer accepts a test-gate record taken against a different base branch: it reruns the gate against the base it ships to.
Why: a record cleared while a pull request was stacked on another branch still verified after the pull request was retargeted at main with the same code, though it used the other branch's policy and CI run profiles.
Nothing to do.

What changed
  • gstack-pregate verify --base <branch> refuses a record whose base names another branch (PREGATE_STALE). Without --base it behaves as before, and a record with no base still verifies.
  • /ship's finish step passes its base to that verify, so a mismatched record reruns the gate on the stamped tree instead of passing.
  • gstack-ship-queue ready and the step that writes /ship's sign-off record for the final head make the same check, so a stale record can't reach the merge queue or the sign-off either.
  • gstack-pregate clear refuses a base that already contains the recorded head (BASE_CONTAINS_HEAD), on a branch or a detached checkout, before it reads that base's policy.
  • docs/pregate.md and docs/troubleshooting.md describe the new refusal and its fix.
Why

GST-3381 (#4689) found that a test-gate record taken while a pull request was stacked on another branch kept verifying after the pull request moved to main. That record's checks used the stacked branch's policy and CI run profiles, so the merge checks could pass on evidence gathered for a different base.

Blast radius

Only the test-gate record's verify and clear paths in bin/gstack-pregate and lib/pregate/index.ts, and the three callers that now pass a base (/ship's finish step, the merge-queue check and the sign-off writer). A record whose base matches, or that names no base, verifies exactly as before; the only new outcome is a refusal that sends /ship back to rerun the gate.

Tests
  • test/pregate-verify-base.test.ts (new): a record cleared under a stacked base verifies with --base stack and is refused with --base main; a record with no base still verifies under --base; clear refuses once the stacked base holds the head, on a branch or detached, and leaves the record uncleared.
  • test/ship-release.test.ts: finish passes verify ok on a matching record and reruns the gate once the record's base names another branch.
  • test/ship-queue-ready-pr-base.test.ts: ready refuses a record from another base.

Each new case fails without its fix. CI's full free suite passed at this tree (run 45030602055).

Agent notes
Review notes

Below the blocking floor (advisory, informational, test-gap or wording items); recorded here and not fixed in this PR.

  • INFORMATIONAL sf-4bb7a4340685 security finding, details recorded privately
  • INFORMATIONAL sf-79029a8012b0 security finding, details recorded privately
  • INFORMATIONAL sf-27544975cb81 security finding, details recorded privately
  • INFORMATIONAL bin/gstack-ship-receipt:586 no test covers the base comparison in receipt write and carry; carry without --base skips it
  • INFORMATIONAL sf-632487ab67ea security finding, details recorded privately
  • INFORMATIONAL sf-bf570b47ca0b security finding, details recorded privately

GST-3493, follow-up to GST-3381 (#4689), ruled ship-as-note by GSTA-36 on finding outside-voice#2, with the clear-side BASE_CONTAINS_HEAD scope added from #4689's cross-family trail read. Round 1's second-model review raised two blockers (ready and receipt write still accepted a record from another base; the clear guard read HEAD, which is null on a detached checkout); both are fixed in ce77277. Round 2 found no blockers. Evals: none affected (no prompt, template or judge change).

Documentation (Step 14.5 audit docs-4706a-1, inserted unchanged):

Scope. The audit covered the committed diff from main (f528f5b) to the head (91efe35). The working tree was clean. The diff adds gstack-pregate verify --base, which refuses a test-gate record taken against another base branch. It also makes gstack-pregate clear refuse with BASE_CONTAINS_HEAD, and makes gstack-ship-receipt and gstack-ship-queue ready check the base. The changelog.d fragment already describes the change.

Result. Two docs were updated with small additions:

  • docs/pregate.md: verify --base <branch> now refuses a record taken against another base branch (PREGATE_STALE).
  • docs/troubleshooting.md: the PREGATE_STALE entry now explains the base-mismatch cause and its fix (rerun gstack-pregate --base <real base>). The BASE_CONTAINS_HEAD entry now says that gstack-pregate clear refuses even on a detached checkout.

Debt. None found. CHANGELOG.md, TODOS.md and VERSION were not touched, and no generated files changed.

Approvals

Plan: exempt: bug fix (merge-check correctness, GST-3493)

{
  "schema_version": 1,
  "pr": 4706,
  "head": "563b841bc34fd2f1175eccb63e6d06484f06d47a",
  "version": "1.102.2.0",
  "base": "main",
  "gate": {
    "focused": {
      "pass": 41,
      "fail": 0,
      "skip": 0
    },
    "test": {
      "pass": 1766,
      "fail": 0,
      "skip": 0
    }
  },
  "ci_carried": [
    {
      "lane": "test",
      "run": 45030602055,
      "attempt": 1,
      "tree": "a6017280330cc00e0469769c8cbd08b21ef9c901"
    }
  ],
  "calls": 20,
  "session_kind": "unattended",
  "run": "ship-4706a",
  "head_tree": "a6017280330cc00e0469769c8cbd08b21ef9c901",
  "product_patch_id": "2f382694ccf43918f21966eede566655e06105c7",
  "gstack_version": "1.102.2.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 31,
    "rules": "630fd3101899e28e",
    "base": "f528f5bacc7e50e9281b31728a2c238aca309c84",
    "registry": "f528f5bacc7e50e9281b31728a2c238aca309c84",
    "gate_scan": {
      "tagged": 0,
      "head": "563b841bc34fd2f1175eccb63e6d06484f06d47a"
    },
    "reasons": [
      "gate-class",
      "runtime=31"
    ],
    "risk": [],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @a6017280330c (8 checks, current for 563b841bc34f)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/45030602055/attempts/1",
    "windows-smoke.yml/windows-smoke: https://github.com/garrytan/gstack/actions/runs/45030604177/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=a6017280330c tests=39128 skipped=72 runs=45030602055/1 profiles=ci-reuse/free-tests heads=563b841bc34f verified=2026-11-22T14:13:05.201Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "updated",
    "scope": "docs/ and README.md (docs/pregate.md and docs/troubleshooting.md updated; bin/gstack-pregate help, the changelog.d fragment and the changed lib files read)"
  },
  "review_loop": {
    "passes": 2,
    "blocking_found": 2,
    "deferred": 0,
    "noted": 5,
    "fixed": 5,
    "scope": "frozen",
    "rounds": 2
  },
  "gate_dispositions": []
}

…ent base branch (GST-3493)

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

trunk-io Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

garrytan and others added 4 commits November 22, 2026 13:40
Review-Finding: p1/specialist-batched#2 reader=testing
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
… another base

clear checks the recorded head against the base, so a detached checkout is covered too.

Review-Finding: p1/outside-voice#1 reader=outside-voice
Review-Finding: p1/specialist-batched#1 reader=security
Review-Finding: p1/adversarial-native#1 reader=adversarial-native
Review-Finding: p1/outside-voice#2 reader=outside-voice
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai
capy-ai Bot merged commit 17afb68 into main Nov 22, 2026
85 checks passed
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