@webpieces/rules-config 0.4.916 → 0.4.918

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/package.json +5 -5
  2. package/src/aged-tree-sweep.d.ts +2 -2
  3. package/src/aged-tree-sweep.js +2 -2
  4. package/src/aged-tree-sweep.js.map +1 -1
  5. package/src/build-log-doc.d.ts +1 -1
  6. package/src/build-log-doc.js +3 -3
  7. package/src/build-log-doc.js.map +1 -1
  8. package/src/builds-log.d.ts +2 -2
  9. package/src/builds-log.js +2 -2
  10. package/src/builds-log.js.map +1 -1
  11. package/src/checklist-override.d.ts +1 -1
  12. package/src/checklist-override.js +1 -1
  13. package/src/checklist-override.js.map +1 -1
  14. package/src/config-error-banner.js +1 -1
  15. package/src/config-error-banner.js.map +1 -1
  16. package/src/constants.js +3 -3
  17. package/src/constants.js.map +1 -1
  18. package/src/exclude-hook-paths.d.ts +5 -5
  19. package/src/exclude-hook-paths.js +5 -5
  20. package/src/exclude-hook-paths.js.map +1 -1
  21. package/src/exclude-paths.d.ts +1 -1
  22. package/src/exclude-paths.js +1 -1
  23. package/src/exclude-paths.js.map +1 -1
  24. package/src/hook-fault-codes.js.map +1 -1
  25. package/src/index.js +5 -5
  26. package/src/index.js.map +1 -1
  27. package/src/instruct-ai-docs.d.ts +3 -3
  28. package/src/instruct-ai-docs.js +3 -3
  29. package/src/instruct-ai-docs.js.map +1 -1
  30. package/src/legacy-config-upgrade.js +2 -2
  31. package/src/legacy-config-upgrade.js.map +1 -1
  32. package/src/load-template.d.ts +1 -1
  33. package/src/load-template.js +2 -2
  34. package/src/load-template.js.map +1 -1
  35. package/src/merge-process-doc.d.ts +1 -1
  36. package/src/merge-process-doc.js +2 -2
  37. package/src/merge-process-doc.js.map +1 -1
  38. package/src/migrate-dirs-cli.js +1 -1
  39. package/src/migrate-dirs-cli.js.map +1 -1
  40. package/src/orphan-dir-archive.d.ts +4 -4
  41. package/src/orphan-dir-archive.js +4 -4
  42. package/src/orphan-dir-archive.js.map +1 -1
  43. package/src/orphan-dir-scan.d.ts +1 -1
  44. package/src/orphan-dir-scan.js +1 -1
  45. package/src/orphan-dir-scan.js.map +1 -1
  46. package/src/orphan-dir-sweep.js +1 -1
  47. package/src/orphan-dir-sweep.js.map +1 -1
  48. package/src/policy-tracking.js +5 -8
  49. package/src/policy-tracking.js.map +1 -1
  50. package/src/pr-gate-config.d.ts +1 -1
  51. package/src/pr-gate-config.js +1 -1
  52. package/src/pr-gate-config.js.map +1 -1
  53. package/src/repo-root.d.ts +7 -7
  54. package/src/repo-root.js +8 -8
  55. package/src/repo-root.js.map +1 -1
  56. package/src/repo-scratch-dirs.d.ts +3 -3
  57. package/src/repo-scratch-dirs.js +5 -5
  58. package/src/repo-scratch-dirs.js.map +1 -1
  59. package/src/review-json-data.js +2 -2
  60. package/src/review-json-data.js.map +1 -1
  61. package/src/review-json.js +1 -1
  62. package/src/review-json.js.map +1 -1
  63. package/src/reviewer-instructions.d.ts +1 -1
  64. package/src/reviewer-instructions.js +1 -1
  65. package/src/reviewer-instructions.js.map +1 -1
  66. package/src/stale-bin-sweep.js +1 -1
  67. package/src/stale-bin-sweep.js.map +1 -1
  68. package/src/subagent-provenance.d.ts +6 -6
  69. package/src/subagent-provenance.js +6 -6
  70. package/src/subagent-provenance.js.map +1 -1
  71. package/src/sync-flow-guidance.js +1 -1
  72. package/src/sync-flow-guidance.js.map +1 -1
  73. package/templates/webpieces.branch-state-matrix.md +2 -2
  74. package/templates/webpieces.buildlog.md +3 -3
  75. package/templates/webpieces.ci-gate-setup.md +2 -2
  76. package/templates/webpieces.git-workflow.md +8 -9
  77. package/templates/webpieces.location-matrix.md +10 -10
  78. package/templates/webpieces.review-checklists.md +3 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webpieces/rules-config",
3
- "version": "0.4.916",
3
+ "version": "0.4.918",
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.916",
23
- "@webpieces/repo-workflow-core": "0.4.916",
24
- "@webpieces/rules-sdk": "0.4.916"
22
+ "@webpieces/tooling-common": "0.4.918",
23
+ "@webpieces/repo-workflow-core": "0.4.918",
24
+ "@webpieces/rules-sdk": "0.4.918"
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.916"
37
+ "@webpieces/tooling-testkit": "0.4.918"
38
38
  },
39
39
  "types": "./src/index.d.ts",
40
40
  "bin": {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * How long a file survives an AGED-TREE SWEEP without being rewritten — the policy `cleanTmp` applies
3
- * to `{repo}/.webpieces-logs`.
3
+ * to `{repo}/.webpieces`.
4
4
  *
5
5
  * It is NOT the only root webpieces writes under, though this comment used to say so: scratch trees go
6
6
  * to `os.tmpdir()` as well, on a much shorter cutoff and through `TmpScratchSweeper`. See that file.
@@ -22,7 +22,7 @@ export declare class SweepCount {
22
22
  /**
23
23
  * The 30-day depth-first reap, as ONE implementation.
24
24
  *
25
- * It was written inside `CleanTmp` for `<primary>/.webpieces-logs`, and extracted here when a second root
25
+ * It was written inside `CleanTmp` for `<primary>/.webpieces`, and extracted here when a second root
26
26
  * (the machine-global PR-body store) needed the identical policy. That second root is gone — the gated
27
27
  * merge body is the PR's own description now, see `decisions/0005` — so today there is one caller. The
28
28
  * loop stays extracted anyway: it is the sweep policy, testable on its own root, and `CleanTmp` reads
@@ -7,7 +7,7 @@ const path = tslib_1.__importStar(require("path"));
7
7
  const inversify_1 = require("inversify");
8
8
  /**
9
9
  * How long a file survives an AGED-TREE SWEEP without being rewritten — the policy `cleanTmp` applies
10
- * to `{repo}/.webpieces-logs`.
10
+ * to `{repo}/.webpieces`.
11
11
  *
12
12
  * It is NOT the only root webpieces writes under, though this comment used to say so: scratch trees go
13
13
  * to `os.tmpdir()` as well, on a much shorter cutoff and through `TmpScratchSweeper`. See that file.
@@ -38,7 +38,7 @@ exports.SweepCount = SweepCount;
38
38
  /**
39
39
  * The 30-day depth-first reap, as ONE implementation.
40
40
  *
41
- * It was written inside `CleanTmp` for `<primary>/.webpieces-logs`, and extracted here when a second root
41
+ * It was written inside `CleanTmp` for `<primary>/.webpieces`, and extracted here when a second root
42
42
  * (the machine-global PR-body store) needed the identical policy. That second root is gone — the gated
43
43
  * merge body is the PR's own description now, see `decisions/0005` — so today there is one caller. The
44
44
  * loop stays extracted anyway: it is the sweep policy, testable on its own root, and `CleanTmp` reads
@@ -1 +1 @@
1
- {"version":3,"file":"aged-tree-sweep.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/aged-tree-sweep.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;AAC7B,yCAA2D;AAE3D;;;;;;;;;;;GAWG;AACU,QAAA,cAAc,GAAG,EAAE,CAAC;AAEjC,wGAAwG;AACxG,MAAa,UAAU;IACnB,KAAK,CAAS;IACd,IAAI,CAAS;IAEb,YAAY,KAAK,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC;QAC3B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;IAED,GAAG,CAAC,KAAiB;QACjB,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC;QAC1B,IAAI,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC;IAC5B,CAAC;IAED,IAAI,KAAK;QACL,OAAO,IAAI,CAAC,KAAK,KAAK,CAAC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CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;gBACtB,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC;YACrB,CAAC;QACL,CAAC;QACD,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC9C,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YAClB,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YACpB,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC;QACpB,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ,CAAA;AAtCY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;GAC5B,eAAe,CAsC3B","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { injectable, bindingScopeValues } from 'inversify';\n\n/**\n * How long a file survives an AGED-TREE SWEEP without being rewritten — the policy `cleanTmp` applies\n * to `{repo}/.webpieces-logs`.\n *\n * It is NOT the only root webpieces writes under, though this comment used to say so: scratch trees go\n * to `os.tmpdir()` as well, on a much shorter cutoff and through `TmpScratchSweeper`. See that file.\n *\n * NOT the same knob as `DEFAULT_RETENTION_DAYS` in review-provenance.ts, which happens to be 30 as well.\n * That one is a CONFIGURABLE ceiling on reviewer transcripts, overridable per repo in settings; this one\n * is the fixed sweep cutoff and nothing reads it from config. Same number today, different decisions,\n * so folding them would couple a repo's transcript-retention preference to when scratch dirs are reaped.\n */\nexport const RETENTION_DAYS = 30;\n\n/** What one sweep reaped: files deleted for age, and directories pruned because they ended up empty. */\nexport class SweepCount {\n files: number;\n dirs: number;\n\n constructor(files = 0, dirs = 0) {\n this.files = files;\n this.dirs = dirs;\n }\n\n add(other: SweepCount): void {\n this.files += other.files;\n this.dirs += other.dirs;\n }\n\n get empty(): boolean {\n return this.files === 0 && this.dirs === 0;\n }\n}\n\n/**\n * The 30-day depth-first reap, as ONE implementation.\n *\n * It was written inside `CleanTmp` for `<primary>/.webpieces-logs`, and extracted here when a second root\n * (the machine-global PR-body store) needed the identical policy. That second root is gone — the gated\n * merge body is the PR's own description now, see `decisions/0005` — so today there is one caller. The\n * loop stays extracted anyway: it is the sweep policy, testable on its own root, and `CleanTmp` reads\n * as the command it is rather than as a deletion algorithm.\n *\n * `onDelete` is a reporter, not a policy hook: it is told what was removed AFTER the decision, so a\n * caller can print a line and cannot change the outcome.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class AgedTreeSweeper {\n /**\n * Delete every file under `root` older than `cutoffMs`, then prune every directory left empty.\n * `root` itself is swept INTO but never removed — every writer `mkdirSync`s its target, so an empty\n * root is harmless, whereas removing it can race a concurrent writer.\n *\n * A missing `root` is a no-op, not an error.\n */\n sweep(root: string, cutoffMs: number, onDelete: (removed: string, isDir: boolean) => void = (): void => {}): SweepCount {\n if (!fs.existsSync(root)) return new SweepCount();\n return this.walk(root, Date.now(), cutoffMs, true, onDelete);\n }\n\n // Depth-first, POST-order: children first, so a directory whose last file just aged out is seen as\n // empty on the way back up and pruned in the same pass.\n // eslint-disable-next-line @typescript-eslint/max-params\n private walk(dir: string, now: number, cutoffMs: number, isRoot: boolean, onDelete: (removed: string, isDir: boolean) => void): SweepCount {\n const count = new SweepCount();\n for (const entry of fs.readdirSync(dir)) {\n const full = path.join(dir, entry);\n // lstat, never stat: a symlink is a leaf that ages out like a file and is NEVER followed, so\n // a sweep can never wander outside `dir` or delete somebody else's file through a link.\n const stat = fs.lstatSync(full);\n if (stat.isDirectory()) {\n count.add(this.walk(full, now, cutoffMs, false, onDelete));\n } else if (now - stat.mtimeMs >= cutoffMs) {\n fs.rmSync(full, { force: true });\n onDelete(full, false);\n count.files += 1;\n }\n }\n if (!isRoot && fs.readdirSync(dir).length === 0) {\n fs.rmdirSync(dir);\n onDelete(dir, true);\n count.dirs += 1;\n }\n return count;\n }\n}\n"]}
1
+ {"version":3,"file":"aged-tree-sweep.js","sourceRo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KAAK,IAAI,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC;YACtC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YACnC,6FAA6F;YAC7F,wFAAwF;YACxF,MAAM,IAAI,GAAG,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;YAChC,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;gBACrB,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;YAC/D,CAAC;iBAAM,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,IAAI,QAAQ,EAAE,CAAC;gBACxC,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;gBACjC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;gBACtB,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC;YACrB,CAAC;QACL,CAAC;QACD,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC9C,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YAClB,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YACpB,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC;QACpB,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ,CAAA;AAtCY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;GAC5B,eAAe,CAsC3B","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { injectable, bindingScopeValues } from 'inversify';\n\n/**\n * How long a file survives an AGED-TREE SWEEP without being rewritten — the policy `cleanTmp` applies\n * to `{repo}/.webpieces`.\n *\n * It is NOT the only root webpieces writes under, though this comment used to say so: scratch trees go\n * to `os.tmpdir()` as well, on a much shorter cutoff and through `TmpScratchSweeper`. See that file.\n *\n * NOT the same knob as `DEFAULT_RETENTION_DAYS` in review-provenance.ts, which happens to be 30 as well.\n * That one is a CONFIGURABLE ceiling on reviewer transcripts, overridable per repo in settings; this one\n * is the fixed sweep cutoff and nothing reads it from config. Same number today, different decisions,\n * so folding them would couple a repo's transcript-retention preference to when scratch dirs are reaped.\n */\nexport const RETENTION_DAYS = 30;\n\n/** What one sweep reaped: files deleted for age, and directories pruned because they ended up empty. */\nexport class SweepCount {\n files: number;\n dirs: number;\n\n constructor(files = 0, dirs = 0) {\n this.files = files;\n this.dirs = dirs;\n }\n\n add(other: SweepCount): void {\n this.files += other.files;\n this.dirs += other.dirs;\n }\n\n get empty(): boolean {\n return this.files === 0 && this.dirs === 0;\n }\n}\n\n/**\n * The 30-day depth-first reap, as ONE implementation.\n *\n * It was written inside `CleanTmp` for `<primary>/.webpieces`, and extracted here when a second root\n * (the machine-global PR-body store) needed the identical policy. That second root is gone — the gated\n * merge body is the PR's own description now, see `decisions/0005` — so today there is one caller. The\n * loop stays extracted anyway: it is the sweep policy, testable on its own root, and `CleanTmp` reads\n * as the command it is rather than as a deletion algorithm.\n *\n * `onDelete` is a reporter, not a policy hook: it is told what was removed AFTER the decision, so a\n * caller can print a line and cannot change the outcome.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class AgedTreeSweeper {\n /**\n * Delete every file under `root` older than `cutoffMs`, then prune every directory left empty.\n * `root` itself is swept INTO but never removed — every writer `mkdirSync`s its target, so an empty\n * root is harmless, whereas removing it can race a concurrent writer.\n *\n * A missing `root` is a no-op, not an error.\n */\n sweep(root: string, cutoffMs: number, onDelete: (removed: string, isDir: boolean) => void = (): void => {}): SweepCount {\n if (!fs.existsSync(root)) return new SweepCount();\n return this.walk(root, Date.now(), cutoffMs, true, onDelete);\n }\n\n // Depth-first, POST-order: children first, so a directory whose last file just aged out is seen as\n // empty on the way back up and pruned in the same pass.\n // eslint-disable-next-line @typescript-eslint/max-params\n private walk(dir: string, now: number, cutoffMs: number, isRoot: boolean, onDelete: (removed: string, isDir: boolean) => void): SweepCount {\n const count = new SweepCount();\n for (const entry of fs.readdirSync(dir)) {\n const full = path.join(dir, entry);\n // lstat, never stat: a symlink is a leaf that ages out like a file and is NEVER followed, so\n // a sweep can never wander outside `dir` or delete somebody else's file through a link.\n const stat = fs.lstatSync(full);\n if (stat.isDirectory()) {\n count.add(this.walk(full, now, cutoffMs, false, onDelete));\n } else if (now - stat.mtimeMs >= cutoffMs) {\n fs.rmSync(full, { force: true });\n onDelete(full, false);\n count.files += 1;\n }\n }\n if (!isRoot && fs.readdirSync(dir).length === 0) {\n fs.rmdirSync(dir);\n onDelete(dir, true);\n count.dirs += 1;\n }\n return count;\n }\n}\n"]}
@@ -1,2 +1,2 @@
1
- /** The rules-config template name, and the file name it lands under in `.webpieces-logs/instruct-ai/`. */
1
+ /** The rules-config template name, and the file name it lands under in `.webpieces/instruct-ai/`. */
2
2
  export declare const BUILD_LOG_DOC = "webpieces.buildlog.md";
@@ -4,9 +4,9 @@
4
4
  //
5
5
  // WHY THIS IS A GENERATED DOC AND NOT A PARAGRAPH IN A REPO'S CLAUDE.md. The rule "read the absolute
6
6
  // `FullLog :` path THIS run printed" was written into webpieces-ts's own CLAUDE.md and stopped there.
7
- // A fleet audit then found three consumer repos still naming a bare `.webpieces-logs/build.log` on their
7
+ // A fleet audit then found three consumer repos still naming a bare `.webpieces/build.log` on their
8
8
  // own `origin/main` — one of them zero commits behind, so staleness was not the explanation — while
9
- // their real logs sat in `.webpieces-logs/worktrees/<name>/build.log`. Hand-copied guidance does not
9
+ // their real logs sat in `.webpieces/worktrees/<name>/build.log`. Hand-copied guidance does not
10
10
  // propagate; a webpieces PR cannot edit a consumer's CLAUDE.md, and should not.
11
11
  //
12
12
  // Generated guidance does propagate: this doc rides git-workflow.md's link closure, so every repo
@@ -16,6 +16,6 @@
16
16
  // ---------------------------------------------------------------------------
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.BUILD_LOG_DOC = void 0;
19
- /** The rules-config template name, and the file name it lands under in `.webpieces-logs/instruct-ai/`. */
19
+ /** The rules-config template name, and the file name it lands under in `.webpieces/instruct-ai/`. */
20
20
  exports.BUILD_LOG_DOC = 'webpieces.buildlog.md';
21
21
  //# sourceMappingURL=build-log-doc.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"build-log-doc.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/build-log-doc.ts"],"names":[],"mappings":";AAAA,8EAA8E;AAC9E,kEAAkE;AAClE,EAAE;AACF,qGAAqG;AACrG,sGAAsG;AACtG,yGAAyG;AACzG,oGAAoG;AACpG,qGAAqG;AACrG,gFAAgF;AAChF,EAAE;AACF,kGAAkG;AAClG,sFAAsF;AACtF,iDAAiD;AACjD,6DAA6D;AAC7D,8EAA8E;;;AAE9E,0GAA0G;AAC7F,QAAA,aAAa,GAAG,uBAAuB,CAAC","sourcesContent":["// ---------------------------------------------------------------------------\n// `webpieces.buildlog.md` — where the build's output actually is.\n//\n// WHY THIS IS A GENERATED DOC AND NOT A PARAGRAPH IN A REPO'S CLAUDE.md. The rule \"read the absolute\n// `FullLog :` path THIS run printed\" was written into webpieces-ts's own CLAUDE.md and stopped there.\n// A fleet audit then found three consumer repos still naming a bare `.webpieces-logs/build.log` on their\n// own `origin/main` — one of them zero commits behind, so staleness was not the explanation — while\n// their real logs sat in `.webpieces-logs/worktrees/<name>/build.log`. Hand-copied guidance does not\n// propagate; a webpieces PR cannot edit a consumer's CLAUDE.md, and should not.\n//\n// Generated guidance does propagate: this doc rides git-workflow.md's link closure, so every repo\n// receives the corrected wording on its next `wp-*` command. That is the corollary in\n// `.claude/rules/no-backwards-compat.md` applied\n// to itself — name the tool, let the tool print the details.\n// ---------------------------------------------------------------------------\n\n/** The rules-config template name, and the file name it lands under in `.webpieces-logs/instruct-ai/`. */\nexport const BUILD_LOG_DOC = 'webpieces.buildlog.md';\n"]}
1
+ {"version":3,"file":"build-log-doc.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/build-log-doc.ts"],"names":[],"mappings":";AAAA,8EAA8E;AAC9E,kEAAkE;AAClE,EAAE;AACF,qGAAqG;AACrG,sGAAsG;AACtG,oGAAoG;AACpG,oGAAoG;AACpG,gGAAgG;AAChG,gFAAgF;AAChF,EAAE;AACF,kGAAkG;AAClG,sFAAsF;AACtF,iDAAiD;AACjD,6DAA6D;AAC7D,8EAA8E;;;AAE9E,qGAAqG;AACxF,QAAA,aAAa,GAAG,uBAAuB,CAAC","sourcesContent":["// ---------------------------------------------------------------------------\n// `webpieces.buildlog.md` — where the build's output actually is.\n//\n// WHY THIS IS A GENERATED DOC AND NOT A PARAGRAPH IN A REPO'S CLAUDE.md. The rule \"read the absolute\n// `FullLog :` path THIS run printed\" was written into webpieces-ts's own CLAUDE.md and stopped there.\n// A fleet audit then found three consumer repos still naming a bare `.webpieces/build.log` on their\n// own `origin/main` — one of them zero commits behind, so staleness was not the explanation — while\n// their real logs sat in `.webpieces/worktrees/<name>/build.log`. Hand-copied guidance does not\n// propagate; a webpieces PR cannot edit a consumer's CLAUDE.md, and should not.\n//\n// Generated guidance does propagate: this doc rides git-workflow.md's link closure, so every repo\n// receives the corrected wording on its next `wp-*` command. That is the corollary in\n// `.claude/rules/no-backwards-compat.md` applied\n// to itself — name the tool, let the tool print the details.\n// ---------------------------------------------------------------------------\n\n/** The rules-config template name, and the file name it lands under in `.webpieces/instruct-ai/`. */\nexport const BUILD_LOG_DOC = 'webpieces.buildlog.md';\n"]}
@@ -4,12 +4,12 @@ import { DotWebpieces } from '@webpieces/tooling-common';
4
4
  *
5
5
  * ─── WHY THIS ONE FILE LIVES OUTSIDE THE REPO ─────────────────────────────────────────────────────────
6
6
  * `no-machine-global-state.spec.ts` records the standing rule: webpieces writes state under
7
- * `{repo}/.webpieces-logs` and nowhere else. This is the ONE carve-out, and the argument is written out in
7
+ * `{repo}/.webpieces` and nowhere else. This is the ONE carve-out, and the argument is written out in
8
8
  * `decisions/0006-the-build-ledger-is-machine-global.md`. In short:
9
9
  *
10
10
  * • The FACT is machine-scoped. "How many builds are burning this box's CPU right now" is not a
11
11
  * property of any repo; it is a property of the machine. A per-repo ledger cannot answer it — every
12
- * linked worktree has its OWN `.webpieces-logs/`, so it would be blind to the sibling worktree it is
12
+ * linked worktree has its OWN `.webpieces/`, so it would be blind to the sibling worktree it is
13
13
  * actually contending with, never mind the four other repos on the disk.
14
14
  * • It is NOT A CACHE. The retired `PrBodyStore` that the no-machine-global rule was written for was a
15
15
  * local copy of a fact GitHub owned, so it could be stale, missing, or on the wrong computer. There
package/src/builds-log.js CHANGED
@@ -16,12 +16,12 @@ const to_error_1 = require("@webpieces/tooling-common/to-error");
16
16
  *
17
17
  * ─── WHY THIS ONE FILE LIVES OUTSIDE THE REPO ─────────────────────────────────────────────────────────
18
18
  * `no-machine-global-state.spec.ts` records the standing rule: webpieces writes state under
19
- * `{repo}/.webpieces-logs` and nowhere else. This is the ONE carve-out, and the argument is written out in
19
+ * `{repo}/.webpieces` and nowhere else. This is the ONE carve-out, and the argument is written out in
20
20
  * `decisions/0006-the-build-ledger-is-machine-global.md`. In short:
21
21
  *
22
22
  * • The FACT is machine-scoped. "How many builds are burning this box's CPU right now" is not a
23
23
  * property of any repo; it is a property of the machine. A per-repo ledger cannot answer it — every
24
- * linked worktree has its OWN `.webpieces-logs/`, so it would be blind to the sibling worktree it is
24
+ * linked worktree has its OWN `.webpieces/`, so it would be blind to the sibling worktree it is
25
25
  * actually contending with, never mind the four other repos on the disk.
26
26
  * • It is NOT A CACHE. The retired `PrBodyStore` that the no-machine-global rule was written for was a
27
27
  * local copy of a fact GitHub owned, so it could be stale, missing, or on the wrong computer. There
@@ -1 +1 @@
1
- {"version":3,"file":"builds-log.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/builds-log.ts"],"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ypto';\nimport * as fs from 'fs';\nimport * as os from 'os';\nimport * as path from 'path';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { DotWebpieces } from '@webpieces/tooling-common';\nimport { HOME_CONFIG_DIR } from './home-config';\nimport { toError } from '@webpieces/tooling-common/to-error';\n\n/**\n * `~/.webpieces/builds.log` — the MACHINE-WIDE, append-only ledger of every build this box has started.\n *\n * ─── WHY THIS ONE FILE LIVES OUTSIDE THE REPO ─────────────────────────────────────────────────────────\n * `no-machine-global-state.spec.ts` records the standing rule: webpieces writes state under\n * `{repo}/.webpieces-logs` and nowhere else. This is the ONE carve-out, and the argument is written out in\n * `decisions/0006-the-build-ledger-is-machine-global.md`. In short:\n *\n * • The FACT is machine-scoped. \"How many builds are burning this box's CPU right now\" is not a\n * property of any repo; it is a property of the machine. A per-repo ledger cannot answer it — every\n * linked worktree has its OWN `.webpieces-logs/`, so it would be blind to the sibling worktree it is\n * actually contending with, never mind the four other repos on the disk.\n * • It is NOT A CACHE. The retired `PrBodyStore` that the no-machine-global rule was written for was a\n * local copy of a fact GitHub owned, so it could be stale, missing, or on the wrong computer. There\n * is no remote copy of this. The file IS the fact.\n * • Its key is an ABSOLUTE LOCAL PATH, which is stable precisely because it never leaves the machine —\n * the instability that killed `PrBodyStore`'s `<host>/<owner>/<repo>` key cannot arise here.\n *\n * ─── WHY IT IS SAFE TO WRITE CONCURRENTLY ─────────────────────────────────────────────────────────────\n * Rows are deliberately kept under `MAX_ROW_BYTES` (512, macOS `PIPE_BUF`). A single `O_APPEND`\n * `write(2)` at or below that size is indivisible, so two builds appending at the same instant cannot\n * interleave halves of a line. The lock is therefore belt-and-braces for the APPEND and genuinely\n * load-bearing for ROTATION, where a rename-and-reopen really does race.\n *\n * ─── IT MAY NEVER FAIL A BUILD ────────────────────────────────────────────────────────────────────────\n * Every method here is best-effort and swallows its own errors. A build must never die because a log\n * file was busy, unwritable, or on a full disk. Lock acquisition retries and then gives up and appends\n * anyway — which the row-size invariant above makes safe.\n */\nexport const BUILDS_LOG_FILE = 'builds.log';\nexport const BUILDS_LOCK_FILE = 'builds.log.lock';\n\n/** START, and the two terminal kinds. `DONE-` is the greppable prefix that pairs with a START. */\nexport const BUILD_START = 'START';\nexport const BUILD_DONE_SUCCESS = 'DONE-SUCCESS';\nexport const BUILD_DONE_FAIL = 'DONE-FAIL';\n\n/** Rotate at 1 MB, keeping five generations (`.1` … `.5`); the old `.5` is dropped. */\nexport const MAX_BUILDS_LOG_BYTES = 1024 * 1024;\nexport const BUILDS_LOG_GENERATIONS = 5;\n\n/**\n * macOS `PIPE_BUF`. A row at or under this size is written by ONE indivisible `write(2)`, which is what\n * makes a lost lock a non-event rather than a corrupted file. Long paths are clipped to hold the line\n * under it — see `clip`.\n */\nexport const MAX_ROW_BYTES = 512;\n\n/** How long a build may hold the lock before another writer stops waiting and appends anyway. */\nconst LOCK_RETRY_MS = 50;\nconst LOCK_TIMEOUT_MS = 2000;\n\n/**\n * The handle a START row hands back, and the ONLY thing `finish()` accepts. Data-only (a class, per\n * CLAUDE.md), carrying exactly the fields the DONE row needs to pair itself with its START: the uuid,\n * the caller, the repo, and when it began (so `took=` is computed from one clock, not two).\n */\nexport class BuildTicket {\n id: string;\n by: string;\n repo: string;\n startedMs: number;\n\n constructor(id: string, by: string, repo: string, startedMs: number) {\n this.id = id;\n this.by = by;\n this.repo = repo;\n this.startedMs = startedMs;\n }\n}\n\n/**\n * How the build process ended. Node reports a null code when a signal ended the process, so collapsing\n * this to a number would discard the only useful explanation for an otherwise silent build failure.\n * Data-only: the PR gate decides which CLI exit code to return, while the ledger records these raw facts.\n */\nexport class BuildTermination {\n code: number | null;\n signal: string | null;\n\n constructor(code: number | null, signal: string | null) {\n this.code = code;\n this.signal = signal;\n }\n}\n\n/**\n * One build that is STILL RUNNING — a START row with no matching `DONE-`, whose pid is still alive.\n * Data-only. This is what the refusal message renders, so it carries the three things a reader needs to\n * recognise the build in question: where it is, which tree, and how old it is.\n */\nexport class RunningBuild {\n id: string;\n by: string;\n repo: string;\n tree: string;\n cwd: string;\n branch: string;\n pid: number;\n startedMs: number;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n id: string, by: string, repo: string, tree: string,\n cwd: string, branch: string, pid: number, startedMs: number,\n ) {\n this.id = id;\n this.by = by;\n this.repo = repo;\n this.tree = tree;\n this.cwd = cwd;\n this.branch = branch;\n this.pid = pid;\n this.startedMs = startedMs;\n }\n}\n\n/**\n * The ledger. See the file docblock for why it is machine-global and why every operation swallows its\n * own errors.\n *\n * `homeDir` is a parameter on every public method, defaulted to `os.homedir()`, for exactly the reason\n * `HomeConfigService.configPath` takes one: a spec must be able to exercise the real code against a temp\n * directory and must never touch the developer's actual `~/.webpieces`.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class BuildsLog {\n constructor(private readonly dotDir: DotWebpieces) {}\n\n /** `~/.webpieces/builds.log`. */\n logPath(homeDir: string = os.homedir()): string {\n return path.join(homeDir, HOME_CONFIG_DIR, BUILDS_LOG_FILE);\n }\n\n /** `~/.webpieces/builds.log.lock` — `{\"pid\":N,\"started\":<epochMs>}`. */\n lockPath(homeDir: string = os.homedir()): string {\n return path.join(homeDir, HOME_CONFIG_DIR, BUILDS_LOCK_FILE);\n }\n\n /** `~/.webpieces/builds.log.<n>` — generation `n`, 1 being the most recent. */\n rotatedPath(generation: number, homeDir: string = os.homedir()): string {\n return `${this.logPath(homeDir)}.${String(generation)}`;\n }\n\n /**\n * Record that a build is starting, and hand back the ticket its DONE row will need.\n *\n * `by` is the CALLER — `BuildGateOptions.stage`, i.e. `build` | `review` | `finish`. There is no\n * second \"caller\" concept anywhere: the stage id already is one, and a second spelling of it would\n * be the shim `.claude/rules/no-backwards-compat.md` rejects.\n *\n * Returns a ticket even when the append failed. A build whose START row never landed still has to be\n * able to call `finish()`; the alternative is a nullable return that every call site must branch on\n * for a logging failure that is, by policy, not an error.\n */\n start(by: string, startDir: string, homeDir: string = os.homedir()): BuildTicket {\n const ticket = new BuildTicket(\n crypto.randomUUID(), by, this.dotDir.primaryRoot(startDir), Date.now());\n this.append(this.startRow(ticket, startDir), homeDir);\n return ticket;\n }\n\n /**\n * Record that the build behind `ticket` has ended. Only code 0 with no signal writes `DONE-SUCCESS`;\n * anything else writes `DONE-FAIL` carrying the raw code and signal, so a killed build does not become\n * an unexplained generic exit 1 in the machine record.\n */\n finish(ticket: BuildTicket, termination: BuildTermination, homeDir: string = os.homedir()): void {\n this.append(this.doneRow(ticket, termination), homeDir);\n }\n\n /**\n * Every build that is still live: a `START` with no matching `DONE-` row, whose pid is still alive.\n *\n * The pid filter is not an optimisation, it is what keeps the ledger from wedging the machine. A\n * build killed with SIGKILL — an agent cancelled mid-run, a terminal closed — writes no DONE row, so\n * without the liveness test its START would count forever and the fourth build would be refused for\n * the rest of the machine's life. The uuid answers \"which build\"; the pid answers \"is it still real\".\n *\n * Only the CURRENT generation is read. A rotated-away START is by definition at least 1 MB of rows\n * old and is not a build anyone is contending with.\n */\n running(homeDir: string = os.homedir()): RunningBuild[] {\n const lines = this.readLines(this.logPath(homeDir));\n const done = new Set<string>();\n for (const line of lines) {\n if (line.startsWith(`${BUILD_DONE_SUCCESS}\\t`) || line.startsWith(`${BUILD_DONE_FAIL}\\t`)) {\n done.add(this.field(line, 'id'));\n }\n }\n const live: RunningBuild[] = [];\n for (const line of lines) {\n if (!line.startsWith(`${BUILD_START}\\t`)) continue;\n const build = this.toRunningBuild(line);\n if (build === null || done.has(build.id)) continue;\n if (!this.isAlive(build.pid)) continue;\n live.push(build);\n }\n return live;\n }\n\n /**\n * The `@webpieces` release ACTUALLY EXECUTING — found by walking UP from this module's own directory\n * to the nearest enclosing `node_modules/@webpieces/<pkg>/package.json`. `''` when this code is\n * running from source rather than from an installed package (which is the state in this repo's own\n * specs, and a perfectly ordinary answer).\n *\n * ─── WHY THIS IS NOT `WebpiecesVersions.readInstalled(root)` ──────────────────────────────────────\n * They answer DIFFERENT QUESTIONS and merging them would break the older one. `readInstalled` joins\n * `<root>/node_modules/@webpieces/...` at a FIXED tree root ON PURPOSE: its whole job is to detect\n * DRIFT between what a tree PINS and what some other tree pins, and a walk-up would silently resolve\n * a worktree with no install of its own to the primary clone's copy — hiding exactly the skew that\n * guard exists to catch. This question is the opposite one: \"whichever copy is running, name it\", and\n * for that the walk-up is the only correct answer. Do not fold them together.\n */\n executingVersion(): string {\n let dir = __dirname;\n for (let hops = 0; hops < 40; hops += 1) {\n const version = this.versionOfEnclosingPackage(dir);\n if (version !== '') return version;\n const parent = path.dirname(dir);\n if (parent === dir) return '';\n dir = parent;\n }\n return '';\n }\n\n // `<dir>` is `node_modules/@webpieces/<pkg>/...`? Then that package's version, else ''.\n private versionOfEnclosingPackage(dir: string): string {\n const parent = path.dirname(dir);\n const grandparent = path.dirname(parent);\n if (path.basename(parent) !== '@webpieces' || path.basename(grandparent) !== 'node_modules') return '';\n const text = this.readTextOrEmpty(path.join(dir, 'package.json'));\n const match = /\"version\"\\s*:\\s*\"([^\"]+)\"/.exec(text);\n return match === null ? '' : match[1];\n }\n\n // ─── ROW RENDERING ────────────────────────────────────────────────────────────────────────────────\n\n private startRow(ticket: BuildTicket, startDir: string): string {\n return [\n BUILD_START,\n `id=${ticket.id}`,\n `t=${new Date(ticket.startedMs).toISOString()}`,\n `ms=${String(ticket.startedMs)}`,\n `by=${ticket.by}`,\n `repo=${this.clip(ticket.repo)}`,\n `tree=${this.dotDir.worktreeName(startDir) || 'primary'}`,\n `cwd=${this.clip(startDir)}`,\n `branch=${this.gitBranch(startDir)}`,\n `pid=${String(process.pid)}`,\n `wp=${this.executingVersion()}`,\n ].join('\\t');\n }\n\n private doneRow(ticket: BuildTicket, termination: BuildTermination): string {\n const now = Date.now();\n const success = termination.code === 0 && termination.signal === null;\n const fields = [\n success ? BUILD_DONE_SUCCESS : BUILD_DONE_FAIL,\n `id=${ticket.id}`,\n `t=${new Date(now).toISOString()}`,\n `ms=${String(now)}`,\n `by=${ticket.by}`,\n `repo=${this.clip(ticket.repo)}`,\n `took=${String(now - ticket.startedMs)}`,\n ];\n if (!success) fields.push(`exit=${termination.code === null ? 'null' : String(termination.code)}`);\n if (termination.signal !== null) fields.push(`signal=${this.clip(termination.signal)}`);\n fields.push(`pid=${String(process.pid)}`);\n return fields.join('\\t');\n }\n\n /**\n * Hold a long path down to `max` characters by keeping its TAIL, which is the half that identifies\n * the tree; a clipped value is marked with a leading `…` so nobody mistakes it for a real path.\n *\n * This is what keeps a row under `MAX_ROW_BYTES` — see the file docblock. `append` re-checks the\n * assembled line as a backstop, because three clipped fields plus a long branch name can still add up.\n */\n private clip(value: string, max = 120): string {\n const oneLine = value.replace(/[\\t\\n\\r]/g, ' ');\n return oneLine.length <= max ? oneLine : `…${oneLine.slice(oneLine.length - max)}`;\n }\n\n // ─── ROW PARSING ──────────────────────────────────────────────────────────────────────────────────\n\n /** The value of `<name>=` on a TSV row, or '' when the row does not carry it. */\n private field(line: string, name: string): string {\n for (const part of line.split('\\t')) {\n if (part.startsWith(`${name}=`)) return part.slice(name.length + 1);\n }\n return '';\n }\n\n // A START row as a RunningBuild, or null when it is missing the two fields that make it usable.\n private toRunningBuild(line: string): RunningBuild | null {\n const id = this.field(line, 'id');\n const pid = Number.parseInt(this.field(line, 'pid'), 10);\n if (id === '' || !Number.isInteger(pid) || pid <= 0) return null;\n const startedMs = Number.parseInt(this.field(line, 'ms'), 10);\n return new RunningBuild(\n id, this.field(line, 'by'), this.field(line, 'repo'), this.field(line, 'tree'),\n this.field(line, 'cwd'), this.field(line, 'branch'), pid,\n Number.isInteger(startedMs) ? startedMs : 0,\n );\n }\n\n /**\n * Is `pid` still addressable? `process.kill(pid, 0)` sends no signal — it only asks the kernel. ESRCH\n * is the ONE answer that proves death; EPERM proves the opposite (it exists, it is somebody else's).\n * Pid reuse is an accepted imprecision here: being wrong in the \"still running\" direction costs\n * one extra refusal, being wrong the other way lets a fourth build start.\n *\n * WHY A PID IS MEANINGFUL HERE AND WAS NOT FOR AGENT WORKTREE LOCKS. Every row in this ledger is\n * written BY the process it names — one real OS process per build — so its pid identifies it.\n * A Claude Code subagent is not a process at all: every agent in a session records the SAME pid,\n * the session's, which is why that check was deleted rather than shared (see\n * harness-agent-activity.ts). Do not generalise this one back out to anything but a real process.\n */\n private isAlive(pid: number): boolean {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n process.kill(pid, 0);\n return true;\n } catch (err: unknown) {\n const error = toError(err);\n return (error as NodeJS.ErrnoException).code !== 'ESRCH';\n }\n }\n\n // ─── APPEND, LOCK, ROTATE ─────────────────────────────────────────────────────────────────────────\n\n /**\n * Append one row, best-effort. Takes the lock so rotation cannot race, and appends ANYWAY when the\n * lock cannot be had within `LOCK_TIMEOUT_MS` — the row is under `PIPE_BUF`, so an unlocked\n * `O_APPEND` write is still indivisible, and a build must never die because a log file was busy.\n */\n private append(row: string, homeDir: string): void {\n const line = `${this.truncateToRowLimit(row)}\\n`;\n const held = this.tryAcquireLock(homeDir);\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n this.ensureDir(this.logPath(homeDir));\n if (held) this.rotateIfLarge(homeDir);\n fs.appendFileSync(this.logPath(homeDir), line);\n } catch (err: unknown) {\n const error = toError(err);\n void error; // logging may never fail a build — see the file docblock\n } finally {\n if (held) this.releaseLock(homeDir);\n }\n }\n\n // The backstop for the PIPE_BUF invariant, measured in BYTES rather than characters because a path\n // may hold multi-byte characters. Truncating a row loses fields off the end, which is strictly better\n // than a torn line that breaks every row after it.\n private truncateToRowLimit(row: string): string {\n const bytes = Buffer.from(row, 'utf8');\n // -1 for the newline `append` adds.\n if (bytes.length <= MAX_ROW_BYTES - 1) return row;\n return bytes.subarray(0, MAX_ROW_BYTES - 1).toString('utf8');\n }\n\n /**\n * Take the ledger lock, retrying every `LOCK_RETRY_MS` until `LOCK_TIMEOUT_MS`. False means \"carry on\n * without it\" — never an error, and never a reason to skip the append.\n *\n * The mechanism is `MainSyncStatusService.tryAcquireMainSyncLock`'s, proven and deliberately copied\n * rather than re-invented: an `wx` (O_CREAT|O_EXCL) create so exactly one of N racers wins, a payload\n * carrying pid + started so a dead holder is identifiable, stale reclaim gated on pid liveness, and a\n * re-read afterwards to confirm the entry on disk is OURS (a simultaneous reclaimer could have\n * unlinked ours and written its own between the two calls).\n */\n private tryAcquireLock(homeDir: string): boolean {\n const deadline = Date.now() + LOCK_TIMEOUT_MS;\n this.ensureDir(this.lockPath(homeDir));\n // Rendered rather than JSON.stringify'd off an anonymous object — two fields, both numbers, and\n // the file's whole contract is `{\"pid\":N,\"started\":M}`.\n const payload = `{\"pid\":${String(process.pid)},\"started\":${String(Date.now())}}\\n`;\n for (;;) {\n if (this.createExclusive(this.lockPath(homeDir), payload)) return true;\n if (!this.isHolderAlive(homeDir)) {\n this.unlinkQuietly(this.lockPath(homeDir));\n if (this.createExclusive(this.lockPath(homeDir), payload) && this.holderIsUs(homeDir)) return true;\n }\n if (Date.now() >= deadline) return false;\n this.sleep(LOCK_RETRY_MS);\n }\n }\n\n private releaseLock(homeDir: string): void {\n if (!this.holderIsUs(homeDir)) return;\n this.unlinkQuietly(this.lockPath(homeDir));\n }\n\n // O_CREAT|O_EXCL write: true when THIS call created the file, false when it already existed.\n private createExclusive(file: string, payload: string): boolean {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n fs.writeFileSync(file, payload, { flag: 'wx' });\n return true;\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n return false;\n }\n }\n\n // The pid recorded in the lock file, or 0 when there is no readable lock.\n private lockHolderPid(homeDir: string): number {\n const text = this.readTextOrEmpty(this.lockPath(homeDir));\n if (text === '') return 0;\n const match = /\"pid\"\\s*:\\s*(\\d+)/.exec(text);\n return match === null ? 0 : Number.parseInt(match[1], 10);\n }\n\n // An unreadable or pid-less lock file counts as DEAD: it is a corpse from a crashed writer, and\n // leaving it forever would mean every future append silently skips rotation.\n private isHolderAlive(homeDir: string): boolean {\n const pid = this.lockHolderPid(homeDir);\n return pid > 0 && this.isAlive(pid);\n }\n\n private holderIsUs(homeDir: string): boolean {\n return this.lockHolderPid(homeDir) === process.pid;\n }\n\n /**\n * `.4→.5, .3→.4, … .log→.1`, dropping the old `.5`. Runs INSIDE the lock, which is the one place the\n * lock is genuinely load-bearing: a rename-and-reopen really does race, and a writer that opened the\n * old inode mid-shift would append into a file nobody reads again.\n */\n private rotateIfLarge(homeDir: string): void {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n if (!fs.existsSync(this.logPath(homeDir))) return;\n if (fs.statSync(this.logPath(homeDir)).size < MAX_BUILDS_LOG_BYTES) return;\n this.unlinkQuietly(this.rotatedPath(BUILDS_LOG_GENERATIONS, homeDir));\n for (let gen = BUILDS_LOG_GENERATIONS - 1; gen >= 1; gen -= 1) {\n this.renameQuietly(this.rotatedPath(gen, homeDir), this.rotatedPath(gen + 1, homeDir));\n }\n this.renameQuietly(this.logPath(homeDir), this.rotatedPath(1, homeDir));\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n }\n }\n\n // ─── FILESYSTEM PRIMITIVES, ALL SWALLOWING ────────────────────────────────────────────────────────\n\n private ensureDir(file: string): void {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n fs.mkdirSync(path.dirname(file), { recursive: true });\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n }\n }\n\n private unlinkQuietly(file: string): void {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n if (fs.existsSync(file)) fs.unlinkSync(file);\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n }\n }\n\n private renameQuietly(from: string, to: string): void {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n if (fs.existsSync(from)) fs.renameSync(from, to);\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n }\n }\n\n private readTextOrEmpty(file: string): string {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n return fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : '';\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n return '';\n }\n }\n\n private readLines(file: string): string[] {\n const text = this.readTextOrEmpty(file);\n if (text === '') return [];\n return text.split('\\n').filter((line: string): boolean => line.trim() !== '');\n }\n\n // A blocking sleep, because the lock retry sits on a synchronous append path that must not become\n // async — `finish()` is called from a `finally` and an async logger there could outlive the process.\n private sleep(ms: number): void {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n }\n }\n\n // The checked-out branch in `startDir`, or '' when git cannot say. spawnSync does not throw on a\n // non-zero exit, so \"not a repo\" arrives as a status, not an exception.\n private gitBranch(startDir: string): string {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const result = spawnSync('git', ['rev-parse', '--abbrev-ref', 'HEAD'],\n { cwd: startDir, encoding: 'utf8' });\n if (result.status !== 0 || typeof result.stdout !== 'string') return '';\n return result.stdout.trim();\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n return '';\n }\n }\n}\n"]}
1
+ {"version":3,"file":"builds-log.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/builds-log.ts"],"names":[],"mappings":";;;;AAAA,iDAA0C;AAC1C,uDAAiC;AACjC,+CAAyB;AACzB,+CAAyB;AACzB,mDAA6B;AAC7B,yCAA2D;AAE3D,8DAAyD;AACzD,+CAAgD;AAChD,iEAA6D;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACU,QAAA,eAAe,GAAG,YAAY,CAAC;AAC/B,QAAA,gBAAgB,GAAG,iBAAiB,CAAC;AAElD,kGAAkG;AACrF,QAAA,WAAW,GAAG,OAAO,CAAC;AACtB,QAAA,kBAAkB,GAAG,cAAc,CAAC;AACpC,QAAA,eAAe,GAAG,WAAW,CAAC;AAE3C,uFAAuF;AAC1E,QAAA,oBAAoB,GAAG,IAAI,GAAG,IAAI,CAAC;AACnC,QAAA,sBAAsB,GAA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wE;IAChE,SAAS,CAAC,QAAgB;QAC9B,8DAA8D;QAC9D,IAAI,CAAC;YACD,MAAM,MAAM,GAAG,IAAA,yBAAS,EAAC,KAAK,EAAE,CAAC,WAAW,EAAE,cAAc,EAAE,MAAM,CAAC,EACjE,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;YACzC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ;gBAAE,OAAO,EAAE,CAAC;YACxE,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QAChC,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACpB,MAAM,KAAK,GAAG,IAAA,kBAAO,EAAC,GAAG,CAAC,CAAC;YAC3B,KAAK,KAAK,CAAC;YACX,OAAO,EAAE,CAAC;QACd,CAAC;IACL,CAAC;CACJ,CAAA;AA/YY,8BAAS;oBAAT,SAAS;IADrB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEA,6BAAY;GADxC,SAAS,CA+YrB","sourcesContent":["import { spawnSync } from 'child_process';\nimport * as crypto from 'crypto';\nimport * as fs from 'fs';\nimport * as os from 'os';\nimport * as path from 'path';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { DotWebpieces } from '@webpieces/tooling-common';\nimport { HOME_CONFIG_DIR } from './home-config';\nimport { toError } from '@webpieces/tooling-common/to-error';\n\n/**\n * `~/.webpieces/builds.log` — the MACHINE-WIDE, append-only ledger of every build this box has started.\n *\n * ─── WHY THIS ONE FILE LIVES OUTSIDE THE REPO ─────────────────────────────────────────────────────────\n * `no-machine-global-state.spec.ts` records the standing rule: webpieces writes state under\n * `{repo}/.webpieces` and nowhere else. This is the ONE carve-out, and the argument is written out in\n * `decisions/0006-the-build-ledger-is-machine-global.md`. In short:\n *\n * • The FACT is machine-scoped. \"How many builds are burning this box's CPU right now\" is not a\n * property of any repo; it is a property of the machine. A per-repo ledger cannot answer it — every\n * linked worktree has its OWN `.webpieces/`, so it would be blind to the sibling worktree it is\n * actually contending with, never mind the four other repos on the disk.\n * • It is NOT A CACHE. The retired `PrBodyStore` that the no-machine-global rule was written for was a\n * local copy of a fact GitHub owned, so it could be stale, missing, or on the wrong computer. There\n * is no remote copy of this. The file IS the fact.\n * • Its key is an ABSOLUTE LOCAL PATH, which is stable precisely because it never leaves the machine —\n * the instability that killed `PrBodyStore`'s `<host>/<owner>/<repo>` key cannot arise here.\n *\n * ─── WHY IT IS SAFE TO WRITE CONCURRENTLY ─────────────────────────────────────────────────────────────\n * Rows are deliberately kept under `MAX_ROW_BYTES` (512, macOS `PIPE_BUF`). A single `O_APPEND`\n * `write(2)` at or below that size is indivisible, so two builds appending at the same instant cannot\n * interleave halves of a line. The lock is therefore belt-and-braces for the APPEND and genuinely\n * load-bearing for ROTATION, where a rename-and-reopen really does race.\n *\n * ─── IT MAY NEVER FAIL A BUILD ────────────────────────────────────────────────────────────────────────\n * Every method here is best-effort and swallows its own errors. A build must never die because a log\n * file was busy, unwritable, or on a full disk. Lock acquisition retries and then gives up and appends\n * anyway — which the row-size invariant above makes safe.\n */\nexport const BUILDS_LOG_FILE = 'builds.log';\nexport const BUILDS_LOCK_FILE = 'builds.log.lock';\n\n/** START, and the two terminal kinds. `DONE-` is the greppable prefix that pairs with a START. */\nexport const BUILD_START = 'START';\nexport const BUILD_DONE_SUCCESS = 'DONE-SUCCESS';\nexport const BUILD_DONE_FAIL = 'DONE-FAIL';\n\n/** Rotate at 1 MB, keeping five generations (`.1` … `.5`); the old `.5` is dropped. */\nexport const MAX_BUILDS_LOG_BYTES = 1024 * 1024;\nexport const BUILDS_LOG_GENERATIONS = 5;\n\n/**\n * macOS `PIPE_BUF`. A row at or under this size is written by ONE indivisible `write(2)`, which is what\n * makes a lost lock a non-event rather than a corrupted file. Long paths are clipped to hold the line\n * under it — see `clip`.\n */\nexport const MAX_ROW_BYTES = 512;\n\n/** How long a build may hold the lock before another writer stops waiting and appends anyway. */\nconst LOCK_RETRY_MS = 50;\nconst LOCK_TIMEOUT_MS = 2000;\n\n/**\n * The handle a START row hands back, and the ONLY thing `finish()` accepts. Data-only (a class, per\n * CLAUDE.md), carrying exactly the fields the DONE row needs to pair itself with its START: the uuid,\n * the caller, the repo, and when it began (so `took=` is computed from one clock, not two).\n */\nexport class BuildTicket {\n id: string;\n by: string;\n repo: string;\n startedMs: number;\n\n constructor(id: string, by: string, repo: string, startedMs: number) {\n this.id = id;\n this.by = by;\n this.repo = repo;\n this.startedMs = startedMs;\n }\n}\n\n/**\n * How the build process ended. Node reports a null code when a signal ended the process, so collapsing\n * this to a number would discard the only useful explanation for an otherwise silent build failure.\n * Data-only: the PR gate decides which CLI exit code to return, while the ledger records these raw facts.\n */\nexport class BuildTermination {\n code: number | null;\n signal: string | null;\n\n constructor(code: number | null, signal: string | null) {\n this.code = code;\n this.signal = signal;\n }\n}\n\n/**\n * One build that is STILL RUNNING — a START row with no matching `DONE-`, whose pid is still alive.\n * Data-only. This is what the refusal message renders, so it carries the three things a reader needs to\n * recognise the build in question: where it is, which tree, and how old it is.\n */\nexport class RunningBuild {\n id: string;\n by: string;\n repo: string;\n tree: string;\n cwd: string;\n branch: string;\n pid: number;\n startedMs: number;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n id: string, by: string, repo: string, tree: string,\n cwd: string, branch: string, pid: number, startedMs: number,\n ) {\n this.id = id;\n this.by = by;\n this.repo = repo;\n this.tree = tree;\n this.cwd = cwd;\n this.branch = branch;\n this.pid = pid;\n this.startedMs = startedMs;\n }\n}\n\n/**\n * The ledger. See the file docblock for why it is machine-global and why every operation swallows its\n * own errors.\n *\n * `homeDir` is a parameter on every public method, defaulted to `os.homedir()`, for exactly the reason\n * `HomeConfigService.configPath` takes one: a spec must be able to exercise the real code against a temp\n * directory and must never touch the developer's actual `~/.webpieces`.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class BuildsLog {\n constructor(private readonly dotDir: DotWebpieces) {}\n\n /** `~/.webpieces/builds.log`. */\n logPath(homeDir: string = os.homedir()): string {\n return path.join(homeDir, HOME_CONFIG_DIR, BUILDS_LOG_FILE);\n }\n\n /** `~/.webpieces/builds.log.lock` — `{\"pid\":N,\"started\":<epochMs>}`. */\n lockPath(homeDir: string = os.homedir()): string {\n return path.join(homeDir, HOME_CONFIG_DIR, BUILDS_LOCK_FILE);\n }\n\n /** `~/.webpieces/builds.log.<n>` — generation `n`, 1 being the most recent. */\n rotatedPath(generation: number, homeDir: string = os.homedir()): string {\n return `${this.logPath(homeDir)}.${String(generation)}`;\n }\n\n /**\n * Record that a build is starting, and hand back the ticket its DONE row will need.\n *\n * `by` is the CALLER — `BuildGateOptions.stage`, i.e. `build` | `review` | `finish`. There is no\n * second \"caller\" concept anywhere: the stage id already is one, and a second spelling of it would\n * be the shim `.claude/rules/no-backwards-compat.md` rejects.\n *\n * Returns a ticket even when the append failed. A build whose START row never landed still has to be\n * able to call `finish()`; the alternative is a nullable return that every call site must branch on\n * for a logging failure that is, by policy, not an error.\n */\n start(by: string, startDir: string, homeDir: string = os.homedir()): BuildTicket {\n const ticket = new BuildTicket(\n crypto.randomUUID(), by, this.dotDir.primaryRoot(startDir), Date.now());\n this.append(this.startRow(ticket, startDir), homeDir);\n return ticket;\n }\n\n /**\n * Record that the build behind `ticket` has ended. Only code 0 with no signal writes `DONE-SUCCESS`;\n * anything else writes `DONE-FAIL` carrying the raw code and signal, so a killed build does not become\n * an unexplained generic exit 1 in the machine record.\n */\n finish(ticket: BuildTicket, termination: BuildTermination, homeDir: string = os.homedir()): void {\n this.append(this.doneRow(ticket, termination), homeDir);\n }\n\n /**\n * Every build that is still live: a `START` with no matching `DONE-` row, whose pid is still alive.\n *\n * The pid filter is not an optimisation, it is what keeps the ledger from wedging the machine. A\n * build killed with SIGKILL — an agent cancelled mid-run, a terminal closed — writes no DONE row, so\n * without the liveness test its START would count forever and the fourth build would be refused for\n * the rest of the machine's life. The uuid answers \"which build\"; the pid answers \"is it still real\".\n *\n * Only the CURRENT generation is read. A rotated-away START is by definition at least 1 MB of rows\n * old and is not a build anyone is contending with.\n */\n running(homeDir: string = os.homedir()): RunningBuild[] {\n const lines = this.readLines(this.logPath(homeDir));\n const done = new Set<string>();\n for (const line of lines) {\n if (line.startsWith(`${BUILD_DONE_SUCCESS}\\t`) || line.startsWith(`${BUILD_DONE_FAIL}\\t`)) {\n done.add(this.field(line, 'id'));\n }\n }\n const live: RunningBuild[] = [];\n for (const line of lines) {\n if (!line.startsWith(`${BUILD_START}\\t`)) continue;\n const build = this.toRunningBuild(line);\n if (build === null || done.has(build.id)) continue;\n if (!this.isAlive(build.pid)) continue;\n live.push(build);\n }\n return live;\n }\n\n /**\n * The `@webpieces` release ACTUALLY EXECUTING — found by walking UP from this module's own directory\n * to the nearest enclosing `node_modules/@webpieces/<pkg>/package.json`. `''` when this code is\n * running from source rather than from an installed package (which is the state in this repo's own\n * specs, and a perfectly ordinary answer).\n *\n * ─── WHY THIS IS NOT `WebpiecesVersions.readInstalled(root)` ──────────────────────────────────────\n * They answer DIFFERENT QUESTIONS and merging them would break the older one. `readInstalled` joins\n * `<root>/node_modules/@webpieces/...` at a FIXED tree root ON PURPOSE: its whole job is to detect\n * DRIFT between what a tree PINS and what some other tree pins, and a walk-up would silently resolve\n * a worktree with no install of its own to the primary clone's copy — hiding exactly the skew that\n * guard exists to catch. This question is the opposite one: \"whichever copy is running, name it\", and\n * for that the walk-up is the only correct answer. Do not fold them together.\n */\n executingVersion(): string {\n let dir = __dirname;\n for (let hops = 0; hops < 40; hops += 1) {\n const version = this.versionOfEnclosingPackage(dir);\n if (version !== '') return version;\n const parent = path.dirname(dir);\n if (parent === dir) return '';\n dir = parent;\n }\n return '';\n }\n\n // `<dir>` is `node_modules/@webpieces/<pkg>/...`? Then that package's version, else ''.\n private versionOfEnclosingPackage(dir: string): string {\n const parent = path.dirname(dir);\n const grandparent = path.dirname(parent);\n if (path.basename(parent) !== '@webpieces' || path.basename(grandparent) !== 'node_modules') return '';\n const text = this.readTextOrEmpty(path.join(dir, 'package.json'));\n const match = /\"version\"\\s*:\\s*\"([^\"]+)\"/.exec(text);\n return match === null ? '' : match[1];\n }\n\n // ─── ROW RENDERING ────────────────────────────────────────────────────────────────────────────────\n\n private startRow(ticket: BuildTicket, startDir: string): string {\n return [\n BUILD_START,\n `id=${ticket.id}`,\n `t=${new Date(ticket.startedMs).toISOString()}`,\n `ms=${String(ticket.startedMs)}`,\n `by=${ticket.by}`,\n `repo=${this.clip(ticket.repo)}`,\n `tree=${this.dotDir.worktreeName(startDir) || 'primary'}`,\n `cwd=${this.clip(startDir)}`,\n `branch=${this.gitBranch(startDir)}`,\n `pid=${String(process.pid)}`,\n `wp=${this.executingVersion()}`,\n ].join('\\t');\n }\n\n private doneRow(ticket: BuildTicket, termination: BuildTermination): string {\n const now = Date.now();\n const success = termination.code === 0 && termination.signal === null;\n const fields = [\n success ? BUILD_DONE_SUCCESS : BUILD_DONE_FAIL,\n `id=${ticket.id}`,\n `t=${new Date(now).toISOString()}`,\n `ms=${String(now)}`,\n `by=${ticket.by}`,\n `repo=${this.clip(ticket.repo)}`,\n `took=${String(now - ticket.startedMs)}`,\n ];\n if (!success) fields.push(`exit=${termination.code === null ? 'null' : String(termination.code)}`);\n if (termination.signal !== null) fields.push(`signal=${this.clip(termination.signal)}`);\n fields.push(`pid=${String(process.pid)}`);\n return fields.join('\\t');\n }\n\n /**\n * Hold a long path down to `max` characters by keeping its TAIL, which is the half that identifies\n * the tree; a clipped value is marked with a leading `…` so nobody mistakes it for a real path.\n *\n * This is what keeps a row under `MAX_ROW_BYTES` — see the file docblock. `append` re-checks the\n * assembled line as a backstop, because three clipped fields plus a long branch name can still add up.\n */\n private clip(value: string, max = 120): string {\n const oneLine = value.replace(/[\\t\\n\\r]/g, ' ');\n return oneLine.length <= max ? oneLine : `…${oneLine.slice(oneLine.length - max)}`;\n }\n\n // ─── ROW PARSING ──────────────────────────────────────────────────────────────────────────────────\n\n /** The value of `<name>=` on a TSV row, or '' when the row does not carry it. */\n private field(line: string, name: string): string {\n for (const part of line.split('\\t')) {\n if (part.startsWith(`${name}=`)) return part.slice(name.length + 1);\n }\n return '';\n }\n\n // A START row as a RunningBuild, or null when it is missing the two fields that make it usable.\n private toRunningBuild(line: string): RunningBuild | null {\n const id = this.field(line, 'id');\n const pid = Number.parseInt(this.field(line, 'pid'), 10);\n if (id === '' || !Number.isInteger(pid) || pid <= 0) return null;\n const startedMs = Number.parseInt(this.field(line, 'ms'), 10);\n return new RunningBuild(\n id, this.field(line, 'by'), this.field(line, 'repo'), this.field(line, 'tree'),\n this.field(line, 'cwd'), this.field(line, 'branch'), pid,\n Number.isInteger(startedMs) ? startedMs : 0,\n );\n }\n\n /**\n * Is `pid` still addressable? `process.kill(pid, 0)` sends no signal — it only asks the kernel. ESRCH\n * is the ONE answer that proves death; EPERM proves the opposite (it exists, it is somebody else's).\n * Pid reuse is an accepted imprecision here: being wrong in the \"still running\" direction costs\n * one extra refusal, being wrong the other way lets a fourth build start.\n *\n * WHY A PID IS MEANINGFUL HERE AND WAS NOT FOR AGENT WORKTREE LOCKS. Every row in this ledger is\n * written BY the process it names — one real OS process per build — so its pid identifies it.\n * A Claude Code subagent is not a process at all: every agent in a session records the SAME pid,\n * the session's, which is why that check was deleted rather than shared (see\n * harness-agent-activity.ts). Do not generalise this one back out to anything but a real process.\n */\n private isAlive(pid: number): boolean {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n process.kill(pid, 0);\n return true;\n } catch (err: unknown) {\n const error = toError(err);\n return (error as NodeJS.ErrnoException).code !== 'ESRCH';\n }\n }\n\n // ─── APPEND, LOCK, ROTATE ─────────────────────────────────────────────────────────────────────────\n\n /**\n * Append one row, best-effort. Takes the lock so rotation cannot race, and appends ANYWAY when the\n * lock cannot be had within `LOCK_TIMEOUT_MS` — the row is under `PIPE_BUF`, so an unlocked\n * `O_APPEND` write is still indivisible, and a build must never die because a log file was busy.\n */\n private append(row: string, homeDir: string): void {\n const line = `${this.truncateToRowLimit(row)}\\n`;\n const held = this.tryAcquireLock(homeDir);\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n this.ensureDir(this.logPath(homeDir));\n if (held) this.rotateIfLarge(homeDir);\n fs.appendFileSync(this.logPath(homeDir), line);\n } catch (err: unknown) {\n const error = toError(err);\n void error; // logging may never fail a build — see the file docblock\n } finally {\n if (held) this.releaseLock(homeDir);\n }\n }\n\n // The backstop for the PIPE_BUF invariant, measured in BYTES rather than characters because a path\n // may hold multi-byte characters. Truncating a row loses fields off the end, which is strictly better\n // than a torn line that breaks every row after it.\n private truncateToRowLimit(row: string): string {\n const bytes = Buffer.from(row, 'utf8');\n // -1 for the newline `append` adds.\n if (bytes.length <= MAX_ROW_BYTES - 1) return row;\n return bytes.subarray(0, MAX_ROW_BYTES - 1).toString('utf8');\n }\n\n /**\n * Take the ledger lock, retrying every `LOCK_RETRY_MS` until `LOCK_TIMEOUT_MS`. False means \"carry on\n * without it\" — never an error, and never a reason to skip the append.\n *\n * The mechanism is `MainSyncStatusService.tryAcquireMainSyncLock`'s, proven and deliberately copied\n * rather than re-invented: an `wx` (O_CREAT|O_EXCL) create so exactly one of N racers wins, a payload\n * carrying pid + started so a dead holder is identifiable, stale reclaim gated on pid liveness, and a\n * re-read afterwards to confirm the entry on disk is OURS (a simultaneous reclaimer could have\n * unlinked ours and written its own between the two calls).\n */\n private tryAcquireLock(homeDir: string): boolean {\n const deadline = Date.now() + LOCK_TIMEOUT_MS;\n this.ensureDir(this.lockPath(homeDir));\n // Rendered rather than JSON.stringify'd off an anonymous object — two fields, both numbers, and\n // the file's whole contract is `{\"pid\":N,\"started\":M}`.\n const payload = `{\"pid\":${String(process.pid)},\"started\":${String(Date.now())}}\\n`;\n for (;;) {\n if (this.createExclusive(this.lockPath(homeDir), payload)) return true;\n if (!this.isHolderAlive(homeDir)) {\n this.unlinkQuietly(this.lockPath(homeDir));\n if (this.createExclusive(this.lockPath(homeDir), payload) && this.holderIsUs(homeDir)) return true;\n }\n if (Date.now() >= deadline) return false;\n this.sleep(LOCK_RETRY_MS);\n }\n }\n\n private releaseLock(homeDir: string): void {\n if (!this.holderIsUs(homeDir)) return;\n this.unlinkQuietly(this.lockPath(homeDir));\n }\n\n // O_CREAT|O_EXCL write: true when THIS call created the file, false when it already existed.\n private createExclusive(file: string, payload: string): boolean {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n fs.writeFileSync(file, payload, { flag: 'wx' });\n return true;\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n return false;\n }\n }\n\n // The pid recorded in the lock file, or 0 when there is no readable lock.\n private lockHolderPid(homeDir: string): number {\n const text = this.readTextOrEmpty(this.lockPath(homeDir));\n if (text === '') return 0;\n const match = /\"pid\"\\s*:\\s*(\\d+)/.exec(text);\n return match === null ? 0 : Number.parseInt(match[1], 10);\n }\n\n // An unreadable or pid-less lock file counts as DEAD: it is a corpse from a crashed writer, and\n // leaving it forever would mean every future append silently skips rotation.\n private isHolderAlive(homeDir: string): boolean {\n const pid = this.lockHolderPid(homeDir);\n return pid > 0 && this.isAlive(pid);\n }\n\n private holderIsUs(homeDir: string): boolean {\n return this.lockHolderPid(homeDir) === process.pid;\n }\n\n /**\n * `.4→.5, .3→.4, … .log→.1`, dropping the old `.5`. Runs INSIDE the lock, which is the one place the\n * lock is genuinely load-bearing: a rename-and-reopen really does race, and a writer that opened the\n * old inode mid-shift would append into a file nobody reads again.\n */\n private rotateIfLarge(homeDir: string): void {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n if (!fs.existsSync(this.logPath(homeDir))) return;\n if (fs.statSync(this.logPath(homeDir)).size < MAX_BUILDS_LOG_BYTES) return;\n this.unlinkQuietly(this.rotatedPath(BUILDS_LOG_GENERATIONS, homeDir));\n for (let gen = BUILDS_LOG_GENERATIONS - 1; gen >= 1; gen -= 1) {\n this.renameQuietly(this.rotatedPath(gen, homeDir), this.rotatedPath(gen + 1, homeDir));\n }\n this.renameQuietly(this.logPath(homeDir), this.rotatedPath(1, homeDir));\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n }\n }\n\n // ─── FILESYSTEM PRIMITIVES, ALL SWALLOWING ────────────────────────────────────────────────────────\n\n private ensureDir(file: string): void {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n fs.mkdirSync(path.dirname(file), { recursive: true });\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n }\n }\n\n private unlinkQuietly(file: string): void {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n if (fs.existsSync(file)) fs.unlinkSync(file);\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n }\n }\n\n private renameQuietly(from: string, to: string): void {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n if (fs.existsSync(from)) fs.renameSync(from, to);\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n }\n }\n\n private readTextOrEmpty(file: string): string {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n return fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : '';\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n return '';\n }\n }\n\n private readLines(file: string): string[] {\n const text = this.readTextOrEmpty(file);\n if (text === '') return [];\n return text.split('\\n').filter((line: string): boolean => line.trim() !== '');\n }\n\n // A blocking sleep, because the lock retry sits on a synchronous append path that must not become\n // async — `finish()` is called from a `finally` and an async logger there could outlive the process.\n private sleep(ms: number): void {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n }\n }\n\n // The checked-out branch in `startDir`, or '' when git cannot say. spawnSync does not throw on a\n // non-zero exit, so \"not a repo\" arrives as a status, not an exception.\n private gitBranch(startDir: string): string {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const result = spawnSync('git', ['rev-parse', '--abbrev-ref', 'HEAD'],\n { cwd: startDir, encoding: 'utf8' });\n if (result.status !== 0 || typeof result.stdout !== 'string') return '';\n return result.stdout.trim();\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n return '';\n }\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * The HUMAN's ship-anyway decision for ONE checklist, recorded in its own file beside the verdict:
3
- * `.webpieces-logs/pr-review/<feature>/override-<id>.json`. Data-only (per CLAUDE.md).
3
+ * `.webpieces/pr-review/<feature>/override-<id>.json`. Data-only (per CLAUDE.md).
4
4
  *
5
5
  * WHY IT IS A SEPARATE FILE FROM THE VERDICT. `review-round<N>-<id>.json` is a REVIEWER's verdict file, and a
6
6
  * coding agent editing a reviewer's verdict is refused by the harness — correctly, and by every route
@@ -11,7 +11,7 @@ const to_error_1 = require("@webpieces/tooling-common/to-error");
11
11
  const REASON_FILL_IN = 'REPLACE THIS with the human\'s own words, verbatim';
12
12
  /**
13
13
  * The HUMAN's ship-anyway decision for ONE checklist, recorded in its own file beside the verdict:
14
- * `.webpieces-logs/pr-review/<feature>/override-<id>.json`. Data-only (per CLAUDE.md).
14
+ * `.webpieces/pr-review/<feature>/override-<id>.json`. Data-only (per CLAUDE.md).
15
15
  *
16
16
  * WHY IT IS A SEPARATE FILE FROM THE VERDICT. `review-round<N>-<id>.json` is a REVIEWER's verdict file, and a
17
17
  * coding agent editing a reviewer's verdict is refused by the harness — correctly, and by every route
@@ -1 +1 @@
1
- {"version":3,"file":"checklist-override.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/checklist-override.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;AAC7B,yCAA2D;AAC3D,iEAA6D;AAE7D,wGAAwG;AACxG,iGAAiG;AACjG,MAAM,cAAc,GAAG,oDAAoD,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAa,iBAAiB;IAC1B,WAAW,CAAS,C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3E,CAAC;IAED;;;;;OAKG;IACH,yDAAyD;IACjD,UAAU,CAAC,mBAA2B,EAAE,WAAmB,EAAE,YAAoB,EAAE,MAAc;QACrG,MAAM,OAAO,GAAa,EAAE,CAAC;QAC7B,IAAI,YAAY,KAAK,EAAE;YAAE,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACxD,IAAI,MAAM,KAAK,EAAE;YAAE,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC5C,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;QACpC,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,mBAAmB,EAAE,WAAW,CAAC,CAAC;QACrE,OAAO,+BAA+B,WAAW,QAAQ,QAAQ,eAAe,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI;cACnG,iGAAiG;cACjG,2DAA2D;cAC3D,IAAI,CAAC,YAAY,CAAC,mBAAmB,EAAE,WAAW,CAAC,CAAC;IAC9D,CAAC;CACJ,CAAA;AA5IY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;GAC5B,wBAAwB,CA4IpC;AAED,0FAA0F;AAC1F,gGAAgG;AACnF,QAAA,wBAAwB,GAAG,IAAI,wBAAwB,EAAE,CAAC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { toError } from '@webpieces/tooling-common/to-error';\n\n// The literal the printed command leaves for the human's words. Named so the message, and any test that\n// asserts the command is still a fill-in rather than a pre-filled excuse, agree on one spelling.\nconst REASON_FILL_IN = 'REPLACE THIS with the human\\'s own words, verbatim';\n\n/**\n * The HUMAN's ship-anyway decision for ONE checklist, recorded in its own file beside the verdict:\n * `.webpieces-logs/pr-review/<feature>/override-<id>.json`. Data-only (per CLAUDE.md).\n *\n * WHY IT IS A SEPARATE FILE FROM THE VERDICT. `review-round<N>-<id>.json` is a REVIEWER's verdict file, and a\n * coding agent editing a reviewer's verdict is refused by the harness — correctly, and by every route\n * (heredoc, `sed -i`, a rewrite). While the ship-anyway justification lived inside that same file as an\n * `override` field, the ONE participant who genuinely hears the human — the coordinating agent — was the\n * one participant physically unable to record what it heard, and a human had to hand-edit JSON. Meanwhile\n * the reviewer subagent refuses to write its own override, also correctly. Two acts, two files:\n *\n * review-round<N>-<id>.json written by the reviewer subagent, once — \"what I found\"\n * override-<id>.json written by the COORDINATING agent — \"the human saw this and said ship it\"\n *\n * The name says what the file is, so nothing has to infer intent from a field inside a verdict.\n *\n * PER-CHECKLIST, AND IT STANDS. There is no time scoping, no branch scoping, no sha scoping and no\n * re-authorization when a reviewer runs again: an authorization is about a checklist the human decided to\n * accept, not about a particular wording of a finding. An earlier draft carried a `findingDigest` (a\n * hash of the reviewer's `output`) meaning to invalidate an override when the finding changed. That was\n * removed deliberately: `output` is LLM-written prose, so a re-run words the SAME finding differently\n * almost every time, and the digest would have mismatched on essentially every re-review — delivering\n * \"any re-review ⇒ re-authorize\", which is the exact dance this file exists to delete. FRESHNESS IS\n * CARRIED BY TRANSPARENCY INSTEAD: the dashboard renders 🟠 OVERRIDDEN with the reason, who authorized it\n * and when, and any new red finding still publishes as its own finding on the PR, so a human reading the\n * PR sees both and can judge for themselves.\n */\nexport class ChecklistOverride {\n checklistId: string; // the checklist this authorizes — never \"the PR as a whole\"\n authorizedBy: string; // WHO decided (e.g. 'human, in-session')\n authorizedAt: string; // WHEN, ISO-8601\n reason: string; // the human's own words, verbatim — the provenance, not an agent's paraphrase\n /**\n * '' = a well-formed authorization. Non-empty = the file exists and parses but cannot be READ as one\n * (a missing field). Carried as DATA rather than thrown for the same reason `ChecklistResult.problem`\n * is: the complaint has to be reportable in identical words by every command that reads the file, and\n * a half-written override must never be silently mistaken for an absent one.\n */\n problem: string;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(checklistId: string, authorizedBy: string, authorizedAt: string, reason: string, problem = '') {\n this.checklistId = checklistId;\n this.authorizedBy = authorizedBy;\n this.authorizedAt = authorizedAt;\n this.reason = reason;\n this.problem = problem;\n }\n}\n\n/**\n * Reads `override-<id>.json`, and renders the ready-to-run command that WRITES one.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ChecklistOverrideService {\n /** `override-<id>.json` — the ONE place this name is spelled. */\n overrideFileName(checklistId: string): string {\n return `override-${checklistId}.json`;\n }\n\n /** Absolute path of the override file, beside summary.json and review-round<N>-<id>.json in the AI-WRITABLE dir. */\n overridePath(summaryJsonFilePath: string, checklistId: string): string {\n return path.join(path.dirname(summaryJsonFilePath), this.overrideFileName(checklistId));\n }\n\n /**\n * The human's authorization for one checklist, or `null` when there is NO FILE — the only state that\n * genuinely means \"nobody authorized anything\".\n *\n * A file that EXISTS always yields a value, carrying any complaint in `problem` — whether a field is\n * missing or the bytes do not parse at all. `null` for those would collapse \"wrote an authorization\n * wrong\" into \"the human never authorized anything\", and send the reader off to ask for a decision that\n * was already made. `resolveVerdict` routes a non-empty `problem` to CK_BAD_FORMAT, so the gate still\n * REFUSES either way; the difference is entirely in whether the writer is told why it did not count.\n */\n // webpieces-disable no-any-unknown -- opaque parsed JSON, narrowed field-by-field below\n load(summaryJsonFilePath: string, checklistId: string): ChecklistOverride | null {\n const filePath = this.overridePath(summaryJsonFilePath, checklistId);\n if (!fs.existsSync(filePath)) return null;\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: an unparseable override reads as absent, never 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)) {\n return this.unreadable(summaryJsonFilePath, checklistId, 'it is not a JSON object');\n }\n const authorizedBy = this.stringField(raw, 'authorizedBy');\n const authorizedAt = this.stringField(raw, 'authorizedAt');\n const reason = this.stringField(raw, 'reason');\n return new ChecklistOverride(\n checklistId, authorizedBy, authorizedAt, reason,\n this.problemFor(summaryJsonFilePath, checklistId, authorizedBy, reason),\n );\n } catch (err: unknown) {\n const error = toError(err);\n return this.unreadable(summaryJsonFilePath, checklistId, error.message);\n }\n }\n\n /**\n * The value for an override file that EXISTS but cannot be read at all — unparseable bytes, or JSON that\n * is not an object. Reported rather than discarded, because \"you wrote it wrong\" and \"you never wrote\n * it\" call for opposite next actions and only the reader can tell them apart.\n */\n private unreadable(summaryJsonFilePath: string, checklistId: string, why: string): ChecklistOverride {\n const filePath = this.overridePath(summaryJsonFilePath, checklistId);\n const problem = `The override for checklist \"${checklistId}\" at ${filePath} cannot be read (${why}), so it `\n + 'authorizes nothing. The human\\'s decision is NOT recorded until this file parses. Rewrite the whole '\n + `file:\\n${this.writeCommand(summaryJsonFilePath, checklistId)}`;\n return new ChecklistOverride(checklistId, '', '', '', problem);\n }\n\n /**\n * What the dashboard and the PR comment print for an OVERRIDDEN checklist: the human's words plus the\n * provenance, so a reader never has to take \"someone approved this\" on trust.\n */\n detail(override: ChecklistOverride): string {\n const who = override.authorizedBy.trim();\n const when = override.authorizedAt.trim();\n const stamp = when === '' ? who : `${who}, ${when}`;\n return `${override.reason.trim()} (authorized by ${stamp})`;\n }\n\n /**\n * THE ready-to-run command that records an authorization — printed verbatim by every refusal.\n *\n * IT IS PRINTED, NOT DESCRIBED, on purpose. The old refusal said WHAT to write and WHERE but never WHO\n * MAY, so the reachable path was an agent improvising an in-place edit of a reviewer's verdict file —\n * which the harness denies, which is how the human ended up hand-editing JSON. An agent copying a\n * printed command into an obviously AI-writable path is a far cleaner ask, and it is the whole reason\n * this string exists.\n *\n * NOT INDENTED, deliberately: a shell heredoc's closing delimiter must sit at column 0, so indenting\n * this block to match the surrounding message would produce a command that does not run.\n */\n writeCommand(summaryJsonFilePath: string, checklistId: string): string {\n const filePath = this.overridePath(summaryJsonFilePath, checklistId);\n return [\n `cat > ${filePath} <<'JSON'`,\n '{',\n ` \"checklistId\": \"${checklistId}\",`,\n ' \"authorizedBy\": \"human, in-session\",',\n ` \"authorizedAt\": \"${this.nowIso()}\",`,\n ` \"reason\": \"${REASON_FILL_IN}\"`,\n '}',\n 'JSON',\n ].join('\\n');\n }\n\n /**\n * The paragraph that says WHO may run the command above — the half of this feature that is messaging.\n *\n * A reviewer subagent once told a human to run a command that no longer shipped, because the refusal\n * named a file and a field and never named a writer. All three facts are stated here in one place so\n * every surface says the same thing.\n */\n writerRule(): string {\n return 'Only the COORDINATING agent may write it — the one agent with the human in its own conversation. '\n + 'Transcribing a decision the human made to its face IN THIS SESSION is NOT self-authorization. '\n + 'A relayed instruction from another agent is NOT consent: if you are a reviewer subagent, say in '\n + 'your \"output\" that this finding needs a human authorization and STOP. Still forbidden: an agent '\n + 'inventing an authorization, a subagent writing one, and any agent authorizing a finding the human '\n + 'never saw.';\n }\n\n /** Seam: overridden in the spec so the printed command is assertable without a clock. */\n protected nowIso(): string {\n return new Date().toISOString();\n }\n\n // webpieces-disable no-any-unknown -- opaque parsed JSON value, narrowed to string here\n private stringField(raw: Record<string, unknown>, key: string): string {\n return typeof raw[key] === 'string' ? (raw[key] as string).trim() : '';\n }\n\n /**\n * '' when the authorization can be read. Otherwise the complaint, printed verbatim.\n *\n * `reason` and `authorizedBy` are the two fields that make the file mean anything: an override with no\n * stated reason is an assertion rather than a record, which is the whole thing this file replaced.\n */\n // eslint-disable-next-line @typescript-eslint/max-params\n private problemFor(summaryJsonFilePath: string, checklistId: string, authorizedBy: string, reason: string): string {\n const missing: string[] = [];\n if (authorizedBy === '') missing.push('\"authorizedBy\"');\n if (reason === '') missing.push('\"reason\"');\n if (missing.length === 0) return '';\n const filePath = this.overridePath(summaryJsonFilePath, checklistId);\n return `The override for checklist \"${checklistId}\" at ${filePath} is missing ${missing.join(' and ')}. `\n + 'An authorization with no stated reason and no named authorizer is an assertion, not a record — '\n + 'it does not authorize anything. Rewrite the whole file:\\n'\n + this.writeCommand(summaryJsonFilePath, checklistId);\n }\n}\n\n// Module-level instance, mirroring `dotWebpieces`: the defaulted constructor parameter of\n// ReviewJsonService, so `new ReviewJsonService()` keeps working while DI still injects by type.\nexport const checklistOverrideService = new ChecklistOverrideService();\n"]}
1
+ {"version":3,"file":"checklist-override.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/checklist-override.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;AAC7B,yCAA2D;AAC3D,iEAA6D;AAE7D,wGAAwG;AACxG,iGAAiG;AACjG,MAAM,cAAc,GAAG,oDAAoD,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAa,iBAAiB;IAC1B,WAAW,CAAS,CAAG,4DAA4D;IACnF,YAAY,CAAS,CAAE,yCAAyC;IAChE,YAAY,CAAS,CAAE,iBAAiB;IACxC,MAAM,CAAS,CAAQ,8EAA8E;IACrG;;;;;OAKG;IACH,OAAO,CAAS;IAEhB,yDAAyD;IACzD,YAAY,WAAmB,EAAE,YAAoB,EAAE,YAAoB,EAAE,MAAc,EAAE,OAAO,GAAG,EAAE;QACrG,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;CACJ;AArBD,8CAqBC;AAED;;;;GAIG;AAEI,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IACjC,iEAAiE;IACjE,gBAAgB,CAAC,WAAmB;QAChC,OAAO,YAAY,WAAW,OAAO,CAAC;IAC1C,CAAC;IAED,oHAAoH;IACpH,YAAY,CAAC,mBAA2B,EAAE,WAAmB;QACzD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,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S,CAAC;GAC5B,wBAAwB,CA4IpC;AAED,0FAA0F;AAC1F,gGAAgG;AACnF,QAAA,wBAAwB,GAAG,IAAI,wBAAwB,EAAE,CAAC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { toError } from '@webpieces/tooling-common/to-error';\n\n// The literal the printed command leaves for the human's words. Named so the message, and any test that\n// asserts the command is still a fill-in rather than a pre-filled excuse, agree on one spelling.\nconst REASON_FILL_IN = 'REPLACE THIS with the human\\'s own words, verbatim';\n\n/**\n * The HUMAN's ship-anyway decision for ONE checklist, recorded in its own file beside the verdict:\n * `.webpieces/pr-review/<feature>/override-<id>.json`. Data-only (per CLAUDE.md).\n *\n * WHY IT IS A SEPARATE FILE FROM THE VERDICT. `review-round<N>-<id>.json` is a REVIEWER's verdict file, and a\n * coding agent editing a reviewer's verdict is refused by the harness — correctly, and by every route\n * (heredoc, `sed -i`, a rewrite). While the ship-anyway justification lived inside that same file as an\n * `override` field, the ONE participant who genuinely hears the human — the coordinating agent — was the\n * one participant physically unable to record what it heard, and a human had to hand-edit JSON. Meanwhile\n * the reviewer subagent refuses to write its own override, also correctly. Two acts, two files:\n *\n * review-round<N>-<id>.json written by the reviewer subagent, once — \"what I found\"\n * override-<id>.json written by the COORDINATING agent — \"the human saw this and said ship it\"\n *\n * The name says what the file is, so nothing has to infer intent from a field inside a verdict.\n *\n * PER-CHECKLIST, AND IT STANDS. There is no time scoping, no branch scoping, no sha scoping and no\n * re-authorization when a reviewer runs again: an authorization is about a checklist the human decided to\n * accept, not about a particular wording of a finding. An earlier draft carried a `findingDigest` (a\n * hash of the reviewer's `output`) meaning to invalidate an override when the finding changed. That was\n * removed deliberately: `output` is LLM-written prose, so a re-run words the SAME finding differently\n * almost every time, and the digest would have mismatched on essentially every re-review — delivering\n * \"any re-review ⇒ re-authorize\", which is the exact dance this file exists to delete. FRESHNESS IS\n * CARRIED BY TRANSPARENCY INSTEAD: the dashboard renders 🟠 OVERRIDDEN with the reason, who authorized it\n * and when, and any new red finding still publishes as its own finding on the PR, so a human reading the\n * PR sees both and can judge for themselves.\n */\nexport class ChecklistOverride {\n checklistId: string; // the checklist this authorizes — never \"the PR as a whole\"\n authorizedBy: string; // WHO decided (e.g. 'human, in-session')\n authorizedAt: string; // WHEN, ISO-8601\n reason: string; // the human's own words, verbatim — the provenance, not an agent's paraphrase\n /**\n * '' = a well-formed authorization. Non-empty = the file exists and parses but cannot be READ as one\n * (a missing field). Carried as DATA rather than thrown for the same reason `ChecklistResult.problem`\n * is: the complaint has to be reportable in identical words by every command that reads the file, and\n * a half-written override must never be silently mistaken for an absent one.\n */\n problem: string;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(checklistId: string, authorizedBy: string, authorizedAt: string, reason: string, problem = '') {\n this.checklistId = checklistId;\n this.authorizedBy = authorizedBy;\n this.authorizedAt = authorizedAt;\n this.reason = reason;\n this.problem = problem;\n }\n}\n\n/**\n * Reads `override-<id>.json`, and renders the ready-to-run command that WRITES one.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ChecklistOverrideService {\n /** `override-<id>.json` — the ONE place this name is spelled. */\n overrideFileName(checklistId: string): string {\n return `override-${checklistId}.json`;\n }\n\n /** Absolute path of the override file, beside summary.json and review-round<N>-<id>.json in the AI-WRITABLE dir. */\n overridePath(summaryJsonFilePath: string, checklistId: string): string {\n return path.join(path.dirname(summaryJsonFilePath), this.overrideFileName(checklistId));\n }\n\n /**\n * The human's authorization for one checklist, or `null` when there is NO FILE — the only state that\n * genuinely means \"nobody authorized anything\".\n *\n * A file that EXISTS always yields a value, carrying any complaint in `problem` — whether a field is\n * missing or the bytes do not parse at all. `null` for those would collapse \"wrote an authorization\n * wrong\" into \"the human never authorized anything\", and send the reader off to ask for a decision that\n * was already made. `resolveVerdict` routes a non-empty `problem` to CK_BAD_FORMAT, so the gate still\n * REFUSES either way; the difference is entirely in whether the writer is told why it did not count.\n */\n // webpieces-disable no-any-unknown -- opaque parsed JSON, narrowed field-by-field below\n load(summaryJsonFilePath: string, checklistId: string): ChecklistOverride | null {\n const filePath = this.overridePath(summaryJsonFilePath, checklistId);\n if (!fs.existsSync(filePath)) return null;\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: an unparseable override reads as absent, never 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)) {\n return this.unreadable(summaryJsonFilePath, checklistId, 'it is not a JSON object');\n }\n const authorizedBy = this.stringField(raw, 'authorizedBy');\n const authorizedAt = this.stringField(raw, 'authorizedAt');\n const reason = this.stringField(raw, 'reason');\n return new ChecklistOverride(\n checklistId, authorizedBy, authorizedAt, reason,\n this.problemFor(summaryJsonFilePath, checklistId, authorizedBy, reason),\n );\n } catch (err: unknown) {\n const error = toError(err);\n return this.unreadable(summaryJsonFilePath, checklistId, error.message);\n }\n }\n\n /**\n * The value for an override file that EXISTS but cannot be read at all — unparseable bytes, or JSON that\n * is not an object. Reported rather than discarded, because \"you wrote it wrong\" and \"you never wrote\n * it\" call for opposite next actions and only the reader can tell them apart.\n */\n private unreadable(summaryJsonFilePath: string, checklistId: string, why: string): ChecklistOverride {\n const filePath = this.overridePath(summaryJsonFilePath, checklistId);\n const problem = `The override for checklist \"${checklistId}\" at ${filePath} cannot be read (${why}), so it `\n + 'authorizes nothing. The human\\'s decision is NOT recorded until this file parses. Rewrite the whole '\n + `file:\\n${this.writeCommand(summaryJsonFilePath, checklistId)}`;\n return new ChecklistOverride(checklistId, '', '', '', problem);\n }\n\n /**\n * What the dashboard and the PR comment print for an OVERRIDDEN checklist: the human's words plus the\n * provenance, so a reader never has to take \"someone approved this\" on trust.\n */\n detail(override: ChecklistOverride): string {\n const who = override.authorizedBy.trim();\n const when = override.authorizedAt.trim();\n const stamp = when === '' ? who : `${who}, ${when}`;\n return `${override.reason.trim()} (authorized by ${stamp})`;\n }\n\n /**\n * THE ready-to-run command that records an authorization — printed verbatim by every refusal.\n *\n * IT IS PRINTED, NOT DESCRIBED, on purpose. The old refusal said WHAT to write and WHERE but never WHO\n * MAY, so the reachable path was an agent improvising an in-place edit of a reviewer's verdict file —\n * which the harness denies, which is how the human ended up hand-editing JSON. An agent copying a\n * printed command into an obviously AI-writable path is a far cleaner ask, and it is the whole reason\n * this string exists.\n *\n * NOT INDENTED, deliberately: a shell heredoc's closing delimiter must sit at column 0, so indenting\n * this block to match the surrounding message would produce a command that does not run.\n */\n writeCommand(summaryJsonFilePath: string, checklistId: string): string {\n const filePath = this.overridePath(summaryJsonFilePath, checklistId);\n return [\n `cat > ${filePath} <<'JSON'`,\n '{',\n ` \"checklistId\": \"${checklistId}\",`,\n ' \"authorizedBy\": \"human, in-session\",',\n ` \"authorizedAt\": \"${this.nowIso()}\",`,\n ` \"reason\": \"${REASON_FILL_IN}\"`,\n '}',\n 'JSON',\n ].join('\\n');\n }\n\n /**\n * The paragraph that says WHO may run the command above — the half of this feature that is messaging.\n *\n * A reviewer subagent once told a human to run a command that no longer shipped, because the refusal\n * named a file and a field and never named a writer. All three facts are stated here in one place so\n * every surface says the same thing.\n */\n writerRule(): string {\n return 'Only the COORDINATING agent may write it — the one agent with the human in its own conversation. '\n + 'Transcribing a decision the human made to its face IN THIS SESSION is NOT self-authorization. '\n + 'A relayed instruction from another agent is NOT consent: if you are a reviewer subagent, say in '\n + 'your \"output\" that this finding needs a human authorization and STOP. Still forbidden: an agent '\n + 'inventing an authorization, a subagent writing one, and any agent authorizing a finding the human '\n + 'never saw.';\n }\n\n /** Seam: overridden in the spec so the printed command is assertable without a clock. */\n protected nowIso(): string {\n return new Date().toISOString();\n }\n\n // webpieces-disable no-any-unknown -- opaque parsed JSON value, narrowed to string here\n private stringField(raw: Record<string, unknown>, key: string): string {\n return typeof raw[key] === 'string' ? (raw[key] as string).trim() : '';\n }\n\n /**\n * '' when the authorization can be read. Otherwise the complaint, printed verbatim.\n *\n * `reason` and `authorizedBy` are the two fields that make the file mean anything: an override with no\n * stated reason is an assertion rather than a record, which is the whole thing this file replaced.\n */\n // eslint-disable-next-line @typescript-eslint/max-params\n private problemFor(summaryJsonFilePath: string, checklistId: string, authorizedBy: string, reason: string): string {\n const missing: string[] = [];\n if (authorizedBy === '') missing.push('\"authorizedBy\"');\n if (reason === '') missing.push('\"reason\"');\n if (missing.length === 0) return '';\n const filePath = this.overridePath(summaryJsonFilePath, checklistId);\n return `The override for checklist \"${checklistId}\" at ${filePath} is missing ${missing.join(' and ')}. `\n + 'An authorization with no stated reason and no named authorizer is an assertion, not a record — '\n + 'it does not authorize anything. Rewrite the whole file:\\n'\n + this.writeCommand(summaryJsonFilePath, checklistId);\n }\n}\n\n// Module-level instance, mirroring `dotWebpieces`: the defaulted constructor parameter of\n// ReviewJsonService, so `new ReviewJsonService()` keeps working while DI still injects by type.\nexport const checklistOverrideService = new ChecklistOverrideService();\n"]}
@@ -103,6 +103,6 @@ function formatConfigErrorsBanner(errors) {
103
103
  ` • A MACHINE-LOCAL setting does not belong in this file at all. Those live in ` +
104
104
  `~/.webpieces/config.json under "experimental" — an optional file tracked by no repo, whose absence ` +
105
105
  `is the default behaviour. Delete the key here and put it there.` +
106
- `\n\nBackground: .webpieces-logs/instruct-ai/${exports.CONFIG_POLICY_DOC}`);
106
+ `\n\nBackground: .webpieces/instruct-ai/${exports.CONFIG_POLICY_DOC}`);
107
107
  }
108
108
  //# sourceMappingURL=config-error-banner.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config-error-banner.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/config-error-banner.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;;;AA0BH,4DA2BC;AAnDD,2CAAoD;AAEpD;;;;;;;GAOG;AACU,QAAA,iBAAiB,GAAG,4BAA4B,CAAC;AAE9D,uGAAuG;AAC1F,QAAA,kBAAkB,GAAG,wCAAwC,CAAC;AAE3E,yGAAyG;AAC5F,QAAA,wBAAwB,GAAG,kBAAkB,CAAC;AAE3D;;;GAGG;AACH,uFAAuF;AACvF,2GAA2G;AAC3G,SAAgB,wBAAwB,CAAC,MAAyB;IAC9D,OAAO;IACH,8FAA8F;IAC9F,wFAAwF;IACxF,6BAA6B,MAAM,CAAC,MAAM,6CAA6C;QACvF,MAAM,CAAC,GAAG,CAAC,CAAC,CAAS,EAAU,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QACxD,kGAAkG;QAClG,8FAA8F;QAC9F,qDAAqD;QACrD,8FAA8F;QAC9F,2FAA2F;QAC3F,gGAAgG;QAChG,8BAA8B;QAC9B,oGAAoG;QACpG,iGAAiG;QACjG,gDAAgD,iCAAqB,gCAAgC;QACrG,6EAA6E;QAC7E,iGAAiG;QACjG,kGAAkG;QAClG,kGAAkG;QAClG,oGAAoG;QACpG,iBAAiB;QACjB,iFAAiF;QACjF,qGAAqG;QACrG,iEAAiE;QACjE,+CAA+C,yBAAiB,EAAE,CACrE,CAAC;AACN,CAAC","sourcesContent":["/**\n * THE validation-failure banner for webpieces.config.json.\n *\n * ## The invariant: there is exactly ONE cure\n *\n * Every error this banner carries came from VALIDATING webpieces.config.json, so the file is the\n * defect and editing it is the fix. That is the whole instruction. Editing it is unconditionally\n * allowed (L0 allowlist entry 2) even while it is invalid, so the cure is always reachable.\n *\n * The banner this replaces printed a FIXED four-step \"FIX ORDER\" that led with `pnpm install`, and each\n * of those steps was wrong in its own way:\n *\n * - `pnpm install` CANNOT help. The committed shim (templates/ai-hook.sh) runs the guard bin only\n * under `[ -x \"$BIN\" ] && [ -z \"$DRIFT_PKG\" ]`, and DRIFT_PKG is set by comparing every exact-pinned\n * `@webpieces/*` spec in the root package.json against the installed version (a `catalog:` spec is\n * resolved through pnpm-lock.yaml first). So the validator only ever runs when package.json and\n * node_modules ALREADY agree: nothing is out of date to install. It is not a first step, it is a\n * detour — and it is the detour that sent an agent down the wrong path in the incident that\n * produced this rewrite. The one gap: the drift check skips RANGE specs (`^`, `~`, `workspace:*`),\n * so a repo pinning with ranges is outside that guarantee. This repo pins exactly\n * (validate-versions-locked).\n * - \"Retry your command\" was not a fix step at all. Retrying is implied by the first line.\n * - A fourth step prescribed an installer flag as a competing \"edit the config\" command. That flag no\n * longer exists, and the paragraph that offered it is gone with it: the banner names ONE action, and\n * an optional second command is how a reader comes to believe there is a choice to make.\n *\n * ## Why the negative instruction is here\n *\n * The failure mode was not a missing instruction, it was a generic ordered list — which is exactly how\n * an agent picks the wrong step. So the banner states what NOT to do as plainly as what to do: do not\n * run `pnpm install`. That is the only DO-NOT left, and it is the only one there was ever evidence for.\n *\n * ## The delete advice used to be INVERTED, and that inversion cost a consumer a day\n *\n * This banner used to say \"Do NOT delete a key just because it is reported unknown\", steering the reader\n * at the stale-PIN case first. That is backwards. A key the running validator has no schema for controls\n * NOTHING; leaving it in place is dead config that reads as live config to the next reader, and for a\n * RETIRED key deleting it is the entire fix. The sentence told the reader not to do the one thing that\n * works, for a key (`whole-repo-build-guard`) whose own retirement instruction is \"DELETE this entry\".\n *\n * So deletion is now the PRIMARY cure and it is MECHANICAL — `PRUNE_UNKNOWN_COMMAND` strips every unknown\n * key — while the stale pin is a secondary note. The stale pin can afford to be secondary because it is\n * not this banner's job at all: the version-drift guard in the shim compares the pin against the installed\n * version BEFORE exec'ing the validator, and on drift it denies every tool call with its own message and\n * its own cure. Reaching this banner is therefore evidence that no drift was detected.\n *\n * ## Nothing here is conditional\n *\n * The banner is the SAME for one error and for twenty: the bullets change, the instruction does not. It\n * names no installer command at all — a unit test asserts that — because every error it can carry is\n * cured by editing the file the errors came from.\n *\n * The markers below are the phrases the message builders (retired-config-keys.ts,\n * commands-section-validators.ts, validate-config.ts) embed rather than re-type, so a message and the\n * phrase other code searches for cannot drift apart.\n */\n\nimport { PRUNE_UNKNOWN_COMMAND } from './constants';\n\n/**\n * The background doc this banner sends the reader to, named ONCE so the link, the installer that ships\n * the file, and the spec that holds it to the banner's advice cannot drift apart.\n *\n * That drift is not hypothetical: the first cut of the delete-first rewrite fixed the banner and left\n * this document still saying \"Do not start by deleting keys\" and prescribing `pnpm install` first — i.e.\n * the message was cured and the page it cites went on teaching the thing that was removed.\n */\nexport const CONFIG_POLICY_DOC = 'webpieces.config-policy.md';\n\n/** `retiredKeyError` — every RETIRED_CONFIG_KEYS entry is one `migrate()` knows how to move/rename. */\nexport const RETIRED_KEY_MARKER = 'is a RETIRED webpieces.config.json key';\n\n/** `validateCommandsSection` — the retired TOP-LEVEL pr-gate block (a shape, so it has its own text). */\nexport const RETIRED_TOP_LEVEL_MARKER = 'block is RETIRED';\n\n/**\n * Assemble the banner: the errors, then the ONE cure, then the warnings. Nothing else belongs here —\n * see the module comment.\n */\n// webpieces-disable no-function-outside-class -- sibling string builder in this module\n// webpieces-disable max-lines-new-methods -- one contiguous string literal; splitting it hides the message\nexport function formatConfigErrorsBanner(errors: readonly string[]): string {\n return (\n // No \"then retry\". Retrying is not a fix STEP — the old banner spent one of its four numbered\n // steps on it, which is how \"run the command again\" came to look like a candidate cure.\n `webpieces.config.json has ${errors.length} validation error(s) — fix ALL of them:\\n\\n` +\n errors.map((e: string): string => ` • ${e}`).join('\\n') +\n `\\n\\n👉 THE FIX: edit webpieces.config.json and apply every • above. Each bullet names the exact ` +\n `change to make, and editing this file is ALWAYS allowed through the guard — including right ` +\n `now, while it is invalid. There is no other step.\\n` +\n ` • Do NOT run \\`pnpm install\\` — it cannot help. The guards only run when package.json and ` +\n `node_modules already agree, so there is nothing out of date to install. (Only exception: ` +\n `@webpieces deps pinned with a RANGE — ^ / ~ / workspace:* — which drift detection skips. This ` +\n `repo pins exact versions.)\\n` +\n ` • DO delete any key reported as an unknown rule. A key the validator has no schema for controls ` +\n `NOTHING — it is dead config that reads as live config to the next reader — and when the key is ` +\n `RETIRED, deleting it is the WHOLE fix. Run \\`${PRUNE_UNKNOWN_COMMAND}\\` to strip every unknown key ` +\n `mechanically, or delete them by hand; either way the file then validates.\\n` +\n ` • Secondary, and rare: a key can be valid-but-unlearned when package.json pins an @webpieces ` +\n `OLDER than this config was written for. You are not in that case here — the version-drift guard ` +\n `compares the pin against the installed version BEFORE this validator runs and denies every tool ` +\n `call with its own message and its own cure (bump the pin), so reaching this banner means no drift ` +\n `was detected.\\n` +\n ` • A MACHINE-LOCAL setting does not belong in this file at all. Those live in ` +\n `~/.webpieces/config.json under \"experimental\" — an optional file tracked by no repo, whose absence ` +\n `is the default behaviour. Delete the key here and put it there.` +\n `\\n\\nBackground: .webpieces-logs/instruct-ai/${CONFIG_POLICY_DOC}`\n );\n}\n"]}
1
+ {"version":3,"file":"config-error-banner.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/config-error-banner.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;;;AA0BH,4DA2BC;AAnDD,2CAAoD;AAEpD;;;;;;;GAOG;AACU,QAAA,iBAAiB,GAAG,4BAA4B,CAAC;AAE9D,uGAAuG;AAC1F,QAAA,kBAAkB,GAAG,wCAAwC,CAAC;AAE3E,yGAAyG;AAC5F,QAAA,wBAAwB,GAAG,kBAAkB,CAAC;AAE3D;;;GAGG;AACH,uFAAuF;AACvF,2GAA2G;AAC3G,SAAgB,wBAAwB,CAAC,MAAyB;IAC9D,OAAO;IACH,8FAA8F;IAC9F,wFAAwF;IACxF,6BAA6B,MAAM,CAAC,MAAM,6CAA6C;QACvF,MAAM,CAAC,GAAG,CAAC,CAAC,CAAS,EAAU,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QACxD,kGAAkG;QAClG,8FAA8F;QAC9F,qDAAqD;QACrD,8FAA8F;QAC9F,2FAA2F;QAC3F,gGAAgG;QAChG,8BAA8B;QAC9B,oGAAoG;QACpG,iGAAiG;QACjG,gDAAgD,iCAAqB,gCAAgC;QACrG,6EAA6E;QAC7E,iGAAiG;QACjG,kGAAkG;QAClG,kGAAkG;QAClG,oGAAoG;QACpG,iBAAiB;QACjB,iFAAiF;QACjF,qGAAqG;QACrG,iEAAiE;QACjE,0CAA0C,yBAAiB,EAAE,CAChE,CAAC;AACN,CAAC","sourcesContent":["/**\n * THE validation-failure banner for webpieces.config.json.\n *\n * ## The invariant: there is exactly ONE cure\n *\n * Every error this banner carries came from VALIDATING webpieces.config.json, so the file is the\n * defect and editing it is the fix. That is the whole instruction. Editing it is unconditionally\n * allowed (L0 allowlist entry 2) even while it is invalid, so the cure is always reachable.\n *\n * The banner this replaces printed a FIXED four-step \"FIX ORDER\" that led with `pnpm install`, and each\n * of those steps was wrong in its own way:\n *\n * - `pnpm install` CANNOT help. The committed shim (templates/ai-hook.sh) runs the guard bin only\n * under `[ -x \"$BIN\" ] && [ -z \"$DRIFT_PKG\" ]`, and DRIFT_PKG is set by comparing every exact-pinned\n * `@webpieces/*` spec in the root package.json against the installed version (a `catalog:` spec is\n * resolved through pnpm-lock.yaml first). So the validator only ever runs when package.json and\n * node_modules ALREADY agree: nothing is out of date to install. It is not a first step, it is a\n * detour — and it is the detour that sent an agent down the wrong path in the incident that\n * produced this rewrite. The one gap: the drift check skips RANGE specs (`^`, `~`, `workspace:*`),\n * so a repo pinning with ranges is outside that guarantee. This repo pins exactly\n * (validate-versions-locked).\n * - \"Retry your command\" was not a fix step at all. Retrying is implied by the first line.\n * - A fourth step prescribed an installer flag as a competing \"edit the config\" command. That flag no\n * longer exists, and the paragraph that offered it is gone with it: the banner names ONE action, and\n * an optional second command is how a reader comes to believe there is a choice to make.\n *\n * ## Why the negative instruction is here\n *\n * The failure mode was not a missing instruction, it was a generic ordered list — which is exactly how\n * an agent picks the wrong step. So the banner states what NOT to do as plainly as what to do: do not\n * run `pnpm install`. That is the only DO-NOT left, and it is the only one there was ever evidence for.\n *\n * ## The delete advice used to be INVERTED, and that inversion cost a consumer a day\n *\n * This banner used to say \"Do NOT delete a key just because it is reported unknown\", steering the reader\n * at the stale-PIN case first. That is backwards. A key the running validator has no schema for controls\n * NOTHING; leaving it in place is dead config that reads as live config to the next reader, and for a\n * RETIRED key deleting it is the entire fix. The sentence told the reader not to do the one thing that\n * works, for a key (`whole-repo-build-guard`) whose own retirement instruction is \"DELETE this entry\".\n *\n * So deletion is now the PRIMARY cure and it is MECHANICAL — `PRUNE_UNKNOWN_COMMAND` strips every unknown\n * key — while the stale pin is a secondary note. The stale pin can afford to be secondary because it is\n * not this banner's job at all: the version-drift guard in the shim compares the pin against the installed\n * version BEFORE exec'ing the validator, and on drift it denies every tool call with its own message and\n * its own cure. Reaching this banner is therefore evidence that no drift was detected.\n *\n * ## Nothing here is conditional\n *\n * The banner is the SAME for one error and for twenty: the bullets change, the instruction does not. It\n * names no installer command at all — a unit test asserts that — because every error it can carry is\n * cured by editing the file the errors came from.\n *\n * The markers below are the phrases the message builders (retired-config-keys.ts,\n * commands-section-validators.ts, validate-config.ts) embed rather than re-type, so a message and the\n * phrase other code searches for cannot drift apart.\n */\n\nimport { PRUNE_UNKNOWN_COMMAND } from './constants';\n\n/**\n * The background doc this banner sends the reader to, named ONCE so the link, the installer that ships\n * the file, and the spec that holds it to the banner's advice cannot drift apart.\n *\n * That drift is not hypothetical: the first cut of the delete-first rewrite fixed the banner and left\n * this document still saying \"Do not start by deleting keys\" and prescribing `pnpm install` first — i.e.\n * the message was cured and the page it cites went on teaching the thing that was removed.\n */\nexport const CONFIG_POLICY_DOC = 'webpieces.config-policy.md';\n\n/** `retiredKeyError` — every RETIRED_CONFIG_KEYS entry is one `migrate()` knows how to move/rename. */\nexport const RETIRED_KEY_MARKER = 'is a RETIRED webpieces.config.json key';\n\n/** `validateCommandsSection` — the retired TOP-LEVEL pr-gate block (a shape, so it has its own text). */\nexport const RETIRED_TOP_LEVEL_MARKER = 'block is RETIRED';\n\n/**\n * Assemble the banner: the errors, then the ONE cure, then the warnings. Nothing else belongs here —\n * see the module comment.\n */\n// webpieces-disable no-function-outside-class -- sibling string builder in this module\n// webpieces-disable max-lines-new-methods -- one contiguous string literal; splitting it hides the message\nexport function formatConfigErrorsBanner(errors: readonly string[]): string {\n return (\n // No \"then retry\". Retrying is not a fix STEP — the old banner spent one of its four numbered\n // steps on it, which is how \"run the command again\" came to look like a candidate cure.\n `webpieces.config.json has ${errors.length} validation error(s) — fix ALL of them:\\n\\n` +\n errors.map((e: string): string => ` • ${e}`).join('\\n') +\n `\\n\\n👉 THE FIX: edit webpieces.config.json and apply every • above. Each bullet names the exact ` +\n `change to make, and editing this file is ALWAYS allowed through the guard — including right ` +\n `now, while it is invalid. There is no other step.\\n` +\n ` • Do NOT run \\`pnpm install\\` — it cannot help. The guards only run when package.json and ` +\n `node_modules already agree, so there is nothing out of date to install. (Only exception: ` +\n `@webpieces deps pinned with a RANGE — ^ / ~ / workspace:* — which drift detection skips. This ` +\n `repo pins exact versions.)\\n` +\n ` • DO delete any key reported as an unknown rule. A key the validator has no schema for controls ` +\n `NOTHING — it is dead config that reads as live config to the next reader — and when the key is ` +\n `RETIRED, deleting it is the WHOLE fix. Run \\`${PRUNE_UNKNOWN_COMMAND}\\` to strip every unknown key ` +\n `mechanically, or delete them by hand; either way the file then validates.\\n` +\n ` • Secondary, and rare: a key can be valid-but-unlearned when package.json pins an @webpieces ` +\n `OLDER than this config was written for. You are not in that case here — the version-drift guard ` +\n `compares the pin against the installed version BEFORE this validator runs and denies every tool ` +\n `call with its own message and its own cure (bump the pin), so reaching this banner means no drift ` +\n `was detected.\\n` +\n ` • A MACHINE-LOCAL setting does not belong in this file at all. Those live in ` +\n `~/.webpieces/config.json under \"experimental\" — an optional file tracked by no repo, whose absence ` +\n `is the default behaviour. Delete the key here and put it there.` +\n `\\n\\nBackground: .webpieces/instruct-ai/${CONFIG_POLICY_DOC}`\n );\n}\n"]}
package/src/constants.js CHANGED
@@ -18,11 +18,11 @@ exports.WEBPIECES_DISABLE = 'webpieces-disable';
18
18
  // to block commit/push/PR until the merge is validated). Kept here so neither package
19
19
  // depends on the other — they only share this vocabulary.
20
20
  //
21
- // `.webpieces-logs/` is the single working dir for all webpieces tooling: ai-hook-rules
21
+ // `.webpieces/` is the single working dir for all webpieces tooling: ai-hook-rules
22
22
  // bootstrap/cache, the instruct-ai docs, and the workflow state. To keep the top level
23
23
  // quiet, per-feature workflow dirs are nested one level down under `merge-info/<feature>`
24
24
  // and `pr-review/<feature>` rather than scattered as top-level `merge-<feature>`/`pr-<feature>`.
25
- // `.webpieces-logs/` is gitignored; only the per-feature subdirs under those two homes are subject
25
+ // `.webpieces/` is gitignored; only the per-feature subdirs under those two homes are subject
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
@@ -39,7 +39,7 @@ exports.MERGE_IN_PROGRESS_FILE = 'merge-in-progress.json';
39
39
  // pr-gate commands WRITE it and things outside pr-gate READ it to decide whether a resolve is
40
40
  // half-finished, and neither side may depend on the other.
41
41
  //
42
- // It lives directly under `.webpieces-logs/` local state (NOT under merge-info/), because a dev-deploy
42
+ // It lives directly under `.webpieces/` local state (NOT under merge-info/), because a dev-deploy
43
43
  // resolve is not a 3-point merge: it never touches the feature branch, never produces merge-info
44
44
  // context, and must NOT be picked up by merge-in-progress-guard's marker scan — that guard's remedy
45
45
  // is `pnpm wp-finish-upsert-pr`, which is the wrong command here and would strand the tmp branch.
@@ -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,wFAAwF;AACxF,uFAAuF;AACvF,0FAA0F;AAC1F,iGAAiG;AACjG,mGAAmG;AACnG,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,uGAAuG;AACvG,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-logs/` 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-logs/` 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-logs/` 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,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"]}