@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.
- package/package.json +9 -4
- package/src/WebpiecesRulesConfig.d.ts +3 -49
- package/src/WebpiecesRulesConfig.js +1 -44
- package/src/WebpiecesRulesConfig.js.map +1 -1
- package/src/abstract-rule.d.ts +1 -1
- package/src/abstract-rule.js.map +1 -1
- package/src/config-pruner.d.ts +3 -1
- package/src/config-pruner.js +13 -9
- package/src/config-pruner.js.map +1 -1
- package/src/constants.d.ts +0 -37
- package/src/constants.js +1 -38
- package/src/constants.js.map +1 -1
- package/src/index.d.ts +7 -24
- package/src/index.js +14 -105
- package/src/index.js.map +1 -1
- package/src/load-config.d.ts +6 -2
- package/src/load-config.js +17 -11
- package/src/load-config.js.map +1 -1
- package/src/match-rules-config.d.ts +2 -1
- package/src/match-rules-config.js +2 -2
- package/src/match-rules-config.js.map +1 -1
- package/src/no-custom-css-scope.d.ts +9 -25
- package/src/no-custom-css-scope.js +10 -24
- package/src/no-custom-css-scope.js.map +1 -1
- package/src/retired-config-keys.d.ts +3 -64
- package/src/retired-config-keys.js +14 -152
- package/src/retired-config-keys.js.map +1 -1
- package/src/rule-pack-registry.d.ts +41 -0
- package/src/rule-pack-registry.js +231 -0
- package/src/rule-pack-registry.js.map +1 -0
- package/src/rule-pack-selection.d.ts +6 -0
- package/src/rule-pack-selection.js +50 -0
- package/src/rule-pack-selection.js.map +1 -0
- package/src/rule-schemas.d.ts +4 -14
- package/src/rule-schemas.js +6 -92
- package/src/rule-schemas.js.map +1 -1
- package/src/sections.d.ts +5 -46
- package/src/sections.js +5 -56
- package/src/sections.js.map +1 -1
- package/src/seed-entry.d.ts +5 -16
- package/src/seed-entry.js +14 -141
- package/src/seed-entry.js.map +1 -1
- package/src/validate-config.d.ts +3 -2
- package/src/validate-config.js +62 -73
- package/src/validate-config.js.map +1 -1
- package/templates/webpieces.branch-state-matrix.md +1 -1
- package/src/api-doc-rules-config.d.ts +0 -60
- package/src/api-doc-rules-config.js +0 -71
- package/src/api-doc-rules-config.js.map +0 -1
- package/src/api-lib-spelling-configs.d.ts +0 -40
- package/src/api-lib-spelling-configs.js +0 -52
- package/src/api-lib-spelling-configs.js.map +0 -1
- package/src/default-rules.d.ts +0 -2
- package/src/default-rules.js +0 -119
- package/src/default-rules.js.map +0 -1
- package/src/field-def.d.ts +0 -24
- package/src/field-def.js +0 -59
- package/src/field-def.js.map +0 -1
- package/src/main-sync-guard-configs.d.ts +0 -38
- package/src/main-sync-guard-configs.js +0 -54
- package/src/main-sync-guard-configs.js.map +0 -1
- package/src/no-client-creation-config.d.ts +0 -12
- package/src/no-client-creation-config.js +0 -40
- package/src/no-client-creation-config.js.map +0 -1
- package/src/no-root-union-config.d.ts +0 -25
- package/src/no-root-union-config.js +0 -33
- package/src/no-root-union-config.js.map +0 -1
- package/src/no-state-paths-config.d.ts +0 -41
- package/src/no-state-paths-config.js +0 -51
- package/src/no-state-paths-config.js.map +0 -1
- package/src/no-utility-types-config.d.ts +0 -30
- package/src/no-utility-types-config.js +0 -39
- package/src/no-utility-types-config.js.map +0 -1
- package/src/required-type-suffix-config.d.ts +0 -49
- package/src/required-type-suffix-config.js +0 -62
- package/src/required-type-suffix-config.js.map +0 -1
- package/src/rule-configs.d.ts +0 -273
- package/src/rule-configs.js +0 -595
- package/src/rule-configs.js.map +0 -1
- package/src/spec-temp-dirs.d.ts +0 -37
- package/src/spec-temp-dirs.js +0 -113
- package/src/spec-temp-dirs.js.map +0 -1
- package/src/tag-truth-configs.d.ts +0 -137
- package/src/tag-truth-configs.js +0 -175
- package/src/tag-truth-configs.js.map +0 -1
package/src/sections.js
CHANGED
|
@@ -1,62 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HOOK_GUARD_NAMES = exports.PR_LIFECYCLE_GUARD_KEY = exports.BRANCH_STATE_GUARD_KEY = void 0;
|
|
4
3
|
exports.isHookGuard = isHookGuard;
|
|
5
4
|
exports.sectionForRule = sectionForRule;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* Single source of truth for the rule/guard split, imported by the config validator (placement
|
|
10
|
-
* checks), the loader (section merge), and the installer (config seeding).
|
|
11
|
-
*
|
|
12
|
-
* | key | the question it answers | classes behind it |
|
|
13
|
-
* |---|---|---|
|
|
14
|
-
* | `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 |
|
|
15
|
-
* | `branch-creation-guard` | should this branch/worktree exist at all? | branch-creation-guard |
|
|
16
|
-
* | `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 |
|
|
17
|
-
*
|
|
18
|
-
* A consumer turns a POLICY on or off; the class split is an implementation detail of tool wiring
|
|
19
|
-
* (Read names one file, Bash is opaque, Write is neither). Nine keys let you configure half a policy —
|
|
20
|
-
* `read-stale-guard: OFF` beside `merged-branch-bash-guard: ON` is "read the file, yes; `cat` the same
|
|
21
|
-
* file, no" — and one key per policy makes that unrepresentable. The eight retired names are in
|
|
22
|
-
* RETIRED_CONFIG_KEYS with the destination, all `prunable: false` so nothing deletes a configured guard.
|
|
23
|
-
*
|
|
24
|
-
* `branch-creation-guard` KEEPS its name. It is already one class and one policy carrying real
|
|
25
|
-
* settings; renaming it to `branch-cleanup-guard` (which three docs once proposed) would cost a
|
|
26
|
-
* retirement, a migration and prose churn for zero policy change.
|
|
27
|
-
*
|
|
28
|
-
* `whole-repo-build-guard` is NOT here: it has no webpieces.config.json entry at all (see
|
|
29
|
-
* RETIRED_CONFIG_KEYS). It is EXPERIMENTAL and OFF for every tree until a machine opts in with
|
|
30
|
-
* `experimental.whole-repo-build-guard: true` in ~/.webpieces/config.json, and ai-hook-rules runs it
|
|
31
|
-
* outside the config-driven rule set entirely.
|
|
32
|
-
*/
|
|
33
|
-
/**
|
|
34
|
-
* The two POLICY keys shared by more than one class, as named constants.
|
|
35
|
-
*
|
|
36
|
-
* Every class behind them passes the constant as its `configKey`, so the wiring is a compile-time
|
|
37
|
-
* reference rather than a repeated string literal that a rename could miss in one file out of four —
|
|
38
|
-
* which is exactly how `applyCommandDefaults` used to break silently.
|
|
39
|
-
*/
|
|
40
|
-
exports.BRANCH_STATE_GUARD_KEY = 'branch-state-guard';
|
|
41
|
-
exports.PR_LIFECYCLE_GUARD_KEY = 'pr-lifecycle-guard';
|
|
42
|
-
exports.HOOK_GUARD_NAMES = [
|
|
43
|
-
exports.BRANCH_STATE_GUARD_KEY,
|
|
44
|
-
'branch-creation-guard',
|
|
45
|
-
exports.PR_LIFECYCLE_GUARD_KEY,
|
|
46
|
-
];
|
|
47
|
-
const HOOK_GUARD_SET = new Set(exports.HOOK_GUARD_NAMES);
|
|
48
|
-
/**
|
|
49
|
-
* Is this CONFIG KEY a hookGuard? Callers must pass `AbstractRule.configKey`, never `rule.name` — the
|
|
50
|
-
* two diverge for every class behind a collapsed policy key, and passing a class name would classify
|
|
51
|
-
* `feature-branch-guard` as a code-style rule and run it in the wrong hook.
|
|
52
|
-
*/
|
|
53
|
-
// webpieces-disable no-function-outside-class -- pure predicate over the module-scope key set beside it; it is imported by the validator, the loader and the installer alike, and a class here would be a namespace with no state
|
|
54
|
-
function isHookGuard(configKey) {
|
|
55
|
-
return HOOK_GUARD_SET.has(configKey);
|
|
56
|
-
}
|
|
57
|
-
/** Which section `configKey`'s entry belongs in. Same contract as isHookGuard: keys, not class names. */
|
|
58
|
-
// webpieces-disable no-function-outside-class -- sibling of isHookGuard over the same module-scope key set
|
|
59
|
-
function sectionForRule(configKey) {
|
|
60
|
-
return HOOK_GUARD_SET.has(configKey) ? 'hookGuards' : 'rules';
|
|
5
|
+
// webpieces-disable no-function-outside-class -- pure registry projection; unknown custom rules have no workflow declaration
|
|
6
|
+
function isHookGuard(configKey, registry) {
|
|
7
|
+
return registry.hasRule(configKey) && registry.sectionFor(configKey) === 'hookGuards';
|
|
61
8
|
}
|
|
9
|
+
// webpieces-disable no-function-outside-class -- pure registry projection
|
|
10
|
+
function sectionForRule(configKey, registry) { return registry.sectionFor(configKey); }
|
|
62
11
|
//# sourceMappingURL=sections.js.map
|
package/src/sections.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sections.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/sections.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sections.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/sections.ts"],"names":[],"mappings":";;AAKA,kCAEC;AAED,wCAAuI;AALvI,6HAA6H;AAC7H,SAAgB,WAAW,CAAC,SAAiB,EAAE,QAA0B;IACrE,OAAO,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,YAAY,CAAC;AAC1F,CAAC;AACD,0EAA0E;AAC1E,SAAgB,cAAc,CAAC,SAAiB,EAAE,QAA0B,IAAmB,OAAO,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC","sourcesContent":["import { RuleConfigSection } from '@webpieces/rules-sdk';\nimport { RulePackRegistry } from './rule-pack-registry';\nexport type ConfigSection = RuleConfigSection;\n\n// webpieces-disable no-function-outside-class -- pure registry projection; unknown custom rules have no workflow declaration\nexport function isHookGuard(configKey: string, registry: RulePackRegistry): boolean {\n return registry.hasRule(configKey) && registry.sectionFor(configKey) === 'hookGuards';\n}\n// webpieces-disable no-function-outside-class -- pure registry projection\nexport function sectionForRule(configKey: string, registry: RulePackRegistry): ConfigSection { return registry.sectionFor(configKey); }\n"]}
|
package/src/seed-entry.d.ts
CHANGED
|
@@ -1,19 +1,8 @@
|
|
|
1
|
+
import { ConfigObject } from '@webpieces/rules-sdk';
|
|
2
|
+
import { RulePackRegistry } from './rule-pack-registry';
|
|
1
3
|
export declare function recommendedSeedModeFor(modes: readonly string[]): string;
|
|
2
|
-
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* which modes they accept.
|
|
6
|
-
*/
|
|
7
|
-
export declare function recommendedSeedMode(ruleName: string): string;
|
|
8
|
-
/**
|
|
9
|
-
* The COMPLETE `webpieces.config.json` entry for `ruleName` — recommended mode, both escape hatches,
|
|
10
|
-
* and a value for every other schema-REQUIRED field.
|
|
11
|
-
*
|
|
12
|
-
* Emitting only mode+hatches is what let `wp-install-ai-hooks` write a config the loader then
|
|
13
|
-
* rejected (`[branch-creation-guard] Missing required field "autoReapMergedBranches"`), so the
|
|
14
|
-
* installer and the validator read the SAME schema here. Unknown rule names (custom rules from
|
|
15
|
-
* `rulesDir`) get the minimal entry — we have no schema to enumerate their required fields.
|
|
16
|
-
*/
|
|
17
|
-
export declare function seedEntryForRule(ruleName: string): Record<string, unknown>;
|
|
4
|
+
/** Recommendations are owner-authored file-writing data, never runtime defaults. */
|
|
5
|
+
export declare function recommendedSeedMode(ruleName: string, registry: RulePackRegistry): string;
|
|
6
|
+
export declare function seedEntryForRule(ruleName: string, registry: RulePackRegistry): ConfigObject;
|
|
18
7
|
/** True when `mode` is one of the gradual (change-scoped) modes — used to decide whether to print the rollout prose. */
|
|
19
8
|
export declare function isGradualMode(mode: string): boolean;
|
package/src/seed-entry.js
CHANGED
|
@@ -4,17 +4,7 @@ exports.recommendedSeedModeFor = recommendedSeedModeFor;
|
|
|
4
4
|
exports.recommendedSeedMode = recommendedSeedMode;
|
|
5
5
|
exports.seedEntryForRule = seedEntryForRule;
|
|
6
6
|
exports.isGradualMode = isGradualMode;
|
|
7
|
-
const
|
|
8
|
-
const default_rules_1 = require("./default-rules");
|
|
9
|
-
// Scoped modes (narrowest → broadest) that enforce ONLY on what changed, so a rule can be
|
|
10
|
-
// adopted gradually instead of all-at-once. When a rule offers one, recommend the first it
|
|
11
|
-
// supports so a fresh config opts into a low-friction rollout rather than reflexively OFF.
|
|
12
|
-
//
|
|
13
|
-
// The two PROJECT-wide modes come LAST (#1027). A project rule offers nothing narrower, so it still
|
|
14
|
-
// arrives as MODIFIED_PROJECTS; but a line/file-scoped rule that ALSO offers the whole-scope modes
|
|
15
|
-
// (every MODIFIED_CODE_MODES rule, #1027) must keep arriving at its narrow mode — seeding it at
|
|
16
|
-
// MODIFIED_PROJECTS would judge every file of every touched project on day one, the opposite of a
|
|
17
|
-
// gradual rollout. RUN_EVERY_TIME is never a gradual mode and is not listed here at all.
|
|
7
|
+
const tooling_common_1 = require("@webpieces/tooling-common");
|
|
18
8
|
const GRADUAL_MODE_PREFERENCE = [
|
|
19
9
|
'NEW_AND_MODIFIED_CODE',
|
|
20
10
|
'NEW_AND_MODIFIED_METHODS',
|
|
@@ -42,137 +32,20 @@ function recommendedSeedModeFor(modes) {
|
|
|
42
32
|
return 'RUN_EVERY_TIME';
|
|
43
33
|
return 'OFF';
|
|
44
34
|
}
|
|
45
|
-
/**
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
*/
|
|
50
|
-
// webpieces-disable no-function-outside-class -- sibling of the module-scope schema helpers in this file
|
|
51
|
-
function recommendedSeedMode(ruleName) {
|
|
52
|
-
const schema = rule_schemas_1.RULE_SCHEMAS[ruleName];
|
|
53
|
-
if (!schema)
|
|
54
|
-
return 'OFF';
|
|
55
|
-
return recommendedSeedModeFor(schema['mode']?.enumValues ?? []);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* What a FRESH config is SEEDED with for a schema-REQUIRED field that is not `mode` or a hatch.
|
|
59
|
-
*
|
|
60
|
-
* This is NOT a default, and the distinction is the whole of #1017. A default is the value a rule
|
|
61
|
-
* runs on when the consumer's config never mentions it — invisible, and therefore a decision made
|
|
62
|
-
* for somebody who was never asked. A seed VALUE is written into the consumer's own
|
|
63
|
-
* `webpieces.config.json`, where it is read, reviewed and changed like any other line they own. So
|
|
64
|
-
* `defaultRules` may not carry a required field (no-rule-defaults.spec.ts fails the build if it
|
|
65
|
-
* does), and the installer still has something sensible to write on day one.
|
|
66
|
-
*
|
|
67
|
-
* Keyed `<rule>.<field>`. Anything absent falls through to the conservative type fallback below.
|
|
68
|
-
*/
|
|
69
|
-
// webpieces-disable no-any-unknown -- a config field value is opaque JSON by construction
|
|
70
|
-
const SEED_VALUES = {
|
|
71
|
-
// The convention this repo's own config states; a consumer edits it to theirs.
|
|
72
|
-
'branch-creation-guard.subBranchNaming': 'feature/<ticket>/<short-description>',
|
|
73
|
-
// FALSE on purpose, and NOT what this repo runs. Unattended branch deletion is the one setting
|
|
74
|
-
// where "nobody has answered yet" must mean "delete nothing" — a consumer turns it on once they
|
|
75
|
-
// have read what BranchReaper proves dead and what it archives.
|
|
76
|
-
'branch-creation-guard.autoReapMergedBranches': false,
|
|
77
|
-
// 0..5 behind allowed, stale-main blocks at 6. The type fallback for a number is 0, which would
|
|
78
|
-
// block the moment origin/main moves at all — a seeded config that blocks on arrival.
|
|
79
|
-
'branch-state-guard.maxCommitsBehind': 5,
|
|
80
|
-
// The api-contract tree the issue that added the rule (#1026) names; a consumer edits it to theirs.
|
|
81
|
-
'no-utility-types-in-api-lib.paths': ['libraries/apis/**'],
|
|
82
|
-
// The api-contract entry the issue that added the rule (#1037) names; a consumer edits it to theirs.
|
|
83
|
-
// `entries` must be non-empty, so the type fallback ([]) would seed a config that fails to load.
|
|
84
|
-
'required-type-suffix.entries': [
|
|
85
|
-
{ paths: ['libraries/apis/**'], suffixes: ['Request', 'Response', 'Event', 'Dto', 'Api'] },
|
|
86
|
-
],
|
|
87
|
-
// #1064 — the reference consumer's layout (ctoteachings/monorepo), documented in
|
|
88
|
-
// .claude/rules/framework-tags.md. A consumer edits each to its own.
|
|
89
|
-
'api-lib-dependencies.apiLibPackages': ['@webpieces/core-util', 'tslib'],
|
|
90
|
-
'api-lib-dependencies.apiClients': [],
|
|
91
|
-
'api-lib-path.paths': ['libraries/apis/**'],
|
|
92
|
-
'framework-folder.entries': [
|
|
93
|
-
{ paths: ['libraries/angular/**'], frameworkSets: ['angular'], roles: ['lib', 'designed-lib'] },
|
|
94
|
-
{ paths: ['libraries/node/**'], frameworkSets: ['node', 'express'], roles: ['lib', 'designed-lib'] },
|
|
95
|
-
{
|
|
96
|
-
paths: ['libraries/universal/**'],
|
|
97
|
-
frameworkSets: ['browser+node+react-native'],
|
|
98
|
-
roles: ['lib', 'designed-lib'],
|
|
99
|
-
},
|
|
100
|
-
{ paths: ['libraries/rn-browser/**'], frameworkSets: ['browser+react-native'], roles: ['lib', 'designed-lib'] },
|
|
101
|
-
{ paths: ['libraries/react-native/**'], frameworkSets: ['react-native'], roles: ['lib', 'designed-lib'] },
|
|
102
|
-
{ paths: ['libraries/apis/internal/**'], frameworkSets: ['browser+node+react-native'], roles: ['api-lib'] },
|
|
103
|
-
{ paths: ['libraries/apis/external-node/**'], frameworkSets: ['node'], roles: ['api-client'] },
|
|
104
|
-
{ paths: ['libraries/apis/external-rn-browser/**'], frameworkSets: ['browser+react-native'], roles: ['api-lib'] },
|
|
105
|
-
],
|
|
106
|
-
'framework-packages.entries': [
|
|
107
|
-
{ packages: ['@angular/*'], frameworks: ['angular'] },
|
|
108
|
-
{ packages: ['react', 'react-native', 'expo*', '@expo/*', '@sentry/react-native'], frameworks: ['react', 'react-native'] },
|
|
109
|
-
{
|
|
110
|
-
packages: ['express', 'firebase-admin', 'googleapis', 'google-auth-library', '@google-cloud/*'],
|
|
111
|
-
frameworks: ['node', 'express'],
|
|
112
|
-
},
|
|
113
|
-
{ packages: ['firebase'], frameworks: ['browser', 'angular', 'react'] },
|
|
114
|
-
],
|
|
115
|
-
};
|
|
116
|
-
// The value a seeded entry gets for ONE required field. Order matters and is deliberate:
|
|
117
|
-
// 1. the two universal escape hatches — always their "active" state (0 / null), never a placeholder;
|
|
118
|
-
// 2. `mode` — the shared recommendation (see recommendedSeedMode);
|
|
119
|
-
// 3. this rule+field's SEED_VALUES entry, when it has one;
|
|
120
|
-
// 4. the framework's documented tuning default for that rule (defaultRules), which by policy holds
|
|
121
|
-
// OPTIONAL fields only (e.g. max-file-lines.limit: 900) — so this step fires for a field that is
|
|
122
|
-
// required here and optional in another rule's schema;
|
|
123
|
-
// 5. a conservative fallback by type — null if the field accepts null, false for boolean, [] for
|
|
124
|
-
// string[], the first enum value for an enum, '' / 0 otherwise. Reaching step 5 for a NEW
|
|
125
|
-
// required field means it wants a SEED_VALUES entry, which the seed-validates-clean spec in
|
|
126
|
-
// ai-hook-rules/src/bin/setup.spec.ts turns into a build failure if the fallback is not valid.
|
|
127
|
-
// webpieces-disable no-any-unknown -- a config field value is opaque JSON by construction
|
|
128
|
-
// webpieces-disable no-function-outside-class -- sibling of the module-scope schema helpers in this file
|
|
129
|
-
function seedFieldValue(ruleName, key, def) {
|
|
130
|
-
if (key === 'turnOffRuleUntilEpoch')
|
|
131
|
-
return 0;
|
|
132
|
-
if (key === 'turnOffRuleWhileOnBranch')
|
|
133
|
-
return null;
|
|
134
|
-
if (key === 'mode')
|
|
135
|
-
return recommendedSeedModeFor(def.enumValues ?? []);
|
|
136
|
-
const seeded = SEED_VALUES[`${ruleName}.${key}`];
|
|
137
|
-
if (seeded !== undefined)
|
|
138
|
-
return seeded;
|
|
139
|
-
const documented = default_rules_1.defaultRules[ruleName]?.[key];
|
|
140
|
-
if (documented !== undefined)
|
|
141
|
-
return documented;
|
|
142
|
-
if (def.nullable)
|
|
143
|
-
return null;
|
|
144
|
-
if (def.type === 'boolean')
|
|
145
|
-
return false;
|
|
146
|
-
if (def.type === 'string[]' || def.type === 'object[]')
|
|
147
|
-
return [];
|
|
148
|
-
if (def.enumValues && def.enumValues.length > 0)
|
|
149
|
-
return def.enumValues[0];
|
|
150
|
-
return def.type === 'number' ? 0 : '';
|
|
35
|
+
/** Recommendations are owner-authored file-writing data, never runtime defaults. */
|
|
36
|
+
// webpieces-disable no-function-outside-class -- pure registry projection
|
|
37
|
+
function recommendedSeedMode(ruleName, registry) {
|
|
38
|
+
return String(seedEntryForRule(ruleName, registry)['mode']);
|
|
151
39
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
// webpieces-disable no-any-unknown -- a config entry is opaque JSON by construction
|
|
162
|
-
// webpieces-disable no-function-outside-class -- sibling of the module-scope schema helpers in this file
|
|
163
|
-
function seedEntryForRule(ruleName) {
|
|
164
|
-
const schema = rule_schemas_1.RULE_SCHEMAS[ruleName];
|
|
165
|
-
const entry = {
|
|
166
|
-
mode: recommendedSeedMode(ruleName), turnOffRuleUntilEpoch: 0, turnOffRuleWhileOnBranch: null,
|
|
167
|
-
};
|
|
168
|
-
if (!schema)
|
|
169
|
-
return entry;
|
|
170
|
-
for (const key of Object.keys(schema)) {
|
|
171
|
-
if (schema[key].optional)
|
|
172
|
-
continue;
|
|
173
|
-
entry[key] = seedFieldValue(ruleName, key, schema[key]);
|
|
174
|
-
}
|
|
175
|
-
return entry;
|
|
40
|
+
// webpieces-disable no-function-outside-class -- pure registry projection
|
|
41
|
+
function seedEntryForRule(ruleName, registry) {
|
|
42
|
+
if (registry.hasRule(ruleName))
|
|
43
|
+
return registry.seedFor(ruleName);
|
|
44
|
+
if (registry.isSafeguard(ruleName))
|
|
45
|
+
throw new tooling_common_1.InformAiError(`${ruleName} is a safeguard with no configurable seed. Remove its config entry.`);
|
|
46
|
+
// Existing rulesDir-only custom implementations have no declared schema. This is file-writing advice,
|
|
47
|
+
// never a loader default; declared custom policies always use their owner's complete seed.
|
|
48
|
+
return { mode: 'OFF', turnOffRuleUntilEpoch: 0, turnOffRuleWhileOnBranch: null };
|
|
176
49
|
}
|
|
177
50
|
/** True when `mode` is one of the gradual (change-scoped) modes — used to decide whether to print the rollout prose. */
|
|
178
51
|
// webpieces-disable no-function-outside-class -- sibling of the seeding helpers in this file
|
package/src/seed-entry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version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E,wBAAwB,EAAE,IAAI;KAChG,CAAC;IACF,IAAI,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAC1B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACpC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ;YAAE,SAAS;QACnC,KAAK,CAAC,GAAG,CAAC,GAAG,cAAc,CAAC,QAAQ,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAGD,wHAAwH;AACxH,6FAA6F;AAC7F,SAAgB,aAAa,CAAC,IAAY;IACtC,OAAO,uBAAuB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAClD,CAAC","sourcesContent":["// Seeding: what a rule's webpieces.config.json entry should look like when nothing has configured it\n// yet. Split out of validate-config.ts (700-line cap). This is the SINGLE source of truth shared by the\n// validator's copy-paste snippet (rolloutTip), the installer (ai-hook-rules setup.seedRule) and fault Y's\n// deny — so a seeded config can never contradict the advice printed beside it.\nimport { FieldDef } from './field-def';\nimport { RULE_SCHEMAS } from './rule-schemas';\nimport { defaultRules } from './default-rules';\n\n// Scoped modes (narrowest → broadest) that enforce ONLY on what changed, so a rule can be\n// adopted gradually instead of all-at-once. When a rule offers one, recommend the first it\n// supports so a fresh config opts into a low-friction rollout rather than reflexively OFF.\n//\n// The two PROJECT-wide modes come LAST (#1027). A project rule offers nothing narrower, so it still\n// arrives as MODIFIED_PROJECTS; but a line/file-scoped rule that ALSO offers the whole-scope modes\n// (every MODIFIED_CODE_MODES rule, #1027) must keep arriving at its narrow mode — seeding it at\n// MODIFIED_PROJECTS would judge every file of every touched project on day one, the opposite of a\n// gradual rollout. RUN_EVERY_TIME is never a gradual mode and is not listed here at all.\nconst GRADUAL_MODE_PREFERENCE = [\n 'NEW_AND_MODIFIED_CODE',\n 'NEW_AND_MODIFIED_METHODS',\n 'MODIFIED_CLASS',\n 'NEW_METHODS',\n 'NEW_AND_MODIFIED_FILES',\n 'MODIFIED_PROJECTS',\n // Same granularity as MODIFIED_PROJECTS, from the other direction: the projects nx's diff makes\n // affected. Listed after it so a rule offering both keeps its existing recommendation (#1017).\n 'AFFECTED_PROJECT',\n];\n\n// The ONE place that decides what mode a rule should arrive as. Every consumer of that decision —\n// the validator's copy-paste snippet (rolloutTip in validate-config.ts), the installer's seeding, and the fault-`Y` deny in\n// ai-hook-rules — calls this, so a seeded config can never contradict the advice printed beside it.\n// Precedence: narrowest gradual mode the rule supports → ON → RUN_EVERY_TIME → OFF (a rule offering\n// none of those has nothing else it can be).\n// webpieces-disable no-function-outside-class -- sibling of the module-scope schema helpers in this file\nexport function recommendedSeedModeFor(modes: readonly string[]): string {\n const gradual = GRADUAL_MODE_PREFERENCE.find((m: string) => modes.includes(m));\n if (gradual) return gradual;\n if (modes.includes('ON')) return 'ON';\n if (modes.includes('RUN_EVERY_TIME')) return 'RUN_EVERY_TIME';\n return 'OFF';\n}\n\n/**\n * The mode a fresh/migrated `webpieces.config.json` entry for `ruleName` should be seeded with.\n * Unknown rule names (custom rules from `rulesDir`) fall back to 'OFF' — we have no schema to know\n * which modes they accept.\n */\n// webpieces-disable no-function-outside-class -- sibling of the module-scope schema helpers in this file\nexport function recommendedSeedMode(ruleName: string): string {\n const schema = RULE_SCHEMAS[ruleName];\n if (!schema) return 'OFF';\n return recommendedSeedModeFor(schema['mode']?.enumValues ?? []);\n}\n\n/**\n * What a FRESH config is SEEDED with for a schema-REQUIRED field that is not `mode` or a hatch.\n *\n * This is NOT a default, and the distinction is the whole of #1017. A default is the value a rule\n * runs on when the consumer's config never mentions it — invisible, and therefore a decision made\n * for somebody who was never asked. A seed VALUE is written into the consumer's own\n * `webpieces.config.json`, where it is read, reviewed and changed like any other line they own. So\n * `defaultRules` may not carry a required field (no-rule-defaults.spec.ts fails the build if it\n * does), and the installer still has something sensible to write on day one.\n *\n * Keyed `<rule>.<field>`. Anything absent falls through to the conservative type fallback below.\n */\n// webpieces-disable no-any-unknown -- a config field value is opaque JSON by construction\nconst SEED_VALUES: Record<string, unknown> = {\n // The convention this repo's own config states; a consumer edits it to theirs.\n 'branch-creation-guard.subBranchNaming': 'feature/<ticket>/<short-description>',\n // FALSE on purpose, and NOT what this repo runs. Unattended branch deletion is the one setting\n // where \"nobody has answered yet\" must mean \"delete nothing\" — a consumer turns it on once they\n // have read what BranchReaper proves dead and what it archives.\n 'branch-creation-guard.autoReapMergedBranches': false,\n // 0..5 behind allowed, stale-main blocks at 6. The type fallback for a number is 0, which would\n // block the moment origin/main moves at all — a seeded config that blocks on arrival.\n 'branch-state-guard.maxCommitsBehind': 5,\n // The api-contract tree the issue that added the rule (#1026) names; a consumer edits it to theirs.\n 'no-utility-types-in-api-lib.paths': ['libraries/apis/**'],\n // The api-contract entry the issue that added the rule (#1037) names; a consumer edits it to theirs.\n // `entries` must be non-empty, so the type fallback ([]) would seed a config that fails to load.\n 'required-type-suffix.entries': [\n { paths: ['libraries/apis/**'], suffixes: ['Request', 'Response', 'Event', 'Dto', 'Api'] },\n ],\n // #1064 — the reference consumer's layout (ctoteachings/monorepo), documented in\n // .claude/rules/framework-tags.md. A consumer edits each to its own.\n 'api-lib-dependencies.apiLibPackages': ['@webpieces/core-util', 'tslib'],\n 'api-lib-dependencies.apiClients': [],\n 'api-lib-path.paths': ['libraries/apis/**'],\n 'framework-folder.entries': [\n { paths: ['libraries/angular/**'], frameworkSets: ['angular'], roles: ['lib', 'designed-lib'] },\n { paths: ['libraries/node/**'], frameworkSets: ['node', 'express'], roles: ['lib', 'designed-lib'] },\n {\n paths: ['libraries/universal/**'],\n frameworkSets: ['browser+node+react-native'],\n roles: ['lib', 'designed-lib'],\n },\n { paths: ['libraries/rn-browser/**'], frameworkSets: ['browser+react-native'], roles: ['lib', 'designed-lib'] },\n { paths: ['libraries/react-native/**'], frameworkSets: ['react-native'], roles: ['lib', 'designed-lib'] },\n { paths: ['libraries/apis/internal/**'], frameworkSets: ['browser+node+react-native'], roles: ['api-lib'] },\n { paths: ['libraries/apis/external-node/**'], frameworkSets: ['node'], roles: ['api-client'] },\n { paths: ['libraries/apis/external-rn-browser/**'], frameworkSets: ['browser+react-native'], roles: ['api-lib'] },\n ],\n 'framework-packages.entries': [\n { packages: ['@angular/*'], frameworks: ['angular'] },\n { packages: ['react', 'react-native', 'expo*', '@expo/*', '@sentry/react-native'], frameworks: ['react', 'react-native'] },\n {\n packages: ['express', 'firebase-admin', 'googleapis', 'google-auth-library', '@google-cloud/*'],\n frameworks: ['node', 'express'],\n },\n { packages: ['firebase'], frameworks: ['browser', 'angular', 'react'] },\n ],\n};\n\n// The value a seeded entry gets for ONE required field. Order matters and is deliberate:\n// 1. the two universal escape hatches — always their \"active\" state (0 / null), never a placeholder;\n// 2. `mode` — the shared recommendation (see recommendedSeedMode);\n// 3. this rule+field's SEED_VALUES entry, when it has one;\n// 4. the framework's documented tuning default for that rule (defaultRules), which by policy holds\n// OPTIONAL fields only (e.g. max-file-lines.limit: 900) — so this step fires for a field that is\n// required here and optional in another rule's schema;\n// 5. a conservative fallback by type — null if the field accepts null, false for boolean, [] for\n// string[], the first enum value for an enum, '' / 0 otherwise. Reaching step 5 for a NEW\n// required field means it wants a SEED_VALUES entry, which the seed-validates-clean spec in\n// ai-hook-rules/src/bin/setup.spec.ts turns into a build failure if the fallback is not valid.\n// webpieces-disable no-any-unknown -- a config field value is opaque JSON by construction\n// webpieces-disable no-function-outside-class -- sibling of the module-scope schema helpers in this file\nfunction seedFieldValue(ruleName: string, key: string, def: FieldDef): unknown {\n if (key === 'turnOffRuleUntilEpoch') return 0;\n if (key === 'turnOffRuleWhileOnBranch') return null;\n if (key === 'mode') return recommendedSeedModeFor(def.enumValues ?? []);\n\n const seeded = SEED_VALUES[`${ruleName}.${key}`];\n if (seeded !== undefined) return seeded;\n\n const documented = defaultRules[ruleName]?.[key];\n if (documented !== undefined) return documented;\n\n if (def.nullable) return null;\n if (def.type === 'boolean') return false;\n if (def.type === 'string[]' || def.type === 'object[]') return [];\n if (def.enumValues && def.enumValues.length > 0) return def.enumValues[0];\n return def.type === 'number' ? 0 : '';\n}\n\n/**\n * The COMPLETE `webpieces.config.json` entry for `ruleName` — recommended mode, both escape hatches,\n * and a value for every other schema-REQUIRED field.\n *\n * Emitting only mode+hatches is what let `wp-install-ai-hooks` write a config the loader then\n * rejected (`[branch-creation-guard] Missing required field \"autoReapMergedBranches\"`), so the\n * installer and the validator read the SAME schema here. Unknown rule names (custom rules from\n * `rulesDir`) get the minimal entry — we have no schema to enumerate their required fields.\n */\n// webpieces-disable no-any-unknown -- a config entry is opaque JSON by construction\n// webpieces-disable no-function-outside-class -- sibling of the module-scope schema helpers in this file\nexport function seedEntryForRule(ruleName: string): Record<string, unknown> {\n const schema = RULE_SCHEMAS[ruleName];\n const entry: Record<string, unknown> = {\n mode: recommendedSeedMode(ruleName), turnOffRuleUntilEpoch: 0, turnOffRuleWhileOnBranch: null,\n };\n if (!schema) return entry;\n for (const key of Object.keys(schema)) {\n if (schema[key].optional) continue;\n entry[key] = seedFieldValue(ruleName, key, schema[key]);\n }\n return entry;\n}\n\n\n/** True when `mode` is one of the gradual (change-scoped) modes — used to decide whether to print the rollout prose. */\n// webpieces-disable no-function-outside-class -- sibling of the seeding helpers in this file\nexport function isGradualMode(mode: string): boolean {\n return GRADUAL_MODE_PREFERENCE.includes(mode);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"seed-entry.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/seed-entry.ts"],"names":[],"mappings":";;AAsBA,wDAMC;AAKD,kDAEC;AAED,4CAMC;AAID,sCAEC;AAjDD,8DAA0D;AAI1D,MAAM,uBAAuB,GAAG;IAC5B,uBAAuB;IACvB,0BAA0B;IAC1B,gBAAgB;IAChB,aAAa;IACb,wBAAwB;IACxB,mBAAmB;IACnB,gGAAgG;IAChG,+FAA+F;IAC/F,kBAAkB;CACrB,CAAC;AAEF,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esContent":["import { InformAiError } from '@webpieces/tooling-common';\nimport { ConfigObject } from '@webpieces/rules-sdk';\nimport { RulePackRegistry } from './rule-pack-registry';\n\nconst GRADUAL_MODE_PREFERENCE = [\n 'NEW_AND_MODIFIED_CODE',\n 'NEW_AND_MODIFIED_METHODS',\n 'MODIFIED_CLASS',\n 'NEW_METHODS',\n 'NEW_AND_MODIFIED_FILES',\n 'MODIFIED_PROJECTS',\n // Same granularity as MODIFIED_PROJECTS, from the other direction: the projects nx's diff makes\n // affected. Listed after it so a rule offering both keeps its existing recommendation (#1017).\n 'AFFECTED_PROJECT',\n];\n\n// The ONE place that decides what mode a rule should arrive as. Every consumer of that decision —\n// the validator's copy-paste snippet (rolloutTip in validate-config.ts), the installer's seeding, and the fault-`Y` deny in\n// ai-hook-rules — calls this, so a seeded config can never contradict the advice printed beside it.\n// Precedence: narrowest gradual mode the rule supports → ON → RUN_EVERY_TIME → OFF (a rule offering\n// none of those has nothing else it can be).\n// webpieces-disable no-function-outside-class -- sibling of the module-scope schema helpers in this file\nexport function recommendedSeedModeFor(modes: readonly string[]): string {\n const gradual = GRADUAL_MODE_PREFERENCE.find((m: string) => modes.includes(m));\n if (gradual) return gradual;\n if (modes.includes('ON')) return 'ON';\n if (modes.includes('RUN_EVERY_TIME')) return 'RUN_EVERY_TIME';\n return 'OFF';\n}\n\n\n/** Recommendations are owner-authored file-writing data, never runtime defaults. */\n// webpieces-disable no-function-outside-class -- pure registry projection\nexport function recommendedSeedMode(ruleName: string, registry: RulePackRegistry): string {\n return String(seedEntryForRule(ruleName, registry)['mode']);\n}\n// webpieces-disable no-function-outside-class -- pure registry projection\nexport function seedEntryForRule(ruleName: string, registry: RulePackRegistry): ConfigObject {\n if (registry.hasRule(ruleName)) return registry.seedFor(ruleName);\n if (registry.isSafeguard(ruleName)) throw new InformAiError(`${ruleName} is a safeguard with no configurable seed. Remove its config entry.`);\n // Existing rulesDir-only custom implementations have no declared schema. This is file-writing advice,\n // never a loader default; declared custom policies always use their owner's complete seed.\n return { mode: 'OFF', turnOffRuleUntilEpoch: 0, turnOffRuleWhileOnBranch: null };\n}\n\n/** True when `mode` is one of the gradual (change-scoped) modes — used to decide whether to print the rollout prose. */\n// webpieces-disable no-function-outside-class -- sibling of the seeding helpers in this file\nexport function isGradualMode(mode: string): boolean {\n return GRADUAL_MODE_PREFERENCE.includes(mode);\n}\n"]}
|
package/src/validate-config.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RulePackRegistry } from './rule-pack-registry';
|
|
1
2
|
import { validateChecklistsSection } from './pr-gate-section-validators';
|
|
2
3
|
export { validateChecklistsSection };
|
|
3
4
|
export { allRuleNames } from './rule-schemas';
|
|
@@ -14,7 +15,7 @@ export { recommendedSeedMode, recommendedSeedModeFor, seedEntryForRule } from '.
|
|
|
14
15
|
* legitimately runs 35+ days, and capping that would only interrupt the one branch that opted in.
|
|
15
16
|
*/
|
|
16
17
|
export declare const MAX_TURN_OFF_EPOCH_DAYS = 7;
|
|
17
|
-
export declare function validateWebpiecesConfig(rawRules: Record<string, Record<string, unknown>>, hasCustomRulesDir?: boolean): string[];
|
|
18
|
+
export declare function validateWebpiecesConfig(rawRules: Record<string, Record<string, unknown>>, registry: RulePackRegistry, hasCustomRulesDir?: boolean): string[];
|
|
18
19
|
/**
|
|
19
20
|
* Validate the top-level `pr-gate` section. It is REQUIRED (a client that opts out sets mode "OFF").
|
|
20
21
|
* `buildCommand` is required unless mode is "OFF". Returns human-readable, copy-paste-friendly errors
|
|
@@ -50,4 +51,4 @@ export declare function validateMatchRulesSection(section: unknown): string[];
|
|
|
50
51
|
* rules from rulesDir). Presence ("every built-in must be configured") is checked separately by
|
|
51
52
|
* validateWebpiecesConfig against the merged map.
|
|
52
53
|
*/
|
|
53
|
-
export declare function validateSectionPlacement(rulesSection: Record<string, Record<string, unknown>>, hookGuardsSection: Record<string, Record<string, unknown
|
|
54
|
+
export declare function validateSectionPlacement(rulesSection: Record<string, Record<string, unknown>>, hookGuardsSection: Record<string, Record<string, unknown>>, registry: RulePackRegistry): string[];
|
package/src/validate-config.js
CHANGED
|
@@ -10,16 +10,15 @@ exports.validateSectionPlacement = validateSectionPlacement;
|
|
|
10
10
|
// this marker is how it recognizes a placement error. See config-error-banner.ts.
|
|
11
11
|
const config_error_banner_1 = require("./config-error-banner");
|
|
12
12
|
const sections_1 = require("./sections");
|
|
13
|
-
const rule_schemas_1 = require("./rule-schemas");
|
|
14
13
|
const seed_entry_1 = require("./seed-entry");
|
|
15
|
-
const
|
|
14
|
+
const rules_sdk_1 = require("@webpieces/rules-sdk");
|
|
16
15
|
const pr_gate_section_validators_1 = require("./pr-gate-section-validators");
|
|
17
16
|
Object.defineProperty(exports, "validateChecklistsSection", { enumerable: true, get: function () { return pr_gate_section_validators_1.validateChecklistsSection; } });
|
|
18
17
|
const retired_config_keys_1 = require("./retired-config-keys");
|
|
19
18
|
const constants_1 = require("./constants");
|
|
20
19
|
// Re-exported from their new homes: this module was the historical entry point for both.
|
|
21
|
-
var
|
|
22
|
-
Object.defineProperty(exports, "allRuleNames", { enumerable: true, get: function () { return
|
|
20
|
+
var rule_schemas_1 = require("./rule-schemas");
|
|
21
|
+
Object.defineProperty(exports, "allRuleNames", { enumerable: true, get: function () { return rule_schemas_1.allRuleNames; } });
|
|
23
22
|
var seed_entry_2 = require("./seed-entry");
|
|
24
23
|
Object.defineProperty(exports, "recommendedSeedMode", { enumerable: true, get: function () { return seed_entry_2.recommendedSeedMode; } });
|
|
25
24
|
Object.defineProperty(exports, "recommendedSeedModeFor", { enumerable: true, get: function () { return seed_entry_2.recommendedSeedModeFor; } });
|
|
@@ -85,40 +84,6 @@ function objectListHint(def) {
|
|
|
85
84
|
.map((key) => `"${key}": ${valueHint(schema[key], key)}`);
|
|
86
85
|
return `[{ ${fields.join(', ')} }, ...]`;
|
|
87
86
|
}
|
|
88
|
-
/** A rollout hint for the copy-paste snippet: recommend the narrowest gradual mode the rule supports. */
|
|
89
|
-
function rolloutTip(schema) {
|
|
90
|
-
const modes = schema['mode']?.enumValues ?? [];
|
|
91
|
-
// Same source of truth as the seeder; only a GRADUAL recommendation gets the rollout prose, so a
|
|
92
|
-
// rule whose recommendation falls through to ON/RUN_EVERY_TIME/OFF prints no tip (as before).
|
|
93
|
-
const recommended = (0, seed_entry_1.recommendedSeedModeFor)(modes);
|
|
94
|
-
if (!(0, seed_entry_1.isGradualMode)(recommended))
|
|
95
|
-
return '';
|
|
96
|
-
const optOut = modes.includes('OFF') ? ' Set "mode": "OFF" to opt out entirely.' : '';
|
|
97
|
-
return (`\n\n💡 Recommended: start with "mode": "${recommended}" — it enforces only on what you ` +
|
|
98
|
-
`actually change, so the rule rolls out gradually (existing code stays grandfathered until ` +
|
|
99
|
-
`you next touch that project/file/method).${optOut}`);
|
|
100
|
-
}
|
|
101
|
-
function missingRuleSnippet(ruleName, schema) {
|
|
102
|
-
// Required fields go in the copy-paste entry. The two universal escape hatches
|
|
103
|
-
// (turnOffRuleUntilEpoch / turnOffRuleWhileOnBranch) are now REQUIRED, so they land in that block —
|
|
104
|
-
// which is the whole point: every seeded rule shows both hatches. Optional fields are listed separately.
|
|
105
|
-
const fields = Object.keys(schema);
|
|
106
|
-
const required = fields.filter(f => !schema[f].optional);
|
|
107
|
-
const optional = fields.filter(f => schema[f].optional);
|
|
108
|
-
const requiredLines = required.map(f => ` "${f}": ${valueHint(schema[f], f)}`);
|
|
109
|
-
const section = (0, sections_1.sectionForRule)(ruleName);
|
|
110
|
-
let out = `[${ruleName}] Not configured in webpieces.config.json. Add this entry to the "${section}" section\n` +
|
|
111
|
-
`(choose values appropriate for your project):\n\n` +
|
|
112
|
-
` "${ruleName}": {\n${requiredLines.join(',\n')}\n }`;
|
|
113
|
-
if (optional.length > 0) {
|
|
114
|
-
const optionalLines = optional.map(f => ` "${f}": ${valueHint(schema[f], f)}`);
|
|
115
|
-
out +=
|
|
116
|
-
`\n\nOptional fields you may add to this rule (omit if not needed):\n` +
|
|
117
|
-
`${optionalLines.join(',\n')}`;
|
|
118
|
-
}
|
|
119
|
-
out += rolloutTip(schema);
|
|
120
|
-
return out;
|
|
121
|
-
}
|
|
122
87
|
/**
|
|
123
88
|
* A config key under rules/hookGuards that the RUNNING validator has no schema for (and no rulesDir is set
|
|
124
89
|
* to supply custom rules). THE FALLBACK: it fires for any name the table in retired-config-keys.ts does not
|
|
@@ -151,31 +116,49 @@ function unknownRuleError(ruleName) {
|
|
|
151
116
|
`and the version-drift guard reports THAT separately with its own cure (bump the pin) before this ` +
|
|
152
117
|
`validator ever runs — so it is not what you are looking at.`);
|
|
153
118
|
}
|
|
119
|
+
/** Schema advice retains the existing validation text and consumes the selected owner registry. */
|
|
120
|
+
class RuleConfigAdvice {
|
|
121
|
+
registry;
|
|
122
|
+
constructor(registry) {
|
|
123
|
+
this.registry = registry;
|
|
124
|
+
}
|
|
125
|
+
rolloutTip(schema) {
|
|
126
|
+
const modes = schema['mode']?.enumValues ?? [];
|
|
127
|
+
// Same source of truth as the seeder; only a GRADUAL recommendation gets the rollout prose, so a
|
|
128
|
+
// rule whose recommendation falls through to ON/RUN_EVERY_TIME/OFF prints no tip (as before).
|
|
129
|
+
const recommended = (0, seed_entry_1.recommendedSeedModeFor)(modes);
|
|
130
|
+
if (!(0, seed_entry_1.isGradualMode)(recommended))
|
|
131
|
+
return '';
|
|
132
|
+
const optOut = modes.includes('OFF') ? ' Set "mode": "OFF" to opt out entirely.' : '';
|
|
133
|
+
return (`\n\n💡 Recommended: start with "mode": "${recommended}" — it enforces only on what you ` +
|
|
134
|
+
`actually change, so the rule rolls out gradually (existing code stays grandfathered until ` +
|
|
135
|
+
`you next touch that project/file/method).${optOut}`);
|
|
136
|
+
}
|
|
137
|
+
missingRuleSnippet(ruleName, schema) {
|
|
138
|
+
// Required fields go in the copy-paste entry. The two universal escape hatches
|
|
139
|
+
// (turnOffRuleUntilEpoch / turnOffRuleWhileOnBranch) are now REQUIRED, so they land in that block —
|
|
140
|
+
// which is the whole point: every seeded rule shows both hatches. Optional fields are listed separately.
|
|
141
|
+
const fields = Object.keys(schema);
|
|
142
|
+
const required = fields.filter(f => !schema[f].optional);
|
|
143
|
+
const optional = fields.filter(f => schema[f].optional);
|
|
144
|
+
const requiredLines = required.map(f => ` "${f}": ${valueHint(schema[f], f)}`);
|
|
145
|
+
const section = this.registry.sectionFor(ruleName);
|
|
146
|
+
let out = `[${ruleName}] Not configured in webpieces.config.json. Add this entry to the "${section}" section\n` +
|
|
147
|
+
`(choose values appropriate for your project):\n\n` +
|
|
148
|
+
` "${ruleName}": {\n${requiredLines.join(',\n')}\n }`;
|
|
149
|
+
if (optional.length > 0) {
|
|
150
|
+
const optionalLines = optional.map(f => ` "${f}": ${valueHint(schema[f], f)}`);
|
|
151
|
+
out +=
|
|
152
|
+
`\n\nOptional fields you may add to this rule (omit if not needed):\n` +
|
|
153
|
+
`${optionalLines.join(',\n')}`;
|
|
154
|
+
}
|
|
155
|
+
out += this.rolloutTip(schema);
|
|
156
|
+
return out;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
154
159
|
// Fields we DELETED from a rule's schema, keyed by "<rule>.<field>". The generic unknown-field error
|
|
155
160
|
// ("Unknown field ... Valid fields: [...]") is correct but doesn't say WHY the field vanished, so an AI
|
|
156
161
|
// might re-add it. These hints explain the removal so the only action left is to delete the key.
|
|
157
|
-
const RETIRED_FIELD_HINTS = {
|
|
158
|
-
'runtime-architecture.servicePaths': 'This field was removed — it was never read. The runtime graph is derived automatically from ' +
|
|
159
|
-
'architecture/dependencies.json (apiRelations + project roles). Delete it.',
|
|
160
|
-
'runtime-architecture.apiProjectPaths': 'This field was removed — it was never read. The runtime graph is derived automatically from ' +
|
|
161
|
-
'architecture/dependencies.json, so there is NO list of api libs to maintain. Delete it (do not ' +
|
|
162
|
-
'enumerate api libs and do not replace it with a glob).',
|
|
163
|
-
'runtime-architecture.allowedCycles': 'This field was removed — a runtime cycle is not allowable at all any more. Levelling now FAILS ' +
|
|
164
|
-
'on any cycle, because CD deploys services in dependency order and a cycle has no such order. ' +
|
|
165
|
-
'Delete the key. If a cycle genuinely cannot be broken yet, declare it PER EDGE with a ' +
|
|
166
|
-
'`cutLegacyCycle:<targetService>` nx tag on the CALLING project, which admits the debt where ' +
|
|
167
|
-
'`grep -rn cutLegacyCycle` can enumerate it — there is no config key for it.',
|
|
168
|
-
// The two per-guard command strings, deleted as SECOND SPELLINGS of commands.guardHints. They were
|
|
169
|
-
// read at the point of use, so they BEAT the commands section — which made guardHintsWhy's promise
|
|
170
|
-
// ("rename a gated command here and every guard message follows") false for any repo that set them.
|
|
171
|
-
// Keyed on the new policy key, since that is the entry a consumer's field now sits inside.
|
|
172
|
-
'pr-lifecycle-guard.upsertPrCommand': 'This field was removed. The command the push/PR-creation block prints lives in ONE place: ' +
|
|
173
|
-
'"commands": { "guardHints": { "prCreationOrPush": <value> } }. Move your value there and delete ' +
|
|
174
|
-
'this key.',
|
|
175
|
-
'pr-lifecycle-guard.mergeCompleteCommand': 'This field was removed. The command the unfinished-merge block prints lives in ONE place: ' +
|
|
176
|
-
'"commands": { "guardHints": { "mergeInProgress": <value> } }. Move your value there and delete ' +
|
|
177
|
-
'this key.',
|
|
178
|
-
};
|
|
179
162
|
// Universal field renames (apply to EVERY rule/guard AND every match-rule, unlike the per-rule
|
|
180
163
|
// RETIRED_FIELD_HINTS). When an entry still uses the old escape-hatch name, the generic unknown-field
|
|
181
164
|
// error is replaced with a precise "renamed to X — rename it" instruction so the fix is mechanical.
|
|
@@ -197,7 +180,7 @@ function renamedFieldError(scope, oldKey, newKey) {
|
|
|
197
180
|
*/
|
|
198
181
|
// webpieces-disable no-any-unknown -- one config entry as opaque JSON; every field is typed-checked below
|
|
199
182
|
// webpieces-disable no-function-outside-class -- module-scope validator helper, matching every other check in this file
|
|
200
|
-
function fieldErrors(ruleName, entry, schema) {
|
|
183
|
+
function fieldErrors(ruleName, entry, schema, registry) {
|
|
201
184
|
const errors = [];
|
|
202
185
|
for (const [key, value] of Object.entries(entry)) {
|
|
203
186
|
const fieldDef = schema[key];
|
|
@@ -207,7 +190,7 @@ function fieldErrors(ruleName, entry, schema) {
|
|
|
207
190
|
errors.push(renamedFieldError(`[${ruleName}]`, key, renamedTo));
|
|
208
191
|
continue;
|
|
209
192
|
}
|
|
210
|
-
const retiredHint =
|
|
193
|
+
const retiredHint = registry.migrations().find(entry => entry.scope === 'field' && entry.key === `${ruleName}.${key}`)?.instruction;
|
|
211
194
|
const suffix = retiredHint ? ` ${retiredHint}` : '';
|
|
212
195
|
errors.push(`[${ruleName}] Unknown field "${key}". Valid fields: [${Object.keys(schema).join(', ')}].${suffix}`);
|
|
213
196
|
continue;
|
|
@@ -282,17 +265,22 @@ function arrayFieldErrors(label, value, def) {
|
|
|
282
265
|
return errors;
|
|
283
266
|
}
|
|
284
267
|
// webpieces-disable no-any-unknown -- rawRules values are opaque JSON; each field is validated individually
|
|
285
|
-
function validateWebpiecesConfig(rawRules, hasCustomRulesDir = false) {
|
|
268
|
+
function validateWebpiecesConfig(rawRules, registry, hasCustomRulesDir = false) {
|
|
286
269
|
const errors = [];
|
|
270
|
+
const advice = new RuleConfigAdvice(registry);
|
|
287
271
|
// Check field-level correctness for rules that are present
|
|
288
272
|
for (const [ruleName, entry] of Object.entries(rawRules)) {
|
|
289
|
-
const schema =
|
|
273
|
+
const schema = registry.hasRule(ruleName) ? registry.schemaFor(ruleName) : undefined;
|
|
290
274
|
if (!schema) {
|
|
275
|
+
if (registry.isSafeguard(ruleName) && !registry.migrations().some(entry => entry.scope === 'rule' && entry.key === ruleName)) {
|
|
276
|
+
errors.push(`[${ruleName}] is a cataloged safeguard, not a configurable policy. Delete its config entry; fixed safety cannot be disabled.`);
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
291
279
|
// A name we KNOW is retired beats the generic unknown-rule message, because only the table
|
|
292
280
|
// knows WHERE the setting went — a rename carries its value over, and a bare "delete it"
|
|
293
281
|
// would throw that value away. It fires even when a rulesDir is set, because a custom rule
|
|
294
282
|
// must not reuse a retired name.
|
|
295
|
-
const retired = (0, retired_config_keys_1.retiredRuleFor)(ruleName);
|
|
283
|
+
const retired = (0, retired_config_keys_1.retiredRuleFor)(ruleName, registry);
|
|
296
284
|
if (retired) {
|
|
297
285
|
errors.push((0, retired_config_keys_1.retiredKeyError)(retired));
|
|
298
286
|
continue;
|
|
@@ -304,7 +292,7 @@ function validateWebpiecesConfig(rawRules, hasCustomRulesDir = false) {
|
|
|
304
292
|
errors.push(unknownRuleError(ruleName));
|
|
305
293
|
continue;
|
|
306
294
|
}
|
|
307
|
-
errors.push(...fieldErrors(ruleName, entry, schema));
|
|
295
|
+
errors.push(...fieldErrors(ruleName, entry, schema, registry));
|
|
308
296
|
// Required fields must actually be present. Until now the loop above only checked
|
|
309
297
|
// fields that WERE present, so an entry like `{}` (or one missing `mode` /
|
|
310
298
|
// `turnOffRuleUntilEpoch`) slipped through. Every non-optional schema field is mandatory.
|
|
@@ -317,9 +305,10 @@ function validateWebpiecesConfig(rawRules, hasCustomRulesDir = false) {
|
|
|
317
305
|
// Every built-in rule must be explicitly configured — no silent defaults.
|
|
318
306
|
// When a new rule is added to the framework, this check surfaces it immediately
|
|
319
307
|
// with a ready-to-copy snippet so AI can configure it in one pass.
|
|
320
|
-
for (const
|
|
308
|
+
for (const ruleName of registry.ruleIds()) {
|
|
309
|
+
const schema = registry.schemaFor(ruleName);
|
|
321
310
|
if (!(ruleName in rawRules)) {
|
|
322
|
-
errors.push(missingRuleSnippet(ruleName, schema));
|
|
311
|
+
errors.push(advice.missingRuleSnippet(ruleName, schema));
|
|
323
312
|
}
|
|
324
313
|
}
|
|
325
314
|
return errors;
|
|
@@ -556,8 +545,8 @@ function validateMatchRule(entry, index) {
|
|
|
556
545
|
}
|
|
557
546
|
if (typeof e['mainMessage'] !== 'string' || e['mainMessage'].trim() === '')
|
|
558
547
|
errors.push(`[match-rules] ${label}.mainMessage must be a non-empty string.`);
|
|
559
|
-
if (typeof e['mode'] !== 'string' || !
|
|
560
|
-
errors.push(`[match-rules] ${label}.mode must be one of: ${
|
|
548
|
+
if (typeof e['mode'] !== 'string' || !rules_sdk_1.MODIFIED_CODE_MODES.includes(e['mode']))
|
|
549
|
+
errors.push(`[match-rules] ${label}.mode must be one of: ${rules_sdk_1.MODIFIED_CODE_MODES.join(', ')}.`);
|
|
561
550
|
// Both escape hatches are REQUIRED on every match-rule too (same as keyed rules), so they are always
|
|
562
551
|
// visible. turnOffRuleUntilEpoch: number (0 = active; a future unix-epoch in seconds = temporarily
|
|
563
552
|
// off). turnOffRuleWhileOnBranch: string | null (null = always on; an EXACT branch name — matched
|
|
@@ -625,17 +614,17 @@ function validateMatchRulesSection(section) {
|
|
|
625
614
|
* validateWebpiecesConfig against the merged map.
|
|
626
615
|
*/
|
|
627
616
|
// webpieces-disable no-any-unknown -- section maps are opaque consumer JSON
|
|
628
|
-
function validateSectionPlacement(rulesSection, hookGuardsSection) {
|
|
617
|
+
function validateSectionPlacement(rulesSection, hookGuardsSection, registry) {
|
|
629
618
|
const errors = [];
|
|
630
619
|
for (const name of Object.keys(rulesSection)) {
|
|
631
|
-
if ((0, sections_1.isHookGuard)(name)) {
|
|
620
|
+
if ((0, sections_1.isHookGuard)(name, registry)) {
|
|
632
621
|
errors.push(`[${name}] is a hook guard and ${config_error_banner_1.SECTION_PLACEMENT_MARKER} "hookGuards" section, not "rules". ` +
|
|
633
622
|
`Move it.`);
|
|
634
623
|
}
|
|
635
624
|
}
|
|
636
625
|
for (const name of Object.keys(hookGuardsSection)) {
|
|
637
626
|
// Only flag KNOWN code rules misplaced into hookGuards; unknown names may be custom rules.
|
|
638
|
-
if (!(0, sections_1.isHookGuard)(name) &&
|
|
627
|
+
if (!(0, sections_1.isHookGuard)(name, registry) && registry.hasRule(name)) {
|
|
639
628
|
errors.push(`[${name}] is a code rule and ${config_error_banner_1.SECTION_PLACEMENT_MARKER} "rules" section, not "hookGuards". ` +
|
|
640
629
|
`Move it.`);
|
|
641
630
|
}
|