@webpieces/pr-gate 0.4.824 → 0.4.826

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/package.json +3 -3
  2. package/src/scripts/commands/await-reviews-command.js +1 -1
  3. package/src/scripts/commands/await-reviews-command.js.map +1 -1
  4. package/src/scripts/commands/finish-upsert-pr-command.js +16 -7
  5. package/src/scripts/commands/finish-upsert-pr-command.js.map +1 -1
  6. package/src/scripts/commands/review-upsert-pr-command.js +1 -1
  7. package/src/scripts/commands/review-upsert-pr-command.js.map +1 -1
  8. package/src/scripts/commands/write-review-command.d.ts +23 -1
  9. package/src/scripts/commands/write-review-command.js +48 -2
  10. package/src/scripts/commands/write-review-command.js.map +1 -1
  11. package/src/scripts/commands/write-review-fixes-command.js +3 -0
  12. package/src/scripts/commands/write-review-fixes-command.js.map +1 -1
  13. package/src/scripts/pr-gate-app.d.ts +3 -1
  14. package/src/scripts/pr-gate-app.js +4 -0
  15. package/src/scripts/pr-gate-app.js.map +1 -1
  16. package/src/scripts/workflow/checklist-scanner.d.ts +29 -3
  17. package/src/scripts/workflow/checklist-scanner.js +51 -5
  18. package/src/scripts/workflow/checklist-scanner.js.map +1 -1
  19. package/src/scripts/workflow/hotfix-finish-preparer.js +1 -1
  20. package/src/scripts/workflow/hotfix-finish-preparer.js.map +1 -1
  21. package/src/scripts/workflow/review-report.js +4 -0
  22. package/src/scripts/workflow/review-report.js.map +1 -1
  23. package/src/scripts/workflow/review-round-state.d.ts +14 -0
  24. package/src/scripts/workflow/review-round-state.js +24 -1
  25. package/src/scripts/workflow/review-round-state.js.map +1 -1
  26. package/src/scripts/workflow/review-stage-receipt.d.ts +14 -1
  27. package/src/scripts/workflow/review-stage-receipt.js +21 -1
  28. package/src/scripts/workflow/review-stage-receipt.js.map +1 -1
  29. package/src/scripts/workflow/verdict-provenance.d.ts +6 -0
  30. package/src/scripts/workflow/verdict-provenance.js +8 -2
  31. package/src/scripts/workflow/verdict-provenance.js.map +1 -1
  32. package/src/scripts/wp-write-review.js +7 -0
  33. package/src/scripts/wp-write-review.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"review-report.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/review-report.ts"],"names":[],"mappings":";;;;AAAA,mDAA6B;AAC7B,yCAA2D;AAC3D,0DAIiC;AACjC,yDAAqD;AACrD,6DAA0F;AAC1F,6DAAkG;AAElG,MAAM,GAAG,GAAG,0DAA0D,CAAC;AAEvE;;;;;;;;;;;;;GAaG;AACH,MAAa,eAAe;IACxB,WAAW,CAAS;IACpB,OAAO,CAAS;IAEhB,YAAY,WAAmB,EAAE,OAAe;QAC5C,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;CACJ;AARD,0CAQC;AAED;;;;GAIG;AACH,MAAa,iBAAiB;IAC1B,QAAQ,CAAS;IACjB,WAAW,CAAS;IACpB,WAAW,CAAS,CAAa,8DAA8D;IAC/F,YAAY,CAAS,CAAW,iDAAiD;IACjF,eAAe,CAAS,CAAQ,yEAAyE;IACzG,QAAQ,CAAsB,CAAE,gDAAgD;IAChF,YAAY,CAAW,CAAS,0DAA0D;IAC1F,SAAS,CAAqB,CAAE,wDAAwD;IACxF,OAAO,CAAoB,CAAK,6EAA6E;IAC7G;;;;OAIG;IACH,YAAY,CAAU;IACtB;;;;;;;;;OASG;IACH,mBAAmB,CAAU;IAC7B;;;;OAIG;IACH,UAAU,CAAsB;IAChC,KAAK,CAAS;IACd,iBAAiB,CAAS;IAC1B,WAAW,CAAS;IACpB,eAAe,CAAW;IAC1B,2GAA2G;IAC3G,wCAAwC;IACxC,QAAQ,CAAsB;IAC9B;;;OAGG;IACH,SAAS,CAAoB;IAE7B,YAAY,QAAgB,EAAE,WAAmB,EAAE,WAAmB;QAClE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAA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C,kCAAe;QACV,0CAA2B;QAC1B,2CAA4B;GAJ/D,YAAY,CA2hBxB","sourcesContent":["import * as path from 'path';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport {\n HOME_CONFIG_DIR, HOME_CONFIG_FILE, HOME_KEY_TURN_OFF_ALL_REVIEWERS, summaryJsonSchemaHint,\n ChecklistInstructionsService, RequiredChecklist, REVIEWER_AGENTS_PLACEHOLDER, ReviewerAgentPolicy,\n ReviewerBriefing, ReviewerInstructionsService, VERDICT_RED,\n} from '@webpieces/rules-config';\nimport { ChecklistNotice } from './checklist-notice';\nimport { STANDING_REJECTED, STANDING_STALE, VerdictStanding } from './verdict-provenance';\nimport { ROUND_ACTION_FINISH, ROUND_ACTION_FIX, ROUND_ACTION_RECORD } from './review-round-state';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/**\n * One reviewer that ALREADY ANSWERED on this branch and refused, with the refusal rendered by\n * `ReviewJsonService.refusalError` — the ONE wording, shared with `wp-finish-upsert-pr`. Data-only.\n *\n * Stage ② carries these because it had the same defect finish did: a refused checklist has no passing\n * verdict, so it is \"owed\", so it got an ordinary spawn block identical to a reviewer that never ran. An\n * agent obeys that block, the reviewer re-reads unchanged code, refuses again — the loop, one stage earlier.\n *\n * The message is rendered by the COMMAND rather than in here for one reason: stage ② must not archive\n * anything. `refusalError` called with no archive path says \"fix it, then re-run\", which is only true while\n * the verdict file is still live — and at stage ② it is. Retiring a verdict is finish's act, on the refusal\n * it is actually acting on. (The ship-anyway route it prints — the command that writes `override-<id>.json`\n * — is correct at either stage: that is a different file, with its own writer, and no archive touches it.)\n */\nexport class RefusedReviewer {\n checklistId: string;\n message: string;\n\n constructor(checklistId: string, message: string) {\n this.checklistId = checklistId;\n this.message = message;\n }\n}\n\n/**\n * Everything the closing block of `wp-review-upsert-pr` needs. Data-only, and a class rather than an\n * object literal per CLAUDE.md. The three identifying paths are constructor args; the rest are optional\n * facts about the scan that default to \"nothing\", so a repo with no checklists constructs it in one line.\n */\nexport class ReviewReportInput {\n repoRoot: string;\n featureName: string;\n summaryPath: string; // the branch's summary.json — the file the AI must write next\n definedCount: number; // how many checklists pr-gate.checklists defines\n applicableCount: number; // how many of them apply to THIS diff (0 ⇒ the notice, not spawn blocks)\n reviewed: RequiredChecklist[]; // already have a passing verdict on this branch\n formatErrors: string[]; // verdict files that exist but cannot be read as verdicts\n briefings: ReviewerBriefing[]; // one per applicable checklist, already written to disk\n refused: RefusedReviewer[]; // of the owed ones, those that already ran and said no (see RefusedReviewer)\n /**\n * `--no-optional` was passed: the human has already said to submit without the optional reviews, so the\n * block that offers them is replaced by a one-line statement that they were skipped. It never suppresses\n * a REQUIRED reviewer, and it is not a gate — nothing about what blocks the PR changes.\n */\n skipOptional: boolean;\n /**\n * `experimental.turnOffAllReviewers` is TRUE in `~/.webpieces/config.json`, so NO reviewer ran and\n * none will — the REQUIRED ones included. Nothing else in this class may be read as evidence of that:\n * `applicableCount` is 0 under suppression exactly as it is on a docs-only PR that matched nothing,\n * and those two must never print the same thing.\n *\n * When true this stage prints a LOUD banner naming the flag, the file and every suppressed checklist,\n * and prints NO spawn block. Reviewers cannot be spawned — there are no briefings and no instructions\n * files — so a block telling an agent to spawn them would be an instruction it cannot obey.\n */\n reviewersSuppressed: boolean;\n /**\n * The checklists that WOULD have applied, had they not been suppressed. Empty unless\n * `reviewersSuppressed`. Named, not counted, because the one thing a human must be able to see is\n * WHICH required reviewer was killed.\n */\n suppressed: RequiredChecklist[];\n round: number;\n maxReviewerRounds: number;\n roundAction: string;\n redChecklistIds: string[];\n // The reviewer agent (webpieces-reviewer, or the overrideReviewerAgent name) + reviewerAgents: which agent\n // type to spawn, and the per-round cap.\n reviewer: ReviewerAgentPolicy;\n /**\n * How every existing verdict stands (issue #863) — straight off the scan. A CURRENT one is printed as\n * CARRIED with its sha and the reason; a STALE or REJECTED one is printed with why it was re-briefed.\n */\n standings: VerdictStanding[];\n\n constructor(repoRoot: string, featureName: string, summaryPath: string) {\n this.repoRoot = repoRoot;\n this.featureName = featureName;\n this.summaryPath = summaryPath;\n this.definedCount = 0;\n this.applicableCount = 0;\n this.reviewed = [];\n this.formatErrors = [];\n this.briefings = [];\n this.refused = [];\n this.skipOptional = false;\n this.reviewersSuppressed = false;\n this.suppressed = [];\n this.round = 1;\n this.maxReviewerRounds = 1;\n this.roundAction = '';\n this.redChecklistIds = [];\n this.reviewer = new ReviewerAgentPolicy('', REVIEWER_AGENTS_PLACEHOLDER);\n this.standings = [];\n }\n}\n\n/**\n * Renders the closing block of `wp-review-upsert-pr` — the checklist verdict, then EXACTLY ONE \"what to do\n * next\".\n *\n * Extracted from the command so it can be asserted on as a rendered string, because the ordering IS the\n * contract. The bug it was extracted to fix: the zero-checklist notice ended with \"Carry on and run: pnpm\n * wp-finish-upsert-pr\", and the block printed directly beneath it said to write summary.json first and\n * finish afterwards. Two next-steps, in the wrong order, and an agent that follows instructions literally —\n * which is the entire reason this command prints them — took the first one and opened a PR with no review.\n * That is precisely the failure the three-stage flow exists to prevent (reported on PR #519).\n *\n * The invariants, enforced by review-report.spec.ts:\n * 1. `wp-finish-upsert-pr` is named as a thing to run EXACTLY ONCE in the whole block.\n * 2. The summary.json instruction comes BEFORE it — and BEFORE the spawn blocks (see nextSteps).\n * 3. With zero checklists the all-clear precedes any configuration guidance.\n * 4. REQUIRED reviewers are spawned unasked; OPTIONAL ones are only ever OFFERED, in one batched\n * question. The two never share a step, because one instruction says \"do it\" and the other says\n * \"ask first\", and an agent reading a merged list will act on the stronger of the two.\n *\n * Pure string building, no I/O. `@injectable(bindingScopeValues.Singleton)` so it is injected by type.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ReviewReport {\n constructor(\n private readonly checklistNotice: ChecklistNotice,\n private readonly reviewerInstructions: ReviewerInstructionsService,\n private readonly checklistInstructions: ChecklistInstructionsService,\n ) {}\n\n render(input: ReviewReportInput): string {\n return '\\n' + SEP + this.header(input) + SEP\n + this.scanVerdict(input)\n + this.nextSteps(input);\n }\n\n /**\n * Name what this block is actually about. A repo with reviewers owed is being told to SPAWN; a repo with\n * none is not, and promising subagents it does not have is the same kind of noise as explaining checklist\n * configuration to a repo that configured none. Keyed on what is actually ACTIONABLE rather than on the\n * applicable count: every applicable checklist already having a verdict means nothing to spawn, and so\n * does a branch whose only outstanding reviews are optional ones the human already waved off.\n *\n * \"spawn\" and \"ask about\" are separate headings because they are separate obligations. A branch owing\n * only optional reviews has nothing the AI may do unilaterally, and a heading that says SPAWN is the\n * single line most likely to make it do exactly that.\n */\n private header(input: ReviewReportInput): string {\n if (input.roundAction === ROUND_ACTION_FIX) return `② ⛔ GLOBAL REVIEW ROUND ${input.round} OF ${input.maxReviewerRounds} IS RED — remediate it\\n`;\n if (input.roundAction === ROUND_ACTION_RECORD) return `② ⛔ GLOBAL REVIEW ROUND ${input.round} OF ${input.maxReviewerRounds} — record the committed remediation\\n`;\n if (input.roundAction === ROUND_ACTION_FINISH) return `② ✅ GLOBAL REVIEW ROUND ${input.round} OF ${input.maxReviewerRounds} COMPLETE — finish\\n`;\n // FIRST, and unconditional: with the kill switch on there is nothing to spawn and nothing to\n // offer, so every heading below would be true-but-misleading. The one thing a reader must take\n // from the first line of this block is that no reviewer looked at this branch.\n if (input.reviewersSuppressed) return '② ⚫ ALL REVIEWERS SUPPRESSED — write the PR summary, then finish\\n';\n if (this.requiredOwed(input).length > 0) return `② GLOBAL REVIEW ROUND ${input.round} OF ${input.maxReviewerRounds} — write the PR summary, spawn reviewers, then finish\\n`;\n if (this.offerableOwed(input).length > 0) return '② Write the PR summary, offer the optional reviewers, then finish\\n';\n return '② Write the PR summary, then finish\\n';\n }\n\n /**\n * What the SCAN found: either \"nothing applies here\" or the already-reviewed / unreadable-verdict lines.\n * Verdicts, not instructions — every instruction lives in nextSteps() below, so no line up here can be\n * mistaken for the next action.\n */\n private scanVerdict(input: ReviewReportInput): string {\n // BEFORE the zero-applicable notice, which would otherwise say \"nothing matched this diff\" — the\n // single most misleading sentence available here, because plenty matched and every one of them was\n // switched off.\n if (input.reviewersSuppressed) return '\\n' + this.suppressionBanner(input);\n if (input.applicableCount === 0) return '\\n' + this.checklistNotice.build(input.definedCount);\n const lines: string[] = [];\n // The prohibition rides on the REUSE line itself, not only in the all-clear below, because the\n // all-clear is not printed when anything is still owed — and \"some reviewers are reused, others\n // must be spawned\" is exactly the shape in which an agent re-spawns the reused ones too.\n for (const r of input.reviewed) lines.push(this.carriedLine(input, r));\n lines.push(...this.rebriefedLines(input));\n // A verdict file that EXISTS but is unreadable as a verdict is called out here. Without it this\n // reports the checklist as simply owed, and the AI re-runs a reviewer that already ran instead of\n // correcting the file sitting right there.\n for (const e of input.formatErrors) lines.push(` ⛔ ${e}`);\n lines.push(...this.skippedLines(input));\n if (this.actionableOwed(input).length === 0) lines.push('', this.allClear(input));\n if (lines.length === 0) return '';\n return '\\n' + lines.join('\\n') + '\\n';\n }\n\n /**\n * One reused verdict, with WHY it is reused. \"Already reviewed\" alone was a state, not a reason, and\n * an agent that cannot see why a verdict still counts re-checks it. The sha and the in-scope claim are\n * the reason: that verdict judged exactly the diff its checklist is judged on now.\n */\n private carriedLine(input: ReviewReportInput, r: RequiredChecklist): string {\n const standing = input.standings.find((s: VerdictStanding): boolean => s.checklistId === r.id);\n if (standing === undefined) {\n return ` ✓ ${r.id} — already reviewed on this branch; verdict STANDS, do NOT re-spawn (review-${r.id}.json)`;\n }\n return ` ✓ ${r.id} — carried ${standing.status.toUpperCase()} from ${this.short(standing.fromSha)}, `\n + `in-scope files unchanged; verdict STANDS, do NOT re-spawn`;\n }\n\n /**\n * The verdicts that exist on disk but do NOT count, each with why — so a reviewer listed below is not\n * mistaken for one that simply never ran. A STALE red is not listed here: it is still a refusal, and\n * its block below says so.\n */\n private rebriefedLines(input: ReviewReportInput): string[] {\n const lines: string[] = [];\n for (const s of input.standings) {\n if (s.standing === STANDING_STALE && s.status !== VERDICT_RED) {\n lines.push(` ↻ ${s.checklistId} — ${s.status.toUpperCase()} from ${this.short(s.fromSha)} is STALE: ${s.reason}; re-briefed below`);\n }\n if (s.standing === STANDING_REJECTED) {\n lines.push(` ⛔ ${s.checklistId} — verdict REJECTED: ${s.reason}; re-briefed below`);\n }\n }\n return lines;\n }\n\n private short(sha: string): string {\n return sha === '' ? '(unknown sha)' : sha.slice(0, 8);\n }\n\n /**\n * THE LOUD BANNER. The one output in this whole flow that says an unreviewed PR is about to be posted.\n *\n * Everything in it is there because a reader has to be able to act on it or audit it: the FLAG name and\n * the FILE it was read from (the only actionable thing — nothing in any repo turns this off), the COUNT\n * split by required/optional, and every suppressed checklist BY NAME with REQUIRED marked. A count\n * alone would leave \"which required reviewer did I just skip?\" unanswerable at the one moment it is\n * being answered.\n *\n * It deliberately does NOT name `wp-finish-upsert-pr` — the closing step already does, exactly once,\n * and that \"exactly once\" is an invariant this class's docstring records having been bought with a bug.\n */\n private suppressionBanner(input: ReviewReportInput): string {\n const required = input.suppressed.filter((r: RequiredChecklist): boolean => r.required);\n const projectDisabled = input.reviewer.maxAgents === 0;\n const lines: string[] = [\n projectDisabled\n ? '⚫ ALL REVIEWER SUBAGENTS ARE DISABLED FOR THIS PROJECT. Nothing reviewed this branch.'\n : '⚫ ALL REVIEWER SUBAGENTS ARE SWITCHED OFF ON THIS MACHINE. Nothing reviewed this branch.',\n '',\n ` ${input.suppressed.length} checklist(s) matched this diff and were SUPPRESSED — `\n + `${required.length} of them REQUIRED:`,\n ];\n for (const r of input.suppressed) {\n lines.push(` • ${r.id}${r.required ? ' (REQUIRED — suppressed anyway)' : ' (optional)'}`);\n }\n lines.push(\n '',\n ...(projectDisabled ? [\n ' Switched off by: commands.pr-gate.reviewerAgents: 0',\n ' Read from: webpieces.config.json (project policy; build and PR gates remain active)',\n ] : [\n ` Switched off by: experimental.${HOME_KEY_TURN_OFF_ALL_REVIEWERS}: true`,\n ` Read from: ~/${HOME_CONFIG_DIR}/${HOME_CONFIG_FILE} (machine-local; no repo config can set this)`,\n ]),\n '',\n ' There is NOTHING to spawn — no reviewer was briefed and no instructions file was written,',\n ' so any attempt to spawn one has nothing to read. Do NOT hand-write a verdict file in their',\n ' place: a fabricated verdict is worse than the absent one this flag deliberately produces.',\n '',\n ' The dashboard is the whole review product for this PR, and the suppression is carried into',\n ' the PR body — which is the squash-merge commit body — so main\\'s history records it.',\n projectDisabled\n ? ' To get reviewers back, set reviewerAgents to a positive integer and re-run this command.'\n : ' To get the reviewers back, set that key to false (or delete it) and re-run this command.',\n );\n return lines.join('\\n') + '\\n';\n }\n\n /**\n * `--no-optional`, stated as a VERDICT rather than left silent. Named individually, not just counted: the\n * whole reason the human is allowed to skip these is that they know this diff, and the only way they can\n * catch \"wait, not THAT one\" is to see which ones went unreviewed.\n */\n private skippedLines(input: ReviewReportInput): string[] {\n const skipped = this.optionalOwed(input);\n if (!input.skipOptional || skipped.length === 0) return [];\n return [\n '',\n ` ⏭️ ${skipped.length} OPTIONAL checklist(s) matched this diff and were SKIPPED (--no-optional):`,\n ...skipped.map((b: ReviewerBriefing): string => ` ${b.checklistId} — ${this.why(b)}`),\n ' Not blocking. Drop the flag and re-run this command to offer them after all.',\n ];\n }\n\n /**\n * The all-clear, then the RULE that makes it actionable.\n *\n * \"nothing to spawn\" on its own is a description of the current state, and an agent that has just been\n * told a state — rather than a rule — treats re-spawning as a judgement call it is entitled to make. It\n * then makes it, reasoning (correctly, on the facts) that the carried-forward verdicts judged an earlier\n * tree. Reviews here are once per branch BY CONSTRUCTION: a passing review-<id>.json satisfies its\n * checklist for the branch's whole life, and `wp-finish-upsert-pr` never archives one the way it archives\n * summary.json. So the reuse is deliberate — it is what keeps post-PR iteration from re-paying for every\n * matched reviewer — and the output has to say so, because the alternative reading is the expensive one.\n *\n * The overwrite warning is not decoration. A re-spawned reviewer writes to the SAME verdict path, so a\n * gratuitous re-run does not merely cost a subagent — it destroys the verdict that was already banked.\n *\n * It must NOT claim everything was reviewed when optional reviews were skipped — that is the one sentence\n * that would turn a deliberate skip into a false record of a review that happened.\n */\n private allClear(input: ReviewReportInput): string {\n const headline = input.skipOptional && this.optionalOwed(input).length > 0\n ? '✅ Nothing left to spawn — every REQUIRED checklist is reviewed (optional ones skipped above).'\n : '✅ Every checklist that applies is already reviewed — nothing to spawn.';\n return headline + '\\n' + this.oncePerBranchRule();\n }\n\n /**\n * The once-per-branch rule, stated as a prohibition rather than left to be inferred from a ✅.\n *\n * Printed whenever verdicts are being reused — which is every iteration of a PR after the first, i.e. the\n * majority of stage-② runs on any branch that gets review feedback.\n */\n private oncePerBranchRule(): string {\n return (\n ' A passing verdict CARRIES FORWARD for as long as its checklist\\'s in-scope files are unchanged,\\n' +\n ' deliberately, so edits elsewhere cost no reviewer tokens. When those files DO change, this\\n' +\n ' stage re-briefs that checklist itself and names it in a STEP below. Do NOT re-spawn a reviewer\\n' +\n ' listed above to \"re-check\" — it burns a full subagent run AND replaces the verdict it already\\n' +\n ' submitted. The only reviewers you may spawn are ones a STEP below names.'\n );\n }\n\n /**\n * The ONE instruction block, and the last thing the stage prints. Numbered rather than prose-linked\n * (\"Then… Finally…\") so that skipping step 1 is visibly skipping a step, and worded so no earlier line\n * can be mistaken for the real next action.\n *\n * summary.json is STEP 1 and the spawn blocks are STEP 2 — that ORDER is the contract, not a preference.\n * This block used to print the spawn blocks first and then say to write summary.json \"WHILE any reviewer\n * subagents above are still running\", which does not merely permit spawning first, it instructs it.\n * Harmless for a reviewer that only reads the diff; wrong for one that judges the PR's stated INTENT —\n * its title, summary or risk level — because summary.json is the only place that intent lives. Such a\n * reviewer either finds no file (a false RED and a wasted reviewer run) or, on a second run of this\n * stage on the same branch, finds the PREVIOUS run's file and validates a title that no longer exists —\n * a false GREEN, with nothing in the output saying which of the two happened. A consuming repo had to\n * write itself a rule telling its agents to DISOBEY this block to work around it.\n *\n * What the old ordering bought was overlap on a single local file write, not a subagent round-trip.\n *\n * The schema hint is rendered by ReviewJsonService — the single renderer — so the shape printed here\n * can never drift from the shape `wp-finish-upsert-pr` validates.\n */\n private nextSteps(input: ReviewReportInput): string {\n if (input.roundAction === ROUND_ACTION_FIX) return this.fixStep(input);\n if (input.roundAction === ROUND_ACTION_RECORD) return this.recordStep(input);\n if (input.roundAction === ROUND_ACTION_FINISH) return this.cappedFinishStep(input);\n const required = this.requiredOwed(input);\n const offerable = this.offerableOwed(input);\n // Numbered by what is actually PRINTED, so the numbers a reader sees are 1..n with no gaps: write\n // summary.json, then a spawn step only if anything must run, then an offer step only if anything may.\n let step = 1;\n const write = this.writeSummaryStep(input.summaryPath, step++, '');\n // The wait block goes under the LAST reviewer-listing step, and only there. Printed under both\n // it would be two \"what to do next\" instructions in one output, which is the defect this\n // method's docstring describes — an agent reading top to bottom obeys the first one it meets.\n const spawn = required.length === 0 ? '' : this.spawnStep(input, required, step++, offerable.length === 0);\n const offer = offerable.length === 0 ? '' : this.offerStep(input, offerable, step++, true);\n return '\\n' + SEP\n + `▶ NEXT — ${step} steps, in this order. Step 1 is NOT optional:\\n` + SEP + '\\n'\n + write + spawn + offer + this.finishStep(step, required.length + offerable.length > 0);\n }\n\n private writeSummaryStep(summaryPath: string, step: number, mainAgentInstructions: string): string {\n return (\n `STEP ${step} — write the PR summary (title, summary, risk) to summary.json. Write it FIRST — BEFORE you spawn\\n` +\n ' anything below. finish REFUSES without it, and a reviewer subagent may READ it: a\\n' +\n ' checklist that judges the PR title, summary or risk level reads exactly this file, so\\n' +\n ' writing it afterwards races that reviewer into seeing nothing — or, on a re-run of this\\n' +\n ' stage, into judging the PREVIOUS run\\'s summary of code that has since changed.\\n\\n' +\n summaryJsonSchemaHint(summaryPath, mainAgentInstructions) + '\\n\\n'\n );\n }\n\n private fixStep(input: ReviewReportInput): string {\n return '\\n' + SEP + `▶ NEXT — fix every finding from round ${input.round} of ${input.maxReviewerRounds}\\n` + SEP + '\\n'\n + ` Red checklist(s): ${input.redChecklistIds.join(', ')}\\n`\n + ' Commit every fix and leave the tree clean, then record one response per checklist with:\\n'\n + ' pnpm wp-write-review-fixes\\n'\n + ' Re-run pnpm wp-review-upsert-pr after that. It will start a focused remediation-only round\\n'\n + ' only when the configured round budget still has room.\\n';\n }\n\n private recordStep(input: ReviewReportInput): string {\n return '\\n' + SEP + `▶ NEXT — record the committed fixes for round ${input.round} of ${input.maxReviewerRounds}\\n` + SEP + '\\n'\n + ' pnpm wp-write-review-fixes\\n\\n'\n + ' The command stamps the reviewed HEAD and current clean HEAD itself. Then re-run\\n'\n + ' pnpm wp-review-upsert-pr; do not edit or recolor the reviewer verdict.\\n';\n }\n\n private cappedFinishStep(input: ReviewReportInput): string {\n const capped = input.redChecklistIds.length > 0\n ? ` Review cap reached. ${input.redChecklistIds.join(', ')} is author-remediated after the cap and was NOT re-reviewed.\\n`\n : '';\n return '\\n' + SEP + '▶ NEXT — write summary.json, then finish\\n' + SEP + '\\n'\n + capped + this.writeSummaryStep(input.summaryPath, 1, '')\n + 'STEP 2 — run: pnpm wp-finish-upsert-pr\\n';\n }\n\n /**\n * The REQUIRED reviewers — one copy-paste block each, and nothing at all when none is owed. The prompt is\n * deliberately a POINTER and nothing else: the generated instructions file is the contract, so anything\n * restated here is a second copy that can go stale — which is exactly how a removed `success` field\n * outlived its own removal in print.\n *\n * These are spawned WITHOUT asking. They are the checklists the repo declared `required: true`, which is\n * the repo saying the decision was already made; putting them to the human again would re-open a question\n * the config exists to settle.\n */\n private spawnStep(input: ReviewReportInput, owed: readonly ReviewerBriefing[], step: number, withAwait: boolean): string {\n const lines: string[] = [\n `STEP ${step} — only once that file is written, review these ${owed.length} REQUIRED checklist(s) with`,\n ...this.howManyAgents(input, owed.length),\n ' They block the PR, so do NOT ask whether to run them. You may NOT review your own',\n ' work, and you may NOT submit a reviewer\\'s verdict on its behalf: pnpm wp-write-review',\n ' refuses the coordinating agent, and finish rejects a verdict file written by hand.',\n '',\n ];\n lines.push(...this.refusedWarning(input, owed));\n for (const b of owed) lines.push(...this.oneSpawnBlock(input, b));\n if (withAwait) lines.push(...this.awaitLines());\n lines.push('');\n return lines.join('\\n');\n }\n\n /**\n * How to WAIT once the spawn list has been spawned — printed after the blocks, because it is the\n * next thing to do and nothing before it can be mistaken for it.\n *\n * It is here because the alternative is measured and expensive: `echo .` every three seconds at\n * ~557,000 tokens a turn, 18.3% of every token the fleet spent in the 24h to 2026-09-07 (#874).\n *\n * It names the efficient options and the wasteful one, and then stops (#902). It does NOT prescribe\n * ending the turn: waiting on the subagents you just spawned is something an agent already does\n * routinely, and whether to do that here is a judgement this string cannot make for it.\n *\n * It names no other stage. `finishStep` below is the ONE place this whole block names\n * `wp-finish-upsert-pr`, and a second mention here would be a second \"what to do next\" instruction\n * for an agent reading top to bottom — the exact defect the class docstring above describes.\n */\n private awaitLines(): string[] {\n return [\n ' Then WAIT. Be efficient with tokens: wait on the subagents you just spawned, or block',\n ' in one call with the command below. Do NOT send status checks every few seconds, and',\n ' do NOT run `echo` to keep your turn alive — a turn costs your whole context, ~557k',\n ' tokens.',\n '',\n ' pnpm wp-await-reviews',\n '',\n ' It heartbeats while it waits, returns as soon as the last verdict lands, and prints',\n ' what each reviewer said. If the wait is long it exits asking to be run again.',\n ];\n }\n\n /**\n * STEP n — the OPTIONAL reviewers: listed, never spawned unasked.\n *\n * This is the whole point of `required: false`. A one-line bug fix in a repo whose checklists key on a\n * glob as broad as every TypeScript file otherwise pays for a dozen subagent reviews, and the only party\n * who can judge whether this particular diff is worth them is the human looking at it.\n *\n * ONE batched multi-select question, explicitly. Asked one at a time, a human answering \"no\" nine times\n * is being worn down rather than consulted, and by the third question the cheap thing is to say yes to\n * everything — which is the state this feature exists to leave. The \"None\" option has to be spelled out\n * too: an agent that offers a list without an explicit way to decline it has not really offered a choice.\n *\n * The blocking consequence is stated because it is the one non-obvious part of the contract: `required`\n * governs whether a reviewer must RUN, not whether its answer counts. Choosing to run one and then\n * shrugging off a red verdict would make the whole exercise theater.\n */\n private offerStep(input: ReviewReportInput, offerable: readonly ReviewerBriefing[], step: number, withAwait: boolean): string {\n const lines: string[] = [\n `STEP ${step} — these ${offerable.length} OPTIONAL review checklist(s) matched this diff. They do NOT block the`,\n ' PR, and you may NOT decide for the human whether to run them.',\n '',\n ' ASK THE HUMAN, in ONE multi-select question listing all of them plus an explicit',\n ' \"None — required only\" choice. Do not ask one question per reviewer. Then spawn ONLY',\n ' what they picked, the same way as any other reviewer.',\n '',\n ' If they pick none, that is a complete answer: go straight to the final step. If they',\n ' told you up front to submit without reviews, re-run this stage as',\n ' `pnpm wp-review-upsert-pr --no-optional` and this step disappears.',\n '',\n ' NOTE: whichever ones you DO run, their verdicts count in full — a red verdict from an',\n ' optional reviewer blocks the PR exactly like a required one.',\n '',\n ];\n lines.push(...this.optionalAgentLines(input, offerable.length));\n lines.push(...this.refusedWarning(input, offerable));\n for (const b of offerable) lines.push(...this.oneSpawnBlock(input, b));\n if (withAwait) lines.push(...this.awaitLines());\n lines.push('');\n return lines.join('\\n');\n }\n\n // How the picked optional checklists are staffed. Grouped, the cap covers the WHOLE round, required\n // reviewers included — otherwise \"at most N\" would quietly become 2N the moment a human said yes.\n private optionalAgentLines(input: ReviewReportInput, count: number): string[] {\n const reviewer = input.reviewer;\n const required = this.requiredOwed(input).length;\n // The Codex pointer is printed once per report: by the required step when there is one.\n const codex = required > 0 ? [] : [this.agentDefinitionLine(input)];\n const scope = required > 0 ? `, COUNTING the ${required} required checklist(s) above — fold picked ones into those subagents` : '';\n return [\n ` Review what they picked with \\`${reviewer.agentName}\\` subagents: at most ${reviewer.maxAgents} IN TOTAL`,\n ` this round${scope}. Hand each subagent the instructions file of every checklist it covers.`,\n ...codex,\n ...(count > 0 ? [''] : []),\n ];\n }\n\n // Said up front, not only beside the block: an agent that has decided to spawn everything listed here\n // needs to know BEFORE it starts that one of these entries is not a spawn-shaped task. Scoped to the\n // group being printed — a refusal among the REQUIRED reviewers is not a caveat on the optional list.\n private refusedWarning(input: ReviewReportInput, group: readonly ReviewerBriefing[]): string[] {\n const ids = new Set(group.map((b: ReviewerBriefing): string => b.checklistId));\n const n = input.refused.filter((r: RefusedReviewer): boolean => ids.has(r.checklistId)).length;\n if (n === 0) return [];\n return [\n ` ${n} of them already ANSWERED and refused (marked ⛔ below). Do not spawn`,\n ' those against unchanged code — fix what they found first; the fix is the prerequisite.',\n '',\n ];\n }\n\n private finishStep(stepNumber: number, anyReviewers: boolean): string {\n // \"every reviewer you ran\" rather than \"every reviewer above\": with an optional list the human may\n // legitimately have run none of them, and a precondition naming reviewers that were declined reads as\n // an unmeetable one.\n const precondition = anyReviewers\n ? 'once every reviewer you ran has submitted its verdict'\n : 'once that file exists';\n return (\n `STEP ${stepNumber} — only ${precondition}, run: pnpm wp-finish-upsert-pr\\n` +\n ' (The build gate is already green for this commit — finish reuses it unless HEAD moves.)\\n\\n'\n );\n }\n\n // The briefings with no passing verdict yet — the ONE definition of \"owed\", shared by the header, the\n // scan verdict and the step numbering, so they cannot disagree about whether there is anything to spawn.\n private owedReviewers(input: ReviewReportInput): ReviewerBriefing[] {\n const reviewedIds = new Set(input.reviewed.map((r: RequiredChecklist): string => r.id));\n return input.briefings.filter((b: ReviewerBriefing): boolean => !reviewedIds.has(b.checklistId));\n }\n\n // Owed AND blocking — spawned without asking.\n private requiredOwed(input: ReviewReportInput): ReviewerBriefing[] {\n return this.owedReviewers(input).filter((b: ReviewerBriefing): boolean => b.required);\n }\n\n // Owed and optional. Still listed under `--no-optional` (as a skip verdict), just never as a step.\n private optionalOwed(input: ReviewReportInput): ReviewerBriefing[] {\n return this.owedReviewers(input).filter((b: ReviewerBriefing): boolean => !b.required);\n }\n\n // The optional ones the human is actually to be ASKED about — none, once they have already answered.\n private offerableOwed(input: ReviewReportInput): ReviewerBriefing[] {\n return input.skipOptional ? [] : this.optionalOwed(input);\n }\n\n // Everything the AI still has to act on. Distinct from `owedReviewers`: a skipped optional checklist is\n // owed a verdict it will never get, and treating it as pending work is what would print a spawn\n // instruction for a review the human just declined.\n private actionableOwed(input: ReviewReportInput): ReviewerBriefing[] {\n return [...this.requiredOwed(input), ...this.offerableOwed(input)];\n }\n\n /**\n * One reviewer's block. A reviewer that already REFUSED gets the SAME spawn coordinates but a different\n * lead-in, because the action before spawning is different: its own words are printed, and the spawn is\n * explicitly conditioned on having fixed the finding first.\n *\n * It keeps its spawn block rather than being dropped from the list, because the reviewer genuinely does\n * still owe a fresh verdict — dropping it would leave nothing anywhere saying how to get one. What must\n * not happen is a bare \"spawn this\" that reads identically to a reviewer that never ran, which is the\n * loop this exists to break.\n */\n private oneSpawnBlock(input: ReviewReportInput, b: ReviewerBriefing): string[] {\n const instructionsFile = this.reviewerInstructions.pathFor(input.repoRoot, input.featureName, b.checklistId);\n // The subagent_type is stated once, above; each block is one checklist's file to hand to\n // whichever subagent covers it.\n return [...this.leadIn(input, b), ` instructions: ${instructionsFile}`, ''];\n }\n\n /**\n * HOW MANY subagents, of WHICH type — the one place this report states it, shared by the required and\n * the optional step so the two cannot disagree.\n *\n * Positive `commands.pr-gate.reviewerAgents` values give the main AI a CAP and the\n * grouping decision: the point of the key is to stop paying for N agents re-reading the same diff, and\n * the AI is the one that can see which checklists belong together. The cap is per ROUND, so a re-run\n * after a red verdict re-reviews only the owed checklists — the only ones listed — under the same cap.\n */\n private howManyAgents(input: ReviewReportInput, count: number): string[] {\n const reviewer = input.reviewer;\n const cap = Math.min(reviewer.maxAgents, count);\n return [\n ` AT MOST ${cap} subagent(s) of type \\`${reviewer.agentName}\\` (commands.pr-gate.reviewerAgents = ${reviewer.maxAgents}).`,\n ` ${this.checklistInstructions.groupingHint(count, cap)}`,\n ' Spawn each one as:',\n ` subagent_type: ${reviewer.agentName}`,\n ' prompt: Read EACH instructions file below FIRST and follow it exactly. Review each',\n ' checklist only over its own in-scope files and submit ONE verdict per',\n ' checklist with pnpm wp-write-review — never one for a checklist you were',\n ' not given.',\n ' <then list the instructions file of every checklist this subagent covers>',\n ' Every checklist below must be covered by exactly one of those subagents.',\n this.agentDefinitionLine(input),\n ];\n }\n\n /**\n * The ONE canonical reviewer definition, named for a harness that cannot spawn it by type. Codex has no\n * registered agent types, so its subagent is generic; pointing it at the same committed file keeps one\n * definition for both harnesses instead of a Codex-specific copy that drifts (#863).\n */\n private agentDefinitionLine(input: ReviewReportInput): string {\n const file = path.join(input.repoRoot, '.claude', 'agents', `${input.reviewer.agentName}.md`);\n return ` Codex (no agent types): spawn a generic subagent with NO forked turns (fresh context — do not\\n`\n + ` fork this conversation into it) and hand it ONLY the instructions files below; it reads\\n`\n + ` ${file} first. The brief on disk is its whole input: a forked conversation hands a\\n`\n + ` reviewer the author's reasoning, which costs tokens and its independence.`;\n }\n\n // The lines above the spawn coordinates: normally just why this reviewer is in scope; for one that\n // already refused, its verdict verbatim plus the order the two actions must happen in.\n private leadIn(input: ReviewReportInput, b: ReviewerBriefing): string[] {\n const refusal = input.refused.find((r: RefusedReviewer): boolean => r.checklistId === b.checklistId);\n if (!refusal) return [` ▶ ${b.checklistId} — ${this.why(b)}`, ...this.docLine(b)];\n return [\n ` ⛔ ${b.checklistId} — ALREADY REVIEWED THIS BRANCH AND REFUSED. It will refuse again on unchanged code.`,\n ` ${refusal.message}`,\n ' FIX THE FINDING FIRST (or record a human-authored override). ONLY THEN spawn it again, to',\n ' write a fresh verdict:',\n ];\n }\n\n /**\n * The checklist's guidance doc, for OPTIONAL reviewers only.\n *\n * \"4 file(s) matched\" plus a broad glob does not tell a human what the review would actually look AT,\n * and they are being asked to decide exactly that. Omitted for required reviewers: there is no decision\n * to inform there — the reviewer runs either way, and the doc is already in its instructions file.\n */\n private docLine(b: ReviewerBriefing): string[] {\n if (b.required || b.docPath === '') return [];\n return [` reviews against: ${b.docPath}`];\n }\n\n // Why this one is in scope. A patternless checklist is NOT \"matched\" — it always runs, over the whole\n // diff, and saying so is what tells a repo its checklist is firing on docs-only PRs by design.\n private why(b: ReviewerBriefing): string {\n if (b.matchedPatterns.length === 0) {\n return `ALWAYS RUNS (no \"patterns\" configured), whole diff in scope — ${b.myFiles.length} file(s)`;\n }\n return `${b.myFiles.length} file(s) matched ${b.matchedPatterns.map((p: string): string => `\"${p}\"`).join(', ')}`;\n }\n}\n"]}
1
+ {"version":3,"file":"review-report.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/review-report.ts"],"names":[],"mappings":";;;;AAAA,mDAA6B;AAC7B,yCAA2D;AAC3D,0DAIiC;AACjC,yDAAqD;AACrD,6DAA4G;AAC5G,6DAAkG;AAElG,MAAM,GAAG,GAAG,0DAA0D,CAAC;AAEvE;;;;;;;;;;;;;GAaG;AACH,MAAa,eAAe;IACxB,WAAW,CAAS;IACpB,OAAO,CAAS;IAEhB,YAAY,WAAmB,EAAE,OAAe;QAC5C,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;CACJ;AARD,0CAQC;AAED;;;;GAIG;AACH,MAAa,iBAAiB;IAC1B,QAAQ,CAAS;IACjB,WAAW,CAAS;IACpB,WAAW,CAAS,CAAa,8DAA8D;IAC/F,YAAY,CAAS,CAAW,iDAAiD;IACjF,eAAe,CAAS,CAAQ,yEAAyE;IACzG,QAAQ,CAAsB,CAAE,gDAAgD;IAChF,YAAY,CAAW,CAAS,0DAA0D;IAC1F,SAAS,CAAqB,CAAE,wDAAwD;IACxF,OAAO,CAAoB,CAAK,6EAA6E;IAC7G;;;;OAIG;IACH,YAAY,CAAU;IACtB;;;;;;;;;OASG;IACH,mBAAmB,CAAU;IAC7B;;;;OAIG;IACH,UAAU,CAAsB;IAChC,KAAK,CAAS;IACd,iBAAiB,CAAS;IAC1B,WAAW,CAAS;IACpB,eAAe,CAAW;IAC1B,2GAA2G;IAC3G,wCAAwC;IACxC,QAAQ,CAAsB;IAC9B;;;OAGG;IACH,SAAS,CAAoB;IAE7B,YAAY,QAAgB,EAAE,WAAmB,EAAE,WAAmB;QAClE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,C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AS,EAAU,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IACtH,CAAC;CACJ,CAAA;AA/hBY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGC,kCAAe;QACV,0CAA2B;QAC1B,2CAA4B;GAJ/D,YAAY,CA+hBxB","sourcesContent":["import * as path from 'path';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport {\n HOME_CONFIG_DIR, HOME_CONFIG_FILE, HOME_KEY_TURN_OFF_ALL_REVIEWERS, summaryJsonSchemaHint,\n ChecklistInstructionsService, RequiredChecklist, REVIEWER_AGENTS_PLACEHOLDER, ReviewerAgentPolicy,\n ReviewerBriefing, ReviewerInstructionsService, VERDICT_RED,\n} from '@webpieces/rules-config';\nimport { ChecklistNotice } from './checklist-notice';\nimport { STANDING_CARRIED, STANDING_REJECTED, STANDING_STALE, VerdictStanding } from './verdict-provenance';\nimport { ROUND_ACTION_FINISH, ROUND_ACTION_FIX, ROUND_ACTION_RECORD } from './review-round-state';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/**\n * One reviewer that ALREADY ANSWERED on this branch and refused, with the refusal rendered by\n * `ReviewJsonService.refusalError` — the ONE wording, shared with `wp-finish-upsert-pr`. Data-only.\n *\n * Stage ② carries these because it had the same defect finish did: a refused checklist has no passing\n * verdict, so it is \"owed\", so it got an ordinary spawn block identical to a reviewer that never ran. An\n * agent obeys that block, the reviewer re-reads unchanged code, refuses again — the loop, one stage earlier.\n *\n * The message is rendered by the COMMAND rather than in here for one reason: stage ② must not archive\n * anything. `refusalError` called with no archive path says \"fix it, then re-run\", which is only true while\n * the verdict file is still live — and at stage ② it is. Retiring a verdict is finish's act, on the refusal\n * it is actually acting on. (The ship-anyway route it prints — the command that writes `override-<id>.json`\n * — is correct at either stage: that is a different file, with its own writer, and no archive touches it.)\n */\nexport class RefusedReviewer {\n checklistId: string;\n message: string;\n\n constructor(checklistId: string, message: string) {\n this.checklistId = checklistId;\n this.message = message;\n }\n}\n\n/**\n * Everything the closing block of `wp-review-upsert-pr` needs. Data-only, and a class rather than an\n * object literal per CLAUDE.md. The three identifying paths are constructor args; the rest are optional\n * facts about the scan that default to \"nothing\", so a repo with no checklists constructs it in one line.\n */\nexport class ReviewReportInput {\n repoRoot: string;\n featureName: string;\n summaryPath: string; // the branch's summary.json — the file the AI must write next\n definedCount: number; // how many checklists pr-gate.checklists defines\n applicableCount: number; // how many of them apply to THIS diff (0 ⇒ the notice, not spawn blocks)\n reviewed: RequiredChecklist[]; // already have a passing verdict on this branch\n formatErrors: string[]; // verdict files that exist but cannot be read as verdicts\n briefings: ReviewerBriefing[]; // one per applicable checklist, already written to disk\n refused: RefusedReviewer[]; // of the owed ones, those that already ran and said no (see RefusedReviewer)\n /**\n * `--no-optional` was passed: the human has already said to submit without the optional reviews, so the\n * block that offers them is replaced by a one-line statement that they were skipped. It never suppresses\n * a REQUIRED reviewer, and it is not a gate — nothing about what blocks the PR changes.\n */\n skipOptional: boolean;\n /**\n * `experimental.turnOffAllReviewers` is TRUE in `~/.webpieces/config.json`, so NO reviewer ran and\n * none will — the REQUIRED ones included. Nothing else in this class may be read as evidence of that:\n * `applicableCount` is 0 under suppression exactly as it is on a docs-only PR that matched nothing,\n * and those two must never print the same thing.\n *\n * When true this stage prints a LOUD banner naming the flag, the file and every suppressed checklist,\n * and prints NO spawn block. Reviewers cannot be spawned — there are no briefings and no instructions\n * files — so a block telling an agent to spawn them would be an instruction it cannot obey.\n */\n reviewersSuppressed: boolean;\n /**\n * The checklists that WOULD have applied, had they not been suppressed. Empty unless\n * `reviewersSuppressed`. Named, not counted, because the one thing a human must be able to see is\n * WHICH required reviewer was killed.\n */\n suppressed: RequiredChecklist[];\n round: number;\n maxReviewerRounds: number;\n roundAction: string;\n redChecklistIds: string[];\n // The reviewer agent (webpieces-reviewer, or the overrideReviewerAgent name) + reviewerAgents: which agent\n // type to spawn, and the per-round cap.\n reviewer: ReviewerAgentPolicy;\n /**\n * How every existing verdict stands (issue #863) — straight off the scan. A CURRENT one is printed as\n * CARRIED with its sha and the reason; a STALE or REJECTED one is printed with why it was re-briefed.\n */\n standings: VerdictStanding[];\n\n constructor(repoRoot: string, featureName: string, summaryPath: string) {\n this.repoRoot = repoRoot;\n this.featureName = featureName;\n this.summaryPath = summaryPath;\n this.definedCount = 0;\n this.applicableCount = 0;\n this.reviewed = [];\n this.formatErrors = [];\n this.briefings = [];\n this.refused = [];\n this.skipOptional = false;\n this.reviewersSuppressed = false;\n this.suppressed = [];\n this.round = 1;\n this.maxReviewerRounds = 1;\n this.roundAction = '';\n this.redChecklistIds = [];\n this.reviewer = new ReviewerAgentPolicy('', REVIEWER_AGENTS_PLACEHOLDER);\n this.standings = [];\n }\n}\n\n/**\n * Renders the closing block of `wp-review-upsert-pr` — the checklist verdict, then EXACTLY ONE \"what to do\n * next\".\n *\n * Extracted from the command so it can be asserted on as a rendered string, because the ordering IS the\n * contract. The bug it was extracted to fix: the zero-checklist notice ended with \"Carry on and run: pnpm\n * wp-finish-upsert-pr\", and the block printed directly beneath it said to write summary.json first and\n * finish afterwards. Two next-steps, in the wrong order, and an agent that follows instructions literally —\n * which is the entire reason this command prints them — took the first one and opened a PR with no review.\n * That is precisely the failure the three-stage flow exists to prevent (reported on PR #519).\n *\n * The invariants, enforced by review-report.spec.ts:\n * 1. `wp-finish-upsert-pr` is named as a thing to run EXACTLY ONCE in the whole block.\n * 2. The summary.json instruction comes BEFORE it — and BEFORE the spawn blocks (see nextSteps).\n * 3. With zero checklists the all-clear precedes any configuration guidance.\n * 4. REQUIRED reviewers are spawned unasked; OPTIONAL ones are only ever OFFERED, in one batched\n * question. The two never share a step, because one instruction says \"do it\" and the other says\n * \"ask first\", and an agent reading a merged list will act on the stronger of the two.\n *\n * Pure string building, no I/O. `@injectable(bindingScopeValues.Singleton)` so it is injected by type.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ReviewReport {\n constructor(\n private readonly checklistNotice: ChecklistNotice,\n private readonly reviewerInstructions: ReviewerInstructionsService,\n private readonly checklistInstructions: ChecklistInstructionsService,\n ) {}\n\n render(input: ReviewReportInput): string {\n return '\\n' + SEP + this.header(input) + SEP\n + this.scanVerdict(input)\n + this.nextSteps(input);\n }\n\n /**\n * Name what this block is actually about. A repo with reviewers owed is being told to SPAWN; a repo with\n * none is not, and promising subagents it does not have is the same kind of noise as explaining checklist\n * configuration to a repo that configured none. Keyed on what is actually ACTIONABLE rather than on the\n * applicable count: every applicable checklist already having a verdict means nothing to spawn, and so\n * does a branch whose only outstanding reviews are optional ones the human already waved off.\n *\n * \"spawn\" and \"ask about\" are separate headings because they are separate obligations. A branch owing\n * only optional reviews has nothing the AI may do unilaterally, and a heading that says SPAWN is the\n * single line most likely to make it do exactly that.\n */\n private header(input: ReviewReportInput): string {\n if (input.roundAction === ROUND_ACTION_FIX) return `② ⛔ GLOBAL REVIEW ROUND ${input.round} OF ${input.maxReviewerRounds} IS RED — remediate it\\n`;\n if (input.roundAction === ROUND_ACTION_RECORD) return `② ⛔ GLOBAL REVIEW ROUND ${input.round} OF ${input.maxReviewerRounds} — record the committed remediation\\n`;\n if (input.roundAction === ROUND_ACTION_FINISH) return `② ✅ GLOBAL REVIEW ROUND ${input.round} OF ${input.maxReviewerRounds} COMPLETE — finish\\n`;\n // FIRST, and unconditional: with the kill switch on there is nothing to spawn and nothing to\n // offer, so every heading below would be true-but-misleading. The one thing a reader must take\n // from the first line of this block is that no reviewer looked at this branch.\n if (input.reviewersSuppressed) return '② ⚫ ALL REVIEWERS SUPPRESSED — write the PR summary, then finish\\n';\n if (this.requiredOwed(input).length > 0) return `② GLOBAL REVIEW ROUND ${input.round} OF ${input.maxReviewerRounds} — write the PR summary, spawn reviewers, then finish\\n`;\n if (this.offerableOwed(input).length > 0) return '② Write the PR summary, offer the optional reviewers, then finish\\n';\n return '② Write the PR summary, then finish\\n';\n }\n\n /**\n * What the SCAN found: either \"nothing applies here\" or the already-reviewed / unreadable-verdict lines.\n * Verdicts, not instructions — every instruction lives in nextSteps() below, so no line up here can be\n * mistaken for the next action.\n */\n private scanVerdict(input: ReviewReportInput): string {\n // BEFORE the zero-applicable notice, which would otherwise say \"nothing matched this diff\" — the\n // single most misleading sentence available here, because plenty matched and every one of them was\n // switched off.\n if (input.reviewersSuppressed) return '\\n' + this.suppressionBanner(input);\n if (input.applicableCount === 0) return '\\n' + this.checklistNotice.build(input.definedCount);\n const lines: string[] = [];\n // The prohibition rides on the REUSE line itself, not only in the all-clear below, because the\n // all-clear is not printed when anything is still owed — and \"some reviewers are reused, others\n // must be spawned\" is exactly the shape in which an agent re-spawns the reused ones too.\n for (const r of input.reviewed) lines.push(this.carriedLine(input, r));\n lines.push(...this.rebriefedLines(input));\n // A verdict file that EXISTS but is unreadable as a verdict is called out here. Without it this\n // reports the checklist as simply owed, and the AI re-runs a reviewer that already ran instead of\n // correcting the file sitting right there.\n for (const e of input.formatErrors) lines.push(` ⛔ ${e}`);\n lines.push(...this.skippedLines(input));\n if (this.actionableOwed(input).length === 0) lines.push('', this.allClear(input));\n if (lines.length === 0) return '';\n return '\\n' + lines.join('\\n') + '\\n';\n }\n\n /**\n * One reused verdict, with WHY it is reused. \"Already reviewed\" alone was a state, not a reason, and\n * an agent that cannot see why a verdict still counts re-checks it. The sha and the in-scope claim are\n * the reason: that verdict judged exactly the diff its checklist is judged on now.\n */\n private carriedLine(input: ReviewReportInput, r: RequiredChecklist): string {\n const standing = input.standings.find((s: VerdictStanding): boolean => s.checklistId === r.id);\n if (standing === undefined) {\n return ` ✓ ${r.id} — already reviewed on this branch; verdict STANDS, do NOT re-spawn (review-${r.id}.json)`;\n }\n if (standing.standing === STANDING_CARRIED) {\n return ` ✓ ${r.id} — carried ${standing.status.toUpperCase()} from ${this.short(standing.fromSha)}: `\n + `${standing.reason}; verdict STANDS, do NOT re-spawn`;\n }\n return ` ✓ ${r.id} — carried ${standing.status.toUpperCase()} from ${this.short(standing.fromSha)}, `\n + `in-scope files unchanged; verdict STANDS, do NOT re-spawn`;\n }\n\n /**\n * The verdicts that exist on disk but do NOT count, each with why — so a reviewer listed below is not\n * mistaken for one that simply never ran. A STALE red is not listed here: it is still a refusal, and\n * its block below says so.\n */\n private rebriefedLines(input: ReviewReportInput): string[] {\n const lines: string[] = [];\n for (const s of input.standings) {\n if (s.standing === STANDING_STALE && s.status !== VERDICT_RED) {\n lines.push(` ↻ ${s.checklistId} — ${s.status.toUpperCase()} from ${this.short(s.fromSha)} is STALE: ${s.reason}; re-briefed below`);\n }\n if (s.standing === STANDING_REJECTED) {\n lines.push(` ⛔ ${s.checklistId} — verdict REJECTED: ${s.reason}; re-briefed below`);\n }\n }\n return lines;\n }\n\n private short(sha: string): string {\n return sha === '' ? '(unknown sha)' : sha.slice(0, 8);\n }\n\n /**\n * THE LOUD BANNER. The one output in this whole flow that says an unreviewed PR is about to be posted.\n *\n * Everything in it is there because a reader has to be able to act on it or audit it: the FLAG name and\n * the FILE it was read from (the only actionable thing — nothing in any repo turns this off), the COUNT\n * split by required/optional, and every suppressed checklist BY NAME with REQUIRED marked. A count\n * alone would leave \"which required reviewer did I just skip?\" unanswerable at the one moment it is\n * being answered.\n *\n * It deliberately does NOT name `wp-finish-upsert-pr` — the closing step already does, exactly once,\n * and that \"exactly once\" is an invariant this class's docstring records having been bought with a bug.\n */\n private suppressionBanner(input: ReviewReportInput): string {\n const required = input.suppressed.filter((r: RequiredChecklist): boolean => r.required);\n const projectDisabled = input.reviewer.maxAgents === 0;\n const lines: string[] = [\n projectDisabled\n ? '⚫ ALL REVIEWER SUBAGENTS ARE DISABLED FOR THIS PROJECT. Nothing reviewed this branch.'\n : '⚫ ALL REVIEWER SUBAGENTS ARE SWITCHED OFF ON THIS MACHINE. Nothing reviewed this branch.',\n '',\n ` ${input.suppressed.length} checklist(s) matched this diff and were SUPPRESSED — `\n + `${required.length} of them REQUIRED:`,\n ];\n for (const r of input.suppressed) {\n lines.push(` • ${r.id}${r.required ? ' (REQUIRED — suppressed anyway)' : ' (optional)'}`);\n }\n lines.push(\n '',\n ...(projectDisabled ? [\n ' Switched off by: commands.pr-gate.reviewerAgents: 0',\n ' Read from: webpieces.config.json (project policy; build and PR gates remain active)',\n ] : [\n ` Switched off by: experimental.${HOME_KEY_TURN_OFF_ALL_REVIEWERS}: true`,\n ` Read from: ~/${HOME_CONFIG_DIR}/${HOME_CONFIG_FILE} (machine-local; no repo config can set this)`,\n ]),\n '',\n ' There is NOTHING to spawn — no reviewer was briefed and no instructions file was written,',\n ' so any attempt to spawn one has nothing to read. Do NOT hand-write a verdict file in their',\n ' place: a fabricated verdict is worse than the absent one this flag deliberately produces.',\n '',\n ' The dashboard is the whole review product for this PR, and the suppression is carried into',\n ' the PR body — which is the squash-merge commit body — so main\\'s history records it.',\n projectDisabled\n ? ' To get reviewers back, set reviewerAgents to a positive integer and re-run this command.'\n : ' To get the reviewers back, set that key to false (or delete it) and re-run this command.',\n );\n return lines.join('\\n') + '\\n';\n }\n\n /**\n * `--no-optional`, stated as a VERDICT rather than left silent. Named individually, not just counted: the\n * whole reason the human is allowed to skip these is that they know this diff, and the only way they can\n * catch \"wait, not THAT one\" is to see which ones went unreviewed.\n */\n private skippedLines(input: ReviewReportInput): string[] {\n const skipped = this.optionalOwed(input);\n if (!input.skipOptional || skipped.length === 0) return [];\n return [\n '',\n ` ⏭️ ${skipped.length} OPTIONAL checklist(s) matched this diff and were SKIPPED (--no-optional):`,\n ...skipped.map((b: ReviewerBriefing): string => ` ${b.checklistId} — ${this.why(b)}`),\n ' Not blocking. Drop the flag and re-run this command to offer them after all.',\n ];\n }\n\n /**\n * The all-clear, then the RULE that makes it actionable.\n *\n * \"nothing to spawn\" on its own is a description of the current state, and an agent that has just been\n * told a state — rather than a rule — treats re-spawning as a judgement call it is entitled to make. It\n * then makes it, reasoning (correctly, on the facts) that the carried-forward verdicts judged an earlier\n * tree. Reviews here are once per branch BY CONSTRUCTION: a passing review-<id>.json satisfies its\n * checklist for the branch's whole life, and `wp-finish-upsert-pr` never archives one the way it archives\n * summary.json. So the reuse is deliberate — it is what keeps post-PR iteration from re-paying for every\n * matched reviewer — and the output has to say so, because the alternative reading is the expensive one.\n *\n * The overwrite warning is not decoration. A re-spawned reviewer writes to the SAME verdict path, so a\n * gratuitous re-run does not merely cost a subagent — it destroys the verdict that was already banked.\n *\n * It must NOT claim everything was reviewed when optional reviews were skipped — that is the one sentence\n * that would turn a deliberate skip into a false record of a review that happened.\n */\n private allClear(input: ReviewReportInput): string {\n const headline = input.skipOptional && this.optionalOwed(input).length > 0\n ? '✅ Nothing left to spawn — every REQUIRED checklist is reviewed (optional ones skipped above).'\n : '✅ Every checklist that applies is already reviewed — nothing to spawn.';\n return headline + '\\n' + this.oncePerBranchRule();\n }\n\n /**\n * The once-per-branch rule, stated as a prohibition rather than left to be inferred from a ✅.\n *\n * Printed whenever verdicts are being reused — which is every iteration of a PR after the first, i.e. the\n * majority of stage-② runs on any branch that gets review feedback.\n */\n private oncePerBranchRule(): string {\n return (\n ' A passing verdict CARRIES FORWARD for as long as its checklist\\'s in-scope files are unchanged,\\n' +\n ' deliberately, so edits elsewhere cost no reviewer tokens. When those files DO change, this\\n' +\n ' stage re-briefs that checklist itself and names it in a STEP below. Do NOT re-spawn a reviewer\\n' +\n ' listed above to \"re-check\" — it burns a full subagent run AND replaces the verdict it already\\n' +\n ' submitted. The only reviewers you may spawn are ones a STEP below names.'\n );\n }\n\n /**\n * The ONE instruction block, and the last thing the stage prints. Numbered rather than prose-linked\n * (\"Then… Finally…\") so that skipping step 1 is visibly skipping a step, and worded so no earlier line\n * can be mistaken for the real next action.\n *\n * summary.json is STEP 1 and the spawn blocks are STEP 2 — that ORDER is the contract, not a preference.\n * This block used to print the spawn blocks first and then say to write summary.json \"WHILE any reviewer\n * subagents above are still running\", which does not merely permit spawning first, it instructs it.\n * Harmless for a reviewer that only reads the diff; wrong for one that judges the PR's stated INTENT —\n * its title, summary or risk level — because summary.json is the only place that intent lives. Such a\n * reviewer either finds no file (a false RED and a wasted reviewer run) or, on a second run of this\n * stage on the same branch, finds the PREVIOUS run's file and validates a title that no longer exists —\n * a false GREEN, with nothing in the output saying which of the two happened. A consuming repo had to\n * write itself a rule telling its agents to DISOBEY this block to work around it.\n *\n * What the old ordering bought was overlap on a single local file write, not a subagent round-trip.\n *\n * The schema hint is rendered by ReviewJsonService — the single renderer — so the shape printed here\n * can never drift from the shape `wp-finish-upsert-pr` validates.\n */\n private nextSteps(input: ReviewReportInput): string {\n if (input.roundAction === ROUND_ACTION_FIX) return this.fixStep(input);\n if (input.roundAction === ROUND_ACTION_RECORD) return this.recordStep(input);\n if (input.roundAction === ROUND_ACTION_FINISH) return this.cappedFinishStep(input);\n const required = this.requiredOwed(input);\n const offerable = this.offerableOwed(input);\n // Numbered by what is actually PRINTED, so the numbers a reader sees are 1..n with no gaps: write\n // summary.json, then a spawn step only if anything must run, then an offer step only if anything may.\n let step = 1;\n const write = this.writeSummaryStep(input.summaryPath, step++, '');\n // The wait block goes under the LAST reviewer-listing step, and only there. Printed under both\n // it would be two \"what to do next\" instructions in one output, which is the defect this\n // method's docstring describes — an agent reading top to bottom obeys the first one it meets.\n const spawn = required.length === 0 ? '' : this.spawnStep(input, required, step++, offerable.length === 0);\n const offer = offerable.length === 0 ? '' : this.offerStep(input, offerable, step++, true);\n return '\\n' + SEP\n + `▶ NEXT — ${step} steps, in this order. Step 1 is NOT optional:\\n` + SEP + '\\n'\n + write + spawn + offer + this.finishStep(step, required.length + offerable.length > 0);\n }\n\n private writeSummaryStep(summaryPath: string, step: number, mainAgentInstructions: string): string {\n return (\n `STEP ${step} — write the PR summary (title, summary, risk) to summary.json. Write it FIRST — BEFORE you spawn\\n` +\n ' anything below. finish REFUSES without it, and a reviewer subagent may READ it: a\\n' +\n ' checklist that judges the PR title, summary or risk level reads exactly this file, so\\n' +\n ' writing it afterwards races that reviewer into seeing nothing — or, on a re-run of this\\n' +\n ' stage, into judging the PREVIOUS run\\'s summary of code that has since changed.\\n\\n' +\n summaryJsonSchemaHint(summaryPath, mainAgentInstructions) + '\\n\\n'\n );\n }\n\n private fixStep(input: ReviewReportInput): string {\n return '\\n' + SEP + `▶ NEXT — fix every finding from round ${input.round} of ${input.maxReviewerRounds}\\n` + SEP + '\\n'\n + ` Red checklist(s): ${input.redChecklistIds.join(', ')}\\n`\n + ' Commit every fix and leave the tree clean, then record one response per checklist with:\\n'\n + ' pnpm wp-write-review-fixes\\n'\n + ' Re-run pnpm wp-review-upsert-pr after that. It will start a focused remediation-only round\\n'\n + ' only when the configured round budget still has room.\\n';\n }\n\n private recordStep(input: ReviewReportInput): string {\n return '\\n' + SEP + `▶ NEXT — record the committed fixes for round ${input.round} of ${input.maxReviewerRounds}\\n` + SEP + '\\n'\n + ' pnpm wp-write-review-fixes\\n\\n'\n + ' The command stamps the reviewed HEAD and current clean HEAD itself. Then re-run\\n'\n + ' pnpm wp-review-upsert-pr; do not edit or recolor the reviewer verdict.\\n';\n }\n\n private cappedFinishStep(input: ReviewReportInput): string {\n const capped = input.redChecklistIds.length > 0\n ? ` Review cap reached. ${input.redChecklistIds.join(', ')} is author-remediated after the cap and was NOT re-reviewed.\\n`\n : '';\n return '\\n' + SEP + '▶ NEXT — write summary.json, then finish\\n' + SEP + '\\n'\n + capped + this.writeSummaryStep(input.summaryPath, 1, '')\n + 'STEP 2 — run: pnpm wp-finish-upsert-pr\\n';\n }\n\n /**\n * The REQUIRED reviewers — one copy-paste block each, and nothing at all when none is owed. The prompt is\n * deliberately a POINTER and nothing else: the generated instructions file is the contract, so anything\n * restated here is a second copy that can go stale — which is exactly how a removed `success` field\n * outlived its own removal in print.\n *\n * These are spawned WITHOUT asking. They are the checklists the repo declared `required: true`, which is\n * the repo saying the decision was already made; putting them to the human again would re-open a question\n * the config exists to settle.\n */\n private spawnStep(input: ReviewReportInput, owed: readonly ReviewerBriefing[], step: number, withAwait: boolean): string {\n const lines: string[] = [\n `STEP ${step} — only once that file is written, review these ${owed.length} REQUIRED checklist(s) with`,\n ...this.howManyAgents(input, owed.length),\n ' They block the PR, so do NOT ask whether to run them. You may NOT review your own',\n ' work, and you may NOT submit a reviewer\\'s verdict on its behalf: pnpm wp-write-review',\n ' refuses the coordinating agent, and finish rejects a verdict file written by hand.',\n '',\n ];\n lines.push(...this.refusedWarning(input, owed));\n for (const b of owed) lines.push(...this.oneSpawnBlock(input, b));\n if (withAwait) lines.push(...this.awaitLines());\n lines.push('');\n return lines.join('\\n');\n }\n\n /**\n * How to WAIT once the spawn list has been spawned — printed after the blocks, because it is the\n * next thing to do and nothing before it can be mistaken for it.\n *\n * It is here because the alternative is measured and expensive: `echo .` every three seconds at\n * ~557,000 tokens a turn, 18.3% of every token the fleet spent in the 24h to 2026-09-07 (#874).\n *\n * It names the efficient options and the wasteful one, and then stops (#902). It does NOT prescribe\n * ending the turn: waiting on the subagents you just spawned is something an agent already does\n * routinely, and whether to do that here is a judgement this string cannot make for it.\n *\n * It names no other stage. `finishStep` below is the ONE place this whole block names\n * `wp-finish-upsert-pr`, and a second mention here would be a second \"what to do next\" instruction\n * for an agent reading top to bottom — the exact defect the class docstring above describes.\n */\n private awaitLines(): string[] {\n return [\n ' Then WAIT. Be efficient with tokens: wait on the subagents you just spawned, or block',\n ' in one call with the command below. Do NOT send status checks every few seconds, and',\n ' do NOT run `echo` to keep your turn alive — a turn costs your whole context, ~557k',\n ' tokens.',\n '',\n ' pnpm wp-await-reviews',\n '',\n ' It heartbeats while it waits, returns as soon as the last verdict lands, and prints',\n ' what each reviewer said. If the wait is long it exits asking to be run again.',\n ];\n }\n\n /**\n * STEP n — the OPTIONAL reviewers: listed, never spawned unasked.\n *\n * This is the whole point of `required: false`. A one-line bug fix in a repo whose checklists key on a\n * glob as broad as every TypeScript file otherwise pays for a dozen subagent reviews, and the only party\n * who can judge whether this particular diff is worth them is the human looking at it.\n *\n * ONE batched multi-select question, explicitly. Asked one at a time, a human answering \"no\" nine times\n * is being worn down rather than consulted, and by the third question the cheap thing is to say yes to\n * everything — which is the state this feature exists to leave. The \"None\" option has to be spelled out\n * too: an agent that offers a list without an explicit way to decline it has not really offered a choice.\n *\n * The blocking consequence is stated because it is the one non-obvious part of the contract: `required`\n * governs whether a reviewer must RUN, not whether its answer counts. Choosing to run one and then\n * shrugging off a red verdict would make the whole exercise theater.\n */\n private offerStep(input: ReviewReportInput, offerable: readonly ReviewerBriefing[], step: number, withAwait: boolean): string {\n const lines: string[] = [\n `STEP ${step} — these ${offerable.length} OPTIONAL review checklist(s) matched this diff. They do NOT block the`,\n ' PR, and you may NOT decide for the human whether to run them.',\n '',\n ' ASK THE HUMAN, in ONE multi-select question listing all of them plus an explicit',\n ' \"None — required only\" choice. Do not ask one question per reviewer. Then spawn ONLY',\n ' what they picked, the same way as any other reviewer.',\n '',\n ' If they pick none, that is a complete answer: go straight to the final step. If they',\n ' told you up front to submit without reviews, re-run this stage as',\n ' `pnpm wp-review-upsert-pr --no-optional` and this step disappears.',\n '',\n ' NOTE: whichever ones you DO run, their verdicts count in full — a red verdict from an',\n ' optional reviewer blocks the PR exactly like a required one.',\n '',\n ];\n lines.push(...this.optionalAgentLines(input, offerable.length));\n lines.push(...this.refusedWarning(input, offerable));\n for (const b of offerable) lines.push(...this.oneSpawnBlock(input, b));\n if (withAwait) lines.push(...this.awaitLines());\n lines.push('');\n return lines.join('\\n');\n }\n\n // How the picked optional checklists are staffed. Grouped, the cap covers the WHOLE round, required\n // reviewers included — otherwise \"at most N\" would quietly become 2N the moment a human said yes.\n private optionalAgentLines(input: ReviewReportInput, count: number): string[] {\n const reviewer = input.reviewer;\n const required = this.requiredOwed(input).length;\n // The Codex pointer is printed once per report: by the required step when there is one.\n const codex = required > 0 ? [] : [this.agentDefinitionLine(input)];\n const scope = required > 0 ? `, COUNTING the ${required} required checklist(s) above — fold picked ones into those subagents` : '';\n return [\n ` Review what they picked with \\`${reviewer.agentName}\\` subagents: at most ${reviewer.maxAgents} IN TOTAL`,\n ` this round${scope}. Hand each subagent the instructions file of every checklist it covers.`,\n ...codex,\n ...(count > 0 ? [''] : []),\n ];\n }\n\n // Said up front, not only beside the block: an agent that has decided to spawn everything listed here\n // needs to know BEFORE it starts that one of these entries is not a spawn-shaped task. Scoped to the\n // group being printed — a refusal among the REQUIRED reviewers is not a caveat on the optional list.\n private refusedWarning(input: ReviewReportInput, group: readonly ReviewerBriefing[]): string[] {\n const ids = new Set(group.map((b: ReviewerBriefing): string => b.checklistId));\n const n = input.refused.filter((r: RefusedReviewer): boolean => ids.has(r.checklistId)).length;\n if (n === 0) return [];\n return [\n ` ${n} of them already ANSWERED and refused (marked ⛔ below). Do not spawn`,\n ' those against unchanged code — fix what they found first; the fix is the prerequisite.',\n '',\n ];\n }\n\n private finishStep(stepNumber: number, anyReviewers: boolean): string {\n // \"every reviewer you ran\" rather than \"every reviewer above\": with an optional list the human may\n // legitimately have run none of them, and a precondition naming reviewers that were declined reads as\n // an unmeetable one.\n const precondition = anyReviewers\n ? 'once every reviewer you ran has submitted its verdict'\n : 'once that file exists';\n return (\n `STEP ${stepNumber} — only ${precondition}, run: pnpm wp-finish-upsert-pr\\n` +\n ' (The build gate is already green for this commit — finish reuses it unless HEAD moves.)\\n\\n'\n );\n }\n\n // The briefings with no passing verdict yet — the ONE definition of \"owed\", shared by the header, the\n // scan verdict and the step numbering, so they cannot disagree about whether there is anything to spawn.\n private owedReviewers(input: ReviewReportInput): ReviewerBriefing[] {\n const reviewedIds = new Set(input.reviewed.map((r: RequiredChecklist): string => r.id));\n return input.briefings.filter((b: ReviewerBriefing): boolean => !reviewedIds.has(b.checklistId));\n }\n\n // Owed AND blocking — spawned without asking.\n private requiredOwed(input: ReviewReportInput): ReviewerBriefing[] {\n return this.owedReviewers(input).filter((b: ReviewerBriefing): boolean => b.required);\n }\n\n // Owed and optional. Still listed under `--no-optional` (as a skip verdict), just never as a step.\n private optionalOwed(input: ReviewReportInput): ReviewerBriefing[] {\n return this.owedReviewers(input).filter((b: ReviewerBriefing): boolean => !b.required);\n }\n\n // The optional ones the human is actually to be ASKED about — none, once they have already answered.\n private offerableOwed(input: ReviewReportInput): ReviewerBriefing[] {\n return input.skipOptional ? [] : this.optionalOwed(input);\n }\n\n // Everything the AI still has to act on. Distinct from `owedReviewers`: a skipped optional checklist is\n // owed a verdict it will never get, and treating it as pending work is what would print a spawn\n // instruction for a review the human just declined.\n private actionableOwed(input: ReviewReportInput): ReviewerBriefing[] {\n return [...this.requiredOwed(input), ...this.offerableOwed(input)];\n }\n\n /**\n * One reviewer's block. A reviewer that already REFUSED gets the SAME spawn coordinates but a different\n * lead-in, because the action before spawning is different: its own words are printed, and the spawn is\n * explicitly conditioned on having fixed the finding first.\n *\n * It keeps its spawn block rather than being dropped from the list, because the reviewer genuinely does\n * still owe a fresh verdict — dropping it would leave nothing anywhere saying how to get one. What must\n * not happen is a bare \"spawn this\" that reads identically to a reviewer that never ran, which is the\n * loop this exists to break.\n */\n private oneSpawnBlock(input: ReviewReportInput, b: ReviewerBriefing): string[] {\n const instructionsFile = this.reviewerInstructions.pathFor(input.repoRoot, input.featureName, b.checklistId);\n // The subagent_type is stated once, above; each block is one checklist's file to hand to\n // whichever subagent covers it.\n return [...this.leadIn(input, b), ` instructions: ${instructionsFile}`, ''];\n }\n\n /**\n * HOW MANY subagents, of WHICH type — the one place this report states it, shared by the required and\n * the optional step so the two cannot disagree.\n *\n * Positive `commands.pr-gate.reviewerAgents` values give the main AI a CAP and the\n * grouping decision: the point of the key is to stop paying for N agents re-reading the same diff, and\n * the AI is the one that can see which checklists belong together. The cap is per ROUND, so a re-run\n * after a red verdict re-reviews only the owed checklists — the only ones listed — under the same cap.\n */\n private howManyAgents(input: ReviewReportInput, count: number): string[] {\n const reviewer = input.reviewer;\n const cap = Math.min(reviewer.maxAgents, count);\n return [\n ` AT MOST ${cap} subagent(s) of type \\`${reviewer.agentName}\\` (commands.pr-gate.reviewerAgents = ${reviewer.maxAgents}).`,\n ` ${this.checklistInstructions.groupingHint(count, cap)}`,\n ' Spawn each one as:',\n ` subagent_type: ${reviewer.agentName}`,\n ' prompt: Read EACH instructions file below FIRST and follow it exactly. Review each',\n ' checklist only over its own in-scope files and submit ONE verdict per',\n ' checklist with pnpm wp-write-review — never one for a checklist you were',\n ' not given.',\n ' <then list the instructions file of every checklist this subagent covers>',\n ' Every checklist below must be covered by exactly one of those subagents.',\n this.agentDefinitionLine(input),\n ];\n }\n\n /**\n * The ONE canonical reviewer definition, named for a harness that cannot spawn it by type. Codex has no\n * registered agent types, so its subagent is generic; pointing it at the same committed file keeps one\n * definition for both harnesses instead of a Codex-specific copy that drifts (#863).\n */\n private agentDefinitionLine(input: ReviewReportInput): string {\n const file = path.join(input.repoRoot, '.claude', 'agents', `${input.reviewer.agentName}.md`);\n return ` Codex (no agent types): spawn a generic subagent with NO forked turns (fresh context — do not\\n`\n + ` fork this conversation into it) and hand it ONLY the instructions files below; it reads\\n`\n + ` ${file} first. The brief on disk is its whole input: a forked conversation hands a\\n`\n + ` reviewer the author's reasoning, which costs tokens and its independence.`;\n }\n\n // The lines above the spawn coordinates: normally just why this reviewer is in scope; for one that\n // already refused, its verdict verbatim plus the order the two actions must happen in.\n private leadIn(input: ReviewReportInput, b: ReviewerBriefing): string[] {\n const refusal = input.refused.find((r: RefusedReviewer): boolean => r.checklistId === b.checklistId);\n if (!refusal) return [` ▶ ${b.checklistId} — ${this.why(b)}`, ...this.docLine(b)];\n return [\n ` ⛔ ${b.checklistId} — ALREADY REVIEWED THIS BRANCH AND REFUSED. It will refuse again on unchanged code.`,\n ` ${refusal.message}`,\n ' FIX THE FINDING FIRST (or record a human-authored override). ONLY THEN spawn it again, to',\n ' write a fresh verdict:',\n ];\n }\n\n /**\n * The checklist's guidance doc, for OPTIONAL reviewers only.\n *\n * \"4 file(s) matched\" plus a broad glob does not tell a human what the review would actually look AT,\n * and they are being asked to decide exactly that. Omitted for required reviewers: there is no decision\n * to inform there — the reviewer runs either way, and the doc is already in its instructions file.\n */\n private docLine(b: ReviewerBriefing): string[] {\n if (b.required || b.docPath === '') return [];\n return [` reviews against: ${b.docPath}`];\n }\n\n // Why this one is in scope. A patternless checklist is NOT \"matched\" — it always runs, over the whole\n // diff, and saying so is what tells a repo its checklist is firing on docs-only PRs by design.\n private why(b: ReviewerBriefing): string {\n if (b.matchedPatterns.length === 0) {\n return `ALWAYS RUNS (no \"patterns\" configured), whole diff in scope — ${b.myFiles.length} file(s)`;\n }\n return `${b.myFiles.length} file(s) matched ${b.matchedPatterns.map((p: string): string => `\"${p}\"`).join(', ')}`;\n }\n}\n"]}
@@ -40,6 +40,20 @@ export declare class ReviewRoundStateService {
40
40
  roundDir(summaryPath: string, round: number): string;
41
41
  archiveVerdict(summaryPath: string, checklistId: string, round: number): void;
42
42
  roundComplete(summaryPath: string, receipt: ReviewStageReceipt): boolean;
43
+ /**
44
+ * TRUE once the repository's reviewer-round budget is SPENT: the latest global round is complete and it
45
+ * was the last one `maxReviewerRounds` allows. From then on {@link plan} never briefs a reviewer again,
46
+ * so nothing downstream may demand one either (issue #1051) — with `maxReviewerRounds: 1` that is what
47
+ * "review → fix → submit" means. The scan uses it to CARRY every non-red verdict forward instead of
48
+ * marking it STALE, whatever changes afterwards (remediation commits, summary edits, gate re-runs).
49
+ */
50
+ capSpent(summaryPath: string, receipt: ReviewStageReceipt | null, maxRounds: number): boolean;
51
+ /**
52
+ * How many times ONE checklist has been reviewed on this branch: the global rounds 1..`throughRound` whose
53
+ * immutable snapshot holds a verdict for it (`wp-write-review` archives every submission there). A
54
+ * re-submission inside one round overwrites that round's snapshot, so it is one review, not two.
55
+ */
56
+ reviewCount(summaryPath: string, checklistId: string, throughRound: number): number;
43
57
  redChecklistIds(summaryPath: string, receipt: ReviewStageReceipt): string[];
44
58
  remediationPath(summaryPath: string, round: number): string;
45
59
  plan(repoRoot: string, summaryPath: string, receipt: ReviewStageReceipt | null, maxRounds: number, fullBasis: DiffBasis): ReviewRoundPlan;
@@ -83,6 +83,29 @@ let ReviewRoundStateService = class ReviewRoundStateService {
83
83
  return false;
84
84
  return receipt.reviewersBriefed.every((id) => fs.existsSync(path.join(this.roundDir(summaryPath, receipt.round), `review-${id}.json`)));
85
85
  }
86
+ /**
87
+ * TRUE once the repository's reviewer-round budget is SPENT: the latest global round is complete and it
88
+ * was the last one `maxReviewerRounds` allows. From then on {@link plan} never briefs a reviewer again,
89
+ * so nothing downstream may demand one either (issue #1051) — with `maxReviewerRounds: 1` that is what
90
+ * "review → fix → submit" means. The scan uses it to CARRY every non-red verdict forward instead of
91
+ * marking it STALE, whatever changes afterwards (remediation commits, summary edits, gate re-runs).
92
+ */
93
+ capSpent(summaryPath, receipt, maxRounds) {
94
+ return receipt !== null && receipt.round >= maxRounds && this.roundComplete(summaryPath, receipt);
95
+ }
96
+ /**
97
+ * How many times ONE checklist has been reviewed on this branch: the global rounds 1..`throughRound` whose
98
+ * immutable snapshot holds a verdict for it (`wp-write-review` archives every submission there). A
99
+ * re-submission inside one round overwrites that round's snapshot, so it is one review, not two.
100
+ */
101
+ reviewCount(summaryPath, checklistId, throughRound) {
102
+ let count = 0;
103
+ for (let round = 1; round <= throughRound; round++) {
104
+ if (fs.existsSync(path.join(this.roundDir(summaryPath, round), `review-${checklistId}.json`)))
105
+ count++;
106
+ }
107
+ return count;
108
+ }
86
109
  redChecklistIds(summaryPath, receipt) {
87
110
  if (!this.roundComplete(summaryPath, receipt))
88
111
  return [];
@@ -168,7 +191,7 @@ let ReviewRoundStateService = class ReviewRoundStateService {
168
191
  }
169
192
  capRemediations(repoRoot, summaryPath, receipt, maxRounds) {
170
193
  const out = {};
171
- if (receipt === null || receipt.round < maxRounds)
194
+ if (receipt === null || !this.capSpent(summaryPath, receipt, maxRounds))
172
195
  return out;
173
196
  const remediation = this.validRemediation(repoRoot, summaryPath, receipt);
174
197
  if (remediation === null)
@@ -1 +1 @@
1
- {"version":3,"file":"review-round-state.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/p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AI,MAAM,CAAC,KAAK,EAAE,OAAO,IAAI,QAAQ,MAAM,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;QAC7G,MAAM,OAAO,GAAG,oCAAoC,OAAO,KAAK,MAAM,EAAE,CAAC;QACzE,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS;YAAE,MAAM,IAAI,4BAAa,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;QAC1F,MAAM,IAAI,4BAAa,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;CACJ,CAAA;AAlOY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGJ,gCAAiB;QACjB,6CAAwB;QACxB,yBAAU;GAJlC,uBAAuB,CAkOnC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { spawnSync } from 'child_process';\nimport { AtomicFile, InformAiError, ReviewJsonService, VERDICT_RED, toError } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { ReviewStageReceipt } from './review-stage-receipt';\nimport { VerdictProvenanceService } from './verdict-provenance';\nimport { DiffBasis } from './diff-basis';\n\ntype JsonPrimitive = string | number | boolean | null;\ntype JsonValue = JsonPrimitive | JsonValue[] | JsonObject;\ninterface JsonObject { [key: string]: JsonValue }\n\nexport const ROUND_ACTION_REVIEW = 'review';\nexport const ROUND_ACTION_RESUME = 'resume';\nexport const ROUND_ACTION_FIX = 'fix';\nexport const ROUND_ACTION_RECORD = 'record';\nexport const ROUND_ACTION_FINISH = 'finish';\n\nexport class ReviewRoundPlan {\n action: string;\n round: number;\n maxRounds: number;\n basis: DiffBasis;\n changedFiles: string[];\n redChecklistIds: string[];\n\n constructor(action: string, round: number, maxRounds: number, basis: DiffBasis, changedFiles: string[] = [], redChecklistIds: string[] = []) {\n this.action = action;\n this.round = round;\n this.maxRounds = maxRounds;\n this.basis = basis;\n this.changedFiles = changedFiles;\n this.redChecklistIds = redChecklistIds;\n }\n}\n\nexport class RemediationResponse {\n checklistId: string;\n resolution: string;\n files: string[];\n\n constructor(checklistId: string, resolution: string, files: string[]) {\n this.checklistId = checklistId;\n this.resolution = resolution;\n this.files = files;\n }\n}\n\nexport class ReviewRemediation {\n agent: string;\n model: string;\n fromHead: string;\n toHead: string;\n responses: RemediationResponse[];\n writtenAt: string;\n\n constructor(agent: string, model: string, fromHead: string, toHead: string, responses: RemediationResponse[]) {\n this.agent = agent;\n this.model = model;\n this.fromHead = fromHead;\n this.toHead = toHead;\n this.responses = responses;\n this.writtenAt = new Date().toISOString();\n }\n}\n\n/** Immutable per-round verdict history plus the author-remediation records between rounds. */\n@injectable(bindingScopeValues.Singleton)\nexport class ReviewRoundStateService {\n constructor(\n private readonly reviewJson: ReviewJsonService,\n private readonly provenance: VerdictProvenanceService,\n private readonly atomicFile: AtomicFile,\n ) {}\n\n roundDir(summaryPath: string, round: number): string {\n return path.join(path.dirname(summaryPath), 'rounds', String(round));\n }\n\n archiveVerdict(summaryPath: string, checklistId: string, round: number): void {\n const dir = this.roundDir(summaryPath, round);\n fs.mkdirSync(dir, { recursive: true });\n fs.copyFileSync(this.reviewJson.checklistResultPath(summaryPath, checklistId), path.join(dir, `review-${checklistId}.json`));\n fs.copyFileSync(this.provenance.provenancePath(summaryPath, checklistId), path.join(dir, `review-${checklistId}.provenance.json`));\n }\n\n roundComplete(summaryPath: string, receipt: ReviewStageReceipt): boolean {\n if (receipt.round < 1 || receipt.reviewersBriefed.length === 0) return false;\n return receipt.reviewersBriefed.every((id: string): boolean =>\n fs.existsSync(path.join(this.roundDir(summaryPath, receipt.round), `review-${id}.json`)));\n }\n\n redChecklistIds(summaryPath: string, receipt: ReviewStageReceipt): string[] {\n if (!this.roundComplete(summaryPath, receipt)) return [];\n return receipt.reviewersBriefed.filter((id: string): boolean => {\n const raw = this.readObject(path.join(this.roundDir(summaryPath, receipt.round), `review-${id}.json`));\n return raw !== null && raw['status'] === VERDICT_RED;\n });\n }\n\n remediationPath(summaryPath: string, round: number): string {\n return path.join(this.roundDir(summaryPath, round), 'review-fixes.json');\n }\n\n plan(repoRoot: string, summaryPath: string, receipt: ReviewStageReceipt | null, maxRounds: number, fullBasis: DiffBasis): ReviewRoundPlan {\n if (receipt === null || receipt.round < 1) {\n return new ReviewRoundPlan(ROUND_ACTION_REVIEW, 1, maxRounds, fullBasis);\n }\n if (!this.roundComplete(summaryPath, receipt)) {\n if (receipt.headSha !== fullBasis.headSha) {\n throw new InformAiError(`Global reviewer round ${receipt.round} of ${maxRounds} is still active at `\n + `${receipt.headSha.slice(0, 8)}. Finish that fixed roster before changing the reviewed HEAD.`);\n }\n return new ReviewRoundPlan(ROUND_ACTION_RESUME, receipt.round, maxRounds, fullBasis);\n }\n const reds = this.redChecklistIds(summaryPath, receipt);\n if (reds.length === 0) return new ReviewRoundPlan(ROUND_ACTION_FINISH, receipt.round, maxRounds, fullBasis);\n if (receipt.headSha === fullBasis.headSha) {\n return new ReviewRoundPlan(ROUND_ACTION_FIX, receipt.round, maxRounds, fullBasis, [], reds);\n }\n const remediation = this.validRemediation(repoRoot, summaryPath, receipt);\n if (remediation === null) {\n return new ReviewRoundPlan(ROUND_ACTION_RECORD, receipt.round, maxRounds, fullBasis, [], reds);\n }\n if (receipt.round >= maxRounds) {\n return new ReviewRoundPlan(ROUND_ACTION_FINISH, receipt.round, maxRounds, fullBasis, [], reds);\n }\n const basis = new DiffBasis(\n receipt.headSha, fullBasis.headSha, false, [],\n `git diff ${receipt.headSha} ${fullBasis.headSha}`,\n `git diff ${receipt.headSha} ${fullBasis.headSha} -- <file>`, fullBasis.hashMainHead);\n const changed = this.git(repoRoot, ['diff', '--name-only', receipt.headSha, fullBasis.headSha])\n .split('\\n').filter((f: string): boolean => f.trim() !== '');\n return new ReviewRoundPlan(ROUND_ACTION_REVIEW, receipt.round + 1, maxRounds, basis, changed, reds);\n }\n\n writeRemediation(repoRoot: string, summaryPath: string, receipt: ReviewStageReceipt, json: string): string {\n if (!this.roundComplete(summaryPath, receipt)) {\n throw new InformAiError('wp-write-review-fixes: the active reviewer round is not complete yet.');\n }\n this.assertClean(repoRoot);\n const currentHead = this.git(repoRoot, ['rev-parse', 'HEAD']);\n const reds = this.redChecklistIds(summaryPath, receipt);\n if (reds.length === 0) throw new InformAiError('wp-write-review-fixes: the completed round has no red verdict to remediate.');\n if (currentHead === receipt.headSha || this.git(repoRoot, ['diff', '--name-only', receipt.headSha, currentHead]) === '') {\n throw new InformAiError('wp-write-review-fixes: remediation must contain a committed, non-empty delta after the reviewed HEAD.');\n }\n const raw = this.parseObject(json, 'wp-write-review-fixes: input must be one JSON object.');\n const agent = this.requiredText(raw, 'agent');\n const model = this.requiredText(raw, 'model');\n const responses = this.responses(raw['responses']);\n const ids = responses.map((r: RemediationResponse): string => r.checklistId);\n const unknown = ids.filter((id: string): boolean => !reds.includes(id));\n const missing = reds.filter((id: string): boolean => !ids.includes(id));\n if (unknown.length > 0 || missing.length > 0) {\n throw new InformAiError(`wp-write-review-fixes: responses must cover exactly the red checklist(s). `\n + `Unknown: ${unknown.join(', ') || '(none)'}. Missing: ${missing.join(', ') || '(none)'}.`);\n }\n const record = new ReviewRemediation(agent, model, receipt.headSha, currentHead, responses);\n const out = this.remediationPath(summaryPath, receipt.round);\n this.atomicFile.writeJsonAtomic(out, record);\n return out;\n }\n\n validRemediation(repoRoot: string, summaryPath: string, receipt: ReviewStageReceipt): ReviewRemediation | null {\n const raw = this.readObject(this.remediationPath(summaryPath, receipt.round));\n if (raw === null) return null;\n const currentHead = this.git(repoRoot, ['rev-parse', 'HEAD']);\n const responses = this.responsesOrEmpty(raw['responses']);\n const reds = this.redChecklistIds(summaryPath, receipt);\n const ids = responses.map((r: RemediationResponse): string => r.checklistId);\n if (this.text(raw['agent']) === '' || this.text(raw['model']) === ''\n || raw['fromHead'] !== receipt.headSha || raw['toHead'] !== currentHead\n || currentHead === receipt.headSha || reds.some((id: string): boolean => !ids.includes(id))\n || ids.some((id: string): boolean => !reds.includes(id))) return null;\n return new ReviewRemediation(this.text(raw['agent']), this.text(raw['model']), receipt.headSha, currentHead, responses);\n }\n\n capRemediations(repoRoot: string, summaryPath: string, receipt: ReviewStageReceipt | null, maxRounds: number): Record<string, string> {\n const out: Record<string, string> = {};\n if (receipt === null || receipt.round < maxRounds) return out;\n const remediation = this.validRemediation(repoRoot, summaryPath, receipt);\n if (remediation === null) return out;\n for (const response of remediation.responses) {\n out[response.checklistId] = `Author-remediated after review cap; NOT re-reviewed. ${response.resolution} `\n + `(${remediation.fromHead.slice(0, 8)}..${remediation.toHead.slice(0, 8)})`;\n }\n return out;\n }\n\n auditTrail(summaryPath: string, checklistId: string, receipt: ReviewStageReceipt | null): string {\n if (receipt === null || receipt.round < 1) return '';\n const lines: string[] = [];\n for (let round = 1; round <= receipt.round; round++) {\n const dir = this.roundDir(summaryPath, round);\n const verdict = this.readObject(path.join(dir, `review-${checklistId}.json`));\n const record = this.readObject(path.join(dir, `review-${checklistId}.provenance.json`));\n if (verdict !== null) {\n lines.push(`#### Reviewer round ${round} of ${receipt.maxReviewerRounds}`);\n lines.push(`Reviewed SHA: ${this.text(record?.['headSha']) || '(unknown)'}`);\n lines.push(`Status: ${this.text(verdict['status']).toUpperCase()}`);\n lines.push('', this.text(verdict['output']), '');\n }\n const remediation = this.readObject(this.remediationPath(summaryPath, round));\n if (remediation !== null && Array.isArray(remediation['responses'])) {\n const response = (remediation['responses'] as JsonValue[]).find((entry: JsonValue): boolean =>\n typeof entry === 'object' && entry !== null && !Array.isArray(entry)\n && (entry as JsonObject)['checklistId'] === checklistId);\n if (typeof response === 'object' && response !== null && !Array.isArray(response)) {\n const raw = response as JsonObject;\n lines.push(`#### Author remediation after round ${round}`);\n lines.push(`Range: ${this.text(remediation['fromHead'])}..${this.text(remediation['toHead'])}`);\n lines.push('', this.text(raw['resolution']), '');\n }\n }\n }\n return lines.join('\\n').trim();\n }\n\n private responses(value: JsonValue | undefined): RemediationResponse[] {\n const responses = this.responsesOrEmpty(value);\n if (responses.length === 0) throw new InformAiError('wp-write-review-fixes: \"responses\" must be a non-empty array.');\n return responses;\n }\n\n private responsesOrEmpty(value: JsonValue | undefined): RemediationResponse[] {\n if (!Array.isArray(value)) return [];\n const out: RemediationResponse[] = [];\n for (const entry of value) {\n if (typeof entry !== 'object' || entry === null || Array.isArray(entry)) return [];\n const raw = entry as JsonObject;\n const id = this.text(raw['checklistId']);\n const resolution = this.text(raw['resolution']);\n const files = Array.isArray(raw['files']) ? raw['files'].filter((f: JsonValue): f is string => typeof f === 'string' && f.trim() !== '') : [];\n if (id === '' || resolution === '' || files.length === 0) return [];\n out.push(new RemediationResponse(id, resolution, files));\n }\n return out;\n }\n\n private requiredText(raw: JsonObject, key: string): string {\n const value = this.text(raw[key]);\n if (value === '') throw new InformAiError(`wp-write-review-fixes: \"${key}\" must be a non-empty string.`);\n return value;\n }\n\n private text(value: JsonValue | undefined): string {\n return typeof value === 'string' ? value.trim() : '';\n }\n\n private parseObject(json: string, message: string): JsonObject {\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: malformed author JSON becomes an actionable refusal\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const value = JSON.parse(json) as JsonValue;\n if (typeof value === 'object' && value !== null && !Array.isArray(value)) return value;\n // webpieces-disable no-any-unknown -- the language types caught JavaScript values as unknown\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n }\n throw new InformAiError(message);\n }\n\n private readObject(file: string): JsonObject | null {\n if (!fs.existsSync(file)) return null;\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: unreadable durable state becomes an actionable refusal\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const value = JSON.parse(fs.readFileSync(file, 'utf8')) as JsonValue;\n if (typeof value === 'object' && value !== null && !Array.isArray(value)) return value;\n throw new InformAiError(`Review state file must contain one JSON object: ${file}`);\n // webpieces-disable no-any-unknown -- the language types caught JavaScript values as unknown\n } catch (err: unknown) {\n const error = toError(err);\n if (error instanceof InformAiError) throw error;\n throw new InformAiError(`Could not read review state file ${file}: ${error.message}`, { cause: error });\n }\n }\n\n private assertClean(repoRoot: string): void {\n const status = this.git(repoRoot, ['status', '--porcelain', '--untracked-files=all']);\n if (status !== '') throw new InformAiError('wp-write-review-fixes: commit every remediation and leave no staged, unstaged, or untracked files first.');\n }\n\n private git(repoRoot: string, args: string[]): string {\n const result = spawnSync('git', args, { cwd: repoRoot, encoding: 'utf8' });\n if (result.status === 0) return (result.stdout ?? '').trim();\n const command = `git ${args.join(' ')}`;\n const detail = (result.stderr ?? '').trim() || result.error?.message || `exit ${result.status ?? 'unknown'}`;\n const message = `Review-round Git command failed: ${command}\\n${detail}`;\n if (result.error !== undefined) throw new InformAiError(message, { cause: result.error });\n throw new InformAiError(message);\n }\n}\n"]}
1
+ {"version":3,"file":"review-round-state.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/review-round-state.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;AAC7B,iDAA0C;AAC1C,0DAA6G;AAC7G,yCAA2D;AAE3D,6DAAgE;AAChE,6CAAyC;AAM5B,QAAA,mBAAmB,GAAG,QAAQ,CAAC;AAC/B,QAAA,mBAAmB,GAAG,QAAQ,CAAC;AAC/B,QAAA,gBAAgB,GAAG,KAAK,CAAC;AACzB,QAAA,mBAAmB,GAAG,QAAQ,CAAC;AAC/B,QAAA,mBAAmB,GAAG,QAAQ,CAAC;AAE5C,MAAa,eAAe;IACxB,MAAM,CAAS;IACf,KAAK,CAAS;IACd,SAAS,CAAS;IAClB,KAAK,CAAY;IACjB,YAAY,CAAW;IACvB,eAAe,CAAW;IAE1B,YAAY,MAAc,EAAE,KAAa,EAAE,SAAiB,EAAE,KAAgB,EAAE,eAAyB,EAAE,EAAE,kBAA4B,EAAE;QACvI,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK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I,MAAM,CAAC,KAAK,EAAE,OAAO,IAAI,QAAQ,MAAM,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;QAC7G,MAAM,OAAO,GAAG,oCAAoC,OAAO,KAAK,MAAM,EAAE,CAAC;QACzE,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS;YAAE,MAAM,IAAI,4BAAa,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;QAC1F,MAAM,IAAI,4BAAa,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;CACJ,CAAA;AA1PY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGJ,gCAAiB;QACjB,6CAAwB;QACxB,yBAAU;GAJlC,uBAAuB,CA0PnC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { spawnSync } from 'child_process';\nimport { AtomicFile, InformAiError, ReviewJsonService, VERDICT_RED, toError } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { ReviewStageReceipt } from './review-stage-receipt';\nimport { VerdictProvenanceService } from './verdict-provenance';\nimport { DiffBasis } from './diff-basis';\n\ntype JsonPrimitive = string | number | boolean | null;\ntype JsonValue = JsonPrimitive | JsonValue[] | JsonObject;\ninterface JsonObject { [key: string]: JsonValue }\n\nexport const ROUND_ACTION_REVIEW = 'review';\nexport const ROUND_ACTION_RESUME = 'resume';\nexport const ROUND_ACTION_FIX = 'fix';\nexport const ROUND_ACTION_RECORD = 'record';\nexport const ROUND_ACTION_FINISH = 'finish';\n\nexport class ReviewRoundPlan {\n action: string;\n round: number;\n maxRounds: number;\n basis: DiffBasis;\n changedFiles: string[];\n redChecklistIds: string[];\n\n constructor(action: string, round: number, maxRounds: number, basis: DiffBasis, changedFiles: string[] = [], redChecklistIds: string[] = []) {\n this.action = action;\n this.round = round;\n this.maxRounds = maxRounds;\n this.basis = basis;\n this.changedFiles = changedFiles;\n this.redChecklistIds = redChecklistIds;\n }\n}\n\nexport class RemediationResponse {\n checklistId: string;\n resolution: string;\n files: string[];\n\n constructor(checklistId: string, resolution: string, files: string[]) {\n this.checklistId = checklistId;\n this.resolution = resolution;\n this.files = files;\n }\n}\n\nexport class ReviewRemediation {\n agent: string;\n model: string;\n fromHead: string;\n toHead: string;\n responses: RemediationResponse[];\n writtenAt: string;\n\n constructor(agent: string, model: string, fromHead: string, toHead: string, responses: RemediationResponse[]) {\n this.agent = agent;\n this.model = model;\n this.fromHead = fromHead;\n this.toHead = toHead;\n this.responses = responses;\n this.writtenAt = new Date().toISOString();\n }\n}\n\n/** Immutable per-round verdict history plus the author-remediation records between rounds. */\n@injectable(bindingScopeValues.Singleton)\nexport class ReviewRoundStateService {\n constructor(\n private readonly reviewJson: ReviewJsonService,\n private readonly provenance: VerdictProvenanceService,\n private readonly atomicFile: AtomicFile,\n ) {}\n\n roundDir(summaryPath: string, round: number): string {\n return path.join(path.dirname(summaryPath), 'rounds', String(round));\n }\n\n archiveVerdict(summaryPath: string, checklistId: string, round: number): void {\n const dir = this.roundDir(summaryPath, round);\n fs.mkdirSync(dir, { recursive: true });\n fs.copyFileSync(this.reviewJson.checklistResultPath(summaryPath, checklistId), path.join(dir, `review-${checklistId}.json`));\n fs.copyFileSync(this.provenance.provenancePath(summaryPath, checklistId), path.join(dir, `review-${checklistId}.provenance.json`));\n }\n\n roundComplete(summaryPath: string, receipt: ReviewStageReceipt): boolean {\n if (receipt.round < 1 || receipt.reviewersBriefed.length === 0) return false;\n return receipt.reviewersBriefed.every((id: string): boolean =>\n fs.existsSync(path.join(this.roundDir(summaryPath, receipt.round), `review-${id}.json`)));\n }\n\n /**\n * TRUE once the repository's reviewer-round budget is SPENT: the latest global round is complete and it\n * was the last one `maxReviewerRounds` allows. From then on {@link plan} never briefs a reviewer again,\n * so nothing downstream may demand one either (issue #1051) — with `maxReviewerRounds: 1` that is what\n * \"review → fix → submit\" means. The scan uses it to CARRY every non-red verdict forward instead of\n * marking it STALE, whatever changes afterwards (remediation commits, summary edits, gate re-runs).\n */\n capSpent(summaryPath: string, receipt: ReviewStageReceipt | null, maxRounds: number): boolean {\n return receipt !== null && receipt.round >= maxRounds && this.roundComplete(summaryPath, receipt);\n }\n\n /**\n * How many times ONE checklist has been reviewed on this branch: the global rounds 1..`throughRound` whose\n * immutable snapshot holds a verdict for it (`wp-write-review` archives every submission there). A\n * re-submission inside one round overwrites that round's snapshot, so it is one review, not two.\n */\n reviewCount(summaryPath: string, checklistId: string, throughRound: number): number {\n let count = 0;\n for (let round = 1; round <= throughRound; round++) {\n if (fs.existsSync(path.join(this.roundDir(summaryPath, round), `review-${checklistId}.json`))) count++;\n }\n return count;\n }\n\n redChecklistIds(summaryPath: string, receipt: ReviewStageReceipt): string[] {\n if (!this.roundComplete(summaryPath, receipt)) return [];\n return receipt.reviewersBriefed.filter((id: string): boolean => {\n const raw = this.readObject(path.join(this.roundDir(summaryPath, receipt.round), `review-${id}.json`));\n return raw !== null && raw['status'] === VERDICT_RED;\n });\n }\n\n remediationPath(summaryPath: string, round: number): string {\n return path.join(this.roundDir(summaryPath, round), 'review-fixes.json');\n }\n\n plan(repoRoot: string, summaryPath: string, receipt: ReviewStageReceipt | null, maxRounds: number, fullBasis: DiffBasis): ReviewRoundPlan {\n if (receipt === null || receipt.round < 1) {\n return new ReviewRoundPlan(ROUND_ACTION_REVIEW, 1, maxRounds, fullBasis);\n }\n if (!this.roundComplete(summaryPath, receipt)) {\n if (receipt.headSha !== fullBasis.headSha) {\n throw new InformAiError(`Global reviewer round ${receipt.round} of ${maxRounds} is still active at `\n + `${receipt.headSha.slice(0, 8)}. Finish that fixed roster before changing the reviewed HEAD.`);\n }\n return new ReviewRoundPlan(ROUND_ACTION_RESUME, receipt.round, maxRounds, fullBasis);\n }\n const reds = this.redChecklistIds(summaryPath, receipt);\n if (reds.length === 0) return new ReviewRoundPlan(ROUND_ACTION_FINISH, receipt.round, maxRounds, fullBasis);\n if (receipt.headSha === fullBasis.headSha) {\n return new ReviewRoundPlan(ROUND_ACTION_FIX, receipt.round, maxRounds, fullBasis, [], reds);\n }\n const remediation = this.validRemediation(repoRoot, summaryPath, receipt);\n if (remediation === null) {\n return new ReviewRoundPlan(ROUND_ACTION_RECORD, receipt.round, maxRounds, fullBasis, [], reds);\n }\n if (receipt.round >= maxRounds) {\n return new ReviewRoundPlan(ROUND_ACTION_FINISH, receipt.round, maxRounds, fullBasis, [], reds);\n }\n const basis = new DiffBasis(\n receipt.headSha, fullBasis.headSha, false, [],\n `git diff ${receipt.headSha} ${fullBasis.headSha}`,\n `git diff ${receipt.headSha} ${fullBasis.headSha} -- <file>`, fullBasis.hashMainHead);\n const changed = this.git(repoRoot, ['diff', '--name-only', receipt.headSha, fullBasis.headSha])\n .split('\\n').filter((f: string): boolean => f.trim() !== '');\n return new ReviewRoundPlan(ROUND_ACTION_REVIEW, receipt.round + 1, maxRounds, basis, changed, reds);\n }\n\n writeRemediation(repoRoot: string, summaryPath: string, receipt: ReviewStageReceipt, json: string): string {\n if (!this.roundComplete(summaryPath, receipt)) {\n throw new InformAiError('wp-write-review-fixes: the active reviewer round is not complete yet.');\n }\n this.assertClean(repoRoot);\n const currentHead = this.git(repoRoot, ['rev-parse', 'HEAD']);\n const reds = this.redChecklistIds(summaryPath, receipt);\n if (reds.length === 0) throw new InformAiError('wp-write-review-fixes: the completed round has no red verdict to remediate.');\n if (currentHead === receipt.headSha || this.git(repoRoot, ['diff', '--name-only', receipt.headSha, currentHead]) === '') {\n throw new InformAiError('wp-write-review-fixes: remediation must contain a committed, non-empty delta after the reviewed HEAD.');\n }\n const raw = this.parseObject(json, 'wp-write-review-fixes: input must be one JSON object.');\n const agent = this.requiredText(raw, 'agent');\n const model = this.requiredText(raw, 'model');\n const responses = this.responses(raw['responses']);\n const ids = responses.map((r: RemediationResponse): string => r.checklistId);\n const unknown = ids.filter((id: string): boolean => !reds.includes(id));\n const missing = reds.filter((id: string): boolean => !ids.includes(id));\n if (unknown.length > 0 || missing.length > 0) {\n throw new InformAiError(`wp-write-review-fixes: responses must cover exactly the red checklist(s). `\n + `Unknown: ${unknown.join(', ') || '(none)'}. Missing: ${missing.join(', ') || '(none)'}.`);\n }\n const record = new ReviewRemediation(agent, model, receipt.headSha, currentHead, responses);\n const out = this.remediationPath(summaryPath, receipt.round);\n this.atomicFile.writeJsonAtomic(out, record);\n return out;\n }\n\n validRemediation(repoRoot: string, summaryPath: string, receipt: ReviewStageReceipt): ReviewRemediation | null {\n const raw = this.readObject(this.remediationPath(summaryPath, receipt.round));\n if (raw === null) return null;\n const currentHead = this.git(repoRoot, ['rev-parse', 'HEAD']);\n const responses = this.responsesOrEmpty(raw['responses']);\n const reds = this.redChecklistIds(summaryPath, receipt);\n const ids = responses.map((r: RemediationResponse): string => r.checklistId);\n if (this.text(raw['agent']) === '' || this.text(raw['model']) === ''\n || raw['fromHead'] !== receipt.headSha || raw['toHead'] !== currentHead\n || currentHead === receipt.headSha || reds.some((id: string): boolean => !ids.includes(id))\n || ids.some((id: string): boolean => !reds.includes(id))) return null;\n return new ReviewRemediation(this.text(raw['agent']), this.text(raw['model']), receipt.headSha, currentHead, responses);\n }\n\n capRemediations(repoRoot: string, summaryPath: string, receipt: ReviewStageReceipt | null, maxRounds: number): Record<string, string> {\n const out: Record<string, string> = {};\n if (receipt === null || !this.capSpent(summaryPath, receipt, maxRounds)) return out;\n const remediation = this.validRemediation(repoRoot, summaryPath, receipt);\n if (remediation === null) return out;\n for (const response of remediation.responses) {\n out[response.checklistId] = `Author-remediated after review cap; NOT re-reviewed. ${response.resolution} `\n + `(${remediation.fromHead.slice(0, 8)}..${remediation.toHead.slice(0, 8)})`;\n }\n return out;\n }\n\n auditTrail(summaryPath: string, checklistId: string, receipt: ReviewStageReceipt | null): string {\n if (receipt === null || receipt.round < 1) return '';\n const lines: string[] = [];\n for (let round = 1; round <= receipt.round; round++) {\n const dir = this.roundDir(summaryPath, round);\n const verdict = this.readObject(path.join(dir, `review-${checklistId}.json`));\n const record = this.readObject(path.join(dir, `review-${checklistId}.provenance.json`));\n if (verdict !== null) {\n lines.push(`#### Reviewer round ${round} of ${receipt.maxReviewerRounds}`);\n lines.push(`Reviewed SHA: ${this.text(record?.['headSha']) || '(unknown)'}`);\n lines.push(`Status: ${this.text(verdict['status']).toUpperCase()}`);\n lines.push('', this.text(verdict['output']), '');\n }\n const remediation = this.readObject(this.remediationPath(summaryPath, round));\n if (remediation !== null && Array.isArray(remediation['responses'])) {\n const response = (remediation['responses'] as JsonValue[]).find((entry: JsonValue): boolean =>\n typeof entry === 'object' && entry !== null && !Array.isArray(entry)\n && (entry as JsonObject)['checklistId'] === checklistId);\n if (typeof response === 'object' && response !== null && !Array.isArray(response)) {\n const raw = response as JsonObject;\n lines.push(`#### Author remediation after round ${round}`);\n lines.push(`Range: ${this.text(remediation['fromHead'])}..${this.text(remediation['toHead'])}`);\n lines.push('', this.text(raw['resolution']), '');\n }\n }\n }\n return lines.join('\\n').trim();\n }\n\n private responses(value: JsonValue | undefined): RemediationResponse[] {\n const responses = this.responsesOrEmpty(value);\n if (responses.length === 0) throw new InformAiError('wp-write-review-fixes: \"responses\" must be a non-empty array.');\n return responses;\n }\n\n private responsesOrEmpty(value: JsonValue | undefined): RemediationResponse[] {\n if (!Array.isArray(value)) return [];\n const out: RemediationResponse[] = [];\n for (const entry of value) {\n if (typeof entry !== 'object' || entry === null || Array.isArray(entry)) return [];\n const raw = entry as JsonObject;\n const id = this.text(raw['checklistId']);\n const resolution = this.text(raw['resolution']);\n const files = Array.isArray(raw['files']) ? raw['files'].filter((f: JsonValue): f is string => typeof f === 'string' && f.trim() !== '') : [];\n if (id === '' || resolution === '' || files.length === 0) return [];\n out.push(new RemediationResponse(id, resolution, files));\n }\n return out;\n }\n\n private requiredText(raw: JsonObject, key: string): string {\n const value = this.text(raw[key]);\n if (value === '') throw new InformAiError(`wp-write-review-fixes: \"${key}\" must be a non-empty string.`);\n return value;\n }\n\n private text(value: JsonValue | undefined): string {\n return typeof value === 'string' ? value.trim() : '';\n }\n\n private parseObject(json: string, message: string): JsonObject {\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: malformed author JSON becomes an actionable refusal\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const value = JSON.parse(json) as JsonValue;\n if (typeof value === 'object' && value !== null && !Array.isArray(value)) return value;\n // webpieces-disable no-any-unknown -- the language types caught JavaScript values as unknown\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n }\n throw new InformAiError(message);\n }\n\n private readObject(file: string): JsonObject | null {\n if (!fs.existsSync(file)) return null;\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: unreadable durable state becomes an actionable refusal\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const value = JSON.parse(fs.readFileSync(file, 'utf8')) as JsonValue;\n if (typeof value === 'object' && value !== null && !Array.isArray(value)) return value;\n throw new InformAiError(`Review state file must contain one JSON object: ${file}`);\n // webpieces-disable no-any-unknown -- the language types caught JavaScript values as unknown\n } catch (err: unknown) {\n const error = toError(err);\n if (error instanceof InformAiError) throw error;\n throw new InformAiError(`Could not read review state file ${file}: ${error.message}`, { cause: error });\n }\n }\n\n private assertClean(repoRoot: string): void {\n const status = this.git(repoRoot, ['status', '--porcelain', '--untracked-files=all']);\n if (status !== '') throw new InformAiError('wp-write-review-fixes: commit every remediation and leave no staged, unstaged, or untracked files first.');\n }\n\n private git(repoRoot: string, args: string[]): string {\n const result = spawnSync('git', args, { cwd: repoRoot, encoding: 'utf8' });\n if (result.status === 0) return (result.stdout ?? '').trim();\n const command = `git ${args.join(' ')}`;\n const detail = (result.stderr ?? '').trim() || result.error?.message || `exit ${result.status ?? 'unknown'}`;\n const message = `Review-round Git command failed: ${command}\\n${detail}`;\n if (result.error !== undefined) throw new InformAiError(message, { cause: result.error });\n throw new InformAiError(message);\n }\n}\n"]}
@@ -19,7 +19,12 @@ export declare class ReviewStageReceipt {
19
19
  round: number;
20
20
  /** Repository-owned cap copied from config so verdict provenance can audit the active budget. */
21
21
  maxReviewerRounds: number;
22
- /** Prior reviewed HEAD for remediation-only rounds; empty for the initial full review. */
22
+ /**
23
+ * The reviewed HEAD the latest recorded author remediation starts from: stamped by stage ② when it opens
24
+ * a remediation-only round (the prior round's HEAD), and by `wp-write-review-fixes` the moment it accepts
25
+ * a remediation — including the one after the round cap, where no further round is ever opened to stamp
26
+ * it (issue #1051: it used to stay '' there). Empty while no remediation exists.
27
+ */
23
28
  remediationFromHead: string;
24
29
  constructor(headSha?: string, mergeValidated?: boolean, buildCommand?: string, buildPassedAt?: string, reviewersBriefed?: string[]);
25
30
  }
@@ -43,6 +48,14 @@ export declare class ReviewStageReceiptService {
43
48
  constructor(reviewJsonService: ReviewJsonService);
44
49
  receiptPath(repoRoot: string, featureName: string): string;
45
50
  write(repoRoot: string, featureName: string, receipt: ReviewStageReceipt): string;
51
+ /**
52
+ * Stamp an ACCEPTED author remediation onto the receipt (issue #1051), keeping the file's mtime.
53
+ *
54
+ * The mtime is kept deliberately: {@link writtenAtMs} answers "when did stage ② last brief anyone?",
55
+ * and recording a remediation briefs nobody. Moving it would make `wp-await-reviews` discount every
56
+ * verdict submitted before the remediation as though a new briefing had superseded it.
57
+ */
58
+ recordRemediation(repoRoot: string, featureName: string, receipt: ReviewStageReceipt): string;
46
59
  /** The receipt, or null when stage ② never ran (or left something unreadable behind). */
47
60
  read(repoRoot: string, featureName: string): ReviewStageReceipt | null;
48
61
  /** The receipt file's mtime in epoch ms, or 0 when there is none — when stage ② last briefed anyone. */
@@ -26,7 +26,12 @@ class ReviewStageReceipt {
26
26
  round;
27
27
  /** Repository-owned cap copied from config so verdict provenance can audit the active budget. */
28
28
  maxReviewerRounds;
29
- /** Prior reviewed HEAD for remediation-only rounds; empty for the initial full review. */
29
+ /**
30
+ * The reviewed HEAD the latest recorded author remediation starts from: stamped by stage ② when it opens
31
+ * a remediation-only round (the prior round's HEAD), and by `wp-write-review-fixes` the moment it accepts
32
+ * a remediation — including the one after the round cap, where no further round is ever opened to stamp
33
+ * it (issue #1051: it used to stay '' there). Empty while no remediation exists.
34
+ */
30
35
  remediationFromHead;
31
36
  // eslint-disable-next-line @typescript-eslint/max-params
32
37
  constructor(headSha = '', mergeValidated = false, buildCommand = '', buildPassedAt = '', reviewersBriefed = []) {
@@ -71,6 +76,21 @@ let ReviewStageReceiptService = class ReviewStageReceiptService {
71
76
  fs.writeFileSync(p, JSON.stringify(receipt, null, 2) + '\n');
72
77
  return p;
73
78
  }
79
+ /**
80
+ * Stamp an ACCEPTED author remediation onto the receipt (issue #1051), keeping the file's mtime.
81
+ *
82
+ * The mtime is kept deliberately: {@link writtenAtMs} answers "when did stage ② last brief anyone?",
83
+ * and recording a remediation briefs nobody. Moving it would make `wp-await-reviews` discount every
84
+ * verdict submitted before the remediation as though a new briefing had superseded it.
85
+ */
86
+ recordRemediation(repoRoot, featureName, receipt) {
87
+ const p = this.receiptPath(repoRoot, featureName);
88
+ const before = fs.statSync(p);
89
+ receipt.remediationFromHead = receipt.headSha;
90
+ this.write(repoRoot, featureName, receipt);
91
+ fs.utimesSync(p, before.atime, before.mtime);
92
+ return p;
93
+ }
74
94
  /** The receipt, or null when stage ② never ran (or left something unreadable behind). */
75
95
  read(repoRoot, featureName) {
76
96
  const p = this.receiptPath(repoRoot, featureName);