@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"match-rules-config.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/match-rules-config.ts"],"names":[],"mappings":";;;AA2GA,wDAGC;AAaD,4DAEC;AAQD,0DAqBC;AAOD,wDASC;AA1KD,i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tM,uBAAuB,EACvB,CAAC,EACD;QACI,0PAA0P;QAC1P,6HAA6H;QAC7H,6QAA6Q;KAChR,EACD,IAAI,EACJ,CAAC,8BAA8B,EAAE,4BAA4B,EAAE,4BAA4B,CAAC,CAC/F;CACJ,CAAC","sourcesContent":["import { BaseRuleConfig, ModifiedCodeMode } from './rule-configs';\nimport { WEBPIECES_DISABLE } from './constants';\n\n// ---------------------------------------------------------------------------\n// match-rules — a generic, client-configurable content-guard engine.\n//\n// Unlike the keyed `rules` (each a framework class with a fixed regex + message),\n// a match-rule is authored ENTIRELY in webpieces.config.json: a `name`, a list of\n// raw-regex `patterns` to flag, a `mainMessage` + `options[]` shown to the AI, and\n// per-entry scoping (`mode`, `allowedPaths`, `disableAllowed`, `turnOffRuleUntilEpoch`).\n// The framework ships ONE default example — the `no-fetch` guard (see DEFAULT_MATCH_RULES)\n// — and clients add more (no-moment, no-lodash-chain, …) without a framework release.\n//\n// Lives in a NEW top-level `match-rules` ARRAY section (shaped like `pr-gate`/`excludePaths`),\n// NOT a keyed entry under `rules`. Both engines (ai-hook-rules edit-time, code-rules build-time)\n// instantiate one guard per array entry and share the pure matching engine below.\n// ---------------------------------------------------------------------------\n\n/**\n * One entry of the `match-rules` array. Extends BaseRuleConfig so AbstractRule.shouldRun()\n * (OFF / epoch / branch escape hatches) works per entry. `name` doubles as the\n * `// webpieces-disable <name> -- <reason>` token and the report label.\n */\nexport class MatchRuleConfig extends BaseRuleConfig {\n declare mode?: ModifiedCodeMode;\n name: string;\n patterns: string[];\n mainMessage: string;\n options: string[];\n disableAllowed?: boolean;\n allowedPaths?: string[];\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n name: string,\n patterns: string[],\n mainMessage: string,\n mode: ModifiedCodeMode,\n turnOffRuleUntilEpoch: number,\n options: string[] = [],\n disableAllowed: boolean = true,\n allowedPaths: string[] = [],\n turnOffRuleWhileOnBranch: string | null = null,\n ) {\n super();\n this.name = name;\n this.patterns = patterns;\n this.mainMessage = mainMessage;\n this.mode = mode;\n this.turnOffRuleUntilEpoch = turnOffRuleUntilEpoch;\n this.turnOffRuleWhileOnBranch = turnOffRuleWhileOnBranch;\n this.options = options;\n this.disableAllowed = disableAllowed;\n this.allowedPaths = allowedPaths;\n }\n}\n\n/** One flagged line. Raw hit — callers apply their own disable filtering. */\nexport class MatchRuleViolation {\n readonly line: number;\n readonly context: string;\n readonly patternIndex: number;\n\n constructor(line: number, context: string, patternIndex: number) {\n this.line = line;\n this.context = context;\n this.patternIndex = patternIndex;\n }\n}\n\nconst TEST_PATHS: readonly RegExp[] = [/\\.test\\.ts$/, /\\.spec\\.ts$/, /__tests__\\//];\n\n// Glob → RegExp, matching the convention used by no-symbol-di-tokens (`**` spans path\n// separators, `*` stays within a segment). Kept local so rules-config owns no shared glob util.\nfunction globToRegex(pattern: string): RegExp {\n let re = '';\n let i = 0;\n while (i < pattern.length) {\n const ch = pattern[i];\n if (ch === '*') {\n if (pattern[i + 1] === '*') {\n re += '.*';\n i += 2;\n if (pattern[i] === '/') i += 1;\n continue;\n }\n re += '[^/]*';\n i += 1;\n continue;\n }\n if (ch === '?') {\n re += '[^/]';\n i += 1;\n continue;\n }\n if ('.+^$(){}|[]\\\\'.includes(ch)) {\n re += '\\\\' + ch;\n i += 1;\n continue;\n }\n re += ch;\n i += 1;\n }\n return new RegExp('^' + re + '$');\n}\n\n/** A file is exempt if it's a test file or matches one of the rule's allowedPaths globs. */\nexport function isMatchRuleAllowedPath(relativePath: string, allowedPaths: readonly string[]): boolean {\n if (TEST_PATHS.some((re: RegExp) => re.test(relativePath))) return true;\n return allowedPaths.some((pattern: string) => globToRegex(pattern).test(relativePath));\n}\n\nfunction stripLineComment(line: string): string {\n const idx = line.indexOf('//');\n if (idx === -1) return line;\n return line.substring(0, idx);\n}\n\n/**\n * Compile a match-rule's raw-regex patterns. Patterns are trusted here — validateMatchRulesSection\n * (run in loadAndValidate, before any engine consumes a match-rule) compile-checks every pattern and\n * rejects the config on the first bad one, so an invalid pattern can never reach this function.\n */\nexport function compileMatchRulePatterns(config: MatchRuleConfig): RegExp[] {\n return (config.patterns ?? []).map((pattern: string) => new RegExp(pattern));\n}\n\n/**\n * Pure matching engine shared by BOTH engines. Takes the ORIGINAL lines (each is stripped of its\n * `//` comment before matching, mirroring the code-rules validators), returns raw hits — NO disable\n * filtering (ai-hook applies its line-mapped isLineDisabled; code-rules applies hasDisable). Returns\n * [] for exempt paths (test files / allowedPaths). At most one violation per line (first pattern wins).\n */\nexport function findMatchRuleViolations(\n lines: readonly string[],\n relativePath: string,\n config: MatchRuleConfig,\n): MatchRuleViolation[] {\n if (isMatchRuleAllowedPath(relativePath, config.allowedPaths ?? [])) return [];\n\n const compiled = compileMatchRulePatterns(config);\n if (compiled.length === 0) return [];\n\n const violations: MatchRuleViolation[] = [];\n for (let i = 0; i < lines.length; i += 1) {\n const stripped = stripLineComment(lines[i] ?? '');\n for (let p = 0; p < compiled.length; p += 1) {\n if (compiled[p].test(stripped)) {\n violations.push(new MatchRuleViolation(i + 1, (lines[i] ?? '').trim(), p));\n break;\n }\n }\n }\n return violations;\n}\n\n/**\n * Render a match-rule's message as a single string for the code-rules console report. Mirrors the\n * ai-hook FixHint layout (mainMessage, \"Fix Option N:\", disable escape) so both engines read alike.\n * ai-hook builds a real FixHint instead (see MatchRule) to reuse report.ts numbering.\n */\nexport function renderMatchRuleMessage(config: MatchRuleConfig): string {\n const lines: string[] = [config.mainMessage];\n (config.options ?? []).forEach((opt: string, i: number) => {\n lines.push(` Fix Option ${String(i + 1)}: ${opt}`);\n });\n if (config.disableAllowed ?? true) {\n lines.push(` Escape (if truly needed): // ${WEBPIECES_DISABLE} ${config.name} -- <reason>`);\n }\n return lines.join('\\n');\n}\n\n// The ONE guard the framework seeds. Printed verbatim (as JSON) by validateMatchRulesSection when the\n// `match-rules` section is missing, and written into a fresh config by the installer. Clients edit it\n// and add more entries. `packages/http/http-client/**` MUST stay allowlisted — ClientFactory.ts is the\n// single sanctioned fetch (the generated proxy); the apis-external dirs host external-service impls.\nexport const DEFAULT_MATCH_RULES: readonly MatchRuleConfig[] = [\n new MatchRuleConfig(\n 'no-fetch',\n [\n '(?<![.\\\\w])fetch\\\\s*\\\\(',\n '\\\\baxios\\\\b',\n '\\\\bXMLHttpRequest\\\\b',\n '\\\\bnew\\\\s+Request\\\\s*\\\\(',\n \"from\\\\s+['\\\"](node-fetch|got|undici)['\\\"]\",\n ],\n 'Raw HTTP (fetch/axios/XMLHttpRequest/…) bypasses contract-first development — the client and server stop sharing the same API contract/types. Generate a type-safe client from the contract instead:',\n 'NEW_AND_MODIFIED_CODE',\n 0,\n [\n \"PREFERRED: generate a client from the API you want to call — import { ClientHttpFactory, ClientConfig } from '@webpieces/http-client-node'; const client = factory.createRpcClient(SomeApi, new ClientConfig('some-svc')); await client.someMethod(req);\",\n 'Reuse an existing API contract already defined in your repo (under libraries/apis/**) and generate its client the same way.',\n 'For a truly external service, create a NEW API contract (a decorated abstract class) AND a NEW implementation that calls fetch behind that contract, under an allowlisted dir (libraries/apis-external/**). The contract stays the shared surface; fetch is an impl detail.',\n ],\n true,\n ['packages/http/http-client/**', 'libraries/apis-external/**', 'libraries/apis/external/**'],\n ),\n];\n"]}
|
|
1
|
+
{"version":3,"file":"match-rules-config.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/match-rules-config.ts"],"names":[],"mappings":";;;AA4GA,wDAGC;AAaD,4DAEC;AAQD,0DAqBC;AAOD,wDASC;AA3KD,oDAAsD;AAEtD,2CAAgD;AAEhD,8EAA8E;AAC9E,qEAAqE;AACrE,EAAE;AACF,kFAAkF;AAClF,kFAAkF;AAClF,mFAAmF;AACnF,yFAAyF;AACzF,2FAA2F;AAC3F,sFAAsF;AACtF,EAAE;AACF,+FAA+F;AAC/F,iGAAiG;AACjG,kFAAkF;AAClF,8EAA8E;AAE9E;;;;GAIG;AACH,MAAa,eAAgB,SAAQ,0BAAc;IAE/C,IAAI,CAAS;IACb,QAAQ,CAAW;IACnB,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AI,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;gBAC3E,MAAM;YACV,CAAC;QACL,CAAC;IACL,CAAC;IACD,OAAO,UAAU,CAAC;AACtB,CAAC;AAED;;;;GAIG;AACH,SAAgB,sBAAsB,CAAC,MAAuB;IAC1D,MAAM,KAAK,GAAa,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC7C,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,GAAW,EAAE,CAAS,EAAE,EAAE;QACtD,KAAK,CAAC,IAAI,CAAC,gBAAgB,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;IACH,IAAI,MAAM,CAAC,cAAc,IAAI,IAAI,EAAE,CAAC;QAChC,KAAK,CAAC,IAAI,CAAC,kCAAkC,6BAAiB,IAAI,MAAM,CAAC,IAAI,cAAc,CAAC,CAAC;IACjG,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC;AAED,sGAAsG;AACtG,sGAAsG;AACtG,uGAAuG;AACvG,qGAAqG;AACxF,QAAA,mBAAmB,GAA+B;IAC3D,IAAI,eAAe,CACf,UAAU,EACV;QACI,yBAAyB;QACzB,aAAa;QACb,sBAAsB;QACtB,0BAA0B;QAC1B,2CAA2C;KAC9C,EACD,sMAAsM,EACtM,uBAAuB,EACvB,CAAC,EACD;QACI,0PAA0P;QAC1P,6HAA6H;QAC7H,6QAA6Q;KAChR,EACD,IAAI,EACJ,CAAC,8BAA8B,EAAE,4BAA4B,EAAE,4BAA4B,CAAC,CAC/F;CACJ,CAAC","sourcesContent":["import { BaseRuleConfig } from '@webpieces/rules-sdk';\nimport { ModifiedCodeMode } from '@webpieces/rules-sdk';\nimport { WEBPIECES_DISABLE } from './constants';\n\n// ---------------------------------------------------------------------------\n// match-rules — a generic, client-configurable content-guard engine.\n//\n// Unlike the keyed `rules` (each a framework class with a fixed regex + message),\n// a match-rule is authored ENTIRELY in webpieces.config.json: a `name`, a list of\n// raw-regex `patterns` to flag, a `mainMessage` + `options[]` shown to the AI, and\n// per-entry scoping (`mode`, `allowedPaths`, `disableAllowed`, `turnOffRuleUntilEpoch`).\n// The framework ships ONE default example — the `no-fetch` guard (see DEFAULT_MATCH_RULES)\n// — and clients add more (no-moment, no-lodash-chain, …) without a framework release.\n//\n// Lives in a NEW top-level `match-rules` ARRAY section (shaped like `pr-gate`/`excludePaths`),\n// NOT a keyed entry under `rules`. Both engines (ai-hook-rules edit-time, code-rules build-time)\n// instantiate one guard per array entry and share the pure matching engine below.\n// ---------------------------------------------------------------------------\n\n/**\n * One entry of the `match-rules` array. Extends BaseRuleConfig so AbstractRule.shouldRun()\n * (OFF / epoch / branch escape hatches) works per entry. `name` doubles as the\n * `// webpieces-disable <name> -- <reason>` token and the report label.\n */\nexport class MatchRuleConfig extends BaseRuleConfig {\n declare mode?: ModifiedCodeMode;\n name: string;\n patterns: string[];\n mainMessage: string;\n options: string[];\n disableAllowed?: boolean;\n allowedPaths?: string[];\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n name: string,\n patterns: string[],\n mainMessage: string,\n mode: ModifiedCodeMode,\n turnOffRuleUntilEpoch: number,\n options: string[] = [],\n disableAllowed: boolean = true,\n allowedPaths: string[] = [],\n turnOffRuleWhileOnBranch: string | null = null,\n ) {\n super();\n this.name = name;\n this.patterns = patterns;\n this.mainMessage = mainMessage;\n this.mode = mode;\n this.turnOffRuleUntilEpoch = turnOffRuleUntilEpoch;\n this.turnOffRuleWhileOnBranch = turnOffRuleWhileOnBranch;\n this.options = options;\n this.disableAllowed = disableAllowed;\n this.allowedPaths = allowedPaths;\n }\n}\n\n/** One flagged line. Raw hit — callers apply their own disable filtering. */\nexport class MatchRuleViolation {\n readonly line: number;\n readonly context: string;\n readonly patternIndex: number;\n\n constructor(line: number, context: string, patternIndex: number) {\n this.line = line;\n this.context = context;\n this.patternIndex = patternIndex;\n }\n}\n\nconst TEST_PATHS: readonly RegExp[] = [/\\.test\\.ts$/, /\\.spec\\.ts$/, /__tests__\\//];\n\n// Glob → RegExp, matching the convention used by no-symbol-di-tokens (`**` spans path\n// separators, `*` stays within a segment). Kept local so rules-config owns no shared glob util.\nfunction globToRegex(pattern: string): RegExp {\n let re = '';\n let i = 0;\n while (i < pattern.length) {\n const ch = pattern[i];\n if (ch === '*') {\n if (pattern[i + 1] === '*') {\n re += '.*';\n i += 2;\n if (pattern[i] === '/') i += 1;\n continue;\n }\n re += '[^/]*';\n i += 1;\n continue;\n }\n if (ch === '?') {\n re += '[^/]';\n i += 1;\n continue;\n }\n if ('.+^$(){}|[]\\\\'.includes(ch)) {\n re += '\\\\' + ch;\n i += 1;\n continue;\n }\n re += ch;\n i += 1;\n }\n return new RegExp('^' + re + '$');\n}\n\n/** A file is exempt if it's a test file or matches one of the rule's allowedPaths globs. */\nexport function isMatchRuleAllowedPath(relativePath: string, allowedPaths: readonly string[]): boolean {\n if (TEST_PATHS.some((re: RegExp) => re.test(relativePath))) return true;\n return allowedPaths.some((pattern: string) => globToRegex(pattern).test(relativePath));\n}\n\nfunction stripLineComment(line: string): string {\n const idx = line.indexOf('//');\n if (idx === -1) return line;\n return line.substring(0, idx);\n}\n\n/**\n * Compile a match-rule's raw-regex patterns. Patterns are trusted here — validateMatchRulesSection\n * (run in loadAndValidate, before any engine consumes a match-rule) compile-checks every pattern and\n * rejects the config on the first bad one, so an invalid pattern can never reach this function.\n */\nexport function compileMatchRulePatterns(config: MatchRuleConfig): RegExp[] {\n return (config.patterns ?? []).map((pattern: string) => new RegExp(pattern));\n}\n\n/**\n * Pure matching engine shared by BOTH engines. Takes the ORIGINAL lines (each is stripped of its\n * `//` comment before matching, mirroring the code-rules validators), returns raw hits — NO disable\n * filtering (ai-hook applies its line-mapped isLineDisabled; code-rules applies hasDisable). Returns\n * [] for exempt paths (test files / allowedPaths). At most one violation per line (first pattern wins).\n */\nexport function findMatchRuleViolations(\n lines: readonly string[],\n relativePath: string,\n config: MatchRuleConfig,\n): MatchRuleViolation[] {\n if (isMatchRuleAllowedPath(relativePath, config.allowedPaths ?? [])) return [];\n\n const compiled = compileMatchRulePatterns(config);\n if (compiled.length === 0) return [];\n\n const violations: MatchRuleViolation[] = [];\n for (let i = 0; i < lines.length; i += 1) {\n const stripped = stripLineComment(lines[i] ?? '');\n for (let p = 0; p < compiled.length; p += 1) {\n if (compiled[p].test(stripped)) {\n violations.push(new MatchRuleViolation(i + 1, (lines[i] ?? '').trim(), p));\n break;\n }\n }\n }\n return violations;\n}\n\n/**\n * Render a match-rule's message as a single string for the code-rules console report. Mirrors the\n * ai-hook FixHint layout (mainMessage, \"Fix Option N:\", disable escape) so both engines read alike.\n * ai-hook builds a real FixHint instead (see MatchRule) to reuse report.ts numbering.\n */\nexport function renderMatchRuleMessage(config: MatchRuleConfig): string {\n const lines: string[] = [config.mainMessage];\n (config.options ?? []).forEach((opt: string, i: number) => {\n lines.push(` Fix Option ${String(i + 1)}: ${opt}`);\n });\n if (config.disableAllowed ?? true) {\n lines.push(` Escape (if truly needed): // ${WEBPIECES_DISABLE} ${config.name} -- <reason>`);\n }\n return lines.join('\\n');\n}\n\n// The ONE guard the framework seeds. Printed verbatim (as JSON) by validateMatchRulesSection when the\n// `match-rules` section is missing, and written into a fresh config by the installer. Clients edit it\n// and add more entries. `packages/http/http-client/**` MUST stay allowlisted — ClientFactory.ts is the\n// single sanctioned fetch (the generated proxy); the apis-external dirs host external-service impls.\nexport const DEFAULT_MATCH_RULES: readonly MatchRuleConfig[] = [\n new MatchRuleConfig(\n 'no-fetch',\n [\n '(?<![.\\\\w])fetch\\\\s*\\\\(',\n '\\\\baxios\\\\b',\n '\\\\bXMLHttpRequest\\\\b',\n '\\\\bnew\\\\s+Request\\\\s*\\\\(',\n \"from\\\\s+['\\\"](node-fetch|got|undici)['\\\"]\",\n ],\n 'Raw HTTP (fetch/axios/XMLHttpRequest/…) bypasses contract-first development — the client and server stop sharing the same API contract/types. Generate a type-safe client from the contract instead:',\n 'NEW_AND_MODIFIED_CODE',\n 0,\n [\n \"PREFERRED: generate a client from the API you want to call — import { ClientHttpFactory, ClientConfig } from '@webpieces/http-client-node'; const client = factory.createRpcClient(SomeApi, new ClientConfig('some-svc')); await client.someMethod(req);\",\n 'Reuse an existing API contract already defined in your repo (under libraries/apis/**) and generate its client the same way.',\n 'For a truly external service, create a NEW API contract (a decorated abstract class) AND a NEW implementation that calls fetch behind that contract, under an allowlisted dir (libraries/apis-external/**). The contract stays the shared surface; fetch is an impl detail.',\n ],\n true,\n ['packages/http/http-client/**', 'libraries/apis-external/**', 'libraries/apis/external/**'],\n ),\n];\n"]}
|
|
@@ -1,32 +1,16 @@
|
|
|
1
|
-
import { NoCustomCssConfig } from './rule-configs';
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* ## Why it lives in rules-config rather than in either engine
|
|
8
|
-
*
|
|
9
|
-
* `allowGlobs` is declared on {@link NoCustomCssConfig} and injected into BOTH engines. It used to be
|
|
10
|
-
* honoured by the hook alone: the CI validator never read the field, so a consumer who exempted
|
|
11
|
-
* `**\/design.html` watched the editor go quiet and CI keep failing on the very files it had exempted,
|
|
12
|
-
* with no diagnostic anywhere. The cure is not "read the field in the validator too" — that is a second
|
|
13
|
-
* implementation of one predicate, which is exactly the shape that produced the divergence. It is ONE
|
|
14
|
-
* class, in the one package both engines already depend on for the schema.
|
|
15
|
-
*
|
|
16
|
-
* ## Constructed from the config, never from a loose list
|
|
17
|
-
*
|
|
18
|
-
* The constructor takes the whole {@link NoCustomCssConfig}, so a scope cannot be built that has quietly
|
|
19
|
-
* dropped `allowGlobs` on the way in. TypeScript still cannot force a call site to CONSULT the scope —
|
|
20
|
-
* that is the gap the two remaining engines close by having exactly one place each where the file set is
|
|
21
|
-
* narrowed.
|
|
22
|
-
*
|
|
23
|
-
* Glob semantics are `matchesAnyGlob`: minimatch against the workspace-relative path, plus the
|
|
24
|
-
* directory-prefix form (`libraries/vendor` also exempts `libraries/vendor/**`). An empty `allowGlobs`
|
|
25
|
-
* matches nothing, so an unconfigured rule is enforced everywhere except the test paths above.
|
|
2
|
+
* Shared path exemption used by both edit-time and build-time CSS enforcement.
|
|
3
|
+
* The owning pack validates its schema; this helper consumes the resolved path
|
|
4
|
+
* settings without importing either implementation pack or its concrete config class.
|
|
5
|
+
* Both consumers use the same matcher so configured exemptions cannot drift.
|
|
26
6
|
*/
|
|
7
|
+
/** A structural path-exemption input, independent of any concrete owner schema. */
|
|
8
|
+
export declare class PathScopeConfig {
|
|
9
|
+
allowGlobs?: string[];
|
|
10
|
+
}
|
|
27
11
|
export declare class NoCustomCssScope {
|
|
28
12
|
private readonly allowGlobs;
|
|
29
|
-
constructor(config:
|
|
13
|
+
constructor(config: PathScopeConfig);
|
|
30
14
|
/** True when `no-custom-css` must not look at this path at all — a test source, or a configured `allowGlobs` match. */
|
|
31
15
|
isExempt(relPath: string): boolean;
|
|
32
16
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NoCustomCssScope = void 0;
|
|
3
|
+
exports.NoCustomCssScope = exports.PathScopeConfig = void 0;
|
|
4
4
|
const exclude_paths_1 = require("./exclude-paths");
|
|
5
5
|
/**
|
|
6
6
|
* Test sources are never Angular UI, so no engine has ever enforced `no-custom-css` on them. The list
|
|
@@ -9,30 +9,16 @@ const exclude_paths_1 = require("./exclude-paths");
|
|
|
9
9
|
*/
|
|
10
10
|
const TEST_PATHS = [/\.test\.ts$/, /\.spec\.ts$/, /__tests__\//];
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* ## Why it lives in rules-config rather than in either engine
|
|
17
|
-
*
|
|
18
|
-
* `allowGlobs` is declared on {@link NoCustomCssConfig} and injected into BOTH engines. It used to be
|
|
19
|
-
* honoured by the hook alone: the CI validator never read the field, so a consumer who exempted
|
|
20
|
-
* `**\/design.html` watched the editor go quiet and CI keep failing on the very files it had exempted,
|
|
21
|
-
* with no diagnostic anywhere. The cure is not "read the field in the validator too" — that is a second
|
|
22
|
-
* implementation of one predicate, which is exactly the shape that produced the divergence. It is ONE
|
|
23
|
-
* class, in the one package both engines already depend on for the schema.
|
|
24
|
-
*
|
|
25
|
-
* ## Constructed from the config, never from a loose list
|
|
26
|
-
*
|
|
27
|
-
* The constructor takes the whole {@link NoCustomCssConfig}, so a scope cannot be built that has quietly
|
|
28
|
-
* dropped `allowGlobs` on the way in. TypeScript still cannot force a call site to CONSULT the scope —
|
|
29
|
-
* that is the gap the two remaining engines close by having exactly one place each where the file set is
|
|
30
|
-
* narrowed.
|
|
31
|
-
*
|
|
32
|
-
* Glob semantics are `matchesAnyGlob`: minimatch against the workspace-relative path, plus the
|
|
33
|
-
* directory-prefix form (`libraries/vendor` also exempts `libraries/vendor/**`). An empty `allowGlobs`
|
|
34
|
-
* matches nothing, so an unconfigured rule is enforced everywhere except the test paths above.
|
|
12
|
+
* Shared path exemption used by both edit-time and build-time CSS enforcement.
|
|
13
|
+
* The owning pack validates its schema; this helper consumes the resolved path
|
|
14
|
+
* settings without importing either implementation pack or its concrete config class.
|
|
15
|
+
* Both consumers use the same matcher so configured exemptions cannot drift.
|
|
35
16
|
*/
|
|
17
|
+
/** A structural path-exemption input, independent of any concrete owner schema. */
|
|
18
|
+
class PathScopeConfig {
|
|
19
|
+
allowGlobs;
|
|
20
|
+
}
|
|
21
|
+
exports.PathScopeConfig = PathScopeConfig;
|
|
36
22
|
class NoCustomCssScope {
|
|
37
23
|
allowGlobs;
|
|
38
24
|
constructor(config) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-custom-css-scope.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/no-custom-css-scope.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"no-custom-css-scope.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/no-custom-css-scope.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAEjD;;;;GAIG;AACH,MAAM,UAAU,GAAsB,CAAC,aAAa,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC;AAEpF;;;;;GAKG;AACH,mFAAmF;AACnF,MAAa,eAAe;IACxB,UAAU,CAAY;CACzB;AAFD,0CAEC;AAED,MAAa,gBAAgB;IACR,UAAU,CAAoB;IAE/C,YAAY,MAAuB;QAC/B,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC;IAC9C,CAAC;IAED,uHAAuH;IACvH,QAAQ,CAAC,OAAe;QACpB,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACzC,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,EAAU,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAAE,OAAO,IAAI,CAAC;QAChE,OAAO,IAAA,8BAAc,EAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IACjD,CAAC;CACJ;AAbD,4CAaC","sourcesContent":["import { matchesAnyGlob } from './exclude-paths';\n\n/**\n * Test sources are never Angular UI, so no engine has ever enforced `no-custom-css` on them. The list\n * lived TWICE — once in the hook rule, once in the CI validator — which is the same duplication that\n * let `allowGlobs` diverge. One copy, here, beside the exemption it belongs to.\n */\nconst TEST_PATHS: readonly RegExp[] = [/\\.test\\.ts$/, /\\.spec\\.ts$/, /__tests__\\//];\n\n/**\n * Shared path exemption used by both edit-time and build-time CSS enforcement.\n * The owning pack validates its schema; this helper consumes the resolved path\n * settings without importing either implementation pack or its concrete config class.\n * Both consumers use the same matcher so configured exemptions cannot drift.\n */\n/** A structural path-exemption input, independent of any concrete owner schema. */\nexport class PathScopeConfig {\n allowGlobs?: string[];\n}\n\nexport class NoCustomCssScope {\n private readonly allowGlobs: readonly string[];\n\n constructor(config: PathScopeConfig) {\n this.allowGlobs = config.allowGlobs ?? [];\n }\n\n /** True when `no-custom-css` must not look at this path at all — a test source, or a configured `allowGlobs` match. */\n isExempt(relPath: string): boolean {\n const norm = relPath.replace(/\\\\/g, '/');\n if (TEST_PATHS.some((re: RegExp) => re.test(norm))) return true;\n return matchesAnyGlob(norm, this.allowGlobs);\n }\n}\n"]}
|
|
@@ -1,68 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* ## THE POLICY: webpieces.config.json is never released backwards-compatible
|
|
5
|
-
*
|
|
6
|
-
* When a config key moves, is renamed, or is deleted, the loader REJECTS the old shape with an error that
|
|
7
|
-
* names the destination. It does NOT quietly accept both. There is no fallback, no alias table applied
|
|
8
|
-
* before validation, no "still accepted for back-compat until every consumer migrates".
|
|
9
|
-
*
|
|
10
|
-
* This is safe *here* in a way it is not for a normal library, and the reason is the consumer: every reader
|
|
11
|
-
* of this file is a coding agent. The config is validated on startup, the agent is handed the exact edit,
|
|
12
|
-
* and it applies it in one pass — so the upgrade is seamless without shipping a compatibility layer. That
|
|
13
|
-
* makes a hard failure strictly cheaper than duality: two accepted shapes means two code paths, two sets of
|
|
14
|
-
* defaults and two sets of error messages to keep honest forever, and the stale shape then lives in
|
|
15
|
-
* consumer configs indefinitely because nothing ever forces the edit.
|
|
16
|
-
*
|
|
17
|
-
* A hard rejection here is always self-recoverable, which is what makes it safe to do:
|
|
18
|
-
* - editing webpieces.config.json is ALWAYS permitted, even while the config is invalid (see the banner
|
|
19
|
-
* in config-file.ts and the guard matrix — a Write/Edit targeting this file is an unconditional PASS),
|
|
20
|
-
* - and `PRUNE_UNKNOWN_COMMAND` is an L0 CURE, so the mechanical cleanup of keys no validator knows runs
|
|
21
|
-
* from inside the block too.
|
|
22
|
-
* So rejecting an old shape can never wedge a repo. "It would deadlock the consumer" is not a reason to add
|
|
23
|
-
* a fallback; it is not true.
|
|
24
|
-
*
|
|
25
|
-
* NOT `pnpm install`. This paragraph used to offer it as the escape hatch that "fixes the far more common
|
|
26
|
-
* cause of a validation failure: an installed validator lagging the config by a release". It is permitted
|
|
27
|
-
* (installer bypass), but it is not the cure for anything you can read here: the shim's version-drift guard
|
|
28
|
-
* compares the pin against the installed version and denies every tool call BEFORE the validator runs, so a
|
|
29
|
-
* validation error on screen is proof that package.json and node_modules already agree. The banner from this
|
|
30
|
-
* same package now says "Do NOT run `pnpm install` — it cannot help", and a docstring teaching the opposite
|
|
31
|
-
* is how that advice leaked back out.
|
|
32
|
-
*
|
|
33
|
-
* ## Adding an entry
|
|
34
|
-
*
|
|
35
|
-
* When you retire a key, add it here and DELETE its read path — do not leave a `??` fallback behind. The
|
|
36
|
-
* `instruction` is the whole product: it is read by an agent that will act on it verbatim, so give the
|
|
37
|
-
* mechanical edit ("rename X to Y", "move A into B"), not a description of the change. Saying where a thing
|
|
38
|
-
* moved to is exactly the point of this table; it is what makes the fallback unnecessary.
|
|
39
|
-
*
|
|
40
|
-
* retired-config-keys.spec.ts asserts every entry below actually FAILS the load. That spec is the guard: a
|
|
41
|
-
* future fallback that silently swallows a retired key turns it red.
|
|
42
|
-
*/
|
|
1
|
+
import { RulePackRegistry } from './rule-pack-registry';
|
|
2
|
+
import { RetiredConfigKey } from '@webpieces/rules-sdk';
|
|
43
3
|
export declare const RETIRED_SCOPE_RULE = "rule";
|
|
44
4
|
export declare const RETIRED_SCOPE_KEY = "key";
|
|
45
|
-
/** One retired config key and the mechanical edit that replaces it. Data-only (per CLAUDE.md). */
|
|
46
|
-
export declare class RetiredConfigKey {
|
|
47
|
-
scope: string;
|
|
48
|
-
key: string;
|
|
49
|
-
movedTo: string;
|
|
50
|
-
instruction: string;
|
|
51
|
-
label: string;
|
|
52
|
-
/**
|
|
53
|
-
* True when DELETING the key from webpieces.config.json is the entire edit — nothing in THIS file
|
|
54
|
-
* replaces it, so `PRUNE_UNKNOWN_COMMAND` may strip it mechanically. `whole-repo-build-guard` is the
|
|
55
|
-
* worked example: its switch moved OUT of the repo config into `~/.webpieces/config.json`, so the
|
|
56
|
-
* value has nowhere to go here.
|
|
57
|
-
*
|
|
58
|
-
* False for a rename or an in-file move: deleting those would DISCARD a value the reader still needs,
|
|
59
|
-
* so they keep their migration instruction and the pruner leaves them alone. Required, not defaulted —
|
|
60
|
-
* a defaulted `false` would let a future deletion-only retirement silently opt out of the mechanical
|
|
61
|
-
* cure and land back in "the reader decides while every Bash call is blocked".
|
|
62
|
-
*/
|
|
63
|
-
prunable: boolean;
|
|
64
|
-
constructor(scope: string, key: string, movedTo: string, instruction: string, label: string, prunable: boolean);
|
|
65
|
-
}
|
|
66
5
|
/**
|
|
67
6
|
* Every retired key. Keep the newest at the bottom with the release that retired it, so the list reads as a
|
|
68
7
|
* changelog an agent can walk when a config is several versions behind.
|
|
@@ -82,7 +21,7 @@ export declare function retiredKeyError(entry: RetiredConfigKey): string;
|
|
|
82
21
|
* setting went — a rename that must carry its value over, or a move to `~/.webpieces/config.json`. The
|
|
83
22
|
* destination is the whole product, and a bare "delete it" would throw it away.
|
|
84
23
|
*/
|
|
85
|
-
export declare function retiredRuleFor(ruleName: string): RetiredConfigKey | null;
|
|
24
|
+
export declare function retiredRuleFor(ruleName: string, registry: RulePackRegistry): RetiredConfigKey | null;
|
|
86
25
|
/**
|
|
87
26
|
* Whether `key` is retired within `label`'s section. Unknown-key rejection consults this so a retired key
|
|
88
27
|
* gets its migration message instead of a generic "unknown key, delete it" — the migration instruction is
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RETIRED_CONFIG_KEYS = exports.RETIRED_SCOPE_KEY = exports.RETIRED_SCOPE_RULE = void 0;
|
|
4
|
+
exports.retiredKeyError = retiredKeyError;
|
|
5
|
+
exports.retiredRuleFor = retiredRuleFor;
|
|
6
|
+
exports.isRetiredKey = isRetiredKey;
|
|
7
|
+
exports.retiredEntry = retiredEntry;
|
|
8
|
+
exports.retiredKeyErrorsIn = retiredKeyErrorsIn;
|
|
9
|
+
const rules_sdk_1 = require("@webpieces/rules-sdk");
|
|
2
10
|
/**
|
|
3
11
|
* Retired webpieces.config.json keys — the ONE place in the codebase where a dead config key may be named.
|
|
4
12
|
*
|
|
@@ -41,13 +49,6 @@
|
|
|
41
49
|
* retired-config-keys.spec.ts asserts every entry below actually FAILS the load. That spec is the guard: a
|
|
42
50
|
* future fallback that silently swallows a retired key turns it red.
|
|
43
51
|
*/
|
|
44
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.RETIRED_CONFIG_KEYS = exports.RetiredConfigKey = exports.RETIRED_SCOPE_KEY = exports.RETIRED_SCOPE_RULE = void 0;
|
|
46
|
-
exports.retiredKeyError = retiredKeyError;
|
|
47
|
-
exports.retiredRuleFor = retiredRuleFor;
|
|
48
|
-
exports.isRetiredKey = isRetiredKey;
|
|
49
|
-
exports.retiredEntry = retiredEntry;
|
|
50
|
-
exports.retiredKeyErrorsIn = retiredKeyErrorsIn;
|
|
51
52
|
const config_error_banner_1 = require("./config-error-banner");
|
|
52
53
|
const constants_1 = require("./constants");
|
|
53
54
|
// A retired key is matched one of two ways, because config keys live at two very different levels.
|
|
@@ -56,155 +57,16 @@ const constants_1 = require("./constants");
|
|
|
56
57
|
// KEY — a plain key inside a known section, matched by name within that section.
|
|
57
58
|
exports.RETIRED_SCOPE_RULE = 'rule';
|
|
58
59
|
exports.RETIRED_SCOPE_KEY = 'key';
|
|
59
|
-
/** One retired config key and the mechanical edit that replaces it. Data-only (per CLAUDE.md). */
|
|
60
|
-
class RetiredConfigKey {
|
|
61
|
-
scope;
|
|
62
|
-
// The key exactly as it appears in webpieces.config.json.
|
|
63
|
-
key;
|
|
64
|
-
// Where the value goes now. Empty string when the key is deleted outright with no replacement.
|
|
65
|
-
movedTo;
|
|
66
|
-
// The imperative fix, written for the agent that will apply it.
|
|
67
|
-
instruction;
|
|
68
|
-
// Bracketed label leading the error, matching the `[rule-name]` / `[section]` convention in this package.
|
|
69
|
-
label;
|
|
70
|
-
/**
|
|
71
|
-
* True when DELETING the key from webpieces.config.json is the entire edit — nothing in THIS file
|
|
72
|
-
* replaces it, so `PRUNE_UNKNOWN_COMMAND` may strip it mechanically. `whole-repo-build-guard` is the
|
|
73
|
-
* worked example: its switch moved OUT of the repo config into `~/.webpieces/config.json`, so the
|
|
74
|
-
* value has nowhere to go here.
|
|
75
|
-
*
|
|
76
|
-
* False for a rename or an in-file move: deleting those would DISCARD a value the reader still needs,
|
|
77
|
-
* so they keep their migration instruction and the pruner leaves them alone. Required, not defaulted —
|
|
78
|
-
* a defaulted `false` would let a future deletion-only retirement silently opt out of the mechanical
|
|
79
|
-
* cure and land back in "the reader decides while every Bash call is blocked".
|
|
80
|
-
*/
|
|
81
|
-
prunable;
|
|
82
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
83
|
-
constructor(scope, key, movedTo, instruction, label, prunable) {
|
|
84
|
-
this.scope = scope;
|
|
85
|
-
this.key = key;
|
|
86
|
-
this.movedTo = movedTo;
|
|
87
|
-
this.instruction = instruction;
|
|
88
|
-
this.label = label;
|
|
89
|
-
this.prunable = prunable;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
exports.RetiredConfigKey = RetiredConfigKey;
|
|
93
60
|
/**
|
|
94
61
|
* Every retired key. Keep the newest at the bottom with the release that retired it, so the list reads as a
|
|
95
62
|
* changelog an agent can walk when a config is several versions behind.
|
|
96
63
|
*/
|
|
97
64
|
exports.RETIRED_CONFIG_KEYS = [
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
//
|
|
103
|
-
// These three RE-POINTED when hookGuards collapsed to one key per policy. Their old destinations
|
|
104
|
-
// (`pr-merge-guard`, `pr-creation-or-push-guard`, `read-stale-guard`) are themselves retired now,
|
|
105
|
-
// and a retirement whose `movedTo` names a dead key teaches the removed API — the same defect one
|
|
106
|
-
// level out. Each therefore names the POLICY key it lands on today, in one hop.
|
|
107
|
-
new RetiredConfigKey(exports.RETIRED_SCOPE_RULE, 'pr-merge-cleanup', 'pr-lifecycle-guard', 'Rename the key to "pr-lifecycle-guard" (merging its value into that entry if you already have ' +
|
|
108
|
-
'one — the four PR/merge guards share one key now). Its mode and escape hatches carry over.', '[pr-merge-cleanup]', false),
|
|
109
|
-
new RetiredConfigKey(exports.RETIRED_SCOPE_RULE, 'pr-creation-guard', 'pr-lifecycle-guard', 'Rename the key to "pr-lifecycle-guard" (merging its value into that entry if you already have ' +
|
|
110
|
-
'one — the four PR/merge guards share one key now). Its mode and escape hatches carry over; the ' +
|
|
111
|
-
'old "upsertPrCommand" field does NOT — that string lives only in commands.guardHints.prCreationOrPush.', '[pr-creation-guard]', false),
|
|
112
|
-
new RetiredConfigKey(exports.RETIRED_SCOPE_RULE, 'main-stale-guard', 'branch-state-guard', 'Rename the key to "branch-state-guard" (merging its value into that entry if you already have ' +
|
|
113
|
-
'one — the four branch-state guards share one key now). Its mode and escape hatches carry over. ' +
|
|
114
|
-
'Note the widened scope: that key arms the Write, Read AND Bash halves of the branch-state ' +
|
|
115
|
-
'policy, not just the Read block this key used to name.', '[main-stale-guard]', false),
|
|
116
|
-
// --- The two flat guard-hint strings, superseded by commands.guardHints so that every guard-facing
|
|
117
|
-
// command string sits in one named sub-object instead of loose beside the gate config.
|
|
118
|
-
new RetiredConfigKey(exports.RETIRED_SCOPE_KEY, 'upsertPr', 'commands.guardHints.prCreationOrPush', 'Move the value to "guardHints": { "prCreationOrPush": <value> } inside the same "commands" ' +
|
|
119
|
-
'section, then delete "upsertPr".', '[commands]', false),
|
|
120
|
-
new RetiredConfigKey(exports.RETIRED_SCOPE_KEY, 'mergeComplete', 'commands.guardHints.mergeInProgress', 'Move the value to "guardHints": { "mergeInProgress": <value> } inside the same "commands" ' +
|
|
121
|
-
'section, then delete "mergeComplete".', '[commands]', false),
|
|
122
|
-
// --- The two-list excludePaths object. The split never earned its keep (every consumer set both lists
|
|
123
|
-
// to the same value), and the one case that would need them to differ is served better by a rule's own
|
|
124
|
-
// `excludePaths`. Retired as a SHAPE: `rules` is the entry validateExcludePaths reports for either key.
|
|
125
|
-
new RetiredConfigKey(exports.RETIRED_SCOPE_KEY, 'rules', 'excludePaths (one flat array)', 'Replace the whole { "rules": [...], "guards": [...] } object with ONE array holding the union of ' +
|
|
126
|
-
'both lists, de-duplicated — e.g. "excludePaths": ["repositories/**"]. A path is governed by ' +
|
|
127
|
-
'webpieces or it is not, so there is no longer a per-engine split. To exclude a path from one rule ' +
|
|
128
|
-
'only, use that rule\'s own "excludePaths" inside its config block instead.', '[excludePaths]', false),
|
|
129
|
-
// --- whole-repo-build-guard, retired as a REPO-CONFIG key one release after it was added. It shipped
|
|
130
|
-
// as a conventional validated guard (mode ON by default, entry REQUIRED under hookGuards), so every
|
|
131
|
-
// consumer that upgraded hit fault Y — every Bash call blocked — for a feature nobody had opted into.
|
|
132
|
-
// The REQUIRED KEY was the fault, not the default: the failure was at config LOAD, before any command
|
|
133
|
-
// was judged. The switch now lives ONLY in the optional machine-local ~/.webpieces/config.json, where
|
|
134
|
-
// nothing has to be added to be in the default state — and the default is OFF, as every experimental
|
|
135
|
-
// flag's is, so deleting this entry loses nothing.
|
|
136
|
-
new RetiredConfigKey(exports.RETIRED_SCOPE_RULE, 'whole-repo-build-guard', '~/.webpieces/config.json → experimental.whole-repo-build-guard', 'DELETE this entry from webpieces.config.json — no repo config key controls this guard any more. ' +
|
|
137
|
-
'The guard is OFF by default for everyone, with no file and no key required. To turn it ON for ' +
|
|
138
|
-
'YOUR machine only, put {"experimental": {"whole-repo-build-guard": true}} in ' +
|
|
139
|
-
'~/.webpieces/config.json — that file is optional and is tracked by no repo.', '[whole-repo-build-guard]', true),
|
|
140
|
-
// --- THE 9 → 3 COLLAPSE of `hookGuards`: one key per POLICY, not one per implementation CLASS.
|
|
141
|
-
//
|
|
142
|
-
// Eight class-named keys become two policy keys. The CLASSES are untouched — `feature-branch-guard`
|
|
143
|
-
// is still the rule name in every decision-log line and every deny report — so nothing an operator
|
|
144
|
-
// greps for moved. What moved is the SWITCH, because nine keys let a consumer configure HALF a
|
|
145
|
-
// policy: `read-stale-guard: OFF` beside `merged-branch-bash-guard: ON` is "read the file, yes;
|
|
146
|
-
// `cat` the same file, no", which nobody chose and the config made reachable.
|
|
147
|
-
//
|
|
148
|
-
// EVERY ONE OF THESE IS `prunable: false`, and that is not bookkeeping. `PRUNABLE_SECTIONS` in
|
|
149
|
-
// ConfigPruner includes `hookGuards`, and the validation banner actively RECOMMENDS running the
|
|
150
|
-
// pruner. A `prunable: true` here would mean the recommended cure silently DELETES four configured
|
|
151
|
-
// guards with no destination named — a config loss, which is worse than a block. False keeps the
|
|
152
|
-
// migration instruction and makes the pruner return null for these keys.
|
|
153
|
-
//
|
|
154
|
-
// 4 → 1 is legal for this table (nothing requires `movedTo` to be unique), but it is NOT legal for
|
|
155
|
-
// a naive 1:1 migrator: see migrateRetiredRuleNames in ai-hook-rules' setup.ts, which unions the
|
|
156
|
-
// four old entries into the destination and then fills any missing required field, rather than
|
|
157
|
-
// renaming the first and deleting the rest.
|
|
158
|
-
...branchStateRetirements(),
|
|
159
|
-
...prLifecycleRetirements(),
|
|
160
|
-
// --- The per-checklist reviewer agent (issue #938). A checklist used to name its own agent type in
|
|
161
|
-
// `subagent`, which also served as its id; every checklist is now reviewed by the ONE agent type that
|
|
162
|
-
// webpieces-reviewer (or an overrideReviewerAgent name) is, so the key that is left is only the checklist's NAME.
|
|
163
|
-
// A rename, so `prunable: false` — deleting it would discard the id every verdict file is keyed by.
|
|
164
|
-
new RetiredConfigKey(exports.RETIRED_SCOPE_KEY, 'subagent', 'id', 'Rename "subagent" to "id" in EVERY commands.pr-gate.checklists entry, keeping its value (it still ' +
|
|
165
|
-
'names the checklist and keys review-round<N>-<id>.json). Checklists no longer choose an agent type: every one ' +
|
|
166
|
-
'is reviewed by the webpieces-reviewer agent (or your own, via "overrideReviewerAgent": true + ' +
|
|
167
|
-
'"reviewerAgentName" in commands.pr-gate).', '[pr-gate.checklists]', false),
|
|
65
|
+
new rules_sdk_1.RetiredConfigKey("key", "upsertPr", "commands.guardHints.prCreationOrPush", "Move the value to \"guardHints\": { \"prCreationOrPush\": <value> } inside the same \"commands\" section, then delete \"upsertPr\".", "[commands]", false),
|
|
66
|
+
new rules_sdk_1.RetiredConfigKey("key", "mergeComplete", "commands.guardHints.mergeInProgress", "Move the value to \"guardHints\": { \"mergeInProgress\": <value> } inside the same \"commands\" section, then delete \"mergeComplete\".", "[commands]", false),
|
|
67
|
+
new rules_sdk_1.RetiredConfigKey("key", "rules", "excludePaths (one flat array)", "Replace the whole { \"rules\": [...], \"guards\": [...] } object with ONE array holding the union of both lists, de-duplicated — e.g. \"excludePaths\": [\"repositories/**\"]. A path is governed by webpieces or it is not, so there is no longer a per-engine split. To exclude a path from one rule only, use that rule's own \"excludePaths\" inside its config block instead.", "[excludePaths]", false),
|
|
68
|
+
new rules_sdk_1.RetiredConfigKey("key", "subagent", "id", "Rename \"subagent\" to \"id\" in EVERY commands.pr-gate.checklists entry, keeping its value (it still names the checklist and keys review-round<N>-<id>.json). Checklists no longer choose an agent type: every one is reviewed by the webpieces-reviewer agent (or your own, via \"overrideReviewerAgent\": true + \"reviewerAgentName\" in commands.pr-gate).", "[pr-gate.checklists]", false),
|
|
168
69
|
];
|
|
169
|
-
// The four branch-state classes. Split into a helper purely to keep the table above readable; the
|
|
170
|
-
// instruction is per-key because the fields that carry over differ (only feature-branch-guard had
|
|
171
|
-
// `branchNamingConvention`).
|
|
172
|
-
// webpieces-disable no-function-outside-class -- table data for RETIRED_CONFIG_KEYS, beside the array it feeds
|
|
173
|
-
function branchStateRetirements() {
|
|
174
|
-
const merged = 'MERGE it into ONE "branch-state-guard" entry under "hookGuards"';
|
|
175
|
-
const shared = `${merged}. All four of feature-branch-guard, read-stale-guard, stale-main-bash-guard and ` +
|
|
176
|
-
'merged-branch-bash-guard now read that single entry — they are one policy ("may I work here, ' +
|
|
177
|
-
'and is what I read current?") implemented by four classes, and configuring them separately let ' +
|
|
178
|
-
'you switch on half of it. Keep "mode", "turnOffRuleUntilEpoch" and "turnOffRuleWhileOnBranch"; ' +
|
|
179
|
-
'the ONE "hangTimeoutMinutes" survives (there was only ever one refresher and one cache, so at ' +
|
|
180
|
-
'most one of the four values could ever take effect); "branchNamingConvention" survives from ' +
|
|
181
|
-
'feature-branch-guard. If the four disagreed on "mode", pick the one you meant — "ON" arms the ' +
|
|
182
|
-
'whole policy including the Read block. Then DELETE this key.';
|
|
183
|
-
return [
|
|
184
|
-
new RetiredConfigKey(exports.RETIRED_SCOPE_RULE, 'feature-branch-guard', 'branch-state-guard', shared, '[feature-branch-guard]', false),
|
|
185
|
-
new RetiredConfigKey(exports.RETIRED_SCOPE_RULE, 'read-stale-guard', 'branch-state-guard', shared, '[read-stale-guard]', false),
|
|
186
|
-
new RetiredConfigKey(exports.RETIRED_SCOPE_RULE, 'stale-main-bash-guard', 'branch-state-guard', shared, '[stale-main-bash-guard]', false),
|
|
187
|
-
new RetiredConfigKey(exports.RETIRED_SCOPE_RULE, 'merged-branch-bash-guard', 'branch-state-guard', shared, '[merged-branch-bash-guard]', false),
|
|
188
|
-
];
|
|
189
|
-
}
|
|
190
|
-
// The four PR-lifecycle classes.
|
|
191
|
-
// webpieces-disable no-function-outside-class -- table data for RETIRED_CONFIG_KEYS, beside the array it feeds
|
|
192
|
-
function prLifecycleRetirements() {
|
|
193
|
-
const shared = 'MERGE it into ONE "pr-lifecycle-guard" entry under "hookGuards". All four of ' +
|
|
194
|
-
'pr-creation-or-push-guard, merge-in-progress-guard, pr-merge-guard and ' +
|
|
195
|
-
'redirect-how-to-merge-main now read that single entry — they are one policy ("do PRs and ' +
|
|
196
|
-
'merges go through the gated flow?"). Keep "mode", "turnOffRuleUntilEpoch" and ' +
|
|
197
|
-
'"turnOffRuleWhileOnBranch". Know what "mode": "OFF" now means: it releases the ' +
|
|
198
|
-
'unvalidated-merge gate as well as the PR/push blocks, because merge-in-progress-guard is under ' +
|
|
199
|
-
'this key too. The per-guard "upsertPrCommand" / "mergeCompleteCommand" fields are gone — those ' +
|
|
200
|
-
'strings live ONLY in commands.guardHints.prCreationOrPush / .mergeInProgress. Then DELETE this key.';
|
|
201
|
-
return [
|
|
202
|
-
new RetiredConfigKey(exports.RETIRED_SCOPE_RULE, 'pr-creation-or-push-guard', 'pr-lifecycle-guard', shared, '[pr-creation-or-push-guard]', false),
|
|
203
|
-
new RetiredConfigKey(exports.RETIRED_SCOPE_RULE, 'merge-in-progress-guard', 'pr-lifecycle-guard', shared, '[merge-in-progress-guard]', false),
|
|
204
|
-
new RetiredConfigKey(exports.RETIRED_SCOPE_RULE, 'pr-merge-guard', 'pr-lifecycle-guard', shared, '[pr-merge-guard]', false),
|
|
205
|
-
new RetiredConfigKey(exports.RETIRED_SCOPE_RULE, 'redirect-how-to-merge-main', 'pr-lifecycle-guard', shared, '[redirect-how-to-merge-main]', false),
|
|
206
|
-
];
|
|
207
|
-
}
|
|
208
70
|
/**
|
|
209
71
|
* The shared message. Leads with the retirement, then the destination, then the edit — an agent reading this
|
|
210
72
|
* should not have to infer anything.
|
|
@@ -231,8 +93,8 @@ function retiredKeyError(entry) {
|
|
|
231
93
|
* destination is the whole product, and a bare "delete it" would throw it away.
|
|
232
94
|
*/
|
|
233
95
|
// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this package
|
|
234
|
-
function retiredRuleFor(ruleName) {
|
|
235
|
-
return
|
|
96
|
+
function retiredRuleFor(ruleName, registry) {
|
|
97
|
+
return registry.migrations().find(e => e.scope === exports.RETIRED_SCOPE_RULE && e.key === ruleName) ?? null;
|
|
236
98
|
}
|
|
237
99
|
/**
|
|
238
100
|
* Whether `key` is retired within `label`'s section. Unknown-key rejection consults this so a retired key
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retired-config-keys.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/retired-config-keys.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;;;AAoNH,0CAUC;AASD,wCAEC;AAQD,oCAEC;AAQD,oCAEC;AAKD,gDAIC;AApQD,+DAA2D;AAC3D,2CAAoD;AAEpD,mGAAmG;AACnG,yGAAyG;AACzG,2CAA2C;AAC3C,kFAAkF;AACrE,QAAA,kBAAkB,GAAG,MAAM,CAAC;AAC5B,QAAA,iBAAiB,GAAG,KAAK,CAAC;AAEvC,kGAAkG;AAClG,MAAa,gBAAgB;IACzB,KAAK,CAAS;IACd,0DAA0D;IAC1D,GAAG,CAAS;IACZ,+FAA+F;IAC/F,OAAO,CAAS;IAChB,gEAAgE;IAChE,WAAW,CAAS;IACpB,0GAA0G;IAC1G,KAAK,CAAS;IACd;;;;;;;;;;OAUG;IACH,QAAQ,CAAU;IAElB,yDAAyD;IACzD,YAAY,KAAa,EAAE,GAAW,EAAE,OAAe,EAAE,WAAmB,EAAE,KAAa,EAAE,QAAiB;QAC1G,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,CAAC;CACJ;AAhCD,4CAgCC;AAED;;;GAGG;AACU,QAAA,mBAAmB,GAAgC;IAC5D,uGAAuG;IACvG,wGAAwG;IACxG,sGAAsG;IACtG,uDAAuD;IACvD,EAAE;IACF,iGAAiG;IACjG,kGAAkG;IAClG,kGAAkG;IAClG,gFAAgF;IAChF,IAAI,gBAAgB,CAChB,0BAAkB,EAAE,kBAAkB,EA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AAC,GAAG,KAAK,QAAQ,CAAC,IAAI,IAAI,CAAC;AACvG,CAAC;AAED;;;;GAIG;AACH,iHAAiH;AACjH,SAAgB,YAAY,CAAC,GAAW,EAAE,KAAa;IACnD,OAAO,2BAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,yBAAiB,IAAI,CAAC,CAAC,KAAK,KAAK,KAAK,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;AAC9G,CAAC;AAED;;;;GAIG;AACH,iHAAiH;AACjH,SAAgB,YAAY,CAAC,GAAW,EAAE,KAAa;IACnD,OAAO,2BAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,yBAAiB,IAAI,CAAC,CAAC,KAAK,KAAK,KAAK,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,IAAI,IAAI,CAAC;AACtH,CAAC;AAED,0GAA0G;AAC1G,mGAAmG;AACnG,iHAAiH;AACjH,SAAgB,kBAAkB,CAAC,OAAgC,EAAE,KAAa;IAC9E,OAAO,2BAAmB;SACrB,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,yBAAiB,IAAI,CAAC,CAAC,KAAK,KAAK,KAAK,IAAI,CAAC,CAAC,GAAG,IAAI,OAAO,CAAC;SACnF,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;AACtC,CAAC","sourcesContent":["/**\n * Retired webpieces.config.json keys — the ONE place in the codebase where a dead config key may be named.\n *\n * ## THE POLICY: webpieces.config.json is never released backwards-compatible\n *\n * When a config key moves, is renamed, or is deleted, the loader REJECTS the old shape with an error that\n * names the destination. It does NOT quietly accept both. There is no fallback, no alias table applied\n * before validation, no \"still accepted for back-compat until every consumer migrates\".\n *\n * This is safe *here* in a way it is not for a normal library, and the reason is the consumer: every reader\n * of this file is a coding agent. The config is validated on startup, the agent is handed the exact edit,\n * and it applies it in one pass — so the upgrade is seamless without shipping a compatibility layer. That\n * makes a hard failure strictly cheaper than duality: two accepted shapes means two code paths, two sets of\n * defaults and two sets of error messages to keep honest forever, and the stale shape then lives in\n * consumer configs indefinitely because nothing ever forces the edit.\n *\n * A hard rejection here is always self-recoverable, which is what makes it safe to do:\n * - editing webpieces.config.json is ALWAYS permitted, even while the config is invalid (see the banner\n * in config-file.ts and the guard matrix — a Write/Edit targeting this file is an unconditional PASS),\n * - and `PRUNE_UNKNOWN_COMMAND` is an L0 CURE, so the mechanical cleanup of keys no validator knows runs\n * from inside the block too.\n * So rejecting an old shape can never wedge a repo. \"It would deadlock the consumer\" is not a reason to add\n * a fallback; it is not true.\n *\n * NOT `pnpm install`. This paragraph used to offer it as the escape hatch that \"fixes the far more common\n * cause of a validation failure: an installed validator lagging the config by a release\". It is permitted\n * (installer bypass), but it is not the cure for anything you can read here: the shim's version-drift guard\n * compares the pin against the installed version and denies every tool call BEFORE the validator runs, so a\n * validation error on screen is proof that package.json and node_modules already agree. The banner from this\n * same package now says \"Do NOT run `pnpm install` — it cannot help\", and a docstring teaching the opposite\n * is how that advice leaked back out.\n *\n * ## Adding an entry\n *\n * When you retire a key, add it here and DELETE its read path — do not leave a `??` fallback behind. The\n * `instruction` is the whole product: it is read by an agent that will act on it verbatim, so give the\n * mechanical edit (\"rename X to Y\", \"move A into B\"), not a description of the change. Saying where a thing\n * moved to is exactly the point of this table; it is what makes the fallback unnecessary.\n *\n * retired-config-keys.spec.ts asserts every entry below actually FAILS the load. That spec is the guard: a\n * future fallback that silently swallows a retired key turns it red.\n */\n\nimport { RETIRED_KEY_MARKER } from './config-error-banner';\nimport { PRUNE_UNKNOWN_COMMAND } from './constants';\n\n// A retired key is matched one of two ways, because config keys live at two very different levels.\n// RULE — a rule/guard NAME, which may sit under either `rules` or `hookGuards`, so it is matched by bare\n// name rather than by a fixed path.\n// KEY — a plain key inside a known section, matched by name within that section.\nexport const RETIRED_SCOPE_RULE = 'rule';\nexport const RETIRED_SCOPE_KEY = 'key';\n\n/** One retired config key and the mechanical edit that replaces it. Data-only (per CLAUDE.md). */\nexport class RetiredConfigKey {\n scope: string;\n // The key exactly as it appears in webpieces.config.json.\n key: string;\n // Where the value goes now. Empty string when the key is deleted outright with no replacement.\n movedTo: string;\n // The imperative fix, written for the agent that will apply it.\n instruction: string;\n // Bracketed label leading the error, matching the `[rule-name]` / `[section]` convention in this package.\n label: string;\n /**\n * True when DELETING the key from webpieces.config.json is the entire edit — nothing in THIS file\n * replaces it, so `PRUNE_UNKNOWN_COMMAND` may strip it mechanically. `whole-repo-build-guard` is the\n * worked example: its switch moved OUT of the repo config into `~/.webpieces/config.json`, so the\n * value has nowhere to go here.\n *\n * False for a rename or an in-file move: deleting those would DISCARD a value the reader still needs,\n * so they keep their migration instruction and the pruner leaves them alone. Required, not defaulted —\n * a defaulted `false` would let a future deletion-only retirement silently opt out of the mechanical\n * cure and land back in \"the reader decides while every Bash call is blocked\".\n */\n prunable: boolean;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(scope: string, key: string, movedTo: string, instruction: string, label: string, prunable: boolean) {\n this.scope = scope;\n this.key = key;\n this.movedTo = movedTo;\n this.instruction = instruction;\n this.label = label;\n this.prunable = prunable;\n }\n}\n\n/**\n * Every retired key. Keep the newest at the bottom with the release that retired it, so the list reads as a\n * changelog an agent can walk when a config is several versions behind.\n */\nexport const RETIRED_CONFIG_KEYS: readonly RetiredConfigKey[] = [\n // --- Guard renames. Previously applied SILENTLY before validation (a DEPRECATED_RULE_ALIASES table in\n // load-config.ts rewrote the key so no validator ever saw it). That hid the rename from the config file\n // forever: the old name kept working, so no consumer ever updated, and the alias table could never be\n // deleted. Now each is a hard error with the new name.\n //\n // These three RE-POINTED when hookGuards collapsed to one key per policy. Their old destinations\n // (`pr-merge-guard`, `pr-creation-or-push-guard`, `read-stale-guard`) are themselves retired now,\n // and a retirement whose `movedTo` names a dead key teaches the removed API — the same defect one\n // level out. Each therefore names the POLICY key it lands on today, in one hop.\n new RetiredConfigKey(\n RETIRED_SCOPE_RULE, 'pr-merge-cleanup', 'pr-lifecycle-guard',\n 'Rename the key to \"pr-lifecycle-guard\" (merging its value into that entry if you already have ' +\n 'one — the four PR/merge guards share one key now). Its mode and escape hatches carry over.',\n '[pr-merge-cleanup]', false,\n ),\n new RetiredConfigKey(\n RETIRED_SCOPE_RULE, 'pr-creation-guard', 'pr-lifecycle-guard',\n 'Rename the key to \"pr-lifecycle-guard\" (merging its value into that entry if you already have ' +\n 'one — the four PR/merge guards share one key now). Its mode and escape hatches carry over; the ' +\n 'old \"upsertPrCommand\" field does NOT — that string lives only in commands.guardHints.prCreationOrPush.',\n '[pr-creation-guard]', false,\n ),\n new RetiredConfigKey(\n RETIRED_SCOPE_RULE, 'main-stale-guard', 'branch-state-guard',\n 'Rename the key to \"branch-state-guard\" (merging its value into that entry if you already have ' +\n 'one — the four branch-state guards share one key now). Its mode and escape hatches carry over. ' +\n 'Note the widened scope: that key arms the Write, Read AND Bash halves of the branch-state ' +\n 'policy, not just the Read block this key used to name.',\n '[main-stale-guard]', false,\n ),\n\n // --- The two flat guard-hint strings, superseded by commands.guardHints so that every guard-facing\n // command string sits in one named sub-object instead of loose beside the gate config.\n new RetiredConfigKey(\n RETIRED_SCOPE_KEY, 'upsertPr', 'commands.guardHints.prCreationOrPush',\n 'Move the value to \"guardHints\": { \"prCreationOrPush\": <value> } inside the same \"commands\" ' +\n 'section, then delete \"upsertPr\".',\n '[commands]', false,\n ),\n new RetiredConfigKey(\n RETIRED_SCOPE_KEY, 'mergeComplete', 'commands.guardHints.mergeInProgress',\n 'Move the value to \"guardHints\": { \"mergeInProgress\": <value> } inside the same \"commands\" ' +\n 'section, then delete \"mergeComplete\".',\n '[commands]', false,\n ),\n\n // --- The two-list excludePaths object. The split never earned its keep (every consumer set both lists\n // to the same value), and the one case that would need them to differ is served better by a rule's own\n // `excludePaths`. Retired as a SHAPE: `rules` is the entry validateExcludePaths reports for either key.\n new RetiredConfigKey(\n RETIRED_SCOPE_KEY, 'rules', 'excludePaths (one flat array)',\n 'Replace the whole { \"rules\": [...], \"guards\": [...] } object with ONE array holding the union of ' +\n 'both lists, de-duplicated — e.g. \"excludePaths\": [\"repositories/**\"]. A path is governed by ' +\n 'webpieces or it is not, so there is no longer a per-engine split. To exclude a path from one rule ' +\n 'only, use that rule\\'s own \"excludePaths\" inside its config block instead.',\n '[excludePaths]', false,\n ),\n\n // --- whole-repo-build-guard, retired as a REPO-CONFIG key one release after it was added. It shipped\n // as a conventional validated guard (mode ON by default, entry REQUIRED under hookGuards), so every\n // consumer that upgraded hit fault Y — every Bash call blocked — for a feature nobody had opted into.\n // The REQUIRED KEY was the fault, not the default: the failure was at config LOAD, before any command\n // was judged. The switch now lives ONLY in the optional machine-local ~/.webpieces/config.json, where\n // nothing has to be added to be in the default state — and the default is OFF, as every experimental\n // flag's is, so deleting this entry loses nothing.\n new RetiredConfigKey(\n RETIRED_SCOPE_RULE, 'whole-repo-build-guard', '~/.webpieces/config.json → experimental.whole-repo-build-guard',\n 'DELETE this entry from webpieces.config.json — no repo config key controls this guard any more. ' +\n 'The guard is OFF by default for everyone, with no file and no key required. To turn it ON for ' +\n 'YOUR machine only, put {\"experimental\": {\"whole-repo-build-guard\": true}} in ' +\n '~/.webpieces/config.json — that file is optional and is tracked by no repo.',\n '[whole-repo-build-guard]', true,\n ),\n\n // --- THE 9 → 3 COLLAPSE of `hookGuards`: one key per POLICY, not one per implementation CLASS.\n //\n // Eight class-named keys become two policy keys. The CLASSES are untouched — `feature-branch-guard`\n // is still the rule name in every decision-log line and every deny report — so nothing an operator\n // greps for moved. What moved is the SWITCH, because nine keys let a consumer configure HALF a\n // policy: `read-stale-guard: OFF` beside `merged-branch-bash-guard: ON` is \"read the file, yes;\n // `cat` the same file, no\", which nobody chose and the config made reachable.\n //\n // EVERY ONE OF THESE IS `prunable: false`, and that is not bookkeeping. `PRUNABLE_SECTIONS` in\n // ConfigPruner includes `hookGuards`, and the validation banner actively RECOMMENDS running the\n // pruner. A `prunable: true` here would mean the recommended cure silently DELETES four configured\n // guards with no destination named — a config loss, which is worse than a block. False keeps the\n // migration instruction and makes the pruner return null for these keys.\n //\n // 4 → 1 is legal for this table (nothing requires `movedTo` to be unique), but it is NOT legal for\n // a naive 1:1 migrator: see migrateRetiredRuleNames in ai-hook-rules' setup.ts, which unions the\n // four old entries into the destination and then fills any missing required field, rather than\n // renaming the first and deleting the rest.\n ...branchStateRetirements(),\n ...prLifecycleRetirements(),\n\n // --- The per-checklist reviewer agent (issue #938). A checklist used to name its own agent type in\n // `subagent`, which also served as its id; every checklist is now reviewed by the ONE agent type that\n // webpieces-reviewer (or an overrideReviewerAgent name) is, so the key that is left is only the checklist's NAME.\n // A rename, so `prunable: false` — deleting it would discard the id every verdict file is keyed by.\n new RetiredConfigKey(\n RETIRED_SCOPE_KEY, 'subagent', 'id',\n 'Rename \"subagent\" to \"id\" in EVERY commands.pr-gate.checklists entry, keeping its value (it still ' +\n 'names the checklist and keys review-round<N>-<id>.json). Checklists no longer choose an agent type: every one ' +\n 'is reviewed by the webpieces-reviewer agent (or your own, via \"overrideReviewerAgent\": true + ' +\n '\"reviewerAgentName\" in commands.pr-gate).',\n '[pr-gate.checklists]', false,\n ),\n];\n\n// The four branch-state classes. Split into a helper purely to keep the table above readable; the\n// instruction is per-key because the fields that carry over differ (only feature-branch-guard had\n// `branchNamingConvention`).\n// webpieces-disable no-function-outside-class -- table data for RETIRED_CONFIG_KEYS, beside the array it feeds\nfunction branchStateRetirements(): RetiredConfigKey[] {\n const merged = 'MERGE it into ONE \"branch-state-guard\" entry under \"hookGuards\"';\n const shared =\n `${merged}. All four of feature-branch-guard, read-stale-guard, stale-main-bash-guard and ` +\n 'merged-branch-bash-guard now read that single entry — they are one policy (\"may I work here, ' +\n 'and is what I read current?\") implemented by four classes, and configuring them separately let ' +\n 'you switch on half of it. Keep \"mode\", \"turnOffRuleUntilEpoch\" and \"turnOffRuleWhileOnBranch\"; ' +\n 'the ONE \"hangTimeoutMinutes\" survives (there was only ever one refresher and one cache, so at ' +\n 'most one of the four values could ever take effect); \"branchNamingConvention\" survives from ' +\n 'feature-branch-guard. If the four disagreed on \"mode\", pick the one you meant — \"ON\" arms the ' +\n 'whole policy including the Read block. Then DELETE this key.';\n return [\n new RetiredConfigKey(RETIRED_SCOPE_RULE, 'feature-branch-guard', 'branch-state-guard', shared, '[feature-branch-guard]', false),\n new RetiredConfigKey(RETIRED_SCOPE_RULE, 'read-stale-guard', 'branch-state-guard', shared, '[read-stale-guard]', false),\n new RetiredConfigKey(RETIRED_SCOPE_RULE, 'stale-main-bash-guard', 'branch-state-guard', shared, '[stale-main-bash-guard]', false),\n new RetiredConfigKey(RETIRED_SCOPE_RULE, 'merged-branch-bash-guard', 'branch-state-guard', shared, '[merged-branch-bash-guard]', false),\n ];\n}\n\n// The four PR-lifecycle classes.\n// webpieces-disable no-function-outside-class -- table data for RETIRED_CONFIG_KEYS, beside the array it feeds\nfunction prLifecycleRetirements(): RetiredConfigKey[] {\n const shared =\n 'MERGE it into ONE \"pr-lifecycle-guard\" entry under \"hookGuards\". All four of ' +\n 'pr-creation-or-push-guard, merge-in-progress-guard, pr-merge-guard and ' +\n 'redirect-how-to-merge-main now read that single entry — they are one policy (\"do PRs and ' +\n 'merges go through the gated flow?\"). Keep \"mode\", \"turnOffRuleUntilEpoch\" and ' +\n '\"turnOffRuleWhileOnBranch\". Know what \"mode\": \"OFF\" now means: it releases the ' +\n 'unvalidated-merge gate as well as the PR/push blocks, because merge-in-progress-guard is under ' +\n 'this key too. The per-guard \"upsertPrCommand\" / \"mergeCompleteCommand\" fields are gone — those ' +\n 'strings live ONLY in commands.guardHints.prCreationOrPush / .mergeInProgress. Then DELETE this key.';\n return [\n new RetiredConfigKey(RETIRED_SCOPE_RULE, 'pr-creation-or-push-guard', 'pr-lifecycle-guard', shared, '[pr-creation-or-push-guard]', false),\n new RetiredConfigKey(RETIRED_SCOPE_RULE, 'merge-in-progress-guard', 'pr-lifecycle-guard', shared, '[merge-in-progress-guard]', false),\n new RetiredConfigKey(RETIRED_SCOPE_RULE, 'pr-merge-guard', 'pr-lifecycle-guard', shared, '[pr-merge-guard]', false),\n new RetiredConfigKey(RETIRED_SCOPE_RULE, 'redirect-how-to-merge-main', 'pr-lifecycle-guard', shared, '[redirect-how-to-merge-main]', false),\n ];\n}\n\n/**\n * The shared message. Leads with the retirement, then the destination, then the edit — an agent reading this\n * should not have to infer anything.\n *\n * RETIRED_KEY_MARKER is the phrase the banner classifier keys off to call this error DEFINITIVE (no\n * install can revive a key this table names), so the marker is IMPORTED rather than re-typed here.\n */\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this package\nexport function retiredKeyError(entry: RetiredConfigKey): string {\n const destination = entry.movedTo === ''\n ? 'It was removed with no replacement.'\n : `It moved to \"${entry.movedTo}\".`;\n // Deletion-only retirements get the mechanical cure named right here, so the reader never has to\n // decide whether removing a key is safe while the guard is denying every Bash call.\n const mechanical = entry.prunable\n ? ` Deleting it is the WHOLE fix — \\`${PRUNE_UNKNOWN_COMMAND}\\` does it for you.`\n : '';\n return `${entry.label} \"${entry.key}\" ${RETIRED_KEY_MARKER}. ${destination} ${entry.instruction}${mechanical}`;\n}\n\n/**\n * The retired entry for a rule/guard NAME, or null. Callers must consult this BEFORE reporting a name as an\n * unknown rule: the generic unknown-rule message can only say \"delete it\", while this table knows WHERE the\n * setting went — a rename that must carry its value over, or a move to `~/.webpieces/config.json`. The\n * destination is the whole product, and a bare \"delete it\" would throw it away.\n */\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this package\nexport function retiredRuleFor(ruleName: string): RetiredConfigKey | null {\n return RETIRED_CONFIG_KEYS.find(e => e.scope === RETIRED_SCOPE_RULE && e.key === ruleName) ?? null;\n}\n\n/**\n * Whether `key` is retired within `label`'s section. Unknown-key rejection consults this so a retired key\n * gets its migration message instead of a generic \"unknown key, delete it\" — the migration instruction is\n * the entire reason this table exists.\n */\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this package\nexport function isRetiredKey(key: string, label: string): boolean {\n return RETIRED_CONFIG_KEYS.some(e => e.scope === RETIRED_SCOPE_KEY && e.label === label && e.key === key);\n}\n\n/**\n * The retired entry for `key` within `label`'s section. For a retirement that is a SHAPE rather than a\n * single key (the excludePaths object), the validator looks the entry up directly so one table row remains\n * the single source of the message.\n */\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this package\nexport function retiredEntry(key: string, label: string): RetiredConfigKey | null {\n return RETIRED_CONFIG_KEYS.find(e => e.scope === RETIRED_SCOPE_KEY && e.label === label && e.key === key) ?? null;\n}\n\n/** Errors for every retired plain key present in `section`. `label` scopes the lookup to that section. */\n// webpieces-disable no-any-unknown -- `section` is opaque consumer JSON; only key PRESENCE is read\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this package\nexport function retiredKeyErrorsIn(section: Record<string, unknown>, label: string): string[] {\n return RETIRED_CONFIG_KEYS\n .filter(e => e.scope === RETIRED_SCOPE_KEY && e.label === label && e.key in section)\n .map(e => retiredKeyError(e));\n}\n"]}
|
|
1
|
+
{"version":3,"file":"retired-config-keys.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/retired-config-keys.ts"],"names":[],"mappings":";;;AA0EA,0CAUC;AASD,wCAEC;AAQD,oCAEC;AAQD,oCAEC;AAKD,gDAIC;AA3HD,oDAAwD;AACxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,+DAA2D;AAC3D,2CAAoD;AAEpD,mGAAmG;AACnG,yGAAyG;AACzG,2CAA2C;AAC3C,kFAAkF;AACrE,QAAA,kBAAkB,GAAG,MAAM,CAAC;AAC5B,QAAA,iBAAiB,GAAG,KAAK,CAAC;AAEvC;;;GAGG;AACU,QAAA,mBAAmB,GAAgC;IAC5D,IAAI,4BAAgB,CAAC,KAAK,EAAE,UAAU,EAAE,sCAAs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AC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,yBAAiB,IAAI,CAAC,CAAC,KAAK,KAAK,KAAK,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;AAC9G,CAAC;AAED;;;;GAIG;AACH,iHAAiH;AACjH,SAAgB,YAAY,CAAC,GAAW,EAAE,KAAa;IACnD,OAAO,2BAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,yBAAiB,IAAI,CAAC,CAAC,KAAK,KAAK,KAAK,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,IAAI,IAAI,CAAC;AACtH,CAAC;AAED,0GAA0G;AAC1G,mGAAmG;AACnG,iHAAiH;AACjH,SAAgB,kBAAkB,CAAC,OAAgC,EAAE,KAAa;IAC9E,OAAO,2BAAmB;SACrB,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,yBAAiB,IAAI,CAAC,CAAC,KAAK,KAAK,KAAK,IAAI,CAAC,CAAC,GAAG,IAAI,OAAO,CAAC;SACnF,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;AACtC,CAAC","sourcesContent":["import { RulePackRegistry } from './rule-pack-registry';\nimport { RetiredConfigKey } from '@webpieces/rules-sdk';\n/**\n * Retired webpieces.config.json keys — the ONE place in the codebase where a dead config key may be named.\n *\n * ## THE POLICY: webpieces.config.json is never released backwards-compatible\n *\n * When a config key moves, is renamed, or is deleted, the loader REJECTS the old shape with an error that\n * names the destination. It does NOT quietly accept both. There is no fallback, no alias table applied\n * before validation, no \"still accepted for back-compat until every consumer migrates\".\n *\n * This is safe *here* in a way it is not for a normal library, and the reason is the consumer: every reader\n * of this file is a coding agent. The config is validated on startup, the agent is handed the exact edit,\n * and it applies it in one pass — so the upgrade is seamless without shipping a compatibility layer. That\n * makes a hard failure strictly cheaper than duality: two accepted shapes means two code paths, two sets of\n * defaults and two sets of error messages to keep honest forever, and the stale shape then lives in\n * consumer configs indefinitely because nothing ever forces the edit.\n *\n * A hard rejection here is always self-recoverable, which is what makes it safe to do:\n * - editing webpieces.config.json is ALWAYS permitted, even while the config is invalid (see the banner\n * in config-file.ts and the guard matrix — a Write/Edit targeting this file is an unconditional PASS),\n * - and `PRUNE_UNKNOWN_COMMAND` is an L0 CURE, so the mechanical cleanup of keys no validator knows runs\n * from inside the block too.\n * So rejecting an old shape can never wedge a repo. \"It would deadlock the consumer\" is not a reason to add\n * a fallback; it is not true.\n *\n * NOT `pnpm install`. This paragraph used to offer it as the escape hatch that \"fixes the far more common\n * cause of a validation failure: an installed validator lagging the config by a release\". It is permitted\n * (installer bypass), but it is not the cure for anything you can read here: the shim's version-drift guard\n * compares the pin against the installed version and denies every tool call BEFORE the validator runs, so a\n * validation error on screen is proof that package.json and node_modules already agree. The banner from this\n * same package now says \"Do NOT run `pnpm install` — it cannot help\", and a docstring teaching the opposite\n * is how that advice leaked back out.\n *\n * ## Adding an entry\n *\n * When you retire a key, add it here and DELETE its read path — do not leave a `??` fallback behind. The\n * `instruction` is the whole product: it is read by an agent that will act on it verbatim, so give the\n * mechanical edit (\"rename X to Y\", \"move A into B\"), not a description of the change. Saying where a thing\n * moved to is exactly the point of this table; it is what makes the fallback unnecessary.\n *\n * retired-config-keys.spec.ts asserts every entry below actually FAILS the load. That spec is the guard: a\n * future fallback that silently swallows a retired key turns it red.\n */\n\nimport { RETIRED_KEY_MARKER } from './config-error-banner';\nimport { PRUNE_UNKNOWN_COMMAND } from './constants';\n\n// A retired key is matched one of two ways, because config keys live at two very different levels.\n// RULE — a rule/guard NAME, which may sit under either `rules` or `hookGuards`, so it is matched by bare\n// name rather than by a fixed path.\n// KEY — a plain key inside a known section, matched by name within that section.\nexport const RETIRED_SCOPE_RULE = 'rule';\nexport const RETIRED_SCOPE_KEY = 'key';\n\n/**\n * Every retired key. Keep the newest at the bottom with the release that retired it, so the list reads as a\n * changelog an agent can walk when a config is several versions behind.\n */\nexport const RETIRED_CONFIG_KEYS: readonly RetiredConfigKey[] = [\n new RetiredConfigKey(\"key\", \"upsertPr\", \"commands.guardHints.prCreationOrPush\", \"Move the value to \\\"guardHints\\\": { \\\"prCreationOrPush\\\": <value> } inside the same \\\"commands\\\" section, then delete \\\"upsertPr\\\".\", \"[commands]\", false),\n new RetiredConfigKey(\"key\", \"mergeComplete\", \"commands.guardHints.mergeInProgress\", \"Move the value to \\\"guardHints\\\": { \\\"mergeInProgress\\\": <value> } inside the same \\\"commands\\\" section, then delete \\\"mergeComplete\\\".\", \"[commands]\", false),\n new RetiredConfigKey(\"key\", \"rules\", \"excludePaths (one flat array)\", \"Replace the whole { \\\"rules\\\": [...], \\\"guards\\\": [...] } object with ONE array holding the union of both lists, de-duplicated — e.g. \\\"excludePaths\\\": [\\\"repositories/**\\\"]. A path is governed by webpieces or it is not, so there is no longer a per-engine split. To exclude a path from one rule only, use that rule's own \\\"excludePaths\\\" inside its config block instead.\", \"[excludePaths]\", false),\n new RetiredConfigKey(\"key\", \"subagent\", \"id\", \"Rename \\\"subagent\\\" to \\\"id\\\" in EVERY commands.pr-gate.checklists entry, keeping its value (it still names the checklist and keys review-round<N>-<id>.json). Checklists no longer choose an agent type: every one is reviewed by the webpieces-reviewer agent (or your own, via \\\"overrideReviewerAgent\\\": true + \\\"reviewerAgentName\\\" in commands.pr-gate).\", \"[pr-gate.checklists]\", false),\n];\n\n/**\n * The shared message. Leads with the retirement, then the destination, then the edit — an agent reading this\n * should not have to infer anything.\n *\n * RETIRED_KEY_MARKER is the phrase the banner classifier keys off to call this error DEFINITIVE (no\n * install can revive a key this table names), so the marker is IMPORTED rather than re-typed here.\n */\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this package\nexport function retiredKeyError(entry: RetiredConfigKey): string {\n const destination = entry.movedTo === ''\n ? 'It was removed with no replacement.'\n : `It moved to \"${entry.movedTo}\".`;\n // Deletion-only retirements get the mechanical cure named right here, so the reader never has to\n // decide whether removing a key is safe while the guard is denying every Bash call.\n const mechanical = entry.prunable\n ? ` Deleting it is the WHOLE fix — \\`${PRUNE_UNKNOWN_COMMAND}\\` does it for you.`\n : '';\n return `${entry.label} \"${entry.key}\" ${RETIRED_KEY_MARKER}. ${destination} ${entry.instruction}${mechanical}`;\n}\n\n/**\n * The retired entry for a rule/guard NAME, or null. Callers must consult this BEFORE reporting a name as an\n * unknown rule: the generic unknown-rule message can only say \"delete it\", while this table knows WHERE the\n * setting went — a rename that must carry its value over, or a move to `~/.webpieces/config.json`. The\n * destination is the whole product, and a bare \"delete it\" would throw it away.\n */\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this package\nexport function retiredRuleFor(ruleName: string, registry: RulePackRegistry): RetiredConfigKey | null {\n return registry.migrations().find(e => e.scope === RETIRED_SCOPE_RULE && e.key === ruleName) ?? null;\n}\n\n/**\n * Whether `key` is retired within `label`'s section. Unknown-key rejection consults this so a retired key\n * gets its migration message instead of a generic \"unknown key, delete it\" — the migration instruction is\n * the entire reason this table exists.\n */\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this package\nexport function isRetiredKey(key: string, label: string): boolean {\n return RETIRED_CONFIG_KEYS.some(e => e.scope === RETIRED_SCOPE_KEY && e.label === label && e.key === key);\n}\n\n/**\n * The retired entry for `key` within `label`'s section. For a retirement that is a SHAPE rather than a\n * single key (the excludePaths object), the validator looks the entry up directly so one table row remains\n * the single source of the message.\n */\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this package\nexport function retiredEntry(key: string, label: string): RetiredConfigKey | null {\n return RETIRED_CONFIG_KEYS.find(e => e.scope === RETIRED_SCOPE_KEY && e.label === label && e.key === key) ?? null;\n}\n\n/** Errors for every retired plain key present in `section`. `label` scopes the lookup to that section. */\n// webpieces-disable no-any-unknown -- `section` is opaque consumer JSON; only key PRESENCE is read\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this package\nexport function retiredKeyErrorsIn(section: Record<string, unknown>, label: string): string[] {\n return RETIRED_CONFIG_KEYS\n .filter(e => e.scope === RETIRED_SCOPE_KEY && e.label === label && e.key in section)\n .map(e => retiredKeyError(e));\n}\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { FieldDef, RulePackManifest, RulePackDeclaration, ConfigObject, RetiredConfigKey, SafeguardDefinition, RuleConfigSection } from '@webpieces/rules-sdk';
|
|
2
|
+
/** Loading is the only impure boundary; callers may supply an alternative module transport. */
|
|
3
|
+
export declare abstract class RulePackModuleLoader {
|
|
4
|
+
abstract load(moduleName: string): RulePackManifest;
|
|
5
|
+
}
|
|
6
|
+
export declare class NodeRulePackModuleLoader extends RulePackModuleLoader {
|
|
7
|
+
private readonly requireModule;
|
|
8
|
+
constructor(clientRoot: string);
|
|
9
|
+
load(moduleName: string): RulePackManifest;
|
|
10
|
+
}
|
|
11
|
+
/** A registry depends only on declarations and the SDK, never on concrete execution packages. */
|
|
12
|
+
export declare class RulePackRegistry {
|
|
13
|
+
readonly manifests: readonly RulePackManifest[];
|
|
14
|
+
private readonly owners;
|
|
15
|
+
private readonly definitions;
|
|
16
|
+
private readonly safeguards;
|
|
17
|
+
constructor(manifests: readonly RulePackManifest[]);
|
|
18
|
+
ownerOf(ruleId: string): string;
|
|
19
|
+
schemaFor(ruleId: string): Readonly<Record<string, FieldDef>>;
|
|
20
|
+
ruleIds(): readonly string[];
|
|
21
|
+
hasRule(ruleId: string): boolean;
|
|
22
|
+
isSafeguard(ruleId: string): boolean;
|
|
23
|
+
sectionFor(ruleId: string): RuleConfigSection;
|
|
24
|
+
optionalTuningFor(ruleId: string): ConfigObject;
|
|
25
|
+
seedFor(ruleId: string): ConfigObject;
|
|
26
|
+
migrations(): readonly RetiredConfigKey[];
|
|
27
|
+
safeguardCatalog(): readonly SafeguardDefinition[];
|
|
28
|
+
private definitionFor;
|
|
29
|
+
/** Validates explicit config values with the owner's schema; supplies no rule defaults. */
|
|
30
|
+
validateRuleConfig(ruleId: string, value: ConfigObject): readonly string[];
|
|
31
|
+
private validateManifest;
|
|
32
|
+
private validateOwnerSettings;
|
|
33
|
+
private validateSchema;
|
|
34
|
+
private validateObject;
|
|
35
|
+
}
|
|
36
|
+
/** Inject the selected module transport; discovery never names a built-in owner package. */
|
|
37
|
+
export declare class RulePackDiscovery {
|
|
38
|
+
private readonly loader;
|
|
39
|
+
constructor(loader: RulePackModuleLoader);
|
|
40
|
+
discover(declarations: readonly RulePackDeclaration[]): RulePackRegistry;
|
|
41
|
+
}
|