@webpieces/pr-gate 0.4.822 → 0.4.823

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 (42) hide show
  1. package/package.json +4 -3
  2. package/src/dashboard/checklist-comment-renderer.js +6 -4
  3. package/src/dashboard/checklist-comment-renderer.js.map +1 -1
  4. package/src/dashboard/dashboard.js +6 -1
  5. package/src/dashboard/dashboard.js.map +1 -1
  6. package/src/scripts/commands/finish-upsert-pr-command.d.ts +4 -1
  7. package/src/scripts/commands/finish-upsert-pr-command.js +26 -5
  8. package/src/scripts/commands/finish-upsert-pr-command.js.map +1 -1
  9. package/src/scripts/commands/review-upsert-pr-command.d.ts +3 -1
  10. package/src/scripts/commands/review-upsert-pr-command.js +40 -23
  11. package/src/scripts/commands/review-upsert-pr-command.js.map +1 -1
  12. package/src/scripts/commands/write-review-command.d.ts +3 -1
  13. package/src/scripts/commands/write-review-command.js +9 -3
  14. package/src/scripts/commands/write-review-command.js.map +1 -1
  15. package/src/scripts/commands/write-review-fixes-command.d.ts +21 -0
  16. package/src/scripts/commands/write-review-fixes-command.js +68 -0
  17. package/src/scripts/commands/write-review-fixes-command.js.map +1 -0
  18. package/src/scripts/pr-gate-app.d.ts +5 -1
  19. package/src/scripts/pr-gate-app.js +9 -1
  20. package/src/scripts/pr-gate-app.js.map +1 -1
  21. package/src/scripts/workflow/checklist-scanner.d.ts +1 -3
  22. package/src/scripts/workflow/checklist-scanner.js +6 -9
  23. package/src/scripts/workflow/checklist-scanner.js.map +1 -1
  24. package/src/scripts/workflow/repo-config-testkit.js +2 -0
  25. package/src/scripts/workflow/repo-config-testkit.js.map +1 -1
  26. package/src/scripts/workflow/review-report.d.ts +7 -4
  27. package/src/scripts/workflow/review-report.js +44 -24
  28. package/src/scripts/workflow/review-report.js.map +1 -1
  29. package/src/scripts/workflow/review-round-state.d.ts +58 -0
  30. package/src/scripts/workflow/review-round-state.js +300 -0
  31. package/src/scripts/workflow/review-round-state.js.map +1 -0
  32. package/src/scripts/workflow/review-stage-receipt.d.ts +6 -0
  33. package/src/scripts/workflow/review-stage-receipt.js +13 -0
  34. package/src/scripts/workflow/review-stage-receipt.js.map +1 -1
  35. package/src/scripts/workflow/reviewer-verdict-gate.js +6 -24
  36. package/src/scripts/workflow/reviewer-verdict-gate.js.map +1 -1
  37. package/src/scripts/workflow/verdict-provenance.d.ts +3 -8
  38. package/src/scripts/workflow/verdict-provenance.js +7 -17
  39. package/src/scripts/workflow/verdict-provenance.js.map +1 -1
  40. package/src/scripts/wp-write-review-fixes.d.ts +2 -0
  41. package/src/scripts/wp-write-review-fixes.js +16 -0
  42. package/src/scripts/wp-write-review-fixes.js.map +1 -0
@@ -116,8 +116,6 @@ class ChecklistScan {
116
116
  * downstream would mean a second changed-file computation that can disagree with this one.
117
117
  */
118
118
  suppressed;
119
- /** TRUE only for the top-level `singleRoundReview` machine opt-in. */
120
- singleRoundReview;
121
119
  /**
122
120
  * How every EXISTING verdict file stands (issue #863): CURRENT (submitted through `wp-write-review` and
123
121
  * its checklist's in-scope diff is unchanged — it carries), STALE (in-scope diff changed since — re-brief)
@@ -137,7 +135,7 @@ class ChecklistScan {
137
135
  reviewersDisabled, suppressed, basis = new diff_basis_1.DiffBasis(), changedFiles = [],
138
136
  // Defaulted so a caller that only cares about the X/N/Z counts (and every existing test construction)
139
137
  // stays a one-liner; the scanner itself always passes the real set.
140
- results = [], optionalNotRun = [], singleRoundReview = false) {
138
+ results = [], optionalNotRun = []) {
141
139
  this.defined = defined;
142
140
  this.applicable = applicable;
143
141
  this.reviewed = reviewed;
@@ -153,7 +151,6 @@ class ChecklistScan {
153
151
  this.changedFiles = changedFiles;
154
152
  this.results = results;
155
153
  this.optionalNotRun = optionalNotRun;
156
- this.singleRoundReview = singleRoundReview;
157
154
  this.standings = [];
158
155
  this.scopeHashes = {};
159
156
  }
@@ -236,12 +233,12 @@ let ChecklistScanner = class ChecklistScanner {
236
233
  // EMPTY: applicable, reviewed, outstanding, formatErrors, results, optionalNotRun. INTACT:
237
234
  // defined, roster, basis, changedFiles, context — so every downstream reader can still say
238
235
  // WHAT was suppressed, which is the difference between an honest record and a silent one.
239
- return new ChecklistScan(defined, [], [], [], context, summaryPath, base, roster, [], true, matched, basis, changedFiles, [], [], homeConfig.singleRoundReview);
236
+ return new ChecklistScan(defined, [], [], [], context, summaryPath, base, roster, [], true, matched, basis, changedFiles, [], []);
240
237
  }
241
238
  const applicable = matched;
242
239
  const scopeHashes = this.scopeHasher.hashes(repoRoot, basis, applicable);
243
240
  const loaded = this.reviewJsonService.loadChecklistResults(summaryPath, applicable);
244
- const standings = this.standingsOf(summaryPath, loaded, scopeHashes, homeConfig.singleRoundReview);
241
+ const standings = this.standingsOf(summaryPath, loaded, scopeHashes);
245
242
  const results = this.liveResults(loaded, standings);
246
243
  const stillOwed = this.reviewJsonService.pendingChecklists(applicable, results);
247
244
  const owedIds = new Set(stillOwed.map((r) => r.id));
@@ -250,7 +247,7 @@ let ChecklistScanner = class ChecklistScanner {
250
247
  // that never happened.
251
248
  const reviewed = applicable.filter((r) => !owedIds.has(r.id));
252
249
  const optionalNotRun = this.reviewJsonService.optionalWithoutVerdict(applicable, results);
253
- const scan = new ChecklistScan(defined, applicable, reviewed, opts.filterAlreadyReviewed ? this.blocking(stillOwed, optionalNotRun) : applicable, context, summaryPath, base, roster, this.reviewJsonService.checklistFormatErrors(applicable, results), false, [], basis, changedFiles, results, optionalNotRun, homeConfig.singleRoundReview);
250
+ const scan = new ChecklistScan(defined, applicable, reviewed, opts.filterAlreadyReviewed ? this.blocking(stillOwed, optionalNotRun) : applicable, context, summaryPath, base, roster, this.reviewJsonService.checklistFormatErrors(applicable, results), false, [], basis, changedFiles, results, optionalNotRun);
254
251
  scan.standings = standings;
255
252
  scan.scopeHashes = scopeHashes;
256
253
  return scan;
@@ -260,10 +257,10 @@ let ChecklistScanner = class ChecklistScanner {
260
257
  * with a format problem is left to the format complaint, which names the fix; it is not assessed.
261
258
  */
262
259
  // eslint-disable-next-line @typescript-eslint/max-params
263
- standingsOf(summaryPath, loaded, scopeHashes, singleRound) {
260
+ standingsOf(summaryPath, loaded, scopeHashes) {
264
261
  return loaded
265
262
  .filter((r) => r.problem === '')
266
- .map((r) => this.verdictProvenance.assess(summaryPath, r, scopeHashes[r.id] ?? '', singleRound));
263
+ .map((r) => this.verdictProvenance.assess(summaryPath, r, scopeHashes[r.id] ?? ''));
267
264
  }
268
265
  /**
269
266
  * The verdicts that still COUNT. A rejected one never does. A stale green or yellow judged code that
@@ -1 +1 @@
1
- {"version":3,"file":"checklist-scanner.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/checklist-scanner.ts"],"names":[],"mappings":";;;;AAAA,0DAGiC;AACjC,yCAA2D;AAC3D,iEAAsD;AACtD,6DAA0E;AAC1E,6CAA4D;AAC5D,2DAAsD;AACtD,qEAAgE;AAChE,6DAE8B;AAE9B,uEAAuE;AACvE,MAAa,oBAAoB;IAC7B;;;;OAIG;IACH,qBAAqB,CAAU;IAC/B;;;;;;;;;;;;OAYG;IACH,YAAY,CAAS;IAErB,YAAY,qBAAqB,GAAG,KAAK,EAAE,YAAY,GAAG,YAAY;QAClE,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;QACnD,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACrC,CAAC;CACJ;AA1BD,oDA0BC;AAED;;;;;;GAMG;AACH,MAAa,aAAa;IACtB,OAAO,CAAwB,CAAM,IAAI;IACzC,UAAU,CAAsB,CAAK,IAAI;IACzC,QAAQ,CAAsB,CAAO,mEAAmE;IACxG,WAAW,CAAsB,CAAI,uCAAuC;IAC5E,OAAO,CAAyB,CAAK,wCAAwC;IAC7E,WAAW,CAAS,CAAkB,yDAAyD;IAC/F,SAAS,CAAS,CAAmB,iCAAiC;IACtE,wGAAwG;IACxG,+FAA+F;IAC/F,6EAA6E;IAC7E,MAAM,CAAkB;IACxB,qGAAqG;IACrG,qGAAqG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W,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9E,CAAC;IAED;;;;;;;;OAQG;IACK,QAAQ,CAAC,SAAuC,EAAE,cAA4C;QAClG,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAoB,EAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACpF,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,CAAoB,EAAW,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACnF,CAAC;IAED;;;;;;;;;OASG;IACK,YAAY,CAAC,QAAgB,EAAE,IAAY;QAC/C,IAAI,IAAI,KAAK,EAAE;YAAE,OAAO,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,IAAI,kCAAmB,EAAE,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;QAC7B,oFAAoF;QACpF,OAAO,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IAC3E,CAAC;CACJ,CAAA;AAnJY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGF,mCAAY;QACP,sCAAiB;QACzB,wBAAS;QACD,8BAAiB;QACnB,mCAAe;QACb,gCAAiB;QAGxB,gCAAiB;QAChB,6CAAoB;QACd,6CAAwB;GAZvD,gBAAgB,CAmJ5B","sourcesContent":["import {\n ChangedFilesOptions, ChecklistDefinition, ChecklistResult, ChecklistReviewContext, DiffScope,\n HomeConfigService, RequiredChecklist, ReviewJsonService, VERDICT_RED, summaryJsonPath,\n} from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { AiBranchName } from './git-readAiBranchName';\nimport { ChecklistDetector, ChecklistRoster } from './checklist-detector';\nimport { DiffBasis, DiffBasisResolver } from './diff-basis';\nimport { PrContextWriter } from './pr-context-writer';\nimport { ChecklistScopeHasher } from './checklist-scope-hasher';\nimport {\n STANDING_REJECTED, STANDING_STALE, VerdictProvenanceService, VerdictStanding,\n} from './verdict-provenance';\n\n/** How a caller wants the scan filtered. Data-only (per CLAUDE.md). */\nexport class ChecklistScanOptions {\n /**\n * false — `outstanding` is every applicable checklist (what `wp-review-upsert-pr` LISTS).\n * true — `outstanding` drops the ones already carrying a passing/overridden verdict, leaving only what\n * still owes review (what `wp-finish-upsert-pr` BLOCKS on).\n */\n filterAlreadyReviewed: boolean;\n /**\n * Which per-stage snapshot this scan should persist ('stage3-finish', …), or '' for \"do not write\n * pr-context.json here\".\n *\n * '' exists for stage ②, which cannot write yet: the context records `diffDir`, and the diff has not\n * been materialized at scan time. Letting the scan write anyway meant stage ② wrote the file twice,\n * ~60 lines apart, the first time with an empty diffDir. Now it writes once, after materializing.\n *\n * The DEFAULT is deliberately non-empty, so writing is what you get by NOT thinking about it. A\n * reviewer block that lost its diff command because nobody had written pr-context.json is a bug this\n * codebase has already shipped once (see PrContextWriter's docstring); opting out must be an explicit,\n * visible act by a caller that takes responsibility for writing it later — not an omission.\n */\n contextStage: string;\n\n constructor(filterAlreadyReviewed = false, contextStage = 'stage-scan') {\n this.filterAlreadyReviewed = filterAlreadyReviewed;\n this.contextStage = contextStage;\n }\n}\n\n/**\n * The answer to \"what review does this branch owe?\", in the X → N → Z terms the commands report:\n * X = `defined` — every checklist in pr-gate.checklists\n * N = `applicable` — those whose patterns matched (or that have no patterns, so always run)\n * Z = `outstanding` — of N, those still owing a verdict (only when filterAlreadyReviewed)\n * Data-only.\n */\nexport class ChecklistScan {\n defined: ChecklistDefinition[]; // X\n applicable: RequiredChecklist[]; // N\n reviewed: RequiredChecklist[]; // N − Z: already have a passing/warned/overridden review-<id>.json\n outstanding: RequiredChecklist[]; // Z (== applicable when not filtering)\n context: ChecklistReviewContext; // fork-point sha + pr-context.json path\n summaryPath: string; // the branch's summary.json; verdict files sit beside it\n forkPoint: string; // '' when no fork point resolved\n // ALL X, matched or not, with why — what the PR comment publishes as its roster. Skipped checklists are\n // absent from `applicable` by construction, and recovering them downstream would mean a second\n // changed-file computation with different semantics (see the class comment).\n roster: ChecklistRoster;\n // Verdict files that exist but cannot be read as a verdict (e.g. still using the removed `success`).\n // Carried on the SCAN because wp-finish-upsert-pr refuses on missing reviewers before it ever parses\n // summary.json — a complaint raised only in there would never reach the AI.\n formatErrors: string[];\n /**\n * The basis the matching ACTUALLY ran against. Carried out so a caller that materializes the diff\n * (stage ②) reuses the identical range instead of resolving its own — two independent resolutions is\n * exactly how the changed-file set and the printed `git diff` command came to disagree.\n */\n basis: DiffBasis;\n changedFiles: string[]; // the full changed-file set the matching ran against\n /**\n * The verdict files the scan ALREADY read, carried out rather than dropped.\n *\n * `outstanding` answers \"who still owes a verdict?\" but not \"why\" — and the two reasons demand opposite\n * actions from the reader: a reviewer that never ran must be SPAWNED, a reviewer that ran and REFUSED\n * must not be (it will refuse again; the finding has to be fixed first). Telling them apart means\n * resolving each checklist's verdict, and without the results here every caller either re-reads the same\n * files off disk — a second read that can disagree with this one — or merges the two cases into one\n * message, which is exactly the loop this field exists to break.\n */\n results: ChecklistResult[];\n /**\n * The OPTIONAL (`required: false`) applicable checklists carrying no verdict file — i.e. nobody ran them.\n *\n * Deliberately NOT in `outstanding` when filtering: that is the exemption that makes `required: false`\n * mean something. Carried out as its own set rather than merely subtracted, because both readers need it\n * BY NAME and neither can recover it from what is left: stage ② offers exactly these to the human, and\n * the PR dashboard must publish them as \"not run\" rather than let a shorter roster imply everything\n * passed. An optional checklist that ran and went RED is absent from here and stays in `outstanding`.\n */\n optionalNotRun: RequiredChecklist[];\n /**\n * TRUE when either this machine's `experimental.turnOffAllReviewers` switch is on or the project sets\n * `commands.pr-gate.reviewerAgents: 0`, and therefore when `applicable`, `reviewed`,\n * `outstanding`, `results`, `optionalNotRun` and `formatErrors` above are ALL EMPTY BY DECREE rather\n * than because nothing matched. Those two states are indistinguishable from the empty lists alone,\n * and telling them apart is the entire reason this field exists: an unreviewed PR must never render\n * as a reviewed one.\n *\n * `defined`, `roster`, `basis`, `changedFiles` and `context` are deliberately left INTACT under\n * suppression, so every reader can still say WHAT was switched off — including which REQUIRED\n * checklists would otherwise have run.\n *\n * See `HOME_KEY_TURN_OFF_ALL_REVIEWERS` in rules-config for the flag's contract; it is an\n * `experimental.*` flag, so only a human ever ends it.\n */\n reviewersDisabled: boolean;\n /**\n * The checklists that WOULD have been `applicable` had the reviewers not been suppressed — required\n * ones included. EMPTY on every ordinary run, and empty is not ambiguous there because\n * `reviewersDisabled` is false.\n *\n * Carried by NAME and not as a count because every reader needs a different slice of it: stage ②\n * prints them so a human can see exactly which required reviewer was killed, the dashboard names them\n * in the 1st comment, and the compact PR body needs only `.length`. Recomputing any of that\n * downstream would mean a second changed-file computation that can disagree with this one.\n */\n suppressed: RequiredChecklist[];\n /** TRUE only for the top-level `singleRoundReview` machine opt-in. */\n singleRoundReview: boolean;\n /**\n * How every EXISTING verdict file stands (issue #863): CURRENT (submitted through `wp-write-review` and\n * its checklist's in-scope diff is unchanged — it carries), STALE (in-scope diff changed since — re-brief)\n * or REJECTED (no bin provenance, or edited after submission — it is not a review). A REJECTED verdict,\n * and a STALE green or yellow one, is left OUT of `results`, so it is owed like one that never ran; a\n * stale RED stays in `results` and keeps refusing. Empty under suppression.\n */\n standings: VerdictStanding[];\n /** checklist id → ChecklistScopeHasher's hash of its in-scope diff NOW. Recorded in the stage-② receipt. */\n scopeHashes: Record<string, string>;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n defined: ChecklistDefinition[],\n applicable: RequiredChecklist[],\n reviewed: RequiredChecklist[],\n outstanding: RequiredChecklist[],\n context: ChecklistReviewContext,\n summaryPath: string,\n forkPoint: string,\n roster: ChecklistRoster,\n formatErrors: string[],\n // REQUIRED, and placed BEFORE the defaulted tail deliberately. A defaulted `reviewersDisabled =\n // false` would let every existing construction keep compiling while asserting, silently, that no\n // reviewer was switched off — the widening-by-omission `.claude/rules/no-backwards-compat.md`\n // rejects, and on the one field whose whole job is to stop an unreviewed PR reading as reviewed.\n reviewersDisabled: boolean,\n suppressed: RequiredChecklist[],\n basis: DiffBasis = new DiffBasis(),\n changedFiles: string[] = [],\n // Defaulted so a caller that only cares about the X/N/Z counts (and every existing test construction)\n // stays a one-liner; the scanner itself always passes the real set.\n results: ChecklistResult[] = [],\n optionalNotRun: RequiredChecklist[] = [],\n singleRoundReview = false,\n ) {\n this.defined = defined;\n this.applicable = applicable;\n this.reviewed = reviewed;\n this.outstanding = outstanding;\n this.context = context;\n this.summaryPath = summaryPath;\n this.forkPoint = forkPoint;\n this.roster = roster;\n this.formatErrors = formatErrors;\n this.reviewersDisabled = reviewersDisabled;\n this.suppressed = suppressed;\n this.basis = basis;\n this.changedFiles = changedFiles;\n this.results = results;\n this.optionalNotRun = optionalNotRun;\n this.singleRoundReview = singleRoundReview;\n this.standings = [];\n this.scopeHashes = {};\n }\n}\n\n/**\n * The ONE computation of which reviewer subagents a branch owes, shared by `wp-review-upsert-pr` (which lists) and\n * `wp-finish-upsert-pr` (which blocks). They previously each assembled this from the same parts in slightly\n * different ways, and any divergence means the command that reports and the command that gates disagree.\n *\n * Two properties are deliberate and load-bearing:\n *\n * 1. **The base is the FORK POINT of main, computed directly** — never `DiffScope.resolveBase`, which\n * overlays `NX_BASE`/`NX_HEAD` from the environment. That made review coverage depend on an env var.\n * It now arrives via {@link DiffBasisResolver}, which injects ForkPoint; same sha, one resolution.\n * 2. **UNCOMMITTED work counts.** `getChangedFiles` is called with NO head, which is the branch of it that\n * diffs base → WORKING TREE and unions in untracked files. Passing a head would diff commit-to-commit and\n * silently miss staged, unstaged and untracked changes — so a checklist matching only uncommitted files\n * would never fire and its reviewer would never be listed.\n * 3. **The range and the command it prints are the SAME basis.** Property 2 used to be true of the file set\n * only: reviewers were handed `git diff <base> HEAD`, which on a dirty tree covers a different range and\n * prints nothing. Both now derive from one {@link DiffBasis}, carried on the scan so a materializing\n * caller cannot re-resolve and drift.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ChecklistScanner {\n constructor(\n private readonly aiBranchName: AiBranchName,\n private readonly checklistDetector: ChecklistDetector,\n private readonly diffScope: DiffScope,\n private readonly diffBasisResolver: DiffBasisResolver,\n private readonly prContextWriter: PrContextWriter,\n private readonly reviewJsonService: ReviewJsonService,\n // Injected BY TYPE (no Symbol token, per CLAUDE.md) so the ONE reviewer kill switch is read in the\n // ONE place that computes what a branch owes — see the suppression note on `scan`.\n private readonly homeConfig: HomeConfigService,\n private readonly scopeHasher: ChecklistScopeHasher,\n private readonly verdictProvenance: VerdictProvenanceService,\n ) {}\n\n /**\n * `defined` is the caller's ALREADY-VALIDATED `prGate.checklists`. The scanner deliberately does not load\n * config itself: `loadAndValidate` is the one gate on the checklist set (it rejects a non-array\n * `checklists`, including the removed `{ doc }` manifest shape, and verifies every guidance doc and\n * reviewer-agent file exists), both callers already run it for other fields, and keeping the read out of\n * here leaves this a function of its inputs rather than of the filesystem.\n */\n scan(repoRoot: string, defined: ChecklistDefinition[], opts: ChecklistScanOptions): ChecklistScan {\n const featureName = this.aiBranchName.getFeatureName();\n const summaryPath = summaryJsonPath(repoRoot, featureName);\n // ONE basis for the file set, the reproduce command and any downstream materialization. The fork\n // point still comes from ForkPoint (never DiffScope.resolveBase) — DiffBasisResolver injects it.\n const basis = this.diffBasisResolver.resolve(repoRoot);\n const base = basis.base;\n // ONE changed-file computation feeds both the roster (all X) and the applicable set (N). `detect` is\n // pure and defined as the roster minus its empty entries, so the two cannot disagree about a match.\n const changedFiles = this.changedFiles(repoRoot, base);\n const roster = new ChecklistRoster(\n this.checklistDetector.roster(defined, changedFiles), changedFiles.length, base !== '');\n const matched = this.checklistDetector.toRequired(this.checklistDetector.detect(defined, changedFiles));\n // THE ONE CHOKE POINT for both reviewer opt-outs. Suppressing HERE — rather than in\n // `wp-review-upsert-pr` and again in `wp-finish-upsert-pr` — is what keeps the command that LISTS\n // and the command that BLOCKS in agreement by construction, which is this class's whole reason for\n // existing. A second check in either command would be a second answer to one question.\n const context = opts.contextStage === ''\n ? this.prContextWriter.contextFor(repoRoot, featureName, basis)\n : this.prContextWriter.ensure(repoRoot, featureName, basis, opts.contextStage, changedFiles);\n const homeConfig = this.homeConfig.load();\n const projectDisabled = defined.some((d: ChecklistDefinition): boolean => d.reviewer.maxAgents === 0);\n if (homeConfig.turnOffAllReviewers || projectDisabled) {\n // EMPTY: applicable, reviewed, outstanding, formatErrors, results, optionalNotRun. INTACT:\n // defined, roster, basis, changedFiles, context — so every downstream reader can still say\n // WHAT was suppressed, which is the difference between an honest record and a silent one.\n return new ChecklistScan(\n defined, [], [], [], context, summaryPath, base, roster, [], true, matched, basis,\n changedFiles, [], [], homeConfig.singleRoundReview);\n }\n const applicable = matched;\n const scopeHashes = this.scopeHasher.hashes(repoRoot, basis, applicable);\n const loaded = this.reviewJsonService.loadChecklistResults(summaryPath, applicable);\n const standings = this.standingsOf(summaryPath, loaded, scopeHashes, homeConfig.singleRoundReview);\n const results = this.liveResults(loaded, standings);\n const stillOwed = this.reviewJsonService.pendingChecklists(applicable, results);\n const owedIds = new Set(stillOwed.map((r: RequiredChecklist): string => r.id));\n // NOT `!owedIds.has(...)`-with-the-optional-exemption-folded-in: an optional checklist nobody ran is\n // neither reviewed nor blocking, and calling it \"reviewed\" would put a ✓ on the dashboard for a review\n // that never happened.\n const reviewed = applicable.filter((r: RequiredChecklist): boolean => !owedIds.has(r.id));\n const optionalNotRun = this.reviewJsonService.optionalWithoutVerdict(applicable, results);\n const scan = new ChecklistScan(\n defined,\n applicable,\n reviewed,\n opts.filterAlreadyReviewed ? this.blocking(stillOwed, optionalNotRun) : applicable,\n context,\n summaryPath,\n base,\n roster,\n this.reviewJsonService.checklistFormatErrors(applicable, results),\n false,\n [],\n basis,\n changedFiles,\n results,\n optionalNotRun,\n homeConfig.singleRoundReview,\n );\n scan.standings = standings;\n scan.scopeHashes = scopeHashes;\n return scan;\n }\n\n /**\n * Judge every READABLE verdict against its bin provenance and the in-scope diff as it is now. A file\n * with a format problem is left to the format complaint, which names the fix; it is not assessed.\n */\n // eslint-disable-next-line @typescript-eslint/max-params\n private standingsOf(\n summaryPath: string, loaded: readonly ChecklistResult[], scopeHashes: Record<string, string>, singleRound: boolean,\n ): VerdictStanding[] {\n return loaded\n .filter((r: ChecklistResult): boolean => r.problem === '')\n .map((r: ChecklistResult): VerdictStanding =>\n this.verdictProvenance.assess(summaryPath, r, scopeHashes[r.id] ?? '', singleRound));\n }\n\n /**\n * The verdicts that still COUNT. A rejected one never does. A stale green or yellow judged code that\n * has since changed, so it is owed again; a stale RED still refuses — a refusal is not lifted by\n * changing other code in its scope, only by a fresh verdict — and it is re-briefed anyway because it\n * is red.\n */\n private liveResults(loaded: readonly ChecklistResult[], standings: readonly VerdictStanding[]): ChecklistResult[] {\n const dropped = new Set(standings\n .filter((s: VerdictStanding): boolean =>\n s.standing === STANDING_REJECTED || (s.standing === STANDING_STALE && s.status !== VERDICT_RED))\n .map((s: VerdictStanding): string => s.checklistId));\n return loaded.filter((r: ChecklistResult): boolean => !dropped.has(r.id));\n }\n\n /**\n * What `wp-finish-upsert-pr` actually REFUSES on: everything still owing a verdict, minus the optional\n * checklists nobody ran.\n *\n * The subtraction happens HERE — in the one place `outstanding` is computed — and not in the gate, so\n * there is a single answer to \"does this branch owe review?\". When the gate did its own filtering, the\n * command that lists and the command that blocks were two implementations of the same question, which is\n * exactly the divergence this class's docstring exists to prevent.\n */\n private blocking(stillOwed: readonly RequiredChecklist[], optionalNotRun: readonly RequiredChecklist[]): RequiredChecklist[] {\n const skipped = new Set(optionalNotRun.map((r: RequiredChecklist): string => r.id));\n return stillOwed.filter((r: RequiredChecklist): boolean => !skipped.has(r.id));\n }\n\n /**\n * Every file changed since the fork point, INCLUDING uncommitted and untracked ones. Two non-default\n * options, both load-bearing:\n *\n * `tsOnly:false` — the default drops every *.sql / Dockerfile / .env* file a checklist most wants\n * to key on, which would silently shrink the set a reviewer is pointed at.\n * `includeDeletions:true` — the default is `--diff-filter=d`, so a DELETED file is invisible. A PR that\n * deletes a migration, an auth check or a terraform rule changed exactly what a\n * checklist exists to catch, and under the default no checklist fires at all.\n */\n private changedFiles(repoRoot: string, base: string): string[] {\n if (base === '') return [];\n const opts = new ChangedFilesOptions();\n opts.tsOnly = false;\n opts.includeDeletions = true;\n // No head argument — see the class comment. This is what includes the working tree.\n return this.diffScope.getChangedFiles(repoRoot, base, undefined, opts);\n }\n}\n"]}
1
+ {"version":3,"file":"checklist-scanner.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/checklist-scanner.ts"],"names":[],"mappings":";;;;AAAA,0DAGiC;AACjC,yCAA2D;AAC3D,iEAAsD;AACtD,6DAA0E;AAC1E,6CAA4D;AAC5D,2DAAsD;AACtD,qEAAgE;AAChE,6DAE8B;AAE9B,uEAAuE;AACvE,MAAa,oBAAoB;IAC7B;;;;OAIG;IACH,qBAAqB,CAAU;IAC/B;;;;;;;;;;;;OAYG;IACH,YAAY,CAAS;IAErB,YAAY,qBAAqB,GAAG,KAAK,EAAE,YAAY,GAAG,YAAY;QAClE,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;QACnD,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACrC,CAAC;CACJ;AA1BD,oDA0BC;AAED;;;;;;GAMG;AACH,MAAa,aAAa;IACtB,OAAO,CAAwB,CAAM,IAAI;IACzC,UAAU,CAAsB,CAAK,IAAI;IACzC,QAAQ,CAAsB,CAAO,mEAAmE;IACxG,WAAW,CAAsB,CAAI,uCAAuC;IAC5E,OAAO,CAAyB,CAAK,wCAAwC;IAC7E,WAAW,CAAS,CAAkB,y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;IAC9E,CAAC;IAED;;;;;;;;OAQG;IACK,QAAQ,CAAC,SAAuC,EAAE,cAA4C;QAClG,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAoB,EAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACpF,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,CAAoB,EAAW,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACnF,CAAC;IAED;;;;;;;;;OASG;IACK,YAAY,CAAC,QAAgB,EAAE,IAAY;QAC/C,IAAI,IAAI,KAAK,EAAE;YAAE,OAAO,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,IAAI,kCAAmB,EAAE,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;QAC7B,oFAAoF;QACpF,OAAO,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IAC3E,CAAC;CACJ,CAAA;AAlJY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGF,mCAAY;QACP,sCAAiB;QACzB,wBAAS;QACD,8BAAiB;QACnB,mCAAe;QACb,gCAAiB;QAGxB,gCAAiB;QAChB,6CAAoB;QACd,6CAAwB;GAZvD,gBAAgB,CAkJ5B","sourcesContent":["import {\n ChangedFilesOptions, ChecklistDefinition, ChecklistResult, ChecklistReviewContext, DiffScope,\n HomeConfigService, RequiredChecklist, ReviewJsonService, VERDICT_RED, summaryJsonPath,\n} from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { AiBranchName } from './git-readAiBranchName';\nimport { ChecklistDetector, ChecklistRoster } from './checklist-detector';\nimport { DiffBasis, DiffBasisResolver } from './diff-basis';\nimport { PrContextWriter } from './pr-context-writer';\nimport { ChecklistScopeHasher } from './checklist-scope-hasher';\nimport {\n STANDING_REJECTED, STANDING_STALE, VerdictProvenanceService, VerdictStanding,\n} from './verdict-provenance';\n\n/** How a caller wants the scan filtered. Data-only (per CLAUDE.md). */\nexport class ChecklistScanOptions {\n /**\n * false — `outstanding` is every applicable checklist (what `wp-review-upsert-pr` LISTS).\n * true — `outstanding` drops the ones already carrying a passing/overridden verdict, leaving only what\n * still owes review (what `wp-finish-upsert-pr` BLOCKS on).\n */\n filterAlreadyReviewed: boolean;\n /**\n * Which per-stage snapshot this scan should persist ('stage3-finish', …), or '' for \"do not write\n * pr-context.json here\".\n *\n * '' exists for stage ②, which cannot write yet: the context records `diffDir`, and the diff has not\n * been materialized at scan time. Letting the scan write anyway meant stage ② wrote the file twice,\n * ~60 lines apart, the first time with an empty diffDir. Now it writes once, after materializing.\n *\n * The DEFAULT is deliberately non-empty, so writing is what you get by NOT thinking about it. A\n * reviewer block that lost its diff command because nobody had written pr-context.json is a bug this\n * codebase has already shipped once (see PrContextWriter's docstring); opting out must be an explicit,\n * visible act by a caller that takes responsibility for writing it later — not an omission.\n */\n contextStage: string;\n\n constructor(filterAlreadyReviewed = false, contextStage = 'stage-scan') {\n this.filterAlreadyReviewed = filterAlreadyReviewed;\n this.contextStage = contextStage;\n }\n}\n\n/**\n * The answer to \"what review does this branch owe?\", in the X → N → Z terms the commands report:\n * X = `defined` — every checklist in pr-gate.checklists\n * N = `applicable` — those whose patterns matched (or that have no patterns, so always run)\n * Z = `outstanding` — of N, those still owing a verdict (only when filterAlreadyReviewed)\n * Data-only.\n */\nexport class ChecklistScan {\n defined: ChecklistDefinition[]; // X\n applicable: RequiredChecklist[]; // N\n reviewed: RequiredChecklist[]; // N − Z: already have a passing/warned/overridden review-<id>.json\n outstanding: RequiredChecklist[]; // Z (== applicable when not filtering)\n context: ChecklistReviewContext; // fork-point sha + pr-context.json path\n summaryPath: string; // the branch's summary.json; verdict files sit beside it\n forkPoint: string; // '' when no fork point resolved\n // ALL X, matched or not, with why — what the PR comment publishes as its roster. Skipped checklists are\n // absent from `applicable` by construction, and recovering them downstream would mean a second\n // changed-file computation with different semantics (see the class comment).\n roster: ChecklistRoster;\n // Verdict files that exist but cannot be read as a verdict (e.g. still using the removed `success`).\n // Carried on the SCAN because wp-finish-upsert-pr refuses on missing reviewers before it ever parses\n // summary.json — a complaint raised only in there would never reach the AI.\n formatErrors: string[];\n /**\n * The basis the matching ACTUALLY ran against. Carried out so a caller that materializes the diff\n * (stage ②) reuses the identical range instead of resolving its own — two independent resolutions is\n * exactly how the changed-file set and the printed `git diff` command came to disagree.\n */\n basis: DiffBasis;\n changedFiles: string[]; // the full changed-file set the matching ran against\n /**\n * The verdict files the scan ALREADY read, carried out rather than dropped.\n *\n * `outstanding` answers \"who still owes a verdict?\" but not \"why\" — and the two reasons demand opposite\n * actions from the reader: a reviewer that never ran must be SPAWNED, a reviewer that ran and REFUSED\n * must not be (it will refuse again; the finding has to be fixed first). Telling them apart means\n * resolving each checklist's verdict, and without the results here every caller either re-reads the same\n * files off disk — a second read that can disagree with this one — or merges the two cases into one\n * message, which is exactly the loop this field exists to break.\n */\n results: ChecklistResult[];\n /**\n * The OPTIONAL (`required: false`) applicable checklists carrying no verdict file — i.e. nobody ran them.\n *\n * Deliberately NOT in `outstanding` when filtering: that is the exemption that makes `required: false`\n * mean something. Carried out as its own set rather than merely subtracted, because both readers need it\n * BY NAME and neither can recover it from what is left: stage ② offers exactly these to the human, and\n * the PR dashboard must publish them as \"not run\" rather than let a shorter roster imply everything\n * passed. An optional checklist that ran and went RED is absent from here and stays in `outstanding`.\n */\n optionalNotRun: RequiredChecklist[];\n /**\n * TRUE when either this machine's `experimental.turnOffAllReviewers` switch is on or the project sets\n * `commands.pr-gate.reviewerAgents: 0`, and therefore when `applicable`, `reviewed`,\n * `outstanding`, `results`, `optionalNotRun` and `formatErrors` above are ALL EMPTY BY DECREE rather\n * than because nothing matched. Those two states are indistinguishable from the empty lists alone,\n * and telling them apart is the entire reason this field exists: an unreviewed PR must never render\n * as a reviewed one.\n *\n * `defined`, `roster`, `basis`, `changedFiles` and `context` are deliberately left INTACT under\n * suppression, so every reader can still say WHAT was switched off — including which REQUIRED\n * checklists would otherwise have run.\n *\n * See `HOME_KEY_TURN_OFF_ALL_REVIEWERS` in rules-config for the flag's contract; it is an\n * `experimental.*` flag, so only a human ever ends it.\n */\n reviewersDisabled: boolean;\n /**\n * The checklists that WOULD have been `applicable` had the reviewers not been suppressed — required\n * ones included. EMPTY on every ordinary run, and empty is not ambiguous there because\n * `reviewersDisabled` is false.\n *\n * Carried by NAME and not as a count because every reader needs a different slice of it: stage ②\n * prints them so a human can see exactly which required reviewer was killed, the dashboard names them\n * in the 1st comment, and the compact PR body needs only `.length`. Recomputing any of that\n * downstream would mean a second changed-file computation that can disagree with this one.\n */\n suppressed: RequiredChecklist[];\n /**\n * How every EXISTING verdict file stands (issue #863): CURRENT (submitted through `wp-write-review` and\n * its checklist's in-scope diff is unchanged — it carries), STALE (in-scope diff changed since — re-brief)\n * or REJECTED (no bin provenance, or edited after submission — it is not a review). A REJECTED verdict,\n * and a STALE green or yellow one, is left OUT of `results`, so it is owed like one that never ran; a\n * stale RED stays in `results` and keeps refusing. Empty under suppression.\n */\n standings: VerdictStanding[];\n /** checklist id → ChecklistScopeHasher's hash of its in-scope diff NOW. Recorded in the stage-② receipt. */\n scopeHashes: Record<string, string>;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n defined: ChecklistDefinition[],\n applicable: RequiredChecklist[],\n reviewed: RequiredChecklist[],\n outstanding: RequiredChecklist[],\n context: ChecklistReviewContext,\n summaryPath: string,\n forkPoint: string,\n roster: ChecklistRoster,\n formatErrors: string[],\n // REQUIRED, and placed BEFORE the defaulted tail deliberately. A defaulted `reviewersDisabled =\n // false` would let every existing construction keep compiling while asserting, silently, that no\n // reviewer was switched off — the widening-by-omission `.claude/rules/no-backwards-compat.md`\n // rejects, and on the one field whose whole job is to stop an unreviewed PR reading as reviewed.\n reviewersDisabled: boolean,\n suppressed: RequiredChecklist[],\n basis: DiffBasis = new DiffBasis(),\n changedFiles: string[] = [],\n // Defaulted so a caller that only cares about the X/N/Z counts (and every existing test construction)\n // stays a one-liner; the scanner itself always passes the real set.\n results: ChecklistResult[] = [],\n optionalNotRun: RequiredChecklist[] = [],\n ) {\n this.defined = defined;\n this.applicable = applicable;\n this.reviewed = reviewed;\n this.outstanding = outstanding;\n this.context = context;\n this.summaryPath = summaryPath;\n this.forkPoint = forkPoint;\n this.roster = roster;\n this.formatErrors = formatErrors;\n this.reviewersDisabled = reviewersDisabled;\n this.suppressed = suppressed;\n this.basis = basis;\n this.changedFiles = changedFiles;\n this.results = results;\n this.optionalNotRun = optionalNotRun;\n this.standings = [];\n this.scopeHashes = {};\n }\n}\n\n/**\n * The ONE computation of which reviewer subagents a branch owes, shared by `wp-review-upsert-pr` (which lists) and\n * `wp-finish-upsert-pr` (which blocks). They previously each assembled this from the same parts in slightly\n * different ways, and any divergence means the command that reports and the command that gates disagree.\n *\n * Two properties are deliberate and load-bearing:\n *\n * 1. **The base is the FORK POINT of main, computed directly** — never `DiffScope.resolveBase`, which\n * overlays `NX_BASE`/`NX_HEAD` from the environment. That made review coverage depend on an env var.\n * It now arrives via {@link DiffBasisResolver}, which injects ForkPoint; same sha, one resolution.\n * 2. **UNCOMMITTED work counts.** `getChangedFiles` is called with NO head, which is the branch of it that\n * diffs base → WORKING TREE and unions in untracked files. Passing a head would diff commit-to-commit and\n * silently miss staged, unstaged and untracked changes — so a checklist matching only uncommitted files\n * would never fire and its reviewer would never be listed.\n * 3. **The range and the command it prints are the SAME basis.** Property 2 used to be true of the file set\n * only: reviewers were handed `git diff <base> HEAD`, which on a dirty tree covers a different range and\n * prints nothing. Both now derive from one {@link DiffBasis}, carried on the scan so a materializing\n * caller cannot re-resolve and drift.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ChecklistScanner {\n constructor(\n private readonly aiBranchName: AiBranchName,\n private readonly checklistDetector: ChecklistDetector,\n private readonly diffScope: DiffScope,\n private readonly diffBasisResolver: DiffBasisResolver,\n private readonly prContextWriter: PrContextWriter,\n private readonly reviewJsonService: ReviewJsonService,\n // Injected BY TYPE (no Symbol token, per CLAUDE.md) so the ONE reviewer kill switch is read in the\n // ONE place that computes what a branch owes — see the suppression note on `scan`.\n private readonly homeConfig: HomeConfigService,\n private readonly scopeHasher: ChecklistScopeHasher,\n private readonly verdictProvenance: VerdictProvenanceService,\n ) {}\n\n /**\n * `defined` is the caller's ALREADY-VALIDATED `prGate.checklists`. The scanner deliberately does not load\n * config itself: `loadAndValidate` is the one gate on the checklist set (it rejects a non-array\n * `checklists`, including the removed `{ doc }` manifest shape, and verifies every guidance doc and\n * reviewer-agent file exists), both callers already run it for other fields, and keeping the read out of\n * here leaves this a function of its inputs rather than of the filesystem.\n */\n scan(repoRoot: string, defined: ChecklistDefinition[], opts: ChecklistScanOptions): ChecklistScan {\n const featureName = this.aiBranchName.getFeatureName();\n const summaryPath = summaryJsonPath(repoRoot, featureName);\n // ONE basis for the file set, the reproduce command and any downstream materialization. The fork\n // point still comes from ForkPoint (never DiffScope.resolveBase) — DiffBasisResolver injects it.\n const basis = this.diffBasisResolver.resolve(repoRoot);\n const base = basis.base;\n // ONE changed-file computation feeds both the roster (all X) and the applicable set (N). `detect` is\n // pure and defined as the roster minus its empty entries, so the two cannot disagree about a match.\n const changedFiles = this.changedFiles(repoRoot, base);\n const roster = new ChecklistRoster(\n this.checklistDetector.roster(defined, changedFiles), changedFiles.length, base !== '');\n const matched = this.checklistDetector.toRequired(this.checklistDetector.detect(defined, changedFiles));\n // THE ONE CHOKE POINT for both reviewer opt-outs. Suppressing HERE — rather than in\n // `wp-review-upsert-pr` and again in `wp-finish-upsert-pr` — is what keeps the command that LISTS\n // and the command that BLOCKS in agreement by construction, which is this class's whole reason for\n // existing. A second check in either command would be a second answer to one question.\n const context = opts.contextStage === ''\n ? this.prContextWriter.contextFor(repoRoot, featureName, basis)\n : this.prContextWriter.ensure(repoRoot, featureName, basis, opts.contextStage, changedFiles);\n const homeConfig = this.homeConfig.load();\n const projectDisabled = defined.some((d: ChecklistDefinition): boolean => d.reviewer.maxAgents === 0);\n if (homeConfig.turnOffAllReviewers || projectDisabled) {\n // EMPTY: applicable, reviewed, outstanding, formatErrors, results, optionalNotRun. INTACT:\n // defined, roster, basis, changedFiles, context — so every downstream reader can still say\n // WHAT was suppressed, which is the difference between an honest record and a silent one.\n return new ChecklistScan(\n defined, [], [], [], context, summaryPath, base, roster, [], true, matched, basis,\n changedFiles, [], []);\n }\n const applicable = matched;\n const scopeHashes = this.scopeHasher.hashes(repoRoot, basis, applicable);\n const loaded = this.reviewJsonService.loadChecklistResults(summaryPath, applicable);\n const standings = this.standingsOf(summaryPath, loaded, scopeHashes);\n const results = this.liveResults(loaded, standings);\n const stillOwed = this.reviewJsonService.pendingChecklists(applicable, results);\n const owedIds = new Set(stillOwed.map((r: RequiredChecklist): string => r.id));\n // NOT `!owedIds.has(...)`-with-the-optional-exemption-folded-in: an optional checklist nobody ran is\n // neither reviewed nor blocking, and calling it \"reviewed\" would put a ✓ on the dashboard for a review\n // that never happened.\n const reviewed = applicable.filter((r: RequiredChecklist): boolean => !owedIds.has(r.id));\n const optionalNotRun = this.reviewJsonService.optionalWithoutVerdict(applicable, results);\n const scan = new ChecklistScan(\n defined,\n applicable,\n reviewed,\n opts.filterAlreadyReviewed ? this.blocking(stillOwed, optionalNotRun) : applicable,\n context,\n summaryPath,\n base,\n roster,\n this.reviewJsonService.checklistFormatErrors(applicable, results),\n false,\n [],\n basis,\n changedFiles,\n results,\n optionalNotRun,\n );\n scan.standings = standings;\n scan.scopeHashes = scopeHashes;\n return scan;\n }\n\n /**\n * Judge every READABLE verdict against its bin provenance and the in-scope diff as it is now. A file\n * with a format problem is left to the format complaint, which names the fix; it is not assessed.\n */\n // eslint-disable-next-line @typescript-eslint/max-params\n private standingsOf(\n summaryPath: string, loaded: readonly ChecklistResult[], scopeHashes: Record<string, string>,\n ): VerdictStanding[] {\n return loaded\n .filter((r: ChecklistResult): boolean => r.problem === '')\n .map((r: ChecklistResult): VerdictStanding =>\n this.verdictProvenance.assess(summaryPath, r, scopeHashes[r.id] ?? ''));\n }\n\n /**\n * The verdicts that still COUNT. A rejected one never does. A stale green or yellow judged code that\n * has since changed, so it is owed again; a stale RED still refuses — a refusal is not lifted by\n * changing other code in its scope, only by a fresh verdict — and it is re-briefed anyway because it\n * is red.\n */\n private liveResults(loaded: readonly ChecklistResult[], standings: readonly VerdictStanding[]): ChecklistResult[] {\n const dropped = new Set(standings\n .filter((s: VerdictStanding): boolean =>\n s.standing === STANDING_REJECTED || (s.standing === STANDING_STALE && s.status !== VERDICT_RED))\n .map((s: VerdictStanding): string => s.checklistId));\n return loaded.filter((r: ChecklistResult): boolean => !dropped.has(r.id));\n }\n\n /**\n * What `wp-finish-upsert-pr` actually REFUSES on: everything still owing a verdict, minus the optional\n * checklists nobody ran.\n *\n * The subtraction happens HERE — in the one place `outstanding` is computed — and not in the gate, so\n * there is a single answer to \"does this branch owe review?\". When the gate did its own filtering, the\n * command that lists and the command that blocks were two implementations of the same question, which is\n * exactly the divergence this class's docstring exists to prevent.\n */\n private blocking(stillOwed: readonly RequiredChecklist[], optionalNotRun: readonly RequiredChecklist[]): RequiredChecklist[] {\n const skipped = new Set(optionalNotRun.map((r: RequiredChecklist): string => r.id));\n return stillOwed.filter((r: RequiredChecklist): boolean => !skipped.has(r.id));\n }\n\n /**\n * Every file changed since the fork point, INCLUDING uncommitted and untracked ones. Two non-default\n * options, both load-bearing:\n *\n * `tsOnly:false` — the default drops every *.sql / Dockerfile / .env* file a checklist most wants\n * to key on, which would silently shrink the set a reviewer is pointed at.\n * `includeDeletions:true` — the default is `--diff-filter=d`, so a DELETED file is invisible. A PR that\n * deletes a migration, an auth check or a terraform rule changed exactly what a\n * checklist exists to catch, and under the default no checklist fires at all.\n */\n private changedFiles(repoRoot: string, base: string): string[] {\n if (base === '') return [];\n const opts = new ChangedFilesOptions();\n opts.tsOnly = false;\n opts.includeDeletions = true;\n // No head argument — see the class comment. This is what includes the working tree.\n return this.diffScope.getChangedFiles(repoRoot, base, undefined, opts);\n }\n}\n"]}
@@ -45,6 +45,8 @@ class RepoConfigFixture {
45
45
  delete commands['pr-gate']['checklists'];
46
46
  delete commands['pr-gate']['checklistsWhy'];
47
47
  const prGate = commands['pr-gate'];
48
+ // Local source requires this before the published validator permits the live repo to add it.
49
+ prGate['maxReviewerRounds'] = 2;
48
50
  if (prGate['overrideReviewerAgent'] !== true && prGate['reviewerAgentName'] === rules_config_1.DEFAULT_REVIEWER_AGENT_NAME) {
49
51
  delete prGate['reviewerAgentName'];
50
52
  }
@@ -1 +1 @@
1
- {"version":3,"file":"repo-config-testkit.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/repo-config-testkit.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;AAE7B,0DAEiC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAa,iBAAiB;IAC1B,iGAAiG;IACjG,mGAAmG;IACnG,IAAI;QACA,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,uBAAuB,CAAC,CAAC;QACjG,mFAAmF;QACnF,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAA4B,CAAC;QACtF,mEAAmE;QACnE,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAA4C,CAAC;QAC/E,OAAO,QAAQ,CAAC,SAAS,CAAC,CAAC,YAAY,CAAC,CAAC;Q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AAC;QACzD,sEAAsE;QACtE,MAAM,MAAM,GAAG,MAAM,CAAC,YAAY,CAA4B,CAAC;QAC/D,KAAK,MAAM,IAAI,IAAI,IAAA,2BAAY,GAAE,EAAE,CAAC;YAChC,MAAM,OAAO,GAAG,IAAA,6BAAc,EAAC,IAAI,CAAC,KAAK,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;YACvE,MAAM,IAAI,GAAG,IAAA,+BAAgB,EAAC,IAAI,CAAC,CAAC;YACpC,iGAAiG;YACjG,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAwC,CAAC;YACtE,OAAO,CAAC,IAAI,CAAC,GAAG,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,EAAE,CAAC;QAC7E,CAAC;IACL,CAAC;CACJ;AArDD,8CAqDC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\n\nimport {\n allRuleNames, DEFAULT_REVIEWER_AGENT_NAME, retiredRuleFor, sectionForRule, seedEntryForRule,\n} from '@webpieces/rules-config';\n\n/**\n * THIS repo's own `webpieces.config.json`, prepared for use inside a temp clone.\n *\n * Specs that exercise a command end-to-end need a config the REAL validator accepts, and using the\n * repo's own file (rather than a hand-rolled minimal one) is what keeps them honest — a stub drifts out\n * from under the validator on the next config change. These adjustments are needed to make that file\n * usable outside this checkout, and all are the same for every such spec, so they live here once:\n *\n * 1. `checklists` is dropped. Its `doc` paths are validated REPO-RELATIVE and point at\n * `.claude/review/*.md`, which exist here and not in a temp clone.\n * 2. Every locally-known rule is completed from its SEED. The repo's config is validated by the PUBLISHED\n * validator and therefore lags local source by one release\n * (`.claude/rules/published-vs-local-source.md`): a rule added in this working tree cannot get a\n * config entry or newly-required field until its release ships,\n * while the LOCAL validator a spec runs already demands one. Without this, adding any rule turns\n * these specs red for exactly one release — a failure that says nothing about the code under test.\n * 3. Every RETIRED rule entry is dropped — the same one-release lag pointing the other way. When a rule\n * is retired in this working tree, the repo's config must KEEP its entry until the release carrying\n * the retirement ships (deleting it early would fail the published validator and block every Bash\n * call), while the LOCAL validator already REJECTS it. Same trade as (2), same fix.\n * 4. A `commands.pr-gate.reviewerAgentName` naming the webpieces default WITHOUT `overrideReviewerAgent`\n * is dropped — the same one-release lag again (issue #947). The published validator still REQUIRES the\n * key, so the repo's config must carry it until the release making it optional ships, while the LOCAL\n * validator already rejects a name without the override. A follow-up PR removes it from the live config.\n *\n * A testkit, not product code: nothing in a published bin imports it (same role as ai-hook-rules'\n * `shim-testkit.ts`).\n */\nexport class RepoConfigFixture {\n /** The repo's config as a mutable object, checklists dropped and local seed fields completed. */\n // webpieces-disable no-any-unknown -- the repo's own config document, opaque until a spec edits it\n load(): Record<string, unknown> {\n const source = path.join(__dirname, '..', '..', '..', '..', '..', '..', 'webpieces.config.json');\n // webpieces-disable no-any-unknown -- parsed JSON, narrowed by the accessors below\n const config = JSON.parse(fs.readFileSync(source, 'utf8')) as Record<string, unknown>;\n // webpieces-disable no-any-unknown -- narrowing one nested section\n const commands = config['commands'] as Record<string, Record<string, unknown>>;\n delete commands['pr-gate']['checklists'];\n delete commands['pr-gate']['checklistsWhy'];\n const prGate = commands['pr-gate'];\n if (prGate['overrideReviewerAgent'] !== true && prGate['reviewerAgentName'] === DEFAULT_REVIEWER_AGENT_NAME) {\n delete prGate['reviewerAgentName'];\n }\n this.dropRetiredRules(config);\n this.completeRulesFromSeed(config);\n return config;\n }\n\n // Drop every rule/guard name this build knows to be RETIRED, from whichever section holds it.\n // webpieces-disable no-any-unknown -- see load()\n private dropRetiredRules(config: Record<string, unknown>): void {\n for (const section of ['rules', 'hookGuards']) {\n // webpieces-disable no-any-unknown -- narrowing one rule section\n const entries = config[section] as Record<string, unknown> | undefined;\n if (entries === undefined) continue;\n for (const name of Object.keys(entries)) {\n if (retiredRuleFor(name) !== null) delete entries[name];\n }\n }\n }\n\n /** Write `config` (usually a `load()` result a spec has edited) as the config of `dir`. */\n // webpieces-disable no-any-unknown -- see load()\n writeTo(dir: string, config: Record<string, unknown>): void {\n fs.writeFileSync(path.join(dir, 'webpieces.config.json'), JSON.stringify(config, null, 4) + '\\n');\n }\n\n // webpieces-disable no-any-unknown -- see load()\n private completeRulesFromSeed(config: Record<string, unknown>): void {\n // webpieces-disable no-any-unknown -- narrowing the two rule sections\n const rules = config['rules'] as Record<string, unknown>;\n // webpieces-disable no-any-unknown -- narrowing the two rule sections\n const guards = config['hookGuards'] as Record<string, unknown>;\n for (const name of allRuleNames()) {\n const section = sectionForRule(name) === 'hookGuards' ? guards : rules;\n const seed = seedEntryForRule(name);\n // webpieces-disable no-any-unknown -- one rule's opaque config entry, merged over its typed seed\n const existing = section[name] as Record<string, unknown> | undefined;\n section[name] = existing === undefined ? seed : { ...seed, ...existing };\n }\n }\n}\n"]}
1
+ {"version":3,"file":"repo-config-testkit.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/repo-config-testkit.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;AAE7B,0DAEiC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAa,iBAAiB;IAC1B,iGAAiG;IACjG,mGAAmG;IACnG,IAAI;QACA,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,uBAAuB,CAAC,CAAC;QACjG,mFAAmF;QACnF,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAA4B,CAAC;QACtF,mEAAmE;QACnE,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAA4C,CAAC;QAC/E,OAAO,QAAQ,CAAC,SAAS,CAAC,CAAC,YAAY,CAAC,CAAC;QACzC,OAAO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AAsE;QACtE,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAA4B,CAAC;QACzD,sEAAsE;QACtE,MAAM,MAAM,GAAG,MAAM,CAAC,YAAY,CAA4B,CAAC;QAC/D,KAAK,MAAM,IAAI,IAAI,IAAA,2BAAY,GAAE,EAAE,CAAC;YAChC,MAAM,OAAO,GAAG,IAAA,6BAAc,EAAC,IAAI,CAAC,KAAK,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;YACvE,MAAM,IAAI,GAAG,IAAA,+BAAgB,EAAC,IAAI,CAAC,CAAC;YACpC,iGAAiG;YACjG,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAwC,CAAC;YACtE,OAAO,CAAC,IAAI,CAAC,GAAG,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,EAAE,CAAC;QAC7E,CAAC;IACL,CAAC;CACJ;AAvDD,8CAuDC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\n\nimport {\n allRuleNames, DEFAULT_REVIEWER_AGENT_NAME, retiredRuleFor, sectionForRule, seedEntryForRule,\n} from '@webpieces/rules-config';\n\n/**\n * THIS repo's own `webpieces.config.json`, prepared for use inside a temp clone.\n *\n * Specs that exercise a command end-to-end need a config the REAL validator accepts, and using the\n * repo's own file (rather than a hand-rolled minimal one) is what keeps them honest — a stub drifts out\n * from under the validator on the next config change. These adjustments are needed to make that file\n * usable outside this checkout, and all are the same for every such spec, so they live here once:\n *\n * 1. `checklists` is dropped. Its `doc` paths are validated REPO-RELATIVE and point at\n * `.claude/review/*.md`, which exist here and not in a temp clone.\n * 2. Every locally-known rule is completed from its SEED. The repo's config is validated by the PUBLISHED\n * validator and therefore lags local source by one release\n * (`.claude/rules/published-vs-local-source.md`): a rule added in this working tree cannot get a\n * config entry or newly-required field until its release ships,\n * while the LOCAL validator a spec runs already demands one. Without this, adding any rule turns\n * these specs red for exactly one release — a failure that says nothing about the code under test.\n * 3. Every RETIRED rule entry is dropped — the same one-release lag pointing the other way. When a rule\n * is retired in this working tree, the repo's config must KEEP its entry until the release carrying\n * the retirement ships (deleting it early would fail the published validator and block every Bash\n * call), while the LOCAL validator already REJECTS it. Same trade as (2), same fix.\n * 4. A `commands.pr-gate.reviewerAgentName` naming the webpieces default WITHOUT `overrideReviewerAgent`\n * is dropped — the same one-release lag again (issue #947). The published validator still REQUIRES the\n * key, so the repo's config must carry it until the release making it optional ships, while the LOCAL\n * validator already rejects a name without the override. A follow-up PR removes it from the live config.\n *\n * A testkit, not product code: nothing in a published bin imports it (same role as ai-hook-rules'\n * `shim-testkit.ts`).\n */\nexport class RepoConfigFixture {\n /** The repo's config as a mutable object, checklists dropped and local seed fields completed. */\n // webpieces-disable no-any-unknown -- the repo's own config document, opaque until a spec edits it\n load(): Record<string, unknown> {\n const source = path.join(__dirname, '..', '..', '..', '..', '..', '..', 'webpieces.config.json');\n // webpieces-disable no-any-unknown -- parsed JSON, narrowed by the accessors below\n const config = JSON.parse(fs.readFileSync(source, 'utf8')) as Record<string, unknown>;\n // webpieces-disable no-any-unknown -- narrowing one nested section\n const commands = config['commands'] as Record<string, Record<string, unknown>>;\n delete commands['pr-gate']['checklists'];\n delete commands['pr-gate']['checklistsWhy'];\n const prGate = commands['pr-gate'];\n // Local source requires this before the published validator permits the live repo to add it.\n prGate['maxReviewerRounds'] = 2;\n if (prGate['overrideReviewerAgent'] !== true && prGate['reviewerAgentName'] === DEFAULT_REVIEWER_AGENT_NAME) {\n delete prGate['reviewerAgentName'];\n }\n this.dropRetiredRules(config);\n this.completeRulesFromSeed(config);\n return config;\n }\n\n // Drop every rule/guard name this build knows to be RETIRED, from whichever section holds it.\n // webpieces-disable no-any-unknown -- see load()\n private dropRetiredRules(config: Record<string, unknown>): void {\n for (const section of ['rules', 'hookGuards']) {\n // webpieces-disable no-any-unknown -- narrowing one rule section\n const entries = config[section] as Record<string, unknown> | undefined;\n if (entries === undefined) continue;\n for (const name of Object.keys(entries)) {\n if (retiredRuleFor(name) !== null) delete entries[name];\n }\n }\n }\n\n /** Write `config` (usually a `load()` result a spec has edited) as the config of `dir`. */\n // webpieces-disable no-any-unknown -- see load()\n writeTo(dir: string, config: Record<string, unknown>): void {\n fs.writeFileSync(path.join(dir, 'webpieces.config.json'), JSON.stringify(config, null, 4) + '\\n');\n }\n\n // webpieces-disable no-any-unknown -- see load()\n private completeRulesFromSeed(config: Record<string, unknown>): void {\n // webpieces-disable no-any-unknown -- narrowing the two rule sections\n const rules = config['rules'] as Record<string, unknown>;\n // webpieces-disable no-any-unknown -- narrowing the two rule sections\n const guards = config['hookGuards'] as Record<string, unknown>;\n for (const name of allRuleNames()) {\n const section = sectionForRule(name) === 'hookGuards' ? guards : rules;\n const seed = seedEntryForRule(name);\n // webpieces-disable no-any-unknown -- one rule's opaque config entry, merged over its typed seed\n const existing = section[name] as Record<string, unknown> | undefined;\n section[name] = existing === undefined ? seed : { ...seed, ...existing };\n }\n }\n}\n"]}
@@ -58,9 +58,10 @@ export declare class ReviewReportInput {
58
58
  * WHICH required reviewer was killed.
59
59
  */
60
60
  suppressed: RequiredChecklist[];
61
- singleRoundReview: boolean;
62
- singleRoundRepeat: boolean;
63
- singleRoundReviewers: string[];
61
+ round: number;
62
+ maxReviewerRounds: number;
63
+ roundAction: string;
64
+ redChecklistIds: string[];
64
65
  reviewer: ReviewerAgentPolicy;
65
66
  /**
66
67
  * How every existing verdict stands (issue #863) — straight off the scan. A CURRENT one is printed as
@@ -193,7 +194,9 @@ export declare class ReviewReport {
193
194
  */
194
195
  private nextSteps;
195
196
  private writeSummaryStep;
196
- private singleRoundRepeatStep;
197
+ private fixStep;
198
+ private recordStep;
199
+ private cappedFinishStep;
197
200
  /**
198
201
  * The REQUIRED reviewers — one copy-paste block each, and nothing at all when none is owed. The prompt is
199
202
  * deliberately a POINTER and nothing else: the generated instructions file is the contract, so anything
@@ -7,6 +7,7 @@ const inversify_1 = require("inversify");
7
7
  const rules_config_1 = require("@webpieces/rules-config");
8
8
  const checklist_notice_1 = require("./checklist-notice");
9
9
  const verdict_provenance_1 = require("./verdict-provenance");
10
+ const review_round_state_1 = require("./review-round-state");
10
11
  const SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n';
11
12
  /**
12
13
  * One reviewer that ALREADY ANSWERED on this branch and refused, with the refusal rendered by
@@ -69,9 +70,10 @@ class ReviewReportInput {
69
70
  * WHICH required reviewer was killed.
70
71
  */
71
72
  suppressed;
72
- singleRoundReview;
73
- singleRoundRepeat;
74
- singleRoundReviewers;
73
+ round;
74
+ maxReviewerRounds;
75
+ roundAction;
76
+ redChecklistIds;
75
77
  // The reviewer agent (webpieces-reviewer, or the overrideReviewerAgent name) + reviewerAgents: which agent
76
78
  // type to spawn, and the per-round cap.
77
79
  reviewer;
@@ -93,9 +95,10 @@ class ReviewReportInput {
93
95
  this.skipOptional = false;
94
96
  this.reviewersSuppressed = false;
95
97
  this.suppressed = [];
96
- this.singleRoundReview = false;
97
- this.singleRoundRepeat = false;
98
- this.singleRoundReviewers = [];
98
+ this.round = 1;
99
+ this.maxReviewerRounds = 1;
100
+ this.roundAction = '';
101
+ this.redChecklistIds = [];
99
102
  this.reviewer = new rules_config_1.ReviewerAgentPolicy('', rules_config_1.REVIEWER_AGENTS_PLACEHOLDER);
100
103
  this.standings = [];
101
104
  }
@@ -148,15 +151,19 @@ let ReviewReport = class ReviewReport {
148
151
  * single line most likely to make it do exactly that.
149
152
  */
150
153
  header(input) {
151
- if (input.singleRoundRepeat)
152
- return '② ⏭️ SINGLE-ROUND REVIEW ALREADY STARTED — skip reviews and finish\n';
154
+ if (input.roundAction === review_round_state_1.ROUND_ACTION_FIX)
155
+ return `② ⛔ GLOBAL REVIEW ROUND ${input.round} OF ${input.maxReviewerRounds} IS RED — remediate it\n`;
156
+ if (input.roundAction === review_round_state_1.ROUND_ACTION_RECORD)
157
+ return `② ⛔ GLOBAL REVIEW ROUND ${input.round} OF ${input.maxReviewerRounds} — record the committed remediation\n`;
158
+ if (input.roundAction === review_round_state_1.ROUND_ACTION_FINISH)
159
+ return `② ✅ GLOBAL REVIEW ROUND ${input.round} OF ${input.maxReviewerRounds} COMPLETE — finish\n`;
153
160
  // FIRST, and unconditional: with the kill switch on there is nothing to spawn and nothing to
154
161
  // offer, so every heading below would be true-but-misleading. The one thing a reader must take
155
162
  // from the first line of this block is that no reviewer looked at this branch.
156
163
  if (input.reviewersSuppressed)
157
164
  return '② ⚫ ALL REVIEWERS SUPPRESSED — write the PR summary, then finish\n';
158
165
  if (this.requiredOwed(input).length > 0)
159
- return '② Write the PR summary, spawn subagent reviewers, then finish\n';
166
+ return `② GLOBAL REVIEW ROUND ${input.round} OF ${input.maxReviewerRounds} — write the PR summary, spawn reviewers, then finish\n`;
160
167
  if (this.offerableOwed(input).length > 0)
161
168
  return '② Write the PR summary, offer the optional reviewers, then finish\n';
162
169
  return '② Write the PR summary, then finish\n';
@@ -167,11 +174,6 @@ let ReviewReport = class ReviewReport {
167
174
  * mistaken for the next action.
168
175
  */
169
176
  scanVerdict(input) {
170
- if (input.singleRoundRepeat) {
171
- return '\n⏭️ `singleRoundReview: true` is enabled and this branch already used its one review round.\n'
172
- + ` Recorded reviewer(s): ${input.singleRoundReviewers.join(', ')}\n`
173
- + ' DO NOT spawn or re-spawn any reviewer, regardless of later edits or an earlier red.\n';
174
- }
175
177
  // BEFORE the zero-applicable notice, which would otherwise say "nothing matched this diff" — the
176
178
  // single most misleading sentence available here, because plenty matched and every one of them was
177
179
  // switched off.
@@ -341,14 +343,18 @@ let ReviewReport = class ReviewReport {
341
343
  * can never drift from the shape `wp-finish-upsert-pr` validates.
342
344
  */
343
345
  nextSteps(input) {
344
- if (input.singleRoundRepeat)
345
- return this.singleRoundRepeatStep();
346
+ if (input.roundAction === review_round_state_1.ROUND_ACTION_FIX)
347
+ return this.fixStep(input);
348
+ if (input.roundAction === review_round_state_1.ROUND_ACTION_RECORD)
349
+ return this.recordStep(input);
350
+ if (input.roundAction === review_round_state_1.ROUND_ACTION_FINISH)
351
+ return this.cappedFinishStep(input);
346
352
  const required = this.requiredOwed(input);
347
353
  const offerable = this.offerableOwed(input);
348
354
  // Numbered by what is actually PRINTED, so the numbers a reader sees are 1..n with no gaps: write
349
355
  // summary.json, then a spawn step only if anything must run, then an offer step only if anything may.
350
356
  let step = 1;
351
- const write = this.writeSummaryStep(input.summaryPath, step++, input.singleRoundReview ? rules_config_1.SINGLE_ROUND_MAIN_AGENT_INSTRUCTIONS : '');
357
+ const write = this.writeSummaryStep(input.summaryPath, step++, '');
352
358
  // The wait block goes under the LAST reviewer-listing step, and only there. Printed under both
353
359
  // it would be two "what to do next" instructions in one output, which is the defect this
354
360
  // method's docstring describes — an agent reading top to bottom obeys the first one it meets.
@@ -366,13 +372,27 @@ let ReviewReport = class ReviewReport {
366
372
  ' stage, into judging the PREVIOUS run\'s summary of code that has since changed.\n\n' +
367
373
  (0, rules_config_1.summaryJsonSchemaHint)(summaryPath, mainAgentInstructions) + '\n\n');
368
374
  }
369
- singleRoundRepeatStep() {
370
- return '\n' + SEP
371
- + '▶ NEXT — reviewers have already run once. SKIP reviews and run:\n' + SEP + '\n'
372
- + ' pnpm wp-finish-upsert-pr\n\n'
373
- + ' Do NOT invoke or re-run reviewer subagents. They are expensive and their one verdict\n'
374
- + ' remains the review record for this PR. If a red remains, finish will block and tell you\n'
375
- + ' how to fix it without another reviewer round.\n\n';
375
+ fixStep(input) {
376
+ return '\n' + SEP + `▶ NEXT — fix every finding from round ${input.round} of ${input.maxReviewerRounds}\n` + SEP + '\n'
377
+ + ` Red checklist(s): ${input.redChecklistIds.join(', ')}\n`
378
+ + ' Commit every fix and leave the tree clean, then record one response per checklist with:\n'
379
+ + ' pnpm wp-write-review-fixes\n'
380
+ + ' Re-run pnpm wp-review-upsert-pr after that. It will start a focused remediation-only round\n'
381
+ + ' only when the configured round budget still has room.\n';
382
+ }
383
+ recordStep(input) {
384
+ return '\n' + SEP + `▶ NEXT — record the committed fixes for round ${input.round} of ${input.maxReviewerRounds}\n` + SEP + '\n'
385
+ + ' pnpm wp-write-review-fixes\n\n'
386
+ + ' The command stamps the reviewed HEAD and current clean HEAD itself. Then re-run\n'
387
+ + ' pnpm wp-review-upsert-pr; do not edit or recolor the reviewer verdict.\n';
388
+ }
389
+ cappedFinishStep(input) {
390
+ const capped = input.redChecklistIds.length > 0
391
+ ? ` Review cap reached. ${input.redChecklistIds.join(', ')} is author-remediated after the cap and was NOT re-reviewed.\n`
392
+ : '';
393
+ return '\n' + SEP + '▶ NEXT — write summary.json, then finish\n' + SEP + '\n'
394
+ + capped + this.writeSummaryStep(input.summaryPath, 1, '')
395
+ + 'STEP 2 — run: pnpm wp-finish-upsert-pr\n';
376
396
  }
377
397
  /**
378
398
  * The REQUIRED reviewers — one copy-paste block each, and nothing at all when none is owed. The prompt is