@threenative/playtest 0.3.4 → 0.3.6

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.
@@ -0,0 +1,844 @@
1
+ import { PlaytestFramePhase, PlaytestFramePassKind, IPlaytestGeometryCaptureRequest } from './protocol.js';
2
+
3
+ /** Display-referred Rec.709 luminance, quantized to 256 rounded byte bins. */
4
+ interface IToneMetrics {
5
+ readonly mean: number;
6
+ readonly p1: number;
7
+ readonly p50: number;
8
+ readonly p99: number;
9
+ /** Fraction in bin 255 (display white). */
10
+ readonly clipFraction: number;
11
+ /** Fraction in bin 0 (display black). */
12
+ readonly blackFraction: number;
13
+ }
14
+ /** Top-left coordinates in decoded PNG physical pixels; never CSS pixels. */
15
+ interface IToneRegion {
16
+ readonly x: number;
17
+ readonly y: number;
18
+ readonly width: number;
19
+ readonly height: number;
20
+ }
21
+ interface IToneComparison {
22
+ readonly region: IToneRegion;
23
+ readonly metric: keyof IToneMetrics;
24
+ readonly minDelta: number;
25
+ }
26
+ interface IPlaytestToneObservation extends IToneMetrics {
27
+ readonly code: "TN_TONE";
28
+ readonly label: string;
29
+ /** Absent for the convenience before/after captures. */
30
+ readonly atStep?: string;
31
+ }
32
+ /** Regional failures carry an error and omit unmeasured metrics. */
33
+ interface IPlaytestRegionalToneObservation extends Partial<IToneMetrics> {
34
+ readonly code: "TN_TONE";
35
+ readonly label: string;
36
+ readonly atStep?: string;
37
+ readonly assertionIndex: number;
38
+ readonly region: IToneRegion;
39
+ readonly reference?: {
40
+ readonly region: IToneRegion;
41
+ readonly metrics?: IToneMetrics;
42
+ readonly error?: string;
43
+ };
44
+ readonly error?: string;
45
+ }
46
+ type IPlaytestToneCaptureObservation = IPlaytestToneObservation | IPlaytestRegionalToneObservation;
47
+
48
+ type PlaytestTarget = "web" | "desktop" | "bevy";
49
+ type PlaytestInputDelivery = "deterministic" | "focused-dom";
50
+ interface IPlaytestViewport {
51
+ height: number;
52
+ width: number;
53
+ }
54
+ interface IPlaytestPointer {
55
+ buttons?: number;
56
+ id: number;
57
+ x: number;
58
+ y: number;
59
+ }
60
+ interface IPlaytestWheel {
61
+ deltaX?: number;
62
+ deltaY: number;
63
+ /** Normalized viewport point the wheel turns over (both or neither); the viewport centre when absent. */
64
+ x?: number;
65
+ y?: number;
66
+ }
67
+ /** Emulated media features, Playwright's `emulateMedia` vocabulary; an absent key keeps its value. */
68
+ interface IPlaytestMedia {
69
+ colorScheme?: "dark" | "light";
70
+ reducedMotion?: "no-preference" | "reduce";
71
+ }
72
+ type IPlaytestResourceWait = {
73
+ equals: unknown;
74
+ gte?: never;
75
+ id: string;
76
+ lte?: never;
77
+ path: string;
78
+ } | {
79
+ equals?: never;
80
+ gte: number;
81
+ id: string;
82
+ lte?: never;
83
+ path: string;
84
+ } | {
85
+ equals?: never;
86
+ gte?: never;
87
+ id: string;
88
+ lte: number;
89
+ path: string;
90
+ };
91
+ interface IPlaytestStep {
92
+ kind?: "aimAt" | "click" | "input" | "lifecycle" | "wait";
93
+ /** @deprecated Use holdTicks. Fixed-step bridges treat this as a tick alias. */
94
+ holdFrames?: number;
95
+ holdTicks?: number;
96
+ /** A viewport-pixel click target, resolved directly or from a registered entity's bounds. */
97
+ at?: IPlaytestClickTarget;
98
+ label?: string;
99
+ /** Emulate media features from this step on (browser, and the desktop native-css UI). */
100
+ media?: IPlaytestMedia;
101
+ /**
102
+ * One device-lifecycle operation the runner drives through the platform driver, so the phases it
103
+ * then reports are read off the device rather than asserted by the game about itself.
104
+ */
105
+ lifecycle?: IPlaytestLifecycleStep;
106
+ overlayMessage?: {
107
+ overlayId: string;
108
+ payload: unknown;
109
+ type: string;
110
+ };
111
+ pitch?: number;
112
+ pointerPosition?: {
113
+ buttons?: number;
114
+ x: number;
115
+ y: number;
116
+ };
117
+ /** The complete held-pointer set for this step, in arrival order. */
118
+ pointers?: readonly IPlaytestPointer[];
119
+ /** A string presses one key; an array describes the complete held-key set. */
120
+ press?: string | readonly string[];
121
+ release: boolean;
122
+ screenshot?: string;
123
+ /** Runner-native aim: yaw/pitch are computed from the sampled subject position. */
124
+ target?: IPlaytestAimTarget;
125
+ timeoutMs?: number;
126
+ /** @deprecated Use waitTicks. Fixed-step bridges treat this as a tick alias. */
127
+ waitFrames?: number;
128
+ waitForResource?: IPlaytestResourceWait;
129
+ waitTicks?: number;
130
+ /** A browser/native wheel sample; negative DOM deltaY is the conventional toward-user gesture. */
131
+ wheel?: IPlaytestWheel;
132
+ window?: {
133
+ height?: number;
134
+ operation: "minimize" | "resize" | "restore";
135
+ width?: number;
136
+ };
137
+ }
138
+ /** Where an aimAt step points: a world xz position or another registered entity. */
139
+ type IPlaytestAimTarget = {
140
+ entity: string;
141
+ } | {
142
+ x: number;
143
+ z: number;
144
+ };
145
+ /**
146
+ * The device operations a `lifecycle` step names.
147
+ *
148
+ * `rotate` is the only one that carries an argument, and the `?: never` arms are what stop a
149
+ * scenario from writing `{ operation: "background", rotation: 1 }` and having the rotation
150
+ * silently dropped.
151
+ */
152
+ type IPlaytestLifecycleStep = {
153
+ operation: "background";
154
+ rotation?: never;
155
+ } | {
156
+ operation: "foreground";
157
+ rotation?: never;
158
+ } | {
159
+ operation: "rotate";
160
+ rotation: number;
161
+ };
162
+ /**
163
+ * Where a click lands: viewport pixels, a registered entity's screen bounds, or (browser only) the
164
+ * centre of a DOM element by `id` or CSS `selector`. Pixels depend on the page's layout, which
165
+ * depends on the fonts a machine has; an element target does not.
166
+ */
167
+ type IPlaytestClickTarget = {
168
+ entity: string;
169
+ } | {
170
+ element: IPlaytestVisualRegionTarget;
171
+ } | {
172
+ x: number;
173
+ y: number;
174
+ };
175
+ interface IPlaytestMovementAssertion {
176
+ axis?: string;
177
+ closesDistanceToPosition?: {
178
+ position: [number, number, number];
179
+ min: number;
180
+ };
181
+ entity?: string;
182
+ facesMovementWithinDegrees?: number;
183
+ minAxisDelta?: {
184
+ axis: string;
185
+ min: number;
186
+ };
187
+ minResolvedAxisDelta?: {
188
+ axis: string;
189
+ min: number;
190
+ };
191
+ maxTiltDegrees?: number;
192
+ minDistance?: number;
193
+ minVelocity?: number;
194
+ maxDistance?: number;
195
+ pathLength?: number;
196
+ notFacing?: {
197
+ entity: string;
198
+ minDegrees: number;
199
+ };
200
+ notFacingPosition?: {
201
+ position: [number, number, number];
202
+ minDegrees: number;
203
+ };
204
+ reachesPositionWithin?: {
205
+ atStep?: string;
206
+ position: [number, number, number];
207
+ maxDistance: number;
208
+ };
209
+ rotationChanged?: boolean;
210
+ }
211
+ interface IPlaytestCameraAssertion {
212
+ entity?: string;
213
+ follows?: string;
214
+ targetInViewport?: boolean;
215
+ within?: number;
216
+ }
217
+ interface IPlaytestPathAssertion {
218
+ atSteps?: Array<{
219
+ equals?: unknown;
220
+ label: string;
221
+ textIncludes?: string;
222
+ }>;
223
+ changed?: boolean;
224
+ equals?: unknown;
225
+ gte?: number;
226
+ id: string;
227
+ lte?: number;
228
+ allowTrivial?: string;
229
+ path?: string;
230
+ textIncludes?: string;
231
+ throughoutSteps?: boolean;
232
+ /** Require a DOM node to occupy pixels above the page at the sampled viewport centre. */
233
+ visible?: boolean;
234
+ }
235
+ interface IPlaytestResourcePathAlternative {
236
+ changed?: boolean;
237
+ equals?: unknown;
238
+ gte?: number;
239
+ lte?: number;
240
+ path: string;
241
+ textIncludes?: string;
242
+ }
243
+ interface IPlaytestResourcePathAssertion extends IPlaytestPathAssertion {
244
+ anyOf?: never;
245
+ }
246
+ interface IPlaytestResourceAnyOfAssertion {
247
+ anyOf: IPlaytestResourcePathAlternative[];
248
+ atSteps?: never;
249
+ changed?: never;
250
+ equals?: never;
251
+ gte?: never;
252
+ id: string;
253
+ lte?: never;
254
+ allowTrivial?: never;
255
+ path?: never;
256
+ textIncludes?: never;
257
+ throughoutSteps?: never;
258
+ }
259
+ type IPlaytestResourceAssertion = IPlaytestResourceAnyOfAssertion | IPlaytestResourcePathAssertion;
260
+ interface IPlaytestComponentAssertion extends Omit<IPlaytestPathAssertion, "id" | "textIncludes" | "throughoutSteps"> {
261
+ component: string;
262
+ entity: string;
263
+ }
264
+ interface IPlaytestContactAssertion {
265
+ atStep?: string;
266
+ entity?: string;
267
+ kind?: string;
268
+ maxCount?: number;
269
+ minCount?: number;
270
+ requiredOn?: PlaytestTarget[];
271
+ with?: string;
272
+ }
273
+ interface IPlaytestSignalAssertion {
274
+ atStep?: string;
275
+ entity?: string;
276
+ maxCount?: number;
277
+ minCount?: number;
278
+ name: string;
279
+ }
280
+ interface IPlaytestSettledAssertion {
281
+ atStep?: string;
282
+ allowTrivial?: string;
283
+ compareToStep?: string;
284
+ entity?: string;
285
+ minBodies?: number;
286
+ minMeanPoseDistance?: number;
287
+ requiredOn?: PlaytestTarget[];
288
+ }
289
+ interface IPlaytestOccludedAssertion {
290
+ allowTrivial?: string;
291
+ entity?: string;
292
+ target?: string;
293
+ }
294
+ interface IPlaytestOverlayNodeAssertion {
295
+ attribute?: string;
296
+ equals?: unknown;
297
+ overlayId: string;
298
+ selector: string;
299
+ textIncludes?: string;
300
+ visible?: boolean;
301
+ }
302
+ /**
303
+ * Bounds on the room the game is played in — what a screenshot would have shown, as numbers.
304
+ *
305
+ * Every member fails closed on an unobserved scene: a bridge that does not report `scene.observe`
306
+ * has not reported a well-lit one.
307
+ */
308
+ interface IPlaytestSceneAssertion {
309
+ allowTrivial?: string;
310
+ /** Fail when the camera's far plane cuts the scene it is pointed at. */
311
+ cameraClearsScene?: boolean;
312
+ /** Fail when a linear fog reaches full colour in front of the scene it is fogging. */
313
+ fogClearsScene?: boolean;
314
+ /** Fail when lit materials are mounted and no light in the scene is visible. */
315
+ litMaterialsAreLit?: boolean;
316
+ /** Floor on how many lights the renderer will actually see. */
317
+ minVisibleLights?: number;
318
+ }
319
+ /**
320
+ * Bounds on named nodes of the scene graph — the questions a screenshot gets taken for.
321
+ *
322
+ * `scene` bounds the room as a whole: is anything lit, does the fog clear the world. This bounds
323
+ * one object: is the crate where the game says it is, is it inside the camera's frustum, did its
324
+ * texture load, is the character's mesh actually visible once every ancestor's flag is taken into
325
+ * account. Each is a frame-destroying failure that leaves every count healthy.
326
+ *
327
+ * `select` is required and every other member is optional, but an assertion that sets only
328
+ * `select` throws at load: selecting nodes and bounding nothing is the vacuous pass this package
329
+ * refuses. Every bound fails closed — a run whose bridge reported no scene nodes has not reported
330
+ * a visible crate, it has reported nothing.
331
+ */
332
+ interface IPlaytestSceneNodesAssertion {
333
+ allowTrivial?: string;
334
+ /** Require every matched node to have at least one clip mounted, or none to. */
335
+ animated?: boolean;
336
+ /** Require every matched node's world bounds to intersect the active camera's frustum. */
337
+ inFrustum?: boolean;
338
+ /** Ceiling on how many nodes the selector may match. Zero asserts absence. */
339
+ maxCount?: number;
340
+ /** Floor on how many nodes the selector must match. Defaults to 1 when absent. */
341
+ minCount?: number;
342
+ /** Floor on the summed triangle count of every matched node. */
343
+ minTriangles?: number;
344
+ /** Which nodes to bound. A selector that matches fewer than `minCount` fails. */
345
+ select: IPlaytestSceneNodeSelectorSpec;
346
+ /** Require every bound texture slot on every matched node to carry pixels. */
347
+ texturesLoaded?: boolean;
348
+ /** Require every matched node to be visible with every ancestor visible too. */
349
+ visible?: boolean;
350
+ }
351
+ /**
352
+ * Which nodes an assertion is about. Every present field must match; an absent field does not
353
+ * filter. At least one field is required — a selector that filters nothing selects the whole
354
+ * scene graph and bounds nothing in particular.
355
+ */
356
+ interface IPlaytestSceneNodeSelectorSpec {
357
+ limit?: number;
358
+ name?: string;
359
+ nameContains?: string;
360
+ pathContains?: string;
361
+ type?: string;
362
+ }
363
+ /**
364
+ * "It happened **because** of that, and never before it."
365
+ *
366
+ * The one sentence a proof of a physics puzzle actually has to make, and the one this harness
367
+ * could not make. A run could already say *a contact happened* and *the state reads `won`*, and
368
+ * `atSteps` could order them at step boundaries — where a win arriving one tick after the contact
369
+ * and a win arriving 199 ticks later inside the same step are the same observation. That is the
370
+ * signature of a terminal state driven by a timer or a distance check that merely lands near a
371
+ * contact, and it is what a sealed proof exists to refuse.
372
+ *
373
+ * Both sides are tick-stamped by the producer. A run whose contacts or transitions carry no ticks
374
+ * fails closed and names which side was unstamped; it never falls back to step granularity, which
375
+ * is a different measurement wearing the same name.
376
+ */
377
+ interface IPlaytestCausedByAssertion {
378
+ allowTrivial?: string;
379
+ cause: IPlaytestCauseSpec;
380
+ effect: IPlaytestEffectSpec;
381
+ /**
382
+ * Fail when the effect is ever observed before the first matching cause. This is the frame-one
383
+ * fake win: a goal volume overlapping the floor reports `won` before anything touched it.
384
+ */
385
+ neverBefore?: boolean;
386
+ /** Ceiling on `effectTick - causeTick`. A win long after the contact was not caused by it. */
387
+ withinTicks?: number;
388
+ }
389
+ /** What must have happened first. */
390
+ interface IPlaytestCauseSpec {
391
+ contact?: {
392
+ entity: string;
393
+ kind?: string;
394
+ with: string;
395
+ };
396
+ /** A published value reaching a given value, named the same way an effect is. */
397
+ transition?: IPlaytestEffectSpec;
398
+ }
399
+ /** The published value whose change is being explained. */
400
+ interface IPlaytestEffectSpec {
401
+ /** `states.<entity>` or `state.<field>`, exactly as the transition log reports it. */
402
+ path: string;
403
+ /** The value the path must reach. */
404
+ becomes: boolean | number | string;
405
+ }
406
+ interface IPlaytestAnimationAssertion {
407
+ advancedFrames?: number;
408
+ allowTrivial?: string;
409
+ clip?: string;
410
+ entered?: boolean;
411
+ entity?: string;
412
+ finished?: boolean;
413
+ /**
414
+ * Ceiling on |feet − ground| / ground for the observed clip. A run whose producer reports no
415
+ * stride fails closed: the convention is on by default, so silence is a missing observation,
416
+ * not agreement.
417
+ */
418
+ maxFootSlide?: number;
419
+ /** Require the stride convention to be applied (`true`) or deliberately overridden (`false`). */
420
+ strideSynced?: boolean;
421
+ }
422
+ interface IPlaytestTagCountAssertion {
423
+ allowTrivial?: string;
424
+ count?: number;
425
+ gte?: number;
426
+ lte?: number;
427
+ tag: string;
428
+ }
429
+ interface IPlaytestStateAssertion {
430
+ allowTrivial?: string;
431
+ entity?: string;
432
+ equals: string;
433
+ }
434
+ interface IPlaytestVisibilityAssertion {
435
+ allowTrivial?: string;
436
+ entity?: string;
437
+ maxOffscreenRatio?: number;
438
+ minProjectedPixels?: number;
439
+ present?: boolean;
440
+ }
441
+ interface IPlaytestDiagnosticsAssertion {
442
+ noConsoleErrors?: boolean;
443
+ noNetworkErrors?: boolean;
444
+ noRuntimeDiagnostics?: boolean;
445
+ consoleErrorsOptOutReason?: string;
446
+ networkErrorsOptOutReason?: string;
447
+ runtimeDiagnosticsOptOutReason?: string;
448
+ runtimeReady?: boolean;
449
+ }
450
+ interface IPlaytestPerformanceAssertion {
451
+ maxDrawCalls?: number;
452
+ maxFrameMsP95?: number;
453
+ maxTriangles?: number;
454
+ /** Frame-budget floor: the median presented frame must sustain at least this many frames a second. */
455
+ minFps?: number;
456
+ /**
457
+ * Per-phase ceilings in milliseconds, nearest-rank p95 across the sampled frames. The phase
458
+ * names are the engine's frame-budget phases: hostGap, update, render, overlay, residual.
459
+ */
460
+ maxPhaseMsP95?: Readonly<Partial<Record<PlaytestFramePhase, number>>>;
461
+ /**
462
+ * Per-pass draw-call ceilings, keyed by pass kind: main, shadow, reflection, nested. The bound
463
+ * is the largest draw count that kind submitted in a sampled frame, so a shadow lane folded into
464
+ * the whole-frame `maxDrawCalls` is bounded on its own.
465
+ */
466
+ maxPassDrawCalls?: Readonly<Partial<Record<PlaytestFramePassKind, number>>>;
467
+ /** Per-pass triangle ceilings, keyed by pass kind: main, shadow, reflection, nested. */
468
+ maxPassTriangles?: Readonly<Partial<Record<PlaytestFramePassKind, number>>>;
469
+ }
470
+ /** The stage expectations a render-chain assertion can hold, without its own per-adapter branches. */
471
+ interface IPlaytestRenderChainExpectation {
472
+ contributions?: {
473
+ graphOutputChanged: string[];
474
+ };
475
+ tier?: "high" | "medium" | "low" | "off";
476
+ stages?: {
477
+ includes?: string[];
478
+ excludes?: string[];
479
+ /** Ordered subsequence of applied stage ids, not necessarily the complete chain. */
480
+ order?: string[];
481
+ };
482
+ velocity?: {
483
+ maxRejectionFraction: number;
484
+ };
485
+ }
486
+ interface IPlaytestRenderChainAssertion extends IPlaytestRenderChainExpectation {
487
+ /**
488
+ * What the chain must look like on each adapter the run's own `adapter.info` classified, chosen
489
+ * by the harness's software-adapter detector rather than by anything the game reported. A lane
490
+ * whose adapter cannot be classified is a failed observation, not a hardware one: a missing
491
+ * branch is not a licence to pass.
492
+ */
493
+ perAdapter?: Partial<Record<PlaytestAdapterClass | PlaytestGpuFamily, IPlaytestRenderChainExpectation>>;
494
+ }
495
+ /** What the harness read out of `adapter.info` for this run, before any game code answered. */
496
+ type PlaytestAdapterClass = "hardware" | "software";
497
+ /**
498
+ * The GPU family the same `adapter.info` fields prove on a hardware run. A family row beside
499
+ * `hardware` is how a scenario holds an iGPU or a phone to the tier a template starts that family
500
+ * at; it overrides `hardware` only when the observed fields prove the family.
501
+ */
502
+ declare const PLAYTEST_GPU_FAMILIES: readonly ["discrete", "integrated", "mobile-high", "mobile-low", "mobile-mid"];
503
+ type PlaytestGpuFamily = (typeof PLAYTEST_GPU_FAMILIES)[number];
504
+ /** Ceilings on the application's startup milestones, in milliseconds since navigation. */
505
+ interface IPlaytestStartupAssertion {
506
+ /** The start scene's `enter()` returned: a controllable world exists. */
507
+ maxEnteredMs?: number;
508
+ /** First-use compilation settled or its budget expired. */
509
+ maxCompileSettledMs?: number;
510
+ /** `whenReady()` resolved: the world is safe to show. */
511
+ maxReadyMs?: number;
512
+ }
513
+ /** Ceilings on work observed after the runtime's explicit shader warm-up settled. */
514
+ interface IPlaytestPipelineCensusAssertion {
515
+ maxNodeBuildsAfterWarmUpSettled?: number;
516
+ maxRenderPipelineCreationsAfterWarmUpSettled?: number;
517
+ warmUpScope?: string;
518
+ maxNodeBuildsAfterWarmUpScope?: number;
519
+ maxRenderPipelineCreationsAfterWarmUpScope?: number;
520
+ }
521
+ interface IPlaytestFramebufferCoverageAssertion {
522
+ backdrop: [number, number, number];
523
+ grid?: {
524
+ columns: number;
525
+ rows: number;
526
+ };
527
+ tolerance: number;
528
+ window: {
529
+ endStep: string;
530
+ startStep: string;
531
+ };
532
+ }
533
+ interface IPlaytestVisualRegionTarget {
534
+ id?: string;
535
+ selector?: string;
536
+ }
537
+ interface IPlaytestVisualRegionBounds {
538
+ height: number;
539
+ width: number;
540
+ x: number;
541
+ y: number;
542
+ }
543
+ interface IPlaytestVisualRegionThresholds {
544
+ maxDarkPixelRatio?: number;
545
+ maxLuminance?: number;
546
+ minDarkPixelRatio?: number;
547
+ minNonblankPixelRatio?: number;
548
+ }
549
+ interface IPlaytestVisualStaticRegion extends IPlaytestVisualRegionBounds, IPlaytestVisualRegionThresholds {
550
+ }
551
+ interface IPlaytestVisualElementRegion extends IPlaytestVisualRegionThresholds {
552
+ element: IPlaytestVisualRegionTarget;
553
+ }
554
+ type IPlaytestVisualRegion = IPlaytestVisualStaticRegion | IPlaytestVisualElementRegion;
555
+ interface IPlaytestVisualAssertion {
556
+ entityVisible?: {
557
+ entity: string;
558
+ minProjectedPixels: number;
559
+ throughoutFrames?: boolean;
560
+ };
561
+ frameDiff?: {
562
+ baselineImage?: string;
563
+ maxChangedPixelRatio?: number;
564
+ minChangedPixelRatio?: number;
565
+ };
566
+ region?: IPlaytestVisualRegion;
567
+ }
568
+ interface IPlaytestAerodynamicsAssertion {
569
+ controls?: Array<{
570
+ minAbs?: number;
571
+ sign: "negative" | "positive";
572
+ surface: string;
573
+ }>;
574
+ entity: string;
575
+ minForceSamples?: number;
576
+ torques?: Array<{
577
+ axis: "x" | "y" | "z";
578
+ label: string;
579
+ minAbs?: number;
580
+ relativeToLabel?: string;
581
+ sign: "negative" | "positive";
582
+ }>;
583
+ }
584
+ interface IPlaytestReachabilityAssertion {
585
+ artifact: string;
586
+ entities: string[];
587
+ /** Loaded from artifact by loadPlaytestScenario; not authored in scenario JSON. */
588
+ envelope?: {
589
+ fallDistanceToGround: number;
590
+ forwardReach: number;
591
+ maxRise: number;
592
+ };
593
+ }
594
+ interface IPlaytestWorldRuntimeAssertion {
595
+ agent: string;
596
+ core: string;
597
+ portable?: boolean;
598
+ randomState: number;
599
+ rapier: string | null;
600
+ step: number;
601
+ }
602
+ interface IPlaytestWorldAssertion {
603
+ runtime?: IPlaytestWorldRuntimeAssertion;
604
+ seed: number | null;
605
+ }
606
+ /**
607
+ * Thermal, power and battery state measured around the run itself. Its point is comparability:
608
+ * a run that started hot, or whose thermal status rose while it ran, is not evidence against a
609
+ * cool baseline, and this is how a scenario says so out loud.
610
+ */
611
+ interface IPlaytestDeviceMetricsAssertion {
612
+ /** Ceiling on the battery temperature climb from the first to the last sample, in °C. */
613
+ maxTemperatureRiseC?: number;
614
+ /** Ceiling on the highest Android thermal status observed during the run (0 is NONE). */
615
+ maxThermalStatus?: number;
616
+ /** Requires a run the harness judged comparable with a cool one. */
617
+ notThermallyConfounded?: boolean;
618
+ }
619
+ /**
620
+ * What the game actually played, by cue label.
621
+ *
622
+ * Every other audio check in this repository is about a *file* — it exists, it decodes, it is
623
+ * inside its byte budget, its loop seam is clean. All of them stay green while a game says its
624
+ * one-shot general-quarters call a second time in the middle of a match, or plays the same line
625
+ * twice at once, because neither is a property of the clip. This reads the runtime ledger
626
+ * (`runtime.audio`), which a game fills by passing `cue` to `AudioBus.play`/`playAt`.
627
+ */
628
+ interface IPlaytestAudioAssertion {
629
+ /** The cue label the game passed. */
630
+ cue: string;
631
+ /** Fewest times it must have sounded. Defaults to 1, so naming a cue asserts it was heard. */
632
+ minPlays?: number;
633
+ /** Most times it may have sounded. `0` proves silence; `1` proves a one-shot stayed one. */
634
+ maxPlays?: number;
635
+ /**
636
+ * Fewest milliseconds that must separate this cue from the cue before it.
637
+ *
638
+ * One loudspeaker cannot say two things at once. A game whose urgent line cuts another 250 ms
639
+ * in sounds broken rather than urgent, and nothing but the gap between two plays shows it.
640
+ */
641
+ minGapMs?: number;
642
+ }
643
+ interface IPlaytestToneAssertion extends Partial<Record<keyof IToneMetrics, {
644
+ min?: number;
645
+ max?: number;
646
+ }>> {
647
+ region?: IToneRegion;
648
+ compare?: IToneComparison;
649
+ /** Omit to bound the final capture, otherwise capture after this named step. */
650
+ atStep?: string;
651
+ }
652
+ interface IPlaytestScenarioAssertions {
653
+ tone?: IPlaytestToneAssertion[];
654
+ aerodynamics?: IPlaytestAerodynamicsAssertion[];
655
+ audio?: IPlaytestAudioAssertion[];
656
+ animation?: IPlaytestAnimationAssertion[];
657
+ camera?: IPlaytestCameraAssertion;
658
+ components?: IPlaytestComponentAssertion[];
659
+ contacts?: IPlaytestContactAssertion[];
660
+ deviceMetrics?: IPlaytestDeviceMetricsAssertion;
661
+ diagnostics?: IPlaytestDiagnosticsAssertion;
662
+ framebufferCoverage?: IPlaytestFramebufferCoverageAssertion;
663
+ /**
664
+ * Arms one per-object geometry capture and reports it as the `geometry` observation. This is a
665
+ * request rather than a comparison: it bounds nothing, and the report is read from
666
+ * `observations.geometry`, exactly as `pipelineCensus` is read from `observations.pipelineCensus`.
667
+ */
668
+ geometry?: IPlaytestGeometryCaptureRequest;
669
+ hud?: IPlaytestPathAssertion[];
670
+ movement?: IPlaytestMovementAssertion;
671
+ occluded?: IPlaytestOccludedAssertion[];
672
+ overlayNodes?: IPlaytestOverlayNodeAssertion[];
673
+ parity?: IPlaytestParityAssertion;
674
+ performance?: IPlaytestPerformanceAssertion;
675
+ pipelineCensus?: IPlaytestPipelineCensusAssertion;
676
+ renderChain?: IPlaytestRenderChainAssertion;
677
+ reachability?: IPlaytestReachabilityAssertion;
678
+ resources?: IPlaytestResourceAssertion[];
679
+ settled?: IPlaytestSettledAssertion[];
680
+ signals?: IPlaytestSignalAssertion[];
681
+ scene?: IPlaytestSceneAssertion;
682
+ causedBy?: IPlaytestCausedByAssertion[];
683
+ sceneNodes?: IPlaytestSceneNodesAssertion[];
684
+ startup?: IPlaytestStartupAssertion;
685
+ states?: IPlaytestStateAssertion[];
686
+ tags?: IPlaytestTagCountAssertion[];
687
+ visibility?: IPlaytestVisibilityAssertion[];
688
+ visual?: IPlaytestVisualAssertion[];
689
+ world?: IPlaytestWorldAssertion;
690
+ }
691
+ interface IPlaytestParityConfig {
692
+ animation?: Array<{
693
+ clip?: string;
694
+ entity: string;
695
+ requiredOn?: PlaytestTarget[];
696
+ }>;
697
+ axisDelta?: Partial<Record<"x" | "y" | "z", number>>;
698
+ contacts?: {
699
+ minSharedCount?: number;
700
+ };
701
+ movementDistance?: {
702
+ maxDelta: number;
703
+ };
704
+ resources?: string[];
705
+ targets?: PlaytestTarget[];
706
+ }
707
+ /** What the parity reference's saved run report yielded, extracted at scenario load. */
708
+ interface IPlaytestParityReference {
709
+ /** Frames per second of the reference run: 1000 ÷ the median frame time of its series. */
710
+ fps: number;
711
+ /** Render-phase p95 of the reference run, when its series carries the phase split. */
712
+ renderP95?: number;
713
+ /** The device the reference run executed on, when it measured one. */
714
+ serial?: string;
715
+ /** The reference run's own thermal verdict, when it measured one. */
716
+ thermallyConfounded?: boolean;
717
+ }
718
+ /**
719
+ * PRD-222 Tier 2: the same scene on the same device, twice — once in the platform's browser,
720
+ * once on the native host. The assertion lives in the second run of the pair and names the
721
+ * first run's saved report.
722
+ *
723
+ * It proves what the artifacts can prove: the same device (both halves' `deviceMetrics.serial`),
724
+ * a thermally comparable pair, and the directed fps ratio. Which scene the reference ran is the
725
+ * pair protocol the operator owns — the report format carries no scene identity — so this
726
+ * assertion never claims it did.
727
+ */
728
+ interface IPlaytestParityAssertion {
729
+ /** Floor on nativeFps ÷ webFps. Tier 2's Floor is 0.85; Target 0.95. */
730
+ minFpsRatio: number;
731
+ /** Optional floor on the inverted render-phase p95 ratio; fails closed when either side's series lacks the split. */
732
+ minRenderParity?: number;
733
+ /** Path to the other half's saved run report JSON, resolved against the project. */
734
+ referenceReport: string;
735
+ /** Which side of the pair the reference report is; the directed ratio needs it. */
736
+ referenceSide: "browser" | "native";
737
+ /** Hydrated from the reference report at scenario load; never set by hand. */
738
+ reference?: IPlaytestParityReference;
739
+ }
740
+ interface IPlaytestArtifactRequest {
741
+ console?: boolean;
742
+ contactSheet?: boolean;
743
+ effectLog?: "focused" | boolean;
744
+ network?: boolean;
745
+ runtimeTrace?: boolean;
746
+ /** `true` captures like `"after"`; only `false` and `"before-after"` change the runner. */
747
+ screenshots?: "before-after" | "after" | boolean;
748
+ }
749
+ interface IPlaytestSetupEntityTransform {
750
+ entity: string;
751
+ position?: [number, number, number];
752
+ rotation?: [number, number, number, number];
753
+ scale?: [number, number, number];
754
+ }
755
+ /** Overrides the subject player start. y is optional and preserves the game's own height when absent. */
756
+ interface IPlaytestSpawnRequest {
757
+ x: number;
758
+ y?: number;
759
+ z: number;
760
+ }
761
+ /** Overrides the subject player-start aim; both angles are radians (Three.js convention). */
762
+ interface IPlaytestAimRequest {
763
+ pitch: number;
764
+ yaw: number;
765
+ }
766
+ /**
767
+ * Places a named entity at an explicit world transform before input. Orientation comes
768
+ * from facing yaw or a lookAt point (never both); frozen delivers the placed-frozen
769
+ * marker the game reads to suppress physics motion — placement is data, not teleports.
770
+ */
771
+ interface IPlaytestPlaceRequest {
772
+ at: {
773
+ x: number;
774
+ y: number;
775
+ z: number;
776
+ };
777
+ entity: string;
778
+ facing?: {
779
+ yaw: number;
780
+ };
781
+ frozen?: boolean;
782
+ lookAt?: {
783
+ x: number;
784
+ y: number;
785
+ z: number;
786
+ };
787
+ }
788
+ interface IPlaytestSetupResource {
789
+ id: string;
790
+ path?: string;
791
+ value: unknown;
792
+ }
793
+ interface IPlaytestScenarioSetup {
794
+ aim?: IPlaytestAimRequest;
795
+ entities?: IPlaytestSetupEntityTransform[];
796
+ place?: IPlaytestPlaceRequest[];
797
+ resources?: IPlaytestSetupResource[];
798
+ spawn?: IPlaytestSpawnRequest;
799
+ }
800
+ interface IPlaytestScenario {
801
+ acceptanceId?: string;
802
+ artifacts?: IPlaytestArtifactRequest;
803
+ assert?: IPlaytestScenarioAssertions;
804
+ /** Test-only browser seam that makes the renderer's no-adapter boot path deterministic. */
805
+ bootFailure?: "renderer-no-adapter";
806
+ /**
807
+ * Wait for the application to finish its own startup before the first observation. Default
808
+ * true, because a fixed-step run otherwise observes a game that has not finished loading.
809
+ * Set false only when the launch *is* the subject — a loading-screen scenario has to be
810
+ * allowed to look at the loading screen.
811
+ */
812
+ awaitStartup?: boolean;
813
+ inputDelivery?: PlaytestInputDelivery;
814
+ name: string;
815
+ parity?: IPlaytestParityConfig;
816
+ /**
817
+ * Browser-only: open the page with `prefers-reduced-motion: reduce` emulated, so a game that
818
+ * honours the preference can prove it. Applied before navigation, so the first read sees it.
819
+ */
820
+ reducedMotion?: "reduce";
821
+ schemaVersion: 1;
822
+ setup?: IPlaytestScenarioSetup;
823
+ sourcePath?: string;
824
+ /** Absolute fixed-step tick reached after startup and warmup, before baseline and input. */
825
+ startTick?: number;
826
+ steps: IPlaytestStep[];
827
+ subject?: string;
828
+ target: PlaytestTarget;
829
+ viewport: IPlaytestViewport;
830
+ warmupFrames: number;
831
+ }
832
+ interface IPlaytestScenarioDiagnostic {
833
+ code: "TN_PLAYTEST_SCENARIO_INVALID" | "TN_PLAYTEST_SCENARIO_NOT_FOUND" | "TN_PLAYTEST_SCENARIO_STEP_INVALID";
834
+ fix?: {
835
+ docs?: string;
836
+ instruction: string;
837
+ snippet?: string;
838
+ };
839
+ message: string;
840
+ severity: "error";
841
+ suggestion?: string;
842
+ }
843
+
844
+ export type { IToneMetrics as I, PlaytestTarget as P, IPlaytestToneAssertion as a, IPlaytestRegionalToneObservation as b, IPlaytestStep as c, IPlaytestScenarioDiagnostic as d, IPlaytestScenario as e, IPlaytestArtifactRequest as f, IPlaytestFramebufferCoverageAssertion as g, IPlaytestMedia as h, IPlaytestPathAssertion as i, IPlaytestPerformanceAssertion as j, IPlaytestPointer as k, IPlaytestRenderChainAssertion as l, IPlaytestResourceWait as m, IPlaytestSignalAssertion as n, IPlaytestStartupAssertion as o, IPlaytestToneObservation as p, IPlaytestVisualAssertion as q, IPlaytestVisualElementRegion as r, IPlaytestVisualRegion as s, IPlaytestVisualRegionBounds as t, IPlaytestVisualRegionTarget as u, IPlaytestWheel as v, IPlaytestWorldRuntimeAssertion as w, IPlaytestToneCaptureObservation as x, IPlaytestDiagnosticsAssertion as y };