@webpieces/rules-config 0.4.909 → 0.4.911

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 (95) hide show
  1. package/package.json +7 -6
  2. package/src/aged-tree-sweep.d.ts +2 -2
  3. package/src/aged-tree-sweep.js +2 -2
  4. package/src/aged-tree-sweep.js.map +1 -1
  5. package/src/build-log-doc.d.ts +1 -1
  6. package/src/build-log-doc.js +3 -3
  7. package/src/build-log-doc.js.map +1 -1
  8. package/src/builds-log.d.ts +2 -2
  9. package/src/builds-log.js +2 -2
  10. package/src/builds-log.js.map +1 -1
  11. package/src/checklist-override.d.ts +1 -1
  12. package/src/checklist-override.js +1 -1
  13. package/src/checklist-override.js.map +1 -1
  14. package/src/config-error-banner.js +1 -1
  15. package/src/config-error-banner.js.map +1 -1
  16. package/src/config-repair-bootstrap-source.d.ts +1 -1
  17. package/src/config-repair-bootstrap-source.js +1 -1
  18. package/src/config-repair-bootstrap-source.js.map +1 -1
  19. package/src/config-repair-probe.js +3 -3
  20. package/src/config-repair-probe.js.map +1 -1
  21. package/src/constants.js +3 -3
  22. package/src/constants.js.map +1 -1
  23. package/src/exclude-hook-paths.d.ts +5 -5
  24. package/src/exclude-hook-paths.js +5 -5
  25. package/src/exclude-hook-paths.js.map +1 -1
  26. package/src/exclude-paths.d.ts +1 -1
  27. package/src/exclude-paths.js +1 -1
  28. package/src/exclude-paths.js.map +1 -1
  29. package/src/hook-fault-codes.js.map +1 -1
  30. package/src/index.js +5 -5
  31. package/src/index.js.map +1 -1
  32. package/src/instruct-ai-docs.d.ts +3 -3
  33. package/src/instruct-ai-docs.js +3 -3
  34. package/src/instruct-ai-docs.js.map +1 -1
  35. package/src/legacy-config-upgrade.js +2 -2
  36. package/src/legacy-config-upgrade.js.map +1 -1
  37. package/src/load-config.js +3 -0
  38. package/src/load-config.js.map +1 -1
  39. package/src/load-template.d.ts +1 -1
  40. package/src/load-template.js +2 -2
  41. package/src/load-template.js.map +1 -1
  42. package/src/merge-process-doc.d.ts +1 -1
  43. package/src/merge-process-doc.js +2 -2
  44. package/src/merge-process-doc.js.map +1 -1
  45. package/src/migrate-dirs-cli.d.ts +4 -0
  46. package/src/migrate-dirs-cli.js +32 -0
  47. package/src/migrate-dirs-cli.js.map +1 -0
  48. package/src/orphan-dir-archive.d.ts +4 -4
  49. package/src/orphan-dir-archive.js +4 -4
  50. package/src/orphan-dir-archive.js.map +1 -1
  51. package/src/orphan-dir-scan.d.ts +1 -1
  52. package/src/orphan-dir-scan.js +1 -1
  53. package/src/orphan-dir-scan.js.map +1 -1
  54. package/src/orphan-dir-sweep.js +1 -1
  55. package/src/orphan-dir-sweep.js.map +1 -1
  56. package/src/pack-policy-files.js +4 -3
  57. package/src/pack-policy-files.js.map +1 -1
  58. package/src/policy-tracking.d.ts +7 -0
  59. package/src/policy-tracking.js +68 -0
  60. package/src/policy-tracking.js.map +1 -0
  61. package/src/pr-gate-config.d.ts +1 -1
  62. package/src/pr-gate-config.js +1 -1
  63. package/src/pr-gate-config.js.map +1 -1
  64. package/src/repo-root.d.ts +7 -7
  65. package/src/repo-root.js +8 -8
  66. package/src/repo-root.js.map +1 -1
  67. package/src/repo-scratch-dirs.d.ts +3 -3
  68. package/src/repo-scratch-dirs.js +5 -5
  69. package/src/repo-scratch-dirs.js.map +1 -1
  70. package/src/review-json-data.js +2 -2
  71. package/src/review-json-data.js.map +1 -1
  72. package/src/review-json.js +1 -1
  73. package/src/review-json.js.map +1 -1
  74. package/src/reviewer-instructions.d.ts +1 -1
  75. package/src/reviewer-instructions.js +1 -1
  76. package/src/reviewer-instructions.js.map +1 -1
  77. package/src/rule-pack-artifacts.d.ts +2 -2
  78. package/src/rule-pack-artifacts.js +2 -2
  79. package/src/rule-pack-artifacts.js.map +1 -1
  80. package/src/rule-pack-sync.js +5 -4
  81. package/src/rule-pack-sync.js.map +1 -1
  82. package/src/stale-bin-sweep.js +1 -1
  83. package/src/stale-bin-sweep.js.map +1 -1
  84. package/src/subagent-provenance.d.ts +6 -6
  85. package/src/subagent-provenance.js +6 -6
  86. package/src/subagent-provenance.js.map +1 -1
  87. package/src/sync-flow-guidance.js +1 -1
  88. package/src/sync-flow-guidance.js.map +1 -1
  89. package/templates/webpieces.branch-state-matrix.md +2 -2
  90. package/templates/webpieces.buildlog.md +3 -3
  91. package/templates/webpieces.ci-gate-setup.md +2 -2
  92. package/templates/webpieces.git-workflow.md +9 -9
  93. package/templates/webpieces.guard-matrix.md +6 -5
  94. package/templates/webpieces.location-matrix.md +9 -9
  95. package/templates/webpieces.review-checklists.md +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"review-json.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/review-json.ts"],"names":[],"mappings":";;;AAirBA,4BAEC;AAGD,0CAEC;AAGD,sDAEC;;AA7rBD,+CAAyB;AACzB,mDAA6B;AAC7B,mCAAoC;AACpC,yCAA2D;AAC3D,8DAA0D;AAC1D,8DAAuE;AACvE,8DAA0D;AAC1D,iEAA6D;AAC7D,iFAA2E;AAC3E,uEAAkE;AAClE,6DAA6G;AAwBpG,kGAxBA,sCAAiB,OAwBA;AAAE,yGAxBA,6CAAwB,OAwBA;AAAE,yGAxBA,6CAAwB,OAwBA;AAvB9E,yDAoB4B;AAKxB,8FAxBA,gCAAa,OAwBA;AACb,+FAxBA,iCAAc,OAwBA;AACd,+FAxBA,iCAAc,OAwBA;AACd,4FAxBA,8BAAW,OAwBA;AACX,iGAxBA,mCAAgB,OAwBA;AAChB,gGAxBA,kCAAe,OAwBA;AACf,kGAxBA,oCAAiB,OAwBA;AACjB,uGAxBA,yCAAsB,OAwBA;AACtB,0FAxBA,4BAAS,OAwBA;AACT,wFAxBA,0BAAO,OAwBA;AACP,wFAxBA,0BAAO,OAwBA;AACP,8FAxBA,gCAAa,OAwBA;AACb,gGAxBA,kCAAe,OAwBA;AACf,0FAxBA,4BAAS,OAwBA;AACT,wFAxBA,0BAAO,OAwBA;AACP,2FAxBA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C;QACtD,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACpB,MAAM,KAAK,GAAG,IAAA,kBAAO,EAAC,GAAG,CAAC,CAAC;YAC3B,MAAM,IAAI,8BAAa,CAAC,mCAAmC,KAAK,CAAC,OAAO,QAAQ,GAAG,GAAG,IAAI,CAAC,qBAAqB,CAAC,QAAQ,EAAE,6BAA6B,CAAC,MAAM,GAAG,gBAAgB,YAAY,EAAE,CAAC,CAAC;QACtM,CAAC;IACL,CAAC;CACJ,CAAA;AA5lBY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGR,6BAAY;QACT,6CAAwB;GAH/C,iBAAiB,CA4lB7B;AAED,0FAA0F;AAC1F,MAAM,aAAa,GAAG,IAAI,iBAAiB,EAAE,CAAC;AAE9C,wIAAwI;AACxI,SAAgB,QAAQ,CAAC,QAAgB,EAAE,WAAmB;IAC1D,OAAO,aAAa,CAAC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;AACzD,CAAC;AAED,wIAAwI;AACxI,SAAgB,eAAe,CAAC,QAAgB,EAAE,WAAmB;IACjE,OAAO,aAAa,CAAC,eAAe,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;AAChE,CAAC;AAED,wIAAwI;AACxI,SAAgB,qBAAqB,CAAC,QAAgB,EAAE,qBAAqB,GAAG,EAAE;IAC9E,OAAO,aAAa,CAAC,qBAAqB,CAAC,QAAQ,EAAE,qBAAqB,CAAC,CAAC;AAChF,CAAC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { randomUUID } from 'crypto';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { PR_REVIEW_DIR } from '@webpieces/tooling-common';\nimport { DotWebpieces, dotWebpieces } from '@webpieces/tooling-common';\nimport { InformAiError } from '@webpieces/tooling-common';\nimport { toError } from '@webpieces/tooling-common/to-error';\nimport { SummaryJsonSchemaRenderer } from './summary-json-schema-renderer';\nimport { VerdictSchemaRenderer } from './verdict-schema-renderer';\nimport { ChecklistOverride, ChecklistOverrideService, checklistOverrideService } from './checklist-override';\nimport {\n VERDICT_GREEN,\n VERDICT_YELLOW,\n VERDICT_ORANGE,\n VERDICT_RED,\n VERDICT_STATUSES,\n ChecklistResult,\n RequiredChecklist,\n ChecklistReviewContext,\n PrSummary,\n CK_PASS,\n CK_WARN,\n CK_OVERRIDDEN,\n CK_ORANGE_FIXED,\n CK_ORANGE,\n CK_FAIL,\n CK_MISSING,\n CK_BAD_FORMAT,\n ChecklistVerdict,\n PrContext,\n} from './review-json-data';\n\n// Re-exported so review-json.ts stays the single import site for the review vocabulary.\nexport { ChecklistOverride, ChecklistOverrideService, checklistOverrideService };\nexport {\n VERDICT_GREEN,\n VERDICT_YELLOW,\n VERDICT_ORANGE,\n VERDICT_RED,\n VERDICT_STATUSES,\n ChecklistResult,\n RequiredChecklist,\n ChecklistReviewContext,\n PrSummary,\n CK_PASS,\n CK_WARN,\n CK_OVERRIDDEN,\n CK_ORANGE_FIXED,\n CK_ORANGE,\n CK_FAIL,\n CK_MISSING,\n CK_BAD_FORMAT,\n ChecklistVerdict,\n PrContext,\n};\n\nconst RISK_LEVELS = ['green', 'yellow', 'red'] as const;\nconst EMOJI_FOR_LEVEL: Record<string, string> = { green: '🟢', yellow: '🟡', red: '🔴' };\n\n// Where `wp-finish-upsert-pr` retires the summary.json it just consumed, and the note it stamps on the way.\n// The key sorts first in the written JSON because it is written first — an AI that opens the file to see\n// whether it can reuse the summary reads what the file IS before it reads a title it might be tempted to keep.\nconst OLD_SUMMARY_FILE = 'old-summary.json';\nconst ARCHIVE_NOTE_KEY = '_ARCHIVED_AUDIT_ONLY';\nconst ARCHIVE_NOTE =\n 'ARCHIVE — this is the PR summary from the PREVIOUS wp-finish-upsert-pr run on this branch, kept for audit ' +\n 'purposes only. It is NOT the summary for a new round: it describes the code as of the last PR ' +\n 'update, which has since moved. If you are updating the PR again, write a FRESH summary.json at the path ' +\n \"pnpm wp-review-upsert-pr prints; do not copy this file's title, summary or risk level forward without \" +\n 're-deciding each one. Overwritten by every finish, so only the most recent summary is ever here.';\n\n// A verdict file is named by its ROUND (issue #1053): `review-round<N>-<id>.json`, one per round, never\n// overwritten. The id is matched EXACTLY (escaped), so `review-round2-fixes.json` (the author's recorded\n// fixes for round 2) and a provenance file beside a verdict can never be read as a verdict.\nconst VERDICT_FILE_PREFIX = 'review-round';\n\n/** Locates + loads/validates the AI-authored summary.json. `@injectable(bindingScopeValues.Singleton)` so it's drawn in the design. */\n@injectable(bindingScopeValues.Singleton)\nexport class ReviewJsonService {\n constructor(\n private readonly dotDir: DotWebpieces = dotWebpieces,\n private readonly overrides: ChecklistOverrideService = checklistOverrideService,\n ) {}\n\n // The per-feature PR working dir: `<worktree>/.webpieces/pr-review/<feature>`. AI-WRITABLE scope,\n // not local() — an agent AUTHORS summary.json here, and each reviewer subagent authors its own\n // review-round<N>-<id>.json beside it. A worktree-isolated agent's Write is refused for any path under the\n // shared checkout, which is where local() puts this, so local() made both files unwritable by the\n // very agents the flow instructs to write them. See DotWebpieces.aiWritable() for the full account.\n prDirFor(repoRoot: string, featureName: string): string {\n return this.dotDir.aiWritableFile(repoRoot, PR_REVIEW_DIR, featureName);\n }\n\n // Absolute path of the summary.json for a feature — beside pr-body.md, keyed by branch name.\n summaryJsonPath(repoRoot: string, featureName: string): string {\n return path.join(this.prDirFor(repoRoot, featureName), 'summary.json');\n }\n\n // Absolute path of the pr-context.json for a feature (the diff base/head + changed files).\n prContextPath(repoRoot: string, featureName: string): string {\n return path.join(this.prDirFor(repoRoot, featureName), 'pr-context.json');\n }\n\n // Where a consumed summary.json is archived to, beside it. Always the SAME path — it holds the last\n // summary and only the last one, so it can never be mistaken for a series that means something.\n oldSummaryJsonPath(summaryJsonFilePath: string): string {\n return path.join(path.dirname(summaryJsonFilePath), OLD_SUMMARY_FILE);\n }\n\n /** Keep the active PR intent available for updates; each publication gets an immutable audit copy. */\n snapshotSummaryJson(summaryJsonFilePath: string): string {\n const dir = path.join(path.dirname(summaryJsonFilePath), 'published-summaries');\n fs.mkdirSync(dir, { recursive: true });\n const snapshot = path.join(dir, `${randomUUID()}.json`);\n const raw = fs.readFileSync(summaryJsonFilePath, 'utf8');\n const note =\n 'AUDIT ONLY — the summary used by this publication. The active PR intent is in ' +\n 'summary.json beside published-summaries. Refresh the active file when intent, issue, title or risk changes.';\n fs.writeFileSync(snapshot, this.archivedBody(raw, note), { flag: 'wx' });\n return snapshot;\n }\n\n /**\n * Retire the PR summary `wp-finish-upsert-pr` just used: move summary.json to old-summary.json, stamped\n * with a note saying what it is. Returns the archive path, or '' when there was nothing to archive.\n *\n * The point is the MOVE, not the copy. summary.json left in place after a PR is posted is a live-looking\n * file describing a PR update that already happened, and the next run of stage ② on this branch finds it\n * sitting there — so a reviewer subagent that judges the PR's stated intent (its title, summary or risk\n * level) can read the previous run's summary and return GREEN against a title that no longer exists.\n * Nothing in the verdict distinguishes that from a real pass. Moving it means the only way to reach\n * finish again is to write a fresh one, and {@link loadSummaryJson} points at the archive when it is\n * missing so the archive reads as an audit trail rather than as a lost file.\n *\n * Called only after the PR is actually up: a finish that failed before publishing must stay re-runnable.\n */\n archiveSummaryJson(summaryJsonFilePath: string): string {\n if (!fs.existsSync(summaryJsonFilePath)) return '';\n const archivePath = this.oldSummaryJsonPath(summaryJsonFilePath);\n const raw = fs.readFileSync(summaryJsonFilePath, 'utf8');\n fs.writeFileSync(archivePath, this.archivedBody(raw, ARCHIVE_NOTE));\n fs.rmSync(summaryJsonFilePath);\n return archivePath;\n }\n\n /**\n * The archived bytes: the original JSON with an AUDIT-ONLY note as its FIRST key, so anything that opens\n * the file — human or AI — reads what it is before it reads any of its content.\n *\n * Falls back to the raw bytes when they do not parse. `loadSummaryJson` has already accepted the file, so\n * that is close to impossible, but preserving the original always beats losing it to a stamping failure,\n * since the archive exists precisely to be the record.\n */\n private archivedBody(raw: string, note: string): string {\n const parsed = this.tryParseObject(raw);\n if (parsed === null) return raw;\n // webpieces-disable no-any-unknown -- re-serializing opaque review fields verbatim; only the key ORDER is ours\n const stamped: Record<string, unknown> = {};\n stamped[ARCHIVE_NOTE_KEY] = note;\n for (const key of Object.keys(parsed)) stamped[key] = parsed[key];\n return JSON.stringify(stamped, null, 2) + '\\n';\n }\n\n // webpieces-disable no-any-unknown -- opaque parsed JSON; the caller only re-serializes it\n private tryParseObject(raw: string): Record<string, unknown> | null {\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: unparseable bytes are archived verbatim, never fatal\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n // webpieces-disable no-any-unknown -- parsed JSON is opaque; only its key order is used\n const parsed = JSON.parse(raw) as Record<string, unknown>;\n if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) return null;\n return parsed;\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n return null;\n }\n }\n\n /**\n * Persist the PR's diff context so reviewer subagents can read the changed-file set + the exact base\n * sha. Returns the file path written.\n *\n * ALSO writes an immutable per-stage snapshot under `stages/<stage>.json` when `stage` is given.\n * `pr-context.json` is overwritten by each stage, so by the time anything goes wrong the earlier\n * states are gone — and \"what did the tooling think the diff was at stage ①, vs ②, vs ③?\" is exactly\n * the question you need answered when debugging a review that went sideways. The snapshots make the\n * review system auditable by an AI reviewing IT, which the single mutable file never could.\n */\n writePrContext(repoRoot: string, featureName: string, context: PrContext, stage = ''): string {\n const dir = this.prDirFor(repoRoot, featureName);\n fs.mkdirSync(dir, { recursive: true });\n const body = JSON.stringify(context, null, 2) + '\\n';\n const p = this.prContextPath(repoRoot, featureName);\n fs.writeFileSync(p, body);\n if (stage !== '') {\n const stagesDir = path.join(dir, 'stages');\n fs.mkdirSync(stagesDir, { recursive: true });\n fs.writeFileSync(path.join(stagesDir, `${stage}.json`), body);\n }\n return p;\n }\n\n /**\n * The review context for a feature, recovered from the pr-context.json wp-start-upsert-pr already wrote.\n * Lets wp-finish-upsert-pr's \"you still owe me review-round<N>-<id>.json\" message inline the SAME self-sufficient\n * per-reviewer block start printed, instead of a checklist name and an indirection. Empty when the file\n * is absent or unreadable — the block then just omits those lines.\n */\n reviewContextFor(repoRoot: string, featureName: string): ChecklistReviewContext {\n const p = this.prContextPath(repoRoot, featureName);\n if (!fs.existsSync(p)) return new ChecklistReviewContext();\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: an unreadable context file degrades to fewer printed lines, never a crash\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n // webpieces-disable no-any-unknown -- parsed JSON is opaque until narrowed on the next line\n const raw = JSON.parse(fs.readFileSync(p, 'utf8')) as Record<string, unknown>;\n const base = typeof raw['base'] === 'string' ? (raw['base'] as string) : '';\n // Recover the REPRODUCE command rather than re-deriving it: a context written by an older\n // pr-gate has no diffCommand, and guessing `<base> HEAD` there would resurrect the exact\n // empty-on-a-dirty-tree bug this field exists to kill. Absent ⇒ omit the line entirely.\n const cmd = typeof raw['diffCommand'] === 'string' ? (raw['diffCommand'] as string) : '';\n const diffDir = typeof raw['diffDir'] === 'string' ? (raw['diffDir'] as string) : '';\n const dirty = raw['dirty'] === true;\n return new ChecklistReviewContext(base, p, cmd === '' ? '' : `${cmd} -- <file>`, diffDir, dirty);\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n return new ChecklistReviewContext('', p);\n }\n }\n\n // Copy-paste summary.json schema shared by every command that asks the coordinating AI to write it.\n summaryJsonSchemaHint(filePath: string, mainAgentInstructions = ''): string {\n return new SummaryJsonSchemaRenderer().render(filePath, mainAgentInstructions);\n }\n\n /**\n * The extra line the \"no summary.json\" complaint carries when a PREVIOUS summary was archived here. It\n * turns a bare \"not found\" — which reads as data loss, and invites hunting for the file — into the fact:\n * the last finish consumed it, and the archive is audit material, not a summary to reuse.\n */\n private archivedSummaryHint(filePath: string, retryCommand: string): string {\n const archive = this.oldSummaryJsonPath(filePath);\n if (!fs.existsSync(archive)) return '';\n return `\\nA PREVIOUS PR summary was archived to ${archive} when the last ${retryCommand} consumed it.\\n` + `That file is for AUDIT ONLY — it describes code this branch has since moved past. Write a fresh one:`;\n }\n\n // Names summary.json when the author wrote its OLD name (review.json until #1033 — refused by Claude\n // auto-mode as Self-Approval beside the review-round<N>-<id>.json verdicts). HARD CUT: the stale file is never read.\n private renamedFileHint(filePath: string): string {\n const stale = path.join(path.dirname(filePath), 'review.json');\n if (!fs.existsSync(stale)) return '';\n return `\\n${stale} is IGNORED — the author's file was renamed to summary.json. ` + `Write the same JSON to ${filePath} instead.`;\n }\n\n /**\n * The per-checklist verdict file for ONE round, beside summary.json: `review-round<N>-<id>.json`.\n *\n * Round-numbered (issue #1053) so no round ever overwrites another. The top-level `review-<id>.json` this\n * replaced was overwritten by every submission, and a separate `rounds/<N>/` copy had to be kept in step\n * with it to recover the history: two records of one fact, and the copy was the one an agent could lose.\n */\n checklistResultPath(summaryJsonFilePath: string, checklistId: string, round: number): string {\n return path.join(path.dirname(summaryJsonFilePath), `${VERDICT_FILE_PREFIX}${round}-${checklistId}.json`);\n }\n\n /**\n * The HIGHEST round a verdict was submitted in for one checklist, or 0 when it has none. The live verdict\n * is always that one; every lower round is history. Derived from the files present, so there is no\n * counter to drift from them.\n */\n latestVerdictRound(summaryJsonFilePath: string, checklistId: string): number {\n const dir = path.dirname(summaryJsonFilePath);\n if (!fs.existsSync(dir)) return 0;\n const pattern = new RegExp(`^${VERDICT_FILE_PREFIX}(\\\\d+)-${this.escapeRegExp(checklistId)}\\\\.json$`);\n let latest = 0;\n for (const name of fs.readdirSync(dir)) {\n const match = pattern.exec(name);\n if (match !== null) latest = Math.max(latest, Number(match[1]));\n }\n return latest;\n }\n\n /** The verdict file name with the round left as `<N>`, for messages that name it before a round is known. */\n checklistResultPathTemplate(summaryJsonFilePath: string, checklistId: string): string {\n return path.join(path.dirname(summaryJsonFilePath), this.checklistFileName(checklistId));\n }\n\n /** The live (highest-round) verdict file for one checklist, or '' when none was ever submitted. */\n latestChecklistResultPath(summaryJsonFilePath: string, checklistId: string): string {\n const round = this.latestVerdictRound(summaryJsonFilePath, checklistId);\n return round === 0 ? '' : this.checklistResultPath(summaryJsonFilePath, checklistId, round);\n }\n\n private escapeRegExp(text: string): string {\n return text.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n }\n\n /**\n * Load + validate the AI-authored summary.json. Throws InformAiError (with the schema) when missing,\n * unparseable, or structurally wrong. `required` is the set of checklists the diff matched: every one\n * must have a well-formed, passing (or overridden) review-round<N>-<id>.json or a validation error is raised\n * alongside the usual ones so the AI gets ONE message.\n */\n // webpieces-disable max-lines-new-methods -- one cohesive load+validate pass over the review fields\n loadSummaryJson(\n filePath: string, required: readonly RequiredChecklist[] = [], expectedMainAgentInstructions = '',\n orangeFixes: Record<string, string> = {},\n retryCommand = 'pnpm wp-finish-upsert-pr',\n ): PrSummary {\n const raw = this.readSummaryObject(filePath, expectedMainAgentInstructions, retryCommand);\n const errors: string[] = [];\n for (const field of ['agent', 'model']) {\n if (typeof raw[field] !== 'string' || raw[field].trim() === '') {\n errors.push(`\"${field}\" must be a non-empty string; use \"unknown\" when unavailable.`);\n }\n }\n const riskScore = raw['riskScore'];\n if (typeof riskScore !== 'number' || !Number.isFinite(riskScore) || riskScore < 0 || riskScore > 100) {\n errors.push(`\"riskScore\" must be a number 0–100, got ${JSON.stringify(riskScore)}.`);\n }\n const riskLevel = raw['riskLevel'];\n if (typeof riskLevel !== 'string' || !RISK_LEVELS.includes(riskLevel as (typeof RISK_LEVELS)[number])) {\n errors.push(`\"riskLevel\" must be one of: ${RISK_LEVELS.join(', ')}.`);\n }\n const title = typeof raw['title'] === 'string' ? (raw['title'] as string).trim() : '';\n if (title === '') {\n errors.push('\"title\" must be a non-empty, imperative PR title describing the change (no branch names).');\n }\n const mainAgentInstructions = this.validateMainAgentInstructions(raw, expectedMainAgentInstructions, errors);\n\n const results = this.loadChecklistResults(filePath, required);\n for (const result of results) result.remediation = orangeFixes[result.id] ?? '';\n for (const err of this.requiredChecklistErrors(required, results, filePath)) errors.push(err);\n\n this.assertValidSummary(errors, filePath, expectedMainAgentInstructions, retryCommand);\n\n const level = riskLevel as string;\n const emoji = typeof raw['riskEmoji'] === 'string' && raw['riskEmoji'] !== '' ? (raw['riskEmoji'] as string) : (EMOJI_FOR_LEVEL[level] ?? '🟡');\n const summary = typeof raw['summary'] === 'string' ? (raw['summary'] as string) : '';\n\n return new PrSummary((raw['agent'] as string).trim(), (raw['model'] as string).trim(), title, riskScore as number, level, emoji, summary, this.asStringArray(raw['violations']), this.asStringArray(raw['risks']), this.asStringArray(raw['filesToReview']), results, mainAgentInstructions);\n }\n\n private assertValidSummary(errors: string[], filePath: string, expectedMainAgentInstructions: string, retryCommand: string): void {\n if (errors.length === 0) return;\n throw new InformAiError(`summary.json has ${errors.length} error(s) — fix ALL, then re-run ${retryCommand}:\\n\\n` + errors.map((e: string): string => ` • ${e}`).join('\\n') + `\\n\\n${this.summaryJsonSchemaHint(filePath, expectedMainAgentInstructions)}`);\n }\n\n /** Load the raw object and render every parse/shape error for the command that called us. */\n private readSummaryObject(\n filePath: string,\n expectedMainAgentInstructions: string,\n retryCommand: string,\n // webpieces-disable-next-line no-any-unknown -- opaque JSON is narrowed field-by-field by loadSummaryJson\n ): Record<string, unknown> {\n if (!fs.existsSync(filePath)) {\n throw new InformAiError(`Required summary.json not found.${this.renamedFileHint(filePath)}${this.archivedSummaryHint(filePath, retryCommand)}\\n\\n` + `${this.summaryJsonSchemaHint(filePath, expectedMainAgentInstructions)}\\n\\n` + `Then re-run: ${retryCommand}`);\n }\n const raw = this.parseSummaryJson(fs.readFileSync(filePath, 'utf8'), filePath, expectedMainAgentInstructions, retryCommand);\n if (typeof raw === 'object' && raw !== null && !Array.isArray(raw)) return raw;\n throw new InformAiError(`summary.json must be a JSON object.\\n\\n${this.summaryJsonSchemaHint(filePath, expectedMainAgentInstructions)}` + `\\n\\nThen re-run: ${retryCommand}`);\n }\n\n // webpieces-disable no-any-unknown -- AI-authored JSON boundary is validated before use\n private validateMainAgentInstructions(\n // webpieces-disable no-any-unknown -- opaque parsed JSON; only tested for key presence below\n raw: Record<string, unknown>,\n expected: string,\n errors: string[],\n ): string {\n const actual = typeof raw['main_agent_instructions'] === 'string' ? (raw['main_agent_instructions'] as string).trim() : '';\n if (expected !== '' && actual !== expected) errors.push('\"main_agent_instructions\" must exactly preserve the single-round instructions printed by stage ②.');\n return actual;\n }\n\n /**\n * The checklists that still OWE a verdict: no review-round<N>-<id>.json at all, a malformed one, or one whose\n * verdict is an un-overridden FAIL. This is the set every message lists — a checklist already PASSed or\n * OVERRIDDEN on this branch is deliberately NOT re-listed, because re-instructing it invites a redundant\n * second run and reads as though the earlier verdict did not count.\n */\n pendingChecklists(required: readonly RequiredChecklist[], results: readonly ChecklistResult[]): RequiredChecklist[] {\n return required.filter((req: RequiredChecklist): boolean => {\n const status = this.resolveVerdict(req, results).status;\n // CK_WARN must be listed here beside PASS/OVERRIDDEN. A yellow verdict SHIPS — leaving it out\n // would mark the checklist owed forever, so `outstanding` never empties and the PR is refused\n // permanently no matter how many times the reviewer runs.\n return status !== CK_PASS && status !== CK_WARN && status !== CK_OVERRIDDEN && status !== CK_ORANGE_FIXED;\n });\n }\n\n /**\n * The checklists whose latest verdict is ORANGE with no recorded author fix (issue #1053): a final-round\n * must-fix. A strict subset of {@link pendingChecklists}, split out because its cure is neither a\n * reviewer nor an override: the author fixes the code and records it with `wp-write-review-fixes`.\n */\n orangeChecklists(required: readonly RequiredChecklist[], results: readonly ChecklistResult[]): RequiredChecklist[] {\n return required.filter((req: RequiredChecklist): boolean => this.resolveVerdict(req, results).status === CK_ORANGE);\n }\n\n /**\n * THE renderer for \"this final-round reviewer marked ORANGE\": the finding verbatim, then the ONE way past\n * it. There is no re-review to ask for: the round cap is spent, and an orange is the reviewer saying so.\n */\n orangeError(req: RequiredChecklist, verdict: ChecklistVerdict): string {\n const finding = `${verdict.detail.split('\\n').join('\\n ')}\\n`;\n return `Checklist \"${req.id}\" is ORANGE — a final-round MUST-FIX that is never re-reviewed. The reviewer (${req.reviewer.agentName}) wrote:\\n `\n + finding\n + ' Fix it in the code, best effort, and commit the fix. Then record it with pnpm wp-write-review-fixes\\n'\n + ` (one response {checklistId: \"${req.id}\", resolution, files}) and re-run. Do NOT spawn a reviewer for it:\\n`\n + ' that was the last review round, and no further verdict can be recorded.\\n';\n }\n\n /**\n * The OPTIONAL checklists (`required: false`) that matched the diff but have no verdict file at all.\n *\n * This is the ONE set that separates \"nobody ran it\" from \"it failed\", and the distinction is the whole\n * feature: an optional checklist with no verdict was legitimately not run — the human declined it — so\n * it must NOT block. An optional checklist with a RED verdict is not in\n * here (it resolves to CK_FAIL) and blocks exactly like a required one: choosing to run a reviewer and\n * then ignoring its answer would make the whole thing theater.\n *\n * A strict subset of {@link pendingChecklists}, computed here rather than at each call site so the\n * command that gates and the dashboard that reports cannot disagree about which checklists were skipped.\n */\n optionalWithoutVerdict(required: readonly RequiredChecklist[], results: readonly ChecklistResult[]): RequiredChecklist[] {\n return required.filter((req: RequiredChecklist): boolean => !req.required && this.resolveVerdict(req, results).status === CK_MISSING);\n }\n\n /**\n * The checklists that REFUSED: a reviewer ran, judged the change, and said no (CK_FAIL — status red with\n * no override). A strict subset of {@link pendingChecklists}, split out because it demands a completely\n * different action from the reader.\n *\n * Public so every command agrees on the set. When \"refused\" was computed ad hoc, a refusal and a\n * never-ran reviewer landed in one bucket and produced one message — \"you MUST run these N reviewer\n * subagent(s)\" — handed to an AI, which obediently re-spawned a reviewer that had already answered. It\n * refused again for the same reason, and the loop cost a full subagent run per pass while the reviewer's\n * actual finding was never shown to anyone. A refusal is a RESULT, not a missing step.\n */\n refusedChecklists(required: readonly RequiredChecklist[], results: readonly ChecklistResult[]): RequiredChecklist[] {\n return required.filter((req: RequiredChecklist): boolean => this.resolveVerdict(req, results).status === CK_FAIL);\n }\n\n /**\n * THE renderer for \"this reviewer refused\" — one wording, wherever the refusal surfaces. It exists as a\n * method because the text was previously inlined in {@link requiredChecklistErrors}, reachable only\n * through summary.json validation, while the command layer refused earlier with its own generic message.\n * Two messages for one event is how the useful one became unreachable; there is now exactly one.\n *\n * It always quotes the reviewer's own `output` verbatim: the finding is the whole point, and an error\n * that names a checklist without saying what it objected to gives the reader nothing to fix.\n *\n * IT NAMES THE WRITER, which is the half that was missing. The old text said WHAT to write (\"set a\n * non-empty override\") and WHERE, but never WHO MAY — so the only reachable move was an agent editing a\n * reviewer's verdict file in place, which the harness denies, which is how a human ended up hand-editing\n * JSON. The ship-anyway route is now a SEPARATE file the coordinating agent may write, and the command\n * that writes it is printed ready to run. See {@link ChecklistOverrideService.writerRule}.\n *\n * A red verdict is never moved or deleted (issue #1053): the next round's verdict is a NEW file,\n * `review-round<N+1>-<id>.json`, and the gate reads the highest round, so the refusal stays on disk as the\n * record of what was found.\n */\n refusalError(req: RequiredChecklist, verdict: ChecklistVerdict, summaryJsonFilePath: string): string {\n const finding = `${verdict.detail.split('\\n').join('\\n ')}\\n`;\n const head = `Checklist \"${req.id}\" FAILED review (status:\"${VERDICT_RED}\"). The reviewer (${req.reviewer.agentName}) wrote:\\n ` + finding;\n return head + ' Fix it, commit the fix, record it with pnpm wp-write-review-fixes, then re-run pnpm wp-review-upsert-pr.\\n'\n + this.overrideRoute(req, summaryJsonFilePath);\n }\n\n /**\n * The ship-anyway paragraph: who may authorize, and the exact command that records it.\n *\n * Its own method because every refusal surface must say the identical thing about who may write an\n * override. A second copy of this paragraph is precisely how the previous one drifted into naming a\n * command that had since been deleted.\n */\n private overrideRoute(req: RequiredChecklist, summaryJsonFilePath: string): string {\n return (\n ` To SHIP ANYWAY a human must decide it, and the decision is recorded in its own file — ` +\n `${this.overrides.overrideFileName(req.id)}, never inside the reviewer's verdict.\\n` +\n ` ${this.overrides.writerRule()}\\n` +\n ' Run exactly this, replacing only the \"reason\" with what the human actually said:\\n\\n' +\n `${this.overrides.writeCommand(summaryJsonFilePath, req.id)}\\n`\n );\n }\n\n // Read the LIVE verdict per required checklist: its highest-round `review-round<N>-<id>.json` beside\n // summary.json (issue #1053). A checklist with no verdict file is simply absent from the result (→ MISSING);\n // a malformed one is skipped. The id is matched exactly (see latestVerdictRound), so neither the author's\n // `review-round<N>-fixes.json` nor a provenance file can ever resolve as a verdict.\n loadChecklistResults(summaryJsonFilePath: string, required: readonly RequiredChecklist[]): ChecklistResult[] {\n const results: ChecklistResult[] = [];\n for (const req of required) {\n const round = this.latestVerdictRound(summaryJsonFilePath, req.id);\n if (round === 0) continue;\n const p = this.checklistResultPath(summaryJsonFilePath, req.id, round);\n // The human's authorization is read from its OWN file beside the verdict, in the same pass, so\n // resolveVerdict never touches disk and every command resolves one outcome from one read.\n const parsed = this.parseChecklistResult(p, req.id, this.overrides.load(summaryJsonFilePath, req.id));\n if (parsed === null) continue;\n parsed.round = round;\n results.push(parsed);\n }\n return results;\n }\n\n // Resolve ONE checklist's verdict from its review-round<N>-<id>.json. Central so summary.json enforcement AND the\n // finish-command dashboard agree on the outcome. `problem` is checked FIRST: a file whose verdict cannot\n // be read must not fall through to any shipping outcome.\n resolveVerdict(req: RequiredChecklist, results: readonly ChecklistResult[]): ChecklistVerdict {\n const result = results.find((r: ChecklistResult): boolean => r.id === req.id);\n if (!result) return new ChecklistVerdict(req.id, CK_MISSING, '');\n if (result.problem !== '') return new ChecklistVerdict(req.id, CK_BAD_FORMAT, result.problem);\n if (result.status === VERDICT_GREEN) return new ChecklistVerdict(req.id, CK_PASS, result.output);\n if (result.status === VERDICT_YELLOW) return new ChecklistVerdict(req.id, CK_WARN, result.output);\n // An ORANGE ships once the author has recorded a fix for it, and ONLY that way: it is the final\n // round's must-fix, so there is no re-review to wait for and no override to hunt (issue #1053).\n if (result.status === VERDICT_ORANGE) {\n return result.remediation !== ''\n ? new ChecklistVerdict(req.id, CK_ORANGE_FIXED, result.remediation)\n : new ChecklistVerdict(req.id, CK_ORANGE, result.output);\n }\n const override = result.override;\n // A malformed authorization is reported as a FORMAT problem, never treated as one: an override with\n // no stated reason authorizes nothing, and silently ignoring it would tell the reader their decision\n // was not recorded without ever saying why.\n if (override !== null && override.problem !== '') return new ChecklistVerdict(req.id, CK_BAD_FORMAT, override.problem);\n if (override !== null) return new ChecklistVerdict(req.id, CK_OVERRIDDEN, this.overrides.detail(override));\n return new ChecklistVerdict(req.id, CK_FAIL, result.output);\n }\n\n /**\n * One loud complaint per checklist whose verdict file EXISTS but cannot be read as a verdict — almost\n * always one still using the removed `success` field. Public and separate from\n * {@link requiredChecklistErrors} because `wp-finish-upsert-pr` refuses on missing reviewers BEFORE it\n * parses summary.json: without this, a legacy file would surface as the generic \"no verdict yet\" block\n * and the AI would re-run a reviewer that already ran instead of fixing four characters of JSON.\n */\n checklistFormatErrors(required: readonly RequiredChecklist[], results: readonly ChecklistResult[]): string[] {\n const errors: string[] = [];\n for (const req of required) {\n const verdict = this.resolveVerdict(req, results);\n if (verdict.status === CK_BAD_FORMAT) errors.push(verdict.detail);\n }\n return errors;\n }\n\n // Every matched checklist whose verdict is FAIL (reviewed, found a problem, no override) or MISSING (no\n // review-round<N>-<id>.json written) → one error each, printing the reviewer's `output` verbatim.\n private requiredChecklistErrors(required: readonly RequiredChecklist[], results: readonly ChecklistResult[], filePath: string): string[] {\n // Format complaints come from the ONE renderer, so wp-review-upsert-pr and wp-finish word them identically.\n const errors: string[] = this.checklistFormatErrors(required, results);\n for (const req of required) {\n const verdict = this.resolveVerdict(req, results);\n // CK_WARN ('yellow' — passed with concerns) is deliberately absent from this chain: it SHIPS.\n // The concern still reaches the PR, published in the checklist comment. Do not \"fix\" this.\n if (verdict.status === CK_FAIL) {\n // Through the ONE renderer, so this path and the command layer's refusal say the same thing.\n errors.push(this.refusalError(req, verdict, filePath));\n } else if (verdict.status === CK_ORANGE) {\n errors.push(this.orangeError(req, verdict));\n } else if (verdict.status === CK_MISSING) {\n // An OPTIONAL checklist with no verdict was legitimately not run — the human was offered it\n // and declined. Demanding it here would make\n // `required: false` mean nothing. Note the CK_FAIL branch above deliberately has no such\n // exemption: once an optional reviewer RUNS, its refusal counts.\n if (!req.required) continue;\n const doc = req.doc.trim() !== '' ? ` Read: ${req.doc}.` : '';\n errors.push(`Checklist \"${req.id}\" MATCHED this diff but has no verdict. Spawn the \"${req.reviewer.agentName}\" subagent to review it; ` + `IT submits the verdict with ${this.submitCommand(req.id)} — nobody writes ${this.checklistFileName(req.id)} by hand.${doc}`);\n }\n }\n return errors;\n }\n\n private checklistFileName(checklistId: string): string {\n return `${VERDICT_FILE_PREFIX}<N>-${checklistId}.json`;\n }\n\n /**\n * THE renderer for a reviewer's verdict schema — with the reviewer's own `id` already filled in.\n *\n * There is one because a verdict schema that lives anywhere a human maintains it goes stale, and a\n * reviewer follows the stale copy. That is not a hypothetical: when `success` was replaced by the\n * tri-state `status`, hand-written `.claude/agents/*.md` files kept documenting `success`, and a real\n * PR had to carry \"the verdict format in your own agent .md file is OUT OF DATE\" in the spawn prompt to\n * work around it. Every printed copy — the stage-② roster, the generated per-reviewer instructions\n * file, and the complaint raised against a malformed verdict — now comes from here. It ends with the\n * ONE way a verdict is submitted (`wp-write-review`, issue #863), never a file path to write.\n */\n renderVerdictSchema(id: string, indent = ' '): string {\n return new VerdictSchemaRenderer().render(id, indent);\n }\n\n /** THE command that submits one checklist's verdict (issue #863) — see VerdictSchemaRenderer. */\n submitCommand(id: string): string {\n return new VerdictSchemaRenderer().submitCommand(id);\n }\n\n // Unreadable objects retain their format complaint; absent/unparseable verdicts return null.\n // webpieces-disable no-any-unknown -- opaque parsed JSON, narrowed field-by-field\n private parseChecklistResult(filePath: string, id: string, override: ChecklistOverride | null): ChecklistResult | null {\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: an unparseable per-checklist file is skipped, not fatal\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n // webpieces-disable no-any-unknown -- parsed JSON is opaque until narrowed below\n const raw = JSON.parse(fs.readFileSync(filePath, 'utf8')) as Record<string, unknown>;\n if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) return null;\n const output = typeof raw['output'] === 'string' ? (raw['output'] as string) : '';\n const status = typeof raw['status'] === 'string' ? (raw['status'] as string).trim().toLowerCase() : '';\n const agent = typeof raw['agent'] === 'string' ? raw['agent'].trim() : '';\n const model = typeof raw['model'] === 'string' ? raw['model'].trim() : '';\n const identityProblem = agent === '' || model === '' ? 'Both \"agent\" and \"model\" must be non-empty strings; use \"unknown\" when unavailable.' : '';\n return new ChecklistResult(agent, model, id, status, output, override, this.verdictProblem(filePath, id, status, raw) || identityProblem);\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n return null;\n }\n }\n\n /**\n * '' when the verdict can be READ. Otherwise the complaint to show the AI verbatim.\n *\n * The MOVED `override` field is checked FIRST, ahead of `status`, because it is the more specific fact: a\n * file carrying it was written against a schema that no longer exists, and a reader told only \"status\n * must be green|yellow|red\" would fix the wrong thing. It is rejected even when EMPTY — an accepted shape\n * is never migrated, and `\"override\": \"\"` sitting in a reviewer's file is the copy that teaches the next\n * reviewer the field still exists.\n *\n * The legacy-`success` case keeps its OWN message for the same reason: `success` was removed outright\n * (no compatibility mode), and a reviewer cannot tell a wrong value from a field that no longer exists.\n */\n private verdictProblem(\n filePath: string,\n id: string,\n status: string,\n // webpieces-disable-next-line no-any-unknown -- opaque parsed JSON; only tested for key presence here\n raw: Record<string, unknown>,\n ): string {\n // The ONE renderer — see renderVerdictSchema. A second copy here is what let the old `success` shape\n // survive in print after it was removed from the parser.\n const shape = this.renderVerdictSchema(id);\n if ('override' in raw) {\n return (\n `Checklist \"${id}\" wrote its verdict with the MOVED \"override\" field. A ship-anyway ` +\n \"authorization is no longer part of a reviewer's verdict: it MOVED to its own file, \" +\n `${this.overrides.overrideFileName(id)}, which only the coordinating agent writes and only on a ` +\n 'human\\'s in-session instruction. There is no compatibility mode — DELETE the \"override\" key from ' +\n `${filePath} by resubmitting it:\\n${shape}`\n );\n }\n // webpieces-disable no-any-unknown -- comparing against the readonly literal tuple of valid colors\n if ((VERDICT_STATUSES as readonly string[]).includes(status)) return '';\n if ('success' in raw) {\n return `Checklist \"${id}\" wrote its verdict with the REMOVED \"success\" field. It is now a color ` + `\"status\" — there is no compatibility mode. Resubmit it as:\\n${shape}`;\n }\n return `Checklist \"${id}\" wrote a verdict with no valid \"status\" (got ${JSON.stringify(status)}). ` + `It must be exactly one of ${VERDICT_STATUSES.join(', ')}:\\n${shape}`;\n }\n\n // webpieces-disable no-any-unknown -- opaque parsed JSON value, narrowed to string[] here\n private asStringArray(value: unknown): string[] {\n if (!Array.isArray(value)) return [];\n // webpieces-disable no-any-unknown -- element of an opaque JSON array, narrowed by the type guard\n return value.filter((v: unknown): v is string => typeof v === 'string');\n }\n\n // Parse opaque AI-authored JSON, converting a SyntaxError into a readable InformAiError.\n // webpieces-disable no-any-unknown -- returns the opaque parsed object; loadSummaryJson narrows each field\n private parseSummaryJson(raw: string, filePath: string, expectedMainAgentInstructions = '', retryCommand = 'pnpm wp-finish-upsert-pr'): Record<string, unknown> {\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: convert JSON.parse SyntaxError to an InformAiError for the AI\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n // webpieces-disable no-any-unknown -- parsed JSON is opaque until narrowed by the caller\n return JSON.parse(raw) as Record<string, unknown>;\n } catch (err: unknown) {\n const error = toError(err);\n throw new InformAiError(`summary.json is not valid JSON (${error.message}).\\n\\n` + `${this.summaryJsonSchemaHint(filePath, expectedMainAgentInstructions)}\\n\\n` + `Then re-run: ${retryCommand}`);\n }\n }\n}\n\n// Temporary migration delegators to ReviewJsonService — removed once consumers inject it.\nconst reviewJsonSvc = new ReviewJsonService();\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to ReviewJsonService; removed once consumers inject it\nexport function prDirFor(repoRoot: string, featureName: string): string {\n return reviewJsonSvc.prDirFor(repoRoot, featureName);\n}\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to ReviewJsonService; removed once consumers inject it\nexport function summaryJsonPath(repoRoot: string, featureName: string): string {\n return reviewJsonSvc.summaryJsonPath(repoRoot, featureName);\n}\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to ReviewJsonService; removed once consumers inject it\nexport function summaryJsonSchemaHint(filePath: string, mainAgentInstructions = ''): string {\n return reviewJsonSvc.summaryJsonSchemaHint(filePath, mainAgentInstructions);\n}\n"]}
1
+ {"version":3,"file":"review-json.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/review-json.ts"],"names":[],"mappings":";;;AAirBA,4BAEC;AAGD,0CAEC;AAGD,sDAEC;;AA7rBD,+CAAyB;AACzB,mDAA6B;AAC7B,mCAAoC;AACpC,yCAA2D;AAC3D,8DAA0D;AAC1D,8DAAuE;AACvE,8DAA0D;AAC1D,iEAA6D;AAC7D,iFAA2E;AAC3E,uEAAkE;AAClE,6DAA6G;AAwBpG,kGAxBA,sCAAiB,OAwBA;AAAE,yGAxBA,6CAAwB,OAwBA;AAAE,yGAxBA,6CAAwB,OAwBA;AAvB9E,yDAoB4B;AAKxB,8FAxBA,gCAAa,OAwBA;AACb,+FAxBA,iCAAc,OAwBA;AACd,+FAxBA,iCAAc,OAwBA;AACd,4FAxBA,8BAAW,OAwBA;AACX,iGAxBA,mCAAgB,OAwBA;AAChB,gGAxBA,kCAAe,OAwBA;AACf,kGAxBA,oCAAiB,OAwBA;AACjB,uGAxBA,yCAAsB,OAwBA;AACtB,0FAxBA,4BAAS,OAwBA;AACT,wFAxBA,0BAAO,OAwBA;AACP,wFAxBA,0BAAO,OAwBA;AACP,8FAxBA,gCAAa,OAwBA;AACb,gGAxBA,kCAAe,OAwBA;AACf,0FAxBA,4BAAS,OAwBA;AACT,wFAxBA,0BAAO,OAwBA;AACP,2FAxBA,6BAAU,OAwBA;AACV,8FAxBA,gCAAa,OAwBA;AACb,iGAxBA,mCAAgB,OAwBA;AAChB,0FAxBA,4BAAS,OAwBA;AAGb,MAAM,WAAW,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAU,CAAC;AACxD,MAAM,eAAe,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AC,qBAAqB,CAAC,QAAQ,EAAE,6BAA6B,CAAC,MAAM,GAAG,gBAAgB,YAAY,EAAE,CAAC,CAAC;QACtM,CAAC;IACL,CAAC;CACJ,CAAA;AA5lBY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGR,6BAAY;QACT,6CAAwB;GAH/C,iBAAiB,CA4lB7B;AAED,0FAA0F;AAC1F,MAAM,aAAa,GAAG,IAAI,iBAAiB,EAAE,CAAC;AAE9C,wIAAwI;AACxI,SAAgB,QAAQ,CAAC,QAAgB,EAAE,WAAmB;IAC1D,OAAO,aAAa,CAAC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;AACzD,CAAC;AAED,wIAAwI;AACxI,SAAgB,eAAe,CAAC,QAAgB,EAAE,WAAmB;IACjE,OAAO,aAAa,CAAC,eAAe,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;AAChE,CAAC;AAED,wIAAwI;AACxI,SAAgB,qBAAqB,CAAC,QAAgB,EAAE,qBAAqB,GAAG,EAAE;IAC9E,OAAO,aAAa,CAAC,qBAAqB,CAAC,QAAQ,EAAE,qBAAqB,CAAC,CAAC;AAChF,CAAC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { randomUUID } from 'crypto';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { PR_REVIEW_DIR } from '@webpieces/tooling-common';\nimport { DotWebpieces, dotWebpieces } from '@webpieces/tooling-common';\nimport { InformAiError } from '@webpieces/tooling-common';\nimport { toError } from '@webpieces/tooling-common/to-error';\nimport { SummaryJsonSchemaRenderer } from './summary-json-schema-renderer';\nimport { VerdictSchemaRenderer } from './verdict-schema-renderer';\nimport { ChecklistOverride, ChecklistOverrideService, checklistOverrideService } from './checklist-override';\nimport {\n VERDICT_GREEN,\n VERDICT_YELLOW,\n VERDICT_ORANGE,\n VERDICT_RED,\n VERDICT_STATUSES,\n ChecklistResult,\n RequiredChecklist,\n ChecklistReviewContext,\n PrSummary,\n CK_PASS,\n CK_WARN,\n CK_OVERRIDDEN,\n CK_ORANGE_FIXED,\n CK_ORANGE,\n CK_FAIL,\n CK_MISSING,\n CK_BAD_FORMAT,\n ChecklistVerdict,\n PrContext,\n} from './review-json-data';\n\n// Re-exported so review-json.ts stays the single import site for the review vocabulary.\nexport { ChecklistOverride, ChecklistOverrideService, checklistOverrideService };\nexport {\n VERDICT_GREEN,\n VERDICT_YELLOW,\n VERDICT_ORANGE,\n VERDICT_RED,\n VERDICT_STATUSES,\n ChecklistResult,\n RequiredChecklist,\n ChecklistReviewContext,\n PrSummary,\n CK_PASS,\n CK_WARN,\n CK_OVERRIDDEN,\n CK_ORANGE_FIXED,\n CK_ORANGE,\n CK_FAIL,\n CK_MISSING,\n CK_BAD_FORMAT,\n ChecklistVerdict,\n PrContext,\n};\n\nconst RISK_LEVELS = ['green', 'yellow', 'red'] as const;\nconst EMOJI_FOR_LEVEL: Record<string, string> = { green: '🟢', yellow: '🟡', red: '🔴' };\n\n// Where `wp-finish-upsert-pr` retires the summary.json it just consumed, and the note it stamps on the way.\n// The key sorts first in the written JSON because it is written first — an AI that opens the file to see\n// whether it can reuse the summary reads what the file IS before it reads a title it might be tempted to keep.\nconst OLD_SUMMARY_FILE = 'old-summary.json';\nconst ARCHIVE_NOTE_KEY = '_ARCHIVED_AUDIT_ONLY';\nconst ARCHIVE_NOTE =\n 'ARCHIVE — this is the PR summary from the PREVIOUS wp-finish-upsert-pr run on this branch, kept for audit ' +\n 'purposes only. It is NOT the summary for a new round: it describes the code as of the last PR ' +\n 'update, which has since moved. If you are updating the PR again, write a FRESH summary.json at the path ' +\n \"pnpm wp-review-upsert-pr prints; do not copy this file's title, summary or risk level forward without \" +\n 're-deciding each one. Overwritten by every finish, so only the most recent summary is ever here.';\n\n// A verdict file is named by its ROUND (issue #1053): `review-round<N>-<id>.json`, one per round, never\n// overwritten. The id is matched EXACTLY (escaped), so `review-round2-fixes.json` (the author's recorded\n// fixes for round 2) and a provenance file beside a verdict can never be read as a verdict.\nconst VERDICT_FILE_PREFIX = 'review-round';\n\n/** Locates + loads/validates the AI-authored summary.json. `@injectable(bindingScopeValues.Singleton)` so it's drawn in the design. */\n@injectable(bindingScopeValues.Singleton)\nexport class ReviewJsonService {\n constructor(\n private readonly dotDir: DotWebpieces = dotWebpieces,\n private readonly overrides: ChecklistOverrideService = checklistOverrideService,\n ) {}\n\n // The per-feature PR working dir: `<worktree>/.webpieces-logs/pr-review/<feature>`. AI-WRITABLE scope,\n // not local() — an agent AUTHORS summary.json here, and each reviewer subagent authors its own\n // review-round<N>-<id>.json beside it. A worktree-isolated agent's Write is refused for any path under the\n // shared checkout, which is where local() puts this, so local() made both files unwritable by the\n // very agents the flow instructs to write them. See DotWebpieces.aiWritable() for the full account.\n prDirFor(repoRoot: string, featureName: string): string {\n return this.dotDir.aiWritableFile(repoRoot, PR_REVIEW_DIR, featureName);\n }\n\n // Absolute path of the summary.json for a feature — beside pr-body.md, keyed by branch name.\n summaryJsonPath(repoRoot: string, featureName: string): string {\n return path.join(this.prDirFor(repoRoot, featureName), 'summary.json');\n }\n\n // Absolute path of the pr-context.json for a feature (the diff base/head + changed files).\n prContextPath(repoRoot: string, featureName: string): string {\n return path.join(this.prDirFor(repoRoot, featureName), 'pr-context.json');\n }\n\n // Where a consumed summary.json is archived to, beside it. Always the SAME path — it holds the last\n // summary and only the last one, so it can never be mistaken for a series that means something.\n oldSummaryJsonPath(summaryJsonFilePath: string): string {\n return path.join(path.dirname(summaryJsonFilePath), OLD_SUMMARY_FILE);\n }\n\n /** Keep the active PR intent available for updates; each publication gets an immutable audit copy. */\n snapshotSummaryJson(summaryJsonFilePath: string): string {\n const dir = path.join(path.dirname(summaryJsonFilePath), 'published-summaries');\n fs.mkdirSync(dir, { recursive: true });\n const snapshot = path.join(dir, `${randomUUID()}.json`);\n const raw = fs.readFileSync(summaryJsonFilePath, 'utf8');\n const note =\n 'AUDIT ONLY — the summary used by this publication. The active PR intent is in ' +\n 'summary.json beside published-summaries. Refresh the active file when intent, issue, title or risk changes.';\n fs.writeFileSync(snapshot, this.archivedBody(raw, note), { flag: 'wx' });\n return snapshot;\n }\n\n /**\n * Retire the PR summary `wp-finish-upsert-pr` just used: move summary.json to old-summary.json, stamped\n * with a note saying what it is. Returns the archive path, or '' when there was nothing to archive.\n *\n * The point is the MOVE, not the copy. summary.json left in place after a PR is posted is a live-looking\n * file describing a PR update that already happened, and the next run of stage ② on this branch finds it\n * sitting there — so a reviewer subagent that judges the PR's stated intent (its title, summary or risk\n * level) can read the previous run's summary and return GREEN against a title that no longer exists.\n * Nothing in the verdict distinguishes that from a real pass. Moving it means the only way to reach\n * finish again is to write a fresh one, and {@link loadSummaryJson} points at the archive when it is\n * missing so the archive reads as an audit trail rather than as a lost file.\n *\n * Called only after the PR is actually up: a finish that failed before publishing must stay re-runnable.\n */\n archiveSummaryJson(summaryJsonFilePath: string): string {\n if (!fs.existsSync(summaryJsonFilePath)) return '';\n const archivePath = this.oldSummaryJsonPath(summaryJsonFilePath);\n const raw = fs.readFileSync(summaryJsonFilePath, 'utf8');\n fs.writeFileSync(archivePath, this.archivedBody(raw, ARCHIVE_NOTE));\n fs.rmSync(summaryJsonFilePath);\n return archivePath;\n }\n\n /**\n * The archived bytes: the original JSON with an AUDIT-ONLY note as its FIRST key, so anything that opens\n * the file — human or AI — reads what it is before it reads any of its content.\n *\n * Falls back to the raw bytes when they do not parse. `loadSummaryJson` has already accepted the file, so\n * that is close to impossible, but preserving the original always beats losing it to a stamping failure,\n * since the archive exists precisely to be the record.\n */\n private archivedBody(raw: string, note: string): string {\n const parsed = this.tryParseObject(raw);\n if (parsed === null) return raw;\n // webpieces-disable no-any-unknown -- re-serializing opaque review fields verbatim; only the key ORDER is ours\n const stamped: Record<string, unknown> = {};\n stamped[ARCHIVE_NOTE_KEY] = note;\n for (const key of Object.keys(parsed)) stamped[key] = parsed[key];\n return JSON.stringify(stamped, null, 2) + '\\n';\n }\n\n // webpieces-disable no-any-unknown -- opaque parsed JSON; the caller only re-serializes it\n private tryParseObject(raw: string): Record<string, unknown> | null {\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: unparseable bytes are archived verbatim, never fatal\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n // webpieces-disable no-any-unknown -- parsed JSON is opaque; only its key order is used\n const parsed = JSON.parse(raw) as Record<string, unknown>;\n if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) return null;\n return parsed;\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n return null;\n }\n }\n\n /**\n * Persist the PR's diff context so reviewer subagents can read the changed-file set + the exact base\n * sha. Returns the file path written.\n *\n * ALSO writes an immutable per-stage snapshot under `stages/<stage>.json` when `stage` is given.\n * `pr-context.json` is overwritten by each stage, so by the time anything goes wrong the earlier\n * states are gone — and \"what did the tooling think the diff was at stage ①, vs ②, vs ③?\" is exactly\n * the question you need answered when debugging a review that went sideways. The snapshots make the\n * review system auditable by an AI reviewing IT, which the single mutable file never could.\n */\n writePrContext(repoRoot: string, featureName: string, context: PrContext, stage = ''): string {\n const dir = this.prDirFor(repoRoot, featureName);\n fs.mkdirSync(dir, { recursive: true });\n const body = JSON.stringify(context, null, 2) + '\\n';\n const p = this.prContextPath(repoRoot, featureName);\n fs.writeFileSync(p, body);\n if (stage !== '') {\n const stagesDir = path.join(dir, 'stages');\n fs.mkdirSync(stagesDir, { recursive: true });\n fs.writeFileSync(path.join(stagesDir, `${stage}.json`), body);\n }\n return p;\n }\n\n /**\n * The review context for a feature, recovered from the pr-context.json wp-start-upsert-pr already wrote.\n * Lets wp-finish-upsert-pr's \"you still owe me review-round<N>-<id>.json\" message inline the SAME self-sufficient\n * per-reviewer block start printed, instead of a checklist name and an indirection. Empty when the file\n * is absent or unreadable — the block then just omits those lines.\n */\n reviewContextFor(repoRoot: string, featureName: string): ChecklistReviewContext {\n const p = this.prContextPath(repoRoot, featureName);\n if (!fs.existsSync(p)) return new ChecklistReviewContext();\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: an unreadable context file degrades to fewer printed lines, never a crash\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n // webpieces-disable no-any-unknown -- parsed JSON is opaque until narrowed on the next line\n const raw = JSON.parse(fs.readFileSync(p, 'utf8')) as Record<string, unknown>;\n const base = typeof raw['base'] === 'string' ? (raw['base'] as string) : '';\n // Recover the REPRODUCE command rather than re-deriving it: a context written by an older\n // pr-gate has no diffCommand, and guessing `<base> HEAD` there would resurrect the exact\n // empty-on-a-dirty-tree bug this field exists to kill. Absent ⇒ omit the line entirely.\n const cmd = typeof raw['diffCommand'] === 'string' ? (raw['diffCommand'] as string) : '';\n const diffDir = typeof raw['diffDir'] === 'string' ? (raw['diffDir'] as string) : '';\n const dirty = raw['dirty'] === true;\n return new ChecklistReviewContext(base, p, cmd === '' ? '' : `${cmd} -- <file>`, diffDir, dirty);\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n return new ChecklistReviewContext('', p);\n }\n }\n\n // Copy-paste summary.json schema shared by every command that asks the coordinating AI to write it.\n summaryJsonSchemaHint(filePath: string, mainAgentInstructions = ''): string {\n return new SummaryJsonSchemaRenderer().render(filePath, mainAgentInstructions);\n }\n\n /**\n * The extra line the \"no summary.json\" complaint carries when a PREVIOUS summary was archived here. It\n * turns a bare \"not found\" — which reads as data loss, and invites hunting for the file — into the fact:\n * the last finish consumed it, and the archive is audit material, not a summary to reuse.\n */\n private archivedSummaryHint(filePath: string, retryCommand: string): string {\n const archive = this.oldSummaryJsonPath(filePath);\n if (!fs.existsSync(archive)) return '';\n return `\\nA PREVIOUS PR summary was archived to ${archive} when the last ${retryCommand} consumed it.\\n` + `That file is for AUDIT ONLY — it describes code this branch has since moved past. Write a fresh one:`;\n }\n\n // Names summary.json when the author wrote its OLD name (review.json until #1033 — refused by Claude\n // auto-mode as Self-Approval beside the review-round<N>-<id>.json verdicts). HARD CUT: the stale file is never read.\n private renamedFileHint(filePath: string): string {\n const stale = path.join(path.dirname(filePath), 'review.json');\n if (!fs.existsSync(stale)) return '';\n return `\\n${stale} is IGNORED — the author's file was renamed to summary.json. ` + `Write the same JSON to ${filePath} instead.`;\n }\n\n /**\n * The per-checklist verdict file for ONE round, beside summary.json: `review-round<N>-<id>.json`.\n *\n * Round-numbered (issue #1053) so no round ever overwrites another. The top-level `review-<id>.json` this\n * replaced was overwritten by every submission, and a separate `rounds/<N>/` copy had to be kept in step\n * with it to recover the history: two records of one fact, and the copy was the one an agent could lose.\n */\n checklistResultPath(summaryJsonFilePath: string, checklistId: string, round: number): string {\n return path.join(path.dirname(summaryJsonFilePath), `${VERDICT_FILE_PREFIX}${round}-${checklistId}.json`);\n }\n\n /**\n * The HIGHEST round a verdict was submitted in for one checklist, or 0 when it has none. The live verdict\n * is always that one; every lower round is history. Derived from the files present, so there is no\n * counter to drift from them.\n */\n latestVerdictRound(summaryJsonFilePath: string, checklistId: string): number {\n const dir = path.dirname(summaryJsonFilePath);\n if (!fs.existsSync(dir)) return 0;\n const pattern = new RegExp(`^${VERDICT_FILE_PREFIX}(\\\\d+)-${this.escapeRegExp(checklistId)}\\\\.json$`);\n let latest = 0;\n for (const name of fs.readdirSync(dir)) {\n const match = pattern.exec(name);\n if (match !== null) latest = Math.max(latest, Number(match[1]));\n }\n return latest;\n }\n\n /** The verdict file name with the round left as `<N>`, for messages that name it before a round is known. */\n checklistResultPathTemplate(summaryJsonFilePath: string, checklistId: string): string {\n return path.join(path.dirname(summaryJsonFilePath), this.checklistFileName(checklistId));\n }\n\n /** The live (highest-round) verdict file for one checklist, or '' when none was ever submitted. */\n latestChecklistResultPath(summaryJsonFilePath: string, checklistId: string): string {\n const round = this.latestVerdictRound(summaryJsonFilePath, checklistId);\n return round === 0 ? '' : this.checklistResultPath(summaryJsonFilePath, checklistId, round);\n }\n\n private escapeRegExp(text: string): string {\n return text.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n }\n\n /**\n * Load + validate the AI-authored summary.json. Throws InformAiError (with the schema) when missing,\n * unparseable, or structurally wrong. `required` is the set of checklists the diff matched: every one\n * must have a well-formed, passing (or overridden) review-round<N>-<id>.json or a validation error is raised\n * alongside the usual ones so the AI gets ONE message.\n */\n // webpieces-disable max-lines-new-methods -- one cohesive load+validate pass over the review fields\n loadSummaryJson(\n filePath: string, required: readonly RequiredChecklist[] = [], expectedMainAgentInstructions = '',\n orangeFixes: Record<string, string> = {},\n retryCommand = 'pnpm wp-finish-upsert-pr',\n ): PrSummary {\n const raw = this.readSummaryObject(filePath, expectedMainAgentInstructions, retryCommand);\n const errors: string[] = [];\n for (const field of ['agent', 'model']) {\n if (typeof raw[field] !== 'string' || raw[field].trim() === '') {\n errors.push(`\"${field}\" must be a non-empty string; use \"unknown\" when unavailable.`);\n }\n }\n const riskScore = raw['riskScore'];\n if (typeof riskScore !== 'number' || !Number.isFinite(riskScore) || riskScore < 0 || riskScore > 100) {\n errors.push(`\"riskScore\" must be a number 0–100, got ${JSON.stringify(riskScore)}.`);\n }\n const riskLevel = raw['riskLevel'];\n if (typeof riskLevel !== 'string' || !RISK_LEVELS.includes(riskLevel as (typeof RISK_LEVELS)[number])) {\n errors.push(`\"riskLevel\" must be one of: ${RISK_LEVELS.join(', ')}.`);\n }\n const title = typeof raw['title'] === 'string' ? (raw['title'] as string).trim() : '';\n if (title === '') {\n errors.push('\"title\" must be a non-empty, imperative PR title describing the change (no branch names).');\n }\n const mainAgentInstructions = this.validateMainAgentInstructions(raw, expectedMainAgentInstructions, errors);\n\n const results = this.loadChecklistResults(filePath, required);\n for (const result of results) result.remediation = orangeFixes[result.id] ?? '';\n for (const err of this.requiredChecklistErrors(required, results, filePath)) errors.push(err);\n\n this.assertValidSummary(errors, filePath, expectedMainAgentInstructions, retryCommand);\n\n const level = riskLevel as string;\n const emoji = typeof raw['riskEmoji'] === 'string' && raw['riskEmoji'] !== '' ? (raw['riskEmoji'] as string) : (EMOJI_FOR_LEVEL[level] ?? '🟡');\n const summary = typeof raw['summary'] === 'string' ? (raw['summary'] as string) : '';\n\n return new PrSummary((raw['agent'] as string).trim(), (raw['model'] as string).trim(), title, riskScore as number, level, emoji, summary, this.asStringArray(raw['violations']), this.asStringArray(raw['risks']), this.asStringArray(raw['filesToReview']), results, mainAgentInstructions);\n }\n\n private assertValidSummary(errors: string[], filePath: string, expectedMainAgentInstructions: string, retryCommand: string): void {\n if (errors.length === 0) return;\n throw new InformAiError(`summary.json has ${errors.length} error(s) — fix ALL, then re-run ${retryCommand}:\\n\\n` + errors.map((e: string): string => ` • ${e}`).join('\\n') + `\\n\\n${this.summaryJsonSchemaHint(filePath, expectedMainAgentInstructions)}`);\n }\n\n /** Load the raw object and render every parse/shape error for the command that called us. */\n private readSummaryObject(\n filePath: string,\n expectedMainAgentInstructions: string,\n retryCommand: string,\n // webpieces-disable-next-line no-any-unknown -- opaque JSON is narrowed field-by-field by loadSummaryJson\n ): Record<string, unknown> {\n if (!fs.existsSync(filePath)) {\n throw new InformAiError(`Required summary.json not found.${this.renamedFileHint(filePath)}${this.archivedSummaryHint(filePath, retryCommand)}\\n\\n` + `${this.summaryJsonSchemaHint(filePath, expectedMainAgentInstructions)}\\n\\n` + `Then re-run: ${retryCommand}`);\n }\n const raw = this.parseSummaryJson(fs.readFileSync(filePath, 'utf8'), filePath, expectedMainAgentInstructions, retryCommand);\n if (typeof raw === 'object' && raw !== null && !Array.isArray(raw)) return raw;\n throw new InformAiError(`summary.json must be a JSON object.\\n\\n${this.summaryJsonSchemaHint(filePath, expectedMainAgentInstructions)}` + `\\n\\nThen re-run: ${retryCommand}`);\n }\n\n // webpieces-disable no-any-unknown -- AI-authored JSON boundary is validated before use\n private validateMainAgentInstructions(\n // webpieces-disable no-any-unknown -- opaque parsed JSON; only tested for key presence below\n raw: Record<string, unknown>,\n expected: string,\n errors: string[],\n ): string {\n const actual = typeof raw['main_agent_instructions'] === 'string' ? (raw['main_agent_instructions'] as string).trim() : '';\n if (expected !== '' && actual !== expected) errors.push('\"main_agent_instructions\" must exactly preserve the single-round instructions printed by stage ②.');\n return actual;\n }\n\n /**\n * The checklists that still OWE a verdict: no review-round<N>-<id>.json at all, a malformed one, or one whose\n * verdict is an un-overridden FAIL. This is the set every message lists — a checklist already PASSed or\n * OVERRIDDEN on this branch is deliberately NOT re-listed, because re-instructing it invites a redundant\n * second run and reads as though the earlier verdict did not count.\n */\n pendingChecklists(required: readonly RequiredChecklist[], results: readonly ChecklistResult[]): RequiredChecklist[] {\n return required.filter((req: RequiredChecklist): boolean => {\n const status = this.resolveVerdict(req, results).status;\n // CK_WARN must be listed here beside PASS/OVERRIDDEN. A yellow verdict SHIPS — leaving it out\n // would mark the checklist owed forever, so `outstanding` never empties and the PR is refused\n // permanently no matter how many times the reviewer runs.\n return status !== CK_PASS && status !== CK_WARN && status !== CK_OVERRIDDEN && status !== CK_ORANGE_FIXED;\n });\n }\n\n /**\n * The checklists whose latest verdict is ORANGE with no recorded author fix (issue #1053): a final-round\n * must-fix. A strict subset of {@link pendingChecklists}, split out because its cure is neither a\n * reviewer nor an override: the author fixes the code and records it with `wp-write-review-fixes`.\n */\n orangeChecklists(required: readonly RequiredChecklist[], results: readonly ChecklistResult[]): RequiredChecklist[] {\n return required.filter((req: RequiredChecklist): boolean => this.resolveVerdict(req, results).status === CK_ORANGE);\n }\n\n /**\n * THE renderer for \"this final-round reviewer marked ORANGE\": the finding verbatim, then the ONE way past\n * it. There is no re-review to ask for: the round cap is spent, and an orange is the reviewer saying so.\n */\n orangeError(req: RequiredChecklist, verdict: ChecklistVerdict): string {\n const finding = `${verdict.detail.split('\\n').join('\\n ')}\\n`;\n return `Checklist \"${req.id}\" is ORANGE — a final-round MUST-FIX that is never re-reviewed. The reviewer (${req.reviewer.agentName}) wrote:\\n `\n + finding\n + ' Fix it in the code, best effort, and commit the fix. Then record it with pnpm wp-write-review-fixes\\n'\n + ` (one response {checklistId: \"${req.id}\", resolution, files}) and re-run. Do NOT spawn a reviewer for it:\\n`\n + ' that was the last review round, and no further verdict can be recorded.\\n';\n }\n\n /**\n * The OPTIONAL checklists (`required: false`) that matched the diff but have no verdict file at all.\n *\n * This is the ONE set that separates \"nobody ran it\" from \"it failed\", and the distinction is the whole\n * feature: an optional checklist with no verdict was legitimately not run — the human declined it — so\n * it must NOT block. An optional checklist with a RED verdict is not in\n * here (it resolves to CK_FAIL) and blocks exactly like a required one: choosing to run a reviewer and\n * then ignoring its answer would make the whole thing theater.\n *\n * A strict subset of {@link pendingChecklists}, computed here rather than at each call site so the\n * command that gates and the dashboard that reports cannot disagree about which checklists were skipped.\n */\n optionalWithoutVerdict(required: readonly RequiredChecklist[], results: readonly ChecklistResult[]): RequiredChecklist[] {\n return required.filter((req: RequiredChecklist): boolean => !req.required && this.resolveVerdict(req, results).status === CK_MISSING);\n }\n\n /**\n * The checklists that REFUSED: a reviewer ran, judged the change, and said no (CK_FAIL — status red with\n * no override). A strict subset of {@link pendingChecklists}, split out because it demands a completely\n * different action from the reader.\n *\n * Public so every command agrees on the set. When \"refused\" was computed ad hoc, a refusal and a\n * never-ran reviewer landed in one bucket and produced one message — \"you MUST run these N reviewer\n * subagent(s)\" — handed to an AI, which obediently re-spawned a reviewer that had already answered. It\n * refused again for the same reason, and the loop cost a full subagent run per pass while the reviewer's\n * actual finding was never shown to anyone. A refusal is a RESULT, not a missing step.\n */\n refusedChecklists(required: readonly RequiredChecklist[], results: readonly ChecklistResult[]): RequiredChecklist[] {\n return required.filter((req: RequiredChecklist): boolean => this.resolveVerdict(req, results).status === CK_FAIL);\n }\n\n /**\n * THE renderer for \"this reviewer refused\" — one wording, wherever the refusal surfaces. It exists as a\n * method because the text was previously inlined in {@link requiredChecklistErrors}, reachable only\n * through summary.json validation, while the command layer refused earlier with its own generic message.\n * Two messages for one event is how the useful one became unreachable; there is now exactly one.\n *\n * It always quotes the reviewer's own `output` verbatim: the finding is the whole point, and an error\n * that names a checklist without saying what it objected to gives the reader nothing to fix.\n *\n * IT NAMES THE WRITER, which is the half that was missing. The old text said WHAT to write (\"set a\n * non-empty override\") and WHERE, but never WHO MAY — so the only reachable move was an agent editing a\n * reviewer's verdict file in place, which the harness denies, which is how a human ended up hand-editing\n * JSON. The ship-anyway route is now a SEPARATE file the coordinating agent may write, and the command\n * that writes it is printed ready to run. See {@link ChecklistOverrideService.writerRule}.\n *\n * A red verdict is never moved or deleted (issue #1053): the next round's verdict is a NEW file,\n * `review-round<N+1>-<id>.json`, and the gate reads the highest round, so the refusal stays on disk as the\n * record of what was found.\n */\n refusalError(req: RequiredChecklist, verdict: ChecklistVerdict, summaryJsonFilePath: string): string {\n const finding = `${verdict.detail.split('\\n').join('\\n ')}\\n`;\n const head = `Checklist \"${req.id}\" FAILED review (status:\"${VERDICT_RED}\"). The reviewer (${req.reviewer.agentName}) wrote:\\n ` + finding;\n return head + ' Fix it, commit the fix, record it with pnpm wp-write-review-fixes, then re-run pnpm wp-review-upsert-pr.\\n'\n + this.overrideRoute(req, summaryJsonFilePath);\n }\n\n /**\n * The ship-anyway paragraph: who may authorize, and the exact command that records it.\n *\n * Its own method because every refusal surface must say the identical thing about who may write an\n * override. A second copy of this paragraph is precisely how the previous one drifted into naming a\n * command that had since been deleted.\n */\n private overrideRoute(req: RequiredChecklist, summaryJsonFilePath: string): string {\n return (\n ` To SHIP ANYWAY a human must decide it, and the decision is recorded in its own file — ` +\n `${this.overrides.overrideFileName(req.id)}, never inside the reviewer's verdict.\\n` +\n ` ${this.overrides.writerRule()}\\n` +\n ' Run exactly this, replacing only the \"reason\" with what the human actually said:\\n\\n' +\n `${this.overrides.writeCommand(summaryJsonFilePath, req.id)}\\n`\n );\n }\n\n // Read the LIVE verdict per required checklist: its highest-round `review-round<N>-<id>.json` beside\n // summary.json (issue #1053). A checklist with no verdict file is simply absent from the result (→ MISSING);\n // a malformed one is skipped. The id is matched exactly (see latestVerdictRound), so neither the author's\n // `review-round<N>-fixes.json` nor a provenance file can ever resolve as a verdict.\n loadChecklistResults(summaryJsonFilePath: string, required: readonly RequiredChecklist[]): ChecklistResult[] {\n const results: ChecklistResult[] = [];\n for (const req of required) {\n const round = this.latestVerdictRound(summaryJsonFilePath, req.id);\n if (round === 0) continue;\n const p = this.checklistResultPath(summaryJsonFilePath, req.id, round);\n // The human's authorization is read from its OWN file beside the verdict, in the same pass, so\n // resolveVerdict never touches disk and every command resolves one outcome from one read.\n const parsed = this.parseChecklistResult(p, req.id, this.overrides.load(summaryJsonFilePath, req.id));\n if (parsed === null) continue;\n parsed.round = round;\n results.push(parsed);\n }\n return results;\n }\n\n // Resolve ONE checklist's verdict from its review-round<N>-<id>.json. Central so summary.json enforcement AND the\n // finish-command dashboard agree on the outcome. `problem` is checked FIRST: a file whose verdict cannot\n // be read must not fall through to any shipping outcome.\n resolveVerdict(req: RequiredChecklist, results: readonly ChecklistResult[]): ChecklistVerdict {\n const result = results.find((r: ChecklistResult): boolean => r.id === req.id);\n if (!result) return new ChecklistVerdict(req.id, CK_MISSING, '');\n if (result.problem !== '') return new ChecklistVerdict(req.id, CK_BAD_FORMAT, result.problem);\n if (result.status === VERDICT_GREEN) return new ChecklistVerdict(req.id, CK_PASS, result.output);\n if (result.status === VERDICT_YELLOW) return new ChecklistVerdict(req.id, CK_WARN, result.output);\n // An ORANGE ships once the author has recorded a fix for it, and ONLY that way: it is the final\n // round's must-fix, so there is no re-review to wait for and no override to hunt (issue #1053).\n if (result.status === VERDICT_ORANGE) {\n return result.remediation !== ''\n ? new ChecklistVerdict(req.id, CK_ORANGE_FIXED, result.remediation)\n : new ChecklistVerdict(req.id, CK_ORANGE, result.output);\n }\n const override = result.override;\n // A malformed authorization is reported as a FORMAT problem, never treated as one: an override with\n // no stated reason authorizes nothing, and silently ignoring it would tell the reader their decision\n // was not recorded without ever saying why.\n if (override !== null && override.problem !== '') return new ChecklistVerdict(req.id, CK_BAD_FORMAT, override.problem);\n if (override !== null) return new ChecklistVerdict(req.id, CK_OVERRIDDEN, this.overrides.detail(override));\n return new ChecklistVerdict(req.id, CK_FAIL, result.output);\n }\n\n /**\n * One loud complaint per checklist whose verdict file EXISTS but cannot be read as a verdict — almost\n * always one still using the removed `success` field. Public and separate from\n * {@link requiredChecklistErrors} because `wp-finish-upsert-pr` refuses on missing reviewers BEFORE it\n * parses summary.json: without this, a legacy file would surface as the generic \"no verdict yet\" block\n * and the AI would re-run a reviewer that already ran instead of fixing four characters of JSON.\n */\n checklistFormatErrors(required: readonly RequiredChecklist[], results: readonly ChecklistResult[]): string[] {\n const errors: string[] = [];\n for (const req of required) {\n const verdict = this.resolveVerdict(req, results);\n if (verdict.status === CK_BAD_FORMAT) errors.push(verdict.detail);\n }\n return errors;\n }\n\n // Every matched checklist whose verdict is FAIL (reviewed, found a problem, no override) or MISSING (no\n // review-round<N>-<id>.json written) → one error each, printing the reviewer's `output` verbatim.\n private requiredChecklistErrors(required: readonly RequiredChecklist[], results: readonly ChecklistResult[], filePath: string): string[] {\n // Format complaints come from the ONE renderer, so wp-review-upsert-pr and wp-finish word them identically.\n const errors: string[] = this.checklistFormatErrors(required, results);\n for (const req of required) {\n const verdict = this.resolveVerdict(req, results);\n // CK_WARN ('yellow' — passed with concerns) is deliberately absent from this chain: it SHIPS.\n // The concern still reaches the PR, published in the checklist comment. Do not \"fix\" this.\n if (verdict.status === CK_FAIL) {\n // Through the ONE renderer, so this path and the command layer's refusal say the same thing.\n errors.push(this.refusalError(req, verdict, filePath));\n } else if (verdict.status === CK_ORANGE) {\n errors.push(this.orangeError(req, verdict));\n } else if (verdict.status === CK_MISSING) {\n // An OPTIONAL checklist with no verdict was legitimately not run — the human was offered it\n // and declined. Demanding it here would make\n // `required: false` mean nothing. Note the CK_FAIL branch above deliberately has no such\n // exemption: once an optional reviewer RUNS, its refusal counts.\n if (!req.required) continue;\n const doc = req.doc.trim() !== '' ? ` Read: ${req.doc}.` : '';\n errors.push(`Checklist \"${req.id}\" MATCHED this diff but has no verdict. Spawn the \"${req.reviewer.agentName}\" subagent to review it; ` + `IT submits the verdict with ${this.submitCommand(req.id)} — nobody writes ${this.checklistFileName(req.id)} by hand.${doc}`);\n }\n }\n return errors;\n }\n\n private checklistFileName(checklistId: string): string {\n return `${VERDICT_FILE_PREFIX}<N>-${checklistId}.json`;\n }\n\n /**\n * THE renderer for a reviewer's verdict schema — with the reviewer's own `id` already filled in.\n *\n * There is one because a verdict schema that lives anywhere a human maintains it goes stale, and a\n * reviewer follows the stale copy. That is not a hypothetical: when `success` was replaced by the\n * tri-state `status`, hand-written `.claude/agents/*.md` files kept documenting `success`, and a real\n * PR had to carry \"the verdict format in your own agent .md file is OUT OF DATE\" in the spawn prompt to\n * work around it. Every printed copy — the stage-② roster, the generated per-reviewer instructions\n * file, and the complaint raised against a malformed verdict — now comes from here. It ends with the\n * ONE way a verdict is submitted (`wp-write-review`, issue #863), never a file path to write.\n */\n renderVerdictSchema(id: string, indent = ' '): string {\n return new VerdictSchemaRenderer().render(id, indent);\n }\n\n /** THE command that submits one checklist's verdict (issue #863) — see VerdictSchemaRenderer. */\n submitCommand(id: string): string {\n return new VerdictSchemaRenderer().submitCommand(id);\n }\n\n // Unreadable objects retain their format complaint; absent/unparseable verdicts return null.\n // webpieces-disable no-any-unknown -- opaque parsed JSON, narrowed field-by-field\n private parseChecklistResult(filePath: string, id: string, override: ChecklistOverride | null): ChecklistResult | null {\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: an unparseable per-checklist file is skipped, not fatal\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n // webpieces-disable no-any-unknown -- parsed JSON is opaque until narrowed below\n const raw = JSON.parse(fs.readFileSync(filePath, 'utf8')) as Record<string, unknown>;\n if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) return null;\n const output = typeof raw['output'] === 'string' ? (raw['output'] as string) : '';\n const status = typeof raw['status'] === 'string' ? (raw['status'] as string).trim().toLowerCase() : '';\n const agent = typeof raw['agent'] === 'string' ? raw['agent'].trim() : '';\n const model = typeof raw['model'] === 'string' ? raw['model'].trim() : '';\n const identityProblem = agent === '' || model === '' ? 'Both \"agent\" and \"model\" must be non-empty strings; use \"unknown\" when unavailable.' : '';\n return new ChecklistResult(agent, model, id, status, output, override, this.verdictProblem(filePath, id, status, raw) || identityProblem);\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n return null;\n }\n }\n\n /**\n * '' when the verdict can be READ. Otherwise the complaint to show the AI verbatim.\n *\n * The MOVED `override` field is checked FIRST, ahead of `status`, because it is the more specific fact: a\n * file carrying it was written against a schema that no longer exists, and a reader told only \"status\n * must be green|yellow|red\" would fix the wrong thing. It is rejected even when EMPTY — an accepted shape\n * is never migrated, and `\"override\": \"\"` sitting in a reviewer's file is the copy that teaches the next\n * reviewer the field still exists.\n *\n * The legacy-`success` case keeps its OWN message for the same reason: `success` was removed outright\n * (no compatibility mode), and a reviewer cannot tell a wrong value from a field that no longer exists.\n */\n private verdictProblem(\n filePath: string,\n id: string,\n status: string,\n // webpieces-disable-next-line no-any-unknown -- opaque parsed JSON; only tested for key presence here\n raw: Record<string, unknown>,\n ): string {\n // The ONE renderer — see renderVerdictSchema. A second copy here is what let the old `success` shape\n // survive in print after it was removed from the parser.\n const shape = this.renderVerdictSchema(id);\n if ('override' in raw) {\n return (\n `Checklist \"${id}\" wrote its verdict with the MOVED \"override\" field. A ship-anyway ` +\n \"authorization is no longer part of a reviewer's verdict: it MOVED to its own file, \" +\n `${this.overrides.overrideFileName(id)}, which only the coordinating agent writes and only on a ` +\n 'human\\'s in-session instruction. There is no compatibility mode — DELETE the \"override\" key from ' +\n `${filePath} by resubmitting it:\\n${shape}`\n );\n }\n // webpieces-disable no-any-unknown -- comparing against the readonly literal tuple of valid colors\n if ((VERDICT_STATUSES as readonly string[]).includes(status)) return '';\n if ('success' in raw) {\n return `Checklist \"${id}\" wrote its verdict with the REMOVED \"success\" field. It is now a color ` + `\"status\" — there is no compatibility mode. Resubmit it as:\\n${shape}`;\n }\n return `Checklist \"${id}\" wrote a verdict with no valid \"status\" (got ${JSON.stringify(status)}). ` + `It must be exactly one of ${VERDICT_STATUSES.join(', ')}:\\n${shape}`;\n }\n\n // webpieces-disable no-any-unknown -- opaque parsed JSON value, narrowed to string[] here\n private asStringArray(value: unknown): string[] {\n if (!Array.isArray(value)) return [];\n // webpieces-disable no-any-unknown -- element of an opaque JSON array, narrowed by the type guard\n return value.filter((v: unknown): v is string => typeof v === 'string');\n }\n\n // Parse opaque AI-authored JSON, converting a SyntaxError into a readable InformAiError.\n // webpieces-disable no-any-unknown -- returns the opaque parsed object; loadSummaryJson narrows each field\n private parseSummaryJson(raw: string, filePath: string, expectedMainAgentInstructions = '', retryCommand = 'pnpm wp-finish-upsert-pr'): Record<string, unknown> {\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: convert JSON.parse SyntaxError to an InformAiError for the AI\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n // webpieces-disable no-any-unknown -- parsed JSON is opaque until narrowed by the caller\n return JSON.parse(raw) as Record<string, unknown>;\n } catch (err: unknown) {\n const error = toError(err);\n throw new InformAiError(`summary.json is not valid JSON (${error.message}).\\n\\n` + `${this.summaryJsonSchemaHint(filePath, expectedMainAgentInstructions)}\\n\\n` + `Then re-run: ${retryCommand}`);\n }\n }\n}\n\n// Temporary migration delegators to ReviewJsonService — removed once consumers inject it.\nconst reviewJsonSvc = new ReviewJsonService();\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to ReviewJsonService; removed once consumers inject it\nexport function prDirFor(repoRoot: string, featureName: string): string {\n return reviewJsonSvc.prDirFor(repoRoot, featureName);\n}\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to ReviewJsonService; removed once consumers inject it\nexport function summaryJsonPath(repoRoot: string, featureName: string): string {\n return reviewJsonSvc.summaryJsonPath(repoRoot, featureName);\n}\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to ReviewJsonService; removed once consumers inject it\nexport function summaryJsonSchemaHint(filePath: string, mainAgentInstructions = ''): string {\n return reviewJsonSvc.summaryJsonSchemaHint(filePath, mainAgentInstructions);\n}\n"]}
@@ -71,7 +71,7 @@ export declare const READ_TRUNCATION_LINES = 2000;
71
71
  export declare const ALL_DIFF_ONE_READ_LINES = 1500;
72
72
  /**
73
73
  * Renders the per-reviewer instructions file that `wp-review-upsert-pr` writes to
74
- * `.webpieces/pr-review/<feature>/instructions/<checklistId>.instructions.md` — ONE PER CHECKLIST, so a
74
+ * `.webpieces-logs/pr-review/<feature>/instructions/<checklistId>.instructions.md` — ONE PER CHECKLIST, so a
75
75
  * subagent covering several checklists (`commands.pr-gate.reviewerAgents`) is simply handed several files.
76
76
  *
77
77
  * WHY this file exists, measured rather than assumed: a reviewer subagent on consumer-monorepo2 spent **14 of its
@@ -134,7 +134,7 @@ exports.READ_TRUNCATION_LINES = 2000;
134
134
  exports.ALL_DIFF_ONE_READ_LINES = 1500;
135
135
  /**
136
136
  * Renders the per-reviewer instructions file that `wp-review-upsert-pr` writes to
137
- * `.webpieces/pr-review/<feature>/instructions/<checklistId>.instructions.md` — ONE PER CHECKLIST, so a
137
+ * `.webpieces-logs/pr-review/<feature>/instructions/<checklistId>.instructions.md` — ONE PER CHECKLIST, so a
138
138
  * subagent covering several checklists (`commands.pr-gate.reviewerAgents`) is simply handed several files.
139
139
  *
140
140
  * WHY this file exists, measured rather than assumed: a reviewer subagent on consumer-monorepo2 spent **14 of its
@@ -1 +1 @@
1
- {"version":3,"file":"reviewer-instructions.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/reviewer-instructions.ts"],"names":[],"mappings":";;;;AAAA,mDAA6B;AAC7B,yCAA2D;AAC3D,+CAAkD;AAClD,sEAAiE;AAEjE,2GAA2G;AAC3G,MAAa,YAAY;IACrB,KAAK,CAAS;IACd,IAAI,CAAS,CAAK,gDAAgD;IAClE,IAAI,CAAS,CAAK,0EAA0E;IAE5F,YAAY,KAAa,EAAE,SAAiB,EAAE,IAAI,GAAG,EAAE;QACnD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,SAA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YACL,EAAE;SACL,CAAC;IACN,CAAC;IAED;;;;;;;OAOG;IACK,aAAa;QACjB,OAAO;YACH,WAAW;YACX,EAAE;YACF,mGAAmG;YACnG,iGAAiG;YACjG,4CAA4C;YAC5C,EAAE;YACF,qGAAqG;YACrG,8FAA8F;YAC9F,EAAE;YACF,mGAAmG;YACnG,qBAAqB;YACrB,EAAE;YACF,oGAAoG;YACpG,kGAAkG;YAClG,kGAAkG;YAClG,+EAA+E;YAC/E,sGAAsG;SACzG,CAAC;IACN,CAAC;CACJ,CAAA;AAtVY,kEAA2B;sCAA3B,2BAA2B;IADvC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEW,+BAAiB;GADxD,2BAA2B,CAsVvC","sourcesContent":["import * as path from 'path';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { ReviewJsonService } from './review-json';\nimport { WRITE_REVIEW_BIN } from '@webpieces/repo-workflow-core';\n\n/** One pre-resolved place a reviewer would otherwise have to go hunting for. Data-only (per CLAUDE.md). */\nexport class ContextEntry {\n label: string;\n path: string; // ABSOLUTE, or '' when it could not be resolved\n note: string; // '(not installed)' / '(configured but missing)' — never silently dropped\n\n constructor(label: string, entryPath: string, note = '') {\n this.label = label;\n this.path = entryPath;\n this.note = note;\n }\n}\n\n/**\n * One reviewer's matched file, the extracted diff for it, AND the absolute path of the file itself.\n *\n * `sourcePath` exists because of a measured 0/4: four reviewers on one PR read the diff and not one opened a\n * single full source file. The instructions handed them an absolute path per diff and only a parent DIRECTORY\n * per source, so reading the diff was a paste and reading the source was \"join this dir to that filename\n * yourself\". Identical affordance, or the cheaper one wins every time. Data-only.\n */\nexport class BriefedFile {\n file: string; // repo-relative source path\n diffPath: string; // ABSOLUTE path of the extracted .diff\n sourcePath: string; // ABSOLUTE path of the file itself; '' for a deleted file, which has no after-state\n status: string; // 'M' | 'A' | 'D' | 'U' (untracked) | 'X' (excluded by config)\n diffBytes: number;\n truncated: boolean;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(file: string, diffPath: string, sourcePath = '', status = 'M', diffBytes = 0, truncated = false) {\n this.file = file;\n this.diffPath = diffPath;\n this.sourcePath = sourcePath;\n this.status = status;\n this.diffBytes = diffBytes;\n this.truncated = truncated;\n }\n}\n\n/**\n * Everything ONE reviewer needs, with every path already resolved to an ABSOLUTE one.\n *\n * Absolute is not fussiness: a subagent's working directory is not guaranteed to be the repo root, and a\n * relative path that fails to resolve turns into a search, which is the cost this whole class exists to\n * remove. Data-only.\n */\nexport class ReviewerBriefing {\n agentName: string; // the agent type the subagent is spawned as (webpieces-reviewer, or the override)\n docPath: string; // the checklist's guidance doc ('' when the checklist has none)\n repoRoot: string;\n diffDir: string; // '' when nothing was materialized\n allDiffPath: string;\n manifestPath: string;\n myFiles: BriefedFile[]; // ONLY this reviewer's matched files\n matchedPatterns: string[]; // [] ⇒ patternless: the whole diff is in scope\n sourceDirs: string[]; // deduped ABSOLUTE parent dirs of myFiles\n contextEntries: ContextEntry[];\n verdictPath: string; // ABSOLUTE review-round<N>-<id>.json\n checklistId: string;\n fileDiffCommand: string;\n dirty: boolean;\n // Facts ABOUT the manifest, surfaced inline so a reviewer learns the diff is complete without opening it.\n changedFileCount: number;\n truncatedCount: number;\n excludedCount: number;\n allDiffLines: number;\n allDiffBytes: number;\n // The three shas, by the names DiffManifest already uses. Printing two bare shas told a reviewer nothing\n // about WHAT the diff is taken against; C beside A makes \"main has moved since the fork\" self-evident.\n hashForkPoint: string;\n hashFeatureHead: string;\n hashMainHead: string;\n ownAgentFileInDiff: string; // ABSOLUTE path when this diff edits the reviewer agent's own file; '' otherwise\n // From the checklist's config `required`. Carried so the stage-② report can group the spawn blocks\n // (must run) apart from the ones the human is merely OFFERED, without a second lookup that could\n // disagree with the scan. The reviewer's OWN instructions do not mention it: a reviewer that has been\n // spawned reviews the same way either way, and telling an optional one it was optional invites it to\n // grade itself softer.\n required: boolean;\n round: number;\n maxRounds: number;\n remediationOnly: boolean;\n previousVerdictPath: string;\n remediationPath: string;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(agentName: string, checklistId: string, repoRoot: string) {\n this.agentName = agentName;\n this.checklistId = checklistId;\n this.repoRoot = repoRoot;\n this.docPath = '';\n this.diffDir = '';\n this.allDiffPath = '';\n this.manifestPath = '';\n this.myFiles = [];\n this.matchedPatterns = [];\n this.sourceDirs = [];\n this.contextEntries = [];\n this.verdictPath = '';\n this.fileDiffCommand = '';\n this.dirty = false;\n this.changedFileCount = 0;\n this.truncatedCount = 0;\n this.excludedCount = 0;\n this.allDiffLines = 0;\n this.allDiffBytes = 0;\n this.hashForkPoint = '';\n this.hashFeatureHead = '';\n this.hashMainHead = '';\n this.ownAgentFileInDiff = '';\n // Fails CLOSED, like RequiredChecklist.required: a briefing built without the flag being copied is\n // treated as a blocking reviewer, never as a skippable one.\n this.required = true;\n this.round = 1;\n this.maxRounds = 1;\n this.remediationOnly = false;\n this.previousVerdictPath = '';\n this.remediationPath = '';\n }\n}\n\n/**\n * The Read tool truncates at roughly this many lines, silently. Any path this file prints alongside a bigger\n * line count has to say so, or a reviewer reviews a fraction of a change and reports on all of it.\n */\nexport const READ_TRUNCATION_LINES = 2000;\n\n/** Comfortably under {@link READ_TRUNCATION_LINES} — the size at which ALL.diff really is one clean Read. */\nexport const ALL_DIFF_ONE_READ_LINES = 1500;\n\n/**\n * Renders the per-reviewer instructions file that `wp-review-upsert-pr` writes to\n * `.webpieces/pr-review/<feature>/instructions/<checklistId>.instructions.md` — ONE PER CHECKLIST, so a\n * subagent covering several checklists (`commands.pr-gate.reviewerAgents`) is simply handed several files.\n *\n * WHY this file exists, measured rather than assumed: a reviewer subagent on consumer-monorepo2 spent **14 of its\n * 26 tool calls** rediscovering context the tooling already had — three separate greps into\n * `node_modules/@webpieces` to locate a scanner, a hunt through terraform for queue names, and a\n * re-derivation of the dependency graph. It did not over-review; it was under-supplied. Everything below is\n * chosen to delete a specific one of those calls.\n *\n * It is GENERATED per run, and the reviewer agent (`.claude/agents/<name>.md`, by default the\n * webpieces-owned `webpieces-reviewer.md`) is checklist-agnostic and points here, because content a human\n * maintains goes stale and a reviewer follows the stale copy. The verdict\n * schema in particular comes from {@link ReviewJsonService.renderVerdictSchema}.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ReviewerInstructionsService {\n constructor(private readonly reviewJsonService: ReviewJsonService) {}\n\n /** The dir holding this branch's generated instructions, beside its summary.json. */\n instructionsDirFor(repoRoot: string, featureName: string): string {\n return path.join(this.reviewJsonService.prDirFor(repoRoot, featureName), 'instructions');\n }\n\n /** The file name for one checklist's generated instructions. */\n fileNameFor(checklistId: string): string {\n return `${checklistId}.instructions.md`;\n }\n\n /** Absolute path of one checklist's generated instructions file. */\n pathFor(repoRoot: string, featureName: string, checklistId: string): string {\n return path.join(this.instructionsDirFor(repoRoot, featureName), this.fileNameFor(checklistId));\n }\n\n render(briefing: ReviewerBriefing): string {\n return [\n ...this.identity(briefing),\n ...this.checklistSection(briefing),\n ...this.diffSection(briefing),\n ...this.sourceSection(briefing),\n ...this.contextSection(briefing),\n ...this.verdictSection(briefing),\n ...this.budgetSection(),\n ].join('\\n') + '\\n';\n }\n\n private identity(b: ReviewerBriefing): string[] {\n return [\n ...this.finalRoundHeader(b),\n `# Checklist \\`${b.checklistId}\\` — reviewed by a \\`${b.agentName}\\` subagent`,\n '',\n `Global reviewer round ${b.round} of ${b.maxRounds}.`,\n '',\n ...this.budgetCheck(b),\n 'Review this diff against THIS checklist only — not as a general code reviewer — and only over the',\n 'files in scope below. If you were handed several of these files, review each checklist separately',\n 'and write each one its own verdict. Never write a verdict for a checklist you were not handed.',\n '',\n `Your agent definition is \\`${this.agentFileFor(b)}\\`. If your harness did not load it for you`,\n '(Codex spawns a generic subagent), read it before anything else — it is the one canonical',\n 'definition of how a reviewer works here.',\n '',\n '\"You may not review your own authorship\" means: you did not write this diff, so review it — but if',\n 'the diff CHANGES YOU, say so in `output` rather than pretending the conflict is not there.',\n ...this.selfEditWarning(b),\n '',\n '_Generated per run by `wp-review-upsert-pr`. Everything below is already resolved for you; the',\n 'paths are absolute because your working directory is not guaranteed to be the repo root._',\n '',\n ];\n }\n\n /**\n * The FINAL round's header (issue #1053), FIRST in the file so nothing above it can be read as the rule.\n * On the last round `wp-write-review` refuses red, so a reviewer that learned this only at submission time\n * would have written its findings for a re-review that never happens.\n */\n private finalRoundHeader(b: ReviewerBriefing): string[] {\n if (b.round < b.maxRounds) return [];\n return [\n 'THIS IS THE FINAL REVIEW ROUND. There is no re-review. You may NOT mark red.',\n 'Mark anything that must be fixed as ORANGE, with a concrete, actionable fix. The author will apply it',\n 'best effort and ship without another review, so put every finding in now.',\n '',\n ];\n }\n\n /**\n * The FIRST thing a reviewer does (issue #1051): ask the gate whether this checklist may still be\n * reviewed. An author agent can spawn a reviewer from this file long after the round budget is spent —\n * the measured deadlock did — so the file itself carries the check, and `wp-write-review` enforces it.\n */\n private budgetCheck(b: ReviewerBriefing): string[] {\n return [\n '## FIRST — confirm this review is within the round budget',\n '',\n `Before you read anything else, run: \\`pnpm ${WRITE_REVIEW_BIN} --checklist ${b.checklistId} --check\\``,\n '',\n `It confirms that round ${b.round} is within \\`maxReviewerRounds\\` (${b.maxRounds}) and that`,\n `\\`${b.checklistId}\\` has no verdict yet in this round. If it REFUSES, do not review this checklist and`,\n 'submit nothing for it: report its refusal verbatim to the agent that spawned you. `wp-write-review`',\n 'refuses an over-budget verdict anyway, so a review past the budget is wasted work that cannot be recorded.',\n '',\n ];\n }\n\n /** The absolute path of the reviewer agent's committed definition (`.claude/agents/<agentName>.md`). */\n agentFileFor(b: ReviewerBriefing): string {\n return path.join(b.repoRoot, '.claude', 'agents', `${b.agentName}.md`);\n }\n\n /**\n * Every PR that edits the review gate hits this: on the measured run, 5 of 8 changed files were the\n * reviewer agent files themselves, two reviewers reviewed their OWN definition, and neither flagged it —\n * neither had any guidance to. Detected by the tooling rather than left to the reviewer to notice.\n */\n private selfEditWarning(b: ReviewerBriefing): string[] {\n if (b.ownAgentFileInDiff === '') return [];\n return [\n '',\n `⚠️ THIS DIFF MODIFIES YOUR OWN AGENT FILE: \\`${b.ownAgentFileInDiff}\\``,\n 'You are reviewing a change to your own definition. Review it anyway — and state that fact in',\n '`output`, so a human reading your verdict knows the reviewer and the reviewed were the same thing.',\n ];\n }\n\n private checklistSection(b: ReviewerBriefing): string[] {\n if (b.docPath === '') {\n return ['## Your checklist', '', 'This checklist has no guidance doc — judge the diff on your own standards.', ''];\n }\n return ['## Your checklist', '', `Read this FIRST: \\`${b.docPath}\\``, ''];\n }\n\n /**\n * The change itself. The MANIFEST leads, and the per-file table with it; `ALL.diff` is demoted to one\n * option among several, recommended only where it is actually the right read.\n *\n * That ordering is the fix for a measured 4/4 failure. `ALL.diff` used to be bolded, first, and framed as\n * \"everything\", with the manifest one unbolded line below it called a \"path map\" — which reads like a\n * lookup aid, not something to open. All four reviewers on that PR read `ALL.diff`, none opened the\n * manifest, and none could therefore have established that the combined view was complete. Reviewers did\n * exactly what the emphasis told them to; so the emphasis moved.\n */\n private diffSection(b: ReviewerBriefing): string[] {\n const lines = ['## The change you are reviewing', ''];\n if (b.remediationOnly) {\n lines.push(\n 'This is a REMEDIATION-ONLY re-review. Verify the claimed fixes and inspect the remediation',\n 'delta for regressions; do not restart a full review of the original branch diff.',\n '',\n `Previous reviewer verdict (verbatim): \\`${b.previousVerdictPath}\\``,\n `Author remediation response: \\`${b.remediationPath}\\``,\n '',\n );\n }\n if (b.dirty) {\n lines.push('> ⚠️ This diff INCLUDES uncommitted and untracked work, so it is not what a');\n lines.push('> commit-to-commit range would show. Judge it anyway — it is what your checklist matched.');\n lines.push('');\n }\n lines.push(...this.manifestLines(b), ...this.basisLines(b), ...this.myFilesTable(b), ...this.allDiffLines(b));\n if (b.fileDiffCommand !== '') {\n lines.push(`Reproduce any single file: \\`${b.fileDiffCommand}\\``);\n lines.push('');\n }\n lines.push('Path matching is COARSE. Judge the change, not the path — if a matched file turns out to be');\n lines.push('irrelevant to your checklist, say so in one sentence and move on.');\n lines.push('');\n return lines;\n }\n\n /**\n * The manifest, named as the authority AND with its own headline facts inlined. Inlining them is the\n * point: a reviewer that never opens the manifest still learns whether anything was truncated or\n * excluded, which is the one thing it could not otherwise have known it was missing.\n */\n private manifestLines(b: ReviewerBriefing): string[] {\n if (b.manifestPath === '') return [];\n const warn = b.truncatedCount + b.excludedCount > 0 ? ' ⚠️ NOT everything is materialized — see the table.' : '';\n return [\n `**Path map — AUTHORITATIVE. Read this first:** \\`${b.manifestPath}\\``,\n ` ${b.changedFileCount} file(s) · ${b.truncatedCount} truncated · ${b.excludedCount} excluded${warn}`,\n ' Per file it carries: `status` (M/A/D/U/X), `bytes`, `file`/`fileAbs`, `diffFile`/`diffAbs`, and the',\n ' three shas below. It is the only place that records what was truncated or left out.',\n '',\n ];\n }\n\n /**\n * What the diff is taken AGAINST. Two bare shas in a `git diff` command said nothing about this, so a\n * reviewer could not tell a fork-point diff from a diff against main's current tip — and therefore could\n * not tell that anything merged to main since the fork is simply absent from what it is judging.\n * Rendering C beside A makes \"main has moved\" self-evident exactly when it has.\n */\n private basisLines(b: ReviewerBriefing): string[] {\n if (b.hashForkPoint === '') return [];\n const sameAsFork = b.hashMainHead === b.hashForkPoint;\n const cNote = b.hashMainHead === '' ? '(unresolved)'\n : sameAsFork ? `${b.hashMainHead} ← same as A, so main has not moved since the fork`\n : `${b.hashMainHead} ← main HAS MOVED since the fork`;\n return [\n 'This diff is **fork-point → feature-head**, NOT a diff against main\\'s current tip:',\n '```',\n `fork point (A) ${b.hashForkPoint}`,\n `feature head (B) ${b.hashFeatureHead}`,\n `main head (C) ${cNote}`,\n '```',\n 'Anything merged to main after A is NOT in this diff.',\n '',\n ];\n }\n\n /**\n * Source and diff get IDENTICAL affordance — an absolute path each, in adjacent columns. The previous\n * table gave an absolute path for the diff and nothing for the source, and the source went unread 4/4.\n */\n private myFilesTable(b: ReviewerBriefing): string[] {\n if (b.myFiles.length === 0) return ['_No files matched your patterns._', ''];\n const why = b.matchedPatterns.length === 0\n ? `**In scope: ALL ${b.myFiles.length} changed file(s)** — your checklist has no \\`patterns\\`, so the whole diff is yours.`\n : `**In scope: ${b.myFiles.length} file(s)** matching ${b.matchedPatterns.map((p: string): string => `\\`${p}\\``).join(', ')}:`;\n const rows = b.myFiles.map((f: BriefedFile): string => this.fileRow(f));\n return [why, '', '| file | status | its diff | full source |', '|---|---|---|---|', ...rows, ''];\n }\n\n /**\n * One row. A truncated or excluded diff is flagged HERE, in the row, not left as a field inside a file the\n * reviewer has to think to open — and an oversized diff states the line count that makes a single Read\n * come back silently incomplete.\n */\n private fileRow(f: BriefedFile): string {\n const flags: string[] = [];\n if (f.truncated) flags.push('⚠️ diff TRUNCATED — read the source');\n if (f.status === 'X') flags.push('⚠️ EXCLUDED, not materialized — read the source');\n const status = [`\\`${f.status}\\``, ...flags].join(' ');\n const source = f.sourcePath === '' ? '_deleted — no file on disk_' : `\\`${f.sourcePath}\\``;\n return `| \\`${f.file}\\` | ${status} | \\`${f.diffPath}\\` (${f.diffBytes} bytes) | ${source} |`;\n }\n\n /**\n * `ALL.diff`, recommended ONLY where it is the right read. It is kept — for a patternless reviewer on a\n * small diff it is genuinely one Read instead of N, which is why all four used it — but the blanket\n * \"everything on this branch\" line was wrong in two different ways at once: it invited a pattern-scoped\n * reviewer to spend its budget on files it was explicitly not asked about, and it pointed a reviewer on a\n * large PR at a file that cannot survive one Read.\n */\n private allDiffLines(b: ReviewerBriefing): string[] {\n if (b.allDiffPath === '') return [];\n const size = b.allDiffLines === 0 ? '' : ` — ${b.allDiffLines} lines / ${b.allDiffBytes} bytes`;\n if (b.matchedPatterns.length > 0) {\n return [`The whole branch${size}, for CROSS-FILE CONTEXT if you need it: \\`${b.allDiffPath}\\``,\n 'Your own files above are what you are reviewing; the rest of the branch is someone else\\'s checklist.', ''];\n }\n if (b.allDiffLines > ALL_DIFF_ONE_READ_LINES) {\n return [`⚠️ The combined diff is ${b.allDiffLines} lines and will NOT survive a single Read (the Read tool`,\n `truncates at ~${READ_TRUNCATION_LINES} lines, silently). Read the per-file diffs above instead, or page it:`,\n `\\`${b.allDiffPath}\\``, ''];\n }\n return [`Whole-branch diff${size} — convenient at this size, but the per-file table above is authoritative:`,\n `\\`${b.allDiffPath}\\``, ''];\n }\n\n /**\n * The rule that used to say \"when you need to\", and lost 4/4 to the more emphatic budget section 40 lines\n * later. \"When you need to\" delegates the judgment to a reviewer that, by construction, does not yet know\n * what it is missing. It has no opt-out now.\n */\n private sourceSection(b: ReviewerBriefing): string[] {\n const lines = ['## Read the full source — every file, every time', '', `Repo root: \\`${b.repoRoot}\\``, ''];\n lines.push('**READ THE FULL SOURCE OF EVERY FILE IN YOUR TABLE.** Not \"if you need to\" — every time.');\n lines.push('A hunk shows what changed; only the whole file shows what it changed INTO, and a change that');\n lines.push('looks fine in isolation can still be wrong in place.');\n lines.push('');\n lines.push('The `full source` column above is the path. For files marked `A` (added) you have already done');\n lines.push('this: an add-diff IS the complete file, byte for byte, so its diff and its source are the same');\n lines.push('text. For `M` (modified) and `D` (deleted) files the diff is a fragment — open the file.');\n lines.push('');\n if (b.sourceDirs.length > 0) {\n lines.push('The neighbouring code lives under:');\n for (const dir of b.sourceDirs) lines.push(`- \\`${dir}\\``);\n lines.push('');\n }\n return lines;\n }\n\n /**\n * The section that deletes the `node_modules` greps. Entries come from config, because the tooling\n * cannot guess that a repo keeps its queue names in terraform — but it CAN resolve where a package\n * installed to, and it must never drop an entry silently: a missing path is stated as missing.\n */\n private contextSection(b: ReviewerBriefing): string[] {\n // Emitting NOTHING made the section this class exists for look like a feature that does not exist.\n // One line naming the config keys costs nothing and is the only hint a repo will ever get.\n if (b.contextEntries.length === 0) {\n return ['## Pre-resolved context', '',\n '_None configured for this repo. If you find yourself hunting for the same path on every review,',\n 'it belongs in `pr-gate.reviewContext` / `pr-gate.reviewContextPackages` in `webpieces.config.json`._',\n ''];\n }\n const lines = ['## Pre-resolved context (do not go hunting for these)', ''];\n for (const entry of b.contextEntries) {\n const suffix = entry.note === '' ? '' : ` ${entry.note}`;\n lines.push(`- **${entry.label}** — \\`${entry.path === '' ? entry.note : entry.path}\\`${entry.path === '' ? '' : suffix}`);\n }\n lines.push('');\n return lines;\n }\n\n /**\n * The verdict shape, GENERATED — never restated in a hand-maintained file. `id` is pre-filled with this\n * reviewer's own checklist id so there is nothing to substitute and nothing to get wrong.\n */\n private verdictSection(b: ReviewerBriefing): string[] {\n return [\n '## Submit your verdict',\n '',\n `Submit EXACTLY this shape through \\`${this.reviewJsonService.submitCommand(b.checklistId)}\\` —`,\n 'the JSON on stdin (a heredoc is simplest), or `--file <path>` naming a scratch file. Do NOT write',\n `\\`${b.verdictPath}\\` yourself: the bin validates the verdict, writes that file, and records that YOU`,\n 'submitted it, and `wp-finish-upsert-pr` REJECTS a verdict file written any other way. The bin also',\n 'refuses the coordinating agent, so nobody can submit this on your behalf.',\n '',\n '```',\n this.reviewJsonService.renderVerdictSchema(b.checklistId, ''),\n '```',\n '',\n ];\n }\n\n /**\n * The anti-hunting rule, with the changed files carved out explicitly.\n *\n * It used to read as \"stay inside what you were given\" and, being the LAST thing in the file, it beat\n * the source-reading instruction 4 times out of 4. It never distinguished HUNTING — greps into\n * `node_modules`, re-deriving the dependency graph — from OPENING A FILE IT WAS EXPLICITLY HANDED. The\n * distinction is now stated, because where two instructions conflict the later and more emphatic one wins.\n */\n private budgetSection(): string[] {\n return [\n '## Budget',\n '',\n 'Do NOT search `node_modules`, do NOT re-derive the dependency graph, and do NOT hunt the repo for',\n 'infrastructure config. That is hunting, and it is what wastes a review budget — those paths are',\n 'either given above or were not configured.',\n '',\n 'Reading the full text of a file that is IN your table is NOT hunting — it is the review. Budget for',\n 'it: read the diff to see what changed, and the source to judge whether it is right in place.',\n '',\n 'If something you genuinely need is missing, name it in `output` and give your verdict on what you',\n 'could actually see.',\n '',\n 'Open your diff files before writing a verdict. `wp-finish-upsert-pr` reads your own transcript and',\n 'reports a verdict written without opening the diff. It also records the path of that transcript,',\n 'beside what you were offered and what you read, in `provenance.json` next to your verdict file —',\n 'so the review is auditable after the fact. You do not write that file, or the',\n '`review-round<N>-<id>.provenance.json` wp-write-review writes beside your verdict; the tooling does.',\n ];\n }\n}\n"]}
1
+ {"version":3,"file":"reviewer-instructions.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/reviewer-instructions.ts"],"names":[],"mappings":";;;;AAAA,mDAA6B;AAC7B,yCAA2D;AAC3D,+CAAkD;AAClD,sEAAiE;AAEjE,2GAA2G;AAC3G,MAAa,YAAY;IACrB,KAAK,CAAS;IACd,IAAI,CAAS,CAAK,gDAAgD;IAClE,IAAI,CAAS,CAAK,0EAA0E;IAE5F,YAAY,KAAa,EAAE,SAAiB,EAAE,IAAI,GAAG,EAAE;QACnD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;CACJ;AAVD,oCAUC;AAED;;;;;;;GAOG;AACH,MAAa,WAAW;IACpB,IAAI,CAAS,CAAQ,4BAA4B;IACjD,QAAQ,CAAS,CAAI,uCAAuC;IAC5D,UAAU,CAAS,CAAE,oFAAoF;IACzG,MAAM,CAAS,CAAM,+DAA+D;IACpF,SAAS,CAAS;IAClB,SAAS,CAAU;IAEnB,yDAAyD;IACzD,YAAY,IAAY,EAAE,QAAgB,EAAE,UAAU,GAAG,EAAE,EAAE,MAAM,GAAG,GAAG,EAAE,SAAS,GAAG,CAAC,EAAE,SAAS,GAAG,KAAK;QACvG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAA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IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;QAC9H,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,OAAO,KAAK,CAAC;IACjB,CAAC;IAED;;;OAGG;IACK,cAAc,CAAC,CAAmB;QACtC,OAAO;YACH,wBAAwB;YACxB,EAAE;YACF,uCAAuC,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM;YAChG,mGAAmG;YACnG,KAAK,CAAC,CAAC,WAAW,oFAAoF;YACtG,oGAAoG;YACpG,2EAA2E;YAC3E,EAAE;YACF,KAAK;YACL,IAAI,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;YAC7D,KAAK;YACL,EAAE;SACL,CAAC;IACN,CAAC;IAED;;;;;;;OAOG;IACK,aAAa;QACjB,OAAO;YACH,WAAW;YACX,EAAE;YACF,mGAAmG;YACnG,iGAAiG;YACjG,4CAA4C;YAC5C,EAAE;YACF,qGAAqG;YACrG,8FAA8F;YAC9F,EAAE;YACF,mGAAmG;YACnG,qBAAqB;YACrB,EAAE;YACF,oGAAoG;YACpG,kGAAkG;YAClG,kGAAkG;YAClG,+EAA+E;YAC/E,sGAAsG;SACzG,CAAC;IACN,CAAC;CACJ,CAAA;AAtVY,kEAA2B;sCAA3B,2BAA2B;IADvC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEW,+BAAiB;GADxD,2BAA2B,CAsVvC","sourcesContent":["import * as path from 'path';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { ReviewJsonService } from './review-json';\nimport { WRITE_REVIEW_BIN } from '@webpieces/repo-workflow-core';\n\n/** One pre-resolved place a reviewer would otherwise have to go hunting for. Data-only (per CLAUDE.md). */\nexport class ContextEntry {\n label: string;\n path: string; // ABSOLUTE, or '' when it could not be resolved\n note: string; // '(not installed)' / '(configured but missing)' — never silently dropped\n\n constructor(label: string, entryPath: string, note = '') {\n this.label = label;\n this.path = entryPath;\n this.note = note;\n }\n}\n\n/**\n * One reviewer's matched file, the extracted diff for it, AND the absolute path of the file itself.\n *\n * `sourcePath` exists because of a measured 0/4: four reviewers on one PR read the diff and not one opened a\n * single full source file. The instructions handed them an absolute path per diff and only a parent DIRECTORY\n * per source, so reading the diff was a paste and reading the source was \"join this dir to that filename\n * yourself\". Identical affordance, or the cheaper one wins every time. Data-only.\n */\nexport class BriefedFile {\n file: string; // repo-relative source path\n diffPath: string; // ABSOLUTE path of the extracted .diff\n sourcePath: string; // ABSOLUTE path of the file itself; '' for a deleted file, which has no after-state\n status: string; // 'M' | 'A' | 'D' | 'U' (untracked) | 'X' (excluded by config)\n diffBytes: number;\n truncated: boolean;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(file: string, diffPath: string, sourcePath = '', status = 'M', diffBytes = 0, truncated = false) {\n this.file = file;\n this.diffPath = diffPath;\n this.sourcePath = sourcePath;\n this.status = status;\n this.diffBytes = diffBytes;\n this.truncated = truncated;\n }\n}\n\n/**\n * Everything ONE reviewer needs, with every path already resolved to an ABSOLUTE one.\n *\n * Absolute is not fussiness: a subagent's working directory is not guaranteed to be the repo root, and a\n * relative path that fails to resolve turns into a search, which is the cost this whole class exists to\n * remove. Data-only.\n */\nexport class ReviewerBriefing {\n agentName: string; // the agent type the subagent is spawned as (webpieces-reviewer, or the override)\n docPath: string; // the checklist's guidance doc ('' when the checklist has none)\n repoRoot: string;\n diffDir: string; // '' when nothing was materialized\n allDiffPath: string;\n manifestPath: string;\n myFiles: BriefedFile[]; // ONLY this reviewer's matched files\n matchedPatterns: string[]; // [] ⇒ patternless: the whole diff is in scope\n sourceDirs: string[]; // deduped ABSOLUTE parent dirs of myFiles\n contextEntries: ContextEntry[];\n verdictPath: string; // ABSOLUTE review-round<N>-<id>.json\n checklistId: string;\n fileDiffCommand: string;\n dirty: boolean;\n // Facts ABOUT the manifest, surfaced inline so a reviewer learns the diff is complete without opening it.\n changedFileCount: number;\n truncatedCount: number;\n excludedCount: number;\n allDiffLines: number;\n allDiffBytes: number;\n // The three shas, by the names DiffManifest already uses. Printing two bare shas told a reviewer nothing\n // about WHAT the diff is taken against; C beside A makes \"main has moved since the fork\" self-evident.\n hashForkPoint: string;\n hashFeatureHead: string;\n hashMainHead: string;\n ownAgentFileInDiff: string; // ABSOLUTE path when this diff edits the reviewer agent's own file; '' otherwise\n // From the checklist's config `required`. Carried so the stage-② report can group the spawn blocks\n // (must run) apart from the ones the human is merely OFFERED, without a second lookup that could\n // disagree with the scan. The reviewer's OWN instructions do not mention it: a reviewer that has been\n // spawned reviews the same way either way, and telling an optional one it was optional invites it to\n // grade itself softer.\n required: boolean;\n round: number;\n maxRounds: number;\n remediationOnly: boolean;\n previousVerdictPath: string;\n remediationPath: string;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(agentName: string, checklistId: string, repoRoot: string) {\n this.agentName = agentName;\n this.checklistId = checklistId;\n this.repoRoot = repoRoot;\n this.docPath = '';\n this.diffDir = '';\n this.allDiffPath = '';\n this.manifestPath = '';\n this.myFiles = [];\n this.matchedPatterns = [];\n this.sourceDirs = [];\n this.contextEntries = [];\n this.verdictPath = '';\n this.fileDiffCommand = '';\n this.dirty = false;\n this.changedFileCount = 0;\n this.truncatedCount = 0;\n this.excludedCount = 0;\n this.allDiffLines = 0;\n this.allDiffBytes = 0;\n this.hashForkPoint = '';\n this.hashFeatureHead = '';\n this.hashMainHead = '';\n this.ownAgentFileInDiff = '';\n // Fails CLOSED, like RequiredChecklist.required: a briefing built without the flag being copied is\n // treated as a blocking reviewer, never as a skippable one.\n this.required = true;\n this.round = 1;\n this.maxRounds = 1;\n this.remediationOnly = false;\n this.previousVerdictPath = '';\n this.remediationPath = '';\n }\n}\n\n/**\n * The Read tool truncates at roughly this many lines, silently. Any path this file prints alongside a bigger\n * line count has to say so, or a reviewer reviews a fraction of a change and reports on all of it.\n */\nexport const READ_TRUNCATION_LINES = 2000;\n\n/** Comfortably under {@link READ_TRUNCATION_LINES} — the size at which ALL.diff really is one clean Read. */\nexport const ALL_DIFF_ONE_READ_LINES = 1500;\n\n/**\n * Renders the per-reviewer instructions file that `wp-review-upsert-pr` writes to\n * `.webpieces-logs/pr-review/<feature>/instructions/<checklistId>.instructions.md` — ONE PER CHECKLIST, so a\n * subagent covering several checklists (`commands.pr-gate.reviewerAgents`) is simply handed several files.\n *\n * WHY this file exists, measured rather than assumed: a reviewer subagent on consumer-monorepo2 spent **14 of its\n * 26 tool calls** rediscovering context the tooling already had — three separate greps into\n * `node_modules/@webpieces` to locate a scanner, a hunt through terraform for queue names, and a\n * re-derivation of the dependency graph. It did not over-review; it was under-supplied. Everything below is\n * chosen to delete a specific one of those calls.\n *\n * It is GENERATED per run, and the reviewer agent (`.claude/agents/<name>.md`, by default the\n * webpieces-owned `webpieces-reviewer.md`) is checklist-agnostic and points here, because content a human\n * maintains goes stale and a reviewer follows the stale copy. The verdict\n * schema in particular comes from {@link ReviewJsonService.renderVerdictSchema}.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ReviewerInstructionsService {\n constructor(private readonly reviewJsonService: ReviewJsonService) {}\n\n /** The dir holding this branch's generated instructions, beside its summary.json. */\n instructionsDirFor(repoRoot: string, featureName: string): string {\n return path.join(this.reviewJsonService.prDirFor(repoRoot, featureName), 'instructions');\n }\n\n /** The file name for one checklist's generated instructions. */\n fileNameFor(checklistId: string): string {\n return `${checklistId}.instructions.md`;\n }\n\n /** Absolute path of one checklist's generated instructions file. */\n pathFor(repoRoot: string, featureName: string, checklistId: string): string {\n return path.join(this.instructionsDirFor(repoRoot, featureName), this.fileNameFor(checklistId));\n }\n\n render(briefing: ReviewerBriefing): string {\n return [\n ...this.identity(briefing),\n ...this.checklistSection(briefing),\n ...this.diffSection(briefing),\n ...this.sourceSection(briefing),\n ...this.contextSection(briefing),\n ...this.verdictSection(briefing),\n ...this.budgetSection(),\n ].join('\\n') + '\\n';\n }\n\n private identity(b: ReviewerBriefing): string[] {\n return [\n ...this.finalRoundHeader(b),\n `# Checklist \\`${b.checklistId}\\` — reviewed by a \\`${b.agentName}\\` subagent`,\n '',\n `Global reviewer round ${b.round} of ${b.maxRounds}.`,\n '',\n ...this.budgetCheck(b),\n 'Review this diff against THIS checklist only — not as a general code reviewer — and only over the',\n 'files in scope below. If you were handed several of these files, review each checklist separately',\n 'and write each one its own verdict. Never write a verdict for a checklist you were not handed.',\n '',\n `Your agent definition is \\`${this.agentFileFor(b)}\\`. If your harness did not load it for you`,\n '(Codex spawns a generic subagent), read it before anything else — it is the one canonical',\n 'definition of how a reviewer works here.',\n '',\n '\"You may not review your own authorship\" means: you did not write this diff, so review it — but if',\n 'the diff CHANGES YOU, say so in `output` rather than pretending the conflict is not there.',\n ...this.selfEditWarning(b),\n '',\n '_Generated per run by `wp-review-upsert-pr`. Everything below is already resolved for you; the',\n 'paths are absolute because your working directory is not guaranteed to be the repo root._',\n '',\n ];\n }\n\n /**\n * The FINAL round's header (issue #1053), FIRST in the file so nothing above it can be read as the rule.\n * On the last round `wp-write-review` refuses red, so a reviewer that learned this only at submission time\n * would have written its findings for a re-review that never happens.\n */\n private finalRoundHeader(b: ReviewerBriefing): string[] {\n if (b.round < b.maxRounds) return [];\n return [\n 'THIS IS THE FINAL REVIEW ROUND. There is no re-review. You may NOT mark red.',\n 'Mark anything that must be fixed as ORANGE, with a concrete, actionable fix. The author will apply it',\n 'best effort and ship without another review, so put every finding in now.',\n '',\n ];\n }\n\n /**\n * The FIRST thing a reviewer does (issue #1051): ask the gate whether this checklist may still be\n * reviewed. An author agent can spawn a reviewer from this file long after the round budget is spent —\n * the measured deadlock did — so the file itself carries the check, and `wp-write-review` enforces it.\n */\n private budgetCheck(b: ReviewerBriefing): string[] {\n return [\n '## FIRST — confirm this review is within the round budget',\n '',\n `Before you read anything else, run: \\`pnpm ${WRITE_REVIEW_BIN} --checklist ${b.checklistId} --check\\``,\n '',\n `It confirms that round ${b.round} is within \\`maxReviewerRounds\\` (${b.maxRounds}) and that`,\n `\\`${b.checklistId}\\` has no verdict yet in this round. If it REFUSES, do not review this checklist and`,\n 'submit nothing for it: report its refusal verbatim to the agent that spawned you. `wp-write-review`',\n 'refuses an over-budget verdict anyway, so a review past the budget is wasted work that cannot be recorded.',\n '',\n ];\n }\n\n /** The absolute path of the reviewer agent's committed definition (`.claude/agents/<agentName>.md`). */\n agentFileFor(b: ReviewerBriefing): string {\n return path.join(b.repoRoot, '.claude', 'agents', `${b.agentName}.md`);\n }\n\n /**\n * Every PR that edits the review gate hits this: on the measured run, 5 of 8 changed files were the\n * reviewer agent files themselves, two reviewers reviewed their OWN definition, and neither flagged it —\n * neither had any guidance to. Detected by the tooling rather than left to the reviewer to notice.\n */\n private selfEditWarning(b: ReviewerBriefing): string[] {\n if (b.ownAgentFileInDiff === '') return [];\n return [\n '',\n `⚠️ THIS DIFF MODIFIES YOUR OWN AGENT FILE: \\`${b.ownAgentFileInDiff}\\``,\n 'You are reviewing a change to your own definition. Review it anyway — and state that fact in',\n '`output`, so a human reading your verdict knows the reviewer and the reviewed were the same thing.',\n ];\n }\n\n private checklistSection(b: ReviewerBriefing): string[] {\n if (b.docPath === '') {\n return ['## Your checklist', '', 'This checklist has no guidance doc — judge the diff on your own standards.', ''];\n }\n return ['## Your checklist', '', `Read this FIRST: \\`${b.docPath}\\``, ''];\n }\n\n /**\n * The change itself. The MANIFEST leads, and the per-file table with it; `ALL.diff` is demoted to one\n * option among several, recommended only where it is actually the right read.\n *\n * That ordering is the fix for a measured 4/4 failure. `ALL.diff` used to be bolded, first, and framed as\n * \"everything\", with the manifest one unbolded line below it called a \"path map\" — which reads like a\n * lookup aid, not something to open. All four reviewers on that PR read `ALL.diff`, none opened the\n * manifest, and none could therefore have established that the combined view was complete. Reviewers did\n * exactly what the emphasis told them to; so the emphasis moved.\n */\n private diffSection(b: ReviewerBriefing): string[] {\n const lines = ['## The change you are reviewing', ''];\n if (b.remediationOnly) {\n lines.push(\n 'This is a REMEDIATION-ONLY re-review. Verify the claimed fixes and inspect the remediation',\n 'delta for regressions; do not restart a full review of the original branch diff.',\n '',\n `Previous reviewer verdict (verbatim): \\`${b.previousVerdictPath}\\``,\n `Author remediation response: \\`${b.remediationPath}\\``,\n '',\n );\n }\n if (b.dirty) {\n lines.push('> ⚠️ This diff INCLUDES uncommitted and untracked work, so it is not what a');\n lines.push('> commit-to-commit range would show. Judge it anyway — it is what your checklist matched.');\n lines.push('');\n }\n lines.push(...this.manifestLines(b), ...this.basisLines(b), ...this.myFilesTable(b), ...this.allDiffLines(b));\n if (b.fileDiffCommand !== '') {\n lines.push(`Reproduce any single file: \\`${b.fileDiffCommand}\\``);\n lines.push('');\n }\n lines.push('Path matching is COARSE. Judge the change, not the path — if a matched file turns out to be');\n lines.push('irrelevant to your checklist, say so in one sentence and move on.');\n lines.push('');\n return lines;\n }\n\n /**\n * The manifest, named as the authority AND with its own headline facts inlined. Inlining them is the\n * point: a reviewer that never opens the manifest still learns whether anything was truncated or\n * excluded, which is the one thing it could not otherwise have known it was missing.\n */\n private manifestLines(b: ReviewerBriefing): string[] {\n if (b.manifestPath === '') return [];\n const warn = b.truncatedCount + b.excludedCount > 0 ? ' ⚠️ NOT everything is materialized — see the table.' : '';\n return [\n `**Path map — AUTHORITATIVE. Read this first:** \\`${b.manifestPath}\\``,\n ` ${b.changedFileCount} file(s) · ${b.truncatedCount} truncated · ${b.excludedCount} excluded${warn}`,\n ' Per file it carries: `status` (M/A/D/U/X), `bytes`, `file`/`fileAbs`, `diffFile`/`diffAbs`, and the',\n ' three shas below. It is the only place that records what was truncated or left out.',\n '',\n ];\n }\n\n /**\n * What the diff is taken AGAINST. Two bare shas in a `git diff` command said nothing about this, so a\n * reviewer could not tell a fork-point diff from a diff against main's current tip — and therefore could\n * not tell that anything merged to main since the fork is simply absent from what it is judging.\n * Rendering C beside A makes \"main has moved\" self-evident exactly when it has.\n */\n private basisLines(b: ReviewerBriefing): string[] {\n if (b.hashForkPoint === '') return [];\n const sameAsFork = b.hashMainHead === b.hashForkPoint;\n const cNote = b.hashMainHead === '' ? '(unresolved)'\n : sameAsFork ? `${b.hashMainHead} ← same as A, so main has not moved since the fork`\n : `${b.hashMainHead} ← main HAS MOVED since the fork`;\n return [\n 'This diff is **fork-point → feature-head**, NOT a diff against main\\'s current tip:',\n '```',\n `fork point (A) ${b.hashForkPoint}`,\n `feature head (B) ${b.hashFeatureHead}`,\n `main head (C) ${cNote}`,\n '```',\n 'Anything merged to main after A is NOT in this diff.',\n '',\n ];\n }\n\n /**\n * Source and diff get IDENTICAL affordance — an absolute path each, in adjacent columns. The previous\n * table gave an absolute path for the diff and nothing for the source, and the source went unread 4/4.\n */\n private myFilesTable(b: ReviewerBriefing): string[] {\n if (b.myFiles.length === 0) return ['_No files matched your patterns._', ''];\n const why = b.matchedPatterns.length === 0\n ? `**In scope: ALL ${b.myFiles.length} changed file(s)** — your checklist has no \\`patterns\\`, so the whole diff is yours.`\n : `**In scope: ${b.myFiles.length} file(s)** matching ${b.matchedPatterns.map((p: string): string => `\\`${p}\\``).join(', ')}:`;\n const rows = b.myFiles.map((f: BriefedFile): string => this.fileRow(f));\n return [why, '', '| file | status | its diff | full source |', '|---|---|---|---|', ...rows, ''];\n }\n\n /**\n * One row. A truncated or excluded diff is flagged HERE, in the row, not left as a field inside a file the\n * reviewer has to think to open — and an oversized diff states the line count that makes a single Read\n * come back silently incomplete.\n */\n private fileRow(f: BriefedFile): string {\n const flags: string[] = [];\n if (f.truncated) flags.push('⚠️ diff TRUNCATED — read the source');\n if (f.status === 'X') flags.push('⚠️ EXCLUDED, not materialized — read the source');\n const status = [`\\`${f.status}\\``, ...flags].join(' ');\n const source = f.sourcePath === '' ? '_deleted — no file on disk_' : `\\`${f.sourcePath}\\``;\n return `| \\`${f.file}\\` | ${status} | \\`${f.diffPath}\\` (${f.diffBytes} bytes) | ${source} |`;\n }\n\n /**\n * `ALL.diff`, recommended ONLY where it is the right read. It is kept — for a patternless reviewer on a\n * small diff it is genuinely one Read instead of N, which is why all four used it — but the blanket\n * \"everything on this branch\" line was wrong in two different ways at once: it invited a pattern-scoped\n * reviewer to spend its budget on files it was explicitly not asked about, and it pointed a reviewer on a\n * large PR at a file that cannot survive one Read.\n */\n private allDiffLines(b: ReviewerBriefing): string[] {\n if (b.allDiffPath === '') return [];\n const size = b.allDiffLines === 0 ? '' : ` — ${b.allDiffLines} lines / ${b.allDiffBytes} bytes`;\n if (b.matchedPatterns.length > 0) {\n return [`The whole branch${size}, for CROSS-FILE CONTEXT if you need it: \\`${b.allDiffPath}\\``,\n 'Your own files above are what you are reviewing; the rest of the branch is someone else\\'s checklist.', ''];\n }\n if (b.allDiffLines > ALL_DIFF_ONE_READ_LINES) {\n return [`⚠️ The combined diff is ${b.allDiffLines} lines and will NOT survive a single Read (the Read tool`,\n `truncates at ~${READ_TRUNCATION_LINES} lines, silently). Read the per-file diffs above instead, or page it:`,\n `\\`${b.allDiffPath}\\``, ''];\n }\n return [`Whole-branch diff${size} — convenient at this size, but the per-file table above is authoritative:`,\n `\\`${b.allDiffPath}\\``, ''];\n }\n\n /**\n * The rule that used to say \"when you need to\", and lost 4/4 to the more emphatic budget section 40 lines\n * later. \"When you need to\" delegates the judgment to a reviewer that, by construction, does not yet know\n * what it is missing. It has no opt-out now.\n */\n private sourceSection(b: ReviewerBriefing): string[] {\n const lines = ['## Read the full source — every file, every time', '', `Repo root: \\`${b.repoRoot}\\``, ''];\n lines.push('**READ THE FULL SOURCE OF EVERY FILE IN YOUR TABLE.** Not \"if you need to\" — every time.');\n lines.push('A hunk shows what changed; only the whole file shows what it changed INTO, and a change that');\n lines.push('looks fine in isolation can still be wrong in place.');\n lines.push('');\n lines.push('The `full source` column above is the path. For files marked `A` (added) you have already done');\n lines.push('this: an add-diff IS the complete file, byte for byte, so its diff and its source are the same');\n lines.push('text. For `M` (modified) and `D` (deleted) files the diff is a fragment — open the file.');\n lines.push('');\n if (b.sourceDirs.length > 0) {\n lines.push('The neighbouring code lives under:');\n for (const dir of b.sourceDirs) lines.push(`- \\`${dir}\\``);\n lines.push('');\n }\n return lines;\n }\n\n /**\n * The section that deletes the `node_modules` greps. Entries come from config, because the tooling\n * cannot guess that a repo keeps its queue names in terraform — but it CAN resolve where a package\n * installed to, and it must never drop an entry silently: a missing path is stated as missing.\n */\n private contextSection(b: ReviewerBriefing): string[] {\n // Emitting NOTHING made the section this class exists for look like a feature that does not exist.\n // One line naming the config keys costs nothing and is the only hint a repo will ever get.\n if (b.contextEntries.length === 0) {\n return ['## Pre-resolved context', '',\n '_None configured for this repo. If you find yourself hunting for the same path on every review,',\n 'it belongs in `pr-gate.reviewContext` / `pr-gate.reviewContextPackages` in `webpieces.config.json`._',\n ''];\n }\n const lines = ['## Pre-resolved context (do not go hunting for these)', ''];\n for (const entry of b.contextEntries) {\n const suffix = entry.note === '' ? '' : ` ${entry.note}`;\n lines.push(`- **${entry.label}** — \\`${entry.path === '' ? entry.note : entry.path}\\`${entry.path === '' ? '' : suffix}`);\n }\n lines.push('');\n return lines;\n }\n\n /**\n * The verdict shape, GENERATED — never restated in a hand-maintained file. `id` is pre-filled with this\n * reviewer's own checklist id so there is nothing to substitute and nothing to get wrong.\n */\n private verdictSection(b: ReviewerBriefing): string[] {\n return [\n '## Submit your verdict',\n '',\n `Submit EXACTLY this shape through \\`${this.reviewJsonService.submitCommand(b.checklistId)}\\` —`,\n 'the JSON on stdin (a heredoc is simplest), or `--file <path>` naming a scratch file. Do NOT write',\n `\\`${b.verdictPath}\\` yourself: the bin validates the verdict, writes that file, and records that YOU`,\n 'submitted it, and `wp-finish-upsert-pr` REJECTS a verdict file written any other way. The bin also',\n 'refuses the coordinating agent, so nobody can submit this on your behalf.',\n '',\n '```',\n this.reviewJsonService.renderVerdictSchema(b.checklistId, ''),\n '```',\n '',\n ];\n }\n\n /**\n * The anti-hunting rule, with the changed files carved out explicitly.\n *\n * It used to read as \"stay inside what you were given\" and, being the LAST thing in the file, it beat\n * the source-reading instruction 4 times out of 4. It never distinguished HUNTING — greps into\n * `node_modules`, re-deriving the dependency graph — from OPENING A FILE IT WAS EXPLICITLY HANDED. The\n * distinction is now stated, because where two instructions conflict the later and more emphatic one wins.\n */\n private budgetSection(): string[] {\n return [\n '## Budget',\n '',\n 'Do NOT search `node_modules`, do NOT re-derive the dependency graph, and do NOT hunt the repo for',\n 'infrastructure config. That is hunting, and it is what wastes a review budget — those paths are',\n 'either given above or were not configured.',\n '',\n 'Reading the full text of a file that is IN your table is NOT hunting — it is the review. Budget for',\n 'it: read the diff to see what changed, and the source to judge whether it is right in place.',\n '',\n 'If something you genuinely need is missing, name it in `output` and give your verdict on what you',\n 'could actually see.',\n '',\n 'Open your diff files before writing a verdict. `wp-finish-upsert-pr` reads your own transcript and',\n 'reports a verdict written without opening the diff. It also records the path of that transcript,',\n 'beside what you were offered and what you read, in `provenance.json` next to your verdict file —',\n 'so the review is auditable after the fact. You do not write that file, or the',\n '`review-round<N>-<id>.provenance.json` wp-write-review writes beside your verdict; the tooling does.',\n ];\n }\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import { AtomicFile } from '@webpieces/tooling-common';
2
2
  import { PackPolicyFilesResult } from './pack-policy-files';
3
- export declare const RULE_LOCK_FILE = ".webpieces/rules.lock.json";
4
- export declare const RULE_CATALOG_FILE = ".webpieces/instruct-ai/rules-catalog.md";
3
+ export declare const RULE_LOCK_FILE = ".webpieces-config/rules.lock.json";
4
+ export declare const RULE_CATALOG_FILE = ".webpieces-config/rules-catalog.md";
5
5
  export declare class RuleArtifactContents {
6
6
  readonly lock: string;
7
7
  readonly catalog: string;
@@ -7,8 +7,8 @@ const fs = tslib_1.__importStar(require("node:fs"));
7
7
  const repository_path_1 = require("./repository-path");
8
8
  const node_crypto_1 = require("node:crypto");
9
9
  const tooling_common_1 = require("@webpieces/tooling-common");
10
- exports.RULE_LOCK_FILE = '.webpieces/rules.lock.json';
11
- exports.RULE_CATALOG_FILE = '.webpieces/instruct-ai/rules-catalog.md';
10
+ exports.RULE_LOCK_FILE = '.webpieces-config/rules.lock.json';
11
+ exports.RULE_CATALOG_FILE = '.webpieces-config/rules-catalog.md';
12
12
  class LockedOwnedRule {
13
13
  id;
14
14
  schemaApiVersion;