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
Review and shipping tools: seven small fixes to exclusions, issue links, PR description checks, build outputs, known-red tests and telemetry (GST-3464) (#4672)
Garry Tanf7e16a54fcb0
diff --git a/bin/gstack-issue-links b/bin/gstack-issue-linksindex f383a8a34..b2bb28507 100755--- a/bin/gstack-issue-links+++ b/bin/gstack-issue-links@@ -141,7 +141,7 @@ function main(argv: string[]): number {const autoLinks = !argv.includes('--no-auto-links');const binDir = path.dirname(Bun.fileURLToPath(import.meta.url));- const log = git(['log', '--format=%H%n%B%x00', `origin/${base}..HEAD`], repoRoot) ?? git(['log', '--format=%H%n%B%x00', `${base}..HEAD`], repoRoot);+ const log = git(['log', '-z', '--format=%H%n%B', `origin/${base}..HEAD`], repoRoot) ?? git(['log', '-z', '--format=%H%n%B', `${base}..HEAD`], repoRoot);if (log === undefined) { process.stderr.write(`gstack-issue-links: cannot read commits ${base}..HEAD (fetch origin/${base} first)\n`); return EXIT.usage; }const named: IssueMention[] = [];for (const entry of log.split('\0')) {diff --git a/bin/gstack-telemetry-log b/bin/gstack-telemetry-logindex 7bd859a23..757311879 100755--- a/bin/gstack-telemetry-log+++ b/bin/gstack-telemetry-log@@ -128,10 +128,12 @@ fi# The day's marker is claimed with noclobber (O_EXCL), so concurrent runs send it once.if [ "$EVENT_TYPE" = "onboarding" ]; thenOB_NAME="$(printf '%s' "$SKILL" | tr -cd 'A-Za-z0-9_-')--$(printf '%s' "$OUTCOME" | tr -cd 'A-Za-z0-9_-')"- OB_MARKER="$ANALYTICS_DIR/.onboarding-$OB_NAME-$(date -u +%Y-%m-%d)"+ OB_DAY="$(date -u +%Y-%m-%d)"+ OB_MARKER="$ANALYTICS_DIR/.onboarding-$OB_NAME-$OB_DAY"mkdir -p "$ANALYTICS_DIR" 2>/dev/null( set -C; : > "$OB_MARKER" ) 2>/dev/null || exit 0 # best-effort: another run already recorded this step today- for _ob in "$ANALYTICS_DIR"/.onboarding-"$OB_NAME"-[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]; do [ "$_ob" = "$OB_MARKER" ] || rm -f "$_ob"; done+ # Only older days' markers go: a run still on yesterday's date at UTC midnight must not delete today's (#4597).+ for _ob in "$ANALYTICS_DIR"/.onboarding-"$OB_NAME"-[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]; do [[ "${_ob: -10}" < "$OB_DAY" ]] && rm -f "$_ob"; donefi# ─── Finalize stale .pending markers ────────────────────────diff --git a/changelog.d/ci-tools-small-fixes.md b/changelog.d/ci-tools-small-fixes.mdnew file mode 100644index 000000000..fdf960bff--- /dev/null+++ b/changelog.d/ci-tools-small-fixes.md@@ -0,0 +1 @@+**Small fixes to /ship's helper tools.** `gstack-issue-links` no longer turns /ship's `Review-Finding:` trailers (`p1/red-team#3`) into `Refs` lines in the PR body (#4371), and names the commit of every issue mention instead of `commit :` for mentions in older commits on the branch (#4378, reported and first fixed by @Davmunrey). `gstack-ship-receipt read --check-prose` skips the PR body's opening above its first fold when that opening fits the 3-line, 600-character limit, so a result the PR is about ("58 fixed with gstack") is no longer a false counter mismatch. The review fetch check no longer stops /ship when a stage builds the repo's own native binary at a path its committed `.gitignore` names exactly (`bin/gstack-cso-core`). A base ship policy whose only error is its exclusion list no longer also drops an unknown key that merely starts with that list's name. Merge trains accept `--fixes-base-red-file` for gate case names that hold a comma and read `>` and `'` in JUnit names (#4569). Setup's daily onboarding event can no longer be sent twice when a run straddles UTC midnight.diff --git a/crew/lib/ship-queue-train-cli.ts b/crew/lib/ship-queue-train-cli.tsindex 44f166740..527a8aefc 100644--- a/crew/lib/ship-queue-train-cli.ts+++ b/crew/lib/ship-queue-train-cli.ts@@ -6,6 +6,7 @@* and the canonical `GSTACK_RESULT: skill=ship-queue status=<s> run=<record>`.* Loaded by the bin only when one of those paths runs.*/+import * as fs from 'node:fs';import { EXIT, formatResult } from '../../lib/headless-artifacts';import { RESULT_CODES } from '../../lib/result-codes';import type { QueueContext } from '../../lib/ship-queue';@@ -56,7 +57,7 @@ export const TRAIN_HELP = ` train build --prs <n>@<sha>[,...] [--order <n>,...]settles merging or green trains whose every PR is merged or closed on GitHub, anddeletes screen/<pr>-* branches of merged or closed PRsready --pr <n> --screen [--broad] | --no-screen [--dry-run] [--dispatch-ci <wf.yml[,…]> [--timeout <s>]]- [--base-red --fixer <pr> | --fixes-base-red <case,...>]+ [--base-red --fixer <pr> | --fixes-base-red <case,...> | --fixes-base-red-file <file>](trains with gates) --base-red: a conditional READY for a paused /ship, seatedonly behind fixer <pr> at slot 1; --fixes-base-red: the fixer's READY(train policy) READY plus the screen choice, recorded as a receipt; a head whose@@ -76,6 +77,22 @@ function flag(args: string[], name: string): string | undefined {return i >= 0 ? args[i + 1] : undefined;}+/**+ * The gate cases a fixer's READY names: `--fixes-base-red <case,...>`, or `--fixes-base-red-file <file>` with one case per+ * line, for case names that hold a comma (#4569: Vitest titles such as "…, and the create saves before the cancel writes").+ */+export function fixesBaseRedCases(args: string[]): { cases: string[] | undefined } | { error: string } {+ const list = flag(args, '--fixes-base-red'), file = flag(args, '--fixes-base-red-file');+ if (list !== undefined && file !== undefined) return { error: 'pass --fixes-base-red or --fixes-base-red-file, not both' };+ if (list === undefined && file === undefined) return args.includes('--fixes-base-red-file') ? { error: '--fixes-base-red-file needs a file, one gate case per line' } : { cases: undefined };+ let cases: string[];+ if (file !== undefined) {+ try { cases = fs.readFileSync(file, 'utf8').split(/\r?\n/).map(s => s.trim()).filter(Boolean); }+ catch { return { error: `--fixes-base-red-file cannot read ${file}; it needs one gate case per line` }; }+ } else cases = list!.split(',').map(s => s.trim()).filter(Boolean);+ return cases.length ? { cases } : { error: '--fixes-base-red names the gate cases the fixer repairs, comma-separated, or one per line in --fixes-base-red-file' };+}+export function printTrain(cmd: string, out: TrainOut): number {for (const line of out.lines) process.stdout.write(line + '\n');if (out.failure) {@@ -178,13 +195,14 @@ export async function readyMain(ctx: QueueContext, args: string[], base: { pr: sconst timeoutSec = positive(flag(args, '--timeout'), 2700);if (!Number.isFinite(timeoutSec)) return usage('--timeout needs a positive number of seconds');const fixer = flag(args, '--fixer');- const fixes = flag(args, '--fixes-base-red');+ const fixes = flag(args, '--fixes-base-red') ?? (args.includes('--fixes-base-red-file') ? '' : undefined);if (fixer !== undefined && !/^\d+$/.test(fixer)) return usage('--fixer needs the fixer PR number');if (fixer !== undefined && !args.includes('--base-red')) return usage('--fixer names the fixer of a --base-red READY');if (args.includes('--base-red') && fixes !== undefined) return usage('--base-red (the paused PR) and --fixes-base-red (its fixer) are different READYs; pass one');if ((args.includes('--base-red') || fixes !== undefined) && !noScreen) return usage('a base-red READY is --no-screen: the train gates every prefix');- const fixesBaseRed = fixes?.split(',').map(s => s.trim()).filter(Boolean);- if (fixes !== undefined && !fixesBaseRed?.length) return usage('--fixes-base-red names the gate cases the fixer repairs, comma-separated');+ const named = fixesBaseRedCases(args);+ if ('error' in named) return usage(named.error);+ const fixesBaseRed = named.cases;return guarded('ready', () => trainReady(ctx, { ...base, baseRed: args.includes('--base-red') ? { fixer } : undefined, fixesBaseRed, screen: screen ? 'screen' : noScreen ? 'no-screen' : undefined, broad: args.includes('--broad'), dryRun: args.includes('--dry-run'),dispatchCi: workflows.length ? { workflows, timeoutSec, pollMs: Number(process.env.GSTACK_SHIP_QUEUE_POLL_MS) || 30_000 } : undefined }));}diff --git a/crew/lib/ship-queue-train-gate.ts b/crew/lib/ship-queue-train-gate.tsindex 28642518f..e2324c6b4 100644--- a/crew/lib/ship-queue-train-gate.ts+++ b/crew/lib/ship-queue-train-gate.ts@@ -146,6 +146,13 @@ export function classifyWorkflowRun(o: { run: RunFacts; head: string; workflow:}/** JUnit XML (testcase elements) or a JSON test list ({ tests: [{ id, status }] }) to executed and failed test ids. */+/** An XML attribute's text with its character references decoded (`>`, `'`, `,`), so a JUnit case id matches the name a READY declares (#4569). */+const XML_NAMED: Record<string, string> = { lt: '<', gt: '>', amp: '&', quot: '"', apos: "'" };+const xmlText = (s: string) => s.replace(/&(?:#x([0-9a-f]+)|#(\d+)|(lt|gt|amp|quot|apos));/gi, (whole, hex: string | undefined, dec: string | undefined, name: string | undefined) => {+ const code = hex ? parseInt(hex, 16) : dec ? Number(dec) : -1;+ return name ? XML_NAMED[name.toLowerCase()]! : code >= 0 && code <= 0x10ffff ? String.fromCodePoint(code) : whole;+});+export function parseTestRecord(files: Array<{ name: string; text: string }>): RecordFacts | null {let executed = 0; const failed: string[] = []; let read = false;for (const f of files) {@@ -162,7 +169,7 @@ export function parseTestRecord(files: Array<{ name: string; text: string }>): R} else if (f.name.endsWith('.xml')) {read = true;for (const m of f.text.matchAll(/<testcase\b([^>]*?)(\/>|>([\s\S]*?)<\/testcase>)/g)) {- const attr = (k: string) => new RegExp(`\\b${k}="([^"]*)"`).exec(m[1]!)?.[1] ?? '';+ const attr = (k: string) => xmlText(new RegExp(`\\b${k}="([^"]*)"`).exec(m[1]!)?.[1] ?? '');const body = m[3] ?? '';if (/<skipped\b/.test(body)) continue;executed++;diff --git a/crew/test/ship-queue-train-generic.test.ts b/crew/test/ship-queue-train-generic.test.tsindex 596b78483..bc924be70 100644--- a/crew/test/ship-queue-train-generic.test.ts+++ b/crew/test/ship-queue-train-generic.test.ts@@ -15,6 +15,7 @@ import { EXIT } from '../../lib/headless-artifacts';import { TRAIN_GATES_KEY_VERSION, validatePolicy } from '../../lib/ship-policy';import { baseRedAdmission, classifyPrefixes, classifyWorkflowRun, commandReservation, concurrencyKeyed, gatedChain, parseTestRecord } from '../lib/ship-queue-train-gate';import { pushMatchesPrefix, workflowFacts } from '../lib/ship-queue-train-init';+import { fixesBaseRedCases } from '../lib/ship-queue-train-cli';import type { TrainSlot } from '../lib/ship-queue-train-record';import { BASE_POLICY, cleanup } from '../../test/helpers/restamp-fixture';import { line, nonceOf, openPr, queue, readyReceipt, repoKey, shippedBody, trainFixture, trainJson, TRAIN_POLICY, type TrainFixture } from '../../test/helpers/ship-queue-train-fixture';@@ -167,6 +168,24 @@ describe('prefix verdicts', () => {expect(parseTestRecord([{ name: 'r.json', text: JSON.stringify({ tests: [{ id: 'x', status: 'pass' }, { id: 'y', status: 'fail' }, { id: 'z', status: 'skip' }] }) }])).toEqual({ executed: 2, failed: ['y'] });expect(parseTestRecord([{ name: 'r.txt', text: '' }])).toBeNull();});+ test('a JUnit case name with XML character references reads as the name a READY declares (#4569)', () => {+ const xml = '<testsuite><testcase classname="cancel.test.ts" name="saves, and the create saves before the cancel writes > it's → done & ,"><failure/></testcase></testsuite>';+ expect(parseTestRecord([{ name: 'r.xml', text: xml }])!.failed).toEqual(["cancel.test.ts.saves, and the create saves before the cancel writes > it's \u2192 done & ,"]);+ });+ test('--fixes-base-red-file names cases that hold a comma, one per line; the comma list and the errors are unchanged (#4569)', () => {+ const d = fs.mkdtempSync(path.join(os.tmpdir(), 'gstack-fixes-red-'));+ try {+ const file = path.join(d, 'cases.txt');+ fs.writeFileSync(file, 'a.test.ts > saves, and the create saves before the cancel writes\r\n\n b.test.ts > other \n');+ expect(fixesBaseRedCases(['--fixes-base-red-file', file])).toEqual({ cases: ['a.test.ts > saves, and the create saves before the cancel writes', 'b.test.ts > other'] });+ expect(fixesBaseRedCases(['--fixes-base-red', 'a, b'])).toEqual({ cases: ['a', 'b'] });+ expect(fixesBaseRedCases([])).toEqual({ cases: undefined });+ expect(fixesBaseRedCases(['--fixes-base-red', 'a', '--fixes-base-red-file', file])).toEqual({ error: 'pass --fixes-base-red or --fixes-base-red-file, not both' });+ expect('error' in fixesBaseRedCases(['--fixes-base-red-file', path.join(d, 'missing')])).toBe(true);+ fs.writeFileSync(file, '\n');+ expect('error' in fixesBaseRedCases(['--fixes-base-red-file', file])).toBe(true);+ } finally { fs.rmSync(d, { recursive: true, force: true }); }+ });test('gated refs and the command price', () => {const prefixes = [0, 1, 2].map(index => ({ index, commit: String(index).repeat(40), tree: 't'.repeat(40) }));expect(gatedChain('n1', prefixes as never).map(p => p.ref)).toEqual(['train-prefix/n1/t0', 'train-prefix/n1/t1', 'train-prefix/n1/t2']);diff --git a/docs/pregate.md b/docs/pregate.mdindex b35f365a3..2f57cefe5 100644--- a/docs/pregate.md+++ b/docs/pregate.md@@ -2430,7 +2430,10 @@ cross-repo `Refs name#N`, never a same-repo Refs line or a promotioncandidate; `(see #12)`, `(closing #12)` and `(#301)` stay bare refs.Several in one parenthesis, `(founderstar #837, harness-evals #393)`, are eachtheir own name's reference. `owner/repo#N` naming this repository is its own-issue, so a `Fixes garrytan/gstack#N` trailer closes it.+issue, so a `Fixes garrytan/gstack#N` trailer closes it. A `Review-Finding:`+trailer line, which /ship writes for each fixed review finding, names a review+ledger entry (`p1/red-team#3`) or a fingerprint, never an issue, so it is skipped+(#4371).Same-repo references are printed aspromotion candidates (`reference #N ← <commit line> (promote: fix #N)` onstderr, `candidates` in `--json`): the owner's `fix #N` reply reruns withdiff --git a/docs/review-policy.md b/docs/review-policy.mdindex 0bf52c0b3..5e9bba8d9 100644--- a/docs/review-policy.md+++ b/docs/review-policy.md@@ -871,6 +871,12 @@ repository whose every network-looking remote resolves to a local path throughmarker on a sweep root itself is not honored, insteadOf that sends a local pathto the network still counts, and a clone made inside a live fixture root goesunseen, as does one whose reader writes the marker or an insteadOf line itself.+The checkout's own build output is not a fetch either: a new big native executable+(ELF, Mach-O or PE) inside the checkout, at a path its committed, unmodified root+`.gitignore` names exactly with no glob (`bin/gstack-cso-core`), prints+`FETCH_IGNORED: … reason=build-output`. A big file under an ignored directory or a+glob, a non-executable at that path, or a path only an uncommitted `.gitignore`+edit names still counts as a download.A `Bun.spawn` child given no `env` keeps the temp dir its test process startedwith, so its fixtures land outside the marked root and still count.diff --git a/docs/ship-policy.md b/docs/ship-policy.mdindex c0328c9c6..a947f57b0 100644--- a/docs/ship-policy.md+++ b/docs/ship-policy.md@@ -584,7 +584,9 @@ commit in another train is reused instead of run again.**Base-red PRs.** A lane whose /ship paused on a red base (its receipt carries`base_red`) READYs with `ready --pr <n> --no-screen --base-red --fixer <pr>`:the condition must have been classified on today's base and not have expired.-The fixer READYs with `--fixes-base-red <case,...>`. The fixer rides at slot 1+The fixer READYs with `--fixes-base-red <case,...>`, or with+`--fixes-base-red-file <file>` (one case per line) when a case name holds a+comma; a JUnit record's `>` and `'` read as `>` and `'` (#4569). The fixer rides at slot 1(moved there unless `--order` says otherwise, which then refuses), T0 may bered on exactly the fixer's cases and nothing else, and every conditional PRbehind it is gated on its own prefix with nothing excluded. A conditional PR@@ -1435,7 +1437,10 @@ key's claim alone, so `passes=2 blocking_found=1` is two claims, never aboth values; prose that quotes no counter is not a claim. The `## Approvals`block `gstack-approvals` renders (its heading, the Date | Asked | Exact wordstable and the `Source: gstack-approvals record` line) quotes the owner's-words, not this PR's numbers, so it is skipped: "one Step 11 pass" in that table+words, not this PR's numbers, so it is skipped, and so is the body's opening+above its first `<details>` fold, which says what changed for a user (a result+the PR is about, "58 fixed with gstack", is not a `fixed` claim; a body with no+fold, or whose opening is longer than 3 lines or 600 characters, is checked whole): "one Step 11 pass" in that tableis not a `pass` claim. Text you write under the heading after that block isstill checked. The `Review-loop exception: …` line (GST-977) and the`Documentation exception: …` line (GST-983) the receipt's own exceptionsdiff --git a/docs/troubleshooting.md b/docs/troubleshooting.mdindex 5f13c6698..4ee3b3129 100644--- a/docs/troubleshooting.md+++ b/docs/troubleshooting.md@@ -4307,7 +4307,9 @@ leave `merged.jsonl`, and it never reaches the Red Team, the judge, thereturned output or PR text. `verify` prints `FETCH_VIOLATION:` and refusesuntil the stage has rerun and swept clean. A test run's fixtures (a rootcarrying `.gstack-test-fixture`, or a repository whose remote resolves to a local-path through `url.<base>.insteadOf`) print `FETCH_IGNORED:` and never count.+path through `url.<base>.insteadOf`) and the checkout's own native build output at a+path its committed root `.gitignore` names exactly (`bin/gstack-cso-core`) print+`FETCH_IGNORED:` and never count.Capy's `~/.capy/drive` is never walked, and the drive sync database under`~/.capy/drive-engine` (`state.db` and its `-wal`, `-shm` and `-journal` files)is ignored, so that database growing past 100 MB is not a violation. Any other@@ -7979,8 +7981,9 @@ the run; the prose was typed, so a reader of the body would learn a number therun did not produce. The `PROSE:` line names each field with both values. The`## Approvals` table `gstack-approvals` renders, the `Review-loop exception: …`,`Documentation exception: …`, `Ruled note: …`, `Gate disposition: …`, `Mechanical retake: …` and-`Test-lane exception: …` lines the receipt requires, and the inside of a-closed code fence are never read as claims.+`Test-lane exception: …` lines the receipt requires, the body's opening above+its first `<details>` fold when it fits 3 lines and 600 characters, and the+inside of a closed code fence are never read as claims.**Fix.** Correct the body to the receipt's number. When the receipt is thestale one (the run was repeated), rerun `/ship` so the receipt is rewrittendiff --git a/lib/issue-links.ts b/lib/issue-links.tsindex 1fd791d5f..cf112f52c 100644--- a/lib/issue-links.ts+++ b/lib/issue-links.ts@@ -48,6 +48,8 @@ export interface ClosingPr { number: number; state?: string; headRefName?: strinconst CLOSURE = /^\s*(?:fix(?:es|ed)?|close[sd]?|resolve[sd]?)\s*:?\s+(?:([A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+)#|#|GH-)(\d+)\s*$/i;const PARTIAL = /\b(?:partial(?:ly)?|part of|defer(?:red)?|follow-?up|related|refs?|see|context)\b/i;const CROSS = /\b([A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+)#(\d+)\b/g;+/** /ship's `Review-Finding: <ledger id or fingerprint> reader=<reader>` trailer names a review ledger entry (`p1/red-team#3`), never an issue (#4371). */+const REVIEW_FINDING = /^\s*review-finding:\s/i;const BARE = /(?<![A-Za-z0-9_./-])#(\d+)\b/g;/** One `name #N[, #M]…`, `name PR #N` or `name issue #N`: the name, then every number. */const NAMED_PART = /([A-Za-z][\w.-]*(?:\/[\w.-]+)?)\s+(?:(?:PR|issue)\s+)?(#\d+(?:,\s*#\d+)*)/gi;@@ -63,6 +65,7 @@ export function mentionsIn(message: string, source = 'commit'): IssueMention[] {const add = (m: IssueMention) => { const k = `${m.repo ?? ''}#${m.issue}:${m.intent}`; if (!seen.has(k)) { seen.add(k); out.push(m); } };for (const raw of message.split('\n')) {const line = raw.replace(/\s+$/, '');+ if (REVIEW_FINDING.test(line)) continue;const trailer = CLOSURE.exec(line);if (trailer && !PARTIAL.test(line)) { add({ issue: Number(trailer[2]), intent: 'fixes', ...(trailer[1] ? { repo: trailer[1] } : {}), source: `${source}: ${line.trim()}` }); continue; }const rest = line.replace(NAMED, whole => whole.replace(NAMED_PART, (part, name: string, numbers: string) => {diff --git a/lib/review-sweep.ts b/lib/review-sweep.tsindex c948e3e44..313f3f4db 100644--- a/lib/review-sweep.ts+++ b/lib/review-sweep.ts@@ -34,7 +34,7 @@ const SCP = /^(?:[\w.-]+@)?[\w.-]+:(?!\/\/)[\w./-]+$/;export interface Inventory { at: number; roots: string[]; repos: Record<string, string[]>; big: Record<string, number>; ignored?: Record<string, Omit<Ignored, 'path'>>; partial?: string }export interface Found { path: string; kind: 'repo' | 'download'; remote?: string; bytes: number | null }/** A new directory the sweep saw and did not count: a marked test fixture root, or a repository whose remote resolves locally. */-export interface Ignored { path: string; reason: 'fixture-marker' | 'local-remote'; remote?: string }+export interface Ignored { path: string; reason: 'fixture-marker' | 'local-remote' | 'build-output'; remote?: string }export type SweepVerdict = 'clean' | 'violation' | 'partial';export interface StageSweep {attempt: number;@@ -139,7 +139,7 @@ export function inventory(roots: readonly string[], checkout: string, skip: read}for (const d of list) {const p = path.join(dir, d.name);- if (d.isFile()) { if (ENGINE_DB.test(d.name) && dir.startsWith(engine)) continue; try { const s = fs.statSync(p); if (s.size >= BIG_BYTES) inv.big[p] = s.size; } catch { /* gone */ } continue; }+ if (d.isFile()) { if (ENGINE_DB.test(d.name) && dir.startsWith(engine)) continue; try { const s = fs.statSync(p); if (s.size >= BIG_BYTES) { if (buildOutput(home, p)) inv.ignored![p] = { reason: 'build-output' }; else inv.big[p] = s.size; } } catch { /* gone */ } continue; }if (d.isDirectory() && !SKIP.has(d.name) && depth < SWEEP_DEPTH) walk(p, depth + 1);}};@@ -148,6 +148,26 @@ export function inventory(roots: readonly string[], checkout: string, skip: read}function realOr(p: string): string { try { return fs.realpathSync(p); } catch { return path.resolve(p); } }++/** ELF, Mach-O (32, 64 and universal, either byte order) and PE headers: what a compiler or `bun build --compile` writes. */+const NATIVE_MAGIC = [[0x7f, 0x45, 0x4c, 0x46], [0xfe, 0xed, 0xfa, 0xce], [0xfe, 0xed, 0xfa, 0xcf], [0xce, 0xfa, 0xed, 0xfe], [0xcf, 0xfa, 0xed, 0xfe], [0xca, 0xfe, 0xba, 0xbe], [0x4d, 0x5a]];++/**+ * A big file the checkout's own build writes, not a fetch (GSTA-745: `bin/gstack-cso-core`, 110 MB, built while a stage ran):+ * a native executable inside the checkout at a path its committed, unmodified root `.gitignore` names exactly, with no glob.+ * Anything else, a download into an ignored directory or under a glob included, stays a fetch.+ */+function buildOutput(checkout: string, file: string): boolean {+ const rel = path.relative(checkout, file);+ if (!rel || rel.startsWith('..') || path.isAbsolute(rel)) return false;+ const git = (args: string[]) => spawnSync('git', ['-C', checkout, ...args], { encoding: 'utf8', timeout: 10_000 });+ if (git(['ls-files', '--error-unmatch', '--', '.gitignore']).status !== 0 || git(['diff', '--quiet', 'HEAD', '--', '.gitignore']).status !== 0) return false;+ const hit = /^\.gitignore:\d+:(.*)\t/.exec(git(['check-ignore', '--no-index', '-v', '--', rel.split(path.sep).join('/')]).stdout ?? '');+ if (!hit || hit[1]!.replace(/^\//, '') !== rel.split(path.sep).join('/')) return false;+ const head = Buffer.alloc(4);+ try { const fd = fs.openSync(file, 'r'); try { fs.readSync(fd, head, 0, 4, 0); } finally { fs.closeSync(fd); } } catch { return false; }+ return NATIVE_MAGIC.some(m => m.every((b, i) => head[i] === b));+}function du(p: string): number | null {const r = spawnSync('du', ['-sk', p], { encoding: 'utf8', timeout: 10_000 });const kb = Number(/^(\d+)/.exec(r.stdout ?? '')?.[1]);@@ -163,7 +183,7 @@ export function sweepDiff(start: Inventory, end: Inventory): Found[] {found.push({ path: p, kind: 'repo', remote, bytes: du(p) });}for (const [p, bytes] of Object.entries(end.big)) {- if (p in start.big || found.some(f => p.startsWith(f.path + path.sep))) continue;+ if (p in start.big || start.ignored?.[p]?.reason === 'build-output' || found.some(f => p.startsWith(f.path + path.sep))) continue;found.push({ path: p, kind: 'download', bytes });}return found;@@ -206,7 +226,7 @@ export function foundLines(stage: Stage, attempt: number, found: readonly Found[export function ignoredLines(stage: Stage, attempt: number, ignored: readonly Ignored[]): string[] {return ignored.map(i => {const remote = i.remote ? ` remote=${control(i.remote) ? JSON.stringify(i.remote) : i.remote}` : '';- const why = i.reason === 'fixture-marker' ? `a test fixture root carrying ${FIXTURE_MARKER}` : 'its remote resolves to a local path through url.<base>.insteadOf';+ const why = i.reason === 'fixture-marker' ? `a test fixture root carrying ${FIXTURE_MARKER}` : i.reason === 'build-output' ? 'a native executable the checkout\'s committed .gitignore names exactly, which its own build writes' : 'its remote resolves to a local path through url.<base>.insteadOf';return `FETCH_IGNORED: stage=${stage} attempt=${attempt} path=${shownPath(i.path)} reason=${i.reason}${remote} (${why}, so not a fetch; docs/review-policy.md#what-readers-may-fetch)`;});}diff --git a/lib/ship-policy.ts b/lib/ship-policy.tsindex e838323e1..59a8d9c22 100644--- a/lib/ship-policy.ts+++ b/lib/ship-policy.ts@@ -683,8 +683,8 @@ export function finish(rawText: string | null, source: PolicySource): LoadedPolilet raw: unknown;try { raw = JSON.parse(rawText); }catch (e: any) { return { policy: JSON.parse(JSON.stringify(DEFAULT_POLICY)), present: true, source, errors: [{ code: 'POLICY_INVALID', path: SHIP_POLICY_PATH, message: `not valid JSON: ${e.message}` }], warnings: [], values: {} }; }- const all = validatePolicy(raw), exclusion = /^review_(exclude_paths|content_patterns)(\[|$)/;- const rest = source.kind === 'base' && all.length && all.every(e => exclusion.test(e.path)) ? Object.fromEntries(Object.entries(raw as Record<string, unknown>).filter(([k]) => !exclusion.test(k))) : null;+ const all = validatePolicy(raw), exclusion = /^review_(exclude_paths|content_patterns)(\[|$)/, exclusionKey = /^review_(exclude_paths|content_patterns)$/;+ const rest = source.kind === 'base' && all.length && all.every(e => exclusion.test(e.path)) ? Object.fromEntries(Object.entries(raw as Record<string, unknown>).filter(([k]) => !exclusionKey.test(k))) : null;const errors = rest && !validatePolicy(rest).length ? [] : all, read = errors.length ? null : (rest ?? raw) as Record<string, unknown>, merged = mergePolicy(read, source.label);const warnings = raw && typeof raw === 'object' && !Array.isArray(raw) ? policyWarnings(raw as Record<string, unknown>) : [];return { policy: merged.policy, present: true, source, errors, warnings, values: merged.values, ...(rest && !errors.length ? { setAside: all } : {}) };diff --git a/lib/ship-receipt-prose.ts b/lib/ship-receipt-prose.tsindex 291c4bfc9..e9d6e6535 100644--- a/lib/ship-receipt-prose.ts+++ b/lib/ship-receipt-prose.ts@@ -12,6 +12,7 @@ import { docsExceptionLine, parseReceiptDocs } from './ship-receipt-docs';import { ruledNoteText, type RuledNote } from './ruled-notes';import { gateDispositionText, type GateDisposition } from './gate-dispositions';import { laneExceptionBodyLines } from './test-lane-exception';+import { VISIBLE_CHARS, VISIBLE_LINES, visibleOpening } from './pr-body-shape';export interface ProseClaim { field: string; prose: number; receipt: number }export interface ProseCheck { checked: number; mismatches: ProseClaim[] }@@ -60,6 +61,20 @@ function withoutFences(body: string): string {return out.join('');}+/**+ * The body without its opening, the lines above its first `<details>` fold (after closed fences are gone): R76 keeps that+ * part to what changed for a user, why and what to do, so a number there is the subject of the PR (`58 fixed with gstack`,+ * a published result), never one of its receipt counters. A body with no fold, or an opening longer than R76 allows+ * (VISIBLE_LINES lines, VISIBLE_CHARS characters, measured on the body before its fences collapse, as the PR body shape check measures it), is checked whole.+ */+function withoutOpening(body: string, unfenced: string): string {+ const lines = body.split(/(?<=\n)/);+ const fold = lines.findIndex(l => /^ {0,3}<details\b/i.test(l));+ if (fold <= 0) return body;+ const opening = visibleOpening(unfenced);+ return opening.length > VISIBLE_LINES || [...opening.join('\n')].length > VISIBLE_CHARS ? body : '(opening)\n' + lines.slice(fold).join('');+}+/*** The body without the `## Approvals` blocks gstack-approvals renders (lib/approval-record.ts renderRecord): the* heading, the Date | Asked | Exact words table and its `Source: gstack-approvals record for …` footer. Those rows@@ -120,7 +135,7 @@ function withoutExceptionLines(body: string, receipt: Record<string, unknown>):/*** Every `<name>=<n>`, `<name>: <n>` and `<n> <name>` in the prose (the body- * without its receipt block, its code fences, its rendered Approvals block and its exception lines), where `<name>` is a counter's leaf key with `_`+ * without its receipt block, its opening above the first fold, its code fences, its rendered Approvals block and its exception lines), where `<name>` is a counter's leaf key with `_`* matched as `_`, space or `-` and not part of a longer word (`3 pass-through`* is not a `pass` claim), compared with the receipt. A leaf key shared by* several counters (`pass` under every gate lane, `passed` under gate and ci)@@ -130,7 +145,8 @@ function withoutExceptionLines(body: string, receipt: Record<string, unknown>):* `<n> <name>` claim about the next key (#3513).*/export function checkReceiptProse(receipt: Record<string, unknown>, body: string): ProseCheck {- const prose = withoutExceptionLines(withoutApprovalsBlocks(withoutFences(body.replace(BLOCK_RE, ''))), receipt);+ const raw = body.replace(BLOCK_RE, '');+ const prose = withoutExceptionLines(withoutApprovalsBlocks(withoutOpening(withoutFences(raw), raw)), receipt);const byLeaf = new Map<string, Array<{ field: string; value: number }>>();for (const [field, value] of receiptCounters(receipt)) {const leaf = field.split('.').at(-1)!;diff --git a/test/review-exclude-base-fallback.test.ts b/test/review-exclude-base-fallback.test.tsindex 8bc44602b..5a61bc018 100644--- a/test/review-exclude-base-fallback.test.ts+++ b/test/review-exclude-base-fallback.test.ts@@ -91,6 +91,17 @@ describe('an invalid exclusion list on the base is set aside, never loosened (GSexpect('code' in q && q.code).toBe('POLICY_INVALID');}, 120_000);+ // Value: protects=only the two exclusion keys themselves are set aside: an unknown key that merely starts with one of their names+ // (review_exclude_paths[0]) is an error of its own and still refuses; fails_when=the key filter is unanchored and drops that key+ // with the list; seam=lib/ship-policy.ts finish; no_claim=the wording of the refusal+ test('an unknown key that starts with an exclusion key name still refuses', () => {+ const repo = repoWith({ review_exclude_paths: patterns(65), 'review_exclude_paths[0]': 'data/**' });+ const r = plan(repo);+ expect(r.status).toBe(EXIT.refused);+ expect(r.err).toContain('POLICY_INVALID');+ expect(r.out).not.toContain('REVIEW_EXCLUDE: fallback');+ }, 120_000);+// Value: protects=the merge step reads a base that fails only on its exclusion list, with its other keys, so the PR that fixes// the list can land; fails_when=gstack-ship-queue refuses POLICY_INVALID on it; seam=loadBasePolicy; no_claim=land's checkstest('the queue reads such a base with its other keys', () => {diff --git a/test/review-sweep.test.ts b/test/review-sweep.test.tsindex e846ab184..813453bf2 100644--- a/test/review-sweep.test.ts+++ b/test/review-sweep.test.ts@@ -110,6 +110,56 @@ describe('review-sweep inventory diff', () => {// Value: protects=a start walk that stopped at its bounds cannot tell a repository it never reached from a new one, so what the end walk finds past it is a note, never a quarantine;// fails_when=a partial start turns pre-existing repositories into FETCH_VIOLATION and FETCH_RERUN_SPENT on runs where nobody fetched; why_new=ship-c-p1 specialist-batched#1 (CRITICAL); seam=sweepResult; no_claim=that a partial sweep sees every fetch+ // Value: protects=a native executable the checkout's own build writes at a path its committed root .gitignore names exactly (bin/gstack-cso-core,+ // GSTA-745) is printed as FETCH_IGNORED build-output, not a download; fails_when=a stage that builds the repo stops /ship with FETCH_VIOLATION, or+ // the exemption lets through a download under an ignored directory or glob, a non-executable at that path, or a path a reader added to .gitignore;+ // seam=inventory; no_claim=which reader built it+ test('a native build output the committed .gitignore names exactly is ignored; every other new big file is still a download', async () => {+ const root = tmp();+ const checkout = path.join(root, 'checkout');+ repoAt(checkout, 'https://github.com/me/app.git');+ fs.writeFileSync(path.join(checkout, '.gitignore'), 'bin/gstack-cso-core\n/bin/gstack-cso-core.exe\ndist/\n*.tar\n');+ const env = { ...process.env, GIT_AUTHOR_NAME: 't', GIT_AUTHOR_EMAIL: '[email protected]', GIT_COMMITTER_NAME: 't', GIT_COMMITTER_EMAIL: '[email protected]' };+ expect(spawnSync('bash', ['-c', 'git add .gitignore && git commit -q -m base'], { cwd: checkout, encoding: 'utf8', env, timeout: 30_000 }).status).toBe(0);+ fs.mkdirSync(path.join(checkout, 'bin')); fs.mkdirSync(path.join(checkout, 'dist'));+ const start = inventory([root], checkout, []);+ await Bun.sleep(30);+ const big = (rel: string, head: number[]) => { const p = path.join(checkout, rel); fs.writeFileSync(p, Buffer.from(head)); fs.truncateSync(p, BIG_BYTES); return p; };+ const elf = [0x7f, 0x45, 0x4c, 0x46];+ const core = big('bin/gstack-cso-core', elf);+ const exe = big('bin/gstack-cso-core.exe', [0x4d, 0x5a, 0x90, 0x00]);+ const found = [big('dist/blob.bin', elf), big('bin/chats.tar', elf), big('bin/notes.txt', [0x68, 0x69, 0x0a, 0x0a])];+ const r = sweepResult(start, inventory([root], checkout, []));+ expect(r.found.map(f => f.path).sort()).toEqual([...found].sort());+ expect([...r.ignored!].sort((a, b) => a.path < b.path ? -1 : 1)).toEqual([{ path: core, reason: 'build-output' as const }, { path: exe, reason: 'build-output' as const }]);+ expect(ignoredLines('specialists', 1, r.ignored!)[0]).toContain('reason=build-output');+ fs.rmSync(core); fs.writeFileSync(core, 'not a binary\n'); fs.truncateSync(core, BIG_BYTES);+ fs.appendFileSync(path.join(checkout, '.gitignore'), 'bin/notes.txt\n');+ const later = sweepResult(start, inventory([root], checkout, []));+ expect(later.found.map(f => f.path).sort()).toEqual([...found, core, exe].sort());+ expect(later.ignored ?? []).toEqual([]);+ });++ // Value: protects=a build output already on disk when a stage starts is never counted, as on main where it sat in start.big;+ // fails_when=an uncommitted .gitignore edit or a git timeout at the end walk moves it from ignored to big and the stage is voided as FETCH_VIOLATION;+ // why_new=ship-4672 p1/red-team#1; seam=sweepDiff; no_claim=files the stage itself wrote+ test('a build output ignored at the start of a stage and big at its end is not a download', () => {+ const core = '/r/checkout/bin/gstack-cso-core';+ const start = { at: 1, roots: ['/r'], repos: {}, big: {}, ignored: { [core]: { reason: 'build-output' as const } } };+ const r = sweepResult(start, { at: 2, roots: ['/r'], repos: {}, big: { [core]: BIG_BYTES }, ignored: {} });+ expect([r.verdict, r.found]).toEqual(['clean', []]);+ });++ // Value: protects=only a build output is excused at its start path; fails_when=a fixture-marker or local-remote directory swapped for a big+ // download at the same path reads clean; why_new=ship-4672 p2/outside-voice#1; seam=sweepDiff; no_claim=a build output replaced in place+ test('an ignored directory swapped for a big file at the same path is still a download', () => {+ for (const reason of ['fixture-marker', 'local-remote'] as const) {+ const dir = '/r/fixtures/root';+ const r = sweepResult({ at: 1, roots: ['/r'], repos: {}, big: {}, ignored: { [dir]: { reason } } }, { at: 2, roots: ['/r'], repos: {}, big: { [dir]: BIG_BYTES }, ignored: {} });+ expect([r.verdict, r.found.map(f => f.path)]).toEqual(['violation', [dir]]);+ }+ });+test('a partial start inventory makes what the end walk finds a partial note, not a violation', () => {const root = tmp();const checkout = path.join(root, 'checkout');diff --git a/test/ship-issue-intent.test.ts b/test/ship-issue-intent.test.tsindex f4a5e95ac..86232277e 100644--- a/test/ship-issue-intent.test.ts+++ b/test/ship-issue-intent.test.ts@@ -32,6 +32,15 @@ describe('issue intent (pure)', () => {// meaning; fails_when=the bare-#N rule reads the numbers as this repository's issues (Refs lines and fix-#N prompts for issues that do not exist here), or// a closure, reference, filler or version word in the parentheses is taken for a repository name (the issue then vanishes from Refs and from the fix-#N// offer as a phantom cross-repo reference); why_new=the intent tests cover owner/repo#N as the only cross form; seam=none; no_claim=none beyond protects+ // Value: protects=/ship's Review-Finding trailer names a review ledger entry (p1/red-team#3) or a fingerprint, never an issue, so it adds no+ // Refs line to the PR body (#4371); fails_when=the cross-repo owner/repo#N rule reads the ledger id as an issue in repository p1/red-team;+ // seam=mentionsIn; no_claim=none beyond protects+ test('a Review-Finding trailer is not an issue reference; the rest of the message still is (#4371)', () => {+ const m = mentionsIn('fix: pre-landing review fixes (owner/other#9)\n\nReview-Finding: p1/red-team#3 reader=red-team\nreview-finding: p2/adversarial-native#3 reader=codex\nReview-Finding: lib/x.ts:10:correctness reader=core\n\nFixes #14\n');+ expect(m.map(x => [x.repo ? `${x.repo}#${x.issue}` : `#${x.issue}`, x.intent])).toEqual([['owner/other#9', 'refs'], ['#14', 'fixes']]);+ expect(renderIssueLines(resolveLinks(mentionsIn('fix\n\nReview-Finding: p1/red-team#3 reader=red-team\n'), [], () => true))).toEqual([]);+ });+test('a parenthesised named reference is a cross-repo reference, never a same-repo Refs or promotion candidate', () => {const named = mentionsIn('ship-queue: screen verdict from the run (gbrain #7625, #7606)\n\nPorts the fix from (gbrain PR #7630) and (acme/tools issue #4).\n');expect(named.map(x => [x.repo ?? '', x.issue, x.intent])).toEqual([['gbrain', 7625, 'refs'], ['gbrain', 7606, 'refs'], ['gbrain', 7630, 'refs'], ['acme/tools', 4, 'refs']]);@@ -99,6 +108,21 @@ describe('gstack-issue-links (bin)', () => {});+ // Value: protects=each reference line on stderr names the commit its mention came from; fails_when=entries after the first keep git log's+ // trailing newline, so the older commit's label reads `commit :` with an empty id (#4378); why_new=the CLI tests ran one commit, whose entry+ // has no leading newline; seam=none; no_claim=none beyond protects+ test('labels a mention in an older commit with that commit, not an empty id', () => {+ const repo = fixture();+ const older = commit(repo, { 'lib/util.js': "exports.add = (a, b) => a + b + 0;\n" }, 'tidy\n\nRefs #11\n').slice(0, 12);+ const newer = commit(repo, { 'lib/util.js': "exports.add = (a, b) => a + b + 1;\n" }, 'tidy again\n\nRefs #12\n').slice(0, 12);+ const env = ghShim(repo, { issues: { '11': { title: 't', body: 'b', comments: [] }, '12': { title: 'u', body: 'c', comments: [] } } });+ const r = runBin(repo, 'gstack-issue-links', ['--base', 'main'], env);+ expect(r.status).toBe(EXIT.ok);+ expect(r.err).toContain(`reference #11 ← commit ${older}: Refs #11`);+ expect(r.err).toContain(`reference #12 ← commit ${newer}: Refs #12`);+ expect(r.err).not.toContain('commit :');+ });+test('a named-reference list in a commit is cross-repo, and Fixes owner/repo#N for this repository closes it (GST-2967)', () => {const repo = fixture();commit(repo, { 'lib/util.js': "exports.add = (a, b) => a + b + 0;\n" }, 'docs audit: stop halting on prose (founderstar #837, harness-evals #393)\n\nFixes owner/repo#14\n');diff --git a/test/ship-receipt-prose.test.ts b/test/ship-receipt-prose.test.tsindex f088ead4b..cd1727b5a 100644--- a/test/ship-receipt-prose.test.ts+++ b/test/ship-receipt-prose.test.ts@@ -75,6 +75,45 @@ describe('checkReceiptProse', () => {// GST-412: the `## Approvals` block gstack-approvals renders quotes the owner's words, which can hold// numbers (`one Step 11 pass` read as a gate `pass` claim of 11). Only that rendered block is skipped.+describe('the opening above the first fold is not prose', () => {+ // Value: protects=a result the PR is about, quoted in its plain opening (58 fixed with gstack), is not read as review_loop.fixed;+ // fails_when=check-prose reports RECEIPT_PROSE_MISMATCH review_loop.fixed body=58 on a correct receipt (GSTA-687, #4598);+ // seam=checkReceiptProse; no_claim=numbers inside a fold, which stay claims+ test('numbers above the first fold are skipped; claims inside the folds and in a body with no fold are still checked', () => {+ const opening = 'gstack shows no gain in bug fixes: 58 fixed with gstack, 61 of 99 without.\nWhy: the old page claimed a gain.\n\n';+ const folded = opening + '<details><summary>Pre-Landing Review</summary>\n\nReview: 2 passes, 1 fixed.\n</details>\n';+ expect(checkReceiptProse(receipt, folded)).toEqual({ checked: 2, mismatches: [] });+ expect(checkReceiptProse(receipt, opening + '<details><summary>Notes</summary>\n\n58 fixed with gstack.\n</details>\n').mismatches).toEqual([{ field: 'review_loop.fixed', prose: 58, receipt: 1 }]);+ expect(checkReceiptProse(receipt, opening).mismatches).toEqual([{ field: 'review_loop.fixed', prose: 58, receipt: 1 }]);+ expect(checkReceiptProse(receipt, '```\n<details>\n```\n' + opening + '<details><summary>x</summary>\n</details>\n').mismatches).toEqual([{ field: 'review_loop.fixed', prose: 58, receipt: 1 }]);+ });++ // Value: protects=only an opening R76 allows (3 lines, 600 characters) is skipped; fails_when=a body that leaves its review section+ // unfolded above a late fold hides every receipt counter claim from the check; why_new=ship-4672 p1/specialist-batched#1; seam=checkReceiptProse+ test('an opening longer than R76 allows is still checked', () => {+ const long = 'What changed.\n\n## Pre-Landing Review\nReview: 2 passes, 9 fixed.\nmore\n<details><summary>Agent notes</summary>\n</details>\n';+ expect(checkReceiptProse(receipt, long).mismatches).toEqual([{ field: 'review_loop.fixed', prose: 9, receipt: 1 }]);+ expect(checkReceiptProse(receipt, 'x'.repeat(601) + '\n9 fixed.\n<details><summary>n</summary>\n</details>\n').mismatches).toEqual([{ field: 'review_loop.fixed', prose: 9, receipt: 1 }]);+ });++ // Value: protects=the opening is measured as the PR body shape check measures it (comments and the Agent notes marker do not count);+ // fails_when=a 3-line opening followed by the marker or a comment line is checked whole and its subject number refuses the receipt;+ // why_new=ship-4672 p2/red-team#1; seam=checkReceiptProse; no_claim=bodies the shape check refuses+ test('a 3-line opening followed by the Agent notes marker or a comment is still skipped', () => {+ const opening = 'gstack shows no gain: 58 fixed with gstack.\nWhy: the old page claimed a gain.\nNothing to do.\n';+ const notes = '<details><summary>Agent notes</summary>\n\nReview: 2 passes, 1 fixed.\n</details>\n';+ expect(checkReceiptProse(receipt, opening + '<!-- gstack:agent-notes -->\n' + notes).mismatches).toEqual([]);+ expect(checkReceiptProse(receipt, opening + '<!-- a note -->\n' + notes).mismatches).toEqual([]);+ });++ // Value: protects=a code block in the opening counts at its full length, as the shape check counts it; fails_when=an opening over R76 because of+ // a fence collapses to one line and hides its counter claims; why_new=ship-4672 p2/outside-voice#2; seam=checkReceiptProse+ test('an opening over R76 because of a code block is still checked', () => {+ const body = 'What changed.\n```\na\nb\nc\n```\n9 fixed.\n<details><summary>n</summary>\n</details>\n';+ expect(checkReceiptProse(receipt, body).mismatches).toEqual([{ field: 'review_loop.fixed', prose: 9, receipt: 1 }]);+ });+});+describe('the rendered Approvals block is not prose', () => {const lanes = { ...receipt, gate: { unit: { pass: 1181, fail: 0, skip: 3 } } };const row = (words: string): ApprovalRow => ({diff --git a/test/telemetry.test.ts b/test/telemetry.test.tsindex fa7fbef17..4d37838f2 100644--- a/test/telemetry.test.ts+++ b/test/telemetry.test.ts@@ -411,6 +411,20 @@ describe('.pending marker', () => {expect(parseJsonl().map(e => e.outcome)).toEqual(['chromium-install', 'deps-missing']);});+ test('a run still on yesterday\'s date never deletes today\'s marker, so a later run today sends nothing (#4597)', () => {+ setConfig('telemetry', 'community');+ fs.writeFileSync(path.join(tmpDir, 'bin', 'date'), '#!/bin/sh\nif [ "$*" = "-u +%Y-%m-%d" ] && [ -n "$FAKE_DAY" ]; then echo "$FAKE_DAY"; else PATH=/usr/bin:/bin exec date "$@"; fi\n', { mode: 0o755 });+ const one = `${BIN}/gstack-telemetry-log --event-type onboarding --skill _setup_playwright --outcome chromium-install --no-sweep`;+ run(one, { FAKE_DAY: '2026-11-22' });+ run(one, { FAKE_DAY: '2026-11-21' });+ run(one, { FAKE_DAY: '2026-11-22' });+ expect(parseJsonl().map(e => e.outcome)).toEqual(['chromium-install', 'chromium-install']);+ const markers = fs.readdirSync(path.join(tmpDir, 'analytics')).filter(f => f.startsWith('.onboarding-')).sort();+ expect(markers).toEqual(['.onboarding-_setup_playwright--chromium-install-2026-11-21', '.onboarding-_setup_playwright--chromium-install-2026-11-22']);+ run(one, { FAKE_DAY: '2026-11-23' });+ expect(fs.readdirSync(path.join(tmpDir, 'analytics')).filter(f => f.startsWith('.onboarding-'))).toEqual(['.onboarding-_setup_playwright--chromium-install-2026-11-23']);+ });+test('concurrent setup runs record an onboarding step once', () => {setConfig('telemetry', 'community');const one = `${BIN}/gstack-telemetry-log --event-type onboarding --skill _setup_playwright --outcome chromium-install --no-sweep`;