Skip to content

A crashed merge no longer blocks every other merge, and a one-call count of PRs waiting to merge (GST-3549) - #4712

Merged
capy-ai[bot] merged 5 commits into
mainfrom
land-lock-cannot-go-stale
Nov 22, 2026
Merged

capy-ai[bot] merged 5 commits into
mainfrom
land-lock-cannot-go-stale

Conversation

@garrytan

@garrytan garrytan commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

When gstack-ship-queue land --pin dies in the middle of a merge, the next merge now takes over its lock by itself (the process has exited, its machine restarted, or 90 minutes passed) and logs it; a merge that is still running is never interrupted.
New gstack-ship-queue count says how many finished PRs are waiting to merge, and the docs now say how to drain that queue and how to time a revert drill.
Nothing to do: the next land --pin uses the new lock on its own.

What changed

On 2026-11-22 one merge died while it held the land lock, and every later merge refused for hours while about 15 green PRs waited. The lock had no way to tell a dead merge from a live one, so the only way out was a person passing --break-lock.

A direct merge's lock now records the process holding it (machine boot, process namespace, process group, start time) and an expiry 90 minutes after its last step. The next merge refuses a lock whose merge still runs, --break-lock included, and takes over one whose merge is gone or that expired, printing LOCK_TAKEOVER:. If a merge stops while the repository's own post-merge checks run (they can outlive it), it leaves a deliberate hold on that machine, which a person releases with the command the refusal prints. Takeovers write under an exact lease on the lock they judged, so a slow takeover never replaces a newer lock.

gstack-ship-queue count reads open PRs with one GitHub call and counts the finished ones (ours, on the base, not draft, not conflicting, green at the head). It prints a DRAIN line when more than 6 wait or one has waited a day. The coordinator docs (crew/docs/captain.md#drain-the-queue, factory.md point 16) say to run it at every wake and how to merge a backlog, and docs/ship-policy.md gains #land-lock and #revert-drill.

Blast radius

Only land --pin writes these process-scoped locks; locks from the older per-PR land and from train land keep their rules, and an older lock with no process record expires 90 minutes after its last step (crew/lib/ship-queue-land-lock.ts, read and covered by crew/test/ship-queue-land-lock.test.ts). A reproduction against the stuck lock from 2026-11-22 refuses forever on main and is taken over after expiry with this change.

Why

Finished PRs that sit unmerged go stale, because the base moves under them and conflicts appear. A merge lock that can go stale turns one crashed process into a stopped queue, so the lock has to clear itself, and the queue has to be counted before it piles up.

Pre-Landing Review

Two full review rounds and one owner-granted check of the second round's fixes. The second-model review found six problems in how the post-merge hold was set and judged; five were fixed in this PR and the check of those fixes found nothing blocking. The sixth is in code this PR did not change and is listed under Deferred findings. Remaining notes are below the blocking floor.

Deferred findings
  • lib/ship-queue-land-direct.ts:187: a rerun of an already-merged PR runs the post-merge checks before it reads the lock. This code predates this PR; left for a follow-up.
Review notes

Below the blocking floor; recorded here and not fixed in this PR.

  • lib/ship-queue-land-direct.ts:277: no land-direct test drives the post-merge hold end to end.
  • crew/lib/ship-queue-land-lock.ts:84: a rerun wrapped in a command substitution from the dead merge's own script now reads its wrapper as a running merge and refuses (the safe direction).
  • lib/ship-queue-land-direct.ts:142: when the post-merge hold cannot be written, the suggested rerun takes the already-merged path, which runs the checks unheld (the deferred finding above).
  • lib/ship-queue-land-direct.ts:195: an already-merged rerun with --allow-repo-commands against a deliberate hold refuses each time without naming the release command.
  • crew/lib/ship-queue-land-lock.ts:246: --break-lock can still take a hold whose checks changed the checkout's git directory; only the advice changed.
  • crew/lib/ship-queue-land-lock.ts:248: releasing a deliberate hold prints the generic takeover line, not that a hold was released.
  • Plus earlier informational notes from round one and the in-house adversarial read, and one security note whose details are recorded privately.
Documentation

Status: updated — one factual fix; the branch already documents its own changes.

Scope: 4 commits from 5962f0d to d732e9c (12 files: land-lock takeover in crew/lib/ship-queue-land-lock.ts and lib/ship-queue-land-direct.ts, new gstack-ship-queue count); no staged, unstaged or new files.

Documentation health:

  • docs/troubleshooting.md — Updated (the QUEUE_LAND_LOCKED fix now covers the merge: direct automatic takeover and its three refusals)
  • docs/ship-policy.md — Current (land-lock and revert-drill sections added on this branch)
  • crew/docs/captain.md — Current (Drain the queue section and QUEUE_LAND_LOCKED row added on this branch)
  • capy/skill/gstack/factory.md — Current (item 16)
  • changelog.d/land-lock-cannot-go-stale.md — Current (not edited by policy)

Coverage debt: gstack-ship-queue count has reference docs (help text, captain.md) and a how-to (Drain the queue) but no tutorial; land-lock takeover has reference and explanation docs (ship-policy.md#land-lock). No critical gaps. Diagram drift: none.

Tests
  • bun test crew/test/ship-queue-land-lock.test.ts test/ship-queue-count.test.ts test/ship-queue-land-direct.test.ts: 105 pass, 0 fail
  • bun test test/captain-skill.test.ts: 11 pass; test/captain-brief.test.ts test/ship-queue-count.test.ts test/docs-only-policy.test.ts: 103 pass
  • bun run typecheck: clean
  • CI: every pull_request check green at f70ef8c; free-tests run 45052448134 dispatched on the branch (39,180 tests) carried as the full run
Agent notes

Refs GST-3549

REVIEW_LOOP: passes=2 blocking_found=6 deferred=0 noted=13 fixed=12 scope=frozen open=6 fix_checks=1 dispatches=6
Fix-check: one owner-granted scoped fix-check (GSTA-36, approval a-a0622b71e145 with range correction a-49757303aec7, #4712's first review-loop exception) over 59412e9..d732e9c, reviewed tree 30977cf4dae1, blocking=0, 5 informational notes.
Ruled note: crew/lib/ship-queue-land-lock.ts:238:outside-voice at e8ad7d3 ruled by GSTA-36 (relayed from GSTA-810:01M8283BPEMWB83T5Y4TXQZGVQ) at 2026-11-22T18:25:57.147Z: closes on the clean fix-check over 59412e9..d732e9c (GSTA-36 confirmed) (approval a-56c1401b87ba)
Ruled note: crew/lib/ship-queue-land-lock.ts:295:outside-voice at e8ad7d3 ruled by GSTA-36 (relayed from GSTA-810:01M8283BPEMWB83T5Y4TXQZGVQ) at 2026-11-22T18:25:57.316Z: closes on the clean fix-check over 59412e9..d732e9c (GSTA-36 confirmed) (approval a-ab9ba41bc9d7)
Ruled note: lib/ship-queue-land-direct.ts:318:outside-voice at e8ad7d3 ruled by GSTA-36 (relayed from GSTA-810:01M8283BPEMWB83T5Y4TXQZGVQ) at 2026-11-22T18:25:57.508Z: closes on the clean fix-check over 59412e9..d732e9c (GSTA-36 confirmed) (approval a-e6419a33e8f0)
Ruled note: crew/lib/ship-queue-land-lock.ts:125:outside-voice at e8ad7d3 ruled by GSTA-36 (relayed from GSTA-810:01M8283BPEMWB83T5Y4TXQZGVQ) at 2026-11-22T18:25:57.693Z: closes on the clean fix-check over 59412e9..d732e9c (GSTA-36 confirmed) (approval a-adadba19ee66)
Ruled note: crew/lib/ship-queue-land-lock.ts:90:outside-voice at e8ad7d3 ruled by GSTA-36 (relayed from GSTA-810:01M8283BPEMWB83T5Y4TXQZGVQ) at 2026-11-22T18:25:57.893Z: closes on the clean fix-check over 59412e9..d732e9c (GSTA-36 confirmed) (approval a-d92b88c9230b)
Ruled note: lib/ship-queue-land-direct.ts:187:outside-voice at e8ad7d3 ruled by GSTA-36 (relayed from GSTA-810:01M8283BPEMWB83T5Y4TXQZGVQ) at 2026-11-22T18:25:58.090Z: ships as a disclosed note on pre-existing code (approval a-c95a949033fc)
Also approved under R119: the factory.md byte budget raised to 5,300 for point 16 (approval a-889893c6937f).

Approvals:
Approved: yes (record r-d2f9d8ffee06). The full approval record stays private.
Plan: exempt: bug fix with a repro on current main (a stale land lock held gstack merges for hours); owner go-ahead 2026-11-22
Plan check: exempt bug fix

{
  "schema_version": 1,
  "pr": 4712,
  "head": "f70ef8cfc9b7ffe1f49b180b9a2938987d3da28f",
  "version": "1.102.2.0",
  "base": "main",
  "gate": {
    "focused": {
      "pass": 105,
      "fail": 0,
      "skip": 0
    }
  },
  "session_kind": "unattended",
  "run": "/home/user/.capy/work/gstack/ship-r119",
  "head_tree": "4a551d89bea39aaefe7ed20f3a7700ca2c731cc3",
  "product_patch_id": "7bd15c61b1b63da5727bc9aaab6fa03c07a112fa",
  "gstack_version": "1.102.2.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 371,
    "rules": "33831f8248a814fd",
    "base": "d3aed00dbe4bd051136294d9947d6a8225e32bed",
    "registry": "d3aed00dbe4bd051136294d9947d6a8225e32bed",
    "gate_scan": {
      "tagged": 0,
      "head": "f70ef8cfc9b7ffe1f49b180b9a2938987d3da28f"
    },
    "reasons": [
      "gate-class",
      "runtime=371"
    ],
    "risk": [],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @4a551d89bea3 (8 checks, current for f70ef8cfc9b7)",
  "requires_remote": [
    "pregate.json/remote_gate: remote-gate tree=4a551d89bea3 tests=39180 skipped=2 runs=45052448134/1 profiles=ci-reuse/free-tests heads=f70ef8cfc9b7 verified=2026-11-22T18:15:24.942Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "updated",
    "scope": "docs/, crew/docs/, capy/skill/gstack/, README.md against the 4 commits from 5962f0d to d732e9c"
  },
  "review_loop": {
    "passes": 2,
    "blocking_found": 6,
    "deferred": 0,
    "noted": 13,
    "fixed": 12,
    "scope": "frozen",
    "fix_checks": 1,
    "rounds": 2,
    "dispatches": {
      "specialist": 6
    }
  },
  "ruled_notes": [
    {
      "finding": "crew/lib/ship-queue-land-lock.ts:238:outside-voice",
      "head": "e8ad7d336cdd9ca4a98affcd8d8a19bd4e37e872",
      "by": "GSTA-36",
      "reason": "closes on the clean fix-check over 59412e9..d732e9c (GSTA-36 confirmed)",
      "at": "2026-11-22T18:25:57.147Z",
      "approval": "a-56c1401b87ba",
      "relayed": "GSTA-810:01M8283BPEMWB83T5Y4TXQZGVQ"
    },
    {
      "finding": "crew/lib/ship-queue-land-lock.ts:295:outside-voice",
      "head": "e8ad7d336cdd9ca4a98affcd8d8a19bd4e37e872",
      "by": "GSTA-36",
      "reason": "closes on the clean fix-check over 59412e9..d732e9c (GSTA-36 confirmed)",
      "at": "2026-11-22T18:25:57.316Z",
      "approval": "a-ab9ba41bc9d7",
      "relayed": "GSTA-810:01M8283BPEMWB83T5Y4TXQZGVQ"
    },
    {
      "finding": "lib/ship-queue-land-direct.ts:318:outside-voice",
      "head": "e8ad7d336cdd9ca4a98affcd8d8a19bd4e37e872",
      "by": "GSTA-36",
      "reason": "closes on the clean fix-check over 59412e9..d732e9c (GSTA-36 confirmed)",
      "at": "2026-11-22T18:25:57.508Z",
      "approval": "a-e6419a33e8f0",
      "relayed": "GSTA-810:01M8283BPEMWB83T5Y4TXQZGVQ"
    },
    {
      "finding": "crew/lib/ship-queue-land-lock.ts:125:outside-voice",
      "head": "e8ad7d336cdd9ca4a98affcd8d8a19bd4e37e872",
      "by": "GSTA-36",
      "reason": "closes on the clean fix-check over 59412e9..d732e9c (GSTA-36 confirmed)",
      "at": "2026-11-22T18:25:57.693Z",
      "approval": "a-adadba19ee66",
      "relayed": "GSTA-810:01M8283BPEMWB83T5Y4TXQZGVQ"
    },
    {
      "finding": "crew/lib/ship-queue-land-lock.ts:90:outside-voice",
      "head": "e8ad7d336cdd9ca4a98affcd8d8a19bd4e37e872",
      "by": "GSTA-36",
      "reason": "closes on the clean fix-check over 59412e9..d732e9c (GSTA-36 confirmed)",
      "at": "2026-11-22T18:25:57.893Z",
      "approval": "a-d92b88c9230b",
      "relayed": "GSTA-810:01M8283BPEMWB83T5Y4TXQZGVQ"
    },
    {
      "finding": "lib/ship-queue-land-direct.ts:187:outside-voice",
      "head": "e8ad7d336cdd9ca4a98affcd8d8a19bd4e37e872",
      "by": "GSTA-36",
      "reason": "ships as a disclosed note on pre-existing code",
      "at": "2026-11-22T18:25:58.090Z",
      "approval": "a-c95a949033fc",
      "relayed": "GSTA-810:01M8283BPEMWB83T5Y4TXQZGVQ"
    }
  ],
  "gate_dispositions": []
}
{"head":"f70ef8cfc9b7ffe1f49b180b9a2938987d3da28f","version":"1.102.2.0","gstack_version":"1.102.2.0","run":"/home/user/.capy/work/gstack/ship-r119","review_loop":{"passes":2,"blocking_found":6,"deferred":0,"noted":13,"fixed":12,"scope":"frozen","fix_checks":1,"rounds":2,"dispatches":{"specialist":6}},"depth":"full"}

Open in Capy

garrytan and others added 3 commits November 22, 2026 16:27
…queue count for the finished-PR queue (GST-3549)

The land lock a direct land writes records its process and expires 90 minutes after its last phase; the next land takes over a lock whose land exited, whose machine restarted or that expired, logs the takeover, and never takes over a running land. gstack-ship-queue count reads the finished-PR queue in one gh call and prints DRAIN past R119 bounds. Docs: the drain lanes (crew/docs/captain.md, factory.md) and the revert drill (docs/ship-policy.md).

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Review-Finding: p1/specialist-batched#1 reader=security
Review-Finding: p1/specialist-batched#2 reader=testing
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>
Review-Finding: p2/outside-voice#1 reader=outside-voice
Review-Finding: p2/outside-voice#3 reader=outside-voice
Review-Finding: p2/outside-voice#4 reader=outside-voice
Review-Finding: p2/red-team#1 reader=red-team
Review-Finding: p2/adversarial-native#1 reader=adversarial-native
Review-Finding: p2/outside-voice#5 reader=outside-voice
Review-Finding: p2/outside-voice#6 reader=outside-voice
Review-Finding: p2/specialist-batched#2 reader=testing
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 17:30
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai
capy-ai Bot marked this pull request as ready for review November 22, 2026 18:21
@capy-ai
capy-ai Bot merged commit 2ab2aad into main Nov 22, 2026
85 of 86 checks passed
capy-ai Bot added a commit that referenced this pull request Nov 22, 2026
…ow leads to a /ship sign-off (GST-3546) (#4717)

After a pull request's two review rounds, an approved extra check of the
fixes now ends in a /ship sign-off instead of a dead end.

Why: three projects (gbrain #10068, gskills #23–#25, gstack #4712) had
no way to finish after a ruling at the round limit and skipped the
sign-off or bent their records.

Nothing to do: the next /ship uses it.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Review-Finding: p1/specialist-batched#1 reader=security
Review-Finding: p1/specialist-batched#2 reader=state-machines
Review-Finding: p1/specialist-batched#3 reader=state-machines
Review-Finding: p1/red-team#1 reader=red-team
Review-Finding: p1/red-team#2 reader=red-team
Review-Finding: p2/outside-voice#1 reader=outside-voice
Review-Finding: p2/outside-voice#2 reader=outside-voice
Review-Finding: p2/outside-voice#3 reader=outside-voice
Review-Finding: p2/adversarial-native#1 reader=adversarial-native
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