mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-29 03:15:05 +01:00
feat(ship): reviewers read one packet; the parent reads only a compact findings record (GSTA-167)
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
53db038c6b
commit
23ea02a72c
27 files changed
+1300
-268
No files matched your search
@@ -20,7 +20,7 @@ describe('defensive-security framing reaches every adversarial dispatch', () =>
|
||||
expect(DEFENSIVE_REVIEW_FRAMING.startsWith(FRAMING_SENTENCE)).toBe(true);
|
||||
expect(FIXTURE_SUMMARY_MODE).toContain('review in SUMMARY mode only');
|
||||
|
||||
for (const skill of ['review', 'ship']) {
|
||||
for (const skill of ['review']) {
|
||||
const army = fs.readFileSync(path.join(ROOT, skill, 'sections', 'review-army.md'), 'utf-8');
|
||||
const adversarial = fs.readFileSync(path.join(ROOT, skill, 'sections', 'adversarial.md'), 'utf-8');
|
||||
|
||||
@@ -50,6 +50,16 @@ describe('defensive-security framing reaches every adversarial dispatch', () =>
|
||||
});
|
||||
}
|
||||
|
||||
// /ship's reviewers read packets: test/review-packet.test.ts proves the security, Red Team and adversarial
|
||||
// packets carry the framing with fixtures as a stat, and the testing packet reads fixtures in full.
|
||||
test('ship: the Red Team and adversarial packets are named as carrying the framing and fixture summary mode', () => {
|
||||
const army = fs.readFileSync(path.join(ROOT, 'ship', 'sections', 'review-army.md'), 'utf-8').replace(/\s+/g, ' ');
|
||||
const adversarial = fs.readFileSync(path.join(ROOT, 'ship', 'sections', 'adversarial.md'), 'utf-8').replace(/\s+/g, ' ');
|
||||
expect(army).toContain('the defensive framing and the diff with fixtures in summary mode');
|
||||
expect(adversarial).toContain('packet carries the defensive framing, the prompt below, the diff with fixtures in summary mode');
|
||||
expect(army).not.toContain(FRAMING_SENTENCE);
|
||||
});
|
||||
|
||||
test('codex host still strips Review Army (specialists and Red Team)', () => {
|
||||
expect(generateReviewArmy({ skillName: 'review', tmplPath: '', host: 'codex', paths: HOST_PATHS.codex })).toBe('');
|
||||
expect(generateReviewArmy({ skillName: 'ship', tmplPath: '', host: 'codex', paths: HOST_PATHS.codex })).toBe('');
|
||||
|
||||
@@ -9,6 +9,7 @@ import { describe, expect, test } from 'bun:test';
|
||||
import * as fs from 'node:fs';
|
||||
import * as path from 'node:path';
|
||||
import { generateReviewArmy } from '../scripts/resolvers/review-army';
|
||||
import { SPECIALIST_CONTRACT } from '../lib/review-prompts';
|
||||
import { HOST_PATHS } from '../scripts/resolvers/types';
|
||||
|
||||
const ROOT = path.resolve(import.meta.dir, '..');
|
||||
@@ -45,9 +46,13 @@ describe('review-loop budget wording', () => {
|
||||
expect(judgment.length).toBeGreaterThan(200);
|
||||
for (const filter of ['Nit gravity', 'Hypothetical, not actual', 'Structure for a case that does not exist', 'A different design is not a defect', 'Missing context']) expect(judgment).toContain(filter);
|
||||
expect(judgment).toContain('returned `NO FINDINGS` was right');
|
||||
}
|
||||
// /review renders the specialist prompt; /ship's reviewers read it from their packet (lib/review-prompts.ts).
|
||||
for (const text of [rendered[1]!, read('review/sections/review-army.md'), SPECIALIST_CONTRACT]) {
|
||||
expect(text).toContain('names the changed line in `cause`');
|
||||
expect(text).toContain('Optional: line, fix, fingerprint, evidence, test_stub, advisory, evidence_paths, helper_target, cause.');
|
||||
}
|
||||
for (const text of [rendered[0]!, read('ship/sections/review-army.md')]) expect(text).toContain('gstack-review-packet build');
|
||||
});
|
||||
|
||||
test('docs/review-policy.md states the glossary, the stop rules and lead judgment once', () => {
|
||||
|
||||
@@ -0,0 +1,265 @@
|
||||
/**
|
||||
* gstack-review-packet: each /ship reviewer reads one packet file and the parent reads only
|
||||
* collect's record (docs/review-policy.md#reviewer-packets). Fixture repositories live under
|
||||
* the OS temp directory, outside this checkout, and every seed commit is asserted.
|
||||
*/
|
||||
import { afterEach, describe, expect, test } from 'bun:test';
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import * as fs from 'node:fs';
|
||||
import * as os from 'node:os';
|
||||
import * as path from 'node:path';
|
||||
import * as P from '../lib/review-prompts';
|
||||
import { shardChunks } from '../lib/review-packet';
|
||||
|
||||
const ROOT = path.join(import.meta.dir, '..');
|
||||
const BIN = path.join(ROOT, 'bin', 'gstack-review-packet');
|
||||
const dirs: string[] = [];
|
||||
afterEach(() => { while (dirs.length) fs.rmSync(dirs.pop()!, { recursive: true, force: true }); });
|
||||
const tmp = (p: string) => { const d = fs.mkdtempSync(path.join(os.tmpdir(), p)); dirs.push(d); return d; };
|
||||
|
||||
interface Repo { dir: string; state: string; out: string }
|
||||
function repo(base: Record<string, string>, feat: Record<string, string>, untracked: Record<string, string> = {}): Repo {
|
||||
const dir = tmp('review-packet-');
|
||||
expect(path.relative(ROOT, dir).startsWith('..')).toBe(true);
|
||||
const git = (...a: string[]) => spawnSync('git', a, { cwd: dir, encoding: 'utf8', timeout: 10_000 });
|
||||
const write = (files: Record<string, string>) => { for (const [p, text] of Object.entries(files)) { fs.mkdirSync(path.dirname(path.join(dir, p)), { recursive: true }); fs.writeFileSync(path.join(dir, p), text); } };
|
||||
git('init', '-q', '-b', 'main'); git('config', 'user.email', 'fixture@example.com'); git('config', 'user.name', 'Fixture'); git('config', 'commit.gpgsign', 'false');
|
||||
write({ 'README.md': '# x\n', ...base });
|
||||
git('add', '.');
|
||||
expect(git('commit', '-qm', 'base').status).toBe(0);
|
||||
git('checkout', '-qb', 'feat');
|
||||
write(feat);
|
||||
git('add', '.');
|
||||
expect(git('commit', '-qm', 'feat').status).toBe(0);
|
||||
write(untracked);
|
||||
return { dir, state: tmp('review-packet-state-'), out: tmp('review-packet-out-') };
|
||||
}
|
||||
const run = (r: Repo, args: string[]) => spawnSync(BIN, args, { cwd: r.dir, encoding: 'utf8', timeout: 120_000, env: { ...process.env, GSTACK_STATE_ROOT: r.state } });
|
||||
const build = (r: Repo, extra: string[] = []) => run(r, ['build', '--base', 'main', '--gate-tagged', '0', '--out-dir', r.out, ...extra]);
|
||||
const packets = (stdout: string) => [...stdout.matchAll(/^PACKET: (\S+) (\S+) effort=\S+ bytes=(\d+) tokens~=\d+ file=(\S+) out=(\S+)$/gm)].map(m => ({ role: m[1]!, name: m[2]!, bytes: Number(m[3]), file: m[4]!, out: m[5]!, text: fs.readFileSync(m[4]!, 'utf8') }));
|
||||
const lines = (n: number, tag: string) => Array.from({ length: n }, (_, i) => `export const ${tag}${i} = ${i};`).join('\n') + '\n';
|
||||
const checklist = (name: string) => fs.readFileSync(path.join(ROOT, 'review', 'specialists', `${name}.md`), 'utf8');
|
||||
|
||||
describe('gstack-review-packet build', () => {
|
||||
test('a packet holds its instructions, contract, checklist, the diff and read budget, and no other repository content', () => {
|
||||
const r = repo({ 'src/unrelated.ts': 'export const UNRELATED_MARKER = 1;\n' }, { 'src/a.ts': lines(80, 'alpha') });
|
||||
const b = build(r);
|
||||
expect(b.status).toBe(0);
|
||||
const all = packets(b.stdout);
|
||||
const testing = all.find(p => p.name === 'testing')!;
|
||||
expect(testing.text).toContain(P.SPECIALIST_INTRO);
|
||||
expect(testing.text).toContain(P.SPECIALIST_CONTRACT.replace('{TEST_FW}', 'unknown'));
|
||||
expect(testing.text).toContain(checklist('testing'));
|
||||
expect(testing.text).toContain('+export const alpha79 = 79;');
|
||||
expect(testing.text).toContain(P.READ_BUDGET);
|
||||
expect(testing.text).toContain(`Output path: \`${testing.out}\``);
|
||||
expect(testing.text).toContain('DONE testing crit=<n> info=<n>');
|
||||
for (const p of all) expect(p.text).not.toContain('UNRELATED_MARKER');
|
||||
expect(b.stdout).toMatch(/^PACKETS: n=\d+ total_bytes=\d+ fingerprint=\S+$/m);
|
||||
expect(all.find(p => p.name === 'adversarial')!.text).toContain(P.ADVERSARIAL_NATIVE);
|
||||
});
|
||||
|
||||
test('the defensive framing reaches the security and adversarial packets with fixtures as a stat; testing reads fixtures in full', () => {
|
||||
const r = repo({}, { 'src/auth/login.ts': lines(120, 'auth'), 'test/login.test.ts': 'PAYLOAD_MARKER\n' });
|
||||
const all = packets(build(r, ['--force', 'security']).stdout);
|
||||
for (const name of ['security', 'adversarial']) {
|
||||
const p = all.find(x => x.name === name)!;
|
||||
expect(p.text).toContain(P.DEFENSIVE_REVIEW_FRAMING);
|
||||
expect(p.text).toContain(P.FIXTURE_SUMMARY_PACKET);
|
||||
expect(p.text).not.toContain('+PAYLOAD_MARKER');
|
||||
expect(p.text).toContain('test/login.test.ts');
|
||||
}
|
||||
const testing = all.find(x => x.name === 'testing')!;
|
||||
expect(testing.text).not.toContain(P.DEFENSIVE_REVIEW_FRAMING);
|
||||
expect(testing.text).toContain('+PAYLOAD_MARKER');
|
||||
});
|
||||
|
||||
test('light depth: the batched specialist inlines every checklist its plan line names', () => {
|
||||
const r = repo({}, { 'src/a.ts': lines(10, 'beta') });
|
||||
const plan = spawnSync(path.join(ROOT, 'bin', 'gstack-review-plan'), ['--base', 'main', '--gate-tagged', '0'], { cwd: r.dir, encoding: 'utf8', timeout: 60_000, env: { ...process.env, GSTACK_STATE_ROOT: r.state } });
|
||||
const named = /DISPATCH: specialist batched effort=\S+ checklists=(\S+)/.exec(plan.stdout)![1]!.split(',');
|
||||
expect(named).toContain('red-team');
|
||||
const batched = packets(build(r).stdout).find(p => p.name === 'batched')!;
|
||||
for (const c of named) {
|
||||
expect(batched.text).toContain(`## Checklist: ${c}`);
|
||||
expect(batched.text).toContain(checklist(c));
|
||||
}
|
||||
expect(batched.text).toContain('Tag each finding with the checklist that found it');
|
||||
});
|
||||
|
||||
test('exclusions are honored: maintainability leaves out docs and tests; testing keeps tests; untracked files are in', () => {
|
||||
const r = repo({}, { 'src/a.ts': lines(80, 'gamma'), 'docs/guide.md': '# Guide\nDOCS_MARKER\n', 'test/a.test.ts': 'TEST_MARKER\n' }, { 'src/new.ts': 'UNTRACKED_MARKER\n' });
|
||||
const all = packets(build(r).stdout);
|
||||
const m = all.find(p => p.name === 'maintainability')!;
|
||||
const t = all.find(p => p.name === 'testing')!;
|
||||
expect(m.text).not.toContain('+DOCS_MARKER');
|
||||
expect(m.text).not.toContain('+TEST_MARKER');
|
||||
expect(m.text).toContain('+UNTRACKED_MARKER');
|
||||
expect(t.text).toContain('+TEST_MARKER');
|
||||
expect(t.text).not.toContain('+DOCS_MARKER');
|
||||
});
|
||||
|
||||
test('a diff past the cap is sharded by path: every path and every line survives, each packet under the cap', () => {
|
||||
const files: Record<string, string> = {};
|
||||
for (let i = 0; i < 30; i++) files[`src/f${i}.ts`] = lines(400, `v${i}_`);
|
||||
const r = repo({}, files);
|
||||
const b = build(r, ['--only', 'testing']);
|
||||
expect(b.status).toBe(0);
|
||||
const shards = packets(b.stdout);
|
||||
expect(shards.length).toBeGreaterThan(1);
|
||||
expect(shards.map(s => s.name)).toEqual(shards.map((_, i) => `testing.${i + 1}of${shards.length}`));
|
||||
for (const s of shards) { expect(s.bytes).toBeLessThanOrEqual(200_000); expect(s.text).toContain(checklist('testing')); }
|
||||
const diffs = shards.map(s => s.text.slice(s.text.indexOf('## Diff (')));
|
||||
for (let i = 0; i < 30; i++) {
|
||||
expect(diffs.filter(d => d.includes(`diff --git a/src/f${i}.ts b/src/f${i}.ts`)).length).toBe(1);
|
||||
expect(diffs.some(d => d.includes(`+export const v${i}_399 = 399;`))).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
test('shardChunks splits a file at hunks and gives a hunk over the budget its own oversize shard, never truncated', () => {
|
||||
const header = 'diff --git a/x b/x\n--- a/x\n+++ b/x\n';
|
||||
const big = '@@ -1 +1 @@\n' + '+y\n'.repeat(100);
|
||||
const small = '@@ -50 +50 @@\n+z\n';
|
||||
const shards = shardChunks([header + small + big + small, 'diff --git a/w b/w\n@@ -1 +1 @@\n+w\n'], 120);
|
||||
expect(shards.some(s => s.oversize && s.text === header + big)).toBe(true);
|
||||
expect(shards.map(s => s.text).join('').replaceAll(header, '')).toContain(big);
|
||||
expect(shards.at(-1)!.text).toContain('+w');
|
||||
});
|
||||
|
||||
test('the Red Team is deferred until collect; with --findings it reads them, the framing and fixtures in summary mode', () => {
|
||||
const r = repo({}, { 'src/a.ts': lines(260, 'delta'), 'test/fixture.test.ts': 'PAYLOAD_MARKER\n' });
|
||||
expect(build(r).stdout).toContain('PACKET_DEFERRED: red-team');
|
||||
const merged = path.join(r.out, 'merged.jsonl');
|
||||
fs.writeFileSync(merged, JSON.stringify({ severity: 'CRITICAL', path: 'src/a.ts', line: 3, summary: 'KNOWN_FINDING', sources: ['testing'] }) + '\n');
|
||||
const red = packets(build(r, ['--only', 'red-team', '--findings', merged]).stdout)[0]!;
|
||||
expect(red.name).toBe('red-team');
|
||||
expect(red.text).toContain('KNOWN_FINDING');
|
||||
expect(red.text).toContain(P.DEFENSIVE_REVIEW_FRAMING);
|
||||
expect(red.text).toContain(P.RED_TEAM_OUTPUT);
|
||||
expect(red.text).toContain(checklist('red-team'));
|
||||
expect(red.text).not.toContain('+PAYLOAD_MARKER');
|
||||
expect(red.text).toContain('test/fixture.test.ts');
|
||||
const manifest = JSON.parse(fs.readFileSync(path.join(r.out, 'manifest.json'), 'utf8'));
|
||||
expect(manifest.packets.some((p: any) => p.name === 'testing')).toBe(true);
|
||||
});
|
||||
|
||||
test('fix-check: the packet carries the fix-check prompt, the parent files and the --range hunks; missing inputs refuse', () => {
|
||||
const r = repo({}, { 'src/a.ts': lines(20, 'eps') });
|
||||
const head = spawnSync('git', ['rev-parse', 'HEAD'], { cwd: r.dir, encoding: 'utf8', timeout: 10_000 }).stdout.trim();
|
||||
fs.appendFileSync(path.join(r.dir, 'src/a.ts'), 'export const FIXED = 1;\n');
|
||||
const flags = ['--pass', '1', '--last', 'full', '--fixed-below', '--range', head];
|
||||
expect(build(r, flags).status).toBe(2);
|
||||
const w = (n: string, t: string) => { const f = path.join(r.state, n); fs.writeFileSync(f, t); return f; };
|
||||
const b = build(r, [...flags, '--fix-list', w('fix.txt', 'FIX_LIST_MARKER'), '--tests', w('tests.txt', '12 pass')]);
|
||||
const fc = packets(b.stdout).find(p => p.role === 'fix-check')!;
|
||||
expect(fc.text).toContain(P.FIX_CHECK_INSTRUCTIONS);
|
||||
expect(fc.text).toContain('FIX_LIST_MARKER');
|
||||
expect(fc.text).toContain('+export const FIXED = 1;');
|
||||
expect(fc.text).not.toContain('+export const eps0 = 0;');
|
||||
});
|
||||
|
||||
test('audits: the packet carries the generated section prompt fence with the base filled in', () => {
|
||||
const r = repo({}, { 'src/a.ts': lines(20, 'zeta') });
|
||||
const a = packets(build(r, ['--audit', 'test-coverage', '--generation', 'audit-only', '--passes-used', '1']).stdout)[0]!;
|
||||
expect(a.text).toContain('You are running a ship-workflow test coverage audit. Run `git diff origin/main`');
|
||||
expect(a.text).toContain('Generation: audit-only; passes used: 1 of 2.');
|
||||
expect(a.text).toContain('+export const zeta19 = 19;');
|
||||
expect(build(r, ['--audit', 'plan-completion']).status).toBe(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('the packet prose and the generated SKILL.md prose are one text', () => {
|
||||
const read = (f: string) => fs.readFileSync(path.join(ROOT, f), 'utf8');
|
||||
const quoted = (s: string) => s.replaceAll('"', '\\"');
|
||||
test('/review renders the shared specialist, Red Team and adversarial prompts; /ship renders the packet brief', () => {
|
||||
expect(read('review/sections/review-army.md')).toContain(quoted(P.SPECIALIST_CONTRACT));
|
||||
expect(read('review/sections/review-army.md')).toContain(P.RED_TEAM_INTRO);
|
||||
expect(read('review/sections/review-army.md')).toContain(P.RED_TEAM_OUTPUT);
|
||||
expect(read('review/sections/adversarial.md')).toContain(P.ADVERSARIAL_NATIVE);
|
||||
expect(read('review/sections/adversarial.md')).toContain(P.OUTSIDE_ADVERSARIAL);
|
||||
expect(read('ship/sections/review-army.md')).toContain(P.packetBrief('<file>', '<out>'));
|
||||
expect(read('ship/sections/adversarial.md')).toContain(P.packetBrief('<file>', '<out>'));
|
||||
});
|
||||
test('the resolvers import the prompt bodies instead of holding a copy', () => {
|
||||
for (const f of ['scripts/resolvers/review-army.ts', 'scripts/resolvers/outside-voice-steps.ts', 'scripts/resolvers/fix-check.ts', 'scripts/resolvers/defensive-review.ts']) {
|
||||
const src = read(f);
|
||||
for (const clause of ['Required fields: severity, confidence', 'Think like an attacker and a chaos engineer. Your job', 'You are the fix-check reviewer', 'This is an authorized defensive-security review', 'Your job is to find what they\nMISSED']) expect(src).not.toContain(clause);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('gstack-review-packet collect', () => {
|
||||
type Entry = { role: string; name: string };
|
||||
function dir(entries: Entry[], outs: Record<string, string | null>) {
|
||||
const d = tmp('review-packet-collect-');
|
||||
const packets = entries.map(e => ({ ...e, reviewer: e.name, effort: 'full', file: path.join(d, `${e.name}.packet.md`), out: path.join(d, `${e.name}.out`), bytes: 1, checklists: [], fixtures: 'full', shard: null }));
|
||||
fs.writeFileSync(path.join(d, 'manifest.json'), JSON.stringify({ version: 1, head: 'h', diff_base: 'b', fingerprint: 'none', packets }));
|
||||
for (const [n, text] of Object.entries(outs)) if (text !== null) fs.writeFileSync(path.join(d, `${n}.out`), text);
|
||||
return d;
|
||||
}
|
||||
const collect = (d: string) => spawnSync(BIN, ['collect', '--dir', d], { encoding: 'utf8', timeout: 60_000 });
|
||||
const finding = (o: Record<string, unknown>) => JSON.stringify({ severity: 'INFORMATIONAL', confidence: 7, path: 'src/a.ts', line: 3, category: 'quality', summary: 's', specialist: 'testing', ...o });
|
||||
const specialists = [{ role: 'specialist', name: 'testing' }, { role: 'specialist', name: 'security' }];
|
||||
|
||||
test('clean and findings: dedupe across sources keeps every label, invalid lines are counted, an advisory CRITICAL stays CRITICAL', () => {
|
||||
const d = dir(specialists, {
|
||||
testing: [finding({ severity: 'CRITICAL', fingerprint: 'fp-1', summary: 'shared defect', specialist: 'testing' }), 'not json', finding({ severity: 'CRITICAL', advisory: true, fingerprint: 'fp-2', summary: 'advisory critical' })].join('\n'),
|
||||
security: finding({ severity: 'CRITICAL', fingerprint: 'fp-1', confidence: 8, summary: 'shared defect', specialist: 'security' }),
|
||||
});
|
||||
const r = collect(d);
|
||||
expect(r.status).toBe(0);
|
||||
expect(r.stdout).toContain('REVIEWER: testing status=findings crit=2 info=0 invalid_lines=1');
|
||||
expect(r.stdout).toContain('REVIEWER: security status=findings crit=1 info=0');
|
||||
const merged = fs.readFileSync(path.join(d, 'merged.jsonl'), 'utf8').trim().split('\n').map(l => JSON.parse(l));
|
||||
const shared = merged.find(m => m.fingerprint === 'fp-1');
|
||||
expect(shared.sources).toEqual(['testing', 'security']);
|
||||
expect(shared.confidence).toBe(9);
|
||||
const adv = merged.find(m => m.fingerprint === 'fp-2');
|
||||
expect(adv.severity).toBe('CRITICAL');
|
||||
expect(adv.advisory).toBeUndefined();
|
||||
expect(r.stdout).toMatch(/^COLLECT: reviewers=2 clean=0 findings=2 missing=0 invalid=0 crit=2 info=0 invalid_lines=1 /m);
|
||||
});
|
||||
|
||||
test('NO FINDINGS is clean; a missing or unusable output is incomplete coverage, exit 3', () => {
|
||||
expect(collect(dir(specialists, { testing: 'NO FINDINGS\n', security: 'NO FINDINGS' })).status).toBe(0);
|
||||
const missing = collect(dir(specialists, { testing: 'NO FINDINGS', security: null }));
|
||||
expect(missing.status).toBe(3);
|
||||
expect(missing.stdout).toContain('REVIEWER: security status=missing');
|
||||
expect(missing.stdout).toMatch(/security=missing.*\(REVIEW_COVERAGE_INCOMPLETE\)$/m);
|
||||
const prose = collect(dir(specialists, { testing: 'NO FINDINGS', security: 'Looks fine to me overall.' }));
|
||||
expect(prose.status).toBe(3);
|
||||
expect(prose.stdout).toContain('REVIEWER: security status=invalid');
|
||||
});
|
||||
|
||||
test('INFORMATIONAL findings are counts in the record and lines in informational.md', () => {
|
||||
const d = dir(specialists, { testing: finding({ summary: 'INFO_ONLY_MARKER', fix: 'do it' }), security: 'NO FINDINGS' });
|
||||
const r = collect(d);
|
||||
expect(r.stdout).not.toContain('INFO_ONLY_MARKER');
|
||||
expect(r.stdout).toMatch(/^INFORMATIONAL: 1 \(advisory 0\)/m);
|
||||
expect(fs.readFileSync(path.join(d, 'informational.md'), 'utf8')).toContain('INFO_ONLY_MARKER Fix: do it');
|
||||
});
|
||||
|
||||
test('the record stays under 60 lines however many findings return, each CRITICAL line at most 300 chars', () => {
|
||||
const many = Array.from({ length: 120 }, (_, i) => finding({ severity: 'CRITICAL', fingerprint: `fp-${i}`, summary: 'x'.repeat(500) })).join('\n');
|
||||
const entries = Array.from({ length: 30 }, (_, i) => ({ role: 'specialist', name: `s${i}` }));
|
||||
const outs: Record<string, string> = Object.fromEntries(entries.map(e => [e.name, 'NO FINDINGS']));
|
||||
outs.s0 = many;
|
||||
const r = collect(dir(entries, outs));
|
||||
const out = r.stdout.trimEnd().split('\n');
|
||||
expect(out.length).toBeLessThanOrEqual(60);
|
||||
expect(r.stdout).toMatch(/^CRITICAL_MORE: \d+ more/m);
|
||||
for (const l of out.filter(x => x.startsWith('CRITICAL:'))) expect(l.length).toBeLessThanOrEqual(300);
|
||||
});
|
||||
|
||||
test('the outside voice keeps its severity contract; adversarial JSONL keeps its Recommendation line', () => {
|
||||
const d = dir([{ role: 'outside-voice', name: 'outside-voice' }, { role: 'adversarial-native', name: 'adversarial' }], {
|
||||
'outside-voice': '[High] src/a.ts:4 — retries forever on 429\n[Low] src/b.ts — naming\nRecommendation: Fix the retry because it loops on 429',
|
||||
adversarial: JSON.stringify({ severity: 'INFORMATIONAL', path: 'src/a.ts', summary: 'edge', classification: 'INVESTIGATE' }) + '\nRecommendation: Ship as-is because the race needs two writers',
|
||||
});
|
||||
const r = collect(d);
|
||||
expect(r.status).toBe(0);
|
||||
expect(r.stdout).toContain('REVIEWER: outside-voice status=findings crit=1 info=1');
|
||||
expect(r.stdout).toContain('REVIEWER: adversarial status=findings crit=0 info=1');
|
||||
expect(r.stdout).toContain('RECOMMENDATION: adversarial: Ship as-is because the race needs two writers');
|
||||
});
|
||||
});
|
||||
@@ -236,7 +236,8 @@ test('Step 9.4 applies the cap before any edit, names its scratch files under .g
|
||||
for (const host of ALL_HOST_CONFIGS) {
|
||||
const army = generateReviewArmy({ host: host.name, skillName: 'ship', tmplPath: '', paths: HOST_PATHS[host.name] });
|
||||
if (!army) continue;
|
||||
expect(army.match(/DIFF_BASE=<diff-base>/g)?.length, `${host.name} ship review army range`).toBe(2);
|
||||
// Packets carry the literal sha: Step 9.1's build takes it as --range, and the Red Team's build reuses those flags.
|
||||
expectTokens(army, ['--range <sha>', 'the Step 9.1 build\'s flags'], `${host.name} ship review army range`);
|
||||
expectAbsent(army, ['${RANGE_BASE'], `${host.name} ship review army fallback`);
|
||||
expectTokens(army, ['--review-fanout auto|serial|parallel', /Fan-out: N specialists in\s+M batches of K/], `${host.name} ship review army fan-out`);
|
||||
const review = generateReviewArmy({ host: host.name, skillName: 'review', tmplPath: '', paths: HOST_PATHS[host.name] });
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"bytes": -3324,
|
||||
"why": "GSTA-167 reviewer packets: Step 9.1 dispatches each reviewer by one packet file (gstack-review-packet build/collect) in place of the inlined specialist prompt; Red Team, fix-check, Step 11 and the Step 7/8 audits read packets too"
|
||||
}
|
||||
Reference in new issue
Block a user