@webpieces/pr-gate 0.4.866 → 0.4.867
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/pr-gate",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.867",
|
|
4
4
|
"description": "Gated PR system: 3-point squash-merge, merge validation gate, and red/yellow/green PR dashboard. Standalone scripts, no Nx dependency required.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -16,18 +16,18 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@inversifyjs/binding-decorators": "1.1.5",
|
|
19
|
-
"@webpieces/hook-runtime": "0.4.
|
|
20
|
-
"@webpieces/rules-config": "0.4.
|
|
19
|
+
"@webpieces/hook-runtime": "0.4.867",
|
|
20
|
+
"@webpieces/rules-config": "0.4.867",
|
|
21
21
|
"inversify": "7.10.4",
|
|
22
22
|
"reflect-metadata": "0.2.2",
|
|
23
|
-
"@webpieces/tooling-common": "0.4.
|
|
24
|
-
"@webpieces/repo-workflow-core": "0.4.
|
|
23
|
+
"@webpieces/tooling-common": "0.4.867",
|
|
24
|
+
"@webpieces/repo-workflow-core": "0.4.867"
|
|
25
25
|
},
|
|
26
26
|
"publishConfig": {
|
|
27
27
|
"access": "public"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@webpieces/tooling-testkit": "0.4.
|
|
30
|
+
"@webpieces/tooling-testkit": "0.4.867"
|
|
31
31
|
},
|
|
32
32
|
"types": "./src/index.d.ts",
|
|
33
33
|
"bin": {
|
|
@@ -66,10 +66,17 @@ class RepoConfigFixture {
|
|
|
66
66
|
// webpieces-disable no-any-unknown -- parsed owner entries remain opaque until fixture validation
|
|
67
67
|
const guards = {};
|
|
68
68
|
const declarations = new rules_config_2.PackPolicyFiles().declarations(config['rulePacks'], root);
|
|
69
|
+
// Validate live ownership before projecting into the fixture's deliberately frozen packs.
|
|
70
|
+
// Newly published policies remain enforced by the real repository; these workflow fixtures
|
|
71
|
+
// carry only policies their selected manifests own. Unknown live keys still fail here.
|
|
72
|
+
const liveRegistry = new rules_config_1.RulePackRegistry(new rules_config_2.PackPolicyFiles().select(root, declarations).map((pack) => pack.manifest));
|
|
69
73
|
for (const declaration of declarations) {
|
|
70
74
|
// webpieces-disable no-any-unknown -- repository owner JSON, consumed by the real fixture validator
|
|
71
75
|
const entries = JSON.parse(fs.readFileSync(path.join(root, declaration.config), 'utf8'));
|
|
72
76
|
for (const name of Object.keys(entries)) {
|
|
77
|
+
liveRegistry.ownerOf(name);
|
|
78
|
+
if (!fixtureRuleRegistry.hasRule(name))
|
|
79
|
+
continue;
|
|
73
80
|
if ((0, rules_config_2.retiredRuleFor)(name, fixtureRuleRegistry) !== null)
|
|
74
81
|
continue;
|
|
75
82
|
const section = (0, rules_config_2.sectionForRule)(name, fixtureRuleRegistry) === 'hookGuards' ? guards : rules;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repo-config-testkit.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/repo-config-testkit.ts"],"names":[],"mappings":";;;;AAAA,gEAA2D;AAC3D,0DAA2D;AAC3D,MAAM,mBAAmB,GAAG,IAAI,+BAAgB,CAAC,+BAAa,CAAC,SAAS,EAAE,CAAC,CAAC;AAC5E,+CAAyB;AACzB,mDAA6B;AAE7B,0DAEiC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAa,iBAAiB;IAC1B,iGAAiG;IACjG,mGAAmG;IACnG,IAAI;QACA,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,uBAAuB,CAAC,CAA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tE,OAAO,CAAC,IAAI,CAAC,GAAG,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,EAAE,CAAC;QAC7E,CAAC;IACL,CAAC;CACJ;AA9DD,8CA8DC","sourcesContent":["import { policyFixture } from '@webpieces/tooling-testkit';\nimport { RulePackRegistry } from '@webpieces/rules-config';\nconst fixtureRuleRegistry = new RulePackRegistry(policyFixture.manifests());\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nimport {\n allRuleNames, DEFAULT_REVIEWER_AGENT_NAME, PackPolicyFiles, retiredRuleFor, sectionForRule, seedEntryForRule,\n} from '@webpieces/rules-config';\n\n/**\n * THIS repo's own `webpieces.config.json`, prepared for use inside a temp clone.\n *\n * Specs that exercise a command end-to-end need a config the REAL validator accepts, and using the\n * repo's own file (rather than a hand-rolled minimal one) is what keeps them honest — a stub drifts out\n * from under the validator on the next config change. These adjustments are needed to make that file\n * usable outside this checkout, and all are the same for every such spec, so they live here once:\n *\n * 1. `checklists` is dropped. Its `doc` paths are validated REPO-RELATIVE and point at\n * `.claude/review/*.md`, which exist here and not in a temp clone.\n * 2. Explicit owner files are read from the root declarations and converted to the frozen\n * PolicyFixture transport ONLY inside these tests. Production loading accepts only owner files.\n * Every locally-known rule is completed from its SEED. The repo's config is validated by the PUBLISHED\n * validator and therefore lags local source by one release\n * (`.claude/rules/published-vs-local-source.md`): a rule added in this working tree cannot get a\n * config entry or newly-required field until its release ships,\n * while the LOCAL validator a spec runs already demands one. Without this, adding any rule turns\n * these specs red for exactly one release — a failure that says nothing about the code under test.\n * 3. Every RETIRED rule entry is dropped — the same one-release lag pointing the other way. When a rule\n * is retired in this working tree, the repo's config must KEEP its entry until the release carrying\n * the retirement ships (deleting it early would fail the published validator and block every Bash\n * call), while the LOCAL validator already REJECTS it. Same trade as (2), same fix.\n * 4. A `commands.pr-gate.reviewerAgentName` naming the webpieces default WITHOUT `overrideReviewerAgent`\n * is dropped — the same one-release lag again (issue #947). The published validator still REQUIRES the\n * key, so the repo's config must carry it until the release making it optional ships, while the LOCAL\n * validator already rejects a name without the override. A follow-up PR removes it from the live config.\n *\n * A testkit, not product code: nothing in a published bin imports it (same role as ai-hook-rules'\n * `shim-testkit.ts`).\n */\nexport class RepoConfigFixture {\n /** The repo's config as a mutable object, checklists dropped and local seed fields completed. */\n // webpieces-disable no-any-unknown -- the repo's own config document, opaque until a spec edits it\n load(): Record<string, unknown> {\n const source = path.join(__dirname, '..', '..', '..', '..', '..', '..', 'webpieces.config.json');\n // webpieces-disable no-any-unknown -- parsed JSON, narrowed by the accessors below\n const config = JSON.parse(fs.readFileSync(source, 'utf8')) as Record<string, unknown>;\n // webpieces-disable no-any-unknown -- narrowing one nested section\n const commands = config['commands'] as Record<string, Record<string, unknown>>;\n delete commands['pr-gate']['checklists'];\n delete commands['pr-gate']['checklistsWhy'];\n const prGate = commands['pr-gate'];\n // Local source requires this before the published validator permits the live repo to add it.\n prGate['maxReviewerRounds'] = 2;\n if (prGate['overrideReviewerAgent'] !== true && prGate['reviewerAgentName'] === DEFAULT_REVIEWER_AGENT_NAME) {\n delete prGate['reviewerAgentName'];\n }\n this.loadOwnedRules(config, path.dirname(source));\n this.completeRulesFromSeed(config);\n return config;\n }\n\n // webpieces-disable no-any-unknown -- test-only transport for PolicyFixture.writeOwnerConfig, never a production accepted shape\n private loadOwnedRules(config: Record<string, unknown>, root: string): void {\n // webpieces-disable no-any-unknown -- parsed owner entries remain opaque until fixture validation\n const rules: Record<string, unknown> = {};\n // webpieces-disable no-any-unknown -- parsed owner entries remain opaque until fixture validation\n const guards: Record<string, unknown> = {};\n const declarations = new PackPolicyFiles().declarations(config['rulePacks'], root);\n for (const declaration of declarations) {\n // webpieces-disable no-any-unknown -- repository owner JSON, consumed by the real fixture validator\n const entries = JSON.parse(fs.readFileSync(path.join(root, declaration.config), 'utf8')) as Record<string, unknown>;\n for (const name of Object.keys(entries)) {\n if (retiredRuleFor(name, fixtureRuleRegistry) !== null) continue;\n const section = sectionForRule(name, fixtureRuleRegistry) === 'hookGuards' ? guards : rules;\n section[name] = entries[name];\n }\n }\n config['rules'] = rules;\n config['hookGuards'] = guards;\n }\n\n /** Write `config` (usually a `load()` result a spec has edited) as the config of `dir`. */\n // webpieces-disable no-any-unknown -- see load()\n writeTo(dir: string, config: Record<string, unknown>): void {\n policyFixture.writeOwnerConfig(dir, config);\n }\n\n // webpieces-disable no-any-unknown -- see load()\n private completeRulesFromSeed(config: Record<string, unknown>): void {\n // webpieces-disable no-any-unknown -- narrowing the two rule sections\n const rules = config['rules'] as Record<string, unknown>;\n // webpieces-disable no-any-unknown -- narrowing the two rule sections\n const guards = config['hookGuards'] as Record<string, unknown>;\n for (const name of allRuleNames(fixtureRuleRegistry)) {\n const section = sectionForRule(name, fixtureRuleRegistry) === 'hookGuards' ? guards : rules;\n const seed = seedEntryForRule(name, fixtureRuleRegistry);\n // webpieces-disable no-any-unknown -- one rule's opaque config entry, merged over its typed seed\n const existing = section[name] as Record<string, unknown> | undefined;\n section[name] = existing === undefined ? seed : { ...seed, ...existing };\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"repo-config-testkit.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/repo-config-testkit.ts"],"names":[],"mappings":";;;;AAAA,gEAA2D;AAC3D,0DAA+E;AAC/E,MAAM,mBAAmB,GAAG,IAAI,+BAAgB,CAAC,+BAAa,CAAC,SAAS,EAAE,CAAC,CAAC;AAC5E,+CAAyB;AACzB,mDAA6B;AAE7B,0DAEiC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAa,iBAAiB;IAC1B,iGAAiG;IACjG,mGAAmG;IACnG,IAAI;QACA,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI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C,YAAY,CAA4B,CAAC;QAC/D,KAAK,MAAM,IAAI,IAAI,IAAA,2BAAY,EAAC,mBAAmB,CAAC,EAAE,CAAC;YACnD,MAAM,OAAO,GAAG,IAAA,6BAAc,EAAC,IAAI,EAAE,mBAAmB,CAAC,KAAK,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;YAC5F,MAAM,IAAI,GAAG,IAAA,+BAAgB,EAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC;YACzD,iGAAiG;YACjG,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAwC,CAAC;YACtE,OAAO,CAAC,IAAI,CAAC,GAAG,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,EAAE,CAAC;QAC7E,CAAC;IACL,CAAC;CACJ;AAtED,8CAsEC","sourcesContent":["import { policyFixture } from '@webpieces/tooling-testkit';\nimport { RulePackRegistry, SelectedPolicyPack } from '@webpieces/rules-config';\nconst fixtureRuleRegistry = new RulePackRegistry(policyFixture.manifests());\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nimport {\n allRuleNames, DEFAULT_REVIEWER_AGENT_NAME, PackPolicyFiles, retiredRuleFor, sectionForRule, seedEntryForRule,\n} from '@webpieces/rules-config';\n\n/**\n * THIS repo's own `webpieces.config.json`, prepared for use inside a temp clone.\n *\n * Specs that exercise a command end-to-end need a config the REAL validator accepts, and using the\n * repo's own file (rather than a hand-rolled minimal one) is what keeps them honest — a stub drifts out\n * from under the validator on the next config change. These adjustments are needed to make that file\n * usable outside this checkout, and all are the same for every such spec, so they live here once:\n *\n * 1. `checklists` is dropped. Its `doc` paths are validated REPO-RELATIVE and point at\n * `.claude/review/*.md`, which exist here and not in a temp clone.\n * 2. Explicit owner files are read from the root declarations and converted to the frozen\n * PolicyFixture transport ONLY inside these tests. Production loading accepts only owner files.\n * Every locally-known rule is completed from its SEED. The repo's config is validated by the PUBLISHED\n * validator and therefore lags local source by one release\n * (`.claude/rules/published-vs-local-source.md`): a rule added in this working tree cannot get a\n * config entry or newly-required field until its release ships,\n * while the LOCAL validator a spec runs already demands one. Without this, adding any rule turns\n * these specs red for exactly one release — a failure that says nothing about the code under test.\n * 3. Every RETIRED rule entry is dropped — the same one-release lag pointing the other way. When a rule\n * is retired in this working tree, the repo's config must KEEP its entry until the release carrying\n * the retirement ships (deleting it early would fail the published validator and block every Bash\n * call), while the LOCAL validator already REJECTS it. Same trade as (2), same fix.\n * 4. A `commands.pr-gate.reviewerAgentName` naming the webpieces default WITHOUT `overrideReviewerAgent`\n * is dropped — the same one-release lag again (issue #947). The published validator still REQUIRES the\n * key, so the repo's config must carry it until the release making it optional ships, while the LOCAL\n * validator already rejects a name without the override. A follow-up PR removes it from the live config.\n *\n * A testkit, not product code: nothing in a published bin imports it (same role as ai-hook-rules'\n * `shim-testkit.ts`).\n */\nexport class RepoConfigFixture {\n /** The repo's config as a mutable object, checklists dropped and local seed fields completed. */\n // webpieces-disable no-any-unknown -- the repo's own config document, opaque until a spec edits it\n load(): Record<string, unknown> {\n const source = path.join(__dirname, '..', '..', '..', '..', '..', '..', 'webpieces.config.json');\n // webpieces-disable no-any-unknown -- parsed JSON, narrowed by the accessors below\n const config = JSON.parse(fs.readFileSync(source, 'utf8')) as Record<string, unknown>;\n // webpieces-disable no-any-unknown -- narrowing one nested section\n const commands = config['commands'] as Record<string, Record<string, unknown>>;\n delete commands['pr-gate']['checklists'];\n delete commands['pr-gate']['checklistsWhy'];\n const prGate = commands['pr-gate'];\n // Local source requires this before the published validator permits the live repo to add it.\n prGate['maxReviewerRounds'] = 2;\n if (prGate['overrideReviewerAgent'] !== true && prGate['reviewerAgentName'] === DEFAULT_REVIEWER_AGENT_NAME) {\n delete prGate['reviewerAgentName'];\n }\n this.loadOwnedRules(config, path.dirname(source));\n this.completeRulesFromSeed(config);\n return config;\n }\n\n // webpieces-disable no-any-unknown -- test-only transport for PolicyFixture.writeOwnerConfig, never a production accepted shape\n private loadOwnedRules(config: Record<string, unknown>, root: string): void {\n // webpieces-disable no-any-unknown -- parsed owner entries remain opaque until fixture validation\n const rules: Record<string, unknown> = {};\n // webpieces-disable no-any-unknown -- parsed owner entries remain opaque until fixture validation\n const guards: Record<string, unknown> = {};\n const declarations = new PackPolicyFiles().declarations(config['rulePacks'], root);\n // Validate live ownership before projecting into the fixture's deliberately frozen packs.\n // Newly published policies remain enforced by the real repository; these workflow fixtures\n // carry only policies their selected manifests own. Unknown live keys still fail here.\n const liveRegistry = new RulePackRegistry(new PackPolicyFiles().select(root, declarations).map(\n (pack: SelectedPolicyPack) => pack.manifest,\n ));\n for (const declaration of declarations) {\n // webpieces-disable no-any-unknown -- repository owner JSON, consumed by the real fixture validator\n const entries = JSON.parse(fs.readFileSync(path.join(root, declaration.config), 'utf8')) as Record<string, unknown>;\n for (const name of Object.keys(entries)) {\n liveRegistry.ownerOf(name);\n if (!fixtureRuleRegistry.hasRule(name)) continue;\n if (retiredRuleFor(name, fixtureRuleRegistry) !== null) continue;\n const section = sectionForRule(name, fixtureRuleRegistry) === 'hookGuards' ? guards : rules;\n section[name] = entries[name];\n }\n }\n config['rules'] = rules;\n config['hookGuards'] = guards;\n }\n\n /** Write `config` (usually a `load()` result a spec has edited) as the config of `dir`. */\n // webpieces-disable no-any-unknown -- see load()\n writeTo(dir: string, config: Record<string, unknown>): void {\n policyFixture.writeOwnerConfig(dir, config);\n }\n\n // webpieces-disable no-any-unknown -- see load()\n private completeRulesFromSeed(config: Record<string, unknown>): void {\n // webpieces-disable no-any-unknown -- narrowing the two rule sections\n const rules = config['rules'] as Record<string, unknown>;\n // webpieces-disable no-any-unknown -- narrowing the two rule sections\n const guards = config['hookGuards'] as Record<string, unknown>;\n for (const name of allRuleNames(fixtureRuleRegistry)) {\n const section = sectionForRule(name, fixtureRuleRegistry) === 'hookGuards' ? guards : rules;\n const seed = seedEntryForRule(name, fixtureRuleRegistry);\n // webpieces-disable no-any-unknown -- one rule's opaque config entry, merged over its typed seed\n const existing = section[name] as Record<string, unknown> | undefined;\n section[name] = existing === undefined ? seed : { ...seed, ...existing };\n }\n }\n}\n"]}
|