Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion docs/REVIEW.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ This API option is not inferred from config, environment, issue text, coder
output or model response. There is no new CLI flag or implicit image acquisition.
The existing `{ receipt }` reviewer option remains supported.
`runOnlyReview` also forwards the host backend executor used by offline tests.
For a retry of a run with independent-verification metadata, the caller must
For a retry with independent-verification metadata in the run or its existing
managed review artifact, the caller must
explicitly supply fresh approval again; otherwise it refuses before archiving
the existing review or invoking a model. Prior review metadata is not an
executable plan, and an ordinary `/review --again` cannot silently drop that
Expand Down
7 changes: 4 additions & 3 deletions src/lib/review.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ export async function runOnlyReview(run, {
if (!run?.worktreePath || !run.result?.resultPath) throw new Error('A completed coder result is required; run or resume a task before /review.');
if (run.planningOnly) throw new Error('Planning-only output is not a completed coder result to review.');
throwIfCancelled(signal);
if (run.review?.independentVerification && !independentVerification) {
throw new Error('Independent verification must be explicitly approved again for a review-only retry; prior review metadata is not execution authority.');
}
const worktree = run.worktreePath;
const task = await readPlannerTask(worktree);
if (task === null) throw new Error('Review requires TASK.md in the current worktree.');
const previous = await readPreviousReview(worktree);
if (!independentVerification && (run.review?.independentVerification ||
/^## Independent verification[ \t]*\r?$/m.test(previous ?? ''))) {
throw new Error('Independent verification must be explicitly approved again for a review-only retry; prior review metadata is not execution authority.');
}
if (previous !== null) {
if (!again) throw new Error('REVIEW.md already exists; use /review --again to rerun the current diff.');
const tracked = (await execute('git', ['ls-files', '--', 'REVIEW.md'], {
Expand Down
8 changes: 8 additions & 0 deletions tests/review-command.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ test('review-only retries execute fresh approved observations and retain depende
runVerificationCommand: async () => assert.fail('Missing host authority must not execute'),
}), /explicitly approved again/);
assert.equal(readFileSync(path.join(run.worktreePath, 'REVIEW.md'), 'utf8'), originalReview);
const retainedReview = originalReview.replaceAll('\n', '\r\n');
writeFileSync(path.join(run.worktreePath, 'REVIEW.md'), retainedReview);
await assert.rejects(runOnlyReview({ ...rejected, review: undefined }, {
...options, independentVerification: undefined, again: true,
fetchImpl: async () => assert.fail('Stored independent authority must survive missing run metadata'),
runVerificationCommand: async () => assert.fail('Stored metadata is not execution approval'),
}), /explicitly approved again/);
assert.equal(readFileSync(path.join(run.worktreePath, 'REVIEW.md'), 'utf8'), retainedReview);
writeFileSync(path.join(run.worktreePath, 'README.md'), '# Approved\n');
const accepted = await runOnlyReview({ ...rejected, result: run.result }, { ...options, again: true });
assert.equal(accepted.review.verdict, 'pass', accepted.review.content);
Expand Down
Loading