@webpieces/pr-gate 0.4.815 → 0.4.817
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.
- package/package.json +3 -3
- package/src/dashboard/author-identity.d.ts +2 -2
- package/src/dashboard/author-identity.js +2 -2
- package/src/dashboard/author-identity.js.map +1 -1
- package/src/dashboard/dashboard.d.ts +5 -5
- package/src/dashboard/dashboard.js +4 -4
- package/src/dashboard/dashboard.js.map +1 -1
- package/src/dashboard/review-identity-renderer.d.ts +1 -1
- package/src/dashboard/review-identity-renderer.js +1 -1
- package/src/dashboard/review-identity-renderer.js.map +1 -1
- package/src/scripts/commands/await-reviews-command.d.ts +2 -2
- package/src/scripts/commands/await-reviews-command.js +6 -6
- package/src/scripts/commands/await-reviews-command.js.map +1 -1
- package/src/scripts/commands/check-pr-command.js +1 -1
- package/src/scripts/commands/check-pr-command.js.map +1 -1
- package/src/scripts/commands/finish-upsert-pr-command.d.ts +4 -4
- package/src/scripts/commands/finish-upsert-pr-command.js +18 -18
- package/src/scripts/commands/finish-upsert-pr-command.js.map +1 -1
- package/src/scripts/commands/land-pr-command.d.ts +3 -3
- package/src/scripts/commands/land-pr-command.js +6 -6
- package/src/scripts/commands/land-pr-command.js.map +1 -1
- package/src/scripts/commands/review-upsert-pr-command.d.ts +2 -2
- package/src/scripts/commands/review-upsert-pr-command.js +5 -5
- package/src/scripts/commands/review-upsert-pr-command.js.map +1 -1
- package/src/scripts/commands/start-update-command.js +1 -1
- package/src/scripts/commands/start-update-command.js.map +1 -1
- package/src/scripts/commands/start-upsert-pr-command.d.ts +3 -3
- package/src/scripts/commands/start-upsert-pr-command.js +7 -7
- package/src/scripts/commands/start-upsert-pr-command.js.map +1 -1
- package/src/scripts/commands/write-review-command.js +1 -1
- package/src/scripts/commands/write-review-command.js.map +1 -1
- package/src/scripts/pr-gate-app.d.ts +1 -1
- package/src/scripts/pr-gate-app.js +1 -1
- package/src/scripts/pr-gate-app.js.map +1 -1
- package/src/scripts/workflow/checklist-detector.js +1 -1
- package/src/scripts/workflow/checklist-detector.js.map +1 -1
- package/src/scripts/workflow/checklist-notice.d.ts +1 -1
- package/src/scripts/workflow/checklist-notice.js +1 -1
- package/src/scripts/workflow/checklist-notice.js.map +1 -1
- package/src/scripts/workflow/checklist-scanner.d.ts +2 -2
- package/src/scripts/workflow/checklist-scanner.js +11 -11
- package/src/scripts/workflow/checklist-scanner.js.map +1 -1
- package/src/scripts/workflow/gated-pr-publisher.d.ts +1 -1
- package/src/scripts/workflow/gated-pr-publisher.js +1 -1
- package/src/scripts/workflow/gated-pr-publisher.js.map +1 -1
- package/src/scripts/workflow/merge-end.d.ts +1 -1
- package/src/scripts/workflow/merge-end.js +2 -2
- package/src/scripts/workflow/merge-end.js.map +1 -1
- package/src/scripts/workflow/open-pr-check.js +1 -1
- package/src/scripts/workflow/open-pr-check.js.map +1 -1
- package/src/scripts/workflow/provenance-enforcer.d.ts +2 -2
- package/src/scripts/workflow/provenance-enforcer.js +6 -6
- package/src/scripts/workflow/provenance-enforcer.js.map +1 -1
- package/src/scripts/workflow/review-report.d.ts +9 -9
- package/src/scripts/workflow/review-report.js +19 -19
- package/src/scripts/workflow/review-report.js.map +1 -1
- package/src/scripts/workflow/review-stage-receipt.d.ts +3 -3
- package/src/scripts/workflow/review-stage-receipt.js +3 -3
- package/src/scripts/workflow/review-stage-receipt.js.map +1 -1
- package/src/scripts/workflow/reviewer-briefing-builder.js +1 -1
- package/src/scripts/workflow/reviewer-briefing-builder.js.map +1 -1
- package/src/scripts/workflow/reviewer-verdict-gate.d.ts +1 -1
- package/src/scripts/workflow/reviewer-verdict-gate.js +6 -6
- package/src/scripts/workflow/reviewer-verdict-gate.js.map +1 -1
- package/src/scripts/workflow/verdict-provenance.d.ts +4 -4
- package/src/scripts/workflow/verdict-provenance.js +10 -10
- package/src/scripts/workflow/verdict-provenance.js.map +1 -1
- package/src/scripts/wp-start-upsert-pr.js +1 -1
- package/src/scripts/wp-start-upsert-pr.js.map +1 -1
|
@@ -39,7 +39,7 @@ exports.RefusedReviewer = RefusedReviewer;
|
|
|
39
39
|
class ReviewReportInput {
|
|
40
40
|
repoRoot;
|
|
41
41
|
featureName;
|
|
42
|
-
|
|
42
|
+
summaryPath; // the branch's summary.json — the file the AI must write next
|
|
43
43
|
definedCount; // how many checklists pr-gate.checklists defines
|
|
44
44
|
applicableCount; // how many of them apply to THIS diff (0 ⇒ the notice, not spawn blocks)
|
|
45
45
|
reviewed; // already have a passing verdict on this branch
|
|
@@ -80,10 +80,10 @@ class ReviewReportInput {
|
|
|
80
80
|
* CARRIED with its sha and the reason; a STALE or REJECTED one is printed with why it was re-briefed.
|
|
81
81
|
*/
|
|
82
82
|
standings;
|
|
83
|
-
constructor(repoRoot, featureName,
|
|
83
|
+
constructor(repoRoot, featureName, summaryPath) {
|
|
84
84
|
this.repoRoot = repoRoot;
|
|
85
85
|
this.featureName = featureName;
|
|
86
|
-
this.
|
|
86
|
+
this.summaryPath = summaryPath;
|
|
87
87
|
this.definedCount = 0;
|
|
88
88
|
this.applicableCount = 0;
|
|
89
89
|
this.reviewed = [];
|
|
@@ -107,14 +107,14 @@ exports.ReviewReportInput = ReviewReportInput;
|
|
|
107
107
|
*
|
|
108
108
|
* Extracted from the command so it can be asserted on as a rendered string, because the ordering IS the
|
|
109
109
|
* contract. The bug it was extracted to fix: the zero-checklist notice ended with "Carry on and run: pnpm
|
|
110
|
-
* wp-finish-upsert-pr", and the block printed directly beneath it said to write
|
|
110
|
+
* wp-finish-upsert-pr", and the block printed directly beneath it said to write summary.json first and
|
|
111
111
|
* finish afterwards. Two next-steps, in the wrong order, and an agent that follows instructions literally —
|
|
112
112
|
* which is the entire reason this command prints them — took the first one and opened a PR with no review.
|
|
113
113
|
* That is precisely the failure the three-stage flow exists to prevent (reported on PR #519).
|
|
114
114
|
*
|
|
115
115
|
* The invariants, enforced by review-report.spec.ts:
|
|
116
116
|
* 1. `wp-finish-upsert-pr` is named as a thing to run EXACTLY ONCE in the whole block.
|
|
117
|
-
* 2. The
|
|
117
|
+
* 2. The summary.json instruction comes BEFORE it — and BEFORE the spawn blocks (see nextSteps).
|
|
118
118
|
* 3. With zero checklists the all-clear precedes any configuration guidance.
|
|
119
119
|
* 4. REQUIRED reviewers are spawned unasked; OPTIONAL ones are only ever OFFERED, in one batched
|
|
120
120
|
* question. The two never share a step, because one instruction says "do it" and the other says
|
|
@@ -154,12 +154,12 @@ let ReviewReport = class ReviewReport {
|
|
|
154
154
|
// offer, so every heading below would be true-but-misleading. The one thing a reader must take
|
|
155
155
|
// from the first line of this block is that no reviewer looked at this branch.
|
|
156
156
|
if (input.reviewersSuppressed)
|
|
157
|
-
return '② ⚫ ALL REVIEWERS SUPPRESSED —
|
|
157
|
+
return '② ⚫ ALL REVIEWERS SUPPRESSED — write the PR summary, then finish\n';
|
|
158
158
|
if (this.requiredOwed(input).length > 0)
|
|
159
|
-
return '②
|
|
159
|
+
return '② Write the PR summary, spawn subagent reviewers, then finish\n';
|
|
160
160
|
if (this.offerableOwed(input).length > 0)
|
|
161
|
-
return '②
|
|
162
|
-
return '②
|
|
161
|
+
return '② Write the PR summary, offer the optional reviewers, then finish\n';
|
|
162
|
+
return '② Write the PR summary, then finish\n';
|
|
163
163
|
}
|
|
164
164
|
/**
|
|
165
165
|
* What the SCAN found: either "nothing applies here" or the already-reviewed / unreadable-verdict lines.
|
|
@@ -292,7 +292,7 @@ let ReviewReport = class ReviewReport {
|
|
|
292
292
|
* then makes it, reasoning (correctly, on the facts) that the carried-forward verdicts judged an earlier
|
|
293
293
|
* tree. Reviews here are once per branch BY CONSTRUCTION: a passing review-<id>.json satisfies its
|
|
294
294
|
* checklist for the branch's whole life, and `wp-finish-upsert-pr` never archives one the way it archives
|
|
295
|
-
*
|
|
295
|
+
* summary.json. So the reuse is deliberate — it is what keeps post-PR iteration from re-paying for every
|
|
296
296
|
* matched reviewer — and the output has to say so, because the alternative reading is the expensive one.
|
|
297
297
|
*
|
|
298
298
|
* The overwrite warning is not decoration. A re-spawned reviewer writes to the SAME verdict path, so a
|
|
@@ -325,11 +325,11 @@ let ReviewReport = class ReviewReport {
|
|
|
325
325
|
* ("Then… Finally…") so that skipping step 1 is visibly skipping a step, and worded so no earlier line
|
|
326
326
|
* can be mistaken for the real next action.
|
|
327
327
|
*
|
|
328
|
-
*
|
|
329
|
-
* This block used to print the spawn blocks first and then say to write
|
|
328
|
+
* summary.json is STEP 1 and the spawn blocks are STEP 2 — that ORDER is the contract, not a preference.
|
|
329
|
+
* This block used to print the spawn blocks first and then say to write summary.json "WHILE any reviewer
|
|
330
330
|
* subagents above are still running", which does not merely permit spawning first, it instructs it.
|
|
331
331
|
* Harmless for a reviewer that only reads the diff; wrong for one that judges the PR's stated INTENT —
|
|
332
|
-
* its title, summary or risk level — because
|
|
332
|
+
* its title, summary or risk level — because summary.json is the only place that intent lives. Such a
|
|
333
333
|
* reviewer either finds no file (a false RED and a wasted reviewer run) or, on a second run of this
|
|
334
334
|
* stage on the same branch, finds the PREVIOUS run's file and validates a title that no longer exists —
|
|
335
335
|
* a false GREEN, with nothing in the output saying which of the two happened. A consuming repo had to
|
|
@@ -346,9 +346,9 @@ let ReviewReport = class ReviewReport {
|
|
|
346
346
|
const required = this.requiredOwed(input);
|
|
347
347
|
const offerable = this.offerableOwed(input);
|
|
348
348
|
// Numbered by what is actually PRINTED, so the numbers a reader sees are 1..n with no gaps: write
|
|
349
|
-
//
|
|
349
|
+
// summary.json, then a spawn step only if anything must run, then an offer step only if anything may.
|
|
350
350
|
let step = 1;
|
|
351
|
-
const write = this.
|
|
351
|
+
const write = this.writeSummaryStep(input.summaryPath, step++, input.singleRoundReview ? rules_config_1.SINGLE_ROUND_MAIN_AGENT_INSTRUCTIONS : '');
|
|
352
352
|
// The wait block goes under the LAST reviewer-listing step, and only there. Printed under both
|
|
353
353
|
// it would be two "what to do next" instructions in one output, which is the defect this
|
|
354
354
|
// method's docstring describes — an agent reading top to bottom obeys the first one it meets.
|
|
@@ -358,13 +358,13 @@ let ReviewReport = class ReviewReport {
|
|
|
358
358
|
+ `▶ NEXT — ${step} steps, in this order. Step 1 is NOT optional:\n` + SEP + '\n'
|
|
359
359
|
+ write + spawn + offer + this.finishStep(step, required.length + offerable.length > 0);
|
|
360
360
|
}
|
|
361
|
-
|
|
362
|
-
return (`STEP ${step} —
|
|
361
|
+
writeSummaryStep(summaryPath, step, mainAgentInstructions) {
|
|
362
|
+
return (`STEP ${step} — write the PR summary (title, summary, risk) to summary.json. Write it FIRST — BEFORE you spawn\n` +
|
|
363
363
|
' anything below. finish REFUSES without it, and a reviewer subagent may READ it: a\n' +
|
|
364
364
|
' checklist that judges the PR title, summary or risk level reads exactly this file, so\n' +
|
|
365
365
|
' writing it afterwards races that reviewer into seeing nothing — or, on a re-run of this\n' +
|
|
366
|
-
' stage, into judging the PREVIOUS run\'s
|
|
367
|
-
(0, rules_config_1.
|
|
366
|
+
' stage, into judging the PREVIOUS run\'s summary of code that has since changed.\n\n' +
|
|
367
|
+
(0, rules_config_1.summaryJsonSchemaHint)(summaryPath, mainAgentInstructions) + '\n\n');
|
|
368
368
|
}
|
|
369
369
|
singleRoundRepeatStep() {
|
|
370
370
|
return '\n' + SEP
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"review-report.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/review-report.ts"],"names":[],"mappings":";;;;AAAA,mDAA6B;AAC7B,yCAA2D;AAC3D,0DAIiC;AACjC,yDAAqD;AACrD,6DAA0F;AAE1F,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;;;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AAiG;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;AA7gBY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGC,kCAAe;QACV,0CAA2B;QAC1B,2CAA4B;GAJ/D,YAAY,CA6gBxB","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, reviewJsonSchemaHint,\n ChecklistInstructionsService, RequiredChecklist, REVIEWER_AGENTS_PLACEHOLDER, ReviewerAgentPolicy,\n ReviewerBriefing, ReviewerInstructionsService, SINGLE_ROUND_MAIN_AGENT_INSTRUCTIONS, VERDICT_RED,\n} from '@webpieces/rules-config';\nimport { ChecklistNotice } from './checklist-notice';\nimport { STANDING_REJECTED, STANDING_STALE, VerdictStanding } from './verdict-provenance';\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 reviewPath: string; // the branch's review.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 singleRoundReview: boolean;\n singleRoundRepeat: boolean;\n singleRoundReviewers: 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, reviewPath: string) {\n this.repoRoot = repoRoot;\n this.featureName = featureName;\n this.reviewPath = reviewPath;\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.singleRoundReview = false;\n this.singleRoundRepeat = false;\n this.singleRoundReviewers = [];\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 review.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 review.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.singleRoundRepeat) return '② ⏭️ SINGLE-ROUND REVIEW ALREADY STARTED — skip reviews and 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 — review, then finish\\n';\n if (this.requiredOwed(input).length > 0) return '② Review, spawn subagent reviewers, then finish\\n';\n if (this.offerableOwed(input).length > 0) return '② Review, offer the optional reviewers, then finish\\n';\n return '② Review, 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 if (input.singleRoundRepeat) {\n return '\\n⏭️ `singleRoundReview: true` is enabled and this branch already used its one review round.\\n'\n + ` Recorded reviewer(s): ${input.singleRoundReviewers.join(', ')}\\n`\n + ' DO NOT spawn or re-spawn any reviewer, regardless of later edits or an earlier red.\\n';\n }\n // BEFORE the zero-applicable notice, which would otherwise say \"nothing matched this diff\" — the\n // single most misleading sentence available here, because plenty matched and every one of them was\n // switched off.\n if (input.reviewersSuppressed) return '\\n' + this.suppressionBanner(input);\n if (input.applicableCount === 0) return '\\n' + this.checklistNotice.build(input.definedCount);\n const lines: string[] = [];\n // The prohibition rides on the REUSE line itself, not only in the all-clear below, because the\n // all-clear is not printed when anything is still owed — and \"some reviewers are reused, others\n // must be spawned\" is exactly the shape in which an agent re-spawns the reused ones too.\n for (const r of input.reviewed) lines.push(this.carriedLine(input, r));\n lines.push(...this.rebriefedLines(input));\n // A verdict file that EXISTS but is unreadable as a verdict is called out here. Without it this\n // reports the checklist as simply owed, and the AI re-runs a reviewer that already ran instead of\n // correcting the file sitting right there.\n for (const e of input.formatErrors) lines.push(` ⛔ ${e}`);\n lines.push(...this.skippedLines(input));\n if (this.actionableOwed(input).length === 0) lines.push('', this.allClear(input));\n if (lines.length === 0) return '';\n return '\\n' + lines.join('\\n') + '\\n';\n }\n\n /**\n * One reused verdict, with WHY it is reused. \"Already reviewed\" alone was a state, not a reason, and\n * an agent that cannot see why a verdict still counts re-checks it. The sha and the in-scope claim are\n * the reason: that verdict judged exactly the diff its checklist is judged on now.\n */\n private carriedLine(input: ReviewReportInput, r: RequiredChecklist): string {\n const standing = input.standings.find((s: VerdictStanding): boolean => s.checklistId === r.id);\n if (standing === undefined) {\n return ` ✓ ${r.id} — already reviewed on this branch; verdict STANDS, do NOT re-spawn (review-${r.id}.json)`;\n }\n return ` ✓ ${r.id} — carried ${standing.status.toUpperCase()} from ${this.short(standing.fromSha)}, `\n + `in-scope files unchanged; verdict STANDS, do NOT re-spawn`;\n }\n\n /**\n * The verdicts that exist on disk but do NOT count, each with why — so a reviewer listed below is not\n * mistaken for one that simply never ran. A STALE red is not listed here: it is still a refusal, and\n * its block below says so.\n */\n private rebriefedLines(input: ReviewReportInput): string[] {\n const lines: string[] = [];\n for (const s of input.standings) {\n if (s.standing === STANDING_STALE && s.status !== VERDICT_RED) {\n lines.push(` ↻ ${s.checklistId} — ${s.status.toUpperCase()} from ${this.short(s.fromSha)} is STALE: ${s.reason}; re-briefed below`);\n }\n if (s.standing === STANDING_REJECTED) {\n lines.push(` ⛔ ${s.checklistId} — verdict REJECTED: ${s.reason}; re-briefed below`);\n }\n }\n return lines;\n }\n\n private short(sha: string): string {\n return sha === '' ? '(unknown sha)' : sha.slice(0, 8);\n }\n\n /**\n * THE LOUD BANNER. The one output in this whole flow that says an unreviewed PR is about to be posted.\n *\n * Everything in it is there because a reader has to be able to act on it or audit it: the FLAG name and\n * the FILE it was read from (the only actionable thing — nothing in any repo turns this off), the COUNT\n * split by required/optional, and every suppressed checklist BY NAME with REQUIRED marked. A count\n * alone would leave \"which required reviewer did I just skip?\" unanswerable at the one moment it is\n * being answered.\n *\n * It deliberately does NOT name `wp-finish-upsert-pr` — the closing step already does, exactly once,\n * and that \"exactly once\" is an invariant this class's docstring records having been bought with a bug.\n */\n private suppressionBanner(input: ReviewReportInput): string {\n const required = input.suppressed.filter((r: RequiredChecklist): boolean => r.required);\n const projectDisabled = input.reviewer.maxAgents === 0;\n const lines: string[] = [\n projectDisabled\n ? '⚫ ALL REVIEWER SUBAGENTS ARE DISABLED FOR THIS PROJECT. Nothing reviewed this branch.'\n : '⚫ ALL REVIEWER SUBAGENTS ARE SWITCHED OFF ON THIS MACHINE. Nothing reviewed this branch.',\n '',\n ` ${input.suppressed.length} checklist(s) matched this diff and were SUPPRESSED — `\n + `${required.length} of them REQUIRED:`,\n ];\n for (const r of input.suppressed) {\n lines.push(` • ${r.id}${r.required ? ' (REQUIRED — suppressed anyway)' : ' (optional)'}`);\n }\n lines.push(\n '',\n ...(projectDisabled ? [\n ' Switched off by: commands.pr-gate.reviewerAgents: 0',\n ' Read from: webpieces.config.json (project policy; build and PR gates remain active)',\n ] : [\n ` Switched off by: experimental.${HOME_KEY_TURN_OFF_ALL_REVIEWERS}: true`,\n ` Read from: ~/${HOME_CONFIG_DIR}/${HOME_CONFIG_FILE} (machine-local; no repo config can set this)`,\n ]),\n '',\n ' There is NOTHING to spawn — no reviewer was briefed and no instructions file was written,',\n ' so any attempt to spawn one has nothing to read. Do NOT hand-write a verdict file in their',\n ' place: a fabricated verdict is worse than the absent one this flag deliberately produces.',\n '',\n ' The dashboard is the whole review product for this PR, and the suppression is carried into',\n ' the PR body — which is the squash-merge commit body — so main\\'s history records it.',\n projectDisabled\n ? ' To get reviewers back, set reviewerAgents to a positive integer and re-run this command.'\n : ' To get the reviewers back, set that key to false (or delete it) and re-run this command.',\n );\n return lines.join('\\n') + '\\n';\n }\n\n /**\n * `--no-optional`, stated as a VERDICT rather than left silent. Named individually, not just counted: the\n * whole reason the human is allowed to skip these is that they know this diff, and the only way they can\n * catch \"wait, not THAT one\" is to see which ones went unreviewed.\n */\n private skippedLines(input: ReviewReportInput): string[] {\n const skipped = this.optionalOwed(input);\n if (!input.skipOptional || skipped.length === 0) return [];\n return [\n '',\n ` ⏭️ ${skipped.length} OPTIONAL checklist(s) matched this diff and were SKIPPED (--no-optional):`,\n ...skipped.map((b: ReviewerBriefing): string => ` ${b.checklistId} — ${this.why(b)}`),\n ' Not blocking. Drop the flag and re-run this command to offer them after all.',\n ];\n }\n\n /**\n * The all-clear, then the RULE that makes it actionable.\n *\n * \"nothing to spawn\" on its own is a description of the current state, and an agent that has just been\n * told a state — rather than a rule — treats re-spawning as a judgement call it is entitled to make. It\n * then makes it, reasoning (correctly, on the facts) that the carried-forward verdicts judged an earlier\n * tree. Reviews here are once per branch BY CONSTRUCTION: a passing review-<id>.json satisfies its\n * checklist for the branch's whole life, and `wp-finish-upsert-pr` never archives one the way it archives\n * review.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 * review.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 review.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 review.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.singleRoundRepeat) return this.singleRoundRepeatStep();\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 // review.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.writeReviewStep(\n input.reviewPath, step++, input.singleRoundReview ? SINGLE_ROUND_MAIN_AGENT_INSTRUCTIONS : '');\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 writeReviewStep(reviewPath: string, step: number, mainAgentInstructions: string): string {\n return (\n `STEP ${step} — review your own changes, then write the review file. 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 review of code that has since changed.\\n\\n' +\n reviewJsonSchemaHint(reviewPath, mainAgentInstructions) + '\\n\\n'\n );\n }\n\n private singleRoundRepeatStep(): string {\n return '\\n' + SEP\n + '▶ NEXT — reviewers have already run once. SKIP reviews and run:\\n' + SEP + '\\n'\n + ' pnpm wp-finish-upsert-pr\\n\\n'\n + ' Do NOT invoke or re-run reviewer subagents. They are expensive and their one verdict\\n'\n + ' remains the review record for this PR. If a red remains, finish will block and tell you\\n'\n + ' how to fix it without another reviewer round.\\n\\n';\n }\n\n /**\n * The REQUIRED reviewers — one copy-paste block each, and nothing at all when none is owed. The prompt is\n * deliberately a POINTER and nothing else: the generated instructions file is the contract, so anything\n * restated here is a second copy that can go stale — which is exactly how a removed `success` field\n * outlived its own removal in print.\n *\n * These are spawned WITHOUT asking. They are the checklists the repo declared `required: true`, which is\n * the repo saying the decision was already made; putting them to the human again would re-open a question\n * the config exists to settle.\n */\n private spawnStep(input: ReviewReportInput, owed: readonly ReviewerBriefing[], step: number, withAwait: boolean): string {\n const lines: string[] = [\n `STEP ${step} — only once that file is written, review these ${owed.length} REQUIRED checklist(s) with`,\n ...this.howManyAgents(input, owed.length),\n ' They block the PR, so do NOT ask whether to run them. You may NOT review your own',\n ' work, and you may NOT submit a reviewer\\'s verdict on its behalf: pnpm wp-write-review',\n ' refuses the coordinating agent, and finish rejects a verdict file written by hand.',\n '',\n ];\n lines.push(...this.refusedWarning(input, owed));\n for (const b of owed) lines.push(...this.oneSpawnBlock(input, b));\n if (withAwait) lines.push(...this.awaitLines());\n lines.push('');\n return lines.join('\\n');\n }\n\n /**\n * How to WAIT once the spawn list has been spawned — printed after the blocks, because it is the\n * next thing to do and nothing before it can be mistaken for it.\n *\n * It is here because the alternative is measured and expensive: `echo .` every three seconds at\n * ~557,000 tokens a turn, 18.3% of every token the fleet spent in the 24h to 2026-09-07 (#874).\n *\n * It names the efficient options and the wasteful one, and then stops (#902). It does NOT prescribe\n * ending the turn: waiting on the subagents you just spawned is something an agent already does\n * routinely, and whether to do that here is a judgement this string cannot make for it.\n *\n * It names no other stage. `finishStep` below is the ONE place this whole block names\n * `wp-finish-upsert-pr`, and a second mention here would be a second \"what to do next\" instruction\n * for an agent reading top to bottom — the exact defect the class docstring above describes.\n */\n private awaitLines(): string[] {\n return [\n ' Then WAIT. Be efficient with tokens: wait on the subagents you just spawned, or block',\n ' in one call with the command below. Do NOT send status checks every few seconds, and',\n ' do NOT run `echo` to keep your turn alive — a turn costs your whole context, ~557k',\n ' tokens.',\n '',\n ' pnpm wp-await-reviews',\n '',\n ' It heartbeats while it waits, returns as soon as the last verdict lands, and prints',\n ' what each reviewer said. If the wait is long it exits asking to be run again.',\n ];\n }\n\n /**\n * STEP n — the OPTIONAL reviewers: listed, never spawned unasked.\n *\n * This is the whole point of `required: false`. A one-line bug fix in a repo whose checklists key on a\n * glob as broad as every TypeScript file otherwise pays for a dozen subagent reviews, and the only party\n * who can judge whether this particular diff is worth them is the human looking at it.\n *\n * ONE batched multi-select question, explicitly. Asked one at a time, a human answering \"no\" nine times\n * is being worn down rather than consulted, and by the third question the cheap thing is to say yes to\n * everything — which is the state this feature exists to leave. The \"None\" option has to be spelled out\n * too: an agent that offers a list without an explicit way to decline it has not really offered a choice.\n *\n * The blocking consequence is stated because it is the one non-obvious part of the contract: `required`\n * governs whether a reviewer must RUN, not whether its answer counts. Choosing to run one and then\n * shrugging off a red verdict would make the whole exercise theater.\n */\n private offerStep(input: ReviewReportInput, offerable: readonly ReviewerBriefing[], step: number, withAwait: boolean): string {\n const lines: string[] = [\n `STEP ${step} — these ${offerable.length} OPTIONAL review checklist(s) matched this diff. They do NOT block the`,\n ' PR, and you may NOT decide for the human whether to run them.',\n '',\n ' ASK THE HUMAN, in ONE multi-select question listing all of them plus an explicit',\n ' \"None — required only\" choice. Do not ask one question per reviewer. Then spawn ONLY',\n ' what they picked, the same way as any other reviewer.',\n '',\n ' If they pick none, that is a complete answer: go straight to the final step. If they',\n ' told you up front to submit without reviews, re-run this stage as',\n ' `pnpm wp-review-upsert-pr --no-optional` and this step disappears.',\n '',\n ' NOTE: whichever ones you DO run, their verdicts count in full — a red verdict from an',\n ' optional reviewer blocks the PR exactly like a required one.',\n '',\n ];\n lines.push(...this.optionalAgentLines(input, offerable.length));\n lines.push(...this.refusedWarning(input, offerable));\n for (const b of offerable) lines.push(...this.oneSpawnBlock(input, b));\n if (withAwait) lines.push(...this.awaitLines());\n lines.push('');\n return lines.join('\\n');\n }\n\n // How the picked optional checklists are staffed. Grouped, the cap covers the WHOLE round, required\n // reviewers included — otherwise \"at most N\" would quietly become 2N the moment a human said yes.\n private optionalAgentLines(input: ReviewReportInput, count: number): string[] {\n const reviewer = input.reviewer;\n const required = this.requiredOwed(input).length;\n // The Codex pointer is printed once per report: by the required step when there is one.\n const codex = required > 0 ? [] : [this.agentDefinitionLine(input)];\n const scope = required > 0 ? `, COUNTING the ${required} required checklist(s) above — fold picked ones into those subagents` : '';\n return [\n ` Review what they picked with \\`${reviewer.agentName}\\` subagents: at most ${reviewer.maxAgents} IN TOTAL`,\n ` this round${scope}. Hand each subagent the instructions file of every checklist it covers.`,\n ...codex,\n ...(count > 0 ? [''] : []),\n ];\n }\n\n // Said up front, not only beside the block: an agent that has decided to spawn everything listed here\n // needs to know BEFORE it starts that one of these entries is not a spawn-shaped task. Scoped to the\n // group being printed — a refusal among the REQUIRED reviewers is not a caveat on the optional list.\n private refusedWarning(input: ReviewReportInput, group: readonly ReviewerBriefing[]): string[] {\n const ids = new Set(group.map((b: ReviewerBriefing): string => b.checklistId));\n const n = input.refused.filter((r: RefusedReviewer): boolean => ids.has(r.checklistId)).length;\n if (n === 0) return [];\n return [\n ` ${n} of them already ANSWERED and refused (marked ⛔ below). Do not spawn`,\n ' those against unchanged code — fix what they found first; the fix is the prerequisite.',\n '',\n ];\n }\n\n private finishStep(stepNumber: number, anyReviewers: boolean): string {\n // \"every reviewer you ran\" rather than \"every reviewer above\": with an optional list the human may\n // legitimately have run none of them, and a precondition naming reviewers that were declined reads as\n // an unmeetable one.\n const precondition = anyReviewers\n ? 'once every reviewer you ran has submitted its verdict'\n : 'once that file exists';\n return (\n `STEP ${stepNumber} — only ${precondition}, run: pnpm wp-finish-upsert-pr\\n` +\n ' (The build gate is already green for this commit — finish reuses it unless HEAD moves.)\\n\\n'\n );\n }\n\n // The briefings with no passing verdict yet — the ONE definition of \"owed\", shared by the header, the\n // scan verdict and the step numbering, so they cannot disagree about whether there is anything to spawn.\n private owedReviewers(input: ReviewReportInput): ReviewerBriefing[] {\n const reviewedIds = new Set(input.reviewed.map((r: RequiredChecklist): string => r.id));\n return input.briefings.filter((b: ReviewerBriefing): boolean => !reviewedIds.has(b.checklistId));\n }\n\n // Owed AND blocking — spawned without asking.\n private requiredOwed(input: ReviewReportInput): ReviewerBriefing[] {\n return this.owedReviewers(input).filter((b: ReviewerBriefing): boolean => b.required);\n }\n\n // Owed and optional. Still listed under `--no-optional` (as a skip verdict), just never as a step.\n private optionalOwed(input: ReviewReportInput): ReviewerBriefing[] {\n return this.owedReviewers(input).filter((b: ReviewerBriefing): boolean => !b.required);\n }\n\n // The optional ones the human is actually to be ASKED about — none, once they have already answered.\n private offerableOwed(input: ReviewReportInput): ReviewerBriefing[] {\n return input.skipOptional ? [] : this.optionalOwed(input);\n }\n\n // Everything the AI still has to act on. Distinct from `owedReviewers`: a skipped optional checklist is\n // owed a verdict it will never get, and treating it as pending work is what would print a spawn\n // instruction for a review the human just declined.\n private actionableOwed(input: ReviewReportInput): ReviewerBriefing[] {\n return [...this.requiredOwed(input), ...this.offerableOwed(input)];\n }\n\n /**\n * One reviewer's block. A reviewer that already REFUSED gets the SAME spawn coordinates but a different\n * lead-in, because the action before spawning is different: its own words are printed, and the spawn is\n * explicitly conditioned on having fixed the finding first.\n *\n * It keeps its spawn block rather than being dropped from the list, because the reviewer genuinely does\n * still owe a fresh verdict — dropping it would leave nothing anywhere saying how to get one. What must\n * not happen is a bare \"spawn this\" that reads identically to a reviewer that never ran, which is the\n * loop this exists to break.\n */\n private oneSpawnBlock(input: ReviewReportInput, b: ReviewerBriefing): string[] {\n const instructionsFile = this.reviewerInstructions.pathFor(input.repoRoot, input.featureName, b.checklistId);\n // The subagent_type is stated once, above; each block is one checklist's file to hand to\n // whichever subagent covers it.\n return [...this.leadIn(input, b), ` instructions: ${instructionsFile}`, ''];\n }\n\n /**\n * HOW MANY subagents, of WHICH type — the one place this report states it, shared by the required and\n * the optional step so the two cannot disagree.\n *\n * Positive `commands.pr-gate.reviewerAgents` values give the main AI a CAP and the\n * grouping decision: the point of the key is to stop paying for N agents re-reading the same diff, and\n * the AI is the one that can see which checklists belong together. The cap is per ROUND, so a re-run\n * after a red verdict re-reviews only the owed checklists — the only ones listed — under the same cap.\n */\n private howManyAgents(input: ReviewReportInput, count: number): string[] {\n const reviewer = input.reviewer;\n const cap = Math.min(reviewer.maxAgents, count);\n return [\n ` AT MOST ${cap} subagent(s) of type \\`${reviewer.agentName}\\` (commands.pr-gate.reviewerAgents = ${reviewer.maxAgents}).`,\n ` ${this.checklistInstructions.groupingHint(count, cap)}`,\n ' Spawn each one as:',\n ` subagent_type: ${reviewer.agentName}`,\n ' prompt: Read EACH instructions file below FIRST and follow it exactly. Review each',\n ' checklist only over its own in-scope files and submit ONE verdict per',\n ' checklist with pnpm wp-write-review — never one for a checklist you were',\n ' not given.',\n ' <then list the instructions file of every checklist this subagent covers>',\n ' Every checklist below must be covered by exactly one of those subagents.',\n this.agentDefinitionLine(input),\n ];\n }\n\n /**\n * The ONE canonical reviewer definition, named for a harness that cannot spawn it by type. Codex has no\n * registered agent types, so its subagent is generic; pointing it at the same committed file keeps one\n * definition for both harnesses instead of a Codex-specific copy that drifts (#863).\n */\n private agentDefinitionLine(input: ReviewReportInput): string {\n const file = path.join(input.repoRoot, '.claude', 'agents', `${input.reviewer.agentName}.md`);\n return ` Codex (no agent types): spawn a generic subagent with NO forked turns (fresh context — do not\\n`\n + ` fork this conversation into it) and hand it ONLY the instructions files below; it reads\\n`\n + ` ${file} first. The brief on disk is its whole input: a forked conversation hands a\\n`\n + ` reviewer the author's reasoning, which costs tokens and its independence.`;\n }\n\n // The lines above the spawn coordinates: normally just why this reviewer is in scope; for one that\n // already refused, its verdict verbatim plus the order the two actions must happen in.\n private leadIn(input: ReviewReportInput, b: ReviewerBriefing): string[] {\n const refusal = input.refused.find((r: RefusedReviewer): boolean => r.checklistId === b.checklistId);\n if (!refusal) return [` ▶ ${b.checklistId} — ${this.why(b)}`, ...this.docLine(b)];\n return [\n ` ⛔ ${b.checklistId} — ALREADY REVIEWED THIS BRANCH AND REFUSED. It will refuse again on unchanged code.`,\n ` ${refusal.message}`,\n ' FIX THE FINDING FIRST (or record a human-authored override). ONLY THEN spawn it again, to',\n ' write a fresh verdict:',\n ];\n }\n\n /**\n * The checklist's guidance doc, for OPTIONAL reviewers only.\n *\n * \"4 file(s) matched\" plus a broad glob does not tell a human what the review would actually look AT,\n * and they are being asked to decide exactly that. Omitted for required reviewers: there is no decision\n * to inform there — the reviewer runs either way, and the doc is already in its instructions file.\n */\n private docLine(b: ReviewerBriefing): string[] {\n if (b.required || b.docPath === '') return [];\n return [` reviews against: ${b.docPath}`];\n }\n\n // Why this one is in scope. A patternless checklist is NOT \"matched\" — it always runs, over the whole\n // diff, and saying so is what tells a repo its checklist is firing on docs-only PRs by design.\n private why(b: ReviewerBriefing): string {\n if (b.matchedPatterns.length === 0) {\n return `ALWAYS RUNS (no \"patterns\" configured), whole diff in scope — ${b.myFiles.length} file(s)`;\n }\n return `${b.myFiles.length} file(s) matched ${b.matchedPatterns.map((p: string): string => `\"${p}\"`).join(', ')}`;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"review-report.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/review-report.ts"],"names":[],"mappings":";;;;AAAA,mDAA6B;AAC7B,yCAA2D;AAC3D,0DAIiC;AACjC,yDAAqD;AACrD,6DAA0F;AAE1F,MAAM,GAAG,GAAG,0DAA0D,CAAC;AAEvE;;;;;;;;;;;;;GAaG;AACH,MAAa,eAAe;IACxB,WAAW,CAAS;IACpB,OAAO,CAAS;IAEhB,YAAY,WAAmB,EAAE,OAAe;QAC5C,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;CACJ;AARD,0CAQC;AAED;;;;GAIG;AACH,MAAa,iBAAiB;IAC1B,QAAQ,CAAS;IACjB,WAAW,CAAS;IACpB,WAAW,CAAS,CAAa,8DAA8D;IAC/F,YAAY,CAAS,CAAW,iDAAiD;IACjF,eAAe,CAAS,CAAQ,yEAAyE;IACzG,QAAQ,CAAsB,CAAE,gDAAgD;IAChF,YAAY,CAAW,CAAS,0DAA0D;IAC1F,SAAS,CAAqB,CAAE,wDAAwD;IACxF,OAAO,CAAoB,CAAK,6EAA6E;IAC7G;;;;OAIG;IACH,YAAY,CAAU;IACtB;;;;;;;;;OASG;IACH,mBAAmB,CAAU;IAC7B;;;;OAIG;IACH,UAAU,CAAsB;IAChC,iBAAiB,CAAU;IAC3B,iBAAiB,CAAU;IAC3B,oBAAoB,CAAW;IAC/B,2GAA2G;IAC3G,wCAAwC;IACxC,QAAQ,CAAsB;IAC9B;;;OAGG;IACH,SAAS,CAAoB;IAE7B,YAAY,QAAgB,EAAE,WAAmB,EAAE,WAAmB;QAClE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CA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C,kCAAe;QACV,0CAA2B;QAC1B,2CAA4B;GAJ/D,YAAY,CA6gBxB","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, SINGLE_ROUND_MAIN_AGENT_INSTRUCTIONS, VERDICT_RED,\n} from '@webpieces/rules-config';\nimport { ChecklistNotice } from './checklist-notice';\nimport { STANDING_REJECTED, STANDING_STALE, VerdictStanding } from './verdict-provenance';\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 singleRoundReview: boolean;\n singleRoundRepeat: boolean;\n singleRoundReviewers: 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.singleRoundReview = false;\n this.singleRoundRepeat = false;\n this.singleRoundReviewers = [];\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.singleRoundRepeat) return '② ⏭️ SINGLE-ROUND REVIEW ALREADY STARTED — skip reviews and 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 '② Write the PR summary, spawn subagent 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 if (input.singleRoundRepeat) {\n return '\\n⏭️ `singleRoundReview: true` is enabled and this branch already used its one review round.\\n'\n + ` Recorded reviewer(s): ${input.singleRoundReviewers.join(', ')}\\n`\n + ' DO NOT spawn or re-spawn any reviewer, regardless of later edits or an earlier red.\\n';\n }\n // BEFORE the zero-applicable notice, which would otherwise say \"nothing matched this diff\" — the\n // single most misleading sentence available here, because plenty matched and every one of them was\n // switched off.\n if (input.reviewersSuppressed) return '\\n' + this.suppressionBanner(input);\n if (input.applicableCount === 0) return '\\n' + this.checklistNotice.build(input.definedCount);\n const lines: string[] = [];\n // The prohibition rides on the REUSE line itself, not only in the all-clear below, because the\n // all-clear is not printed when anything is still owed — and \"some reviewers are reused, others\n // must be spawned\" is exactly the shape in which an agent re-spawns the reused ones too.\n for (const r of input.reviewed) lines.push(this.carriedLine(input, r));\n lines.push(...this.rebriefedLines(input));\n // A verdict file that EXISTS but is unreadable as a verdict is called out here. Without it this\n // reports the checklist as simply owed, and the AI re-runs a reviewer that already ran instead of\n // correcting the file sitting right there.\n for (const e of input.formatErrors) lines.push(` ⛔ ${e}`);\n lines.push(...this.skippedLines(input));\n if (this.actionableOwed(input).length === 0) lines.push('', this.allClear(input));\n if (lines.length === 0) return '';\n return '\\n' + lines.join('\\n') + '\\n';\n }\n\n /**\n * One reused verdict, with WHY it is reused. \"Already reviewed\" alone was a state, not a reason, and\n * an agent that cannot see why a verdict still counts re-checks it. The sha and the in-scope claim are\n * the reason: that verdict judged exactly the diff its checklist is judged on now.\n */\n private carriedLine(input: ReviewReportInput, r: RequiredChecklist): string {\n const standing = input.standings.find((s: VerdictStanding): boolean => s.checklistId === r.id);\n if (standing === undefined) {\n return ` ✓ ${r.id} — already reviewed on this branch; verdict STANDS, do NOT re-spawn (review-${r.id}.json)`;\n }\n return ` ✓ ${r.id} — carried ${standing.status.toUpperCase()} from ${this.short(standing.fromSha)}, `\n + `in-scope files unchanged; verdict STANDS, do NOT re-spawn`;\n }\n\n /**\n * The verdicts that exist on disk but do NOT count, each with why — so a reviewer listed below is not\n * mistaken for one that simply never ran. A STALE red is not listed here: it is still a refusal, and\n * its block below says so.\n */\n private rebriefedLines(input: ReviewReportInput): string[] {\n const lines: string[] = [];\n for (const s of input.standings) {\n if (s.standing === STANDING_STALE && s.status !== VERDICT_RED) {\n lines.push(` ↻ ${s.checklistId} — ${s.status.toUpperCase()} from ${this.short(s.fromSha)} is STALE: ${s.reason}; re-briefed below`);\n }\n if (s.standing === STANDING_REJECTED) {\n lines.push(` ⛔ ${s.checklistId} — verdict REJECTED: ${s.reason}; re-briefed below`);\n }\n }\n return lines;\n }\n\n private short(sha: string): string {\n return sha === '' ? '(unknown sha)' : sha.slice(0, 8);\n }\n\n /**\n * THE LOUD BANNER. The one output in this whole flow that says an unreviewed PR is about to be posted.\n *\n * Everything in it is there because a reader has to be able to act on it or audit it: the FLAG name and\n * the FILE it was read from (the only actionable thing — nothing in any repo turns this off), the COUNT\n * split by required/optional, and every suppressed checklist BY NAME with REQUIRED marked. A count\n * alone would leave \"which required reviewer did I just skip?\" unanswerable at the one moment it is\n * being answered.\n *\n * It deliberately does NOT name `wp-finish-upsert-pr` — the closing step already does, exactly once,\n * and that \"exactly once\" is an invariant this class's docstring records having been bought with a bug.\n */\n private suppressionBanner(input: ReviewReportInput): string {\n const required = input.suppressed.filter((r: RequiredChecklist): boolean => r.required);\n const projectDisabled = input.reviewer.maxAgents === 0;\n const lines: string[] = [\n projectDisabled\n ? '⚫ ALL REVIEWER SUBAGENTS ARE DISABLED FOR THIS PROJECT. Nothing reviewed this branch.'\n : '⚫ ALL REVIEWER SUBAGENTS ARE SWITCHED OFF ON THIS MACHINE. Nothing reviewed this branch.',\n '',\n ` ${input.suppressed.length} checklist(s) matched this diff and were SUPPRESSED — `\n + `${required.length} of them REQUIRED:`,\n ];\n for (const r of input.suppressed) {\n lines.push(` • ${r.id}${r.required ? ' (REQUIRED — suppressed anyway)' : ' (optional)'}`);\n }\n lines.push(\n '',\n ...(projectDisabled ? [\n ' Switched off by: commands.pr-gate.reviewerAgents: 0',\n ' Read from: webpieces.config.json (project policy; build and PR gates remain active)',\n ] : [\n ` Switched off by: experimental.${HOME_KEY_TURN_OFF_ALL_REVIEWERS}: true`,\n ` Read from: ~/${HOME_CONFIG_DIR}/${HOME_CONFIG_FILE} (machine-local; no repo config can set this)`,\n ]),\n '',\n ' There is NOTHING to spawn — no reviewer was briefed and no instructions file was written,',\n ' so any attempt to spawn one has nothing to read. Do NOT hand-write a verdict file in their',\n ' place: a fabricated verdict is worse than the absent one this flag deliberately produces.',\n '',\n ' The dashboard is the whole review product for this PR, and the suppression is carried into',\n ' the PR body — which is the squash-merge commit body — so main\\'s history records it.',\n projectDisabled\n ? ' To get reviewers back, set reviewerAgents to a positive integer and re-run this command.'\n : ' To get the reviewers back, set that key to false (or delete it) and re-run this command.',\n );\n return lines.join('\\n') + '\\n';\n }\n\n /**\n * `--no-optional`, stated as a VERDICT rather than left silent. Named individually, not just counted: the\n * whole reason the human is allowed to skip these is that they know this diff, and the only way they can\n * catch \"wait, not THAT one\" is to see which ones went unreviewed.\n */\n private skippedLines(input: ReviewReportInput): string[] {\n const skipped = this.optionalOwed(input);\n if (!input.skipOptional || skipped.length === 0) return [];\n return [\n '',\n ` ⏭️ ${skipped.length} OPTIONAL checklist(s) matched this diff and were SKIPPED (--no-optional):`,\n ...skipped.map((b: ReviewerBriefing): string => ` ${b.checklistId} — ${this.why(b)}`),\n ' Not blocking. Drop the flag and re-run this command to offer them after all.',\n ];\n }\n\n /**\n * The all-clear, then the RULE that makes it actionable.\n *\n * \"nothing to spawn\" on its own is a description of the current state, and an agent that has just been\n * told a state — rather than a rule — treats re-spawning as a judgement call it is entitled to make. It\n * then makes it, reasoning (correctly, on the facts) that the carried-forward verdicts judged an earlier\n * tree. Reviews here are once per branch BY CONSTRUCTION: a passing review-<id>.json satisfies its\n * checklist for the branch's whole life, and `wp-finish-upsert-pr` never archives one the way it archives\n * summary.json. So the reuse is deliberate — it is what keeps post-PR iteration from re-paying for every\n * matched reviewer — and the output has to say so, because the alternative reading is the expensive one.\n *\n * The overwrite warning is not decoration. A re-spawned reviewer writes to the SAME verdict path, so a\n * gratuitous re-run does not merely cost a subagent — it destroys the verdict that was already banked.\n *\n * It must NOT claim everything was reviewed when optional reviews were skipped — that is the one sentence\n * that would turn a deliberate skip into a false record of a review that happened.\n */\n private allClear(input: ReviewReportInput): string {\n const headline = input.skipOptional && this.optionalOwed(input).length > 0\n ? '✅ Nothing left to spawn — every REQUIRED checklist is reviewed (optional ones skipped above).'\n : '✅ Every checklist that applies is already reviewed — nothing to spawn.';\n return headline + '\\n' + this.oncePerBranchRule();\n }\n\n /**\n * The once-per-branch rule, stated as a prohibition rather than left to be inferred from a ✅.\n *\n * Printed whenever verdicts are being reused — which is every iteration of a PR after the first, i.e. the\n * majority of stage-② runs on any branch that gets review feedback.\n */\n private oncePerBranchRule(): string {\n return (\n ' A passing verdict CARRIES FORWARD for as long as its checklist\\'s in-scope files are unchanged,\\n' +\n ' deliberately, so edits elsewhere cost no reviewer tokens. When those files DO change, this\\n' +\n ' stage re-briefs that checklist itself and names it in a STEP below. Do NOT re-spawn a reviewer\\n' +\n ' listed above to \"re-check\" — it burns a full subagent run AND replaces the verdict it already\\n' +\n ' submitted. The only reviewers you may spawn are ones a STEP below names.'\n );\n }\n\n /**\n * The ONE instruction block, and the last thing the stage prints. Numbered rather than prose-linked\n * (\"Then… Finally…\") so that skipping step 1 is visibly skipping a step, and worded so no earlier line\n * can be mistaken for the real next action.\n *\n * summary.json is STEP 1 and the spawn blocks are STEP 2 — that ORDER is the contract, not a preference.\n * This block used to print the spawn blocks first and then say to write summary.json \"WHILE any reviewer\n * subagents above are still running\", which does not merely permit spawning first, it instructs it.\n * Harmless for a reviewer that only reads the diff; wrong for one that judges the PR's stated INTENT —\n * its title, summary or risk level — because summary.json is the only place that intent lives. Such a\n * reviewer either finds no file (a false RED and a wasted reviewer run) or, on a second run of this\n * stage on the same branch, finds the PREVIOUS run's file and validates a title that no longer exists —\n * a false GREEN, with nothing in the output saying which of the two happened. A consuming repo had to\n * write itself a rule telling its agents to DISOBEY this block to work around it.\n *\n * What the old ordering bought was overlap on a single local file write, not a subagent round-trip.\n *\n * The schema hint is rendered by ReviewJsonService — the single renderer — so the shape printed here\n * can never drift from the shape `wp-finish-upsert-pr` validates.\n */\n private nextSteps(input: ReviewReportInput): string {\n if (input.singleRoundRepeat) return this.singleRoundRepeatStep();\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(\n input.summaryPath, step++, input.singleRoundReview ? SINGLE_ROUND_MAIN_AGENT_INSTRUCTIONS : '');\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 singleRoundRepeatStep(): string {\n return '\\n' + SEP\n + '▶ NEXT — reviewers have already run once. SKIP reviews and run:\\n' + SEP + '\\n'\n + ' pnpm wp-finish-upsert-pr\\n\\n'\n + ' Do NOT invoke or re-run reviewer subagents. They are expensive and their one verdict\\n'\n + ' remains the review record for this PR. If a red remains, finish will block and tell you\\n'\n + ' how to fix it without another reviewer round.\\n\\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"]}
|
|
@@ -21,9 +21,9 @@ export declare class ReviewStageReceipt {
|
|
|
21
21
|
* Reads/writes the stage-② receipt.
|
|
22
22
|
*
|
|
23
23
|
* WHY a receipt rather than relying on the artifacts that already exist: `wp-finish-upsert-pr` already
|
|
24
|
-
* refuses when a reviewer has no verdict and when
|
|
25
|
-
* mostly interlocked already. A repo with NO checklists is not —
|
|
26
|
-
* between it and a PR, and the AI writes
|
|
24
|
+
* refuses when a reviewer has no verdict and when summary.json is absent, so a repo WITH checklists is
|
|
25
|
+
* mostly interlocked already. A repo with NO checklists is not — summary.json is the only thing standing
|
|
26
|
+
* between it and a PR, and the AI writes summary.json itself. Nothing stopped it from writing that file and
|
|
27
27
|
* going straight to finish, skipping the merge validation and the build entirely.
|
|
28
28
|
*
|
|
29
29
|
* The receipt also pays for itself in the other direction: because it records the sha the build passed on,
|
|
@@ -37,9 +37,9 @@ exports.ReviewStageReceipt = ReviewStageReceipt;
|
|
|
37
37
|
* Reads/writes the stage-② receipt.
|
|
38
38
|
*
|
|
39
39
|
* WHY a receipt rather than relying on the artifacts that already exist: `wp-finish-upsert-pr` already
|
|
40
|
-
* refuses when a reviewer has no verdict and when
|
|
41
|
-
* mostly interlocked already. A repo with NO checklists is not —
|
|
42
|
-
* between it and a PR, and the AI writes
|
|
40
|
+
* refuses when a reviewer has no verdict and when summary.json is absent, so a repo WITH checklists is
|
|
41
|
+
* mostly interlocked already. A repo with NO checklists is not — summary.json is the only thing standing
|
|
42
|
+
* between it and a PR, and the AI writes summary.json itself. Nothing stopped it from writing that file and
|
|
43
43
|
* going straight to finish, skipping the merge validation and the build entirely.
|
|
44
44
|
*
|
|
45
45
|
* The receipt also pays for itself in the other direction: because it records the sha the build passed on,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"review-stage-receipt.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/review-stage-receipt.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;AAC7B,0DAAqE;AACrE,yCAA2D;AAE9C,QAAA,YAAY,GAAG,mBAAmB,CAAC;AAEhD;;GAEG;AACH,MAAa,kBAAkB;IAC3B,OAAO,CAAS,CAAU,gEAAgE;IAC1F,cAAc,CAAU,CAAE,oEAAoE;IAC9F,YAAY,CAAS;IACrB,aAAa,CAAS,CAAI,4DAA4D;IACtF,gBAAgB,CAAW;IAC3B;;;;OAIG;IACH,WAAW,CAAyB;IAEpC,yDAAyD;IACzD,YAAY,OAAO,GAAG,EAAE,EAAE,cAAc,GAAG,KAAK,EAAE,YAAY,GAAG,EAAE,EAAE,aAAa,GAAG,EAAE,EAAE,mBAA6B,EAAE;QACpH,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IAC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CAAC,OAAO,CAAC,KAAK,CAAC;YAAE,OAAO,GAAG,CAAC;QACpF,4FAA4F;QAC5F,MAAM,GAAG,GAAG,KAAgC,CAAC;QAC7C,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACjC,MAAM,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;YACnB,IAAI,OAAO,CAAC,KAAK,QAAQ;gBAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5C,CAAC;QACD,OAAO,GAAG,CAAC;IACf,CAAC;CACJ,CAAA;AAzDY,8DAAyB;oCAAzB,yBAAyB;IADrC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEW,gCAAiB;GADxD,yBAAyB,CAyDrC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { ReviewJsonService, toError } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nexport const RECEIPT_FILE = 'review-stage.json';\n\n/**\n * Proof that stage ② (`wp-review-upsert-pr`) actually ran, and on WHICH commit. Data-only (per CLAUDE.md).\n */\nexport class ReviewStageReceipt {\n headSha: string; // the sha the merge was validated and the build was run against\n mergeValidated: boolean; // a 3-point merge was finalized here, or there was none to finalize\n buildCommand: string;\n buildPassedAt: string; // ISO; '' when the gate was skipped (mode OFF / no command)\n reviewersBriefed: string[];\n /**\n * checklist id → the hash of its in-scope diff at `headSha` (ChecklistScopeHasher). `wp-write-review`\n * stamps a verdict's provenance with the hash its reviewer was BRIEFED on, and the next stage ② carries\n * a green/yellow forward only while that hash is unchanged (issue #863). Assigned after construction.\n */\n scopeHashes: Record<string, string>;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(headSha = '', mergeValidated = false, buildCommand = '', buildPassedAt = '', reviewersBriefed: string[] = []) {\n this.headSha = headSha;\n this.mergeValidated = mergeValidated;\n this.buildCommand = buildCommand;\n this.buildPassedAt = buildPassedAt;\n this.reviewersBriefed = reviewersBriefed;\n this.scopeHashes = {};\n }\n}\n\n/**\n * Reads/writes the stage-② receipt.\n *\n * WHY a receipt rather than relying on the artifacts that already exist: `wp-finish-upsert-pr` already\n * refuses when a reviewer has no verdict and when
|
|
1
|
+
{"version":3,"file":"review-stage-receipt.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/review-stage-receipt.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;AAC7B,0DAAqE;AACrE,yCAA2D;AAE9C,QAAA,YAAY,GAAG,mBAAmB,CAAC;AAEhD;;GAEG;AACH,MAAa,kBAAkB;IAC3B,OAAO,CAAS,CAAU,gEAAgE;IAC1F,cAAc,CAAU,CAAE,oEAAoE;IAC9F,YAAY,CAAS;IACrB,aAAa,CAAS,CAAI,4DAA4D;IACtF,gBAAgB,CAAW;IAC3B;;;;OAIG;IACH,WAAW,CAAyB;IAEpC,yDAAyD;IACzD,YAAY,OAAO,GAAG,EAAE,EAAE,cAAc,GAAG,KAAK,EAAE,YAAY,GAAG,EAAE,EAAE,aAAa,GAAG,EAAE,EAAE,mBAA6B,EAAE;QACpH,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IAC1B,CAAC;CACJ;AAtBD,gDAsBC;AAED;;;;;;;;;;;;;;GAcG;AAEI,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IACL;IAA7B,YAA6B,iBAAoC;QAApC,sBAAiB,GAAjB,iBAAiB,CAAmB;IAAG,CAAC;IAErE,WAAW,CAAC,QAAgB,EAAE,WAAmB;QAC7C,OAAO,IAAI,CAAC,I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ACnB,IAAI,OAAO,CAAC,KAAK,QAAQ;gBAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5C,CAAC;QACD,OAAO,GAAG,CAAC;IACf,CAAC;CACJ,CAAA;AAzDY,8DAAyB;oCAAzB,yBAAyB;IADrC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEW,gCAAiB;GADxD,yBAAyB,CAyDrC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { ReviewJsonService, toError } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nexport const RECEIPT_FILE = 'review-stage.json';\n\n/**\n * Proof that stage ② (`wp-review-upsert-pr`) actually ran, and on WHICH commit. Data-only (per CLAUDE.md).\n */\nexport class ReviewStageReceipt {\n headSha: string; // the sha the merge was validated and the build was run against\n mergeValidated: boolean; // a 3-point merge was finalized here, or there was none to finalize\n buildCommand: string;\n buildPassedAt: string; // ISO; '' when the gate was skipped (mode OFF / no command)\n reviewersBriefed: string[];\n /**\n * checklist id → the hash of its in-scope diff at `headSha` (ChecklistScopeHasher). `wp-write-review`\n * stamps a verdict's provenance with the hash its reviewer was BRIEFED on, and the next stage ② carries\n * a green/yellow forward only while that hash is unchanged (issue #863). Assigned after construction.\n */\n scopeHashes: Record<string, string>;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(headSha = '', mergeValidated = false, buildCommand = '', buildPassedAt = '', reviewersBriefed: string[] = []) {\n this.headSha = headSha;\n this.mergeValidated = mergeValidated;\n this.buildCommand = buildCommand;\n this.buildPassedAt = buildPassedAt;\n this.reviewersBriefed = reviewersBriefed;\n this.scopeHashes = {};\n }\n}\n\n/**\n * Reads/writes the stage-② receipt.\n *\n * WHY a receipt rather than relying on the artifacts that already exist: `wp-finish-upsert-pr` already\n * refuses when a reviewer has no verdict and when summary.json is absent, so a repo WITH checklists is\n * mostly interlocked already. A repo with NO checklists is not — summary.json is the only thing standing\n * between it and a PR, and the AI writes summary.json itself. Nothing stopped it from writing that file and\n * going straight to finish, skipping the merge validation and the build entirely.\n *\n * The receipt also pays for itself in the other direction: because it records the sha the build passed on,\n * finish can SKIP its own build when HEAD has not moved, so adding a gate in the middle did not cost a\n * second full `nx affected` run.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ReviewStageReceiptService {\n constructor(private readonly reviewJsonService: ReviewJsonService) {}\n\n receiptPath(repoRoot: string, featureName: string): string {\n return path.join(this.reviewJsonService.prDirFor(repoRoot, featureName), RECEIPT_FILE);\n }\n\n write(repoRoot: string, featureName: string, receipt: ReviewStageReceipt): string {\n const p = this.receiptPath(repoRoot, featureName);\n fs.mkdirSync(path.dirname(p), { recursive: true });\n fs.writeFileSync(p, JSON.stringify(receipt, null, 2) + '\\n');\n return p;\n }\n\n /** The receipt, or null when stage ② never ran (or left something unreadable behind). */\n read(repoRoot: string, featureName: string): ReviewStageReceipt | null {\n const p = this.receiptPath(repoRoot, featureName);\n if (!fs.existsSync(p)) return null;\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: an unreadable receipt is treated as absent, which re-runs stage ②\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n // webpieces-disable no-any-unknown -- opaque parsed JSON, narrowed field-by-field below\n const raw = JSON.parse(fs.readFileSync(p, 'utf8')) as Record<string, unknown>;\n const receipt = new ReviewStageReceipt(\n typeof raw['headSha'] === 'string' ? (raw['headSha'] as string) : '',\n raw['mergeValidated'] === true,\n typeof raw['buildCommand'] === 'string' ? (raw['buildCommand'] as string) : '',\n typeof raw['buildPassedAt'] === 'string' ? (raw['buildPassedAt'] as string) : '',\n Array.isArray(raw['reviewersBriefed']) ? (raw['reviewersBriefed'] as string[]) : [],\n );\n receipt.scopeHashes = this.stringMap(raw['scopeHashes']);\n return receipt;\n } catch (err: unknown) {\n const error = toError(err);\n void error; // unreadable ⇒ treated as absent, which re-runs stage ② (the safe direction)\n return null;\n }\n }\n\n /** The receipt file's mtime in epoch ms, or 0 when there is none — when stage ② last briefed anyone. */\n writtenAtMs(repoRoot: string, featureName: string): number {\n const p = this.receiptPath(repoRoot, featureName);\n return fs.existsSync(p) ? fs.statSync(p).mtimeMs : 0;\n }\n\n // webpieces-disable no-any-unknown -- one opaque JSON value, narrowed to string→string\n private stringMap(value: unknown): Record<string, string> {\n const out: Record<string, string> = {};\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return out;\n // webpieces-disable no-any-unknown -- entries of an opaque JSON object, each narrowed below\n const obj = value as Record<string, unknown>;\n for (const key of Object.keys(obj)) {\n const v = obj[key];\n if (typeof v === 'string') out[key] = v;\n }\n return out;\n }\n}\n"]}
|
|
@@ -41,7 +41,7 @@ let ReviewerBriefingBuilder = class ReviewerBriefingBuilder {
|
|
|
41
41
|
b.required = req.required;
|
|
42
42
|
b.sourceDirs = this.sourceDirsFor(repoRoot, req.matchedFiles);
|
|
43
43
|
b.contextEntries = shared;
|
|
44
|
-
b.verdictPath = this.reviewJsonService.checklistResultPath(scan.
|
|
44
|
+
b.verdictPath = this.reviewJsonService.checklistResultPath(scan.summaryPath, req.id);
|
|
45
45
|
b.fileDiffCommand = scan.context.fileDiffCommand;
|
|
46
46
|
b.dirty = scan.basis.dirty;
|
|
47
47
|
b.ownAgentFileInDiff = this.ownAgentFileIn(manifest, req.reviewer.agentName);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reviewer-briefing-builder.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/reviewer-briefing-builder.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;AAC7B,0DAEiC;AACjC,yCAA2D;AAI3D;;;;;;GAMG;AAEI,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IACH;IAA7B,YAA6B,iBAAoC;QAApC,sBAAiB,GAAjB,iBAAiB,CAAmB;IAAG,CAAC;IAErE,uGAAuG;IAC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ACD,OAAO,OAAO,CAAC;IACnB,CAAC;IAEO,cAAc,CAAC,QAAgB,EAAE,GAAW;QAChD,oHAAoH;QACpH,8DAA8D;QAC9D,IAAI,CAAC;YACD,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,GAAG,eAAe,EAAE,EAAE,KAAK,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;YACnF,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;YACvC,sFAAsF;YACtF,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC,CAA4B,CAAC;YAC1F,MAAM,IAAI,GAAG,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAE,IAAI,CAAC,aAAa,CAAY,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5F,OAAO,IAAI,2BAAY,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,MAAM,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC;QACzE,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACpB,MAAM,KAAK,GAAG,IAAA,sBAAO,EAAC,GAAG,CAAC,CAAC;YAC3B,KAAK,KAAK,CAAC,CAAC,yDAAyD;YACrE,OAAO,IAAI,2BAAY,CAAC,GAAG,EAAE,EAAE,EAAE,+DAA+D,CAAC,CAAC;QACtG,CAAC;IACL,CAAC;CACJ,CAAA;AAlIY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEW,gCAAiB;GADxD,uBAAuB,CAkInC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport {\n BriefedFile, ContextEntry, PrGateConfig, RequiredChecklist, ReviewerBriefing, ReviewJsonService, toError,\n} from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { DiffManifest, DiffManifestEntry } from './diff-materializer';\nimport { ChecklistScan } from './checklist-scanner';\n\n/**\n * Turns a {@link ChecklistScan} plus the materialized {@link DiffManifest} into one {@link ReviewerBriefing}\n * per reviewer — resolving every path to an absolute one, because a reviewer that has to resolve a path\n * ends up searching, and searching is the cost this whole feature exists to remove.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ReviewerBriefingBuilder {\n constructor(private readonly reviewJsonService: ReviewJsonService) {}\n\n /** One briefing per checklist in `checklists` — the OWED ones; a carried verdict is not re-briefed. */\n // eslint-disable-next-line @typescript-eslint/max-params\n build(\n repoRoot: string, scan: ChecklistScan, checklists: readonly RequiredChecklist[], manifest: DiffManifest,\n diffDir: string, config: PrGateConfig,\n ): ReviewerBriefing[] {\n // Resolved ONCE for the whole run, not per reviewer: `require.resolve` hits the filesystem, and the\n // answer cannot differ between two reviewers in the same process.\n const shared = this.contextEntries(repoRoot, config);\n const entryByFile = new Map<string, DiffManifestEntry>();\n for (const e of manifest.entries) entryByFile.set(e.file, e);\n return checklists.map((req: RequiredChecklist): ReviewerBriefing =>\n this.one(repoRoot, req, scan, entryByFile, diffDir, shared, manifest));\n }\n\n // eslint-disable-next-line @typescript-eslint/max-params\n private one(\n repoRoot: string, req: RequiredChecklist, scan: ChecklistScan,\n entryByFile: Map<string, DiffManifestEntry>, diffDir: string, shared: ContextEntry[], manifest: DiffManifest,\n ): ReviewerBriefing {\n const b = new ReviewerBriefing(req.reviewer.agentName, req.id, repoRoot);\n b.docPath = req.doc.trim() === '' ? '' : path.resolve(repoRoot, req.doc);\n b.diffDir = diffDir;\n b.allDiffPath = diffDir === '' ? '' : path.join(diffDir, 'ALL.diff');\n b.manifestPath = diffDir === '' ? '' : path.join(diffDir, 'manifest.json');\n b.myFiles = req.matchedFiles.map((f: string): BriefedFile => this.briefedFile(repoRoot, f, entryByFile));\n b.matchedPatterns = req.matchedPatterns;\n b.required = req.required;\n b.sourceDirs = this.sourceDirsFor(repoRoot, req.matchedFiles);\n b.contextEntries = shared;\n b.verdictPath = this.reviewJsonService.checklistResultPath(scan.reviewPath, req.id);\n b.fileDiffCommand = scan.context.fileDiffCommand;\n b.dirty = scan.basis.dirty;\n b.ownAgentFileInDiff = this.ownAgentFileIn(manifest, req.reviewer.agentName);\n this.copyManifestFacts(b, manifest);\n return b;\n }\n\n /**\n * One row of the reviewer's table. The SOURCE path comes over with the diff path because the two need\n * identical affordance: when the diff was an absolute path and the source was a parent directory, four of\n * four reviewers read the diff and none opened a source file.\n */\n private briefedFile(repoRoot: string, file: string, entryByFile: Map<string, DiffManifestEntry>): BriefedFile {\n const e = entryByFile.get(file);\n if (e === undefined) return new BriefedFile(file, '', path.resolve(repoRoot, file));\n return new BriefedFile(file, e.diffAbs, e.fileAbs, e.status, e.bytes, e.truncated);\n }\n\n /**\n * Manifest headline facts, copied onto the briefing so the instructions can state them INLINE. A reviewer\n * that never opens the manifest still has to learn whether anything was truncated or excluded — that is\n * precisely the thing it could not otherwise know it was missing.\n */\n private copyManifestFacts(b: ReviewerBriefing, manifest: DiffManifest): void {\n b.changedFileCount = manifest.entries.length;\n b.truncatedCount = manifest.entries.filter((e: DiffManifestEntry): boolean => e.truncated).length;\n b.excludedCount = manifest.excluded.length;\n b.allDiffLines = manifest.allDiffLines;\n b.allDiffBytes = manifest.allDiffBytes;\n b.hashForkPoint = manifest.hashForkPoint;\n b.hashFeatureHead = manifest.hashFeatureHead;\n b.hashMainHead = manifest.hashMainHead;\n }\n\n /**\n * The reviewer agent's own `.claude/agents/<agentName>.md`, when THIS diff changes it. Detected here rather than\n * left to the reviewer to notice: on the measured run two reviewers reviewed their own definition and\n * neither mentioned it, and every PR that edits the review gate reproduces that.\n */\n private ownAgentFileIn(manifest: DiffManifest, agentName: string): string {\n const suffix = path.join('.claude', 'agents', `${agentName}.md`);\n const hit = manifest.entries.find((e: DiffManifestEntry): boolean => e.file.split('/').join(path.sep).endsWith(suffix));\n return hit === undefined ? '' : (hit.fileAbs === '' ? hit.file : hit.fileAbs);\n }\n\n /**\n * Deduped absolute parent dirs of the matched files. Dirs rather than files because the point is to say\n * \"the neighbourhood is here\" — a reviewer already has the file list; what it lacks is where to look for\n * the code AROUND the change.\n */\n private sourceDirsFor(repoRoot: string, files: readonly string[]): string[] {\n const dirs = new Set<string>();\n for (const f of files) dirs.add(path.resolve(repoRoot, path.dirname(f)));\n return [...dirs].sort();\n }\n\n /**\n * The pre-resolved context list, from two config keys with deliberately different jobs:\n *\n * `reviewContextPackages` — installed packages, resolved to their real on-disk dir. This is what deletes\n * the repeated `node_modules/@webpieces` greps: the tooling knows where a package resolved to, and the\n * reviewer does not.\n * `reviewContext` — the repo-specific escape hatch (`{label, path}`) for what tooling cannot possibly\n * guess, e.g. \"queue names live in terraform/services/\".\n *\n * Neither ever drops an entry: an unresolvable package or a missing path is LISTED, with the reason. A\n * silently shorter list is indistinguishable from a complete one.\n */\n private contextEntries(repoRoot: string, config: PrGateConfig): ContextEntry[] {\n const entries: ContextEntry[] = [];\n for (const pkg of config.reviewContextPackages) entries.push(this.resolvePackage(repoRoot, pkg));\n for (const item of config.reviewContext) {\n const abs = path.resolve(repoRoot, item.path);\n entries.push(fs.existsSync(abs)\n ? new ContextEntry(item.label, abs)\n : new ContextEntry(item.label, '', `(configured as \"${item.path}\" but missing)`));\n }\n return entries;\n }\n\n private resolvePackage(repoRoot: string, pkg: string): ContextEntry {\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: an unresolvable package is REPORTED as such, never fatal\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const manifestPath = require.resolve(`${pkg}/package.json`, { paths: [repoRoot] });\n const dir = path.dirname(manifestPath);\n // webpieces-disable no-any-unknown -- opaque package.json, only `description` is read\n const meta = JSON.parse(fs.readFileSync(manifestPath, 'utf8')) as Record<string, unknown>;\n const desc = typeof meta['description'] === 'string' ? (meta['description'] as string) : '';\n return new ContextEntry(desc === '' ? pkg : `${pkg} — ${desc}`, dir);\n } catch (err: unknown) {\n const error = toError(err);\n void error; // an unresolvable package is REPORTED below, never fatal\n return new ContextEntry(pkg, '', '(not installed — configured in pr-gate.reviewContextPackages)');\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"reviewer-briefing-builder.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/reviewer-briefing-builder.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;AAC7B,0DAEiC;AACjC,yCAA2D;AAI3D;;;;;;GAMG;AAEI,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IACH;IAA7B,YAA6B,iBAAoC;QAApC,sBAAiB,GAAjB,iBAAiB,CAAmB;IAAG,CAAC;IAErE,uGAAuG;IACvG,yDAAyD;IACzD,KAAK,CACD,QAAgB,EAAE,IAAmB,EAAE,UAAwC,EAAE,QAAsB,EACvG,OAAe,EAAE,MAAoB;QAErC,oGAAoG;QACpG,kEAAkE;QAClE,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACrD,MAAM,WAAW,GAAG,IAAI,GAAG,EAA6B,CAAC;QACzD,KAAK,MAAM,CAAC,IAAI,QAAQ,CAAC,OAAO;YAAE,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QAC7D,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,GAAsB,EAAoB,EAAE,CAC/D,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC/E,CAAC;IAED,yDAAyD;IACjD,GAAG,CACP,QAAgB,EAAE,GAAsB,EAAE,IAAmB,EAC7D,WAA2C,EAAE,OAAe,EAAE,MAAsB,EAAE,QA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EAAE,GAAG,CAAC,CAAC;QACzE,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACpB,MAAM,KAAK,GAAG,IAAA,sBAAO,EAAC,GAAG,CAAC,CAAC;YAC3B,KAAK,KAAK,CAAC,CAAC,yDAAyD;YACrE,OAAO,IAAI,2BAAY,CAAC,GAAG,EAAE,EAAE,EAAE,+DAA+D,CAAC,CAAC;QACtG,CAAC;IACL,CAAC;CACJ,CAAA;AAlIY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEW,gCAAiB;GADxD,uBAAuB,CAkInC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport {\n BriefedFile, ContextEntry, PrGateConfig, RequiredChecklist, ReviewerBriefing, ReviewJsonService, toError,\n} from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { DiffManifest, DiffManifestEntry } from './diff-materializer';\nimport { ChecklistScan } from './checklist-scanner';\n\n/**\n * Turns a {@link ChecklistScan} plus the materialized {@link DiffManifest} into one {@link ReviewerBriefing}\n * per reviewer — resolving every path to an absolute one, because a reviewer that has to resolve a path\n * ends up searching, and searching is the cost this whole feature exists to remove.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ReviewerBriefingBuilder {\n constructor(private readonly reviewJsonService: ReviewJsonService) {}\n\n /** One briefing per checklist in `checklists` — the OWED ones; a carried verdict is not re-briefed. */\n // eslint-disable-next-line @typescript-eslint/max-params\n build(\n repoRoot: string, scan: ChecklistScan, checklists: readonly RequiredChecklist[], manifest: DiffManifest,\n diffDir: string, config: PrGateConfig,\n ): ReviewerBriefing[] {\n // Resolved ONCE for the whole run, not per reviewer: `require.resolve` hits the filesystem, and the\n // answer cannot differ between two reviewers in the same process.\n const shared = this.contextEntries(repoRoot, config);\n const entryByFile = new Map<string, DiffManifestEntry>();\n for (const e of manifest.entries) entryByFile.set(e.file, e);\n return checklists.map((req: RequiredChecklist): ReviewerBriefing =>\n this.one(repoRoot, req, scan, entryByFile, diffDir, shared, manifest));\n }\n\n // eslint-disable-next-line @typescript-eslint/max-params\n private one(\n repoRoot: string, req: RequiredChecklist, scan: ChecklistScan,\n entryByFile: Map<string, DiffManifestEntry>, diffDir: string, shared: ContextEntry[], manifest: DiffManifest,\n ): ReviewerBriefing {\n const b = new ReviewerBriefing(req.reviewer.agentName, req.id, repoRoot);\n b.docPath = req.doc.trim() === '' ? '' : path.resolve(repoRoot, req.doc);\n b.diffDir = diffDir;\n b.allDiffPath = diffDir === '' ? '' : path.join(diffDir, 'ALL.diff');\n b.manifestPath = diffDir === '' ? '' : path.join(diffDir, 'manifest.json');\n b.myFiles = req.matchedFiles.map((f: string): BriefedFile => this.briefedFile(repoRoot, f, entryByFile));\n b.matchedPatterns = req.matchedPatterns;\n b.required = req.required;\n b.sourceDirs = this.sourceDirsFor(repoRoot, req.matchedFiles);\n b.contextEntries = shared;\n b.verdictPath = this.reviewJsonService.checklistResultPath(scan.summaryPath, req.id);\n b.fileDiffCommand = scan.context.fileDiffCommand;\n b.dirty = scan.basis.dirty;\n b.ownAgentFileInDiff = this.ownAgentFileIn(manifest, req.reviewer.agentName);\n this.copyManifestFacts(b, manifest);\n return b;\n }\n\n /**\n * One row of the reviewer's table. The SOURCE path comes over with the diff path because the two need\n * identical affordance: when the diff was an absolute path and the source was a parent directory, four of\n * four reviewers read the diff and none opened a source file.\n */\n private briefedFile(repoRoot: string, file: string, entryByFile: Map<string, DiffManifestEntry>): BriefedFile {\n const e = entryByFile.get(file);\n if (e === undefined) return new BriefedFile(file, '', path.resolve(repoRoot, file));\n return new BriefedFile(file, e.diffAbs, e.fileAbs, e.status, e.bytes, e.truncated);\n }\n\n /**\n * Manifest headline facts, copied onto the briefing so the instructions can state them INLINE. A reviewer\n * that never opens the manifest still has to learn whether anything was truncated or excluded — that is\n * precisely the thing it could not otherwise know it was missing.\n */\n private copyManifestFacts(b: ReviewerBriefing, manifest: DiffManifest): void {\n b.changedFileCount = manifest.entries.length;\n b.truncatedCount = manifest.entries.filter((e: DiffManifestEntry): boolean => e.truncated).length;\n b.excludedCount = manifest.excluded.length;\n b.allDiffLines = manifest.allDiffLines;\n b.allDiffBytes = manifest.allDiffBytes;\n b.hashForkPoint = manifest.hashForkPoint;\n b.hashFeatureHead = manifest.hashFeatureHead;\n b.hashMainHead = manifest.hashMainHead;\n }\n\n /**\n * The reviewer agent's own `.claude/agents/<agentName>.md`, when THIS diff changes it. Detected here rather than\n * left to the reviewer to notice: on the measured run two reviewers reviewed their own definition and\n * neither mentioned it, and every PR that edits the review gate reproduces that.\n */\n private ownAgentFileIn(manifest: DiffManifest, agentName: string): string {\n const suffix = path.join('.claude', 'agents', `${agentName}.md`);\n const hit = manifest.entries.find((e: DiffManifestEntry): boolean => e.file.split('/').join(path.sep).endsWith(suffix));\n return hit === undefined ? '' : (hit.fileAbs === '' ? hit.file : hit.fileAbs);\n }\n\n /**\n * Deduped absolute parent dirs of the matched files. Dirs rather than files because the point is to say\n * \"the neighbourhood is here\" — a reviewer already has the file list; what it lacks is where to look for\n * the code AROUND the change.\n */\n private sourceDirsFor(repoRoot: string, files: readonly string[]): string[] {\n const dirs = new Set<string>();\n for (const f of files) dirs.add(path.resolve(repoRoot, path.dirname(f)));\n return [...dirs].sort();\n }\n\n /**\n * The pre-resolved context list, from two config keys with deliberately different jobs:\n *\n * `reviewContextPackages` — installed packages, resolved to their real on-disk dir. This is what deletes\n * the repeated `node_modules/@webpieces` greps: the tooling knows where a package resolved to, and the\n * reviewer does not.\n * `reviewContext` — the repo-specific escape hatch (`{label, path}`) for what tooling cannot possibly\n * guess, e.g. \"queue names live in terraform/services/\".\n *\n * Neither ever drops an entry: an unresolvable package or a missing path is LISTED, with the reason. A\n * silently shorter list is indistinguishable from a complete one.\n */\n private contextEntries(repoRoot: string, config: PrGateConfig): ContextEntry[] {\n const entries: ContextEntry[] = [];\n for (const pkg of config.reviewContextPackages) entries.push(this.resolvePackage(repoRoot, pkg));\n for (const item of config.reviewContext) {\n const abs = path.resolve(repoRoot, item.path);\n entries.push(fs.existsSync(abs)\n ? new ContextEntry(item.label, abs)\n : new ContextEntry(item.label, '', `(configured as \"${item.path}\" but missing)`));\n }\n return entries;\n }\n\n private resolvePackage(repoRoot: string, pkg: string): ContextEntry {\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: an unresolvable package is REPORTED as such, never fatal\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const manifestPath = require.resolve(`${pkg}/package.json`, { paths: [repoRoot] });\n const dir = path.dirname(manifestPath);\n // webpieces-disable no-any-unknown -- opaque package.json, only `description` is read\n const meta = JSON.parse(fs.readFileSync(manifestPath, 'utf8')) as Record<string, unknown>;\n const desc = typeof meta['description'] === 'string' ? (meta['description'] as string) : '';\n return new ContextEntry(desc === '' ? pkg : `${pkg} — ${desc}`, dir);\n } catch (err: unknown) {\n const error = toError(err);\n void error; // an unresolvable package is REPORTED below, never fatal\n return new ContextEntry(pkg, '', '(not installed — configured in pr-gate.reviewContextPackages)');\n }\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ChecklistInstructionsService, ReviewJsonService } from '@webpieces/rules-config';
|
|
2
2
|
import { ChecklistScan } from './checklist-scanner';
|
|
3
3
|
/**
|
|
4
|
-
* The gate `wp-finish-upsert-pr` runs before it parses
|
|
4
|
+
* The gate `wp-finish-upsert-pr` runs before it parses summary.json: REFUSE the PR while any applicable
|
|
5
5
|
* checklist is not clear, and say — per checklist — which of three different things went wrong.
|
|
6
6
|
*
|
|
7
7
|
* It is its own class, not a private method on the command, for two reasons. It is the one piece of finish
|
|
@@ -6,7 +6,7 @@ const rules_config_1 = require("@webpieces/rules-config");
|
|
|
6
6
|
const inversify_1 = require("inversify");
|
|
7
7
|
const verdict_provenance_1 = require("./verdict-provenance");
|
|
8
8
|
/**
|
|
9
|
-
* The gate `wp-finish-upsert-pr` runs before it parses
|
|
9
|
+
* The gate `wp-finish-upsert-pr` runs before it parses summary.json: REFUSE the PR while any applicable
|
|
10
10
|
* checklist is not clear, and say — per checklist — which of three different things went wrong.
|
|
11
11
|
*
|
|
12
12
|
* It is its own class, not a private method on the command, for two reasons. It is the one piece of finish
|
|
@@ -146,7 +146,7 @@ let ReviewerVerdictGate = class ReviewerVerdictGate {
|
|
|
146
146
|
if (neverRan.length === 0)
|
|
147
147
|
return '';
|
|
148
148
|
return '❓ NO VERDICT YET — nothing that counts has been submitted for these, so they must actually be run:\n\n'
|
|
149
|
-
+ `${this.instructions.render(neverRan, scan.
|
|
149
|
+
+ `${this.instructions.render(neverRan, scan.summaryPath, scan.context)}\n\n`;
|
|
150
150
|
}
|
|
151
151
|
/**
|
|
152
152
|
* Retire ONE refused checklist's verdict and render the refusal that reports it.
|
|
@@ -164,21 +164,21 @@ let ReviewerVerdictGate = class ReviewerVerdictGate {
|
|
|
164
164
|
retireAndReport(scan, req) {
|
|
165
165
|
const verdict = this.reviewJsonService.resolveVerdict(req, scan.results);
|
|
166
166
|
if (scan.singleRoundReview) {
|
|
167
|
-
const live = this.reviewJsonService.checklistResultPath(scan.
|
|
167
|
+
const live = this.reviewJsonService.checklistResultPath(scan.summaryPath, req.id);
|
|
168
168
|
return `Checklist "${req.id}" FAILED review (status:"red"). The reviewer wrote:\n`
|
|
169
169
|
+ ` ${verdict.detail}\n`
|
|
170
170
|
+ ` DO NOT RERUN this reviewer. After fixing every finding, edit ${live}.\n`
|
|
171
171
|
+ ' Change its addressed red status to "yellow". Yellow is accepted by the gate. If you genuinely\n'
|
|
172
172
|
+ ' disagree, leave it red and flag the human BEFORE posting the PR; red remains blocking.';
|
|
173
173
|
}
|
|
174
|
-
return this.reviewJsonService.refusalError(req, verdict, scan.
|
|
174
|
+
return this.reviewJsonService.refusalError(req, verdict, scan.summaryPath, this.archiveOrWarn(scan.summaryPath, req.id));
|
|
175
175
|
}
|
|
176
176
|
// The archive path, or '' when there was nothing to move or the move failed (see retireAndReport).
|
|
177
|
-
archiveOrWarn(
|
|
177
|
+
archiveOrWarn(summaryPath, checklistId) {
|
|
178
178
|
// webpieces-disable no-unmanaged-exceptions -- chokepoint: a failed archive must never swallow the refusal it belongs to
|
|
179
179
|
// eslint-disable-next-line @webpieces/no-unmanaged-exceptions
|
|
180
180
|
try {
|
|
181
|
-
return this.reviewJsonService.archiveChecklistResult(
|
|
181
|
+
return this.reviewJsonService.archiveChecklistResult(summaryPath, checklistId);
|
|
182
182
|
}
|
|
183
183
|
catch (err) {
|
|
184
184
|
const error = (0, rules_config_1.toError)(err);
|