@threenative/playtest 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -0
- package/dist/diagnostics-Ckm_5lrw.d.ts +549 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +3057 -0
- package/dist/protocol-CeC1lz_G.d.ts +130 -0
- package/dist/runner/cli.d.ts +20 -0
- package/dist/runner/cli.js +5219 -0
- package/dist/runner/index.d.ts +390 -0
- package/dist/runner/index.js +5081 -0
- package/dist/three/index.d.ts +65 -0
- package/dist/three/index.js +394 -0
- package/package.json +63 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,3057 @@
|
|
|
1
|
+
import { readFile } from 'fs/promises';
|
|
2
|
+
import { resolve } from 'path';
|
|
3
|
+
|
|
4
|
+
// src/capabilities.ts
|
|
5
|
+
var PLAYTEST_CAPABILITY_REGISTRY = [
|
|
6
|
+
capability("browser.canvas", "Samples canvas pixels and health."),
|
|
7
|
+
capability("browser.console", "Captures browser console and page errors."),
|
|
8
|
+
capability("browser.dom", "Reads bounded DOM observations."),
|
|
9
|
+
capability("browser.input", "Delivers keyboard and pointer input."),
|
|
10
|
+
capability("browser.network", "Captures failed browser requests."),
|
|
11
|
+
capability("browser.screenshot", "Captures viewport screenshots."),
|
|
12
|
+
capability("browser.trace", "Captures a bounded Playwright trace."),
|
|
13
|
+
capability("camera.observe", "Samples the active camera transform and projection."),
|
|
14
|
+
capability("entity.bounds", "Projects registered entity bounds into the viewport."),
|
|
15
|
+
capability("entity.observe", "Samples registered entity transforms and visibility."),
|
|
16
|
+
capability("entity.setup", "Applies bounded transforms to registered entities."),
|
|
17
|
+
capability("runtime.animation", "Samples application-owned animation state."),
|
|
18
|
+
capability("runtime.audio", "Samples application-owned audio runtime state."),
|
|
19
|
+
capability("runtime.components", "Samples registered JSON-safe component state."),
|
|
20
|
+
capability("runtime.contacts", "Samples bounded collision and trigger contacts."),
|
|
21
|
+
capability("runtime.diagnostics", "Samples application-owned runtime diagnostics."),
|
|
22
|
+
capability("runtime.events", "Drains bounded application event observations."),
|
|
23
|
+
capability("runtime.fixedStep", "Advances an application-owned deterministic tick."),
|
|
24
|
+
capability("runtime.physics", "Samples bounded application-owned physics observations."),
|
|
25
|
+
capability("runtime.resources", "Reads and writes registered JSON-safe application state."),
|
|
26
|
+
capability("runtime.state", "Samples application-owned state-machine state."),
|
|
27
|
+
capability("runtime.tags", "Samples bounded application-owned entity tags."),
|
|
28
|
+
capability("runtime.ui", "Samples registered JSON-safe UI and HUD state."),
|
|
29
|
+
capability("runtime.world", "Samples bounded runtime world metadata.")
|
|
30
|
+
];
|
|
31
|
+
var KNOWN_CAPABILITIES = new Set(PLAYTEST_CAPABILITY_REGISTRY.map(({ name }) => name));
|
|
32
|
+
function unknownPlaytestCapabilities(capabilities) {
|
|
33
|
+
return capabilities.filter((name) => !KNOWN_CAPABILITIES.has(name));
|
|
34
|
+
}
|
|
35
|
+
function missingPlaytestCapabilities(required, available) {
|
|
36
|
+
const availableSet = new Set(available);
|
|
37
|
+
return [...new Set(required)].filter((name) => !availableSet.has(name)).sort();
|
|
38
|
+
}
|
|
39
|
+
function capability(name, description) {
|
|
40
|
+
return { description, name, protocolVersion: 1 };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// src/assertions.ts
|
|
44
|
+
var PLAYTEST_ASSERTION_REGISTRY = [
|
|
45
|
+
{
|
|
46
|
+
description: "Checks every consecutive platform against a measured static movement-envelope fit; it does not simulate traversal, walls, ceilings, run-up, or air control.",
|
|
47
|
+
example: { reachability: { artifact: "artifacts/character-envelope/player.json", entities: ["platform.a", "platform.b"] } },
|
|
48
|
+
fields: [
|
|
49
|
+
{ description: "Project-relative character envelope artifact emitted by tn character envelope.", name: "artifact", required: true, type: "string" },
|
|
50
|
+
{ description: "Ordered platform entity ids forming the critical path.", name: "entities", required: true, type: "string[] (minimum 2)" }
|
|
51
|
+
],
|
|
52
|
+
cardinality: "object",
|
|
53
|
+
kind: "reachability",
|
|
54
|
+
observationPath: "entityTransforms",
|
|
55
|
+
requiredCapabilities: ["entity.observe"],
|
|
56
|
+
resultIdPrefix: "reachability.",
|
|
57
|
+
supportedOn: ["web", "desktop", "bevy"],
|
|
58
|
+
triviality: "not-applicable"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
description: "Proves aerodynamic force telemetry and signed control-surface delivery for a flight entity.",
|
|
62
|
+
example: { aerodynamics: [{ controls: [{ sign: "negative", surface: "elevator" }], entity: "aircraft", minForceSamples: 4 }] },
|
|
63
|
+
fields: [
|
|
64
|
+
{ description: "Aerodynamic entity id.", name: "entity", required: true, type: "string" },
|
|
65
|
+
{ description: "Minimum physics-debug samples containing finite aerodynamic force vectors.", name: "minForceSamples", type: "positive integer" },
|
|
66
|
+
{ description: "Signed surface values required in physics.aerodynamics.setInputs calls.", name: "controls", type: "Array<{ surface: string, sign: 'negative' | 'positive', minAbs?: number }>" },
|
|
67
|
+
{ description: "Signed net aerodynamic torque, optionally relative to another labeled step.", name: "torques", type: "Array<{ label: string, relativeToLabel?: string, axis: 'x' | 'y' | 'z', sign: 'negative' | 'positive', minAbs?: number }>" }
|
|
68
|
+
],
|
|
69
|
+
cardinality: "array",
|
|
70
|
+
kind: "aerodynamics",
|
|
71
|
+
observationPath: "physicsDebugSeries",
|
|
72
|
+
requiredCapabilities: ["runtime.fixedStep", "runtime.physics"],
|
|
73
|
+
resultIdPrefix: "aerodynamics.",
|
|
74
|
+
supportedOn: ["web", "desktop", "bevy"],
|
|
75
|
+
triviality: "not-applicable"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
description: "Proves screenshot change, populated regions, and sustained projected entity visibility.",
|
|
79
|
+
example: { visual: [{ frameDiff: { baselineImage: "artifacts/baseline.png", minChangedPixelRatio: 0.01 }, entityVisible: { entity: "board.e4", minProjectedPixels: 20, throughoutFrames: true } }] },
|
|
80
|
+
fields: [
|
|
81
|
+
{ description: "Before/after or baseline-image changed-pixel ratio bounds.", name: "frameDiff", type: "{ baselineImage?: project-relative PNG, minChangedPixelRatio?: number, maxChangedPixelRatio?: number }" },
|
|
82
|
+
{ description: "Pixel region that must remain populated and may require dark-pixel occupancy.", name: "region", type: "{ x: number, y: number, width: number, height: number, minNonblankPixelRatio?: number, minDarkPixelRatio?: number, maxLuminance?: number }" },
|
|
83
|
+
{ description: "Entity projected-pixel floor, optionally across all captured samples.", name: "entityVisible", type: "{ entity: string, minProjectedPixels: number, throughoutFrames?: boolean }" }
|
|
84
|
+
],
|
|
85
|
+
cardinality: "array",
|
|
86
|
+
kind: "visual",
|
|
87
|
+
observationPath: "visual",
|
|
88
|
+
requiredCapabilities: ["browser.screenshot"],
|
|
89
|
+
resultIdPrefix: "visual.",
|
|
90
|
+
supportedOn: ["web"],
|
|
91
|
+
triviality: "not-applicable"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
description: "Proves the subject moved, reached a minimum velocity, or changed rotation during held input.",
|
|
95
|
+
example: { movement: { entity: "player", minDistance: 0.5, minVelocity: 0.01, rotationChanged: true } },
|
|
96
|
+
fields: [
|
|
97
|
+
{ description: "Entity id to measure. Defaults to scenario subject.", name: "entity", type: "string" },
|
|
98
|
+
{ description: "Require distance to a fixed world position to decrease by at least min.", name: "closesDistanceToPosition", type: "{ position: [number, number, number], min: number }" },
|
|
99
|
+
{ description: "Maximum yaw error from resolved movement direction.", name: "facesMovementWithinDegrees", type: "number" },
|
|
100
|
+
{ description: "Expected movement axis: x, y, or z.", name: "axis", type: "string" },
|
|
101
|
+
{ description: "Minimum signed movement on a specific axis, for example { axis: '+y', min: 0.2 }.", name: "minAxisDelta", type: "{ axis: string, min: number }" },
|
|
102
|
+
{ description: "Minimum signed resolved character.move displacement on a specific axis, for example { axis: '+y', min: 0.2 }.", name: "minResolvedAxisDelta", type: "{ axis: string, min: number }" },
|
|
103
|
+
{ description: "Maximum final pitch/roll tilt from world up, in degrees; yaw is ignored.", name: "maxTiltDegrees", type: "number in [0, 180]" },
|
|
104
|
+
{ description: "Minimum distance moved over the scenario.", name: "minDistance", type: "number" },
|
|
105
|
+
{ description: "Maximum distance allowed; use for blocked-movement proof.", name: "maxDistance", type: "number" },
|
|
106
|
+
{ description: "Minimum distance per frame.", name: "minVelocity", type: "number" },
|
|
107
|
+
{ description: "Minimum accumulated path length; use with minDistance to catch movement that cancels out.", name: "pathLength", type: "number" },
|
|
108
|
+
{ description: "Require the final facing to differ from another entity by at least minDegrees.", name: "notFacing", type: "{ entity: string, minDegrees: number }" },
|
|
109
|
+
{ description: "Require the final facing to differ from a fixed world position by at least minDegrees.", name: "notFacingPosition", type: "{ position: [number, number, number], minDegrees: number }" },
|
|
110
|
+
{ description: "Require a resolved character position to come within maxDistance of a fixed world position, optionally within one labeled step.", name: "reachesPositionWithin", type: "{ position: [number, number, number], maxDistance: number, atStep?: string }" },
|
|
111
|
+
{ description: "Require any observed rotation delta.", name: "rotationChanged", type: "boolean" }
|
|
112
|
+
],
|
|
113
|
+
cardinality: "object",
|
|
114
|
+
kind: "movement",
|
|
115
|
+
observationPath: "runtimeObservations",
|
|
116
|
+
requiredCapabilities: ["entity.observe"],
|
|
117
|
+
resultIdPrefix: "movement.",
|
|
118
|
+
supportedOn: ["web", "desktop", "bevy"],
|
|
119
|
+
triviality: "not-applicable"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
description: "Proves a camera follows an entity or keeps a target in view.",
|
|
123
|
+
example: { camera: { entity: "camera.main", follows: "player", within: 10, targetInViewport: true } },
|
|
124
|
+
fields: [
|
|
125
|
+
{ description: "Camera entity id.", name: "entity", type: "string" },
|
|
126
|
+
{ description: "Entity the camera should follow.", name: "follows", type: "string" },
|
|
127
|
+
{ description: "Maximum allowed separation.", name: "within", type: "number" },
|
|
128
|
+
{ description: "Require the target to be visible in the viewport.", name: "targetInViewport", type: "boolean" }
|
|
129
|
+
],
|
|
130
|
+
cardinality: "object",
|
|
131
|
+
kind: "camera",
|
|
132
|
+
observationPath: "runtimeDiagnostics",
|
|
133
|
+
requiredCapabilities: ["camera.observe", "entity.observe"],
|
|
134
|
+
resultIdPrefix: "camera",
|
|
135
|
+
supportedOn: ["web", "desktop", "bevy"],
|
|
136
|
+
triviality: "not-applicable"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
description: "Proves a live entity component value after the scenario or at named steps.",
|
|
140
|
+
example: { components: [{ component: "Camera", entity: "camera.main", path: "fovY", equals: 22, changed: true }] },
|
|
141
|
+
fields: [
|
|
142
|
+
{ description: "Entity id carrying the component.", name: "entity", required: true, type: "string" },
|
|
143
|
+
{ description: "Component name as emitted in the runtime world.", name: "component", required: true, type: "string" },
|
|
144
|
+
{ description: "Optional dot path inside the component snapshot.", name: "path", type: "string" },
|
|
145
|
+
{ description: "Exact expected value.", name: "equals", type: "json" },
|
|
146
|
+
{ description: "Minimum numeric value.", name: "gte", type: "number" },
|
|
147
|
+
{ description: "Require before and after values to differ or remain equal.", name: "changed", type: "boolean" },
|
|
148
|
+
{ description: "Expected values at named scenario-step samples.", name: "atSteps", type: "Array<{ label: string, equals: json }>" },
|
|
149
|
+
{ description: "Visible opt-out for a held invariant whose initial value intentionally satisfies the assertion.", name: "allowTrivial", type: "boolean" }
|
|
150
|
+
],
|
|
151
|
+
cardinality: "array",
|
|
152
|
+
kind: "components",
|
|
153
|
+
observationPath: "components",
|
|
154
|
+
requiredCapabilities: ["runtime.components"],
|
|
155
|
+
resultIdPrefix: "component.",
|
|
156
|
+
supportedOn: ["web", "desktop", "bevy"],
|
|
157
|
+
triviality: "reject-initial-value"
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
description: "Proves resource state after the scenario through equals, gte, textIncludes, or changed checks.",
|
|
161
|
+
example: { resources: [{ id: "GameState", path: "score", gte: 1, changed: true }] },
|
|
162
|
+
fields: [
|
|
163
|
+
{ description: "Resource id.", name: "id", required: true, type: "string" },
|
|
164
|
+
{ description: "Optional dot path inside the resource snapshot.", name: "path", type: "string" },
|
|
165
|
+
{ description: "Exact expected value.", name: "equals", type: "json" },
|
|
166
|
+
{ description: "Minimum numeric value.", name: "gte", type: "number" },
|
|
167
|
+
{ description: "Substring expected in the observed value.", name: "textIncludes", type: "string" },
|
|
168
|
+
{ description: "Require before and after values to differ or remain equal.", name: "changed", type: "boolean" },
|
|
169
|
+
{ description: "Require the value assertion after every labeled scenario step.", name: "throughoutSteps", type: "boolean" },
|
|
170
|
+
{ description: "Expected values at named scenario-step samples.", name: "atSteps", type: "Array<{ label: string, equals?: json, textIncludes?: string }>" },
|
|
171
|
+
{ description: "Visible opt-out for a held invariant whose initial value intentionally satisfies the assertion.", name: "allowTrivial", type: "boolean" },
|
|
172
|
+
{ description: "Require at least one alternative path assertion on this resource id.", name: "anyOf", type: "Array<{ path: string, equals?: json, gte?: number, textIncludes?: string, changed?: boolean }>" }
|
|
173
|
+
],
|
|
174
|
+
cardinality: "array",
|
|
175
|
+
kind: "resources",
|
|
176
|
+
observationPath: "resources",
|
|
177
|
+
requiredCapabilities: ["runtime.resources"],
|
|
178
|
+
resultIdPrefix: "resource.",
|
|
179
|
+
supportedOn: ["web", "desktop", "bevy"],
|
|
180
|
+
triviality: "reject-initial-value"
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
description: "Proves the final count of entities carrying a bounded runtime tag.",
|
|
184
|
+
example: { tags: [{ tag: "coin", count: 10 }] },
|
|
185
|
+
fields: [
|
|
186
|
+
{ description: "Entity tag to count.", name: "tag", required: true, type: "string" },
|
|
187
|
+
{ description: "Exact expected entity count.", name: "count", type: "non-negative integer" },
|
|
188
|
+
{ description: "Minimum expected entity count.", name: "gte", type: "non-negative integer" }
|
|
189
|
+
],
|
|
190
|
+
cardinality: "array",
|
|
191
|
+
kind: "tags",
|
|
192
|
+
observationPath: "runtimeObservations",
|
|
193
|
+
requiredCapabilities: ["runtime.tags"],
|
|
194
|
+
resultIdPrefix: "tags.",
|
|
195
|
+
supportedOn: ["web", "desktop", "bevy"],
|
|
196
|
+
triviality: "not-applicable"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
description: "Proves a named Godot signal was emitted by the application during the run or at a labeled step.",
|
|
200
|
+
example: { signals: [{ name: "collected", entity: "player", minCount: 3, atStep: "last-coin" }] },
|
|
201
|
+
fields: [
|
|
202
|
+
{ description: "Retained step label to inspect instead of the full signal history.", name: "atStep", type: "string" },
|
|
203
|
+
{ description: "Entity id that emitted the signal.", name: "entity", type: "string" },
|
|
204
|
+
{ description: "Maximum number of matching signals; use zero to prove separation.", name: "maxCount", type: "non-negative integer" },
|
|
205
|
+
{ description: "Minimum number of matching signals.", name: "minCount", type: "non-negative integer" },
|
|
206
|
+
{ description: "Godot signal name emitted by the application.", name: "name", required: true, type: "string" }
|
|
207
|
+
],
|
|
208
|
+
cardinality: "array",
|
|
209
|
+
kind: "signals",
|
|
210
|
+
observationPath: "signals",
|
|
211
|
+
requiredCapabilities: ["runtime.events"],
|
|
212
|
+
resultIdPrefix: "signal.",
|
|
213
|
+
supportedOn: ["web", "desktop", "bevy"],
|
|
214
|
+
triviality: "not-applicable"
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
description: "Proves an entity's final runtime-owned state-machine state.",
|
|
218
|
+
example: { states: [{ entity: "guard", equals: "chase" }] },
|
|
219
|
+
fields: [
|
|
220
|
+
{ description: "Entity carrying the StateMachine component.", name: "entity", required: true, type: "string" },
|
|
221
|
+
{ description: "Expected current state name.", name: "equals", required: true, type: "string" }
|
|
222
|
+
],
|
|
223
|
+
cardinality: "array",
|
|
224
|
+
kind: "states",
|
|
225
|
+
observationPath: "runtimeObservations",
|
|
226
|
+
requiredCapabilities: ["runtime.state"],
|
|
227
|
+
resultIdPrefix: "states.",
|
|
228
|
+
supportedOn: ["web", "desktop", "bevy"],
|
|
229
|
+
triviality: "not-applicable"
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
description: "Proves retained UI/HUD text or values after the scenario.",
|
|
233
|
+
example: { hud: [{ id: "score-label", textIncludes: "Score" }] },
|
|
234
|
+
fields: [
|
|
235
|
+
{ description: "UI node id.", name: "id", required: true, type: "string" },
|
|
236
|
+
{ description: "Optional dot path inside the UI snapshot.", name: "path", type: "string" },
|
|
237
|
+
{ description: "Exact expected value.", name: "equals", type: "json" },
|
|
238
|
+
{ description: "Minimum numeric value.", name: "gte", type: "number" },
|
|
239
|
+
{ description: "Substring expected in the observed value.", name: "textIncludes", type: "string" },
|
|
240
|
+
{ description: "Require before and after values to differ or remain equal.", name: "changed", type: "boolean" },
|
|
241
|
+
{ description: "Visible opt-out for a held invariant whose initial value intentionally satisfies the assertion.", name: "allowTrivial", type: "boolean" }
|
|
242
|
+
],
|
|
243
|
+
cardinality: "array",
|
|
244
|
+
kind: "hud",
|
|
245
|
+
observationPath: "hud",
|
|
246
|
+
requiredCapabilities: ["runtime.ui"],
|
|
247
|
+
resultIdPrefix: "hud.",
|
|
248
|
+
supportedOn: ["web"],
|
|
249
|
+
triviality: "reject-initial-value"
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
description: "Proves DOM state inside a same-origin webview overlay iframe.",
|
|
253
|
+
example: { overlayNodes: [{ attribute: "data-aiming", equals: "true", overlayId: "game-ui", selector: "[data-testid=fps-crosshair]", visible: false }] },
|
|
254
|
+
fields: [
|
|
255
|
+
{ description: "Declared overlay id.", name: "overlayId", required: true, type: "string" },
|
|
256
|
+
{ description: "CSS selector inside the overlay document.", name: "selector", required: true, type: "string" },
|
|
257
|
+
{ description: "Optional attribute to read instead of text content.", name: "attribute", type: "string" },
|
|
258
|
+
{ description: "Exact expected attribute or text value.", name: "equals", type: "json" },
|
|
259
|
+
{ description: "Substring expected in text content.", name: "textIncludes", type: "string" },
|
|
260
|
+
{ description: "Expected computed visibility.", name: "visible", type: "boolean" }
|
|
261
|
+
],
|
|
262
|
+
cardinality: "array",
|
|
263
|
+
kind: "overlayNodes",
|
|
264
|
+
observationPath: "overlayNodes",
|
|
265
|
+
requiredCapabilities: ["browser.dom"],
|
|
266
|
+
resultIdPrefix: "overlayNode.",
|
|
267
|
+
supportedOn: ["web"],
|
|
268
|
+
triviality: "not-applicable"
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
description: "Proves console, network, runtime, and readiness diagnostics stayed clean.",
|
|
272
|
+
example: { diagnostics: { noConsoleErrors: true, noNetworkErrors: true, noRuntimeDiagnostics: true, runtimeReady: true } },
|
|
273
|
+
fields: [
|
|
274
|
+
{ description: "Fail on captured console errors.", name: "noConsoleErrors", type: "boolean" },
|
|
275
|
+
{ description: "Fail on captured network errors.", name: "noNetworkErrors", type: "boolean" },
|
|
276
|
+
{ description: "Fail on runtime diagnostics.", name: "noRuntimeDiagnostics", type: "boolean" },
|
|
277
|
+
{ description: "Required bounded justification when noRuntimeDiagnostics is false.", name: "runtimeDiagnosticsOptOutReason", type: "non-empty string" },
|
|
278
|
+
{ description: "Require runtime readiness.", name: "runtimeReady", type: "boolean" }
|
|
279
|
+
],
|
|
280
|
+
cardinality: "object",
|
|
281
|
+
kind: "diagnostics",
|
|
282
|
+
observationPath: "runtimeDiagnostics",
|
|
283
|
+
requiredCapabilities: ["browser.console", "browser.network", "runtime.diagnostics"],
|
|
284
|
+
resultIdPrefix: "diagnostics",
|
|
285
|
+
supportedOn: ["web"],
|
|
286
|
+
triviality: "not-applicable"
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
description: "Proves projected entity visibility in the viewport.",
|
|
290
|
+
example: { visibility: [{ entity: "player", minProjectedPixels: 1200, maxOffscreenRatio: 0.05 }] },
|
|
291
|
+
fields: [
|
|
292
|
+
{ description: "Entity id. Defaults to scenario subject.", name: "entity", type: "string" },
|
|
293
|
+
{ description: "Minimum projected pixel area.", name: "minProjectedPixels", type: "number" },
|
|
294
|
+
{ description: "Maximum allowed offscreen ratio.", name: "maxOffscreenRatio", type: "number" },
|
|
295
|
+
{ description: "Require the entity to be registered in the sampled scene.", name: "present", type: "boolean" }
|
|
296
|
+
],
|
|
297
|
+
cardinality: "array",
|
|
298
|
+
kind: "visibility",
|
|
299
|
+
observationPath: "runtimeDiagnostics",
|
|
300
|
+
requiredCapabilities: ["entity.bounds"],
|
|
301
|
+
resultIdPrefix: "visibility.",
|
|
302
|
+
supportedOn: ["web"],
|
|
303
|
+
triviality: "not-applicable"
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
description: "Proves runtime world metadata exposed by the application bridge.",
|
|
307
|
+
example: { world: { seed: 90210 } },
|
|
308
|
+
fields: [
|
|
309
|
+
{ description: "Expected configured deterministic seed, or null when unseeded.", name: "seed", required: true, type: "json" },
|
|
310
|
+
{ description: "Expected deterministic replay runtime fingerprint.", name: "runtime", type: "object" }
|
|
311
|
+
],
|
|
312
|
+
cardinality: "object",
|
|
313
|
+
kind: "world",
|
|
314
|
+
observationPath: "runtimeObservations",
|
|
315
|
+
requiredCapabilities: ["runtime.world"],
|
|
316
|
+
resultIdPrefix: "world.",
|
|
317
|
+
supportedOn: ["web", "desktop", "bevy"],
|
|
318
|
+
triviality: "not-applicable"
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
description: "Proves contact or trigger evidence appeared in the effect log.",
|
|
322
|
+
example: { contacts: [{ entity: "player", with: "pickup", kind: "trigger", minCount: 1 }] },
|
|
323
|
+
fields: [
|
|
324
|
+
{ description: "Retained step label to inspect instead of the full observation history.", name: "atStep", type: "string" },
|
|
325
|
+
{ description: "Entity id. Defaults to scenario subject.", name: "entity", type: "string" },
|
|
326
|
+
{ description: "Other entity or tag token expected in the contact evidence.", name: "with", type: "string" },
|
|
327
|
+
{ description: "Contact kind token, such as contact or trigger.", name: "kind", type: "string" },
|
|
328
|
+
{ description: "Minimum number of matching observations.", name: "minCount", type: "number" },
|
|
329
|
+
{ description: "Maximum number of matching observations; use zero to prove separation.", name: "maxCount", type: "non-negative integer" },
|
|
330
|
+
{ description: "Targets on which the contact assertion is required.", name: "requiredOn", type: "Array<'web' | 'desktop' | 'bevy'>" }
|
|
331
|
+
],
|
|
332
|
+
cardinality: "array",
|
|
333
|
+
kind: "contacts",
|
|
334
|
+
observationPath: "runtimeObservations",
|
|
335
|
+
requiredCapabilities: ["runtime.contacts"],
|
|
336
|
+
resultIdPrefix: "contact.",
|
|
337
|
+
supportedOn: ["web", "desktop", "bevy"],
|
|
338
|
+
triviality: "not-applicable"
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
description: "Proves matching physics bodies are asleep in a retained physics-debug sample.",
|
|
342
|
+
example: { settled: [{ atStep: "fall-and-settle", entity: "enemy.default/0/", minBodies: 15 }] },
|
|
343
|
+
fields: [
|
|
344
|
+
{ description: "Exact entity id or stable entity-id prefix.", name: "entity", required: true, type: "string" },
|
|
345
|
+
{ description: "Optional labeled step whose physics-debug sample must be used.", name: "atStep", type: "string" },
|
|
346
|
+
{ description: "Minimum number of matching bodies required.", name: "minBodies", type: "positive integer" },
|
|
347
|
+
{ description: "Optional earlier labeled step whose matching body positions are compared.", name: "compareToStep", type: "string" },
|
|
348
|
+
{ description: "Minimum mean body-position distance from compareToStep, in metres.", name: "minMeanPoseDistance", type: "positive number" },
|
|
349
|
+
{ description: "Targets on which the settled assertion is required.", name: "requiredOn", type: "Array<'web' | 'desktop' | 'bevy'>" }
|
|
350
|
+
],
|
|
351
|
+
cardinality: "array",
|
|
352
|
+
kind: "settled",
|
|
353
|
+
observationPath: "physicsDebugSeries",
|
|
354
|
+
triviality: "not-applicable",
|
|
355
|
+
requiredCapabilities: ["runtime.physics"],
|
|
356
|
+
resultIdPrefix: "settled.",
|
|
357
|
+
supportedOn: ["web", "desktop", "bevy"]
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
description: "Proves rendered scene geometry occludes the segment between an origin entity and target.",
|
|
361
|
+
example: { occluded: [{ entity: "listener", target: "emitter" }] },
|
|
362
|
+
fields: [
|
|
363
|
+
{ description: "Optional origin/listener entity token expected in the raycast request.", name: "entity", type: "string" },
|
|
364
|
+
{ description: "Optional target/emitter entity token expected in the raycast request.", name: "target", type: "string" }
|
|
365
|
+
],
|
|
366
|
+
cardinality: "array",
|
|
367
|
+
kind: "occluded",
|
|
368
|
+
observationPath: "effectLog",
|
|
369
|
+
requiredCapabilities: ["runtime.physics"],
|
|
370
|
+
resultIdPrefix: "occluded.",
|
|
371
|
+
supportedOn: ["web", "desktop", "bevy"],
|
|
372
|
+
triviality: "not-applicable"
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
description: "Proves animation evidence appeared in the effect log.",
|
|
376
|
+
example: { animation: [{ entity: "player", clip: "run", entered: true, advancedFrames: 5 }] },
|
|
377
|
+
fields: [
|
|
378
|
+
{ description: "Entity id. Defaults to scenario subject.", name: "entity", type: "string" },
|
|
379
|
+
{ description: "Animation clip id or name.", name: "clip", type: "string" },
|
|
380
|
+
{ description: "Require entering the animation state.", name: "entered", type: "boolean" },
|
|
381
|
+
{ description: "Require animation advancement evidence.", name: "advancedFrames", type: "number" }
|
|
382
|
+
],
|
|
383
|
+
cardinality: "array",
|
|
384
|
+
kind: "animation",
|
|
385
|
+
observationPath: "runtimeObservations",
|
|
386
|
+
requiredCapabilities: ["runtime.animation"],
|
|
387
|
+
resultIdPrefix: "animation.",
|
|
388
|
+
supportedOn: ["web", "desktop", "bevy"],
|
|
389
|
+
triviality: "not-applicable"
|
|
390
|
+
}
|
|
391
|
+
];
|
|
392
|
+
var PLAYTEST_SETUP_REGISTRY = [
|
|
393
|
+
{
|
|
394
|
+
description: "Applies bounded transforms to registered entities before input.",
|
|
395
|
+
kind: "entities",
|
|
396
|
+
requiredCapabilities: ["entity.setup"]
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
description: "Writes bounded JSON-safe application state before input.",
|
|
400
|
+
kind: "resources",
|
|
401
|
+
requiredCapabilities: ["runtime.resources"]
|
|
402
|
+
}
|
|
403
|
+
];
|
|
404
|
+
function requiredPlaytestCapabilities(scenario) {
|
|
405
|
+
const required = /* @__PURE__ */ new Set();
|
|
406
|
+
if (scenario.steps.some((step) => step.kind !== "wait" && (step.press !== void 0 || step.pointerPosition !== void 0))) {
|
|
407
|
+
required.add("browser.input");
|
|
408
|
+
}
|
|
409
|
+
if (scenario.artifacts?.screenshots !== false) {
|
|
410
|
+
required.add("browser.screenshot");
|
|
411
|
+
}
|
|
412
|
+
for (const entry of PLAYTEST_ASSERTION_REGISTRY) {
|
|
413
|
+
if (scenario.assert?.[entry.kind] !== void 0) {
|
|
414
|
+
if (entry.kind === "diagnostics") {
|
|
415
|
+
const policy = scenario.assert.diagnostics;
|
|
416
|
+
if (policy?.noConsoleErrors === true) required.add("browser.console");
|
|
417
|
+
if (policy?.noNetworkErrors === true) required.add("browser.network");
|
|
418
|
+
if (policy?.noRuntimeDiagnostics !== false) required.add("runtime.diagnostics");
|
|
419
|
+
} else {
|
|
420
|
+
entry.requiredCapabilities.forEach((capability2) => required.add(capability2));
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
for (const entry of PLAYTEST_SETUP_REGISTRY) {
|
|
425
|
+
if (scenario.setup?.[entry.kind] !== void 0) {
|
|
426
|
+
entry.requiredCapabilities.forEach((capability2) => required.add(capability2));
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
return [...required].sort();
|
|
430
|
+
}
|
|
431
|
+
function evaluateRichPlaytestAssertions(input) {
|
|
432
|
+
const assertions = [];
|
|
433
|
+
const diagnostics = [];
|
|
434
|
+
const scenarioAssertions = input.scenario.assert ?? {};
|
|
435
|
+
if (scenarioAssertions.reachability !== void 0) {
|
|
436
|
+
const { entities, envelope } = scenarioAssertions.reachability;
|
|
437
|
+
for (let index = 0; index < entities.length - 1; index += 1) {
|
|
438
|
+
const fromId = entities[index];
|
|
439
|
+
const toId = entities[index + 1];
|
|
440
|
+
const from = input.report.observations?.entityTransforms?.[fromId];
|
|
441
|
+
const to = input.report.observations?.entityTransforms?.[toId];
|
|
442
|
+
const rise = from?.position === void 0 || to?.position === void 0 ? void 0 : platformTop(to) - platformTop(from);
|
|
443
|
+
const horizontalDelta = from?.position === void 0 || to?.position === void 0 ? void 0 : [to.position[0] - from.position[0], to.position[2] - from.position[2]];
|
|
444
|
+
const centerGap = horizontalDelta === void 0 ? void 0 : Math.hypot(...horizontalDelta);
|
|
445
|
+
const direction = horizontalDelta === void 0 || centerGap === 0 ? void 0 : [horizontalDelta[0] / centerGap, horizontalDelta[1] / centerGap];
|
|
446
|
+
const edgeGap = centerGap === void 0 || direction === void 0 ? centerGap : Math.max(0, centerGap - horizontalRadius(from, direction) - horizontalRadius(to, direction));
|
|
447
|
+
const horizontalLimit = envelope === void 0 || rise === void 0 ? void 0 : movementEnvelopeHorizontalLimit(envelope, rise);
|
|
448
|
+
const pass = horizontalLimit !== void 0 && edgeGap !== void 0 && edgeGap <= horizontalLimit;
|
|
449
|
+
assertions.push({
|
|
450
|
+
details: { constraint: "static-movement-envelope-fit", edgeGap: edgeGap ?? null, envelope: envelope ?? null, from: fromId, horizontalLimit: horizontalLimit ?? null, rise: rise ?? null, to: toId },
|
|
451
|
+
id: `reachability.${index}.${fromId}.${toId}`,
|
|
452
|
+
pass
|
|
453
|
+
});
|
|
454
|
+
if (!pass) diagnostics.push({
|
|
455
|
+
code: "TN_PLAYTEST_REACHABILITY_ASSERTION_FAILED",
|
|
456
|
+
message: `Static platform fit '${fromId}' to '${toId}' is outside the measured character envelope.`,
|
|
457
|
+
path: `/assert/reachability/entities/${index + 1}`,
|
|
458
|
+
severity: "error",
|
|
459
|
+
...input.scenario.sourcePath === void 0 ? {} : { sourcePath: input.scenario.sourcePath },
|
|
460
|
+
suggestion: "Reduce the platform rise or edge-to-edge gap, regenerate the envelope after changing movement, then use a traversal playtest to prove walls, ceilings, run-up, and air control."
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
for (const assertion of scenarioAssertions.overlayNodes ?? []) {
|
|
465
|
+
const id = overlayNodeObservationKey(assertion.overlayId, assertion.selector);
|
|
466
|
+
if (input.scenario.target !== "web") {
|
|
467
|
+
assertions.push({ details: { reason: "target-unsupported", target: input.scenario.target }, id: `overlayNode.${id}`, pass: false });
|
|
468
|
+
diagnostics.push(assertionNotEvaluatedDiagnostic(`overlayNode.${id}`, `target '${input.scenario.target}' cannot evaluate same-origin overlay DOM state`));
|
|
469
|
+
continue;
|
|
470
|
+
}
|
|
471
|
+
const snapshot = input.report.observations?.overlayNodes?.[id]?.after;
|
|
472
|
+
const observed = isRecord(snapshot) ? snapshot : {};
|
|
473
|
+
const value = assertion.attribute === void 0 ? observed.text : observed.attribute;
|
|
474
|
+
const checks = [
|
|
475
|
+
...Object.hasOwn(assertion, "equals") ? [jsonEqual(value, assertion.equals)] : [],
|
|
476
|
+
...assertion.textIncludes === void 0 ? [] : [String(value ?? "").includes(assertion.textIncludes)],
|
|
477
|
+
...assertion.visible === void 0 ? [] : [observed.visible === assertion.visible]
|
|
478
|
+
];
|
|
479
|
+
const pass = checks.length > 0 && checks.every(Boolean);
|
|
480
|
+
assertions.push({ details: { expected: assertion, observed }, id: `overlayNode.${id}`, pass });
|
|
481
|
+
if (!pass) diagnostics.push({
|
|
482
|
+
code: "TN_PLAYTEST_OVERLAY_NODE_ASSERTION_FAILED",
|
|
483
|
+
message: `Overlay '${assertion.overlayId}' node '${assertion.selector}' did not satisfy the DOM assertion.`,
|
|
484
|
+
severity: "error",
|
|
485
|
+
suggestion: "Inspect observations.json/overlayNodes and verify the overlay subscription, selector, attribute, and computed style."
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
const hasVisualSamples = input.report.observations?.visual !== void 0;
|
|
489
|
+
if ((scenarioAssertions.visual?.length ?? 0) > 0 && !hasVisualSamples) {
|
|
490
|
+
for (const [index] of scenarioAssertions.visual.entries()) {
|
|
491
|
+
assertions.push({ id: `visual.${index}`, pass: false, details: { reason: "target-unsupported", target: input.scenario.target } });
|
|
492
|
+
diagnostics.push(assertionNotEvaluatedDiagnostic(`visual.${index}`, `target '${input.scenario.target}' does not expose visual assertion samples`));
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
for (const [index, visual] of (hasVisualSamples ? scenarioAssertions.visual ?? [] : []).entries()) {
|
|
496
|
+
if (visual.frameDiff !== void 0) {
|
|
497
|
+
const ratio = input.report.observations?.visual?.changedPixelRatio;
|
|
498
|
+
const pass = ratio !== void 0 && (visual.frameDiff.minChangedPixelRatio === void 0 || ratio >= visual.frameDiff.minChangedPixelRatio) && (visual.frameDiff.maxChangedPixelRatio === void 0 || ratio <= visual.frameDiff.maxChangedPixelRatio);
|
|
499
|
+
assertions.push({ id: `visual.${index}.frameDiff`, pass, details: { after: pass, changedPixelRatio: ratio, comparisonSource: input.report.observations?.visual?.comparisonSource, expected: { equals: true }, ...visual.frameDiff } });
|
|
500
|
+
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." });
|
|
501
|
+
}
|
|
502
|
+
if (visual.region !== void 0) {
|
|
503
|
+
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);
|
|
504
|
+
const minimum = visual.region.minNonblankPixelRatio ?? 2e-3;
|
|
505
|
+
const pass = observed !== void 0 && observed.nonblankPixelRatio >= minimum;
|
|
506
|
+
assertions.push({ id: `visual.${index}.region`, pass, details: { after: pass, expected: { equals: true }, minimum, observed: observed?.nonblankPixelRatio } });
|
|
507
|
+
if (!pass) diagnostics.push({ code: "TN_PLAYTEST_REGION_BLANK", message: `Screenshot region at (${visual.region.x}, ${visual.region.y}) did not meet nonblank ratio ${minimum}.`, severity: "error", suggestion: "Check camera framing and whether expected geometry renders in the asserted region." });
|
|
508
|
+
if (visual.region.minDarkPixelRatio !== void 0) {
|
|
509
|
+
const darkPass = observed?.darkPixelRatio !== void 0 && observed.darkPixelRatio >= visual.region.minDarkPixelRatio;
|
|
510
|
+
assertions.push({
|
|
511
|
+
id: `visual.${index}.region.darkPixels`,
|
|
512
|
+
pass: darkPass,
|
|
513
|
+
details: {
|
|
514
|
+
maximumLuminance: visual.region.maxLuminance ?? 0.25,
|
|
515
|
+
minimumDarkPixelRatio: visual.region.minDarkPixelRatio,
|
|
516
|
+
observedDarkPixelRatio: observed?.darkPixelRatio
|
|
517
|
+
}
|
|
518
|
+
});
|
|
519
|
+
if (!darkPass) diagnostics.push({
|
|
520
|
+
code: "TN_PLAYTEST_REGION_DARK_PIXEL_RATIO_FAILED",
|
|
521
|
+
message: `Screenshot region at (${visual.region.x}, ${visual.region.y}) contained ${observed?.darkPixelRatio ?? "unavailable"} dark pixels, below required ratio ${visual.region.minDarkPixelRatio}.`,
|
|
522
|
+
severity: "error",
|
|
523
|
+
suggestion: "Check whether the expected foreground silhouette occupies the asserted raster region."
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
if (visual.entityVisible !== void 0) {
|
|
528
|
+
const frameSeries = input.report.observations?.visual?.runtimeDiagnosticsSeries;
|
|
529
|
+
const samples = frameSeries ?? [input.report.observations?.runtimeDiagnostics];
|
|
530
|
+
const selected = visual.entityVisible.throughoutFrames === true ? samples : samples.slice(-1);
|
|
531
|
+
const projected = selected.map((sample) => projectedPixelsForEntity(runtimeDiagnosticsSnapshot(sample), visual.entityVisible.entity, input.scenario.viewport));
|
|
532
|
+
const hasRequiredSeries = visual.entityVisible.throughoutFrames !== true || frameSeries !== void 0 && frameSeries.length > 0;
|
|
533
|
+
const pass = hasRequiredSeries && projected.length > 0 && projected.every((pixels) => pixels !== void 0 && pixels >= visual.entityVisible.minProjectedPixels);
|
|
534
|
+
assertions.push({ id: `visual.${index}.entityVisible`, pass, details: { entity: visual.entityVisible.entity, hasRequiredSeries, projectedPixels: projected } });
|
|
535
|
+
if (!pass) diagnostics.push({ code: "TN_PLAYTEST_ENTITY_VISIBILITY_DROPPED", message: `Entity '${visual.entityVisible.entity}' dropped below ${visual.entityVisible.minProjectedPixels} projected pixels.`, severity: "error", suggestion: "Check per-frame visibility, camera clipping, scale, and renderer state." });
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
for (const assertion of scenarioAssertions.resources ?? []) {
|
|
539
|
+
if (assertion.anyOf !== void 0) {
|
|
540
|
+
const result = evaluateResourceAnyOfAssertion(assertion, input.report.observations?.resources[assertion.id], {
|
|
541
|
+
effectLog: input.report.effectLog ?? input.report.observations?.effectLog,
|
|
542
|
+
movedDistance: input.report.distance,
|
|
543
|
+
scenarioSourcePath: input.scenario.sourcePath
|
|
544
|
+
});
|
|
545
|
+
assertions.push(result.assertion);
|
|
546
|
+
if (result.diagnostic !== void 0) diagnostics.push(result.diagnostic);
|
|
547
|
+
continue;
|
|
548
|
+
}
|
|
549
|
+
if (hasFinalPathExpectation(assertion)) {
|
|
550
|
+
const result = evaluatePathAssertion("resource", assertion, input.report.observations?.resources[assertion.id], {
|
|
551
|
+
effectLog: input.report.effectLog ?? input.report.observations?.effectLog,
|
|
552
|
+
movedDistance: input.report.distance,
|
|
553
|
+
scenarioSourcePath: input.scenario.sourcePath
|
|
554
|
+
});
|
|
555
|
+
assertions.push(result.assertion);
|
|
556
|
+
if (result.diagnostic !== void 0) {
|
|
557
|
+
diagnostics.push({ ...result.diagnostic, code: result.diagnostic.code || "TN_PLAYTEST_RESOURCE_ASSERTION_FAILED" });
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
if (assertion.throughoutSteps === true) {
|
|
561
|
+
const samples = (input.report.observations?.resourceSeries ?? []).map((sample) => ({
|
|
562
|
+
label: sample.label,
|
|
563
|
+
value: readPath(sample.snapshots[assertion.id], assertion.path)
|
|
564
|
+
}));
|
|
565
|
+
const expectedSamples = input.scenario.steps.reduce((count, step) => count + (step.label === void 0 ? 0 : 1), 0);
|
|
566
|
+
const pass = expectedSamples > 0 && samples.length === expectedSamples && samples.every((sample) => pathValuePass(assertion, sample.value));
|
|
567
|
+
assertions.push({ details: { samples }, id: `resource.${assertion.id}.${assertion.path ?? "value"}.throughoutSteps`, pass });
|
|
568
|
+
if (!pass) diagnostics.push({
|
|
569
|
+
code: "TN_PLAYTEST_RESOURCE_TRANSITION_ASSERTION_FAILED",
|
|
570
|
+
message: `Resource '${assertion.id}'${assertion.path === void 0 ? "" : ` path '${assertion.path}'`} did not satisfy the assertion after every scenario step.`,
|
|
571
|
+
observedRuntimePath: "observations.json/resourceSeries",
|
|
572
|
+
severity: "error",
|
|
573
|
+
suggestion: "Inspect the labeled resource samples and fix the transient gameplay-state transition."
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
if ((assertion.atSteps?.length ?? 0) > 0) {
|
|
577
|
+
const samples = assertion.atSteps.map((expected) => {
|
|
578
|
+
const sample = (input.report.observations?.resourceSeries ?? []).find((candidate) => candidate.label === expected.label);
|
|
579
|
+
const value = readPath(sample?.snapshots[assertion.id], assertion.path);
|
|
580
|
+
const pass2 = sample !== void 0 && (!Object.hasOwn(expected, "equals") || jsonEqual(value, expected.equals)) && (expected.textIncludes === void 0 || String(textValue(value)).includes(expected.textIncludes));
|
|
581
|
+
return { expected, pass: pass2, value };
|
|
582
|
+
});
|
|
583
|
+
const pass = samples.every((sample) => sample.pass);
|
|
584
|
+
assertions.push({ details: { samples }, id: `resource.${assertion.id}.${assertion.path ?? "value"}.atSteps`, pass });
|
|
585
|
+
if (!pass) diagnostics.push({
|
|
586
|
+
code: "TN_PLAYTEST_RESOURCE_TRANSITION_ASSERTION_FAILED",
|
|
587
|
+
message: `Resource '${assertion.id}'${assertion.path === void 0 ? "" : ` path '${assertion.path}'`} did not match the expected labeled-step transition.`,
|
|
588
|
+
observedRuntimePath: "observations.json/resourceSeries",
|
|
589
|
+
severity: "error",
|
|
590
|
+
suggestion: "Inspect the failed and restored labeled samples and fix the retry transition."
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
for (const assertion of scenarioAssertions.signals ?? []) {
|
|
595
|
+
const series = input.report.observations?.signalSeries;
|
|
596
|
+
const selected = assertion.atStep === void 0 ? void 0 : series?.find((sample) => sample.label === assertion.atStep);
|
|
597
|
+
const drained = assertion.atStep === void 0 ? series !== void 0 && series.length > 0 : selected !== void 0;
|
|
598
|
+
const events = assertion.atStep === void 0 ? input.report.observations?.signals : selected?.signals;
|
|
599
|
+
const count = matchingSignals(events, assertion);
|
|
600
|
+
const minCount = assertion.minCount ?? (assertion.maxCount === void 0 ? 1 : 0);
|
|
601
|
+
const pass = drained && count >= minCount && (assertion.maxCount === void 0 || count <= assertion.maxCount);
|
|
602
|
+
assertions.push({
|
|
603
|
+
details: { atStep: assertion.atStep, count, entity: assertion.entity, maxCount: assertion.maxCount, minCount, name: assertion.name },
|
|
604
|
+
id: `signal.${assertion.name}`,
|
|
605
|
+
pass
|
|
606
|
+
});
|
|
607
|
+
if (!pass) diagnostics.push({
|
|
608
|
+
code: "TN_PLAYTEST_SIGNAL_NOT_OBSERVED",
|
|
609
|
+
message: !drained ? `Signal assertion '${assertion.name}' had no retained event drain${assertion.atStep === void 0 ? "" : ` at step '${assertion.atStep}'`}.` : `Expected signal '${assertion.name}'${assertion.entity === void 0 ? "" : ` from '${assertion.entity}'`} ${minCount} time(s), observed ${count}.`,
|
|
610
|
+
observedRuntimePath: "observations.json/signalSeries",
|
|
611
|
+
severity: "error",
|
|
612
|
+
suggestion: "Expose a bounded events callback on the playtest bridge and inspect the emitted signal name and entity."
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
if (scenarioAssertions.world !== void 0) {
|
|
616
|
+
const result = evaluateWorldAssertion(scenarioAssertions.world, input.report.observations?.runtimeObservations);
|
|
617
|
+
assertions.push(result.assertion);
|
|
618
|
+
if (result.diagnostic !== void 0) diagnostics.push(result.diagnostic);
|
|
619
|
+
}
|
|
620
|
+
for (const assertion of scenarioAssertions.components ?? []) {
|
|
621
|
+
const observed = input.report.observations?.components?.[assertion.entity]?.[assertion.component];
|
|
622
|
+
const before = readPath(observed?.before, assertion.path);
|
|
623
|
+
const after = readPath(observed?.after, assertion.path);
|
|
624
|
+
if (hasFinalComponentExpectation(assertion)) {
|
|
625
|
+
const valueChecks = [
|
|
626
|
+
...Object.hasOwn(assertion, "equals") ? [jsonEqual(after, assertion.equals)] : [],
|
|
627
|
+
...assertion.gte === void 0 ? [] : [typeof after === "number" && after >= assertion.gte]
|
|
628
|
+
];
|
|
629
|
+
const checks = [
|
|
630
|
+
...valueChecks,
|
|
631
|
+
// Same absent-value trap as evaluatePathAssertion: a component that was
|
|
632
|
+
// never observed must not satisfy "this value did not change".
|
|
633
|
+
...assertion.changed === void 0 ? [] : [(before !== void 0 || after !== void 0) && (assertion.changed ? !jsonEqual(before, after) : jsonEqual(before, after))]
|
|
634
|
+
];
|
|
635
|
+
const trivial = rejectsTrivialAssertion("components") && valueChecks.length > 0 && before !== void 0 && componentValueChecks(assertion, before).every(Boolean);
|
|
636
|
+
const pass = checks.length > 0 && checks.every(Boolean) && (!trivial || assertion.allowTrivial === true);
|
|
637
|
+
assertions.push({
|
|
638
|
+
details: {
|
|
639
|
+
after,
|
|
640
|
+
before,
|
|
641
|
+
component: assertion.component,
|
|
642
|
+
entity: assertion.entity,
|
|
643
|
+
expected: assertion,
|
|
644
|
+
trivial,
|
|
645
|
+
...trivial && assertion.allowTrivial === true ? { trivialityOptOut: true } : {}
|
|
646
|
+
},
|
|
647
|
+
id: `component.${assertion.entity}.${assertion.component}.${assertion.path ?? "value"}`,
|
|
648
|
+
pass
|
|
649
|
+
});
|
|
650
|
+
if (!pass) diagnostics.push(trivial && assertion.allowTrivial !== true ? trivialAssertionDiagnostic(`component.${assertion.entity}.${assertion.component}.${assertion.path ?? "value"}`, assertion.path, before, input.scenario.sourcePath) : componentAssertionDiagnostic(assertion, before, after));
|
|
651
|
+
}
|
|
652
|
+
if ((assertion.atSteps?.length ?? 0) > 0) {
|
|
653
|
+
const samples = assertion.atSteps.map((expected) => {
|
|
654
|
+
const sample = (input.report.observations?.componentSeries ?? []).find((candidate) => candidate.label === expected.label);
|
|
655
|
+
const value = readPath(sample?.snapshots[assertion.entity]?.[assertion.component], assertion.path);
|
|
656
|
+
return { expected, pass: sample !== void 0 && Object.hasOwn(expected, "equals") && jsonEqual(value, expected.equals), value };
|
|
657
|
+
});
|
|
658
|
+
const pass = samples.every((sample) => sample.pass);
|
|
659
|
+
assertions.push({ details: { samples }, id: `component.${assertion.entity}.${assertion.component}.${assertion.path ?? "value"}.atSteps`, pass });
|
|
660
|
+
if (!pass) diagnostics.push({
|
|
661
|
+
code: "TN_PLAYTEST_COMPONENT_TRANSITION_ASSERTION_FAILED",
|
|
662
|
+
message: `Component '${assertion.component}' on entity '${assertion.entity}'${assertion.path === void 0 ? "" : ` path '${assertion.path}'`} did not match the expected labeled-step transition.`,
|
|
663
|
+
observedRuntimePath: "observations.json/componentSeries",
|
|
664
|
+
severity: "error",
|
|
665
|
+
suggestion: "Inspect the labeled component samples and fix the runtime component transition."
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
for (const [index, assertion] of (scenarioAssertions.aerodynamics ?? []).entries()) {
|
|
670
|
+
const forceSamples = aerodynamicForceSampleCount(input.report.observations?.physicsDebugSeries, assertion.entity);
|
|
671
|
+
const controlsSupported = input.scenario.target === "web";
|
|
672
|
+
const controls = (assertion.controls ?? []).map((control) => ({
|
|
673
|
+
...control,
|
|
674
|
+
observed: aerodynamicControlValues(
|
|
675
|
+
input.report.effectLog ?? input.report.observations?.effectLog,
|
|
676
|
+
input.report.observations?.effectLogSeries,
|
|
677
|
+
assertion.entity,
|
|
678
|
+
control.surface
|
|
679
|
+
),
|
|
680
|
+
...controlsSupported ? {} : { skipped: true, reason: "native-service-log-unavailable" }
|
|
681
|
+
}));
|
|
682
|
+
const torques = (assertion.torques ?? []).map((torque) => {
|
|
683
|
+
const value = aerodynamicTorqueAtLabel(input.report.observations?.physicsDebugSeries, assertion.entity, torque.label)?.[axisIndex(torque.axis)];
|
|
684
|
+
const relative = torque.relativeToLabel === void 0 ? void 0 : aerodynamicTorqueAtLabel(input.report.observations?.physicsDebugSeries, assertion.entity, torque.relativeToLabel)?.[axisIndex(torque.axis)];
|
|
685
|
+
return { ...torque, observed: value === void 0 || torque.relativeToLabel !== void 0 && relative === void 0 ? void 0 : value - (relative ?? 0) };
|
|
686
|
+
});
|
|
687
|
+
const forcePass = assertion.minForceSamples === void 0 || forceSamples >= assertion.minForceSamples;
|
|
688
|
+
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;
|
|
689
|
+
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));
|
|
690
|
+
const pass = forcePass && controlsPass && torquesPass && (assertion.minForceSamples !== void 0 || controls.length > 0 || torques.length > 0);
|
|
691
|
+
assertions.push({ details: { controls, forceSamples, minimumForceSamples: assertion.minForceSamples, torques }, id: `aerodynamics.${index}`, pass });
|
|
692
|
+
if (!pass) {
|
|
693
|
+
diagnostics.push({
|
|
694
|
+
artifactPath: assertion.minForceSamples !== void 0 ? "observations.json" : "effect-log.json",
|
|
695
|
+
code: "TN_PLAYTEST_AERODYNAMICS_ASSERTION_FAILED",
|
|
696
|
+
message: `Aerodynamic proof for '${assertion.entity}' did not observe the required finite force samples and signed control values.`,
|
|
697
|
+
observedRuntimePath: "observations.json/physicsDebugSeries/artifact/primitives[category=aero] | effect-log.json/entries[service=physics.aerodynamics.setInputs]",
|
|
698
|
+
severity: "error",
|
|
699
|
+
suggestion: "Check AerodynamicBody metadata, physics debug capture, input-axis bindings, and surface sign mapping."
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
for (const assertion of scenarioAssertions.hud ?? []) {
|
|
704
|
+
const result = evaluatePathAssertion("hud", assertion, input.report.observations?.hud[assertion.id], {});
|
|
705
|
+
assertions.push(result.assertion);
|
|
706
|
+
if (result.diagnostic !== void 0) {
|
|
707
|
+
diagnostics.push({ ...result.diagnostic, code: result.diagnostic.code || "TN_PLAYTEST_HUD_ASSERTION_FAILED" });
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
for (const assertion of scenarioAssertions.tags ?? []) {
|
|
711
|
+
const result = evaluateTagCountAssertion(assertion, input.report.observations?.runtimeObservations);
|
|
712
|
+
assertions.push(result.assertion);
|
|
713
|
+
if (result.diagnostic !== void 0) {
|
|
714
|
+
diagnostics.push(result.diagnostic);
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
for (const assertion of scenarioAssertions.states ?? []) {
|
|
718
|
+
const result = evaluateStateAssertion(assertion, input.report.observations?.runtimeObservations);
|
|
719
|
+
assertions.push(result.assertion);
|
|
720
|
+
if (result.diagnostic !== void 0) {
|
|
721
|
+
diagnostics.push(result.diagnostic);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
{
|
|
725
|
+
const diagnosticsPolicy = {
|
|
726
|
+
...scenarioAssertions.diagnostics,
|
|
727
|
+
noRuntimeDiagnostics: scenarioAssertions.diagnostics?.noRuntimeDiagnostics ?? true
|
|
728
|
+
};
|
|
729
|
+
const policyDiagnostics = evaluateDiagnosticsPolicy(input.report, diagnosticsPolicy);
|
|
730
|
+
diagnostics.push(...policyDiagnostics);
|
|
731
|
+
if (scenarioAssertions.diagnostics !== void 0 || policyDiagnostics.length > 0) {
|
|
732
|
+
assertions.push({
|
|
733
|
+
details: {
|
|
734
|
+
consoleErrors: consoleErrors(input.report.observations?.console ?? []).length,
|
|
735
|
+
networkErrors: input.report.observations?.network.length ?? 0,
|
|
736
|
+
runtimeDiagnostics: runtimeDiagnostics(input.report.observations?.runtimeDiagnostics).length
|
|
737
|
+
},
|
|
738
|
+
id: "diagnostics",
|
|
739
|
+
pass: policyDiagnostics.length === 0
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
if (scenarioAssertions.movement?.minVelocity !== void 0) {
|
|
744
|
+
const velocity = input.report.frames <= 0 ? 0 : input.report.distance / input.report.frames;
|
|
745
|
+
const pass = velocity >= scenarioAssertions.movement.minVelocity;
|
|
746
|
+
assertions.push({ details: { minVelocity: scenarioAssertions.movement.minVelocity, velocity }, id: "movement.velocity", pass });
|
|
747
|
+
if (!pass) {
|
|
748
|
+
diagnostics.push({
|
|
749
|
+
code: "TN_PLAYTEST_VELOCITY_ASSERTION_FAILED",
|
|
750
|
+
message: `Entity '${input.report.entity}' velocity ${velocity.toFixed(6)} was below required ${scenarioAssertions.movement.minVelocity}.`,
|
|
751
|
+
severity: "error",
|
|
752
|
+
suggestion: "Check input force/speed tuning and whether the scenario holds input long enough."
|
|
753
|
+
});
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
if (scenarioAssertions.movement?.minDistance !== void 0) {
|
|
757
|
+
const pass = input.report.distance >= scenarioAssertions.movement.minDistance;
|
|
758
|
+
assertions.push({
|
|
759
|
+
details: { distance: input.report.distance, minimum: scenarioAssertions.movement.minDistance },
|
|
760
|
+
id: "movement.distance",
|
|
761
|
+
pass
|
|
762
|
+
});
|
|
763
|
+
if (!pass && !input.report.diagnostics.some((diagnostic) => diagnostic.code === "TN_PLAYTEST_INPUT_NO_EFFECT")) {
|
|
764
|
+
diagnostics.push({
|
|
765
|
+
code: "TN_PLAYTEST_MOVEMENT_ASSERTION_FAILED",
|
|
766
|
+
message: `Entity '${scenarioAssertions.movement.entity ?? input.report.entity}' moved ${input.report.distance.toFixed(6)}, below required ${scenarioAssertions.movement.minDistance}.`,
|
|
767
|
+
severity: "error",
|
|
768
|
+
suggestion: "Check input bindings, collision response, and whether the scenario holds input long enough."
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
if (scenarioAssertions.movement?.maxDistance !== void 0) {
|
|
773
|
+
const observed = input.report.before !== void 0 && input.report.after !== void 0;
|
|
774
|
+
const pass = observed && input.report.distance <= scenarioAssertions.movement.maxDistance;
|
|
775
|
+
assertions.push({ details: { distance: input.report.distance, maximum: scenarioAssertions.movement.maxDistance, observed }, id: "movement.maxDistance", pass });
|
|
776
|
+
if (!pass) {
|
|
777
|
+
diagnostics.push({
|
|
778
|
+
code: "TN_PLAYTEST_MOVEMENT_ASSERTION_FAILED",
|
|
779
|
+
message: observed ? `Entity '${input.report.entity}' moved ${input.report.distance.toFixed(6)}, above allowed ${scenarioAssertions.movement.maxDistance}.` : `Entity '${scenarioAssertions.movement.entity ?? input.report.entity}' was never observed, so its movement could not be bounded.`,
|
|
780
|
+
severity: "error",
|
|
781
|
+
suggestion: observed ? "Check bounds/blocked-cell handling and ensure the scenario drives the intended blocked direction." : "Register the entity with the playtest bridge under the id the assertion names."
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
if (scenarioAssertions.movement?.pathLength !== void 0) {
|
|
786
|
+
const pathLength = input.report.pathLength ?? input.report.distance;
|
|
787
|
+
const pass = pathLength >= scenarioAssertions.movement.pathLength;
|
|
788
|
+
assertions.push({ details: { minimum: scenarioAssertions.movement.pathLength, pathLength }, id: "movement.pathLength", pass });
|
|
789
|
+
if (!pass) {
|
|
790
|
+
diagnostics.push({
|
|
791
|
+
code: "TN_PLAYTEST_PATH_LENGTH_ASSERTION_FAILED",
|
|
792
|
+
message: `Entity '${input.report.entity}' accumulated path length ${pathLength.toFixed(6)}, below required ${scenarioAssertions.movement.pathLength}.`,
|
|
793
|
+
severity: "error",
|
|
794
|
+
suggestion: "Use pathLength with minDistance to distinguish actual traversal from a route that returns to its starting point."
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
if (scenarioAssertions.movement?.minAxisDelta !== void 0) {
|
|
799
|
+
const expectation = parseMovementAxisExpectation(scenarioAssertions.movement.minAxisDelta.axis);
|
|
800
|
+
let rawDelta;
|
|
801
|
+
if (expectation !== void 0 && input.report.movementDelta !== void 0) {
|
|
802
|
+
rawDelta = input.report.movementDelta[axisIndex(expectation.axis)];
|
|
803
|
+
}
|
|
804
|
+
const signedDelta = rawDelta === void 0 || expectation === void 0 ? void 0 : rawDelta * (expectation.sign ?? 1);
|
|
805
|
+
const pass = signedDelta !== void 0 && signedDelta >= scenarioAssertions.movement.minAxisDelta.min;
|
|
806
|
+
assertions.push({
|
|
807
|
+
details: {
|
|
808
|
+
axis: scenarioAssertions.movement.minAxisDelta.axis,
|
|
809
|
+
min: scenarioAssertions.movement.minAxisDelta.min,
|
|
810
|
+
rawDelta: rawDelta ?? null,
|
|
811
|
+
signedDelta: signedDelta ?? null
|
|
812
|
+
},
|
|
813
|
+
id: "movement.axisDelta",
|
|
814
|
+
pass
|
|
815
|
+
});
|
|
816
|
+
if (!pass) {
|
|
817
|
+
diagnostics.push({
|
|
818
|
+
code: "TN_PLAYTEST_AXIS_DELTA_ASSERTION_FAILED",
|
|
819
|
+
message: `Entity '${scenarioAssertions.movement.entity ?? input.report.entity}' did not move ${scenarioAssertions.movement.minAxisDelta.min} units on ${scenarioAssertions.movement.minAxisDelta.axis}.`,
|
|
820
|
+
severity: "error",
|
|
821
|
+
suggestion: "Check route setup, collision response, and whether the scenario ends on the expected vertical surface."
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
if (scenarioAssertions.movement?.minResolvedAxisDelta !== void 0) {
|
|
826
|
+
const entity = scenarioAssertions.movement.entity ?? input.scenario.subject ?? input.report.entity;
|
|
827
|
+
const expectation = parseMovementAxisExpectation(scenarioAssertions.movement.minResolvedAxisDelta.axis);
|
|
828
|
+
const resolved = expectation === void 0 ? void 0 : maxResolvedAxisDelta(input.report.effectLog, entity, expectation, input.report.before?.position);
|
|
829
|
+
const pass = resolved !== void 0 && resolved >= scenarioAssertions.movement.minResolvedAxisDelta.min;
|
|
830
|
+
assertions.push({
|
|
831
|
+
details: {
|
|
832
|
+
axis: scenarioAssertions.movement.minResolvedAxisDelta.axis,
|
|
833
|
+
entity,
|
|
834
|
+
min: scenarioAssertions.movement.minResolvedAxisDelta.min,
|
|
835
|
+
signedDelta: resolved ?? null
|
|
836
|
+
},
|
|
837
|
+
id: "movement.resolvedAxisDelta",
|
|
838
|
+
pass
|
|
839
|
+
});
|
|
840
|
+
if (!pass) {
|
|
841
|
+
diagnostics.push({
|
|
842
|
+
code: "TN_PLAYTEST_RESOLVED_AXIS_DELTA_ASSERTION_FAILED",
|
|
843
|
+
message: `Entity '${entity}' did not resolve ${scenarioAssertions.movement.minResolvedAxisDelta.min} units on ${scenarioAssertions.movement.minResolvedAxisDelta.axis}.`,
|
|
844
|
+
severity: "error",
|
|
845
|
+
suggestion: "Check character.move effect-log entries, route setup, collision response, and whether the scenario reaches the expected slope or step surface."
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
if (scenarioAssertions.movement?.rotationChanged === true) {
|
|
850
|
+
const rotation = rotationDelta(
|
|
851
|
+
input.report.effectLog,
|
|
852
|
+
scenarioAssertions.movement.entity ?? input.report.entity,
|
|
853
|
+
input.report.before?.rotation,
|
|
854
|
+
input.report.after?.rotation
|
|
855
|
+
);
|
|
856
|
+
const pass = rotation !== void 0 && rotation > 1e-4;
|
|
857
|
+
assertions.push({ details: { rotationDelta: rotation ?? null }, id: "movement.rotation", pass });
|
|
858
|
+
if (!pass) {
|
|
859
|
+
diagnostics.push({
|
|
860
|
+
code: "TN_PLAYTEST_ROTATION_ASSERTION_FAILED",
|
|
861
|
+
message: `Entity '${scenarioAssertions.movement.entity ?? input.report.entity}' did not expose a changed rotation during the playtest.`,
|
|
862
|
+
severity: "error",
|
|
863
|
+
suggestion: "Check turn/yaw script output and ensure Transform rotation changes are emitted."
|
|
864
|
+
});
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
if (scenarioAssertions.movement?.maxTiltDegrees !== void 0) {
|
|
868
|
+
const entity = scenarioAssertions.movement.entity ?? input.report.entity;
|
|
869
|
+
const tilt = tiltDegrees(input.report.after?.rotation) ?? finalTiltDegrees(input.report.effectLog, entity);
|
|
870
|
+
const pass = tilt !== void 0 && tilt <= scenarioAssertions.movement.maxTiltDegrees;
|
|
871
|
+
assertions.push({
|
|
872
|
+
details: { entity, maxTiltDegrees: scenarioAssertions.movement.maxTiltDegrees, tiltDegrees: tilt ?? null },
|
|
873
|
+
id: "movement.tilt",
|
|
874
|
+
pass
|
|
875
|
+
});
|
|
876
|
+
if (!pass) {
|
|
877
|
+
diagnostics.push({
|
|
878
|
+
code: "TN_PLAYTEST_TILT_ASSERTION_FAILED",
|
|
879
|
+
message: `Entity '${entity}' final tilt ${tilt === void 0 ? "was unavailable" : `${tilt.toFixed(3)} degrees`} and must not exceed ${scenarioAssertions.movement.maxTiltDegrees} degrees.`,
|
|
880
|
+
severity: "error",
|
|
881
|
+
suggestion: "Inspect the final Transform rotation and fix suspension, grounding, collision response, or recovery before accepting the playtest."
|
|
882
|
+
});
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
if (scenarioAssertions.movement?.closesDistanceToPosition !== void 0) {
|
|
886
|
+
const expectation = scenarioAssertions.movement.closesDistanceToPosition;
|
|
887
|
+
const before = input.report.before?.position;
|
|
888
|
+
const after = input.report.after?.position;
|
|
889
|
+
const decrease = before === void 0 || after === void 0 ? void 0 : vectorDistance(before, expectation.position) - vectorDistance(after, expectation.position);
|
|
890
|
+
const pass = decrease !== void 0 && decrease >= expectation.min;
|
|
891
|
+
assertions.push({
|
|
892
|
+
details: { decrease: decrease ?? null, position: expectation.position, required: expectation.min },
|
|
893
|
+
id: "movement.closesDistance",
|
|
894
|
+
pass
|
|
895
|
+
});
|
|
896
|
+
if (!pass) diagnostics.push({
|
|
897
|
+
code: "TN_PLAYTEST_DISTANCE_CLOSURE_ASSERTION_FAILED",
|
|
898
|
+
message: `Entity did not close distance to the expected position by ${expectation.min}.`,
|
|
899
|
+
severity: "error",
|
|
900
|
+
suggestion: "Inspect pursue target ownership and character.move resolved positions."
|
|
901
|
+
});
|
|
902
|
+
}
|
|
903
|
+
if (scenarioAssertions.movement?.reachesPositionWithin !== void 0) {
|
|
904
|
+
const expectation = scenarioAssertions.movement.reachesPositionWithin;
|
|
905
|
+
const entity = scenarioAssertions.movement.entity ?? input.scenario.subject ?? input.report.entity;
|
|
906
|
+
const resolvedDistance = minimumResolvedDistance(
|
|
907
|
+
input.report.effectLog,
|
|
908
|
+
input.report.observations?.effectLogSeries,
|
|
909
|
+
entity,
|
|
910
|
+
expectation.position,
|
|
911
|
+
input.report.before?.position,
|
|
912
|
+
expectation.atStep
|
|
913
|
+
);
|
|
914
|
+
const finalDistance = (expectation.atStep === void 0 || input.scenario.steps.at(-1)?.label === expectation.atStep) && input.report.after?.position !== void 0 ? vectorDistance(input.report.after.position, expectation.position) : void 0;
|
|
915
|
+
const candidates = [resolvedDistance, finalDistance].filter((value) => value !== void 0);
|
|
916
|
+
const closestDistance = candidates.length === 0 ? void 0 : Math.min(...candidates);
|
|
917
|
+
const pass = closestDistance !== void 0 && closestDistance <= expectation.maxDistance;
|
|
918
|
+
assertions.push({
|
|
919
|
+
details: { closestDistance: closestDistance ?? null, entity, ...expectation },
|
|
920
|
+
id: "movement.reachesPosition",
|
|
921
|
+
pass
|
|
922
|
+
});
|
|
923
|
+
if (!pass) diagnostics.push({
|
|
924
|
+
code: "TN_PLAYTEST_POSITION_REACH_ASSERTION_FAILED",
|
|
925
|
+
message: `Entity '${entity}' did not come within ${expectation.maxDistance} units of the expected position.`,
|
|
926
|
+
severity: "error",
|
|
927
|
+
suggestion: "Inspect character.move resolved positions and the owned last-known-position target."
|
|
928
|
+
});
|
|
929
|
+
}
|
|
930
|
+
if (scenarioAssertions.movement?.facesMovementWithinDegrees !== void 0) {
|
|
931
|
+
const entity = scenarioAssertions.movement.entity ?? input.scenario.subject ?? input.report.entity;
|
|
932
|
+
const evidence = movementFacingEvidence(input.report.effectLog, entity);
|
|
933
|
+
const pass = evidence.sampleCount > 0 && evidence.maxErrorDegrees <= scenarioAssertions.movement.facesMovementWithinDegrees;
|
|
934
|
+
assertions.push({
|
|
935
|
+
details: { entity, ...evidence, threshold: scenarioAssertions.movement.facesMovementWithinDegrees },
|
|
936
|
+
id: "movement.facing",
|
|
937
|
+
pass
|
|
938
|
+
});
|
|
939
|
+
if (!pass) diagnostics.push({
|
|
940
|
+
code: "TN_PLAYTEST_MOVEMENT_FACING_ASSERTION_FAILED",
|
|
941
|
+
message: `Entity '${entity}' did not face resolved movement within ${scenarioAssertions.movement.facesMovementWithinDegrees} degrees.`,
|
|
942
|
+
severity: "error",
|
|
943
|
+
suggestion: "Inspect character.move direction and Transform yaw effects; slew facing before allowing translation."
|
|
944
|
+
});
|
|
945
|
+
}
|
|
946
|
+
if (scenarioAssertions.movement?.notFacing !== void 0) {
|
|
947
|
+
const entity = scenarioAssertions.movement.entity ?? input.scenario.subject ?? input.report.entity;
|
|
948
|
+
const angleDegrees = finalFacingAngleToEntity(input.report.effectLog, entity, scenarioAssertions.movement.notFacing.entity);
|
|
949
|
+
const pass = angleDegrees !== void 0 && angleDegrees >= scenarioAssertions.movement.notFacing.minDegrees;
|
|
950
|
+
assertions.push({
|
|
951
|
+
details: { angleDegrees: angleDegrees ?? null, entity, target: scenarioAssertions.movement.notFacing.entity },
|
|
952
|
+
id: "movement.notFacing",
|
|
953
|
+
pass
|
|
954
|
+
});
|
|
955
|
+
if (!pass) diagnostics.push({
|
|
956
|
+
code: "TN_PLAYTEST_NOT_FACING_ASSERTION_FAILED",
|
|
957
|
+
message: `Entity '${entity}' remained pointed at '${scenarioAssertions.movement.notFacing.entity}' during movement.`,
|
|
958
|
+
severity: "error",
|
|
959
|
+
suggestion: "Drive patrol yaw from movement direction rather than the target entity."
|
|
960
|
+
});
|
|
961
|
+
}
|
|
962
|
+
if (scenarioAssertions.movement?.notFacingPosition !== void 0) {
|
|
963
|
+
const entity = scenarioAssertions.movement.entity ?? input.scenario.subject ?? input.report.entity;
|
|
964
|
+
const expectation = scenarioAssertions.movement.notFacingPosition;
|
|
965
|
+
const angleDegrees = finalFacingAngleToPosition(input.report.effectLog, entity, expectation.position);
|
|
966
|
+
const pass = angleDegrees !== void 0 && angleDegrees >= expectation.minDegrees;
|
|
967
|
+
assertions.push({
|
|
968
|
+
details: { angleDegrees: angleDegrees ?? null, entity, position: expectation.position },
|
|
969
|
+
id: "movement.notFacingPosition",
|
|
970
|
+
pass
|
|
971
|
+
});
|
|
972
|
+
if (!pass) diagnostics.push({
|
|
973
|
+
code: "TN_PLAYTEST_NOT_FACING_POSITION_ASSERTION_FAILED",
|
|
974
|
+
message: `Entity '${entity}' remained pointed at the excluded world position during movement.`,
|
|
975
|
+
severity: "error",
|
|
976
|
+
suggestion: "Drive patrol yaw from movement direction rather than the observed target position."
|
|
977
|
+
});
|
|
978
|
+
}
|
|
979
|
+
for (const assertion of scenarioAssertions.visibility ?? []) {
|
|
980
|
+
const entity = assertion.entity ?? input.scenario.subject ?? input.report.entity;
|
|
981
|
+
const result = evaluateVisibilityAssertion(entity, assertion.minProjectedPixels, assertion.maxOffscreenRatio, assertion.present, input.scenario.viewport, input.report.observations?.runtimeDiagnostics);
|
|
982
|
+
assertions.push(result.assertion);
|
|
983
|
+
if (result.diagnostic !== void 0) {
|
|
984
|
+
diagnostics.push(result.diagnostic);
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
for (const assertion of scenarioAssertions.contacts ?? []) {
|
|
988
|
+
const entity = assertion.entity ?? input.scenario.subject ?? input.report.entity;
|
|
989
|
+
if (assertion.requiredOn !== void 0 && !assertion.requiredOn.includes(input.scenario.target)) {
|
|
990
|
+
assertions.push({
|
|
991
|
+
details: { entity, requiredOn: assertion.requiredOn, skipped: true, target: input.scenario.target },
|
|
992
|
+
id: `contact.${entity}`,
|
|
993
|
+
pass: true
|
|
994
|
+
});
|
|
995
|
+
continue;
|
|
996
|
+
}
|
|
997
|
+
const tokens = [entity, assertion.with, assertion.kind].filter((item) => item !== void 0);
|
|
998
|
+
const selectedSample = assertion.atStep === void 0 ? void 0 : input.report.observations?.physicsDebugSeries?.find((sample) => sample.label === assertion.atStep);
|
|
999
|
+
const stepAvailable = assertion.atStep === void 0 || selectedSample !== void 0;
|
|
1000
|
+
const effectEvidence = assertion.atStep === void 0 ? mergeEffectLogs(input.report.effectLog, input.report.observations?.effectLogSeries) : [];
|
|
1001
|
+
const effectCount = countMatchingEntries(effectEvidence, tokens);
|
|
1002
|
+
const runtimeCount = assertion.atStep === void 0 ? countRuntimeContacts(input.report.observations?.runtimeObservations, entity, assertion.with, assertion.kind) : 0;
|
|
1003
|
+
const physicsDebugCount = assertion.kind === void 0 || assertion.kind === "contact" ? countPhysicsDebugContacts(input.report.observations, entity, assertion.with, selectedSample?.snapshot) : 0;
|
|
1004
|
+
const count = effectCount + physicsDebugCount + runtimeCount;
|
|
1005
|
+
const minCount = assertion.minCount ?? (assertion.maxCount === void 0 ? 1 : 0);
|
|
1006
|
+
const pass = stepAvailable && count >= minCount && (assertion.maxCount === void 0 || count <= assertion.maxCount);
|
|
1007
|
+
assertions.push({ details: { atStep: assertion.atStep, count, entity, kind: assertion.kind, maxCount: assertion.maxCount, minCount, with: assertion.with }, id: `contact.${entity}`, pass });
|
|
1008
|
+
if (!pass) {
|
|
1009
|
+
const partial = summarizeMatchingEntries(effectEvidence, [entity, assertion.with].filter((item) => item !== void 0));
|
|
1010
|
+
const hasPhysicsDebugEvidence = input.report.observations?.physicsDebug !== void 0 || (input.report.observations?.physicsDebugSeries?.length ?? 0) > 0;
|
|
1011
|
+
diagnostics.push({
|
|
1012
|
+
artifactPath: partial !== void 0 || !hasPhysicsDebugEvidence ? "effect-log.json" : "observations.json",
|
|
1013
|
+
code: !stepAvailable ? "TN_PLAYTEST_CONTACT_STEP_NOT_OBSERVED" : assertion.maxCount !== void 0 && count > assertion.maxCount ? "TN_PLAYTEST_CONTACT_COUNT_EXCEEDED" : "TN_PLAYTEST_CONTACT_NOT_OBSERVED",
|
|
1014
|
+
message: !stepAvailable ? `Contact assertion step '${assertion.atStep}' was not retained.` : assertion.maxCount !== void 0 && count > assertion.maxCount ? `Contact/trigger for '${entity}' was observed ${count} time(s), above allowed ${assertion.maxCount}.` : `Expected contact/trigger for '${entity}' was not observed ${minCount} time(s).`,
|
|
1015
|
+
observedRuntimePath: `observations.json/physicsDebugSeries/artifact/primitives[category=contact,entity=${entity}] | effect-log.json/entries[kind=service|event,entity=${entity}]`,
|
|
1016
|
+
path: `${input.scenario.sourcePath ?? "playtest"}/assert/contacts/${entity}`,
|
|
1017
|
+
severity: "error",
|
|
1018
|
+
...input.scenario.sourcePath === void 0 ? {} : { sourcePath: input.scenario.sourcePath },
|
|
1019
|
+
...partial?.systemId === void 0 ? {} : { systemId: partial.systemId, sourcePath: partial.sourcePath },
|
|
1020
|
+
suggestion: !stepAvailable ? "Add a scenario step with the requested label or correct assert.contacts[].atStep." : partial === void 0 ? "Check collider/trigger metadata, contact filters, and whether the scenario reaches the target. Inspect observations.json physics-debug contacts and effect-log.json." : `effect-log.json contains ${partial.entryCount} related runtime entr${partial.entryCount === 1 ? "y" : "ies"} from ${partial.systems}, but none satisfied the contact assertion. Check collider/trigger metadata, contact filters, and route timing in the listed system(s).`
|
|
1021
|
+
});
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
for (const assertion of scenarioAssertions.settled ?? []) {
|
|
1025
|
+
if (assertion.requiredOn !== void 0 && !assertion.requiredOn.includes(input.scenario.target)) {
|
|
1026
|
+
assertions.push({
|
|
1027
|
+
details: { entity: assertion.entity, requiredOn: assertion.requiredOn, skipped: true, target: input.scenario.target },
|
|
1028
|
+
id: `settled.${assertion.entity}`,
|
|
1029
|
+
pass: true
|
|
1030
|
+
});
|
|
1031
|
+
continue;
|
|
1032
|
+
}
|
|
1033
|
+
const snapshot = assertion.atStep === void 0 ? input.report.observations?.physicsDebugSeries?.at(-1)?.snapshot ?? input.report.observations?.physicsDebug : input.report.observations?.physicsDebugSeries?.find((sample) => sample.label === assertion.atStep)?.snapshot;
|
|
1034
|
+
const bodies = physicsDebugSleepStates(snapshot, assertion.entity);
|
|
1035
|
+
const minimum = assertion.minBodies ?? 1;
|
|
1036
|
+
const sleeping = bodies.filter((body) => body.sleeping).length;
|
|
1037
|
+
const comparisonSnapshot = assertion.compareToStep === void 0 ? void 0 : input.report.observations?.physicsDebugSeries?.find((sample) => sample.label === assertion.compareToStep)?.snapshot;
|
|
1038
|
+
const poseDistance = assertion.compareToStep === void 0 ? void 0 : physicsDebugMeanPoseDistance(snapshot, comparisonSnapshot, assertion.entity);
|
|
1039
|
+
const posePass = assertion.minMeanPoseDistance === void 0 || poseDistance !== void 0 && poseDistance.sharedBodies >= minimum && poseDistance.mean >= assertion.minMeanPoseDistance;
|
|
1040
|
+
const pass = bodies.length >= minimum && sleeping === bodies.length && posePass;
|
|
1041
|
+
assertions.push({
|
|
1042
|
+
details: { atStep: assertion.atStep, bodies: bodies.length, compareToStep: assertion.compareToStep, entity: assertion.entity, minimum, poseDistance, sleeping },
|
|
1043
|
+
id: `settled.${assertion.entity}`,
|
|
1044
|
+
pass
|
|
1045
|
+
});
|
|
1046
|
+
if (!pass) diagnostics.push({
|
|
1047
|
+
artifactPath: "observations.json",
|
|
1048
|
+
code: !posePass ? "TN_PLAYTEST_RAGDOLL_POSE_NOT_DISTINCT" : "TN_PLAYTEST_PHYSICS_NOT_SETTLED",
|
|
1049
|
+
message: !posePass ? `Expected mean settled-pose distance for '${assertion.entity}' to reach ${assertion.minMeanPoseDistance}m from step '${assertion.compareToStep}'; observed ${poseDistance?.mean ?? "unavailable"}m across ${poseDistance?.sharedBodies ?? 0} bodies.` : `Expected at least ${minimum} physics bod${minimum === 1 ? "y" : "ies"} matching '${assertion.entity}' to be asleep; observed ${sleeping} of ${bodies.length}.`,
|
|
1050
|
+
observedRuntimePath: "observations.json/physicsDebugSeries/artifact/primitives[category=sleep]",
|
|
1051
|
+
path: `${input.scenario.sourcePath ?? "playtest"}/assert/settled/${assertion.entity}`,
|
|
1052
|
+
severity: "error",
|
|
1053
|
+
...input.scenario.sourcePath === void 0 ? {} : { sourcePath: input.scenario.sourcePath },
|
|
1054
|
+
suggestion: "Allow a longer settle window or fix damping, contacts, joints, and persistent forces that keep the bodies awake."
|
|
1055
|
+
});
|
|
1056
|
+
}
|
|
1057
|
+
for (const assertion of scenarioAssertions.occluded ?? []) {
|
|
1058
|
+
const matches = matchingOccludedRaycasts(input.report.effectLog, assertion.entity, assertion.target);
|
|
1059
|
+
const pass = matches > 0;
|
|
1060
|
+
assertions.push({ details: { count: matches, entity: assertion.entity, target: assertion.target }, id: `occluded.${assertion.entity ?? "ray"}`, pass });
|
|
1061
|
+
if (!pass) diagnostics.push({
|
|
1062
|
+
artifactPath: "effect-log.json",
|
|
1063
|
+
code: "TN_PLAYTEST_OCCLUSION_NOT_OBSERVED",
|
|
1064
|
+
message: "Expected a render scene-ray query or physics raycast result with hit=true, but no matching occlusion evidence was observed.",
|
|
1065
|
+
observedRuntimePath: "effect-log.json/entries[service=render.sceneRayQuery|physics.raycast]/payload/result/hit",
|
|
1066
|
+
severity: "error",
|
|
1067
|
+
suggestion: "Check the listener/emitter entity ids and rendered occluder geometry, then inspect effect-log.json for the scene-query request and hit result."
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1070
|
+
for (const assertion of scenarioAssertions.animation ?? []) {
|
|
1071
|
+
const entity = assertion.entity ?? input.scenario.subject ?? input.report.entity;
|
|
1072
|
+
const runtime = runtimeAnimationObservations(input.report.observations?.runtimeObservations);
|
|
1073
|
+
if (runtime !== void 0) {
|
|
1074
|
+
const observed = isRecord(runtime[entity]) ? runtime[entity] : void 0;
|
|
1075
|
+
const clip = typeof observed?.clip === "string" ? observed.clip : void 0;
|
|
1076
|
+
const advancedFrames = typeof observed?.advancedFrames === "number" ? observed.advancedFrames : void 0;
|
|
1077
|
+
const pass2 = observed !== void 0 && (assertion.clip === void 0 || clip === assertion.clip) && (assertion.entered !== true || clip !== void 0) && (assertion.advancedFrames === void 0 || advancedFrames !== void 0 && advancedFrames >= assertion.advancedFrames);
|
|
1078
|
+
assertions.push({ details: { advancedFrames, clip, entity, expected: assertion }, id: `animation.${entity}`, pass: pass2 });
|
|
1079
|
+
if (!pass2) {
|
|
1080
|
+
diagnostics.push({
|
|
1081
|
+
code: "TN_PLAYTEST_ANIMATION_NOT_OBSERVED",
|
|
1082
|
+
message: `Expected animation evidence for '${entity}'${assertion.clip === void 0 ? "" : ` clip '${assertion.clip}'`} was not observed.`,
|
|
1083
|
+
severity: "error",
|
|
1084
|
+
suggestion: "Check model animation clip wiring and runtime animation playback state."
|
|
1085
|
+
});
|
|
1086
|
+
}
|
|
1087
|
+
continue;
|
|
1088
|
+
}
|
|
1089
|
+
const tokens = [entity, assertion.clip].filter((item) => item !== void 0);
|
|
1090
|
+
const count = countMatchingEntries(input.report.effectLog, tokens);
|
|
1091
|
+
const minCount = Math.max(1, assertion.advancedFrames ?? 1);
|
|
1092
|
+
const pass = count >= minCount;
|
|
1093
|
+
assertions.push({ details: { count, entity, clip: assertion.clip, advancedFrames: assertion.advancedFrames }, id: `animation.${entity}`, pass });
|
|
1094
|
+
if (!pass) {
|
|
1095
|
+
diagnostics.push({
|
|
1096
|
+
code: "TN_PLAYTEST_ANIMATION_NOT_OBSERVED",
|
|
1097
|
+
message: `Expected animation evidence for '${entity}'${assertion.clip === void 0 ? "" : ` clip '${assertion.clip}'`} was not observed.`,
|
|
1098
|
+
severity: "error",
|
|
1099
|
+
suggestion: "Check model animation clip wiring and runtime animation playback state."
|
|
1100
|
+
});
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
for (const entry of PLAYTEST_ASSERTION_REGISTRY) {
|
|
1104
|
+
if (scenarioAssertions[entry.kind] === void 0 || assertions.some((assertion) => assertion.id.startsWith(entry.resultIdPrefix)) || assertionEvaluatedByBaseProbe(entry.kind, input.report)) {
|
|
1105
|
+
continue;
|
|
1106
|
+
}
|
|
1107
|
+
const id = `assert.${entry.kind}`;
|
|
1108
|
+
assertions.push({ details: { reason: "registered-without-evaluator" }, id, pass: false });
|
|
1109
|
+
diagnostics.push(assertionNotEvaluatedDiagnostic(id, "the registered assertion produced no evaluator result"));
|
|
1110
|
+
}
|
|
1111
|
+
if (assertions.length === 0) {
|
|
1112
|
+
const id = "scenario.assertions";
|
|
1113
|
+
assertions.push({ details: { reason: "no-evaluated-assertions" }, id, pass: false });
|
|
1114
|
+
diagnostics.push({
|
|
1115
|
+
code: "TN_PLAYTEST_SCENARIO_NO_ASSERTIONS",
|
|
1116
|
+
message: `Scenario '${input.scenario.name}' completed without evaluating any assertions.`,
|
|
1117
|
+
severity: "error",
|
|
1118
|
+
...input.scenario.sourcePath === void 0 ? {} : { sourcePath: input.scenario.sourcePath },
|
|
1119
|
+
suggestion: "Declare a supported assertion and ensure its evaluator observes a result before treating the scenario as proof."
|
|
1120
|
+
});
|
|
1121
|
+
}
|
|
1122
|
+
return { assertions, diagnostics };
|
|
1123
|
+
}
|
|
1124
|
+
function horizontalRadius(transform, direction) {
|
|
1125
|
+
const halfExtents = transform?.halfExtents ?? (transform?.scale === void 0 ? void 0 : transform.scale.map((value) => Math.abs(value) * 0.5));
|
|
1126
|
+
return halfExtents === void 0 ? 0 : Math.abs(direction[0]) * Math.abs(halfExtents[0]) + Math.abs(direction[1]) * Math.abs(halfExtents[2]);
|
|
1127
|
+
}
|
|
1128
|
+
function platformTop(transform) {
|
|
1129
|
+
const halfHeight = transform.halfExtents?.[1] ?? (transform.scale === void 0 ? 0 : Math.abs(transform.scale[1]) * 0.5);
|
|
1130
|
+
return (transform.position?.[1] ?? 0) + halfHeight;
|
|
1131
|
+
}
|
|
1132
|
+
function movementEnvelopeHorizontalLimit(envelope, rise) {
|
|
1133
|
+
if (rise > envelope.maxRise) return void 0;
|
|
1134
|
+
const dropFromApex = envelope.maxRise - rise;
|
|
1135
|
+
if (dropFromApex > envelope.fallDistanceToGround) return void 0;
|
|
1136
|
+
if (envelope.maxRise === 0) return rise === 0 ? envelope.forwardReach : void 0;
|
|
1137
|
+
return envelope.forwardReach * (1 + Math.sqrt(dropFromApex / envelope.maxRise));
|
|
1138
|
+
}
|
|
1139
|
+
function countPhysicsDebugContacts(observations, entity, withEntity, selectedSnapshot) {
|
|
1140
|
+
const snapshots = selectedSnapshot === void 0 ? [
|
|
1141
|
+
observations?.physicsDebug,
|
|
1142
|
+
...(observations?.physicsDebugSeries ?? []).map((sample) => sample.snapshot)
|
|
1143
|
+
] : [selectedSnapshot];
|
|
1144
|
+
let count = 0;
|
|
1145
|
+
for (const snapshot of snapshots) {
|
|
1146
|
+
if (!isRecord(snapshot) || !isRecord(snapshot.artifact) || !Array.isArray(snapshot.artifact.primitives)) continue;
|
|
1147
|
+
count += snapshot.artifact.primitives.filter((primitive) => {
|
|
1148
|
+
if (!isRecord(primitive) || primitive.category !== "contact" || typeof primitive.id !== "string") return false;
|
|
1149
|
+
return primitive.id.includes(entity) && (withEntity === void 0 || primitive.id.includes(withEntity));
|
|
1150
|
+
}).length;
|
|
1151
|
+
}
|
|
1152
|
+
return count;
|
|
1153
|
+
}
|
|
1154
|
+
function physicsDebugSleepStates(snapshot, entity) {
|
|
1155
|
+
if (!isRecord(snapshot) || !isRecord(snapshot.artifact) || !Array.isArray(snapshot.artifact.primitives)) return [];
|
|
1156
|
+
return snapshot.artifact.primitives.flatMap((primitive) => {
|
|
1157
|
+
if (!isRecord(primitive) || primitive.category !== "sleep" || typeof primitive.entity !== "string" || primitive.entity !== entity && !primitive.entity.startsWith(entity) || typeof primitive.value !== "number") return [];
|
|
1158
|
+
return [{ entity: primitive.entity, sleeping: primitive.value >= 1 }];
|
|
1159
|
+
});
|
|
1160
|
+
}
|
|
1161
|
+
function physicsDebugMeanPoseDistance(snapshot, comparisonSnapshot, entity) {
|
|
1162
|
+
const positions = physicsDebugBodyPositions(snapshot, entity);
|
|
1163
|
+
const comparison = physicsDebugBodyPositions(comparisonSnapshot, entity);
|
|
1164
|
+
const distances = [...positions.entries()].flatMap(([id, position]) => {
|
|
1165
|
+
const other = comparison.get(id);
|
|
1166
|
+
return other === void 0 ? [] : [Math.hypot(position[0] - other[0], position[1] - other[1], position[2] - other[2])];
|
|
1167
|
+
});
|
|
1168
|
+
if (distances.length === 0) return void 0;
|
|
1169
|
+
return {
|
|
1170
|
+
mean: distances.reduce((sum, distance) => sum + distance, 0) / distances.length,
|
|
1171
|
+
sharedBodies: distances.length
|
|
1172
|
+
};
|
|
1173
|
+
}
|
|
1174
|
+
function physicsDebugBodyPositions(snapshot, entity) {
|
|
1175
|
+
const positions = /* @__PURE__ */ new Map();
|
|
1176
|
+
if (!isRecord(snapshot) || !isRecord(snapshot.artifact) || !Array.isArray(snapshot.artifact.primitives)) return positions;
|
|
1177
|
+
for (const primitive of snapshot.artifact.primitives) {
|
|
1178
|
+
if (!isRecord(primitive) || primitive.category !== "center-of-mass" || typeof primitive.entity !== "string" || primitive.entity !== entity && !primitive.entity.startsWith(entity) || !finiteVector(primitive.position)) continue;
|
|
1179
|
+
positions.set(primitive.entity, primitive.position);
|
|
1180
|
+
}
|
|
1181
|
+
return positions;
|
|
1182
|
+
}
|
|
1183
|
+
function assertionEvaluatedByBaseProbe(kind, report) {
|
|
1184
|
+
if (kind === "movement") return report.expectMoved || report.expectAxis !== void 0;
|
|
1185
|
+
if (kind === "camera") return report.follow !== void 0;
|
|
1186
|
+
return false;
|
|
1187
|
+
}
|
|
1188
|
+
function assertionNotEvaluatedDiagnostic(id, reason) {
|
|
1189
|
+
return {
|
|
1190
|
+
code: "TN_PLAYTEST_ASSERTION_NOT_EVALUATED",
|
|
1191
|
+
message: `Declared assertion '${id}' was not evaluated: ${reason}.`,
|
|
1192
|
+
severity: "error",
|
|
1193
|
+
suggestion: "Run this assertion on a supported target or add its evaluator before treating the scenario as proof."
|
|
1194
|
+
};
|
|
1195
|
+
}
|
|
1196
|
+
function overlayNodeObservationKey(overlayId, selector) {
|
|
1197
|
+
return `${overlayId}:${selector}`;
|
|
1198
|
+
}
|
|
1199
|
+
function evaluateTagCountAssertion(assertion, observations) {
|
|
1200
|
+
const gameplay = gameplayObservations(observations);
|
|
1201
|
+
const tags = isRecord(gameplay?.tags) ? gameplay.tags : void 0;
|
|
1202
|
+
const candidate = tags?.[assertion.tag];
|
|
1203
|
+
const summary = isRecord(candidate) ? candidate : void 0;
|
|
1204
|
+
const count = typeof summary?.count === "number" ? summary.count : tags === void 0 ? void 0 : 0;
|
|
1205
|
+
const pass = count !== void 0 && (assertion.count === void 0 || count === assertion.count) && (assertion.gte === void 0 || count >= assertion.gte);
|
|
1206
|
+
const result = { details: { count: count ?? null, expected: assertion, tag: assertion.tag }, id: `tags.${assertion.tag}`, pass };
|
|
1207
|
+
return pass ? { assertion: result } : {
|
|
1208
|
+
assertion: result,
|
|
1209
|
+
diagnostic: {
|
|
1210
|
+
code: "TN_PLAYTEST_TAG_COUNT_ASSERTION_FAILED",
|
|
1211
|
+
message: `Tag '${assertion.tag}' count ${count === void 0 ? "was unavailable" : count} did not satisfy the expected count.`,
|
|
1212
|
+
severity: "error",
|
|
1213
|
+
suggestion: "Ensure the runtime entity tags are authored and inspect runtimeObservations.gameplay.tags in the playtest artifact."
|
|
1214
|
+
}
|
|
1215
|
+
};
|
|
1216
|
+
}
|
|
1217
|
+
function evaluateStateAssertion(assertion, observations) {
|
|
1218
|
+
const gameplay = gameplayObservations(observations);
|
|
1219
|
+
const states = isRecord(gameplay?.states) ? gameplay.states : void 0;
|
|
1220
|
+
const observed = typeof states?.[assertion.entity] === "string" ? states[assertion.entity] : void 0;
|
|
1221
|
+
const pass = observed === assertion.equals;
|
|
1222
|
+
const result = { details: { entity: assertion.entity, expected: assertion.equals, observed: observed ?? null }, id: `states.${assertion.entity}`, pass };
|
|
1223
|
+
return pass ? { assertion: result } : {
|
|
1224
|
+
assertion: result,
|
|
1225
|
+
diagnostic: {
|
|
1226
|
+
code: "TN_PLAYTEST_STATE_ASSERTION_FAILED",
|
|
1227
|
+
message: `Entity '${assertion.entity}' state ${observed === void 0 ? "was unavailable" : `'${observed}'`} did not equal '${assertion.equals}'.`,
|
|
1228
|
+
severity: "error",
|
|
1229
|
+
suggestion: "Ensure the entity has a StateMachine component and inspect runtimeObservations.gameplay.states in the playtest artifact."
|
|
1230
|
+
}
|
|
1231
|
+
};
|
|
1232
|
+
}
|
|
1233
|
+
function evaluateWorldAssertion(assertion, observations) {
|
|
1234
|
+
const gameplay = gameplayObservations(observations);
|
|
1235
|
+
const world = isRecord(gameplay?.world) ? gameplay.world : void 0;
|
|
1236
|
+
const observed = world?.seed;
|
|
1237
|
+
const seedPass = (typeof observed === "number" || observed === null) && observed === assertion.seed;
|
|
1238
|
+
const observedRuntime = isRecord(world?.runtime) ? world.runtime : void 0;
|
|
1239
|
+
const expectedRuntime = assertion.runtime;
|
|
1240
|
+
const runtimePass = expectedRuntime === void 0 || observedRuntime !== void 0 && observedRuntime.agent === expectedRuntime.agent && observedRuntime.core === expectedRuntime.core && observedRuntime.randomState === expectedRuntime.randomState && observedRuntime.rapier === expectedRuntime.rapier && observedRuntime.step === expectedRuntime.step;
|
|
1241
|
+
const pass = seedPass && runtimePass;
|
|
1242
|
+
const result = {
|
|
1243
|
+
details: {
|
|
1244
|
+
expected: assertion.seed,
|
|
1245
|
+
expectedRuntime: expectedRuntime ?? null,
|
|
1246
|
+
observed: observed ?? null,
|
|
1247
|
+
observedRuntime: observedRuntime ?? null
|
|
1248
|
+
},
|
|
1249
|
+
id: "world.seed",
|
|
1250
|
+
pass
|
|
1251
|
+
};
|
|
1252
|
+
return pass ? { assertion: result } : {
|
|
1253
|
+
assertion: result,
|
|
1254
|
+
diagnostic: {
|
|
1255
|
+
code: "TN_PLAYTEST_WORLD_ASSERTION_FAILED",
|
|
1256
|
+
message: !seedPass ? `Runtime world seed ${observed === void 0 ? "was unavailable" : JSON.stringify(observed)} did not equal ${JSON.stringify(assertion.seed)}.` : `Runtime world fingerprint ${observedRuntime === void 0 ? "was unavailable" : JSON.stringify(observedRuntime)} did not equal ${JSON.stringify(expectedRuntime)}.`,
|
|
1257
|
+
observedRuntimePath: !seedPass ? "observations.json/runtimeObservations/gameplay/world/seed" : "observations.json/runtimeObservations/gameplay/world/runtime",
|
|
1258
|
+
severity: "error",
|
|
1259
|
+
suggestion: "Expose the configured world seed and deterministic runtime fingerprint through the runtime bridge and rerun the scenario."
|
|
1260
|
+
}
|
|
1261
|
+
};
|
|
1262
|
+
}
|
|
1263
|
+
function gameplayObservations(value) {
|
|
1264
|
+
if (!isRecord(value)) {
|
|
1265
|
+
return void 0;
|
|
1266
|
+
}
|
|
1267
|
+
const gameplay = value.gameplay;
|
|
1268
|
+
return isRecord(gameplay) ? gameplay : void 0;
|
|
1269
|
+
}
|
|
1270
|
+
function countRuntimeContacts(observations, entity, withEntity, kind) {
|
|
1271
|
+
const gameplay = gameplayObservations(observations);
|
|
1272
|
+
if (!Array.isArray(gameplay?.contacts)) return 0;
|
|
1273
|
+
return gameplay.contacts.filter((contact) => {
|
|
1274
|
+
if (!isRecord(contact)) return false;
|
|
1275
|
+
return contact.entity === entity && (withEntity === void 0 || contact.with === withEntity) && (kind === void 0 || contact.kind === kind);
|
|
1276
|
+
}).length;
|
|
1277
|
+
}
|
|
1278
|
+
function runtimeAnimationObservations(value) {
|
|
1279
|
+
const gameplay = gameplayObservations(value);
|
|
1280
|
+
return isRecord(gameplay?.animation) ? gameplay.animation : void 0;
|
|
1281
|
+
}
|
|
1282
|
+
function evaluatePathAssertion(kind, assertion, observed, context) {
|
|
1283
|
+
const before = readPath(observed?.before, assertion.path);
|
|
1284
|
+
const after = readPath(observed?.after, assertion.path);
|
|
1285
|
+
const valueChecksBefore = [];
|
|
1286
|
+
const valueChecksAfter = [];
|
|
1287
|
+
if (Object.hasOwn(assertion, "equals")) {
|
|
1288
|
+
valueChecksBefore.push(jsonEqual(before, assertion.equals));
|
|
1289
|
+
valueChecksAfter.push(jsonEqual(after, assertion.equals));
|
|
1290
|
+
}
|
|
1291
|
+
if (assertion.gte !== void 0) {
|
|
1292
|
+
valueChecksBefore.push(typeof before === "number" && before >= assertion.gte);
|
|
1293
|
+
valueChecksAfter.push(typeof after === "number" && after >= assertion.gte);
|
|
1294
|
+
}
|
|
1295
|
+
if (assertion.textIncludes !== void 0) {
|
|
1296
|
+
valueChecksBefore.push(String(textValue(before)).includes(assertion.textIncludes));
|
|
1297
|
+
valueChecksAfter.push(String(textValue(after)).includes(assertion.textIncludes));
|
|
1298
|
+
}
|
|
1299
|
+
const trivial = rejectsTrivialAssertion(kind === "hud" ? "hud" : "resources") && valueChecksBefore.length > 0 && before !== void 0 && valueChecksBefore.every(Boolean);
|
|
1300
|
+
const checks = [...valueChecksAfter];
|
|
1301
|
+
if (assertion.changed !== void 0) {
|
|
1302
|
+
const observed2 = before !== void 0 || after !== void 0;
|
|
1303
|
+
checks.push(observed2 && (assertion.changed ? !jsonEqual(before, after) : jsonEqual(before, after)));
|
|
1304
|
+
}
|
|
1305
|
+
const pass = checks.length > 0 && checks.every(Boolean) && (!trivial || assertion.allowTrivial === true);
|
|
1306
|
+
const result = {
|
|
1307
|
+
details: {
|
|
1308
|
+
after,
|
|
1309
|
+
before,
|
|
1310
|
+
expected: expectedPathAssertion(assertion),
|
|
1311
|
+
id: assertion.id,
|
|
1312
|
+
path: assertion.path,
|
|
1313
|
+
trivial,
|
|
1314
|
+
...trivial && assertion.allowTrivial === true ? { trivialityOptOut: true } : {}
|
|
1315
|
+
},
|
|
1316
|
+
id: `${kind}.${assertion.id}${assertion.path === void 0 ? "" : `.${assertion.path}`}`,
|
|
1317
|
+
pass
|
|
1318
|
+
};
|
|
1319
|
+
return pass ? { assertion: result } : {
|
|
1320
|
+
assertion: result,
|
|
1321
|
+
diagnostic: trivial && assertion.allowTrivial !== true ? trivialAssertionDiagnostic(`${kind}.${assertion.id}`, assertion.path, before, context.scenarioSourcePath) : pathAssertionDiagnostic(kind, assertion, before, after, context)
|
|
1322
|
+
};
|
|
1323
|
+
}
|
|
1324
|
+
function evaluateResourceAnyOfAssertion(assertion, observed, context) {
|
|
1325
|
+
const alternatives = assertion.anyOf ?? [];
|
|
1326
|
+
const evaluated = alternatives.map((alternative) => evaluatePathAssertion(
|
|
1327
|
+
"resource",
|
|
1328
|
+
{ ...alternative, id: assertion.id },
|
|
1329
|
+
observed,
|
|
1330
|
+
context
|
|
1331
|
+
));
|
|
1332
|
+
const passing = evaluated.find(({ assertion: result2 }) => result2.pass);
|
|
1333
|
+
const result = {
|
|
1334
|
+
details: {
|
|
1335
|
+
alternatives: evaluated.map(({ assertion: alternative }) => alternative.details ?? {}),
|
|
1336
|
+
id: assertion.id,
|
|
1337
|
+
observed: observed ?? null
|
|
1338
|
+
},
|
|
1339
|
+
id: `resource.${assertion.id}.anyOf`,
|
|
1340
|
+
pass: passing !== void 0
|
|
1341
|
+
};
|
|
1342
|
+
return passing === void 0 ? {
|
|
1343
|
+
assertion: result,
|
|
1344
|
+
diagnostic: {
|
|
1345
|
+
code: "TN_PLAYTEST_RESOURCE_ANY_OF_ASSERTION_FAILED",
|
|
1346
|
+
message: `No alternative path assertion for resource '${assertion.id}' passed.`,
|
|
1347
|
+
observedRuntimePath: `observations.json/resources/${assertion.id}`,
|
|
1348
|
+
severity: "error",
|
|
1349
|
+
suggestion: "Check the shared action input and the resource paths exposed by the runtime bridge."
|
|
1350
|
+
}
|
|
1351
|
+
} : { assertion: result };
|
|
1352
|
+
}
|
|
1353
|
+
function rejectsTrivialAssertion(kind) {
|
|
1354
|
+
return PLAYTEST_ASSERTION_REGISTRY.find((entry) => entry.kind === kind)?.triviality === "reject-initial-value";
|
|
1355
|
+
}
|
|
1356
|
+
function componentValueChecks(assertion, value) {
|
|
1357
|
+
const resolved = value;
|
|
1358
|
+
return [
|
|
1359
|
+
...Object.hasOwn(assertion, "equals") ? [jsonEqual(resolved, assertion.equals)] : [],
|
|
1360
|
+
...assertion.gte === void 0 ? [] : [typeof resolved === "number" && resolved >= assertion.gte]
|
|
1361
|
+
];
|
|
1362
|
+
}
|
|
1363
|
+
function matchingSignals(events, assertion) {
|
|
1364
|
+
if (events === void 0) return 0;
|
|
1365
|
+
let count = 0;
|
|
1366
|
+
for (const event of events) {
|
|
1367
|
+
if (!isRecord(event) || event.name !== assertion.name) continue;
|
|
1368
|
+
if (assertion.entity !== void 0 && event.entity !== assertion.entity) continue;
|
|
1369
|
+
count += 1;
|
|
1370
|
+
}
|
|
1371
|
+
return count;
|
|
1372
|
+
}
|
|
1373
|
+
function trivialAssertionDiagnostic(id, path, before, sourcePath) {
|
|
1374
|
+
return {
|
|
1375
|
+
code: "TN_PLAYTEST_ASSERTION_TRIVIAL",
|
|
1376
|
+
message: `Assertion '${id}'${path === void 0 ? "" : ` at path '${path}'`} was already satisfied before the scenario ran (value ${JSON.stringify(before)}).`,
|
|
1377
|
+
path,
|
|
1378
|
+
severity: "error",
|
|
1379
|
+
...sourcePath === void 0 ? {} : { sourcePath },
|
|
1380
|
+
suggestion: "Drive the asserted value from a failing initial state, assert changed:true, or set allowTrivial:true with a documented held-invariant reason."
|
|
1381
|
+
};
|
|
1382
|
+
}
|
|
1383
|
+
function hasFinalPathExpectation(assertion) {
|
|
1384
|
+
return Object.hasOwn(assertion, "equals") || assertion.gte !== void 0 || assertion.textIncludes !== void 0 || assertion.changed !== void 0;
|
|
1385
|
+
}
|
|
1386
|
+
function hasFinalComponentExpectation(assertion) {
|
|
1387
|
+
return Object.hasOwn(assertion, "equals") || assertion.gte !== void 0 || assertion.changed !== void 0;
|
|
1388
|
+
}
|
|
1389
|
+
function componentAssertionDiagnostic(assertion, before, after) {
|
|
1390
|
+
return {
|
|
1391
|
+
code: "TN_PLAYTEST_COMPONENT_ASSERTION_FAILED",
|
|
1392
|
+
message: `Component '${assertion.component}' on entity '${assertion.entity}'${assertion.path === void 0 ? "" : ` path '${assertion.path}'`} did not satisfy the assertion.`,
|
|
1393
|
+
observedRuntimePath: `observations.json/components/${assertion.entity}/${assertion.component}`,
|
|
1394
|
+
severity: "error",
|
|
1395
|
+
suggestion: `Expected ${JSON.stringify(assertion)}, observed before=${JSON.stringify(before)} after=${JSON.stringify(after)}. Check the owning script and runtime component synchronization.`
|
|
1396
|
+
};
|
|
1397
|
+
}
|
|
1398
|
+
function pathValuePass(assertion, value) {
|
|
1399
|
+
const checks = [];
|
|
1400
|
+
if (Object.hasOwn(assertion, "equals")) checks.push(jsonEqual(value, assertion.equals));
|
|
1401
|
+
if (assertion.gte !== void 0) checks.push(typeof value === "number" && value >= assertion.gte);
|
|
1402
|
+
if (assertion.textIncludes !== void 0) checks.push(String(textValue(value)).includes(assertion.textIncludes));
|
|
1403
|
+
return checks.length > 0 && checks.every(Boolean);
|
|
1404
|
+
}
|
|
1405
|
+
function aerodynamicForceSampleCount(series, entity) {
|
|
1406
|
+
return (series ?? []).filter(({ snapshot }) => {
|
|
1407
|
+
if (!isRecord(snapshot) || !isRecord(snapshot.artifact) || !Array.isArray(snapshot.artifact.primitives)) return false;
|
|
1408
|
+
return snapshot.artifact.primitives.some((primitive) => isRecord(primitive) && primitive.category === "aero" && primitive.entity === entity && typeof primitive.value === "number" && Number.isFinite(primitive.value) && finiteVector(primitive.from) && finiteVector(primitive.to));
|
|
1409
|
+
}).length;
|
|
1410
|
+
}
|
|
1411
|
+
function aerodynamicControlValues(effectLog, series, entity, surface) {
|
|
1412
|
+
const logs = [effectLog, ...(series ?? []).map((sample) => sample.snapshot)];
|
|
1413
|
+
return logs.flatMap((log) => !isRecord(log) || !Array.isArray(log.entries) ? [] : log.entries.flatMap((entry) => {
|
|
1414
|
+
if (!isRecord(entry) || entry.service !== "physics.aerodynamics.setInputs" || !isRecord(entry.payload)) return [];
|
|
1415
|
+
const request = record(entry.payload.request);
|
|
1416
|
+
const inputs = record(request?.inputs);
|
|
1417
|
+
const surfaces = record(inputs?.surfaces);
|
|
1418
|
+
const value = surfaces?.[surface];
|
|
1419
|
+
return request?.entity === entity && typeof value === "number" && Number.isFinite(value) ? [value] : [];
|
|
1420
|
+
}));
|
|
1421
|
+
}
|
|
1422
|
+
function aerodynamicTorqueAtLabel(series, entity, label) {
|
|
1423
|
+
const snapshot = (series ?? []).find((sample) => sample.label === label)?.snapshot;
|
|
1424
|
+
if (!isRecord(snapshot) || !isRecord(snapshot.artifact) || !Array.isArray(snapshot.artifact.primitives)) return void 0;
|
|
1425
|
+
const primitives = snapshot.artifact.primitives.filter(isRecord);
|
|
1426
|
+
const bodyPosition = primitives.find((primitive) => primitive.id === `sleep:${entity}`)?.position;
|
|
1427
|
+
if (!finiteVector(bodyPosition)) return void 0;
|
|
1428
|
+
const origin = bodyPosition;
|
|
1429
|
+
const torque = [0, 0, 0];
|
|
1430
|
+
let samples = 0;
|
|
1431
|
+
for (const primitive of primitives) {
|
|
1432
|
+
if (primitive.category !== "aero" || primitive.entity !== entity || !finiteVector(primitive.from) || !finiteVector(primitive.to)) continue;
|
|
1433
|
+
const from = primitive.from;
|
|
1434
|
+
const to = primitive.to;
|
|
1435
|
+
const momentArm = [from[0] - origin[0], from[1] - origin[1], from[2] - origin[2]];
|
|
1436
|
+
const force = [to[0] - from[0], to[1] - from[1], to[2] - from[2]];
|
|
1437
|
+
const cross = [
|
|
1438
|
+
momentArm[1] * force[2] - momentArm[2] * force[1],
|
|
1439
|
+
momentArm[2] * force[0] - momentArm[0] * force[2],
|
|
1440
|
+
momentArm[0] * force[1] - momentArm[1] * force[0]
|
|
1441
|
+
];
|
|
1442
|
+
torque[0] += cross[0];
|
|
1443
|
+
torque[1] += cross[1];
|
|
1444
|
+
torque[2] += cross[2];
|
|
1445
|
+
samples += 1;
|
|
1446
|
+
}
|
|
1447
|
+
return samples === 0 || !torque.every(Number.isFinite) ? void 0 : torque;
|
|
1448
|
+
}
|
|
1449
|
+
function finiteVector(value) {
|
|
1450
|
+
return Array.isArray(value) && value.length === 3 && value.every((item) => typeof item === "number" && Number.isFinite(item));
|
|
1451
|
+
}
|
|
1452
|
+
function record(value) {
|
|
1453
|
+
return isRecord(value) ? value : void 0;
|
|
1454
|
+
}
|
|
1455
|
+
function expectedPathAssertion(assertion) {
|
|
1456
|
+
return {
|
|
1457
|
+
...assertion.atSteps === void 0 ? {} : { atSteps: assertion.atSteps },
|
|
1458
|
+
...Object.hasOwn(assertion, "equals") ? { equals: assertion.equals } : {},
|
|
1459
|
+
...assertion.gte === void 0 ? {} : { gte: assertion.gte },
|
|
1460
|
+
...assertion.textIncludes === void 0 ? {} : { textIncludes: assertion.textIncludes },
|
|
1461
|
+
...assertion.throughoutSteps === void 0 ? {} : { throughoutSteps: assertion.throughoutSteps },
|
|
1462
|
+
...assertion.changed === void 0 ? {} : { changed: assertion.changed },
|
|
1463
|
+
...assertion.allowTrivial === void 0 ? {} : { allowTrivial: assertion.allowTrivial }
|
|
1464
|
+
};
|
|
1465
|
+
}
|
|
1466
|
+
function unchangedPathValue(before, after) {
|
|
1467
|
+
return before !== void 0 && after !== void 0 && jsonEqual(before, after);
|
|
1468
|
+
}
|
|
1469
|
+
function pathAssertionDiagnostic(kind, assertion, before, after, context) {
|
|
1470
|
+
const unchanged = unchangedPathValue(before, after);
|
|
1471
|
+
if (kind === "resource" && unchanged && (context.movedDistance ?? 0) > 0.01) {
|
|
1472
|
+
const summary = summarizeResourceEffectLog(context.effectLog, assertion.id, assertion.path);
|
|
1473
|
+
return {
|
|
1474
|
+
code: "TN_PLAYTEST_RESOURCE_STATE_STAGNATED",
|
|
1475
|
+
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.`,
|
|
1476
|
+
artifactPath: "effect-log.json",
|
|
1477
|
+
observedRuntimePath: `effect-log.json/entries[kind=resource,resource=${assertion.id}]`,
|
|
1478
|
+
path: assertion.path === void 0 ? `${context.scenarioSourcePath ?? "playtest"}/assert/resources/${assertion.id}` : `${context.scenarioSourcePath ?? "playtest"}/assert/resources/${assertion.id}/${assertion.path}`,
|
|
1479
|
+
resourceId: assertion.id,
|
|
1480
|
+
severity: "error",
|
|
1481
|
+
...context.scenarioSourcePath === void 0 ? {} : { sourcePath: context.scenarioSourcePath },
|
|
1482
|
+
...summary?.systemId === void 0 ? {} : { systemId: summary.systemId, sourcePath: summary.sourcePath },
|
|
1483
|
+
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).`
|
|
1484
|
+
};
|
|
1485
|
+
}
|
|
1486
|
+
return {
|
|
1487
|
+
code: "",
|
|
1488
|
+
message: `${kind === "hud" ? "HUD" : "Resource"} assertion failed for '${assertion.id}'${assertion.path === void 0 ? "" : ` path '${assertion.path}'`}.`,
|
|
1489
|
+
severity: "error",
|
|
1490
|
+
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."
|
|
1491
|
+
};
|
|
1492
|
+
}
|
|
1493
|
+
function summarizeResourceEffectLog(effectLog, resourceId, path) {
|
|
1494
|
+
if (!isRecord(effectLog) || !Array.isArray(effectLog.entries)) {
|
|
1495
|
+
return void 0;
|
|
1496
|
+
}
|
|
1497
|
+
const entries = effectLog.entries.filter((entry) => isRecord(entry)).filter((entry) => entry.kind === "resource" && entry.resource === resourceId);
|
|
1498
|
+
if (entries.length === 0) {
|
|
1499
|
+
return void 0;
|
|
1500
|
+
}
|
|
1501
|
+
const systems = /* @__PURE__ */ new Set();
|
|
1502
|
+
const values = /* @__PURE__ */ new Set();
|
|
1503
|
+
for (const entry of entries) {
|
|
1504
|
+
if (typeof entry.system === "string") {
|
|
1505
|
+
systems.add(entry.system);
|
|
1506
|
+
}
|
|
1507
|
+
values.add(shortJson(readPath(entry.value, path)));
|
|
1508
|
+
}
|
|
1509
|
+
return {
|
|
1510
|
+
distinctValues: Array.from(values).slice(0, 3).join(", "),
|
|
1511
|
+
entryCount: entries.length,
|
|
1512
|
+
...[...systems].at(0) === void 0 ? {} : { sourcePath: sourcePathForSystem([...systems][0]), systemId: [...systems][0] },
|
|
1513
|
+
systems: systems.size === 0 ? "unknown systems" : Array.from(systems).slice(0, 5).join(", ")
|
|
1514
|
+
};
|
|
1515
|
+
}
|
|
1516
|
+
function sourcePathForSystem(systemId) {
|
|
1517
|
+
return `content/systems/${systemId}.systems.json`;
|
|
1518
|
+
}
|
|
1519
|
+
function shortJson(value) {
|
|
1520
|
+
const text = JSON.stringify(value);
|
|
1521
|
+
if (text === void 0) {
|
|
1522
|
+
return "undefined";
|
|
1523
|
+
}
|
|
1524
|
+
return text.length > 120 ? `${text.slice(0, 117)}...` : text;
|
|
1525
|
+
}
|
|
1526
|
+
function evaluateDiagnosticsPolicy(report, policy) {
|
|
1527
|
+
const diagnostics = [];
|
|
1528
|
+
if (policy?.runtimeReady === true && report.diagnostics.some((diagnostic) => diagnostic.code === "TN_PLAYTEST_RUNTIME_NOT_READY")) {
|
|
1529
|
+
diagnostics.push({
|
|
1530
|
+
code: "TN_PLAYTEST_RUNTIME_DIAGNOSTIC",
|
|
1531
|
+
message: "Runtime did not reach ready state while diagnostics policy required it.",
|
|
1532
|
+
severity: "error",
|
|
1533
|
+
suggestion: "Inspect runtime diagnostics and bundle validation output before replaying the scenario."
|
|
1534
|
+
});
|
|
1535
|
+
}
|
|
1536
|
+
const capturedConsoleErrors = consoleErrors(report.observations?.console ?? []);
|
|
1537
|
+
if (policy?.noConsoleErrors === true && capturedConsoleErrors.length > 0) {
|
|
1538
|
+
diagnostics.push({
|
|
1539
|
+
code: "TN_PLAYTEST_CONSOLE_ERROR",
|
|
1540
|
+
message: `${capturedConsoleErrors.length} browser console error(s) were captured during playtest.`,
|
|
1541
|
+
severity: "error",
|
|
1542
|
+
suggestion: "Open console.json in the playtest artifact directory and fix the first runtime error."
|
|
1543
|
+
});
|
|
1544
|
+
}
|
|
1545
|
+
if (policy?.noNetworkErrors === true && (report.observations?.network.length ?? 0) > 0) {
|
|
1546
|
+
diagnostics.push({
|
|
1547
|
+
code: "TN_PLAYTEST_NETWORK_ERROR",
|
|
1548
|
+
message: `${report.observations?.network.length ?? 0} failed network request(s) were captured during playtest.`,
|
|
1549
|
+
severity: "error",
|
|
1550
|
+
suggestion: "Open network.json in the playtest artifact directory and fix missing asset or bundle paths."
|
|
1551
|
+
});
|
|
1552
|
+
}
|
|
1553
|
+
const runtimeErrors = runtimeDiagnostics(report.observations?.runtimeDiagnostics);
|
|
1554
|
+
if (policy?.noRuntimeDiagnostics === true && runtimeErrors.length > 0) {
|
|
1555
|
+
diagnostics.push({
|
|
1556
|
+
code: "TN_PLAYTEST_RUNTIME_DIAGNOSTIC",
|
|
1557
|
+
message: `${runtimeErrors.length} runtime diagnostic error(s) were captured during playtest.`,
|
|
1558
|
+
severity: "error",
|
|
1559
|
+
suggestion: "Inspect runtime-trace.json and repair the authored source that owns the diagnostic path."
|
|
1560
|
+
});
|
|
1561
|
+
}
|
|
1562
|
+
return diagnostics;
|
|
1563
|
+
}
|
|
1564
|
+
function evaluateVisibilityAssertion(entity, minProjectedPixels, maxOffscreenRatio, present2, viewport, runtimeDiagnosticsValue) {
|
|
1565
|
+
const diagnosticsSnapshot = runtimeDiagnosticsSnapshot(runtimeDiagnosticsValue);
|
|
1566
|
+
const rendered = renderedEntity(diagnosticsSnapshot, entity);
|
|
1567
|
+
const supportsProjectedBounds = renderedEntitiesAreReported(diagnosticsSnapshot);
|
|
1568
|
+
if (present2 !== void 0 && minProjectedPixels === void 0 && maxOffscreenRatio === void 0) {
|
|
1569
|
+
const observed = rendered !== void 0;
|
|
1570
|
+
const pass2 = observed === present2;
|
|
1571
|
+
const assertion2 = { details: { entity, observed, present: present2 }, id: `visibility.${entity}`, pass: pass2 };
|
|
1572
|
+
return pass2 ? { assertion: assertion2 } : {
|
|
1573
|
+
assertion: assertion2,
|
|
1574
|
+
diagnostic: {
|
|
1575
|
+
code: "TN_PLAYTEST_VISIBILITY_FAILED",
|
|
1576
|
+
message: `Entity '${entity}' presence did not match the expected value.`,
|
|
1577
|
+
severity: "error",
|
|
1578
|
+
suggestion: "Check entity registration and streaming unload decisions."
|
|
1579
|
+
}
|
|
1580
|
+
};
|
|
1581
|
+
}
|
|
1582
|
+
if (!supportsProjectedBounds && hasNativeReadinessSamples(diagnosticsSnapshot)) {
|
|
1583
|
+
return {
|
|
1584
|
+
assertion: {
|
|
1585
|
+
details: {
|
|
1586
|
+
entity,
|
|
1587
|
+
maxOffscreenRatio,
|
|
1588
|
+
minProjectedPixels,
|
|
1589
|
+
reason: "native-projected-bounds-unavailable",
|
|
1590
|
+
skipped: false
|
|
1591
|
+
},
|
|
1592
|
+
id: `visibility.${entity}`,
|
|
1593
|
+
pass: false
|
|
1594
|
+
},
|
|
1595
|
+
diagnostic: {
|
|
1596
|
+
code: "TN_PLAYTEST_VISIBILITY_FAILED",
|
|
1597
|
+
message: `Entity '${entity}' projected bounds are unavailable on the native target.`,
|
|
1598
|
+
severity: "error",
|
|
1599
|
+
suggestion: "Expose rendered entity projected bounds or remove the projected-pixel assertion."
|
|
1600
|
+
}
|
|
1601
|
+
};
|
|
1602
|
+
}
|
|
1603
|
+
const bounds = isRecord(rendered?.projectedBounds) ? rendered.projectedBounds : void 0;
|
|
1604
|
+
const min = Array.isArray(bounds?.min) ? bounds.min : void 0;
|
|
1605
|
+
const max = Array.isArray(bounds?.max) ? bounds.max : void 0;
|
|
1606
|
+
const projectedPixels = min === void 0 || max === void 0 ? void 0 : Math.max(0, (Number(max[0]) - Number(min[0])) / 2 * viewport.width) * Math.max(0, (Number(max[1]) - Number(min[1])) / 2 * viewport.height);
|
|
1607
|
+
const offscreenRatio = min === void 0 || max === void 0 ? void 0 : projectedOffscreenRatio([Number(min[0]), Number(min[1])], [Number(max[0]), Number(max[1])]);
|
|
1608
|
+
const pass = rendered !== void 0 && bounds !== void 0 && (present2 === void 0 || present2) && (minProjectedPixels === void 0 || (projectedPixels ?? 0) >= minProjectedPixels) && (maxOffscreenRatio === void 0 || (offscreenRatio ?? 1) <= maxOffscreenRatio);
|
|
1609
|
+
const assertion = { details: { entity, maxOffscreenRatio, minProjectedPixels, offscreenRatio, present: present2, projectedPixels }, id: `visibility.${entity}`, pass };
|
|
1610
|
+
return pass ? { assertion } : {
|
|
1611
|
+
assertion,
|
|
1612
|
+
diagnostic: {
|
|
1613
|
+
code: "TN_PLAYTEST_VISIBILITY_FAILED",
|
|
1614
|
+
message: `Entity '${entity}' did not satisfy projected visibility assertions.`,
|
|
1615
|
+
severity: "error",
|
|
1616
|
+
suggestion: "Check camera framing, clipping range, entity scale, and viewport-specific layout."
|
|
1617
|
+
}
|
|
1618
|
+
};
|
|
1619
|
+
}
|
|
1620
|
+
function projectedPixelsForEntity(snapshot, entity, viewport) {
|
|
1621
|
+
const rendered = renderedEntity(snapshot, entity);
|
|
1622
|
+
const bounds = isRecord(rendered?.projectedBounds) ? rendered.projectedBounds : void 0;
|
|
1623
|
+
const min = Array.isArray(bounds?.min) ? bounds.min : void 0;
|
|
1624
|
+
const max = Array.isArray(bounds?.max) ? bounds.max : void 0;
|
|
1625
|
+
return min === void 0 || max === void 0 ? void 0 : Math.max(0, (Number(max[0]) - Number(min[0])) / 2 * viewport.width) * Math.max(0, (Number(max[1]) - Number(min[1])) / 2 * viewport.height);
|
|
1626
|
+
}
|
|
1627
|
+
function countMatchingEntries(effectLog, tokens) {
|
|
1628
|
+
if (tokens.length === 0 || !isRecord(effectLog) || !Array.isArray(effectLog.entries)) {
|
|
1629
|
+
return 0;
|
|
1630
|
+
}
|
|
1631
|
+
return effectLog.entries.filter((entry) => {
|
|
1632
|
+
const text = JSON.stringify(entry);
|
|
1633
|
+
return tokens.every((token) => text.includes(token));
|
|
1634
|
+
}).length;
|
|
1635
|
+
}
|
|
1636
|
+
function mergeEffectLogs(effectLog, series) {
|
|
1637
|
+
return {
|
|
1638
|
+
entries: [effectLog, ...(series ?? []).map((sample) => sample.snapshot)].flatMap((log) => isRecord(log) && Array.isArray(log.entries) ? log.entries : [])
|
|
1639
|
+
};
|
|
1640
|
+
}
|
|
1641
|
+
function matchingOccludedRaycasts(effectLog, entity, target) {
|
|
1642
|
+
if (!isRecord(effectLog) || !Array.isArray(effectLog.entries)) return 0;
|
|
1643
|
+
return effectLog.entries.filter((entry) => {
|
|
1644
|
+
if (!isRecord(entry) || entry.service !== "render.sceneRayQuery" && entry.service !== "physics.raycast" || !isRecord(entry.payload) || !isRecord(entry.payload.result) || entry.payload.result.hit !== true) return false;
|
|
1645
|
+
const request = JSON.stringify(entry.payload.request ?? null);
|
|
1646
|
+
return (entity === void 0 || request.includes(entity)) && (target === void 0 || request.includes(target));
|
|
1647
|
+
}).length;
|
|
1648
|
+
}
|
|
1649
|
+
function summarizeMatchingEntries(effectLog, tokens) {
|
|
1650
|
+
if (tokens.length === 0 || !isRecord(effectLog) || !Array.isArray(effectLog.entries)) {
|
|
1651
|
+
return void 0;
|
|
1652
|
+
}
|
|
1653
|
+
const entries = effectLog.entries.filter((entry) => isRecord(entry)).filter((entry) => {
|
|
1654
|
+
const text = JSON.stringify(entry);
|
|
1655
|
+
return tokens.every((token) => text.includes(token));
|
|
1656
|
+
});
|
|
1657
|
+
if (entries.length === 0) {
|
|
1658
|
+
return void 0;
|
|
1659
|
+
}
|
|
1660
|
+
const systems = new Set(entries.map((entry) => typeof entry.system === "string" ? entry.system : void 0).filter((item) => item !== void 0));
|
|
1661
|
+
const firstSystem = [...systems][0];
|
|
1662
|
+
return {
|
|
1663
|
+
entryCount: entries.length,
|
|
1664
|
+
...firstSystem === void 0 ? {} : { sourcePath: sourcePathForSystem(firstSystem), systemId: firstSystem },
|
|
1665
|
+
systems: systems.size === 0 ? "unknown systems" : [...systems].slice(0, 5).join(", ")
|
|
1666
|
+
};
|
|
1667
|
+
}
|
|
1668
|
+
function rotationDelta(effectLog, entityId, beforeRotation, afterRotation) {
|
|
1669
|
+
if (isRecord(effectLog) && Array.isArray(effectLog.entries)) {
|
|
1670
|
+
const rotations = effectLog.entries.filter((entry) => isRecord(entry)).filter((entry) => entry.kind === "patch" && entry.command === "setComponent" && entry.component === "Transform" && entry.entity === entityId).map((entry) => readRotation(entry.value)).filter((item) => item !== void 0);
|
|
1671
|
+
const first = rotations[0];
|
|
1672
|
+
const last = rotations[rotations.length - 1];
|
|
1673
|
+
if (first !== void 0 && last !== void 0) return vectorDistance(first, last);
|
|
1674
|
+
}
|
|
1675
|
+
return quaternionDelta(beforeRotation, afterRotation);
|
|
1676
|
+
}
|
|
1677
|
+
function quaternionDelta(before, after) {
|
|
1678
|
+
if (before === void 0 || after === void 0) return void 0;
|
|
1679
|
+
const beforeLength = Math.hypot(...before);
|
|
1680
|
+
const afterLength = Math.hypot(...after);
|
|
1681
|
+
if (beforeLength <= Number.EPSILON || afterLength <= Number.EPSILON) return void 0;
|
|
1682
|
+
const dot = Math.abs((before[0] * after[0] + before[1] * after[1] + before[2] * after[2] + before[3] * after[3]) / (beforeLength * afterLength));
|
|
1683
|
+
return 2 * Math.acos(Math.max(-1, Math.min(1, dot)));
|
|
1684
|
+
}
|
|
1685
|
+
function finalTiltDegrees(effectLog, entityId) {
|
|
1686
|
+
if (!isRecord(effectLog) || !Array.isArray(effectLog.entries)) return void 0;
|
|
1687
|
+
const rotation = effectLog.entries.filter((entry) => isRecord(entry)).filter((entry) => entry.kind === "patch" && entry.command === "setComponent" && entry.component === "Transform" && entry.entity === entityId).map((entry) => isRecord(entry.value) ? entry.value.rotation : void 0).filter((value) => Array.isArray(value) && value.length >= 4).at(-1);
|
|
1688
|
+
return tiltDegrees(rotation);
|
|
1689
|
+
}
|
|
1690
|
+
function tiltDegrees(rotation) {
|
|
1691
|
+
if (rotation === void 0) return void 0;
|
|
1692
|
+
const quaternion = rotation.slice(0, 4).map((value) => typeof value === "number" && Number.isFinite(value) ? value : Number.NaN);
|
|
1693
|
+
if (!quaternion.every(Number.isFinite)) return void 0;
|
|
1694
|
+
const [x, y, z, w] = quaternion;
|
|
1695
|
+
const length = Math.hypot(x, y, z, w);
|
|
1696
|
+
if (length <= Number.EPSILON) return void 0;
|
|
1697
|
+
const upDot = 1 - 2 * ((x / length) ** 2 + (z / length) ** 2);
|
|
1698
|
+
return Math.acos(Math.max(-1, Math.min(1, upDot))) * 180 / Math.PI;
|
|
1699
|
+
}
|
|
1700
|
+
function movementFacingEvidence(effectLog, entityId) {
|
|
1701
|
+
if (!isRecord(effectLog) || !Array.isArray(effectLog.entries)) {
|
|
1702
|
+
return { maxErrorDegrees: Number.POSITIVE_INFINITY, sampleCount: 0 };
|
|
1703
|
+
}
|
|
1704
|
+
let yaw;
|
|
1705
|
+
const errors = [];
|
|
1706
|
+
for (const entry of effectLog.entries) {
|
|
1707
|
+
if (!isRecord(entry)) continue;
|
|
1708
|
+
if (entry.kind === "patch" && entry.command === "setComponent" && entry.component === "Transform" && entry.entity === entityId) {
|
|
1709
|
+
yaw = yawFromTransform(entry.value) ?? yaw;
|
|
1710
|
+
continue;
|
|
1711
|
+
}
|
|
1712
|
+
if (entry.kind !== "service" || entry.service !== "character.move" || yaw === void 0 || !isRecord(entry.payload)) continue;
|
|
1713
|
+
const request = isRecord(entry.payload.request) ? entry.payload.request : void 0;
|
|
1714
|
+
const options = isRecord(request?.options) ? request.options : void 0;
|
|
1715
|
+
const direction = Array.isArray(options?.direction) ? options.direction : void 0;
|
|
1716
|
+
if (request?.entity !== entityId || direction === void 0 || typeof direction[0] !== "number" || typeof direction[1] !== "number") continue;
|
|
1717
|
+
const heading = Math.atan2(direction[0], direction[1]);
|
|
1718
|
+
errors.push(Math.abs(wrappedAngle(heading - yaw)) * 180 / Math.PI);
|
|
1719
|
+
}
|
|
1720
|
+
return {
|
|
1721
|
+
maxErrorDegrees: errors.length === 0 ? Number.POSITIVE_INFINITY : Math.max(...errors),
|
|
1722
|
+
sampleCount: errors.length
|
|
1723
|
+
};
|
|
1724
|
+
}
|
|
1725
|
+
function finalFacingAngleToEntity(effectLog, entityId, targetId) {
|
|
1726
|
+
if (!isRecord(effectLog) || !Array.isArray(effectLog.entries)) return void 0;
|
|
1727
|
+
let subject;
|
|
1728
|
+
let target;
|
|
1729
|
+
for (const entry of effectLog.entries) {
|
|
1730
|
+
if (!isRecord(entry)) continue;
|
|
1731
|
+
if (entry.kind === "service" && entry.service === "character.move" && isRecord(entry.payload)) {
|
|
1732
|
+
const result = isRecord(entry.payload.result) ? entry.payload.result : void 0;
|
|
1733
|
+
if (result?.entity === targetId) target = readVec3(result.resolved) ?? target;
|
|
1734
|
+
continue;
|
|
1735
|
+
}
|
|
1736
|
+
if (entry.kind !== "patch" || entry.command !== "setComponent" || entry.component !== "Transform") continue;
|
|
1737
|
+
if (entry.entity === entityId) {
|
|
1738
|
+
const position = isRecord(entry.value) ? readVec3(entry.value.position) : void 0;
|
|
1739
|
+
const yaw = yawFromTransform(entry.value);
|
|
1740
|
+
if (position !== void 0 && yaw !== void 0) subject = { position, yaw };
|
|
1741
|
+
} else if (entry.entity === targetId && isRecord(entry.value)) {
|
|
1742
|
+
target = readVec3(entry.value.position) ?? target;
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
if (subject === void 0 || target === void 0) return void 0;
|
|
1746
|
+
const heading = Math.atan2(target[0] - subject.position[0], target[2] - subject.position[2]);
|
|
1747
|
+
return Math.abs(wrappedAngle(heading - subject.yaw)) * 180 / Math.PI;
|
|
1748
|
+
}
|
|
1749
|
+
function finalFacingAngleToPosition(effectLog, entityId, target) {
|
|
1750
|
+
if (!isRecord(effectLog) || !Array.isArray(effectLog.entries)) return void 0;
|
|
1751
|
+
let subject;
|
|
1752
|
+
for (const entry of effectLog.entries) {
|
|
1753
|
+
if (!isRecord(entry) || entry.kind !== "patch" || entry.command !== "setComponent" || entry.component !== "Transform" || entry.entity !== entityId) continue;
|
|
1754
|
+
const position = isRecord(entry.value) ? readVec3(entry.value.position) : void 0;
|
|
1755
|
+
const yaw = yawFromTransform(entry.value);
|
|
1756
|
+
if (position !== void 0 && yaw !== void 0) subject = { position, yaw };
|
|
1757
|
+
}
|
|
1758
|
+
if (subject === void 0) return void 0;
|
|
1759
|
+
const heading = Math.atan2(target[0] - subject.position[0], target[2] - subject.position[2]);
|
|
1760
|
+
return Math.abs(wrappedAngle(heading - subject.yaw)) * 180 / Math.PI;
|
|
1761
|
+
}
|
|
1762
|
+
function yawFromTransform(value) {
|
|
1763
|
+
if (!isRecord(value) || !Array.isArray(value.rotation) || value.rotation.length < 4) return void 0;
|
|
1764
|
+
const y = value.rotation[1];
|
|
1765
|
+
const w = value.rotation[3];
|
|
1766
|
+
return typeof y === "number" && Number.isFinite(y) && typeof w === "number" && Number.isFinite(w) ? 2 * Math.atan2(y, w) : void 0;
|
|
1767
|
+
}
|
|
1768
|
+
function wrappedAngle(value) {
|
|
1769
|
+
return Math.atan2(Math.sin(value), Math.cos(value));
|
|
1770
|
+
}
|
|
1771
|
+
function maxResolvedAxisDelta(effectLog, entityId, expectation, baseline) {
|
|
1772
|
+
if (!isRecord(effectLog) || !Array.isArray(effectLog.entries)) {
|
|
1773
|
+
return void 0;
|
|
1774
|
+
}
|
|
1775
|
+
const index = axisIndex(expectation.axis);
|
|
1776
|
+
const resolvedValues = effectLog.entries.filter((entry) => isRecord(entry)).filter((entry) => entry.kind === "service" && entry.service === "character.move").map((entry) => {
|
|
1777
|
+
const payload = isRecord(entry.payload) ? entry.payload : void 0;
|
|
1778
|
+
const result = isRecord(payload?.result) ? payload.result : void 0;
|
|
1779
|
+
return result?.entity === entityId ? readVec3(result.resolved) : void 0;
|
|
1780
|
+
}).filter((item) => item !== void 0);
|
|
1781
|
+
const first = baseline ?? resolvedValues[0];
|
|
1782
|
+
if (first === void 0 || resolvedValues.length === 0) {
|
|
1783
|
+
return void 0;
|
|
1784
|
+
}
|
|
1785
|
+
const sign = expectation.sign ?? 1;
|
|
1786
|
+
return Math.max(...resolvedValues.map((value) => (value[index] - first[index]) * sign));
|
|
1787
|
+
}
|
|
1788
|
+
function minimumResolvedDistance(effectLog, effectLogSeries, entityId, target, baseline, atStep) {
|
|
1789
|
+
const logs = [
|
|
1790
|
+
...atStep === void 0 ? [effectLog] : [],
|
|
1791
|
+
...Array.isArray(effectLogSeries) ? effectLogSeries.filter((item) => atStep === void 0 || isRecord(item) && item.label === atStep).map((item) => isRecord(item) ? item.snapshot : void 0) : []
|
|
1792
|
+
];
|
|
1793
|
+
const positions = logs.flatMap((log) => isRecord(log) && Array.isArray(log.entries) ? log.entries : []).filter((entry) => isRecord(entry)).filter((entry) => entry.kind === "service" && entry.service === "character.move").map((entry) => {
|
|
1794
|
+
const payload = isRecord(entry.payload) ? entry.payload : void 0;
|
|
1795
|
+
const result = isRecord(payload?.result) ? payload.result : void 0;
|
|
1796
|
+
return result?.entity === entityId ? readVec3(result.resolved) : void 0;
|
|
1797
|
+
}).filter((item) => item !== void 0);
|
|
1798
|
+
if (baseline !== void 0 && atStep === void 0) positions.unshift(baseline);
|
|
1799
|
+
return positions.length === 0 ? void 0 : Math.min(...positions.map((position) => vectorDistance(position, target)));
|
|
1800
|
+
}
|
|
1801
|
+
function renderedEntity(runtimeDiagnosticsValue, entity) {
|
|
1802
|
+
if (!renderedEntitiesAreReported(runtimeDiagnosticsValue)) {
|
|
1803
|
+
return void 0;
|
|
1804
|
+
}
|
|
1805
|
+
return runtimeDiagnosticsValue.scene.renderedEntities.find((item) => isRecord(item) && item.id === entity);
|
|
1806
|
+
}
|
|
1807
|
+
function renderedEntitiesAreReported(runtimeDiagnosticsValue) {
|
|
1808
|
+
return isRecord(runtimeDiagnosticsValue) && isRecord(runtimeDiagnosticsValue.scene) && Array.isArray(runtimeDiagnosticsValue.scene.renderedEntities);
|
|
1809
|
+
}
|
|
1810
|
+
function hasNativeReadinessSamples(runtimeDiagnosticsValue) {
|
|
1811
|
+
return isRecord(runtimeDiagnosticsValue) && Array.isArray(runtimeDiagnosticsValue.readiness);
|
|
1812
|
+
}
|
|
1813
|
+
function projectedOffscreenRatio(min, max) {
|
|
1814
|
+
const width = Math.max(0, max[0] - min[0]);
|
|
1815
|
+
const height = Math.max(0, max[1] - min[1]);
|
|
1816
|
+
const area = width * height;
|
|
1817
|
+
if (area === 0) {
|
|
1818
|
+
return 1;
|
|
1819
|
+
}
|
|
1820
|
+
const visibleWidth = Math.max(0, Math.min(max[0], 1) - Math.max(min[0], -1));
|
|
1821
|
+
const visibleHeight = Math.max(0, Math.min(max[1], 1) - Math.max(min[1], -1));
|
|
1822
|
+
return 1 - Math.max(0, visibleWidth * visibleHeight) / area;
|
|
1823
|
+
}
|
|
1824
|
+
function runtimeDiagnostics(value) {
|
|
1825
|
+
const snapshot = runtimeDiagnosticsSnapshot(value);
|
|
1826
|
+
if (snapshot !== value) {
|
|
1827
|
+
return runtimeDiagnostics(snapshot);
|
|
1828
|
+
}
|
|
1829
|
+
if (!isRecord(snapshot)) {
|
|
1830
|
+
return [];
|
|
1831
|
+
}
|
|
1832
|
+
const recentRuntimeErrors = Array.isArray(snapshot.recentRuntimeErrors) ? snapshot.recentRuntimeErrors : [];
|
|
1833
|
+
const resourceFailures = isRecord(snapshot.assets) && Array.isArray(snapshot.assets.resourceFailures) ? snapshot.assets.resourceFailures : [];
|
|
1834
|
+
return [...recentRuntimeErrors, ...resourceFailures];
|
|
1835
|
+
}
|
|
1836
|
+
function runtimeDiagnosticsSnapshot(value) {
|
|
1837
|
+
if (isRecord(value) && isRecord(value.diagnostics)) {
|
|
1838
|
+
return value.diagnostics;
|
|
1839
|
+
}
|
|
1840
|
+
return value;
|
|
1841
|
+
}
|
|
1842
|
+
function consoleErrors(entries) {
|
|
1843
|
+
return entries.filter((entry) => entry.type === "error" || entry.type === "assert" || entry.type === "pageerror");
|
|
1844
|
+
}
|
|
1845
|
+
function readPath(value, path) {
|
|
1846
|
+
if (path === void 0 || path.length === 0) {
|
|
1847
|
+
return value;
|
|
1848
|
+
}
|
|
1849
|
+
return path.split(".").reduce((current, part) => {
|
|
1850
|
+
if (Array.isArray(current) && /^(0|[1-9]\d*)$/u.test(part)) {
|
|
1851
|
+
return current[Number(part)];
|
|
1852
|
+
}
|
|
1853
|
+
if (!isRecord(current)) {
|
|
1854
|
+
return void 0;
|
|
1855
|
+
}
|
|
1856
|
+
return current[part];
|
|
1857
|
+
}, value);
|
|
1858
|
+
}
|
|
1859
|
+
function parseMovementAxisExpectation(value) {
|
|
1860
|
+
if (value === "x" || value === "y" || value === "z") {
|
|
1861
|
+
return { axis: value };
|
|
1862
|
+
}
|
|
1863
|
+
const match = /^([+-])([xyz])$/.exec(value);
|
|
1864
|
+
if (match === null) {
|
|
1865
|
+
return void 0;
|
|
1866
|
+
}
|
|
1867
|
+
return { axis: match[2], sign: match[1] === "-" ? -1 : 1 };
|
|
1868
|
+
}
|
|
1869
|
+
function axisIndex(axis) {
|
|
1870
|
+
return axis === "x" ? 0 : axis === "y" ? 1 : 2;
|
|
1871
|
+
}
|
|
1872
|
+
function textValue(value) {
|
|
1873
|
+
if (isRecord(value)) {
|
|
1874
|
+
return value.text ?? value.label ?? value.valueText ?? value.value;
|
|
1875
|
+
}
|
|
1876
|
+
return value;
|
|
1877
|
+
}
|
|
1878
|
+
function readRotation(value) {
|
|
1879
|
+
if (!isRecord(value) || !Array.isArray(value.rotation) || value.rotation.length < 3) {
|
|
1880
|
+
return void 0;
|
|
1881
|
+
}
|
|
1882
|
+
const rotation = value.rotation.slice(0, 3).map((item) => typeof item === "number" && Number.isFinite(item) ? item : Number.NaN);
|
|
1883
|
+
return rotation.every(Number.isFinite) ? rotation : void 0;
|
|
1884
|
+
}
|
|
1885
|
+
function readVec3(value) {
|
|
1886
|
+
if (!Array.isArray(value) || value.length < 3) {
|
|
1887
|
+
return void 0;
|
|
1888
|
+
}
|
|
1889
|
+
const vector = value.slice(0, 3).map((item) => typeof item === "number" && Number.isFinite(item) ? item : Number.NaN);
|
|
1890
|
+
return vector.every(Number.isFinite) ? vector : void 0;
|
|
1891
|
+
}
|
|
1892
|
+
function vectorDistance(left, right) {
|
|
1893
|
+
const dx = right[0] - left[0];
|
|
1894
|
+
const dy = right[1] - left[1];
|
|
1895
|
+
const dz = right[2] - left[2];
|
|
1896
|
+
return Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
1897
|
+
}
|
|
1898
|
+
function formatNumber(value) {
|
|
1899
|
+
return Number.isInteger(value) ? String(value) : value.toFixed(3);
|
|
1900
|
+
}
|
|
1901
|
+
function jsonEqual(left, right) {
|
|
1902
|
+
return JSON.stringify(left) === JSON.stringify(right);
|
|
1903
|
+
}
|
|
1904
|
+
function isRecord(value) {
|
|
1905
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1906
|
+
}
|
|
1907
|
+
|
|
1908
|
+
// src/diagnostics.ts
|
|
1909
|
+
function playtestDiagnostic(code, message, instruction, details = {}) {
|
|
1910
|
+
return {
|
|
1911
|
+
...details.capability === void 0 ? {} : { capability: details.capability },
|
|
1912
|
+
code,
|
|
1913
|
+
fix: {
|
|
1914
|
+
instruction,
|
|
1915
|
+
...details.nextCommand === void 0 ? {} : { nextCommand: details.nextCommand }
|
|
1916
|
+
},
|
|
1917
|
+
message,
|
|
1918
|
+
...details.path === void 0 ? {} : { path: details.path },
|
|
1919
|
+
severity: "error"
|
|
1920
|
+
};
|
|
1921
|
+
}
|
|
1922
|
+
|
|
1923
|
+
// src/protocol.ts
|
|
1924
|
+
var PLAYTEST_BRIDGE_GLOBAL = "__THREENATIVE_PLAYTEST_BRIDGE__";
|
|
1925
|
+
var PLAYTEST_PROTOCOL_VERSION = 1;
|
|
1926
|
+
var PLAYTEST_PROTOCOL_LIMITS = {
|
|
1927
|
+
maxEntitiesPerSample: 100,
|
|
1928
|
+
maxEventsPerDrain: 1e3,
|
|
1929
|
+
maxPayloadBytes: 1e6,
|
|
1930
|
+
operationTimeoutMs: 5e3
|
|
1931
|
+
};
|
|
1932
|
+
function jsonByteLength(value) {
|
|
1933
|
+
return new TextEncoder().encode(JSON.stringify(value)).byteLength;
|
|
1934
|
+
}
|
|
1935
|
+
function assertJsonSafe(value, path = "$") {
|
|
1936
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") {
|
|
1937
|
+
return;
|
|
1938
|
+
}
|
|
1939
|
+
if (typeof value === "number") {
|
|
1940
|
+
if (Number.isFinite(value)) {
|
|
1941
|
+
return;
|
|
1942
|
+
}
|
|
1943
|
+
throw new TypeError(`${path} must contain only finite JSON numbers.`);
|
|
1944
|
+
}
|
|
1945
|
+
if (Array.isArray(value)) {
|
|
1946
|
+
value.forEach((item, index) => assertJsonSafe(item, `${path}[${index}]`));
|
|
1947
|
+
return;
|
|
1948
|
+
}
|
|
1949
|
+
if (typeof value === "object") {
|
|
1950
|
+
for (const [key, item] of Object.entries(value)) {
|
|
1951
|
+
assertJsonSafe(item, `${path}.${key}`);
|
|
1952
|
+
}
|
|
1953
|
+
return;
|
|
1954
|
+
}
|
|
1955
|
+
throw new TypeError(`${path} must be JSON-safe.`);
|
|
1956
|
+
}
|
|
1957
|
+
|
|
1958
|
+
// src/replay.ts
|
|
1959
|
+
function fail(message, code = "TN_REPLAY_INVALID") {
|
|
1960
|
+
throw new Error(`${code}: ${message}`);
|
|
1961
|
+
}
|
|
1962
|
+
function checked(value, allowed) {
|
|
1963
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) fail("bad object");
|
|
1964
|
+
const result = value;
|
|
1965
|
+
const unknown = Object.keys(result).find((key) => !allowed.includes(key));
|
|
1966
|
+
if (unknown !== void 0) fail(`unknown key '${unknown}'`);
|
|
1967
|
+
return result;
|
|
1968
|
+
}
|
|
1969
|
+
function validatePointer(value) {
|
|
1970
|
+
const pointer = Array.isArray(value) ? value : [];
|
|
1971
|
+
if (pointer.length !== 5 || !pointer.every(Number.isFinite) || !Number.isInteger(pointer[2]) || pointer[2] < 0 || Math.min(pointer[3], pointer[4]) <= 0)
|
|
1972
|
+
fail("pointer tuple is invalid");
|
|
1973
|
+
}
|
|
1974
|
+
function parseReplayRecording(value) {
|
|
1975
|
+
const root = checked(value, ["input", "randomState", "runtime", "seed", "ticks", "version"]);
|
|
1976
|
+
if (root.version !== 1 || !Number.isFinite(root.seed) || !Number.isInteger(root.randomState))
|
|
1977
|
+
fail("bad header");
|
|
1978
|
+
const ticks = root.ticks;
|
|
1979
|
+
if (!Number.isInteger(ticks) || ticks < 1) fail("ticks must be positive");
|
|
1980
|
+
const input = root.input;
|
|
1981
|
+
if (!Array.isArray(input) || input.length === 0) fail("empty input", "TN_REPLAY_EMPTY");
|
|
1982
|
+
const runtime = checked(root.runtime, ["agent", "core", "rapier", "step"]);
|
|
1983
|
+
const step = runtime.step;
|
|
1984
|
+
if (typeof runtime.agent !== "string" || !runtime.agent || typeof runtime.core !== "string" || !runtime.core || runtime.rapier !== null && typeof runtime.rapier !== "string" || !Number.isFinite(step) || step <= 0)
|
|
1985
|
+
fail("runtime fingerprint is invalid");
|
|
1986
|
+
let previousTick = -1;
|
|
1987
|
+
for (const rawSample of input) {
|
|
1988
|
+
const sample = checked(rawSample, ["keys", "pointer", "tick"]);
|
|
1989
|
+
const tick = sample.tick;
|
|
1990
|
+
if (!Number.isInteger(tick) || tick <= previousTick || tick >= ticks) fail("bad tick");
|
|
1991
|
+
const keys = sample.keys;
|
|
1992
|
+
if (!Array.isArray(keys) || keys.some((key) => typeof key !== "string")) fail("bad keys");
|
|
1993
|
+
if (new Set(keys).size !== keys.length) fail("duplicate keys");
|
|
1994
|
+
if (sample.pointer !== void 0) validatePointer(sample.pointer);
|
|
1995
|
+
previousTick = tick;
|
|
1996
|
+
}
|
|
1997
|
+
return root;
|
|
1998
|
+
}
|
|
1999
|
+
var PlaytestScenarioError = class extends Error {
|
|
2000
|
+
constructor(diagnostic) {
|
|
2001
|
+
super(diagnostic.message);
|
|
2002
|
+
this.diagnostic = diagnostic;
|
|
2003
|
+
}
|
|
2004
|
+
diagnostic;
|
|
2005
|
+
};
|
|
2006
|
+
async function loadPlaytestScenario(projectPath, scenarioPath) {
|
|
2007
|
+
const absolutePath = resolve(projectPath, scenarioPath);
|
|
2008
|
+
let raw;
|
|
2009
|
+
try {
|
|
2010
|
+
raw = await readFile(absolutePath, "utf8");
|
|
2011
|
+
} catch {
|
|
2012
|
+
throw new PlaytestScenarioError({
|
|
2013
|
+
code: "TN_PLAYTEST_SCENARIO_NOT_FOUND",
|
|
2014
|
+
message: `Playtest scenario '${scenarioPath}' could not be read.`,
|
|
2015
|
+
severity: "error",
|
|
2016
|
+
suggestion: "Check the --scenario path. Committed playtest scenarios normally live under playtests/*.playtest.json."
|
|
2017
|
+
});
|
|
2018
|
+
}
|
|
2019
|
+
let parsed;
|
|
2020
|
+
try {
|
|
2021
|
+
parsed = JSON.parse(raw);
|
|
2022
|
+
} catch (error) {
|
|
2023
|
+
throw new PlaytestScenarioError({
|
|
2024
|
+
code: "TN_PLAYTEST_SCENARIO_INVALID",
|
|
2025
|
+
message: `Playtest scenario '${scenarioPath}' is not valid JSON: ${error instanceof Error ? error.message : String(error)}.`,
|
|
2026
|
+
severity: "error",
|
|
2027
|
+
suggestion: "Fix the scenario JSON syntax and rerun tn playtest."
|
|
2028
|
+
});
|
|
2029
|
+
}
|
|
2030
|
+
const scenario = validatePlaytestScenario(parsed, scenarioPath, absolutePath);
|
|
2031
|
+
return hydrateReachabilityArtifact(projectPath, scenario, scenarioPath);
|
|
2032
|
+
}
|
|
2033
|
+
async function hydrateReachabilityArtifact(projectPath, scenario, scenarioPath) {
|
|
2034
|
+
const assertion = scenario.assert?.reachability;
|
|
2035
|
+
if (assertion === void 0) return scenario;
|
|
2036
|
+
let parsed;
|
|
2037
|
+
try {
|
|
2038
|
+
parsed = JSON.parse(await readFile(resolve(projectPath, assertion.artifact), "utf8"));
|
|
2039
|
+
} catch {
|
|
2040
|
+
throw invalidScenario(scenarioPath, `Reachability artifact '${assertion.artifact}' could not be read as JSON.`);
|
|
2041
|
+
}
|
|
2042
|
+
const envelope = reachabilityEnvelope(parsed);
|
|
2043
|
+
if (envelope === void 0) {
|
|
2044
|
+
throw invalidScenario(scenarioPath, `Reachability artifact '${assertion.artifact}' must contain finite non-negative maxRise, forwardReach, and fallDistanceToGround measurements.`);
|
|
2045
|
+
}
|
|
2046
|
+
return {
|
|
2047
|
+
...scenario,
|
|
2048
|
+
assert: { ...scenario.assert, reachability: { ...assertion, envelope } }
|
|
2049
|
+
};
|
|
2050
|
+
}
|
|
2051
|
+
function reachabilityEnvelope(value) {
|
|
2052
|
+
if (!isRecord2(value)) return void 0;
|
|
2053
|
+
const measurement = isRecord2(value.jump) ? value.jump : value;
|
|
2054
|
+
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;
|
|
2055
|
+
}
|
|
2056
|
+
function oneShotScenario(options) {
|
|
2057
|
+
return {
|
|
2058
|
+
assert: {
|
|
2059
|
+
...options.expectMoved || options.expectAxis !== void 0 ? { movement: { axis: options.expectAxis, entity: options.subject, minDistance: options.expectMoved ? options.movementThreshold : void 0 } } : {},
|
|
2060
|
+
...options.follow === void 0 ? {} : { camera: { entity: options.follow.entityId, follows: options.subject, within: options.follow.within } }
|
|
2061
|
+
},
|
|
2062
|
+
name: `${safeFilePart(options.subject)}-${safeFilePart(options.press)}`,
|
|
2063
|
+
schemaVersion: 1,
|
|
2064
|
+
steps: [{ holdFrames: options.frames, press: options.press, release: true }],
|
|
2065
|
+
subject: options.subject,
|
|
2066
|
+
target: options.target ?? "web",
|
|
2067
|
+
viewport: options.viewport ?? { height: 720, width: 1280 },
|
|
2068
|
+
warmupFrames: 0
|
|
2069
|
+
};
|
|
2070
|
+
}
|
|
2071
|
+
function applyScenarioOverrides(scenario, overrides) {
|
|
2072
|
+
return {
|
|
2073
|
+
...scenario,
|
|
2074
|
+
...overrides.target === void 0 ? {} : { target: overrides.target },
|
|
2075
|
+
...overrides.viewport === void 0 ? {} : { viewport: overrides.viewport }
|
|
2076
|
+
};
|
|
2077
|
+
}
|
|
2078
|
+
function parsePlaytestTarget(value) {
|
|
2079
|
+
if (value === void 0) {
|
|
2080
|
+
return void 0;
|
|
2081
|
+
}
|
|
2082
|
+
return value === "web" || value === "desktop" || value === "bevy" ? value : void 0;
|
|
2083
|
+
}
|
|
2084
|
+
function parseViewport(value) {
|
|
2085
|
+
if (value === void 0) {
|
|
2086
|
+
return void 0;
|
|
2087
|
+
}
|
|
2088
|
+
const match = /^(\d+)x(\d+)$/.exec(value);
|
|
2089
|
+
if (match === null) {
|
|
2090
|
+
return void 0;
|
|
2091
|
+
}
|
|
2092
|
+
const width = Number(match[1]);
|
|
2093
|
+
const height = Number(match[2]);
|
|
2094
|
+
return Number.isInteger(width) && width > 0 && Number.isInteger(height) && height > 0 ? { height, width } : void 0;
|
|
2095
|
+
}
|
|
2096
|
+
function validatePlaytestScenario(value, scenarioPath, absolutePath) {
|
|
2097
|
+
if (!isRecord2(value)) {
|
|
2098
|
+
throw invalidScenario(scenarioPath, "Scenario root must be a JSON object.");
|
|
2099
|
+
}
|
|
2100
|
+
rejectUnknownKeys(value, [
|
|
2101
|
+
"acceptanceId",
|
|
2102
|
+
"artifacts",
|
|
2103
|
+
"assert",
|
|
2104
|
+
"inputDelivery",
|
|
2105
|
+
"name",
|
|
2106
|
+
"parity",
|
|
2107
|
+
"schemaVersion",
|
|
2108
|
+
"setup",
|
|
2109
|
+
"steps",
|
|
2110
|
+
"subject",
|
|
2111
|
+
"target",
|
|
2112
|
+
"viewport",
|
|
2113
|
+
"warmupFrames"
|
|
2114
|
+
], scenarioPath, "scenario root");
|
|
2115
|
+
if (value.schemaVersion !== 1) {
|
|
2116
|
+
throw invalidScenario(scenarioPath, "Scenario schemaVersion must be 1.");
|
|
2117
|
+
}
|
|
2118
|
+
if (value.acceptanceId !== void 0 && (typeof value.acceptanceId !== "string" || value.acceptanceId.length === 0)) {
|
|
2119
|
+
throw invalidScenario(scenarioPath, "Scenario acceptanceId must be a non-empty string when present.");
|
|
2120
|
+
}
|
|
2121
|
+
const name = typeof value.name === "string" ? value.name : void 0;
|
|
2122
|
+
if (name === void 0 || !/^[A-Za-z0-9._-]+$/.test(name)) {
|
|
2123
|
+
throw invalidScenario(scenarioPath, "Scenario name must be a stable file-safe identifier.");
|
|
2124
|
+
}
|
|
2125
|
+
const target = value.target === void 0 ? "web" : value.target;
|
|
2126
|
+
if (target !== "web" && target !== "desktop" && target !== "bevy") {
|
|
2127
|
+
throw invalidScenario(scenarioPath, "Scenario target must be one of: web, desktop, bevy.");
|
|
2128
|
+
}
|
|
2129
|
+
const inputDelivery = value.inputDelivery ?? "deterministic";
|
|
2130
|
+
if (inputDelivery !== "deterministic" && inputDelivery !== "focused-dom") {
|
|
2131
|
+
throw invalidScenario(scenarioPath, "Scenario inputDelivery must be deterministic or focused-dom.");
|
|
2132
|
+
}
|
|
2133
|
+
if (value.assert !== void 0 && !isRecord2(value.assert)) {
|
|
2134
|
+
throw invalidScenario(scenarioPath, "Scenario assert must be a JSON object keyed by supported assertion kinds.");
|
|
2135
|
+
}
|
|
2136
|
+
if (!Array.isArray(value.steps) || value.steps.length === 0) {
|
|
2137
|
+
throw invalidStep(scenarioPath, "Scenario steps[] must contain at least one step.");
|
|
2138
|
+
}
|
|
2139
|
+
const steps = value.steps.map((step, index) => validateStep(step, scenarioPath, index));
|
|
2140
|
+
const assertions = isRecord2(value.assert) ? validateAssertions(value.assert, scenarioPath) : void 0;
|
|
2141
|
+
validateStepLabels(steps, assertions, scenarioPath);
|
|
2142
|
+
return {
|
|
2143
|
+
...typeof value.acceptanceId === "string" ? { acceptanceId: value.acceptanceId } : {},
|
|
2144
|
+
...isRecord2(value.artifacts) ? { artifacts: validateArtifacts(value.artifacts, scenarioPath) } : {},
|
|
2145
|
+
...assertions === void 0 ? {} : { assert: assertions },
|
|
2146
|
+
inputDelivery,
|
|
2147
|
+
name,
|
|
2148
|
+
...isRecord2(value.parity) ? { parity: validateParityConfig(value.parity, scenarioPath) } : {},
|
|
2149
|
+
schemaVersion: 1,
|
|
2150
|
+
...isRecord2(value.setup) ? { setup: validateSetup(value.setup, scenarioPath) } : {},
|
|
2151
|
+
...absolutePath === void 0 ? {} : { sourcePath: absolutePath },
|
|
2152
|
+
steps,
|
|
2153
|
+
...typeof value.subject === "string" ? { subject: value.subject } : {},
|
|
2154
|
+
target,
|
|
2155
|
+
viewport: validateViewport(value.viewport),
|
|
2156
|
+
warmupFrames: positiveInteger(value.warmupFrames) ?? 0
|
|
2157
|
+
};
|
|
2158
|
+
}
|
|
2159
|
+
function validateArtifacts(value, scenarioPath) {
|
|
2160
|
+
rejectUnknownKeys(value, ["console", "contactSheet", "effectLog", "network", "runtimeTrace", "screenshots"], scenarioPath, "artifacts");
|
|
2161
|
+
return value;
|
|
2162
|
+
}
|
|
2163
|
+
function validateParityConfig(value, scenarioPath) {
|
|
2164
|
+
rejectUnknownKeys(value, ["animation", "axisDelta", "compare", "contacts", "movementDistance", "resources", "targets"], scenarioPath, "parity");
|
|
2165
|
+
if (isRecord2(value.compare)) {
|
|
2166
|
+
rejectUnknownKeys(value.compare, ["animation", "axisDelta", "contacts", "movementDistance", "resources"], scenarioPath, "parity.compare");
|
|
2167
|
+
}
|
|
2168
|
+
return {
|
|
2169
|
+
...Array.isArray(value.animation) ? { animation: value.animation.map(validateParityAnimation).filter((item) => item !== void 0) } : {},
|
|
2170
|
+
...isRecord2(value.compare) ? validateParityCompare(value.compare) : validateParityCompare(value),
|
|
2171
|
+
...Array.isArray(value.resources) ? { resources: value.resources.filter((item) => typeof item === "string") } : {},
|
|
2172
|
+
...Array.isArray(value.targets) ? { targets: value.targets.filter((item) => item === "web" || item === "desktop" || item === "bevy") } : {}
|
|
2173
|
+
};
|
|
2174
|
+
}
|
|
2175
|
+
function validateParityCompare(value) {
|
|
2176
|
+
const movementDistance = isRecord2(value.movementDistance) && typeof value.movementDistance.maxDelta === "number" && Number.isFinite(value.movementDistance.maxDelta) ? { maxDelta: value.movementDistance.maxDelta } : void 0;
|
|
2177
|
+
const axisDelta = isRecord2(value.axisDelta) ? Object.fromEntries(Object.entries(value.axisDelta).filter(
|
|
2178
|
+
(entry) => (entry[0] === "x" || entry[0] === "y" || entry[0] === "z") && typeof entry[1] === "number" && Number.isFinite(entry[1])
|
|
2179
|
+
)) : void 0;
|
|
2180
|
+
const contacts = isRecord2(value.contacts) && typeof value.contacts.minSharedCount === "number" && Number.isFinite(value.contacts.minSharedCount) ? { minSharedCount: value.contacts.minSharedCount } : void 0;
|
|
2181
|
+
return {
|
|
2182
|
+
...axisDelta !== void 0 && Object.keys(axisDelta).length > 0 ? { axisDelta } : {},
|
|
2183
|
+
...Array.isArray(value.animation) ? { animation: value.animation.map(validateParityAnimation).filter((item) => item !== void 0) } : {},
|
|
2184
|
+
...contacts === void 0 ? {} : { contacts },
|
|
2185
|
+
...movementDistance === void 0 ? {} : { movementDistance },
|
|
2186
|
+
...Array.isArray(value.resources) ? { resources: value.resources.filter((item) => typeof item === "string") } : {}
|
|
2187
|
+
};
|
|
2188
|
+
}
|
|
2189
|
+
function validateParityAnimation(value) {
|
|
2190
|
+
if (!isRecord2(value) || typeof value.entity !== "string") {
|
|
2191
|
+
return void 0;
|
|
2192
|
+
}
|
|
2193
|
+
return {
|
|
2194
|
+
...typeof value.clip === "string" ? { clip: value.clip } : {},
|
|
2195
|
+
entity: value.entity,
|
|
2196
|
+
...Array.isArray(value.requiredOn) ? { requiredOn: value.requiredOn.filter((item) => item === "web" || item === "desktop" || item === "bevy") } : {}
|
|
2197
|
+
};
|
|
2198
|
+
}
|
|
2199
|
+
function validateSetup(value, scenarioPath) {
|
|
2200
|
+
rejectUnknownKeys(value, ["entities", "resources"], scenarioPath, "setup");
|
|
2201
|
+
return {
|
|
2202
|
+
...Array.isArray(value.entities) ? { entities: value.entities.map((entity, index) => validateSetupEntity(entity, scenarioPath, index)) } : {},
|
|
2203
|
+
...Array.isArray(value.resources) ? { resources: value.resources.map((resource, index) => validateSetupResource(resource, scenarioPath, index)) } : {}
|
|
2204
|
+
};
|
|
2205
|
+
}
|
|
2206
|
+
function validateSetupResource(value, scenarioPath, index) {
|
|
2207
|
+
if (!isRecord2(value) || typeof value.id !== "string" || value.id.length === 0) {
|
|
2208
|
+
throw invalidScenario(scenarioPath, `Scenario setup.resources[${index}] must name a resource id.`);
|
|
2209
|
+
}
|
|
2210
|
+
rejectUnknownKeys(value, ["id", "path", "value"], scenarioPath, `setup.resources[${index}]`);
|
|
2211
|
+
if (!hasKey(value, "value")) {
|
|
2212
|
+
throw invalidScenario(scenarioPath, `Scenario setup.resources[${index}] must define value.`);
|
|
2213
|
+
}
|
|
2214
|
+
if (value.path !== void 0 && (typeof value.path !== "string" || value.path.split(".").some((part) => part.length === 0))) {
|
|
2215
|
+
throw invalidScenario(scenarioPath, `Scenario setup.resources[${index}].path must be a non-empty dot path when present.`);
|
|
2216
|
+
}
|
|
2217
|
+
return {
|
|
2218
|
+
id: value.id,
|
|
2219
|
+
...typeof value.path === "string" ? { path: value.path } : {},
|
|
2220
|
+
value: value.value
|
|
2221
|
+
};
|
|
2222
|
+
}
|
|
2223
|
+
function validateSetupEntity(value, scenarioPath, index) {
|
|
2224
|
+
if (!isRecord2(value) || typeof value.entity !== "string" || value.entity.length === 0) {
|
|
2225
|
+
throw invalidScenario(scenarioPath, `Scenario setup.entities[${index}] must name an entity.`);
|
|
2226
|
+
}
|
|
2227
|
+
rejectUnknownKeys(value, ["entity", "position", "rotation", "scale"], scenarioPath, `setup.entities[${index}]`);
|
|
2228
|
+
const position = validateOptionalNumberTuple(value, "position", 3, scenarioPath, index);
|
|
2229
|
+
const rotation = validateOptionalNumberTuple(value, "rotation", 4, scenarioPath, index);
|
|
2230
|
+
const scale = validateOptionalNumberTuple(value, "scale", 3, scenarioPath, index);
|
|
2231
|
+
if (position === void 0 && rotation === void 0 && scale === void 0) {
|
|
2232
|
+
throw invalidScenario(scenarioPath, `Scenario setup.entities[${index}] must define position, rotation, or scale.`);
|
|
2233
|
+
}
|
|
2234
|
+
return {
|
|
2235
|
+
entity: value.entity,
|
|
2236
|
+
...position === void 0 ? {} : { position },
|
|
2237
|
+
...rotation === void 0 ? {} : { rotation },
|
|
2238
|
+
...scale === void 0 ? {} : { scale }
|
|
2239
|
+
};
|
|
2240
|
+
}
|
|
2241
|
+
function validateStep(value, scenarioPath, index) {
|
|
2242
|
+
if (!isRecord2(value)) {
|
|
2243
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} must be a JSON object.`);
|
|
2244
|
+
}
|
|
2245
|
+
rejectUnknownKeys(value, [
|
|
2246
|
+
"holdFrames",
|
|
2247
|
+
"holdTicks",
|
|
2248
|
+
"kind",
|
|
2249
|
+
"label",
|
|
2250
|
+
"overlayMessage",
|
|
2251
|
+
"pointerPosition",
|
|
2252
|
+
"press",
|
|
2253
|
+
"release",
|
|
2254
|
+
"screenshot",
|
|
2255
|
+
"waitFrames",
|
|
2256
|
+
"waitTicks",
|
|
2257
|
+
"window"
|
|
2258
|
+
], scenarioPath, `steps[${index}]`);
|
|
2259
|
+
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;
|
|
2260
|
+
const overlayMessage = isRecord2(value.overlayMessage) && typeof value.overlayMessage.overlayId === "string" && value.overlayMessage.overlayId.length > 0 && typeof value.overlayMessage.type === "string" && value.overlayMessage.type.length > 0 ? {
|
|
2261
|
+
overlayId: value.overlayMessage.overlayId,
|
|
2262
|
+
payload: value.overlayMessage.payload ?? {},
|
|
2263
|
+
type: value.overlayMessage.type
|
|
2264
|
+
} : void 0;
|
|
2265
|
+
const pointerButtons = isRecord2(value.pointerPosition) && typeof value.pointerPosition.buttons === "number" && Number.isInteger(value.pointerPosition.buttons) && value.pointerPosition.buttons >= 0 ? value.pointerPosition.buttons : void 0;
|
|
2266
|
+
const pointerPosition = isRecord2(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) ? {
|
|
2267
|
+
...pointerButtons === void 0 ? {} : { buttons: pointerButtons },
|
|
2268
|
+
x: value.pointerPosition.x,
|
|
2269
|
+
y: value.pointerPosition.y
|
|
2270
|
+
} : void 0;
|
|
2271
|
+
if (isRecord2(value.overlayMessage)) {
|
|
2272
|
+
rejectUnknownKeys(value.overlayMessage, ["overlayId", "payload", "type"], scenarioPath, `steps[${index}].overlayMessage`);
|
|
2273
|
+
}
|
|
2274
|
+
if (isRecord2(value.pointerPosition)) {
|
|
2275
|
+
rejectUnknownKeys(value.pointerPosition, ["buttons", "x", "y"], scenarioPath, `steps[${index}].pointerPosition`);
|
|
2276
|
+
}
|
|
2277
|
+
const holdFrames = positiveInteger(value.holdFrames);
|
|
2278
|
+
const holdTicks = positiveInteger(value.holdTicks);
|
|
2279
|
+
const waitFrames = positiveInteger(value.waitFrames);
|
|
2280
|
+
const waitTicks = positiveInteger(value.waitTicks);
|
|
2281
|
+
const kind = value.kind === "wait" ? "wait" : value.kind === "input" ? "input" : void 0;
|
|
2282
|
+
const screenshot = typeof value.screenshot === "string" && /^[A-Za-z0-9._-]+$/.test(value.screenshot) ? value.screenshot : void 0;
|
|
2283
|
+
const window = isRecord2(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) ? {
|
|
2284
|
+
operation: value.window.operation,
|
|
2285
|
+
...typeof value.window.width === "number" ? { width: value.window.width } : {},
|
|
2286
|
+
...typeof value.window.height === "number" ? { height: value.window.height } : {}
|
|
2287
|
+
} : void 0;
|
|
2288
|
+
if (isRecord2(value.window)) {
|
|
2289
|
+
rejectUnknownKeys(value.window, ["height", "operation", "width"], scenarioPath, `steps[${index}].window`);
|
|
2290
|
+
}
|
|
2291
|
+
if (value.press !== void 0 && press === void 0) {
|
|
2292
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} press must be a non-empty key or a unique array of non-empty keys.`);
|
|
2293
|
+
}
|
|
2294
|
+
const hasPress = press !== void 0 && (typeof press === "string" || press.length > 0);
|
|
2295
|
+
if (kind === "wait" && hasPress) {
|
|
2296
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} kind wait cannot define press.`);
|
|
2297
|
+
}
|
|
2298
|
+
if (value.overlayMessage !== void 0 && overlayMessage === void 0) {
|
|
2299
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} overlayMessage must define non-empty overlayId and type fields.`);
|
|
2300
|
+
}
|
|
2301
|
+
if (value.pointerPosition !== void 0 && pointerPosition === void 0) {
|
|
2302
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} pointerPosition must define normalized x and y values from 0 through 1.`);
|
|
2303
|
+
}
|
|
2304
|
+
if (value.screenshot !== void 0 && screenshot === void 0) {
|
|
2305
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} screenshot must be a stable file-safe name.`);
|
|
2306
|
+
}
|
|
2307
|
+
if (value.label !== void 0 && (typeof value.label !== "string" || value.label.trim() === "")) {
|
|
2308
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} label must be a non-empty string.`);
|
|
2309
|
+
}
|
|
2310
|
+
if (value.window !== void 0 && window === void 0) {
|
|
2311
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} window must define minimize, restore, or resize with positive width and height.`);
|
|
2312
|
+
}
|
|
2313
|
+
if (press === void 0 && overlayMessage === void 0 && pointerPosition === void 0 && window === void 0 && waitFrames === void 0 && waitTicks === void 0) {
|
|
2314
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} must define press, overlayMessage, pointerPosition, window, or waitFrames/waitTicks.`);
|
|
2315
|
+
}
|
|
2316
|
+
if (value.holdFrames !== void 0 && holdFrames === void 0) {
|
|
2317
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} holdFrames must be a positive integer.`);
|
|
2318
|
+
}
|
|
2319
|
+
if (value.waitFrames !== void 0 && waitFrames === void 0) {
|
|
2320
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} waitFrames must be a positive integer.`);
|
|
2321
|
+
}
|
|
2322
|
+
if (value.holdTicks !== void 0 && holdTicks === void 0) {
|
|
2323
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} holdTicks must be a positive integer.`);
|
|
2324
|
+
}
|
|
2325
|
+
if (value.waitTicks !== void 0 && waitTicks === void 0) {
|
|
2326
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} waitTicks must be a positive integer.`);
|
|
2327
|
+
}
|
|
2328
|
+
if (holdTicks !== void 0 && holdFrames !== void 0) {
|
|
2329
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} must choose holdTicks or holdFrames, not both.`);
|
|
2330
|
+
}
|
|
2331
|
+
if (waitTicks !== void 0 && waitFrames !== void 0) {
|
|
2332
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} must choose waitTicks or waitFrames, not both.`);
|
|
2333
|
+
}
|
|
2334
|
+
if ((holdTicks !== void 0 || waitTicks !== void 0) && (holdFrames !== void 0 || waitFrames !== void 0)) {
|
|
2335
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} must choose frame timing or fixed ticks, not both.`);
|
|
2336
|
+
}
|
|
2337
|
+
return {
|
|
2338
|
+
...kind === void 0 ? {} : { kind },
|
|
2339
|
+
...holdFrames === void 0 ? {} : { holdFrames },
|
|
2340
|
+
...holdTicks === void 0 ? {} : { holdTicks },
|
|
2341
|
+
...typeof value.label === "string" ? { label: value.label } : {},
|
|
2342
|
+
...overlayMessage === void 0 ? {} : { overlayMessage },
|
|
2343
|
+
...pointerPosition === void 0 ? {} : { pointerPosition },
|
|
2344
|
+
...press === void 0 ? {} : { press },
|
|
2345
|
+
release: typeof value.release === "boolean" ? value.release : true,
|
|
2346
|
+
...screenshot === void 0 ? {} : { screenshot },
|
|
2347
|
+
...waitFrames === void 0 ? {} : { waitFrames },
|
|
2348
|
+
...waitTicks === void 0 ? {} : { waitTicks },
|
|
2349
|
+
...window === void 0 ? {} : { window }
|
|
2350
|
+
};
|
|
2351
|
+
}
|
|
2352
|
+
function validateStepLabels(steps, assertions, scenarioPath) {
|
|
2353
|
+
const labels = /* @__PURE__ */ new Set();
|
|
2354
|
+
for (const [index, step] of steps.entries()) {
|
|
2355
|
+
if (step.label === void 0) continue;
|
|
2356
|
+
if (step.label.trim() === "") {
|
|
2357
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} label must be a non-empty string.`);
|
|
2358
|
+
}
|
|
2359
|
+
if (labels.has(step.label)) {
|
|
2360
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} repeats duplicate label '${step.label}'.`);
|
|
2361
|
+
}
|
|
2362
|
+
labels.add(step.label);
|
|
2363
|
+
}
|
|
2364
|
+
if (assertions === void 0) return;
|
|
2365
|
+
const requireLabel = (label, path) => {
|
|
2366
|
+
if (label !== void 0 && !labels.has(label)) {
|
|
2367
|
+
throw invalidScenario(scenarioPath, `Assertion '${path}' names step label '${label}', but no scenario step defines it.`);
|
|
2368
|
+
}
|
|
2369
|
+
};
|
|
2370
|
+
for (const [index, assertion] of (assertions.resources ?? []).entries()) {
|
|
2371
|
+
for (const [stepIndex, step] of (assertion.atSteps ?? []).entries()) {
|
|
2372
|
+
requireLabel(step.label, `assert.resources[${index}].atSteps[${stepIndex}].label`);
|
|
2373
|
+
}
|
|
2374
|
+
}
|
|
2375
|
+
for (const [index, assertion] of (assertions.components ?? []).entries()) {
|
|
2376
|
+
for (const [stepIndex, step] of (assertion.atSteps ?? []).entries()) {
|
|
2377
|
+
requireLabel(step.label, `assert.components[${index}].atSteps[${stepIndex}].label`);
|
|
2378
|
+
}
|
|
2379
|
+
}
|
|
2380
|
+
for (const [index, assertion] of (assertions.signals ?? []).entries()) {
|
|
2381
|
+
requireLabel(assertion.atStep, `assert.signals[${index}].atStep`);
|
|
2382
|
+
}
|
|
2383
|
+
for (const [index, assertion] of (assertions.contacts ?? []).entries()) {
|
|
2384
|
+
requireLabel(assertion.atStep, `assert.contacts[${index}].atStep`);
|
|
2385
|
+
}
|
|
2386
|
+
for (const [index, assertion] of (assertions.settled ?? []).entries()) {
|
|
2387
|
+
requireLabel(assertion.atStep, `assert.settled[${index}].atStep`);
|
|
2388
|
+
requireLabel(assertion.compareToStep, `assert.settled[${index}].compareToStep`);
|
|
2389
|
+
}
|
|
2390
|
+
requireLabel(assertions.movement?.reachesPositionWithin?.atStep, "assert.movement.reachesPositionWithin.atStep");
|
|
2391
|
+
}
|
|
2392
|
+
function playtestStepHoldTicks(step, fallback = 1) {
|
|
2393
|
+
if (step.press === void 0 || step.holdFrames !== void 0 || step.waitFrames !== void 0) return 0;
|
|
2394
|
+
return Math.max(1, step.holdTicks ?? fallback);
|
|
2395
|
+
}
|
|
2396
|
+
function playtestStepWaitTicks(step) {
|
|
2397
|
+
return step.waitFrames === void 0 ? Math.max(0, step.waitTicks ?? 0) : 0;
|
|
2398
|
+
}
|
|
2399
|
+
function validateAssertions(value, scenarioPath) {
|
|
2400
|
+
rejectUnknownKeys(value, PLAYTEST_ASSERTION_REGISTRY.map((entry) => entry.kind), scenarioPath, "assert");
|
|
2401
|
+
validateAssertionShapes(value, scenarioPath);
|
|
2402
|
+
validateAssertionKeys(value, scenarioPath);
|
|
2403
|
+
if (Array.isArray(value.signals) && value.signals.length === 0) {
|
|
2404
|
+
throw invalidScenario(scenarioPath, "Assertion 'assert.signals' must contain at least one signal assertion.");
|
|
2405
|
+
}
|
|
2406
|
+
const movement = isRecord2(value.movement) ? value.movement : void 0;
|
|
2407
|
+
const camera = isRecord2(value.camera) ? value.camera : void 0;
|
|
2408
|
+
const diagnostics = isRecord2(value.diagnostics) ? value.diagnostics : void 0;
|
|
2409
|
+
const world = isRecord2(value.world) ? value.world : void 0;
|
|
2410
|
+
if (diagnostics?.noRuntimeDiagnostics === false && (typeof diagnostics.runtimeDiagnosticsOptOutReason !== "string" || diagnostics.runtimeDiagnosticsOptOutReason.trim() === "")) {
|
|
2411
|
+
throw invalidScenario(
|
|
2412
|
+
scenarioPath,
|
|
2413
|
+
"Assertion 'assert.diagnostics.noRuntimeDiagnostics' may be false only when 'runtimeDiagnosticsOptOutReason' explains the bounded exception."
|
|
2414
|
+
);
|
|
2415
|
+
}
|
|
2416
|
+
return {
|
|
2417
|
+
...Array.isArray(value.aerodynamics) ? { aerodynamics: value.aerodynamics.map(validateAerodynamicsAssertion).filter((item) => item !== void 0) } : {},
|
|
2418
|
+
...Array.isArray(value.animation) ? { animation: value.animation.map(validateAnimationAssertion).filter((item) => item !== void 0) } : {},
|
|
2419
|
+
...camera === void 0 ? {} : {
|
|
2420
|
+
camera: {
|
|
2421
|
+
...typeof camera.entity === "string" ? { entity: camera.entity } : {},
|
|
2422
|
+
...typeof camera.follows === "string" ? { follows: camera.follows } : {},
|
|
2423
|
+
...typeof camera.targetInViewport === "boolean" ? { targetInViewport: camera.targetInViewport } : {},
|
|
2424
|
+
...typeof camera.within === "number" && Number.isFinite(camera.within) ? { within: camera.within } : {}
|
|
2425
|
+
}
|
|
2426
|
+
},
|
|
2427
|
+
...Array.isArray(value.components) ? {
|
|
2428
|
+
components: value.components.map(
|
|
2429
|
+
(entry, index) => validateComponentAssertion(entry, scenarioPath, `assert.components[${index}]`)
|
|
2430
|
+
)
|
|
2431
|
+
} : {},
|
|
2432
|
+
...Array.isArray(value.contacts) ? { contacts: value.contacts.map(validateContactAssertion).filter((item) => item !== void 0) } : {},
|
|
2433
|
+
...diagnostics === void 0 ? {} : {
|
|
2434
|
+
diagnostics: {
|
|
2435
|
+
...typeof diagnostics.noConsoleErrors === "boolean" ? { noConsoleErrors: diagnostics.noConsoleErrors } : {},
|
|
2436
|
+
...typeof diagnostics.noNetworkErrors === "boolean" ? { noNetworkErrors: diagnostics.noNetworkErrors } : {},
|
|
2437
|
+
...typeof diagnostics.noRuntimeDiagnostics === "boolean" ? { noRuntimeDiagnostics: diagnostics.noRuntimeDiagnostics } : {},
|
|
2438
|
+
...typeof diagnostics.runtimeDiagnosticsOptOutReason === "string" ? { runtimeDiagnosticsOptOutReason: diagnostics.runtimeDiagnosticsOptOutReason } : {},
|
|
2439
|
+
...typeof diagnostics.runtimeReady === "boolean" ? { runtimeReady: diagnostics.runtimeReady } : {}
|
|
2440
|
+
}
|
|
2441
|
+
},
|
|
2442
|
+
...Array.isArray(value.hud) ? { hud: value.hud.map(validatePathAssertion).filter((item) => item !== void 0) } : {},
|
|
2443
|
+
...movement === void 0 ? {} : {
|
|
2444
|
+
movement: {
|
|
2445
|
+
...typeof movement.axis === "string" ? { axis: movement.axis } : {},
|
|
2446
|
+
...isRecord2(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 } } : {},
|
|
2447
|
+
...typeof movement.entity === "string" ? { entity: movement.entity } : {},
|
|
2448
|
+
...typeof movement.facesMovementWithinDegrees === "number" && Number.isFinite(movement.facesMovementWithinDegrees) ? { facesMovementWithinDegrees: movement.facesMovementWithinDegrees } : {},
|
|
2449
|
+
...isRecord2(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 } } : {},
|
|
2450
|
+
...isRecord2(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 } } : {},
|
|
2451
|
+
...typeof movement.maxTiltDegrees === "number" && Number.isFinite(movement.maxTiltDegrees) && movement.maxTiltDegrees >= 0 && movement.maxTiltDegrees <= 180 ? { maxTiltDegrees: movement.maxTiltDegrees } : {},
|
|
2452
|
+
...typeof movement.minDistance === "number" && Number.isFinite(movement.minDistance) ? { minDistance: movement.minDistance } : {},
|
|
2453
|
+
...typeof movement.maxDistance === "number" && Number.isFinite(movement.maxDistance) && movement.maxDistance >= 0 ? { maxDistance: movement.maxDistance } : {},
|
|
2454
|
+
...typeof movement.minVelocity === "number" && Number.isFinite(movement.minVelocity) ? { minVelocity: movement.minVelocity } : {},
|
|
2455
|
+
...typeof movement.pathLength === "number" && Number.isFinite(movement.pathLength) && movement.pathLength >= 0 ? { pathLength: movement.pathLength } : {},
|
|
2456
|
+
...isRecord2(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 } } : {},
|
|
2457
|
+
...isRecord2(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 } } : {},
|
|
2458
|
+
...isRecord2(movement.reachesPositionWithin) && validateNumberTuple(movement.reachesPositionWithin.position, 3) !== void 0 && typeof movement.reachesPositionWithin.maxDistance === "number" && Number.isFinite(movement.reachesPositionWithin.maxDistance) ? {
|
|
2459
|
+
reachesPositionWithin: {
|
|
2460
|
+
...typeof movement.reachesPositionWithin.atStep === "string" ? { atStep: movement.reachesPositionWithin.atStep } : {},
|
|
2461
|
+
position: validateNumberTuple(movement.reachesPositionWithin.position, 3),
|
|
2462
|
+
maxDistance: movement.reachesPositionWithin.maxDistance
|
|
2463
|
+
}
|
|
2464
|
+
} : {},
|
|
2465
|
+
...typeof movement.rotationChanged === "boolean" ? { rotationChanged: movement.rotationChanged } : {}
|
|
2466
|
+
}
|
|
2467
|
+
},
|
|
2468
|
+
...Array.isArray(value.occluded) ? { occluded: value.occluded.map(validateOccludedAssertion).filter((item) => item !== void 0) } : {},
|
|
2469
|
+
...Array.isArray(value.overlayNodes) ? {
|
|
2470
|
+
overlayNodes: value.overlayNodes.map(
|
|
2471
|
+
(entry, index) => validateOverlayNodeAssertion(entry, scenarioPath, `assert.overlayNodes[${index}]`)
|
|
2472
|
+
)
|
|
2473
|
+
} : {},
|
|
2474
|
+
...isRecord2(value.reachability) ? { reachability: validateReachabilityAssertion(value.reachability, scenarioPath) } : {},
|
|
2475
|
+
...Array.isArray(value.resources) ? { resources: value.resources.map((item, index) => validateResourcePathAssertion(item, scenarioPath, `assert.resources[${index}]`)) } : {},
|
|
2476
|
+
...Array.isArray(value.settled) ? {
|
|
2477
|
+
settled: value.settled.map(
|
|
2478
|
+
(entry, index) => validateSettledAssertion(entry, scenarioPath, `assert.settled[${index}]`)
|
|
2479
|
+
)
|
|
2480
|
+
} : {},
|
|
2481
|
+
...Array.isArray(value.signals) ? {
|
|
2482
|
+
signals: value.signals.map(
|
|
2483
|
+
(entry, index) => validateSignalAssertion(entry, scenarioPath, `assert.signals[${index}]`)
|
|
2484
|
+
)
|
|
2485
|
+
} : {},
|
|
2486
|
+
...Array.isArray(value.states) ? { states: value.states.map((entry, index) => validateStateAssertion(entry, scenarioPath, `assert.states[${index}]`)) } : {},
|
|
2487
|
+
...Array.isArray(value.tags) ? { tags: value.tags.map((entry, index) => validateTagCountAssertion(entry, scenarioPath, `assert.tags[${index}]`)) } : {},
|
|
2488
|
+
...Array.isArray(value.visibility) ? { visibility: value.visibility.map(validateVisibilityAssertion).filter((item) => item !== void 0) } : {},
|
|
2489
|
+
...Array.isArray(value.visual) ? { visual: value.visual.map(validateVisualAssertion).filter((item) => item !== void 0) } : {},
|
|
2490
|
+
...world === void 0 ? {} : { world: validateWorldAssertion(world, scenarioPath) }
|
|
2491
|
+
};
|
|
2492
|
+
}
|
|
2493
|
+
function validateWorldAssertion(value, scenarioPath) {
|
|
2494
|
+
rejectUnknownKeys(value, ["runtime", "seed"], scenarioPath, "assert.world");
|
|
2495
|
+
if (!hasKey(value, "seed") || value.seed !== null && (typeof value.seed !== "number" || !Number.isFinite(value.seed))) {
|
|
2496
|
+
throw invalidScenario(scenarioPath, "Assertion 'assert.world.seed' must be a finite number or null.");
|
|
2497
|
+
}
|
|
2498
|
+
const runtimeValue = value.runtime;
|
|
2499
|
+
if (runtimeValue === void 0) return { seed: value.seed };
|
|
2500
|
+
const runtime = requireRecord(runtimeValue, scenarioPath, "assert.world.runtime");
|
|
2501
|
+
rejectUnknownKeys(runtime, ["agent", "core", "randomState", "rapier", "step"], scenarioPath, "assert.world.runtime");
|
|
2502
|
+
const randomState = optionalNumber(runtime, "randomState", scenarioPath, "assert.world.runtime");
|
|
2503
|
+
if (randomState === void 0 || !Number.isInteger(randomState)) {
|
|
2504
|
+
throw invalidScenario(scenarioPath, "'assert.world.runtime.randomState' must be an integer.");
|
|
2505
|
+
}
|
|
2506
|
+
const rapier = runtime.rapier;
|
|
2507
|
+
if (rapier !== null && typeof rapier !== "string") {
|
|
2508
|
+
throw invalidScenario(scenarioPath, "'assert.world.runtime.rapier' must be a string or null.");
|
|
2509
|
+
}
|
|
2510
|
+
return {
|
|
2511
|
+
runtime: {
|
|
2512
|
+
agent: requireString(runtime, "agent", scenarioPath, "assert.world.runtime"),
|
|
2513
|
+
core: requireString(runtime, "core", scenarioPath, "assert.world.runtime"),
|
|
2514
|
+
randomState,
|
|
2515
|
+
rapier,
|
|
2516
|
+
step: optionalPositiveNumber(runtime, "step", scenarioPath, "assert.world.runtime") ?? (() => {
|
|
2517
|
+
throw invalidScenario(scenarioPath, "'assert.world.runtime.step' must be a positive number.");
|
|
2518
|
+
})()
|
|
2519
|
+
},
|
|
2520
|
+
seed: value.seed
|
|
2521
|
+
};
|
|
2522
|
+
}
|
|
2523
|
+
function validateReachabilityAssertion(value, scenarioPath) {
|
|
2524
|
+
if (typeof value.artifact !== "string" || value.artifact.trim() === "") {
|
|
2525
|
+
throw invalidScenario(scenarioPath, "Assertion 'assert.reachability.artifact' must be a non-empty project-relative path.");
|
|
2526
|
+
}
|
|
2527
|
+
if (!Array.isArray(value.entities) || value.entities.length < 2 || value.entities.some((entity) => typeof entity !== "string" || entity.trim() === "")) {
|
|
2528
|
+
throw invalidScenario(scenarioPath, "Assertion 'assert.reachability.entities' must contain at least two non-empty entity ids.");
|
|
2529
|
+
}
|
|
2530
|
+
const entities = value.entities;
|
|
2531
|
+
if (entities.some((entity, index) => index > 0 && entity === entities[index - 1])) {
|
|
2532
|
+
throw invalidScenario(scenarioPath, "Assertion 'assert.reachability.entities' must not repeat a consecutive entity id.");
|
|
2533
|
+
}
|
|
2534
|
+
return {
|
|
2535
|
+
artifact: value.artifact,
|
|
2536
|
+
entities
|
|
2537
|
+
};
|
|
2538
|
+
}
|
|
2539
|
+
function validateSettledAssertion(value, scenarioPath, objectPath) {
|
|
2540
|
+
const record2 = requireRecord(value, scenarioPath, objectPath);
|
|
2541
|
+
rejectUnknownKeys(record2, ["atStep", "compareToStep", "entity", "minBodies", "minMeanPoseDistance", "requiredOn"], scenarioPath, objectPath);
|
|
2542
|
+
return {
|
|
2543
|
+
...present("atStep", optionalString(record2, "atStep", scenarioPath, objectPath)),
|
|
2544
|
+
...present("compareToStep", optionalString(record2, "compareToStep", scenarioPath, objectPath)),
|
|
2545
|
+
entity: requireString(record2, "entity", scenarioPath, objectPath),
|
|
2546
|
+
...present("minBodies", optionalPositiveInteger(record2, "minBodies", scenarioPath, objectPath)),
|
|
2547
|
+
...present("minMeanPoseDistance", optionalPositiveNumber(record2, "minMeanPoseDistance", scenarioPath, objectPath)),
|
|
2548
|
+
...present("requiredOn", optionalTargetArray(record2, "requiredOn", scenarioPath, objectPath))
|
|
2549
|
+
};
|
|
2550
|
+
}
|
|
2551
|
+
function validateOverlayNodeAssertion(value, scenarioPath, objectPath) {
|
|
2552
|
+
const record2 = requireRecord(value, scenarioPath, objectPath);
|
|
2553
|
+
rejectUnknownKeys(record2, ["attribute", "equals", "overlayId", "selector", "textIncludes", "visible"], scenarioPath, objectPath);
|
|
2554
|
+
return {
|
|
2555
|
+
...present("attribute", optionalString(record2, "attribute", scenarioPath, objectPath)),
|
|
2556
|
+
// `equals` is deliberately untyped: an overlay node may be compared against any
|
|
2557
|
+
// JSON value, so presence is the only check that can be made here.
|
|
2558
|
+
...hasKey(record2, "equals") ? { equals: record2.equals } : {},
|
|
2559
|
+
overlayId: requireString(record2, "overlayId", scenarioPath, objectPath),
|
|
2560
|
+
selector: requireString(record2, "selector", scenarioPath, objectPath),
|
|
2561
|
+
...present("textIncludes", optionalString(record2, "textIncludes", scenarioPath, objectPath)),
|
|
2562
|
+
...present("visible", optionalBoolean(record2, "visible", scenarioPath, objectPath))
|
|
2563
|
+
};
|
|
2564
|
+
}
|
|
2565
|
+
function validateComponentAssertion(value, scenarioPath, objectPath) {
|
|
2566
|
+
const record2 = requireRecord(value, scenarioPath, objectPath);
|
|
2567
|
+
rejectUnknownKeys(record2, ["allowTrivial", "atSteps", "changed", "component", "entity", "equals", "gte", "path"], scenarioPath, objectPath);
|
|
2568
|
+
return {
|
|
2569
|
+
...record2.atSteps === void 0 ? {} : {
|
|
2570
|
+
atSteps: requireArray(record2, "atSteps", scenarioPath, objectPath).map((step, index) => {
|
|
2571
|
+
const stepPath = `${objectPath}.atSteps[${index}]`;
|
|
2572
|
+
const stepRecord = requireRecord(step, scenarioPath, stepPath);
|
|
2573
|
+
rejectUnknownKeys(stepRecord, ["equals", "label"], scenarioPath, stepPath);
|
|
2574
|
+
return {
|
|
2575
|
+
...hasKey(stepRecord, "equals") ? { equals: stepRecord.equals } : {},
|
|
2576
|
+
label: requireString(stepRecord, "label", scenarioPath, stepPath)
|
|
2577
|
+
};
|
|
2578
|
+
})
|
|
2579
|
+
},
|
|
2580
|
+
...present("changed", optionalBoolean(record2, "changed", scenarioPath, objectPath)),
|
|
2581
|
+
component: requireString(record2, "component", scenarioPath, objectPath),
|
|
2582
|
+
entity: requireString(record2, "entity", scenarioPath, objectPath),
|
|
2583
|
+
...present("allowTrivial", optionalBoolean(record2, "allowTrivial", scenarioPath, objectPath)),
|
|
2584
|
+
// As above: any JSON value is a legal comparison target.
|
|
2585
|
+
...hasKey(record2, "equals") ? { equals: record2.equals } : {},
|
|
2586
|
+
...present("gte", optionalNumber(record2, "gte", scenarioPath, objectPath)),
|
|
2587
|
+
...present("path", optionalString(record2, "path", scenarioPath, objectPath))
|
|
2588
|
+
};
|
|
2589
|
+
}
|
|
2590
|
+
function validateAssertionShapes(value, scenarioPath) {
|
|
2591
|
+
for (const entry of PLAYTEST_ASSERTION_REGISTRY) {
|
|
2592
|
+
const assertionValue = value[entry.kind];
|
|
2593
|
+
if (assertionValue === void 0) {
|
|
2594
|
+
continue;
|
|
2595
|
+
}
|
|
2596
|
+
const valid = entry.cardinality === "array" ? Array.isArray(assertionValue) : isRecord2(assertionValue);
|
|
2597
|
+
if (!valid) {
|
|
2598
|
+
throw invalidScenario(
|
|
2599
|
+
scenarioPath,
|
|
2600
|
+
`Assertion 'assert.${entry.kind}' must be ${entry.cardinality === "array" ? "an array" : "an object"}; the declared assertion cannot be executed.`
|
|
2601
|
+
);
|
|
2602
|
+
}
|
|
2603
|
+
}
|
|
2604
|
+
}
|
|
2605
|
+
function validateAerodynamicsAssertion(value) {
|
|
2606
|
+
if (!isRecord2(value) || typeof value.entity !== "string") return void 0;
|
|
2607
|
+
const controls = Array.isArray(value.controls) ? value.controls.flatMap((control) => isRecord2(control) && typeof control.surface === "string" && (control.sign === "negative" || control.sign === "positive") ? [{
|
|
2608
|
+
...typeof control.minAbs === "number" && Number.isFinite(control.minAbs) && control.minAbs >= 0 ? { minAbs: control.minAbs } : {},
|
|
2609
|
+
sign: control.sign,
|
|
2610
|
+
surface: control.surface
|
|
2611
|
+
}] : []) : void 0;
|
|
2612
|
+
const torques = Array.isArray(value.torques) ? value.torques.flatMap((torque) => isRecord2(torque) && (torque.axis === "x" || torque.axis === "y" || torque.axis === "z") && typeof torque.label === "string" && (torque.sign === "negative" || torque.sign === "positive") ? [{
|
|
2613
|
+
axis: torque.axis,
|
|
2614
|
+
label: torque.label,
|
|
2615
|
+
...typeof torque.minAbs === "number" && Number.isFinite(torque.minAbs) && torque.minAbs >= 0 ? { minAbs: torque.minAbs } : {},
|
|
2616
|
+
...typeof torque.relativeToLabel === "string" ? { relativeToLabel: torque.relativeToLabel } : {},
|
|
2617
|
+
sign: torque.sign
|
|
2618
|
+
}] : []) : void 0;
|
|
2619
|
+
return {
|
|
2620
|
+
...controls === void 0 ? {} : { controls },
|
|
2621
|
+
entity: value.entity,
|
|
2622
|
+
...typeof value.minForceSamples === "number" && Number.isInteger(value.minForceSamples) && value.minForceSamples > 0 ? { minForceSamples: value.minForceSamples } : {},
|
|
2623
|
+
...torques === void 0 ? {} : { torques }
|
|
2624
|
+
};
|
|
2625
|
+
}
|
|
2626
|
+
function validateOccludedAssertion(value) {
|
|
2627
|
+
if (!isRecord2(value)) {
|
|
2628
|
+
return void 0;
|
|
2629
|
+
}
|
|
2630
|
+
return {
|
|
2631
|
+
...typeof value.entity === "string" ? { entity: value.entity } : {},
|
|
2632
|
+
...typeof value.target === "string" ? { target: value.target } : {}
|
|
2633
|
+
};
|
|
2634
|
+
}
|
|
2635
|
+
function validateVisualAssertion(value) {
|
|
2636
|
+
if (!isRecord2(value)) return void 0;
|
|
2637
|
+
const frameDiff = isRecord2(value.frameDiff) ? value.frameDiff : void 0;
|
|
2638
|
+
const region = isRecord2(value.region) ? value.region : void 0;
|
|
2639
|
+
const entityVisible = isRecord2(value.entityVisible) ? value.entityVisible : void 0;
|
|
2640
|
+
const validRegion = region !== void 0 && [region.x, region.y, region.width, region.height].every((item) => typeof item === "number" && Number.isFinite(item));
|
|
2641
|
+
return {
|
|
2642
|
+
...frameDiff === void 0 ? {} : { frameDiff: {
|
|
2643
|
+
...isSafeProjectRelativePng(frameDiff.baselineImage) ? { baselineImage: frameDiff.baselineImage } : {},
|
|
2644
|
+
...typeof frameDiff.minChangedPixelRatio === "number" ? { minChangedPixelRatio: frameDiff.minChangedPixelRatio } : {},
|
|
2645
|
+
...typeof frameDiff.maxChangedPixelRatio === "number" ? { maxChangedPixelRatio: frameDiff.maxChangedPixelRatio } : {}
|
|
2646
|
+
} },
|
|
2647
|
+
...validRegion ? { region: {
|
|
2648
|
+
height: Number(region.height),
|
|
2649
|
+
width: Number(region.width),
|
|
2650
|
+
x: Number(region.x),
|
|
2651
|
+
y: Number(region.y),
|
|
2652
|
+
...typeof region.minNonblankPixelRatio === "number" ? { minNonblankPixelRatio: region.minNonblankPixelRatio } : {},
|
|
2653
|
+
...typeof region.maxLuminance === "number" ? { maxLuminance: region.maxLuminance } : {},
|
|
2654
|
+
...typeof region.minDarkPixelRatio === "number" ? { minDarkPixelRatio: region.minDarkPixelRatio } : {}
|
|
2655
|
+
} } : {},
|
|
2656
|
+
...entityVisible !== void 0 && typeof entityVisible.entity === "string" && typeof entityVisible.minProjectedPixels === "number" ? { entityVisible: {
|
|
2657
|
+
entity: entityVisible.entity,
|
|
2658
|
+
minProjectedPixels: entityVisible.minProjectedPixels,
|
|
2659
|
+
...typeof entityVisible.throughoutFrames === "boolean" ? { throughoutFrames: entityVisible.throughoutFrames } : {}
|
|
2660
|
+
} } : {}
|
|
2661
|
+
};
|
|
2662
|
+
}
|
|
2663
|
+
function isSafeProjectRelativePng(value) {
|
|
2664
|
+
if (typeof value !== "string" || !value.toLowerCase().endsWith(".png") || value.startsWith("/") || /^[A-Za-z]:[\\/]/.test(value)) {
|
|
2665
|
+
return false;
|
|
2666
|
+
}
|
|
2667
|
+
return !value.split(/[\\/]/).includes("..");
|
|
2668
|
+
}
|
|
2669
|
+
function describeValue(value) {
|
|
2670
|
+
if (value === null) return "null";
|
|
2671
|
+
if (Array.isArray(value)) return "an array";
|
|
2672
|
+
if (typeof value === "string") return `the string ${JSON.stringify(value)}`;
|
|
2673
|
+
return `${typeof value} ${JSON.stringify(value) ?? String(value)}`;
|
|
2674
|
+
}
|
|
2675
|
+
function requireRecord(value, scenarioPath, objectPath) {
|
|
2676
|
+
if (!isRecord2(value)) {
|
|
2677
|
+
throw invalidScenario(scenarioPath, `'${objectPath}' must be an object, received ${describeValue(value)}.`);
|
|
2678
|
+
}
|
|
2679
|
+
return value;
|
|
2680
|
+
}
|
|
2681
|
+
function requireArray(value, key, scenarioPath, objectPath) {
|
|
2682
|
+
const raw = value[key];
|
|
2683
|
+
if (!Array.isArray(raw)) {
|
|
2684
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.${key}' must be an array, received ${describeValue(raw)}.`);
|
|
2685
|
+
}
|
|
2686
|
+
return raw;
|
|
2687
|
+
}
|
|
2688
|
+
function requireString(value, key, scenarioPath, objectPath) {
|
|
2689
|
+
const raw = value[key];
|
|
2690
|
+
if (typeof raw !== "string" || raw.trim() === "") {
|
|
2691
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.${key}' must be a non-empty string, received ${describeValue(raw)}.`);
|
|
2692
|
+
}
|
|
2693
|
+
return raw;
|
|
2694
|
+
}
|
|
2695
|
+
function optionalString(value, key, scenarioPath, objectPath) {
|
|
2696
|
+
if (value[key] === void 0) return void 0;
|
|
2697
|
+
return requireString(value, key, scenarioPath, objectPath);
|
|
2698
|
+
}
|
|
2699
|
+
function optionalBoolean(value, key, scenarioPath, objectPath) {
|
|
2700
|
+
const raw = value[key];
|
|
2701
|
+
if (raw === void 0) return void 0;
|
|
2702
|
+
if (typeof raw !== "boolean") {
|
|
2703
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.${key}' must be a boolean, received ${describeValue(raw)}.`);
|
|
2704
|
+
}
|
|
2705
|
+
return raw;
|
|
2706
|
+
}
|
|
2707
|
+
function optionalNumber(value, key, scenarioPath, objectPath) {
|
|
2708
|
+
const raw = value[key];
|
|
2709
|
+
if (raw === void 0) return void 0;
|
|
2710
|
+
if (typeof raw !== "number" || !Number.isFinite(raw)) {
|
|
2711
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.${key}' must be a finite number, received ${describeValue(raw)}.`);
|
|
2712
|
+
}
|
|
2713
|
+
return raw;
|
|
2714
|
+
}
|
|
2715
|
+
function optionalNonNegativeInteger(value, key, scenarioPath, objectPath) {
|
|
2716
|
+
const raw = value[key];
|
|
2717
|
+
if (raw === void 0) return void 0;
|
|
2718
|
+
if (typeof raw !== "number" || !Number.isInteger(raw) || raw < 0) {
|
|
2719
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.${key}' must be a non-negative integer, received ${describeValue(raw)}.`);
|
|
2720
|
+
}
|
|
2721
|
+
return raw;
|
|
2722
|
+
}
|
|
2723
|
+
function optionalPositiveInteger(value, key, scenarioPath, objectPath) {
|
|
2724
|
+
const raw = value[key];
|
|
2725
|
+
if (raw === void 0) return void 0;
|
|
2726
|
+
if (typeof raw !== "number" || !Number.isInteger(raw) || raw <= 0) {
|
|
2727
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.${key}' must be a positive integer, received ${describeValue(raw)}.`);
|
|
2728
|
+
}
|
|
2729
|
+
return raw;
|
|
2730
|
+
}
|
|
2731
|
+
function optionalPositiveNumber(value, key, scenarioPath, objectPath) {
|
|
2732
|
+
const raw = value[key];
|
|
2733
|
+
if (raw === void 0) return void 0;
|
|
2734
|
+
if (typeof raw !== "number" || !Number.isFinite(raw) || raw <= 0) {
|
|
2735
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.${key}' must be a positive number, received ${describeValue(raw)}.`);
|
|
2736
|
+
}
|
|
2737
|
+
return raw;
|
|
2738
|
+
}
|
|
2739
|
+
function optionalTargetArray(value, key, scenarioPath, objectPath) {
|
|
2740
|
+
const raw = value[key];
|
|
2741
|
+
if (raw === void 0) return void 0;
|
|
2742
|
+
if (!Array.isArray(raw)) {
|
|
2743
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.${key}' must be an array of targets, received ${describeValue(raw)}.`);
|
|
2744
|
+
}
|
|
2745
|
+
return raw.map((target, index) => {
|
|
2746
|
+
if (target !== "web" && target !== "desktop" && target !== "bevy") {
|
|
2747
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.${key}[${index}]' must be one of web, desktop, bevy; received ${describeValue(target)}.`);
|
|
2748
|
+
}
|
|
2749
|
+
return target;
|
|
2750
|
+
});
|
|
2751
|
+
}
|
|
2752
|
+
function present(key, value) {
|
|
2753
|
+
return value === void 0 ? {} : { [key]: value };
|
|
2754
|
+
}
|
|
2755
|
+
function validateStateAssertion(value, scenarioPath, objectPath) {
|
|
2756
|
+
const record2 = requireRecord(value, scenarioPath, objectPath);
|
|
2757
|
+
rejectUnknownKeys(record2, ["entity", "equals"], scenarioPath, objectPath);
|
|
2758
|
+
return {
|
|
2759
|
+
entity: requireString(record2, "entity", scenarioPath, objectPath),
|
|
2760
|
+
equals: requireString(record2, "equals", scenarioPath, objectPath)
|
|
2761
|
+
};
|
|
2762
|
+
}
|
|
2763
|
+
function validateTagCountAssertion(value, scenarioPath, objectPath) {
|
|
2764
|
+
const record2 = requireRecord(value, scenarioPath, objectPath);
|
|
2765
|
+
rejectUnknownKeys(record2, ["count", "gte", "tag"], scenarioPath, objectPath);
|
|
2766
|
+
const count = optionalNonNegativeInteger(record2, "count", scenarioPath, objectPath);
|
|
2767
|
+
const gte = optionalNonNegativeInteger(record2, "gte", scenarioPath, objectPath);
|
|
2768
|
+
if (count === void 0 && gte === void 0) {
|
|
2769
|
+
throw invalidScenario(
|
|
2770
|
+
scenarioPath,
|
|
2771
|
+
`'${objectPath}' must declare 'count' or 'gte'; a tag assertion with neither passes on a count of zero.`
|
|
2772
|
+
);
|
|
2773
|
+
}
|
|
2774
|
+
return {
|
|
2775
|
+
...present("count", count),
|
|
2776
|
+
...present("gte", gte),
|
|
2777
|
+
tag: requireString(record2, "tag", scenarioPath, objectPath)
|
|
2778
|
+
};
|
|
2779
|
+
}
|
|
2780
|
+
function validateContactAssertion(value) {
|
|
2781
|
+
if (!isRecord2(value)) {
|
|
2782
|
+
return void 0;
|
|
2783
|
+
}
|
|
2784
|
+
return {
|
|
2785
|
+
...typeof value.atStep === "string" ? { atStep: value.atStep } : {},
|
|
2786
|
+
...typeof value.entity === "string" ? { entity: value.entity } : {},
|
|
2787
|
+
...typeof value.kind === "string" ? { kind: value.kind } : {},
|
|
2788
|
+
...typeof value.maxCount === "number" && Number.isInteger(value.maxCount) && value.maxCount >= 0 ? { maxCount: value.maxCount } : {},
|
|
2789
|
+
...typeof value.minCount === "number" && Number.isFinite(value.minCount) ? { minCount: value.minCount } : {},
|
|
2790
|
+
...Array.isArray(value.requiredOn) ? { requiredOn: value.requiredOn.filter((item) => item === "web" || item === "desktop" || item === "bevy") } : {},
|
|
2791
|
+
...typeof value.with === "string" ? { with: value.with } : {}
|
|
2792
|
+
};
|
|
2793
|
+
}
|
|
2794
|
+
function validateSignalAssertion(value, scenarioPath, objectPath) {
|
|
2795
|
+
const record2 = requireRecord(value, scenarioPath, objectPath);
|
|
2796
|
+
rejectUnknownKeys(record2, ["atStep", "entity", "maxCount", "minCount", "name"], scenarioPath, objectPath);
|
|
2797
|
+
return {
|
|
2798
|
+
...present("atStep", optionalString(record2, "atStep", scenarioPath, objectPath)),
|
|
2799
|
+
...present("entity", optionalString(record2, "entity", scenarioPath, objectPath)),
|
|
2800
|
+
...present("maxCount", optionalNonNegativeInteger(record2, "maxCount", scenarioPath, objectPath)),
|
|
2801
|
+
...present("minCount", optionalNonNegativeInteger(record2, "minCount", scenarioPath, objectPath)),
|
|
2802
|
+
name: requireString(record2, "name", scenarioPath, objectPath)
|
|
2803
|
+
};
|
|
2804
|
+
}
|
|
2805
|
+
function validateAnimationAssertion(value) {
|
|
2806
|
+
if (!isRecord2(value)) {
|
|
2807
|
+
return void 0;
|
|
2808
|
+
}
|
|
2809
|
+
return {
|
|
2810
|
+
...typeof value.advancedFrames === "number" && Number.isFinite(value.advancedFrames) ? { advancedFrames: value.advancedFrames } : {},
|
|
2811
|
+
...typeof value.clip === "string" ? { clip: value.clip } : {},
|
|
2812
|
+
...typeof value.entered === "boolean" ? { entered: value.entered } : {},
|
|
2813
|
+
...typeof value.entity === "string" ? { entity: value.entity } : {}
|
|
2814
|
+
};
|
|
2815
|
+
}
|
|
2816
|
+
function validateVisibilityAssertion(value) {
|
|
2817
|
+
if (!isRecord2(value)) {
|
|
2818
|
+
return void 0;
|
|
2819
|
+
}
|
|
2820
|
+
return {
|
|
2821
|
+
...typeof value.entity === "string" ? { entity: value.entity } : {},
|
|
2822
|
+
...typeof value.maxOffscreenRatio === "number" && Number.isFinite(value.maxOffscreenRatio) ? { maxOffscreenRatio: value.maxOffscreenRatio } : {},
|
|
2823
|
+
...typeof value.minProjectedPixels === "number" && Number.isFinite(value.minProjectedPixels) ? { minProjectedPixels: value.minProjectedPixels } : {},
|
|
2824
|
+
...typeof value.present === "boolean" ? { present: value.present } : {}
|
|
2825
|
+
};
|
|
2826
|
+
}
|
|
2827
|
+
function validatePathAssertion(value) {
|
|
2828
|
+
if (!isRecord2(value) || typeof value.id !== "string") {
|
|
2829
|
+
return void 0;
|
|
2830
|
+
}
|
|
2831
|
+
return {
|
|
2832
|
+
...Array.isArray(value.atSteps) ? { atSteps: value.atSteps.flatMap((step) => isRecord2(step) && typeof step.label === "string" ? [{ ...hasKey(step, "equals") ? { equals: step.equals } : {}, label: step.label, ...typeof step.textIncludes === "string" ? { textIncludes: step.textIncludes } : {} }] : []) } : {},
|
|
2833
|
+
...typeof value.changed === "boolean" ? { changed: value.changed } : {},
|
|
2834
|
+
...typeof value.allowTrivial === "boolean" ? { allowTrivial: value.allowTrivial } : {},
|
|
2835
|
+
...hasKey(value, "equals") ? { equals: value.equals } : {},
|
|
2836
|
+
...typeof value.gte === "number" && Number.isFinite(value.gte) ? { gte: value.gte } : {},
|
|
2837
|
+
id: value.id,
|
|
2838
|
+
...typeof value.path === "string" ? { path: value.path } : {},
|
|
2839
|
+
...typeof value.textIncludes === "string" ? { textIncludes: value.textIncludes } : {},
|
|
2840
|
+
...typeof value.throughoutSteps === "boolean" ? { throughoutSteps: value.throughoutSteps } : {}
|
|
2841
|
+
};
|
|
2842
|
+
}
|
|
2843
|
+
function validateResourcePathAssertion(value, scenarioPath, objectPath) {
|
|
2844
|
+
const record2 = requireRecord(value, scenarioPath, objectPath);
|
|
2845
|
+
if (hasKey(record2, "anyOf")) {
|
|
2846
|
+
rejectUnknownKeys(record2, ["anyOf", "id"], scenarioPath, objectPath);
|
|
2847
|
+
const alternatives = requireArray(record2, "anyOf", scenarioPath, objectPath);
|
|
2848
|
+
if (alternatives.length === 0) {
|
|
2849
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.anyOf' must contain at least one path assertion.`);
|
|
2850
|
+
}
|
|
2851
|
+
return {
|
|
2852
|
+
anyOf: alternatives.map((alternative, index) => validateResourcePathAlternative(
|
|
2853
|
+
alternative,
|
|
2854
|
+
scenarioPath,
|
|
2855
|
+
`${objectPath}.anyOf[${index}]`
|
|
2856
|
+
)),
|
|
2857
|
+
id: requireString(record2, "id", scenarioPath, objectPath)
|
|
2858
|
+
};
|
|
2859
|
+
}
|
|
2860
|
+
const assertion = validatePathAssertion(record2);
|
|
2861
|
+
if (assertion === void 0) {
|
|
2862
|
+
throw invalidScenario(scenarioPath, `'${objectPath}' must name a resource id.`);
|
|
2863
|
+
}
|
|
2864
|
+
return assertion;
|
|
2865
|
+
}
|
|
2866
|
+
function validateResourcePathAlternative(value, scenarioPath, objectPath) {
|
|
2867
|
+
const record2 = requireRecord(value, scenarioPath, objectPath);
|
|
2868
|
+
rejectUnknownKeys(record2, ["changed", "equals", "gte", "path", "textIncludes"], scenarioPath, objectPath);
|
|
2869
|
+
const changed = optionalBoolean(record2, "changed", scenarioPath, objectPath);
|
|
2870
|
+
const gte = optionalNumber(record2, "gte", scenarioPath, objectPath);
|
|
2871
|
+
const textIncludes = optionalString(record2, "textIncludes", scenarioPath, objectPath);
|
|
2872
|
+
if (!hasKey(record2, "equals") && changed === void 0 && gte === void 0 && textIncludes === void 0) {
|
|
2873
|
+
throw invalidScenario(scenarioPath, `'${objectPath}' must declare equals, gte, textIncludes, or changed.`);
|
|
2874
|
+
}
|
|
2875
|
+
return {
|
|
2876
|
+
...present("changed", changed),
|
|
2877
|
+
...hasKey(record2, "equals") ? { equals: record2.equals } : {},
|
|
2878
|
+
...present("gte", gte),
|
|
2879
|
+
path: requireString(record2, "path", scenarioPath, objectPath),
|
|
2880
|
+
...present("textIncludes", textIncludes)
|
|
2881
|
+
};
|
|
2882
|
+
}
|
|
2883
|
+
function validateViewport(value) {
|
|
2884
|
+
if (!isRecord2(value)) {
|
|
2885
|
+
return { height: 720, width: 1280 };
|
|
2886
|
+
}
|
|
2887
|
+
const width = positiveInteger(value.width);
|
|
2888
|
+
const height = positiveInteger(value.height);
|
|
2889
|
+
return width === void 0 || height === void 0 ? { height: 720, width: 1280 } : { height, width };
|
|
2890
|
+
}
|
|
2891
|
+
function invalidScenario(scenarioPath, message) {
|
|
2892
|
+
return new PlaytestScenarioError({
|
|
2893
|
+
code: "TN_PLAYTEST_SCENARIO_INVALID",
|
|
2894
|
+
fix: {
|
|
2895
|
+
docs: "docs/workflows/playtest-proof.md",
|
|
2896
|
+
instruction: "Use playtest schemaVersion 1 with a file-safe name, target, viewport, warmupFrames, and non-empty steps.",
|
|
2897
|
+
snippet: '{ "schemaVersion": 1, "name": "forward-smoke", "target": "web", "viewport": { "width": 1280, "height": 720 }, "warmupFrames": 10, "steps": [{ "kind": "input", "press": "KeyW", "holdTicks": 30, "release": true }] }'
|
|
2898
|
+
},
|
|
2899
|
+
message: `Playtest scenario '${scenarioPath}' is invalid: ${message}`,
|
|
2900
|
+
severity: "error",
|
|
2901
|
+
suggestion: "Use schemaVersion 1 with a file-safe name, a supported target, and non-empty steps."
|
|
2902
|
+
});
|
|
2903
|
+
}
|
|
2904
|
+
function invalidStep(scenarioPath, message) {
|
|
2905
|
+
return new PlaytestScenarioError({
|
|
2906
|
+
code: "TN_PLAYTEST_SCENARIO_STEP_INVALID",
|
|
2907
|
+
fix: {
|
|
2908
|
+
docs: "docs/workflows/playtest-proof.md",
|
|
2909
|
+
instruction: "Give each step either a press with positive holdTicks/holdFrames or a positive waitTicks/waitFrames value; use kind: wait for an explicit no-input interval.",
|
|
2910
|
+
snippet: '{ "kind": "input", "press": "KeyW", "holdTicks": 30, "release": true }'
|
|
2911
|
+
},
|
|
2912
|
+
message: `Playtest scenario '${scenarioPath}' has an invalid step: ${message}`,
|
|
2913
|
+
severity: "error",
|
|
2914
|
+
suggestion: "Each step must define press or waitTicks/waitFrames; holdTicks/holdFrames and waitTicks/waitFrames must be positive integers."
|
|
2915
|
+
});
|
|
2916
|
+
}
|
|
2917
|
+
function positiveInteger(value) {
|
|
2918
|
+
return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : void 0;
|
|
2919
|
+
}
|
|
2920
|
+
function validateOptionalNumberTuple(value, key, length, scenarioPath, index) {
|
|
2921
|
+
if (!hasKey(value, key)) {
|
|
2922
|
+
return void 0;
|
|
2923
|
+
}
|
|
2924
|
+
const tuple = length === 3 ? validateNumberTuple(value[key], 3) : validateNumberTuple(value[key], 4);
|
|
2925
|
+
if (tuple === void 0) {
|
|
2926
|
+
throw invalidScenario(scenarioPath, `Scenario setup.entities[${index}].${key} must be a ${length}-number tuple.`);
|
|
2927
|
+
}
|
|
2928
|
+
return tuple;
|
|
2929
|
+
}
|
|
2930
|
+
function validateNumberTuple(value, length) {
|
|
2931
|
+
if (!Array.isArray(value) || value.length !== length || !value.every((item) => typeof item === "number" && Number.isFinite(item))) {
|
|
2932
|
+
return void 0;
|
|
2933
|
+
}
|
|
2934
|
+
return value;
|
|
2935
|
+
}
|
|
2936
|
+
function safeFilePart(value) {
|
|
2937
|
+
return value.replace(/[^A-Za-z0-9._-]+/g, "-");
|
|
2938
|
+
}
|
|
2939
|
+
function isRecord2(value) {
|
|
2940
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2941
|
+
}
|
|
2942
|
+
function hasKey(value, key) {
|
|
2943
|
+
return Object.prototype.hasOwnProperty.call(value, key);
|
|
2944
|
+
}
|
|
2945
|
+
var ASSERTION_FIELD_TYPE_CHECKS = {
|
|
2946
|
+
"boolean": (value) => typeof value === "boolean",
|
|
2947
|
+
"non-empty string": isNonEmptyString,
|
|
2948
|
+
"non-negative integer": (value) => typeof value === "number" && Number.isInteger(value) && value >= 0,
|
|
2949
|
+
"number": (value) => typeof value === "number" && Number.isFinite(value),
|
|
2950
|
+
"number in [0, 180]": (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= 180,
|
|
2951
|
+
"positive integer": (value) => typeof value === "number" && Number.isInteger(value) && value > 0,
|
|
2952
|
+
"positive number": (value) => typeof value === "number" && Number.isFinite(value) && value > 0,
|
|
2953
|
+
"string": isNonEmptyString
|
|
2954
|
+
};
|
|
2955
|
+
function isNonEmptyString(value) {
|
|
2956
|
+
return typeof value === "string" && value.trim() !== "";
|
|
2957
|
+
}
|
|
2958
|
+
function rejectWrongTypedFields(fields, value, scenarioPath, objectPath) {
|
|
2959
|
+
for (const field of fields) {
|
|
2960
|
+
const check = ASSERTION_FIELD_TYPE_CHECKS[field.type];
|
|
2961
|
+
if (check === void 0 || value[field.name] === void 0) continue;
|
|
2962
|
+
if (!check(value[field.name])) {
|
|
2963
|
+
throw invalidScenario(
|
|
2964
|
+
scenarioPath,
|
|
2965
|
+
`'${objectPath}.${field.name}' must be ${field.type}, received ${describeValue(value[field.name])}.`
|
|
2966
|
+
);
|
|
2967
|
+
}
|
|
2968
|
+
}
|
|
2969
|
+
}
|
|
2970
|
+
function rejectUnknownKeys(value, allowedKeys, scenarioPath, objectPath) {
|
|
2971
|
+
const allowed = new Set(allowedKeys);
|
|
2972
|
+
const unknown = Object.keys(value).find((key) => !allowed.has(key));
|
|
2973
|
+
if (unknown !== void 0) {
|
|
2974
|
+
throw invalidScenario(
|
|
2975
|
+
scenarioPath,
|
|
2976
|
+
`Unknown key '${unknown}' at ${objectPath}.${unknown}. Supported keys: ${[...allowed].sort().join(", ")}.`
|
|
2977
|
+
);
|
|
2978
|
+
}
|
|
2979
|
+
}
|
|
2980
|
+
function validateAssertionKeys(value, scenarioPath) {
|
|
2981
|
+
for (const entry of PLAYTEST_ASSERTION_REGISTRY) {
|
|
2982
|
+
const assertionValue = value[entry.kind];
|
|
2983
|
+
if (assertionValue === void 0) {
|
|
2984
|
+
continue;
|
|
2985
|
+
}
|
|
2986
|
+
const items = Array.isArray(assertionValue) ? assertionValue : [assertionValue];
|
|
2987
|
+
items.forEach((item, index) => {
|
|
2988
|
+
if (!isRecord2(item)) {
|
|
2989
|
+
return;
|
|
2990
|
+
}
|
|
2991
|
+
const suffix = Array.isArray(assertionValue) ? `[${index}]` : "";
|
|
2992
|
+
rejectUnknownKeys(item, entry.fields.map((field) => field.name), scenarioPath, `assert.${entry.kind}${suffix}`);
|
|
2993
|
+
rejectWrongTypedFields(entry.fields, item, scenarioPath, `assert.${entry.kind}${suffix}`);
|
|
2994
|
+
validateNestedAssertionKeys(entry.kind, item, scenarioPath, suffix);
|
|
2995
|
+
});
|
|
2996
|
+
}
|
|
2997
|
+
}
|
|
2998
|
+
function validateNestedAssertionKeys(kind, value, scenarioPath, suffix) {
|
|
2999
|
+
if (kind === "movement") {
|
|
3000
|
+
for (const field of ["minAxisDelta", "minResolvedAxisDelta"]) {
|
|
3001
|
+
if (isRecord2(value[field])) {
|
|
3002
|
+
rejectUnknownKeys(value[field], ["axis", "min"], scenarioPath, `assert.${kind}${suffix}.${field}`);
|
|
3003
|
+
}
|
|
3004
|
+
}
|
|
3005
|
+
}
|
|
3006
|
+
if (kind === "resources" || kind === "hud" || kind === "components") {
|
|
3007
|
+
if (kind === "resources" && hasKey(value, "anyOf")) {
|
|
3008
|
+
rejectUnknownKeys(value, ["anyOf", "id"], scenarioPath, `assert.${kind}${suffix}`);
|
|
3009
|
+
return;
|
|
3010
|
+
}
|
|
3011
|
+
if (Array.isArray(value.atSteps)) {
|
|
3012
|
+
value.atSteps.forEach((step, index) => {
|
|
3013
|
+
if (isRecord2(step)) {
|
|
3014
|
+
rejectUnknownKeys(step, kind === "components" ? ["equals", "label"] : ["equals", "label", "textIncludes"], scenarioPath, `assert.${kind}${suffix}.atSteps[${index}]`);
|
|
3015
|
+
}
|
|
3016
|
+
});
|
|
3017
|
+
}
|
|
3018
|
+
}
|
|
3019
|
+
if (kind === "visual") {
|
|
3020
|
+
const fields = {
|
|
3021
|
+
entityVisible: ["entity", "minProjectedPixels", "throughoutFrames"],
|
|
3022
|
+
frameDiff: ["baselineImage", "maxChangedPixelRatio", "minChangedPixelRatio"],
|
|
3023
|
+
region: ["height", "maxLuminance", "minDarkPixelRatio", "minNonblankPixelRatio", "width", "x", "y"]
|
|
3024
|
+
};
|
|
3025
|
+
for (const [field, keys] of Object.entries(fields)) {
|
|
3026
|
+
if (isRecord2(value[field])) {
|
|
3027
|
+
rejectUnknownKeys(value[field], keys, scenarioPath, `assert.${kind}${suffix}.${field}`);
|
|
3028
|
+
}
|
|
3029
|
+
}
|
|
3030
|
+
}
|
|
3031
|
+
if (kind === "aerodynamics") {
|
|
3032
|
+
const arrays = {
|
|
3033
|
+
controls: ["minAbs", "sign", "surface"],
|
|
3034
|
+
torques: ["axis", "label", "minAbs", "relativeToLabel", "sign"]
|
|
3035
|
+
};
|
|
3036
|
+
for (const [field, keys] of Object.entries(arrays)) {
|
|
3037
|
+
const entries = value[field];
|
|
3038
|
+
if (Array.isArray(entries)) {
|
|
3039
|
+
entries.forEach((item, index) => {
|
|
3040
|
+
if (isRecord2(item)) {
|
|
3041
|
+
rejectUnknownKeys(item, keys, scenarioPath, `assert.${kind}${suffix}.${field}[${index}]`);
|
|
3042
|
+
}
|
|
3043
|
+
});
|
|
3044
|
+
}
|
|
3045
|
+
}
|
|
3046
|
+
}
|
|
3047
|
+
if (kind === "world" && isRecord2(value.runtime)) {
|
|
3048
|
+
rejectUnknownKeys(
|
|
3049
|
+
value.runtime,
|
|
3050
|
+
["agent", "core", "randomState", "rapier", "step"],
|
|
3051
|
+
scenarioPath,
|
|
3052
|
+
`assert.${kind}${suffix}.runtime`
|
|
3053
|
+
);
|
|
3054
|
+
}
|
|
3055
|
+
}
|
|
3056
|
+
|
|
3057
|
+
export { PLAYTEST_ASSERTION_REGISTRY, PLAYTEST_BRIDGE_GLOBAL, PLAYTEST_CAPABILITY_REGISTRY, PLAYTEST_PROTOCOL_LIMITS, PLAYTEST_PROTOCOL_VERSION, PLAYTEST_SETUP_REGISTRY, PlaytestScenarioError, applyScenarioOverrides, assertJsonSafe, evaluateRichPlaytestAssertions, invalidScenario, jsonByteLength, loadPlaytestScenario, missingPlaytestCapabilities, oneShotScenario, overlayNodeObservationKey, parsePlaytestTarget, parseReplayRecording, parseViewport, playtestDiagnostic, playtestStepHoldTicks, playtestStepWaitTicks, rejectUnknownKeys, requiredPlaytestCapabilities, unknownPlaytestCapabilities };
|