Skip to content

Local checks reuse every green CI run at your code, not only the first (GST-3381) - #4671

Merged
capy-ai[bot] merged 4 commits into
mainfrom
pregate-ci-reuse-unions-green-runs
Nov 22, 2026
Merged

capy-ai[bot] merged 4 commits into
mainfrom
pregate-ci-reuse-unions-green-runs

Conversation

@garrytan

@garrytan garrytan commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

Local checks before opening a PR now reuse the newest verified CI run per eligible profile at your exact code, so files an end-to-end run already passed beside the test run no longer run again on your machine.
Before, only the first matching profile's run counted; a failed run, a run of different code, or a run that changes while it is being read still counts for nothing.
Nothing to do: this changes what runs locally, not what CI runs.

What changed
  • The local check that reuses CI results now keeps the newest verified run of each eligible profile at your exact code, verifies each one on its own, reads them all again once they are collected, and counts the test files any of them ran.
  • A failed run, a run of different code, or a run that moves to a new attempt while the others are read adds nothing (the last case refuses the reuse, so every selected test runs locally).
  • A new test reproduces the bug with a Test run and an E2E run (it fails on main and passes here), with a failed E2E run and an E2E run of other code as negative controls.
Agent notes

Agent notes

Files

  • lib/pregate/index.ts: the CI carry keeps every run profile that verified at HEAD's tree (ctx.fromRun.runs) instead of stopping at the first; the remote-gate clear uses the run under the gate's profile.
  • lib/pregate/checks/lanes.ts: fromRun verifies each kept run under its own profile and unions their tree.json files.
  • lib/pregate/types.ts, docs/pregate.md, changelog.d/ fragment, test/pregate-ci-carry-profiles.test.ts. Commit 14c3760 points the test's state root at its fixture home, so it no longer writes the runner's real ~/.gstack/security/egress.jsonl (CI's free suite refused shard 9 for that at 92dc2e9).
  • Commit 860fe60 (cross-family trail read blocker, owner grant a-9f7bcc32d32c): fromRun rereads every kept run with runChanged once the union is built, as findCarry does, and refuses the reuse on any change; docs/pregate.md says a remote_gate_runs naming two profiles is refused by the carry; a new case flips the Test run to a red attempt while the E2E run is read. One scoped fix-check on 14c3760..860fe60: clean, one informational note (the reread runs only when two or more runs verified; lib/pregate/checks/lanes.ts:745).

Pre-Landing Review

Pre-Landing Review: 13 issues — 0 auto-fixed, 0 asked, 1 deferred, 7 noted, 4 skipped (informational, below the blocking floor), 1 ruled note
Gate edits: none detected (GATE_SCAN tagged=0 at 14c3760)
Scope Check: CLEAN
Coverage: 7/9 paths (78%); gaps: which carried run feeds the gate clear, and the skipped count across runs
Exploratory QA: no server or browser surface; smoke covered by the targeted test lane (494 tests) including the red-run and other-tree negative controls

Pass 1 (full panel plus second-model review) raised the findings below; pass 2 read the test-only fix range and found nothing.

Deferred findings

Blocking findings in code this PR did not change (review scope: frozen). They stay on this PR and are not filed as issues.

  • Deferred: CRITICAL lib/pregate/index.ts:136 1. Multi-profile remote gates never auto-clear. lib/pregate/index.ts:136 passes only ctx.fromRun.ref to clearByRuns, which requires exactly one distinct run per remote_gate_runs profile. If two declared runs are green and jointly cover the gate inventory, but a gate-only file leaves a remote obligation, pregate still refuses with got 1. Small-machine shipping stays blocked until someone clears the gate manually. Pass the verified runs for the configured gate profiles to clearByRuns. Severity: High. Blocks: yes.

Review notes

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

  • INFORMATIONAL lib/pregate/checks/lanes.ts:747 1. Duplicate run in the receipt (lib/pregate/checks/lanes.ts:747). Say two base profiles share a workflow and OS but list different jobs. They can resolve to the same run id, and then the receipt shows runs=123/1,123/1 and counts tests= twice. The union of files is still correct; only the receipt number is wrong. Fix: dedupe ok by run_id/run_attempt before summing and before calling runReceiptFields. FIXABLE. Severity: Low. Blocks: no.
  • INFORMATIONAL lib/pregate/index.ts:136 2. Remote gate gets one run even though all runs are now known (lib/pregate/index.ts:136, with :87). carryGate still passes only [ctx.fromRun.ref] to clearByRuns. So a base whose remote_gate_runs names two profiles is always refused with "exactly 2 run(s)", even though ctx.fromRun.runs now holds both verified runs. This existed before the change, but the change makes it a one-line fix: pass runs.filter(r => gateRuns.profiles.includes(r.profile)).map(r => r.ref). FIXABLE. Severity: Low. Blocks: no.
  • INFORMATIONAL lib/pregate/index.ts:88 3. CI_CARRY line can list a run that REUSE later drops (lib/pregate/index.ts:88 against lanes.ts:740–742). autoCarry prints CI_CARRY: accepted A + B from findCarry. Then fromRun verifies again and silently drops any run that fails (for example a docs-only run with no files). The REUSE line shows the true smaller set, but the CI_CARRY line pasted into READY claims more than was used. FIXABLE. Severity: Low. Blocks: no.
  • INFORMATIONAL lib/pregate/checks/lanes.ts:742 4. Refusal reason comes from the first run only (lib/pregate/checks/lanes.ts:742). When every run fails re-verification, the REUSE refusal names only the first profile's reason, which hides the others. Fix: join every refused verdict, as verifyFromRun does. FIXABLE. Severity: Low. Blocks: no.
  • INFORMATIONAL lib/ship-release.ts:740 5. Long CI_CARRY line gets truncated (lib/ship-release.ts:738–740). A line with several receipts joined by + is clipped to 240 characters there, so the second receipt can be cut off in release output. Display only. FIXABLE. Severity: Low. Blocks: no.
  • INFORMATIONAL lib/pregate/index.ts:80 6. More GitHub API calls per pregate (lib/pregate/index.ts:80). autoCarry used to stop at the first accepted profile. It now runs findCarry and then verifyFromRun for every matching profile, which adds run and artifact reads against the shared 7,900-per-hour budget. This only matters on repositories with several same-OS profiles. INVESTIGATE (is the extra coverage worth the calls?). Severity: Low. Blocks: no.

Skipped (informational, below the floor)

  • docs/pregate.md says the carried runs clear the remote gate, but carryGate passes one run (lib/pregate/index.ts:136).
  • Untested: the gate-profile preference for fromRun.ref, and the skipped count when another run ran the file.
  • Two profiles resolving to one run id would list it twice in the receipt and double tests= (lib/pregate/checks/lanes.ts:746).
  • CI_CARRY: accepted A + B can name a run that the later re-verification drops without saying why (lib/pregate/checks/lanes.ts:742).

Documentation

Status: current. The docs already match the change, so no edits were made and nothing blocks.

Scope: candidate base c2b4f0d2 to head 860fe60, 6 committed files (lib/pregate/{index,types,checks/lanes}.ts, a new test, docs/pregate.md and a changelog.d fragment). Nothing was staged, unstaged or untracked. Every Markdown and template file was searched for the changed output formats (CI_CARRY: accepted, REUSE: accepted).

Documentation health:

  • docs/pregate.md: current. The branch's edit to #ci-carry describes how reuse now combines every green profile run at the tree, the CI_CARRY: accepted <receipt> + <receipt>… format, and the refusal of a remote_gate_runs that names two profiles. The --from-run receipt format (runs=<id>/<attempt>) still holds.
  • changelog.d/pregate-ci-reuse-unions-green-runs.md: current and accurate. It was reviewed only and not edited.
  • docs/ship-policy.md: current. Its CI carry references are generic.

Coverage debt: the behaviour change has reference coverage (docs/pregate.md) and an explanation of why a red run or a run on another tree adds nothing. No tutorial covers it, which is acceptable for an internal gate flag. No critical gaps.

Diagram drift: none. No diagrams reference the changed modules.

Tests

  • bun test test/pregate-*.test.ts (40 files): 494 tests passed at 14c3760
  • At 860fe60: the four focused files (pregate-ci-carry-profiles, pregate-from-run, pregate-carry-gate, pregate-remote-gate-runs) pass, 15 tests; the full 40-file run hit unrelated 5 s timeouts on a slow machine (each passed on one rerun)
  • CI at 860fe60: every check green; Free Tests run 45003114028 (dispatched on the branch) carried

Approvals

Approved: yes (record r-6fe014209a01). The full approval record stays private.
Plan: exempt: bug fix with a failing-first test (GST-3381)
Plan check: exempt bug fix

Ruled note: lib/pregate/checks/lanes.ts:744:correctness at 92dc2e9 ruled by GStack Minder (relayed from GSTA-36:2026-11-22T05:25:48Z) at 2026-11-22T05:42:33.064Z: same verify-then-use window as the single-run path; below the blocking floor (approval a-8f868ce8a09b)
Review-loop exception: accepted by GSTA-36 2026-11-22 via GStack Minder grant relayed by the #4671 lane (approval a-9f7bcc32d32c): Match findCarry's documented reread-after-collect contract and correct the docs; scoped read only. (fix-check at 14c3760, 1 finding)
Gate edits: none detected (GATE_SCAN tagged=0 at 14c3760)

Open in Capy

{
  "schema_version": 1,
  "pr": 4671,
  "head": "860fe6080ee884484de82dd6f297bb229fce9237",
  "version": "1.102.2.0",
  "base": "main",
  "calls": 98,
  "session_kind": "unattended",
  "run": "ship-pregate-ci-reuse-unions-green-runs",
  "head_tree": "1b860c5700d162527a0312e78b3fc07c00222108",
  "product_patch_id": "4d0a5661c21edca98b8a287581495d808caa1128",
  "gstack_version": "1.102.2.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 62,
    "rules": "630fd3101899e28e",
    "base": "0b4f0ceeec19fef62480db6c8eb00c4015380a39",
    "registry": "0b4f0ceeec19fef62480db6c8eb00c4015380a39",
    "gate_scan": {
      "tagged": 0,
      "head": "860fe6080ee884484de82dd6f297bb229fce9237"
    },
    "reasons": [
      "gate-class",
      "runtime=62"
    ],
    "risk": [],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @1b860c5700d1 (8 checks, current for 860fe6080ee8)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/44998794722/attempts/1",
    "windows-smoke.yml/windows-smoke: https://github.com/garrytan/gstack/actions/runs/44998794728/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=1b860c5700d1 tests=38818 skipped=72 runs=45003114028/1 profiles=ci-reuse/free-tests heads=860fe6080ee8 verified=2026-11-22T08:54:17.444Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "docs/ and README.md (152 docs files hashed); docs/pregate.md#ci-carry already updated by this branch"
  },
  "review_loop": {
    "passes": 2,
    "blocking_found": 2,
    "deferred": 1,
    "noted": 8,
    "fixed": 0,
    "scope": "frozen",
    "fix_checks": 1,
    "rounds": 2,
    "ledgers_read": 6,
    "dispatches": {
      "specialist": 6
    }
  },
  "review_loop_exception": {
    "accepted_by": "GSTA-36",
    "date": "2026-11-22",
    "via": "GStack Minder grant relayed by the #4671 lane (approval a-9f7bcc32d32c)",
    "reason": "Match findCarry's documented reread-after-collect contract and correct the docs; scoped read only.",
    "fix_check": {
      "head": "14c3760deee3e4f0577acd9b5744661c9fd1abd4",
      "findings": 1
    }
  },
  "ruled_notes": [
    {
      "finding": "lib/pregate/checks/lanes.ts:744:correctness",
      "head": "92dc2e99d3eb99cc4cb17d2e5efbff18d45e2946",
      "by": "GStack Minder",
      "reason": "same verify-then-use window as the single-run path; below the blocking floor",
      "at": "2026-11-22T05:42:33.064Z",
      "approval": "a-8f868ce8a09b",
      "relayed": "GSTA-36:2026-11-22T05:25:48Z"
    }
  ],
  "gate_dispositions": []
}

garrytan and others added 2 commits November 22, 2026 04:53
…rst (GST-3381)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…ile (GST-3381)

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 2 commits November 22, 2026 05:28
…e (GST-3381)

CI's free suite refused shard 9 because the test wrote ~/.gstack/security/egress.jsonl in the runner's real home. The test now points GSTACK_STATE_ROOT at the fixture's home, as pregate-from-run.test.ts does.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…docs say a two-profile gate is refused (GST-3381)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai
capy-ai Bot merged commit 3d3ce73 into main Nov 22, 2026
77 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