@usefragments/core 1.11.0 → 2.0.1
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-3LLRNCPX.js → chunk-MZ2FS7U4.js} +1 -1
- package/dist/chunk-MZ2FS7U4.js.map +1 -0
- package/dist/{chunk-RPSEABY3.js → chunk-QPOKQ5H6.js} +30 -34
- package/dist/chunk-QPOKQ5H6.js.map +1 -0
- package/dist/codes/index.d.ts +1 -1
- package/dist/codes/index.js +1 -1
- package/dist/compiled-types/index.d.ts +1 -1
- package/dist/generate/index.d.ts +1 -1
- package/dist/{governance-BAsy1k2H.d.ts → governance-hOPXGbbs.d.ts} +3 -3
- package/dist/index.d.ts +145 -6026
- package/dist/index.js +298 -860
- package/dist/index.js.map +1 -1
- package/dist/preview-runtime.d.ts +1 -1
- package/dist/react-types.d.ts +1 -1
- package/dist/schemas/index.js +1 -1
- package/dist/storyAdapter.d.ts +1 -1
- package/dist/test-utils.d.ts +1 -1
- package/dist/topology/index.d.ts +1 -1
- package/dist/topology/index.js +1 -1
- package/package.json +1 -1
- package/src/approved-contract-tokens.test.ts +39 -0
- package/src/approved-contract-tokens.ts +18 -0
- package/src/canonical-source.ts +41 -0
- package/src/codes/__tests__/codes.test.ts +4 -0
- package/src/codes/codes.ts +10 -0
- package/src/domain-ids.test.ts +9 -26
- package/src/domain-ids.ts +0 -45
- package/src/evaluation/evaluate.ts +17 -7
- package/src/evaluation/evaluation-v2-receipt-v1.test.ts +20 -8
- package/src/evaluation/index.ts +1 -1
- package/src/facts/builders.ts +4 -0
- package/src/facts/fact-index.ts +4 -0
- package/src/facts/facts.test.ts +70 -0
- package/src/facts/types.ts +4 -0
- package/src/governance.ts +18 -0
- package/src/identity/usage.test.ts +64 -0
- package/src/identity/usage.ts +7 -1
- package/src/index.ts +15 -79
- package/src/rules/components-prefer-library.ts +110 -33
- package/src/topology/resolve-area.ts +1 -1
- package/src/types.ts +0 -3
- package/dist/chunk-3LLRNCPX.js.map +0 -1
- package/dist/chunk-RPSEABY3.js.map +0 -1
- package/src/feature-plan/digest.ts +0 -217
- package/src/feature-plan/feature-plan-v1.test.ts +0 -529
- package/src/feature-plan/index.ts +0 -65
- package/src/feature-plan/types.ts +0 -628
package/dist/index.js
CHANGED
|
@@ -66,7 +66,7 @@ import {
|
|
|
66
66
|
} from "./chunk-SH4KPIYH.js";
|
|
67
67
|
import {
|
|
68
68
|
resolveArea
|
|
69
|
-
} from "./chunk-
|
|
69
|
+
} from "./chunk-MZ2FS7U4.js";
|
|
70
70
|
import {
|
|
71
71
|
generateContext
|
|
72
72
|
} from "./chunk-X34IA4LR.js";
|
|
@@ -113,12 +113,6 @@ import {
|
|
|
113
113
|
factEvidenceSchema,
|
|
114
114
|
factId,
|
|
115
115
|
factLocationSchema,
|
|
116
|
-
featurePlanIdFromEntropy,
|
|
117
|
-
featurePlanIdSchema,
|
|
118
|
-
featurePlanIdStringSchema,
|
|
119
|
-
featureRevisionIdFromDigest,
|
|
120
|
-
featureRevisionIdSchema,
|
|
121
|
-
featureRevisionIdStringSchema,
|
|
122
116
|
findingFixSchema,
|
|
123
117
|
findingReplaceClassTokenFixSchema,
|
|
124
118
|
findingReplaceComponentFixSchema,
|
|
@@ -194,10 +188,9 @@ import {
|
|
|
194
188
|
ownedImportMatchesRoot,
|
|
195
189
|
ownedImportsEqual,
|
|
196
190
|
parseAnalysisPlanId,
|
|
191
|
+
parseComponentGovernancePolicyJson,
|
|
197
192
|
parseDigestHex,
|
|
198
193
|
parseEvaluationReceiptId,
|
|
199
|
-
parseFeaturePlanId,
|
|
200
|
-
parseFeatureRevisionId,
|
|
201
194
|
policyExcludeMatchesPath,
|
|
202
195
|
policyExcludeSchema,
|
|
203
196
|
projectSupersededImportPathPreferences,
|
|
@@ -208,7 +201,7 @@ import {
|
|
|
208
201
|
suppressionDirectiveSchema,
|
|
209
202
|
validatorResultSchema,
|
|
210
203
|
violationSchema
|
|
211
|
-
} from "./chunk-
|
|
204
|
+
} from "./chunk-QPOKQ5H6.js";
|
|
212
205
|
import {
|
|
213
206
|
isPortableRepoPath,
|
|
214
207
|
normalizeConfigPath,
|
|
@@ -1346,14 +1339,14 @@ function rgbToLab(rgb) {
|
|
|
1346
1339
|
b = b > 0.04045 ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;
|
|
1347
1340
|
let x = (r * 0.4124564 + g2 * 0.3575761 + b * 0.1804375) / 0.95047;
|
|
1348
1341
|
let y = r * 0.2126729 + g2 * 0.7151522 + b * 0.072175;
|
|
1349
|
-
let
|
|
1342
|
+
let z11 = (r * 0.0193339 + g2 * 0.119192 + b * 0.9503041) / 1.08883;
|
|
1350
1343
|
x = x > 8856e-6 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
|
|
1351
1344
|
y = y > 8856e-6 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
|
|
1352
|
-
|
|
1345
|
+
z11 = z11 > 8856e-6 ? Math.pow(z11, 1 / 3) : 7.787 * z11 + 16 / 116;
|
|
1353
1346
|
return {
|
|
1354
1347
|
l: 116 * y - 16,
|
|
1355
1348
|
a: 500 * (x - y),
|
|
1356
|
-
b: 200 * (y -
|
|
1349
|
+
b: 200 * (y - z11)
|
|
1357
1350
|
};
|
|
1358
1351
|
}
|
|
1359
1352
|
|
|
@@ -5267,6 +5260,56 @@ function isEnforceableHtmlEquivalent(args) {
|
|
|
5267
5260
|
return builtIn !== null && builtIn.canonical === args.canonical;
|
|
5268
5261
|
}
|
|
5269
5262
|
|
|
5263
|
+
// src/identity/usage.ts
|
|
5264
|
+
function indexComponentIdentityUsage(ix) {
|
|
5265
|
+
const nodesById = new Map(ix.byKind("usage_node").map((node) => [node.id, node]));
|
|
5266
|
+
const definitions = new Set(
|
|
5267
|
+
ix.byKind("component_definition").map((definition) => definition.componentKey)
|
|
5268
|
+
);
|
|
5269
|
+
const nodesByComponent = /* @__PURE__ */ new Map();
|
|
5270
|
+
for (const usage of ix.byKind("usage_component")) {
|
|
5271
|
+
const node = nodesById.get(usage.nodeId);
|
|
5272
|
+
if (!node) continue;
|
|
5273
|
+
const componentKey = usage.definitionKey && definitions.has(usage.definitionKey) ? usage.definitionKey : String(usage.componentId);
|
|
5274
|
+
const nodes = nodesByComponent.get(componentKey) ?? /* @__PURE__ */ new Map();
|
|
5275
|
+
nodes.set(node.id, node);
|
|
5276
|
+
nodesByComponent.set(componentKey, nodes);
|
|
5277
|
+
}
|
|
5278
|
+
return new Map(
|
|
5279
|
+
[...nodesByComponent].map(([componentKey, nodesByIdForComponent]) => {
|
|
5280
|
+
const nodes = [...nodesByIdForComponent.values()];
|
|
5281
|
+
return [
|
|
5282
|
+
componentKey,
|
|
5283
|
+
{
|
|
5284
|
+
usageCount: nodes.length,
|
|
5285
|
+
blastRadius: new Set(nodes.map((node) => node.file)).size,
|
|
5286
|
+
nodes
|
|
5287
|
+
}
|
|
5288
|
+
];
|
|
5289
|
+
})
|
|
5290
|
+
);
|
|
5291
|
+
}
|
|
5292
|
+
|
|
5293
|
+
// src/canonical-source.ts
|
|
5294
|
+
function canonicalSourceIncludesExport(source, name) {
|
|
5295
|
+
const role = name.split(".").at(-1) ?? name;
|
|
5296
|
+
const matches = (names) => names.includes(name) || names.includes(role);
|
|
5297
|
+
return !matches(source.exclude ?? []) && (source.include === void 0 || matches(source.include));
|
|
5298
|
+
}
|
|
5299
|
+
function canonicalSourceContainsFile(source, file) {
|
|
5300
|
+
const root = source.kind === "directory" ? source.path : source.kind === "registry" ? source.installPath : source.implementationPath;
|
|
5301
|
+
if (!root) return false;
|
|
5302
|
+
const normalize = (value) => value.replace(/\\/g, "/").replace(/^\.\//, "").replace(/\/$/, "");
|
|
5303
|
+
const normalizedRoot = normalize(root);
|
|
5304
|
+
const normalizedFile = normalize(file);
|
|
5305
|
+
return normalizedRoot === "." || normalizedFile === normalizedRoot || normalizedFile.startsWith(`${normalizedRoot}/`);
|
|
5306
|
+
}
|
|
5307
|
+
function isCanonicalSourceDefinition(file, exportName, sources) {
|
|
5308
|
+
return sources.some(
|
|
5309
|
+
(source) => canonicalSourceContainsFile(source, file) && canonicalSourceIncludesExport(source, exportName)
|
|
5310
|
+
);
|
|
5311
|
+
}
|
|
5312
|
+
|
|
5270
5313
|
// src/canonical-direction.ts
|
|
5271
5314
|
function projectCanonicalDirectionConflicts(ix, canonicalSources) {
|
|
5272
5315
|
const npmSources = canonicalSources.filter(
|
|
@@ -5500,6 +5543,11 @@ function ruleComponentsPreferLibrary(ix) {
|
|
|
5500
5543
|
const configuredSources = canonicalSourcesFromPolicy(policy.options?.canonicalSources);
|
|
5501
5544
|
const conflicts = projectCanonicalDirectionConflicts(ix, configuredSources);
|
|
5502
5545
|
const sources = configuredSources.map((source) => suppressConflictedExports(source, conflicts));
|
|
5546
|
+
const approvedLocalDefinitionKeys = Array.isArray(policy.options?.approvedLocalDefinitionKeys) ? new Set(
|
|
5547
|
+
policy.options.approvedLocalDefinitionKeys.filter(
|
|
5548
|
+
(key) => typeof key === "string"
|
|
5549
|
+
)
|
|
5550
|
+
) : void 0;
|
|
5503
5551
|
const mappings = canonicalMappingsFromPolicy(policy.options?.canonicalMappings).filter(
|
|
5504
5552
|
(mapping) => !canonicalDirectionConflictsTarget(conflicts, mapping.importPath, mapping.name)
|
|
5505
5553
|
);
|
|
@@ -5509,12 +5557,33 @@ function ruleComponentsPreferLibrary(ix) {
|
|
|
5509
5557
|
const textByNode = indexTextChildrenByNodeId(ix);
|
|
5510
5558
|
const classTokensByNode = indexClassTokensByNode(ix);
|
|
5511
5559
|
const reimplTargets = canonicalReimplTargets(sources, mappings);
|
|
5512
|
-
const canonicalDirectoryResolvedNodes = indexCanonicalDirectoryResolvedNodes(
|
|
5560
|
+
const canonicalDirectoryResolvedNodes = indexCanonicalDirectoryResolvedNodes(
|
|
5561
|
+
ix,
|
|
5562
|
+
sources,
|
|
5563
|
+
approvedLocalDefinitionKeys
|
|
5564
|
+
);
|
|
5513
5565
|
const shadowRenderRootNodeIds = ix.policy.ruleConfig("components/shadow-component")?.enabled === true ? indexShadowRenderRootNodeIds(ix) : /* @__PURE__ */ new Set();
|
|
5514
5566
|
const findings = [];
|
|
5515
5567
|
const seenImportFixes = /* @__PURE__ */ new Set();
|
|
5568
|
+
const canonicalIdentities = new Map(
|
|
5569
|
+
ix.byKind("component_identity").map((identity) => [identity.componentKey, identity.state === "canonical"])
|
|
5570
|
+
);
|
|
5571
|
+
const definitionsByFile = /* @__PURE__ */ new Map();
|
|
5572
|
+
for (const definition of ix.byKind("component_definition")) {
|
|
5573
|
+
const file = normalizePath(definition.file);
|
|
5574
|
+
const definitions = definitionsByFile.get(file) ?? [];
|
|
5575
|
+
definitions.push(definition);
|
|
5576
|
+
definitionsByFile.set(file, definitions);
|
|
5577
|
+
}
|
|
5516
5578
|
for (const node of ix.byKind("usage_node")) {
|
|
5517
|
-
if (
|
|
5579
|
+
if (isCanonicalSourceImplementation(
|
|
5580
|
+
node,
|
|
5581
|
+
sources,
|
|
5582
|
+
definitionsByFile,
|
|
5583
|
+
canonicalIdentities,
|
|
5584
|
+
approvedLocalDefinitionKeys
|
|
5585
|
+
))
|
|
5586
|
+
continue;
|
|
5518
5587
|
if (node.element.includes(".")) continue;
|
|
5519
5588
|
if (canonicalDirectoryResolvedNodes.has(node.id)) continue;
|
|
5520
5589
|
if (shadowRenderRootNodeIds.has(node.id)) continue;
|
|
@@ -5525,7 +5594,12 @@ function ruleComponentsPreferLibrary(ix) {
|
|
|
5525
5594
|
const nodeInputType = node.element === "input" ? readStaticStringProp(props, "type") : void 0;
|
|
5526
5595
|
const mapped = findMapping(node, nodeInputType, mappings);
|
|
5527
5596
|
if (mapped && imported && isMappedCanonicalImport(imported, mapped)) continue;
|
|
5528
|
-
if (imported && isCanonicalImport(
|
|
5597
|
+
if (imported && isCanonicalImport(
|
|
5598
|
+
imported,
|
|
5599
|
+
node.element,
|
|
5600
|
+
approvedLocalDefinitionKeys === void 0 ? sources : sources.filter((source) => source.kind !== "directory")
|
|
5601
|
+
))
|
|
5602
|
+
continue;
|
|
5529
5603
|
if (mapped) {
|
|
5530
5604
|
if (!shouldSuggestMapped(node, nodeInputType, imported, mapped)) continue;
|
|
5531
5605
|
const importPath = mapped.importPath;
|
|
@@ -6076,18 +6150,27 @@ function canonicalImportPath(source) {
|
|
|
6076
6150
|
if (source.kind === "registry") return source.importPath;
|
|
6077
6151
|
return void 0;
|
|
6078
6152
|
}
|
|
6079
|
-
function indexCanonicalDirectoryResolvedNodes(ix, sources) {
|
|
6153
|
+
function indexCanonicalDirectoryResolvedNodes(ix, sources, approvedLocalDefinitionKeys) {
|
|
6080
6154
|
const out = /* @__PURE__ */ new Set();
|
|
6081
|
-
const
|
|
6155
|
+
const directorySources = sources.filter(
|
|
6082
6156
|
(source) => source.kind === "directory"
|
|
6083
|
-
)
|
|
6084
|
-
if (
|
|
6085
|
-
|
|
6086
|
-
|
|
6157
|
+
);
|
|
6158
|
+
if (directorySources.length === 0) return out;
|
|
6159
|
+
const identities = new Map(
|
|
6160
|
+
ix.byKind("component_identity").map((identity) => [identity.componentKey, identity])
|
|
6161
|
+
);
|
|
6162
|
+
for (const [componentKey, usage] of indexComponentIdentityUsage(ix)) {
|
|
6163
|
+
if (approvedLocalDefinitionKeys !== void 0 && !approvedLocalDefinitionKeys.has(componentKey))
|
|
6164
|
+
continue;
|
|
6165
|
+
const identity = identities.get(componentKey);
|
|
6166
|
+
if (identity && identity.state !== "canonical") continue;
|
|
6167
|
+
const module = componentIdModule(componentKey);
|
|
6087
6168
|
if (module === void 0) continue;
|
|
6088
|
-
const
|
|
6089
|
-
if (
|
|
6090
|
-
|
|
6169
|
+
const exportName = componentKey.slice(componentKey.indexOf("#") + 1);
|
|
6170
|
+
if (directorySources.some(
|
|
6171
|
+
(source) => canonicalSourceContainsFile(source, module) && canonicalSourceIncludesExport(source, exportName)
|
|
6172
|
+
)) {
|
|
6173
|
+
for (const node of usage.nodes) out.add(node.id);
|
|
6091
6174
|
}
|
|
6092
6175
|
}
|
|
6093
6176
|
return out;
|
|
@@ -6096,24 +6179,23 @@ function componentIdModule(componentId2) {
|
|
|
6096
6179
|
const hash = componentId2.indexOf("#");
|
|
6097
6180
|
return hash > 0 ? componentId2.slice(0, hash) : void 0;
|
|
6098
6181
|
}
|
|
6099
|
-
function
|
|
6100
|
-
const
|
|
6182
|
+
function isCanonicalSourceImplementation(node, sources, definitionsByFile, canonicalIdentities, approvedLocalDefinitionKeys) {
|
|
6183
|
+
const definitions = definitionsByFile.get(normalizePath(node.file)) ?? [];
|
|
6101
6184
|
return sources.some((source) => {
|
|
6102
|
-
if (source
|
|
6103
|
-
|
|
6104
|
-
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
return false;
|
|
6185
|
+
if (!canonicalSourceContainsFile(source, node.file)) return false;
|
|
6186
|
+
if (approvedLocalDefinitionKeys === void 0 && (source.kind !== "directory" || source.include === void 0 && !source.exclude?.length))
|
|
6187
|
+
return true;
|
|
6188
|
+
const owners = definitions.filter(
|
|
6189
|
+
(definition) => definition.location && locationContains(definition.location, node.location)
|
|
6190
|
+
);
|
|
6191
|
+
return owners.length > 0 && owners.every(
|
|
6192
|
+
(definition) => (approvedLocalDefinitionKeys === void 0 || approvedLocalDefinitionKeys.has(definition.componentKey)) && canonicalIdentities.get(definition.componentKey) !== false && canonicalSourceIncludesExport(source, definition.exportName)
|
|
6193
|
+
);
|
|
6112
6194
|
});
|
|
6113
6195
|
}
|
|
6114
|
-
function
|
|
6115
|
-
|
|
6116
|
-
return
|
|
6196
|
+
function locationContains(region, node) {
|
|
6197
|
+
if (region.endLine === void 0 || region.endColumn === void 0) return false;
|
|
6198
|
+
return (node.line > region.line || node.line === region.line && node.column >= region.column) && (node.line < region.endLine || node.line === region.endLine && node.column < region.endColumn);
|
|
6117
6199
|
}
|
|
6118
6200
|
function normalizePath(path) {
|
|
6119
6201
|
return path.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
@@ -6122,33 +6204,6 @@ function isIdentifier(value) {
|
|
|
6122
6204
|
return /^[A-Za-z_$][\w$]*$/.test(value);
|
|
6123
6205
|
}
|
|
6124
6206
|
|
|
6125
|
-
// src/identity/usage.ts
|
|
6126
|
-
function indexComponentIdentityUsage(ix) {
|
|
6127
|
-
const nodesById = new Map(ix.byKind("usage_node").map((node) => [node.id, node]));
|
|
6128
|
-
const nodesByComponent = /* @__PURE__ */ new Map();
|
|
6129
|
-
for (const usage of ix.byKind("usage_component")) {
|
|
6130
|
-
const node = nodesById.get(usage.nodeId);
|
|
6131
|
-
if (!node) continue;
|
|
6132
|
-
const componentKey = String(usage.componentId);
|
|
6133
|
-
const nodes = nodesByComponent.get(componentKey) ?? /* @__PURE__ */ new Map();
|
|
6134
|
-
nodes.set(node.id, node);
|
|
6135
|
-
nodesByComponent.set(componentKey, nodes);
|
|
6136
|
-
}
|
|
6137
|
-
return new Map(
|
|
6138
|
-
[...nodesByComponent].map(([componentKey, nodesByIdForComponent]) => {
|
|
6139
|
-
const nodes = [...nodesByIdForComponent.values()];
|
|
6140
|
-
return [
|
|
6141
|
-
componentKey,
|
|
6142
|
-
{
|
|
6143
|
-
usageCount: nodes.length,
|
|
6144
|
-
blastRadius: new Set(nodes.map((node) => node.file)).size,
|
|
6145
|
-
nodes
|
|
6146
|
-
}
|
|
6147
|
-
];
|
|
6148
|
-
})
|
|
6149
|
-
);
|
|
6150
|
-
}
|
|
6151
|
-
|
|
6152
6207
|
// src/rules/components-shadow-component.ts
|
|
6153
6208
|
var RULE_ID4 = "components/shadow-component";
|
|
6154
6209
|
var RULE_VERSION4 = "1";
|
|
@@ -9389,11 +9444,11 @@ function collectPassthroughRecordValues(authored, path, allowed, diagnostics) {
|
|
|
9389
9444
|
}
|
|
9390
9445
|
}
|
|
9391
9446
|
function stableConfigDiagnostics(diagnostics) {
|
|
9392
|
-
const
|
|
9447
|
+
const unique2 = /* @__PURE__ */ new Map();
|
|
9393
9448
|
for (const diagnostic of diagnostics) {
|
|
9394
|
-
|
|
9449
|
+
unique2.set(`${diagnostic.code}\0${diagnostic.path}`, diagnostic);
|
|
9395
9450
|
}
|
|
9396
|
-
return [...
|
|
9451
|
+
return [...unique2.values()].sort(
|
|
9397
9452
|
(left, right) => left.path.localeCompare(right.path) || left.code.localeCompare(right.code) || left.message.localeCompare(right.message)
|
|
9398
9453
|
);
|
|
9399
9454
|
}
|
|
@@ -10889,607 +10944,12 @@ function coverageArtifactDigestV1(rawPlan, rawCoverage) {
|
|
|
10889
10944
|
);
|
|
10890
10945
|
}
|
|
10891
10946
|
|
|
10892
|
-
// src/feature-plan/types.ts
|
|
10893
|
-
import { z as z10 } from "zod";
|
|
10894
|
-
var FEATURE_PLAN_MAX_EVIDENCE_REFS_V1 = 200;
|
|
10895
|
-
var FEATURE_PLAN_MAX_USES_PER_KIND_V1 = 100;
|
|
10896
|
-
var FEATURE_PLAN_MAX_GAPS_V1 = 50;
|
|
10897
|
-
var FEATURE_PLAN_MAX_DECISIONS_V1 = 50;
|
|
10898
|
-
var FEATURE_PLAN_MAX_SCENARIOS_V1 = 50;
|
|
10899
|
-
var FEATURE_PLAN_MAX_ACCEPTANCE_ITEMS_V1 = 100;
|
|
10900
|
-
var FEATURE_PLAN_MAX_TEXT_BYTES_V1 = 32 * 1024;
|
|
10901
|
-
var AGENT_FEATURE_CONTEXT_MAX_BYTES_V1 = 64 * 1024;
|
|
10902
|
-
var utf8Length2 = (value) => new TextEncoder().encode(value).byteLength;
|
|
10903
|
-
var boundedString2 = (maxBytes = FEATURE_PLAN_MAX_TEXT_BYTES_V1) => z10.string().min(1).refine((value) => utf8Length2(value) <= maxBytes, `Value exceeds ${maxBytes} UTF-8 bytes`);
|
|
10904
|
-
var shortString = () => boundedString2(4096);
|
|
10905
|
-
var unique = (values) => new Set(values).size === values.length;
|
|
10906
|
-
var uniqueIdArray = (max = FEATURE_PLAN_MAX_EVIDENCE_REFS_V1) => z10.array(shortString()).max(max).refine(unique, "ID references must be unique");
|
|
10907
|
-
var evidenceRefV1Schema = z10.object({
|
|
10908
|
-
evidenceId: shortString(),
|
|
10909
|
-
kind: z10.enum(["user_intent", "image", "source", "contract", "pattern", "model"]),
|
|
10910
|
-
authority: z10.enum(["user_asserted", "source_observed", "contract_approved", "model_inferred"]),
|
|
10911
|
-
ref: boundedString2(),
|
|
10912
|
-
digest: digestHexStringSchema
|
|
10913
|
-
}).strict();
|
|
10914
|
-
var placementDecisionV1Schema = z10.object({
|
|
10915
|
-
targetKind: z10.enum(["page", "section"]),
|
|
10916
|
-
targetRef: shortString(),
|
|
10917
|
-
routeRef: shortString().optional(),
|
|
10918
|
-
parentSlotRef: shortString(),
|
|
10919
|
-
evidenceRefIds: uniqueIdArray()
|
|
10920
|
-
}).strict();
|
|
10921
|
-
var propValueSchema = z10.union([boundedString2(), z10.number().finite(), z10.boolean(), z10.null()]);
|
|
10922
|
-
var componentUseDecisionV1Schema = z10.object({
|
|
10923
|
-
useId: shortString(),
|
|
10924
|
-
componentId: shortString(),
|
|
10925
|
-
importPath: shortString(),
|
|
10926
|
-
purpose: boundedString2(),
|
|
10927
|
-
props: z10.record(shortString(), propValueSchema).refine((props) => Object.keys(props).length <= 100, "Component props exceed V1 limit"),
|
|
10928
|
-
evidenceRefIds: uniqueIdArray()
|
|
10929
|
-
}).strict();
|
|
10930
|
-
var tokenUseDecisionV1Schema = z10.object({
|
|
10931
|
-
useId: shortString(),
|
|
10932
|
-
tokenId: shortString(),
|
|
10933
|
-
role: shortString(),
|
|
10934
|
-
evidenceRefIds: uniqueIdArray()
|
|
10935
|
-
}).strict();
|
|
10936
|
-
var patternStatusV1Schema = z10.enum([
|
|
10937
|
-
"observed",
|
|
10938
|
-
"candidate",
|
|
10939
|
-
"approved_guidance",
|
|
10940
|
-
"contract_canonical",
|
|
10941
|
-
"deprecated"
|
|
10942
|
-
]);
|
|
10943
|
-
var patternUseDecisionV1Schema = z10.object({
|
|
10944
|
-
useId: shortString(),
|
|
10945
|
-
patternId: shortString(),
|
|
10946
|
-
patternRevisionDigest: digestHexStringSchema,
|
|
10947
|
-
status: patternStatusV1Schema,
|
|
10948
|
-
disposition: z10.enum(["reuse", "reference", "reject"]),
|
|
10949
|
-
evidenceRefIds: uniqueIdArray()
|
|
10950
|
-
}).strict().superRefine((pattern, context) => {
|
|
10951
|
-
if (pattern.disposition === "reuse" && pattern.status !== "approved_guidance" && pattern.status !== "contract_canonical") {
|
|
10952
|
-
context.addIssue({
|
|
10953
|
-
code: z10.ZodIssueCode.custom,
|
|
10954
|
-
path: ["disposition"],
|
|
10955
|
-
message: "Only approved-guidance or contract-canonical patterns may be reused"
|
|
10956
|
-
});
|
|
10957
|
-
}
|
|
10958
|
-
});
|
|
10959
|
-
var layoutConcernV1Schema = z10.enum([
|
|
10960
|
-
"outer_inline_spacing",
|
|
10961
|
-
"outer_block_spacing",
|
|
10962
|
-
"inner_padding",
|
|
10963
|
-
"child_gap",
|
|
10964
|
-
"max_inline_size",
|
|
10965
|
-
"scroll_x",
|
|
10966
|
-
"scroll_y",
|
|
10967
|
-
"sticky_offset",
|
|
10968
|
-
"breakpoint_switching"
|
|
10969
|
-
]);
|
|
10970
|
-
var layoutConcernOwnerV1Schema = z10.object({
|
|
10971
|
-
concern: layoutConcernV1Schema,
|
|
10972
|
-
ownerLayer: z10.enum([
|
|
10973
|
-
"application_shell",
|
|
10974
|
-
"route_shell",
|
|
10975
|
-
"page",
|
|
10976
|
-
"section",
|
|
10977
|
-
"pattern",
|
|
10978
|
-
"primitive"
|
|
10979
|
-
]),
|
|
10980
|
-
ownerRef: shortString(),
|
|
10981
|
-
childAction: z10.enum(["consume", "own", "override"]),
|
|
10982
|
-
tokenRef: shortString().optional(),
|
|
10983
|
-
breakpointRef: shortString().optional(),
|
|
10984
|
-
evidenceRefIds: uniqueIdArray(),
|
|
10985
|
-
overrideDecisionId: shortString().optional()
|
|
10986
|
-
}).strict().superRefine((row, context) => {
|
|
10987
|
-
if (row.childAction === "override" && !row.overrideDecisionId) {
|
|
10988
|
-
context.addIssue({
|
|
10989
|
-
code: z10.ZodIssueCode.custom,
|
|
10990
|
-
path: ["overrideDecisionId"],
|
|
10991
|
-
message: "A layout override must reference an approved decision"
|
|
10992
|
-
});
|
|
10993
|
-
}
|
|
10994
|
-
if (row.childAction !== "override" && row.overrideDecisionId) {
|
|
10995
|
-
context.addIssue({
|
|
10996
|
-
code: z10.ZodIssueCode.custom,
|
|
10997
|
-
path: ["overrideDecisionId"],
|
|
10998
|
-
message: "Only an override may reference an override decision"
|
|
10999
|
-
});
|
|
11000
|
-
}
|
|
11001
|
-
});
|
|
11002
|
-
var layoutOwnershipV1Schema = z10.object({
|
|
11003
|
-
concerns: z10.array(layoutConcernOwnerV1Schema).max(32).refine(
|
|
11004
|
-
(rows) => new Set(rows.map((row) => row.concern)).size === rows.length,
|
|
11005
|
-
"Each layout concern must have exactly one owner"
|
|
11006
|
-
)
|
|
11007
|
-
}).strict();
|
|
11008
|
-
var responsiveDecisionV1Schema = z10.object({
|
|
11009
|
-
decisionId: shortString(),
|
|
11010
|
-
source: z10.enum(["contract", "observed", "desktop_only"]),
|
|
11011
|
-
breakpointRef: shortString().optional(),
|
|
11012
|
-
behavior: boundedString2(),
|
|
11013
|
-
evidenceRefIds: uniqueIdArray()
|
|
11014
|
-
}).strict().superRefine((decision, context) => {
|
|
11015
|
-
if (decision.source !== "desktop_only" && !decision.breakpointRef) {
|
|
11016
|
-
context.addIssue({
|
|
11017
|
-
code: z10.ZodIssueCode.custom,
|
|
11018
|
-
path: ["breakpointRef"],
|
|
11019
|
-
message: "Responsive contract/observed decisions must pin a breakpoint"
|
|
11020
|
-
});
|
|
11021
|
-
}
|
|
11022
|
-
});
|
|
11023
|
-
var scenarioRequirementV1Schema = z10.object({
|
|
11024
|
-
scenarioId: shortString(),
|
|
11025
|
-
viewportRef: shortString().optional(),
|
|
11026
|
-
themeRef: shortString().optional(),
|
|
11027
|
-
actorRole: shortString().optional(),
|
|
11028
|
-
dataState: z10.enum(["default", "loading", "empty", "partial", "error"]),
|
|
11029
|
-
interactionState: z10.enum(["pristine", "dirty", "validating", "saving", "saved", "disabled"]).optional(),
|
|
11030
|
-
acceptanceIds: uniqueIdArray(FEATURE_PLAN_MAX_ACCEPTANCE_ITEMS_V1)
|
|
11031
|
-
}).strict();
|
|
11032
|
-
var gapDispositionV1Schema = z10.enum([
|
|
11033
|
-
"canonical_reuse",
|
|
11034
|
-
"approved_pattern",
|
|
11035
|
-
"local_composition",
|
|
11036
|
-
"intentional_one_off",
|
|
11037
|
-
"proposed_contract_addition",
|
|
11038
|
-
"unresolved"
|
|
11039
|
-
]);
|
|
11040
|
-
var capabilityGapV1Schema = z10.object({
|
|
11041
|
-
gapId: shortString(),
|
|
11042
|
-
capability: boundedString2(),
|
|
11043
|
-
required: z10.boolean(),
|
|
11044
|
-
disposition: gapDispositionV1Schema,
|
|
11045
|
-
reason: boundedString2(),
|
|
11046
|
-
evidenceRefIds: uniqueIdArray(),
|
|
11047
|
-
proposedContractCandidateId: shortString().optional()
|
|
11048
|
-
}).strict().superRefine((gap, context) => {
|
|
11049
|
-
if (gap.disposition === "proposed_contract_addition" && !gap.proposedContractCandidateId) {
|
|
11050
|
-
context.addIssue({
|
|
11051
|
-
code: z10.ZodIssueCode.custom,
|
|
11052
|
-
path: ["proposedContractCandidateId"],
|
|
11053
|
-
message: "A proposed contract addition must pin its candidate"
|
|
11054
|
-
});
|
|
11055
|
-
}
|
|
11056
|
-
if (gap.disposition !== "proposed_contract_addition" && gap.proposedContractCandidateId) {
|
|
11057
|
-
context.addIssue({
|
|
11058
|
-
code: z10.ZodIssueCode.custom,
|
|
11059
|
-
path: ["proposedContractCandidateId"],
|
|
11060
|
-
message: "Only a proposed contract addition may carry a candidate ID"
|
|
11061
|
-
});
|
|
11062
|
-
}
|
|
11063
|
-
});
|
|
11064
|
-
var featureAcceptanceItemV1Schema = z10.object({
|
|
11065
|
-
acceptanceId: shortString(),
|
|
11066
|
-
statement: boundedString2(),
|
|
11067
|
-
proof: z10.enum(["unit", "integration", "browser", "governance", "manual"]),
|
|
11068
|
-
required: z10.boolean(),
|
|
11069
|
-
evidenceRefIds: uniqueIdArray()
|
|
11070
|
-
}).strict();
|
|
11071
|
-
var decisionOptionV1Schema = z10.object({ optionId: shortString(), label: boundedString2(), consequence: boundedString2() }).strict();
|
|
11072
|
-
var decisionRequestV1Schema = z10.object({
|
|
11073
|
-
decisionId: shortString(),
|
|
11074
|
-
kind: z10.enum(["placement", "reuse", "gap", "layout_override", "responsive", "scope"]),
|
|
11075
|
-
question: boundedString2(),
|
|
11076
|
-
options: z10.array(decisionOptionV1Schema).min(2).max(20).refine(
|
|
11077
|
-
(options) => new Set(options.map((option) => option.optionId)).size === options.length,
|
|
11078
|
-
"Decision option IDs must be unique"
|
|
11079
|
-
),
|
|
11080
|
-
recommendedOptionId: shortString().optional(),
|
|
11081
|
-
required: z10.boolean(),
|
|
11082
|
-
evidenceRefIds: uniqueIdArray()
|
|
11083
|
-
}).strict().superRefine((decision, context) => {
|
|
11084
|
-
if (decision.recommendedOptionId && !decision.options.some((option) => option.optionId === decision.recommendedOptionId)) {
|
|
11085
|
-
context.addIssue({
|
|
11086
|
-
code: z10.ZodIssueCode.custom,
|
|
11087
|
-
path: ["recommendedOptionId"],
|
|
11088
|
-
message: "Recommended option must resolve inside the decision"
|
|
11089
|
-
});
|
|
11090
|
-
}
|
|
11091
|
-
});
|
|
11092
|
-
var decisionResolutionV1Schema = z10.object({ decisionId: shortString(), selectedOptionId: shortString() }).strict();
|
|
11093
|
-
var featurePinsV1Schema = z10.object({
|
|
11094
|
-
bindingId: shortString(),
|
|
11095
|
-
grounding: z10.object({
|
|
11096
|
-
sourceCommitId: shortString(),
|
|
11097
|
-
analysisPlanDigest: digestHexStringSchema,
|
|
11098
|
-
contextSliceDigest: digestHexStringSchema
|
|
11099
|
-
}).strict(),
|
|
11100
|
-
authority: z10.object({
|
|
11101
|
-
fcid: digestHexStringSchema,
|
|
11102
|
-
contractArtifactDigest: digestHexStringSchema,
|
|
11103
|
-
analysisObligationsDigest: digestHexStringSchema
|
|
11104
|
-
}).strict(),
|
|
11105
|
-
evidenceDigest: digestHexStringSchema
|
|
11106
|
-
}).strict();
|
|
11107
|
-
var commonRevisionShape = {
|
|
11108
|
-
pins: featurePinsV1Schema,
|
|
11109
|
-
placement: placementDecisionV1Schema,
|
|
11110
|
-
componentUses: z10.array(componentUseDecisionV1Schema).max(FEATURE_PLAN_MAX_USES_PER_KIND_V1),
|
|
11111
|
-
tokenUses: z10.array(tokenUseDecisionV1Schema).max(FEATURE_PLAN_MAX_USES_PER_KIND_V1),
|
|
11112
|
-
patternUses: z10.array(patternUseDecisionV1Schema).max(FEATURE_PLAN_MAX_USES_PER_KIND_V1),
|
|
11113
|
-
layout: layoutOwnershipV1Schema,
|
|
11114
|
-
responsive: z10.array(responsiveDecisionV1Schema).max(FEATURE_PLAN_MAX_DECISIONS_V1),
|
|
11115
|
-
scenarios: z10.array(scenarioRequirementV1Schema).max(FEATURE_PLAN_MAX_SCENARIOS_V1),
|
|
11116
|
-
gaps: z10.array(capabilityGapV1Schema).max(FEATURE_PLAN_MAX_GAPS_V1),
|
|
11117
|
-
acceptance: z10.array(featureAcceptanceItemV1Schema).max(FEATURE_PLAN_MAX_ACCEPTANCE_ITEMS_V1),
|
|
11118
|
-
evidenceRefs: z10.array(evidenceRefV1Schema).max(FEATURE_PLAN_MAX_EVIDENCE_REFS_V1)
|
|
11119
|
-
};
|
|
11120
|
-
function addUniqueIdIssue(rows, key, path, context) {
|
|
11121
|
-
const values = rows.map((row) => row[key]).filter((value) => typeof value === "string");
|
|
11122
|
-
if (new Set(values).size !== values.length) {
|
|
11123
|
-
context.addIssue({
|
|
11124
|
-
code: z10.ZodIssueCode.custom,
|
|
11125
|
-
path: [path],
|
|
11126
|
-
message: `${path} IDs must be unique`
|
|
11127
|
-
});
|
|
11128
|
-
}
|
|
11129
|
-
}
|
|
11130
|
-
function validateCommonGraph(graph, context, decisionIds) {
|
|
11131
|
-
addUniqueIdIssue(graph.evidenceRefs, "evidenceId", "evidenceRefs", context);
|
|
11132
|
-
addUniqueIdIssue(graph.componentUses, "useId", "componentUses", context);
|
|
11133
|
-
addUniqueIdIssue(graph.tokenUses, "useId", "tokenUses", context);
|
|
11134
|
-
addUniqueIdIssue(graph.patternUses, "useId", "patternUses", context);
|
|
11135
|
-
addUniqueIdIssue(graph.responsive, "decisionId", "responsive", context);
|
|
11136
|
-
addUniqueIdIssue(graph.scenarios, "scenarioId", "scenarios", context);
|
|
11137
|
-
addUniqueIdIssue(graph.gaps, "gapId", "gaps", context);
|
|
11138
|
-
addUniqueIdIssue(graph.acceptance, "acceptanceId", "acceptance", context);
|
|
11139
|
-
const evidenceIds = new Set(graph.evidenceRefs.map((evidence) => evidence.evidenceId));
|
|
11140
|
-
const acceptanceIds = new Set(graph.acceptance.map((acceptance) => acceptance.acceptanceId));
|
|
11141
|
-
const evidenceReferences = [
|
|
11142
|
-
[graph.placement.evidenceRefIds, "placement.evidenceRefIds"],
|
|
11143
|
-
...graph.componentUses.map(
|
|
11144
|
-
(row, index) => [row.evidenceRefIds, `componentUses.${index}.evidenceRefIds`]
|
|
11145
|
-
),
|
|
11146
|
-
...graph.tokenUses.map(
|
|
11147
|
-
(row, index) => [row.evidenceRefIds, `tokenUses.${index}.evidenceRefIds`]
|
|
11148
|
-
),
|
|
11149
|
-
...graph.patternUses.map(
|
|
11150
|
-
(row, index) => [row.evidenceRefIds, `patternUses.${index}.evidenceRefIds`]
|
|
11151
|
-
),
|
|
11152
|
-
...graph.layout.concerns.map(
|
|
11153
|
-
(row, index) => [row.evidenceRefIds, `layout.concerns.${index}.evidenceRefIds`]
|
|
11154
|
-
),
|
|
11155
|
-
...graph.responsive.map(
|
|
11156
|
-
(row, index) => [row.evidenceRefIds, `responsive.${index}.evidenceRefIds`]
|
|
11157
|
-
),
|
|
11158
|
-
...graph.gaps.map(
|
|
11159
|
-
(row, index) => [row.evidenceRefIds, `gaps.${index}.evidenceRefIds`]
|
|
11160
|
-
),
|
|
11161
|
-
...graph.acceptance.map(
|
|
11162
|
-
(row, index) => [row.evidenceRefIds, `acceptance.${index}.evidenceRefIds`]
|
|
11163
|
-
)
|
|
11164
|
-
];
|
|
11165
|
-
for (const [references, path] of evidenceReferences) {
|
|
11166
|
-
for (const reference of references) {
|
|
11167
|
-
if (!evidenceIds.has(reference)) {
|
|
11168
|
-
context.addIssue({
|
|
11169
|
-
code: z10.ZodIssueCode.custom,
|
|
11170
|
-
path: path.split("."),
|
|
11171
|
-
message: `Unknown evidence reference: ${reference}`
|
|
11172
|
-
});
|
|
11173
|
-
}
|
|
11174
|
-
}
|
|
11175
|
-
}
|
|
11176
|
-
for (const [index, scenario] of graph.scenarios.entries()) {
|
|
11177
|
-
for (const acceptanceId of scenario.acceptanceIds) {
|
|
11178
|
-
if (!acceptanceIds.has(acceptanceId)) {
|
|
11179
|
-
context.addIssue({
|
|
11180
|
-
code: z10.ZodIssueCode.custom,
|
|
11181
|
-
path: ["scenarios", index, "acceptanceIds"],
|
|
11182
|
-
message: `Unknown acceptance reference: ${acceptanceId}`
|
|
11183
|
-
});
|
|
11184
|
-
}
|
|
11185
|
-
}
|
|
11186
|
-
}
|
|
11187
|
-
for (const [index, row] of graph.layout.concerns.entries()) {
|
|
11188
|
-
if (row.overrideDecisionId && !decisionIds.has(row.overrideDecisionId)) {
|
|
11189
|
-
context.addIssue({
|
|
11190
|
-
code: z10.ZodIssueCode.custom,
|
|
11191
|
-
path: ["layout", "concerns", index, "overrideDecisionId"],
|
|
11192
|
-
message: `Unknown decision reference: ${row.overrideDecisionId}`
|
|
11193
|
-
});
|
|
11194
|
-
}
|
|
11195
|
-
}
|
|
11196
|
-
}
|
|
11197
|
-
var proposalInputShape = {
|
|
11198
|
-
schemaVersion: z10.literal(1),
|
|
11199
|
-
kind: z10.literal("proposal"),
|
|
11200
|
-
planId: featurePlanIdStringSchema,
|
|
11201
|
-
parentRevisionDigest: digestHexStringSchema.optional(),
|
|
11202
|
-
...commonRevisionShape,
|
|
11203
|
-
questions: z10.array(decisionRequestV1Schema).max(FEATURE_PLAN_MAX_DECISIONS_V1)
|
|
11204
|
-
};
|
|
11205
|
-
function validateProposal(proposal, context) {
|
|
11206
|
-
addUniqueIdIssue(proposal.questions, "decisionId", "questions", context);
|
|
11207
|
-
const decisionIds = new Set(proposal.questions.map((question) => question.decisionId));
|
|
11208
|
-
validateCommonGraph(proposal, context, decisionIds);
|
|
11209
|
-
const evidenceIds = new Set(proposal.evidenceRefs.map((evidence) => evidence.evidenceId));
|
|
11210
|
-
for (const [index, question] of proposal.questions.entries()) {
|
|
11211
|
-
for (const reference of question.evidenceRefIds) {
|
|
11212
|
-
if (!evidenceIds.has(reference)) {
|
|
11213
|
-
context.addIssue({
|
|
11214
|
-
code: z10.ZodIssueCode.custom,
|
|
11215
|
-
path: ["questions", index, "evidenceRefIds"],
|
|
11216
|
-
message: `Unknown evidence reference: ${reference}`
|
|
11217
|
-
});
|
|
11218
|
-
}
|
|
11219
|
-
}
|
|
11220
|
-
}
|
|
11221
|
-
}
|
|
11222
|
-
var featureProposalInputV1Schema = z10.object(proposalInputShape).strict().superRefine(validateProposal);
|
|
11223
|
-
var featureProposalV1Schema = z10.object({
|
|
11224
|
-
...proposalInputShape,
|
|
11225
|
-
revisionId: featureRevisionIdStringSchema,
|
|
11226
|
-
revisionDigest: digestHexStringSchema
|
|
11227
|
-
}).strict().superRefine(validateProposal);
|
|
11228
|
-
var manifestInputShape = {
|
|
11229
|
-
schemaVersion: z10.literal(1),
|
|
11230
|
-
kind: z10.literal("approved_manifest"),
|
|
11231
|
-
planId: featurePlanIdStringSchema,
|
|
11232
|
-
parentRevisionDigest: digestHexStringSchema,
|
|
11233
|
-
proposalRevisionDigest: digestHexStringSchema,
|
|
11234
|
-
...commonRevisionShape,
|
|
11235
|
-
validatedGrounding: z10.object({
|
|
11236
|
-
sourceCommitId: shortString(),
|
|
11237
|
-
analysisPlanDigest: digestHexStringSchema,
|
|
11238
|
-
contextSliceDigest: digestHexStringSchema
|
|
11239
|
-
}).strict(),
|
|
11240
|
-
decisions: z10.array(decisionResolutionV1Schema).max(FEATURE_PLAN_MAX_DECISIONS_V1),
|
|
11241
|
-
approval: z10.object({
|
|
11242
|
-
approverUserId: shortString(),
|
|
11243
|
-
decisionDigest: digestHexStringSchema,
|
|
11244
|
-
approvedAt: z10.string().datetime({ offset: true }),
|
|
11245
|
-
expiresAt: z10.string().datetime({ offset: true }).optional()
|
|
11246
|
-
}).strict()
|
|
11247
|
-
};
|
|
11248
|
-
var portableRepositoryPathSchema = shortString().refine(
|
|
11249
|
-
(value) => !value.startsWith("/") && !value.includes("\\") && !value.split("/").includes(".."),
|
|
11250
|
-
"Expected a portable repository-relative path"
|
|
11251
|
-
);
|
|
11252
|
-
function validateManifest(manifest, context) {
|
|
11253
|
-
addUniqueIdIssue(manifest.decisions, "decisionId", "decisions", context);
|
|
11254
|
-
validateCommonGraph(manifest, context, new Set(manifest.decisions.map((row) => row.decisionId)));
|
|
11255
|
-
if (manifest.validatedGrounding.contextSliceDigest !== manifest.pins.grounding.contextSliceDigest) {
|
|
11256
|
-
context.addIssue({
|
|
11257
|
-
code: z10.ZodIssueCode.custom,
|
|
11258
|
-
path: ["validatedGrounding", "contextSliceDigest"],
|
|
11259
|
-
message: "Validated material context must match the pinned proposal context"
|
|
11260
|
-
});
|
|
11261
|
-
}
|
|
11262
|
-
for (const [index, gap] of manifest.gaps.entries()) {
|
|
11263
|
-
if (gap.required && (gap.disposition === "unresolved" || gap.disposition === "proposed_contract_addition")) {
|
|
11264
|
-
context.addIssue({
|
|
11265
|
-
code: z10.ZodIssueCode.custom,
|
|
11266
|
-
path: ["gaps", index, "disposition"],
|
|
11267
|
-
message: "A required unresolved or proposed-contract gap blocks approval until it is resolved"
|
|
11268
|
-
});
|
|
11269
|
-
}
|
|
11270
|
-
}
|
|
11271
|
-
}
|
|
11272
|
-
var approvedFeatureManifestInputV1Schema = z10.object(manifestInputShape).strict().superRefine(validateManifest);
|
|
11273
|
-
var approvedFeatureManifestV1Schema = z10.object({
|
|
11274
|
-
...manifestInputShape,
|
|
11275
|
-
revisionId: featureRevisionIdStringSchema,
|
|
11276
|
-
revisionDigest: digestHexStringSchema
|
|
11277
|
-
}).strict().superRefine(validateManifest);
|
|
11278
|
-
var agentFeatureContextV1Schema = z10.object({
|
|
11279
|
-
schemaVersion: z10.literal(1),
|
|
11280
|
-
planId: featurePlanIdStringSchema,
|
|
11281
|
-
manifestDigest: digestHexStringSchema,
|
|
11282
|
-
pins: featurePinsV1Schema,
|
|
11283
|
-
validatedGrounding: manifestInputShape.validatedGrounding,
|
|
11284
|
-
target: placementDecisionV1Schema,
|
|
11285
|
-
componentUses: commonRevisionShape.componentUses,
|
|
11286
|
-
tokenUses: commonRevisionShape.tokenUses,
|
|
11287
|
-
patternUses: commonRevisionShape.patternUses,
|
|
11288
|
-
layout: layoutOwnershipV1Schema,
|
|
11289
|
-
responsive: commonRevisionShape.responsive,
|
|
11290
|
-
scenarios: commonRevisionShape.scenarios,
|
|
11291
|
-
acceptedGaps: commonRevisionShape.gaps,
|
|
11292
|
-
acceptance: commonRevisionShape.acceptance,
|
|
11293
|
-
decisions: manifestInputShape.decisions,
|
|
11294
|
-
relevantFiles: z10.array(portableRepositoryPathSchema).max(500).refine(unique, "relevantFiles must be unique"),
|
|
11295
|
-
commands: z10.array(boundedString2()).max(100)
|
|
11296
|
-
}).strict().superRefine((contextValue, context) => {
|
|
11297
|
-
const graph = {
|
|
11298
|
-
pins: contextValue.pins,
|
|
11299
|
-
placement: contextValue.target,
|
|
11300
|
-
componentUses: contextValue.componentUses,
|
|
11301
|
-
tokenUses: contextValue.tokenUses,
|
|
11302
|
-
patternUses: contextValue.patternUses,
|
|
11303
|
-
layout: contextValue.layout,
|
|
11304
|
-
responsive: contextValue.responsive,
|
|
11305
|
-
scenarios: contextValue.scenarios,
|
|
11306
|
-
gaps: contextValue.acceptedGaps,
|
|
11307
|
-
acceptance: contextValue.acceptance,
|
|
11308
|
-
evidenceRefs: []
|
|
11309
|
-
};
|
|
11310
|
-
addUniqueIdIssue(contextValue.decisions, "decisionId", "decisions", context);
|
|
11311
|
-
addUniqueIdIssue(graph.componentUses, "useId", "componentUses", context);
|
|
11312
|
-
addUniqueIdIssue(graph.tokenUses, "useId", "tokenUses", context);
|
|
11313
|
-
addUniqueIdIssue(graph.patternUses, "useId", "patternUses", context);
|
|
11314
|
-
addUniqueIdIssue(graph.scenarios, "scenarioId", "scenarios", context);
|
|
11315
|
-
addUniqueIdIssue(graph.acceptance, "acceptanceId", "acceptance", context);
|
|
11316
|
-
const decisions = new Set(contextValue.decisions.map((row) => row.decisionId));
|
|
11317
|
-
for (const [index, row] of contextValue.layout.concerns.entries()) {
|
|
11318
|
-
if (row.overrideDecisionId && !decisions.has(row.overrideDecisionId)) {
|
|
11319
|
-
context.addIssue({
|
|
11320
|
-
code: z10.ZodIssueCode.custom,
|
|
11321
|
-
path: ["layout", "concerns", index, "overrideDecisionId"],
|
|
11322
|
-
message: `Unknown decision reference: ${row.overrideDecisionId}`
|
|
11323
|
-
});
|
|
11324
|
-
}
|
|
11325
|
-
}
|
|
11326
|
-
for (const [index, gap] of contextValue.acceptedGaps.entries()) {
|
|
11327
|
-
if (gap.required && (gap.disposition === "unresolved" || gap.disposition === "proposed_contract_addition")) {
|
|
11328
|
-
context.addIssue({
|
|
11329
|
-
code: z10.ZodIssueCode.custom,
|
|
11330
|
-
path: ["acceptedGaps", index],
|
|
11331
|
-
message: "Agent context cannot contain a required unresolved or proposed-contract gap"
|
|
11332
|
-
});
|
|
11333
|
-
}
|
|
11334
|
-
}
|
|
11335
|
-
});
|
|
11336
|
-
|
|
11337
|
-
// src/feature-plan/digest.ts
|
|
11338
|
-
var sortedUnique2 = (values) => [...new Set(values)].sort();
|
|
11339
|
-
function normalizeEvidenceRefs(row) {
|
|
11340
|
-
return { ...row, evidenceRefIds: sortedUnique2(row.evidenceRefIds) };
|
|
11341
|
-
}
|
|
11342
|
-
function normalizeCommon(value) {
|
|
11343
|
-
return {
|
|
11344
|
-
...value,
|
|
11345
|
-
placement: normalizeEvidenceRefs(value.placement),
|
|
11346
|
-
componentUses: value.componentUses.map(normalizeEvidenceRefs).sort((left, right) => compareCanonicalStrings(left.useId, right.useId)),
|
|
11347
|
-
tokenUses: value.tokenUses.map(normalizeEvidenceRefs).sort((left, right) => compareCanonicalStrings(left.useId, right.useId)),
|
|
11348
|
-
patternUses: value.patternUses.map(normalizeEvidenceRefs).sort((left, right) => compareCanonicalStrings(left.useId, right.useId)),
|
|
11349
|
-
layout: {
|
|
11350
|
-
concerns: value.layout.concerns.map(normalizeEvidenceRefs).sort((left, right) => compareCanonicalStrings(left.concern, right.concern))
|
|
11351
|
-
},
|
|
11352
|
-
responsive: value.responsive.map(normalizeEvidenceRefs).sort((left, right) => compareCanonicalStrings(left.decisionId, right.decisionId)),
|
|
11353
|
-
scenarios: value.scenarios.map((scenario) => ({ ...scenario, acceptanceIds: sortedUnique2(scenario.acceptanceIds) })).sort((left, right) => compareCanonicalStrings(left.scenarioId, right.scenarioId)),
|
|
11354
|
-
gaps: value.gaps.map(normalizeEvidenceRefs).sort((left, right) => compareCanonicalStrings(left.gapId, right.gapId)),
|
|
11355
|
-
acceptance: value.acceptance.map(normalizeEvidenceRefs).sort((left, right) => compareCanonicalStrings(left.acceptanceId, right.acceptanceId)),
|
|
11356
|
-
evidenceRefs: [...value.evidenceRefs].sort(
|
|
11357
|
-
(left, right) => compareCanonicalStrings(left.evidenceId, right.evidenceId)
|
|
11358
|
-
)
|
|
11359
|
-
};
|
|
11360
|
-
}
|
|
11361
|
-
function normalizeFeatureProposalInputV1(value) {
|
|
11362
|
-
const parsed = featureProposalInputV1Schema.parse(value);
|
|
11363
|
-
return normalizeCommon({
|
|
11364
|
-
...parsed,
|
|
11365
|
-
questions: parsed.questions.map((question) => ({ ...normalizeEvidenceRefs(question), options: [...question.options] })).sort((left, right) => compareCanonicalStrings(left.decisionId, right.decisionId))
|
|
11366
|
-
});
|
|
11367
|
-
}
|
|
11368
|
-
function proposalProjection(proposal) {
|
|
11369
|
-
return {
|
|
11370
|
-
schema: "feature-revision.v1",
|
|
11371
|
-
kind: proposal.kind,
|
|
11372
|
-
planId: proposal.planId,
|
|
11373
|
-
parentRevisionDigest: proposal.parentRevisionDigest,
|
|
11374
|
-
pins: proposal.pins,
|
|
11375
|
-
placement: proposal.placement,
|
|
11376
|
-
componentUses: proposal.componentUses,
|
|
11377
|
-
tokenUses: proposal.tokenUses,
|
|
11378
|
-
patternUses: proposal.patternUses,
|
|
11379
|
-
layout: proposal.layout,
|
|
11380
|
-
responsive: proposal.responsive,
|
|
11381
|
-
scenarios: proposal.scenarios,
|
|
11382
|
-
gaps: proposal.gaps,
|
|
11383
|
-
acceptance: proposal.acceptance,
|
|
11384
|
-
questions: proposal.questions,
|
|
11385
|
-
evidenceRefs: proposal.evidenceRefs
|
|
11386
|
-
};
|
|
11387
|
-
}
|
|
11388
|
-
function featureProposalRevisionDigestV1(value) {
|
|
11389
|
-
const proposal = normalizeFeatureProposalInputV1(value);
|
|
11390
|
-
return sha256Hex(canonicalPreimage(proposalProjection(proposal)));
|
|
11391
|
-
}
|
|
11392
|
-
function buildFeatureProposalV1(value) {
|
|
11393
|
-
const proposal = normalizeFeatureProposalInputV1(value);
|
|
11394
|
-
const revisionDigest = sha256Hex(canonicalPreimage(proposalProjection(proposal)));
|
|
11395
|
-
return featureProposalV1Schema.parse({
|
|
11396
|
-
...proposal,
|
|
11397
|
-
revisionId: featureRevisionIdFromDigest(revisionDigest),
|
|
11398
|
-
revisionDigest
|
|
11399
|
-
});
|
|
11400
|
-
}
|
|
11401
|
-
function parseFeatureProposalV1(value) {
|
|
11402
|
-
const parsed = featureProposalV1Schema.parse(value);
|
|
11403
|
-
const { revisionId, revisionDigest, ...input } = parsed;
|
|
11404
|
-
const rebuilt = buildFeatureProposalV1(input);
|
|
11405
|
-
if (revisionId !== rebuilt.revisionId || revisionDigest !== rebuilt.revisionDigest) {
|
|
11406
|
-
throw new TypeError("Feature proposal derived identity does not match its semantic projection");
|
|
11407
|
-
}
|
|
11408
|
-
return rebuilt;
|
|
11409
|
-
}
|
|
11410
|
-
function normalizeApprovedFeatureManifestInputV1(value) {
|
|
11411
|
-
const parsed = approvedFeatureManifestInputV1Schema.parse(value);
|
|
11412
|
-
return normalizeCommon({
|
|
11413
|
-
...parsed,
|
|
11414
|
-
decisions: [...parsed.decisions].sort(
|
|
11415
|
-
(left, right) => compareCanonicalStrings(left.decisionId, right.decisionId)
|
|
11416
|
-
),
|
|
11417
|
-
approval: { ...parsed.approval },
|
|
11418
|
-
validatedGrounding: { ...parsed.validatedGrounding }
|
|
11419
|
-
});
|
|
11420
|
-
}
|
|
11421
|
-
function manifestProjection(manifest) {
|
|
11422
|
-
return {
|
|
11423
|
-
schema: "feature-revision.v1",
|
|
11424
|
-
kind: manifest.kind,
|
|
11425
|
-
planId: manifest.planId,
|
|
11426
|
-
parentRevisionDigest: manifest.parentRevisionDigest,
|
|
11427
|
-
proposalRevisionDigest: manifest.proposalRevisionDigest,
|
|
11428
|
-
pins: manifest.pins,
|
|
11429
|
-
validatedGrounding: manifest.validatedGrounding,
|
|
11430
|
-
placement: manifest.placement,
|
|
11431
|
-
componentUses: manifest.componentUses,
|
|
11432
|
-
tokenUses: manifest.tokenUses,
|
|
11433
|
-
patternUses: manifest.patternUses,
|
|
11434
|
-
layout: manifest.layout,
|
|
11435
|
-
responsive: manifest.responsive,
|
|
11436
|
-
scenarios: manifest.scenarios,
|
|
11437
|
-
gaps: manifest.gaps,
|
|
11438
|
-
acceptance: manifest.acceptance,
|
|
11439
|
-
evidenceRefs: manifest.evidenceRefs,
|
|
11440
|
-
decisions: manifest.decisions,
|
|
11441
|
-
approval: {
|
|
11442
|
-
approverUserId: manifest.approval.approverUserId,
|
|
11443
|
-
decisionDigest: manifest.approval.decisionDigest,
|
|
11444
|
-
expiresAt: manifest.approval.expiresAt
|
|
11445
|
-
}
|
|
11446
|
-
};
|
|
11447
|
-
}
|
|
11448
|
-
function approvedFeatureManifestRevisionDigestV1(value) {
|
|
11449
|
-
const manifest = normalizeApprovedFeatureManifestInputV1(value);
|
|
11450
|
-
return sha256Hex(canonicalPreimage(manifestProjection(manifest)));
|
|
11451
|
-
}
|
|
11452
|
-
function buildApprovedFeatureManifestV1(value) {
|
|
11453
|
-
const manifest = normalizeApprovedFeatureManifestInputV1(value);
|
|
11454
|
-
const revisionDigest = sha256Hex(canonicalPreimage(manifestProjection(manifest)));
|
|
11455
|
-
return approvedFeatureManifestV1Schema.parse({
|
|
11456
|
-
...manifest,
|
|
11457
|
-
revisionId: featureRevisionIdFromDigest(revisionDigest),
|
|
11458
|
-
revisionDigest
|
|
11459
|
-
});
|
|
11460
|
-
}
|
|
11461
|
-
function parseApprovedFeatureManifestV1(value) {
|
|
11462
|
-
const parsed = approvedFeatureManifestV1Schema.parse(value);
|
|
11463
|
-
const { revisionId, revisionDigest, ...input } = parsed;
|
|
11464
|
-
const rebuilt = buildApprovedFeatureManifestV1(input);
|
|
11465
|
-
if (revisionId !== rebuilt.revisionId || revisionDigest !== rebuilt.revisionDigest) {
|
|
11466
|
-
throw new TypeError(
|
|
11467
|
-
"Approved manifest derived identity does not match its semantic projection"
|
|
11468
|
-
);
|
|
11469
|
-
}
|
|
11470
|
-
return rebuilt;
|
|
11471
|
-
}
|
|
11472
|
-
var agentFeatureContextV1Schema2 = agentFeatureContextV1Schema.superRefine(
|
|
11473
|
-
(value, context) => {
|
|
11474
|
-
const bytes = new TextEncoder().encode(canonicalPreimage(value)).byteLength;
|
|
11475
|
-
if (bytes > AGENT_FEATURE_CONTEXT_MAX_BYTES_V1) {
|
|
11476
|
-
context.addIssue({
|
|
11477
|
-
code: "custom",
|
|
11478
|
-
message: `Agent feature context exceeds ${AGENT_FEATURE_CONTEXT_MAX_BYTES_V1} UTF-8 bytes`
|
|
11479
|
-
});
|
|
11480
|
-
}
|
|
11481
|
-
}
|
|
11482
|
-
);
|
|
11483
|
-
function parseAgentFeatureContextV1(value) {
|
|
11484
|
-
return agentFeatureContextV1Schema2.parse(value);
|
|
11485
|
-
}
|
|
11486
|
-
|
|
11487
10947
|
// src/evaluation/types.ts
|
|
11488
10948
|
var EVALUATOR_VERSION = "evaluation-kernel:v1";
|
|
11489
10949
|
var EVALUATOR_VERSION_V2 = "evaluation-kernel:v2";
|
|
11490
10950
|
|
|
11491
10951
|
// src/evaluation/receipt.ts
|
|
11492
|
-
import { z as
|
|
10952
|
+
import { z as z10 } from "zod";
|
|
11493
10953
|
var EVALUATION_MAX_WAIVERS_V2 = 1e3;
|
|
11494
10954
|
var EVALUATION_MAX_WAIVER_MATCHES_V2 = 1e4;
|
|
11495
10955
|
var EVALUATION_MAX_FINDINGS_V2 = 1e4;
|
|
@@ -11497,112 +10957,112 @@ var EVALUATION_MAX_REASON_CODES_V2 = 64;
|
|
|
11497
10957
|
var EVALUATION_MAX_MAP_ENTRIES_V2 = 1e5;
|
|
11498
10958
|
var EVALUATION_MAX_POLICY_RULES_V2 = 1e4;
|
|
11499
10959
|
var EVALUATION_RECEIPT_STRING_MAX_BYTES_V1 = 4096;
|
|
11500
|
-
var
|
|
11501
|
-
var
|
|
11502
|
-
var
|
|
11503
|
-
var contractPreimageV1Schema =
|
|
11504
|
-
schema:
|
|
11505
|
-
domains:
|
|
10960
|
+
var utf8Length2 = (value) => new TextEncoder().encode(value).byteLength;
|
|
10961
|
+
var boundedString2 = (maxBytes = EVALUATION_RECEIPT_STRING_MAX_BYTES_V1) => z10.string().min(1).refine((value) => utf8Length2(value) <= maxBytes, `Value exceeds ${maxBytes} UTF-8 bytes`);
|
|
10962
|
+
var unique = (values) => new Set(values).size === values.length;
|
|
10963
|
+
var contractPreimageV1Schema = z10.object({
|
|
10964
|
+
schema: z10.literal(CONTRACT_PREIMAGE_SCHEMA),
|
|
10965
|
+
domains: z10.object({
|
|
11506
10966
|
components: digestHexStringSchema,
|
|
11507
10967
|
tokens: digestHexStringSchema,
|
|
11508
10968
|
canonicalMap: digestHexStringSchema,
|
|
11509
10969
|
policy: digestHexStringSchema
|
|
11510
10970
|
}).strict()
|
|
11511
10971
|
}).strict();
|
|
11512
|
-
var effectiveRulePolicySchema =
|
|
11513
|
-
var effectivePolicySchema =
|
|
11514
|
-
failOnWarnings:
|
|
11515
|
-
failOnInert:
|
|
11516
|
-
rules:
|
|
10972
|
+
var effectiveRulePolicySchema = z10.object({ trust: z10.enum(["canonical", "evidence", "none"]).optional() }).strict();
|
|
10973
|
+
var effectivePolicySchema = z10.object({
|
|
10974
|
+
failOnWarnings: z10.boolean(),
|
|
10975
|
+
failOnInert: z10.boolean().optional(),
|
|
10976
|
+
rules: z10.record(boundedString2(), effectiveRulePolicySchema).refine(
|
|
11517
10977
|
(rules) => Object.keys(rules).length <= EVALUATION_MAX_POLICY_RULES_V2,
|
|
11518
10978
|
"Policy rule map exceeds the V2 limit"
|
|
11519
10979
|
).optional()
|
|
11520
10980
|
}).strict();
|
|
11521
|
-
var evaluationTrustSchema =
|
|
11522
|
-
source:
|
|
11523
|
-
sources:
|
|
10981
|
+
var evaluationTrustSchema = z10.object({
|
|
10982
|
+
source: z10.enum(["verified", "unverified", "unknown"]),
|
|
10983
|
+
sources: z10.record(boundedString2(), z10.enum(["verified", "unverified", "unknown"])).refine(
|
|
11524
10984
|
(sources) => Object.keys(sources).length <= EVALUATION_MAX_MAP_ENTRIES_V2,
|
|
11525
10985
|
"Source trust map exceeds the V2 limit"
|
|
11526
10986
|
).optional(),
|
|
11527
|
-
mappings:
|
|
10987
|
+
mappings: z10.record(boundedString2(), z10.enum(["confirmed", "unconfirmed", "unknown"])).refine(
|
|
11528
10988
|
(mappings) => Object.keys(mappings).length <= EVALUATION_MAX_MAP_ENTRIES_V2,
|
|
11529
10989
|
"Mapping trust map exceeds the V2 limit"
|
|
11530
10990
|
)
|
|
11531
10991
|
}).strict();
|
|
11532
|
-
var waiverScopeSchema =
|
|
11533
|
-
|
|
11534
|
-
|
|
11535
|
-
|
|
11536
|
-
|
|
10992
|
+
var waiverScopeSchema = z10.discriminatedUnion("kind", [
|
|
10993
|
+
z10.object({ kind: z10.literal("finding"), fingerprint: boundedString2() }).strict(),
|
|
10994
|
+
z10.object({ kind: z10.literal("rule"), ruleId: boundedString2() }).strict(),
|
|
10995
|
+
z10.object({ kind: z10.literal("path"), pathPattern: boundedString2() }).strict(),
|
|
10996
|
+
z10.object({ kind: z10.literal("rule_path"), ruleId: boundedString2(), pathPattern: boundedString2() }).strict()
|
|
11537
10997
|
]);
|
|
11538
|
-
var effectiveEvaluationWaiverV2Schema =
|
|
11539
|
-
waiverId:
|
|
10998
|
+
var effectiveEvaluationWaiverV2Schema = z10.object({
|
|
10999
|
+
waiverId: boundedString2(),
|
|
11540
11000
|
scope: waiverScopeSchema,
|
|
11541
|
-
matchedFindingFingerprints:
|
|
11542
|
-
reason:
|
|
11543
|
-
expiresAt:
|
|
11001
|
+
matchedFindingFingerprints: z10.array(boundedString2()).min(1).max(EVALUATION_MAX_WAIVER_MATCHES_V2).refine(unique, "matched finding fingerprints must be unique"),
|
|
11002
|
+
reason: boundedString2(),
|
|
11003
|
+
expiresAt: z10.number().finite().optional()
|
|
11544
11004
|
}).strict();
|
|
11545
|
-
var evaluationIntegrityInputV2Schema =
|
|
11546
|
-
governance:
|
|
11547
|
-
inertConfigDiagnosticCount:
|
|
11548
|
-
profile:
|
|
11549
|
-
|
|
11550
|
-
state:
|
|
11551
|
-
profileId:
|
|
11552
|
-
profileVersion:
|
|
11005
|
+
var evaluationIntegrityInputV2Schema = z10.object({
|
|
11006
|
+
governance: z10.enum(["healthy", "inert"]),
|
|
11007
|
+
inertConfigDiagnosticCount: z10.number().int().nonnegative(),
|
|
11008
|
+
profile: z10.discriminatedUnion("state", [
|
|
11009
|
+
z10.object({
|
|
11010
|
+
state: z10.literal("known"),
|
|
11011
|
+
profileId: boundedString2(),
|
|
11012
|
+
profileVersion: boundedString2()
|
|
11553
11013
|
}).strict(),
|
|
11554
|
-
|
|
11555
|
-
state:
|
|
11556
|
-
profileId:
|
|
11557
|
-
profileVersion:
|
|
11014
|
+
z10.object({
|
|
11015
|
+
state: z10.literal("unknown"),
|
|
11016
|
+
profileId: boundedString2(),
|
|
11017
|
+
profileVersion: boundedString2().optional()
|
|
11558
11018
|
}).strict()
|
|
11559
11019
|
]),
|
|
11560
11020
|
facts: canonicalFactIntegrityV1Schema
|
|
11561
11021
|
}).strict();
|
|
11562
|
-
var baselineSchema =
|
|
11563
|
-
identity:
|
|
11022
|
+
var baselineSchema = z10.object({
|
|
11023
|
+
identity: z10.object({
|
|
11564
11024
|
bindingDigest: digestHexStringSchema,
|
|
11565
|
-
repositoryExternalId:
|
|
11025
|
+
repositoryExternalId: boundedString2(),
|
|
11566
11026
|
fcid: digestHexStringSchema,
|
|
11567
|
-
sourceCommitId:
|
|
11568
|
-
generationId:
|
|
11027
|
+
sourceCommitId: boundedString2(),
|
|
11028
|
+
generationId: boundedString2()
|
|
11569
11029
|
}).strict(),
|
|
11570
|
-
findingStates:
|
|
11030
|
+
findingStates: z10.record(boundedString2(), z10.enum(["introduced", "existing", "unknown"])).refine(
|
|
11571
11031
|
(states) => Object.keys(states).length <= EVALUATION_MAX_MAP_ENTRIES_V2,
|
|
11572
11032
|
"Baseline finding-state map exceeds the V2 limit"
|
|
11573
11033
|
)
|
|
11574
11034
|
}).strict();
|
|
11575
|
-
var evaluationInputV2RawSchema =
|
|
11576
|
-
schemaVersion:
|
|
11035
|
+
var evaluationInputV2RawSchema = z10.object({
|
|
11036
|
+
schemaVersion: z10.literal(2),
|
|
11577
11037
|
binding: repositoryBindingKeyV1Schema,
|
|
11578
11038
|
analysisPlan: analysisPlanV1Schema,
|
|
11579
|
-
contract:
|
|
11039
|
+
contract: z10.object({
|
|
11580
11040
|
fcid: digestHexStringSchema,
|
|
11581
11041
|
preimage: contractPreimageV1Schema,
|
|
11582
|
-
active:
|
|
11042
|
+
active: z10.boolean()
|
|
11583
11043
|
}).strict(),
|
|
11584
|
-
factSchemaVersion:
|
|
11585
|
-
facts:
|
|
11044
|
+
factSchemaVersion: boundedString2(256),
|
|
11045
|
+
facts: z10.instanceof(FactIndex),
|
|
11586
11046
|
factsDigest: digestHexStringSchema,
|
|
11587
|
-
coverage:
|
|
11047
|
+
coverage: z10.array(coverageRegionV1Schema).max(1e3),
|
|
11588
11048
|
policy: effectivePolicySchema,
|
|
11589
11049
|
baseline: baselineSchema.optional(),
|
|
11590
|
-
adoption:
|
|
11050
|
+
adoption: z10.union([z10.literal("unavailable"), z10.object({ regressed: z10.boolean() }).strict()]).optional(),
|
|
11591
11051
|
trust: evaluationTrustSchema.optional(),
|
|
11592
|
-
waivers:
|
|
11052
|
+
waivers: z10.array(effectiveEvaluationWaiverV2Schema).max(EVALUATION_MAX_WAIVERS_V2).refine(
|
|
11593
11053
|
(waivers) => new Set(waivers.map((waiver) => waiver.waiverId)).size === waivers.length,
|
|
11594
11054
|
"waiver IDs must be unique"
|
|
11595
11055
|
),
|
|
11596
11056
|
integrity: evaluationIntegrityInputV2Schema,
|
|
11597
|
-
evaluatedAt:
|
|
11598
|
-
evaluatorVersion:
|
|
11057
|
+
evaluatedAt: z10.number().finite(),
|
|
11058
|
+
evaluatorVersion: boundedString2(256)
|
|
11599
11059
|
}).strict().superRefine((input, context) => {
|
|
11600
11060
|
let plan;
|
|
11601
11061
|
try {
|
|
11602
11062
|
plan = parseAnalysisPlanV1(input.analysisPlan);
|
|
11603
11063
|
} catch (error) {
|
|
11604
11064
|
context.addIssue({
|
|
11605
|
-
code:
|
|
11065
|
+
code: z10.ZodIssueCode.custom,
|
|
11606
11066
|
path: ["analysisPlan"],
|
|
11607
11067
|
message: error instanceof Error ? error.message : "Invalid analysis plan identity"
|
|
11608
11068
|
});
|
|
@@ -11610,35 +11070,35 @@ var evaluationInputV2RawSchema = z11.object({
|
|
|
11610
11070
|
}
|
|
11611
11071
|
if (repositoryBindingDigestV1(plan.binding) !== repositoryBindingDigestV1(input.binding)) {
|
|
11612
11072
|
context.addIssue({
|
|
11613
|
-
code:
|
|
11073
|
+
code: z10.ZodIssueCode.custom,
|
|
11614
11074
|
path: ["binding"],
|
|
11615
11075
|
message: "Evaluation binding does not match the analysis plan binding"
|
|
11616
11076
|
});
|
|
11617
11077
|
}
|
|
11618
11078
|
if (plan.contract.fcid !== input.contract.fcid) {
|
|
11619
11079
|
context.addIssue({
|
|
11620
|
-
code:
|
|
11080
|
+
code: z10.ZodIssueCode.custom,
|
|
11621
11081
|
path: ["contract", "fcid"],
|
|
11622
11082
|
message: "Evaluation FCID does not match the analysis plan"
|
|
11623
11083
|
});
|
|
11624
11084
|
}
|
|
11625
11085
|
if (contractHash(input.contract.preimage) !== input.contract.fcid) {
|
|
11626
11086
|
context.addIssue({
|
|
11627
|
-
code:
|
|
11087
|
+
code: z10.ZodIssueCode.custom,
|
|
11628
11088
|
path: ["contract", "preimage"],
|
|
11629
11089
|
message: "Contract preimage does not reproduce the pinned FCID"
|
|
11630
11090
|
});
|
|
11631
11091
|
}
|
|
11632
11092
|
if (plan.evaluatorVersion !== input.evaluatorVersion) {
|
|
11633
11093
|
context.addIssue({
|
|
11634
|
-
code:
|
|
11094
|
+
code: z10.ZodIssueCode.custom,
|
|
11635
11095
|
path: ["evaluatorVersion"],
|
|
11636
11096
|
message: "Evaluator version does not match the analysis plan"
|
|
11637
11097
|
});
|
|
11638
11098
|
}
|
|
11639
11099
|
if (input.integrity.profile.state === "known" && (input.integrity.profile.profileId !== plan.profile.id || input.integrity.profile.profileVersion !== plan.profile.version)) {
|
|
11640
11100
|
context.addIssue({
|
|
11641
|
-
code:
|
|
11101
|
+
code: z10.ZodIssueCode.custom,
|
|
11642
11102
|
path: ["integrity", "profile"],
|
|
11643
11103
|
message: "Known profile identity does not match the analysis plan"
|
|
11644
11104
|
});
|
|
@@ -11647,7 +11107,7 @@ var evaluationInputV2RawSchema = z11.object({
|
|
|
11647
11107
|
const expectedBindingDigest = repositoryBindingDigestV1(input.binding);
|
|
11648
11108
|
if (input.baseline.identity.bindingDigest !== expectedBindingDigest || input.baseline.identity.repositoryExternalId !== input.binding.repositoryExternalId || input.baseline.identity.fcid !== input.contract.fcid) {
|
|
11649
11109
|
context.addIssue({
|
|
11650
|
-
code:
|
|
11110
|
+
code: z10.ZodIssueCode.custom,
|
|
11651
11111
|
path: ["baseline", "identity"],
|
|
11652
11112
|
message: "Baseline identity does not match the evaluation binding and FCID"
|
|
11653
11113
|
});
|
|
@@ -11655,7 +11115,7 @@ var evaluationInputV2RawSchema = z11.object({
|
|
|
11655
11115
|
}
|
|
11656
11116
|
if (input.facts.size() > plan.limits.maxFacts) {
|
|
11657
11117
|
context.addIssue({
|
|
11658
|
-
code:
|
|
11118
|
+
code: z10.ZodIssueCode.custom,
|
|
11659
11119
|
path: ["facts"],
|
|
11660
11120
|
message: "Fact count exceeds the analysis-plan limit"
|
|
11661
11121
|
});
|
|
@@ -11664,7 +11124,7 @@ var evaluationInputV2RawSchema = z11.object({
|
|
|
11664
11124
|
deriveCoverageSummaryV1(plan, input.coverage);
|
|
11665
11125
|
} catch (error) {
|
|
11666
11126
|
context.addIssue({
|
|
11667
|
-
code:
|
|
11127
|
+
code: z10.ZodIssueCode.custom,
|
|
11668
11128
|
path: ["coverage"],
|
|
11669
11129
|
message: error instanceof Error ? error.message : "Coverage does not match the plan"
|
|
11670
11130
|
});
|
|
@@ -11677,7 +11137,7 @@ var evaluationInputV2Schema = evaluationInputV2RawSchema.transform(
|
|
|
11677
11137
|
analysisPlan: parseAnalysisPlanV1(input.analysisPlan)
|
|
11678
11138
|
})
|
|
11679
11139
|
);
|
|
11680
|
-
var evaluationReasonV2Schema =
|
|
11140
|
+
var evaluationReasonV2Schema = z10.enum([
|
|
11681
11141
|
"zeroFileScan",
|
|
11682
11142
|
"governanceInert",
|
|
11683
11143
|
"contractUnpinned",
|
|
@@ -11696,33 +11156,33 @@ var evaluationReasonV2Schema = z11.enum([
|
|
|
11696
11156
|
"factConflict",
|
|
11697
11157
|
"unknownAnalysisProfile"
|
|
11698
11158
|
]);
|
|
11699
|
-
var evaluationResultV2Schema =
|
|
11700
|
-
schemaVersion:
|
|
11701
|
-
verdict:
|
|
11702
|
-
reasons:
|
|
11703
|
-
findings:
|
|
11704
|
-
|
|
11705
|
-
fingerprint:
|
|
11706
|
-
ruleId:
|
|
11707
|
-
severity:
|
|
11708
|
-
state:
|
|
11709
|
-
stateReasons:
|
|
11159
|
+
var evaluationResultV2Schema = z10.object({
|
|
11160
|
+
schemaVersion: z10.literal(2),
|
|
11161
|
+
verdict: z10.enum(["pass", "block", "indeterminate"]),
|
|
11162
|
+
reasons: z10.array(evaluationReasonV2Schema).max(EVALUATION_MAX_REASON_CODES_V2).refine(unique, "Evaluation reason codes must be unique"),
|
|
11163
|
+
findings: z10.array(
|
|
11164
|
+
z10.object({
|
|
11165
|
+
fingerprint: boundedString2(),
|
|
11166
|
+
ruleId: boundedString2(),
|
|
11167
|
+
severity: z10.enum(["error", "warn", "info"]),
|
|
11168
|
+
state: z10.enum(["blocked", "advisory", "pending_cloud_trust"]),
|
|
11169
|
+
stateReasons: z10.array(boundedString2()).max(256)
|
|
11710
11170
|
}).strict()
|
|
11711
11171
|
).max(EVALUATION_MAX_FINDINGS_V2),
|
|
11712
|
-
counts:
|
|
11713
|
-
blocked:
|
|
11714
|
-
advisory:
|
|
11715
|
-
pendingCloudTrust:
|
|
11172
|
+
counts: z10.object({
|
|
11173
|
+
blocked: z10.number().int().nonnegative().max(EVALUATION_MAX_FINDINGS_V2),
|
|
11174
|
+
advisory: z10.number().int().nonnegative().max(EVALUATION_MAX_FINDINGS_V2),
|
|
11175
|
+
pendingCloudTrust: z10.number().int().nonnegative().max(EVALUATION_MAX_FINDINGS_V2)
|
|
11716
11176
|
}).strict(),
|
|
11717
|
-
derived:
|
|
11177
|
+
derived: z10.object({ warnPresent: z10.boolean(), gatingFindingsPresent: z10.boolean() }).strict(),
|
|
11718
11178
|
coverageSummary: coverageSummaryV1Schema,
|
|
11719
|
-
integrity:
|
|
11720
|
-
fcidVerified:
|
|
11721
|
-
analysisPlanVerified:
|
|
11722
|
-
factIntegrity:
|
|
11723
|
-
requiredCoverage:
|
|
11724
|
-
governance:
|
|
11725
|
-
profile:
|
|
11179
|
+
integrity: z10.object({
|
|
11180
|
+
fcidVerified: z10.boolean(),
|
|
11181
|
+
analysisPlanVerified: z10.boolean(),
|
|
11182
|
+
factIntegrity: z10.enum(["healthy", "conflict"]),
|
|
11183
|
+
requiredCoverage: z10.enum(["complete", "incomplete", "no_required_regions"]),
|
|
11184
|
+
governance: z10.enum(["healthy", "inert"]),
|
|
11185
|
+
profile: z10.enum(["known", "unknown"])
|
|
11726
11186
|
}).strict(),
|
|
11727
11187
|
inputDigest: digestHexStringSchema,
|
|
11728
11188
|
resultDigest: digestHexStringSchema
|
|
@@ -11736,7 +11196,7 @@ var evaluationResultV2Schema = z11.object({
|
|
|
11736
11196
|
if (finding.severity === "warn") emittedWarnPresent = true;
|
|
11737
11197
|
if (new Set(finding.stateReasons).size !== finding.stateReasons.length) {
|
|
11738
11198
|
context.addIssue({
|
|
11739
|
-
code:
|
|
11199
|
+
code: z10.ZodIssueCode.custom,
|
|
11740
11200
|
path: ["findings", index, "stateReasons"],
|
|
11741
11201
|
message: "Finding state reasons must be unique"
|
|
11742
11202
|
});
|
|
@@ -11744,7 +11204,7 @@ var evaluationResultV2Schema = z11.object({
|
|
|
11744
11204
|
}
|
|
11745
11205
|
if (new Set(result.findings.map((finding) => finding.fingerprint)).size !== result.findings.length) {
|
|
11746
11206
|
context.addIssue({
|
|
11747
|
-
code:
|
|
11207
|
+
code: z10.ZodIssueCode.custom,
|
|
11748
11208
|
path: ["findings"],
|
|
11749
11209
|
message: "Evaluation finding fingerprints must be unique"
|
|
11750
11210
|
});
|
|
@@ -11752,7 +11212,7 @@ var evaluationResultV2Schema = z11.object({
|
|
|
11752
11212
|
for (const key of ["blocked", "advisory", "pendingCloudTrust"]) {
|
|
11753
11213
|
if (result.counts[key] !== expectedCounts[key]) {
|
|
11754
11214
|
context.addIssue({
|
|
11755
|
-
code:
|
|
11215
|
+
code: z10.ZodIssueCode.custom,
|
|
11756
11216
|
path: ["counts", key],
|
|
11757
11217
|
message: `Evaluation ${key} count must match findings`
|
|
11758
11218
|
});
|
|
@@ -11760,14 +11220,14 @@ var evaluationResultV2Schema = z11.object({
|
|
|
11760
11220
|
}
|
|
11761
11221
|
if (emittedWarnPresent && !result.derived.warnPresent) {
|
|
11762
11222
|
context.addIssue({
|
|
11763
|
-
code:
|
|
11223
|
+
code: z10.ZodIssueCode.custom,
|
|
11764
11224
|
path: ["derived", "warnPresent"],
|
|
11765
11225
|
message: "An emitted warning finding requires warnPresent"
|
|
11766
11226
|
});
|
|
11767
11227
|
}
|
|
11768
11228
|
if (result.derived.gatingFindingsPresent !== expectedCounts.blocked > 0) {
|
|
11769
11229
|
context.addIssue({
|
|
11770
|
-
code:
|
|
11230
|
+
code: z10.ZodIssueCode.custom,
|
|
11771
11231
|
path: ["derived", "gatingFindingsPresent"],
|
|
11772
11232
|
message: "gatingFindingsPresent must match blocked findings"
|
|
11773
11233
|
});
|
|
@@ -11789,14 +11249,14 @@ var evaluationResultV2Schema = z11.object({
|
|
|
11789
11249
|
);
|
|
11790
11250
|
if (requiredCount !== result.coverageSummary.requiredRegions || requiredCount + optionalCount !== result.coverageSummary.observedRegions || result.coverageSummary.observedRegions !== result.coverageSummary.plannedRegions) {
|
|
11791
11251
|
context.addIssue({
|
|
11792
|
-
code:
|
|
11252
|
+
code: z10.ZodIssueCode.custom,
|
|
11793
11253
|
path: ["coverageSummary"],
|
|
11794
11254
|
message: "Coverage summary counts must reconcile with planned and observed regions"
|
|
11795
11255
|
});
|
|
11796
11256
|
}
|
|
11797
11257
|
if (result.coverageSummary.analyzedFiles > result.coverageSummary.eligibleFiles) {
|
|
11798
11258
|
context.addIssue({
|
|
11799
|
-
code:
|
|
11259
|
+
code: z10.ZodIssueCode.custom,
|
|
11800
11260
|
path: ["coverageSummary", "analyzedFiles"],
|
|
11801
11261
|
message: "Analyzed files cannot exceed eligible files"
|
|
11802
11262
|
});
|
|
@@ -11804,7 +11264,7 @@ var evaluationResultV2Schema = z11.object({
|
|
|
11804
11264
|
const expectedRequiredCoverage = result.coverageSummary.requiredRegions === 0 ? "no_required_regions" : result.coverageSummary.requiredByState.analyzed === result.coverageSummary.requiredRegions ? "complete" : "incomplete";
|
|
11805
11265
|
if (result.integrity.requiredCoverage !== expectedRequiredCoverage) {
|
|
11806
11266
|
context.addIssue({
|
|
11807
|
-
code:
|
|
11267
|
+
code: z10.ZodIssueCode.custom,
|
|
11808
11268
|
path: ["integrity", "requiredCoverage"],
|
|
11809
11269
|
message: "Required coverage integrity must match the derived coverage summary"
|
|
11810
11270
|
});
|
|
@@ -11813,7 +11273,7 @@ var evaluationResultV2Schema = z11.object({
|
|
|
11813
11273
|
const requireReason = (reason, required, path) => {
|
|
11814
11274
|
if (reasons.has(reason) !== required) {
|
|
11815
11275
|
context.addIssue({
|
|
11816
|
-
code:
|
|
11276
|
+
code: z10.ZodIssueCode.custom,
|
|
11817
11277
|
path,
|
|
11818
11278
|
message: `${reason} must match the evaluation result`
|
|
11819
11279
|
});
|
|
@@ -11861,76 +11321,76 @@ var evaluationResultV2Schema = z11.object({
|
|
|
11861
11321
|
const expectedVerdict = !integrityHealthy || result.reasons.some((reason) => integrityReasons.has(reason)) ? "indeterminate" : result.reasons.some((reason) => blockingReasons.has(reason)) ? "block" : result.reasons.length > 0 ? "indeterminate" : "pass";
|
|
11862
11322
|
if (result.verdict !== expectedVerdict) {
|
|
11863
11323
|
context.addIssue({
|
|
11864
|
-
code:
|
|
11324
|
+
code: z10.ZodIssueCode.custom,
|
|
11865
11325
|
path: ["verdict"],
|
|
11866
11326
|
message: `Evaluation verdict must be ${expectedVerdict} for its reasons and integrity`
|
|
11867
11327
|
});
|
|
11868
11328
|
}
|
|
11869
11329
|
});
|
|
11870
|
-
var providerProofSemanticV1Schema =
|
|
11871
|
-
schemaVersion:
|
|
11872
|
-
adapterId:
|
|
11873
|
-
adapterVersion:
|
|
11874
|
-
providerInstanceId:
|
|
11330
|
+
var providerProofSemanticV1Schema = z10.object({
|
|
11331
|
+
schemaVersion: z10.literal(1),
|
|
11332
|
+
adapterId: boundedString2(),
|
|
11333
|
+
adapterVersion: boundedString2(),
|
|
11334
|
+
providerInstanceId: boundedString2(),
|
|
11875
11335
|
bindingDigest: digestHexStringSchema,
|
|
11876
|
-
repositoryExternalId:
|
|
11877
|
-
sourceCommitId:
|
|
11878
|
-
eventExternalId:
|
|
11879
|
-
changeExternalId:
|
|
11880
|
-
publisherExternalId:
|
|
11336
|
+
repositoryExternalId: boundedString2(),
|
|
11337
|
+
sourceCommitId: boundedString2(),
|
|
11338
|
+
eventExternalId: boundedString2(),
|
|
11339
|
+
changeExternalId: boundedString2().optional(),
|
|
11340
|
+
publisherExternalId: boundedString2()
|
|
11881
11341
|
}).strict();
|
|
11882
11342
|
function providerProofDigestV1(value) {
|
|
11883
11343
|
const proof = providerProofSemanticV1Schema.parse(value);
|
|
11884
11344
|
return sha256Hex(canonicalPreimage({ schema: "provider-proof.v1", ...proof }));
|
|
11885
11345
|
}
|
|
11886
|
-
var providerProofV1Schema =
|
|
11887
|
-
schemaVersion:
|
|
11888
|
-
adapterId:
|
|
11889
|
-
adapterVersion:
|
|
11890
|
-
providerInstanceId:
|
|
11346
|
+
var providerProofV1Schema = z10.object({
|
|
11347
|
+
schemaVersion: z10.literal(1),
|
|
11348
|
+
adapterId: boundedString2(),
|
|
11349
|
+
adapterVersion: boundedString2(),
|
|
11350
|
+
providerInstanceId: boundedString2(),
|
|
11891
11351
|
bindingDigest: digestHexStringSchema,
|
|
11892
|
-
repositoryExternalId:
|
|
11893
|
-
sourceCommitId:
|
|
11894
|
-
eventExternalId:
|
|
11895
|
-
changeExternalId:
|
|
11896
|
-
publisherExternalId:
|
|
11352
|
+
repositoryExternalId: boundedString2(),
|
|
11353
|
+
sourceCommitId: boundedString2(),
|
|
11354
|
+
eventExternalId: boundedString2(),
|
|
11355
|
+
changeExternalId: boundedString2().optional(),
|
|
11356
|
+
publisherExternalId: boundedString2(),
|
|
11897
11357
|
proofDigest: digestHexStringSchema
|
|
11898
11358
|
}).strict().superRefine((proof, context) => {
|
|
11899
11359
|
const { proofDigest, ...semantic } = proof;
|
|
11900
11360
|
if (providerProofDigestV1(semantic) !== proofDigest) {
|
|
11901
11361
|
context.addIssue({
|
|
11902
|
-
code:
|
|
11362
|
+
code: z10.ZodIssueCode.custom,
|
|
11903
11363
|
path: ["proofDigest"],
|
|
11904
11364
|
message: "Provider proof digest mismatch"
|
|
11905
11365
|
});
|
|
11906
11366
|
}
|
|
11907
11367
|
});
|
|
11908
11368
|
var receiptSemanticShape = {
|
|
11909
|
-
schemaVersion:
|
|
11910
|
-
trust:
|
|
11911
|
-
authority:
|
|
11369
|
+
schemaVersion: z10.literal(1),
|
|
11370
|
+
trust: z10.enum(["source_verified", "ci_attested", "local", "unknown"]),
|
|
11371
|
+
authority: z10.enum(["advisory", "enforcement_eligible"]),
|
|
11912
11372
|
binding: repositoryBindingKeyV1Schema,
|
|
11913
|
-
sourceCommitId:
|
|
11373
|
+
sourceCommitId: boundedString2(),
|
|
11914
11374
|
fcid: digestHexStringSchema,
|
|
11915
11375
|
analysisPlanDigest: digestHexStringSchema,
|
|
11916
11376
|
factsDigest: digestHexStringSchema,
|
|
11917
11377
|
inputDigest: digestHexStringSchema,
|
|
11918
11378
|
resultDigest: digestHexStringSchema,
|
|
11919
|
-
evaluatorVersion:
|
|
11379
|
+
evaluatorVersion: boundedString2(),
|
|
11920
11380
|
providerProof: providerProofV1Schema.optional()
|
|
11921
11381
|
};
|
|
11922
11382
|
function validateReceiptSemantics(receipt, context) {
|
|
11923
11383
|
if (receipt.authority === "enforcement_eligible") {
|
|
11924
11384
|
if (receipt.trust !== "source_verified") {
|
|
11925
11385
|
context.addIssue({
|
|
11926
|
-
code:
|
|
11386
|
+
code: z10.ZodIssueCode.custom,
|
|
11927
11387
|
path: ["authority"],
|
|
11928
11388
|
message: "Only source-verified evidence can enforce"
|
|
11929
11389
|
});
|
|
11930
11390
|
}
|
|
11931
11391
|
if (!receipt.providerProof) {
|
|
11932
11392
|
context.addIssue({
|
|
11933
|
-
code:
|
|
11393
|
+
code: z10.ZodIssueCode.custom,
|
|
11934
11394
|
path: ["providerProof"],
|
|
11935
11395
|
message: "Source-verified enforcement requires provider proof"
|
|
11936
11396
|
});
|
|
@@ -11938,14 +11398,14 @@ function validateReceiptSemantics(receipt, context) {
|
|
|
11938
11398
|
}
|
|
11939
11399
|
if (receipt.trust === "source_verified" && !receipt.providerProof) {
|
|
11940
11400
|
context.addIssue({
|
|
11941
|
-
code:
|
|
11401
|
+
code: z10.ZodIssueCode.custom,
|
|
11942
11402
|
path: ["providerProof"],
|
|
11943
11403
|
message: "Source-verified trust requires provider proof"
|
|
11944
11404
|
});
|
|
11945
11405
|
}
|
|
11946
11406
|
if (receipt.trust !== "source_verified" && receipt.providerProof) {
|
|
11947
11407
|
context.addIssue({
|
|
11948
|
-
code:
|
|
11408
|
+
code: z10.ZodIssueCode.custom,
|
|
11949
11409
|
path: ["providerProof"],
|
|
11950
11410
|
message: "Provider proof is reserved for source-verified trust"
|
|
11951
11411
|
});
|
|
@@ -11955,34 +11415,34 @@ function validateReceiptSemantics(receipt, context) {
|
|
|
11955
11415
|
const binding = normalizeRepositoryBindingKeyV1(receipt.binding);
|
|
11956
11416
|
if (proof.bindingDigest !== repositoryBindingDigestV1(binding)) {
|
|
11957
11417
|
context.addIssue({
|
|
11958
|
-
code:
|
|
11418
|
+
code: z10.ZodIssueCode.custom,
|
|
11959
11419
|
path: ["providerProof", "bindingDigest"],
|
|
11960
11420
|
message: "Provider proof binding mismatch"
|
|
11961
11421
|
});
|
|
11962
11422
|
}
|
|
11963
11423
|
if (proof.providerInstanceId !== binding.providerInstanceId) {
|
|
11964
11424
|
context.addIssue({
|
|
11965
|
-
code:
|
|
11425
|
+
code: z10.ZodIssueCode.custom,
|
|
11966
11426
|
path: ["providerProof", "providerInstanceId"],
|
|
11967
11427
|
message: "Provider proof instance mismatch"
|
|
11968
11428
|
});
|
|
11969
11429
|
}
|
|
11970
11430
|
if (proof.repositoryExternalId !== binding.repositoryExternalId) {
|
|
11971
11431
|
context.addIssue({
|
|
11972
|
-
code:
|
|
11432
|
+
code: z10.ZodIssueCode.custom,
|
|
11973
11433
|
path: ["providerProof", "repositoryExternalId"],
|
|
11974
11434
|
message: "Provider proof repository mismatch"
|
|
11975
11435
|
});
|
|
11976
11436
|
}
|
|
11977
11437
|
if (proof.sourceCommitId !== receipt.sourceCommitId) {
|
|
11978
11438
|
context.addIssue({
|
|
11979
|
-
code:
|
|
11439
|
+
code: z10.ZodIssueCode.custom,
|
|
11980
11440
|
path: ["providerProof", "sourceCommitId"],
|
|
11981
11441
|
message: "Provider proof source mismatch"
|
|
11982
11442
|
});
|
|
11983
11443
|
}
|
|
11984
11444
|
}
|
|
11985
|
-
var evaluationReceiptSemanticV1Schema =
|
|
11445
|
+
var evaluationReceiptSemanticV1Schema = z10.object(receiptSemanticShape).strict().superRefine(validateReceiptSemantics);
|
|
11986
11446
|
function evaluationReceiptDigestV1(value) {
|
|
11987
11447
|
const receipt = evaluationReceiptSemanticV1Schema.parse(value);
|
|
11988
11448
|
return sha256Hex(
|
|
@@ -12002,10 +11462,10 @@ function evaluationReceiptDigestV1(value) {
|
|
|
12002
11462
|
})
|
|
12003
11463
|
);
|
|
12004
11464
|
}
|
|
12005
|
-
var evaluationReceiptV1Schema =
|
|
11465
|
+
var evaluationReceiptV1Schema = z10.object({
|
|
12006
11466
|
receiptId: evaluationReceiptIdStringSchema,
|
|
12007
11467
|
...receiptSemanticShape,
|
|
12008
|
-
mintedAt:
|
|
11468
|
+
mintedAt: z10.string().datetime({ offset: true }),
|
|
12009
11469
|
digest: digestHexStringSchema
|
|
12010
11470
|
}).strict().superRefine((receipt, context) => {
|
|
12011
11471
|
validateReceiptSemantics(receipt, context);
|
|
@@ -12015,21 +11475,21 @@ var evaluationReceiptV1Schema = z11.object({
|
|
|
12015
11475
|
digest = evaluationReceiptDigestV1(semantic);
|
|
12016
11476
|
} catch (error) {
|
|
12017
11477
|
context.addIssue({
|
|
12018
|
-
code:
|
|
11478
|
+
code: z10.ZodIssueCode.custom,
|
|
12019
11479
|
message: error instanceof Error ? error.message : "Invalid receipt semantics"
|
|
12020
11480
|
});
|
|
12021
11481
|
return;
|
|
12022
11482
|
}
|
|
12023
11483
|
if (digest !== receipt.digest) {
|
|
12024
11484
|
context.addIssue({
|
|
12025
|
-
code:
|
|
11485
|
+
code: z10.ZodIssueCode.custom,
|
|
12026
11486
|
path: ["digest"],
|
|
12027
11487
|
message: "Receipt digest mismatch"
|
|
12028
11488
|
});
|
|
12029
11489
|
}
|
|
12030
11490
|
if (evaluationReceiptIdFromDigest(digest) !== receipt.receiptId) {
|
|
12031
11491
|
context.addIssue({
|
|
12032
|
-
code:
|
|
11492
|
+
code: z10.ZodIssueCode.custom,
|
|
12033
11493
|
path: ["receiptId"],
|
|
12034
11494
|
message: "Receipt ID mismatch"
|
|
12035
11495
|
});
|
|
@@ -12038,17 +11498,17 @@ var evaluationReceiptV1Schema = z11.object({
|
|
|
12038
11498
|
function parseEvaluationReceiptV1(value) {
|
|
12039
11499
|
return evaluationReceiptV1Schema.parse(value);
|
|
12040
11500
|
}
|
|
12041
|
-
var evaluationReceiptMintInputV1Schema =
|
|
12042
|
-
schemaVersion:
|
|
12043
|
-
trust:
|
|
11501
|
+
var evaluationReceiptMintInputV1Schema = z10.object({
|
|
11502
|
+
schemaVersion: z10.literal(1),
|
|
11503
|
+
trust: z10.enum(["ci_attested", "local", "unknown"]),
|
|
12044
11504
|
binding: repositoryBindingKeyV1Schema,
|
|
12045
|
-
sourceCommitId:
|
|
11505
|
+
sourceCommitId: boundedString2(),
|
|
12046
11506
|
fcid: digestHexStringSchema,
|
|
12047
11507
|
analysisPlanDigest: digestHexStringSchema,
|
|
12048
11508
|
factsDigest: digestHexStringSchema,
|
|
12049
11509
|
inputDigest: digestHexStringSchema,
|
|
12050
11510
|
resultDigest: digestHexStringSchema,
|
|
12051
|
-
evaluatorVersion:
|
|
11511
|
+
evaluatorVersion: boundedString2()
|
|
12052
11512
|
}).strict();
|
|
12053
11513
|
|
|
12054
11514
|
// src/evaluation/evaluate.ts
|
|
@@ -12247,9 +11707,7 @@ function evaluateV2(rawInput) {
|
|
|
12247
11707
|
if (orderedReasons.some((reason) => V2_INTEGRITY_REASONS.has(reason))) {
|
|
12248
11708
|
verdict = "indeterminate";
|
|
12249
11709
|
}
|
|
12250
|
-
const inputDigest =
|
|
12251
|
-
canonicalPreimage(normalizeInputV2ForDigest(input, coverageSummary))
|
|
12252
|
-
);
|
|
11710
|
+
const inputDigest = evaluationInputDigestV2(input);
|
|
12253
11711
|
const partial = {
|
|
12254
11712
|
schemaVersion: 2,
|
|
12255
11713
|
verdict,
|
|
@@ -12263,11 +11721,19 @@ function evaluateV2(rawInput) {
|
|
|
12263
11721
|
coverageSummary,
|
|
12264
11722
|
integrity
|
|
12265
11723
|
};
|
|
12266
|
-
const resultDigest =
|
|
12267
|
-
canonicalPreimage({ schema: "evaluation-result:v2", ...partial, inputDigest })
|
|
12268
|
-
);
|
|
11724
|
+
const resultDigest = evaluationResultDigestV2({ ...partial, inputDigest });
|
|
12269
11725
|
return evaluationResultV2Schema.parse({ ...partial, inputDigest, resultDigest });
|
|
12270
11726
|
}
|
|
11727
|
+
function evaluationInputDigestV2(input) {
|
|
11728
|
+
return sha256Hex(
|
|
11729
|
+
canonicalPreimage(
|
|
11730
|
+
normalizeInputV2ForDigest(input, deriveCoverageSummaryV1(input.analysisPlan, input.coverage))
|
|
11731
|
+
)
|
|
11732
|
+
);
|
|
11733
|
+
}
|
|
11734
|
+
function evaluationResultDigestV2(result) {
|
|
11735
|
+
return sha256Hex(canonicalPreimage({ schema: "evaluation-result:v2", ...result }));
|
|
11736
|
+
}
|
|
12271
11737
|
function normalizeInputV2ForDigest(input, coverageSummary) {
|
|
12272
11738
|
const {
|
|
12273
11739
|
analysisPlanId: _analysisPlanId,
|
|
@@ -12475,14 +11941,24 @@ function canonicalWaivers(waivers) {
|
|
|
12475
11941
|
(waiver, index) => index === 0 || waiver.fingerprint !== sorted[index - 1].fingerprint || expiryOf(waiver) !== expiryOf(sorted[index - 1])
|
|
12476
11942
|
);
|
|
12477
11943
|
}
|
|
11944
|
+
|
|
11945
|
+
// src/approved-contract-tokens.ts
|
|
11946
|
+
var APPROVED_CONTRACT_TOKEN_MAX_NAMES = 1e4;
|
|
11947
|
+
var APPROVED_CONTRACT_TOKEN_MAX_NAME_LENGTH = 512;
|
|
11948
|
+
function isApprovedContractTokenNames(value) {
|
|
11949
|
+
return Array.isArray(value) && value.length <= APPROVED_CONTRACT_TOKEN_MAX_NAMES && value.every(
|
|
11950
|
+
(name) => typeof name === "string" && name.startsWith("--") && name.length > 2 && name.length <= APPROVED_CONTRACT_TOKEN_MAX_NAME_LENGTH
|
|
11951
|
+
);
|
|
11952
|
+
}
|
|
12478
11953
|
export {
|
|
12479
11954
|
AGENT_CONTEXT_RELATIVE_PATH,
|
|
12480
|
-
AGENT_FEATURE_CONTEXT_MAX_BYTES_V1,
|
|
12481
11955
|
AGENT_FORMAT_SCHEMA_VERSION,
|
|
12482
11956
|
ANALYSIS_LIMIT_CEILINGS_V1,
|
|
12483
11957
|
ANALYSIS_PLAN_MAX_CAPABILITIES_V1,
|
|
12484
11958
|
ANALYSIS_PLAN_MAX_DIALECTS_PER_REGION_V1,
|
|
12485
11959
|
ANALYSIS_PLAN_MAX_REGIONS_V1,
|
|
11960
|
+
APPROVED_CONTRACT_TOKEN_MAX_NAMES,
|
|
11961
|
+
APPROVED_CONTRACT_TOKEN_MAX_NAME_LENGTH,
|
|
12486
11962
|
BLOCKING_RULE_ALLOWLIST,
|
|
12487
11963
|
BRAND,
|
|
12488
11964
|
CANONICAL_FACT_MAX_CONFLICTS_V1,
|
|
@@ -12514,13 +11990,6 @@ export {
|
|
|
12514
11990
|
EVALUATOR_VERSION_V2,
|
|
12515
11991
|
EVIDENCE_ORDER,
|
|
12516
11992
|
EXPLAIN_URL_BASE,
|
|
12517
|
-
FEATURE_PLAN_MAX_ACCEPTANCE_ITEMS_V1,
|
|
12518
|
-
FEATURE_PLAN_MAX_DECISIONS_V1,
|
|
12519
|
-
FEATURE_PLAN_MAX_EVIDENCE_REFS_V1,
|
|
12520
|
-
FEATURE_PLAN_MAX_GAPS_V1,
|
|
12521
|
-
FEATURE_PLAN_MAX_SCENARIOS_V1,
|
|
12522
|
-
FEATURE_PLAN_MAX_TEXT_BYTES_V1,
|
|
12523
|
-
FEATURE_PLAN_MAX_USES_PER_KIND_V1,
|
|
12524
11993
|
FRAGMENTS_INTERNAL_RULE_IDS,
|
|
12525
11994
|
FRAGMENTS_MANIFEST_FILENAME,
|
|
12526
11995
|
FRAGMENTS_MANIFEST_SCHEMA_VERSION,
|
|
@@ -12555,7 +12024,6 @@ export {
|
|
|
12555
12024
|
SEVERITY_RANK,
|
|
12556
12025
|
SEVERITY_WEIGHTS,
|
|
12557
12026
|
agentErrorEnvelopeSchema,
|
|
12558
|
-
agentFeatureContextV1Schema2 as agentFeatureContextV1Schema,
|
|
12559
12027
|
agentFormatSchema,
|
|
12560
12028
|
agentIntegritySchema,
|
|
12561
12029
|
agentOutputSchema,
|
|
@@ -12570,9 +12038,6 @@ export {
|
|
|
12570
12038
|
analysisPlanV1Schema,
|
|
12571
12039
|
analysisRegionV1Schema,
|
|
12572
12040
|
analyzeComposition,
|
|
12573
|
-
approvedFeatureManifestInputV1Schema,
|
|
12574
|
-
approvedFeatureManifestRevisionDigestV1,
|
|
12575
|
-
approvedFeatureManifestV1Schema,
|
|
12576
12041
|
artifactContentHash,
|
|
12577
12042
|
asComponentId,
|
|
12578
12043
|
assembleRegistryArtifact,
|
|
@@ -12585,9 +12050,7 @@ export {
|
|
|
12585
12050
|
budgetBar,
|
|
12586
12051
|
buildAgentFormat,
|
|
12587
12052
|
buildAnalysisPlanV1,
|
|
12588
|
-
buildApprovedFeatureManifestV1,
|
|
12589
12053
|
buildComponentKey,
|
|
12590
|
-
buildFeatureProposalV1,
|
|
12591
12054
|
buildRegistryArtifact,
|
|
12592
12055
|
buildRegistryFile,
|
|
12593
12056
|
buildRegistryInstallPlan,
|
|
@@ -12615,10 +12078,11 @@ export {
|
|
|
12615
12078
|
canonicalFactIntegrityV1Schema,
|
|
12616
12079
|
canonicalJson,
|
|
12617
12080
|
canonicalPreimage,
|
|
12081
|
+
canonicalSourceContainsFile,
|
|
12082
|
+
canonicalSourceIncludesExport,
|
|
12618
12083
|
canonicalizeOwnedComponentId,
|
|
12619
12084
|
canonicalizeOwnedImport,
|
|
12620
12085
|
capConfiguredSeverity,
|
|
12621
|
-
capabilityGapV1Schema,
|
|
12622
12086
|
catalogFixtureA,
|
|
12623
12087
|
catalogFixtureAContractPayload,
|
|
12624
12088
|
catalogFixtureATokensDtcg,
|
|
@@ -12646,7 +12110,6 @@ export {
|
|
|
12646
12110
|
componentGovernanceRecordsSchema,
|
|
12647
12111
|
componentId,
|
|
12648
12112
|
componentRelationSchema,
|
|
12649
|
-
componentUseDecisionV1Schema,
|
|
12650
12113
|
compositionAuthoringEntrySchema,
|
|
12651
12114
|
compositionMetadataSchema,
|
|
12652
12115
|
compositionPatternSchema,
|
|
@@ -12665,8 +12128,6 @@ export {
|
|
|
12665
12128
|
coverageStateV1Schema,
|
|
12666
12129
|
coverageSummaryV1Schema,
|
|
12667
12130
|
customerDefaultRuleStates,
|
|
12668
|
-
decisionRequestV1Schema,
|
|
12669
|
-
decisionResolutionV1Schema,
|
|
12670
12131
|
defaultRegistryShardPath,
|
|
12671
12132
|
defineBlock,
|
|
12672
12133
|
defineConfig,
|
|
@@ -12687,6 +12148,7 @@ export {
|
|
|
12687
12148
|
emptyVocabularyConfigFile,
|
|
12688
12149
|
evaluate2 as evaluate,
|
|
12689
12150
|
evaluateGovernanceIntegrity,
|
|
12151
|
+
evaluationInputDigestV2,
|
|
12690
12152
|
evaluationInputV2Schema,
|
|
12691
12153
|
evaluationReceiptDigestV1,
|
|
12692
12154
|
evaluationReceiptIdFromDigest,
|
|
@@ -12694,8 +12156,8 @@ export {
|
|
|
12694
12156
|
evaluationReceiptIdStringSchema,
|
|
12695
12157
|
evaluationReceiptMintInputV1Schema,
|
|
12696
12158
|
evaluationReceiptV1Schema,
|
|
12159
|
+
evaluationResultDigestV2,
|
|
12697
12160
|
evaluationResultV2Schema,
|
|
12698
|
-
evidenceRefV1Schema,
|
|
12699
12161
|
excludeGlobToRegExp,
|
|
12700
12162
|
expandRegistryComponentClosure,
|
|
12701
12163
|
explainUrlForCode,
|
|
@@ -12703,17 +12165,6 @@ export {
|
|
|
12703
12165
|
factId,
|
|
12704
12166
|
factLocationSchema,
|
|
12705
12167
|
familyDistance,
|
|
12706
|
-
featureAcceptanceItemV1Schema,
|
|
12707
|
-
featurePinsV1Schema,
|
|
12708
|
-
featurePlanIdFromEntropy,
|
|
12709
|
-
featurePlanIdSchema,
|
|
12710
|
-
featurePlanIdStringSchema,
|
|
12711
|
-
featureProposalInputV1Schema,
|
|
12712
|
-
featureProposalRevisionDigestV1,
|
|
12713
|
-
featureProposalV1Schema,
|
|
12714
|
-
featureRevisionIdFromDigest,
|
|
12715
|
-
featureRevisionIdSchema,
|
|
12716
|
-
featureRevisionIdStringSchema,
|
|
12717
12168
|
figma,
|
|
12718
12169
|
figmaPropMappingSchema,
|
|
12719
12170
|
finalizeRegistryManifest,
|
|
@@ -12758,7 +12209,6 @@ export {
|
|
|
12758
12209
|
fragmentsManifestSchema,
|
|
12759
12210
|
fragmentsPresetRuleStates,
|
|
12760
12211
|
g,
|
|
12761
|
-
gapDispositionV1Schema,
|
|
12762
12212
|
gatesCi,
|
|
12763
12213
|
generateCSSCustomProperties,
|
|
12764
12214
|
generateContext,
|
|
@@ -12783,6 +12233,8 @@ export {
|
|
|
12783
12233
|
indexComponentIdentityUsage,
|
|
12784
12234
|
inferTokenCategory,
|
|
12785
12235
|
inferTokenGroup,
|
|
12236
|
+
isApprovedContractTokenNames,
|
|
12237
|
+
isCanonicalSourceDefinition,
|
|
12786
12238
|
isColorLike,
|
|
12787
12239
|
isCompositionPattern,
|
|
12788
12240
|
isContractFile,
|
|
@@ -12797,8 +12249,6 @@ export {
|
|
|
12797
12249
|
isRawHtmlAdvisoryTier,
|
|
12798
12250
|
isReactComponent,
|
|
12799
12251
|
isRuleFamilyId,
|
|
12800
|
-
layoutConcernV1Schema,
|
|
12801
|
-
layoutOwnershipV1Schema,
|
|
12802
12252
|
localCanonicalContractMappings,
|
|
12803
12253
|
lowerCompositionContract,
|
|
12804
12254
|
makeA11yNameRequiredFact,
|
|
@@ -12870,12 +12320,10 @@ export {
|
|
|
12870
12320
|
nearestByDeltaE,
|
|
12871
12321
|
nearestSignedScaleValue,
|
|
12872
12322
|
normalizeAnalysisPlanInputV1,
|
|
12873
|
-
normalizeApprovedFeatureManifestInputV1,
|
|
12874
12323
|
normalizeCanonicalFactIntegrityV1,
|
|
12875
12324
|
normalizeColor,
|
|
12876
12325
|
normalizeConfigPath,
|
|
12877
12326
|
normalizeExcludePath,
|
|
12878
|
-
normalizeFeatureProposalInputV1,
|
|
12879
12327
|
normalizeFinding,
|
|
12880
12328
|
normalizeGovernanceConfig,
|
|
12881
12329
|
normalizePolicyExcludes,
|
|
@@ -12889,14 +12337,13 @@ export {
|
|
|
12889
12337
|
normalizeViolation,
|
|
12890
12338
|
overriddenRecordSeverityDiagnostic,
|
|
12891
12339
|
ownedImportEquivalents,
|
|
12892
|
-
parseAgentFeatureContextV1,
|
|
12893
12340
|
parseAnalysisPlanId,
|
|
12894
12341
|
parseAnalysisPlanV1,
|
|
12895
|
-
parseApprovedFeatureManifestV1,
|
|
12896
12342
|
parseColor,
|
|
12897
12343
|
parseColorToRgb,
|
|
12898
12344
|
parseCompiledFragmentsFile,
|
|
12899
12345
|
parseComponentContract,
|
|
12346
|
+
parseComponentGovernancePolicyJson,
|
|
12900
12347
|
parseContractStamp,
|
|
12901
12348
|
parseCssTokens,
|
|
12902
12349
|
parseDtcgTokens as parseDTCGFile,
|
|
@@ -12905,9 +12352,6 @@ export {
|
|
|
12905
12352
|
parseDtcgTokens,
|
|
12906
12353
|
parseEvaluationReceiptId,
|
|
12907
12354
|
parseEvaluationReceiptV1,
|
|
12908
|
-
parseFeaturePlanId,
|
|
12909
|
-
parseFeatureProposalV1,
|
|
12910
|
-
parseFeatureRevisionId,
|
|
12911
12355
|
parseFragmentsManifest,
|
|
12912
12356
|
parseRgb,
|
|
12913
12357
|
parseScssTokens,
|
|
@@ -12915,9 +12359,6 @@ export {
|
|
|
12915
12359
|
parseTailwindV4Theme,
|
|
12916
12360
|
parseTokenFile,
|
|
12917
12361
|
parseTokens,
|
|
12918
|
-
patternStatusV1Schema,
|
|
12919
|
-
patternUseDecisionV1Schema,
|
|
12920
|
-
placementDecisionV1Schema,
|
|
12921
12362
|
policyExcludeMatchesPath,
|
|
12922
12363
|
policyExcludeSchema,
|
|
12923
12364
|
portableRepoPathError,
|
|
@@ -12977,7 +12418,6 @@ export {
|
|
|
12977
12418
|
resolveRegistryInstallSources,
|
|
12978
12419
|
resolveSpacingValue,
|
|
12979
12420
|
resolveTokenValue,
|
|
12980
|
-
responsiveDecisionV1Schema,
|
|
12981
12421
|
rgbToHex,
|
|
12982
12422
|
ruleA11yRequiredAccessibleName,
|
|
12983
12423
|
ruleA11yStandard,
|
|
@@ -13003,7 +12443,6 @@ export {
|
|
|
13003
12443
|
ruleTokensRequireDualFallback,
|
|
13004
12444
|
runRules,
|
|
13005
12445
|
scaleGovernanceRecordSchema,
|
|
13006
|
-
scenarioRequirementV1Schema,
|
|
13007
12446
|
serializeContractStamp,
|
|
13008
12447
|
severityLevel,
|
|
13009
12448
|
severitySchema,
|
|
@@ -13014,7 +12453,6 @@ export {
|
|
|
13014
12453
|
suppressionDirectiveSchema,
|
|
13015
12454
|
tierFor,
|
|
13016
12455
|
tokenIncludesFromConfig,
|
|
13017
|
-
tokenUseDecisionV1Schema,
|
|
13018
12456
|
topologyBase,
|
|
13019
12457
|
validatorResultSchema,
|
|
13020
12458
|
verifiedContractPreimageFromPin,
|