Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
342ab5c
fix(review): repair seven pipeline defects found by live runs
wenshao Aug 14, 2026
7f73fe8
fix(review): tell a continuation that ended before its test phase apa…
wenshao Aug 14, 2026
cbc1824
fix(review): close the nine findings the pipeline raised on this branch
wenshao Aug 14, 2026
e0524b0
fix(review): answer the second review round's blockers
wenshao Aug 14, 2026
f39f3bf
fix(review): answer the third round, whose blockers were all mine
wenshao Aug 15, 2026
04a52a5
fix(review): answer the fourth round; the anchor list has three writers
wenshao Aug 15, 2026
2118866
fix(review): give the report a run identity; keep foreign ids out of …
wenshao Aug 15, 2026
77a8396
Merge remote-tracking branch 'origin/main' into fix/review-live-run-d…
wenshao Aug 15, 2026
a3c70ae
fix(review): refuse element-level corruption instead of crashing on it
wenshao Aug 15, 2026
661d1ba
fix(review): answer the seventh round — instance identity, relay inde…
wenshao Aug 15, 2026
d024939
fix(review): answer the eighth round — exact machine text, anchored r…
wenshao Aug 15, 2026
8c527fa
fix(review): answer the ninth round — structural caveats, bounded for…
wenshao Aug 15, 2026
694f30a
fix(review): answer the tenth round — the cache reads the marker, and…
wenshao Aug 16, 2026
5560e8f
Merge remote-tracking branch 'origin/main' into fix/review-live-run-d…
wenshao Aug 16, 2026
8c27f23
fix(review): answer the eleventh round — a proven identity, a validat…
wenshao Aug 16, 2026
f0efe67
fix(review): answer the twelfth round — the union that ends displacem…
wenshao Aug 16, 2026
6f5378f
Merge remote-tracking branch 'origin/main' into fix/review-live-run-d…
wenshao Aug 16, 2026
1442181
Merge remote-tracking branch 'origin/main' into fix/review-live-run-d…
wenshao Aug 16, 2026
e3e939d
Merge remote-tracking branch 'origin/main' into fix/review-live-run-d…
wenshao Aug 16, 2026
e792d44
fix(review): answer the thirteenth round — exec evidence, a command g…
wenshao Aug 16, 2026
7f05080
fix(review): answer the fourteenth round — an anonymous recovery cann…
wenshao Aug 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
35 changes: 34 additions & 1 deletion packages/cli/src/commands/review/agent-prompt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// is in the prompt, the read call is in the prompt, and the agent is not handed a
// sentence to recite when it finds nothing.

import { SHELL_TOOL_MAX_TIMEOUT_MS } from './lib/build-budget.js';
import {
describe,
it,
Expand Down Expand Up @@ -2638,7 +2639,39 @@ describe('buildRoleBrief — every agent, not just the territory ones', () => {
// 120s shell timeout would kill it — the very failure this command prevents, one
// level up. So the block tells the agent to pass the tool's max, 600000ms.
const p = buildRoleBrief(PR_PLAN, '7', { planPath: '/abs/tmp/plan.json' });
expect(p).toContain('timeout: 600000');
expect(p).toContain(`timeout: ${SHELL_TOOL_MAX_TIMEOUT_MS}`);
});

it('tells Agent 7 how to CONTINUE a run one call could not finish', () => {
// The ceiling is per call. On this repo one call cannot reach every suite
// (install + builds + `packages/core` at 106s leaves 285s, and
// `packages/cli` alone needs 401s), so a brief that stops at the first
// call teaches the agent to report a truncated dimension as a finished
// one — which is what three live reviews did.
const p = buildRoleBrief(PR_PLAN, '7', { planPath: '/abs/tmp/plan.json' });
expect(p).toContain('testScope.notRun');
expect(p).toContain('"clamped": true');

// Asserted on the CONTINUATION BLOCK ALONE, which is the whole point. The
// first cut of this test searched the entire prompt: `--resume` matched the
// prose, the window ran to the end of the prompt, and every assertion was
// satisfied by text the sibling brief bullet and the FIRST invocation block
// already supply — so deleting the continuation block outright left it
// green. The block is the last fenced command in the role-7 prompt.
const fences = [...p.matchAll(/```bash\n([\s\S]*?)```/g)].map((m) => m[1]);
const resumeBlock = fences.filter((f) => f.includes('--resume'));
expect(resumeBlock).toHaveLength(1);
// The continuation runs the same command, so the block must carry the same
// plan and out paths — an agent that has to re-derive them gets them wrong.
// Paths are built the way the rest of this block builds them — `join` and
// `resolve` — not spelled as POSIX literals: on Windows the prompt carries
// `C:\\abs\\tmp\\plan.json`, and a hardcoded expectation fails there for a
// reason that has nothing to do with the continuation block.
expect(resumeBlock[0]).toContain('review build-test');
expect(resumeBlock[0]).toContain(`--plan ${resolve('/abs/tmp/plan.json')}`);
expect(resumeBlock[0]).toContain(
`--out ${join(resolve('/abs/tmp'), 'qwen-review-pr-6766-build-test.json')}`,
);
});

it('welds the PR into Agent 0 — an unqualified number judges the wrong issue', () => {
Expand Down
34 changes: 32 additions & 2 deletions packages/cli/src/commands/review/agent-prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ import {
writeStderrLine,
writeStderrLineSafe,
} from '../../utils/stdioHelpers.js';
import {
MAX_RESUME_CALLS,
SHELL_TOOL_MAX_TIMEOUT_MS,
} from './lib/build-budget.js';
import { launchToolBudget, reverseAuditRoundCap } from './lib/budget.js';
import {
clearBudgetStop,
Expand Down Expand Up @@ -1403,7 +1407,7 @@ export function buildRoleBrief(
'**Build and test what the diff changed.** Give this one call a long tool ' +
'timeout — it installs, builds and tests in a single process, which the ' +
'default 120-second shell timeout would kill mid-run (the very failure this ' +
'command exists to prevent, one level up). Invoke it with `timeout: 600000`:',
`command exists to prevent, one level up). Invoke it with \`timeout: ${SHELL_TOOL_MAX_TIMEOUT_MS}\`:`,
'',
'```bash',
// Prefixed like every other executable review command: this block is run
Expand All @@ -1418,6 +1422,32 @@ export function buildRoleBrief(
` --worktree ${resolve(buildTree)} \\`,
` --out ${resolve(dirname(opts.planPath), outName)}`,
'```',
'',
'**If the report says work is left, run it again with `--resume`.** The ' +
`${SHELL_TOOL_MAX_TIMEOUT_MS / 1000}-second ceiling is per CALL, not per run: this repo needs more than ` +
'one call to finish its suites (install, the builds, then `packages/core` ' +
'at 106s and `packages/cli` at 401s, before the rest). Work is left when ' +
'`testScope.notRun` is non-empty, or when any `test[]` entry has ' +
'`"clamped": true` — a suite the budget started too late and killed, which ' +
'says nothing about the suite. A third shape carries no field at all: a ' +
'single-package repo whose budget ran out before its one suite has an ' +
'empty `test[]` and no `testScope`, and only its `note` says so — read ' +
'the note before calling the dimension finished. That shape cannot be ' +
'continued (a continuation has no recorded scope to read, and answers ' +
'"ended before its test phase" without running anything): report the ' +
'dimension UNFINISHED and do not spend a continuation on it. A resumed ' +
'call skips install and build and ' +
'runs only what is left, merging into the SAME report file. Same ' +
`\`timeout: ${SHELL_TOOL_MAX_TIMEOUT_MS}\`, and at most ` +
`${MAX_RESUME_CALLS} continuations — then report what the run has:`,
'',
'```bash',
`"\${QWEN_CODE_CLI:-qwen}" review build-test \\`,
` --plan ${resolve(opts.planPath)} \\`,
` --worktree ${resolve(buildTree)} \\`,
` --out ${resolve(dirname(opts.planPath), outName)} \\`,
' --resume',
'```',
);
}
if (typeof base === 'string' && base && pr !== undefined && opts.planPath) {
Expand All @@ -1432,7 +1462,7 @@ export function buildRoleBrief(
'',
'**Then run the test-efficacy probe.** A green suite says the tests pass. It does ' +
'not say they would have failed had the change been wrong, and those are ' +
'different claims. Give this call `timeout: 600000` too — besides the revert ' +
`different claims. Give this call \`timeout: ${SHELL_TOOL_MAX_TIMEOUT_MS}\` too — besides the revert ` +
'probe it runs up to 8 single-statement deletion mutants and up to 6 per-hunk ' +
'reverse-apply probes, each a suite run, and it budgets itself to finish inside ' +
'that ceiling:',
Expand Down
Loading
Loading