@usefragments/core 1.10.2 → 2.0.0
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/dist/{chunk-MZ4SW3TP.js → chunk-3IOWHECM.js} +8 -1
- package/dist/{chunk-MZ4SW3TP.js.map → chunk-3IOWHECM.js.map} +1 -1
- package/dist/chunk-7ULGH74M.js +66 -0
- package/dist/chunk-7ULGH74M.js.map +1 -0
- package/dist/{chunk-XN3LSDPY.js → chunk-BMPYIUZE.js} +612 -344
- package/dist/chunk-BMPYIUZE.js.map +1 -0
- package/dist/{chunk-YF65VYRY.js → chunk-ML5S6QNU.js} +191 -169
- package/dist/chunk-ML5S6QNU.js.map +1 -0
- package/dist/{chunk-3LLRNCPX.js → chunk-MZ2FS7U4.js} +1 -1
- package/dist/chunk-MZ2FS7U4.js.map +1 -0
- package/dist/chunk-PWIJMOI4.js +202 -0
- package/dist/chunk-PWIJMOI4.js.map +1 -0
- package/dist/chunk-RYFULE43.js +578 -0
- package/dist/chunk-RYFULE43.js.map +1 -0
- package/dist/codes/index.d.ts +2 -2
- package/dist/codes/index.js +3 -2
- package/dist/compiled-types/index.d.ts +327 -2
- package/dist/compiled-types/index.js +1 -1
- package/dist/generate/index.d.ts +3 -2
- package/dist/{governance-CLk_wkP9.d.ts → governance-hOPXGbbs.d.ts} +474 -515
- package/dist/governance-telemetry.d.ts +6 -0
- package/dist/governance-telemetry.js +1 -1
- package/dist/{index-_sxhUNqx.d.ts → index-C8bcXVav.d.ts} +448 -448
- package/dist/index.d.ts +3280 -1305
- package/dist/index.js +2414 -350
- package/dist/index.js.map +1 -1
- package/dist/manifest.d.ts +228 -0
- package/dist/manifest.js +24 -0
- package/dist/manifest.js.map +1 -0
- package/dist/preview/index.js +45 -1
- package/dist/preview/index.js.map +1 -1
- package/dist/preview-runtime.d.ts +1 -2
- package/dist/preview-runtime.js +150 -14
- package/dist/preview-runtime.js.map +1 -1
- package/dist/react-types.d.ts +1 -2
- package/dist/registry.d.ts +1412 -203
- package/dist/registry.js +30 -3
- package/dist/schemas/index.d.ts +1 -1
- package/dist/schemas/index.js +3 -2
- package/dist/storyAdapter.d.ts +1 -2
- package/dist/storyAdapter.js +11 -49
- package/dist/storyAdapter.js.map +1 -1
- package/dist/test-utils.d.ts +3 -2
- package/dist/topology/index.d.ts +1 -1
- package/dist/topology/index.js +1 -1
- package/package.json +8 -2
- package/src/__tests__/contract-parser.test.ts +318 -277
- package/src/__tests__/preview-runtime-hook.test.tsx +315 -0
- package/src/__tests__/preview-runtime.test.tsx +30 -8
- package/src/__tests__/schema.test.ts +191 -14
- package/src/analysis-plan/analysis-plan-v1.test.ts +320 -0
- package/src/analysis-plan/coverage.ts +181 -0
- package/src/analysis-plan/digest.ts +141 -0
- package/src/analysis-plan/index.ts +34 -0
- package/src/analysis-plan/types.ts +207 -0
- package/src/approved-contract-tokens.test.ts +39 -0
- package/src/approved-contract-tokens.ts +18 -0
- package/src/codes/__tests__/codes.test.ts +13 -0
- package/src/codes/codes.ts +40 -0
- package/src/compiled-types/index.ts +640 -39
- package/src/compiled-types/parse.test.ts +145 -4
- package/src/component-contract.ts +95 -53
- package/src/composition.ts +7 -13
- package/src/constants.ts +3 -6
- package/src/contract/hash.test.ts +20 -0
- package/src/contract/hash.ts +66 -9
- package/src/contract/index.ts +24 -1
- package/src/contract/manifest.test.ts +94 -0
- package/src/contract/manifest.ts +68 -0
- package/src/contract/preimage.test.ts +219 -1
- package/src/contract/preimage.ts +326 -6
- package/src/contract/stamp.test.ts +3 -0
- package/src/contract/stamp.ts +1 -1
- package/src/contract-parser.ts +54 -30
- package/src/defineFragment.test.ts +476 -91
- package/src/defineFragment.ts +204 -114
- package/src/domain-ids.test.ts +35 -0
- package/src/domain-ids.ts +61 -0
- package/src/evaluation/evaluate.test.ts +522 -0
- package/src/evaluation/evaluate.ts +690 -0
- package/src/evaluation/evaluation-v2-receipt-v1.test.ts +772 -0
- package/src/evaluation/index.ts +58 -0
- package/src/evaluation/receipt.ts +753 -0
- package/src/evaluation/types.ts +406 -0
- package/src/facts/builders.ts +2 -0
- package/src/facts/compile.ts +29 -6
- package/src/facts/fact-index.ts +13 -3
- package/src/facts/fact-integrity-v1.test.ts +172 -0
- package/src/facts/facts.test.ts +15 -0
- package/src/facts/ids.ts +46 -3
- package/src/facts/index.ts +14 -1
- package/src/facts/integrity.ts +134 -0
- package/src/facts/types.ts +36 -0
- package/src/governance-integrity.test.ts +1 -0
- package/src/governance-integrity.ts +5 -3
- package/src/governance-telemetry.ts +8 -0
- package/src/governance.ts +70 -8
- package/src/index.ts +230 -37
- package/src/preview/validation.test.ts +62 -0
- package/src/preview/validation.ts +48 -2
- package/src/preview-runtime.tsx +227 -20
- package/src/registry-install-plan.ts +200 -109
- package/src/registry-shards.test.ts +263 -0
- package/src/registry.ts +237 -0
- package/src/repository-binding.test.ts +50 -0
- package/src/repository-binding.ts +96 -0
- package/src/rules/families.test.ts +36 -0
- package/src/rules/finding.ts +7 -2
- package/src/rules/index.ts +17 -1
- package/src/rules/rule-config.test.ts +66 -0
- package/src/rules/rule-config.ts +73 -0
- package/src/rules/rules.test.ts +26 -0
- package/src/rules/tokens-css-vars-must-be-defined.test.ts +51 -2
- package/src/rules/tokens-css-vars-must-be-defined.ts +34 -1
- package/src/schema.ts +293 -113
- package/src/schemas/index.ts +1 -1
- package/src/storyAdapter.test.ts +68 -12
- package/src/storyAdapter.ts +44 -75
- package/src/topology/resolve-area.ts +1 -1
- package/src/types.ts +258 -40
- package/dist/chunk-3LLRNCPX.js.map +0 -1
- package/dist/chunk-RANPUC6C.js +0 -72
- package/dist/chunk-RANPUC6C.js.map +0 -1
- package/dist/chunk-XN3LSDPY.js.map +0 -1
- package/dist/chunk-YF65VYRY.js.map +0 -1
- package/src/fragment-types.ts +0 -214
- package/src/react-create-element.test.ts +0 -22
- package/src/react-create-element.ts +0 -12
- package/src/storyFilters.test.ts +0 -350
- package/src/storyFilters.ts +0 -253
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
portableRepoPathError
|
|
3
|
+
} from "./chunk-EIYNNS77.js";
|
|
4
|
+
import {
|
|
5
|
+
compareCanonicalStrings
|
|
6
|
+
} from "./chunk-PWIJMOI4.js";
|
|
1
7
|
import {
|
|
2
8
|
authorOwnedImport,
|
|
3
9
|
canonicalizeOwnedComponentId,
|
|
@@ -6,9 +12,6 @@ import {
|
|
|
6
12
|
projectV1OwnedComponentId,
|
|
7
13
|
projectV1OwnedImportIdentity
|
|
8
14
|
} from "./chunk-JNBFJ34I.js";
|
|
9
|
-
import {
|
|
10
|
-
portableRepoPathError
|
|
11
|
-
} from "./chunk-EIYNNS77.js";
|
|
12
15
|
import {
|
|
13
16
|
legacySeverityLevelSchema,
|
|
14
17
|
severityFromLevel,
|
|
@@ -285,6 +288,16 @@ var CODES = [
|
|
|
285
288
|
lifecycle: "experimental",
|
|
286
289
|
evidenceRequired: true
|
|
287
290
|
}),
|
|
291
|
+
code({
|
|
292
|
+
code: "FUI2018",
|
|
293
|
+
ruleId: "config/empty-token-vocabulary",
|
|
294
|
+
category: "system",
|
|
295
|
+
defaultSeverity: "serious",
|
|
296
|
+
title: "Token sources resolved to 0 tokens",
|
|
297
|
+
lifecycle: "experimental",
|
|
298
|
+
fixAvailable: false,
|
|
299
|
+
evidenceRequired: true
|
|
300
|
+
}),
|
|
288
301
|
ruleCode({
|
|
289
302
|
code: "FUI3001",
|
|
290
303
|
ruleId: "a11y/required-accessible-name",
|
|
@@ -538,6 +551,36 @@ var CODES = [
|
|
|
538
551
|
lifecycle: "experimental",
|
|
539
552
|
fixAvailable: false,
|
|
540
553
|
evidenceRequired: false
|
|
554
|
+
}),
|
|
555
|
+
code({
|
|
556
|
+
code: "FUI9010",
|
|
557
|
+
ruleId: "fragment/invalid-definition",
|
|
558
|
+
category: "system",
|
|
559
|
+
defaultSeverity: "critical",
|
|
560
|
+
title: "Fragment definition is not valid",
|
|
561
|
+
lifecycle: "experimental",
|
|
562
|
+
fixAvailable: false,
|
|
563
|
+
evidenceRequired: false
|
|
564
|
+
}),
|
|
565
|
+
code({
|
|
566
|
+
code: "FUI9011",
|
|
567
|
+
ruleId: "fragment/source-drift",
|
|
568
|
+
category: "system",
|
|
569
|
+
defaultSeverity: "critical",
|
|
570
|
+
title: "Fragment definition drifted from its component source",
|
|
571
|
+
lifecycle: "experimental",
|
|
572
|
+
fixAvailable: false,
|
|
573
|
+
evidenceRequired: false
|
|
574
|
+
}),
|
|
575
|
+
code({
|
|
576
|
+
code: "FUI9012",
|
|
577
|
+
ruleId: "contract/write-not-entitled",
|
|
578
|
+
category: "system",
|
|
579
|
+
defaultSeverity: "critical",
|
|
580
|
+
title: "Contract write requires a paid workspace",
|
|
581
|
+
lifecycle: "experimental",
|
|
582
|
+
fixAvailable: false,
|
|
583
|
+
evidenceRequired: false
|
|
541
584
|
})
|
|
542
585
|
];
|
|
543
586
|
var byCode = new Map(
|
|
@@ -550,15 +593,179 @@ function explainUrlForCode(code2) {
|
|
|
550
593
|
return `${EXPLAIN_URL_BASE}${code2}`;
|
|
551
594
|
}
|
|
552
595
|
|
|
596
|
+
// src/facts/integrity.ts
|
|
597
|
+
import { z as z2 } from "zod";
|
|
598
|
+
|
|
599
|
+
// src/domain-ids.ts
|
|
600
|
+
import { z } from "zod";
|
|
601
|
+
var FULL_DIGEST_PATTERN = /^[0-9a-f]{64}$/u;
|
|
602
|
+
var digestHexStringSchema = z.string().regex(FULL_DIGEST_PATTERN, "Expected 64 lowercase hexadecimal characters");
|
|
603
|
+
var digestHexSchema = digestHexStringSchema;
|
|
604
|
+
var analysisPlanIdStringSchema = z.string().regex(/^apl_[0-9a-f]{64}$/u, "Invalid analysis plan ID");
|
|
605
|
+
var analysisPlanIdSchema = analysisPlanIdStringSchema.transform(
|
|
606
|
+
(value) => value
|
|
607
|
+
);
|
|
608
|
+
var evaluationReceiptIdSchema = z.string().regex(/^evr_[0-9a-f]{64}$/u, "Invalid evaluation receipt ID").transform((value) => value);
|
|
609
|
+
var evaluationReceiptIdStringSchema = z.string().regex(/^evr_[0-9a-f]{64}$/u, "Invalid evaluation receipt ID");
|
|
610
|
+
function parseDigestHex(value) {
|
|
611
|
+
return digestHexSchema.parse(value);
|
|
612
|
+
}
|
|
613
|
+
function analysisPlanIdFromDigest(digest) {
|
|
614
|
+
return analysisPlanIdSchema.parse(`apl_${parseDigestHex(digest)}`);
|
|
615
|
+
}
|
|
616
|
+
function evaluationReceiptIdFromDigest(digest) {
|
|
617
|
+
return evaluationReceiptIdSchema.parse(`evr_${parseDigestHex(digest)}`);
|
|
618
|
+
}
|
|
619
|
+
function mintEvaluationReceiptId(resultDigest) {
|
|
620
|
+
return evaluationReceiptIdFromDigest(resultDigest);
|
|
621
|
+
}
|
|
622
|
+
function parseAnalysisPlanId(value) {
|
|
623
|
+
return analysisPlanIdSchema.parse(value);
|
|
624
|
+
}
|
|
625
|
+
function parseEvaluationReceiptId(value) {
|
|
626
|
+
return evaluationReceiptIdSchema.parse(value);
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
// src/facts/integrity.ts
|
|
630
|
+
var CANONICAL_FACT_MAX_CONFLICTS_V1 = 1e3;
|
|
631
|
+
var CANONICAL_FACT_MAX_VALUES_PER_CONFLICT_V1 = 64;
|
|
632
|
+
var CANONICAL_FACT_MAX_PROVENANCE_PER_VALUE_V1 = 1e3;
|
|
633
|
+
var boundedString = z2.string().min(1).max(4096);
|
|
634
|
+
var unique = (values) => new Set(values).size === values.length;
|
|
635
|
+
var provenance = z2.array(boundedString).min(1).max(CANONICAL_FACT_MAX_PROVENANCE_PER_VALUE_V1).refine(unique, "provenance values must be unique");
|
|
636
|
+
var canonicalFactConflictValueV1Schema = z2.object({
|
|
637
|
+
valueDigest: digestHexStringSchema,
|
|
638
|
+
factIds: provenance,
|
|
639
|
+
totalFactIdCount: z2.number().int().positive().optional(),
|
|
640
|
+
analyzerIds: provenance,
|
|
641
|
+
totalAnalyzerIdCount: z2.number().int().positive().optional(),
|
|
642
|
+
evidenceRefs: provenance,
|
|
643
|
+
totalEvidenceRefCount: z2.number().int().positive().optional()
|
|
644
|
+
}).strict().superRefine((value, context) => {
|
|
645
|
+
for (const [path, total, retained] of [
|
|
646
|
+
["totalFactIdCount", value.totalFactIdCount, value.factIds.length],
|
|
647
|
+
["totalAnalyzerIdCount", value.totalAnalyzerIdCount, value.analyzerIds.length],
|
|
648
|
+
["totalEvidenceRefCount", value.totalEvidenceRefCount, value.evidenceRefs.length]
|
|
649
|
+
]) {
|
|
650
|
+
if (total !== void 0 && total < retained) {
|
|
651
|
+
context.addIssue({
|
|
652
|
+
code: z2.ZodIssueCode.custom,
|
|
653
|
+
path: [path],
|
|
654
|
+
message: `${path} cannot be smaller than retained provenance`
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
});
|
|
659
|
+
var canonicalFactConflictV1Schema = z2.object({
|
|
660
|
+
canonicalKey: boundedString,
|
|
661
|
+
factKind: boundedString,
|
|
662
|
+
state: z2.literal("conflict"),
|
|
663
|
+
values: z2.array(canonicalFactConflictValueV1Schema).min(2).max(CANONICAL_FACT_MAX_VALUES_PER_CONFLICT_V1).refine(
|
|
664
|
+
(values) => new Set(values.map((value) => value.valueDigest)).size === values.length,
|
|
665
|
+
"conflict values must have distinct material digests"
|
|
666
|
+
),
|
|
667
|
+
totalValueCount: z2.number().int().min(2).optional()
|
|
668
|
+
}).strict().superRefine((value, context) => {
|
|
669
|
+
if (value.totalValueCount !== void 0 && value.totalValueCount < value.values.length) {
|
|
670
|
+
context.addIssue({
|
|
671
|
+
code: z2.ZodIssueCode.custom,
|
|
672
|
+
path: ["totalValueCount"],
|
|
673
|
+
message: "totalValueCount cannot be smaller than retained values"
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
});
|
|
677
|
+
var canonicalFactIntegrityV1Schema = z2.union([
|
|
678
|
+
z2.object({
|
|
679
|
+
state: z2.literal("healthy"),
|
|
680
|
+
coalescedDuplicateCount: z2.number().int().nonnegative()
|
|
681
|
+
}).strict(),
|
|
682
|
+
z2.object({
|
|
683
|
+
state: z2.literal("conflict"),
|
|
684
|
+
coalescedDuplicateCount: z2.number().int().nonnegative(),
|
|
685
|
+
conflicts: z2.array(canonicalFactConflictV1Schema).min(1).max(CANONICAL_FACT_MAX_CONFLICTS_V1).refine(
|
|
686
|
+
(conflicts) => new Set(conflicts.map((conflict) => conflict.canonicalKey)).size === conflicts.length,
|
|
687
|
+
"canonical conflict keys must be unique"
|
|
688
|
+
),
|
|
689
|
+
totalConflictCount: z2.number().int().positive().optional()
|
|
690
|
+
}).strict().superRefine((value, context) => {
|
|
691
|
+
if (value.totalConflictCount !== void 0 && value.totalConflictCount < value.conflicts.length) {
|
|
692
|
+
context.addIssue({
|
|
693
|
+
code: z2.ZodIssueCode.custom,
|
|
694
|
+
path: ["totalConflictCount"],
|
|
695
|
+
message: "totalConflictCount cannot be smaller than retained conflicts"
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
})
|
|
699
|
+
]);
|
|
700
|
+
var sorted = (values) => [...values].sort();
|
|
701
|
+
function normalizeCanonicalFactIntegrityV1(value) {
|
|
702
|
+
const parsed = canonicalFactIntegrityV1Schema.parse(value);
|
|
703
|
+
if (parsed.state === "healthy") return parsed;
|
|
704
|
+
return {
|
|
705
|
+
...parsed,
|
|
706
|
+
totalConflictCount: parsed.totalConflictCount ?? parsed.conflicts.length,
|
|
707
|
+
conflicts: parsed.conflicts.map((conflict) => ({
|
|
708
|
+
...conflict,
|
|
709
|
+
totalValueCount: conflict.totalValueCount ?? conflict.values.length,
|
|
710
|
+
values: conflict.values.map((entry) => ({
|
|
711
|
+
...entry,
|
|
712
|
+
factIds: sorted(entry.factIds),
|
|
713
|
+
totalFactIdCount: entry.totalFactIdCount ?? entry.factIds.length,
|
|
714
|
+
analyzerIds: sorted(entry.analyzerIds),
|
|
715
|
+
totalAnalyzerIdCount: entry.totalAnalyzerIdCount ?? entry.analyzerIds.length,
|
|
716
|
+
evidenceRefs: sorted(entry.evidenceRefs),
|
|
717
|
+
totalEvidenceRefCount: entry.totalEvidenceRefCount ?? entry.evidenceRefs.length
|
|
718
|
+
})).sort((left, right) => compareCanonicalStrings(left.valueDigest, right.valueDigest))
|
|
719
|
+
})).sort((left, right) => compareCanonicalStrings(left.canonicalKey, right.canonicalKey))
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
|
|
553
723
|
// src/facts/ids.ts
|
|
554
724
|
function canonicalJson(value) {
|
|
725
|
+
return canonicalJsonValue(value, /* @__PURE__ */ new Set(), "(root)");
|
|
726
|
+
}
|
|
727
|
+
function canonicalJsonValue(value, ancestors, path) {
|
|
555
728
|
if (value === void 0) return "null";
|
|
556
|
-
if (value === null || typeof value
|
|
729
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") {
|
|
730
|
+
return JSON.stringify(value);
|
|
731
|
+
}
|
|
732
|
+
if (typeof value === "number") {
|
|
733
|
+
if (!Number.isFinite(value)) {
|
|
734
|
+
throw new TypeError(`Unsupported fact identity value at ${path}: non-finite number`);
|
|
735
|
+
}
|
|
736
|
+
const serialized = JSON.stringify(value);
|
|
737
|
+
if (serialized === void 0) {
|
|
738
|
+
throw new TypeError(`Unsupported fact identity value at ${path}: number`);
|
|
739
|
+
}
|
|
740
|
+
return serialized;
|
|
741
|
+
}
|
|
742
|
+
if (typeof value !== "object") {
|
|
743
|
+
throw new TypeError(`Unsupported fact identity value at ${path}: ${typeof value}`);
|
|
744
|
+
}
|
|
557
745
|
if (Array.isArray(value)) {
|
|
558
|
-
|
|
746
|
+
if (ancestors.has(value)) throw new TypeError(`Circular fact identity value at ${path}`);
|
|
747
|
+
ancestors.add(value);
|
|
748
|
+
try {
|
|
749
|
+
return `[${value.map((entry, index) => canonicalJsonValue(entry, ancestors, `${path}[${index}]`)).join(",")}]`;
|
|
750
|
+
} finally {
|
|
751
|
+
ancestors.delete(value);
|
|
752
|
+
}
|
|
559
753
|
}
|
|
754
|
+
const prototype = Object.getPrototypeOf(value);
|
|
755
|
+
if (prototype !== Object.prototype && prototype !== null) {
|
|
756
|
+
const objectType = prototype?.constructor?.name ?? "unknown";
|
|
757
|
+
throw new TypeError(`Unsupported fact identity object at ${path}: ${objectType}`);
|
|
758
|
+
}
|
|
759
|
+
if (ancestors.has(value)) throw new TypeError(`Circular fact identity value at ${path}`);
|
|
760
|
+
ancestors.add(value);
|
|
560
761
|
const entries = Object.entries(value).filter(([, v]) => v !== void 0).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
561
|
-
|
|
762
|
+
try {
|
|
763
|
+
return `{${entries.map(
|
|
764
|
+
([key, entry]) => `${JSON.stringify(key)}:${canonicalJsonValue(entry, ancestors, `${path}.${key}`)}`
|
|
765
|
+
).join(",")}}`;
|
|
766
|
+
} finally {
|
|
767
|
+
ancestors.delete(value);
|
|
768
|
+
}
|
|
562
769
|
}
|
|
563
770
|
var FNV_PRIME = 16777619;
|
|
564
771
|
var FNV_SEED_A = 2166136261;
|
|
@@ -854,6 +1061,7 @@ function makeStyleCssVarsMustBeDefinedFact(input) {
|
|
|
854
1061
|
id: factId("style_css_vars_must_be_defined", {}),
|
|
855
1062
|
kind: "style_css_vars_must_be_defined",
|
|
856
1063
|
severity: input.severity,
|
|
1064
|
+
...input.configPath ? { configPath: input.configPath } : {},
|
|
857
1065
|
...policyExcludeField(input.exclude)
|
|
858
1066
|
};
|
|
859
1067
|
}
|
|
@@ -1267,11 +1475,14 @@ var FactIndex = class {
|
|
|
1267
1475
|
}
|
|
1268
1476
|
const existing = this.facts.get(fact.id);
|
|
1269
1477
|
if (existing) {
|
|
1270
|
-
|
|
1478
|
+
const differs = canonicalJson(logicalFactForComparison(existing)) !== canonicalJson(logicalFactForComparison(fact));
|
|
1479
|
+
if (differs) {
|
|
1271
1480
|
this.options.onConflict?.(
|
|
1272
1481
|
`FactIndex: conflicting facts for id ${fact.id} \u2014 keeping ${describeFactForConflict(existing)}, skipping ${describeFactForConflict(fact)}`,
|
|
1273
1482
|
{ kept: existing, skipped: fact }
|
|
1274
1483
|
);
|
|
1484
|
+
} else {
|
|
1485
|
+
this.options.onDuplicate?.({ kept: existing, duplicate: fact });
|
|
1275
1486
|
}
|
|
1276
1487
|
return;
|
|
1277
1488
|
}
|
|
@@ -1490,16 +1701,16 @@ function describeFactForConflict(fact) {
|
|
|
1490
1701
|
}
|
|
1491
1702
|
|
|
1492
1703
|
// src/governance.ts
|
|
1493
|
-
import { z as
|
|
1704
|
+
import { z as z4 } from "zod";
|
|
1494
1705
|
|
|
1495
1706
|
// src/policy-exclude.ts
|
|
1496
|
-
import { z } from "zod";
|
|
1497
|
-
var policyExcludeSchema =
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
glob:
|
|
1502
|
-
reason:
|
|
1707
|
+
import { z as z3 } from "zod";
|
|
1708
|
+
var policyExcludeSchema = z3.array(
|
|
1709
|
+
z3.union([
|
|
1710
|
+
z3.string().min(1),
|
|
1711
|
+
z3.object({
|
|
1712
|
+
glob: z3.string().min(1),
|
|
1713
|
+
reason: z3.string().min(1).optional()
|
|
1503
1714
|
})
|
|
1504
1715
|
])
|
|
1505
1716
|
);
|
|
@@ -1543,90 +1754,90 @@ function describePolicyExclude(scope, exclude) {
|
|
|
1543
1754
|
}
|
|
1544
1755
|
|
|
1545
1756
|
// src/governance.ts
|
|
1546
|
-
var governanceSeveritySchema =
|
|
1757
|
+
var governanceSeveritySchema = z4.enum(["error", "warn", "info"]);
|
|
1547
1758
|
var recordExcludeSchema = policyExcludeSchema.optional();
|
|
1548
|
-
var scaleGovernanceRecordSchema =
|
|
1549
|
-
kind:
|
|
1550
|
-
name:
|
|
1551
|
-
unit:
|
|
1552
|
-
values:
|
|
1553
|
-
rootFontSizePx:
|
|
1554
|
-
emBasePx:
|
|
1759
|
+
var scaleGovernanceRecordSchema = z4.object({
|
|
1760
|
+
kind: z4.literal("scale").default("scale"),
|
|
1761
|
+
name: z4.string().min(1).optional(),
|
|
1762
|
+
unit: z4.enum(["px", "rem"]),
|
|
1763
|
+
values: z4.array(z4.number()),
|
|
1764
|
+
rootFontSizePx: z4.number().positive().optional(),
|
|
1765
|
+
emBasePx: z4.number().positive().optional()
|
|
1555
1766
|
});
|
|
1556
|
-
var styleRawColorsForbidRecordSchema =
|
|
1557
|
-
kind:
|
|
1558
|
-
except:
|
|
1559
|
-
prefer:
|
|
1767
|
+
var styleRawColorsForbidRecordSchema = z4.object({
|
|
1768
|
+
kind: z4.literal("style.rawColors.forbid"),
|
|
1769
|
+
except: z4.array(z4.string()),
|
|
1770
|
+
prefer: z4.enum(["token", "css-variable"]),
|
|
1560
1771
|
severity: governanceSeveritySchema,
|
|
1561
1772
|
exclude: recordExcludeSchema
|
|
1562
1773
|
});
|
|
1563
|
-
var styleRawDimensionsForbidRecordSchema =
|
|
1564
|
-
kind:
|
|
1565
|
-
appliesTo:
|
|
1566
|
-
prefer:
|
|
1774
|
+
var styleRawDimensionsForbidRecordSchema = z4.object({
|
|
1775
|
+
kind: z4.literal("style.rawDimensions.forbid"),
|
|
1776
|
+
appliesTo: z4.array(z4.string().min(1)),
|
|
1777
|
+
prefer: z4.enum(["token", "css-variable"]),
|
|
1567
1778
|
severity: governanceSeveritySchema,
|
|
1568
1779
|
exclude: recordExcludeSchema
|
|
1569
1780
|
});
|
|
1570
|
-
var styleRawSpacingMustMatchScaleRecordSchema =
|
|
1571
|
-
kind:
|
|
1572
|
-
scale:
|
|
1573
|
-
appliesTo:
|
|
1781
|
+
var styleRawSpacingMustMatchScaleRecordSchema = z4.object({
|
|
1782
|
+
kind: z4.literal("style.rawSpacing.mustMatchScale"),
|
|
1783
|
+
scale: z4.string().min(1),
|
|
1784
|
+
appliesTo: z4.array(z4.string().min(1)),
|
|
1574
1785
|
severity: governanceSeveritySchema,
|
|
1575
1786
|
exclude: recordExcludeSchema
|
|
1576
1787
|
});
|
|
1577
|
-
var styleFontSizeMustMatchScaleRecordSchema =
|
|
1578
|
-
kind:
|
|
1579
|
-
scale:
|
|
1788
|
+
var styleFontSizeMustMatchScaleRecordSchema = z4.object({
|
|
1789
|
+
kind: z4.literal("style.fontSize.mustMatchScale"),
|
|
1790
|
+
scale: z4.string().min(1),
|
|
1580
1791
|
severity: governanceSeveritySchema,
|
|
1581
1792
|
exclude: recordExcludeSchema
|
|
1582
1793
|
});
|
|
1583
|
-
var styleCssVarsMustBeDefinedRecordSchema =
|
|
1584
|
-
kind:
|
|
1794
|
+
var styleCssVarsMustBeDefinedRecordSchema = z4.object({
|
|
1795
|
+
kind: z4.literal("style.cssVars.mustBeDefined"),
|
|
1585
1796
|
severity: governanceSeveritySchema,
|
|
1586
1797
|
exclude: recordExcludeSchema
|
|
1587
1798
|
});
|
|
1588
|
-
var globalStyleGovernanceRecordSchema =
|
|
1799
|
+
var globalStyleGovernanceRecordSchema = z4.discriminatedUnion("kind", [
|
|
1589
1800
|
styleRawColorsForbidRecordSchema,
|
|
1590
1801
|
styleRawDimensionsForbidRecordSchema,
|
|
1591
1802
|
styleRawSpacingMustMatchScaleRecordSchema,
|
|
1592
1803
|
styleFontSizeMustMatchScaleRecordSchema,
|
|
1593
1804
|
styleCssVarsMustBeDefinedRecordSchema
|
|
1594
1805
|
]);
|
|
1595
|
-
var jsxUnknownPropsForbidRecordSchema =
|
|
1596
|
-
kind:
|
|
1806
|
+
var jsxUnknownPropsForbidRecordSchema = z4.object({
|
|
1807
|
+
kind: z4.literal("jsx.unknownProps.forbid"),
|
|
1597
1808
|
severity: governanceSeveritySchema,
|
|
1598
1809
|
exclude: recordExcludeSchema
|
|
1599
1810
|
});
|
|
1600
|
-
var jsxInlineStyleForbidRawRecordSchema =
|
|
1601
|
-
kind:
|
|
1602
|
-
properties:
|
|
1811
|
+
var jsxInlineStyleForbidRawRecordSchema = z4.object({
|
|
1812
|
+
kind: z4.literal("jsx.inlineStyle.forbidRaw"),
|
|
1813
|
+
properties: z4.array(z4.string().min(1)),
|
|
1603
1814
|
severity: governanceSeveritySchema,
|
|
1604
1815
|
exclude: recordExcludeSchema
|
|
1605
1816
|
});
|
|
1606
|
-
var jsxImportPathPreferRecordSchema =
|
|
1607
|
-
kind:
|
|
1608
|
-
from:
|
|
1609
|
-
to:
|
|
1610
|
-
imported:
|
|
1611
|
-
because:
|
|
1817
|
+
var jsxImportPathPreferRecordSchema = z4.object({
|
|
1818
|
+
kind: z4.literal("jsx.importPath.prefer"),
|
|
1819
|
+
from: z4.string().min(1),
|
|
1820
|
+
to: z4.string().min(1),
|
|
1821
|
+
imported: z4.string().min(1).optional(),
|
|
1822
|
+
because: z4.string().optional(),
|
|
1612
1823
|
severity: governanceSeveritySchema,
|
|
1613
1824
|
exclude: recordExcludeSchema
|
|
1614
1825
|
});
|
|
1615
|
-
var jsxComponentPreferRecordSchema =
|
|
1616
|
-
kind:
|
|
1617
|
-
from:
|
|
1618
|
-
to:
|
|
1619
|
-
because:
|
|
1826
|
+
var jsxComponentPreferRecordSchema = z4.object({
|
|
1827
|
+
kind: z4.literal("jsx.component.prefer"),
|
|
1828
|
+
from: z4.string().min(1),
|
|
1829
|
+
to: z4.string().min(1),
|
|
1830
|
+
because: z4.string().optional(),
|
|
1620
1831
|
severity: governanceSeveritySchema,
|
|
1621
1832
|
exclude: recordExcludeSchema
|
|
1622
1833
|
});
|
|
1623
|
-
var globalJsxGovernanceRecordSchema =
|
|
1834
|
+
var globalJsxGovernanceRecordSchema = z4.discriminatedUnion("kind", [
|
|
1624
1835
|
jsxUnknownPropsForbidRecordSchema,
|
|
1625
1836
|
jsxInlineStyleForbidRawRecordSchema,
|
|
1626
1837
|
jsxImportPathPreferRecordSchema,
|
|
1627
1838
|
jsxComponentPreferRecordSchema
|
|
1628
1839
|
]);
|
|
1629
|
-
var globalGovernanceRecordSchema =
|
|
1840
|
+
var globalGovernanceRecordSchema = z4.discriminatedUnion("kind", [
|
|
1630
1841
|
scaleGovernanceRecordSchema,
|
|
1631
1842
|
styleRawColorsForbidRecordSchema,
|
|
1632
1843
|
styleRawDimensionsForbidRecordSchema,
|
|
@@ -1638,99 +1849,114 @@ var globalGovernanceRecordSchema = z2.discriminatedUnion("kind", [
|
|
|
1638
1849
|
jsxImportPathPreferRecordSchema,
|
|
1639
1850
|
jsxComponentPreferRecordSchema
|
|
1640
1851
|
]);
|
|
1641
|
-
var componentCapabilityRecordSchema =
|
|
1642
|
-
kind:
|
|
1643
|
-
capability:
|
|
1852
|
+
var componentCapabilityRecordSchema = z4.object({
|
|
1853
|
+
kind: z4.literal("capability"),
|
|
1854
|
+
capability: z4.string().min(1)
|
|
1644
1855
|
});
|
|
1645
|
-
var
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1856
|
+
var requiredComponentGovernanceValueSchema = z4.custom(
|
|
1857
|
+
(value) => value !== void 0,
|
|
1858
|
+
"Expected an explicitly present governance value"
|
|
1859
|
+
);
|
|
1860
|
+
var propValueAvoidRecordSchema = z4.object({
|
|
1861
|
+
kind: z4.literal("prop.value.avoid"),
|
|
1862
|
+
prop: z4.string().min(1),
|
|
1863
|
+
value: requiredComponentGovernanceValueSchema,
|
|
1864
|
+
because: z4.string(),
|
|
1865
|
+
suggest: z4.string().optional(),
|
|
1651
1866
|
severity: governanceSeveritySchema
|
|
1652
1867
|
});
|
|
1653
|
-
var propValueForbidRecordSchema =
|
|
1654
|
-
kind:
|
|
1655
|
-
prop:
|
|
1656
|
-
value:
|
|
1657
|
-
when:
|
|
1658
|
-
because:
|
|
1659
|
-
fix:
|
|
1868
|
+
var propValueForbidRecordSchema = z4.object({
|
|
1869
|
+
kind: z4.literal("prop.value.forbid"),
|
|
1870
|
+
prop: z4.string().min(1),
|
|
1871
|
+
value: requiredComponentGovernanceValueSchema,
|
|
1872
|
+
when: z4.object({ path: z4.string().min(1).optional() }).optional(),
|
|
1873
|
+
because: z4.string(),
|
|
1874
|
+
fix: z4.object({ replaceWith: requiredComponentGovernanceValueSchema }).optional(),
|
|
1660
1875
|
severity: governanceSeveritySchema
|
|
1661
1876
|
});
|
|
1662
|
-
var a11yRequireNameRecordSchema =
|
|
1663
|
-
kind:
|
|
1664
|
-
because:
|
|
1877
|
+
var a11yRequireNameRecordSchema = z4.object({
|
|
1878
|
+
kind: z4.literal("a11y.requireName"),
|
|
1879
|
+
because: z4.string(),
|
|
1665
1880
|
severity: governanceSeveritySchema
|
|
1666
1881
|
});
|
|
1667
|
-
var componentGovernanceRecordSchema =
|
|
1882
|
+
var componentGovernanceRecordSchema = z4.discriminatedUnion("kind", [
|
|
1668
1883
|
componentCapabilityRecordSchema,
|
|
1669
1884
|
propValueAvoidRecordSchema,
|
|
1670
1885
|
propValueForbidRecordSchema,
|
|
1671
1886
|
a11yRequireNameRecordSchema
|
|
1672
1887
|
]);
|
|
1673
|
-
var componentGovernanceRecordsSchema =
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1888
|
+
var componentGovernanceRecordsSchema = z4.array(componentGovernanceRecordSchema);
|
|
1889
|
+
function parseComponentGovernancePolicyJson(policyJson) {
|
|
1890
|
+
try {
|
|
1891
|
+
const parsed = JSON.parse(policyJson);
|
|
1892
|
+
const record = parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
1893
|
+
const candidate = Array.isArray(parsed) ? parsed : record?.governance ?? record?.rules;
|
|
1894
|
+
const result = componentGovernanceRecordsSchema.safeParse(candidate);
|
|
1895
|
+
return result.success ? result.data : null;
|
|
1896
|
+
} catch {
|
|
1897
|
+
return null;
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
var componentPolicyMatchSchema = z4.object({
|
|
1901
|
+
componentKey: z4.string().min(1).optional(),
|
|
1902
|
+
componentId: z4.string().min(1).optional(),
|
|
1903
|
+
publicRef: z4.string().min(1).optional(),
|
|
1904
|
+
importPath: z4.string().min(1).optional(),
|
|
1905
|
+
sourcePath: z4.string().min(1).optional(),
|
|
1906
|
+
path: z4.string().min(1).optional(),
|
|
1907
|
+
exportName: z4.string().min(1).optional(),
|
|
1908
|
+
export: z4.string().min(1).optional(),
|
|
1909
|
+
name: z4.string().min(1).optional(),
|
|
1910
|
+
scope: z4.enum(["one", "all"]).optional()
|
|
1685
1911
|
}).strict();
|
|
1686
|
-
var componentPolicyRecordSchema =
|
|
1912
|
+
var componentPolicyRecordSchema = z4.object({
|
|
1687
1913
|
rules: componentGovernanceRecordsSchema,
|
|
1688
|
-
status:
|
|
1914
|
+
status: z4.enum(["active", "draft", "disabled"]).optional()
|
|
1689
1915
|
}).strict();
|
|
1690
|
-
var componentPolicyOverrideSchema =
|
|
1916
|
+
var componentPolicyOverrideSchema = z4.object({
|
|
1691
1917
|
match: componentPolicyMatchSchema,
|
|
1692
1918
|
rules: componentGovernanceRecordsSchema,
|
|
1693
|
-
status:
|
|
1919
|
+
status: z4.enum(["active", "draft", "disabled"]).optional()
|
|
1694
1920
|
}).strict();
|
|
1695
|
-
var canonicalSourcePathSchema =
|
|
1921
|
+
var canonicalSourcePathSchema = z4.string().min(1).superRefine((value, ctx) => {
|
|
1696
1922
|
const error = portableRepoPathError(value);
|
|
1697
1923
|
if (error) {
|
|
1698
|
-
ctx.addIssue({ code:
|
|
1924
|
+
ctx.addIssue({ code: z4.ZodIssueCode.custom, message: error });
|
|
1699
1925
|
}
|
|
1700
1926
|
});
|
|
1701
|
-
var canonicalSourceRegistryHashSchema =
|
|
1702
|
-
var canonicalBridgeModuleSpecifierSchema =
|
|
1927
|
+
var canonicalSourceRegistryHashSchema = z4.string().regex(/^[0-9a-f]{64}$/);
|
|
1928
|
+
var canonicalBridgeModuleSpecifierSchema = z4.string().min(1).superRefine((value, ctx) => {
|
|
1703
1929
|
const normalized = value.replace(/\\/gu, "/");
|
|
1704
1930
|
if (normalized.startsWith("/") || /^[A-Za-z]:\//u.test(normalized)) {
|
|
1705
1931
|
ctx.addIssue({
|
|
1706
|
-
code:
|
|
1932
|
+
code: z4.ZodIssueCode.custom,
|
|
1707
1933
|
message: "Canonical bridge moduleSpecifier must be a portable import specifier"
|
|
1708
1934
|
});
|
|
1709
1935
|
}
|
|
1710
1936
|
if (normalized.split("/").includes("..")) {
|
|
1711
1937
|
ctx.addIssue({
|
|
1712
|
-
code:
|
|
1938
|
+
code: z4.ZodIssueCode.custom,
|
|
1713
1939
|
message: "Canonical bridge moduleSpecifier must not traverse outside the project"
|
|
1714
1940
|
});
|
|
1715
1941
|
}
|
|
1716
1942
|
});
|
|
1717
|
-
var canonicalBridgeV1Schema =
|
|
1718
|
-
underlying:
|
|
1719
|
-
packageName:
|
|
1720
|
-
exportName:
|
|
1943
|
+
var canonicalBridgeV1Schema = z4.object({
|
|
1944
|
+
underlying: z4.object({
|
|
1945
|
+
packageName: z4.string().min(1),
|
|
1946
|
+
exportName: z4.string().min(1)
|
|
1721
1947
|
}).strict(),
|
|
1722
|
-
local:
|
|
1723
|
-
componentKey:
|
|
1948
|
+
local: z4.object({
|
|
1949
|
+
componentKey: z4.string().min(1),
|
|
1724
1950
|
moduleSpecifier: canonicalBridgeModuleSpecifierSchema,
|
|
1725
|
-
exportName:
|
|
1726
|
-
implementationFiles:
|
|
1951
|
+
exportName: z4.string().min(1),
|
|
1952
|
+
implementationFiles: z4.array(canonicalSourcePathSchema).min(1)
|
|
1727
1953
|
}).strict(),
|
|
1728
|
-
decision:
|
|
1729
|
-
state:
|
|
1730
|
-
source:
|
|
1954
|
+
decision: z4.object({
|
|
1955
|
+
state: z4.literal("confirmed"),
|
|
1956
|
+
source: z4.enum(["authored", "migration"])
|
|
1731
1957
|
}).strict()
|
|
1732
1958
|
}).strict();
|
|
1733
|
-
var canonicalBridgesV1Schema =
|
|
1959
|
+
var canonicalBridgesV1Schema = z4.array(canonicalBridgeV1Schema).superRefine((bridges, ctx) => {
|
|
1734
1960
|
const underlying = /* @__PURE__ */ new Map();
|
|
1735
1961
|
const componentKeys = /* @__PURE__ */ new Map();
|
|
1736
1962
|
for (const [index, bridge] of bridges.entries()) {
|
|
@@ -1738,7 +1964,7 @@ var canonicalBridgesV1Schema = z2.array(canonicalBridgeV1Schema).superRefine((br
|
|
|
1738
1964
|
const previousUnderlying = underlying.get(underlyingKey);
|
|
1739
1965
|
if (previousUnderlying !== void 0) {
|
|
1740
1966
|
ctx.addIssue({
|
|
1741
|
-
code:
|
|
1967
|
+
code: z4.ZodIssueCode.custom,
|
|
1742
1968
|
message: `Duplicate confirmed bridge target for ${bridge.underlying.packageName}#${bridge.underlying.exportName} (also at canonicalBridges.${previousUnderlying})`,
|
|
1743
1969
|
path: [index, "underlying"]
|
|
1744
1970
|
});
|
|
@@ -1748,7 +1974,7 @@ var canonicalBridgesV1Schema = z2.array(canonicalBridgeV1Schema).superRefine((br
|
|
|
1748
1974
|
const previousComponent = componentKeys.get(bridge.local.componentKey);
|
|
1749
1975
|
if (previousComponent !== void 0) {
|
|
1750
1976
|
ctx.addIssue({
|
|
1751
|
-
code:
|
|
1977
|
+
code: z4.ZodIssueCode.custom,
|
|
1752
1978
|
message: `Local component key overlaps canonicalBridges.${previousComponent}`,
|
|
1753
1979
|
path: [index, "local", "componentKey"]
|
|
1754
1980
|
});
|
|
@@ -1757,65 +1983,65 @@ var canonicalBridgesV1Schema = z2.array(canonicalBridgeV1Schema).superRefine((br
|
|
|
1757
1983
|
}
|
|
1758
1984
|
}
|
|
1759
1985
|
});
|
|
1760
|
-
var canonicalSourceSchema =
|
|
1761
|
-
|
|
1762
|
-
kind:
|
|
1763
|
-
specifier:
|
|
1764
|
-
implementationPath:
|
|
1765
|
-
include:
|
|
1766
|
-
exclude:
|
|
1986
|
+
var canonicalSourceSchema = z4.discriminatedUnion("kind", [
|
|
1987
|
+
z4.object({
|
|
1988
|
+
kind: z4.literal("npm"),
|
|
1989
|
+
specifier: z4.string().min(1),
|
|
1990
|
+
implementationPath: z4.string().min(1).optional(),
|
|
1991
|
+
include: z4.array(z4.string().min(1)).optional(),
|
|
1992
|
+
exclude: z4.array(z4.string().min(1)).optional()
|
|
1767
1993
|
}),
|
|
1768
|
-
|
|
1769
|
-
kind:
|
|
1770
|
-
path:
|
|
1771
|
-
include:
|
|
1772
|
-
exclude:
|
|
1994
|
+
z4.object({
|
|
1995
|
+
kind: z4.literal("directory"),
|
|
1996
|
+
path: z4.string().min(1),
|
|
1997
|
+
include: z4.array(z4.string().min(1)).optional(),
|
|
1998
|
+
exclude: z4.array(z4.string().min(1)).optional()
|
|
1773
1999
|
}),
|
|
1774
|
-
|
|
1775
|
-
kind:
|
|
1776
|
-
registryId:
|
|
2000
|
+
z4.object({
|
|
2001
|
+
kind: z4.literal("registry"),
|
|
2002
|
+
registryId: z4.string().min(1),
|
|
1777
2003
|
registryHash: canonicalSourceRegistryHashSchema.optional(),
|
|
1778
2004
|
receiptPath: canonicalSourcePathSchema.default(".fragments/registry-lock.json"),
|
|
1779
2005
|
installPath: canonicalSourcePathSchema,
|
|
1780
|
-
importPath:
|
|
1781
|
-
include:
|
|
1782
|
-
exclude:
|
|
2006
|
+
importPath: z4.string().min(1).optional(),
|
|
2007
|
+
include: z4.array(z4.string().min(1)).optional(),
|
|
2008
|
+
exclude: z4.array(z4.string().min(1)).optional(),
|
|
1783
2009
|
severity: governanceSeveritySchema.optional()
|
|
1784
2010
|
})
|
|
1785
2011
|
]);
|
|
1786
|
-
var governanceConfigSchema =
|
|
1787
|
-
extends:
|
|
2012
|
+
var governanceConfigSchema = z4.object({
|
|
2013
|
+
extends: z4.array(z4.string()).optional(),
|
|
1788
2014
|
severity: governanceSeveritySchema.optional(),
|
|
1789
|
-
rules:
|
|
1790
|
-
agents:
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
rules:
|
|
2015
|
+
rules: z4.record(z4.string(), z4.unknown()).optional(),
|
|
2016
|
+
agents: z4.record(
|
|
2017
|
+
z4.string(),
|
|
2018
|
+
z4.object({
|
|
2019
|
+
rules: z4.record(z4.string(), z4.unknown()).optional()
|
|
1794
2020
|
}).passthrough()
|
|
1795
2021
|
).optional(),
|
|
1796
|
-
audit:
|
|
1797
|
-
runners:
|
|
1798
|
-
canonicalSources:
|
|
2022
|
+
audit: z4.object({}).passthrough().optional(),
|
|
2023
|
+
runners: z4.record(z4.string(), z4.object({}).passthrough()).optional(),
|
|
2024
|
+
canonicalSources: z4.array(canonicalSourceSchema).optional(),
|
|
1799
2025
|
canonicalBridges: canonicalBridgesV1Schema.optional(),
|
|
1800
|
-
presets:
|
|
1801
|
-
scales:
|
|
1802
|
-
styles:
|
|
1803
|
-
jsx:
|
|
1804
|
-
tailwind:
|
|
1805
|
-
palette:
|
|
1806
|
-
allow:
|
|
1807
|
-
deny:
|
|
2026
|
+
presets: z4.array(z4.string()).optional(),
|
|
2027
|
+
scales: z4.record(z4.string(), scaleGovernanceRecordSchema).optional(),
|
|
2028
|
+
styles: z4.array(globalStyleGovernanceRecordSchema).optional(),
|
|
2029
|
+
jsx: z4.array(globalJsxGovernanceRecordSchema).optional(),
|
|
2030
|
+
tailwind: z4.object({
|
|
2031
|
+
palette: z4.object({
|
|
2032
|
+
allow: z4.array(z4.string().min(1)).optional(),
|
|
2033
|
+
deny: z4.array(z4.string().min(1)).optional()
|
|
1808
2034
|
}).optional()
|
|
1809
2035
|
}).passthrough().optional(),
|
|
1810
|
-
agent:
|
|
1811
|
-
repairOrder:
|
|
2036
|
+
agent: z4.object({
|
|
2037
|
+
repairOrder: z4.array(z4.string().min(1)).optional()
|
|
1812
2038
|
}).passthrough().optional(),
|
|
1813
|
-
components:
|
|
1814
|
-
overrides:
|
|
1815
|
-
ci:
|
|
1816
|
-
failOnWarnings:
|
|
1817
|
-
failOnInert:
|
|
1818
|
-
failOnAdoptionRegression:
|
|
2039
|
+
components: z4.record(componentPolicyRecordSchema).optional(),
|
|
2040
|
+
overrides: z4.array(componentPolicyOverrideSchema).optional(),
|
|
2041
|
+
ci: z4.object({
|
|
2042
|
+
failOnWarnings: z4.boolean().optional(),
|
|
2043
|
+
failOnInert: z4.boolean().optional(),
|
|
2044
|
+
failOnAdoptionRegression: z4.boolean().optional()
|
|
1819
2045
|
}).passthrough().optional()
|
|
1820
2046
|
}).strict();
|
|
1821
2047
|
var PRESET_SOURCED_RULE = /* @__PURE__ */ Symbol.for("@usefragments/core:preset-sourced-rule");
|
|
@@ -1881,6 +2107,17 @@ function resolveComponentGovernance(definition) {
|
|
|
1881
2107
|
const records = definition.govern ? definition.govern(builder) : definition.governance ?? [];
|
|
1882
2108
|
return componentGovernanceRecordsSchema.parse(records);
|
|
1883
2109
|
}
|
|
2110
|
+
function resolveGovernanceRecordsForIdentity(definition) {
|
|
2111
|
+
if (!definition) return void 0;
|
|
2112
|
+
if (Array.isArray(definition.governance)) {
|
|
2113
|
+
return componentGovernanceRecordsSchema.parse(definition.governance);
|
|
2114
|
+
}
|
|
2115
|
+
if (typeof definition.govern === "function") {
|
|
2116
|
+
const builder = createComponentGovernanceBuilder();
|
|
2117
|
+
return componentGovernanceRecordsSchema.parse(definition.govern(builder));
|
|
2118
|
+
}
|
|
2119
|
+
return void 0;
|
|
2120
|
+
}
|
|
1884
2121
|
function normalizeGovernanceConfig(config) {
|
|
1885
2122
|
if (!config.govern?.scales) {
|
|
1886
2123
|
return config;
|
|
@@ -2040,6 +2277,10 @@ function recordExclude(record) {
|
|
|
2040
2277
|
const exclude = normalizePolicyExcludes(record.exclude);
|
|
2041
2278
|
return exclude ? { exclude } : {};
|
|
2042
2279
|
}
|
|
2280
|
+
function cssVarsConfigPathField(style) {
|
|
2281
|
+
const value = style.configPath;
|
|
2282
|
+
return typeof value === "string" && value.length > 0 ? { configPath: value } : {};
|
|
2283
|
+
}
|
|
2043
2284
|
function unionExcludesBySharedFactId(facts) {
|
|
2044
2285
|
const byId = /* @__PURE__ */ new Map();
|
|
2045
2286
|
for (const fact of facts) {
|
|
@@ -2126,7 +2367,8 @@ function compileGlobalGovernanceFacts(govern) {
|
|
|
2126
2367
|
out.push(
|
|
2127
2368
|
makeStyleCssVarsMustBeDefinedFact({
|
|
2128
2369
|
severity: style.severity,
|
|
2129
|
-
...recordExclude(style)
|
|
2370
|
+
...recordExclude(style),
|
|
2371
|
+
...cssVarsConfigPathField(style)
|
|
2130
2372
|
})
|
|
2131
2373
|
);
|
|
2132
2374
|
break;
|
|
@@ -2265,14 +2507,19 @@ function compileRuleConfigFacts(govern) {
|
|
|
2265
2507
|
const rules = govern.rules;
|
|
2266
2508
|
if (!rules && !govern.canonicalSources?.length) return [];
|
|
2267
2509
|
const configs = /* @__PURE__ */ new Map();
|
|
2510
|
+
for (const [ruleId, value] of Object.entries(rules ?? {})) {
|
|
2511
|
+
configs.set(ruleId, ruleConfigFromValue(value, govern.severity ?? "warn"));
|
|
2512
|
+
}
|
|
2268
2513
|
for (const [ruleId, value] of Object.entries(rules ?? {})) {
|
|
2269
2514
|
const family = RULE_FAMILY_MEMBERS[ruleId];
|
|
2270
2515
|
if (!family) continue;
|
|
2516
|
+
const aggregateIsPreset = isPresetSourcedRule(value);
|
|
2271
2517
|
const config = ruleConfigFromValue(value, govern.severity ?? "warn");
|
|
2272
|
-
for (const memberRuleId of family)
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2518
|
+
for (const memberRuleId of family) {
|
|
2519
|
+
const member = rules?.[memberRuleId];
|
|
2520
|
+
if (member !== void 0 && (aggregateIsPreset || !isPresetSourcedRule(member))) continue;
|
|
2521
|
+
configs.set(memberRuleId, config);
|
|
2522
|
+
}
|
|
2276
2523
|
}
|
|
2277
2524
|
if (govern.canonicalSources?.length) {
|
|
2278
2525
|
for (const ruleId of ["components/prefer-library", "components/shadow-component"]) {
|
|
@@ -2424,244 +2671,244 @@ function compileComponentGovernanceRecord(componentId2, record) {
|
|
|
2424
2671
|
}
|
|
2425
2672
|
|
|
2426
2673
|
// src/schemas/index.ts
|
|
2427
|
-
import { z as
|
|
2428
|
-
var evidenceGradeSchema =
|
|
2674
|
+
import { z as z5 } from "zod";
|
|
2675
|
+
var evidenceGradeSchema = z5.enum([
|
|
2429
2676
|
"none",
|
|
2430
2677
|
"runtime_advisory",
|
|
2431
2678
|
"provenance_bound",
|
|
2432
2679
|
"source_backed",
|
|
2433
2680
|
"receipt_backed"
|
|
2434
2681
|
]);
|
|
2435
|
-
var factLocationSchema =
|
|
2436
|
-
file:
|
|
2437
|
-
line:
|
|
2438
|
-
column:
|
|
2439
|
-
endLine:
|
|
2440
|
-
endColumn:
|
|
2682
|
+
var factLocationSchema = z5.object({
|
|
2683
|
+
file: z5.string(),
|
|
2684
|
+
line: z5.number().int().nonnegative(),
|
|
2685
|
+
column: z5.number().int().nonnegative(),
|
|
2686
|
+
endLine: z5.number().int().nonnegative().optional(),
|
|
2687
|
+
endColumn: z5.number().int().nonnegative().optional()
|
|
2441
2688
|
});
|
|
2442
|
-
var findingReplacePropValueFixSchema =
|
|
2443
|
-
kind:
|
|
2444
|
-
title:
|
|
2445
|
-
prop:
|
|
2446
|
-
value:
|
|
2447
|
-
deterministic:
|
|
2689
|
+
var findingReplacePropValueFixSchema = z5.object({
|
|
2690
|
+
kind: z5.literal("replacePropValue"),
|
|
2691
|
+
title: z5.string(),
|
|
2692
|
+
prop: z5.string(),
|
|
2693
|
+
value: z5.unknown(),
|
|
2694
|
+
deterministic: z5.boolean().optional()
|
|
2448
2695
|
});
|
|
2449
|
-
var findingReplaceStyleValueFixSchema =
|
|
2450
|
-
kind:
|
|
2451
|
-
title:
|
|
2452
|
-
property:
|
|
2453
|
-
value:
|
|
2454
|
-
deterministic:
|
|
2696
|
+
var findingReplaceStyleValueFixSchema = z5.object({
|
|
2697
|
+
kind: z5.literal("replaceStyleValue"),
|
|
2698
|
+
title: z5.string(),
|
|
2699
|
+
property: z5.string(),
|
|
2700
|
+
value: z5.string(),
|
|
2701
|
+
deterministic: z5.boolean().optional()
|
|
2455
2702
|
});
|
|
2456
|
-
var findingReplaceImportFixSchema =
|
|
2457
|
-
kind:
|
|
2458
|
-
title:
|
|
2459
|
-
from:
|
|
2460
|
-
to:
|
|
2461
|
-
deterministic:
|
|
2703
|
+
var findingReplaceImportFixSchema = z5.object({
|
|
2704
|
+
kind: z5.literal("replaceImport"),
|
|
2705
|
+
title: z5.string(),
|
|
2706
|
+
from: z5.string(),
|
|
2707
|
+
to: z5.string(),
|
|
2708
|
+
deterministic: z5.boolean().optional()
|
|
2462
2709
|
});
|
|
2463
|
-
var findingReplaceComponentFixSchema =
|
|
2464
|
-
kind:
|
|
2465
|
-
title:
|
|
2466
|
-
from:
|
|
2467
|
-
to:
|
|
2468
|
-
deterministic:
|
|
2710
|
+
var findingReplaceComponentFixSchema = z5.object({
|
|
2711
|
+
kind: z5.literal("replaceComponent"),
|
|
2712
|
+
title: z5.string(),
|
|
2713
|
+
from: z5.string(),
|
|
2714
|
+
to: z5.string(),
|
|
2715
|
+
deterministic: z5.boolean().optional()
|
|
2469
2716
|
});
|
|
2470
|
-
var findingReplaceClassTokenFixSchema =
|
|
2471
|
-
kind:
|
|
2472
|
-
title:
|
|
2473
|
-
from:
|
|
2474
|
-
to:
|
|
2475
|
-
utility:
|
|
2476
|
-
deterministic:
|
|
2717
|
+
var findingReplaceClassTokenFixSchema = z5.object({
|
|
2718
|
+
kind: z5.literal("replaceClassToken"),
|
|
2719
|
+
title: z5.string(),
|
|
2720
|
+
from: z5.string(),
|
|
2721
|
+
to: z5.string().nullable(),
|
|
2722
|
+
utility: z5.string(),
|
|
2723
|
+
deterministic: z5.boolean().optional()
|
|
2477
2724
|
});
|
|
2478
|
-
var findingFixSchema =
|
|
2725
|
+
var findingFixSchema = z5.discriminatedUnion("kind", [
|
|
2479
2726
|
findingReplacePropValueFixSchema,
|
|
2480
2727
|
findingReplaceStyleValueFixSchema,
|
|
2481
2728
|
findingReplaceImportFixSchema,
|
|
2482
2729
|
findingReplaceComponentFixSchema,
|
|
2483
2730
|
findingReplaceClassTokenFixSchema
|
|
2484
2731
|
]);
|
|
2485
|
-
var factEvidenceSchema =
|
|
2486
|
-
factId:
|
|
2487
|
-
fact:
|
|
2488
|
-
kind:
|
|
2732
|
+
var factEvidenceSchema = z5.object({
|
|
2733
|
+
factId: z5.string(),
|
|
2734
|
+
fact: z5.object({
|
|
2735
|
+
kind: z5.string(),
|
|
2489
2736
|
location: factLocationSchema.optional()
|
|
2490
2737
|
}).passthrough()
|
|
2491
2738
|
});
|
|
2492
|
-
var findingSchema =
|
|
2493
|
-
ruleId:
|
|
2494
|
-
ruleVersion:
|
|
2739
|
+
var findingSchema = z5.object({
|
|
2740
|
+
ruleId: z5.string(),
|
|
2741
|
+
ruleVersion: z5.string(),
|
|
2495
2742
|
severity: severitySchema,
|
|
2496
2743
|
level: severityLevelSchema,
|
|
2497
|
-
code:
|
|
2498
|
-
helpUrl:
|
|
2499
|
-
message:
|
|
2500
|
-
fingerprint:
|
|
2744
|
+
code: z5.string().regex(/^FUI\d{4}$/).optional(),
|
|
2745
|
+
helpUrl: z5.string().url().optional(),
|
|
2746
|
+
message: z5.string(),
|
|
2747
|
+
fingerprint: z5.string(),
|
|
2501
2748
|
/**
|
|
2502
2749
|
* Fingerprint this finding carried before a fingerprint-identity migration.
|
|
2503
2750
|
* Emitted only by migrated rules during the grace window so baseline
|
|
2504
2751
|
* records keyed on the legacy hash keep matching instead of churning.
|
|
2505
2752
|
*/
|
|
2506
|
-
previousFingerprint:
|
|
2753
|
+
previousFingerprint: z5.string().optional(),
|
|
2507
2754
|
location: factLocationSchema,
|
|
2508
|
-
evidence:
|
|
2755
|
+
evidence: z5.array(factEvidenceSchema).min(1),
|
|
2509
2756
|
evidenceGrade: evidenceGradeSchema.optional(),
|
|
2510
2757
|
fix: findingFixSchema.optional(),
|
|
2511
|
-
attributes:
|
|
2758
|
+
attributes: z5.record(z5.unknown()).optional(),
|
|
2512
2759
|
/**
|
|
2513
2760
|
* Product area this finding's file resolved to (topology layer). Optional —
|
|
2514
2761
|
* absent when the repo has no `topology` config. See `topology/resolve-area`.
|
|
2515
2762
|
*/
|
|
2516
|
-
area:
|
|
2517
|
-
areaId:
|
|
2518
|
-
areaName:
|
|
2519
|
-
criticality:
|
|
2520
|
-
owners:
|
|
2521
|
-
matchedGlob:
|
|
2763
|
+
area: z5.object({
|
|
2764
|
+
areaId: z5.string(),
|
|
2765
|
+
areaName: z5.string(),
|
|
2766
|
+
criticality: z5.enum(["low", "medium", "high", "revenue", "regulated"]),
|
|
2767
|
+
owners: z5.array(z5.string()),
|
|
2768
|
+
matchedGlob: z5.string()
|
|
2522
2769
|
}).optional()
|
|
2523
2770
|
});
|
|
2524
|
-
var violationSchema =
|
|
2525
|
-
nodeId:
|
|
2526
|
-
nodeType:
|
|
2527
|
-
rule:
|
|
2771
|
+
var violationSchema = z5.object({
|
|
2772
|
+
nodeId: z5.string(),
|
|
2773
|
+
nodeType: z5.string(),
|
|
2774
|
+
rule: z5.string(),
|
|
2528
2775
|
severity: severitySchema,
|
|
2529
2776
|
level: severityLevelSchema.optional(),
|
|
2530
|
-
code:
|
|
2531
|
-
helpUrl:
|
|
2532
|
-
message:
|
|
2533
|
-
path:
|
|
2534
|
-
suggestion:
|
|
2535
|
-
prop:
|
|
2536
|
-
filePath:
|
|
2537
|
-
line:
|
|
2538
|
-
column:
|
|
2539
|
-
rawValue:
|
|
2540
|
-
extra:
|
|
2777
|
+
code: z5.string().regex(/^FUI\d{4}$/).optional(),
|
|
2778
|
+
helpUrl: z5.string().url().optional(),
|
|
2779
|
+
message: z5.string(),
|
|
2780
|
+
path: z5.string().optional(),
|
|
2781
|
+
suggestion: z5.string().optional(),
|
|
2782
|
+
prop: z5.string().optional(),
|
|
2783
|
+
filePath: z5.string().optional(),
|
|
2784
|
+
line: z5.number().int().nonnegative().optional(),
|
|
2785
|
+
column: z5.number().int().nonnegative().optional(),
|
|
2786
|
+
rawValue: z5.string().optional(),
|
|
2787
|
+
extra: z5.record(z5.unknown()).optional()
|
|
2541
2788
|
});
|
|
2542
|
-
var fixSchema =
|
|
2543
|
-
nodeId:
|
|
2544
|
-
prop:
|
|
2545
|
-
action:
|
|
2546
|
-
value:
|
|
2547
|
-
description:
|
|
2789
|
+
var fixSchema = z5.object({
|
|
2790
|
+
nodeId: z5.string(),
|
|
2791
|
+
prop: z5.string().optional(),
|
|
2792
|
+
action: z5.enum(["remove", "replace", "add"]),
|
|
2793
|
+
value: z5.unknown().optional(),
|
|
2794
|
+
description: z5.string()
|
|
2548
2795
|
});
|
|
2549
|
-
var validatorResultSchema =
|
|
2550
|
-
validator:
|
|
2796
|
+
var validatorResultSchema = z5.object({
|
|
2797
|
+
validator: z5.string(),
|
|
2551
2798
|
severity: severitySchema,
|
|
2552
|
-
passed:
|
|
2553
|
-
violations:
|
|
2554
|
-
findings:
|
|
2555
|
-
suggestions:
|
|
2799
|
+
passed: z5.boolean(),
|
|
2800
|
+
violations: z5.array(violationSchema),
|
|
2801
|
+
findings: z5.array(findingSchema).optional(),
|
|
2802
|
+
suggestions: z5.array(fixSchema).optional()
|
|
2556
2803
|
});
|
|
2557
|
-
var governanceVerdictMetadataSchema =
|
|
2558
|
-
runner:
|
|
2559
|
-
policyVersion:
|
|
2560
|
-
duration:
|
|
2561
|
-
nodeCount:
|
|
2562
|
-
componentTypes:
|
|
2804
|
+
var governanceVerdictMetadataSchema = z5.object({
|
|
2805
|
+
runner: z5.string(),
|
|
2806
|
+
policyVersion: z5.string().optional(),
|
|
2807
|
+
duration: z5.number().nonnegative(),
|
|
2808
|
+
nodeCount: z5.number().int().nonnegative(),
|
|
2809
|
+
componentTypes: z5.array(z5.string())
|
|
2563
2810
|
});
|
|
2564
|
-
var governanceVerdictSchema =
|
|
2565
|
-
verdict:
|
|
2566
|
-
passed:
|
|
2567
|
-
score:
|
|
2568
|
-
results:
|
|
2811
|
+
var governanceVerdictSchema = z5.object({
|
|
2812
|
+
verdict: z5.enum(["pass", "warn", "fail"]).optional(),
|
|
2813
|
+
passed: z5.boolean(),
|
|
2814
|
+
score: z5.number(),
|
|
2815
|
+
results: z5.array(validatorResultSchema),
|
|
2569
2816
|
metadata: governanceVerdictMetadataSchema
|
|
2570
2817
|
});
|
|
2571
|
-
var suppressionDirectiveSchema =
|
|
2572
|
-
ruleId:
|
|
2573
|
-
reason:
|
|
2574
|
-
expiresAt:
|
|
2575
|
-
expiresOn:
|
|
2576
|
-
scope:
|
|
2577
|
-
code:
|
|
2818
|
+
var suppressionDirectiveSchema = z5.object({
|
|
2819
|
+
ruleId: z5.string().optional(),
|
|
2820
|
+
reason: z5.string().min(1),
|
|
2821
|
+
expiresAt: z5.string().datetime().optional(),
|
|
2822
|
+
expiresOn: z5.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional(),
|
|
2823
|
+
scope: z5.enum(["line", "block", "file"]).default("line"),
|
|
2824
|
+
code: z5.string().regex(/^FUI\d{4}$/).optional()
|
|
2578
2825
|
});
|
|
2579
|
-
var agentPlanSchema =
|
|
2580
|
-
tool:
|
|
2826
|
+
var agentPlanSchema = z5.object({
|
|
2827
|
+
tool: z5.enum([
|
|
2581
2828
|
"design_system/list_primitives",
|
|
2582
2829
|
"design_system/conform",
|
|
2583
2830
|
"design_system/prove_compliant"
|
|
2584
2831
|
]),
|
|
2585
|
-
args:
|
|
2586
|
-
confidence:
|
|
2832
|
+
args: z5.record(z5.unknown()),
|
|
2833
|
+
confidence: z5.number().min(0).max(1)
|
|
2587
2834
|
});
|
|
2588
|
-
var agentFindingSchema =
|
|
2589
|
-
code:
|
|
2590
|
-
ruleId:
|
|
2591
|
-
filePath:
|
|
2592
|
-
line:
|
|
2593
|
-
col:
|
|
2835
|
+
var agentFindingSchema = z5.object({
|
|
2836
|
+
code: z5.string().regex(/^FUI\d{4}$/).optional(),
|
|
2837
|
+
ruleId: z5.string(),
|
|
2838
|
+
filePath: z5.string(),
|
|
2839
|
+
line: z5.number().int().nonnegative(),
|
|
2840
|
+
col: z5.number().int().nonnegative(),
|
|
2594
2841
|
severity: severitySchema,
|
|
2595
2842
|
level: severityLevelSchema,
|
|
2596
|
-
message:
|
|
2843
|
+
message: z5.string(),
|
|
2597
2844
|
evidenceGrade: evidenceGradeSchema.optional(),
|
|
2598
|
-
evidence:
|
|
2845
|
+
evidence: z5.array(factEvidenceSchema),
|
|
2599
2846
|
plan: agentPlanSchema
|
|
2600
2847
|
});
|
|
2601
2848
|
var AGENT_FORMAT_SCHEMA_VERSION = "typestyle.agent.v2";
|
|
2602
|
-
var agentIntegritySchema =
|
|
2603
|
-
rulesLoaded:
|
|
2604
|
-
status:
|
|
2605
|
-
healthy:
|
|
2606
|
-
inert:
|
|
2607
|
-
reasons:
|
|
2849
|
+
var agentIntegritySchema = z5.object({
|
|
2850
|
+
rulesLoaded: z5.number().int().nonnegative(),
|
|
2851
|
+
status: z5.enum(["healthy", "degraded", "inert"]),
|
|
2852
|
+
healthy: z5.boolean(),
|
|
2853
|
+
inert: z5.boolean(),
|
|
2854
|
+
reasons: z5.array(z5.string())
|
|
2608
2855
|
});
|
|
2609
|
-
var agentRunProvenanceSchema =
|
|
2610
|
-
runId:
|
|
2611
|
-
fcid:
|
|
2612
|
-
baselineId:
|
|
2613
|
-
scope:
|
|
2614
|
-
method:
|
|
2615
|
-
gitOk:
|
|
2856
|
+
var agentRunProvenanceSchema = z5.object({
|
|
2857
|
+
runId: z5.string().regex(/^run_[a-f0-9]{12}$/),
|
|
2858
|
+
fcid: z5.string().min(1),
|
|
2859
|
+
baselineId: z5.string().min(1).optional(),
|
|
2860
|
+
scope: z5.object({
|
|
2861
|
+
method: z5.enum(["three-dot", "tree-diff", "status", "fallback-full", "explicit", "full"]),
|
|
2862
|
+
gitOk: z5.boolean()
|
|
2616
2863
|
}),
|
|
2617
|
-
engineVersion:
|
|
2618
|
-
scopeHash:
|
|
2619
|
-
inputsHash:
|
|
2620
|
-
inputFilesHash:
|
|
2864
|
+
engineVersion: z5.string().min(1),
|
|
2865
|
+
scopeHash: z5.string().regex(/^[a-f0-9]{64}$/),
|
|
2866
|
+
inputsHash: z5.string().regex(/^[a-f0-9]{64}$/).optional(),
|
|
2867
|
+
inputFilesHash: z5.string().regex(/^[a-f0-9]{64}$/)
|
|
2621
2868
|
});
|
|
2622
|
-
var agentRunVerdictSchema =
|
|
2623
|
-
exitCode:
|
|
2624
|
-
reasons:
|
|
2625
|
-
gatingFindingCount:
|
|
2869
|
+
var agentRunVerdictSchema = z5.object({
|
|
2870
|
+
exitCode: z5.union([z5.literal(0), z5.literal(1)]),
|
|
2871
|
+
reasons: z5.array(z5.string()),
|
|
2872
|
+
gatingFindingCount: z5.number().int().nonnegative()
|
|
2626
2873
|
});
|
|
2627
|
-
var agentFormatBaseSchema =
|
|
2628
|
-
schemaVersion:
|
|
2629
|
-
summary:
|
|
2874
|
+
var agentFormatBaseSchema = z5.object({
|
|
2875
|
+
schemaVersion: z5.literal(AGENT_FORMAT_SCHEMA_VERSION),
|
|
2876
|
+
summary: z5.string(),
|
|
2630
2877
|
integrity: agentIntegritySchema,
|
|
2631
|
-
fix_first:
|
|
2632
|
-
remaining:
|
|
2633
|
-
suppression_template:
|
|
2634
|
-
directive:
|
|
2635
|
-
requiredFields:
|
|
2636
|
-
example:
|
|
2878
|
+
fix_first: z5.array(agentFindingSchema),
|
|
2879
|
+
remaining: z5.array(agentFindingSchema),
|
|
2880
|
+
suppression_template: z5.object({
|
|
2881
|
+
directive: z5.string(),
|
|
2882
|
+
requiredFields: z5.array(z5.string()),
|
|
2883
|
+
example: z5.string()
|
|
2637
2884
|
}),
|
|
2638
|
-
budget:
|
|
2639
|
-
iteration:
|
|
2640
|
-
maxIterations:
|
|
2641
|
-
scoreDelta:
|
|
2885
|
+
budget: z5.object({
|
|
2886
|
+
iteration: z5.number().int().nonnegative(),
|
|
2887
|
+
maxIterations: z5.number().int().positive(),
|
|
2888
|
+
scoreDelta: z5.number()
|
|
2642
2889
|
}),
|
|
2643
|
-
findings:
|
|
2644
|
-
suppressions:
|
|
2890
|
+
findings: z5.array(findingSchema).optional(),
|
|
2891
|
+
suppressions: z5.array(suppressionDirectiveSchema).optional(),
|
|
2645
2892
|
provenance: agentRunProvenanceSchema.optional(),
|
|
2646
2893
|
verdict: agentRunVerdictSchema.optional()
|
|
2647
2894
|
});
|
|
2648
|
-
var agentFormatSchema =
|
|
2895
|
+
var agentFormatSchema = z5.union([
|
|
2649
2896
|
agentFormatBaseSchema.extend({
|
|
2650
|
-
passed:
|
|
2651
|
-
score:
|
|
2652
|
-
status:
|
|
2653
|
-
reasons:
|
|
2897
|
+
passed: z5.boolean(),
|
|
2898
|
+
score: z5.number(),
|
|
2899
|
+
status: z5.never().optional(),
|
|
2900
|
+
reasons: z5.never().optional(),
|
|
2654
2901
|
integrity: agentIntegritySchema.extend({
|
|
2655
|
-
rulesLoaded:
|
|
2902
|
+
rulesLoaded: z5.number().int().positive()
|
|
2656
2903
|
})
|
|
2657
2904
|
}),
|
|
2658
2905
|
agentFormatBaseSchema.extend({
|
|
2659
|
-
passed:
|
|
2660
|
-
score:
|
|
2661
|
-
status:
|
|
2662
|
-
reasons:
|
|
2906
|
+
passed: z5.literal(false),
|
|
2907
|
+
score: z5.never().optional(),
|
|
2908
|
+
status: z5.literal("indeterminate"),
|
|
2909
|
+
reasons: z5.tuple([z5.literal("zero_rules_loaded")]),
|
|
2663
2910
|
integrity: agentIntegritySchema.extend({
|
|
2664
|
-
rulesLoaded:
|
|
2911
|
+
rulesLoaded: z5.literal(0)
|
|
2665
2912
|
})
|
|
2666
2913
|
}),
|
|
2667
2914
|
// A finalized Run can explicitly allow inert governance. Preserve the
|
|
@@ -2669,30 +2916,30 @@ var agentFormatSchema = z3.union([
|
|
|
2669
2916
|
// verdict; requiring Run pins prevents generic zero-rule envelopes from
|
|
2670
2917
|
// accidentally becoming green.
|
|
2671
2918
|
agentFormatBaseSchema.extend({
|
|
2672
|
-
passed:
|
|
2673
|
-
score:
|
|
2674
|
-
status:
|
|
2675
|
-
reasons:
|
|
2919
|
+
passed: z5.literal(true),
|
|
2920
|
+
score: z5.never().optional(),
|
|
2921
|
+
status: z5.literal("indeterminate"),
|
|
2922
|
+
reasons: z5.tuple([z5.literal("zero_rules_loaded")]),
|
|
2676
2923
|
integrity: agentIntegritySchema.extend({
|
|
2677
|
-
rulesLoaded:
|
|
2924
|
+
rulesLoaded: z5.literal(0)
|
|
2678
2925
|
}),
|
|
2679
2926
|
provenance: agentRunProvenanceSchema,
|
|
2680
|
-
verdict: agentRunVerdictSchema.extend({ exitCode:
|
|
2927
|
+
verdict: agentRunVerdictSchema.extend({ exitCode: z5.literal(0) })
|
|
2681
2928
|
})
|
|
2682
2929
|
]);
|
|
2683
|
-
var agentErrorEnvelopeSchema =
|
|
2684
|
-
schemaVersion:
|
|
2685
|
-
passed:
|
|
2686
|
-
error:
|
|
2687
|
-
code:
|
|
2688
|
-
message:
|
|
2930
|
+
var agentErrorEnvelopeSchema = z5.object({
|
|
2931
|
+
schemaVersion: z5.literal(AGENT_FORMAT_SCHEMA_VERSION),
|
|
2932
|
+
passed: z5.literal(false),
|
|
2933
|
+
error: z5.object({
|
|
2934
|
+
code: z5.string().min(1),
|
|
2935
|
+
message: z5.string().min(1)
|
|
2689
2936
|
}),
|
|
2690
2937
|
provenance: agentRunProvenanceSchema.optional(),
|
|
2691
2938
|
verdict: agentRunVerdictSchema.optional(),
|
|
2692
|
-
cloudReport:
|
|
2693
|
-
notices:
|
|
2939
|
+
cloudReport: z5.enum(["accepted", "reported", "failed", "skipped"]).optional(),
|
|
2940
|
+
notices: z5.array(z5.string()).optional()
|
|
2694
2941
|
});
|
|
2695
|
-
var agentOutputSchema =
|
|
2942
|
+
var agentOutputSchema = z5.union([agentFormatSchema, agentErrorEnvelopeSchema]);
|
|
2696
2943
|
function normalizeSeverity(severity) {
|
|
2697
2944
|
return severitySchema.safeParse(severity).success ? severity : severityFromLevel(legacySeverityLevelSchema.parse(severity));
|
|
2698
2945
|
}
|
|
@@ -2805,6 +3052,25 @@ export {
|
|
|
2805
3052
|
byCode,
|
|
2806
3053
|
byRuleId,
|
|
2807
3054
|
explainUrlForCode,
|
|
3055
|
+
digestHexStringSchema,
|
|
3056
|
+
digestHexSchema,
|
|
3057
|
+
analysisPlanIdStringSchema,
|
|
3058
|
+
analysisPlanIdSchema,
|
|
3059
|
+
evaluationReceiptIdSchema,
|
|
3060
|
+
evaluationReceiptIdStringSchema,
|
|
3061
|
+
parseDigestHex,
|
|
3062
|
+
analysisPlanIdFromDigest,
|
|
3063
|
+
evaluationReceiptIdFromDigest,
|
|
3064
|
+
mintEvaluationReceiptId,
|
|
3065
|
+
parseAnalysisPlanId,
|
|
3066
|
+
parseEvaluationReceiptId,
|
|
3067
|
+
CANONICAL_FACT_MAX_CONFLICTS_V1,
|
|
3068
|
+
CANONICAL_FACT_MAX_VALUES_PER_CONFLICT_V1,
|
|
3069
|
+
CANONICAL_FACT_MAX_PROVENANCE_PER_VALUE_V1,
|
|
3070
|
+
canonicalFactConflictValueV1Schema,
|
|
3071
|
+
canonicalFactConflictV1Schema,
|
|
3072
|
+
canonicalFactIntegrityV1Schema,
|
|
3073
|
+
normalizeCanonicalFactIntegrityV1,
|
|
2808
3074
|
canonicalJson,
|
|
2809
3075
|
hash64Hex,
|
|
2810
3076
|
componentId,
|
|
@@ -2870,11 +3136,13 @@ export {
|
|
|
2870
3136
|
globalGovernanceRecordSchema,
|
|
2871
3137
|
componentGovernanceRecordSchema,
|
|
2872
3138
|
componentGovernanceRecordsSchema,
|
|
3139
|
+
parseComponentGovernancePolicyJson,
|
|
2873
3140
|
canonicalBridgeV1Schema,
|
|
2874
3141
|
governanceConfigSchema,
|
|
2875
3142
|
markPresetSourcedRules,
|
|
2876
3143
|
isPresetSourcedRule,
|
|
2877
3144
|
resolveComponentGovernance,
|
|
3145
|
+
resolveGovernanceRecordsForIdentity,
|
|
2878
3146
|
normalizeGovernanceConfig,
|
|
2879
3147
|
g,
|
|
2880
3148
|
RULE_FAMILY_MEMBERS,
|
|
@@ -2912,4 +3180,4 @@ export {
|
|
|
2912
3180
|
normalizeFinding,
|
|
2913
3181
|
normalizeViolation
|
|
2914
3182
|
};
|
|
2915
|
-
//# sourceMappingURL=chunk-
|
|
3183
|
+
//# sourceMappingURL=chunk-BMPYIUZE.js.map
|