@plasius/gpu-shader 0.1.2 → 0.1.4

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/node.cjs CHANGED
@@ -5796,63 +5796,217 @@ var cn;
5796
5796
  var ln = { [cn.ExpensiveBuiltinInLoop]: "expensive-builtin-in-loop", [cn.CostlyArithmeticInLoop]: "costly-arithmetic-in-loop", [cn.LoopInvariantExpression]: "loop-invariant-expression", [cn.AtomicInLoop]: "atomic-in-loop", [cn.BarrierInLoop]: "barrier-in-loop", [cn.AtomicStorageRead]: "atomic-storage-read", [cn.WorkgroupArrayThreadPrivate]: "workgroup-array-thread-private", [cn.WorkgroupStorageOversized]: "workgroup-storage-oversized", [cn.SerialScanEmulation]: "serial-scan-emulation" };
5797
5797
 
5798
5798
  // src/canonical-json.ts
5799
- function isPlainObject(value) {
5800
- const prototype = Object.getPrototypeOf(value);
5801
- return prototype === Object.prototype || prototype === null;
5799
+ var GPU_CONTRACT_SNAPSHOT_LIMITS = Object.freeze({
5800
+ maximumDepth: 64,
5801
+ maximumNodes: 262144,
5802
+ maximumProperties: 131072,
5803
+ maximumElements: 131072,
5804
+ maximumArrayLength: 1e5,
5805
+ maximumStringBytes: 1024 * 1024,
5806
+ maximumAggregateStringBytes: 8 * 1024 * 1024,
5807
+ maximumAggregateBytes: 16 * 1024 * 1024,
5808
+ maximumInputBytes: 16 * 1024 * 1024
5809
+ });
5810
+ var QUALIFICATION_GPU_CONTRACT_SNAPSHOT_LIMITS = Object.freeze({
5811
+ maximumDepth: 96,
5812
+ maximumNodes: 4e6,
5813
+ maximumProperties: 2e6,
5814
+ maximumElements: 2e6,
5815
+ maximumArrayLength: 25e4,
5816
+ maximumStringBytes: 4 * 1024 * 1024,
5817
+ maximumAggregateStringBytes: 128 * 1024 * 1024,
5818
+ maximumAggregateBytes: 256 * 1024 * 1024,
5819
+ maximumInputBytes: 256 * 1024 * 1024
5820
+ });
5821
+ var FAILURE_MESSAGES = Object.freeze({
5822
+ "aggregate-bytes": "GPU contract snapshot exceeds the aggregate byte limit.",
5823
+ "aggregate-string-bytes": "GPU contract snapshot exceeds the aggregate string byte limit.",
5824
+ "array-length": "GPU contract snapshot exceeds the single-array element limit.",
5825
+ cycle: "GPU contract snapshot contains a circular reference.",
5826
+ depth: "GPU contract snapshot exceeds the nesting-depth limit.",
5827
+ elements: "GPU contract snapshot exceeds the total element limit.",
5828
+ inspection: "GPU contract snapshot rejected unsafe object inspection.",
5829
+ nodes: "GPU contract snapshot exceeds the total node limit.",
5830
+ "non-finite": "GPU contract snapshot contains a non-finite number.",
5831
+ properties: "GPU contract snapshot exceeds the total property limit.",
5832
+ shape: "GPU contract snapshot requires plain JSON objects with own enumerable data properties and dense arrays.",
5833
+ "string-bytes": "GPU contract snapshot exceeds the individual string byte limit.",
5834
+ unicode: "GPU contract snapshot contains an invalid Unicode scalar string or unpaired UTF-16 surrogate.",
5835
+ value: "GPU contract snapshot contains undefined or another value that JSON cannot represent."
5836
+ });
5837
+ var GpuContractSnapshotError = class extends TypeError {
5838
+ code;
5839
+ constructor(code) {
5840
+ super(FAILURE_MESSAGES[code]);
5841
+ this.name = "GpuContractSnapshotError";
5842
+ this.code = code;
5843
+ }
5844
+ };
5845
+ var TYPED_ARRAY_PROTOTYPE = Reflect.getPrototypeOf(Uint8Array.prototype);
5846
+ var TYPED_ARRAY_BYTE_LENGTH = Reflect.getOwnPropertyDescriptor(
5847
+ TYPED_ARRAY_PROTOTYPE,
5848
+ "byteLength"
5849
+ )?.get;
5850
+ var TYPED_ARRAY_TAG = Reflect.getOwnPropertyDescriptor(
5851
+ TYPED_ARRAY_PROTOTYPE,
5852
+ Symbol.toStringTag
5853
+ )?.get;
5854
+ var UINT8_ARRAY_SET = Uint8Array.prototype.set;
5855
+ function fail(reason) {
5856
+ throw new GpuContractSnapshotError(reason);
5857
+ }
5858
+ function inspected(operation) {
5859
+ try {
5860
+ return operation();
5861
+ } catch {
5862
+ return fail("inspection");
5863
+ }
5864
+ }
5865
+ function assertLimit(value, maximum, reason) {
5866
+ if (!Number.isSafeInteger(value) || value > maximum) fail(reason);
5802
5867
  }
5803
- function assertUnicodeScalarString(value, path2) {
5868
+ function quotedJsonByteLength(value, maximum) {
5869
+ let raw = 0;
5870
+ let quoted = 2;
5804
5871
  for (let index = 0; index < value.length; index += 1) {
5805
5872
  const code = value.charCodeAt(index);
5806
- if (code >= 55296 && code <= 56319) {
5873
+ if (code <= 127) {
5874
+ raw += 1;
5875
+ if (code <= 31) quoted += code === 8 || code === 9 || code === 10 || code === 12 || code === 13 ? 2 : 6;
5876
+ else quoted += code === 34 || code === 92 ? 2 : 1;
5877
+ } else if (code <= 2047) {
5878
+ raw += 2;
5879
+ quoted += 2;
5880
+ } else if (code >= 55296 && code <= 56319) {
5807
5881
  const next = value.charCodeAt(index + 1);
5808
- if (!(next >= 56320 && next <= 57343)) throw new TypeError(`${path2} contains an unpaired UTF-16 surrogate.`);
5882
+ if (!(next >= 56320 && next <= 57343)) fail("unicode");
5883
+ raw += 4;
5884
+ quoted += 4;
5809
5885
  index += 1;
5810
- } else if (code >= 56320 && code <= 57343) throw new TypeError(`${path2} contains an unpaired UTF-16 surrogate.`);
5886
+ } else if (code >= 56320 && code <= 57343) fail("unicode");
5887
+ else {
5888
+ raw += 3;
5889
+ quoted += 3;
5890
+ }
5891
+ if (raw > maximum) fail("string-bytes");
5811
5892
  }
5893
+ return { raw, quoted };
5812
5894
  }
5813
- function canonicalizeGpuContract(value) {
5895
+ function assertLimits(limits) {
5896
+ for (const value of Object.values(limits)) {
5897
+ if (!Number.isSafeInteger(value) || value < 1) throw new TypeError("GPU contract snapshot limits must be positive safe integers.");
5898
+ }
5899
+ }
5900
+ function snapshotGpuContract(value, limits = GPU_CONTRACT_SNAPSHOT_LIMITS) {
5901
+ assertLimits(limits);
5814
5902
  const ancestors = /* @__PURE__ */ new Set();
5815
- const visit = (current, path2) => {
5816
- if (current === null) return "null";
5817
- if (typeof current === "string" || typeof current === "boolean") {
5818
- if (typeof current === "string") assertUnicodeScalarString(current, path2);
5819
- return JSON.stringify(current);
5903
+ let nodes = 0;
5904
+ let properties = 0;
5905
+ let elements = 0;
5906
+ let aggregateStringBytes = 0;
5907
+ let aggregateBytes = 0;
5908
+ const addAggregate = (bytes) => {
5909
+ aggregateBytes += bytes;
5910
+ assertLimit(aggregateBytes, limits.maximumAggregateBytes, "aggregate-bytes");
5911
+ };
5912
+ const addString = (text2) => {
5913
+ const measured = quotedJsonByteLength(text2, limits.maximumStringBytes);
5914
+ aggregateStringBytes += measured.raw;
5915
+ assertLimit(aggregateStringBytes, limits.maximumAggregateStringBytes, "aggregate-string-bytes");
5916
+ return measured.quoted;
5917
+ };
5918
+ const visit = (current, depth) => {
5919
+ if (depth > limits.maximumDepth) fail("depth");
5920
+ nodes += 1;
5921
+ assertLimit(nodes, limits.maximumNodes, "nodes");
5922
+ if (current === null) {
5923
+ addAggregate(4);
5924
+ return null;
5925
+ }
5926
+ if (typeof current === "string") {
5927
+ addAggregate(addString(current));
5928
+ return current;
5929
+ }
5930
+ if (typeof current === "boolean") {
5931
+ addAggregate(current ? 4 : 5);
5932
+ return current;
5820
5933
  }
5821
5934
  if (typeof current === "number") {
5822
- if (!Number.isFinite(current)) {
5823
- throw new TypeError(`${path2} contains a non-finite number.`);
5824
- }
5825
- return Object.is(current, -0) ? "0" : JSON.stringify(current);
5826
- }
5827
- if (typeof current !== "object") {
5828
- throw new TypeError(`${path2} contains a value that JSON cannot represent.`);
5829
- }
5830
- if (ancestors.has(current)) {
5831
- throw new TypeError(`${path2} contains a circular reference.`);
5832
- }
5935
+ if (!Number.isFinite(current)) fail("non-finite");
5936
+ const normalized = Object.is(current, -0) ? 0 : current;
5937
+ addAggregate(JSON.stringify(normalized).length);
5938
+ return normalized;
5939
+ }
5940
+ if (typeof current !== "object") fail("value");
5941
+ if (ancestors.has(current)) fail("cycle");
5942
+ const isArray = inspected(() => Array.isArray(current));
5943
+ const prototype = inspected(() => Reflect.getPrototypeOf(current));
5944
+ if (isArray ? prototype !== Array.prototype : prototype !== Object.prototype && prototype !== null) fail("shape");
5833
5945
  ancestors.add(current);
5834
5946
  try {
5835
- if (Array.isArray(current)) {
5836
- return `[${current.map((item, index) => visit(item, `${path2}[${index}]`)).join(",")}]`;
5837
- }
5838
- if (!isPlainObject(current)) {
5839
- throw new TypeError(`${path2} must contain only plain JSON objects.`);
5840
- }
5841
- const keys = Object.keys(current).sort();
5842
- const properties = keys.map((key) => {
5843
- assertUnicodeScalarString(key, `${path2} key`);
5844
- const member = current[key];
5845
- if (member === void 0) {
5846
- throw new TypeError(`${path2}.${key} is undefined.`);
5947
+ if (isArray) {
5948
+ const lengthDescriptor = inspected(() => Reflect.getOwnPropertyDescriptor(current, "length"));
5949
+ if (!lengthDescriptor || !Object.hasOwn(lengthDescriptor, "value") || lengthDescriptor.enumerable || typeof lengthDescriptor.value !== "number" || !Number.isSafeInteger(lengthDescriptor.value) || lengthDescriptor.value < 0) fail("shape");
5950
+ const length = lengthDescriptor.value;
5951
+ assertLimit(length, limits.maximumArrayLength, "array-length");
5952
+ elements += length;
5953
+ assertLimit(elements, limits.maximumElements, "elements");
5954
+ const ownKeys2 = inspected(() => Reflect.ownKeys(current));
5955
+ if (ownKeys2.some((key) => typeof key !== "string")) fail("shape");
5956
+ if (ownKeys2.length !== length + 1) fail("shape");
5957
+ const keySet = new Set(ownKeys2);
5958
+ if (!keySet.delete("length")) fail("shape");
5959
+ const output2 = new Array(length);
5960
+ addAggregate(2 + Math.max(0, length - 1));
5961
+ for (let index = 0; index < length; index += 1) {
5962
+ const key = String(index);
5963
+ if (!keySet.delete(key)) fail("shape");
5964
+ const descriptor = inspected(() => Reflect.getOwnPropertyDescriptor(current, key));
5965
+ if (!descriptor || !descriptor.enumerable || !Object.hasOwn(descriptor, "value")) fail("shape");
5966
+ Object.defineProperty(output2, key, {
5967
+ configurable: true,
5968
+ enumerable: true,
5969
+ value: visit(descriptor.value, depth + 1),
5970
+ writable: true
5971
+ });
5847
5972
  }
5848
- return `${JSON.stringify(key)}:${visit(member, `${path2}.${key}`)}`;
5849
- });
5850
- return `{${properties.join(",")}}`;
5973
+ if (keySet.size !== 0) fail("shape");
5974
+ return output2;
5975
+ }
5976
+ const ownKeys = inspected(() => Reflect.ownKeys(current));
5977
+ if (ownKeys.some((key) => typeof key !== "string")) fail("shape");
5978
+ properties += ownKeys.length;
5979
+ assertLimit(properties, limits.maximumProperties, "properties");
5980
+ addAggregate(2 + Math.max(0, ownKeys.length - 1) + ownKeys.length);
5981
+ const output = {};
5982
+ for (const key of ownKeys) {
5983
+ addAggregate(addString(key));
5984
+ const descriptor = inspected(() => Reflect.getOwnPropertyDescriptor(current, key));
5985
+ if (!descriptor || !descriptor.enumerable || !Object.hasOwn(descriptor, "value")) fail("shape");
5986
+ Object.defineProperty(output, key, {
5987
+ configurable: true,
5988
+ enumerable: true,
5989
+ value: visit(descriptor.value, depth + 1),
5990
+ writable: true
5991
+ });
5992
+ }
5993
+ return output;
5851
5994
  } finally {
5852
5995
  ancestors.delete(current);
5853
5996
  }
5854
5997
  };
5855
- return visit(value, "$root");
5998
+ return visit(value, 0);
5999
+ }
6000
+ function serializeSnapshot(value) {
6001
+ if (value === null) return "null";
6002
+ if (typeof value === "string" || typeof value === "boolean") return JSON.stringify(value);
6003
+ if (typeof value === "number") return JSON.stringify(value);
6004
+ if (Array.isArray(value)) return `[${value.map(serializeSnapshot).join(",")}]`;
6005
+ const input = value;
6006
+ return `{${Object.keys(input).sort().map((key) => `${JSON.stringify(key)}:${serializeSnapshot(input[key])}`).join(",")}}`;
6007
+ }
6008
+ function canonicalizeGpuContract(value) {
6009
+ return serializeSnapshot(snapshotGpuContract(value));
5856
6010
  }
5857
6011
 
5858
6012
  // src/contracts.ts
@@ -5950,39 +6104,41 @@ function modelProjection(manifest) {
5950
6104
  };
5951
6105
  }
5952
6106
  async function computeGpuAbiHash(input) {
5953
- if (input.kind === "model") {
6107
+ const snapshot = snapshotGpuContract(input);
6108
+ if (snapshot.kind === "model") {
5954
6109
  return computeSha256(
5955
6110
  `plasius.gpu.model-abi/v1
5956
- ${canonicalizeGpuContract(modelProjection(input.interface))}`
6111
+ ${canonicalizeGpuContract(modelProjection(snapshot.interface))}`
5957
6112
  );
5958
6113
  }
5959
- if (input.kind === "interface") {
6114
+ if (snapshot.kind === "interface") {
5960
6115
  return computeSha256(
5961
6116
  `plasius.gpu.interface-abi/v1
5962
- ${canonicalizeGpuContract(interfaceProjection(input.interface))}`
6117
+ ${canonicalizeGpuContract(interfaceProjection(snapshot.interface))}`
5963
6118
  );
5964
6119
  }
5965
6120
  const pipelines = sorted(
5966
- input.pipelines,
6121
+ snapshot.pipelines,
5967
6122
  (left, right) => compareString(left.pipelineId, right.pipelineId)
5968
6123
  );
5969
6124
  const requirements = {
5970
- semantics: [...input.requirements.semantics].sort(),
5971
- features: [...input.requirements.features].sort(),
5972
- limits: sorted(input.requirements.limits, (left, right) => compareString(left.name, right.name)),
5973
- formats: [...input.requirements.formats].sort()
6125
+ semantics: [...snapshot.requirements.semantics].sort(),
6126
+ features: [...snapshot.requirements.features].sort(),
6127
+ limits: sorted(snapshot.requirements.limits, (left, right) => compareString(left.name, right.name)),
6128
+ formats: [...snapshot.requirements.formats].sort()
5974
6129
  };
5975
6130
  return computeSha256(
5976
6131
  `plasius.gpu.shader-abi/v1
5977
6132
  ${canonicalizeGpuContract({
5978
- interface: interfaceProjection(input.interface),
6133
+ interface: interfaceProjection(snapshot.interface),
5979
6134
  pipelines,
5980
6135
  requirements
5981
6136
  })}`
5982
6137
  );
5983
6138
  }
5984
6139
  async function computeShaderManifestCoreSha256(manifest) {
5985
- const core = Object.fromEntries(Object.entries(manifest).filter(
6140
+ const snapshot = snapshotGpuContract(manifest);
6141
+ const core = Object.fromEntries(Object.entries(snapshot).filter(
5986
6142
  ([key]) => key !== "validationEvidence" && key !== "additionalValidationEvidence"
5987
6143
  ));
5988
6144
  return computeSha256(
@@ -6343,11 +6499,10 @@ var stages = ["vertex", "fragment", "compute"];
6343
6499
  var roles = ["material", "lighting", "outline", "shadow", "post-processing"];
6344
6500
  function detachedJson(value, path2) {
6345
6501
  try {
6346
- return JSON.parse(canonicalizeGpuContract(value));
6502
+ return snapshotGpuContract(value);
6347
6503
  } catch (cause) {
6348
- const detail = cause instanceof Error ? cause.message : "Contract snapshot failed.";
6349
- const boundedDetail = [...detail].slice(0, 512).join("");
6350
- throw new TypeError(`${path2} must contain detached JSON contract data: ${boundedDetail}`, { cause });
6504
+ const detail = cause instanceof GpuContractSnapshotError ? ` ${cause.message}` : "";
6505
+ throw new TypeError(`${path2} must contain bounded detached JSON contract data.${detail}`);
6351
6506
  }
6352
6507
  }
6353
6508
  function object(value, path2) {
@@ -6357,7 +6512,7 @@ function object(value, path2) {
6357
6512
  function exact(value, keys, path2) {
6358
6513
  const allowed = new Set(keys);
6359
6514
  for (const key of Object.keys(value)) if (!allowed.has(key)) throw new TypeError(`${path2}.${key} is not part of this contract version.`);
6360
- for (const key of keys) if (!(key in value)) throw new TypeError(`${path2}.${key} is required.`);
6515
+ for (const key of keys) if (!Object.hasOwn(value, key)) throw new TypeError(`${path2}.${key} is required.`);
6361
6516
  }
6362
6517
  function text(value, path2, maximum = 512) {
6363
6518
  if (typeof value !== "string" || value.length === 0 || value.length > maximum || [...value].some((character) => character.charCodeAt(0) <= 31)) {
@@ -6373,11 +6528,8 @@ function token(value, path2) {
6373
6528
  function immutableVersion(value, path2) {
6374
6529
  try {
6375
6530
  return assertImmutableAssetVersion(value);
6376
- } catch (cause) {
6377
- throw new TypeError(
6378
- `${path2} must be an immutable asset version: exact token required; mutable aliases, ranges, wildcards, and URLs are not allowed.`,
6379
- { cause }
6380
- );
6531
+ } catch {
6532
+ throw new TypeError(`${path2} must be an immutable asset version: exact token required; mutable aliases, ranges, wildcards, and URLs are not allowed.`);
6381
6533
  }
6382
6534
  }
6383
6535
  function enumeration(value, values, path2) {
@@ -6407,8 +6559,8 @@ function nullableToken(value, path2) {
6407
6559
  function digest(value, path2) {
6408
6560
  try {
6409
6561
  return asSha256Hex(text(value, path2, 64));
6410
- } catch (cause) {
6411
- throw new TypeError(`${path2} must be a lowercase SHA-256 digest.`, { cause });
6562
+ } catch {
6563
+ throw new TypeError(`${path2} must be a lowercase SHA-256 digest.`);
6412
6564
  }
6413
6565
  }
6414
6566
  function uri(value, path2) {
@@ -6416,8 +6568,8 @@ function uri(value, path2) {
6416
6568
  let parsed;
6417
6569
  try {
6418
6570
  parsed = new URL(result);
6419
- } catch (cause) {
6420
- throw new TypeError(`${path2} must be an absolute immutable asset URI.`, { cause });
6571
+ } catch {
6572
+ throw new TypeError(`${path2} must be an absolute immutable asset URI.`);
6421
6573
  }
6422
6574
  if (parsed.protocol !== "https:" || parsed.username || parsed.password || parsed.hash) throw new TypeError(`${path2} must be credential-free HTTPS without a fragment.`);
6423
6575
  const keys = [...parsed.searchParams.keys()].map((key) => key.toLowerCase());
@@ -7555,7 +7707,7 @@ function validatePipelineInterfaces(input) {
7555
7707
  // package.json
7556
7708
  var package_default = {
7557
7709
  name: "@plasius/gpu-shader",
7558
- version: "0.1.2",
7710
+ version: "0.1.4",
7559
7711
  description: "Reflection-first WebGPU WGSL interfaces, CPU codecs, compatibility validation, style profiles, and qualification tooling",
7560
7712
  type: "module",
7561
7713
  sideEffects: false,
@@ -7600,6 +7752,7 @@ var package_default = {
7600
7752
  "audit:npm": "npm audit --audit-level=high --omit=dev",
7601
7753
  "audit:test": "vitest run --coverage",
7602
7754
  "pack:check": "node scripts/verify-public-package.cjs",
7755
+ "privacy:check": "node scripts/verify-public-artifacts.cjs --source-only",
7603
7756
  "harness:fingerprint": "node scripts/fingerprint-trusted-harness.cjs .",
7604
7757
  "shader:matrix": "npm run build && node dist/cli.js validate-matrix --matrix matrices/stable-webgpu-2026-07-13.json",
7605
7758
  prepare: "npm run build",
@@ -7628,25 +7781,29 @@ var package_default = {
7628
7781
  wgsl_reflect: "1.5.0"
7629
7782
  },
7630
7783
  optionalDependencies: {
7631
- "playwright-core": "1.61.1"
7784
+ "playwright-core": "1.62.1"
7632
7785
  },
7633
7786
  devDependencies: {
7634
7787
  "@eslint/js": "^10.0.1",
7635
- "@types/node": "^26.0.1",
7636
- "@typescript-eslint/eslint-plugin": "^8.59.3",
7637
- "@typescript-eslint/parser": "^8.59.3",
7638
- "@vitest/coverage-v8": "^4.1.6",
7639
- eslint: "^10.3.0",
7640
- globals: "^17.6.0",
7788
+ "@types/node": "^26.4.0",
7789
+ "@typescript-eslint/eslint-plugin": "^8.69.0",
7790
+ "@typescript-eslint/parser": "^8.69.0",
7791
+ "@vitest/coverage-v8": "^4.1.11",
7792
+ eslint: "^10.9.1",
7793
+ globals: "^17.11.0",
7641
7794
  rimraf: "^6.1.3",
7642
7795
  tsup: "^8.5.1",
7643
7796
  typescript: "^6.0.3",
7644
- vitest: "^4.1.6"
7797
+ vitest: "^4.1.11"
7645
7798
  },
7646
7799
  publishConfig: {
7647
7800
  access: "public"
7648
7801
  },
7649
7802
  overrides: {
7803
+ nanoid: "3.3.18",
7804
+ postcss: "8.5.26",
7805
+ "brace-expansion": "5.0.9",
7806
+ esbuild: "^0.28.1",
7650
7807
  minimatch: "^10.2.1"
7651
7808
  },
7652
7809
  engines: {
@@ -9014,7 +9171,7 @@ function freezeJson(value) {
9014
9171
  }
9015
9172
  function exactKeys(value, keys) {
9016
9173
  const expected = new Set(keys);
9017
- return Object.keys(value).every((key) => expected.has(key)) && keys.every((key) => key in value);
9174
+ return Object.keys(value).every((key) => expected.has(key)) && keys.every((key) => Object.hasOwn(value, key));
9018
9175
  }
9019
9176
  function safeToken(value) {
9020
9177
  return typeof value === "string" && /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,159}$/u.test(value) && !value.includes("..");
@@ -9038,13 +9195,13 @@ function validSha(value) {
9038
9195
  function validateCompileUnitInventory(value) {
9039
9196
  let snapshot;
9040
9197
  try {
9041
- snapshot = JSON.parse(canonicalizeGpuContract(value));
9042
- } catch (cause) {
9198
+ snapshot = snapshotGpuContract(value, QUALIFICATION_GPU_CONTRACT_SNAPSHOT_LIMITS);
9199
+ } catch {
9043
9200
  return {
9044
9201
  ok: false,
9045
9202
  diagnostics: [issue2(
9046
9203
  "invalid-contract",
9047
- cause instanceof Error ? cause.message : "Compile-unit inventory must contain detached JSON data."
9204
+ "Compile-unit inventory must contain bounded detached JSON contract data."
9048
9205
  )]
9049
9206
  };
9050
9207
  }
@@ -9285,9 +9442,9 @@ function object3(value, path2) {
9285
9442
  }
9286
9443
  function detachedJson2(value, label) {
9287
9444
  try {
9288
- return JSON.parse(canonicalizeGpuContract(value));
9289
- } catch (cause) {
9290
- throw new TypeError(`${label} must contain detached JSON contract data.`, { cause });
9445
+ return snapshotGpuContract(value, QUALIFICATION_GPU_CONTRACT_SNAPSHOT_LIMITS);
9446
+ } catch {
9447
+ throw new TypeError(`${label} must contain bounded detached JSON contract data.`);
9291
9448
  }
9292
9449
  }
9293
9450
  function freezeJson2(value) {
@@ -9297,7 +9454,7 @@ function freezeJson2(value) {
9297
9454
  }
9298
9455
  function exact2(value, keys, path2) {
9299
9456
  const expected = new Set(keys);
9300
- if (!Object.keys(value).every((key) => expected.has(key)) || !keys.every((key) => key in value)) throw new TypeError(`${path2} has unknown or missing fields.`);
9457
+ if (!Object.keys(value).every((key) => expected.has(key)) || !keys.every((key) => Object.hasOwn(value, key))) throw new TypeError(`${path2} has unknown or missing fields.`);
9301
9458
  }
9302
9459
  function token2(value, path2) {
9303
9460
  if (typeof value !== "string" || !TOKEN.test(value) || value.includes("..")) throw new TypeError(`${path2} must be a safe token.`);
@@ -9306,11 +9463,8 @@ function token2(value, path2) {
9306
9463
  function immutableVersion3(value, path2) {
9307
9464
  try {
9308
9465
  return assertImmutableAssetVersion(value);
9309
- } catch (cause) {
9310
- throw new TypeError(
9311
- `${path2} must be an immutable asset version: exact token required; mutable aliases, ranges, wildcards, and URLs are not allowed.`,
9312
- { cause }
9313
- );
9466
+ } catch {
9467
+ throw new TypeError(`${path2} must be an immutable asset version: exact token required; mutable aliases, ranges, wildcards, and URLs are not allowed.`);
9314
9468
  }
9315
9469
  }
9316
9470
  function path(value, label, extensions) {
@@ -9322,8 +9476,8 @@ function path(value, label, extensions) {
9322
9476
  function sha(value, label) {
9323
9477
  try {
9324
9478
  return asSha256Hex(String(value));
9325
- } catch (cause) {
9326
- throw new TypeError(`${label} must be a lowercase SHA-256 digest.`, { cause });
9479
+ } catch {
9480
+ throw new TypeError(`${label} must be a lowercase SHA-256 digest.`);
9327
9481
  }
9328
9482
  }
9329
9483
  function integer4(value, label, minimum = 0, maximum = 4294967295) {
@@ -9447,6 +9601,7 @@ function jsonValue(value, label, depth = 0) {
9447
9601
  }
9448
9602
  function validateQualificationFixture(value, unit) {
9449
9603
  try {
9604
+ const compileUnit = unit === void 0 ? void 0 : detachedJson2(unit, "compile unit");
9450
9605
  const fixture = object3(detachedJson2(value, "fixture"), "fixture");
9451
9606
  exact2(fixture, ["contractVersion", "fixtureId", "resources", "bindGroups", "commands", "layoutProbes", "readbacks", "bounds"], "fixture");
9452
9607
  if (fixture.contractVersion !== SHADER_QUALIFICATION_FIXTURE_VERSION) throw new TypeError("Unsupported qualification fixture version.");
@@ -9577,14 +9732,14 @@ function validateQualificationFixture(value, unit) {
9577
9732
  unique2(bindingIds, `${label}.entries`);
9578
9733
  bindGroups.set(id, { group: groupIndex, entries: parsedEntries });
9579
9734
  }
9580
- const pipelines = new Map(unit?.pipelines.map((pipeline2) => [pipeline2.pipelineId, pipeline2]) ?? []);
9735
+ const pipelines = new Map(compileUnit?.pipelines.map((pipeline2) => [pipeline2.pipelineId, pipeline2]) ?? []);
9581
9736
  const pipelineIds = new Set(pipelines.keys());
9582
9737
  const commandBindGroups = (value2, pipelineId, label) => {
9583
9738
  const ids = boundedArray(value2, label, 32).map((item, index) => token2(item, `${label}[${index}]`));
9584
9739
  unique2(ids, label);
9585
9740
  const pipeline2 = pipelines.get(pipelineId);
9586
9741
  if (!pipeline2) {
9587
- if (unit) throw new TypeError(`${label} pipeline is missing.`);
9742
+ if (compileUnit) throw new TypeError(`${label} pipeline is missing.`);
9588
9743
  return;
9589
9744
  }
9590
9745
  const expectedGroups = [...pipeline2.layout.bindGroups].sort((left, right) => left.group - right.group);
@@ -9609,7 +9764,7 @@ function validateQualificationFixture(value, unit) {
9609
9764
  executionCommands += 1;
9610
9765
  exact2(command, ["kind", "pipelineId", "bindGroupIds", "workgroups"], label);
9611
9766
  const id = token2(command.pipelineId, `${label}.pipelineId`);
9612
- if (unit && pipelines.get(id)?.kind !== "compute") throw new TypeError(`${label} references a missing or non-compute pipeline.`);
9767
+ if (compileUnit && pipelines.get(id)?.kind !== "compute") throw new TypeError(`${label} references a missing or non-compute pipeline.`);
9613
9768
  commandBindGroups(command.bindGroupIds, id, `${label}.bindGroupIds`);
9614
9769
  const workgroups = tuple(command.workgroups, `${label}.workgroups`, 3, 1);
9615
9770
  if (workgroups[0] * workgroups[1] * workgroups[2] > 1048576) throw new TypeError(`${label}.workgroups exceeds the hard dispatch bound.`);