@webpieces/rules-config 0.4.901 → 0.4.903
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.
|
|
3
|
+
"version": "0.4.903",
|
|
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.
|
|
23
|
-
"@webpieces/repo-workflow-core": "0.4.
|
|
24
|
-
"@webpieces/rules-sdk": "0.4.
|
|
22
|
+
"@webpieces/tooling-common": "0.4.903",
|
|
23
|
+
"@webpieces/repo-workflow-core": "0.4.903",
|
|
24
|
+
"@webpieces/rules-sdk": "0.4.903"
|
|
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.
|
|
37
|
+
"@webpieces/tooling-testkit": "0.4.903"
|
|
38
38
|
},
|
|
39
39
|
"types": "./src/index.d.ts",
|
|
40
40
|
"bin": {
|
|
@@ -249,6 +249,9 @@ class RulePackRegistry {
|
|
|
249
249
|
if (field[flag] !== undefined && typeof field[flag] !== 'boolean')
|
|
250
250
|
throw new tooling_common_1.InformAiError(`Invalid ${flag} for ${location}.${key}. Supply a boolean.`);
|
|
251
251
|
}
|
|
252
|
+
if (field.emptyInstruction !== undefined && typeof field.emptyInstruction !== 'string') {
|
|
253
|
+
throw new tooling_common_1.InformAiError(`Invalid emptyInstruction for ${location}.${key}. Supply owner-authored cure text.`);
|
|
254
|
+
}
|
|
252
255
|
if (field.enumValues !== undefined &&
|
|
253
256
|
(!Array.isArray(field.enumValues) ||
|
|
254
257
|
// webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution
|
|
@@ -300,7 +303,8 @@ class RulePackRegistry {
|
|
|
300
303
|
errors.push(`${label} must be one of ${field.enumValues.join(', ')}.`);
|
|
301
304
|
if (Array.isArray(entry)) {
|
|
302
305
|
if (field.nonEmpty && entry.length === 0)
|
|
303
|
-
errors.push(`${label} must contain at least one entry.`
|
|
306
|
+
errors.push(`${label} must contain at least one entry.` +
|
|
307
|
+
(field.emptyInstruction === undefined ? '' : ` ${field.emptyInstruction}`));
|
|
304
308
|
if (field.type === 'string[]' &&
|
|
305
309
|
entry.some((item) => typeof item !== 'string'))
|
|
306
310
|
errors.push(`${label} must contain only strings.`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule-pack-registry.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/rule-pack-registry.ts"],"names":[],"mappings":";;;;AAAA,yEAAoE;AACpE,yCAA2D;AAC3D,6CAA4C;AAC5C,8DAA0D;AAC1D,wDAAkC;AAClC,yEAAoE;AACpE,oDAY8B;AAE9B,+FAA+F;AAC/F,MAAsB,oBAAoB;CAEzC;AAFD,oDAEC;AAED,MAAa,wBAAyB,SAAQ,oBAAoB;IAC7C,aAAa,CAAc;IAC3B,UAAU,CAAyB;IAEpD,YAAY,UAAkB;QAC1B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,aAAa,GAAG,IAAA,2BAAa,EAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC,CAAC;QAC1E,IAAI,CAAC,UAAU,GAAG,IAAI,iDAAsB,CAAC,UAAU,CAAC,CAAC;I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AwYC;AAED,4FAA4F;AAErF,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IACG;IAA7B,YAA6B,MAA4B;QAA5B,WAAM,GAAN,MAAM,CAAsB;IAAG,CAAC;IAE7D,QAAQ,CAAC,YAA4C;QACjD,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,WAAgC,EAAE,EAAE,CACpE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CACvC,CAAC;QACF,MAAM,QAAQ,GAAG,IAAI,gBAAgB,CAAC,SAAS,CAAC,CAAC;QACjD,SAAS,CAAC,OAAO,CAAC,CAAC,QAA0B,EAAE,KAAa,EAAE,EAAE,CAC5D,QAAQ,CAAC,oBAAoB,CAAC,QAAQ,CAAC,WAAW,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAClF,CAAC;QACF,OAAO,QAAQ,CAAC;IACpB,CAAC;CACJ,CAAA;AAbY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEA,oBAAoB;GADhD,iBAAiB,CAa7B","sourcesContent":["import { PolicyFieldConstraints } from './policy-field-constraints';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { createRequire } from 'node:module';\nimport { InformAiError } from '@webpieces/tooling-common';\nimport * as path from 'node:path';\nimport { ClientModuleResolution } from './client-module-resolution';\nimport {\n FieldDef,\n RulePackManifest,\n RulePackDeclaration,\n OwnedRuleDefinition,\n RULE_PACK_API_VERSION,\n RULE_SCHEMA_API_VERSION,\n ConfigObject,\n RetiredConfigKey,\n SafeguardDefinition,\n RuleConfigSection,\n ConfigValue,\n} from '@webpieces/rules-sdk';\n\n/** Loading is the only impure boundary; callers may supply an alternative module transport. */\nexport abstract class RulePackModuleLoader {\n abstract load(moduleName: string): RulePackManifest;\n}\n\nexport class NodeRulePackModuleLoader extends RulePackModuleLoader {\n private readonly requireModule: NodeRequire;\n private readonly resolution: ClientModuleResolution;\n\n constructor(clientRoot: string) {\n super();\n this.requireModule = createRequire(path.join(clientRoot, 'package.json'));\n this.resolution = new ClientModuleResolution(clientRoot);\n }\n\n override load(moduleName: string): RulePackManifest {\n // webpieces-disable no-any-unknown -- external module boundary; registry validates its exported data before use\n const exports: unknown = this.requireModule(this.resolution.resolve(moduleName));\n if (typeof exports !== 'object' || exports === null || !('rulePackManifest' in exports)) {\n throw new InformAiError(\n `Rule pack ${moduleName} must export rulePackManifest. Add the public manifest export.`,\n );\n }\n return exports.rulePackManifest as RulePackManifest;\n }\n}\n\n/** A registry depends only on declarations and the SDK, never on concrete execution packages. */\nexport class RulePackRegistry {\n private readonly modules = new Map<string, string>();\n private readonly owners = new Map<string, string>();\n private readonly definitions = new Map<string, OwnedRuleDefinition>();\n private readonly safeguards = new Map<string, SafeguardDefinition>();\n\n constructor(readonly manifests: readonly RulePackManifest[]) {\n for (const manifest of manifests) this.validateManifestHeader(manifest);\n const packs = new Set<string>();\n for (const manifest of manifests) {\n this.validateManifest(manifest);\n if (packs.has(manifest.packageName))\n throw new InformAiError(`Duplicate pack ${manifest.packageName}. Declare it once.`);\n packs.add(manifest.packageName);\n for (const definition of manifest.ownedRules) {\n if (this.owners.has(definition.id))\n throw new InformAiError(\n `Rule ${definition.id} has multiple owners. Keep exactly one owner.`,\n );\n this.owners.set(definition.id, manifest.packageName);\n this.definitions.set(definition.id, definition);\n }\n }\n for (const manifest of manifests) {\n for (const safeguard of manifest.safeguards) {\n if (\n !safeguard ||\n typeof safeguard.id !== 'string' ||\n !safeguard.id ||\n !['fixed', 'experimental'].includes(safeguard.activation) ||\n typeof safeguard.description !== 'string' ||\n !safeguard.description\n ) {\n throw new InformAiError(\n 'Invalid safeguard catalog. Supply id, activation, and description.',\n );\n }\n if (this.owners.has(safeguard.id) || this.safeguards.has(safeguard.id)) {\n throw new InformAiError(\n `Safeguard ${safeguard.id} cannot be configured or owned twice. Keep it outside configurable policies.`,\n );\n }\n this.safeguards.set(safeguard.id, safeguard);\n }\n }\n const executions = new Set<string>();\n for (const manifest of manifests) this.registerContributions(manifest, executions);\n }\n\n private registerContributions(manifest: RulePackManifest, executions: Set<string>): void {\n for (const contribution of manifest.contributions) {\n if (\n !contribution ||\n typeof contribution.ruleId !== 'string' ||\n typeof contribution.ownerPack !== 'string'\n ) {\n throw new InformAiError(\n `Invalid contribution in ${manifest.packageName}. Supply ruleId and ownerPack.`,\n );\n }\n if (\n typeof contribution.implementationModule !== 'string' ||\n !contribution.implementationModule.trim()\n ) {\n throw new InformAiError(\n `Missing implementation module for ${contribution.ruleId} in ${manifest.packageName}. Declare its public runtime module.`,\n );\n }\n const owner = this.owners.get(contribution.ruleId);\n if (!owner || owner !== contribution.ownerPack) {\n throw new InformAiError(\n `Unknown owner ${contribution.ownerPack} for ${contribution.ruleId}. Declare the owning pack and use its exact name.`,\n );\n }\n if (\n !['build', 'source-hook', 'workflow-guard', 'lint'].includes(\n contribution.executionKind,\n )\n ) {\n throw new InformAiError(\n `Invalid execution kind for ${contribution.ruleId}. Use build, source-hook, workflow-guard, or lint.`,\n );\n }\n const execution = `${contribution.ruleId}:${contribution.executionKind}`;\n if (executions.has(execution))\n throw new InformAiError(\n `Duplicate execution-kind contribution ${execution}. Keep one implementation per execution kind.`,\n );\n executions.add(execution);\n }\n }\n\n ownerOf(ruleId: string): string {\n const owner = this.owners.get(ruleId);\n if (!owner) throw new InformAiError(`Unknown rule ${ruleId}. Declare its owning pack.`);\n return owner;\n }\n\n schemaFor(ruleId: string): Readonly<Record<string, FieldDef>> {\n this.ownerOf(ruleId);\n return this.definitions.get(ruleId)!.schema;\n }\n\n /** The transport records the exact client declaration, including local manifest modules. */\n recordModuleLocation(packName: string, moduleName: string): void {\n if (\n !this.manifests.some(\n (manifest: RulePackManifest) => manifest.packageName === packName,\n ) ||\n this.modules.has(packName)\n ) {\n throw new InformAiError(\n `Invalid or duplicate module location for ${packName}. Declare each selected pack once.`,\n );\n }\n this.modules.set(packName, moduleName);\n }\n\n get manifestModules(): ReadonlyMap<string, string> {\n return this.modules;\n }\n\n ruleIds(): readonly string[] {\n return [...this.definitions.keys()];\n }\n\n hasRule(ruleId: string): boolean {\n return this.definitions.has(ruleId);\n }\n\n isSafeguard(ruleId: string): boolean {\n return this.safeguards.has(ruleId);\n }\n\n sectionFor(ruleId: string): RuleConfigSection {\n return this.definitionFor(ruleId).section;\n }\n\n optionalTuningFor(ruleId: string): ConfigObject {\n return this.definitionFor(ruleId).optionalTuning;\n }\n\n seedFor(ruleId: string): ConfigObject {\n return structuredClone(this.definitionFor(ruleId).recommendedSeed);\n }\n\n migrations(): readonly RetiredConfigKey[] {\n return this.manifests.flatMap((manifest: RulePackManifest) => [...manifest.migrations]);\n }\n\n safeguardCatalog(): readonly SafeguardDefinition[] {\n return [...this.safeguards.values()];\n }\n\n private definitionFor(ruleId: string): OwnedRuleDefinition {\n this.ownerOf(ruleId);\n return this.definitions.get(ruleId)!;\n }\n\n /** Validates explicit config values with the owner's schema; supplies no rule defaults. */\n validateRuleConfig(ruleId: string, value: ConfigObject): readonly string[] {\n const errors = this.validateObject(ruleId, this.schemaFor(ruleId), value);\n if (value && typeof value['turnOffRuleUntilEpoch'] === 'number') {\n const epoch = new PolicyFieldConstraints().epochError(\n `[${ruleId}]`,\n value['turnOffRuleUntilEpoch'],\n );\n if (epoch) errors.push(epoch);\n }\n return errors;\n }\n\n private validateManifestHeader(manifest: RulePackManifest): void {\n if (\n !manifest ||\n typeof manifest.packageName !== 'string' ||\n manifest.packageName.length === 0 ||\n typeof manifest.packageVersion !== 'string' ||\n manifest.packageVersion.length === 0 ||\n !Array.isArray(manifest.ownedRules) ||\n !Array.isArray(manifest.contributions) ||\n !Array.isArray(manifest.migrations) ||\n !Array.isArray(manifest.safeguards)\n ) {\n throw new InformAiError(\n 'Invalid rule pack manifest. Supply packageName, packageVersion, ownedRules, contributions, migrations, and safeguards.',\n );\n }\n if (manifest.apiVersion !== RULE_PACK_API_VERSION) {\n throw new InformAiError(\n `Unsupported manifest API ${manifest.apiVersion} for ${manifest.packageName}. Use API ${RULE_PACK_API_VERSION}.`,\n );\n }\n for (const migration of manifest.migrations) {\n if (\n !migration ||\n !['rule', 'key', 'field'].includes(migration.scope) ||\n typeof migration.key !== 'string' ||\n !migration.key ||\n typeof migration.movedTo !== 'string' ||\n typeof migration.instruction !== 'string' ||\n !migration.instruction ||\n typeof migration.label !== 'string' ||\n typeof migration.prunable !== 'boolean'\n ) {\n throw new InformAiError(\n `Invalid migration in ${manifest.packageName}. Supply the retired key and exact edit.`,\n );\n }\n }\n }\n\n private validateManifest(manifest: RulePackManifest): void {\n for (const definition of manifest.ownedRules) {\n if (!definition || typeof definition.id !== 'string' || definition.id.length === 0) {\n throw new InformAiError(\n `Invalid owned rule in ${manifest.packageName}. Supply a nonempty id.`,\n );\n }\n if (definition.schemaApiVersion !== RULE_SCHEMA_API_VERSION) {\n throw new InformAiError(\n `Unsupported schema API for ${definition.id}. Use API ${RULE_SCHEMA_API_VERSION}.`,\n );\n }\n this.validateSchema(definition.id, definition.schema);\n if (\n !definition.help ||\n typeof definition.help.description !== 'string' ||\n !definition.help.description.trim() ||\n typeof definition.help.remediation !== 'string' ||\n !definition.help.remediation.trim()\n ) {\n throw new InformAiError(\n `Missing catalog help for ${definition.id}. Its owner must supply description and remediation.`,\n );\n }\n this.validateOwnerSettings(definition);\n const mode = definition.schema['mode'];\n if (\n !mode ||\n mode.type !== 'string' ||\n mode.optional ||\n mode.nullable ||\n !mode.enumValues?.includes('OFF')\n ) {\n throw new InformAiError(\n `Policy ${definition.id} must declare a required string mode with explicit OFF opt-out. Fix its owner schema.`,\n );\n }\n }\n }\n\n private validateOwnerSettings(definition: OwnedRuleDefinition): void {\n if (!['rules', 'hookGuards', 'lint'].includes(definition.section)) {\n throw new InformAiError(\n `Invalid config section for ${definition.id}. Use rules, hookGuards, or lint.`,\n );\n }\n const tuning = definition.optionalTuning;\n if (!tuning || typeof tuning !== 'object' || Array.isArray(tuning)) {\n throw new InformAiError(\n `Missing optional tuning for ${definition.id}. Supply an explicit object, including {} when empty.`,\n );\n }\n for (const key of Object.keys(tuning)) {\n const field = definition.schema[key];\n if (\n !field ||\n !field.optional ||\n ['mode', 'turnOffRuleUntilEpoch', 'turnOffRuleWhileOnBranch'].includes(key)\n ) {\n throw new InformAiError(\n `${definition.id}.${key} cannot have a default. Keep required behaviour in explicit repository config.`,\n );\n }\n const errors = this.validateObject(\n definition.id,\n { [key]: field },\n { [key]: tuning[key] },\n );\n if (errors.length) throw new InformAiError(errors.join('\\n'));\n }\n const errors = this.validateObject(\n definition.id,\n definition.schema,\n definition.recommendedSeed,\n );\n if (errors.length)\n throw new InformAiError(\n `Invalid recommended seed: ${errors.join('\\n')}. Fix the owner's seed; the loader never applies it.`,\n );\n }\n\n private validateSchema(location: string, schema: Readonly<Record<string, FieldDef>>): void {\n if (!schema || typeof schema !== 'object' || Array.isArray(schema))\n throw new InformAiError(`Invalid schema for ${location}. Supply a field map.`);\n for (const [key, field] of Object.entries(schema)) {\n if (\n !field ||\n !['string', 'number', 'boolean', 'string[]', 'object[]'].includes(field.type)\n ) {\n throw new InformAiError(\n `Invalid field ${location}.${key}. Supply a supported FieldDef type.`,\n );\n }\n for (const flag of ['optional', 'nullable', 'nonEmpty'] as const) {\n if (field[flag] !== undefined && typeof field[flag] !== 'boolean')\n throw new InformAiError(\n `Invalid ${flag} for ${location}.${key}. Supply a boolean.`,\n );\n }\n if (\n field.enumValues !== undefined &&\n (!Array.isArray(field.enumValues) ||\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n field.enumValues.some((item: unknown) => typeof item !== 'string'))\n ) {\n throw new InformAiError(\n `Invalid enum for ${location}.${key}. Supply string values.`,\n );\n }\n if (field.type === 'object[]')\n this.validateSchema(`${location}.${key}[]`, field.elementSchema!);\n }\n }\n\n private validateObject(\n location: string,\n schema: Readonly<Record<string, FieldDef>>,\n value: ConfigObject,\n ): string[] {\n if (!value || typeof value !== 'object' || Array.isArray(value))\n return [`${location} must be an explicitly configured object.`];\n const errors: string[] = [];\n for (const key of Object.keys(value)) {\n if (Object.hasOwn(schema, key)) continue;\n const fields = new PolicyFieldConstraints();\n const renamed = fields.renamedField(key);\n const retired = this.migrations().find(\n (entry: RetiredConfigKey) =>\n entry.scope === 'field' && entry.key === `${location}.${key}`,\n );\n if (renamed)\n errors.push(\n `${location}.${key} was renamed to ${renamed}. Rename the field; the old spelling is rejected.`,\n );\n else if (retired) errors.push(`${location}.${key}: ${retired.instruction}`);\n else if (fields.isRationale(key)) {\n if (typeof value[key] !== 'string')\n errors.push(`${location}.${key} must be a string rationale note.`);\n } else errors.push(`${location}.${key} is unknown. Use a field declared by its owner.`);\n }\n for (const [key, field] of Object.entries(schema)) {\n const entry = Object.hasOwn(value, key) ? value[key] : undefined,\n label = `${location}.${key}`;\n if (entry === undefined) {\n if (!field.optional)\n errors.push(`${label} is required. Add an explicit ${field.type} value.`);\n continue;\n }\n if (entry === null && field.nullable) continue;\n const valid = field.type.endsWith('[]')\n ? Array.isArray(entry)\n : typeof entry === field.type;\n if (!valid || entry === null) {\n errors.push(`${label} must be ${field.type}.`);\n continue;\n }\n if (field.enumValues && !field.enumValues.includes(String(entry)))\n errors.push(`${label} must be one of ${field.enumValues.join(', ')}.`);\n if (Array.isArray(entry)) {\n if (field.nonEmpty && entry.length === 0)\n errors.push(`${label} must contain at least one entry.`);\n if (\n field.type === 'string[]' &&\n entry.some((item: ConfigValue) => typeof item !== 'string')\n )\n errors.push(`${label} must contain only strings.`);\n if (field.type === 'object[]')\n entry.forEach((item: ConfigValue, index: number) =>\n errors.push(\n ...this.validateObject(\n `${label}[${index}]`,\n field.elementSchema!,\n item as ConfigObject,\n ),\n ),\n );\n }\n }\n return errors;\n }\n}\n\n/** Inject the selected module transport; discovery never names a built-in owner package. */\n@injectable(bindingScopeValues.Singleton)\nexport class RulePackDiscovery {\n constructor(private readonly loader: RulePackModuleLoader) {}\n\n discover(declarations: readonly RulePackDeclaration[]): RulePackRegistry {\n const manifests = declarations.map((declaration: RulePackDeclaration) =>\n this.loader.load(declaration.module),\n );\n const registry = new RulePackRegistry(manifests);\n manifests.forEach((manifest: RulePackManifest, index: number) =>\n registry.recordModuleLocation(manifest.packageName, declarations[index].module),\n );\n return registry;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"rule-pack-registry.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/rule-pack-registry.ts"],"names":[],"mappings":";;;;AAAA,yEAAoE;AACpE,yCAA2D;AAC3D,6CAA4C;AAC5C,8DAA0D;AAC1D,wDAAkC;AAClC,yEAAoE;AACpE,oDAY8B;AAE9B,+FAA+F;AAC/F,MAAsB,oBAAoB;CAEzC;AAFD,oDAEC;AAED,MAAa,wBAAyB,SAAQ,oBAAoB;IAC7C,aAAa,CAAc;IAC3B,UAAU,CAAyB;IAEpD,YAAY,UAAkB;QAC1B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,aAAa,GAAG,IAAA,2BAAa,EAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC,CAAC;QAC1E,IAAI,CAAC,UAAU,GAAG,IAAI,iDAAsB,CAAC,UAAU,CAAC,CAAC;IAC7D,CAAC;IAEQ,IAAI,CAAC,UAAkB;QAC5B,gHAAgH;QAChH,MAAM,OAAO,GAAY,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;QACjF,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,kBAAkB,IAAI,OAAO,CAAC,EAAE,CAAC;YACtF,MAAM,IAAI,8BAAa,CACnB,aAAa,UAAU,gEAAgE,CAC1F,CAAC;QACN,CAAC;QACD,OAAO,OAAO,CAAC,gBAAoC,CAAC;IACxD,CAAC;CACJ;AApBD,4DAoBC;AAED,iGAAiG;AACjG,MAAa,gBAAgB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QAAQ,CAAC,YAA4C;QACjD,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,WAAgC,EAAE,EAAE,CACpE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CACvC,CAAC;QACF,MAAM,QAAQ,GAAG,IAAI,gBAAgB,CAAC,SAAS,CAAC,CAAC;QACjD,SAAS,CAAC,OAAO,CAAC,CAAC,QAA0B,EAAE,KAAa,EAAE,EAAE,CAC5D,QAAQ,CAAC,oBAAoB,CAAC,QAAQ,CAAC,WAAW,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAClF,CAAC;QACF,OAAO,QAAQ,CAAC;IACpB,CAAC;CACJ,CAAA;AAbY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEA,oBAAoB;GADhD,iBAAiB,CAa7B","sourcesContent":["import { PolicyFieldConstraints } from './policy-field-constraints';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { createRequire } from 'node:module';\nimport { InformAiError } from '@webpieces/tooling-common';\nimport * as path from 'node:path';\nimport { ClientModuleResolution } from './client-module-resolution';\nimport {\n FieldDef,\n RulePackManifest,\n RulePackDeclaration,\n OwnedRuleDefinition,\n RULE_PACK_API_VERSION,\n RULE_SCHEMA_API_VERSION,\n ConfigObject,\n RetiredConfigKey,\n SafeguardDefinition,\n RuleConfigSection,\n ConfigValue,\n} from '@webpieces/rules-sdk';\n\n/** Loading is the only impure boundary; callers may supply an alternative module transport. */\nexport abstract class RulePackModuleLoader {\n abstract load(moduleName: string): RulePackManifest;\n}\n\nexport class NodeRulePackModuleLoader extends RulePackModuleLoader {\n private readonly requireModule: NodeRequire;\n private readonly resolution: ClientModuleResolution;\n\n constructor(clientRoot: string) {\n super();\n this.requireModule = createRequire(path.join(clientRoot, 'package.json'));\n this.resolution = new ClientModuleResolution(clientRoot);\n }\n\n override load(moduleName: string): RulePackManifest {\n // webpieces-disable no-any-unknown -- external module boundary; registry validates its exported data before use\n const exports: unknown = this.requireModule(this.resolution.resolve(moduleName));\n if (typeof exports !== 'object' || exports === null || !('rulePackManifest' in exports)) {\n throw new InformAiError(\n `Rule pack ${moduleName} must export rulePackManifest. Add the public manifest export.`,\n );\n }\n return exports.rulePackManifest as RulePackManifest;\n }\n}\n\n/** A registry depends only on declarations and the SDK, never on concrete execution packages. */\nexport class RulePackRegistry {\n private readonly modules = new Map<string, string>();\n private readonly owners = new Map<string, string>();\n private readonly definitions = new Map<string, OwnedRuleDefinition>();\n private readonly safeguards = new Map<string, SafeguardDefinition>();\n\n constructor(readonly manifests: readonly RulePackManifest[]) {\n for (const manifest of manifests) this.validateManifestHeader(manifest);\n const packs = new Set<string>();\n for (const manifest of manifests) {\n this.validateManifest(manifest);\n if (packs.has(manifest.packageName))\n throw new InformAiError(`Duplicate pack ${manifest.packageName}. Declare it once.`);\n packs.add(manifest.packageName);\n for (const definition of manifest.ownedRules) {\n if (this.owners.has(definition.id))\n throw new InformAiError(\n `Rule ${definition.id} has multiple owners. Keep exactly one owner.`,\n );\n this.owners.set(definition.id, manifest.packageName);\n this.definitions.set(definition.id, definition);\n }\n }\n for (const manifest of manifests) {\n for (const safeguard of manifest.safeguards) {\n if (\n !safeguard ||\n typeof safeguard.id !== 'string' ||\n !safeguard.id ||\n !['fixed', 'experimental'].includes(safeguard.activation) ||\n typeof safeguard.description !== 'string' ||\n !safeguard.description\n ) {\n throw new InformAiError(\n 'Invalid safeguard catalog. Supply id, activation, and description.',\n );\n }\n if (this.owners.has(safeguard.id) || this.safeguards.has(safeguard.id)) {\n throw new InformAiError(\n `Safeguard ${safeguard.id} cannot be configured or owned twice. Keep it outside configurable policies.`,\n );\n }\n this.safeguards.set(safeguard.id, safeguard);\n }\n }\n const executions = new Set<string>();\n for (const manifest of manifests) this.registerContributions(manifest, executions);\n }\n\n private registerContributions(manifest: RulePackManifest, executions: Set<string>): void {\n for (const contribution of manifest.contributions) {\n if (\n !contribution ||\n typeof contribution.ruleId !== 'string' ||\n typeof contribution.ownerPack !== 'string'\n ) {\n throw new InformAiError(\n `Invalid contribution in ${manifest.packageName}. Supply ruleId and ownerPack.`,\n );\n }\n if (\n typeof contribution.implementationModule !== 'string' ||\n !contribution.implementationModule.trim()\n ) {\n throw new InformAiError(\n `Missing implementation module for ${contribution.ruleId} in ${manifest.packageName}. Declare its public runtime module.`,\n );\n }\n const owner = this.owners.get(contribution.ruleId);\n if (!owner || owner !== contribution.ownerPack) {\n throw new InformAiError(\n `Unknown owner ${contribution.ownerPack} for ${contribution.ruleId}. Declare the owning pack and use its exact name.`,\n );\n }\n if (\n !['build', 'source-hook', 'workflow-guard', 'lint'].includes(\n contribution.executionKind,\n )\n ) {\n throw new InformAiError(\n `Invalid execution kind for ${contribution.ruleId}. Use build, source-hook, workflow-guard, or lint.`,\n );\n }\n const execution = `${contribution.ruleId}:${contribution.executionKind}`;\n if (executions.has(execution))\n throw new InformAiError(\n `Duplicate execution-kind contribution ${execution}. Keep one implementation per execution kind.`,\n );\n executions.add(execution);\n }\n }\n\n ownerOf(ruleId: string): string {\n const owner = this.owners.get(ruleId);\n if (!owner) throw new InformAiError(`Unknown rule ${ruleId}. Declare its owning pack.`);\n return owner;\n }\n\n schemaFor(ruleId: string): Readonly<Record<string, FieldDef>> {\n this.ownerOf(ruleId);\n return this.definitions.get(ruleId)!.schema;\n }\n\n /** The transport records the exact client declaration, including local manifest modules. */\n recordModuleLocation(packName: string, moduleName: string): void {\n if (\n !this.manifests.some(\n (manifest: RulePackManifest) => manifest.packageName === packName,\n ) ||\n this.modules.has(packName)\n ) {\n throw new InformAiError(\n `Invalid or duplicate module location for ${packName}. Declare each selected pack once.`,\n );\n }\n this.modules.set(packName, moduleName);\n }\n\n get manifestModules(): ReadonlyMap<string, string> {\n return this.modules;\n }\n\n ruleIds(): readonly string[] {\n return [...this.definitions.keys()];\n }\n\n hasRule(ruleId: string): boolean {\n return this.definitions.has(ruleId);\n }\n\n isSafeguard(ruleId: string): boolean {\n return this.safeguards.has(ruleId);\n }\n\n sectionFor(ruleId: string): RuleConfigSection {\n return this.definitionFor(ruleId).section;\n }\n\n optionalTuningFor(ruleId: string): ConfigObject {\n return this.definitionFor(ruleId).optionalTuning;\n }\n\n seedFor(ruleId: string): ConfigObject {\n return structuredClone(this.definitionFor(ruleId).recommendedSeed);\n }\n\n migrations(): readonly RetiredConfigKey[] {\n return this.manifests.flatMap((manifest: RulePackManifest) => [...manifest.migrations]);\n }\n\n safeguardCatalog(): readonly SafeguardDefinition[] {\n return [...this.safeguards.values()];\n }\n\n private definitionFor(ruleId: string): OwnedRuleDefinition {\n this.ownerOf(ruleId);\n return this.definitions.get(ruleId)!;\n }\n\n /** Validates explicit config values with the owner's schema; supplies no rule defaults. */\n validateRuleConfig(ruleId: string, value: ConfigObject): readonly string[] {\n const errors = this.validateObject(ruleId, this.schemaFor(ruleId), value);\n if (value && typeof value['turnOffRuleUntilEpoch'] === 'number') {\n const epoch = new PolicyFieldConstraints().epochError(\n `[${ruleId}]`,\n value['turnOffRuleUntilEpoch'],\n );\n if (epoch) errors.push(epoch);\n }\n return errors;\n }\n\n private validateManifestHeader(manifest: RulePackManifest): void {\n if (\n !manifest ||\n typeof manifest.packageName !== 'string' ||\n manifest.packageName.length === 0 ||\n typeof manifest.packageVersion !== 'string' ||\n manifest.packageVersion.length === 0 ||\n !Array.isArray(manifest.ownedRules) ||\n !Array.isArray(manifest.contributions) ||\n !Array.isArray(manifest.migrations) ||\n !Array.isArray(manifest.safeguards)\n ) {\n throw new InformAiError(\n 'Invalid rule pack manifest. Supply packageName, packageVersion, ownedRules, contributions, migrations, and safeguards.',\n );\n }\n if (manifest.apiVersion !== RULE_PACK_API_VERSION) {\n throw new InformAiError(\n `Unsupported manifest API ${manifest.apiVersion} for ${manifest.packageName}. Use API ${RULE_PACK_API_VERSION}.`,\n );\n }\n for (const migration of manifest.migrations) {\n if (\n !migration ||\n !['rule', 'key', 'field'].includes(migration.scope) ||\n typeof migration.key !== 'string' ||\n !migration.key ||\n typeof migration.movedTo !== 'string' ||\n typeof migration.instruction !== 'string' ||\n !migration.instruction ||\n typeof migration.label !== 'string' ||\n typeof migration.prunable !== 'boolean'\n ) {\n throw new InformAiError(\n `Invalid migration in ${manifest.packageName}. Supply the retired key and exact edit.`,\n );\n }\n }\n }\n\n private validateManifest(manifest: RulePackManifest): void {\n for (const definition of manifest.ownedRules) {\n if (!definition || typeof definition.id !== 'string' || definition.id.length === 0) {\n throw new InformAiError(\n `Invalid owned rule in ${manifest.packageName}. Supply a nonempty id.`,\n );\n }\n if (definition.schemaApiVersion !== RULE_SCHEMA_API_VERSION) {\n throw new InformAiError(\n `Unsupported schema API for ${definition.id}. Use API ${RULE_SCHEMA_API_VERSION}.`,\n );\n }\n this.validateSchema(definition.id, definition.schema);\n if (\n !definition.help ||\n typeof definition.help.description !== 'string' ||\n !definition.help.description.trim() ||\n typeof definition.help.remediation !== 'string' ||\n !definition.help.remediation.trim()\n ) {\n throw new InformAiError(\n `Missing catalog help for ${definition.id}. Its owner must supply description and remediation.`,\n );\n }\n this.validateOwnerSettings(definition);\n const mode = definition.schema['mode'];\n if (\n !mode ||\n mode.type !== 'string' ||\n mode.optional ||\n mode.nullable ||\n !mode.enumValues?.includes('OFF')\n ) {\n throw new InformAiError(\n `Policy ${definition.id} must declare a required string mode with explicit OFF opt-out. Fix its owner schema.`,\n );\n }\n }\n }\n\n private validateOwnerSettings(definition: OwnedRuleDefinition): void {\n if (!['rules', 'hookGuards', 'lint'].includes(definition.section)) {\n throw new InformAiError(\n `Invalid config section for ${definition.id}. Use rules, hookGuards, or lint.`,\n );\n }\n const tuning = definition.optionalTuning;\n if (!tuning || typeof tuning !== 'object' || Array.isArray(tuning)) {\n throw new InformAiError(\n `Missing optional tuning for ${definition.id}. Supply an explicit object, including {} when empty.`,\n );\n }\n for (const key of Object.keys(tuning)) {\n const field = definition.schema[key];\n if (\n !field ||\n !field.optional ||\n ['mode', 'turnOffRuleUntilEpoch', 'turnOffRuleWhileOnBranch'].includes(key)\n ) {\n throw new InformAiError(\n `${definition.id}.${key} cannot have a default. Keep required behaviour in explicit repository config.`,\n );\n }\n const errors = this.validateObject(\n definition.id,\n { [key]: field },\n { [key]: tuning[key] },\n );\n if (errors.length) throw new InformAiError(errors.join('\\n'));\n }\n const errors = this.validateObject(\n definition.id,\n definition.schema,\n definition.recommendedSeed,\n );\n if (errors.length)\n throw new InformAiError(\n `Invalid recommended seed: ${errors.join('\\n')}. Fix the owner's seed; the loader never applies it.`,\n );\n }\n\n private validateSchema(location: string, schema: Readonly<Record<string, FieldDef>>): void {\n if (!schema || typeof schema !== 'object' || Array.isArray(schema))\n throw new InformAiError(`Invalid schema for ${location}. Supply a field map.`);\n for (const [key, field] of Object.entries(schema)) {\n if (\n !field ||\n !['string', 'number', 'boolean', 'string[]', 'object[]'].includes(field.type)\n ) {\n throw new InformAiError(\n `Invalid field ${location}.${key}. Supply a supported FieldDef type.`,\n );\n }\n for (const flag of ['optional', 'nullable', 'nonEmpty'] as const) {\n if (field[flag] !== undefined && typeof field[flag] !== 'boolean')\n throw new InformAiError(\n `Invalid ${flag} for ${location}.${key}. Supply a boolean.`,\n );\n }\n if (field.emptyInstruction !== undefined && typeof field.emptyInstruction !== 'string') {\n throw new InformAiError(`Invalid emptyInstruction for ${location}.${key}. Supply owner-authored cure text.`);\n }\n if (\n field.enumValues !== undefined &&\n (!Array.isArray(field.enumValues) ||\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n field.enumValues.some((item: unknown) => typeof item !== 'string'))\n ) {\n throw new InformAiError(\n `Invalid enum for ${location}.${key}. Supply string values.`,\n );\n }\n if (field.type === 'object[]')\n this.validateSchema(`${location}.${key}[]`, field.elementSchema!);\n }\n }\n\n private validateObject(\n location: string,\n schema: Readonly<Record<string, FieldDef>>,\n value: ConfigObject,\n ): string[] {\n if (!value || typeof value !== 'object' || Array.isArray(value))\n return [`${location} must be an explicitly configured object.`];\n const errors: string[] = [];\n for (const key of Object.keys(value)) {\n if (Object.hasOwn(schema, key)) continue;\n const fields = new PolicyFieldConstraints();\n const renamed = fields.renamedField(key);\n const retired = this.migrations().find(\n (entry: RetiredConfigKey) =>\n entry.scope === 'field' && entry.key === `${location}.${key}`,\n );\n if (renamed)\n errors.push(\n `${location}.${key} was renamed to ${renamed}. Rename the field; the old spelling is rejected.`,\n );\n else if (retired) errors.push(`${location}.${key}: ${retired.instruction}`);\n else if (fields.isRationale(key)) {\n if (typeof value[key] !== 'string')\n errors.push(`${location}.${key} must be a string rationale note.`);\n } else errors.push(`${location}.${key} is unknown. Use a field declared by its owner.`);\n }\n for (const [key, field] of Object.entries(schema)) {\n const entry = Object.hasOwn(value, key) ? value[key] : undefined,\n label = `${location}.${key}`;\n if (entry === undefined) {\n if (!field.optional)\n errors.push(`${label} is required. Add an explicit ${field.type} value.`);\n continue;\n }\n if (entry === null && field.nullable) continue;\n const valid = field.type.endsWith('[]')\n ? Array.isArray(entry)\n : typeof entry === field.type;\n if (!valid || entry === null) {\n errors.push(`${label} must be ${field.type}.`);\n continue;\n }\n if (field.enumValues && !field.enumValues.includes(String(entry)))\n errors.push(`${label} must be one of ${field.enumValues.join(', ')}.`);\n if (Array.isArray(entry)) {\n if (field.nonEmpty && entry.length === 0)\n errors.push(`${label} must contain at least one entry.` +\n (field.emptyInstruction === undefined ? '' : ` ${field.emptyInstruction}`));\n if (\n field.type === 'string[]' &&\n entry.some((item: ConfigValue) => typeof item !== 'string')\n )\n errors.push(`${label} must contain only strings.`);\n if (field.type === 'object[]')\n entry.forEach((item: ConfigValue, index: number) =>\n errors.push(\n ...this.validateObject(\n `${label}[${index}]`,\n field.elementSchema!,\n item as ConfigObject,\n ),\n ),\n );\n }\n }\n return errors;\n }\n}\n\n/** Inject the selected module transport; discovery never names a built-in owner package. */\n@injectable(bindingScopeValues.Singleton)\nexport class RulePackDiscovery {\n constructor(private readonly loader: RulePackModuleLoader) {}\n\n discover(declarations: readonly RulePackDeclaration[]): RulePackRegistry {\n const manifests = declarations.map((declaration: RulePackDeclaration) =>\n this.loader.load(declaration.module),\n );\n const registry = new RulePackRegistry(manifests);\n manifests.forEach((manifest: RulePackManifest, index: number) =>\n registry.recordModuleLocation(manifest.packageName, declarations[index].module),\n );\n return registry;\n }\n}\n"]}
|
package/src/validate-config.js
CHANGED
|
@@ -231,7 +231,8 @@ function arrayFieldErrors(label, value, def) {
|
|
|
231
231
|
}
|
|
232
232
|
if (def.nonEmpty && value.length === 0) {
|
|
233
233
|
return [
|
|
234
|
-
`${label} must not be empty — an empty list judges nothing while reading as configured. Add ${valueHint(def)}
|
|
234
|
+
`${label} must not be empty — an empty list judges nothing while reading as configured. Add ${valueHint(def)}.` +
|
|
235
|
+
(def.emptyInstruction === undefined ? '' : ` ${def.emptyInstruction}`),
|
|
235
236
|
];
|
|
236
237
|
}
|
|
237
238
|
if (!isObjects || def.elementSchema === undefined)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-config.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/validate-config.ts"],"names":[],"mappings":";;;AAuSA,0DA8DC;AA8BD,oDAuBC;AA+FD,8DA4BC;AArhBD,yEAAoE;AACpE,uEAAqE;AAA5D,mIAAA,uBAAuB,OAAA;AAOhC,6CAAqE;AACrE,oDAA2D;AAC3D,6EAMsC;AAK7B,0GAVL,sDAAyB,OAUK;AAJlC,+DAAsF;AACtF,2CAAoD;AAIpD,yFAAyF;AACzF,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,2CAA6F;AAApF,iHAAA,mBAAmB,OAAA;AAAE,oHAAA,sBAAsB,OAAA;AAAE,8GAAA,gBAAgB,OAAA;AACtE,6DAA2D;AAC3D,iEAA6D;AAE7D;;;;;;;;;;GAUG;AAEH;;;;;;GAMG;AACH,wHAAwH;AACxH,SAAS,aAAa,CAAC,KAAa,EAAE,KAAa;IAC/C,OAAO,IAAI,iDAAsB,EA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G;IAClG,mFAAmF;IACnF,IAAI,OAAO,CAAC,CAAC,uBAAuB,CAAC,KAAK,QAAQ,EAAE,CAAC;QACjD,MAAM,CAAC,IAAI,CACP,iBAAiB,KAAK,oGAAoG,CAC7H,CAAC;IACN,CAAC;SAAM,CAAC;QACJ,MAAM,QAAQ,GAAG,aAAa,CAAC,iBAAiB,KAAK,EAAE,EAAE,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC;QACrF,IAAI,QAAQ;YAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;IACD,IACI,CAAC,CACG,CAAC,CAAC,0BAA0B,CAAC,KAAK,IAAI;QACtC,OAAO,CAAC,CAAC,0BAA0B,CAAC,KAAK,QAAQ,CACpD;QAED,MAAM,CAAC,IAAI,CACP,iBAAiB,KAAK,+IAA+I,CACxK,CAAC;IAEN,iEAAiE;IACjE,KAAK,MAAM,MAAM,IAAI,IAAI,iDAAsB,EAAE,CAAC,aAAa,EAAE,EAAE,CAAC;QAChE,IAAI,MAAM,IAAI,CAAC;YACX,MAAM,CAAC,IAAI,CACP,iBAAiB,CAAC,iBAAiB,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,iDAAsB,EAAE,CAAC,YAAY,CAAC,MAAM,CAAE,CAAC,CAC1G,CAAC;IACV,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { PolicyFieldConstraints } from './policy-field-constraints';\nexport { MAX_TURN_OFF_EPOCH_DAYS } from './policy-field-constraints';\nimport { FieldDef, RetiredConfigKey } from '@webpieces/rules-sdk';\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nimport { RulePackRegistry } from './rule-pack-registry';\nimport { allRuleNames } from './rule-schemas';\nimport { recommendedSeedModeFor, isGradualMode } from './seed-entry';\nimport { MODIFIED_CODE_MODES } from '@webpieces/rules-sdk';\nimport {\n validateChecklistsSection,\n validateDevDeploySection,\n validateLandPrSection,\n validateNoGateSaltRationale,\n validateReviewerAgentKeys,\n} from './pr-gate-section-validators';\nimport { retiredEntry, retiredKeyError, retiredRuleFor } from './retired-config-keys';\nimport { PRUNE_UNKNOWN_COMMAND } from './constants';\n\n// Re-exported so the isolated validate-checklist-docs target keeps importing it from here.\nexport { validateChecklistsSection };\n// Re-exported from their new homes: this module was the historical entry point for both.\nexport { allRuleNames } from './rule-schemas';\nexport { recommendedSeedMode, recommendedSeedModeFor, seedEntryForRule } from './seed-entry';\nimport { DEFAULT_MATCH_RULES } from './match-rules-config';\nimport { toError } from '@webpieces/tooling-common/to-error';\n\n/**\n * The longest a `turnOffRuleUntilEpoch` may reach into the future: ONE WEEK. Poke it again next week to\n * extend — that weekly re-set IS the intended workflow, not a workaround: it is what makes a rule that is\n * off on purpose stay a decision somebody keeps making, instead of one nobody remembers.\n *\n * DELIBERATELY ASYMMETRIC with turnOffRuleWhileOnBranch, which has NO cap and must not get one. The epoch\n * hatch is REPO-WIDE while it lasts, so a long window shelters every unrelated change that lands inside it\n * (a fleet repo was found with max-file-lines/max-method-lines switched off until 2026-10-01 — 43 days\n * out, six times this cap). The branch hatch fires only on ONE exact branch name — a big refactor\n * legitimately runs 35+ days, and capping that would only interrupt the one branch that opted in.\n */\n\n/**\n * Reject a `turnOffRuleUntilEpoch` more than MAX_TURN_OFF_EPOCH_DAYS into the future.\n *\n * A PAST epoch is always valid: it is inert (it skips nothing), and every existing config is full of them.\n * The BOUNDARY is inclusive — exactly MAX_TURN_OFF_EPOCH_DAYS out is accepted, only strictly beyond it is\n * refused — so a config written as \"now + 7 days\" is never rejected by the second it took to save.\n */\n// webpieces-disable no-function-outside-class -- module-scope validator helper, matching every other check in this file\nfunction epochCapError(label: string, value: number): string | null {\n return new PolicyFieldConstraints().epochError(label, value);\n}\n\nfunction valueHint(def: FieldDef, key?: string): string {\n // The two universal escape hatches, REQUIRED on every rule so they're always visible. Spell out the\n // \"off\" value so a fresh config seeds them in the active/no-op state (0 / null), not a placeholder.\n if (key === 'turnOffRuleUntilEpoch')\n return '0 (0 = active; future unix-epoch seconds = temporarily off)';\n if (key === 'turnOffRuleWhileOnBranch')\n return 'null (null = always on; an EXACT branch name — no globs — disables the rule while that branch is checked out)';\n return def.enumValues\n ? `\"${def.enumValues.join(' | ')}\"`\n : def.type === 'string[]'\n ? '[\"<string>\", ...]'\n : def.type === 'object[]'\n ? objectListHint(def)\n : def.type === 'number'\n ? '<number>'\n : def.type === 'boolean'\n ? '<boolean>'\n : '\"<string>\"';\n}\n\n/** `[{ \"paths\": [\"<string>\", ...], \"suffixes\": [\"<string>\", ...] }, ...]` — one element spelled out from its schema. */\n// webpieces-disable no-function-outside-class -- module-scope sibling of valueHint\nfunction objectListHint(def: FieldDef): string {\n const schema: Readonly<Record<string, FieldDef>> = def.elementSchema ?? {};\n const fields = Object.keys(schema)\n .filter((key: string) => !schema[key].optional)\n .map((key: string) => `\"${key}\": ${valueHint(schema[key], key)}`);\n return `[{ ${fields.join(', ')} }, ...]`;\n}\n\n/**\n * A config key whose schema is absent from every explicitly selected owner manifest. THE FALLBACK: it fires for any name the table in retired-config-keys.ts does not\n * know, which very much includes RETIRED names on a tree whose validator predates the retirement — the\n * ordinary linked-worktree layout, where the worktree is on one release and the parent checkout that\n * supplies the hook's resolution is on an older one. So this text has to be useful with NO table entry.\n *\n * DELETION LEADS, and it is not a hedge. A key the running validator has no schema for controls nothing:\n * every code path that would read it is keyed off the schema. Leaving it is dead config that reads as live\n * config, and for a retired key deleting it is the entire fix.\n *\n * This message used to lead with `pnpm install` instead, on the theory that the key might be valid and the\n * validator merely stale. Two things are wrong with that. First, it CONTRADICTED the banner this error is\n * printed inside, which states outright that `pnpm install` cannot help — one output, two opposite orders.\n * Second, the premise is already handled upstream: the shim's version-drift guard compares the pin against\n * the installed version and denies every tool call BEFORE exec'ing this validator, with its own message and\n * its own cure. If this text is on screen, that guard found no drift. The pin therefore appears here only as\n * a secondary note, so a valid-but-newer key is never dropped without the reader being told the case exists.\n */\nfunction unknownRuleError(ruleName: string): string {\n return (\n `[${ruleName}] Unknown rule — the running @webpieces validator has no selected owner schema for it. A key no validator knows controls NOTHING, so ` +\n `DELETE the \"${ruleName}\" key from the direct policy-ID map in its declared owner config file. ` +\n `Run \\`${PRUNE_UNKNOWN_COMMAND}\\` to remove unknown entries from declared owner files mechanically. ` +\n `It may be RETIRED: a newer release can move ` +\n `a setting out of this file entirely, in which case deleting the key here is the WHOLE fix. ` +\n `MACHINE-LOCAL settings in particular now live in ~/.webpieces/config.json under \"experimental\" — ` +\n `an optional file tracked by no repo, whose absence is the default behaviour — so if ` +\n `\"${ruleName}\" is one of those, delete it here and set it there. Secondary, and rare: a key is ` +\n `valid-but-unlearned when package.json pins an @webpieces OLDER than this config was written for, ` +\n `and the version-drift guard reports THAT separately with its own cure (bump the pin) before this ` +\n `validator ever runs — so it is not what you are looking at.`\n );\n}\n\n/** Schema advice names the selected owner rather than a retired root section. */\nclass RuleConfigAdvice {\n constructor(private readonly registry: RulePackRegistry) {}\n\n private rolloutTip(schema: Readonly<Record<string, FieldDef>>): string {\n const modes = schema['mode']?.enumValues ?? [];\n // Same source of truth as the seeder; only a GRADUAL recommendation gets the rollout prose, so a\n // rule whose recommendation falls through to ON/RUN_EVERY_TIME/OFF prints no tip (as before).\n const recommended = recommendedSeedModeFor(modes);\n if (!isGradualMode(recommended)) return '';\n const optOut = modes.includes('OFF') ? ' Set \"mode\": \"OFF\" to opt out entirely.' : '';\n return (\n `\\n\\n💡 Recommended: start with \"mode\": \"${recommended}\" — it enforces only on what you ` +\n `actually change, so the rule rolls out gradually (existing code stays grandfathered until ` +\n `you next touch that project/file/method).${optOut}`\n );\n }\n\n missingRuleSnippet(ruleName: string, schema: Readonly<Record<string, FieldDef>>): string {\n // Required fields go in the copy-paste entry. The two universal escape hatches\n // (turnOffRuleUntilEpoch / turnOffRuleWhileOnBranch) are now REQUIRED, so they land in that block —\n // which is the whole point: every seeded rule shows both hatches. Optional fields are listed separately.\n const fields = Object.keys(schema);\n const required = fields.filter((f: string) => !schema[f].optional);\n const optional = fields.filter((f: string) => schema[f].optional);\n\n const requiredLines = required.map((f: string) => ` \"${f}\": ${valueHint(schema[f], f)}`);\n const owner = this.registry.ownerOf(ruleName);\n let out =\n `[${ruleName}] Not configured in the declared owner config file for ${owner}. ` +\n `Add this entry directly to that file's policy-ID map\\n` +\n `(choose values appropriate for your project):\\n\\n` +\n ` \"${ruleName}\": {\\n${requiredLines.join(',\\n')}\\n }`;\n\n if (optional.length > 0) {\n const optionalLines = optional.map(\n (f: string) => ` \"${f}\": ${valueHint(schema[f], f)}`,\n );\n out +=\n `\\n\\nOptional fields you may add to this rule (omit if not needed):\\n` +\n `${optionalLines.join(',\\n')}`;\n }\n out += this.rolloutTip(schema);\n return out;\n }\n}\n\n// Fields we DELETED from a rule's schema, keyed by \"<rule>.<field>\". The generic unknown-field error\n// (\"Unknown field ... Valid fields: [...]\") is correct but doesn't say WHY the field vanished, so an AI\n// might re-add it. These hints explain the removal so the only action left is to delete the key.\n\n// Universal field renames (apply to EVERY rule/guard AND every match-rule, unlike the per-rule\n// RETIRED_FIELD_HINTS). When an entry still uses the old escape-hatch name, the generic unknown-field\n// error is replaced with a precise \"renamed to X — rename it\" instruction so the fix is mechanical.\n\n\n// The renamed-field message shared by keyed rules and match-rules.\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nfunction renamedFieldError(scope: string, oldKey: string, newKey: string): string {\n return `${scope} Unknown field \"${oldKey}\" — it was renamed to \"${newKey}\". Rename it (the value carries over unchanged; for the branch hatch, use null when there is no branch).`;\n}\n\n/**\n * Field-level errors for ONE configured rule entry: unknown/renamed/retired keys, type and enum\n * mismatches, and the two-week cap on turnOffRuleUntilEpoch.\n *\n * Extracted out of validateWebpiecesConfig purely so that function stays inside max-method-lines; it is\n * the same checks in the same order.\n */\n// webpieces-disable no-any-unknown -- one config entry as opaque JSON; every field is typed-checked below\n// webpieces-disable no-function-outside-class -- module-scope validator helper, matching every other check in this file\nfunction fieldErrors(\n ruleName: string,\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n entry: Record<string, unknown>,\n schema: Readonly<Record<string, FieldDef>>,\n registry: RulePackRegistry,\n): string[] {\n const errors: string[] = [];\n for (const [key, value] of Object.entries(entry)) {\n const fieldDef = schema[key];\n if (!fieldDef) {\n const renamedTo = new PolicyFieldConstraints().renamedField(key);\n if (renamedTo) {\n errors.push(renamedFieldError(`[${ruleName}]`, key, renamedTo));\n continue;\n }\n const retiredHint = registry\n .migrations()\n .find(\n (entry: RetiredConfigKey) =>\n entry.scope === 'field' && entry.key === `${ruleName}.${key}`,\n )?.instruction;\n const suffix = retiredHint ? ` ${retiredHint}` : '';\n errors.push(\n `[${ruleName}] Unknown field \"${key}\". Valid fields: [${Object.keys(schema).join(', ')}].${suffix}`,\n );\n continue;\n }\n // A nullable field (e.g. turnOffRuleWhileOnBranch) accepts JSON null in addition to its type.\n if (value === null && fieldDef.nullable) continue;\n if (fieldDef.type === 'string[]' || fieldDef.type === 'object[]') {\n errors.push(...arrayFieldErrors(`[${ruleName}] \"${key}\"`, value, fieldDef));\n } else if (typeof value !== fieldDef.type) {\n errors.push(`[${ruleName}] \"${key}\" must be ${fieldDef.type}, got ${typeof value}.`);\n } else if (fieldDef.enumValues && !fieldDef.enumValues.includes(value as string)) {\n errors.push(\n `[${ruleName}] \"${key}\" = \"${value}\" is not valid. Must be one of: ${fieldDef.enumValues.join(', ')}.`,\n );\n } else if (key === 'turnOffRuleUntilEpoch') {\n const capError = epochCapError(`[${ruleName}]`, value as number);\n if (capError) errors.push(capError);\n } else if (\n ruleName === 'branch-state-guard' &&\n key === 'maxCommitsBehind' &&\n (!Number.isInteger(value) || (value as number) < 0)\n ) {\n errors.push('[branch-state-guard] \"maxCommitsBehind\" must be a non-negative integer.');\n }\n }\n return errors;\n}\n\n/**\n * Errors for one array-typed field (`string[]` / `object[]`): the element type, `nonEmpty`, and — for\n * `object[]` — every element against the field's `elementSchema` (unknown keys, missing required keys,\n * and each element field checked recursively). `label` is `[rule] \"field\"`, extended per element\n * (`[rule] \"entries\"[0].suffixes`) so an error names the exact spot to edit.\n */\n// webpieces-disable no-any-unknown -- a config field value is opaque JSON until this checks its shape\n// webpieces-disable no-function-outside-class -- module-scope validator helper, matching every other check in this file\n// webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\nfunction arrayFieldErrors(label: string, value: unknown, def: FieldDef): string[] {\n const isObjects = def.type === 'object[]';\n // webpieces-disable no-any-unknown -- one list element as opaque JSON; this line is what checks its shape\n const elementOk = (v: unknown): boolean =>\n isObjects\n ? typeof v === 'object' && v !== null && !Array.isArray(v)\n : typeof v === 'string';\n if (!Array.isArray(value) || !value.every(elementOk)) {\n const shape = isObjects ? 'a list of objects' : 'string[]';\n return [\n `${label} must be ${shape}, got ${Array.isArray(value) ? 'a list holding something else' : typeof value}.`,\n ];\n }\n if (def.nonEmpty && value.length === 0) {\n return [\n `${label} must not be empty — an empty list judges nothing while reading as configured. Add ${valueHint(def)}.`,\n ];\n }\n if (!isObjects || def.elementSchema === undefined) return [];\n const errors: string[] = [];\n const schema = def.elementSchema;\n // webpieces-disable no-any-unknown -- an element's fields are opaque JSON until checked against its schema below\n value.forEach((element: Record<string, unknown>, index: number) => {\n const at = `${label}[${index}]`;\n for (const key of Object.keys(element)) {\n if (!(key in schema))\n errors.push(\n `${at} Unknown field \"${key}\". Valid fields: [${Object.keys(schema).join(', ')}].`,\n );\n }\n for (const [key, fieldDef] of Object.entries(schema)) {\n if (!(key in element)) {\n if (!fieldDef.optional)\n errors.push(\n `${at} Missing required field \"${key}\". Add ${key}: ${valueHint(fieldDef, key)}.`,\n );\n } else if (fieldDef.type === 'string[]' || fieldDef.type === 'object[]') {\n errors.push(...arrayFieldErrors(`${at}.${key}`, element[key], fieldDef));\n } else if (typeof element[key] !== fieldDef.type) {\n errors.push(`${at}.${key} must be ${fieldDef.type}, got ${typeof element[key]}.`);\n }\n }\n });\n return errors;\n}\n\n// webpieces-disable no-any-unknown -- rawRules values are opaque JSON; each field is validated individually\nexport function validateWebpiecesConfig(\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n rawRules: Record<string, Record<string, unknown>>,\n registry: RulePackRegistry,\n): string[] {\n const errors: string[] = [];\n const advice = new RuleConfigAdvice(registry);\n\n // Check field-level correctness for rules that are present\n for (const [ruleName, entry] of Object.entries(rawRules)) {\n const schema = registry.hasRule(ruleName) ? registry.schemaFor(ruleName) : undefined;\n if (!schema) {\n if (\n registry.isSafeguard(ruleName) &&\n !registry\n .migrations()\n .some(\n (entry: RetiredConfigKey) =>\n entry.scope === 'rule' && entry.key === ruleName,\n )\n ) {\n errors.push(\n `[${ruleName}] is a cataloged safeguard, not a configurable policy. Delete its config entry; fixed safety cannot be disabled.`,\n );\n continue;\n }\n // A name we KNOW is retired beats the generic unknown-rule message, because only the table\n // knows WHERE the setting went — a rename carries its value over, and a bare \"delete it\"\n // would throw that value away. Client packs must not reuse a retired canonical ID.\n const retired = retiredRuleFor(ruleName, registry);\n if (retired) {\n errors.push(retiredKeyError(retired));\n continue;\n }\n // Client policies require a schema from an explicitly selected owner.\n errors.push(unknownRuleError(ruleName));\n continue;\n }\n errors.push(...fieldErrors(ruleName, entry, schema, registry));\n // Required fields must actually be present. Until now the loop above only checked\n // fields that WERE present, so an entry like `{}` (or one missing `mode` /\n // `turnOffRuleUntilEpoch`) slipped through. Every non-optional schema field is mandatory.\n for (const [key, fieldDef] of Object.entries(schema)) {\n if (!fieldDef.optional && !(key in entry)) {\n errors.push(\n `[${ruleName}] Missing required field \"${key}\". Add ${key}: ${valueHint(fieldDef, key)}.`,\n );\n }\n }\n }\n\n // Every built-in rule must be explicitly configured — no silent defaults.\n // When a new rule is added to the framework, this check surfaces it immediately\n // with a ready-to-copy snippet so AI can configure it in one pass.\n for (const ruleName of registry.ruleIds()) {\n const schema = registry.schemaFor(ruleName);\n if (!(ruleName in rawRules)) {\n errors.push(advice.missingRuleSnippet(ruleName, schema));\n }\n }\n\n return errors;\n}\n\nexport { validatePrGateSection } from './validate-pr-gate';\n\nfunction excludePathsExample(): string {\n return '\"excludePaths\": [\"repositories/**\"]';\n}\n\n// A glob list: must be a string[] (may be empty). `key` names it for the error.\n// webpieces-disable no-any-unknown -- `value` is opaque consumer JSON until narrowed here\nfunction validateExcludeList(value: unknown, key: string): string[] {\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n if (!(Array.isArray(value) && value.every((p: unknown) => typeof p === 'string'))) {\n return [`[excludePaths] \"${key}\" must be a string[] of glob paths (use [] for none).`];\n }\n return [];\n}\n\n/**\n * Validate the REQUIRED top-level `excludePaths` block: ONE glob list suppressing hook enforcement per\n * file path, for code-style rules and file-scoped guards alike. Required so every client upgrading is\n * forced to declare it (as [] to keep today's behavior, or with real paths). Returns copy-paste\n * friendly errors and never throws — same contract as validatePrGateSection.\n *\n * The two-list object form `{ \"rules\": [...], \"guards\": [...] }` is RETIRED, not tolerated. It used to be\n * accepted and silently unioned, which is why this repo's own config sat on the dead shape for releases: an\n * accepted shape is never migrated. Rejecting it cannot wedge a consumer — editing webpieces.config.json is\n * always permitted, even while it is invalid. See retired-config-keys.ts.\n */\n// webpieces-disable no-any-unknown -- `section` is opaque consumer JSON until narrowed below\nexport function validateExcludePaths(section: unknown): string[] {\n if (section === undefined || section === null) {\n return [\n `[excludePaths] Not configured in webpieces.config.json. Add this REQUIRED block ` +\n `(use an empty array to keep enforcing everywhere):\\n\\n ${excludePathsExample()}`,\n ];\n }\n if (Array.isArray(section)) return validateExcludeList(section, 'excludePaths');\n if (typeof section !== 'object') {\n return [\n `[excludePaths] Must be a string[] of glob paths. Example:\\n\\n ${excludePathsExample()}`,\n ];\n }\n // webpieces-disable no-any-unknown -- narrowing the opaque excludePaths section from consumer JSON\n const s = section as Record<string, unknown>;\n // The retired two-list object. One table row owns the message for either key present.\n const retired = retiredEntry('rules', '[excludePaths]');\n if (retired && (s['rules'] !== undefined || s['guards'] !== undefined)) {\n return [`${retiredKeyError(retired)}\\n\\n ${excludePathsExample()}`];\n }\n return [\n `[excludePaths] Must be a string[] of glob paths. Example:\\n\\n ${excludePathsExample()}`,\n ];\n}\n\n// ---------------------------------------------------------------------------\n// match-rules — a new top-level ARRAY section (parallel to pr-gate/excludePaths). Each entry is a\n// client-authored content guard (raw-regex patterns + message + scoping). Validated structurally here\n// the same way pr-gate's `gates` are, because an array of objects can't be expressed in FieldDef schema.\n// ---------------------------------------------------------------------------\n\nfunction matchRulesExample(): string {\n return `\"match-rules\": ${JSON.stringify(DEFAULT_MATCH_RULES, null, 4)}`;\n}\n\n// webpieces-disable no-any-unknown -- generic type guard over an opaque JSON value\nfunction isStringArray(value: unknown): value is string[] {\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n return Array.isArray(value) && value.every((v: unknown) => typeof v === 'string');\n}\n\n// Compile a pattern to validate it; returns the error message, or undefined when it compiles.\nfunction regexError(pattern: string): string | undefined {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n // Constructed only to validate the syntax; the object is intentionally discarded.\n void new RegExp(pattern);\n return undefined;\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 error.message;\n }\n}\n\n// One entry of the match-rules array, validated field-by-field (see validateGate for the pattern).\n// webpieces-disable no-any-unknown -- one match-rule entry from opaque consumer JSON, validated field-by-field\nfunction validateMatchRule(entry: unknown, index: number): string[] {\n if (typeof entry !== 'object' || entry === null || Array.isArray(entry)) {\n return [\n `[match-rules] entry[${index}] must be an object { name, patterns, mainMessage, mode, turnOffRuleUntilEpoch, turnOffRuleWhileOnBranch, ... }.`,\n ];\n }\n // webpieces-disable no-any-unknown -- narrowing one opaque match-rule entry from consumer JSON\n const e = entry as Record<string, unknown>;\n const label = typeof e['name'] === 'string' ? `\"${e['name']}\"` : `entry[${index}]`;\n const errors: string[] = [];\n\n if (typeof e['name'] !== 'string' || e['name'].trim() === '')\n errors.push(\n `[match-rules] entry[${index}].name must be a non-empty string (it is the disable token and report label).`,\n );\n\n if (!isStringArray(e['patterns']) || e['patterns'].length === 0) {\n errors.push(`[match-rules] ${label}.patterns must be a non-empty string[] of regexes.`);\n } else {\n e['patterns'].forEach((p: string, pi: number) => {\n const rxErr = regexError(p);\n if (rxErr)\n errors.push(\n `[match-rules] ${label}.patterns[${pi}] is not a valid regex: ${rxErr}`,\n );\n });\n }\n\n if (typeof e['mainMessage'] !== 'string' || e['mainMessage'].trim() === '')\n errors.push(`[match-rules] ${label}.mainMessage must be a non-empty string.`);\n\n if (\n typeof e['mode'] !== 'string' ||\n !MODIFIED_CODE_MODES.includes(e['mode'] as (typeof MODIFIED_CODE_MODES)[number])\n )\n errors.push(\n `[match-rules] ${label}.mode must be one of: ${MODIFIED_CODE_MODES.join(', ')}.`,\n );\n\n errors.push(...validateMatchRuleHatches(e, label));\n\n if (e['options'] !== undefined && !isStringArray(e['options']))\n errors.push(`[match-rules] ${label}.options must be a string[] (omit if not needed).`);\n if (e['allowedPaths'] !== undefined && !isStringArray(e['allowedPaths']))\n errors.push(\n `[match-rules] ${label}.allowedPaths must be a string[] of globs (omit if not needed).`,\n );\n if (e['disableAllowed'] !== undefined && typeof e['disableAllowed'] !== 'boolean')\n errors.push(`[match-rules] ${label}.disableAllowed must be a boolean.`);\n\n return errors;\n}\n\n/**\n * Validate the REQUIRED top-level `match-rules` array (client-authored content guards). MISSING →\n * one error printing the ready-to-paste `no-fetch` example (add at least this; more can follow).\n * Present-but-`[]` → allowed (a conscious opt-out, matching pr-gate mode:OFF / excludePaths []).\n * Otherwise every entry is validated field-by-field (each regex compile-checked) plus name\n * uniqueness. Copy-paste-friendly errors; never throws — same contract as validatePrGateSection.\n */\n// webpieces-disable no-any-unknown -- `section` is opaque consumer JSON until narrowed below\nexport function validateMatchRulesSection(section: unknown): string[] {\n if (section === undefined || section === null) {\n return [\n `[match-rules] Not configured in webpieces.config.json. Add this REQUIRED top-level array — ` +\n `seed it with the no-fetch guard below (you can add more entries: no-moment, no-lodash-chain, …):\\n\\n${matchRulesExample()}`,\n ];\n }\n if (!Array.isArray(section)) {\n return [\n `[match-rules] Must be an array of content-guard objects. Example:\\n\\n${matchRulesExample()}`,\n ];\n }\n\n const errors: string[] = [];\n const seen = new Set<string>();\n for (let i = 0; i < section.length; i += 1) {\n errors.push(...validateMatchRule(section[i], i));\n // webpieces-disable no-any-unknown -- reading the name off an opaque entry only to dedupe\n const name = (section[i] as Record<string, unknown> | null)?.['name'];\n if (typeof name === 'string') {\n if (seen.has(name))\n errors.push(\n `[match-rules] duplicate entry name \"${name}\" — each match-rule name must be unique.`,\n );\n seen.add(name);\n }\n }\n return errors;\n}\n\n// webpieces-disable no-any-unknown -- explicit match-rule JSON is checked field by field\n// webpieces-disable no-function-outside-class -- pure validation helper\nfunction validateMatchRuleHatches(e: Record<string, unknown>, label: string): string[] {\n const errors: string[] = [];\n // Both escape hatches are REQUIRED on every match-rule too (same as keyed rules), so they are always\n // visible. turnOffRuleUntilEpoch: number (0 = active; a future unix-epoch in seconds = temporarily\n // off). turnOffRuleWhileOnBranch: string | null (null = always on; an EXACT branch name — matched\n // with ===, never as a glob — disables the rule while that branch is checked out).\n if (typeof e['turnOffRuleUntilEpoch'] !== 'number') {\n errors.push(\n `[match-rules] ${label}.turnOffRuleUntilEpoch must be a number (0 = active; future unix-epoch seconds = temporarily off).`,\n );\n } else {\n const capError = epochCapError(`[match-rules] ${label}`, e['turnOffRuleUntilEpoch']);\n if (capError) errors.push(capError);\n }\n if (\n !(\n e['turnOffRuleWhileOnBranch'] === null ||\n typeof e['turnOffRuleWhileOnBranch'] === 'string'\n )\n )\n errors.push(\n `[match-rules] ${label}.turnOffRuleWhileOnBranch must be a string or null (null = no branch / always on; a string is an EXACT branch name, globs are not supported).`,\n );\n\n // The old escape-hatch names were renamed — flag them precisely.\n for (const oldKey of new PolicyFieldConstraints().retiredFields()) {\n if (oldKey in e)\n errors.push(\n renamedFieldError(`[match-rules] ${label}`, oldKey, new PolicyFieldConstraints().renamedField(oldKey)!),\n );\n }\n\n return errors;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"validate-config.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/validate-config.ts"],"names":[],"mappings":";;;AAwSA,0DA8DC;AA8BD,oDAuBC;AA+FD,8DA4BC;AAthBD,yEAAoE;AACpE,uEAAqE;AAA5D,mIAAA,uBAAuB,OAAA;AAOhC,6CAAqE;AACrE,oDAA2D;AAC3D,6EAMsC;AAK7B,0GAVL,sDAAyB,OAUK;AAJlC,+DAAsF;AACtF,2CAAoD;AAIpD,yFAAyF;AACzF,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,2CAA6F;AAApF,iHAAA,mBAAmB,OAAA;AAAE,oHAAA,sBAAsB,OAAA;AAAE,8GAAA,gBAAgB,OAAA;AACtE,6DAA2D;AAC3D,iEAA6D;AAE7D;;;;;;;;;;GAUG;AAEH;;;;;;GAMG;AACH,wHAAwH;AACxH,SAAS,aAAa,CAAC,KAAa,EAAE,KAAa;IAC/C,OAAO,IAAI,iDAAsB,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AACjE,CAAC;AAED,SAAS,SAAS,CAAC,GAAa,EAAE,GAAY;IAC1C,oGAAoG;IACpG,oGAAoG;IACpG,IAAI,GAAG,KAAK,uBAAuB;QAC/B,OAAO,8DAA8D,CAAC;IAC1E,IAAI,GAAG,KAAK,0BAA0B;QAClC,OAAO,gHAAgH,CAAC;IAC5H,OAAO,GAAG,CAAC,UAAU;QACjB,CAAC,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG;QACnC,CAAC,CAAC,GAAG,CAAC,IAAI,KAAK,UAAU;YACvB,CAAC,CAAC,mBAAmB;YACrB,CAAC,CAAC,GAAG,CAAC,IAAI,KAAK,UAAU;gBACvB,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC;gBACrB,CAAC,CAAC,GAAG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O,CAAC,CAAC,0BAA0B,CAAC,KAAK,QAAQ,CACpD;QAED,MAAM,CAAC,IAAI,CACP,iBAAiB,KAAK,+IAA+I,CACxK,CAAC;IAEN,iEAAiE;IACjE,KAAK,MAAM,MAAM,IAAI,IAAI,iDAAsB,EAAE,CAAC,aAAa,EAAE,EAAE,CAAC;QAChE,IAAI,MAAM,IAAI,CAAC;YACX,MAAM,CAAC,IAAI,CACP,iBAAiB,CAAC,iBAAiB,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,iDAAsB,EAAE,CAAC,YAAY,CAAC,MAAM,CAAE,CAAC,CAC1G,CAAC;IACV,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { PolicyFieldConstraints } from './policy-field-constraints';\nexport { MAX_TURN_OFF_EPOCH_DAYS } from './policy-field-constraints';\nimport { FieldDef, RetiredConfigKey } from '@webpieces/rules-sdk';\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nimport { RulePackRegistry } from './rule-pack-registry';\nimport { allRuleNames } from './rule-schemas';\nimport { recommendedSeedModeFor, isGradualMode } from './seed-entry';\nimport { MODIFIED_CODE_MODES } from '@webpieces/rules-sdk';\nimport {\n validateChecklistsSection,\n validateDevDeploySection,\n validateLandPrSection,\n validateNoGateSaltRationale,\n validateReviewerAgentKeys,\n} from './pr-gate-section-validators';\nimport { retiredEntry, retiredKeyError, retiredRuleFor } from './retired-config-keys';\nimport { PRUNE_UNKNOWN_COMMAND } from './constants';\n\n// Re-exported so the isolated validate-checklist-docs target keeps importing it from here.\nexport { validateChecklistsSection };\n// Re-exported from their new homes: this module was the historical entry point for both.\nexport { allRuleNames } from './rule-schemas';\nexport { recommendedSeedMode, recommendedSeedModeFor, seedEntryForRule } from './seed-entry';\nimport { DEFAULT_MATCH_RULES } from './match-rules-config';\nimport { toError } from '@webpieces/tooling-common/to-error';\n\n/**\n * The longest a `turnOffRuleUntilEpoch` may reach into the future: ONE WEEK. Poke it again next week to\n * extend — that weekly re-set IS the intended workflow, not a workaround: it is what makes a rule that is\n * off on purpose stay a decision somebody keeps making, instead of one nobody remembers.\n *\n * DELIBERATELY ASYMMETRIC with turnOffRuleWhileOnBranch, which has NO cap and must not get one. The epoch\n * hatch is REPO-WIDE while it lasts, so a long window shelters every unrelated change that lands inside it\n * (a fleet repo was found with max-file-lines/max-method-lines switched off until 2026-10-01 — 43 days\n * out, six times this cap). The branch hatch fires only on ONE exact branch name — a big refactor\n * legitimately runs 35+ days, and capping that would only interrupt the one branch that opted in.\n */\n\n/**\n * Reject a `turnOffRuleUntilEpoch` more than MAX_TURN_OFF_EPOCH_DAYS into the future.\n *\n * A PAST epoch is always valid: it is inert (it skips nothing), and every existing config is full of them.\n * The BOUNDARY is inclusive — exactly MAX_TURN_OFF_EPOCH_DAYS out is accepted, only strictly beyond it is\n * refused — so a config written as \"now + 7 days\" is never rejected by the second it took to save.\n */\n// webpieces-disable no-function-outside-class -- module-scope validator helper, matching every other check in this file\nfunction epochCapError(label: string, value: number): string | null {\n return new PolicyFieldConstraints().epochError(label, value);\n}\n\nfunction valueHint(def: FieldDef, key?: string): string {\n // The two universal escape hatches, REQUIRED on every rule so they're always visible. Spell out the\n // \"off\" value so a fresh config seeds them in the active/no-op state (0 / null), not a placeholder.\n if (key === 'turnOffRuleUntilEpoch')\n return '0 (0 = active; future unix-epoch seconds = temporarily off)';\n if (key === 'turnOffRuleWhileOnBranch')\n return 'null (null = always on; an EXACT branch name — no globs — disables the rule while that branch is checked out)';\n return def.enumValues\n ? `\"${def.enumValues.join(' | ')}\"`\n : def.type === 'string[]'\n ? '[\"<string>\", ...]'\n : def.type === 'object[]'\n ? objectListHint(def)\n : def.type === 'number'\n ? '<number>'\n : def.type === 'boolean'\n ? '<boolean>'\n : '\"<string>\"';\n}\n\n/** `[{ \"paths\": [\"<string>\", ...], \"suffixes\": [\"<string>\", ...] }, ...]` — one element spelled out from its schema. */\n// webpieces-disable no-function-outside-class -- module-scope sibling of valueHint\nfunction objectListHint(def: FieldDef): string {\n const schema: Readonly<Record<string, FieldDef>> = def.elementSchema ?? {};\n const fields = Object.keys(schema)\n .filter((key: string) => !schema[key].optional)\n .map((key: string) => `\"${key}\": ${valueHint(schema[key], key)}`);\n return `[{ ${fields.join(', ')} }, ...]`;\n}\n\n/**\n * A config key whose schema is absent from every explicitly selected owner manifest. THE FALLBACK: it fires for any name the table in retired-config-keys.ts does not\n * know, which very much includes RETIRED names on a tree whose validator predates the retirement — the\n * ordinary linked-worktree layout, where the worktree is on one release and the parent checkout that\n * supplies the hook's resolution is on an older one. So this text has to be useful with NO table entry.\n *\n * DELETION LEADS, and it is not a hedge. A key the running validator has no schema for controls nothing:\n * every code path that would read it is keyed off the schema. Leaving it is dead config that reads as live\n * config, and for a retired key deleting it is the entire fix.\n *\n * This message used to lead with `pnpm install` instead, on the theory that the key might be valid and the\n * validator merely stale. Two things are wrong with that. First, it CONTRADICTED the banner this error is\n * printed inside, which states outright that `pnpm install` cannot help — one output, two opposite orders.\n * Second, the premise is already handled upstream: the shim's version-drift guard compares the pin against\n * the installed version and denies every tool call BEFORE exec'ing this validator, with its own message and\n * its own cure. If this text is on screen, that guard found no drift. The pin therefore appears here only as\n * a secondary note, so a valid-but-newer key is never dropped without the reader being told the case exists.\n */\nfunction unknownRuleError(ruleName: string): string {\n return (\n `[${ruleName}] Unknown rule — the running @webpieces validator has no selected owner schema for it. A key no validator knows controls NOTHING, so ` +\n `DELETE the \"${ruleName}\" key from the direct policy-ID map in its declared owner config file. ` +\n `Run \\`${PRUNE_UNKNOWN_COMMAND}\\` to remove unknown entries from declared owner files mechanically. ` +\n `It may be RETIRED: a newer release can move ` +\n `a setting out of this file entirely, in which case deleting the key here is the WHOLE fix. ` +\n `MACHINE-LOCAL settings in particular now live in ~/.webpieces/config.json under \"experimental\" — ` +\n `an optional file tracked by no repo, whose absence is the default behaviour — so if ` +\n `\"${ruleName}\" is one of those, delete it here and set it there. Secondary, and rare: a key is ` +\n `valid-but-unlearned when package.json pins an @webpieces OLDER than this config was written for, ` +\n `and the version-drift guard reports THAT separately with its own cure (bump the pin) before this ` +\n `validator ever runs — so it is not what you are looking at.`\n );\n}\n\n/** Schema advice names the selected owner rather than a retired root section. */\nclass RuleConfigAdvice {\n constructor(private readonly registry: RulePackRegistry) {}\n\n private rolloutTip(schema: Readonly<Record<string, FieldDef>>): string {\n const modes = schema['mode']?.enumValues ?? [];\n // Same source of truth as the seeder; only a GRADUAL recommendation gets the rollout prose, so a\n // rule whose recommendation falls through to ON/RUN_EVERY_TIME/OFF prints no tip (as before).\n const recommended = recommendedSeedModeFor(modes);\n if (!isGradualMode(recommended)) return '';\n const optOut = modes.includes('OFF') ? ' Set \"mode\": \"OFF\" to opt out entirely.' : '';\n return (\n `\\n\\n💡 Recommended: start with \"mode\": \"${recommended}\" — it enforces only on what you ` +\n `actually change, so the rule rolls out gradually (existing code stays grandfathered until ` +\n `you next touch that project/file/method).${optOut}`\n );\n }\n\n missingRuleSnippet(ruleName: string, schema: Readonly<Record<string, FieldDef>>): string {\n // Required fields go in the copy-paste entry. The two universal escape hatches\n // (turnOffRuleUntilEpoch / turnOffRuleWhileOnBranch) are now REQUIRED, so they land in that block —\n // which is the whole point: every seeded rule shows both hatches. Optional fields are listed separately.\n const fields = Object.keys(schema);\n const required = fields.filter((f: string) => !schema[f].optional);\n const optional = fields.filter((f: string) => schema[f].optional);\n\n const requiredLines = required.map((f: string) => ` \"${f}\": ${valueHint(schema[f], f)}`);\n const owner = this.registry.ownerOf(ruleName);\n let out =\n `[${ruleName}] Not configured in the declared owner config file for ${owner}. ` +\n `Add this entry directly to that file's policy-ID map\\n` +\n `(choose values appropriate for your project):\\n\\n` +\n ` \"${ruleName}\": {\\n${requiredLines.join(',\\n')}\\n }`;\n\n if (optional.length > 0) {\n const optionalLines = optional.map(\n (f: string) => ` \"${f}\": ${valueHint(schema[f], f)}`,\n );\n out +=\n `\\n\\nOptional fields you may add to this rule (omit if not needed):\\n` +\n `${optionalLines.join(',\\n')}`;\n }\n out += this.rolloutTip(schema);\n return out;\n }\n}\n\n// Fields we DELETED from a rule's schema, keyed by \"<rule>.<field>\". The generic unknown-field error\n// (\"Unknown field ... Valid fields: [...]\") is correct but doesn't say WHY the field vanished, so an AI\n// might re-add it. These hints explain the removal so the only action left is to delete the key.\n\n// Universal field renames (apply to EVERY rule/guard AND every match-rule, unlike the per-rule\n// RETIRED_FIELD_HINTS). When an entry still uses the old escape-hatch name, the generic unknown-field\n// error is replaced with a precise \"renamed to X — rename it\" instruction so the fix is mechanical.\n\n\n// The renamed-field message shared by keyed rules and match-rules.\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nfunction renamedFieldError(scope: string, oldKey: string, newKey: string): string {\n return `${scope} Unknown field \"${oldKey}\" — it was renamed to \"${newKey}\". Rename it (the value carries over unchanged; for the branch hatch, use null when there is no branch).`;\n}\n\n/**\n * Field-level errors for ONE configured rule entry: unknown/renamed/retired keys, type and enum\n * mismatches, and the two-week cap on turnOffRuleUntilEpoch.\n *\n * Extracted out of validateWebpiecesConfig purely so that function stays inside max-method-lines; it is\n * the same checks in the same order.\n */\n// webpieces-disable no-any-unknown -- one config entry as opaque JSON; every field is typed-checked below\n// webpieces-disable no-function-outside-class -- module-scope validator helper, matching every other check in this file\nfunction fieldErrors(\n ruleName: string,\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n entry: Record<string, unknown>,\n schema: Readonly<Record<string, FieldDef>>,\n registry: RulePackRegistry,\n): string[] {\n const errors: string[] = [];\n for (const [key, value] of Object.entries(entry)) {\n const fieldDef = schema[key];\n if (!fieldDef) {\n const renamedTo = new PolicyFieldConstraints().renamedField(key);\n if (renamedTo) {\n errors.push(renamedFieldError(`[${ruleName}]`, key, renamedTo));\n continue;\n }\n const retiredHint = registry\n .migrations()\n .find(\n (entry: RetiredConfigKey) =>\n entry.scope === 'field' && entry.key === `${ruleName}.${key}`,\n )?.instruction;\n const suffix = retiredHint ? ` ${retiredHint}` : '';\n errors.push(\n `[${ruleName}] Unknown field \"${key}\". Valid fields: [${Object.keys(schema).join(', ')}].${suffix}`,\n );\n continue;\n }\n // A nullable field (e.g. turnOffRuleWhileOnBranch) accepts JSON null in addition to its type.\n if (value === null && fieldDef.nullable) continue;\n if (fieldDef.type === 'string[]' || fieldDef.type === 'object[]') {\n errors.push(...arrayFieldErrors(`[${ruleName}] \"${key}\"`, value, fieldDef));\n } else if (typeof value !== fieldDef.type) {\n errors.push(`[${ruleName}] \"${key}\" must be ${fieldDef.type}, got ${typeof value}.`);\n } else if (fieldDef.enumValues && !fieldDef.enumValues.includes(value as string)) {\n errors.push(\n `[${ruleName}] \"${key}\" = \"${value}\" is not valid. Must be one of: ${fieldDef.enumValues.join(', ')}.`,\n );\n } else if (key === 'turnOffRuleUntilEpoch') {\n const capError = epochCapError(`[${ruleName}]`, value as number);\n if (capError) errors.push(capError);\n } else if (\n ruleName === 'branch-state-guard' &&\n key === 'maxCommitsBehind' &&\n (!Number.isInteger(value) || (value as number) < 0)\n ) {\n errors.push('[branch-state-guard] \"maxCommitsBehind\" must be a non-negative integer.');\n }\n }\n return errors;\n}\n\n/**\n * Errors for one array-typed field (`string[]` / `object[]`): the element type, `nonEmpty`, and — for\n * `object[]` — every element against the field's `elementSchema` (unknown keys, missing required keys,\n * and each element field checked recursively). `label` is `[rule] \"field\"`, extended per element\n * (`[rule] \"entries\"[0].suffixes`) so an error names the exact spot to edit.\n */\n// webpieces-disable no-any-unknown -- a config field value is opaque JSON until this checks its shape\n// webpieces-disable no-function-outside-class -- module-scope validator helper, matching every other check in this file\n// webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\nfunction arrayFieldErrors(label: string, value: unknown, def: FieldDef): string[] {\n const isObjects = def.type === 'object[]';\n // webpieces-disable no-any-unknown -- one list element as opaque JSON; this line is what checks its shape\n const elementOk = (v: unknown): boolean =>\n isObjects\n ? typeof v === 'object' && v !== null && !Array.isArray(v)\n : typeof v === 'string';\n if (!Array.isArray(value) || !value.every(elementOk)) {\n const shape = isObjects ? 'a list of objects' : 'string[]';\n return [\n `${label} must be ${shape}, got ${Array.isArray(value) ? 'a list holding something else' : typeof value}.`,\n ];\n }\n if (def.nonEmpty && value.length === 0) {\n return [\n `${label} must not be empty — an empty list judges nothing while reading as configured. Add ${valueHint(def)}.` +\n (def.emptyInstruction === undefined ? '' : ` ${def.emptyInstruction}`),\n ];\n }\n if (!isObjects || def.elementSchema === undefined) return [];\n const errors: string[] = [];\n const schema = def.elementSchema;\n // webpieces-disable no-any-unknown -- an element's fields are opaque JSON until checked against its schema below\n value.forEach((element: Record<string, unknown>, index: number) => {\n const at = `${label}[${index}]`;\n for (const key of Object.keys(element)) {\n if (!(key in schema))\n errors.push(\n `${at} Unknown field \"${key}\". Valid fields: [${Object.keys(schema).join(', ')}].`,\n );\n }\n for (const [key, fieldDef] of Object.entries(schema)) {\n if (!(key in element)) {\n if (!fieldDef.optional)\n errors.push(\n `${at} Missing required field \"${key}\". Add ${key}: ${valueHint(fieldDef, key)}.`,\n );\n } else if (fieldDef.type === 'string[]' || fieldDef.type === 'object[]') {\n errors.push(...arrayFieldErrors(`${at}.${key}`, element[key], fieldDef));\n } else if (typeof element[key] !== fieldDef.type) {\n errors.push(`${at}.${key} must be ${fieldDef.type}, got ${typeof element[key]}.`);\n }\n }\n });\n return errors;\n}\n\n// webpieces-disable no-any-unknown -- rawRules values are opaque JSON; each field is validated individually\nexport function validateWebpiecesConfig(\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n rawRules: Record<string, Record<string, unknown>>,\n registry: RulePackRegistry,\n): string[] {\n const errors: string[] = [];\n const advice = new RuleConfigAdvice(registry);\n\n // Check field-level correctness for rules that are present\n for (const [ruleName, entry] of Object.entries(rawRules)) {\n const schema = registry.hasRule(ruleName) ? registry.schemaFor(ruleName) : undefined;\n if (!schema) {\n if (\n registry.isSafeguard(ruleName) &&\n !registry\n .migrations()\n .some(\n (entry: RetiredConfigKey) =>\n entry.scope === 'rule' && entry.key === ruleName,\n )\n ) {\n errors.push(\n `[${ruleName}] is a cataloged safeguard, not a configurable policy. Delete its config entry; fixed safety cannot be disabled.`,\n );\n continue;\n }\n // A name we KNOW is retired beats the generic unknown-rule message, because only the table\n // knows WHERE the setting went — a rename carries its value over, and a bare \"delete it\"\n // would throw that value away. Client packs must not reuse a retired canonical ID.\n const retired = retiredRuleFor(ruleName, registry);\n if (retired) {\n errors.push(retiredKeyError(retired));\n continue;\n }\n // Client policies require a schema from an explicitly selected owner.\n errors.push(unknownRuleError(ruleName));\n continue;\n }\n errors.push(...fieldErrors(ruleName, entry, schema, registry));\n // Required fields must actually be present. Until now the loop above only checked\n // fields that WERE present, so an entry like `{}` (or one missing `mode` /\n // `turnOffRuleUntilEpoch`) slipped through. Every non-optional schema field is mandatory.\n for (const [key, fieldDef] of Object.entries(schema)) {\n if (!fieldDef.optional && !(key in entry)) {\n errors.push(\n `[${ruleName}] Missing required field \"${key}\". Add ${key}: ${valueHint(fieldDef, key)}.`,\n );\n }\n }\n }\n\n // Every built-in rule must be explicitly configured — no silent defaults.\n // When a new rule is added to the framework, this check surfaces it immediately\n // with a ready-to-copy snippet so AI can configure it in one pass.\n for (const ruleName of registry.ruleIds()) {\n const schema = registry.schemaFor(ruleName);\n if (!(ruleName in rawRules)) {\n errors.push(advice.missingRuleSnippet(ruleName, schema));\n }\n }\n\n return errors;\n}\n\nexport { validatePrGateSection } from './validate-pr-gate';\n\nfunction excludePathsExample(): string {\n return '\"excludePaths\": [\"repositories/**\"]';\n}\n\n// A glob list: must be a string[] (may be empty). `key` names it for the error.\n// webpieces-disable no-any-unknown -- `value` is opaque consumer JSON until narrowed here\nfunction validateExcludeList(value: unknown, key: string): string[] {\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n if (!(Array.isArray(value) && value.every((p: unknown) => typeof p === 'string'))) {\n return [`[excludePaths] \"${key}\" must be a string[] of glob paths (use [] for none).`];\n }\n return [];\n}\n\n/**\n * Validate the REQUIRED top-level `excludePaths` block: ONE glob list suppressing hook enforcement per\n * file path, for code-style rules and file-scoped guards alike. Required so every client upgrading is\n * forced to declare it (as [] to keep today's behavior, or with real paths). Returns copy-paste\n * friendly errors and never throws — same contract as validatePrGateSection.\n *\n * The two-list object form `{ \"rules\": [...], \"guards\": [...] }` is RETIRED, not tolerated. It used to be\n * accepted and silently unioned, which is why this repo's own config sat on the dead shape for releases: an\n * accepted shape is never migrated. Rejecting it cannot wedge a consumer — editing webpieces.config.json is\n * always permitted, even while it is invalid. See retired-config-keys.ts.\n */\n// webpieces-disable no-any-unknown -- `section` is opaque consumer JSON until narrowed below\nexport function validateExcludePaths(section: unknown): string[] {\n if (section === undefined || section === null) {\n return [\n `[excludePaths] Not configured in webpieces.config.json. Add this REQUIRED block ` +\n `(use an empty array to keep enforcing everywhere):\\n\\n ${excludePathsExample()}`,\n ];\n }\n if (Array.isArray(section)) return validateExcludeList(section, 'excludePaths');\n if (typeof section !== 'object') {\n return [\n `[excludePaths] Must be a string[] of glob paths. Example:\\n\\n ${excludePathsExample()}`,\n ];\n }\n // webpieces-disable no-any-unknown -- narrowing the opaque excludePaths section from consumer JSON\n const s = section as Record<string, unknown>;\n // The retired two-list object. One table row owns the message for either key present.\n const retired = retiredEntry('rules', '[excludePaths]');\n if (retired && (s['rules'] !== undefined || s['guards'] !== undefined)) {\n return [`${retiredKeyError(retired)}\\n\\n ${excludePathsExample()}`];\n }\n return [\n `[excludePaths] Must be a string[] of glob paths. Example:\\n\\n ${excludePathsExample()}`,\n ];\n}\n\n// ---------------------------------------------------------------------------\n// match-rules — a new top-level ARRAY section (parallel to pr-gate/excludePaths). Each entry is a\n// client-authored content guard (raw-regex patterns + message + scoping). Validated structurally here\n// the same way pr-gate's `gates` are, because an array of objects can't be expressed in FieldDef schema.\n// ---------------------------------------------------------------------------\n\nfunction matchRulesExample(): string {\n return `\"match-rules\": ${JSON.stringify(DEFAULT_MATCH_RULES, null, 4)}`;\n}\n\n// webpieces-disable no-any-unknown -- generic type guard over an opaque JSON value\nfunction isStringArray(value: unknown): value is string[] {\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n return Array.isArray(value) && value.every((v: unknown) => typeof v === 'string');\n}\n\n// Compile a pattern to validate it; returns the error message, or undefined when it compiles.\nfunction regexError(pattern: string): string | undefined {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n // Constructed only to validate the syntax; the object is intentionally discarded.\n void new RegExp(pattern);\n return undefined;\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 error.message;\n }\n}\n\n// One entry of the match-rules array, validated field-by-field (see validateGate for the pattern).\n// webpieces-disable no-any-unknown -- one match-rule entry from opaque consumer JSON, validated field-by-field\nfunction validateMatchRule(entry: unknown, index: number): string[] {\n if (typeof entry !== 'object' || entry === null || Array.isArray(entry)) {\n return [\n `[match-rules] entry[${index}] must be an object { name, patterns, mainMessage, mode, turnOffRuleUntilEpoch, turnOffRuleWhileOnBranch, ... }.`,\n ];\n }\n // webpieces-disable no-any-unknown -- narrowing one opaque match-rule entry from consumer JSON\n const e = entry as Record<string, unknown>;\n const label = typeof e['name'] === 'string' ? `\"${e['name']}\"` : `entry[${index}]`;\n const errors: string[] = [];\n\n if (typeof e['name'] !== 'string' || e['name'].trim() === '')\n errors.push(\n `[match-rules] entry[${index}].name must be a non-empty string (it is the disable token and report label).`,\n );\n\n if (!isStringArray(e['patterns']) || e['patterns'].length === 0) {\n errors.push(`[match-rules] ${label}.patterns must be a non-empty string[] of regexes.`);\n } else {\n e['patterns'].forEach((p: string, pi: number) => {\n const rxErr = regexError(p);\n if (rxErr)\n errors.push(\n `[match-rules] ${label}.patterns[${pi}] is not a valid regex: ${rxErr}`,\n );\n });\n }\n\n if (typeof e['mainMessage'] !== 'string' || e['mainMessage'].trim() === '')\n errors.push(`[match-rules] ${label}.mainMessage must be a non-empty string.`);\n\n if (\n typeof e['mode'] !== 'string' ||\n !MODIFIED_CODE_MODES.includes(e['mode'] as (typeof MODIFIED_CODE_MODES)[number])\n )\n errors.push(\n `[match-rules] ${label}.mode must be one of: ${MODIFIED_CODE_MODES.join(', ')}.`,\n );\n\n errors.push(...validateMatchRuleHatches(e, label));\n\n if (e['options'] !== undefined && !isStringArray(e['options']))\n errors.push(`[match-rules] ${label}.options must be a string[] (omit if not needed).`);\n if (e['allowedPaths'] !== undefined && !isStringArray(e['allowedPaths']))\n errors.push(\n `[match-rules] ${label}.allowedPaths must be a string[] of globs (omit if not needed).`,\n );\n if (e['disableAllowed'] !== undefined && typeof e['disableAllowed'] !== 'boolean')\n errors.push(`[match-rules] ${label}.disableAllowed must be a boolean.`);\n\n return errors;\n}\n\n/**\n * Validate the REQUIRED top-level `match-rules` array (client-authored content guards). MISSING →\n * one error printing the ready-to-paste `no-fetch` example (add at least this; more can follow).\n * Present-but-`[]` → allowed (a conscious opt-out, matching pr-gate mode:OFF / excludePaths []).\n * Otherwise every entry is validated field-by-field (each regex compile-checked) plus name\n * uniqueness. Copy-paste-friendly errors; never throws — same contract as validatePrGateSection.\n */\n// webpieces-disable no-any-unknown -- `section` is opaque consumer JSON until narrowed below\nexport function validateMatchRulesSection(section: unknown): string[] {\n if (section === undefined || section === null) {\n return [\n `[match-rules] Not configured in webpieces.config.json. Add this REQUIRED top-level array — ` +\n `seed it with the no-fetch guard below (you can add more entries: no-moment, no-lodash-chain, …):\\n\\n${matchRulesExample()}`,\n ];\n }\n if (!Array.isArray(section)) {\n return [\n `[match-rules] Must be an array of content-guard objects. Example:\\n\\n${matchRulesExample()}`,\n ];\n }\n\n const errors: string[] = [];\n const seen = new Set<string>();\n for (let i = 0; i < section.length; i += 1) {\n errors.push(...validateMatchRule(section[i], i));\n // webpieces-disable no-any-unknown -- reading the name off an opaque entry only to dedupe\n const name = (section[i] as Record<string, unknown> | null)?.['name'];\n if (typeof name === 'string') {\n if (seen.has(name))\n errors.push(\n `[match-rules] duplicate entry name \"${name}\" — each match-rule name must be unique.`,\n );\n seen.add(name);\n }\n }\n return errors;\n}\n\n// webpieces-disable no-any-unknown -- explicit match-rule JSON is checked field by field\n// webpieces-disable no-function-outside-class -- pure validation helper\nfunction validateMatchRuleHatches(e: Record<string, unknown>, label: string): string[] {\n const errors: string[] = [];\n // Both escape hatches are REQUIRED on every match-rule too (same as keyed rules), so they are always\n // visible. turnOffRuleUntilEpoch: number (0 = active; a future unix-epoch in seconds = temporarily\n // off). turnOffRuleWhileOnBranch: string | null (null = always on; an EXACT branch name — matched\n // with ===, never as a glob — disables the rule while that branch is checked out).\n if (typeof e['turnOffRuleUntilEpoch'] !== 'number') {\n errors.push(\n `[match-rules] ${label}.turnOffRuleUntilEpoch must be a number (0 = active; future unix-epoch seconds = temporarily off).`,\n );\n } else {\n const capError = epochCapError(`[match-rules] ${label}`, e['turnOffRuleUntilEpoch']);\n if (capError) errors.push(capError);\n }\n if (\n !(\n e['turnOffRuleWhileOnBranch'] === null ||\n typeof e['turnOffRuleWhileOnBranch'] === 'string'\n )\n )\n errors.push(\n `[match-rules] ${label}.turnOffRuleWhileOnBranch must be a string or null (null = no branch / always on; a string is an EXACT branch name, globs are not supported).`,\n );\n\n // The old escape-hatch names were renamed — flag them precisely.\n for (const oldKey of new PolicyFieldConstraints().retiredFields()) {\n if (oldKey in e)\n errors.push(\n renamedFieldError(`[match-rules] ${label}`, oldKey, new PolicyFieldConstraints().renamedField(oldKey)!),\n );\n }\n\n return errors;\n}\n"]}
|