Files
gstack/test/defensive-review-framing.test.ts
T
Garry Tanandcapy-ai[bot] ae3d58c932 v1.91.331.0 revert(review): restore pre-#3621 reviewer briefs (no-loss round 3) (#3638)
* revert(review): restore pre-#3621 reviewer briefs (GSTA-167 no-loss round 3)

Reverts the reviewer-packet parts of 5358a3b3 (#3621, v1.91.326.0) and
ce3a093a (#3636, v1.91.330.0). No-loss round 3
(handoffs/GSTA-167/noloss3-results.md) found the packet reviewers caught 10 of
the 19 blockers the dcd62c3 reviewers find.

Every non-stamp file is back to dcd62c389d73's bytes; the later main commits
959c8a6, 9184ffd and de53aef touch none of these files and are kept. Stamp
files (VERSION, package.json, agents-digest) stay at main; CHANGELOG gains an
[Unreleased] entry.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* test: keep the reverted reviewer-packet files gone and unreferenced (GSTA-167)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* docs(changelog): name the reviewer-packet guard test

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* fix: pre-landing review fixes

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* chore: stamp 1.91.331.0

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>
2026-10-30 10:40:19 +00:00

58 lines
3.1 KiB
TypeScript

import { describe, expect, test } from 'bun:test';
import * as fs from 'fs';
import * as path from 'path';
import { DEFENSIVE_REVIEW_FRAMING, FIXTURE_SUMMARY_MODE } from '../scripts/resolvers/defensive-review';
import { generateReviewArmy } from '../scripts/resolvers/review-army';
import { HOST_PATHS } from '../scripts/resolvers/types';
const ROOT = path.join(import.meta.dir, '..');
const FRAMING_SENTENCE = "This is an authorized defensive-security review of the maintainer's own repository";
function between(text: string, start: string, end: string): string {
const from = text.indexOf(start);
expect(from).toBeGreaterThanOrEqual(0);
const to = text.indexOf(end, from + start.length);
expect(to).toBeGreaterThan(from);
return text.slice(from, to);
}
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']) {
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');
test(`${skill}: adversarial subagent keeps the framing and fixture summary mode`, () => {
const prompt = between(adversarial, 'Subagent prompt:', 'Think like an attacker');
expect(prompt).toContain(DEFENSIVE_REVIEW_FRAMING);
expect(prompt).toContain(FIXTURE_SUMMARY_MODE);
});
test(`${skill}: Red Team prompt starts from the framing and fixture summary mode`, () => {
const redTeam = between(army, '### Red Team dispatch', "don't cover.\"");
expect(redTeam).toContain('Prompt, after the defensive framing and fixture handling from item 4 of the specialist dispatch:');
expect(redTeam).toContain('read them as that fixture handling says');
expect(redTeam).not.toMatch(/git diff "\$DIFF_BASE"`, and look for gaps/);
});
test(`${skill}: only the security specialist gets the framing; testing reads fixtures in full`, () => {
const dispatch = between(army, '### Dispatch specialists in parallel', '**Subagent configuration:**');
const securityOnly = between(dispatch, '4. **Defensive framing (Security specialist and the Red Team below only).**', 'Instructions:');
expect(securityOnly).toContain(DEFENSIVE_REVIEW_FRAMING);
expect(securityOnly).toContain(FIXTURE_SUMMARY_MODE);
expect(securityOnly).toContain('including Testing, reads the full diff with fixtures');
const sharedInstructions = dispatch.slice(dispatch.indexOf('Instructions:'));
expect(sharedInstructions).not.toContain(FRAMING_SENTENCE);
expect(sharedInstructions).not.toContain('SUMMARY mode');
expect(dispatch.split(FRAMING_SENTENCE)).toHaveLength(2);
});
}
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('');
});
});