@plasius/gpu-shader 0.1.0 → 0.1.2
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/README.md +42 -16
- package/dist/cli.cjs +235 -43
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +235 -43
- package/dist/cli.js.map +1 -1
- package/dist/{contracts-C4eel8MT.d.cts → contracts-B49AUejk.d.cts} +1 -1
- package/dist/{contracts-C4eel8MT.d.ts → contracts-B49AUejk.d.ts} +1 -1
- package/dist/index.cjs +238 -115
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -3
- package/dist/index.d.ts +12 -3
- package/dist/index.js +237 -115
- package/dist/index.js.map +1 -1
- package/dist/node.cjs +116 -24
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.js +116 -24
- package/dist/node.js.map +1 -1
- package/dist/testing.cjs +117 -29
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +117 -29
- package/dist/testing.js.map +1 -1
- package/matrices/stable-webgpu-2026-07-13.json +1 -545
- package/package.json +1 -1
package/dist/testing.cjs
CHANGED
|
@@ -46,7 +46,7 @@ var SUPPORTED_STABLE_WEBGPU_MATRIX_POLICIES = [
|
|
|
46
46
|
Object.freeze({
|
|
47
47
|
matrixId: "stable-webgpu",
|
|
48
48
|
matrixVersion: "2026-07-13",
|
|
49
|
-
matrixSha256: "
|
|
49
|
+
matrixSha256: "4620eca44fd03004ee7650cfe9fcf42934493611a5097da5525f71578980b016"
|
|
50
50
|
})
|
|
51
51
|
];
|
|
52
52
|
Object.freeze(SUPPORTED_STABLE_WEBGPU_MATRIX_POLICIES);
|
|
@@ -112,6 +112,29 @@ function canonicalizeGpuContract(value) {
|
|
|
112
112
|
return visit(value, "$root");
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
// src/asset-version.ts
|
|
116
|
+
var ASSET_VERSION_PATTERN = /^[0-9A-Za-z][0-9A-Za-z._-]{0,127}$/u;
|
|
117
|
+
var MUTABLE_VERSION_ALIASES = /* @__PURE__ */ new Set([
|
|
118
|
+
"latest",
|
|
119
|
+
"current",
|
|
120
|
+
"stable",
|
|
121
|
+
"preview",
|
|
122
|
+
"default",
|
|
123
|
+
"production",
|
|
124
|
+
"canary",
|
|
125
|
+
"next",
|
|
126
|
+
"head",
|
|
127
|
+
"main"
|
|
128
|
+
]);
|
|
129
|
+
var X_WILDCARD_SEGMENT_PATTERN = /^(?:[vV])?[xX](?:\.|-|$)|\.[xX](?:\.|-|$)/u;
|
|
130
|
+
var IMMUTABLE_VERSION_ERROR_MESSAGE = "Immutable asset version must be an exact token up to 128 characters; mutable aliases, ranges, wildcards, and URLs are not allowed.";
|
|
131
|
+
function assertImmutableAssetVersion(value) {
|
|
132
|
+
if (typeof value !== "string" || !ASSET_VERSION_PATTERN.test(value) || MUTABLE_VERSION_ALIASES.has(value.toLowerCase()) || X_WILDCARD_SEGMENT_PATTERN.test(value)) {
|
|
133
|
+
throw new TypeError(IMMUTABLE_VERSION_ERROR_MESSAGE);
|
|
134
|
+
}
|
|
135
|
+
return value;
|
|
136
|
+
}
|
|
137
|
+
|
|
115
138
|
// src/hash.ts
|
|
116
139
|
var SHA256_PATTERN = /^[a-f0-9]{64}$/u;
|
|
117
140
|
function asSha256Hex(value) {
|
|
@@ -134,6 +157,15 @@ async function computeSha256(value) {
|
|
|
134
157
|
|
|
135
158
|
// src/manifest-validation.ts
|
|
136
159
|
var stages = ["vertex", "fragment", "compute"];
|
|
160
|
+
function detachedJson(value, path2) {
|
|
161
|
+
try {
|
|
162
|
+
return JSON.parse(canonicalizeGpuContract(value));
|
|
163
|
+
} catch (cause) {
|
|
164
|
+
const detail = cause instanceof Error ? cause.message : "Contract snapshot failed.";
|
|
165
|
+
const boundedDetail = [...detail].slice(0, 512).join("");
|
|
166
|
+
throw new TypeError(`${path2} must contain detached JSON contract data: ${boundedDetail}`, { cause });
|
|
167
|
+
}
|
|
168
|
+
}
|
|
137
169
|
function object(value, path2) {
|
|
138
170
|
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new TypeError(`${path2} must be an object.`);
|
|
139
171
|
return value;
|
|
@@ -346,7 +378,7 @@ function pipeline(value, path2, moduleIds) {
|
|
|
346
378
|
return input;
|
|
347
379
|
}
|
|
348
380
|
function parseSerializableGpuPipelineDescriptors(value, moduleIds, path2 = "pipelines") {
|
|
349
|
-
const parsed = array(value, path2).map((item, index) => pipeline(item, `${path2}[${index}]`, new Set(moduleIds)));
|
|
381
|
+
const parsed = array(detachedJson(value, path2), path2).map((item, index) => pipeline(item, `${path2}[${index}]`, new Set(moduleIds)));
|
|
350
382
|
unique(parsed, (item) => item.pipelineId, path2);
|
|
351
383
|
return freeze(parsed);
|
|
352
384
|
}
|
|
@@ -364,6 +396,11 @@ function issue(code, message, path2) {
|
|
|
364
396
|
function object2(value) {
|
|
365
397
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
|
|
366
398
|
}
|
|
399
|
+
function freezeJson(value) {
|
|
400
|
+
if (typeof value !== "object" || value === null || Object.isFrozen(value)) return value;
|
|
401
|
+
for (const child of Object.values(value)) freezeJson(child);
|
|
402
|
+
return Object.freeze(value);
|
|
403
|
+
}
|
|
367
404
|
function exactKeys(value, keys2) {
|
|
368
405
|
const expected = new Set(keys2);
|
|
369
406
|
return Object.keys(value).every((key) => expected.has(key)) && keys2.every((key) => key in value);
|
|
@@ -371,6 +408,14 @@ function exactKeys(value, keys2) {
|
|
|
371
408
|
function safeToken(value) {
|
|
372
409
|
return typeof value === "string" && /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,159}$/u.test(value) && !value.includes("..");
|
|
373
410
|
}
|
|
411
|
+
function immutableVersion(value) {
|
|
412
|
+
try {
|
|
413
|
+
assertImmutableAssetVersion(value);
|
|
414
|
+
return true;
|
|
415
|
+
} catch {
|
|
416
|
+
return false;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
374
419
|
function validSha(value) {
|
|
375
420
|
try {
|
|
376
421
|
asSha256Hex(String(value));
|
|
@@ -383,8 +428,20 @@ function defineShaderCompileUnit(unit) {
|
|
|
383
428
|
return Object.freeze(unit);
|
|
384
429
|
}
|
|
385
430
|
function validateCompileUnitInventory(value) {
|
|
386
|
-
|
|
387
|
-
|
|
431
|
+
let snapshot;
|
|
432
|
+
try {
|
|
433
|
+
snapshot = JSON.parse(canonicalizeGpuContract(value));
|
|
434
|
+
} catch (cause) {
|
|
435
|
+
return {
|
|
436
|
+
ok: false,
|
|
437
|
+
diagnostics: [issue(
|
|
438
|
+
"invalid-contract",
|
|
439
|
+
cause instanceof Error ? cause.message : "Compile-unit inventory must contain detached JSON data."
|
|
440
|
+
)]
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
const envelope = object2(snapshot);
|
|
444
|
+
const candidate = envelope && Object.hasOwn(envelope, "inventory") ? object2(snapshot.inventory) : envelope;
|
|
388
445
|
const diagnostics = [];
|
|
389
446
|
if (!candidate || !exactKeys(candidate, ["contractVersion", "fragments", "compileUnits"])) {
|
|
390
447
|
return { ok: false, diagnostics: [issue("invalid-contract", "Compile-unit inventory has unknown or missing fields.")] };
|
|
@@ -515,7 +572,7 @@ function validateCompileUnitInventory(value) {
|
|
|
515
572
|
diagnostics.push(issue("invalid-contract", cause instanceof Error ? cause.message : "Compile-unit pipelines are invalid.", `${path2}.pipelines`));
|
|
516
573
|
}
|
|
517
574
|
const interfaceRef = object2(unit.interfaceRef);
|
|
518
|
-
if (!interfaceRef || !exactKeys(interfaceRef, ["interfaceId", "interfaceVersion", "manifestUri", "manifestSha256", "interfaceAbiHash", "modelAbiHash"]) || !safeToken(interfaceRef.interfaceId) || !
|
|
575
|
+
if (!interfaceRef || !exactKeys(interfaceRef, ["interfaceId", "interfaceVersion", "manifestUri", "manifestSha256", "interfaceAbiHash", "modelAbiHash"]) || !safeToken(interfaceRef.interfaceId) || !immutableVersion(interfaceRef.interfaceVersion) || typeof interfaceRef.manifestUri !== "string" || !interfaceRef.manifestUri.startsWith("https://") || !validSha(interfaceRef.manifestSha256) || !validSha(interfaceRef.interfaceAbiHash) || !validSha(interfaceRef.modelAbiHash)) {
|
|
519
576
|
diagnostics.push(issue("invalid-contract", "Compile-unit interfaceRef is invalid.", `${path2}.interfaceRef`));
|
|
520
577
|
}
|
|
521
578
|
const fixture = object2(unit.qualificationFixture);
|
|
@@ -526,7 +583,7 @@ function validateCompileUnitInventory(value) {
|
|
|
526
583
|
for (const fragmentId of fragmentIds) {
|
|
527
584
|
if (!covered.has(fragmentId)) diagnostics.push(issue("uncovered-fragment", `WGSL fragment ${fragmentId} has no compile unit.`));
|
|
528
585
|
}
|
|
529
|
-
return diagnostics.length > 0 ? { ok: false, diagnostics } : { ok: true, value: candidate };
|
|
586
|
+
return diagnostics.length > 0 ? { ok: false, diagnostics } : { ok: true, value: freezeJson(candidate) };
|
|
530
587
|
}
|
|
531
588
|
|
|
532
589
|
// src/testing/matrix.ts
|
|
@@ -540,6 +597,13 @@ function keys(value, expected) {
|
|
|
540
597
|
const set = new Set(expected);
|
|
541
598
|
return Object.keys(value).every((key) => set.has(key)) && expected.every((key) => key in value);
|
|
542
599
|
}
|
|
600
|
+
function canonicalEqual(left, right) {
|
|
601
|
+
try {
|
|
602
|
+
return canonicalizeGpuContract(left) === canonicalizeGpuContract(right);
|
|
603
|
+
} catch {
|
|
604
|
+
return false;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
543
607
|
var browserNames = /* @__PURE__ */ new Set(["chromium", "chrome", "edge", "firefox", "safari"]);
|
|
544
608
|
var osNames = /* @__PURE__ */ new Set(["ubuntu", "windows", "macos", "chromeos", "android", "ios", "ipados", "visionos"]);
|
|
545
609
|
var backends = /* @__PURE__ */ new Set(["swiftshader", "d3d12", "metal", "vulkan"]);
|
|
@@ -633,7 +697,9 @@ function validateStableWebGpuMatrix(value) {
|
|
|
633
697
|
const kind = String(requirement?.kind);
|
|
634
698
|
const validRequirement = requirement && (kind === "exact" ? keys(requirement, ["kind", "value"]) && typeof requirement.value === "string" && /^\d+(?:\.\d+)*$/u.test(requirement.value) : kind === "major" || kind === "minimum-major" ? keys(requirement, ["kind", "value"]) && Number.isSafeInteger(requirement.value) && Number(requirement.value) > 0 : kind === "stable-channel" && keys(requirement, ["kind", "channel"]) && requirement.channel === "stable");
|
|
635
699
|
if (!validRequirement) diagnostics.push(issue2("OS version requirement is invalid.", `${path2}.os.versionRequirement`));
|
|
636
|
-
if (typeof cell.cellId === "string" &&
|
|
700
|
+
if (typeof cell.cellId === "string" && !canonicalEqual(requirement, VERSION_REQUIREMENTS.get(cell.cellId))) {
|
|
701
|
+
diagnostics.push(issue2("OS version requirement differs from the stable baseline.", `${path2}.os.versionRequirement`));
|
|
702
|
+
}
|
|
637
703
|
}
|
|
638
704
|
if (!adapter || !keys(adapter, ["kind", "vendor", "family", "backend"]) || !["software", "physical"].includes(String(adapter.kind)) || !backends.has(String(adapter.backend))) diagnostics.push(issue2("Adapter descriptor is invalid.", `${path2}.adapter`));
|
|
639
705
|
if (!adapterAutomation || !keys(adapterAutomation, ["kind"]) || !automation.has(String(adapterAutomation.kind))) diagnostics.push(issue2("Automation descriptor is invalid.", `${path2}.automation`));
|
|
@@ -744,6 +810,18 @@ function object4(value, path2) {
|
|
|
744
810
|
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new TypeError(`${path2} must be an object.`);
|
|
745
811
|
return value;
|
|
746
812
|
}
|
|
813
|
+
function detachedJson2(value, label) {
|
|
814
|
+
try {
|
|
815
|
+
return JSON.parse(canonicalizeGpuContract(value));
|
|
816
|
+
} catch (cause) {
|
|
817
|
+
throw new TypeError(`${label} must contain detached JSON contract data.`, { cause });
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
function freezeJson2(value) {
|
|
821
|
+
if (typeof value !== "object" || value === null || Object.isFrozen(value)) return value;
|
|
822
|
+
for (const child of Object.values(value)) freezeJson2(child);
|
|
823
|
+
return Object.freeze(value);
|
|
824
|
+
}
|
|
747
825
|
function exact2(value, keys2, path2) {
|
|
748
826
|
const expected = new Set(keys2);
|
|
749
827
|
if (!Object.keys(value).every((key) => expected.has(key)) || !keys2.every((key) => key in value)) throw new TypeError(`${path2} has unknown or missing fields.`);
|
|
@@ -752,6 +830,16 @@ function token2(value, path2) {
|
|
|
752
830
|
if (typeof value !== "string" || !TOKEN.test(value) || value.includes("..")) throw new TypeError(`${path2} must be a safe token.`);
|
|
753
831
|
return value;
|
|
754
832
|
}
|
|
833
|
+
function immutableVersion2(value, path2) {
|
|
834
|
+
try {
|
|
835
|
+
return assertImmutableAssetVersion(value);
|
|
836
|
+
} catch (cause) {
|
|
837
|
+
throw new TypeError(
|
|
838
|
+
`${path2} must be an immutable asset version: exact token required; mutable aliases, ranges, wildcards, and URLs are not allowed.`,
|
|
839
|
+
{ cause }
|
|
840
|
+
);
|
|
841
|
+
}
|
|
842
|
+
}
|
|
755
843
|
function path(value, label, extensions) {
|
|
756
844
|
if (typeof value !== "string" || !SAFE_PATH2.test(value) || !extensions.some((extension) => value.endsWith(extension))) {
|
|
757
845
|
throw new TypeError(`${label} must be a safe data-only bundle path (${extensions.join(", ")}).`);
|
|
@@ -886,7 +974,7 @@ function jsonValue(value, label, depth = 0) {
|
|
|
886
974
|
}
|
|
887
975
|
function validateQualificationFixture(value, unit) {
|
|
888
976
|
try {
|
|
889
|
-
const fixture = object4(value, "fixture");
|
|
977
|
+
const fixture = object4(detachedJson2(value, "fixture"), "fixture");
|
|
890
978
|
exact2(fixture, ["contractVersion", "fixtureId", "resources", "bindGroups", "commands", "layoutProbes", "readbacks", "bounds"], "fixture");
|
|
891
979
|
if (fixture.contractVersion !== SHADER_QUALIFICATION_FIXTURE_VERSION) throw new TypeError("Unsupported qualification fixture version.");
|
|
892
980
|
token2(fixture.fixtureId, "fixture.fixtureId");
|
|
@@ -1222,14 +1310,14 @@ function validateQualificationFixture(value, unit) {
|
|
|
1222
1310
|
}
|
|
1223
1311
|
unique2(probeIds, "fixture.layoutProbes probe IDs");
|
|
1224
1312
|
unique2(probeSources, "fixture.layoutProbes model sources");
|
|
1225
|
-
return { ok: true, value: fixture };
|
|
1313
|
+
return { ok: true, value: freezeJson2(fixture) };
|
|
1226
1314
|
} catch (cause) {
|
|
1227
1315
|
return { ok: false, diagnostics: [{ code: "invalid-contract", severity: "error", message: cause instanceof Error ? cause.message : "Invalid qualification fixture." }] };
|
|
1228
1316
|
}
|
|
1229
1317
|
}
|
|
1230
1318
|
function validateQualificationBundleManifest(value) {
|
|
1231
1319
|
try {
|
|
1232
|
-
const bundle = object4(value, "qualification");
|
|
1320
|
+
const bundle = object4(detachedJson2(value, "qualification"), "qualification");
|
|
1233
1321
|
exact2(bundle, ["contractVersion", "inventory", "subject", "shaderManifestCorePath", "gpuInterfaceManifest", "modelCompatibilityFixtures", "modules", "fixtures"], "qualification");
|
|
1234
1322
|
if (bundle.contractVersion !== SHADER_QUALIFICATION_BUNDLE_VERSION) throw new TypeError("Unsupported qualification bundle version.");
|
|
1235
1323
|
const inventory = validateCompileUnitInventory(bundle.inventory);
|
|
@@ -1239,7 +1327,7 @@ function validateQualificationBundleManifest(value) {
|
|
|
1239
1327
|
const candidate = object4(subject.shaderManifestCore, "qualification.subject.shaderManifestCore");
|
|
1240
1328
|
exact2(candidate, ["shaderId", "version", "sha256"], "qualification.subject.shaderManifestCore");
|
|
1241
1329
|
token2(candidate.shaderId, "qualification.subject.shaderManifestCore.shaderId");
|
|
1242
|
-
|
|
1330
|
+
immutableVersion2(candidate.version, "qualification.subject.shaderManifestCore.version");
|
|
1243
1331
|
sha(candidate.sha256, "qualification.subject.shaderManifestCore.sha256");
|
|
1244
1332
|
path(bundle.shaderManifestCorePath, "qualification.shaderManifestCorePath", [".json"]);
|
|
1245
1333
|
const interfaceManifest = object4(bundle.gpuInterfaceManifest, "qualification.gpuInterfaceManifest");
|
|
@@ -1299,7 +1387,7 @@ function validateQualificationBundleManifest(value) {
|
|
|
1299
1387
|
const expectedUnits = [...inventory.value.compileUnits.map((unit) => unit.compileUnitId)].sort();
|
|
1300
1388
|
if (unitIds.join("\n") !== expectedUnits.join("\n")) throw new TypeError("Subject compile-unit IDs differ from inventory.");
|
|
1301
1389
|
orderedUniqueTokens(subject.requiredCellIds, "qualification.subject.requiredCellIds");
|
|
1302
|
-
return { ok: true, value: bundle };
|
|
1390
|
+
return { ok: true, value: freezeJson2(bundle) };
|
|
1303
1391
|
} catch (cause) {
|
|
1304
1392
|
return { ok: false, diagnostics: [{ code: "invalid-contract", severity: "error", message: cause instanceof Error ? cause.message : "Invalid qualification bundle." }] };
|
|
1305
1393
|
}
|
|
@@ -1398,12 +1486,12 @@ function parseQualificationExecutionProducer(value, path2 = "producer") {
|
|
|
1398
1486
|
return input;
|
|
1399
1487
|
}
|
|
1400
1488
|
function assertProducerMatchesPreflight(producer, provenance, cell, path2, expectedJob) {
|
|
1401
|
-
if (producer.repository !== provenance.repository || !
|
|
1489
|
+
if (producer.repository !== provenance.repository || !canonicalEqual2(producer.commit, provenance.commit) || producer.ref !== provenance.ref || producer.runId !== provenance.runId || producer.runAttempt !== provenance.runAttempt || producer.trustedWorkflowRepository !== "Plasius-LTD/gpu-shader" || producer.trustedWorkflowRef !== provenance.workflowRef || !canonicalEqual2(producer.trustedWorkflowSha, provenance.workflowSha) || producer.job !== expectedJob) throw new TypeError(`${path2} does not match the exact qualification workflow run or subject.`);
|
|
1402
1490
|
if (expectedJob === "swiftshader" && producer.runner.environment !== "github-hosted") throw new TypeError(`${path2} must identify the hosted SwiftShader job.`);
|
|
1403
1491
|
if (expectedJob === "physical" && producer.runner.environment === "github-hosted") throw new TypeError(`${path2} cannot use a hosted runner for a physical execution cell.`);
|
|
1404
1492
|
if (expectedJob === "physical-runner-preflight" && producer.runner.environment !== "github-hosted") throw new TypeError(`${path2} must identify its hosted orchestration job truthfully.`);
|
|
1405
1493
|
}
|
|
1406
|
-
function
|
|
1494
|
+
function canonicalEqual2(left, right) {
|
|
1407
1495
|
return canonicalizeGpuContract(left) === canonicalizeGpuContract(right);
|
|
1408
1496
|
}
|
|
1409
1497
|
function foldRunnerLabel(value) {
|
|
@@ -1439,13 +1527,13 @@ async function createQualificationPreflight(input) {
|
|
|
1439
1527
|
} catch (cause) {
|
|
1440
1528
|
throw new TypeError("Selected matrix artifact is not UTF-8 JSON.", { cause });
|
|
1441
1529
|
}
|
|
1442
|
-
if (!
|
|
1530
|
+
if (!canonicalEqual2(parsedMatrix, input.matrix)) throw new TypeError("Selected matrix artifact bytes differ from the supplied matrix value.");
|
|
1443
1531
|
const actualMatrixSha256 = await computeSha256(input.matrixBytes);
|
|
1444
1532
|
if (actualMatrixSha256 !== input.matrixSha256) throw new TypeError("Selected matrix digest is not derived from the exact matrix manifest.");
|
|
1445
1533
|
const inventorySha256 = await computeQualificationInventorySha256(input.bundle);
|
|
1446
1534
|
if (inventorySha256 !== input.bundle.subject.compileUnitInventorySha256) throw new TypeError("Bundle subject contains a stale compile-unit inventory digest.");
|
|
1447
1535
|
const requiredCells = input.matrix.cells.map((cell) => cell.cellId);
|
|
1448
|
-
if (!
|
|
1536
|
+
if (!canonicalEqual2(input.bundle.subject.requiredCellIds, requiredCells)) throw new TypeError("Bundle subject cell set differs from the selected matrix.");
|
|
1449
1537
|
const subjectBindingSha256 = await computeQualificationSubjectBinding({
|
|
1450
1538
|
subject: input.bundle.subject,
|
|
1451
1539
|
dataBundleSha256: input.dataBundleSha256,
|
|
@@ -1505,7 +1593,7 @@ function assertResult(value, path2, cell, passingRequired, timeBounds, expectedR
|
|
|
1505
1593
|
const labels = array2(runner.labels, `${path2}.observed.runner.labels`).map((item, index) => token3(item, `${path2}.observed.runner.labels[${index}]`));
|
|
1506
1594
|
const normalizedLabels = labels.map(foldRunnerLabel);
|
|
1507
1595
|
if (new Set(normalizedLabels).size !== normalizedLabels.length || cell.runnerLabels.some((label) => !normalizedLabels.includes(foldRunnerLabel(label)))) throw new TypeError(`${path2} actual runner labels do not contain the matrix route (ASCII case-insensitive).`);
|
|
1508
|
-
if (expectedRunner && (runnerId !== expectedRunner.name || !
|
|
1596
|
+
if (expectedRunner && (runnerId !== expectedRunner.name || !canonicalEqual2(labels, expectedRunner.labels))) throw new TypeError(`${path2} runner identity/labels differ from the exact runner API preflight observation.`);
|
|
1509
1597
|
const os = object5(observed.os, `${path2}.observed.os`);
|
|
1510
1598
|
exact3(os, ["name", "version", "channel", "architecture"], `${path2}.observed.os`);
|
|
1511
1599
|
const osVersion = token3(os.version, `${path2}.observed.os.version`);
|
|
@@ -1564,15 +1652,15 @@ function assertCellEvidence(value, cell, matrix, preflight, harness, adapterHarn
|
|
|
1564
1652
|
if (input.contractVersion !== SHADER_VALIDATION_EVIDENCE_VERSION || input.qualificationId !== preflight.qualificationId || input.matrixId !== matrix.matrixId || input.matrixVersion !== matrix.version || input.cellId !== cell.cellId || input.matrixSha256 !== preflight.matrixSha256 || input.dataBundleSha256 !== preflight.dataBundleSha256 || input.compileUnitInventorySha256 !== preflight.compileUnitInventorySha256 || input.subjectBindingSha256 !== preflight.subjectBindingSha256) throw new TypeError(`Cell evidence ${cell.cellId} has stale subject/matrix identities.`);
|
|
1565
1653
|
const actualHarness = object5(input.harness, `cellEvidence.${cell.cellId}.harness`);
|
|
1566
1654
|
exact3(actualHarness, ["id", "version", "sha256"], `cellEvidence.${cell.cellId}.harness`);
|
|
1567
|
-
if (!
|
|
1655
|
+
if (!canonicalEqual2(actualHarness, harness)) throw new TypeError(`Cell evidence ${cell.cellId} used a different harness.`);
|
|
1568
1656
|
const automation2 = object5(input.automation, `cellEvidence.${cell.cellId}.automation`);
|
|
1569
1657
|
exact3(automation2, ["kind", "driver", "version", "sha256"], `cellEvidence.${cell.cellId}.automation`);
|
|
1570
1658
|
if (automation2.kind !== cell.automation.kind) throw new TypeError(`Cell evidence ${cell.cellId} used the wrong automation route.`);
|
|
1571
1659
|
token3(automation2.driver, `cellEvidence.${cell.cellId}.automation.driver`);
|
|
1572
1660
|
token3(automation2.version, `cellEvidence.${cell.cellId}.automation.version`);
|
|
1573
1661
|
sha2(automation2.sha256, `cellEvidence.${cell.cellId}.automation.sha256`);
|
|
1574
|
-
if (adapterHarness !== null && !
|
|
1575
|
-
if (!
|
|
1662
|
+
if (adapterHarness !== null && !canonicalEqual2({ id: automation2.driver, version: automation2.version, sha256: automation2.sha256 }, adapterHarness)) throw new TypeError(`Cell evidence ${cell.cellId} automation differs from its independently verified preflight adapter harness.`);
|
|
1663
|
+
if (!canonicalEqual2(parseTrustedWorkflowProvenance(input.qualificationPreflightProvenance), preflight.provenance)) throw new TypeError(`Cell evidence ${cell.cellId} changed trusted prepare provenance.`);
|
|
1576
1664
|
const producer = parseQualificationExecutionProducer(input.producer, `cellEvidence.${cell.cellId}.producer`);
|
|
1577
1665
|
assertProducerMatchesPreflight(producer, preflight.provenance, cell, `cellEvidence.${cell.cellId}.producer`, cell.adapter.kind === "software" ? "swiftshader" : "physical");
|
|
1578
1666
|
const results = array2(input.results, `cellEvidence.${cell.cellId}.results`);
|
|
@@ -1614,7 +1702,7 @@ async function aggregateShaderValidationEvidence(input) {
|
|
|
1614
1702
|
} catch (cause) {
|
|
1615
1703
|
throw new TypeError(`${label} bytes are not UTF-8 JSON.`, { cause });
|
|
1616
1704
|
}
|
|
1617
|
-
if (!
|
|
1705
|
+
if (!canonicalEqual2(parsed, artifact.value)) throw new TypeError(`${label} parsed value differs from its exact bytes.`);
|
|
1618
1706
|
};
|
|
1619
1707
|
await verifyArtifact(input.preflight, "Qualification preflight");
|
|
1620
1708
|
for (const artifact of input.cellEvidence) await verifyArtifact(artifact, "Cell evidence");
|
|
@@ -1634,14 +1722,14 @@ async function aggregateShaderValidationEvidence(input) {
|
|
|
1634
1722
|
const sourceBlob = object5(preflight.sourceBlob, "Qualification preflight.sourceBlob");
|
|
1635
1723
|
exact3(sourceBlob, ["host", "versionId", "uri"], "Qualification preflight.sourceBlob");
|
|
1636
1724
|
const normalizedSource = immutableBlobUri(token3(sourceBlob.uri, "Qualification preflight.sourceBlob.uri", 2048));
|
|
1637
|
-
if (!
|
|
1725
|
+
if (!canonicalEqual2(sourceBlob, normalizedSource)) throw new TypeError("Qualification preflight source Blob claims are stale.");
|
|
1638
1726
|
let parsedMatrix;
|
|
1639
1727
|
try {
|
|
1640
1728
|
parsedMatrix = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(input.matrixBytes));
|
|
1641
1729
|
} catch (cause) {
|
|
1642
1730
|
throw new TypeError("Matrix artifact is not UTF-8 JSON.", { cause });
|
|
1643
1731
|
}
|
|
1644
|
-
if (!
|
|
1732
|
+
if (!canonicalEqual2(parsedMatrix, input.matrix)) throw new TypeError("Matrix artifact bytes differ from the supplied matrix value.");
|
|
1645
1733
|
const actualMatrixSha256 = await computeSha256(input.matrixBytes);
|
|
1646
1734
|
if (preflight.matrixSha256 !== actualMatrixSha256) throw new TypeError("Qualification preflight matrix artifact digest is stale.");
|
|
1647
1735
|
const actualInventorySha256 = await computeQualificationInventorySha256(input.bundle);
|
|
@@ -1685,7 +1773,7 @@ async function aggregateShaderValidationEvidence(input) {
|
|
|
1685
1773
|
exact3(raw, ["contractVersion", "kind", "qualificationId", "cellId", "status", "matrixSha256", "runnerLabels", "matchedRunners", "adapterHarness", "qualificationPreflightProvenance", "producer"], `runnerPreflight.${cell.cellId}`);
|
|
1686
1774
|
const producer = parseQualificationExecutionProducer(value2.producer, `runnerPreflight.${cell.cellId}.producer`);
|
|
1687
1775
|
assertProducerMatchesPreflight(producer, preflight.provenance, cell, `runnerPreflight.${cell.cellId}.producer`, cell.adapter.kind === "software" ? "swiftshader" : "physical-runner-preflight");
|
|
1688
|
-
if (value2.contractVersion !== SHADER_VALIDATION_EVIDENCE_VERSION || value2.kind !== "shader-runner-cell-preflight-evidence" || value2.qualificationId !== preflight.qualificationId || value2.cellId !== cell.cellId || value2.matrixSha256 !== preflight.matrixSha256 || !
|
|
1776
|
+
if (value2.contractVersion !== SHADER_VALIDATION_EVIDENCE_VERSION || value2.kind !== "shader-runner-cell-preflight-evidence" || value2.qualificationId !== preflight.qualificationId || value2.cellId !== cell.cellId || value2.matrixSha256 !== preflight.matrixSha256 || !canonicalEqual2(value2.runnerLabels, cell.runnerLabels) || !canonicalEqual2(value2.qualificationPreflightProvenance, preflight.provenance)) throw new TypeError(`Runner preflight ${cell.cellId} is stale or inconsistent.`);
|
|
1689
1777
|
const requestedLabels = cell.runnerLabels.map(foldRunnerLabel);
|
|
1690
1778
|
const matched = array2(value2.matchedRunners, `runnerPreflight.${cell.cellId}.matchedRunners`).map((item, index) => {
|
|
1691
1779
|
const label = `runnerPreflight.${cell.cellId}.matchedRunners[${index}]`;
|
|
@@ -1724,7 +1812,7 @@ async function aggregateShaderValidationEvidence(input) {
|
|
|
1724
1812
|
const producer = parseQualificationExecutionProducer(value2.producer, `workflowDiagnostic.${cell.cellId}.producer`);
|
|
1725
1813
|
assertProducerMatchesPreflight(producer, preflight.provenance, cell, `workflowDiagnostic.${cell.cellId}.producer`, cell.adapter.kind === "software" ? "swiftshader" : "physical");
|
|
1726
1814
|
if (!runner.value.matchedRunners.some((item) => item.name === producer.runner.name)) throw new TypeError(`Workflow diagnostic ${cell.cellId} was not produced by a runner matched in preflight.`);
|
|
1727
|
-
if (value2.contractVersion !== SHADER_VALIDATION_EVIDENCE_VERSION || value2.kind !== "non-qualifying-workflow-diagnostic" || value2.qualificationId !== preflight.qualificationId || value2.cellId !== cell.cellId || value2.matrixSha256 !== preflight.matrixSha256 || !
|
|
1815
|
+
if (value2.contractVersion !== SHADER_VALIDATION_EVIDENCE_VERSION || value2.kind !== "non-qualifying-workflow-diagnostic" || value2.qualificationId !== preflight.qualificationId || value2.cellId !== cell.cellId || value2.matrixSha256 !== preflight.matrixSha256 || !canonicalEqual2(value2.qualificationPreflightProvenance, preflight.provenance)) throw new TypeError(`Workflow diagnostic ${cell.cellId} is stale or inconsistent.`);
|
|
1728
1816
|
token3(value2.message, `workflowDiagnostic.${cell.cellId}.message`, 4096);
|
|
1729
1817
|
const status2 = value2.status === "timeout" ? "timeout" : "failed";
|
|
1730
1818
|
for (const unit of units) results.push(syntheticResult(unit, cell, status2, value2.message, now));
|
|
@@ -1773,7 +1861,7 @@ async function validateShaderValidationEvidence(input) {
|
|
|
1773
1861
|
} catch (cause) {
|
|
1774
1862
|
throw new TypeError("Matrix artifact is not UTF-8 JSON.", { cause });
|
|
1775
1863
|
}
|
|
1776
|
-
if (!
|
|
1864
|
+
if (!canonicalEqual2(parsedMatrix, input.matrix)) throw new TypeError("Matrix artifact bytes differ from the supplied matrix value.");
|
|
1777
1865
|
const matrixSha256 = await computeSha256(input.matrixBytes);
|
|
1778
1866
|
const inventorySha256 = await computeQualificationInventorySha256(input.bundle);
|
|
1779
1867
|
if (inventorySha256 !== input.bundle.subject.compileUnitInventorySha256) throw new TypeError("Bundle subject inventory digest is stale.");
|
|
@@ -1781,7 +1869,7 @@ async function validateShaderValidationEvidence(input) {
|
|
|
1781
1869
|
const expectedSubjectKeys = [...Object.keys(input.bundle.subject), "dataBundleSha256"];
|
|
1782
1870
|
exact3(subject, expectedSubjectKeys, "evidence.subject");
|
|
1783
1871
|
const candidateSubject = Object.fromEntries(Object.entries(subject).filter(([key]) => key !== "dataBundleSha256"));
|
|
1784
|
-
if (!
|
|
1872
|
+
if (!canonicalEqual2(candidateSubject, input.bundle.subject)) throw new TypeError("Evidence candidate subject differs from bundle.");
|
|
1785
1873
|
const dataBundleSha256 = sha2(subject.dataBundleSha256, "evidence.subject.dataBundleSha256");
|
|
1786
1874
|
if (input.dataBundleSha256 && input.dataBundleSha256 !== dataBundleSha256) throw new TypeError("Evidence data bundle digest differs from the exact archive.");
|
|
1787
1875
|
if (subject.compileUnitInventorySha256 !== inventorySha256) throw new TypeError("Evidence compile-unit inventory digest is stale.");
|
|
@@ -1839,11 +1927,11 @@ async function validateShaderValidationEvidence(input) {
|
|
|
1839
1927
|
const sourceArtifactSha256 = sha2(run.sourceArtifactSha256, `${path2}.sourceArtifactSha256`);
|
|
1840
1928
|
if (/^0{64}$/u.test(sourceArtifactSha256)) throw new TypeError(`${path2}.sourceArtifactSha256 cannot be a placeholder.`);
|
|
1841
1929
|
const resultsSha256 = sha2(run.resultsSha256, `${path2}.resultsSha256`);
|
|
1842
|
-
if (!
|
|
1930
|
+
if (!canonicalEqual2(parseTrustedWorkflowProvenance(run.qualificationPreflightProvenance, `${path2}.qualificationPreflightProvenance`), preflightProvenance)) throw new TypeError(`${path2} changed qualification preflight provenance.`);
|
|
1843
1931
|
const producer = parseQualificationExecutionProducer(run.producer, `${path2}.producer`);
|
|
1844
1932
|
const expectedJob = run.source === "runner-preflight" ? cell.adapter.kind === "software" ? "swiftshader" : "physical-runner-preflight" : cell.adapter.kind === "software" ? "swiftshader" : "physical";
|
|
1845
1933
|
assertProducerMatchesPreflight(producer, preflightProvenance, cell, `${path2}.producer`, expectedJob);
|
|
1846
|
-
if (!
|
|
1934
|
+
if (!canonicalEqual2(run.harness, harness)) throw new TypeError(`${path2}.harness differs.`);
|
|
1847
1935
|
if (run.source === "cell-evidence") {
|
|
1848
1936
|
const automation2 = object5(run.automation, `${path2}.automation`);
|
|
1849
1937
|
exact3(automation2, ["kind", "driver", "version", "sha256"], `${path2}.automation`);
|