Skip to content

ship finish chains granted fix-check rows; a pregate rerun at the same tree keeps its clears (GST-1627) - #4077

Merged
capy-ai[bot] merged 2 commits into
mainfrom
capy/gst-1627-fix-check-chain
Nov 6, 2026
Merged

capy-ai[bot] merged 2 commits into
mainfrom
capy/gst-1627-fix-check-chain

Conversation

@garrytan

@garrytan garrytan commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

Two /ship tooling gaps from #4063 (GST-1627).

finish counts every granted fix-check in a chain. A second granted fix-check (a merge resolution) logs its range from the first fix-check's commit. finish read only the newest review-fix-check row and refused any range that didn't start at the reviewed tree, so the later fix-check unbound the earlier one and lanes logged a synthetic combined row. finish now walks back from the newest row through earlier rows whose commit is the next row's range_base, to a row whose range_base holds the reviewed tree. The chain counts only when every link is a clean committed read with its own approved review_loop_grant (an earlier link's stop head must sit before its commit, so one grant never covers two fix-checks). A gap or an ungranted link refuses, and nothing in the chain counts.

A pregate rerun at the same tree keeps its clears. accept's final gstack-pregate rewrote pregate.json and dropped the macos-named-regressions and windows-smoke clears made at the same tree, so accept never exited 0. The run writer now keeps an earlier receipt for the same lane, platform, workflow and job (tests covered) under the same tree, policy and base branch, and prints PREGATE_CLEAR_KEPT:, which accept relays. Another tree, or a rerun with a failed or unfinished check, keeps nothing.

Tests: the #4063 shape (fc3, then fc4 over the merge resolution) counts both; a broken chain and an ungranted link refuse; accept at the same tree keeps the clear and exits 0; a changed tree drops it. /ship receipt to follow.

Open in Capy

{
  "schema_version": 1,
  "pr": 4077,
  "head": "27d3bb5669705a398557f23cfb54ae0ff2f03b17",
  "version": "1.96.0.0",
  "base": "main",
  "gate": {
    "tests": {
      "pass": 1611,
      "fail": 0,
      "skip": 6
    }
  },
  "ci_carried": [
    {
      "lane": "tests",
      "run": 42241538788,
      "attempt": 1,
      "tree": "80cf0613838edabe29f750be0fafa482a13e9e7e"
    }
  ],
  "session_kind": "unattended",
  "head_tree": "80cf0613838edabe29f750be0fafa482a13e9e7e",
  "product_patch_id": "56628dfcfac4160e457302324569fa3aea10ecf7",
  "gstack_version": "1.96.0.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 199,
    "rules": "70895942bb8a8ee2",
    "base": "274fb34537edc2d90e021a27d91a0a7bc61125f8",
    "registry": "274fb34537edc2d90e021a27d91a0a7bc61125f8",
    "gate_scan": {
      "tagged": 0,
      "head": "27d3bb5669705a398557f23cfb54ae0ff2f03b17"
    },
    "reasons": [
      "gate-class",
      "runtime=199"
    ],
    "risk": [],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @80cf0613838e (7 checks, current for 27d3bb566970)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/42241538788/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=80cf0613838e tests=35940 skipped=69 runs=42241538788/1 profiles=ci-reuse/free-tests heads=27d3bb566970 verified=2026-11-06T15:26:29.655Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "docs/, README.md, AGENTS.md, CLAUDE.md, CONTRIBUTING.md against base 1a06afdc19b1 (GST-1627 ship, pregate and review-policy docs)"
  },
  "review_loop": {
    "passes": 2,
    "blocking_found": 2,
    "deferred": 0,
    "noted": 7,
    "fixed": 5,
    "scope": "frozen",
    "rounds": 2,
    "ledgers_read": 5,
    "unbound": 3,
    "dispatches": {
      "specialist": 6,
      "red-team": 2
    }
  }
}

What changed

Before: main's accept drops the macOS clear made at the same tree and stops. After: this branch keeps a clear made at the same head and tree (accept exits 0 in the fixture), and one grant counts for one fix-check link

Before: main's accept drops the macOS clear made at the same tree and stops. After: this branch keeps a clear made at the same head and tree (accept exits 0 in the fixture), and one grant counts for one fix-check link.

Before/after as text: Before: main's accept drops the macOS clear made at the same tree and stops. After: this branch keeps a clear made at the same head and tree (accept exits 0 in the fixture), and one grant counts for one fix-check link
--- Before · before.txt · captured output
+++ After · after.txt · captured output
+$ bun test test/ship-accept-same-tree-clears.test.ts test/ship-finish-ruled-notes.test.ts   # this branch, 27d3bb5
+(pass) finish chains contiguous fix-check rows (GST-1627) > #4063: fc3 at its fix, then fc4 over the merge resolution, and finish counts both
+(pass) finish chains contiguous fix-check rows (GST-1627) > a gap in the chain refuses: fc4's range starts at a commit no fix-check ends at
+(pass) finish chains contiguous fix-check rows (GST-1627) > a link without its own grant refuses the chain
+(pass) finish chains contiguous fix-check rows (GST-1627) > one grant naming both links' stop heads counts for one link, and the chain refuses
+(pass) accept keeps the remote-lane clears made at its tree (GST-1627) > a clear at the same tree survives accept's final pregate, and accept exits 0
+(pass) accept keeps the remote-lane clears made at its tree (GST-1627) > a different tree drops the clear
+(pass) keepSameTreeClears (GST-1627) > keeps a receipt only for the same head, tree, policy, base branch and lane with covered tests, in a rerun that finished
+ 17 pass
+ 0 fail
-$ gstack-ship-release accept --base main --lane tests=...   # installed gstack 1.96.0.0 (main), PR #4077 at 27d3bb5
-LANE: tests carried run=42241538788/1 tests_ran=1611 (files) skipped_here=6 file(s) tests_ran_here=0 not_owed_here=6
-EVIDENCE: FRESH label=tests exit=0 tests_ran=1611 unit=files ts=2026-11-06T15:23:32.000Z source=ci runs=42241538788/1
-PREGATE: requires-remote (1 uncleared) (final tree)
-STOP: pregate requires-remote (1 uncleared) on the final tree: fix it, then rerun accept
 

Why

On #4063, "finish read only the newest review-fix-check row", so a second granted fix-check unbound the first and the lane had to log a synthetic combined row, and accept "never exited 0" because its final pregate dropped the macOS and Windows clears made at the same tree. Now finish counts a chain of granted fix-checks back to the reviewed tree, one owner grant per link, and a pregate rerun at the same head and tree keeps the clears it already has.

Blast radius

The change touches gstack-ship-release finish (its fix-check route), gstack-pregate's run writer and accept's output. Both new paths fail closed: a gap, an ungranted link or a reused grant refuses the chain, and a clear is kept only for the same head, tree, policy, base branch and obligation in a rerun whose checks all finished (read at lib/ship-release.ts fixChecked and lib/pregate/index.ts keepSameTreeClears; covered by 17 passing cases in the two test files, and by the full free suite in CI run 42241538788 at 27d3bb5).

Approvals

No approvals recorded for branch capy/gst-1627-fix-check-chain.

Summary

Two /ship tooling gaps from #4063 (GST-1627). finish now chains contiguous review-fix-check rows. Each row links to the earlier row whose commit is its range_base, back to one whose range_base holds the reviewed tree, and the chain counts only when every link is a clean committed read with its own approved review_loop_grant. A grant counts for one link only, so one grant naming two links' commits cannot cover both. Separately, a gstack-pregate rerun at the same head, tree, policy and base branch keeps each earlier receipt for the same obligation and prints PREGATE_CLEAR_KEPT: (after the record is written), which accept relays; another head or tree, or a rerun with a failed or unfinished check, keeps nothing. The /ship review's fixes landed in 27d3bb5.

Test Coverage

Step 7 audit (pass 1, audit-only): 9 of 12 changed paths have a test, 7 of 12 a strong one. The gaps it named are an earlier stale link in a chain, the --json stderr routing of PREGATE_CLEAR_KEPT, and the git-diff failure stop in fixChecked (needs a seam). docs/review-policy.md (prose) and scripts/lib/windows-curation.ts (one data row) need no naming test.

Review fixes added two regression cases: one grant naming both links' stop heads counts for one link, and the chain refuses (Regression proof — fails at HEAD: yes (run against 5220d42's lib/ship-release.ts) · passes at base: unavailable (the chain code does not exist at base) · passes after fix: yes) and a new-head row in the keepSameTreeClears unit test.

Tests ran: tests 1611 (files, carried from CI run 42241538788/1, 35940 tests at tree 80cf0613838e)

Pre-Landing Review

Pre-Landing Review: 13 issues — 0 auto-fixed, 0 asked, 4 fixed (2 blocking, from the Step 11 queue, commit 27d3bb5), 0 deferred, 9 noted. The count merges duplicates across readers: two pass-1 notes and two native findings were the same defects as the two fixed outside-voice blockers.

REVIEW_LOOP: passes=2 blocking_found=2 deferred=0 noted=7 fixed=5 scope=frozen unbound=3 ledgers_read=5 dispatches=8

Pass 1 (full panel at 5220d42: batched testing/security/state-machines specialist, Red Team) found four INFORMATIONAL items, all logged as notes. Step 11's outside voice (openai/gpt-6.1-sol, host subagent, completed) marked two findings Blocks: yes: one approved grant naming two commits counted for two chain links (lib/ship-release.ts), and a same-tree rerun at a new head carried a flaky exception bound to the old head, so accept passed while verify refused (lib/pregate/index.ts). The native adversarial pass and the Red Team found the same two. Both were fixed in 27d3bb5, with the native pass's print-after-write item. Pass 2 (full on the range 5220d42..27d3bb5) found three INFORMATIONAL items, all notes. The unbound=3 count is the three native-voice trailers on 27d3bb5, which duplicate the two outside-voice findings and the write-order note; no review row lists them.

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)

Outside review: completed (openai/gpt-6.1-sol via host subagent), recommendation "request changes" on the two findings fixed in 27d3bb5.

Review notes

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

  • INFORMATIONAL lib/ship-release.ts:279 Grant matching is greedy from the newest link back. Each link takes the unused grant whose stop head is latest in its own range, and nothing checks whether an earlier link still needs that grant. Example: grant A names a stop only in link 2. Grant B names a stop in link 1 and a later stop in link 2. Link 2 takes B, so link 1 finds no grant and finish refuses the chain, even though giving A to link 2 and B to link 1 is valid. This fails closed (a false refusal), so no data is lost, but a lane with valid grants could still be blocked.
  • INFORMATIONAL lib/ship-release.ts:278 The new rule that one grant counts for one link is keyed on the approval row's id. That id is a hash of source, date, ask, words and by (lib/approval-record.ts:169). The same owner approval recorded again on a later date or under another --source gets a new id and can cover a second fix-check link. That is the exact outcome the docs say cannot happen ('one grant never covers two fix-checks'). readRecord also unions read_also, the mirror and the local record (approval-record.ts:136), so one approval logged by two threads, or once by hand and once imported, shows up as two grants. In finish, this lets the chain pass where the rule says it should refuse. It does not lose data, and it needs a second approved review_loop_grant row with the owner's words in it.
  • INFORMATIONAL docs/ship-policy.md:1829 The docs and the fixChecked JSDoc (lib/ship-release.ts:253) both say a grant counts for 'the newest link that names it'. The code does something else. The newest link takes whichever unused grant has the latest stop in its own range. If grant S names stops in links 1 and 2, and grant N names a later stop only in link 2, then link 2 takes N and S goes to link 1. So S counts for the earlier link, against what the docs say. Lanes that read the policy to work out which grant to ask the owner for will predict the wrong pairing. This is the docs side of the greedy-matching finding already reported, not a new bypass.
  • INFORMATIONAL test/ship-finish-ruled-notes.test.ts:250 (pass 1, testing) The chain tests do not cover a stale earlier link while the newest is clean, an off-branch range_base, or a ruling at a boundary commit; keepSameTreeClears's substitution and exception carry and the policy_digest refusal have no case.
  • INFORMATIONAL lib/pregate/index.ts:500 (Step 11, native) A kept receipt can still hide a fresh carry refusal (newer_run, run_changed) at the same head; only fail, incomplete and not_installed checks stop the keep.
  • INFORMATIONAL (Step 11, native) A hand-edited pregate.json receipt now survives a same-head rerun, where a fresh rerun used to drop it; verify checks only that a receipt names the tree.
  • INFORMATIONAL lib/pregate/index.ts:502 (Step 11, native) keepSameTreeClears matches on lane, platform, workflow and job, while clearObligation writes to the first obligation with that lane name.
  • INFORMATIONAL lib/ship-release.ts:265 (Step 11, native) The chain walk takes the newest row at a range_base commit, so a stale newest row there refuses even when an older clean row exists (fails closed).

Exploratory QA

Functional surface (CLI: finish fix-check chain, gstack-pregate keepSameTreeClears), smoke bound 300 s. Pass 1 at 5220d42: the two focused test files passed 16/16, and a pure-function probe confirmed a same-tree record at a new head kept the old receipt (the finding fixed later). Revalidated at 27d3bb5: 17/17 pass, and the same probe now keeps the receipt only at the same head and tree, nothing at a new head or another tree. Verdict pass. Reports: .gstack/tmp/qa-reports/run-20261106T145515Z/functional/report.md and functional-p2/report.md (local to the /ship run). Limit: the probe exercises the pure function; the bin path is covered by the accept fixture tests.

Design Review

No frontend files changed — design review skipped.

Eval Results

No prompt-related files changed — evals skipped.

Review bot comments

No review bot comments.

Scope Drift

Scope Check: CLEAN. Intent: count chained granted fix-checks in finish and keep same-tree pregate clears through accept (GST-1627). Delivered: that, plus one Windows curation row for the new bin-spawning test file (windows-latest fails bin spawns, run 41607840098).

Plan Completion

Plan completion audit: not run (no plan is bound to this branch and no docs/designs/ file matches). Fix: add "Plan: " to the PR body, or run /autoplan.

Issues

Refs p1/red-team#1
Refs p1/red-team#2
Refs p1/specialist-batched#1
Refs s11/adversarial-native#2
Refs s11/adversarial-native#3
Refs s11/adversarial-native#6
Refs s11/outside-voice#1
Refs s11/outside-voice#2
reference s11/outside-voice#1 ← commit 27d3bb5: Review-Finding: s11/outside-voice#1 reader=outside-voice
reference s11/outside-voice#2 ← commit 27d3bb5: Review-Finding: s11/outside-voice#2 reader=outside-voice
reference s11/adversarial-native#2 ← commit 27d3bb5: Review-Finding: s11/adversarial-native#2 reader=adversarial-native
reference s11/adversarial-native#3 ← commit 27d3bb5: Review-Finding: s11/adversarial-native#3 reader=adversarial-native
reference s11/adversarial-native#6 ← commit 27d3bb5: Review-Finding: s11/adversarial-native#6 reader=adversarial-native
reference p1/red-team#1 ← commit 27d3bb5: Review-Finding: p1/red-team#1 reader=red-team
reference p1/red-team#2 ← commit 27d3bb5: Review-Finding: p1/red-team#2 reader=red-team
reference p1/specialist-batched#1 ← commit 27d3bb5: Review-Finding: p1/specialist-batched#1 reader=security

Verification Results

No plan-specific verification items (no plan file). Automatic QA above: 2 PASS, 0 FAIL, 0 BLOCKED, 0 NOT RUN.

TODOS

No TODO items completed in this PR.

Documentation

Scope: audited the committed diff against base 1a06afd (10 files) for GST-1627, covering the ship-policy, review-policy and pregate docs, the changelog.d fragment and the code they describe, plus a grep of all .md and .tmpl files for stale wording. There were no staged, unstaged or new-file changes beyond the committed diff.

Result: the docs are current. The chained fix-check behavior, including the grant-per-link rule, gap and ungranted-link refusals and the FIX_CHECK line format, and the same-tree PREGATE_CLEAR_KEPT behavior, match the implementation. Anchors #fix-check-chain and #same-tree-clears exist and are referenced from the right places.

Debt: none found. The historical CHANGELOG entry about the newest row is intentionally unchanged.

Test plan

  • bun run test (tests lane): carried from CI run 42241538788/1 at tree 80cf0613838e, 1611 files, 35940 tests, 0 failed
  • bun test test/ship-finish-ruled-notes.test.ts test/ship-accept-same-tree-clears.test.ts: 17 pass, 0 fail at 27d3bb5
  • bun run typecheck: 0 errors; test/module-size-ratchet.test.ts: 6 pass
  • free-tests.yml/macos-named-regressions cleared from run 42241538788 at 27d3bb5; gstack-pregate verify: ok

🤖 Generated with Claude Code

…e tree keeps its clears (GST-1627)

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

trunk-io Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

…e clears keep only at the same head)

Review-Finding: s11/outside-voice#1 reader=outside-voice
Review-Finding: s11/outside-voice#2 reader=outside-voice
Review-Finding: s11/adversarial-native#2 reader=adversarial-native
Review-Finding: s11/adversarial-native#3 reader=adversarial-native
Review-Finding: s11/adversarial-native#6 reader=adversarial-native
Review-Finding: p1/red-team#1 reader=red-team
Review-Finding: p1/red-team#2 reader=red-team
Review-Finding: p1/specialist-batched#1 reader=security
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai

capy-ai Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Cross-family decision-trail read (openai/gpt-6.1-sol, rule 27) at 27d3bb5. Three items stay open as notes. None meets the blocking floor, because each one either fails closed or is caught by another gate:

  • A grant whose stop head is an earlier chain link's own commit is refused for that link. finish refuses, and the lane can still log one combined row.
  • Grants are matched to links greedily, newest link first, so a chain where every link has a grant can still be refused. It never counts a link that has no grant.
  • A receipt kept at the same head can stand beside a fresh CI-carry refusal of the remote gate. The kept receipt was verified for this exact head and tree, and a newer red run still fails the required checks at this head.

Also, test/ship-accept-same-tree-clears.test.ts is excluded from the Windows-safe subset (bin shebangs; same cause as run 41607840098).

@capy-ai
capy-ai Bot marked this pull request as ready for review November 6, 2026 15:34
@capy-ai
capy-ai Bot merged commit 603d6bb into main Nov 6, 2026
65 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