@threenative/playtest 0.2.0 → 0.3.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.
@@ -0,0 +1,841 @@
1
+ import { PlaytestFramePhase, JsonValue, IPlaytestRenderChainObservation } from './protocol.js';
2
+
3
+ type PlaytestTarget = "web" | "desktop" | "bevy";
4
+ type PlaytestInputDelivery = "deterministic" | "focused-dom";
5
+ interface IPlaytestViewport$1 {
6
+ height: number;
7
+ width: number;
8
+ }
9
+ interface IPlaytestPointer {
10
+ buttons?: number;
11
+ id: number;
12
+ x: number;
13
+ y: number;
14
+ }
15
+ interface IPlaytestWheel {
16
+ deltaX?: number;
17
+ deltaY: number;
18
+ }
19
+ interface IPlaytestStep {
20
+ kind?: "aimAt" | "click" | "input" | "wait";
21
+ /** @deprecated Use holdTicks. Fixed-step bridges treat this as a tick alias. */
22
+ holdFrames?: number;
23
+ holdTicks?: number;
24
+ /** A viewport-pixel click target, resolved directly or from a registered entity's bounds. */
25
+ at?: IPlaytestClickTarget;
26
+ label?: string;
27
+ overlayMessage?: {
28
+ overlayId: string;
29
+ payload: unknown;
30
+ type: string;
31
+ };
32
+ pitch?: number;
33
+ pointerPosition?: {
34
+ buttons?: number;
35
+ x: number;
36
+ y: number;
37
+ };
38
+ /** The complete held-pointer set for this step, in arrival order. */
39
+ pointers?: readonly IPlaytestPointer[];
40
+ /** A string presses one key; an array describes the complete held-key set. */
41
+ press?: string | readonly string[];
42
+ release: boolean;
43
+ screenshot?: string;
44
+ /** Runner-native aim: yaw/pitch are computed from the sampled subject position. */
45
+ target?: IPlaytestAimTarget;
46
+ /** @deprecated Use waitTicks. Fixed-step bridges treat this as a tick alias. */
47
+ waitFrames?: number;
48
+ waitTicks?: number;
49
+ /** A browser/native wheel sample; negative DOM deltaY is the conventional toward-user gesture. */
50
+ wheel?: IPlaytestWheel;
51
+ window?: {
52
+ height?: number;
53
+ operation: "minimize" | "resize" | "restore";
54
+ width?: number;
55
+ };
56
+ }
57
+ /** Where an aimAt step points: a world xz position or another registered entity. */
58
+ type IPlaytestAimTarget = {
59
+ entity: string;
60
+ } | {
61
+ x: number;
62
+ z: number;
63
+ };
64
+ type IPlaytestClickTarget = {
65
+ entity: string;
66
+ } | {
67
+ x: number;
68
+ y: number;
69
+ };
70
+ interface IPlaytestMovementAssertion {
71
+ axis?: string;
72
+ closesDistanceToPosition?: {
73
+ position: [number, number, number];
74
+ min: number;
75
+ };
76
+ entity?: string;
77
+ facesMovementWithinDegrees?: number;
78
+ minAxisDelta?: {
79
+ axis: string;
80
+ min: number;
81
+ };
82
+ minResolvedAxisDelta?: {
83
+ axis: string;
84
+ min: number;
85
+ };
86
+ maxTiltDegrees?: number;
87
+ minDistance?: number;
88
+ minVelocity?: number;
89
+ maxDistance?: number;
90
+ pathLength?: number;
91
+ notFacing?: {
92
+ entity: string;
93
+ minDegrees: number;
94
+ };
95
+ notFacingPosition?: {
96
+ position: [number, number, number];
97
+ minDegrees: number;
98
+ };
99
+ reachesPositionWithin?: {
100
+ atStep?: string;
101
+ position: [number, number, number];
102
+ maxDistance: number;
103
+ };
104
+ rotationChanged?: boolean;
105
+ }
106
+ interface IPlaytestCameraAssertion {
107
+ entity?: string;
108
+ follows?: string;
109
+ targetInViewport?: boolean;
110
+ within?: number;
111
+ }
112
+ interface IPlaytestPathAssertion {
113
+ atSteps?: Array<{
114
+ equals?: unknown;
115
+ label: string;
116
+ textIncludes?: string;
117
+ }>;
118
+ changed?: boolean;
119
+ equals?: unknown;
120
+ gte?: number;
121
+ id: string;
122
+ lte?: number;
123
+ allowTrivial?: string;
124
+ path?: string;
125
+ textIncludes?: string;
126
+ throughoutSteps?: boolean;
127
+ }
128
+ interface IPlaytestResourcePathAlternative {
129
+ changed?: boolean;
130
+ equals?: unknown;
131
+ gte?: number;
132
+ lte?: number;
133
+ path: string;
134
+ textIncludes?: string;
135
+ }
136
+ interface IPlaytestResourcePathAssertion extends IPlaytestPathAssertion {
137
+ anyOf?: never;
138
+ }
139
+ interface IPlaytestResourceAnyOfAssertion {
140
+ anyOf: IPlaytestResourcePathAlternative[];
141
+ atSteps?: never;
142
+ changed?: never;
143
+ equals?: never;
144
+ gte?: never;
145
+ id: string;
146
+ lte?: never;
147
+ allowTrivial?: never;
148
+ path?: never;
149
+ textIncludes?: never;
150
+ throughoutSteps?: never;
151
+ }
152
+ type IPlaytestResourceAssertion = IPlaytestResourceAnyOfAssertion | IPlaytestResourcePathAssertion;
153
+ interface IPlaytestComponentAssertion extends Omit<IPlaytestPathAssertion, "id" | "textIncludes" | "throughoutSteps"> {
154
+ component: string;
155
+ entity: string;
156
+ }
157
+ interface IPlaytestContactAssertion {
158
+ atStep?: string;
159
+ entity?: string;
160
+ kind?: string;
161
+ maxCount?: number;
162
+ minCount?: number;
163
+ requiredOn?: PlaytestTarget[];
164
+ with?: string;
165
+ }
166
+ interface IPlaytestSignalAssertion {
167
+ atStep?: string;
168
+ entity?: string;
169
+ maxCount?: number;
170
+ minCount?: number;
171
+ name: string;
172
+ }
173
+ interface IPlaytestSettledAssertion {
174
+ atStep?: string;
175
+ allowTrivial?: string;
176
+ compareToStep?: string;
177
+ entity?: string;
178
+ minBodies?: number;
179
+ minMeanPoseDistance?: number;
180
+ requiredOn?: PlaytestTarget[];
181
+ }
182
+ interface IPlaytestOccludedAssertion {
183
+ allowTrivial?: string;
184
+ entity?: string;
185
+ target?: string;
186
+ }
187
+ interface IPlaytestOverlayNodeAssertion {
188
+ attribute?: string;
189
+ equals?: unknown;
190
+ overlayId: string;
191
+ selector: string;
192
+ textIncludes?: string;
193
+ visible?: boolean;
194
+ }
195
+ interface IPlaytestAnimationAssertion {
196
+ advancedFrames?: number;
197
+ allowTrivial?: string;
198
+ clip?: string;
199
+ entered?: boolean;
200
+ entity?: string;
201
+ finished?: boolean;
202
+ }
203
+ interface IPlaytestTagCountAssertion {
204
+ allowTrivial?: string;
205
+ count?: number;
206
+ gte?: number;
207
+ lte?: number;
208
+ tag: string;
209
+ }
210
+ interface IPlaytestStateAssertion {
211
+ allowTrivial?: string;
212
+ entity?: string;
213
+ equals: string;
214
+ }
215
+ interface IPlaytestVisibilityAssertion {
216
+ allowTrivial?: string;
217
+ entity?: string;
218
+ maxOffscreenRatio?: number;
219
+ minProjectedPixels?: number;
220
+ present?: boolean;
221
+ }
222
+ interface IPlaytestDiagnosticsAssertion {
223
+ noConsoleErrors?: boolean;
224
+ noNetworkErrors?: boolean;
225
+ noRuntimeDiagnostics?: boolean;
226
+ consoleErrorsOptOutReason?: string;
227
+ networkErrorsOptOutReason?: string;
228
+ runtimeDiagnosticsOptOutReason?: string;
229
+ runtimeReady?: boolean;
230
+ }
231
+ interface IPlaytestPerformanceAssertion {
232
+ maxDrawCalls?: number;
233
+ maxFrameMsP95?: number;
234
+ maxTriangles?: number;
235
+ /** Frame-budget floor: the median presented frame must sustain at least this many frames a second. */
236
+ minFps?: number;
237
+ /**
238
+ * Per-phase ceilings in milliseconds, nearest-rank p95 across the sampled frames. The phase
239
+ * names are the engine's frame-budget phases: hostGap, update, render, overlay, residual.
240
+ */
241
+ maxPhaseMsP95?: Readonly<Partial<Record<PlaytestFramePhase, number>>>;
242
+ }
243
+ interface IPlaytestRenderChainAssertion {
244
+ tier?: "high" | "medium" | "low" | "off";
245
+ velocity?: {
246
+ maxRejectionFraction: number;
247
+ };
248
+ }
249
+ interface IPlaytestFramebufferCoverageAssertion {
250
+ backdrop: [number, number, number];
251
+ grid?: {
252
+ columns: number;
253
+ rows: number;
254
+ };
255
+ tolerance: number;
256
+ window: {
257
+ endStep: string;
258
+ startStep: string;
259
+ };
260
+ }
261
+ interface IPlaytestVisualAssertion {
262
+ entityVisible?: {
263
+ entity: string;
264
+ minProjectedPixels: number;
265
+ throughoutFrames?: boolean;
266
+ };
267
+ frameDiff?: {
268
+ baselineImage?: string;
269
+ maxChangedPixelRatio?: number;
270
+ minChangedPixelRatio?: number;
271
+ };
272
+ region?: {
273
+ height: number;
274
+ maxLuminance?: number;
275
+ minDarkPixelRatio?: number;
276
+ minNonblankPixelRatio?: number;
277
+ width: number;
278
+ x: number;
279
+ y: number;
280
+ };
281
+ }
282
+ interface IPlaytestAerodynamicsAssertion {
283
+ controls?: Array<{
284
+ minAbs?: number;
285
+ sign: "negative" | "positive";
286
+ surface: string;
287
+ }>;
288
+ entity: string;
289
+ minForceSamples?: number;
290
+ torques?: Array<{
291
+ axis: "x" | "y" | "z";
292
+ label: string;
293
+ minAbs?: number;
294
+ relativeToLabel?: string;
295
+ sign: "negative" | "positive";
296
+ }>;
297
+ }
298
+ interface IPlaytestReachabilityAssertion {
299
+ artifact: string;
300
+ entities: string[];
301
+ /** Loaded from artifact by loadPlaytestScenario; not authored in scenario JSON. */
302
+ envelope?: {
303
+ fallDistanceToGround: number;
304
+ forwardReach: number;
305
+ maxRise: number;
306
+ };
307
+ }
308
+ interface IPlaytestWorldRuntimeAssertion {
309
+ agent: string;
310
+ core: string;
311
+ portable?: boolean;
312
+ randomState: number;
313
+ rapier: string | null;
314
+ step: number;
315
+ }
316
+ interface IPlaytestWorldAssertion {
317
+ runtime?: IPlaytestWorldRuntimeAssertion;
318
+ seed: number | null;
319
+ }
320
+ /**
321
+ * Thermal, power and battery state measured around the run itself. Its point is comparability:
322
+ * a run that started hot, or whose thermal status rose while it ran, is not evidence against a
323
+ * cool baseline, and this is how a scenario says so out loud.
324
+ */
325
+ interface IPlaytestDeviceMetricsAssertion {
326
+ /** Ceiling on the battery temperature climb from the first to the last sample, in °C. */
327
+ maxTemperatureRiseC?: number;
328
+ /** Ceiling on the highest Android thermal status observed during the run (0 is NONE). */
329
+ maxThermalStatus?: number;
330
+ /** Requires a run the harness judged comparable with a cool one. */
331
+ notThermallyConfounded?: boolean;
332
+ }
333
+ interface IPlaytestScenarioAssertions {
334
+ aerodynamics?: IPlaytestAerodynamicsAssertion[];
335
+ animation?: IPlaytestAnimationAssertion[];
336
+ camera?: IPlaytestCameraAssertion;
337
+ components?: IPlaytestComponentAssertion[];
338
+ contacts?: IPlaytestContactAssertion[];
339
+ deviceMetrics?: IPlaytestDeviceMetricsAssertion;
340
+ diagnostics?: IPlaytestDiagnosticsAssertion;
341
+ framebufferCoverage?: IPlaytestFramebufferCoverageAssertion;
342
+ hud?: IPlaytestPathAssertion[];
343
+ movement?: IPlaytestMovementAssertion;
344
+ occluded?: IPlaytestOccludedAssertion[];
345
+ overlayNodes?: IPlaytestOverlayNodeAssertion[];
346
+ performance?: IPlaytestPerformanceAssertion;
347
+ renderChain?: IPlaytestRenderChainAssertion;
348
+ reachability?: IPlaytestReachabilityAssertion;
349
+ resources?: IPlaytestResourceAssertion[];
350
+ settled?: IPlaytestSettledAssertion[];
351
+ signals?: IPlaytestSignalAssertion[];
352
+ states?: IPlaytestStateAssertion[];
353
+ tags?: IPlaytestTagCountAssertion[];
354
+ visibility?: IPlaytestVisibilityAssertion[];
355
+ visual?: IPlaytestVisualAssertion[];
356
+ world?: IPlaytestWorldAssertion;
357
+ }
358
+ interface IPlaytestParityConfig {
359
+ animation?: Array<{
360
+ clip?: string;
361
+ entity: string;
362
+ requiredOn?: PlaytestTarget[];
363
+ }>;
364
+ axisDelta?: Partial<Record<"x" | "y" | "z", number>>;
365
+ contacts?: {
366
+ minSharedCount?: number;
367
+ };
368
+ movementDistance?: {
369
+ maxDelta: number;
370
+ };
371
+ resources?: string[];
372
+ targets?: PlaytestTarget[];
373
+ }
374
+ interface IPlaytestArtifactRequest {
375
+ console?: boolean;
376
+ contactSheet?: boolean;
377
+ effectLog?: "focused" | boolean;
378
+ network?: boolean;
379
+ runtimeTrace?: boolean;
380
+ screenshots?: "before-after" | "after" | false;
381
+ }
382
+ interface IPlaytestSetupEntityTransform {
383
+ entity: string;
384
+ position?: [number, number, number];
385
+ rotation?: [number, number, number, number];
386
+ scale?: [number, number, number];
387
+ }
388
+ /** Overrides the subject player start. y is optional and preserves the game's own height when absent. */
389
+ interface IPlaytestSpawnRequest {
390
+ x: number;
391
+ y?: number;
392
+ z: number;
393
+ }
394
+ /** Overrides the subject player-start aim; both angles are radians (Three.js convention). */
395
+ interface IPlaytestAimRequest {
396
+ pitch: number;
397
+ yaw: number;
398
+ }
399
+ /**
400
+ * Places a named entity at an explicit world transform before input. Orientation comes
401
+ * from facing yaw or a lookAt point (never both); frozen delivers the placed-frozen
402
+ * marker the game reads to suppress physics motion — placement is data, not teleports.
403
+ */
404
+ interface IPlaytestPlaceRequest {
405
+ at: {
406
+ x: number;
407
+ y: number;
408
+ z: number;
409
+ };
410
+ entity: string;
411
+ facing?: {
412
+ yaw: number;
413
+ };
414
+ frozen?: boolean;
415
+ lookAt?: {
416
+ x: number;
417
+ y: number;
418
+ z: number;
419
+ };
420
+ }
421
+ interface IPlaytestSetupResource {
422
+ id: string;
423
+ path?: string;
424
+ value: unknown;
425
+ }
426
+ interface IPlaytestScenarioSetup {
427
+ aim?: IPlaytestAimRequest;
428
+ entities?: IPlaytestSetupEntityTransform[];
429
+ place?: IPlaytestPlaceRequest[];
430
+ resources?: IPlaytestSetupResource[];
431
+ spawn?: IPlaytestSpawnRequest;
432
+ }
433
+ interface IPlaytestScenario {
434
+ acceptanceId?: string;
435
+ artifacts?: IPlaytestArtifactRequest;
436
+ assert?: IPlaytestScenarioAssertions;
437
+ /**
438
+ * Wait for the application to finish its own startup before the first observation. Default
439
+ * true, because a fixed-step run otherwise observes a game that has not finished loading.
440
+ * Set false only when the launch *is* the subject — a loading-screen scenario has to be
441
+ * allowed to look at the loading screen.
442
+ */
443
+ awaitStartup?: boolean;
444
+ inputDelivery?: PlaytestInputDelivery;
445
+ name: string;
446
+ parity?: IPlaytestParityConfig;
447
+ schemaVersion: 1;
448
+ setup?: IPlaytestScenarioSetup;
449
+ sourcePath?: string;
450
+ steps: IPlaytestStep[];
451
+ subject?: string;
452
+ target: PlaytestTarget;
453
+ viewport: IPlaytestViewport$1;
454
+ warmupFrames: number;
455
+ }
456
+ interface IPlaytestScenarioDiagnostic {
457
+ code: "TN_PLAYTEST_SCENARIO_INVALID" | "TN_PLAYTEST_SCENARIO_NOT_FOUND" | "TN_PLAYTEST_SCENARIO_STEP_INVALID";
458
+ fix?: {
459
+ docs?: string;
460
+ instruction: string;
461
+ snippet?: string;
462
+ };
463
+ message: string;
464
+ severity: "error";
465
+ suggestion?: string;
466
+ }
467
+
468
+ /**
469
+ * Device thermal, power and battery state as a first-class measured observation.
470
+ *
471
+ * Why this exists, measured on 2026-08-24 against a physical Pixel 8: two cold-launch runs
472
+ * reported 44 s to first frame against a 14.7 s baseline, and the difference was attributed to a
473
+ * code change. It was not. The device had climbed to 43.2 °C at thermal status 2 while the
474
+ * baseline ran at 38.2 °C at status 0 — the run was throttled, and nothing in the playtest report
475
+ * said so. Every agent that needs this answer has been hand-rolling `adb shell dumpsys` for it.
476
+ *
477
+ * Two rules this module holds to:
478
+ *
479
+ * 1. **Never report a zero for something that was not measured.** A rail breakdown a device does
480
+ * not expose comes back `{ available: false, reason }`, never `0 mW`. Google's per-rail ODPM
481
+ * numbers exist on Pixel hardware and nowhere else.
482
+ * 2. **Never discard a confounded run's numbers, and never let it pass as comparable.** The
483
+ * samples are always reported; the verdict says whether the run may be compared with a cool
484
+ * one. A missing sample is a failure, not a skip.
485
+ *
486
+ * The parsers here read real `dumpsys` and `logcat` text. Captured samples of every format live in
487
+ * `__tests__/fixtures/device-metrics/`.
488
+ */
489
+ /** Battery temperature at or above which a run is treated as having started hot, in °C. */
490
+ declare const HOT_START_TEMPERATURE_C = 40;
491
+ /** How often the recorder samples while a scenario runs, in milliseconds. */
492
+ declare const DEVICE_METRICS_CADENCE_MS = 5000;
493
+ /** Ceiling on retained samples, so a long run cannot outgrow the bridge payload budget. */
494
+ declare const DEVICE_METRICS_MAX_SAMPLES = 240;
495
+ declare class DeviceMetricsError extends Error {
496
+ readonly code: string;
497
+ readonly observed: string;
498
+ constructor(code: string, detail: string, observed: string);
499
+ }
500
+ /** A reading that a given device may simply not expose. Absent means absent, never zero. */
501
+ type PlaytestDeviceMeasurement<T> = {
502
+ available: false;
503
+ reason: string;
504
+ } | {
505
+ available: true;
506
+ value: T;
507
+ };
508
+ interface IPlaytestDeviceBattery {
509
+ chargeCounterUah?: number;
510
+ charging: boolean;
511
+ levelPercent: number;
512
+ /** `dumpsys battery` status: 2 charging, 3 discharging, 4 not charging, 5 full. */
513
+ status: number;
514
+ temperatureC: number;
515
+ voltageMv?: number;
516
+ }
517
+ interface IPlaytestDeviceThermal {
518
+ sensors: Record<string, number>;
519
+ skinSensorName?: string;
520
+ skinTemperatureC: PlaytestDeviceMeasurement<number>;
521
+ status: number;
522
+ statusName: string;
523
+ }
524
+ type PlaytestDevicePowerRails = {
525
+ available: false;
526
+ reason: string;
527
+ } | {
528
+ at: string;
529
+ available: true;
530
+ rails: Record<string, number>;
531
+ totalMw: number;
532
+ windowMs: number;
533
+ };
534
+ interface IPlaytestDeviceMetricsSample {
535
+ /** Milliseconds since the recorder was created. */
536
+ at: number;
537
+ batteryLevelPercent: number;
538
+ batteryStatus: number;
539
+ batteryTemperatureC: number;
540
+ charging: boolean;
541
+ /** Negative is discharge, matching the sysfs sign convention. */
542
+ currentMa: PlaytestDeviceMeasurement<number>;
543
+ phase: "after" | "before" | "during";
544
+ powerRails: PlaytestDevicePowerRails;
545
+ skinTemperatureC: PlaytestDeviceMeasurement<number>;
546
+ thermalStatus: number;
547
+ thermalStatusName: string;
548
+ }
549
+ interface IPlaytestDeviceMetricsVerdict {
550
+ endTemperatureC: number | null;
551
+ endThermalStatus: number | null;
552
+ maxThermalStatus: number | null;
553
+ peakTemperatureC: number | null;
554
+ /**
555
+ * Whether a fresh per-rail power window was logged between the first and last sample. When it
556
+ * is false the rail figures describe a window that predates the run and are not attributable
557
+ * to it; `null` when the device exposes no rails at all.
558
+ */
559
+ powerRailWindowAdvanced: boolean | null;
560
+ /** Named codes: charging, hot-start, incomplete, thermal-status-rose, throttled-start. */
561
+ reasons: string[];
562
+ startTemperatureC: number | null;
563
+ startThermalStatus: number | null;
564
+ temperatureRiseC: number | null;
565
+ thermallyConfounded: boolean;
566
+ }
567
+ interface IPlaytestDeviceMetricsObservation {
568
+ available: boolean;
569
+ /** Probe failures, kept rather than dropped: an unexplained gap is itself the finding. */
570
+ errors: string[];
571
+ samples: IPlaytestDeviceMetricsSample[];
572
+ serial?: string;
573
+ source: string;
574
+ verdict: IPlaytestDeviceMetricsVerdict;
575
+ }
576
+ declare function parseDeviceBattery(output: string): IPlaytestDeviceBattery;
577
+ declare function parseDeviceThermal(output: string): IPlaytestDeviceThermal;
578
+ /**
579
+ * `/sys/class/power_supply/battery/current_now` in microamps. A device that does not expose the
580
+ * node answers with `cat`'s error text, which is unavailability, not a zero-current reading.
581
+ */
582
+ declare function parseDeviceCurrent(output: string): PlaytestDeviceMeasurement<number>;
583
+ /**
584
+ * Pixel's on-device power monitor writes a whole-rail breakdown to logcat once per ~60 s window,
585
+ * as `Power rails total power: 547.76 mW for 60014 ms` followed by `[RAIL: n mW]` groups. Devices
586
+ * without Google's ODPM hardware log nothing here, and must say so rather than report zeros.
587
+ */
588
+ declare function parseDevicePowerRails(output: string): PlaytestDevicePowerRails;
589
+ /**
590
+ * The thermal verdict. It never removes a number — a confounded run reports everything it
591
+ * measured — it only states whether this run may be compared with a cool one.
592
+ */
593
+ declare function summarizeDeviceMetrics(samples: readonly IPlaytestDeviceMetricsSample[]): IPlaytestDeviceMetricsVerdict;
594
+ interface IDeviceMetricsRecorderOptions {
595
+ adb(args: readonly string[]): Promise<string>;
596
+ cadenceMs?: number;
597
+ now?(): number;
598
+ serial?: string;
599
+ }
600
+ /**
601
+ * Samples the device around and during a run. The periodic sampler is wall-clock paced on
602
+ * purpose and deliberately reads nothing the scenario depends on: it observes the phone, it
603
+ * never advances or gates a tick, so scenario determinism is untouched.
604
+ */
605
+ declare class DeviceMetricsRecorder {
606
+ private readonly options;
607
+ private readonly errors;
608
+ private readonly samples;
609
+ private readonly startedAt;
610
+ private timer?;
611
+ constructor(options: IDeviceMetricsRecorderOptions);
612
+ sampleNow(phase: IPlaytestDeviceMetricsSample["phase"]): Promise<IPlaytestDeviceMetricsSample>;
613
+ /** Begins periodic `during` sampling. A periodic probe failure is recorded, never thrown away. */
614
+ start(): void;
615
+ stop(): void;
616
+ observation(): IPlaytestDeviceMetricsObservation;
617
+ private now;
618
+ private probe;
619
+ }
620
+
621
+ type PlaytestVec3 = [number, number, number];
622
+ /** One honest-reporting line: a placement/aim/spawn override the scenario requested. */
623
+ interface IPlaytestSetupRecord {
624
+ entity?: string;
625
+ kind: "aim" | "entities" | "place" | "resources" | "spawn";
626
+ value: JsonValue;
627
+ }
628
+ /** Requested overrides next to what actually applied; an unapplied request fails the run. */
629
+ interface IPlaytestSetupApplication {
630
+ applied: IPlaytestSetupRecord[];
631
+ requested: IPlaytestSetupRecord[];
632
+ }
633
+ interface IPlaytestTransformSample {
634
+ frame: number;
635
+ position: PlaytestVec3;
636
+ rotation?: readonly [number, number, number, number];
637
+ tick: number;
638
+ }
639
+ interface IPlaytestFollowReport {
640
+ after?: IPlaytestTransformSample;
641
+ before?: IPlaytestTransformSample;
642
+ entity: string;
643
+ moved?: number;
644
+ separation?: number;
645
+ within: number;
646
+ }
647
+ interface IPlaytestDiagnosticsPolicy {
648
+ consoleErrorsOptOutReason?: string;
649
+ networkErrorsOptOutReason?: string;
650
+ noConsoleErrors: boolean;
651
+ noNetworkErrors: boolean;
652
+ noRuntimeDiagnostics: boolean;
653
+ runtimeReady?: boolean;
654
+ runtimeDiagnosticsOptOutReason?: string;
655
+ }
656
+ interface IPlaytestCaptureProvenance {
657
+ adapter: Record<string, string>;
658
+ browserArgs: readonly string[];
659
+ captureMethod: "page.screenshot";
660
+ rendererKind: "webgl" | "webgpu";
661
+ target: string;
662
+ viewport: IPlaytestViewport;
663
+ }
664
+ interface IPlaytestTrivialityOptOut {
665
+ id: string;
666
+ reason: string;
667
+ }
668
+ interface IPlaytestViewport {
669
+ height: number;
670
+ width: number;
671
+ }
672
+ interface IPlaytestReport {
673
+ after?: IPlaytestTransformSample;
674
+ assertionResults?: IPlaytestAssertionResult[];
675
+ before?: IPlaytestTransformSample;
676
+ capture?: IPlaytestCaptureProvenance;
677
+ diagnostics: IPlaytestDiagnostic[];
678
+ diagnosticsPolicy?: IPlaytestDiagnosticsPolicy;
679
+ distance: number;
680
+ effectLog?: unknown;
681
+ entity: string;
682
+ expectAxis?: string;
683
+ expectMoved: boolean;
684
+ follow?: IPlaytestFollowReport;
685
+ frames: number;
686
+ movementDelta?: PlaytestVec3;
687
+ observations?: IPlaytestObservations;
688
+ pathLength?: number;
689
+ setup?: IPlaytestSetupApplication;
690
+ trivialityOptOuts: IPlaytestTrivialityOptOut[];
691
+ }
692
+
693
+ type Vec3 = [number, number, number];
694
+ interface IPlaytestDiagnostic {
695
+ artifactPath?: string;
696
+ code: string;
697
+ exportName?: string;
698
+ gate?: "waived-headless";
699
+ message: string;
700
+ modulePath?: string;
701
+ observedRuntimePath?: string;
702
+ path?: string;
703
+ resourceId?: string;
704
+ severity: "error" | "warning";
705
+ sourcePath?: string;
706
+ suggestion?: string;
707
+ systemId?: string;
708
+ }
709
+ interface IPlaytestAssertionResult {
710
+ details?: Record<string, unknown>;
711
+ id: string;
712
+ pass: boolean;
713
+ }
714
+ interface IPlaytestObservations {
715
+ animation?: unknown;
716
+ components?: Record<string, Record<string, {
717
+ after?: unknown;
718
+ before?: unknown;
719
+ }>>;
720
+ componentSeries?: Array<{
721
+ label: string;
722
+ snapshots: Record<string, Record<string, unknown>>;
723
+ tick: number;
724
+ }>;
725
+ console: Array<{
726
+ source?: "browser-console" | "page-error" | "unhandled-rejection";
727
+ text: string;
728
+ type: string;
729
+ }>;
730
+ contacts?: unknown;
731
+ debugColliderCount?: number;
732
+ /** Host-measured device thermal, power and battery state; produced by the android target. */
733
+ deviceMetrics?: IPlaytestDeviceMetricsObservation;
734
+ effectLog?: unknown;
735
+ effectLogBefore?: unknown;
736
+ effectLogSeries?: Array<{
737
+ label: string;
738
+ snapshot: unknown;
739
+ tick: number;
740
+ }>;
741
+ entityTransforms?: Record<string, {
742
+ halfExtents?: Vec3;
743
+ position?: Vec3;
744
+ scale?: Vec3;
745
+ }>;
746
+ framebufferCoverage?: IPlaytestFramebufferCoverageObservation;
747
+ hud: Record<string, {
748
+ after?: unknown;
749
+ before?: unknown;
750
+ }>;
751
+ overlayNodes?: Record<string, {
752
+ after?: unknown;
753
+ before?: unknown;
754
+ }>;
755
+ network: Array<{
756
+ method: string;
757
+ url: string;
758
+ }>;
759
+ physicsDebug?: unknown;
760
+ physicsDebugBefore?: unknown;
761
+ physicsDebugSeries?: Array<{
762
+ label: string;
763
+ snapshot: unknown;
764
+ tick: number;
765
+ }>;
766
+ performanceSeries?: unknown[];
767
+ renderChain?: IPlaytestRenderChainObservation;
768
+ resources: Record<string, {
769
+ after?: unknown;
770
+ before?: unknown;
771
+ }>;
772
+ resourceSeries?: Array<{
773
+ label: string;
774
+ snapshots: Record<string, unknown>;
775
+ tick: number;
776
+ }>;
777
+ runtimeObservations?: unknown;
778
+ runtimeDiagnostics?: unknown;
779
+ runtimeDiagnosticsBefore?: unknown;
780
+ signals?: unknown[];
781
+ signalSeries?: Array<{
782
+ label: string;
783
+ signals: unknown[];
784
+ tick: number;
785
+ }>;
786
+ visibility?: Record<string, unknown>;
787
+ visual?: {
788
+ captureFailure?: {
789
+ code: "TN_CAPTURE_BLANK";
790
+ label: string;
791
+ reason: string;
792
+ };
793
+ changedPixelRatio?: number;
794
+ comparisonSource?: string;
795
+ nonblankRegions?: Array<{
796
+ darkPixelRatio?: number;
797
+ height: number;
798
+ nonblankPixelRatio: number;
799
+ width: number;
800
+ x: number;
801
+ y: number;
802
+ }>;
803
+ /** Visual frame observations only; performance samples live in performanceSeries. */
804
+ runtimeDiagnosticsSeries?: unknown[];
805
+ };
806
+ }
807
+ declare function resolveDiagnosticsPolicy(policy: IPlaytestDiagnosticsAssertion | undefined): IPlaytestDiagnosticsPolicy;
808
+ interface IPlaytestFramebufferCoverageObservation {
809
+ boundarySource: "scenario-steps" | "video-backdrop-dominance";
810
+ firstViolation?: {
811
+ frameIndex: number;
812
+ grid: {
813
+ columns: number;
814
+ rows: number;
815
+ samples: Array<[number, number, number]>;
816
+ };
817
+ screenshotPath: string;
818
+ };
819
+ frameCount: number;
820
+ unreadableReason?: string;
821
+ windowCompleted: boolean;
822
+ windowStarted: boolean;
823
+ }
824
+
825
+ type PlaytestDiagnosticCode = "TN_PLAYTEST_BRIDGE_INCOMPATIBLE" | "TN_PLAYTEST_BRIDGE_CAPABILITY_UNKNOWN" | "TN_PLAYTEST_BRIDGE_MISSING" | "TN_PLAYTEST_BRIDGE_NOT_READY" | "TN_PLAYTEST_CAPTURE_PROVENANCE_MISSING" | "TN_PLAYTEST_CAPABILITY_MISSING" | "TN_PLAYTEST_DEVICE_FAILED" | "TN_PLAYTEST_HOST_EXITED" | "TN_PLAYTEST_MAILBOX_POLL_STALLED" | "TN_PLAYTEST_OBSERVATION_UNAVAILABLE" | "TN_PLAYTEST_OPERATION_TIMEOUT" | "TN_PLAYTEST_PAGE_CRASHED" | "TN_PLAYTEST_PAGE_NAVIGATED" | "TN_PLAYTEST_PAYLOAD_TOO_LARGE" | "TN_PLAYTEST_SERVER_FAILED" | "TN_PLAYTEST_SETUP_UNAPPLIED" | "TN_PLAYTEST_STARTUP_ABORTED" | "TN_PLAYTEST_STARTUP_NOT_READY" | "TN_PLAYTEST_UNSUPPORTED_ON_TARGET";
826
+ interface IPlaytestProtocolDiagnostic {
827
+ capability?: string;
828
+ code: PlaytestDiagnosticCode;
829
+ fix: {
830
+ instruction: string;
831
+ nextCommand?: string;
832
+ };
833
+ message: string;
834
+ path?: string;
835
+ severity: "error";
836
+ }
837
+ declare function playtestDiagnostic(code: PlaytestDiagnosticCode, message: string, instruction: string, details?: Pick<IPlaytestProtocolDiagnostic, "capability" | "path"> & {
838
+ nextCommand?: string;
839
+ }): IPlaytestProtocolDiagnostic;
840
+
841
+ export { type IPlaytestSignalAssertion as A, type IPlaytestTrivialityOptOut as B, type IPlaytestWheel as C, DEVICE_METRICS_CADENCE_MS as D, type IPlaytestWorldRuntimeAssertion as E, type PlaytestDeviceMeasurement as F, type PlaytestDevicePowerRails as G, HOT_START_TEMPERATURE_C as H, type IPlaytestStep as I, type PlaytestVec3 as J, parseDeviceBattery as K, parseDeviceCurrent as L, parseDevicePowerRails as M, parseDeviceThermal as N, playtestDiagnostic as O, type PlaytestTarget as P, resolveDiagnosticsPolicy as Q, summarizeDeviceMetrics as R, type IPlaytestScenarioDiagnostic as a, type IPlaytestScenario as b, type IPlaytestReport as c, type IPlaytestAssertionResult as d, type IPlaytestDiagnostic as e, DEVICE_METRICS_MAX_SAMPLES as f, DeviceMetricsError as g, DeviceMetricsRecorder as h, type IPlaytestArtifactRequest as i, type IPlaytestCaptureProvenance as j, type IPlaytestDeviceBattery as k, type IPlaytestDeviceMetricsObservation as l, type IPlaytestDeviceMetricsSample as m, type IPlaytestDeviceMetricsVerdict as n, type IPlaytestDeviceThermal as o, type IPlaytestDiagnosticsPolicy as p, type IPlaytestFramebufferCoverageAssertion as q, type IPlaytestFramebufferCoverageObservation as r, type IPlaytestObservations as s, type IPlaytestPathAssertion as t, type IPlaytestPerformanceAssertion as u, type IPlaytestPointer as v, type IPlaytestProtocolDiagnostic as w, type IPlaytestRenderChainAssertion as x, type IPlaytestSetupApplication as y, type IPlaytestSetupRecord as z };