Skip to content

fix(ship-queue): keep land's merged checks out of the checkout's git config and hooks (GST-1747) - #4119

Closed
garrytan wants to merge 6 commits into
mainfrom
capy/keep-lands-merged-checks
Closed

garrytan wants to merge 6 commits into
mainfrom
capy/keep-lands-merged-checks

Conversation

@garrytan

@garrytan garrytan commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

Parked. This PR is parked at 59b7b26 by the Captain's ruling; GST-1766 continues from this branch.

What changed

  • gstack-ship-queue land --pin --allow-repo-commands records the guarded git paths of the checkout before land.merged_checks run: config, config.worktree, hooks/, commondir and gitdir in the checkout's git directories, the checkout's .git entry, and every hop of a symlink among them.
  • When a check changed or added any of them, land restores nothing. It refuses with QUEUE_LAND_MERGED_CHECKS and names each changed path. It makes no further git call in the checkout, so it does not merge, remove the worktree or push the lock release, and the land lock stays held. The LOCK: line names the release command: once the named paths are restored from a trusted copy (or an added hook is deleted), gstack-ship-queue land --pr <n> --pin <sha> without --allow-repo-commands refuses with REPO_COMMANDS_NOT_ALLOWED and releases the lock without running the checks.
  • Land's own rev-parse HEAD and status in the merged tree now run with the checks' scrubbed environment, before the after-snapshot, followed by a stray-process sweep on Linux.
  • lib/ship-queue-gate's git(), the runner behind every queue, lock, notes and train call, runs with core.hooksPath=/dev/null and core.fsmonitor=false through GIT_CONFIG_COUNT, appended after any count the caller already sets.
  • docs/ship-policy.md#land-direct, docs/troubleshooting.md and the docs/captain.md result table describe the refusal and the release step.

Why

The merged checks run with a scrubbed environment (GST-1421) so land's tokens never reach repo commands, but they share the checkout's .git through the worktree, and land's later git calls run with its full environment. Land now stops instead of trusting a git directory the checks changed, and leaves the lock held so a person checks the checkout before any further git call there.

Blast radius

  • Only land with --allow-repo-commands on a moved base takes the snapshot. A merged check that writes the shared .git/config or installs a hook now stops land and holds the lock until someone restores the paths and runs the release command.
  • Every gstack-ship-queue git call stops running hooks and fsmonitor.
  • The same-user residual is documented and not sandboxed. The checks run as land's user, so they can still write the linked node_modules, other files in the checkout, the user's global git config and directories on PATH, and on macOS read land's starting environment through ps -E. Pass --allow-repo-commands only for PRs you trust to run.

Approvals

Approved: yes (record r-32e4bf46e427). The full approval record stays private: this repository is public or its visibility is unknown.

Test Coverage

  • Changed tests in test/ship-queue-land-direct.test.ts: a check that changes hooks and config is refused with each path named, runs no hook and pushes no lock release, and the release command frees the lock without running the checks; a hook under the checkout's core.hooksPath never runs and land still merges; a repointed commondir is refused with the lock held; a repointed middle link of a symlinked .git/config chain is detected.
  • Focused at the final code: test/gstack-clean-producers, gstack-ship-policy, gstack-ship-queue, land-direct-recovery-isolation and ship-queue-land-direct, 107 pass, 0 fail; typecheck clean; module-size ratchet and conflict-marker checks pass. CI is the full run.

Pre-Landing Review

Pass 1 (specialists, red-team) found 4 issues, all fixed. Pass 2 found 3 blocking issues in the fix round, all fixed. Step 11's voices (adversarial-native, outside voice gpt-6.1-sol, targeted) found 3 blocking issues in the restore code; the granted fix-check round replaced the restore with the refusal above. The fix-check found one blocking issue, which the owner ruled a disclosed note (below).

REVIEW_LOOP: passes=2 blocking_found=8 deferred=0 noted=6 fixed=10 scope=frozen unbound=3 ledgers_read=4 fix_checks=1 dispatches=8

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)

Gate edits: 3 listed, 2 read, 0 findings — 0 kept, 0 restored, 0 open

Outside review: openai/gpt-6.1-sol (outside voice) reviewed; its two blocking findings were resolved by the fix-check round.

Review notes

  • A checkout whose .git is reached through a symlink chain is not re-located after the checks (ruled note above; GST-1766 follows up by running the checks in a separate clone).
  • Files pulled in through [include] or includeIf in the checkout's config are not among the guarded paths.
  • On macOS, a stray process a check leaves running is not swept, so it can change the config after the snapshot.
  • The QUEUE_LAND_MERGED_CHECKS fix: text still says to merge main and push, which does not match the hold-and-inspect detail for changed git paths.
  • The release command assumes the earlier land checks still pass, and its line does not mention --break-lock.
  • No test covers a FIFO among the guarded paths.
  • git()'s global hooks-off setting also skips the managed pre-push guard on train, stamp and notes pushes; whether to scope it to land is a design question for the Captain.
  • A same-content hard-link swap of a guarded file is not detected.
  • refs/replace in the shared object store was already reachable before this PR.
  • A refused land leaves a stale worktree registration until git worktree prune.

Issues

Refs GST-1747

Documentation

Status: updated. Two downstream docs now describe land's git-directory guard.

Scope: the 6 selected committed files (base 5862765..d8efd24): lib/land-merged-checks.ts, lib/ship-queue-gate.ts, lib/ship-queue-land-direct.ts, docs/ship-policy.md, changelog.d/capy-gst-1747-land-git-dir.md, test/ship-queue-land-direct.test.ts.

Documentation health:

  • docs/ship-policy.md: Current (land-direct section already documents the guard)
  • docs/troubleshooting.md: Updated (QUEUE_LAND_MERGED_CHECKS covers the changed git paths, the held lock, the restore step and the lock release)
  • docs/captain.md: Updated (result-code table row adds the restore and lock-release step)
  • changelog.d/capy-gst-1747-land-git-dir.md: Current

Coverage debt: the policy explanation string LAND_EXPLANATION does not mention the git-dir refusal. No diagram drift.

Test plan

  • Focused land and ship-queue suites at the final code (107 pass, 0 fail)
  • typecheck, module-size ratchet, conflict markers
  • CI free-tests at the pushed head (carried by /ship)

…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>
@trunk-io

trunk-io Bot commented Nov 7, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

garrytan and others added 5 commits November 7, 2026 06:51
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>
@capy-ai

capy-ai Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Closing while parked at 59b7b26. Its thread is archived. The branch capy/keep-lands-merged-checks is kept as the base GST-1766 continues from, and a new PR opens when that work is scheduled.

@capy-ai capy-ai Bot closed this Nov 9, 2026
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