Use Garry Tan's exact Claude Code setup: 23 opinionated tools that serve as CEO, Designer, Eng Manager, Release Manager, Doc Engineer, and QA
TypeScript
Merge queue ready fetches missing pull request heads in one go, says so, and stops after 60 seconds (GST-3460) (#4668)
Garry Tan7c0659a69fd7
diff --git a/changelog.d/ready-finishes-fast-on-a-long-queue.md b/changelog.d/ready-finishes-fast-on-a-long-queue.mdnew file mode 100644index 000000000..dbad0e1aa--- /dev/null+++ b/changelog.d/ready-finishes-fast-on-a-long-queue.md@@ -0,0 +1 @@+**`gstack-ship-queue ready` no longer goes silent for minutes on a long merge queue.** Its trial merges against other open pull requests used to fetch each missing pull request head on its own, one after another, allowing 120 s per fetch, and printed nothing until the end (gbrain #10011). Ready now fetches every missing head in one `git fetch`, prints a progress line before it starts, and stops after 60 s (`GSTACK_TRIAL_FETCH_TIMEOUT_MS` changes the limit). When the limit runs out, ready refuses and names each `refs/pull/<n>/head` it was waiting on, instead of printing READY with that trial merge missing. (GST-3460)diff --git a/crew/lib/ship-queue-gate.ts b/crew/lib/ship-queue-gate.tsindex f1b9a7b0e..7cb716167 100644--- a/crew/lib/ship-queue-gate.ts+++ b/crew/lib/ship-queue-gate.ts@@ -44,11 +44,11 @@ let hooksOff = false;/** land calls this first: none of its git calls runs a hook or fsmonitor, because land.merged_checks are repo commands that can write where the checkout's hooks live (lib/land-merged-checks.ts). Other queue commands keep the checkout's hooks, the managed pre-push guard among them. */export function queueHooksOff(): void { hooksOff = true; }-export function git(cwd: string, args: string[], env?: NodeJS.ProcessEnv, input?: string | Buffer): { ok: boolean; out: string; err: string; status: number | null } {+export function git(cwd: string, args: string[], env?: NodeJS.ProcessEnv, input?: string | Buffer, timeoutMs = 120_000): { ok: boolean; out: string; err: string; status: number | null } {const base = env ?? process.env;const n = Number(base.GIT_CONFIG_COUNT) || 0;const noHooks = hooksOff ? { GIT_CONFIG_COUNT: String(n + 2), [`GIT_CONFIG_KEY_${n}`]: 'core.hooksPath', [`GIT_CONFIG_VALUE_${n}`]: '/dev/null', [`GIT_CONFIG_KEY_${n + 1}`]: 'core.fsmonitor', [`GIT_CONFIG_VALUE_${n + 1}`]: 'false' } : {};- const r = spawnSync(toolPath('git', base.PATH), args, { cwd, encoding: 'utf8', timeout: 120_000, env: { ...base, ...noHooks }, input, maxBuffer: 64 * 1024 * 1024 });+ const r = spawnSync(toolPath('git', base.PATH), args, { cwd, encoding: 'utf8', timeout: timeoutMs, env: { ...base, ...noHooks }, input, maxBuffer: 64 * 1024 * 1024 });return { ok: r.status === 0, out: (r.stdout ?? '').replace(/\n$/, ''), err: (r.stderr ?? '').trim(), status: r.status };}diff --git a/docs/troubleshooting.md b/docs/troubleshooting.mdindex 9173f73b6..d735861ea 100644--- a/docs/troubleshooting.md+++ b/docs/troubleshooting.md@@ -6209,7 +6209,10 @@ HEAD is not the PR's pushed head (read through `gh pr view`), CI at thatexact head is not green (failed, pending or unreadable), or the pregate resultis missing, failed or recorded on another tree (`PREGATE_STALE`). Under`--dispatch-ci` it is also a dispatched workflow run that concluded red (a red-run clears no pregate lane) or a `gh workflow run` that failed. `train land`+run clears no pregate lane) or a `gh workflow run` that failed. It is also the trial-merge fetch (rule 14)+running out of time (`GSTACK_TRIAL_FETCH_TIMEOUT_MS`, default 60 s) before+every sibling PR head arrived; the message names each `refs/pull/<n>/head` it+was waiting on. `train land`uses it while a slot cannot merge yet: checks on the stamp commit are notgreen, a name in `changelog_fragments.required_checks` is missing or not greenthere, the PR's base is no longer the train's base, the stamp push failed while@@ -6221,7 +6224,10 @@ origin's lock ref could not be read to tell whether the push landed.`gstack-pregate run --allow-repo-commands` when the tree changed, then rerun`gstack-ship-queue ready --pr <n>`. The block it prints before refusing showswhich line is not yet true. For `train land`, do what `NEXT:` says, then rerun-the same `train land` command; it adopts its own journaled stamp commit. For an+the same `train land` command; it adopts its own journaled stamp commit. For a+trial-merge fetch timeout, fetch the named refs by hand+(`git fetch origin <ref>`) or raise `GSTACK_TRIAL_FETCH_TIMEOUT_MS`, then+rerun ready. For anunreadable land lock, rerun the same `land` command once origin answers; itresumes its own lock.diff --git a/docs/unattended.md b/docs/unattended.mdindex 6a11872f0..6134194b7 100644--- a/docs/unattended.md+++ b/docs/unattended.md@@ -1101,8 +1101,11 @@ whose decision names the reader (`gstack-decision-trail <file> trail-readfor a risk-class receipt, then that row's flags (`Flags (trail row <n>): …`, or`No flags (trail row <n>)`), or `MISSING: cross-family trail read` when the trailhas none, and one `TRIAL_MERGES` line per open PR that shares a file, from-`git merge-tree` at both heads. A PR from a fork is labelled as an outside PR-and never fetched or merged. `decisions.jsonl` stays the typed record `gstack-artifact` validates; the+`git merge-tree` at both heads. Heads this clone lacks come down in one+`git fetch` (then one at a time if that fails) within+`GSTACK_TRIAL_FETCH_TIMEOUT_MS` (default 60 s); ready prints a progress line+before the fetch and refuses with `QUEUE_NOT_READY` when the limit runs out.+A PR from a fork is labelled as an outside PR and never fetched or merged. `decisions.jsonl` stays the typed record `gstack-artifact` validates; thetrail is the plain one a person reads, and `column -s$'\t' -t decisions.tsv`renders it in a terminal.diff --git a/lib/ship-queue.ts b/lib/ship-queue.tsindex ac6152a25..1e790f502 100644--- a/lib/ship-queue.ts+++ b/lib/ship-queue.ts@@ -295,9 +295,13 @@ export function refreshBase(ctx: QueueContext): QueueFailure | null {/*** TRIAL_MERGES (rule 14): each open PR into the base that changes a path this PR changes, trial-merged with this head by git* merge-tree; one line per such PR, or a MISSING line when gh or the fetch cannot tell. A PR from a fork is an outside- * contribution, not a sibling lane: it is labelled and never fetched or merged (outside code is read as text only).+ * contribution, not a sibling lane: it is labelled and never fetched or merged (outside code is read as text only). Heads this+ * clone lacks come down in one git fetch, then one at a time if that fails, all within GSTACK_TRIAL_FETCH_TIMEOUT_MS (default+ * 60 s); a head still missing when the time runs out gets a TRIAL_FETCH_STALLED line, which ready refuses (GST-3460).*/-export function trialMergeLines(ctx: QueueContext, pr: string, head: string, changed: readonly string[]): string[] {+export const TRIAL_FETCH_STALLED = 'the trial-merge fetch time limit ran out';++export function trialMergeLines(ctx: QueueContext, pr: string, head: string, changed: readonly string[], progress?: (line: string) => void): string[] {const list = ctx.gh(['pr', 'list', '--state', 'open', '--base', ctx.base, '--limit', '200', '--json', 'number,headRefOid,files,isCrossRepository']);let open: Array<{ number: number; headRefOid: string; files?: Array<{ path: string }>; isCrossRepository?: boolean }> | undefined;try { open = list.ok ? JSON.parse(list.out) : undefined; } catch { open = undefined; }@@ -307,11 +311,27 @@ export function trialMergeLines(ctx: QueueContext, pr: string, head: string, chaconst siblings = others.map(p => ({ ...p, shared: (p.files ?? []).map(f => f.path).filter(f => own.has(f)) })).filter(p => p.shared.length);if (!siblings.length) return [`TRIAL_MERGES: none share a file (${others.length} open PRs checked)`];const remote = ctx.remote ?? 'origin';+ const has = (sha: string) => git(ctx.repoRoot, ['cat-file', '-e', `${sha}^{commit}`]).ok;+ const limitMs = Number(process.env.GSTACK_TRIAL_FETCH_TIMEOUT_MS) || 60_000;+ const deadline = Date.now() + limitMs;+ let missing = siblings.filter(p => !p.isCrossRepository && !has(p.headRefOid));+ let stalled = false;+ if (missing.length) {+ const refs = missing.map(p => `refs/pull/${p.number}/head`);+ progress?.(`TRIAL_MERGES: fetching ${refs.length} PR head(s) from ${remote} (time limit ${Math.ceil(limitMs / 1000)} s): ${refs.slice(0, 5).join(' ')}${refs.length > 5 ? ` (+${refs.length - 5} more)` : ''}`);+ stalled = git(ctx.repoRoot, ['fetch', '--no-tags', '-q', remote, ...refs], undefined, undefined, limitMs).status === null;+ missing = missing.filter(p => !has(p.headRefOid));+ for (const p of stalled ? [] : missing) {+ const left = deadline - Date.now();+ if (left <= 0 || git(ctx.repoRoot, ['fetch', '--no-tags', '-q', remote, `refs/pull/${p.number}/head`], undefined, undefined, left).status === null) { stalled = true; break; }+ }+ }return siblings.map(p => {const at = `#${p.number} ${p.headRefOid.slice(0, 12)} shares ${p.shared.slice(0, 5).join(', ')}${p.shared.length > 5 ? ` (+${p.shared.length - 5} more)` : ''}`;if (p.isCrossRepository) return `TRIAL_MERGES: ${at}: outside PR from a fork, not a sibling lane; not trial-merged (rule 19)`;- if (!git(ctx.repoRoot, ['cat-file', '-e', `${p.headRefOid}^{commit}`]).ok) git(ctx.repoRoot, ['fetch', '--no-tags', '-q', remote, `refs/pull/${p.number}/head`]);- if (!git(ctx.repoRoot, ['cat-file', '-e', `${p.headRefOid}^{commit}`]).ok) return `TRIAL_MERGES: ${at}: MISSING: its head is not in this clone after git fetch ${remote} refs/pull/${p.number}/head, so no trial merge ran`;+ if (!has(p.headRefOid)) return stalled+ ? `TRIAL_MERGES: ${at}: MISSING: ${TRIAL_FETCH_STALLED} (${Math.ceil(limitMs / 1000)} s) waiting on git fetch ${remote} refs/pull/${p.number}/head, so no trial merge ran`+ : `TRIAL_MERGES: ${at}: MISSING: its head is not in this clone after git fetch ${remote} refs/pull/${p.number}/head, so no trial merge ran`;const m = git(ctx.repoRoot, ['merge-tree', '--write-tree', '--name-only', '--no-messages', head, p.headRefOid]);const [tree, ...files] = m.out.split('\n').filter(Boolean);if (m.status === 0) return `TRIAL_MERGES: ${at}: merge-tree clean (tree ${(tree ?? '').slice(0, 12)})`;@@ -387,6 +407,8 @@ export function ready(ctx: QueueContext, o: { pr: string; pregate?: string; gateconst attempt = currentAttempt(ctx.repoRoot, o.pr);const changed = git(ctx.repoRoot, ['-c', 'core.quotePath=false', 'diff', '--name-only', `${baseSha}...${head}`]).out.split('\n').filter(Boolean);const hint = conflictHint(info.mergeable, ci, info.headRefName, info.isCrossRepository === true, head);+ const trials = trialMergeLines(ctx, o.pr, head, changed, line => process.stderr.write(`gstack-ship-queue ready: ${line}\n`));+ const stalled = trials.filter(l => l.includes(TRIAL_FETCH_STALLED)).map(l => /refs\/pull\/\d+\/head/.exec(l)?.[0]);const lines = [`READY #${o.pr} ${head} STAMP_VERSION=${version}`,`pr: ${info.url ?? `#${o.pr}`}`,@@ -403,7 +425,7 @@ export function ready(ctx: QueueContext, o: { pr: string; pregate?: string; gate...(receipt.depthLine ? [receipt.depthLine] : []),...(receipt.targetedLine ? [receipt.targetedLine] : []),...(gates?.lines ?? []),- ...readyTailLines(receipt.ok ? { ...receipt.receipt, gate_dispositions: undefined } : undefined, { trialMerges: trialMergeLines(ctx, o.pr, head, changed), trailRead: trailReadRow(o.trail) }),+ ...readyTailLines(receipt.ok ? { ...receipt.receipt, gate_dispositions: undefined } : undefined, { trialMerges: trials, trailRead: trailReadRow(o.trail) }),];const gate = policy.policy.full_e2e ? gateEvidence(ctx, o.pr, head, attempt, o.gateExit, o.gateLog) : null;if (gate) lines.push(gate.line);@@ -412,6 +434,7 @@ export function ready(ctx: QueueContext, o: { pr: string; pregate?: string; gateif (gate && !gate.ok) return fail({ code: 'QUEUE_GATE_MISSING', message: `full_e2e is set and no passing gate is bound to ${head.slice(0, 12)}: ${gate.line}` }, lines, run);if (!receipt.ok) return fail({ code: receipt.code, message: receipt.message }, lines, run);if (gates?.failure) return fail(gates.failure, lines, run);+ if (stalled.length) return fail({ code: 'QUEUE_NOT_READY', message: `the trial merges (rule 14) ran out of time waiting on git fetch ${ctx.remote ?? 'origin'} ${stalled.join(' ')}`, fix: `fetch those refs by hand (git fetch ${ctx.remote ?? 'origin'} <ref>), then rerun ready; GSTACK_TRIAL_FETCH_TIMEOUT_MS raises the limit` }, lines, run);const plan: ReturnType<typeof readyPlan> = policy.policy.train ? {} : readyPlan({ cwd: ctx.repoRoot, env: process.env, body: info.body ?? '', policyValue: policy.policy.plan_record, changed, fragmentsDir: policy.policy.changelog_fragments?.dir, finishLine: finishPlanLine(ctx.repoRoot, info.headRefName, head) });if (plan.line) lines.push(plan.line);if (plan.failure) return fail(plan.failure, lines, run);diff --git a/scripts/lib/windows-curation.ts b/scripts/lib/windows-curation.tsindex ba7ba3d1a..800b6065b 100644--- a/scripts/lib/windows-curation.ts+++ b/scripts/lib/windows-curation.ts@@ -318,6 +318,10 @@ export const KNOWN_WINDOWS_INCOMPATIBLE: Array<{ file: string; reason: string }>file: 'test/gstack-ship-queue.test.ts',reason: 'spawns bin/gstack-ship-queue (shebang) and a #!/bin/sh gh shim through test/helpers/restamp-fixture.ts and test/helpers/ship-queue-fixture.ts',},+ {+ file: 'test/ship-queue-trial-fetch.test.ts',+ reason: 'spawns bin/gstack-ship-queue (shebang), a #!/bin/sh gh shim and a #!/bin/sh upload-pack wrapper through test/helpers/restamp-fixture.ts and test/helpers/ship-queue-fixture.ts, as test/ship-queue-ready-fresh-base.test.ts does',+ },{file: 'test/ship-queue-ready-fresh-base.test.ts',reason: 'spawns bin/gstack-ship-queue (shebang) and a #!/bin/sh gh shim through test/helpers/restamp-fixture.ts and test/helpers/ship-queue-fixture.ts (windows-scoped-shard, run 42720453184)',diff --git a/test/ship-queue-trial-fetch.test.ts b/test/ship-queue-trial-fetch.test.tsnew file mode 100644index 000000000..627d35b0c--- /dev/null+++ b/test/ship-queue-trial-fetch.test.ts@@ -0,0 +1,151 @@+/**+ * gstack-ship-queue ready's trial merges (rule 14) fetch the PR heads this clone lacks in one git fetch under a time limit+ * (GST-3460). On gbrain #10011 ready printed nothing for minutes: each sibling PR's head came down in its own fetch, one at a+ * time, each allowed 120 s. Real fixture repos (bare origin plus working clone, PR heads under refs/pull/<n>/head) and a+ * logging upload-pack wrapper that counts fetches and can stall.+ */+import { afterEach, describe, expect, test } from 'bun:test';+import { spawnSync } from 'node:child_process';+import * as fs from 'node:fs';+import * as os from 'node:os';+import * as path from 'node:path';+import { EXIT } from '../lib/headless-artifacts';+import { CHECK_IDS } from '../lib/pregate/index';+import { trialMergeLines } from '../lib/ship-queue';+import { BASE_POLICY, cleanup, makeFixtureRepo, runBin, type FixtureRepo } from './helpers/restamp-fixture';+import { ghQueueShim } from './helpers/ship-queue-fixture';+import { shippedBody } from './helpers/ship-queue-train-fixture';++const dirs: string[] = [];+const repos: FixtureRepo[] = [];+afterEach(() => {+ while (dirs.length) fs.rmSync(dirs.pop()!, { recursive: true, force: true });+ while (repos.length) cleanup(repos.pop()!);+ delete process.env.GSTACK_TRIAL_FETCH_TIMEOUT_MS;+});++const STALLED = 'the trial-merge fetch time limit ran out';+const sh = (cwd: string, ...a: string[]) => {+ const r = spawnSync('git', ['-c', 'user.name=Fx', '-c', '[email protected]', ...a], { cwd, encoding: 'utf8', timeout: 30_000 });+ if (r.status !== 0) throw new Error(r.stderr);+ return r.stdout.trim();+};++/** An upload-pack that logs each fetch and, from fetch number `slowFrom` on, sleeps 30 s first. */+function uploadPack(dir: string, slowFrom = Infinity): { wrapper: string; count: () => number } {+ const log = path.join(dir, 'fetches.log');+ const wrapper = path.join(dir, 'upload-pack.sh');+ fs.writeFileSync(wrapper, `#!/bin/sh\necho x >> '${log}'\nn=$(wc -l < '${log}')\n[ "$n" -ge ${Number.isFinite(slowFrom) ? slowFrom : 999999} ] && sleep 30\nexec git-upload-pack "$@"\n`, { mode: 0o755 });+ return { wrapper, count: () => fs.existsSync(log) ? fs.readFileSync(log, 'utf8').split('\n').filter(Boolean).length : 0 };+}++/** A bare origin holding `n` sibling PR heads under refs/pull/<k>/head (k = 2..n+1), and a clone that has none of them. */+function queueOf(n: number, slowFrom?: number, gone?: number) {+ const root = fs.mkdtempSync(path.join(os.tmpdir(), 'gstack-trial-fetch-'));+ dirs.push(root);+ const origin = path.join(root, 'origin.git');+ const seed = path.join(root, 'seed');+ sh(root, 'init', '-q', '--bare', '-b', 'main', origin);+ sh(root, 'init', '-q', '-b', 'main', seed);+ fs.writeFileSync(path.join(seed, 'a.txt'), 'a\n');+ sh(seed, 'add', '-A'); sh(seed, 'commit', '-q', '-m', 'base'); sh(seed, 'push', '-q', origin, 'main');+ const list: Array<{ number: number; headRefOid: string; files: Array<{ path: string }> }> = [];+ for (let k = 2; k <= n + 1; k++) {+ sh(seed, 'checkout', '-q', '-B', `pr-${k}`, 'main');+ fs.writeFileSync(path.join(seed, `pr-${k}.txt`), `${k}\n`); fs.appendFileSync(path.join(seed, 'a.txt'), `${k}\n`);+ sh(seed, 'add', '-A'); sh(seed, 'commit', '-q', '-m', `pr ${k}`);+ sh(seed, 'push', '-q', origin, `HEAD:refs/pull/${k}/head`);+ list.push({ number: k, headRefOid: sh(seed, 'rev-parse', 'HEAD'), files: [{ path: 'a.txt' }] });+ }+ const work = path.join(root, 'work');+ sh(root, 'clone', '-q', '--no-local', origin, work);+ const pack = uploadPack(root, slowFrom);+ sh(work, 'config', 'remote.origin.uploadpack', pack.wrapper);+ sh(work, 'checkout', '-q', '-b', 'mine', 'origin/main');+ fs.writeFileSync(path.join(work, 'b.txt'), 'b\n'); fs.appendFileSync(path.join(work, 'a.txt'), 'mine\n');+ sh(work, 'add', '-A'); sh(work, 'commit', '-q', '-m', 'mine');+ const head = sh(work, 'rev-parse', 'HEAD');+ const mine = { number: 1, headRefOid: head, files: [{ path: 'a.txt' }] };+ const progress: string[] = [];+ const run = () => trialMergeLines({ repoRoot: work, base: 'main', gh: () => ({ ok: true, out: JSON.stringify([mine, ...list, ...(gone ? [{ number: gone, headRefOid: '1234567890abcdef1234567890abcdef12345678', files: [{ path: 'a.txt' }] }] : [])]) }) }, '1', head, ['a.txt', 'b.txt'], l => progress.push(l));+ return { run, list, progress, fetches: pack.count };+}++describe('trial merges fetch the missing PR heads once, under a time limit (GST-3460)', () => {+ // Value: protects=ready on a long queue fetches every missing sibling head in one git fetch and says so before it starts;+ // fails_when=each sibling's head is fetched on its own (gbrain #10011: minutes of silence, a 120 s allowance per fetch);+ // why_new=no trial-merge test had a head missing from the clone; seam=trialMergeLines' fetch; no_claim=gh's own latency+ test('twelve missing sibling heads come down in one fetch, announced first, and every sibling is still trial-merged', () => {+ const q = queueOf(12);+ const lines = q.run();+ expect(q.fetches()).toBe(1);+ expect(q.progress).toHaveLength(1);+ expect(q.progress[0]).toMatch(/^TRIAL_MERGES: fetching 12 PR head\(s\) from origin \(time limit 60 s\): refs\/pull\/2\/head .* \(\+7 more\)$/);+ expect(lines).toHaveLength(12);+ for (const p of q.list) expect(lines).toContainEqual(expect.stringMatching(new RegExp(`^TRIAL_MERGES: #${p.number} ${p.headRefOid.slice(0, 12)} shares a.txt: CONFLICT in a.txt;`)));+ }, 120_000);++ // Value: protects=a combined fetch that fails fast (one sibling's ref is gone from origin) falls back to one fetch per ref+ // and still trial-merges the rest; fails_when=the fallback loop is dropped or a failed fetch reads as a stall; why_new=no+ // case had a ref missing from origin; seam=trialMergeLines' fallback; no_claim=the fallback's own time limit+ test('a combined fetch that fails without stalling falls back to one fetch per ref and still trial-merges the rest', () => {+ const q = queueOf(3, undefined, 9);+ const lines = q.run();+ expect(q.fetches()).toBe(5);+ expect(lines.filter(l => l.includes('CONFLICT in a.txt'))).toHaveLength(3);+ expect(lines).toContainEqual('TRIAL_MERGES: #9 1234567890ab shares a.txt: MISSING: its head is not in this clone after git fetch origin refs/pull/9/head, so no trial merge ran');+ expect(lines.join('\n')).not.toContain(STALLED);+ }, 120_000);++ // Value: protects=a fetch that stalls ends at the time limit with a line naming each ref it waited on, instead of a silent+ // wait; fails_when=the fetch has no limit of its own or the stalled heads read as an ordinary missing head; why_new=the+ // fixtures never stalled a fetch; seam=trialMergeLines' time limit; no_claim=how ready refuses it (the bin case below)+ test('a stalled fetch stops at the limit and names every ref it was waiting on', () => {+ process.env.GSTACK_TRIAL_FETCH_TIMEOUT_MS = '1500';+ const q = queueOf(2, 1);+ const started = Date.now();+ const lines = q.run();+ expect(Date.now() - started).toBeLessThan(15_000);+ expect(lines).toEqual(q.list.map(p => `TRIAL_MERGES: #${p.number} ${p.headRefOid.slice(0, 12)} shares a.txt: MISSING: ${STALLED} (2 s) waiting on git fetch origin refs/pull/${p.number}/head, so no trial merge ran`));+ }, 60_000);+});++describe('ready refuses when the trial-merge fetch runs out of time (GST-3460)', () => {+ // Value: protects=ready fails closed, with a progress line first, when a sibling's head cannot be fetched in time;+ // fails_when=ready waits on the fetch silently, or prints READY with the trial merge missing; why_new=no ready test had a+ // sibling head missing from the clone; seam=ready -> trialMergeLines; no_claim=the train path's own ready+ test('a stalled sibling fetch prints a progress line, then refuses QUEUE_NOT_READY naming the ref', () => {+ const repo = makeFixtureRepo({ prefix: 'gstack-ready-trial-fetch-', policy: BASE_POLICY });+ repos.push(repo);+ repo.git('checkout', '-q', '-b', 'sib', 'origin/main');+ fs.writeFileSync(path.join(repo.work, 'shared.txt'), 'sibling\n');+ repo.git('add', '-A'); repo.git('commit', '-q', '-m', 'sibling');+ const sibling = repo.git('rev-parse', 'HEAD');+ repo.git('push', '-q', 'origin', 'HEAD:refs/pull/3/head');+ repo.git('checkout', '-q', '-b', 'pr-2', 'origin/main');+ repo.git('branch', '-D', 'sib');+ repo.git('reflog', 'expire', '--expire=now', '--all');+ repo.git('gc', '-q', '--prune=now');+ fs.writeFileSync(path.join(repo.work, 'shared.txt'), 'mine\n');+ repo.git('add', '-A'); repo.git('commit', '-q', '-m', 'mine');+ const head = repo.git('rev-parse', 'HEAD');+ expect(spawnSync('git', ['cat-file', '-e', `${sibling}^{commit}`], { cwd: repo.work, timeout: 30_000 }).status).not.toBe(0);+ const pregate = path.join(repo.root, 'pregate.json');+ fs.writeFileSync(pregate, JSON.stringify({ schema_version: 1, tree: runBin(repo, 'gstack-wtree', []).out.trim(), head, verdict: 'pass', checks: CHECK_IDS.map(id => ({ id, status: 'pass' })) }));+ const pr = { headRefOid: head, url: 'https://github.com/o/r/pull/2', headRefName: 'pr-2', isCrossRepository: false, body: shippedBody('2', head) };+ const shim = (list: unknown[]) => ghQueueShim(repo, { prs: { '2': pr }, list, checks: { [head]: { check_runs: [{ status: 'completed', conclusion: 'success' }] } } });+ const pack = uploadPack(repo.root);+ repo.git('config', 'remote.origin.uploadpack', pack.wrapper);+ const quiet = runBin(repo, 'gstack-ship-queue', ['ready', '--pr', '2', '--pregate', pregate, '--base', 'main'], shim([{ number: 2, headRefOid: head, files: [{ path: 'shared.txt' }] }]));+ expect([quiet.status, quiet.err]).toEqual([EXIT.ok, '']);+ fs.mkdirSync(path.join(repo.root, 'slow'));+ repo.git('config', 'remote.origin.uploadpack', uploadPack(path.join(repo.root, 'slow'), pack.count() + 1).wrapper);+ const r = runBin(repo, 'gstack-ship-queue', ['ready', '--pr', '2', '--pregate', pregate, '--base', 'main'], { ...shim([{ number: 2, headRefOid: head, files: [{ path: 'shared.txt' }] }, { number: 3, headRefOid: sibling, files: [{ path: 'shared.txt' }] }]), GSTACK_TRIAL_FETCH_TIMEOUT_MS: '1500' });+ expect(r.status).toBe(EXIT.refused);+ expect(r.err).toMatch(/^gstack-ship-queue ready: TRIAL_MERGES: fetching 1 PR head\(s\) from origin \(time limit 2 s\): refs\/pull\/3\/head$/m);+ expect(r.err).toContain('ran out of time waiting on git fetch origin refs/pull/3/head');+ expect(r.err).toContain('(QUEUE_NOT_READY)');+ expect(r.out).toContain(`TRIAL_MERGES: #3 ${sibling.slice(0, 12)} shares shared.txt: MISSING: ${STALLED}`);+ expect(r.out).not.toMatch(/^READY_RECEIPT:/m);+ }, 180_000);+});