@plasius/gpu-shader 0.1.2 → 0.1.3
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 +36 -0
- package/dist/cli.cjs +360 -147
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +360 -147
- 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 +235 -84
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +235 -84
- 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 +2 -1
package/dist/cli.js
CHANGED
|
@@ -11,63 +11,244 @@ import { readdir, readFile, lstat } from "fs/promises";
|
|
|
11
11
|
import { join, relative, resolve, sep } from "path";
|
|
12
12
|
|
|
13
13
|
// src/canonical-json.ts
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
var GPU_CONTRACT_SNAPSHOT_LIMITS = Object.freeze({
|
|
15
|
+
maximumDepth: 64,
|
|
16
|
+
maximumNodes: 262144,
|
|
17
|
+
maximumProperties: 131072,
|
|
18
|
+
maximumElements: 131072,
|
|
19
|
+
maximumArrayLength: 1e5,
|
|
20
|
+
maximumStringBytes: 1024 * 1024,
|
|
21
|
+
maximumAggregateStringBytes: 8 * 1024 * 1024,
|
|
22
|
+
maximumAggregateBytes: 16 * 1024 * 1024,
|
|
23
|
+
maximumInputBytes: 16 * 1024 * 1024
|
|
24
|
+
});
|
|
25
|
+
var QUALIFICATION_GPU_CONTRACT_SNAPSHOT_LIMITS = Object.freeze({
|
|
26
|
+
maximumDepth: 96,
|
|
27
|
+
maximumNodes: 4e6,
|
|
28
|
+
maximumProperties: 2e6,
|
|
29
|
+
maximumElements: 2e6,
|
|
30
|
+
maximumArrayLength: 25e4,
|
|
31
|
+
maximumStringBytes: 4 * 1024 * 1024,
|
|
32
|
+
maximumAggregateStringBytes: 128 * 1024 * 1024,
|
|
33
|
+
maximumAggregateBytes: 256 * 1024 * 1024,
|
|
34
|
+
maximumInputBytes: 256 * 1024 * 1024
|
|
35
|
+
});
|
|
36
|
+
var FAILURE_MESSAGES = Object.freeze({
|
|
37
|
+
"aggregate-bytes": "GPU contract snapshot exceeds the aggregate byte limit.",
|
|
38
|
+
"aggregate-string-bytes": "GPU contract snapshot exceeds the aggregate string byte limit.",
|
|
39
|
+
"array-length": "GPU contract snapshot exceeds the single-array element limit.",
|
|
40
|
+
cycle: "GPU contract snapshot contains a circular reference.",
|
|
41
|
+
depth: "GPU contract snapshot exceeds the nesting-depth limit.",
|
|
42
|
+
elements: "GPU contract snapshot exceeds the total element limit.",
|
|
43
|
+
inspection: "GPU contract snapshot rejected unsafe object inspection.",
|
|
44
|
+
nodes: "GPU contract snapshot exceeds the total node limit.",
|
|
45
|
+
"non-finite": "GPU contract snapshot contains a non-finite number.",
|
|
46
|
+
properties: "GPU contract snapshot exceeds the total property limit.",
|
|
47
|
+
shape: "GPU contract snapshot requires plain JSON objects with own enumerable data properties and dense arrays.",
|
|
48
|
+
"string-bytes": "GPU contract snapshot exceeds the individual string byte limit.",
|
|
49
|
+
unicode: "GPU contract snapshot contains an invalid Unicode scalar string or unpaired UTF-16 surrogate.",
|
|
50
|
+
value: "GPU contract snapshot contains undefined or another value that JSON cannot represent."
|
|
51
|
+
});
|
|
52
|
+
var GpuContractSnapshotError = class extends TypeError {
|
|
53
|
+
code;
|
|
54
|
+
constructor(code) {
|
|
55
|
+
super(FAILURE_MESSAGES[code]);
|
|
56
|
+
this.name = "GpuContractSnapshotError";
|
|
57
|
+
this.code = code;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
var TYPED_ARRAY_PROTOTYPE = Reflect.getPrototypeOf(Uint8Array.prototype);
|
|
61
|
+
var TYPED_ARRAY_BYTE_LENGTH = Reflect.getOwnPropertyDescriptor(
|
|
62
|
+
TYPED_ARRAY_PROTOTYPE,
|
|
63
|
+
"byteLength"
|
|
64
|
+
)?.get;
|
|
65
|
+
var TYPED_ARRAY_TAG = Reflect.getOwnPropertyDescriptor(
|
|
66
|
+
TYPED_ARRAY_PROTOTYPE,
|
|
67
|
+
Symbol.toStringTag
|
|
68
|
+
)?.get;
|
|
69
|
+
var UINT8_ARRAY_SET = Uint8Array.prototype.set;
|
|
70
|
+
function snapshotUint8Array(value, maximumBytes) {
|
|
71
|
+
if (!Number.isSafeInteger(maximumBytes) || maximumBytes < 0) {
|
|
72
|
+
throw new TypeError("GPU contract byte limit must be a non-negative safe integer.");
|
|
73
|
+
}
|
|
74
|
+
let byteLength;
|
|
75
|
+
let tag;
|
|
76
|
+
try {
|
|
77
|
+
if (!TYPED_ARRAY_BYTE_LENGTH || !TYPED_ARRAY_TAG) throw new TypeError();
|
|
78
|
+
byteLength = Reflect.apply(TYPED_ARRAY_BYTE_LENGTH, value, []);
|
|
79
|
+
tag = Reflect.apply(TYPED_ARRAY_TAG, value, []);
|
|
80
|
+
} catch {
|
|
81
|
+
throw new TypeError("GPU contract bytes must be a bounded detached Uint8Array.");
|
|
82
|
+
}
|
|
83
|
+
if (tag !== "Uint8Array" || !Number.isSafeInteger(byteLength) || byteLength > maximumBytes) {
|
|
84
|
+
throw new TypeError("GPU contract bytes must be a bounded detached Uint8Array.");
|
|
85
|
+
}
|
|
86
|
+
const output = new Uint8Array(byteLength);
|
|
87
|
+
try {
|
|
88
|
+
Reflect.apply(UINT8_ARRAY_SET, output, [value]);
|
|
89
|
+
} catch {
|
|
90
|
+
throw new TypeError("GPU contract bytes must be a bounded detached Uint8Array.");
|
|
91
|
+
}
|
|
92
|
+
return output;
|
|
93
|
+
}
|
|
94
|
+
function fail(reason) {
|
|
95
|
+
throw new GpuContractSnapshotError(reason);
|
|
17
96
|
}
|
|
18
|
-
function
|
|
97
|
+
function inspected(operation) {
|
|
98
|
+
try {
|
|
99
|
+
return operation();
|
|
100
|
+
} catch {
|
|
101
|
+
return fail("inspection");
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function assertLimit(value, maximum, reason) {
|
|
105
|
+
if (!Number.isSafeInteger(value) || value > maximum) fail(reason);
|
|
106
|
+
}
|
|
107
|
+
function quotedJsonByteLength(value, maximum) {
|
|
108
|
+
let raw = 0;
|
|
109
|
+
let quoted = 2;
|
|
19
110
|
for (let index = 0; index < value.length; index += 1) {
|
|
20
111
|
const code = value.charCodeAt(index);
|
|
21
|
-
if (code
|
|
112
|
+
if (code <= 127) {
|
|
113
|
+
raw += 1;
|
|
114
|
+
if (code <= 31) quoted += code === 8 || code === 9 || code === 10 || code === 12 || code === 13 ? 2 : 6;
|
|
115
|
+
else quoted += code === 34 || code === 92 ? 2 : 1;
|
|
116
|
+
} else if (code <= 2047) {
|
|
117
|
+
raw += 2;
|
|
118
|
+
quoted += 2;
|
|
119
|
+
} else if (code >= 55296 && code <= 56319) {
|
|
22
120
|
const next = value.charCodeAt(index + 1);
|
|
23
|
-
if (!(next >= 56320 && next <= 57343))
|
|
121
|
+
if (!(next >= 56320 && next <= 57343)) fail("unicode");
|
|
122
|
+
raw += 4;
|
|
123
|
+
quoted += 4;
|
|
24
124
|
index += 1;
|
|
25
|
-
} else if (code >= 56320 && code <= 57343)
|
|
125
|
+
} else if (code >= 56320 && code <= 57343) fail("unicode");
|
|
126
|
+
else {
|
|
127
|
+
raw += 3;
|
|
128
|
+
quoted += 3;
|
|
129
|
+
}
|
|
130
|
+
if (raw > maximum) fail("string-bytes");
|
|
26
131
|
}
|
|
132
|
+
return { raw, quoted };
|
|
27
133
|
}
|
|
28
|
-
function
|
|
134
|
+
function assertLimits(limits) {
|
|
135
|
+
for (const value of Object.values(limits)) {
|
|
136
|
+
if (!Number.isSafeInteger(value) || value < 1) throw new TypeError("GPU contract snapshot limits must be positive safe integers.");
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
function snapshotGpuContract(value, limits = GPU_CONTRACT_SNAPSHOT_LIMITS) {
|
|
140
|
+
assertLimits(limits);
|
|
29
141
|
const ancestors = /* @__PURE__ */ new Set();
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
142
|
+
let nodes = 0;
|
|
143
|
+
let properties = 0;
|
|
144
|
+
let elements = 0;
|
|
145
|
+
let aggregateStringBytes = 0;
|
|
146
|
+
let aggregateBytes = 0;
|
|
147
|
+
const addAggregate = (bytes2) => {
|
|
148
|
+
aggregateBytes += bytes2;
|
|
149
|
+
assertLimit(aggregateBytes, limits.maximumAggregateBytes, "aggregate-bytes");
|
|
150
|
+
};
|
|
151
|
+
const addString = (text2) => {
|
|
152
|
+
const measured = quotedJsonByteLength(text2, limits.maximumStringBytes);
|
|
153
|
+
aggregateStringBytes += measured.raw;
|
|
154
|
+
assertLimit(aggregateStringBytes, limits.maximumAggregateStringBytes, "aggregate-string-bytes");
|
|
155
|
+
return measured.quoted;
|
|
156
|
+
};
|
|
157
|
+
const visit = (current, depth) => {
|
|
158
|
+
if (depth > limits.maximumDepth) fail("depth");
|
|
159
|
+
nodes += 1;
|
|
160
|
+
assertLimit(nodes, limits.maximumNodes, "nodes");
|
|
161
|
+
if (current === null) {
|
|
162
|
+
addAggregate(4);
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
if (typeof current === "string") {
|
|
166
|
+
addAggregate(addString(current));
|
|
167
|
+
return current;
|
|
168
|
+
}
|
|
169
|
+
if (typeof current === "boolean") {
|
|
170
|
+
addAggregate(current ? 4 : 5);
|
|
171
|
+
return current;
|
|
35
172
|
}
|
|
36
173
|
if (typeof current === "number") {
|
|
37
|
-
if (!Number.isFinite(current))
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return
|
|
41
|
-
}
|
|
42
|
-
if (typeof current !== "object")
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
174
|
+
if (!Number.isFinite(current)) fail("non-finite");
|
|
175
|
+
const normalized = Object.is(current, -0) ? 0 : current;
|
|
176
|
+
addAggregate(JSON.stringify(normalized).length);
|
|
177
|
+
return normalized;
|
|
178
|
+
}
|
|
179
|
+
if (typeof current !== "object") fail("value");
|
|
180
|
+
if (ancestors.has(current)) fail("cycle");
|
|
181
|
+
const isArray = inspected(() => Array.isArray(current));
|
|
182
|
+
const prototype = inspected(() => Reflect.getPrototypeOf(current));
|
|
183
|
+
if (isArray ? prototype !== Array.prototype : prototype !== Object.prototype && prototype !== null) fail("shape");
|
|
48
184
|
ancestors.add(current);
|
|
49
185
|
try {
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
186
|
+
if (isArray) {
|
|
187
|
+
const lengthDescriptor = inspected(() => Reflect.getOwnPropertyDescriptor(current, "length"));
|
|
188
|
+
if (!lengthDescriptor || !Object.hasOwn(lengthDescriptor, "value") || lengthDescriptor.enumerable || typeof lengthDescriptor.value !== "number" || !Number.isSafeInteger(lengthDescriptor.value) || lengthDescriptor.value < 0) fail("shape");
|
|
189
|
+
const length = lengthDescriptor.value;
|
|
190
|
+
assertLimit(length, limits.maximumArrayLength, "array-length");
|
|
191
|
+
elements += length;
|
|
192
|
+
assertLimit(elements, limits.maximumElements, "elements");
|
|
193
|
+
const ownKeys2 = inspected(() => Reflect.ownKeys(current));
|
|
194
|
+
if (ownKeys2.some((key) => typeof key !== "string")) fail("shape");
|
|
195
|
+
if (ownKeys2.length !== length + 1) fail("shape");
|
|
196
|
+
const keySet = new Set(ownKeys2);
|
|
197
|
+
if (!keySet.delete("length")) fail("shape");
|
|
198
|
+
const output2 = new Array(length);
|
|
199
|
+
addAggregate(2 + Math.max(0, length - 1));
|
|
200
|
+
for (let index = 0; index < length; index += 1) {
|
|
201
|
+
const key = String(index);
|
|
202
|
+
if (!keySet.delete(key)) fail("shape");
|
|
203
|
+
const descriptor = inspected(() => Reflect.getOwnPropertyDescriptor(current, key));
|
|
204
|
+
if (!descriptor || !descriptor.enumerable || !Object.hasOwn(descriptor, "value")) fail("shape");
|
|
205
|
+
Object.defineProperty(output2, key, {
|
|
206
|
+
configurable: true,
|
|
207
|
+
enumerable: true,
|
|
208
|
+
value: visit(descriptor.value, depth + 1),
|
|
209
|
+
writable: true
|
|
210
|
+
});
|
|
62
211
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
212
|
+
if (keySet.size !== 0) fail("shape");
|
|
213
|
+
return output2;
|
|
214
|
+
}
|
|
215
|
+
const ownKeys = inspected(() => Reflect.ownKeys(current));
|
|
216
|
+
if (ownKeys.some((key) => typeof key !== "string")) fail("shape");
|
|
217
|
+
properties += ownKeys.length;
|
|
218
|
+
assertLimit(properties, limits.maximumProperties, "properties");
|
|
219
|
+
addAggregate(2 + Math.max(0, ownKeys.length - 1) + ownKeys.length);
|
|
220
|
+
const output = {};
|
|
221
|
+
for (const key of ownKeys) {
|
|
222
|
+
addAggregate(addString(key));
|
|
223
|
+
const descriptor = inspected(() => Reflect.getOwnPropertyDescriptor(current, key));
|
|
224
|
+
if (!descriptor || !descriptor.enumerable || !Object.hasOwn(descriptor, "value")) fail("shape");
|
|
225
|
+
Object.defineProperty(output, key, {
|
|
226
|
+
configurable: true,
|
|
227
|
+
enumerable: true,
|
|
228
|
+
value: visit(descriptor.value, depth + 1),
|
|
229
|
+
writable: true
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
return output;
|
|
66
233
|
} finally {
|
|
67
234
|
ancestors.delete(current);
|
|
68
235
|
}
|
|
69
236
|
};
|
|
70
|
-
return visit(value,
|
|
237
|
+
return visit(value, 0);
|
|
238
|
+
}
|
|
239
|
+
function serializeSnapshot(value) {
|
|
240
|
+
if (value === null) return "null";
|
|
241
|
+
if (typeof value === "string" || typeof value === "boolean") return JSON.stringify(value);
|
|
242
|
+
if (typeof value === "number") return JSON.stringify(value);
|
|
243
|
+
if (Array.isArray(value)) return `[${value.map(serializeSnapshot).join(",")}]`;
|
|
244
|
+
const input = value;
|
|
245
|
+
return `{${Object.keys(input).sort().map((key) => `${JSON.stringify(key)}:${serializeSnapshot(input[key])}`).join(",")}}`;
|
|
246
|
+
}
|
|
247
|
+
function canonicalizeGpuContract(value) {
|
|
248
|
+
return serializeSnapshot(snapshotGpuContract(value));
|
|
249
|
+
}
|
|
250
|
+
function canonicalizeQualificationGpuContract(value) {
|
|
251
|
+
return serializeSnapshot(snapshotGpuContract(value, QUALIFICATION_GPU_CONTRACT_SNAPSHOT_LIMITS));
|
|
71
252
|
}
|
|
72
253
|
|
|
73
254
|
// src/codec/codec.ts
|
|
@@ -539,39 +720,41 @@ function modelProjection(manifest) {
|
|
|
539
720
|
};
|
|
540
721
|
}
|
|
541
722
|
async function computeGpuAbiHash(input) {
|
|
542
|
-
|
|
723
|
+
const snapshot = snapshotGpuContract(input);
|
|
724
|
+
if (snapshot.kind === "model") {
|
|
543
725
|
return computeSha256(
|
|
544
726
|
`plasius.gpu.model-abi/v1
|
|
545
|
-
${canonicalizeGpuContract(modelProjection(
|
|
727
|
+
${canonicalizeGpuContract(modelProjection(snapshot.interface))}`
|
|
546
728
|
);
|
|
547
729
|
}
|
|
548
|
-
if (
|
|
730
|
+
if (snapshot.kind === "interface") {
|
|
549
731
|
return computeSha256(
|
|
550
732
|
`plasius.gpu.interface-abi/v1
|
|
551
|
-
${canonicalizeGpuContract(interfaceProjection(
|
|
733
|
+
${canonicalizeGpuContract(interfaceProjection(snapshot.interface))}`
|
|
552
734
|
);
|
|
553
735
|
}
|
|
554
736
|
const pipelines = sorted(
|
|
555
|
-
|
|
737
|
+
snapshot.pipelines,
|
|
556
738
|
(left, right) => compareString(left.pipelineId, right.pipelineId)
|
|
557
739
|
);
|
|
558
740
|
const requirements = {
|
|
559
|
-
semantics: [...
|
|
560
|
-
features: [...
|
|
561
|
-
limits: sorted(
|
|
562
|
-
formats: [...
|
|
741
|
+
semantics: [...snapshot.requirements.semantics].sort(),
|
|
742
|
+
features: [...snapshot.requirements.features].sort(),
|
|
743
|
+
limits: sorted(snapshot.requirements.limits, (left, right) => compareString(left.name, right.name)),
|
|
744
|
+
formats: [...snapshot.requirements.formats].sort()
|
|
563
745
|
};
|
|
564
746
|
return computeSha256(
|
|
565
747
|
`plasius.gpu.shader-abi/v1
|
|
566
748
|
${canonicalizeGpuContract({
|
|
567
|
-
interface: interfaceProjection(
|
|
749
|
+
interface: interfaceProjection(snapshot.interface),
|
|
568
750
|
pipelines,
|
|
569
751
|
requirements
|
|
570
752
|
})}`
|
|
571
753
|
);
|
|
572
754
|
}
|
|
573
755
|
async function computeShaderManifestCoreSha256(manifest) {
|
|
574
|
-
const
|
|
756
|
+
const snapshot = snapshotGpuContract(manifest);
|
|
757
|
+
const core = Object.fromEntries(Object.entries(snapshot).filter(
|
|
575
758
|
([key]) => key !== "validationEvidence" && key !== "additionalValidationEvidence"
|
|
576
759
|
));
|
|
577
760
|
return computeSha256(
|
|
@@ -951,11 +1134,10 @@ var stages = ["vertex", "fragment", "compute"];
|
|
|
951
1134
|
var roles = ["material", "lighting", "outline", "shadow", "post-processing"];
|
|
952
1135
|
function detachedJson(value, path2) {
|
|
953
1136
|
try {
|
|
954
|
-
return
|
|
1137
|
+
return snapshotGpuContract(value);
|
|
955
1138
|
} catch (cause) {
|
|
956
|
-
const detail = cause instanceof
|
|
957
|
-
|
|
958
|
-
throw new TypeError(`${path2} must contain detached JSON contract data: ${boundedDetail}`, { cause });
|
|
1139
|
+
const detail = cause instanceof GpuContractSnapshotError ? ` ${cause.message}` : "";
|
|
1140
|
+
throw new TypeError(`${path2} must contain bounded detached JSON contract data.${detail}`);
|
|
959
1141
|
}
|
|
960
1142
|
}
|
|
961
1143
|
function object(value, path2) {
|
|
@@ -965,7 +1147,7 @@ function object(value, path2) {
|
|
|
965
1147
|
function exact(value, keys2, path2) {
|
|
966
1148
|
const allowed = new Set(keys2);
|
|
967
1149
|
for (const key of Object.keys(value)) if (!allowed.has(key)) throw new TypeError(`${path2}.${key} is not part of this contract version.`);
|
|
968
|
-
for (const key of keys2) if (!(key
|
|
1150
|
+
for (const key of keys2) if (!Object.hasOwn(value, key)) throw new TypeError(`${path2}.${key} is required.`);
|
|
969
1151
|
}
|
|
970
1152
|
function text(value, path2, maximum = 512) {
|
|
971
1153
|
if (typeof value !== "string" || value.length === 0 || value.length > maximum || [...value].some((character) => character.charCodeAt(0) <= 31)) {
|
|
@@ -981,11 +1163,8 @@ function token(value, path2) {
|
|
|
981
1163
|
function immutableVersion(value, path2) {
|
|
982
1164
|
try {
|
|
983
1165
|
return assertImmutableAssetVersion(value);
|
|
984
|
-
} catch
|
|
985
|
-
throw new TypeError(
|
|
986
|
-
`${path2} must be an immutable asset version: exact token required; mutable aliases, ranges, wildcards, and URLs are not allowed.`,
|
|
987
|
-
{ cause }
|
|
988
|
-
);
|
|
1166
|
+
} catch {
|
|
1167
|
+
throw new TypeError(`${path2} must be an immutable asset version: exact token required; mutable aliases, ranges, wildcards, and URLs are not allowed.`);
|
|
989
1168
|
}
|
|
990
1169
|
}
|
|
991
1170
|
function enumeration(value, values, path2) {
|
|
@@ -1015,8 +1194,8 @@ function nullableToken(value, path2) {
|
|
|
1015
1194
|
function digest(value, path2) {
|
|
1016
1195
|
try {
|
|
1017
1196
|
return asSha256Hex(text(value, path2, 64));
|
|
1018
|
-
} catch
|
|
1019
|
-
throw new TypeError(`${path2} must be a lowercase SHA-256 digest
|
|
1197
|
+
} catch {
|
|
1198
|
+
throw new TypeError(`${path2} must be a lowercase SHA-256 digest.`);
|
|
1020
1199
|
}
|
|
1021
1200
|
}
|
|
1022
1201
|
function uri(value, path2) {
|
|
@@ -1024,8 +1203,8 @@ function uri(value, path2) {
|
|
|
1024
1203
|
let parsed;
|
|
1025
1204
|
try {
|
|
1026
1205
|
parsed = new URL(result);
|
|
1027
|
-
} catch
|
|
1028
|
-
throw new TypeError(`${path2} must be an absolute immutable asset URI
|
|
1206
|
+
} catch {
|
|
1207
|
+
throw new TypeError(`${path2} must be an absolute immutable asset URI.`);
|
|
1029
1208
|
}
|
|
1030
1209
|
if (parsed.protocol !== "https:" || parsed.username || parsed.password || parsed.hash) throw new TypeError(`${path2} must be credential-free HTTPS without a fragment.`);
|
|
1031
1210
|
const keys2 = [...parsed.searchParams.keys()].map((key) => key.toLowerCase());
|
|
@@ -1869,7 +2048,7 @@ function freezeJson(value) {
|
|
|
1869
2048
|
}
|
|
1870
2049
|
function exactKeys(value, keys2) {
|
|
1871
2050
|
const expected = new Set(keys2);
|
|
1872
|
-
return Object.keys(value).every((key) => expected.has(key)) && keys2.every((key) => key
|
|
2051
|
+
return Object.keys(value).every((key) => expected.has(key)) && keys2.every((key) => Object.hasOwn(value, key));
|
|
1873
2052
|
}
|
|
1874
2053
|
function safeToken(value) {
|
|
1875
2054
|
return typeof value === "string" && /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,159}$/u.test(value) && !value.includes("..");
|
|
@@ -1893,13 +2072,13 @@ function validSha(value) {
|
|
|
1893
2072
|
function validateCompileUnitInventory(value) {
|
|
1894
2073
|
let snapshot;
|
|
1895
2074
|
try {
|
|
1896
|
-
snapshot =
|
|
1897
|
-
} catch
|
|
2075
|
+
snapshot = snapshotGpuContract(value, QUALIFICATION_GPU_CONTRACT_SNAPSHOT_LIMITS);
|
|
2076
|
+
} catch {
|
|
1898
2077
|
return {
|
|
1899
2078
|
ok: false,
|
|
1900
2079
|
diagnostics: [issue(
|
|
1901
2080
|
"invalid-contract",
|
|
1902
|
-
|
|
2081
|
+
"Compile-unit inventory must contain bounded detached JSON contract data."
|
|
1903
2082
|
)]
|
|
1904
2083
|
};
|
|
1905
2084
|
}
|
|
@@ -2140,9 +2319,9 @@ function object3(value, path2) {
|
|
|
2140
2319
|
}
|
|
2141
2320
|
function detachedJson2(value, label) {
|
|
2142
2321
|
try {
|
|
2143
|
-
return
|
|
2144
|
-
} catch
|
|
2145
|
-
throw new TypeError(`${label} must contain detached JSON contract data
|
|
2322
|
+
return snapshotGpuContract(value, QUALIFICATION_GPU_CONTRACT_SNAPSHOT_LIMITS);
|
|
2323
|
+
} catch {
|
|
2324
|
+
throw new TypeError(`${label} must contain bounded detached JSON contract data.`);
|
|
2146
2325
|
}
|
|
2147
2326
|
}
|
|
2148
2327
|
function freezeJson2(value) {
|
|
@@ -2152,7 +2331,7 @@ function freezeJson2(value) {
|
|
|
2152
2331
|
}
|
|
2153
2332
|
function exact2(value, keys2, path2) {
|
|
2154
2333
|
const expected = new Set(keys2);
|
|
2155
|
-
if (!Object.keys(value).every((key) => expected.has(key)) || !keys2.every((key) => key
|
|
2334
|
+
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.`);
|
|
2156
2335
|
}
|
|
2157
2336
|
function token2(value, path2) {
|
|
2158
2337
|
if (typeof value !== "string" || !TOKEN.test(value) || value.includes("..")) throw new TypeError(`${path2} must be a safe token.`);
|
|
@@ -2161,11 +2340,8 @@ function token2(value, path2) {
|
|
|
2161
2340
|
function immutableVersion3(value, path2) {
|
|
2162
2341
|
try {
|
|
2163
2342
|
return assertImmutableAssetVersion(value);
|
|
2164
|
-
} catch
|
|
2165
|
-
throw new TypeError(
|
|
2166
|
-
`${path2} must be an immutable asset version: exact token required; mutable aliases, ranges, wildcards, and URLs are not allowed.`,
|
|
2167
|
-
{ cause }
|
|
2168
|
-
);
|
|
2343
|
+
} catch {
|
|
2344
|
+
throw new TypeError(`${path2} must be an immutable asset version: exact token required; mutable aliases, ranges, wildcards, and URLs are not allowed.`);
|
|
2169
2345
|
}
|
|
2170
2346
|
}
|
|
2171
2347
|
function path(value, label, extensions) {
|
|
@@ -2177,8 +2353,8 @@ function path(value, label, extensions) {
|
|
|
2177
2353
|
function sha(value, label) {
|
|
2178
2354
|
try {
|
|
2179
2355
|
return asSha256Hex(String(value));
|
|
2180
|
-
} catch
|
|
2181
|
-
throw new TypeError(`${label} must be a lowercase SHA-256 digest
|
|
2356
|
+
} catch {
|
|
2357
|
+
throw new TypeError(`${label} must be a lowercase SHA-256 digest.`);
|
|
2182
2358
|
}
|
|
2183
2359
|
}
|
|
2184
2360
|
function integer4(value, label, minimum = 0, maximum = 4294967295) {
|
|
@@ -2302,6 +2478,7 @@ function jsonValue(value, label, depth = 0) {
|
|
|
2302
2478
|
}
|
|
2303
2479
|
function validateQualificationFixture(value, unit) {
|
|
2304
2480
|
try {
|
|
2481
|
+
const compileUnit = unit === void 0 ? void 0 : detachedJson2(unit, "compile unit");
|
|
2305
2482
|
const fixture = object3(detachedJson2(value, "fixture"), "fixture");
|
|
2306
2483
|
exact2(fixture, ["contractVersion", "fixtureId", "resources", "bindGroups", "commands", "layoutProbes", "readbacks", "bounds"], "fixture");
|
|
2307
2484
|
if (fixture.contractVersion !== SHADER_QUALIFICATION_FIXTURE_VERSION) throw new TypeError("Unsupported qualification fixture version.");
|
|
@@ -2432,14 +2609,14 @@ function validateQualificationFixture(value, unit) {
|
|
|
2432
2609
|
unique2(bindingIds, `${label}.entries`);
|
|
2433
2610
|
bindGroups.set(id, { group: groupIndex, entries: parsedEntries });
|
|
2434
2611
|
}
|
|
2435
|
-
const pipelines = new Map(
|
|
2612
|
+
const pipelines = new Map(compileUnit?.pipelines.map((pipeline2) => [pipeline2.pipelineId, pipeline2]) ?? []);
|
|
2436
2613
|
const pipelineIds = new Set(pipelines.keys());
|
|
2437
2614
|
const commandBindGroups = (value2, pipelineId, label) => {
|
|
2438
2615
|
const ids = boundedArray(value2, label, 32).map((item, index) => token2(item, `${label}[${index}]`));
|
|
2439
2616
|
unique2(ids, label);
|
|
2440
2617
|
const pipeline2 = pipelines.get(pipelineId);
|
|
2441
2618
|
if (!pipeline2) {
|
|
2442
|
-
if (
|
|
2619
|
+
if (compileUnit) throw new TypeError(`${label} pipeline is missing.`);
|
|
2443
2620
|
return;
|
|
2444
2621
|
}
|
|
2445
2622
|
const expectedGroups = [...pipeline2.layout.bindGroups].sort((left, right) => left.group - right.group);
|
|
@@ -2464,7 +2641,7 @@ function validateQualificationFixture(value, unit) {
|
|
|
2464
2641
|
executionCommands += 1;
|
|
2465
2642
|
exact2(command, ["kind", "pipelineId", "bindGroupIds", "workgroups"], label);
|
|
2466
2643
|
const id = token2(command.pipelineId, `${label}.pipelineId`);
|
|
2467
|
-
if (
|
|
2644
|
+
if (compileUnit && pipelines.get(id)?.kind !== "compute") throw new TypeError(`${label} references a missing or non-compute pipeline.`);
|
|
2468
2645
|
commandBindGroups(command.bindGroupIds, id, `${label}.bindGroupIds`);
|
|
2469
2646
|
const workgroups = tuple(command.workgroups, `${label}.workgroups`, 3, 1);
|
|
2470
2647
|
if (workgroups[0] * workgroups[1] * workgroups[2] > 1048576) throw new TypeError(`${label}.workgroups exceeds the hard dispatch bound.`);
|
|
@@ -8844,7 +9021,7 @@ function validatePipelineInterfaces(input) {
|
|
|
8844
9021
|
// package.json
|
|
8845
9022
|
var package_default = {
|
|
8846
9023
|
name: "@plasius/gpu-shader",
|
|
8847
|
-
version: "0.1.
|
|
9024
|
+
version: "0.1.3",
|
|
8848
9025
|
description: "Reflection-first WebGPU WGSL interfaces, CPU codecs, compatibility validation, style profiles, and qualification tooling",
|
|
8849
9026
|
type: "module",
|
|
8850
9027
|
sideEffects: false,
|
|
@@ -8936,6 +9113,7 @@ var package_default = {
|
|
|
8936
9113
|
access: "public"
|
|
8937
9114
|
},
|
|
8938
9115
|
overrides: {
|
|
9116
|
+
esbuild: "^0.28.1",
|
|
8939
9117
|
minimatch: "^10.2.1"
|
|
8940
9118
|
},
|
|
8941
9119
|
engines: {
|
|
@@ -10107,7 +10285,37 @@ function object4(value, path2) {
|
|
|
10107
10285
|
}
|
|
10108
10286
|
function exact3(value, keys2, path2) {
|
|
10109
10287
|
const expected = new Set(keys2);
|
|
10110
|
-
if (!Object.keys(value).every((key) => expected.has(key)) || !keys2.every((key) => key
|
|
10288
|
+
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.`);
|
|
10289
|
+
}
|
|
10290
|
+
function detachedQualificationContract(value) {
|
|
10291
|
+
try {
|
|
10292
|
+
return snapshotGpuContract(value, QUALIFICATION_GPU_CONTRACT_SNAPSHOT_LIMITS);
|
|
10293
|
+
} catch {
|
|
10294
|
+
throw new TypeError("Qualification data must contain bounded detached JSON contract data.");
|
|
10295
|
+
}
|
|
10296
|
+
}
|
|
10297
|
+
function parseQualificationJsonBytes(bytes2, label) {
|
|
10298
|
+
let snapshot;
|
|
10299
|
+
try {
|
|
10300
|
+
snapshot = snapshotUint8Array(
|
|
10301
|
+
bytes2,
|
|
10302
|
+
QUALIFICATION_GPU_CONTRACT_SNAPSHOT_LIMITS.maximumInputBytes
|
|
10303
|
+
);
|
|
10304
|
+
} catch {
|
|
10305
|
+
throw new TypeError(`${label} is not bounded UTF-8 JSON.`);
|
|
10306
|
+
}
|
|
10307
|
+
let parsed;
|
|
10308
|
+
try {
|
|
10309
|
+
parsed = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(snapshot));
|
|
10310
|
+
} catch {
|
|
10311
|
+
throw new TypeError(`${label} is not valid UTF-8 JSON.`);
|
|
10312
|
+
}
|
|
10313
|
+
return detachedQualificationContract(parsed);
|
|
10314
|
+
}
|
|
10315
|
+
function freezeJson3(value) {
|
|
10316
|
+
if (typeof value !== "object" || value === null || Object.isFrozen(value)) return value;
|
|
10317
|
+
for (const child of Object.values(value)) freezeJson3(child);
|
|
10318
|
+
return Object.freeze(value);
|
|
10111
10319
|
}
|
|
10112
10320
|
function token3(value, path2, maximum = 512) {
|
|
10113
10321
|
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.`);
|
|
@@ -10116,8 +10324,8 @@ function token3(value, path2, maximum = 512) {
|
|
|
10116
10324
|
function sha2(value, path2) {
|
|
10117
10325
|
try {
|
|
10118
10326
|
return asSha256Hex(token3(value, path2, 64));
|
|
10119
|
-
} catch
|
|
10120
|
-
throw new TypeError(`${path2} is not a SHA-256 digest
|
|
10327
|
+
} catch {
|
|
10328
|
+
throw new TypeError(`${path2} is not a SHA-256 digest.`);
|
|
10121
10329
|
}
|
|
10122
10330
|
}
|
|
10123
10331
|
function integer5(value, path2, minimum = 0) {
|
|
@@ -10150,7 +10358,7 @@ function trustedWorkflowRef(value, path2) {
|
|
|
10150
10358
|
return result;
|
|
10151
10359
|
}
|
|
10152
10360
|
function parseTrustedWorkflowProvenance(value, path2 = "provenance") {
|
|
10153
|
-
const input = object4(value, path2);
|
|
10361
|
+
const input = object4(detachedQualificationContract(value), path2);
|
|
10154
10362
|
exact3(input, ["repository", "commit", "ref", "workflowRef", "workflowSha", "runId", "runAttempt", "job", "eventName", "oidcAttestation"], path2);
|
|
10155
10363
|
const repository = token3(input.repository, `${path2}.repository`);
|
|
10156
10364
|
if (!repository.startsWith("Plasius-LTD/")) throw new TypeError(`${path2}.repository is outside Plasius-LTD.`);
|
|
@@ -10169,10 +10377,10 @@ function parseTrustedWorkflowProvenance(value, path2 = "provenance") {
|
|
|
10169
10377
|
token3(oidc.audience, `${path2}.oidcAttestation.audience`, 2048);
|
|
10170
10378
|
sha2(oidc.verifiedClaimsSha256, `${path2}.oidcAttestation.verifiedClaimsSha256`);
|
|
10171
10379
|
timestamp(oidc.verifiedAt, `${path2}.oidcAttestation.verifiedAt`);
|
|
10172
|
-
return input;
|
|
10380
|
+
return freezeJson3(input);
|
|
10173
10381
|
}
|
|
10174
10382
|
function parseQualificationExecutionProducer(value, path2 = "producer") {
|
|
10175
|
-
const input = object4(value, path2);
|
|
10383
|
+
const input = object4(detachedQualificationContract(value), path2);
|
|
10176
10384
|
exact3(input, ["repository", "commit", "ref", "runId", "runAttempt", "job", "trustedWorkflowRepository", "trustedWorkflowRef", "trustedWorkflowSha", "runner"], path2);
|
|
10177
10385
|
const repository = token3(input.repository, `${path2}.repository`);
|
|
10178
10386
|
if (!repository.startsWith("Plasius-LTD/")) throw new TypeError(`${path2}.repository is outside Plasius-LTD.`);
|
|
@@ -10190,7 +10398,7 @@ function parseQualificationExecutionProducer(value, path2 = "producer") {
|
|
|
10190
10398
|
if (!["github-hosted", "self-hosted", "device-farm"].includes(String(runner.environment))) throw new TypeError(`${path2}.runner.environment is invalid.`);
|
|
10191
10399
|
token3(runner.os, `${path2}.runner.os`);
|
|
10192
10400
|
token3(runner.architecture, `${path2}.runner.architecture`);
|
|
10193
|
-
return input;
|
|
10401
|
+
return freezeJson3(input);
|
|
10194
10402
|
}
|
|
10195
10403
|
function assertProducerMatchesPreflight(producer, provenance, cell, path2, expectedJob) {
|
|
10196
10404
|
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.`);
|
|
@@ -10199,26 +10407,32 @@ function assertProducerMatchesPreflight(producer, provenance, cell, path2, expec
|
|
|
10199
10407
|
if (expectedJob === "physical-runner-preflight" && producer.runner.environment !== "github-hosted") throw new TypeError(`${path2} must identify its hosted orchestration job truthfully.`);
|
|
10200
10408
|
}
|
|
10201
10409
|
function canonicalEqual(left, right) {
|
|
10202
|
-
return
|
|
10410
|
+
return canonicalizeQualificationGpuContract(left) === canonicalizeQualificationGpuContract(right);
|
|
10203
10411
|
}
|
|
10204
10412
|
function foldRunnerLabel(value) {
|
|
10205
10413
|
return value.replace(/[A-Z]/gu, (character) => character.toLowerCase());
|
|
10206
10414
|
}
|
|
10207
10415
|
async function computeQualificationInventorySha256(bundle) {
|
|
10208
|
-
|
|
10416
|
+
const snapshot = detachedQualificationContract(bundle);
|
|
10417
|
+
return computeSha256(canonicalizeQualificationGpuContract(snapshot.inventory));
|
|
10209
10418
|
}
|
|
10210
10419
|
async function computeQualificationSubjectBinding(input) {
|
|
10211
10420
|
return computeSha256(`plasius.gpu.qualification-subject/v1
|
|
10212
|
-
${
|
|
10421
|
+
${canonicalizeQualificationGpuContract(input)}`);
|
|
10213
10422
|
}
|
|
10214
10423
|
async function computeValidationEvidenceId(value) {
|
|
10215
10424
|
const input = object4(value, "evidence identity input");
|
|
10216
10425
|
const projection = Object.fromEntries(Object.entries(input).filter(([key]) => key !== "evidenceId"));
|
|
10217
10426
|
return `qualification-${(await computeSha256(`plasius.gpu.validation-evidence/v1
|
|
10218
|
-
${
|
|
10427
|
+
${canonicalizeQualificationGpuContract(projection)}`)).slice(0, 24)}`;
|
|
10219
10428
|
}
|
|
10220
10429
|
function immutableBlobUri(value) {
|
|
10221
|
-
|
|
10430
|
+
let url;
|
|
10431
|
+
try {
|
|
10432
|
+
url = new URL(value);
|
|
10433
|
+
} catch {
|
|
10434
|
+
throw new TypeError("Source URI must be a normalized immutable Azure Blob .tar URL.");
|
|
10435
|
+
}
|
|
10222
10436
|
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 === ".."))) {
|
|
10223
10437
|
throw new TypeError("Source URI must be a normalized immutable Azure Blob .tar URL.");
|
|
10224
10438
|
}
|
|
@@ -10228,12 +10442,7 @@ function immutableBlobUri(value) {
|
|
|
10228
10442
|
}
|
|
10229
10443
|
async function createQualificationPreflight(input) {
|
|
10230
10444
|
token3(input.qualificationId, "qualificationId");
|
|
10231
|
-
|
|
10232
|
-
try {
|
|
10233
|
-
parsedMatrix = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(input.matrixBytes));
|
|
10234
|
-
} catch (cause) {
|
|
10235
|
-
throw new TypeError("Selected matrix artifact is not UTF-8 JSON.", { cause });
|
|
10236
|
-
}
|
|
10445
|
+
const parsedMatrix = parseQualificationJsonBytes(input.matrixBytes, "Selected matrix artifact");
|
|
10237
10446
|
if (!canonicalEqual(parsedMatrix, input.matrix)) throw new TypeError("Selected matrix artifact bytes differ from the supplied matrix value.");
|
|
10238
10447
|
const actualMatrixSha256 = await computeSha256(input.matrixBytes);
|
|
10239
10448
|
if (actualMatrixSha256 !== input.matrixSha256) throw new TypeError("Selected matrix digest is not derived from the exact matrix manifest.");
|
|
@@ -10403,12 +10612,7 @@ function syntheticResult(unitId, cell, status, message, now) {
|
|
|
10403
10612
|
async function aggregateShaderValidationEvidence(input) {
|
|
10404
10613
|
const verifyArtifact = async (artifact2, label) => {
|
|
10405
10614
|
if (await computeSha256(artifact2.bytes) !== artifact2.sha256) throw new TypeError(`${label} artifact digest is not derived from its exact bytes.`);
|
|
10406
|
-
|
|
10407
|
-
try {
|
|
10408
|
-
parsed = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(artifact2.bytes));
|
|
10409
|
-
} catch (cause) {
|
|
10410
|
-
throw new TypeError(`${label} bytes are not UTF-8 JSON.`, { cause });
|
|
10411
|
-
}
|
|
10615
|
+
const parsed = parseQualificationJsonBytes(artifact2.bytes, `${label} bytes`);
|
|
10412
10616
|
if (!canonicalEqual(parsed, artifact2.value)) throw new TypeError(`${label} parsed value differs from its exact bytes.`);
|
|
10413
10617
|
};
|
|
10414
10618
|
await verifyArtifact(input.preflight, "Qualification preflight");
|
|
@@ -10430,12 +10634,7 @@ async function aggregateShaderValidationEvidence(input) {
|
|
|
10430
10634
|
exact3(sourceBlob, ["host", "versionId", "uri"], "Qualification preflight.sourceBlob");
|
|
10431
10635
|
const normalizedSource = immutableBlobUri(token3(sourceBlob.uri, "Qualification preflight.sourceBlob.uri", 2048));
|
|
10432
10636
|
if (!canonicalEqual(sourceBlob, normalizedSource)) throw new TypeError("Qualification preflight source Blob claims are stale.");
|
|
10433
|
-
|
|
10434
|
-
try {
|
|
10435
|
-
parsedMatrix = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(input.matrixBytes));
|
|
10436
|
-
} catch (cause) {
|
|
10437
|
-
throw new TypeError("Matrix artifact is not UTF-8 JSON.", { cause });
|
|
10438
|
-
}
|
|
10637
|
+
const parsedMatrix = parseQualificationJsonBytes(input.matrixBytes, "Matrix artifact");
|
|
10439
10638
|
if (!canonicalEqual(parsedMatrix, input.matrix)) throw new TypeError("Matrix artifact bytes differ from the supplied matrix value.");
|
|
10440
10639
|
const actualMatrixSha256 = await computeSha256(input.matrixBytes);
|
|
10441
10640
|
if (preflight.matrixSha256 !== actualMatrixSha256) throw new TypeError("Qualification preflight matrix artifact digest is stale.");
|
|
@@ -10509,7 +10708,7 @@ async function aggregateShaderValidationEvidence(input) {
|
|
|
10509
10708
|
if (cellArtifact || diagnostic) throw new TypeError(`Unavailable cell ${cell.cellId} has conflicting evidence.`);
|
|
10510
10709
|
for (const unit of units) results.push(syntheticResult(unit, cell, "runner-unavailable", "Required physical runner was unavailable.", now));
|
|
10511
10710
|
const cellResults = results.slice(-units.size);
|
|
10512
|
-
cellRuns.push({ cellId: cell.cellId, source: "runner-preflight", sourceArtifactSha256: runner.sha256, resultsSha256: await computeSha256(
|
|
10711
|
+
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" });
|
|
10513
10712
|
continue;
|
|
10514
10713
|
}
|
|
10515
10714
|
if (diagnostic) {
|
|
@@ -10524,7 +10723,7 @@ async function aggregateShaderValidationEvidence(input) {
|
|
|
10524
10723
|
const status2 = value2.status === "timeout" ? "timeout" : "failed";
|
|
10525
10724
|
for (const unit of units) results.push(syntheticResult(unit, cell, status2, value2.message, now));
|
|
10526
10725
|
const cellResults = results.slice(-units.size);
|
|
10527
|
-
cellRuns.push({ cellId: cell.cellId, source: "workflow-diagnostic", sourceArtifactSha256: diagnostic.sha256, resultsSha256: await computeSha256(
|
|
10726
|
+
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 });
|
|
10528
10727
|
continue;
|
|
10529
10728
|
}
|
|
10530
10729
|
if (!cellArtifact) throw new TypeError(`Cell ${cell.cellId} has no qualification evidence.`);
|
|
@@ -10532,7 +10731,7 @@ async function aggregateShaderValidationEvidence(input) {
|
|
|
10532
10731
|
if (!matchedRunner) throw new TypeError(`Cell evidence ${cell.cellId} producer was not matched by runner preflight.`);
|
|
10533
10732
|
const value = assertCellEvidence(cellArtifact.value, cell, input.matrix, preflight, input.harness, runner.value.adapterHarness, matchedRunner, units, now);
|
|
10534
10733
|
results.push(...value.results);
|
|
10535
|
-
cellRuns.push({ cellId: cell.cellId, source: "cell-evidence", sourceArtifactSha256: cellArtifact.sha256, resultsSha256: await computeSha256(
|
|
10734
|
+
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" });
|
|
10536
10735
|
}
|
|
10537
10736
|
const expectedResults = units.size * cells.size;
|
|
10538
10737
|
if (results.length !== expectedResults) throw new TypeError("Aggregate result product is incomplete.");
|
|
@@ -10555,34 +10754,31 @@ async function aggregateShaderValidationEvidence(input) {
|
|
|
10555
10754
|
}
|
|
10556
10755
|
async function validateShaderValidationEvidence(input) {
|
|
10557
10756
|
try {
|
|
10558
|
-
const evidence = object4(input.evidence, "evidence");
|
|
10757
|
+
const evidence = object4(detachedQualificationContract(input.evidence), "evidence");
|
|
10758
|
+
const bundle = detachedQualificationContract(input.bundle);
|
|
10759
|
+
const matrix = detachedQualificationContract(input.matrix);
|
|
10559
10760
|
exact3(evidence, ["contractVersion", "evidenceId", "status", "generatedAt", "subjectBindingSha256", "subject", "matrixRef", "toolchain", "qualificationPreflightProvenance", "counts", "cellRuns", "results"], "evidence");
|
|
10560
10761
|
if (evidence.contractVersion !== SHADER_VALIDATION_EVIDENCE_VERSION) throw new TypeError("Unsupported evidence contract version.");
|
|
10561
10762
|
const evidenceId = token3(evidence.evidenceId, "evidence.evidenceId");
|
|
10562
10763
|
const generatedAt = timestamp(evidence.generatedAt, "evidence.generatedAt");
|
|
10563
10764
|
const subjectBindingSha256 = sha2(evidence.subjectBindingSha256, "evidence.subjectBindingSha256");
|
|
10564
10765
|
if (evidence.status !== "passed" && evidence.status !== "failed") throw new TypeError("Evidence status is invalid.");
|
|
10565
|
-
|
|
10566
|
-
|
|
10567
|
-
parsedMatrix = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(input.matrixBytes));
|
|
10568
|
-
} catch (cause) {
|
|
10569
|
-
throw new TypeError("Matrix artifact is not UTF-8 JSON.", { cause });
|
|
10570
|
-
}
|
|
10571
|
-
if (!canonicalEqual(parsedMatrix, input.matrix)) throw new TypeError("Matrix artifact bytes differ from the supplied matrix value.");
|
|
10766
|
+
const parsedMatrix = parseQualificationJsonBytes(input.matrixBytes, "Matrix artifact");
|
|
10767
|
+
if (!canonicalEqual(parsedMatrix, matrix)) throw new TypeError("Matrix artifact bytes differ from the supplied matrix value.");
|
|
10572
10768
|
const matrixSha256 = await computeSha256(input.matrixBytes);
|
|
10573
|
-
const inventorySha256 = await computeQualificationInventorySha256(
|
|
10574
|
-
if (inventorySha256 !==
|
|
10769
|
+
const inventorySha256 = await computeQualificationInventorySha256(bundle);
|
|
10770
|
+
if (inventorySha256 !== bundle.subject.compileUnitInventorySha256) throw new TypeError("Bundle subject inventory digest is stale.");
|
|
10575
10771
|
const subject = object4(evidence.subject, "evidence.subject");
|
|
10576
|
-
const expectedSubjectKeys = [...Object.keys(
|
|
10772
|
+
const expectedSubjectKeys = [...Object.keys(bundle.subject), "dataBundleSha256"];
|
|
10577
10773
|
exact3(subject, expectedSubjectKeys, "evidence.subject");
|
|
10578
10774
|
const candidateSubject = Object.fromEntries(Object.entries(subject).filter(([key]) => key !== "dataBundleSha256"));
|
|
10579
|
-
if (!canonicalEqual(candidateSubject,
|
|
10775
|
+
if (!canonicalEqual(candidateSubject, bundle.subject)) throw new TypeError("Evidence candidate subject differs from bundle.");
|
|
10580
10776
|
const dataBundleSha256 = sha2(subject.dataBundleSha256, "evidence.subject.dataBundleSha256");
|
|
10581
10777
|
if (input.dataBundleSha256 && input.dataBundleSha256 !== dataBundleSha256) throw new TypeError("Evidence data bundle digest differs from the exact archive.");
|
|
10582
10778
|
if (subject.compileUnitInventorySha256 !== inventorySha256) throw new TypeError("Evidence compile-unit inventory digest is stale.");
|
|
10583
10779
|
const matrixRef = object4(evidence.matrixRef, "evidence.matrixRef");
|
|
10584
10780
|
exact3(matrixRef, ["matrixId", "version", "sha256"], "evidence.matrixRef");
|
|
10585
|
-
if (matrixRef.matrixId !==
|
|
10781
|
+
if (matrixRef.matrixId !== matrix.matrixId || matrixRef.version !== matrix.version || matrixRef.sha256 !== matrixSha256) throw new TypeError("Evidence matrix artifact identity differs.");
|
|
10586
10782
|
const toolchain = object4(evidence.toolchain, "evidence.toolchain");
|
|
10587
10783
|
exact3(toolchain, ["packageVersion", "reflectorVersion", "harness"], "evidence.toolchain");
|
|
10588
10784
|
token3(toolchain.packageVersion, "evidence.toolchain.packageVersion");
|
|
@@ -10594,11 +10790,11 @@ async function validateShaderValidationEvidence(input) {
|
|
|
10594
10790
|
const harnessSha256 = sha2(harness.sha256, "evidence.toolchain.harness.sha256");
|
|
10595
10791
|
const preflightProvenance = parseTrustedWorkflowProvenance(evidence.qualificationPreflightProvenance, "evidence.qualificationPreflightProvenance");
|
|
10596
10792
|
if (Date.parse(generatedAt) < Date.parse(preflightProvenance.oidcAttestation.verifiedAt)) throw new TypeError("Evidence predates trusted preflight verification.");
|
|
10597
|
-
const expectedBinding = await computeQualificationSubjectBinding({ subject:
|
|
10793
|
+
const expectedBinding = await computeQualificationSubjectBinding({ subject: bundle.subject, dataBundleSha256, compileUnitInventorySha256: inventorySha256, matrixSha256, harnessSha256 });
|
|
10598
10794
|
if (subjectBindingSha256 !== expectedBinding) throw new TypeError("Evidence subject binding is stale.");
|
|
10599
10795
|
if (evidenceId !== await computeValidationEvidenceId(evidence)) throw new TypeError("Evidence identity is stale.");
|
|
10600
|
-
const units = new Set(
|
|
10601
|
-
const cells = new Map(
|
|
10796
|
+
const units = new Set(bundle.inventory.compileUnits.map((unit) => unit.compileUnitId));
|
|
10797
|
+
const cells = new Map(matrix.cells.map((cell) => [cell.cellId, cell]));
|
|
10602
10798
|
const expected = units.size * cells.size;
|
|
10603
10799
|
const results = array2(evidence.results, "evidence.results");
|
|
10604
10800
|
if (results.length !== expected) throw new TypeError("Evidence result product is incomplete.");
|
|
@@ -10648,7 +10844,7 @@ async function validateShaderValidationEvidence(input) {
|
|
|
10648
10844
|
sha2(automation2.sha256, `${path2}.automation.sha256`);
|
|
10649
10845
|
} else if (run.automation !== null) throw new TypeError(`${path2}.automation must be null when no adapter completed a cell run.`);
|
|
10650
10846
|
const cellResults = parsedResults.filter((result) => result.cellId === cellId);
|
|
10651
|
-
if (run.resultCount !== units.size || cellResults.length !== units.size || await computeSha256(
|
|
10847
|
+
if (run.resultCount !== units.size || cellResults.length !== units.size || await computeSha256(canonicalizeQualificationGpuContract(cellResults)) !== resultsSha256) throw new TypeError(`${path2} result count/digest is stale.`);
|
|
10652
10848
|
const resultStatuses = new Set(cellResults.map((result) => result.status));
|
|
10653
10849
|
if (resultStatuses.size !== 1 || !resultStatuses.has(String(run.status))) throw new TypeError(`${path2}.status differs from its results.`);
|
|
10654
10850
|
if (run.source === "cell-evidence" && run.status !== "passed") throw new TypeError(`${path2} cell evidence must contain passing results.`);
|
|
@@ -10657,7 +10853,7 @@ async function validateShaderValidationEvidence(input) {
|
|
|
10657
10853
|
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.`);
|
|
10658
10854
|
}
|
|
10659
10855
|
if (evidence.status === "passed" !== (passed === expected) || input.requirePassed !== false && evidence.status !== "passed") throw new TypeError("Evidence does not satisfy the required passed gate.");
|
|
10660
|
-
return { ok: true, value: evidence };
|
|
10856
|
+
return { ok: true, value: freezeJson3(evidence) };
|
|
10661
10857
|
} catch (cause) {
|
|
10662
10858
|
return { ok: false, diagnostics: [{ code: "invalid-contract", severity: "error", message: cause instanceof Error ? cause.message : "Invalid shader validation evidence." }] };
|
|
10663
10859
|
}
|
|
@@ -10672,7 +10868,12 @@ function object5(value) {
|
|
|
10672
10868
|
}
|
|
10673
10869
|
function keys(value, expected) {
|
|
10674
10870
|
const set = new Set(expected);
|
|
10675
|
-
return Object.keys(value).every((key) => set.has(key)) && expected.every((key) => key
|
|
10871
|
+
return Object.keys(value).every((key) => set.has(key)) && expected.every((key) => Object.hasOwn(value, key));
|
|
10872
|
+
}
|
|
10873
|
+
function freezeJson4(value) {
|
|
10874
|
+
if (typeof value !== "object" || value === null || Object.isFrozen(value)) return value;
|
|
10875
|
+
for (const child of Object.values(value)) freezeJson4(child);
|
|
10876
|
+
return Object.freeze(value);
|
|
10676
10877
|
}
|
|
10677
10878
|
function canonicalEqual2(left, right) {
|
|
10678
10879
|
try {
|
|
@@ -10722,7 +10923,13 @@ var BASELINE = /* @__PURE__ */ new Map([
|
|
|
10722
10923
|
["win11-nvidia-edge-d3d12", "edge|windows|x64|physical|nvidia|qualified-nvidia|d3d12|playwright|self-hosted,Windows,X64,shader-validation,physical-gpu,gpu-nvidia,d3d12"]
|
|
10723
10924
|
]);
|
|
10724
10925
|
function validateStableWebGpuMatrix(value) {
|
|
10725
|
-
|
|
10926
|
+
let snapshot;
|
|
10927
|
+
try {
|
|
10928
|
+
snapshot = snapshotGpuContract(value);
|
|
10929
|
+
} catch {
|
|
10930
|
+
return { ok: false, diagnostics: [issue3("Matrix must contain bounded detached JSON contract data.")] };
|
|
10931
|
+
}
|
|
10932
|
+
const matrix = object5(snapshot);
|
|
10726
10933
|
const diagnostics = [];
|
|
10727
10934
|
if (!matrix || !keys(matrix, ["contractVersion", "matrixId", "version", "policy", "cells"])) {
|
|
10728
10935
|
return { ok: false, diagnostics: [issue3("Matrix has unknown or missing top-level fields.")] };
|
|
@@ -10795,7 +11002,7 @@ function validateStableWebGpuMatrix(value) {
|
|
|
10795
11002
|
}
|
|
10796
11003
|
}
|
|
10797
11004
|
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."));
|
|
10798
|
-
return diagnostics.length > 0 ? { ok: false, diagnostics } : { ok: true, value: matrix };
|
|
11005
|
+
return diagnostics.length > 0 ? { ok: false, diagnostics } : { ok: true, value: freezeJson4(matrix) };
|
|
10799
11006
|
}
|
|
10800
11007
|
|
|
10801
11008
|
// src/testing/runner/playwright-swiftshader.ts
|
|
@@ -12104,9 +12311,6 @@ function error(code, message, path2) {
|
|
|
12104
12311
|
function interfaceMatches(item, model) {
|
|
12105
12312
|
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;
|
|
12106
12313
|
}
|
|
12107
|
-
function detachedContract(value) {
|
|
12108
|
-
return JSON.parse(canonicalizeGpuContract(value));
|
|
12109
|
-
}
|
|
12110
12314
|
function hasValidationEvidence(value) {
|
|
12111
12315
|
return typeof value === "object" && value !== null && !Array.isArray(value) && (Object.hasOwn(value, "validationEvidence") || Object.hasOwn(value, "additionalValidationEvidence"));
|
|
12112
12316
|
}
|
|
@@ -12154,16 +12358,25 @@ function validateModelShaderCompatibility(input) {
|
|
|
12154
12358
|
let profile;
|
|
12155
12359
|
let capabilities;
|
|
12156
12360
|
try {
|
|
12157
|
-
const
|
|
12158
|
-
|
|
12159
|
-
|
|
12160
|
-
|
|
12161
|
-
const
|
|
12361
|
+
const snapshot = snapshotGpuContract(input);
|
|
12362
|
+
if (typeof snapshot !== "object" || snapshot === null || Array.isArray(snapshot)) {
|
|
12363
|
+
throw new TypeError("GPU compatibility input must be a bounded contract object.");
|
|
12364
|
+
}
|
|
12365
|
+
const envelope = snapshot;
|
|
12366
|
+
const keys2 = Object.keys(envelope);
|
|
12367
|
+
const allowed = /* @__PURE__ */ new Set(["model", "shader", "gpuInterface", "profile", "capabilities"]);
|
|
12368
|
+
if (keys2.some((key) => !allowed.has(key)) || !["model", "shader", "gpuInterface"].every((key) => Object.hasOwn(envelope, key))) {
|
|
12369
|
+
throw new TypeError("GPU compatibility input has unknown or missing fields.");
|
|
12370
|
+
}
|
|
12371
|
+
const modelSnapshot = envelope.model;
|
|
12372
|
+
const shaderSnapshot = envelope.shader;
|
|
12373
|
+
const gpuInterfaceSnapshot = envelope.gpuInterface;
|
|
12374
|
+
const profileSnapshot = Object.hasOwn(envelope, "profile") ? envelope.profile : void 0;
|
|
12162
12375
|
model = parseModelGpuCompatibilityDescriptor(modelSnapshot);
|
|
12163
12376
|
shader = hasValidationEvidence(shaderSnapshot) ? parseShaderVersionManifest(shaderSnapshot) : parseShaderVersionManifestCore(shaderSnapshot);
|
|
12164
12377
|
gpuInterface = parseGpuInterfaceManifest(gpuInterfaceSnapshot);
|
|
12165
12378
|
profile = profileSnapshot === void 0 ? void 0 : parseShaderStyleProfileManifest(profileSnapshot);
|
|
12166
|
-
capabilities =
|
|
12379
|
+
capabilities = Object.hasOwn(envelope, "capabilities") ? envelope.capabilities : void 0;
|
|
12167
12380
|
} catch (cause) {
|
|
12168
12381
|
return {
|
|
12169
12382
|
ok: false,
|