mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-23 00:21:14 +01:00
* Add failing tests: outside reviews read clean only from a last-line verdict
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* Count an outside review as clean only from its last VERDICT line
Every outside-review prompt now asks the reviewer to end with exactly
VERDICT: CLEAN or VERDICT: FINDINGS, and the parser reads a pass only from
that line. Prose no-findings sentences are no longer evidence for clean.
Codex's structured review and /codex review run through codex exec, since
codex review --base takes no prompt and could never give the line.
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* Repin the outside reviewer briefs and fix the tests the verdict line broke (GST-1821)
The outside brief, both adversarial sections and the review-army prompt-file line now carry the last-line VERDICT request; their pins move under the preregistered no-loss replay GST-1821. Test fakes that wrote a clean reply now end it with VERDICT: CLEAN, the review carve marker follows the codex exec sentence, size pins drop where skills shrank, and the plan-review prompt-file line is shortened so /plan-eng-review stays at its pin.
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* Give the plan-review invocation test's fake reviewer the verdict line it now needs
CI's free-suite shard 5 failed at 1de52b0 with 18 cases in test/model-role-invocation.test.ts: the fake Codex reply had no VERDICT line, so it read unverified (exit 4), and the review-mode template now has one codex exec dispatch block instead of two. The fake reply now ends with VERDICT: FINDINGS and the block count expects one.
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* Stop the changelog correction from claiming the verdict line closes every false-clean case
Review-Finding: p1/red-team#2 reader=red-team
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* Split the changelog correction's last sentence for readability
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* Close the review fail-opens the fix-check found (GST-1821)
A /codex review whose git diff fails now stops before Codex runs instead of sending an empty diff. The verdict is read from the raw last line, so inline code after VERDICT: CLEAN no longer reads clean, and VERDICT: CLEAN beside numbered items with no severity reads unverified. Codex structured review gets the base-branch diff appended to its prompt, the way the Claude path does, so the scope no longer depends on the prompt the host writes.
Fix round granted by the Captain (a-aec3882c9d48). Review-section pins move under replay GST-1821: the free 681-input replay and the 54 scored probe replies are unchanged through the fixed parser.
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* Say in the changelog which numbered-list replies now read unverified, and that /codex review stops without its diff
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* Say in the skills guide that /codex review now sends the diff through codex exec
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* Check that the structured outside review appends the base-branch diff to its prompt
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
---------
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
117 lines
7.3 KiB
TypeScript
117 lines
7.3 KiB
TypeScript
/**
|
||
* CEO-28 / DX-11 / ENG-10: a review that lists high-severity findings is never
|
||
* `VERDICT: clean`. The Oct 7 /autoplan run's Codex CEO and DX outputs labeled
|
||
* seven and eight findings "High"/"Medium" without [Pn] tags, and the installed
|
||
* classifier printed `VERDICT: clean` / `FINDINGS: none` for both. The fixtures
|
||
* in test/fixtures/outside-review-severity/ reproduce those shapes (the
|
||
* findings come from the run's review record; the raw outputs were not kept),
|
||
* plus the eng output's [P1] tags, a table, and prose negative controls.
|
||
*/
|
||
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 { classifyOutsideReview, type OutsideGate } from '../lib/outside-review-result';
|
||
import { HOST_PATHS } from '../scripts/resolvers/types';
|
||
import { outsideVoiceCommand } from '../scripts/resolvers/outside-voice';
|
||
|
||
const ROOT = path.resolve(import.meta.dir, '..');
|
||
const LIB = path.join(ROOT, 'lib', 'outside-review-result.ts');
|
||
const FIX = path.join(ROOT, 'test', 'fixtures', 'outside-review-severity');
|
||
const fixture = (name: string) => path.join(FIX, name);
|
||
const read = (name: string) => fs.readFileSync(fixture(name), 'utf8');
|
||
const REC = 'Recommendation: fix it because the change loses data.';
|
||
|
||
describe('severity words count as findings in label position', () => {
|
||
for (const [name, highest] of [
|
||
['ceo-codex-shape.txt', 'P1'],
|
||
['dx-codex-shape.txt', 'P1'],
|
||
['eng-codex-tagged.txt', 'P1'],
|
||
['table-shape.txt', 'P1'],
|
||
] as const) {
|
||
test(`${name}: the CLI prints VERDICT: findings, FINDINGS: ${highest}, exit 3`, () => {
|
||
const r = spawnSync(process.execPath, [LIB, '--verdict', 'review', fixture(name)], { encoding: 'utf8', timeout: 10000 });
|
||
expect([r.status, r.stdout]).toEqual([3, `VERDICT: findings\nFINDINGS: ${highest}\n`]);
|
||
});
|
||
}
|
||
|
||
test('every label form ENG-10 names is read, with critical/high blocking and medium/low advisory', () => {
|
||
const cases: Array<[string, string | null, string]> = [
|
||
['Severity: High\nThe cap is ignored.', 'P1', 'findings'],
|
||
['Priority: critical — data loss', 'P0', 'findings'],
|
||
['Severity: **medium**', 'P2', 'clean'],
|
||
['High: the retry loop never stops.', 'P1', 'findings'],
|
||
['1. **High** — the cap is ignored.', 'P1', 'findings'],
|
||
['- [High] the cap is ignored.', 'P1', 'findings'],
|
||
['### Critical - secrets in logs', 'P0', 'findings'],
|
||
['High — the cap is ignored.', 'P1', 'findings'],
|
||
['The cap is ignored (**High**).', 'P1', 'findings'],
|
||
['| 1 | high | cap ignored |', 'P1', 'findings'],
|
||
['Low: rename the helper.', 'P3', 'clean'],
|
||
['Medium: the docs lag.\nLow: a typo.', 'P2', 'clean'],
|
||
['1. The guard trusts the payload without a flush check — High.', 'P1', 'findings'],
|
||
['2. The docs lag the new flag – Medium.', 'P2', 'clean'],
|
||
['- The retry loop never stops (high)', 'P1', 'findings'],
|
||
];
|
||
for (const [text, highest, verdict] of cases) {
|
||
const r = classifyOutsideReview({ text: `${text}\n${REC}\nVERDICT: FINDINGS`, gate: 'review' });
|
||
expect({ text, highest: r.findings.highest as string | null, verdict: r.verdict as string }).toEqual({ text, highest, verdict });
|
||
}
|
||
});
|
||
|
||
test('negative controls: severity words inside prose never count', () => {
|
||
const r = classifyOutsideReview({ text: `${read('prose-negative.txt')}\nVERDICT: CLEAN`, gate: 'review' });
|
||
expect([r.verdict, r.findings.highest]).toEqual(['clean', null]);
|
||
for (const text of ['A high-level plan.', 'Highly consistent.', 'This is low-risk.', 'A medium-term follow-up.',
|
||
'There are no critical findings.', 'High availability: kept.', 'The high number of retries is fine.', 'Lower the limit.',
|
||
'Latency stays low.', 'The cost is high-ish - acceptable.', 'Keep the trade-off low.']) {
|
||
expect({ text, highest: classifyOutsideReview({ text: `${text}\nNo issues found.\n${REC}`, gate: 'review' }).findings.highest })
|
||
.toEqual({ text, highest: null });
|
||
}
|
||
});
|
||
|
||
test('a review with neither tags, severity labels nor the verdict line is unverified, never clean', () => {
|
||
const r = classifyOutsideReview({ text: read('prose-unlabeled.txt'), gate: 'review' });
|
||
expect([r.verdict, r.reason]).toEqual(['unverified', 'missing_verdict']);
|
||
const cli = spawnSync(process.execPath, [LIB, '--verdict', 'review', fixture('prose-unlabeled.txt')], { encoding: 'utf8', timeout: 10000 });
|
||
expect(cli.status).toBe(4);
|
||
expect(cli.stdout).toContain('VERDICT: unverified\n');
|
||
expect(classifyOutsideReview({ text: `No issues found.\n${REC}`, gate: 'review' }).verdict).toBe('unverified');
|
||
expect(classifyOutsideReview({ text: `No issues found.\n${REC}\nVERDICT: CLEAN`, gate: 'review' }).verdict).toBe('clean');
|
||
expect(classifyOutsideReview({ text: `I did not find any issues.\n${REC}`, gate: 'review' }).verdict).toBe('unverified');
|
||
expect(classifyOutsideReview({ text: `I did not find any issues.\n${REC}\nVERDICT: CLEAN`, gate: 'review' }).verdict).toBe('clean');
|
||
});
|
||
|
||
test('the structured gate reads severity labels too', () => {
|
||
expect(classifyOutsideReview({ text: 'High: race in cleanup.', gate: 'structured' }).verdict).toBe('findings');
|
||
expect(classifyOutsideReview({ text: 'Medium: stale comment.\nVERDICT: FINDINGS', gate: 'structured' }).verdict).toBe('clean');
|
||
});
|
||
|
||
test('a stored panel of real Codex outputs keeps its verdicts', () => {
|
||
const panel = path.join(ROOT, 'test', 'fixtures', 'codex-review');
|
||
const verdict = (name: string, gate: OutsideGate, tail = '') => {
|
||
const r = classifyOutsideReview({ text: fs.readFileSync(path.join(panel, name), 'utf8') + tail, gate });
|
||
return [r.verdict, r.findings.highest, r.reason ?? null];
|
||
};
|
||
expect(verdict('clean-review.stdout.txt', 'structured')).toEqual(['unverified', null, 'missing_verdict']);
|
||
expect(verdict('p2-review.stdout.txt', 'structured', '\nVERDICT: FINDINGS')).toEqual(['clean', 'P2', null]);
|
||
expect(verdict('clean-review.stdout.txt', 'review')).toEqual(['unavailable', null, 'missing_markers']);
|
||
expect(verdict('p2-review.stdout.txt', 'review')).toEqual(['unavailable', 'P2', 'missing_markers']);
|
||
});
|
||
});
|
||
|
||
describe('design proposals use the proposal gate', () => {
|
||
test('a completed proposal needs only its Recommendation line; severity rules do not apply', () => {
|
||
const proposal = 'Use a dense triage table with sticky filters.\nRecommendation: table because operators compare many rows.';
|
||
expect(classifyOutsideReview({ text: proposal, gate: 'proposal' }).verdict).toBe('clean');
|
||
expect(classifyOutsideReview({ text: 'A table.', gate: 'proposal' }).reason).toBe('missing_markers');
|
||
expect(classifyOutsideReview({ text: proposal, gate: 'review' }).verdict).toBe('unverified');
|
||
});
|
||
|
||
test('design-direction invocations render the proposal gate; reviews keep the review gate', () => {
|
||
const ctx = { skillName: 'design-consultation', tmplPath: 'design-consultation/SKILL.md.tmpl', host: 'claude' as const, paths: HOST_PATHS.claude };
|
||
expect(outsideVoiceCommand(ctx, { timeoutMs: 300000, purpose: 'design-direction' })).toMatch(/ proposal "\$_OUTSIDE_TMP\/text"/);
|
||
expect(outsideVoiceCommand({ ...ctx, skillName: 'plan-ceo-review' }, { timeoutMs: 300000 })).toMatch(/ review "\$_OUTSIDE_TMP\/text"/);
|
||
});
|
||
});
|