@threenative/playtest 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{diagnostics-D89qJhf0.d.ts → diagnostics-f8464bJw.d.ts} +279 -14
- package/dist/index.d.ts +5 -5
- package/dist/index.js +2483 -440
- package/dist/protocol.d.ts +270 -2
- package/dist/runner/cli.d.ts +15 -3
- package/dist/runner/cli.js +8311 -2466
- package/dist/runner/index.d.ts +211 -7
- package/dist/runner/index.js +4847 -753
- package/dist/{shared-Ax3-pneQ.d.ts → shared-BGwYk5HG.d.ts} +20 -1
- package/dist/three/index.d.ts +27 -3
- package/dist/three/index.js +358 -7
- package/package.json +20 -2
package/dist/index.js
CHANGED
|
@@ -25,13 +25,17 @@ var PLAYTEST_CAPABILITY_REGISTRY = [
|
|
|
25
25
|
capability("runtime.fixedStep", "Advances an application-owned deterministic tick."),
|
|
26
26
|
capability("runtime.physics", "Samples bounded application-owned physics observations."),
|
|
27
27
|
capability("runtime.performance", "Samples bounded per-render frame cost and renderer counts."),
|
|
28
|
+
capability("runtime.pipelineCensus", "Samples bounded shader and pipeline creation observations."),
|
|
28
29
|
capability("runtime.renderChain", "Reports the render stages, quality tier, and velocity route actually applied."),
|
|
29
30
|
capability("runtime.resources", "Reads and writes registered JSON-safe application state."),
|
|
30
31
|
capability("runtime.startup", "Reports whether first-use startup work has finished and the world is safe to observe."),
|
|
31
32
|
capability("runtime.state", "Samples application-owned state-machine state."),
|
|
33
|
+
capability("runtime.transitions", "Samples tick-stamped changes to published entity states and game-state fields."),
|
|
32
34
|
capability("runtime.tags", "Samples bounded application-owned entity tags."),
|
|
33
35
|
capability("runtime.ui", "Samples registered JSON-safe UI and HUD state."),
|
|
34
|
-
capability("runtime.world", "Samples bounded runtime world metadata.")
|
|
36
|
+
capability("runtime.world", "Samples bounded runtime world metadata."),
|
|
37
|
+
capability("scene.nodes", "Reports scene-graph nodes selected by name, path or type, with world transform, bounds, frustum membership, geometry, materials and texture load state."),
|
|
38
|
+
capability("scene.observe", "Counts the lights, materials, fog, background and camera framing mounted in the scene.")
|
|
35
39
|
];
|
|
36
40
|
var KNOWN_CAPABILITIES = new Set(PLAYTEST_CAPABILITY_REGISTRY.map(({ name }) => name));
|
|
37
41
|
function unknownPlaytestCapabilities(capabilities) {
|
|
@@ -45,6 +49,204 @@ function capability(name, description) {
|
|
|
45
49
|
return { description, name, protocolVersion: 1 };
|
|
46
50
|
}
|
|
47
51
|
|
|
52
|
+
// src/assertion-report.ts
|
|
53
|
+
var NETWORK_BLIND_TARGETS = /* @__PURE__ */ new Set(["android", "desktop", "ios"]);
|
|
54
|
+
var UNOBSERVABLE_NETWORK_REASON = "The run target has no network observer; its network observation is hardwired empty, so the default network policy is waived rather than evaluated against nothing.";
|
|
55
|
+
function resolveDiagnosticsPolicy(policy, target) {
|
|
56
|
+
const networkBlind = target !== void 0 && NETWORK_BLIND_TARGETS.has(target);
|
|
57
|
+
const waivedByTarget = networkBlind && policy?.noNetworkErrors === void 0;
|
|
58
|
+
return {
|
|
59
|
+
...policy?.consoleErrorsOptOutReason === void 0 ? {} : { consoleErrorsOptOutReason: policy.consoleErrorsOptOutReason },
|
|
60
|
+
...policy?.networkErrorsOptOutReason === void 0 ? waivedByTarget ? { networkErrorsOptOutReason: UNOBSERVABLE_NETWORK_REASON } : {} : { networkErrorsOptOutReason: policy.networkErrorsOptOutReason },
|
|
61
|
+
noConsoleErrors: policy?.noConsoleErrors ?? true,
|
|
62
|
+
noNetworkErrors: policy?.noNetworkErrors ?? !networkBlind,
|
|
63
|
+
noRuntimeDiagnostics: policy?.noRuntimeDiagnostics ?? true,
|
|
64
|
+
...policy?.runtimeReady === void 0 ? {} : { runtimeReady: policy.runtimeReady },
|
|
65
|
+
...policy?.runtimeDiagnosticsOptOutReason === void 0 ? {} : { runtimeDiagnosticsOptOutReason: policy.runtimeDiagnosticsOptOutReason }
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function trivialAssertionDiagnostic(id, path, before, sourcePath) {
|
|
69
|
+
return {
|
|
70
|
+
code: "TN_PLAYTEST_ASSERTION_TRIVIAL",
|
|
71
|
+
message: `Assertion '${id}'${path === void 0 ? "" : ` at path '${path}'`} was already satisfied before the scenario ran (value ${JSON.stringify(before)}).`,
|
|
72
|
+
path,
|
|
73
|
+
severity: "error",
|
|
74
|
+
...sourcePath === void 0 ? {} : { sourcePath },
|
|
75
|
+
suggestion: "Drive the asserted value from a failing initial state, or assert changed:true. If the value is genuinely a held invariant, allowTrivial takes the reason it is held \u2014 it is recorded in the report and counted against the run."
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function componentAssertionDiagnostic(assertion, before, after) {
|
|
79
|
+
return {
|
|
80
|
+
code: "TN_PLAYTEST_COMPONENT_ASSERTION_FAILED",
|
|
81
|
+
message: `Component '${assertion.component}' on entity '${assertion.entity}'${assertion.path === void 0 ? "" : ` path '${assertion.path}'`} did not satisfy the assertion.`,
|
|
82
|
+
observedRuntimePath: `observations.json/components/${assertion.entity}/${assertion.component}`,
|
|
83
|
+
severity: "error",
|
|
84
|
+
suggestion: `Expected ${JSON.stringify(assertion)}, observed before=${JSON.stringify(before)} after=${JSON.stringify(after)}. Check the owning script and runtime component synchronization.`
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function finiteVector(value) {
|
|
88
|
+
return Array.isArray(value) && value.length === 3 && value.every((item) => typeof item === "number" && Number.isFinite(item));
|
|
89
|
+
}
|
|
90
|
+
function record(value) {
|
|
91
|
+
return isRecord(value) ? value : void 0;
|
|
92
|
+
}
|
|
93
|
+
function expectedPathAssertion(assertion) {
|
|
94
|
+
return {
|
|
95
|
+
...assertion.atSteps === void 0 ? {} : { atSteps: assertion.atSteps },
|
|
96
|
+
...Object.hasOwn(assertion, "equals") ? { equals: assertion.equals } : {},
|
|
97
|
+
...assertion.gte === void 0 ? {} : { gte: assertion.gte },
|
|
98
|
+
...assertion.lte === void 0 ? {} : { lte: assertion.lte },
|
|
99
|
+
...assertion.textIncludes === void 0 ? {} : { textIncludes: assertion.textIncludes },
|
|
100
|
+
...assertion.throughoutSteps === void 0 ? {} : { throughoutSteps: assertion.throughoutSteps },
|
|
101
|
+
...assertion.changed === void 0 ? {} : { changed: assertion.changed },
|
|
102
|
+
...assertion.allowTrivial === void 0 ? {} : { allowTrivial: assertion.allowTrivial },
|
|
103
|
+
...assertion.visible === void 0 ? {} : { visible: assertion.visible }
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function unchangedPathValue(before, after) {
|
|
107
|
+
return before !== void 0 && after !== void 0 && jsonEqual(before, after);
|
|
108
|
+
}
|
|
109
|
+
function pathAssertionDiagnostic(kind, assertion, before, after, context) {
|
|
110
|
+
const unchanged = unchangedPathValue(before, after);
|
|
111
|
+
if (kind === "resource" && unchanged && (context.movedDistance ?? 0) > 0.01) {
|
|
112
|
+
const summary = summarizeResourceEffectLog(context.effectLog, assertion.id, assertion.path);
|
|
113
|
+
return {
|
|
114
|
+
code: "TN_PLAYTEST_RESOURCE_STATE_STAGNATED",
|
|
115
|
+
message: `Resource '${assertion.id}'${assertion.path === void 0 ? "" : ` path '${assertion.path}'`} did not change after the scenario moved the subject ${formatNumber(context.movedDistance ?? 0)} units.`,
|
|
116
|
+
artifactPath: "effect-log.json",
|
|
117
|
+
observedRuntimePath: `effect-log.json/entries[kind=resource,resource=${assertion.id}]`,
|
|
118
|
+
path: assertion.path === void 0 ? `${context.scenarioSourcePath ?? "playtest"}/assert/resources/${assertion.id}` : `${context.scenarioSourcePath ?? "playtest"}/assert/resources/${assertion.id}/${assertion.path}`,
|
|
119
|
+
resourceId: assertion.id,
|
|
120
|
+
severity: "error",
|
|
121
|
+
...context.scenarioSourcePath === void 0 ? {} : { sourcePath: context.scenarioSourcePath },
|
|
122
|
+
...summary?.systemId === void 0 ? {} : { systemId: summary.systemId, sourcePath: summary.sourcePath },
|
|
123
|
+
suggestion: summary === void 0 ? "The scenario movement path executed but the asserted resource never changed. Capture effect-log.json, then check pickup/contact predicates, route coordinates, resource write declarations, and stale duplicate systems before rerunning." : `The scenario movement path executed and effect-log.json shows ${summary.entryCount} '${assertion.id}' resource snapshot(s) from ${summary.systems}; observed values stayed ${summary.distinctValues}. Check pickup/contact predicates, route coordinates, resource write declarations, and stale duplicate systems in the listed system(s).`
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
code: "",
|
|
128
|
+
message: `${kind === "hud" ? "HUD" : "Resource"} assertion failed for '${assertion.id}'${assertion.path === void 0 ? "" : ` path '${assertion.path}'`}.`,
|
|
129
|
+
severity: "error",
|
|
130
|
+
suggestion: unchanged ? `${kind === "hud" ? "Observed HUD value" : "Observed resource value"} did not change during the scenario. Inspect effect-log.json for the owning system's resource writes, run tn build --project . --json for undeclared writes, and check whether duplicate/stale systems or route/collision setup prevented the state transition.` : kind === "hud" ? "Check UI binding IDs and whether the backing resource changes during the scenario." : "Check resource IDs, script writes, and assertion path spelling."
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
function summarizeResourceEffectLog(effectLog, resourceId, path) {
|
|
134
|
+
if (!isRecord(effectLog) || !Array.isArray(effectLog.entries)) {
|
|
135
|
+
return void 0;
|
|
136
|
+
}
|
|
137
|
+
const entries = effectLog.entries.filter((entry) => isRecord(entry)).filter((entry) => entry.kind === "resource" && entry.resource === resourceId);
|
|
138
|
+
if (entries.length === 0) {
|
|
139
|
+
return void 0;
|
|
140
|
+
}
|
|
141
|
+
const systems = /* @__PURE__ */ new Set();
|
|
142
|
+
const values = /* @__PURE__ */ new Set();
|
|
143
|
+
for (const entry of entries) {
|
|
144
|
+
if (typeof entry.system === "string") {
|
|
145
|
+
systems.add(entry.system);
|
|
146
|
+
}
|
|
147
|
+
values.add(shortJson(readPath(entry.value, path)));
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
distinctValues: Array.from(values).slice(0, 3).join(", "),
|
|
151
|
+
entryCount: entries.length,
|
|
152
|
+
...[...systems].at(0) === void 0 ? {} : { sourcePath: sourcePathForSystem([...systems][0]), systemId: [...systems][0] },
|
|
153
|
+
systems: systems.size === 0 ? "unknown systems" : Array.from(systems).slice(0, 5).join(", ")
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
function sourcePathForSystem(systemId) {
|
|
157
|
+
return `content/systems/${systemId}.systems.json`;
|
|
158
|
+
}
|
|
159
|
+
function shortJson(value) {
|
|
160
|
+
const text = JSON.stringify(value);
|
|
161
|
+
if (text === void 0) {
|
|
162
|
+
return "undefined";
|
|
163
|
+
}
|
|
164
|
+
return text.length > 120 ? `${text.slice(0, 117)}...` : text;
|
|
165
|
+
}
|
|
166
|
+
function runtimeDiagnostics(value) {
|
|
167
|
+
const snapshot = runtimeDiagnosticsSnapshot(value);
|
|
168
|
+
if (snapshot !== value) {
|
|
169
|
+
return runtimeDiagnostics(snapshot);
|
|
170
|
+
}
|
|
171
|
+
if (!isRecord(snapshot)) {
|
|
172
|
+
return [];
|
|
173
|
+
}
|
|
174
|
+
const recentRuntimeErrors = Array.isArray(snapshot.recentRuntimeErrors) ? snapshot.recentRuntimeErrors : [];
|
|
175
|
+
const resourceFailures = isRecord(snapshot.assets) && Array.isArray(snapshot.assets.resourceFailures) ? snapshot.assets.resourceFailures : [];
|
|
176
|
+
return [...recentRuntimeErrors, ...resourceFailures];
|
|
177
|
+
}
|
|
178
|
+
function runtimeDiagnosticsSnapshot(value) {
|
|
179
|
+
if (isRecord(value) && isRecord(value.diagnostics)) {
|
|
180
|
+
return value.diagnostics;
|
|
181
|
+
}
|
|
182
|
+
return value;
|
|
183
|
+
}
|
|
184
|
+
function consoleErrors(entries) {
|
|
185
|
+
return entries.filter((entry) => entry.type === "error" || entry.type === "assert" || entry.type === "pageerror");
|
|
186
|
+
}
|
|
187
|
+
function readPath(value, path) {
|
|
188
|
+
if (path === void 0 || path.length === 0) {
|
|
189
|
+
return value;
|
|
190
|
+
}
|
|
191
|
+
return path.split(".").reduce((current, part) => {
|
|
192
|
+
if (Array.isArray(current) && /^(0|[1-9]\d*)$/u.test(part)) {
|
|
193
|
+
return current[Number(part)];
|
|
194
|
+
}
|
|
195
|
+
if (!isRecord(current)) {
|
|
196
|
+
return void 0;
|
|
197
|
+
}
|
|
198
|
+
return current[part];
|
|
199
|
+
}, value);
|
|
200
|
+
}
|
|
201
|
+
function parseMovementAxisExpectation(value) {
|
|
202
|
+
if (value === "x" || value === "y" || value === "z") {
|
|
203
|
+
return { axis: value };
|
|
204
|
+
}
|
|
205
|
+
const match = /^([+-])([xyz])$/.exec(value);
|
|
206
|
+
if (match === null) {
|
|
207
|
+
return void 0;
|
|
208
|
+
}
|
|
209
|
+
return { axis: match[2], sign: match[1] === "-" ? -1 : 1 };
|
|
210
|
+
}
|
|
211
|
+
function axisIndex(axis) {
|
|
212
|
+
return axis === "x" ? 0 : axis === "y" ? 1 : 2;
|
|
213
|
+
}
|
|
214
|
+
function textValue(value) {
|
|
215
|
+
if (isRecord(value)) {
|
|
216
|
+
return value.text ?? value.label ?? value.valueText ?? value.value;
|
|
217
|
+
}
|
|
218
|
+
return value;
|
|
219
|
+
}
|
|
220
|
+
function readRotation(value) {
|
|
221
|
+
if (!isRecord(value) || !Array.isArray(value.rotation) || value.rotation.length < 3) {
|
|
222
|
+
return void 0;
|
|
223
|
+
}
|
|
224
|
+
const rotation = value.rotation.slice(0, 3).map((item) => typeof item === "number" && Number.isFinite(item) ? item : Number.NaN);
|
|
225
|
+
return rotation.every(Number.isFinite) ? rotation : void 0;
|
|
226
|
+
}
|
|
227
|
+
function readVec3(value) {
|
|
228
|
+
if (!Array.isArray(value) || value.length < 3) {
|
|
229
|
+
return void 0;
|
|
230
|
+
}
|
|
231
|
+
const vector = value.slice(0, 3).map((item) => typeof item === "number" && Number.isFinite(item) ? item : Number.NaN);
|
|
232
|
+
return vector.every(Number.isFinite) ? vector : void 0;
|
|
233
|
+
}
|
|
234
|
+
function vectorDistance(left, right) {
|
|
235
|
+
const dx = right[0] - left[0];
|
|
236
|
+
const dy = right[1] - left[1];
|
|
237
|
+
const dz = right[2] - left[2];
|
|
238
|
+
return Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
239
|
+
}
|
|
240
|
+
function formatNumber(value) {
|
|
241
|
+
return Number.isInteger(value) ? String(value) : value.toFixed(3);
|
|
242
|
+
}
|
|
243
|
+
function jsonEqual(left, right) {
|
|
244
|
+
return JSON.stringify(left) === JSON.stringify(right);
|
|
245
|
+
}
|
|
246
|
+
function isRecord(value) {
|
|
247
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
248
|
+
}
|
|
249
|
+
|
|
48
250
|
// src/assertion-schema.ts
|
|
49
251
|
var PLAYTEST_ASSERTION_REGISTRY = [
|
|
50
252
|
{
|
|
@@ -124,11 +326,11 @@ var PLAYTEST_ASSERTION_REGISTRY = [
|
|
|
124
326
|
trivialityRationale: "It requires force telemetry and signed control delivery across samples; no held initial scalar can satisfy the proof."
|
|
125
327
|
},
|
|
126
328
|
{
|
|
127
|
-
description: "Proves screenshot change, populated regions, and sustained projected entity visibility.",
|
|
128
|
-
example: { visual: [{ frameDiff: { baselineImage: "artifacts/baseline.png", minChangedPixelRatio: 0.01 }, entityVisible: { entity: "board.e4", minProjectedPixels: 20, throughoutFrames: true } }] },
|
|
329
|
+
description: "Proves screenshot change, populated coordinate or DOM element-bound regions, dark-pixel bounds, and sustained projected entity visibility.",
|
|
330
|
+
example: { visual: [{ frameDiff: { baselineImage: "artifacts/baseline.png", minChangedPixelRatio: 0.01 }, entityVisible: { entity: "board.e4", minProjectedPixels: 20, throughoutFrames: true }, region: { element: { id: "error" }, minNonblankPixelRatio: 2e-3 } }] },
|
|
129
331
|
fields: [
|
|
130
332
|
{ description: "Before/after or baseline-image changed-pixel ratio bounds.", name: "frameDiff", type: "{ baselineImage?: project-relative PNG, minChangedPixelRatio?: number, maxChangedPixelRatio?: number }" },
|
|
131
|
-
{ description: "
|
|
333
|
+
{ description: "Static pixel bounds, or a DOM element whose bounds are captured beside the screenshot; the latter accepts exactly one id or selector. Both forms accept nonblank, dark-pixel, and luminance thresholds.", name: "region", type: "static bounds { x: number, y: number, width: number, height: number, minNonblankPixelRatio?: number, maxDarkPixelRatio?: number, minDarkPixelRatio?: number, maxLuminance?: number } or element bounds { element: { id?: string, selector?: string }, minNonblankPixelRatio?: number, maxDarkPixelRatio?: number, minDarkPixelRatio?: number, maxLuminance?: number }" },
|
|
132
334
|
{ description: "Entity projected-pixel floor, optionally across all captured samples.", name: "entityVisible", type: "{ entity: string, minProjectedPixels: number, throughoutFrames?: boolean }" }
|
|
133
335
|
],
|
|
134
336
|
cardinality: "array",
|
|
@@ -301,12 +503,13 @@ var PLAYTEST_ASSERTION_REGISTRY = [
|
|
|
301
503
|
{ description: "Maximum numeric value.", name: "lte", type: "number" },
|
|
302
504
|
{ description: "Substring expected in the observed value.", name: "textIncludes", type: "string" },
|
|
303
505
|
{ description: "Require before and after values to differ or remain equal.", name: "changed", type: "boolean" },
|
|
304
|
-
{ description: "Written reason for a held invariant whose initial value intentionally satisfies the assertion.", name: "allowTrivial", type: "triviality reason" }
|
|
506
|
+
{ description: "Written reason for a held invariant whose initial value intentionally satisfies the assertion.", name: "allowTrivial", type: "triviality reason" },
|
|
507
|
+
{ description: "Require the node to have a non-zero rendered box and be the topmost element at its viewport centre.", name: "visible", type: "boolean" }
|
|
305
508
|
],
|
|
306
509
|
cardinality: "array",
|
|
307
510
|
kind: "hud",
|
|
308
511
|
observationPath: "hud",
|
|
309
|
-
requiredCapabilities: ["
|
|
512
|
+
requiredCapabilities: ["browser.dom"],
|
|
310
513
|
resultIdPrefix: "hud.",
|
|
311
514
|
supportedOn: ["web"],
|
|
312
515
|
triviality: "reject-initial-value",
|
|
@@ -372,6 +575,25 @@ var PLAYTEST_ASSERTION_REGISTRY = [
|
|
|
372
575
|
triviality: "not-applicable",
|
|
373
576
|
trivialityRationale: "It reads aggregate render samples such as frame time and draw calls; an initial value cannot stand in for the measured series."
|
|
374
577
|
},
|
|
578
|
+
{
|
|
579
|
+
description: "PRD-222 Tier 2: proves the fps ratio of a parity pair \u2014 the same scene on the same device, once in the browser and once native. Lives in the second run and names the first run's saved report; refuses a pair whose halves ran on different devices, a thermally confounded half, or a missing series on either side.",
|
|
580
|
+
example: { parity: { minFpsRatio: 0.85, referenceReport: "reports/native.json", referenceSide: "native" } },
|
|
581
|
+
fields: [
|
|
582
|
+
{ description: "Floor on nativeFps \xF7 webFps. Tier 2's Floor is 0.85, Target 0.95.", name: "minFpsRatio", type: "positive number" },
|
|
583
|
+
{ description: "Optional floor on the inverted render-phase p95 ratio; fails closed when either side lacks the phase split.", name: "minRenderParity", type: "positive number" },
|
|
584
|
+
{ description: "Path to the other half's saved run report JSON, resolved against the project.", name: "referenceReport", type: "non-empty string" },
|
|
585
|
+
{ description: "Which side of the pair the reference is; the directed ratio needs it.", name: "referenceSide", type: "'browser' or 'native'" },
|
|
586
|
+
{ description: "Hydrated from the reference report at load; never written by hand.", name: "reference", type: "object" }
|
|
587
|
+
],
|
|
588
|
+
cardinality: "object",
|
|
589
|
+
kind: "parity",
|
|
590
|
+
observationPath: "performanceSeries",
|
|
591
|
+
requiredCapabilities: ["runtime.performance"],
|
|
592
|
+
resultIdPrefix: "parity.",
|
|
593
|
+
supportedOn: ["web", "desktop", "bevy"],
|
|
594
|
+
triviality: "not-applicable",
|
|
595
|
+
trivialityRationale: "It compares two measured run series; no initial in-scene value can satisfy a cross-run ratio."
|
|
596
|
+
},
|
|
375
597
|
{
|
|
376
598
|
description: "Proves projected entity visibility in the viewport.",
|
|
377
599
|
example: { visibility: [{ entity: "player", minProjectedPixels: 1200, maxOffscreenRatio: 0.05 }] },
|
|
@@ -475,6 +697,8 @@ var PLAYTEST_ASSERTION_REGISTRY = [
|
|
|
475
697
|
{ description: "Require entering the animation state.", name: "entered", type: "boolean" },
|
|
476
698
|
{ description: "Require animation advancement evidence.", name: "advancedFrames", type: "number" },
|
|
477
699
|
{ description: "Require the observed clip to report its completion state.", name: "finished", type: "boolean" },
|
|
700
|
+
{ description: "Ceiling on how far the feet and the ground disagree, as |feet - ground| / ground. Fails closed when the producer reports no stride.", name: "maxFootSlide", type: "number" },
|
|
701
|
+
{ description: "Require the stride convention to be applied (true) or deliberately overridden (false).", name: "strideSynced", type: "boolean" },
|
|
478
702
|
{ description: "Written reason for a held invariant whose initial value intentionally satisfies the assertion.", name: "allowTrivial", type: "triviality reason" }
|
|
479
703
|
],
|
|
480
704
|
cardinality: "array",
|
|
@@ -487,10 +711,97 @@ var PLAYTEST_ASSERTION_REGISTRY = [
|
|
|
487
711
|
trivialityRationale: "A clip can already be playing at the first sample; an entered assertion must prove a transition or document why the clip is held."
|
|
488
712
|
},
|
|
489
713
|
{
|
|
490
|
-
description: "
|
|
491
|
-
example: {
|
|
714
|
+
description: "Bounds the room the game is played in \u2014 the lights, materials, fog and camera framing the renderer was handed. Fails closed on a bridge that does not report the scene.",
|
|
715
|
+
example: { scene: { litMaterialsAreLit: true, minVisibleLights: 1 } },
|
|
716
|
+
fields: [
|
|
717
|
+
{ description: "Fail when the camera's far plane cuts the scene it is pointed at.", name: "cameraClearsScene", type: "boolean" },
|
|
718
|
+
{ description: "Fail when a linear fog reaches full colour in front of the scene it is fogging.", name: "fogClearsScene", type: "boolean" },
|
|
719
|
+
{ description: "Fail when lit materials are mounted and no light in the scene is visible.", name: "litMaterialsAreLit", type: "boolean" },
|
|
720
|
+
{ description: "Floor on how many lights in the scene are visible to the renderer.", name: "minVisibleLights", type: "number" },
|
|
721
|
+
{ description: "Written reason for a held invariant whose initial value intentionally satisfies the assertion.", name: "allowTrivial", type: "triviality reason" }
|
|
722
|
+
],
|
|
723
|
+
cardinality: "object",
|
|
724
|
+
kind: "scene",
|
|
725
|
+
observationPath: "scene",
|
|
726
|
+
requiredCapabilities: ["scene.observe"],
|
|
727
|
+
resultIdPrefix: "scene.",
|
|
728
|
+
supportedOn: ["web", "desktop", "bevy"],
|
|
729
|
+
triviality: "not-applicable",
|
|
730
|
+
trivialityRationale: "The room is a property of the scene as built, not of anything the scenario drives; a scene that is already lit is the assertion holding, not a trivial pass."
|
|
731
|
+
},
|
|
732
|
+
{
|
|
733
|
+
cardinality: "array",
|
|
734
|
+
description: "Bounds on named nodes of the scene graph \u2014 where an object is, whether it is on screen, whether its textures loaded.",
|
|
735
|
+
example: { sceneNodes: [{ inFrustum: true, select: { nameContains: "crate" }, texturesLoaded: true, visible: true }] },
|
|
736
|
+
fields: [
|
|
737
|
+
{ description: "Which nodes to bound, by name, nameContains, pathContains or type.", name: "select", type: "object" },
|
|
738
|
+
{ description: "Require every matched node visible with every ancestor visible too.", name: "visible", type: "boolean" },
|
|
739
|
+
{ description: "Require every matched node's world bounds inside the active camera's frustum.", name: "inFrustum", type: "boolean" },
|
|
740
|
+
{ description: "Require every bound texture slot on every matched node to carry pixels.", name: "texturesLoaded", type: "boolean" },
|
|
741
|
+
{ description: "Require every matched node to carry animation clips, or none to.", name: "animated", type: "boolean" },
|
|
742
|
+
{ description: "Floor on how many nodes the selector must match. Defaults to 1.", name: "minCount", type: "number" },
|
|
743
|
+
{ description: "Ceiling on how many nodes the selector may match. Zero asserts absence.", name: "maxCount", type: "number" },
|
|
744
|
+
{ description: "Floor on the summed triangle count across the matched nodes.", name: "minTriangles", type: "number" }
|
|
745
|
+
],
|
|
746
|
+
kind: "sceneNodes",
|
|
747
|
+
observationPath: "sceneNodes",
|
|
748
|
+
requiredCapabilities: ["scene.nodes"],
|
|
749
|
+
resultIdPrefix: "sceneNodes",
|
|
750
|
+
supportedOn: ["web", "desktop", "bevy"],
|
|
751
|
+
triviality: "not-applicable",
|
|
752
|
+
trivialityRationale: "A node's presence, visibility, framing and texture state are properties of the scene as built; a crate that is already on screen is the assertion holding, not a trivial pass."
|
|
753
|
+
},
|
|
754
|
+
{
|
|
755
|
+
cardinality: "array",
|
|
756
|
+
description: "Relates a tick-stamped effect to the tick-stamped cause that must precede it \u2014 the 'because' a terminal state needs.",
|
|
757
|
+
example: {
|
|
758
|
+
causedBy: [
|
|
759
|
+
{
|
|
760
|
+
cause: { contact: { entity: "player", kind: "trigger", with: "seal" } },
|
|
761
|
+
effect: { becomes: "won", path: "state.status" },
|
|
762
|
+
neverBefore: true,
|
|
763
|
+
withinTicks: 4
|
|
764
|
+
}
|
|
765
|
+
]
|
|
766
|
+
},
|
|
767
|
+
fields: [
|
|
768
|
+
{ description: "The event that must happen first: a contact, or another transition.", name: "cause", type: "object" },
|
|
769
|
+
{ description: "The published value whose change is being explained: path and becomes.", name: "effect", type: "object" },
|
|
770
|
+
{ description: "Fail when the effect is ever observed before the first matching cause.", name: "neverBefore", type: "boolean" },
|
|
771
|
+
{ description: "Ceiling on effectTick minus causeTick.", name: "withinTicks", type: "number" }
|
|
772
|
+
],
|
|
773
|
+
kind: "causedBy",
|
|
774
|
+
observationPath: "runtimeObservations",
|
|
775
|
+
requiredCapabilities: ["runtime.transitions"],
|
|
776
|
+
resultIdPrefix: "causedBy",
|
|
777
|
+
supportedOn: ["web", "desktop", "bevy"],
|
|
778
|
+
triviality: "not-applicable",
|
|
779
|
+
trivialityRationale: "It relates two tick-stamped observations the run produced; a pre-existing value cannot manufacture an ordering, and a value already at the asserted state never transitions to it."
|
|
780
|
+
},
|
|
781
|
+
{
|
|
782
|
+
description: "Bounds when the application's startup milestones happened: the world entered, first-use compilation settled, readiness reached \u2014 in milliseconds since navigation, from the runtime's own startup timeline.",
|
|
783
|
+
example: { startup: { maxEnteredMs: 2500, maxReadyMs: 8e3 } },
|
|
784
|
+
fields: [
|
|
785
|
+
{ description: "Ceiling on when the start scene's enter() returned, in ms since navigation.", name: "maxEnteredMs", type: "number" },
|
|
786
|
+
{ description: "Ceiling on when first-use compilation settled or its budget expired, in ms since navigation.", name: "maxCompileSettledMs", type: "number" },
|
|
787
|
+
{ description: "Ceiling on when startup readiness resolved, in ms since navigation.", name: "maxReadyMs", type: "number" }
|
|
788
|
+
],
|
|
789
|
+
cardinality: "object",
|
|
790
|
+
kind: "startup",
|
|
791
|
+
observationPath: "startup",
|
|
792
|
+
requiredCapabilities: ["runtime.startup"],
|
|
793
|
+
resultIdPrefix: "startup.",
|
|
794
|
+
supportedOn: ["web", "desktop", "bevy"],
|
|
795
|
+
triviality: "not-applicable",
|
|
796
|
+
trivialityRationale: "The timeline is stamped by the runtime as milestones happen; a missing milestone fails the ceiling rather than passing it."
|
|
797
|
+
},
|
|
798
|
+
{
|
|
799
|
+
description: "Proves the render chain reports its quality tier, authored stage ids/order, graph-output changes for named stages, and, when asserted, a bounded temporal-history rejection fraction.",
|
|
800
|
+
example: { renderChain: { tier: "high", stages: { includes: ["outline", "kuwahara", "watercolor"], order: ["outline", "kuwahara", "watercolor"] }, contributions: { graphOutputChanged: ["outline", "kuwahara", "watercolor"] } } },
|
|
492
801
|
fields: [
|
|
493
802
|
{ description: "Exact render-chain quality tier required after the chain applies.", name: "tier", type: "string" },
|
|
803
|
+
{ description: "Stage ids to include, exclude, or find as an ordered subsequence in the applied chain.", name: "stages", type: "object" },
|
|
804
|
+
{ description: "Applied stage ids whose build returned a different graph node than its input; this is graph evidence, not pixel attribution.", name: "contributions", type: "object" },
|
|
494
805
|
{ description: "Temporal history rejection ceiling as a fraction from 0 to 1.", name: "velocity", type: "object" }
|
|
495
806
|
],
|
|
496
807
|
cardinality: "object",
|
|
@@ -530,8 +841,11 @@ var PLAYTEST_SETUP_REGISTRY = [
|
|
|
530
841
|
requiredCapabilities: ["runtime.resources"]
|
|
531
842
|
}
|
|
532
843
|
];
|
|
533
|
-
function requiredPlaytestCapabilities(scenario) {
|
|
844
|
+
function requiredPlaytestCapabilities(scenario, target) {
|
|
534
845
|
const required = /* @__PURE__ */ new Set();
|
|
846
|
+
if (scenario.steps.some((step) => step.waitForResource !== void 0)) {
|
|
847
|
+
required.add("runtime.resources");
|
|
848
|
+
}
|
|
535
849
|
if (scenario.steps.some((step) => step.kind !== "wait" && (step.press !== void 0 || step.pointerPosition !== void 0 || step.pointers !== void 0))) {
|
|
536
850
|
required.add("browser.input");
|
|
537
851
|
}
|
|
@@ -544,10 +858,10 @@ function requiredPlaytestCapabilities(scenario) {
|
|
|
544
858
|
for (const entry of PLAYTEST_ASSERTION_REGISTRY) {
|
|
545
859
|
if (scenario.assert?.[entry.kind] !== void 0) {
|
|
546
860
|
if (entry.kind === "diagnostics") {
|
|
547
|
-
const policy = scenario.assert.diagnostics;
|
|
548
|
-
if (policy
|
|
549
|
-
if (policy
|
|
550
|
-
if (policy
|
|
861
|
+
const policy = resolveDiagnosticsPolicy(scenario.assert.diagnostics, target);
|
|
862
|
+
if (policy.noConsoleErrors) required.add("browser.console");
|
|
863
|
+
if (policy.noNetworkErrors) required.add("browser.network");
|
|
864
|
+
if (policy.noRuntimeDiagnostics) required.add("runtime.diagnostics");
|
|
551
865
|
} else {
|
|
552
866
|
entry.requiredCapabilities.forEach((capability2) => required.add(capability2));
|
|
553
867
|
}
|
|
@@ -678,203 +992,10 @@ function format(value) {
|
|
|
678
992
|
return value === null ? "unknown" : String(value);
|
|
679
993
|
}
|
|
680
994
|
|
|
681
|
-
// src/
|
|
682
|
-
function
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
...policy?.networkErrorsOptOutReason === void 0 ? {} : { networkErrorsOptOutReason: policy.networkErrorsOptOutReason },
|
|
686
|
-
noConsoleErrors: policy?.noConsoleErrors ?? true,
|
|
687
|
-
noNetworkErrors: policy?.noNetworkErrors ?? true,
|
|
688
|
-
noRuntimeDiagnostics: policy?.noRuntimeDiagnostics ?? true,
|
|
689
|
-
...policy?.runtimeReady === void 0 ? {} : { runtimeReady: policy.runtimeReady },
|
|
690
|
-
...policy?.runtimeDiagnosticsOptOutReason === void 0 ? {} : { runtimeDiagnosticsOptOutReason: policy.runtimeDiagnosticsOptOutReason }
|
|
691
|
-
};
|
|
692
|
-
}
|
|
693
|
-
function trivialAssertionDiagnostic(id, path, before, sourcePath) {
|
|
694
|
-
return {
|
|
695
|
-
code: "TN_PLAYTEST_ASSERTION_TRIVIAL",
|
|
696
|
-
message: `Assertion '${id}'${path === void 0 ? "" : ` at path '${path}'`} was already satisfied before the scenario ran (value ${JSON.stringify(before)}).`,
|
|
697
|
-
path,
|
|
698
|
-
severity: "error",
|
|
699
|
-
...sourcePath === void 0 ? {} : { sourcePath },
|
|
700
|
-
suggestion: "Drive the asserted value from a failing initial state, or assert changed:true. If the value is genuinely a held invariant, allowTrivial takes the reason it is held \u2014 it is recorded in the report and counted against the run."
|
|
701
|
-
};
|
|
702
|
-
}
|
|
703
|
-
function componentAssertionDiagnostic(assertion, before, after) {
|
|
704
|
-
return {
|
|
705
|
-
code: "TN_PLAYTEST_COMPONENT_ASSERTION_FAILED",
|
|
706
|
-
message: `Component '${assertion.component}' on entity '${assertion.entity}'${assertion.path === void 0 ? "" : ` path '${assertion.path}'`} did not satisfy the assertion.`,
|
|
707
|
-
observedRuntimePath: `observations.json/components/${assertion.entity}/${assertion.component}`,
|
|
708
|
-
severity: "error",
|
|
709
|
-
suggestion: `Expected ${JSON.stringify(assertion)}, observed before=${JSON.stringify(before)} after=${JSON.stringify(after)}. Check the owning script and runtime component synchronization.`
|
|
710
|
-
};
|
|
711
|
-
}
|
|
712
|
-
function finiteVector(value) {
|
|
713
|
-
return Array.isArray(value) && value.length === 3 && value.every((item) => typeof item === "number" && Number.isFinite(item));
|
|
714
|
-
}
|
|
715
|
-
function record(value) {
|
|
716
|
-
return isRecord(value) ? value : void 0;
|
|
717
|
-
}
|
|
718
|
-
function expectedPathAssertion(assertion) {
|
|
719
|
-
return {
|
|
720
|
-
...assertion.atSteps === void 0 ? {} : { atSteps: assertion.atSteps },
|
|
721
|
-
...Object.hasOwn(assertion, "equals") ? { equals: assertion.equals } : {},
|
|
722
|
-
...assertion.gte === void 0 ? {} : { gte: assertion.gte },
|
|
723
|
-
...assertion.lte === void 0 ? {} : { lte: assertion.lte },
|
|
724
|
-
...assertion.textIncludes === void 0 ? {} : { textIncludes: assertion.textIncludes },
|
|
725
|
-
...assertion.throughoutSteps === void 0 ? {} : { throughoutSteps: assertion.throughoutSteps },
|
|
726
|
-
...assertion.changed === void 0 ? {} : { changed: assertion.changed },
|
|
727
|
-
...assertion.allowTrivial === void 0 ? {} : { allowTrivial: assertion.allowTrivial }
|
|
728
|
-
};
|
|
729
|
-
}
|
|
730
|
-
function unchangedPathValue(before, after) {
|
|
731
|
-
return before !== void 0 && after !== void 0 && jsonEqual(before, after);
|
|
732
|
-
}
|
|
733
|
-
function pathAssertionDiagnostic(kind, assertion, before, after, context) {
|
|
734
|
-
const unchanged = unchangedPathValue(before, after);
|
|
735
|
-
if (kind === "resource" && unchanged && (context.movedDistance ?? 0) > 0.01) {
|
|
736
|
-
const summary = summarizeResourceEffectLog(context.effectLog, assertion.id, assertion.path);
|
|
737
|
-
return {
|
|
738
|
-
code: "TN_PLAYTEST_RESOURCE_STATE_STAGNATED",
|
|
739
|
-
message: `Resource '${assertion.id}'${assertion.path === void 0 ? "" : ` path '${assertion.path}'`} did not change after the scenario moved the subject ${formatNumber(context.movedDistance ?? 0)} units.`,
|
|
740
|
-
artifactPath: "effect-log.json",
|
|
741
|
-
observedRuntimePath: `effect-log.json/entries[kind=resource,resource=${assertion.id}]`,
|
|
742
|
-
path: assertion.path === void 0 ? `${context.scenarioSourcePath ?? "playtest"}/assert/resources/${assertion.id}` : `${context.scenarioSourcePath ?? "playtest"}/assert/resources/${assertion.id}/${assertion.path}`,
|
|
743
|
-
resourceId: assertion.id,
|
|
744
|
-
severity: "error",
|
|
745
|
-
...context.scenarioSourcePath === void 0 ? {} : { sourcePath: context.scenarioSourcePath },
|
|
746
|
-
...summary?.systemId === void 0 ? {} : { systemId: summary.systemId, sourcePath: summary.sourcePath },
|
|
747
|
-
suggestion: summary === void 0 ? "The scenario movement path executed but the asserted resource never changed. Capture effect-log.json, then check pickup/contact predicates, route coordinates, resource write declarations, and stale duplicate systems before rerunning." : `The scenario movement path executed and effect-log.json shows ${summary.entryCount} '${assertion.id}' resource snapshot(s) from ${summary.systems}; observed values stayed ${summary.distinctValues}. Check pickup/contact predicates, route coordinates, resource write declarations, and stale duplicate systems in the listed system(s).`
|
|
748
|
-
};
|
|
749
|
-
}
|
|
750
|
-
return {
|
|
751
|
-
code: "",
|
|
752
|
-
message: `${kind === "hud" ? "HUD" : "Resource"} assertion failed for '${assertion.id}'${assertion.path === void 0 ? "" : ` path '${assertion.path}'`}.`,
|
|
753
|
-
severity: "error",
|
|
754
|
-
suggestion: unchanged ? `${kind === "hud" ? "Observed HUD value" : "Observed resource value"} did not change during the scenario. Inspect effect-log.json for the owning system's resource writes, run tn build --project . --json for undeclared writes, and check whether duplicate/stale systems or route/collision setup prevented the state transition.` : kind === "hud" ? "Check UI binding IDs and whether the backing resource changes during the scenario." : "Check resource IDs, script writes, and assertion path spelling."
|
|
755
|
-
};
|
|
756
|
-
}
|
|
757
|
-
function summarizeResourceEffectLog(effectLog, resourceId, path) {
|
|
758
|
-
if (!isRecord(effectLog) || !Array.isArray(effectLog.entries)) {
|
|
759
|
-
return void 0;
|
|
760
|
-
}
|
|
761
|
-
const entries = effectLog.entries.filter((entry) => isRecord(entry)).filter((entry) => entry.kind === "resource" && entry.resource === resourceId);
|
|
762
|
-
if (entries.length === 0) {
|
|
763
|
-
return void 0;
|
|
764
|
-
}
|
|
765
|
-
const systems = /* @__PURE__ */ new Set();
|
|
766
|
-
const values = /* @__PURE__ */ new Set();
|
|
767
|
-
for (const entry of entries) {
|
|
768
|
-
if (typeof entry.system === "string") {
|
|
769
|
-
systems.add(entry.system);
|
|
770
|
-
}
|
|
771
|
-
values.add(shortJson(readPath(entry.value, path)));
|
|
772
|
-
}
|
|
773
|
-
return {
|
|
774
|
-
distinctValues: Array.from(values).slice(0, 3).join(", "),
|
|
775
|
-
entryCount: entries.length,
|
|
776
|
-
...[...systems].at(0) === void 0 ? {} : { sourcePath: sourcePathForSystem([...systems][0]), systemId: [...systems][0] },
|
|
777
|
-
systems: systems.size === 0 ? "unknown systems" : Array.from(systems).slice(0, 5).join(", ")
|
|
778
|
-
};
|
|
779
|
-
}
|
|
780
|
-
function sourcePathForSystem(systemId) {
|
|
781
|
-
return `content/systems/${systemId}.systems.json`;
|
|
782
|
-
}
|
|
783
|
-
function shortJson(value) {
|
|
784
|
-
const text = JSON.stringify(value);
|
|
785
|
-
if (text === void 0) {
|
|
786
|
-
return "undefined";
|
|
787
|
-
}
|
|
788
|
-
return text.length > 120 ? `${text.slice(0, 117)}...` : text;
|
|
789
|
-
}
|
|
790
|
-
function runtimeDiagnostics(value) {
|
|
791
|
-
const snapshot = runtimeDiagnosticsSnapshot(value);
|
|
792
|
-
if (snapshot !== value) {
|
|
793
|
-
return runtimeDiagnostics(snapshot);
|
|
794
|
-
}
|
|
795
|
-
if (!isRecord(snapshot)) {
|
|
796
|
-
return [];
|
|
797
|
-
}
|
|
798
|
-
const recentRuntimeErrors = Array.isArray(snapshot.recentRuntimeErrors) ? snapshot.recentRuntimeErrors : [];
|
|
799
|
-
const resourceFailures = isRecord(snapshot.assets) && Array.isArray(snapshot.assets.resourceFailures) ? snapshot.assets.resourceFailures : [];
|
|
800
|
-
return [...recentRuntimeErrors, ...resourceFailures];
|
|
801
|
-
}
|
|
802
|
-
function runtimeDiagnosticsSnapshot(value) {
|
|
803
|
-
if (isRecord(value) && isRecord(value.diagnostics)) {
|
|
804
|
-
return value.diagnostics;
|
|
805
|
-
}
|
|
806
|
-
return value;
|
|
807
|
-
}
|
|
808
|
-
function consoleErrors(entries) {
|
|
809
|
-
return entries.filter((entry) => entry.type === "error" || entry.type === "assert" || entry.type === "pageerror");
|
|
810
|
-
}
|
|
811
|
-
function readPath(value, path) {
|
|
812
|
-
if (path === void 0 || path.length === 0) {
|
|
813
|
-
return value;
|
|
814
|
-
}
|
|
815
|
-
return path.split(".").reduce((current, part) => {
|
|
816
|
-
if (Array.isArray(current) && /^(0|[1-9]\d*)$/u.test(part)) {
|
|
817
|
-
return current[Number(part)];
|
|
818
|
-
}
|
|
819
|
-
if (!isRecord(current)) {
|
|
820
|
-
return void 0;
|
|
821
|
-
}
|
|
822
|
-
return current[part];
|
|
823
|
-
}, value);
|
|
824
|
-
}
|
|
825
|
-
function parseMovementAxisExpectation(value) {
|
|
826
|
-
if (value === "x" || value === "y" || value === "z") {
|
|
827
|
-
return { axis: value };
|
|
828
|
-
}
|
|
829
|
-
const match = /^([+-])([xyz])$/.exec(value);
|
|
830
|
-
if (match === null) {
|
|
831
|
-
return void 0;
|
|
832
|
-
}
|
|
833
|
-
return { axis: match[2], sign: match[1] === "-" ? -1 : 1 };
|
|
834
|
-
}
|
|
835
|
-
function axisIndex(axis) {
|
|
836
|
-
return axis === "x" ? 0 : axis === "y" ? 1 : 2;
|
|
837
|
-
}
|
|
838
|
-
function textValue(value) {
|
|
839
|
-
if (isRecord(value)) {
|
|
840
|
-
return value.text ?? value.label ?? value.valueText ?? value.value;
|
|
841
|
-
}
|
|
842
|
-
return value;
|
|
843
|
-
}
|
|
844
|
-
function readRotation(value) {
|
|
845
|
-
if (!isRecord(value) || !Array.isArray(value.rotation) || value.rotation.length < 3) {
|
|
846
|
-
return void 0;
|
|
847
|
-
}
|
|
848
|
-
const rotation = value.rotation.slice(0, 3).map((item) => typeof item === "number" && Number.isFinite(item) ? item : Number.NaN);
|
|
849
|
-
return rotation.every(Number.isFinite) ? rotation : void 0;
|
|
850
|
-
}
|
|
851
|
-
function readVec3(value) {
|
|
852
|
-
if (!Array.isArray(value) || value.length < 3) {
|
|
853
|
-
return void 0;
|
|
854
|
-
}
|
|
855
|
-
const vector = value.slice(0, 3).map((item) => typeof item === "number" && Number.isFinite(item) ? item : Number.NaN);
|
|
856
|
-
return vector.every(Number.isFinite) ? vector : void 0;
|
|
857
|
-
}
|
|
858
|
-
function vectorDistance(left, right) {
|
|
859
|
-
const dx = right[0] - left[0];
|
|
860
|
-
const dy = right[1] - left[1];
|
|
861
|
-
const dz = right[2] - left[2];
|
|
862
|
-
return Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
863
|
-
}
|
|
864
|
-
function formatNumber(value) {
|
|
865
|
-
return Number.isInteger(value) ? String(value) : value.toFixed(3);
|
|
866
|
-
}
|
|
867
|
-
function jsonEqual(left, right) {
|
|
868
|
-
return JSON.stringify(left) === JSON.stringify(right);
|
|
869
|
-
}
|
|
870
|
-
function isRecord(value) {
|
|
871
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
// src/evaluators/measures.ts
|
|
875
|
-
function horizontalRadius(transform, direction) {
|
|
876
|
-
const halfExtents = transform?.halfExtents ?? (transform?.scale === void 0 ? void 0 : transform.scale.map((value) => Math.abs(value) * 0.5));
|
|
877
|
-
return halfExtents === void 0 ? 0 : Math.abs(direction[0]) * Math.abs(halfExtents[0]) + Math.abs(direction[1]) * Math.abs(halfExtents[2]);
|
|
995
|
+
// src/evaluators/measures.ts
|
|
996
|
+
function horizontalRadius(transform, direction) {
|
|
997
|
+
const halfExtents = transform?.halfExtents ?? (transform?.scale === void 0 ? void 0 : transform.scale.map((value) => Math.abs(value) * 0.5));
|
|
998
|
+
return halfExtents === void 0 ? 0 : Math.abs(direction[0]) * Math.abs(halfExtents[0]) + Math.abs(direction[1]) * Math.abs(halfExtents[2]);
|
|
878
999
|
}
|
|
879
1000
|
function platformTop(transform) {
|
|
880
1001
|
const halfHeight = transform.halfExtents?.[1] ?? (transform.scale === void 0 ? 0 : Math.abs(transform.scale[1]) * 0.5);
|
|
@@ -997,6 +1118,10 @@ function evaluatePathAssertion(kind, assertion, observed, context) {
|
|
|
997
1118
|
valueChecksBefore.push(String(textValue(before)).includes(assertion.textIncludes));
|
|
998
1119
|
valueChecksAfter.push(String(textValue(after)).includes(assertion.textIncludes));
|
|
999
1120
|
}
|
|
1121
|
+
if (assertion.visible !== void 0) {
|
|
1122
|
+
valueChecksBefore.push(isRecord(before) && before.visible === assertion.visible);
|
|
1123
|
+
valueChecksAfter.push(isRecord(after) && after.visible === assertion.visible);
|
|
1124
|
+
}
|
|
1000
1125
|
const trivial = rejectsTrivialAssertion(kind === "hud" ? "hud" : "resources") && valueChecksBefore.length > 0 && before !== void 0 && valueChecksBefore.every(Boolean);
|
|
1001
1126
|
const checks = [...valueChecksAfter];
|
|
1002
1127
|
if (assertion.changed !== void 0) {
|
|
@@ -1449,7 +1574,60 @@ function animationObservationPass(assertion, observed) {
|
|
|
1449
1574
|
const clip = typeof observed.clip === "string" ? observed.clip : void 0;
|
|
1450
1575
|
const advancedFrames = typeof observed.advancedFrames === "number" ? observed.advancedFrames : void 0;
|
|
1451
1576
|
const finished = typeof observed.finished === "boolean" ? observed.finished : void 0;
|
|
1452
|
-
return (assertion.clip === void 0 || clip === assertion.clip) && (assertion.entered !== true || clip !== void 0) && (assertion.finished === void 0 || finished !== void 0 && finished === assertion.finished) && (assertion.advancedFrames === void 0 || advancedFrames !== void 0 && advancedFrames >= assertion.advancedFrames);
|
|
1577
|
+
return (assertion.clip === void 0 || clip === assertion.clip) && (assertion.entered !== true || clip !== void 0) && (assertion.finished === void 0 || finished !== void 0 && finished === assertion.finished) && (assertion.advancedFrames === void 0 || advancedFrames !== void 0 && advancedFrames >= assertion.advancedFrames) && strideFailure(assertion, observed) === void 0;
|
|
1578
|
+
}
|
|
1579
|
+
function strideReading(observed) {
|
|
1580
|
+
if (!isRecord(observed)) return void 0;
|
|
1581
|
+
const stride = observed.stride;
|
|
1582
|
+
if (!isRecord(stride)) return void 0;
|
|
1583
|
+
const numbers = ["clipGroundSpeed", "groundSpeed", "rate"];
|
|
1584
|
+
if (!numbers.every((key) => typeof stride[key] === "number" && Number.isFinite(stride[key]))) return void 0;
|
|
1585
|
+
if (typeof stride.overridden !== "boolean" || typeof stride.synced !== "boolean") return void 0;
|
|
1586
|
+
return {
|
|
1587
|
+
clipGroundSpeed: stride.clipGroundSpeed,
|
|
1588
|
+
groundSpeed: stride.groundSpeed,
|
|
1589
|
+
overridden: stride.overridden,
|
|
1590
|
+
rate: stride.rate,
|
|
1591
|
+
synced: stride.synced
|
|
1592
|
+
};
|
|
1593
|
+
}
|
|
1594
|
+
var STRIDE_GROUND_SPEED_FLOOR = 1e-3;
|
|
1595
|
+
function appliedStrideRate(reading) {
|
|
1596
|
+
return reading.synced ? reading.rate : 1;
|
|
1597
|
+
}
|
|
1598
|
+
function strideFeetSpeed(reading) {
|
|
1599
|
+
return reading.clipGroundSpeed * appliedStrideRate(reading);
|
|
1600
|
+
}
|
|
1601
|
+
function footSlideRatio(reading) {
|
|
1602
|
+
if (Math.abs(reading.groundSpeed) <= STRIDE_GROUND_SPEED_FLOOR) return void 0;
|
|
1603
|
+
return Math.abs(strideFeetSpeed(reading) - reading.groundSpeed) / Math.abs(reading.groundSpeed);
|
|
1604
|
+
}
|
|
1605
|
+
function strideFailure(assertion, observed) {
|
|
1606
|
+
if (assertion.maxFootSlide === void 0 && assertion.strideSynced === void 0) return void 0;
|
|
1607
|
+
const reading = strideReading(observed);
|
|
1608
|
+
if (reading === void 0)
|
|
1609
|
+
return {
|
|
1610
|
+
code: "TN_PLAYTEST_STRIDE_UNOBSERVED",
|
|
1611
|
+
detail: "the runtime reported no stride for this clip, so neither the feet nor the ground were measured"
|
|
1612
|
+
};
|
|
1613
|
+
if (assertion.strideSynced !== void 0 && reading.synced !== assertion.strideSynced)
|
|
1614
|
+
return {
|
|
1615
|
+
code: "TN_PLAYTEST_STRIDE_NOT_SYNCED",
|
|
1616
|
+
detail: `stride sync is ${reading.synced ? "applied" : "not applied"}, expected ${assertion.strideSynced ? "applied" : "not applied"}${reading.overridden ? " (the game set strideSync: false)" : ""}`
|
|
1617
|
+
};
|
|
1618
|
+
if (assertion.maxFootSlide === void 0) return void 0;
|
|
1619
|
+
const ratio = footSlideRatio(reading);
|
|
1620
|
+
if (ratio === void 0)
|
|
1621
|
+
return {
|
|
1622
|
+
code: "TN_PLAYTEST_STRIDE_UNOBSERVED",
|
|
1623
|
+
detail: "the body covered no ground between samples, so foot slide was not measurable \u2014 drive the subject before bounding it"
|
|
1624
|
+
};
|
|
1625
|
+
if (ratio > assertion.maxFootSlide)
|
|
1626
|
+
return {
|
|
1627
|
+
code: "TN_PLAYTEST_FOOT_SLIDE",
|
|
1628
|
+
detail: `feet carry ${strideFeetSpeed(reading).toFixed(3)} m/s against ${reading.groundSpeed.toFixed(3)} m/s of ground \u2014 ${(ratio * 100).toFixed(0)}% apart, ceiling ${(assertion.maxFootSlide * 100).toFixed(0)}%`
|
|
1629
|
+
};
|
|
1630
|
+
return void 0;
|
|
1453
1631
|
}
|
|
1454
1632
|
function runtimeGameplaySamples(value) {
|
|
1455
1633
|
const runtime = runtimeObservationValue(value);
|
|
@@ -1869,28 +2047,108 @@ function emitEvidenceFamilies(ctx) {
|
|
|
1869
2047
|
if (!pass) diagnostics.push({ code: "TN_PLAYTEST_FRAME_DIFF_FAILED", message: `Screenshot changed-pixel ratio ${ratio ?? "unavailable"} was outside the asserted range.`, severity: "error", suggestion: "Check whether the expected visual change rendered and whether the thresholds match the scenario." });
|
|
1870
2048
|
}
|
|
1871
2049
|
if (visual.region !== void 0) {
|
|
1872
|
-
const observed = input.report.observations?.visual?.nonblankRegions?.find((region) => region.x === visual.region?.x && region.y === visual.region.y && region.width === visual.region.width && region.height === visual.region.height);
|
|
1873
2050
|
const minimum = visual.region.minNonblankPixelRatio ?? 2e-3;
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
const
|
|
2051
|
+
if ("element" in visual.region) {
|
|
2052
|
+
const observed = input.report.observations?.visual?.elementRegions?.find(({ assertionIndex }) => assertionIndex === index);
|
|
2053
|
+
const bounds = observed?.bounds;
|
|
2054
|
+
const hasBounds = bounds !== void 0 && Number.isFinite(bounds.x) && Number.isFinite(bounds.y) && Number.isFinite(bounds.width) && Number.isFinite(bounds.height) && bounds.width > 0 && bounds.height > 0;
|
|
2055
|
+
const pass = observed?.rendered === true && hasBounds && observed.nonblankPixelRatio !== void 0 && observed.nonblankPixelRatio >= minimum;
|
|
1879
2056
|
assertions.push({
|
|
1880
|
-
id: `visual.${index}.region
|
|
1881
|
-
pass
|
|
2057
|
+
id: `visual.${index}.region`,
|
|
2058
|
+
pass,
|
|
1882
2059
|
details: {
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
2060
|
+
after: pass,
|
|
2061
|
+
bounds: observed?.bounds,
|
|
2062
|
+
element: visual.region.element,
|
|
2063
|
+
expected: { equals: true },
|
|
2064
|
+
minimum,
|
|
2065
|
+
observed: observed?.nonblankPixelRatio,
|
|
2066
|
+
rendered: observed?.rendered ?? false
|
|
1886
2067
|
}
|
|
1887
2068
|
});
|
|
1888
|
-
if (!
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
2069
|
+
if (!pass) diagnostics.push({ code: "TN_PLAYTEST_REGION_BLANK", message: `Screenshot bounds for element '${describeVisualElement(visual.region.element)}' did not meet nonblank ratio ${minimum}.`, severity: "error", suggestion: "Check that the target element exists, has rendered computed styles, and contains nonblank screenshot pixels." });
|
|
2070
|
+
if (visual.region.minDarkPixelRatio !== void 0) {
|
|
2071
|
+
const darkPass = observed?.rendered === true && hasBounds && observed.darkPixelRatio !== void 0 && observed.darkPixelRatio >= visual.region.minDarkPixelRatio;
|
|
2072
|
+
assertions.push({
|
|
2073
|
+
id: `visual.${index}.region.darkPixels`,
|
|
2074
|
+
pass: darkPass,
|
|
2075
|
+
details: {
|
|
2076
|
+
bounds: observed?.bounds,
|
|
2077
|
+
element: visual.region.element,
|
|
2078
|
+
maximumLuminance: visual.region.maxLuminance ?? 0.25,
|
|
2079
|
+
minimumDarkPixelRatio: visual.region.minDarkPixelRatio,
|
|
2080
|
+
observedDarkPixelRatio: observed?.darkPixelRatio,
|
|
2081
|
+
rendered: observed?.rendered ?? false
|
|
2082
|
+
}
|
|
2083
|
+
});
|
|
2084
|
+
if (!darkPass) diagnostics.push({
|
|
2085
|
+
code: "TN_PLAYTEST_REGION_DARK_PIXEL_RATIO_FAILED",
|
|
2086
|
+
message: `Screenshot bounds for element '${describeVisualElement(visual.region.element)}' contained ${observed?.darkPixelRatio ?? "unavailable"} dark pixels, below required ratio ${visual.region.minDarkPixelRatio}.`,
|
|
2087
|
+
severity: "error",
|
|
2088
|
+
suggestion: "Check that the target element renders the expected foreground pixels inside its captured bounds."
|
|
2089
|
+
});
|
|
2090
|
+
}
|
|
2091
|
+
if (visual.region.maxDarkPixelRatio !== void 0) {
|
|
2092
|
+
const darkPass = observed?.rendered === true && hasBounds && observed.darkPixelRatio !== void 0 && observed.darkPixelRatio <= visual.region.maxDarkPixelRatio;
|
|
2093
|
+
assertions.push({
|
|
2094
|
+
id: `visual.${index}.region.maxDarkPixels`,
|
|
2095
|
+
pass: darkPass,
|
|
2096
|
+
details: {
|
|
2097
|
+
bounds: observed?.bounds,
|
|
2098
|
+
element: visual.region.element,
|
|
2099
|
+
maximumDarkPixelRatio: visual.region.maxDarkPixelRatio,
|
|
2100
|
+
observedDarkPixelRatio: observed?.darkPixelRatio,
|
|
2101
|
+
rendered: observed?.rendered ?? false
|
|
2102
|
+
}
|
|
2103
|
+
});
|
|
2104
|
+
if (!darkPass) diagnostics.push({
|
|
2105
|
+
code: "TN_PLAYTEST_REGION_DARK_PIXEL_RATIO_EXCEEDED",
|
|
2106
|
+
message: `Screenshot bounds for element '${describeVisualElement(visual.region.element)}' contained ${observed?.darkPixelRatio ?? "unavailable"} dark pixels, above maximum ratio ${visual.region.maxDarkPixelRatio}.`,
|
|
2107
|
+
severity: "error",
|
|
2108
|
+
suggestion: "Check whether unexpected dark foreground geometry occupies the asserted element bounds."
|
|
2109
|
+
});
|
|
2110
|
+
}
|
|
2111
|
+
} else {
|
|
2112
|
+
const staticRegion = visual.region;
|
|
2113
|
+
const observed = input.report.observations?.visual?.nonblankRegions?.find((region) => region.x === staticRegion.x && region.y === staticRegion.y && region.width === staticRegion.width && region.height === staticRegion.height);
|
|
2114
|
+
const pass = observed !== void 0 && observed.nonblankPixelRatio >= minimum;
|
|
2115
|
+
assertions.push({ id: `visual.${index}.region`, pass, details: { after: pass, expected: { equals: true }, minimum, observed: observed?.nonblankPixelRatio } });
|
|
2116
|
+
if (!pass) diagnostics.push({ code: "TN_PLAYTEST_REGION_BLANK", message: `Screenshot region at (${staticRegion.x}, ${staticRegion.y}) did not meet nonblank ratio ${minimum}.`, severity: "error", suggestion: "Check camera framing and whether expected geometry renders in the asserted region." });
|
|
2117
|
+
if (staticRegion.minDarkPixelRatio !== void 0) {
|
|
2118
|
+
const darkPass = observed?.darkPixelRatio !== void 0 && observed.darkPixelRatio >= staticRegion.minDarkPixelRatio;
|
|
2119
|
+
assertions.push({
|
|
2120
|
+
id: `visual.${index}.region.darkPixels`,
|
|
2121
|
+
pass: darkPass,
|
|
2122
|
+
details: {
|
|
2123
|
+
maximumLuminance: staticRegion.maxLuminance ?? 0.25,
|
|
2124
|
+
minimumDarkPixelRatio: staticRegion.minDarkPixelRatio,
|
|
2125
|
+
observedDarkPixelRatio: observed?.darkPixelRatio
|
|
2126
|
+
}
|
|
2127
|
+
});
|
|
2128
|
+
if (!darkPass) diagnostics.push({
|
|
2129
|
+
code: "TN_PLAYTEST_REGION_DARK_PIXEL_RATIO_FAILED",
|
|
2130
|
+
message: `Screenshot region at (${staticRegion.x}, ${staticRegion.y}) contained ${observed?.darkPixelRatio ?? "unavailable"} dark pixels, below required ratio ${staticRegion.minDarkPixelRatio}.`,
|
|
2131
|
+
severity: "error",
|
|
2132
|
+
suggestion: "Check whether the expected foreground silhouette occupies the asserted raster region."
|
|
2133
|
+
});
|
|
2134
|
+
}
|
|
2135
|
+
if (staticRegion.maxDarkPixelRatio !== void 0) {
|
|
2136
|
+
const darkPass = observed?.darkPixelRatio !== void 0 && observed.darkPixelRatio <= staticRegion.maxDarkPixelRatio;
|
|
2137
|
+
assertions.push({
|
|
2138
|
+
id: `visual.${index}.region.maxDarkPixels`,
|
|
2139
|
+
pass: darkPass,
|
|
2140
|
+
details: {
|
|
2141
|
+
maximumDarkPixelRatio: staticRegion.maxDarkPixelRatio,
|
|
2142
|
+
observedDarkPixelRatio: observed?.darkPixelRatio
|
|
2143
|
+
}
|
|
2144
|
+
});
|
|
2145
|
+
if (!darkPass) diagnostics.push({
|
|
2146
|
+
code: "TN_PLAYTEST_REGION_DARK_PIXEL_RATIO_EXCEEDED",
|
|
2147
|
+
message: `Screenshot region at (${staticRegion.x}, ${staticRegion.y}) contained ${observed?.darkPixelRatio ?? "unavailable"} dark pixels, above maximum ratio ${staticRegion.maxDarkPixelRatio}.`,
|
|
2148
|
+
severity: "error",
|
|
2149
|
+
suggestion: "Check whether unexpected dark foreground geometry occupies the asserted raster region."
|
|
2150
|
+
});
|
|
2151
|
+
}
|
|
1894
2152
|
}
|
|
1895
2153
|
}
|
|
1896
2154
|
if (visual.entityVisible !== void 0) {
|
|
@@ -1905,13 +2163,19 @@ function emitEvidenceFamilies(ctx) {
|
|
|
1905
2163
|
}
|
|
1906
2164
|
}
|
|
1907
2165
|
}
|
|
2166
|
+
function describeVisualElement(element) {
|
|
2167
|
+
return element.id === void 0 ? `selector ${JSON.stringify(element.selector)}` : `id ${JSON.stringify(element.id)}`;
|
|
2168
|
+
}
|
|
1908
2169
|
|
|
1909
2170
|
// src/evaluators/movement-evidence.ts
|
|
1910
2171
|
function emitMovementEvidence(ctx) {
|
|
1911
2172
|
const { assertions, diagnostics } = ctx;
|
|
1912
2173
|
const { input, scenarioAssertions } = ctx;
|
|
1913
2174
|
{
|
|
1914
|
-
const diagnosticsPolicy = resolveDiagnosticsPolicy(
|
|
2175
|
+
const diagnosticsPolicy = resolveDiagnosticsPolicy(
|
|
2176
|
+
scenarioAssertions.diagnostics,
|
|
2177
|
+
input.report.target
|
|
2178
|
+
);
|
|
1915
2179
|
const policyDiagnostics = evaluateDiagnosticsPolicy(input.report, diagnosticsPolicy);
|
|
1916
2180
|
diagnostics.push(...policyDiagnostics);
|
|
1917
2181
|
assertions.push({
|
|
@@ -2332,7 +2596,10 @@ function emitMovementEvidence(ctx) {
|
|
|
2332
2596
|
const clip = typeof observed?.clip === "string" ? observed.clip : void 0;
|
|
2333
2597
|
const advancedFrames = typeof observed?.advancedFrames === "number" ? observed.advancedFrames : void 0;
|
|
2334
2598
|
const finished = typeof observed?.finished === "boolean" ? observed.finished : void 0;
|
|
2335
|
-
const pass2 =
|
|
2599
|
+
const pass2 = animationObservationPass(assertion, observed);
|
|
2600
|
+
const stride = strideReading(observed);
|
|
2601
|
+
const slide = stride === void 0 ? void 0 : footSlideRatio(stride);
|
|
2602
|
+
const strideMiss = strideFailure(assertion, observed);
|
|
2336
2603
|
const initialGameplay = runtimeGameplayBefore(input.report.observations?.runtimeObservations);
|
|
2337
2604
|
const initialAnimations = isRecord(initialGameplay?.animation) ? initialGameplay.animation : void 0;
|
|
2338
2605
|
const initialObserved = isRecord(initialAnimations?.[entity]) ? initialAnimations[entity] : void 0;
|
|
@@ -2347,6 +2614,8 @@ function emitMovementEvidence(ctx) {
|
|
|
2347
2614
|
expected: assertion,
|
|
2348
2615
|
finished,
|
|
2349
2616
|
initialPass,
|
|
2617
|
+
...slide === void 0 ? {} : { footSlide: slide },
|
|
2618
|
+
...stride === void 0 ? {} : { stride },
|
|
2350
2619
|
trivial: trivial2,
|
|
2351
2620
|
...trivial2 && typeof assertion.allowTrivial === "string" ? { trivialityOptOut: true } : {}
|
|
2352
2621
|
},
|
|
@@ -2354,11 +2623,12 @@ function emitMovementEvidence(ctx) {
|
|
|
2354
2623
|
pass: guardedPass
|
|
2355
2624
|
});
|
|
2356
2625
|
if (!guardedPass) {
|
|
2626
|
+
const triviallyHeld = trivial2 && typeof assertion.allowTrivial !== "string";
|
|
2357
2627
|
diagnostics.push({
|
|
2358
|
-
code:
|
|
2359
|
-
message:
|
|
2628
|
+
code: triviallyHeld ? "TN_PLAYTEST_ASSERTION_TRIVIAL" : strideMiss?.code ?? "TN_PLAYTEST_ANIMATION_NOT_OBSERVED",
|
|
2629
|
+
message: triviallyHeld ? `Assertion 'animation.${entity}' was already satisfied before the scenario ran.` : strideMiss === void 0 ? `Expected animation evidence for '${entity}'${assertion.clip === void 0 ? "" : ` clip '${assertion.clip}'`} was not observed.` : `Stride bound on '${entity}' did not hold: ${strideMiss.detail}.`,
|
|
2360
2630
|
severity: "error",
|
|
2361
|
-
suggestion:
|
|
2631
|
+
suggestion: triviallyHeld ? "Drive the asserted animation from a different initial clip, or provide allowTrivial with the reason the clip is intentionally held." : strideMiss === void 0 ? "Check model animation clip wiring and runtime animation playback state." : "Read the stride line in 'doctor --url', then either retime the clip, correct the body speed, or state the override the game intends."
|
|
2362
2632
|
});
|
|
2363
2633
|
}
|
|
2364
2634
|
continue;
|
|
@@ -2512,55 +2782,228 @@ function emitDisplayFamilies(ctx) {
|
|
|
2512
2782
|
}
|
|
2513
2783
|
}
|
|
2514
2784
|
|
|
2515
|
-
// src/evaluators/
|
|
2516
|
-
function
|
|
2517
|
-
const
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2785
|
+
// src/evaluators/parity-evidence.ts
|
|
2786
|
+
function emitParity(ctx) {
|
|
2787
|
+
const assertion = ctx.scenarioAssertions.parity;
|
|
2788
|
+
if (assertion === void 0) return;
|
|
2789
|
+
const { assertions, diagnostics, input } = ctx;
|
|
2790
|
+
const sourcePath = input.scenario.sourcePath;
|
|
2791
|
+
const reference = assertion.reference;
|
|
2792
|
+
if (reference === void 0) {
|
|
2793
|
+
assertions.push({ details: { reason: "no-hydrated-reference" }, id: "parity.observed", pass: false });
|
|
2794
|
+
diagnostics.push({
|
|
2795
|
+
code: "TN_PLAYTEST_PARITY_REFERENCE_UNHYDRATED",
|
|
2796
|
+
message: `Scenario '${input.scenario.name}' asserts parity but its reference from '${assertion.referenceReport}' was never read.`,
|
|
2797
|
+
observedRuntimePath: "observations.json/performanceSeries",
|
|
2798
|
+
severity: "error",
|
|
2799
|
+
...sourcePath === void 0 ? {} : { sourcePath },
|
|
2800
|
+
suggestion: "Load the scenario through loadPlaytestScenario, which hydrates the parity reference at load."
|
|
2801
|
+
});
|
|
2802
|
+
return;
|
|
2527
2803
|
}
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
}
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2804
|
+
const series = input.report.observations?.performanceSeries ?? [];
|
|
2805
|
+
if (series.length === 0) {
|
|
2806
|
+
assertions.push({ details: { sampleCount: series.length }, id: "parity.observed", pass: false });
|
|
2807
|
+
diagnostics.push({
|
|
2808
|
+
code: "TN_PLAYTEST_PARITY_SERIES_MISSING",
|
|
2809
|
+
message: `Scenario '${input.scenario.name}' asserts parity but this run produced no measurable frame-time series.`,
|
|
2810
|
+
observedRuntimePath: "observations.json/performanceSeries",
|
|
2811
|
+
severity: "error",
|
|
2812
|
+
...sourcePath === void 0 ? {} : { sourcePath },
|
|
2813
|
+
suggestion: "Run against a target that measures the render loop and keep the performance bridge provider installed."
|
|
2814
|
+
});
|
|
2815
|
+
return;
|
|
2816
|
+
}
|
|
2817
|
+
const frameTimes = series.map((sample) => sample.frameMs);
|
|
2818
|
+
if (!frameTimes.every((value) => typeof value === "number" && Number.isFinite(value) && value > 0)) {
|
|
2819
|
+
assertions.push({ details: { sampleCount: series.length }, id: "parity.observed", pass: false });
|
|
2820
|
+
diagnostics.push({
|
|
2821
|
+
code: "TN_PLAYTEST_PARITY_SERIES_MALFORMED",
|
|
2822
|
+
message: `Scenario '${input.scenario.name}' asserts parity but this run produced a malformed frame-time sample.`,
|
|
2823
|
+
observedRuntimePath: "observations.json/performanceSeries",
|
|
2824
|
+
severity: "error",
|
|
2825
|
+
...sourcePath === void 0 ? {} : { sourcePath },
|
|
2826
|
+
suggestion: "Fix the performance bridge provider so every sample carries a finite positive frameMs."
|
|
2827
|
+
});
|
|
2828
|
+
return;
|
|
2829
|
+
}
|
|
2830
|
+
const median = (values) => [...values].sort((left, right) => left - right)[Math.floor(values.length / 2)];
|
|
2831
|
+
const thisFps = 1e3 / median(frameTimes);
|
|
2832
|
+
const ratio = assertion.referenceSide === "native" ? reference.fps / thisFps : thisFps / reference.fps;
|
|
2833
|
+
assertions.push({
|
|
2834
|
+
details: { referenceFps: reference.fps, referenceSide: assertion.referenceSide, ratio, unit: "ratio" },
|
|
2835
|
+
id: "parity.fpsRatio",
|
|
2836
|
+
pass: ratio >= assertion.minFpsRatio
|
|
2837
|
+
});
|
|
2838
|
+
if (ratio < assertion.minFpsRatio) {
|
|
2839
|
+
diagnostics.push({
|
|
2840
|
+
code: "TN_PLAYTEST_PARITY_BELOW_FLOOR",
|
|
2841
|
+
message: `Parity ratio ${ratio.toFixed(3)} is below the ${assertion.minFpsRatio} floor (reference ${reference.fps.toFixed(2)} fps, this run ${thisFps.toFixed(2)} fps).`,
|
|
2842
|
+
observedRuntimePath: "observations.json/performanceSeries",
|
|
2843
|
+
severity: "error",
|
|
2844
|
+
...sourcePath === void 0 ? {} : { sourcePath },
|
|
2845
|
+
suggestion: "Per PRD-222: a ratio under 0.85 on the same device routes to engine work \u2014 read TN_FRAME_BUDGET's phases and find which one owns the gap."
|
|
2846
|
+
});
|
|
2847
|
+
}
|
|
2848
|
+
const thisSerial = input.report.observations?.deviceMetrics?.serial;
|
|
2849
|
+
const referenceSerial = reference.serial;
|
|
2850
|
+
if (thisSerial === void 0 || referenceSerial === void 0) {
|
|
2851
|
+
assertions.push({
|
|
2852
|
+
details: { reason: thisSerial === void 0 ? "this-run-has-no-device-identity" : "reference-has-no-device-identity" },
|
|
2853
|
+
id: "parity.sameDevice",
|
|
2854
|
+
pass: false
|
|
2855
|
+
});
|
|
2856
|
+
diagnostics.push({
|
|
2857
|
+
code: "TN_PLAYTEST_PARITY_DEVICE_UNPROVABLE",
|
|
2858
|
+
message: `Parity cannot prove both halves ran on the same device: ${thisSerial === void 0 ? "this run" : "the reference"} carries no device serial.`,
|
|
2859
|
+
observedRuntimePath: "observations.json/deviceMetrics",
|
|
2860
|
+
severity: "error",
|
|
2861
|
+
...sourcePath === void 0 ? {} : { sourcePath },
|
|
2862
|
+
suggestion: "Run both halves with --target android or --target browser --device <serial> so each report carries deviceMetrics.serial."
|
|
2863
|
+
});
|
|
2864
|
+
} else if (thisSerial !== referenceSerial) {
|
|
2865
|
+
assertions.push({ details: { referenceSerial, thisSerial }, id: "parity.sameDevice", pass: false });
|
|
2866
|
+
diagnostics.push({
|
|
2867
|
+
code: "TN_PLAYTEST_PARITY_DEVICE_MISMATCH",
|
|
2868
|
+
message: `The parity halves ran on different devices: this run on '${thisSerial}', the reference on '${referenceSerial}'. A cross-device ratio measures the hardware, not the framework.`,
|
|
2869
|
+
observedRuntimePath: "observations.json/deviceMetrics",
|
|
2870
|
+
severity: "error",
|
|
2871
|
+
...sourcePath === void 0 ? {} : { sourcePath },
|
|
2872
|
+
suggestion: "Take both halves on the same device in the same thermal window, then rerun."
|
|
2873
|
+
});
|
|
2874
|
+
} else {
|
|
2875
|
+
assertions.push({ details: { serial: thisSerial }, id: "parity.sameDevice", pass: true });
|
|
2876
|
+
}
|
|
2877
|
+
const thisConfounded = input.report.observations?.deviceMetrics?.verdict.thermallyConfounded;
|
|
2878
|
+
if (reference.thermallyConfounded === void 0 || thisConfounded === void 0) {
|
|
2879
|
+
assertions.push({
|
|
2880
|
+
details: {
|
|
2881
|
+
referenceVerdictObserved: reference.thermallyConfounded !== void 0,
|
|
2882
|
+
thisRunVerdictObserved: thisConfounded !== void 0
|
|
2883
|
+
},
|
|
2884
|
+
id: "parity.thermalComparability",
|
|
2885
|
+
pass: false
|
|
2886
|
+
});
|
|
2887
|
+
diagnostics.push({
|
|
2888
|
+
code: "TN_PLAYTEST_PARITY_THERMAL_UNPROVABLE",
|
|
2889
|
+
message: "Parity cannot prove thermal comparability because at least one half carries no thermal verdict.",
|
|
2890
|
+
observedRuntimePath: "observations.json/deviceMetrics",
|
|
2891
|
+
severity: "error",
|
|
2892
|
+
...sourcePath === void 0 ? {} : { sourcePath },
|
|
2893
|
+
suggestion: "Run both halves through the Android device metrics recorder, then rerun the comparison."
|
|
2894
|
+
});
|
|
2895
|
+
} else if (reference.thermallyConfounded || thisConfounded) {
|
|
2896
|
+
assertions.push({ details: { referenceThermallyConfounded: reference.thermallyConfounded === true, thisRunThermallyConfounded: thisConfounded === true }, id: "parity.thermalComparability", pass: false });
|
|
2897
|
+
diagnostics.push({
|
|
2898
|
+
code: "TN_PLAYTEST_PARITY_THERMALLY_CONFOUNDED",
|
|
2899
|
+
message: "At least one half of the parity pair is thermally confounded; the ratio it produced is not a same-thermal-window comparison.",
|
|
2900
|
+
observedRuntimePath: "observations.json/deviceMetrics",
|
|
2901
|
+
severity: "error",
|
|
2902
|
+
...sourcePath === void 0 ? {} : { sourcePath },
|
|
2903
|
+
suggestion: "Let the device cool to thermal status 0 and rerun both halves; the measured ratios stay in the reports."
|
|
2904
|
+
});
|
|
2905
|
+
} else {
|
|
2906
|
+
assertions.push({
|
|
2907
|
+
details: { referenceThermallyConfounded: false, thisRunThermallyConfounded: false },
|
|
2908
|
+
id: "parity.thermalComparability",
|
|
2909
|
+
pass: true
|
|
2910
|
+
});
|
|
2911
|
+
}
|
|
2912
|
+
const minRenderParity = assertion.minRenderParity;
|
|
2913
|
+
if (minRenderParity !== void 0) {
|
|
2914
|
+
const renderTimes = series.map((sample) => sample.phases?.render);
|
|
2915
|
+
const completeRenderTimes = renderTimes.every(
|
|
2916
|
+
(value) => typeof value === "number" && Number.isFinite(value) && value > 0
|
|
2917
|
+
) ? renderTimes : void 0;
|
|
2918
|
+
if (reference.renderP95 === void 0 || completeRenderTimes === void 0) {
|
|
2919
|
+
assertions.push({
|
|
2920
|
+
details: {
|
|
2921
|
+
referenceRenderP95: reference.renderP95 ?? null,
|
|
2922
|
+
thisRunSamplesWithRender: completeRenderTimes?.length ?? 0
|
|
2923
|
+
},
|
|
2924
|
+
id: "parity.renderParity",
|
|
2925
|
+
pass: false
|
|
2926
|
+
});
|
|
2927
|
+
diagnostics.push({
|
|
2928
|
+
code: "TN_PLAYTEST_PARITY_RENDER_UNMEASURED",
|
|
2929
|
+
message: "A render-parity floor was requested but at least one half's series carries no render-phase split.",
|
|
2930
|
+
observedRuntimePath: "observations.json/performanceSeries",
|
|
2931
|
+
severity: "error",
|
|
2932
|
+
...sourcePath === void 0 ? {} : { sourcePath },
|
|
2933
|
+
suggestion: "Keep the engine frame budget installed on both halves so every sample carries its phase split."
|
|
2934
|
+
});
|
|
2935
|
+
return;
|
|
2936
|
+
}
|
|
2937
|
+
const thisRenderP95Value = [...completeRenderTimes].sort((left, right) => left - right)[Math.ceil(completeRenderTimes.length * 0.95) - 1];
|
|
2938
|
+
const renderRatio = assertion.referenceSide === "native" ? thisRenderP95Value / reference.renderP95 : reference.renderP95 / thisRenderP95Value;
|
|
2939
|
+
assertions.push({
|
|
2940
|
+
details: { referenceRenderP95: reference.renderP95, renderRatio, thisRunRenderP95: thisRenderP95Value, unit: "ratio" },
|
|
2941
|
+
id: "parity.renderParity",
|
|
2942
|
+
pass: renderRatio >= minRenderParity
|
|
2943
|
+
});
|
|
2944
|
+
if (renderRatio < minRenderParity) {
|
|
2945
|
+
diagnostics.push({
|
|
2946
|
+
code: "TN_PLAYTEST_PARITY_BELOW_FLOOR",
|
|
2947
|
+
message: `Inverted render p95 parity ${renderRatio.toFixed(3)} is below the ${minRenderParity} floor.`,
|
|
2948
|
+
observedRuntimePath: "observations.json/performanceSeries",
|
|
2949
|
+
severity: "error",
|
|
2950
|
+
...sourcePath === void 0 ? {} : { sourcePath },
|
|
2951
|
+
suggestion: "Read the render phase on both halves and find the submission cost the native half pays that the browser does not."
|
|
2952
|
+
});
|
|
2953
|
+
}
|
|
2954
|
+
}
|
|
2955
|
+
}
|
|
2956
|
+
|
|
2957
|
+
// src/evaluators/perf-signals-world.ts
|
|
2958
|
+
function emitPerfSignalsWorld(ctx) {
|
|
2959
|
+
const { assertions, diagnostics } = ctx;
|
|
2960
|
+
const { input, scenarioAssertions } = ctx;
|
|
2961
|
+
emitTerrainResidency(input.report.observations?.components?.terrain, assertions, diagnostics);
|
|
2962
|
+
if (scenarioAssertions.performance !== void 0) {
|
|
2963
|
+
const result = evaluatePerformanceAssertion(
|
|
2964
|
+
scenarioAssertions.performance,
|
|
2965
|
+
input.report.observations?.performanceSeries,
|
|
2966
|
+
input.scenario.sourcePath
|
|
2967
|
+
);
|
|
2968
|
+
assertions.push(...result.assertions);
|
|
2969
|
+
diagnostics.push(...result.diagnostics);
|
|
2970
|
+
}
|
|
2971
|
+
for (const assertion of scenarioAssertions.resources ?? []) {
|
|
2972
|
+
if (assertion.anyOf !== void 0) {
|
|
2973
|
+
const result = evaluateResourceAnyOfAssertion(assertion, input.report.observations?.resources[assertion.id], {
|
|
2974
|
+
effectLog: input.report.effectLog ?? input.report.observations?.effectLog,
|
|
2975
|
+
movedDistance: input.report.distance,
|
|
2976
|
+
scenarioSourcePath: input.scenario.sourcePath
|
|
2977
|
+
});
|
|
2978
|
+
assertions.push(result.assertion);
|
|
2979
|
+
if (result.diagnostic !== void 0) diagnostics.push(result.diagnostic);
|
|
2980
|
+
continue;
|
|
2981
|
+
}
|
|
2982
|
+
if (hasFinalPathExpectation(assertion)) {
|
|
2983
|
+
const result = evaluatePathAssertion("resource", assertion, input.report.observations?.resources[assertion.id], {
|
|
2984
|
+
effectLog: input.report.effectLog ?? input.report.observations?.effectLog,
|
|
2985
|
+
movedDistance: input.report.distance,
|
|
2986
|
+
scenarioSourcePath: input.scenario.sourcePath
|
|
2987
|
+
});
|
|
2988
|
+
assertions.push(result.assertion);
|
|
2989
|
+
if (result.diagnostic !== void 0) {
|
|
2990
|
+
diagnostics.push({ ...result.diagnostic, code: result.diagnostic.code || "TN_PLAYTEST_RESOURCE_ASSERTION_FAILED" });
|
|
2991
|
+
}
|
|
2992
|
+
}
|
|
2993
|
+
if (assertion.throughoutSteps === true) {
|
|
2994
|
+
const samples = (input.report.observations?.resourceSeries ?? []).map((sample) => ({
|
|
2995
|
+
label: sample.label,
|
|
2996
|
+
value: readPath(sample.snapshots[assertion.id], assertion.path)
|
|
2997
|
+
}));
|
|
2998
|
+
const expectedSamples = input.scenario.steps.reduce((count, step) => count + (step.label === void 0 ? 0 : 1), 0);
|
|
2999
|
+
const pass = expectedSamples > 0 && samples.length === expectedSamples && samples.every((sample) => pathValuePass(assertion, sample.value));
|
|
3000
|
+
assertions.push({ details: { samples }, id: `resource.${assertion.id}.${assertion.path ?? "value"}.throughoutSteps`, pass });
|
|
3001
|
+
if (!pass) diagnostics.push({
|
|
3002
|
+
code: "TN_PLAYTEST_RESOURCE_TRANSITION_ASSERTION_FAILED",
|
|
3003
|
+
message: `Resource '${assertion.id}'${assertion.path === void 0 ? "" : ` path '${assertion.path}'`} did not satisfy the assertion after every scenario step.`,
|
|
3004
|
+
observedRuntimePath: "observations.json/resourceSeries",
|
|
3005
|
+
severity: "error",
|
|
3006
|
+
suggestion: "Inspect the labeled resource samples and fix the transient gameplay-state transition."
|
|
2564
3007
|
});
|
|
2565
3008
|
}
|
|
2566
3009
|
if ((assertion.atSteps?.length ?? 0) > 0) {
|
|
@@ -2608,11 +3051,56 @@ function emitPerfSignalsWorld(ctx) {
|
|
|
2608
3051
|
if (result.diagnostic !== void 0) diagnostics.push(result.diagnostic);
|
|
2609
3052
|
}
|
|
2610
3053
|
}
|
|
3054
|
+
function emitTerrainResidency(component, assertions, diagnostics) {
|
|
3055
|
+
if (component === void 0) return;
|
|
3056
|
+
const valueAfter = (name) => component[name]?.after;
|
|
3057
|
+
const residentTiles = valueAfter("residentTiles");
|
|
3058
|
+
const residentBytes = valueAfter("residentBytes");
|
|
3059
|
+
const peakResidentTiles = valueAfter("peakResidentTiles");
|
|
3060
|
+
const peakResidentBytes = valueAfter("peakResidentBytes");
|
|
3061
|
+
const residentTileBudget = valueAfter("residentTileBudget");
|
|
3062
|
+
const residentByteBudget = valueAfter("residentByteBudget");
|
|
3063
|
+
const finiteNumbers = [
|
|
3064
|
+
residentTiles,
|
|
3065
|
+
residentBytes,
|
|
3066
|
+
peakResidentTiles,
|
|
3067
|
+
peakResidentBytes,
|
|
3068
|
+
residentTileBudget,
|
|
3069
|
+
residentByteBudget
|
|
3070
|
+
].every((value) => typeof value === "number" && Number.isFinite(value));
|
|
3071
|
+
const pass = finiteNumbers && residentTiles <= peakResidentTiles && residentBytes <= peakResidentBytes && residentTiles <= residentTileBudget && residentBytes <= residentByteBudget && peakResidentTiles <= residentTileBudget && peakResidentBytes <= residentByteBudget;
|
|
3072
|
+
assertions.push({
|
|
3073
|
+
details: {
|
|
3074
|
+
peakResidentBytes,
|
|
3075
|
+
peakResidentTiles,
|
|
3076
|
+
residentByteBudget,
|
|
3077
|
+
residentBytes,
|
|
3078
|
+
residentTileBudget,
|
|
3079
|
+
residentTiles
|
|
3080
|
+
},
|
|
3081
|
+
id: "world.residency",
|
|
3082
|
+
pass
|
|
3083
|
+
});
|
|
3084
|
+
if (!pass)
|
|
3085
|
+
diagnostics.push({
|
|
3086
|
+
code: "TN_PLAYTEST_WORLD_RESIDENCY_ASSERTION_FAILED",
|
|
3087
|
+
message: "Terrain residency did not report finite measurements within its declared tile and byte caps.",
|
|
3088
|
+
observedRuntimePath: "observations.json/components/terrain",
|
|
3089
|
+
severity: "error",
|
|
3090
|
+
suggestion: "Expose TerrainTiles.debug() through the terrain entity and inspect the residency counters."
|
|
3091
|
+
});
|
|
3092
|
+
}
|
|
2611
3093
|
|
|
2612
3094
|
// src/evaluators/world-gameplay.ts
|
|
2613
3095
|
function emitWorldGameplay(ctx) {
|
|
2614
3096
|
const { assertions, diagnostics } = ctx;
|
|
2615
3097
|
const { input, scenarioAssertions } = ctx;
|
|
3098
|
+
const terrain = input.report.observations?.components?.terrain;
|
|
3099
|
+
const terrainRequired = terrain !== void 0 || (scenarioAssertions.components ?? []).some(({ entity }) => entity === "terrain");
|
|
3100
|
+
if (terrainRequired) {
|
|
3101
|
+
const terrainAfter = terrain === void 0 ? void 0 : Object.fromEntries(Object.entries(terrain).map(([name, sample]) => [name, sample.after]));
|
|
3102
|
+
emitWorldTopology(terrainAfter, assertions, diagnostics);
|
|
3103
|
+
}
|
|
2616
3104
|
for (const assertion of scenarioAssertions.components ?? []) {
|
|
2617
3105
|
const observed = input.report.observations?.components?.[assertion.entity]?.[assertion.component];
|
|
2618
3106
|
const before = readPath(observed?.before, assertion.path);
|
|
@@ -2681,90 +3169,985 @@ function emitWorldGameplay(ctx) {
|
|
|
2681
3169
|
const relative = torque.relativeToLabel === void 0 ? void 0 : aerodynamicTorqueAtLabel(input.report.observations?.physicsDebugSeries, assertion.entity, torque.relativeToLabel)?.[axisIndex(torque.axis)];
|
|
2682
3170
|
return { ...torque, observed: value === void 0 || torque.relativeToLabel !== void 0 && relative === void 0 ? void 0 : value - (relative ?? 0) };
|
|
2683
3171
|
});
|
|
2684
|
-
const forcePass = assertion.minForceSamples === void 0 || forceSamples >= assertion.minForceSamples;
|
|
2685
|
-
const controlsPass = controlsSupported ? controls.every((control) => control.observed.some((value) => Math.abs(value) >= (control.minAbs ?? 0.01) && (control.sign === "positive" ? value > 0 : value < 0))) : torques.length > 0;
|
|
2686
|
-
const torquesPass = torques.every((torque) => torque.observed !== void 0 && Math.abs(torque.observed) >= (torque.minAbs ?? 0.01) && (torque.sign === "positive" ? torque.observed > 0 : torque.observed < 0));
|
|
2687
|
-
const pass = forcePass && controlsPass && torquesPass && (assertion.minForceSamples !== void 0 || controls.length > 0 || torques.length > 0);
|
|
2688
|
-
assertions.push({ details: { controls, forceSamples, minimumForceSamples: assertion.minForceSamples, torques }, id: `aerodynamics.${index}`, pass });
|
|
2689
|
-
if (!pass) {
|
|
2690
|
-
diagnostics.push({
|
|
2691
|
-
artifactPath: assertion.minForceSamples !== void 0 ? "observations.json" : "effect-log.json",
|
|
2692
|
-
code: "TN_PLAYTEST_AERODYNAMICS_ASSERTION_FAILED",
|
|
2693
|
-
message: `Aerodynamic proof for '${assertion.entity}' did not observe the required finite force samples and signed control values.`,
|
|
2694
|
-
observedRuntimePath: "observations.json/physicsDebugSeries/artifact/primitives[category=aero] | effect-log.json/entries[service=physics.aerodynamics.setInputs]",
|
|
3172
|
+
const forcePass = assertion.minForceSamples === void 0 || forceSamples >= assertion.minForceSamples;
|
|
3173
|
+
const controlsPass = controlsSupported ? controls.every((control) => control.observed.some((value) => Math.abs(value) >= (control.minAbs ?? 0.01) && (control.sign === "positive" ? value > 0 : value < 0))) : torques.length > 0;
|
|
3174
|
+
const torquesPass = torques.every((torque) => torque.observed !== void 0 && Math.abs(torque.observed) >= (torque.minAbs ?? 0.01) && (torque.sign === "positive" ? torque.observed > 0 : torque.observed < 0));
|
|
3175
|
+
const pass = forcePass && controlsPass && torquesPass && (assertion.minForceSamples !== void 0 || controls.length > 0 || torques.length > 0);
|
|
3176
|
+
assertions.push({ details: { controls, forceSamples, minimumForceSamples: assertion.minForceSamples, torques }, id: `aerodynamics.${index}`, pass });
|
|
3177
|
+
if (!pass) {
|
|
3178
|
+
diagnostics.push({
|
|
3179
|
+
artifactPath: assertion.minForceSamples !== void 0 ? "observations.json" : "effect-log.json",
|
|
3180
|
+
code: "TN_PLAYTEST_AERODYNAMICS_ASSERTION_FAILED",
|
|
3181
|
+
message: `Aerodynamic proof for '${assertion.entity}' did not observe the required finite force samples and signed control values.`,
|
|
3182
|
+
observedRuntimePath: "observations.json/physicsDebugSeries/artifact/primitives[category=aero] | effect-log.json/entries[service=physics.aerodynamics.setInputs]",
|
|
3183
|
+
severity: "error",
|
|
3184
|
+
suggestion: "Check AerodynamicBody metadata, physics debug capture, input-axis bindings, and surface sign mapping."
|
|
3185
|
+
});
|
|
3186
|
+
}
|
|
3187
|
+
}
|
|
3188
|
+
for (const assertion of scenarioAssertions.hud ?? []) {
|
|
3189
|
+
const result = evaluatePathAssertion("hud", assertion, input.report.observations?.hud[assertion.id], {});
|
|
3190
|
+
assertions.push(result.assertion);
|
|
3191
|
+
if (result.diagnostic !== void 0) {
|
|
3192
|
+
diagnostics.push({ ...result.diagnostic, code: result.diagnostic.code || "TN_PLAYTEST_HUD_ASSERTION_FAILED" });
|
|
3193
|
+
}
|
|
3194
|
+
}
|
|
3195
|
+
for (const assertion of scenarioAssertions.tags ?? []) {
|
|
3196
|
+
const result = evaluateTagCountAssertion(assertion, input.report.observations?.runtimeObservations);
|
|
3197
|
+
assertions.push(result.assertion);
|
|
3198
|
+
if (result.diagnostic !== void 0) {
|
|
3199
|
+
diagnostics.push(result.diagnostic);
|
|
3200
|
+
}
|
|
3201
|
+
}
|
|
3202
|
+
for (const [stateIndex, assertion] of (scenarioAssertions.states ?? []).entries()) {
|
|
3203
|
+
const result = evaluateStateAssertion(assertion, input.report.observations, input.scenario, stateIndex);
|
|
3204
|
+
assertions.push(result.assertion);
|
|
3205
|
+
if (result.diagnostic !== void 0) {
|
|
3206
|
+
diagnostics.push(result.diagnostic);
|
|
3207
|
+
}
|
|
3208
|
+
}
|
|
3209
|
+
}
|
|
3210
|
+
var WORLD_TOPOLOGY_METRIC_FAILURES = {
|
|
3211
|
+
directionalAnisotropy: "directional-anisotropy",
|
|
3212
|
+
powerSpectrumSlope: "power-spectrum-slope",
|
|
3213
|
+
reliefFieldEdge: "relief-field-edge",
|
|
3214
|
+
median64mRelief: "median-64m-relief",
|
|
3215
|
+
maxHortonStrahlerOrder: "horton-strahler-order",
|
|
3216
|
+
profileCurvatureExcessKurtosis: "curvature-excess-kurtosis",
|
|
3217
|
+
effectiveVertexDensityPerKm2: "effective-vertex-density",
|
|
3218
|
+
slopeTailAbove30Degrees: "slope-tail-above-30-degrees"
|
|
3219
|
+
};
|
|
3220
|
+
var WORLD_TOPOLOGY_MEASUREMENT_SIZE = 1024;
|
|
3221
|
+
var DEFAULT_WORLD_TOPOLOGY_THRESHOLDS = {
|
|
3222
|
+
maxDirectionalAnisotropy: 0.1,
|
|
3223
|
+
minPowerSpectrumSlope: 2.5,
|
|
3224
|
+
maxPowerSpectrumSlope: 5,
|
|
3225
|
+
minReliefFieldEdge: 0.1,
|
|
3226
|
+
maxMedian64mRelief: 0.25,
|
|
3227
|
+
minHortonStrahlerOrder: 5,
|
|
3228
|
+
minProfileCurvatureExcessKurtosis: 5,
|
|
3229
|
+
minEffectiveVertexDensityPerKm2: 5e5,
|
|
3230
|
+
minSlopeTailAbove30Degrees: 0.1
|
|
3231
|
+
};
|
|
3232
|
+
function topologyNumber(value, name, minimum = 0) {
|
|
3233
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value < minimum)
|
|
3234
|
+
throw new Error(`World topology ${name} must be finite and at least ${String(minimum)}.`);
|
|
3235
|
+
return value;
|
|
3236
|
+
}
|
|
3237
|
+
function rawHeights(field) {
|
|
3238
|
+
if (field.heights === void 0) throw new Error("World topology raw heights are missing.");
|
|
3239
|
+
return field.heights;
|
|
3240
|
+
}
|
|
3241
|
+
function rawFlow(field) {
|
|
3242
|
+
if (field.flow === void 0) throw new Error("World topology raw flow is missing.");
|
|
3243
|
+
return field.flow;
|
|
3244
|
+
}
|
|
3245
|
+
function topologyField(field) {
|
|
3246
|
+
if (field === null || typeof field !== "object")
|
|
3247
|
+
throw new Error("World topology field must be an object.");
|
|
3248
|
+
const rows = topologyNumber(field.rows, "rows", 2);
|
|
3249
|
+
const columns = topologyNumber(field.columns, "columns", 2);
|
|
3250
|
+
if (!Number.isInteger(rows) || !Number.isInteger(columns))
|
|
3251
|
+
throw new Error("World topology rows and columns must be integers.");
|
|
3252
|
+
const width = topologyNumber(field.width, "width", Number.EPSILON);
|
|
3253
|
+
const depth = topologyNumber(field.depth, "depth", Number.EPSILON);
|
|
3254
|
+
if (width !== WORLD_TOPOLOGY_MEASUREMENT_SIZE || depth !== WORLD_TOPOLOGY_MEASUREMENT_SIZE)
|
|
3255
|
+
throw new Error(
|
|
3256
|
+
`World topology must cover the declared ${String(WORLD_TOPOLOGY_MEASUREMENT_SIZE)}m by ${String(WORLD_TOPOLOGY_MEASUREMENT_SIZE)}m measurement region.`
|
|
3257
|
+
);
|
|
3258
|
+
if (field.metrics !== void 0) {
|
|
3259
|
+
if (field.heights !== void 0 || field.flow !== void 0)
|
|
3260
|
+
throw new Error("World topology metrics cannot be combined with raw channels.");
|
|
3261
|
+
for (const name of Object.keys(WORLD_TOPOLOGY_METRIC_FAILURES))
|
|
3262
|
+
topologyNumber(field.metrics[name], `metrics.${name}`, Number.NEGATIVE_INFINITY);
|
|
3263
|
+
return;
|
|
3264
|
+
}
|
|
3265
|
+
if (field.heights === void 0 || typeof field.heights.length !== "number")
|
|
3266
|
+
throw new Error("World topology heights must be an array-like channel.");
|
|
3267
|
+
const expected = rows * columns;
|
|
3268
|
+
if (field.heights.length !== expected)
|
|
3269
|
+
throw new Error("World topology heights must contain rows times columns samples.");
|
|
3270
|
+
for (let index = 0; index < field.heights.length; index += 1)
|
|
3271
|
+
topologyNumber(field.heights[index], "height", Number.NEGATIVE_INFINITY);
|
|
3272
|
+
if (field.flow === void 0 || typeof field.flow.length !== "number")
|
|
3273
|
+
throw new Error("World topology flow must be an array-like channel.");
|
|
3274
|
+
if (field.flow.length !== expected)
|
|
3275
|
+
throw new Error("World topology flow must contain rows times columns samples.");
|
|
3276
|
+
for (let index = 0; index < field.flow.length; index += 1) {
|
|
3277
|
+
const value = topologyNumber(field.flow[index], "flow");
|
|
3278
|
+
if (value > 1) throw new Error("World topology flow samples must be at most 1.");
|
|
3279
|
+
}
|
|
3280
|
+
}
|
|
3281
|
+
function topologyHeight(field, row, column) {
|
|
3282
|
+
const clampedRow = Math.max(0, Math.min(field.rows - 1, row));
|
|
3283
|
+
const clampedColumn = Math.max(0, Math.min(field.columns - 1, column));
|
|
3284
|
+
const value = rawHeights(field)[clampedRow * field.columns + clampedColumn];
|
|
3285
|
+
if (value === void 0) throw new Error("World topology height sample is missing.");
|
|
3286
|
+
return value;
|
|
3287
|
+
}
|
|
3288
|
+
function topologyGradient(field, row, column) {
|
|
3289
|
+
const dx = field.width / (field.columns - 1);
|
|
3290
|
+
const dz = field.depth / (field.rows - 1);
|
|
3291
|
+
return [
|
|
3292
|
+
(topologyHeight(field, row, column + 1) - topologyHeight(field, row, column - 1)) / (2 * dx),
|
|
3293
|
+
(topologyHeight(field, row + 1, column) - topologyHeight(field, row - 1, column)) / (2 * dz)
|
|
3294
|
+
];
|
|
3295
|
+
}
|
|
3296
|
+
function variance(values) {
|
|
3297
|
+
if (values.length === 0) return 0;
|
|
3298
|
+
const mean = values.reduce((total, value) => total + value, 0) / values.length;
|
|
3299
|
+
return values.reduce((total, value) => total + (value - mean) ** 2, 0) / values.length;
|
|
3300
|
+
}
|
|
3301
|
+
function directionalAnisotropy(field) {
|
|
3302
|
+
const x = [];
|
|
3303
|
+
const z = [];
|
|
3304
|
+
for (let row = 0; row < field.rows; row += 1) {
|
|
3305
|
+
for (let column = 0; column < field.columns; column += 1) {
|
|
3306
|
+
const gradient = topologyGradient(field, row, column);
|
|
3307
|
+
x.push(gradient[0]);
|
|
3308
|
+
z.push(gradient[1]);
|
|
3309
|
+
}
|
|
3310
|
+
}
|
|
3311
|
+
const xVariance = variance(x);
|
|
3312
|
+
const zVariance = variance(z);
|
|
3313
|
+
if (xVariance === 0 || zVariance === 0) return Number.POSITIVE_INFINITY;
|
|
3314
|
+
return Math.abs(Math.log(xVariance / zVariance));
|
|
3315
|
+
}
|
|
3316
|
+
function powerSpectrumSlope(field) {
|
|
3317
|
+
const sampleCount = field.columns;
|
|
3318
|
+
const average = [];
|
|
3319
|
+
for (let column = 0; column < sampleCount; column += 1) {
|
|
3320
|
+
let total = 0;
|
|
3321
|
+
for (let row = 0; row < field.rows; row += 1) total += topologyHeight(field, row, column);
|
|
3322
|
+
average.push(total / field.rows);
|
|
3323
|
+
}
|
|
3324
|
+
const wavelengths = [];
|
|
3325
|
+
const powers = [];
|
|
3326
|
+
for (let frequency = 1; frequency <= Math.floor(sampleCount / 2); frequency += 1) {
|
|
3327
|
+
const wavelength = field.width / frequency;
|
|
3328
|
+
if (wavelength < 8 || wavelength > 256) continue;
|
|
3329
|
+
let real = 0;
|
|
3330
|
+
let imaginary = 0;
|
|
3331
|
+
for (let index = 0; index < sampleCount; index += 1) {
|
|
3332
|
+
const angle = 2 * Math.PI * frequency * index / sampleCount;
|
|
3333
|
+
real += average[index] * Math.cos(angle);
|
|
3334
|
+
imaginary -= average[index] * Math.sin(angle);
|
|
3335
|
+
}
|
|
3336
|
+
const power = real * real + imaginary * imaginary;
|
|
3337
|
+
if (power > 0) {
|
|
3338
|
+
wavelengths.push(Math.log(wavelength));
|
|
3339
|
+
powers.push(Math.log(power));
|
|
3340
|
+
}
|
|
3341
|
+
}
|
|
3342
|
+
if (wavelengths.length < 2) return Number.POSITIVE_INFINITY;
|
|
3343
|
+
const meanWavelength = wavelengths.reduce((total, value) => total + value, 0) / wavelengths.length;
|
|
3344
|
+
const meanPower = powers.reduce((total, value) => total + value, 0) / powers.length;
|
|
3345
|
+
let numerator = 0;
|
|
3346
|
+
let denominator = 0;
|
|
3347
|
+
for (let index = 0; index < wavelengths.length; index += 1) {
|
|
3348
|
+
numerator += (wavelengths[index] - meanWavelength) * (powers[index] - meanPower);
|
|
3349
|
+
denominator += (wavelengths[index] - meanWavelength) ** 2;
|
|
3350
|
+
}
|
|
3351
|
+
return denominator === 0 ? Number.POSITIVE_INFINITY : numerator / denominator;
|
|
3352
|
+
}
|
|
3353
|
+
function reliefFieldEdge(field) {
|
|
3354
|
+
let minimum = Number.POSITIVE_INFINITY;
|
|
3355
|
+
let maximum = Number.NEGATIVE_INFINITY;
|
|
3356
|
+
let edgeTotal = 0;
|
|
3357
|
+
let edgeCount = 0;
|
|
3358
|
+
for (let row = 0; row < field.rows; row += 1) {
|
|
3359
|
+
for (let column = 0; column < field.columns; column += 1) {
|
|
3360
|
+
const value = topologyHeight(field, row, column);
|
|
3361
|
+
minimum = Math.min(minimum, value);
|
|
3362
|
+
maximum = Math.max(maximum, value);
|
|
3363
|
+
if (row === 0 || column === 0 || row === field.rows - 1 || column === field.columns - 1) {
|
|
3364
|
+
edgeTotal += value;
|
|
3365
|
+
edgeCount += 1;
|
|
3366
|
+
}
|
|
3367
|
+
}
|
|
3368
|
+
}
|
|
3369
|
+
const relief = maximum - minimum;
|
|
3370
|
+
if (relief === 0) return 0;
|
|
3371
|
+
const edgeMean = edgeTotal / edgeCount;
|
|
3372
|
+
const center = topologyHeight(field, Math.floor(field.rows / 2), Math.floor(field.columns / 2));
|
|
3373
|
+
return Math.abs(center - edgeMean) / relief;
|
|
3374
|
+
}
|
|
3375
|
+
function median64mRelief(field) {
|
|
3376
|
+
let minimum = Number.POSITIVE_INFINITY;
|
|
3377
|
+
let maximum = Number.NEGATIVE_INFINITY;
|
|
3378
|
+
const heights = rawHeights(field);
|
|
3379
|
+
for (let index = 0; index < heights.length; index += 1) {
|
|
3380
|
+
const value = heights[index];
|
|
3381
|
+
minimum = Math.min(minimum, value);
|
|
3382
|
+
maximum = Math.max(maximum, value);
|
|
3383
|
+
}
|
|
3384
|
+
const globalRelief = maximum - minimum;
|
|
3385
|
+
if (globalRelief === 0) return 0;
|
|
3386
|
+
const radiusX = Math.max(1, Math.round(64 / (field.width / (field.columns - 1))));
|
|
3387
|
+
const radiusZ = Math.max(1, Math.round(64 / (field.depth / (field.rows - 1))));
|
|
3388
|
+
const local = [];
|
|
3389
|
+
const horizontalMinimum = new Float64Array(field.rows * field.columns);
|
|
3390
|
+
const horizontalMaximum = new Float64Array(field.rows * field.columns);
|
|
3391
|
+
for (let row = 0; row < field.rows; row += 1)
|
|
3392
|
+
slidingExtrema(
|
|
3393
|
+
(column) => topologyHeight(field, row, column),
|
|
3394
|
+
field.columns,
|
|
3395
|
+
radiusX,
|
|
3396
|
+
(column, lineMinimum, lineMaximum) => {
|
|
3397
|
+
horizontalMinimum[row * field.columns + column] = lineMinimum;
|
|
3398
|
+
horizontalMaximum[row * field.columns + column] = lineMaximum;
|
|
3399
|
+
}
|
|
3400
|
+
);
|
|
3401
|
+
for (let column = 0; column < field.columns; column += 1) {
|
|
3402
|
+
const localMinimum = new Float64Array(field.rows);
|
|
3403
|
+
const localMaximum = new Float64Array(field.rows);
|
|
3404
|
+
slidingExtrema(
|
|
3405
|
+
(row) => horizontalMinimum[row * field.columns + column],
|
|
3406
|
+
field.rows,
|
|
3407
|
+
radiusZ,
|
|
3408
|
+
(row, lineMinimum) => {
|
|
3409
|
+
localMinimum[row] = lineMinimum;
|
|
3410
|
+
}
|
|
3411
|
+
);
|
|
3412
|
+
slidingExtrema(
|
|
3413
|
+
(row) => horizontalMaximum[row * field.columns + column],
|
|
3414
|
+
field.rows,
|
|
3415
|
+
radiusZ,
|
|
3416
|
+
(row, _lineMinimum, lineMaximum) => {
|
|
3417
|
+
localMaximum[row] = lineMaximum;
|
|
3418
|
+
}
|
|
3419
|
+
);
|
|
3420
|
+
for (let row = 0; row < field.rows; row += 1)
|
|
3421
|
+
local.push((localMaximum[row] - localMinimum[row]) / globalRelief);
|
|
3422
|
+
}
|
|
3423
|
+
local.sort((a, b) => a - b);
|
|
3424
|
+
return local[Math.floor(local.length / 2)];
|
|
3425
|
+
}
|
|
3426
|
+
function slidingExtrema(read, length, radius, write) {
|
|
3427
|
+
const minimumDeque = [];
|
|
3428
|
+
const maximumDeque = [];
|
|
3429
|
+
let minimumHead = 0;
|
|
3430
|
+
let maximumHead = 0;
|
|
3431
|
+
let right = -1;
|
|
3432
|
+
for (let index = 0; index < length; index += 1) {
|
|
3433
|
+
const desiredRight = Math.min(length - 1, index + radius);
|
|
3434
|
+
while (right < desiredRight) {
|
|
3435
|
+
right += 1;
|
|
3436
|
+
const value = read(right);
|
|
3437
|
+
while (minimumDeque.length > minimumHead && read(minimumDeque[minimumDeque.length - 1]) >= value)
|
|
3438
|
+
minimumDeque.pop();
|
|
3439
|
+
minimumDeque.push(right);
|
|
3440
|
+
while (maximumDeque.length > maximumHead && read(maximumDeque[maximumDeque.length - 1]) <= value)
|
|
3441
|
+
maximumDeque.pop();
|
|
3442
|
+
maximumDeque.push(right);
|
|
3443
|
+
}
|
|
3444
|
+
const left = Math.max(0, index - radius);
|
|
3445
|
+
while (minimumHead < minimumDeque.length && minimumDeque[minimumHead] < left)
|
|
3446
|
+
minimumHead += 1;
|
|
3447
|
+
while (maximumHead < maximumDeque.length && maximumDeque[maximumHead] < left)
|
|
3448
|
+
maximumHead += 1;
|
|
3449
|
+
const minimumIndex = minimumDeque[minimumHead];
|
|
3450
|
+
const maximumIndex = maximumDeque[maximumHead];
|
|
3451
|
+
if (minimumIndex === void 0 || maximumIndex === void 0)
|
|
3452
|
+
throw new Error("World topology sliding window is empty.");
|
|
3453
|
+
write(index, read(minimumIndex), read(maximumIndex));
|
|
3454
|
+
if (minimumHead > 64 && minimumHead * 2 > minimumDeque.length) {
|
|
3455
|
+
minimumDeque.splice(0, minimumHead);
|
|
3456
|
+
minimumHead = 0;
|
|
3457
|
+
}
|
|
3458
|
+
if (maximumHead > 64 && maximumHead * 2 > maximumDeque.length) {
|
|
3459
|
+
maximumDeque.splice(0, maximumHead);
|
|
3460
|
+
maximumHead = 0;
|
|
3461
|
+
}
|
|
3462
|
+
}
|
|
3463
|
+
}
|
|
3464
|
+
function downhill(field, index) {
|
|
3465
|
+
const row = Math.floor(index / field.columns);
|
|
3466
|
+
const column = index % field.columns;
|
|
3467
|
+
const current = topologyHeight(field, row, column);
|
|
3468
|
+
let destination = index;
|
|
3469
|
+
let lowest = current;
|
|
3470
|
+
const offsets = [[-1, 0], [1, 0], [0, -1], [0, 1]];
|
|
3471
|
+
for (const [rowOffset, columnOffset] of offsets) {
|
|
3472
|
+
const nextRow = row + rowOffset;
|
|
3473
|
+
const nextColumn = column + columnOffset;
|
|
3474
|
+
if (nextRow < 0 || nextRow >= field.rows || nextColumn < 0 || nextColumn >= field.columns) continue;
|
|
3475
|
+
const candidate = topologyHeight(field, nextRow, nextColumn);
|
|
3476
|
+
if (candidate < lowest) {
|
|
3477
|
+
lowest = candidate;
|
|
3478
|
+
destination = nextRow * field.columns + nextColumn;
|
|
3479
|
+
}
|
|
3480
|
+
}
|
|
3481
|
+
return destination;
|
|
3482
|
+
}
|
|
3483
|
+
function streamOrder(field) {
|
|
3484
|
+
const count = field.rows * field.columns;
|
|
3485
|
+
const flow = rawFlow(field);
|
|
3486
|
+
const accumulation = new Float64Array(count);
|
|
3487
|
+
const targets = new Int32Array(count);
|
|
3488
|
+
targets.fill(-1);
|
|
3489
|
+
const order = Array.from({ length: count }, (_, index) => index).sort(
|
|
3490
|
+
(a, b) => topologyHeight(field, Math.floor(b / field.columns), b % field.columns) - topologyHeight(field, Math.floor(a / field.columns), a % field.columns) || a - b
|
|
3491
|
+
);
|
|
3492
|
+
for (let source = 0; source < count; source += 1) {
|
|
3493
|
+
const destination = downhill(field, source);
|
|
3494
|
+
targets[source] = destination === source ? -1 : destination;
|
|
3495
|
+
}
|
|
3496
|
+
for (const source of order) {
|
|
3497
|
+
accumulation[source] = (accumulation[source] ?? 0) + 1;
|
|
3498
|
+
const destination = targets[source];
|
|
3499
|
+
if (destination !== void 0 && destination >= 0)
|
|
3500
|
+
accumulation[destination] = (accumulation[destination] ?? 0) + accumulation[source];
|
|
3501
|
+
}
|
|
3502
|
+
const cellArea = field.width / (field.columns - 1) * (field.depth / (field.rows - 1));
|
|
3503
|
+
const minimumFlow = Math.log1p(2048 / cellArea) / Math.log1p(count);
|
|
3504
|
+
const stream = Array.from({ length: count }, (_, index) => flow[index] >= minimumFlow);
|
|
3505
|
+
const orders = new Int32Array(count);
|
|
3506
|
+
let maximum = 0;
|
|
3507
|
+
for (const index of order) {
|
|
3508
|
+
if (!stream[index]) continue;
|
|
3509
|
+
const row = Math.floor(index / field.columns);
|
|
3510
|
+
const column = index % field.columns;
|
|
3511
|
+
const upstream = [];
|
|
3512
|
+
for (const [rowOffset, columnOffset] of [[-1, 0], [1, 0], [0, -1], [0, 1]]) {
|
|
3513
|
+
const upstreamRow = row + rowOffset;
|
|
3514
|
+
const upstreamColumn = column + columnOffset;
|
|
3515
|
+
if (upstreamRow < 0 || upstreamRow >= field.rows || upstreamColumn < 0 || upstreamColumn >= field.columns) continue;
|
|
3516
|
+
const candidate = upstreamRow * field.columns + upstreamColumn;
|
|
3517
|
+
if (targets[candidate] === index && stream[candidate]) upstream.push(orders[candidate]);
|
|
3518
|
+
}
|
|
3519
|
+
const highest = Math.max(1, ...upstream);
|
|
3520
|
+
const ties = upstream.filter((value) => value === highest).length;
|
|
3521
|
+
orders[index] = ties > 1 ? highest + 1 : highest;
|
|
3522
|
+
maximum = Math.max(maximum, orders[index]);
|
|
3523
|
+
}
|
|
3524
|
+
return maximum;
|
|
3525
|
+
}
|
|
3526
|
+
function curvatureExcessKurtosis(field) {
|
|
3527
|
+
const values = [];
|
|
3528
|
+
for (let row = 0; row < field.rows; row += 1) {
|
|
3529
|
+
for (let column = 0; column < field.columns; column += 1) {
|
|
3530
|
+
const center = topologyHeight(field, row, column);
|
|
3531
|
+
values.push(
|
|
3532
|
+
topologyHeight(field, row, column - 1) + topologyHeight(field, row, column + 1) + topologyHeight(field, row - 1, column) + topologyHeight(field, row + 1, column) - 4 * center
|
|
3533
|
+
);
|
|
3534
|
+
}
|
|
3535
|
+
}
|
|
3536
|
+
const mean = values.reduce((total, value) => total + value, 0) / values.length;
|
|
3537
|
+
const second = values.reduce((total, value) => total + (value - mean) ** 2, 0) / values.length;
|
|
3538
|
+
if (second === 0) return Number.NEGATIVE_INFINITY;
|
|
3539
|
+
const fourth = values.reduce((total, value) => total + (value - mean) ** 4, 0) / values.length;
|
|
3540
|
+
return fourth / (second * second) - 3;
|
|
3541
|
+
}
|
|
3542
|
+
function measureWorldTopology(field) {
|
|
3543
|
+
topologyField(field);
|
|
3544
|
+
if (field.metrics !== void 0) return { ...field.metrics };
|
|
3545
|
+
let steep = 0;
|
|
3546
|
+
for (let row = 0; row < field.rows; row += 1) {
|
|
3547
|
+
for (let column = 0; column < field.columns; column += 1) {
|
|
3548
|
+
const [x, z] = topologyGradient(field, row, column);
|
|
3549
|
+
if (Math.atan(Math.hypot(x, z)) > Math.PI / 6) steep += 1;
|
|
3550
|
+
}
|
|
3551
|
+
}
|
|
3552
|
+
return {
|
|
3553
|
+
directionalAnisotropy: directionalAnisotropy(field),
|
|
3554
|
+
powerSpectrumSlope: powerSpectrumSlope(field),
|
|
3555
|
+
reliefFieldEdge: reliefFieldEdge(field),
|
|
3556
|
+
median64mRelief: median64mRelief(field),
|
|
3557
|
+
maxHortonStrahlerOrder: streamOrder(field),
|
|
3558
|
+
profileCurvatureExcessKurtosis: curvatureExcessKurtosis(field),
|
|
3559
|
+
effectiveVertexDensityPerKm2: field.rows * field.columns * 1e6 / (field.width * field.depth),
|
|
3560
|
+
slopeTailAbove30Degrees: steep / (field.rows * field.columns)
|
|
3561
|
+
};
|
|
3562
|
+
}
|
|
3563
|
+
function evaluateWorldTopology(field, thresholds = DEFAULT_WORLD_TOPOLOGY_THRESHOLDS) {
|
|
3564
|
+
const metrics = measureWorldTopology(field);
|
|
3565
|
+
const failed = [
|
|
3566
|
+
...metrics.directionalAnisotropy <= thresholds.maxDirectionalAnisotropy ? [] : ["directional-anisotropy"],
|
|
3567
|
+
...metrics.powerSpectrumSlope >= thresholds.minPowerSpectrumSlope && metrics.powerSpectrumSlope <= thresholds.maxPowerSpectrumSlope ? [] : ["power-spectrum-slope"],
|
|
3568
|
+
...metrics.reliefFieldEdge >= thresholds.minReliefFieldEdge ? [] : ["relief-field-edge"],
|
|
3569
|
+
...metrics.median64mRelief <= thresholds.maxMedian64mRelief ? [] : ["median-64m-relief"],
|
|
3570
|
+
...metrics.maxHortonStrahlerOrder >= thresholds.minHortonStrahlerOrder ? [] : ["horton-strahler-order"],
|
|
3571
|
+
...metrics.profileCurvatureExcessKurtosis >= thresholds.minProfileCurvatureExcessKurtosis ? [] : ["curvature-excess-kurtosis"],
|
|
3572
|
+
...metrics.effectiveVertexDensityPerKm2 >= thresholds.minEffectiveVertexDensityPerKm2 ? [] : ["effective-vertex-density"],
|
|
3573
|
+
...metrics.slopeTailAbove30Degrees >= thresholds.minSlopeTailAbove30Degrees ? [] : ["slope-tail-above-30-degrees"]
|
|
3574
|
+
];
|
|
3575
|
+
return { failed, metrics, pass: failed.length === 0 };
|
|
3576
|
+
}
|
|
3577
|
+
function emitWorldTopology(value, assertions, diagnostics) {
|
|
3578
|
+
const fail = (reason) => {
|
|
3579
|
+
for (const name of Object.keys(WORLD_TOPOLOGY_METRIC_FAILURES))
|
|
3580
|
+
assertions.push({ details: { reason }, id: `world.topology.${name}`, pass: false });
|
|
3581
|
+
diagnostics.push({
|
|
3582
|
+
code: "TN_PLAYTEST_WORLD_TOPOLOGY_ASSERTION_FAILED",
|
|
3583
|
+
message: `World topology was not evaluated: ${reason}.`,
|
|
3584
|
+
observedRuntimePath: "observations.json/components/terrain/after/topology",
|
|
3585
|
+
severity: "error",
|
|
3586
|
+
suggestion: "Publish finite height and normalized flow channels before treating terrain metrics as proof."
|
|
3587
|
+
});
|
|
3588
|
+
};
|
|
3589
|
+
if (value === null || typeof value !== "object") {
|
|
3590
|
+
fail("the terrain observation is missing");
|
|
3591
|
+
return;
|
|
3592
|
+
}
|
|
3593
|
+
const candidate = value.topology;
|
|
3594
|
+
if (candidate === null || typeof candidate !== "object") {
|
|
3595
|
+
fail("the topology field is missing");
|
|
3596
|
+
return;
|
|
3597
|
+
}
|
|
3598
|
+
try {
|
|
3599
|
+
const result = evaluateWorldTopology(candidate);
|
|
3600
|
+
for (const name of Object.keys(WORLD_TOPOLOGY_METRIC_FAILURES))
|
|
3601
|
+
assertions.push({
|
|
3602
|
+
details: { metric: result.metrics[name] },
|
|
3603
|
+
id: `world.topology.${name}`,
|
|
3604
|
+
pass: !result.failed.includes(WORLD_TOPOLOGY_METRIC_FAILURES[name])
|
|
3605
|
+
});
|
|
3606
|
+
if (!result.pass)
|
|
3607
|
+
diagnostics.push({
|
|
3608
|
+
code: "TN_PLAYTEST_WORLD_TOPOLOGY_ASSERTION_FAILED",
|
|
3609
|
+
message: `World topology failed metrics: ${result.failed.join(", ")}.`,
|
|
3610
|
+
observedRuntimePath: "observations.json/components/terrain/after/topology",
|
|
3611
|
+
severity: "error",
|
|
3612
|
+
suggestion: "Inspect the seeded field and keep synthesis, erosion, and flow in their declared order."
|
|
3613
|
+
});
|
|
3614
|
+
} catch (error) {
|
|
3615
|
+
fail(error instanceof Error ? error.message : String(error));
|
|
3616
|
+
}
|
|
3617
|
+
}
|
|
3618
|
+
|
|
3619
|
+
// src/evaluators/render-chain.ts
|
|
3620
|
+
function emitRenderChain(ctx) {
|
|
3621
|
+
const assertion = ctx.scenarioAssertions.renderChain;
|
|
3622
|
+
if (assertion === void 0) return;
|
|
3623
|
+
const observed = ctx.input.report.observations?.renderChain;
|
|
3624
|
+
if (assertion.tier !== void 0) {
|
|
3625
|
+
const pass = observed?.tier === assertion.tier;
|
|
3626
|
+
ctx.assertions.push({
|
|
3627
|
+
details: { expected: assertion.tier, observed: observed?.tier },
|
|
3628
|
+
id: "renderChain.tier",
|
|
3629
|
+
pass
|
|
3630
|
+
});
|
|
3631
|
+
if (!pass) {
|
|
3632
|
+
ctx.diagnostics.push({
|
|
3633
|
+
code: observed === void 0 ? "TN_PLAYTEST_RENDER_CHAIN_UNOBSERVABLE" : "TN_PLAYTEST_RENDER_CHAIN_TIER_FAILED",
|
|
3634
|
+
message: observed === void 0 ? "Render-chain tier was not observed because the TN_RENDER_CHAIN marker was absent." : `Render-chain tier '${observed.tier}' did not match the asserted tier '${assertion.tier}'.`,
|
|
3635
|
+
observedRuntimePath: "observations.json/renderChain/tier",
|
|
3636
|
+
severity: "error",
|
|
3637
|
+
suggestion: "Install the RenderChain through the renderer seam and keep its marker callback connected to the playtest bridge."
|
|
3638
|
+
});
|
|
3639
|
+
}
|
|
3640
|
+
}
|
|
3641
|
+
const stageAssertion = assertion.stages;
|
|
3642
|
+
if (stageAssertion !== void 0) {
|
|
3643
|
+
const observedStages = observed?.stages;
|
|
3644
|
+
if (stageAssertion.includes !== void 0) {
|
|
3645
|
+
emitStageCheck(
|
|
3646
|
+
ctx,
|
|
3647
|
+
observedStages,
|
|
3648
|
+
"includes",
|
|
3649
|
+
stageAssertion.includes,
|
|
3650
|
+
observedStages !== void 0 && stageAssertion.includes.every((stage) => observedStages.includes(stage))
|
|
3651
|
+
);
|
|
3652
|
+
}
|
|
3653
|
+
if (stageAssertion.excludes !== void 0) {
|
|
3654
|
+
emitStageCheck(
|
|
3655
|
+
ctx,
|
|
3656
|
+
observedStages,
|
|
3657
|
+
"excludes",
|
|
3658
|
+
stageAssertion.excludes,
|
|
3659
|
+
observedStages !== void 0 && stageAssertion.excludes.every((stage) => !observedStages.includes(stage))
|
|
3660
|
+
);
|
|
3661
|
+
}
|
|
3662
|
+
if (stageAssertion.order !== void 0) {
|
|
3663
|
+
emitStageCheck(
|
|
3664
|
+
ctx,
|
|
3665
|
+
observedStages,
|
|
3666
|
+
"order",
|
|
3667
|
+
stageAssertion.order,
|
|
3668
|
+
observedStages !== void 0 && isOrderedSubsequence(stageAssertion.order, observedStages)
|
|
3669
|
+
);
|
|
3670
|
+
}
|
|
3671
|
+
}
|
|
3672
|
+
const contributionAssertion = assertion.contributions;
|
|
3673
|
+
if (contributionAssertion !== void 0) {
|
|
3674
|
+
const observedContributions = observed?.contributions;
|
|
3675
|
+
const pass = Array.isArray(observedContributions) && contributionAssertion.graphOutputChanged.every(
|
|
3676
|
+
(name) => observedContributions.some((entry) => entry.name === name && entry.graphOutputChanged === true)
|
|
3677
|
+
);
|
|
3678
|
+
ctx.assertions.push({
|
|
3679
|
+
details: {
|
|
3680
|
+
expected: contributionAssertion.graphOutputChanged,
|
|
3681
|
+
observed: observedContributions
|
|
3682
|
+
},
|
|
3683
|
+
id: "renderChain.contributions.graphOutputChanged",
|
|
3684
|
+
pass
|
|
3685
|
+
});
|
|
3686
|
+
if (!pass) {
|
|
3687
|
+
ctx.diagnostics.push({
|
|
3688
|
+
code: observed === void 0 || observedContributions === void 0 ? "TN_PLAYTEST_RENDER_CHAIN_UNOBSERVABLE" : "TN_PLAYTEST_RENDER_CHAIN_CONTRIBUTIONS_FAILED",
|
|
3689
|
+
message: observed === void 0 ? "Render-chain contributions were not observed because the TN_RENDER_CHAIN marker was absent." : observedContributions === void 0 ? "Render-chain stage contributions were not observed on the TN_RENDER_CHAIN marker." : "One or more authored stages did not report a changed graph output.",
|
|
3690
|
+
observedRuntimePath: "observations.json/renderChain/contributions",
|
|
3691
|
+
severity: "error",
|
|
3692
|
+
suggestion: "Publish one graphOutputChanged marker per applied stage; this is graph evidence, not pixel attribution."
|
|
3693
|
+
});
|
|
3694
|
+
}
|
|
3695
|
+
}
|
|
3696
|
+
if (assertion.velocity !== void 0) {
|
|
3697
|
+
const rejectionFraction = observed?.velocity.rejectionFraction;
|
|
3698
|
+
const measurementFrame = observed?.velocity.measurementFrame;
|
|
3699
|
+
const hasMeasurement = rejectionFraction !== void 0 && Number.isFinite(rejectionFraction) && typeof measurementFrame === "number" && Number.isInteger(measurementFrame) && measurementFrame >= 0;
|
|
3700
|
+
const pass = hasMeasurement && rejectionFraction !== void 0 && rejectionFraction <= assertion.velocity.maxRejectionFraction;
|
|
3701
|
+
ctx.assertions.push({
|
|
3702
|
+
details: {
|
|
3703
|
+
expected: assertion.velocity.maxRejectionFraction,
|
|
3704
|
+
measurementFrame,
|
|
3705
|
+
observed: rejectionFraction
|
|
3706
|
+
},
|
|
3707
|
+
id: "renderChain.velocity.rejectionFraction",
|
|
3708
|
+
pass
|
|
3709
|
+
});
|
|
3710
|
+
if (!pass) {
|
|
3711
|
+
ctx.diagnostics.push({
|
|
3712
|
+
code: observed === void 0 || !hasMeasurement ? "TN_PLAYTEST_RENDER_CHAIN_UNOBSERVABLE" : "TN_PLAYTEST_RENDER_CHAIN_REJECTION_FAILED",
|
|
3713
|
+
message: observed === void 0 ? "Render-chain velocity rejection was not observed because the TN_RENDER_CHAIN marker was absent." : !hasMeasurement ? "Render-chain velocity was provisioned without a fresh completed-frame history-rejection measurement." : `Render-chain history rejection fraction ${rejectionFraction ?? "missing"} exceeded the asserted ceiling ${assertion.velocity.maxRejectionFraction}.`,
|
|
3714
|
+
observedRuntimePath: "observations.json/renderChain/velocity/rejectionFraction",
|
|
3715
|
+
severity: "error",
|
|
3716
|
+
suggestion: "Publish the temporal stage's measured rejection fraction on the same render-chain marker used for tier reporting."
|
|
3717
|
+
});
|
|
3718
|
+
}
|
|
3719
|
+
}
|
|
3720
|
+
}
|
|
3721
|
+
function emitStageCheck(ctx, observed, kind, expected, pass) {
|
|
3722
|
+
ctx.assertions.push({
|
|
3723
|
+
details: { expected, observed },
|
|
3724
|
+
id: `renderChain.stages.${kind}`,
|
|
3725
|
+
pass
|
|
3726
|
+
});
|
|
3727
|
+
if (pass) return;
|
|
3728
|
+
ctx.diagnostics.push({
|
|
3729
|
+
code: observed === void 0 ? "TN_PLAYTEST_RENDER_CHAIN_UNOBSERVABLE" : "TN_PLAYTEST_RENDER_CHAIN_STAGES_FAILED",
|
|
3730
|
+
message: observed === void 0 ? "Render-chain stages were not observed because the TN_RENDER_CHAIN marker was absent." : `Render-chain stage ${kind} assertion did not match the observed stage order.`,
|
|
3731
|
+
observedRuntimePath: "observations.json/renderChain/stages",
|
|
3732
|
+
severity: "error",
|
|
3733
|
+
suggestion: "Keep each authored stage in the renderer chain and publish its id on TN_RENDER_CHAIN."
|
|
3734
|
+
});
|
|
3735
|
+
}
|
|
3736
|
+
function isOrderedSubsequence(expected, observed) {
|
|
3737
|
+
let cursor = 0;
|
|
3738
|
+
for (const stage of expected) {
|
|
3739
|
+
const found = observed.indexOf(stage, cursor);
|
|
3740
|
+
if (found < 0) return false;
|
|
3741
|
+
cursor = found + 1;
|
|
3742
|
+
}
|
|
3743
|
+
return true;
|
|
3744
|
+
}
|
|
3745
|
+
|
|
3746
|
+
// src/evaluators/caused-by.ts
|
|
3747
|
+
function emitCausedBy(ctx) {
|
|
3748
|
+
const assertions = ctx.scenarioAssertions.causedBy;
|
|
3749
|
+
if (assertions === void 0 || assertions.length === 0) return;
|
|
3750
|
+
const runtime = ctx.input.report.observations?.runtimeObservations;
|
|
3751
|
+
const gameplay = runtime?.gameplay;
|
|
3752
|
+
const transitions = gameplay?.transitions;
|
|
3753
|
+
if (transitions === void 0) {
|
|
3754
|
+
ctx.assertions.push({ details: { expected: assertions.length, observed: void 0 }, id: "causedBy.observed", pass: false });
|
|
3755
|
+
ctx.diagnostics.push({
|
|
3756
|
+
code: "TN_PLAYTEST_TRANSITIONS_UNOBSERVED",
|
|
3757
|
+
message: "A causedBy assertion was evaluated against a run that reported no transition log, so no effect has a tick and nothing can be related to a cause.",
|
|
3758
|
+
observedRuntimePath: "observations.json/runtimeObservations/gameplay/transitions",
|
|
3759
|
+
severity: "error",
|
|
3760
|
+
suggestion: "Install core's playtest() plugin so the run advertises 'runtime.transitions', and drive the scenario with fixed-step ticks. A run whose loop never ticked has observed nothing, not nothing-changed."
|
|
3761
|
+
});
|
|
3762
|
+
return;
|
|
3763
|
+
}
|
|
3764
|
+
assertions.forEach((assertion, index) => {
|
|
3765
|
+
emitOne(ctx, assertion, index, gameplay?.contacts ?? [], transitions);
|
|
3766
|
+
});
|
|
3767
|
+
}
|
|
3768
|
+
function describeEffect(effect) {
|
|
3769
|
+
return `${effect.path} becomes ${JSON.stringify(effect.becomes)}`;
|
|
3770
|
+
}
|
|
3771
|
+
function describeCause(assertion) {
|
|
3772
|
+
const { contact, transition } = assertion.cause;
|
|
3773
|
+
if (contact !== void 0)
|
|
3774
|
+
return `contact ${contact.entity} with ${contact.with}${contact.kind === void 0 ? "" : ` (${contact.kind})`}`;
|
|
3775
|
+
return transition === void 0 ? "unspecified" : describeEffect(transition);
|
|
3776
|
+
}
|
|
3777
|
+
function firstEffectTick(transitions, effect) {
|
|
3778
|
+
let earliest;
|
|
3779
|
+
for (const entry of transitions) {
|
|
3780
|
+
if (entry.path !== effect.path || entry.to !== effect.becomes) continue;
|
|
3781
|
+
if (earliest === void 0 || entry.tick < earliest) earliest = entry.tick;
|
|
3782
|
+
}
|
|
3783
|
+
return earliest;
|
|
3784
|
+
}
|
|
3785
|
+
function firstCauseTick(assertion, contacts, transitions) {
|
|
3786
|
+
const spec = assertion.cause.contact;
|
|
3787
|
+
if (spec === void 0) {
|
|
3788
|
+
const transition = assertion.cause.transition;
|
|
3789
|
+
const tick = transition === void 0 ? void 0 : firstEffectTick(transitions, transition);
|
|
3790
|
+
return { ...tick === void 0 ? {} : { tick }, unstamped: false };
|
|
3791
|
+
}
|
|
3792
|
+
let earliest;
|
|
3793
|
+
let unstamped = false;
|
|
3794
|
+
for (const contact of contacts) {
|
|
3795
|
+
if (contact.entity !== spec.entity || contact.with !== spec.with) continue;
|
|
3796
|
+
if (spec.kind !== void 0 && contact.kind !== spec.kind) continue;
|
|
3797
|
+
if (contact.tick === void 0) {
|
|
3798
|
+
unstamped = true;
|
|
3799
|
+
continue;
|
|
3800
|
+
}
|
|
3801
|
+
if (earliest === void 0 || contact.tick < earliest) earliest = contact.tick;
|
|
3802
|
+
}
|
|
3803
|
+
return { ...earliest === void 0 ? {} : { tick: earliest }, unstamped };
|
|
3804
|
+
}
|
|
3805
|
+
function emitOne(ctx, assertion, index, contacts, transitions) {
|
|
3806
|
+
const id = `causedBy[${index}]`;
|
|
3807
|
+
const cause = describeCause(assertion);
|
|
3808
|
+
const effect = describeEffect(assertion.effect);
|
|
3809
|
+
const causeReading = firstCauseTick(assertion, contacts, transitions);
|
|
3810
|
+
const effectTick = firstEffectTick(transitions, assertion.effect);
|
|
3811
|
+
if (causeReading.tick === void 0) {
|
|
3812
|
+
ctx.assertions.push({ details: { cause, effect, unstamped: causeReading.unstamped }, id: `${id}.cause`, pass: false });
|
|
3813
|
+
ctx.diagnostics.push({
|
|
3814
|
+
code: causeReading.unstamped ? "TN_PLAYTEST_CAUSE_UNSTAMPED" : "TN_PLAYTEST_CAUSE_NOT_OBSERVED",
|
|
3815
|
+
message: causeReading.unstamped ? `The run observed ${cause} but the producer stamped no tick on it, so it cannot be placed against ${effect}.` : `The run never observed ${cause}, so nothing could have caused ${effect}.`,
|
|
3816
|
+
observedRuntimePath: "observations.json/runtimeObservations/gameplay/contacts",
|
|
3817
|
+
severity: "error",
|
|
3818
|
+
suggestion: causeReading.unstamped ? "The producer drains its contact log only at sample time. Drain it per tick and stamp each event, or assert the ordering with assert.states[].atSteps and accept step granularity." : "Check that both sides of the contact are registered entities and that the scenario's input actually reaches the trigger. A contact nothing observed is not a contact that did not happen \u2014 inspect observations.json first."
|
|
3819
|
+
});
|
|
3820
|
+
return;
|
|
3821
|
+
}
|
|
3822
|
+
if (effectTick === void 0) {
|
|
3823
|
+
ctx.assertions.push({ details: { cause, causeTick: causeReading.tick, effect }, id: `${id}.effect`, pass: false });
|
|
3824
|
+
ctx.diagnostics.push({
|
|
3825
|
+
code: "TN_PLAYTEST_EFFECT_NOT_OBSERVED",
|
|
3826
|
+
message: `${cause} happened at tick ${causeReading.tick}, and ${effect} never did.`,
|
|
3827
|
+
observedRuntimePath: "observations.json/runtimeObservations/gameplay/transitions",
|
|
3828
|
+
severity: "error",
|
|
3829
|
+
suggestion: "The transition log records a path's first value as its starting point, not as a change. A value that was already at the asserted value when the run began has not transitioned to it \u2014 which is the frame-one case this family exists to catch, and neverBefore reports it as such."
|
|
3830
|
+
});
|
|
3831
|
+
return;
|
|
3832
|
+
}
|
|
3833
|
+
const gap = effectTick - causeReading.tick;
|
|
3834
|
+
if (assertion.neverBefore === true) {
|
|
3835
|
+
const pass = gap >= 0;
|
|
3836
|
+
ctx.assertions.push({
|
|
3837
|
+
details: { causeTick: causeReading.tick, effectTick, gap, id: cause },
|
|
3838
|
+
id: `${id}.neverBefore`,
|
|
3839
|
+
pass
|
|
3840
|
+
});
|
|
3841
|
+
if (!pass)
|
|
3842
|
+
ctx.diagnostics.push({
|
|
3843
|
+
code: "TN_PLAYTEST_EFFECT_PRECEDES_CAUSE",
|
|
3844
|
+
message: `${effect} at tick ${effectTick}, ${Math.abs(gap)} tick(s) before ${cause} at tick ${causeReading.tick}. The effect did not come from that cause.`,
|
|
3845
|
+
observedRuntimePath: "observations.json/runtimeObservations/gameplay/transitions",
|
|
3846
|
+
severity: "error",
|
|
3847
|
+
suggestion: "Something other than the named cause produced the effect \u2014 a trigger volume overlapping static geometry, a timer, or a distance check. Find what set the value at that tick; the game reporting the right final answer is not proof it got there the right way."
|
|
3848
|
+
});
|
|
3849
|
+
}
|
|
3850
|
+
if (assertion.withinTicks !== void 0) {
|
|
3851
|
+
const pass = gap >= 0 && gap <= assertion.withinTicks;
|
|
3852
|
+
ctx.assertions.push({
|
|
3853
|
+
details: { causeTick: causeReading.tick, effectTick, gap, withinTicks: assertion.withinTicks },
|
|
3854
|
+
id: `${id}.withinTicks`,
|
|
3855
|
+
pass
|
|
3856
|
+
});
|
|
3857
|
+
if (!pass)
|
|
3858
|
+
ctx.diagnostics.push({
|
|
3859
|
+
code: "TN_PLAYTEST_CAUSE_TOO_DISTANT",
|
|
3860
|
+
message: gap < 0 ? `${effect} happened ${Math.abs(gap)} tick(s) before ${cause}, so no window contains it.` : `${effect} happened ${gap} tick(s) after ${cause}, past the asserted window of ${assertion.withinTicks}.`,
|
|
3861
|
+
observedRuntimePath: "observations.json/runtimeObservations/gameplay/transitions",
|
|
3862
|
+
severity: "error",
|
|
3863
|
+
suggestion: "A long gap between the contact and the state change is the signature of a timer or a distance check that happens to fire near the contact. Widen the window only if the game genuinely defers the effect, and say why in the scenario."
|
|
3864
|
+
});
|
|
3865
|
+
}
|
|
3866
|
+
}
|
|
3867
|
+
|
|
3868
|
+
// src/evaluators/scene-nodes.ts
|
|
3869
|
+
function emitSceneNodes(ctx) {
|
|
3870
|
+
const assertions = ctx.scenarioAssertions.sceneNodes;
|
|
3871
|
+
if (assertions === void 0 || assertions.length === 0) return;
|
|
3872
|
+
const observed = ctx.input.report.observations?.sceneNodes;
|
|
3873
|
+
if (observed === void 0) {
|
|
3874
|
+
ctx.assertions.push({ details: { expected: assertions.length, observed: void 0 }, id: "sceneNodes.observed", pass: false });
|
|
3875
|
+
ctx.diagnostics.push({
|
|
3876
|
+
code: "TN_PLAYTEST_SCENE_NODES_UNOBSERVED",
|
|
3877
|
+
message: "A sceneNodes assertion was evaluated against a run whose bridge reported no scene-node observation.",
|
|
3878
|
+
observedRuntimePath: "observations.json/sceneNodes",
|
|
3879
|
+
severity: "error",
|
|
3880
|
+
suggestion: "Install the playtest bridge (core's playtest() plugin, or installThreePlaytestBridge for a plain Three.js project) so the run advertises 'scene.nodes', or narrow the scenario. Never delete the assertion to get green."
|
|
3881
|
+
});
|
|
3882
|
+
return;
|
|
3883
|
+
}
|
|
3884
|
+
assertions.forEach((assertion, index) => {
|
|
3885
|
+
emitOne2(ctx, assertion, index, observed[index]);
|
|
3886
|
+
});
|
|
3887
|
+
}
|
|
3888
|
+
function describeSelector(assertion) {
|
|
3889
|
+
const { limit: _limit, ...filters } = assertion.select;
|
|
3890
|
+
return Object.entries(filters).map(([key, value]) => `${key}=${String(value)}`).join(" ");
|
|
3891
|
+
}
|
|
3892
|
+
function emitOne2(ctx, assertion, index, observation) {
|
|
3893
|
+
const id = `sceneNodes[${index}]`;
|
|
3894
|
+
const selector = describeSelector(assertion);
|
|
3895
|
+
if (observation === void 0) {
|
|
3896
|
+
ctx.assertions.push({ details: { selector }, id: `${id}.observed`, pass: false });
|
|
3897
|
+
ctx.diagnostics.push({
|
|
3898
|
+
code: "TN_PLAYTEST_SCENE_NODES_UNOBSERVED",
|
|
3899
|
+
message: `The run reported no scene-node observation for selector ${selector}.`,
|
|
3900
|
+
observedRuntimePath: `observations.json/sceneNodes/${index}`,
|
|
3901
|
+
severity: "error",
|
|
3902
|
+
suggestion: "The runner requests one observation per assertion in order; a missing one means the bridge answered a different request. Re-run against a build that advertises 'scene.nodes'."
|
|
3903
|
+
});
|
|
3904
|
+
return;
|
|
3905
|
+
}
|
|
3906
|
+
const minCount = assertion.minCount ?? (assertion.maxCount === 0 ? 0 : 1);
|
|
3907
|
+
const countPass = observation.matched >= minCount && (assertion.maxCount === void 0 || observation.matched <= assertion.maxCount);
|
|
3908
|
+
ctx.assertions.push({
|
|
3909
|
+
details: { matched: observation.matched, maxCount: assertion.maxCount, minCount, selector },
|
|
3910
|
+
id: `${id}.count`,
|
|
3911
|
+
pass: countPass
|
|
3912
|
+
});
|
|
3913
|
+
if (!countPass)
|
|
3914
|
+
ctx.diagnostics.push({
|
|
3915
|
+
code: "TN_PLAYTEST_SCENE_NODES_COUNT",
|
|
3916
|
+
message: `Selector ${selector} matched ${observation.matched} node(s); the scenario bounds it to ${minCount}..${assertion.maxCount ?? "\u221E"}.`,
|
|
3917
|
+
observedRuntimePath: `observations.json/sceneNodes/${index}/matched`,
|
|
3918
|
+
severity: "error",
|
|
3919
|
+
suggestion: observation.matched === 0 ? "Check the node's name against the scene graph \u2014 the walk reports Object3D.name, which is empty unless the game sets it. Nothing was matched, so no other bound in this assertion was measured." : "Narrow the selector, or fix the scene so it carries the number of nodes the scenario expects."
|
|
3920
|
+
});
|
|
3921
|
+
if (observation.nodes.length === 0) return;
|
|
3922
|
+
const sampled = observation.truncated;
|
|
3923
|
+
if (assertion.visible !== void 0)
|
|
3924
|
+
emitPerNode(ctx, id, index, "visible", observation, sampled, assertion.visible, (node) => node.visibleInTree, {
|
|
3925
|
+
code: "TN_PLAYTEST_SCENE_NODE_INVISIBLE",
|
|
3926
|
+
failure: (names) => assertion.visible === true ? `${names} is not visible to the renderer once every ancestor's flag is counted.` : `${names} is visible to the renderer, and the scenario asserts it is not.`,
|
|
3927
|
+
suggestion: "Object3D.visible is checked up the whole parent chain \u2014 a visible mesh under a hidden group draws nothing. Check the ancestors, not just the node."
|
|
3928
|
+
});
|
|
3929
|
+
if (assertion.inFrustum !== void 0)
|
|
3930
|
+
emitPerNode(ctx, id, index, "inFrustum", observation, sampled, assertion.inFrustum, (node) => node.inFrustum, {
|
|
3931
|
+
code: "TN_PLAYTEST_SCENE_NODE_OFF_SCREEN",
|
|
3932
|
+
failure: (names) => assertion.inFrustum === true ? `${names} is outside the active camera's frustum, so nothing the scenario asserts about it reaches the screen.` : `${names} is inside the active camera's frustum, and the scenario asserts it is not.`,
|
|
3933
|
+
suggestion: "Compare the node's world bounds against the camera position, forward and clip planes in the same observation. A node with no bounds is not tested and reports no frustum membership at all."
|
|
3934
|
+
});
|
|
3935
|
+
if (assertion.texturesLoaded === true)
|
|
3936
|
+
emitPerNode(
|
|
3937
|
+
ctx,
|
|
3938
|
+
id,
|
|
3939
|
+
index,
|
|
3940
|
+
"texturesLoaded",
|
|
3941
|
+
observation,
|
|
3942
|
+
sampled,
|
|
3943
|
+
true,
|
|
3944
|
+
(node) => (node.materials ?? []).every((material) => material.mapsUnloaded.length === 0),
|
|
3945
|
+
{
|
|
3946
|
+
code: "TN_PLAYTEST_SCENE_NODE_TEXTURE_UNLOADED",
|
|
3947
|
+
failure: (names, nodes) => {
|
|
3948
|
+
const slots = nodes.flatMap((node) => (node.materials ?? []).flatMap((material) => material.mapsUnloaded)).join(", ");
|
|
3949
|
+
return `${names} has bound texture slot(s) carrying no image: ${slots}. Those slots sample black while every material and light count stays healthy.`;
|
|
3950
|
+
},
|
|
3951
|
+
suggestion: "The texture was bound before it loaded, or its load failed. Check the network observations for the image request and await the loader before assigning the map."
|
|
3952
|
+
}
|
|
3953
|
+
);
|
|
3954
|
+
if (assertion.animated !== void 0)
|
|
3955
|
+
emitPerNode(ctx, id, index, "animated", observation, sampled, assertion.animated, (node) => (node.animation?.clips.length ?? 0) > 0, {
|
|
3956
|
+
code: "TN_PLAYTEST_SCENE_NODE_NOT_ANIMATED",
|
|
3957
|
+
failure: (names) => assertion.animated === true ? `${names} carries no animation clips, so nothing it is asked to play exists on it.` : `${names} carries animation clips, and the scenario asserts it carries none.`,
|
|
3958
|
+
suggestion: "This reports the clips mounted on the object, not the actions running on the game's mixer. A game that drives its own mixer publishes what is playing through gameplay.animation and bounds it with assert.animation."
|
|
3959
|
+
});
|
|
3960
|
+
if (assertion.minTriangles !== void 0) {
|
|
3961
|
+
const triangles = observation.nodes.reduce((total, node) => total + (node.geometry?.triangles ?? 0), 0);
|
|
3962
|
+
const pass = triangles >= assertion.minTriangles;
|
|
3963
|
+
ctx.assertions.push({
|
|
3964
|
+
details: { expected: assertion.minTriangles, observed: triangles, sampled, selector },
|
|
3965
|
+
id: `${id}.minTriangles`,
|
|
3966
|
+
pass
|
|
3967
|
+
});
|
|
3968
|
+
if (!pass)
|
|
3969
|
+
ctx.diagnostics.push({
|
|
3970
|
+
code: "TN_PLAYTEST_SCENE_NODE_GEOMETRY",
|
|
3971
|
+
message: `Selector ${selector} reported ${triangles} triangle(s) across ${observation.nodes.length} node(s), below the asserted floor of ${assertion.minTriangles}.`,
|
|
3972
|
+
observedRuntimePath: `observations.json/sceneNodes/${index}/nodes`,
|
|
3973
|
+
severity: "error",
|
|
3974
|
+
suggestion: sampled ? "The reported nodes are a sample cut by the selector's limit, so the sum is a floor. Raise the limit before reading this as the scene's total." : "The mesh loaded with less geometry than expected, or a placeholder is standing in for an asset that never arrived."
|
|
3975
|
+
});
|
|
3976
|
+
}
|
|
3977
|
+
}
|
|
3978
|
+
function emitPerNode(ctx, id, index, bound, observation, sampled, expected, read, messages) {
|
|
3979
|
+
const failing = observation.nodes.filter((node) => read(node) !== expected);
|
|
3980
|
+
const pass = failing.length === 0;
|
|
3981
|
+
ctx.assertions.push({
|
|
3982
|
+
details: {
|
|
3983
|
+
expected,
|
|
3984
|
+
failing: failing.map((node) => node.path).slice(0, 10),
|
|
3985
|
+
observed: observation.nodes.length - failing.length,
|
|
3986
|
+
of: observation.nodes.length,
|
|
3987
|
+
sampled
|
|
3988
|
+
},
|
|
3989
|
+
id: `${id}.${bound}`,
|
|
3990
|
+
pass
|
|
3991
|
+
});
|
|
3992
|
+
if (pass) return;
|
|
3993
|
+
const names = failing.length === 1 ? `'${failing[0].path}'` : `${failing.length} node(s), including '${failing[0].path}',`;
|
|
3994
|
+
ctx.diagnostics.push({
|
|
3995
|
+
code: messages.code,
|
|
3996
|
+
message: messages.failure(names, failing),
|
|
3997
|
+
observedRuntimePath: `observations.json/sceneNodes/${index}/nodes`,
|
|
3998
|
+
severity: "error",
|
|
3999
|
+
suggestion: messages.suggestion
|
|
4000
|
+
});
|
|
4001
|
+
}
|
|
4002
|
+
|
|
4003
|
+
// src/runner/sceneRoom.ts
|
|
4004
|
+
var LIT_MATERIAL_PATTERN = /standard|physical|lambert|phong|toon/iu;
|
|
4005
|
+
function summariseRoom(scene) {
|
|
4006
|
+
const types = {};
|
|
4007
|
+
for (const light of scene.lights) types[light.type] = (types[light.type] ?? 0) + 1;
|
|
4008
|
+
const litMaterials = Object.entries(scene.materials).filter(([name]) => LIT_MATERIAL_PATTERN.test(name)).reduce((total, [, count]) => total + count, 0);
|
|
4009
|
+
return {
|
|
4010
|
+
background: scene.background,
|
|
4011
|
+
camera: scene.camera,
|
|
4012
|
+
...scene.fog === void 0 ? {} : { fog: scene.fog },
|
|
4013
|
+
lights: {
|
|
4014
|
+
count: scene.lights.length,
|
|
4015
|
+
types,
|
|
4016
|
+
visible: scene.lights.filter(({ visible }) => visible).length
|
|
4017
|
+
},
|
|
4018
|
+
litMaterials,
|
|
4019
|
+
materials: scene.materials,
|
|
4020
|
+
objects: scene.objects,
|
|
4021
|
+
truncated: scene.truncated,
|
|
4022
|
+
...scene.worldExtent === void 0 ? {} : { worldExtent: scene.worldExtent }
|
|
4023
|
+
};
|
|
4024
|
+
}
|
|
4025
|
+
function furthestSceneCornerDistance(summary) {
|
|
4026
|
+
const extent = summary.worldExtent;
|
|
4027
|
+
if (extent === void 0) return void 0;
|
|
4028
|
+
const [cx, cy, cz] = summary.camera.position;
|
|
4029
|
+
let furthest = 0;
|
|
4030
|
+
for (const x of [extent.min[0], extent.max[0]])
|
|
4031
|
+
for (const y of [extent.min[1], extent.max[1]])
|
|
4032
|
+
for (const z of [extent.min[2], extent.max[2]])
|
|
4033
|
+
furthest = Math.max(furthest, Math.hypot(x - cx, y - cy, z - cz));
|
|
4034
|
+
return furthest;
|
|
4035
|
+
}
|
|
4036
|
+
|
|
4037
|
+
// src/evaluators/scene.ts
|
|
4038
|
+
function emitScene(ctx) {
|
|
4039
|
+
const assertion = ctx.scenarioAssertions.scene;
|
|
4040
|
+
if (assertion === void 0) return;
|
|
4041
|
+
const observed = ctx.input.report.observations?.scene;
|
|
4042
|
+
if (observed === void 0) {
|
|
4043
|
+
ctx.assertions.push({ details: { expected: assertion, observed: void 0 }, id: "scene.observed", pass: false });
|
|
4044
|
+
ctx.diagnostics.push({
|
|
4045
|
+
code: "TN_PLAYTEST_SCENE_UNOBSERVED",
|
|
4046
|
+
message: "A scene assertion was evaluated against a run whose bridge reported no scene observation.",
|
|
4047
|
+
observedRuntimePath: "observations.json/scene",
|
|
4048
|
+
severity: "error",
|
|
4049
|
+
suggestion: "Install the playtest bridge (core's playtest() plugin, or installThreePlaytestBridge for a plain Three.js project) so the run advertises 'scene.observe', or narrow the scenario. Never delete the assertion to get green."
|
|
4050
|
+
});
|
|
4051
|
+
return;
|
|
4052
|
+
}
|
|
4053
|
+
const summary = summariseRoom(observed);
|
|
4054
|
+
const furthest = furthestSceneCornerDistance(summary);
|
|
4055
|
+
if (assertion.minVisibleLights !== void 0) {
|
|
4056
|
+
const pass = summary.lights.visible >= assertion.minVisibleLights;
|
|
4057
|
+
ctx.assertions.push({
|
|
4058
|
+
details: { expected: assertion.minVisibleLights, observed: summary.lights.visible, total: summary.lights.count },
|
|
4059
|
+
id: "scene.minVisibleLights",
|
|
4060
|
+
pass
|
|
4061
|
+
});
|
|
4062
|
+
if (!pass)
|
|
4063
|
+
ctx.diagnostics.push({
|
|
4064
|
+
code: "TN_PLAYTEST_SCENE_UNLIT",
|
|
4065
|
+
message: `The scene has ${summary.lights.visible} visible light(s) of ${summary.lights.count} mounted, below the asserted floor of ${assertion.minVisibleLights}.`,
|
|
4066
|
+
observedRuntimePath: "observations.json/scene/lights",
|
|
2695
4067
|
severity: "error",
|
|
2696
|
-
suggestion: "
|
|
4068
|
+
suggestion: "Add the light the scene is missing, or make the mounted one visible \u2014 an invisible light is no light as far as the renderer is concerned."
|
|
2697
4069
|
});
|
|
2698
|
-
}
|
|
2699
|
-
}
|
|
2700
|
-
for (const assertion of scenarioAssertions.hud ?? []) {
|
|
2701
|
-
const result = evaluatePathAssertion("hud", assertion, input.report.observations?.hud[assertion.id], {});
|
|
2702
|
-
assertions.push(result.assertion);
|
|
2703
|
-
if (result.diagnostic !== void 0) {
|
|
2704
|
-
diagnostics.push({ ...result.diagnostic, code: result.diagnostic.code || "TN_PLAYTEST_HUD_ASSERTION_FAILED" });
|
|
2705
|
-
}
|
|
2706
|
-
}
|
|
2707
|
-
for (const assertion of scenarioAssertions.tags ?? []) {
|
|
2708
|
-
const result = evaluateTagCountAssertion(assertion, input.report.observations?.runtimeObservations);
|
|
2709
|
-
assertions.push(result.assertion);
|
|
2710
|
-
if (result.diagnostic !== void 0) {
|
|
2711
|
-
diagnostics.push(result.diagnostic);
|
|
2712
|
-
}
|
|
2713
4070
|
}
|
|
2714
|
-
|
|
2715
|
-
const
|
|
2716
|
-
assertions.push(
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
4071
|
+
if (assertion.litMaterialsAreLit === true) {
|
|
4072
|
+
const pass = summary.litMaterials === 0 || summary.lights.visible > 0;
|
|
4073
|
+
ctx.assertions.push({
|
|
4074
|
+
details: { litMaterials: summary.litMaterials, visibleLights: summary.lights.visible },
|
|
4075
|
+
id: "scene.litMaterialsAreLit",
|
|
4076
|
+
pass
|
|
4077
|
+
});
|
|
4078
|
+
if (!pass)
|
|
4079
|
+
ctx.diagnostics.push({
|
|
4080
|
+
code: "TN_PLAYTEST_SCENE_UNLIT",
|
|
4081
|
+
message: `${summary.litMaterials} lit material(s) are mounted and no light in the scene is visible, so everything wearing one renders black.`,
|
|
4082
|
+
observedRuntimePath: "observations.json/scene/materials",
|
|
4083
|
+
severity: "error",
|
|
4084
|
+
suggestion: "Add a visible light, or move the affected meshes onto a material that does not read one."
|
|
4085
|
+
});
|
|
2720
4086
|
}
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
function emitRenderChain(ctx) {
|
|
2725
|
-
const assertion = ctx.scenarioAssertions.renderChain;
|
|
2726
|
-
if (assertion === void 0) return;
|
|
2727
|
-
const observed = ctx.input.report.observations?.renderChain;
|
|
2728
|
-
if (assertion.tier !== void 0) {
|
|
2729
|
-
const pass = observed?.tier === assertion.tier;
|
|
4087
|
+
const fog = summary.fog;
|
|
4088
|
+
if (assertion.fogClearsScene === true) {
|
|
4089
|
+
const pass = furthest !== void 0 && (fog === void 0 || fog.type !== "linear" || fog.far === void 0 || fog.far >= furthest);
|
|
2730
4090
|
ctx.assertions.push({
|
|
2731
|
-
details: {
|
|
2732
|
-
id: "
|
|
4091
|
+
details: { fogFar: fog?.type === "linear" ? fog.far : void 0, sceneReach: furthest },
|
|
4092
|
+
id: "scene.fogClearsScene",
|
|
2733
4093
|
pass
|
|
2734
4094
|
});
|
|
2735
|
-
if (!pass)
|
|
4095
|
+
if (!pass)
|
|
2736
4096
|
ctx.diagnostics.push({
|
|
2737
|
-
code:
|
|
2738
|
-
message:
|
|
2739
|
-
observedRuntimePath: "observations.json/
|
|
4097
|
+
code: furthest === void 0 ? "TN_PLAYTEST_SCENE_UNOBSERVED" : "TN_PLAYTEST_SCENE_FOG_CLIPS",
|
|
4098
|
+
message: furthest === void 0 ? "The scene reported no world extent, so there was nothing to measure the fog against." : `Fog reaches full ${fog?.color} at ${(fog?.type === "linear" ? fog.far : 0)?.toFixed(1)} units while the scene runs to ${furthest.toFixed(1)} \u2014 everything past the far plane is one flat wash.`,
|
|
4099
|
+
observedRuntimePath: "observations.json/scene/fog",
|
|
2740
4100
|
severity: "error",
|
|
2741
|
-
suggestion: "
|
|
4101
|
+
suggestion: "Move the fog's far plane past the scene, or take the far geometry out of the fog by setting fog: false on its material."
|
|
2742
4102
|
});
|
|
2743
|
-
}
|
|
2744
4103
|
}
|
|
2745
|
-
if (assertion.
|
|
2746
|
-
const
|
|
2747
|
-
const
|
|
2748
|
-
const hasMeasurement = rejectionFraction !== void 0 && Number.isFinite(rejectionFraction) && typeof measurementFrame === "number" && Number.isInteger(measurementFrame) && measurementFrame >= 0;
|
|
2749
|
-
const pass = hasMeasurement && rejectionFraction !== void 0 && rejectionFraction <= assertion.velocity.maxRejectionFraction;
|
|
4104
|
+
if (assertion.cameraClearsScene === true) {
|
|
4105
|
+
const far = summary.camera.far;
|
|
4106
|
+
const pass = furthest !== void 0 && far !== void 0 && far >= furthest;
|
|
2750
4107
|
ctx.assertions.push({
|
|
2751
|
-
details: {
|
|
2752
|
-
|
|
2753
|
-
measurementFrame,
|
|
2754
|
-
observed: rejectionFraction
|
|
2755
|
-
},
|
|
2756
|
-
id: "renderChain.velocity.rejectionFraction",
|
|
4108
|
+
details: { cameraFar: far, sceneReach: furthest },
|
|
4109
|
+
id: "scene.cameraClearsScene",
|
|
2757
4110
|
pass
|
|
2758
4111
|
});
|
|
2759
|
-
if (!pass)
|
|
4112
|
+
if (!pass)
|
|
2760
4113
|
ctx.diagnostics.push({
|
|
2761
|
-
code:
|
|
2762
|
-
message:
|
|
2763
|
-
observedRuntimePath: "observations.json/
|
|
4114
|
+
code: furthest === void 0 || far === void 0 ? "TN_PLAYTEST_SCENE_UNOBSERVED" : "TN_PLAYTEST_SCENE_CAMERA_CLIPS",
|
|
4115
|
+
message: furthest === void 0 || far === void 0 ? "The camera reported no far plane, or the scene reported no world extent, so the two could not be compared." : `The camera's far plane is ${far.toFixed(1)} and the scene runs to ${furthest.toFixed(1)} \u2014 geometry past it is clipped, not drawn small.`,
|
|
4116
|
+
observedRuntimePath: "observations.json/scene/camera",
|
|
2764
4117
|
severity: "error",
|
|
2765
|
-
suggestion: "
|
|
4118
|
+
suggestion: "Raise the camera's far plane past the scene's reach, or stop building geometry the camera was never going to draw."
|
|
2766
4119
|
});
|
|
2767
|
-
|
|
4120
|
+
}
|
|
4121
|
+
}
|
|
4122
|
+
|
|
4123
|
+
// src/evaluators/startup.ts
|
|
4124
|
+
var MILESTONES = {
|
|
4125
|
+
maxCompileSettledMs: "compileSettledMs",
|
|
4126
|
+
maxEnteredMs: "enteredMs",
|
|
4127
|
+
maxReadyMs: "readyMs"
|
|
4128
|
+
};
|
|
4129
|
+
function emitStartup(ctx) {
|
|
4130
|
+
const assertion = ctx.scenarioAssertions.startup;
|
|
4131
|
+
if (assertion === void 0) return;
|
|
4132
|
+
const timeline = ctx.input.report.observations?.startup?.timeline;
|
|
4133
|
+
for (const [ceilingKey, milestone] of Object.entries(MILESTONES)) {
|
|
4134
|
+
const ceiling = assertion[ceilingKey];
|
|
4135
|
+
if (ceiling === void 0) continue;
|
|
4136
|
+
const observed = timeline?.[milestone];
|
|
4137
|
+
const pass = typeof observed === "number" && Number.isFinite(observed) && observed <= ceiling;
|
|
4138
|
+
ctx.assertions.push({
|
|
4139
|
+
details: { expected: ceiling, observed },
|
|
4140
|
+
id: `startup.${milestone}`,
|
|
4141
|
+
pass
|
|
4142
|
+
});
|
|
4143
|
+
if (pass) continue;
|
|
4144
|
+
ctx.diagnostics.push({
|
|
4145
|
+
code: observed === void 0 ? "TN_PLAYTEST_STARTUP_UNOBSERVABLE" : "TN_PLAYTEST_STARTUP_TOO_SLOW",
|
|
4146
|
+
message: observed === void 0 ? `Startup milestone '${milestone}' was not observed: the runtime reported no timeline entry for it.` : `Startup milestone '${milestone}' happened at ${Math.round(observed)} ms, past the asserted ceiling of ${ceiling} ms.`,
|
|
4147
|
+
observedRuntimePath: `observations.json/startup/timeline/${milestone}`,
|
|
4148
|
+
severity: "error",
|
|
4149
|
+
suggestion: observed === void 0 ? "Keep the playtest bridge installed before startup and let the game reach that milestone inside the run; a runtime without a startup timeline cannot satisfy this assertion." : "Move work out of the critical startup path \u2014 load detail after enter(), share textures across models, keep first-use compilation inside its budget \u2014 or raise the ceiling with the measurement that justifies it."
|
|
4150
|
+
});
|
|
2768
4151
|
}
|
|
2769
4152
|
}
|
|
2770
4153
|
|
|
@@ -2777,9 +4160,14 @@ function evaluateRichPlaytestAssertions(input) {
|
|
|
2777
4160
|
emitDeviceMetrics(ctx);
|
|
2778
4161
|
emitDisplayFamilies(ctx);
|
|
2779
4162
|
emitEvidenceFamilies(ctx);
|
|
4163
|
+
emitParity(ctx);
|
|
2780
4164
|
emitPerfSignalsWorld(ctx);
|
|
2781
4165
|
emitWorldGameplay(ctx);
|
|
2782
4166
|
emitRenderChain(ctx);
|
|
4167
|
+
emitScene(ctx);
|
|
4168
|
+
emitSceneNodes(ctx);
|
|
4169
|
+
emitCausedBy(ctx);
|
|
4170
|
+
emitStartup(ctx);
|
|
2783
4171
|
emitMovementEvidence(ctx);
|
|
2784
4172
|
if (assertions.length === 0 || scenarioAssertions.diagnostics === void 0 && !assertions.some(({ id }) => id !== "diagnostics")) {
|
|
2785
4173
|
const id = "scenario.assertions";
|
|
@@ -3170,6 +4558,225 @@ function rejectUnknownKeys(value, allowedKeys, scenarioPath, objectPath) {
|
|
|
3170
4558
|
var NUMERIC_COMPARISON_KEYS = ["gte", "lte"];
|
|
3171
4559
|
var MIN_TRIVIALITY_REASON_LENGTH = 20;
|
|
3172
4560
|
|
|
4561
|
+
// src/scenario/generated-assertion-validators.ts
|
|
4562
|
+
function isRecord2(value) {
|
|
4563
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4564
|
+
}
|
|
4565
|
+
var GENERATED_ASSERTION_FIELD_VALIDATORS = Object.freeze({
|
|
4566
|
+
"deviceMetrics": Object.freeze({
|
|
4567
|
+
"maxTemperatureRiseC": (value) => typeof value === "number" && Number.isFinite(value) && value >= 0,
|
|
4568
|
+
"maxThermalStatus": (value) => typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= 6,
|
|
4569
|
+
"notThermallyConfounded": (value) => value === true
|
|
4570
|
+
}),
|
|
4571
|
+
"framebufferCoverage": Object.freeze({
|
|
4572
|
+
"backdrop": (value) => Array.isArray(value),
|
|
4573
|
+
"grid": (value) => isRecord2(value),
|
|
4574
|
+
"tolerance": (value) => typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= 255,
|
|
4575
|
+
"window": (value) => isRecord2(value)
|
|
4576
|
+
}),
|
|
4577
|
+
"reachability": Object.freeze({
|
|
4578
|
+
"artifact": (value) => typeof value === "string" && value.trim() !== "",
|
|
4579
|
+
"entities": (value) => Array.isArray(value)
|
|
4580
|
+
}),
|
|
4581
|
+
"aerodynamics": Object.freeze({
|
|
4582
|
+
"entity": (value) => typeof value === "string" && value.trim() !== "",
|
|
4583
|
+
"minForceSamples": (value) => typeof value === "number" && Number.isInteger(value) && value > 0,
|
|
4584
|
+
"controls": (value) => Array.isArray(value),
|
|
4585
|
+
"torques": (value) => Array.isArray(value)
|
|
4586
|
+
}),
|
|
4587
|
+
"visual": Object.freeze({
|
|
4588
|
+
"frameDiff": (value) => isRecord2(value),
|
|
4589
|
+
"region": (value) => isRecord2(value),
|
|
4590
|
+
"entityVisible": (value) => isRecord2(value)
|
|
4591
|
+
}),
|
|
4592
|
+
"movement": Object.freeze({
|
|
4593
|
+
"entity": (value) => typeof value === "string" && value.trim() !== "",
|
|
4594
|
+
"closesDistanceToPosition": (value) => isRecord2(value),
|
|
4595
|
+
"facesMovementWithinDegrees": (value) => typeof value === "number" && Number.isFinite(value),
|
|
4596
|
+
"axis": (value) => typeof value === "string" && value.trim() !== "",
|
|
4597
|
+
"minAxisDelta": (value) => isRecord2(value),
|
|
4598
|
+
"minResolvedAxisDelta": (value) => isRecord2(value),
|
|
4599
|
+
"maxTiltDegrees": (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= 180,
|
|
4600
|
+
"minDistance": (value) => typeof value === "number" && Number.isFinite(value),
|
|
4601
|
+
"maxDistance": (value) => typeof value === "number" && Number.isFinite(value),
|
|
4602
|
+
"minVelocity": (value) => typeof value === "number" && Number.isFinite(value),
|
|
4603
|
+
"pathLength": (value) => typeof value === "number" && Number.isFinite(value),
|
|
4604
|
+
"notFacing": (value) => isRecord2(value),
|
|
4605
|
+
"notFacingPosition": (value) => isRecord2(value),
|
|
4606
|
+
"reachesPositionWithin": (value) => isRecord2(value),
|
|
4607
|
+
"rotationChanged": (value) => typeof value === "boolean"
|
|
4608
|
+
}),
|
|
4609
|
+
"camera": Object.freeze({
|
|
4610
|
+
"entity": (value) => typeof value === "string" && value.trim() !== "",
|
|
4611
|
+
"follows": (value) => typeof value === "string" && value.trim() !== "",
|
|
4612
|
+
"within": (value) => typeof value === "number" && Number.isFinite(value),
|
|
4613
|
+
"targetInViewport": (value) => typeof value === "boolean"
|
|
4614
|
+
}),
|
|
4615
|
+
"components": Object.freeze({
|
|
4616
|
+
"entity": (value) => typeof value === "string" && value.trim() !== "",
|
|
4617
|
+
"component": (value) => typeof value === "string" && value.trim() !== "",
|
|
4618
|
+
"path": (value) => typeof value === "string" && value.trim() !== "",
|
|
4619
|
+
"equals": (value) => true,
|
|
4620
|
+
"gte": (value) => typeof value === "number" && Number.isFinite(value),
|
|
4621
|
+
"lte": (value) => typeof value === "number" && Number.isFinite(value),
|
|
4622
|
+
"changed": (value) => typeof value === "boolean",
|
|
4623
|
+
"atSteps": (value) => Array.isArray(value),
|
|
4624
|
+
"allowTrivial": (value) => typeof value === "string" && value.replace(/\s/gu, "").length >= MIN_TRIVIALITY_REASON_LENGTH
|
|
4625
|
+
}),
|
|
4626
|
+
"resources": Object.freeze({
|
|
4627
|
+
"id": (value) => typeof value === "string" && value.trim() !== "",
|
|
4628
|
+
"path": (value) => typeof value === "string" && value.trim() !== "",
|
|
4629
|
+
"equals": (value) => true,
|
|
4630
|
+
"gte": (value) => typeof value === "number" && Number.isFinite(value),
|
|
4631
|
+
"lte": (value) => typeof value === "number" && Number.isFinite(value),
|
|
4632
|
+
"textIncludes": (value) => typeof value === "string" && value.trim() !== "",
|
|
4633
|
+
"changed": (value) => typeof value === "boolean",
|
|
4634
|
+
"throughoutSteps": (value) => typeof value === "boolean",
|
|
4635
|
+
"atSteps": (value) => Array.isArray(value),
|
|
4636
|
+
"allowTrivial": (value) => typeof value === "string" && value.replace(/\s/gu, "").length >= MIN_TRIVIALITY_REASON_LENGTH,
|
|
4637
|
+
"anyOf": (value) => Array.isArray(value)
|
|
4638
|
+
}),
|
|
4639
|
+
"tags": Object.freeze({
|
|
4640
|
+
"tag": (value) => typeof value === "string" && value.trim() !== "",
|
|
4641
|
+
"count": (value) => typeof value === "number" && Number.isInteger(value) && value >= 0,
|
|
4642
|
+
"gte": (value) => typeof value === "number" && Number.isInteger(value) && value >= 0,
|
|
4643
|
+
"lte": (value) => typeof value === "number" && Number.isInteger(value) && value >= 0,
|
|
4644
|
+
"allowTrivial": (value) => typeof value === "string" && value.replace(/\s/gu, "").length >= MIN_TRIVIALITY_REASON_LENGTH
|
|
4645
|
+
}),
|
|
4646
|
+
"signals": Object.freeze({
|
|
4647
|
+
"atStep": (value) => typeof value === "string" && value.trim() !== "",
|
|
4648
|
+
"entity": (value) => typeof value === "string" && value.trim() !== "",
|
|
4649
|
+
"maxCount": (value) => typeof value === "number" && Number.isInteger(value) && value >= 0,
|
|
4650
|
+
"minCount": (value) => typeof value === "number" && Number.isInteger(value) && value >= 0,
|
|
4651
|
+
"name": (value) => typeof value === "string" && value.trim() !== ""
|
|
4652
|
+
}),
|
|
4653
|
+
"states": Object.freeze({
|
|
4654
|
+
"entity": (value) => typeof value === "string" && value.trim() !== "",
|
|
4655
|
+
"equals": (value) => typeof value === "string" && value.trim() !== "",
|
|
4656
|
+
"allowTrivial": (value) => typeof value === "string" && value.replace(/\s/gu, "").length >= MIN_TRIVIALITY_REASON_LENGTH
|
|
4657
|
+
}),
|
|
4658
|
+
"hud": Object.freeze({
|
|
4659
|
+
"id": (value) => typeof value === "string" && value.trim() !== "",
|
|
4660
|
+
"path": (value) => typeof value === "string" && value.trim() !== "",
|
|
4661
|
+
"equals": (value) => true,
|
|
4662
|
+
"gte": (value) => typeof value === "number" && Number.isFinite(value),
|
|
4663
|
+
"lte": (value) => typeof value === "number" && Number.isFinite(value),
|
|
4664
|
+
"textIncludes": (value) => typeof value === "string" && value.trim() !== "",
|
|
4665
|
+
"changed": (value) => typeof value === "boolean",
|
|
4666
|
+
"allowTrivial": (value) => typeof value === "string" && value.replace(/\s/gu, "").length >= MIN_TRIVIALITY_REASON_LENGTH,
|
|
4667
|
+
"visible": (value) => typeof value === "boolean"
|
|
4668
|
+
}),
|
|
4669
|
+
"overlayNodes": Object.freeze({
|
|
4670
|
+
"overlayId": (value) => typeof value === "string" && value.trim() !== "",
|
|
4671
|
+
"selector": (value) => typeof value === "string" && value.trim() !== "",
|
|
4672
|
+
"attribute": (value) => typeof value === "string" && value.trim() !== "",
|
|
4673
|
+
"equals": (value) => true,
|
|
4674
|
+
"textIncludes": (value) => typeof value === "string" && value.trim() !== "",
|
|
4675
|
+
"visible": (value) => typeof value === "boolean"
|
|
4676
|
+
}),
|
|
4677
|
+
"diagnostics": Object.freeze({
|
|
4678
|
+
"noConsoleErrors": (value) => typeof value === "boolean",
|
|
4679
|
+
"noNetworkErrors": (value) => typeof value === "boolean",
|
|
4680
|
+
"noRuntimeDiagnostics": (value) => typeof value === "boolean",
|
|
4681
|
+
"consoleErrorsOptOutReason": (value) => typeof value === "string" && value.trim() !== "",
|
|
4682
|
+
"networkErrorsOptOutReason": (value) => typeof value === "string" && value.trim() !== "",
|
|
4683
|
+
"runtimeDiagnosticsOptOutReason": (value) => typeof value === "string" && value.trim() !== "",
|
|
4684
|
+
"runtimeReady": (value) => typeof value === "boolean"
|
|
4685
|
+
}),
|
|
4686
|
+
"performance": Object.freeze({
|
|
4687
|
+
"maxFrameMsP95": (value) => typeof value === "number" && Number.isFinite(value),
|
|
4688
|
+
"minFps": (value) => typeof value === "number" && Number.isFinite(value),
|
|
4689
|
+
"maxPhaseMsP95": (value) => isRecord2(value),
|
|
4690
|
+
"maxDrawCalls": (value) => typeof value === "number" && Number.isFinite(value),
|
|
4691
|
+
"maxTriangles": (value) => typeof value === "number" && Number.isFinite(value)
|
|
4692
|
+
}),
|
|
4693
|
+
"parity": Object.freeze({
|
|
4694
|
+
"minFpsRatio": (value) => typeof value === "number" && Number.isFinite(value) && value > 0,
|
|
4695
|
+
"minRenderParity": (value) => typeof value === "number" && Number.isFinite(value) && value > 0,
|
|
4696
|
+
"referenceReport": (value) => typeof value === "string" && value.trim() !== "",
|
|
4697
|
+
"referenceSide": (value) => value === "browser" || value === "native",
|
|
4698
|
+
"reference": (value) => isRecord2(value)
|
|
4699
|
+
}),
|
|
4700
|
+
"visibility": Object.freeze({
|
|
4701
|
+
"entity": (value) => typeof value === "string" && value.trim() !== "",
|
|
4702
|
+
"minProjectedPixels": (value) => typeof value === "number" && Number.isFinite(value),
|
|
4703
|
+
"maxOffscreenRatio": (value) => typeof value === "number" && Number.isFinite(value),
|
|
4704
|
+
"present": (value) => typeof value === "boolean",
|
|
4705
|
+
"allowTrivial": (value) => typeof value === "string" && value.replace(/\s/gu, "").length >= MIN_TRIVIALITY_REASON_LENGTH
|
|
4706
|
+
}),
|
|
4707
|
+
"world": Object.freeze({
|
|
4708
|
+
"seed": (value) => true,
|
|
4709
|
+
"runtime": (value) => isRecord2(value)
|
|
4710
|
+
}),
|
|
4711
|
+
"contacts": Object.freeze({
|
|
4712
|
+
"atStep": (value) => typeof value === "string" && value.trim() !== "",
|
|
4713
|
+
"entity": (value) => typeof value === "string" && value.trim() !== "",
|
|
4714
|
+
"with": (value) => typeof value === "string" && value.trim() !== "",
|
|
4715
|
+
"kind": (value) => typeof value === "string" && value.trim() !== "",
|
|
4716
|
+
"minCount": (value) => typeof value === "number" && Number.isFinite(value),
|
|
4717
|
+
"maxCount": (value) => typeof value === "number" && Number.isInteger(value) && value >= 0,
|
|
4718
|
+
"requiredOn": (value) => Array.isArray(value)
|
|
4719
|
+
}),
|
|
4720
|
+
"settled": Object.freeze({
|
|
4721
|
+
"entity": (value) => typeof value === "string" && value.trim() !== "",
|
|
4722
|
+
"atStep": (value) => typeof value === "string" && value.trim() !== "",
|
|
4723
|
+
"minBodies": (value) => typeof value === "number" && Number.isInteger(value) && value > 0,
|
|
4724
|
+
"compareToStep": (value) => typeof value === "string" && value.trim() !== "",
|
|
4725
|
+
"minMeanPoseDistance": (value) => typeof value === "number" && Number.isFinite(value) && value > 0,
|
|
4726
|
+
"requiredOn": (value) => Array.isArray(value),
|
|
4727
|
+
"allowTrivial": (value) => typeof value === "string" && value.replace(/\s/gu, "").length >= MIN_TRIVIALITY_REASON_LENGTH
|
|
4728
|
+
}),
|
|
4729
|
+
"occluded": Object.freeze({
|
|
4730
|
+
"entity": (value) => typeof value === "string" && value.trim() !== "",
|
|
4731
|
+
"target": (value) => typeof value === "string" && value.trim() !== "",
|
|
4732
|
+
"allowTrivial": (value) => typeof value === "string" && value.replace(/\s/gu, "").length >= MIN_TRIVIALITY_REASON_LENGTH
|
|
4733
|
+
}),
|
|
4734
|
+
"animation": Object.freeze({
|
|
4735
|
+
"entity": (value) => typeof value === "string" && value.trim() !== "",
|
|
4736
|
+
"clip": (value) => typeof value === "string" && value.trim() !== "",
|
|
4737
|
+
"entered": (value) => typeof value === "boolean",
|
|
4738
|
+
"advancedFrames": (value) => typeof value === "number" && Number.isFinite(value),
|
|
4739
|
+
"finished": (value) => typeof value === "boolean",
|
|
4740
|
+
"maxFootSlide": (value) => typeof value === "number" && Number.isFinite(value),
|
|
4741
|
+
"strideSynced": (value) => typeof value === "boolean",
|
|
4742
|
+
"allowTrivial": (value) => typeof value === "string" && value.replace(/\s/gu, "").length >= MIN_TRIVIALITY_REASON_LENGTH
|
|
4743
|
+
}),
|
|
4744
|
+
"scene": Object.freeze({
|
|
4745
|
+
"cameraClearsScene": (value) => typeof value === "boolean",
|
|
4746
|
+
"fogClearsScene": (value) => typeof value === "boolean",
|
|
4747
|
+
"litMaterialsAreLit": (value) => typeof value === "boolean",
|
|
4748
|
+
"minVisibleLights": (value) => typeof value === "number" && Number.isFinite(value),
|
|
4749
|
+
"allowTrivial": (value) => typeof value === "string" && value.replace(/\s/gu, "").length >= MIN_TRIVIALITY_REASON_LENGTH
|
|
4750
|
+
}),
|
|
4751
|
+
"sceneNodes": Object.freeze({
|
|
4752
|
+
"select": (value) => isRecord2(value),
|
|
4753
|
+
"visible": (value) => typeof value === "boolean",
|
|
4754
|
+
"inFrustum": (value) => typeof value === "boolean",
|
|
4755
|
+
"texturesLoaded": (value) => typeof value === "boolean",
|
|
4756
|
+
"animated": (value) => typeof value === "boolean",
|
|
4757
|
+
"minCount": (value) => typeof value === "number" && Number.isFinite(value),
|
|
4758
|
+
"maxCount": (value) => typeof value === "number" && Number.isFinite(value),
|
|
4759
|
+
"minTriangles": (value) => typeof value === "number" && Number.isFinite(value)
|
|
4760
|
+
}),
|
|
4761
|
+
"causedBy": Object.freeze({
|
|
4762
|
+
"cause": (value) => isRecord2(value),
|
|
4763
|
+
"effect": (value) => isRecord2(value),
|
|
4764
|
+
"neverBefore": (value) => typeof value === "boolean",
|
|
4765
|
+
"withinTicks": (value) => typeof value === "number" && Number.isFinite(value)
|
|
4766
|
+
}),
|
|
4767
|
+
"startup": Object.freeze({
|
|
4768
|
+
"maxEnteredMs": (value) => typeof value === "number" && Number.isFinite(value),
|
|
4769
|
+
"maxCompileSettledMs": (value) => typeof value === "number" && Number.isFinite(value),
|
|
4770
|
+
"maxReadyMs": (value) => typeof value === "number" && Number.isFinite(value)
|
|
4771
|
+
}),
|
|
4772
|
+
"renderChain": Object.freeze({
|
|
4773
|
+
"tier": (value) => typeof value === "string" && value.trim() !== "",
|
|
4774
|
+
"stages": (value) => isRecord2(value),
|
|
4775
|
+
"contributions": (value) => isRecord2(value),
|
|
4776
|
+
"velocity": (value) => isRecord2(value)
|
|
4777
|
+
})
|
|
4778
|
+
});
|
|
4779
|
+
|
|
3173
4780
|
// src/scenario/schema-accessors.ts
|
|
3174
4781
|
function validateVisualAssertion(value, scenarioPath, objectPath) {
|
|
3175
4782
|
const record4 = requireRecord(value, scenarioPath, objectPath);
|
|
@@ -3177,20 +4784,37 @@ function validateVisualAssertion(value, scenarioPath, objectPath) {
|
|
|
3177
4784
|
const regionRecord = record4.region === void 0 ? void 0 : requireRecord(record4.region, scenarioPath, `${objectPath}.region`);
|
|
3178
4785
|
let region;
|
|
3179
4786
|
if (regionRecord !== void 0) {
|
|
3180
|
-
const
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
4787
|
+
const element = regionRecord.element === void 0 ? void 0 : validateVisualRegionTarget(regionRecord.element, scenarioPath, `${objectPath}.region.element`);
|
|
4788
|
+
const edgeKeys = ["height", "width", "x", "y"];
|
|
4789
|
+
if (element !== void 0) {
|
|
4790
|
+
const authoredEdge = edgeKeys.find((key) => hasKey(regionRecord, key));
|
|
4791
|
+
if (authoredEdge !== void 0) {
|
|
4792
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.region.${authoredEdge}' cannot be combined with an element-bound region; the element supplies its bounds.`);
|
|
4793
|
+
}
|
|
4794
|
+
region = {
|
|
4795
|
+
element,
|
|
4796
|
+
...present("maxDarkPixelRatio", optionalRatio(regionRecord, "maxDarkPixelRatio", scenarioPath, `${objectPath}.region`)),
|
|
4797
|
+
...present("maxLuminance", optionalNumber(regionRecord, "maxLuminance", scenarioPath, `${objectPath}.region`)),
|
|
4798
|
+
...present("minDarkPixelRatio", optionalNumber(regionRecord, "minDarkPixelRatio", scenarioPath, `${objectPath}.region`)),
|
|
4799
|
+
...present("minNonblankPixelRatio", optionalNumber(regionRecord, "minNonblankPixelRatio", scenarioPath, `${objectPath}.region`))
|
|
4800
|
+
};
|
|
4801
|
+
} else {
|
|
4802
|
+
const edges = { height: 0, width: 0, x: 0, y: 0 };
|
|
4803
|
+
for (const key of edgeKeys) {
|
|
4804
|
+
const item = regionRecord[key];
|
|
4805
|
+
if (typeof item !== "number" || !Number.isFinite(item)) {
|
|
4806
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.region.${key}' must be a finite number, received ${describeValue(item)}.`);
|
|
4807
|
+
}
|
|
4808
|
+
edges[key] = item;
|
|
3185
4809
|
}
|
|
3186
|
-
|
|
4810
|
+
region = {
|
|
4811
|
+
...edges,
|
|
4812
|
+
...present("maxDarkPixelRatio", optionalRatio(regionRecord, "maxDarkPixelRatio", scenarioPath, `${objectPath}.region`)),
|
|
4813
|
+
...present("maxLuminance", optionalNumber(regionRecord, "maxLuminance", scenarioPath, `${objectPath}.region`)),
|
|
4814
|
+
...present("minDarkPixelRatio", optionalNumber(regionRecord, "minDarkPixelRatio", scenarioPath, `${objectPath}.region`)),
|
|
4815
|
+
...present("minNonblankPixelRatio", optionalNumber(regionRecord, "minNonblankPixelRatio", scenarioPath, `${objectPath}.region`))
|
|
4816
|
+
};
|
|
3187
4817
|
}
|
|
3188
|
-
region = {
|
|
3189
|
-
...edges,
|
|
3190
|
-
...present("maxLuminance", optionalNumber(regionRecord, "maxLuminance", scenarioPath, `${objectPath}.region`)),
|
|
3191
|
-
...present("minDarkPixelRatio", optionalNumber(regionRecord, "minDarkPixelRatio", scenarioPath, `${objectPath}.region`)),
|
|
3192
|
-
...present("minNonblankPixelRatio", optionalNumber(regionRecord, "minNonblankPixelRatio", scenarioPath, `${objectPath}.region`))
|
|
3193
|
-
};
|
|
3194
4818
|
}
|
|
3195
4819
|
const entityVisibleRecord = record4.entityVisible === void 0 ? void 0 : requireRecord(record4.entityVisible, scenarioPath, `${objectPath}.entityVisible`);
|
|
3196
4820
|
let entityVisible;
|
|
@@ -3216,6 +4840,19 @@ function validateVisualAssertion(value, scenarioPath, objectPath) {
|
|
|
3216
4840
|
...region === void 0 ? {} : { region }
|
|
3217
4841
|
};
|
|
3218
4842
|
}
|
|
4843
|
+
function validateVisualRegionTarget(value, scenarioPath, objectPath) {
|
|
4844
|
+
const record4 = requireRecord(value, scenarioPath, objectPath);
|
|
4845
|
+
rejectUnknownKeys(record4, ["id", "selector"], scenarioPath, objectPath);
|
|
4846
|
+
const id = optionalString(record4, "id", scenarioPath, objectPath);
|
|
4847
|
+
const selector = optionalString(record4, "selector", scenarioPath, objectPath);
|
|
4848
|
+
if (id === void 0 === (selector === void 0)) {
|
|
4849
|
+
throw invalidScenario(scenarioPath, `'${objectPath}' must declare exactly one non-empty 'id' or 'selector'.`);
|
|
4850
|
+
}
|
|
4851
|
+
return {
|
|
4852
|
+
...id === void 0 ? {} : { id },
|
|
4853
|
+
...selector === void 0 ? {} : { selector }
|
|
4854
|
+
};
|
|
4855
|
+
}
|
|
3219
4856
|
function validateVisualFrameDiff(record4, scenarioPath, objectPath) {
|
|
3220
4857
|
if (record4.baselineImage !== void 0 && !isSafeProjectRelativePng(record4.baselineImage)) {
|
|
3221
4858
|
throw invalidScenario(scenarioPath, `'${objectPath}.baselineImage' must be a project-relative .png path without '..' or absolute segments, received ${describeValue(record4.baselineImage)}.`);
|
|
@@ -3239,7 +4876,7 @@ function describeValue(value) {
|
|
|
3239
4876
|
return `${typeof value} ${JSON.stringify(value) ?? String(value)}`;
|
|
3240
4877
|
}
|
|
3241
4878
|
function requireRecord(value, scenarioPath, objectPath) {
|
|
3242
|
-
if (!
|
|
4879
|
+
if (!isRecord3(value)) {
|
|
3243
4880
|
throw invalidScenario(scenarioPath, `'${objectPath}' must be an object, received ${describeValue(value)}.`);
|
|
3244
4881
|
}
|
|
3245
4882
|
return value;
|
|
@@ -3290,6 +4927,14 @@ function optionalNumber(value, key, scenarioPath, objectPath) {
|
|
|
3290
4927
|
}
|
|
3291
4928
|
return raw;
|
|
3292
4929
|
}
|
|
4930
|
+
function optionalRatio(value, key, scenarioPath, objectPath) {
|
|
4931
|
+
const raw = value[key];
|
|
4932
|
+
if (raw === void 0) return void 0;
|
|
4933
|
+
if (typeof raw !== "number" || !Number.isFinite(raw) || raw < 0 || raw > 1) {
|
|
4934
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.${key}' must be a finite number between 0 and 1, received ${describeValue(raw)}.`);
|
|
4935
|
+
}
|
|
4936
|
+
return raw;
|
|
4937
|
+
}
|
|
3293
4938
|
function optionalNonNegativeNumber(value, key, scenarioPath, objectPath) {
|
|
3294
4939
|
const raw = value[key];
|
|
3295
4940
|
if (raw === void 0) return void 0;
|
|
@@ -3371,12 +5016,81 @@ function validatePerformanceAssertion(value, scenarioPath, objectPath) {
|
|
|
3371
5016
|
...present("minFps", optionalNonNegativeNumber(record4, "minFps", scenarioPath, objectPath))
|
|
3372
5017
|
};
|
|
3373
5018
|
}
|
|
5019
|
+
function validateParityAssertion(value, scenarioPath, objectPath) {
|
|
5020
|
+
const record4 = requireRecord(value, scenarioPath, objectPath);
|
|
5021
|
+
rejectUnknownKeys(record4, ["minFpsRatio", "minRenderParity", "reference", "referenceReport", "referenceSide"], scenarioPath, objectPath);
|
|
5022
|
+
const minFpsRatio = optionalNumber(record4, "minFpsRatio", scenarioPath, objectPath);
|
|
5023
|
+
if (minFpsRatio === void 0 || minFpsRatio <= 0) {
|
|
5024
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.minFpsRatio' must be a positive number (Tier 2's Floor is 0.85).`);
|
|
5025
|
+
}
|
|
5026
|
+
const minRenderParity = optionalNumber(record4, "minRenderParity", scenarioPath, objectPath);
|
|
5027
|
+
if (minRenderParity !== void 0 && minRenderParity <= 0) {
|
|
5028
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.minRenderParity' must be a positive number when present.`);
|
|
5029
|
+
}
|
|
5030
|
+
const referenceReport = record4.referenceReport;
|
|
5031
|
+
if (typeof referenceReport !== "string" || referenceReport.trim() === "") {
|
|
5032
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.referenceReport' must name the other half's saved run report.`);
|
|
5033
|
+
}
|
|
5034
|
+
const referenceSide = record4.referenceSide;
|
|
5035
|
+
if (referenceSide !== "browser" && referenceSide !== "native") {
|
|
5036
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.referenceSide' must be 'browser' or 'native' \u2014 the directed native \xF7 web ratio needs to know which side the reference is.`);
|
|
5037
|
+
}
|
|
5038
|
+
const reference = record4.reference === void 0 ? void 0 : requireRecord(record4.reference, scenarioPath, `${objectPath}.reference`);
|
|
5039
|
+
const referenceFps = reference === void 0 ? void 0 : optionalNumber(reference, "fps", scenarioPath, `${objectPath}.reference`);
|
|
5040
|
+
if (referenceFps !== void 0 && referenceFps <= 0) {
|
|
5041
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.reference.fps' must be a positive number.`);
|
|
5042
|
+
}
|
|
5043
|
+
const referenceRenderP95 = reference === void 0 ? void 0 : optionalNumber(reference, "renderP95", scenarioPath, `${objectPath}.reference`);
|
|
5044
|
+
if (referenceRenderP95 !== void 0 && referenceRenderP95 <= 0) {
|
|
5045
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.reference.renderP95' must be a positive number.`);
|
|
5046
|
+
}
|
|
5047
|
+
const referenceSerial = reference?.serial;
|
|
5048
|
+
if (referenceSerial !== void 0 && typeof referenceSerial !== "string") {
|
|
5049
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.reference.serial' must be a string when present.`);
|
|
5050
|
+
}
|
|
5051
|
+
const referenceThermal = reference?.thermallyConfounded;
|
|
5052
|
+
if (referenceThermal !== void 0 && typeof referenceThermal !== "boolean") {
|
|
5053
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.reference.thermallyConfounded' must be a boolean when present.`);
|
|
5054
|
+
}
|
|
5055
|
+
return {
|
|
5056
|
+
minFpsRatio,
|
|
5057
|
+
...minRenderParity === void 0 ? {} : { minRenderParity },
|
|
5058
|
+
referenceReport,
|
|
5059
|
+
referenceSide,
|
|
5060
|
+
...reference === void 0 || referenceFps === void 0 ? {} : {
|
|
5061
|
+
reference: {
|
|
5062
|
+
fps: referenceFps,
|
|
5063
|
+
...referenceRenderP95 === void 0 ? {} : { renderP95: referenceRenderP95 },
|
|
5064
|
+
...typeof referenceSerial === "string" ? { serial: referenceSerial } : {},
|
|
5065
|
+
...typeof referenceThermal === "boolean" ? { thermallyConfounded: referenceThermal } : {}
|
|
5066
|
+
}
|
|
5067
|
+
}
|
|
5068
|
+
};
|
|
5069
|
+
}
|
|
3374
5070
|
function validateRenderChainAssertion(value, scenarioPath, objectPath) {
|
|
3375
5071
|
const record4 = requireRecord(value, scenarioPath, objectPath);
|
|
3376
5072
|
const tier = record4.tier;
|
|
3377
5073
|
if (tier !== void 0 && tier !== "high" && tier !== "medium" && tier !== "low" && tier !== "off") {
|
|
3378
5074
|
throw invalidScenario(scenarioPath, `'${objectPath}.tier' must be high, medium, low, or off, received ${describeValue(tier)}.`);
|
|
3379
5075
|
}
|
|
5076
|
+
const stagesValue = record4.stages === void 0 ? void 0 : requireRecord(record4.stages, scenarioPath, `${objectPath}.stages`);
|
|
5077
|
+
const stages = stagesValue === void 0 ? void 0 : {
|
|
5078
|
+
...stagesValue.includes === void 0 ? {} : { includes: renderChainStageIds(stagesValue, "includes", scenarioPath, `${objectPath}.stages`) },
|
|
5079
|
+
...stagesValue.excludes === void 0 ? {} : { excludes: renderChainStageIds(stagesValue, "excludes", scenarioPath, `${objectPath}.stages`) },
|
|
5080
|
+
...stagesValue.order === void 0 ? {} : { order: renderChainStageIds(stagesValue, "order", scenarioPath, `${objectPath}.stages`) }
|
|
5081
|
+
};
|
|
5082
|
+
if (stages !== void 0 && Object.keys(stages).length === 0) {
|
|
5083
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.stages' must assert includes, excludes, or order.`);
|
|
5084
|
+
}
|
|
5085
|
+
const contributionsValue = record4.contributions === void 0 ? void 0 : requireRecord(record4.contributions, scenarioPath, `${objectPath}.contributions`);
|
|
5086
|
+
const contributions = contributionsValue === void 0 ? void 0 : {
|
|
5087
|
+
graphOutputChanged: renderChainStageIds(
|
|
5088
|
+
contributionsValue,
|
|
5089
|
+
"graphOutputChanged",
|
|
5090
|
+
scenarioPath,
|
|
5091
|
+
`${objectPath}.contributions`
|
|
5092
|
+
)
|
|
5093
|
+
};
|
|
3380
5094
|
const velocityValue = record4.velocity;
|
|
3381
5095
|
const velocity = velocityValue === void 0 ? void 0 : requireRecord(velocityValue, scenarioPath, `${objectPath}.velocity`);
|
|
3382
5096
|
if (velocity !== void 0) {
|
|
@@ -3386,13 +5100,52 @@ function validateRenderChainAssertion(value, scenarioPath, objectPath) {
|
|
|
3386
5100
|
}
|
|
3387
5101
|
return {
|
|
3388
5102
|
...tier === void 0 ? {} : { tier },
|
|
5103
|
+
...stages === void 0 ? {} : { stages },
|
|
5104
|
+
...contributions === void 0 ? {} : { contributions },
|
|
3389
5105
|
velocity: { maxRejectionFraction }
|
|
3390
5106
|
};
|
|
3391
5107
|
}
|
|
3392
|
-
if (tier === void 0) {
|
|
3393
|
-
throw invalidScenario(scenarioPath, `'${objectPath}' must assert tier or velocity.maxRejectionFraction; an empty render-chain assertion observes nothing.`);
|
|
5108
|
+
if (tier === void 0 && stages === void 0 && contributions === void 0) {
|
|
5109
|
+
throw invalidScenario(scenarioPath, `'${objectPath}' must assert tier, stages, contributions, or velocity.maxRejectionFraction; an empty render-chain assertion observes nothing.`);
|
|
5110
|
+
}
|
|
5111
|
+
return {
|
|
5112
|
+
...tier === void 0 ? {} : { tier },
|
|
5113
|
+
...stages === void 0 ? {} : { stages },
|
|
5114
|
+
...contributions === void 0 ? {} : { contributions }
|
|
5115
|
+
};
|
|
5116
|
+
}
|
|
5117
|
+
function renderChainStageIds(record4, key, scenarioPath, objectPath) {
|
|
5118
|
+
const values = requireArray(record4, key, scenarioPath, objectPath);
|
|
5119
|
+
if (values.length === 0) {
|
|
5120
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.${key}' must contain at least one stage id.`);
|
|
5121
|
+
}
|
|
5122
|
+
const ids = values.map((value, index) => {
|
|
5123
|
+
if (typeof value !== "string" || value.trim() === "") {
|
|
5124
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.${key}[${String(index)}]' must be a non-empty stage id.`);
|
|
5125
|
+
}
|
|
5126
|
+
return value;
|
|
5127
|
+
});
|
|
5128
|
+
if (new Set(ids).size !== ids.length) {
|
|
5129
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.${key}' must not repeat a stage id.`);
|
|
5130
|
+
}
|
|
5131
|
+
return ids;
|
|
5132
|
+
}
|
|
5133
|
+
var STARTUP_CEILINGS = ["maxEnteredMs", "maxCompileSettledMs", "maxReadyMs"];
|
|
5134
|
+
function validateStartupAssertion(value, scenarioPath, objectPath) {
|
|
5135
|
+
const record4 = requireRecord(value, scenarioPath, objectPath);
|
|
5136
|
+
const result = {};
|
|
5137
|
+
for (const key of STARTUP_CEILINGS) {
|
|
5138
|
+
const ceiling = record4[key];
|
|
5139
|
+
if (ceiling === void 0) continue;
|
|
5140
|
+
if (typeof ceiling !== "number" || !Number.isFinite(ceiling) || ceiling <= 0) {
|
|
5141
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.${key}' must be a positive finite number of milliseconds, received ${describeValue(ceiling)}.`);
|
|
5142
|
+
}
|
|
5143
|
+
result[key] = ceiling;
|
|
5144
|
+
}
|
|
5145
|
+
if (Object.keys(result).length === 0) {
|
|
5146
|
+
throw invalidScenario(scenarioPath, `'${objectPath}' must set at least one of ${STARTUP_CEILINGS.join(", ")}; an empty startup assertion observes nothing.`);
|
|
3394
5147
|
}
|
|
3395
|
-
return
|
|
5148
|
+
return result;
|
|
3396
5149
|
}
|
|
3397
5150
|
function validatePhaseBudget(value, scenarioPath, objectPath) {
|
|
3398
5151
|
if (value === void 0) return void 0;
|
|
@@ -3506,16 +5259,138 @@ function validateSignalAssertion(value, scenarioPath, objectPath) {
|
|
|
3506
5259
|
name: requireString(record4, "name", scenarioPath, objectPath)
|
|
3507
5260
|
};
|
|
3508
5261
|
}
|
|
5262
|
+
var SCENE_FLAGS = ["cameraClearsScene", "fogClearsScene", "litMaterialsAreLit"];
|
|
5263
|
+
function validateSceneAssertion(value, scenarioPath, objectPath) {
|
|
5264
|
+
const record4 = requireRecord(value, scenarioPath, objectPath);
|
|
5265
|
+
rejectUnknownKeys(record4, ["allowTrivial", ...SCENE_FLAGS, "minVisibleLights"], scenarioPath, objectPath);
|
|
5266
|
+
const result = {
|
|
5267
|
+
...present("allowTrivial", optionalTrivialityReason(record4, "allowTrivial", scenarioPath, objectPath)),
|
|
5268
|
+
...present("cameraClearsScene", optionalBoolean(record4, "cameraClearsScene", scenarioPath, objectPath)),
|
|
5269
|
+
...present("fogClearsScene", optionalBoolean(record4, "fogClearsScene", scenarioPath, objectPath)),
|
|
5270
|
+
...present("litMaterialsAreLit", optionalBoolean(record4, "litMaterialsAreLit", scenarioPath, objectPath)),
|
|
5271
|
+
...present("minVisibleLights", optionalNonNegativeInteger(record4, "minVisibleLights", scenarioPath, objectPath))
|
|
5272
|
+
};
|
|
5273
|
+
if (SCENE_FLAGS.every((flag) => result[flag] === void 0) && result.minVisibleLights === void 0) {
|
|
5274
|
+
throw invalidScenario(
|
|
5275
|
+
scenarioPath,
|
|
5276
|
+
`'${objectPath}' must set at least one of ${[...SCENE_FLAGS, "minVisibleLights"].join(", ")}; an empty scene assertion observes nothing.`
|
|
5277
|
+
);
|
|
5278
|
+
}
|
|
5279
|
+
return result;
|
|
5280
|
+
}
|
|
5281
|
+
var SCENE_NODE_SELECTOR_KEYS = ["limit", "name", "nameContains", "pathContains", "type"];
|
|
5282
|
+
var SCENE_NODE_BOUNDS = ["animated", "inFrustum", "maxCount", "minCount", "minTriangles", "texturesLoaded", "visible"];
|
|
5283
|
+
function validateEffectSpec(value, scenarioPath, objectPath) {
|
|
5284
|
+
const record4 = requireRecord(value, scenarioPath, objectPath);
|
|
5285
|
+
rejectUnknownKeys(record4, ["becomes", "path"], scenarioPath, objectPath);
|
|
5286
|
+
const becomes = record4.becomes;
|
|
5287
|
+
if (typeof becomes !== "string" && typeof becomes !== "number" && typeof becomes !== "boolean")
|
|
5288
|
+
throw invalidScenario(
|
|
5289
|
+
scenarioPath,
|
|
5290
|
+
`'${objectPath}.becomes' must be a string, number or boolean; ${describeValue(becomes)} names no value a transition can reach.`
|
|
5291
|
+
);
|
|
5292
|
+
if (typeof becomes === "number" && !Number.isFinite(becomes))
|
|
5293
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.becomes' must be a finite number.`);
|
|
5294
|
+
return { becomes, path: requireString(record4, "path", scenarioPath, objectPath) };
|
|
5295
|
+
}
|
|
5296
|
+
function validateCauseSpec(value, scenarioPath, objectPath) {
|
|
5297
|
+
const record4 = requireRecord(value, scenarioPath, objectPath);
|
|
5298
|
+
rejectUnknownKeys(record4, ["contact", "transition"], scenarioPath, objectPath);
|
|
5299
|
+
const hasContact = hasKey(record4, "contact");
|
|
5300
|
+
const hasTransition = hasKey(record4, "transition");
|
|
5301
|
+
if (hasContact === hasTransition)
|
|
5302
|
+
throw invalidScenario(
|
|
5303
|
+
scenarioPath,
|
|
5304
|
+
`'${objectPath}' must set exactly one of contact, transition.`
|
|
5305
|
+
);
|
|
5306
|
+
if (hasTransition)
|
|
5307
|
+
return { transition: validateEffectSpec(record4.transition, scenarioPath, `${objectPath}.transition`) };
|
|
5308
|
+
const contact = requireRecord(record4.contact, scenarioPath, `${objectPath}.contact`);
|
|
5309
|
+
rejectUnknownKeys(contact, ["entity", "kind", "with"], scenarioPath, `${objectPath}.contact`);
|
|
5310
|
+
return {
|
|
5311
|
+
contact: {
|
|
5312
|
+
entity: requireString(contact, "entity", scenarioPath, `${objectPath}.contact`),
|
|
5313
|
+
...present("kind", optionalString(contact, "kind", scenarioPath, `${objectPath}.contact`)),
|
|
5314
|
+
with: requireString(contact, "with", scenarioPath, `${objectPath}.contact`)
|
|
5315
|
+
}
|
|
5316
|
+
};
|
|
5317
|
+
}
|
|
5318
|
+
function validateCausedByAssertion(value, scenarioPath, objectPath) {
|
|
5319
|
+
const record4 = requireRecord(value, scenarioPath, objectPath);
|
|
5320
|
+
rejectUnknownKeys(record4, ["allowTrivial", "cause", "effect", "neverBefore", "withinTicks"], scenarioPath, objectPath);
|
|
5321
|
+
if (!hasKey(record4, "cause") || !hasKey(record4, "effect"))
|
|
5322
|
+
throw invalidScenario(scenarioPath, `'${objectPath}' must set both 'cause' and 'effect'.`);
|
|
5323
|
+
const result = {
|
|
5324
|
+
...present("allowTrivial", optionalTrivialityReason(record4, "allowTrivial", scenarioPath, objectPath)),
|
|
5325
|
+
cause: validateCauseSpec(record4.cause, scenarioPath, `${objectPath}.cause`),
|
|
5326
|
+
effect: validateEffectSpec(record4.effect, scenarioPath, `${objectPath}.effect`),
|
|
5327
|
+
...present("neverBefore", optionalBoolean(record4, "neverBefore", scenarioPath, objectPath)),
|
|
5328
|
+
...present("withinTicks", optionalNonNegativeInteger(record4, "withinTicks", scenarioPath, objectPath))
|
|
5329
|
+
};
|
|
5330
|
+
if (result.neverBefore === void 0 && result.withinTicks === void 0)
|
|
5331
|
+
throw invalidScenario(
|
|
5332
|
+
scenarioPath,
|
|
5333
|
+
`'${objectPath}' must set neverBefore or withinTicks; without one it asserts only that both events happened, which assert.states and assert.contacts already do separately.`
|
|
5334
|
+
);
|
|
5335
|
+
return result;
|
|
5336
|
+
}
|
|
5337
|
+
function validateSceneNodeSelector(value, scenarioPath, objectPath) {
|
|
5338
|
+
const record4 = requireRecord(value, scenarioPath, objectPath);
|
|
5339
|
+
rejectUnknownKeys(record4, [...SCENE_NODE_SELECTOR_KEYS], scenarioPath, objectPath);
|
|
5340
|
+
const result = {
|
|
5341
|
+
...present("limit", optionalPositiveInteger(record4, "limit", scenarioPath, objectPath)),
|
|
5342
|
+
...present("name", optionalString(record4, "name", scenarioPath, objectPath)),
|
|
5343
|
+
...present("nameContains", optionalString(record4, "nameContains", scenarioPath, objectPath)),
|
|
5344
|
+
...present("pathContains", optionalString(record4, "pathContains", scenarioPath, objectPath)),
|
|
5345
|
+
...present("type", optionalString(record4, "type", scenarioPath, objectPath))
|
|
5346
|
+
};
|
|
5347
|
+
if (result.name === void 0 && result.nameContains === void 0 && result.pathContains === void 0 && result.type === void 0)
|
|
5348
|
+
throw invalidScenario(
|
|
5349
|
+
scenarioPath,
|
|
5350
|
+
`'${objectPath}' must set at least one of name, nameContains, pathContains, type; a selector that filters nothing selects the whole scene.`
|
|
5351
|
+
);
|
|
5352
|
+
return result;
|
|
5353
|
+
}
|
|
5354
|
+
function validateSceneNodesAssertion(value, scenarioPath, objectPath) {
|
|
5355
|
+
const record4 = requireRecord(value, scenarioPath, objectPath);
|
|
5356
|
+
rejectUnknownKeys(record4, ["allowTrivial", "select", ...SCENE_NODE_BOUNDS], scenarioPath, objectPath);
|
|
5357
|
+
if (!hasKey(record4, "select"))
|
|
5358
|
+
throw invalidScenario(scenarioPath, `'${objectPath}' must set 'select'; an assertion with no selector observes nothing.`);
|
|
5359
|
+
const result = {
|
|
5360
|
+
...present("allowTrivial", optionalTrivialityReason(record4, "allowTrivial", scenarioPath, objectPath)),
|
|
5361
|
+
...present("animated", optionalBoolean(record4, "animated", scenarioPath, objectPath)),
|
|
5362
|
+
...present("inFrustum", optionalBoolean(record4, "inFrustum", scenarioPath, objectPath)),
|
|
5363
|
+
...present("maxCount", optionalNonNegativeInteger(record4, "maxCount", scenarioPath, objectPath)),
|
|
5364
|
+
...present("minCount", optionalNonNegativeInteger(record4, "minCount", scenarioPath, objectPath)),
|
|
5365
|
+
...present("minTriangles", optionalNonNegativeInteger(record4, "minTriangles", scenarioPath, objectPath)),
|
|
5366
|
+
select: validateSceneNodeSelector(record4.select, scenarioPath, `${objectPath}.select`),
|
|
5367
|
+
...present("texturesLoaded", optionalBoolean(record4, "texturesLoaded", scenarioPath, objectPath)),
|
|
5368
|
+
...present("visible", optionalBoolean(record4, "visible", scenarioPath, objectPath))
|
|
5369
|
+
};
|
|
5370
|
+
if (result.minCount !== void 0 && result.maxCount !== void 0 && result.minCount > result.maxCount)
|
|
5371
|
+
throw invalidScenario(
|
|
5372
|
+
scenarioPath,
|
|
5373
|
+
`'${objectPath}' sets minCount ${result.minCount} above maxCount ${result.maxCount}; no run can satisfy it.`
|
|
5374
|
+
);
|
|
5375
|
+
if (SCENE_NODE_BOUNDS.every((bound) => result[bound] === void 0))
|
|
5376
|
+
throw invalidScenario(
|
|
5377
|
+
scenarioPath,
|
|
5378
|
+
`'${objectPath}' must set at least one of ${SCENE_NODE_BOUNDS.join(", ")}; selecting nodes without bounding them observes nothing.`
|
|
5379
|
+
);
|
|
5380
|
+
return result;
|
|
5381
|
+
}
|
|
3509
5382
|
function validateAnimationAssertion(value, scenarioPath, objectPath) {
|
|
3510
5383
|
const record4 = requireRecord(value, scenarioPath, objectPath);
|
|
3511
|
-
rejectUnknownKeys(record4, ["advancedFrames", "allowTrivial", "clip", "entered", "entity", "finished"], scenarioPath, objectPath);
|
|
5384
|
+
rejectUnknownKeys(record4, ["advancedFrames", "allowTrivial", "clip", "entered", "entity", "finished", "maxFootSlide", "strideSynced"], scenarioPath, objectPath);
|
|
3512
5385
|
return {
|
|
3513
5386
|
...present("advancedFrames", optionalNumber(record4, "advancedFrames", scenarioPath, objectPath)),
|
|
3514
5387
|
...present("allowTrivial", optionalTrivialityReason(record4, "allowTrivial", scenarioPath, objectPath)),
|
|
3515
5388
|
...present("clip", optionalString(record4, "clip", scenarioPath, objectPath)),
|
|
3516
5389
|
...present("entered", optionalBoolean(record4, "entered", scenarioPath, objectPath)),
|
|
3517
5390
|
...present("entity", optionalString(record4, "entity", scenarioPath, objectPath)),
|
|
3518
|
-
...present("finished", optionalBoolean(record4, "finished", scenarioPath, objectPath))
|
|
5391
|
+
...present("finished", optionalBoolean(record4, "finished", scenarioPath, objectPath)),
|
|
5392
|
+
...present("maxFootSlide", optionalNumber(record4, "maxFootSlide", scenarioPath, objectPath)),
|
|
5393
|
+
...present("strideSynced", optionalBoolean(record4, "strideSynced", scenarioPath, objectPath))
|
|
3519
5394
|
};
|
|
3520
5395
|
}
|
|
3521
5396
|
function validateVisibilityAssertion(value, scenarioPath, objectPath) {
|
|
@@ -3550,7 +5425,8 @@ function validatePathAssertion(value, scenarioPath, objectPath) {
|
|
|
3550
5425
|
...present("lte", lte),
|
|
3551
5426
|
...present("path", optionalString(record4, "path", scenarioPath, objectPath)),
|
|
3552
5427
|
...present("textIncludes", optionalString(record4, "textIncludes", scenarioPath, objectPath)),
|
|
3553
|
-
...present("throughoutSteps", optionalBoolean(record4, "throughoutSteps", scenarioPath, objectPath))
|
|
5428
|
+
...present("throughoutSteps", optionalBoolean(record4, "throughoutSteps", scenarioPath, objectPath)),
|
|
5429
|
+
...present("visible", optionalBoolean(record4, "visible", scenarioPath, objectPath))
|
|
3554
5430
|
};
|
|
3555
5431
|
}
|
|
3556
5432
|
function validateResourcePathAssertion(value, scenarioPath, objectPath) {
|
|
@@ -3630,33 +5506,23 @@ function validateNumberTuple(value, length) {
|
|
|
3630
5506
|
}
|
|
3631
5507
|
return value;
|
|
3632
5508
|
}
|
|
3633
|
-
function
|
|
5509
|
+
function isRecord3(value) {
|
|
3634
5510
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3635
5511
|
}
|
|
3636
5512
|
function hasKey(value, key) {
|
|
3637
5513
|
return Object.prototype.hasOwnProperty.call(value, key);
|
|
3638
5514
|
}
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
"number in [0, 180]": (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= 180,
|
|
3645
|
-
"positive integer": (value) => typeof value === "number" && Number.isInteger(value) && value > 0,
|
|
3646
|
-
"positive number": (value) => typeof value === "number" && Number.isFinite(value) && value > 0,
|
|
3647
|
-
"string": isNonEmptyString,
|
|
3648
|
-
"triviality reason": isTrivialityReason
|
|
3649
|
-
};
|
|
3650
|
-
function isNonEmptyString(value) {
|
|
3651
|
-
return typeof value === "string" && value.trim() !== "";
|
|
3652
|
-
}
|
|
3653
|
-
function isTrivialityReason(value) {
|
|
3654
|
-
return typeof value === "string" && value.replace(/\s/gu, "").length >= MIN_TRIVIALITY_REASON_LENGTH;
|
|
3655
|
-
}
|
|
3656
|
-
function rejectWrongTypedFields(fields, value, scenarioPath, objectPath) {
|
|
5515
|
+
function rejectWrongTypedFields(kind, fields, value, scenarioPath, objectPath) {
|
|
5516
|
+
const validators = GENERATED_ASSERTION_FIELD_VALIDATORS[kind];
|
|
5517
|
+
if (validators === void 0) {
|
|
5518
|
+
throw new Error(`Generated assertion validators are missing registry kind '${kind}'.`);
|
|
5519
|
+
}
|
|
3657
5520
|
for (const field of fields) {
|
|
3658
|
-
|
|
3659
|
-
|
|
5521
|
+
if (value[field.name] === void 0) continue;
|
|
5522
|
+
const check = validators[field.name];
|
|
5523
|
+
if (check === void 0) {
|
|
5524
|
+
throw new Error(`Generated assertion validator is missing '${kind}.${field.name}'.`);
|
|
5525
|
+
}
|
|
3660
5526
|
if (!check(value[field.name])) {
|
|
3661
5527
|
const expectedType = field.type === "triviality reason" ? `a string with at least ${MIN_TRIVIALITY_REASON_LENGTH} non-whitespace characters` : field.type;
|
|
3662
5528
|
throw invalidScenario(
|
|
@@ -3674,14 +5540,14 @@ function validateAssertionKeys(value, scenarioPath) {
|
|
|
3674
5540
|
}
|
|
3675
5541
|
const items = Array.isArray(assertionValue) ? assertionValue : [assertionValue];
|
|
3676
5542
|
items.forEach((item, index) => {
|
|
3677
|
-
if (!
|
|
5543
|
+
if (!isRecord3(item)) {
|
|
3678
5544
|
return;
|
|
3679
5545
|
}
|
|
3680
5546
|
const suffix = Array.isArray(assertionValue) ? `[${index}]` : "";
|
|
3681
5547
|
rejectUnknownKeys(item, entry.fields.map((field) => field.name), scenarioPath, `assert.${entry.kind}${suffix}`);
|
|
3682
5548
|
const pathAssertionWithId = (entry.kind === "hud" || entry.kind === "resources") && typeof item.id === "string";
|
|
3683
5549
|
const fields = pathAssertionWithId ? entry.fields.filter((field) => !NUMERIC_COMPARISON_KEYS.includes(field.name)) : entry.fields;
|
|
3684
|
-
rejectWrongTypedFields(fields, item, scenarioPath, `assert.${entry.kind}${suffix}`);
|
|
5550
|
+
rejectWrongTypedFields(entry.kind, fields, item, scenarioPath, `assert.${entry.kind}${suffix}`);
|
|
3685
5551
|
validateNestedAssertionKeys(entry.kind, item, scenarioPath, suffix);
|
|
3686
5552
|
});
|
|
3687
5553
|
}
|
|
@@ -3689,7 +5555,7 @@ function validateAssertionKeys(value, scenarioPath) {
|
|
|
3689
5555
|
function validateNestedAssertionKeys(kind, value, scenarioPath, suffix) {
|
|
3690
5556
|
if (kind === "movement") {
|
|
3691
5557
|
for (const field of ["minAxisDelta", "minResolvedAxisDelta"]) {
|
|
3692
|
-
if (
|
|
5558
|
+
if (isRecord3(value[field])) {
|
|
3693
5559
|
rejectUnknownKeys(value[field], ["axis", "min"], scenarioPath, `assert.${kind}${suffix}.${field}`);
|
|
3694
5560
|
}
|
|
3695
5561
|
}
|
|
@@ -3701,7 +5567,7 @@ function validateNestedAssertionKeys(kind, value, scenarioPath, suffix) {
|
|
|
3701
5567
|
}
|
|
3702
5568
|
if (Array.isArray(value.atSteps)) {
|
|
3703
5569
|
value.atSteps.forEach((step, index) => {
|
|
3704
|
-
if (
|
|
5570
|
+
if (isRecord3(step)) {
|
|
3705
5571
|
rejectUnknownKeys(step, kind === "components" ? ["equals", "label"] : ["equals", "label", "textIncludes"], scenarioPath, `assert.${kind}${suffix}.atSteps[${index}]`);
|
|
3706
5572
|
}
|
|
3707
5573
|
});
|
|
@@ -3711,10 +5577,13 @@ function validateNestedAssertionKeys(kind, value, scenarioPath, suffix) {
|
|
|
3711
5577
|
const fields = {
|
|
3712
5578
|
entityVisible: ["entity", "minProjectedPixels", "throughoutFrames"],
|
|
3713
5579
|
frameDiff: ["baselineImage", "maxChangedPixelRatio", "minChangedPixelRatio"],
|
|
3714
|
-
region: ["height", "maxLuminance", "minDarkPixelRatio", "minNonblankPixelRatio", "width", "x", "y"]
|
|
5580
|
+
region: ["element", "height", "maxDarkPixelRatio", "maxLuminance", "minDarkPixelRatio", "minNonblankPixelRatio", "width", "x", "y"]
|
|
3715
5581
|
};
|
|
3716
5582
|
for (const [field, keys] of Object.entries(fields)) {
|
|
3717
|
-
if (
|
|
5583
|
+
if (isRecord3(value[field])) {
|
|
5584
|
+
if (field === "region" && isRecord3(value[field].element)) {
|
|
5585
|
+
rejectUnknownKeys(value[field].element, ["id", "selector"], scenarioPath, `assert.${kind}${suffix}.${field}.element`);
|
|
5586
|
+
}
|
|
3718
5587
|
rejectUnknownKeys(value[field], keys, scenarioPath, `assert.${kind}${suffix}.${field}`);
|
|
3719
5588
|
}
|
|
3720
5589
|
}
|
|
@@ -3728,14 +5597,14 @@ function validateNestedAssertionKeys(kind, value, scenarioPath, suffix) {
|
|
|
3728
5597
|
const entries = value[field];
|
|
3729
5598
|
if (Array.isArray(entries)) {
|
|
3730
5599
|
entries.forEach((item, index) => {
|
|
3731
|
-
if (
|
|
5600
|
+
if (isRecord3(item)) {
|
|
3732
5601
|
rejectUnknownKeys(item, keys, scenarioPath, `assert.${kind}${suffix}.${field}[${index}]`);
|
|
3733
5602
|
}
|
|
3734
5603
|
});
|
|
3735
5604
|
}
|
|
3736
5605
|
}
|
|
3737
5606
|
}
|
|
3738
|
-
if (kind === "world" &&
|
|
5607
|
+
if (kind === "world" && isRecord3(value.runtime)) {
|
|
3739
5608
|
rejectUnknownKeys(
|
|
3740
5609
|
value.runtime,
|
|
3741
5610
|
["agent", "core", "portable", "randomState", "rapier", "step"],
|
|
@@ -3743,7 +5612,7 @@ function validateNestedAssertionKeys(kind, value, scenarioPath, suffix) {
|
|
|
3743
5612
|
`assert.${kind}${suffix}.runtime`
|
|
3744
5613
|
);
|
|
3745
5614
|
}
|
|
3746
|
-
if (kind === "renderChain" &&
|
|
5615
|
+
if (kind === "renderChain" && isRecord3(value.velocity)) {
|
|
3747
5616
|
rejectUnknownKeys(
|
|
3748
5617
|
value.velocity,
|
|
3749
5618
|
["maxRejectionFraction"],
|
|
@@ -3751,6 +5620,22 @@ function validateNestedAssertionKeys(kind, value, scenarioPath, suffix) {
|
|
|
3751
5620
|
`assert.${kind}${suffix}.velocity`
|
|
3752
5621
|
);
|
|
3753
5622
|
}
|
|
5623
|
+
if (kind === "renderChain" && isRecord3(value.contributions)) {
|
|
5624
|
+
rejectUnknownKeys(
|
|
5625
|
+
value.contributions,
|
|
5626
|
+
["graphOutputChanged"],
|
|
5627
|
+
scenarioPath,
|
|
5628
|
+
`assert.${kind}${suffix}.contributions`
|
|
5629
|
+
);
|
|
5630
|
+
}
|
|
5631
|
+
if (kind === "renderChain" && isRecord3(value.stages)) {
|
|
5632
|
+
rejectUnknownKeys(
|
|
5633
|
+
value.stages,
|
|
5634
|
+
["excludes", "includes", "order"],
|
|
5635
|
+
scenarioPath,
|
|
5636
|
+
`assert.${kind}${suffix}.stages`
|
|
5637
|
+
);
|
|
5638
|
+
}
|
|
3754
5639
|
}
|
|
3755
5640
|
|
|
3756
5641
|
// src/scenario/schema-validate.ts
|
|
@@ -3759,6 +5644,7 @@ var PLAYTEST_ROOT_KEYS = [
|
|
|
3759
5644
|
"artifacts",
|
|
3760
5645
|
"assert",
|
|
3761
5646
|
"awaitStartup",
|
|
5647
|
+
"bootFailure",
|
|
3762
5648
|
"inputDelivery",
|
|
3763
5649
|
"name",
|
|
3764
5650
|
"parity",
|
|
@@ -3771,7 +5657,7 @@ var PLAYTEST_ROOT_KEYS = [
|
|
|
3771
5657
|
"warmupFrames"
|
|
3772
5658
|
];
|
|
3773
5659
|
function validatePlaytestScenario(value, scenarioPath, absolutePath) {
|
|
3774
|
-
if (!
|
|
5660
|
+
if (!isRecord3(value)) {
|
|
3775
5661
|
throw invalidScenario(scenarioPath, "Scenario root must be a JSON object.");
|
|
3776
5662
|
}
|
|
3777
5663
|
rejectUnknownKeys(value, PLAYTEST_ROOT_KEYS, scenarioPath, "scenario root");
|
|
@@ -3788,15 +5674,21 @@ function validatePlaytestScenario(value, scenarioPath, absolutePath) {
|
|
|
3788
5674
|
if (value.awaitStartup !== void 0 && typeof value.awaitStartup !== "boolean") {
|
|
3789
5675
|
throw invalidScenario(scenarioPath, "Scenario awaitStartup must be a boolean when present.");
|
|
3790
5676
|
}
|
|
5677
|
+
if (value.bootFailure !== void 0 && value.bootFailure !== "renderer-no-adapter") {
|
|
5678
|
+
throw invalidScenario(scenarioPath, "Scenario bootFailure must be 'renderer-no-adapter' when present.");
|
|
5679
|
+
}
|
|
3791
5680
|
const target = value.target === void 0 ? "web" : value.target;
|
|
3792
5681
|
if (target !== "web" && target !== "desktop" && target !== "bevy") {
|
|
3793
5682
|
throw invalidScenario(scenarioPath, "Scenario target must be one of: web, desktop, bevy.");
|
|
3794
5683
|
}
|
|
5684
|
+
if (value.bootFailure !== void 0 && target !== "web") {
|
|
5685
|
+
throw invalidScenario(scenarioPath, "Scenario bootFailure is browser-only and requires target 'web'.");
|
|
5686
|
+
}
|
|
3795
5687
|
const inputDelivery = value.inputDelivery ?? "deterministic";
|
|
3796
5688
|
if (inputDelivery !== "deterministic" && inputDelivery !== "focused-dom") {
|
|
3797
5689
|
throw invalidScenario(scenarioPath, "Scenario inputDelivery must be deterministic or focused-dom.");
|
|
3798
5690
|
}
|
|
3799
|
-
if (value.assert !== void 0 && !
|
|
5691
|
+
if (value.assert !== void 0 && !isRecord3(value.assert)) {
|
|
3800
5692
|
throw invalidScenario(scenarioPath, "Scenario assert must be a JSON object keyed by supported assertion kinds.");
|
|
3801
5693
|
}
|
|
3802
5694
|
if (!Array.isArray(value.steps) || value.steps.length === 0) {
|
|
@@ -3807,18 +5699,19 @@ function validatePlaytestScenario(value, scenarioPath, absolutePath) {
|
|
|
3807
5699
|
if (steps.some(({ kind }) => kind === "aimAt") && subject === void 0) {
|
|
3808
5700
|
throw invalidScenario(scenarioPath, "A step with kind 'aimAt' aims the subject player start; declare scenario.subject or replace the step.");
|
|
3809
5701
|
}
|
|
3810
|
-
const assertions =
|
|
5702
|
+
const assertions = isRecord3(value.assert) ? validateAssertions(value.assert, scenarioPath) : void 0;
|
|
3811
5703
|
validateStepLabels(steps, assertions, scenarioPath);
|
|
3812
5704
|
return {
|
|
3813
5705
|
...typeof value.acceptanceId === "string" ? { acceptanceId: value.acceptanceId } : {},
|
|
3814
|
-
...
|
|
5706
|
+
...isRecord3(value.artifacts) ? { artifacts: validateArtifacts(value.artifacts, scenarioPath) } : {},
|
|
3815
5707
|
...assertions === void 0 ? {} : { assert: assertions },
|
|
3816
5708
|
...typeof value.awaitStartup === "boolean" ? { awaitStartup: value.awaitStartup } : {},
|
|
5709
|
+
...value.bootFailure === "renderer-no-adapter" ? { bootFailure: value.bootFailure } : {},
|
|
3817
5710
|
inputDelivery,
|
|
3818
5711
|
name,
|
|
3819
|
-
...
|
|
5712
|
+
...isRecord3(value.parity) ? { parity: validateParityConfig(value.parity, scenarioPath) } : {},
|
|
3820
5713
|
schemaVersion: 1,
|
|
3821
|
-
...
|
|
5714
|
+
...isRecord3(value.setup) ? { setup: validateSetup(value.setup, scenarioPath, subject) } : {},
|
|
3822
5715
|
...absolutePath === void 0 ? {} : { sourcePath: absolutePath },
|
|
3823
5716
|
steps,
|
|
3824
5717
|
...typeof value.subject === "string" ? { subject: value.subject } : {},
|
|
@@ -3854,11 +5747,11 @@ function validateParityConfig(value, scenarioPath) {
|
|
|
3854
5747
|
function validateParityCompare(value, scenarioPath = "scenario", objectPath = "parity") {
|
|
3855
5748
|
const animation = value.animation === void 0 ? void 0 : requireArray(value, "animation", scenarioPath, objectPath).map((item, index) => validateParityAnimation(item, scenarioPath, `${objectPath}.animation[${index}]`));
|
|
3856
5749
|
const resources = value.resources === void 0 ? void 0 : validateParityResourceIds(value.resources, scenarioPath, `${objectPath}.resources`);
|
|
3857
|
-
const movementDistance =
|
|
3858
|
-
const axisDelta =
|
|
5750
|
+
const movementDistance = isRecord3(value.movementDistance) && typeof value.movementDistance.maxDelta === "number" && Number.isFinite(value.movementDistance.maxDelta) ? { maxDelta: value.movementDistance.maxDelta } : void 0;
|
|
5751
|
+
const axisDelta = isRecord3(value.axisDelta) ? Object.fromEntries(Object.entries(value.axisDelta).filter(
|
|
3859
5752
|
(entry) => (entry[0] === "x" || entry[0] === "y" || entry[0] === "z") && typeof entry[1] === "number" && Number.isFinite(entry[1])
|
|
3860
5753
|
)) : void 0;
|
|
3861
|
-
const contacts =
|
|
5754
|
+
const contacts = isRecord3(value.contacts) && typeof value.contacts.minSharedCount === "number" && Number.isFinite(value.contacts.minSharedCount) ? { minSharedCount: value.contacts.minSharedCount } : void 0;
|
|
3862
5755
|
return {
|
|
3863
5756
|
...axisDelta !== void 0 && Object.keys(axisDelta).length > 0 ? { axisDelta } : {},
|
|
3864
5757
|
...animation === void 0 ? {} : { animation },
|
|
@@ -3911,7 +5804,7 @@ function validateSetup(value, scenarioPath, subject) {
|
|
|
3911
5804
|
}
|
|
3912
5805
|
const claimed = /* @__PURE__ */ new Map();
|
|
3913
5806
|
for (const [index, entity] of (Array.isArray(value.entities) ? value.entities : []).entries()) {
|
|
3914
|
-
if (
|
|
5807
|
+
if (isRecord3(entity) && typeof entity.entity === "string") {
|
|
3915
5808
|
claimed.set(entity.entity, `setup.entities[${index}]`);
|
|
3916
5809
|
}
|
|
3917
5810
|
}
|
|
@@ -4002,7 +5895,7 @@ function validatePoint(value, scenarioPath, objectPath, requirement) {
|
|
|
4002
5895
|
return { x, y, z };
|
|
4003
5896
|
}
|
|
4004
5897
|
function validateSetupResource(value, scenarioPath, index) {
|
|
4005
|
-
if (!
|
|
5898
|
+
if (!isRecord3(value) || typeof value.id !== "string" || value.id.length === 0) {
|
|
4006
5899
|
throw invalidScenario(scenarioPath, `Scenario setup.resources[${index}] must name a resource id.`);
|
|
4007
5900
|
}
|
|
4008
5901
|
rejectUnknownKeys(value, ["id", "path", "value"], scenarioPath, `setup.resources[${index}]`);
|
|
@@ -4019,7 +5912,7 @@ function validateSetupResource(value, scenarioPath, index) {
|
|
|
4019
5912
|
};
|
|
4020
5913
|
}
|
|
4021
5914
|
function validateSetupEntity(value, scenarioPath, index) {
|
|
4022
|
-
if (!
|
|
5915
|
+
if (!isRecord3(value) || typeof value.entity !== "string" || value.entity.length === 0) {
|
|
4023
5916
|
throw invalidScenario(scenarioPath, `Scenario setup.entities[${index}] must name an entity.`);
|
|
4024
5917
|
}
|
|
4025
5918
|
rejectUnknownKeys(value, ["entity", "position", "rotation", "scale"], scenarioPath, `setup.entities[${index}]`);
|
|
@@ -4050,40 +5943,74 @@ var PLAYTEST_STEP_KEYS = [
|
|
|
4050
5943
|
"release",
|
|
4051
5944
|
"screenshot",
|
|
4052
5945
|
"target",
|
|
5946
|
+
"timeoutMs",
|
|
4053
5947
|
"waitFrames",
|
|
5948
|
+
"waitForResource",
|
|
4054
5949
|
"waitTicks",
|
|
4055
5950
|
"wheel",
|
|
4056
5951
|
"window"
|
|
4057
5952
|
];
|
|
5953
|
+
var MAX_RESOURCE_WAIT_TIMEOUT_MS = 12e4;
|
|
4058
5954
|
function validateStep(value, scenarioPath, index) {
|
|
4059
|
-
if (!
|
|
5955
|
+
if (!isRecord3(value)) {
|
|
4060
5956
|
throw invalidStep(scenarioPath, `Scenario step ${index} must be a JSON object.`);
|
|
4061
5957
|
}
|
|
4062
5958
|
rejectUnknownKeys(value, PLAYTEST_STEP_KEYS, scenarioPath, `steps[${index}]`);
|
|
5959
|
+
const waitForResource = value.waitForResource === void 0 ? void 0 : validateResourceWait(value.waitForResource, scenarioPath, index);
|
|
5960
|
+
const timeoutMs = positiveInteger(value.timeoutMs);
|
|
5961
|
+
if (waitForResource === void 0) {
|
|
5962
|
+
if (value.timeoutMs !== void 0) {
|
|
5963
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} timeoutMs belongs to waitForResource.`);
|
|
5964
|
+
}
|
|
5965
|
+
} else {
|
|
5966
|
+
if (timeoutMs === void 0 || timeoutMs > MAX_RESOURCE_WAIT_TIMEOUT_MS) {
|
|
5967
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} timeoutMs must be a positive integer no greater than ${MAX_RESOURCE_WAIT_TIMEOUT_MS}.`);
|
|
5968
|
+
}
|
|
5969
|
+
for (const forbidden of [
|
|
5970
|
+
"at",
|
|
5971
|
+
"holdFrames",
|
|
5972
|
+
"holdTicks",
|
|
5973
|
+
"kind",
|
|
5974
|
+
"overlayMessage",
|
|
5975
|
+
"pitch",
|
|
5976
|
+
"pointerPosition",
|
|
5977
|
+
"pointers",
|
|
5978
|
+
"press",
|
|
5979
|
+
"target",
|
|
5980
|
+
"waitFrames",
|
|
5981
|
+
"waitTicks",
|
|
5982
|
+
"wheel",
|
|
5983
|
+
"window"
|
|
5984
|
+
]) {
|
|
5985
|
+
if (value[forbidden] !== void 0) {
|
|
5986
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} waitForResource cannot mix with ${forbidden}.`);
|
|
5987
|
+
}
|
|
5988
|
+
}
|
|
5989
|
+
}
|
|
4063
5990
|
const press = typeof value.press === "string" && value.press.length > 0 ? value.press : Array.isArray(value.press) && value.press.every((key) => typeof key === "string" && key.length > 0) && new Set(value.press).size === value.press.length ? [...value.press] : void 0;
|
|
4064
|
-
const overlayMessage =
|
|
5991
|
+
const overlayMessage = isRecord3(value.overlayMessage) && typeof value.overlayMessage.overlayId === "string" && value.overlayMessage.overlayId.length > 0 && typeof value.overlayMessage.type === "string" && value.overlayMessage.type.length > 0 ? {
|
|
4065
5992
|
overlayId: value.overlayMessage.overlayId,
|
|
4066
5993
|
payload: value.overlayMessage.payload ?? {},
|
|
4067
5994
|
type: value.overlayMessage.type
|
|
4068
5995
|
} : void 0;
|
|
4069
|
-
const pointerButtons =
|
|
4070
|
-
const pointerPosition =
|
|
5996
|
+
const pointerButtons = isRecord3(value.pointerPosition) && typeof value.pointerPosition.buttons === "number" && Number.isInteger(value.pointerPosition.buttons) && value.pointerPosition.buttons >= 0 ? value.pointerPosition.buttons : void 0;
|
|
5997
|
+
const pointerPosition = isRecord3(value.pointerPosition) && typeof value.pointerPosition.x === "number" && Number.isFinite(value.pointerPosition.x) && value.pointerPosition.x >= 0 && value.pointerPosition.x <= 1 && typeof value.pointerPosition.y === "number" && Number.isFinite(value.pointerPosition.y) && value.pointerPosition.y >= 0 && value.pointerPosition.y <= 1 && (value.pointerPosition.buttons === void 0 || pointerButtons !== void 0) ? {
|
|
4071
5998
|
...pointerButtons === void 0 ? {} : { buttons: pointerButtons },
|
|
4072
5999
|
x: value.pointerPosition.x,
|
|
4073
6000
|
y: value.pointerPosition.y
|
|
4074
6001
|
} : void 0;
|
|
4075
6002
|
const pointers = Array.isArray(value.pointers) ? value.pointers.map((pointer, pointerIndex) => validatePointer(pointer, scenarioPath, index, pointerIndex)) : void 0;
|
|
4076
|
-
const wheel =
|
|
6003
|
+
const wheel = isRecord3(value.wheel) && typeof value.wheel.deltaY === "number" && Number.isFinite(value.wheel.deltaY) && (value.wheel.deltaX === void 0 || typeof value.wheel.deltaX === "number" && Number.isFinite(value.wheel.deltaX)) ? {
|
|
4077
6004
|
...typeof value.wheel.deltaX === "number" ? { deltaX: value.wheel.deltaX } : {},
|
|
4078
6005
|
deltaY: value.wheel.deltaY
|
|
4079
6006
|
} : void 0;
|
|
4080
|
-
if (
|
|
6007
|
+
if (isRecord3(value.overlayMessage)) {
|
|
4081
6008
|
rejectUnknownKeys(value.overlayMessage, ["overlayId", "payload", "type"], scenarioPath, `steps[${index}].overlayMessage`);
|
|
4082
6009
|
}
|
|
4083
|
-
if (
|
|
6010
|
+
if (isRecord3(value.pointerPosition)) {
|
|
4084
6011
|
rejectUnknownKeys(value.pointerPosition, ["buttons", "x", "y"], scenarioPath, `steps[${index}].pointerPosition`);
|
|
4085
6012
|
}
|
|
4086
|
-
if (
|
|
6013
|
+
if (isRecord3(value.wheel)) {
|
|
4087
6014
|
rejectUnknownKeys(value.wheel, ["deltaX", "deltaY"], scenarioPath, `steps[${index}].wheel`);
|
|
4088
6015
|
}
|
|
4089
6016
|
if (pointers !== void 0 && new Set(pointers.map(({ id }) => id)).size !== pointers.length) {
|
|
@@ -4101,12 +6028,12 @@ function validateStep(value, scenarioPath, index) {
|
|
|
4101
6028
|
const target = validateAimTarget(value.target, scenarioPath, index);
|
|
4102
6029
|
const pitch = typeof value.pitch === "number" && Number.isFinite(value.pitch) ? value.pitch : void 0;
|
|
4103
6030
|
const screenshot = typeof value.screenshot === "string" && /^[A-Za-z0-9._-]+$/.test(value.screenshot) ? value.screenshot : void 0;
|
|
4104
|
-
const window =
|
|
6031
|
+
const window = isRecord3(value.window) && (value.window.operation === "minimize" || value.window.operation === "resize" || value.window.operation === "restore") && (value.window.operation !== "resize" || typeof value.window.width === "number" && Number.isFinite(value.window.width) && value.window.width >= 1 && typeof value.window.height === "number" && Number.isFinite(value.window.height) && value.window.height >= 1) ? {
|
|
4105
6032
|
operation: value.window.operation,
|
|
4106
6033
|
...typeof value.window.width === "number" ? { width: value.window.width } : {},
|
|
4107
6034
|
...typeof value.window.height === "number" ? { height: value.window.height } : {}
|
|
4108
6035
|
} : void 0;
|
|
4109
|
-
if (
|
|
6036
|
+
if (isRecord3(value.window)) {
|
|
4110
6037
|
rejectUnknownKeys(value.window, ["height", "operation", "width"], scenarioPath, `steps[${index}].window`);
|
|
4111
6038
|
}
|
|
4112
6039
|
if (kind !== "click" && (at !== void 0 || value.at !== void 0)) {
|
|
@@ -4175,7 +6102,7 @@ function validateStep(value, scenarioPath, index) {
|
|
|
4175
6102
|
if (value.window !== void 0 && window === void 0) {
|
|
4176
6103
|
throw invalidStep(scenarioPath, `Scenario step ${index} window must define minimize, restore, or resize with positive width and height.`);
|
|
4177
6104
|
}
|
|
4178
|
-
if (at === void 0 && press === void 0 && overlayMessage === void 0 && pointerPosition === void 0 && pointers === void 0 && wheel === void 0 && window === void 0 && waitFrames === void 0 && waitTicks === void 0 && target === void 0) {
|
|
6105
|
+
if (at === void 0 && press === void 0 && overlayMessage === void 0 && pointerPosition === void 0 && pointers === void 0 && wheel === void 0 && window === void 0 && waitFrames === void 0 && waitTicks === void 0 && target === void 0 && waitForResource === void 0) {
|
|
4179
6106
|
throw invalidStep(scenarioPath, `Scenario step ${index} must define click at, press, overlayMessage, pointerPosition, pointers, wheel, window, aimAt target, or waitFrames/waitTicks.`);
|
|
4180
6107
|
}
|
|
4181
6108
|
if (value.holdFrames !== void 0 && holdFrames === void 0) {
|
|
@@ -4213,14 +6140,49 @@ function validateStep(value, scenarioPath, index) {
|
|
|
4213
6140
|
release: typeof value.release === "boolean" ? value.release : true,
|
|
4214
6141
|
...target === void 0 ? {} : { target },
|
|
4215
6142
|
...screenshot === void 0 ? {} : { screenshot },
|
|
6143
|
+
...timeoutMs === void 0 ? {} : { timeoutMs },
|
|
4216
6144
|
...waitFrames === void 0 ? {} : { waitFrames },
|
|
6145
|
+
...waitForResource === void 0 ? {} : { waitForResource },
|
|
4217
6146
|
...waitTicks === void 0 ? {} : { waitTicks },
|
|
4218
6147
|
...wheel === void 0 ? {} : { wheel },
|
|
4219
6148
|
...window === void 0 ? {} : { window }
|
|
4220
6149
|
};
|
|
4221
6150
|
}
|
|
6151
|
+
function validateResourceWait(value, scenarioPath, index) {
|
|
6152
|
+
const objectPath = `steps[${index}].waitForResource`;
|
|
6153
|
+
if (!isRecord3(value)) {
|
|
6154
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} waitForResource must be an object.`);
|
|
6155
|
+
}
|
|
6156
|
+
rejectUnknownKeys(value, ["equals", "gte", "id", "lte", "path"], scenarioPath, objectPath);
|
|
6157
|
+
const hasEquals = hasKey(value, "equals");
|
|
6158
|
+
const hasGte = hasKey(value, "gte");
|
|
6159
|
+
const hasLte = hasKey(value, "lte");
|
|
6160
|
+
if (Number(hasEquals) + Number(hasGte) + Number(hasLte) !== 1) {
|
|
6161
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} waitForResource must define exactly one of equals, gte, or lte.`);
|
|
6162
|
+
}
|
|
6163
|
+
const gte = hasGte ? optionalNumber(value, "gte", scenarioPath, objectPath) : void 0;
|
|
6164
|
+
const lte = hasLte ? optionalNumber(value, "lte", scenarioPath, objectPath) : void 0;
|
|
6165
|
+
if (hasGte && gte === void 0) {
|
|
6166
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} waitForResource.gte must be a finite number.`);
|
|
6167
|
+
}
|
|
6168
|
+
if (hasLte && lte === void 0) {
|
|
6169
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} waitForResource.lte must be a finite number.`);
|
|
6170
|
+
}
|
|
6171
|
+
const id = requireString(value, "id", scenarioPath, objectPath);
|
|
6172
|
+
const path = requireString(value, "path", scenarioPath, objectPath);
|
|
6173
|
+
if (path.split(".").some((part) => part.length === 0)) {
|
|
6174
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} waitForResource.path must be a non-empty dot path.`);
|
|
6175
|
+
}
|
|
6176
|
+
return {
|
|
6177
|
+
...hasEquals ? { equals: value.equals } : {},
|
|
6178
|
+
...gte === void 0 ? {} : { gte },
|
|
6179
|
+
id,
|
|
6180
|
+
...lte === void 0 ? {} : { lte },
|
|
6181
|
+
path
|
|
6182
|
+
};
|
|
6183
|
+
}
|
|
4222
6184
|
function validateClickTarget(value, scenarioPath, index) {
|
|
4223
|
-
if (!
|
|
6185
|
+
if (!isRecord3(value)) return void 0;
|
|
4224
6186
|
if (typeof value.entity === "string") {
|
|
4225
6187
|
rejectUnknownKeys(value, ["entity"], scenarioPath, `steps[${index}].at`);
|
|
4226
6188
|
return value.entity.length === 0 ? void 0 : { entity: value.entity };
|
|
@@ -4232,7 +6194,7 @@ function validateClickTarget(value, scenarioPath, index) {
|
|
|
4232
6194
|
function validateAimTarget(value, scenarioPath, stepIndex) {
|
|
4233
6195
|
if (value === void 0) return void 0;
|
|
4234
6196
|
const objectPath = `steps[${stepIndex}].target`;
|
|
4235
|
-
if (!
|
|
6197
|
+
if (!isRecord3(value)) {
|
|
4236
6198
|
throw invalidStep(scenarioPath, `Scenario ${objectPath} must be an object, received ${describeValue(value)}.`);
|
|
4237
6199
|
}
|
|
4238
6200
|
if (value.entity !== void 0 && (value.x !== void 0 || value.z !== void 0)) {
|
|
@@ -4252,7 +6214,7 @@ function validateAimTarget(value, scenarioPath, stepIndex) {
|
|
|
4252
6214
|
}
|
|
4253
6215
|
function validatePointer(value, scenarioPath, stepIndex, pointerIndex) {
|
|
4254
6216
|
const path = `steps[${stepIndex}].pointers[${pointerIndex}]`;
|
|
4255
|
-
if (!
|
|
6217
|
+
if (!isRecord3(value)) throw invalidStep(scenarioPath, `${path} must be an object.`);
|
|
4256
6218
|
rejectUnknownKeys(value, ["buttons", "id", "x", "y"], scenarioPath, path);
|
|
4257
6219
|
if (!Number.isInteger(value.id) || value.id < 1) {
|
|
4258
6220
|
throw invalidStep(scenarioPath, `${path}.id must be a positive integer.`);
|
|
@@ -4336,24 +6298,27 @@ function validateAssertions(value, scenarioPath) {
|
|
|
4336
6298
|
if (Array.isArray(value.signals) && value.signals.length === 0) {
|
|
4337
6299
|
throw invalidScenario(scenarioPath, "Assertion 'assert.signals' must contain at least one signal assertion.");
|
|
4338
6300
|
}
|
|
4339
|
-
const movement =
|
|
4340
|
-
const camera =
|
|
6301
|
+
const movement = isRecord3(value.movement) ? value.movement : void 0;
|
|
6302
|
+
const camera = isRecord3(value.camera) ? value.camera : void 0;
|
|
4341
6303
|
if (camera !== void 0 && !(typeof camera.within === "number" && Number.isFinite(camera.within) || camera.targetInViewport === true)) {
|
|
4342
6304
|
throw invalidScenario(
|
|
4343
6305
|
scenarioPath,
|
|
4344
6306
|
"Assertion 'assert.camera' must declare 'within' or 'targetInViewport: true'; a camera assertion with neither passes without consulting any observation."
|
|
4345
6307
|
);
|
|
4346
6308
|
}
|
|
4347
|
-
const diagnostics =
|
|
4348
|
-
const performance =
|
|
6309
|
+
const diagnostics = isRecord3(value.diagnostics) ? value.diagnostics : void 0;
|
|
6310
|
+
const performance = isRecord3(value.performance) ? validatePerformanceAssertion(value.performance, scenarioPath, "assert.performance") : void 0;
|
|
4349
6311
|
const deviceMetrics = value.deviceMetrics === void 0 ? void 0 : validateDeviceMetricsAssertion(value.deviceMetrics, scenarioPath, "assert.deviceMetrics");
|
|
4350
|
-
const
|
|
6312
|
+
const parity = value.parity === void 0 ? void 0 : validateParityAssertion(value.parity, scenarioPath, "assert.parity");
|
|
6313
|
+
const framebufferCoverage = isRecord3(value.framebufferCoverage) ? validateFramebufferCoverageAssertion(
|
|
4351
6314
|
value.framebufferCoverage,
|
|
4352
6315
|
scenarioPath,
|
|
4353
6316
|
"assert.framebufferCoverage"
|
|
4354
6317
|
) : void 0;
|
|
4355
6318
|
const renderChain = value.renderChain === void 0 ? void 0 : validateRenderChainAssertion(value.renderChain, scenarioPath, "assert.renderChain");
|
|
4356
|
-
const
|
|
6319
|
+
const startup = value.startup === void 0 ? void 0 : validateStartupAssertion(value.startup, scenarioPath, "assert.startup");
|
|
6320
|
+
const scene = value.scene === void 0 ? void 0 : validateSceneAssertion(value.scene, scenarioPath, "assert.scene");
|
|
6321
|
+
const world = isRecord3(value.world) ? value.world : void 0;
|
|
4357
6322
|
const optOuts = [
|
|
4358
6323
|
["noConsoleErrors", "consoleErrorsOptOutReason"],
|
|
4359
6324
|
["noNetworkErrors", "networkErrorsOptOutReason"],
|
|
@@ -4400,24 +6365,33 @@ function validateAssertions(value, scenarioPath) {
|
|
|
4400
6365
|
} : {},
|
|
4401
6366
|
...performance === void 0 ? {} : { performance },
|
|
4402
6367
|
...renderChain === void 0 ? {} : { renderChain },
|
|
6368
|
+
...startup === void 0 ? {} : { startup },
|
|
6369
|
+
...scene === void 0 ? {} : { scene },
|
|
6370
|
+
...hasKey(value, "causedBy") ? {
|
|
6371
|
+
causedBy: requireArray(value, "causedBy", scenarioPath, "assert.causedBy").map((entry, index) => validateCausedByAssertion(entry, scenarioPath, `assert.causedBy[${index}]`))
|
|
6372
|
+
} : {},
|
|
6373
|
+
...hasKey(value, "sceneNodes") ? {
|
|
6374
|
+
sceneNodes: requireArray(value, "sceneNodes", scenarioPath, "assert.sceneNodes").map((entry, index) => validateSceneNodesAssertion(entry, scenarioPath, `assert.sceneNodes[${index}]`))
|
|
6375
|
+
} : {},
|
|
4403
6376
|
...deviceMetrics === void 0 ? {} : { deviceMetrics },
|
|
6377
|
+
...parity === void 0 ? {} : { parity },
|
|
4404
6378
|
...framebufferCoverage === void 0 ? {} : { framebufferCoverage },
|
|
4405
6379
|
...movement === void 0 ? {} : {
|
|
4406
6380
|
movement: {
|
|
4407
6381
|
...typeof movement.axis === "string" ? { axis: movement.axis } : {},
|
|
4408
|
-
...
|
|
6382
|
+
...isRecord3(movement.closesDistanceToPosition) && validateNumberTuple(movement.closesDistanceToPosition.position, 3) !== void 0 && typeof movement.closesDistanceToPosition.min === "number" && Number.isFinite(movement.closesDistanceToPosition.min) ? { closesDistanceToPosition: { position: validateNumberTuple(movement.closesDistanceToPosition.position, 3), min: movement.closesDistanceToPosition.min } } : {},
|
|
4409
6383
|
...typeof movement.entity === "string" ? { entity: movement.entity } : {},
|
|
4410
6384
|
...typeof movement.facesMovementWithinDegrees === "number" && Number.isFinite(movement.facesMovementWithinDegrees) ? { facesMovementWithinDegrees: movement.facesMovementWithinDegrees } : {},
|
|
4411
|
-
...
|
|
4412
|
-
...
|
|
6385
|
+
...isRecord3(movement.minAxisDelta) && typeof movement.minAxisDelta.axis === "string" && typeof movement.minAxisDelta.min === "number" && Number.isFinite(movement.minAxisDelta.min) ? { minAxisDelta: { axis: movement.minAxisDelta.axis, min: movement.minAxisDelta.min } } : {},
|
|
6386
|
+
...isRecord3(movement.minResolvedAxisDelta) && typeof movement.minResolvedAxisDelta.axis === "string" && typeof movement.minResolvedAxisDelta.min === "number" && Number.isFinite(movement.minResolvedAxisDelta.min) ? { minResolvedAxisDelta: { axis: movement.minResolvedAxisDelta.axis, min: movement.minResolvedAxisDelta.min } } : {},
|
|
4413
6387
|
...typeof movement.maxTiltDegrees === "number" && Number.isFinite(movement.maxTiltDegrees) && movement.maxTiltDegrees >= 0 && movement.maxTiltDegrees <= 180 ? { maxTiltDegrees: movement.maxTiltDegrees } : {},
|
|
4414
6388
|
...typeof movement.minDistance === "number" && Number.isFinite(movement.minDistance) ? { minDistance: movement.minDistance } : {},
|
|
4415
6389
|
...typeof movement.maxDistance === "number" && Number.isFinite(movement.maxDistance) && movement.maxDistance >= 0 ? { maxDistance: movement.maxDistance } : {},
|
|
4416
6390
|
...typeof movement.minVelocity === "number" && Number.isFinite(movement.minVelocity) ? { minVelocity: movement.minVelocity } : {},
|
|
4417
6391
|
...typeof movement.pathLength === "number" && Number.isFinite(movement.pathLength) && movement.pathLength >= 0 ? { pathLength: movement.pathLength } : {},
|
|
4418
|
-
...
|
|
4419
|
-
...
|
|
4420
|
-
...
|
|
6392
|
+
...isRecord3(movement.notFacing) && typeof movement.notFacing.entity === "string" && typeof movement.notFacing.minDegrees === "number" && Number.isFinite(movement.notFacing.minDegrees) ? { notFacing: { entity: movement.notFacing.entity, minDegrees: movement.notFacing.minDegrees } } : {},
|
|
6393
|
+
...isRecord3(movement.notFacingPosition) && validateNumberTuple(movement.notFacingPosition.position, 3) !== void 0 && typeof movement.notFacingPosition.minDegrees === "number" && Number.isFinite(movement.notFacingPosition.minDegrees) ? { notFacingPosition: { position: validateNumberTuple(movement.notFacingPosition.position, 3), minDegrees: movement.notFacingPosition.minDegrees } } : {},
|
|
6394
|
+
...isRecord3(movement.reachesPositionWithin) && validateNumberTuple(movement.reachesPositionWithin.position, 3) !== void 0 && typeof movement.reachesPositionWithin.maxDistance === "number" && Number.isFinite(movement.reachesPositionWithin.maxDistance) ? {
|
|
4421
6395
|
reachesPositionWithin: {
|
|
4422
6396
|
...typeof movement.reachesPositionWithin.atStep === "string" ? { atStep: movement.reachesPositionWithin.atStep } : {},
|
|
4423
6397
|
position: validateNumberTuple(movement.reachesPositionWithin.position, 3),
|
|
@@ -4433,7 +6407,7 @@ function validateAssertions(value, scenarioPath) {
|
|
|
4433
6407
|
(entry, index) => validateOverlayNodeAssertion(entry, scenarioPath, `assert.overlayNodes[${index}]`)
|
|
4434
6408
|
)
|
|
4435
6409
|
} : {},
|
|
4436
|
-
...
|
|
6410
|
+
...isRecord3(value.reachability) ? { reachability: validateReachabilityAssertion(value.reachability, scenarioPath) } : {},
|
|
4437
6411
|
...Array.isArray(value.resources) ? { resources: value.resources.map((item, index) => validateResourcePathAssertion(item, scenarioPath, `assert.resources[${index}]`)) } : {},
|
|
4438
6412
|
...Array.isArray(value.settled) ? {
|
|
4439
6413
|
settled: value.settled.map(
|
|
@@ -4562,7 +6536,7 @@ function validateAssertionShapes(value, scenarioPath) {
|
|
|
4562
6536
|
if (assertionValue === void 0) {
|
|
4563
6537
|
continue;
|
|
4564
6538
|
}
|
|
4565
|
-
const valid = entry.cardinality === "array" ? Array.isArray(assertionValue) :
|
|
6539
|
+
const valid = entry.cardinality === "array" ? Array.isArray(assertionValue) : isRecord3(assertionValue);
|
|
4566
6540
|
if (!valid) {
|
|
4567
6541
|
throw invalidScenario(
|
|
4568
6542
|
scenarioPath,
|
|
@@ -4645,7 +6619,76 @@ async function loadPlaytestScenario(projectPath, scenarioPath) {
|
|
|
4645
6619
|
});
|
|
4646
6620
|
}
|
|
4647
6621
|
const scenario = validatePlaytestScenario(parsed, scenarioPath, absolutePath);
|
|
4648
|
-
|
|
6622
|
+
const withReachability = await hydrateReachabilityArtifact(projectPath, scenario, scenarioPath);
|
|
6623
|
+
return hydrateParityReference(projectPath, withReachability, scenarioPath);
|
|
6624
|
+
}
|
|
6625
|
+
async function hydrateParityReference(projectPath, scenario, scenarioPath) {
|
|
6626
|
+
const assertion = scenario.assert?.parity;
|
|
6627
|
+
if (assertion === void 0 || assertion.reference !== void 0) return scenario;
|
|
6628
|
+
let parsed;
|
|
6629
|
+
try {
|
|
6630
|
+
parsed = JSON.parse(await readFile(resolve(projectPath, assertion.referenceReport), "utf8"));
|
|
6631
|
+
} catch {
|
|
6632
|
+
throw invalidScenario(
|
|
6633
|
+
scenarioPath,
|
|
6634
|
+
`Parity reference '${assertion.referenceReport}' could not be read as JSON. Run the other half of the pair first and save its report.`
|
|
6635
|
+
);
|
|
6636
|
+
}
|
|
6637
|
+
if (!isRecord3(parsed) || !isRecord3(parsed.observations) || !Array.isArray(parsed.observations.performanceSeries)) {
|
|
6638
|
+
throw invalidScenario(
|
|
6639
|
+
scenarioPath,
|
|
6640
|
+
`Parity reference '${assertion.referenceReport}' carries no observations.performanceSeries; a run report without a measured series is not a parity half.`
|
|
6641
|
+
);
|
|
6642
|
+
}
|
|
6643
|
+
const performanceSeries = parsed.observations.performanceSeries;
|
|
6644
|
+
if (performanceSeries.length === 0) {
|
|
6645
|
+
throw invalidScenario(
|
|
6646
|
+
scenarioPath,
|
|
6647
|
+
`Parity reference '${assertion.referenceReport}' has no valid frame-time samples; a parity half must have measured the render loop.`
|
|
6648
|
+
);
|
|
6649
|
+
}
|
|
6650
|
+
const frameTimes = [];
|
|
6651
|
+
for (const sample of performanceSeries) {
|
|
6652
|
+
if (!isRecord3(sample) || typeof sample.frameMs !== "number" || !Number.isFinite(sample.frameMs) || sample.frameMs <= 0) {
|
|
6653
|
+
throw invalidScenario(
|
|
6654
|
+
scenarioPath,
|
|
6655
|
+
`Parity reference '${assertion.referenceReport}' contains a malformed frame-time sample; every sample must carry a finite positive frameMs.`
|
|
6656
|
+
);
|
|
6657
|
+
}
|
|
6658
|
+
frameTimes.push(sample.frameMs);
|
|
6659
|
+
}
|
|
6660
|
+
const sorted = [...frameTimes].sort((left, right) => left - right);
|
|
6661
|
+
const medianFrameMs = sorted[Math.floor(sorted.length / 2)];
|
|
6662
|
+
if (medianFrameMs === void 0 || medianFrameMs <= 0) {
|
|
6663
|
+
throw invalidScenario(
|
|
6664
|
+
scenarioPath,
|
|
6665
|
+
`Parity reference '${assertion.referenceReport}' produced no median frame time; a parity half must have measured the render loop.`
|
|
6666
|
+
);
|
|
6667
|
+
}
|
|
6668
|
+
const fps = 1e3 / medianFrameMs;
|
|
6669
|
+
const renderTimes = performanceSeries.map((sample) => sample.phases?.render);
|
|
6670
|
+
const completeRenderTimes = renderTimes.every(
|
|
6671
|
+
(value) => typeof value === "number" && Number.isFinite(value) && value > 0
|
|
6672
|
+
) ? renderTimes : void 0;
|
|
6673
|
+
const deviceMetrics = isRecord3(parsed.observations.deviceMetrics) ? parsed.observations.deviceMetrics : void 0;
|
|
6674
|
+
const verdict = isRecord3(deviceMetrics?.verdict) ? deviceMetrics.verdict : void 0;
|
|
6675
|
+
return {
|
|
6676
|
+
...scenario,
|
|
6677
|
+
assert: {
|
|
6678
|
+
...scenario.assert,
|
|
6679
|
+
parity: {
|
|
6680
|
+
...assertion,
|
|
6681
|
+
reference: {
|
|
6682
|
+
fps,
|
|
6683
|
+
...completeRenderTimes === void 0 ? {} : {
|
|
6684
|
+
renderP95: [...completeRenderTimes].sort((left, right) => left - right)[Math.ceil(completeRenderTimes.length * 0.95) - 1]
|
|
6685
|
+
},
|
|
6686
|
+
...typeof deviceMetrics?.serial === "string" ? { serial: deviceMetrics.serial } : {},
|
|
6687
|
+
...typeof verdict?.thermallyConfounded === "boolean" ? { thermallyConfounded: verdict.thermallyConfounded } : {}
|
|
6688
|
+
}
|
|
6689
|
+
}
|
|
6690
|
+
}
|
|
6691
|
+
};
|
|
4649
6692
|
}
|
|
4650
6693
|
async function hydrateReachabilityArtifact(projectPath, scenario, scenarioPath) {
|
|
4651
6694
|
const assertion = scenario.assert?.reachability;
|
|
@@ -4666,8 +6709,8 @@ async function hydrateReachabilityArtifact(projectPath, scenario, scenarioPath)
|
|
|
4666
6709
|
};
|
|
4667
6710
|
}
|
|
4668
6711
|
function reachabilityEnvelope(value) {
|
|
4669
|
-
if (!
|
|
4670
|
-
const measurement =
|
|
6712
|
+
if (!isRecord3(value)) return void 0;
|
|
6713
|
+
const measurement = isRecord3(value.jump) ? value.jump : value;
|
|
4671
6714
|
return typeof measurement.maxRise === "number" && Number.isFinite(measurement.maxRise) && measurement.maxRise >= 0 && typeof measurement.forwardReach === "number" && Number.isFinite(measurement.forwardReach) && measurement.forwardReach >= 0 && typeof measurement.fallDistanceToGround === "number" && Number.isFinite(measurement.fallDistanceToGround) && measurement.fallDistanceToGround >= measurement.maxRise ? { fallDistanceToGround: measurement.fallDistanceToGround, forwardReach: measurement.forwardReach, maxRise: measurement.maxRise } : void 0;
|
|
4672
6715
|
}
|
|
4673
6716
|
|