Skip to content

Land checks a PR whose base moved in a separate clone, then with full CI, before merging (GST-1766) - #4649

Merged
capy-ai[bot] merged 11 commits into
mainfrom
capy/keep-lands-merged-checks
Nov 22, 2026
Merged

capy-ai[bot] merged 11 commits into
mainfrom
capy/keep-lands-merged-checks

Conversation

@garrytan

@garrytan garrytan commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

When main has moved since a PR's last CI run, gstack-ship-queue land now runs its local merge checks in a throwaway clone and can then run the full CI suite on the merged code before it merges.
Why: the old checks shared the checkout's git directory, so a PR's own test commands could plant a hook that later ran with land's tokens, and a PR could reach main on a base its full suite never saw.
Nothing to do: gstack's own policy turns the CI run on; other repos opt in with land.merged_ci.

What changed
  • Separate clone. land.merged_checks run in a fresh clone outside the checkout (git clone --no-hardlinks, its remote removed) with a copy of node_modules, so writes to its .git, hooks, config or modules are deleted with it. About 2.5 s extra per stale-base land on this repo (0.5 s clone, 2.2 s module copy).
  • Pinned tools. Land resolves the absolute git and gh at its first call (lib/tool-path.ts) and, before the checks, puts their directories first on its own PATH, so a git a check drops earlier on PATH never runs. gh's child PATH starts with the pinned git's directory.
  • Fail closed on writes outside the clone. Besides the checkout's git config, hooks, commondir/gitdir and their symlink hops (from fix(ship-queue): keep land's merged checks out of the checkout's git config and hooks (GST-1747) #4119, carried here), land now also records every config file git loads in the checkout (includes and the global file), the global and XDG config paths when absent, gh's config.yml and hosts.yml, and the pinned binaries. A change refuses with QUEUE_LAND_MERGED_CHECKS, makes no further git or gh call, keeps the land lock held, and the fix text now says hold and inspect instead of "merge main and push".
  • Pre-push guard decision. Only land turns hooks off for its git calls (queueHooksOff() in crew/lib/ship-queue-gate.ts, called first in landDirect), which skips the managed pre-push redaction hook on its lock, notes and scratch-branch pushes: land pushes only records it writes and a merge of commits that were already pushed (and scanned) on their own branches, and running a checkout hook after repo commands is the hole being closed. Other queue pushes keep the hook.
  • land.merged_ci ({ workflow, profile }). After any local checks pass, land pushes the merged commit to gstack-land/<pr>, dispatches the workflow there, waits up to 45 minutes, and lands only when lib/run-evidence.ts verifyRun accepts the run under the named profile with the merged commit and tree. Red run: QUEUE_LAND_MERGED_CHECKS. Can't push, dispatch, finish or prove: QUEUE_NOT_READY. The branch is deleted either way. gstack's policy sets { "workflow": "free-tests.yml", "profile": "ci-reuse/free-tests" } and keeps its local checks as the fast first step.
Things a reviewer should look at
  • Network and permissions: land now pushes and deletes a branch named gstack-land/<pr> and runs gh workflow run with its own credentials. The pushed commit can include workflow file changes from the PR, so the token needs the workflow scope it already uses for branch pushes.
  • Workflows: no workflow file changes. Pushing gstack-land/* may start other workflows that trigger on any branch push.
  • No dependency, install script or secret handling changes. lib/gh-poll.ts (every gh call through it) now runs the pinned gh with the pinned git's directory first on PATH.
  • Not sandboxed: a check can still read anything the user can and write the checkout's other files; bwrap/unshare was left out because it isn't available on every land machine (macOS has no equivalent).
  • Not covered by a land-level test: the dispatch wiring in ship-queue-land-direct.ts (the fixture's gh shim can't serve run artifacts); test/land-merged-ci.test.ts covers every verdict with fake dependencies.
  • Follow-up, not here: main's push run can't reuse the dispatch run (the push reuse looks up the PR head's tree, not the merged tree), so a stale-base land still runs Free Tests twice.
Agent notes

Base: #4119's branch capy/keep-lands-merged-checks (closed PR, parked at 59b7b26), merged with main at dd61103 (three conflicts resolved: docs/captain.md took main's rewrite, which no longer holds the refusal table; lib/land-merged-checks.ts and lib/ship-queue-land-direct.ts kept both sides). GST-3303 change 7 and GST-1766 in one PR on the Captain's ruling. #4119's four tests were rewritten for the clone: relative writes now land in the clone (test asserts the checkout is untouched and land merges), absolute writes still refuse.

Local checks at 9b28718: bun run typecheck clean, bun run typecheck:test no new diagnostics, gen:skill-docs --host all left no diff; bun test on test/ship-queue-land-direct, land-merged-ci, gstack-ship-policy, module-size-ratchet, free-seed-ratchet, spawnsync-timeout-tripwire, bun-entry-isolation, changelog-fragments, gh-poll, gh-poll-tripwire, ship-policy-compat: all pass.

Approved: yes (record r-32e4bf46e427). The full approval record stays private.
Plan: exempt: audited-list
Plan check: exempt audited-list

REVIEW_LOOP: passes=2 blocking_found=1 deferred=0 noted=1 fixed=1 scope=frozen dispatches=8
Gate edits: 7 listed, 4 read, 0 findings — 0 kept, 0 restored, 0 open
Ruled note: lib/land-merged-checks.ts:62:fix-check at d8efd24 ruled by Captain GStack Minder (GSTA-36), 2026-11-07 at 2026-11-07T08:11:29.416Z: ships as a disclosed note: a checkout whose .git is reached through a symlink chain is not re-located after the checks; GST-1766 moves merged-tree checks to a separate clone (approval a-0530ca53a87c)
Refs from the branch's older commit subjects (gstack-issue-links):
Refs #225
Refs #3338
Refs #3851
Refs #4045
Refs #4051
Refs #4055
Refs #4058
Refs #4059
Refs #4060
Refs #4061
Refs #4062
Refs #4063
Refs #4064
Refs #4065
Refs #4068
Refs #4069
Refs #4070
Refs #4071
Refs #4072
Refs #4073
Refs #4074
Refs #4075
Refs #4076
Refs #4077
Refs #4078
Refs #4079
Refs #4080
Refs #4081
Refs #4082
Refs #4083
Refs #4085
Refs #4087
Refs #4088
Refs #4089
Refs #4090
Refs #4091
Refs #4093
Refs #4094
Refs #4095
Refs #4096
Refs #4098
Refs #4099
Refs #4100
Refs #4101
Refs #4102
Refs #4104
Refs #4105
Refs #4106
Refs #4108
Refs #4109
Refs #4111
Refs #4112
Refs #4115

Second-model review: gpt-6.1-sol, clean. Exploratory QA: pass (5 captures, 2 revalidated after the fix).

{
  "schema_version": 1,
  "pr": 4649,
  "head": "c879645449882dead3125b003bbbcb1351f73689",
  "version": "1.102.2.0",
  "base": "main",
  "gate": {
    "free": {
      "pass": 1735,
      "fail": 0,
      "skip": 0
    }
  },
  "ci_carried": [
    {
      "lane": "free",
      "run": 44970049923,
      "attempt": 1,
      "tree": "b332416fec271075fb0dcf79009c3d198f8f271d"
    }
  ],
  "calls": 32,
  "session_kind": "unattended",
  "run": "ship-4649",
  "head_tree": "b332416fec271075fb0dcf79009c3d198f8f271d",
  "product_patch_id": "0f3bf21b9c59ab4195abb56674f7f9c878c7dbc8",
  "gstack_version": "1.102.2.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 413,
    "rules": "85b3923b1a978e41",
    "base": "d8abe59096b6205b84fa80162083c702f6ff4703",
    "registry": "d8abe59096b6205b84fa80162083c702f6ff4703",
    "gate_scan": {
      "tagged": 4,
      "head": "c879645449882dead3125b003bbbcb1351f73689"
    },
    "reasons": [
      "gate-class",
      "risk:security",
      "runtime=413"
    ],
    "risk": [
      "security"
    ],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @b332416fec27 (8 checks, current for c87964544988)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/44970049923/attempts/1",
    "windows-smoke.yml/windows-smoke: https://github.com/garrytan/gstack/actions/runs/44969521358/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=b332416fec27 tests=38731 skipped=89 runs=44970049923/1 profiles=ci-reuse/free-tests heads=c87964544988 verified=2026-11-22T01:15:45.149Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [
      225,
      3338,
      3851,
      4045,
      4051,
      4055,
      4058,
      4059,
      4060,
      4061,
      4062,
      4063,
      4064,
      4065,
      4068,
      4069,
      4070,
      4071,
      4072,
      4073,
      4074,
      4075,
      4076,
      4077,
      4078,
      4079,
      4080,
      4081,
      4082,
      4083,
      4085,
      4087,
      4088,
      4089,
      4090,
      4091,
      4093,
      4094,
      4095,
      4096,
      4098,
      4099,
      4100,
      4101,
      4102,
      4104,
      4105,
      4106,
      4108,
      4109,
      4111,
      4112,
      4115
    ],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "docs/, README.md, AGENTS.md, CLAUDE.md, CONTRIBUTING.md and crew/docs/captain.md against the land merged-checks and merged_ci diff (re-audit; crew/docs/captain.md row left as debt)"
  },
  "review_loop": {
    "passes": 2,
    "blocking_found": 1,
    "deferred": 0,
    "noted": 4,
    "fixed": 1,
    "scope": "frozen",
    "rounds": 2,
    "dispatches": {
      "specialist": 6,
      "red-team": 2
    }
  },
  "ruled_notes": [
    {
      "finding": "lib/land-merged-checks.ts:62:fix-check",
      "head": "d8efd242bb1d9d50eaadee8ff751b5ef35b9fe59",
      "by": "Captain GStack Minder (GSTA-36), 2026-11-07",
      "reason": "ships as a disclosed note: a checkout whose .git is reached through a symlink chain is not re-located after the checks; GST-1766 moves merged-tree checks to a separate clone",
      "at": "2026-11-07T08:11:29.416Z",
      "approval": "a-0530ca53a87c"
    }
  ],
  "gate_dispositions": [],
  "review_targeted": {
    "classes": [
      "gate"
    ],
    "rules": "b3f6f8b4843c0c30",
    "brief_sha": "7f92a0d0a8319c3c0e076fb3b1a4689c45120b2be2c14dfc7d4cb03aafa9d6a5",
    "product_patch_id": "0f3bf21b9c59ab4195abb56674f7f9c878c7dbc8",
    "status": "done",
    "findings": 0,
    "raised_by": "targeted"
  }
}

Open in Capy

garrytan and others added 8 commits November 7, 2026 06:27
…config and hooks (GST-1747)

Land records the checkout's git config and hooks before land.merged_checks run,
puts back anything a check changed or added and refuses; every ship-queue git
call runs with hooks and fsmonitor off.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Guard the commondir and gitdir files and the checkout's .git, follow
symlinked config and hooks to their targets, never read a FIFO, socket
or device, restore per entry by rename with modes reset children first,
and run the restore in a finally so a thrown check still puts the git
directory back. Recheck where git finds the git directory after the
checks and refuse when it moved or a path could not be put back.

Review-Finding: p1/red-team#1 reader=red-team
Review-Finding: p1/specialist-batched#1 reader=security
Review-Finding: p1/red-team#2 reader=red-team
Review-Finding: p1/red-team#3 reader=red-team
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Put back a guarded symlink whenever its target differs, open directories
(u+rwx, parents first) before restoring into them, and when a path cannot
be put back make no further git call in the checkout: land refuses and
leaves the land lock held instead of pushing its release. Run the merged
tree's rev-parse and status with the checks' environment, before the
restore and followed by a stray-process sweep.

Review-Finding: p2/specialist-batched#1 reader=security
Review-Finding: p2/red-team#1 reader=red-team
Review-Finding: p2/red-team#2 reader=red-team
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Per the Captain's grant (a-6bbdd886c96b) replace the restore with a
refusal: land compares the guarded git paths (every symlink hop
recorded) after land.merged_checks, and on any change it names each
path, makes no further git call in the checkout, pushes no lock release
and prints the command that releases the lock without running the checks.

Review-Finding: p2/outside-voice#1 reader=outside-voice
Review-Finding: p2/outside-voice#2 reader=outside-voice
Review-Finding: p2/adversarial-native#1 reader=adversarial-native
Review-Finding: p2/adversarial-native#2 reader=adversarial-native
Review-Finding: p2/adversarial-native#3 reader=adversarial-native
Review-Finding: p2/adversarial-native#4 reader=adversarial-native
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…e captain table

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

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

# Conflicts:
#	docs/captain.md
#	lib/land-merged-checks.ts
#	lib/ship-queue-land-direct.ts
… merged tree

The merged-tree checks run in a fresh clone with its own .git and a copy of
node_modules. Land pins the git and gh it runs before the checks and refuses,
holding the land lock, when a check changed a file its later git or gh calls
read. A new land.merged_ci key dispatches a workflow on the merged commit and
lands only when that run proves the merged tree; gstack's policy runs Free
Tests this way.

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 3 commits November 22, 2026 00:47
Only gstack-ship-queue land turns off git hooks for its git calls; wave, train and other queue pushes keep the checkout's hooks, the managed pre-push guard among them.

Review-Finding: p1/red-team#2 reader=red-team
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…lock

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