@webpieces/rules-config 0.4.843 → 0.4.845

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/package.json +9 -4
  2. package/src/WebpiecesRulesConfig.d.ts +3 -49
  3. package/src/WebpiecesRulesConfig.js +1 -44
  4. package/src/WebpiecesRulesConfig.js.map +1 -1
  5. package/src/abstract-rule.d.ts +1 -1
  6. package/src/abstract-rule.js.map +1 -1
  7. package/src/config-pruner.d.ts +3 -1
  8. package/src/config-pruner.js +13 -9
  9. package/src/config-pruner.js.map +1 -1
  10. package/src/constants.d.ts +0 -37
  11. package/src/constants.js +1 -38
  12. package/src/constants.js.map +1 -1
  13. package/src/index.d.ts +7 -24
  14. package/src/index.js +14 -105
  15. package/src/index.js.map +1 -1
  16. package/src/load-config.d.ts +6 -2
  17. package/src/load-config.js +17 -11
  18. package/src/load-config.js.map +1 -1
  19. package/src/match-rules-config.d.ts +2 -1
  20. package/src/match-rules-config.js +2 -2
  21. package/src/match-rules-config.js.map +1 -1
  22. package/src/no-custom-css-scope.d.ts +9 -25
  23. package/src/no-custom-css-scope.js +10 -24
  24. package/src/no-custom-css-scope.js.map +1 -1
  25. package/src/retired-config-keys.d.ts +3 -64
  26. package/src/retired-config-keys.js +14 -152
  27. package/src/retired-config-keys.js.map +1 -1
  28. package/src/rule-pack-registry.d.ts +41 -0
  29. package/src/rule-pack-registry.js +231 -0
  30. package/src/rule-pack-registry.js.map +1 -0
  31. package/src/rule-pack-selection.d.ts +6 -0
  32. package/src/rule-pack-selection.js +50 -0
  33. package/src/rule-pack-selection.js.map +1 -0
  34. package/src/rule-schemas.d.ts +4 -14
  35. package/src/rule-schemas.js +6 -92
  36. package/src/rule-schemas.js.map +1 -1
  37. package/src/sections.d.ts +5 -46
  38. package/src/sections.js +5 -56
  39. package/src/sections.js.map +1 -1
  40. package/src/seed-entry.d.ts +5 -16
  41. package/src/seed-entry.js +14 -141
  42. package/src/seed-entry.js.map +1 -1
  43. package/src/validate-config.d.ts +3 -2
  44. package/src/validate-config.js +62 -73
  45. package/src/validate-config.js.map +1 -1
  46. package/templates/webpieces.branch-state-matrix.md +1 -1
  47. package/src/api-doc-rules-config.d.ts +0 -60
  48. package/src/api-doc-rules-config.js +0 -71
  49. package/src/api-doc-rules-config.js.map +0 -1
  50. package/src/api-lib-spelling-configs.d.ts +0 -40
  51. package/src/api-lib-spelling-configs.js +0 -52
  52. package/src/api-lib-spelling-configs.js.map +0 -1
  53. package/src/default-rules.d.ts +0 -2
  54. package/src/default-rules.js +0 -119
  55. package/src/default-rules.js.map +0 -1
  56. package/src/field-def.d.ts +0 -24
  57. package/src/field-def.js +0 -59
  58. package/src/field-def.js.map +0 -1
  59. package/src/main-sync-guard-configs.d.ts +0 -38
  60. package/src/main-sync-guard-configs.js +0 -54
  61. package/src/main-sync-guard-configs.js.map +0 -1
  62. package/src/no-client-creation-config.d.ts +0 -12
  63. package/src/no-client-creation-config.js +0 -40
  64. package/src/no-client-creation-config.js.map +0 -1
  65. package/src/no-root-union-config.d.ts +0 -25
  66. package/src/no-root-union-config.js +0 -33
  67. package/src/no-root-union-config.js.map +0 -1
  68. package/src/no-state-paths-config.d.ts +0 -41
  69. package/src/no-state-paths-config.js +0 -51
  70. package/src/no-state-paths-config.js.map +0 -1
  71. package/src/no-utility-types-config.d.ts +0 -30
  72. package/src/no-utility-types-config.js +0 -39
  73. package/src/no-utility-types-config.js.map +0 -1
  74. package/src/required-type-suffix-config.d.ts +0 -49
  75. package/src/required-type-suffix-config.js +0 -62
  76. package/src/required-type-suffix-config.js.map +0 -1
  77. package/src/rule-configs.d.ts +0 -273
  78. package/src/rule-configs.js +0 -595
  79. package/src/rule-configs.js.map +0 -1
  80. package/src/spec-temp-dirs.d.ts +0 -37
  81. package/src/spec-temp-dirs.js +0 -113
  82. package/src/spec-temp-dirs.js.map +0 -1
  83. package/src/tag-truth-configs.d.ts +0 -137
  84. package/src/tag-truth-configs.js +0 -175
  85. package/src/tag-truth-configs.js.map +0 -1
@@ -0,0 +1,231 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RulePackDiscovery = exports.RulePackRegistry = exports.NodeRulePackModuleLoader = exports.RulePackModuleLoader = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const inversify_1 = require("inversify");
6
+ const node_module_1 = require("node:module");
7
+ const tooling_common_1 = require("@webpieces/tooling-common");
8
+ const path = tslib_1.__importStar(require("node:path"));
9
+ const rules_sdk_1 = require("@webpieces/rules-sdk");
10
+ /** Loading is the only impure boundary; callers may supply an alternative module transport. */
11
+ class RulePackModuleLoader {
12
+ }
13
+ exports.RulePackModuleLoader = RulePackModuleLoader;
14
+ class NodeRulePackModuleLoader extends RulePackModuleLoader {
15
+ requireModule;
16
+ constructor(clientRoot) {
17
+ super();
18
+ this.requireModule = (0, node_module_1.createRequire)(path.join(clientRoot, 'package.json'));
19
+ }
20
+ load(moduleName) {
21
+ // webpieces-disable no-any-unknown -- external module boundary; registry validates its exported data before use
22
+ const exports = this.requireModule(moduleName);
23
+ if (typeof exports !== 'object' || exports === null || !('rulePackManifest' in exports)) {
24
+ throw new tooling_common_1.InformAiError(`Rule pack ${moduleName} must export rulePackManifest. Add the public manifest export.`);
25
+ }
26
+ return exports.rulePackManifest;
27
+ }
28
+ }
29
+ exports.NodeRulePackModuleLoader = NodeRulePackModuleLoader;
30
+ /** A registry depends only on declarations and the SDK, never on concrete execution packages. */
31
+ class RulePackRegistry {
32
+ manifests;
33
+ owners = new Map();
34
+ definitions = new Map();
35
+ safeguards = new Map();
36
+ constructor(manifests) {
37
+ this.manifests = manifests;
38
+ const packs = new Set();
39
+ for (const manifest of manifests) {
40
+ this.validateManifest(manifest);
41
+ if (packs.has(manifest.packageName))
42
+ throw new tooling_common_1.InformAiError(`Duplicate pack ${manifest.packageName}. Declare it once.`);
43
+ packs.add(manifest.packageName);
44
+ for (const definition of manifest.ownedRules) {
45
+ if (this.owners.has(definition.id))
46
+ throw new tooling_common_1.InformAiError(`Rule ${definition.id} has multiple owners. Keep exactly one owner.`);
47
+ this.owners.set(definition.id, manifest.packageName);
48
+ this.definitions.set(definition.id, definition);
49
+ }
50
+ }
51
+ for (const manifest of manifests) {
52
+ for (const safeguard of manifest.safeguards) {
53
+ if (!safeguard || typeof safeguard.id !== 'string' || !safeguard.id ||
54
+ !['fixed', 'experimental'].includes(safeguard.activation) ||
55
+ typeof safeguard.description !== 'string' || !safeguard.description) {
56
+ throw new tooling_common_1.InformAiError('Invalid safeguard catalog. Supply id, activation, and description.');
57
+ }
58
+ if (this.owners.has(safeguard.id) || this.safeguards.has(safeguard.id)) {
59
+ throw new tooling_common_1.InformAiError(`Safeguard ${safeguard.id} cannot be configured or owned twice. Keep it outside configurable policies.`);
60
+ }
61
+ this.safeguards.set(safeguard.id, safeguard);
62
+ }
63
+ }
64
+ const executions = new Set();
65
+ for (const manifest of manifests) {
66
+ for (const contribution of manifest.contributions) {
67
+ if (!contribution || typeof contribution.ruleId !== 'string' || typeof contribution.ownerPack !== 'string') {
68
+ throw new tooling_common_1.InformAiError(`Invalid contribution in ${manifest.packageName}. Supply ruleId and ownerPack.`);
69
+ }
70
+ const owner = this.owners.get(contribution.ruleId);
71
+ if (!owner || owner !== contribution.ownerPack) {
72
+ throw new tooling_common_1.InformAiError(`Unknown owner ${contribution.ownerPack} for ${contribution.ruleId}. Declare the owning pack and use its exact name.`);
73
+ }
74
+ if (!['build', 'source-hook', 'workflow-guard', 'lint'].includes(contribution.executionKind)) {
75
+ throw new tooling_common_1.InformAiError(`Invalid execution kind for ${contribution.ruleId}. Use build, source-hook, workflow-guard, or lint.`);
76
+ }
77
+ const execution = `${contribution.ruleId}:${contribution.executionKind}`;
78
+ if (executions.has(execution))
79
+ throw new tooling_common_1.InformAiError(`Duplicate execution-kind contribution ${execution}. Keep one implementation per execution kind.`);
80
+ executions.add(execution);
81
+ }
82
+ }
83
+ }
84
+ ownerOf(ruleId) {
85
+ const owner = this.owners.get(ruleId);
86
+ if (!owner)
87
+ throw new tooling_common_1.InformAiError(`Unknown rule ${ruleId}. Declare its owning pack.`);
88
+ return owner;
89
+ }
90
+ schemaFor(ruleId) {
91
+ this.ownerOf(ruleId);
92
+ return this.definitions.get(ruleId).schema;
93
+ }
94
+ ruleIds() {
95
+ return [...this.definitions.keys()];
96
+ }
97
+ hasRule(ruleId) { return this.definitions.has(ruleId); }
98
+ isSafeguard(ruleId) { return this.safeguards.has(ruleId); }
99
+ sectionFor(ruleId) { return this.definitionFor(ruleId).section; }
100
+ optionalTuningFor(ruleId) { return this.definitionFor(ruleId).optionalTuning; }
101
+ seedFor(ruleId) { return structuredClone(this.definitionFor(ruleId).recommendedSeed); }
102
+ migrations() { return this.manifests.flatMap(manifest => [...manifest.migrations]); }
103
+ safeguardCatalog() { return [...this.safeguards.values()]; }
104
+ definitionFor(ruleId) {
105
+ this.ownerOf(ruleId);
106
+ return this.definitions.get(ruleId);
107
+ }
108
+ /** Validates explicit config values with the owner's schema; supplies no rule defaults. */
109
+ validateRuleConfig(ruleId, value) {
110
+ return this.validateObject(ruleId, this.schemaFor(ruleId), value);
111
+ }
112
+ validateManifest(manifest) {
113
+ if (!manifest || typeof manifest.packageName !== 'string' || manifest.packageName.length === 0 ||
114
+ typeof manifest.packageVersion !== 'string' || manifest.packageVersion.length === 0 ||
115
+ !Array.isArray(manifest.ownedRules) || !Array.isArray(manifest.contributions) ||
116
+ !Array.isArray(manifest.migrations) || !Array.isArray(manifest.safeguards)) {
117
+ throw new tooling_common_1.InformAiError('Invalid rule pack manifest. Supply packageName, packageVersion, ownedRules, contributions, migrations, and safeguards.');
118
+ }
119
+ if (manifest.apiVersion !== rules_sdk_1.RULE_PACK_API_VERSION) {
120
+ throw new tooling_common_1.InformAiError(`Unsupported manifest API ${manifest.apiVersion} for ${manifest.packageName}. Use API ${rules_sdk_1.RULE_PACK_API_VERSION}.`);
121
+ }
122
+ for (const definition of manifest.ownedRules) {
123
+ if (!definition || typeof definition.id !== 'string' || definition.id.length === 0) {
124
+ throw new tooling_common_1.InformAiError(`Invalid owned rule in ${manifest.packageName}. Supply a nonempty id.`);
125
+ }
126
+ if (definition.schemaApiVersion !== rules_sdk_1.RULE_SCHEMA_API_VERSION) {
127
+ throw new tooling_common_1.InformAiError(`Unsupported schema API for ${definition.id}. Use API ${rules_sdk_1.RULE_SCHEMA_API_VERSION}.`);
128
+ }
129
+ this.validateSchema(definition.id, definition.schema);
130
+ this.validateOwnerSettings(definition);
131
+ }
132
+ for (const migration of manifest.migrations) {
133
+ if (!migration || !['rule', 'key', 'field'].includes(migration.scope) ||
134
+ typeof migration.key !== 'string' || !migration.key ||
135
+ typeof migration.movedTo !== 'string' || typeof migration.instruction !== 'string' ||
136
+ !migration.instruction || typeof migration.label !== 'string' || typeof migration.prunable !== 'boolean') {
137
+ throw new tooling_common_1.InformAiError(`Invalid migration in ${manifest.packageName}. Supply the retired key and exact edit.`);
138
+ }
139
+ }
140
+ }
141
+ validateOwnerSettings(definition) {
142
+ if (!['rules', 'hookGuards', 'lint'].includes(definition.section)) {
143
+ throw new tooling_common_1.InformAiError(`Invalid config section for ${definition.id}. Use rules, hookGuards, or lint.`);
144
+ }
145
+ const tuning = definition.optionalTuning;
146
+ if (!tuning || typeof tuning !== 'object' || Array.isArray(tuning)) {
147
+ throw new tooling_common_1.InformAiError(`Missing optional tuning for ${definition.id}. Supply an explicit object, including {} when empty.`);
148
+ }
149
+ for (const key of Object.keys(tuning)) {
150
+ const field = definition.schema[key];
151
+ if (!field || !field.optional || key === 'mode') {
152
+ throw new tooling_common_1.InformAiError(`${definition.id}.${key} cannot have a default. Keep required behaviour in explicit repository config.`);
153
+ }
154
+ const errors = this.validateObject(definition.id, { [key]: field }, { [key]: tuning[key] });
155
+ if (errors.length)
156
+ throw new tooling_common_1.InformAiError(errors.join('\n'));
157
+ }
158
+ const errors = this.validateObject(definition.id, definition.schema, definition.recommendedSeed);
159
+ if (errors.length)
160
+ throw new tooling_common_1.InformAiError(`Invalid recommended seed: ${errors.join('\n')}. Fix the owner's seed; the loader never applies it.`);
161
+ }
162
+ validateSchema(location, schema) {
163
+ if (!schema || typeof schema !== 'object' || Array.isArray(schema))
164
+ throw new tooling_common_1.InformAiError(`Invalid schema for ${location}. Supply a field map.`);
165
+ for (const [key, field] of Object.entries(schema)) {
166
+ if (!field || !['string', 'number', 'boolean', 'string[]', 'object[]'].includes(field.type)) {
167
+ throw new tooling_common_1.InformAiError(`Invalid field ${location}.${key}. Supply a supported FieldDef type.`);
168
+ }
169
+ for (const flag of ['optional', 'nullable', 'nonEmpty']) {
170
+ if (field[flag] !== undefined && typeof field[flag] !== 'boolean')
171
+ throw new tooling_common_1.InformAiError(`Invalid ${flag} for ${location}.${key}. Supply a boolean.`);
172
+ }
173
+ if (field.enumValues !== undefined && (!Array.isArray(field.enumValues) || field.enumValues.some(item => typeof item !== 'string'))) {
174
+ throw new tooling_common_1.InformAiError(`Invalid enum for ${location}.${key}. Supply string values.`);
175
+ }
176
+ if (field.type === 'object[]')
177
+ this.validateSchema(`${location}.${key}[]`, field.elementSchema);
178
+ }
179
+ }
180
+ validateObject(location, schema, value) {
181
+ if (!value || typeof value !== 'object' || Array.isArray(value))
182
+ return [`${location} must be an explicitly configured object.`];
183
+ const errors = [];
184
+ for (const key of Object.keys(value))
185
+ if (!Object.hasOwn(schema, key))
186
+ errors.push(`${location}.${key} is unknown. Use a field declared by its owner.`);
187
+ for (const [key, field] of Object.entries(schema)) {
188
+ const entry = Object.hasOwn(value, key) ? value[key] : undefined, label = `${location}.${key}`;
189
+ if (entry === undefined) {
190
+ if (!field.optional)
191
+ errors.push(`${label} is required. Add an explicit ${field.type} value.`);
192
+ continue;
193
+ }
194
+ if (entry === null && field.nullable)
195
+ continue;
196
+ const valid = field.type.endsWith('[]') ? Array.isArray(entry) : typeof entry === field.type;
197
+ if (!valid || entry === null) {
198
+ errors.push(`${label} must be ${field.type}.`);
199
+ continue;
200
+ }
201
+ if (field.enumValues && !field.enumValues.includes(String(entry)))
202
+ errors.push(`${label} must be one of ${field.enumValues.join(', ')}.`);
203
+ if (Array.isArray(entry)) {
204
+ if (field.nonEmpty && entry.length === 0)
205
+ errors.push(`${label} must contain at least one entry.`);
206
+ if (field.type === 'string[]' && entry.some(item => typeof item !== 'string'))
207
+ errors.push(`${label} must contain only strings.`);
208
+ if (field.type === 'object[]')
209
+ entry.forEach((item, index) => errors.push(...this.validateObject(`${label}[${index}]`, field.elementSchema, item)));
210
+ }
211
+ }
212
+ return errors;
213
+ }
214
+ }
215
+ exports.RulePackRegistry = RulePackRegistry;
216
+ /** Inject the selected module transport; discovery never names a built-in owner package. */
217
+ let RulePackDiscovery = class RulePackDiscovery {
218
+ loader;
219
+ constructor(loader) {
220
+ this.loader = loader;
221
+ }
222
+ discover(declarations) {
223
+ return new RulePackRegistry(declarations.map(declaration => this.loader.load(declaration.module)));
224
+ }
225
+ };
226
+ exports.RulePackDiscovery = RulePackDiscovery;
227
+ exports.RulePackDiscovery = RulePackDiscovery = tslib_1.__decorate([
228
+ (0, inversify_1.injectable)(inversify_1.bindingScopeValues.Singleton),
229
+ tslib_1.__metadata("design:paramtypes", [RulePackModuleLoader])
230
+ ], RulePackDiscovery);
231
+ //# sourceMappingURL=rule-pack-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rule-pack-registry.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/rule-pack-registry.ts"],"names":[],"mappings":";;;;AAAA,yCAA2D;AAC3D,6CAA4C;AAC5C,8DAA0D;AAC1D,wDAAkC;AAClC,oDAG8B;AAE9B,+FAA+F;AAC/F,MAAsB,oBAAoB;CAEzC;AAFD,oDAEC;AAED,MAAa,wBAAyB,SAAQ,oBAAoB;IAC7C,aAAa,CAAc;IAE5C,YAAY,UAAkB;QAC1B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,aAAa,GAAG,IAAA,2BAAa,EAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,cA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BAAiB;IAD7B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEA,oBAAoB;GADhD,iBAAiB,CAM7B","sourcesContent":["import { injectable, bindingScopeValues } from 'inversify';\nimport { createRequire } from 'node:module';\nimport { InformAiError } from '@webpieces/tooling-common';\nimport * as path from 'node:path';\nimport {\n FieldDef, RulePackManifest, RulePackDeclaration, OwnedRuleDefinition,\n RULE_PACK_API_VERSION, RULE_SCHEMA_API_VERSION, ConfigObject, RetiredConfigKey, SafeguardDefinition, RuleConfigSection,\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\n constructor(clientRoot: string) {\n super();\n this.requireModule = createRequire(path.join(clientRoot, 'package.json'));\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(moduleName);\n if (typeof exports !== 'object' || exports === null || !('rulePackManifest' in exports)) {\n throw new InformAiError(`Rule pack ${moduleName} must export rulePackManifest. Add the public manifest export.`);\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 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 const packs = new Set<string>();\n for (const manifest of manifests) {\n this.validateManifest(manifest);\n if (packs.has(manifest.packageName)) 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)) throw new InformAiError(`Rule ${definition.id} has multiple owners. Keep exactly one owner.`);\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 (!safeguard || typeof safeguard.id !== 'string' || !safeguard.id ||\n !['fixed', 'experimental'].includes(safeguard.activation) ||\n typeof safeguard.description !== 'string' || !safeguard.description) {\n throw new InformAiError('Invalid safeguard catalog. Supply id, activation, and description.');\n }\n if (this.owners.has(safeguard.id) || this.safeguards.has(safeguard.id)) {\n throw new InformAiError(`Safeguard ${safeguard.id} cannot be configured or owned twice. Keep it outside configurable policies.`);\n }\n this.safeguards.set(safeguard.id, safeguard);\n }\n }\n const executions = new Set<string>();\n for (const manifest of manifests) {\n for (const contribution of manifest.contributions) {\n if (!contribution || typeof contribution.ruleId !== 'string' || typeof contribution.ownerPack !== 'string') {\n throw new InformAiError(`Invalid contribution in ${manifest.packageName}. Supply ruleId and ownerPack.`);\n }\n const owner = this.owners.get(contribution.ruleId);\n if (!owner || owner !== contribution.ownerPack) {\n throw new InformAiError(`Unknown owner ${contribution.ownerPack} for ${contribution.ruleId}. Declare the owning pack and use its exact name.`);\n }\n if (!['build', 'source-hook', 'workflow-guard', 'lint'].includes(contribution.executionKind)) {\n throw new InformAiError(`Invalid execution kind for ${contribution.ruleId}. Use build, source-hook, workflow-guard, or lint.`);\n }\n const execution = `${contribution.ruleId}:${contribution.executionKind}`;\n if (executions.has(execution)) throw new InformAiError(`Duplicate execution-kind contribution ${execution}. Keep one implementation per execution kind.`);\n executions.add(execution);\n }\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 ruleIds(): readonly string[] {\n return [...this.definitions.keys()];\n }\n\n hasRule(ruleId: string): boolean { return this.definitions.has(ruleId); }\n\n isSafeguard(ruleId: string): boolean { return this.safeguards.has(ruleId); }\n\n sectionFor(ruleId: string): RuleConfigSection { return this.definitionFor(ruleId).section; }\n\n optionalTuningFor(ruleId: string): ConfigObject { return this.definitionFor(ruleId).optionalTuning; }\n\n seedFor(ruleId: string): ConfigObject { return structuredClone(this.definitionFor(ruleId).recommendedSeed); }\n\n migrations(): readonly RetiredConfigKey[] { return this.manifests.flatMap(manifest => [...manifest.migrations]); }\n\n safeguardCatalog(): readonly SafeguardDefinition[] { return [...this.safeguards.values()]; }\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 return this.validateObject(ruleId, this.schemaFor(ruleId), value);\n }\n\n private validateManifest(manifest: RulePackManifest): void {\n if (!manifest || typeof manifest.packageName !== 'string' || manifest.packageName.length === 0 ||\n typeof manifest.packageVersion !== 'string' || manifest.packageVersion.length === 0 ||\n !Array.isArray(manifest.ownedRules) || !Array.isArray(manifest.contributions) ||\n !Array.isArray(manifest.migrations) || !Array.isArray(manifest.safeguards)) {\n throw new InformAiError('Invalid rule pack manifest. Supply packageName, packageVersion, ownedRules, contributions, migrations, and safeguards.');\n }\n if (manifest.apiVersion !== RULE_PACK_API_VERSION) {\n throw new InformAiError(`Unsupported manifest API ${manifest.apiVersion} for ${manifest.packageName}. Use API ${RULE_PACK_API_VERSION}.`);\n }\n for (const definition of manifest.ownedRules) {\n if (!definition || typeof definition.id !== 'string' || definition.id.length === 0) {\n throw new InformAiError(`Invalid owned rule in ${manifest.packageName}. Supply a nonempty id.`);\n }\n if (definition.schemaApiVersion !== RULE_SCHEMA_API_VERSION) {\n throw new InformAiError(`Unsupported schema API for ${definition.id}. Use API ${RULE_SCHEMA_API_VERSION}.`);\n }\n this.validateSchema(definition.id, definition.schema);\n this.validateOwnerSettings(definition);\n }\n for (const migration of manifest.migrations) {\n if (!migration || !['rule', 'key', 'field'].includes(migration.scope) ||\n typeof migration.key !== 'string' || !migration.key ||\n typeof migration.movedTo !== 'string' || typeof migration.instruction !== 'string' ||\n !migration.instruction || typeof migration.label !== 'string' || typeof migration.prunable !== 'boolean') {\n throw new InformAiError(`Invalid migration in ${manifest.packageName}. Supply the retired key and exact edit.`);\n }\n }\n }\n\n private validateOwnerSettings(definition: OwnedRuleDefinition): void {\n if (!['rules', 'hookGuards', 'lint'].includes(definition.section)) {\n throw new InformAiError(`Invalid config section for ${definition.id}. Use rules, hookGuards, or lint.`);\n }\n const tuning = definition.optionalTuning;\n if (!tuning || typeof tuning !== 'object' || Array.isArray(tuning)) {\n throw new InformAiError(`Missing optional tuning for ${definition.id}. Supply an explicit object, including {} when empty.`);\n }\n for (const key of Object.keys(tuning)) {\n const field = definition.schema[key];\n if (!field || !field.optional || key === 'mode') {\n throw new InformAiError(`${definition.id}.${key} cannot have a default. Keep required behaviour in explicit repository config.`);\n }\n const errors = this.validateObject(definition.id, { [key]: field }, { [key]: tuning[key] });\n if (errors.length) throw new InformAiError(errors.join('\\n'));\n }\n const errors = this.validateObject(definition.id, definition.schema, definition.recommendedSeed);\n if (errors.length) throw new InformAiError(`Invalid recommended seed: ${errors.join('\\n')}. Fix the owner's seed; the loader never applies it.`);\n }\n\n private validateSchema(location: string, schema: Readonly<Record<string, FieldDef>>): void {\n if (!schema || typeof schema !== 'object' || Array.isArray(schema)) throw new InformAiError(`Invalid schema for ${location}. Supply a field map.`);\n for (const [key, field] of Object.entries(schema)) {\n if (!field || !['string', 'number', 'boolean', 'string[]', 'object[]'].includes(field.type)) {\n throw new InformAiError(`Invalid field ${location}.${key}. Supply a supported FieldDef type.`);\n }\n for (const flag of ['optional', 'nullable', 'nonEmpty'] as const) {\n if (field[flag] !== undefined && typeof field[flag] !== 'boolean') throw new InformAiError(`Invalid ${flag} for ${location}.${key}. Supply a boolean.`);\n }\n if (field.enumValues !== undefined && (!Array.isArray(field.enumValues) || field.enumValues.some(item => typeof item !== 'string'))) {\n throw new InformAiError(`Invalid enum for ${location}.${key}. Supply string values.`);\n }\n if (field.type === 'object[]') this.validateSchema(`${location}.${key}[]`, field.elementSchema!);\n }\n }\n\n private validateObject(location: string, schema: Readonly<Record<string, FieldDef>>, value: ConfigObject): string[] {\n if (!value || typeof value !== 'object' || Array.isArray(value)) return [`${location} must be an explicitly configured object.`];\n const errors: string[] = [];\n for (const key of Object.keys(value)) if (!Object.hasOwn(schema, key)) errors.push(`${location}.${key} is unknown. Use a field declared by its owner.`);\n for (const [key, field] of Object.entries(schema)) {\n const entry = Object.hasOwn(value, key) ? value[key] : undefined, label = `${location}.${key}`;\n if (entry === undefined) {\n if (!field.optional) 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('[]') ? Array.isArray(entry) : typeof entry === field.type;\n if (!valid || entry === null) { errors.push(`${label} must be ${field.type}.`); continue; }\n if (field.enumValues && !field.enumValues.includes(String(entry))) errors.push(`${label} must be one of ${field.enumValues.join(', ')}.`);\n if (Array.isArray(entry)) {\n if (field.nonEmpty && entry.length === 0) errors.push(`${label} must contain at least one entry.`);\n if (field.type === 'string[]' && entry.some(item => typeof item !== 'string')) errors.push(`${label} must contain only strings.`);\n if (field.type === 'object[]') entry.forEach((item, index) => errors.push(...this.validateObject(`${label}[${index}]`, field.elementSchema!, item as ConfigObject)));\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 return new RulePackRegistry(declarations.map(declaration => this.loader.load(declaration.module)));\n }\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import { RulePackRegistry } from './rule-pack-registry';
2
+ /** Client-owned package declarations are the only source of pack selection. */
3
+ export declare class RulePackSelection {
4
+ loadFrom(clientRoot: string): RulePackRegistry;
5
+ private loadDeclaredFrom;
6
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RulePackSelection = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fs = tslib_1.__importStar(require("node:fs"));
6
+ const path = tslib_1.__importStar(require("node:path"));
7
+ const inversify_1 = require("inversify");
8
+ const rules_sdk_1 = require("@webpieces/rules-sdk");
9
+ const tooling_common_1 = require("@webpieces/tooling-common");
10
+ const to_error_1 = require("@webpieces/tooling-common/to-error");
11
+ const rule_pack_registry_1 = require("./rule-pack-registry");
12
+ /** Client-owned package declarations are the only source of pack selection. */
13
+ let RulePackSelection = class RulePackSelection {
14
+ loadFrom(clientRoot) {
15
+ // eslint-disable-next-line @webpieces/no-unmanaged-exceptions
16
+ try {
17
+ return this.loadDeclaredFrom(clientRoot);
18
+ }
19
+ catch (err) {
20
+ const error = (0, to_error_1.toError)(err);
21
+ if (error instanceof tooling_common_1.InformAiError)
22
+ throw error;
23
+ throw new tooling_common_1.InformAiError(`Cannot load declared rule packs from ${path.join(clientRoot, 'package.json')}: ${error.message}. Install their declared package versions and repair the module declarations.`);
24
+ }
25
+ }
26
+ loadDeclaredFrom(clientRoot) {
27
+ const manifestPath = path.join(clientRoot, 'package.json');
28
+ if (!fs.existsSync(manifestPath)) {
29
+ throw new tooling_common_1.InformAiError(`Missing ${manifestPath}. Declare webpieces.rulePacks in the client package.json before loading policy config.`);
30
+ }
31
+ // webpieces-disable no-any-unknown -- external JSON is narrowed before use
32
+ const pkg = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
33
+ const webpieces = pkg['webpieces'];
34
+ if (!webpieces || typeof webpieces !== 'object' || !('rulePacks' in webpieces) || !Array.isArray(webpieces.rulePacks)) {
35
+ throw new tooling_common_1.InformAiError('Missing webpieces.rulePacks in package.json. Declare each selected pack using its public rule-pack module; there is no built-in pack fallback.');
36
+ }
37
+ const declarations = webpieces.rulePacks.map(entry => {
38
+ if (!entry || typeof entry !== 'object' || typeof entry.module !== 'string' || !entry.module) {
39
+ throw new tooling_common_1.InformAiError('Invalid webpieces.rulePacks entry. Supply {"module":"<package>/rule-pack"}.');
40
+ }
41
+ return new rules_sdk_1.RulePackDeclaration(entry.module);
42
+ });
43
+ return new rule_pack_registry_1.RulePackDiscovery(new rule_pack_registry_1.NodeRulePackModuleLoader(clientRoot)).discover(declarations);
44
+ }
45
+ };
46
+ exports.RulePackSelection = RulePackSelection;
47
+ exports.RulePackSelection = RulePackSelection = tslib_1.__decorate([
48
+ (0, inversify_1.injectable)(inversify_1.bindingScopeValues.Singleton)
49
+ ], RulePackSelection);
50
+ //# sourceMappingURL=rule-pack-selection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rule-pack-selection.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/rule-pack-selection.ts"],"names":[],"mappings":";;;;AAAA,oDAA8B;AAC9B,wDAAkC;AAClC,yCAA2D;AAC3D,oDAA2D;AAC3D,8DAA0D;AAC1D,iEAA6D;AAC7D,6DAAqG;AAErG,+EAA+E;AAExE,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAC1B,QAAQ,CAAC,UAAkB;QACvB,8DAA8D;QAC9D,IAAI,CAAC;YACD,OAAO,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;QAC7C,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACpB,MAAM,KAAK,GAAG,IAAA,kBAAO,EAAC,GAAG,CAAC,CAAC;YAC3B,IAAI,KAAK,YAAY,8BAAa;gBAAE,MAAM,KAAK,CAAC;YAChD,MAAM,IAAI,8BAAa,CAAC,wCAAwC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,KAAK,KAAK,CAAC,OAAO,+EAA+E,CAAC,CAAC;QAC5M,CAAC;IACL,CAAC;IAEO,gBAAgB,CAAC,UAAkB;QACvC,MAAM,YAAY,GAAG,IAAI,CAA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from 'node:fs';\nimport * as path from 'node:path';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { RulePackDeclaration } from '@webpieces/rules-sdk';\nimport { InformAiError } from '@webpieces/tooling-common';\nimport { toError } from '@webpieces/tooling-common/to-error';\nimport { NodeRulePackModuleLoader, RulePackDiscovery, RulePackRegistry } from './rule-pack-registry';\n\n/** Client-owned package declarations are the only source of pack selection. */\n@injectable(bindingScopeValues.Singleton)\nexport class RulePackSelection {\n loadFrom(clientRoot: string): RulePackRegistry {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n return this.loadDeclaredFrom(clientRoot);\n } catch (err: unknown) {\n const error = toError(err);\n if (error instanceof InformAiError) throw error;\n throw new InformAiError(`Cannot load declared rule packs from ${path.join(clientRoot, 'package.json')}: ${error.message}. Install their declared package versions and repair the module declarations.`);\n }\n }\n\n private loadDeclaredFrom(clientRoot: string): RulePackRegistry {\n const manifestPath = path.join(clientRoot, 'package.json');\n if (!fs.existsSync(manifestPath)) {\n throw new InformAiError(`Missing ${manifestPath}. Declare webpieces.rulePacks in the client package.json before loading policy config.`);\n }\n // webpieces-disable no-any-unknown -- external JSON is narrowed before use\n const pkg = JSON.parse(fs.readFileSync(manifestPath, 'utf8')) as Record<string, unknown>;\n const webpieces = pkg['webpieces'];\n if (!webpieces || typeof webpieces !== 'object' || !('rulePacks' in webpieces) || !Array.isArray(webpieces.rulePacks)) {\n throw new InformAiError('Missing webpieces.rulePacks in package.json. Declare each selected pack using its public rule-pack module; there is no built-in pack fallback.');\n }\n const declarations: RulePackDeclaration[] = webpieces.rulePacks.map(entry => {\n if (!entry || typeof entry !== 'object' || typeof entry.module !== 'string' || !entry.module) {\n throw new InformAiError('Invalid webpieces.rulePacks entry. Supply {\"module\":\"<package>/rule-pack\"}.');\n }\n return new RulePackDeclaration(entry.module);\n });\n return new RulePackDiscovery(new NodeRulePackModuleLoader(clientRoot)).discover(declarations);\n }\n}\n"]}
@@ -1,14 +1,4 @@
1
- import { FieldDef } from './field-def';
2
- export declare const RULE_SCHEMAS: Record<string, Record<string, FieldDef>>;
3
- /**
4
- * The field names `configKey`'s schema accepts, or null when there is no schema (a custom rule from
5
- * `rulesDir`, or a name that is not a config key at all).
6
- *
7
- * Exists so the installer's N→1 retirement merge can drop fields the DESTINATION schema does not know
8
- * — `upsertPrCommand` folded from a retired guard entry into `pr-lifecycle-guard` would otherwise
9
- * produce a config the validator rejects on the very next call. Returning the names rather than the
10
- * FieldDefs keeps the schema objects themselves unexported: there is one reader of a schema's shape,
11
- * and it is this package's own validator.
12
- */
13
- export declare function schemaFieldNames(configKey: string): readonly string[] | null;
14
- export declare function allRuleNames(): readonly string[];
1
+ import { RulePackRegistry } from './rule-pack-registry';
2
+ /** Every schema and ID comes from explicitly selected owners. */
3
+ export declare function schemaFieldNames(configKey: string, registry: RulePackRegistry): readonly string[] | null;
4
+ export declare function allRuleNames(registry: RulePackRegistry): readonly string[];
@@ -1,98 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RULE_SCHEMAS = void 0;
4
3
  exports.schemaFieldNames = schemaFieldNames;
5
4
  exports.allRuleNames = allRuleNames;
6
- const main_sync_guard_configs_1 = require("./main-sync-guard-configs");
7
- const rule_configs_1 = require("./rule-configs");
8
- const no_root_union_config_1 = require("./no-root-union-config");
9
- const api_lib_spelling_configs_1 = require("./api-lib-spelling-configs");
10
- const no_utility_types_config_1 = require("./no-utility-types-config");
11
- const required_type_suffix_config_1 = require("./required-type-suffix-config");
12
- const api_doc_rules_config_1 = require("./api-doc-rules-config");
13
- const no_client_creation_config_1 = require("./no-client-creation-config");
14
- const no_state_paths_config_1 = require("./no-state-paths-config");
15
- const tag_truth_configs_1 = require("./tag-truth-configs");
16
- // Thin lookup table — each entry delegates to the class's own SCHEMA.
17
- // No field lists here; all schemas live with their config class.
18
- //
19
- // KEYED BY CONFIG KEY, not by rule name. For most rules those are the same string, but the three
20
- // hookGuard entries below are POLICIES implemented by more than one class: `branch-state-guard` is
21
- // read by the four branch-state guards and `pr-lifecycle-guard` by the four PR-lifecycle guards (see
22
- // AbstractRule.configKey). A rule NAME that is not a config key has no row here and never should.
23
- exports.RULE_SCHEMAS = {
24
- 'max-method-lines': rule_configs_1.MaxMethodLinesConfig.SCHEMA,
25
- 'max-file-lines': rule_configs_1.MaxFileLinesConfig.SCHEMA,
26
- 'require-return-type': rule_configs_1.RequireReturnTypeConfig.SCHEMA,
27
- 'no-inline-type-literals': rule_configs_1.NoInlineTypeLiteralsConfig.SCHEMA,
28
- 'no-any-unknown': rule_configs_1.NoAnyUnknownConfig.SCHEMA,
29
- 'no-implicit-any': rule_configs_1.NoImplicitAnyConfig.SCHEMA,
30
- 'prisma-validate-dtos': rule_configs_1.PrismaValidateDtosConfig.SCHEMA,
31
- 'prisma-converter': rule_configs_1.PrismaConverterConfig.SCHEMA,
32
- 'no-destructure': rule_configs_1.NoDestructureConfig.SCHEMA,
33
- 'no-unmanaged-exceptions': rule_configs_1.NoUnmanagedExceptionsConfig.SCHEMA,
34
- 'catch-error-pattern': rule_configs_1.CatchErrorPatternConfig.SCHEMA,
35
- 'throw-cause-required': rule_configs_1.ThrowCauseRequiredConfig.SCHEMA,
36
- 'angular-no-direct-api-in-resolver': rule_configs_1.AngularNoDirectApiInResolverConfig.SCHEMA,
37
- 'no-symbol-di-tokens': rule_configs_1.NoSymbolDiTokensConfig.SCHEMA,
38
- 'no-client-creation-outside-server-or-client': no_client_creation_config_1.NoClientCreationOutsideServerOrClientConfig.SCHEMA,
39
- 'no-custom-css': rule_configs_1.NoCustomCssConfig.SCHEMA,
40
- 'no-state-paths-in-templates': no_state_paths_config_1.NoStatePathsInTemplatesConfig.SCHEMA,
41
- 'no-process-exit-outside-main': rule_configs_1.NoProcessExitOutsideMainConfig.SCHEMA,
42
- 'no-function-outside-class': rule_configs_1.NoFunctionOutsideClassConfig.SCHEMA,
43
- 'inject-annotation-not-needed-for-concrete-class': rule_configs_1.InjectAnnotationNotNeededForConcreteClassConfig.SCHEMA,
44
- 'framework-tag': rule_configs_1.FrameworkTagConfig.SCHEMA,
45
- 'role-tag': rule_configs_1.RoleTagConfig.SCHEMA,
46
- 'ensure-we-are-secure': rule_configs_1.EnsureWeAreSecureConfig.SCHEMA,
47
- 'branch-creation-guard': rule_configs_1.BranchCreationGuardConfig.SCHEMA,
48
- 'pr-lifecycle-guard': rule_configs_1.PrLifecycleGuardConfig.SCHEMA,
49
- 'branch-state-guard': main_sync_guard_configs_1.BranchStateGuardConfig.SCHEMA,
50
- 'no-file-import-cycles': rule_configs_1.NoFileImportCyclesConfig.SCHEMA,
51
- 'runtime-architecture': rule_configs_1.RuntimeArchitectureConfig.SCHEMA,
52
- 'nx-wiring': rule_configs_1.NxWiringConfig.SCHEMA,
53
- 'di-graph': rule_configs_1.DiGraphConfig.SCHEMA,
54
- 'missing-design-annotation': rule_configs_1.MissingDesignAnnotationConfig.SCHEMA,
55
- 'no-js-files': rule_configs_1.NoJsFilesConfig.SCHEMA,
56
- 'validate-ts-in-src': rule_configs_1.ValidateTsInSrcConfig.SCHEMA,
57
- 'validate-architecture-unchanged': rule_configs_1.ValidateArchitectureUnchangedConfig.SCHEMA,
58
- 'validate-no-architecture-cycles': rule_configs_1.ValidateNoArchitectureCyclesConfig.SCHEMA,
59
- 'validate-packagejson': rule_configs_1.ValidatePackageJsonConfig.SCHEMA,
60
- 'validate-versions-locked': rule_configs_1.ValidateVersionsLockedConfig.SCHEMA,
61
- 'validate-eslint-sync': rule_configs_1.ValidateEslintSyncConfig.SCHEMA,
62
- 'no-root-union-api-type': no_root_union_config_1.NoRootUnionApiTypeConfig.SCHEMA,
63
- 'api-rules-for-openapi': api_doc_rules_config_1.ApiRulesForOpenApiConfig.SCHEMA,
64
- 'api-rules-for-mcp': api_doc_rules_config_1.ApiRulesForMcpConfig.SCHEMA,
65
- 'no-inline-import-in-api-lib': api_lib_spelling_configs_1.NoInlineImportInApiLibConfig.SCHEMA,
66
- 'one-enum-spelling-in-api-lib': api_lib_spelling_configs_1.OneEnumSpellingInApiLibConfig.SCHEMA,
67
- 'no-utility-types-in-api-lib': no_utility_types_config_1.NoUtilityTypesInApiLibConfig.SCHEMA,
68
- 'required-type-suffix': required_type_suffix_config_1.RequiredTypeSuffixConfig.SCHEMA,
69
- // #1064: the five rules that make framework:* / role:* tags true. See tag-truth-configs.ts.
70
- 'api-lib-dependencies': tag_truth_configs_1.ApiLibDependenciesConfig.SCHEMA,
71
- 'api-lib-path': tag_truth_configs_1.ApiLibPathConfig.SCHEMA,
72
- 'framework-folder': tag_truth_configs_1.FrameworkFolderConfig.SCHEMA,
73
- 'framework-tsconfig': tag_truth_configs_1.FrameworkTsconfigConfig.SCHEMA,
74
- 'framework-packages': tag_truth_configs_1.FrameworkPackagesConfig.SCHEMA,
75
- };
76
- /**
77
- * The field names `configKey`'s schema accepts, or null when there is no schema (a custom rule from
78
- * `rulesDir`, or a name that is not a config key at all).
79
- *
80
- * Exists so the installer's N→1 retirement merge can drop fields the DESTINATION schema does not know
81
- * — `upsertPrCommand` folded from a retired guard entry into `pr-lifecycle-guard` would otherwise
82
- * produce a config the validator rejects on the very next call. Returning the names rather than the
83
- * FieldDefs keeps the schema objects themselves unexported: there is one reader of a schema's shape,
84
- * and it is this package's own validator.
85
- */
86
- // webpieces-disable no-function-outside-class -- pure lookup over the module-scope schema table, beside allRuleNames
87
- function schemaFieldNames(configKey) {
88
- const schema = exports.RULE_SCHEMAS[configKey];
89
- return schema === undefined ? null : Object.keys(schema);
90
- }
91
- // Every built-in CONFIG KEY that has a typed schema (code rules + bash guards). The installer uses
92
- // this (with sectionForRule) to seed a fresh webpieces.config.json with every entry in its section.
93
- // It is the key set, not the class set: four classes behind `branch-state-guard` contribute one name.
94
- // webpieces-disable no-function-outside-class -- pure lookup over the module-scope schema table
95
- function allRuleNames() {
96
- return Object.keys(exports.RULE_SCHEMAS);
5
+ /** Every schema and ID comes from explicitly selected owners. */
6
+ // webpieces-disable no-function-outside-class -- pure registry projection
7
+ function schemaFieldNames(configKey, registry) {
8
+ return registry.hasRule(configKey) ? Object.keys(registry.schemaFor(configKey)) : null;
97
9
  }
10
+ // webpieces-disable no-function-outside-class -- pure registry projection
11
+ function allRuleNames(registry) { return registry.ruleIds(); }
98
12
  //# sourceMappingURL=rule-schemas.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rule-schemas.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/rule-schemas.ts"],"names":[],"mappings":";;;AAmIA,4CAGC;AAMD,oCAEC;AA1ID,uEAAmE;AACnE,iDAoCwB;AACxB,iEAAkE;AAClE,yEAAyG;AACzG,uEAAyE;AACzE,+EAAyE;AACzE,iEAAwF;AACxF,2EAA0F;AAC1F,mEAAwE;AACxE,2DAM6B;AAE7B,sEAAsE;AACtE,iEAAiE;AACjE,EAAE;AACF,iGAAiG;AACjG,mGAAmG;AACnG,qGAAqG;AACrG,kGAAkG;AACrF,QAAA,YAAY,GAA6C;IAClE,kBAAkB,EAAE,mCAAoB,CAAC,MAAM;IAC/C,gBAAgB,EAAE,iCAAkB,CAAC,MAAM;IAC3C,qBAAqB,EAAE,sCAAuB,CAAC,MAAM;IACrD,yBAAyB,EAAE,yCAA0B,CAAC,MAAM;IAC5D,gBAAgB,EAAE,iCAAkB,CAAC,MAAM;IAC3C,iBAAiB,EAAE,kCAAmB,CAAC,MAAM;IAC7C,sBAAsB,EAAE,uCAAwB,CAAC,MAAM;IACvD,kBAAkB,EAAE,oCAAqB,CAAC,MAAM;IAChD,gBAAgB,EAAE,kCAAmB,CAAC,MAAM;IAC5C,yBAAyB,EAAE,0CAA2B,CAAC,MAAM;IAC7D,qBAAqB,EAAE,sCAAuB,CAAC,MAAM;IACrD,sBAAsB,EAAE,uCAAwB,CAAC,MAAM;IACvD,mCAAmC,EAAE,iDAAkC,CAAC,MAAM;IAC9E,qBAAqB,EAAE,qCAAsB,CAAC,MAAM;IACpD,6CAA6C,EACzC,uEAA2C,CAAC,MAAM;IACtD,e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AAsB,EAAE,4CAAwB,CAAC,MAAM;IACvD,cAAc,EAAE,oCAAgB,CAAC,MAAM;IACvC,kBAAkB,EAAE,yCAAqB,CAAC,MAAM;IAChD,oBAAoB,EAAE,2CAAuB,CAAC,MAAM;IACpD,oBAAoB,EAAE,2CAAuB,CAAC,MAAM;CACvD,CAAC;AAEF;;;;;;;;;GASG;AACH,qHAAqH;AACrH,SAAgB,gBAAgB,CAAC,SAAiB;IAC9C,MAAM,MAAM,GAAG,oBAAY,CAAC,SAAS,CAAC,CAAC;IACvC,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC7D,CAAC;AAED,mGAAmG;AACnG,oGAAoG;AACpG,sGAAsG;AACtG,gGAAgG;AAChG,SAAgB,YAAY;IACxB,OAAO,MAAM,CAAC,IAAI,CAAC,oBAAY,CAAC,CAAC;AACrC,CAAC","sourcesContent":["// The rule-name -> schema lookup table, split out of validate-config.ts (which hit the 700-line cap).\n// Every consumer of \"what fields does rule X have\" reads it from here: the validator, the missing-rule\n// snippet, and the installer's seeding (seed-entry.ts) — one table, so they cannot disagree.\nimport { FieldDef } from './field-def';\nimport { BranchStateGuardConfig } from './main-sync-guard-configs';\nimport {\n MaxMethodLinesConfig,\n MaxFileLinesConfig,\n RequireReturnTypeConfig,\n NoInlineTypeLiteralsConfig,\n NoAnyUnknownConfig,\n NoImplicitAnyConfig,\n PrismaValidateDtosConfig,\n PrismaConverterConfig,\n NoDestructureConfig,\n NoUnmanagedExceptionsConfig,\n CatchErrorPatternConfig,\n ThrowCauseRequiredConfig,\n AngularNoDirectApiInResolverConfig,\n NoSymbolDiTokensConfig,\n NoCustomCssConfig,\n NoProcessExitOutsideMainConfig,\n NoFunctionOutsideClassConfig,\n InjectAnnotationNotNeededForConcreteClassConfig,\n FrameworkTagConfig,\n RoleTagConfig,\n EnsureWeAreSecureConfig,\n BranchCreationGuardConfig,\n PrLifecycleGuardConfig,\n NoFileImportCyclesConfig,\n RuntimeArchitectureConfig,\n NxWiringConfig,\n DiGraphConfig,\n MissingDesignAnnotationConfig,\n NoJsFilesConfig,\n ValidateTsInSrcConfig,\n ValidateArchitectureUnchangedConfig,\n ValidateNoArchitectureCyclesConfig,\n ValidatePackageJsonConfig,\n ValidateVersionsLockedConfig,\n ValidateEslintSyncConfig,\n} from './rule-configs';\nimport { NoRootUnionApiTypeConfig } from './no-root-union-config';\nimport { NoInlineImportInApiLibConfig, OneEnumSpellingInApiLibConfig } from './api-lib-spelling-configs';\nimport { NoUtilityTypesInApiLibConfig } from './no-utility-types-config';\nimport { RequiredTypeSuffixConfig } from './required-type-suffix-config';\nimport { ApiRulesForMcpConfig, ApiRulesForOpenApiConfig } from './api-doc-rules-config';\nimport { NoClientCreationOutsideServerOrClientConfig } from './no-client-creation-config';\nimport { NoStatePathsInTemplatesConfig } from './no-state-paths-config';\nimport {\n ApiLibDependenciesConfig,\n ApiLibPathConfig,\n FrameworkFolderConfig,\n FrameworkPackagesConfig,\n FrameworkTsconfigConfig,\n} from './tag-truth-configs';\n\n// Thin lookup table — each entry delegates to the class's own SCHEMA.\n// No field lists here; all schemas live with their config class.\n//\n// KEYED BY CONFIG KEY, not by rule name. For most rules those are the same string, but the three\n// hookGuard entries below are POLICIES implemented by more than one class: `branch-state-guard` is\n// read by the four branch-state guards and `pr-lifecycle-guard` by the four PR-lifecycle guards (see\n// AbstractRule.configKey). A rule NAME that is not a config key has no row here and never should.\nexport const RULE_SCHEMAS: Record<string, Record<string, FieldDef>> = {\n 'max-method-lines': MaxMethodLinesConfig.SCHEMA,\n 'max-file-lines': MaxFileLinesConfig.SCHEMA,\n 'require-return-type': RequireReturnTypeConfig.SCHEMA,\n 'no-inline-type-literals': NoInlineTypeLiteralsConfig.SCHEMA,\n 'no-any-unknown': NoAnyUnknownConfig.SCHEMA,\n 'no-implicit-any': NoImplicitAnyConfig.SCHEMA,\n 'prisma-validate-dtos': PrismaValidateDtosConfig.SCHEMA,\n 'prisma-converter': PrismaConverterConfig.SCHEMA,\n 'no-destructure': NoDestructureConfig.SCHEMA,\n 'no-unmanaged-exceptions': NoUnmanagedExceptionsConfig.SCHEMA,\n 'catch-error-pattern': CatchErrorPatternConfig.SCHEMA,\n 'throw-cause-required': ThrowCauseRequiredConfig.SCHEMA,\n 'angular-no-direct-api-in-resolver': AngularNoDirectApiInResolverConfig.SCHEMA,\n 'no-symbol-di-tokens': NoSymbolDiTokensConfig.SCHEMA,\n 'no-client-creation-outside-server-or-client':\n NoClientCreationOutsideServerOrClientConfig.SCHEMA,\n 'no-custom-css': NoCustomCssConfig.SCHEMA,\n 'no-state-paths-in-templates': NoStatePathsInTemplatesConfig.SCHEMA,\n 'no-process-exit-outside-main': NoProcessExitOutsideMainConfig.SCHEMA,\n 'no-function-outside-class': NoFunctionOutsideClassConfig.SCHEMA,\n 'inject-annotation-not-needed-for-concrete-class':\n InjectAnnotationNotNeededForConcreteClassConfig.SCHEMA,\n 'framework-tag': FrameworkTagConfig.SCHEMA,\n 'role-tag': RoleTagConfig.SCHEMA,\n 'ensure-we-are-secure': EnsureWeAreSecureConfig.SCHEMA,\n 'branch-creation-guard': BranchCreationGuardConfig.SCHEMA,\n 'pr-lifecycle-guard': PrLifecycleGuardConfig.SCHEMA,\n 'branch-state-guard': BranchStateGuardConfig.SCHEMA,\n 'no-file-import-cycles': NoFileImportCyclesConfig.SCHEMA,\n 'runtime-architecture': RuntimeArchitectureConfig.SCHEMA,\n 'nx-wiring': NxWiringConfig.SCHEMA,\n 'di-graph': DiGraphConfig.SCHEMA,\n 'missing-design-annotation': MissingDesignAnnotationConfig.SCHEMA,\n 'no-js-files': NoJsFilesConfig.SCHEMA,\n 'validate-ts-in-src': ValidateTsInSrcConfig.SCHEMA,\n 'validate-architecture-unchanged': ValidateArchitectureUnchangedConfig.SCHEMA,\n 'validate-no-architecture-cycles': ValidateNoArchitectureCyclesConfig.SCHEMA,\n 'validate-packagejson': ValidatePackageJsonConfig.SCHEMA,\n 'validate-versions-locked': ValidateVersionsLockedConfig.SCHEMA,\n 'validate-eslint-sync': ValidateEslintSyncConfig.SCHEMA,\n 'no-root-union-api-type': NoRootUnionApiTypeConfig.SCHEMA,\n 'api-rules-for-openapi': ApiRulesForOpenApiConfig.SCHEMA,\n 'api-rules-for-mcp': ApiRulesForMcpConfig.SCHEMA,\n 'no-inline-import-in-api-lib': NoInlineImportInApiLibConfig.SCHEMA,\n 'one-enum-spelling-in-api-lib': OneEnumSpellingInApiLibConfig.SCHEMA,\n 'no-utility-types-in-api-lib': NoUtilityTypesInApiLibConfig.SCHEMA,\n 'required-type-suffix': RequiredTypeSuffixConfig.SCHEMA,\n // #1064: the five rules that make framework:* / role:* tags true. See tag-truth-configs.ts.\n 'api-lib-dependencies': ApiLibDependenciesConfig.SCHEMA,\n 'api-lib-path': ApiLibPathConfig.SCHEMA,\n 'framework-folder': FrameworkFolderConfig.SCHEMA,\n 'framework-tsconfig': FrameworkTsconfigConfig.SCHEMA,\n 'framework-packages': FrameworkPackagesConfig.SCHEMA,\n};\n\n/**\n * The field names `configKey`'s schema accepts, or null when there is no schema (a custom rule from\n * `rulesDir`, or a name that is not a config key at all).\n *\n * Exists so the installer's N→1 retirement merge can drop fields the DESTINATION schema does not know\n * — `upsertPrCommand` folded from a retired guard entry into `pr-lifecycle-guard` would otherwise\n * produce a config the validator rejects on the very next call. Returning the names rather than the\n * FieldDefs keeps the schema objects themselves unexported: there is one reader of a schema's shape,\n * and it is this package's own validator.\n */\n// webpieces-disable no-function-outside-class -- pure lookup over the module-scope schema table, beside allRuleNames\nexport function schemaFieldNames(configKey: string): readonly string[] | null {\n const schema = RULE_SCHEMAS[configKey];\n return schema === undefined ? null : Object.keys(schema);\n}\n\n// Every built-in CONFIG KEY that has a typed schema (code rules + bash guards). The installer uses\n// this (with sectionForRule) to seed a fresh webpieces.config.json with every entry in its section.\n// It is the key set, not the class set: four classes behind `branch-state-guard` contribute one name.\n// webpieces-disable no-function-outside-class -- pure lookup over the module-scope schema table\nexport function allRuleNames(): readonly string[] {\n return Object.keys(RULE_SCHEMAS);\n}\n"]}
1
+ {"version":3,"file":"rule-schemas.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/rule-schemas.ts"],"names":[],"mappings":";;AAIA,4CAEC;AAED,oCAA0G;AAN1G,iEAAiE;AACjE,0EAA0E;AAC1E,SAAgB,gBAAgB,CAAC,SAAiB,EAAE,QAA0B;IAC1E,OAAO,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC3F,CAAC;AACD,0EAA0E;AAC1E,SAAgB,YAAY,CAAC,QAA0B,IAAuB,OAAO,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC","sourcesContent":["import { RulePackRegistry } from './rule-pack-registry';\n\n/** Every schema and ID comes from explicitly selected owners. */\n// webpieces-disable no-function-outside-class -- pure registry projection\nexport function schemaFieldNames(configKey: string, registry: RulePackRegistry): readonly string[] | null {\n return registry.hasRule(configKey) ? Object.keys(registry.schemaFor(configKey)) : null;\n}\n// webpieces-disable no-function-outside-class -- pure registry projection\nexport function allRuleNames(registry: RulePackRegistry): readonly string[] { return registry.ruleIds(); }\n"]}
package/src/sections.d.ts CHANGED
@@ -1,46 +1,5 @@
1
- export type ConfigSection = 'rules' | 'hookGuards';
2
- /**
3
- * The `hookGuards` CONFIG KEYS — ONE PER POLICY, not one per implementation class.
4
- *
5
- * Single source of truth for the rule/guard split, imported by the config validator (placement
6
- * checks), the loader (section merge), and the installer (config seeding).
7
- *
8
- * | key | the question it answers | classes behind it |
9
- * |---|---|---|
10
- * | `branch-state-guard` | may I work here, and is what I read current? | feature-branch-guard, read-stale-guard, stale-main-bash-guard, merged-branch-bash-guard |
11
- * | `branch-creation-guard` | should this branch/worktree exist at all? | branch-creation-guard |
12
- * | `pr-lifecycle-guard` | do PRs and merges go through the gated flow? | pr-creation-or-push-guard, merge-in-progress-guard, pr-merge-guard, redirect-how-to-merge-main |
13
- *
14
- * A consumer turns a POLICY on or off; the class split is an implementation detail of tool wiring
15
- * (Read names one file, Bash is opaque, Write is neither). Nine keys let you configure half a policy —
16
- * `read-stale-guard: OFF` beside `merged-branch-bash-guard: ON` is "read the file, yes; `cat` the same
17
- * file, no" — and one key per policy makes that unrepresentable. The eight retired names are in
18
- * RETIRED_CONFIG_KEYS with the destination, all `prunable: false` so nothing deletes a configured guard.
19
- *
20
- * `branch-creation-guard` KEEPS its name. It is already one class and one policy carrying real
21
- * settings; renaming it to `branch-cleanup-guard` (which three docs once proposed) would cost a
22
- * retirement, a migration and prose churn for zero policy change.
23
- *
24
- * `whole-repo-build-guard` is NOT here: it has no webpieces.config.json entry at all (see
25
- * RETIRED_CONFIG_KEYS). It is EXPERIMENTAL and OFF for every tree until a machine opts in with
26
- * `experimental.whole-repo-build-guard: true` in ~/.webpieces/config.json, and ai-hook-rules runs it
27
- * outside the config-driven rule set entirely.
28
- */
29
- /**
30
- * The two POLICY keys shared by more than one class, as named constants.
31
- *
32
- * Every class behind them passes the constant as its `configKey`, so the wiring is a compile-time
33
- * reference rather than a repeated string literal that a rename could miss in one file out of four —
34
- * which is exactly how `applyCommandDefaults` used to break silently.
35
- */
36
- export declare const BRANCH_STATE_GUARD_KEY = "branch-state-guard";
37
- export declare const PR_LIFECYCLE_GUARD_KEY = "pr-lifecycle-guard";
38
- export declare const HOOK_GUARD_NAMES: readonly string[];
39
- /**
40
- * Is this CONFIG KEY a hookGuard? Callers must pass `AbstractRule.configKey`, never `rule.name` — the
41
- * two diverge for every class behind a collapsed policy key, and passing a class name would classify
42
- * `feature-branch-guard` as a code-style rule and run it in the wrong hook.
43
- */
44
- export declare function isHookGuard(configKey: string): boolean;
45
- /** Which section `configKey`'s entry belongs in. Same contract as isHookGuard: keys, not class names. */
46
- export declare function sectionForRule(configKey: string): ConfigSection;
1
+ import { RuleConfigSection } from '@webpieces/rules-sdk';
2
+ import { RulePackRegistry } from './rule-pack-registry';
3
+ export type ConfigSection = RuleConfigSection;
4
+ export declare function isHookGuard(configKey: string, registry: RulePackRegistry): boolean;
5
+ export declare function sectionForRule(configKey: string, registry: RulePackRegistry): ConfigSection;