@webpieces/rules-config 0.4.953 → 0.4.955

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webpieces/rules-config",
3
- "version": "0.4.953",
3
+ "version": "0.4.955",
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.953",
23
- "@webpieces/repo-workflow-core": "0.4.953",
24
- "@webpieces/rules-sdk": "0.4.953"
22
+ "@webpieces/tooling-common": "0.4.955",
23
+ "@webpieces/repo-workflow-core": "0.4.955",
24
+ "@webpieces/rules-sdk": "0.4.955"
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.953"
37
+ "@webpieces/tooling-testkit": "0.4.955"
38
38
  },
39
39
  "types": "./src/index.d.ts",
40
40
  "bin": {
@@ -6,7 +6,7 @@ const config_key_rules_1 = require("./config-key-rules");
6
6
  const retired_config_keys_1 = require("./retired-config-keys");
7
7
  const validate_config_1 = require("./validate-config");
8
8
  // The `commands` section of webpieces.config.json, plus the key-level rules every section shares: strict
9
- // unknown-key rejection and the `*Why` comment convention. Split out of validate-config.ts only for size,
9
+ // unknown-key rejection and external documentation. Split out of validate-config.ts only for size,
10
10
  // exactly as pr-gate-section-validators.ts was; loadAndValidate still reaches this through
11
11
  // validateCommandsSection, which validate-config.ts re-exports.
12
12
  // Every key the `commands` section defines. Anything else is rejected — see unknownKeyErrors for why a
@@ -1 +1 @@
1
- {"version":3,"file":"commands-section-validators.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/commands-section-validators.ts"],"names":[],"mappings":";;AA0BA,0DA4BC;AAtDD,+DAAiE;AACjE,yDAAsD;AACtD,+DAA2D;AAC3D,uDAA0D;AAE1D,yGAAyG;AACzG,0GAA0G;AAC1G,2FAA2F;AAC3F,gEAAgE;AAEhE,uGAAuG;AACvG,kGAAkG;AAClG,MAAM,aAAa,GAAsB,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;AACnE,MAAM,iBAAiB,GAAsB,CAAC,kBAAkB,EAAE,iBAAiB,CAAC,CAAC;AAErF;;;;;;;;GAQG;AACH,yFAAyF;AACzF,8GAA8G;AAC9G,SAAgB,uBAAuB,CAAC,QAAiB,EAAE,YAAqB,EAAE,QAAiB;IAC/F,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAC7B,MAAM,CAAC,IAAI;QACP,gGAAgG;QAChG,yEAAyE;QACzE,qCAAqC,8CAAwB,iCAAiC;YAC9F,iCAAiC,CACpC,CAAC;IACN,CAAC;IAED,IAAI,QAAQ,KAAK,SAAS,IAAI,CAAC,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;QAC3G,MAAM,CAAC,IAAI,CAAC,yEAAyE,CAAC,CAAC;QACvF,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,+FAA+F;IAC/F,MAAM,CAAC,GAAG,CAAC,QAAQ,IAAI,EAAE,CAA4B,CAAC;IAEtD,MAAM,CAAC,IAAI,CAAC,GAAG,IAAA,wCAAkB,EAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC;IACpD,MAAM,CAAC,IAAI,CAAC,GAAG,IAAA,mCAAgB,EAAC,CAAC,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC,CAAC;IAEjE,iDAAiD;IACjD,MAAM,CAAC,IAAI,CAAC,GAAG,IAAA,uCAAqB,EAAC,CAAC,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC9D,MAAM,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAEpD,OAAO,MAAM,CAAC;AAClB,CAAC;AAED;;;GAGG;AACH,0FAA0F;AAC1F,8GAA8G;AAC9G,SAAS,kBAAkB,CAAC,KAAc;IACtC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IACnC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACtE,OAAO,CAAC,oGAAoG,CAAC,CAAC;IAClH,CAAC;IACD,gGAAgG;IAChG,MAAM,CAAC,GAAG,KAAgC,CAAC;IAC3C,MAAM,MAAM,GAAa,IAAA,mCAAgB,EAAC,CAAC,EAAE,iBAAiB,EAAE,uBAAuB,CAAC,CAAC;IACzF,KAAK,MAAM,KAAK,IAAI,iBAAiB,EAAE,CAAC;QACpC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,KAAK,QAAQ,IAAK,CAAC,CAAC,KAAK,CAAY,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;YACrF,MAAM,CAAC,IAAI,CAAC,0BAA0B,KAAK,0DAA0D,CAAC,CAAC;QAC3G,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { RETIRED_TOP_LEVEL_MARKER } from './config-error-banner';\nimport { unknownKeyErrors } from './config-key-rules';\nimport { retiredKeyErrorsIn } from './retired-config-keys';\nimport { validatePrGateSection } from './validate-config';\n\n// The `commands` section of webpieces.config.json, plus the key-level rules every section shares: strict\n// unknown-key rejection and the `*Why` comment convention. Split out of validate-config.ts only for size,\n// exactly as pr-gate-section-validators.ts was; loadAndValidate still reaches this through\n// validateCommandsSection, which validate-config.ts re-exports.\n\n// Every key the `commands` section defines. Anything else is rejected — see unknownKeyErrors for why a\n// tolerated unknown key is the mechanism by which a stale config shape survives upgrades forever.\nconst COMMANDS_KEYS: readonly string[] = ['pr-gate', 'guardHints'];\nconst GUARD_HINT_FIELDS: readonly string[] = ['prCreationOrPush', 'mergeInProgress'];\n\n/**\n * Validate the `commands` section: its `pr-gate` block (delegated to validatePrGateSection), the\n * `guardHints` command strings, and strict rejection of everything else. Also surfaces a migration error if\n * a DEPRECATED top-level `pr-gate` block is still present, telling the consumer to move it under `commands`.\n *\n * There is deliberately no fallback from `commands[\"pr-gate\"]` to the top-level block: the top-level block\n * is a hard error above, so a config carrying it never loads, and a fallback for a shape that cannot load is\n * dead code that only makes the real shape ambiguous. See retired-config-keys.ts for the policy.\n */\n// webpieces-disable no-any-unknown -- `commands`/`legacyPrGate` are opaque consumer JSON\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nexport function validateCommandsSection(commands: unknown, legacyPrGate: unknown, repoRoot?: string): string[] {\n const errors: string[] = [];\n\n if (legacyPrGate !== undefined) {\n errors.push(\n // RETIRED_TOP_LEVEL_MARKER is imported, not re-typed: it is what the banner classifier keys off\n // to call this DEFINITIVE (a shape no version of the validator accepts).\n `[pr-gate] The top-level \"pr-gate\" ${RETIRED_TOP_LEVEL_MARKER}. Move it under the \"commands\" ` +\n `section as commands[\"pr-gate\"].`,\n );\n }\n\n if (commands !== undefined && (typeof commands !== 'object' || commands === null || Array.isArray(commands))) {\n errors.push(`[commands] Must be an object { \"pr-gate\": {...}, \"guardHints\": {...} }.`);\n return errors;\n }\n\n // webpieces-disable no-any-unknown -- narrowing the opaque commands section from consumer JSON\n const c = (commands ?? {}) as Record<string, unknown>;\n\n errors.push(...retiredKeyErrorsIn(c, '[commands]'));\n errors.push(...unknownKeyErrors(c, COMMANDS_KEYS, '[commands]'));\n\n // pr-gate is required (set mode OFF to opt out).\n errors.push(...validatePrGateSection(c['pr-gate'], repoRoot));\n errors.push(...validateGuardHints(c['guardHints']));\n\n return errors;\n}\n\n/**\n * The `commands.guardHints` sub-object: the command strings the bash guards print in their fix hints. Each\n * name binds to exactly one guard, so an unknown field here is a hint nothing will ever read.\n */\n// webpieces-disable no-any-unknown -- `hints` is opaque consumer JSON until narrowed here\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nfunction validateGuardHints(hints: unknown): string[] {\n if (hints === undefined) return [];\n if (typeof hints !== 'object' || hints === null || Array.isArray(hints)) {\n return [`[commands] \"guardHints\" must be an object { \"prCreationOrPush\": \"...\", \"mergeInProgress\": \"...\" }.`];\n }\n // webpieces-disable no-any-unknown -- narrowing the opaque guardHints object from consumer JSON\n const h = hints as Record<string, unknown>;\n const errors: string[] = unknownKeyErrors(h, GUARD_HINT_FIELDS, '[commands.guardHints]');\n for (const field of GUARD_HINT_FIELDS) {\n if (field in h && (typeof h[field] !== 'string' || (h[field] as string).trim() === '')) {\n errors.push(`[commands] \"guardHints.${field}\" must be a non-empty string (the gated command to run).`);\n }\n }\n return errors;\n}\n"]}
1
+ {"version":3,"file":"commands-section-validators.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/commands-section-validators.ts"],"names":[],"mappings":";;AA0BA,0DA4BC;AAtDD,+DAAiE;AACjE,yDAAsD;AACtD,+DAA2D;AAC3D,uDAA0D;AAE1D,yGAAyG;AACzG,mGAAmG;AACnG,2FAA2F;AAC3F,gEAAgE;AAEhE,uGAAuG;AACvG,kGAAkG;AAClG,MAAM,aAAa,GAAsB,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;AACnE,MAAM,iBAAiB,GAAsB,CAAC,kBAAkB,EAAE,iBAAiB,CAAC,CAAC;AAErF;;;;;;;;GAQG;AACH,yFAAyF;AACzF,8GAA8G;AAC9G,SAAgB,uBAAuB,CAAC,QAAiB,EA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CAAC,EAAE,CAAC;QACtE,OAAO,CAAC,oGAAoG,CAAC,CAAC;IAClH,CAAC;IACD,gGAAgG;IAChG,MAAM,CAAC,GAAG,KAAgC,CAAC;IAC3C,MAAM,MAAM,GAAa,IAAA,mCAAgB,EAAC,CAAC,EAAE,iBAAiB,EAAE,uBAAuB,CAAC,CAAC;IACzF,KAAK,MAAM,KAAK,IAAI,iBAAiB,EAAE,CAAC;QACpC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,KAAK,QAAQ,IAAK,CAAC,CAAC,KAAK,CAAY,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;YACrF,MAAM,CAAC,IAAI,CAAC,0BAA0B,KAAK,0DAA0D,CAAC,CAAC;QAC3G,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { RETIRED_TOP_LEVEL_MARKER } from './config-error-banner';\nimport { unknownKeyErrors } from './config-key-rules';\nimport { retiredKeyErrorsIn } from './retired-config-keys';\nimport { validatePrGateSection } from './validate-config';\n\n// The `commands` section of webpieces.config.json, plus the key-level rules every section shares: strict\n// unknown-key rejection and external documentation. Split out of validate-config.ts only for size,\n// exactly as pr-gate-section-validators.ts was; loadAndValidate still reaches this through\n// validateCommandsSection, which validate-config.ts re-exports.\n\n// Every key the `commands` section defines. Anything else is rejected — see unknownKeyErrors for why a\n// tolerated unknown key is the mechanism by which a stale config shape survives upgrades forever.\nconst COMMANDS_KEYS: readonly string[] = ['pr-gate', 'guardHints'];\nconst GUARD_HINT_FIELDS: readonly string[] = ['prCreationOrPush', 'mergeInProgress'];\n\n/**\n * Validate the `commands` section: its `pr-gate` block (delegated to validatePrGateSection), the\n * `guardHints` command strings, and strict rejection of everything else. Also surfaces a migration error if\n * a DEPRECATED top-level `pr-gate` block is still present, telling the consumer to move it under `commands`.\n *\n * There is deliberately no fallback from `commands[\"pr-gate\"]` to the top-level block: the top-level block\n * is a hard error above, so a config carrying it never loads, and a fallback for a shape that cannot load is\n * dead code that only makes the real shape ambiguous. See retired-config-keys.ts for the policy.\n */\n// webpieces-disable no-any-unknown -- `commands`/`legacyPrGate` are opaque consumer JSON\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nexport function validateCommandsSection(commands: unknown, legacyPrGate: unknown, repoRoot?: string): string[] {\n const errors: string[] = [];\n\n if (legacyPrGate !== undefined) {\n errors.push(\n // RETIRED_TOP_LEVEL_MARKER is imported, not re-typed: it is what the banner classifier keys off\n // to call this DEFINITIVE (a shape no version of the validator accepts).\n `[pr-gate] The top-level \"pr-gate\" ${RETIRED_TOP_LEVEL_MARKER}. Move it under the \"commands\" ` +\n `section as commands[\"pr-gate\"].`,\n );\n }\n\n if (commands !== undefined && (typeof commands !== 'object' || commands === null || Array.isArray(commands))) {\n errors.push(`[commands] Must be an object { \"pr-gate\": {...}, \"guardHints\": {...} }.`);\n return errors;\n }\n\n // webpieces-disable no-any-unknown -- narrowing the opaque commands section from consumer JSON\n const c = (commands ?? {}) as Record<string, unknown>;\n\n errors.push(...retiredKeyErrorsIn(c, '[commands]'));\n errors.push(...unknownKeyErrors(c, COMMANDS_KEYS, '[commands]'));\n\n // pr-gate is required (set mode OFF to opt out).\n errors.push(...validatePrGateSection(c['pr-gate'], repoRoot));\n errors.push(...validateGuardHints(c['guardHints']));\n\n return errors;\n}\n\n/**\n * The `commands.guardHints` sub-object: the command strings the bash guards print in their fix hints. Each\n * name binds to exactly one guard, so an unknown field here is a hint nothing will ever read.\n */\n// webpieces-disable no-any-unknown -- `hints` is opaque consumer JSON until narrowed here\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nfunction validateGuardHints(hints: unknown): string[] {\n if (hints === undefined) return [];\n if (typeof hints !== 'object' || hints === null || Array.isArray(hints)) {\n return [`[commands] \"guardHints\" must be an object { \"prCreationOrPush\": \"...\", \"mergeInProgress\": \"...\" }.`];\n }\n // webpieces-disable no-any-unknown -- narrowing the opaque guardHints object from consumer JSON\n const h = hints as Record<string, unknown>;\n const errors: string[] = unknownKeyErrors(h, GUARD_HINT_FIELDS, '[commands.guardHints]');\n for (const field of GUARD_HINT_FIELDS) {\n if (field in h && (typeof h[field] !== 'string' || (h[field] as string).trim() === '')) {\n errors.push(`[commands] \"guardHints.${field}\" must be a non-empty string (the gated command to run).`);\n }\n }\n return errors;\n}\n"]}
@@ -0,0 +1,6 @@
1
+ export declare const CONFIG_DOCUMENTATION_KEY = "webpiecesConfigJsonDocumentation";
2
+ export declare const CONFIG_DOCUMENTATION_PATH = ".webpieces/instruct-ai/webpieces.config-policy.md";
3
+ /** Inline prose belongs in tracked Markdown, including notes nested inside gates or checklists. */
4
+ export declare class ConfigDocumentation {
5
+ inlineErrors(value: unknown, label: string): string[];
6
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConfigDocumentation = exports.CONFIG_DOCUMENTATION_PATH = exports.CONFIG_DOCUMENTATION_KEY = void 0;
4
+ exports.CONFIG_DOCUMENTATION_KEY = 'webpiecesConfigJsonDocumentation';
5
+ exports.CONFIG_DOCUMENTATION_PATH = '.webpieces/instruct-ai/webpieces.config-policy.md';
6
+ /** Inline prose belongs in tracked Markdown, including notes nested inside gates or checklists. */
7
+ class ConfigDocumentation {
8
+ // webpieces-disable no-any-unknown -- traversing unvalidated JSON to reject retired documentation keys
9
+ inlineErrors(value, label) {
10
+ if (Array.isArray(value))
11
+ return value.flatMap((entry, index) => this.inlineErrors(entry, `${label}[${index}]`));
12
+ if (value === null || typeof value !== 'object')
13
+ return [];
14
+ return Object.entries(value).flatMap((entry) => entry[0].endsWith('Why')
15
+ ? [`${label} "${entry[0]}" is a retired inline documentation key. Remove it from JSON; ` +
16
+ `keep repository-specific rationale in tracked Markdown. ` +
17
+ `Config instructions: ${exports.CONFIG_DOCUMENTATION_PATH}.`]
18
+ : this.inlineErrors(entry[1], `${label}.${entry[0]}`));
19
+ }
20
+ }
21
+ exports.ConfigDocumentation = ConfigDocumentation;
22
+ //# sourceMappingURL=config-documentation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-documentation.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/config-documentation.ts"],"names":[],"mappings":";;;AAAa,QAAA,wBAAwB,GAAG,kCAAkC,CAAC;AAC9D,QAAA,yBAAyB,GAAG,mDAAmD,CAAC;AAE7F,mGAAmG;AACnG,MAAa,mBAAmB;IAC5B,uGAAuG;IACvG,YAAY,CAAC,KAAc,EAAE,KAAa;QACtC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;YACpB,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC;QAC3F,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,OAAO,EAAE,CAAC;QAC3D,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAC3C,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC;YACpB,CAAC,CAAC,CAAC,GAAG,KAAK,KAAK,KAAK,CAAC,CAAC,CAAC,gEAAgE;oBACrF,0DAA0D;oBAC1D,wBAAwB,iCAAyB,GAAG,CAAC;YACxD,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAC5D,CAAC;IACN,CAAC;CACJ;AAdD,kDAcC","sourcesContent":["export const CONFIG_DOCUMENTATION_KEY = 'webpiecesConfigJsonDocumentation';\nexport const CONFIG_DOCUMENTATION_PATH = '.webpieces/instruct-ai/webpieces.config-policy.md';\n\n/** Inline prose belongs in tracked Markdown, including notes nested inside gates or checklists. */\nexport class ConfigDocumentation {\n // webpieces-disable no-any-unknown -- traversing unvalidated JSON to reject retired documentation keys\n inlineErrors(value: unknown, label: string): string[] {\n if (Array.isArray(value))\n return value.flatMap((entry, index) => this.inlineErrors(entry, `${label}[${index}]`));\n if (value === null || typeof value !== 'object') return [];\n return Object.entries(value).flatMap((entry) =>\n entry[0].endsWith('Why')\n ? [`${label} \"${entry[0]}\" is a retired inline documentation key. Remove it from JSON; ` +\n `keep repository-specific rationale in tracked Markdown. ` +\n `Config instructions: ${CONFIG_DOCUMENTATION_PATH}.`]\n : this.inlineErrors(entry[1], `${label}.${entry[0]}`),\n );\n }\n}\n"]}
@@ -23,6 +23,7 @@ export declare class ConfigParseAttempt {
23
23
  }
24
24
  /** Parsed but unvalidated root declaration. Concrete policy settings live only in declared owner files. */
25
25
  export declare class RawConfigFile {
26
+ webpiecesConfigJsonDocumentation?: string;
26
27
  rulePacks?: unknown;
27
28
  commands?: unknown;
28
29
  excludePaths?: unknown;
@@ -38,6 +38,7 @@ class ConfigParseAttempt {
38
38
  exports.ConfigParseAttempt = ConfigParseAttempt;
39
39
  /** Parsed but unvalidated root declaration. Concrete policy settings live only in declared owner files. */
40
40
  class RawConfigFile {
41
+ webpiecesConfigJsonDocumentation;
41
42
  // webpieces-disable no-any-unknown -- opaque client JSON is validated at the root/owner boundary
42
43
  rulePacks;
43
44
  // webpieces-disable no-any-unknown -- command behavior has its own structural validator
@@ -1 +1 @@
1
- {"version":3,"file":"config-file.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/config-file.ts"],"names":[],"mappings":";;;AAkJA,wCAEC;AAKD,sCAEC;;AA3JD,+CAAyB;AACzB,mDAA6B;AAC7B,yCAA2D;AAE3D,iEAA6D;AAC7D,+DAAwE;AAE3D,QAAA,eAAe,GAAG,uBAAuB,CAAC;AAEvD;;;;;;;;;GASG;AACU,QAAA,qBAAqB,GAAG,CAAC,CAAC;AA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AS,iCAAyB,GAAG,CAAC,6BAAqB,GAAG,CAAC,CAAC,gCAAgC;YAChG,gBAAgB,KAAK,EAAE,OAAO,IAAI,SAAS,IAAI;YAC/C,SAAS,UAAU,MAAM;YACzB,2CAA2C;YAC3C,6FAA6F;YAC7F,0FAA0F;YAC1F,6FAA6F;YAC7F,0BAA0B,6BAAqB,mDAAmD;YAClG,kGAAkG;YAClG,0BAA0B,uBAAe,qDAAqD;YAC9F,iGAAiG;YACjG,yFAAyF;YACzF,6FAA6F,CAChG,CAAC;IACN,CAAC;CACJ,CAAA;AArFY,gCAAU;qBAAV,UAAU;IADtB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;GAC5B,UAAU,CAqFtB;AAED,sGAAsG;AACtG,oGAAoG;AACpG,MAAM,aAAa,GAAG,IAAI,UAAU,EAAE,CAAC;AAEvC;;GAEG;AACH,SAAgB,cAAc,CAAC,QAAgB;IAC3C,OAAO,aAAa,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;AAClD,CAAC;AAED;;GAEG;AACH,SAAgB,aAAa,CAAC,UAAkB;IAC5C,OAAO,aAAa,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;AACnD,CAAC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { toError } from '@webpieces/tooling-common/to-error';\nimport { ConfigRepairError, EditFileCure } from './config-repair-error';\n\nexport const CONFIG_FILENAME = 'webpieces.config.json';\n\n/**\n * How many times a read+parse of webpieces.config.json is attempted before the failure is treated as\n * REAL. On a machine running several agents at once the file is routinely rewritten underneath us\n * (a dep bump, another worktree's `wp-*` command, an editor's write-then-rename), and for the few\n * milliseconds of that write the bytes on disk are a truncated/half-written JSON document. Reading\n * exactly then produced a hard block that self-healed seconds later — a false positive that also\n * blocked the tools needed to look into it. Three attempts spanning ~50ms covers a normal write with\n * a cost no human or agent can perceive, and cannot mask a file that is genuinely malformed (a\n * conflict-marked or typo'd config fails all three, identically, and still blocks).\n */\nexport const CONFIG_PARSE_ATTEMPTS = 3;\n\n/** Pause between parse attempts. Small enough to be invisible, long enough to outlast a file write. */\nexport const CONFIG_PARSE_RETRY_MILLIS = 25;\n\n/**\n * One read+parse attempt: EITHER a parsed config OR the error that attempt hit, never both.\n * Data-only (per CLAUDE.md, classes for data).\n */\nexport class ConfigParseAttempt {\n constructor(\n readonly config: RawConfigFile | null,\n readonly error: Error | null,\n ) {}\n}\n\n/** Parsed but unvalidated root declaration. Concrete policy settings live only in declared owner files. */\nexport class RawConfigFile {\n // webpieces-disable no-any-unknown -- opaque client JSON is validated at the root/owner boundary\n rulePacks?: unknown;\n // webpieces-disable no-any-unknown -- command behavior has its own structural validator\n commands?: unknown;\n // webpieces-disable no-any-unknown -- generic exclusions are validated before interpretation\n excludePaths?: unknown;\n // webpieces-disable no-any-unknown -- client match rules have their own structural validator\n 'match-rules'?: unknown;\n}\n\n/**\n * Locates + reads webpieces.config.json. `@injectable(bindingScopeValues.Singleton)` so it can be injected into the config\n * loader and appear in the rules-config DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ConfigFile {\n /** Walk up from `startDir` looking for webpieces.config.json. Returns its absolute path or null. */\n findConfigFile(startDir: string): string | null {\n let dir = startDir;\n while (true) {\n const primary = path.join(dir, CONFIG_FILENAME);\n if (fs.existsSync(primary)) return primary;\n const parent = path.dirname(dir);\n if (parent === dir) return null;\n dir = parent;\n }\n }\n\n /**\n * Read + JSON.parse webpieces.config.json, RETRYING a failed attempt before escalating.\n *\n * A single failed read is not evidence of a broken config: another process on this machine may be\n * mid-write, and a half-written file is unparseable for a few milliseconds and then fine. Only a\n * failure that survives every attempt is treated as real — and then it still throws, so a\n * genuinely invalid config blocks exactly as before. See {@link CONFIG_PARSE_ATTEMPTS}.\n */\n readRawConfig(configPath: string): RawConfigFile {\n let lastError: Error | null = null;\n for (let attempt = 1; attempt <= CONFIG_PARSE_ATTEMPTS; attempt++) {\n if (attempt > 1) this.sleepSync(CONFIG_PARSE_RETRY_MILLIS);\n const outcome = this.attemptReadAndParse(configPath);\n if (outcome.config !== null) return outcome.config;\n lastError = outcome.error;\n }\n throw new ConfigRepairError(this.formatParseFailure(configPath, lastError), [\n new EditFileCure(configPath, `Edit ${configPath} to restore valid JSON.`),\n ]);\n }\n\n // ONE read+parse attempt. The read is inside the try too: a file being replaced can momentarily\n // fail to open (ENOENT between unlink and rename), which is the same transient class as a\n // half-written parse failure and must be retried the same way.\n private attemptReadAndParse(configPath: string): ConfigParseAttempt {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const raw = this.readFileText(configPath);\n return new ConfigParseAttempt(JSON.parse(raw) as RawConfigFile, null);\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n } catch (err: unknown) {\n const error = toError(err);\n return new ConfigParseAttempt(null, error);\n }\n }\n\n /** Read the file's bytes. `protected` so a test can inject a transient failure deterministically. */\n protected readFileText(configPath: string): string {\n return fs.readFileSync(configPath, 'utf8');\n }\n\n /**\n * Block this thread for `millis`. The hook path is synchronous top to bottom (a PreToolUse hook\n * answers on stdout before the tool runs), so an async delay is not available; `Atomics.wait` on a\n * never-notified word is the standard dependency-free synchronous sleep.\n */\n protected sleepSync(millis: number): void {\n Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, millis);\n }\n\n // The AI-facing message for a parse failure that survived every attempt. It names the retry count\n // on purpose: an agent that sees \"invalid JSON\" for a file that reads fine three seconds later has\n // no way to tell a race from a real syntax error, and the FIRST thing it needs to know is that\n // read-only inspection of the file is still available so it can go look.\n private formatParseFailure(configPath: string, error: Error | null): string {\n return (\n `webpieces.config.json could not be parsed as JSON — retried ${CONFIG_PARSE_ATTEMPTS} times ` +\n `over ~${CONFIG_PARSE_RETRY_MILLIS * (CONFIG_PARSE_ATTEMPTS - 1)}ms and it failed every time.\\n` +\n `Parse error: ${error?.message ?? 'unknown'}\\n` +\n `File: ${configPath}\\n\\n` +\n `Two causes, in the order to check them:\\n` +\n ` 1. GENUINELY INVALID — most likely. Look at the file: a trailing comma, a missing brace, ` +\n `or leftover conflict markers (\\`<<<<<<< HEAD\\`) from a merge you are in the middle of.\\n` +\n ` 2. STILL BEING WRITTEN by another process (another agent/worktree on this machine, a dep ` +\n `bump, an editor save). ${CONFIG_PARSE_ATTEMPTS} attempts already ruled out a brief write, but a ` +\n `long-running writer can outlast them — if so, simply retrying your command now will succeed.\\n\\n` +\n `👉 READING AND EDITING ${CONFIG_FILENAME} IS ALWAYS ALLOWED, including right now: \\`Read\\`, ` +\n `\\`cat\\`, \\`grep\\`, \\`sed -n\\` and the other read-only inspection commands still work while the ` +\n `config is broken. Go look at the file, fix it, then retry. (Writes to OTHER files stay ` +\n `blocked — with an unparseable config every guard is disabled, so nothing else may proceed.)`\n );\n }\n}\n\n// Temporary migration delegators — consumers migrate to injecting ConfigFile over follow-up PRs, then\n// these free functions are removed. Declarations kept identical to the originals (unchanged lines).\nconst configFileSvc = new ConfigFile();\n\n/**\n * Walk up from `startDir` looking for webpieces.config.json. Returns its absolute path or null.\n */\nexport function findConfigFile(startDir: string): string | null {\n return configFileSvc.findConfigFile(startDir);\n}\n\n/**\n * Read + JSON.parse webpieces.config.json, surfacing parse failures as a readable InformAiError.\n */\nexport function readRawConfig(configPath: string): RawConfigFile {\n return configFileSvc.readRawConfig(configPath);\n}\n"]}
1
+ {"version":3,"file":"config-file.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/config-file.ts"],"names":[],"mappings":";;;AAmJA,wCAEC;AAKD,sCAEC;;AA5JD,+CAAyB;AACzB,mDAA6B;AAC7B,yCAA2D;AAE3D,iEAA6D;AAC7D,+DAAwE;AAE3D,QAAA,eAAe,GAAG,uBAAuB,CAAC;AAEvD;;;;;;;;;GASG;AACU,QAAA,qBAAqB,GAAG,CAAC,CAAC;AAEvC,uGAAuG;AAC1F,QAAA,yBAAyB,GAAG,EAAE,CAAC;AAE5C;;;GAGG;AACH,MAAa,kB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;YAChG,gBAAgB,KAAK,EAAE,OAAO,IAAI,SAAS,IAAI;YAC/C,SAAS,UAAU,MAAM;YACzB,2CAA2C;YAC3C,6FAA6F;YAC7F,0FAA0F;YAC1F,6FAA6F;YAC7F,0BAA0B,6BAAqB,mDAAmD;YAClG,kGAAkG;YAClG,0BAA0B,uBAAe,qDAAqD;YAC9F,iGAAiG;YACjG,yFAAyF;YACzF,6FAA6F,CAChG,CAAC;IACN,CAAC;CACJ,CAAA;AArFY,gCAAU;qBAAV,UAAU;IADtB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;GAC5B,UAAU,CAqFtB;AAED,sGAAsG;AACtG,oGAAoG;AACpG,MAAM,aAAa,GAAG,IAAI,UAAU,EAAE,CAAC;AAEvC;;GAEG;AACH,SAAgB,cAAc,CAAC,QAAgB;IAC3C,OAAO,aAAa,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;AAClD,CAAC;AAED;;GAEG;AACH,SAAgB,aAAa,CAAC,UAAkB;IAC5C,OAAO,aAAa,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;AACnD,CAAC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { toError } from '@webpieces/tooling-common/to-error';\nimport { ConfigRepairError, EditFileCure } from './config-repair-error';\n\nexport const CONFIG_FILENAME = 'webpieces.config.json';\n\n/**\n * How many times a read+parse of webpieces.config.json is attempted before the failure is treated as\n * REAL. On a machine running several agents at once the file is routinely rewritten underneath us\n * (a dep bump, another worktree's `wp-*` command, an editor's write-then-rename), and for the few\n * milliseconds of that write the bytes on disk are a truncated/half-written JSON document. Reading\n * exactly then produced a hard block that self-healed seconds later — a false positive that also\n * blocked the tools needed to look into it. Three attempts spanning ~50ms covers a normal write with\n * a cost no human or agent can perceive, and cannot mask a file that is genuinely malformed (a\n * conflict-marked or typo'd config fails all three, identically, and still blocks).\n */\nexport const CONFIG_PARSE_ATTEMPTS = 3;\n\n/** Pause between parse attempts. Small enough to be invisible, long enough to outlast a file write. */\nexport const CONFIG_PARSE_RETRY_MILLIS = 25;\n\n/**\n * One read+parse attempt: EITHER a parsed config OR the error that attempt hit, never both.\n * Data-only (per CLAUDE.md, classes for data).\n */\nexport class ConfigParseAttempt {\n constructor(\n readonly config: RawConfigFile | null,\n readonly error: Error | null,\n ) {}\n}\n\n/** Parsed but unvalidated root declaration. Concrete policy settings live only in declared owner files. */\nexport class RawConfigFile {\n webpiecesConfigJsonDocumentation?: string;\n // webpieces-disable no-any-unknown -- opaque client JSON is validated at the root/owner boundary\n rulePacks?: unknown;\n // webpieces-disable no-any-unknown -- command behavior has its own structural validator\n commands?: unknown;\n // webpieces-disable no-any-unknown -- generic exclusions are validated before interpretation\n excludePaths?: unknown;\n // webpieces-disable no-any-unknown -- client match rules have their own structural validator\n 'match-rules'?: unknown;\n}\n\n/**\n * Locates + reads webpieces.config.json. `@injectable(bindingScopeValues.Singleton)` so it can be injected into the config\n * loader and appear in the rules-config DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ConfigFile {\n /** Walk up from `startDir` looking for webpieces.config.json. Returns its absolute path or null. */\n findConfigFile(startDir: string): string | null {\n let dir = startDir;\n while (true) {\n const primary = path.join(dir, CONFIG_FILENAME);\n if (fs.existsSync(primary)) return primary;\n const parent = path.dirname(dir);\n if (parent === dir) return null;\n dir = parent;\n }\n }\n\n /**\n * Read + JSON.parse webpieces.config.json, RETRYING a failed attempt before escalating.\n *\n * A single failed read is not evidence of a broken config: another process on this machine may be\n * mid-write, and a half-written file is unparseable for a few milliseconds and then fine. Only a\n * failure that survives every attempt is treated as real — and then it still throws, so a\n * genuinely invalid config blocks exactly as before. See {@link CONFIG_PARSE_ATTEMPTS}.\n */\n readRawConfig(configPath: string): RawConfigFile {\n let lastError: Error | null = null;\n for (let attempt = 1; attempt <= CONFIG_PARSE_ATTEMPTS; attempt++) {\n if (attempt > 1) this.sleepSync(CONFIG_PARSE_RETRY_MILLIS);\n const outcome = this.attemptReadAndParse(configPath);\n if (outcome.config !== null) return outcome.config;\n lastError = outcome.error;\n }\n throw new ConfigRepairError(this.formatParseFailure(configPath, lastError), [\n new EditFileCure(configPath, `Edit ${configPath} to restore valid JSON.`),\n ]);\n }\n\n // ONE read+parse attempt. The read is inside the try too: a file being replaced can momentarily\n // fail to open (ENOENT between unlink and rename), which is the same transient class as a\n // half-written parse failure and must be retried the same way.\n private attemptReadAndParse(configPath: string): ConfigParseAttempt {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const raw = this.readFileText(configPath);\n return new ConfigParseAttempt(JSON.parse(raw) as RawConfigFile, null);\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n } catch (err: unknown) {\n const error = toError(err);\n return new ConfigParseAttempt(null, error);\n }\n }\n\n /** Read the file's bytes. `protected` so a test can inject a transient failure deterministically. */\n protected readFileText(configPath: string): string {\n return fs.readFileSync(configPath, 'utf8');\n }\n\n /**\n * Block this thread for `millis`. The hook path is synchronous top to bottom (a PreToolUse hook\n * answers on stdout before the tool runs), so an async delay is not available; `Atomics.wait` on a\n * never-notified word is the standard dependency-free synchronous sleep.\n */\n protected sleepSync(millis: number): void {\n Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, millis);\n }\n\n // The AI-facing message for a parse failure that survived every attempt. It names the retry count\n // on purpose: an agent that sees \"invalid JSON\" for a file that reads fine three seconds later has\n // no way to tell a race from a real syntax error, and the FIRST thing it needs to know is that\n // read-only inspection of the file is still available so it can go look.\n private formatParseFailure(configPath: string, error: Error | null): string {\n return (\n `webpieces.config.json could not be parsed as JSON — retried ${CONFIG_PARSE_ATTEMPTS} times ` +\n `over ~${CONFIG_PARSE_RETRY_MILLIS * (CONFIG_PARSE_ATTEMPTS - 1)}ms and it failed every time.\\n` +\n `Parse error: ${error?.message ?? 'unknown'}\\n` +\n `File: ${configPath}\\n\\n` +\n `Two causes, in the order to check them:\\n` +\n ` 1. GENUINELY INVALID — most likely. Look at the file: a trailing comma, a missing brace, ` +\n `or leftover conflict markers (\\`<<<<<<< HEAD\\`) from a merge you are in the middle of.\\n` +\n ` 2. STILL BEING WRITTEN by another process (another agent/worktree on this machine, a dep ` +\n `bump, an editor save). ${CONFIG_PARSE_ATTEMPTS} attempts already ruled out a brief write, but a ` +\n `long-running writer can outlast them — if so, simply retrying your command now will succeed.\\n\\n` +\n `👉 READING AND EDITING ${CONFIG_FILENAME} IS ALWAYS ALLOWED, including right now: \\`Read\\`, ` +\n `\\`cat\\`, \\`grep\\`, \\`sed -n\\` and the other read-only inspection commands still work while the ` +\n `config is broken. Go look at the file, fix it, then retry. (Writes to OTHER files stay ` +\n `blocked — with an unparseable config every guard is disabled, so nothing else may proceed.)`\n );\n }\n}\n\n// Temporary migration delegators — consumers migrate to injecting ConfigFile over follow-up PRs, then\n// these free functions are removed. Declarations kept identical to the originals (unchanged lines).\nconst configFileSvc = new ConfigFile();\n\n/**\n * Walk up from `startDir` looking for webpieces.config.json. Returns its absolute path or null.\n */\nexport function findConfigFile(startDir: string): string | null {\n return configFileSvc.findConfigFile(startDir);\n}\n\n/**\n * Read + JSON.parse webpieces.config.json, surfacing parse failures as a readable InformAiError.\n */\nexport function readRawConfig(configPath: string): RawConfigFile {\n return configFileSvc.readRawConfig(configPath);\n}\n"]}
@@ -1,23 +1,4 @@
1
- /**
2
- * Reject unknown TOP-LEVEL keys. Without this, a key that was retired at the top level (or simply
3
- * misspelled) is silently ignored — the config looks configured and behaves as if it were not, and the dead
4
- * key survives every upgrade. `*Why` rationale keys are allowed, which is what lets the file document
5
- * itself: this repo ships a top-level `upgradePolicyWhy` stating that config is validated on startup and
6
- * migrated by the agent, so no backwards-compatible release is needed.
7
- */
8
1
  export declare function validateTopLevelKeys(raw: Record<string, unknown>): string[];
9
- /**
10
- * The `*Why` convention: any key ending in "Why" is free-form rationale a consumer keeps beside the key it
11
- * explains. JSON has no comments, so this is how this repo documents non-obvious config — and it is the only
12
- * way the config file can carry the note that matters most to the agent reading it (see the top-level
13
- * "upgradePolicyWhy" this repo ships). Comment keys are therefore allowed wherever unknown keys are
14
- * otherwise rejected, and must be strings.
15
- *
16
- * ONE exception, enforced separately: `gateSaltWhy` is rejected outright, because rationale next to the gate
17
- * salt is a bypass how-to in the most-read file in the repo. See validateNoGateSaltRationale.
18
- */
19
- export declare const COMMENT_KEY_SUFFIX = "Why";
20
- export declare function isCommentKey(key: string): boolean;
21
2
  /**
22
3
  * Reject keys a section does not define. Without this a retired or misspelled key is simply ignored, which is
23
4
  * how a stale shape survives an upgrade forever — the whole failure mode RETIRED_CONFIG_KEYS exists to end.
@@ -1,27 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.COMMENT_KEY_SUFFIX = void 0;
4
3
  exports.validateTopLevelKeys = validateTopLevelKeys;
5
- exports.isCommentKey = isCommentKey;
6
4
  exports.unknownKeyErrors = unknownKeyErrors;
5
+ const config_documentation_1 = require("./config-documentation");
7
6
  const retired_config_keys_1 = require("./retired-config-keys");
8
- // Key-level rules every webpieces.config.json section shares: strict unknown-key rejection and the `*Why`
9
- // comment convention. Its own module because both validate-config.ts (top level) and
10
- // commands-section-validators.ts (the commands section) need it, and either importing the other would
11
- // close an import cycle.
12
- /**
13
- * Every key webpieces.config.json defines at the TOP level. `pr-gate` is deliberately absent — it is the
14
- * retired top-level block, and validateCommandsSection already reports it with the move instruction, so
15
- * listing it here would replace that precise message with a generic "unknown key".
16
- */
17
- const TOP_LEVEL_KEYS = ['rulePacks', 'commands', 'excludePaths', 'match-rules'];
18
- /**
19
- * Reject unknown TOP-LEVEL keys. Without this, a key that was retired at the top level (or simply
20
- * misspelled) is silently ignored — the config looks configured and behaves as if it were not, and the dead
21
- * key survives every upgrade. `*Why` rationale keys are allowed, which is what lets the file document
22
- * itself: this repo ships a top-level `upgradePolicyWhy` stating that config is validated on startup and
23
- * migrated by the agent, so no backwards-compatible release is needed.
24
- */
7
+ // Root config contains settings and one exact link to the generated instructions.
8
+ const TOP_LEVEL_KEYS = [config_documentation_1.CONFIG_DOCUMENTATION_KEY, 'rulePacks', 'commands', 'excludePaths', 'match-rules'];
25
9
  // webpieces-disable no-any-unknown -- the raw parsed config is opaque; only key names are read here
26
10
  // webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file
27
11
  // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution
@@ -35,24 +19,14 @@ function validateTopLevelKeys(raw) {
35
19
  : 'Move each entry it holds into the owner file its pack declares in rulePacks (.webpieces-config/rules/<pack>.json), then delete this key.'));
36
20
  return [
37
21
  ...errors,
22
+ ...new config_documentation_1.ConfigDocumentation().inlineErrors(raw, '[webpieces.config.json]'),
23
+ ...(raw[config_documentation_1.CONFIG_DOCUMENTATION_KEY] === config_documentation_1.CONFIG_DOCUMENTATION_PATH ? [] : [
24
+ `[webpieces.config.json] Require "${config_documentation_1.CONFIG_DOCUMENTATION_KEY}": "${config_documentation_1.CONFIG_DOCUMENTATION_PATH}". ` +
25
+ `This exact generated guide documents the config; arbitrary paths are not accepted.`,
26
+ ]),
38
27
  ...unknownKeyErrors(raw, [...TOP_LEVEL_KEYS, 'pr-gate', ...retired], '[webpieces.config.json]'),
39
28
  ];
40
29
  }
41
- /**
42
- * The `*Why` convention: any key ending in "Why" is free-form rationale a consumer keeps beside the key it
43
- * explains. JSON has no comments, so this is how this repo documents non-obvious config — and it is the only
44
- * way the config file can carry the note that matters most to the agent reading it (see the top-level
45
- * "upgradePolicyWhy" this repo ships). Comment keys are therefore allowed wherever unknown keys are
46
- * otherwise rejected, and must be strings.
47
- *
48
- * ONE exception, enforced separately: `gateSaltWhy` is rejected outright, because rationale next to the gate
49
- * salt is a bypass how-to in the most-read file in the repo. See validateNoGateSaltRationale.
50
- */
51
- exports.COMMENT_KEY_SUFFIX = 'Why';
52
- // webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file
53
- function isCommentKey(key) {
54
- return key.length > exports.COMMENT_KEY_SUFFIX.length && key.endsWith(exports.COMMENT_KEY_SUFFIX);
55
- }
56
30
  /**
57
31
  * Reject keys a section does not define. Without this a retired or misspelled key is simply ignored, which is
58
32
  * how a stale shape survives an upgrade forever — the whole failure mode RETIRED_CONFIG_KEYS exists to end.
@@ -67,15 +41,14 @@ section, knownKeys, label) {
67
41
  for (const key of Object.keys(section)) {
68
42
  if (knownKeys.includes(key) || (0, retired_config_keys_1.isRetiredKey)(key, label))
69
43
  continue;
70
- if (isCommentKey(key)) {
71
- if (typeof section[key] !== 'string') {
72
- errors.push(`${label} "${key}" is a *Why rationale note and must be a string.`);
73
- }
44
+ if (key.endsWith('Why')) {
45
+ errors.push(`${label} "${key}" is a retired inline documentation key. ` +
46
+ `Remove it from JSON; keep repository-specific rationale in tracked Markdown. ` +
47
+ `Config instructions: ${config_documentation_1.CONFIG_DOCUMENTATION_PATH}.`);
74
48
  continue;
75
49
  }
76
50
  errors.push(`${label} Unknown key "${key}". Valid keys: [${knownKeys.join(', ')}]. ` +
77
- `Delete it, or — if it is rationale you want to keep beside a key — rename it to "<key>Why" ` +
78
- `with a string value (JSON has no comments, so "*Why" siblings are how this repo documents config).`);
51
+ `Delete it. Config instructions: ${config_documentation_1.CONFIG_DOCUMENTATION_PATH}.`);
79
52
  }
80
53
  return errors;
81
54
  }
@@ -1 +1 @@
1
- {"version":3,"file":"config-key-rules.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/config-key-rules.ts"],"names":[],"mappings":";;;AAwBA,oDAqBC;AAeD,oCAEC;AASD,4CAsBC;AA7FD,+DAAqD;AAErD,0GAA0G;AAC1G,qFAAqF;AACrF,sGAAsG;AACtG,yBAAyB;AAEzB;;;;GAIG;AACH,MAAM,cAAc,GAAsB,CAAC,WAAW,EAAE,UAAU,EAAE,cAAc,EAAE,aAAa,CAAC,CAAC;AAEnG;;;;;;GAMG;AACH,oGAAoG;AACpG,8GAA8G;AAC9G,6GAA6G;AAC7G,SAAgB,oBAAoB,CAAC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C,EAAE,CAAC;YACpB,IAAI,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,QAAQ,EAAE,CAAC;gBACnC,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,KAAK,GAAG,kDAAkD,CAAC,CAAC;YACpF,CAAC;YACD,SAAS;QACb,CAAC;QACD,MAAM,CAAC,IAAI,CACP,GAAG,KAAK,iBAAiB,GAAG,mBAAmB,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK;YACpE,6FAA6F;YAC7F,oGAAoG,CAC3G,CAAC;IACN,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { isRetiredKey } from './retired-config-keys';\n\n// Key-level rules every webpieces.config.json section shares: strict unknown-key rejection and the `*Why`\n// comment convention. Its own module because both validate-config.ts (top level) and\n// commands-section-validators.ts (the commands section) need it, and either importing the other would\n// close an import cycle.\n\n/**\n * Every key webpieces.config.json defines at the TOP level. `pr-gate` is deliberately absent — it is the\n * retired top-level block, and validateCommandsSection already reports it with the move instruction, so\n * listing it here would replace that precise message with a generic \"unknown key\".\n */\nconst TOP_LEVEL_KEYS: readonly string[] = ['rulePacks', 'commands', 'excludePaths', 'match-rules'];\n\n/**\n * Reject unknown TOP-LEVEL keys. Without this, a key that was retired at the top level (or simply\n * misspelled) is silently ignored — the config looks configured and behaves as if it were not, and the dead\n * key survives every upgrade. `*Why` rationale keys are allowed, which is what lets the file document\n * itself: this repo ships a top-level `upgradePolicyWhy` stating that config is validated on startup and\n * migrated by the agent, so no backwards-compatible release is needed.\n */\n// webpieces-disable no-any-unknown -- the raw parsed config is opaque; only key names are read here\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\n// webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\nexport function validateTopLevelKeys(raw: Record<string, unknown>): string[] {\n const retired = ['rules', 'hookGuards', 'rulesDir', 'extends'].filter((key: string) =>\n Object.hasOwn(raw, key),\n );\n const errors = retired.map(\n (key: string) =>\n `[webpieces.config.json] Retired top-level key \"${key}\". ` +\n (key === 'rulesDir'\n ? 'Declare a client-owned rule pack with a schema and implementation module; directory scanning is retired.'\n : key === 'extends'\n ? 'Declare exact rulePacks and explicit owner files; inherited central config is retired.'\n : 'Move each entry it holds into the owner file its pack declares in rulePacks (.webpieces-config/rules/<pack>.json), then delete this key.'),\n );\n return [\n ...errors,\n ...unknownKeyErrors(\n raw,\n [...TOP_LEVEL_KEYS, 'pr-gate', ...retired],\n '[webpieces.config.json]',\n ),\n ];\n}\n\n/**\n * The `*Why` convention: any key ending in \"Why\" is free-form rationale a consumer keeps beside the key it\n * explains. JSON has no comments, so this is how this repo documents non-obvious config — and it is the only\n * way the config file can carry the note that matters most to the agent reading it (see the top-level\n * \"upgradePolicyWhy\" this repo ships). Comment keys are therefore allowed wherever unknown keys are\n * otherwise rejected, and must be strings.\n *\n * ONE exception, enforced separately: `gateSaltWhy` is rejected outright, because rationale next to the gate\n * salt is a bypass how-to in the most-read file in the repo. See validateNoGateSaltRationale.\n */\nexport const COMMENT_KEY_SUFFIX = 'Why';\n\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nexport function isCommentKey(key: string): boolean {\n return key.length > COMMENT_KEY_SUFFIX.length && key.endsWith(COMMENT_KEY_SUFFIX);\n}\n\n/**\n * Reject keys a section does not define. Without this a retired or misspelled key is simply ignored, which is\n * how a stale shape survives an upgrade forever — the whole failure mode RETIRED_CONFIG_KEYS exists to end.\n * Retired keys are skipped here so they get their own migration message instead of a generic \"unknown key\".\n */\n// webpieces-disable no-any-unknown -- `section` is opaque consumer JSON; only key names are read\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nexport function unknownKeyErrors(\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n section: Record<string, unknown>,\n knownKeys: readonly string[],\n label: string,\n): string[] {\n const errors: string[] = [];\n for (const key of Object.keys(section)) {\n if (knownKeys.includes(key) || isRetiredKey(key, label)) continue;\n if (isCommentKey(key)) {\n if (typeof section[key] !== 'string') {\n errors.push(`${label} \"${key}\" is a *Why rationale note and must be a string.`);\n }\n continue;\n }\n errors.push(\n `${label} Unknown key \"${key}\". Valid keys: [${knownKeys.join(', ')}]. ` +\n `Delete it, or — if it is rationale you want to keep beside a key — rename it to \"<key>Why\" ` +\n `with a string value (JSON has no comments, so \"*Why\" siblings are how this repo documents config).`,\n );\n }\n return errors;\n}\n"]}
1
+ {"version":3,"file":"config-key-rules.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/config-key-rules.ts"],"names":[],"mappings":";;AASA,oDA0BC;AASD,4CAqBC;AAjED,iEAAkH;AAClH,+DAAqD;AAErD,kFAAkF;AAClF,MAAM,cAAc,GAAsB,CAAC,+CAAwB,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,EAAE,aAAa,CAAC,CAAC;AAE7H,oGAAoG;AACpG,8GAA8G;AAC9G,6GAA6G;AAC7G,SAAgB,oBAAoB,CAAC,GAA4B;IAC7D,MAAM,OAAO,GAAG,CAAC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,GAAW,EAAE,EAAE,CAClF,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAC1B,CAAC;IACF,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CACtB,CAAC,GAAW,EAAE,EAAE,CACZ,kDAAkD,GAAG,KAAK;QAC1D,CAAC,GAAG,KAAK,UAAU;YACf,CAAC,CAAC,0GAA0G;YAC5G,CAAC,CAAC,GAAG,KAAK,SAAS;gBACjB,CAAC,CAAC,wFAAwF;gBAC1F,CAAC,CAAC,0IAA0I,CAAC,CAC1J,CAAC;IACF,OAAO;QACH,GAAG,MAAM;QACT,GAAG,IAAI,0CAAmB,EAAE,CAAC,YAAY,CAAC,GAAG,EAAE,yBAAyB,CAAC;QACzE,GAAG,CAAC,GAAG,CAAC,+CAAwB,CAAC,KAAK,gDAAyB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YACnE,oCAAoC,+CAAwB,OAAO,gDAAyB,KAAK;gBACjG,oFAAoF;SACvF,CAAC;QACF,GAAG,gBAAgB,CACf,GAAG,EACH,CAAC,GAAG,cAAc,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,EAC1C,yBAAyB,CAC5B;KACJ,CAAC;AACN,CAAC;AAED;;;;GAIG;AACH,iGAAiG;AACjG,8GAA8G;AAC9G,SAAgB,gBAAgB;AAC5B,6GAA6G;AAC7G,OAAgC,EAChC,SAA4B,EAC5B,KAAa;IAEb,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACrC,IAAI,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,IAAA,kCAAY,EAAC,GAAG,EAAE,KAAK,CAAC;YAAE,SAAS;QAClE,IAAI,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACtB,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,KAAK,GAAG,2CAA2C;gBACnE,+EAA+E;gBAC/E,wBAAwB,gDAAyB,GAAG,CAAC,CAAC;YAC1D,SAAS;QACb,CAAC;QACD,MAAM,CAAC,IAAI,CACP,GAAG,KAAK,iBAAiB,GAAG,mBAAmB,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK;YACpE,mCAAmC,gDAAyB,GAAG,CACtE,CAAC;IACN,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { ConfigDocumentation, CONFIG_DOCUMENTATION_KEY, CONFIG_DOCUMENTATION_PATH } from './config-documentation';\nimport { isRetiredKey } from './retired-config-keys';\n\n// Root config contains settings and one exact link to the generated instructions.\nconst TOP_LEVEL_KEYS: readonly string[] = [CONFIG_DOCUMENTATION_KEY, 'rulePacks', 'commands', 'excludePaths', 'match-rules'];\n\n// webpieces-disable no-any-unknown -- the raw parsed config is opaque; only key names are read here\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\n// webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\nexport function validateTopLevelKeys(raw: Record<string, unknown>): string[] {\n const retired = ['rules', 'hookGuards', 'rulesDir', 'extends'].filter((key: string) =>\n Object.hasOwn(raw, key),\n );\n const errors = retired.map(\n (key: string) =>\n `[webpieces.config.json] Retired top-level key \"${key}\". ` +\n (key === 'rulesDir'\n ? 'Declare a client-owned rule pack with a schema and implementation module; directory scanning is retired.'\n : key === 'extends'\n ? 'Declare exact rulePacks and explicit owner files; inherited central config is retired.'\n : 'Move each entry it holds into the owner file its pack declares in rulePacks (.webpieces-config/rules/<pack>.json), then delete this key.'),\n );\n return [\n ...errors,\n ...new ConfigDocumentation().inlineErrors(raw, '[webpieces.config.json]'),\n ...(raw[CONFIG_DOCUMENTATION_KEY] === CONFIG_DOCUMENTATION_PATH ? [] : [\n `[webpieces.config.json] Require \"${CONFIG_DOCUMENTATION_KEY}\": \"${CONFIG_DOCUMENTATION_PATH}\". ` +\n `This exact generated guide documents the config; arbitrary paths are not accepted.`,\n ]),\n ...unknownKeyErrors(\n raw,\n [...TOP_LEVEL_KEYS, 'pr-gate', ...retired],\n '[webpieces.config.json]',\n ),\n ];\n}\n\n/**\n * Reject keys a section does not define. Without this a retired or misspelled key is simply ignored, which is\n * how a stale shape survives an upgrade forever — the whole failure mode RETIRED_CONFIG_KEYS exists to end.\n * Retired keys are skipped here so they get their own migration message instead of a generic \"unknown key\".\n */\n// webpieces-disable no-any-unknown -- `section` is opaque consumer JSON; only key names are read\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nexport function unknownKeyErrors(\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n section: Record<string, unknown>,\n knownKeys: readonly string[],\n label: string,\n): string[] {\n const errors: string[] = [];\n for (const key of Object.keys(section)) {\n if (knownKeys.includes(key) || isRetiredKey(key, label)) continue;\n if (key.endsWith('Why')) {\n errors.push(`${label} \"${key}\" is a retired inline documentation key. ` +\n `Remove it from JSON; keep repository-specific rationale in tracked Markdown. ` +\n `Config instructions: ${CONFIG_DOCUMENTATION_PATH}.`);\n continue;\n }\n errors.push(\n `${label} Unknown key \"${key}\". Valid keys: [${knownKeys.join(', ')}]. ` +\n `Delete it. Config instructions: ${CONFIG_DOCUMENTATION_PATH}.`,\n );\n }\n return errors;\n}\n"]}
package/src/index.d.ts CHANGED
@@ -27,7 +27,8 @@ export { MERGE_PROCESS_DOC, MergeProcessText, MergeRun, ReferenceMergeRun, } fro
27
27
  export { BUILD_LOG_DOC } from './build-log-doc';
28
28
  export { validateWebpiecesConfig, validatePrGateSection, validateChecklistsSection, validateExcludePaths, validateMatchRulesSection, allRuleNames, recommendedSeedMode, recommendedSeedModeFor, seedEntryForRule, } from './validate-config';
29
29
  export { validateCommandsSection } from './commands-section-validators';
30
- export { unknownKeyErrors, isCommentKey, validateTopLevelKeys, COMMENT_KEY_SUFFIX, } from './config-key-rules';
30
+ export { unknownKeyErrors, validateTopLevelKeys, } from './config-key-rules';
31
+ export { CONFIG_DOCUMENTATION_KEY, CONFIG_DOCUMENTATION_PATH } from './config-documentation';
31
32
  export { RETIRED_CONFIG_KEYS, RETIRED_SCOPE_KEY, RETIRED_SCOPE_RULE, isRetiredKey, retiredEntry, retiredKeyError, retiredKeyErrorsIn, retiredRuleFor, } from './retired-config-keys';
32
33
  export { ConfigPruner, PruneResult, PrunedKey } from './config-pruner';
33
34
  export { validateChecklistDocs } from './checklist-docs-validator';
package/src/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.globMatches = exports.matchesAnyGlob = exports.isPathExcluded = exports.isWebpiecesStateDir = exports.ExcludePaths = exports.DESIGN_METADATA_KEYS = exports.isDocumentDesign = exports.DocumentDesign = exports.RulesConfigDesign = exports.atRoot = exports.CLAUDE_PROJECT_DIR_UNSET = exports.CLAUDE_PROJECT_DIR_ENV = exports.claudeEnv = exports.ClaudeEnv = exports.RETENTION_DAYS = exports.SweepCount = exports.AgedTreeSweeper = exports.INSTRUCT_AI_LEAF = exports.INSTRUCT_AI_DIR = exports.RepoRootFinder = exports.RawConfigFile = exports.CONFIG_PARSE_RETRY_MILLIS = exports.CONFIG_PARSE_ATTEMPTS = exports.ConfigParseAttempt = exports.ConfigFile = exports.CONFIG_FILENAME = exports.findConfigFile = exports.RETIRED_TOP_LEVEL_MARKER = exports.RETIRED_KEY_MARKER = exports.CONFIG_POLICY_DOC = exports.formatConfigErrorsBanner = exports.ConfigLoader = exports.LoadedConfig = exports.loadAndValidate = exports.runMain = exports.CliArgs = exports.CliArgsCheck = exports.CliArgSet = exports.CliFlag = exports.CliUsage = exports.CliExitError = exports.LAST_RESORT_TURN_OFF_SECONDS = exports.TurnOffRuleCure = exports.formatFixOptions = exports.Option = exports.renderRuleFailForHuman = exports.renderRuleFailForAi = exports.RuleFailError = exports.ResolvedRuleConfig = exports.ResolvedConfig = void 0;
4
- exports.HOME_CONFIG_DIR = exports.RETIRED_HOME_CONFIG_KEYS = exports.RetiredHomeConfigKey = exports.HomeConfigService = exports.HomeConfig = exports.validateChecklistDocs = exports.PrunedKey = exports.PruneResult = exports.ConfigPruner = exports.retiredRuleFor = exports.retiredKeyErrorsIn = exports.retiredKeyError = exports.retiredEntry = exports.isRetiredKey = exports.RETIRED_SCOPE_RULE = exports.RETIRED_SCOPE_KEY = exports.RETIRED_CONFIG_KEYS = exports.COMMENT_KEY_SUFFIX = exports.validateTopLevelKeys = exports.isCommentKey = exports.unknownKeyErrors = exports.validateCommandsSection = exports.seedEntryForRule = exports.recommendedSeedModeFor = exports.recommendedSeedMode = exports.allRuleNames = exports.validateMatchRulesSection = exports.validateExcludePaths = exports.validateChecklistsSection = exports.validatePrGateSection = exports.validateWebpiecesConfig = exports.BUILD_LOG_DOC = exports.ReferenceMergeRun = exports.MergeRun = exports.MergeProcessText = exports.MERGE_PROCESS_DOC = exports.MergeProcessDoc = exports.InstructAiDocSet = exports.InstructAiDoc = exports.GitWorkflowDoc = exports.GIT_WORKFLOW_DOC = exports.TemplateWriter = exports.writeTemplate = exports.writeTemplateIfMissing = exports.loadTemplate = exports.PathScopeConfig = exports.NoCustomCssScope = exports.GENERATED_CODE_PATHS = exports.RuleFileExclusions = exports.RuleFileScope = void 0;
4
+ exports.HOME_CONFIG_DIR = exports.RETIRED_HOME_CONFIG_KEYS = exports.RetiredHomeConfigKey = exports.HomeConfigService = exports.HomeConfig = exports.validateChecklistDocs = exports.PrunedKey = exports.PruneResult = exports.ConfigPruner = exports.retiredRuleFor = exports.retiredKeyErrorsIn = exports.retiredKeyError = exports.retiredEntry = exports.isRetiredKey = exports.RETIRED_SCOPE_RULE = exports.RETIRED_SCOPE_KEY = exports.RETIRED_CONFIG_KEYS = exports.CONFIG_DOCUMENTATION_PATH = exports.CONFIG_DOCUMENTATION_KEY = exports.validateTopLevelKeys = exports.unknownKeyErrors = exports.validateCommandsSection = exports.seedEntryForRule = exports.recommendedSeedModeFor = exports.recommendedSeedMode = exports.allRuleNames = exports.validateMatchRulesSection = exports.validateExcludePaths = exports.validateChecklistsSection = exports.validatePrGateSection = exports.validateWebpiecesConfig = exports.BUILD_LOG_DOC = exports.ReferenceMergeRun = exports.MergeRun = exports.MergeProcessText = exports.MERGE_PROCESS_DOC = exports.MergeProcessDoc = exports.InstructAiDocSet = exports.InstructAiDoc = exports.GitWorkflowDoc = exports.GIT_WORKFLOW_DOC = exports.TemplateWriter = exports.writeTemplate = exports.writeTemplateIfMissing = exports.loadTemplate = exports.PathScopeConfig = exports.NoCustomCssScope = exports.GENERATED_CODE_PATHS = exports.RuleFileExclusions = exports.RuleFileScope = void 0;
5
5
  exports.resolveBase = exports.detectBase = exports.SkipRuleResult = exports.HOTFIX_AUDIT_BANNER = exports.HOTFIX_BUILD_COMMAND = exports.shouldSkipRule = exports.sectionForRule = exports.isHookGuard = exports.schemaFieldNames = exports.DEFAULT_MATCH_RULES = exports.renderMatchRuleMessage = exports.compileMatchRulePatterns = exports.isMatchRuleAllowedPath = exports.findMatchRuleViolations = exports.MatchRuleViolation = exports.MatchRuleConfig = exports.OrphanSweepReport = exports.OrphanDirSweeper = exports.TRASH_RETENTION_DAYS = exports.TRASH_MANIFEST_FILE = exports.TRASH_STATE_DIR = exports.OrphanSweepManifest = exports.OrphanSweepResult = exports.FailedOrphan = exports.ArchivedOrphan = exports.OrphanDirArchiver = exports.OrphanCandidate = exports.OrphanDirScanner = exports.MAX_ROW_BYTES = exports.BUILDS_LOG_GENERATIONS = exports.MAX_BUILDS_LOG_BYTES = exports.BUILD_DONE_FAIL = exports.BUILD_DONE_SUCCESS = exports.BUILD_START = exports.BUILDS_LOCK_FILE = exports.BUILDS_LOG_FILE = exports.RunningBuild = exports.BuildTermination = exports.BuildTicket = exports.BuildsLog = exports.DOCUMENTATION_KEYS = exports.HOME_KEY_AI_DOC = exports.HOME_KEY_DOC = exports.DEFAULT_MAX_CONCURRENT_BUILDS = exports.HOME_KEY_TURN_OFF_ALL_REVIEWERS = exports.HOME_KEY_MAX_CONCURRENT_BUILDS = exports.HOME_KEY_WHOLE_REPO_BUILD_GUARD = exports.HOME_KEY_ORPHAN_DIR_SWEEP = exports.HOME_EXPERIMENTAL_SECTION = exports.HOME_CONFIG_FILE = void 0;
6
6
  exports.normalizeChecklistDoc = exports.toChecklist = exports.DEFAULT_REVIEWER_AGENT_NAME = exports.REVIEWER_AGENTS_PLACEHOLDER = exports.ReviewerAgentPolicy = exports.ChecklistDefinition = exports.MERGE_MODES = exports.MERGE_MODE_NONE = exports.MERGE_MODE_AUTO = exports.buildDevDeployConfig = exports.buildLandPrConfig = exports.buildPrGateConfig = exports.defaultDevDeployConfig = exports.defaultLandPrConfig = exports.defaultPrGateConfig = exports.defaultGates = exports.ReviewContextEntry = exports.DEFAULT_DEV_BRANCH = exports.DEFAULT_DEV_BRANCH_NAMESPACE = exports.DevDeployConfig = exports.LandPrConfig = exports.DEFAULT_BUILD_COMMAND = exports.PrGateConfig = exports.GateDefinition = exports.WP_FINISH_PUSH_DEV = exports.WP_PUSH_DEV = exports.WP_FINISH_UPSERT_PR = exports.WP_START_UPSERT_PR = exports.WP_FINISH_UPDATE = exports.WP_START_UPDATE = exports.SyncFlowGuidance = exports.WebpiecesRulesConfig = exports.UPGRADE_SHIM_COMMAND = exports.PRUNE_UNKNOWN_COMMAND = exports.PUSH_DEV_STATE_FILE = exports.MERGE_EXPLANATION_FILE = exports.MERGE_IN_PROGRESS_FILE = exports.MERGE_INFO_DIR = exports.hasDisable = exports.WEBPIECES_DISABLE = exports.AbstractRule = exports.ChangedFilesOptions = exports.DiffRange = exports.DiffScope = exports.isNewOrModified = exports.hasChangesInRange = exports.findNewMethodSignaturesInDiff = exports.getChangedLineNumbers = exports.getFileDiff = exports.getChangedFiles = void 0;
7
7
  exports.VERDICT_RED = exports.VERDICT_ORANGE = exports.VERDICT_YELLOW = exports.VERDICT_GREEN = exports.CK_BAD_FORMAT = exports.CK_MISSING = exports.CK_FAIL = exports.CK_ORANGE = exports.CK_ORANGE_FIXED = exports.CK_OVERRIDDEN = exports.CK_WARN = exports.CK_PASS = exports.checklistOverrideService = exports.ChecklistOverrideService = exports.ChecklistOverride = exports.ChecklistVerdict = exports.ChecklistResult = exports.PrContext = exports.AddressedIssue = exports.PrSummary = exports.DEFAULT_RETENTION_DAYS = exports.ProvenanceWriteRequest = exports.OfferedContext = exports.ReviewerPaths = exports.ReviewerTranscript = exports.ReviewProvenance = exports.ReviewProvenanceService = exports.PROVENANCE_SKIPPED = exports.PROVENANCE_MISSING = exports.PROVENANCE_OK = exports.ProvenanceResult = exports.TranscriptScan = exports.ExpectedReviewer = exports.ReviewerContext = exports.ReviewerEvidence = exports.SubagentProvenanceService = exports.verifyGateToken = exports.extractGateToken = exports.gateTokenMarker = exports.computeGateToken = exports.GateTokenService = exports.ALL_DIFF_ONE_READ_LINES = exports.READ_TRUNCATION_LINES = exports.ContextEntry = exports.BriefedFile = exports.ReviewerBriefing = exports.ReviewerInstructionsService = exports.ChecklistInstructionsService = exports.ChecklistValidator = exports.formatFileList = void 0;
@@ -140,9 +140,10 @@ var commands_section_validators_1 = require("./commands-section-validators");
140
140
  Object.defineProperty(exports, "validateCommandsSection", { enumerable: true, get: function () { return commands_section_validators_1.validateCommandsSection; } });
141
141
  var config_key_rules_1 = require("./config-key-rules");
142
142
  Object.defineProperty(exports, "unknownKeyErrors", { enumerable: true, get: function () { return config_key_rules_1.unknownKeyErrors; } });
143
- Object.defineProperty(exports, "isCommentKey", { enumerable: true, get: function () { return config_key_rules_1.isCommentKey; } });
144
143
  Object.defineProperty(exports, "validateTopLevelKeys", { enumerable: true, get: function () { return config_key_rules_1.validateTopLevelKeys; } });
145
- Object.defineProperty(exports, "COMMENT_KEY_SUFFIX", { enumerable: true, get: function () { return config_key_rules_1.COMMENT_KEY_SUFFIX; } });
144
+ var config_documentation_1 = require("./config-documentation");
145
+ Object.defineProperty(exports, "CONFIG_DOCUMENTATION_KEY", { enumerable: true, get: function () { return config_documentation_1.CONFIG_DOCUMENTATION_KEY; } });
146
+ Object.defineProperty(exports, "CONFIG_DOCUMENTATION_PATH", { enumerable: true, get: function () { return config_documentation_1.CONFIG_DOCUMENTATION_PATH; } });
146
147
  // The retired-key table + the no-back-compat policy it enforces. Exported so the installer can migrate
147
148
  // what the errors instruct, and so consumers can enumerate retirements.
148
149
  var retired_config_keys_1 = require("./retired-config-keys");
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,iCAA0E;AAAjE,uGAAA,cAAc,OAAA;AAAE,2GAAA,kBAAkB,OAAA;AAE3C,qDAA+F;AAAtF,gHAAA,aAAa,OAAA;AAAE,sHAAA,mBAAmB,OAAA;AAAE,yHAAA,sBAAsB,OAAA;AACnE,u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AA;AAGtB,6DAAmC;AACnC,oEAA0C;AAC1C,2DAK8B;AAJ1B,sHAAA,gBAAgB,OAAA;AAChB,8HAAA,wBAAwB,OAAA;AACxB,uHAAA,iBAAiB,OAAA;AACjB,0HAAA,oBAAoB,OAAA;AAGxB,iEAIiC;AAH7B,6HAAA,oBAAoB,OAAA;AACpB,6HAAA,oBAAoB,OAAA;AACpB,4HAAA,mBAAmB,OAAA;AAEvB,yDAK6B;AAJzB,0HAAA,qBAAqB,OAAA;AACrB,uHAAA,kBAAkB,OAAA;AAClB,0HAAA,qBAAqB,OAAA;AACrB,oHAAA,eAAe,OAAA;AAEnB,mDAAgD;AAAvC,8GAAA,YAAY,OAAA;AACrB,+DAA4D;AAAnD,0HAAA,kBAAkB,OAAA;AAC3B,6DAA8D;AAArD,4HAAA,qBAAqB,OAAA;AAC9B,6DAM+B;AAL3B,uHAAA,gBAAgB,OAAA;AAChB,wHAAA,iBAAiB,OAAA;AACjB,mHAAA,YAAY,OAAA;AACZ,qHAAA,cAAc,OAAA;AACd,6HAAA,sBAAsB,OAAA;AAE1B,qDAAyD;AAAhD,uHAAA,oBAAoB,OAAA;AAC7B,+DAKgC;AAJ5B,0HAAA,kBAAkB,OAAA;AAClB,+HAAA,uBAAuB,OAAA;AACvB,mIAAA,2BAA2B,OAAA;AAC3B,gIAAA,wBAAwB,OAAA;AAG5B,uDAA8F;AAArF,kHAAA,cAAc,OAAA;AAAE,wHAAA,oBAAoB,OAAA;AAAE,sHAAA,kBAAkB,OAAA","sourcesContent":["export { ResolvedConfig, ResolvedRuleConfig, RuleOptions } from './types';\n\nexport { RuleFailError, renderRuleFailForAi, renderRuleFailForHuman } from './rule-fail-error';\n// THE one representation of a cure, shared by RuleFailError (build-time) and FixHint (edit-time), plus\n// the one renderer that owns the \"Fix Option N:\" numbering and the \"(preferred)\" tag.\nexport { Option, formatFixOptions } from './fix-option';\nexport { TurnOffRuleCure, LAST_RESORT_TURN_OFF_SECONDS } from './turn-off-rule-cure';\nexport { CliExitError } from './cli-exit-error';\nexport { CliUsage, CliFlag, CliArgSet, CliArgsCheck, CliArgs } from './cli-args';\nexport { runMain } from './run-main';\n\nexport { loadAndValidate, LoadedConfig, ConfigLoader } from './load-config';\n// The validation-failure banner: ONE cure (edit the file), plus the marker phrases the validator\n// messages embed rather than re-type.\nexport {\n formatConfigErrorsBanner,\n CONFIG_POLICY_DOC,\n RETIRED_KEY_MARKER,\n RETIRED_TOP_LEVEL_MARKER,\n} from './config-error-banner';\nexport {\n findConfigFile,\n CONFIG_FILENAME,\n ConfigFile,\n ConfigParseAttempt,\n CONFIG_PARSE_ATTEMPTS,\n CONFIG_PARSE_RETRY_MILLIS,\n} from './config-file';\n// The PARSED-BUT-UNVALIDATED config shape. Exported for readers that walk the file generically rather\n// than through the typed config (the pr-gate active-hatch dashboard section reads every rule's hatches).\nexport { RawConfigFile } from './config-file';\nexport { RepoRootFinder, INSTRUCT_AI_DIR, INSTRUCT_AI_LEAF } from './repo-root';\n// The scoped `.webpieces` resolver. EVERY reader/writer of `.webpieces/...` goes through one of its two\n// named methods so the call site declares whether the state is repo-wide or worktree-private.\n\n// There is NO machine-global state root. `MachineStateHome`/`StateHome`/`WEBPIECES_STATE_HOME` and the\n// `PrBodyStore` that used them are DELETED: the one artifact that needed a scope above the clone was the\n// gated squash body, and GitHub holds it now (it IS the PR description). Every `.webpieces` path a\n// webpieces tool writes is `{repo}/.webpieces`, resolved through `DotWebpieces` above. See\n// `decisions/0005-the-pr-description-is-the-merge-body.md`.\nexport { AgedTreeSweeper, SweepCount, RETENTION_DAYS } from './aged-tree-sweep';\nexport {\n ClaudeEnv,\n claudeEnv,\n CLAUDE_PROJECT_DIR_ENV,\n CLAUDE_PROJECT_DIR_UNSET,\n} from './claude-env';\n\n// The ONE formatter for a remedy that must run in a named directory: `cd '<root>' && <command>`.\n// Single-quoted so a repo path containing a space is still runnable (and still un-smuggleable).\nexport { atRoot } from './at-root';\nexport { RulesConfigDesign } from './rules-config-design';\nexport { DocumentDesign, isDocumentDesign, DESIGN_METADATA_KEYS } from './di';\nexport { ExcludePaths, isWebpiecesStateDir } from './exclude-hook-paths';\nexport { isPathExcluded, matchesAnyGlob } from './exclude-paths';\nexport { globMatches } from './glob-matches';\n// Framework-applied path exclusions for a rule run (#1253): the dispatcher enters the scope, DiffScope's\n// file listings honour it, so no rule filters its own files.\nexport { RuleFileScope, RuleFileExclusions } from './rule-file-scope';\n// The machine-generated trees a line-count rule never fires on. A FLOOR, not a default value:\n// `max-file-lines.excludePaths` adds to it, so configuring your own tree cannot lose it.\nexport { GENERATED_CODE_PATHS } from './generated-code-paths';\n// THE one `no-custom-css` path exemption. Both engines that enforce the rule (the edit-time hook and the\n// CI validator) consult this class, so `allowGlobs` cannot be honoured by one half and ignored by the other.\nexport { NoCustomCssScope, PathScopeConfig } from './no-custom-css-scope';\nexport {\n loadTemplate,\n writeTemplateIfMissing,\n writeTemplate,\n TemplateWriter,\n} from './load-template';\n// The instruct-ai docs are delivered as a SET: writing one writes the transitive closure of the docs it\n// links to, so a doc and everything it points at always land together. See instruct-ai-docs.ts.\nexport {\n GIT_WORKFLOW_DOC,\n GitWorkflowDoc,\n InstructAiDoc,\n InstructAiDocSet,\n MergeProcessDoc,\n} from './instruct-ai-docs';\nexport {\n MERGE_PROCESS_DOC,\n MergeProcessText,\n MergeRun,\n ReferenceMergeRun,\n} from './merge-process-doc';\nexport { BUILD_LOG_DOC } from './build-log-doc';\nexport {\n validateWebpiecesConfig,\n validatePrGateSection,\n validateChecklistsSection,\n validateExcludePaths,\n validateMatchRulesSection,\n allRuleNames,\n recommendedSeedMode,\n recommendedSeedModeFor,\n seedEntryForRule,\n} from './validate-config';\nexport { validateCommandsSection } from './commands-section-validators';\nexport {\n unknownKeyErrors,\n isCommentKey,\n validateTopLevelKeys,\n COMMENT_KEY_SUFFIX,\n} from './config-key-rules';\n// The retired-key table + the no-back-compat policy it enforces. Exported so the installer can migrate\n// what the errors instruct, and so consumers can enumerate retirements.\nexport {\n RETIRED_CONFIG_KEYS,\n RETIRED_SCOPE_KEY,\n RETIRED_SCOPE_RULE,\n isRetiredKey,\n retiredEntry,\n retiredKeyError,\n retiredKeyErrorsIn,\n retiredRuleFor,\n} from './retired-config-keys';\n// The MECHANICAL cure the unknown-rule error and the banner both name: strip every key no validator has a\n// schema for, so cleanliness is one command rather than a judgement call made while every Bash call is\n// blocked. `PRUNE_UNKNOWN_COMMAND` (constants.ts) is the single spelling of that command.\nexport { ConfigPruner, PruneResult, PrunedKey } from './config-pruner';\nexport { validateChecklistDocs } from './checklist-docs-validator';\n// The OPTIONAL machine-local `~/.webpieces/config.json`: absent (the normal state for every consumer) means\n// each key's declared default, silently; present means STRICT about what it understands and FORWARD-COMPATIBLE\n// about what it does not. A retired key (its own retirement table), a known key of the wrong TYPE and an\n// unparseable document all REJECT; a key this release simply does not recognise is IGNORED with a warning,\n// because the file is machine-global and the repos reading it pin different releases — rejecting a newer\n// release's key would hard-block every repo on the machine that is not yet on it. See home-config.ts.\n// `isHomeConfigPath` is what grants the file its unconditional Write/Edit PASS in the hook guards, which is\n// what keeps a rejection repairable. Every `experimental.*` key is an OPT-IN that defaults OFF, including\n// `whole-repo-build-guard`: ON requires an explicit `true`, and there is no per-key default to export.\nexport {\n HomeConfig,\n HomeConfigService,\n RetiredHomeConfigKey,\n RETIRED_HOME_CONFIG_KEYS,\n HOME_CONFIG_DIR,\n HOME_CONFIG_FILE,\n HOME_EXPERIMENTAL_SECTION,\n HOME_KEY_ORPHAN_DIR_SWEEP,\n HOME_KEY_WHOLE_REPO_BUILD_GUARD,\n HOME_KEY_MAX_CONCURRENT_BUILDS,\n HOME_KEY_TURN_OFF_ALL_REVIEWERS,\n DEFAULT_MAX_CONCURRENT_BUILDS,\n HOME_KEY_DOC,\n HOME_KEY_AI_DOC,\n DOCUMENTATION_KEYS,\n} from './home-config';\n// The MACHINE-WIDE build ledger, `~/.webpieces/builds.log`. THE one carve-out from\n// `no-machine-global-state.spec.ts`'s rule that webpieces writes only under `{repo}/.webpieces` — the\n// argument is in `decisions/0006-the-build-ledger-is-machine-global.md`, and the short form is that \"how\n// many builds are burning this box's CPU\" is a fact about the MACHINE, is not a cache of anything a\n// remote owns, and cannot be answered from a per-repo file because every linked worktree has its own\n// `.webpieces/` and would be blind to the sibling it is contending with. See builds-log.ts.\nexport {\n BuildsLog,\n BuildTicket,\n BuildTermination,\n RunningBuild,\n BUILDS_LOG_FILE,\n BUILDS_LOCK_FILE,\n BUILD_START,\n BUILD_DONE_SUCCESS,\n BUILD_DONE_FAIL,\n MAX_BUILDS_LOG_BYTES,\n BUILDS_LOG_GENERATIONS,\n MAX_ROW_BYTES,\n} from './builds-log';\n// The orphan-directory sweep: the corpse an `nx g move` leaves on every clone, which git cannot remove\n// because an ignored dist/ or node_modules/ outlives every tracked file under it. See orphan-dir-scan.ts\n// for why the predicate is git's own `clean -Xdn` answer rather than a hand-rolled ignore walk.\nexport { OrphanDirScanner, OrphanCandidate } from './orphan-dir-scan';\nexport {\n OrphanDirArchiver,\n ArchivedOrphan,\n FailedOrphan,\n OrphanSweepResult,\n OrphanSweepManifest,\n TRASH_STATE_DIR,\n TRASH_MANIFEST_FILE,\n TRASH_RETENTION_DAYS,\n} from './orphan-dir-archive';\nexport { OrphanDirSweeper, OrphanSweepReport } from './orphan-dir-sweep';\nexport {\n MatchRuleConfig,\n MatchRuleViolation,\n findMatchRuleViolations,\n isMatchRuleAllowedPath,\n compileMatchRulePatterns,\n renderMatchRuleMessage,\n DEFAULT_MATCH_RULES,\n} from './match-rules-config';\nexport type { ConfigSection } from './sections';\nexport { schemaFieldNames } from './rule-schemas';\nexport { isHookGuard, sectionForRule } from './sections';\nexport { shouldSkipRule, HOTFIX_BUILD_COMMAND, HOTFIX_AUDIT_BANNER } from './skip-rule';\nexport { SkipRuleResult } from './skip-rule';\nexport {\n detectBase,\n resolveBase,\n getChangedFiles,\n getFileDiff,\n getChangedLineNumbers,\n findNewMethodSignaturesInDiff,\n hasChangesInRange,\n isNewOrModified,\n DiffScope,\n DiffRange,\n ChangedFilesOptions,\n} from './diff-scope';\nexport { AbstractRule } from './abstract-rule';\nexport {\n WEBPIECES_DISABLE,\n hasDisable,\n MERGE_INFO_DIR,\n MERGE_IN_PROGRESS_FILE,\n MERGE_EXPLANATION_FILE,\n PUSH_DEV_STATE_FILE,\n PRUNE_UNKNOWN_COMMAND,\n UPGRADE_SHIM_COMMAND,\n} from './constants';\nexport { WebpiecesRulesConfig } from './WebpiecesRulesConfig';\nexport {\n SyncFlowGuidance,\n WP_START_UPDATE,\n WP_FINISH_UPDATE,\n WP_START_UPSERT_PR,\n WP_FINISH_UPSERT_PR,\n WP_PUSH_DEV,\n WP_FINISH_PUSH_DEV,\n} from './sync-flow-guidance';\n\n// Mode unions + their value arrays — the single source of truth shared with code-rules.\n\n// The `no-state-paths-in-templates` config, in its own module for the same reason no-client-creation is:\n// rule-configs.ts is at its file-size cap and a rule that carries real defaults belongs beside them.\n\nexport {\n GateDefinition,\n PrGateConfig,\n DEFAULT_BUILD_COMMAND,\n LandPrConfig,\n DevDeployConfig,\n DEFAULT_DEV_BRANCH_NAMESPACE,\n DEFAULT_DEV_BRANCH,\n ReviewContextEntry,\n defaultGates,\n defaultPrGateConfig,\n defaultLandPrConfig,\n defaultDevDeployConfig,\n buildPrGateConfig,\n buildLandPrConfig,\n buildDevDeployConfig,\n MERGE_MODE_AUTO,\n MERGE_MODE_NONE,\n MERGE_MODES,\n} from './pr-gate-config';\nexport {\n ChecklistDefinition,\n ReviewerAgentPolicy,\n REVIEWER_AGENTS_PLACEHOLDER,\n DEFAULT_REVIEWER_AGENT_NAME,\n toChecklist,\n normalizeChecklistDoc,\n formatFileList,\n} from './checklist-config';\nexport type { RawChecklistItem } from './checklist-config';\nexport { ChecklistValidator } from './checklist-validator';\nexport { ChecklistInstructionsService } from './checklist-instructions';\nexport {\n ReviewerInstructionsService,\n ReviewerBriefing,\n BriefedFile,\n ContextEntry,\n READ_TRUNCATION_LINES,\n ALL_DIFF_ONE_READ_LINES,\n} from './reviewer-instructions';\nexport {\n GateTokenService,\n computeGateToken,\n gateTokenMarker,\n extractGateToken,\n verifyGateToken,\n} from './gate-token';\nexport {\n SubagentProvenanceService,\n ReviewerEvidence,\n ReviewerContext,\n ExpectedReviewer,\n TranscriptScan,\n ProvenanceResult,\n PROVENANCE_OK,\n PROVENANCE_MISSING,\n PROVENANCE_SKIPPED,\n} from './subagent-provenance';\n\nexport {\n ReviewProvenanceService,\n ReviewProvenance,\n ReviewerTranscript,\n ReviewerPaths,\n OfferedContext,\n ProvenanceWriteRequest,\n DEFAULT_RETENTION_DAYS,\n} from './review-provenance';\nexport {\n PrSummary,\n AddressedIssue,\n PrContext,\n ChecklistResult,\n ChecklistVerdict,\n ChecklistOverride,\n ChecklistOverrideService,\n checklistOverrideService,\n CK_PASS,\n CK_WARN,\n CK_OVERRIDDEN,\n CK_ORANGE_FIXED,\n CK_ORANGE,\n CK_FAIL,\n CK_MISSING,\n CK_BAD_FORMAT,\n VERDICT_GREEN,\n VERDICT_YELLOW,\n VERDICT_ORANGE,\n VERDICT_RED,\n VERDICT_STATUSES,\n RequiredChecklist,\n ChecklistReviewContext,\n ReviewJsonService,\n prDirFor,\n summaryJsonPath,\n summaryJsonSchemaHint,\n} from './review-json';\n\nexport {\n CommandsConfig,\n buildCommandsConfig,\n DEFAULT_UPSERT_PR_COMMAND,\n DEFAULT_MERGE_COMPLETE_COMMAND,\n} from './commands-config';\nexport { StaleBinRemoval, StaleBinSweeper, staleBinSweeper } from './stale-bin-sweep';\nexport { RepoScratchDirs, SCRATCH_DIR_NAME } from './repo-scratch-dirs';\nexport {\n TmpScratchSweeper,\n TMP_SCRATCH_RETENTION_DAYS,\n TMP_SCRATCH_PREFIX,\n} from './tmp-scratch-sweep';\n\nexport * from './hook-fault-codes';\nexport * from './hook-config-diagnostics';\nexport {\n RulePackRegistry,\n NodeRulePackModuleLoader,\n RulePackDiscovery,\n RulePackModuleLoader,\n} from './rule-pack-registry';\n\nexport {\n prepareLegacyUpgrade,\n LegacyConfigDocument,\n LegacyUpgradeResult,\n} from './legacy-config-upgrade';\nexport {\n PackPolicyDeclaration,\n SelectedPolicyPack,\n PackPolicyFilesResult,\n PackPolicyFiles,\n} from './pack-policy-files';\nexport { RulePackSync } from './rule-pack-sync';\nexport { ConfigRepairAccess } from './config-repair-access';\nexport { ConfigRepairBootstrap } from './config-repair-probe';\nexport {\n ConfigRepairCure,\n ConfigRepairError,\n EditFileCure,\n RunCommandCure,\n RepositoryLayoutRepair,\n} from './config-repair-error';\nexport { UntrackedPolicyError } from './policy-tracking';\nexport {\n RuleRuntimeModules,\n RuleRuntimeModuleLoader,\n NodeRuleRuntimeModuleLoader,\n RuntimeContributionGroup,\n} from './rule-runtime-modules';\n\nexport { FirstPathMatch, FirstPathMatchResult, PathMatchCandidate } from './first-path-match';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,iCAA0E;AAAjE,uGAAA,cAAc,OAAA;AAAE,2GAAA,kBAAkB,OAAA;AAE3C,qDAA+F;AAAtF,gHAAA,aAAa,OAAA;AAAE,sHAAA,mBAAmB,OAAA;AAAE,yHAAA,sBAAsB,OAAA;AACnE,uGAAuG;AACvG,sFAAsF;AACtF,2CAAwD;AAA/C,oGAAA,MAAM,OAAA;AAAE,8GAAA,gBAAgB,OAAA;AACjC,2DAAqF;AAA5E,qHAAA,eAAe,OAAA;AAAE,kIAAA,4BAA4B,OAAA;AACtD,mDAAgD;AAAvC,8GAAA,YAAY,OAAA;AACrB,uCAAiF;AAAxE,oGAAA,QAAQ,OAAA;AAAE,mGAAA,OAAO,OAAA;AAAE,qGAAA,SAAS,OAAA;AAAE,wGAAA,YAAY,OAAA;AAAE,mGAAA,OAAO,OAAA;AAC5D,uCAAqC;AAA5B,mGAAA,OAAO,OAAA;AAEhB,6CAA4E;AAAnE,8GAAA,eAAe,OAAA;AAAE,2G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AAY,OAAA;AACrB,+DAA4D;AAAnD,0HAAA,kBAAkB,OAAA;AAC3B,6DAA8D;AAArD,4HAAA,qBAAqB,OAAA;AAC9B,6DAM+B;AAL3B,uHAAA,gBAAgB,OAAA;AAChB,wHAAA,iBAAiB,OAAA;AACjB,mHAAA,YAAY,OAAA;AACZ,qHAAA,cAAc,OAAA;AACd,6HAAA,sBAAsB,OAAA;AAE1B,qDAAyD;AAAhD,uHAAA,oBAAoB,OAAA;AAC7B,+DAKgC;AAJ5B,0HAAA,kBAAkB,OAAA;AAClB,+HAAA,uBAAuB,OAAA;AACvB,mIAAA,2BAA2B,OAAA;AAC3B,gIAAA,wBAAwB,OAAA;AAG5B,uDAA8F;AAArF,kHAAA,cAAc,OAAA;AAAE,wHAAA,oBAAoB,OAAA;AAAE,sHAAA,kBAAkB,OAAA","sourcesContent":["export { ResolvedConfig, ResolvedRuleConfig, RuleOptions } from './types';\n\nexport { RuleFailError, renderRuleFailForAi, renderRuleFailForHuman } from './rule-fail-error';\n// THE one representation of a cure, shared by RuleFailError (build-time) and FixHint (edit-time), plus\n// the one renderer that owns the \"Fix Option N:\" numbering and the \"(preferred)\" tag.\nexport { Option, formatFixOptions } from './fix-option';\nexport { TurnOffRuleCure, LAST_RESORT_TURN_OFF_SECONDS } from './turn-off-rule-cure';\nexport { CliExitError } from './cli-exit-error';\nexport { CliUsage, CliFlag, CliArgSet, CliArgsCheck, CliArgs } from './cli-args';\nexport { runMain } from './run-main';\n\nexport { loadAndValidate, LoadedConfig, ConfigLoader } from './load-config';\n// The validation-failure banner: ONE cure (edit the file), plus the marker phrases the validator\n// messages embed rather than re-type.\nexport {\n formatConfigErrorsBanner,\n CONFIG_POLICY_DOC,\n RETIRED_KEY_MARKER,\n RETIRED_TOP_LEVEL_MARKER,\n} from './config-error-banner';\nexport {\n findConfigFile,\n CONFIG_FILENAME,\n ConfigFile,\n ConfigParseAttempt,\n CONFIG_PARSE_ATTEMPTS,\n CONFIG_PARSE_RETRY_MILLIS,\n} from './config-file';\n// The PARSED-BUT-UNVALIDATED config shape. Exported for readers that walk the file generically rather\n// than through the typed config (the pr-gate active-hatch dashboard section reads every rule's hatches).\nexport { RawConfigFile } from './config-file';\nexport { RepoRootFinder, INSTRUCT_AI_DIR, INSTRUCT_AI_LEAF } from './repo-root';\n// The scoped `.webpieces` resolver. EVERY reader/writer of `.webpieces/...` goes through one of its two\n// named methods so the call site declares whether the state is repo-wide or worktree-private.\n\n// There is NO machine-global state root. `MachineStateHome`/`StateHome`/`WEBPIECES_STATE_HOME` and the\n// `PrBodyStore` that used them are DELETED: the one artifact that needed a scope above the clone was the\n// gated squash body, and GitHub holds it now (it IS the PR description). Every `.webpieces` path a\n// webpieces tool writes is `{repo}/.webpieces`, resolved through `DotWebpieces` above. See\n// `decisions/0005-the-pr-description-is-the-merge-body.md`.\nexport { AgedTreeSweeper, SweepCount, RETENTION_DAYS } from './aged-tree-sweep';\nexport {\n ClaudeEnv,\n claudeEnv,\n CLAUDE_PROJECT_DIR_ENV,\n CLAUDE_PROJECT_DIR_UNSET,\n} from './claude-env';\n\n// The ONE formatter for a remedy that must run in a named directory: `cd '<root>' && <command>`.\n// Single-quoted so a repo path containing a space is still runnable (and still un-smuggleable).\nexport { atRoot } from './at-root';\nexport { RulesConfigDesign } from './rules-config-design';\nexport { DocumentDesign, isDocumentDesign, DESIGN_METADATA_KEYS } from './di';\nexport { ExcludePaths, isWebpiecesStateDir } from './exclude-hook-paths';\nexport { isPathExcluded, matchesAnyGlob } from './exclude-paths';\nexport { globMatches } from './glob-matches';\n// Framework-applied path exclusions for a rule run (#1253): the dispatcher enters the scope, DiffScope's\n// file listings honour it, so no rule filters its own files.\nexport { RuleFileScope, RuleFileExclusions } from './rule-file-scope';\n// The machine-generated trees a line-count rule never fires on. A FLOOR, not a default value:\n// `max-file-lines.excludePaths` adds to it, so configuring your own tree cannot lose it.\nexport { GENERATED_CODE_PATHS } from './generated-code-paths';\n// THE one `no-custom-css` path exemption. Both engines that enforce the rule (the edit-time hook and the\n// CI validator) consult this class, so `allowGlobs` cannot be honoured by one half and ignored by the other.\nexport { NoCustomCssScope, PathScopeConfig } from './no-custom-css-scope';\nexport {\n loadTemplate,\n writeTemplateIfMissing,\n writeTemplate,\n TemplateWriter,\n} from './load-template';\n// The instruct-ai docs are delivered as a SET: writing one writes the transitive closure of the docs it\n// links to, so a doc and everything it points at always land together. See instruct-ai-docs.ts.\nexport {\n GIT_WORKFLOW_DOC,\n GitWorkflowDoc,\n InstructAiDoc,\n InstructAiDocSet,\n MergeProcessDoc,\n} from './instruct-ai-docs';\nexport {\n MERGE_PROCESS_DOC,\n MergeProcessText,\n MergeRun,\n ReferenceMergeRun,\n} from './merge-process-doc';\nexport { BUILD_LOG_DOC } from './build-log-doc';\nexport {\n validateWebpiecesConfig,\n validatePrGateSection,\n validateChecklistsSection,\n validateExcludePaths,\n validateMatchRulesSection,\n allRuleNames,\n recommendedSeedMode,\n recommendedSeedModeFor,\n seedEntryForRule,\n} from './validate-config';\nexport { validateCommandsSection } from './commands-section-validators';\nexport {\n unknownKeyErrors,\n validateTopLevelKeys,\n} from './config-key-rules';\nexport { CONFIG_DOCUMENTATION_KEY, CONFIG_DOCUMENTATION_PATH } from './config-documentation';\n// The retired-key table + the no-back-compat policy it enforces. Exported so the installer can migrate\n// what the errors instruct, and so consumers can enumerate retirements.\nexport {\n RETIRED_CONFIG_KEYS,\n RETIRED_SCOPE_KEY,\n RETIRED_SCOPE_RULE,\n isRetiredKey,\n retiredEntry,\n retiredKeyError,\n retiredKeyErrorsIn,\n retiredRuleFor,\n} from './retired-config-keys';\n// The MECHANICAL cure the unknown-rule error and the banner both name: strip every key no validator has a\n// schema for, so cleanliness is one command rather than a judgement call made while every Bash call is\n// blocked. `PRUNE_UNKNOWN_COMMAND` (constants.ts) is the single spelling of that command.\nexport { ConfigPruner, PruneResult, PrunedKey } from './config-pruner';\nexport { validateChecklistDocs } from './checklist-docs-validator';\n// The OPTIONAL machine-local `~/.webpieces/config.json`: absent (the normal state for every consumer) means\n// each key's declared default, silently; present means STRICT about what it understands and FORWARD-COMPATIBLE\n// about what it does not. A retired key (its own retirement table), a known key of the wrong TYPE and an\n// unparseable document all REJECT; a key this release simply does not recognise is IGNORED with a warning,\n// because the file is machine-global and the repos reading it pin different releases — rejecting a newer\n// release's key would hard-block every repo on the machine that is not yet on it. See home-config.ts.\n// `isHomeConfigPath` is what grants the file its unconditional Write/Edit PASS in the hook guards, which is\n// what keeps a rejection repairable. Every `experimental.*` key is an OPT-IN that defaults OFF, including\n// `whole-repo-build-guard`: ON requires an explicit `true`, and there is no per-key default to export.\nexport {\n HomeConfig,\n HomeConfigService,\n RetiredHomeConfigKey,\n RETIRED_HOME_CONFIG_KEYS,\n HOME_CONFIG_DIR,\n HOME_CONFIG_FILE,\n HOME_EXPERIMENTAL_SECTION,\n HOME_KEY_ORPHAN_DIR_SWEEP,\n HOME_KEY_WHOLE_REPO_BUILD_GUARD,\n HOME_KEY_MAX_CONCURRENT_BUILDS,\n HOME_KEY_TURN_OFF_ALL_REVIEWERS,\n DEFAULT_MAX_CONCURRENT_BUILDS,\n HOME_KEY_DOC,\n HOME_KEY_AI_DOC,\n DOCUMENTATION_KEYS,\n} from './home-config';\n// The MACHINE-WIDE build ledger, `~/.webpieces/builds.log`. THE one carve-out from\n// `no-machine-global-state.spec.ts`'s rule that webpieces writes only under `{repo}/.webpieces` — the\n// argument is in `decisions/0006-the-build-ledger-is-machine-global.md`, and the short form is that \"how\n// many builds are burning this box's CPU\" is a fact about the MACHINE, is not a cache of anything a\n// remote owns, and cannot be answered from a per-repo file because every linked worktree has its own\n// `.webpieces/` and would be blind to the sibling it is contending with. See builds-log.ts.\nexport {\n BuildsLog,\n BuildTicket,\n BuildTermination,\n RunningBuild,\n BUILDS_LOG_FILE,\n BUILDS_LOCK_FILE,\n BUILD_START,\n BUILD_DONE_SUCCESS,\n BUILD_DONE_FAIL,\n MAX_BUILDS_LOG_BYTES,\n BUILDS_LOG_GENERATIONS,\n MAX_ROW_BYTES,\n} from './builds-log';\n// The orphan-directory sweep: the corpse an `nx g move` leaves on every clone, which git cannot remove\n// because an ignored dist/ or node_modules/ outlives every tracked file under it. See orphan-dir-scan.ts\n// for why the predicate is git's own `clean -Xdn` answer rather than a hand-rolled ignore walk.\nexport { OrphanDirScanner, OrphanCandidate } from './orphan-dir-scan';\nexport {\n OrphanDirArchiver,\n ArchivedOrphan,\n FailedOrphan,\n OrphanSweepResult,\n OrphanSweepManifest,\n TRASH_STATE_DIR,\n TRASH_MANIFEST_FILE,\n TRASH_RETENTION_DAYS,\n} from './orphan-dir-archive';\nexport { OrphanDirSweeper, OrphanSweepReport } from './orphan-dir-sweep';\nexport {\n MatchRuleConfig,\n MatchRuleViolation,\n findMatchRuleViolations,\n isMatchRuleAllowedPath,\n compileMatchRulePatterns,\n renderMatchRuleMessage,\n DEFAULT_MATCH_RULES,\n} from './match-rules-config';\nexport type { ConfigSection } from './sections';\nexport { schemaFieldNames } from './rule-schemas';\nexport { isHookGuard, sectionForRule } from './sections';\nexport { shouldSkipRule, HOTFIX_BUILD_COMMAND, HOTFIX_AUDIT_BANNER } from './skip-rule';\nexport { SkipRuleResult } from './skip-rule';\nexport {\n detectBase,\n resolveBase,\n getChangedFiles,\n getFileDiff,\n getChangedLineNumbers,\n findNewMethodSignaturesInDiff,\n hasChangesInRange,\n isNewOrModified,\n DiffScope,\n DiffRange,\n ChangedFilesOptions,\n} from './diff-scope';\nexport { AbstractRule } from './abstract-rule';\nexport {\n WEBPIECES_DISABLE,\n hasDisable,\n MERGE_INFO_DIR,\n MERGE_IN_PROGRESS_FILE,\n MERGE_EXPLANATION_FILE,\n PUSH_DEV_STATE_FILE,\n PRUNE_UNKNOWN_COMMAND,\n UPGRADE_SHIM_COMMAND,\n} from './constants';\nexport { WebpiecesRulesConfig } from './WebpiecesRulesConfig';\nexport {\n SyncFlowGuidance,\n WP_START_UPDATE,\n WP_FINISH_UPDATE,\n WP_START_UPSERT_PR,\n WP_FINISH_UPSERT_PR,\n WP_PUSH_DEV,\n WP_FINISH_PUSH_DEV,\n} from './sync-flow-guidance';\n\n// Mode unions + their value arrays — the single source of truth shared with code-rules.\n\n// The `no-state-paths-in-templates` config, in its own module for the same reason no-client-creation is:\n// rule-configs.ts is at its file-size cap and a rule that carries real defaults belongs beside them.\n\nexport {\n GateDefinition,\n PrGateConfig,\n DEFAULT_BUILD_COMMAND,\n LandPrConfig,\n DevDeployConfig,\n DEFAULT_DEV_BRANCH_NAMESPACE,\n DEFAULT_DEV_BRANCH,\n ReviewContextEntry,\n defaultGates,\n defaultPrGateConfig,\n defaultLandPrConfig,\n defaultDevDeployConfig,\n buildPrGateConfig,\n buildLandPrConfig,\n buildDevDeployConfig,\n MERGE_MODE_AUTO,\n MERGE_MODE_NONE,\n MERGE_MODES,\n} from './pr-gate-config';\nexport {\n ChecklistDefinition,\n ReviewerAgentPolicy,\n REVIEWER_AGENTS_PLACEHOLDER,\n DEFAULT_REVIEWER_AGENT_NAME,\n toChecklist,\n normalizeChecklistDoc,\n formatFileList,\n} from './checklist-config';\nexport type { RawChecklistItem } from './checklist-config';\nexport { ChecklistValidator } from './checklist-validator';\nexport { ChecklistInstructionsService } from './checklist-instructions';\nexport {\n ReviewerInstructionsService,\n ReviewerBriefing,\n BriefedFile,\n ContextEntry,\n READ_TRUNCATION_LINES,\n ALL_DIFF_ONE_READ_LINES,\n} from './reviewer-instructions';\nexport {\n GateTokenService,\n computeGateToken,\n gateTokenMarker,\n extractGateToken,\n verifyGateToken,\n} from './gate-token';\nexport {\n SubagentProvenanceService,\n ReviewerEvidence,\n ReviewerContext,\n ExpectedReviewer,\n TranscriptScan,\n ProvenanceResult,\n PROVENANCE_OK,\n PROVENANCE_MISSING,\n PROVENANCE_SKIPPED,\n} from './subagent-provenance';\n\nexport {\n ReviewProvenanceService,\n ReviewProvenance,\n ReviewerTranscript,\n ReviewerPaths,\n OfferedContext,\n ProvenanceWriteRequest,\n DEFAULT_RETENTION_DAYS,\n} from './review-provenance';\nexport {\n PrSummary,\n AddressedIssue,\n PrContext,\n ChecklistResult,\n ChecklistVerdict,\n ChecklistOverride,\n ChecklistOverrideService,\n checklistOverrideService,\n CK_PASS,\n CK_WARN,\n CK_OVERRIDDEN,\n CK_ORANGE_FIXED,\n CK_ORANGE,\n CK_FAIL,\n CK_MISSING,\n CK_BAD_FORMAT,\n VERDICT_GREEN,\n VERDICT_YELLOW,\n VERDICT_ORANGE,\n VERDICT_RED,\n VERDICT_STATUSES,\n RequiredChecklist,\n ChecklistReviewContext,\n ReviewJsonService,\n prDirFor,\n summaryJsonPath,\n summaryJsonSchemaHint,\n} from './review-json';\n\nexport {\n CommandsConfig,\n buildCommandsConfig,\n DEFAULT_UPSERT_PR_COMMAND,\n DEFAULT_MERGE_COMPLETE_COMMAND,\n} from './commands-config';\nexport { StaleBinRemoval, StaleBinSweeper, staleBinSweeper } from './stale-bin-sweep';\nexport { RepoScratchDirs, SCRATCH_DIR_NAME } from './repo-scratch-dirs';\nexport {\n TmpScratchSweeper,\n TMP_SCRATCH_RETENTION_DAYS,\n TMP_SCRATCH_PREFIX,\n} from './tmp-scratch-sweep';\n\nexport * from './hook-fault-codes';\nexport * from './hook-config-diagnostics';\nexport {\n RulePackRegistry,\n NodeRulePackModuleLoader,\n RulePackDiscovery,\n RulePackModuleLoader,\n} from './rule-pack-registry';\n\nexport {\n prepareLegacyUpgrade,\n LegacyConfigDocument,\n LegacyUpgradeResult,\n} from './legacy-config-upgrade';\nexport {\n PackPolicyDeclaration,\n SelectedPolicyPack,\n PackPolicyFilesResult,\n PackPolicyFiles,\n} from './pack-policy-files';\nexport { RulePackSync } from './rule-pack-sync';\nexport { ConfigRepairAccess } from './config-repair-access';\nexport { ConfigRepairBootstrap } from './config-repair-probe';\nexport {\n ConfigRepairCure,\n ConfigRepairError,\n EditFileCure,\n RunCommandCure,\n RepositoryLayoutRepair,\n} from './config-repair-error';\nexport { UntrackedPolicyError } from './policy-tracking';\nexport {\n RuleRuntimeModules,\n RuleRuntimeModuleLoader,\n NodeRuleRuntimeModuleLoader,\n RuntimeContributionGroup,\n} from './rule-runtime-modules';\n\nexport { FirstPathMatch, FirstPathMatchResult, PathMatchCandidate } from './first-path-match';\n"]}
@@ -20,6 +20,8 @@ const WebpiecesRulesConfig_1 = require("./WebpiecesRulesConfig");
20
20
  const policy_tracking_1 = require("./policy-tracking");
21
21
  const config_error_banner_1 = require("./config-error-banner");
22
22
  const config_repair_error_1 = require("./config-repair-error");
23
+ const load_template_1 = require("./load-template");
24
+ const config_error_banner_2 = require("./config-error-banner");
23
25
  const constants_1 = require("./constants");
24
26
  /** One root parse and one owner-resolution pass supply all consumers with the same registry and settings. */
25
27
  class LoadedConfig {
@@ -60,6 +62,7 @@ let ConfigLoader = class ConfigLoader {
60
62
  const raw = this.configFile.readRawConfig(configPath), root = path.dirname(configPath);
61
63
  // webpieces-disable no-any-unknown -- the root parser returns opaque client JSON; these validators narrow every accepted field
62
64
  const document = raw;
65
+ (0, load_template_1.writeTemplate)(root, config_error_banner_2.CONFIG_POLICY_DOC);
63
66
  const errors = [
64
67
  ...(0, config_key_rules_1.validateTopLevelKeys)(document),
65
68
  ...(0, commands_section_validators_1.validateCommandsSection)(raw.commands, document['pr-gate'], root),
@@ -1 +1 @@
1
- {"version":3,"file":"load-config.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/load-config.ts"],"names":[],"mappings":";;;AAoIA,0CAEC;;AAtID,wDAAkC;AAClC,yCAA2D;AAC3D,oDAAoD;AACpD,8DAA6D;AAC7D,uDAAwE;AACxE,+CAA2C;AAC3C,6DAAwD;AACxD,2DAA6E;AAC7E,6DAAoD;AAEpD,mCAA6D;AAC7D,+EAAwE;AACxE,yDAA0D;AAC1D,uDAAoF;AAEpF,iEAA8D;AAC9D,uDAAmD;AACnD,+DAAiE;AACjE,+DAAgH;AAChH,2CAAoD;AAEpD,6GAA6G;AAC7G,MAAa,YAAY;IAGR;IACA;IACA;IACA;IACA;IACA;IACA;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Ae,GAAG,IAAI,YAAY,CAAC,IAAI,wBAAU,EAAE,EAAE,IAAI,mCAAe,EAAE,CAAC,CAAC;AAElF,oFAAoF;AACpF,oHAAoH;AACpH,SAAgB,eAAe,CAAC,GAAW;IACvC,OAAO,eAAe,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;AAChD,CAAC","sourcesContent":["import * as path from 'node:path';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { ConfigObject } from '@webpieces/rules-sdk';\nimport { RepositoryLayout } from '@webpieces/tooling-common';\nimport { buildCommandsConfig, CommandsConfig } from './commands-config';\nimport { ConfigFile } from './config-file';\nimport { RulePackRegistry } from './rule-pack-registry';\nimport { PackPolicyFiles, PackPolicyFilesResult } from './pack-policy-files';\nimport { ExcludePaths } from './exclude-hook-paths';\nimport { PrGateConfig } from './pr-gate-config';\nimport { ResolvedConfig, ResolvedRuleConfig } from './types';\nimport { validateCommandsSection } from './commands-section-validators';\nimport { validateTopLevelKeys } from './config-key-rules';\nimport { validateExcludePaths, validateMatchRulesSection } from './validate-config';\nimport { MatchRuleConfig } from './match-rules-config';\nimport { WebpiecesRulesConfig } from './WebpiecesRulesConfig';\nimport { PolicyTracking } from './policy-tracking';\nimport { formatConfigErrorsBanner } from './config-error-banner';\nimport { ConfigRepairError, EditFileCure, RepositoryLayoutRepair, RunCommandCure } from './config-repair-error';\nimport { PRUNE_UNKNOWN_COMMAND } from './constants';\n\n/** One root parse and one owner-resolution pass supply all consumers with the same registry and settings. */\nexport class LoadedConfig {\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n readonly resolved: ResolvedConfig,\n readonly rulesConfig: WebpiecesRulesConfig,\n readonly commands: CommandsConfig,\n readonly prGate: PrGateConfig,\n readonly excludePaths: ExcludePaths,\n readonly matchRules: readonly MatchRuleConfig[],\n readonly configPath: string | null,\n readonly ruleRegistry: RulePackRegistry,\n readonly policyFiles: PackPolicyFilesResult | null,\n ) {}\n}\n\n@injectable(bindingScopeValues.Singleton)\nexport class ConfigLoader {\n constructor(\n private readonly configFile: ConfigFile,\n private readonly files: PackPolicyFiles,\n ) {}\n\n loadAndValidate(cwd: string): LoadedConfig {\n const configPath = this.configFile.findConfigFile(cwd);\n if (!configPath) return this.empty();\n const raw = this.configFile.readRawConfig(configPath),\n root = path.dirname(configPath);\n // webpieces-disable no-any-unknown -- the root parser returns opaque client JSON; these validators narrow every accepted field\n const document = raw as Record<string, unknown>;\n const errors = [\n ...validateTopLevelKeys(document),\n ...validateCommandsSection(raw.commands, document['pr-gate'], root),\n ...validateExcludePaths(raw.excludePaths),\n ...validateMatchRulesSection(raw['match-rules']),\n ];\n if (errors.length)\n throw new ConfigRepairError(formatConfigErrorsBanner(errors), [\n new EditFileCure(configPath, `Edit ${configPath} and apply every bullet above.`),\n new RunCommandCure(\n PRUNE_UNKNOWN_COMMAND,\n `${PRUNE_UNKNOWN_COMMAND} — deletes every key no validator has a schema for.`,\n ),\n ]);\n new RepositoryLayoutRepair().run(() => new RepositoryLayout().assertCurrent(root));\n const declarations = this.files.declarations(raw.rulePacks, root);\n const policy = this.files.resolve(root, this.files.select(root, declarations));\n new PolicyTracking().check(root, declarations);\n return this.loaded(\n configPath,\n raw.commands,\n raw.excludePaths as string[],\n raw['match-rules'] as MatchRuleConfig[],\n policy,\n );\n }\n\n private loaded(\n configPath: string,\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n commandsRaw: unknown,\n excluded: readonly string[],\n matches: readonly MatchRuleConfig[],\n policy: PackPolicyFilesResult,\n ): LoadedConfig {\n const commands = buildCommandsConfig(commandsRaw),\n values = new WebpiecesRulesConfig();\n const resolved = new Map<string, ResolvedRuleConfig>();\n for (const id of policy.registry.ruleIds()) {\n const explicit = policy.values[id];\n values[id] = explicit;\n const options = Object.assign(\n new ConfigObject(),\n policy.registry.optionalTuningFor(id),\n explicit,\n );\n resolved.set(id, new ResolvedRuleConfig(options));\n }\n return new LoadedConfig(\n new ResolvedConfig(resolved, new Set(policy.registry.ruleIds()), configPath),\n values,\n commands,\n commands.prGate,\n new ExcludePaths([...excluded]),\n matches,\n configPath,\n policy.registry,\n policy,\n );\n }\n\n private empty(): LoadedConfig {\n const commands = buildCommandsConfig(undefined);\n return new LoadedConfig(\n new ResolvedConfig(new Map(), new Set(), null),\n new WebpiecesRulesConfig(),\n commands,\n commands.prGate,\n new ExcludePaths([]),\n [],\n null,\n new RulePackRegistry([]),\n null,\n );\n }\n}\n\nconst configLoaderSvc = new ConfigLoader(new ConfigFile(), new PackPolicyFiles());\n\n/** Public function entry point and injected service use the same implementation. */\n// webpieces-disable no-function-outside-class -- canonical public loader function for CLI and executor entry points\nexport function loadAndValidate(cwd: string): LoadedConfig {\n return configLoaderSvc.loadAndValidate(cwd);\n}\n"]}
1
+ {"version":3,"file":"load-config.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/load-config.ts"],"names":[],"mappings":";;;AAuIA,0CAEC;;AAzID,wDAAkC;AAClC,yCAA2D;AAC3D,oDAAoD;AACpD,8DAA6D;AAC7D,uDAAwE;AACxE,+CAA2C;AAC3C,6DAAwD;AACxD,2DAA6E;AAC7E,6DAAoD;AAEpD,mCAA6D;AAC7D,+EAAwE;AACxE,yDAA0D;AAC1D,uDAAoF;AAEpF,iEAA8D;AAC9D,uDAAmD;AACnD,+DAAiE;AACjE,+DAAgH;AAChH,mDAAgD;AAChD,+DAA0D;AAC1D,2CAAoD;AAEpD,6GAA6G;AAC7G,MAAa,YAAY;IAGR;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAVb,yDAAyD;IACzD,YACa,QAAwB,EACxB,WAAiC,EACjC,QAAwB,EACxB,MAAoB,EACpB,YAA0B,EAC1B,UAAsC,EACtC,UAAyB,EACzB,YAA8B,EAC9B,WAAyC;QARzC,aAAQ,GAAR,QAAQ,CAAgB;QACxB,gBAAW,GAAX,WAAW,CAAsB;QACjC,aAAQ,GAAR,QAAQ,CAAgB;QACxB,WAAM,GAAN,MAAM,CAAc;QACpB,i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:path';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { ConfigObject } from '@webpieces/rules-sdk';\nimport { RepositoryLayout } from '@webpieces/tooling-common';\nimport { buildCommandsConfig, CommandsConfig } from './commands-config';\nimport { ConfigFile } from './config-file';\nimport { RulePackRegistry } from './rule-pack-registry';\nimport { PackPolicyFiles, PackPolicyFilesResult } from './pack-policy-files';\nimport { ExcludePaths } from './exclude-hook-paths';\nimport { PrGateConfig } from './pr-gate-config';\nimport { ResolvedConfig, ResolvedRuleConfig } from './types';\nimport { validateCommandsSection } from './commands-section-validators';\nimport { validateTopLevelKeys } from './config-key-rules';\nimport { validateExcludePaths, validateMatchRulesSection } from './validate-config';\nimport { MatchRuleConfig } from './match-rules-config';\nimport { WebpiecesRulesConfig } from './WebpiecesRulesConfig';\nimport { PolicyTracking } from './policy-tracking';\nimport { formatConfigErrorsBanner } from './config-error-banner';\nimport { ConfigRepairError, EditFileCure, RepositoryLayoutRepair, RunCommandCure } from './config-repair-error';\nimport { writeTemplate } from './load-template';\nimport { CONFIG_POLICY_DOC } from './config-error-banner';\nimport { PRUNE_UNKNOWN_COMMAND } from './constants';\n\n/** One root parse and one owner-resolution pass supply all consumers with the same registry and settings. */\nexport class LoadedConfig {\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n readonly resolved: ResolvedConfig,\n readonly rulesConfig: WebpiecesRulesConfig,\n readonly commands: CommandsConfig,\n readonly prGate: PrGateConfig,\n readonly excludePaths: ExcludePaths,\n readonly matchRules: readonly MatchRuleConfig[],\n readonly configPath: string | null,\n readonly ruleRegistry: RulePackRegistry,\n readonly policyFiles: PackPolicyFilesResult | null,\n ) {}\n}\n\n@injectable(bindingScopeValues.Singleton)\nexport class ConfigLoader {\n constructor(\n private readonly configFile: ConfigFile,\n private readonly files: PackPolicyFiles,\n ) {}\n\n loadAndValidate(cwd: string): LoadedConfig {\n const configPath = this.configFile.findConfigFile(cwd);\n if (!configPath) return this.empty();\n const raw = this.configFile.readRawConfig(configPath),\n root = path.dirname(configPath);\n // webpieces-disable no-any-unknown -- the root parser returns opaque client JSON; these validators narrow every accepted field\n const document = raw as Record<string, unknown>;\n writeTemplate(root, CONFIG_POLICY_DOC);\n const errors = [\n ...validateTopLevelKeys(document),\n ...validateCommandsSection(raw.commands, document['pr-gate'], root),\n ...validateExcludePaths(raw.excludePaths),\n ...validateMatchRulesSection(raw['match-rules']),\n ];\n if (errors.length)\n throw new ConfigRepairError(formatConfigErrorsBanner(errors), [\n new EditFileCure(configPath, `Edit ${configPath} and apply every bullet above.`),\n new RunCommandCure(\n PRUNE_UNKNOWN_COMMAND,\n `${PRUNE_UNKNOWN_COMMAND} — deletes every key no validator has a schema for.`,\n ),\n ]);\n new RepositoryLayoutRepair().run(() => new RepositoryLayout().assertCurrent(root));\n const declarations = this.files.declarations(raw.rulePacks, root);\n const policy = this.files.resolve(root, this.files.select(root, declarations));\n new PolicyTracking().check(root, declarations);\n return this.loaded(\n configPath,\n raw.commands,\n raw.excludePaths as string[],\n raw['match-rules'] as MatchRuleConfig[],\n policy,\n );\n }\n\n private loaded(\n configPath: string,\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n commandsRaw: unknown,\n excluded: readonly string[],\n matches: readonly MatchRuleConfig[],\n policy: PackPolicyFilesResult,\n ): LoadedConfig {\n const commands = buildCommandsConfig(commandsRaw),\n values = new WebpiecesRulesConfig();\n const resolved = new Map<string, ResolvedRuleConfig>();\n for (const id of policy.registry.ruleIds()) {\n const explicit = policy.values[id];\n values[id] = explicit;\n const options = Object.assign(\n new ConfigObject(),\n policy.registry.optionalTuningFor(id),\n explicit,\n );\n resolved.set(id, new ResolvedRuleConfig(options));\n }\n return new LoadedConfig(\n new ResolvedConfig(resolved, new Set(policy.registry.ruleIds()), configPath),\n values,\n commands,\n commands.prGate,\n new ExcludePaths([...excluded]),\n matches,\n configPath,\n policy.registry,\n policy,\n );\n }\n\n private empty(): LoadedConfig {\n const commands = buildCommandsConfig(undefined);\n return new LoadedConfig(\n new ResolvedConfig(new Map(), new Set(), null),\n new WebpiecesRulesConfig(),\n commands,\n commands.prGate,\n new ExcludePaths([]),\n [],\n null,\n new RulePackRegistry([]),\n null,\n );\n }\n}\n\nconst configLoaderSvc = new ConfigLoader(new ConfigFile(), new PackPolicyFiles());\n\n/** Public function entry point and injected service use the same implementation. */\n// webpieces-disable no-function-outside-class -- canonical public loader function for CLI and executor entry points\nexport function loadAndValidate(cwd: string): LoadedConfig {\n return configLoaderSvc.loadAndValidate(cwd);\n}\n"]}
@@ -5,8 +5,7 @@
5
5
  * necessarily explains what the token protects, that the salt is committed, and therefore how to forge it —
6
6
  * i.e. it is a bypass how-to, sitting in the most-read file in the repo, defeating the only thing an
7
7
  * obscurity-grade mechanism has going for it. The rationale belongs in the webpieces source (pr-gate-config.ts
8
- * documents it in full for humans reading the tooling), never in consumer config. Every other `*Why` key
9
- * stays allowed; this is not a general ban on documenting your config.
8
+ * documents it in full for humans reading the tooling), never in consumer config. All other `*Why` keys are rejected by unknownKeyErrors; config prose lives in Markdown.
10
9
  */
11
10
  export declare function validateNoGateSaltRationale(s: Record<string, unknown>): string[];
12
11
  export declare const CHECKLIST_ENTRY_LABEL = "[pr-gate.checklists]";
@@ -14,8 +14,7 @@ const retired_config_keys_1 = require("./retired-config-keys");
14
14
  // The two `pr-gate` sub-sections whose validation is bulky enough to own a file: the review `checklists`
15
15
  // and the one rationale key that is rejected outright. Split out of validate-config.ts only for size;
16
16
  // loadAndValidate still reaches both through validatePrGateSection.
17
- // The `*Why` convention (buildCommandWhy, mergeModeWhy, gatesWhy…) is free-form rationale a consumer keeps
18
- // beside a field, and pr-gate tolerates any of them — EXCEPT this one. See validateNoGateSaltRationale.
17
+ // Inline rationale is retired. This salt-specific error also avoids publishing bypass details.
19
18
  const GATE_SALT_WHY = 'gateSaltWhy';
20
19
  /**
21
20
  * Reject `gateSaltWhy` outright, and say why, so the next validate on upgrade FORCES its removal.
@@ -24,8 +23,7 @@ const GATE_SALT_WHY = 'gateSaltWhy';
24
23
  * necessarily explains what the token protects, that the salt is committed, and therefore how to forge it —
25
24
  * i.e. it is a bypass how-to, sitting in the most-read file in the repo, defeating the only thing an
26
25
  * obscurity-grade mechanism has going for it. The rationale belongs in the webpieces source (pr-gate-config.ts
27
- * documents it in full for humans reading the tooling), never in consumer config. Every other `*Why` key
28
- * stays allowed; this is not a general ban on documenting your config.
26
+ * documents it in full for humans reading the tooling), never in consumer config. All other `*Why` keys are rejected by unknownKeyErrors; config prose lives in Markdown.
29
27
  */
30
28
  // webpieces-disable no-any-unknown -- the already-narrowed opaque pr-gate section; only key PRESENCE is read
31
29
  // webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file
@@ -290,7 +288,7 @@ function reviewerAgentsErrors(s) {
290
288
  }
291
289
  // The `landPr` block: what happens to the LOCAL branch once its PR is in main. Optional — omitted
292
290
  // means "archive-tag", which is deliberately the DEFAULT so a consumer gets the branch-accumulation
293
- // fix without editing config at all. `branchRetentionWhy` (and any other `*Why` sibling) is free-form
291
+ // fix without editing config at all. Repository-specific rationale belongs in Markdown, not free-form
294
292
  // rationale prose and is tolerated, per the repo's convention for documenting comment-less JSON.
295
293
  // webpieces-disable no-any-unknown -- `value` is the opaque consumer `landPr` value until narrowed here
296
294
  // webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file
@@ -1 +1 @@
1
- {"version":3,"file":"pr-gate-section-validators.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/pr-gate-section-validators.ts"],"names":[],"mappings":";;;AA6BA,kEASC;AAoCD,8DAIC;AAqID,8DAoCC;AA8DD,sDAkBC;AAmBD,4DA0BC;AApXD,sEAAgJ;AAChJ,+DAA2D;AAC3D,yDAG4B;AAC5B,2CAAmD;AACnD,+DAA2D;AAE3D,yGAAyG;AACzG,sGAAsG;AACtG,oEAAoE;AAEpE,2GAA2G;AAC3G,wGAAwG;AACxG,MAAM,aAAa,GAAG,aAAa,CAAC;AAEpC;;;;;;;;;GASG;AAC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VE_TAG, BRANCH_RETENTION_DELETE, BRANCH_RETENTION_KEEP } from '@webpieces/repo-workflow-core';\nimport { ChecklistValidator } from './checklist-validator';\nimport {\n ChecklistDefinition, DEFAULT_REVIEWER_AGENT_NAME, RawChecklistItem, REVIEWER_AGENTS_PLACEHOLDER,\n ReviewerAgentPolicy, toChecklist,\n} from './checklist-config';\nimport { UPGRADE_SHIM_COMMAND } from './constants';\nimport { retiredKeyErrorsIn } from './retired-config-keys';\n\n// The two `pr-gate` sub-sections whose validation is bulky enough to own a file: the review `checklists`\n// and the one rationale key that is rejected outright. Split out of validate-config.ts only for size;\n// loadAndValidate still reaches both through validatePrGateSection.\n\n// The `*Why` convention (buildCommandWhy, mergeModeWhy, gatesWhy…) is free-form rationale a consumer keeps\n// beside a field, and pr-gate tolerates any of them — EXCEPT this one. See validateNoGateSaltRationale.\nconst GATE_SALT_WHY = 'gateSaltWhy';\n\n/**\n * Reject `gateSaltWhy` outright, and say why, so the next validate on upgrade FORCES its removal.\n *\n * webpieces.config.json is one of the first files a coding agent reads. A rationale note next to `gateSalt`\n * necessarily explains what the token protects, that the salt is committed, and therefore how to forge it —\n * i.e. it is a bypass how-to, sitting in the most-read file in the repo, defeating the only thing an\n * obscurity-grade mechanism has going for it. The rationale belongs in the webpieces source (pr-gate-config.ts\n * documents it in full for humans reading the tooling), never in consumer config. Every other `*Why` key\n * stays allowed; this is not a general ban on documenting your config.\n */\n// webpieces-disable no-any-unknown -- the already-narrowed opaque pr-gate section; only key PRESENCE is read\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nexport function validateNoGateSaltRationale(s: Record<string, unknown>): string[] {\n if (!(GATE_SALT_WHY in s)) return [];\n return [\n `[pr-gate] DELETE the \"${GATE_SALT_WHY}\" key from webpieces.config.json. It is a rationale note next to ` +\n `\"gateSalt\", which means it spells out what the gate token protects and that the salt is committed — a ` +\n `bypass how-to in the file a coding agent reads first. The mechanism is obscurity-grade; documenting it ` +\n `here removes the obscurity. Nothing else needs changing: the reasoning is already documented in the ` +\n `webpieces source (PrGateConfig.gateSalt) for humans reading the tooling.`,\n ];\n}\n\nconst CHECKLIST_EXAMPLE = (\n 'Example:\\n' +\n ' \"checklists\": [\\n' +\n ' { \"id\": \"db-migrations\",\\n' +\n ' \"doc\": \".claude/review/db-migrations.md\",\\n' +\n ' \"patterns\": [\"**/migrations/**\", \"**/*.sql\"],\\n' +\n ' \"required\": true }\\n' +\n ' ]\\n' +\n ' \"id\" names the checklist and keys its review-round<N>-<id>.json. Every checklist is reviewed by the\\n' +\n ' webpieces-reviewer agent (or your own: \"overrideReviewerAgent\": true + \"reviewerAgentName\"), against\\n' +\n ' its own \"doc\" (REQUIRED, REPO-relative). Omit \"patterns\" (or use []) to run on every PR.\\n' +\n ' \"required\" is MANDATORY on every entry: true blocks the PR until the reviewer passes; false makes\\n' +\n ' it an OPTIONAL review the human is offered and may decline (but if they DO run it, a red verdict\\n' +\n ' still blocks).'\n);\n\n// The label every RETIRED checklist-entry key is filed under in RETIRED_CONFIG_KEYS.\nexport const CHECKLIST_ENTRY_LABEL = '[pr-gate.checklists]';\n\n/**\n * The `checklists` section of a pr-gate config: an ARRAY of { id, doc, patterns?, required }, and nothing else.\n *\n * The previous `{ \"doc\": \"...\" }` shape — which hid the same array in a `<!-- webpieces:checklists -->` HTML\n * comment inside a markdown doc — is REMOVED, not deprecated. It is rejected with the exact edit to make.\n * There is deliberately no back-compat branch: two accepted shapes means two code paths, two doc-resolution\n * rules and two sets of error messages to keep honest forever, while the migration itself is a mechanical\n * config edit that the coding agent reading this error applies in one pass. A hard failure naming the fix is\n * cheaper than permanent duality.\n *\n * Exported so the isolated validate-checklist-docs target reuses it. `repoRoot` (when known) lets the doc\n * existence checks run.\n */\n// webpieces-disable no-any-unknown -- `value` is opaque consumer JSON until narrowed below\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nexport function validateChecklistsSection(value: unknown, repoRoot?: string): string[] {\n if (Array.isArray(value)) return validateChecklistArray(value, repoRoot);\n if (typeof value === 'object' && value !== null && 'doc' in value) return [legacyManifestError(value)];\n return [`[pr-gate] \"checklists\" must be an ARRAY of { \"id\", \"doc\", \"patterns\"?, \"required\" }. ${CHECKLIST_EXAMPLE}`];\n}\n\n/**\n * The migration message for the removed `{ doc }` manifest shape. It names the doc the consumer pointed at,\n * because that is the file holding the array they must move, and spells out the one non-obvious part of the\n * move: entry `doc` paths used to resolve relative to that manifest doc and are now REPO-relative.\n */\n// webpieces-disable no-any-unknown -- narrowing the opaque checklists section to read the old `doc` key\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nfunction legacyManifestError(value: object): string {\n const doc = (value as Record<string, unknown>)['doc'];\n const docRel = typeof doc === 'string' && doc.trim() !== '' ? doc : '<your review index doc>';\n return (\n `[pr-gate] \"checklists\" is the REMOVED { \"doc\": \"${docRel}\" } shape. The checklist array no longer lives in\\n` +\n ` an HTML comment inside a markdown doc — put it directly in webpieces.config.json:\\n` +\n ` 1. Open \"${docRel}\" and copy the JSON array out of its <!-- webpieces:checklists [...] --> comment.\\n` +\n ` 2. Replace \"checklists\": { \"doc\": \"${docRel}\" } with \"checklists\": <that array>.\\n` +\n ` 3. Rewrite each entry's \"doc\" to be REPO-relative — they used to resolve relative to\\n` +\n ` \"${docRel}\", so a bare \"db-migrations.md\" becomes e.g. \".claude/review/db-migrations.md\".\\n` +\n ` 4. Delete the <!-- webpieces:checklists ... --> comment from \"${docRel}\"; keep the prose.\\n` +\n ` ${CHECKLIST_EXAMPLE}`\n );\n}\n\n/**\n * `required` is MANDATORY on every checklist entry — omitting it is an error, never a default.\n *\n * The error names the entry's own id, because that is what the consumer recognizes in a twelve-entry\n * array; `checklists[7]` alone means counting braces. It also states BOTH edits, because the whole point of\n * the key is that the answer differs per checklist and only the consumer knows which.\n *\n * Why a hard rejection instead of `?? true`: an accepted shape is never migrated. Defaulting to true\n * silently keeps the all-blocking behavior this key exists to relieve, and every consumer that would have\n * benefited stays on the old behavior forever without ever being told the dial exists. Defaulting to false\n * is worse — it would silently DOWNGRADE a live review gate on upgrade. Per CLAUDE.md the reader of this\n * message is a coding agent, so the migration is one mechanical pass.\n */\n// webpieces-disable no-any-unknown -- one opaque checklist entry, narrowed by the typeof guards here\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nfunction requiredKeyErrors(e: Record<string, unknown>, i: number): string[] {\n const name = typeof e['id'] === 'string' && e['id'].trim() !== '' ? ` (\"${e['id']}\")` : '';\n if (e['required'] === undefined) {\n return [\n `[pr-gate] checklists[${i}]${name} is missing \"required\". Every checklist must state one — there is\\n` +\n ` no default, in either direction.\\n` +\n ` \"required\": true → BLOCKING. wp-finish-upsert-pr refuses the PR until this reviewer passes.\\n` +\n ` This is what every checklist did before this key existed.\\n` +\n ` \"required\": false → OPTIONAL. When it matches the diff, wp-review-upsert-pr offers it and the\\n` +\n ` human may decline it. If they DO run it, a red verdict still blocks.\\n` +\n ` ${CHECKLIST_EXAMPLE}`,\n ];\n }\n if (typeof e['required'] !== 'boolean') {\n return [`[pr-gate] checklists[${i}]${name}.required must be a boolean (true = blocking, false = optional) — not a string or number.`];\n }\n return [];\n}\n\n// Structurally check ONE entry — a bad `patterns` or a non-string `doc` is a config-file typo and deserves a\n// `checklists[i]` message. A RETIRED key (the per-entry `subagent`) is reported with its migration edit.\n// webpieces-disable no-any-unknown -- one opaque checklist entry, narrowed per-field below\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nfunction checklistEntryErrors(e: Record<string, unknown>, i: number): string[] {\n const errors = retiredKeyErrorsIn(e, CHECKLIST_ENTRY_LABEL).map((m: string): string => `checklists[${i}] ${m}`);\n if (e['id'] !== undefined && typeof e['id'] !== 'string') {\n errors.push(`[pr-gate] checklists[${i}].id must be a string — the checklist's name; it keys review-round<N>-<id>.json.`);\n }\n if (e['doc'] !== undefined && typeof e['doc'] !== 'string') {\n errors.push(`[pr-gate] checklists[${i}].doc must be a string — the REPO-relative path to the checklist's guidance doc.`);\n }\n // webpieces-disable no-any-unknown -- opaque array element, narrowed by the typeof guard\n if (e['patterns'] !== undefined && !(Array.isArray(e['patterns']) && e['patterns'].every((p: unknown): boolean => typeof p === 'string'))) {\n errors.push(`[pr-gate] checklists[${i}].patterns must be a string[] of path globs (omit or [] to run on every PR).`);\n }\n errors.push(...requiredKeyErrors(e, i));\n return errors;\n}\n\n// Structurally check each entry, then hand the narrowed defs to ChecklistValidator for the id rules and the\n// checks only the filesystem can answer (the guidance doc exists). The reviewer agent itself is repo-wide\n// and is validated once, beside `overrideReviewerAgent` / `reviewerAgentName`, by validateReviewerAgentKeys.\n// webpieces-disable no-any-unknown -- opaque consumer JSON entries, narrowed per-field below\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nfunction validateChecklistArray(value: readonly unknown[], repoRoot?: string): string[] {\n const errors: string[] = [];\n const items: RawChecklistItem[] = [];\n // webpieces-disable no-any-unknown -- each array entry is opaque consumer JSON, narrowed field-by-field below\n value.forEach((entry: unknown, i: number): void => {\n if (typeof entry !== 'object' || entry === null || Array.isArray(entry)) {\n errors.push(`[pr-gate] checklists[${i}] must be an object { \"id\", \"doc\", \"patterns\"?, \"required\" }.`);\n return;\n }\n // webpieces-disable no-any-unknown -- narrowing one opaque checklist entry\n const e = entry as Record<string, unknown>;\n errors.push(...checklistEntryErrors(e, i));\n // Only the fields that passed their type check reach toChecklist — the wrong-typed ones already\n // have their own error above, and must not crash the id/doc checks below.\n items.push({\n id: typeof e['id'] === 'string' ? e['id'] : undefined,\n doc: typeof e['doc'] === 'string' ? e['doc'] : undefined,\n required: e['required'] === true,\n });\n });\n // The reviewer policy plays no part in these checks (ids and docs), so a placeholder is bound here.\n const placeholder = new ReviewerAgentPolicy('', REVIEWER_AGENTS_PLACEHOLDER);\n const defs = items.map((item: RawChecklistItem): ChecklistDefinition => toChecklist(item, placeholder));\n return [...errors, ...new ChecklistValidator().validate(repoRoot, defs)];\n}\n\nexport const REVIEWER_AGENT_NAME_KEY = 'reviewerAgentName';\nexport const OVERRIDE_REVIEWER_AGENT_KEY = 'overrideReviewerAgent';\nexport const REVIEWER_AGENTS_KEY = 'reviewerAgents';\nexport const MAX_REVIEWER_ROUNDS_KEY = 'maxReviewerRounds';\n\n/**\n * `overrideReviewerAgent` (optional boolean, absent == false), `reviewerAgentName` (only with the override)\n * and `reviewerAgents` (required nonnegative integer; zero disables reviewer-agent reviews).\n *\n * The reviewer agent defaults to {@link DEFAULT_REVIEWER_AGENT_NAME} — the generic reviewer webpieces ships\n * and manages — so a new repo writes NOTHING here (issue #947). Replacing it changes how every PR is\n * reviewed, so it must be said out loud with `\"overrideReviewerAgent\": true` (greppable) AND a\n * `reviewerAgentName`. A name WITHOUT the override is rejected rather than silently ignored: a key that looks\n * meaningful but controls nothing is a second spelling of a decision (.claude/rules/no-backwards-compat.md).\n *\n * `reviewerAgents` is REQUIRED while the gate is active, for the same reason `required` and `mergeMode` have\n * no default: it sets the PRICE of every review round, and a price nobody chose is the one that stops the\n * gate being run. It used to be optional, and absent meant one SEPARATE subagent per checklist — so a repo\n * with four required checklists charged a one-line typo fix four full reviewer spawns re-reading the same\n * diff, silently, having never been asked. The absent branch is GONE rather than kept as a fallback: an\n * accepted shape is never migrated, and the number is the whole decision the key exists to record.\n */\n// webpieces-disable no-any-unknown -- the already-narrowed opaque pr-gate section; three keys are read\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nexport function validateReviewerAgentKeys(s: Record<string, unknown>, repoRoot?: string): string[] {\n const errors: string[] = [];\n const override = s[OVERRIDE_REVIEWER_AGENT_KEY];\n const hasName = REVIEWER_AGENT_NAME_KEY in s;\n const name = s[REVIEWER_AGENT_NAME_KEY];\n const named = typeof name === 'string' && name.trim() !== '';\n if (OVERRIDE_REVIEWER_AGENT_KEY in s && typeof override !== 'boolean') {\n errors.push(\n `[pr-gate] \"${OVERRIDE_REVIEWER_AGENT_KEY}\" = ${JSON.stringify(override)} is not valid — it must be true or ` +\n `false. Delete the key to use the webpieces reviewer (${DEFAULT_REVIEWER_AGENT_NAME}); set it to true, together ` +\n `with \"${REVIEWER_AGENT_NAME_KEY}\", to use an agent of your own.`);\n } else if (override === true && !named) {\n errors.push(\n `[pr-gate] \"${OVERRIDE_REVIEWER_AGENT_KEY}\": true needs \"${REVIEWER_AGENT_NAME_KEY}\" — add the agent type every ` +\n `reviewer subagent is spawned as (its .claude/agents/<name>.md must exist) to commands.pr-gate in ` +\n `webpieces.config.json:\\n` +\n ` \"${REVIEWER_AGENT_NAME_KEY}\": \"my-reviewer\",\\n` +\n ` Or delete \"${OVERRIDE_REVIEWER_AGENT_KEY}\" to use the webpieces reviewer (${DEFAULT_REVIEWER_AGENT_NAME}).`);\n } else if (override !== true && hasName) {\n errors.push(\n `[pr-gate] \"${REVIEWER_AGENT_NAME_KEY}\" is set but \"${OVERRIDE_REVIEWER_AGENT_KEY}\" is not true, so it would be ` +\n `ignored. The reviewer agent defaults to ${DEFAULT_REVIEWER_AGENT_NAME} (.claude/agents/${DEFAULT_REVIEWER_AGENT_NAME}.md, ` +\n `written by \\`${UPGRADE_SHIM_COMMAND}\\`). Either:\\n` +\n ` • remove \"${REVIEWER_AGENT_NAME_KEY}\" from commands.pr-gate in webpieces.config.json to use that default, or\\n` +\n ` • set \"${OVERRIDE_REVIEWER_AGENT_KEY}\": true beside it to review with your own agent.`);\n }\n const agentKeysValid = errors.length === 0;\n errors.push(...reviewerAgentsErrors(s));\n errors.push(...maxReviewerRoundsErrors(s));\n // A disabled project never spawns this agent, so requiring its file would make `0` an incomplete opt-out.\n if (repoRoot !== undefined && agentKeysValid && s[REVIEWER_AGENTS_KEY] !== 0) {\n const agentName = override === true ? (name as string).trim() : DEFAULT_REVIEWER_AGENT_NAME;\n errors.push(...new ChecklistValidator().validateReviewerAgent(\n repoRoot, new ReviewerAgentPolicy(agentName, REVIEWER_AGENTS_PLACEHOLDER)));\n }\n return errors;\n}\n\n/** `maxReviewerRounds`: required positive integer. Zero cannot describe an enabled or disabled policy. */\n// webpieces-disable no-any-unknown -- the already-narrowed opaque pr-gate section; one key is read\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nfunction maxReviewerRoundsErrors(s: Record<string, unknown>): string[] {\n const max = s[MAX_REVIEWER_ROUNDS_KEY];\n if (!(MAX_REVIEWER_ROUNDS_KEY in s)) {\n return [\n `[pr-gate] Missing required field \"${MAX_REVIEWER_ROUNDS_KEY}\" — the maximum number of complete ` +\n `reviewer cycles one PR review state may start. Add this line beside \"${REVIEWER_AGENTS_KEY}\":\\n` +\n ` \"${MAX_REVIEWER_ROUNDS_KEY}\": 2,\\n` +\n ' 1 = one full review followed by author remediation with no re-review. 2 = one full review plus ' +\n 'one remediation-only re-review. There is deliberately no default: this repository owns the review budget.',\n ];\n }\n if (!(typeof max === 'number' && Number.isInteger(max) && max > 0)) {\n return [\n `[pr-gate] \"${MAX_REVIEWER_ROUNDS_KEY}\" = ${JSON.stringify(max)} is not valid — it must be a positive integer.`,\n ];\n }\n return [];\n}\n\n/**\n * `reviewerAgents`: present, and a nonnegative integer. Missing and wrong-typed get DIFFERENT messages — the\n * missing one has to teach a reader what the number means and what to weigh when picking it, because they\n * have never seen the key; the wrong-typed one only has to name the constraint they just broke.\n */\n// webpieces-disable no-any-unknown -- the already-narrowed opaque pr-gate section; one key is read\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nfunction reviewerAgentsErrors(s: Record<string, unknown>): string[] {\n const max = s[REVIEWER_AGENTS_KEY];\n if (!(REVIEWER_AGENTS_KEY in s)) {\n return [\n `[pr-gate] Missing required field \"${REVIEWER_AGENTS_KEY}\" — the MOST reviewer subagents one review ` +\n `round may use. Add this line to commands.pr-gate in webpieces.config.json:\\n` +\n ` \"${REVIEWER_AGENTS_KEY}\": 1,\\n` +\n ` 0 = reviewer-agent reviews are disabled for this project while the build and PR gate stay active. ` +\n `1 = ONE subagent reviews every owed checklist (cheapest enabled setting; it is handed each checklist's ` +\n `instructions file and still writes one verdict file per checklist). A HIGHER number buys independent readers — ` +\n `set it to your checklist count for one subagent each — at that many times the tokens per PR. There is ` +\n `deliberately no default: this sets the price of every review round, and an unchosen price is what ` +\n `makes a gate expensive enough that people stop running it.`,\n ];\n }\n if (!(typeof max === 'number' && Number.isInteger(max) && max >= 0)) {\n return [\n `[pr-gate] \"${REVIEWER_AGENTS_KEY}\" = ${JSON.stringify(max)} is not valid — it must be a nonnegative integer: ` +\n `0 disables reviewer-agent reviews for this project while leaving the build and PR gate active; a positive ` +\n `value is the MOST reviewer subagents one review round may use, with owed checklists grouped across them.`,\n ];\n }\n return [];\n}\n\n// The `landPr` block: what happens to the LOCAL branch once its PR is in main. Optional — omitted\n// means \"archive-tag\", which is deliberately the DEFAULT so a consumer gets the branch-accumulation\n// fix without editing config at all. `branchRetentionWhy` (and any other `*Why` sibling) is free-form\n// rationale prose and is tolerated, per the repo's convention for documenting comment-less JSON.\n// webpieces-disable no-any-unknown -- `value` is the opaque consumer `landPr` value until narrowed here\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nexport function validateLandPrSection(value: unknown): string[] {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n return [`[pr-gate] \"landPr\" must be an object, e.g. { \"branchRetention\": \"${BRANCH_RETENTION_ARCHIVE_TAG}\" }.`];\n }\n // webpieces-disable no-any-unknown -- narrowing the opaque landPr object from consumer JSON\n const s = value as Record<string, unknown>;\n if (!('branchRetention' in s)) return [];\n const retention = s['branchRetention'];\n if (typeof retention === 'string' && BRANCH_RETENTIONS.includes(retention)) return [];\n return [\n `[pr-gate] \"landPr.branchRetention\" = \"${String(retention)}\" is not valid. ` +\n `Must be one of: ${BRANCH_RETENTIONS.join(', ')}.\\n` +\n ` \"${BRANCH_RETENTION_ARCHIVE_TAG}\" — (default) tag the branch tip as archive/<date>/<branch>, THEN delete it. The\\n` +\n ` history stays byte-identical and restorable, but the branch stops counting\\n` +\n ` toward the branch cap and cannot be committed onto by accident.\\n` +\n ` \"${BRANCH_RETENTION_DELETE}\" — delete outright; recoverable only from the reflog, which expires.\\n` +\n ` \"${BRANCH_RETENTION_KEEP}\" — do not delete. Branches then accumulate until branch-creation-guard trips.`,\n ];\n}\n\n// A git ref COMPONENT this flow is willing to build a ref name out of. Deliberately much narrower than\n// git's own check-ref-format: these two values are concatenated into a ref that a command then\n// force-pushes, so anything that could be read as a flag, a path escape, or a glob is rejected outright\n// rather than trusted to `git push` argument order.\nconst REF_COMPONENT = /^[A-Za-z0-9][A-Za-z0-9._/-]*$/;\n\n/**\n * Validate the optional `pr-gate.devDeploy` block — where `wp-push-dev` publishes the disposable copy of\n * a feature branch, and which ref is the shared dev branch itself. Absent ⇒ `dev-include` / `dev`.\n *\n * `devBranch` must NOT contain a slash and must not sit inside `branchNamespace`: the whole point of the\n * namespace is that the composed dev branch is written by CI and the copies are written by developers, so\n * a config where one contains the other makes `--list` enumerate the deploy branch and makes the\n * \"refused as a source branch\" check ambiguous.\n */\n// webpieces-disable no-any-unknown -- `value` is the opaque consumer devDeploy value until narrowed here\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nexport function validateDevDeploySection(value: unknown): string[] {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n return ['[pr-gate] \"devDeploy\" must be an object, e.g. { \"branchNamespace\": \"dev-include\", \"devBranch\": \"dev\" }.'];\n }\n // webpieces-disable no-any-unknown -- narrowing the opaque devDeploy object from consumer JSON\n const s = value as Record<string, unknown>;\n const errors: string[] = [];\n errors.push(...validateRefComponent(s, 'branchNamespace', 'dev-include'));\n errors.push(...validateRefComponent(s, 'devBranch', 'dev'));\n if (errors.length > 0) return errors;\n\n const namespace = typeof s['branchNamespace'] === 'string' ? s['branchNamespace'].trim() : 'dev-include';\n const devBranch = typeof s['devBranch'] === 'string' ? s['devBranch'].trim() : 'dev';\n if (devBranch.includes('/')) {\n errors.push(\n `[pr-gate] \"devDeploy.devBranch\" = \"${devBranch}\" must be a single ref name with no \"/\" — it is the ` +\n `branch your CI composes and deploys, not a namespace.`);\n }\n if (devBranch === namespace || devBranch.startsWith(`${namespace}/`) || namespace.startsWith(`${devBranch}/`)) {\n errors.push(\n `[pr-gate] \"devDeploy.devBranch\" (\"${devBranch}\") and \"devDeploy.branchNamespace\" (\"${namespace}\") must not ` +\n `contain one another. The namespace holds the DISPOSABLE per-developer copies (written by wp-push-dev); ` +\n `devBranch is the COMPOSED branch your CI rebuilds from origin/main. Overlapping them makes wp-push-dev ` +\n `--list enumerate the deploy branch and makes \"refused as a source branch\" ambiguous.`);\n }\n return errors;\n}\n\n// One `devDeploy` string field: present ⇒ must be a non-empty, ref-safe string. Absent ⇒ the default.\n// webpieces-disable no-any-unknown -- the already-narrowed opaque devDeploy object\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nfunction validateRefComponent(s: Record<string, unknown>, key: string, example: string): string[] {\n if (!(key in s)) return [];\n const raw = s[key];\n if (typeof raw !== 'string' || raw.trim() === '') {\n return [`[pr-gate] \"devDeploy.${key}\" must be a non-empty string, e.g. \"${example}\". Omit the key for the \"${example}\" default.`];\n }\n if (!REF_COMPONENT.test(raw.trim())) {\n return [\n `[pr-gate] \"devDeploy.${key}\" = \"${raw}\" is not a usable git ref name. Use letters, digits, \".\", \"_\", ` +\n `\"-\" and \"/\" only, starting with a letter or digit (e.g. \"${example}\").`,\n ];\n }\n return [];\n}\n"]}
1
+ {"version":3,"file":"pr-gate-section-validators.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/pr-gate-section-validators.ts"],"names":[],"mappings":";;;AA2BA,kEASC;AAoCD,8DAIC;AAqID,8DAoCC;AA8DD,sDAkBC;AAmBD,4DA0BC;AAlXD,sEAAgJ;AAChJ,+DAA2D;AAC3D,yDAG4B;AAC5B,2CAAmD;AACnD,+DAA2D;AAE3D,yGAAyG;AACzG,sGAAsG;AACtG,oEAAoE;AAEpE,+FAA+F;AAC/F,MAAM,aAAa,GAAG,aAAa,CAAC;AAEpC;;;;;;;;GAQG;AACH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E_TAG, BRANCH_RETENTION_DELETE, BRANCH_RETENTION_KEEP } from '@webpieces/repo-workflow-core';\nimport { ChecklistValidator } from './checklist-validator';\nimport {\n ChecklistDefinition, DEFAULT_REVIEWER_AGENT_NAME, RawChecklistItem, REVIEWER_AGENTS_PLACEHOLDER,\n ReviewerAgentPolicy, toChecklist,\n} from './checklist-config';\nimport { UPGRADE_SHIM_COMMAND } from './constants';\nimport { retiredKeyErrorsIn } from './retired-config-keys';\n\n// The two `pr-gate` sub-sections whose validation is bulky enough to own a file: the review `checklists`\n// and the one rationale key that is rejected outright. Split out of validate-config.ts only for size;\n// loadAndValidate still reaches both through validatePrGateSection.\n\n// Inline rationale is retired. This salt-specific error also avoids publishing bypass details.\nconst GATE_SALT_WHY = 'gateSaltWhy';\n\n/**\n * Reject `gateSaltWhy` outright, and say why, so the next validate on upgrade FORCES its removal.\n *\n * webpieces.config.json is one of the first files a coding agent reads. A rationale note next to `gateSalt`\n * necessarily explains what the token protects, that the salt is committed, and therefore how to forge it —\n * i.e. it is a bypass how-to, sitting in the most-read file in the repo, defeating the only thing an\n * obscurity-grade mechanism has going for it. The rationale belongs in the webpieces source (pr-gate-config.ts\n * documents it in full for humans reading the tooling), never in consumer config. All other `*Why` keys are rejected by unknownKeyErrors; config prose lives in Markdown.\n */\n// webpieces-disable no-any-unknown -- the already-narrowed opaque pr-gate section; only key PRESENCE is read\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nexport function validateNoGateSaltRationale(s: Record<string, unknown>): string[] {\n if (!(GATE_SALT_WHY in s)) return [];\n return [\n `[pr-gate] DELETE the \"${GATE_SALT_WHY}\" key from webpieces.config.json. It is a rationale note next to ` +\n `\"gateSalt\", which means it spells out what the gate token protects and that the salt is committed — a ` +\n `bypass how-to in the file a coding agent reads first. The mechanism is obscurity-grade; documenting it ` +\n `here removes the obscurity. Nothing else needs changing: the reasoning is already documented in the ` +\n `webpieces source (PrGateConfig.gateSalt) for humans reading the tooling.`,\n ];\n}\n\nconst CHECKLIST_EXAMPLE = (\n 'Example:\\n' +\n ' \"checklists\": [\\n' +\n ' { \"id\": \"db-migrations\",\\n' +\n ' \"doc\": \".claude/review/db-migrations.md\",\\n' +\n ' \"patterns\": [\"**/migrations/**\", \"**/*.sql\"],\\n' +\n ' \"required\": true }\\n' +\n ' ]\\n' +\n ' \"id\" names the checklist and keys its review-round<N>-<id>.json. Every checklist is reviewed by the\\n' +\n ' webpieces-reviewer agent (or your own: \"overrideReviewerAgent\": true + \"reviewerAgentName\"), against\\n' +\n ' its own \"doc\" (REQUIRED, REPO-relative). Omit \"patterns\" (or use []) to run on every PR.\\n' +\n ' \"required\" is MANDATORY on every entry: true blocks the PR until the reviewer passes; false makes\\n' +\n ' it an OPTIONAL review the human is offered and may decline (but if they DO run it, a red verdict\\n' +\n ' still blocks).'\n);\n\n// The label every RETIRED checklist-entry key is filed under in RETIRED_CONFIG_KEYS.\nexport const CHECKLIST_ENTRY_LABEL = '[pr-gate.checklists]';\n\n/**\n * The `checklists` section of a pr-gate config: an ARRAY of { id, doc, patterns?, required }, and nothing else.\n *\n * The previous `{ \"doc\": \"...\" }` shape — which hid the same array in a `<!-- webpieces:checklists -->` HTML\n * comment inside a markdown doc — is REMOVED, not deprecated. It is rejected with the exact edit to make.\n * There is deliberately no back-compat branch: two accepted shapes means two code paths, two doc-resolution\n * rules and two sets of error messages to keep honest forever, while the migration itself is a mechanical\n * config edit that the coding agent reading this error applies in one pass. A hard failure naming the fix is\n * cheaper than permanent duality.\n *\n * Exported so the isolated validate-checklist-docs target reuses it. `repoRoot` (when known) lets the doc\n * existence checks run.\n */\n// webpieces-disable no-any-unknown -- `value` is opaque consumer JSON until narrowed below\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nexport function validateChecklistsSection(value: unknown, repoRoot?: string): string[] {\n if (Array.isArray(value)) return validateChecklistArray(value, repoRoot);\n if (typeof value === 'object' && value !== null && 'doc' in value) return [legacyManifestError(value)];\n return [`[pr-gate] \"checklists\" must be an ARRAY of { \"id\", \"doc\", \"patterns\"?, \"required\" }. ${CHECKLIST_EXAMPLE}`];\n}\n\n/**\n * The migration message for the removed `{ doc }` manifest shape. It names the doc the consumer pointed at,\n * because that is the file holding the array they must move, and spells out the one non-obvious part of the\n * move: entry `doc` paths used to resolve relative to that manifest doc and are now REPO-relative.\n */\n// webpieces-disable no-any-unknown -- narrowing the opaque checklists section to read the old `doc` key\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nfunction legacyManifestError(value: object): string {\n const doc = (value as Record<string, unknown>)['doc'];\n const docRel = typeof doc === 'string' && doc.trim() !== '' ? doc : '<your review index doc>';\n return (\n `[pr-gate] \"checklists\" is the REMOVED { \"doc\": \"${docRel}\" } shape. The checklist array no longer lives in\\n` +\n ` an HTML comment inside a markdown doc — put it directly in webpieces.config.json:\\n` +\n ` 1. Open \"${docRel}\" and copy the JSON array out of its <!-- webpieces:checklists [...] --> comment.\\n` +\n ` 2. Replace \"checklists\": { \"doc\": \"${docRel}\" } with \"checklists\": <that array>.\\n` +\n ` 3. Rewrite each entry's \"doc\" to be REPO-relative — they used to resolve relative to\\n` +\n ` \"${docRel}\", so a bare \"db-migrations.md\" becomes e.g. \".claude/review/db-migrations.md\".\\n` +\n ` 4. Delete the <!-- webpieces:checklists ... --> comment from \"${docRel}\"; keep the prose.\\n` +\n ` ${CHECKLIST_EXAMPLE}`\n );\n}\n\n/**\n * `required` is MANDATORY on every checklist entry — omitting it is an error, never a default.\n *\n * The error names the entry's own id, because that is what the consumer recognizes in a twelve-entry\n * array; `checklists[7]` alone means counting braces. It also states BOTH edits, because the whole point of\n * the key is that the answer differs per checklist and only the consumer knows which.\n *\n * Why a hard rejection instead of `?? true`: an accepted shape is never migrated. Defaulting to true\n * silently keeps the all-blocking behavior this key exists to relieve, and every consumer that would have\n * benefited stays on the old behavior forever without ever being told the dial exists. Defaulting to false\n * is worse — it would silently DOWNGRADE a live review gate on upgrade. Per CLAUDE.md the reader of this\n * message is a coding agent, so the migration is one mechanical pass.\n */\n// webpieces-disable no-any-unknown -- one opaque checklist entry, narrowed by the typeof guards here\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nfunction requiredKeyErrors(e: Record<string, unknown>, i: number): string[] {\n const name = typeof e['id'] === 'string' && e['id'].trim() !== '' ? ` (\"${e['id']}\")` : '';\n if (e['required'] === undefined) {\n return [\n `[pr-gate] checklists[${i}]${name} is missing \"required\". Every checklist must state one — there is\\n` +\n ` no default, in either direction.\\n` +\n ` \"required\": true → BLOCKING. wp-finish-upsert-pr refuses the PR until this reviewer passes.\\n` +\n ` This is what every checklist did before this key existed.\\n` +\n ` \"required\": false → OPTIONAL. When it matches the diff, wp-review-upsert-pr offers it and the\\n` +\n ` human may decline it. If they DO run it, a red verdict still blocks.\\n` +\n ` ${CHECKLIST_EXAMPLE}`,\n ];\n }\n if (typeof e['required'] !== 'boolean') {\n return [`[pr-gate] checklists[${i}]${name}.required must be a boolean (true = blocking, false = optional) — not a string or number.`];\n }\n return [];\n}\n\n// Structurally check ONE entry — a bad `patterns` or a non-string `doc` is a config-file typo and deserves a\n// `checklists[i]` message. A RETIRED key (the per-entry `subagent`) is reported with its migration edit.\n// webpieces-disable no-any-unknown -- one opaque checklist entry, narrowed per-field below\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nfunction checklistEntryErrors(e: Record<string, unknown>, i: number): string[] {\n const errors = retiredKeyErrorsIn(e, CHECKLIST_ENTRY_LABEL).map((m: string): string => `checklists[${i}] ${m}`);\n if (e['id'] !== undefined && typeof e['id'] !== 'string') {\n errors.push(`[pr-gate] checklists[${i}].id must be a string — the checklist's name; it keys review-round<N>-<id>.json.`);\n }\n if (e['doc'] !== undefined && typeof e['doc'] !== 'string') {\n errors.push(`[pr-gate] checklists[${i}].doc must be a string — the REPO-relative path to the checklist's guidance doc.`);\n }\n // webpieces-disable no-any-unknown -- opaque array element, narrowed by the typeof guard\n if (e['patterns'] !== undefined && !(Array.isArray(e['patterns']) && e['patterns'].every((p: unknown): boolean => typeof p === 'string'))) {\n errors.push(`[pr-gate] checklists[${i}].patterns must be a string[] of path globs (omit or [] to run on every PR).`);\n }\n errors.push(...requiredKeyErrors(e, i));\n return errors;\n}\n\n// Structurally check each entry, then hand the narrowed defs to ChecklistValidator for the id rules and the\n// checks only the filesystem can answer (the guidance doc exists). The reviewer agent itself is repo-wide\n// and is validated once, beside `overrideReviewerAgent` / `reviewerAgentName`, by validateReviewerAgentKeys.\n// webpieces-disable no-any-unknown -- opaque consumer JSON entries, narrowed per-field below\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nfunction validateChecklistArray(value: readonly unknown[], repoRoot?: string): string[] {\n const errors: string[] = [];\n const items: RawChecklistItem[] = [];\n // webpieces-disable no-any-unknown -- each array entry is opaque consumer JSON, narrowed field-by-field below\n value.forEach((entry: unknown, i: number): void => {\n if (typeof entry !== 'object' || entry === null || Array.isArray(entry)) {\n errors.push(`[pr-gate] checklists[${i}] must be an object { \"id\", \"doc\", \"patterns\"?, \"required\" }.`);\n return;\n }\n // webpieces-disable no-any-unknown -- narrowing one opaque checklist entry\n const e = entry as Record<string, unknown>;\n errors.push(...checklistEntryErrors(e, i));\n // Only the fields that passed their type check reach toChecklist — the wrong-typed ones already\n // have their own error above, and must not crash the id/doc checks below.\n items.push({\n id: typeof e['id'] === 'string' ? e['id'] : undefined,\n doc: typeof e['doc'] === 'string' ? e['doc'] : undefined,\n required: e['required'] === true,\n });\n });\n // The reviewer policy plays no part in these checks (ids and docs), so a placeholder is bound here.\n const placeholder = new ReviewerAgentPolicy('', REVIEWER_AGENTS_PLACEHOLDER);\n const defs = items.map((item: RawChecklistItem): ChecklistDefinition => toChecklist(item, placeholder));\n return [...errors, ...new ChecklistValidator().validate(repoRoot, defs)];\n}\n\nexport const REVIEWER_AGENT_NAME_KEY = 'reviewerAgentName';\nexport const OVERRIDE_REVIEWER_AGENT_KEY = 'overrideReviewerAgent';\nexport const REVIEWER_AGENTS_KEY = 'reviewerAgents';\nexport const MAX_REVIEWER_ROUNDS_KEY = 'maxReviewerRounds';\n\n/**\n * `overrideReviewerAgent` (optional boolean, absent == false), `reviewerAgentName` (only with the override)\n * and `reviewerAgents` (required nonnegative integer; zero disables reviewer-agent reviews).\n *\n * The reviewer agent defaults to {@link DEFAULT_REVIEWER_AGENT_NAME} — the generic reviewer webpieces ships\n * and manages — so a new repo writes NOTHING here (issue #947). Replacing it changes how every PR is\n * reviewed, so it must be said out loud with `\"overrideReviewerAgent\": true` (greppable) AND a\n * `reviewerAgentName`. A name WITHOUT the override is rejected rather than silently ignored: a key that looks\n * meaningful but controls nothing is a second spelling of a decision (.claude/rules/no-backwards-compat.md).\n *\n * `reviewerAgents` is REQUIRED while the gate is active, for the same reason `required` and `mergeMode` have\n * no default: it sets the PRICE of every review round, and a price nobody chose is the one that stops the\n * gate being run. It used to be optional, and absent meant one SEPARATE subagent per checklist — so a repo\n * with four required checklists charged a one-line typo fix four full reviewer spawns re-reading the same\n * diff, silently, having never been asked. The absent branch is GONE rather than kept as a fallback: an\n * accepted shape is never migrated, and the number is the whole decision the key exists to record.\n */\n// webpieces-disable no-any-unknown -- the already-narrowed opaque pr-gate section; three keys are read\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nexport function validateReviewerAgentKeys(s: Record<string, unknown>, repoRoot?: string): string[] {\n const errors: string[] = [];\n const override = s[OVERRIDE_REVIEWER_AGENT_KEY];\n const hasName = REVIEWER_AGENT_NAME_KEY in s;\n const name = s[REVIEWER_AGENT_NAME_KEY];\n const named = typeof name === 'string' && name.trim() !== '';\n if (OVERRIDE_REVIEWER_AGENT_KEY in s && typeof override !== 'boolean') {\n errors.push(\n `[pr-gate] \"${OVERRIDE_REVIEWER_AGENT_KEY}\" = ${JSON.stringify(override)} is not valid — it must be true or ` +\n `false. Delete the key to use the webpieces reviewer (${DEFAULT_REVIEWER_AGENT_NAME}); set it to true, together ` +\n `with \"${REVIEWER_AGENT_NAME_KEY}\", to use an agent of your own.`);\n } else if (override === true && !named) {\n errors.push(\n `[pr-gate] \"${OVERRIDE_REVIEWER_AGENT_KEY}\": true needs \"${REVIEWER_AGENT_NAME_KEY}\" — add the agent type every ` +\n `reviewer subagent is spawned as (its .claude/agents/<name>.md must exist) to commands.pr-gate in ` +\n `webpieces.config.json:\\n` +\n ` \"${REVIEWER_AGENT_NAME_KEY}\": \"my-reviewer\",\\n` +\n ` Or delete \"${OVERRIDE_REVIEWER_AGENT_KEY}\" to use the webpieces reviewer (${DEFAULT_REVIEWER_AGENT_NAME}).`);\n } else if (override !== true && hasName) {\n errors.push(\n `[pr-gate] \"${REVIEWER_AGENT_NAME_KEY}\" is set but \"${OVERRIDE_REVIEWER_AGENT_KEY}\" is not true, so it would be ` +\n `ignored. The reviewer agent defaults to ${DEFAULT_REVIEWER_AGENT_NAME} (.claude/agents/${DEFAULT_REVIEWER_AGENT_NAME}.md, ` +\n `written by \\`${UPGRADE_SHIM_COMMAND}\\`). Either:\\n` +\n ` • remove \"${REVIEWER_AGENT_NAME_KEY}\" from commands.pr-gate in webpieces.config.json to use that default, or\\n` +\n ` • set \"${OVERRIDE_REVIEWER_AGENT_KEY}\": true beside it to review with your own agent.`);\n }\n const agentKeysValid = errors.length === 0;\n errors.push(...reviewerAgentsErrors(s));\n errors.push(...maxReviewerRoundsErrors(s));\n // A disabled project never spawns this agent, so requiring its file would make `0` an incomplete opt-out.\n if (repoRoot !== undefined && agentKeysValid && s[REVIEWER_AGENTS_KEY] !== 0) {\n const agentName = override === true ? (name as string).trim() : DEFAULT_REVIEWER_AGENT_NAME;\n errors.push(...new ChecklistValidator().validateReviewerAgent(\n repoRoot, new ReviewerAgentPolicy(agentName, REVIEWER_AGENTS_PLACEHOLDER)));\n }\n return errors;\n}\n\n/** `maxReviewerRounds`: required positive integer. Zero cannot describe an enabled or disabled policy. */\n// webpieces-disable no-any-unknown -- the already-narrowed opaque pr-gate section; one key is read\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nfunction maxReviewerRoundsErrors(s: Record<string, unknown>): string[] {\n const max = s[MAX_REVIEWER_ROUNDS_KEY];\n if (!(MAX_REVIEWER_ROUNDS_KEY in s)) {\n return [\n `[pr-gate] Missing required field \"${MAX_REVIEWER_ROUNDS_KEY}\" — the maximum number of complete ` +\n `reviewer cycles one PR review state may start. Add this line beside \"${REVIEWER_AGENTS_KEY}\":\\n` +\n ` \"${MAX_REVIEWER_ROUNDS_KEY}\": 2,\\n` +\n ' 1 = one full review followed by author remediation with no re-review. 2 = one full review plus ' +\n 'one remediation-only re-review. There is deliberately no default: this repository owns the review budget.',\n ];\n }\n if (!(typeof max === 'number' && Number.isInteger(max) && max > 0)) {\n return [\n `[pr-gate] \"${MAX_REVIEWER_ROUNDS_KEY}\" = ${JSON.stringify(max)} is not valid — it must be a positive integer.`,\n ];\n }\n return [];\n}\n\n/**\n * `reviewerAgents`: present, and a nonnegative integer. Missing and wrong-typed get DIFFERENT messages — the\n * missing one has to teach a reader what the number means and what to weigh when picking it, because they\n * have never seen the key; the wrong-typed one only has to name the constraint they just broke.\n */\n// webpieces-disable no-any-unknown -- the already-narrowed opaque pr-gate section; one key is read\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nfunction reviewerAgentsErrors(s: Record<string, unknown>): string[] {\n const max = s[REVIEWER_AGENTS_KEY];\n if (!(REVIEWER_AGENTS_KEY in s)) {\n return [\n `[pr-gate] Missing required field \"${REVIEWER_AGENTS_KEY}\" — the MOST reviewer subagents one review ` +\n `round may use. Add this line to commands.pr-gate in webpieces.config.json:\\n` +\n ` \"${REVIEWER_AGENTS_KEY}\": 1,\\n` +\n ` 0 = reviewer-agent reviews are disabled for this project while the build and PR gate stay active. ` +\n `1 = ONE subagent reviews every owed checklist (cheapest enabled setting; it is handed each checklist's ` +\n `instructions file and still writes one verdict file per checklist). A HIGHER number buys independent readers — ` +\n `set it to your checklist count for one subagent each — at that many times the tokens per PR. There is ` +\n `deliberately no default: this sets the price of every review round, and an unchosen price is what ` +\n `makes a gate expensive enough that people stop running it.`,\n ];\n }\n if (!(typeof max === 'number' && Number.isInteger(max) && max >= 0)) {\n return [\n `[pr-gate] \"${REVIEWER_AGENTS_KEY}\" = ${JSON.stringify(max)} is not valid — it must be a nonnegative integer: ` +\n `0 disables reviewer-agent reviews for this project while leaving the build and PR gate active; a positive ` +\n `value is the MOST reviewer subagents one review round may use, with owed checklists grouped across them.`,\n ];\n }\n return [];\n}\n\n// The `landPr` block: what happens to the LOCAL branch once its PR is in main. Optional — omitted\n// means \"archive-tag\", which is deliberately the DEFAULT so a consumer gets the branch-accumulation\n// fix without editing config at all. Repository-specific rationale belongs in Markdown, not free-form\n// rationale prose and is tolerated, per the repo's convention for documenting comment-less JSON.\n// webpieces-disable no-any-unknown -- `value` is the opaque consumer `landPr` value until narrowed here\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nexport function validateLandPrSection(value: unknown): string[] {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n return [`[pr-gate] \"landPr\" must be an object, e.g. { \"branchRetention\": \"${BRANCH_RETENTION_ARCHIVE_TAG}\" }.`];\n }\n // webpieces-disable no-any-unknown -- narrowing the opaque landPr object from consumer JSON\n const s = value as Record<string, unknown>;\n if (!('branchRetention' in s)) return [];\n const retention = s['branchRetention'];\n if (typeof retention === 'string' && BRANCH_RETENTIONS.includes(retention)) return [];\n return [\n `[pr-gate] \"landPr.branchRetention\" = \"${String(retention)}\" is not valid. ` +\n `Must be one of: ${BRANCH_RETENTIONS.join(', ')}.\\n` +\n ` \"${BRANCH_RETENTION_ARCHIVE_TAG}\" — (default) tag the branch tip as archive/<date>/<branch>, THEN delete it. The\\n` +\n ` history stays byte-identical and restorable, but the branch stops counting\\n` +\n ` toward the branch cap and cannot be committed onto by accident.\\n` +\n ` \"${BRANCH_RETENTION_DELETE}\" — delete outright; recoverable only from the reflog, which expires.\\n` +\n ` \"${BRANCH_RETENTION_KEEP}\" — do not delete. Branches then accumulate until branch-creation-guard trips.`,\n ];\n}\n\n// A git ref COMPONENT this flow is willing to build a ref name out of. Deliberately much narrower than\n// git's own check-ref-format: these two values are concatenated into a ref that a command then\n// force-pushes, so anything that could be read as a flag, a path escape, or a glob is rejected outright\n// rather than trusted to `git push` argument order.\nconst REF_COMPONENT = /^[A-Za-z0-9][A-Za-z0-9._/-]*$/;\n\n/**\n * Validate the optional `pr-gate.devDeploy` block — where `wp-push-dev` publishes the disposable copy of\n * a feature branch, and which ref is the shared dev branch itself. Absent ⇒ `dev-include` / `dev`.\n *\n * `devBranch` must NOT contain a slash and must not sit inside `branchNamespace`: the whole point of the\n * namespace is that the composed dev branch is written by CI and the copies are written by developers, so\n * a config where one contains the other makes `--list` enumerate the deploy branch and makes the\n * \"refused as a source branch\" check ambiguous.\n */\n// webpieces-disable no-any-unknown -- `value` is the opaque consumer devDeploy value until narrowed here\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nexport function validateDevDeploySection(value: unknown): string[] {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n return ['[pr-gate] \"devDeploy\" must be an object, e.g. { \"branchNamespace\": \"dev-include\", \"devBranch\": \"dev\" }.'];\n }\n // webpieces-disable no-any-unknown -- narrowing the opaque devDeploy object from consumer JSON\n const s = value as Record<string, unknown>;\n const errors: string[] = [];\n errors.push(...validateRefComponent(s, 'branchNamespace', 'dev-include'));\n errors.push(...validateRefComponent(s, 'devBranch', 'dev'));\n if (errors.length > 0) return errors;\n\n const namespace = typeof s['branchNamespace'] === 'string' ? s['branchNamespace'].trim() : 'dev-include';\n const devBranch = typeof s['devBranch'] === 'string' ? s['devBranch'].trim() : 'dev';\n if (devBranch.includes('/')) {\n errors.push(\n `[pr-gate] \"devDeploy.devBranch\" = \"${devBranch}\" must be a single ref name with no \"/\" — it is the ` +\n `branch your CI composes and deploys, not a namespace.`);\n }\n if (devBranch === namespace || devBranch.startsWith(`${namespace}/`) || namespace.startsWith(`${devBranch}/`)) {\n errors.push(\n `[pr-gate] \"devDeploy.devBranch\" (\"${devBranch}\") and \"devDeploy.branchNamespace\" (\"${namespace}\") must not ` +\n `contain one another. The namespace holds the DISPOSABLE per-developer copies (written by wp-push-dev); ` +\n `devBranch is the COMPOSED branch your CI rebuilds from origin/main. Overlapping them makes wp-push-dev ` +\n `--list enumerate the deploy branch and makes \"refused as a source branch\" ambiguous.`);\n }\n return errors;\n}\n\n// One `devDeploy` string field: present ⇒ must be a non-empty, ref-safe string. Absent ⇒ the default.\n// webpieces-disable no-any-unknown -- the already-narrowed opaque devDeploy object\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nfunction validateRefComponent(s: Record<string, unknown>, key: string, example: string): string[] {\n if (!(key in s)) return [];\n const raw = s[key];\n if (typeof raw !== 'string' || raw.trim() === '') {\n return [`[pr-gate] \"devDeploy.${key}\" must be a non-empty string, e.g. \"${example}\". Omit the key for the \"${example}\" default.`];\n }\n if (!REF_COMPONENT.test(raw.trim())) {\n return [\n `[pr-gate] \"devDeploy.${key}\" = \"${raw}\" is not a usable git ref name. Use letters, digits, \".\", \"_\", ` +\n `\"-\" and \"/\" only, starting with a letter or digit (e.g. \"${example}\").`,\n ];\n }\n return [];\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validatePrGateSection = validatePrGateSection;
4
+ const config_documentation_1 = require("./config-documentation");
4
5
  const pr_gate_section_validators_1 = require("./pr-gate-section-validators");
5
6
  const PR_GATE_MODES = ['ON', 'OFF'];
6
7
  // Optional — omitted means DETECT. Kept inline (like prGateExample) to avoid a load-config ↔
@@ -14,10 +15,12 @@ const MERGE_MODE_HELP = `Must be one of: ${PR_GATE_MERGE_MODES.join(', ')}.\n` +
14
15
  ` GitHub auto-merge, both with an explicit --subject/--body-file so main's history\n` +
15
16
  ` gets the PR title + the compact risk/flags body. Needs allow_auto_merge on the repo\n` +
16
17
  ` (gh api repos/{owner}/{repo} --jq .allow_auto_merge).\n` +
17
- ` "NONE" — wp-finish-upsert-pr only opens/updates the PR; a human merges it, and that still\n` +
18
+ ` "NONE" — wp-finish-upsert-pr only opens/updates the PR without attempting to merge. It still\n` +
18
19
  ` lands the compact body: the PR DESCRIPTION *is* that body, and stage \u2462 keeps the repo's\n` +
19
20
  ` squash_merge_commit_title/message pinned to PR_TITLE/PR_BODY so a UI merge copies it\n` +
20
- ` verbatim (SquashSettingsEnforcer). Nothing to set by hand.`;
21
+ ` verbatim (SquashSettingsEnforcer). Nothing to set by hand.\n` +
22
+ ` This is tooling behavior, not an authorization requirement. Honor existing user\n` +
23
+ ` instructions, including $full-cycle; use pnpm wp-land-pr when landing was requested.`;
21
24
  // Copy-paste example for the top-level `pr-gate` block (sibling of `rules`). Kept inline rather
22
25
  // than imported from pr-gate-config.ts to avoid a load-config ↔ pr-gate-config import cycle.
23
26
  // webpieces-disable no-function-outside-class -- pure example renderer beside the public command validator
@@ -97,7 +100,7 @@ function validatePrGateSection(section, repoRoot) {
97
100
  }
98
101
  // webpieces-disable no-any-unknown -- narrowing the opaque pr-gate section from consumer JSON
99
102
  const s = section;
100
- const errors = [];
103
+ const errors = new config_documentation_1.ConfigDocumentation().inlineErrors(section, '[pr-gate]');
101
104
  if (!('mode' in s)) {
102
105
  errors.push(`[pr-gate] Missing required field "mode". Must be one of: ${PR_GATE_MODES.join(', ')}.`);
103
106
  }
@@ -1 +1 @@
1
- {"version":3,"file":"validate-pr-gate.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/validate-pr-gate.ts"],"names":[],"mappings":";;AAsGA,sDA8DC;AApKD,6EAAkL;AAGlL,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,KAAK,CAAU,CAAC;AAC7C,6FAA6F;AAC7F,yFAAyF;AACzF,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAU,CAAC;AAEtD,iGAAiG;AACjG,kGAAkG;AAClG,+FAA+F;AAC/F,MA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C;QACpF,CAAC;aAAM,IACH,OAAO,EAAE,KAAK,QAAQ;YACtB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,EAA0C,CAAC,EAC3E,CAAC;YACC,MAAM,CAAC,IAAI,CAAC,4BAA4B,MAAM,CAAC,EAAE,CAAC,mBAAmB,eAAe,EAAE,CAAC,CAAC;QAC5F,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,GAAG,IAAA,sDAAyB,EAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { validateChecklistsSection, validateDevDeploySection, validateLandPrSection, validateNoGateSaltRationale, validateReviewerAgentKeys } from './pr-gate-section-validators';\nimport * as fs from 'fs';\nimport * as path from 'path';\nconst PR_GATE_MODES = ['ON', 'OFF'] as const;\n// Optional — omitted means DETECT. Kept inline (like prGateExample) to avoid a load-config ↔\n// pr-gate-config import cycle; the canonical list + semantics live in pr-gate-config.ts.\nconst PR_GATE_MERGE_MODES = ['AUTO', 'NONE'] as const;\n\n// Spelled out because the choice is a POLICY decision with a consequence the chooser cannot see:\n// only the AUTO path can put the compact risk/flags body in main's history, because a UI merge is\n// composed from the repo's squash_merge_commit_title/message settings, which the tooling pins.\nconst MERGE_MODE_HELP =\n `Must be one of: ${PR_GATE_MERGE_MODES.join(', ')}.\\n` +\n ` \"AUTO\" — wp-finish-upsert-pr lands the PR: it squash-merges when mergeable, else enables\\n` +\n ` GitHub auto-merge, both with an explicit --subject/--body-file so main's history\\n` +\n ` gets the PR title + the compact risk/flags body. Needs allow_auto_merge on the repo\\n` +\n ` (gh api repos/{owner}/{repo} --jq .allow_auto_merge).\\n` +\n ` \"NONE\" — wp-finish-upsert-pr only opens/updates the PR; a human merges it, and that still\\n` +\n ` lands the compact body: the PR DESCRIPTION *is* that body, and stage \\u2462 keeps the repo's\\n` +\n ` squash_merge_commit_title/message pinned to PR_TITLE/PR_BODY so a UI merge copies it\\n` +\n ` verbatim (SquashSettingsEnforcer). Nothing to set by hand.`;\n\n// Copy-paste example for the top-level `pr-gate` block (sibling of `rules`). Kept inline rather\n// than imported from pr-gate-config.ts to avoid a load-config ↔ pr-gate-config import cycle.\n// webpieces-disable no-function-outside-class -- pure example renderer beside the public command validator\nfunction prGateExample(): string {\n return (\n ` \"pr-gate\": {\\n` +\n ` \"mode\": \"ON\",\\n` +\n ` \"buildCommand\": \"<command CI runs to validate a PR, e.g. pnpm nx affected --target=ci --base=$(git merge-base origin/main HEAD)>\",\\n` +\n ` \"gates\": [\\n` +\n ` { \"name\": \"API Changed\", \"patterns\": [\"libraries/apis/**\", \"**/*Api.ts\"], \"warningColor\": \"yellow\" }\\n` +\n ` ],\\n` +\n ` \"reviewerAgents\": 1, // REQUIRED — 0 disables reviews; positive values cap subagents per round\\n` +\n ` \"maxReviewerRounds\": 2, // REQUIRED positive integer — caps complete global review rounds\\n` +\n ` \"checklists\": [ // OPTIONAL — per-area review, each against its own doc\\n` +\n ` { \"id\": \"db-migrations\", \"doc\": \".claude/review/db-migrations.md\", \"patterns\": [\"**/*.sql\"], \"required\": true }\\n` +\n ` ]\\n` +\n ` }`\n );\n}\n\n// The `gates` array: dashboard-only warning flags. Extracted from validatePrGateSection to keep that\n// method inside the length limit.\n// webpieces-disable no-any-unknown -- `value` is the opaque consumer `gates` value until narrowed here\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nfunction validateGatesSection(value: unknown): string[] {\n if (!Array.isArray(value)) {\n return [\n `[pr-gate] \"gates\" must be an array of { name, patterns, warningColor, disabled? }.`,\n ];\n }\n const errors: string[] = [];\n for (let i = 0; i < value.length; i += 1) {\n errors.push(...validateGate(value[i], i));\n }\n return errors;\n}\n\n// webpieces-disable no-any-unknown -- one gate entry from opaque consumer JSON, validated field-by-field\n// webpieces-disable no-function-outside-class -- pure field validator beside the public command validator\nfunction validateGate(gate: unknown, index: number): string[] {\n if (typeof gate !== 'object' || gate === null) {\n return [\n `[pr-gate] gates[${index}] must be an object { name, patterns, warningColor, disabled? }.`,\n ];\n }\n // webpieces-disable no-any-unknown -- narrowing one opaque gate object from consumer JSON\n const g = gate as Record<string, unknown>;\n const errors: string[] = [];\n if (typeof g['name'] !== 'string')\n errors.push(`[pr-gate] gates[${index}].name must be a string.`);\n if (\n !Array.isArray(g['patterns']) ||\n // webpieces-disable no-any-unknown -- opaque config patterns are checked before use\n !g['patterns'].every((p: unknown) => typeof p === 'string')\n )\n errors.push(`[pr-gate] gates[${index}].patterns must be string[].`);\n if (g['warningColor'] === undefined)\n errors.push(\n `[pr-gate] gates[${index}].warningColor is required — set it to \"yellow\" or \"red\" (green is implicit when nothing matches).`,\n );\n else if (g['warningColor'] !== 'yellow' && g['warningColor'] !== 'red')\n errors.push(\n `[pr-gate] gates[${index}].warningColor must be \"yellow\" or \"red\" (green is implicit when nothing matches).`,\n );\n if (g['disabled'] !== undefined && typeof g['disabled'] !== 'boolean')\n errors.push(\n `[pr-gate] gates[${index}].disabled must be a boolean (example/inactive gate kept in the file).`,\n );\n return errors;\n}\n\n/**\n * Validate the top-level `pr-gate` section. It is REQUIRED (a client that opts out sets mode \"OFF\").\n * `buildCommand` is required unless mode is \"OFF\". Returns human-readable, copy-paste-friendly errors\n * — never throws. The pr-gate block lives outside the FieldDef-driven `rules` schema because its\n * nested `gates`/`checklists` arrays can't be expressed there, so they get structural validation here.\n * `repoRoot` (when known) lets the `checklists[].docs` existence check run.\n */\n// webpieces-disable no-any-unknown -- `section` is opaque consumer JSON until narrowed below\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nexport function validatePrGateSection(section: unknown, repoRoot?: string): string[] {\n if (section === undefined || section === null) {\n return [\n `[pr-gate] Not configured in webpieces.config.json. Add this block under the \"commands\" ` +\n `section (set \"mode\": \"OFF\" to opt out):\\n\\n${prGateExample()}`,\n ];\n }\n if (typeof section !== 'object' || Array.isArray(section)) {\n return [`[pr-gate] Must be an object. Example:\\n\\n${prGateExample()}`];\n }\n // webpieces-disable no-any-unknown -- narrowing the opaque pr-gate section from consumer JSON\n const s = section as Record<string, unknown>;\n const errors: string[] = [];\n\n if (!('mode' in s)) {\n errors.push(\n `[pr-gate] Missing required field \"mode\". Must be one of: ${PR_GATE_MODES.join(', ')}.`,\n );\n } else if (\n typeof s['mode'] !== 'string' ||\n !PR_GATE_MODES.includes(s['mode'] as (typeof PR_GATE_MODES)[number])\n ) {\n errors.push(\n `[pr-gate] \"mode\" = \"${String(s['mode'])}\" is not valid. Must be one of: ${PR_GATE_MODES.join(', ')}.`,\n );\n }\n\n errors.push(...validateActiveGatePolicy(s, repoRoot));\n\n if ('gates' in s) errors.push(...validateGatesSection(s['gates']));\n\n // Optional extension point: company review checklists, as an ARRAY right here in the config. Absent ⇒\n // none. The removed { doc } manifest shape is rejected with the exact migration edit.\n if ('checklists' in s) errors.push(...validateChecklistsSection(s['checklists'], repoRoot));\n\n // Optional server-token salt. Absent ⇒ no token minted, CI enforcement is a no-op. Present ⇒ must be\n // a non-empty string (an empty salt would mint a token anyone can forge from a known-empty secret).\n if ('gateSalt' in s) {\n const salt = s['gateSalt'];\n if (typeof salt !== 'string' || salt.trim() === '') {\n errors.push(\n `[pr-gate] \"gateSalt\" must be a non-empty string — it is the shared secret the gate token is HMAC'd with. Omit the key entirely to disable server-side token enforcement.`,\n );\n }\n }\n\n // Optional: what happens to the LOCAL branch once its PR lands. Absent ⇒ \"archive-tag\".\n if ('landPr' in s) errors.push(...validateLandPrSection(s['landPr']));\n\n // Optional: where wp-push-dev publishes the disposable copy. Absent ⇒ \"dev-include\" / \"dev\".\n if ('devDeploy' in s) errors.push(...validateDevDeploySection(s['devDeploy']));\n\n errors.push(...validateNoGateSaltRationale(s));\n\n // Optional: publish reviewer output as a PR comment (defaults true). Must be a boolean when present.\n if ('checklistComments' in s && typeof s['checklistComments'] !== 'boolean') {\n errors.push(\n `[pr-gate] \"checklistComments\" must be a boolean (defaults to true; set false to keep the PR body-only).`,\n );\n }\n\n return errors;\n}\n\n\n// webpieces-disable no-any-unknown -- explicit command configuration JSON is checked field by field\n// webpieces-disable no-function-outside-class -- pure validation helper\nfunction validateActiveGatePolicy(s: Record<string, unknown>, repoRoot: string | undefined): string[] {\n const errors: string[] = [];\n // buildCommand and mergeMode are both required whenever the gate is active (mode !== OFF). There\n // is deliberately NO default for mergeMode: whether the tooling may land your PRs is a policy\n // decision, and either guess is wrong for somebody.\n if (s['mode'] !== 'OFF') {\n const cmd = s['buildCommand'];\n if (typeof cmd !== 'string' || cmd.trim() === '') {\n errors.push(\n `[pr-gate] Missing required field \"buildCommand\" — the command CI runs to validate a PR. ` +\n `Add e.g. \"buildCommand\": \"pnpm nx affected --target=ci --base=$(git merge-base origin/main HEAD)\".`,\n );\n }\n const mm = s['mergeMode'];\n if (!('mergeMode' in s)) {\n errors.push(`[pr-gate] Missing required field \"mergeMode\". ${MERGE_MODE_HELP}`);\n } else if (\n typeof mm !== 'string' ||\n !PR_GATE_MERGE_MODES.includes(mm as (typeof PR_GATE_MERGE_MODES)[number])\n ) {\n errors.push(`[pr-gate] \"mergeMode\" = \"${String(mm)}\" is not valid. ${MERGE_MODE_HELP}`);\n }\n errors.push(...validateReviewerAgentKeys(s, repoRoot));\n }\n\n return errors;\n}\n"]}
1
+ {"version":3,"file":"validate-pr-gate.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/validate-pr-gate.ts"],"names":[],"mappings":";;AAyGA,sDA8DC;AAvKD,iEAA6D;AAC7D,6EAAkL;AAGlL,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,KAAK,CAAU,CAAC;AAC7C,6FAA6F;AAC7F,yFAAyF;AACzF,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAU,CAAC;AAEtD,iGAAiG;AACjG,kGAAkG;AAClG,+FAA+F;AAC/F,MAAM,eAAe,GACjB,mBAAmB,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK;IACtD,8FAA8F;IAC9F,+FAA+F;IA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AAM,IACH,OAAO,EAAE,KAAK,QAAQ;YACtB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,EAA0C,CAAC,EAC3E,CAAC;YACC,MAAM,CAAC,IAAI,CAAC,4BAA4B,MAAM,CAAC,EAAE,CAAC,mBAAmB,eAAe,EAAE,CAAC,CAAC;QAC5F,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,GAAG,IAAA,sDAAyB,EAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { ConfigDocumentation } from './config-documentation';\nimport { validateChecklistsSection, validateDevDeploySection, validateLandPrSection, validateNoGateSaltRationale, validateReviewerAgentKeys } from './pr-gate-section-validators';\nimport * as fs from 'fs';\nimport * as path from 'path';\nconst PR_GATE_MODES = ['ON', 'OFF'] as const;\n// Optional — omitted means DETECT. Kept inline (like prGateExample) to avoid a load-config ↔\n// pr-gate-config import cycle; the canonical list + semantics live in pr-gate-config.ts.\nconst PR_GATE_MERGE_MODES = ['AUTO', 'NONE'] as const;\n\n// Spelled out because the choice is a POLICY decision with a consequence the chooser cannot see:\n// only the AUTO path can put the compact risk/flags body in main's history, because a UI merge is\n// composed from the repo's squash_merge_commit_title/message settings, which the tooling pins.\nconst MERGE_MODE_HELP =\n `Must be one of: ${PR_GATE_MERGE_MODES.join(', ')}.\\n` +\n ` \"AUTO\" — wp-finish-upsert-pr lands the PR: it squash-merges when mergeable, else enables\\n` +\n ` GitHub auto-merge, both with an explicit --subject/--body-file so main's history\\n` +\n ` gets the PR title + the compact risk/flags body. Needs allow_auto_merge on the repo\\n` +\n ` (gh api repos/{owner}/{repo} --jq .allow_auto_merge).\\n` +\n ` \"NONE\" — wp-finish-upsert-pr only opens/updates the PR without attempting to merge. It still\\n` +\n ` lands the compact body: the PR DESCRIPTION *is* that body, and stage \\u2462 keeps the repo's\\n` +\n ` squash_merge_commit_title/message pinned to PR_TITLE/PR_BODY so a UI merge copies it\\n` +\n ` verbatim (SquashSettingsEnforcer). Nothing to set by hand.\\n` +\n ` This is tooling behavior, not an authorization requirement. Honor existing user\\n` +\n ` instructions, including $full-cycle; use pnpm wp-land-pr when landing was requested.`;\n\n// Copy-paste example for the top-level `pr-gate` block (sibling of `rules`). Kept inline rather\n// than imported from pr-gate-config.ts to avoid a load-config ↔ pr-gate-config import cycle.\n// webpieces-disable no-function-outside-class -- pure example renderer beside the public command validator\nfunction prGateExample(): string {\n return (\n ` \"pr-gate\": {\\n` +\n ` \"mode\": \"ON\",\\n` +\n ` \"buildCommand\": \"<command CI runs to validate a PR, e.g. pnpm nx affected --target=ci --base=$(git merge-base origin/main HEAD)>\",\\n` +\n ` \"gates\": [\\n` +\n ` { \"name\": \"API Changed\", \"patterns\": [\"libraries/apis/**\", \"**/*Api.ts\"], \"warningColor\": \"yellow\" }\\n` +\n ` ],\\n` +\n ` \"reviewerAgents\": 1, // REQUIRED — 0 disables reviews; positive values cap subagents per round\\n` +\n ` \"maxReviewerRounds\": 2, // REQUIRED positive integer — caps complete global review rounds\\n` +\n ` \"checklists\": [ // OPTIONAL — per-area review, each against its own doc\\n` +\n ` { \"id\": \"db-migrations\", \"doc\": \".claude/review/db-migrations.md\", \"patterns\": [\"**/*.sql\"], \"required\": true }\\n` +\n ` ]\\n` +\n ` }`\n );\n}\n\n// The `gates` array: dashboard-only warning flags. Extracted from validatePrGateSection to keep that\n// method inside the length limit.\n// webpieces-disable no-any-unknown -- `value` is the opaque consumer `gates` value until narrowed here\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nfunction validateGatesSection(value: unknown): string[] {\n if (!Array.isArray(value)) {\n return [\n `[pr-gate] \"gates\" must be an array of { name, patterns, warningColor, disabled? }.`,\n ];\n }\n const errors: string[] = [];\n for (let i = 0; i < value.length; i += 1) {\n errors.push(...validateGate(value[i], i));\n }\n return errors;\n}\n\n// webpieces-disable no-any-unknown -- one gate entry from opaque consumer JSON, validated field-by-field\n// webpieces-disable no-function-outside-class -- pure field validator beside the public command validator\nfunction validateGate(gate: unknown, index: number): string[] {\n if (typeof gate !== 'object' || gate === null) {\n return [\n `[pr-gate] gates[${index}] must be an object { name, patterns, warningColor, disabled? }.`,\n ];\n }\n // webpieces-disable no-any-unknown -- narrowing one opaque gate object from consumer JSON\n const g = gate as Record<string, unknown>;\n const errors: string[] = [];\n if (typeof g['name'] !== 'string')\n errors.push(`[pr-gate] gates[${index}].name must be a string.`);\n if (\n !Array.isArray(g['patterns']) ||\n // webpieces-disable no-any-unknown -- opaque config patterns are checked before use\n !g['patterns'].every((p: unknown) => typeof p === 'string')\n )\n errors.push(`[pr-gate] gates[${index}].patterns must be string[].`);\n if (g['warningColor'] === undefined)\n errors.push(\n `[pr-gate] gates[${index}].warningColor is required — set it to \"yellow\" or \"red\" (green is implicit when nothing matches).`,\n );\n else if (g['warningColor'] !== 'yellow' && g['warningColor'] !== 'red')\n errors.push(\n `[pr-gate] gates[${index}].warningColor must be \"yellow\" or \"red\" (green is implicit when nothing matches).`,\n );\n if (g['disabled'] !== undefined && typeof g['disabled'] !== 'boolean')\n errors.push(\n `[pr-gate] gates[${index}].disabled must be a boolean (example/inactive gate kept in the file).`,\n );\n return errors;\n}\n\n/**\n * Validate the top-level `pr-gate` section. It is REQUIRED (a client that opts out sets mode \"OFF\").\n * `buildCommand` is required unless mode is \"OFF\". Returns human-readable, copy-paste-friendly errors\n * — never throws. The pr-gate block lives outside the FieldDef-driven `rules` schema because its\n * nested `gates`/`checklists` arrays can't be expressed there, so they get structural validation here.\n * `repoRoot` (when known) lets the `checklists[].docs` existence check run.\n */\n// webpieces-disable no-any-unknown -- `section` is opaque consumer JSON until narrowed below\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nexport function validatePrGateSection(section: unknown, repoRoot?: string): string[] {\n if (section === undefined || section === null) {\n return [\n `[pr-gate] Not configured in webpieces.config.json. Add this block under the \"commands\" ` +\n `section (set \"mode\": \"OFF\" to opt out):\\n\\n${prGateExample()}`,\n ];\n }\n if (typeof section !== 'object' || Array.isArray(section)) {\n return [`[pr-gate] Must be an object. Example:\\n\\n${prGateExample()}`];\n }\n // webpieces-disable no-any-unknown -- narrowing the opaque pr-gate section from consumer JSON\n const s = section as Record<string, unknown>;\n const errors: string[] = new ConfigDocumentation().inlineErrors(section, '[pr-gate]');\n\n if (!('mode' in s)) {\n errors.push(\n `[pr-gate] Missing required field \"mode\". Must be one of: ${PR_GATE_MODES.join(', ')}.`,\n );\n } else if (\n typeof s['mode'] !== 'string' ||\n !PR_GATE_MODES.includes(s['mode'] as (typeof PR_GATE_MODES)[number])\n ) {\n errors.push(\n `[pr-gate] \"mode\" = \"${String(s['mode'])}\" is not valid. Must be one of: ${PR_GATE_MODES.join(', ')}.`,\n );\n }\n\n errors.push(...validateActiveGatePolicy(s, repoRoot));\n\n if ('gates' in s) errors.push(...validateGatesSection(s['gates']));\n\n // Optional extension point: company review checklists, as an ARRAY right here in the config. Absent ⇒\n // none. The removed { doc } manifest shape is rejected with the exact migration edit.\n if ('checklists' in s) errors.push(...validateChecklistsSection(s['checklists'], repoRoot));\n\n // Optional server-token salt. Absent ⇒ no token minted, CI enforcement is a no-op. Present ⇒ must be\n // a non-empty string (an empty salt would mint a token anyone can forge from a known-empty secret).\n if ('gateSalt' in s) {\n const salt = s['gateSalt'];\n if (typeof salt !== 'string' || salt.trim() === '') {\n errors.push(\n `[pr-gate] \"gateSalt\" must be a non-empty string — it is the shared secret the gate token is HMAC'd with. Omit the key entirely to disable server-side token enforcement.`,\n );\n }\n }\n\n // Optional: what happens to the LOCAL branch once its PR lands. Absent ⇒ \"archive-tag\".\n if ('landPr' in s) errors.push(...validateLandPrSection(s['landPr']));\n\n // Optional: where wp-push-dev publishes the disposable copy. Absent ⇒ \"dev-include\" / \"dev\".\n if ('devDeploy' in s) errors.push(...validateDevDeploySection(s['devDeploy']));\n\n errors.push(...validateNoGateSaltRationale(s));\n\n // Optional: publish reviewer output as a PR comment (defaults true). Must be a boolean when present.\n if ('checklistComments' in s && typeof s['checklistComments'] !== 'boolean') {\n errors.push(\n `[pr-gate] \"checklistComments\" must be a boolean (defaults to true; set false to keep the PR body-only).`,\n );\n }\n\n return errors;\n}\n\n\n// webpieces-disable no-any-unknown -- explicit command configuration JSON is checked field by field\n// webpieces-disable no-function-outside-class -- pure validation helper\nfunction validateActiveGatePolicy(s: Record<string, unknown>, repoRoot: string | undefined): string[] {\n const errors: string[] = [];\n // buildCommand and mergeMode are both required whenever the gate is active (mode !== OFF). There\n // is deliberately NO default for mergeMode: whether the tooling may land your PRs is a policy\n // decision, and either guess is wrong for somebody.\n if (s['mode'] !== 'OFF') {\n const cmd = s['buildCommand'];\n if (typeof cmd !== 'string' || cmd.trim() === '') {\n errors.push(\n `[pr-gate] Missing required field \"buildCommand\" — the command CI runs to validate a PR. ` +\n `Add e.g. \"buildCommand\": \"pnpm nx affected --target=ci --base=$(git merge-base origin/main HEAD)\".`,\n );\n }\n const mm = s['mergeMode'];\n if (!('mergeMode' in s)) {\n errors.push(`[pr-gate] Missing required field \"mergeMode\". ${MERGE_MODE_HELP}`);\n } else if (\n typeof mm !== 'string' ||\n !PR_GATE_MERGE_MODES.includes(mm as (typeof PR_GATE_MERGE_MODES)[number])\n ) {\n errors.push(`[pr-gate] \"mergeMode\" = \"${String(mm)}\" is not valid. ${MERGE_MODE_HELP}`);\n }\n errors.push(...validateReviewerAgentKeys(s, repoRoot));\n }\n\n return errors;\n}\n"]}
@@ -58,19 +58,31 @@ version-drift guard compares the pin against the installed version *before* the
58
58
  every tool call with its own message and its own cure. So if you are reading a validation error, no drift
59
59
  was detected.
60
60
 
61
- ## Documenting your own config: the `*Why` convention
61
+ ## Documentation lives outside JSON
62
62
 
63
- JSON has no comments, so any key ending in **`Why`** is free-form rationale kept beside the key it explains,
64
- and must be a string:
63
+ The first entry in `webpieces.config.json` must be exactly:
65
64
 
65
+ <!-- webpieces-disable no-state-paths-in-templates -- This example documents the exact required literal config value, not a resolved runtime state path. -->
66
66
  ```json
67
- "mergeModeWhy": "NONE, deliberately: a human always clicks merge in this repo.",
68
- "mergeMode": "NONE"
67
+ "webpiecesConfigJsonDocumentation": ".webpieces/instruct-ai/webpieces.config-policy.md"
69
68
  ```
70
69
 
71
- Unknown keys are rejected — a silently-ignored key is how a stale config survives an upgrade — so if you
72
- want a note in the file, give it a `*Why` name rather than inventing a key.
70
+ This path is required and validated literally. The loader regenerates this guide before validating the
71
+ config, including when validation fails, so the link has a real destination on a fresh checkout.
72
+ `wp-install-ai-hooks` also writes it. Do not hand-edit the generated guide.
73
73
 
74
- One exception: **`gateSaltWhy` is rejected outright.** Rationale next to the gate salt necessarily explains
75
- what the token protects and that the salt is committed, i.e. it is a bypass how-to sitting in the most-read
76
- file in the repo. That reasoning lives in the webpieces source instead.
74
+ Inline `*Why` keys, including `upgradePolicyWhy`, are rejected at every config section.
75
+ Remove them from JSON. Keep repository-specific decisions in tracked Markdown in the repository;
76
+ put reusable config instructions in this guide's source template. Generated files are overwritten.
77
+
78
+ ## Merge automation and existing authorization
79
+
80
+ `commands.pr-gate.mergeMode` controls only what `wp-finish-upsert-pr` does:
81
+
82
+ - `AUTO`: attempt to squash-merge; if necessary and available, queue GitHub auto-merge.
83
+ - `NONE`: publish/update the PR without attempting to merge it.
84
+
85
+ This setting does not require extra merge authorization and does not override user instructions.
86
+ When the user has requested landing, including through `$full-cycle` or `/full-cycle`, continue with
87
+ `pnpm wp-land-pr` after the required checks. That command works with either value. GitHub permissions
88
+ and merge requirements still apply.