mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-23 08:31:44 +01:00
Split the slowest free test file so no shard waits on it (GST-3303) (#4588)
Free Tests no longer waits on one 263-second test file. Its 79 tests (80 cases) now run as six files of 25 to 40 seconds, so the shard planner can spread them out. This is part of making pull request CI faster: a file that big puts a floor under one shard, and that floor matters most on bigger runners. Nothing to do. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> Review-Finding: v1/adversarial-native#1 reader=adversarial-native Review-Finding: p1/red-team#1 reader=red-team
This commit is contained in:
1 parent
e096fa850c
commit
ffdd5354b8
13 files changed
+1331
-1238
No files matched your search
@@ -0,0 +1 @@
|
||||
**The slowest free test file is now six files.** `test/review-pass.test.ts` took about 263 seconds on its own, and Free Tests can't split a file across workers, so one shard waited on it every run. Its cases now live in six files of 25 to 40 seconds each on CI (run 44875106601), sharing their fixtures through `test/helpers/review-pass-harness.ts`. No case changed. The duration seed lists the six files, and the slow-file allowlist no longer needs an entry for it.
|
||||
@@ -1240,7 +1240,7 @@ ones, and the arm lost blockers. `bin/gstack-review-dispatch` closes both ends:
|
||||
|
||||
## Where this is enforced
|
||||
|
||||
- `lib/review-brief.ts`, `lib/review-ledger.ts`, `lib/review-pass.ts`, `lib/capy-review-pass.js`, `bin/gstack-review-dispatch`: [verbatim dispatch](#verbatim-dispatch) (`test/review-dispatch.test.ts`, `test/review-pass.test.ts`).
|
||||
- `lib/review-brief.ts`, `lib/review-ledger.ts`, `lib/review-pass.ts`, `lib/capy-review-pass.js`, `bin/gstack-review-dispatch`: [verbatim dispatch](#verbatim-dispatch) (`test/review-dispatch.test.ts`, `test/review-pass*.test.ts`).
|
||||
- `lib/ship-parts.ts`, `bin/gstack-ship-parts`: the section text each /ship phase uses, returned once per run inside the phase program before it; `next --resend` sends an unreceived batch again (`test/ship-parts.test.ts`).
|
||||
|
||||
- `scripts/resolvers/review-army.ts`: the floor and `NO FINDINGS` in every specialist and Red Team prompt (rendered into `review/sections/review-army.md` and `ship/sections/review-army.md`), and the lead judgment's "On record" line that turns a [ruled class](#rulings-below-the-floor) into a note; in `/ship` every specialist and Red Team prompt it renders carries its diff base as a literal sha the parent writes in (`DIFF_BASE=<diff-base>`: the merge base on pass 1, `RANGE_BASE` from pass 2 on) beside its plan's `DIFF_CMD` excludes, because a reviewer is its own process and never sees the parent's shell variables; the fan-out batches above.
|
||||
|
||||
@@ -1339,7 +1339,12 @@
|
||||
"test/review-negated-severity.test.ts": 74,
|
||||
"test/review-notes-only-pass.test.ts": 8622,
|
||||
"test/review-packets-removed.test.ts": 508,
|
||||
"test/review-pass.test.ts": 263472,
|
||||
"test/review-pass-program-steps.test.ts": 48027,
|
||||
"test/review-pass-program.test.ts": 43415,
|
||||
"test/review-pass-shared-machine.test.ts": 30119,
|
||||
"test/review-pass-step11.test.ts": 45992,
|
||||
"test/review-pass-voice-failures.test.ts": 52640,
|
||||
"test/review-pass.test.ts": 43822,
|
||||
"test/review-plan-cli.test.ts": 29693,
|
||||
"test/review-plan-granted-targeted.test.ts": 4291,
|
||||
"test/review-plan-merged-range.test.ts": 2017,
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
{"file": "test/setup-install-registry.test.ts", "reason": "82s in the 2026-10-15 recording (58s on 2026-10-04): 11 cases each run the real ./setup, gstack-relink, gstack-config and gstack-uninstall against throwaway checkouts", "todo": "split by describe block so the packer can balance it, then rerun bun run test:ubicloud --record-durations (TODOS.md, fix wave 2 follow-ups)"},
|
||||
{"file": "test/brain-sync.test.ts", "reason": "89s in the 2026-10-19 weekly recording (58s on 2026-10-15): #3254 added the case-collision suite, and every case drains a real gstack-brain-sync against a local bare remote", "todo": "split by describe block so the packer can balance it, then rerun bun run test:ubicloud --record-durations (TODOS.md, fix wave 2 follow-ups)"},
|
||||
{"file": "test/setup-codex-scope.test.ts", "reason": "64s in the 2026-10-19 weekly recording (59s on 2026-10-15): each case runs the real ./setup twice against a Codex install fixture", "todo": "split by describe block so the packer can balance it, then rerun bun run test:ubicloud --record-durations (TODOS.md, fix wave 2 follow-ups)"},
|
||||
{"file": "test/review-pass.test.ts", "reason": "221s in the 2026-11-09 recording (run 42691699570; 24s on 2026-10-31); admitted so the refreshed seed can land", "todo": "split or speed up; post-11-21 slow-test pass"},
|
||||
{"file": "test/review-exclude.test.ts", "reason": "126s in the 2026-11-09 recording (run 42691699570; unseeded before); admitted so the refreshed seed can land", "todo": "split or speed up; post-11-21 slow-test pass"},
|
||||
{"file": "test/ubicloud-runner-recovery.test.ts", "reason": "79s in the 2026-11-09 recording (run 42691699570; unseeded before); admitted so the refreshed seed can land", "todo": "split or speed up; post-11-21 slow-test pass"},
|
||||
{"file": "test/ship-rereview-triggers.test.ts", "reason": "78s in the 2026-11-09 recording (run 42691699570; unseeded before); admitted so the refreshed seed can land", "todo": "split or speed up; post-11-21 slow-test pass"},
|
||||
|
||||
@@ -484,6 +484,26 @@ export const KNOWN_WINDOWS_INCOMPATIBLE: Array<{ file: string; reason: string }>
|
||||
file: 'test/ship-finish-fixed-links.test.ts',
|
||||
reason: 'drives bin/gstack-ship-release, gstack-approvals, gstack-review-log, gstack-docs-candidate and gstack-wtree (shebangs) through test/helpers/ship-bin-fixture.ts like test/ship-finish-ruled-notes.test.ts; windows-latest fails every case at the first bin spawn (windows-free-shard 3, run 42593329215)',
|
||||
},
|
||||
{
|
||||
file: 'test/review-pass-program.test.ts',
|
||||
reason: 'split from test/review-pass.test.ts, which Windows never ran (its POSIX mode-bit check): runs bin/gstack-review-dispatch (a shebang) and bash git fixtures through test/helpers/review-pass-harness.ts',
|
||||
},
|
||||
{
|
||||
file: 'test/review-pass-program-steps.test.ts',
|
||||
reason: 'split from test/review-pass.test.ts, which Windows never ran (its POSIX mode-bit check): runs bin/gstack-review-dispatch (a shebang) and bash git fixtures through test/helpers/review-pass-harness.ts',
|
||||
},
|
||||
{
|
||||
file: 'test/review-pass-shared-machine.test.ts',
|
||||
reason: 'split from test/review-pass.test.ts, which Windows never ran (its POSIX mode-bit check): runs bin/gstack-review-dispatch (a shebang) and bash git fixtures through test/helpers/review-pass-harness.ts',
|
||||
},
|
||||
{
|
||||
file: 'test/review-pass-step11.test.ts',
|
||||
reason: 'split from test/review-pass.test.ts, which Windows never ran (its POSIX mode-bit check): runs bin/gstack-review-dispatch (a shebang) and bash git fixtures through test/helpers/review-pass-harness.ts',
|
||||
},
|
||||
{
|
||||
file: 'test/review-pass-voice-failures.test.ts',
|
||||
reason: 'split from test/review-pass.test.ts, which Windows never ran (its POSIX mode-bit check): runs bin/gstack-review-dispatch (a shebang) and bash git fixtures through test/helpers/review-pass-harness.ts',
|
||||
},
|
||||
];
|
||||
|
||||
// Force-include overrides: files a WINDOWS_FRAGILE_PATTERNS regex excludes for
|
||||
|
||||
@@ -62,7 +62,7 @@ export const FREE_FIXTURES: Readonly<Record<string, readonly string[]>> = {
|
||||
'test/fixtures/codex-review-sandbox-unavailable-37158847998.json': ['test/outside-voice-evidence.test.ts'],
|
||||
'test/fixtures/codex-review/**': ['test/codex-hardening.test.ts', 'test/outside-review-severity.test.ts', 'test/outside-voice-evidence.test.ts', 'test/skill-validation.test.ts'],
|
||||
'test/fixtures/codex-sandbox/**': ['test/codex-eval-recording.test.ts', 'test/codex-model-probe.test.ts', 'test/outside-review-result.test.ts', 'test/outside-voice-invocation.test.ts'],
|
||||
'test/fixtures/cyber-policy/**': ['test/outside-review-cyber-policy.test.ts', 'test/review-pass.test.ts'],
|
||||
'test/fixtures/cyber-policy/**': ['test/outside-review-cyber-policy.test.ts', 'test/review-pass-voice-failures.test.ts'],
|
||||
'test/fixtures/context-bill/**': ['test/context-bill.test.ts', 'test/context-budget-ratchet.test.ts'],
|
||||
'test/fixtures/context-budget.json': ['test/helpers/capture-context-budget.ts', 'test/test-value-bar.test.ts'],
|
||||
'test/fixtures/context-restore-fragment-match-captures.json': ['test/context-restore-fragment-verdict.test.ts'],
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
/** Shared fixtures for the review-pass tests: the manifest builder, a feature-branch repository, a fake Capy host whose shell is real, and the pass program runner. */
|
||||
import { expect } from 'bun:test';
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import * as fs from 'node:fs';
|
||||
import * as os from 'node:os';
|
||||
import * as path from 'node:path';
|
||||
import { sectionTexts } from '../../lib/review-brief';
|
||||
import { buildManifest, markReader, type Manifest } from '../../lib/review-pass';
|
||||
import type { Dispatch } from '../../lib/review-depth';
|
||||
|
||||
export const ROOT = path.resolve(import.meta.dir, '..', '..');
|
||||
export const BIN = path.join(ROOT, 'bin');
|
||||
export const texts = sectionTexts(ROOT);
|
||||
export const SHA = 'a'.repeat(40);
|
||||
export const spec = (name: string, exclude: string[] = []): Dispatch => ({ role: 'specialist', name, effort: 'full', exclude });
|
||||
|
||||
export function tmp(prefix: string) { return fs.mkdtempSync(path.join(os.tmpdir(), prefix)); }
|
||||
export function manifest(dispatches: Dispatch[], o: Partial<Parameters<typeof buildManifest>[0]> = {}): Manifest {
|
||||
const out = tmp('rp-out-');
|
||||
const root = tmp('rp-root-');
|
||||
fs.writeFileSync(path.join(root, 'package.json'), '{}');
|
||||
return buildManifest({ pass: 'p1', out, ledger: path.join(out, 'ledger.jsonl'), base: 'main', diffBase: SHA, root, checklistRoot: ROOT, dispatches, next: 'full', planLines: [], ...o });
|
||||
}
|
||||
export const collectAll = (m: Manifest, stage: string) => { for (const r of m.readers.filter(x => x.stage === stage)) { markReader(m, r.reader, 'intent'); markReader(m, r.reader, 'created', { path: '9' }); markReader(m, r.reader, 'collected'); } };
|
||||
|
||||
export function writeManifestFile(m: Manifest): string {
|
||||
const f = path.join(m.out, 'pass-manifest.json');
|
||||
fs.writeFileSync(f, JSON.stringify(m));
|
||||
return f;
|
||||
}
|
||||
|
||||
/** A repository on a feature branch with enough runtime lines for a full plan. */
|
||||
/** A checkout whose history shares no commit with repo()'s, standing in for a project's default checkout of another repository. */
|
||||
export function unrelated(env: NodeJS.ProcessEnv): string {
|
||||
const dir = fs.realpathSync(tmp('rp-other-'));
|
||||
const r = spawnSync('bash', ['-c', 'git init -q -b main && echo other > o.txt && git add -A && git commit -qm other'], { cwd: dir, env, encoding: 'utf8', timeout: 60_000 });
|
||||
if (r.status !== 0) throw new Error(r.stderr);
|
||||
return dir;
|
||||
}
|
||||
|
||||
export function repo(): { dir: string; env: NodeJS.ProcessEnv } {
|
||||
const dir = tmp('rp-repo-');
|
||||
const env = { ...process.env, PATH: BIN + path.delimiter + process.env.PATH, GSTACK_STATE_ROOT: path.join(dir, '.state'), GSTACK_SWEEP_ROOTS: dir, GIT_AUTHOR_NAME: 't', GIT_AUTHOR_EMAIL: 't@t', GIT_COMMITTER_NAME: 't', GIT_COMMITTER_EMAIL: 't@t' };
|
||||
const sh = (c: string) => { const r = spawnSync('bash', ['-c', c], { cwd: dir, env, encoding: 'utf8', timeout: 60_000 }); if (r.status !== 0) throw new Error(r.stderr); };
|
||||
sh("git init -q -b main && echo '{}' > package.json && mkdir -p src && echo 'export const a = 1;' > src/a.ts && echo .state > .gitignore && git add -A && git commit -qm base && git checkout -qb feat");
|
||||
sh('for i in $(seq 1 80); do echo "export const v$i = $i;" >> src/a.ts; done && git commit -qam feat');
|
||||
return { dir, env };
|
||||
}
|
||||
|
||||
export interface Sub { title: string; prompt: string; status: string; polls: number; model?: unknown; summary?: string; late?: boolean; error?: string }
|
||||
/** A fake Capy host: the shell is real (the repository's bins), subagents are scripted. */
|
||||
export const cleanReply = (title: string) => (title.endsWith('outside-voice') ? 'Recommendation: ship as-is because no finding survived' : 'NO FINDINGS');
|
||||
/** The REVIEWED_TREE line a reader prints from dir (its brief's checkout when it follows the workspace paragraph); '' outside a checkout. */
|
||||
export function treeLine(dir: string): string {
|
||||
if (!dir) return '';
|
||||
const git = (a: string[]) => spawnSync('git', ['-C', dir, ...a], { encoding: 'utf8', timeout: 30_000 });
|
||||
const tree = git(['rev-parse', 'HEAD^{tree}']), top = git(['rev-parse', '--show-toplevel']);
|
||||
return tree.status === 0 && top.status === 0 ? `REVIEWED_TREE: ${tree.stdout.trim()} ${top.stdout.trim()}\n` : '';
|
||||
}
|
||||
export const briefDir = (prompt: string) => /Workspace: the checkout under review is (.+?)\. Your shell and file tools/.exec(prompt)?.[1] ?? '';
|
||||
export function host(dir: string, env: NodeJS.ProcessEnv, o: { output?: (title: string) => string; reportFrom?: (title: string) => string; fail?: (title: string) => boolean; reject?: (title: string) => boolean; createThrows?: (title: string) => 'before' | 'after' | undefined; pollsToFinish?: number; lateSummary?: boolean; hang?: (title: string) => boolean; stopped?: (title: string) => boolean; keepSummary?: boolean; epoch?: number; error?: (title: string) => string | undefined } = {}) {
|
||||
let clock = 0;
|
||||
const subs = new Map<string, Sub>();
|
||||
const creates: Sub[] = [];
|
||||
const starts: number[][] = [];
|
||||
const stops: string[] = [];
|
||||
const reply = (s: Sub) => treeLine(o.reportFrom?.(s.title) ?? briefDir(s.prompt)) + (o.output?.(s.title) ?? cleanReply(s.title));
|
||||
const advance = () => {
|
||||
for (const s of subs.values()) {
|
||||
if (s.late && !s.summary) { s.summary = reply(s); continue; }
|
||||
if (s.status !== 'working' || o.hang?.(s.title)) continue;
|
||||
if (++s.polls < (o.pollsToFinish ?? 1)) continue;
|
||||
if (o.error?.(s.title)) { s.status = 'failed'; s.error = o.error(s.title); if (o.keepSummary) s.summary = reply(s); }
|
||||
else if (o.stopped?.(s.title)) { s.status = 'stopped'; if (o.keepSummary) s.summary = reply(s); }
|
||||
else if (o.fail?.(s.title)) { s.status = 'failed'; if (o.keepSummary) s.summary = reply(s); }
|
||||
else if (o.lateSummary && !s.late) { s.status = 'done'; s.late = true; }
|
||||
else { s.status = 'done'; s.summary = reply(s); }
|
||||
}
|
||||
};
|
||||
const tools = {
|
||||
capy: {
|
||||
bash: async ({ command }: { command: string }) => {
|
||||
const r = spawnSync('bash', ['-c', command], { cwd: dir, env, encoding: 'utf8', timeout: 120_000, maxBuffer: 64 * 1024 * 1024 });
|
||||
return { exit_code: r.status ?? 1, output: (r.stdout ?? '') + (r.stderr ?? '') };
|
||||
},
|
||||
write: async ({ path: p, content }: { path: string; content: string }) => { fs.mkdirSync(path.dirname(p), { recursive: true }); fs.writeFileSync(p, content); return { path: p }; },
|
||||
},
|
||||
subagent: {
|
||||
create: async ({ tasks, start }: { tasks: Array<{ title: string; prompt: string }>; start: { machine: string; model?: unknown } }) => {
|
||||
const t = tasks[0]!;
|
||||
const mode = o.createThrows?.(t.title);
|
||||
if (mode === 'before') throw new Error('create lost before it ran');
|
||||
expect(start.machine).toBe('shared');
|
||||
const index = subs.size + 1;
|
||||
const rejected = !!o.reject?.(t.title) && !creates.some(c => c.title === t.title);
|
||||
const s: Sub = { title: t.title, prompt: t.prompt, status: rejected ? 'draft' : 'working', polls: 0, model: start.model };
|
||||
subs.set(String(index), s);
|
||||
creates.push(s);
|
||||
if (mode === 'after') throw new Error('create result lost');
|
||||
return { tasks: [{ index, title: t.title }], ...(rejected ? { rejected: [{ index, error: 'cap' }] } : {}) };
|
||||
},
|
||||
start: async ({ indices, model }: { indices: number[]; model?: unknown }) => { starts.push(indices); for (const i of indices) { const s = subs.get(String(i))!; s.status = 'working'; if (model) s.model = model; } return { started: indices.map(index => ({ index })), rejected: [] }; },
|
||||
list: async () => { advance(); return { tasks: [...subs].map(([p, s]) => ({ path: p, title: s.title, status: s.status })), total: subs.size }; },
|
||||
get: async ({ path: p }: { path: string }) => ({ path: p, status: subs.get(p)!.status, summary: subs.get(p)!.summary, ...(subs.get(p)!.error ? { latest_error: subs.get(p)!.error } : {}) }),
|
||||
stop: async ({ paths }: { paths: string[] }) => { stops.push(...paths); for (const p of paths) subs.get(p)!.status = 'stopped'; return { results: paths.map(p => ({ path: p, ok: true })) }; },
|
||||
},
|
||||
thread: { get: async () => ({ cost: { tokens: 1000 + clock, credits: 1 + clock / 1000 } }) },
|
||||
};
|
||||
return { tools, subs, creates, starts, stops, sleep: async (ms: number) => { clock += ms; }, now: async () => (o.epoch ?? 1_000_000) + clock };
|
||||
}
|
||||
|
||||
export const PROGRAM = fs.readFileSync(path.join(ROOT, 'lib/capy-review-pass.js'), 'utf8');
|
||||
export const AsyncFunction = Object.getPrototypeOf(async () => {}).constructor as new (...a: string[]) => (...v: unknown[]) => Promise<string>;
|
||||
export async function runPass(h: ReturnType<typeof host>, input: Record<string, unknown>): Promise<string> {
|
||||
return new AsyncFunction('tools', 'sleep', 'now', 'input', PROGRAM)(h.tools, h.sleep, h.now, { startedAt: await h.now(), laneModel: 'anthropic/claude-opus-5-5', ...input });
|
||||
}
|
||||
export const bin = (dir: string, env: NodeJS.ProcessEnv, a: string[]) => spawnSync(path.join(BIN, 'gstack-review-dispatch'), a, { cwd: dir, env, encoding: 'utf8', timeout: 60_000 });
|
||||
export const briefDirOf = (h: ReturnType<typeof host>, title: string) => briefDir(h.creates.find(c => c.title === title)?.prompt ?? '');
|
||||
@@ -0,0 +1,262 @@
|
||||
/**
|
||||
* The Capy pass program's later steps: ids, budget notes, extras, fix-checks, repeat and scoped passes.
|
||||
* Split from test/review-pass.test.ts; shared fixtures live in test/helpers/review-pass-harness.ts.
|
||||
*/
|
||||
import { describe, expect, test } from 'bun:test';
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import * as fs from 'node:fs';
|
||||
import * as path from 'node:path';
|
||||
import { withWorkspace } from '../lib/review-brief';
|
||||
import { PARENT_ONLY_QA, type Manifest } from '../lib/review-pass';
|
||||
import { ROOT, BIN, spec, manifest, repo, host, runPass, bin } from './helpers/review-pass-harness';
|
||||
|
||||
describe('Capy pass program (fake host, real bins)', () => {
|
||||
test('Step 11 notes its own growth from its first dispatch, not from the pass\'s starting reading', async () => {
|
||||
const { dir, env } = repo();
|
||||
const rec = path.join(dir, '.state/rec.md');
|
||||
fs.mkdirSync(path.dirname(rec), { recursive: true });
|
||||
expect(spawnSync('bash', ['-c', 'gstack-ship-budget start --record "$1" --mode observe --reading 1000 --credits 1', '_', rec], { cwd: dir, env, encoding: 'utf8', timeout: 60_000 }).status).toBe(0);
|
||||
const h = host(dir, env, { pollsToFinish: 3 });
|
||||
const get = h.tools.thread.get;
|
||||
let last = 0;
|
||||
h.tools.thread.get = async () => { const r = await get(); last = r.cost.tokens; return r; };
|
||||
const out = path.join(dir, '.state/run/p1');
|
||||
const base = { base: 'main', out, pass: 'x17p1', planFlags: ['--depth-floor', 'full'], record: rec, jam: 'jam_test' };
|
||||
expect(await runPass(h, { ...base, step: '9' })).toContain('NEXT: judge (Phase 4)');
|
||||
const models = { 'outside-voice': { model_id: 'openai/gpt-6.1-sol' }, 'adversarial-native': { model_id: 'anthropic/claude-opus-5-5', reasoning_mode: 'high' } };
|
||||
const res = await runPass(h, { ...base, step: '11', stage: 'voices', models });
|
||||
const m = JSON.parse(fs.readFileSync(path.join(out, 'pass-manifest.json'), 'utf8'));
|
||||
expect(m.before_voices.tokens).toBeGreaterThan(m.before.tokens);
|
||||
const note = res.split('\n').find(l => l.startsWith('NOTE: '))!;
|
||||
expect(Number(note.match(/readers_tokens=(\d+)/)![1])).toBe(last - m.before_voices.tokens);
|
||||
}, 240_000);
|
||||
|
||||
test('effort=medium readers run the lane model at medium reasoning; without laneModel or models the pass stops before creating any', async () => {
|
||||
const { dir, env } = repo();
|
||||
const h = host(dir, env);
|
||||
const base = { base: 'main', out: path.join(dir, '.state/run/p1'), pass: 'x11p1', planFlags: ['--depth-floor', 'full'] };
|
||||
expect(await runPass(h, { ...base, laneModel: undefined })).toMatch(/STOP: specialist\S* runs at effort=medium, which needs input.laneModel/);
|
||||
expect(h.creates).toHaveLength(0);
|
||||
expect(await runPass(h, base)).toContain('NEXT: judge (Phase 4)');
|
||||
const m = JSON.parse(fs.readFileSync(path.join(base.out, 'pass-manifest.json'), 'utf8')) as Manifest;
|
||||
for (const r of m.readers.filter(x => x.stage !== 'voices')) {
|
||||
const want = r.effort === 'medium' ? { model_id: 'anthropic/claude-opus-5-5', reasoning_mode: 'medium' } : undefined;
|
||||
expect(h.creates.find(c => c.title === r.title)!.model).toEqual(want);
|
||||
}
|
||||
expect(m.readers.some(r => r.effort === 'medium')).toBe(true);
|
||||
}, 180_000);
|
||||
|
||||
// Value: protects=once Phase 2 starts the run's parts, the pass program carries the next phase's section parts in the room its own return leaves, so Phase 4 needs no read call of its own, and it never adds them to a run that did not start them; fails_when=the pass returns parts without a started run, overruns 32 KB, puts them after its NEXT line, or repeats a part a poll return already carried;
|
||||
// why_new=GSTA-167 calls plan C5 in code; seam=none; no_claim=how much room real reader outputs leave
|
||||
test('a started run gets the next parts inside each poll and the finished pass, once each and before NEXT', async () => {
|
||||
const { dir, env } = repo();
|
||||
const out = path.join(dir, '.state/run/p1');
|
||||
const h = host(dir, env, { pollsToFinish: 30 });
|
||||
const input = { base: 'main', out, pass: 'x12p1', planFlags: ['--depth-floor', 'full'] };
|
||||
expect(await runPass(h, input)).not.toContain('PART: ');
|
||||
fs.mkdirSync(path.join(dir, '.state/run/parts'), { recursive: true });
|
||||
fs.writeFileSync(path.join(dir, '.state/run/parts/state.json'), JSON.stringify({ returned: ['review-9', 'review-9.1', 'review-red-team', 'review-9.2.1'] }));
|
||||
const ids: string[] = [];
|
||||
let res = '';
|
||||
for (let i = 0; i < 8 && !res.includes('NEXT: judge'); i++) {
|
||||
res = await runPass(h, input);
|
||||
expect(res.length).toBeLessThanOrEqual(32000);
|
||||
const got = [...res.matchAll(/^PART: (\S+) /gm)].map(m => m[1]!);
|
||||
if (got.length) expect(res.lastIndexOf('PART_END: ')).toBeLessThan(res.lastIndexOf('\nNEXT: '));
|
||||
ids.push(...got);
|
||||
}
|
||||
expect(res).toContain('NEXT: judge (Phase 4)');
|
||||
expect(ids.length).toBeGreaterThan(0);
|
||||
expect(new Set(ids).size).toBe(ids.length);
|
||||
expect(ids[0]).toBe('plan-8.1-8.2');
|
||||
}, 240_000);
|
||||
|
||||
// Value: protects=the loader's input is filled as SKILL.md reads it: extras as JSON, the checkout named by cwd, and a reader whose summary lands a tick after its done status is collected, not stopped; fails_when=extras must be a file path (replay C2-34: BRIEF_RENDER_FAILED [object Object]), the bins run in the jam's directory instead of the checkout (C2-34: a wrapper launch file), or a done reader without its summary yet stops the pass (C2-34: "finished with no output", one extra call);
|
||||
// why_new=replay C2-34 (GSTA-193) on PR 2; seam=none; no_claim=the host's status timing beyond one late summary
|
||||
test('extras as JSON, the checkout as cwd, and a late summary all run through without a STOP', async () => {
|
||||
const { dir, env } = repo();
|
||||
const out = path.join(dir, '.state/run/p1');
|
||||
fs.mkdirSync(out, { recursive: true });
|
||||
fs.writeFileSync(path.join(out, 'plan.prompt.md'), 'Plan completion brief');
|
||||
const h = host(dir, env, { lateSummary: true });
|
||||
const res = await runPass(h, { base: 'main', out, pass: 'x13p1', cwd: dir, planFlags: ['--depth-floor', 'full'],
|
||||
extras: [{ name: 'plan', prompt_file: path.join(out, 'plan.prompt.md'), model: { model_id: 'anthropic/claude-haiku-5-5', reasoning_mode: 'low' } }] });
|
||||
expect(res).not.toContain('STOP:');
|
||||
expect(res).toContain('NEXT: judge (Phase 4)');
|
||||
expect(h.creates.find(c => c.title === 'ship x13p1 audit/plan')!.prompt).toBe(withWorkspace('Plan completion brief', fs.realpathSync(dir)));
|
||||
}, 180_000);
|
||||
|
||||
// Value: protects=Step 9.2.1's probes stay the parent's, as its section says, so QA coverage is never a subagent's refusal; fails_when=the
|
||||
// pass program dispatches a QA extra (C4-36, C5-36: the QA reader refused both passes, "parent-only", and the parent ran the probes after it);
|
||||
// why_new=extras took any prompt (GST-450); seam=the pass program; no_claim=the parent's probes themselves (DRIVER Phase 4)
|
||||
test('a QA extra, by name or by its section\'s parent-only brief, stops the pass before any reader is created', async () => {
|
||||
const section = fs.readFileSync(path.join(ROOT, 'ship/sections/review-army.md'), 'utf8');
|
||||
expect(section).toContain(PARENT_ONLY_QA);
|
||||
const brief = section.slice(section.indexOf('### Step 9.2.1'), section.indexOf('### Step 9.3'));
|
||||
for (const [name, text] of [['qa', 'QA brief'], ['exploratory', brief]] as const) {
|
||||
const { dir, env } = repo();
|
||||
const out = path.join(dir, '.state/run/p1');
|
||||
fs.mkdirSync(out, { recursive: true });
|
||||
fs.writeFileSync(path.join(out, name + '.prompt.md'), text);
|
||||
const h = host(dir, env);
|
||||
const res = await runPass(h, { base: 'main', out, pass: 'x14p1', planFlags: ['--depth-floor', 'full'],
|
||||
extras: [{ name, prompt_file: path.join(out, name + '.prompt.md'), model: { model_id: 'anthropic/claude-haiku-5-5', reasoning_mode: 'low' } }] });
|
||||
expect([name, res.includes('STOP:'), res.includes("Step 9.2.1 is the parent's report-only discovery"), h.creates.length]).toEqual([name, true, true, 0]);
|
||||
}
|
||||
}, 240_000);
|
||||
|
||||
test('decision 3.5 runs in the program: one fix-check reader whose prompt is the render CLI brief byte for byte, sent and collected', async () => {
|
||||
const { dir, env } = repo();
|
||||
const out = path.join(dir, '.state/run/fc');
|
||||
const files = path.join(dir, '.state/fc');
|
||||
fs.mkdirSync(files, { recursive: true });
|
||||
const fc: Record<string, string> = {};
|
||||
for (const [k, v] of [['fix_list', '1. src/a.ts: guard v80\n'], ['hunks', 'diff --git a/src/a.ts b/src/a.ts\n+export const v81 = 81;\n'], ['tests', 'bun test: 3 pass, 0 fail\n'], ['callers', 'none\n']]) { fc[k] = path.join(files, k + '.txt'); fs.writeFileSync(fc[k]!, v!); }
|
||||
const planFlags = ['--pass', '1', '--last', 'full', '--fixed-below'];
|
||||
const missing = await runPass(host(dir, env), { base: 'main', out: path.join(dir, '.state/run/fc0'), pass: 'x19fc0', planFlags });
|
||||
expect(missing).toContain('STOP: gstack-review-dispatch pass exited');
|
||||
expect(missing).toContain('the plan dispatches a fix-check: pass needs --fix-list, --hunks and --tests');
|
||||
const h = host(dir, env);
|
||||
const res = await runPass(h, { base: 'main', out, pass: 'x19fc', planFlags, fixCheck: fc, logStart: ['review-fix-check'] });
|
||||
expect(res).toMatch(/REVIEW_LOG_START: review-fix-check token=\S+/);
|
||||
expect(res).toContain('NEXT: judge (Phase 4)');
|
||||
expect(h.creates.map(c => c.title)).toEqual(['ship x19fc fix-check']);
|
||||
const cli = bin(dir, env, ['render', '--role', 'fix-check', '--out', path.join(dir, '.state/cli'), '--fix-list', fc.fix_list!, '--hunks', fc.hunks!, '--tests', fc.tests!, '--callers', fc.callers!]);
|
||||
expect(cli.status).toBe(0);
|
||||
expect(h.creates[0]!.prompt).toBe(fs.readFileSync(path.join(dir, '.state/cli/fix-check.prompt.md'), 'utf8'));
|
||||
expect(h.creates[0]!.prompt).toContain('You are the fix-check reviewer');
|
||||
const v = bin(dir, env, ['verify', '--ledger', path.join(out, 'review-ledger.jsonl')]).stdout;
|
||||
expect(v).toMatch(/^BRIEF fix-check MATCH rendered=(\w+) sent=\1$/m);
|
||||
expect(v).toMatch(/^OUTPUT fix-check MATCH /m);
|
||||
}, 240_000);
|
||||
|
||||
// Value: protects=decision 3.5's fix-check takes a review-fix-check start token even when the parent passes the Capy skill's
|
||||
// logStart ["review"], so its row is never a pass and a review_loop_exception can follow it; fails_when=the fix-check pass logs a
|
||||
// review start; why_new=ggstack#52 (GST-1031): a scoped fix-check logged as review counted as a second pass; seam=the pass program;
|
||||
// no_claim=what the parent writes in the row
|
||||
test('a fix-check pass given logStart ["review"] takes the review-fix-check start', async () => {
|
||||
const { dir, env } = repo();
|
||||
const files = path.join(dir, '.state/fc');
|
||||
fs.mkdirSync(files, { recursive: true });
|
||||
const fc: Record<string, string> = {};
|
||||
for (const [k, v] of [['fix_list', '1. src/a.ts: guard v80\n'], ['hunks', 'diff --git a/src/a.ts b/src/a.ts\n+export const v81 = 81;\n'], ['tests', 'bun test: 3 pass, 0 fail\n']]) { fc[k] = path.join(files, k + '.txt'); fs.writeFileSync(fc[k]!, v!); }
|
||||
const res = await runPass(host(dir, env), { base: 'main', out: path.join(dir, '.state/run/fcr'), pass: 'x52fc', planFlags: ['--pass', '1', '--last', 'full', '--fixed-below'], fixCheck: fc, logStart: ['review'] });
|
||||
expect(res).toMatch(/REVIEW_LOG_START: review-fix-check token=\S+/);
|
||||
expect(res).not.toMatch(/REVIEW_LOG_START: review token=/);
|
||||
}, 240_000);
|
||||
|
||||
test('Step 11 records one start per row it logs, even when two rows share a skill (native and outside adversarial-review)', async () => {
|
||||
const { dir, env } = repo();
|
||||
const out = path.join(dir, '.state/run/p1');
|
||||
const h = host(dir, env);
|
||||
const base = { base: 'main', out, pass: 'x20p1', planFlags: ['--depth-floor', 'full'] };
|
||||
expect(await runPass(h, base)).toContain('NEXT: judge (Phase 4)');
|
||||
const models = { 'outside-voice': { model_id: 'openai/gpt-6.1-sol' }, 'adversarial-native': { model_id: 'anthropic/claude-opus-5-5', reasoning_mode: 'high' } };
|
||||
const res = await runPass(h, { ...base, stage: 'voices', models, logStart: ['adversarial-review', 'adversarial-review'] });
|
||||
const starts = res.split('\n').filter(l => l.startsWith('REVIEW_LOG_START: adversarial-review'));
|
||||
expect(starts.length).toBe(2);
|
||||
expect(new Set(starts.map(l => l.split('token=')[1])).size).toBe(2);
|
||||
const m = JSON.parse(fs.readFileSync(path.join(out, 'pass-manifest.json'), 'utf8'));
|
||||
expect(Object.keys(m.log_starts).sort()).toEqual(['voices:adversarial-review', 'voices:adversarial-review#2']);
|
||||
const again = await runPass(h, { ...base, stage: 'voices', models, logStart: ['adversarial-review', 'adversarial-review'] });
|
||||
expect(again).not.toContain('REVIEW_LOG_START:');
|
||||
}, 240_000);
|
||||
|
||||
test('a repeat pass reads the range: diffBase reaches the specialists and the Red Team, byte for byte the render CLI at that base', async () => {
|
||||
const { dir, env } = repo();
|
||||
const sh = (c: string) => spawnSync('bash', ['-c', c], { cwd: dir, env, encoding: 'utf8', timeout: 60_000 });
|
||||
const rangeBase = sh('git rev-parse HEAD').stdout.trim();
|
||||
expect(sh('echo "export const fix = 1;" >> src/a.ts && git commit -qam fix').status).toBe(0);
|
||||
const out = path.join(dir, '.state/run/p2');
|
||||
const h = host(dir, env);
|
||||
expect(await runPass(h, { base: 'main', out, pass: 'x21p2', diffBase: rangeBase, planFlags: ['--depth-floor', 'full'] })).toContain('NEXT: judge (Phase 4)');
|
||||
const m = JSON.parse(fs.readFileSync(path.join(out, 'pass-manifest.json'), 'utf8'));
|
||||
expect(m.diff_base).toBe(rangeBase);
|
||||
const spec = m.readers.find((r: { role?: string }) => r.role === 'specialist-batched');
|
||||
const cli = bin(dir, env, ['render', '--role', 'specialist-batched', '--out', path.join(dir, '.state/cli'), '--diff-base', rangeBase, '--checklists', spec.checklists.join(','), '--stack', m.stack, '--test-fw', m.test_fw]);
|
||||
expect(cli.status, cli.stderr).toBe(0);
|
||||
expect(h.creates.find(c => c.title === 'ship x21p2 specialist-batched')!.prompt).toBe(fs.readFileSync(path.join(dir, '.state/cli/specialist-batched.prompt.md'), 'utf8'));
|
||||
expect(h.creates.find(c => c.title === 'ship x21p2 red-team')!.prompt).toContain('DIFF_BASE=' + rangeBase);
|
||||
}, 240_000);
|
||||
|
||||
// Value: protects=the pass program dispatches the owner's granted fix-check from the plan, as decision 3.5 runs any fix-check, instead of PASS: none; fails_when=a recorded grant still prints PASS: none next=stop and the lane renders, sends and collects the fix-check by hand (C6-36 after-opus-grant);
|
||||
// why_new=GST-967; seam=the pass program; no_claim=the fix-check reviewer's verdict
|
||||
test('GST-967: a recorded grant after round 2 runs its one scoped fix-check through the program', async () => {
|
||||
const { dir, env } = repo();
|
||||
const head = spawnSync('git', ['rev-parse', 'HEAD'], { cwd: dir, encoding: 'utf8', timeout: 10_000 }).stdout.trim();
|
||||
const add = spawnSync(path.join(BIN, 'gstack-approvals'), ['add', '--ask', `Owner grant: one scoped fix-check after round 2 (review_loop_grant ${head.slice(0, 12)})`, '--words', 'one scoped fix-check after round 2', '--by', 'GStack Minder', '--scope', 'this /ship invocation', '--json'], { cwd: dir, env: { ...env, GSTACK_APPROVALS_MIRROR: '0' }, encoding: 'utf8', timeout: 60_000 });
|
||||
expect(add.status, add.stderr).toBe(0);
|
||||
const id = JSON.parse(add.stdout).added[0] as string;
|
||||
const files = path.join(dir, '.state/gfc');
|
||||
fs.mkdirSync(files, { recursive: true });
|
||||
const fc: Record<string, string> = {};
|
||||
for (const [k, v] of [['fix_list', '1. src/a.ts: guard v80\n'], ['hunks', 'diff --git a/src/a.ts b/src/a.ts\n+export const v81 = 81;\n'], ['tests', 'bun test: 3 pass, 0 fail\n'], ['callers', 'none\n']]) { fc[k] = path.join(files, k + '.txt'); fs.writeFileSync(fc[k]!, v!); }
|
||||
const h = host(dir, env);
|
||||
const res = await runPass(h, { base: 'main', out: path.join(dir, '.state/run/gfc'), pass: 'x30gfc', planFlags: ['--pass', '2', '--last', 'full', '--fixed-blocking', '--range-base', head, '--grant', id], fixCheck: fc, logStart: ['review-fix-check'] });
|
||||
expect(res).not.toContain('PASS: none');
|
||||
expect(res).toContain(`NEXT: fix-check (the owner's grant ${id}`);
|
||||
expect(h.creates.map(c => c.title)).toEqual(['ship x30gfc fix-check']);
|
||||
expect(res).toContain('NEXT: judge (Phase 4)');
|
||||
}, 240_000);
|
||||
|
||||
// Value: protects=the Capy pass program runs a scoped repeat with no fix-check files, dispatches its Red Team and leaves the fix-check to Step 3.5 as GST-619 does on the CLI; fails_when=the program stops a scoped plan for missing files or creates a fix-check reader in the scoped manifest;
|
||||
// why_new=#3670 Step 11 (adversarial 1, red team 1), re-scoped to GST-619's model in the merge of main; seam=none; no_claim=the Step 3.5 fix-check itself
|
||||
test('a scoped repeat runs without fixCheck files and leaves its fix-check to Step 3.5 (GST-619)', async () => {
|
||||
const { dir, env } = repo();
|
||||
const sh = (c: string) => spawnSync('bash', ['-c', c], { cwd: dir, env, encoding: 'utf8', timeout: 60_000 });
|
||||
const rangeBase = sh('git rev-parse HEAD').stdout.trim();
|
||||
expect(sh('echo "export const fix = 1;" >> src/a.ts && git commit -qam fix').status).toBe(0);
|
||||
const planFlags = ['--pass', '1', '--last', 'full', '--fixed-blocking', '--pass1-depth', 'standard', '--range-base', rangeBase];
|
||||
const h = host(dir, env);
|
||||
const res = await runPass(h, { base: 'main', out: path.join(dir, '.state/run/s1'), pass: 'x22s1', diffBase: rangeBase, planFlags });
|
||||
expect(res).toContain('next=scoped');
|
||||
expect(res).not.toContain('STOP:');
|
||||
expect(res).toContain('FIX_CHECK: planned');
|
||||
expect(h.creates.map(c => c.title)).not.toContain('ship x22s1 fix-check');
|
||||
expect(h.creates.map(c => c.title)).toContain('ship x22s1 red-team');
|
||||
}, 240_000);
|
||||
|
||||
// Value: protects=a scoped pass run through the Capy program as the driver now says, with no diffBase, gives the pending Step 11 voices the merge base and only the Red Team the fix range (GST-619); fails_when=the program sends a scoped pass a base of its own or the voices read the range before Step 11 ran;
|
||||
// why_new=#3670 merge fix-check (row 454); the driver test "a scoped repeat pass passes no diffBase" is the failing-first half; seam=none; no_claim=an explicit --diff-base, which GST-619 lets win
|
||||
test('a scoped pass run as the driver says keeps the merge base for the Step 11 voices; only the Red Team reads the fix range', async () => {
|
||||
const { dir, env } = repo();
|
||||
const sh = (c: string) => spawnSync('bash', ['-c', c], { cwd: dir, env, encoding: 'utf8', timeout: 60_000 });
|
||||
const mergeBase = sh('git merge-base main HEAD').stdout.trim();
|
||||
const rangeBase = sh('git rev-parse HEAD').stdout.trim();
|
||||
expect(sh('echo "export const fix = 2;" >> src/a.ts && git commit -qam fix').status).toBe(0);
|
||||
const out = path.join(dir, '.state/run/s2');
|
||||
const planFlags = ['--pass', '1', '--last', 'full', '--fixed-blocking', '--pass1-depth', 'standard', '--range-base', rangeBase];
|
||||
const res = await runPass(host(dir, env), { base: 'main', out, pass: 'x22s2', planFlags });
|
||||
expect(res).toContain('next=scoped');
|
||||
const m = JSON.parse(fs.readFileSync(path.join(out, 'pass-manifest.json'), 'utf8')) as { diff_base: string; readers: { role?: string; stage: string; diff_base?: string }[] };
|
||||
expect(m.diff_base).toBe(mergeBase);
|
||||
expect(m.readers.find(r => r.role === 'red-team')!.diff_base).toBe(rangeBase);
|
||||
const voices = m.readers.filter(r => r.stage === 'voices');
|
||||
expect(voices.length).toBeGreaterThan(0);
|
||||
for (const v of voices) expect(v.diff_base ?? m.diff_base).toBe(mergeBase);
|
||||
}, 240_000);
|
||||
|
||||
// Value: protects=the program's final NEXT line survives a return that its reader outputs push to the 32 KB cap, and a pass whose out is not <run dir>/<pass dir> says it skipped the parts; fails_when=finish() cuts the tail line, the room ignores the parts trailer, or parts are skipped without a line;
|
||||
// why_new=#3670 Step 11 (outside voice 2, adversarial 2 and 6); seam=none; no_claim=what the parent does with a capped return
|
||||
test('a near-cap return still ends with its NEXT line, and an odd out prints PARTS: skipped', async () => {
|
||||
const { dir, env } = repo();
|
||||
const out = path.join(dir, '.state/run/p1');
|
||||
fs.mkdirSync(path.join(dir, '.state/run/parts'), { recursive: true });
|
||||
fs.writeFileSync(path.join(dir, '.state/run/parts/state.json'), JSON.stringify({ returned: [] }));
|
||||
const big = host(dir, env, { output: () => 'x'.repeat(15_900) + '\nNO FINDINGS' });
|
||||
const res = await runPass(big, { base: 'main', out, pass: 'x23p1', planFlags: ['--depth-floor', 'full'] });
|
||||
expect(res.length).toBeLessThanOrEqual(32000);
|
||||
expect(res.trimEnd().split('\n').at(-1)).toBe('NEXT: judge (Phase 4)');
|
||||
const odd = await runPass(host(dir, env), { base: 'main', out: path.join(dir, '.state/run/deep/p1'), pass: 'x23p2', planFlags: ['--depth-floor', 'full'] });
|
||||
expect(odd).toMatch(/^PARTS: skipped \(/m);
|
||||
expect(odd.trimEnd().split('\n').at(-1)).toBe('NEXT: judge (Phase 4)');
|
||||
}, 240_000);
|
||||
|
||||
test('a plan with no reviewer pass dispatches nothing and passes NEXT through', async () => {
|
||||
const { dir, env } = repo();
|
||||
const h = host(dir, env);
|
||||
const res = await runPass(h, { base: 'main', out: path.join(dir, '.state/run/p2'), pass: 'x9p2', planFlags: ['--pass', '1', '--last', 'full'] });
|
||||
expect(res).toContain('PASS: none next=');
|
||||
expect(h.creates).toHaveLength(0);
|
||||
}, 120_000);
|
||||
});
|
||||
@@ -0,0 +1,288 @@
|
||||
/**
|
||||
* The Capy pass program against a fake host whose shell is real: staging, reruns, recovery and audit readers.
|
||||
* Split from test/review-pass.test.ts; shared fixtures live in test/helpers/review-pass-harness.ts.
|
||||
*/
|
||||
import { describe, expect, test } from 'bun:test';
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import * as fs from 'node:fs';
|
||||
import * as path from 'node:path';
|
||||
import { promptHash, withWorkspace } from '../lib/review-brief';
|
||||
import { type Manifest } from '../lib/review-pass';
|
||||
import { BIN, manifest, repo, host, PROGRAM, runPass, bin } from './helpers/review-pass-harness';
|
||||
|
||||
describe('Capy pass program (fake host, real bins)', () => {
|
||||
test('gstack-review-dispatch program serves the checked-in file verbatim with its sha', () => {
|
||||
const r = spawnSync(path.join(BIN, 'gstack-review-dispatch'), ['program'], { encoding: 'utf8', timeout: 30_000 });
|
||||
const [head, body] = r.stdout.split('\n');
|
||||
expect(head).toBe('PROGRAM: v1 sha256=' + promptHash(PROGRAM) + ' bytes=' + Buffer.byteLength(PROGRAM));
|
||||
expect(JSON.parse(body!)).toBe(PROGRAM);
|
||||
});
|
||||
|
||||
test('one pass: specialists, then the Red Team on their collected lines; every prompt is the rendered brief; the ledger verifies clean', async () => {
|
||||
const { dir, env } = repo();
|
||||
const out = path.join(dir, '.state/run/p1');
|
||||
const h = host(dir, env, { output: t => (t.endsWith('specialist-batched') ? 'High: src/a.ts:3 the export is untested' : 'NO FINDINGS') });
|
||||
const medium = { model_id: 'anthropic/claude-opus-5-5', reasoning_mode: 'medium' };
|
||||
const res = await runPass(h, { base: 'main', out, pass: 'x1p1', planFlags: ['--depth-floor', 'full'], models: { specialist: medium, 'red-team': medium } });
|
||||
expect(h.creates.every(c => JSON.stringify(c.model) === JSON.stringify(medium))).toBe(true);
|
||||
expect(res).toContain('NEXT: judge (Phase 4)');
|
||||
const m = JSON.parse(fs.readFileSync(path.join(out, 'pass-manifest.json'), 'utf8')) as Manifest;
|
||||
const active = m.readers.filter(r => r.stage !== 'voices');
|
||||
expect(h.creates.map(c => c.title)).toEqual(active.map(r => r.title));
|
||||
expect(h.creates.at(-1)!.title).toBe('ship x1p1 red-team');
|
||||
for (const r of active) expect(h.creates.find(c => c.title === r.title)!.prompt).toBe(fs.readFileSync(r.file!, 'utf8'));
|
||||
expect(h.creates.at(-1)!.prompt).toContain('the export is untested');
|
||||
expect(active.every(r => r.state === 'collected')).toBe(true);
|
||||
const merged = fs.readFileSync(m.merged, 'utf8').trim().split('\n').map(l => JSON.parse(l) as { id: string; label: string });
|
||||
fs.writeFileSync(path.join(out, 'judged.jsonl'), merged.map(l => JSON.stringify({ id: l.id, severity: l.label }) + '\n').join(''));
|
||||
expect(bin(dir, env, ['judge', '--ledger', m.ledger, '--merged', m.merged, '--judged', path.join(out, 'judged.jsonl')]).status).toBe(0);
|
||||
const v = bin(dir, env, ['verify', '--ledger', m.ledger]);
|
||||
expect(v.stdout).toContain('VERIFY: clean briefs=' + active.length);
|
||||
}, 180_000);
|
||||
|
||||
test('a pass past its 200 s window returns NEXT: poll and the rerun resumes without creating any reader twice', async () => {
|
||||
const { dir, env } = repo();
|
||||
const out = path.join(dir, '.state/run/p1');
|
||||
const h = host(dir, env, { pollsToFinish: 30 });
|
||||
const first = await runPass(h, { base: 'main', out, pass: 'x2p1', planFlags: ['--depth-floor', 'full'], logStart: ['review'] });
|
||||
expect(first).toContain('NEXT: poll');
|
||||
expect(first).toMatch(/REVIEW_LOG_START: review token=\S+/);
|
||||
expect(first).toMatch(/RUNNING: specialist-batched state=created path=1/);
|
||||
const created = h.creates.length;
|
||||
let res = '';
|
||||
for (let i = 0; i < 6 && !res.includes('NEXT: judge'); i++) res = await runPass(h, { base: 'main', out, pass: 'x2p1', planFlags: ['--depth-floor', 'full'], logStart: ['review'] });
|
||||
expect(res).toContain('NEXT: judge');
|
||||
expect(res).not.toContain('REVIEW_PLAN:');
|
||||
expect(res).not.toContain('REVIEW_LOG_START:');
|
||||
expect(new Set(h.creates.map(c => c.title)).size).toBe(h.creates.length);
|
||||
expect(h.creates.length).toBe(created + 1);
|
||||
}, 240_000);
|
||||
|
||||
test('a create whose result was lost is reconciled by title on resume; a create that never ran stops the pass as ambiguous', async () => {
|
||||
const { dir, env } = repo();
|
||||
let lost = true;
|
||||
const h = host(dir, env, { createThrows: t => (t.endsWith('specialist-batched') && lost ? (lost = false, 'after') : undefined) });
|
||||
const input = { base: 'main', out: path.join(dir, '.state/run/p1'), pass: 'x3p1', planFlags: ['--depth-floor', 'full'] };
|
||||
expect(await runPass(h, input)).toContain('STOP: pass program error: create result lost');
|
||||
expect(await runPass(h, input)).toContain('NEXT: judge');
|
||||
expect(h.creates.filter(c => c.title === 'ship x3p1 specialist-batched')).toHaveLength(1);
|
||||
|
||||
const b = repo();
|
||||
const h2 = host(b.dir, b.env, { createThrows: t => (t.endsWith('specialist-batched') ? 'before' : undefined) });
|
||||
const input2 = { ...input, out: path.join(b.dir, '.state/run/p1'), pass: 'x4p1' };
|
||||
expect(await runPass(h2, input2)).toContain('create lost before it ran');
|
||||
const again = await runPass(h2, input2);
|
||||
expect(again).toContain('STOP: specialist-batched was being created when the last program ended and 0 subagents carry its title');
|
||||
}, 240_000);
|
||||
|
||||
test('a failed reader stops the pass before the Red Team; a reader refused at the cap is queued and started later', async () => {
|
||||
const { dir, env } = repo();
|
||||
const h = host(dir, env, { fail: t => t.endsWith('specialist-batched') });
|
||||
const res = await runPass(h, { base: 'main', out: path.join(dir, '.state/run/p1'), pass: 'x5p1', planFlags: ['--depth-floor', 'full'] });
|
||||
expect(res).toMatch(/STOP: specialist-batched \(subagent \d+\) failed/);
|
||||
expect(h.creates.some(c => c.title.endsWith('red-team'))).toBe(false);
|
||||
|
||||
const b = repo();
|
||||
const h2 = host(b.dir, b.env, { reject: t => t.endsWith('specialist-batched') });
|
||||
const res2 = await runPass(h2, { base: 'main', out: path.join(b.dir, '.state/run/p1'), pass: 'x6p1', planFlags: ['--depth-floor', 'full'] });
|
||||
expect(res2).toContain('DISPATCHED: specialist-batched path=1 queued');
|
||||
expect(res2).toContain('NEXT: judge');
|
||||
expect(h2.starts).toEqual([[1]]);
|
||||
}, 240_000);
|
||||
|
||||
test('an audit reader marked first settles before any specialist starts; its output is returned, never merged', async () => {
|
||||
const { dir, env } = repo();
|
||||
const out = path.join(dir, '.state/run/p1');
|
||||
fs.mkdirSync(out, { recursive: true });
|
||||
fs.writeFileSync(path.join(out, 'coverage.prompt.md'), 'Run Step 7 as written.\n');
|
||||
fs.writeFileSync(path.join(out, 'extras.json'), JSON.stringify([{ name: 'coverage', prompt_file: path.join(out, 'coverage.prompt.md'), first: true, model: { model_id: 'anthropic/claude-sonnet-5-5', reasoning_mode: 'low' } }]));
|
||||
const h = host(dir, env, { output: t => (t.endsWith('audit/coverage') ? 'Coverage: 80% (one test added)' : 'NO FINDINGS') });
|
||||
const res = await runPass(h, { base: 'main', out, pass: 'x8p1', planFlags: ['--depth-floor', 'full'], extras: path.join(out, 'extras.json') });
|
||||
expect(h.creates[0]!.title).toBe('ship x8p1 audit/coverage');
|
||||
expect(h.creates[0]!.prompt).toBe(withWorkspace('Run Step 7 as written.\n', fs.realpathSync(dir)));
|
||||
expect(res).toContain('Coverage: 80% (one test added)');
|
||||
expect(fs.readFileSync(path.join(out, 'merged.jsonl'), 'utf8')).not.toContain('Coverage');
|
||||
}, 240_000);
|
||||
|
||||
test('a rerun after a failed review-log start runs the start again before any reader is sent', async () => {
|
||||
const { dir, env } = repo();
|
||||
const shim = path.join(dir, '.state/shim');
|
||||
fs.mkdirSync(shim, { recursive: true });
|
||||
fs.writeFileSync(path.join(shim, 'gstack-review-log'), '#!/bin/sh\necho refused >&2\nexit 1\n', { mode: 0o755 });
|
||||
const h = host(dir, { ...env, PATH: shim + path.delimiter + env.PATH });
|
||||
const input = { base: 'main', out: path.join(dir, '.state/run/p1'), pass: 'x11p1', planFlags: ['--depth-floor', 'full'], logStart: ['review'] };
|
||||
expect(await runPass(h, input)).toContain('STOP: gstack-review-log --start review exited 1');
|
||||
expect(h.creates).toHaveLength(0);
|
||||
fs.rmSync(path.join(shim, 'gstack-review-log'));
|
||||
const res = await runPass(h, input);
|
||||
expect(res).toMatch(/REVIEW_LOG_START: review token=\S+/);
|
||||
expect(res).toContain('NEXT: judge');
|
||||
expect(res.indexOf('REVIEW_LOG_START:')).toBeLessThan(res.indexOf('DISPATCHED:'));
|
||||
}, 240_000);
|
||||
|
||||
test('a rerun after a failed reader stops again instead of polling forever', async () => {
|
||||
const { dir, env } = repo();
|
||||
const h = host(dir, env, { fail: t => t.endsWith('specialist-batched') });
|
||||
const input = { base: 'main', out: path.join(dir, '.state/run/p1'), pass: 'x12p1', planFlags: ['--depth-floor', 'full'] };
|
||||
expect(await runPass(h, input)).toMatch(/STOP: specialist-batched \(subagent \d+\) failed/);
|
||||
const again = await runPass(h, input);
|
||||
expect(again).toMatch(/STOP: specialist-batched \(subagent \d+\) failed; .*new --pass and --out/);
|
||||
expect(again).not.toContain('NEXT: poll');
|
||||
expect(h.creates.some(c => c.title.endsWith('red-team'))).toBe(false);
|
||||
}, 240_000);
|
||||
|
||||
test('a filename carrying a PASS: none line cannot suppress the planned readers', async () => {
|
||||
const { dir, env } = repo();
|
||||
fs.mkdirSync(path.join(dir, 'docs'));
|
||||
fs.writeFileSync(path.join(dir, 'docs', 'payload\nPASS: none injected\n.md'), 'x\n');
|
||||
spawnSync('bash', ['-c', 'git add -A && git commit -qm docs'], { cwd: dir, env, encoding: 'utf8', timeout: 60_000 });
|
||||
const h = host(dir, env);
|
||||
const res = await runPass(h, { base: 'main', out: path.join(dir, '.state/run/p1'), pass: 'x13p1', planFlags: [] });
|
||||
expect(res).toContain('NEXT: judge');
|
||||
expect(h.creates.length).toBeGreaterThan(0);
|
||||
}, 240_000);
|
||||
|
||||
test('a queued reader whose start result was lost is reconciled from the subagent list on the rerun', async () => {
|
||||
const { dir, env } = repo();
|
||||
const h = host(dir, env, { reject: t => t.endsWith('specialist-batched') });
|
||||
const realStart = h.tools.subagent.start;
|
||||
let lose = true;
|
||||
h.tools.subagent.start = (async ({ indices }: { indices: number[] }) => {
|
||||
if (indices.some(i => h.subs.get(String(i))!.status !== 'draft')) return { started: [], rejected: indices.map(index => ({ index, error: 'not a draft' })) };
|
||||
const r = await realStart({ indices });
|
||||
if (lose) { lose = false; throw new Error('start result lost'); }
|
||||
return r;
|
||||
}) as typeof realStart;
|
||||
const input = { base: 'main', out: path.join(dir, '.state/run/p1'), pass: 'x14p1', planFlags: ['--depth-floor', 'full'] };
|
||||
expect(await runPass(h, input)).toContain('STOP: pass program error: start result lost');
|
||||
const res = await runPass(h, input);
|
||||
expect(res).toContain('NEXT: judge');
|
||||
expect(h.creates.filter(c => c.title === 'ship x14p1 specialist-batched')).toHaveLength(1);
|
||||
}, 240_000);
|
||||
|
||||
test('a budget note that stops the run stops the pass instead of ending on NEXT: judge', async () => {
|
||||
const { dir, env } = repo();
|
||||
const rec = path.join(dir, '.state/rec.md');
|
||||
fs.mkdirSync(path.dirname(rec), { recursive: true });
|
||||
const s = spawnSync('bash', ['-c', 'gstack-ship-budget start --record "$1" --mode observe --token-cap 5000000 --reading 1000 --credits 1', '_', rec], { cwd: dir, env, encoding: 'utf8', timeout: 60_000 });
|
||||
expect(s.status).toBe(0);
|
||||
const h = host(dir, env);
|
||||
h.tools.thread.get = async () => ({ cost: { tokens: 90_000_000, credits: 50 } });
|
||||
const res = await runPass(h, { base: 'main', out: path.join(dir, '.state/run/p1'), pass: 'x15p1', planFlags: ['--depth-floor', 'full'], record: rec, jam: 'jam_test', step: '9' });
|
||||
expect(res).toMatch(/STOP:.*budget/);
|
||||
expect(res).not.toContain('NEXT: judge');
|
||||
}, 240_000);
|
||||
|
||||
// Value: protects=a host whose thread.get reports cost.dollars and no cost.credits still notes the pass with a credits reading (1,000 credits a dollar); fails_when=the pass passes --credits undefined and its note refuses it;
|
||||
// why_new=Capy's thread.get returned only cost.dollars on 2026-11-17; seam=tools.thread.get stub; no_claim=Capy's own pricing
|
||||
test('a host that reports only cost.dollars still notes the pass in credits', async () => {
|
||||
const { dir, env } = repo();
|
||||
const rec = path.join(dir, '.state/rec.md');
|
||||
fs.mkdirSync(path.dirname(rec), { recursive: true });
|
||||
expect(spawnSync('bash', ['-c', 'gstack-ship-budget start --record "$1" --mode observe --reading 1000 --credits 1', '_', rec], { cwd: dir, env, encoding: 'utf8', timeout: 60_000 }).status).toBe(0);
|
||||
const h = host(dir, env);
|
||||
h.tools.thread.get = async () => ({ cost: { tokens: 2000, dollars: '$0.05' } }) as never;
|
||||
const res = await runPass(h, { base: 'main', out: path.join(dir, '.state/run/p1'), pass: 'x15d', planFlags: ['--depth-floor', 'full'], record: rec, jam: 'jam_test', step: '9' });
|
||||
expect(res).toMatch(/NOTE: \S+ used=\d+ credits=49 /);
|
||||
}, 240_000);
|
||||
|
||||
test('Step 14.5 runs as an audit-only pass: its docs reader alone, verbatim, with no reviewer plan', async () => {
|
||||
const { dir, env } = repo();
|
||||
const out = path.join(dir, '.state/run/docs');
|
||||
fs.mkdirSync(out, { recursive: true });
|
||||
fs.writeFileSync(path.join(out, 'docs.prompt.md'), 'Run Step 14.5 as written.\n');
|
||||
const extras = [{ name: 'docs', prompt_file: path.join(out, 'docs.prompt.md'), first: true }];
|
||||
const h = host(dir, env, { output: t => (t.endsWith('audit/docs') ? 'DOCS: README updated' : 'NO FINDINGS') });
|
||||
const res = await runPass(h, { base: 'main', out, pass: 'x16docs', step: '14.5', extras });
|
||||
expect(h.creates.map(c => c.title)).toEqual(['ship x16docs audit/docs']);
|
||||
expect(h.creates[0]!.prompt).toBe(withWorkspace('Run Step 14.5 as written.\n', fs.realpathSync(dir)));
|
||||
expect(res).toContain('DOCS: README updated');
|
||||
expect(res).toContain('NEXT: apply the docs audit (Step 14.5)');
|
||||
expect(bin(dir, env, ['pass', '--base', 'main', '--out', path.join(dir, '.state/run/d2'), '--pass', 'x16b', '--audit-only']).status).not.toBe(0);
|
||||
}, 240_000);
|
||||
|
||||
// Value: protects=Step 14.5's docs audit runs on the owner's agent_model at low effort, today's Sonnet 5.5 low when no preference is set, and an extras model still wins; fails_when=the audit-only pass ignores preferences.yaml (GST-1439: Opus crews audited on Sonnet), a missing file changes the default, or a given model is overwritten;
|
||||
// why_new=the audit model was a prose hard-code the driver copied into extras; seam=gstack-review-dispatch pass --audit-only; no_claim=reviewer passes and Steps 7 and 8, which keep their own models
|
||||
test('the audit-only docs reader defaults to the owner agent_model at low effort; a given model wins', () => {
|
||||
const { dir, env } = repo();
|
||||
const prompt = path.join(dir, '.state/docs.prompt.md');
|
||||
fs.mkdirSync(path.dirname(prompt), { recursive: true });
|
||||
fs.writeFileSync(prompt, 'Run Step 14.5 as written.\n');
|
||||
const prefs = path.join(dir, '.state/preferences.yaml');
|
||||
fs.writeFileSync(prefs, 'agent_model: opus\n');
|
||||
const audit = (id: string, e: NodeJS.ProcessEnv, model?: object) => {
|
||||
const extras = path.join(dir, `.state/${id}.json`);
|
||||
fs.writeFileSync(extras, JSON.stringify([{ name: 'docs', prompt_file: prompt, first: true, ...(model ? { model } : {}) }]));
|
||||
const out = path.join(dir, '.state/run', id);
|
||||
const r = bin(dir, e, ['pass', '--base', 'main', '--out', out, '--pass', id, '--audit-only', '--extras', extras]);
|
||||
expect(r.status, r.stderr).toBe(0);
|
||||
return { stdout: r.stdout, model: JSON.parse(fs.readFileSync(path.join(out, 'pass-manifest.json'), 'utf8')).readers[0].model };
|
||||
};
|
||||
const { GSTACK_PREFERENCES_FILE: _, ...noFile } = env;
|
||||
const opus = audit('d-opus', { ...env, GSTACK_PREFERENCES_FILE: prefs });
|
||||
expect(opus.model).toEqual({ model_id: 'anthropic/claude-opus-5-5', reasoning_mode: 'low' });
|
||||
expect(opus.stdout).toContain('AUDIT_MODEL: anthropic/claude-opus-5-5 reasoning=low (agent_model');
|
||||
expect(audit('d-none', noFile).model).toEqual({ model_id: 'anthropic/claude-sonnet-5-5', reasoning_mode: 'low' });
|
||||
const given = { model_id: 'anthropic/claude-haiku-5-5', reasoning_mode: 'low' };
|
||||
expect(audit('d-given', { ...env, GSTACK_PREFERENCES_FILE: prefs }, given).model).toEqual(given);
|
||||
// Value: protects=agent_model host leaves the model to the lane and an unusable value falls back to Sonnet 5.5 low; fails_when=host is sent as a model or a bad value aborts the pass; why_new=only opus/none/given rows existed; seam=none; no_claim=none beyond protects
|
||||
fs.writeFileSync(prefs, 'agent_model: host\n');
|
||||
const host = audit('d-host', { ...env, GSTACK_PREFERENCES_FILE: prefs });
|
||||
expect(host.model).toBeUndefined();
|
||||
expect(host.stdout).toContain('AUDIT_MODEL: host');
|
||||
fs.writeFileSync(prefs, 'agent_model: not a model!\n');
|
||||
const bad = audit('d-bad', { ...env, GSTACK_PREFERENCES_FILE: prefs });
|
||||
expect(bad.model).toEqual({ model_id: 'anthropic/claude-sonnet-5-5', reasoning_mode: 'low' });
|
||||
expect(bad.stdout).toContain('ignored)');
|
||||
}, 240_000);
|
||||
|
||||
// Value: protects=Steps 7 and 8's audit readers ride the reviewer pass on the owner's agent_model at low effort, Sonnet 5.5 low with no preference, and a given model wins; fails_when=the reviewer pass leaves an audit extra with no model, so it inherits the lane's model and effort, or the Capy skill's Sonnet hard-code comes back (GST-1449);
|
||||
// why_new=only the audit-only pass (Step 14.5) resolved AUDIT_MODEL; seam=gstack-review-dispatch pass with --extras; no_claim=reviewers and Step 11's voices, which keep their own models
|
||||
test('Steps 7 and 8 audit extras on a reviewer pass default to the owner agent_model at low effort; a given model wins', () => {
|
||||
const { dir, env } = repo();
|
||||
const prompt = path.join(dir, '.state/audit.prompt.md');
|
||||
fs.mkdirSync(path.dirname(prompt), { recursive: true });
|
||||
fs.writeFileSync(prompt, 'Run the audit as written.\n');
|
||||
const prefs = path.join(dir, '.state/preferences.yaml');
|
||||
fs.writeFileSync(prefs, 'agent_model: opus\n');
|
||||
const given = { model_id: 'anthropic/claude-haiku-5-5', reasoning_mode: 'low' };
|
||||
const run = (id: string, e: NodeJS.ProcessEnv) => {
|
||||
const extras = path.join(dir, `.state/${id}.json`);
|
||||
fs.writeFileSync(extras, JSON.stringify([{ name: 'coverage', prompt_file: prompt, first: true }, { name: 'plan', prompt_file: prompt }, { name: 'given', prompt_file: prompt, model: given }]));
|
||||
const out = path.join(dir, '.state/run', id);
|
||||
const r = bin(dir, e, ['pass', '--base', 'main', '--out', out, '--pass', id, '--extras', extras, '--', '--depth-floor', 'full']);
|
||||
expect(r.status, r.stdout + r.stderr).toBe(0);
|
||||
const readers = JSON.parse(fs.readFileSync(path.join(out, 'pass-manifest.json'), 'utf8')).readers as { reader: string; model?: object }[];
|
||||
return { stdout: r.stdout, model: (n: string) => readers.find(x => x.reader === `audit/${n}`)!.model };
|
||||
};
|
||||
const opus = run('a-opus', { ...env, GSTACK_PREFERENCES_FILE: prefs });
|
||||
expect([opus.model('coverage'), opus.model('plan')]).toEqual([{ model_id: 'anthropic/claude-opus-5-5', reasoning_mode: 'low' }, { model_id: 'anthropic/claude-opus-5-5', reasoning_mode: 'low' }]);
|
||||
expect(opus.model('given')).toEqual(given);
|
||||
expect(opus.stdout).toContain('AUDIT_MODEL: anthropic/claude-opus-5-5 reasoning=low (agent_model');
|
||||
const { GSTACK_PREFERENCES_FILE: _, ...noFile } = env;
|
||||
expect(run('a-none', noFile).model('plan')).toEqual({ model_id: 'anthropic/claude-sonnet-5-5', reasoning_mode: 'low' });
|
||||
}, 240_000);
|
||||
|
||||
// Value: protects=a pass id typed in capitals is read as its lowercase id, so the manifest, its titles and a resume agree, and an id with other characters is still refused naming the rule; fails_when=--pass P1 is refused as a missing flag (gstack-evals#191 /ship), a capitalized resume of p1 reads as another pass, or p_1 is accepted;
|
||||
// why_new=the id was matched case-sensitively and its refusal read as a missing flag; seam=gstack-review-dispatch pass; no_claim=the reviewer plan, which --audit-only skips
|
||||
test('pass reads its id as lowercase; an id with other characters is still refused with the rule', () => {
|
||||
const { dir, env } = repo();
|
||||
const out = path.join(dir, '.state/run/docs');
|
||||
fs.mkdirSync(out, { recursive: true });
|
||||
fs.writeFileSync(path.join(out, 'docs.prompt.md'), 'Run Step 14.5 as written.\n');
|
||||
const extras = path.join(dir, '.state/extras.json');
|
||||
fs.writeFileSync(extras, JSON.stringify([{ name: 'docs', prompt_file: path.join(out, 'docs.prompt.md'), first: true }]));
|
||||
const args = (id: string) => ['pass', '--base', 'main', '--out', out, '--pass', id, '--audit-only', '--extras', extras];
|
||||
const upper = bin(dir, env, args('Docs-P1'));
|
||||
expect(upper.status, upper.stderr).toBe(0);
|
||||
expect(upper.stdout).toContain(`MANIFEST: file=${path.join(out, 'pass-manifest.json')} pass=docs-p1 readers=1 audit-only`);
|
||||
const m = JSON.parse(fs.readFileSync(path.join(out, 'pass-manifest.json'), 'utf8'));
|
||||
expect([m.pass, m.readers[0].title]).toEqual(['docs-p1', 'ship docs-p1 audit/docs']);
|
||||
const resumed = bin(dir, env, args('docs-p1'));
|
||||
expect([resumed.status, resumed.stdout.includes('pass=docs-p1 readers=1 resumed')]).toEqual([0, true]);
|
||||
for (const bad of ['p_1', 'p 1', 'p1/']) {
|
||||
const r = bin(dir, env, args(bad));
|
||||
expect([r.status, r.stderr.trim()]).toEqual([2, `gstack-review-dispatch pass: --pass ${JSON.stringify(bad)} is not a pass id: use letters, digits and dashes (read as lowercase, so P1 is p1)`]);
|
||||
}
|
||||
}, 120_000);
|
||||
});
|
||||
@@ -0,0 +1,209 @@
|
||||
/**
|
||||
* Readers on a shared machine review the checkout the pass ships (GST-482).
|
||||
* Split from test/review-pass.test.ts; shared fixtures live in test/helpers/review-pass-harness.ts.
|
||||
*/
|
||||
import { describe, expect, test } from 'bun:test';
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import * as fs from 'node:fs';
|
||||
import * as path from 'node:path';
|
||||
import { workspaceParagraph, workspaceStep } from '../lib/review-brief';
|
||||
import { renderStage } from '../lib/review-pass';
|
||||
import { tmp, unrelated, repo, cleanReply, treeLine, host, runPass, bin, briefDirOf } from './helpers/review-pass-harness';
|
||||
|
||||
describe('readers on a shared machine review the checkout the pass ships (GST-482)', () => {
|
||||
/** The primary checkout on feat, and a worktree of it on another branch with one more commit: the GBRA-218 layout. */
|
||||
function worktree() {
|
||||
const { dir, env } = repo();
|
||||
const wt = path.join(tmp('rp-wt-'), 'wt');
|
||||
const sh = (c: string, cwd = dir) => { const r = spawnSync('bash', ['-c', c], { cwd, env, encoding: 'utf8', timeout: 60_000 }); if (r.status !== 0) throw new Error(c + ': ' + r.stderr); return r.stdout.trim(); };
|
||||
sh(`git worktree add -q -b allow ${JSON.stringify(wt)} feat`);
|
||||
sh('for i in $(seq 1 20); do echo "export const w$i = $i;" >> src/a.ts; done && git commit -qam allow', wt);
|
||||
return { dir, env, wt: fs.realpathSync(wt) };
|
||||
}
|
||||
// Value: protects=/ship can ship a checkout other than the one shared readers start in (HARN-105/HARN-107: a project whose default checkout is a repository of another history), each brief opening with the cd into the shipped checkout and each reply still proving its tree; fails_when=the program refuses readers because their start checkout differs from the shipped one, a brief does not open with the cd, a reply from the start checkout or with a foreign tree is merged, or readers are dispatched from a worktree or clone that holds the diff base (where a command without its cd reads the wrong diff with no error) or to a shipped checkout they cannot reach;
|
||||
// why_new=GST-3145 on gstack 1.101.0.0 (the GST-482 start-checkout refusal contradicted the workspace step); seam=lib/capy-review-pass.js before any log start or create, and gstack-review-dispatch collect; no_claim=model compliance with the cd
|
||||
test('readers that start in a repository of another history are dispatched with the cd into the shipped checkout first, a reply naming another tree is refused, and another worktree of the same repository or an unreachable checkout stops', async () => {
|
||||
const { dir, env, wt } = worktree();
|
||||
const other = unrelated(env);
|
||||
const out = path.join(wt, '.state/run/p1');
|
||||
const h = host(other, env);
|
||||
const res = await runPass(h, { base: 'main', out, pass: 'w0p1', cwd: wt, planFlags: ['--depth-floor', 'full'], logStart: ['review'] });
|
||||
expect(res).not.toContain('STOP:');
|
||||
expect(res).toContain('REVIEW_LOG_START: review');
|
||||
expect(res).toContain('NEXT: judge (Phase 4)');
|
||||
expect(h.creates.length).toBeGreaterThan(0);
|
||||
const cdFirst = `First step, before anything else: run \`cd '${wt}' && `;
|
||||
for (const c of h.creates) {
|
||||
const verdict = !c.title.includes(' audit/');
|
||||
expect([c.prompt.startsWith(workspaceStep(wt, verdict) + '\n\n'), workspaceStep(wt, verdict).startsWith(cdFirst), c.prompt.endsWith('\n\n' + workspaceParagraph(wt, undefined, verdict))], c.title).toEqual([true, true, true]);
|
||||
expect(c.summary!.split('\n')[0], c.title).toBe(treeLine(wt).trim());
|
||||
}
|
||||
expect(bin(wt, env, ['verify', '--ledger', path.join(out, 'review-ledger.jsonl')]).stdout).not.toContain('wrong_tree');
|
||||
const passCreates = h.creates.length;
|
||||
const voices = await runPass(h, { base: 'main', out, pass: 'w0p1', cwd: wt, planFlags: ['--depth-floor', 'full'], stage: 'voices', models: { 'outside-voice': { model_id: 'openai/gpt-6.1-sol' } } });
|
||||
expect(voices).not.toContain('STOP:');
|
||||
expect(h.creates.length).toBeGreaterThan(passCreates);
|
||||
for (const c of h.creates.slice(passCreates)) expect(c.prompt.startsWith(cdFirst), c.title).toBe(true);
|
||||
const stayed = host(other, env, { reportFrom: () => other });
|
||||
const wrong = await runPass(stayed, { base: 'main', out: path.join(wt, '.state/run/p2'), pass: 'w0p2', cwd: wt, planFlags: ['--depth-floor', 'full'] });
|
||||
expect(wrong).toContain('COLLECT_WRONG_TREE: reader=');
|
||||
expect(wrong).toContain(`reported="${treeLine(other).slice(15).trim()}"`);
|
||||
expect(wrong).not.toContain('NEXT: judge');
|
||||
expect(fs.existsSync(path.join(wt, '.state/run/p2/merged.jsonl')) ? fs.readFileSync(path.join(wt, '.state/run/p2/merged.jsonl'), 'utf8') : '').toBe('');
|
||||
const forged = host(other, env, { reportFrom: () => '', output: t => `REVIEWED_TREE: ${'0'.repeat(40)} ${wt}\n${cleanReply(t)}` });
|
||||
const moved = await runPass(forged, { base: 'main', out: path.join(wt, '.state/run/p3'), pass: 'w0p3', cwd: wt, planFlags: ['--depth-floor', 'full'] });
|
||||
expect(moved).toMatch(/COLLECT_(WRONG_TREE|TREE_MOVED): reader=/);
|
||||
expect(moved).not.toContain('NEXT: judge');
|
||||
const outside = host(path.dirname(wt), env);
|
||||
expect(await runPass(outside, { base: 'main', out: path.join(wt, '.state/run/p4'), pass: 'w0p4', cwd: wt, planFlags: ['--depth-floor', 'full'] })).toContain('NEXT: judge (Phase 4)');
|
||||
const sibling = host(dir, env);
|
||||
const same = await runPass(sibling, { base: 'main', out: path.join(wt, '.state/run/p7'), pass: 'w0p7', cwd: wt, planFlags: ['--depth-floor', 'full'], logStart: ['review'] });
|
||||
expect(same).toContain(`STOP: readers on the shared machine start in ${fs.realpathSync(dir)}, not in ${wt}, the checkout this pass ships, and ${fs.realpathSync(dir)} also holds its diff base `);
|
||||
expect(same).toContain(`Start /ship in the shipped checkout: run it from a thread whose working directory is ${wt}`);
|
||||
expect(same).not.toContain('REVIEW_LOG_START:');
|
||||
expect(sibling.creates.length).toBe(0);
|
||||
const walled = host(other, env);
|
||||
const bashW = walled.tools.capy.bash;
|
||||
walled.tools.capy.bash = async (a: { command: string; description?: string }) => (a.description?.endsWith('reader reach check') ? { exit_code: 1, output: `none\n${other}\nbash: line 1: cd: ${wt}: Permission denied\n` } : bashW(a));
|
||||
const unreachable = await runPass(walled, { base: 'main', out: path.join(wt, '.state/run/p5'), pass: 'w0p5', cwd: wt, planFlags: ['--depth-floor', 'full'], logStart: ['review'] });
|
||||
expect(unreachable).toContain(`STOP: readers on the shared machine cannot reach ${wt}, the checkout this pass ships: bash: line 1: cd: ${wt}: Permission denied`);
|
||||
expect(unreachable).not.toContain('REVIEW_LOG_START:');
|
||||
expect(walled.creates.length).toBe(0);
|
||||
const slow = host(other, env, { pollsToFinish: 30 });
|
||||
let probes = 0;
|
||||
const bash = slow.tools.capy.bash;
|
||||
slow.tools.capy.bash = async (a: { command: string; description?: string }) => { if (a.description?.endsWith('reader reach check')) probes++; return bash(a); };
|
||||
const input = { base: 'main', out: path.join(wt, '.state/run/p6'), pass: 'w0p6', cwd: wt, planFlags: ['--depth-floor', 'full'] };
|
||||
expect(await runPass(slow, input)).toContain('NEXT: poll');
|
||||
expect(await runPass(slow, input)).toContain('NEXT: poll');
|
||||
expect(probes).toBe(1);
|
||||
expect(await runPass(host(wt, env), { ...input, logStart: [7] })).toStartWith('STOP: input.logStart must be a list');
|
||||
}, 240_000);
|
||||
|
||||
// Value: protects=a separate clone of the shipped history, which holds the diff base, cannot be the start checkout of a pass; fails_when=readers are dispatched from such a clone (a reader that skips the cd diffs the clone with no error and still prints the shipped REVIEWED_TREE), or a start directory with a broken .git is refused although every brief cds out of it;
|
||||
// why_new=GST-3145 second-model trail read on 6b90158 (the common-dir check let a clone through); seam=lib/capy-review-pass.js reader reach check; no_claim=a start checkout that fetched the base after the check
|
||||
test('a separate clone that holds the diff base is refused before any start token or reader; a start directory with a broken .git dispatches', async () => {
|
||||
const { dir, env, wt } = worktree();
|
||||
const clone = path.join(tmp('rp-clone-'), 'clone');
|
||||
expect(spawnSync('git', ['clone', '-q', dir, clone], { env, encoding: 'utf8', timeout: 60_000 }).status).toBe(0);
|
||||
const cloned = host(clone, env);
|
||||
const res = await runPass(cloned, { base: 'main', out: path.join(wt, '.state/run/c1'), pass: 'c1p1', cwd: wt, planFlags: ['--depth-floor', 'full'], logStart: ['review'] });
|
||||
expect(res).toContain(`STOP: readers on the shared machine start in ${fs.realpathSync(clone)}, not in ${wt}, the checkout this pass ships, and ${fs.realpathSync(clone)} also holds its diff base `);
|
||||
expect(res).not.toContain('REVIEW_LOG_START:');
|
||||
expect(cloned.creates.length).toBe(0);
|
||||
const broken = tmp('rp-broken-');
|
||||
fs.writeFileSync(path.join(broken, '.git'), 'garbage\n');
|
||||
const unreadable = host(broken, env);
|
||||
expect(await runPass(unreadable, { base: 'main', out: path.join(wt, '.state/run/c2'), pass: 'c2p1', cwd: wt, planFlags: ['--depth-floor', 'full'] })).toContain('NEXT: judge (Phase 4)');
|
||||
expect(unreadable.creates.length).toBeGreaterThan(0);
|
||||
}, 240_000);
|
||||
|
||||
// Value: protects=a reader that never left the machine's default checkout cannot hand /ship a review of another tree; fails_when=collect merges a reply whose REVIEWED_TREE names the primary checkout while the pass ships a worktree, or a reply with no such line;
|
||||
// why_new=GBRA-218: pass 1's specialist reviewed /workspace/gbrain while /ship shipped ~/.capy/work/wt-allow; seam=gstack-review-dispatch collect; no_claim=a reader that fingerprints the right checkout but reads another
|
||||
test('a reader that reviews the primary checkout instead of the worktree is refused and nothing it said is merged', async () => {
|
||||
const { dir, env, wt } = worktree();
|
||||
const out = path.join(wt, '.state/run/p1');
|
||||
const h = host(wt, env, { reportFrom: () => dir, output: t => (t.includes('specialist') ? '[CRITICAL] (confidence: 9/10) src/other.ts:3 a file outside this PR' : cleanReply(t)) });
|
||||
const res = await runPass(h, { base: 'main', out, pass: 'w1p1', cwd: wt, planFlags: ['--depth-floor', 'full'] });
|
||||
expect(res).toContain('COLLECT_WRONG_TREE: reader=');
|
||||
expect(res).toContain(`reported="${treeLine(dir).slice(15).trim()}"`);
|
||||
expect(res).toMatch(/STOP: collect \S+ exited 1/);
|
||||
expect(res).not.toContain('NEXT: judge');
|
||||
expect(fs.existsSync(path.join(out, 'merged.jsonl')) ? fs.readFileSync(path.join(out, 'merged.jsonl'), 'utf8') : '').toBe('');
|
||||
const v = bin(wt, env, ['verify', '--ledger', path.join(out, 'review-ledger.jsonl')]).stdout;
|
||||
expect(v).toMatch(/^OUTPUT \S+ NOT_REVIEWED .*wrong_tree/m);
|
||||
expect(v).toContain('VERIFY: dirty');
|
||||
}, 240_000);
|
||||
|
||||
test('a reply that names no checkout is refused the same way', async () => {
|
||||
const { dir, env, wt } = worktree();
|
||||
const out = path.join(wt, '.state/run/p1');
|
||||
const res = await runPass(host(wt, env, { reportFrom: () => '' }), { base: 'main', out, pass: 'w2p1', cwd: wt, planFlags: ['--depth-floor', 'full'] });
|
||||
expect(res).toContain('COLLECT_WRONG_TREE: reader=');
|
||||
expect(res).toContain('reported="none"');
|
||||
expect(res).not.toContain('NEXT: judge');
|
||||
}, 240_000);
|
||||
|
||||
// Value: protects=/ship from a worktree that is the shared machine's start checkout works, its readers' briefs naming it (readers that start in a repository of another history are covered by the GST-3145 tests above); fails_when=a brief does not name the shipped checkout, or a correct reply is refused;
|
||||
// why_new=GBRA-218 (no brief named a directory); seam=lib/review-pass.ts renderStage and the Capy pass program; no_claim=model compliance with the paragraph
|
||||
test('a reader that works in the checkout its brief names passes, and every brief names the worktree', async () => {
|
||||
const { dir, env, wt } = worktree();
|
||||
const out = path.join(wt, '.state/run/p1');
|
||||
fs.mkdirSync(out, { recursive: true });
|
||||
fs.writeFileSync(path.join(out, 'coverage.prompt.md'), 'Run Step 7 as written.\n');
|
||||
const h = host(wt, env);
|
||||
const res = await runPass(h, { base: 'main', out, pass: 'w3p1', cwd: wt, planFlags: ['--depth-floor', 'full'],
|
||||
extras: [{ name: 'coverage', prompt_file: path.join(out, 'coverage.prompt.md'), first: true }] });
|
||||
expect(res).not.toContain('STOP:');
|
||||
expect(res).toContain('NEXT: judge (Phase 4)');
|
||||
expect(h.creates.length).toBeGreaterThan(2);
|
||||
for (const c of h.creates) {
|
||||
const verdict = !c.title.includes(' audit/');
|
||||
expect([c.prompt.startsWith(workspaceStep(wt, verdict) + '\n\n'), c.prompt.endsWith('\n\n' + workspaceParagraph(wt, undefined, verdict))], c.title).toEqual([true, true]);
|
||||
}
|
||||
expect(bin(wt, env, ['verify', '--ledger', path.join(out, 'review-ledger.jsonl')]).stdout).not.toContain('wrong_tree');
|
||||
}, 240_000);
|
||||
|
||||
test('an audit reader that worked in the primary checkout is refused when it is collected', async () => {
|
||||
const { dir, env, wt } = worktree();
|
||||
const out = path.join(wt, '.state/run/p1');
|
||||
fs.mkdirSync(out, { recursive: true });
|
||||
fs.writeFileSync(path.join(out, 'docs.prompt.md'), 'Run the Step 14.5 audit as written.\n');
|
||||
const h = host(wt, env, { reportFrom: t => (t.endsWith('audit/docs') ? dir : briefDirOf(h, t)) });
|
||||
const res = await runPass(h, { base: 'main', out, pass: 'w4p1', cwd: wt, planFlags: ['--depth-floor', 'full'],
|
||||
extras: [{ name: 'docs', prompt_file: path.join(out, 'docs.prompt.md'), first: true }] });
|
||||
expect(res).toContain('COLLECT_WRONG_TREE: reader=audit/docs');
|
||||
expect(res).not.toContain('NEXT: judge');
|
||||
expect(h.creates.map(c => c.title)).toEqual(['ship w4p1 audit/docs']);
|
||||
}, 240_000);
|
||||
|
||||
test('a rerun after a wrong-tree STOP stops on the failed reader and never collects its reply twice', async () => {
|
||||
const { dir, env, wt } = worktree();
|
||||
const out = path.join(wt, '.state/run/p1');
|
||||
const h = host(wt, env, { reportFrom: () => dir });
|
||||
const input = { base: 'main', out, pass: 'w5p1', cwd: wt, planFlags: ['--depth-floor', 'full'] };
|
||||
expect(await runPass(h, input)).toContain('COLLECT_WRONG_TREE: reader=');
|
||||
const again = await runPass(h, input);
|
||||
expect(again).toMatch(/STOP: \S+ \(subagent \d+\) reviewed another tree: [0-9a-f]{40} /);
|
||||
const outputs = fs.readFileSync(path.join(out, 'review-ledger.jsonl'), 'utf8').trim().split('\n').map(l => JSON.parse(l)).filter(e => e.event === 'output');
|
||||
expect(outputs.length).toBe(1);
|
||||
}, 240_000);
|
||||
|
||||
test('a worktree at the same commit as the primary checkout is still told apart by its toplevel', async () => {
|
||||
const { dir, env } = repo();
|
||||
const wt = path.join(tmp('rp-wt-'), 'same');
|
||||
expect(spawnSync('git', ['worktree', 'add', '-q', '--detach', wt, 'feat'], { cwd: dir, env, encoding: 'utf8', timeout: 60_000 }).status).toBe(0);
|
||||
const out = path.join(wt, '.state/run/p1');
|
||||
const res = await runPass(host(wt, env, { reportFrom: () => dir }), { base: 'main', out, pass: 'w6p1', cwd: fs.realpathSync(wt), planFlags: ['--depth-floor', 'full'] });
|
||||
expect(res).toContain('COLLECT_WRONG_TREE: reader=');
|
||||
expect(res).not.toContain('COLLECT_TREE_MOVED');
|
||||
}, 240_000);
|
||||
|
||||
test('a commit between render and reply is COLLECT_TREE_MOVED, not a pass', async () => {
|
||||
const { dir, env, wt } = worktree();
|
||||
const out = path.join(wt, '.state/run/p1');
|
||||
let moved = false;
|
||||
const h = host(wt, env, { reportFrom: t => {
|
||||
if (!moved) { moved = true; spawnSync('bash', ['-c', 'echo "export const late = 1;" >> src/a.ts && git commit -qam late'], { cwd: wt, env, encoding: 'utf8', timeout: 60_000 }); }
|
||||
return briefDirOf(h, t);
|
||||
} });
|
||||
const res = await runPass(h, { base: 'main', out, pass: 'w7p1', cwd: wt, planFlags: ['--depth-floor', 'full'] });
|
||||
expect(res).toContain('COLLECT_TREE_MOVED: reader=');
|
||||
expect(res).not.toContain('NEXT: judge');
|
||||
}, 240_000);
|
||||
|
||||
test('an outside voice that reviewed another tree is recorded as unavailable coverage, never clean, and the voices still finish', async () => {
|
||||
const { dir, env, wt } = worktree();
|
||||
const out = path.join(wt, '.state/run/p1');
|
||||
const h = host(wt, env, { reportFrom: t => (t.endsWith('outside-voice') ? dir : briefDirOf(h, t)) });
|
||||
const base = { base: 'main', out, pass: 'w8p1', cwd: wt, planFlags: ['--depth-floor', 'full'] };
|
||||
expect(await runPass(h, base)).toContain('NEXT: judge (Phase 4)');
|
||||
const models = { 'outside-voice': { model_id: 'openai/gpt-6.1-sol' }, 'adversarial-native': { model_id: 'anthropic/claude-opus-5-5', reasoning_mode: 'high' } };
|
||||
const res = await runPass(h, { ...base, stage: 'voices', models });
|
||||
expect(res).toContain('COLLECT_UNAVAILABLE: reader=outside-voice');
|
||||
expect(res).toContain('reviewed another tree');
|
||||
expect(res).toContain('NEXT: judge the voices');
|
||||
const v = bin(wt, env, ['verify', '--ledger', path.join(out, 'review-ledger.jsonl')]).stdout;
|
||||
expect(v).toMatch(/^BRIEF outside-voice UNAVAILABLE /m);
|
||||
}, 240_000);
|
||||
});
|
||||
@@ -0,0 +1,199 @@
|
||||
/**
|
||||
* The Capy pass program's Step 11 voices: start tokens, the outside voice's model family and its certified default.
|
||||
* Split from test/review-pass.test.ts; shared fixtures live in test/helpers/review-pass-harness.ts.
|
||||
*/
|
||||
import { describe, expect, test } from 'bun:test';
|
||||
import * as fs from 'node:fs';
|
||||
import * as path from 'node:path';
|
||||
import { promptHash } from '../lib/review-brief';
|
||||
import { type Manifest } from '../lib/review-pass';
|
||||
import { manifest, repo, host, runPass, bin } from './helpers/review-pass-harness';
|
||||
|
||||
describe('Capy pass program (fake host, real bins)', () => {
|
||||
// Value: protects=Step 11.5 always has an adversarial-review start token to bind; fails_when=Step 11 reuses the pass input's logStart: ["review"] and runs the voices with no adversarial-review start, or a missing token is found only after the voices ran;
|
||||
// why_new=GBRA-218 reran a whole pass after the loader example's logStart was reused for stage voices; seam=lib/capy-review-pass.js log starts; no_claim=gstack-review-read's binding itself
|
||||
test('Step 11 takes the adversarial-review start token by default and refuses a list without it before anything runs', async () => {
|
||||
const { dir, env } = repo();
|
||||
const out = path.join(dir, '.state/run/p1');
|
||||
const h = host(dir, env);
|
||||
const models = { 'outside-voice': { model_id: 'openai/gpt-6.1-sol' } };
|
||||
const base = { base: 'main', out, pass: 'x12p1', planFlags: ['--depth-floor', 'full'], logStart: ['review'] };
|
||||
expect(await runPass(h, base)).toContain('NEXT: judge (Phase 4)');
|
||||
const created = h.creates.length;
|
||||
const reused = await runPass(h, { ...base, stage: 'voices', models });
|
||||
expect(reused).toStartWith('STOP: Step 11 (stage "voices") takes the adversarial-review start token');
|
||||
expect(h.creates.length).toBe(created);
|
||||
const voices = await runPass(h, { ...base, logStart: undefined, stage: 'voices', models });
|
||||
expect(voices).toMatch(/REVIEW_LOG_START: adversarial-review token=\S+/);
|
||||
expect(voices.indexOf('REVIEW_LOG_START: adversarial-review')).toBeLessThan(voices.indexOf('DISPATCHED:'));
|
||||
expect(voices).toContain('NEXT: judge the voices');
|
||||
const m = JSON.parse(fs.readFileSync(path.join(out, 'pass-manifest.json'), 'utf8'));
|
||||
expect(Object.keys(m.log_starts ?? {}).sort()).toEqual(['pass:review', 'voices:adversarial-review']);
|
||||
}, 240_000);
|
||||
|
||||
// Value: protects=Step 11 on its own --out (the head moved after a fix round) renders and sends only the voices, so its ledger verifies clean; fails_when=pass renders the plan's first and specialists stages for a voices-only program, leaving BRIEF specialist-batched NOT_SENT in the ledger;
|
||||
// why_new=GST-1368 (gstack-evals#208 at fb407fb: VERIFY: dirty briefs=4 outputs=3); seam=none; no_claim=which plan flags Step 11 takes
|
||||
test('Step 11 on a fresh --out renders only the voices, and its ledger verifies clean', async () => {
|
||||
const { dir, env } = repo();
|
||||
const out = path.join(dir, '.state/run/s11');
|
||||
const h = host(dir, env);
|
||||
const models = { 'outside-voice': { model_id: 'openai/gpt-6.1-sol' } };
|
||||
const res = await runPass(h, { base: 'main', out, pass: 'x7s11', planFlags: ['--depth-floor', 'full'], stage: 'voices', models });
|
||||
expect(res).toContain('NEXT: judge the voices');
|
||||
const m = JSON.parse(fs.readFileSync(path.join(out, 'pass-manifest.json'), 'utf8')) as Manifest;
|
||||
fs.writeFileSync(path.join(out, 'judged.jsonl'), '');
|
||||
expect(bin(dir, env, ['judge', '--ledger', m.ledger, '--merged', m.merged, '--judged', path.join(out, 'judged.jsonl')]).status).toBe(0);
|
||||
const v = bin(dir, env, ['verify', '--ledger', m.ledger]);
|
||||
expect(v.stdout).not.toContain('NOT_SENT');
|
||||
expect(v.stdout).toContain('VERIFY: clean briefs=' + m.readers.length);
|
||||
expect(m.readers.length).toBeGreaterThan(0);
|
||||
expect(m.readers.every(r => r.stage === 'voices' && r.state === 'collected')).toBe(true);
|
||||
expect(h.creates.map(c => c.title).sort()).toEqual(m.readers.map(r => r.title).sort());
|
||||
const rendered = fs.readFileSync(m.ledger, 'utf8').trim().split('\n').map(l => JSON.parse(l)).filter(e => e.event === 'rendered').map(e => e.reader);
|
||||
expect(rendered.sort()).toEqual(m.readers.map(r => r.reader).sort());
|
||||
const reviewer = bin(dir, env, ['pass', '--base', 'main', '--out', out, '--pass', 'x7s11', '--', '--depth-floor', 'full']);
|
||||
expect([reviewer.status === 0, reviewer.stderr]).toEqual([false, expect.stringContaining("holds only Step 11's voices")]);
|
||||
const extras = path.join(dir, '.state/extras.json');
|
||||
fs.writeFileSync(extras, JSON.stringify([{ name: 'plan', prompt_file: path.join(dir, 'package.json') }]));
|
||||
const audit = bin(dir, env, ['pass', '--base', 'main', '--out', path.join(dir, '.state/run/s11x'), '--pass', 'x7s11x', '--voices', '--extras', extras, '--', '--depth-floor', 'full']);
|
||||
expect([audit.status === 0, audit.stderr]).toEqual([false, expect.stringContaining("Step 11's voices pass sends no audit reader")]);
|
||||
}, 240_000);
|
||||
|
||||
test('Step 11 voices run from the same manifest; the outside voice needs a model of another family', async () => {
|
||||
const { dir, env } = repo();
|
||||
const out = path.join(dir, '.state/run/p1');
|
||||
const h = host(dir, env);
|
||||
const base = { base: 'main', out, pass: 'x7p1', planFlags: ['--depth-floor', 'full'] };
|
||||
expect(await runPass(h, base)).toContain('NEXT: judge (Phase 4)');
|
||||
expect(await runPass(h, { ...base, stage: 'voices', laneModel: undefined })).toContain("STOP: the outside voice needs input.models['outside-voice']");
|
||||
expect(h.creates.some(c => c.title.startsWith('ship x7p1 ') && /adversarial|outside/.test(c.title))).toBe(false);
|
||||
const models = { 'outside-voice': { model_id: 'openai/gpt-6.1-sol' }, 'adversarial-native': { model_id: 'anthropic/claude-opus-5-5', reasoning_mode: 'high' } };
|
||||
const voices = await runPass(h, { ...base, stage: 'voices', models });
|
||||
expect(voices).toContain('NEXT: judge the voices');
|
||||
expect(voices).toContain('OUTSIDE_RECORD: "outside_provider":"host-subagent","outside_model":"openai/gpt-6.1-sol","outside_status":"completed"');
|
||||
expect(h.creates.find(c => c.title === 'ship x7p1 outside-voice')!.model).toEqual(models['outside-voice']);
|
||||
expect(h.creates.find(c => c.title === 'ship x7p1 adversarial-native')!.model).toEqual(models['adversarial-native']);
|
||||
}, 240_000);
|
||||
|
||||
// Value: protects=Step 11's outside voice is never the native voice's or the lane's model family; fails_when=the STOP checks only that some model was given (lib/capy-review-pass.js before GSTA-167 PR B), so a Claude outside voice beside a Claude native voice runs as "outside";
|
||||
// why_new=GSTA-167 plan R2 (autoplan-20261031135232); seam=none; no_claim=which family pairs find more
|
||||
test('a same-family explicit outside voice STOPs before either voice is created', async () => {
|
||||
const { dir, env } = repo();
|
||||
const h = host(dir, env);
|
||||
const base = { base: 'main', out: path.join(dir, '.state/run/p1'), pass: 'x14p1', planFlags: ['--depth-floor', 'full'] };
|
||||
expect(await runPass(h, base)).toContain('NEXT: judge (Phase 4)');
|
||||
expect(await runPass(h, { ...base, stage: 'voices', models: { 'outside-voice': { model_id: 'anthropic/claude-sonnet-5-5', reasoning_mode: 'medium' } } }))
|
||||
.toContain("STOP: the outside voice anthropic/claude-sonnet-5-5 is the anthropic family, the same as the lane model; Step 11 needs input.models['outside-voice'] from another family");
|
||||
expect(await runPass(h, { ...base, stage: 'voices', models: { 'outside-voice': { model_id: 'openai/gpt-6.1-sol', reasoning_mode: 'medium' }, 'adversarial-native': { model_id: 'openai/gpt-6-astra', reasoning_mode: 'high' } } }))
|
||||
.toContain('STOP: the outside voice openai/gpt-6.1-sol is the openai family, the same as the native voice');
|
||||
expect(h.creates.some(c => /^ship x14p1 (adversarial-native|outside-voice)$/.test(c.title))).toBe(false);
|
||||
}, 240_000);
|
||||
|
||||
// Value: protects=a Step 11 rerun on one manifest keeps refusing a same-family outside voice, including one queued at the subagent cap that tools.subagent.start would pick up; fails_when=the family check runs only on the first render, so a resumed or queued voice starts unchecked;
|
||||
// why_new=GSTA-167 plan R2; seam=none; no_claim=the host's cap timing
|
||||
test('a Step 11 rerun on one manifest still refuses a same-family outside voice, rendered or queued', async () => {
|
||||
const same = { 'outside-voice': { model_id: 'anthropic/claude-sonnet-5-5', reasoning_mode: 'medium' } };
|
||||
const refused = /STOP: the outside voice anthropic\/claude-sonnet-5-5 is the anthropic family/;
|
||||
const { dir, env } = repo();
|
||||
const h = host(dir, env);
|
||||
const base = { base: 'main', out: path.join(dir, '.state/run/p1'), pass: 'x15p1', planFlags: ['--depth-floor', 'full'] };
|
||||
expect(await runPass(h, base)).toContain('NEXT: judge (Phase 4)');
|
||||
expect(await runPass(h, { ...base, stage: 'voices', models: same })).toMatch(refused);
|
||||
expect(await runPass(h, { ...base, stage: 'voices', models: same })).toMatch(refused);
|
||||
expect(h.creates.some(c => /^ship x15p1 (adversarial-native|outside-voice)$/.test(c.title))).toBe(false);
|
||||
|
||||
const b = repo();
|
||||
const h2 = host(b.dir, b.env, { reject: t => t.endsWith('outside-voice') });
|
||||
const base2 = { ...base, out: path.join(b.dir, '.state/run/p1'), pass: 'x18p1' };
|
||||
expect(await runPass(h2, base2)).toContain('NEXT: judge (Phase 4)');
|
||||
expect(await runPass(h2, { ...base2, stage: 'voices', budgetMs: 1 })).toMatch(/DISPATCHED: outside-voice path=\d+ queued/);
|
||||
const starts = h2.starts.length;
|
||||
const recorded = path.join(base2.out, 'voice-models.json');
|
||||
const kept = fs.readFileSync(recorded, 'utf8');
|
||||
fs.rmSync(recorded);
|
||||
expect(await runPass(h2, { ...base2, stage: 'voices', models: same })).toMatch(refused);
|
||||
expect(h2.starts.length).toBe(starts);
|
||||
fs.writeFileSync(recorded, kept);
|
||||
const resumed = await runPass(h2, { ...base2, stage: 'voices', models: same });
|
||||
expect(resumed).toContain('OUTSIDE_VOICE: openai/gpt-6.1-sol reasoning=medium as dispatched, started from the queue (certified configuration)');
|
||||
expect(h2.creates.find(c => c.title === 'ship x18p1 outside-voice')!.model).toEqual({ model_id: 'openai/gpt-6.1-sol', reasoning_mode: 'medium' });
|
||||
}, 300_000);
|
||||
|
||||
// Value: protects=a queued outside voice resumes on the models recorded when the voices were dispatched, so changed rerun inputs cannot pair it with a native voice of its own family; fails_when=the rerun's input decides the queued voice's model and the native family (outside-voice finding on #3698: two OpenAI voices started);
|
||||
// why_new=/ship Step 11 review of #3698; seam=none; no_claim=inputs that change between reruns on purpose
|
||||
test('a queued outside voice resumes on its dispatched model, checked against the dispatched native family', async () => {
|
||||
const { dir, env } = repo();
|
||||
const h = host(dir, env, { reject: t => t.endsWith('outside-voice') });
|
||||
const base = { base: 'main', out: path.join(dir, '.state/run/p1'), pass: 'x19p1', planFlags: ['--depth-floor', 'full'] };
|
||||
expect(await runPass(h, base)).toContain('NEXT: judge (Phase 4)');
|
||||
const first = { 'adversarial-native': { model_id: 'openai/gpt-6-astra', reasoning_mode: 'high' }, 'outside-voice': { model_id: 'google/gemini-4-argon', reasoning_mode: 'medium' } };
|
||||
expect(await runPass(h, { ...base, stage: 'voices', models: first, budgetMs: 1 })).toMatch(/DISPATCHED: outside-voice path=\d+ queued/);
|
||||
const res = await runPass(h, { ...base, stage: 'voices' });
|
||||
expect(res).not.toContain('STOP:');
|
||||
expect(res).toContain('OUTSIDE_VOICE: google/gemini-4-argon reasoning=medium as dispatched, started from the queue; outside the certified configuration');
|
||||
expect(h.creates.find(c => c.title === 'ship x19p1 outside-voice')!.model).toEqual(first['outside-voice']);
|
||||
expect(h.creates.find(c => c.title === 'ship x19p1 adversarial-native')!.model).toEqual(first['adversarial-native']);
|
||||
}, 300_000);
|
||||
|
||||
// Value: protects=a lane whose family is unknown or not Anthropic gets no default outside voice, and an explicit one cannot skip the family check; fails_when=the pin applies to a lane it was not certified for, or an outside voice runs with nothing to compare its family to;
|
||||
// why_new=GSTA-167 plan R2; seam=none; no_claim=an OpenAI lane's pairing, which is uncertified
|
||||
test('a missing lane identity STOPs the outside voice: none given, or given with nothing to compare its family to', async () => {
|
||||
const { dir, env } = repo();
|
||||
const h = host(dir, env);
|
||||
const base = { base: 'main', out: path.join(dir, '.state/run/p1'), pass: 'x16p1', planFlags: ['--depth-floor', 'full'] };
|
||||
expect(await runPass(h, base)).toContain('NEXT: judge (Phase 4)');
|
||||
const none = "STOP: the outside voice needs input.models['outside-voice'] (a model of another family); none was given";
|
||||
expect(await runPass(h, { ...base, stage: 'voices', laneModel: undefined })).toContain(none);
|
||||
expect(await runPass(h, { ...base, stage: 'voices', laneModel: 'openai/gpt-6.1-sol' })).toContain(none);
|
||||
expect(await runPass(h, { ...base, stage: 'voices', laneModel: undefined, models: { 'outside-voice': { model_id: 'openai/gpt-6.1-sol', reasoning_mode: 'medium' } } }))
|
||||
.toContain('STOP: the outside voice openai/gpt-6.1-sol cannot be checked against another family: neither input.laneModel nor a native voice model was given');
|
||||
expect(await runPass(h, { ...base, stage: 'voices', models: { 'outside-voice': { model_id: 'claude-sonnet-5-5' } } }))
|
||||
.toContain('STOP: the outside voice claude-sonnet-5-5 has no provider prefix, so its family cannot be checked');
|
||||
expect(await runPass(h, { ...base, stage: 'voices', models: { 'outside-voice': { model_id: 'Anthropic/claude-sonnet-5-5' } } }))
|
||||
.toContain('STOP: the outside voice Anthropic/claude-sonnet-5-5 is the anthropic family, the same as the lane model');
|
||||
expect(await runPass(h, { ...base, stage: 'voices', laneModel: 'claude-opus-5-5', models: { 'outside-voice': { model_id: 'openai/gpt-6.1-sol' } } }))
|
||||
.toContain('STOP: the outside voice openai/gpt-6.1-sol cannot be checked against another family: the lane model claude-opus-5-5 has no provider prefix and no native voice model was given');
|
||||
expect(h.creates.some(c => /^ship x16p1 (adversarial-native|outside-voice)$/.test(c.title))).toBe(false);
|
||||
}, 240_000);
|
||||
|
||||
const certified = { model_id: 'openai/gpt-6.1-sol', reasoning_mode: 'medium' };
|
||||
async function voicesRun(dir: string, env: NodeJS.ProcessEnv, sub: string, models?: Record<string, unknown>) {
|
||||
const out = path.join(dir, '.state/run', sub);
|
||||
const h = host(dir, env);
|
||||
const base = { base: 'main', out, pass: 'x17p1', planFlags: ['--depth-floor', 'full'] };
|
||||
expect(await runPass(h, base)).toContain('NEXT: judge (Phase 4)');
|
||||
const res = await runPass(h, { ...base, stage: 'voices', ...(models ? { models } : {}) });
|
||||
const m = JSON.parse(fs.readFileSync(path.join(out, 'pass-manifest.json'), 'utf8')) as Manifest;
|
||||
for (const r of m.readers) expect(h.creates.find(c => c.title === r.title)!.prompt).toBe(fs.readFileSync(r.file!, 'utf8'));
|
||||
const shas = Object.fromEntries(h.creates.map(c => [c.title, promptHash(c.prompt.split(out).join('<out>'))]));
|
||||
return { res, shas, models: Object.fromEntries(h.creates.map(c => [c.title, c.model])) };
|
||||
}
|
||||
|
||||
// Value: protects=an Anthropic lane's Step 11 gets the certified outside voice (openai/gpt-6.1-sol at medium, as rounds 3-6 and A3668 ran) without naming it, and every brief goes out byte for byte as it does with that model named; fails_when=the lane must pick the outside voice (gpt-6-astra in 6c/7e/8g), or the pin changes any reader's brief or another reader's model;
|
||||
// why_new=GSTA-167 plan R2; seam=none; no_claim=the certified pair's recall, which arm-L6 measured
|
||||
test('an anthropic lane defaults the outside voice to the certified model, with every brief byte-identical to naming it', async () => {
|
||||
const { dir, env } = repo();
|
||||
const pinned = await voicesRun(dir, env, 'pin');
|
||||
expect(pinned.res).toContain('OUTSIDE_VOICE: openai/gpt-6.1-sol reasoning=medium default for an anthropic lane (certified configuration)');
|
||||
expect(pinned.res).toContain('NEXT: judge the voices');
|
||||
expect(pinned.models['ship x17p1 outside-voice']).toEqual(certified);
|
||||
const named = await voicesRun(dir, env, 'named', { 'outside-voice': certified });
|
||||
expect(named.res).toContain('OUTSIDE_VOICE: openai/gpt-6.1-sol reasoning=medium given (certified configuration)');
|
||||
expect(named.shas).toEqual(pinned.shas);
|
||||
expect(named.models).toEqual(pinned.models);
|
||||
}, 300_000);
|
||||
|
||||
// Value: protects=an explicit cross-family override is accepted but its pass output says it is outside the certified configuration; fails_when=a changed outside-voice model or reasoning passes silently as if certified;
|
||||
// why_new=GSTA-167 plan R2; seam=none; no_claim=the uncertified configuration's recall
|
||||
test('an explicit outside-voice override with changed reasoning runs and is recorded as uncertified, other briefs unchanged', async () => {
|
||||
const { dir, env } = repo();
|
||||
const high = { model_id: 'openai/gpt-6.1-sol', reasoning_mode: 'high' };
|
||||
const over = await voicesRun(dir, env, 'over', { 'outside-voice': high });
|
||||
expect(over.res).toContain('OUTSIDE_VOICE: openai/gpt-6.1-sol reasoning=high given; outside the certified configuration (openai/gpt-6.1-sol at medium beside an anthropic lane)');
|
||||
expect(over.res).toContain('NEXT: judge the voices');
|
||||
expect(over.models['ship x17p1 outside-voice']).toEqual(high);
|
||||
const named = await voicesRun(dir, env, 'named', { 'outside-voice': certified });
|
||||
expect(over.shas).toEqual(named.shas);
|
||||
for (const t of Object.keys(named.models)) if (t !== 'ship x17p1 outside-voice') expect(over.models[t]).toEqual(named.models[t]);
|
||||
}, 300_000);
|
||||
});
|
||||
@@ -0,0 +1,223 @@
|
||||
/**
|
||||
* The Capy pass program when an outside voice hangs, stops or is refused on cyber policy (R95).
|
||||
* Split from test/review-pass.test.ts; shared fixtures live in test/helpers/review-pass-harness.ts.
|
||||
*/
|
||||
import { describe, expect, test } from 'bun:test';
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import * as fs from 'node:fs';
|
||||
import * as path from 'node:path';
|
||||
import { READ_ONLY_RETRY } from '../lib/review-brief';
|
||||
import { planCyberRetry, type Manifest } from '../lib/review-pass';
|
||||
import { ROOT, BIN, repo, cleanReply, host, runPass, bin } from './helpers/review-pass-harness';
|
||||
|
||||
describe('Capy pass program (fake host, real bins)', () => {
|
||||
// Value: protects=GST-1104 (TRUT-7, truther#1159): an outside voice that runs past the stuck limit, or ends stopped or failed with no result, is stopped and recorded as unavailable coverage under its own runner and model, and Step 11 goes on to judge the native voice; fails_when=the stuck subagent is left running (TRUT-7 p2 burned 16.9M tokens before anyone stopped it), the pass stops with nothing recorded, or the returned record names no host-subagent runner so the review-log row falls back to the template's codex;
|
||||
// why_new=GST-1104; seam=lib/capy-review-pass.js reader poll; no_claim=which outside model Step 11 picks
|
||||
test('an outside voice that hangs or stops with no result is stopped and recorded unavailable as the host subagent, and Step 11 goes on (GST-1104)', async () => {
|
||||
for (const [pass, o] of [['x30p1', { hang: (t: string) => t.endsWith('outside-voice') }], ['x31p1', { stopped: (t: string) => t.endsWith('outside-voice') }], ['x32p1', { fail: (t: string) => t.endsWith('outside-voice') }]] as const) {
|
||||
const { dir, env } = repo();
|
||||
const out = path.join(dir, '.state/run/p1');
|
||||
const h = host(dir, env, { ...o, epoch: Date.now() });
|
||||
const base = { base: 'main', out, pass, planFlags: ['--depth-floor', 'full'] };
|
||||
expect(await runPass(h, base)).toContain('NEXT: judge (Phase 4)');
|
||||
let res = '';
|
||||
for (let i = 0; i < 6; i++) {
|
||||
res = await runPass(h, { ...base, stage: 'voices', stuckMs: 60_000 });
|
||||
if (!res.includes('NEXT: poll')) break;
|
||||
}
|
||||
expect(res).not.toContain('STOP:');
|
||||
expect(res).toContain('COLLECT_UNAVAILABLE: reader=outside-voice');
|
||||
expect(res).toContain('OUTSIDE_RECORD: "outside_provider":"host-subagent","outside_model":"openai/gpt-6.1-sol","outside_status":"unavailable"');
|
||||
expect(res).toContain('first write this voice its own adversarial-review row with "source":"host-subagent","status":"unavailable","completed":false,"converged":false and no --finish, then the native row');
|
||||
expect(res).toContain('NEXT: judge the voices');
|
||||
if ('hang' in o) {
|
||||
const token = /REVIEW_LOG_START: adversarial-review token=(\S+)/.exec(res)![1]!;
|
||||
const record = /OUTSIDE_RECORD: (\S+)/.exec(res)![1]!;
|
||||
const log = (row: string, a: string[] = []) => spawnSync(path.join(BIN, 'gstack-review-log'), [row, ...a], { cwd: dir, env, encoding: 'utf8', timeout: 60_000 });
|
||||
expect(log('{"skill":"adversarial-review","status":"unavailable","source":"host-subagent",' + record + ',"phase":"adversarial","completed":false,"converged":false}').status).toBe(0);
|
||||
expect(log('{"skill":"adversarial-review","status":"clean","source":"in-host",' + record + ',"phase":"adversarial","completed":true,"converged":true}', ['--finish', token]).status).toBe(0);
|
||||
const rows = spawnSync(path.join(BIN, 'gstack-review-read'), [], { cwd: dir, env, encoding: 'utf8', timeout: 60_000 }).stdout.split('---CONFIG---')[0]!.trim().split('\n').map(l => JSON.parse(l));
|
||||
expect(rows.map(r => [r.source, r.outside_provider, r.outside_status, r.converged])).toEqual([['host-subagent', 'host-subagent', 'unavailable', false], ['in-host', 'host-subagent', 'unavailable', true]]);
|
||||
expect(rows[1].review_freshness).toMatchObject({ status: 'CURRENT' });
|
||||
}
|
||||
const ov = [...h.subs].find(([, s]) => s.title === 'ship ' + pass + ' outside-voice')!;
|
||||
expect(ov[1].status).not.toBe('working');
|
||||
expect(h.stops).toEqual('hang' in o ? [ov[0]] : []);
|
||||
const v = bin(dir, env, ['verify', '--ledger', path.join(out, 'review-ledger.jsonl')]);
|
||||
expect(v.stdout).toMatch(/^BRIEF outside-voice UNAVAILABLE/m);
|
||||
expect(v.stdout).not.toContain('MISMATCH');
|
||||
expect(v.stdout).toContain('unavailable=1');
|
||||
}
|
||||
}, 600_000);
|
||||
|
||||
// Value: protects=GST-1104 review finding: an outside voice that wrote its report and then ended stopped or failed is collected from its summary, never replaced by unavailable coverage; fails_when=the pass records the voice unavailable without reading the summary, silently dropping its findings;
|
||||
// why_new=GST-1104 /ship review (three readers); seam=lib/capy-review-pass.js reader poll; no_claim=what the voice found
|
||||
test('an outside voice that ends stopped or failed with a report is collected, not marked unavailable (GST-1104)', async () => {
|
||||
for (const [pass, o] of [['x33p1', { stopped: (t: string) => t.endsWith('outside-voice') }], ['x34p1', { fail: (t: string) => t.endsWith('outside-voice') }]] as const) {
|
||||
const { dir, env } = repo();
|
||||
const out = path.join(dir, '.state/run/p1');
|
||||
const h = host(dir, env, { ...o, keepSummary: true, output: (t: string) => (t.endsWith('outside-voice') ? '1. **A guard fails open** - `src/a.ts:1` accepts any input. Severity: Medium. Blocks: no.\n\nRecommendation: fix the guard because it fails open' : cleanReply(t)), epoch: Date.now() });
|
||||
const base = { base: 'main', out, pass, planFlags: ['--depth-floor', 'full'] };
|
||||
expect(await runPass(h, base)).toContain('NEXT: judge (Phase 4)');
|
||||
let res = '';
|
||||
for (let i = 0; i < 6; i++) {
|
||||
res = await runPass(h, { ...base, stage: 'voices', stuckMs: 60_000 });
|
||||
if (!res.includes('NEXT: poll')) break;
|
||||
}
|
||||
expect(res).not.toContain('STOP:');
|
||||
expect(res).not.toContain('COLLECT_UNAVAILABLE: reader=outside-voice');
|
||||
expect(res).toContain('OUTSIDE_RECORD: "outside_provider":"host-subagent","outside_model":"openai/gpt-6.1-sol","outside_status":"completed"');
|
||||
expect(res).toContain('NEXT: judge the voices');
|
||||
}
|
||||
}, 600_000);
|
||||
|
||||
// Value: protects=GST-1104 review finding: an outside voice that ends stopped or failed with a summary that is not a review is recorded unavailable and Step 11 goes on; fails_when=collect's COLLECT_NOT_REVIEWED stops the pass and every rerun stops the same way;
|
||||
// why_new=GST-1104 /ship review round 2; seam=lib/capy-review-pass.js reader collect; no_claim=what the summary says
|
||||
test('an outside voice that ends stopped with a non-review summary is recorded unavailable, not a stuck pass (GST-1104)', async () => {
|
||||
const { dir, env } = repo();
|
||||
const out = path.join(dir, '.state/run/p1');
|
||||
const h = host(dir, env, { stopped: (t: string) => t.endsWith('outside-voice'), keepSummary: true, output: (t: string) => (t.endsWith('outside-voice') ? 'Stopped before I could read the diff.' : cleanReply(t)), epoch: Date.now() });
|
||||
const base = { base: 'main', out, pass: 'x35p1', planFlags: ['--depth-floor', 'full'] };
|
||||
expect(await runPass(h, base)).toContain('NEXT: judge (Phase 4)');
|
||||
let res = '';
|
||||
for (let i = 0; i < 6; i++) {
|
||||
res = await runPass(h, { ...base, stage: 'voices', stuckMs: 60_000 });
|
||||
if (!res.includes('NEXT: poll')) break;
|
||||
}
|
||||
expect(res).not.toContain('STOP:');
|
||||
expect(res).toContain('COLLECT_UNAVAILABLE: reader=outside-voice');
|
||||
expect(res).toContain('"outside_status":"unavailable"');
|
||||
expect(res).toContain('NEXT: judge the voices');
|
||||
const v = bin(dir, env, ['verify', '--ledger', path.join(out, 'review-ledger.jsonl')]);
|
||||
expect(v.stdout).toMatch(/^BRIEF outside-voice UNAVAILABLE/m);
|
||||
expect(v.stdout).not.toContain('MISMATCH');
|
||||
expect(v.stdout).not.toContain('NOT_REVIEWED');
|
||||
}, 300_000);
|
||||
|
||||
// R95 (2026-11-13): a cyber_policy refusal of the outside voice is retried once on GPT-6 Astra with the read-only brief, then on Gemini 4 Carbon with the original brief; when every attempt fails the second-family read is missing, disclosed, and Step 11 goes on.
|
||||
const CYBER = fs.readFileSync(path.join(ROOT, 'test/fixtures/cyber-policy/capy-latest-error.txt'), 'utf8').trim();
|
||||
const voiceReply = (t: string) => (t.includes('outside-voice') ? 'Recommendation: ship as-is because no finding survived' : cleanReply(t));
|
||||
async function refusedVoices(pass: string, error: (title: string) => string | undefined, lane: Record<string, unknown> = {}) {
|
||||
const { dir, env } = repo();
|
||||
const out = path.join(dir, '.state/run/p1');
|
||||
const h = host(dir, env, { error, output: voiceReply, epoch: Date.now() });
|
||||
const base = { base: 'main', out, pass, planFlags: ['--depth-floor', 'full'], ...lane };
|
||||
expect(await runPass(h, base)).toContain('NEXT: judge (Phase 4)');
|
||||
let res = '', all = '';
|
||||
for (let i = 0; i < 12; i++) {
|
||||
res = await runPass(h, { ...base, stage: 'voices', stuckMs: 60_000 });
|
||||
all += res + '\n';
|
||||
if (!res.includes('NEXT: poll')) break;
|
||||
}
|
||||
const created = (suffix: string) => h.creates.find(c => c.title === 'ship ' + pass + ' ' + suffix);
|
||||
const verify = bin(dir, env, ['verify', '--ledger', path.join(out, 'review-ledger.jsonl')]).stdout;
|
||||
return { res, all, h, created, verify, base };
|
||||
}
|
||||
|
||||
// Value: protects=R95 on the real pass program: Capy's captured cyber_policy refusal of the Sol outside voice is recorded unavailable with its own reason and retried once on openai/gpt-6-astra with the read-only brief, whose review is the Step 11 outside record; fails_when=the refusal is recorded as a plain failure with no retry, the retry resends the original brief, or the original's unavailable record replaces the retry's;
|
||||
// why_new=R95; seam=lib/capy-review-pass.js ended outside voice; no_claim=that Astra finishes a real refused brief (one live smoke in GSTA-537)
|
||||
test('a cyber_policy refusal is retried once on Astra with the read-only brief (R95)', async () => {
|
||||
const { res, all, h, created, verify } = await refusedVoices('x40p1', t => (t.endsWith(' outside-voice') ? CYBER : undefined));
|
||||
expect(res).not.toContain('STOP:');
|
||||
expect(all).toContain('RETRY: reader=outside-voice/astra-read-only model=openai/gpt-6-astra brief=read-only');
|
||||
expect(all).toMatch(/COLLECT_UNAVAILABLE: reader=outside-voice .*/);
|
||||
const astra = created('outside-voice/astra-read-only')!;
|
||||
expect(astra.model).toEqual({ model_id: 'openai/gpt-6-astra', reasoning_mode: 'high' });
|
||||
expect(astra.prompt).toContain(READ_ONLY_RETRY);
|
||||
expect(astra.prompt).not.toContain('Think like an attacker');
|
||||
expect(created('outside-voice')!.prompt).toContain('Think like an attacker and a chaos engineer.');
|
||||
expect(created('outside-voice/gemini-4-carbon')).toBeUndefined();
|
||||
expect(res).toContain('OUTSIDE_RECORD: "outside_provider":"host-subagent","outside_model":"openai/gpt-6-astra","outside_status":"completed","outside_note":"second-family read by openai/gpt-6-astra on the read-only retry brief after cyber_policy refused openai/gpt-6.1-sol"');
|
||||
expect(res).not.toContain('"outside_model":"openai/gpt-6.1-sol"');
|
||||
expect(res).toContain('NEXT: judge the voices');
|
||||
expect(verify).toMatch(/^BRIEF outside-voice UNAVAILABLE/m);
|
||||
expect(verify).toMatch(/^OUTPUT outside-voice UNAVAILABLE .*reason=".*cyber_policy/m);
|
||||
expect(verify).toMatch(/^BRIEF outside-voice\/astra-read-only MATCH/m);
|
||||
expect(verify).not.toContain('MISMATCH');
|
||||
expect(verify).toMatch(/^VERIFY: .* unavailable=1$/m);
|
||||
expect(h.creates.filter(c => c.title.includes('outside-voice')).length).toBe(2);
|
||||
}, 600_000);
|
||||
|
||||
// Value: protects=an Astra refusal of the retry falls through to google/gemini-4-carbon with the original brief byte for byte, and a refusal or failure there records the second-family read as missing (a disclosed gap, not a pass) while Step 11 goes on to the native voice; fails_when=a fourth attempt starts, Gemini gets the reworded brief, or the exhausted chain STOPs the pass;
|
||||
// why_new=R95; seam=lib/capy-review-pass.js retry chain; no_claim=Gemini's availability under another organization's model policy
|
||||
test('an Astra refusal falls through to Gemini 4 Carbon with the original brief, then the second-family read is missing (R95)', async () => {
|
||||
const { res, all, h, created, verify } = await refusedVoices('x41p1', t => (/outside-voice(\/astra-read-only|\/gemini-4-carbon)?$/.test(t) ? CYBER : undefined));
|
||||
expect(res).not.toContain('STOP:');
|
||||
expect(all).toContain('RETRY: reader=outside-voice/astra-read-only model=openai/gpt-6-astra brief=read-only');
|
||||
expect(all).toContain('RETRY: reader=outside-voice/gemini-4-carbon model=google/gemini-4-carbon brief=original');
|
||||
expect(all).toContain('RETRY: exhausted');
|
||||
const gemini = created('outside-voice/gemini-4-carbon')!;
|
||||
expect(gemini.model).toEqual({ model_id: 'google/gemini-4-carbon', reasoning_mode: 'high' });
|
||||
expect(gemini.prompt).toBe(created('outside-voice')!.prompt);
|
||||
expect(h.creates.filter(c => c.title.includes('outside-voice')).length).toBe(3);
|
||||
expect(res).toContain('"outside_model":"google/gemini-4-carbon","outside_status":"unavailable","outside_note":"second-family read missing: cyber_policy refused openai/gpt-6.1-sol, openai/gpt-6-astra (read-only retry brief) and google/gemini-4-carbon"');
|
||||
expect(res).toContain('first write this voice its own adversarial-review row');
|
||||
expect(res).toContain('NEXT: judge the voices');
|
||||
expect(verify).not.toContain('MISMATCH');
|
||||
expect(verify).toMatch(/^BRIEF outside-voice\/gemini-4-carbon UNAVAILABLE/m);
|
||||
expect(verify).toMatch(/^VERIFY: .* unavailable=3$/m);
|
||||
}, 900_000);
|
||||
|
||||
// Value: protects=on a Google-family lane the Gemini step is skipped (Step 11 refuses an outside voice of the lane's family), so two OpenAI refusals record the second-family read as missing and a resume finishes instead of stopping; fails_when=Gemini is planned beside a Google lane and familyStop stops every resume;
|
||||
// why_new=GSTA-537 /ship outside-voice finding (lib/review-pass.ts:274), fixed under the Captain's scoped fix-check grant; seam=planCyberRetry via gstack-review-dispatch retry; no_claim=which outside voice a Google lane should use
|
||||
test('a Google-family lane skips the Gemini retry and records the second-family read missing, with no STOP on resume (R95)', async () => {
|
||||
const lane = { laneModel: 'google/gemini-4-argon', models: { 'outside-voice': { model_id: 'openai/gpt-6.1-sol', reasoning_mode: 'medium' } } };
|
||||
const { res, all, h, created, base } = await refusedVoices('x45p1', t => (/outside-voice(\/astra-read-only)?$/.test(t) ? CYBER : undefined), lane);
|
||||
expect(all).not.toContain('STOP:');
|
||||
expect(all).toContain('RETRY: reader=outside-voice/astra-read-only model=openai/gpt-6-astra brief=read-only');
|
||||
expect(all).toContain('RETRY: exhausted reader=outside-voice/astra-read-only');
|
||||
expect(created('outside-voice/gemini-4-carbon')).toBeUndefined();
|
||||
expect(res).toContain('"outside_status":"unavailable","outside_note":"second-family read missing: cyber_policy refused openai/gpt-6.1-sol and openai/gpt-6-astra (read-only retry brief)"');
|
||||
expect(res).toContain('NEXT: judge the voices');
|
||||
const again = await runPass(h, { ...base, stage: 'voices', stuckMs: 60_000 });
|
||||
expect(again).not.toContain('STOP:');
|
||||
}, 600_000);
|
||||
|
||||
// Value: protects=planCyberRetry skips only the steps whose family the lane or native voice holds: an Anthropic lane still gets Astra then Gemini, a Google lane gets Astra and then nothing; fails_when=the family check drops Gemini for every lane or keeps it beside a Google lane;
|
||||
// why_new=GSTA-537 scoped fix-check (control for the Google-lane case); seam=lib/review-pass.ts planCyberRetry; no_claim=none
|
||||
test('planCyberRetry keeps Gemini for an Anthropic lane and skips it for a Google lane (R95)', () => {
|
||||
const chain = (taken: string[]) => {
|
||||
const m = { pass: 'u1', readers: [{ reader: 'outside-voice', role: 'outside-voice', stage: 'voices', state: 'collected' }] } as unknown as Manifest;
|
||||
const astra = planCyberRetry(m, m.readers[0]!, taken);
|
||||
return [astra?.reader, astra ? planCyberRetry(m, astra, taken)?.reader ?? null : null];
|
||||
};
|
||||
expect(chain(['anthropic'])).toEqual(['outside-voice/astra-read-only', 'outside-voice/gemini-4-carbon']);
|
||||
expect(chain(['google'])).toEqual(['outside-voice/astra-read-only', null]);
|
||||
});
|
||||
|
||||
// Value: protects=only cyber_policy starts a retry: a failed voice whose host error is another provider failure, and a voice that reviews normally, each run exactly one outside voice; fails_when=any failure, or a success, dispatches an Astra or Gemini reader;
|
||||
// why_new=R95 (no new retries for anything else; negative control); seam=lib/capy-review-pass.js; no_claim=none
|
||||
test('a non-refusal failure and a normal review never retry (R95)', async () => {
|
||||
const failed = await refusedVoices('x42p1', t => (t.endsWith(' outside-voice') ? 'OpenAI key declined the request: invalid_api_key: Incorrect API key provided.' : undefined));
|
||||
expect(failed.res).not.toContain('STOP:');
|
||||
expect(failed.all).toContain('RETRY: none');
|
||||
expect(failed.res).toContain('"outside_model":"openai/gpt-6.1-sol","outside_status":"unavailable"');
|
||||
expect(failed.h.creates.filter(c => c.title.includes('outside-voice')).length).toBe(1);
|
||||
const clean = await refusedVoices('x43p1', () => undefined);
|
||||
expect(clean.all).not.toContain('RETRY:');
|
||||
expect(clean.res).toContain('"outside_model":"openai/gpt-6.1-sol","outside_status":"completed"');
|
||||
expect(clean.res).not.toContain('outside_note');
|
||||
expect(clean.h.creates.filter(c => c.title.includes('outside-voice')).length).toBe(1);
|
||||
}, 600_000);
|
||||
|
||||
// Value: protects=a voice that the host marks refused under cyber_policy but that still wrote a review is collected as that review, with its own outside record, and starts no retry; fails_when=the retry is planned before the program knows the voice left findings, so a redundant Astra reader runs and the collected voice's OUTSIDE_RECORD is dropped;
|
||||
// why_new=GSTA-537 /ship red-team finding (capy-review-pass.js refusal before collect); seam=lib/capy-review-pass.js ended outside voice; no_claim=how often a refused voice leaves a review
|
||||
test('a cyber_policy refusal that still left a review is collected and never retried (R95)', async () => {
|
||||
const { dir, env } = repo();
|
||||
const out = path.join(dir, '.state/run/p1');
|
||||
const h = host(dir, env, { error: t => (t.endsWith(' outside-voice') ? CYBER : undefined), keepSummary: true, output: t => (t.endsWith('outside-voice') ? '1. **A guard fails open** - `src/a.ts:1` accepts any input. Severity: Medium. Blocks: no.\n\nRecommendation: fix the guard because it fails open' : cleanReply(t)), epoch: Date.now() });
|
||||
const base = { base: 'main', out, pass: 'x44p1', planFlags: ['--depth-floor', 'full'] };
|
||||
expect(await runPass(h, base)).toContain('NEXT: judge (Phase 4)');
|
||||
let res = '', all = '';
|
||||
for (let i = 0; i < 6; i++) {
|
||||
res = await runPass(h, { ...base, stage: 'voices', stuckMs: 60_000 });
|
||||
all += res + '\n';
|
||||
if (!res.includes('NEXT: poll')) break;
|
||||
}
|
||||
expect(res).not.toContain('STOP:');
|
||||
expect(all).not.toContain('RETRY:');
|
||||
expect(h.creates.filter(c => c.title.includes('outside-voice')).length).toBe(1);
|
||||
expect(res).toContain('OUTSIDE_RECORD: "outside_provider":"host-subagent","outside_model":"openai/gpt-6.1-sol","outside_status":"completed"');
|
||||
expect(fs.readFileSync(path.join(out, 'merged.jsonl'), 'utf8')).toContain('A guard fails open');
|
||||
}, 300_000);
|
||||
});
|
||||
+3
-1234
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user