@webpieces/rules-config 0.4.997 → 0.4.999
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webpieces/rules-config",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.999",
|
|
4
4
|
"description": "Shared webpieces.config.json loader. Single source of truth for validation rule configuration consumed by @webpieces/ai-hook-rules, @webpieces/code-rules, and @webpieces/nx-webpieces-rules.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"inversify": "7.10.4",
|
|
20
20
|
"reflect-metadata": "0.2.2",
|
|
21
21
|
"minimatch": "10.0.1",
|
|
22
|
-
"@webpieces/tooling-common": "0.4.
|
|
23
|
-
"@webpieces/repo-workflow-core": "0.4.
|
|
24
|
-
"@webpieces/rules-sdk": "0.4.
|
|
22
|
+
"@webpieces/tooling-common": "0.4.999",
|
|
23
|
+
"@webpieces/repo-workflow-core": "0.4.999",
|
|
24
|
+
"@webpieces/rules-sdk": "0.4.999"
|
|
25
25
|
},
|
|
26
26
|
"author": "Dean Hiller",
|
|
27
27
|
"license": "Apache-2.0",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@webpieces/tooling-testkit": "0.4.
|
|
37
|
+
"@webpieces/tooling-testkit": "0.4.999"
|
|
38
38
|
},
|
|
39
39
|
"types": "./src/index.d.ts",
|
|
40
40
|
"bin": {
|
package/src/validate-config.js
CHANGED
|
@@ -201,9 +201,9 @@ entry, schema, registry) {
|
|
|
201
201
|
errors.push(capError);
|
|
202
202
|
}
|
|
203
203
|
else if (ruleName === 'branch-state-guard' &&
|
|
204
|
-
key === 'maxCommitsBehind' &&
|
|
204
|
+
(key === 'maxCommitsBehind' || key === 'featureBranchMaxCommitsBehind') &&
|
|
205
205
|
(!Number.isInteger(value) || value < 0)) {
|
|
206
|
-
errors.push(
|
|
206
|
+
errors.push(`[branch-state-guard] "${key}" must be a non-negative integer.`);
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
209
|
return errors;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-config.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/validate-config.ts"],"names":[],"mappings":";;;AAwSA,0DA8DC;AA+BD,oDAuBC;AA+FD,8DA4BC;AAvhBD,yEAAoE;AACpE,uEAAqE;AAA5D,mIAAA,uBAAuB,OAAA;AAOhC,6CAAqE;AACrE,oDAA2D;AAC3D,6EAMsC;AAK7B,0GAVL,sDAAyB,OAUK;AAJlC,+DAAsF;AACtF,2CAAoD;AAIpD,yFAAyF;AACzF,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,2CAA6F;AAApF,iHAAA,mBAAmB,OAAA;AAAE,oHAAA,sBAAsB,OAAA;AAAE,8GAAA,gBAAgB,OAAA;AACtE,6DAA2D;AAC3D,iEAA6D;AAE7D;;;;;;;;;;GAUG;AAEH;;;;;;GAMG;AACH,wHAAwH;AACxH,SAAS,aAAa,CAAC,KAAa,EAAE,KAAa;IAC/C,OAAO,IAAI,iDAAsB,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AACjE,CAAC;AAED,SAAS,SAAS,CAAC,GAAa,EAAE,GAAY;IAC1C,oGAAoG;IACpG,oGAAoG;IACpG,IAAI,GAAG,KAAK,uBAAuB;QAC/B,OAAO,8DAA8D,CAAC;IAC1E,IAAI,GAAG,KAAK,0BAA0B;QAClC,OAAO,gHAAgH,CAAC;IAC5H,OAAO,GAAG,CAAC,UAAU;QACjB,CAAC,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG;QACnC,CAAC,CAAC,GAAG,CAAC,IAA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C,CAAC;QACrF,IAAI,QAAQ;YAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;IACD,IACI,CAAC,CACG,CAAC,CAAC,0BAA0B,CAAC,KAAK,IAAI;QACtC,OAAO,CAAC,CAAC,0BAA0B,CAAC,KAAK,QAAQ,CACpD;QAED,MAAM,CAAC,IAAI,CACP,iBAAiB,KAAK,+IAA+I,CACxK,CAAC;IAEN,iEAAiE;IACjE,KAAK,MAAM,MAAM,IAAI,IAAI,iDAAsB,EAAE,CAAC,aAAa,EAAE,EAAE,CAAC;QAChE,IAAI,MAAM,IAAI,CAAC;YACX,MAAM,CAAC,IAAI,CACP,iBAAiB,CAAC,iBAAiB,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,iDAAsB,EAAE,CAAC,YAAY,CAAC,MAAM,CAAE,CAAC,CAC1G,CAAC;IACV,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { PolicyFieldConstraints } from './policy-field-constraints';\nexport { MAX_TURN_OFF_EPOCH_DAYS } from './policy-field-constraints';\nimport { FieldDef, RetiredConfigKey } from '@webpieces/rules-sdk';\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nimport { RulePackRegistry } from './rule-pack-registry';\nimport { allRuleNames } from './rule-schemas';\nimport { recommendedSeedModeFor, isGradualMode } from './seed-entry';\nimport { MODIFIED_CODE_MODES } from '@webpieces/rules-sdk';\nimport {\n validateChecklistsSection,\n validateDevDeploySection,\n validateLandPrSection,\n validateNoGateSaltRationale,\n validateReviewerAgentKeys,\n} from './pr-gate-section-validators';\nimport { retiredEntry, retiredKeyError, retiredRuleFor } from './retired-config-keys';\nimport { PRUNE_UNKNOWN_COMMAND } from './constants';\n\n// Re-exported so the isolated validate-checklist-docs target keeps importing it from here.\nexport { validateChecklistsSection };\n// Re-exported from their new homes: this module was the historical entry point for both.\nexport { allRuleNames } from './rule-schemas';\nexport { recommendedSeedMode, recommendedSeedModeFor, seedEntryForRule } from './seed-entry';\nimport { DEFAULT_MATCH_RULES } from './match-rules-config';\nimport { toError } from '@webpieces/tooling-common/to-error';\n\n/**\n * The longest a `turnOffRuleUntilEpoch` may reach into the future: ONE WEEK — a hard ceiling, not the\n * advice. The advice every cure gives (#1318) is the BRANCH hatch first, and the epoch only as a last\n * resort set to now + 1 hour, because it is REPO-WIDE while it lasts (see TurnOffRuleCure).\n *\n * DELIBERATELY ASYMMETRIC with turnOffRuleWhileOnBranch, which has NO cap and must not get one. The epoch\n * hatch is REPO-WIDE while it lasts, so a long window shelters every unrelated change that lands inside it\n * (a fleet repo was found with max-file-lines/max-method-lines switched off until 2026-10-01 — 43 days\n * out, six times this cap). The branch hatch fires only on ONE exact branch name — a big refactor\n * legitimately runs 35+ days, and capping that would only interrupt the one branch that opted in.\n */\n\n/**\n * Reject a `turnOffRuleUntilEpoch` more than MAX_TURN_OFF_EPOCH_DAYS into the future.\n *\n * A PAST epoch is always valid: it is inert (it skips nothing), and every existing config is full of them.\n * The BOUNDARY is inclusive — exactly MAX_TURN_OFF_EPOCH_DAYS out is accepted, only strictly beyond it is\n * refused — so a config written as \"now + 7 days\" is never rejected by the second it took to save.\n */\n// webpieces-disable no-function-outside-class -- module-scope validator helper, matching every other check in this file\nfunction epochCapError(label: string, value: number): string | null {\n return new PolicyFieldConstraints().epochError(label, value);\n}\n\nfunction valueHint(def: FieldDef, key?: string): string {\n // The two universal escape hatches, REQUIRED on every rule so they're always visible. Spell out the\n // \"off\" value so a fresh config seeds them in the active/no-op state (0 / null), not a placeholder.\n if (key === 'turnOffRuleUntilEpoch')\n return '0 (0 = active; future unix-epoch seconds = temporarily off)';\n if (key === 'turnOffRuleWhileOnBranch')\n return 'null (null = always on; an EXACT branch name — no globs — disables the rule while that branch is checked out)';\n return def.enumValues\n ? `\"${def.enumValues.join(' | ')}\"`\n : def.type === 'string[]'\n ? '[\"<string>\", ...]'\n : def.type === 'object[]'\n ? objectListHint(def)\n : def.type === 'number'\n ? '<number>'\n : def.type === 'boolean'\n ? '<boolean>'\n : '\"<string>\"';\n}\n\n/** `[{ \"paths\": [\"<string>\", ...], \"suffixes\": [\"<string>\", ...] }, ...]` — one element spelled out from its schema. */\n// webpieces-disable no-function-outside-class -- module-scope sibling of valueHint\nfunction objectListHint(def: FieldDef): string {\n const schema: Readonly<Record<string, FieldDef>> = def.elementSchema ?? {};\n const fields = Object.keys(schema)\n .filter((key: string) => !schema[key].optional)\n .map((key: string) => `\"${key}\": ${valueHint(schema[key], key)}`);\n return `[{ ${fields.join(', ')} }, ...]`;\n}\n\n/**\n * A config key whose schema is absent from every explicitly selected owner manifest. THE FALLBACK: it fires for any name the table in retired-config-keys.ts does not\n * know, which very much includes RETIRED names on a tree whose validator predates the retirement — the\n * ordinary linked-worktree layout, where the worktree is on one release and the parent checkout that\n * supplies the hook's resolution is on an older one. So this text has to be useful with NO table entry.\n *\n * DELETION LEADS, and it is not a hedge. A key the running validator has no schema for controls nothing:\n * every code path that would read it is keyed off the schema. Leaving it is dead config that reads as live\n * config, and for a retired key deleting it is the entire fix.\n *\n * This message used to lead with `pnpm install` instead, on the theory that the key might be valid and the\n * validator merely stale. Two things are wrong with that. First, it CONTRADICTED the banner this error is\n * printed inside, which states outright that `pnpm install` cannot help — one output, two opposite orders.\n * Second, the premise is already handled upstream: the shim's version-drift guard compares the pin against\n * the installed version and denies every tool call BEFORE exec'ing this validator, with its own message and\n * its own cure. If this text is on screen, that guard found no drift. The pin therefore appears here only as\n * a secondary note, so a valid-but-newer key is never dropped without the reader being told the case exists.\n */\nfunction unknownRuleError(ruleName: string): string {\n return (\n `[${ruleName}] Unknown rule — the running @webpieces validator has no selected owner schema for it. A key no validator knows controls NOTHING, so ` +\n `DELETE the \"${ruleName}\" key from the direct policy-ID map in its declared owner config file. ` +\n `Run \\`${PRUNE_UNKNOWN_COMMAND}\\` to remove unknown entries from declared owner files mechanically. ` +\n `It may be RETIRED: a newer release can move ` +\n `a setting out of this file entirely, in which case deleting the key here is the WHOLE fix. ` +\n `MACHINE-LOCAL settings in particular now live in ~/.webpieces/config.json under \"experimental\" — ` +\n `an optional file tracked by no repo, whose absence is the default behaviour — so if ` +\n `\"${ruleName}\" is one of those, delete it here and set it there. Secondary, and rare: a key is ` +\n `valid-but-unlearned when package.json pins an @webpieces OLDER than this config was written for, ` +\n `and the version-drift guard reports THAT separately with its own cure (bump the pin) before this ` +\n `validator ever runs — so it is not what you are looking at.`\n );\n}\n\n/** Schema advice names the selected owner rather than a retired root section. */\nclass RuleConfigAdvice {\n constructor(private readonly registry: RulePackRegistry) {}\n\n private rolloutTip(schema: Readonly<Record<string, FieldDef>>): string {\n const modes = schema['mode']?.enumValues ?? [];\n // Same source of truth as the seeder; only a GRADUAL recommendation gets the rollout prose, so a\n // rule whose recommendation falls through to ON/RUN_EVERY_TIME/OFF prints no tip (as before).\n const recommended = recommendedSeedModeFor(modes);\n if (!isGradualMode(recommended)) return '';\n const optOut = modes.includes('OFF') ? ' Set \"mode\": \"OFF\" to opt out entirely.' : '';\n return (\n `\\n\\n💡 Recommended: start with \"mode\": \"${recommended}\" — it enforces only on what you ` +\n `actually change, so the rule rolls out gradually (existing code stays grandfathered until ` +\n `you next touch that project/file/method).${optOut}`\n );\n }\n\n missingRuleSnippet(ruleName: string, schema: Readonly<Record<string, FieldDef>>): string {\n // Required fields go in the copy-paste entry. The two universal escape hatches\n // (turnOffRuleUntilEpoch / turnOffRuleWhileOnBranch) are now REQUIRED, so they land in that block —\n // which is the whole point: every seeded rule shows both hatches. Optional fields are listed separately.\n const fields = Object.keys(schema);\n const required = fields.filter((f: string) => !schema[f].optional);\n const optional = fields.filter((f: string) => schema[f].optional);\n\n const requiredLines = required.map((f: string) => ` \"${f}\": ${valueHint(schema[f], f)}`);\n const owner = this.registry.ownerOf(ruleName);\n let out =\n `[${ruleName}] Not configured in the declared owner config file for ${owner}. ` +\n `Add this entry directly to that file's policy-ID map\\n` +\n `(choose values appropriate for your project):\\n\\n` +\n ` \"${ruleName}\": {\\n${requiredLines.join(',\\n')}\\n }`;\n\n if (optional.length > 0) {\n const optionalLines = optional.map(\n (f: string) => ` \"${f}\": ${valueHint(schema[f], f)}`,\n );\n out +=\n `\\n\\nOptional fields you may add to this rule (omit if not needed):\\n` +\n `${optionalLines.join(',\\n')}`;\n }\n out += this.rolloutTip(schema);\n return out;\n }\n}\n\n// Fields we DELETED from a rule's schema, keyed by \"<rule>.<field>\". The generic unknown-field error\n// (\"Unknown field ... Valid fields: [...]\") is correct but doesn't say WHY the field vanished, so an AI\n// might re-add it. These hints explain the removal so the only action left is to delete the key.\n\n// Universal field renames (apply to EVERY rule/guard AND every match-rule, unlike the per-rule\n// RETIRED_FIELD_HINTS). When an entry still uses the old escape-hatch name, the generic unknown-field\n// error is replaced with a precise \"renamed to X — rename it\" instruction so the fix is mechanical.\n\n\n// The renamed-field message shared by keyed rules and match-rules.\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nfunction renamedFieldError(scope: string, oldKey: string, newKey: string): string {\n return `${scope} Unknown field \"${oldKey}\" — it was renamed to \"${newKey}\". Rename it (the value carries over unchanged; for the branch hatch, use null when there is no branch).`;\n}\n\n/**\n * Field-level errors for ONE configured rule entry: unknown/renamed/retired keys, type and enum\n * mismatches, and the two-week cap on turnOffRuleUntilEpoch.\n *\n * Extracted out of validateWebpiecesConfig purely so that function stays inside max-method-lines; it is\n * the same checks in the same order.\n */\n// webpieces-disable no-any-unknown -- one config entry as opaque JSON; every field is typed-checked below\n// webpieces-disable no-function-outside-class -- module-scope validator helper, matching every other check in this file\nfunction fieldErrors(\n ruleName: string,\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n entry: Record<string, unknown>,\n schema: Readonly<Record<string, FieldDef>>,\n registry: RulePackRegistry,\n): string[] {\n const errors: string[] = [];\n for (const [key, value] of Object.entries(entry)) {\n const fieldDef = schema[key];\n if (!fieldDef) {\n const renamedTo = new PolicyFieldConstraints().renamedField(key);\n if (renamedTo) {\n errors.push(renamedFieldError(`[${ruleName}]`, key, renamedTo));\n continue;\n }\n const retiredHint = registry\n .migrations()\n .find(\n (entry: RetiredConfigKey) =>\n entry.scope === 'field' && entry.key === `${ruleName}.${key}`,\n )?.instruction;\n const suffix = retiredHint ? ` ${retiredHint}` : '';\n errors.push(\n `[${ruleName}] Unknown field \"${key}\". Valid fields: [${Object.keys(schema).join(', ')}].${suffix}`,\n );\n continue;\n }\n // A nullable field (e.g. turnOffRuleWhileOnBranch) accepts JSON null in addition to its type.\n if (value === null && fieldDef.nullable) continue;\n if (fieldDef.type === 'string[]' || fieldDef.type === 'object[]') {\n errors.push(...arrayFieldErrors(`[${ruleName}] \"${key}\"`, value, fieldDef));\n } else if (typeof value !== fieldDef.type) {\n errors.push(`[${ruleName}] \"${key}\" must be ${fieldDef.type}, got ${typeof value}.`);\n } else if (fieldDef.enumValues && !fieldDef.enumValues.includes(value as string)) {\n errors.push(\n `[${ruleName}] \"${key}\" = \"${value}\" is not valid. Must be one of: ${fieldDef.enumValues.join(', ')}.`,\n );\n } else if (key === 'turnOffRuleUntilEpoch') {\n const capError = epochCapError(`[${ruleName}]`, value as number);\n if (capError) errors.push(capError);\n } else if (\n ruleName === 'branch-state-guard' &&\n key === 'maxCommitsBehind' &&\n (!Number.isInteger(value) || (value as number) < 0)\n ) {\n errors.push('[branch-state-guard] \"maxCommitsBehind\" must be a non-negative integer.');\n }\n }\n return errors;\n}\n\n/**\n * Errors for one array-typed field (`string[]` / `object[]`): the element type, `nonEmpty`, and — for\n * `object[]` — every element against the field's `elementSchema` (unknown keys, missing required keys,\n * and each element field checked recursively). `label` is `[rule] \"field\"`, extended per element\n * (`[rule] \"entries\"[0].suffixes`) so an error names the exact spot to edit.\n */\n// webpieces-disable no-any-unknown -- a config field value is opaque JSON until this checks its shape\n// webpieces-disable no-function-outside-class -- module-scope validator helper, matching every other check in this file\n// webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\nfunction arrayFieldErrors(label: string, value: unknown, def: FieldDef): string[] {\n const isObjects = def.type === 'object[]';\n // webpieces-disable no-any-unknown -- one list element as opaque JSON; this line is what checks its shape\n const elementOk = (v: unknown): boolean =>\n isObjects\n ? typeof v === 'object' && v !== null && !Array.isArray(v)\n : typeof v === 'string';\n if (!Array.isArray(value) || !value.every(elementOk)) {\n const shape = isObjects ? 'a list of objects' : 'string[]';\n return [\n `${label} must be ${shape}, got ${Array.isArray(value) ? 'a list holding something else' : typeof value}.`,\n ];\n }\n if (def.nonEmpty && value.length === 0) {\n return [\n `${label} must not be empty — an empty list judges nothing while reading as configured. Add ${valueHint(def)}.` +\n (def.emptyInstruction === undefined ? '' : ` ${def.emptyInstruction}`),\n ];\n }\n if (!isObjects || def.elementSchema === undefined) return [];\n const errors: string[] = [];\n const schema = def.elementSchema;\n // webpieces-disable no-any-unknown -- an element's fields are opaque JSON until checked against its schema below\n value.forEach((element: Record<string, unknown>, index: number) => {\n const at = `${label}[${index}]`;\n for (const key of Object.keys(element)) {\n if (!(key in schema))\n errors.push(\n `${at} Unknown field \"${key}\". Valid fields: [${Object.keys(schema).join(', ')}].`,\n );\n }\n for (const [key, fieldDef] of Object.entries(schema)) {\n if (!(key in element)) {\n if (!fieldDef.optional)\n errors.push(\n `${at} Missing required field \"${key}\". Add ${key}: ${valueHint(fieldDef, key)}.`,\n );\n } else if (fieldDef.type === 'string[]' || fieldDef.type === 'object[]') {\n errors.push(...arrayFieldErrors(`${at}.${key}`, element[key], fieldDef));\n } else if (typeof element[key] !== fieldDef.type) {\n errors.push(`${at}.${key} must be ${fieldDef.type}, got ${typeof element[key]}.`);\n }\n }\n });\n return errors;\n}\n\n// webpieces-disable no-any-unknown -- rawRules values are opaque JSON; each field is validated individually\nexport function validateWebpiecesConfig(\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n rawRules: Record<string, Record<string, unknown>>,\n registry: RulePackRegistry,\n): string[] {\n const errors: string[] = [];\n const advice = new RuleConfigAdvice(registry);\n\n // Check field-level correctness for rules that are present\n for (const [ruleName, entry] of Object.entries(rawRules)) {\n const schema = registry.hasRule(ruleName) ? registry.schemaFor(ruleName) : undefined;\n if (!schema) {\n if (\n registry.isSafeguard(ruleName) &&\n !registry\n .migrations()\n .some(\n (entry: RetiredConfigKey) =>\n entry.scope === 'rule' && entry.key === ruleName,\n )\n ) {\n errors.push(\n `[${ruleName}] is a cataloged safeguard, not a configurable policy. Delete its config entry; fixed safety cannot be disabled.`,\n );\n continue;\n }\n // A name we KNOW is retired beats the generic unknown-rule message, because only the table\n // knows WHERE the setting went — a rename carries its value over, and a bare \"delete it\"\n // would throw that value away. Client packs must not reuse a retired canonical ID.\n const retired = retiredRuleFor(ruleName, registry);\n if (retired) {\n errors.push(retiredKeyError(retired));\n continue;\n }\n // Client policies require a schema from an explicitly selected owner.\n errors.push(unknownRuleError(ruleName));\n continue;\n }\n errors.push(...fieldErrors(ruleName, entry, schema, registry));\n // Required fields must actually be present. Until now the loop above only checked\n // fields that WERE present, so an entry like `{}` (or one missing `mode` /\n // `turnOffRuleUntilEpoch`) slipped through. Every non-optional schema field is mandatory.\n for (const [key, fieldDef] of Object.entries(schema)) {\n if (!fieldDef.optional && !(key in entry)) {\n errors.push(\n `[${ruleName}] Missing required field \"${key}\". Add ${key}: ${valueHint(fieldDef, key)}.`,\n );\n }\n }\n }\n\n // Every built-in rule must be explicitly configured — no silent defaults.\n // When a new rule is added to the framework, this check surfaces it immediately\n // with a ready-to-copy snippet so AI can configure it in one pass.\n for (const ruleName of registry.ruleIds()) {\n const schema = registry.schemaFor(ruleName);\n if (!(ruleName in rawRules)) {\n errors.push(advice.missingRuleSnippet(ruleName, schema));\n }\n }\n\n return errors;\n}\n\nexport { validatePrGateSection } from './validate-pr-gate';\n\nfunction excludePathsExample(): string {\n return '\"excludePaths\": [\"repositories/**\"]';\n}\n\n// A glob list: must be a string[] (may be empty). `key` names it for the error.\n// webpieces-disable no-any-unknown -- `value` is opaque consumer JSON until narrowed here\nfunction validateExcludeList(value: unknown, key: string): string[] {\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n if (!(Array.isArray(value) && value.every((p: unknown) => typeof p === 'string'))) {\n return [`[excludePaths] \"${key}\" must be a string[] of glob paths (use [] for none).`];\n }\n return [];\n}\n\n/**\n * Validate the REQUIRED top-level `excludePaths` block: ONE glob list of paths NO rule judges — hook\n * rules, file-scoped guards and the build's code rules alike (#1253: the code-rules runtime applies it\n * too, through RuleFileScope). Required so every client upgrading is\n * forced to declare it (as [] to keep today's behavior, or with real paths). Returns copy-paste\n * friendly errors and never throws — same contract as validatePrGateSection.\n *\n * The two-list object form `{ \"rules\": [...], \"guards\": [...] }` is RETIRED, not tolerated. It used to be\n * accepted and silently unioned, which is why this repo's own config sat on the dead shape for releases: an\n * accepted shape is never migrated. Rejecting it cannot wedge a consumer — editing webpieces.config.json is\n * always permitted, even while it is invalid. See retired-config-keys.ts.\n */\n// webpieces-disable no-any-unknown -- `section` is opaque consumer JSON until narrowed below\nexport function validateExcludePaths(section: unknown): string[] {\n if (section === undefined || section === null) {\n return [\n `[excludePaths] Not configured in webpieces.config.json. Add this REQUIRED block ` +\n `(use an empty array to keep enforcing everywhere):\\n\\n ${excludePathsExample()}`,\n ];\n }\n if (Array.isArray(section)) return validateExcludeList(section, 'excludePaths');\n if (typeof section !== 'object') {\n return [\n `[excludePaths] Must be a string[] of glob paths. Example:\\n\\n ${excludePathsExample()}`,\n ];\n }\n // webpieces-disable no-any-unknown -- narrowing the opaque excludePaths section from consumer JSON\n const s = section as Record<string, unknown>;\n // The retired two-list object. One table row owns the message for either key present.\n const retired = retiredEntry('rules', '[excludePaths]');\n if (retired && (s['rules'] !== undefined || s['guards'] !== undefined)) {\n return [`${retiredKeyError(retired)}\\n\\n ${excludePathsExample()}`];\n }\n return [\n `[excludePaths] Must be a string[] of glob paths. Example:\\n\\n ${excludePathsExample()}`,\n ];\n}\n\n// ---------------------------------------------------------------------------\n// match-rules — a new top-level ARRAY section (parallel to pr-gate/excludePaths). Each entry is a\n// client-authored content guard (raw-regex patterns + message + scoping). Validated structurally here\n// the same way pr-gate's `gates` are, because an array of objects can't be expressed in FieldDef schema.\n// ---------------------------------------------------------------------------\n\nfunction matchRulesExample(): string {\n return `\"match-rules\": ${JSON.stringify(DEFAULT_MATCH_RULES, null, 4)}`;\n}\n\n// webpieces-disable no-any-unknown -- generic type guard over an opaque JSON value\nfunction isStringArray(value: unknown): value is string[] {\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n return Array.isArray(value) && value.every((v: unknown) => typeof v === 'string');\n}\n\n// Compile a pattern to validate it; returns the error message, or undefined when it compiles.\nfunction regexError(pattern: string): string | undefined {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n // Constructed only to validate the syntax; the object is intentionally discarded.\n void new RegExp(pattern);\n return undefined;\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n } catch (err: unknown) {\n const error = toError(err);\n return error.message;\n }\n}\n\n// One entry of the match-rules array, validated field-by-field (see validateGate for the pattern).\n// webpieces-disable no-any-unknown -- one match-rule entry from opaque consumer JSON, validated field-by-field\nfunction validateMatchRule(entry: unknown, index: number): string[] {\n if (typeof entry !== 'object' || entry === null || Array.isArray(entry)) {\n return [\n `[match-rules] entry[${index}] must be an object { name, patterns, mainMessage, mode, turnOffRuleUntilEpoch, turnOffRuleWhileOnBranch, ... }.`,\n ];\n }\n // webpieces-disable no-any-unknown -- narrowing one opaque match-rule entry from consumer JSON\n const e = entry as Record<string, unknown>;\n const label = typeof e['name'] === 'string' ? `\"${e['name']}\"` : `entry[${index}]`;\n const errors: string[] = [];\n\n if (typeof e['name'] !== 'string' || e['name'].trim() === '')\n errors.push(\n `[match-rules] entry[${index}].name must be a non-empty string (it is the disable token and report label).`,\n );\n\n if (!isStringArray(e['patterns']) || e['patterns'].length === 0) {\n errors.push(`[match-rules] ${label}.patterns must be a non-empty string[] of regexes.`);\n } else {\n e['patterns'].forEach((p: string, pi: number) => {\n const rxErr = regexError(p);\n if (rxErr)\n errors.push(\n `[match-rules] ${label}.patterns[${pi}] is not a valid regex: ${rxErr}`,\n );\n });\n }\n\n if (typeof e['mainMessage'] !== 'string' || e['mainMessage'].trim() === '')\n errors.push(`[match-rules] ${label}.mainMessage must be a non-empty string.`);\n\n if (\n typeof e['mode'] !== 'string' ||\n !MODIFIED_CODE_MODES.includes(e['mode'] as (typeof MODIFIED_CODE_MODES)[number])\n )\n errors.push(\n `[match-rules] ${label}.mode must be one of: ${MODIFIED_CODE_MODES.join(', ')}.`,\n );\n\n errors.push(...validateMatchRuleHatches(e, label));\n\n if (e['options'] !== undefined && !isStringArray(e['options']))\n errors.push(`[match-rules] ${label}.options must be a string[] (omit if not needed).`);\n if (e['allowedPaths'] !== undefined && !isStringArray(e['allowedPaths']))\n errors.push(\n `[match-rules] ${label}.allowedPaths must be a string[] of globs (omit if not needed).`,\n );\n if (e['disableAllowed'] !== undefined && typeof e['disableAllowed'] !== 'boolean')\n errors.push(`[match-rules] ${label}.disableAllowed must be a boolean.`);\n\n return errors;\n}\n\n/**\n * Validate the REQUIRED top-level `match-rules` array (client-authored content guards). MISSING →\n * one error printing the ready-to-paste `no-fetch` example (add at least this; more can follow).\n * Present-but-`[]` → allowed (a conscious opt-out, matching pr-gate mode:OFF / excludePaths []).\n * Otherwise every entry is validated field-by-field (each regex compile-checked) plus name\n * uniqueness. Copy-paste-friendly errors; never throws — same contract as validatePrGateSection.\n */\n// webpieces-disable no-any-unknown -- `section` is opaque consumer JSON until narrowed below\nexport function validateMatchRulesSection(section: unknown): string[] {\n if (section === undefined || section === null) {\n return [\n `[match-rules] Not configured in webpieces.config.json. Add this REQUIRED top-level array — ` +\n `seed it with the no-fetch guard below (you can add more entries: no-moment, no-lodash-chain, …):\\n\\n${matchRulesExample()}`,\n ];\n }\n if (!Array.isArray(section)) {\n return [\n `[match-rules] Must be an array of content-guard objects. Example:\\n\\n${matchRulesExample()}`,\n ];\n }\n\n const errors: string[] = [];\n const seen = new Set<string>();\n for (let i = 0; i < section.length; i += 1) {\n errors.push(...validateMatchRule(section[i], i));\n // webpieces-disable no-any-unknown -- reading the name off an opaque entry only to dedupe\n const name = (section[i] as Record<string, unknown> | null)?.['name'];\n if (typeof name === 'string') {\n if (seen.has(name))\n errors.push(\n `[match-rules] duplicate entry name \"${name}\" — each match-rule name must be unique.`,\n );\n seen.add(name);\n }\n }\n return errors;\n}\n\n// webpieces-disable no-any-unknown -- explicit match-rule JSON is checked field by field\n// webpieces-disable no-function-outside-class -- pure validation helper\nfunction validateMatchRuleHatches(e: Record<string, unknown>, label: string): string[] {\n const errors: string[] = [];\n // Both escape hatches are REQUIRED on every match-rule too (same as keyed rules), so they are always\n // visible. turnOffRuleUntilEpoch: number (0 = active; a future unix-epoch in seconds = temporarily\n // off). turnOffRuleWhileOnBranch: string | null (null = always on; an EXACT branch name — matched\n // with ===, never as a glob — disables the rule while that branch is checked out).\n if (typeof e['turnOffRuleUntilEpoch'] !== 'number') {\n errors.push(\n `[match-rules] ${label}.turnOffRuleUntilEpoch must be a number (0 = active; future unix-epoch seconds = temporarily off).`,\n );\n } else {\n const capError = epochCapError(`[match-rules] ${label}`, e['turnOffRuleUntilEpoch']);\n if (capError) errors.push(capError);\n }\n if (\n !(\n e['turnOffRuleWhileOnBranch'] === null ||\n typeof e['turnOffRuleWhileOnBranch'] === 'string'\n )\n )\n errors.push(\n `[match-rules] ${label}.turnOffRuleWhileOnBranch must be a string or null (null = no branch / always on; a string is an EXACT branch name, globs are not supported).`,\n );\n\n // The old escape-hatch names were renamed — flag them precisely.\n for (const oldKey of new PolicyFieldConstraints().retiredFields()) {\n if (oldKey in e)\n errors.push(\n renamedFieldError(`[match-rules] ${label}`, oldKey, new PolicyFieldConstraints().renamedField(oldKey)!),\n );\n }\n\n return errors;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"validate-config.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/validate-config.ts"],"names":[],"mappings":";;;AAwSA,0DA8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,iEAAiE;IACjE,KAAK,MAAM,MAAM,IAAI,IAAI,iDAAsB,EAAE,CAAC,aAAa,EAAE,EAAE,CAAC;QAChE,IAAI,MAAM,IAAI,CAAC;YACX,MAAM,CAAC,IAAI,CACP,iBAAiB,CAAC,iBAAiB,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,iDAAsB,EAAE,CAAC,YAAY,CAAC,MAAM,CAAE,CAAC,CAC1G,CAAC;IACV,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { PolicyFieldConstraints } from './policy-field-constraints';\nexport { MAX_TURN_OFF_EPOCH_DAYS } from './policy-field-constraints';\nimport { FieldDef, RetiredConfigKey } from '@webpieces/rules-sdk';\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nimport { RulePackRegistry } from './rule-pack-registry';\nimport { allRuleNames } from './rule-schemas';\nimport { recommendedSeedModeFor, isGradualMode } from './seed-entry';\nimport { MODIFIED_CODE_MODES } from '@webpieces/rules-sdk';\nimport {\n validateChecklistsSection,\n validateDevDeploySection,\n validateLandPrSection,\n validateNoGateSaltRationale,\n validateReviewerAgentKeys,\n} from './pr-gate-section-validators';\nimport { retiredEntry, retiredKeyError, retiredRuleFor } from './retired-config-keys';\nimport { PRUNE_UNKNOWN_COMMAND } from './constants';\n\n// Re-exported so the isolated validate-checklist-docs target keeps importing it from here.\nexport { validateChecklistsSection };\n// Re-exported from their new homes: this module was the historical entry point for both.\nexport { allRuleNames } from './rule-schemas';\nexport { recommendedSeedMode, recommendedSeedModeFor, seedEntryForRule } from './seed-entry';\nimport { DEFAULT_MATCH_RULES } from './match-rules-config';\nimport { toError } from '@webpieces/tooling-common/to-error';\n\n/**\n * The longest a `turnOffRuleUntilEpoch` may reach into the future: ONE WEEK — a hard ceiling, not the\n * advice. The advice every cure gives (#1318) is the BRANCH hatch first, and the epoch only as a last\n * resort set to now + 1 hour, because it is REPO-WIDE while it lasts (see TurnOffRuleCure).\n *\n * DELIBERATELY ASYMMETRIC with turnOffRuleWhileOnBranch, which has NO cap and must not get one. The epoch\n * hatch is REPO-WIDE while it lasts, so a long window shelters every unrelated change that lands inside it\n * (a fleet repo was found with max-file-lines/max-method-lines switched off until 2026-10-01 — 43 days\n * out, six times this cap). The branch hatch fires only on ONE exact branch name — a big refactor\n * legitimately runs 35+ days, and capping that would only interrupt the one branch that opted in.\n */\n\n/**\n * Reject a `turnOffRuleUntilEpoch` more than MAX_TURN_OFF_EPOCH_DAYS into the future.\n *\n * A PAST epoch is always valid: it is inert (it skips nothing), and every existing config is full of them.\n * The BOUNDARY is inclusive — exactly MAX_TURN_OFF_EPOCH_DAYS out is accepted, only strictly beyond it is\n * refused — so a config written as \"now + 7 days\" is never rejected by the second it took to save.\n */\n// webpieces-disable no-function-outside-class -- module-scope validator helper, matching every other check in this file\nfunction epochCapError(label: string, value: number): string | null {\n return new PolicyFieldConstraints().epochError(label, value);\n}\n\nfunction valueHint(def: FieldDef, key?: string): string {\n // The two universal escape hatches, REQUIRED on every rule so they're always visible. Spell out the\n // \"off\" value so a fresh config seeds them in the active/no-op state (0 / null), not a placeholder.\n if (key === 'turnOffRuleUntilEpoch')\n return '0 (0 = active; future unix-epoch seconds = temporarily off)';\n if (key === 'turnOffRuleWhileOnBranch')\n return 'null (null = always on; an EXACT branch name — no globs — disables the rule while that branch is checked out)';\n return def.enumValues\n ? `\"${def.enumValues.join(' | ')}\"`\n : def.type === 'string[]'\n ? '[\"<string>\", ...]'\n : def.type === 'object[]'\n ? objectListHint(def)\n : def.type === 'number'\n ? '<number>'\n : def.type === 'boolean'\n ? '<boolean>'\n : '\"<string>\"';\n}\n\n/** `[{ \"paths\": [\"<string>\", ...], \"suffixes\": [\"<string>\", ...] }, ...]` — one element spelled out from its schema. */\n// webpieces-disable no-function-outside-class -- module-scope sibling of valueHint\nfunction objectListHint(def: FieldDef): string {\n const schema: Readonly<Record<string, FieldDef>> = def.elementSchema ?? {};\n const fields = Object.keys(schema)\n .filter((key: string) => !schema[key].optional)\n .map((key: string) => `\"${key}\": ${valueHint(schema[key], key)}`);\n return `[{ ${fields.join(', ')} }, ...]`;\n}\n\n/**\n * A config key whose schema is absent from every explicitly selected owner manifest. THE FALLBACK: it fires for any name the table in retired-config-keys.ts does not\n * know, which very much includes RETIRED names on a tree whose validator predates the retirement — the\n * ordinary linked-worktree layout, where the worktree is on one release and the parent checkout that\n * supplies the hook's resolution is on an older one. So this text has to be useful with NO table entry.\n *\n * DELETION LEADS, and it is not a hedge. A key the running validator has no schema for controls nothing:\n * every code path that would read it is keyed off the schema. Leaving it is dead config that reads as live\n * config, and for a retired key deleting it is the entire fix.\n *\n * This message used to lead with `pnpm install` instead, on the theory that the key might be valid and the\n * validator merely stale. Two things are wrong with that. First, it CONTRADICTED the banner this error is\n * printed inside, which states outright that `pnpm install` cannot help — one output, two opposite orders.\n * Second, the premise is already handled upstream: the shim's version-drift guard compares the pin against\n * the installed version and denies every tool call BEFORE exec'ing this validator, with its own message and\n * its own cure. If this text is on screen, that guard found no drift. The pin therefore appears here only as\n * a secondary note, so a valid-but-newer key is never dropped without the reader being told the case exists.\n */\nfunction unknownRuleError(ruleName: string): string {\n return (\n `[${ruleName}] Unknown rule — the running @webpieces validator has no selected owner schema for it. A key no validator knows controls NOTHING, so ` +\n `DELETE the \"${ruleName}\" key from the direct policy-ID map in its declared owner config file. ` +\n `Run \\`${PRUNE_UNKNOWN_COMMAND}\\` to remove unknown entries from declared owner files mechanically. ` +\n `It may be RETIRED: a newer release can move ` +\n `a setting out of this file entirely, in which case deleting the key here is the WHOLE fix. ` +\n `MACHINE-LOCAL settings in particular now live in ~/.webpieces/config.json under \"experimental\" — ` +\n `an optional file tracked by no repo, whose absence is the default behaviour — so if ` +\n `\"${ruleName}\" is one of those, delete it here and set it there. Secondary, and rare: a key is ` +\n `valid-but-unlearned when package.json pins an @webpieces OLDER than this config was written for, ` +\n `and the version-drift guard reports THAT separately with its own cure (bump the pin) before this ` +\n `validator ever runs — so it is not what you are looking at.`\n );\n}\n\n/** Schema advice names the selected owner rather than a retired root section. */\nclass RuleConfigAdvice {\n constructor(private readonly registry: RulePackRegistry) {}\n\n private rolloutTip(schema: Readonly<Record<string, FieldDef>>): string {\n const modes = schema['mode']?.enumValues ?? [];\n // Same source of truth as the seeder; only a GRADUAL recommendation gets the rollout prose, so a\n // rule whose recommendation falls through to ON/RUN_EVERY_TIME/OFF prints no tip (as before).\n const recommended = recommendedSeedModeFor(modes);\n if (!isGradualMode(recommended)) return '';\n const optOut = modes.includes('OFF') ? ' Set \"mode\": \"OFF\" to opt out entirely.' : '';\n return (\n `\\n\\n💡 Recommended: start with \"mode\": \"${recommended}\" — it enforces only on what you ` +\n `actually change, so the rule rolls out gradually (existing code stays grandfathered until ` +\n `you next touch that project/file/method).${optOut}`\n );\n }\n\n missingRuleSnippet(ruleName: string, schema: Readonly<Record<string, FieldDef>>): string {\n // Required fields go in the copy-paste entry. The two universal escape hatches\n // (turnOffRuleUntilEpoch / turnOffRuleWhileOnBranch) are now REQUIRED, so they land in that block —\n // which is the whole point: every seeded rule shows both hatches. Optional fields are listed separately.\n const fields = Object.keys(schema);\n const required = fields.filter((f: string) => !schema[f].optional);\n const optional = fields.filter((f: string) => schema[f].optional);\n\n const requiredLines = required.map((f: string) => ` \"${f}\": ${valueHint(schema[f], f)}`);\n const owner = this.registry.ownerOf(ruleName);\n let out =\n `[${ruleName}] Not configured in the declared owner config file for ${owner}. ` +\n `Add this entry directly to that file's policy-ID map\\n` +\n `(choose values appropriate for your project):\\n\\n` +\n ` \"${ruleName}\": {\\n${requiredLines.join(',\\n')}\\n }`;\n\n if (optional.length > 0) {\n const optionalLines = optional.map(\n (f: string) => ` \"${f}\": ${valueHint(schema[f], f)}`,\n );\n out +=\n `\\n\\nOptional fields you may add to this rule (omit if not needed):\\n` +\n `${optionalLines.join(',\\n')}`;\n }\n out += this.rolloutTip(schema);\n return out;\n }\n}\n\n// Fields we DELETED from a rule's schema, keyed by \"<rule>.<field>\". The generic unknown-field error\n// (\"Unknown field ... Valid fields: [...]\") is correct but doesn't say WHY the field vanished, so an AI\n// might re-add it. These hints explain the removal so the only action left is to delete the key.\n\n// Universal field renames (apply to EVERY rule/guard AND every match-rule, unlike the per-rule\n// RETIRED_FIELD_HINTS). When an entry still uses the old escape-hatch name, the generic unknown-field\n// error is replaced with a precise \"renamed to X — rename it\" instruction so the fix is mechanical.\n\n\n// The renamed-field message shared by keyed rules and match-rules.\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nfunction renamedFieldError(scope: string, oldKey: string, newKey: string): string {\n return `${scope} Unknown field \"${oldKey}\" — it was renamed to \"${newKey}\". Rename it (the value carries over unchanged; for the branch hatch, use null when there is no branch).`;\n}\n\n/**\n * Field-level errors for ONE configured rule entry: unknown/renamed/retired keys, type and enum\n * mismatches, and the two-week cap on turnOffRuleUntilEpoch.\n *\n * Extracted out of validateWebpiecesConfig purely so that function stays inside max-method-lines; it is\n * the same checks in the same order.\n */\n// webpieces-disable no-any-unknown -- one config entry as opaque JSON; every field is typed-checked below\n// webpieces-disable no-function-outside-class -- module-scope validator helper, matching every other check in this file\nfunction fieldErrors(\n ruleName: string,\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n entry: Record<string, unknown>,\n schema: Readonly<Record<string, FieldDef>>,\n registry: RulePackRegistry,\n): string[] {\n const errors: string[] = [];\n for (const [key, value] of Object.entries(entry)) {\n const fieldDef = schema[key];\n if (!fieldDef) {\n const renamedTo = new PolicyFieldConstraints().renamedField(key);\n if (renamedTo) {\n errors.push(renamedFieldError(`[${ruleName}]`, key, renamedTo));\n continue;\n }\n const retiredHint = registry\n .migrations()\n .find(\n (entry: RetiredConfigKey) =>\n entry.scope === 'field' && entry.key === `${ruleName}.${key}`,\n )?.instruction;\n const suffix = retiredHint ? ` ${retiredHint}` : '';\n errors.push(\n `[${ruleName}] Unknown field \"${key}\". Valid fields: [${Object.keys(schema).join(', ')}].${suffix}`,\n );\n continue;\n }\n // A nullable field (e.g. turnOffRuleWhileOnBranch) accepts JSON null in addition to its type.\n if (value === null && fieldDef.nullable) continue;\n if (fieldDef.type === 'string[]' || fieldDef.type === 'object[]') {\n errors.push(...arrayFieldErrors(`[${ruleName}] \"${key}\"`, value, fieldDef));\n } else if (typeof value !== fieldDef.type) {\n errors.push(`[${ruleName}] \"${key}\" must be ${fieldDef.type}, got ${typeof value}.`);\n } else if (fieldDef.enumValues && !fieldDef.enumValues.includes(value as string)) {\n errors.push(\n `[${ruleName}] \"${key}\" = \"${value}\" is not valid. Must be one of: ${fieldDef.enumValues.join(', ')}.`,\n );\n } else if (key === 'turnOffRuleUntilEpoch') {\n const capError = epochCapError(`[${ruleName}]`, value as number);\n if (capError) errors.push(capError);\n } else if (\n ruleName === 'branch-state-guard' &&\n (key === 'maxCommitsBehind' || key === 'featureBranchMaxCommitsBehind') &&\n (!Number.isInteger(value) || (value as number) < 0)\n ) {\n errors.push(`[branch-state-guard] \"${key}\" must be a non-negative integer.`);\n }\n }\n return errors;\n}\n\n/**\n * Errors for one array-typed field (`string[]` / `object[]`): the element type, `nonEmpty`, and — for\n * `object[]` — every element against the field's `elementSchema` (unknown keys, missing required keys,\n * and each element field checked recursively). `label` is `[rule] \"field\"`, extended per element\n * (`[rule] \"entries\"[0].suffixes`) so an error names the exact spot to edit.\n */\n// webpieces-disable no-any-unknown -- a config field value is opaque JSON until this checks its shape\n// webpieces-disable no-function-outside-class -- module-scope validator helper, matching every other check in this file\n// webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\nfunction arrayFieldErrors(label: string, value: unknown, def: FieldDef): string[] {\n const isObjects = def.type === 'object[]';\n // webpieces-disable no-any-unknown -- one list element as opaque JSON; this line is what checks its shape\n const elementOk = (v: unknown): boolean =>\n isObjects\n ? typeof v === 'object' && v !== null && !Array.isArray(v)\n : typeof v === 'string';\n if (!Array.isArray(value) || !value.every(elementOk)) {\n const shape = isObjects ? 'a list of objects' : 'string[]';\n return [\n `${label} must be ${shape}, got ${Array.isArray(value) ? 'a list holding something else' : typeof value}.`,\n ];\n }\n if (def.nonEmpty && value.length === 0) {\n return [\n `${label} must not be empty — an empty list judges nothing while reading as configured. Add ${valueHint(def)}.` +\n (def.emptyInstruction === undefined ? '' : ` ${def.emptyInstruction}`),\n ];\n }\n if (!isObjects || def.elementSchema === undefined) return [];\n const errors: string[] = [];\n const schema = def.elementSchema;\n // webpieces-disable no-any-unknown -- an element's fields are opaque JSON until checked against its schema below\n value.forEach((element: Record<string, unknown>, index: number) => {\n const at = `${label}[${index}]`;\n for (const key of Object.keys(element)) {\n if (!(key in schema))\n errors.push(\n `${at} Unknown field \"${key}\". Valid fields: [${Object.keys(schema).join(', ')}].`,\n );\n }\n for (const [key, fieldDef] of Object.entries(schema)) {\n if (!(key in element)) {\n if (!fieldDef.optional)\n errors.push(\n `${at} Missing required field \"${key}\". Add ${key}: ${valueHint(fieldDef, key)}.`,\n );\n } else if (fieldDef.type === 'string[]' || fieldDef.type === 'object[]') {\n errors.push(...arrayFieldErrors(`${at}.${key}`, element[key], fieldDef));\n } else if (typeof element[key] !== fieldDef.type) {\n errors.push(`${at}.${key} must be ${fieldDef.type}, got ${typeof element[key]}.`);\n }\n }\n });\n return errors;\n}\n\n// webpieces-disable no-any-unknown -- rawRules values are opaque JSON; each field is validated individually\nexport function validateWebpiecesConfig(\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n rawRules: Record<string, Record<string, unknown>>,\n registry: RulePackRegistry,\n): string[] {\n const errors: string[] = [];\n const advice = new RuleConfigAdvice(registry);\n\n // Check field-level correctness for rules that are present\n for (const [ruleName, entry] of Object.entries(rawRules)) {\n const schema = registry.hasRule(ruleName) ? registry.schemaFor(ruleName) : undefined;\n if (!schema) {\n if (\n registry.isSafeguard(ruleName) &&\n !registry\n .migrations()\n .some(\n (entry: RetiredConfigKey) =>\n entry.scope === 'rule' && entry.key === ruleName,\n )\n ) {\n errors.push(\n `[${ruleName}] is a cataloged safeguard, not a configurable policy. Delete its config entry; fixed safety cannot be disabled.`,\n );\n continue;\n }\n // A name we KNOW is retired beats the generic unknown-rule message, because only the table\n // knows WHERE the setting went — a rename carries its value over, and a bare \"delete it\"\n // would throw that value away. Client packs must not reuse a retired canonical ID.\n const retired = retiredRuleFor(ruleName, registry);\n if (retired) {\n errors.push(retiredKeyError(retired));\n continue;\n }\n // Client policies require a schema from an explicitly selected owner.\n errors.push(unknownRuleError(ruleName));\n continue;\n }\n errors.push(...fieldErrors(ruleName, entry, schema, registry));\n // Required fields must actually be present. Until now the loop above only checked\n // fields that WERE present, so an entry like `{}` (or one missing `mode` /\n // `turnOffRuleUntilEpoch`) slipped through. Every non-optional schema field is mandatory.\n for (const [key, fieldDef] of Object.entries(schema)) {\n if (!fieldDef.optional && !(key in entry)) {\n errors.push(\n `[${ruleName}] Missing required field \"${key}\". Add ${key}: ${valueHint(fieldDef, key)}.`,\n );\n }\n }\n }\n\n // Every built-in rule must be explicitly configured — no silent defaults.\n // When a new rule is added to the framework, this check surfaces it immediately\n // with a ready-to-copy snippet so AI can configure it in one pass.\n for (const ruleName of registry.ruleIds()) {\n const schema = registry.schemaFor(ruleName);\n if (!(ruleName in rawRules)) {\n errors.push(advice.missingRuleSnippet(ruleName, schema));\n }\n }\n\n return errors;\n}\n\nexport { validatePrGateSection } from './validate-pr-gate';\n\nfunction excludePathsExample(): string {\n return '\"excludePaths\": [\"repositories/**\"]';\n}\n\n// A glob list: must be a string[] (may be empty). `key` names it for the error.\n// webpieces-disable no-any-unknown -- `value` is opaque consumer JSON until narrowed here\nfunction validateExcludeList(value: unknown, key: string): string[] {\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n if (!(Array.isArray(value) && value.every((p: unknown) => typeof p === 'string'))) {\n return [`[excludePaths] \"${key}\" must be a string[] of glob paths (use [] for none).`];\n }\n return [];\n}\n\n/**\n * Validate the REQUIRED top-level `excludePaths` block: ONE glob list of paths NO rule judges — hook\n * rules, file-scoped guards and the build's code rules alike (#1253: the code-rules runtime applies it\n * too, through RuleFileScope). Required so every client upgrading is\n * forced to declare it (as [] to keep today's behavior, or with real paths). Returns copy-paste\n * friendly errors and never throws — same contract as validatePrGateSection.\n *\n * The two-list object form `{ \"rules\": [...], \"guards\": [...] }` is RETIRED, not tolerated. It used to be\n * accepted and silently unioned, which is why this repo's own config sat on the dead shape for releases: an\n * accepted shape is never migrated. Rejecting it cannot wedge a consumer — editing webpieces.config.json is\n * always permitted, even while it is invalid. See retired-config-keys.ts.\n */\n// webpieces-disable no-any-unknown -- `section` is opaque consumer JSON until narrowed below\nexport function validateExcludePaths(section: unknown): string[] {\n if (section === undefined || section === null) {\n return [\n `[excludePaths] Not configured in webpieces.config.json. Add this REQUIRED block ` +\n `(use an empty array to keep enforcing everywhere):\\n\\n ${excludePathsExample()}`,\n ];\n }\n if (Array.isArray(section)) return validateExcludeList(section, 'excludePaths');\n if (typeof section !== 'object') {\n return [\n `[excludePaths] Must be a string[] of glob paths. Example:\\n\\n ${excludePathsExample()}`,\n ];\n }\n // webpieces-disable no-any-unknown -- narrowing the opaque excludePaths section from consumer JSON\n const s = section as Record<string, unknown>;\n // The retired two-list object. One table row owns the message for either key present.\n const retired = retiredEntry('rules', '[excludePaths]');\n if (retired && (s['rules'] !== undefined || s['guards'] !== undefined)) {\n return [`${retiredKeyError(retired)}\\n\\n ${excludePathsExample()}`];\n }\n return [\n `[excludePaths] Must be a string[] of glob paths. Example:\\n\\n ${excludePathsExample()}`,\n ];\n}\n\n// ---------------------------------------------------------------------------\n// match-rules — a new top-level ARRAY section (parallel to pr-gate/excludePaths). Each entry is a\n// client-authored content guard (raw-regex patterns + message + scoping). Validated structurally here\n// the same way pr-gate's `gates` are, because an array of objects can't be expressed in FieldDef schema.\n// ---------------------------------------------------------------------------\n\nfunction matchRulesExample(): string {\n return `\"match-rules\": ${JSON.stringify(DEFAULT_MATCH_RULES, null, 4)}`;\n}\n\n// webpieces-disable no-any-unknown -- generic type guard over an opaque JSON value\nfunction isStringArray(value: unknown): value is string[] {\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n return Array.isArray(value) && value.every((v: unknown) => typeof v === 'string');\n}\n\n// Compile a pattern to validate it; returns the error message, or undefined when it compiles.\nfunction regexError(pattern: string): string | undefined {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n // Constructed only to validate the syntax; the object is intentionally discarded.\n void new RegExp(pattern);\n return undefined;\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n } catch (err: unknown) {\n const error = toError(err);\n return error.message;\n }\n}\n\n// One entry of the match-rules array, validated field-by-field (see validateGate for the pattern).\n// webpieces-disable no-any-unknown -- one match-rule entry from opaque consumer JSON, validated field-by-field\nfunction validateMatchRule(entry: unknown, index: number): string[] {\n if (typeof entry !== 'object' || entry === null || Array.isArray(entry)) {\n return [\n `[match-rules] entry[${index}] must be an object { name, patterns, mainMessage, mode, turnOffRuleUntilEpoch, turnOffRuleWhileOnBranch, ... }.`,\n ];\n }\n // webpieces-disable no-any-unknown -- narrowing one opaque match-rule entry from consumer JSON\n const e = entry as Record<string, unknown>;\n const label = typeof e['name'] === 'string' ? `\"${e['name']}\"` : `entry[${index}]`;\n const errors: string[] = [];\n\n if (typeof e['name'] !== 'string' || e['name'].trim() === '')\n errors.push(\n `[match-rules] entry[${index}].name must be a non-empty string (it is the disable token and report label).`,\n );\n\n if (!isStringArray(e['patterns']) || e['patterns'].length === 0) {\n errors.push(`[match-rules] ${label}.patterns must be a non-empty string[] of regexes.`);\n } else {\n e['patterns'].forEach((p: string, pi: number) => {\n const rxErr = regexError(p);\n if (rxErr)\n errors.push(\n `[match-rules] ${label}.patterns[${pi}] is not a valid regex: ${rxErr}`,\n );\n });\n }\n\n if (typeof e['mainMessage'] !== 'string' || e['mainMessage'].trim() === '')\n errors.push(`[match-rules] ${label}.mainMessage must be a non-empty string.`);\n\n if (\n typeof e['mode'] !== 'string' ||\n !MODIFIED_CODE_MODES.includes(e['mode'] as (typeof MODIFIED_CODE_MODES)[number])\n )\n errors.push(\n `[match-rules] ${label}.mode must be one of: ${MODIFIED_CODE_MODES.join(', ')}.`,\n );\n\n errors.push(...validateMatchRuleHatches(e, label));\n\n if (e['options'] !== undefined && !isStringArray(e['options']))\n errors.push(`[match-rules] ${label}.options must be a string[] (omit if not needed).`);\n if (e['allowedPaths'] !== undefined && !isStringArray(e['allowedPaths']))\n errors.push(\n `[match-rules] ${label}.allowedPaths must be a string[] of globs (omit if not needed).`,\n );\n if (e['disableAllowed'] !== undefined && typeof e['disableAllowed'] !== 'boolean')\n errors.push(`[match-rules] ${label}.disableAllowed must be a boolean.`);\n\n return errors;\n}\n\n/**\n * Validate the REQUIRED top-level `match-rules` array (client-authored content guards). MISSING →\n * one error printing the ready-to-paste `no-fetch` example (add at least this; more can follow).\n * Present-but-`[]` → allowed (a conscious opt-out, matching pr-gate mode:OFF / excludePaths []).\n * Otherwise every entry is validated field-by-field (each regex compile-checked) plus name\n * uniqueness. Copy-paste-friendly errors; never throws — same contract as validatePrGateSection.\n */\n// webpieces-disable no-any-unknown -- `section` is opaque consumer JSON until narrowed below\nexport function validateMatchRulesSection(section: unknown): string[] {\n if (section === undefined || section === null) {\n return [\n `[match-rules] Not configured in webpieces.config.json. Add this REQUIRED top-level array — ` +\n `seed it with the no-fetch guard below (you can add more entries: no-moment, no-lodash-chain, …):\\n\\n${matchRulesExample()}`,\n ];\n }\n if (!Array.isArray(section)) {\n return [\n `[match-rules] Must be an array of content-guard objects. Example:\\n\\n${matchRulesExample()}`,\n ];\n }\n\n const errors: string[] = [];\n const seen = new Set<string>();\n for (let i = 0; i < section.length; i += 1) {\n errors.push(...validateMatchRule(section[i], i));\n // webpieces-disable no-any-unknown -- reading the name off an opaque entry only to dedupe\n const name = (section[i] as Record<string, unknown> | null)?.['name'];\n if (typeof name === 'string') {\n if (seen.has(name))\n errors.push(\n `[match-rules] duplicate entry name \"${name}\" — each match-rule name must be unique.`,\n );\n seen.add(name);\n }\n }\n return errors;\n}\n\n// webpieces-disable no-any-unknown -- explicit match-rule JSON is checked field by field\n// webpieces-disable no-function-outside-class -- pure validation helper\nfunction validateMatchRuleHatches(e: Record<string, unknown>, label: string): string[] {\n const errors: string[] = [];\n // Both escape hatches are REQUIRED on every match-rule too (same as keyed rules), so they are always\n // visible. turnOffRuleUntilEpoch: number (0 = active; a future unix-epoch in seconds = temporarily\n // off). turnOffRuleWhileOnBranch: string | null (null = always on; an EXACT branch name — matched\n // with ===, never as a glob — disables the rule while that branch is checked out).\n if (typeof e['turnOffRuleUntilEpoch'] !== 'number') {\n errors.push(\n `[match-rules] ${label}.turnOffRuleUntilEpoch must be a number (0 = active; future unix-epoch seconds = temporarily off).`,\n );\n } else {\n const capError = epochCapError(`[match-rules] ${label}`, e['turnOffRuleUntilEpoch']);\n if (capError) errors.push(capError);\n }\n if (\n !(\n e['turnOffRuleWhileOnBranch'] === null ||\n typeof e['turnOffRuleWhileOnBranch'] === 'string'\n )\n )\n errors.push(\n `[match-rules] ${label}.turnOffRuleWhileOnBranch must be a string or null (null = no branch / always on; a string is an EXACT branch name, globs are not supported).`,\n );\n\n // The old escape-hatch names were renamed — flag them precisely.\n for (const oldKey of new PolicyFieldConstraints().retiredFields()) {\n if (oldKey in e)\n errors.push(\n renamedFieldError(`[match-rules] ${label}`, oldKey, new PolicyFieldConstraints().renamedField(oldKey)!),\n );\n }\n\n return errors;\n}\n"]}
|
|
@@ -103,6 +103,7 @@ the interval, so neither can launch a refresh on every call.
|
|
|
103
103
|
| 7 | `B R` | on `main`, current or within `maxCommitsBehind` | 1 allow | — |
|
|
104
104
|
| 8 | `B R E` | on a branch whose PR is **already merged** | 4 block | `git fetch origin main && git checkout -b <new> origin/main` |
|
|
105
105
|
| 9 | `B R E` | no fork point with `origin/main`, or `origin/main` moved and collided with your files | 4 block | `pnpm wp-start-update`, or `pnpm wp-start-upsert-pr` when a PR is open |
|
|
106
|
+
| 15 | `E` | on a feature branch farther behind `origin/main` than `featureBranchMaxCommitsBehind` | 4 block | `pnpm wp-start-update`, or `pnpm wp-start-upsert-pr` when a PR is open |
|
|
106
107
|
| 10 | `B R E` | healthy feature branch | 1 allow | — |
|
|
107
108
|
|
|
108
109
|
Rows 1-5 need **no cache** and fire on call #1: rows 1, 2 and 4 are text matches, row 3 is a
|
|
@@ -114,6 +115,12 @@ Row 11 is numbered after row 10 and PRINTED between 5 and 6, and that is not a m
|
|
|
114
115
|
numbers are identity — they are logged as `row=` and cited here — so renumbering 6-10 to slot it in
|
|
115
116
|
would silently re-point every reference. L1 does the same with its row 8.
|
|
116
117
|
|
|
118
|
+
Row 15 is the FEATURE-branch twin of rows 6/7 (issue #1431): the refresher caches how far the
|
|
119
|
+
branch tip is behind `origin/main` (`headCommitsBehind`), and above the REQUIRED
|
|
120
|
+
`branch-state-guard.featureBranchMaxCommitsBehind` (seeded 20) Write/Edit are blocked — Read and
|
|
121
|
+
Bash stay open so the cure runs. Unknown distance allows; a `/hotfix/` branch is exempt by row 14,
|
|
122
|
+
an unvalidated merge marker by row 3, and `main` itself belongs to rows 5-7.
|
|
123
|
+
|
|
117
124
|
### The one rule that explains the tool column
|
|
118
125
|
|
|
119
126
|
**`B` tracks `E` everywhere except on `main`, where `B` tracks `R` instead — rows 5, 6 and 7.**
|
|
@@ -199,6 +206,7 @@ under. So a case whose row is wrong fails the build rather than misinforming a r
|
|
|
199
206
|
| 3 | `git checkout main` after a merge, to start the next piece of work | about to land on whatever local `main` you last had — 157 commits behind, in the incident | BLOCK: decided from command TEXT alone, before the checkout, because the only `main` this could measure is the one it is about to leave | `pnpm wp-sync-main` — checkout, pull, reap dead branches/worktrees, sweep orphan directories, in one command (hand-rolled, the pull must be in the SAME command as the checkout) |
|
|
200
207
|
| 4 | The same command inside a linked worktree, where `git checkout main` fatals anyway | linked worktree — `main` is already checked out in the primary clone | BLOCK, and the message prints the worktree form rather than a cure git would refuse | `git fetch origin main`, then work off `origin/main` |
|
|
201
208
|
| 5 | Reading and editing conflicted files during a 3-point merge, on a branch row 9 would block | merge markers on disk — `pnpm wp-start-update` has run and not finished | EXEMPT: everything is permitted, which is exactly what lets row 9 be strict | Resolve the conflicts, then `pnpm wp-finish-upsert-pr` |
|
|
209
|
+
| 35 | Editing conflicted files during the update that row 15 demanded, while the branch is still counted far behind `origin/main` | merge marker unvalidated in this tree, and cached `headCommitsBehind` above `featureBranchMaxCommitsBehind` | EXEMPT, logged `ALLOW_EXEMPT`: the update row 15 asks for is the thing in progress, so blocking its edits would wedge the cure | Resolve the conflicts, then finish the merge |
|
|
202
210
|
| 6 | `git status` / `gh pr view` while blocked, to work out where you are | any state — orientation is never "working here" | ALLOW: metadata tells you where you are without putting stale file CONTENT in context | None needed |
|
|
203
211
|
| 7 | `git stash` when `git checkout -b <new> origin/main` refuses because `origin/main` touched the same files you edited | on a stale `main` or a merged branch, dirty tree, with an overlapping upstream change | ALLOW: the cure for the row that blocked you must itself never be blocked — and this is the residual step that makes rows 6 and 8 safe to block on a dirty tree | None needed — then re-run the checkout and `git stash pop` |
|
|
204
212
|
| 28 | `gh pr close 123`, `gh pr comment`, `gh api …` or a `curl` while parked on a stale `main` or a merged branch | blocked state, running something that touches GitHub or a URL and nothing in this tree | ALLOW: the skip list asks one question — does this read or write repo CONTENT? `gh` talks to GitHub and `curl`/`wget` talk to a network, so the branch state has nothing to say about them. The forms that write a local file (`gh repo clone`, `gh pr checkout`, `curl -o`, any `> file`) are excluded, and `gh pr create`/`merge` remain governed by their own guards | None needed |
|
|
@@ -224,6 +232,8 @@ under. So a case whose row is wrong fails the build rather than misinforming a r
|
|
|
224
232
|
| 19 | A shell-only session sails through on a merged branch | merged branch, Bash only — both FILE guards are file-scoped, so Bash reached neither | BLOCK: `merged-branch-bash-guard` exists because `branchAlreadyMerged` was being computed and logged on that very path, then thrown away | `git fetch origin main && git checkout -b <new> origin/main` |
|
|
225
233
|
| 20 | Your branch and `origin/main` share no merge base — usually a branch cut from a squashed-away tip | no fork point | BLOCK: nothing built on this branch can be reasoned about relative to main | `pnpm wp-start-update`, or `pnpm wp-start-upsert-pr` when a PR is open |
|
|
226
234
|
| 21 | `origin/main` moved and changed the same files you edited | main-moved collision | BLOCK — and row 3 then exempts everything once the merge starts, which is what makes this safe | `pnpm wp-start-update`, resolve, `pnpm wp-finish-upsert-pr` |
|
|
235
|
+
| 33 | An Edit on a branch cut weeks ago, 40 commits behind `origin/main`, with no PR yet | feature branch, cached `headCommitsBehind` above `featureBranchMaxCommitsBehind` (seeded 20), no open PR | BLOCK Write/Edit only: building and testing against old pins, old generated graphs and old neighbouring code is how a branch meets main at PR time with the largest possible merge. An unknown distance allows | `pnpm wp-start-update` |
|
|
236
|
+
| 34 | The same Edit on a branch whose PR is already open | feature branch beyond the threshold, an open PR tracks it | BLOCK, and the message prints ONLY the PR flow, because `pnpm wp-start-update` refuses when a PR tracks the branch | `pnpm wp-start-upsert-pr` |
|
|
227
237
|
| 22 | Ordinary work on a branch cut from a current `origin/main` | healthy feature branch | ALLOW — the state every other row exists to push you back into | None needed |
|
|
228
238
|
| 23 | `stale-main-bash-guard` sees a feature branch and hands off | not on `main` — state B belongs to `merged-branch-bash-guard` | ALLOW: the same verdict about the same tree, logged by the guard that is not responsible for it | None needed |
|
|
229
239
|
|