@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/cli.js
CHANGED
|
@@ -583,6 +583,7 @@ ${canonicalizeGpuContract(core)}`
|
|
|
583
583
|
// src/contracts.ts
|
|
584
584
|
var GPU_INTERFACE_MANIFEST_VERSION = "1.0.0";
|
|
585
585
|
var SHADER_VERSION_MANIFEST_VERSION = "1.0.0";
|
|
586
|
+
var SHADER_STYLE_PROFILE_MANIFEST_VERSION = "1.0.0";
|
|
586
587
|
var SHADER_COMPILE_UNIT_VERSION = "1.0.0";
|
|
587
588
|
var SHADER_VALIDATION_EVIDENCE_VERSION = "1.0.0";
|
|
588
589
|
var STABLE_WEBGPU_MATRIX_VERSION = "1.0.0";
|
|
@@ -592,12 +593,35 @@ var SUPPORTED_STABLE_WEBGPU_MATRIX_POLICIES = [
|
|
|
592
593
|
Object.freeze({
|
|
593
594
|
matrixId: "stable-webgpu",
|
|
594
595
|
matrixVersion: "2026-07-13",
|
|
595
|
-
matrixSha256: "
|
|
596
|
+
matrixSha256: "4620eca44fd03004ee7650cfe9fcf42934493611a5097da5525f71578980b016"
|
|
596
597
|
})
|
|
597
598
|
];
|
|
598
599
|
Object.freeze(SUPPORTED_STABLE_WEBGPU_MATRIX_POLICIES);
|
|
599
600
|
var SUPPORTED_ADDITIVE_WEBGPU_MATRIX_POLICIES = Object.freeze([]);
|
|
600
601
|
|
|
602
|
+
// src/asset-version.ts
|
|
603
|
+
var ASSET_VERSION_PATTERN = /^[0-9A-Za-z][0-9A-Za-z._-]{0,127}$/u;
|
|
604
|
+
var MUTABLE_VERSION_ALIASES = /* @__PURE__ */ new Set([
|
|
605
|
+
"latest",
|
|
606
|
+
"current",
|
|
607
|
+
"stable",
|
|
608
|
+
"preview",
|
|
609
|
+
"default",
|
|
610
|
+
"production",
|
|
611
|
+
"canary",
|
|
612
|
+
"next",
|
|
613
|
+
"head",
|
|
614
|
+
"main"
|
|
615
|
+
]);
|
|
616
|
+
var X_WILDCARD_SEGMENT_PATTERN = /^(?:[vV])?[xX](?:\.|-|$)|\.[xX](?:\.|-|$)/u;
|
|
617
|
+
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.";
|
|
618
|
+
function assertImmutableAssetVersion(value) {
|
|
619
|
+
if (typeof value !== "string" || !ASSET_VERSION_PATTERN.test(value) || MUTABLE_VERSION_ALIASES.has(value.toLowerCase()) || X_WILDCARD_SEGMENT_PATTERN.test(value)) {
|
|
620
|
+
throw new TypeError(IMMUTABLE_VERSION_ERROR_MESSAGE);
|
|
621
|
+
}
|
|
622
|
+
return value;
|
|
623
|
+
}
|
|
624
|
+
|
|
601
625
|
// src/requirements-validation.ts
|
|
602
626
|
var ENABLED_FEATURES = Object.freeze({
|
|
603
627
|
f16: "shader-f16",
|
|
@@ -925,6 +949,15 @@ function validateShaderDerivedRequirements(input) {
|
|
|
925
949
|
// src/manifest-validation.ts
|
|
926
950
|
var stages = ["vertex", "fragment", "compute"];
|
|
927
951
|
var roles = ["material", "lighting", "outline", "shadow", "post-processing"];
|
|
952
|
+
function detachedJson(value, path2) {
|
|
953
|
+
try {
|
|
954
|
+
return JSON.parse(canonicalizeGpuContract(value));
|
|
955
|
+
} catch (cause) {
|
|
956
|
+
const detail = cause instanceof Error ? cause.message : "Contract snapshot failed.";
|
|
957
|
+
const boundedDetail = [...detail].slice(0, 512).join("");
|
|
958
|
+
throw new TypeError(`${path2} must contain detached JSON contract data: ${boundedDetail}`, { cause });
|
|
959
|
+
}
|
|
960
|
+
}
|
|
928
961
|
function object(value, path2) {
|
|
929
962
|
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new TypeError(`${path2} must be an object.`);
|
|
930
963
|
return value;
|
|
@@ -945,6 +978,16 @@ function token(value, path2) {
|
|
|
945
978
|
if (!/^[A-Za-z0-9][A-Za-z0-9._:/-]*$/u.test(result) || result.includes("..")) throw new TypeError(`${path2} must be a safe token.`);
|
|
946
979
|
return result;
|
|
947
980
|
}
|
|
981
|
+
function immutableVersion(value, path2) {
|
|
982
|
+
try {
|
|
983
|
+
return assertImmutableAssetVersion(value);
|
|
984
|
+
} catch (cause) {
|
|
985
|
+
throw new TypeError(
|
|
986
|
+
`${path2} must be an immutable asset version: exact token required; mutable aliases, ranges, wildcards, and URLs are not allowed.`,
|
|
987
|
+
{ cause }
|
|
988
|
+
);
|
|
989
|
+
}
|
|
990
|
+
}
|
|
948
991
|
function enumeration(value, values, path2) {
|
|
949
992
|
if (!values.includes(value)) throw new TypeError(`${path2} is invalid.`);
|
|
950
993
|
return value;
|
|
@@ -1218,7 +1261,7 @@ function interfaceRef(value, path2) {
|
|
|
1218
1261
|
const input = object(value, path2);
|
|
1219
1262
|
exact(input, ["interfaceId", "interfaceVersion", "manifestUri", "manifestSha256", "interfaceAbiHash", "modelAbiHash"], path2);
|
|
1220
1263
|
token(input.interfaceId, `${path2}.interfaceId`);
|
|
1221
|
-
|
|
1264
|
+
immutableVersion(input.interfaceVersion, `${path2}.interfaceVersion`);
|
|
1222
1265
|
uri(input.manifestUri, `${path2}.manifestUri`);
|
|
1223
1266
|
digest(input.manifestSha256, `${path2}.manifestSha256`);
|
|
1224
1267
|
digest(input.interfaceAbiHash, `${path2}.interfaceAbiHash`);
|
|
@@ -1356,7 +1399,7 @@ function pipeline(value, path2, moduleIds) {
|
|
|
1356
1399
|
return input;
|
|
1357
1400
|
}
|
|
1358
1401
|
function parseSerializableGpuPipelineDescriptors(value, moduleIds, path2 = "pipelines") {
|
|
1359
|
-
const parsed = array(value, path2).map((item, index) => pipeline(item, `${path2}[${index}]`, new Set(moduleIds)));
|
|
1402
|
+
const parsed = array(detachedJson(value, path2), path2).map((item, index) => pipeline(item, `${path2}[${index}]`, new Set(moduleIds)));
|
|
1360
1403
|
unique(parsed, (item) => item.pipelineId, path2);
|
|
1361
1404
|
return freeze(parsed);
|
|
1362
1405
|
}
|
|
@@ -1364,7 +1407,7 @@ function compatibleModel(value, path2) {
|
|
|
1364
1407
|
const input = object(value, path2);
|
|
1365
1408
|
exact(input, ["interfaceId", "interfaceVersion", "manifestSha256", "interfaceAbiHash", "modelAbiHash"], path2);
|
|
1366
1409
|
token(input.interfaceId, `${path2}.interfaceId`);
|
|
1367
|
-
|
|
1410
|
+
immutableVersion(input.interfaceVersion, `${path2}.interfaceVersion`);
|
|
1368
1411
|
digest(input.manifestSha256, `${path2}.manifestSha256`);
|
|
1369
1412
|
digest(input.interfaceAbiHash, `${path2}.interfaceAbiHash`);
|
|
1370
1413
|
digest(input.modelAbiHash, `${path2}.modelAbiHash`);
|
|
@@ -1377,7 +1420,7 @@ function validationEvidenceRef(value, path2) {
|
|
|
1377
1420
|
uri(evidence.uri, `${path2}.uri`);
|
|
1378
1421
|
digest(evidence.sha256, `${path2}.sha256`);
|
|
1379
1422
|
token(evidence.matrixId, `${path2}.matrixId`);
|
|
1380
|
-
|
|
1423
|
+
immutableVersion(evidence.matrixVersion, `${path2}.matrixVersion`);
|
|
1381
1424
|
digest(evidence.matrixSha256, `${path2}.matrixSha256`);
|
|
1382
1425
|
const attestation = object(evidence.attestationRef, `${path2}.attestationRef`);
|
|
1383
1426
|
exact(attestation, ["uri", "sha256"], `${path2}.attestationRef`);
|
|
@@ -1404,11 +1447,11 @@ function reflectedRecordBindingSize(record) {
|
|
|
1404
1447
|
return Math.ceil(unrounded / record.alignment) * record.alignment;
|
|
1405
1448
|
}
|
|
1406
1449
|
function parseGpuInterfaceManifest(value) {
|
|
1407
|
-
const input = object(value, "GpuInterfaceManifest");
|
|
1450
|
+
const input = object(detachedJson(value, "GpuInterfaceManifest"), "GpuInterfaceManifest");
|
|
1408
1451
|
exact(input, ["contractVersion", "interfaceId", "interfaceVersion", "modules", "records", "bindings", "entryPoints", "vertexInputs", "overrides", "modelAbi", "modelAbiHash", "interfaceAbiHash", "generatedBy"], "GpuInterfaceManifest");
|
|
1409
1452
|
if (input.contractVersion !== GPU_INTERFACE_MANIFEST_VERSION) throw new TypeError("Unsupported GPU interface contract version.");
|
|
1410
1453
|
token(input.interfaceId, "GpuInterfaceManifest.interfaceId");
|
|
1411
|
-
|
|
1454
|
+
immutableVersion(input.interfaceVersion, "GpuInterfaceManifest.interfaceVersion");
|
|
1412
1455
|
const moduleValues = array(input.modules, "GpuInterfaceManifest.modules");
|
|
1413
1456
|
if (moduleValues.length === 0) throw new TypeError("GpuInterfaceManifest.modules must not be empty.");
|
|
1414
1457
|
const moduleIds = moduleValues.map((value2, index) => {
|
|
@@ -1590,11 +1633,11 @@ function parseGpuInterfaceManifest(value) {
|
|
|
1590
1633
|
return freeze(input);
|
|
1591
1634
|
}
|
|
1592
1635
|
function parseShaderVersionManifest(value) {
|
|
1593
|
-
const input = object(value, "ShaderVersionManifest");
|
|
1636
|
+
const input = object(detachedJson(value, "ShaderVersionManifest"), "ShaderVersionManifest");
|
|
1594
1637
|
exact(input, ["contractVersion", "shaderId", "version", "modules", "gpuInterface", "pipelines", "renderRoles", "compatibleModelInterfaces", "requirements", "shaderAbiHash", "validationEvidence", "additionalValidationEvidence"], "ShaderVersionManifest");
|
|
1595
1638
|
if (input.contractVersion !== SHADER_VERSION_MANIFEST_VERSION) throw new TypeError("Unsupported shader manifest contract version.");
|
|
1596
1639
|
token(input.shaderId, "ShaderVersionManifest.shaderId");
|
|
1597
|
-
|
|
1640
|
+
immutableVersion(input.version, "ShaderVersionManifest.version");
|
|
1598
1641
|
const moduleValues = array(input.modules, "ShaderVersionManifest.modules");
|
|
1599
1642
|
if (moduleValues.length === 0) throw new TypeError("ShaderVersionManifest.modules must not be empty.");
|
|
1600
1643
|
const moduleIds = moduleValues.map((item, index) => {
|
|
@@ -1707,7 +1750,7 @@ function parseShaderVersionManifest(value) {
|
|
|
1707
1750
|
return freeze(input);
|
|
1708
1751
|
}
|
|
1709
1752
|
function parseShaderVersionManifestCore(value) {
|
|
1710
|
-
const input = object(value, "ShaderVersionManifestCore");
|
|
1753
|
+
const input = object(detachedJson(value, "ShaderVersionManifestCore"), "ShaderVersionManifestCore");
|
|
1711
1754
|
if ("validationEvidence" in input || "additionalValidationEvidence" in input) {
|
|
1712
1755
|
throw new TypeError("ShaderVersionManifestCore must not contain validationEvidence or additionalValidationEvidence.");
|
|
1713
1756
|
}
|
|
@@ -1732,11 +1775,59 @@ function parseShaderVersionManifestCore(value) {
|
|
|
1732
1775
|
void additionalValidationEvidence;
|
|
1733
1776
|
return freeze(core);
|
|
1734
1777
|
}
|
|
1778
|
+
function parseShaderStyleProfileManifest(value) {
|
|
1779
|
+
const input = object(detachedJson(value, "ShaderStyleProfileManifest"), "ShaderStyleProfileManifest");
|
|
1780
|
+
exact(input, ["contractVersion", "profileId", "version", "style", "roles", "compatibleModelInterfaces", "requiredSemantics", "requiredValidationScopes"], "ShaderStyleProfileManifest");
|
|
1781
|
+
if (input.contractVersion !== SHADER_STYLE_PROFILE_MANIFEST_VERSION) throw new TypeError("Unsupported style-profile contract version.");
|
|
1782
|
+
token(input.profileId, "ShaderStyleProfileManifest.profileId");
|
|
1783
|
+
immutableVersion(input.version, "ShaderStyleProfileManifest.version");
|
|
1784
|
+
token(input.style, "ShaderStyleProfileManifest.style");
|
|
1785
|
+
const roleValues = array(input.roles, "ShaderStyleProfileManifest.roles", 5);
|
|
1786
|
+
if (roleValues.length === 0) throw new TypeError("ShaderStyleProfileManifest.roles must not be empty.");
|
|
1787
|
+
const roleNames = [];
|
|
1788
|
+
roleValues.forEach((item, index) => {
|
|
1789
|
+
const path2 = `ShaderStyleProfileManifest.roles[${index}]`;
|
|
1790
|
+
const role = object(item, path2);
|
|
1791
|
+
exact(role, ["role", "shader"], path2);
|
|
1792
|
+
roleNames.push(enumeration(role.role, roles, `${path2}.role`));
|
|
1793
|
+
const shader = object(role.shader, `${path2}.shader`);
|
|
1794
|
+
exact(shader, ["shaderId", "version", "manifestUri", "manifestSha256"], `${path2}.shader`);
|
|
1795
|
+
token(shader.shaderId, `${path2}.shader.shaderId`);
|
|
1796
|
+
immutableVersion(shader.version, `${path2}.shader.version`);
|
|
1797
|
+
uri(shader.manifestUri, `${path2}.shader.manifestUri`);
|
|
1798
|
+
digest(shader.manifestSha256, `${path2}.shader.manifestSha256`);
|
|
1799
|
+
});
|
|
1800
|
+
unique(roleNames, String, "ShaderStyleProfileManifest.roles");
|
|
1801
|
+
const compatible = array(input.compatibleModelInterfaces, "ShaderStyleProfileManifest.compatibleModelInterfaces").map((item, index) => compatibleModel(item, `ShaderStyleProfileManifest.compatibleModelInterfaces[${index}]`));
|
|
1802
|
+
if (compatible.length === 0) throw new TypeError("ShaderStyleProfileManifest.compatibleModelInterfaces must not be empty.");
|
|
1803
|
+
unique(compatible, (item) => `${item.interfaceId}:${item.interfaceVersion}:${item.manifestSha256}:${item.interfaceAbiHash}:${item.modelAbiHash}`, "ShaderStyleProfileManifest.compatibleModelInterfaces");
|
|
1804
|
+
tokenArray(input.requiredSemantics, "ShaderStyleProfileManifest.requiredSemantics");
|
|
1805
|
+
const requiredValidationScopes = array(input.requiredValidationScopes, "ShaderStyleProfileManifest.requiredValidationScopes").map((item, index) => {
|
|
1806
|
+
const path2 = `ShaderStyleProfileManifest.requiredValidationScopes[${index}]`;
|
|
1807
|
+
const requirement = object(item, path2);
|
|
1808
|
+
exact(requirement, ["scope", "matrixId", "matrixVersion", "matrixSha256"], path2);
|
|
1809
|
+
const scope = token(requirement.scope, `${path2}.scope`);
|
|
1810
|
+
if (scope === "universal") throw new TypeError(`${path2}.scope must not use the reserved universal scope.`);
|
|
1811
|
+
token(requirement.matrixId, `${path2}.matrixId`);
|
|
1812
|
+
immutableVersion(requirement.matrixVersion, `${path2}.matrixVersion`);
|
|
1813
|
+
const matrixSha256 = digest(requirement.matrixSha256, `${path2}.matrixSha256`);
|
|
1814
|
+
if (SUPPORTED_STABLE_WEBGPU_MATRIX_POLICIES.some((policy) => policy.matrixSha256 === matrixSha256)) {
|
|
1815
|
+
throw new TypeError(`${path2} must require an additive matrix policy, not the universal matrix policy.`);
|
|
1816
|
+
}
|
|
1817
|
+
if (!SUPPORTED_ADDITIVE_WEBGPU_MATRIX_POLICIES.some((policy) => scope === policy.scope && requirement.matrixId === policy.matrixId && requirement.matrixVersion === policy.matrixVersion && matrixSha256 === policy.matrixSha256)) {
|
|
1818
|
+
throw new TypeError(`${path2} is not a supported additive WebGPU matrix policy.`);
|
|
1819
|
+
}
|
|
1820
|
+
return requirement;
|
|
1821
|
+
});
|
|
1822
|
+
unique(requiredValidationScopes, (item) => String(item.scope), "ShaderStyleProfileManifest.requiredValidationScopes scopes");
|
|
1823
|
+
unique(requiredValidationScopes, (item) => String(item.matrixSha256), "ShaderStyleProfileManifest.requiredValidationScopes matrix policies");
|
|
1824
|
+
return freeze(input);
|
|
1825
|
+
}
|
|
1735
1826
|
function parseModelGpuCompatibilityDescriptor(value) {
|
|
1736
|
-
const input = object(value, "ModelGpuCompatibilityDescriptor");
|
|
1827
|
+
const input = object(detachedJson(value, "ModelGpuCompatibilityDescriptor"), "ModelGpuCompatibilityDescriptor");
|
|
1737
1828
|
exact(input, ["modelId", "version", "gpuInterface", "modelAbiHash", "providedSemantics", "defaultStyleProfile"], "ModelGpuCompatibilityDescriptor");
|
|
1738
1829
|
token(input.modelId, "ModelGpuCompatibilityDescriptor.modelId");
|
|
1739
|
-
|
|
1830
|
+
immutableVersion(input.version, "ModelGpuCompatibilityDescriptor.version");
|
|
1740
1831
|
const gpuInterface = interfaceRef(input.gpuInterface, "ModelGpuCompatibilityDescriptor.gpuInterface");
|
|
1741
1832
|
const modelAbiHash = digest(input.modelAbiHash, "ModelGpuCompatibilityDescriptor.modelAbiHash");
|
|
1742
1833
|
if (gpuInterface.modelAbiHash !== modelAbiHash) throw new TypeError("ModelGpuCompatibilityDescriptor.gpuInterface.modelAbiHash differs from modelAbiHash.");
|
|
@@ -1745,14 +1836,17 @@ function parseModelGpuCompatibilityDescriptor(value) {
|
|
|
1745
1836
|
const profile = object(input.defaultStyleProfile, "ModelGpuCompatibilityDescriptor.defaultStyleProfile");
|
|
1746
1837
|
exact(profile, ["profileId", "version", "manifestUri", "manifestSha256"], "ModelGpuCompatibilityDescriptor.defaultStyleProfile");
|
|
1747
1838
|
token(profile.profileId, "ModelGpuCompatibilityDescriptor.defaultStyleProfile.profileId");
|
|
1748
|
-
|
|
1839
|
+
immutableVersion(profile.version, "ModelGpuCompatibilityDescriptor.defaultStyleProfile.version");
|
|
1749
1840
|
uri(profile.manifestUri, "ModelGpuCompatibilityDescriptor.defaultStyleProfile.manifestUri");
|
|
1750
1841
|
digest(profile.manifestSha256, "ModelGpuCompatibilityDescriptor.defaultStyleProfile.manifestSha256");
|
|
1751
1842
|
}
|
|
1752
1843
|
return freeze(input);
|
|
1753
1844
|
}
|
|
1754
1845
|
function parseShaderQualificationModelCompatibilityFixture(value) {
|
|
1755
|
-
const input = object(
|
|
1846
|
+
const input = object(
|
|
1847
|
+
detachedJson(value, "ShaderQualificationModelCompatibilityFixture"),
|
|
1848
|
+
"ShaderQualificationModelCompatibilityFixture"
|
|
1849
|
+
);
|
|
1756
1850
|
exact(input, ["contractVersion", "fixtureId", "model"], "ShaderQualificationModelCompatibilityFixture");
|
|
1757
1851
|
if (input.contractVersion !== SHADER_QUALIFICATION_FIXTURE_VERSION) throw new TypeError("Unsupported model compatibility fixture version.");
|
|
1758
1852
|
token(input.fixtureId, "ShaderQualificationModelCompatibilityFixture.fixtureId");
|
|
@@ -1768,6 +1862,11 @@ function issue(code, message, path2) {
|
|
|
1768
1862
|
function object2(value) {
|
|
1769
1863
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
|
|
1770
1864
|
}
|
|
1865
|
+
function freezeJson(value) {
|
|
1866
|
+
if (typeof value !== "object" || value === null || Object.isFrozen(value)) return value;
|
|
1867
|
+
for (const child of Object.values(value)) freezeJson(child);
|
|
1868
|
+
return Object.freeze(value);
|
|
1869
|
+
}
|
|
1771
1870
|
function exactKeys(value, keys2) {
|
|
1772
1871
|
const expected = new Set(keys2);
|
|
1773
1872
|
return Object.keys(value).every((key) => expected.has(key)) && keys2.every((key) => key in value);
|
|
@@ -1775,6 +1874,14 @@ function exactKeys(value, keys2) {
|
|
|
1775
1874
|
function safeToken(value) {
|
|
1776
1875
|
return typeof value === "string" && /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,159}$/u.test(value) && !value.includes("..");
|
|
1777
1876
|
}
|
|
1877
|
+
function immutableVersion2(value) {
|
|
1878
|
+
try {
|
|
1879
|
+
assertImmutableAssetVersion(value);
|
|
1880
|
+
return true;
|
|
1881
|
+
} catch {
|
|
1882
|
+
return false;
|
|
1883
|
+
}
|
|
1884
|
+
}
|
|
1778
1885
|
function validSha(value) {
|
|
1779
1886
|
try {
|
|
1780
1887
|
asSha256Hex(String(value));
|
|
@@ -1784,8 +1891,20 @@ function validSha(value) {
|
|
|
1784
1891
|
}
|
|
1785
1892
|
}
|
|
1786
1893
|
function validateCompileUnitInventory(value) {
|
|
1787
|
-
|
|
1788
|
-
|
|
1894
|
+
let snapshot;
|
|
1895
|
+
try {
|
|
1896
|
+
snapshot = JSON.parse(canonicalizeGpuContract(value));
|
|
1897
|
+
} catch (cause) {
|
|
1898
|
+
return {
|
|
1899
|
+
ok: false,
|
|
1900
|
+
diagnostics: [issue(
|
|
1901
|
+
"invalid-contract",
|
|
1902
|
+
cause instanceof Error ? cause.message : "Compile-unit inventory must contain detached JSON data."
|
|
1903
|
+
)]
|
|
1904
|
+
};
|
|
1905
|
+
}
|
|
1906
|
+
const envelope = object2(snapshot);
|
|
1907
|
+
const candidate = envelope && Object.hasOwn(envelope, "inventory") ? object2(snapshot.inventory) : envelope;
|
|
1789
1908
|
const diagnostics = [];
|
|
1790
1909
|
if (!candidate || !exactKeys(candidate, ["contractVersion", "fragments", "compileUnits"])) {
|
|
1791
1910
|
return { ok: false, diagnostics: [issue("invalid-contract", "Compile-unit inventory has unknown or missing fields.")] };
|
|
@@ -1916,7 +2035,7 @@ function validateCompileUnitInventory(value) {
|
|
|
1916
2035
|
diagnostics.push(issue("invalid-contract", cause instanceof Error ? cause.message : "Compile-unit pipelines are invalid.", `${path2}.pipelines`));
|
|
1917
2036
|
}
|
|
1918
2037
|
const interfaceRef2 = object2(unit.interfaceRef);
|
|
1919
|
-
if (!interfaceRef2 || !exactKeys(interfaceRef2, ["interfaceId", "interfaceVersion", "manifestUri", "manifestSha256", "interfaceAbiHash", "modelAbiHash"]) || !safeToken(interfaceRef2.interfaceId) || !
|
|
2038
|
+
if (!interfaceRef2 || !exactKeys(interfaceRef2, ["interfaceId", "interfaceVersion", "manifestUri", "manifestSha256", "interfaceAbiHash", "modelAbiHash"]) || !safeToken(interfaceRef2.interfaceId) || !immutableVersion2(interfaceRef2.interfaceVersion) || typeof interfaceRef2.manifestUri !== "string" || !interfaceRef2.manifestUri.startsWith("https://") || !validSha(interfaceRef2.manifestSha256) || !validSha(interfaceRef2.interfaceAbiHash) || !validSha(interfaceRef2.modelAbiHash)) {
|
|
1920
2039
|
diagnostics.push(issue("invalid-contract", "Compile-unit interfaceRef is invalid.", `${path2}.interfaceRef`));
|
|
1921
2040
|
}
|
|
1922
2041
|
const fixture = object2(unit.qualificationFixture);
|
|
@@ -1927,7 +2046,7 @@ function validateCompileUnitInventory(value) {
|
|
|
1927
2046
|
for (const fragmentId of fragmentIds) {
|
|
1928
2047
|
if (!covered.has(fragmentId)) diagnostics.push(issue("uncovered-fragment", `WGSL fragment ${fragmentId} has no compile unit.`));
|
|
1929
2048
|
}
|
|
1930
|
-
return diagnostics.length > 0 ? { ok: false, diagnostics } : { ok: true, value: candidate };
|
|
2049
|
+
return diagnostics.length > 0 ? { ok: false, diagnostics } : { ok: true, value: freezeJson(candidate) };
|
|
1931
2050
|
}
|
|
1932
2051
|
|
|
1933
2052
|
// src/testing/qualification-bundle.ts
|
|
@@ -2019,6 +2138,18 @@ function object3(value, path2) {
|
|
|
2019
2138
|
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new TypeError(`${path2} must be an object.`);
|
|
2020
2139
|
return value;
|
|
2021
2140
|
}
|
|
2141
|
+
function detachedJson2(value, label) {
|
|
2142
|
+
try {
|
|
2143
|
+
return JSON.parse(canonicalizeGpuContract(value));
|
|
2144
|
+
} catch (cause) {
|
|
2145
|
+
throw new TypeError(`${label} must contain detached JSON contract data.`, { cause });
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
function freezeJson2(value) {
|
|
2149
|
+
if (typeof value !== "object" || value === null || Object.isFrozen(value)) return value;
|
|
2150
|
+
for (const child of Object.values(value)) freezeJson2(child);
|
|
2151
|
+
return Object.freeze(value);
|
|
2152
|
+
}
|
|
2022
2153
|
function exact2(value, keys2, path2) {
|
|
2023
2154
|
const expected = new Set(keys2);
|
|
2024
2155
|
if (!Object.keys(value).every((key) => expected.has(key)) || !keys2.every((key) => key in value)) throw new TypeError(`${path2} has unknown or missing fields.`);
|
|
@@ -2027,6 +2158,16 @@ function token2(value, path2) {
|
|
|
2027
2158
|
if (typeof value !== "string" || !TOKEN.test(value) || value.includes("..")) throw new TypeError(`${path2} must be a safe token.`);
|
|
2028
2159
|
return value;
|
|
2029
2160
|
}
|
|
2161
|
+
function immutableVersion3(value, path2) {
|
|
2162
|
+
try {
|
|
2163
|
+
return assertImmutableAssetVersion(value);
|
|
2164
|
+
} catch (cause) {
|
|
2165
|
+
throw new TypeError(
|
|
2166
|
+
`${path2} must be an immutable asset version: exact token required; mutable aliases, ranges, wildcards, and URLs are not allowed.`,
|
|
2167
|
+
{ cause }
|
|
2168
|
+
);
|
|
2169
|
+
}
|
|
2170
|
+
}
|
|
2030
2171
|
function path(value, label, extensions) {
|
|
2031
2172
|
if (typeof value !== "string" || !SAFE_PATH2.test(value) || !extensions.some((extension) => value.endsWith(extension))) {
|
|
2032
2173
|
throw new TypeError(`${label} must be a safe data-only bundle path (${extensions.join(", ")}).`);
|
|
@@ -2161,7 +2302,7 @@ function jsonValue(value, label, depth = 0) {
|
|
|
2161
2302
|
}
|
|
2162
2303
|
function validateQualificationFixture(value, unit) {
|
|
2163
2304
|
try {
|
|
2164
|
-
const fixture = object3(value, "fixture");
|
|
2305
|
+
const fixture = object3(detachedJson2(value, "fixture"), "fixture");
|
|
2165
2306
|
exact2(fixture, ["contractVersion", "fixtureId", "resources", "bindGroups", "commands", "layoutProbes", "readbacks", "bounds"], "fixture");
|
|
2166
2307
|
if (fixture.contractVersion !== SHADER_QUALIFICATION_FIXTURE_VERSION) throw new TypeError("Unsupported qualification fixture version.");
|
|
2167
2308
|
token2(fixture.fixtureId, "fixture.fixtureId");
|
|
@@ -2497,14 +2638,14 @@ function validateQualificationFixture(value, unit) {
|
|
|
2497
2638
|
}
|
|
2498
2639
|
unique2(probeIds, "fixture.layoutProbes probe IDs");
|
|
2499
2640
|
unique2(probeSources, "fixture.layoutProbes model sources");
|
|
2500
|
-
return { ok: true, value: fixture };
|
|
2641
|
+
return { ok: true, value: freezeJson2(fixture) };
|
|
2501
2642
|
} catch (cause) {
|
|
2502
2643
|
return { ok: false, diagnostics: [{ code: "invalid-contract", severity: "error", message: cause instanceof Error ? cause.message : "Invalid qualification fixture." }] };
|
|
2503
2644
|
}
|
|
2504
2645
|
}
|
|
2505
2646
|
function validateQualificationBundleManifest(value) {
|
|
2506
2647
|
try {
|
|
2507
|
-
const bundle = object3(value, "qualification");
|
|
2648
|
+
const bundle = object3(detachedJson2(value, "qualification"), "qualification");
|
|
2508
2649
|
exact2(bundle, ["contractVersion", "inventory", "subject", "shaderManifestCorePath", "gpuInterfaceManifest", "modelCompatibilityFixtures", "modules", "fixtures"], "qualification");
|
|
2509
2650
|
if (bundle.contractVersion !== SHADER_QUALIFICATION_BUNDLE_VERSION) throw new TypeError("Unsupported qualification bundle version.");
|
|
2510
2651
|
const inventory = validateCompileUnitInventory(bundle.inventory);
|
|
@@ -2514,7 +2655,7 @@ function validateQualificationBundleManifest(value) {
|
|
|
2514
2655
|
const candidate = object3(subject.shaderManifestCore, "qualification.subject.shaderManifestCore");
|
|
2515
2656
|
exact2(candidate, ["shaderId", "version", "sha256"], "qualification.subject.shaderManifestCore");
|
|
2516
2657
|
token2(candidate.shaderId, "qualification.subject.shaderManifestCore.shaderId");
|
|
2517
|
-
|
|
2658
|
+
immutableVersion3(candidate.version, "qualification.subject.shaderManifestCore.version");
|
|
2518
2659
|
sha(candidate.sha256, "qualification.subject.shaderManifestCore.sha256");
|
|
2519
2660
|
path(bundle.shaderManifestCorePath, "qualification.shaderManifestCorePath", [".json"]);
|
|
2520
2661
|
const interfaceManifest = object3(bundle.gpuInterfaceManifest, "qualification.gpuInterfaceManifest");
|
|
@@ -2574,7 +2715,7 @@ function validateQualificationBundleManifest(value) {
|
|
|
2574
2715
|
const expectedUnits = [...inventory.value.compileUnits.map((unit) => unit.compileUnitId)].sort();
|
|
2575
2716
|
if (unitIds.join("\n") !== expectedUnits.join("\n")) throw new TypeError("Subject compile-unit IDs differ from inventory.");
|
|
2576
2717
|
orderedUniqueTokens(subject.requiredCellIds, "qualification.subject.requiredCellIds");
|
|
2577
|
-
return { ok: true, value: bundle };
|
|
2718
|
+
return { ok: true, value: freezeJson2(bundle) };
|
|
2578
2719
|
} catch (cause) {
|
|
2579
2720
|
return { ok: false, diagnostics: [{ code: "invalid-contract", severity: "error", message: cause instanceof Error ? cause.message : "Invalid qualification bundle." }] };
|
|
2580
2721
|
}
|
|
@@ -8703,7 +8844,7 @@ function validatePipelineInterfaces(input) {
|
|
|
8703
8844
|
// package.json
|
|
8704
8845
|
var package_default = {
|
|
8705
8846
|
name: "@plasius/gpu-shader",
|
|
8706
|
-
version: "0.1.
|
|
8847
|
+
version: "0.1.2",
|
|
8707
8848
|
description: "Reflection-first WebGPU WGSL interfaces, CPU codecs, compatibility validation, style profiles, and qualification tooling",
|
|
8708
8849
|
type: "module",
|
|
8709
8850
|
sideEffects: false,
|
|
@@ -10533,6 +10674,13 @@ function keys(value, expected) {
|
|
|
10533
10674
|
const set = new Set(expected);
|
|
10534
10675
|
return Object.keys(value).every((key) => set.has(key)) && expected.every((key) => key in value);
|
|
10535
10676
|
}
|
|
10677
|
+
function canonicalEqual2(left, right) {
|
|
10678
|
+
try {
|
|
10679
|
+
return canonicalizeGpuContract(left) === canonicalizeGpuContract(right);
|
|
10680
|
+
} catch {
|
|
10681
|
+
return false;
|
|
10682
|
+
}
|
|
10683
|
+
}
|
|
10536
10684
|
var browserNames = /* @__PURE__ */ new Set(["chromium", "chrome", "edge", "firefox", "safari"]);
|
|
10537
10685
|
var osNames = /* @__PURE__ */ new Set(["ubuntu", "windows", "macos", "chromeos", "android", "ios", "ipados", "visionos"]);
|
|
10538
10686
|
var backends = /* @__PURE__ */ new Set(["swiftshader", "d3d12", "metal", "vulkan"]);
|
|
@@ -10626,7 +10774,9 @@ function validateStableWebGpuMatrix(value) {
|
|
|
10626
10774
|
const kind = String(requirement?.kind);
|
|
10627
10775
|
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");
|
|
10628
10776
|
if (!validRequirement) diagnostics.push(issue3("OS version requirement is invalid.", `${path2}.os.versionRequirement`));
|
|
10629
|
-
if (typeof cell.cellId === "string" &&
|
|
10777
|
+
if (typeof cell.cellId === "string" && !canonicalEqual2(requirement, VERSION_REQUIREMENTS.get(cell.cellId))) {
|
|
10778
|
+
diagnostics.push(issue3("OS version requirement differs from the stable baseline.", `${path2}.os.versionRequirement`));
|
|
10779
|
+
}
|
|
10630
10780
|
}
|
|
10631
10781
|
if (!adapter || !keys(adapter, ["kind", "vendor", "family", "backend"]) || !["software", "physical"].includes(String(adapter.kind)) || !backends.has(String(adapter.backend))) diagnostics.push(issue3("Adapter descriptor is invalid.", `${path2}.adapter`));
|
|
10632
10782
|
if (!adapterAutomation || !keys(adapterAutomation, ["kind"]) || !automation.has(String(adapterAutomation.kind))) diagnostics.push(issue3("Automation descriptor is invalid.", `${path2}.automation`));
|
|
@@ -11661,7 +11811,7 @@ function createQualificationExecutionProducer(input) {
|
|
|
11661
11811
|
}
|
|
11662
11812
|
|
|
11663
11813
|
// src/testing/runner/identity.ts
|
|
11664
|
-
function
|
|
11814
|
+
function canonicalEqual3(left, right) {
|
|
11665
11815
|
return canonicalizeGpuContract(left) === canonicalizeGpuContract(right);
|
|
11666
11816
|
}
|
|
11667
11817
|
function required2(environment, name) {
|
|
@@ -11697,7 +11847,7 @@ async function validateTrustedCellIdentity(input) {
|
|
|
11697
11847
|
} catch (cause) {
|
|
11698
11848
|
throw new TypeError("Stable WebGPU matrix bytes are not UTF-8 JSON.", { cause });
|
|
11699
11849
|
}
|
|
11700
|
-
if (!
|
|
11850
|
+
if (!canonicalEqual3(parsedMatrix, input.matrix) || matrixSha256 !== input.preflight.matrixSha256) {
|
|
11701
11851
|
throw new TypeError("Exact stable WebGPU matrix artifact differs from qualification preflight evidence.");
|
|
11702
11852
|
}
|
|
11703
11853
|
if (input.preflight.contractVersion !== SHADER_VALIDATION_EVIDENCE_VERSION || input.preflight.kind !== "shader-qualification-preflight") throw new TypeError("Qualification preflight contract is unsupported.");
|
|
@@ -11726,7 +11876,7 @@ async function validateTrustedCellIdentity(input) {
|
|
|
11726
11876
|
environment
|
|
11727
11877
|
});
|
|
11728
11878
|
const runner = input.runnerPreflight;
|
|
11729
|
-
if (runner.contractVersion !== SHADER_VALIDATION_EVIDENCE_VERSION || runner.kind !== "shader-runner-cell-preflight-evidence" || runner.qualificationId !== input.preflight.qualificationId || runner.cellId !== input.cell.cellId || runner.status !== "available" || runner.matrixSha256 !== matrixSha256 || !
|
|
11879
|
+
if (runner.contractVersion !== SHADER_VALIDATION_EVIDENCE_VERSION || runner.kind !== "shader-runner-cell-preflight-evidence" || runner.qualificationId !== input.preflight.qualificationId || runner.cellId !== input.cell.cellId || runner.status !== "available" || runner.matrixSha256 !== matrixSha256 || !canonicalEqual3(runner.runnerLabels, input.cell.runnerLabels) || !canonicalEqual3(runner.qualificationPreflightProvenance, input.preflight.provenance) || !runner.matchedRunners.some((candidate) => {
|
|
11730
11880
|
const labels = new Set(candidate.labels.map((label) => label.toLocaleLowerCase("en-US")));
|
|
11731
11881
|
return candidate.name === executionProducer.runner.name && runner.runnerLabels.every((label) => labels.has(label.toLocaleLowerCase("en-US")));
|
|
11732
11882
|
})) {
|
|
@@ -11734,7 +11884,7 @@ async function validateTrustedCellIdentity(input) {
|
|
|
11734
11884
|
}
|
|
11735
11885
|
const selectorProducer = parseQualificationExecutionProducer(runner.producer, "runnerPreflight.producer");
|
|
11736
11886
|
const expectedSelectorJob = input.cell.adapter.kind === "software" ? "swiftshader" : "physical-runner-preflight";
|
|
11737
|
-
if (selectorProducer.job !== expectedSelectorJob || selectorProducer.repository !== input.preflight.provenance.repository || !
|
|
11887
|
+
if (selectorProducer.job !== expectedSelectorJob || selectorProducer.repository !== input.preflight.provenance.repository || !canonicalEqual3(selectorProducer.commit, input.preflight.provenance.commit) || selectorProducer.ref !== input.preflight.provenance.ref || selectorProducer.runId !== input.preflight.provenance.runId || selectorProducer.runAttempt !== input.preflight.provenance.runAttempt || selectorProducer.trustedWorkflowRef !== input.preflight.provenance.workflowRef || !canonicalEqual3(selectorProducer.trustedWorkflowSha, input.preflight.provenance.workflowSha)) {
|
|
11738
11888
|
throw new TypeError("Runner-preflight producer differs from the immutable qualification route.");
|
|
11739
11889
|
}
|
|
11740
11890
|
return executionProducer;
|
|
@@ -11751,7 +11901,7 @@ async function createHostedSwiftShaderRunnerPreflight(input) {
|
|
|
11751
11901
|
} catch (cause) {
|
|
11752
11902
|
throw new TypeError("Stable WebGPU matrix bytes are not UTF-8 JSON.", { cause });
|
|
11753
11903
|
}
|
|
11754
|
-
if (!
|
|
11904
|
+
if (!canonicalEqual3(parsedMatrix, input.matrix) || matrixSha256 !== input.preflight.matrixSha256) {
|
|
11755
11905
|
throw new TypeError("Hosted runner preflight matrix artifact differs from qualification preflight.");
|
|
11756
11906
|
}
|
|
11757
11907
|
assertTrustedPreflightEnvironment({ preflight: input.preflight, environment });
|
|
@@ -11761,7 +11911,7 @@ async function createHostedSwiftShaderRunnerPreflight(input) {
|
|
|
11761
11911
|
}
|
|
11762
11912
|
const observedHost = await observeTrustedRunnerHost(input.cell, { name: producer.runner.name, labels: [] });
|
|
11763
11913
|
const hostedLabels = [`${observedHost.os.name}-${observedHost.os.version}`];
|
|
11764
|
-
if (!
|
|
11914
|
+
if (!canonicalEqual3(hostedLabels, input.cell.runnerLabels)) {
|
|
11765
11915
|
throw new TypeError("Actual hosted runner image does not derive the fixed matrix scheduler label.");
|
|
11766
11916
|
}
|
|
11767
11917
|
let playwright;
|
|
@@ -11945,11 +12095,21 @@ function verifyReflectedLayoutProbeOutputs(input) {
|
|
|
11945
12095
|
|
|
11946
12096
|
// src/compatibility.ts
|
|
11947
12097
|
function error(code, message, path2) {
|
|
11948
|
-
|
|
12098
|
+
const bounded = [...message].map((character) => {
|
|
12099
|
+
const codePoint = character.codePointAt(0);
|
|
12100
|
+
return codePoint <= 31 || codePoint === 127 ? " " : character;
|
|
12101
|
+
}).slice(0, 512).join("");
|
|
12102
|
+
return { code, severity: "error", message: bounded, ...path2 ? { path: path2 } : {} };
|
|
11949
12103
|
}
|
|
11950
12104
|
function interfaceMatches(item, model) {
|
|
11951
12105
|
return item.interfaceId === model.gpuInterface.interfaceId && item.interfaceVersion === model.gpuInterface.interfaceVersion && item.manifestSha256 === model.gpuInterface.manifestSha256 && item.interfaceAbiHash === model.gpuInterface.interfaceAbiHash && item.modelAbiHash === model.modelAbiHash;
|
|
11952
12106
|
}
|
|
12107
|
+
function detachedContract(value) {
|
|
12108
|
+
return JSON.parse(canonicalizeGpuContract(value));
|
|
12109
|
+
}
|
|
12110
|
+
function hasValidationEvidence(value) {
|
|
12111
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && (Object.hasOwn(value, "validationEvidence") || Object.hasOwn(value, "additionalValidationEvidence"));
|
|
12112
|
+
}
|
|
11953
12113
|
function validateRequirements(shader, gpuInterface, model, capabilities, diagnostics) {
|
|
11954
12114
|
const semantics = new Set(model.providedSemantics);
|
|
11955
12115
|
const requiredSemantics = /* @__PURE__ */ new Set([
|
|
@@ -11988,7 +12148,31 @@ function validateRequirements(shader, gpuInterface, model, capabilities, diagnos
|
|
|
11988
12148
|
}
|
|
11989
12149
|
function validateModelShaderCompatibility(input) {
|
|
11990
12150
|
const diagnostics = [];
|
|
11991
|
-
|
|
12151
|
+
let model;
|
|
12152
|
+
let shader;
|
|
12153
|
+
let gpuInterface;
|
|
12154
|
+
let profile;
|
|
12155
|
+
let capabilities;
|
|
12156
|
+
try {
|
|
12157
|
+
const modelSnapshot = detachedContract(input.model);
|
|
12158
|
+
const shaderSnapshot = detachedContract(input.shader);
|
|
12159
|
+
const gpuInterfaceSnapshot = detachedContract(input.gpuInterface);
|
|
12160
|
+
const profileValue = input.profile;
|
|
12161
|
+
const profileSnapshot = profileValue === void 0 ? void 0 : detachedContract(profileValue);
|
|
12162
|
+
model = parseModelGpuCompatibilityDescriptor(modelSnapshot);
|
|
12163
|
+
shader = hasValidationEvidence(shaderSnapshot) ? parseShaderVersionManifest(shaderSnapshot) : parseShaderVersionManifestCore(shaderSnapshot);
|
|
12164
|
+
gpuInterface = parseGpuInterfaceManifest(gpuInterfaceSnapshot);
|
|
12165
|
+
profile = profileSnapshot === void 0 ? void 0 : parseShaderStyleProfileManifest(profileSnapshot);
|
|
12166
|
+
capabilities = input.capabilities;
|
|
12167
|
+
} catch (cause) {
|
|
12168
|
+
return {
|
|
12169
|
+
ok: false,
|
|
12170
|
+
diagnostics: [error(
|
|
12171
|
+
"invalid-contract",
|
|
12172
|
+
cause instanceof Error ? cause.message : "GPU compatibility contract snapshot failed."
|
|
12173
|
+
)]
|
|
12174
|
+
};
|
|
12175
|
+
}
|
|
11992
12176
|
try {
|
|
11993
12177
|
validateShaderInterfaceRequirements({ manifest: shader, gpuInterface });
|
|
11994
12178
|
} catch (cause) {
|
|
@@ -12018,7 +12202,15 @@ function validateModelShaderCompatibility(input) {
|
|
|
12018
12202
|
}
|
|
12019
12203
|
}
|
|
12020
12204
|
}
|
|
12021
|
-
|
|
12205
|
+
try {
|
|
12206
|
+
validateRequirements(shader, gpuInterface, model, capabilities, diagnostics);
|
|
12207
|
+
} catch (cause) {
|
|
12208
|
+
diagnostics.push(error(
|
|
12209
|
+
"invalid-contract",
|
|
12210
|
+
cause instanceof Error ? cause.message : "GPU capability snapshot validation failed.",
|
|
12211
|
+
"capabilities"
|
|
12212
|
+
));
|
|
12213
|
+
}
|
|
12022
12214
|
if (diagnostics.length > 0) return { ok: false, diagnostics };
|
|
12023
12215
|
return {
|
|
12024
12216
|
ok: true,
|
|
@@ -12031,7 +12223,7 @@ function validateModelShaderCompatibility(input) {
|
|
|
12031
12223
|
}
|
|
12032
12224
|
|
|
12033
12225
|
// src/testing/runner/reflection-proof.ts
|
|
12034
|
-
function
|
|
12226
|
+
function canonicalEqual4(left, right) {
|
|
12035
12227
|
return canonicalizeGpuContract(left) === canonicalizeGpuContract(right);
|
|
12036
12228
|
}
|
|
12037
12229
|
async function createTrustedReflectionProof(admitted) {
|
|
@@ -12060,12 +12252,12 @@ async function createTrustedReflectionProof(admitted) {
|
|
|
12060
12252
|
const usedPipelineIds = /* @__PURE__ */ new Set();
|
|
12061
12253
|
const assemblySha256ByUnit = /* @__PURE__ */ new Map();
|
|
12062
12254
|
for (const unit of admitted.manifest.inventory.compileUnits) {
|
|
12063
|
-
if (!
|
|
12255
|
+
if (!canonicalEqual4(unit.interfaceRef, admitted.shaderManifestCore.gpuInterface)) {
|
|
12064
12256
|
throw new TypeError(`Compile unit ${unit.compileUnitId} interface reference differs from the admitted shader core.`);
|
|
12065
12257
|
}
|
|
12066
12258
|
for (const pipeline2 of unit.pipelines) {
|
|
12067
12259
|
const declared = shaderPipelines.get(pipeline2.pipelineId);
|
|
12068
|
-
if (!declared || !
|
|
12260
|
+
if (!declared || !canonicalEqual4(declared, pipeline2)) {
|
|
12069
12261
|
throw new TypeError(`Compile unit ${unit.compileUnitId} pipeline ${pipeline2.pipelineId} differs from the admitted shader core.`);
|
|
12070
12262
|
}
|
|
12071
12263
|
usedPipelineIds.add(pipeline2.pipelineId);
|
|
@@ -12079,7 +12271,7 @@ async function createTrustedReflectionProof(admitted) {
|
|
|
12079
12271
|
constants.set(name, value);
|
|
12080
12272
|
}
|
|
12081
12273
|
}
|
|
12082
|
-
if (!
|
|
12274
|
+
if (!canonicalEqual4(Object.fromEntries([...constants.entries()].sort()), unit.overrideValues)) {
|
|
12083
12275
|
throw new TypeError(`Compile unit ${unit.compileUnitId} override set differs from its exact pipeline constants.`);
|
|
12084
12276
|
}
|
|
12085
12277
|
assemblySha256ByUnit.set(unit.compileUnitId, await computeSha256(canonicalizeGpuContract({
|
|
@@ -12105,7 +12297,7 @@ async function createTrustedReflectionProof(admitted) {
|
|
|
12105
12297
|
if (!compatibility.ok) throw new TypeError(compatibility.diagnostics.map((item) => item.message).join("; "));
|
|
12106
12298
|
compatibleHashes.add(model.modelAbiHash);
|
|
12107
12299
|
}
|
|
12108
|
-
if (!
|
|
12300
|
+
if (!canonicalEqual4([...compatibleHashes].sort(), [...admitted.manifest.subject.modelAbiHashes].sort())) {
|
|
12109
12301
|
throw new TypeError("Admitted model compatibility fixtures differ from the qualification subject ABI set.");
|
|
12110
12302
|
}
|
|
12111
12303
|
const reflectionSha256 = await computeSha256(canonicalizeGpuContract({
|
|
@@ -12139,7 +12331,7 @@ var BROWSER_PHASES = [
|
|
|
12139
12331
|
"bounded-execution",
|
|
12140
12332
|
"semantic-readback"
|
|
12141
12333
|
];
|
|
12142
|
-
function
|
|
12334
|
+
function canonicalEqual5(left, right) {
|
|
12143
12335
|
return canonicalizeGpuContract(left) === canonicalizeGpuContract(right);
|
|
12144
12336
|
}
|
|
12145
12337
|
function concrete(value, label) {
|
|
@@ -12170,7 +12362,7 @@ function validateObservation(input) {
|
|
|
12170
12362
|
throw new TypeError("Trusted WebGPU execution did not pass all eight browser phases in fixed order.");
|
|
12171
12363
|
}
|
|
12172
12364
|
const observed = result.observed;
|
|
12173
|
-
if (observed.runner.id !== runnerName || !
|
|
12365
|
+
if (observed.runner.id !== runnerName || !canonicalEqual5(observed.runner.labels, expectedRunner.labels)) {
|
|
12174
12366
|
throw new TypeError("Observed runner identity differs from API-verified runner preflight evidence.");
|
|
12175
12367
|
}
|
|
12176
12368
|
if (observed.os.name !== cell.os.name || observed.os.architecture !== cell.os.architecture || !versionMatches(cell, observed.os.version, observed.os.channel)) {
|
|
@@ -12256,7 +12448,7 @@ async function runTrustedQualificationCell(input) {
|
|
|
12256
12448
|
const apiRunner = input.runnerPreflight.matchedRunners.find((runner) => runner.name === producer.runner.name);
|
|
12257
12449
|
if (!apiRunner) throw new TypeError("Execution runner was not matched by runner preflight evidence.");
|
|
12258
12450
|
const host = await withinDeadline((input.observeHost ?? observeTrustedRunnerHost)(input.cell, apiRunner), deadline);
|
|
12259
|
-
if (host.runner.id !== producer.runner.name || !
|
|
12451
|
+
if (host.runner.id !== producer.runner.name || !canonicalEqual5(host.runner.labels, apiRunner.labels)) {
|
|
12260
12452
|
throw new TypeError("Observed controller runner differs from API-verified preflight evidence.");
|
|
12261
12453
|
}
|
|
12262
12454
|
const packageMetadata = await withinDeadline(readTrustedHarnessPackageMetadata(), deadline);
|
|
@@ -12264,7 +12456,7 @@ async function runTrustedQualificationCell(input) {
|
|
|
12264
12456
|
input.adapterFactory ?? defaultTrustedQualificationAdapterFactory,
|
|
12265
12457
|
input.cell
|
|
12266
12458
|
), deadline);
|
|
12267
|
-
if (input.runnerPreflight.adapterHarness !== null && !
|
|
12459
|
+
if (input.runnerPreflight.adapterHarness !== null && !canonicalEqual5(
|
|
12268
12460
|
{ id: adapter.automation.driver, version: adapter.automation.version, sha256: adapter.automation.sha256 },
|
|
12269
12461
|
input.runnerPreflight.adapterHarness
|
|
12270
12462
|
)) {
|