@threenative/playtest 0.3.12 → 0.3.15

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.
@@ -45,7 +45,9 @@ interface IPlaytestRegionalToneObservation extends Partial<IToneMetrics> {
45
45
  }
46
46
  type IPlaytestToneCaptureObservation = IPlaytestToneObservation | IPlaytestRegionalToneObservation;
47
47
 
48
+ /** The scenario file's `target` vocabulary. It stays as authored; the lane a run executes on is `PlaytestLane`. */
48
49
  type PlaytestTarget = "web" | "desktop" | "bevy";
50
+
49
51
  type PlaytestInputDelivery = "deterministic" | "focused-dom";
50
52
  interface IPlaytestViewport {
51
53
  height: number;
@@ -88,8 +90,24 @@ type IPlaytestResourceWait = {
88
90
  lte: number;
89
91
  path: string;
90
92
  };
93
+ /**
94
+ * The standard pad a `gamepad` step holds down: the sticks' four axes and the indices held.
95
+ */
96
+ interface IPlaytestGamepad {
97
+ /** The standard's stick axes 0..3, each `-1`..`1`. Absent axes read centred. */
98
+ readonly axes?: readonly number[];
99
+ /** Standard button indices held down, `0` south through `15` d-pad right. */
100
+ readonly buttons?: readonly number[];
101
+ }
91
102
  interface IPlaytestStep {
92
103
  kind?: "aimAt" | "click" | "input" | "lifecycle" | "wait";
104
+ /**
105
+ * A scripted W3C "standard" pad, so a scenario proves a controller binding without hardware. The
106
+ * runner installs `navigator.getGamepads` on the page and this is the pad it returns: `axes` are
107
+ * the standard's stick axes 0..3, `buttons` the indices held down. A step that names it drives
108
+ * input exactly like `press` does, and `release` lifts every button and re-centres both sticks.
109
+ */
110
+ gamepad?: IPlaytestGamepad;
93
111
  /** @deprecated Use holdTicks. Fixed-step bridges treat this as a tick alias. */
94
112
  holdFrames?: number;
95
113
  holdTicks?: number;
@@ -287,19 +305,6 @@ interface IPlaytestSettledAssertion {
287
305
  minMeanPoseDistance?: number;
288
306
  requiredOn?: PlaytestTarget[];
289
307
  }
290
- interface IPlaytestOccludedAssertion {
291
- allowTrivial?: string;
292
- entity?: string;
293
- target?: string;
294
- }
295
- interface IPlaytestOverlayNodeAssertion {
296
- attribute?: string;
297
- equals?: unknown;
298
- overlayId: string;
299
- selector: string;
300
- textIncludes?: string;
301
- visible?: boolean;
302
- }
303
308
  /**
304
309
  * Bounds on the room the game is played in — what a screenshot would have shown, as numbers.
305
310
  *
@@ -667,16 +672,6 @@ interface IPlaytestAerodynamicsAssertion {
667
672
  sign: "negative" | "positive";
668
673
  }>;
669
674
  }
670
- interface IPlaytestReachabilityAssertion {
671
- artifact: string;
672
- entities: string[];
673
- /** Loaded from artifact by loadPlaytestScenario; not authored in scenario JSON. */
674
- envelope?: {
675
- fallDistanceToGround: number;
676
- forwardReach: number;
677
- maxRise: number;
678
- };
679
- }
680
675
  interface IPlaytestWorldRuntimeAssertion {
681
676
  agent: string;
682
677
  core: string;
@@ -754,13 +749,10 @@ interface IPlaytestScenarioAssertions {
754
749
  geometry?: IPlaytestGeometryCaptureRequest;
755
750
  hud?: IPlaytestPathAssertion[];
756
751
  movement?: IPlaytestMovementAssertion;
757
- occluded?: IPlaytestOccludedAssertion[];
758
- overlayNodes?: IPlaytestOverlayNodeAssertion[];
759
752
  parity?: IPlaytestParityAssertion;
760
753
  performance?: IPlaytestPerformanceAssertion;
761
754
  pipelineCensus?: IPlaytestPipelineCensusAssertion;
762
755
  renderChain?: IPlaytestRenderChainAssertion;
763
- reachability?: IPlaytestReachabilityAssertion;
764
756
  resources?: IPlaytestResourceAssertion[];
765
757
  settled?: IPlaytestSettledAssertion[];
766
758
  signals?: IPlaytestSignalAssertion[];
@@ -954,4 +946,4 @@ interface IPlaytestScenarioDiagnostic {
954
946
  suggestion?: string;
955
947
  }
956
948
 
957
- 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 };
949
+ export type { IToneMetrics as I, IPlaytestToneAssertion as a, IPlaytestRegionalToneObservation as b, IPlaytestStep as c, IPlaytestScenarioDiagnostic as d, IPlaytestScenario as e, IPlaytestArtifactRequest as f, IPlaytestFramebufferCoverageAssertion as g, IPlaytestGamepad as h, IPlaytestMedia as i, IPlaytestPathAssertion as j, IPlaytestPerformanceAssertion as k, IPlaytestPointer as l, IPlaytestRenderChainAssertion as m, IPlaytestResourceWait as n, IPlaytestSignalAssertion as o, IPlaytestStartupAssertion as p, IPlaytestToneObservation as q, IPlaytestVisualAssertion as r, IPlaytestVisualElementRegion as s, IPlaytestVisualRegion as t, IPlaytestVisualRegionBounds as u, IPlaytestVisualRegionTarget as v, IPlaytestWheel as w, IPlaytestWorldRuntimeAssertion as x, IPlaytestToneCaptureObservation as y, IPlaytestDiagnosticsAssertion as z };
@@ -1,7 +1,7 @@
1
- import { e as IPlaytestScenario, j as IPlaytestPerformanceAssertion } from './schema-base-C2pIQ165.js';
1
+ import { e as IPlaytestScenario, k as IPlaytestPerformanceAssertion } from './schema-base-D8wNuOLE.js';
2
2
  import { IPlaytestObservationSnapshot } from './protocol.js';
3
3
  import { Page } from 'playwright';
4
- import { I as IPlaytestReport, p as IPlaytestProtocolDiagnostic, l as IPlaytestDiagnosticsPolicy, a as IPlaytestAssertionResult } from './diagnostics-BPaaU6JB.js';
4
+ import { I as IPlaytestReport, p as IPlaytestProtocolDiagnostic, l as IPlaytestDiagnosticsPolicy, a as IPlaytestAssertionResult } from './diagnostics-BDWgOKJj.js';
5
5
 
6
6
  /** Capture the largest rendered canvas bounds without waiting for locator screenshot stability. */
7
7
  declare function captureVisualSurface(page: Page, artifactPath?: string): Promise<Buffer | undefined>;
@@ -228,6 +228,11 @@ declare const PLAYTEST_FLAGS: {
228
228
  readonly summary: "the <artifact>.build-report.json threenative build published; its performanceBudget bounds every scenario, and a stale or foreign report refuses the run";
229
229
  readonly takesValue: true;
230
230
  };
231
+ readonly "--skip-check": {
232
+ readonly default: "false";
233
+ readonly summary: "skip an installed project's typecheck and lint scripts, which otherwise run first and fail the run (reported as TN_PLAYTEST_CHECK_SKIPPED)";
234
+ readonly takesValue: false;
235
+ };
231
236
  readonly "--no-screenshots": {
232
237
  readonly default: "false";
233
238
  readonly summary: "skip the before/after artifact frames; scenarios that assert on a frame still capture one";
@@ -242,7 +247,7 @@ declare const PLAYTEST_FLAGS: {
242
247
  };
243
248
  readonly "--browser-recipe": {
244
249
  readonly default: "none";
245
- readonly summary: "named browser recipe (webgpu)";
250
+ readonly summary: "named browser recipe (webgpu, which also launches headed)";
246
251
  readonly takesValue: true;
247
252
  };
248
253
  readonly "--cpu-prof": {
@@ -0,0 +1,112 @@
1
+ # playtest determinism and startup readiness
2
+
3
+ Why scenario timing is ticks rather than milliseconds, and what the runner waits for
4
+ before it observes a game. Moved out of
5
+ [`@threenative/playtest/AGENTS.md`](../AGENTS.md) verbatim; every paragraph below is the text
6
+ AGENTS.md used to carry.
7
+
8
+ ## Scenario steps count fixed-step ticks, not milliseconds
9
+
10
+ Scenario steps count fixed-step ticks, not milliseconds — use `holdTicks`, `waitTicks`. The
11
+ deprecated `holdFrames` and `waitFrames` aliases remain accepted for compatibility and are
12
+ treated as ticks when the bridge exposes `runtime.fixedStep`; `warmupFrames` remains a genuine
13
+ requestAnimationFrame warmup. Never introduce a wall-clock sleep or a millisecond-based step
14
+ into scenario semantics.
15
+
16
+ `"reducedMotion": "reduce"` (web target only) opens the page with `prefers-reduced-motion: reduce`
17
+ emulated before navigation, so a game that suppresses flashes or motion for it can prove so.
18
+
19
+ ## Ticks are not the clock a launch runs on
20
+
21
+ **Ticks are not the clock a launch runs on.** A run advances ticks as fast as the machine allows,
22
+ so a whole scenario can complete during a launch that has not finished — and everything the
23
+ application gates on startup (compute dispatch, the first world present) then never happens inside
24
+ the run. `starter-look` read `flagSteps` 0 before and 0 after because the cloth had never been
25
+ dispatched; twelve starter scenarios photographed the loading screen and reported
26
+ `TN_CAPTURE_BLANK`. Both depended only on how long boot took.
27
+
28
+ So after `warmupFrames` and before the baseline observation, the runner waits for the application
29
+ to say its world is safe to observe: a bridge that advertises **`runtime.startup`** reports
30
+ `{ phase, progress }` from `ready()` (core's `playtest()` plugin publishes `ctx.startup`), and the
31
+ runner holds — pumping frames on browser, ticks on device — until `phase` is `"ready"`. Bounded by
32
+ `PLAYTEST_STARTUP_READY_TIMEOUT_MS`; a game that never gets there fails
33
+ `TN_PLAYTEST_STARTUP_NOT_READY` rather than being observed mid-load. An application that reports no
34
+ startup at all — a plain Three.js page — is never waited on, and advertising the capability without
35
+ reporting it is malformed and throws.
36
+
37
+ Readiness means two things, and the wait always insists on both. Core reaches `"ready"` after
38
+ first-use compilation settles **and** a frame window — five sustained in-budget frames, or a
39
+ bounded expiry of `STARTUP_STABLE_WINDOW_MS` (10s) when a CPU rasteriser can never meet them.
40
+ Observing at bare compile settlement is not enough: a game that builds its world on `whenReady()`
41
+ (the puzzle's crate pile is one) has not run yet, and the run then asserts against a half-built
42
+ world. So the software lane waits for `"ready"` like any other — at most 10s more per scenario —
43
+ and the declaration (`--allow-software` / `TN_PLAYTEST_ALLOW_SOFTWARE=1`) only **labels** the
44
+ result: `startup.rule` is `"compile-settled"`, because a CPU rasteriser reached readiness on the
45
+ bounded window rather than on sustained frames, and an operator must not read that pass as a
46
+ smoothness measurement. A lane that reaches readiness immediately is labelled the same way.
47
+
48
+ Compile settlement is still required — it is the part that makes a run observe the game rather than
49
+ the loading screen — and a game whose phase never leaves `"collapsing"` fails
50
+ `TN_PLAYTEST_STARTUP_NOT_READY` rather than being observed mid-load. The label is keyed *only* off
51
+ that declaration, never off a timeout or an adapter guess. Every report carries `startup.rule`,
52
+ `"sustained-frames"` or `"compile-settled"`, so a software-lane pass is never read as a smoothness
53
+ measurement.
54
+
55
+ A bridge that stops answering is not automatically a slow launch. A host that has **exited** looks
56
+ identical from the runner's side — both are operation timeouts — so on the device targets the wait
57
+ also asks the driver whether the process is still there, and a dead one fails immediately as
58
+ `TN_PLAYTEST_STARTUP_HOST_EXITED` with the console tail that says why. Only a `false` reading ends
59
+ the wait: a driver that cannot answer leaves it exactly as it was, because inferring a crash from an
60
+ unreadable probe is the implicit fallback everything else here refuses. Without it a crashed runtime
61
+ spent the full `PLAYTEST_STARTUP_READY_TIMEOUT_MS` and was then reported as the game's loading gate
62
+ being too slow — three minutes of silence blamed on the wrong layer, which is how the hosted
63
+ Windows performance collector read on PR #122.
64
+
65
+ Never fix a boot race by lengthening a wait. Padding changes which runs get lucky; the tick counts
66
+ were already identical in the runs that disagreed.
67
+
68
+ ## `--live-clock`: the one wall clock a measurement may ask for
69
+
70
+ **A standing scene is not measurable on counted ticks, and that is not the game's defect.** The
71
+ browser runner sends each fixed-step tick through its own bounded `advance(1)` request, while recording
72
+ path samples in groups of ten ticks. A counted group presents no extra observation frame: a game
73
+ standing still while a scenario watches it reports one boot window and nothing after it, because
74
+ there was no second frame to close a window on.
75
+
76
+ Browser assertions containing `maxFrameMsP95` or `minFps` select this live clock automatically:
77
+ forced simulation batches do not measure normal frame pacing. An explicit `liveClock: false`
78
+ run configuration retains counted ticks; draw-count-only assertions and other targets keep their
79
+ existing default.
80
+
81
+ `--live-clock` (browser and desktop targets) also opts in, and it is the harness half of what the
82
+ native production profile's own `--live-clock` already does there. On the browser the runner puts
83
+ `globalThis.__THREENATIVE_PLAYTEST_CLOCK__ = "wall-clock"` in an `addInitScript` — ahead of every
84
+ page script, so a request that lands after the game's module evaluated cannot happen — and on the
85
+ native desktop host it hands the same request over as `TN_PLAYTEST_CLOCK=wall-clock`, which
86
+ `loadScript` reads before it evaluates the game entry (`runtime.cpp`). Either way the
87
+ producer reads it: the loop is left unfrozen, the host's frame pump moves the simulation at the
88
+ machine's own rate, and `advance` spends the span of wall time its ticks name and reports the ticks
89
+ that pump really ran instead of insisting on the count it asked for. Every report then carries
90
+ `clock: "wall-clock"`, so a rate is never read without the clock that produced it.
91
+
92
+ The request lives in the protocol beside the mode it names, so a game that installs the bridge
93
+ itself (`installThreePlaytestBridge`, a plain Three.js project) honours it too: only an installer
94
+ that names its own mode outranks it, and a producer with no request still reports the clock it
95
+ really runs on. An unrecognised value throws `TN_PLAYTEST_CLOCK_UNSUPPORTED` rather than falling
96
+ back — a misspelling that quietly left the loop frozen published a frame rate for a game that was
97
+ not playing.
98
+
99
+ A browser scenario can ask for it itself with `"clock": "wall-clock"` (target `web` only, any other value
100
+ or target throws at load). The flag then applies to that scenario alone, so a kit's glob run
101
+ (`--scenario "playtests/*.playtest.json"`) measures its `performance` scenario on the wall clock and
102
+ leaves every other scenario on counted ticks. On the counted clock a 300-tick window of a kit
103
+ performance run closed on 44 to 53 presented frames and held 1 to 3 GPU samples; on the wall clock the
104
+ same windows held 17 to 38 (desktop RTX 2080 on a shared GPU, four kits). A performance judgment
105
+ needs the second, and the frame bound fails closed with `TN_PLAYTEST_PERF_FEW_GPU_SAMPLES` without it.
106
+
107
+ It is a measurement switch, not scenario semantics. `holdTicks` and `waitTicks` stay tick counts,
108
+ the flag is refused on the device targets (their hosts take the request from the production
109
+ profile's injected instrumentation, not from this runner). Ordinary deterministic scenarios retain
110
+ counted ticks. A value the host does not recognize is refused there too:
111
+ `TN_PLAYTEST_CLOCK_UNSUPPORTED` on stderr, and the launch fails rather than reporting a wall-clock
112
+ run that never happened.