Skip to content

Stop the pre-merge check from accepting a half-finished run (GST-2194) - #4258

Merged
capy-ai[bot] merged 6 commits into
mainfrom
pregate-verify-refuses-partial-run
Nov 10, 2026
Merged

capy-ai[bot] merged 6 commits into
mainfrom
pregate-verify-refuses-partial-run

Conversation

@garrytan

@garrytan garrytan commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

The pre-merge check no longer accepts a record from a half-finished run. This serves the goal of only merging work whose secret scan and tests actually passed on the code that lands.

What changed

  • verifyPregate refuses PREGATE_INCOMPLETE unless the record holds every registered check. Because gstack-ship-queue ready and gstack-ship-receipt write call it, they refuse too. The message names what is missing: pregate.json holds checks=1 of 8 (missing: regen, secrets, …). Fail, incomplete, environment and uncleared-remote records still refuse under their own codes first.
  • The PREGATE: line prints checks=N of M.
  • A --only or --stage preflight|tests run keeps the checks it skipped from the record it replaces when head, tree, base commit, policy and registry all match, and prints PREGATE_MERGED: kept …. So the documented order (a full run, then --stage tests --remote at the same head) still verifies, and a same-tree rerun can no longer drop an earlier secrets failure. Guards-stage runs never merge, and nothing merges from the by-tree mirror (any probe run overwrites it).
  • docs/pregate.md describes the completeness rule and the same-tree merge (#same-tree-checks). docs/troubleshooting.md now names the missing-checks refusal under PREGATE_INCOMPLETE and says a fix commit needs a full run. The clone-lane mirror now stands in only for a complete record: run the full gstack-pregate --remote in the clone, or clear --receipt.

Why

The GSTA-461 audit (item 2) reproduced it. After a full run failed on secrets (github.pat), following pregate's own "rerun --stage tests" hint gave PREGATE_VERIFY: ok with the token still in HEAD. gstack-pregate --only strays (checks=1) also verified as a full pass. docs/pregate.md already called such runs "not evidence", but the code didn't enforce it.

Blast radius

Anything that verifies a pregate record: gstack-pregate verify, gstack-ship-queue ready (its own record and the by-tree mirror), gstack-ship-receipt write/carry, and the remote-gate stand-in. A record from a standalone --stage tests --remote with no full run at that head is now refused, which is the hole being closed. Test fixtures that wrote fake one-check records now write the full check list, including the crew queue tests (crew/test/ship-queue-train, -train-ops, -wave), which CI run 42718782737 showed failing at dbad74c (file:line read and the three files run 55 pass, 0 fail).

Tests

  • New: test/pregate-partial-record.test.ts. It failed 5 of 5 on main f75ce6f (including the audit repro) and passes 5 of 5 here.
  • Focused run on this branch rebased onto a5bcbc4: 351 pass, 0 fail across 16 files (my edited files plus every pregate, ship-queue or receipt test that main changed since f75ce6f). Before the rebase, an inventory of 131 related files ran green apart from the fixtures updated here.

Open notes (review round 1 at 24b3c73, all below the blocking floor, deferred)

  1. lib/ship-queue.ts: mirrorGap and its comment still describe a tests-only mirror as enough. ready treats the missing-checks refusal as final and doesn't say why a mirror stopped standing in (red-team and adversarial agree).
  2. lib/pregate/index.ts: mergeSameTreeChecks needs an exact base-commit match, so a moved origin/main keeps nothing and verify asks for a full rerun (fails closed). coordinator-contract.ts:22 and autoplan/DRIVER.md:157 still describe a staged rerun.
  3. Repair hints in lanes.ts:583, result-codes.ts:405/415, guards.ts:101 and troubleshooting.md still say to rerun one stage. After a fix commit that alone is refused, so they should name a full run.
  4. No test yet for the obligation carry on a preflight rerun or for the base/policy mismatch guard.
  5. Verify checks against the installed registry, so an upgrade that adds a check fails in-flight records closed. The missing-checks refusal is also reported after remote-uncleared refusals, and the stage-2 time can show 0 ms on an --only run.

Test Coverage

Coverage: deterministic (each of the 3 changed runtime files has a changed test naming it).

  • New: test/pregate-partial-record.test.ts. It failed 5 of 5 on main f75ce6f (including the audit repro) and passes 5 of 5 here.
    Tests ran: test 1659 (files, carried from CI free-tests run 42732479322 at tree c58c4b924efe)

Pre-Landing Review

Pass 1 (full panel at dbad74c): specialist-batched, red-team, native adversarial and outside voice (GPT-6.1 Sol, CLEAN). No blocking review finding. CI free-suite run 42718782737 then failed 19 tests in three crew queue test files whose fixtures wrote one-check records; fixed in c676d76 (fixtures only). Pass 2 on dbad74c..c676d76: specialist-batched and red-team, NO FINDINGS.
REVIEW_LOOP: passes=2 blocking_found=0 deferred=0 noted=3 fixed=1 scope=frozen ledgers_read=4 dispatches=8
Gate edits: 37 listed, 28 read, 0 findings (patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)
Outside review: GPT-6.1 Sol (host subagent), completed, VERDICT: CLEAN.

New notes (/ship review at dbad74c and c676d76, all below the blocking floor)

  1. lib/ship-queue.ts:292: a partial local record vetoes a complete by-tree mirror because the missing-checks refusal reuses PREGATE_INCOMPLETE; fails closed (specialist and native adversarial).
  2. lib/ship-queue.ts:247: no queue test pins the tests-only mirror refusal; stale --stage tests --remote guidance also sits in scripts/ubicloud/pregate-remote.sh:53 and ubicloud/SKILL.md.tmpl:166.
  3. lib/result-codes.ts:420 and lib/pregate/remote-receipt.ts:81 point at the paid --stage tests --remote run, which verify refuses at a moved head or base, so it can waste a paid gate (red-team).
  4. docs/pregate.md promises a guards record keeps nothing, which only the separate default --out enforces; stage clocks are not carried on an --only run at --stage all (cosmetic).
  5. PREGATE_INCOMPLETE's generic opening and fix text (timeouts, missing tools) wrap the missing-check message (QA capture 003); wording.
  6. Remaining single-entry pregate fixtures, all intentional or refused for their own status first, all green in CI run 42732479322: crew/test/ship-queue-train.test.ts:101 (fail record), test/gstack-ship-queue.test.ts:318/342/350/354, test/headless-artifacts.test.ts:242, test/ship-accept-same-tree-clears.test.ts:124/140.

Exploratory QA

Functional smoke on the branch's bin/gstack-pregate in an isolated worktree of dbad74c: --only strays records checks=1 of 8 (pass); verify refuses PREGATE_INCOMPLETE naming the 7 missing checks (pass); a same-tree --only literals prints PREGATE_MERGED: kept strays=pass, checks=2 of 8 (pass). Evidence verdict: inconclusive, because capture 001 ran the installed main-branch binary by mistake and is recorded as superseded.

Eval Results

No prompt-related files changed — evals skipped (eval:select picks no gate cases; CI evals.yml covers the PR profile).

Plan Completion

Plan completion audit: not run (no plan is bound to this branch: bug fix, plan exempt).

TODOS

No TODO items completed in this PR.

Documentation

Status: updated. One factual line was added to docs/troubleshooting.md; there are no blockers.

Scope: the committed diff from 97b796e to c676d76 (pregate verify now refuses a record from a partial run, and a staged rerun on the same tree keeps the checks it skipped), plus the unstaged docs/troubleshooting.md change. Nothing was staged and there were no new files. Every .md and .tmpl file was searched for --stage tests and --only usage.

Documentation health

  • docs/pregate.md: current (already describes checks=N of M, PREGATE_INCOMPLETE and same-tree-checks)
  • docs/troubleshooting.md: updated (the PREGATE_LANE_FAILED fix now says a fix that changes the tree needs a full run before verify)
  • CONTRIBUTING.md: current
  • docs/TESTING_INTERNALS.md: current
  • crew/docs/recommended-harness.md: current
  • autoplan/DRIVER.md: current
  • spec/sections/gate-and-file.md: current
  • ubicloud/SKILL.md.tmpl: current

Coverage debt: none. The verify refusal and the PREGATE_MERGED line have reference coverage in docs/pregate.md and docs/troubleshooting.md and a how-to in the fix text.

Diagram drift: none.

Test plan

  • bun run test: carried from CI free-tests run 42732479322 at tree c58c4b924efe (1659 files)
  • crew/test/ship-queue-train.test.ts, ship-queue-train-ops.test.ts, ship-queue-wave.test.ts: 55 pass, 0 fail locally after c676d76

Status: ready. /ship finished at ec34bb5: two review passes, the Step 14.5 docs audit, finish and push, the CI carry from free-tests run 42732479322, the macOS named-regressions lane cleared from the same run, and PREGATE_VERIFY: ok at tree c58c4b924efe. The ship receipt is in the Agent notes.

Plan: exempt: bug fix

Agent notes

GST-2194, audit GSTA-461 item 2, lane GSTA-465. Scope extensions approved by the Captain: test/gstack-ship-queue.test.ts, test/ship-accept-remote-gate-lanes.test.ts, docs/pregate.md. Rebased onto #4235's landing commit a5bcbc4 with one fixture conflict resolved. Peer note: handoffs/GSTA-465/gbrain-note.md.
REVIEW_LOOP: passes=2 blocking_found=0 deferred=0 noted=3 fixed=1 scope=frozen ledgers_read=4 dispatches=8
Gate edits: 37 listed, 28 read, 0 findings (patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)

{
  "schema_version": 1,
  "pr": 4258,
  "head": "ec34bb55d4490a1f4573b45718ab148ce7a35904",
  "version": "1.98.0.0",
  "base": "main",
  "gate": {
    "test": {
      "pass": 1659,
      "fail": 0,
      "skip": 0
    }
  },
  "ci_carried": [
    {
      "lane": "test",
      "run": 42732479322,
      "attempt": 1,
      "tree": "c58c4b924efe5bb313cc3b6a77f108b1ae832772"
    }
  ],
  "session_kind": "unattended",
  "head_tree": "c58c4b924efe5bb313cc3b6a77f108b1ae832772",
  "product_patch_id": "1992b5f67f33c311662a25ddfbe6329b5987bbfb",
  "gstack_version": "1.98.0.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 78,
    "rules": "66e5174161eecc2c",
    "base": "97b796e5aee42ab4b304aadeedd8b417fd950d94",
    "registry": "97b796e5aee42ab4b304aadeedd8b417fd950d94",
    "gate_scan": {
      "tagged": 0,
      "head": "ec34bb55d4490a1f4573b45718ab148ce7a35904"
    },
    "reasons": [
      "gate-class",
      "runtime=78"
    ],
    "risk": [],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @c58c4b924efe (8 checks, current for ec34bb55d449)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/42732479322/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=c58c4b924efe tests=36958 skipped=68 runs=42732479322/1 profiles=ci-reuse/free-tests heads=ec34bb55d449 verified=2026-11-10T01:22:39.325Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "updated",
    "scope": "docs/, README.md, AGENTS.md, CLAUDE.md, CONTRIBUTING.md (base 97b796e5 to c676d76a)"
  },
  "review_loop": {
    "passes": 2,
    "blocking_found": 0,
    "deferred": 0,
    "noted": 3,
    "fixed": 1,
    "scope": "frozen",
    "rounds": 2,
    "ledgers_read": 4,
    "dispatches": {
      "specialist": 6,
      "red-team": 2
    }
  }
}

Open in Capy

@trunk-io

trunk-io Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

garrytan and others added 4 commits November 9, 2026 23:14
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>
…the rest

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…ane is a remote obligation

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@garrytan
garrytan force-pushed the pregate-verify-refuses-partial-run branch from e9794d9 to dbad74c Compare November 9, 2026 23:14
@capy-ai capy-ai Bot changed the title Stop pregate verify from passing a record from a partial run (GST-2194) Stop the pre-merge check from accepting a half-finished run (GST-2194) Nov 9, 2026
garrytan and others added 2 commits November 10, 2026 00:01
The train, train-ops and wave tests wrote one-check pregate records, which verify now refuses as a partial run. They now write every registered check, as test/gstack-ship-queue.test.ts already does (CI free-suite run 42718782737).

Review-Finding: lib/pregate/index.ts:251:functional-contract reader=core
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Documents that verify refuses a record missing registered checks, and that a fix commit needs a full gstack-pregate run (Step 14.5 docs audit).

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai
capy-ai Bot merged commit 56c4e87 into main Nov 10, 2026
82 checks passed
capy-ai Bot added a commit that referenced this pull request Nov 10, 2026
…T-2282) (#4271)

* Give the ship-queue ready tests complete pregate records

The notes-push and fresh-base suites wrote a one-check pregate record, which ready refuses as a partial run since #4258. They now write every registered check, as the other queue tests do.

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

* Add a changelog entry for the ship-queue ready test fix

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>
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