From eff19e267854c8fba5a254d8c6d419d9335e9e59 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Mon, 2 Nov 2026 05:07:54 -0800 Subject: [PATCH 01/19] v1.92.78.0 test: seven flaky-test repairs and six failure diagnostics from the 2026-11-01 flaky pass (GSTA-240) (#3804) * test: eight flaky-test repairs and five failure diagnostics from the 2026-11-01 flaky pass (GSTA-240) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(free-shards): keep failing a shard on an unseen browser child, and name it and whether it exited (review finding) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * changelog: pregate-regate copies through gitFixtureTemplate after the main merge Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --------- Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- CHANGELOG.md | 17 +++++++++ VERSION | 2 +- agents-digest/gstack-AGENTS.md | 2 +- bin/gstack-codex-probe | 4 +- bin/gstack-evidence | 2 +- package.json | 2 +- scripts/lib/free-home-guard.ts | 9 +++-- scripts/test-free-shards.ts | 2 + test/auq-parallel.test.ts | 3 +- test/autoplan-publication-guard.test.ts | 4 +- test/bootstrap-retention-shard.test.ts | 2 +- test/codex-probe-cache.test.ts | 25 ++++++++++++ test/evidence.test.ts | 8 ++++ test/free-home-guard.test.ts | 28 ++++++++++++++ test/gstack-design-detect.test.ts | 7 +++- test/office-hours-attempt.test.ts | 3 +- test/pregate-regate.test.ts | 51 +++++++++++++++++++++---- test/session-update-autostash.test.ts | 3 +- test/shard-engine.test.ts | 5 ++- test/ship-budget.test.ts | 2 +- test/ship-queue-train.test.ts | 7 +++- 21 files changed, 162 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf0437f2c..517e1d270 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,22 @@ # Changelog +## [1.92.78.0] - 2026-11-02 + +**Seven flaky tests from the 2026-11-01 flaky pass stop failing correct runs, and six more now name their cause when they fail.** One product lock broke a fresh lock it had misjudged as abandoned, a /ship lane tripped the free runner's home check with its own log, and the rest were fixtures that raced their own setup, leaned on wall-clock sleeps or read the caller's state root. + +### Fixed +- **`bin/gstack-codex-probe`**: a waiter that cannot read an owner-less lock's age (the holder removed it in that instant, or `stat -f` printed filesystem text on Linux) now treats the lock as fresh instead of abandoned, so it no longer deletes a live owner's lock on a misread age and the probe no longer ends `MODEL_PROBE_INCONCLUSIVE` (Free Tests 41216564482, 41235671867, 41263831361). A stat stub for both race windows fails without the fix; 64 stress runs went from 2 failures to 0. +- **`scripts/lib/free-home-guard.ts`, `bin/gstack-evidence`**: `gstack-evidence run` names its own lane log in `GSTACK_EVIDENCE_LOG`, and the real-home tripwire ignores exactly that file, so a /ship lane no longer trips over its own output. A foreign write under the home's `~/.gstack` still fails. +- **`test/autoplan-publication-guard.test.ts`**: the render-root cases clear the state-root variables they don't name, so a `GSTACK_STATE_ROOT` exported by the gstack launch file no longer picks the root. Three cases failed every time under that variable, and the lookalike controls passed for the wrong reason. +- **`test/gstack-design-detect.test.ts`**: the directory scan proves one batch by counting engine calls instead of sleeping near the 1,500 ms detect timeout (macOS job 124813933194). The product timeout is unchanged. +- **`test/pregate-regate.test.ts`**: the two fixtures are built once and copied per test through the `gitFixtureTemplate` helper from #3586, so 8 builds become 2. +- **`test/ship-queue-train.test.ts`**: the planted seam has its own name, so the fixture's own background `git maintenance` lock no longer collides with it (EEXIST, Free Tests 41288253305, 41288417894), and the test now holds a real `maintenance.lock` beside it. +- **`test/ship-budget.test.ts`**: the fake child writes its args to a temporary file and renames it, so the poll never reads an empty file (Free Tests 41242243205). + +### Changed +- `scripts/test-free-shards.ts` names the recorded browser child it never saw in the daemon's process tree, and whether it was still alive, when it fails a shard for unconfirmed ownership (Free Tests 41264845860 shard 7). The shard still fails. +- `test/bootstrap-retention-shard.test.ts`, `test/office-hours-attempt.test.ts`, `test/session-update-autostash.test.ts`, `test/shard-engine.test.ts` and `test/auq-parallel.test.ts` print the process state, exit status or cleanup events behind their assertion, so the next red names its cause. + ## [1.92.77.0] - 2026-11-02 **The weekly marathon evals can run /design-motion again: the CI eval image now ships ffmpeg (#3687).** The `design-motion-showcase` case joined the marathon tier on 2026-10-26, and its first scheduled run (Actions run 41200316994, main @ 088bfc5) failed 0/3. Every trial built and captured the page, then stopped at `FFMPEG_MISSING`, because the image had no ffmpeg and the skill rightly refuses to export before its checks run. The model did nothing wrong; the case could not pass on that image. diff --git a/VERSION b/VERSION index 463685b58..66231b754 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.92.77.0 +1.92.78.0 diff --git a/agents-digest/gstack-AGENTS.md b/agents-digest/gstack-AGENTS.md index ac6c1e65e..9f27e6a29 100644 --- a/agents-digest/gstack-AGENTS.md +++ b/agents-digest/gstack-AGENTS.md @@ -1,4 +1,4 @@ -# gstack digest v1.92.77.0 — regenerate/re-copy after upgrading gstack +# gstack digest v1.92.78.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/bin/gstack-codex-probe b/bin/gstack-codex-probe index 0292e5674..981ae1499 100755 --- a/bin/gstack-codex-probe +++ b/bin/gstack-codex-probe @@ -662,8 +662,8 @@ _gstack_codex_lock_acquire() { if [ "$_ohost" = "$_host" ] && ! kill -0 "$_pid" 2>/dev/null; then _dead=1; fi [ $((_now - _ts)) -ge "$_stale" ] && _dead=1 else - _ts=$(stat -c %Y "$_dir" 2>/dev/null || stat -f %m "$_dir" 2>/dev/null || echo 0) - case "$_ts" in ''|*[!0-9]*) _ts=0 ;; esac + _ts=$(stat -c %Y "$_dir" 2>/dev/null || stat -f %m "$_dir" 2>/dev/null || echo "$_now") + case "$_ts" in ''|*[!0-9]*) _ts="$_now" ;; esac [ $((_now - _ts)) -ge 5 ] && _dead=1 fi [ "$_dead" -eq 1 ] && _gstack_codex_lock_break "$_dir" "$_owner" diff --git a/bin/gstack-evidence b/bin/gstack-evidence index 59f8bbe30..35ca01d7b 100755 --- a/bin/gstack-evidence +++ b/bin/gstack-evidence @@ -400,7 +400,7 @@ async function cmdRun(argv: string[]): Promise { try { if (shell && !shell.ok) throw new Error(shell.error); const spawnArgv = shell?.ok ? [shell.cmd, ...shell.argv] : cmdArgv; - proc = Bun.spawn(spawnArgv, { stdin: "inherit", stdout: "pipe", stderr: "pipe" }); + proc = Bun.spawn(spawnArgv, { stdin: "inherit", stdout: "pipe", stderr: "pipe", env: log ? { ...process.env, GSTACK_EVIDENCE_LOG: log.path } : process.env }); } catch (e: any) { // Spawn failure (ENOENT on argv-direct form): record exit 127, propagate 127. exitCode = 127; diff --git a/package.json b/package.json index 8d40c09f7..bce0fb11b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gstack", - "version": "1.92.77", + "version": "1.92.78", "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/scripts/lib/free-home-guard.ts b/scripts/lib/free-home-guard.ts index 69b4bfd17..fb07555d3 100644 --- a/scripts/lib/free-home-guard.ts +++ b/scripts/lib/free-home-guard.ts @@ -5,8 +5,10 @@ * the real home before and after each free shard, and names the shard's files * when one of those entries changed. It watches only these surfaces; it is not * a universal write-containment check. Live agent-session logs that a - * concurrently running host keeps writing are excluded, and directory mtimes - * are ignored, so only file, link and directory-set changes count. + * concurrently running host keeps writing are excluded, as is the one lane log + * `gstack-evidence run` tees this run's own output into (its exact path, from + * GSTACK_EVIDENCE_LOG). Directory mtimes are ignored, so only file, link and + * directory-set changes count. * * A shard that runs alone owns its window, so its guard names its files. * Concurrent shards share one HOME and cannot tell whose write a change was, so @@ -104,6 +106,7 @@ export type FreeHomeGuardFactory = (files: string[], env: NodeJS.ProcessEnv, sta /** Take the baseline now; verify() returns null or the failure to report. */ export function guardFreeHome(files: string[], env: NodeJS.ProcessEnv = process.env, scope: FreeHomeScope = { kind: 'shard' }): FreeHomeGuard { const home = freeHomeDir(env); + const ownLog = env.GSTACK_EVIDENCE_LOG && path.isAbsolute(env.GSTACK_EVIDENCE_LOG) ? path.relative(home, env.GSTACK_EVIDENCE_LOG) : null; const unreadable = (error: unknown) => `real home surfaces could not be snapshotted (${(error as NodeJS.ErrnoException).code ?? 'error'}); shard files: ${files.join(', ')}`; let before: FreeHomeSnapshot | undefined; let baselineError: string | undefined; @@ -112,7 +115,7 @@ export function guardFreeHome(files: string[], env: NodeJS.ProcessEnv = process. verify() { if (!before) return baselineError!; try { - const changed = diffFreeHome(before, snapshotFreeHome(home)); + const changed = diffFreeHome(before, snapshotFreeHome(home)).filter(entry => entry !== ownLog); return changed.length ? formatFreeHomeChange(changed, files, scope) : null; } catch (error) { return unreadable(error); } }, diff --git a/scripts/test-free-shards.ts b/scripts/test-free-shards.ts index d61ca6112..b4012a60a 100755 --- a/scripts/test-free-shards.ts +++ b/scripts/test-free-shards.ts @@ -1370,6 +1370,8 @@ function trackShardBrowser(stateDir: string, env: NodeJS.ProcessEnv) { check(operation); if (!Number.isSafeInteger(pid) || (pid as number) <= 1) throw new BrowserCleanupError('invalid browser child identity'); const identity = identities.get(pid as number); + if (!identity && identities.get(daemon as number)?.root) throw new BrowserCleanupError( + `browser child ownership is unconfirmed: recorded pid ${pid} (${await inspect(operation, pid as number) ? 'alive' : 'exited'}) was never seen in daemon ${daemon}'s process tree`); if (!identity || identity.daemon !== daemon || identity.root) throw new BrowserCleanupError('browser child ownership is unconfirmed'); if (await live(operation, identity) && (typeof start !== 'string' || !start || await nativeStart(operation, identity) !== start.replace(/\s+/g, ' '))) throw new BrowserCleanupError('browser child identity was replaced'); diff --git a/test/auq-parallel.test.ts b/test/auq-parallel.test.ts index d7296a5b1..5a6facc94 100644 --- a/test/auq-parallel.test.ts +++ b/test/auq-parallel.test.ts @@ -111,7 +111,8 @@ test.each([ expect(facts.receipts.filter((receipt: any) => receipt.outcome === 'timeout')).toHaveLength(3 - scenario.passed); expect(facts.receipts.every((receipt: any) => receipt.timeoutMs === 240_000 && !receipt.answered)).toBe(true); expect(facts.active).toBe(0); expect(facts.answers).toBe(0); expect(facts.pendingTimers).toBe(0); - expect(facts.leftovers).toEqual([]); expect(facts.ownedStateLeftovers).toEqual([]); + expect(facts.leftovers).toEqual([]); + expect(facts.ownedStateLeftovers, JSON.stringify({ fixtures: facts.fixtures, inputs: facts.inputs.map((input: any) => [input.id, input.config, input.state]), events: facts.events.filter((event: any) => ['query-close', 'capture-settle', 'cleanup'].includes(event.kind)) })).toEqual([]); expect(facts.events.filter((event: any) => event.kind === 'query-close')).toHaveLength(scenario.queries); expect(facts.events.filter((event: any) => event.kind === 'cleanup')).toHaveLength(3); }, 20_000); diff --git a/test/autoplan-publication-guard.test.ts b/test/autoplan-publication-guard.test.ts index 44a375db4..d39a6baa2 100644 --- a/test/autoplan-publication-guard.test.ts +++ b/test/autoplan-publication-guard.test.ts @@ -1326,7 +1326,9 @@ describe('Autoplan phase entry through the gbrain :user render (#2569)', () => { edit(rewriteSectionBase(fs.readFileSync(path.join(ROOT, 'autoplan/sections', name), 'utf8'), linkRoot))); return root; } - function withEnv(env: Record, work: () => T): T { + /** The state-root chain the case does not name is cleared, so an ambient GSTACK_STATE_ROOT (every gstack launch file exports one) cannot pick the root. */ + function withEnv(given: Record, work: () => T): T { + const env = { GSTACK_STATE_ROOT: undefined, GSTACK_STATE_DIR: undefined, CLAUDE_PLUGIN_DATA: undefined, ...given }; const previous = Object.fromEntries(Object.keys(env).map(k => [k, process.env[k]])); for (const [k, v] of Object.entries(env)) if (v === undefined) delete process.env[k]; else process.env[k] = v; try { return work(); } diff --git a/test/bootstrap-retention-shard.test.ts b/test/bootstrap-retention-shard.test.ts index cbeac1275..2b120bd4e 100644 --- a/test/bootstrap-retention-shard.test.ts +++ b/test/bootstrap-retention-shard.test.ts @@ -62,7 +62,7 @@ describe.skipIf(process.platform !== 'linux')('bootstrap paid-shard cleanup inte fs.writeFileSync(path.join(root, 'controller.stdout.log'), controller.stdout ?? '', { mode: 0o600 }); fs.writeFileSync(path.join(root, 'controller.stderr.log'), controller.stderr ?? '', { mode: 0o600 }); expect(controller.error).toBeUndefined(); - expect(controller.status).toBe(0); + expect(controller.status, `controller exited ${controller.status} (signal ${controller.signal}); stderr tail: ${(controller.stderr ?? '').slice(-600).replace(/\s*\n\s*/g, ' | ')}`).toBe(0); const outcome = JSON.parse(fs.readFileSync(outcomePath, 'utf8')); if (scenario === 'ack-failure') { expect(controller.stdout).toContain('(fail) qa-bootstrap'); diff --git a/test/codex-probe-cache.test.ts b/test/codex-probe-cache.test.ts index 002fdb921..981fde6dd 100644 --- a/test/codex-probe-cache.test.ts +++ b/test/codex-probe-cache.test.ts @@ -247,6 +247,31 @@ describe('probe lock recovery and failure', () => { expect(calls(f)).toBe(1); })); + test('a lock released while a waiter reads its age is not abandoned; the next owner\'s fresh lock survives', withFixture((f) => { + const sig = sigOf(f); + const lock = path.join(f.locks, sig); + const once = path.join(f.home, 'vanish-once'); + const real = JSON.stringify(Bun.which('stat')); + fs.mkdirSync(lock, { recursive: true }); + fs.writeFileSync(path.join(f.home, 'bin/stat'), `#!/usr/bin/env bash +if [ "$3" = "$RACE_LOCK" ] && [ -f "$RACE_ONCE" ]; then + case "$1" in + -c) rmdir "$RACE_LOCK"; [ "$RACE_PHASE" = early ] && mkdir "$RACE_LOCK"; exit 1 ;; + -f) ${real} "$@"; rc=$?; rm -f "$RACE_ONCE"; [ -d "$RACE_LOCK" ] || mkdir "$RACE_LOCK"; exit "$rc" ;; + esac +fi +exec ${real} "$@" +`, { mode: 0o755 }); + for (const phase of ['early', 'late']) { + fs.writeFileSync(once, 'armed'); + const r = probe(f, { _GSTACK_CODEX_LOCK_WAIT: '1', RACE_LOCK: lock, RACE_ONCE: once, RACE_PHASE: phase }); + expect(fs.existsSync(once)).toBe(false); + expect(r.stdout).toContain('MODEL_PROBE_INCONCLUSIVE (another probe of this model still holds its lock)'); + expect(fs.existsSync(lock)).toBe(true); + expect(calls(f)).toBe(0); + } + })); + test('an unreadable cache or uncreatable lock is unverified and launches no paid probe', withFixture((f) => { fs.mkdirSync(f.cache); const dir = probe(f); diff --git a/test/evidence.test.ts b/test/evidence.test.ts index e40d6769c..0617ef8ed 100644 --- a/test/evidence.test.ts +++ b/test/evidence.test.ts @@ -74,6 +74,14 @@ describe('gstack-evidence run', () => { expect(fs.readFileSync(rec.log_path, 'utf-8')).toContain('ok'); }); + test('the lane command sees its own log path as GSTACK_EVIDENCE_LOG (the free runner\'s home tripwire excludes exactly that file)', () => { + const r = run(['run', '--label', 'focused', '--', 'printf "%s" "$GSTACK_EVIDENCE_LOG"']); + expect(r.status).toBe(0); + const rec = records().pop(); + expect(path.isAbsolute(rec.log_path)).toBe(true); + expect(r.stdout).toBe(rec.log_path); + }); + test('propagates a failing exit code and records it', () => { const r = run(['run', '--label', 'tests', '--', 'exit 3']); expect(r.status).toBe(3); diff --git a/test/free-home-guard.test.ts b/test/free-home-guard.test.ts index d01c8c979..4f387b5bd 100644 --- a/test/free-home-guard.test.ts +++ b/test/free-home-guard.test.ts @@ -78,6 +78,34 @@ describe('free-suite home-write tripwire (#2895)', () => { expect(failure).toContain('only'); }); + test.skipIf(process.platform === 'win32')('the wrapping gstack-evidence lane log is excluded by its exact path; a foreign write beside it still trips', async () => { + const home = fakeHome(); + const logs = path.join(home, '.gstack/projects/p/logs'); + fs.mkdirSync(logs, { recursive: true }); + const laneLog = path.join(logs, 'focused.log'); + fs.writeFileSync(laneLog, 'lane start\n'); + const unexcluded = guardFreeHome(['test/a.test.ts'], { HOME: home }); + const options = (script: string, name: string) => ({ env: { ...process.env, HOME: home, GSTACK_EVIDENCE_LOG: laneLog }, quiet: true, log: () => {}, + logFilePath: path.join(home, `${name}.log`), + commandFor: () => ({ command: process.execPath, args: ['-e', `${script}console.log('Ran 1 tests across 1 files. [1.00ms]')`] }) }); + const grow = `require('fs').appendFileSync(${JSON.stringify(laneLog)}, 'lane output\\n');`; + const errors: string[] = []; + const spy = spyOn(console, 'error').mockImplementation((...args: unknown[]) => { errors.push(args.join(' ')); }); + try { + expect((await runFreeShard(['test/a.test.ts'], 1, 1, options(grow, 'lane'))).status).toBe('passed'); + expect(unexcluded.verify()).toContain('~/.gstack/projects/p/logs/focused.log'); + const foreign = `${grow}require('fs').writeFileSync(${JSON.stringify(path.join(logs, 'other.log'))}, 'x');`; + expect((await runFreeShard(['test/a.test.ts'], 1, 1, options(foreign, 'foreign'))).status).toBe('failed'); + expect(errors.join('\n')).toContain('~/.gstack/projects/p/logs/other.log'); + expect(errors.join('\n')).not.toContain('focused.log'); + } finally { + spy.mockRestore(); + for (const retained of errors.flatMap(line => /retained (\S+)$/.exec(line)?.[1] ?? [])) { + if (/^gstack-free-shard-/.test(path.basename(retained))) fs.rmSync(retained, { recursive: true, force: true }); + } + } + }); + test('a concurrent phase guard names no shard and points at attribution', () => { const home = fakeHome(); const guard = guardFreeHome(['test/a.test.ts', 'test/b.test.ts'], { HOME: home }, { kind: 'concurrent', shards: 3 }); diff --git a/test/gstack-design-detect.test.ts b/test/gstack-design-detect.test.ts index 6349ec7d9..39388ac41 100644 --- a/test/gstack-design-detect.test.ts +++ b/test/gstack-design-detect.test.ts @@ -1460,8 +1460,13 @@ describe('scan: option-like bases and page-controlled inline ignores', () => { fs.mkdirSync(many, { recursive: true }); for (let i = 0; i < 1100; i++) fs.writeFileSync(path.join(many, `f${i}.css`), 'a{}'); try { - const r = run(['scan', '--format', 'gstack', 'src/many'], { env: { IMPECCABLE_BIN: FAKE, IMPECCABLE_FAKE_SLEEP_MS: '1000', GSTACK_DESIGN_DETECT_TIMEOUT_MS: '1500' } }); + const log = path.join(SANDBOX, 'argv-many.log'); + fs.rmSync(log, { force: true }); + const r = run(['scan', '--format', 'gstack', 'src/many'], { env: { IMPECCABLE_BIN: FAKE, IMPECCABLE_FAKE_LOG: log } }); expect(r.code).toBe(2); // a directory target is one batch (the fake reports findings): the budget test needs files + const calls = fs.readFileSync(log, 'utf-8').trim().split('\n').map(l => JSON.parse(l).argv as string[]); + expect(calls).toHaveLength(1); + expect(calls[0].some(x => x.endsWith(path.join('src', 'many')))).toBe(true); const files = fs.readdirSync(many).map(f => path.join('src', 'many', f)); const r2 = run(['scan', '--format', 'gstack', ...files], { env: { IMPECCABLE_BIN: FAKE, IMPECCABLE_FAKE_SLEEP_MS: '1000', GSTACK_DESIGN_DETECT_TIMEOUT_MS: '1500' } }); expect(r2.err).toMatch(/DETECT_TIMEOUT: whole-scan budget 7500ms exceeded, \d+ of 11 batches not run/); diff --git a/test/office-hours-attempt.test.ts b/test/office-hours-attempt.test.ts index c36da4486..c96bc8889 100644 --- a/test/office-hours-attempt.test.ts +++ b/test/office-hours-attempt.test.ts @@ -312,7 +312,8 @@ describe('Office Hours real session runner with fake processes', () => { expect(captured.output).toBe('captured output'); const diagnostic = JSON.parse(fs.readFileSync(path.join(dir, '.gstack/test-transcripts/drain-failure.json'), 'utf8')); expect(diagnostic.stderr).toContain('fixture auth failure'); - expect(running(Number(fs.readFileSync(path.join(dir, 'child.pid'), 'utf8')))).toBe(false); + const child = fs.readFileSync(path.join(dir, 'child.pid'), 'utf8').trim(); + expect(running(Number(child)), `held-pipe child after the runner returned (group ${fs.readFileSync(path.join(dir, 'parent.pid'), 'utf8').trim()}): ${spawnSync('ps', ['-o', 'pid=,ppid=,pgid=,stat=,etime=', '-p', child], { encoding: 'utf8', timeout: 5_000 }).stdout.trim() || 'gone now'}`).toBe(false); }); }, 10_000); } diff --git a/test/pregate-regate.test.ts b/test/pregate-regate.test.ts index 2e31a4c5f..09f01a004 100644 --- a/test/pregate-regate.test.ts +++ b/test/pregate-regate.test.ts @@ -6,11 +6,12 @@ * the base branch and every other open PR, and a lookup that cannot finish is * `unknown`, which withholds `REGATE: not-needed`. */ -import { afterEach, describe, expect, test } from 'bun:test'; +import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test'; import * as fs from 'node:fs'; import * as path from 'node:path'; import { EXIT } from '../lib/headless-artifacts'; -import { BASE_POLICY, cleanup, makeFixtureRepo, makePr, recordAndBundle, restamp, runBin, type FixtureRepo } from './helpers/restamp-fixture'; +import { gitFixtureTemplate, rebindFile, rebindGitDir, type GitFixtureTemplate } from './helpers/git-fixture-template'; +import { BASE_POLICY, cleanup, fixtureRepoAt, makePr, recordAndBundle, restamp, runBin, seedFixtureRepo, type FixtureRepo } from './helpers/restamp-fixture'; const repos: FixtureRepo[] = []; afterEach(() => { while (repos.length) cleanup(repos.pop()!); }); @@ -39,10 +40,14 @@ console.error("gh shim: unsupported "+a.join(" ")); process.exit(1)' "${file}" " } const ghCalls = (repo: FixtureRepo) => fs.readFileSync(path.join(repo.root, 'gh-regate', 'calls.log'), 'utf8'); +type Lanes = Array<{ label: string; command: string }>; +const TESTS_LANE: Lanes = [{ label: 'tests', command: 'true' }]; +const DIGEST_LANES: Lanes = [...TESTS_LANE, { label: 'digest', command: 'cat generated/digest.md' }]; + /** pr-a adds migration v240, is stamped 1.2.4.0 and gated (lanes recorded and bundled); then restamped to 1.2.5.0. */ -function gatedThenRestamped(lanes: Array<{ label: string; command: string }> = [{ label: 'tests', command: 'true' }]) { - const repo = makeFixtureRepo({ prefix: 'pregate-regate-', policy: POLICY }); - repos.push(repo); +function buildGated(root: string, lanes: Lanes) { + seedFixtureRepo(root, { policy: POLICY }); + const repo = fixtureRepoAt(root); makePr(repo, 'pr-a', { expects: '1.2.4.0' }); fs.mkdirSync(path.join(repo.work, 'migrations'), { recursive: true }); fs.writeFileSync(path.join(repo.work, 'migrations', 'v240-add-index.sql'), 'create index a;\n'); @@ -54,7 +59,39 @@ function gatedThenRestamped(lanes: Array<{ label: string; command: string }> = [ const head = repo.git('rev-parse', 'HEAD'); expect(restamp(repo, ['--version', '1.2.5.0']).status).toBe(EXIT.ok); repo.git('commit', '-qam', 'stamp 1.2.5.0'); - return { repo, head, bundle, current: repo.git('rev-parse', 'HEAD') }; + return { head, current: repo.git('rev-parse', 'HEAD') }; +} + +// Each fixture costs four gstack bin runs (two restamps, an evidence run and a bundle); build each lane set once +// and give every test its own copy instead of rebuilding it per test. +const templates = new Map>>(); +beforeAll(() => { + for (const lanes of [TESTS_LANE, DIGEST_LANES]) { + const template = gitFixtureTemplate({ + prefix: 'pregate-regate-', + build: root => buildGated(root, lanes), + rebind: (copy, tpl) => { + rebindGitDir(path.join(copy, 'work', '.git'), tpl, copy); + rebindFile(path.join(copy, 'bundle.json'), tpl, copy); + const projects = path.join(copy, 'home', 'projects'); + for (const slug of fs.existsSync(projects) ? fs.readdirSync(projects) : []) { + const dir = path.join(projects, slug.split(path.basename(tpl)).join(path.basename(copy))); + if (dir !== path.join(projects, slug)) fs.renameSync(path.join(projects, slug), dir); + for (const file of fs.readdirSync(dir, { recursive: true, withFileTypes: true })) if (file.isFile()) rebindFile(path.join(file.parentPath, file.name), tpl, copy); + } + fs.rmSync(path.join(copy, 'home', '.capy'), { recursive: true, force: true }); + }, + }); + template.copy().root && templates.set(lanes, template); + } +}, 60_000); +afterAll(() => { for (const t of templates.values()) t.dispose(); }); + +function gatedThenRestamped(lanes: Lanes = TESTS_LANE) { + const { root, meta: { head, current } } = templates.get(lanes)!.copy(); + const repo = fixtureRepoAt(root); + repos.push(repo); + return { repo, head, bundle: path.join(repo.root, 'bundle.json'), current }; } const regate = (repo: FixtureRepo, args: string[], env: Record) => runBin(repo, 'gstack-pregate', ['regate', '--base', 'main', ...args], env); @@ -97,7 +134,7 @@ describe('gstack-pregate regate: evidence, stamps and lane verdicts', () => { }); test('a stamp-sensitive lane reruns, so a regate is needed; a code edit is not stamp-only and names the file and line', () => { - const { repo, head, bundle } = gatedThenRestamped([{ label: 'tests', command: 'true' }, { label: 'digest', command: 'cat generated/digest.md' }]); + const { repo, head, bundle } = gatedThenRestamped(DIGEST_LANES); const env = ghShim(repo, { list: [] }); const r = regate(repo, ['--against', head, '--bundle', bundle], env); expect(r.status).toBe(EXIT.fail); diff --git a/test/session-update-autostash.test.ts b/test/session-update-autostash.test.ts index f2ab223d9..d5a0cff24 100644 --- a/test/session-update-autostash.test.ts +++ b/test/session-update-autostash.test.ts @@ -284,7 +284,8 @@ describe('gstack-session-update lock identity + TTL (#2613)', () => { const r = runScript(base, install, state); expect(r.status).toBe(0); const log = await waitForLog(state, /UP_TO_DATE|UPDATING/); - expect(log).toMatch(/UP_TO_DATE|UPDATING/); + const lockPid = fs.existsSync(path.join(lockDir, 'pid')) ? fs.readFileSync(path.join(lockDir, 'pid'), 'utf8').trim() : 'no lock'; + expect(log, `planted dead pid ${dead.pid} (alive now: ${isAlive(dead.pid)}); lock pid after 15 s: ${lockPid} (alive: ${isAlive(Number(lockPid))}); script exit ${r.status}, stderr: ${r.stderr}`).toMatch(/UP_TO_DATE|UPDATING/); } finally { fs.rmSync(base, { recursive: true, force: true }); } diff --git a/test/shard-engine.test.ts b/test/shard-engine.test.ts index 272d5d740..60c99de61 100644 --- a/test/shard-engine.test.ts +++ b/test/shard-engine.test.ts @@ -171,7 +171,10 @@ describe('shard engine: process lifecycle', () => { }); expect(paid.status).toBe('timed-out'); expect(summaryExitCode(summarize([paid]))).toBe(1); - expect(await waitDead(Number(fs.readFileSync(pidFile, 'utf8')))).toBe(true); + const paidChild = Number(fs.readFileSync(pidFile, 'utf8')); + const paidChildDead = await waitDead(paidChild); + const procStat = (pid: number) => { try { return fs.readFileSync(`/proc/${pid}/stat`, 'utf8').trim(); } catch { return 'no /proc entry'; } }; + expect(paidChildDead, `paid grandchild ${paidChild} of group ${paid.groupPid} 2 s after the timeout kill: ${procStat(paidChild)}`).toBe(true); }, 30_000); test('win32 semantics: no process group and never a negative-pid kill', async () => { diff --git a/test/ship-budget.test.ts b/test/ship-budget.test.ts index 2ce43a144..5043da5a1 100644 --- a/test/ship-budget.test.ts +++ b/test/ship-budget.test.ts @@ -308,7 +308,7 @@ describe('Claude Code child launch', () => { const file = ho.out.match(/^HANDOFF: (\S+)/m)![1]!; const argsFile = path.join(h.root, 'claude-args.txt'); const fake = path.join(h.root, 'fake-claude'); - fs.writeFileSync(fake, `#!/bin/sh\nprintf '%s\\n' "$@" > "${argsFile}"\n`, { mode: 0o755 }); + fs.writeFileSync(fake, `#!/bin/sh\nprintf '%s\\n' "$@" > "${argsFile}.tmp" && mv "${argsFile}.tmp" "${argsFile}"\n`, { mode: 0o755 }); const r = h.sb(['launch', '--in', file], { GSTACK_CLAUDE_BIN: fake }); expect(r.code).toBe(0); const session = h.field(r.out, 'CHILD', 'session'); diff --git a/test/ship-queue-train.test.ts b/test/ship-queue-train.test.ts index ad5c056a3..9a46e65be 100644 --- a/test/ship-queue-train.test.ts +++ b/test/ship-queue-train.test.ts @@ -35,13 +35,16 @@ const result = (out: string) => line(out, 'GSTACK_RESULT:'); const next = (out: string) => line(out, 'NEXT:'); const remoteRefs = (fx: TrainFixture) => fx.repo.git('ls-remote', 'origin'); -// fails_when=coordinatorClone copies origin.git/objects file by file again, so an entry that appears or vanishes there mid-copy (the detached maintenance.lock every push into the fixture origin leaves) fails the clone, as in two Free Tests reds on 2026-10-28 (GSTA-139 ledger); why_new=no other test clones while origin's objects directory changes; seam=a dangling symlink planted under objects/, which a local copy refuses on every run; no_claim=which process removed the loose object those runs named +// fails_when=coordinatorClone copies origin.git/objects file by file again, so an entry that appears or vanishes there mid-copy (the detached maintenance.lock every push into the fixture origin leaves) fails the clone, as in two Free Tests reds on 2026-10-28 (GSTA-139 ledger); why_new=no other test clones while origin's objects directory changes; seam=a dangling symlink planted under objects/ beside a held maintenance.lock, which a local copy refuses on every run; the seam has its own name because the fixture push's own detached maintenance can hold objects/maintenance.lock at that moment (EEXIST in Free Tests 41288253305 and 41288417894, 2026-11-01); no_claim=which process removed the loose object those runs named test('the coordinator clone reads origin through git, never by copying its objects directory (GSTA-139)', () => { const fx = make(); - fs.symlinkSync(path.join(fx.repo.root, 'gone'), path.join(fx.repo.origin, 'objects', 'maintenance.lock')); + const objects = path.join(fx.repo.origin, 'objects'); + fs.writeFileSync(path.join(objects, 'maintenance.lock'), ''); + fs.symlinkSync(path.join(fx.repo.root, 'gone'), path.join(objects, 'gstack-dangling-seam')); const coord = coordinatorClone(fx.repo); expect(spawnSync('git', ['-C', coord, 'rev-parse', 'origin/main'], { encoding: 'utf8', timeout: 30_000, env: { ...process.env, ...fx.repo.env } }).stdout.trim()).toBe(fx.repo.git('rev-parse', 'origin/main')); expect(fs.existsSync(path.join(coord, '.git', 'objects', 'maintenance.lock'))).toBe(false); + expect(fs.readdirSync(path.join(coord, '.git', 'objects'))).not.toContain('gstack-dangling-seam'); }); describe('the train command surface', () => { From 322906ab2b0975c6b009ae4a2804259be9e8ed70 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Mon, 2 Nov 2026 05:17:17 -0800 Subject: [PATCH 02/19] v1.92.79.0 fix: /plan-tune stops reporting mismatches with no observed answers behind them (#3436) (#3856) * fix(plan-tune): compare declared and inferred only with 3+ observed answers (#3436) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: derive keeps the gap at 3 events; changelog fragment for #3436 Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(plan-tune): profile view and design doc honor the 3-answer floor (#3436) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(plan-tune): keep the 10-answer floor in --check-mismatch beside the per-dimension floor Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --------- Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- CHANGELOG.md | 11 ++++ VERSION | 2 +- agents-digest/gstack-AGENTS.md | 2 +- bin/gstack-developer-profile | 23 +++++-- docs/designs/PLAN_TUNING_V0.md | 2 +- package.json | 2 +- plan-tune/SKILL.md | 5 ++ plan-tune/SKILL.md.tmpl | 5 ++ test/gstack-developer-profile.test.ts | 92 +++++++++++++++++++++++++++ 9 files changed, 135 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 517e1d270..1fc172340 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +## [1.92.79.0] - 2026-11-02 + +**/plan-tune no longer reports a mismatch between your stated and observed preferences when it has no observed answers behind it (#3436).** `--check-mismatch` compared a declared value against an inferred value that had never moved from its 0.5 starting point, so a strong declaration with no matching answers printed `scope_appetite: declared 0.9 vs inferred 0.5 (gap 0.4)` even though no logged answer touched that dimension. + +### Fixed +- **`bin/gstack-developer-profile`**: `--check-mismatch`, `--gap` and the gap that `--derive` stores compare a dimension only when at least 3 logged answers moved it. `--check-mismatch` still needs 10 logged answers overall before it reports anything. Below the 3-answer floor, `--check-mismatch` prints `no observed evidence` or `too little evidence (n of 3 events)` instead of a gap, and `--gap` lists the dimension under a new `low_evidence` field. A profile derived before `contributing_events` existed keeps the old behavior until its next derive. +- **/plan-tune "Show gap"**: says "not enough observed answers yet" for those dimensions instead of calling them drift. + +### Tests +- `test/gstack-developer-profile.test.ts`: a declared dimension with no evidence is not flagged by `--check-mismatch` or `--gap` (both failed on main), 1 or 2 events report too little evidence, 3 events are compared, three same-day answers that agree with the declaration still report not enough data, and `--derive` stores no gap without evidence. + ## [1.92.78.0] - 2026-11-02 **Seven flaky tests from the 2026-11-01 flaky pass stop failing correct runs, and six more now name their cause when they fail.** One product lock broke a fresh lock it had misjudged as abandoned, a /ship lane tripped the free runner's home check with its own log, and the rest were fixtures that raced their own setup, leaned on wall-clock sleeps or read the caller's state root. diff --git a/VERSION b/VERSION index 66231b754..dfb847afe 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.92.78.0 +1.92.79.0 diff --git a/agents-digest/gstack-AGENTS.md b/agents-digest/gstack-AGENTS.md index 9f27e6a29..192027e8e 100644 --- a/agents-digest/gstack-AGENTS.md +++ b/agents-digest/gstack-AGENTS.md @@ -1,4 +1,4 @@ -# gstack digest v1.92.78.0 — regenerate/re-copy after upgrading gstack +# gstack digest v1.92.79.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/bin/gstack-developer-profile b/bin/gstack-developer-profile index bc489c5c1..409c4f56e 100755 --- a/bin/gstack-developer-profile +++ b/bin/gstack-developer-profile @@ -54,6 +54,7 @@ case "$(uname -s)" in esac PROFILE_FILE="$GSTACK_HOME/developer-profile.json" LEGACY_FILE="$GSTACK_HOME/builder-profile.jsonl" +MIN_EVIDENCE=3 eval "$("$SCRIPT_DIR/gstack-slug" 2>/dev/null || true)" SLUG="${SLUG:-unknown}" @@ -512,14 +513,19 @@ do_gap() { const p = JSON.parse(await Bun.stdin.text()); const declared = p.declared || {}; const inferred = (p.inferred && p.inferred.values) || {}; + const contributing = p.inferred && p.inferred.contributing_events; const dims = ['scope_appetite','risk_tolerance','detail_preference','autonomy','architecture_care']; const gap = {}; + const low_evidence = {}; for (const d of dims) { - if (declared[d] !== undefined && inferred[d] !== undefined) { - gap[d] = +(Math.abs(declared[d] - inferred[d])).toFixed(3); + if (declared[d] === undefined || inferred[d] === undefined) continue; + if (contributing && (contributing[d] || 0) < $MIN_EVIDENCE) { + low_evidence[d] = contributing[d] || 0; + continue; } + gap[d] = +(Math.abs(declared[d] - inferred[d])).toFixed(3); } - console.log(JSON.stringify({ declared, inferred, gap }, null, 2)); + console.log(JSON.stringify({ declared, inferred, gap, low_evidence }, null, 2)); " } @@ -657,6 +663,7 @@ do_derive() { // Recompute gap. const gap = {}; for (const d of Object.keys(values)) { + if ((contributing[d] || 0) < $MIN_EVIDENCE) continue; if (profile.declared && profile.declared[d] !== undefined) { gap[d] = +(Math.abs(profile.declared[d] - values[d])).toFixed(3); } @@ -727,9 +734,8 @@ do_check_mismatch() { const declared = p.declared || {}; const inferred = (p.inferred && p.inferred.values) || {}; const sampleSize = (p.inferred && p.inferred.sample_size) || 0; - const diversity = (p.inferred && p.inferred.diversity) || {}; + const contributing = p.inferred && p.inferred.contributing_events; - // Require enough data before reporting mismatch. if (sampleSize < 10) { console.log('MISMATCH: not enough data (' + sampleSize + ' events; need 10+)'); process.exit(0); @@ -737,8 +743,14 @@ do_check_mismatch() { const THRESHOLD = 0.3; const flagged = []; + const thin = []; for (const d of Object.keys(declared)) { if (inferred[d] === undefined) continue; + const n = contributing ? (contributing[d] || 0) : undefined; + if (n !== undefined && n < $MIN_EVIDENCE) { + thin.push(' ' + d + ': ' + (n === 0 ? 'no observed evidence' : 'too little evidence (' + n + ' of $MIN_EVIDENCE events)')); + continue; + } const gap = Math.abs(declared[d] - inferred[d]); if (gap > THRESHOLD) { flagged.push({ dim: d, declared: declared[d], inferred: inferred[d], gap: +gap.toFixed(3) }); @@ -753,6 +765,7 @@ do_check_mismatch() { console.log(' ' + f.dim + ': declared ' + f.declared + ' vs inferred ' + f.inferred + ' (gap ' + f.gap + ')'); } } + for (const line of thin) console.log(line); " } diff --git a/docs/designs/PLAN_TUNING_V0.md b/docs/designs/PLAN_TUNING_V0.md index e9bf2b440..77bf95e8d 100644 --- a/docs/designs/PLAN_TUNING_V0.md +++ b/docs/designs/PLAN_TUNING_V0.md @@ -105,7 +105,7 @@ After weighing Codex's argument, we chose to roll back CEO EXPANSION and ship an } ``` -`signal_events` counts the logged answers that moved any dimension, and `contributing_events` counts, per dimension, the logged answers that moved it (an answer that writes two deltas to one dimension counts once), so a dimension with no evidence (0) is visible beside one whose evidence balances out; both print 0.5 (#2623). Each value is the sigmoid of its accumulated deltas, and each UTC day's sum per dimension (by the row's `ts`) is clamped to the largest single delta in the signal map (currently ±0.06), so one burst of answers can't pin a dimension; `--trace ` lists every contributing answer, each clamped day and the total. The bound keys on the day, not on `session_id`: the PostToolUse hook and the agent log different ids for the same review (the host's conversation id and the preamble's run id), and an agent can leave the `SESSION_ID` placeholder unsubstituted, so no logged id reliably marks one review. The cost is that several reviews on one day count as one. `contributing_events` still counts an answer logged by both writers twice. Only an ISO 8601 date or date-time `ts` counts as dated (a time without a zone is read as UTC), every other row shares one undated bucket, and `diversity.days_span` counts the same UTC days. Nothing displays `contributing_events` yet (#3436). +`signal_events` counts the logged answers that moved any dimension, and `contributing_events` counts, per dimension, the logged answers that moved it (an answer that writes two deltas to one dimension counts once), so a dimension with no evidence (0) is visible beside one whose evidence balances out; both print 0.5 (#2623). Each value is the sigmoid of its accumulated deltas, and each UTC day's sum per dimension (by the row's `ts`) is clamped to the largest single delta in the signal map (currently ±0.06), so one burst of answers can't pin a dimension; `--trace ` lists every contributing answer, each clamped day and the total. The bound keys on the day, not on `session_id`: the PostToolUse hook and the agent log different ids for the same review (the host's conversation id and the preamble's run id), and an agent can leave the `SESSION_ID` placeholder unsubstituted, so no logged id reliably marks one review. The cost is that several reviews on one day count as one. `contributing_events` still counts an answer logged by both writers twice. Only an ISO 8601 date or date-time `ts` counts as dated (a time without a zone is read as UTC), every other row shares one undated bucket, and `diversity.days_span` counts the same UTC days. `--check-mismatch`, `--gap`, the stored `gap` and /plan-tune's profile view compare a dimension only when its `contributing_events` is at least 3; `--gap` lists the others under `low_evidence` and the stored `gap` omits them (#3436). **Diversity check** (Codex #13): `inferred` is considered "enough data" only when `sample_size >= 20 AND skills_covered >= 3 AND question_ids_covered >= 8 AND days_span >= 7`. Below this, `/plan-tune profile` shows "not enough observed data yet" instead of a potentially-misleading inferred value. diff --git a/package.json b/package.json index bce0fb11b..b8a73016c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gstack", - "version": "1.92.78", + "version": "1.92.79", "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/plan-tune/SKILL.md b/plan-tune/SKILL.md index 86b2cbdb7..481d7764e 100644 --- a/plan-tune/SKILL.md +++ b/plan-tune/SKILL.md @@ -341,6 +341,8 @@ Parse the JSON. Present in **plain English**, not raw floats: the inferred column next to declared: "**scope_appetite:** declared 0.8 (boil the ocean) ↔ observed 0.72 (close)" Use words for the gap: 0.0-0.1 "close", 0.1-0.3 "drift", 0.3+ "mismatch". + When `inferred.contributing_events[dim]` is below 3, show "not enough + observed answers yet" for that dimension instead of an observed value or gap word. This display gate is intentionally lower than the E1 **promotion gate** (90+ days stable across 3+ skills, per `docs/designs/PLAN_TUNING_V0.md`). @@ -491,6 +493,9 @@ Parse the JSON. For each dimension where both declared and inferred exist: Consider updating your declared value, or reflect on whether your behavior is actually what you want." +For each dimension in `low_evidence` (fewer than 3 observed answers moved it), +say "not enough observed answers yet" instead of a gap. + Never auto-update declared based on the gap. In v1 the gap is reporting only — the user decides whether declared is wrong or behavior is wrong. diff --git a/plan-tune/SKILL.md.tmpl b/plan-tune/SKILL.md.tmpl index 748dfad62..88b7a8eb3 100644 --- a/plan-tune/SKILL.md.tmpl +++ b/plan-tune/SKILL.md.tmpl @@ -272,6 +272,8 @@ Parse the JSON. Present in **plain English**, not raw floats: the inferred column next to declared: "**scope_appetite:** declared 0.8 (boil the ocean) ↔ observed 0.72 (close)" Use words for the gap: 0.0-0.1 "close", 0.1-0.3 "drift", 0.3+ "mismatch". + When `inferred.contributing_events[dim]` is below 3, show "not enough + observed answers yet" for that dimension instead of an observed value or gap word. This display gate is intentionally lower than the E1 **promotion gate** (90+ days stable across 3+ skills, per `docs/designs/PLAN_TUNING_V0.md`). @@ -422,6 +424,9 @@ Parse the JSON. For each dimension where both declared and inferred exist: Consider updating your declared value, or reflect on whether your behavior is actually what you want." +For each dimension in `low_evidence` (fewer than 3 observed answers moved it), +say "not enough observed answers yet" instead of a gap. + Never auto-update declared based on the gap. In v1 the gap is reporting only — the user decides whether declared is wrong or behavior is wrong. diff --git a/test/gstack-developer-profile.test.ts b/test/gstack-developer-profile.test.ts index df23a9c3b..cffaadebc 100644 --- a/test/gstack-developer-profile.test.ts +++ b/test/gstack-developer-profile.test.ts @@ -622,6 +622,98 @@ describe('gstack-developer-profile --check-mismatch', () => { expect(r.stdout).toContain('scope_appetite'); expect(r.stdout).toContain('autonomy'); }); + + const deriveWithOneSignal = () => { + logQuestion({ skill: 'plan-eng-review', question_id: 'plan-eng-review-arch-finding', question_summary: 'arch?', user_choice: 'fix-now', session_id: 's0' }); + for (let i = 1; i < 13; i++) { + logQuestion({ skill: 'plan-eng-review', question_id: `adhoc-unregistered-${i}`, question_summary: 'x', user_choice: 'anything', session_id: `s${i}` }); + } + expect(runDev('--derive').status).toBe(0); + const file = path.join(tmpHome, 'developer-profile.json'); + const p = readProfile() as any; + expect(p.inferred.contributing_events.scope_appetite).toBe(0); + p.declared = { scope_appetite: 0.9 }; + fs.writeFileSync(file, JSON.stringify(p)); + }; + + test('a declared dimension with no observed evidence is not flagged (#3436)', () => { + deriveWithOneSignal(); + const r = runDev('--check-mismatch'); + expect(r.status).toBe(0); + expect(r.stdout).not.toContain('scope_appetite: declared'); + expect(r.stdout).toContain('scope_appetite: no observed evidence'); + }); + + test('--gap leaves out a dimension with no observed evidence (#3436)', () => { + deriveWithOneSignal(); + const out = JSON.parse(runDev('--gap').stdout); + expect(out.gap.scope_appetite).toBeUndefined(); + expect(out.low_evidence).toEqual({ scope_appetite: 0 }); + }); + + test('a dimension with 1 or 2 contributing events reports too little evidence', () => { + runDev('--read'); + const file = path.join(tmpHome, 'developer-profile.json'); + const p = readProfile() as any; + p.declared = { scope_appetite: 0.9 }; + p.inferred.values.scope_appetite = 0.45; + p.inferred.sample_size = 10; + p.inferred.contributing_events = { scope_appetite: 2 }; + fs.writeFileSync(file, JSON.stringify(p)); + const r = runDev('--check-mismatch'); + expect(r.stdout).toContain('MISMATCH: none'); + expect(r.stdout).toContain('scope_appetite: too little evidence (2 of 3 events)'); + expect(JSON.parse(runDev('--gap').stdout).low_evidence).toEqual({ scope_appetite: 2 }); + }); + + test('a dimension with 3 contributing events is compared', () => { + runDev('--read'); + const file = path.join(tmpHome, 'developer-profile.json'); + const p = readProfile() as any; + p.declared = { scope_appetite: 0.9 }; + p.inferred.values.scope_appetite = 0.45; + p.inferred.sample_size = 10; + p.inferred.contributing_events = { scope_appetite: 3 }; + fs.writeFileSync(file, JSON.stringify(p)); + expect(runDev('--check-mismatch').stdout).toContain('scope_appetite: declared 0.9 vs inferred 0.45 (gap 0.45)'); + expect(JSON.parse(runDev('--gap').stdout).gap.scope_appetite).toBeCloseTo(0.45, 2); + }); + + test('three same-day answers that agree with the declaration are not a mismatch', () => { + for (let i = 0; i < 3; i++) { + logQuestion({ skill: 'plan-ceo-review', question_id: 'plan-ceo-review-mode', question_summary: 'mode?', user_choice: 'expand', session_id: `s${i}`, ts: '2026-10-20T12:00:00Z' }); + } + expect(runDev('--derive').status).toBe(0); + const file = path.join(tmpHome, 'developer-profile.json'); + const p = readProfile() as any; + expect(p.inferred.contributing_events.scope_appetite).toBe(3); + p.declared = { scope_appetite: 0.9 }; + fs.writeFileSync(file, JSON.stringify(p)); + const r = runDev('--check-mismatch'); + expect(r.stdout).toContain('not enough data'); + expect(r.stdout).not.toContain('scope_appetite: declared'); + }); + + test('derive stores the gap for a dimension with 3 contributing events', () => { + for (let i = 0; i < 3; i++) { + logQuestion({ skill: 'plan-eng-review', question_id: 'plan-eng-review-arch-finding', question_summary: 'arch?', user_choice: 'fix-now', session_id: `s${i}`, ts: `2026-10-2${i}T12:00:00Z` }); + } + expect(runDev('--derive').status).toBe(0); + const file = path.join(tmpHome, 'developer-profile.json'); + const p = readProfile() as any; + expect(p.inferred.contributing_events.architecture_care).toBe(3); + p.declared = { architecture_care: 0.1 }; + fs.writeFileSync(file, JSON.stringify(p)); + expect(runDev('--derive').status).toBe(0); + expect((readProfile() as any).gap.architecture_care).toBeGreaterThan(0.3); + }); + + test('derive stores no gap for a dimension without evidence', () => { + deriveWithOneSignal(); + expect(runDev('--derive').status).toBe(0); + const p = readProfile() as any; + expect(p.gap.scope_appetite).toBeUndefined(); + }); }); // ----------------------------------------------------------------------- From 0542230e632b5e6b2d776aadbe21fb4b8109d0d5 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Mon, 2 Nov 2026 05:28:00 -0800 Subject: [PATCH 03/19] test(fixtures): leak scan skips Capy's git shim log in fixture homes (#3860) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- CHANGELOG.md | 8 ++++++++ VERSION | 2 +- agents-digest/gstack-AGENTS.md | 2 +- package.json | 2 +- test/git-fixture-template.test.ts | 17 +++++++++++++++++ test/helpers/git-fixture-template.ts | 8 ++++++-- 6 files changed, 34 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fc172340..f32c13f1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## [1.92.80.0] - 2026-11-02 + +**On a Capy machine, the git fixture tests no longer fail locally because of Capy's git shim log.** Capy's `/usr/bin/git` shim appends to `$HOME/.capy/git-shim.log`, so each fixture home that ran git during its template build ended up with a log naming the template. The leak scan in `test/helpers/git-fixture-template.ts` flagged it, and 34 tests in `test/train-backstop.test.ts`, `test/restamp-mentions.test.ts` and `test/pregate-user-policy.test.ts` failed on every Capy lane, though they passed on the remote gate. + +### Tests +- `templateReferences` skips `.capy/git-shim.log`. Nothing reads that file back, and every other file is still scanned. +- `test/git-fixture-template.test.ts` plants the shim log in a template's `home/.capy/` (the copy succeeds), and plants `home/.capy/state.json` as a control (the copy still throws). + ## [1.92.79.0] - 2026-11-02 **/plan-tune no longer reports a mismatch between your stated and observed preferences when it has no observed answers behind it (#3436).** `--check-mismatch` compared a declared value against an inferred value that had never moved from its 0.5 starting point, so a strong declaration with no matching answers printed `scope_appetite: declared 0.9 vs inferred 0.5 (gap 0.4)` even though no logged answer touched that dimension. diff --git a/VERSION b/VERSION index dfb847afe..f17ba7e50 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.92.79.0 +1.92.80.0 diff --git a/agents-digest/gstack-AGENTS.md b/agents-digest/gstack-AGENTS.md index 192027e8e..835c2c05f 100644 --- a/agents-digest/gstack-AGENTS.md +++ b/agents-digest/gstack-AGENTS.md @@ -1,4 +1,4 @@ -# gstack digest v1.92.79.0 — regenerate/re-copy after upgrading gstack +# gstack digest v1.92.80.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/package.json b/package.json index b8a73016c..2da268dcb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gstack", - "version": "1.92.79", + "version": "1.92.80", "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/git-fixture-template.test.ts b/test/git-fixture-template.test.ts index 76375466c..f63a6c002 100644 --- a/test/git-fixture-template.test.ts +++ b/test/git-fixture-template.test.ts @@ -71,6 +71,23 @@ describe('git fixture template', () => { expect(() => leaky.copy()).toThrow(/still references its template [^\n]*\n.*config/); }); + test("Capy's git shim log in a fixture home (home/.capy/git-shim.log) is not a leak; any other file naming the template still is", () => { + const plant = (rel: string) => gitFixtureTemplate({ prefix: 'gstack-fixture-template-shim-', build: (root) => { + const meta = build(root); + fs.mkdirSync(path.dirname(path.join(root, rel)), { recursive: true }); + fs.writeFileSync(path.join(root, rel), '# capy git shim v2: ts cwd ppid parent verb\n2026-11-02T02:15:30Z\t' + path.join(root, 'work') + '\t1\tbun\tcat-file\n'); + return meta; + }, rebind: (copy, tpl) => rebindGitDir(path.join(copy, 'work', '.git'), tpl, copy) }); + const shim = plant(path.join('home', '.capy', 'git-shim.log')); + const other = plant(path.join('home', '.capy', 'state.json')); + try { + const c = shim.copy(); + roots.push(c.root); + expect(git(path.join(c.root, 'work'), 'remote', 'get-url', 'origin')).toBe(path.join(c.root, 'origin.git')); + expect(() => other.copy()).toThrow(/still references its template [^\n]*\n.*state\.json/); + } finally { shim.dispose(); other.dispose(); } + }); + test('native, forward-slash, backslash-escaped and Git Bash spellings are each rewritten, and each one left behind is found', () => { const to = fs.mkdtempSync(path.join(os.tmpdir(), 'gstack-fixture-spellings-')); roots.push(to); diff --git a/test/helpers/git-fixture-template.ts b/test/helpers/git-fixture-template.ts index a646747ab..5fb9f72eb 100644 --- a/test/helpers/git-fixture-template.ts +++ b/test/helpers/git-fixture-template.ts @@ -52,7 +52,11 @@ export function rebindGitDir(gitDir: string, from: string, to: string): void { } } -/** Files and symlinks under dir (and the template's meta value) that still name templateRoot; zlib-compressed object storage is skipped. */ +/** + * Files and symlinks under dir (and the template's meta value) that still name templateRoot. Skipped: zlib-compressed object + * storage, and the log Capy's /usr/bin/git shim appends to in whatever HOME it runs under (.capy/git-shim.log), which names + * the template whenever a fixture home ran git during build; nothing reads it back. + */ export function templateReferences(dir: string, templateRoot: string, meta?: unknown): string[] { const needles = pathSpellings(templateRoot).map(s => Buffer.from(s)); const names = (buf: Buffer) => needles.some(n => buf.includes(n)); @@ -62,7 +66,7 @@ export function templateReferences(dir: string, templateRoot: string, meta?: unk const p = path.join(d, entry.name); if (entry.isSymbolicLink()) { if (names(Buffer.from(fs.readlinkSync(p)))) hits.push(p); } else if (entry.isDirectory()) { if (!(path.basename(d) === 'objects' && /^(pack|[0-9a-f]{2})$/.test(entry.name))) walk(p); } - else if (entry.isFile() && names(fs.readFileSync(p))) hits.push(p); + else if (entry.isFile() && !(entry.name === 'git-shim.log' && path.basename(d) === '.capy') && names(fs.readFileSync(p))) hits.push(p); } }; walk(dir); From 1022f4fc51a4771e3838ce6bbf7c19b7e94e67fe Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Mon, 2 Nov 2026 05:38:02 -0800 Subject: [PATCH 04/19] v1.92.81.0 feat(ship-release): finish accepts the owner's edit after a fix-check (GST-965) (#3861) * feat(ship-release): finish accepts the owner's edit after a fix-check (GST-965) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(ship-release): fix_check.files narrows the accepted scope; gate-edited and over-cap paths stay behavior (GST-965) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs(review-policy): the gate-edited and over-cap exclusions hold with --reviewed-base (GST-965) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(ship-release): a gate-edited test is never owner-accepted; an empty fix_check.files stops (GST-965) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs(review-policy): the over-cap exclusion holds with --reviewed-base (GST-965 fix-check note) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --------- Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- CHANGELOG.md | 10 ++++ VERSION | 2 +- agents-digest/gstack-AGENTS.md | 2 +- docs/review-policy.md | 9 +++- lib/ship-release.ts | 57 ++++++++++++++++------ package.json | 2 +- test/ship-rereview-triggers.test.ts | 76 +++++++++++++++++++++++++++++ 7 files changed, 140 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f32c13f1e..209155077 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## [1.92.81.0] - 2026-11-02 + +**`gstack-ship-release finish` now accepts the owner's edit after a fix-check instead of asking for another review round (GST-965).** On gbrain #8425, the fix-check found a blocker, the owner's pre-agreed fallback was applied and "then ship" was granted. Finish still classed the edit as behavior and stopped with `insert 5–11.5 → 12–14 → 16`, a third round the R51 cap forbids, so /ship could not get through Step 16 without running its stages by hand. + +### Added +- **`finish --review-loop-exception `** (`lib/ship-release.ts`) takes the same record `gstack-ship-receipt write --review-loop-exception` takes. Paths changed since `fix_check.head` that the branch already touched at that commit (narrowed to the record's `fix_check.files` when it lists them) route as `accepted=` on the `ROUTE:` line, a `REVIEW_LOOP_EXCEPTION:` line names them with the owner, date and channel, and the docs stage carries them (`accepted=` in the DOCS line). A path outside that scope and a gate-edited test (with or without `--reviewed-base`) still route as behavior, and with `--reviewed-base` so does a file too large for the scoped review. A malformed record, or a `fix_check.head` that is not HEAD or an ancestor of it, stops before the release commit. Without the flag nothing changes. + +### Tests +- `test/ship-rereview-triggers.test.ts`: an owner fallback edit to a source file and a doc after the fix-check stops without the record and passes Step 16 with it; a new file outside the scope (even when `fix_check.files` lists it), a fix-check head off the branch, a malformed record, an unreadable record file and an empty `fix_check.files` stop; a `fix_check.files` list narrows what is accepted; a test weakened after the fix-check stops with and without `--reviewed-base`. + ## [1.92.80.0] - 2026-11-02 **On a Capy machine, the git fixture tests no longer fail locally because of Capy's git shim log.** Capy's `/usr/bin/git` shim appends to `$HOME/.capy/git-shim.log`, so each fixture home that ran git during its template build ended up with a log naming the template. The leak scan in `test/helpers/git-fixture-template.ts` flagged it, and 34 tests in `test/train-backstop.test.ts`, `test/restamp-mentions.test.ts` and `test/pregate-user-policy.test.ts` failed on every Capy lane, though they passed on the remote gate. diff --git a/VERSION b/VERSION index f17ba7e50..9a1e28b7f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.92.80.0 +1.92.81.0 diff --git a/agents-digest/gstack-AGENTS.md b/agents-digest/gstack-AGENTS.md index 835c2c05f..45e52d15a 100644 --- a/agents-digest/gstack-AGENTS.md +++ b/agents-digest/gstack-AGENTS.md @@ -1,4 +1,4 @@ -# gstack digest v1.92.80.0 — regenerate/re-copy after upgrading gstack +# gstack digest v1.92.81.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/review-policy.md b/docs/review-policy.md index db10c3753..16e93e891 100644 --- a/docs/review-policy.md +++ b/docs/review-policy.md @@ -429,7 +429,14 @@ rules hash, base and registry commits, the gate scan bound to the head and the r the queue refuses a receipt below the depth its head needs ([ship-policy.md#ship-receipt](ship-policy.md#ship-receipt)). A stop the owner accepted after a fix-check edit goes in `review_loop_exception`, never in prose -under `REVIEW_LOOP:`. +under `REVIEW_LOOP:`. Step 16 takes the same record: +`gstack-ship-release finish --review-loop-exception ` routes the +paths the branch touched at `fix_check.head` (narrowed to the record's +`fix_check.files` when it lists them) and changed since as `accepted=` in +`ROUTE:`, prints them on a `REVIEW_LOOP_EXCEPTION:` line, and carries them +through the docs stage. A path outside that scope and a gate-edited test still +route as behavior, with `--reviewed-base` (as /ship passes it) so does a file +too large for the scoped review, and without the record nothing changes. The receipt's summary line prints `passes= blocking_found= deferred=`, which is what a scorecard tracks (target: a median of 1 pass per PR). A diff --git a/lib/ship-release.ts b/lib/ship-release.ts index bdce14414..02f5218a7 100644 --- a/lib/ship-release.ts +++ b/lib/ship-release.ts @@ -15,6 +15,7 @@ import { mergeChangelogs, normalizeChangelog } from './changelog-check'; import { versionAtRef } from './restamp'; import { classifyPath } from './review-depth'; import { comparePath, contextPacket, gateEditedPaths, isTestCode, PACKET_SECTION_CAP, readScopedReview, touchedPaths, type PatchSides } from './ship-patch'; +import { parseReviewLoopException, type ReviewLoopException } from './ship-receipt-depth'; import { parseReceiptDocs, type ReceiptDocs } from './ship-receipt-docs'; import { resolveStateRoot } from './state-root'; import { bumpVersion, cmpVersion, fmtVersion, parseVersion, versionWidth, type Bump } from './version-source'; @@ -27,10 +28,11 @@ export const RELEASE_HELP = `gstack-ship-release — /ship Steps 12 and 15-17 (s --keep-current (or --version ) keeps VERSION; under bump ask a session no person answers needs --answer before a bump is written finish --base --reviewed-tree [--reviewed-base ] --docs-post [--lane