@plasius/gpu-shader 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -592,7 +592,7 @@ var SUPPORTED_STABLE_WEBGPU_MATRIX_POLICIES = [
592
592
  Object.freeze({
593
593
  matrixId: "stable-webgpu",
594
594
  matrixVersion: "2026-07-13",
595
- matrixSha256: "9b47ff8162b055d49e38c4fe90b9074992ab8c9e1125926e936f8122e6119fd8"
595
+ matrixSha256: "4620eca44fd03004ee7650cfe9fcf42934493611a5097da5525f71578980b016"
596
596
  })
597
597
  ];
598
598
  Object.freeze(SUPPORTED_STABLE_WEBGPU_MATRIX_POLICIES);
@@ -8703,7 +8703,7 @@ function validatePipelineInterfaces(input) {
8703
8703
  // package.json
8704
8704
  var package_default = {
8705
8705
  name: "@plasius/gpu-shader",
8706
- version: "0.1.0",
8706
+ version: "0.1.1",
8707
8707
  description: "Reflection-first WebGPU WGSL interfaces, CPU codecs, compatibility validation, style profiles, and qualification tooling",
8708
8708
  type: "module",
8709
8709
  sideEffects: false,
@@ -10533,6 +10533,13 @@ function keys(value, expected) {
10533
10533
  const set = new Set(expected);
10534
10534
  return Object.keys(value).every((key) => set.has(key)) && expected.every((key) => key in value);
10535
10535
  }
10536
+ function canonicalEqual2(left, right) {
10537
+ try {
10538
+ return canonicalizeGpuContract(left) === canonicalizeGpuContract(right);
10539
+ } catch {
10540
+ return false;
10541
+ }
10542
+ }
10536
10543
  var browserNames = /* @__PURE__ */ new Set(["chromium", "chrome", "edge", "firefox", "safari"]);
10537
10544
  var osNames = /* @__PURE__ */ new Set(["ubuntu", "windows", "macos", "chromeos", "android", "ios", "ipados", "visionos"]);
10538
10545
  var backends = /* @__PURE__ */ new Set(["swiftshader", "d3d12", "metal", "vulkan"]);
@@ -10626,7 +10633,9 @@ function validateStableWebGpuMatrix(value) {
10626
10633
  const kind = String(requirement?.kind);
10627
10634
  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
10635
  if (!validRequirement) diagnostics.push(issue3("OS version requirement is invalid.", `${path2}.os.versionRequirement`));
10629
- if (typeof cell.cellId === "string" && JSON.stringify(requirement) !== JSON.stringify(VERSION_REQUIREMENTS.get(cell.cellId))) diagnostics.push(issue3("OS version requirement differs from the stable baseline.", `${path2}.os.versionRequirement`));
10636
+ if (typeof cell.cellId === "string" && !canonicalEqual2(requirement, VERSION_REQUIREMENTS.get(cell.cellId))) {
10637
+ diagnostics.push(issue3("OS version requirement differs from the stable baseline.", `${path2}.os.versionRequirement`));
10638
+ }
10630
10639
  }
10631
10640
  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
10641
  if (!adapterAutomation || !keys(adapterAutomation, ["kind"]) || !automation.has(String(adapterAutomation.kind))) diagnostics.push(issue3("Automation descriptor is invalid.", `${path2}.automation`));
@@ -11661,7 +11670,7 @@ function createQualificationExecutionProducer(input) {
11661
11670
  }
11662
11671
 
11663
11672
  // src/testing/runner/identity.ts
11664
- function canonicalEqual2(left, right) {
11673
+ function canonicalEqual3(left, right) {
11665
11674
  return canonicalizeGpuContract(left) === canonicalizeGpuContract(right);
11666
11675
  }
11667
11676
  function required2(environment, name) {
@@ -11697,7 +11706,7 @@ async function validateTrustedCellIdentity(input) {
11697
11706
  } catch (cause) {
11698
11707
  throw new TypeError("Stable WebGPU matrix bytes are not UTF-8 JSON.", { cause });
11699
11708
  }
11700
- if (!canonicalEqual2(parsedMatrix, input.matrix) || matrixSha256 !== input.preflight.matrixSha256) {
11709
+ if (!canonicalEqual3(parsedMatrix, input.matrix) || matrixSha256 !== input.preflight.matrixSha256) {
11701
11710
  throw new TypeError("Exact stable WebGPU matrix artifact differs from qualification preflight evidence.");
11702
11711
  }
11703
11712
  if (input.preflight.contractVersion !== SHADER_VALIDATION_EVIDENCE_VERSION || input.preflight.kind !== "shader-qualification-preflight") throw new TypeError("Qualification preflight contract is unsupported.");
@@ -11726,7 +11735,7 @@ async function validateTrustedCellIdentity(input) {
11726
11735
  environment
11727
11736
  });
11728
11737
  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 || !canonicalEqual2(runner.runnerLabels, input.cell.runnerLabels) || !canonicalEqual2(runner.qualificationPreflightProvenance, input.preflight.provenance) || !runner.matchedRunners.some((candidate) => {
11738
+ 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
11739
  const labels = new Set(candidate.labels.map((label) => label.toLocaleLowerCase("en-US")));
11731
11740
  return candidate.name === executionProducer.runner.name && runner.runnerLabels.every((label) => labels.has(label.toLocaleLowerCase("en-US")));
11732
11741
  })) {
@@ -11734,7 +11743,7 @@ async function validateTrustedCellIdentity(input) {
11734
11743
  }
11735
11744
  const selectorProducer = parseQualificationExecutionProducer(runner.producer, "runnerPreflight.producer");
11736
11745
  const expectedSelectorJob = input.cell.adapter.kind === "software" ? "swiftshader" : "physical-runner-preflight";
11737
- if (selectorProducer.job !== expectedSelectorJob || selectorProducer.repository !== input.preflight.provenance.repository || !canonicalEqual2(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 || !canonicalEqual2(selectorProducer.trustedWorkflowSha, input.preflight.provenance.workflowSha)) {
11746
+ 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
11747
  throw new TypeError("Runner-preflight producer differs from the immutable qualification route.");
11739
11748
  }
11740
11749
  return executionProducer;
@@ -11751,7 +11760,7 @@ async function createHostedSwiftShaderRunnerPreflight(input) {
11751
11760
  } catch (cause) {
11752
11761
  throw new TypeError("Stable WebGPU matrix bytes are not UTF-8 JSON.", { cause });
11753
11762
  }
11754
- if (!canonicalEqual2(parsedMatrix, input.matrix) || matrixSha256 !== input.preflight.matrixSha256) {
11763
+ if (!canonicalEqual3(parsedMatrix, input.matrix) || matrixSha256 !== input.preflight.matrixSha256) {
11755
11764
  throw new TypeError("Hosted runner preflight matrix artifact differs from qualification preflight.");
11756
11765
  }
11757
11766
  assertTrustedPreflightEnvironment({ preflight: input.preflight, environment });
@@ -11761,7 +11770,7 @@ async function createHostedSwiftShaderRunnerPreflight(input) {
11761
11770
  }
11762
11771
  const observedHost = await observeTrustedRunnerHost(input.cell, { name: producer.runner.name, labels: [] });
11763
11772
  const hostedLabels = [`${observedHost.os.name}-${observedHost.os.version}`];
11764
- if (!canonicalEqual2(hostedLabels, input.cell.runnerLabels)) {
11773
+ if (!canonicalEqual3(hostedLabels, input.cell.runnerLabels)) {
11765
11774
  throw new TypeError("Actual hosted runner image does not derive the fixed matrix scheduler label.");
11766
11775
  }
11767
11776
  let playwright;
@@ -12031,7 +12040,7 @@ function validateModelShaderCompatibility(input) {
12031
12040
  }
12032
12041
 
12033
12042
  // src/testing/runner/reflection-proof.ts
12034
- function canonicalEqual3(left, right) {
12043
+ function canonicalEqual4(left, right) {
12035
12044
  return canonicalizeGpuContract(left) === canonicalizeGpuContract(right);
12036
12045
  }
12037
12046
  async function createTrustedReflectionProof(admitted) {
@@ -12060,12 +12069,12 @@ async function createTrustedReflectionProof(admitted) {
12060
12069
  const usedPipelineIds = /* @__PURE__ */ new Set();
12061
12070
  const assemblySha256ByUnit = /* @__PURE__ */ new Map();
12062
12071
  for (const unit of admitted.manifest.inventory.compileUnits) {
12063
- if (!canonicalEqual3(unit.interfaceRef, admitted.shaderManifestCore.gpuInterface)) {
12072
+ if (!canonicalEqual4(unit.interfaceRef, admitted.shaderManifestCore.gpuInterface)) {
12064
12073
  throw new TypeError(`Compile unit ${unit.compileUnitId} interface reference differs from the admitted shader core.`);
12065
12074
  }
12066
12075
  for (const pipeline2 of unit.pipelines) {
12067
12076
  const declared = shaderPipelines.get(pipeline2.pipelineId);
12068
- if (!declared || !canonicalEqual3(declared, pipeline2)) {
12077
+ if (!declared || !canonicalEqual4(declared, pipeline2)) {
12069
12078
  throw new TypeError(`Compile unit ${unit.compileUnitId} pipeline ${pipeline2.pipelineId} differs from the admitted shader core.`);
12070
12079
  }
12071
12080
  usedPipelineIds.add(pipeline2.pipelineId);
@@ -12079,7 +12088,7 @@ async function createTrustedReflectionProof(admitted) {
12079
12088
  constants.set(name, value);
12080
12089
  }
12081
12090
  }
12082
- if (!canonicalEqual3(Object.fromEntries([...constants.entries()].sort()), unit.overrideValues)) {
12091
+ if (!canonicalEqual4(Object.fromEntries([...constants.entries()].sort()), unit.overrideValues)) {
12083
12092
  throw new TypeError(`Compile unit ${unit.compileUnitId} override set differs from its exact pipeline constants.`);
12084
12093
  }
12085
12094
  assemblySha256ByUnit.set(unit.compileUnitId, await computeSha256(canonicalizeGpuContract({
@@ -12105,7 +12114,7 @@ async function createTrustedReflectionProof(admitted) {
12105
12114
  if (!compatibility.ok) throw new TypeError(compatibility.diagnostics.map((item) => item.message).join("; "));
12106
12115
  compatibleHashes.add(model.modelAbiHash);
12107
12116
  }
12108
- if (!canonicalEqual3([...compatibleHashes].sort(), [...admitted.manifest.subject.modelAbiHashes].sort())) {
12117
+ if (!canonicalEqual4([...compatibleHashes].sort(), [...admitted.manifest.subject.modelAbiHashes].sort())) {
12109
12118
  throw new TypeError("Admitted model compatibility fixtures differ from the qualification subject ABI set.");
12110
12119
  }
12111
12120
  const reflectionSha256 = await computeSha256(canonicalizeGpuContract({
@@ -12139,7 +12148,7 @@ var BROWSER_PHASES = [
12139
12148
  "bounded-execution",
12140
12149
  "semantic-readback"
12141
12150
  ];
12142
- function canonicalEqual4(left, right) {
12151
+ function canonicalEqual5(left, right) {
12143
12152
  return canonicalizeGpuContract(left) === canonicalizeGpuContract(right);
12144
12153
  }
12145
12154
  function concrete(value, label) {
@@ -12170,7 +12179,7 @@ function validateObservation(input) {
12170
12179
  throw new TypeError("Trusted WebGPU execution did not pass all eight browser phases in fixed order.");
12171
12180
  }
12172
12181
  const observed = result.observed;
12173
- if (observed.runner.id !== runnerName || !canonicalEqual4(observed.runner.labels, expectedRunner.labels)) {
12182
+ if (observed.runner.id !== runnerName || !canonicalEqual5(observed.runner.labels, expectedRunner.labels)) {
12174
12183
  throw new TypeError("Observed runner identity differs from API-verified runner preflight evidence.");
12175
12184
  }
12176
12185
  if (observed.os.name !== cell.os.name || observed.os.architecture !== cell.os.architecture || !versionMatches(cell, observed.os.version, observed.os.channel)) {
@@ -12256,7 +12265,7 @@ async function runTrustedQualificationCell(input) {
12256
12265
  const apiRunner = input.runnerPreflight.matchedRunners.find((runner) => runner.name === producer.runner.name);
12257
12266
  if (!apiRunner) throw new TypeError("Execution runner was not matched by runner preflight evidence.");
12258
12267
  const host = await withinDeadline((input.observeHost ?? observeTrustedRunnerHost)(input.cell, apiRunner), deadline);
12259
- if (host.runner.id !== producer.runner.name || !canonicalEqual4(host.runner.labels, apiRunner.labels)) {
12268
+ if (host.runner.id !== producer.runner.name || !canonicalEqual5(host.runner.labels, apiRunner.labels)) {
12260
12269
  throw new TypeError("Observed controller runner differs from API-verified preflight evidence.");
12261
12270
  }
12262
12271
  const packageMetadata = await withinDeadline(readTrustedHarnessPackageMetadata(), deadline);
@@ -12264,7 +12273,7 @@ async function runTrustedQualificationCell(input) {
12264
12273
  input.adapterFactory ?? defaultTrustedQualificationAdapterFactory,
12265
12274
  input.cell
12266
12275
  ), deadline);
12267
- if (input.runnerPreflight.adapterHarness !== null && !canonicalEqual4(
12276
+ if (input.runnerPreflight.adapterHarness !== null && !canonicalEqual5(
12268
12277
  { id: adapter.automation.driver, version: adapter.automation.version, sha256: adapter.automation.sha256 },
12269
12278
  input.runnerPreflight.adapterHarness
12270
12279
  )) {