Skip to content

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

v1.92.34.0 fix(ship-queue): wave plan links PRs only on a real code conflict and leaves out READY heads whose CI is not green (GST-770) (#3791)

Garry Tan6954a8c42be3
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d633c0025..c9dab291f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# Changelog
+## [1.92.34.0] - 2026-11-01
+
+- `gstack-ship-queue wave plan` no longer packs the whole READY queue into one area. Shared files now link two PRs into one group only when `git merge-tree` finds a real conflict between them in a code file or skill template. PRs of the same area still pack together as before. Docs, other Markdown and JSON ledgers never link PRs, since most PRs add to them. Before, any shared file linked two PRs, so `docs/troubleshooting.md` and a few ledgers chained 55 READY PRs into eight waves all labeled `setup`. With this change, the 57-PR queue later that day gives five groups split by area. A READY head whose CI is red or still running now prints `NOT_GREEN: #<n> (...)` and stays out of the plan, as `ready` would refuse it. A head whose CI cannot be read fails the plan with `QUEUE_PROOF_MISSING`, the same as an unreadable PR. Renamed files are compared by their real paths (GST-770).
+
## [1.92.33.0] - 2026-11-01
**Eleven flaky tests from the 2026-10-31 flaky pass stop failing correct runs, and six more now name their cause when they fail.** Three paid detectors missed correct replies, one product script copied a file git was rewriting, and the free-test reds came from a binary's slow first launch on a fresh Windows runner, a fixture written in two steps and a cleanup that raced the runner's own scanner.
diff --git a/VERSION b/VERSION
index 079d43520..64d2db59e 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.92.33.0
+1.92.34.0
diff --git a/agents-digest/gstack-AGENTS.md b/agents-digest/gstack-AGENTS.md
index 0ad343905..a945033ba 100644
--- a/agents-digest/gstack-AGENTS.md
+++ b/agents-digest/gstack-AGENTS.md
@@ -1,4 +1,4 @@
-# gstack digest v1.92.33.0 — regenerate/re-copy after upgrading gstack
+# gstack digest v1.92.34.0 — regenerate/re-copy after upgrading gstack
Behavioral rules from gstack (https://github.com/garrytan/gstack), compressed
for agent hosts without a full skill install. The full skills add workflows,
diff --git a/docs/ship-policy.md b/docs/ship-policy.md
index 99549bf1d..e7d658833 100644
--- a/docs/ship-policy.md
+++ b/docs/ship-policy.md
@@ -563,7 +563,7 @@ of required checks before it merges, one slot after another, so a wave of
three saves two of those rounds and two versions.
```bash
-gstack-ship-queue wave plan # read-only: QUEUE, WAVE_ADVISED, WAVE_GROUP lines
+gstack-ship-queue wave plan # read-only (merge-tree scratch objects aside): QUEUE, WAVE_ADVISED, WAVE_GROUP lines
gstack-ship-queue wave build --area ship --prs 41@<sha>,42@<sha>,43@<sha>
gstack-ship-queue wave build --wave <nonce> --continue # after resolving a conflict in the printed worktree
gstack-ship-queue wave build --wave <nonce> --drop 42 # rebuild without #42 as a new wave
@@ -573,9 +573,19 @@ gstack-ship-queue wave settle --wave <nonce> [--dry-run] # after the wave
```
- **When.** `wave plan` counts the live READY PRs (open, head equal to their
- READY receipt). Over the trigger (6) it prints `WAVE_ADVISED` and suggested
- groups of 3 to 6: PRs that change a common file always share a group (their
- conflicts are resolved once), each group takes its largest PR's functional
+ READY receipt, CI green at that head; a READY head whose CI is red, still
+ running or absent prints a `NOT_GREEN` line and stays out of the plan). A
+ READY PR whose CI, head or diff cannot be read fails the whole plan with
+ `QUEUE_PROOF_MISSING`. Over the
+ trigger (6) it prints `WAVE_ADVISED` and suggested groups of 3 to 6: PRs
+ whose changes to a common code file conflict (`git merge-tree` cannot merge
+ the two heads, or the check itself fails) always share a group, so that
+ conflict is resolved once. Hub
+ files never link PRs: anything under `docs/`, Markdown (generated skill
+ renders included; their `.tmpl` sources still link) and every `.json` or
+ `.jsonl` file (ledgers and registries). Most PRs append to them, and
+ linking through them once chained a 55-PR queue into a single area
+ (GST-770). Each group takes its largest PR's functional
area (a skill directory, the first word of a `lib/`, `bin/` or `test/`
module name, or `docs`), smaller groups ride solo, and the integrator is
the PR with the most changed lines. `train build` handed more than 6 pins
diff --git a/lib/ship-queue-wave.ts b/lib/ship-queue-wave.ts
index 73aec5177..c0f505f41 100644
--- a/lib/ship-queue-wave.ts
+++ b/lib/ship-queue-wave.ts
@@ -3,7 +3,8 @@
* when the queue is long, 3-6 PRs of one functional area travel as one wave PR
* that takes one train slot, one /ship, one READY and one version.
*
- * wave plan read-only: live READY PRs, WAVE_ADVISED over the trigger, suggested area groups
+ * wave plan read-only (git merge-tree leaves only unreferenced objects): live READY PRs with green
+ * CI, WAVE_ADVISED over the trigger, suggested area groups
* wave build the integrator branch wave/<nonce>: main plus each constituent's pinned head merged
* unchanged with the train's merge rules (a merge commit whose second parent is the
* pin); a conflict stops in a worktree under the state root (--continue resumes);
@@ -24,7 +25,7 @@ import { EXIT, formatResult } from './headless-artifacts';
import { RESULT_CODES } from './result-codes';
import { versionAtRef } from './restamp';
import { globToRegExp, type ShipPolicy } from './ship-policy';
-import type { QueueContext } from './ship-queue';
+import { ciAtHead, type QueueContext } from './ship-queue';
import { git, sha256, type QueueFailure } from './ship-queue-gate';
import { fetchBase, mergeCommit, outFailed, outOk, outRefused, parsePins, trainEnv, type TrainEnv, type TrainOut } from './ship-queue-train';
import { prInfo, type PrInfo } from './ship-queue-train-github';
@@ -79,20 +80,34 @@ export function dominantArea(files: string[], areaOf: (f: string) => string): st
const largestFirst = (a: PlanPr, b: PlanPr) => b.lines - a.lines || Number(a.pr) - Number(b.pr);
/**
- * Group PRs into waves: PRs that change a common file always travel together (one integrator
- * resolves their conflicts once), each cluster takes its largest PR's area, clusters of one
- * area are packed in PR order into waves of at most max, and a wave below min rides solo.
- * The integrator is the PR with the most changed lines.
+ * Hub files: prose (docs/**, Markdown, generated SKILL.md renders) and JSON ledgers and registries.
+ * Most PRs append to them, so their conflicts are kept-both-sides edits that any train slot
+ * resolves; linking PRs through them chained a 55-PR queue into one area (GST-770). They never
+ * link PRs into a wave. Skill templates (.md.tmpl) are source and link on a real conflict.
*/
-export function groupWaves(prs: PlanPr[], areaOf: (f: string) => string, min = WAVE_MIN, max = WAVE_MAX): { groups: WaveGroup[]; solo: string[] } {
+export const isHubFile = (file: string) => file.startsWith('docs/') || /\.(md|jsonl?)$/.test(file);
+
+/**
+ * Group PRs into waves: PRs whose changes to a common code file conflict always travel together
+ * (one integrator resolves the conflict once); hub files never link. conflicts(a, b) names the
+ * files a merge of the two heads cannot resolve, or null when unknown, which counts every shared
+ * file as conflicting. Each cluster takes its largest PR's area, clusters of one area are packed
+ * in PR order into waves of at most max, and a wave below min rides solo. The integrator is the
+ * PR with the most changed lines.
+ */
+export function groupWaves(prs: PlanPr[], areaOf: (f: string) => string, min = WAVE_MIN, max = WAVE_MAX, conflicts: (a: PlanPr, b: PlanPr) => string[] | null = () => null): { groups: WaveGroup[]; solo: string[] } {
const sorted = [...prs].sort((a, b) => Number(a.pr) - Number(b.pr));
const root = new Map(sorted.map(p => [p.pr, p.pr]));
const find = (x: string): string => { const r = root.get(x)!; return r === x ? x : find(r); };
- const owner = new Map<string, string>();
- for (const p of sorted) for (const f of p.files) {
- const o = owner.get(f);
- if (o && find(o) !== find(p.pr)) root.set(find(p.pr), find(o)); else if (!o) owner.set(f, p.pr);
- }
+ const sharers = new Map<string, PlanPr[]>();
+ for (const p of sorted) for (const f of p.files) if (!isHubFile(f)) sharers.set(f, [...(sharers.get(f) ?? []), p]);
+ const clash = new Map<string, string[] | null>();
+ for (const [f, list] of sharers) list.forEach((a, i) => list.slice(i + 1).forEach(b => {
+ const key = `${a.pr} ${b.pr}`;
+ if (!clash.has(key)) clash.set(key, conflicts(a, b));
+ const hit = clash.get(key);
+ if ((!hit || hit.includes(f)) && find(a.pr) !== find(b.pr)) root.set(find(b.pr), find(a.pr));
+ }));
const clusters = new Map<string, PlanPr[]>();
for (const p of sorted) clusters.set(find(p.pr), [...(clusters.get(find(p.pr)) ?? []), p]);
const byArea = new Map<string, PlanPr[][]>();
@@ -212,7 +227,7 @@ function readyReceipts(env: TrainEnv): ReadyReceipt[] {
function changed(env: TrainEnv, head: string): { files: string[]; lines: number } | null {
const fork = git(env.ctx.repoRoot, ['merge-base', `${env.remote}/${env.ctx.base}`, head]);
- const stat = fork.ok ? git(env.ctx.repoRoot, ['diff', '--numstat', fork.out, head]) : fork;
+ const stat = fork.ok ? git(env.ctx.repoRoot, ['diff', '--numstat', '--no-renames', fork.out, head]) : fork;
if (!stat.ok) return null;
let lines = 0;
const files: string[] = [];
@@ -250,15 +265,21 @@ export function wavePlan(ctx: QueueContext, o: { trigger: number; min: number; m
const info = prInfo(ctx, r.pr);
if ('error' in info) { unreadable.push(`#${r.pr} (${info.error})`); continue; }
if (info.state !== 'OPEN' || info.headRefOid !== r.head || info.isCrossRepository || info.headRefName.startsWith('wave/')) continue;
+ const ci = ciAtHead(ctx, r.head);
+ if (ci.line.startsWith('unknown')) { unreadable.push(`#${r.pr} (CI ${ci.line})`); continue; }
+ if (!ci.green) { lines.push(`NOT_GREEN: #${r.pr} (${ci.line}; left out until CI is green at the READY head)`); continue; }
if (!ensureCommit(env, r.head, r.pr)) { unreadable.push(`#${r.pr} (head ${short(r.head)} not fetchable)`); continue; }
const c = changed(env, r.head);
if (!c) { unreadable.push(`#${r.pr} (diff unreadable)`); continue; }
live.push({ pr: r.pr, head: r.head, ...c });
}
if (unreadable.length) return outFailed(fail('QUEUE_PROOF_MISSING', `cannot read ${unreadable.length} READY PR(s): ${unreadable.join('; ')}; a plan from a partial queue would mislead`), lines, `${Q} wave plan (after gh and git can read every PR)`, 'none');
- lines.push(`QUEUE: ${live.length} live READY PR(s) (open, head equal to its READY receipt); wave trigger ${o.trigger}`);
+ lines.push(`QUEUE: ${live.length} live READY PR(s) (open, head equal to its READY receipt, CI green there); wave trigger ${o.trigger}`);
if (live.length <= o.trigger) return outOk([...lines, `WAVE: not needed (${live.length} <= ${o.trigger}); build trains of single PRs`], `${Q} train build --prs <pins>`, 'none');
- const plan = groupWaves(live, areaOf(env), o.min, o.max);
+ const plan = groupWaves(live, areaOf(env), o.min, o.max, (a, b) => {
+ const m = git(env.ctx.repoRoot, ['merge-tree', '--write-tree', '--name-only', '--no-messages', a.head, b.head]);
+ return m.ok ? [] : m.status === 1 ? m.out.split('\n').slice(1).filter(Boolean) : null;
+ });
lines.push(`WAVE_ADVISED: ${live.length} READY PRs over the wave trigger ${o.trigger}; group by area into waves of ${o.min}-${o.max} (Garry R46)`);
for (const g of plan.groups) {
lines.push(`WAVE_GROUP: area=${g.area} prs=${g.prs.map(p => '#' + p.pr).join(',')} integrator=#${g.integrator} (most changed lines)`);
diff --git a/package.json b/package.json
index d45586b0c..b8524302e 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "gstack",
- "version": "1.92.33",
+ "version": "1.92.34",
"description": "Garry's Stack — Claude Code skills + fast headless browser. One repo, one install, entire AI engineering workflow.",
"license": "MIT",
"type": "module",
diff --git a/test/helpers/ship-queue-train-fixture.ts b/test/helpers/ship-queue-train-fixture.ts
index e1baa0cfe..c48fed515 100644
--- a/test/helpers/ship-queue-train-fixture.ts
+++ b/test/helpers/ship-queue-train-fixture.ts
@@ -44,7 +44,7 @@ export interface Rule {
export interface ShimData {
repo: string; origin: string; nextId: number; prs: Record<string, unknown>; runs: Array<Record<string, unknown>>;
artifacts: Record<string, Record<string, unknown>>; checks: Record<string, Array<{ name: string; status: string; conclusion: string | null }>>;
- ci: Record<string, unknown[]>; rules: Record<string, Rule>; artifact: string; log: Array<Record<string, unknown>>;
+ ci: Record<string, unknown[]>; ciFail?: string[]; rules: Record<string, Rule>; artifact: string; log: Array<Record<string, unknown>>;
/** Commit statuses (the legacy status API) at a sha, beside the check runs in `ci`. */
statuses?: Record<string, Array<{ state: string; context: string }>>;
/** Per PR, how many more `gh pr view` calls answer before the PR reads as not found (a GitHub answer that changes between two reads). */
@@ -206,6 +206,7 @@ function shimSource(): string {
" const named = /commits\\/([0-9a-f]+)\\/check-runs\\?check_name=([^&]+)/.exec(a[1] || '');",
" if (named) { const list = (d.checks[named[1]] || []).filter(c => c.name === decodeURIComponent(named[2])); out({ total_count: list.length, check_runs: list }); }",
" const paged = /commits\\/([0-9a-f]+)\\/(check-runs|status)\\?.*page=(\\d+)/.exec(a[1] || '');",
+ " if (paged && (d.ciFail || []).includes(paged[1])) fail('HTTP 502: gateway timeout');",
" if (paged) { const list = paged[2] === 'check-runs' ? (d.ci[paged[1]] || []) : ((d.statuses || {})[paged[1]] || []); const key = paged[2] === 'check-runs' ? 'check_runs' : 'statuses';",
" out(paged[3] === '1' ? { total_count: list.length, state: 'success', [key]: list } : { total_count: list.length, [key]: [] }); }",
"}",
diff --git a/test/ship-queue-wave.test.ts b/test/ship-queue-wave.test.ts
index e2132fd7c..d2f0a1ce2 100644
--- a/test/ship-queue-wave.test.ts
+++ b/test/ship-queue-wave.test.ts
@@ -12,7 +12,7 @@ import { spawnSync } from 'node:child_process';
import * as fs from 'node:fs';
import * as path from 'node:path';
import { EXIT } from '../lib/headless-artifacts';
-import { WAVE_HELP, areaKey, groupWaves, type PlanPr } from '../lib/ship-queue-wave';
+import { WAVE_HELP, areaKey, groupWaves, isHubFile, type PlanPr } from '../lib/ship-queue-wave';
import { cleanup, runBin } from './helpers/restamp-fixture';
import { line, openPr, queue, readyReceipt, shippedBody, trainFixture, type TrainFixture } from './helpers/ship-queue-train-fixture';
@@ -66,6 +66,19 @@ describe('areas and grouping', () => {
]);
expect(solo).toEqual(['7']);
});
+
+ test('groupWaves links PRs through a shared code file or skill template only when the merge conflicts there, never through a hub file (GST-770)', () => {
+ const pr = (n: string, files: string[]): PlanPr => ({ pr: n, head: n.repeat(40).slice(0, 40), files, lines: 10 });
+ const areaOf = (f: string) => areaKey(f, d => d === 'ship');
+ const linked = (files: string[], conflicts?: (a: PlanPr, b: PlanPr) => string[] | null) =>
+ groupWaves([pr('1', ['lib/pregate-a.ts', 'test/pregate-a.test.ts', ...files]), pr('2', ['lib/review-b.ts', 'test/review-b.test.ts', ...files])], areaOf, 2, 6, conflicts).groups.map(g => g.prs.map(p => p.pr));
+ expect(linked(['lib/ship-a.ts'])).toEqual([['1', '2']]);
+ expect(linked(['lib/ship-a.ts'], () => ['lib/ship-a.ts'])).toEqual([['1', '2']]);
+ expect(linked(['lib/ship-a.ts'], () => [])).toEqual([]);
+ expect(linked(['ship/SKILL.md.tmpl'], () => ['ship/SKILL.md.tmpl'])).toEqual([['1', '2']]);
+ for (const hub of ['docs/troubleshooting.md', 'ship/SKILL.md', 'scripts/harness-version.json']) expect(linked([hub], () => [hub])).toEqual([]);
+ expect([isHubFile('docs/x.ts'), isHubFile('TODOS.md'), isHubFile('test/fixtures/x.json'), isHubFile('ship/SKILL.md.tmpl'), isHubFile('lib/x.ts')]).toEqual([true, true, true, false, false]);
+ });
});
describe('wave build', () => {
@@ -235,6 +248,7 @@ describe('ready and train build read the wave', () => {
const pins = ['1', '2', '3', '4', '5', '6', '7'].map(pr => {
const h = openPr(fx, pr, { file: pr === '7' ? 'docs/seven.md' : `lib/ship-${pr}.ts`, changelog: false });
readyReceipt(fx, pr, h);
+ fx.write(d => { d.ci[h] = [{ name: 'free-tests', status: 'completed', conclusion: 'success' }]; });
return `${pr}@${h}`;
});
const build = queue(fx, ['train', 'build', '--prs', pins.join(','), '--dry-run']);
@@ -246,6 +260,55 @@ describe('ready and train build read the wave', () => {
expect(line(plan.out, 'SOLO:')).toContain('#7');
expect(line(queue(fx, ['wave', 'plan', '--trigger', '7']).out, 'WAVE:')).toContain('not needed');
}, 180_000);
+
+ test('wave plan links PRs only on a real code conflict, so hub docs and ledgers do not chain areas together, and leaves out READY heads whose CI is not green (GST-770)', () => {
+ const fx = make();
+ const moved = (first: string) => Array.from({ length: 10 }, (_, i) => i === 0 && first ? `export const o0 = '${first}';\n` : `export const o${i} = ${i};\n`).join('');
+ const seed = { 'docs/troubleshooting.md': '# Troubleshooting\n', 'test/fixtures/ledger.json': '{}\n', 'lib/ship-a.ts': 'export const a = 0;\n', 'lib/ship-old.ts': moved('') };
+ fx.repo.git('checkout', '-q', 'origin/main', '-B', 'seed');
+ for (const [f, t] of Object.entries(seed)) { fs.mkdirSync(path.dirname(path.join(fx.repo.work, f)), { recursive: true }); fs.writeFileSync(path.join(fx.repo.work, f), t); }
+ fx.repo.git('add', '-A');
+ fx.repo.git('commit', '-q', '-m', 'seed hub files');
+ fx.repo.git('push', '-q', 'origin', 'HEAD:main');
+ fx.repo.git('fetch', '-q', 'origin');
+ const pr = (n: string, area: string, extra: Record<string, string | null> = {}, ci = 'success') => {
+ fx.repo.git('checkout', '-q', 'origin/main', '-B', `pr-${n}`);
+ const files = { [`lib/${area}-${n}.ts`]: `export const x${n} = 1;\n`, [`test/${area}-${n}.test.ts`]: `// #${n}\n`,
+ 'docs/troubleshooting.md': `# Troubleshooting\n\n## #${n}\n`, 'test/fixtures/ledger.json': `{ "pr": ${n} }\n`, ...extra };
+ for (const [f, t] of Object.entries(files)) if (t === null) fs.rmSync(path.join(fx.repo.work, f)); else fs.writeFileSync(path.join(fx.repo.work, f), t);
+ fx.repo.git('add', '-A');
+ fx.repo.git('commit', '-q', '-m', `feat #${n}`);
+ const head = fx.repo.git('rev-parse', 'HEAD');
+ fx.repo.git('push', '-q', '-f', 'origin', `HEAD:refs/pull/${n}/head`);
+ fx.write(d => {
+ d.prs[n] = { headRefOid: head, isCrossRepository: false, state: 'OPEN', headRefName: `pr-${n}`, url: `https://github.com/fixture/repo/pull/${n}`, body: shippedBody(n, head) };
+ d.ci[head] = [{ name: 'free-tests', status: 'completed', conclusion: ci }];
+ });
+ readyReceipt(fx, n, head);
+ };
+ pr('1', 'ship', { 'lib/ship-a.ts': Array.from({ length: 40 }, (_, i) => `export const a${i} = 'one';\n`).join('') });
+ pr('2', 'ship', { 'lib/ship-old.ts': null, 'lib/ship-new.ts': moved('two') });
+ pr('3', 'ship');
+ for (const n of ['4', '5', '6']) pr(n, 'pregate');
+ pr('8', 'review', { 'lib/ship-a.ts': "export const a = 'eight';\n" });
+ pr('9', 'pregate', {}, 'failure');
+ pr('10', 'pregate');
+ pr('11', 'pregate', { 'lib/ship-old.ts': null, 'lib/ship-new.ts': moved('eleven') });
+ fx.write(d => { d.ci[(d.prs['10'] as any).headRefOid] = [{ name: 'free-tests', status: 'in_progress', conclusion: null }]; });
+ const plan = queue(fx, ['wave', 'plan']);
+ expect(plan.status).toBe(EXIT.ok);
+ expect(plan.out.split('\n').filter(l => l.startsWith('NOT_GREEN:')).map(l => l.replace(/ at [0-9a-f]{12} .*/, ''))).toEqual(['NOT_GREEN: #9 (red', 'NOT_GREEN: #10 (pending']);
+ expect(line(plan.out, 'QUEUE:')).toContain('8 live READY PR(s)');
+ expect(plan.out.split('\n').filter(l => l.startsWith('WAVE_GROUP:'))).toEqual([
+ 'WAVE_GROUP: area=pregate prs=#4,#5,#6 integrator=#4 (most changed lines)',
+ 'WAVE_GROUP: area=ship prs=#1,#8,#2,#11,#3 integrator=#1 (most changed lines)',
+ ]);
+ expect(line(plan.out, 'SOLO:')).toBe('');
+ fx.write(d => { d.ciFail = [(d.prs['4'] as any).headRefOid]; });
+ const unread = queue(fx, ['wave', 'plan']);
+ expect([unread.status, unread.err]).toEqual([EXIT.fail, expect.stringContaining('(QUEUE_PROOF_MISSING')]);
+ expect(unread.err).toContain('#4 (CI unknown at');
+ }, 180_000);
});
describe('wave settle', () => {