@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/README.md +52 -5
- package/dist/cli.cjs +372 -155
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +372 -155
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +543 -146
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +543 -146
- package/dist/index.js.map +1 -1
- package/dist/node.cjs +247 -92
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +247 -92
- package/dist/node.js.map +1 -1
- package/dist/testing.cjs +366 -124
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.js +366 -124
- package/dist/testing.js.map +1 -1
- package/package.json +14 -9
package/dist/cli.cjs
CHANGED
|
@@ -34,63 +34,244 @@ var import_promises = require("fs/promises");
|
|
|
34
34
|
var import_node_path = require("path");
|
|
35
35
|
|
|
36
36
|
// src/canonical-json.ts
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
var GPU_CONTRACT_SNAPSHOT_LIMITS = Object.freeze({
|
|
38
|
+
maximumDepth: 64,
|
|
39
|
+
maximumNodes: 262144,
|
|
40
|
+
maximumProperties: 131072,
|
|
41
|
+
maximumElements: 131072,
|
|
42
|
+
maximumArrayLength: 1e5,
|
|
43
|
+
maximumStringBytes: 1024 * 1024,
|
|
44
|
+
maximumAggregateStringBytes: 8 * 1024 * 1024,
|
|
45
|
+
maximumAggregateBytes: 16 * 1024 * 1024,
|
|
46
|
+
maximumInputBytes: 16 * 1024 * 1024
|
|
47
|
+
});
|
|
48
|
+
var QUALIFICATION_GPU_CONTRACT_SNAPSHOT_LIMITS = Object.freeze({
|
|
49
|
+
maximumDepth: 96,
|
|
50
|
+
maximumNodes: 4e6,
|
|
51
|
+
maximumProperties: 2e6,
|
|
52
|
+
maximumElements: 2e6,
|
|
53
|
+
maximumArrayLength: 25e4,
|
|
54
|
+
maximumStringBytes: 4 * 1024 * 1024,
|
|
55
|
+
maximumAggregateStringBytes: 128 * 1024 * 1024,
|
|
56
|
+
maximumAggregateBytes: 256 * 1024 * 1024,
|
|
57
|
+
maximumInputBytes: 256 * 1024 * 1024
|
|
58
|
+
});
|
|
59
|
+
var FAILURE_MESSAGES = Object.freeze({
|
|
60
|
+
"aggregate-bytes": "GPU contract snapshot exceeds the aggregate byte limit.",
|
|
61
|
+
"aggregate-string-bytes": "GPU contract snapshot exceeds the aggregate string byte limit.",
|
|
62
|
+
"array-length": "GPU contract snapshot exceeds the single-array element limit.",
|
|
63
|
+
cycle: "GPU contract snapshot contains a circular reference.",
|
|
64
|
+
depth: "GPU contract snapshot exceeds the nesting-depth limit.",
|
|
65
|
+
elements: "GPU contract snapshot exceeds the total element limit.",
|
|
66
|
+
inspection: "GPU contract snapshot rejected unsafe object inspection.",
|
|
67
|
+
nodes: "GPU contract snapshot exceeds the total node limit.",
|
|
68
|
+
"non-finite": "GPU contract snapshot contains a non-finite number.",
|
|
69
|
+
properties: "GPU contract snapshot exceeds the total property limit.",
|
|
70
|
+
shape: "GPU contract snapshot requires plain JSON objects with own enumerable data properties and dense arrays.",
|
|
71
|
+
"string-bytes": "GPU contract snapshot exceeds the individual string byte limit.",
|
|
72
|
+
unicode: "GPU contract snapshot contains an invalid Unicode scalar string or unpaired UTF-16 surrogate.",
|
|
73
|
+
value: "GPU contract snapshot contains undefined or another value that JSON cannot represent."
|
|
74
|
+
});
|
|
75
|
+
var GpuContractSnapshotError = class extends TypeError {
|
|
76
|
+
code;
|
|
77
|
+
constructor(code) {
|
|
78
|
+
super(FAILURE_MESSAGES[code]);
|
|
79
|
+
this.name = "GpuContractSnapshotError";
|
|
80
|
+
this.code = code;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
var TYPED_ARRAY_PROTOTYPE = Reflect.getPrototypeOf(Uint8Array.prototype);
|
|
84
|
+
var TYPED_ARRAY_BYTE_LENGTH = Reflect.getOwnPropertyDescriptor(
|
|
85
|
+
TYPED_ARRAY_PROTOTYPE,
|
|
86
|
+
"byteLength"
|
|
87
|
+
)?.get;
|
|
88
|
+
var TYPED_ARRAY_TAG = Reflect.getOwnPropertyDescriptor(
|
|
89
|
+
TYPED_ARRAY_PROTOTYPE,
|
|
90
|
+
Symbol.toStringTag
|
|
91
|
+
)?.get;
|
|
92
|
+
var UINT8_ARRAY_SET = Uint8Array.prototype.set;
|
|
93
|
+
function snapshotUint8Array(value, maximumBytes) {
|
|
94
|
+
if (!Number.isSafeInteger(maximumBytes) || maximumBytes < 0) {
|
|
95
|
+
throw new TypeError("GPU contract byte limit must be a non-negative safe integer.");
|
|
96
|
+
}
|
|
97
|
+
let byteLength;
|
|
98
|
+
let tag;
|
|
99
|
+
try {
|
|
100
|
+
if (!TYPED_ARRAY_BYTE_LENGTH || !TYPED_ARRAY_TAG) throw new TypeError();
|
|
101
|
+
byteLength = Reflect.apply(TYPED_ARRAY_BYTE_LENGTH, value, []);
|
|
102
|
+
tag = Reflect.apply(TYPED_ARRAY_TAG, value, []);
|
|
103
|
+
} catch {
|
|
104
|
+
throw new TypeError("GPU contract bytes must be a bounded detached Uint8Array.");
|
|
105
|
+
}
|
|
106
|
+
if (tag !== "Uint8Array" || !Number.isSafeInteger(byteLength) || byteLength > maximumBytes) {
|
|
107
|
+
throw new TypeError("GPU contract bytes must be a bounded detached Uint8Array.");
|
|
108
|
+
}
|
|
109
|
+
const output = new Uint8Array(byteLength);
|
|
110
|
+
try {
|
|
111
|
+
Reflect.apply(UINT8_ARRAY_SET, output, [value]);
|
|
112
|
+
} catch {
|
|
113
|
+
throw new TypeError("GPU contract bytes must be a bounded detached Uint8Array.");
|
|
114
|
+
}
|
|
115
|
+
return output;
|
|
116
|
+
}
|
|
117
|
+
function fail(reason) {
|
|
118
|
+
throw new GpuContractSnapshotError(reason);
|
|
40
119
|
}
|
|
41
|
-
function
|
|
120
|
+
function inspected(operation) {
|
|
121
|
+
try {
|
|
122
|
+
return operation();
|
|
123
|
+
} catch {
|
|
124
|
+
return fail("inspection");
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function assertLimit(value, maximum, reason) {
|
|
128
|
+
if (!Number.isSafeInteger(value) || value > maximum) fail(reason);
|
|
129
|
+
}
|
|
130
|
+
function quotedJsonByteLength(value, maximum) {
|
|
131
|
+
let raw = 0;
|
|
132
|
+
let quoted = 2;
|
|
42
133
|
for (let index = 0; index < value.length; index += 1) {
|
|
43
134
|
const code = value.charCodeAt(index);
|
|
44
|
-
if (code
|
|
135
|
+
if (code <= 127) {
|
|
136
|
+
raw += 1;
|
|
137
|
+
if (code <= 31) quoted += code === 8 || code === 9 || code === 10 || code === 12 || code === 13 ? 2 : 6;
|
|
138
|
+
else quoted += code === 34 || code === 92 ? 2 : 1;
|
|
139
|
+
} else if (code <= 2047) {
|
|
140
|
+
raw += 2;
|
|
141
|
+
quoted += 2;
|
|
142
|
+
} else if (code >= 55296 && code <= 56319) {
|
|
45
143
|
const next = value.charCodeAt(index + 1);
|
|
46
|
-
if (!(next >= 56320 && next <= 57343))
|
|
144
|
+
if (!(next >= 56320 && next <= 57343)) fail("unicode");
|
|
145
|
+
raw += 4;
|
|
146
|
+
quoted += 4;
|
|
47
147
|
index += 1;
|
|
48
|
-
} else if (code >= 56320 && code <= 57343)
|
|
148
|
+
} else if (code >= 56320 && code <= 57343) fail("unicode");
|
|
149
|
+
else {
|
|
150
|
+
raw += 3;
|
|
151
|
+
quoted += 3;
|
|
152
|
+
}
|
|
153
|
+
if (raw > maximum) fail("string-bytes");
|
|
49
154
|
}
|
|
155
|
+
return { raw, quoted };
|
|
50
156
|
}
|
|
51
|
-
function
|
|
157
|
+
function assertLimits(limits) {
|
|
158
|
+
for (const value of Object.values(limits)) {
|
|
159
|
+
if (!Number.isSafeInteger(value) || value < 1) throw new TypeError("GPU contract snapshot limits must be positive safe integers.");
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
function snapshotGpuContract(value, limits = GPU_CONTRACT_SNAPSHOT_LIMITS) {
|
|
163
|
+
assertLimits(limits);
|
|
52
164
|
const ancestors = /* @__PURE__ */ new Set();
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
165
|
+
let nodes = 0;
|
|
166
|
+
let properties = 0;
|
|
167
|
+
let elements = 0;
|
|
168
|
+
let aggregateStringBytes = 0;
|
|
169
|
+
let aggregateBytes = 0;
|
|
170
|
+
const addAggregate = (bytes2) => {
|
|
171
|
+
aggregateBytes += bytes2;
|
|
172
|
+
assertLimit(aggregateBytes, limits.maximumAggregateBytes, "aggregate-bytes");
|
|
173
|
+
};
|
|
174
|
+
const addString = (text2) => {
|
|
175
|
+
const measured = quotedJsonByteLength(text2, limits.maximumStringBytes);
|
|
176
|
+
aggregateStringBytes += measured.raw;
|
|
177
|
+
assertLimit(aggregateStringBytes, limits.maximumAggregateStringBytes, "aggregate-string-bytes");
|
|
178
|
+
return measured.quoted;
|
|
179
|
+
};
|
|
180
|
+
const visit = (current, depth) => {
|
|
181
|
+
if (depth > limits.maximumDepth) fail("depth");
|
|
182
|
+
nodes += 1;
|
|
183
|
+
assertLimit(nodes, limits.maximumNodes, "nodes");
|
|
184
|
+
if (current === null) {
|
|
185
|
+
addAggregate(4);
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
if (typeof current === "string") {
|
|
189
|
+
addAggregate(addString(current));
|
|
190
|
+
return current;
|
|
191
|
+
}
|
|
192
|
+
if (typeof current === "boolean") {
|
|
193
|
+
addAggregate(current ? 4 : 5);
|
|
194
|
+
return current;
|
|
58
195
|
}
|
|
59
196
|
if (typeof current === "number") {
|
|
60
|
-
if (!Number.isFinite(current))
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return
|
|
64
|
-
}
|
|
65
|
-
if (typeof current !== "object")
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
197
|
+
if (!Number.isFinite(current)) fail("non-finite");
|
|
198
|
+
const normalized = Object.is(current, -0) ? 0 : current;
|
|
199
|
+
addAggregate(JSON.stringify(normalized).length);
|
|
200
|
+
return normalized;
|
|
201
|
+
}
|
|
202
|
+
if (typeof current !== "object") fail("value");
|
|
203
|
+
if (ancestors.has(current)) fail("cycle");
|
|
204
|
+
const isArray = inspected(() => Array.isArray(current));
|
|
205
|
+
const prototype = inspected(() => Reflect.getPrototypeOf(current));
|
|
206
|
+
if (isArray ? prototype !== Array.prototype : prototype !== Object.prototype && prototype !== null) fail("shape");
|
|
71
207
|
ancestors.add(current);
|
|
72
208
|
try {
|
|
73
|
-
if (
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
209
|
+
if (isArray) {
|
|
210
|
+
const lengthDescriptor = inspected(() => Reflect.getOwnPropertyDescriptor(current, "length"));
|
|
211
|
+
if (!lengthDescriptor || !Object.hasOwn(lengthDescriptor, "value") || lengthDescriptor.enumerable || typeof lengthDescriptor.value !== "number" || !Number.isSafeInteger(lengthDescriptor.value) || lengthDescriptor.value < 0) fail("shape");
|
|
212
|
+
const length = lengthDescriptor.value;
|
|
213
|
+
assertLimit(length, limits.maximumArrayLength, "array-length");
|
|
214
|
+
elements += length;
|
|
215
|
+
assertLimit(elements, limits.maximumElements, "elements");
|
|
216
|
+
const ownKeys2 = inspected(() => Reflect.ownKeys(current));
|
|
217
|
+
if (ownKeys2.some((key) => typeof key !== "string")) fail("shape");
|
|
218
|
+
if (ownKeys2.length !== length + 1) fail("shape");
|
|
219
|
+
const keySet = new Set(ownKeys2);
|
|
220
|
+
if (!keySet.delete("length")) fail("shape");
|
|
221
|
+
const output2 = new Array(length);
|
|
222
|
+
addAggregate(2 + Math.max(0, length - 1));
|
|
223
|
+
for (let index = 0; index < length; index += 1) {
|
|
224
|
+
const key = String(index);
|
|
225
|
+
if (!keySet.delete(key)) fail("shape");
|
|
226
|
+
const descriptor = inspected(() => Reflect.getOwnPropertyDescriptor(current, key));
|
|
227
|
+
if (!descriptor || !descriptor.enumerable || !Object.hasOwn(descriptor, "value")) fail("shape");
|
|
228
|
+
Object.defineProperty(output2, key, {
|
|
229
|
+
configurable: true,
|
|
230
|
+
enumerable: true,
|
|
231
|
+
value: visit(descriptor.value, depth + 1),
|
|
232
|
+
writable: true
|
|
233
|
+
});
|
|
85
234
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
235
|
+
if (keySet.size !== 0) fail("shape");
|
|
236
|
+
return output2;
|
|
237
|
+
}
|
|
238
|
+
const ownKeys = inspected(() => Reflect.ownKeys(current));
|
|
239
|
+
if (ownKeys.some((key) => typeof key !== "string")) fail("shape");
|
|
240
|
+
properties += ownKeys.length;
|
|
241
|
+
assertLimit(properties, limits.maximumProperties, "properties");
|
|
242
|
+
addAggregate(2 + Math.max(0, ownKeys.length - 1) + ownKeys.length);
|
|
243
|
+
const output = {};
|
|
244
|
+
for (const key of ownKeys) {
|
|
245
|
+
addAggregate(addString(key));
|
|
246
|
+
const descriptor = inspected(() => Reflect.getOwnPropertyDescriptor(current, key));
|
|
247
|
+
if (!descriptor || !descriptor.enumerable || !Object.hasOwn(descriptor, "value")) fail("shape");
|
|
248
|
+
Object.defineProperty(output, key, {
|
|
249
|
+
configurable: true,
|
|
250
|
+
enumerable: true,
|
|
251
|
+
value: visit(descriptor.value, depth + 1),
|
|
252
|
+
writable: true
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
return output;
|
|
89
256
|
} finally {
|
|
90
257
|
ancestors.delete(current);
|
|
91
258
|
}
|
|
92
259
|
};
|
|
93
|
-
return visit(value,
|
|
260
|
+
return visit(value, 0);
|
|
261
|
+
}
|
|
262
|
+
function serializeSnapshot(value) {
|
|
263
|
+
if (value === null) return "null";
|
|
264
|
+
if (typeof value === "string" || typeof value === "boolean") return JSON.stringify(value);
|
|
265
|
+
if (typeof value === "number") return JSON.stringify(value);
|
|
266
|
+
if (Array.isArray(value)) return `[${value.map(serializeSnapshot).join(",")}]`;
|
|
267
|
+
const input = value;
|
|
268
|
+
return `{${Object.keys(input).sort().map((key) => `${JSON.stringify(key)}:${serializeSnapshot(input[key])}`).join(",")}}`;
|
|
269
|
+
}
|
|
270
|
+
function canonicalizeGpuContract(value) {
|
|
271
|
+
return serializeSnapshot(snapshotGpuContract(value));
|
|
272
|
+
}
|
|
273
|
+
function canonicalizeQualificationGpuContract(value) {
|
|
274
|
+
return serializeSnapshot(snapshotGpuContract(value, QUALIFICATION_GPU_CONTRACT_SNAPSHOT_LIMITS));
|
|
94
275
|
}
|
|
95
276
|
|
|
96
277
|
// src/codec/codec.ts
|
|
@@ -562,39 +743,41 @@ function modelProjection(manifest) {
|
|
|
562
743
|
};
|
|
563
744
|
}
|
|
564
745
|
async function computeGpuAbiHash(input) {
|
|
565
|
-
|
|
746
|
+
const snapshot = snapshotGpuContract(input);
|
|
747
|
+
if (snapshot.kind === "model") {
|
|
566
748
|
return computeSha256(
|
|
567
749
|
`plasius.gpu.model-abi/v1
|
|
568
|
-
${canonicalizeGpuContract(modelProjection(
|
|
750
|
+
${canonicalizeGpuContract(modelProjection(snapshot.interface))}`
|
|
569
751
|
);
|
|
570
752
|
}
|
|
571
|
-
if (
|
|
753
|
+
if (snapshot.kind === "interface") {
|
|
572
754
|
return computeSha256(
|
|
573
755
|
`plasius.gpu.interface-abi/v1
|
|
574
|
-
${canonicalizeGpuContract(interfaceProjection(
|
|
756
|
+
${canonicalizeGpuContract(interfaceProjection(snapshot.interface))}`
|
|
575
757
|
);
|
|
576
758
|
}
|
|
577
759
|
const pipelines = sorted(
|
|
578
|
-
|
|
760
|
+
snapshot.pipelines,
|
|
579
761
|
(left, right) => compareString(left.pipelineId, right.pipelineId)
|
|
580
762
|
);
|
|
581
763
|
const requirements = {
|
|
582
|
-
semantics: [...
|
|
583
|
-
features: [...
|
|
584
|
-
limits: sorted(
|
|
585
|
-
formats: [...
|
|
764
|
+
semantics: [...snapshot.requirements.semantics].sort(),
|
|
765
|
+
features: [...snapshot.requirements.features].sort(),
|
|
766
|
+
limits: sorted(snapshot.requirements.limits, (left, right) => compareString(left.name, right.name)),
|
|
767
|
+
formats: [...snapshot.requirements.formats].sort()
|
|
586
768
|
};
|
|
587
769
|
return computeSha256(
|
|
588
770
|
`plasius.gpu.shader-abi/v1
|
|
589
771
|
${canonicalizeGpuContract({
|
|
590
|
-
interface: interfaceProjection(
|
|
772
|
+
interface: interfaceProjection(snapshot.interface),
|
|
591
773
|
pipelines,
|
|
592
774
|
requirements
|
|
593
775
|
})}`
|
|
594
776
|
);
|
|
595
777
|
}
|
|
596
778
|
async function computeShaderManifestCoreSha256(manifest) {
|
|
597
|
-
const
|
|
779
|
+
const snapshot = snapshotGpuContract(manifest);
|
|
780
|
+
const core = Object.fromEntries(Object.entries(snapshot).filter(
|
|
598
781
|
([key]) => key !== "validationEvidence" && key !== "additionalValidationEvidence"
|
|
599
782
|
));
|
|
600
783
|
return computeSha256(
|
|
@@ -974,11 +1157,10 @@ var stages = ["vertex", "fragment", "compute"];
|
|
|
974
1157
|
var roles = ["material", "lighting", "outline", "shadow", "post-processing"];
|
|
975
1158
|
function detachedJson(value, path2) {
|
|
976
1159
|
try {
|
|
977
|
-
return
|
|
1160
|
+
return snapshotGpuContract(value);
|
|
978
1161
|
} catch (cause) {
|
|
979
|
-
const detail = cause instanceof
|
|
980
|
-
|
|
981
|
-
throw new TypeError(`${path2} must contain detached JSON contract data: ${boundedDetail}`, { cause });
|
|
1162
|
+
const detail = cause instanceof GpuContractSnapshotError ? ` ${cause.message}` : "";
|
|
1163
|
+
throw new TypeError(`${path2} must contain bounded detached JSON contract data.${detail}`);
|
|
982
1164
|
}
|
|
983
1165
|
}
|
|
984
1166
|
function object(value, path2) {
|
|
@@ -988,7 +1170,7 @@ function object(value, path2) {
|
|
|
988
1170
|
function exact(value, keys2, path2) {
|
|
989
1171
|
const allowed = new Set(keys2);
|
|
990
1172
|
for (const key of Object.keys(value)) if (!allowed.has(key)) throw new TypeError(`${path2}.${key} is not part of this contract version.`);
|
|
991
|
-
for (const key of keys2) if (!(key
|
|
1173
|
+
for (const key of keys2) if (!Object.hasOwn(value, key)) throw new TypeError(`${path2}.${key} is required.`);
|
|
992
1174
|
}
|
|
993
1175
|
function text(value, path2, maximum = 512) {
|
|
994
1176
|
if (typeof value !== "string" || value.length === 0 || value.length > maximum || [...value].some((character) => character.charCodeAt(0) <= 31)) {
|
|
@@ -1004,11 +1186,8 @@ function token(value, path2) {
|
|
|
1004
1186
|
function immutableVersion(value, path2) {
|
|
1005
1187
|
try {
|
|
1006
1188
|
return assertImmutableAssetVersion(value);
|
|
1007
|
-
} catch
|
|
1008
|
-
throw new TypeError(
|
|
1009
|
-
`${path2} must be an immutable asset version: exact token required; mutable aliases, ranges, wildcards, and URLs are not allowed.`,
|
|
1010
|
-
{ cause }
|
|
1011
|
-
);
|
|
1189
|
+
} catch {
|
|
1190
|
+
throw new TypeError(`${path2} must be an immutable asset version: exact token required; mutable aliases, ranges, wildcards, and URLs are not allowed.`);
|
|
1012
1191
|
}
|
|
1013
1192
|
}
|
|
1014
1193
|
function enumeration(value, values, path2) {
|
|
@@ -1038,8 +1217,8 @@ function nullableToken(value, path2) {
|
|
|
1038
1217
|
function digest(value, path2) {
|
|
1039
1218
|
try {
|
|
1040
1219
|
return asSha256Hex(text(value, path2, 64));
|
|
1041
|
-
} catch
|
|
1042
|
-
throw new TypeError(`${path2} must be a lowercase SHA-256 digest
|
|
1220
|
+
} catch {
|
|
1221
|
+
throw new TypeError(`${path2} must be a lowercase SHA-256 digest.`);
|
|
1043
1222
|
}
|
|
1044
1223
|
}
|
|
1045
1224
|
function uri(value, path2) {
|
|
@@ -1047,8 +1226,8 @@ function uri(value, path2) {
|
|
|
1047
1226
|
let parsed;
|
|
1048
1227
|
try {
|
|
1049
1228
|
parsed = new URL(result);
|
|
1050
|
-
} catch
|
|
1051
|
-
throw new TypeError(`${path2} must be an absolute immutable asset URI
|
|
1229
|
+
} catch {
|
|
1230
|
+
throw new TypeError(`${path2} must be an absolute immutable asset URI.`);
|
|
1052
1231
|
}
|
|
1053
1232
|
if (parsed.protocol !== "https:" || parsed.username || parsed.password || parsed.hash) throw new TypeError(`${path2} must be credential-free HTTPS without a fragment.`);
|
|
1054
1233
|
const keys2 = [...parsed.searchParams.keys()].map((key) => key.toLowerCase());
|
|
@@ -1892,7 +2071,7 @@ function freezeJson(value) {
|
|
|
1892
2071
|
}
|
|
1893
2072
|
function exactKeys(value, keys2) {
|
|
1894
2073
|
const expected = new Set(keys2);
|
|
1895
|
-
return Object.keys(value).every((key) => expected.has(key)) && keys2.every((key) => key
|
|
2074
|
+
return Object.keys(value).every((key) => expected.has(key)) && keys2.every((key) => Object.hasOwn(value, key));
|
|
1896
2075
|
}
|
|
1897
2076
|
function safeToken(value) {
|
|
1898
2077
|
return typeof value === "string" && /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,159}$/u.test(value) && !value.includes("..");
|
|
@@ -1916,13 +2095,13 @@ function validSha(value) {
|
|
|
1916
2095
|
function validateCompileUnitInventory(value) {
|
|
1917
2096
|
let snapshot;
|
|
1918
2097
|
try {
|
|
1919
|
-
snapshot =
|
|
1920
|
-
} catch
|
|
2098
|
+
snapshot = snapshotGpuContract(value, QUALIFICATION_GPU_CONTRACT_SNAPSHOT_LIMITS);
|
|
2099
|
+
} catch {
|
|
1921
2100
|
return {
|
|
1922
2101
|
ok: false,
|
|
1923
2102
|
diagnostics: [issue(
|
|
1924
2103
|
"invalid-contract",
|
|
1925
|
-
|
|
2104
|
+
"Compile-unit inventory must contain bounded detached JSON contract data."
|
|
1926
2105
|
)]
|
|
1927
2106
|
};
|
|
1928
2107
|
}
|
|
@@ -2163,9 +2342,9 @@ function object3(value, path2) {
|
|
|
2163
2342
|
}
|
|
2164
2343
|
function detachedJson2(value, label) {
|
|
2165
2344
|
try {
|
|
2166
|
-
return
|
|
2167
|
-
} catch
|
|
2168
|
-
throw new TypeError(`${label} must contain detached JSON contract data
|
|
2345
|
+
return snapshotGpuContract(value, QUALIFICATION_GPU_CONTRACT_SNAPSHOT_LIMITS);
|
|
2346
|
+
} catch {
|
|
2347
|
+
throw new TypeError(`${label} must contain bounded detached JSON contract data.`);
|
|
2169
2348
|
}
|
|
2170
2349
|
}
|
|
2171
2350
|
function freezeJson2(value) {
|
|
@@ -2175,7 +2354,7 @@ function freezeJson2(value) {
|
|
|
2175
2354
|
}
|
|
2176
2355
|
function exact2(value, keys2, path2) {
|
|
2177
2356
|
const expected = new Set(keys2);
|
|
2178
|
-
if (!Object.keys(value).every((key) => expected.has(key)) || !keys2.every((key) => key
|
|
2357
|
+
if (!Object.keys(value).every((key) => expected.has(key)) || !keys2.every((key) => Object.hasOwn(value, key))) throw new TypeError(`${path2} has unknown or missing fields.`);
|
|
2179
2358
|
}
|
|
2180
2359
|
function token2(value, path2) {
|
|
2181
2360
|
if (typeof value !== "string" || !TOKEN.test(value) || value.includes("..")) throw new TypeError(`${path2} must be a safe token.`);
|
|
@@ -2184,11 +2363,8 @@ function token2(value, path2) {
|
|
|
2184
2363
|
function immutableVersion3(value, path2) {
|
|
2185
2364
|
try {
|
|
2186
2365
|
return assertImmutableAssetVersion(value);
|
|
2187
|
-
} catch
|
|
2188
|
-
throw new TypeError(
|
|
2189
|
-
`${path2} must be an immutable asset version: exact token required; mutable aliases, ranges, wildcards, and URLs are not allowed.`,
|
|
2190
|
-
{ cause }
|
|
2191
|
-
);
|
|
2366
|
+
} catch {
|
|
2367
|
+
throw new TypeError(`${path2} must be an immutable asset version: exact token required; mutable aliases, ranges, wildcards, and URLs are not allowed.`);
|
|
2192
2368
|
}
|
|
2193
2369
|
}
|
|
2194
2370
|
function path(value, label, extensions) {
|
|
@@ -2200,8 +2376,8 @@ function path(value, label, extensions) {
|
|
|
2200
2376
|
function sha(value, label) {
|
|
2201
2377
|
try {
|
|
2202
2378
|
return asSha256Hex(String(value));
|
|
2203
|
-
} catch
|
|
2204
|
-
throw new TypeError(`${label} must be a lowercase SHA-256 digest
|
|
2379
|
+
} catch {
|
|
2380
|
+
throw new TypeError(`${label} must be a lowercase SHA-256 digest.`);
|
|
2205
2381
|
}
|
|
2206
2382
|
}
|
|
2207
2383
|
function integer4(value, label, minimum = 0, maximum = 4294967295) {
|
|
@@ -2325,6 +2501,7 @@ function jsonValue(value, label, depth = 0) {
|
|
|
2325
2501
|
}
|
|
2326
2502
|
function validateQualificationFixture(value, unit) {
|
|
2327
2503
|
try {
|
|
2504
|
+
const compileUnit = unit === void 0 ? void 0 : detachedJson2(unit, "compile unit");
|
|
2328
2505
|
const fixture = object3(detachedJson2(value, "fixture"), "fixture");
|
|
2329
2506
|
exact2(fixture, ["contractVersion", "fixtureId", "resources", "bindGroups", "commands", "layoutProbes", "readbacks", "bounds"], "fixture");
|
|
2330
2507
|
if (fixture.contractVersion !== SHADER_QUALIFICATION_FIXTURE_VERSION) throw new TypeError("Unsupported qualification fixture version.");
|
|
@@ -2455,14 +2632,14 @@ function validateQualificationFixture(value, unit) {
|
|
|
2455
2632
|
unique2(bindingIds, `${label}.entries`);
|
|
2456
2633
|
bindGroups.set(id, { group: groupIndex, entries: parsedEntries });
|
|
2457
2634
|
}
|
|
2458
|
-
const pipelines = new Map(
|
|
2635
|
+
const pipelines = new Map(compileUnit?.pipelines.map((pipeline2) => [pipeline2.pipelineId, pipeline2]) ?? []);
|
|
2459
2636
|
const pipelineIds = new Set(pipelines.keys());
|
|
2460
2637
|
const commandBindGroups = (value2, pipelineId, label) => {
|
|
2461
2638
|
const ids = boundedArray(value2, label, 32).map((item, index) => token2(item, `${label}[${index}]`));
|
|
2462
2639
|
unique2(ids, label);
|
|
2463
2640
|
const pipeline2 = pipelines.get(pipelineId);
|
|
2464
2641
|
if (!pipeline2) {
|
|
2465
|
-
if (
|
|
2642
|
+
if (compileUnit) throw new TypeError(`${label} pipeline is missing.`);
|
|
2466
2643
|
return;
|
|
2467
2644
|
}
|
|
2468
2645
|
const expectedGroups = [...pipeline2.layout.bindGroups].sort((left, right) => left.group - right.group);
|
|
@@ -2487,7 +2664,7 @@ function validateQualificationFixture(value, unit) {
|
|
|
2487
2664
|
executionCommands += 1;
|
|
2488
2665
|
exact2(command, ["kind", "pipelineId", "bindGroupIds", "workgroups"], label);
|
|
2489
2666
|
const id = token2(command.pipelineId, `${label}.pipelineId`);
|
|
2490
|
-
if (
|
|
2667
|
+
if (compileUnit && pipelines.get(id)?.kind !== "compute") throw new TypeError(`${label} references a missing or non-compute pipeline.`);
|
|
2491
2668
|
commandBindGroups(command.bindGroupIds, id, `${label}.bindGroupIds`);
|
|
2492
2669
|
const workgroups = tuple(command.workgroups, `${label}.workgroups`, 3, 1);
|
|
2493
2670
|
if (workgroups[0] * workgroups[1] * workgroups[2] > 1048576) throw new TypeError(`${label}.workgroups exceeds the hard dispatch bound.`);
|
|
@@ -8867,7 +9044,7 @@ function validatePipelineInterfaces(input) {
|
|
|
8867
9044
|
// package.json
|
|
8868
9045
|
var package_default = {
|
|
8869
9046
|
name: "@plasius/gpu-shader",
|
|
8870
|
-
version: "0.1.
|
|
9047
|
+
version: "0.1.4",
|
|
8871
9048
|
description: "Reflection-first WebGPU WGSL interfaces, CPU codecs, compatibility validation, style profiles, and qualification tooling",
|
|
8872
9049
|
type: "module",
|
|
8873
9050
|
sideEffects: false,
|
|
@@ -8912,6 +9089,7 @@ var package_default = {
|
|
|
8912
9089
|
"audit:npm": "npm audit --audit-level=high --omit=dev",
|
|
8913
9090
|
"audit:test": "vitest run --coverage",
|
|
8914
9091
|
"pack:check": "node scripts/verify-public-package.cjs",
|
|
9092
|
+
"privacy:check": "node scripts/verify-public-artifacts.cjs --source-only",
|
|
8915
9093
|
"harness:fingerprint": "node scripts/fingerprint-trusted-harness.cjs .",
|
|
8916
9094
|
"shader:matrix": "npm run build && node dist/cli.js validate-matrix --matrix matrices/stable-webgpu-2026-07-13.json",
|
|
8917
9095
|
prepare: "npm run build",
|
|
@@ -8940,25 +9118,29 @@ var package_default = {
|
|
|
8940
9118
|
wgsl_reflect: "1.5.0"
|
|
8941
9119
|
},
|
|
8942
9120
|
optionalDependencies: {
|
|
8943
|
-
"playwright-core": "1.
|
|
9121
|
+
"playwright-core": "1.62.1"
|
|
8944
9122
|
},
|
|
8945
9123
|
devDependencies: {
|
|
8946
9124
|
"@eslint/js": "^10.0.1",
|
|
8947
|
-
"@types/node": "^26.0
|
|
8948
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
8949
|
-
"@typescript-eslint/parser": "^8.
|
|
8950
|
-
"@vitest/coverage-v8": "^4.1.
|
|
8951
|
-
eslint: "^10.
|
|
8952
|
-
globals: "^17.
|
|
9125
|
+
"@types/node": "^26.4.0",
|
|
9126
|
+
"@typescript-eslint/eslint-plugin": "^8.69.0",
|
|
9127
|
+
"@typescript-eslint/parser": "^8.69.0",
|
|
9128
|
+
"@vitest/coverage-v8": "^4.1.11",
|
|
9129
|
+
eslint: "^10.9.1",
|
|
9130
|
+
globals: "^17.11.0",
|
|
8953
9131
|
rimraf: "^6.1.3",
|
|
8954
9132
|
tsup: "^8.5.1",
|
|
8955
9133
|
typescript: "^6.0.3",
|
|
8956
|
-
vitest: "^4.1.
|
|
9134
|
+
vitest: "^4.1.11"
|
|
8957
9135
|
},
|
|
8958
9136
|
publishConfig: {
|
|
8959
9137
|
access: "public"
|
|
8960
9138
|
},
|
|
8961
9139
|
overrides: {
|
|
9140
|
+
nanoid: "3.3.18",
|
|
9141
|
+
postcss: "8.5.26",
|
|
9142
|
+
"brace-expansion": "5.0.9",
|
|
9143
|
+
esbuild: "^0.28.1",
|
|
8962
9144
|
minimatch: "^10.2.1"
|
|
8963
9145
|
},
|
|
8964
9146
|
engines: {
|
|
@@ -10130,7 +10312,37 @@ function object4(value, path2) {
|
|
|
10130
10312
|
}
|
|
10131
10313
|
function exact3(value, keys2, path2) {
|
|
10132
10314
|
const expected = new Set(keys2);
|
|
10133
|
-
if (!Object.keys(value).every((key) => expected.has(key)) || !keys2.every((key) => key
|
|
10315
|
+
if (!Object.keys(value).every((key) => expected.has(key)) || !keys2.every((key) => Object.hasOwn(value, key))) throw new TypeError(`${path2} has unknown or missing fields.`);
|
|
10316
|
+
}
|
|
10317
|
+
function detachedQualificationContract(value) {
|
|
10318
|
+
try {
|
|
10319
|
+
return snapshotGpuContract(value, QUALIFICATION_GPU_CONTRACT_SNAPSHOT_LIMITS);
|
|
10320
|
+
} catch {
|
|
10321
|
+
throw new TypeError("Qualification data must contain bounded detached JSON contract data.");
|
|
10322
|
+
}
|
|
10323
|
+
}
|
|
10324
|
+
function parseQualificationJsonBytes(bytes2, label) {
|
|
10325
|
+
let snapshot;
|
|
10326
|
+
try {
|
|
10327
|
+
snapshot = snapshotUint8Array(
|
|
10328
|
+
bytes2,
|
|
10329
|
+
QUALIFICATION_GPU_CONTRACT_SNAPSHOT_LIMITS.maximumInputBytes
|
|
10330
|
+
);
|
|
10331
|
+
} catch {
|
|
10332
|
+
throw new TypeError(`${label} is not bounded UTF-8 JSON.`);
|
|
10333
|
+
}
|
|
10334
|
+
let parsed;
|
|
10335
|
+
try {
|
|
10336
|
+
parsed = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(snapshot));
|
|
10337
|
+
} catch {
|
|
10338
|
+
throw new TypeError(`${label} is not valid UTF-8 JSON.`);
|
|
10339
|
+
}
|
|
10340
|
+
return detachedQualificationContract(parsed);
|
|
10341
|
+
}
|
|
10342
|
+
function freezeJson3(value) {
|
|
10343
|
+
if (typeof value !== "object" || value === null || Object.isFrozen(value)) return value;
|
|
10344
|
+
for (const child of Object.values(value)) freezeJson3(child);
|
|
10345
|
+
return Object.freeze(value);
|
|
10134
10346
|
}
|
|
10135
10347
|
function token3(value, path2, maximum = 512) {
|
|
10136
10348
|
if (typeof value !== "string" || value.length === 0 || value.length > maximum || [...value].some((character) => character.charCodeAt(0) <= 31)) throw new TypeError(`${path2} is not a bounded string.`);
|
|
@@ -10139,8 +10351,8 @@ function token3(value, path2, maximum = 512) {
|
|
|
10139
10351
|
function sha2(value, path2) {
|
|
10140
10352
|
try {
|
|
10141
10353
|
return asSha256Hex(token3(value, path2, 64));
|
|
10142
|
-
} catch
|
|
10143
|
-
throw new TypeError(`${path2} is not a SHA-256 digest
|
|
10354
|
+
} catch {
|
|
10355
|
+
throw new TypeError(`${path2} is not a SHA-256 digest.`);
|
|
10144
10356
|
}
|
|
10145
10357
|
}
|
|
10146
10358
|
function integer5(value, path2, minimum = 0) {
|
|
@@ -10173,7 +10385,7 @@ function trustedWorkflowRef(value, path2) {
|
|
|
10173
10385
|
return result;
|
|
10174
10386
|
}
|
|
10175
10387
|
function parseTrustedWorkflowProvenance(value, path2 = "provenance") {
|
|
10176
|
-
const input = object4(value, path2);
|
|
10388
|
+
const input = object4(detachedQualificationContract(value), path2);
|
|
10177
10389
|
exact3(input, ["repository", "commit", "ref", "workflowRef", "workflowSha", "runId", "runAttempt", "job", "eventName", "oidcAttestation"], path2);
|
|
10178
10390
|
const repository = token3(input.repository, `${path2}.repository`);
|
|
10179
10391
|
if (!repository.startsWith("Plasius-LTD/")) throw new TypeError(`${path2}.repository is outside Plasius-LTD.`);
|
|
@@ -10192,10 +10404,10 @@ function parseTrustedWorkflowProvenance(value, path2 = "provenance") {
|
|
|
10192
10404
|
token3(oidc.audience, `${path2}.oidcAttestation.audience`, 2048);
|
|
10193
10405
|
sha2(oidc.verifiedClaimsSha256, `${path2}.oidcAttestation.verifiedClaimsSha256`);
|
|
10194
10406
|
timestamp(oidc.verifiedAt, `${path2}.oidcAttestation.verifiedAt`);
|
|
10195
|
-
return input;
|
|
10407
|
+
return freezeJson3(input);
|
|
10196
10408
|
}
|
|
10197
10409
|
function parseQualificationExecutionProducer(value, path2 = "producer") {
|
|
10198
|
-
const input = object4(value, path2);
|
|
10410
|
+
const input = object4(detachedQualificationContract(value), path2);
|
|
10199
10411
|
exact3(input, ["repository", "commit", "ref", "runId", "runAttempt", "job", "trustedWorkflowRepository", "trustedWorkflowRef", "trustedWorkflowSha", "runner"], path2);
|
|
10200
10412
|
const repository = token3(input.repository, `${path2}.repository`);
|
|
10201
10413
|
if (!repository.startsWith("Plasius-LTD/")) throw new TypeError(`${path2}.repository is outside Plasius-LTD.`);
|
|
@@ -10213,7 +10425,7 @@ function parseQualificationExecutionProducer(value, path2 = "producer") {
|
|
|
10213
10425
|
if (!["github-hosted", "self-hosted", "device-farm"].includes(String(runner.environment))) throw new TypeError(`${path2}.runner.environment is invalid.`);
|
|
10214
10426
|
token3(runner.os, `${path2}.runner.os`);
|
|
10215
10427
|
token3(runner.architecture, `${path2}.runner.architecture`);
|
|
10216
|
-
return input;
|
|
10428
|
+
return freezeJson3(input);
|
|
10217
10429
|
}
|
|
10218
10430
|
function assertProducerMatchesPreflight(producer, provenance, cell, path2, expectedJob) {
|
|
10219
10431
|
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.`);
|
|
@@ -10222,26 +10434,32 @@ function assertProducerMatchesPreflight(producer, provenance, cell, path2, expec
|
|
|
10222
10434
|
if (expectedJob === "physical-runner-preflight" && producer.runner.environment !== "github-hosted") throw new TypeError(`${path2} must identify its hosted orchestration job truthfully.`);
|
|
10223
10435
|
}
|
|
10224
10436
|
function canonicalEqual(left, right) {
|
|
10225
|
-
return
|
|
10437
|
+
return canonicalizeQualificationGpuContract(left) === canonicalizeQualificationGpuContract(right);
|
|
10226
10438
|
}
|
|
10227
10439
|
function foldRunnerLabel(value) {
|
|
10228
10440
|
return value.replace(/[A-Z]/gu, (character) => character.toLowerCase());
|
|
10229
10441
|
}
|
|
10230
10442
|
async function computeQualificationInventorySha256(bundle) {
|
|
10231
|
-
|
|
10443
|
+
const snapshot = detachedQualificationContract(bundle);
|
|
10444
|
+
return computeSha256(canonicalizeQualificationGpuContract(snapshot.inventory));
|
|
10232
10445
|
}
|
|
10233
10446
|
async function computeQualificationSubjectBinding(input) {
|
|
10234
10447
|
return computeSha256(`plasius.gpu.qualification-subject/v1
|
|
10235
|
-
${
|
|
10448
|
+
${canonicalizeQualificationGpuContract(input)}`);
|
|
10236
10449
|
}
|
|
10237
10450
|
async function computeValidationEvidenceId(value) {
|
|
10238
10451
|
const input = object4(value, "evidence identity input");
|
|
10239
10452
|
const projection = Object.fromEntries(Object.entries(input).filter(([key]) => key !== "evidenceId"));
|
|
10240
10453
|
return `qualification-${(await computeSha256(`plasius.gpu.validation-evidence/v1
|
|
10241
|
-
${
|
|
10454
|
+
${canonicalizeQualificationGpuContract(projection)}`)).slice(0, 24)}`;
|
|
10242
10455
|
}
|
|
10243
10456
|
function immutableBlobUri(value) {
|
|
10244
|
-
|
|
10457
|
+
let url;
|
|
10458
|
+
try {
|
|
10459
|
+
url = new URL(value);
|
|
10460
|
+
} catch {
|
|
10461
|
+
throw new TypeError("Source URI must be a normalized immutable Azure Blob .tar URL.");
|
|
10462
|
+
}
|
|
10245
10463
|
if (url.protocol !== "https:" || url.username || url.password || url.hash || url.port || !/^[a-z0-9]{3,24}\.blob\.core\.windows\.net$/u.test(url.hostname) || !/^[A-Za-z0-9][A-Za-z0-9._/-]*\.tar$/u.test(url.pathname.slice(1)) || url.pathname.split("/").some((segment, index) => index > 0 && (!segment || segment === "." || segment === ".."))) {
|
|
10246
10464
|
throw new TypeError("Source URI must be a normalized immutable Azure Blob .tar URL.");
|
|
10247
10465
|
}
|
|
@@ -10251,12 +10469,7 @@ function immutableBlobUri(value) {
|
|
|
10251
10469
|
}
|
|
10252
10470
|
async function createQualificationPreflight(input) {
|
|
10253
10471
|
token3(input.qualificationId, "qualificationId");
|
|
10254
|
-
|
|
10255
|
-
try {
|
|
10256
|
-
parsedMatrix = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(input.matrixBytes));
|
|
10257
|
-
} catch (cause) {
|
|
10258
|
-
throw new TypeError("Selected matrix artifact is not UTF-8 JSON.", { cause });
|
|
10259
|
-
}
|
|
10472
|
+
const parsedMatrix = parseQualificationJsonBytes(input.matrixBytes, "Selected matrix artifact");
|
|
10260
10473
|
if (!canonicalEqual(parsedMatrix, input.matrix)) throw new TypeError("Selected matrix artifact bytes differ from the supplied matrix value.");
|
|
10261
10474
|
const actualMatrixSha256 = await computeSha256(input.matrixBytes);
|
|
10262
10475
|
if (actualMatrixSha256 !== input.matrixSha256) throw new TypeError("Selected matrix digest is not derived from the exact matrix manifest.");
|
|
@@ -10426,12 +10639,7 @@ function syntheticResult(unitId, cell, status, message, now) {
|
|
|
10426
10639
|
async function aggregateShaderValidationEvidence(input) {
|
|
10427
10640
|
const verifyArtifact = async (artifact2, label) => {
|
|
10428
10641
|
if (await computeSha256(artifact2.bytes) !== artifact2.sha256) throw new TypeError(`${label} artifact digest is not derived from its exact bytes.`);
|
|
10429
|
-
|
|
10430
|
-
try {
|
|
10431
|
-
parsed = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(artifact2.bytes));
|
|
10432
|
-
} catch (cause) {
|
|
10433
|
-
throw new TypeError(`${label} bytes are not UTF-8 JSON.`, { cause });
|
|
10434
|
-
}
|
|
10642
|
+
const parsed = parseQualificationJsonBytes(artifact2.bytes, `${label} bytes`);
|
|
10435
10643
|
if (!canonicalEqual(parsed, artifact2.value)) throw new TypeError(`${label} parsed value differs from its exact bytes.`);
|
|
10436
10644
|
};
|
|
10437
10645
|
await verifyArtifact(input.preflight, "Qualification preflight");
|
|
@@ -10453,12 +10661,7 @@ async function aggregateShaderValidationEvidence(input) {
|
|
|
10453
10661
|
exact3(sourceBlob, ["host", "versionId", "uri"], "Qualification preflight.sourceBlob");
|
|
10454
10662
|
const normalizedSource = immutableBlobUri(token3(sourceBlob.uri, "Qualification preflight.sourceBlob.uri", 2048));
|
|
10455
10663
|
if (!canonicalEqual(sourceBlob, normalizedSource)) throw new TypeError("Qualification preflight source Blob claims are stale.");
|
|
10456
|
-
|
|
10457
|
-
try {
|
|
10458
|
-
parsedMatrix = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(input.matrixBytes));
|
|
10459
|
-
} catch (cause) {
|
|
10460
|
-
throw new TypeError("Matrix artifact is not UTF-8 JSON.", { cause });
|
|
10461
|
-
}
|
|
10664
|
+
const parsedMatrix = parseQualificationJsonBytes(input.matrixBytes, "Matrix artifact");
|
|
10462
10665
|
if (!canonicalEqual(parsedMatrix, input.matrix)) throw new TypeError("Matrix artifact bytes differ from the supplied matrix value.");
|
|
10463
10666
|
const actualMatrixSha256 = await computeSha256(input.matrixBytes);
|
|
10464
10667
|
if (preflight.matrixSha256 !== actualMatrixSha256) throw new TypeError("Qualification preflight matrix artifact digest is stale.");
|
|
@@ -10532,7 +10735,7 @@ async function aggregateShaderValidationEvidence(input) {
|
|
|
10532
10735
|
if (cellArtifact || diagnostic) throw new TypeError(`Unavailable cell ${cell.cellId} has conflicting evidence.`);
|
|
10533
10736
|
for (const unit of units) results.push(syntheticResult(unit, cell, "runner-unavailable", "Required physical runner was unavailable.", now));
|
|
10534
10737
|
const cellResults = results.slice(-units.size);
|
|
10535
|
-
cellRuns.push({ cellId: cell.cellId, source: "runner-preflight", sourceArtifactSha256: runner.sha256, resultsSha256: await computeSha256(
|
|
10738
|
+
cellRuns.push({ cellId: cell.cellId, source: "runner-preflight", sourceArtifactSha256: runner.sha256, resultsSha256: await computeSha256(canonicalizeQualificationGpuContract(cellResults)), qualificationPreflightProvenance: preflight.provenance, producer: runner.value.producer, harness: input.harness, automation: null, resultCount: units.size, status: "runner-unavailable" });
|
|
10536
10739
|
continue;
|
|
10537
10740
|
}
|
|
10538
10741
|
if (diagnostic) {
|
|
@@ -10547,7 +10750,7 @@ async function aggregateShaderValidationEvidence(input) {
|
|
|
10547
10750
|
const status2 = value2.status === "timeout" ? "timeout" : "failed";
|
|
10548
10751
|
for (const unit of units) results.push(syntheticResult(unit, cell, status2, value2.message, now));
|
|
10549
10752
|
const cellResults = results.slice(-units.size);
|
|
10550
|
-
cellRuns.push({ cellId: cell.cellId, source: "workflow-diagnostic", sourceArtifactSha256: diagnostic.sha256, resultsSha256: await computeSha256(
|
|
10753
|
+
cellRuns.push({ cellId: cell.cellId, source: "workflow-diagnostic", sourceArtifactSha256: diagnostic.sha256, resultsSha256: await computeSha256(canonicalizeQualificationGpuContract(cellResults)), qualificationPreflightProvenance: preflight.provenance, producer: value2.producer, harness: input.harness, automation: null, resultCount: units.size, status: status2 });
|
|
10551
10754
|
continue;
|
|
10552
10755
|
}
|
|
10553
10756
|
if (!cellArtifact) throw new TypeError(`Cell ${cell.cellId} has no qualification evidence.`);
|
|
@@ -10555,7 +10758,7 @@ async function aggregateShaderValidationEvidence(input) {
|
|
|
10555
10758
|
if (!matchedRunner) throw new TypeError(`Cell evidence ${cell.cellId} producer was not matched by runner preflight.`);
|
|
10556
10759
|
const value = assertCellEvidence(cellArtifact.value, cell, input.matrix, preflight, input.harness, runner.value.adapterHarness, matchedRunner, units, now);
|
|
10557
10760
|
results.push(...value.results);
|
|
10558
|
-
cellRuns.push({ cellId: cell.cellId, source: "cell-evidence", sourceArtifactSha256: cellArtifact.sha256, resultsSha256: await computeSha256(
|
|
10761
|
+
cellRuns.push({ cellId: cell.cellId, source: "cell-evidence", sourceArtifactSha256: cellArtifact.sha256, resultsSha256: await computeSha256(canonicalizeQualificationGpuContract(value.results)), qualificationPreflightProvenance: value.qualificationPreflightProvenance, producer: value.producer, harness: value.harness, automation: value.automation, resultCount: value.results.length, status: "passed" });
|
|
10559
10762
|
}
|
|
10560
10763
|
const expectedResults = units.size * cells.size;
|
|
10561
10764
|
if (results.length !== expectedResults) throw new TypeError("Aggregate result product is incomplete.");
|
|
@@ -10578,34 +10781,31 @@ async function aggregateShaderValidationEvidence(input) {
|
|
|
10578
10781
|
}
|
|
10579
10782
|
async function validateShaderValidationEvidence(input) {
|
|
10580
10783
|
try {
|
|
10581
|
-
const evidence = object4(input.evidence, "evidence");
|
|
10784
|
+
const evidence = object4(detachedQualificationContract(input.evidence), "evidence");
|
|
10785
|
+
const bundle = detachedQualificationContract(input.bundle);
|
|
10786
|
+
const matrix = detachedQualificationContract(input.matrix);
|
|
10582
10787
|
exact3(evidence, ["contractVersion", "evidenceId", "status", "generatedAt", "subjectBindingSha256", "subject", "matrixRef", "toolchain", "qualificationPreflightProvenance", "counts", "cellRuns", "results"], "evidence");
|
|
10583
10788
|
if (evidence.contractVersion !== SHADER_VALIDATION_EVIDENCE_VERSION) throw new TypeError("Unsupported evidence contract version.");
|
|
10584
10789
|
const evidenceId = token3(evidence.evidenceId, "evidence.evidenceId");
|
|
10585
10790
|
const generatedAt = timestamp(evidence.generatedAt, "evidence.generatedAt");
|
|
10586
10791
|
const subjectBindingSha256 = sha2(evidence.subjectBindingSha256, "evidence.subjectBindingSha256");
|
|
10587
10792
|
if (evidence.status !== "passed" && evidence.status !== "failed") throw new TypeError("Evidence status is invalid.");
|
|
10588
|
-
|
|
10589
|
-
|
|
10590
|
-
parsedMatrix = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(input.matrixBytes));
|
|
10591
|
-
} catch (cause) {
|
|
10592
|
-
throw new TypeError("Matrix artifact is not UTF-8 JSON.", { cause });
|
|
10593
|
-
}
|
|
10594
|
-
if (!canonicalEqual(parsedMatrix, input.matrix)) throw new TypeError("Matrix artifact bytes differ from the supplied matrix value.");
|
|
10793
|
+
const parsedMatrix = parseQualificationJsonBytes(input.matrixBytes, "Matrix artifact");
|
|
10794
|
+
if (!canonicalEqual(parsedMatrix, matrix)) throw new TypeError("Matrix artifact bytes differ from the supplied matrix value.");
|
|
10595
10795
|
const matrixSha256 = await computeSha256(input.matrixBytes);
|
|
10596
|
-
const inventorySha256 = await computeQualificationInventorySha256(
|
|
10597
|
-
if (inventorySha256 !==
|
|
10796
|
+
const inventorySha256 = await computeQualificationInventorySha256(bundle);
|
|
10797
|
+
if (inventorySha256 !== bundle.subject.compileUnitInventorySha256) throw new TypeError("Bundle subject inventory digest is stale.");
|
|
10598
10798
|
const subject = object4(evidence.subject, "evidence.subject");
|
|
10599
|
-
const expectedSubjectKeys = [...Object.keys(
|
|
10799
|
+
const expectedSubjectKeys = [...Object.keys(bundle.subject), "dataBundleSha256"];
|
|
10600
10800
|
exact3(subject, expectedSubjectKeys, "evidence.subject");
|
|
10601
10801
|
const candidateSubject = Object.fromEntries(Object.entries(subject).filter(([key]) => key !== "dataBundleSha256"));
|
|
10602
|
-
if (!canonicalEqual(candidateSubject,
|
|
10802
|
+
if (!canonicalEqual(candidateSubject, bundle.subject)) throw new TypeError("Evidence candidate subject differs from bundle.");
|
|
10603
10803
|
const dataBundleSha256 = sha2(subject.dataBundleSha256, "evidence.subject.dataBundleSha256");
|
|
10604
10804
|
if (input.dataBundleSha256 && input.dataBundleSha256 !== dataBundleSha256) throw new TypeError("Evidence data bundle digest differs from the exact archive.");
|
|
10605
10805
|
if (subject.compileUnitInventorySha256 !== inventorySha256) throw new TypeError("Evidence compile-unit inventory digest is stale.");
|
|
10606
10806
|
const matrixRef = object4(evidence.matrixRef, "evidence.matrixRef");
|
|
10607
10807
|
exact3(matrixRef, ["matrixId", "version", "sha256"], "evidence.matrixRef");
|
|
10608
|
-
if (matrixRef.matrixId !==
|
|
10808
|
+
if (matrixRef.matrixId !== matrix.matrixId || matrixRef.version !== matrix.version || matrixRef.sha256 !== matrixSha256) throw new TypeError("Evidence matrix artifact identity differs.");
|
|
10609
10809
|
const toolchain = object4(evidence.toolchain, "evidence.toolchain");
|
|
10610
10810
|
exact3(toolchain, ["packageVersion", "reflectorVersion", "harness"], "evidence.toolchain");
|
|
10611
10811
|
token3(toolchain.packageVersion, "evidence.toolchain.packageVersion");
|
|
@@ -10617,11 +10817,11 @@ async function validateShaderValidationEvidence(input) {
|
|
|
10617
10817
|
const harnessSha256 = sha2(harness.sha256, "evidence.toolchain.harness.sha256");
|
|
10618
10818
|
const preflightProvenance = parseTrustedWorkflowProvenance(evidence.qualificationPreflightProvenance, "evidence.qualificationPreflightProvenance");
|
|
10619
10819
|
if (Date.parse(generatedAt) < Date.parse(preflightProvenance.oidcAttestation.verifiedAt)) throw new TypeError("Evidence predates trusted preflight verification.");
|
|
10620
|
-
const expectedBinding = await computeQualificationSubjectBinding({ subject:
|
|
10820
|
+
const expectedBinding = await computeQualificationSubjectBinding({ subject: bundle.subject, dataBundleSha256, compileUnitInventorySha256: inventorySha256, matrixSha256, harnessSha256 });
|
|
10621
10821
|
if (subjectBindingSha256 !== expectedBinding) throw new TypeError("Evidence subject binding is stale.");
|
|
10622
10822
|
if (evidenceId !== await computeValidationEvidenceId(evidence)) throw new TypeError("Evidence identity is stale.");
|
|
10623
|
-
const units = new Set(
|
|
10624
|
-
const cells = new Map(
|
|
10823
|
+
const units = new Set(bundle.inventory.compileUnits.map((unit) => unit.compileUnitId));
|
|
10824
|
+
const cells = new Map(matrix.cells.map((cell) => [cell.cellId, cell]));
|
|
10625
10825
|
const expected = units.size * cells.size;
|
|
10626
10826
|
const results = array2(evidence.results, "evidence.results");
|
|
10627
10827
|
if (results.length !== expected) throw new TypeError("Evidence result product is incomplete.");
|
|
@@ -10671,7 +10871,7 @@ async function validateShaderValidationEvidence(input) {
|
|
|
10671
10871
|
sha2(automation2.sha256, `${path2}.automation.sha256`);
|
|
10672
10872
|
} else if (run.automation !== null) throw new TypeError(`${path2}.automation must be null when no adapter completed a cell run.`);
|
|
10673
10873
|
const cellResults = parsedResults.filter((result) => result.cellId === cellId);
|
|
10674
|
-
if (run.resultCount !== units.size || cellResults.length !== units.size || await computeSha256(
|
|
10874
|
+
if (run.resultCount !== units.size || cellResults.length !== units.size || await computeSha256(canonicalizeQualificationGpuContract(cellResults)) !== resultsSha256) throw new TypeError(`${path2} result count/digest is stale.`);
|
|
10675
10875
|
const resultStatuses = new Set(cellResults.map((result) => result.status));
|
|
10676
10876
|
if (resultStatuses.size !== 1 || !resultStatuses.has(String(run.status))) throw new TypeError(`${path2}.status differs from its results.`);
|
|
10677
10877
|
if (run.source === "cell-evidence" && run.status !== "passed") throw new TypeError(`${path2} cell evidence must contain passing results.`);
|
|
@@ -10680,7 +10880,7 @@ async function validateShaderValidationEvidence(input) {
|
|
|
10680
10880
|
if (run.source === "cell-evidence" && cellResults.some((result) => result.observed.runner.id !== producer.runner.name)) throw new TypeError(`${path2} producer runner differs from its results.`);
|
|
10681
10881
|
}
|
|
10682
10882
|
if (evidence.status === "passed" !== (passed === expected) || input.requirePassed !== false && evidence.status !== "passed") throw new TypeError("Evidence does not satisfy the required passed gate.");
|
|
10683
|
-
return { ok: true, value: evidence };
|
|
10883
|
+
return { ok: true, value: freezeJson3(evidence) };
|
|
10684
10884
|
} catch (cause) {
|
|
10685
10885
|
return { ok: false, diagnostics: [{ code: "invalid-contract", severity: "error", message: cause instanceof Error ? cause.message : "Invalid shader validation evidence." }] };
|
|
10686
10886
|
}
|
|
@@ -10695,7 +10895,12 @@ function object5(value) {
|
|
|
10695
10895
|
}
|
|
10696
10896
|
function keys(value, expected) {
|
|
10697
10897
|
const set = new Set(expected);
|
|
10698
|
-
return Object.keys(value).every((key) => set.has(key)) && expected.every((key) => key
|
|
10898
|
+
return Object.keys(value).every((key) => set.has(key)) && expected.every((key) => Object.hasOwn(value, key));
|
|
10899
|
+
}
|
|
10900
|
+
function freezeJson4(value) {
|
|
10901
|
+
if (typeof value !== "object" || value === null || Object.isFrozen(value)) return value;
|
|
10902
|
+
for (const child of Object.values(value)) freezeJson4(child);
|
|
10903
|
+
return Object.freeze(value);
|
|
10699
10904
|
}
|
|
10700
10905
|
function canonicalEqual2(left, right) {
|
|
10701
10906
|
try {
|
|
@@ -10745,7 +10950,13 @@ var BASELINE = /* @__PURE__ */ new Map([
|
|
|
10745
10950
|
["win11-nvidia-edge-d3d12", "edge|windows|x64|physical|nvidia|qualified-nvidia|d3d12|playwright|self-hosted,Windows,X64,shader-validation,physical-gpu,gpu-nvidia,d3d12"]
|
|
10746
10951
|
]);
|
|
10747
10952
|
function validateStableWebGpuMatrix(value) {
|
|
10748
|
-
|
|
10953
|
+
let snapshot;
|
|
10954
|
+
try {
|
|
10955
|
+
snapshot = snapshotGpuContract(value);
|
|
10956
|
+
} catch {
|
|
10957
|
+
return { ok: false, diagnostics: [issue3("Matrix must contain bounded detached JSON contract data.")] };
|
|
10958
|
+
}
|
|
10959
|
+
const matrix = object5(snapshot);
|
|
10749
10960
|
const diagnostics = [];
|
|
10750
10961
|
if (!matrix || !keys(matrix, ["contractVersion", "matrixId", "version", "policy", "cells"])) {
|
|
10751
10962
|
return { ok: false, diagnostics: [issue3("Matrix has unknown or missing top-level fields.")] };
|
|
@@ -10818,7 +11029,7 @@ function validateStableWebGpuMatrix(value) {
|
|
|
10818
11029
|
}
|
|
10819
11030
|
}
|
|
10820
11031
|
if (physical !== 15 || blocking !== 16 || software !== 1 || ids.size !== BASELINE.size) diagnostics.push(issue3("Matrix must contain the exact 15 physical baseline cells plus one SwiftShader smoke cell."));
|
|
10821
|
-
return diagnostics.length > 0 ? { ok: false, diagnostics } : { ok: true, value: matrix };
|
|
11032
|
+
return diagnostics.length > 0 ? { ok: false, diagnostics } : { ok: true, value: freezeJson4(matrix) };
|
|
10822
11033
|
}
|
|
10823
11034
|
|
|
10824
11035
|
// src/testing/runner/playwright-swiftshader.ts
|
|
@@ -12127,9 +12338,6 @@ function error(code, message, path2) {
|
|
|
12127
12338
|
function interfaceMatches(item, model) {
|
|
12128
12339
|
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;
|
|
12129
12340
|
}
|
|
12130
|
-
function detachedContract(value) {
|
|
12131
|
-
return JSON.parse(canonicalizeGpuContract(value));
|
|
12132
|
-
}
|
|
12133
12341
|
function hasValidationEvidence(value) {
|
|
12134
12342
|
return typeof value === "object" && value !== null && !Array.isArray(value) && (Object.hasOwn(value, "validationEvidence") || Object.hasOwn(value, "additionalValidationEvidence"));
|
|
12135
12343
|
}
|
|
@@ -12177,16 +12385,25 @@ function validateModelShaderCompatibility(input) {
|
|
|
12177
12385
|
let profile;
|
|
12178
12386
|
let capabilities;
|
|
12179
12387
|
try {
|
|
12180
|
-
const
|
|
12181
|
-
|
|
12182
|
-
|
|
12183
|
-
|
|
12184
|
-
const
|
|
12388
|
+
const snapshot = snapshotGpuContract(input);
|
|
12389
|
+
if (typeof snapshot !== "object" || snapshot === null || Array.isArray(snapshot)) {
|
|
12390
|
+
throw new TypeError("GPU compatibility input must be a bounded contract object.");
|
|
12391
|
+
}
|
|
12392
|
+
const envelope = snapshot;
|
|
12393
|
+
const keys2 = Object.keys(envelope);
|
|
12394
|
+
const allowed = /* @__PURE__ */ new Set(["model", "shader", "gpuInterface", "profile", "capabilities"]);
|
|
12395
|
+
if (keys2.some((key) => !allowed.has(key)) || !["model", "shader", "gpuInterface"].every((key) => Object.hasOwn(envelope, key))) {
|
|
12396
|
+
throw new TypeError("GPU compatibility input has unknown or missing fields.");
|
|
12397
|
+
}
|
|
12398
|
+
const modelSnapshot = envelope.model;
|
|
12399
|
+
const shaderSnapshot = envelope.shader;
|
|
12400
|
+
const gpuInterfaceSnapshot = envelope.gpuInterface;
|
|
12401
|
+
const profileSnapshot = Object.hasOwn(envelope, "profile") ? envelope.profile : void 0;
|
|
12185
12402
|
model = parseModelGpuCompatibilityDescriptor(modelSnapshot);
|
|
12186
12403
|
shader = hasValidationEvidence(shaderSnapshot) ? parseShaderVersionManifest(shaderSnapshot) : parseShaderVersionManifestCore(shaderSnapshot);
|
|
12187
12404
|
gpuInterface = parseGpuInterfaceManifest(gpuInterfaceSnapshot);
|
|
12188
12405
|
profile = profileSnapshot === void 0 ? void 0 : parseShaderStyleProfileManifest(profileSnapshot);
|
|
12189
|
-
capabilities =
|
|
12406
|
+
capabilities = Object.hasOwn(envelope, "capabilities") ? envelope.capabilities : void 0;
|
|
12190
12407
|
} catch (cause) {
|
|
12191
12408
|
return {
|
|
12192
12409
|
ok: false,
|