From 4381b21014b2a666bb38d1e7fb083300cf5b3509 Mon Sep 17 00:00:00 2001 From: "r4yharris-agent-coder[bot]" <334673250+r4yharris-agent-coder[bot]@users.noreply.github.com> Date: Mon, 12 Oct 2026 08:42:37 -0400 Subject: [PATCH] fix(review): retain stored verification authority on reconstructed retries Review-only retry checks the canonical prior REVIEW independent-verification section as well as in-memory run metadata before archive, backend or model invocation. Missing run.review cannot silently remove the required explicit host reapproval. Stored text still grants no executable approval; CRLF heading supported. Existing no-option/default reviewer behavior and explicit new approval unchanged. FEATURE_SPEC5.4/5.5/5.8; principles3/non-goals7. Node20review-command4/4 pass0skip; new regression strips run metadata and checks exact retained CRLF artifact, no model/backend calls, then existing fresh approved retry and dependency publication controls. No dependencies, store, human policy/workflow/vendor edits. Closes #598. Parent #581 remains open; fresh #593 calibration follows reviewed delivery. Copilot #596 permission-blocked recovery is separate; no bypass or unapproved permissions change. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> AI-Agent: r4yharris-agent-coder AI-Model: GPT-6.1-Sol AI-Run: 1|github-copilot|GPT-6.1-Sol@-|x|-/1000000|-|ghcp-113508|598 --- docs/REVIEW.md | 3 ++- src/lib/review.mjs | 7 ++++--- tests/review-command.test.mjs | 8 ++++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/docs/REVIEW.md b/docs/REVIEW.md index b913a20..e6c5164 100644 --- a/docs/REVIEW.md +++ b/docs/REVIEW.md @@ -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 diff --git a/src/lib/review.mjs b/src/lib/review.mjs index 55d459c..6e7850e 100644 --- a/src/lib/review.mjs +++ b/src/lib/review.mjs @@ -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'], { diff --git a/tests/review-command.test.mjs b/tests/review-command.test.mjs index 5361593..c1d4734 100644 --- a/tests/review-command.test.mjs +++ b/tests/review-command.test.mjs @@ -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);