@webpieces/rules-config 0.4.984 → 0.4.986

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.
@@ -1 +1 @@
1
- {"version":3,"file":"validate-pr-gate.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/validate-pr-gate.ts"],"names":[],"mappings":";;AAyGA,sDA8DC;AAvKD,iEAA6D;AAC7D,6EAAkL;AAGlL,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,KAAK,CAAU,CAAC;AAC7C,6FAA6F;AAC7F,yFAAyF;AACzF,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAU,CAAC;AAEtD,iGAAiG;AACjG,kGAAkG;AAClG,+FAA+F;AAC/F,MAAM,eAAe,GACjB,mBAAmB,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK;IACtD,8FAA8F;IAC9F,+FAA+F;IAC/F,kGAAkG;IAClG,oEAAoE;IACpE,kGAAkG;IAClG,2GAA2G;IAC3G,mGAAmG;IACnG,yEAAyE;IACzE,8FAA8F;IAC9F,iGAAiG,CAAC;AAEtG,gGAAgG;AAChG,6FAA6F;AAC7F,2GAA2G;AAC3G,SAAS,aAAa;IAClB,OAAO,CACH,kBAAkB;QAClB,qBAAqB;QACrB,0IAA0I;QAC1I,kBAAkB;QAClB,8GAA8G;QAC9G,UAAU;QACV,wGAAwG;QACxG,iGAAiG;QACjG,iFAAiF;QACjF,yHAAyH;QACzH,SAAS;QACT,KAAK,CACR,CAAC;AACN,CAAC;AAED,qGAAqG;AACrG,kCAAkC;AAClC,uGAAuG;AACvG,8GAA8G;AAC9G,SAAS,oBAAoB,CAAC,KAAc;IACxC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO;YACH,oFAAoF;SACvF,CAAC;IACN,CAAC;IACD,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,KAAK,IAAI,CAAC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AAC,CAA0B,EAAE,QAA4B;IACtF,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,iGAAiG;IACjG,8FAA8F;IAC9F,oDAAoD;IACpD,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,KAAK,EAAE,CAAC;QACtB,MAAM,GAAG,GAAG,CAAC,CAAC,cAAc,CAAC,CAAC;QAC9B,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YAC/C,MAAM,CAAC,IAAI,CACP,0FAA0F;gBACtF,oGAAoG,CAC3G,CAAC;QACN,CAAC;QACD,MAAM,EAAE,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC;QAC1B,IAAI,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,EAAE,CAAC;YACtB,MAAM,CAAC,IAAI,CAAC,iDAAiD,eAAe,EAAE,CAAC,CAAC;QACpF,CAAC;aAAM,IACH,OAAO,EAAE,KAAK,QAAQ;YACtB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,EAA0C,CAAC,EAC3E,CAAC;YACC,MAAM,CAAC,IAAI,CAAC,4BAA4B,MAAM,CAAC,EAAE,CAAC,mBAAmB,eAAe,EAAE,CAAC,CAAC;QAC5F,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,GAAG,IAAA,sDAAyB,EAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { ConfigDocumentation } from './config-documentation';\nimport { validateChecklistsSection, validateDevDeploySection, validateLandPrSection, validateNoGateSaltRationale, validateReviewerAgentKeys } from './pr-gate-section-validators';\nimport * as fs from 'fs';\nimport * as path from 'path';\nconst PR_GATE_MODES = ['ON', 'OFF'] as const;\n// Optional — omitted means DETECT. Kept inline (like prGateExample) to avoid a load-config ↔\n// pr-gate-config import cycle; the canonical list + semantics live in pr-gate-config.ts.\nconst PR_GATE_MERGE_MODES = ['AUTO', 'NONE'] as const;\n\n// Spelled out because the choice is a POLICY decision with a consequence the chooser cannot see:\n// only the AUTO path can put the compact risk/flags body in main's history, because a UI merge is\n// composed from the repo's squash_merge_commit_title/message settings, which the tooling pins.\nconst MERGE_MODE_HELP =\n `Must be one of: ${PR_GATE_MERGE_MODES.join(', ')}.\\n` +\n ` \"AUTO\" — wp-finish-upsert-pr lands the PR: it squash-merges when mergeable, else enables\\n` +\n ` GitHub auto-merge, both with an explicit --subject/--body-file so main's history\\n` +\n ` gets the PR title + the compact risk/flags body. Needs allow_auto_merge on the repo\\n` +\n ` (gh api repos/{owner}/{repo} --jq .allow_auto_merge).\\n` +\n ` \"NONE\" — wp-finish-upsert-pr only opens/updates the PR without attempting to merge. It still\\n` +\n ` lands the compact body: the PR DESCRIPTION *is* that body, and stage \\u2462 keeps the repo's\\n` +\n ` squash_merge_commit_title/message pinned to PR_TITLE/PR_BODY so a UI merge copies it\\n` +\n ` verbatim (SquashSettingsEnforcer). Nothing to set by hand.\\n` +\n ` This is tooling behavior, not an authorization requirement. Honor existing user\\n` +\n ` instructions, including $full-cycle; use pnpm wp-land-pr when landing was requested.`;\n\n// Copy-paste example for the top-level `pr-gate` block (sibling of `rules`). Kept inline rather\n// than imported from pr-gate-config.ts to avoid a load-config ↔ pr-gate-config import cycle.\n// webpieces-disable no-function-outside-class -- pure example renderer beside the public command validator\nfunction prGateExample(): string {\n return (\n ` \"pr-gate\": {\\n` +\n ` \"mode\": \"ON\",\\n` +\n ` \"buildCommand\": \"<command CI runs to validate a PR, e.g. pnpm nx affected --target=ci --base=$(git merge-base origin/main HEAD)>\",\\n` +\n ` \"gates\": [\\n` +\n ` { \"name\": \"API Changed\", \"patterns\": [\"libraries/apis/**\", \"**/*Api.ts\"], \"warningColor\": \"yellow\" }\\n` +\n ` ],\\n` +\n ` \"reviewerAgents\": 1, // REQUIRED — 0 disables reviews; positive values cap subagents per round\\n` +\n ` \"maxReviewerRounds\": 2, // REQUIRED positive integer — caps complete global review rounds\\n` +\n ` \"checklists\": [ // OPTIONAL — per-area review, each against its own doc\\n` +\n ` { \"id\": \"db-migrations\", \"doc\": \".claude/review/db-migrations.md\", \"patterns\": [\"**/*.sql\"], \"required\": true }\\n` +\n ` ]\\n` +\n ` }`\n );\n}\n\n// The `gates` array: dashboard-only warning flags. Extracted from validatePrGateSection to keep that\n// method inside the length limit.\n// webpieces-disable no-any-unknown -- `value` is the opaque consumer `gates` value until narrowed here\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nfunction validateGatesSection(value: unknown): string[] {\n if (!Array.isArray(value)) {\n return [\n `[pr-gate] \"gates\" must be an array of { name, patterns, warningColor, disabled? }.`,\n ];\n }\n const errors: string[] = [];\n for (let i = 0; i < value.length; i += 1) {\n errors.push(...validateGate(value[i], i));\n }\n return errors;\n}\n\n// webpieces-disable no-any-unknown -- one gate entry from opaque consumer JSON, validated field-by-field\n// webpieces-disable no-function-outside-class -- pure field validator beside the public command validator\nfunction validateGate(gate: unknown, index: number): string[] {\n if (typeof gate !== 'object' || gate === null) {\n return [\n `[pr-gate] gates[${index}] must be an object { name, patterns, warningColor, disabled? }.`,\n ];\n }\n // webpieces-disable no-any-unknown -- narrowing one opaque gate object from consumer JSON\n const g = gate as Record<string, unknown>;\n const errors: string[] = [];\n if (typeof g['name'] !== 'string')\n errors.push(`[pr-gate] gates[${index}].name must be a string.`);\n if (\n !Array.isArray(g['patterns']) ||\n // webpieces-disable no-any-unknown -- opaque config patterns are checked before use\n !g['patterns'].every((p: unknown) => typeof p === 'string')\n )\n errors.push(`[pr-gate] gates[${index}].patterns must be string[].`);\n if (g['warningColor'] === undefined)\n errors.push(\n `[pr-gate] gates[${index}].warningColor is required — set it to \"yellow\" or \"red\" (green is implicit when nothing matches).`,\n );\n else if (g['warningColor'] !== 'yellow' && g['warningColor'] !== 'red')\n errors.push(\n `[pr-gate] gates[${index}].warningColor must be \"yellow\" or \"red\" (green is implicit when nothing matches).`,\n );\n if (g['disabled'] !== undefined && typeof g['disabled'] !== 'boolean')\n errors.push(\n `[pr-gate] gates[${index}].disabled must be a boolean (example/inactive gate kept in the file).`,\n );\n return errors;\n}\n\n/**\n * Validate the top-level `pr-gate` section. It is REQUIRED (a client that opts out sets mode \"OFF\").\n * `buildCommand` is required unless mode is \"OFF\". Returns human-readable, copy-paste-friendly errors\n * — never throws. The pr-gate block lives outside the FieldDef-driven `rules` schema because its\n * nested `gates`/`checklists` arrays can't be expressed there, so they get structural validation here.\n * `repoRoot` (when known) lets the `checklists[].docs` existence check run.\n */\n// webpieces-disable no-any-unknown -- `section` is opaque consumer JSON until narrowed below\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nexport function validatePrGateSection(section: unknown, repoRoot?: string): string[] {\n if (section === undefined || section === null) {\n return [\n `[pr-gate] Not configured in webpieces.config.json. Add this block under the \"commands\" ` +\n `section (set \"mode\": \"OFF\" to opt out):\\n\\n${prGateExample()}`,\n ];\n }\n if (typeof section !== 'object' || Array.isArray(section)) {\n return [`[pr-gate] Must be an object. Example:\\n\\n${prGateExample()}`];\n }\n // webpieces-disable no-any-unknown -- narrowing the opaque pr-gate section from consumer JSON\n const s = section as Record<string, unknown>;\n const errors: string[] = new ConfigDocumentation().inlineErrors(section, '[pr-gate]');\n\n if (!('mode' in s)) {\n errors.push(\n `[pr-gate] Missing required field \"mode\". Must be one of: ${PR_GATE_MODES.join(', ')}.`,\n );\n } else if (\n typeof s['mode'] !== 'string' ||\n !PR_GATE_MODES.includes(s['mode'] as (typeof PR_GATE_MODES)[number])\n ) {\n errors.push(\n `[pr-gate] \"mode\" = \"${String(s['mode'])}\" is not valid. Must be one of: ${PR_GATE_MODES.join(', ')}.`,\n );\n }\n\n errors.push(...validateActiveGatePolicy(s, repoRoot));\n\n if ('gates' in s) errors.push(...validateGatesSection(s['gates']));\n\n // Optional extension point: company review checklists, as an ARRAY right here in the config. Absent ⇒\n // none. The removed { doc } manifest shape is rejected with the exact migration edit.\n if ('checklists' in s) errors.push(...validateChecklistsSection(s['checklists'], repoRoot));\n\n // Optional server-token salt. Absent ⇒ no token minted, CI enforcement is a no-op. Present ⇒ must be\n // a non-empty string (an empty salt would mint a token anyone can forge from a known-empty secret).\n if ('gateSalt' in s) {\n const salt = s['gateSalt'];\n if (typeof salt !== 'string' || salt.trim() === '') {\n errors.push(\n `[pr-gate] \"gateSalt\" must be a non-empty string — it is the shared secret the gate token is HMAC'd with. Omit the key entirely to disable server-side token enforcement.`,\n );\n }\n }\n\n // Optional: what happens to the LOCAL branch once its PR lands. Absent ⇒ \"archive-tag\".\n if ('landPr' in s) errors.push(...validateLandPrSection(s['landPr']));\n\n // Optional: where wp-push-dev publishes the disposable copy. Absent ⇒ \"dev-include\" / \"dev\".\n if ('devDeploy' in s) errors.push(...validateDevDeploySection(s['devDeploy']));\n\n errors.push(...validateNoGateSaltRationale(s));\n\n // Optional: publish reviewer output as a PR comment (defaults true). Must be a boolean when present.\n if ('checklistComments' in s && typeof s['checklistComments'] !== 'boolean') {\n errors.push(\n `[pr-gate] \"checklistComments\" must be a boolean (defaults to true; set false to keep the PR body-only).`,\n );\n }\n\n return errors;\n}\n\n\n// webpieces-disable no-any-unknown -- explicit command configuration JSON is checked field by field\n// webpieces-disable no-function-outside-class -- pure validation helper\nfunction validateActiveGatePolicy(s: Record<string, unknown>, repoRoot: string | undefined): string[] {\n const errors: string[] = [];\n // buildCommand and mergeMode are both required whenever the gate is active (mode !== OFF). There\n // is deliberately NO default for mergeMode: whether the tooling may land your PRs is a policy\n // decision, and either guess is wrong for somebody.\n if (s['mode'] !== 'OFF') {\n const cmd = s['buildCommand'];\n if (typeof cmd !== 'string' || cmd.trim() === '') {\n errors.push(\n `[pr-gate] Missing required field \"buildCommand\" — the command CI runs to validate a PR. ` +\n `Add e.g. \"buildCommand\": \"pnpm nx affected --target=ci --base=$(git merge-base origin/main HEAD)\".`,\n );\n }\n const mm = s['mergeMode'];\n if (!('mergeMode' in s)) {\n errors.push(`[pr-gate] Missing required field \"mergeMode\". ${MERGE_MODE_HELP}`);\n } else if (\n typeof mm !== 'string' ||\n !PR_GATE_MERGE_MODES.includes(mm as (typeof PR_GATE_MERGE_MODES)[number])\n ) {\n errors.push(`[pr-gate] \"mergeMode\" = \"${String(mm)}\" is not valid. ${MERGE_MODE_HELP}`);\n }\n errors.push(...validateReviewerAgentKeys(s, repoRoot));\n }\n\n return errors;\n}\n"]}
1
+ {"version":3,"file":"validate-pr-gate.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/validate-pr-gate.ts"],"names":[],"mappings":";;AAyGA,sDA8DC;AAvKD,iEAA6D;AAC7D,6EAAkL;AAGlL,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,KAAK,CAAU,CAAC;AAC7C,6FAA6F;AAC7F,yFAAyF;AACzF,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAU,CAAC;AAEtD,iGAAiG;AACjG,kGAAkG;AAClG,+FAA+F;AAC/F,MAAM,eAAe,GACjB,mBAAmB,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK;IACtD,8FAA8F;IAC9F,+FAA+F;IAC/F,kGAAkG;IAClG,oEAAoE;IACpE,kGAAkG;IAClG,2GAA2G;IAC3G,mGAAmG;IACnG,yEAAyE;IACzE,8FAA8F;IAC9F,iGAAiG,CAAC;AAEtG,gGAAgG;AAChG,6FAA6F;AAC7F,2GAA2G;AAC3G,SAAS,aAAa;IAClB,OAAO,CACH,kBAAkB;QAClB,qBAAqB;QACrB,0IAA0I;QAC1I,kBAAkB;QAClB,8GAA8G;QAC9G,UAAU;QACV,wGAAwG;QACxG,iGAAiG;QACjG,iFAAiF;QACjF,yHAAyH;QACzH,SAAS;QACT,KAAK,CACR,CAAC;AACN,CAAC;AAED,qGAAqG;AACrG,kCAAkC;AAClC,uGAAuG;AACvG,8GAA8G;AAC9G,SAAS,oBAAoB,CAAC,KAAc;IACxC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC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C,IAAI,CACP,yGAAyG,CAC5G,CAAC;IACN,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC;AAGD,oGAAoG;AACpG,wEAAwE;AACxE,SAAS,wBAAwB,CAAC,CAA0B,EAAE,QAA4B;IACtF,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,iGAAiG;IACjG,8FAA8F;IAC9F,oDAAoD;IACpD,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,KAAK,EAAE,CAAC;QACtB,MAAM,GAAG,GAAG,CAAC,CAAC,cAAc,CAAC,CAAC;QAC9B,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YAC/C,MAAM,CAAC,IAAI,CACP,0FAA0F;gBACtF,oGAAoG,CAC3G,CAAC;QACN,CAAC;QACD,MAAM,EAAE,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC;QAC1B,IAAI,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,EAAE,CAAC;YACtB,MAAM,CAAC,IAAI,CAAC,iDAAiD,eAAe,EAAE,CAAC,CAAC;QACpF,CAAC;aAAM,IACH,OAAO,EAAE,KAAK,QAAQ;YACtB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,EAA0C,CAAC,EAC3E,CAAC;YACC,MAAM,CAAC,IAAI,CAAC,4BAA4B,MAAM,CAAC,EAAE,CAAC,mBAAmB,eAAe,EAAE,CAAC,CAAC;QAC5F,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,GAAG,IAAA,sDAAyB,EAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { ConfigDocumentation } from './config-documentation';\nimport { validateChecklistsSection, validateDevDeploySection, validateLandPrSection, validateNoGateSaltRationale, validateReviewerAgentKeys } from './pr-gate-section-validators';\nimport * as fs from 'fs';\nimport * as path from 'path';\nconst PR_GATE_MODES = ['ON', 'OFF'] as const;\n// Optional — omitted means DETECT. Kept inline (like prGateExample) to avoid a load-config ↔\n// pr-gate-config import cycle; the canonical list + semantics live in pr-gate-config.ts.\nconst PR_GATE_MERGE_MODES = ['AUTO', 'NONE'] as const;\n\n// Spelled out because the choice is a POLICY decision with a consequence the chooser cannot see:\n// only the AUTO path can put the compact risk/flags body in main's history, because a UI merge is\n// composed from the repo's squash_merge_commit_title/message settings, which the tooling pins.\nconst MERGE_MODE_HELP =\n `Must be one of: ${PR_GATE_MERGE_MODES.join(', ')}.\\n` +\n ` \"AUTO\" — wp-finish-upsert-pr lands the PR: it squash-merges when mergeable, else enables\\n` +\n ` GitHub auto-merge, both with an explicit --subject/--body-file so main's history\\n` +\n ` gets the PR title + the compact risk/flags body. Needs allow_auto_merge on the repo\\n` +\n ` (gh api repos/{owner}/{repo} --jq .allow_auto_merge).\\n` +\n ` \"NONE\" — wp-finish-upsert-pr only opens/updates the PR without attempting to merge. It still\\n` +\n ` lands the compact body: the PR DESCRIPTION *is* that body, and stage \\u2462 keeps the repo's\\n` +\n ` squash_merge_commit_title/message pinned to PR_TITLE/PR_BODY so a UI merge copies it\\n` +\n ` verbatim (SquashSettingsEnforcer). Nothing to set by hand.\\n` +\n ` This is tooling behavior, not an authorization requirement. Honor existing user\\n` +\n ` instructions, including $full-cycle; use pnpm wp-land-pr when landing was requested.`;\n\n// Copy-paste example for the top-level `pr-gate` block (sibling of `rules`). Kept inline rather\n// than imported from pr-gate-config.ts to avoid a load-config ↔ pr-gate-config import cycle.\n// webpieces-disable no-function-outside-class -- pure example renderer beside the public command validator\nfunction prGateExample(): string {\n return (\n ` \"pr-gate\": {\\n` +\n ` \"mode\": \"ON\",\\n` +\n ` \"buildCommand\": \"<command CI runs to validate a PR, e.g. pnpm nx affected --target=ci --base=$(git merge-base origin/main HEAD)>\",\\n` +\n ` \"gates\": [\\n` +\n ` { \"name\": \"API Changed\", \"patterns\": [\"libraries/apis/**\", \"**/*Api.ts\"], \"warningColor\": \"yellow\" }\\n` +\n ` ],\\n` +\n ` \"reviewerAgents\": 1, // REQUIRED — 0 disables reviews; positive values cap subagents per round\\n` +\n ` \"maxReviewerRounds\": 2, // REQUIRED positive integer — caps complete global review rounds\\n` +\n ` \"checklists\": [ // OPTIONAL — per-area review, each against its own doc\\n` +\n ` { \"id\": \"db-migrations\", \"doc\": \".claude/review/db-migrations.md\", \"patterns\": [\"**/*.sql\"], \"required\": true }\\n` +\n ` ]\\n` +\n ` }`\n );\n}\n\n// The `gates` array: dashboard-only warning flags. Extracted from validatePrGateSection to keep that\n// method inside the length limit.\n// webpieces-disable no-any-unknown -- `value` is the opaque consumer `gates` value until narrowed here\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nfunction validateGatesSection(value: unknown): string[] {\n if (!Array.isArray(value)) {\n return [\n `[pr-gate] \"gates\" must be an array of { name, patterns, warningColor, disabled? }.`,\n ];\n }\n const errors: string[] = [];\n for (let i = 0; i < value.length; i += 1) {\n errors.push(...validateGate(value[i], i));\n }\n return errors;\n}\n\n// webpieces-disable no-any-unknown -- one gate entry from opaque consumer JSON, validated field-by-field\n// webpieces-disable no-function-outside-class -- pure field validator beside the public command validator\nfunction validateGate(gate: unknown, index: number): string[] {\n if (typeof gate !== 'object' || gate === null) {\n return [\n `[pr-gate] gates[${index}] must be an object { name, patterns, warningColor, disabled? }.`,\n ];\n }\n // webpieces-disable no-any-unknown -- narrowing one opaque gate object from consumer JSON\n const g = gate as Record<string, unknown>;\n const errors: string[] = [];\n if (typeof g['name'] !== 'string')\n errors.push(`[pr-gate] gates[${index}].name must be a string.`);\n if (\n !Array.isArray(g['patterns']) ||\n // webpieces-disable no-any-unknown -- opaque config patterns are checked before use\n !g['patterns'].every((p: unknown) => typeof p === 'string')\n )\n errors.push(`[pr-gate] gates[${index}].patterns must be string[].`);\n if (g['warningColor'] === undefined)\n errors.push(\n `[pr-gate] gates[${index}].warningColor is required — set it to \"yellow\" or \"red\" (green is implicit when nothing matches).`,\n );\n else if (g['warningColor'] !== 'yellow' && g['warningColor'] !== 'red')\n errors.push(\n `[pr-gate] gates[${index}].warningColor must be \"yellow\" or \"red\" (green is implicit when nothing matches).`,\n );\n if (g['disabled'] !== undefined && typeof g['disabled'] !== 'boolean')\n errors.push(\n `[pr-gate] gates[${index}].disabled must be a boolean (example/inactive gate kept in the file).`,\n );\n return errors;\n}\n\n/**\n * Validate the top-level `pr-gate` section. It is REQUIRED (a client that opts out sets mode \"OFF\").\n * `buildCommand` is required unless mode is \"OFF\". Returns human-readable, copy-paste-friendly errors\n * — never throws. The pr-gate block lives outside the FieldDef-driven `rules` schema because its\n * nested `gates`/`checklists` arrays can't be expressed there, so they get structural validation here.\n * `repoRoot` (when known) lets the `checklists[].docs` existence check run.\n */\n// webpieces-disable no-any-unknown -- `section` is opaque consumer JSON until narrowed below\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nexport function validatePrGateSection(section: unknown, repoRoot?: string): string[] {\n if (section === undefined || section === null) {\n return [\n `[pr-gate] Not configured in webpieces.config.json. Add this block under the \"commands\" ` +\n `section (set \"mode\": \"OFF\" to opt out):\\n\\n${prGateExample()}`,\n ];\n }\n if (typeof section !== 'object' || Array.isArray(section)) {\n return [`[pr-gate] Must be an object. Example:\\n\\n${prGateExample()}`];\n }\n // webpieces-disable no-any-unknown -- narrowing the opaque pr-gate section from consumer JSON\n const s = section as Record<string, unknown>;\n const errors: string[] = new ConfigDocumentation().inlineErrors(section, '[pr-gate]');\n\n if (!('mode' in s)) {\n errors.push(\n `[pr-gate] Missing required field \"mode\". Must be one of: ${PR_GATE_MODES.join(', ')}.`,\n );\n } else if (\n typeof s['mode'] !== 'string' ||\n !PR_GATE_MODES.includes(s['mode'] as (typeof PR_GATE_MODES)[number])\n ) {\n errors.push(\n `[pr-gate] \"mode\" = \"${String(s['mode'])}\" is not valid. Must be one of: ${PR_GATE_MODES.join(', ')}.`,\n );\n }\n\n errors.push(...validateActiveGatePolicy(s, repoRoot));\n\n if ('gates' in s) errors.push(...validateGatesSection(s['gates']));\n\n // Optional extension point: company review checklists, as an ARRAY right here in the config. Absent ⇒\n // none. The removed { doc } manifest shape is rejected with the exact migration edit.\n if ('checklists' in s) errors.push(...validateChecklistsSection(s['checklists'], repoRoot));\n\n // Optional server-token salt. Absent ⇒ no token minted, CI enforcement is a no-op. Present ⇒ must be\n // a non-empty string (an empty salt would mint a token anyone can forge from a known-empty secret).\n if ('gateSalt' in s) {\n const salt = s['gateSalt'];\n if (typeof salt !== 'string' || salt.trim() === '') {\n errors.push(\n `[pr-gate] \"gateSalt\" must be a non-empty string — it is the shared secret the gate token is HMAC'd with. Omit the key entirely to disable server-side token enforcement.`,\n );\n }\n }\n\n // Optional: what happens to the LOCAL branch once its PR lands. Absent ⇒ \"archive-tag\".\n if ('landPr' in s) errors.push(...validateLandPrSection(s['landPr']));\n\n // Optional: where wp-finish-push-dev publishes the disposable copy. Absent ⇒ \"dev-include\" / \"dev\".\n if ('devDeploy' in s) errors.push(...validateDevDeploySection(s['devDeploy']));\n\n errors.push(...validateNoGateSaltRationale(s));\n\n // Optional: publish reviewer output as a PR comment (defaults true). Must be a boolean when present.\n if ('checklistComments' in s && typeof s['checklistComments'] !== 'boolean') {\n errors.push(\n `[pr-gate] \"checklistComments\" must be a boolean (defaults to true; set false to keep the PR body-only).`,\n );\n }\n\n return errors;\n}\n\n\n// webpieces-disable no-any-unknown -- explicit command configuration JSON is checked field by field\n// webpieces-disable no-function-outside-class -- pure validation helper\nfunction validateActiveGatePolicy(s: Record<string, unknown>, repoRoot: string | undefined): string[] {\n const errors: string[] = [];\n // buildCommand and mergeMode are both required whenever the gate is active (mode !== OFF). There\n // is deliberately NO default for mergeMode: whether the tooling may land your PRs is a policy\n // decision, and either guess is wrong for somebody.\n if (s['mode'] !== 'OFF') {\n const cmd = s['buildCommand'];\n if (typeof cmd !== 'string' || cmd.trim() === '') {\n errors.push(\n `[pr-gate] Missing required field \"buildCommand\" — the command CI runs to validate a PR. ` +\n `Add e.g. \"buildCommand\": \"pnpm nx affected --target=ci --base=$(git merge-base origin/main HEAD)\".`,\n );\n }\n const mm = s['mergeMode'];\n if (!('mergeMode' in s)) {\n errors.push(`[pr-gate] Missing required field \"mergeMode\". ${MERGE_MODE_HELP}`);\n } else if (\n typeof mm !== 'string' ||\n !PR_GATE_MERGE_MODES.includes(mm as (typeof PR_GATE_MERGE_MODES)[number])\n ) {\n errors.push(`[pr-gate] \"mergeMode\" = \"${String(mm)}\" is not valid. ${MERGE_MODE_HELP}`);\n }\n errors.push(...validateReviewerAgentKeys(s, repoRoot));\n }\n\n return errors;\n}\n"]}
@@ -77,17 +77,23 @@ put reusable config instructions in this guide's source template. Generated file
77
77
 
78
78
  ## The dev-deploy build: `commands.push-dev.buildCommand`
79
79
 
80
- `wp-push-dev` merges `origin/dev` into a throwaway branch and runs this command on the merged tree before
81
- it publishes a dev copy; `wp-build-dev` runs the same check without publishing. It has NO default — which
80
+ `wp-build-push-dev` first runs `commands.pr-gate.buildCommand` on your branch alone (the code rules judge it
81
+ against main, exactly as the PR gate will), then merges `origin/dev` into a throwaway branch, runs
82
+ `pnpm install`, and runs this command on the merged tree; `wp-finish-push-dev` publishes only the copy it
83
+ verified. It has NO default — which
82
84
  build vouches for a dev publish is this repo's decision. The section is optional (a repo that never
83
- publishes to a shared dev server needs none), but those two commands refuse without it, and a present
85
+ publishes to a shared dev server needs none), but `wp-build-push-dev` refuses without it, and a present
84
86
  `push-dev` section must carry a non-empty `buildCommand`:
85
87
 
86
88
  ```json
87
- "commands": { "push-dev": { "buildCommand": "pnpm nx affected --target=ci --base=origin/dev --head=HEAD" } }
89
+ "commands": { "push-dev": { "buildCommand": "pnpm nx affected -t build test --base=origin/dev --head=HEAD" } }
88
90
  ```
89
91
 
90
- Choose a command that builds only what differs from `origin/dev`, so it finishes in a minute or two.
92
+ Choose a command that **compiles and tests only** what differs from `origin/dev`, so it finishes in a minute
93
+ or two — and that runs **no code rules** (not an nx `ci` target, which runs `architecture:validate-code`).
94
+ The merged tree holds every other developer's published copy, so rules run there judge their code as your
95
+ change: one copy's oversized method would fail everybody else's publish. The rules already ran against main
96
+ in the first build.
91
97
 
92
98
  ## Merge automation and existing authorization
93
99
 
@@ -189,11 +189,11 @@ There are **two destinations**, and they are opposites. Answer this first:
189
189
  | You want… | Use | It touches |
190
190
  |---|---|---|
191
191
  | the change **landed on `main`** (prod-quality, reviewed) | the PR flow below | your branch, a PR, eventually `main` |
192
- | the change **running on the shared dev server**, no PR | `pnpm wp-push-dev` | a disposable copy, and nothing else |
192
+ | the change **running on the shared dev server**, no PR | `pnpm wp-start-push-dev` → `wp-build-push-dev` → `wp-finish-push-dev` | your branch (brought up to date with main), then a disposable copy |
193
193
 
194
194
  **Do NOT open a PR to `main` just to test something in a shared dev environment.** That is the single
195
195
  most expensive mistake available here: it ships unreviewed work toward production to answer a question
196
- the dev environment exists to answer. `pnpm wp-push-dev` is the answer to "get my branch onto dev", and
196
+ the dev environment exists to answer. That three-stage flow is the answer to "get my branch onto dev", and
197
197
  the push guard's block message will say so when your `git push` targets the dev refs.
198
198
 
199
199
  See "Publishing to the shared dev server" below. Everything from here to that section is the **main**
@@ -303,50 +303,86 @@ snapshots are never loaded as active summaries; a new PR requires its own author
303
303
  The numbers in a `--delete-*` flag are the numbers printed on the SAME run — wp-cleanup renumbers
304
304
  from a fresh scan every time, and a number past the end of the block stops the run rather than
305
305
  deleting the wrong ref. An explicit flag always beats the terminal sniff.
306
- 8. **`pnpm wp-push-dev`** — check this branch against `origin/dev`, build it, then publish a **disposable
307
- copy** of it so a shared dev environment can build it. No PR, and your feature branch is never moved.
308
- See below.
309
- 9. **`pnpm wp-finish-push-dev`** — finish after you resolved the conflicts `wp-push-dev` stopped on. Only
310
- needed on the conflict path; a clean run finalizes itself.
311
- 10. **`pnpm wp-build-dev`** — the same check against `origin/dev` and the same build, WITHOUT publishing.
306
+ 8. **`pnpm wp-start-push-dev`** — stage ① of publishing to the shared dev server: bring this branch up to
307
+ date with `origin/main` (the same 3-point merge as `wp-start-update`), ONLY if it is behind. No PR is
308
+ opened. See below.
309
+ 9. **`pnpm wp-build-push-dev`** — stage ②: build this branch alone against main
310
+ (`commands.pr-gate.buildCommand`, code rules ON), then check it against `origin/dev` on a throwaway merge,
311
+ `pnpm install`, and run `commands.push-dev.buildCommand` (compile + tests only). Publishes nothing.
312
+ 10. **`pnpm wp-finish-push-dev`** — stage ③: publish the copy stage ② verified as `dev-include/<branch>`.
313
+ Also `--list` (what is in the pool) and `--remove` (the rollback).
312
314
 
313
315
  ## Publishing to the shared dev server (no PR, nothing lands on main)
314
316
 
315
- Some repos deploy a shared `dev` branch that is a **build artifact, not a source of truth**: CI resets it
316
- to `origin/main`, merges every published copy, builds the composed tree, and force-pushes — every run.
317
- Nobody ever checks it out, so the wipe is a non-event, and it can never be stale.
317
+ Some repos deploy a shared `dev` branch that is a **build artifact, not a source of truth**: CI composes
318
+ it from `origin/main` plus every published copy and deploys it. Nobody ever checks it out.
319
+
320
+ Publishing is three stages, the same shape as the PR flow:
318
321
 
319
322
  ```bash
320
- pnpm wp-push-dev # check against origin/dev, build, publish this branch as dev-include/<your-branch>
321
- pnpm wp-build-dev # the same check and build, publishing nothing
322
- pnpm wp-push-dev --list # what is currently in the pool
323
- pnpm wp-push-dev --remove # take your branch back out (this is the rollback)
323
+ pnpm wp-start-push-dev # ① 3-point merge from origin/main — ONLY if your branch is behind it
324
+ # conflict → resolve with /wp-merge, then go on to ②
325
+ pnpm wp-build-push-dev # ② build your branch vs main (rules ON), then merge origin/dev into a
326
+ # throwaway, pnpm install, run the dev build (compile + tests only)
327
+ # conflict → resolve on the throwaway, `git add`, re-run ②
328
+ pnpm wp-finish-push-dev # ③ publish the copy ② verified as dev-include/<your-branch>
329
+
330
+ pnpm wp-finish-push-dev --list # what is currently in the pool
331
+ pnpm wp-finish-push-dev --remove # take your branch back out (this is the rollback)
324
332
  ```
325
333
 
326
334
  `--remove` is for rolling back a copy that broke dev. When you are done testing, or after your PR lands,
327
335
  leave the copy alone: the business-day reset removes it. Re-publishing replaces your own copy, so you
328
336
  don't need to remove it first.
329
337
 
330
- **What `wp-push-dev` does before it publishes.** It fetches `origin/dev`, merges it into a THROWAWAY
331
- branch (`<your-branch>DevResolve`, never your branch), and runs `commands.push-dev.buildCommand` on the
332
- merged tree. Only when the merge is clean (or you resolved it) and that build is green does it publish.
333
- So a conflict or a broken build is found on your machine, in a minute, instead of after the shared
334
- composition fails. The build output goes to a log file; read the `FullLog :` path it prints rather than
335
- re-running it.
336
-
337
- **What it publishes is never that merge.** The copy is your branch exactly as it is, plus — only when
338
+ **① Why every copy starts from the latest main.** A branch forked from an old main builds against a
339
+ `node_modules` that is missing whatever main added since, and dev already contains it — so the dev build
340
+ fails for reasons that have nothing to do with your change. `wp-start-push-dev` runs the SAME 3-point
341
+ merge as `wp-start-update` / `wp-start-upsert-pr`, and does nothing when the branch already contains
342
+ `origin/main`. It REWRITES your branch (that is expected). With no open PR it pushes the rewrite to
343
+ `origin/<your-branch>` like `wp-start-update`; with an open PR it keeps it local like
344
+ `wp-start-upsert-pr`, and the PR is updated by your next `wp-start-upsert-pr` → `wp-finish-upsert-pr`. A
345
+ conflict is resolved with `/wp-merge` on your own branch; `wp-build-push-dev` then validates and
346
+ finalizes that merge before anything else. `wp-build-push-dev` refuses a branch that is still behind
347
+ `origin/main`, naming `wp-start-push-dev`.
348
+
349
+ **② What `wp-build-push-dev` checks — two builds, two questions.**
350
+
351
+ | build | tree | runs | answers |
352
+ |---|---|---|---|
353
+ | 1 | your branch alone (it contains the latest main) | `commands.pr-gate.buildCommand` — code rules ON, affected vs main | would the PR gate let this land? |
354
+ | 2 | your branch merged with `origin/dev`, on a throwaway | `commands.push-dev.buildCommand` — compile + tests ONLY, affected vs `origin/dev` | does everyone's code still compile and pass together? |
355
+
356
+ Build 1 is the same thing the PR gate will judge, so you learn early what would block landing, and the
357
+ rules only ever judge what will actually land on main. Build 2 must NOT run the code rules: the merged tree
358
+ holds every other developer's copy, and diffed against main their code would be judged as yours — one
359
+ copy's oversized method would fail everybody else's publish. Its compile/test is mostly nx cache hits from
360
+ build 1.
361
+
362
+ For build 2 it fetches `origin/dev`, merges it into a THROWAWAY branch (`<your-branch>DevResolve`, never
363
+ your branch), runs `pnpm install` — other copies on dev can add workspace packages main does not have yet —
364
+ and runs `commands.push-dev.buildCommand` on the merged tree. So a conflict or a broken build is found on
365
+ your machine instead of after the shared composition fails. Each build's output goes to a log file; read
366
+ the `FullLog :` path it prints rather than re-running it. When both are green it records the copy it
367
+ verified and puts you back on your branch.
368
+
369
+ **What ③ publishes is never that merge.** The copy is your branch exactly as it is, plus — only when
338
370
  something conflicted — ONE commit holding the files you resolved. A copy that contained `dev` would carry
339
371
  every other copy's history, and a later `--remove` of one of them would leave it on dev through yours.
372
+ `wp-finish-push-dev` refuses when your branch moved after ② verified it (re-run ②), and force-pushes the
373
+ copy (leased against the sha ② saw), so the push event carries the previous copy's sha.
340
374
 
341
375
  **`commands.push-dev.buildCommand` has no default.** Configure the dev-scoped build in
342
- `webpieces.config.json` (it should build only what differs from `origin/dev`, so it stays fast):
376
+ `webpieces.config.json` — compile and test only what differs from `origin/dev`, with NO code rules (not an
377
+ nx `ci` target, which runs `architecture:validate-code`):
343
378
 
344
379
  ```json
345
- "commands": { "push-dev": { "buildCommand": "pnpm nx affected --target=ci --base=origin/dev --head=HEAD" } }
380
+ "commands": { "push-dev": { "buildCommand": "pnpm nx affected -t build test --base=origin/dev --head=HEAD" } }
346
381
  ```
347
382
 
348
- Without it, `wp-push-dev` and `wp-build-dev` refuse before touching anything and print that entry. When
349
- `origin/dev` does not exist yet (the very first composition), `wp-push-dev` publishes unchecked.
383
+ Without it, `wp-build-push-dev` refuses before touching anything and prints that entry. When `origin/dev`
384
+ does not exist yet (the very first composition), ② has nothing to check against and verifies the branch
385
+ as it is.
350
386
 
351
387
  `--remove` deletes `dev-include/<your-branch>` **and then** pushes a content-free marker
352
388
  `dev-remove/<your-branch>` at the `origin/main` tip. The marker push is the rebuild signal: a deletion
@@ -373,25 +409,26 @@ on:
373
409
  # no `delete:` trigger — it cannot be filtered by branch, so every deletion in the repo would start a run
374
410
  ```
375
411
 
376
- On a `dev-remove/**` push the workflow deletes that marker ref, then runs the ordinary rebuild: reset
377
- `dev` to `origin/main`, merge every remaining `dev-include/*` copy, build, force-push. A workflow still
378
- listening on `on: delete:` keeps working too, because `--remove` still deletes the copy — add the
379
- `dev-remove/**` trigger first, upgrade webpieces, then drop `delete:`.
412
+ On a `dev-remove/**` push the workflow deletes that marker ref and takes the copy back out of `dev`. A
413
+ workflow still listening on `on: delete:` keeps working too, because `--remove` still deletes the copy —
414
+ add the `dev-remove/**` trigger first, upgrade webpieces, then drop `delete:`. Because ① rewrites the
415
+ branch, a re-published copy is usually a rewrite of the previous one; the push event's `before` sha is
416
+ that previous copy, which is what a workflow needs to apply only the difference.
380
417
 
381
418
  **The cardinal rule, and the reason a COPY exists at all:** your feature branch is the PR head, so it
382
419
  must **never** acquire another developer's commits — landing that PR would ship their unreviewed work to
383
- production. Conflict resolutions therefore live on the throwaway copy, never on your branch. After any
384
- command here, `git log <your-branch>` shows it did not move.
420
+ production. The dev merge and any resolution of it therefore happen on the throwaway, never on your
421
+ branch. (① merges `origin/main` into your branch, which is exactly what the PR flow does anyway.)
385
422
 
386
423
  ### Is it deployed yet? — two questions, in this order
387
424
 
388
- `wp-push-dev` prints both, **fully substituted with your sha and refs**, so you can paste them straight
425
+ `wp-finish-push-dev` prints both, **fully substituted with your sha and refs**, so you can paste them straight
389
426
  in. Nothing here is blocked: they are read-only git queries plus `gh run list|watch|view`.
390
427
 
391
428
  1. **Did YOUR code land in the composed branch?** Pure git, works whatever the CI is:
392
429
  ```bash
393
430
  git fetch origin dev
394
- git merge-base --is-ancestor <the sha wp-push-dev printed> origin/dev && echo IN || echo "not yet"
431
+ git merge-base --is-ancestor <the sha wp-finish-push-dev printed> origin/dev && echo IN || echo "not yet"
395
432
  ```
396
433
  `dev` is rebuilt from `origin/main` plus every copy on each run, so **ancestry is inclusion**. If it
397
434
  says "not yet", the composition simply has not run since you published — re-check, do not re-push.
@@ -409,48 +446,31 @@ in. Nothing here is blocked: they are read-only git queries plus `gh run list|wa
409
446
  composition may have excluded yours. Question 1 is the one that answers for *your* code; question 2 only
410
447
  tells you the machinery finished. Answer them in that order, and report both.
411
448
 
412
- ### When `wp-push-dev` stops on a conflict
413
-
414
- It stops on the THROWAWAY branch and lists the files. Resolve them, `git add` each one, then:
449
+ ### When `wp-build-push-dev` stops on a conflict with dev
415
450
 
416
- ```bash
417
- pnpm wp-finish-push-dev # commits, runs the dev build, publishes
418
- pnpm wp-finish-push-dev --abort # or throw it all away
419
- ```
451
+ First it resolves, by itself, every conflicted file whose dev side comes ONLY from copies already on
452
+ `origin/main` — a copy whose branch has a merged PR, or whose content of that file main already holds. That
453
+ is the copy that was published, then landed on main with different content (review commits, a squash):
454
+ `dev` still holds its old version, and your branch carries its final one, so your side is taken and the
455
+ landed copy it overrode is named in the output. Nothing is lost and nothing is redeployed. Any file another
456
+ LIVE copy also changes is left for you.
420
457
 
421
- ### When two branches conflict in the composition
422
-
423
- CI will name the branch you conflict with. Compose locally, so what you resolve is what CI will build:
458
+ It stops on the THROWAWAY branch and lists the files that remain. Resolve them, `git add` each one, then:
424
459
 
425
460
  ```bash
426
- pnpm wp-push-dev --resolve # merge every OTHER copy, in CI's order
427
- pnpm wp-push-dev --resolve <their-branch> # or just the one CI named
428
- # clean → nothing to publish: CI already composes your copy as it is
429
- # CONFLICT → it stops on a THROWAWAY branch and lists the files
430
- # resolve them, `git add` each one, then:
431
- pnpm wp-finish-push-dev # commits, resumes the queue, publishes
432
- pnpm wp-finish-push-dev --abort # or throw it all away
461
+ pnpm wp-build-push-dev # commits the resolution, pnpm install, runs the dev build
462
+ pnpm wp-build-push-dev --abort # or throw it all away
433
463
  ```
434
464
 
435
- Either way, what is published is your copy plus ONE commit holding the resolved files — never a merge of
436
- the other copies.
437
-
438
465
  While a resolve is half-finished the other `wp-*` commands refuse (you are parked on a throwaway branch,
439
466
  not your feature branch). The block message lists exactly which ones and how to get out.
440
467
 
441
468
  **Do not run `git merge --continue`, `git commit` or `git push` yourself** — they are blocked, and
442
- `wp-finish-push-dev` does all three. Your only job is editing the conflicted files and `git add`-ing
443
- them; neither is blocked.
444
-
445
- ### If your copy already holds a resolution
446
-
447
- `wp-push-dev` **refuses** rather than force-pushing over commits the copy has and your branch does not —
448
- that is somebody's real work, and it exists only there, by design. (A resolution commit `wp-push-dev`
449
- recorded itself is the exception: the next publish re-checks against dev and records it again, so it is
450
- replaced without asking.) Two ways forward:
469
+ `wp-build-push-dev` / `wp-finish-push-dev` do them for you. Your only job is editing the conflicted files
470
+ and `git add`-ing them; neither is blocked.
451
471
 
452
- - `pnpm wp-push-dev --rebase-resolution` — replay it on top of your new commits (keeps the work)
453
- - `pnpm wp-push-dev --force` — discard it (somebody re-resolves the composition afterwards)
472
+ Conflicts between two developers' published copies are not resolved here: ② merges `origin/dev`, which
473
+ already holds the other copies, so what you resolve is what the composition will meet.
454
474
 
455
475
  ## Worktrees (works the same as a primary clone)
456
476