@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.
@@ -1,4 +1,4 @@
1
- import { ay as ShaderCompileUnitManifest, j as ShaderResult, ax as ShaderCompileUnitInventory, b6 as StableWebGpuMatrixManifest, aH as ShaderQualificationBundleManifest, aL as ShaderQualificationFixtureManifest, S as Sha256Hex, aQ as ShaderQualificationPreflightManifest, au as ShaderCellEvidence, aX as ShaderRunnerCellPreflightEvidence, aE as ShaderNonQualifyingWorkflowDiagnostic, a$ as ShaderValidationEvidence, aI as ShaderQualificationCandidateSubject, aZ as ShaderTrustedWorkflowProvenance, b0 as ShaderValidationEvidenceAttestationRef } from './contracts-C4eel8MT.cjs';
1
+ import { ay as ShaderCompileUnitManifest, j as ShaderResult, ax as ShaderCompileUnitInventory, b6 as StableWebGpuMatrixManifest, aH as ShaderQualificationBundleManifest, aL as ShaderQualificationFixtureManifest, S as Sha256Hex, aQ as ShaderQualificationPreflightManifest, au as ShaderCellEvidence, aX as ShaderRunnerCellPreflightEvidence, aE as ShaderNonQualifyingWorkflowDiagnostic, a$ as ShaderValidationEvidence, aI as ShaderQualificationCandidateSubject, aZ as ShaderTrustedWorkflowProvenance, b0 as ShaderValidationEvidenceAttestationRef } from './contracts-B49AUejk.cjs';
2
2
 
3
3
  /** Identity helper that makes compile-unit declarations readonly at the call site. */
4
4
  declare function defineShaderCompileUnit<const T extends ShaderCompileUnitManifest>(unit: T): T;
package/dist/testing.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ay as ShaderCompileUnitManifest, j as ShaderResult, ax as ShaderCompileUnitInventory, b6 as StableWebGpuMatrixManifest, aH as ShaderQualificationBundleManifest, aL as ShaderQualificationFixtureManifest, S as Sha256Hex, aQ as ShaderQualificationPreflightManifest, au as ShaderCellEvidence, aX as ShaderRunnerCellPreflightEvidence, aE as ShaderNonQualifyingWorkflowDiagnostic, a$ as ShaderValidationEvidence, aI as ShaderQualificationCandidateSubject, aZ as ShaderTrustedWorkflowProvenance, b0 as ShaderValidationEvidenceAttestationRef } from './contracts-C4eel8MT.js';
1
+ import { ay as ShaderCompileUnitManifest, j as ShaderResult, ax as ShaderCompileUnitInventory, b6 as StableWebGpuMatrixManifest, aH as ShaderQualificationBundleManifest, aL as ShaderQualificationFixtureManifest, S as Sha256Hex, aQ as ShaderQualificationPreflightManifest, au as ShaderCellEvidence, aX as ShaderRunnerCellPreflightEvidence, aE as ShaderNonQualifyingWorkflowDiagnostic, a$ as ShaderValidationEvidence, aI as ShaderQualificationCandidateSubject, aZ as ShaderTrustedWorkflowProvenance, b0 as ShaderValidationEvidenceAttestationRef } from './contracts-B49AUejk.js';
2
2
 
3
3
  /** Identity helper that makes compile-unit declarations readonly at the call site. */
4
4
  declare function defineShaderCompileUnit<const T extends ShaderCompileUnitManifest>(unit: T): T;
package/dist/testing.js CHANGED
@@ -8,7 +8,7 @@ var SUPPORTED_STABLE_WEBGPU_MATRIX_POLICIES = [
8
8
  Object.freeze({
9
9
  matrixId: "stable-webgpu",
10
10
  matrixVersion: "2026-07-13",
11
- matrixSha256: "9b47ff8162b055d49e38c4fe90b9074992ab8c9e1125926e936f8122e6119fd8"
11
+ matrixSha256: "4620eca44fd03004ee7650cfe9fcf42934493611a5097da5525f71578980b016"
12
12
  })
13
13
  ];
14
14
  Object.freeze(SUPPORTED_STABLE_WEBGPU_MATRIX_POLICIES);
@@ -74,6 +74,29 @@ function canonicalizeGpuContract(value) {
74
74
  return visit(value, "$root");
75
75
  }
76
76
 
77
+ // src/asset-version.ts
78
+ var ASSET_VERSION_PATTERN = /^[0-9A-Za-z][0-9A-Za-z._-]{0,127}$/u;
79
+ var MUTABLE_VERSION_ALIASES = /* @__PURE__ */ new Set([
80
+ "latest",
81
+ "current",
82
+ "stable",
83
+ "preview",
84
+ "default",
85
+ "production",
86
+ "canary",
87
+ "next",
88
+ "head",
89
+ "main"
90
+ ]);
91
+ var X_WILDCARD_SEGMENT_PATTERN = /^(?:[vV])?[xX](?:\.|-|$)|\.[xX](?:\.|-|$)/u;
92
+ 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.";
93
+ function assertImmutableAssetVersion(value) {
94
+ if (typeof value !== "string" || !ASSET_VERSION_PATTERN.test(value) || MUTABLE_VERSION_ALIASES.has(value.toLowerCase()) || X_WILDCARD_SEGMENT_PATTERN.test(value)) {
95
+ throw new TypeError(IMMUTABLE_VERSION_ERROR_MESSAGE);
96
+ }
97
+ return value;
98
+ }
99
+
77
100
  // src/hash.ts
78
101
  var SHA256_PATTERN = /^[a-f0-9]{64}$/u;
79
102
  function asSha256Hex(value) {
@@ -96,6 +119,15 @@ async function computeSha256(value) {
96
119
 
97
120
  // src/manifest-validation.ts
98
121
  var stages = ["vertex", "fragment", "compute"];
122
+ function detachedJson(value, path2) {
123
+ try {
124
+ return JSON.parse(canonicalizeGpuContract(value));
125
+ } catch (cause) {
126
+ const detail = cause instanceof Error ? cause.message : "Contract snapshot failed.";
127
+ const boundedDetail = [...detail].slice(0, 512).join("");
128
+ throw new TypeError(`${path2} must contain detached JSON contract data: ${boundedDetail}`, { cause });
129
+ }
130
+ }
99
131
  function object(value, path2) {
100
132
  if (typeof value !== "object" || value === null || Array.isArray(value)) throw new TypeError(`${path2} must be an object.`);
101
133
  return value;
@@ -308,7 +340,7 @@ function pipeline(value, path2, moduleIds) {
308
340
  return input;
309
341
  }
310
342
  function parseSerializableGpuPipelineDescriptors(value, moduleIds, path2 = "pipelines") {
311
- const parsed = array(value, path2).map((item, index) => pipeline(item, `${path2}[${index}]`, new Set(moduleIds)));
343
+ const parsed = array(detachedJson(value, path2), path2).map((item, index) => pipeline(item, `${path2}[${index}]`, new Set(moduleIds)));
312
344
  unique(parsed, (item) => item.pipelineId, path2);
313
345
  return freeze(parsed);
314
346
  }
@@ -326,6 +358,11 @@ function issue(code, message, path2) {
326
358
  function object2(value) {
327
359
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
328
360
  }
361
+ function freezeJson(value) {
362
+ if (typeof value !== "object" || value === null || Object.isFrozen(value)) return value;
363
+ for (const child of Object.values(value)) freezeJson(child);
364
+ return Object.freeze(value);
365
+ }
329
366
  function exactKeys(value, keys2) {
330
367
  const expected = new Set(keys2);
331
368
  return Object.keys(value).every((key) => expected.has(key)) && keys2.every((key) => key in value);
@@ -333,6 +370,14 @@ function exactKeys(value, keys2) {
333
370
  function safeToken(value) {
334
371
  return typeof value === "string" && /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,159}$/u.test(value) && !value.includes("..");
335
372
  }
373
+ function immutableVersion(value) {
374
+ try {
375
+ assertImmutableAssetVersion(value);
376
+ return true;
377
+ } catch {
378
+ return false;
379
+ }
380
+ }
336
381
  function validSha(value) {
337
382
  try {
338
383
  asSha256Hex(String(value));
@@ -345,8 +390,20 @@ function defineShaderCompileUnit(unit) {
345
390
  return Object.freeze(unit);
346
391
  }
347
392
  function validateCompileUnitInventory(value) {
348
- const envelope = object2(value);
349
- const candidate = envelope && "inventory" in envelope ? object2(value.inventory) : envelope;
393
+ let snapshot;
394
+ try {
395
+ snapshot = JSON.parse(canonicalizeGpuContract(value));
396
+ } catch (cause) {
397
+ return {
398
+ ok: false,
399
+ diagnostics: [issue(
400
+ "invalid-contract",
401
+ cause instanceof Error ? cause.message : "Compile-unit inventory must contain detached JSON data."
402
+ )]
403
+ };
404
+ }
405
+ const envelope = object2(snapshot);
406
+ const candidate = envelope && Object.hasOwn(envelope, "inventory") ? object2(snapshot.inventory) : envelope;
350
407
  const diagnostics = [];
351
408
  if (!candidate || !exactKeys(candidate, ["contractVersion", "fragments", "compileUnits"])) {
352
409
  return { ok: false, diagnostics: [issue("invalid-contract", "Compile-unit inventory has unknown or missing fields.")] };
@@ -477,7 +534,7 @@ function validateCompileUnitInventory(value) {
477
534
  diagnostics.push(issue("invalid-contract", cause instanceof Error ? cause.message : "Compile-unit pipelines are invalid.", `${path2}.pipelines`));
478
535
  }
479
536
  const interfaceRef = object2(unit.interfaceRef);
480
- if (!interfaceRef || !exactKeys(interfaceRef, ["interfaceId", "interfaceVersion", "manifestUri", "manifestSha256", "interfaceAbiHash", "modelAbiHash"]) || !safeToken(interfaceRef.interfaceId) || !safeToken(interfaceRef.interfaceVersion) || typeof interfaceRef.manifestUri !== "string" || !interfaceRef.manifestUri.startsWith("https://") || !validSha(interfaceRef.manifestSha256) || !validSha(interfaceRef.interfaceAbiHash) || !validSha(interfaceRef.modelAbiHash)) {
537
+ 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)) {
481
538
  diagnostics.push(issue("invalid-contract", "Compile-unit interfaceRef is invalid.", `${path2}.interfaceRef`));
482
539
  }
483
540
  const fixture = object2(unit.qualificationFixture);
@@ -488,7 +545,7 @@ function validateCompileUnitInventory(value) {
488
545
  for (const fragmentId of fragmentIds) {
489
546
  if (!covered.has(fragmentId)) diagnostics.push(issue("uncovered-fragment", `WGSL fragment ${fragmentId} has no compile unit.`));
490
547
  }
491
- return diagnostics.length > 0 ? { ok: false, diagnostics } : { ok: true, value: candidate };
548
+ return diagnostics.length > 0 ? { ok: false, diagnostics } : { ok: true, value: freezeJson(candidate) };
492
549
  }
493
550
 
494
551
  // src/testing/matrix.ts
@@ -502,6 +559,13 @@ function keys(value, expected) {
502
559
  const set = new Set(expected);
503
560
  return Object.keys(value).every((key) => set.has(key)) && expected.every((key) => key in value);
504
561
  }
562
+ function canonicalEqual(left, right) {
563
+ try {
564
+ return canonicalizeGpuContract(left) === canonicalizeGpuContract(right);
565
+ } catch {
566
+ return false;
567
+ }
568
+ }
505
569
  var browserNames = /* @__PURE__ */ new Set(["chromium", "chrome", "edge", "firefox", "safari"]);
506
570
  var osNames = /* @__PURE__ */ new Set(["ubuntu", "windows", "macos", "chromeos", "android", "ios", "ipados", "visionos"]);
507
571
  var backends = /* @__PURE__ */ new Set(["swiftshader", "d3d12", "metal", "vulkan"]);
@@ -595,7 +659,9 @@ function validateStableWebGpuMatrix(value) {
595
659
  const kind = String(requirement?.kind);
596
660
  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");
597
661
  if (!validRequirement) diagnostics.push(issue2("OS version requirement is invalid.", `${path2}.os.versionRequirement`));
598
- if (typeof cell.cellId === "string" && JSON.stringify(requirement) !== JSON.stringify(VERSION_REQUIREMENTS.get(cell.cellId))) diagnostics.push(issue2("OS version requirement differs from the stable baseline.", `${path2}.os.versionRequirement`));
662
+ if (typeof cell.cellId === "string" && !canonicalEqual(requirement, VERSION_REQUIREMENTS.get(cell.cellId))) {
663
+ diagnostics.push(issue2("OS version requirement differs from the stable baseline.", `${path2}.os.versionRequirement`));
664
+ }
599
665
  }
600
666
  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`));
601
667
  if (!adapterAutomation || !keys(adapterAutomation, ["kind"]) || !automation.has(String(adapterAutomation.kind))) diagnostics.push(issue2("Automation descriptor is invalid.", `${path2}.automation`));
@@ -706,6 +772,18 @@ function object4(value, path2) {
706
772
  if (typeof value !== "object" || value === null || Array.isArray(value)) throw new TypeError(`${path2} must be an object.`);
707
773
  return value;
708
774
  }
775
+ function detachedJson2(value, label) {
776
+ try {
777
+ return JSON.parse(canonicalizeGpuContract(value));
778
+ } catch (cause) {
779
+ throw new TypeError(`${label} must contain detached JSON contract data.`, { cause });
780
+ }
781
+ }
782
+ function freezeJson2(value) {
783
+ if (typeof value !== "object" || value === null || Object.isFrozen(value)) return value;
784
+ for (const child of Object.values(value)) freezeJson2(child);
785
+ return Object.freeze(value);
786
+ }
709
787
  function exact2(value, keys2, path2) {
710
788
  const expected = new Set(keys2);
711
789
  if (!Object.keys(value).every((key) => expected.has(key)) || !keys2.every((key) => key in value)) throw new TypeError(`${path2} has unknown or missing fields.`);
@@ -714,6 +792,16 @@ function token2(value, path2) {
714
792
  if (typeof value !== "string" || !TOKEN.test(value) || value.includes("..")) throw new TypeError(`${path2} must be a safe token.`);
715
793
  return value;
716
794
  }
795
+ function immutableVersion2(value, path2) {
796
+ try {
797
+ return assertImmutableAssetVersion(value);
798
+ } catch (cause) {
799
+ throw new TypeError(
800
+ `${path2} must be an immutable asset version: exact token required; mutable aliases, ranges, wildcards, and URLs are not allowed.`,
801
+ { cause }
802
+ );
803
+ }
804
+ }
717
805
  function path(value, label, extensions) {
718
806
  if (typeof value !== "string" || !SAFE_PATH2.test(value) || !extensions.some((extension) => value.endsWith(extension))) {
719
807
  throw new TypeError(`${label} must be a safe data-only bundle path (${extensions.join(", ")}).`);
@@ -848,7 +936,7 @@ function jsonValue(value, label, depth = 0) {
848
936
  }
849
937
  function validateQualificationFixture(value, unit) {
850
938
  try {
851
- const fixture = object4(value, "fixture");
939
+ const fixture = object4(detachedJson2(value, "fixture"), "fixture");
852
940
  exact2(fixture, ["contractVersion", "fixtureId", "resources", "bindGroups", "commands", "layoutProbes", "readbacks", "bounds"], "fixture");
853
941
  if (fixture.contractVersion !== SHADER_QUALIFICATION_FIXTURE_VERSION) throw new TypeError("Unsupported qualification fixture version.");
854
942
  token2(fixture.fixtureId, "fixture.fixtureId");
@@ -1184,14 +1272,14 @@ function validateQualificationFixture(value, unit) {
1184
1272
  }
1185
1273
  unique2(probeIds, "fixture.layoutProbes probe IDs");
1186
1274
  unique2(probeSources, "fixture.layoutProbes model sources");
1187
- return { ok: true, value: fixture };
1275
+ return { ok: true, value: freezeJson2(fixture) };
1188
1276
  } catch (cause) {
1189
1277
  return { ok: false, diagnostics: [{ code: "invalid-contract", severity: "error", message: cause instanceof Error ? cause.message : "Invalid qualification fixture." }] };
1190
1278
  }
1191
1279
  }
1192
1280
  function validateQualificationBundleManifest(value) {
1193
1281
  try {
1194
- const bundle = object4(value, "qualification");
1282
+ const bundle = object4(detachedJson2(value, "qualification"), "qualification");
1195
1283
  exact2(bundle, ["contractVersion", "inventory", "subject", "shaderManifestCorePath", "gpuInterfaceManifest", "modelCompatibilityFixtures", "modules", "fixtures"], "qualification");
1196
1284
  if (bundle.contractVersion !== SHADER_QUALIFICATION_BUNDLE_VERSION) throw new TypeError("Unsupported qualification bundle version.");
1197
1285
  const inventory = validateCompileUnitInventory(bundle.inventory);
@@ -1201,7 +1289,7 @@ function validateQualificationBundleManifest(value) {
1201
1289
  const candidate = object4(subject.shaderManifestCore, "qualification.subject.shaderManifestCore");
1202
1290
  exact2(candidate, ["shaderId", "version", "sha256"], "qualification.subject.shaderManifestCore");
1203
1291
  token2(candidate.shaderId, "qualification.subject.shaderManifestCore.shaderId");
1204
- token2(candidate.version, "qualification.subject.shaderManifestCore.version");
1292
+ immutableVersion2(candidate.version, "qualification.subject.shaderManifestCore.version");
1205
1293
  sha(candidate.sha256, "qualification.subject.shaderManifestCore.sha256");
1206
1294
  path(bundle.shaderManifestCorePath, "qualification.shaderManifestCorePath", [".json"]);
1207
1295
  const interfaceManifest = object4(bundle.gpuInterfaceManifest, "qualification.gpuInterfaceManifest");
@@ -1261,7 +1349,7 @@ function validateQualificationBundleManifest(value) {
1261
1349
  const expectedUnits = [...inventory.value.compileUnits.map((unit) => unit.compileUnitId)].sort();
1262
1350
  if (unitIds.join("\n") !== expectedUnits.join("\n")) throw new TypeError("Subject compile-unit IDs differ from inventory.");
1263
1351
  orderedUniqueTokens(subject.requiredCellIds, "qualification.subject.requiredCellIds");
1264
- return { ok: true, value: bundle };
1352
+ return { ok: true, value: freezeJson2(bundle) };
1265
1353
  } catch (cause) {
1266
1354
  return { ok: false, diagnostics: [{ code: "invalid-contract", severity: "error", message: cause instanceof Error ? cause.message : "Invalid qualification bundle." }] };
1267
1355
  }
@@ -1360,12 +1448,12 @@ function parseQualificationExecutionProducer(value, path2 = "producer") {
1360
1448
  return input;
1361
1449
  }
1362
1450
  function assertProducerMatchesPreflight(producer, provenance, cell, path2, expectedJob) {
1363
- if (producer.repository !== provenance.repository || !canonicalEqual(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 || !canonicalEqual(producer.trustedWorkflowSha, provenance.workflowSha) || producer.job !== expectedJob) throw new TypeError(`${path2} does not match the exact qualification workflow run or subject.`);
1451
+ 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.`);
1364
1452
  if (expectedJob === "swiftshader" && producer.runner.environment !== "github-hosted") throw new TypeError(`${path2} must identify the hosted SwiftShader job.`);
1365
1453
  if (expectedJob === "physical" && producer.runner.environment === "github-hosted") throw new TypeError(`${path2} cannot use a hosted runner for a physical execution cell.`);
1366
1454
  if (expectedJob === "physical-runner-preflight" && producer.runner.environment !== "github-hosted") throw new TypeError(`${path2} must identify its hosted orchestration job truthfully.`);
1367
1455
  }
1368
- function canonicalEqual(left, right) {
1456
+ function canonicalEqual2(left, right) {
1369
1457
  return canonicalizeGpuContract(left) === canonicalizeGpuContract(right);
1370
1458
  }
1371
1459
  function foldRunnerLabel(value) {
@@ -1401,13 +1489,13 @@ async function createQualificationPreflight(input) {
1401
1489
  } catch (cause) {
1402
1490
  throw new TypeError("Selected matrix artifact is not UTF-8 JSON.", { cause });
1403
1491
  }
1404
- if (!canonicalEqual(parsedMatrix, input.matrix)) throw new TypeError("Selected matrix artifact bytes differ from the supplied matrix value.");
1492
+ if (!canonicalEqual2(parsedMatrix, input.matrix)) throw new TypeError("Selected matrix artifact bytes differ from the supplied matrix value.");
1405
1493
  const actualMatrixSha256 = await computeSha256(input.matrixBytes);
1406
1494
  if (actualMatrixSha256 !== input.matrixSha256) throw new TypeError("Selected matrix digest is not derived from the exact matrix manifest.");
1407
1495
  const inventorySha256 = await computeQualificationInventorySha256(input.bundle);
1408
1496
  if (inventorySha256 !== input.bundle.subject.compileUnitInventorySha256) throw new TypeError("Bundle subject contains a stale compile-unit inventory digest.");
1409
1497
  const requiredCells = input.matrix.cells.map((cell) => cell.cellId);
1410
- if (!canonicalEqual(input.bundle.subject.requiredCellIds, requiredCells)) throw new TypeError("Bundle subject cell set differs from the selected matrix.");
1498
+ if (!canonicalEqual2(input.bundle.subject.requiredCellIds, requiredCells)) throw new TypeError("Bundle subject cell set differs from the selected matrix.");
1411
1499
  const subjectBindingSha256 = await computeQualificationSubjectBinding({
1412
1500
  subject: input.bundle.subject,
1413
1501
  dataBundleSha256: input.dataBundleSha256,
@@ -1467,7 +1555,7 @@ function assertResult(value, path2, cell, passingRequired, timeBounds, expectedR
1467
1555
  const labels = array2(runner.labels, `${path2}.observed.runner.labels`).map((item, index) => token3(item, `${path2}.observed.runner.labels[${index}]`));
1468
1556
  const normalizedLabels = labels.map(foldRunnerLabel);
1469
1557
  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).`);
1470
- if (expectedRunner && (runnerId !== expectedRunner.name || !canonicalEqual(labels, expectedRunner.labels))) throw new TypeError(`${path2} runner identity/labels differ from the exact runner API preflight observation.`);
1558
+ if (expectedRunner && (runnerId !== expectedRunner.name || !canonicalEqual2(labels, expectedRunner.labels))) throw new TypeError(`${path2} runner identity/labels differ from the exact runner API preflight observation.`);
1471
1559
  const os = object5(observed.os, `${path2}.observed.os`);
1472
1560
  exact3(os, ["name", "version", "channel", "architecture"], `${path2}.observed.os`);
1473
1561
  const osVersion = token3(os.version, `${path2}.observed.os.version`);
@@ -1526,15 +1614,15 @@ function assertCellEvidence(value, cell, matrix, preflight, harness, adapterHarn
1526
1614
  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.`);
1527
1615
  const actualHarness = object5(input.harness, `cellEvidence.${cell.cellId}.harness`);
1528
1616
  exact3(actualHarness, ["id", "version", "sha256"], `cellEvidence.${cell.cellId}.harness`);
1529
- if (!canonicalEqual(actualHarness, harness)) throw new TypeError(`Cell evidence ${cell.cellId} used a different harness.`);
1617
+ if (!canonicalEqual2(actualHarness, harness)) throw new TypeError(`Cell evidence ${cell.cellId} used a different harness.`);
1530
1618
  const automation2 = object5(input.automation, `cellEvidence.${cell.cellId}.automation`);
1531
1619
  exact3(automation2, ["kind", "driver", "version", "sha256"], `cellEvidence.${cell.cellId}.automation`);
1532
1620
  if (automation2.kind !== cell.automation.kind) throw new TypeError(`Cell evidence ${cell.cellId} used the wrong automation route.`);
1533
1621
  token3(automation2.driver, `cellEvidence.${cell.cellId}.automation.driver`);
1534
1622
  token3(automation2.version, `cellEvidence.${cell.cellId}.automation.version`);
1535
1623
  sha2(automation2.sha256, `cellEvidence.${cell.cellId}.automation.sha256`);
1536
- if (adapterHarness !== null && !canonicalEqual({ 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.`);
1537
- if (!canonicalEqual(parseTrustedWorkflowProvenance(input.qualificationPreflightProvenance), preflight.provenance)) throw new TypeError(`Cell evidence ${cell.cellId} changed trusted prepare provenance.`);
1624
+ 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.`);
1625
+ if (!canonicalEqual2(parseTrustedWorkflowProvenance(input.qualificationPreflightProvenance), preflight.provenance)) throw new TypeError(`Cell evidence ${cell.cellId} changed trusted prepare provenance.`);
1538
1626
  const producer = parseQualificationExecutionProducer(input.producer, `cellEvidence.${cell.cellId}.producer`);
1539
1627
  assertProducerMatchesPreflight(producer, preflight.provenance, cell, `cellEvidence.${cell.cellId}.producer`, cell.adapter.kind === "software" ? "swiftshader" : "physical");
1540
1628
  const results = array2(input.results, `cellEvidence.${cell.cellId}.results`);
@@ -1576,7 +1664,7 @@ async function aggregateShaderValidationEvidence(input) {
1576
1664
  } catch (cause) {
1577
1665
  throw new TypeError(`${label} bytes are not UTF-8 JSON.`, { cause });
1578
1666
  }
1579
- if (!canonicalEqual(parsed, artifact.value)) throw new TypeError(`${label} parsed value differs from its exact bytes.`);
1667
+ if (!canonicalEqual2(parsed, artifact.value)) throw new TypeError(`${label} parsed value differs from its exact bytes.`);
1580
1668
  };
1581
1669
  await verifyArtifact(input.preflight, "Qualification preflight");
1582
1670
  for (const artifact of input.cellEvidence) await verifyArtifact(artifact, "Cell evidence");
@@ -1596,14 +1684,14 @@ async function aggregateShaderValidationEvidence(input) {
1596
1684
  const sourceBlob = object5(preflight.sourceBlob, "Qualification preflight.sourceBlob");
1597
1685
  exact3(sourceBlob, ["host", "versionId", "uri"], "Qualification preflight.sourceBlob");
1598
1686
  const normalizedSource = immutableBlobUri(token3(sourceBlob.uri, "Qualification preflight.sourceBlob.uri", 2048));
1599
- if (!canonicalEqual(sourceBlob, normalizedSource)) throw new TypeError("Qualification preflight source Blob claims are stale.");
1687
+ if (!canonicalEqual2(sourceBlob, normalizedSource)) throw new TypeError("Qualification preflight source Blob claims are stale.");
1600
1688
  let parsedMatrix;
1601
1689
  try {
1602
1690
  parsedMatrix = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(input.matrixBytes));
1603
1691
  } catch (cause) {
1604
1692
  throw new TypeError("Matrix artifact is not UTF-8 JSON.", { cause });
1605
1693
  }
1606
- if (!canonicalEqual(parsedMatrix, input.matrix)) throw new TypeError("Matrix artifact bytes differ from the supplied matrix value.");
1694
+ if (!canonicalEqual2(parsedMatrix, input.matrix)) throw new TypeError("Matrix artifact bytes differ from the supplied matrix value.");
1607
1695
  const actualMatrixSha256 = await computeSha256(input.matrixBytes);
1608
1696
  if (preflight.matrixSha256 !== actualMatrixSha256) throw new TypeError("Qualification preflight matrix artifact digest is stale.");
1609
1697
  const actualInventorySha256 = await computeQualificationInventorySha256(input.bundle);
@@ -1647,7 +1735,7 @@ async function aggregateShaderValidationEvidence(input) {
1647
1735
  exact3(raw, ["contractVersion", "kind", "qualificationId", "cellId", "status", "matrixSha256", "runnerLabels", "matchedRunners", "adapterHarness", "qualificationPreflightProvenance", "producer"], `runnerPreflight.${cell.cellId}`);
1648
1736
  const producer = parseQualificationExecutionProducer(value2.producer, `runnerPreflight.${cell.cellId}.producer`);
1649
1737
  assertProducerMatchesPreflight(producer, preflight.provenance, cell, `runnerPreflight.${cell.cellId}.producer`, cell.adapter.kind === "software" ? "swiftshader" : "physical-runner-preflight");
1650
- 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 || !canonicalEqual(value2.runnerLabels, cell.runnerLabels) || !canonicalEqual(value2.qualificationPreflightProvenance, preflight.provenance)) throw new TypeError(`Runner preflight ${cell.cellId} is stale or inconsistent.`);
1738
+ 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.`);
1651
1739
  const requestedLabels = cell.runnerLabels.map(foldRunnerLabel);
1652
1740
  const matched = array2(value2.matchedRunners, `runnerPreflight.${cell.cellId}.matchedRunners`).map((item, index) => {
1653
1741
  const label = `runnerPreflight.${cell.cellId}.matchedRunners[${index}]`;
@@ -1686,7 +1774,7 @@ async function aggregateShaderValidationEvidence(input) {
1686
1774
  const producer = parseQualificationExecutionProducer(value2.producer, `workflowDiagnostic.${cell.cellId}.producer`);
1687
1775
  assertProducerMatchesPreflight(producer, preflight.provenance, cell, `workflowDiagnostic.${cell.cellId}.producer`, cell.adapter.kind === "software" ? "swiftshader" : "physical");
1688
1776
  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.`);
1689
- 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 || !canonicalEqual(value2.qualificationPreflightProvenance, preflight.provenance)) throw new TypeError(`Workflow diagnostic ${cell.cellId} is stale or inconsistent.`);
1777
+ 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.`);
1690
1778
  token3(value2.message, `workflowDiagnostic.${cell.cellId}.message`, 4096);
1691
1779
  const status2 = value2.status === "timeout" ? "timeout" : "failed";
1692
1780
  for (const unit of units) results.push(syntheticResult(unit, cell, status2, value2.message, now));
@@ -1735,7 +1823,7 @@ async function validateShaderValidationEvidence(input) {
1735
1823
  } catch (cause) {
1736
1824
  throw new TypeError("Matrix artifact is not UTF-8 JSON.", { cause });
1737
1825
  }
1738
- if (!canonicalEqual(parsedMatrix, input.matrix)) throw new TypeError("Matrix artifact bytes differ from the supplied matrix value.");
1826
+ if (!canonicalEqual2(parsedMatrix, input.matrix)) throw new TypeError("Matrix artifact bytes differ from the supplied matrix value.");
1739
1827
  const matrixSha256 = await computeSha256(input.matrixBytes);
1740
1828
  const inventorySha256 = await computeQualificationInventorySha256(input.bundle);
1741
1829
  if (inventorySha256 !== input.bundle.subject.compileUnitInventorySha256) throw new TypeError("Bundle subject inventory digest is stale.");
@@ -1743,7 +1831,7 @@ async function validateShaderValidationEvidence(input) {
1743
1831
  const expectedSubjectKeys = [...Object.keys(input.bundle.subject), "dataBundleSha256"];
1744
1832
  exact3(subject, expectedSubjectKeys, "evidence.subject");
1745
1833
  const candidateSubject = Object.fromEntries(Object.entries(subject).filter(([key]) => key !== "dataBundleSha256"));
1746
- if (!canonicalEqual(candidateSubject, input.bundle.subject)) throw new TypeError("Evidence candidate subject differs from bundle.");
1834
+ if (!canonicalEqual2(candidateSubject, input.bundle.subject)) throw new TypeError("Evidence candidate subject differs from bundle.");
1747
1835
  const dataBundleSha256 = sha2(subject.dataBundleSha256, "evidence.subject.dataBundleSha256");
1748
1836
  if (input.dataBundleSha256 && input.dataBundleSha256 !== dataBundleSha256) throw new TypeError("Evidence data bundle digest differs from the exact archive.");
1749
1837
  if (subject.compileUnitInventorySha256 !== inventorySha256) throw new TypeError("Evidence compile-unit inventory digest is stale.");
@@ -1801,11 +1889,11 @@ async function validateShaderValidationEvidence(input) {
1801
1889
  const sourceArtifactSha256 = sha2(run.sourceArtifactSha256, `${path2}.sourceArtifactSha256`);
1802
1890
  if (/^0{64}$/u.test(sourceArtifactSha256)) throw new TypeError(`${path2}.sourceArtifactSha256 cannot be a placeholder.`);
1803
1891
  const resultsSha256 = sha2(run.resultsSha256, `${path2}.resultsSha256`);
1804
- if (!canonicalEqual(parseTrustedWorkflowProvenance(run.qualificationPreflightProvenance, `${path2}.qualificationPreflightProvenance`), preflightProvenance)) throw new TypeError(`${path2} changed qualification preflight provenance.`);
1892
+ if (!canonicalEqual2(parseTrustedWorkflowProvenance(run.qualificationPreflightProvenance, `${path2}.qualificationPreflightProvenance`), preflightProvenance)) throw new TypeError(`${path2} changed qualification preflight provenance.`);
1805
1893
  const producer = parseQualificationExecutionProducer(run.producer, `${path2}.producer`);
1806
1894
  const expectedJob = run.source === "runner-preflight" ? cell.adapter.kind === "software" ? "swiftshader" : "physical-runner-preflight" : cell.adapter.kind === "software" ? "swiftshader" : "physical";
1807
1895
  assertProducerMatchesPreflight(producer, preflightProvenance, cell, `${path2}.producer`, expectedJob);
1808
- if (!canonicalEqual(run.harness, harness)) throw new TypeError(`${path2}.harness differs.`);
1896
+ if (!canonicalEqual2(run.harness, harness)) throw new TypeError(`${path2}.harness differs.`);
1809
1897
  if (run.source === "cell-evidence") {
1810
1898
  const automation2 = object5(run.automation, `${path2}.automation`);
1811
1899
  exact3(automation2, ["kind", "driver", "version", "sha256"], `${path2}.automation`);