@webpieces/rules-config 0.4.979 → 0.4.981

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webpieces/rules-config",
3
- "version": "0.4.979",
3
+ "version": "0.4.981",
4
4
  "description": "Shared webpieces.config.json loader. Single source of truth for validation rule configuration consumed by @webpieces/ai-hook-rules, @webpieces/code-rules, and @webpieces/nx-webpieces-rules.",
5
5
  "type": "commonjs",
6
6
  "main": "./src/index.js",
@@ -19,9 +19,9 @@
19
19
  "inversify": "7.10.4",
20
20
  "reflect-metadata": "0.2.2",
21
21
  "minimatch": "10.0.1",
22
- "@webpieces/tooling-common": "0.4.979",
23
- "@webpieces/repo-workflow-core": "0.4.979",
24
- "@webpieces/rules-sdk": "0.4.979"
22
+ "@webpieces/tooling-common": "0.4.981",
23
+ "@webpieces/repo-workflow-core": "0.4.981",
24
+ "@webpieces/rules-sdk": "0.4.981"
25
25
  },
26
26
  "author": "Dean Hiller",
27
27
  "license": "Apache-2.0",
@@ -34,7 +34,7 @@
34
34
  "access": "public"
35
35
  },
36
36
  "devDependencies": {
37
- "@webpieces/tooling-testkit": "0.4.979"
37
+ "@webpieces/tooling-testkit": "0.4.981"
38
38
  },
39
39
  "types": "./src/index.d.ts",
40
40
  "bin": {
package/src/constants.js CHANGED
@@ -26,7 +26,7 @@ exports.WEBPIECES_DISABLE = 'webpieces-disable';
26
26
  // to 30-day cleanup (the homes themselves, like hooks/ and instruct-ai/, are permanent).
27
27
  // The DIRECTORY NAME only. Never join it onto a root yourself — go through `DotWebpieces.shared()`
28
28
  // (repo-wide state), `DotWebpieces.local()` (this worktree's own tooling-written state) or
29
- // `DotWebpieces.aiWritable()` (this worktree's state that a CODING AGENT writes) so the call site
29
+ // `DotWebpieces.aiFacing()` (this worktree's state a CODING AGENT writes, or reads at a printed path) so the call site
30
30
  // declares its scope. In a linked worktree the three resolve to different places, and getting that
31
31
  // silently wrong is the bug those methods exist to prevent.
32
32
  exports.MERGE_INFO_DIR = 'merge-info';
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/constants.ts"],"names":[],"mappings":";AAAA,iFAAiF;AACjF,sEAAsE;AACtE,EAAE;AACF,yFAAyF;AACzF,qFAAqF;AACrF,kFAAkF;;;AA6ElF,gCAEC;AA7EY,QAAA,iBAAiB,GAAG,mBAAmB,CAAC;AAErD,kFAAkF;AAClF,uFAAuF;AACvF,uEAAuE;AACvE,sFAAsF;AAGtF,wFAAwF;AACxF,0FAA0F;AAC1F,sFAAsF;AACtF,0DAA0D;AAC1D,EAAE;AACF,mFAAmF;AACnF,uFAAuF;AACvF,0FAA0F;AAC1F,iGAAiG;AACjG,8FAA8F;AAC9F,yFAAyF;AACzF,mGAAmG;AACnG,2FAA2F;AAC3F,kGAAkG;AAClG,mGAAmG;AACnG,4DAA4D;AAC/C,QAAA,cAAc,GAAG,YAAY,CAAC;AAC3C,kGAAkG;AAClG,qGAAqG;AACrG,iCAAiC;AACpB,QAAA,sBAAsB,GAAG,wBAAwB,CAAC;AAE/D,uFAAuF;AACvF,qGAAqG;AACrG,8FAA8F;AAC9F,2DAA2D;AAC3D,EAAE;AACF,kGAAkG;AAClG,iGAAiG;AACjG,oGAAoG;AACpG,kGAAkG;AACrF,QAAA,mBAAmB,GAAG,2BAA2B,CAAC;AAE/D,2FAA2F;AAC3F,mFAAmF;AACnF,uFAAuF;AACvF,uGAAuG;AACvG,kGAAkG;AAClG,kGAAkG;AAClG,iDAAiD;AACpC,QAAA,sBAAsB,GAAG,sBAAsB,CAAC;AAE7D;;;;;;;;;GASG;AACU,QAAA,qBAAqB,GAAG,8BAA8B,CAAC;AAEpE;;;;GAIG;AACU,QAAA,oBAAoB,GAAG,sBAAsB,CAAC;AAE3D;;;;;GAKG;AACH,SAAgB,UAAU,CAAC,IAAY,EAAE,QAAgB;IACrD,OAAO,IAAI,CAAC,QAAQ,CAAC,yBAAiB,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACvE,CAAC","sourcesContent":["// Single source of truth for the disable-comment token and rule-name identifiers\n// shared across rules-config, ai-hook-rules, code-rules, and pr-gate.\n//\n// There is exactly ONE disable form: `// webpieces-disable <rule>[, <rule2>] -- reason`.\n// The legacy `ai-hook-disable` alias and the `-file`/`-next`/`-all` variants and the\n// `*`/bare (no-rule) wildcard have been removed — every disable MUST name a rule.\n\nexport const WEBPIECES_DISABLE = 'webpieces-disable';\n\n// Rule-name tokens as they appear AFTER `webpieces-disable` in a disable comment.\n// Values must match existing comments exactly — changing a value silently breaks every\n// disable that names that rule. Note MAX_LINES_MODIFIED is a prefix of\n// MAX_LINES_MODIFIED_FILES (a historical substring-match quirk preserved on purpose).\n\n\n// Merge-state convention shared by the pr-gate scripts (which WRITE the marker during a\n// conflicted 3-point merge) and the ai-hook-rules merge-in-progress-guard (which READS it\n// to block commit/push/PR until the merge is validated). Kept here so neither package\n// depends on the other — they only share this vocabulary.\n//\n// `.webpieces/` is the single working dir for all webpieces tooling: ai-hook-rules\n// bootstrap/cache, the instruct-ai docs, and the workflow state. To keep the top level\n// quiet, per-feature workflow dirs are nested one level down under `merge-info/<feature>`\n// and `pr-review/<feature>` rather than scattered as top-level `merge-<feature>`/`pr-<feature>`.\n// `.webpieces/` is gitignored; only the per-feature subdirs under those two homes are subject\n// to 30-day cleanup (the homes themselves, like hooks/ and instruct-ai/, are permanent).\n// The DIRECTORY NAME only. Never join it onto a root yourself — go through `DotWebpieces.shared()`\n// (repo-wide state), `DotWebpieces.local()` (this worktree's own tooling-written state) or\n// `DotWebpieces.aiWritable()` (this worktree's state that a CODING AGENT writes) so the call site\n// declares its scope. In a linked worktree the three resolve to different places, and getting that\n// silently wrong is the bug those methods exist to prevent.\nexport const MERGE_INFO_DIR = 'merge-info';\n// The PR working home. Renamed from the legacy `pr-info` to `pr-review` for clarity (it holds the\n// AI's PR review + rendered body). Old `pr-info/` dirs are gitignored local state and self-clear via\n// cleanTmp's legacy `pr-` sweep.\nexport const MERGE_IN_PROGRESS_FILE = 'merge-in-progress.json';\n\n// The dev-deploy resolve state file, written by `wp-push-dev --resolve` and cleared by\n// `wp-finish-push-dev` (or `--abort`). Named here for the same reason MERGE_IN_PROGRESS_FILE is: the\n// pr-gate commands WRITE it and things outside pr-gate READ it to decide whether a resolve is\n// half-finished, and neither side may depend on the other.\n//\n// It lives directly under `.webpieces/` local state (NOT under merge-info/), because a dev-deploy\n// resolve is not a 3-point merge: it never touches the feature branch, never produces merge-info\n// context, and must NOT be picked up by merge-in-progress-guard's marker scan — that guard's remedy\n// is `pnpm wp-finish-upsert-pr`, which is the wrong command here and would strand the tmp branch.\nexport const PUSH_DEV_STATE_FILE = 'push-dev-in-progress.json';\n\n// Proof-of-work the AI must produce for every conflicted file it resolves during a 3-point\n// merge: a short explanation written NEXT TO that file's 3-point context (the same\n// `updatemain-<safe_path>/` dir that holds A-forkpoint.txt / B-A.diff / C-A.diff). The\n// wp-finish-upsert-pr gate requires a non-empty file of this name per conflicted file before passing —\n// it is the only check on the part of the process the AI actually owns (resolving files). Using a\n// sidecar file (rather than an in-source comment) works for any file type, including comment-less\n// ones like JSON and files resolved by deletion.\nexport const MERGE_EXPLANATION_FILE = 'merge-explanation.md';\n\n/**\n * The command that MECHANICALLY strips every unknown key from webpieces.config.json.\n *\n * An unknown key controls nothing, so deleting it is the cure — but \"delete it\" is a judgement call made\n * while the guard denies every Bash call, which is exactly when a reader is least able to make one. This\n * command turns that judgement into one keystroke, and every message that reports an unknown key names it.\n *\n * Lives in this leaf module (no imports) so both the banner and the validators can name it without\n * importing the pruner and re-creating an import cycle.\n */\nexport const PRUNE_UNKNOWN_COMMAND = 'pnpm wp-prune-unknown-config';\n\n/**\n * The command that rewrites every webpieces-owned file a repo commits — the L0 hook shim and the generic\n * reviewer agent (`.claude/agents/webpieces-reviewer.md`). Named here, in the leaf module, so the config\n * validator that finds that agent missing can print the cure without importing ai-hook-rules.\n */\nexport const UPGRADE_SHIM_COMMAND = 'pnpm wp-upgrade-shim';\n\n/**\n * Fast predicate: does this text carry a webpieces-disable for the given rule?\n * Line-agnostic — the caller decides which line(s) or block of text to feed it.\n * This is the cheap substring form used by code-rules detection and pr-gate's\n * dashboard grep/count. (ai-hook-rules uses a richer line-mapping parser.)\n */\nexport function hasDisable(text: string, ruleName: string): boolean {\n return text.includes(WEBPIECES_DISABLE) && text.includes(ruleName);\n}\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/constants.ts"],"names":[],"mappings":";AAAA,iFAAiF;AACjF,sEAAsE;AACtE,EAAE;AACF,yFAAyF;AACzF,qFAAqF;AACrF,kFAAkF;;;AA6ElF,gCAEC;AA7EY,QAAA,iBAAiB,GAAG,mBAAmB,CAAC;AAErD,kFAAkF;AAClF,uFAAuF;AACvF,uEAAuE;AACvE,sFAAsF;AAGtF,wFAAwF;AACxF,0FAA0F;AAC1F,sFAAsF;AACtF,0DAA0D;AAC1D,EAAE;AACF,mFAAmF;AACnF,uFAAuF;AACvF,0FAA0F;AAC1F,iGAAiG;AACjG,8FAA8F;AAC9F,yFAAyF;AACzF,mGAAmG;AACnG,2FAA2F;AAC3F,uHAAuH;AACvH,mGAAmG;AACnG,4DAA4D;AAC/C,QAAA,cAAc,GAAG,YAAY,CAAC;AAC3C,kGAAkG;AAClG,qGAAqG;AACrG,iCAAiC;AACpB,QAAA,sBAAsB,GAAG,wBAAwB,CAAC;AAE/D,uFAAuF;AACvF,qGAAqG;AACrG,8FAA8F;AAC9F,2DAA2D;AAC3D,EAAE;AACF,kGAAkG;AAClG,iGAAiG;AACjG,oGAAoG;AACpG,kGAAkG;AACrF,QAAA,mBAAmB,GAAG,2BAA2B,CAAC;AAE/D,2FAA2F;AAC3F,mFAAmF;AACnF,uFAAuF;AACvF,uGAAuG;AACvG,kGAAkG;AAClG,kGAAkG;AAClG,iDAAiD;AACpC,QAAA,sBAAsB,GAAG,sBAAsB,CAAC;AAE7D;;;;;;;;;GASG;AACU,QAAA,qBAAqB,GAAG,8BAA8B,CAAC;AAEpE;;;;GAIG;AACU,QAAA,oBAAoB,GAAG,sBAAsB,CAAC;AAE3D;;;;;GAKG;AACH,SAAgB,UAAU,CAAC,IAAY,EAAE,QAAgB;IACrD,OAAO,IAAI,CAAC,QAAQ,CAAC,yBAAiB,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACvE,CAAC","sourcesContent":["// Single source of truth for the disable-comment token and rule-name identifiers\n// shared across rules-config, ai-hook-rules, code-rules, and pr-gate.\n//\n// There is exactly ONE disable form: `// webpieces-disable <rule>[, <rule2>] -- reason`.\n// The legacy `ai-hook-disable` alias and the `-file`/`-next`/`-all` variants and the\n// `*`/bare (no-rule) wildcard have been removed — every disable MUST name a rule.\n\nexport const WEBPIECES_DISABLE = 'webpieces-disable';\n\n// Rule-name tokens as they appear AFTER `webpieces-disable` in a disable comment.\n// Values must match existing comments exactly — changing a value silently breaks every\n// disable that names that rule. Note MAX_LINES_MODIFIED is a prefix of\n// MAX_LINES_MODIFIED_FILES (a historical substring-match quirk preserved on purpose).\n\n\n// Merge-state convention shared by the pr-gate scripts (which WRITE the marker during a\n// conflicted 3-point merge) and the ai-hook-rules merge-in-progress-guard (which READS it\n// to block commit/push/PR until the merge is validated). Kept here so neither package\n// depends on the other — they only share this vocabulary.\n//\n// `.webpieces/` is the single working dir for all webpieces tooling: ai-hook-rules\n// bootstrap/cache, the instruct-ai docs, and the workflow state. To keep the top level\n// quiet, per-feature workflow dirs are nested one level down under `merge-info/<feature>`\n// and `pr-review/<feature>` rather than scattered as top-level `merge-<feature>`/`pr-<feature>`.\n// `.webpieces/` is gitignored; only the per-feature subdirs under those two homes are subject\n// to 30-day cleanup (the homes themselves, like hooks/ and instruct-ai/, are permanent).\n// The DIRECTORY NAME only. Never join it onto a root yourself — go through `DotWebpieces.shared()`\n// (repo-wide state), `DotWebpieces.local()` (this worktree's own tooling-written state) or\n// `DotWebpieces.aiFacing()` (this worktree's state a CODING AGENT writes, or reads at a printed path) so the call site\n// declares its scope. In a linked worktree the three resolve to different places, and getting that\n// silently wrong is the bug those methods exist to prevent.\nexport const MERGE_INFO_DIR = 'merge-info';\n// The PR working home. Renamed from the legacy `pr-info` to `pr-review` for clarity (it holds the\n// AI's PR review + rendered body). Old `pr-info/` dirs are gitignored local state and self-clear via\n// cleanTmp's legacy `pr-` sweep.\nexport const MERGE_IN_PROGRESS_FILE = 'merge-in-progress.json';\n\n// The dev-deploy resolve state file, written by `wp-push-dev --resolve` and cleared by\n// `wp-finish-push-dev` (or `--abort`). Named here for the same reason MERGE_IN_PROGRESS_FILE is: the\n// pr-gate commands WRITE it and things outside pr-gate READ it to decide whether a resolve is\n// half-finished, and neither side may depend on the other.\n//\n// It lives directly under `.webpieces/` local state (NOT under merge-info/), because a dev-deploy\n// resolve is not a 3-point merge: it never touches the feature branch, never produces merge-info\n// context, and must NOT be picked up by merge-in-progress-guard's marker scan — that guard's remedy\n// is `pnpm wp-finish-upsert-pr`, which is the wrong command here and would strand the tmp branch.\nexport const PUSH_DEV_STATE_FILE = 'push-dev-in-progress.json';\n\n// Proof-of-work the AI must produce for every conflicted file it resolves during a 3-point\n// merge: a short explanation written NEXT TO that file's 3-point context (the same\n// `updatemain-<safe_path>/` dir that holds A-forkpoint.txt / B-A.diff / C-A.diff). The\n// wp-finish-upsert-pr gate requires a non-empty file of this name per conflicted file before passing —\n// it is the only check on the part of the process the AI actually owns (resolving files). Using a\n// sidecar file (rather than an in-source comment) works for any file type, including comment-less\n// ones like JSON and files resolved by deletion.\nexport const MERGE_EXPLANATION_FILE = 'merge-explanation.md';\n\n/**\n * The command that MECHANICALLY strips every unknown key from webpieces.config.json.\n *\n * An unknown key controls nothing, so deleting it is the cure — but \"delete it\" is a judgement call made\n * while the guard denies every Bash call, which is exactly when a reader is least able to make one. This\n * command turns that judgement into one keystroke, and every message that reports an unknown key names it.\n *\n * Lives in this leaf module (no imports) so both the banner and the validators can name it without\n * importing the pruner and re-creating an import cycle.\n */\nexport const PRUNE_UNKNOWN_COMMAND = 'pnpm wp-prune-unknown-config';\n\n/**\n * The command that rewrites every webpieces-owned file a repo commits — the L0 hook shim and the generic\n * reviewer agent (`.claude/agents/webpieces-reviewer.md`). Named here, in the leaf module, so the config\n * validator that finds that agent missing can print the cure without importing ai-hook-rules.\n */\nexport const UPGRADE_SHIM_COMMAND = 'pnpm wp-upgrade-shim';\n\n/**\n * Fast predicate: does this text carry a webpieces-disable for the given rule?\n * Line-agnostic — the caller decides which line(s) or block of text to feed it.\n * This is the cheap substring form used by code-rules detection and pr-gate's\n * dashboard grep/count. (ai-hook-rules uses a richer line-mapping parser.)\n */\nexport function hasDisable(text: string, ruleName: string): boolean {\n return text.includes(WEBPIECES_DISABLE) && text.includes(ruleName);\n}\n"]}
@@ -4,7 +4,7 @@ export declare const SCRATCH_DIR_NAME = "scratch";
4
4
  /**
5
5
  * Creates short-lived scratch directories under this worktree's `.webpieces/` scope.
6
6
  *
7
- * `local()` (not `aiWritable()`) is the right scope: these files are written by the TOOLING, never by an
7
+ * `local()` (not `aiFacing()`) is the right scope: these files are written by the TOOLING, never by an
8
8
  * agent, and `local()` keeps them under the primary clone so they outlive a reaped worktree exactly like
9
9
  * the gate logs beside them.
10
10
  */
@@ -26,7 +26,7 @@ exports.SCRATCH_DIR_NAME = 'scratch';
26
26
  /**
27
27
  * Creates short-lived scratch directories under this worktree's `.webpieces/` scope.
28
28
  *
29
- * `local()` (not `aiWritable()`) is the right scope: these files are written by the TOOLING, never by an
29
+ * `local()` (not `aiFacing()`) is the right scope: these files are written by the TOOLING, never by an
30
30
  * agent, and `local()` keeps them under the primary clone so they outlive a reaped worktree exactly like
31
31
  * the gate logs beside them.
32
32
  */
@@ -1 +1 @@
1
- {"version":3,"file":"repo-scratch-dirs.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/repo-scratch-dirs.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;AAC7B,yCAA2D;AAC3D,8DAAuE;AAEvE,8EAA8E;AAC9E,+EAA+E;AAC/E,EAAE;AACF,0GAA0G;AAC1G,yGAAyG;AACzG,uGAAuG;AACvG,kGAAkG;AAClG,sFAAsF;AACtF,EAAE;AACF,iGAAiG;AACjG,oGAAoG;AACpG,oGAAoG;AACpG,oGAAoG;AACpG,WAAW;AACX,8EAA8E;AAE9E,kGAAkG;AACrF,QAAA,gBAAgB,GAAG,SAAS,CAAC;AAE1C;;;;;;GAMG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAe;IACK;IAA7B,YAA6B,SAAuB,6BAAY;QAAnC,WAAM,GAAN,MAAM,CAA6B;IAAG,CAAC;IAEpE;;;;OAIG;IACH,IAAI,CAAC,QAAgB,EAAE,MAAc;QACjC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,wBAAgB,CAAC,CAAC;QACtE,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACxC,OAAO,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IACnD,CAAC;CACJ,CAAA;AAbY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEA,6BAAY;GADxC,eAAe,CAa3B","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { DotWebpieces, dotWebpieces } from '@webpieces/tooling-common';\n\n// ---------------------------------------------------------------------------\n// SHORT-LIVED RUNTIME SCRATCH FILES BELONG IN `.webpieces/`, NOT IN `$TMPDIR`.\n//\n// Two `wp-*` code paths needed a path on disk for the length of one subprocess call — the squash body for\n// `gh pr merge --body-file`, and the nx graph dump — and both reached for `os.tmpdir()`. Neither has the\n// reason that justifies `$TMPDIR` for a SPEC fixture (see `spec-temp-dirs.ts`): they are not isolating\n// themselves from the developer's `$HOME`, and they do not `git init` inside themselves. They are\n// ordinary gate state, and every other piece of gate state lives under `.webpieces/`.\n//\n// Putting them there is not tidiness — it is what gives them an OWNER. `CleanTmp` already sweeps\n// `DotWebpieces.local()` on a 30-day retention at the end of every merge/PR flow, so a scratch file\n// written here is reaped by a mechanism that already exists and is already tested. The same file in\n// `$TMPDIR` had no owner at all, which is how 4,222 `wp-merge-body-` directories accumulated on one\n// machine.\n// ---------------------------------------------------------------------------\n\n/** The subdirectory of the per-worktree `.webpieces` scope that holds throwaway runtime files. */\nexport const SCRATCH_DIR_NAME = 'scratch';\n\n/**\n * Creates short-lived scratch directories under this worktree's `.webpieces/` scope.\n *\n * `local()` (not `aiWritable()`) is the right scope: these files are written by the TOOLING, never by an\n * agent, and `local()` keeps them under the primary clone so they outlive a reaped worktree exactly like\n * the gate logs beside them.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class RepoScratchDirs {\n constructor(private readonly dotDir: DotWebpieces = dotWebpieces) {}\n\n /**\n * `fs.mkdtempSync` under `<.webpieces scope>/scratch/`, creating the parent if this is the first call.\n *\n * `prefix` keeps the `wp-<area>-` convention, so a leftover names the code path that wrote it.\n */\n make(repoRoot: string, prefix: string): string {\n const base = path.join(this.dotDir.local(repoRoot), SCRATCH_DIR_NAME);\n fs.mkdirSync(base, { recursive: true });\n return fs.mkdtempSync(path.join(base, prefix));\n }\n}\n"]}
1
+ {"version":3,"file":"repo-scratch-dirs.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/repo-scratch-dirs.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;AAC7B,yCAA2D;AAC3D,8DAAuE;AAEvE,8EAA8E;AAC9E,+EAA+E;AAC/E,EAAE;AACF,0GAA0G;AAC1G,yGAAyG;AACzG,uGAAuG;AACvG,kGAAkG;AAClG,sFAAsF;AACtF,EAAE;AACF,iGAAiG;AACjG,oGAAoG;AACpG,oGAAoG;AACpG,oGAAoG;AACpG,WAAW;AACX,8EAA8E;AAE9E,kGAAkG;AACrF,QAAA,gBAAgB,GAAG,SAAS,CAAC;AAE1C;;;;;;GAMG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAe;IACK;IAA7B,YAA6B,SAAuB,6BAAY;QAAnC,WAAM,GAAN,MAAM,CAA6B;IAAG,CAAC;IAEpE;;;;OAIG;IACH,IAAI,CAAC,QAAgB,EAAE,MAAc;QACjC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,wBAAgB,CAAC,CAAC;QACtE,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACxC,OAAO,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IACnD,CAAC;CACJ,CAAA;AAbY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEA,6BAAY;GADxC,eAAe,CAa3B","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { DotWebpieces, dotWebpieces } from '@webpieces/tooling-common';\n\n// ---------------------------------------------------------------------------\n// SHORT-LIVED RUNTIME SCRATCH FILES BELONG IN `.webpieces/`, NOT IN `$TMPDIR`.\n//\n// Two `wp-*` code paths needed a path on disk for the length of one subprocess call — the squash body for\n// `gh pr merge --body-file`, and the nx graph dump — and both reached for `os.tmpdir()`. Neither has the\n// reason that justifies `$TMPDIR` for a SPEC fixture (see `spec-temp-dirs.ts`): they are not isolating\n// themselves from the developer's `$HOME`, and they do not `git init` inside themselves. They are\n// ordinary gate state, and every other piece of gate state lives under `.webpieces/`.\n//\n// Putting them there is not tidiness — it is what gives them an OWNER. `CleanTmp` already sweeps\n// `DotWebpieces.local()` on a 30-day retention at the end of every merge/PR flow, so a scratch file\n// written here is reaped by a mechanism that already exists and is already tested. The same file in\n// `$TMPDIR` had no owner at all, which is how 4,222 `wp-merge-body-` directories accumulated on one\n// machine.\n// ---------------------------------------------------------------------------\n\n/** The subdirectory of the per-worktree `.webpieces` scope that holds throwaway runtime files. */\nexport const SCRATCH_DIR_NAME = 'scratch';\n\n/**\n * Creates short-lived scratch directories under this worktree's `.webpieces/` scope.\n *\n * `local()` (not `aiFacing()`) is the right scope: these files are written by the TOOLING, never by an\n * agent, and `local()` keeps them under the primary clone so they outlive a reaped worktree exactly like\n * the gate logs beside them.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class RepoScratchDirs {\n constructor(private readonly dotDir: DotWebpieces = dotWebpieces) {}\n\n /**\n * `fs.mkdtempSync` under `<.webpieces scope>/scratch/`, creating the parent if this is the first call.\n *\n * `prefix` keeps the `wp-<area>-` convention, so a leftover names the code path that wrote it.\n */\n make(repoRoot: string, prefix: string): string {\n const base = path.join(this.dotDir.local(repoRoot), SCRATCH_DIR_NAME);\n fs.mkdirSync(base, { recursive: true });\n return fs.mkdtempSync(path.join(base, prefix));\n }\n}\n"]}
@@ -69,9 +69,9 @@ let ReviewJsonService = class ReviewJsonService {
69
69
  // not local() — an agent AUTHORS summary.json here, and each reviewer subagent authors its own
70
70
  // review-round<N>-<id>.json beside it. A worktree-isolated agent's Write is refused for any path under the
71
71
  // shared checkout, which is where local() puts this, so local() made both files unwritable by the
72
- // very agents the flow instructs to write them. See DotWebpieces.aiWritable() for the full account.
72
+ // very agents the flow instructs to write them. See DotWebpieces.aiFacing() for the full account.
73
73
  prDirFor(repoRoot, featureName) {
74
- return this.dotDir.aiWritableFile(repoRoot, tooling_common_1.PR_REVIEW_DIR, featureName);
74
+ return this.dotDir.aiFacingFile(repoRoot, tooling_common_1.PR_REVIEW_DIR, featureName);
75
75
  }
76
76
  // Absolute path of the summary.json for a feature — beside pr-body.md, keyed by branch name.
77
77
  summaryJsonPath(repoRoot, featureName) {
@@ -1 +1 @@
1
- {"version":3,"file":"review-json.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/review-json.ts"],"names":[],"mappings":";;;AAqrBA,4BAEC;AAGD,0CAEC;AAGD,sDAEC;;AAjsBD,+CAAyB;AACzB,mDAA6B;AAC7B,mCAAoC;AACpC,yCAA2D;AAC3D,8DAA0D;AAC1D,8DAAuE;AACvE,8DAA0D;AAC1D,iEAA6D;AAC7D,iFAA2E;AAC3E,uEAAkE;AAClE,uEAAkE;AAClE,6DAA6G;AAyBpG,kGAzBA,sCAAiB,OAyBA;AAAE,yGAzBA,6CAAwB,OAyBA;AAAE,yGAzBA,6CAAwB,OAyBA;AAxB9E,yDAqB4B;AAKxB,8FAzBA,gCAAa,OAyBA;AACb,+FAzBA,iCAAc,OAyBA;AACd,+FAzBA,iCAAc,OAyBA;AACd,4FAzBA,8BAAW,OAyBA;AACX,iGAzBA,mCAAgB,OAyBA;AAChB,gGAzBA,kCAAe,OAyBA;AACf,kGAzBA,oCAAiB,OAyBA;AACjB,uGAzBA,yCAAsB,OAyBA;AACtB,0FAzBA,4BAAS,OAyBA;AACT,+FAzBA,iCAAc,OAyBA;AACd,wFAzBA,0BAAO,OAyBA;AACP,wFAzBA,0BAAO,OAyBA;AACP,8FAzBA,gCAAa,OAyBA;AACb,gGAzBA,kCAAe,OAyBA;AACf,0FAzBA,4BAAS,OAyBA;AACT,wFAzBA,0BAAO,OAyBA;AACP,2FAzBA,6BAAU,OAyBA;AACV,8FAzBA,gCAAa,OAyBA;AACb,iGAzBA,mCAAgB,OAyBA;AAChB,0FAzBA,4BAAS,OAyBA;AAGb,MAAM,WAAW,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAU,CAAC;AACxD,MAAM,eAAe,GAA2B,EA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BAAO,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;AA7lBY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGR,6BAAY;QACT,6CAAwB;GAH/C,iBAAiB,CA6lB7B;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 { AddressedIssuesParser } from './addressed-issues-parser';\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 AddressedIssue,\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 AddressedIssue,\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 const addressesIssues = new AddressedIssuesParser().parse(raw['addressesIssues'], 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']), addressesIssues, 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":";;;AAqrBA,4BAEC;AAGD,0CAEC;AAGD,sDAEC;;AAjsBD,+CAAyB;AACzB,mDAA6B;AAC7B,mCAAoC;AACpC,yCAA2D;AAC3D,8DAA0D;AAC1D,8DAAuE;AACvE,8DAA0D;AAC1D,iEAA6D;AAC7D,iFAA2E;AAC3E,uEAAkE;AAClE,uEAAkE;AAClE,6DAA6G;AAyBpG,kGAzBA,sCAAiB,OAyBA;AAAE,yGAzBA,6CAAwB,OAyBA;AAAE,yGAzBA,6CAAwB,OAyBA;AAxB9E,yDAqB4B;AAKxB,8FAzBA,gCAAa,OAyBA;AACb,+FAzBA,iCAAc,OAyBA;AACd,+FAzBA,iCAAc,OAyBA;AACd,4FAzBA,8BAAW,OAyBA;AACX,iGAzBA,mCAAgB,OAyBA;AAChB,gGAzBA,kCAAe,OAyBA;AACf,kGAzBA,oCAAiB,OAyBA;AACjB,uGAzBA,yCAAsB,OAyBA;AACtB,0FAzBA,4BAAS,OAyBA;AACT,+FAzBA,iCAAc,OAyBA;AACd,wFAzBA,0BAAO,OAyBA;AACP,wFAzBA,0BAAO,OAyBA;AACP,8FAzBA,gCAAa,OAyBA;AACb,gGAzBA,kCAAe,OAyBA;AACf,0FAzBA,4BAAS,OAyBA;AACT,wFAzBA,0BAAO,OAyBA;AACP,2FAzBA,6BAAU,OAyBA;AACV,8FAzBA,gCAAa,OAyBA;AACb,iGAzBA,mCAAgB,OAyBA;AAChB,0FAzBA,4BAAS,OAyBA;AAGb,MAAM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AG,CAA4B,CAAC;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;AA7lBY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGR,6BAAY;QACT,6CAAwB;GAH/C,iBAAiB,CA6lB7B;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 { AddressedIssuesParser } from './addressed-issues-parser';\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 AddressedIssue,\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 AddressedIssue,\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.aiFacing() for the full account.\n prDirFor(repoRoot: string, featureName: string): string {\n return this.dotDir.aiFacingFile(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 const addressesIssues = new AddressedIssuesParser().parse(raw['addressesIssues'], 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']), addressesIssues, 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"]}
@@ -11,33 +11,45 @@ by running the build again.
11
11
 
12
12
  **Read the log at the absolute path the `FullLog :` line of THIS run printed.**
13
13
 
14
- Every run — success or failure — ends with two lines:
14
+ Every run prints that line FIRST, before it does any work:
15
+
16
+ ```
17
+ FullLog : /abs/path/to/build.log
18
+ ```
19
+
20
+ and — success or failure — ends with it again:
15
21
 
16
22
  ```
17
23
  FullLog : /abs/path/to/build.log
18
24
  (a second line, naming that log's `.bak` — the previous run is rotated aside on every build)
19
25
  ```
20
26
 
27
+ `pnpm wp-review-upsert-pr` and `pnpm wp-finish-upsert-pr` open the same way, with the path of the log
28
+ their own console goes to, and print the build's `FullLog :` line again when their build starts.
29
+
30
+ Running one of these commands in the background is fine. If you do, read the path from that first line
31
+ and grep that file — never your harness's own captured output, which you may not be allowed to read.
32
+
21
33
  Copy that path. `grep -n error "<the FullLog path>"` always works. A path typed from memory does not:
22
34
  it either greps a file from some other tree or greps nothing at all and reports "no matches", which
23
35
  reads exactly like a clean build.
24
36
 
25
37
  ## WHY A REMEMBERED PATH IS WRONG MORE OFTEN THAN IT IS RIGHT
26
38
 
27
- webpieces state is worktree-namespaced **inside the primary clone**, not duplicated per worktree:
39
+ The logs land inside the checkout the command ran in, in its own gitignored state directory:
28
40
 
29
41
  | where you are standing | where `wp-build` writes |
30
42
  |---|---|
31
- | the primary clone | `build.log` in the primary clone's state directory |
32
- | a linked worktree (the normal case for a subagent) | `build.log` in that worktree's namespace inside the PRIMARY clone's state directory |
43
+ | the primary clone | `logs/build.log` in the primary clone's state directory |
44
+ | a linked worktree (the normal case for a subagent) | `logs/build.log` in that WORKTREE's own state directory — inside the worktree, so an agent confined to it can read it |
33
45
 
34
- A `build.log` relative to a linked worktree's own root **does not exist at all**. Those two rows are
35
- an illustration of why you read the printed path — they are not a lookup table to memorise, and the
36
- namespacing scheme is webpieces' to change.
46
+ A path remembered from another tree, or from an older release, points at somebody else's build or at
47
+ nothing. Those two rows are an illustration of why you read the printed path — they are not a lookup
48
+ table to memorise, and the layout is webpieces' to change.
37
49
 
38
- The PR gate's own build stages use a different name again — `logs/build-gate-<stage>-<branch>-<sha>.log`
39
- — precisely because two stages can build the same commit and neither may overwrite the other's evidence.
40
- Nobody types those names either. The failure message prints them.
50
+ The PR gate's own build stages use a different name again — `build-gate-<stage>-<branch>-<sha>.log`,
51
+ beside it — precisely because two stages can build the same commit and neither may overwrite the other's
52
+ evidence. Nobody types those names either. Each run prints its own.
41
53
 
42
54
  ## WHAT THE CONSOLE GIVES YOU WHILE IT RUNS
43
55