@webpieces/pr-gate 0.4.849 → 0.4.851

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webpieces/pr-gate",
3
- "version": "0.4.849",
3
+ "version": "0.4.851",
4
4
  "description": "Gated PR system: 3-point squash-merge, merge validation gate, and red/yellow/green PR dashboard. Standalone scripts, no Nx dependency required.",
5
5
  "type": "commonjs",
6
6
  "main": "./src/index.js",
@@ -16,18 +16,18 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "@inversifyjs/binding-decorators": "1.1.5",
19
- "@webpieces/hook-runtime": "0.4.849",
20
- "@webpieces/rules-config": "0.4.849",
19
+ "@webpieces/hook-runtime": "0.4.851",
20
+ "@webpieces/rules-config": "0.4.851",
21
21
  "inversify": "7.10.4",
22
22
  "reflect-metadata": "0.2.2",
23
- "@webpieces/tooling-common": "0.4.849",
24
- "@webpieces/repo-workflow-core": "0.4.849"
23
+ "@webpieces/tooling-common": "0.4.851",
24
+ "@webpieces/repo-workflow-core": "0.4.851"
25
25
  },
26
26
  "publishConfig": {
27
27
  "access": "public"
28
28
  },
29
29
  "devDependencies": {
30
- "@webpieces/tooling-testkit": "0.4.849"
30
+ "@webpieces/tooling-testkit": "0.4.851"
31
31
  },
32
32
  "types": "./src/index.d.ts",
33
33
  "bin": {
@@ -8,7 +8,9 @@
8
8
  *
9
9
  * 1. `checklists` is dropped. Its `doc` paths are validated REPO-RELATIVE and point at
10
10
  * `.claude/review/*.md`, which exist here and not in a temp clone.
11
- * 2. Every locally-known rule is completed from its SEED. The repo's config is validated by the PUBLISHED
11
+ * 2. Explicit owner files are read from the root declarations and converted to the frozen
12
+ * PolicyFixture transport ONLY inside these tests. Production loading accepts only owner files.
13
+ * Every locally-known rule is completed from its SEED. The repo's config is validated by the PUBLISHED
12
14
  * validator and therefore lags local source by one release
13
15
  * (`.claude/rules/published-vs-local-source.md`): a rule added in this working tree cannot get a
14
16
  * config entry or newly-required field until its release ships,
@@ -29,7 +31,7 @@
29
31
  export declare class RepoConfigFixture {
30
32
  /** The repo's config as a mutable object, checklists dropped and local seed fields completed. */
31
33
  load(): Record<string, unknown>;
32
- private dropRetiredRules;
34
+ private loadOwnedRules;
33
35
  /** Write `config` (usually a `load()` result a spec has edited) as the config of `dir`. */
34
36
  writeTo(dir: string, config: Record<string, unknown>): void;
35
37
  private completeRulesFromSeed;
@@ -18,7 +18,9 @@ const rules_config_2 = require("@webpieces/rules-config");
18
18
  *
19
19
  * 1. `checklists` is dropped. Its `doc` paths are validated REPO-RELATIVE and point at
20
20
  * `.claude/review/*.md`, which exist here and not in a temp clone.
21
- * 2. Every locally-known rule is completed from its SEED. The repo's config is validated by the PUBLISHED
21
+ * 2. Explicit owner files are read from the root declarations and converted to the frozen
22
+ * PolicyFixture transport ONLY inside these tests. Production loading accepts only owner files.
23
+ * Every locally-known rule is completed from its SEED. The repo's config is validated by the PUBLISHED
22
24
  * validator and therefore lags local source by one release
23
25
  * (`.claude/rules/published-vs-local-source.md`): a rule added in this working tree cannot get a
24
26
  * config entry or newly-required field until its release ships,
@@ -53,23 +55,29 @@ class RepoConfigFixture {
53
55
  if (prGate['overrideReviewerAgent'] !== true && prGate['reviewerAgentName'] === rules_config_2.DEFAULT_REVIEWER_AGENT_NAME) {
54
56
  delete prGate['reviewerAgentName'];
55
57
  }
56
- this.dropRetiredRules(config);
58
+ this.loadOwnedRules(config, path.dirname(source));
57
59
  this.completeRulesFromSeed(config);
58
60
  return config;
59
61
  }
60
- // Drop every rule/guard name this build knows to be RETIRED, from whichever section holds it.
61
- // webpieces-disable no-any-unknown -- see load()
62
- dropRetiredRules(config) {
63
- for (const section of ['rules', 'hookGuards']) {
64
- // webpieces-disable no-any-unknown -- narrowing one rule section
65
- const entries = config[section];
66
- if (entries === undefined)
67
- continue;
62
+ // webpieces-disable no-any-unknown -- test-only transport for PolicyFixture.writeOwnerConfig, never a production accepted shape
63
+ loadOwnedRules(config, root) {
64
+ // webpieces-disable no-any-unknown -- parsed owner entries remain opaque until fixture validation
65
+ const rules = {};
66
+ // webpieces-disable no-any-unknown -- parsed owner entries remain opaque until fixture validation
67
+ const guards = {};
68
+ const declarations = new rules_config_2.PackPolicyFiles().declarations(config['rulePacks'], root);
69
+ for (const declaration of declarations) {
70
+ // webpieces-disable no-any-unknown -- repository owner JSON, consumed by the real fixture validator
71
+ const entries = JSON.parse(fs.readFileSync(path.join(root, declaration.config), 'utf8'));
68
72
  for (const name of Object.keys(entries)) {
69
73
  if ((0, rules_config_2.retiredRuleFor)(name, fixtureRuleRegistry) !== null)
70
- delete entries[name];
74
+ continue;
75
+ const section = (0, rules_config_2.sectionForRule)(name, fixtureRuleRegistry) === 'hookGuards' ? guards : rules;
76
+ section[name] = entries[name];
71
77
  }
72
78
  }
79
+ config['rules'] = rules;
80
+ config['hookGuards'] = guards;
73
81
  }
74
82
  /** Write `config` (usually a `load()` result a spec has edited) as the config of `dir`. */
75
83
  // webpieces-disable no-any-unknown -- see load()
@@ -1 +1 @@
1
- {"version":3,"file":"repo-config-testkit.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/repo-config-testkit.ts"],"names":[],"mappings":";;;;AAAA,gEAA2D;AAC3D,0DAA2D;AAC3D,MAAM,mBAAmB,GAAG,IAAI,+BAAgB,CAAC,+BAAa,CAAC,SAAS,EAAE,CAAC,CAAC;AAC5E,+CAAyB;AACzB,mDAA6B;AAE7B,0DAEiC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAa,iBAAiB;IAC1B,iGAAiG;IACjG,mGAAmG;IACnG,IAAI;QACA,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,uBAAuB,CAAC,CAAC;QACjG,mFAAmF;QACnF,M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O,CAAC,GAAW,EAAE,MAA+B;QAChD,+BAAa,CAAC,gBAAgB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAChD,CAAC;IAED,iDAAiD;IACzC,qBAAqB,CAAC,MAA+B;QACzD,sEAAsE;QACtE,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAA4B,CAAC;QACzD,sEAAsE;QACtE,MAAM,MAAM,GAAG,MAAM,CAAC,YAAY,CAA4B,CAAC;QAC/D,KAAK,MAAM,IAAI,IAAI,IAAA,2BAAY,EAAC,mBAAmB,CAAC,EAAE,CAAC;YACnD,MAAM,OAAO,GAAG,IAAA,6BAAc,EAAC,IAAI,EAAE,mBAAmB,CAAC,KAAK,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;YAC5F,MAAM,IAAI,GAAG,IAAA,+BAAgB,EAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC;YACzD,iGAAiG;YACjG,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAwC,CAAC;YACtE,OAAO,CAAC,IAAI,CAAC,GAAG,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,EAAE,CAAC;QAC7E,CAAC;IACL,CAAC;CACJ;AAvDD,8CAuDC","sourcesContent":["import { policyFixture } from '@webpieces/tooling-testkit';\nimport { RulePackRegistry } from '@webpieces/rules-config';\nconst fixtureRuleRegistry = new RulePackRegistry(policyFixture.manifests());\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nimport {\n allRuleNames, DEFAULT_REVIEWER_AGENT_NAME, retiredRuleFor, sectionForRule, seedEntryForRule,\n} from '@webpieces/rules-config';\n\n/**\n * THIS repo's own `webpieces.config.json`, prepared for use inside a temp clone.\n *\n * Specs that exercise a command end-to-end need a config the REAL validator accepts, and using the\n * repo's own file (rather than a hand-rolled minimal one) is what keeps them honest — a stub drifts out\n * from under the validator on the next config change. These adjustments are needed to make that file\n * usable outside this checkout, and all are the same for every such spec, so they live here once:\n *\n * 1. `checklists` is dropped. Its `doc` paths are validated REPO-RELATIVE and point at\n * `.claude/review/*.md`, which exist here and not in a temp clone.\n * 2. Every locally-known rule is completed from its SEED. The repo's config is validated by the PUBLISHED\n * validator and therefore lags local source by one release\n * (`.claude/rules/published-vs-local-source.md`): a rule added in this working tree cannot get a\n * config entry or newly-required field until its release ships,\n * while the LOCAL validator a spec runs already demands one. Without this, adding any rule turns\n * these specs red for exactly one release — a failure that says nothing about the code under test.\n * 3. Every RETIRED rule entry is dropped — the same one-release lag pointing the other way. When a rule\n * is retired in this working tree, the repo's config must KEEP its entry until the release carrying\n * the retirement ships (deleting it early would fail the published validator and block every Bash\n * call), while the LOCAL validator already REJECTS it. Same trade as (2), same fix.\n * 4. A `commands.pr-gate.reviewerAgentName` naming the webpieces default WITHOUT `overrideReviewerAgent`\n * is dropped — the same one-release lag again (issue #947). The published validator still REQUIRES the\n * key, so the repo's config must carry it until the release making it optional ships, while the LOCAL\n * validator already rejects a name without the override. A follow-up PR removes it from the live config.\n *\n * A testkit, not product code: nothing in a published bin imports it (same role as ai-hook-rules'\n * `shim-testkit.ts`).\n */\nexport class RepoConfigFixture {\n /** The repo's config as a mutable object, checklists dropped and local seed fields completed. */\n // webpieces-disable no-any-unknown -- the repo's own config document, opaque until a spec edits it\n load(): Record<string, unknown> {\n const source = path.join(__dirname, '..', '..', '..', '..', '..', '..', 'webpieces.config.json');\n // webpieces-disable no-any-unknown -- parsed JSON, narrowed by the accessors below\n const config = JSON.parse(fs.readFileSync(source, 'utf8')) as Record<string, unknown>;\n // webpieces-disable no-any-unknown -- narrowing one nested section\n const commands = config['commands'] as Record<string, Record<string, unknown>>;\n delete commands['pr-gate']['checklists'];\n delete commands['pr-gate']['checklistsWhy'];\n const prGate = commands['pr-gate'];\n // Local source requires this before the published validator permits the live repo to add it.\n prGate['maxReviewerRounds'] = 2;\n if (prGate['overrideReviewerAgent'] !== true && prGate['reviewerAgentName'] === DEFAULT_REVIEWER_AGENT_NAME) {\n delete prGate['reviewerAgentName'];\n }\n this.dropRetiredRules(config);\n this.completeRulesFromSeed(config);\n return config;\n }\n\n // Drop every rule/guard name this build knows to be RETIRED, from whichever section holds it.\n // webpieces-disable no-any-unknown -- see load()\n private dropRetiredRules(config: Record<string, unknown>): void {\n for (const section of ['rules', 'hookGuards']) {\n // webpieces-disable no-any-unknown -- narrowing one rule section\n const entries = config[section] as Record<string, unknown> | undefined;\n if (entries === undefined) continue;\n for (const name of Object.keys(entries)) {\n if (retiredRuleFor(name, fixtureRuleRegistry) !== null) delete entries[name];\n }\n }\n }\n\n /** Write `config` (usually a `load()` result a spec has edited) as the config of `dir`. */\n // webpieces-disable no-any-unknown -- see load()\n writeTo(dir: string, config: Record<string, unknown>): void {\n policyFixture.writeOwnerConfig(dir, config);\n }\n\n // webpieces-disable no-any-unknown -- see load()\n private completeRulesFromSeed(config: Record<string, unknown>): void {\n // webpieces-disable no-any-unknown -- narrowing the two rule sections\n const rules = config['rules'] as Record<string, unknown>;\n // webpieces-disable no-any-unknown -- narrowing the two rule sections\n const guards = config['hookGuards'] as Record<string, unknown>;\n for (const name of allRuleNames(fixtureRuleRegistry)) {\n const section = sectionForRule(name, fixtureRuleRegistry) === 'hookGuards' ? guards : rules;\n const seed = seedEntryForRule(name, fixtureRuleRegistry);\n // webpieces-disable no-any-unknown -- one rule's opaque config entry, merged over its typed seed\n const existing = section[name] as Record<string, unknown> | undefined;\n section[name] = existing === undefined ? seed : { ...seed, ...existing };\n }\n }\n}\n"]}
1
+ {"version":3,"file":"repo-config-testkit.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/repo-config-testkit.ts"],"names":[],"mappings":";;;;AAAA,gEAA2D;AAC3D,0DAA2D;AAC3D,MAAM,mBAAmB,GAAG,IAAI,+BAAgB,CAAC,+BAAa,CAAC,SAAS,EAAE,CAAC,CAAC;AAC5E,+CAAyB;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;YACnD,MAAM,OAAO,GAAG,IAAA,6BAAc,EAAC,IAAI,EAAE,mBAAmB,CAAC,KAAK,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;YAC5F,MAAM,IAAI,GAAG,IAAA,+BAAgB,EAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC;YACzD,iGAAiG;YACjG,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAwC,CAAC;YACtE,OAAO,CAAC,IAAI,CAAC,GAAG,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,EAAE,CAAC;QAC7E,CAAC;IACL,CAAC;CACJ;AA9DD,8CA8DC","sourcesContent":["import { policyFixture } from '@webpieces/tooling-testkit';\nimport { RulePackRegistry } from '@webpieces/rules-config';\nconst fixtureRuleRegistry = new RulePackRegistry(policyFixture.manifests());\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nimport {\n allRuleNames, DEFAULT_REVIEWER_AGENT_NAME, PackPolicyFiles, retiredRuleFor, sectionForRule, seedEntryForRule,\n} from '@webpieces/rules-config';\n\n/**\n * THIS repo's own `webpieces.config.json`, prepared for use inside a temp clone.\n *\n * Specs that exercise a command end-to-end need a config the REAL validator accepts, and using the\n * repo's own file (rather than a hand-rolled minimal one) is what keeps them honest — a stub drifts out\n * from under the validator on the next config change. These adjustments are needed to make that file\n * usable outside this checkout, and all are the same for every such spec, so they live here once:\n *\n * 1. `checklists` is dropped. Its `doc` paths are validated REPO-RELATIVE and point at\n * `.claude/review/*.md`, which exist here and not in a temp clone.\n * 2. Explicit owner files are read from the root declarations and converted to the frozen\n * PolicyFixture transport ONLY inside these tests. Production loading accepts only owner files.\n * Every locally-known rule is completed from its SEED. The repo's config is validated by the PUBLISHED\n * validator and therefore lags local source by one release\n * (`.claude/rules/published-vs-local-source.md`): a rule added in this working tree cannot get a\n * config entry or newly-required field until its release ships,\n * while the LOCAL validator a spec runs already demands one. Without this, adding any rule turns\n * these specs red for exactly one release — a failure that says nothing about the code under test.\n * 3. Every RETIRED rule entry is dropped — the same one-release lag pointing the other way. When a rule\n * is retired in this working tree, the repo's config must KEEP its entry until the release carrying\n * the retirement ships (deleting it early would fail the published validator and block every Bash\n * call), while the LOCAL validator already REJECTS it. Same trade as (2), same fix.\n * 4. A `commands.pr-gate.reviewerAgentName` naming the webpieces default WITHOUT `overrideReviewerAgent`\n * is dropped — the same one-release lag again (issue #947). The published validator still REQUIRES the\n * key, so the repo's config must carry it until the release making it optional ships, while the LOCAL\n * validator already rejects a name without the override. A follow-up PR removes it from the live config.\n *\n * A testkit, not product code: nothing in a published bin imports it (same role as ai-hook-rules'\n * `shim-testkit.ts`).\n */\nexport class RepoConfigFixture {\n /** The repo's config as a mutable object, checklists dropped and local seed fields completed. */\n // webpieces-disable no-any-unknown -- the repo's own config document, opaque until a spec edits it\n load(): Record<string, unknown> {\n const source = path.join(__dirname, '..', '..', '..', '..', '..', '..', 'webpieces.config.json');\n // webpieces-disable no-any-unknown -- parsed JSON, narrowed by the accessors below\n const config = JSON.parse(fs.readFileSync(source, 'utf8')) as Record<string, unknown>;\n // webpieces-disable no-any-unknown -- narrowing one nested section\n const commands = config['commands'] as Record<string, Record<string, unknown>>;\n delete commands['pr-gate']['checklists'];\n delete commands['pr-gate']['checklistsWhy'];\n const prGate = commands['pr-gate'];\n // Local source requires this before the published validator permits the live repo to add it.\n prGate['maxReviewerRounds'] = 2;\n if (prGate['overrideReviewerAgent'] !== true && prGate['reviewerAgentName'] === DEFAULT_REVIEWER_AGENT_NAME) {\n delete prGate['reviewerAgentName'];\n }\n this.loadOwnedRules(config, path.dirname(source));\n this.completeRulesFromSeed(config);\n return config;\n }\n\n // webpieces-disable no-any-unknown -- test-only transport for PolicyFixture.writeOwnerConfig, never a production accepted shape\n private loadOwnedRules(config: Record<string, unknown>, root: string): void {\n // webpieces-disable no-any-unknown -- parsed owner entries remain opaque until fixture validation\n const rules: Record<string, unknown> = {};\n // webpieces-disable no-any-unknown -- parsed owner entries remain opaque until fixture validation\n const guards: Record<string, unknown> = {};\n const declarations = new PackPolicyFiles().declarations(config['rulePacks'], root);\n for (const declaration of declarations) {\n // webpieces-disable no-any-unknown -- repository owner JSON, consumed by the real fixture validator\n const entries = JSON.parse(fs.readFileSync(path.join(root, declaration.config), 'utf8')) as Record<string, unknown>;\n for (const name of Object.keys(entries)) {\n if (retiredRuleFor(name, fixtureRuleRegistry) !== null) continue;\n const section = sectionForRule(name, fixtureRuleRegistry) === 'hookGuards' ? guards : rules;\n section[name] = entries[name];\n }\n }\n config['rules'] = rules;\n config['hookGuards'] = guards;\n }\n\n /** Write `config` (usually a `load()` result a spec has edited) as the config of `dir`. */\n // webpieces-disable no-any-unknown -- see load()\n writeTo(dir: string, config: Record<string, unknown>): void {\n policyFixture.writeOwnerConfig(dir, config);\n }\n\n // webpieces-disable no-any-unknown -- see load()\n private completeRulesFromSeed(config: Record<string, unknown>): void {\n // webpieces-disable no-any-unknown -- narrowing the two rule sections\n const rules = config['rules'] as Record<string, unknown>;\n // webpieces-disable no-any-unknown -- narrowing the two rule sections\n const guards = config['hookGuards'] as Record<string, unknown>;\n for (const name of allRuleNames(fixtureRuleRegistry)) {\n const section = sectionForRule(name, fixtureRuleRegistry) === 'hookGuards' ? guards : rules;\n const seed = seedEntryForRule(name, fixtureRuleRegistry);\n // webpieces-disable no-any-unknown -- one rule's opaque config entry, merged over its typed seed\n const existing = section[name] as Record<string, unknown> | undefined;\n section[name] = existing === undefined ? seed : { ...seed, ...existing };\n }\n }\n}\n"]}
@@ -64,7 +64,7 @@ let ReviewerIdentityResolver = class ReviewerIdentityResolver {
64
64
  }
65
65
  const inHarness = HARNESS_ENV.filter((name) => (env[name] ?? '').trim() !== '');
66
66
  if (inHarness.length > 0)
67
- throw new tooling_common_1.InformAiError(this.unstampedRefusal(checklistId, inHarness));
67
+ throw new tooling_common_1.InformAiError(this.unstampedRefusal(cwd, checklistId, inHarness));
68
68
  return new ReviewerIdentity(verdict_provenance_1.HARNESS_TERMINAL, '', '', '');
69
69
  }
70
70
  coordinatorRefusal(checklistId, aiType) {
@@ -74,13 +74,16 @@ let ReviewerIdentityResolver = class ReviewerIdentityResolver {
74
74
  + 'Spawn the reviewer subagent pnpm wp-review-upsert-pr names and hand it the instructions file; the\n'
75
75
  + 'reviewer submits its own verdict.';
76
76
  }
77
- unstampedRefusal(checklistId, harnessEnv) {
78
- return `${repo_workflow_core_1.WRITE_REVIEW_BIN} REFUSED: this process runs under an AI harness (${harnessEnv.join(', ')} set), but the\n`
79
- + `webpieces PreToolUse hook left no identity stamp for checklist "${checklistId}", so nothing can say whether a\n`
80
- + 'reviewer subagent or the coordinator is calling.\n\n'
81
- + `Run it as a plain Bash command the hook can read, naming the checklist literally:\n`
82
- + ` pnpm ${repo_workflow_core_1.WRITE_REVIEW_BIN} --checklist ${checklistId} <<'EOF' … EOF\n`
83
- + 'If it already was, the webpieces hooks are not installed in this harness: pnpm wp-install-ai-hooks.';
77
+ unstampedRefusal(cwd, checklistId, harnessEnv) {
78
+ return (`${repo_workflow_core_1.WRITE_REVIEW_BIN} REFUSED: this process runs under an AI harness (${harnessEnv.join(', ')} set), but the\n` +
79
+ `expected worktree has no usable identity stamp for checklist "${checklistId}", so nothing can say whether a\n` +
80
+ 'reviewer subagent or the coordinator is calling.\n\n' +
81
+ `Submission cwd: ${cwd}\nExpected stamp: ${this.stamps.stampPath(cwd, checklistId)}\n\n` +
82
+ 'The hook may have written a stamp in the session checkout instead of this worktree. Use a literal\n' +
83
+ 'leading cd to the absolute reviewed worktree path, then name the checklist literally:\n' +
84
+ ` cd '/absolute/reviewed-worktree' && pnpm ${repo_workflow_core_1.WRITE_REVIEW_BIN} --checklist ${checklistId} <<'EOF' … EOF\n` +
85
+ 'Do not rely on exec_command.workdir alone when the hook exposes only the session cwd. Check hook\n' +
86
+ 'delivery and its selected tree; reinstall hooks only if they are actually missing.');
84
87
  }
85
88
  };
86
89
  exports.ReviewerIdentityResolver = ReviewerIdentityResolver;
@@ -1 +1 @@
1
- {"version":3,"file":"reviewer-identity.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/reviewer-identity.ts"],"names":[],"mappings":";;;;AAAA,8DAA0D;AAC1D,sEAA6F;AAC7F,yCAA2D;AAC3D,6DAAwD;AAExD;;;;GAIG;AACH,MAAM,WAAW,GAAG,CAAC,YAAY,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,iBAAiB,CAAU,CAAC;AAE7G,8CAA8C;AAC9C,MAAa,gBAAgB;IACzB,OAAO,CAAS;IAChB,SAAS,CAAS;IAClB,OAAO,CAAS;IAChB,SAAS,CAAS;IAElB,yDAAyD;IACzD,YAAY,OAAe,EAAE,SAAiB,EAAE,OAAe,EAAE,SAAiB;QAC9E,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;CACJ;AAbD,4CAaC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEI,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IACJ;IAA7B,YAA6B,MAAkC;QAAlC,WAAM,GAAN,MAAM,CAA4B;IAAG,CAAC;IAEnE,OAAO,CAAC,GAAW,EAAE,WAAmB,EAAE,MAAyB,OAAO,CAAC,GAAG;QAC1E,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;QACjD,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACjB,IAAI,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC;gBAAE,MAAM,IAAI,8BAAa,CAAC,IAAI,CAAC,kBAAkB,CAAC,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;YAClH,OAAO,IAAI,gBAAgB,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;QAC/F,CAAC;QACD,MAAM,SAAS,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,IAAY,EAAW,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QACjG,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC;YAAE,MAAM,IAAI,8BAAa,CAAC,IAAI,CAAC,gBAAgB,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC,CAAC;QACjG,OAAO,IAAI,gBAAgB,CAAC,qCAAgB,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IAC9D,CAAC;IAEO,kBAAkB,CAAC,WAAmB,EAAE,MAAc;QAC1D,OAAO,GAAG,qCAAgB,iBAAiB,MAAM,uEAAuE;cAClH,iFAAiF,WAAW,mBAAmB;cAC/G,sGAAsG;cACtG,qGAAqG;cACrG,mCAAmC,CAAC;IAC9C,CAAC;IAEO,gBAAgB,CAAC,WAAmB,EAAE,UAA6B;QACvE,OAAO,GAAG,qCAAgB,oDAAoD,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB;cAC/G,mEAAmE,WAAW,mCAAmC;cACjH,sDAAsD;cACtD,qFAAqF;cACrF,YAAY,qCAAgB,gBAAgB,WAAW,kBAAkB;cACzE,qGAAqG,CAAC;IAChH,CAAC;CACJ,CAAA;AA9BY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEA,+CAA0B;GADtD,wBAAwB,CA8BpC","sourcesContent":["import { InformAiError } from '@webpieces/tooling-common';\nimport { ReviewIdentityStampService, WRITE_REVIEW_BIN } from '@webpieces/repo-workflow-core';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { HARNESS_TERMINAL } from './verdict-provenance';\n\n/**\n * Env vars whose presence means an AI harness launched this process. Any one of them and there MUST be a\n * hook stamp — a harness-launched submission without one either bypassed the hook or ran where the hook is\n * not installed, and neither can say who is calling.\n */\nconst HARNESS_ENV = ['CLAUDECODE', 'CLAUDE_CODE_SESSION_ID', 'CODEX_SESSION_ID', 'CODEX_THREAD_ID'] as const;\n\n/** WHO is submitting a verdict. Data-only. */\nexport class ReviewerIdentity {\n harness: string;\n sessionId: string;\n agentId: string;\n agentType: string;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(harness: string, sessionId: string, agentId: string, agentType: string) {\n this.harness = harness;\n this.sessionId = sessionId;\n this.agentId = agentId;\n this.agentType = agentType;\n }\n}\n\n/**\n * Answers \"who is running `wp-write-review`?\" — and REFUSES the coordinating agent (issue #863).\n *\n * The mechanism, per harness, and why it is not the environment:\n * - CLAUDE CODE: a Bash child inherits `CLAUDE_CODE_SESSION_ID`, which is the PARENT session's id inside\n * a subagent too, and there is no agent id in the env at all. Env cannot tell a reviewer from its\n * coordinator.\n * - CODEX: `CODEX_SESSION_ID` / `CODEX_THREAD_ID` are exported, but nothing documents — and nothing here\n * has measured — that a spawned subagent gets its own thread id instead of the coordinator's.\n * - BOTH: the PreToolUse hook payload carries `agent_id`, empty for the main loop and set for a subagent,\n * on the same key in both harnesses. So the hook writes a {@link ReviewIdentityStamp} for each\n * checklist a `wp-write-review` command names, just before the command runs, and this consumes it.\n *\n * The plain-terminal story: with NO harness env and no stamp, the caller is a HUMAN at a terminal. That is\n * a legitimate reviewer, and the verdict is recorded with harness `terminal`. CI never submits verdicts —\n * `.webpieces/` is not in the repo, so there is nothing for CI to read or write here.\n *\n * NOT tamper-proof: an agent can scrub its env AND invoke the bin some way the hook does not recognise, or\n * forge a stamp file. That is deliberate, visible forgery in the transcript — the bar the rest of reviewer\n * provenance sets — rather than the one ordinary file write it used to take.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ReviewerIdentityResolver {\n constructor(private readonly stamps: ReviewIdentityStampService) {}\n\n resolve(cwd: string, checklistId: string, env: NodeJS.ProcessEnv = process.env): ReviewerIdentity {\n const stamp = this.stamps.take(cwd, checklistId);\n if (stamp !== null) {\n if (this.stamps.isCoordinator(stamp)) throw new InformAiError(this.coordinatorRefusal(checklistId, stamp.aiType));\n return new ReviewerIdentity(stamp.aiType, stamp.sessionId, stamp.agentId, stamp.agentType);\n }\n const inHarness = HARNESS_ENV.filter((name: string): boolean => (env[name] ?? '').trim() !== '');\n if (inHarness.length > 0) throw new InformAiError(this.unstampedRefusal(checklistId, inHarness));\n return new ReviewerIdentity(HARNESS_TERMINAL, '', '', '');\n }\n\n private coordinatorRefusal(checklistId: string, aiType: string): string {\n return `${WRITE_REVIEW_BIN} REFUSED: the ${aiType} harness reports this call comes from the COORDINATING agent, not a\\n`\n + `reviewer subagent. The coordinator may never submit a reviewer's verdict for \"${checklistId}\" — not by this\\n`\n + 'bin, and not by writing the file (wp-finish-upsert-pr rejects a verdict this bin did not write).\\n\\n'\n + 'Spawn the reviewer subagent pnpm wp-review-upsert-pr names and hand it the instructions file; the\\n'\n + 'reviewer submits its own verdict.';\n }\n\n private unstampedRefusal(checklistId: string, harnessEnv: readonly string[]): string {\n return `${WRITE_REVIEW_BIN} REFUSED: this process runs under an AI harness (${harnessEnv.join(', ')} set), but the\\n`\n + `webpieces PreToolUse hook left no identity stamp for checklist \"${checklistId}\", so nothing can say whether a\\n`\n + 'reviewer subagent or the coordinator is calling.\\n\\n'\n + `Run it as a plain Bash command the hook can read, naming the checklist literally:\\n`\n + ` pnpm ${WRITE_REVIEW_BIN} --checklist ${checklistId} <<'EOF' … EOF\\n`\n + 'If it already was, the webpieces hooks are not installed in this harness: pnpm wp-install-ai-hooks.';\n }\n}\n"]}
1
+ {"version":3,"file":"reviewer-identity.js","sour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@webpieces/tooling-common';\nimport { ReviewIdentityStampService, WRITE_REVIEW_BIN } from '@webpieces/repo-workflow-core';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { HARNESS_TERMINAL } from './verdict-provenance';\n\n/**\n * Env vars whose presence means an AI harness launched this process. Any one of them and there MUST be a\n * hook stamp — a harness-launched submission without one either bypassed the hook or ran where the hook is\n * not installed, and neither can say who is calling.\n */\nconst HARNESS_ENV = ['CLAUDECODE', 'CLAUDE_CODE_SESSION_ID', 'CODEX_SESSION_ID', 'CODEX_THREAD_ID'] as const;\n\n/** WHO is submitting a verdict. Data-only. */\nexport class ReviewerIdentity {\n harness: string;\n sessionId: string;\n agentId: string;\n agentType: string;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(harness: string, sessionId: string, agentId: string, agentType: string) {\n this.harness = harness;\n this.sessionId = sessionId;\n this.agentId = agentId;\n this.agentType = agentType;\n }\n}\n\n/**\n * Answers \"who is running `wp-write-review`?\" — and REFUSES the coordinating agent (issue #863).\n *\n * The mechanism, per harness, and why it is not the environment:\n * - CLAUDE CODE: a Bash child inherits `CLAUDE_CODE_SESSION_ID`, which is the PARENT session's id inside\n * a subagent too, and there is no agent id in the env at all. Env cannot tell a reviewer from its\n * coordinator.\n * - CODEX: `CODEX_SESSION_ID` / `CODEX_THREAD_ID` are exported, but nothing documents — and nothing here\n * has measured — that a spawned subagent gets its own thread id instead of the coordinator's.\n * - BOTH: the PreToolUse hook payload carries `agent_id`, empty for the main loop and set for a subagent,\n * on the same key in both harnesses. So the hook writes a {@link ReviewIdentityStamp} for each\n * checklist a `wp-write-review` command names, just before the command runs, and this consumes it.\n *\n * The plain-terminal story: with NO harness env and no stamp, the caller is a HUMAN at a terminal. That is\n * a legitimate reviewer, and the verdict is recorded with harness `terminal`. CI never submits verdicts —\n * `.webpieces/` is not in the repo, so there is nothing for CI to read or write here.\n *\n * NOT tamper-proof: an agent can scrub its env AND invoke the bin some way the hook does not recognise, or\n * forge a stamp file. That is deliberate, visible forgery in the transcript — the bar the rest of reviewer\n * provenance sets — rather than the one ordinary file write it used to take.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ReviewerIdentityResolver {\n constructor(private readonly stamps: ReviewIdentityStampService) {}\n\n resolve(cwd: string, checklistId: string, env: NodeJS.ProcessEnv = process.env): ReviewerIdentity {\n const stamp = this.stamps.take(cwd, checklistId);\n if (stamp !== null) {\n if (this.stamps.isCoordinator(stamp)) throw new InformAiError(this.coordinatorRefusal(checklistId, stamp.aiType));\n return new ReviewerIdentity(stamp.aiType, stamp.sessionId, stamp.agentId, stamp.agentType);\n }\n const inHarness = HARNESS_ENV.filter((name: string): boolean => (env[name] ?? '').trim() !== '');\n if (inHarness.length > 0) throw new InformAiError(this.unstampedRefusal(cwd, checklistId, inHarness));\n return new ReviewerIdentity(HARNESS_TERMINAL, '', '', '');\n }\n\n private coordinatorRefusal(checklistId: string, aiType: string): string {\n return `${WRITE_REVIEW_BIN} REFUSED: the ${aiType} harness reports this call comes from the COORDINATING agent, not a\\n`\n + `reviewer subagent. The coordinator may never submit a reviewer's verdict for \"${checklistId}\" — not by this\\n`\n + 'bin, and not by writing the file (wp-finish-upsert-pr rejects a verdict this bin did not write).\\n\\n'\n + 'Spawn the reviewer subagent pnpm wp-review-upsert-pr names and hand it the instructions file; the\\n'\n + 'reviewer submits its own verdict.';\n }\n\n private unstampedRefusal(\n cwd: string,\n checklistId: string,\n harnessEnv: readonly string[],\n ): string {\n return (\n `${WRITE_REVIEW_BIN} REFUSED: this process runs under an AI harness (${harnessEnv.join(', ')} set), but the\\n` +\n `expected worktree has no usable identity stamp for checklist \"${checklistId}\", so nothing can say whether a\\n` +\n 'reviewer subagent or the coordinator is calling.\\n\\n' +\n `Submission cwd: ${cwd}\\nExpected stamp: ${this.stamps.stampPath(cwd, checklistId)}\\n\\n` +\n 'The hook may have written a stamp in the session checkout instead of this worktree. Use a literal\\n' +\n 'leading cd to the absolute reviewed worktree path, then name the checklist literally:\\n' +\n ` cd '/absolute/reviewed-worktree' && pnpm ${WRITE_REVIEW_BIN} --checklist ${checklistId} <<'EOF' … EOF\\n` +\n 'Do not rely on exec_command.workdir alone when the hook exposes only the session cwd. Check hook\\n' +\n 'delivery and its selected tree; reinstall hooks only if they are actually missing.'\n );\n }\n}\n"]}