Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5a8e517
fix(review): name a rewritten launch as itself, and leave nothing to …
wenshao Jul 16, 2026
2b0834b
fix(review): call the CLI that is running, not whatever `qwen` PATH f…
wenshao Jul 16, 2026
436e634
fix(review): point the dev daemon's CLI at the source it is running, …
wenshao Jul 16, 2026
fdcb0fe
fix(review): say what a missing brief proves, once, to the reader who…
wenshao Jul 16, 2026
9fa667f
fix(review): name the directory the missing briefs were missing from
wenshao Jul 16, 2026
c08274c
feat(review): build the whole roster in one call, because compliance …
wenshao Jul 16, 2026
e1f708b
fix(review): close the review's five consistency gaps in the CLI-pinn…
wenshao Jul 16, 2026
b50894f
fix(review): finish the two-register split, and pin the last unpinned…
wenshao Jul 17, 2026
73f23b0
fix(review): isolate the env var this PR exports, and give every gap …
wenshao Jul 17, 2026
673fc12
fix(review): retire the last two overclaims the round-3 review found
wenshao Jul 17, 2026
a5ad086
test(review): make the every-gap-has-a-FIX claim true, and pin the pa…
wenshao Jul 17, 2026
9bc9aab
fix(review): close the round-5 findings — entry contracts, gap reach,…
wenshao Jul 17, 2026
c7ada33
fix(review): filter by overwriting, not omitting — the spread carries…
wenshao Jul 17, 2026
bde0857
fix(review): reunite roleLabel with the doc comment the selectorOf in…
wenshao Jul 17, 2026
b5b87ae
fix(review): close the round-9 findings — convergence, injectivity, a…
wenshao Jul 17, 2026
e13b9bb
fix(review): close the three paths the round-11 review found still open
wenshao Jul 17, 2026
7c74ad2
fix(review): bind the receipt to what was delivered, and match what a…
wenshao Jul 17, 2026
1cfa71c
docs(review): let the docs and comments claim only what the new recor…
wenshao Jul 17, 2026
0464780
docs(review): finish retiring the findings-free record from every sen…
wenshao Jul 17, 2026
6d24470
docs(review): the actually-last sentence describing the findings-free…
wenshao Jul 17, 2026
b48be34
test(review): pin the idle and missing-chunk FIX lines to the remedia…
wenshao Jul 17, 2026
96a430d
fix(review): quote the plan path in every printed repair, and test th…
wenshao Jul 17, 2026
1cec1b4
fix(review): shell-quote the plan path properly — an apostrophe is no…
wenshao Jul 17, 2026
90cc220
fix(review): quote the --file selector, un-dead the spawn guard, test…
wenshao Jul 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 71 additions & 12 deletions packages/cli/src/commands/review/agent-prompt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,14 @@ describe('agent-prompt (command boundary)', () => {
try {
const plan = join(dir, 'plan.json');
writeFileSync(plan, JSON.stringify(PLAN));
const findings = join(dir, 'f.md');
writeFileSync(findings, '- **[Critical]** x.ts:1 — y');
expect(() =>
(agentPromptCommand.handler as (a: unknown) => void)({
plan,
role: 'reverse-audit',
chunk: 14,
findings,
}),
).not.toThrow();
const recorded = readRecordedPrompts(plan);
Expand All @@ -392,10 +395,13 @@ describe('agent-prompt (command boundary)', () => {
try {
const plan = join(dir, 'plan.json');
writeFileSync(plan, JSON.stringify(PLAN));
const findings = join(dir, 'f.md');
writeFileSync(findings, '- **[Critical]** x.ts:1 — y');
expect(() =>
(agentPromptCommand.handler as (a: unknown) => void)({
plan,
role: 'verify',
findings,
}),
).not.toThrow();
const recorded = readRecordedPrompts(plan);
Expand Down Expand Up @@ -550,28 +556,78 @@ describe('--findings — fold the list in, print one block, record the block alo
expect(printed).not.toContain('Nothing is confirmed yet');
});

it('the record is byte-identical whether or not --findings was passed', () => {
// Proves the shared per-shard/round key is unaffected: two verify shards with
// different findings record the SAME launch block, so both match it. Same plan
// both times (the record embeds the plan-derived brief path), differing only in
// whether findings were folded into what was PRINTED.
const dir = tmp('ap-nof-');
it('two shards with different findings record the same launch block', () => {
// The property the shared per-shard/round key rests on: the findings are printed,
// never recorded, so shard 2's record does not overwrite shard 1's with a
// different block — both shards' launches match the one record by the add-only
// delivery rule. Same plan both times (the record embeds the plan-derived brief
// path); only the folded-in list differs.
const dir = tmp('ap-shards-');
const plan = join(dir, 'plan.json');
writeFileSync(plan, JSON.stringify(PLAN));
const findings = join(dir, 'f.md');
writeFileSync(findings, '- **[Critical]** foo.ts:10 — x');
const shard1 = join(dir, 'f1.md');
const shard2 = join(dir, 'f2.md');
writeFileSync(shard1, '- **[Critical]** foo.ts:10 — first shard');
writeFileSync(shard2, '- **[Suggestion]** bar.ts:99 — second shard');

(agentPromptCommand.handler as (a: unknown) => void)({
plan,
role: 'verify',
findings,
findings: shard1,
});
const withFindings = readRecordedPrompts(plan).get('verify')!;
const recAfter1 = readRecordedPrompts(plan).get('verify')!;
const printed1 = (writeStdoutLine as unknown as Mock).mock
.calls[0][0] as string;

(agentPromptCommand.handler as (a: unknown) => void)({
plan,
role: 'verify',
findings: shard2,
});
const withoutFindings = readRecordedPrompts(plan).get('verify')!;
expect(withFindings).toBe(withoutFindings);
const recAfter2 = readRecordedPrompts(plan).get('verify')!;
const printed2 = (writeStdoutLine as unknown as Mock).mock
.calls[1][0] as string;

expect(recAfter1).toBe(recAfter2); // the record never carried either list
Comment thread
wenshao marked this conversation as resolved.
Resolved
expect(recAfter2).not.toContain('first shard');
expect(recAfter2).not.toContain('second shard');
// Each shard got its OWN list, and both still match the one record.
expect(printed1).toContain('first shard');
expect(printed2).toContain('second shard');
expect(wasDeliveredVerbatim(printed1, recAfter2)).toBe(true);
expect(wasDeliveredVerbatim(printed2, recAfter2)).toBe(true);
});

it('refuses a findings-taking role launched without --findings', () => {
// There is no bare-block path left to hand-assemble. Dogfooded on a real 3A
// review, the orchestrator skipped --findings, hand-wrote the auditor's launch,
// and the delivery check capped the verdict — which it then talked past. A role
// that takes findings must be given them, so the command prints one block and
// there is nothing to assemble.
for (const role of ['verify', 'reverse-audit']) {
expect(() =>
(agentPromptCommand.handler as (a: unknown) => void)({
plan: '/nonexistent/plan.json',
role,
}),
).toThrow(new RegExp(`--role ${role} needs --findings`));
}
// The guard runs before the plan is read, so the message is about the call.
expect(() =>
(agentPromptCommand.handler as (a: unknown) => void)({
plan: '/nonexistent/plan.json',
role: 'reverse-audit',
}),
).toThrow(
/an early reverse-audit round with nothing confirmed yet passes an empty file/,
);
// A role that does NOT take findings is unaffected.
expect(() =>
(agentPromptCommand.handler as (a: unknown) => void)({
plan: '/nonexistent/plan.json',
role: '2',
}),
).toThrow(/cannot read the plan/);
});

it('cannot read the findings file — says so, does not review without them', () => {
Expand Down Expand Up @@ -732,11 +788,14 @@ describe('buildWholeDiffBlock — the agents that walk the whole diff', () => {
try {
const plan = join(dir, 'plan.json');
writeFileSync(plan, JSON.stringify(PLAN));
const findings = join(dir, 'f.md');
writeFileSync(findings, '- x');
expect(() =>
(agentPromptCommand.handler as (a: unknown) => void)({
plan,
role: 'reverse-audit',
chunk: 999,
findings,
}),
).toThrow(/the plan has no chunk 999/);
} finally {
Expand Down
16 changes: 16 additions & 0 deletions packages/cli/src/commands/review/agent-prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1076,6 +1076,22 @@ function runAgentPrompt(args: AgentPromptArgs): void {
// `--findings` folds a findings list into the printed prompt, for the two roles
// that take one: the verifier rules on findings, the reverse auditor avoids
// re-reporting them. Declared on the brief (`acceptsFindings`), like `acceptsChunk`.
// A role that TAKES findings must be GIVEN them. Without this the command still
// printed a bare launch block, and the caller was left to prepend the list by
// hand — the one assembly step left in the skill, and measurably where the
// prompt got rewritten: dogfooded on a real 3A review, the orchestrator skipped
// `--findings`, hand-wrote the auditor's launch, and the delivery check capped
// the verdict (which it then talked its way past). There is no bare-block path
// to hand-assemble any more. An early reverse-audit round with nothing confirmed
// yet passes an empty file — the command says so in the prompt.
if (!hasFindings && BRIEFS[role]?.acceptsFindings) {
Comment thread
wenshao marked this conversation as resolved.
Resolved
bad(
`--role ${role} needs --findings <file>: it is launched with a findings ` +
Comment thread
wenshao marked this conversation as resolved.
Resolved
`list folded in, and this command builds that block so there is nothing ` +
`for you to assemble. Write the list to a file and pass it — an early ` +
`reverse-audit round with nothing confirmed yet passes an empty file.`,
);
}
if (hasFindings && !BRIEFS[role]?.acceptsFindings) {
const findingRoles = (Object.keys(BRIEFS) as RoleId[]).filter(
(r) => BRIEFS[r].acceptsFindings,
Expand Down
78 changes: 68 additions & 10 deletions packages/cli/src/commands/review/check-coverage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -952,14 +952,16 @@ describe('an agent that paged its chunk still read it', () => {
describe('verificationGaps — Step 4 and Step 5 ran, and read their briefs', () => {
// A Step 4/5 agent as a real run leaves it: the CLI's record of the prompt it
// built (`agent-prompt --role <role>`), the brief that prompt points at, and the
// harness's transcript of an agent launched with it. `launch: false` models a
// prompt built but never handed to an agent; `opensBrief: false` an agent that
// ran but never opened the brief. To model a step skipped wholesale, do not set
// the key up at all — there is then no record and no transcript.
// harness's transcript of an agent launched with it. The opts model each way
// delivery fails: `launch: false` — built, never handed to an agent;
// `opensBrief: false` — launched with the built prompt, never opened the brief;
// `rewritten: true` — an agent ran and opened the brief, but the orchestrator
// wrote the launch itself (the real 3A run this precision exists for). To model a
// step skipped wholesale, do not set the key up at all.
function step45(
planPath: string,
key: string,
opts: { launch?: boolean; opensBrief?: boolean } = {},
opts: { launch?: boolean; opensBrief?: boolean; rewritten?: boolean } = {},
): void {
const d = promptRecordDir(planPath);
mkdirSync(d, { recursive: true });
Expand All @@ -971,7 +973,20 @@ describe('verificationGaps — Step 4 and Step 5 ran, and read their briefs', ()
`read_file(file_path="${DIFF}")`;
writeFileSync(join(d, `${encodeURIComponent(key)}.txt`), prompt);
if (opts.launch === false) return;
transcript(`v-${key.replace(/[^a-z0-9]/gi, '_')}`, prompt, {
const id = `v-${key.replace(/[^a-z0-9]/gi, '_')}`;
if (opts.rewritten) {
// Kept the brief pointer, threw the rest away and wrote its own preamble —
// verbatim word-for-word from a real run's transcript.
transcript(
id,
`You are performing a reverse audit of PR #1, which hardens things. ` +
`**Your brief is a file. Read it first.**\n` +
`read_file(file_path="${brief}")`,
{ calls: 2, opens: [brief] },
);
return;
}
transcript(id, prompt, {
calls: 2,
opens: opts.opensBrief === false ? [] : [brief],
});
Expand Down Expand Up @@ -999,20 +1014,59 @@ describe('verificationGaps — Step 4 and Step 5 ran, and read their briefs', ()
expect(r.gaps.join(' ')).toMatch(/reverse audit — no auditor ran/);
});

it('names a rewritten launch as itself, not as an agent that never ran', () => {
// The real 3A run this precision exists for: two auditors ran, made 16 and 23
// tool calls, and opened their brief — the orchestrator had simply written the
// launch itself. The old message said "no agent was launched with it that opened
// its brief", which was false as written; the orchestrator read it, called it a
// "transcript visibility issue", and reported an Approve over the capped verdict.
const p = plan();
step45(p, 'reverse-audit', { rewritten: true });
const r = verificationGaps(p, { postsFindings: false }, ENV);
expect(r.ok).toBe(false);
const gap = r.gaps.join(' ');
// It says what happened: the agent ran and read the brief …
expect(gap).toMatch(/an auditor ran and opened its brief/);
// … and what was actually wrong, with the fix.
expect(gap).toMatch(
/no agent was launched with the \*\*prompt the CLI built|prompt the CLI built/,
);
expect(gap).toMatch(/--findings/);
// And it must NOT claim the agent never ran or never read its brief.
expect(gap).not.toMatch(/no auditor ran/);
expect(gap).not.toMatch(/never opened its brief/);
});

it('names a rewritten verifier launch as itself too', () => {
const p = plan();
step45(p, 'reverse-audit');
step45(p, 'verify', { rewritten: true });
const gap = verificationGaps(p, { postsFindings: true }, ENV).gaps.join(
' ',
);
expect(gap).toMatch(/a verifier ran and opened its brief/);
expect(gap).toMatch(/prompt the CLI built/);
expect(gap).not.toMatch(/no verifier ran/);
});

it('flags a reverse audit built but whose agent never opened its brief', () => {
const p = plan();
step45(p, 'reverse-audit', { opensBrief: false });
const r = verificationGaps(p, { postsFindings: false }, ENV);
expect(r.ok).toBe(false);
expect(r.gaps.join(' ')).toMatch(/reverse audit — its prompt was built/);
expect(r.gaps.join(' ')).toMatch(
/reverse audit — it was launched with the built prompt but never opened its brief/,
);
});

it('flags a reverse audit whose prompt was built but never launched', () => {
const p = plan();
step45(p, 'reverse-audit', { launch: false });
const r = verificationGaps(p, { postsFindings: false }, ENV);
expect(r.ok).toBe(false);
expect(r.gaps.join(' ')).toMatch(/reverse audit — its prompt was built/);
expect(r.gaps.join(' ')).toMatch(
/reverse audit — its prompt was built, but no agent was launched with it/,
);
});

it('counts a Step 3B per-chunk reverse auditor (reverse-audit--chunk-N)', () => {
Expand Down Expand Up @@ -1044,7 +1098,9 @@ describe('verificationGaps — Step 4 and Step 5 ran, and read their briefs', ()
step45(p, 'reverse-audit');
step45(p, 'verify', { opensBrief: false });
const r = verificationGaps(p, { postsFindings: true }, ENV);
expect(r.gaps.join(' ')).toMatch(/verification — its prompt was built/);
expect(r.gaps.join(' ')).toMatch(
/verification — it was launched with the built prompt but never opened its brief/,
);
});

it('flags a verifier whose prompt was built but never launched', () => {
Expand All @@ -1055,6 +1111,8 @@ describe('verificationGaps — Step 4 and Step 5 ran, and read their briefs', ()
step45(p, 'reverse-audit');
step45(p, 'verify', { launch: false });
const r = verificationGaps(p, { postsFindings: true }, ENV);
expect(r.gaps.join(' ')).toMatch(/verification — its prompt was built/);
expect(r.gaps.join(' ')).toMatch(
/verification — its prompt was built, but no agent was launched with it/,
);
});
});
Loading
Loading