Skip to content

Merge queue ready fetches missing pull request heads in one go, says so, and stops after 60 seconds (GST-3460) - #4668

Merged
capy-ai[bot] merged 3 commits into
mainfrom
ready-finishes-fast-on-a-long-queue
Nov 22, 2026
Merged

capy-ai[bot] merged 3 commits into
mainfrom
ready-finishes-fast-on-a-long-queue

Conversation

@garrytan

@garrytan garrytan commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

gstack-ship-queue ready no longer goes silent for minutes on a long merge queue: it fetches every missing pull request head in one git fetch, prints a progress line first, and stops after 60 seconds.
Why: on gbrain #10011 ready printed nothing for minutes, so nobody could tell a slow fetch from a hang.
Nothing to do; GSTACK_TRIAL_FETCH_TIMEOUT_MS changes the limit.

What was happening

A trace of the stuck run showed one pass, not a loop. Ready checks the PR against every open PR that touches the same files by merging the two heads in memory. Any head missing from the clone was fetched with its own git fetch origin refs/pull/<n>/head, one at a time, and each fetch could take up to 120 s. Ready prints its whole report at the end, so nothing appeared until every fetch was done. The trace ended inside git fetch origin refs/pull/9946/head, 26 s into that one fetch.

What changed

Ready's trial merges against other open pull requests used to fetch each missing head on its own, one after another, allowing 120 s per fetch, and said nothing until the end. Now the missing heads come down in one git fetch (one at a time only if that fails), all inside one 60 s limit, and ready prints a line to stderr before it starts:

gstack-ship-queue ready: TRIAL_MERGES: fetching 12 PR head(s) from origin (time limit 60 s): refs/pull/2/head ... (+7 more)

When the limit runs out, ready refuses with QUEUE_NOT_READY and names each refs/pull/<n>/head it was waiting on, instead of printing READY with that trial merge missing.

Tests
  • bun test test/ship-queue-trial-fetch.test.ts test/ship-queue-ready-tail.test.ts test/ship-queue-ready-fresh-base.test.ts test/gstack-ship-queue.test.ts: 40 pass, 0 fail
  • bun run test: carried from CI run 44989710296 at this tree (38,819 tests)
Why

"ready printed nothing for minutes" (gbrain #10011). The wait is now bounded and announced, and a fetch that cannot finish stops ready instead of slipping through.

Blast radius

Only ready (and the batched landing path, which calls ready()) runs the trial merges; git() in crew/lib/ship-queue-gate.ts gains an optional timeout whose default stays 120 s, so its other callers are unchanged (file:line read). The new stderr line cannot break a caller, because nothing parses ready's stderr (read across the source tree by the reviewers).

Test Coverage

Tests: 1863 → 1864 (+1 new). The new file test/ship-queue-trial-fetch.test.ts has 4 cases: one combined fetch for twelve missing heads with the progress line first; a fast-failing combined fetch falling back to one fetch per ref and still trial-merging the rest; a stalled fetch stopping at the limit; and ready refusing QUEUE_NOT_READY naming the ref. Left untested: the fallback loop running out of time partway through.
Tests ran: focused 40

Pre-Landing Review

One full review pass (testing, security and state-machine checklists, red team), one follow-up read of the fix, a Claude adversarial pass and a second-model review (GPT-6.2 Sol). Pass 1 found one test gap (the fallback path), fixed in 51cac14; the follow-up read found nothing. The second-model review raised two findings it marked blocking: presence checks can fetch lazily on a partial clone outside the 60 s limit, and ready finds a stall by matching a sentence in its own output. The maintainer accepted both as open notes (see Agent notes): the first is unchanged old behaviour, and the second can only cause a refusal, never a wrong READY.

Review notes

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

  • A negative, fractional or infinite GSTACK_TRIAL_FETCH_TIMEOUT_MS makes spawnSync throw instead of giving a coded refusal (lib/ship-queue.ts:315).
  • A null exit status also covers a failed spawn or another signal, which is reported as a stall (lib/ship-queue.ts:321).
  • The combined fetch gets the full limit although the clock started before the presence checks (lib/ship-queue.ts:321).
  • A timed-out git fetch's transport child processes are not killed; Bun's spawnSync still returns at the limit (crew/lib/ship-queue-gate.ts:51).
Exploratory QA

Functional smoke, report-only, on owned fixture repositories: the combined fetch, stall and refusal cases passed (bun test test/ship-queue-trial-fetch.test.ts, 3 of 3), and a probe with one sibling ref missing from origin showed the fallback recovering the other three heads (5 fetches, plain MISSING line, no stall). One probe was a test-runner selector error and was rerun. Revalidated after the fix: 4 of 4 pass. Not probed: the fallback running out of time partway through.

Design Review

No frontend files changed — design review skipped.

Eval Results

No prompt-related files changed — evals skipped.

Review bot comments

Review bot triage: not run in this /ship invocation.

Issues

Refs #10011
Refs p1/specialist-batched#1

TODOS

No TODO items completed in this PR.

Documentation

Scope: This audit covers the trial-merge fetch change on tree 43511a407711020f5a2d7d76756e2ebce178a530, run in ship-owned edit mode (Steps 1, 1.5, 2-4 and 6 only). I reviewed changelog.d/ready-finishes-fast-on-a-long-queue.md, crew/lib/ship-queue-gate.ts, lib/ship-queue.ts, scripts/lib/windows-curation.ts, test/ship-queue-trial-fetch.test.ts, docs/unattended.md, docs/troubleshooting.md and docs/ship-policy.md.

Result: I updated two docs and left the edits uncommitted.

  • docs/unattended.md: the TRIAL_MERGES paragraph now covers the fetch. Missing heads are fetched in one go, with a 60 s limit you can change with GSTACK_TRIAL_FETCH_TIMEOUT_MS. ready prints a progress line first and refuses with QUEUE_NOT_READY when the limit runs out.
  • docs/troubleshooting.md: the QUEUE_NOT_READY entry now lists the fetch timeout as a cause and gives its fix.
  • docs/ship-policy.md: current. Line 875 mentions the sibling trial merge only in passing and does not describe fetch behavior.
  • changelog.d fragment: reviewed but not edited, because it already describes the change accurately.
  • Every other doc in the candidate list: no reference to this change.

No templates or generated files changed, so nothing needs regenerating. The banned-terms check reported none (the repo has no .gstack/banned-terms.json).

Debt: There are no blockers and no documentation debt. Steps 5, 7, 8 and 9 and the cross-model review did not run in this mode.

Agent notes

Refs GST-3460

Approvals

Approved: yes (record r-2394f2c69602). The full approval record stays private.
Plan: exempt: bug fix (R65)
Plan check: exempt bug fix

REVIEW_LOOP: passes=1 blocking_found=2 deferred=0 noted=4 fixed=1 scope=frozen open=2 unbound=2 ledgers_read=4 fix_checks=1 dispatches=4
Gate edits: none detected (1 listed, 0 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)
Ruled note: lib/ship-queue.ts:314:performance at 51cac14 ruled by Captain GStack Minder (GSTA-36) (relayed from GSTA-36:2026-11-22T05:40:00Z) at 2026-11-22T05:31:42.894Z: Both are below the floor: lazy fetch on partial clones is unchanged old behaviour, and the sentence match can only cause a refusal, never a wrong READY. (approval a-f9a6d0e6f9a8)
Ruled note: lib/ship-queue.ts:411:correctness at 51cac14 ruled by Captain GStack Minder (GSTA-36) (relayed from GSTA-36:2026-11-22T05:40:00Z) at 2026-11-22T05:31:43.094Z: Both are below the floor: lazy fetch on partial clones is unchanged old behaviour, and the sentence match can only cause a refusal, never a wrong READY. (approval a-084558292e57)

🤖 Generated with Claude Code

{
  "schema_version": 1,
  "pr": 4668,
  "head": "139eb596fe3eb7a916869e5795a3ce46802aae1c",
  "version": "1.102.2.0",
  "base": "main",
  "gate": {
    "focused": {
      "pass": 40,
      "fail": 0,
      "skip": 0
    },
    "tests": {
      "pass": 38819,
      "fail": 0,
      "skip": 0
    }
  },
  "ci_carried": [
    {
      "lane": "test",
      "run": 44989710296,
      "attempt": 1,
      "tree": "6b69750765773f062c39fba1b32d6347786d79eb"
    }
  ],
  "session_kind": "unattended",
  "run": "ship-4668-fec69ae",
  "head_tree": "6b69750765773f062c39fba1b32d6347786d79eb",
  "product_patch_id": "132b4dd44486aabf3c494aa7f7549bf3fbaf95d7",
  "gstack_version": "1.102.2.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 48,
    "rules": "630fd3101899e28e",
    "base": "c2b4f0d2adfa66e11143b95d9a42023a09380212",
    "registry": "c2b4f0d2adfa66e11143b95d9a42023a09380212",
    "gate_scan": {
      "tagged": 0,
      "head": "139eb596fe3eb7a916869e5795a3ce46802aae1c"
    },
    "reasons": [
      "gate-class",
      "runtime=48"
    ],
    "risk": [],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @6b6975076577 (8 checks, current for 139eb596fe3e)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/44989710296/attempts/1",
    "windows-smoke.yml/windows-smoke: https://github.com/garrytan/gstack/actions/runs/44989710397/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=6b6975076577 tests=38819 skipped=72 runs=44989710296/1 profiles=ci-reuse/free-tests heads=139eb596fe3e verified=2026-11-22T05:39:50.030Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [
      10011
    ],
    "flakes": []
  },
  "docs": {
    "status": "updated",
    "scope": "docs/, README.md, CLAUDE.md, AGENTS.md, CONTRIBUTING.md against the trial-merge fetch change"
  },
  "review_loop": {
    "passes": 1,
    "blocking_found": 2,
    "deferred": 0,
    "noted": 4,
    "fixed": 1,
    "scope": "frozen",
    "fix_checks": 1,
    "rounds": 1,
    "ledgers_read": 4,
    "unbound": 2,
    "dispatches": {
      "specialist": 3,
      "red-team": 1
    }
  },
  "ruled_notes": [
    {
      "finding": "lib/ship-queue.ts:314:performance",
      "head": "51cac14cf0dbd5752df1875034da56bd1ad92f75",
      "by": "Captain GStack Minder (GSTA-36)",
      "reason": "Both are below the floor: lazy fetch on partial clones is unchanged old behaviour, and the sentence match can only cause a refusal, never a wrong READY.",
      "at": "2026-11-22T05:31:42.894Z",
      "approval": "a-f9a6d0e6f9a8",
      "relayed": "GSTA-36:2026-11-22T05:40:00Z"
    },
    {
      "finding": "lib/ship-queue.ts:411:correctness",
      "head": "51cac14cf0dbd5752df1875034da56bd1ad92f75",
      "by": "Captain GStack Minder (GSTA-36)",
      "reason": "Both are below the floor: lazy fetch on partial clones is unchanged old behaviour, and the sentence match can only cause a refusal, never a wrong READY.",
      "at": "2026-11-22T05:31:43.094Z",
      "approval": "a-084558292e57",
      "relayed": "GSTA-36:2026-11-22T05:40:00Z"
    }
  ],
  "gate_dispositions": []
}
{"head":"51cac14cf0dbd5752df1875034da56bd1ad92f75","run":"ship-4668-fec69ae","mark":"stop","tree":"43511a407711020f5a2d7d76756e2ebce178a530"}

Open in Capy

…so, and stops after 60 seconds (GST-3460)

On gbrain #10011 ready printed nothing for minutes: its trial merges fetched each missing sibling head on its own, one after another, with 120 s allowed per fetch. Ready now fetches them in one git fetch (falling back to one at a time within the same limit), prints a progress line first, and refuses with the refs it was waiting on when the limit runs out.

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:11
…t head when the combined fetch fails (GST-3460)

Review-Finding: p1/specialist-batched#1 reader=testing
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
… refusal (GST-3460)

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