@webpieces/rules-config 0.4.943 → 0.4.945

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.943",
3
+ "version": "0.4.945",
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.943",
23
- "@webpieces/repo-workflow-core": "0.4.943",
24
- "@webpieces/rules-sdk": "0.4.943"
22
+ "@webpieces/tooling-common": "0.4.945",
23
+ "@webpieces/repo-workflow-core": "0.4.945",
24
+ "@webpieces/rules-sdk": "0.4.945"
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.943"
37
+ "@webpieces/tooling-testkit": "0.4.945"
38
38
  },
39
39
  "types": "./src/index.d.ts",
40
40
  "bin": {
@@ -22,7 +22,7 @@ class PackPolicyDeclaration {
22
22
  this.package = packageName;
23
23
  }
24
24
  moduleName() {
25
- return /\.(?:cjs|mjs|js)$/.test(this.package) ? this.package : `${this.package}/rule-pack`;
25
+ return /\.(?:cjs|mjs|js|cts|ts)$/.test(this.package) ? this.package : `${this.package}/rule-pack`;
26
26
  }
27
27
  }
28
28
  exports.PackPolicyDeclaration = PackPolicyDeclaration;
@@ -1 +1 @@
1
- {"version":3,"file":"pack-policy-files.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/pack-policy-files.ts"],"names":[],"mappings":";;;;AAAA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A+B,EAAE,EAAE,CAAC;YAC9D,UAAU,CAAC,EAAE;YACb,eAAe,CAAC,UAAU,CAAC,eAAe,CAAC;SAC9C,CAAC,CACL,CAAC;IACN,CAAC;CACJ,CAAA;AArRY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;GAC5B,eAAe,CAqR3B","sourcesContent":["import { injectable, bindingScopeValues } from 'inversify';\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { RulePackManifest, ConfigObject, RetiredConfigKey, OwnedRuleDefinition } from '@webpieces/rules-sdk';\nimport { InformAiError, RepositoryLayout } from '@webpieces/tooling-common';\nimport { toError } from '@webpieces/tooling-common/to-error';\nimport { NodeRulePackModuleLoader, RulePackRegistry } from './rule-pack-registry';\nimport { RepositoryPath } from './repository-path';\nimport { retiredKeyError, RETIRED_SCOPE_RULE } from './retired-config-keys';\nimport { formatConfigErrorsBanner } from './config-error-banner';\nimport { ConfigRepairError, EditFileCure, RepositoryLayoutRepair, RunCommandCure } from './config-repair-error';\nimport { CONFIG_FILENAME } from './config-file';\n\n/** The root declaration identifies an exact package/module and its owner-specific config file. */\nexport class PackPolicyDeclaration {\n readonly package: string;\n\n constructor(\n packageName: string,\n readonly config: string,\n ) {\n this.package = packageName;\n }\n\n moduleName(): string {\n return /\\.(?:cjs|mjs|js)$/.test(this.package) ? this.package : `${this.package}/rule-pack`;\n }\n}\n\nexport class SelectedPolicyPack {\n constructor(\n readonly declaration: PackPolicyDeclaration,\n readonly manifest: RulePackManifest,\n ) {}\n}\n\nexport class PackPolicyFilesResult {\n constructor(\n readonly registry: RulePackRegistry,\n readonly selected: readonly SelectedPolicyPack[],\n readonly values: Record<string, ConfigObject>,\n readonly targetFiles: ReadonlyMap<string, string>,\n ) {}\n}\n\n/**\n * Configuration belongs to explicitly selected owners; loading never supplies recommended seeds.\n *\n * Every problem this class finds is a ConfigRepairError naming the file to edit and the exact entry to\n * paste or delete (#1273). The hooks permit those edits while the config is invalid, so an upgrade that\n * adds a required rule costs the agent one edit of one named file, and no command.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class PackPolicyFiles {\n // webpieces-disable no-any-unknown -- root JSON is narrowed before resolving modules or files.\n declarations(raw: unknown, root: string): PackPolicyDeclaration[] {\n const rootFile = path.join(root, CONFIG_FILENAME);\n if (!Array.isArray(raw) || raw.length === 0) {\n throw new ConfigRepairError(`${rootFile}: rulePacks is required.`, [\n new EditFileCure(\n rootFile,\n 'Add \"rulePacks\": [{\"package\":\"<pack>\",\"config\":\".webpieces-config/rules/<pack>.json\"}, ...] with one declaration per selected rule pack; each rule then names the owner file its entry belongs in.',\n ),\n ]);\n }\n const packages = new Set<string>(),\n files = new Set<string>();\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n return raw.map((entry: unknown) => {\n if (\n !entry ||\n typeof entry !== 'object' ||\n Array.isArray(entry) ||\n !('package' in entry) ||\n !('config' in entry) ||\n typeof entry.package !== 'string' ||\n !entry.package ||\n typeof entry.config !== 'string' ||\n !entry.config ||\n Object.keys(entry).some((key: string) => !['package', 'config'].includes(key))\n ) {\n throw new ConfigRepairError(\n `${rootFile}: invalid rulePacks entry ${JSON.stringify(entry)}.`,\n [\n new EditFileCure(\n rootFile,\n 'Give the entry exactly two string fields: {\"package\":\"<pack>\",\"config\":\".webpieces-config/rules/<pack>.json\"}.',\n ),\n ],\n );\n }\n const filename = this.configPath(root, entry.config);\n if (packages.has(entry.package) || files.has(filename)) {\n throw new ConfigRepairError(\n `${rootFile}: duplicate rule-pack declaration or config path: ${entry.package}, ${entry.config}.`,\n [\n new EditFileCure(\n rootFile,\n 'Delete the second rulePacks entry; declare each pack and config once.',\n ),\n ],\n );\n }\n packages.add(entry.package);\n files.add(filename);\n return new PackPolicyDeclaration(entry.package, entry.config);\n });\n }\n\n select(root: string, declarations: readonly PackPolicyDeclaration[]): SelectedPolicyPack[] {\n const loader = new NodeRulePackModuleLoader(root);\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- module failures identify the declaration's actual repair file.\n try {\n return declarations.map((declaration: PackPolicyDeclaration) => {\n const manifest = loader.load(declaration.moduleName());\n if (\n declaration.moduleName() === `${declaration.package}/rule-pack` &&\n manifest.packageName !== declaration.package\n ) {\n throw new InformAiError(\n `Declared package ${declaration.package} exports owner ${manifest.packageName}. Declare the actual owning package or an explicit client manifest module.`,\n );\n }\n return new SelectedPolicyPack(declaration, manifest);\n });\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 const rootFile = path.join(root, CONFIG_FILENAME);\n throw new ConfigRepairError(\n `Rule-pack selection in ${rootFile} needs repair: ${error.message}`,\n [\n new EditFileCure(\n rootFile,\n 'Fix the rulePacks entry named above: declare the package that actually owns the pack, or delete the entry.',\n ),\n new RunCommandCure(\n 'pnpm install',\n 'pnpm install — when the declared pack is simply missing from node_modules.',\n ),\n ],\n { cause: error },\n );\n }\n }\n\n resolve(root: string, selected: readonly SelectedPolicyPack[]): PackPolicyFilesResult {\n const registry = this.registry(root, selected);\n const values: Record<string, ConfigObject> = {},\n targetFiles = new Map<string, string>();\n const errors: string[] = [];\n const filesToEdit = new Set<string>();\n for (const pack of selected) {\n const filename = this.configPath(root, pack.declaration.config);\n for (const definition of pack.manifest.ownedRules)\n targetFiles.set(definition.id, filename);\n }\n for (const pack of selected) {\n const filename = this.configPath(root, pack.declaration.config);\n if (!fs.existsSync(filename)) {\n filesToEdit.add(filename);\n errors.push(\n `${filename}: missing rule-pack config for ${pack.manifest.packageName}. Create it with this content (the owner's recommended seeds — review every value):\\n${JSON.stringify(this.seeds(pack), null, 2)}`,\n );\n continue;\n }\n const entries = this.read(filename);\n this.foreignEntries(filename, entries, pack, registry, targetFiles, errors, filesToEdit);\n for (const definition of pack.manifest.ownedRules) {\n if (!Object.hasOwn(entries, definition.id)) {\n filesToEdit.add(filename);\n errors.push(\n `${filename}: missing required entry \"${definition.id}\". Paste this entry into that file (the owner's recommended seed — choose your own values; OFF still states every required field):\\n\"${definition.id}\": ${JSON.stringify(registry.seedFor(definition.id))}`,\n );\n continue;\n }\n const value = entries[definition.id];\n const invalid = registry\n .validateRuleConfig(definition.id, value)\n .map((error: string) => `${filename}: ${error}`);\n if (invalid.length) filesToEdit.add(filename);\n errors.push(...invalid);\n values[definition.id] = value;\n }\n }\n if (errors.length) {\n throw new ConfigRepairError(\n formatConfigErrorsBanner(errors).replace(\n 'THE FIX: edit webpieces.config.json',\n 'THE FIX: edit the declared owner config files named above',\n ) +\n '\\nEditing webpieces.config.json and every file under .webpieces-config/ is ALWAYS allowed, even while the config is invalid. Required settings are never supplied during loading.',\n [...filesToEdit].map((file: string) =>\n new EditFileCure(file, `Edit ${file} and apply every bullet above that names it.`),\n ),\n );\n }\n return new PackPolicyFilesResult(registry, selected, values, targetFiles);\n }\n\n configPath(root: string, relative: string): string {\n const rootFile = path.join(root, CONFIG_FILENAME);\n const fixPath = new EditFileCure(\n rootFile,\n `Change the rulePacks config \"${relative}\" to a distinct repository-relative JSON path such as .webpieces-config/rules/code.json.`,\n );\n if (path.isAbsolute(relative) || !relative.endsWith('.json')) {\n throw new ConfigRepairError(`${rootFile}: invalid pack config path ${relative}.`, [fixPath]);\n }\n let target: string;\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- path faults name the declaration that needs repair\n try {\n target = new RepositoryPath(root).resolve(relative);\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 throw new ConfigRepairError(\n `${rootFile}: invalid pack config path ${relative}: ${error.message}`,\n [fixPath],\n { cause: error },\n );\n }\n const normalized = path.relative(fs.realpathSync(root), target);\n if (\n path.isAbsolute(relative) ||\n normalized.startsWith('..') ||\n !normalized.endsWith('.json') ||\n normalized === CONFIG_FILENAME\n ) {\n throw new ConfigRepairError(`${rootFile}: invalid pack config path ${relative}.`, [fixPath]);\n }\n new RepositoryLayoutRepair().run(() => new RepositoryLayout().assertPolicyPath(normalized));\n return target;\n }\n\n read(filename: string): Record<string, ConfigObject> {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- malformed pack files name their exact repair path.\n try {\n // webpieces-disable no-any-unknown -- registry validation narrows the parsed option bags.\n const entries: unknown = JSON.parse(fs.readFileSync(filename, 'utf8'));\n if (!entries || typeof entries !== 'object' || Array.isArray(entries)) {\n throw new ConfigRepairError(\n `${filename} must be an object mapping owned rule IDs to explicit config objects.`,\n [\n new EditFileCure(\n filename,\n `Rewrite ${filename} as one JSON object: {\"<rule-id>\": {...}, ...}.`,\n ),\n ],\n );\n }\n return entries as Record<string, ConfigObject>;\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 if (error instanceof InformAiError) throw error;\n throw new ConfigRepairError(\n `Cannot parse rule-pack config ${filename}: ${error.message}.`,\n [new EditFileCure(filename, `Edit ${filename} to restore valid JSON.`)],\n { cause: error },\n );\n }\n }\n\n // Entries this owner file must not hold: unknown or retired IDs (delete), and another owner's (move).\n // eslint-disable-next-line @typescript-eslint/max-params -- the accumulators of resolve(), passed through once\n private foreignEntries(\n filename: string,\n entries: Record<string, ConfigObject>,\n pack: SelectedPolicyPack,\n registry: RulePackRegistry,\n targetFiles: ReadonlyMap<string, string>,\n errors: string[],\n filesToEdit: Set<string>,\n ): void {\n for (const id of Object.keys(entries)) {\n if (!registry.hasRule(id)) {\n const retired = registry\n .migrations()\n .find(\n (entry: RetiredConfigKey) =>\n entry.scope === RETIRED_SCOPE_RULE && entry.key === id,\n );\n filesToEdit.add(filename);\n errors.push(\n `${filename}: ${retired ? retiredKeyError(retired) : `\"${id}\" has no declared configurable owner. Delete the \"${id}\" entry from this file.`}`,\n );\n } else if (registry.ownerOf(id) !== pack.manifest.packageName) {\n const owner = targetFiles.get(id) ?? '';\n filesToEdit.add(filename);\n filesToEdit.add(owner);\n errors.push(\n `${filename}: \"${id}\" belongs to ${registry.ownerOf(id)}. Delete the \"${id}\" entry here and paste it into ${owner}.`,\n );\n }\n }\n }\n\n // Conflicting manifests (two packs owning one rule) are a SELECTION problem: the declaration is the fix.\n private registry(root: string, selected: readonly SelectedPolicyPack[]): RulePackRegistry {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- converts a manifest conflict into the declaration's structured repair\n try {\n const registry = new RulePackRegistry(\n selected.map((pack: SelectedPolicyPack) => pack.manifest),\n );\n for (const pack of selected)\n registry.recordModuleLocation(pack.manifest.packageName, pack.declaration.moduleName());\n return registry;\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 if (!(error instanceof InformAiError)) throw error;\n const rootFile = path.join(root, CONFIG_FILENAME);\n throw new ConfigRepairError(\n `The rule packs declared in ${rootFile} conflict: ${error.message}`,\n [new EditFileCure(rootFile, 'Delete one of the conflicting rulePacks declarations.')],\n { cause: error },\n );\n }\n }\n\n // The exact owner file a missing declaration needs: every owned rule's recommended seed, for review.\n private seeds(pack: SelectedPolicyPack): Record<string, ConfigObject> {\n return Object.fromEntries(\n pack.manifest.ownedRules.map((definition: OwnedRuleDefinition) => [\n definition.id,\n structuredClone(definition.recommendedSeed),\n ]),\n );\n }\n}\n"]}
1
+ {"version":3,"file":"pack-policy-files.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/pack-policy-files.ts"],"names":[],"mappings":";;;;AAAA,yCAA2D;AAC3D,oDAA8B;AAC9B,wDAAkC;AAElC,8DAA4E;AAC5E,iEAA6D;AAC7D,6DAAkF;AAClF,uDAAmD;AACnD,+DAA4E;AAC5E,+DAAiE;AACjE,+DAAgH;AAChH,+CAAgD;AAEhD,kGAAkG;AAClG,MAAa,qBAAqB;IAKjB;IAJJ,OAAO,CAAS;IAEzB,YACI,WAAmB,EACV,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;QAEvB,IAAI,CAAC,OAAO,GAAG,WAAW,CAAC;IAC/B,CAAC;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AAC,GAAG,CAAC,CAAC,IAAwB,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAC5D,CAAC;YACF,KAAK,MAAM,IAAI,IAAI,QAAQ;gBACvB,QAAQ,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,CAAC,CAAC;YAC5F,OAAO,QAAQ,CAAC;YAChB,6GAA6G;QACjH,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACpB,MAAM,KAAK,GAAG,IAAA,kBAAO,EAAC,GAAG,CAAC,CAAC;YAC3B,IAAI,CAAC,CAAC,KAAK,YAAY,8BAAa,CAAC;gBAAE,MAAM,KAAK,CAAC;YACnD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,6BAAe,CAAC,CAAC;YAClD,MAAM,IAAI,uCAAiB,CACvB,8BAA8B,QAAQ,cAAc,KAAK,CAAC,OAAO,EAAE,EACnE,CAAC,IAAI,kCAAY,CAAC,QAAQ,EAAE,uDAAuD,CAAC,CAAC,EACrF,EAAE,KAAK,EAAE,KAAK,EAAE,CACnB,CAAC;QACN,CAAC;IACL,CAAC;IAED,qGAAqG;IAC7F,KAAK,CAAC,IAAwB;QAClC,OAAO,MAAM,CAAC,WAAW,CACrB,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,UAA+B,EAAE,EAAE,CAAC;YAC9D,UAAU,CAAC,EAAE;YACb,eAAe,CAAC,UAAU,CAAC,eAAe,CAAC;SAC9C,CAAC,CACL,CAAC;IACN,CAAC;CACJ,CAAA;AArRY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;GAC5B,eAAe,CAqR3B","sourcesContent":["import { injectable, bindingScopeValues } from 'inversify';\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { RulePackManifest, ConfigObject, RetiredConfigKey, OwnedRuleDefinition } from '@webpieces/rules-sdk';\nimport { InformAiError, RepositoryLayout } from '@webpieces/tooling-common';\nimport { toError } from '@webpieces/tooling-common/to-error';\nimport { NodeRulePackModuleLoader, RulePackRegistry } from './rule-pack-registry';\nimport { RepositoryPath } from './repository-path';\nimport { retiredKeyError, RETIRED_SCOPE_RULE } from './retired-config-keys';\nimport { formatConfigErrorsBanner } from './config-error-banner';\nimport { ConfigRepairError, EditFileCure, RepositoryLayoutRepair, RunCommandCure } from './config-repair-error';\nimport { CONFIG_FILENAME } from './config-file';\n\n/** The root declaration identifies an exact package/module and its owner-specific config file. */\nexport class PackPolicyDeclaration {\n readonly package: string;\n\n constructor(\n packageName: string,\n readonly config: string,\n ) {\n this.package = packageName;\n }\n\n moduleName(): string {\n return /\\.(?:cjs|mjs|js|cts|ts)$/.test(this.package) ? this.package : `${this.package}/rule-pack`;\n }\n}\n\nexport class SelectedPolicyPack {\n constructor(\n readonly declaration: PackPolicyDeclaration,\n readonly manifest: RulePackManifest,\n ) {}\n}\n\nexport class PackPolicyFilesResult {\n constructor(\n readonly registry: RulePackRegistry,\n readonly selected: readonly SelectedPolicyPack[],\n readonly values: Record<string, ConfigObject>,\n readonly targetFiles: ReadonlyMap<string, string>,\n ) {}\n}\n\n/**\n * Configuration belongs to explicitly selected owners; loading never supplies recommended seeds.\n *\n * Every problem this class finds is a ConfigRepairError naming the file to edit and the exact entry to\n * paste or delete (#1273). The hooks permit those edits while the config is invalid, so an upgrade that\n * adds a required rule costs the agent one edit of one named file, and no command.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class PackPolicyFiles {\n // webpieces-disable no-any-unknown -- root JSON is narrowed before resolving modules or files.\n declarations(raw: unknown, root: string): PackPolicyDeclaration[] {\n const rootFile = path.join(root, CONFIG_FILENAME);\n if (!Array.isArray(raw) || raw.length === 0) {\n throw new ConfigRepairError(`${rootFile}: rulePacks is required.`, [\n new EditFileCure(\n rootFile,\n 'Add \"rulePacks\": [{\"package\":\"<pack>\",\"config\":\".webpieces-config/rules/<pack>.json\"}, ...] with one declaration per selected rule pack; each rule then names the owner file its entry belongs in.',\n ),\n ]);\n }\n const packages = new Set<string>(),\n files = new Set<string>();\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n return raw.map((entry: unknown) => {\n if (\n !entry ||\n typeof entry !== 'object' ||\n Array.isArray(entry) ||\n !('package' in entry) ||\n !('config' in entry) ||\n typeof entry.package !== 'string' ||\n !entry.package ||\n typeof entry.config !== 'string' ||\n !entry.config ||\n Object.keys(entry).some((key: string) => !['package', 'config'].includes(key))\n ) {\n throw new ConfigRepairError(\n `${rootFile}: invalid rulePacks entry ${JSON.stringify(entry)}.`,\n [\n new EditFileCure(\n rootFile,\n 'Give the entry exactly two string fields: {\"package\":\"<pack>\",\"config\":\".webpieces-config/rules/<pack>.json\"}.',\n ),\n ],\n );\n }\n const filename = this.configPath(root, entry.config);\n if (packages.has(entry.package) || files.has(filename)) {\n throw new ConfigRepairError(\n `${rootFile}: duplicate rule-pack declaration or config path: ${entry.package}, ${entry.config}.`,\n [\n new EditFileCure(\n rootFile,\n 'Delete the second rulePacks entry; declare each pack and config once.',\n ),\n ],\n );\n }\n packages.add(entry.package);\n files.add(filename);\n return new PackPolicyDeclaration(entry.package, entry.config);\n });\n }\n\n select(root: string, declarations: readonly PackPolicyDeclaration[]): SelectedPolicyPack[] {\n const loader = new NodeRulePackModuleLoader(root);\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- module failures identify the declaration's actual repair file.\n try {\n return declarations.map((declaration: PackPolicyDeclaration) => {\n const manifest = loader.load(declaration.moduleName());\n if (\n declaration.moduleName() === `${declaration.package}/rule-pack` &&\n manifest.packageName !== declaration.package\n ) {\n throw new InformAiError(\n `Declared package ${declaration.package} exports owner ${manifest.packageName}. Declare the actual owning package or an explicit client manifest module.`,\n );\n }\n return new SelectedPolicyPack(declaration, manifest);\n });\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 const rootFile = path.join(root, CONFIG_FILENAME);\n throw new ConfigRepairError(\n `Rule-pack selection in ${rootFile} needs repair: ${error.message}`,\n [\n new EditFileCure(\n rootFile,\n 'Fix the rulePacks entry named above: declare the package that actually owns the pack, or delete the entry.',\n ),\n new RunCommandCure(\n 'pnpm install',\n 'pnpm install — when the declared pack is simply missing from node_modules.',\n ),\n ],\n { cause: error },\n );\n }\n }\n\n resolve(root: string, selected: readonly SelectedPolicyPack[]): PackPolicyFilesResult {\n const registry = this.registry(root, selected);\n const values: Record<string, ConfigObject> = {},\n targetFiles = new Map<string, string>();\n const errors: string[] = [];\n const filesToEdit = new Set<string>();\n for (const pack of selected) {\n const filename = this.configPath(root, pack.declaration.config);\n for (const definition of pack.manifest.ownedRules)\n targetFiles.set(definition.id, filename);\n }\n for (const pack of selected) {\n const filename = this.configPath(root, pack.declaration.config);\n if (!fs.existsSync(filename)) {\n filesToEdit.add(filename);\n errors.push(\n `${filename}: missing rule-pack config for ${pack.manifest.packageName}. Create it with this content (the owner's recommended seeds — review every value):\\n${JSON.stringify(this.seeds(pack), null, 2)}`,\n );\n continue;\n }\n const entries = this.read(filename);\n this.foreignEntries(filename, entries, pack, registry, targetFiles, errors, filesToEdit);\n for (const definition of pack.manifest.ownedRules) {\n if (!Object.hasOwn(entries, definition.id)) {\n filesToEdit.add(filename);\n errors.push(\n `${filename}: missing required entry \"${definition.id}\". Paste this entry into that file (the owner's recommended seed — choose your own values; OFF still states every required field):\\n\"${definition.id}\": ${JSON.stringify(registry.seedFor(definition.id))}`,\n );\n continue;\n }\n const value = entries[definition.id];\n const invalid = registry\n .validateRuleConfig(definition.id, value)\n .map((error: string) => `${filename}: ${error}`);\n if (invalid.length) filesToEdit.add(filename);\n errors.push(...invalid);\n values[definition.id] = value;\n }\n }\n if (errors.length) {\n throw new ConfigRepairError(\n formatConfigErrorsBanner(errors).replace(\n 'THE FIX: edit webpieces.config.json',\n 'THE FIX: edit the declared owner config files named above',\n ) +\n '\\nEditing webpieces.config.json and every file under .webpieces-config/ is ALWAYS allowed, even while the config is invalid. Required settings are never supplied during loading.',\n [...filesToEdit].map((file: string) =>\n new EditFileCure(file, `Edit ${file} and apply every bullet above that names it.`),\n ),\n );\n }\n return new PackPolicyFilesResult(registry, selected, values, targetFiles);\n }\n\n configPath(root: string, relative: string): string {\n const rootFile = path.join(root, CONFIG_FILENAME);\n const fixPath = new EditFileCure(\n rootFile,\n `Change the rulePacks config \"${relative}\" to a distinct repository-relative JSON path such as .webpieces-config/rules/code.json.`,\n );\n if (path.isAbsolute(relative) || !relative.endsWith('.json')) {\n throw new ConfigRepairError(`${rootFile}: invalid pack config path ${relative}.`, [fixPath]);\n }\n let target: string;\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- path faults name the declaration that needs repair\n try {\n target = new RepositoryPath(root).resolve(relative);\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 throw new ConfigRepairError(\n `${rootFile}: invalid pack config path ${relative}: ${error.message}`,\n [fixPath],\n { cause: error },\n );\n }\n const normalized = path.relative(fs.realpathSync(root), target);\n if (\n path.isAbsolute(relative) ||\n normalized.startsWith('..') ||\n !normalized.endsWith('.json') ||\n normalized === CONFIG_FILENAME\n ) {\n throw new ConfigRepairError(`${rootFile}: invalid pack config path ${relative}.`, [fixPath]);\n }\n new RepositoryLayoutRepair().run(() => new RepositoryLayout().assertPolicyPath(normalized));\n return target;\n }\n\n read(filename: string): Record<string, ConfigObject> {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- malformed pack files name their exact repair path.\n try {\n // webpieces-disable no-any-unknown -- registry validation narrows the parsed option bags.\n const entries: unknown = JSON.parse(fs.readFileSync(filename, 'utf8'));\n if (!entries || typeof entries !== 'object' || Array.isArray(entries)) {\n throw new ConfigRepairError(\n `${filename} must be an object mapping owned rule IDs to explicit config objects.`,\n [\n new EditFileCure(\n filename,\n `Rewrite ${filename} as one JSON object: {\"<rule-id>\": {...}, ...}.`,\n ),\n ],\n );\n }\n return entries as Record<string, ConfigObject>;\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 if (error instanceof InformAiError) throw error;\n throw new ConfigRepairError(\n `Cannot parse rule-pack config ${filename}: ${error.message}.`,\n [new EditFileCure(filename, `Edit ${filename} to restore valid JSON.`)],\n { cause: error },\n );\n }\n }\n\n // Entries this owner file must not hold: unknown or retired IDs (delete), and another owner's (move).\n // eslint-disable-next-line @typescript-eslint/max-params -- the accumulators of resolve(), passed through once\n private foreignEntries(\n filename: string,\n entries: Record<string, ConfigObject>,\n pack: SelectedPolicyPack,\n registry: RulePackRegistry,\n targetFiles: ReadonlyMap<string, string>,\n errors: string[],\n filesToEdit: Set<string>,\n ): void {\n for (const id of Object.keys(entries)) {\n if (!registry.hasRule(id)) {\n const retired = registry\n .migrations()\n .find(\n (entry: RetiredConfigKey) =>\n entry.scope === RETIRED_SCOPE_RULE && entry.key === id,\n );\n filesToEdit.add(filename);\n errors.push(\n `${filename}: ${retired ? retiredKeyError(retired) : `\"${id}\" has no declared configurable owner. Delete the \"${id}\" entry from this file.`}`,\n );\n } else if (registry.ownerOf(id) !== pack.manifest.packageName) {\n const owner = targetFiles.get(id) ?? '';\n filesToEdit.add(filename);\n filesToEdit.add(owner);\n errors.push(\n `${filename}: \"${id}\" belongs to ${registry.ownerOf(id)}. Delete the \"${id}\" entry here and paste it into ${owner}.`,\n );\n }\n }\n }\n\n // Conflicting manifests (two packs owning one rule) are a SELECTION problem: the declaration is the fix.\n private registry(root: string, selected: readonly SelectedPolicyPack[]): RulePackRegistry {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- converts a manifest conflict into the declaration's structured repair\n try {\n const registry = new RulePackRegistry(\n selected.map((pack: SelectedPolicyPack) => pack.manifest),\n );\n for (const pack of selected)\n registry.recordModuleLocation(pack.manifest.packageName, pack.declaration.moduleName());\n return registry;\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 if (!(error instanceof InformAiError)) throw error;\n const rootFile = path.join(root, CONFIG_FILENAME);\n throw new ConfigRepairError(\n `The rule packs declared in ${rootFile} conflict: ${error.message}`,\n [new EditFileCure(rootFile, 'Delete one of the conflicting rulePacks declarations.')],\n { cause: error },\n );\n }\n }\n\n // The exact owner file a missing declaration needs: every owned rule's recommended seed, for review.\n private seeds(pack: SelectedPolicyPack): Record<string, ConfigObject> {\n return Object.fromEntries(\n pack.manifest.ownedRules.map((definition: OwnedRuleDefinition) => [\n definition.id,\n structuredClone(definition.recommendedSeed),\n ]),\n );\n }\n}\n"]}
@@ -75,7 +75,7 @@ class NodeRulePackModuleLoader extends RulePackModuleLoader {
75
75
  }
76
76
  load(moduleName) {
77
77
  // webpieces-disable no-any-unknown -- external module boundary; registry validates its exported data before use
78
- const exports = this.requireModule(this.resolution.resolve(moduleName));
78
+ const exports = new tooling_common_1.TypeScriptRequire().load(this.requireModule, this.resolution.resolve(moduleName));
79
79
  if (typeof exports !== 'object' || exports === null || !('rulePackManifest' in exports)) {
80
80
  throw new tooling_common_1.InformAiError(`Rule pack ${moduleName} must export rulePackManifest. Add the public manifest export.`);
81
81
  }
@@ -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,oDAa8B;AAE9B;;;;;;;GAOG;AACH,MAAa,mBAAmB;IAC5B,SAAS,CAAC,OAA0B;QAChC,IAAI,OAAO,KAAK,MAAM;YAAE,OAAO,4BAAgB,CAAC;QAChD,MAAM,IAAI,GAA6B,EAAE,GAAG,4BAAgB,EAAE,CAAC;QAC/D,OAAO,IAAI,CAAC,cAA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AAiB,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 BASE_RULE_SCHEMA,\n} from '@webpieces/rules-sdk';\n\n/**\n * The framework-owned fields every owned rule's schema carries (#1253), merged in HERE so no pack\n * declares them and no rule can lose them by forgetting a spread.\n *\n * A `lint` rule gets the hatches and `reason` but not `excludePaths`: ESLint decides which files it\n * lints (its own `ignores`), and webpieces' activation of a lint rule is on/off only — an accepted\n * `excludePaths` there would change nothing, so the field is refused rather than silently ignored.\n */\nexport class UniversalRuleSchema {\n fieldsFor(section: RuleConfigSection): Readonly<Record<string, FieldDef>> {\n if (section !== 'lint') return BASE_RULE_SCHEMA;\n const lint: Record<string, FieldDef> = { ...BASE_RULE_SCHEMA };\n delete lint['excludePaths'];\n return lint;\n }\n\n isUniversal(key: string): boolean {\n return Object.hasOwn(BASE_RULE_SCHEMA, key);\n }\n\n /**\n * The owner schema plus the framework's fields. A pack schema that names a universal field is\n * REFUSED — one spelling: the registry supplies them, a pack never declares them.\n *\n * The ONE exception is a `lint` rule carrying the framework's own definition: eslint-rules'\n * LintRuleConfig still spreads BASE_RULE_SCHEMA, and decision 6 of #1253 keeps eslint-rules\n * untouched in that change. Its follow-up (#1278) deletes that spread and this exception with it.\n * Any other section, and any differing definition, fails here.\n */\n merge(ruleId: string, section: RuleConfigSection, schema: Readonly<Record<string, FieldDef>>): Readonly<Record<string, FieldDef>> {\n const merged: Record<string, FieldDef> = {};\n for (const [key, field] of Object.entries(schema)) {\n if (!this.isUniversal(key)) {\n merged[key] = field;\n continue;\n }\n const owned = BASE_RULE_SCHEMA[key as keyof typeof BASE_RULE_SCHEMA];\n if (section === 'lint' && this.sameField(field, owned)) continue;\n throw new InformAiError(\n `Policy ${ruleId} declares the framework-owned field \"${key}\". Delete it from the owner schema (and any ...BASE_RULE_SCHEMA spread); the registry supplies ${Object.keys(BASE_RULE_SCHEMA).join(', ')} to every rule.`,\n );\n }\n return { ...merged, ...this.fieldsFor(section) };\n }\n\n private sameField(a: FieldDef, b: FieldDef): boolean {\n return (\n a.type === b.type &&\n Boolean(a.optional) === Boolean(b.optional) &&\n Boolean(a.nullable) === Boolean(b.nullable) &&\n Boolean(a.nonEmpty) === Boolean(b.nonEmpty) &&\n a.enumValues === undefined &&\n b.enumValues === undefined\n );\n }\n}\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 // Owner schema + the framework-owned universal fields (UniversalRuleSchema) — what config is validated against.\n private readonly schemas = new Map<string, Readonly<Record<string, FieldDef>>>();\n private readonly universal = new UniversalRuleSchema();\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.schemas.get(ruleId)!;\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.schemas.set(\n definition.id,\n this.universal.merge(definition.id, definition.section, definition.schema),\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 = this.schemas.get(definition.id)![key];\n if (\n !field ||\n !field.optional ||\n key === 'mode' ||\n this.universal.isUniversal(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 this.schemas.get(definition.id)!,\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"]}
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,8DAA6E;AAC7E,wDAAkC;AAClC,yEAAoE;AACpE,oDAa8B;AAE9B;;;;;;;GAOG;AACH,MAAa,mBAAmB;IAC5B,SAAS,CAAC,OAA0B;QAChC,IAAI,OAAO,KAAK,MAAM;YAAE,OAAO,4BAAgB,CAAC;QAChD,MAAM,IAAI,GAA6B,EAAE,GAAG,4BAAgB,EAAE,CAAC;QAC/D,OAAO,IAAI,CAAC,cAAc,CAAC,CAAC;QAC5B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,WAAW,CAAC,GAAW;QACnB,OAAO,MAAM,CAAC,MAAM,CAAC,4BAAgB,EAAE,GAAG,CAAC,CAAC;IAChD,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,MAAc,EAAE,OAA0B,EAAE,MAA0C;Q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C,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, TypeScriptRequire } 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 BASE_RULE_SCHEMA,\n} from '@webpieces/rules-sdk';\n\n/**\n * The framework-owned fields every owned rule's schema carries (#1253), merged in HERE so no pack\n * declares them and no rule can lose them by forgetting a spread.\n *\n * A `lint` rule gets the hatches and `reason` but not `excludePaths`: ESLint decides which files it\n * lints (its own `ignores`), and webpieces' activation of a lint rule is on/off only — an accepted\n * `excludePaths` there would change nothing, so the field is refused rather than silently ignored.\n */\nexport class UniversalRuleSchema {\n fieldsFor(section: RuleConfigSection): Readonly<Record<string, FieldDef>> {\n if (section !== 'lint') return BASE_RULE_SCHEMA;\n const lint: Record<string, FieldDef> = { ...BASE_RULE_SCHEMA };\n delete lint['excludePaths'];\n return lint;\n }\n\n isUniversal(key: string): boolean {\n return Object.hasOwn(BASE_RULE_SCHEMA, key);\n }\n\n /**\n * The owner schema plus the framework's fields. A pack schema that names a universal field is\n * REFUSED — one spelling: the registry supplies them, a pack never declares them.\n *\n * The ONE exception is a `lint` rule carrying the framework's own definition: eslint-rules'\n * LintRuleConfig still spreads BASE_RULE_SCHEMA, and decision 6 of #1253 keeps eslint-rules\n * untouched in that change. Its follow-up (#1278) deletes that spread and this exception with it.\n * Any other section, and any differing definition, fails here.\n */\n merge(ruleId: string, section: RuleConfigSection, schema: Readonly<Record<string, FieldDef>>): Readonly<Record<string, FieldDef>> {\n const merged: Record<string, FieldDef> = {};\n for (const [key, field] of Object.entries(schema)) {\n if (!this.isUniversal(key)) {\n merged[key] = field;\n continue;\n }\n const owned = BASE_RULE_SCHEMA[key as keyof typeof BASE_RULE_SCHEMA];\n if (section === 'lint' && this.sameField(field, owned)) continue;\n throw new InformAiError(\n `Policy ${ruleId} declares the framework-owned field \"${key}\". Delete it from the owner schema (and any ...BASE_RULE_SCHEMA spread); the registry supplies ${Object.keys(BASE_RULE_SCHEMA).join(', ')} to every rule.`,\n );\n }\n return { ...merged, ...this.fieldsFor(section) };\n }\n\n private sameField(a: FieldDef, b: FieldDef): boolean {\n return (\n a.type === b.type &&\n Boolean(a.optional) === Boolean(b.optional) &&\n Boolean(a.nullable) === Boolean(b.nullable) &&\n Boolean(a.nonEmpty) === Boolean(b.nonEmpty) &&\n a.enumValues === undefined &&\n b.enumValues === undefined\n );\n }\n}\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 = new TypeScriptRequire().load(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 // Owner schema + the framework-owned universal fields (UniversalRuleSchema) — what config is validated against.\n private readonly schemas = new Map<string, Readonly<Record<string, FieldDef>>>();\n private readonly universal = new UniversalRuleSchema();\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.schemas.get(ruleId)!;\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.schemas.set(\n definition.id,\n this.universal.merge(definition.id, definition.section, definition.schema),\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 = this.schemas.get(definition.id)![key];\n if (\n !field ||\n !field.optional ||\n key === 'mode' ||\n this.universal.isUniversal(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 this.schemas.get(definition.id)!,\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"]}
@@ -40,7 +40,7 @@ class NodeRuleRuntimeModuleLoader extends RuleRuntimeModuleLoader {
40
40
  const resolved = moduleName.startsWith('.') || path.isAbsolute(moduleName)
41
41
  ? path.resolve(path.dirname(this.resolution.resolve(providerModule)), moduleName)
42
42
  : this.resolution.resolve(moduleName);
43
- return this.requireModule(resolved);
43
+ return new tooling_common_1.TypeScriptRequire().load(this.requireModule, resolved);
44
44
  // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution
45
45
  }
46
46
  catch (err) {
@@ -1 +1 @@
1
- {"version":3,"file":"rule-runtime-modules.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/rule-runtime-modules.ts"],"names":[],"mappings":";;;;AAAA,wDAAkC;AAClC,6CAA4C;AAC5C,oDAS8B;AAC9B,8DAA0D;AAE1D,yEAAoE;AACpE,iEAA6D;AAE7D,0FAA0F;AAC1F,MAAa,wBAAwB;IAEpB;IACA;IACA;IACA;IAJb,YACa,YAAoB,EACpB,oBAA4B,EAC5B,aAA4B,EAC5B,OAA0B;QAH1B,iBAAY,GAAZ,YAAY,CAAQ;QACpB,yBAAoB,GAApB,oBAAoB,CAAQ;QAC5B,kBAAa,GAAb,aAAa,CAAe;QAC5B,YAAO,GAAP,OAAO,CAAmB;IACpC,CAAC;C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* as path from 'node:path';\nimport { createRequire } from 'node:module';\nimport {\n BuildPolicy,\n BuildRuleRuntime,\n BuildDebugRequest,\n BuildDebugRuntime,\n BuildPolicyResult,\n ConfigObject,\n ExecutionKind,\n PolicyRuntimeRequest,\n} from '@webpieces/rules-sdk';\nimport { InformAiError } from '@webpieces/tooling-common';\nimport { RulePackRegistry } from './rule-pack-registry';\nimport { ClientModuleResolution } from './client-module-resolution';\nimport { toError } from '@webpieces/tooling-common/to-error';\n\n/** Describes an implementation without evaluating its module during config validation. */\nexport class RuntimeContributionGroup {\n constructor(\n readonly providerPack: string,\n readonly implementationModule: string,\n readonly executionKind: ExecutionKind,\n readonly ruleIds: readonly string[],\n ) {}\n}\n\nexport abstract class RuleRuntimeModuleLoader {\n // webpieces-disable no-any-unknown -- execution-family consumers validate external module contracts\n abstract load(moduleName: string, providerModule: string): unknown;\n}\n\nexport class NodeRuleRuntimeModuleLoader extends RuleRuntimeModuleLoader {\n private readonly resolution: ClientModuleResolution;\n private readonly requireModule: NodeRequire;\n\n constructor(clientRoot: string) {\n super();\n this.resolution = new ClientModuleResolution(clientRoot);\n this.requireModule = createRequire(path.join(clientRoot, 'package.json'));\n }\n\n // webpieces-disable no-any-unknown -- narrowed by its execution-family consumer\n override load(moduleName: string, providerModule: string): unknown {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- a declared module fault names the runtime and declaration needed for repair\n try {\n const resolved =\n moduleName.startsWith('.') || path.isAbsolute(moduleName)\n ? path.resolve(\n path.dirname(this.resolution.resolve(providerModule)),\n moduleName,\n )\n : this.resolution.resolve(moduleName);\n return this.requireModule(resolved);\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 throw new InformAiError(\n `Cannot load declared policy runtime ${moduleName} from ${providerModule}: ${error.message}. Repair its public implementation module or root declaration.`,\n { cause: error },\n );\n }\n }\n}\n\n/** Grouped module loading has no built-in package list or policy IDs. */\nexport class RuleRuntimeModules {\n // webpieces-disable no-any-unknown -- a selected provider explicitly advertises its debug capability\n async runBuildDebug(exports: unknown, request: BuildDebugRequest): Promise<BuildPolicyResult> {\n if (!exports || typeof exports !== 'object' || !('buildDebugRuntime' in exports)) {\n throw new InformAiError(\n `The build provider for ${request.selection.rule} does not support debug runs. Use its declared policy settings and normal validation.`,\n );\n }\n const runtime = exports.buildDebugRuntime as BuildDebugRuntime;\n if (!runtime || typeof runtime.run !== 'function')\n throw new InformAiError(\n 'Invalid buildDebugRuntime.run(request). Repair the provider export.',\n );\n const result = await runtime.run(request);\n if (!result || typeof result.success !== 'boolean')\n throw new InformAiError('Debug runtime must return an explicit success boolean.');\n return result;\n }\n\n groups(registry: RulePackRegistry, kind: ExecutionKind): readonly RuntimeContributionGroup[] {\n const groups: RuntimeContributionGroup[] = [];\n for (const manifest of registry.manifests) {\n const modules = new Map<string, string[]>();\n for (const contribution of manifest.contributions) {\n if (contribution.executionKind !== kind) continue;\n const ids = modules.get(contribution.implementationModule) ?? [];\n ids.push(contribution.ruleId);\n modules.set(contribution.implementationModule, ids);\n }\n for (const entry of modules) {\n const moduleName = entry[0], ids = entry[1];\n groups.push(\n new RuntimeContributionGroup(manifest.packageName, moduleName, kind, ids),\n );\n }\n }\n return groups;\n }\n\n // webpieces-disable no-any-unknown -- transport boundary for execution-family adapters\n load(\n group: RuntimeContributionGroup,\n providers: ReadonlyMap<string, string>,\n loader: RuleRuntimeModuleLoader,\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n ): unknown {\n const provider = providers.get(group.providerPack);\n if (!provider)\n throw new InformAiError(\n `Missing declared manifest module for ${group.providerPack}. Repair rulePacks.`,\n );\n return loader.load(group.implementationModule, provider);\n }\n\n request(\n root: string,\n configs: Readonly<Record<string, ConfigObject>>,\n group: RuntimeContributionGroup,\n // The repo's top-level `excludePaths` — handed to the runtime so it applies them (#1253).\n excludePaths: readonly string[],\n ): PolicyRuntimeRequest {\n const selected: Record<string, ConfigObject> = {};\n for (const id of group.ruleIds) {\n if (!Object.hasOwn(configs, id))\n throw new InformAiError(\n `Missing explicit config for ${id}. Repair its declared owner file.`,\n );\n selected[id] = configs[id];\n }\n return new PolicyRuntimeRequest(root, selected, group.ruleIds, excludePaths);\n }\n\n // webpieces-disable no-any-unknown -- public exports are validated before use; no concrete execution package is imported\n async createBuildPolicies(\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n exports: unknown,\n request: PolicyRuntimeRequest,\n ): Promise<readonly BuildPolicy[]> {\n if (!exports || typeof exports !== 'object' || !('buildRuleRuntime' in exports)) {\n throw new InformAiError(\n 'Build contribution must export buildRuleRuntime.create(request). Repair its public runtime export.',\n );\n }\n const runtime = exports.buildRuleRuntime as BuildRuleRuntime;\n if (!runtime || typeof runtime.create !== 'function')\n throw new InformAiError(\n 'Invalid buildRuleRuntime.create. Supply a build runtime factory.',\n );\n const checks = await runtime.create(request);\n if (!Array.isArray(checks))\n throw new InformAiError('Build runtime must return an array of configured checks.');\n const covered = new Set<string>();\n for (const check of checks) {\n if (\n !check ||\n typeof check.name !== 'string' ||\n !check.name ||\n !request.ruleIds.includes(check.configKey) ||\n typeof check.shouldRun !== 'function' ||\n typeof check.run !== 'function'\n ) {\n throw new InformAiError(\n 'Invalid build check. Supply name, declared configKey, shouldRun(), and run(root).',\n );\n }\n covered.add(check.configKey);\n }\n for (const id of request.ruleIds) {\n if (!covered.has(id))\n throw new InformAiError(\n `Build runtime omitted declared policy ${id}. Supply its actual implementation.`,\n );\n }\n return checks;\n }\n}\n"]}
1
+ {"version":3,"file":"rule-runtime-modules.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/rule-runtime-modules.ts"],"names":[],"mappings":";;;;AAAA,wDAAkC;AAClC,6CAA4C;AAC5C,oDAS8B;AAC9B,8DAA6E;AAE7E,yEAAoE;AACpE,iEAA6D;AAE7D,0FAA0F;AAC1F,MAAa,wBAAwB;IAEpB;IACA;IACA;IACA;IAJb,YACa,YAAoB,EACp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O,CAAC,OAAO,EAAE,CAAC;YAC/B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;gBAChB,MAAM,IAAI,8BAAa,CACnB,yCAAyC,EAAE,qCAAqC,CACnF,CAAC;QACV,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAnHD,gDAmHC","sourcesContent":["import * as path from 'node:path';\nimport { createRequire } from 'node:module';\nimport {\n BuildPolicy,\n BuildRuleRuntime,\n BuildDebugRequest,\n BuildDebugRuntime,\n BuildPolicyResult,\n ConfigObject,\n ExecutionKind,\n PolicyRuntimeRequest,\n} from '@webpieces/rules-sdk';\nimport { InformAiError, TypeScriptRequire } from '@webpieces/tooling-common';\nimport { RulePackRegistry } from './rule-pack-registry';\nimport { ClientModuleResolution } from './client-module-resolution';\nimport { toError } from '@webpieces/tooling-common/to-error';\n\n/** Describes an implementation without evaluating its module during config validation. */\nexport class RuntimeContributionGroup {\n constructor(\n readonly providerPack: string,\n readonly implementationModule: string,\n readonly executionKind: ExecutionKind,\n readonly ruleIds: readonly string[],\n ) {}\n}\n\nexport abstract class RuleRuntimeModuleLoader {\n // webpieces-disable no-any-unknown -- execution-family consumers validate external module contracts\n abstract load(moduleName: string, providerModule: string): unknown;\n}\n\nexport class NodeRuleRuntimeModuleLoader extends RuleRuntimeModuleLoader {\n private readonly resolution: ClientModuleResolution;\n private readonly requireModule: NodeRequire;\n\n constructor(clientRoot: string) {\n super();\n this.resolution = new ClientModuleResolution(clientRoot);\n this.requireModule = createRequire(path.join(clientRoot, 'package.json'));\n }\n\n // webpieces-disable no-any-unknown -- narrowed by its execution-family consumer\n override load(moduleName: string, providerModule: string): unknown {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- a declared module fault names the runtime and declaration needed for repair\n try {\n const resolved =\n moduleName.startsWith('.') || path.isAbsolute(moduleName)\n ? path.resolve(\n path.dirname(this.resolution.resolve(providerModule)),\n moduleName,\n )\n : this.resolution.resolve(moduleName);\n return new TypeScriptRequire().load(this.requireModule, resolved);\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 throw new InformAiError(\n `Cannot load declared policy runtime ${moduleName} from ${providerModule}: ${error.message}. Repair its public implementation module or root declaration.`,\n { cause: error },\n );\n }\n }\n}\n\n/** Grouped module loading has no built-in package list or policy IDs. */\nexport class RuleRuntimeModules {\n // webpieces-disable no-any-unknown -- a selected provider explicitly advertises its debug capability\n async runBuildDebug(exports: unknown, request: BuildDebugRequest): Promise<BuildPolicyResult> {\n if (!exports || typeof exports !== 'object' || !('buildDebugRuntime' in exports)) {\n throw new InformAiError(\n `The build provider for ${request.selection.rule} does not support debug runs. Use its declared policy settings and normal validation.`,\n );\n }\n const runtime = exports.buildDebugRuntime as BuildDebugRuntime;\n if (!runtime || typeof runtime.run !== 'function')\n throw new InformAiError(\n 'Invalid buildDebugRuntime.run(request). Repair the provider export.',\n );\n const result = await runtime.run(request);\n if (!result || typeof result.success !== 'boolean')\n throw new InformAiError('Debug runtime must return an explicit success boolean.');\n return result;\n }\n\n groups(registry: RulePackRegistry, kind: ExecutionKind): readonly RuntimeContributionGroup[] {\n const groups: RuntimeContributionGroup[] = [];\n for (const manifest of registry.manifests) {\n const modules = new Map<string, string[]>();\n for (const contribution of manifest.contributions) {\n if (contribution.executionKind !== kind) continue;\n const ids = modules.get(contribution.implementationModule) ?? [];\n ids.push(contribution.ruleId);\n modules.set(contribution.implementationModule, ids);\n }\n for (const entry of modules) {\n const moduleName = entry[0], ids = entry[1];\n groups.push(\n new RuntimeContributionGroup(manifest.packageName, moduleName, kind, ids),\n );\n }\n }\n return groups;\n }\n\n // webpieces-disable no-any-unknown -- transport boundary for execution-family adapters\n load(\n group: RuntimeContributionGroup,\n providers: ReadonlyMap<string, string>,\n loader: RuleRuntimeModuleLoader,\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n ): unknown {\n const provider = providers.get(group.providerPack);\n if (!provider)\n throw new InformAiError(\n `Missing declared manifest module for ${group.providerPack}. Repair rulePacks.`,\n );\n return loader.load(group.implementationModule, provider);\n }\n\n request(\n root: string,\n configs: Readonly<Record<string, ConfigObject>>,\n group: RuntimeContributionGroup,\n // The repo's top-level `excludePaths` — handed to the runtime so it applies them (#1253).\n excludePaths: readonly string[],\n ): PolicyRuntimeRequest {\n const selected: Record<string, ConfigObject> = {};\n for (const id of group.ruleIds) {\n if (!Object.hasOwn(configs, id))\n throw new InformAiError(\n `Missing explicit config for ${id}. Repair its declared owner file.`,\n );\n selected[id] = configs[id];\n }\n return new PolicyRuntimeRequest(root, selected, group.ruleIds, excludePaths);\n }\n\n // webpieces-disable no-any-unknown -- public exports are validated before use; no concrete execution package is imported\n async createBuildPolicies(\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n exports: unknown,\n request: PolicyRuntimeRequest,\n ): Promise<readonly BuildPolicy[]> {\n if (!exports || typeof exports !== 'object' || !('buildRuleRuntime' in exports)) {\n throw new InformAiError(\n 'Build contribution must export buildRuleRuntime.create(request). Repair its public runtime export.',\n );\n }\n const runtime = exports.buildRuleRuntime as BuildRuleRuntime;\n if (!runtime || typeof runtime.create !== 'function')\n throw new InformAiError(\n 'Invalid buildRuleRuntime.create. Supply a build runtime factory.',\n );\n const checks = await runtime.create(request);\n if (!Array.isArray(checks))\n throw new InformAiError('Build runtime must return an array of configured checks.');\n const covered = new Set<string>();\n for (const check of checks) {\n if (\n !check ||\n typeof check.name !== 'string' ||\n !check.name ||\n !request.ruleIds.includes(check.configKey) ||\n typeof check.shouldRun !== 'function' ||\n typeof check.run !== 'function'\n ) {\n throw new InformAiError(\n 'Invalid build check. Supply name, declared configKey, shouldRun(), and run(root).',\n );\n }\n covered.add(check.configKey);\n }\n for (const id of request.ruleIds) {\n if (!covered.has(id))\n throw new InformAiError(\n `Build runtime omitted declared policy ${id}. Supply its actual implementation.`,\n );\n }\n return checks;\n }\n}\n"]}
@@ -739,6 +739,53 @@ const config = JSON.parse(raw);
739
739
  The `cause` field is available on the original error object and will appear in stack traces
740
740
  and in `/debugLocal/{traceId}` responses.
741
741
 
742
+ ## Rule: catch-must-propagate
743
+
744
+ `throw-cause-required` only fires on a THROW inside a catch. A catch that copies `error.message` into a
745
+ field, a variable or a return value, and lets the error go, throws nothing — so the cause disappears and
746
+ a later, generic error says nothing of why. `catch-must-propagate` judges the catch itself: the caught
747
+ error must leave it WHOLE.
748
+
749
+ ### BAD (triggers violation)
750
+ ```typescript
751
+ } catch (err: unknown) {
752
+ const error = toError(err);
753
+ this.diagnostic = error.message; // ← only the text survives
754
+ }
755
+
756
+ } catch { // ← no binding: the error is dropped
757
+ return undefined;
758
+ }
759
+ ```
760
+
761
+ ### GOOD — any one of these, with the error whole
762
+ ```typescript
763
+ } catch (err: unknown) {
764
+ const error = toError(err);
765
+ throw new Error('Cannot decode the saved script', { cause: error }); // thrown as a cause
766
+ }
767
+ } catch (err: unknown) {
768
+ log.warn('decode failed', toError(err)); // a configured forwarder (catch-must-propagate.forwards)
769
+ }
770
+ } catch (err: unknown) {
771
+ this.lastError = toError(err); // stored whole on a member for a later throw
772
+ }
773
+ } catch (err: unknown) {
774
+ return toError(err); // returned whole to a caller that throws it
775
+ }
776
+ ```
777
+
778
+ Only `err.message`, `String(err)`, `JSON.stringify(err)`, a template or `+` does NOT count. A helper
779
+ the error is passed to (`report(err)`) counts only once its name is listed in the rule's `forwards`.
780
+
781
+ If dropping the error is genuinely correct (an EXPECTED condition, not a defect), say why, per site, on
782
+ the catch's line or the line above it — a reason of at least 20 characters is required:
783
+
784
+ ```typescript
785
+ // webpieces-disable catch-must-propagate -- a missing file is the expected first-run state
786
+ } catch {
787
+ ```
788
+
742
789
  ## Summary
743
790
 
744
791
  **The webpieces philosophy**: Errors should bubble to the global handler where they are logged with traceId and stored for debugging. Local try-catch blocks break this architecture and create blind spots in production.