@webpieces/pr-gate 0.4.826 → 0.4.827

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 (49) hide show
  1. package/package.json +3 -3
  2. package/src/dashboard/checklist-comment-renderer.js +8 -6
  3. package/src/dashboard/checklist-comment-renderer.js.map +1 -1
  4. package/src/dashboard/checklist-comment-row.d.ts +6 -0
  5. package/src/dashboard/checklist-comment-row.js +6 -0
  6. package/src/dashboard/checklist-comment-row.js.map +1 -1
  7. package/src/dashboard/dashboard.d.ts +11 -0
  8. package/src/dashboard/dashboard.js +24 -6
  9. package/src/dashboard/dashboard.js.map +1 -1
  10. package/src/scripts/commands/await-reviews-command.d.ts +3 -3
  11. package/src/scripts/commands/await-reviews-command.js +24 -20
  12. package/src/scripts/commands/await-reviews-command.js.map +1 -1
  13. package/src/scripts/commands/finish-upsert-pr-command.js +27 -31
  14. package/src/scripts/commands/finish-upsert-pr-command.js.map +1 -1
  15. package/src/scripts/commands/review-upsert-pr-command.d.ts +3 -8
  16. package/src/scripts/commands/review-upsert-pr-command.js +15 -17
  17. package/src/scripts/commands/review-upsert-pr-command.js.map +1 -1
  18. package/src/scripts/commands/write-review-command.d.ts +29 -15
  19. package/src/scripts/commands/write-review-command.js +62 -29
  20. package/src/scripts/commands/write-review-command.js.map +1 -1
  21. package/src/scripts/commands/write-review-fixes-command.d.ts +5 -1
  22. package/src/scripts/commands/write-review-fixes-command.js +6 -5
  23. package/src/scripts/commands/write-review-fixes-command.js.map +1 -1
  24. package/src/scripts/workflow/checklist-scanner.d.ts +47 -22
  25. package/src/scripts/workflow/checklist-scanner.js +77 -34
  26. package/src/scripts/workflow/checklist-scanner.js.map +1 -1
  27. package/src/scripts/workflow/provenance-enforcer.d.ts +2 -2
  28. package/src/scripts/workflow/provenance-enforcer.js +5 -5
  29. package/src/scripts/workflow/provenance-enforcer.js.map +1 -1
  30. package/src/scripts/workflow/review-report.d.ts +26 -8
  31. package/src/scripts/workflow/review-report.js +61 -39
  32. package/src/scripts/workflow/review-report.js.map +1 -1
  33. package/src/scripts/workflow/review-round-state.d.ts +87 -22
  34. package/src/scripts/workflow/review-round-state.js +252 -104
  35. package/src/scripts/workflow/review-round-state.js.map +1 -1
  36. package/src/scripts/workflow/review-round-text.d.ts +37 -0
  37. package/src/scripts/workflow/review-round-text.js +87 -0
  38. package/src/scripts/workflow/review-round-text.js.map +1 -0
  39. package/src/scripts/workflow/review-stage-receipt.d.ts +7 -19
  40. package/src/scripts/workflow/review-stage-receipt.js +7 -31
  41. package/src/scripts/workflow/review-stage-receipt.js.map +1 -1
  42. package/src/scripts/workflow/reviewer-briefing-builder.js +0 -1
  43. package/src/scripts/workflow/reviewer-briefing-builder.js.map +1 -1
  44. package/src/scripts/workflow/reviewer-verdict-gate.d.ts +14 -26
  45. package/src/scripts/workflow/reviewer-verdict-gate.js +38 -51
  46. package/src/scripts/workflow/reviewer-verdict-gate.js.map +1 -1
  47. package/src/scripts/workflow/verdict-provenance.d.ts +10 -10
  48. package/src/scripts/workflow/verdict-provenance.js +25 -23
  49. package/src/scripts/workflow/verdict-provenance.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,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,QA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,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;QACnF,OAAO;YACH,OAAO,CAAC,CAAC,WAAW,sFAAsF;YAC1G,SAAS,OAAO,CAAC,OAAO,EAAE;YAC1B,iGAAiG;YACjG,8BAA8B;SACjC,CAAC;IACN,CAAC;IAED;;;;;;OAMG;IACK,OAAO,CAAC,CAAmB;QAC/B,IAAI,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,OAAO,KAAK,EAAE;YAAE,OAAO,EAAE,CAAC;QAC9C,OAAO,CAAC,0BAA0B,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;IACnD,CAAC;IAED,sGAAsG;IACtG,+FAA+F;IACvF,GAAG,CAAC,CAAmB;QAC3B,IAAI,CAAC,CAAC,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACjC,OAAO,iEAAiE,CAAC,CAAC,OAAO,CAAC,MAAM,UAAU,CAAC;QACvG,CAAC;QACD,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,oBAAoB,CAAC,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAS,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"]}
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;AAC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,mCAAe;GALtC,YAAY,CAyiBxB","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';\nimport { ReviewRoundText } from './review-round-text';\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 final round's ORANGE checklists: the author fixes and records each, and nobody re-reviews it. */\n orangeChecklistIds: string[];\n /**\n * Checklists the diff matches now that were never briefed, because a round had already started when a\n * later commit first triggered them (issue #1053). Informational only — they are never owed a reviewer.\n */\n notBriefed: RequiredChecklist[];\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.orangeChecklistIds = [];\n this.notBriefed = [];\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 private readonly roundText: ReviewRoundText,\n ) {}\n\n /**\n * The final round's banner comes BEFORE everything else (issue #1053): the coordinating agent has to know\n * this is the last review the PR will ever get before it reads which reviewers to spawn, not after.\n */\n render(input: ReviewReportInput): string {\n const briefsFinalRound = input.briefings.length > 0 && input.round >= input.maxReviewerRounds;\n return (briefsFinalRound ? this.roundText.finalRoundBanner(input.round, input.maxReviewerRounds) : '')\n + '\\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 && input.orangeChecklistIds.length > 0) {\n return `② 🟠 REVIEW ROUND ${input.round} OF ${input.maxReviewerRounds} COMPLETE — fix the orange findings, then finish\\n`;\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) + this.notBriefedBlock(input);\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 lines.push(...this.notBriefedLines(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 private notBriefedLines(input: ReviewReportInput): string[] {\n return this.roundText.notBriefedLines(input.notBriefed.map((r: RequiredChecklist): string => r.id));\n }\n\n private notBriefedBlock(input: ReviewReportInput): string {\n const lines = this.notBriefedLines(input);\n return lines.length === 0 ? '' : 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-round<N>-${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 && input.round < input.maxReviewerRounds) {\n lines.push(` ↻ ${s.checklistId} — RED from ${this.short(s.fromSha)}: ${s.reason}; still refuses until the next round re-reviews it`);\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 bounded BY CONSTRUCTION: a passing verdict satisfies its checklist for the\n * branch's whole life, whatever changes afterwards, and only a red with a round left opens another round\n * (issue #1053). 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 refusal warning is not decoration: `wp-write-review` refuses a second verdict for a round, so a\n * gratuitous re-spawn costs a whole subagent run and records nothing.\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 whatever changes afterwards, deliberately: maxReviewerRounds is a\\n' +\n ' hard ceiling, and only a RED with a round left ever opens another round — this stage then names\\n' +\n ' the reds in a STEP below. Do NOT re-spawn a reviewer listed above to \"re-check\": it burns a full\\n' +\n ' subagent run, and pnpm wp-write-review refuses a second verdict for a round anyway. The only\\n' +\n ' 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.roundText.fixStep(input.round, input.maxReviewerRounds, input.redChecklistIds);\n if (input.roundAction === ROUND_ACTION_RECORD) return this.roundText.recordStep(input.round, input.maxReviewerRounds);\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 /**\n * The round is complete and no further round runs. An ORANGE is the final round's must-fix: its step\n * comes FIRST, because finish refuses until each one has a recorded fix — and it names no reviewer,\n * because none may be spawned for it (issue #1053).\n */\n private cappedFinishStep(input: ReviewReportInput): string {\n const oranges = input.orangeChecklistIds;\n let step = 1;\n const fix = oranges.length === 0 ? '' : this.roundText.orangeFixStep(step++, input.round, input.maxReviewerRounds, oranges);\n const write = this.writeSummaryStep(input.summaryPath, step++, '');\n return '\\n' + SEP + `▶ NEXT — ${oranges.length === 0 ? 'write summary.json, then finish' : 'fix the orange findings, write summary.json, then finish'}\\n` + SEP + '\\n'\n + fix + write\n + `STEP ${step} — 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,4 +1,4 @@
1
- import { AtomicFile, ReviewJsonService } from '@webpieces/rules-config';
1
+ import { AtomicFile, ChecklistResult, ReviewJsonService } from '@webpieces/rules-config';
2
2
  import { ReviewStageReceipt } from './review-stage-receipt';
3
3
  import { VerdictProvenanceService } from './verdict-provenance';
4
4
  import { DiffBasis } from './diff-basis';
@@ -14,7 +14,21 @@ export declare class ReviewRoundPlan {
14
14
  basis: DiffBasis;
15
15
  changedFiles: string[];
16
16
  redChecklistIds: string[];
17
- constructor(action: string, round: number, maxRounds: number, basis: DiffBasis, changedFiles?: string[], redChecklistIds?: string[]);
17
+ /** The final round's ORANGE checklists — must-fix, never re-reviewed (issue #1053). */
18
+ orangeChecklistIds: string[];
19
+ constructor(action: string, round: number, maxRounds: number, basis: DiffBasis, changedFiles?: string[], redChecklistIds?: string[], orangeChecklistIds?: string[]);
20
+ }
21
+ /**
22
+ * Where a branch's review stands, DERIVED from the round-numbered files on disk plus the stage-② receipt
23
+ * (issue #1053). There is no separate round counter: `round` is the highest round any file or briefing
24
+ * names. Data-only.
25
+ */
26
+ export declare class RoundSnapshot {
27
+ round: number;
28
+ roster: string[];
29
+ headSha: string;
30
+ complete: boolean;
31
+ constructor(round: number, roster: string[], headSha: string, complete: boolean);
18
32
  }
19
33
  export declare class RemediationResponse {
20
34
  checklistId: string;
@@ -22,6 +36,7 @@ export declare class RemediationResponse {
22
36
  files: string[];
23
37
  constructor(checklistId: string, resolution: string, files: string[]);
24
38
  }
39
+ /** The author's recorded fixes for one completed round: `review-round<N>-fixes.json`. Data-only. */
25
40
  export declare class ReviewRemediation {
26
41
  agent: string;
27
42
  model: string;
@@ -31,36 +46,80 @@ export declare class ReviewRemediation {
31
46
  writtenAt: string;
32
47
  constructor(agent: string, model: string, fromHead: string, toHead: string, responses: RemediationResponse[]);
33
48
  }
34
- /** Immutable per-round verdict history plus the author-remediation records between rounds. */
49
+ /**
50
+ * The reviewer rounds of one branch, read from their round-numbered files (issue #1053).
51
+ *
52
+ * `commands.pr-gate.maxReviewerRounds` is a HARD CEILING, not a quota: 1 round means 1 round. Three rules
53
+ * follow from it, and everything here exists to hold them:
54
+ *
55
+ * 1. Every verdict is `review-round<N>-<id>.json` (+ `.provenance.json`), every author fix record is
56
+ * `review-round<N>-fixes.json`, and nothing is ever overwritten. The live verdict of a checklist is its
57
+ * highest round; the round the branch is on is the highest round any file names.
58
+ * 2. A new round starts ONLY when the previous round has a RED and rounds remain, and it re-briefs only
59
+ * those reds. A green or yellow stands whatever changes afterwards — staleness never re-reviews.
60
+ * 3. The final round has no red. Its blocking color is ORANGE: the author fixes it best effort, records the
61
+ * fix, and ships with the finding and its claimed fix stamped on the dashboard.
62
+ */
35
63
  export declare class ReviewRoundStateService {
36
64
  private readonly reviewJson;
37
65
  private readonly provenance;
38
66
  private readonly atomicFile;
39
67
  constructor(reviewJson: ReviewJsonService, provenance: VerdictProvenanceService, atomicFile: AtomicFile);
40
- roundDir(summaryPath: string, round: number): string;
41
- archiveVerdict(summaryPath: string, checklistId: string, round: number): void;
42
- roundComplete(summaryPath: string, receipt: ReviewStageReceipt): boolean;
68
+ /** The author's recorded fixes for one round: `review-round<N>-fixes.json`, beside summary.json. */
69
+ fixesPath(summaryPath: string, round: number): string;
70
+ /** The highest round any round-numbered file names, or 0. */
71
+ highestRound(summaryPath: string): number;
72
+ /** Every checklist that has a verdict in ANY round on this branch. */
73
+ verdictChecklistIds(summaryPath: string): string[];
74
+ /** Where the branch's review stands — see {@link RoundSnapshot}. */
75
+ snapshot(summaryPath: string, receipt: ReviewStageReceipt | null): RoundSnapshot;
43
76
  /**
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).
77
+ * TRUE once a review round has started on this branch. From then on the checklist set is FROZEN (issue
78
+ * #1053): finish judges only the checklists that were briefed, never ones a later commit newly triggers.
49
79
  */
50
- capSpent(summaryPath: string, receipt: ReviewStageReceipt | null, maxRounds: number): boolean;
80
+ roundStarted(summaryPath: string, receipt: ReviewStageReceipt | null): boolean;
81
+ /** The frozen checklist set: every checklist briefed in any round — see {@link roundStarted}. */
82
+ briefedChecklistIds(summaryPath: string, receipt: ReviewStageReceipt | null): string[];
83
+ /** Does `checklistId` already have a verdict in `round`? A round's verdict is never overwritten. */
84
+ hasVerdict(summaryPath: string, checklistId: string, round: number): boolean;
85
+ /** The roster checklists whose verdict in the snapshot's round is `status`. */
86
+ checklistIdsWithStatus(summaryPath: string, snap: RoundSnapshot, status: string): string[];
87
+ /** What stage ② does next. See the class comment for the three rules it holds. */
88
+ plan(repoRoot: string, summaryPath: string, receipt: ReviewStageReceipt | null, maxRounds: number, fullBasis: DiffBasis): ReviewRoundPlan;
51
89
  /**
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.
90
+ * Record the author's fixes for the latest completed round — one response per RED (a round that is not
91
+ * the last) or ORANGE (the final round) — as `review-round<N>-fixes.json`.
92
+ *
93
+ * A record that still HOLDS is never overwritten. One that no longer holds — its `toHead` left HEAD's
94
+ * history, which every `wp-start-upsert-pr` squash-update does — is kept beside it as
95
+ * `review-round<N>-fixes.json.superseded-<k>` and a fresh record is written, so re-recording is always
96
+ * the way past a stale record and nothing is ever lost.
55
97
  */
56
- reviewCount(summaryPath: string, checklistId: string, throughRound: number): number;
57
- redChecklistIds(summaryPath: string, receipt: ReviewStageReceipt): string[];
58
- remediationPath(summaryPath: string, round: number): string;
59
- plan(repoRoot: string, summaryPath: string, receipt: ReviewStageReceipt | null, maxRounds: number, fullBasis: DiffBasis): ReviewRoundPlan;
60
98
  writeRemediation(repoRoot: string, summaryPath: string, receipt: ReviewStageReceipt, json: string): string;
61
- validRemediation(repoRoot: string, summaryPath: string, receipt: ReviewStageReceipt): ReviewRemediation | null;
62
- capRemediations(repoRoot: string, summaryPath: string, receipt: ReviewStageReceipt | null, maxRounds: number): Record<string, string>;
63
- auditTrail(summaryPath: string, checklistId: string, receipt: ReviewStageReceipt | null): string;
99
+ /**
100
+ * Keep a record that no longer holds beside the new one, as `<file>.superseded-<k>` — a name no round
101
+ * scan reads, so it is history and never a live record.
102
+ */
103
+ private supersede;
104
+ /**
105
+ * The round's recorded fixes, or null when there are none that still hold: written from the reviewed
106
+ * HEAD, to a later commit that is still in HEAD's history, covering exactly the round's red/orange set.
107
+ */
108
+ validFixes(repoRoot: string, summaryPath: string, snap: RoundSnapshot): ReviewRemediation | null;
109
+ /**
110
+ * checklist id → the dashboard stamp for every ORANGE whose fix the author recorded (issue #1053):
111
+ * "orange at <fromHead>, author-fixed in <toHead>, not re-reviewed: <resolution>". An orange with no
112
+ * valid record is absent, and so still blocks.
113
+ */
114
+ orangeFixes(repoRoot: string, summaryPath: string, results: readonly ChecklistResult[]): Record<string, string>;
115
+ auditTrail(summaryPath: string, checklistId: string, maxRounds: number): string;
116
+ private blockingIds;
117
+ /** A round's fix record, provided its `toHead` is still in HEAD's history; else null. */
118
+ private readFixes;
119
+ private everyVerdictIn;
120
+ /** `review-round<N>-<id>.json` → `<id>`; '' for the fixes record, a provenance file, or anything else. */
121
+ private verdictIdOf;
122
+ private roundFiles;
64
123
  private responses;
65
124
  private responsesOrEmpty;
66
125
  private requiredText;
@@ -68,5 +127,11 @@ export declare class ReviewRoundStateService {
68
127
  private parseObject;
69
128
  private readObject;
70
129
  private assertClean;
130
+ /**
131
+ * `git merge-base --is-ancestor`: exit 0 = yes, 1 = no. A `sha` git does not know (exit 128 with
132
+ * "Not a valid commit name") is also no — the commit is gone from this clone, so it is not in HEAD's
133
+ * history. Anything else is a real failure and refuses.
134
+ */
135
+ private isAncestorOfHead;
71
136
  private git;
72
137
  }