Skip to content

Skip the second Free Tests run when a PR lands onto a moved main (GST-3303) - #4655

Merged
capy-ai[bot] merged 2 commits into
mainfrom
main-push-reuses-land-ci-run
Nov 22, 2026
Merged

capy-ai[bot] merged 2 commits into
mainfrom
main-push-reuses-land-ci-run

Conversation

@garrytan

@garrytan garrytan commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

When the land tool merges a PR whose base moved, it has already run Free Tests on the exact merged tree. Main's push run now reuses that run instead of running the whole suite again, and still runs it whenever main moved again before the merge or the newest land run wasn't green.
This also fixes the outdated QUEUE_LAND_MERGED_CHECKS row in the maintainers' land guide. Nothing to do: the next stale-base land shows REUSE: accepted run … on main's push run.

How it decides, and why it's safe
  • scripts/ci-tree-reuse.ts find (main-push path): when the merged PR's head tree differs from the pushed tree, the only candidate is the newest workflow_dispatch run of free-tests.yml on gstack-land/<n>. It's reused only when verifyRun accepts it under ci-reuse/free-tests and its tested-tree record names the pushed tree.
  • Only the newest land run counts, so a red retry on the same tree can't hide behind an older green one. A land run on another tree (main moved before the merge), an in-progress run, a pull_request run, another branch, or a profile without dispatch all fall back to the full suite.
  • No byte-identical check on the reuse files is needed here, unlike the pull-request consumer: the dispatch run executed the workflow from its own commit, whose tree is the tree now on main, so the rules it ran under are main's own, whoever dispatched it.
  • landBranch() in lib/run-evidence.ts is now the one source of the gstack-land/<n> name for land and for reuse.
  • Docs: docs/pregate.md#ci-reuse, docs/ship-policy.md#land-direct, the free-tests.yml header, and the QUEUE_LAND_MERGED_CHECKS row in the land guide (the hold-and-inspect case for files the checks changed, and the red merged_ci run).
Not verified live

No gstack-land/* run exists yet. Two GitHub reads are untested against a deleted scratch branch: listing runs by ?branch=gstack-land/<n> and reading the scratch commit's tree. If either fails, the reuse job refuses and the push run tests the tree itself, as today.

Agent notes

Plan: exempt: audited-list
Tests: test/ci-tree-reuse.test.ts adds 4 cases for the land path; each one breaks with the script change reverted. Focused files ci-tree-reuse, land-merged-ci, ci-reuse-workflow-wiring and run-evidence are green; typecheck and typecheck:test clean.
Fix since round 1 (fa089ab → 3347d52): the land candidate is now the newest run by run id, not start time, so a re-run of an older land run can't outrank a later red one (one new assertion in test/ci-tree-reuse.test.ts, one sentence in docs/pregate.md). Found by a second-model read of the decision trail; this head got the PR's round 2 of 2, a fresh full review.

REVIEW_LOOP: passes=1 blocking_found=0 deferred=0 noted=5 fixed=0 scope=frozen dispatches=4
Gate edits: none detected (5 listed, 3 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)
Pre-Landing Review: No issues found. Review plan: gate class, full depth, round 2 of 2 on 3347d52 (batched specialist for testing, security and state machines; red team; adversarial; second-model review on openai/gpt-6.1-sol); no blockers, no fix round.
Review notes (below the blocking floor, not fixed in this PR):

  • INFORMATIONAL [ADVISORY] scripts/ci-tree-reuse.ts:227 integration: the branch-filtered run lookup after land deletes gstack-land/<n> is proven only with fakes; if GitHub stopped listing a deleted branch's runs, reuse never fires and the suite runs as before.
  • INFORMATIONAL [ADVISORY] scripts/ci-tree-reuse.ts:77 consistency: windows-free-tests.yml's main push also takes the land path and refuses with a reason that suggests a land run should exist; same outcome as before plus one API call.
  • INFORMATIONAL scripts/ci-tree-reuse.ts:82 ordering (adversarial): if the newest land run's own first attempt was red and a person re-runs it to green and then merges by hand past land's red-run refusal, main's push reuses the green attempt; it is green on the exact pushed tree, so nothing fails or leaks.
  • INFORMATIONAL scripts/ci-tree-reuse.ts:82 consistency (adversarial): the land path orders by run id and the head path by start time; deliberate and documented.
  • INFORMATIONAL scripts/ci-tree-reuse.ts:76 summary: the adversarial reader's preamble (the tree binding in verifyRun holds), recorded as a note.
    Coverage: 10 of 10 changed code paths have a test (Phase 2 audit map; the Step 7 coverage reader was not rerun in round 2).
    Exploratory QA: smoke only, bun test test/ci-tree-reuse.test.ts green, including the newest-by-id case; no required plan checks.
    Documentation: current (docs/, crew/docs/, README.md, AGENTS.md, CONTRIBUTING.md, ARCHITECTURE.md audited; no edits).
    Tests ran: test 1735 (files, carried from CI run 44973881857/1)
{
  "schema_version": 1,
  "pr": 4655,
  "head": "3347d52b1ae820f945b6c2799dbf8f5529bcc0b8",
  "version": "1.102.2.0",
  "base": "main",
  "gate": {
    "test": {
      "pass": 1735,
      "fail": 0,
      "skip": 0
    }
  },
  "ci_carried": [
    {
      "lane": "test",
      "run": 44973881857,
      "attempt": 1,
      "tree": "a933c3efc404efd12ef789458e325c25eece23ee"
    }
  ],
  "calls": 11,
  "session_kind": "unattended",
  "run": "ship-4655-3347",
  "head_tree": "a933c3efc404efd12ef789458e325c25eece23ee",
  "product_patch_id": "7e9517142c1251601be224555d3f772d5f1fa88a",
  "gstack_version": "1.102.2.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 63,
    "rules": "85b3923b1a978e41",
    "base": "abdc09dad16a4c15070cc7ba0b863409992d49d1",
    "registry": "abdc09dad16a4c15070cc7ba0b863409992d49d1",
    "gate_scan": {
      "tagged": 0,
      "head": "3347d52b1ae820f945b6c2799dbf8f5529bcc0b8"
    },
    "reasons": [
      "gate-class",
      "runtime=63"
    ],
    "risk": [],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @a933c3efc404 (8 checks, current for 3347d52b1ae8)",
  "requires_remote": [
    "free-tests.yml/cso-macos-launcher: https://github.com/garrytan/gstack/actions/runs/44973881857/attempts/1",
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/44973881857/attempts/1",
    "free-tests.yml/cso-windows-launcher: https://github.com/garrytan/gstack/actions/runs/44973881857/attempts/1",
    "windows-smoke.yml/windows-smoke: https://github.com/garrytan/gstack/actions/runs/44973881868/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=a933c3efc404 tests=38737 skipped=72 runs=44973881857/1 profiles=ci-reuse/free-tests heads=3347d52b1ae8 verified=2026-11-22T02:12:58.206Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "docs/, crew/docs/, README.md, AGENTS.md, CONTRIBUTING.md, ARCHITECTURE.md"
  },
  "review_loop": {
    "passes": 1,
    "blocking_found": 0,
    "deferred": 0,
    "noted": 5,
    "fixed": 0,
    "scope": "frozen",
    "rounds": 1,
    "ledgers_read": 2,
    "dispatches": {
      "specialist": 3,
      "red-team": 1
    }
  },
  "gate_dispositions": []
}
{"head":"fa089ab039de2a1da3c69a1fe8f004a4b1a01b07","version":"1.102.2.0","gstack_version":"1.102.2.0","run":"ship-4655","review_loop":{"passes":1,"blocking_found":0,"deferred":0,"noted":4,"fixed":0,"scope":"frozen","rounds":1,"dispatches":{"specialist":1,"red-team":1}},"depth":"full"}

Open in Capy

When land merges a PR onto a main that moved past it, land.merged_ci has
already run Free Tests on the merged tree. Main's push run now reuses the
newest dispatch run on gstack-land/<n> when it verifies with the pushed tree
as its tested tree, and runs the suite otherwise. Also updates the
QUEUE_LAND_MERGED_CHECKS row in the crew Captain guide for the tamper hold
and the red merged_ci run. (GST-3303)

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.

A re-run of an older green land run restarts it, so ordering by start time
could put it ahead of a later red run on the same tree. Run ids grow with
creation, so the latest land attempt always wins. (GST-3303)

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