@webpieces/pr-gate 0.4.826 → 0.4.827

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/package.json +3 -3
  2. package/src/dashboard/checklist-comment-renderer.js +8 -6
  3. package/src/dashboard/checklist-comment-renderer.js.map +1 -1
  4. package/src/dashboard/checklist-comment-row.d.ts +6 -0
  5. package/src/dashboard/checklist-comment-row.js +6 -0
  6. package/src/dashboard/checklist-comment-row.js.map +1 -1
  7. package/src/dashboard/dashboard.d.ts +11 -0
  8. package/src/dashboard/dashboard.js +24 -6
  9. package/src/dashboard/dashboard.js.map +1 -1
  10. package/src/scripts/commands/await-reviews-command.d.ts +3 -3
  11. package/src/scripts/commands/await-reviews-command.js +24 -20
  12. package/src/scripts/commands/await-reviews-command.js.map +1 -1
  13. package/src/scripts/commands/finish-upsert-pr-command.js +27 -31
  14. package/src/scripts/commands/finish-upsert-pr-command.js.map +1 -1
  15. package/src/scripts/commands/review-upsert-pr-command.d.ts +3 -8
  16. package/src/scripts/commands/review-upsert-pr-command.js +15 -17
  17. package/src/scripts/commands/review-upsert-pr-command.js.map +1 -1
  18. package/src/scripts/commands/write-review-command.d.ts +29 -15
  19. package/src/scripts/commands/write-review-command.js +62 -29
  20. package/src/scripts/commands/write-review-command.js.map +1 -1
  21. package/src/scripts/commands/write-review-fixes-command.d.ts +5 -1
  22. package/src/scripts/commands/write-review-fixes-command.js +6 -5
  23. package/src/scripts/commands/write-review-fixes-command.js.map +1 -1
  24. package/src/scripts/workflow/checklist-scanner.d.ts +47 -22
  25. package/src/scripts/workflow/checklist-scanner.js +77 -34
  26. package/src/scripts/workflow/checklist-scanner.js.map +1 -1
  27. package/src/scripts/workflow/provenance-enforcer.d.ts +2 -2
  28. package/src/scripts/workflow/provenance-enforcer.js +5 -5
  29. package/src/scripts/workflow/provenance-enforcer.js.map +1 -1
  30. package/src/scripts/workflow/review-report.d.ts +26 -8
  31. package/src/scripts/workflow/review-report.js +61 -39
  32. package/src/scripts/workflow/review-report.js.map +1 -1
  33. package/src/scripts/workflow/review-round-state.d.ts +87 -22
  34. package/src/scripts/workflow/review-round-state.js +252 -104
  35. package/src/scripts/workflow/review-round-state.js.map +1 -1
  36. package/src/scripts/workflow/review-round-text.d.ts +37 -0
  37. package/src/scripts/workflow/review-round-text.js +87 -0
  38. package/src/scripts/workflow/review-round-text.js.map +1 -0
  39. package/src/scripts/workflow/review-stage-receipt.d.ts +7 -19
  40. package/src/scripts/workflow/review-stage-receipt.js +7 -31
  41. package/src/scripts/workflow/review-stage-receipt.js.map +1 -1
  42. package/src/scripts/workflow/reviewer-briefing-builder.js +0 -1
  43. package/src/scripts/workflow/reviewer-briefing-builder.js.map +1 -1
  44. package/src/scripts/workflow/reviewer-verdict-gate.d.ts +14 -26
  45. package/src/scripts/workflow/reviewer-verdict-gate.js +38 -51
  46. package/src/scripts/workflow/reviewer-verdict-gate.js.map +1 -1
  47. package/src/scripts/workflow/verdict-provenance.d.ts +10 -10
  48. package/src/scripts/workflow/verdict-provenance.js +25 -23
  49. package/src/scripts/workflow/verdict-provenance.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"review-upsert-pr-command.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/commands/review-upsert-pr-command.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;AAC7B,0DAA6N;AAC7N,yCAA2D;AAC3D,+DAA4E;AAC5E,2EAAgE;AAChE,+DAA6E;AAC7E,+DAA0D;AAC1D,yEAAoE;AACpE,qEAAsG;AACtG,qEAAiE;AACjE,mDAA+C;AAC/C,yDAAuD;AACvD,qDAAkE;AAClE,yDAAqD;AACrD,qEAAgE;AAChE,qFAAgF;AAChF,6DAA6F;AAC7F,2EAAiG;AACjG,mEAAkF;AAClF,yEAAqE;AACrE,uEAEwC;AAExC,MAAM,GAAG,GAAG,0DAA0D,CAAC;AAEvE,kGAAkG;AAClG,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,EAAE,CAAC,IAAI,+BAAe,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,iBAAiB,CAAC,YAAY,CAAC,GAAG,EAAE,IAAI,CAAC,iBAAiB,CAAC,cAAc,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IACvN,CAAC;CACJ,CAAA;AAjOY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAIA,6BAAc;QAChB,mCAAY;QACjB,kBAAO;QACD,8BAAa;QACT,uCAAiB;QACxB,wBAAU;QACZ,oBAAQ;QACA,oCAAgB;QACpB,4BAAY;QACZ,oCAAgB;QACb,mCAAe;QACf,mDAAuB;QAClB,0CAA2B;QACvC,gDAAyB;QAChB,kCAAiB;QAEjB,gCAAiB;QACtB,iCAAc;QACZ,6BAAc;QACV,wCAAkB;QAC9B,4CAAuB;GAvB3C,qBAAqB,CAiOjC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { loadAndValidate, writeTemplate, PrGateConfig, RepoRootFinder, RequiredChecklist, ReviewerBriefing, ReviewerInstructionsService, ReviewJsonService, BranchIdentity, summaryJsonPath } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { ActiveHatch, ActiveHatchReport } from '../workflow/active-hatches';\nimport { AiBranchName } from '../workflow/git-readAiBranchName';\nimport { BuildAffected, BuildGateOptions } from '../workflow/build-affected';\nimport { REVIEW_STAGE } from '../workflow/build-gate-log';\nimport { BuildArtifactGate } from '../workflow/build-artifact-gate';\nimport { ChecklistScan, ChecklistScanOptions, ChecklistScanner } from '../workflow/checklist-scanner';\nimport { DiffMaterializer } from '../workflow/diff-materializer';\nimport { GitExec } from '../workflow/git-exec';\nimport { MergeContext } from '../workflow/merge-start';\nimport { MergeEnd, MergeEndOptions } from '../workflow/merge-end';\nimport { MergeState } from '../workflow/merge-state';\nimport { PrContextWriter } from '../workflow/pr-context-writer';\nimport { ReviewerBriefingBuilder } from '../workflow/reviewer-briefing-builder';\nimport { RefusedReviewer, ReviewReport, ReviewReportInput } from '../workflow/review-report';\nimport { ReviewStageReceipt, ReviewStageReceiptService } from '../workflow/review-stage-receipt';\nimport { StageOutputLog, REVIEW_CONSOLE_LOG } from '../workflow/stage-output-log';\nimport { HotfixInstructions } from '../workflow/hotfix-instructions';\nimport {\n ReviewRoundPlan, ReviewRoundStateService, ROUND_ACTION_REVIEW, ROUND_ACTION_RESUME,\n} from '../workflow/review-round-state';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/** The `--no-optional` decision, as data (per CLAUDE.md) rather than a bare boolean parameter. */\nexport class ReviewUpsertPrOptions {\n /**\n * true ⇒ the human ALREADY said to submit without the optional reviews, so stage ② must not print the\n * block telling the AI to offer them. It changes nothing about what BLOCKS: required checklists are\n * unaffected, and an optional checklist that already has a red verdict on this branch still refuses the\n * PR at finish. This only suppresses the offer.\n */\n skipOptional: boolean;\n\n constructor(skipOptional = false) {\n this.skipOptional = skipOptional;\n }\n}\n\n/**\n * `wp-review-upsert-pr` — STAGE ② of the three-stage PR flow, between `wp-start-upsert-pr` (sync from main)\n * and `wp-finish-upsert-pr` (post the PR).\n *\n * It exists because reviewing came before verifying. Under the old two-command flow the 3-point merge was\n * finalized and the build gate ran inside `wp-finish-upsert-pr` — i.e. AFTER the reviewers had already run.\n * A reviewer could therefore spend a full review on an unresolved merge, or on code that does not compile,\n * and only afterwards would the branch be checked. This command puts the verification first:\n *\n * 1. finalize + VALIDATE any in-progress 3-point merge (moved here from finish)\n * 2. assert a clean tree (meaningful now — step 1 committed the resolution)\n * 3. run the build gate (on the merged, committed tree)\n * 4. scan the checklists, EXTRACT the diff, BRIEF the reviewers\n * 5. write the stage receipt, then print what to spawn + the summary.json schema\n *\n * Unlike the report-only command it replaces — which always exited 0, because reporting is not gating — this\n * command CAN FAIL, at steps 1, 2 and 3. That is the point: it fails BEFORE any reviewer is spawned, so a\n * branch with an unresolved merge or a broken build costs zero reviewer tokens.\n *\n * The ordering of 1 → 2 → 3 is load-bearing. MergeEnd stages and commits the conflict resolution, so the\n * tree is clean by the time the build runs; building first would either build a dirty tree (proving nothing\n * about what ships) or refuse a tree that is legitimately mid-resolution.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ReviewUpsertPrCommand {\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n private readonly repoRootFinder: RepoRootFinder,\n private readonly aiBranchName: AiBranchName,\n private readonly gitExec: GitExec,\n private readonly buildAffected: BuildAffected,\n private readonly buildArtifactGate: BuildArtifactGate,\n private readonly mergeState: MergeState,\n private readonly mergeEnd: MergeEnd,\n private readonly checklistScanner: ChecklistScanner,\n private readonly reviewReport: ReviewReport,\n private readonly materializer: DiffMaterializer,\n private readonly prContextWriter: PrContextWriter,\n private readonly briefingBuilder: ReviewerBriefingBuilder,\n private readonly reviewerInstructions: ReviewerInstructionsService,\n private readonly receipts: ReviewStageReceiptService,\n private readonly activeHatchReport: ActiveHatchReport,\n // Injected only to RESOLVE + RENDER refusals (see refusals()). This stage never archives a verdict.\n private readonly reviewJsonService: ReviewJsonService,\n private readonly stageConsole: StageOutputLog,\n private readonly branchIdentity: BranchIdentity,\n private readonly hotfixInstructions: HotfixInstructions,\n private readonly rounds: ReviewRoundStateService,\n ) {}\n\n /**\n * Everything below runs with this stage's console CAPTURED to a file (see StageOutputLog). Only the\n * lines an agent must act on before it can do anything else reach the terminal — the build heartbeat\n * and result, and the closing instruction block. The merge validation, the hatch report, the checklist\n * scan and the diff extraction are all in the file, one `grep` away.\n *\n * This is the FIRST half of the fix for the piped-command watchdog kill: an agent pipes a command it\n * expects to flood, a pipe withholds every byte until exit, and the harness kills a command that has\n * printed nothing for 600 seconds — after a full build. Guarding the pipe without first shrinking the\n * output would only have traded that kill for a flooded context.\n */\n async run(opts: ReviewUpsertPrOptions = new ReviewUpsertPrOptions()): Promise<void> {\n const repoRoot = this.repoRootFinder.resolveRepoRoot(process.cwd());\n await this.stageConsole.withCapture(repoRoot, REVIEW_CONSOLE_LOG, (): Promise<void> => this.runStage(repoRoot, opts));\n }\n\n private async runStage(repoRoot: string, opts: ReviewUpsertPrOptions): Promise<void> {\n if (this.branchIdentity.isHotfix()) {\n const summaryPath = summaryJsonPath(repoRoot, this.aiBranchName.getFeatureName());\n this.stageConsole.say(this.hotfixInstructions.reviewNoOp(summaryPath));\n return;\n }\n writeTemplate(repoRoot, 'webpieces.git-workflow.md');\n writeTemplate(repoRoot, 'webpieces.review-checklists.md');\n const featureName = this.aiBranchName.getFeatureName();\n const config = loadAndValidate(repoRoot).prGate;\n\n const mergeValidated = await this.finalizeAnyInProgressMerge(repoRoot);\n this.gitExec.assertCleanTree(repoRoot);\n const buildPassedAt = await this.runBuildGate(repoRoot);\n\n const scan = this.checklistScanner.scan(repoRoot, config.checklists, new ChecklistScanOptions(config.maxReviewerRounds, false, '')); // '' — THIS command writes the context itself, after materializing\n const previousReceipt = this.receipts.read(repoRoot, featureName);\n const plan = this.rounds.plan(repoRoot, scan.summaryPath, previousReceipt, config.maxReviewerRounds, scan.basis);\n const shouldBrief = plan.action === ROUND_ACTION_REVIEW || plan.action === ROUND_ACTION_RESUME;\n const briefings = shouldBrief\n ? this.briefReviewers(repoRoot, featureName, scan, config, plan)\n : [];\n const recordedReviewers = briefings.map((b: ReviewerBriefing): string => b.checklistId);\n if (shouldBrief) {\n const receipt = new ReviewStageReceipt(scan.basis.headSha, mergeValidated, this.buildAffected.resolveBuildCommand(repoRoot), buildPassedAt, recordedReviewers);\n receipt.scopeHashes = scan.scopeHashes;\n // A global round begins only when a non-empty fixed roster is actually briefed.\n receipt.round = recordedReviewers.length === 0 ? 0 : plan.round;\n receipt.maxReviewerRounds = plan.maxRounds;\n receipt.remediationFromHead = plan.round > 1 ? plan.basis.base : '';\n this.receipts.write(repoRoot, featureName, receipt);\n }\n this.reportActiveHatches(repoRoot);\n this.report(repoRoot, featureName, scan, briefings, opts, plan, config);\n }\n\n /**\n * List every rule that is currently switched off in webpieces.config.json. NON-BLOCKING and printed\n * before the instruction block, because it is context for the review rather than a step in it.\n *\n * A hatch is the one config change that makes the build QUIETER, so no gate, reviewer or red check\n * will ever mention it — which is how a repo ends up with rules off for weeks that nobody chose to\n * leave off. This is the only place in the flow that says so out loud.\n */\n private reportActiveHatches(repoRoot: string): void {\n const hatches: ActiveHatch[] = this.activeHatchReport.scan(repoRoot);\n process.stdout.write(this.activeHatchReport.render(hatches));\n }\n\n /**\n * Validate + commit + finalize a conflict resolution, if one is in flight. MOVED here from\n * `wp-finish-upsert-pr` so that exactly one command owns merge finalization — two owners is the drift\n * failure `PrContextWriter`'s own docstring records having already happened once in this codebase.\n *\n * MergeEnd's three checks are what \"did the AI do the 3-point merge right?\" means concretely: no\n * conflict markers left in the scoped files, `git diff --diff-filter=U` empty, and a non-empty\n * merge-explanation.md beside every conflicted file.\n *\n * Returns true when a merge was finalized OR there was none to finalize; it throws rather than returning\n * false when validation fails, so the receipt can never record an unvalidated merge as validated.\n */\n private async finalizeAnyInProgressMerge(repoRoot: string): Promise<boolean> {\n const home = this.mergeState.mergeDirFor(repoRoot, this.aiBranchName.getFeatureName());\n const activeDir = this.mergeState.findActiveMergeRunDir(home);\n const marker = activeDir ? this.mergeState.readMergeMarker(activeDir) : null;\n if (!activeDir || !marker || marker.validated) return true;\n process.stdout.write('\\n' + SEP + '① Validating your 3-point merge\\n' + SEP + '\\n');\n // pushRemote:false — finish still owns the single push.\n await this.mergeEnd.mergeEnd(repoRoot, 'wp-review-upsert-pr', activeDir, new MergeContext(marker.currentBranch, marker.squashBranch, marker.backupBranch, marker.prNumber), new MergeEndOptions(marker.conflictedFiles, false));\n return true;\n }\n\n /**\n * The build gate, run BEFORE any reviewer is briefed. Returns the ISO time it passed, for the receipt —\n * which is what lets `wp-finish-upsert-pr` skip its own gate when HEAD has not moved, so moving the gate\n * earlier did not turn one build into two.\n */\n private async runBuildGate(repoRoot: string): Promise<string> {\n await this.buildAffected.runBuildGate(repoRoot, new BuildGateOptions('🛠️ Build gate', 'pnpm wp-review-upsert-pr', 'Build failed — NO reviewer was briefed and no diff was extracted. Fix it, then re-run.', REVIEW_STAGE));\n // Repo-wide: the build must not have left anything uncommitted AND unstaged. Runs HERE, not in\n // finish, because this is the stage that ran buildCommand and is therefore holding the dirty\n // tree at the exact moment the question is answerable. Replaces the per-project\n // validate-di-graph-unchanged nx target — see BuildArtifactGate for why that one had to go.\n this.buildArtifactGate.assertBuildLeftNothingUncommitted(repoRoot);\n return new Date().toISOString();\n }\n\n /**\n * Extract the diff once, then write one instructions file per reviewer.\n *\n * The changed-file set and the basis both come off the SCAN rather than being recomputed, so the diff a\n * reviewer reads covers exactly the files its checklist matched against.\n */\n private briefReviewers(repoRoot: string, featureName: string, scan: ChecklistScan, config: PrGateConfig, plan: ReviewRoundPlan): ReviewerBriefing[] {\n if (plan.basis.unresolved) return [];\n const changedFiles = plan.round > 1 ? plan.changedFiles : scan.changedFiles;\n const manifest = this.materializer.materialize(repoRoot, featureName, plan.basis, changedFiles, config.reviewDiffExclude);\n const diffDir = this.materializer.diffDirFor(repoRoot, featureName);\n // Write pr-context.json ONCE, here — after materializing, so `diffDir` is populated on the first\n // write. The scan deliberately did not write it (ChecklistScanOptions.contextStage === ''); it used\n // to, which meant this command wrote the same file twice, the first time with an empty diffDir.\n // `scan.changedFiles` is passed through so the context is not recomputed from a second git call.\n scan.context = this.prContextWriter.ensure(repoRoot, featureName, plan.basis, 'stage2-review', changedFiles, diffDir);\n // ONLY the checklists still owed a verdict (issue #863). A green or yellow whose in-scope diff is\n // unchanged since it was submitted CARRIES — the scan left it in `reviewed` — so briefing it again\n // would pay a reviewer to re-read code it already judged. Red, stale and never-run are briefed.\n const reviewedIds = new Set(scan.reviewed.map((r: RequiredChecklist): string => r.id));\n const owed = scan.applicable.filter((r: RequiredChecklist): boolean => !reviewedIds.has(r.id));\n const briefings = this.briefingBuilder.build(repoRoot, scan, owed, manifest, diffDir, config);\n const dir = this.reviewerInstructions.instructionsDirFor(repoRoot, featureName);\n fs.rmSync(dir, { recursive: true, force: true }); // stale instructions read as current are worse than none\n fs.mkdirSync(dir, { recursive: true });\n for (const b of briefings) {\n b.round = plan.round;\n b.maxRounds = plan.maxRounds;\n b.remediationOnly = plan.round > 1;\n if (b.remediationOnly) {\n b.previousVerdictPath = path.join(this.rounds.roundDir(scan.summaryPath, plan.round - 1), `review-${b.checklistId}.json`);\n b.remediationPath = this.rounds.remediationPath(scan.summaryPath, plan.round - 1);\n }\n fs.writeFileSync(this.reviewerInstructions.pathFor(repoRoot, featureName, b.checklistId), this.reviewerInstructions.render(b));\n }\n return briefings;\n }\n\n /**\n * What the AI must do next — rendered by `ReviewReport`, which owns the ordering.\n *\n * The rendering moved OUT of this command so the ordering could be asserted on as a string. It had a\n * real bug: the zero-checklist notice signed off with \"Carry on and run: pnpm wp-finish-upsert-pr\"\n * while the block right beneath it said to write summary.json first. An agent that reads top to bottom\n * obeyed the first line and posted a PR with no review at all.\n */\n // eslint-disable-next-line @typescript-eslint/max-params\n private report(repoRoot: string, featureName: string, scan: ChecklistScan, briefings: readonly ReviewerBriefing[], opts: ReviewUpsertPrOptions, plan: ReviewRoundPlan, config: PrGateConfig): void {\n const input = new ReviewReportInput(repoRoot, featureName, scan.summaryPath);\n input.definedCount = scan.defined.length;\n input.applicableCount = scan.applicable.length;\n input.reviewed = scan.reviewed.slice();\n input.formatErrors = scan.formatErrors.slice();\n input.briefings = briefings.slice();\n input.refused = this.refusals(scan);\n input.skipOptional = opts.skipOptional;\n input.reviewer = config.reviewer;\n // Straight off the SCAN — the one place `experimental.turnOffAllReviewers` is read. This command\n // deliberately does NOT consult the home config itself: a second read is a second answer, and the\n // command that lists and the command that blocks would be free to disagree about whether a branch\n // was reviewed. See ChecklistScanner.\n input.reviewersSuppressed = scan.reviewersDisabled;\n input.suppressed = scan.suppressed.slice();\n input.round = plan.round;\n input.maxReviewerRounds = plan.maxRounds;\n input.roundAction = plan.action;\n input.redChecklistIds = plan.redChecklistIds.slice();\n input.standings = scan.standings.slice();\n // `say`: this block IS the next action — which reviewers to spawn, where summary.json goes, and\n // the command after that. Capturing it into the log would leave the terminal with a pointer and\n // no instruction, which is the one thing this stage may never do.\n this.stageConsole.say(this.reviewReport.render(input));\n }\n\n /**\n * The applicable checklists that ALREADY ANSWERED and refused, each with its refusal rendered by the ONE\n * renderer `wp-finish-upsert-pr` also uses.\n *\n * Stage ② had the identical defect finish did: a refused checklist has no passing verdict, so it is not\n * in `scan.reviewed`, so it was printed as an ordinary owed reviewer and re-instructed word for word —\n * and an agent that obeys spawns it against unchanged code, gets the same refusal, and loops one stage\n * earlier than the loop that was reported.\n *\n * NO archive path is passed, deliberately, and this stage moves nothing. Retiring a verdict is finish's\n * act on the refusal it is actually enforcing; doing it here would delete the live verdict of a branch\n * that has not even been asked to finish yet, and `refusalError`'s un-archived wording — \"fix it, then\n * re-run\" — is only correct while that verdict file is still there, which here it is.\n *\n * The review path IS passed, because the ship-anyway route the refusal prints is a command that writes\n * `override-<id>.json` beside it. That command is as correct at this stage as at finish: the override\n * is a separate file with its own writer, so nothing about it depends on the verdict having been moved.\n */\n private refusals(scan: ChecklistScan): RefusedReviewer[] {\n const refused = this.reviewJsonService.refusedChecklists(scan.applicable, scan.results);\n return refused.map((req: RequiredChecklist): RefusedReviewer => new RefusedReviewer(req.id, this.reviewJsonService.refusalError(req, this.reviewJsonService.resolveVerdict(req, scan.results), scan.summaryPath)));\n }\n}\n"]}
1
+ {"version":3,"file":"review-upsert-pr-command.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/commands/review-upsert-pr-command.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,0DAA6N;AAC7N,yCAA2D;AAC3D,+DAA4E;AAC5E,2EAAgE;AAChE,+DAA6E;AAC7E,+DAA0D;AAC1D,yEA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IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QAC3C,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACzC,gGAAgG;QAChG,gGAAgG;QAChG,kEAAkE;QAClE,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED;;;;;;;;;;;;OAYG;IACK,QAAQ,CAAC,IAAmB;QAChC,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACxF,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,GAAsB,EAAmB,EAAE,CAAC,IAAI,+BAAe,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,iBAAiB,CAAC,YAAY,CAAC,GAAG,EAAE,IAAI,CAAC,iBAAiB,CAAC,cAAc,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IACvN,CAAC;CACJ,CAAA;AAhOY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAIA,6BAAc;QAChB,mCAAY;QACjB,kBAAO;QACD,8BAAa;QACT,uCAAiB;QACxB,wBAAU;QACZ,oBAAQ;QACA,oCAAgB;QACpB,4BAAY;QACZ,oCAAgB;QACb,mCAAe;QACf,mDAAuB;QAClB,0CAA2B;QACvC,gDAAyB;QAChB,kCAAiB;QAEjB,gCAAiB;QACtB,iCAAc;QACZ,6BAAc;QACV,wCAAkB;QAC9B,4CAAuB;GAvB3C,qBAAqB,CAgOjC","sourcesContent":["import * as fs from 'fs';\nimport { loadAndValidate, writeTemplate, PrGateConfig, RepoRootFinder, RequiredChecklist, ReviewerBriefing, ReviewerInstructionsService, ReviewJsonService, BranchIdentity, summaryJsonPath } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { ActiveHatch, ActiveHatchReport } from '../workflow/active-hatches';\nimport { AiBranchName } from '../workflow/git-readAiBranchName';\nimport { BuildAffected, BuildGateOptions } from '../workflow/build-affected';\nimport { REVIEW_STAGE } from '../workflow/build-gate-log';\nimport { BuildArtifactGate } from '../workflow/build-artifact-gate';\nimport { ChecklistScan, ChecklistScanOptions, ChecklistScanner } from '../workflow/checklist-scanner';\nimport { DiffMaterializer } from '../workflow/diff-materializer';\nimport { GitExec } from '../workflow/git-exec';\nimport { MergeContext } from '../workflow/merge-start';\nimport { MergeEnd, MergeEndOptions } from '../workflow/merge-end';\nimport { MergeState } from '../workflow/merge-state';\nimport { PrContextWriter } from '../workflow/pr-context-writer';\nimport { ReviewerBriefingBuilder } from '../workflow/reviewer-briefing-builder';\nimport { RefusedReviewer, ReviewReport, ReviewReportInput } from '../workflow/review-report';\nimport { ReviewStageReceipt, ReviewStageReceiptService } from '../workflow/review-stage-receipt';\nimport { StageOutputLog, REVIEW_CONSOLE_LOG } from '../workflow/stage-output-log';\nimport { HotfixInstructions } from '../workflow/hotfix-instructions';\nimport {\n ReviewRoundPlan, ReviewRoundStateService, ROUND_ACTION_REVIEW, ROUND_ACTION_RESUME,\n} from '../workflow/review-round-state';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/** The `--no-optional` decision, as data (per CLAUDE.md) rather than a bare boolean parameter. */\nexport class ReviewUpsertPrOptions {\n /**\n * true ⇒ the human ALREADY said to submit without the optional reviews, so stage ② must not print the\n * block telling the AI to offer them. It changes nothing about what BLOCKS: required checklists are\n * unaffected, and an optional checklist that already has a red verdict on this branch still refuses the\n * PR at finish. This only suppresses the offer.\n */\n skipOptional: boolean;\n\n constructor(skipOptional = false) {\n this.skipOptional = skipOptional;\n }\n}\n\n/**\n * `wp-review-upsert-pr` — STAGE ② of the three-stage PR flow, between `wp-start-upsert-pr` (sync from main)\n * and `wp-finish-upsert-pr` (post the PR).\n *\n * It exists because reviewing came before verifying. Under the old two-command flow the 3-point merge was\n * finalized and the build gate ran inside `wp-finish-upsert-pr` — i.e. AFTER the reviewers had already run.\n * A reviewer could therefore spend a full review on an unresolved merge, or on code that does not compile,\n * and only afterwards would the branch be checked. This command puts the verification first:\n *\n * 1. finalize + VALIDATE any in-progress 3-point merge (moved here from finish)\n * 2. assert a clean tree (meaningful now — step 1 committed the resolution)\n * 3. run the build gate (on the merged, committed tree)\n * 4. scan the checklists, EXTRACT the diff, BRIEF the reviewers\n * 5. write the stage receipt, then print what to spawn + the summary.json schema\n *\n * Unlike the report-only command it replaces — which always exited 0, because reporting is not gating — this\n * command CAN FAIL, at steps 1, 2 and 3. That is the point: it fails BEFORE any reviewer is spawned, so a\n * branch with an unresolved merge or a broken build costs zero reviewer tokens.\n *\n * The ordering of 1 → 2 → 3 is load-bearing. MergeEnd stages and commits the conflict resolution, so the\n * tree is clean by the time the build runs; building first would either build a dirty tree (proving nothing\n * about what ships) or refuse a tree that is legitimately mid-resolution.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ReviewUpsertPrCommand {\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n private readonly repoRootFinder: RepoRootFinder,\n private readonly aiBranchName: AiBranchName,\n private readonly gitExec: GitExec,\n private readonly buildAffected: BuildAffected,\n private readonly buildArtifactGate: BuildArtifactGate,\n private readonly mergeState: MergeState,\n private readonly mergeEnd: MergeEnd,\n private readonly checklistScanner: ChecklistScanner,\n private readonly reviewReport: ReviewReport,\n private readonly materializer: DiffMaterializer,\n private readonly prContextWriter: PrContextWriter,\n private readonly briefingBuilder: ReviewerBriefingBuilder,\n private readonly reviewerInstructions: ReviewerInstructionsService,\n private readonly receipts: ReviewStageReceiptService,\n private readonly activeHatchReport: ActiveHatchReport,\n // Injected to RESOLVE + RENDER refusals (see refusals()) and to name each round's verdict file.\n private readonly reviewJsonService: ReviewJsonService,\n private readonly stageConsole: StageOutputLog,\n private readonly branchIdentity: BranchIdentity,\n private readonly hotfixInstructions: HotfixInstructions,\n private readonly rounds: ReviewRoundStateService,\n ) {}\n\n /**\n * Everything below runs with this stage's console CAPTURED to a file (see StageOutputLog). Only the\n * lines an agent must act on before it can do anything else reach the terminal — the build heartbeat\n * and result, and the closing instruction block. The merge validation, the hatch report, the checklist\n * scan and the diff extraction are all in the file, one `grep` away.\n *\n * This is the FIRST half of the fix for the piped-command watchdog kill: an agent pipes a command it\n * expects to flood, a pipe withholds every byte until exit, and the harness kills a command that has\n * printed nothing for 600 seconds — after a full build. Guarding the pipe without first shrinking the\n * output would only have traded that kill for a flooded context.\n */\n async run(opts: ReviewUpsertPrOptions = new ReviewUpsertPrOptions()): Promise<void> {\n const repoRoot = this.repoRootFinder.resolveRepoRoot(process.cwd());\n await this.stageConsole.withCapture(repoRoot, REVIEW_CONSOLE_LOG, (): Promise<void> => this.runStage(repoRoot, opts));\n }\n\n private async runStage(repoRoot: string, opts: ReviewUpsertPrOptions): Promise<void> {\n if (this.branchIdentity.isHotfix()) {\n const summaryPath = summaryJsonPath(repoRoot, this.aiBranchName.getFeatureName());\n this.stageConsole.say(this.hotfixInstructions.reviewNoOp(summaryPath));\n return;\n }\n writeTemplate(repoRoot, 'webpieces.git-workflow.md');\n writeTemplate(repoRoot, 'webpieces.review-checklists.md');\n const featureName = this.aiBranchName.getFeatureName();\n const config = loadAndValidate(repoRoot).prGate;\n\n const mergeValidated = await this.finalizeAnyInProgressMerge(repoRoot);\n this.gitExec.assertCleanTree(repoRoot);\n const buildPassedAt = await this.runBuildGate(repoRoot);\n\n const scan = this.checklistScanner.scan(repoRoot, config.checklists, new ChecklistScanOptions(config.maxReviewerRounds, false, '')); // '' — THIS command writes the context itself, after materializing\n const previousReceipt = this.receipts.read(repoRoot, featureName);\n const plan = this.rounds.plan(repoRoot, scan.summaryPath, previousReceipt, config.maxReviewerRounds, scan.basis);\n const shouldBrief = plan.action === ROUND_ACTION_REVIEW || plan.action === ROUND_ACTION_RESUME;\n const briefings = shouldBrief\n ? this.briefReviewers(repoRoot, featureName, scan, config, plan)\n : [];\n const recordedReviewers = briefings.map((b: ReviewerBriefing): string => b.checklistId);\n if (shouldBrief) {\n const receipt = new ReviewStageReceipt(scan.basis.headSha, mergeValidated, this.buildAffected.resolveBuildCommand(repoRoot), buildPassedAt, recordedReviewers);\n receipt.scopeHashes = scan.scopeHashes;\n // A global round begins only when a non-empty fixed roster is actually briefed.\n receipt.round = recordedReviewers.length === 0 ? 0 : plan.round;\n receipt.maxReviewerRounds = plan.maxRounds;\n this.receipts.write(repoRoot, featureName, receipt);\n }\n this.reportActiveHatches(repoRoot);\n this.report(repoRoot, featureName, scan, briefings, opts, plan, config);\n }\n\n /**\n * List every rule that is currently switched off in webpieces.config.json. NON-BLOCKING and printed\n * before the instruction block, because it is context for the review rather than a step in it.\n *\n * A hatch is the one config change that makes the build QUIETER, so no gate, reviewer or red check\n * will ever mention it — which is how a repo ends up with rules off for weeks that nobody chose to\n * leave off. This is the only place in the flow that says so out loud.\n */\n private reportActiveHatches(repoRoot: string): void {\n const hatches: ActiveHatch[] = this.activeHatchReport.scan(repoRoot);\n process.stdout.write(this.activeHatchReport.render(hatches));\n }\n\n /**\n * Validate + commit + finalize a conflict resolution, if one is in flight. MOVED here from\n * `wp-finish-upsert-pr` so that exactly one command owns merge finalization — two owners is the drift\n * failure `PrContextWriter`'s own docstring records having already happened once in this codebase.\n *\n * MergeEnd's three checks are what \"did the AI do the 3-point merge right?\" means concretely: no\n * conflict markers left in the scoped files, `git diff --diff-filter=U` empty, and a non-empty\n * merge-explanation.md beside every conflicted file.\n *\n * Returns true when a merge was finalized OR there was none to finalize; it throws rather than returning\n * false when validation fails, so the receipt can never record an unvalidated merge as validated.\n */\n private async finalizeAnyInProgressMerge(repoRoot: string): Promise<boolean> {\n const home = this.mergeState.mergeDirFor(repoRoot, this.aiBranchName.getFeatureName());\n const activeDir = this.mergeState.findActiveMergeRunDir(home);\n const marker = activeDir ? this.mergeState.readMergeMarker(activeDir) : null;\n if (!activeDir || !marker || marker.validated) return true;\n process.stdout.write('\\n' + SEP + '① Validating your 3-point merge\\n' + SEP + '\\n');\n // pushRemote:false — finish still owns the single push.\n await this.mergeEnd.mergeEnd(repoRoot, 'wp-review-upsert-pr', activeDir, new MergeContext(marker.currentBranch, marker.squashBranch, marker.backupBranch, marker.prNumber), new MergeEndOptions(marker.conflictedFiles, false));\n return true;\n }\n\n /**\n * The build gate, run BEFORE any reviewer is briefed. Returns the ISO time it passed, for the receipt —\n * which is what lets `wp-finish-upsert-pr` skip its own gate when HEAD has not moved, so moving the gate\n * earlier did not turn one build into two.\n */\n private async runBuildGate(repoRoot: string): Promise<string> {\n await this.buildAffected.runBuildGate(repoRoot, new BuildGateOptions('🛠️ Build gate', 'pnpm wp-review-upsert-pr', 'Build failed — NO reviewer was briefed and no diff was extracted. Fix it, then re-run.', REVIEW_STAGE));\n // Repo-wide: the build must not have left anything uncommitted AND unstaged. Runs HERE, not in\n // finish, because this is the stage that ran buildCommand and is therefore holding the dirty\n // tree at the exact moment the question is answerable. Replaces the per-project\n // validate-di-graph-unchanged nx target — see BuildArtifactGate for why that one had to go.\n this.buildArtifactGate.assertBuildLeftNothingUncommitted(repoRoot);\n return new Date().toISOString();\n }\n\n /**\n * Extract the diff once, then write one instructions file per reviewer.\n *\n * The changed-file set and the basis both come off the SCAN rather than being recomputed, so the diff a\n * reviewer reads covers exactly the files its checklist matched against.\n */\n private briefReviewers(repoRoot: string, featureName: string, scan: ChecklistScan, config: PrGateConfig, plan: ReviewRoundPlan): ReviewerBriefing[] {\n if (plan.basis.unresolved) return [];\n const changedFiles = plan.round > 1 ? plan.changedFiles : scan.changedFiles;\n const manifest = this.materializer.materialize(repoRoot, featureName, plan.basis, changedFiles, config.reviewDiffExclude);\n const diffDir = this.materializer.diffDirFor(repoRoot, featureName);\n // Write pr-context.json ONCE, here — after materializing, so `diffDir` is populated on the first\n // write. The scan deliberately did not write it (ChecklistScanOptions.contextStage === ''); it used\n // to, which meant this command wrote the same file twice, the first time with an empty diffDir.\n // `scan.changedFiles` is passed through so the context is not recomputed from a second git call.\n scan.context = this.prContextWriter.ensure(repoRoot, featureName, plan.basis, 'stage2-review', changedFiles, diffDir);\n // ONLY the checklists still owed a verdict (issue #863). A green or yellow CARRIES whatever changed\n // since (issue #1053) — the scan left it in `reviewed` — so briefing it again would pay a reviewer to\n // re-read code it already judged. A later round re-briefs exactly the previous round's REDS.\n const reviewedIds = new Set(scan.reviewed.map((r: RequiredChecklist): string => r.id));\n const owed = scan.applicable.filter((r: RequiredChecklist): boolean => plan.round > 1\n ? plan.redChecklistIds.includes(r.id)\n : !reviewedIds.has(r.id));\n const briefings = this.briefingBuilder.build(repoRoot, scan, owed, manifest, diffDir, config);\n const dir = this.reviewerInstructions.instructionsDirFor(repoRoot, featureName);\n fs.rmSync(dir, { recursive: true, force: true }); // stale instructions read as current are worse than none\n fs.mkdirSync(dir, { recursive: true });\n for (const b of briefings) {\n b.round = plan.round;\n b.maxRounds = plan.maxRounds;\n b.verdictPath = this.reviewJsonService.checklistResultPath(scan.summaryPath, b.checklistId, plan.round);\n b.remediationOnly = plan.round > 1;\n if (b.remediationOnly) {\n b.previousVerdictPath = this.reviewJsonService.checklistResultPath(scan.summaryPath, b.checklistId, plan.round - 1);\n b.remediationPath = this.rounds.fixesPath(scan.summaryPath, plan.round - 1);\n }\n fs.writeFileSync(this.reviewerInstructions.pathFor(repoRoot, featureName, b.checklistId), this.reviewerInstructions.render(b));\n }\n return briefings;\n }\n\n /**\n * What the AI must do next — rendered by `ReviewReport`, which owns the ordering.\n *\n * The rendering moved OUT of this command so the ordering could be asserted on as a string. It had a\n * real bug: the zero-checklist notice signed off with \"Carry on and run: pnpm wp-finish-upsert-pr\"\n * while the block right beneath it said to write summary.json first. An agent that reads top to bottom\n * obeyed the first line and posted a PR with no review at all.\n */\n // eslint-disable-next-line @typescript-eslint/max-params\n private report(repoRoot: string, featureName: string, scan: ChecklistScan, briefings: readonly ReviewerBriefing[], opts: ReviewUpsertPrOptions, plan: ReviewRoundPlan, config: PrGateConfig): void {\n const input = new ReviewReportInput(repoRoot, featureName, scan.summaryPath);\n input.definedCount = scan.defined.length;\n input.applicableCount = scan.applicable.length;\n input.reviewed = scan.reviewed.slice();\n input.formatErrors = scan.formatErrors.slice();\n input.briefings = briefings.slice();\n input.refused = this.refusals(scan);\n input.skipOptional = opts.skipOptional;\n input.reviewer = config.reviewer;\n // Straight off the SCAN — the one place `experimental.turnOffAllReviewers` is read. This command\n // deliberately does NOT consult the home config itself: a second read is a second answer, and the\n // command that lists and the command that blocks would be free to disagree about whether a branch\n // was reviewed. See ChecklistScanner.\n input.reviewersSuppressed = scan.reviewersDisabled;\n input.suppressed = scan.suppressed.slice();\n input.round = plan.round;\n input.maxReviewerRounds = plan.maxRounds;\n input.roundAction = plan.action;\n input.redChecklistIds = plan.redChecklistIds.slice();\n input.orangeChecklistIds = plan.orangeChecklistIds.slice();\n input.notBriefed = scan.notBriefed.slice();\n input.standings = scan.standings.slice();\n // `say`: this block IS the next action — which reviewers to spawn, where summary.json goes, and\n // the command after that. Capturing it into the log would leave the terminal with a pointer and\n // no instruction, which is the one thing this stage may never do.\n this.stageConsole.say(this.reviewReport.render(input));\n }\n\n /**\n * The applicable checklists that ALREADY ANSWERED and refused, each with its refusal rendered by the ONE\n * renderer `wp-finish-upsert-pr` also uses.\n *\n * Stage ② had the identical defect finish did: a refused checklist has no passing verdict, so it is not\n * in `scan.reviewed`, so it was printed as an ordinary owed reviewer and re-instructed word for word —\n * and an agent that obeys spawns it against unchanged code, gets the same refusal, and loops one stage\n * earlier than the loop that was reported.\n *\n * Nothing is moved: a red verdict stays on disk as its round's record, and the next round's verdict is a\n * new file (issue #1053). The review path IS passed, because the ship-anyway route the refusal prints is a\n * command that writes `override-<id>.json` beside it.\n */\n private refusals(scan: ChecklistScan): RefusedReviewer[] {\n const refused = this.reviewJsonService.refusedChecklists(scan.applicable, scan.results);\n return refused.map((req: RequiredChecklist): RefusedReviewer => new RefusedReviewer(req.id, this.reviewJsonService.refusalError(req, this.reviewJsonService.resolveVerdict(req, scan.results), scan.summaryPath)));\n }\n}\n"]}
@@ -1,9 +1,8 @@
1
- import { RepoRootFinder } from '@webpieces/rules-config';
1
+ import { RepoRootFinder, ReviewJsonService } from '@webpieces/rules-config';
2
2
  import { AiBranchName } from '../workflow/git-readAiBranchName';
3
3
  import { ReviewStageReceiptService } from '../workflow/review-stage-receipt';
4
4
  import { ReviewerIdentityResolver } from '../workflow/reviewer-identity';
5
5
  import { VerdictProvenanceService } from '../workflow/verdict-provenance';
6
- import { ReviewRoundStateService } from '../workflow/review-round-state';
7
6
  /** What `wp-write-review` was asked to do. Data-only. */
8
7
  export declare class WriteReviewOptions {
9
8
  checklistId: string;
@@ -28,11 +27,15 @@ export declare class ReviewBudgetCheckOptions {
28
27
  * 2. the checklist must be one stage ② briefed this round (its receipt), so a carried verdict cannot be
29
28
  * overwritten and a checklist that does not apply cannot be invented;
30
29
  * 3. the verdict is validated strictly — the five fields, nothing else;
31
- * 4. it is written WITH `review-<id>.provenance.json`: who, which commit, which in-scope diff, and a hash
32
- * of the verdict. `wp-finish-upsert-pr` rejects a verdict without one, or one edited since;
33
- * 5. the checklist must still be inside the round budget (issue #1051): once it has been reviewed
34
- * `maxReviewerRounds` times on this branch, no further verdict is recorded, whoever spawned the
35
- * reviewer. `--check` asks the same question BEFORE a reviewer spends a review on it.
30
+ * 4. it is written as `review-round<N>-<id>.json` WITH `review-round<N>-<id>.provenance.json`: who, which
31
+ * commit, which in-scope diff, and a hash of the verdict. `wp-finish-upsert-pr` rejects a verdict
32
+ * without one, or one edited since;
33
+ * 5. the round must be inside the budget (issues #1051, #1053): a round above `maxReviewerRounds` records
34
+ * nothing, and a round's verdict is never overwritten, whoever spawned the reviewer. `--check` asks the
35
+ * same question BEFORE a reviewer spends a review on it;
36
+ * 6. the color must fit the round (issue #1053): the FINAL round has no red — its must-fix color is
37
+ * orange, never re-reviewed — and orange is refused before the final round, where red still means
38
+ * "fix it and it will be reviewed again".
36
39
  *
37
40
  * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.
38
41
  */
@@ -42,26 +45,37 @@ export declare class WriteReviewCommand {
42
45
  private readonly receipts;
43
46
  private readonly identity;
44
47
  private readonly provenance;
45
- private readonly rounds;
46
- constructor(repoRootFinder: RepoRootFinder, aiBranchName: AiBranchName, receipts: ReviewStageReceiptService, identity: ReviewerIdentityResolver, provenance: VerdictProvenanceService, rounds: ReviewRoundStateService);
48
+ private readonly reviewJsonService;
49
+ constructor(repoRootFinder: RepoRootFinder, aiBranchName: AiBranchName, receipts: ReviewStageReceiptService, identity: ReviewerIdentityResolver, provenance: VerdictProvenanceService, reviewJsonService: ReviewJsonService);
47
50
  run(opts: WriteReviewOptions): Promise<void>;
48
51
  /**
49
52
  * `wp-write-review --check`: the reviewer's FIRST step. Refuses exactly when {@link run} would refuse
50
53
  * on the budget, so a reviewer past the budget learns it before it reviews rather than after.
51
54
  */
52
55
  check(opts: ReviewBudgetCheckOptions): Promise<void>;
56
+ /** The last round `maxReviewerRounds` allows — the one with no red (issue #1053). */
57
+ private isFinalRound;
53
58
  /**
54
- * THE ROUND CAP, held by the reviewer's own submission path (issue #1051). The planner already never
55
- * briefs past the cap, but an author agent could still spawn a reviewer from an old instructions file —
56
- * the measured deadlock did exactly that — and the verdict it produced then had to be judged by
57
- * everything downstream. Counting from the immutable round snapshots makes it mechanical: a checklist
58
- * reviewed `maxReviewerRounds` times gets no further verdict. Returns how many reviews it already has.
59
+ * THE ROUND CAP, held by the reviewer's own submission path (issues #1051, #1053). The planner already
60
+ * never briefs past the cap, but an author agent could still spawn a reviewer from an old instructions
61
+ * file — the measured deadlock did exactly that. Two refusals make it mechanical: a round above
62
+ * `maxReviewerRounds` records nothing, and a checklist that already has a verdict in this round (or a
63
+ * later one) gets no second one — a round's verdict is never overwritten.
59
64
  */
60
65
  private assertWithinBudget;
61
66
  /** The stage-② receipt, provided it briefed THIS checklist this round. */
62
67
  private briefedReceipt;
63
- /** Strict: an object with exactly the verdict's five fields, every one a string, status one of three. */
68
+ /**
69
+ * Strict: an object with exactly the verdict's five fields, every one a string, and a status that fits
70
+ * the round — red only BEFORE the final round, orange only ON it (issue #1053).
71
+ */
64
72
  private parse;
73
+ /**
74
+ * The round decides which blocking color exists. The FINAL round's red would mean "fix it and it will be
75
+ * reviewed again", and there is no again — so it is refused and orange named. Orange before the final
76
+ * round would waive a re-review that the budget still pays for — so it is refused and red named.
77
+ */
78
+ private colorForRound;
65
79
  private text;
66
80
  private parseObject;
67
81
  }
@@ -9,7 +9,6 @@ const git_readAiBranchName_1 = require("../workflow/git-readAiBranchName");
9
9
  const review_stage_receipt_1 = require("../workflow/review-stage-receipt");
10
10
  const reviewer_identity_1 = require("../workflow/reviewer-identity");
11
11
  const verdict_provenance_1 = require("../workflow/verdict-provenance");
12
- const review_round_state_1 = require("../workflow/review-round-state");
13
12
  /** The only keys a verdict may carry. Anything else is somebody's second schema. */
14
13
  const VERDICT_KEYS = ['id', 'status', 'agent', 'model', 'output'];
15
14
  /** What `wp-write-review` was asked to do. Data-only. */
@@ -49,11 +48,15 @@ exports.ReviewBudgetCheckOptions = ReviewBudgetCheckOptions;
49
48
  * 2. the checklist must be one stage ② briefed this round (its receipt), so a carried verdict cannot be
50
49
  * overwritten and a checklist that does not apply cannot be invented;
51
50
  * 3. the verdict is validated strictly — the five fields, nothing else;
52
- * 4. it is written WITH `review-<id>.provenance.json`: who, which commit, which in-scope diff, and a hash
53
- * of the verdict. `wp-finish-upsert-pr` rejects a verdict without one, or one edited since;
54
- * 5. the checklist must still be inside the round budget (issue #1051): once it has been reviewed
55
- * `maxReviewerRounds` times on this branch, no further verdict is recorded, whoever spawned the
56
- * reviewer. `--check` asks the same question BEFORE a reviewer spends a review on it.
51
+ * 4. it is written as `review-round<N>-<id>.json` WITH `review-round<N>-<id>.provenance.json`: who, which
52
+ * commit, which in-scope diff, and a hash of the verdict. `wp-finish-upsert-pr` rejects a verdict
53
+ * without one, or one edited since;
54
+ * 5. the round must be inside the budget (issues #1051, #1053): a round above `maxReviewerRounds` records
55
+ * nothing, and a round's verdict is never overwritten, whoever spawned the reviewer. `--check` asks the
56
+ * same question BEFORE a reviewer spends a review on it;
57
+ * 6. the color must fit the round (issue #1053): the FINAL round has no red — its must-fix color is
58
+ * orange, never re-reviewed — and orange is refused before the final round, where red still means
59
+ * "fix it and it will be reviewed again".
57
60
  *
58
61
  * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.
59
62
  */
@@ -63,15 +66,15 @@ let WriteReviewCommand = class WriteReviewCommand {
63
66
  receipts;
64
67
  identity;
65
68
  provenance;
66
- rounds;
69
+ reviewJsonService;
67
70
  // eslint-disable-next-line @typescript-eslint/max-params
68
- constructor(repoRootFinder, aiBranchName, receipts, identity, provenance, rounds) {
71
+ constructor(repoRootFinder, aiBranchName, receipts, identity, provenance, reviewJsonService) {
69
72
  this.repoRootFinder = repoRootFinder;
70
73
  this.aiBranchName = aiBranchName;
71
74
  this.receipts = receipts;
72
75
  this.identity = identity;
73
76
  this.provenance = provenance;
74
- this.rounds = rounds;
77
+ this.reviewJsonService = reviewJsonService;
75
78
  }
76
79
  run(opts) {
77
80
  const id = opts.checklistId.trim();
@@ -83,11 +86,10 @@ let WriteReviewCommand = class WriteReviewCommand {
83
86
  // consumes must not survive to lend itself to a later call.
84
87
  const who = this.identity.resolve(cwd, id);
85
88
  this.assertWithinBudget((0, rules_config_1.summaryJsonPath)(repoRoot, featureName), receipt, id);
86
- const verdict = this.parse(opts.json, id);
89
+ const verdict = this.parse(opts.json, id, receipt);
87
90
  const record = new verdict_provenance_1.VerdictProvenance(id, who.harness, who.sessionId, who.agentId, who.agentType, receipt.headSha, receipt.scopeHashes[id] ?? '');
88
91
  record.round = receipt.round;
89
92
  const written = this.provenance.write((0, rules_config_1.summaryJsonPath)(repoRoot, featureName), verdict, record);
90
- this.rounds.archiveVerdict((0, rules_config_1.summaryJsonPath)(repoRoot, featureName), id, receipt.round);
91
93
  process.stdout.write(`✅ ${verdict.status.toUpperCase()} verdict for "${id}" submitted → ${written}\n`
92
94
  + ` provenance: ${who.harness}${who.agentId === '' ? '' : ` agent ${who.agentId}`}, `
93
95
  + `briefed at ${receipt.headSha.slice(0, 8)}, global round ${receipt.round} of ${receipt.maxReviewerRounds}\n`);
@@ -102,28 +104,37 @@ let WriteReviewCommand = class WriteReviewCommand {
102
104
  const repoRoot = this.repoRootFinder.resolveRepoRoot(opts.cwd);
103
105
  const featureName = this.aiBranchName.getFeatureName();
104
106
  const receipt = this.briefedReceipt(repoRoot, featureName, id);
105
- const count = this.assertWithinBudget((0, rules_config_1.summaryJsonPath)(repoRoot, featureName), receipt, id);
106
- process.stdout.write(`✅ "${id}" may be reviewed: this is review ${count + 1} of at most ${receipt.maxReviewerRounds} on this branch `
107
- + `(global round ${receipt.round}). Review it, then submit with pnpm ${rules_config_1.WRITE_REVIEW_BIN} --checklist ${id}.\n`);
107
+ this.assertWithinBudget((0, rules_config_1.summaryJsonPath)(repoRoot, featureName), receipt, id);
108
+ const final = this.isFinalRound(receipt)
109
+ ? ` This is the FINAL round: there is no re-review, so you may NOT mark ${rules_config_1.VERDICT_RED} — mark every must-fix finding ${rules_config_1.VERDICT_ORANGE}.`
110
+ : '';
111
+ process.stdout.write(`✅ "${id}" may be reviewed: this is review round ${receipt.round} of at most ${receipt.maxReviewerRounds}.${final} `
112
+ + `Review it, then submit with pnpm ${rules_config_1.WRITE_REVIEW_BIN} --checklist ${id}.\n`);
108
113
  return Promise.resolve();
109
114
  }
115
+ /** The last round `maxReviewerRounds` allows — the one with no red (issue #1053). */
116
+ isFinalRound(receipt) {
117
+ return receipt.round >= receipt.maxReviewerRounds;
118
+ }
110
119
  /**
111
- * THE ROUND CAP, held by the reviewer's own submission path (issue #1051). The planner already never
112
- * briefs past the cap, but an author agent could still spawn a reviewer from an old instructions file —
113
- * the measured deadlock did exactly that — and the verdict it produced then had to be judged by
114
- * everything downstream. Counting from the immutable round snapshots makes it mechanical: a checklist
115
- * reviewed `maxReviewerRounds` times gets no further verdict. Returns how many reviews it already has.
120
+ * THE ROUND CAP, held by the reviewer's own submission path (issues #1051, #1053). The planner already
121
+ * never briefs past the cap, but an author agent could still spawn a reviewer from an old instructions
122
+ * file — the measured deadlock did exactly that. Two refusals make it mechanical: a round above
123
+ * `maxReviewerRounds` records nothing, and a checklist that already has a verdict in this round (or a
124
+ * later one) gets no second one — a round's verdict is never overwritten.
116
125
  */
117
126
  assertWithinBudget(summaryPath, receipt, id) {
118
127
  const max = receipt.maxReviewerRounds;
119
- const count = this.rounds.reviewCount(summaryPath, id, receipt.round);
120
- if (count < max)
121
- return count;
122
- throw new rules_config_1.InformAiError(`I am not allowed to review ${id}: maxReviewerRounds is ${max} and it has already been reviewed `
123
- + `${count} time(s) on this branch.\n`
128
+ const latest = this.reviewJsonService.latestVerdictRound(summaryPath, id);
129
+ if (receipt.round <= max && latest < receipt.round)
130
+ return;
131
+ const why = receipt.round > max
132
+ ? `this briefing is for review round ${receipt.round}, above maxReviewerRounds (${max})`
133
+ : `it already has a verdict for review round ${latest} (maxReviewerRounds is ${max}), and a round's verdict is never overwritten`;
134
+ throw new rules_config_1.InformAiError(`I am not allowed to review ${id}: ${why}.\n`
124
135
  + `Do not review it and submit nothing for it; report this refusal, verbatim, to the agent that spawned you. `
125
- + `The verdict already recorded for it stands (${this.rounds.roundDir(summaryPath, receipt.round)}), and `
126
- + 'the author records any fix made after the cap with pnpm wp-write-review-fixes.');
136
+ + `The verdict already recorded for it stands (${this.reviewJsonService.latestChecklistResultPath(summaryPath, id) || 'none'}), and `
137
+ + 'the author records any fix with pnpm wp-write-review-fixes.');
127
138
  }
128
139
  /** The stage-② receipt, provided it briefed THIS checklist this round. */
129
140
  briefedReceipt(repoRoot, featureName, id) {
@@ -142,8 +153,11 @@ let WriteReviewCommand = class WriteReviewCommand {
142
153
  }
143
154
  return receipt;
144
155
  }
145
- /** Strict: an object with exactly the verdict's five fields, every one a string, status one of three. */
146
- parse(json, id) {
156
+ /**
157
+ * Strict: an object with exactly the verdict's five fields, every one a string, and a status that fits
158
+ * the round — red only BEFORE the final round, orange only ON it (issue #1053).
159
+ */
160
+ parse(json, id, receipt) {
147
161
  const raw = this.parseObject(json);
148
162
  const problems = [];
149
163
  const extra = Object.keys(raw).filter((k) => !VERDICT_KEYS.includes(k));
@@ -158,6 +172,7 @@ let WriteReviewCommand = class WriteReviewCommand {
158
172
  // webpieces-disable no-any-unknown -- comparing against the readonly literal tuple of valid colors
159
173
  if (!rules_config_1.VERDICT_STATUSES.includes(status))
160
174
  problems.push(`"status" must be one of ${rules_config_1.VERDICT_STATUSES.join(', ')}`);
175
+ problems.push(...this.colorForRound(status, receipt));
161
176
  for (const key of ['agent', 'model', 'output']) {
162
177
  if (this.text(raw, key) === '')
163
178
  problems.push(`"${key}" must be a non-empty string${key === 'output' ? '' : ' (use "unknown" when unavailable)'}`);
@@ -168,6 +183,24 @@ let WriteReviewCommand = class WriteReviewCommand {
168
183
  }
169
184
  return new verdict_provenance_1.SubmittedVerdict(id, status, this.text(raw, 'agent'), this.text(raw, 'model'), raw['output']);
170
185
  }
186
+ /**
187
+ * The round decides which blocking color exists. The FINAL round's red would mean "fix it and it will be
188
+ * reviewed again", and there is no again — so it is refused and orange named. Orange before the final
189
+ * round would waive a re-review that the budget still pays for — so it is refused and red named.
190
+ */
191
+ colorForRound(status, receipt) {
192
+ const round = `review round ${receipt.round} of ${receipt.maxReviewerRounds}`;
193
+ if (status === rules_config_1.VERDICT_RED && this.isFinalRound(receipt)) {
194
+ return [`"status": "${rules_config_1.VERDICT_RED}" is not allowed: ${round} is the FINAL round, and there is no re-review. `
195
+ + `Mark anything that must be fixed "${rules_config_1.VERDICT_ORANGE}", with a concrete, actionable fix in "output" — the author applies it `
196
+ + 'best effort and ships without another review.'];
197
+ }
198
+ if (status === rules_config_1.VERDICT_ORANGE && !this.isFinalRound(receipt)) {
199
+ return [`"status": "${rules_config_1.VERDICT_ORANGE}" is only for the FINAL review round, and ${round} is not it. `
200
+ + `Use "${rules_config_1.VERDICT_RED}" for a must-fix finding: the author's fix will be reviewed again next round.`];
201
+ }
202
+ return [];
203
+ }
171
204
  // webpieces-disable no-any-unknown -- one field of the opaque submitted object, narrowed to a trimmed string
172
205
  text(raw, key) {
173
206
  const value = raw[key];
@@ -201,7 +234,7 @@ exports.WriteReviewCommand = WriteReviewCommand = tslib_1.__decorate([
201
234
  review_stage_receipt_1.ReviewStageReceiptService,
202
235
  reviewer_identity_1.ReviewerIdentityResolver,
203
236
  verdict_provenance_1.VerdictProvenanceService,
204
- review_round_state_1.ReviewRoundStateService])
237
+ rules_config_1.ReviewJsonService])
205
238
  ], WriteReviewCommand);
206
239
  /**
207
240
  * Reads the verdict JSON for the composition root: `--file <path>`, else stdin. Separate from the command
@@ -1 +1 @@
1
- {"version":3,"file":"write-review-command.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/commands/write-review-command.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,0DAEiC;AACjC,yCAA2D;AAC3D,2EAAgE;AAChE,2EAAiG;AACjG,qEAA2F;AAC3F,uEAA+G;AAC/G,uEAAyE;AAEzE,oFAAoF;AACpF,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAU,CAAC;AAE3E,yDAAyD;AACzD,MAAa,kBAAkB;IAC3B,WAAW,CAAS;IACpB,sGAAsG;IACtG,iEAAiE;IACjE,IAAI,CAAS;IACb,kGAAkG;IAClG,8EAA8E;IAC9E,GAAG,CAAS;IAEZ,YAAY,WAAmB,EAAE,IAAY,EAAE,GAAW;QACtD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,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IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YACzE,MAAM,IAAI,4BAAa,CAAC,GAAG,+BAAgB,wCAAwC,CAAC,CAAC;QACzF,CAAC;QACD,4EAA4E;QAC5E,OAAO,MAAiC,CAAC;IAC7C,CAAC;CACJ,CAAA;AArIY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAIA,6BAAc;QAChB,mCAAY;QAChB,gDAAyB;QACzB,4CAAwB;QACtB,6CAAwB;QAC5B,4CAAuB;GAR3C,kBAAkB,CAqI9B;AAED;;;GAGG;AAEI,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IACzB,IAAI,CAAC,QAAgB;QACjB,IAAI,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACzB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;gBAAE,MAAM,IAAI,4BAAa,CAAC,GAAG,+BAAgB,YAAY,QAAQ,kBAAkB,CAAC,CAAC;YACjH,OAAO,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC7C,CAAC;QACD,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;YAC/B,MAAM,IAAI,4BAAa,CAAC,GAAG,+BAAgB,0CAA0C,+BAAgB,yDAAyD,CAAC,CAAC;QACpK,CAAC;QACD,OAAO,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC;CACJ,CAAA;AAXY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;GAC5B,gBAAgB,CAW5B","sourcesContent":["import * as fs from 'fs';\nimport {\n InformAiError, RepoRootFinder, VERDICT_STATUSES, WRITE_REVIEW_BIN, checklistOverrideService, summaryJsonPath, toError,\n} from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { AiBranchName } from '../workflow/git-readAiBranchName';\nimport { ReviewStageReceipt, ReviewStageReceiptService } from '../workflow/review-stage-receipt';\nimport { ReviewerIdentity, ReviewerIdentityResolver } from '../workflow/reviewer-identity';\nimport { SubmittedVerdict, VerdictProvenance, VerdictProvenanceService } from '../workflow/verdict-provenance';\nimport { ReviewRoundStateService } from '../workflow/review-round-state';\n\n/** The only keys a verdict may carry. Anything else is somebody's second schema. */\nconst VERDICT_KEYS = ['id', 'status', 'agent', 'model', 'output'] as const;\n\n/** What `wp-write-review` was asked to do. Data-only. */\nexport class WriteReviewOptions {\n checklistId: string;\n // The verdict JSON itself — read from `--file` or stdin by the composition root, so this command is a\n // function of its inputs and a spec can drive it without a pipe.\n json: string;\n // Where the caller stands — the tree whose review dir and hook stamp are used. Passed in (the bin\n // passes process.cwd()) rather than read here, for the same reason `json` is.\n cwd: string;\n\n constructor(checklistId: string, json: string, cwd: string) {\n this.checklistId = checklistId;\n this.json = json;\n this.cwd = cwd;\n }\n}\n\n/** What `wp-write-review --check` was asked: may this checklist still be reviewed? Data-only. */\nexport class ReviewBudgetCheckOptions {\n checklistId: string;\n cwd: string;\n\n constructor(checklistId: string, cwd: string) {\n this.checklistId = checklistId;\n this.cwd = cwd;\n }\n}\n\n/**\n * `wp-write-review` — the ONE way any reviewer, Claude or Codex, submits a checklist verdict (issue #863).\n *\n * Before it existed a verdict was \"a file with the right shape at the right path\", and that is exactly what\n * a Codex coordinator produced on two merged PRs: the shared-tree guard blocked its reviewer's write, the\n * guard's own cure said to hand the edit to the coordinator, the coordinator wrote all five verdicts, and\n * `wp-finish-upsert-pr` accepted them. Now:\n * 1. the caller is identified by the harness (ReviewerIdentityResolver) and the COORDINATOR is refused;\n * 2. the checklist must be one stage ② briefed this round (its receipt), so a carried verdict cannot be\n * overwritten and a checklist that does not apply cannot be invented;\n * 3. the verdict is validated strictly — the five fields, nothing else;\n * 4. it is written WITH `review-<id>.provenance.json`: who, which commit, which in-scope diff, and a hash\n * of the verdict. `wp-finish-upsert-pr` rejects a verdict without one, or one edited since;\n * 5. the checklist must still be inside the round budget (issue #1051): once it has been reviewed\n * `maxReviewerRounds` times on this branch, no further verdict is recorded, whoever spawned the\n * reviewer. `--check` asks the same question BEFORE a reviewer spends a review on it.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class WriteReviewCommand {\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n private readonly repoRootFinder: RepoRootFinder,\n private readonly aiBranchName: AiBranchName,\n private readonly receipts: ReviewStageReceiptService,\n private readonly identity: ReviewerIdentityResolver,\n private readonly provenance: VerdictProvenanceService,\n private readonly rounds: ReviewRoundStateService,\n ) {}\n\n run(opts: WriteReviewOptions): Promise<void> {\n const id = opts.checklistId.trim();\n const cwd = opts.cwd;\n const repoRoot = this.repoRootFinder.resolveRepoRoot(cwd);\n const featureName = this.aiBranchName.getFeatureName();\n const receipt = this.briefedReceipt(repoRoot, featureName, id);\n // Identity BEFORE parsing: a coordinator is refused whatever it submitted, and the stamp it\n // consumes must not survive to lend itself to a later call.\n const who: ReviewerIdentity = this.identity.resolve(cwd, id);\n this.assertWithinBudget(summaryJsonPath(repoRoot, featureName), receipt, id);\n const verdict = this.parse(opts.json, id);\n const record = new VerdictProvenance(\n id, who.harness, who.sessionId, who.agentId, who.agentType, receipt.headSha, receipt.scopeHashes[id] ?? '');\n record.round = receipt.round;\n const written = this.provenance.write(summaryJsonPath(repoRoot, featureName), verdict, record);\n this.rounds.archiveVerdict(summaryJsonPath(repoRoot, featureName), id, receipt.round);\n process.stdout.write(\n `✅ ${verdict.status.toUpperCase()} verdict for \"${id}\" submitted → ${written}\\n`\n + ` provenance: ${who.harness}${who.agentId === '' ? '' : ` agent ${who.agentId}`}, `\n + `briefed at ${receipt.headSha.slice(0, 8)}, global round ${receipt.round} of ${receipt.maxReviewerRounds}\\n`);\n return Promise.resolve();\n }\n\n /**\n * `wp-write-review --check`: the reviewer's FIRST step. Refuses exactly when {@link run} would refuse\n * on the budget, so a reviewer past the budget learns it before it reviews rather than after.\n */\n check(opts: ReviewBudgetCheckOptions): Promise<void> {\n const id = opts.checklistId.trim();\n const repoRoot = this.repoRootFinder.resolveRepoRoot(opts.cwd);\n const featureName = this.aiBranchName.getFeatureName();\n const receipt = this.briefedReceipt(repoRoot, featureName, id);\n const count = this.assertWithinBudget(summaryJsonPath(repoRoot, featureName), receipt, id);\n process.stdout.write(\n `✅ \"${id}\" may be reviewed: this is review ${count + 1} of at most ${receipt.maxReviewerRounds} on this branch `\n + `(global round ${receipt.round}). Review it, then submit with pnpm ${WRITE_REVIEW_BIN} --checklist ${id}.\\n`);\n return Promise.resolve();\n }\n\n /**\n * THE ROUND CAP, held by the reviewer's own submission path (issue #1051). The planner already never\n * briefs past the cap, but an author agent could still spawn a reviewer from an old instructions file —\n * the measured deadlock did exactly that — and the verdict it produced then had to be judged by\n * everything downstream. Counting from the immutable round snapshots makes it mechanical: a checklist\n * reviewed `maxReviewerRounds` times gets no further verdict. Returns how many reviews it already has.\n */\n private assertWithinBudget(summaryPath: string, receipt: ReviewStageReceipt, id: string): number {\n const max = receipt.maxReviewerRounds;\n const count = this.rounds.reviewCount(summaryPath, id, receipt.round);\n if (count < max) return count;\n throw new InformAiError(\n `I am not allowed to review ${id}: maxReviewerRounds is ${max} and it has already been reviewed `\n + `${count} time(s) on this branch.\\n`\n + `Do not review it and submit nothing for it; report this refusal, verbatim, to the agent that spawned you. `\n + `The verdict already recorded for it stands (${this.rounds.roundDir(summaryPath, receipt.round)}), and `\n + 'the author records any fix made after the cap with pnpm wp-write-review-fixes.');\n }\n\n /** The stage-② receipt, provided it briefed THIS checklist this round. */\n private briefedReceipt(repoRoot: string, featureName: string, id: string): ReviewStageReceipt {\n if (id === '') throw new InformAiError(`${WRITE_REVIEW_BIN} needs the checklist id: pnpm ${WRITE_REVIEW_BIN} --checklist <id>`);\n const receipt = this.receipts.read(repoRoot, featureName);\n if (receipt === null) {\n throw new InformAiError(`${WRITE_REVIEW_BIN}: pnpm wp-review-upsert-pr has not briefed any reviewer on this branch yet, `\n + 'so there is nothing to submit a verdict against.');\n }\n if (!receipt.reviewersBriefed.includes(id) || (receipt.scopeHashes[id] ?? '') === '') {\n const briefed = receipt.reviewersBriefed.length === 0 ? '(none)' : receipt.reviewersBriefed.join(', ');\n throw new InformAiError(`${WRITE_REVIEW_BIN}: checklist \"${id}\" was not briefed by the last pnpm wp-review-upsert-pr `\n + `(briefed this round: ${briefed}). Submit only for a checklist whose instructions file you were handed — `\n + 'a checklist absent here either carries its earlier verdict or does not apply to this diff.');\n }\n return receipt;\n }\n\n /** Strict: an object with exactly the verdict's five fields, every one a string, status one of three. */\n private parse(json: string, id: string): SubmittedVerdict {\n const raw = this.parseObject(json);\n const problems: string[] = [];\n const extra = Object.keys(raw).filter((k: string): boolean => !(VERDICT_KEYS as readonly string[]).includes(k));\n if (extra.includes('override')) {\n problems.push(`\"override\" is not a verdict field — a ship-anyway decision is a HUMAN's, recorded by the coordinating agent in ${checklistOverrideService.overrideFileName(id)}`);\n }\n if (extra.length > 0) problems.push(`unknown field(s) ${extra.map((k: string): string => `\"${k}\"`).join(', ')} — a verdict has exactly: ${VERDICT_KEYS.join(', ')}`);\n if (raw['id'] !== undefined && this.text(raw, 'id') !== id) problems.push(`\"id\" is ${JSON.stringify(raw['id'])} but --checklist is \"${id}\"`);\n const status = this.text(raw, 'status').toLowerCase();\n // webpieces-disable no-any-unknown -- comparing against the readonly literal tuple of valid colors\n if (!(VERDICT_STATUSES as readonly string[]).includes(status)) problems.push(`\"status\" must be one of ${VERDICT_STATUSES.join(', ')}`);\n for (const key of ['agent', 'model', 'output']) {\n if (this.text(raw, key) === '') problems.push(`\"${key}\" must be a non-empty string${key === 'output' ? '' : ' (use \"unknown\" when unavailable)'}`);\n }\n if (problems.length > 0) {\n throw new InformAiError(`${WRITE_REVIEW_BIN}: the verdict for \"${id}\" was NOT submitted:\\n`\n + problems.map((p: string): string => ` • ${p}`).join('\\n'));\n }\n return new SubmittedVerdict(id, status, this.text(raw, 'agent'), this.text(raw, 'model'), raw['output'] as string);\n }\n\n // webpieces-disable no-any-unknown -- one field of the opaque submitted object, narrowed to a trimmed string\n private text(raw: Record<string, unknown>, key: string): string {\n const value = raw[key];\n return typeof value === 'string' ? value.trim() : '';\n }\n\n // webpieces-disable no-any-unknown -- the submitted JSON is opaque until parse() narrows every field\n private parseObject(json: string): Record<string, unknown> {\n // webpieces-disable no-any-unknown -- parsed JSON is opaque until narrowed\n let parsed: unknown = null;\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: a JSON syntax error becomes the AI-facing refusal\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n parsed = JSON.parse(json);\n } catch (err: unknown) {\n const error = toError(err);\n throw new InformAiError(`${WRITE_REVIEW_BIN}: the verdict is not valid JSON.`, { cause: error });\n }\n if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n throw new InformAiError(`${WRITE_REVIEW_BIN}: the verdict must be ONE JSON object.`);\n }\n // webpieces-disable no-any-unknown -- narrowed to a plain object just above\n return parsed as Record<string, unknown>;\n }\n}\n\n/**\n * Reads the verdict JSON for the composition root: `--file <path>`, else stdin. Separate from the command\n * so the command stays a function of its inputs.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class WriteReviewInput {\n read(filePath: string): string {\n if (filePath.trim() !== '') {\n if (!fs.existsSync(filePath)) throw new InformAiError(`${WRITE_REVIEW_BIN}: --file ${filePath} does not exist.`);\n return fs.readFileSync(filePath, 'utf8');\n }\n if (process.stdin.isTTY === true) {\n throw new InformAiError(`${WRITE_REVIEW_BIN}: pass the verdict JSON on stdin (pnpm ${WRITE_REVIEW_BIN} --checklist <id> <<'EOF' … EOF) or with --file <path>.`);\n }\n return fs.readFileSync(0, 'utf8');\n }\n}\n"]}
1
+ {"version":3,"file":"write-review-command.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/commands/write-review-command.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,0DAGiC;AACjC,yCAA2D;AAC3D,2EAAgE;AAChE,2EAAiG;AACjG,qEAA2F;AAC3F,uEAA+G;AAE/G,oFAAoF;AACpF,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAU,CAAC;AAE3E,yDAAyD;AACzD,MAAa,kBAAkB;IAC3B,WAAW,CAAS;IACpB,sGAAsG;IACtG,iEAAiE;IACjE,IAAI,CAAS;IACb,kGAAkG;IAClG,8EAA8E;IAC9E,GAAG,CAAS;IAEZ,YAAY,WAAmB,EAAE,IAAY,EAAE,GAAW;QACtD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACnB,CAAC;CACJ;AAdD,gDAcC;AAED,iGAAiG;AACjG,MAAa,wBAAwB;IACjC,WAAW,CAAS;IACpB,GAAG,CAAS;IAEZ,YAAY,WAAmB,EAAE,GAAW;QACxC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACnB,CAAC;CACJ;AARD,4DAQC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEI,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAGN;IACA;IACA;IACA;IACA;IACA;IAPrB,yDAAyD;IACzD,YACqB,cAA8B,EAC9B,YAA0B,EAC1B,QAAmC,EACnC,QAAkC,EAClC,UAAoC,EACpC,iBAAoC;QALpC,mBAAc,GAAd,cAAc,CAAgB;QAC9B,iBAAY,GAAZ,YAAY,CAAc;QAC1B,aAAQ,GAAR,QAAQ,CAA2B;QACnC,aAAQ,GAAR,QAAQ,CAA0B;QAClC,eAAU,GA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D,OAAO,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC;CACJ,CAAA;AAXY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;GAC5B,gBAAgB,CAW5B","sourcesContent":["import * as fs from 'fs';\nimport {\n InformAiError, RepoRootFinder, ReviewJsonService, VERDICT_ORANGE, VERDICT_RED, VERDICT_STATUSES, WRITE_REVIEW_BIN, checklistOverrideService,\n summaryJsonPath, toError,\n} from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { AiBranchName } from '../workflow/git-readAiBranchName';\nimport { ReviewStageReceipt, ReviewStageReceiptService } from '../workflow/review-stage-receipt';\nimport { ReviewerIdentity, ReviewerIdentityResolver } from '../workflow/reviewer-identity';\nimport { SubmittedVerdict, VerdictProvenance, VerdictProvenanceService } from '../workflow/verdict-provenance';\n\n/** The only keys a verdict may carry. Anything else is somebody's second schema. */\nconst VERDICT_KEYS = ['id', 'status', 'agent', 'model', 'output'] as const;\n\n/** What `wp-write-review` was asked to do. Data-only. */\nexport class WriteReviewOptions {\n checklistId: string;\n // The verdict JSON itself — read from `--file` or stdin by the composition root, so this command is a\n // function of its inputs and a spec can drive it without a pipe.\n json: string;\n // Where the caller stands — the tree whose review dir and hook stamp are used. Passed in (the bin\n // passes process.cwd()) rather than read here, for the same reason `json` is.\n cwd: string;\n\n constructor(checklistId: string, json: string, cwd: string) {\n this.checklistId = checklistId;\n this.json = json;\n this.cwd = cwd;\n }\n}\n\n/** What `wp-write-review --check` was asked: may this checklist still be reviewed? Data-only. */\nexport class ReviewBudgetCheckOptions {\n checklistId: string;\n cwd: string;\n\n constructor(checklistId: string, cwd: string) {\n this.checklistId = checklistId;\n this.cwd = cwd;\n }\n}\n\n/**\n * `wp-write-review` — the ONE way any reviewer, Claude or Codex, submits a checklist verdict (issue #863).\n *\n * Before it existed a verdict was \"a file with the right shape at the right path\", and that is exactly what\n * a Codex coordinator produced on two merged PRs: the shared-tree guard blocked its reviewer's write, the\n * guard's own cure said to hand the edit to the coordinator, the coordinator wrote all five verdicts, and\n * `wp-finish-upsert-pr` accepted them. Now:\n * 1. the caller is identified by the harness (ReviewerIdentityResolver) and the COORDINATOR is refused;\n * 2. the checklist must be one stage ② briefed this round (its receipt), so a carried verdict cannot be\n * overwritten and a checklist that does not apply cannot be invented;\n * 3. the verdict is validated strictly — the five fields, nothing else;\n * 4. it is written as `review-round<N>-<id>.json` WITH `review-round<N>-<id>.provenance.json`: who, which\n * commit, which in-scope diff, and a hash of the verdict. `wp-finish-upsert-pr` rejects a verdict\n * without one, or one edited since;\n * 5. the round must be inside the budget (issues #1051, #1053): a round above `maxReviewerRounds` records\n * nothing, and a round's verdict is never overwritten, whoever spawned the reviewer. `--check` asks the\n * same question BEFORE a reviewer spends a review on it;\n * 6. the color must fit the round (issue #1053): the FINAL round has no red — its must-fix color is\n * orange, never re-reviewed — and orange is refused before the final round, where red still means\n * \"fix it and it will be reviewed again\".\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class WriteReviewCommand {\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n private readonly repoRootFinder: RepoRootFinder,\n private readonly aiBranchName: AiBranchName,\n private readonly receipts: ReviewStageReceiptService,\n private readonly identity: ReviewerIdentityResolver,\n private readonly provenance: VerdictProvenanceService,\n private readonly reviewJsonService: ReviewJsonService,\n ) {}\n\n run(opts: WriteReviewOptions): Promise<void> {\n const id = opts.checklistId.trim();\n const cwd = opts.cwd;\n const repoRoot = this.repoRootFinder.resolveRepoRoot(cwd);\n const featureName = this.aiBranchName.getFeatureName();\n const receipt = this.briefedReceipt(repoRoot, featureName, id);\n // Identity BEFORE parsing: a coordinator is refused whatever it submitted, and the stamp it\n // consumes must not survive to lend itself to a later call.\n const who: ReviewerIdentity = this.identity.resolve(cwd, id);\n this.assertWithinBudget(summaryJsonPath(repoRoot, featureName), receipt, id);\n const verdict = this.parse(opts.json, id, receipt);\n const record = new VerdictProvenance(\n id, who.harness, who.sessionId, who.agentId, who.agentType, receipt.headSha, receipt.scopeHashes[id] ?? '');\n record.round = receipt.round;\n const written = this.provenance.write(summaryJsonPath(repoRoot, featureName), verdict, record);\n process.stdout.write(\n `✅ ${verdict.status.toUpperCase()} verdict for \"${id}\" submitted → ${written}\\n`\n + ` provenance: ${who.harness}${who.agentId === '' ? '' : ` agent ${who.agentId}`}, `\n + `briefed at ${receipt.headSha.slice(0, 8)}, global round ${receipt.round} of ${receipt.maxReviewerRounds}\\n`);\n return Promise.resolve();\n }\n\n /**\n * `wp-write-review --check`: the reviewer's FIRST step. Refuses exactly when {@link run} would refuse\n * on the budget, so a reviewer past the budget learns it before it reviews rather than after.\n */\n check(opts: ReviewBudgetCheckOptions): Promise<void> {\n const id = opts.checklistId.trim();\n const repoRoot = this.repoRootFinder.resolveRepoRoot(opts.cwd);\n const featureName = this.aiBranchName.getFeatureName();\n const receipt = this.briefedReceipt(repoRoot, featureName, id);\n this.assertWithinBudget(summaryJsonPath(repoRoot, featureName), receipt, id);\n const final = this.isFinalRound(receipt)\n ? ` This is the FINAL round: there is no re-review, so you may NOT mark ${VERDICT_RED} — mark every must-fix finding ${VERDICT_ORANGE}.`\n : '';\n process.stdout.write(\n `✅ \"${id}\" may be reviewed: this is review round ${receipt.round} of at most ${receipt.maxReviewerRounds}.${final} `\n + `Review it, then submit with pnpm ${WRITE_REVIEW_BIN} --checklist ${id}.\\n`);\n return Promise.resolve();\n }\n\n /** The last round `maxReviewerRounds` allows — the one with no red (issue #1053). */\n private isFinalRound(receipt: ReviewStageReceipt): boolean {\n return receipt.round >= receipt.maxReviewerRounds;\n }\n\n /**\n * THE ROUND CAP, held by the reviewer's own submission path (issues #1051, #1053). The planner already\n * never briefs past the cap, but an author agent could still spawn a reviewer from an old instructions\n * file — the measured deadlock did exactly that. Two refusals make it mechanical: a round above\n * `maxReviewerRounds` records nothing, and a checklist that already has a verdict in this round (or a\n * later one) gets no second one — a round's verdict is never overwritten.\n */\n private assertWithinBudget(summaryPath: string, receipt: ReviewStageReceipt, id: string): void {\n const max = receipt.maxReviewerRounds;\n const latest = this.reviewJsonService.latestVerdictRound(summaryPath, id);\n if (receipt.round <= max && latest < receipt.round) return;\n const why = receipt.round > max\n ? `this briefing is for review round ${receipt.round}, above maxReviewerRounds (${max})`\n : `it already has a verdict for review round ${latest} (maxReviewerRounds is ${max}), and a round's verdict is never overwritten`;\n throw new InformAiError(\n `I am not allowed to review ${id}: ${why}.\\n`\n + `Do not review it and submit nothing for it; report this refusal, verbatim, to the agent that spawned you. `\n + `The verdict already recorded for it stands (${this.reviewJsonService.latestChecklistResultPath(summaryPath, id) || 'none'}), and `\n + 'the author records any fix with pnpm wp-write-review-fixes.');\n }\n\n /** The stage-② receipt, provided it briefed THIS checklist this round. */\n private briefedReceipt(repoRoot: string, featureName: string, id: string): ReviewStageReceipt {\n if (id === '') throw new InformAiError(`${WRITE_REVIEW_BIN} needs the checklist id: pnpm ${WRITE_REVIEW_BIN} --checklist <id>`);\n const receipt = this.receipts.read(repoRoot, featureName);\n if (receipt === null) {\n throw new InformAiError(`${WRITE_REVIEW_BIN}: pnpm wp-review-upsert-pr has not briefed any reviewer on this branch yet, `\n + 'so there is nothing to submit a verdict against.');\n }\n if (!receipt.reviewersBriefed.includes(id) || (receipt.scopeHashes[id] ?? '') === '') {\n const briefed = receipt.reviewersBriefed.length === 0 ? '(none)' : receipt.reviewersBriefed.join(', ');\n throw new InformAiError(`${WRITE_REVIEW_BIN}: checklist \"${id}\" was not briefed by the last pnpm wp-review-upsert-pr `\n + `(briefed this round: ${briefed}). Submit only for a checklist whose instructions file you were handed — `\n + 'a checklist absent here either carries its earlier verdict or does not apply to this diff.');\n }\n return receipt;\n }\n\n /**\n * Strict: an object with exactly the verdict's five fields, every one a string, and a status that fits\n * the round — red only BEFORE the final round, orange only ON it (issue #1053).\n */\n private parse(json: string, id: string, receipt: ReviewStageReceipt): SubmittedVerdict {\n const raw = this.parseObject(json);\n const problems: string[] = [];\n const extra = Object.keys(raw).filter((k: string): boolean => !(VERDICT_KEYS as readonly string[]).includes(k));\n if (extra.includes('override')) {\n problems.push(`\"override\" is not a verdict field — a ship-anyway decision is a HUMAN's, recorded by the coordinating agent in ${checklistOverrideService.overrideFileName(id)}`);\n }\n if (extra.length > 0) problems.push(`unknown field(s) ${extra.map((k: string): string => `\"${k}\"`).join(', ')} — a verdict has exactly: ${VERDICT_KEYS.join(', ')}`);\n if (raw['id'] !== undefined && this.text(raw, 'id') !== id) problems.push(`\"id\" is ${JSON.stringify(raw['id'])} but --checklist is \"${id}\"`);\n const status = this.text(raw, 'status').toLowerCase();\n // webpieces-disable no-any-unknown -- comparing against the readonly literal tuple of valid colors\n if (!(VERDICT_STATUSES as readonly string[]).includes(status)) problems.push(`\"status\" must be one of ${VERDICT_STATUSES.join(', ')}`);\n problems.push(...this.colorForRound(status, receipt));\n for (const key of ['agent', 'model', 'output']) {\n if (this.text(raw, key) === '') problems.push(`\"${key}\" must be a non-empty string${key === 'output' ? '' : ' (use \"unknown\" when unavailable)'}`);\n }\n if (problems.length > 0) {\n throw new InformAiError(`${WRITE_REVIEW_BIN}: the verdict for \"${id}\" was NOT submitted:\\n`\n + problems.map((p: string): string => ` • ${p}`).join('\\n'));\n }\n return new SubmittedVerdict(id, status, this.text(raw, 'agent'), this.text(raw, 'model'), raw['output'] as string);\n }\n\n /**\n * The round decides which blocking color exists. The FINAL round's red would mean \"fix it and it will be\n * reviewed again\", and there is no again — so it is refused and orange named. Orange before the final\n * round would waive a re-review that the budget still pays for — so it is refused and red named.\n */\n private colorForRound(status: string, receipt: ReviewStageReceipt): string[] {\n const round = `review round ${receipt.round} of ${receipt.maxReviewerRounds}`;\n if (status === VERDICT_RED && this.isFinalRound(receipt)) {\n return [`\"status\": \"${VERDICT_RED}\" is not allowed: ${round} is the FINAL round, and there is no re-review. `\n + `Mark anything that must be fixed \"${VERDICT_ORANGE}\", with a concrete, actionable fix in \"output\" — the author applies it `\n + 'best effort and ships without another review.'];\n }\n if (status === VERDICT_ORANGE && !this.isFinalRound(receipt)) {\n return [`\"status\": \"${VERDICT_ORANGE}\" is only for the FINAL review round, and ${round} is not it. `\n + `Use \"${VERDICT_RED}\" for a must-fix finding: the author's fix will be reviewed again next round.`];\n }\n return [];\n }\n\n // webpieces-disable no-any-unknown -- one field of the opaque submitted object, narrowed to a trimmed string\n private text(raw: Record<string, unknown>, key: string): string {\n const value = raw[key];\n return typeof value === 'string' ? value.trim() : '';\n }\n\n // webpieces-disable no-any-unknown -- the submitted JSON is opaque until parse() narrows every field\n private parseObject(json: string): Record<string, unknown> {\n // webpieces-disable no-any-unknown -- parsed JSON is opaque until narrowed\n let parsed: unknown = null;\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: a JSON syntax error becomes the AI-facing refusal\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n parsed = JSON.parse(json);\n } catch (err: unknown) {\n const error = toError(err);\n throw new InformAiError(`${WRITE_REVIEW_BIN}: the verdict is not valid JSON.`, { cause: error });\n }\n if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n throw new InformAiError(`${WRITE_REVIEW_BIN}: the verdict must be ONE JSON object.`);\n }\n // webpieces-disable no-any-unknown -- narrowed to a plain object just above\n return parsed as Record<string, unknown>;\n }\n}\n\n/**\n * Reads the verdict JSON for the composition root: `--file <path>`, else stdin. Separate from the command\n * so the command stays a function of its inputs.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class WriteReviewInput {\n read(filePath: string): string {\n if (filePath.trim() !== '') {\n if (!fs.existsSync(filePath)) throw new InformAiError(`${WRITE_REVIEW_BIN}: --file ${filePath} does not exist.`);\n return fs.readFileSync(filePath, 'utf8');\n }\n if (process.stdin.isTTY === true) {\n throw new InformAiError(`${WRITE_REVIEW_BIN}: pass the verdict JSON on stdin (pnpm ${WRITE_REVIEW_BIN} --checklist <id> <<'EOF' … EOF) or with --file <path>.`);\n }\n return fs.readFileSync(0, 'utf8');\n }\n}\n"]}
@@ -7,7 +7,11 @@ export declare class WriteReviewFixesOptions {
7
7
  cwd: string;
8
8
  constructor(json: string, cwd: string);
9
9
  }
10
- /** Coordinator-owned writer for the SHA-bound response to a completed red reviewer round. */
10
+ /**
11
+ * Coordinator-owned writer for the SHA-bound response to a completed reviewer round: one fix per RED (a round
12
+ * that is not the last, re-reviewed next round) or per ORANGE (the final round, never re-reviewed — finish
13
+ * stamps each on the dashboard with its resolution). Written as `review-round<N>-fixes.json`, once.
14
+ */
11
15
  export declare class WriteReviewFixesCommand {
12
16
  private readonly repoRootFinder;
13
17
  private readonly aiBranchName;
@@ -17,7 +17,11 @@ class WriteReviewFixesOptions {
17
17
  }
18
18
  }
19
19
  exports.WriteReviewFixesOptions = WriteReviewFixesOptions;
20
- /** Coordinator-owned writer for the SHA-bound response to a completed red reviewer round. */
20
+ /**
21
+ * Coordinator-owned writer for the SHA-bound response to a completed reviewer round: one fix per RED (a round
22
+ * that is not the last, re-reviewed next round) or per ORANGE (the final round, never re-reviewed — finish
23
+ * stamps each on the dashboard with its resolution). Written as `review-round<N>-fixes.json`, once.
24
+ */
21
25
  let WriteReviewFixesCommand = class WriteReviewFixesCommand {
22
26
  repoRootFinder;
23
27
  aiBranchName;
@@ -36,10 +40,7 @@ let WriteReviewFixesCommand = class WriteReviewFixesCommand {
36
40
  if (receipt === null)
37
41
  throw new rules_config_1.InformAiError('wp-write-review-fixes: no reviewer round has started on this branch.');
38
42
  const written = this.rounds.writeRemediation(repoRoot, (0, rules_config_1.summaryJsonPath)(repoRoot, featureName), receipt, opts.json);
39
- // The receipt names the reviewed HEAD this remediation starts from. After the round cap no later
40
- // stage ② ever opens a round to stamp it, so the command that ACCEPTS the remediation does (#1051).
41
- this.receipts.recordRemediation(repoRoot, featureName, receipt);
42
- process.stdout.write(`✅ SHA-bound remediation for global round ${receipt.round} recorded → ${written}\n`);
43
+ process.stdout.write(`✅ SHA-bound fixes recorded → ${written}\n`);
43
44
  return Promise.resolve();
44
45
  }
45
46
  };
@@ -1 +1 @@
1
- {"version":3,"file":"write-review-fixes-command.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/commands/write-review-fixes-command.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,0DAAyF;AACzF,yCAA2D;AAC3D,2EAAgE;AAChE,uEAAyE;AACzE,2EAA6E;AAE7E,MAAa,uBAAuB;IAChC,IAAI,CAAS;IACb,GAAG,CAAS;IAEZ,YAAY,IAAY,EAAE,GAAW;QACjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACnB,CAAC;CACJ;AARD,0DAQC;AAED,6FAA6F;AAEtF,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAEX;IACA;IACA;IACA;IAJrB,YACqB,cAA8B,EAC9B,YAA0B,EAC1B,QAAmC,EACnC,MAA+B;QAH/B,mBAAc,GAAd,cAAc,CAAgB;QAC9B,iBAAY,GAAZ,YAAY,CAAc;QAC1B,aAAQ,GAAR,QAAQ,CAA2B;QACnC,WAAM,GAAN,MAAM,CAAyB;IACjD,CAAC;IAEJ,GAAG,CAAC,IAA6B;QAC7B,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC/D,MAAM,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC,cAAc,EAAE,CAAC;QACvD,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QAC1D,IAAI,OAAO,KAAK,IAAI;YAAE,MAAM,IAAI,4BAAa,CAAC,sEAAsE,CAAC,CAAC;QACtH,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,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oRootFinder, InformAiError, summaryJsonPath } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { AiBranchName } from '../workflow/git-readAiBranchName';\nimport { ReviewRoundStateService } from '../workflow/review-round-state';\nimport { ReviewStageReceiptService } from '../workflow/review-stage-receipt';\n\nexport class WriteReviewFixesOptions {\n json: string;\n cwd: string;\n\n constructor(json: string, cwd: string) {\n this.json = json;\n this.cwd = cwd;\n }\n}\n\n/** Coordinator-owned writer for the SHA-bound response to a completed red reviewer round. */\n@injectable(bindingScopeValues.Singleton)\nexport class WriteReviewFixesCommand {\n constructor(\n private readonly repoRootFinder: RepoRootFinder,\n private readonly aiBranchName: AiBranchName,\n private readonly receipts: ReviewStageReceiptService,\n private readonly rounds: ReviewRoundStateService,\n ) {}\n\n run(opts: WriteReviewFixesOptions): Promise<void> {\n const repoRoot = this.repoRootFinder.resolveRepoRoot(opts.cwd);\n const featureName = this.aiBranchName.getFeatureName();\n const receipt = this.receipts.read(repoRoot, featureName);\n if (receipt === null) throw new InformAiError('wp-write-review-fixes: no reviewer round has started on this branch.');\n const written = this.rounds.writeRemediation(repoRoot, summaryJsonPath(repoRoot, featureName), receipt, opts.json);\n // The receipt names the reviewed HEAD this remediation starts from. After the round cap no later\n // stage ② ever opens a round to stamp it, so the command that ACCEPTS the remediation does (#1051).\n this.receipts.recordRemediation(repoRoot, featureName, receipt);\n process.stdout.write(`✅ SHA-bound remediation for global round ${receipt.round} recorded → ${written}\\n`);\n return Promise.resolve();\n }\n}\n\n@injectable(bindingScopeValues.Singleton)\nexport class WriteReviewFixesInput {\n read(filePath: string): string {\n if (filePath.trim() !== '') {\n if (!fs.existsSync(filePath)) throw new InformAiError(`wp-write-review-fixes: --file ${filePath} does not exist.`);\n return fs.readFileSync(filePath, 'utf8');\n }\n if (process.stdin.isTTY === true) {\n throw new InformAiError('wp-write-review-fixes: pass JSON on stdin or with --file <path>.');\n }\n return fs.readFileSync(0, 'utf8');\n }\n}\n"]}
1
+ {"version":3,"file":"write-review-fixes-command.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/commands/write-review-fixes-command.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,0DAAyF;AACzF,yCAA2D;AAC3D,2EAAgE;AAChE,uEAAyE;AACzE,2EAA6E;AAE7E,MAAa,uBAAuB;IAChC,IAAI,CAAS;IACb,GAAG,CAAS;IAEZ,YAAY,IAAY,EAAE,GAAW;QACjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACnB,CAAC;CACJ;AARD,0DAQC;AAED;;;;GAIG;AAEI,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAEX;IACA;IACA;IACA;IAJrB,YACqB,cAA8B,EAC9B,YAA0B,EAC1B,QAAmC,EACnC,MAA+B;QAH/B,mBAAc,GAAd,cAAc,CAAgB;QAC9B,iBAAY,GAAZ,YAAY,CAAc;QAC1B,aAAQ,GAAR,QAAQ,CAA2B;QACnC,WAAM,GAAN,MAAM,CAAyB;IACjD,CAAC;IAEJ,GAAG,CAAC,IAA6B;QAC7B,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC/D,MAAM,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC,cAAc,EAAE,CAAC;QACvD,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QAC1D,IAAI,OAAO,KAAK,IAAI;YAAE,MAAM,IAAI,4BAAa,CAAC,sEAAsE,CAAC,CAAC;QACtH,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAA,8BAAe,EAAC,QAAQ,EAAE,WAAW,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QACnH,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,gCAAgC,OAAO,IAAI,CAAC,CAAC;QAClE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;CACJ,CAAA;AAjBY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGA,6BAAc;QAChB,mCAAY;QAChB,gDAAyB;QAC3B,4CAAuB;GAL3C,uBAAuB,CAiBnC;AAGM,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAC9B,IAAI,CAAC,QAAgB;QACjB,IAAI,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACzB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;gBAAE,MAAM,IAAI,4BAAa,CAAC,iCAAiC,QAAQ,kBAAkB,CAAC,CAAC;YACnH,OAAO,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC7C,CAAC;QACD,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;YAC/B,MAAM,IAAI,4BAAa,CAAC,kEAAkE,CAAC,CAAC;QAChG,CAAC;QACD,OAAO,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC;CACJ,CAAA;AAXY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;GAC5B,qBAAqB,CAWjC","sourcesContent":["import * as fs from 'fs';\nimport { RepoRootFinder, InformAiError, summaryJsonPath } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { AiBranchName } from '../workflow/git-readAiBranchName';\nimport { ReviewRoundStateService } from '../workflow/review-round-state';\nimport { ReviewStageReceiptService } from '../workflow/review-stage-receipt';\n\nexport class WriteReviewFixesOptions {\n json: string;\n cwd: string;\n\n constructor(json: string, cwd: string) {\n this.json = json;\n this.cwd = cwd;\n }\n}\n\n/**\n * Coordinator-owned writer for the SHA-bound response to a completed reviewer round: one fix per RED (a round\n * that is not the last, re-reviewed next round) or per ORANGE (the final round, never re-reviewed — finish\n * stamps each on the dashboard with its resolution). Written as `review-round<N>-fixes.json`, once.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class WriteReviewFixesCommand {\n constructor(\n private readonly repoRootFinder: RepoRootFinder,\n private readonly aiBranchName: AiBranchName,\n private readonly receipts: ReviewStageReceiptService,\n private readonly rounds: ReviewRoundStateService,\n ) {}\n\n run(opts: WriteReviewFixesOptions): Promise<void> {\n const repoRoot = this.repoRootFinder.resolveRepoRoot(opts.cwd);\n const featureName = this.aiBranchName.getFeatureName();\n const receipt = this.receipts.read(repoRoot, featureName);\n if (receipt === null) throw new InformAiError('wp-write-review-fixes: no reviewer round has started on this branch.');\n const written = this.rounds.writeRemediation(repoRoot, summaryJsonPath(repoRoot, featureName), receipt, opts.json);\n process.stdout.write(`✅ SHA-bound fixes recorded → ${written}\\n`);\n return Promise.resolve();\n }\n}\n\n@injectable(bindingScopeValues.Singleton)\nexport class WriteReviewFixesInput {\n read(filePath: string): string {\n if (filePath.trim() !== '') {\n if (!fs.existsSync(filePath)) throw new InformAiError(`wp-write-review-fixes: --file ${filePath} does not exist.`);\n return fs.readFileSync(filePath, 'utf8');\n }\n if (process.stdin.isTTY === true) {\n throw new InformAiError('wp-write-review-fixes: pass JSON on stdin or with --file <path>.');\n }\n return fs.readFileSync(0, 'utf8');\n }\n}\n"]}