@threenative/playtest 0.3.2 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/capture.d.ts +7 -0
- package/dist/{diagnostics-f8464bJw.d.ts → diagnostics-BXhYI2sc.d.ts} +431 -6
- package/dist/index.d.ts +4 -4
- package/dist/index.js +459 -90
- package/dist/protocol.d.ts +39 -1
- package/dist/protocol.js +2 -1
- package/dist/runner/cli.d.ts +2 -2
- package/dist/runner/cli.js +2016 -591
- package/dist/runner/index.d.ts +86 -242
- package/dist/runner/index.js +2891 -1701
- package/dist/{shared-BGwYk5HG.d.ts → shared-CHIDDJpp.d.ts} +46 -5
- package/dist/three/index.d.ts +10 -1
- package/dist/three/index.js +15 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -23,6 +23,7 @@ var PLAYTEST_CAPABILITY_REGISTRY = [
|
|
|
23
23
|
capability("runtime.diagnostics", "Captures application runtime errors."),
|
|
24
24
|
capability("runtime.events", "Drains bounded application event observations."),
|
|
25
25
|
capability("runtime.fixedStep", "Advances an application-owned deterministic tick."),
|
|
26
|
+
capability("runtime.geometry", "Answers one armed per-object geometry capture for the frame it was requested on."),
|
|
26
27
|
capability("runtime.physics", "Samples bounded application-owned physics observations."),
|
|
27
28
|
capability("runtime.performance", "Samples bounded per-render frame cost and renderer counts."),
|
|
28
29
|
capability("runtime.pipelineCensus", "Samples bounded shader and pipeline creation observations."),
|
|
@@ -241,7 +242,24 @@ function formatNumber(value) {
|
|
|
241
242
|
return Number.isInteger(value) ? String(value) : value.toFixed(3);
|
|
242
243
|
}
|
|
243
244
|
function jsonEqual(left, right) {
|
|
244
|
-
return JSON.stringify(left) === JSON.stringify(right);
|
|
245
|
+
return JSON.stringify(sortedKeys(left)) === JSON.stringify(sortedKeys(right));
|
|
246
|
+
}
|
|
247
|
+
function sortedKeys(value) {
|
|
248
|
+
if (Array.isArray(value)) {
|
|
249
|
+
return value.map(sortedKeys);
|
|
250
|
+
}
|
|
251
|
+
if (!isRecord(value)) {
|
|
252
|
+
return value;
|
|
253
|
+
}
|
|
254
|
+
const prototype = Object.getPrototypeOf(value);
|
|
255
|
+
if (prototype !== Object.prototype && prototype !== null) {
|
|
256
|
+
return value;
|
|
257
|
+
}
|
|
258
|
+
const sorted = {};
|
|
259
|
+
for (const key of Object.keys(value).sort()) {
|
|
260
|
+
sorted[key] = sortedKeys(value[key]);
|
|
261
|
+
}
|
|
262
|
+
return sorted;
|
|
245
263
|
}
|
|
246
264
|
function isRecord(value) {
|
|
247
265
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -557,14 +575,16 @@ var PLAYTEST_ASSERTION_REGISTRY = [
|
|
|
557
575
|
trivialityRationale: "It evaluates captured error and readiness channels across the run; no initial scalar value can satisfy those diagnostics by itself."
|
|
558
576
|
},
|
|
559
577
|
{
|
|
560
|
-
description: "Proves a live render sample exists and optionally bounds frame time, an fps floor, per-phase frame budget, draw calls
|
|
561
|
-
example: { performance: { maxPhaseMsP95: { render: 12 }, minFps: 30 } },
|
|
578
|
+
description: "Proves a live render sample exists and optionally bounds frame time, an fps floor, per-phase frame budget, whole-frame or per-pass draw calls and triangles.",
|
|
579
|
+
example: { performance: { maxPassDrawCalls: { shadow: 400 }, maxPhaseMsP95: { render: 12 }, minFps: 30 } },
|
|
562
580
|
fields: [
|
|
563
581
|
{ description: "Maximum nearest-rank 95th-percentile frame time in milliseconds.", name: "maxFrameMsP95", type: "number" },
|
|
564
582
|
{ description: "Minimum sustained frames per second, from the median sampled frame.", name: "minFps", type: "number" },
|
|
565
583
|
{ description: "Per-phase millisecond ceilings at nearest-rank p95. Phases: hostGap, update, render, overlay, residual.", name: "maxPhaseMsP95", type: "{ [phase]: number }" },
|
|
566
|
-
{ description: "Maximum observed renderer draw-call count.", name: "maxDrawCalls", type: "number" },
|
|
567
|
-
{ description: "
|
|
584
|
+
{ description: "Maximum observed renderer draw-call count across every pass combined.", name: "maxDrawCalls", type: "number" },
|
|
585
|
+
{ description: "Per-pass draw-call ceilings, keyed by pass kind: main, shadow, reflection, nested. Fails closed when a sampled frame carries no pass split or omits the declared kind.", name: "maxPassDrawCalls", type: "{ [pass: 'main' | 'shadow' | 'reflection' | 'nested']: number }" },
|
|
586
|
+
{ description: "Per-pass triangle ceilings, keyed by pass kind: main, shadow, reflection, nested. Fails closed when a sampled frame carries no pass split or omits the declared kind.", name: "maxPassTriangles", type: "{ [pass: 'main' | 'shadow' | 'reflection' | 'nested']: number }" },
|
|
587
|
+
{ description: "Maximum observed renderer triangle count across every pass combined.", name: "maxTriangles", type: "number" }
|
|
568
588
|
],
|
|
569
589
|
cardinality: "object",
|
|
570
590
|
kind: "performance",
|
|
@@ -613,6 +633,24 @@ var PLAYTEST_ASSERTION_REGISTRY = [
|
|
|
613
633
|
triviality: "reject-initial-value",
|
|
614
634
|
trivialityRationale: "An entity can be present and in-frame before input; the scenario must prove visibility after its setup or document why that presence is held."
|
|
615
635
|
},
|
|
636
|
+
{
|
|
637
|
+
description: "Proves which labelled audio cues the game actually played, and how often.",
|
|
638
|
+
example: { audio: [{ cue: "speech:p01", maxPlays: 1 }] },
|
|
639
|
+
fields: [
|
|
640
|
+
{ description: "Cue label the game passed to AudioBus.play/playAt.", name: "cue", required: true, type: "string" },
|
|
641
|
+
{ description: "Fewest plays required. Defaults to 1, so naming a cue asserts it was heard.", name: "minPlays", type: "non-negative integer" },
|
|
642
|
+
{ description: "Most plays allowed; 0 proves silence and 1 proves a one-shot stayed one.", name: "maxPlays", type: "non-negative integer" },
|
|
643
|
+
{ description: "Fewest milliseconds between this cue and the cue played before it, so one line cannot cut another.", name: "minGapMs", type: "non-negative integer" }
|
|
644
|
+
],
|
|
645
|
+
cardinality: "array",
|
|
646
|
+
kind: "audio",
|
|
647
|
+
observationPath: "runtimeObservations",
|
|
648
|
+
requiredCapabilities: ["runtime.audio"],
|
|
649
|
+
resultIdPrefix: "audio.",
|
|
650
|
+
supportedOn: ["web", "desktop"],
|
|
651
|
+
triviality: "not-applicable",
|
|
652
|
+
trivialityRationale: "A cue count starts at zero and only a played cue moves it, so there is no initial value to reject."
|
|
653
|
+
},
|
|
616
654
|
{
|
|
617
655
|
description: "Proves runtime world metadata exposed by the application bridge.",
|
|
618
656
|
example: { world: { seed: 90210 } },
|
|
@@ -802,7 +840,8 @@ var PLAYTEST_ASSERTION_REGISTRY = [
|
|
|
802
840
|
{ description: "Exact render-chain quality tier required after the chain applies.", name: "tier", type: "string" },
|
|
803
841
|
{ description: "Stage ids to include, exclude, or find as an ordered subsequence in the applied chain.", name: "stages", type: "object" },
|
|
804
842
|
{ description: "Applied stage ids whose build returned a different graph node than its input; this is graph evidence, not pixel attribution.", name: "contributions", type: "object" },
|
|
805
|
-
{ description: "Temporal history rejection ceiling as a fraction from 0 to 1.", name: "velocity", type: "object" }
|
|
843
|
+
{ description: "Temporal history rejection ceiling as a fraction from 0 to 1.", name: "velocity", type: "object" },
|
|
844
|
+
{ description: "What the chain must be on each adapter class the harness classified from its own adapter.info reading; an unclassifiable adapter fails rather than matching either branch.", name: "perAdapter", type: "object" }
|
|
806
845
|
],
|
|
807
846
|
cardinality: "object",
|
|
808
847
|
kind: "renderChain",
|
|
@@ -852,6 +891,9 @@ function requiredPlaytestCapabilities(scenario, target) {
|
|
|
852
891
|
if (scenario.steps.some((step) => step.kind === "aimAt")) {
|
|
853
892
|
required.add("entity.setup");
|
|
854
893
|
}
|
|
894
|
+
if (scenario.assert?.geometry !== void 0) {
|
|
895
|
+
required.add("runtime.geometry");
|
|
896
|
+
}
|
|
855
897
|
if (scenario.artifacts?.screenshots !== false) {
|
|
856
898
|
required.add("browser.screenshot");
|
|
857
899
|
}
|
|
@@ -1512,6 +1554,53 @@ function contactAssertionSatisfiedAtStep(assertion, observations, scenario) {
|
|
|
1512
1554
|
const minimum = assertion.minCount ?? (assertion.maxCount === void 0 ? 1 : 0);
|
|
1513
1555
|
return stepAvailable && (!anonymous || candidates.length > 0) && count >= minimum && (assertion.maxCount === void 0 || count <= assertion.maxCount);
|
|
1514
1556
|
}
|
|
1557
|
+
function smallestGapBefore(recent, cue) {
|
|
1558
|
+
let smallest;
|
|
1559
|
+
for (let index = 1; index < recent.length; index += 1) {
|
|
1560
|
+
const entry = recent[index];
|
|
1561
|
+
const previous = recent[index - 1];
|
|
1562
|
+
if (!isRecord(entry) || !isRecord(previous)) continue;
|
|
1563
|
+
if (entry.cue !== cue) continue;
|
|
1564
|
+
if (typeof entry.atMs !== "number" || typeof previous.atMs !== "number") continue;
|
|
1565
|
+
const gap = entry.atMs - previous.atMs;
|
|
1566
|
+
if (smallest === void 0 || gap < smallest) smallest = gap;
|
|
1567
|
+
}
|
|
1568
|
+
return smallest;
|
|
1569
|
+
}
|
|
1570
|
+
function evaluateAudioAssertion(assertion, observations) {
|
|
1571
|
+
const gameplay = gameplayObservations(observations);
|
|
1572
|
+
const audio = isRecord(gameplay?.audio) ? gameplay.audio : void 0;
|
|
1573
|
+
const cues = isRecord(audio?.cues) ? audio.cues : void 0;
|
|
1574
|
+
const observed = cues === void 0 ? void 0 : cues[assertion.cue];
|
|
1575
|
+
const plays = typeof observed === "number" ? observed : 0;
|
|
1576
|
+
const minimum = assertion.minPlays ?? 1;
|
|
1577
|
+
const recent = Array.isArray(audio?.recentCues) ? audio.recentCues : [];
|
|
1578
|
+
const gap = smallestGapBefore(recent, assertion.cue);
|
|
1579
|
+
const gapPass = assertion.minGapMs === void 0 || gap === void 0 || gap >= assertion.minGapMs;
|
|
1580
|
+
const pass = cues !== void 0 && plays >= minimum && (assertion.maxPlays === void 0 || plays <= assertion.maxPlays) && gapPass;
|
|
1581
|
+
const result = {
|
|
1582
|
+
details: {
|
|
1583
|
+
cue: assertion.cue,
|
|
1584
|
+
maxPlays: assertion.maxPlays ?? null,
|
|
1585
|
+
minGapMs: assertion.minGapMs ?? null,
|
|
1586
|
+
minPlays: minimum,
|
|
1587
|
+
observed: cues === void 0 ? null : plays,
|
|
1588
|
+
observedGapMs: gap ?? null
|
|
1589
|
+
},
|
|
1590
|
+
id: `audio.${assertion.cue}`,
|
|
1591
|
+
pass
|
|
1592
|
+
};
|
|
1593
|
+
return pass ? { assertion: result } : {
|
|
1594
|
+
assertion: result,
|
|
1595
|
+
diagnostic: {
|
|
1596
|
+
code: "TN_PLAYTEST_AUDIO_ASSERTION_FAILED",
|
|
1597
|
+
message: cues === void 0 ? `No runtime audio ledger was published, so cue '${assertion.cue}' cannot be proved either way.` : gapPass ? `Cue '${assertion.cue}' played ${plays} time(s); expected at least ${minimum}${assertion.maxPlays === void 0 ? "" : ` and at most ${assertion.maxPlays}`}.` : `Cue '${assertion.cue}' started ${gap ?? 0} ms after the line before it, which is under the ${String(assertion.minGapMs)} ms it needs; one of them was cut off.`,
|
|
1598
|
+
observedRuntimePath: "observations.json/runtimeObservations/gameplay/audio/cues",
|
|
1599
|
+
severity: "error",
|
|
1600
|
+
suggestion: cues === void 0 ? "Run on a target whose bridge advertises runtime.audio, and pass `cue` to AudioBus.play/playAt for the lines under test." : "Read observations.json/runtimeObservations/gameplay/audio/recentCues for when each play happened, and check the one-shot flag that gates the cue."
|
|
1601
|
+
}
|
|
1602
|
+
};
|
|
1603
|
+
}
|
|
1515
1604
|
function evaluateWorldAssertion(assertion, observations) {
|
|
1516
1605
|
const gameplay = gameplayObservations(observations);
|
|
1517
1606
|
const world = isRecord(gameplay?.world) ? gameplay.world : void 0;
|
|
@@ -1683,6 +1772,47 @@ function runtimeAnimationObservations(value) {
|
|
|
1683
1772
|
return isRecord(gameplay?.animation) ? gameplay.animation : void 0;
|
|
1684
1773
|
}
|
|
1685
1774
|
|
|
1775
|
+
// src/protocol.ts
|
|
1776
|
+
var PLAYTEST_BRIDGE_GLOBAL = "__THREENATIVE_PLAYTEST_BRIDGE__";
|
|
1777
|
+
var PLAYTEST_PROTOCOL_VERSION = 1;
|
|
1778
|
+
var PLAYTEST_FROZEN_MARKER = "__threenativeFrozen";
|
|
1779
|
+
var PLAYTEST_ADVANCE_TICK_BUDGET_MS = 250;
|
|
1780
|
+
var PLAYTEST_STARTUP_COMPILE_BUDGET_MS = 15e3;
|
|
1781
|
+
var PLAYTEST_PROTOCOL_LIMITS = {
|
|
1782
|
+
maxEntitiesPerSample: 100,
|
|
1783
|
+
maxEventsPerDrain: 1e3,
|
|
1784
|
+
maxPayloadBytes: 1e6,
|
|
1785
|
+
operationTimeoutMs: 5e3
|
|
1786
|
+
};
|
|
1787
|
+
var PLAYTEST_STARTUP_READY_TIMEOUT_MS = 18e4;
|
|
1788
|
+
var PLAYTEST_FRAME_BUDGET_PHASES = ["hostGap", "overlay", "render", "residual", "update"];
|
|
1789
|
+
var PLAYTEST_FRAME_PASS_KINDS = ["main", "shadow", "reflection", "nested"];
|
|
1790
|
+
function jsonByteLength(value) {
|
|
1791
|
+
return new TextEncoder().encode(JSON.stringify(value)).byteLength;
|
|
1792
|
+
}
|
|
1793
|
+
function assertJsonSafe(value, path = "$") {
|
|
1794
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") {
|
|
1795
|
+
return;
|
|
1796
|
+
}
|
|
1797
|
+
if (typeof value === "number") {
|
|
1798
|
+
if (Number.isFinite(value)) {
|
|
1799
|
+
return;
|
|
1800
|
+
}
|
|
1801
|
+
throw new TypeError(`${path} must contain only finite JSON numbers.`);
|
|
1802
|
+
}
|
|
1803
|
+
if (Array.isArray(value)) {
|
|
1804
|
+
value.forEach((item, index) => assertJsonSafe(item, `${path}[${index}]`));
|
|
1805
|
+
return;
|
|
1806
|
+
}
|
|
1807
|
+
if (typeof value === "object") {
|
|
1808
|
+
for (const [key, item] of Object.entries(value)) {
|
|
1809
|
+
assertJsonSafe(item, `${path}.${key}`);
|
|
1810
|
+
}
|
|
1811
|
+
return;
|
|
1812
|
+
}
|
|
1813
|
+
throw new TypeError(`${path} must be JSON-safe.`);
|
|
1814
|
+
}
|
|
1815
|
+
|
|
1686
1816
|
// src/evaluators/render-evidence.ts
|
|
1687
1817
|
function projectedPixelsForEntity(snapshot, entity, viewport) {
|
|
1688
1818
|
const rendered = renderedEntity(snapshot, entity);
|
|
@@ -1805,13 +1935,47 @@ function evaluatePerformanceAssertion(assertion, series, sourcePath) {
|
|
|
1805
1935
|
samplesPass && triangles.length === samples.length && maxObservedTriangles !== void 0 && maxObservedTriangles <= assertion.maxTriangles
|
|
1806
1936
|
);
|
|
1807
1937
|
}
|
|
1938
|
+
const addPassBound = (unit, kind, ceiling) => {
|
|
1939
|
+
const noun = unit === "draws" ? "draw calls" : "triangles";
|
|
1940
|
+
const measured = observed.flatMap((sample) => {
|
|
1941
|
+
const pass2 = sample.passes?.find((candidate) => candidate.kind === kind);
|
|
1942
|
+
return pass2 === void 0 ? [] : [pass2[unit]];
|
|
1943
|
+
});
|
|
1944
|
+
const actual = measured.length === samples.length ? Math.max(...measured) : void 0;
|
|
1945
|
+
const id = unit === "draws" ? `performance.maxPassDrawCalls.${kind}` : `performance.maxPassTriangles.${kind}`;
|
|
1946
|
+
const pass = samplesPass && actual !== void 0 && actual <= ceiling;
|
|
1947
|
+
results.push({
|
|
1948
|
+
details: { actual: actual ?? null, expected: ceiling, pass: kind, sampleCount: samples.length, unit: noun },
|
|
1949
|
+
id,
|
|
1950
|
+
pass
|
|
1951
|
+
});
|
|
1952
|
+
if (!pass) diagnostics.push({
|
|
1953
|
+
code: "TN_PLAYTEST_PERFORMANCE_ASSERTION_FAILED",
|
|
1954
|
+
message: actual === void 0 ? `${id} received no per-pass samples for '${kind}'; ${measured.length} of ${samples.length} frames carried that pass.` : `${id} expected at most ${ceiling} ${noun}, observed ${actual}.`,
|
|
1955
|
+
observedRuntimePath: path,
|
|
1956
|
+
severity: "error",
|
|
1957
|
+
sourcePath,
|
|
1958
|
+
suggestion: "Keep the engine frame budget installed so the run carries a per-pass split; a renderer that reports no split cannot satisfy a per-pass ceiling."
|
|
1959
|
+
});
|
|
1960
|
+
};
|
|
1961
|
+
for (const [kind, ceiling] of Object.entries(assertion.maxPassDrawCalls ?? {}))
|
|
1962
|
+
addPassBound("draws", kind, ceiling);
|
|
1963
|
+
for (const [kind, ceiling] of Object.entries(assertion.maxPassTriangles ?? {}))
|
|
1964
|
+
addPassBound("triangles", kind, ceiling);
|
|
1808
1965
|
return { assertions: results, diagnostics };
|
|
1809
1966
|
}
|
|
1810
1967
|
function isRuntimeDiagnosticsSample(value) {
|
|
1811
1968
|
if (!isRecord(value) || typeof value.frameMs !== "number" || !Number.isFinite(value.frameMs) || value.frameMs <= 0) {
|
|
1812
1969
|
return false;
|
|
1813
1970
|
}
|
|
1814
|
-
return (value.drawCalls === void 0 || typeof value.drawCalls === "number" && Number.isFinite(value.drawCalls) && value.drawCalls >= 0) && (value.triangles === void 0 || typeof value.triangles === "number" && Number.isFinite(value.triangles) && value.triangles >= 0) && isFramePhaseSplit(value.phases);
|
|
1971
|
+
return (value.drawCalls === void 0 || typeof value.drawCalls === "number" && Number.isFinite(value.drawCalls) && value.drawCalls >= 0) && (value.triangles === void 0 || typeof value.triangles === "number" && Number.isFinite(value.triangles) && value.triangles >= 0) && isFramePhaseSplit(value.phases) && isFramePassSplit(value.passes);
|
|
1972
|
+
}
|
|
1973
|
+
function isFramePassSplit(value) {
|
|
1974
|
+
if (value === void 0) return true;
|
|
1975
|
+
if (!Array.isArray(value)) return false;
|
|
1976
|
+
return value.every(
|
|
1977
|
+
(pass) => isRecord(pass) && PLAYTEST_FRAME_PASS_KINDS.includes(pass.kind) && typeof pass.draws === "number" && Number.isFinite(pass.draws) && pass.draws >= 0 && typeof pass.triangles === "number" && Number.isFinite(pass.triangles) && pass.triangles >= 0
|
|
1978
|
+
);
|
|
1815
1979
|
}
|
|
1816
1980
|
function isFramePhaseSplit(value) {
|
|
1817
1981
|
if (value === void 0) return true;
|
|
@@ -3045,6 +3209,11 @@ function emitPerfSignalsWorld(ctx) {
|
|
|
3045
3209
|
suggestion: "Expose a bounded events callback on the playtest bridge and inspect the emitted signal name and entity."
|
|
3046
3210
|
});
|
|
3047
3211
|
}
|
|
3212
|
+
for (const assertion of scenarioAssertions.audio ?? []) {
|
|
3213
|
+
const result = evaluateAudioAssertion(assertion, input.report.observations?.runtimeObservations);
|
|
3214
|
+
assertions.push(result.assertion);
|
|
3215
|
+
if (result.diagnostic !== void 0) diagnostics.push(result.diagnostic);
|
|
3216
|
+
}
|
|
3048
3217
|
if (scenarioAssertions.world !== void 0) {
|
|
3049
3218
|
const result = evaluateWorldAssertion(scenarioAssertions.world, input.report.observations?.runtimeObservations);
|
|
3050
3219
|
assertions.push(result.assertion);
|
|
@@ -3616,34 +3785,65 @@ function emitWorldTopology(value, assertions, diagnostics) {
|
|
|
3616
3785
|
}
|
|
3617
3786
|
}
|
|
3618
3787
|
|
|
3788
|
+
// src/runner/browser.ts
|
|
3789
|
+
var SOFTWARE_ADAPTER = /swiftshader|llvmpipe|lavapipe|softwarerasterizer|software adapter|basic render/i;
|
|
3790
|
+
function softwareAdapterName(adapter) {
|
|
3791
|
+
if (adapter === void 0) return void 0;
|
|
3792
|
+
for (const value of Object.values(adapter)) {
|
|
3793
|
+
if (typeof value === "string" && SOFTWARE_ADAPTER.test(value)) return value;
|
|
3794
|
+
}
|
|
3795
|
+
return void 0;
|
|
3796
|
+
}
|
|
3797
|
+
|
|
3798
|
+
// src/evaluators/adapter-class.ts
|
|
3799
|
+
function classifyAdapter(report) {
|
|
3800
|
+
const capture = report.capture;
|
|
3801
|
+
if (capture === void 0 || capture.rendererKind !== "webgpu") return {};
|
|
3802
|
+
if (adapterIdentity(capture.adapter) === void 0) return {};
|
|
3803
|
+
const software = softwareAdapterName(capture.adapter);
|
|
3804
|
+
return software === void 0 ? { adapterClass: "hardware" } : { adapterClass: "software", softwareAdapter: software };
|
|
3805
|
+
}
|
|
3806
|
+
var ADAPTER_IDENTITY_KEYS = ["architecture", "description", "device", "vendor"];
|
|
3807
|
+
function adapterIdentity(adapter) {
|
|
3808
|
+
if (adapter === void 0) return void 0;
|
|
3809
|
+
for (const key of ADAPTER_IDENTITY_KEYS) {
|
|
3810
|
+
const value = adapter[key];
|
|
3811
|
+
if (typeof value === "string" && value.trim() !== "") return value;
|
|
3812
|
+
}
|
|
3813
|
+
return void 0;
|
|
3814
|
+
}
|
|
3815
|
+
|
|
3619
3816
|
// src/evaluators/render-chain.ts
|
|
3620
3817
|
function emitRenderChain(ctx) {
|
|
3621
3818
|
const assertion = ctx.scenarioAssertions.renderChain;
|
|
3622
3819
|
if (assertion === void 0) return;
|
|
3623
3820
|
const observed = ctx.input.report.observations?.renderChain;
|
|
3624
|
-
|
|
3625
|
-
|
|
3821
|
+
const selected = selectExpectation(ctx, assertion);
|
|
3822
|
+
const expected = selected.expectation;
|
|
3823
|
+
if (expected.tier !== void 0) {
|
|
3824
|
+
const pass = observed?.tier === expected.tier;
|
|
3626
3825
|
ctx.assertions.push({
|
|
3627
|
-
details: { expected:
|
|
3826
|
+
details: { ...selected.provenance, expected: expected.tier, observed: observed?.tier },
|
|
3628
3827
|
id: "renderChain.tier",
|
|
3629
3828
|
pass
|
|
3630
3829
|
});
|
|
3631
3830
|
if (!pass) {
|
|
3632
3831
|
ctx.diagnostics.push({
|
|
3633
3832
|
code: observed === void 0 ? "TN_PLAYTEST_RENDER_CHAIN_UNOBSERVABLE" : "TN_PLAYTEST_RENDER_CHAIN_TIER_FAILED",
|
|
3634
|
-
message: observed === void 0 ? "Render-chain tier was not observed because the TN_RENDER_CHAIN marker was absent." : `Render-chain tier '${observed.tier}' did not match the asserted tier '${
|
|
3833
|
+
message: observed === void 0 ? "Render-chain tier was not observed because the TN_RENDER_CHAIN marker was absent." : `Render-chain tier '${observed.tier}' did not match the asserted tier '${expected.tier}'.`,
|
|
3635
3834
|
observedRuntimePath: "observations.json/renderChain/tier",
|
|
3636
3835
|
severity: "error",
|
|
3637
3836
|
suggestion: "Install the RenderChain through the renderer seam and keep its marker callback connected to the playtest bridge."
|
|
3638
3837
|
});
|
|
3639
3838
|
}
|
|
3640
3839
|
}
|
|
3641
|
-
const stageAssertion =
|
|
3840
|
+
const stageAssertion = expected.stages;
|
|
3642
3841
|
if (stageAssertion !== void 0) {
|
|
3643
3842
|
const observedStages = observed?.stages;
|
|
3644
3843
|
if (stageAssertion.includes !== void 0) {
|
|
3645
3844
|
emitStageCheck(
|
|
3646
3845
|
ctx,
|
|
3846
|
+
selected.provenance,
|
|
3647
3847
|
observedStages,
|
|
3648
3848
|
"includes",
|
|
3649
3849
|
stageAssertion.includes,
|
|
@@ -3653,6 +3853,7 @@ function emitRenderChain(ctx) {
|
|
|
3653
3853
|
if (stageAssertion.excludes !== void 0) {
|
|
3654
3854
|
emitStageCheck(
|
|
3655
3855
|
ctx,
|
|
3856
|
+
selected.provenance,
|
|
3656
3857
|
observedStages,
|
|
3657
3858
|
"excludes",
|
|
3658
3859
|
stageAssertion.excludes,
|
|
@@ -3662,6 +3863,7 @@ function emitRenderChain(ctx) {
|
|
|
3662
3863
|
if (stageAssertion.order !== void 0) {
|
|
3663
3864
|
emitStageCheck(
|
|
3664
3865
|
ctx,
|
|
3866
|
+
selected.provenance,
|
|
3665
3867
|
observedStages,
|
|
3666
3868
|
"order",
|
|
3667
3869
|
stageAssertion.order,
|
|
@@ -3669,7 +3871,7 @@ function emitRenderChain(ctx) {
|
|
|
3669
3871
|
);
|
|
3670
3872
|
}
|
|
3671
3873
|
}
|
|
3672
|
-
const contributionAssertion =
|
|
3874
|
+
const contributionAssertion = expected.contributions;
|
|
3673
3875
|
if (contributionAssertion !== void 0) {
|
|
3674
3876
|
const observedContributions = observed?.contributions;
|
|
3675
3877
|
const pass = Array.isArray(observedContributions) && contributionAssertion.graphOutputChanged.every(
|
|
@@ -3677,6 +3879,7 @@ function emitRenderChain(ctx) {
|
|
|
3677
3879
|
);
|
|
3678
3880
|
ctx.assertions.push({
|
|
3679
3881
|
details: {
|
|
3882
|
+
...selected.provenance,
|
|
3680
3883
|
expected: contributionAssertion.graphOutputChanged,
|
|
3681
3884
|
observed: observedContributions
|
|
3682
3885
|
},
|
|
@@ -3693,14 +3896,15 @@ function emitRenderChain(ctx) {
|
|
|
3693
3896
|
});
|
|
3694
3897
|
}
|
|
3695
3898
|
}
|
|
3696
|
-
if (
|
|
3899
|
+
if (expected.velocity !== void 0) {
|
|
3697
3900
|
const rejectionFraction = observed?.velocity.rejectionFraction;
|
|
3698
3901
|
const measurementFrame = observed?.velocity.measurementFrame;
|
|
3699
3902
|
const hasMeasurement = rejectionFraction !== void 0 && Number.isFinite(rejectionFraction) && typeof measurementFrame === "number" && Number.isInteger(measurementFrame) && measurementFrame >= 0;
|
|
3700
|
-
const pass = hasMeasurement && rejectionFraction !== void 0 && rejectionFraction <=
|
|
3903
|
+
const pass = hasMeasurement && rejectionFraction !== void 0 && rejectionFraction <= expected.velocity.maxRejectionFraction;
|
|
3701
3904
|
ctx.assertions.push({
|
|
3702
3905
|
details: {
|
|
3703
|
-
|
|
3906
|
+
...selected.provenance,
|
|
3907
|
+
expected: expected.velocity.maxRejectionFraction,
|
|
3704
3908
|
measurementFrame,
|
|
3705
3909
|
observed: rejectionFraction
|
|
3706
3910
|
},
|
|
@@ -3710,17 +3914,47 @@ function emitRenderChain(ctx) {
|
|
|
3710
3914
|
if (!pass) {
|
|
3711
3915
|
ctx.diagnostics.push({
|
|
3712
3916
|
code: observed === void 0 || !hasMeasurement ? "TN_PLAYTEST_RENDER_CHAIN_UNOBSERVABLE" : "TN_PLAYTEST_RENDER_CHAIN_REJECTION_FAILED",
|
|
3713
|
-
message: observed === void 0 ? "Render-chain velocity rejection was not observed because the TN_RENDER_CHAIN marker was absent." : !hasMeasurement ? "Render-chain velocity was provisioned without a fresh completed-frame history-rejection measurement." : `Render-chain history rejection fraction ${rejectionFraction ?? "missing"} exceeded the asserted ceiling ${
|
|
3917
|
+
message: observed === void 0 ? "Render-chain velocity rejection was not observed because the TN_RENDER_CHAIN marker was absent." : !hasMeasurement ? "Render-chain velocity was provisioned without a fresh completed-frame history-rejection measurement." : `Render-chain history rejection fraction ${rejectionFraction ?? "missing"} exceeded the asserted ceiling ${expected.velocity.maxRejectionFraction}.`,
|
|
3714
3918
|
observedRuntimePath: "observations.json/renderChain/velocity/rejectionFraction",
|
|
3715
3919
|
severity: "error",
|
|
3716
3920
|
suggestion: "Publish the temporal stage's measured rejection fraction on the same render-chain marker used for tier reporting."
|
|
3717
3921
|
});
|
|
3718
3922
|
}
|
|
3719
3923
|
}
|
|
3924
|
+
if (assertion.perAdapter !== void 0 && selected.classification === void 0) {
|
|
3925
|
+
ctx.assertions.push({
|
|
3926
|
+
details: { ...selected.provenance, expected: Object.keys(assertion.perAdapter) },
|
|
3927
|
+
id: "renderChain.adapterClass",
|
|
3928
|
+
pass: false
|
|
3929
|
+
});
|
|
3930
|
+
ctx.diagnostics.push({
|
|
3931
|
+
code: "TN_PLAYTEST_RENDER_CHAIN_ADAPTER_UNCLASSIFIED",
|
|
3932
|
+
message: "No adapter.info field named a software rasteriser, so this run is not proven to be either adapter class and was held to the flat render-chain expectation.",
|
|
3933
|
+
observedRuntimePath: "observations.json/capture/adapter",
|
|
3934
|
+
severity: "error",
|
|
3935
|
+
suggestion: "Run on a lane that reports adapter.info, or drop perAdapter and assert one policy for every adapter."
|
|
3936
|
+
});
|
|
3937
|
+
}
|
|
3720
3938
|
}
|
|
3721
|
-
function
|
|
3939
|
+
function selectExpectation(ctx, assertion) {
|
|
3940
|
+
const flat = {
|
|
3941
|
+
...assertion.tier === void 0 ? {} : { tier: assertion.tier },
|
|
3942
|
+
...assertion.stages === void 0 ? {} : { stages: assertion.stages },
|
|
3943
|
+
...assertion.contributions === void 0 ? {} : { contributions: assertion.contributions },
|
|
3944
|
+
...assertion.velocity === void 0 ? {} : { velocity: assertion.velocity }
|
|
3945
|
+
};
|
|
3946
|
+
const provenance = classifyAdapter(ctx.input.report);
|
|
3947
|
+
const { adapterClass } = provenance;
|
|
3948
|
+
const branch = adapterClass === void 0 ? void 0 : assertion.perAdapter?.[adapterClass];
|
|
3949
|
+
return {
|
|
3950
|
+
classification: adapterClass,
|
|
3951
|
+
expectation: branch ?? flat,
|
|
3952
|
+
provenance
|
|
3953
|
+
};
|
|
3954
|
+
}
|
|
3955
|
+
function emitStageCheck(ctx, provenance, observed, kind, expected, pass) {
|
|
3722
3956
|
ctx.assertions.push({
|
|
3723
|
-
details: { expected, observed },
|
|
3957
|
+
details: { ...provenance, expected, observed },
|
|
3724
3958
|
id: `renderChain.stages.${kind}`,
|
|
3725
3959
|
pass
|
|
3726
3960
|
});
|
|
@@ -4166,6 +4400,19 @@ function evaluateRichPlaytestAssertions(input) {
|
|
|
4166
4400
|
emitRenderChain(ctx);
|
|
4167
4401
|
emitScene(ctx);
|
|
4168
4402
|
emitSceneNodes(ctx);
|
|
4403
|
+
if (scenarioAssertions.geometry !== void 0) {
|
|
4404
|
+
const observed = input.report.observations?.geometry;
|
|
4405
|
+
const status = observed?.status;
|
|
4406
|
+
const pass = status === "captured";
|
|
4407
|
+
assertions.push({ details: { observed, status }, id: "geometry.observed", pass });
|
|
4408
|
+
if (!pass) diagnostics.push({
|
|
4409
|
+
code: "TN_PLAYTEST_GEOMETRY_UNOBSERVED",
|
|
4410
|
+
message: "A geometry assertion was evaluated against a run whose bridge reported no captured geometry frame.",
|
|
4411
|
+
observedRuntimePath: "observations.json/geometry",
|
|
4412
|
+
severity: "error",
|
|
4413
|
+
suggestion: "Request the capture on a target whose bridge advertises runtime.geometry and is presenting world frames."
|
|
4414
|
+
});
|
|
4415
|
+
}
|
|
4169
4416
|
emitCausedBy(ctx);
|
|
4170
4417
|
emitStartup(ctx);
|
|
4171
4418
|
emitMovementEvidence(ctx);
|
|
@@ -4471,46 +4718,6 @@ function playtestDiagnostic(code, message, instruction, details = {}) {
|
|
|
4471
4718
|
};
|
|
4472
4719
|
}
|
|
4473
4720
|
|
|
4474
|
-
// src/protocol.ts
|
|
4475
|
-
var PLAYTEST_BRIDGE_GLOBAL = "__THREENATIVE_PLAYTEST_BRIDGE__";
|
|
4476
|
-
var PLAYTEST_PROTOCOL_VERSION = 1;
|
|
4477
|
-
var PLAYTEST_FROZEN_MARKER = "__threenativeFrozen";
|
|
4478
|
-
var PLAYTEST_ADVANCE_TICK_BUDGET_MS = 250;
|
|
4479
|
-
var PLAYTEST_STARTUP_COMPILE_BUDGET_MS = 15e3;
|
|
4480
|
-
var PLAYTEST_PROTOCOL_LIMITS = {
|
|
4481
|
-
maxEntitiesPerSample: 100,
|
|
4482
|
-
maxEventsPerDrain: 1e3,
|
|
4483
|
-
maxPayloadBytes: 1e6,
|
|
4484
|
-
operationTimeoutMs: 5e3
|
|
4485
|
-
};
|
|
4486
|
-
var PLAYTEST_STARTUP_READY_TIMEOUT_MS = 18e4;
|
|
4487
|
-
var PLAYTEST_FRAME_BUDGET_PHASES = ["hostGap", "overlay", "render", "residual", "update"];
|
|
4488
|
-
function jsonByteLength(value) {
|
|
4489
|
-
return new TextEncoder().encode(JSON.stringify(value)).byteLength;
|
|
4490
|
-
}
|
|
4491
|
-
function assertJsonSafe(value, path = "$") {
|
|
4492
|
-
if (value === null || typeof value === "string" || typeof value === "boolean") {
|
|
4493
|
-
return;
|
|
4494
|
-
}
|
|
4495
|
-
if (typeof value === "number") {
|
|
4496
|
-
if (Number.isFinite(value)) {
|
|
4497
|
-
return;
|
|
4498
|
-
}
|
|
4499
|
-
throw new TypeError(`${path} must contain only finite JSON numbers.`);
|
|
4500
|
-
}
|
|
4501
|
-
if (Array.isArray(value)) {
|
|
4502
|
-
value.forEach((item, index) => assertJsonSafe(item, `${path}[${index}]`));
|
|
4503
|
-
return;
|
|
4504
|
-
}
|
|
4505
|
-
if (typeof value === "object") {
|
|
4506
|
-
for (const [key, item] of Object.entries(value)) {
|
|
4507
|
-
assertJsonSafe(item, `${path}.${key}`);
|
|
4508
|
-
}
|
|
4509
|
-
return;
|
|
4510
|
-
}
|
|
4511
|
-
throw new TypeError(`${path} must be JSON-safe.`);
|
|
4512
|
-
}
|
|
4513
|
-
|
|
4514
4721
|
// src/scenario/errors.ts
|
|
4515
4722
|
var PlaytestScenarioError = class extends Error {
|
|
4516
4723
|
constructor(diagnostic) {
|
|
@@ -4688,6 +4895,8 @@ var GENERATED_ASSERTION_FIELD_VALIDATORS = Object.freeze({
|
|
|
4688
4895
|
"minFps": (value) => typeof value === "number" && Number.isFinite(value),
|
|
4689
4896
|
"maxPhaseMsP95": (value) => isRecord2(value),
|
|
4690
4897
|
"maxDrawCalls": (value) => typeof value === "number" && Number.isFinite(value),
|
|
4898
|
+
"maxPassDrawCalls": (value) => isRecord2(value),
|
|
4899
|
+
"maxPassTriangles": (value) => isRecord2(value),
|
|
4691
4900
|
"maxTriangles": (value) => typeof value === "number" && Number.isFinite(value)
|
|
4692
4901
|
}),
|
|
4693
4902
|
"parity": Object.freeze({
|
|
@@ -4704,6 +4913,12 @@ var GENERATED_ASSERTION_FIELD_VALIDATORS = Object.freeze({
|
|
|
4704
4913
|
"present": (value) => typeof value === "boolean",
|
|
4705
4914
|
"allowTrivial": (value) => typeof value === "string" && value.replace(/\s/gu, "").length >= MIN_TRIVIALITY_REASON_LENGTH
|
|
4706
4915
|
}),
|
|
4916
|
+
"audio": Object.freeze({
|
|
4917
|
+
"cue": (value) => typeof value === "string" && value.trim() !== "",
|
|
4918
|
+
"minPlays": (value) => typeof value === "number" && Number.isInteger(value) && value >= 0,
|
|
4919
|
+
"maxPlays": (value) => typeof value === "number" && Number.isInteger(value) && value >= 0,
|
|
4920
|
+
"minGapMs": (value) => typeof value === "number" && Number.isInteger(value) && value >= 0
|
|
4921
|
+
}),
|
|
4707
4922
|
"world": Object.freeze({
|
|
4708
4923
|
"seed": (value) => true,
|
|
4709
4924
|
"runtime": (value) => isRecord2(value)
|
|
@@ -4773,7 +4988,8 @@ var GENERATED_ASSERTION_FIELD_VALIDATORS = Object.freeze({
|
|
|
4773
4988
|
"tier": (value) => typeof value === "string" && value.trim() !== "",
|
|
4774
4989
|
"stages": (value) => isRecord2(value),
|
|
4775
4990
|
"contributions": (value) => isRecord2(value),
|
|
4776
|
-
"velocity": (value) => isRecord2(value)
|
|
4991
|
+
"velocity": (value) => isRecord2(value),
|
|
4992
|
+
"perAdapter": (value) => isRecord2(value)
|
|
4777
4993
|
})
|
|
4778
4994
|
});
|
|
4779
4995
|
|
|
@@ -5007,10 +5223,12 @@ function validateDeviceMetricsAssertion(value, scenarioPath, objectPath) {
|
|
|
5007
5223
|
}
|
|
5008
5224
|
function validatePerformanceAssertion(value, scenarioPath, objectPath) {
|
|
5009
5225
|
const record4 = requireRecord(value, scenarioPath, objectPath);
|
|
5010
|
-
rejectUnknownKeys(record4, ["maxDrawCalls", "maxFrameMsP95", "maxPhaseMsP95", "maxTriangles", "minFps"], scenarioPath, objectPath);
|
|
5226
|
+
rejectUnknownKeys(record4, ["maxDrawCalls", "maxFrameMsP95", "maxPassDrawCalls", "maxPassTriangles", "maxPhaseMsP95", "maxTriangles", "minFps"], scenarioPath, objectPath);
|
|
5011
5227
|
return {
|
|
5012
5228
|
...present("maxDrawCalls", optionalNonNegativeNumber(record4, "maxDrawCalls", scenarioPath, objectPath)),
|
|
5013
5229
|
...present("maxFrameMsP95", optionalNonNegativeNumber(record4, "maxFrameMsP95", scenarioPath, objectPath)),
|
|
5230
|
+
...present("maxPassDrawCalls", validatePassBudget(record4.maxPassDrawCalls, scenarioPath, `${objectPath}.maxPassDrawCalls`)),
|
|
5231
|
+
...present("maxPassTriangles", validatePassBudget(record4.maxPassTriangles, scenarioPath, `${objectPath}.maxPassTriangles`)),
|
|
5014
5232
|
...present("maxPhaseMsP95", validatePhaseBudget(record4.maxPhaseMsP95, scenarioPath, `${objectPath}.maxPhaseMsP95`)),
|
|
5015
5233
|
...present("maxTriangles", optionalNonNegativeNumber(record4, "maxTriangles", scenarioPath, objectPath)),
|
|
5016
5234
|
...present("minFps", optionalNonNegativeNumber(record4, "minFps", scenarioPath, objectPath))
|
|
@@ -5069,6 +5287,33 @@ function validateParityAssertion(value, scenarioPath, objectPath) {
|
|
|
5069
5287
|
}
|
|
5070
5288
|
function validateRenderChainAssertion(value, scenarioPath, objectPath) {
|
|
5071
5289
|
const record4 = requireRecord(value, scenarioPath, objectPath);
|
|
5290
|
+
const perAdapter = record4.perAdapter === void 0 ? void 0 : validateRenderChainPerAdapter(record4.perAdapter, scenarioPath, `${objectPath}.perAdapter`);
|
|
5291
|
+
const expectation = validateRenderChainExpectation(record4, scenarioPath, objectPath);
|
|
5292
|
+
return perAdapter === void 0 ? expectation : { ...expectation, perAdapter };
|
|
5293
|
+
}
|
|
5294
|
+
function validateRenderChainPerAdapter(value, scenarioPath, objectPath) {
|
|
5295
|
+
const record4 = requireRecord(value, scenarioPath, objectPath);
|
|
5296
|
+
const entries = Object.entries(record4);
|
|
5297
|
+
if (entries.length === 0) {
|
|
5298
|
+
throw invalidScenario(scenarioPath, `'${objectPath}' must name at least one adapter class.`);
|
|
5299
|
+
}
|
|
5300
|
+
const result = {};
|
|
5301
|
+
for (const [kind, branch] of entries) {
|
|
5302
|
+
if (kind !== "hardware" && kind !== "software") {
|
|
5303
|
+
throw invalidScenario(
|
|
5304
|
+
scenarioPath,
|
|
5305
|
+
`'${objectPath}.${kind}' is not an adapter class this harness can classify; expected hardware or software.`
|
|
5306
|
+
);
|
|
5307
|
+
}
|
|
5308
|
+
result[kind] = validateRenderChainExpectation(
|
|
5309
|
+
requireRecord(branch, scenarioPath, `${objectPath}.${kind}`),
|
|
5310
|
+
scenarioPath,
|
|
5311
|
+
`${objectPath}.${kind}`
|
|
5312
|
+
);
|
|
5313
|
+
}
|
|
5314
|
+
return result;
|
|
5315
|
+
}
|
|
5316
|
+
function validateRenderChainExpectation(record4, scenarioPath, objectPath) {
|
|
5072
5317
|
const tier = record4.tier;
|
|
5073
5318
|
if (tier !== void 0 && tier !== "high" && tier !== "medium" && tier !== "low" && tier !== "off") {
|
|
5074
5319
|
throw invalidScenario(scenarioPath, `'${objectPath}.tier' must be high, medium, low, or off, received ${describeValue(tier)}.`);
|
|
@@ -5147,6 +5392,25 @@ function validateStartupAssertion(value, scenarioPath, objectPath) {
|
|
|
5147
5392
|
}
|
|
5148
5393
|
return result;
|
|
5149
5394
|
}
|
|
5395
|
+
function validatePassBudget(value, scenarioPath, objectPath) {
|
|
5396
|
+
if (value === void 0) return void 0;
|
|
5397
|
+
const record4 = requireRecord(value, scenarioPath, objectPath);
|
|
5398
|
+
const entries = Object.entries(record4);
|
|
5399
|
+
if (entries.length === 0)
|
|
5400
|
+
throw invalidScenario(scenarioPath, `${objectPath} must name at least one render pass.`);
|
|
5401
|
+
const budget = {};
|
|
5402
|
+
for (const [pass, ceiling] of entries) {
|
|
5403
|
+
if (!PLAYTEST_FRAME_PASS_KINDS.includes(pass))
|
|
5404
|
+
throw invalidScenario(
|
|
5405
|
+
scenarioPath,
|
|
5406
|
+
`${objectPath}.${pass} is not a render pass. Expected one of: ${PLAYTEST_FRAME_PASS_KINDS.join(", ")}.`
|
|
5407
|
+
);
|
|
5408
|
+
if (typeof ceiling !== "number" || !Number.isFinite(ceiling) || ceiling < 0)
|
|
5409
|
+
throw invalidScenario(scenarioPath, `${objectPath}.${pass} must be a non-negative number of draw calls or triangles.`);
|
|
5410
|
+
budget[pass] = ceiling;
|
|
5411
|
+
}
|
|
5412
|
+
return budget;
|
|
5413
|
+
}
|
|
5150
5414
|
function validatePhaseBudget(value, scenarioPath, objectPath) {
|
|
5151
5415
|
if (value === void 0) return void 0;
|
|
5152
5416
|
const record4 = requireRecord(value, scenarioPath, objectPath);
|
|
@@ -5612,29 +5876,30 @@ function validateNestedAssertionKeys(kind, value, scenarioPath, suffix) {
|
|
|
5612
5876
|
`assert.${kind}${suffix}.runtime`
|
|
5613
5877
|
);
|
|
5614
5878
|
}
|
|
5615
|
-
if (kind === "renderChain"
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
|
|
5619
|
-
scenarioPath,
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
|
|
5627
|
-
scenarioPath,
|
|
5628
|
-
`assert.${kind}${suffix}.contributions`
|
|
5629
|
-
);
|
|
5879
|
+
if (kind === "renderChain") {
|
|
5880
|
+
rejectRenderChainExpectationKeys(value, scenarioPath, `assert.${kind}${suffix}`);
|
|
5881
|
+
if (isRecord3(value.perAdapter)) {
|
|
5882
|
+
const branchPath = `assert.renderChain${suffix}.perAdapter`;
|
|
5883
|
+
rejectUnknownKeys(value.perAdapter, ["hardware", "software"], scenarioPath, branchPath);
|
|
5884
|
+
for (const [adapterKind, branch] of Object.entries(value.perAdapter)) {
|
|
5885
|
+
if (isRecord3(branch)) {
|
|
5886
|
+
rejectUnknownKeys(branch, ["contributions", "stages", "tier", "velocity"], scenarioPath, `${branchPath}.${adapterKind}`);
|
|
5887
|
+
rejectRenderChainExpectationKeys(branch, scenarioPath, `${branchPath}.${adapterKind}`);
|
|
5888
|
+
}
|
|
5889
|
+
}
|
|
5890
|
+
}
|
|
5630
5891
|
}
|
|
5631
|
-
|
|
5632
|
-
|
|
5633
|
-
|
|
5634
|
-
|
|
5635
|
-
|
|
5636
|
-
|
|
5637
|
-
|
|
5892
|
+
}
|
|
5893
|
+
var RENDER_CHAIN_NESTED_KEYS = {
|
|
5894
|
+
contributions: ["graphOutputChanged"],
|
|
5895
|
+
stages: ["excludes", "includes", "order"],
|
|
5896
|
+
velocity: ["maxRejectionFraction"]
|
|
5897
|
+
};
|
|
5898
|
+
function rejectRenderChainExpectationKeys(value, scenarioPath, objectPath) {
|
|
5899
|
+
for (const [field, keys] of Object.entries(RENDER_CHAIN_NESTED_KEYS)) {
|
|
5900
|
+
if (isRecord3(value[field])) {
|
|
5901
|
+
rejectUnknownKeys(value[field], keys, scenarioPath, `${objectPath}.${field}`);
|
|
5902
|
+
}
|
|
5638
5903
|
}
|
|
5639
5904
|
}
|
|
5640
5905
|
|
|
@@ -5935,6 +6200,7 @@ var PLAYTEST_STEP_KEYS = [
|
|
|
5935
6200
|
"holdTicks",
|
|
5936
6201
|
"kind",
|
|
5937
6202
|
"label",
|
|
6203
|
+
"lifecycle",
|
|
5938
6204
|
"overlayMessage",
|
|
5939
6205
|
"pitch",
|
|
5940
6206
|
"pointerPosition",
|
|
@@ -5971,6 +6237,7 @@ function validateStep(value, scenarioPath, index) {
|
|
|
5971
6237
|
"holdFrames",
|
|
5972
6238
|
"holdTicks",
|
|
5973
6239
|
"kind",
|
|
6240
|
+
"lifecycle",
|
|
5974
6241
|
"overlayMessage",
|
|
5975
6242
|
"pitch",
|
|
5976
6243
|
"pointerPosition",
|
|
@@ -6020,9 +6287,9 @@ function validateStep(value, scenarioPath, index) {
|
|
|
6020
6287
|
const holdTicks = positiveInteger(value.holdTicks);
|
|
6021
6288
|
const waitFrames = positiveInteger(value.waitFrames);
|
|
6022
6289
|
const waitTicks = positiveInteger(value.waitTicks);
|
|
6023
|
-
const kind = value.kind === "aimAt" ? "aimAt" : value.kind === "click" ? "click" : value.kind === "wait" ? "wait" : value.kind === "input" ? "input" : void 0;
|
|
6290
|
+
const kind = value.kind === "aimAt" ? "aimAt" : value.kind === "click" ? "click" : value.kind === "lifecycle" ? "lifecycle" : value.kind === "wait" ? "wait" : value.kind === "input" ? "input" : void 0;
|
|
6024
6291
|
if (value.kind !== void 0 && kind === void 0) {
|
|
6025
|
-
throw invalidStep(scenarioPath, `Scenario step ${index} kind must be 'aimAt', 'click', 'input', or 'wait'.`);
|
|
6292
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} kind must be 'aimAt', 'click', 'input', 'lifecycle', or 'wait'.`);
|
|
6026
6293
|
}
|
|
6027
6294
|
const at = validateClickTarget(value.at, scenarioPath, index);
|
|
6028
6295
|
const target = validateAimTarget(value.target, scenarioPath, index);
|
|
@@ -6036,6 +6303,10 @@ function validateStep(value, scenarioPath, index) {
|
|
|
6036
6303
|
if (isRecord3(value.window)) {
|
|
6037
6304
|
rejectUnknownKeys(value.window, ["height", "operation", "width"], scenarioPath, `steps[${index}].window`);
|
|
6038
6305
|
}
|
|
6306
|
+
if (isRecord3(value.lifecycle)) {
|
|
6307
|
+
rejectUnknownKeys(value.lifecycle, ["operation", "rotation"], scenarioPath, `steps[${index}].lifecycle`);
|
|
6308
|
+
}
|
|
6309
|
+
const lifecycle = validateLifecycleStep(value.lifecycle, scenarioPath, index);
|
|
6039
6310
|
if (kind !== "click" && (at !== void 0 || value.at !== void 0)) {
|
|
6040
6311
|
throw invalidStep(scenarioPath, `Scenario step ${index} declares at, which belongs to kind 'click'.`);
|
|
6041
6312
|
}
|
|
@@ -6102,8 +6373,38 @@ function validateStep(value, scenarioPath, index) {
|
|
|
6102
6373
|
if (value.window !== void 0 && window === void 0) {
|
|
6103
6374
|
throw invalidStep(scenarioPath, `Scenario step ${index} window must define minimize, restore, or resize with positive width and height.`);
|
|
6104
6375
|
}
|
|
6105
|
-
if (
|
|
6106
|
-
throw invalidStep(scenarioPath, `Scenario step ${index} must define
|
|
6376
|
+
if (value.lifecycle !== void 0 && lifecycle === void 0) {
|
|
6377
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} lifecycle must define an operation of 'background', 'foreground', or 'rotate', and 'rotate' must name a rotation from 0 through 3.`);
|
|
6378
|
+
}
|
|
6379
|
+
if (kind !== "lifecycle" && value.lifecycle !== void 0) {
|
|
6380
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} declares lifecycle, which belongs to kind 'lifecycle'.`);
|
|
6381
|
+
}
|
|
6382
|
+
if (kind === "lifecycle") {
|
|
6383
|
+
if (lifecycle === void 0) {
|
|
6384
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} with kind 'lifecycle' must define lifecycle.operation.`);
|
|
6385
|
+
}
|
|
6386
|
+
for (const forbidden of [
|
|
6387
|
+
"holdFrames",
|
|
6388
|
+
"holdTicks",
|
|
6389
|
+
"label",
|
|
6390
|
+
"overlayMessage",
|
|
6391
|
+
"pointerPosition",
|
|
6392
|
+
"pointers",
|
|
6393
|
+
"press",
|
|
6394
|
+
"screenshot",
|
|
6395
|
+
"target",
|
|
6396
|
+
"waitFrames",
|
|
6397
|
+
"waitTicks",
|
|
6398
|
+
"wheel",
|
|
6399
|
+
"window"
|
|
6400
|
+
]) {
|
|
6401
|
+
if (value[forbidden] !== void 0) {
|
|
6402
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} with kind 'lifecycle' cannot define ${forbidden}; a lifecycle step is one device operation and nothing else.`);
|
|
6403
|
+
}
|
|
6404
|
+
}
|
|
6405
|
+
}
|
|
6406
|
+
if (at === void 0 && press === void 0 && overlayMessage === void 0 && pointerPosition === void 0 && pointers === void 0 && wheel === void 0 && window === void 0 && waitFrames === void 0 && waitTicks === void 0 && target === void 0 && waitForResource === void 0 && lifecycle === void 0) {
|
|
6407
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} must define click at, press, overlayMessage, pointerPosition, pointers, wheel, window, aimAt target, lifecycle operation, or waitFrames/waitTicks.`);
|
|
6107
6408
|
}
|
|
6108
6409
|
if (value.holdFrames !== void 0 && holdFrames === void 0) {
|
|
6109
6410
|
throw invalidStep(scenarioPath, `Scenario step ${index} holdFrames must be a positive integer.`);
|
|
@@ -6132,6 +6433,7 @@ function validateStep(value, scenarioPath, index) {
|
|
|
6132
6433
|
...holdTicks === void 0 ? {} : { holdTicks },
|
|
6133
6434
|
...typeof value.label === "string" ? { label: value.label } : {},
|
|
6134
6435
|
...at === void 0 ? {} : { at },
|
|
6436
|
+
...lifecycle === void 0 ? {} : { lifecycle },
|
|
6135
6437
|
...overlayMessage === void 0 ? {} : { overlayMessage },
|
|
6136
6438
|
...pitch === void 0 ? {} : { pitch },
|
|
6137
6439
|
...pointerPosition === void 0 ? {} : { pointerPosition },
|
|
@@ -6148,6 +6450,22 @@ function validateStep(value, scenarioPath, index) {
|
|
|
6148
6450
|
...window === void 0 ? {} : { window }
|
|
6149
6451
|
};
|
|
6150
6452
|
}
|
|
6453
|
+
function validateLifecycleStep(value, scenarioPath, index) {
|
|
6454
|
+
if (!isRecord3(value)) return void 0;
|
|
6455
|
+
const rotation = value.rotation;
|
|
6456
|
+
const rotationValue = typeof rotation === "number" && Number.isInteger(rotation) && rotation >= 0 && rotation <= 3 ? rotation : void 0;
|
|
6457
|
+
if (value.operation === "rotate") {
|
|
6458
|
+
if (rotationValue === void 0) {
|
|
6459
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} lifecycle.operation 'rotate' must name a rotation from 0 through 3.`);
|
|
6460
|
+
}
|
|
6461
|
+
return { operation: "rotate", rotation: rotationValue };
|
|
6462
|
+
}
|
|
6463
|
+
if (value.operation !== "background" && value.operation !== "foreground") return void 0;
|
|
6464
|
+
if (rotation !== void 0) {
|
|
6465
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} lifecycle.operation '${value.operation}' cannot define rotation; only 'rotate' takes one.`);
|
|
6466
|
+
}
|
|
6467
|
+
return { operation: value.operation };
|
|
6468
|
+
}
|
|
6151
6469
|
function validateResourceWait(value, scenarioPath, index) {
|
|
6152
6470
|
const objectPath = `steps[${index}].waitForResource`;
|
|
6153
6471
|
if (!isRecord3(value)) {
|
|
@@ -6285,14 +6603,16 @@ function validateStepLabels(steps, assertions, scenarioPath) {
|
|
|
6285
6603
|
}
|
|
6286
6604
|
}
|
|
6287
6605
|
function playtestStepHoldTicks(step, fallback = 1) {
|
|
6288
|
-
|
|
6606
|
+
const pointerHold = (step.pointers !== void 0 || step.pointerPosition !== void 0) && step.holdTicks !== void 0;
|
|
6607
|
+
if (step.press === void 0 && !pointerHold || step.holdFrames !== void 0 || step.waitFrames !== void 0)
|
|
6608
|
+
return 0;
|
|
6289
6609
|
return Math.max(1, step.holdTicks ?? fallback);
|
|
6290
6610
|
}
|
|
6291
6611
|
function playtestStepWaitTicks(step) {
|
|
6292
6612
|
return step.waitFrames === void 0 ? Math.max(0, step.waitTicks ?? 0) : 0;
|
|
6293
6613
|
}
|
|
6294
6614
|
function validateAssertions(value, scenarioPath) {
|
|
6295
|
-
rejectUnknownKeys(value, PLAYTEST_ASSERTION_REGISTRY.map((entry) => entry.kind), scenarioPath, "assert");
|
|
6615
|
+
rejectUnknownKeys(value, [...PLAYTEST_ASSERTION_REGISTRY.map((entry) => entry.kind), "geometry"], scenarioPath, "assert");
|
|
6296
6616
|
validateAssertionShapes(value, scenarioPath);
|
|
6297
6617
|
validateAssertionKeys(value, scenarioPath);
|
|
6298
6618
|
if (Array.isArray(value.signals) && value.signals.length === 0) {
|
|
@@ -6318,6 +6638,7 @@ function validateAssertions(value, scenarioPath) {
|
|
|
6318
6638
|
const renderChain = value.renderChain === void 0 ? void 0 : validateRenderChainAssertion(value.renderChain, scenarioPath, "assert.renderChain");
|
|
6319
6639
|
const startup = value.startup === void 0 ? void 0 : validateStartupAssertion(value.startup, scenarioPath, "assert.startup");
|
|
6320
6640
|
const scene = value.scene === void 0 ? void 0 : validateSceneAssertion(value.scene, scenarioPath, "assert.scene");
|
|
6641
|
+
const geometry = value.geometry === void 0 ? void 0 : validateGeometryCaptureRequest(value.geometry, scenarioPath, "assert.geometry");
|
|
6321
6642
|
const world = isRecord3(value.world) ? value.world : void 0;
|
|
6322
6643
|
const optOuts = [
|
|
6323
6644
|
["noConsoleErrors", "consoleErrorsOptOutReason"],
|
|
@@ -6335,6 +6656,7 @@ function validateAssertions(value, scenarioPath) {
|
|
|
6335
6656
|
return {
|
|
6336
6657
|
...Array.isArray(value.aerodynamics) ? { aerodynamics: value.aerodynamics.map((entry, index) => validateAerodynamicsAssertion(entry, scenarioPath, `assert.aerodynamics[${index}]`)) } : {},
|
|
6337
6658
|
...Array.isArray(value.animation) ? { animation: value.animation.map((entry, index) => validateAnimationAssertion(entry, scenarioPath, `assert.animation[${index}]`)) } : {},
|
|
6659
|
+
...Array.isArray(value.audio) ? { audio: value.audio.map((entry, index) => validateAudioAssertion(entry, scenarioPath, `assert.audio[${index}]`)) } : {},
|
|
6338
6660
|
...camera === void 0 ? {} : {
|
|
6339
6661
|
camera: {
|
|
6340
6662
|
...typeof camera.entity === "string" ? { entity: camera.entity } : {},
|
|
@@ -6367,6 +6689,7 @@ function validateAssertions(value, scenarioPath) {
|
|
|
6367
6689
|
...renderChain === void 0 ? {} : { renderChain },
|
|
6368
6690
|
...startup === void 0 ? {} : { startup },
|
|
6369
6691
|
...scene === void 0 ? {} : { scene },
|
|
6692
|
+
...geometry === void 0 ? {} : { geometry },
|
|
6370
6693
|
...hasKey(value, "causedBy") ? {
|
|
6371
6694
|
causedBy: requireArray(value, "causedBy", scenarioPath, "assert.causedBy").map((entry, index) => validateCausedByAssertion(entry, scenarioPath, `assert.causedBy[${index}]`))
|
|
6372
6695
|
} : {},
|
|
@@ -6426,6 +6749,34 @@ function validateAssertions(value, scenarioPath) {
|
|
|
6426
6749
|
...world === void 0 ? {} : { world: validateWorldAssertion(world, scenarioPath) }
|
|
6427
6750
|
};
|
|
6428
6751
|
}
|
|
6752
|
+
function validateAudioAssertion(value, scenarioPath, objectPath) {
|
|
6753
|
+
const record4 = requireRecord(value, scenarioPath, objectPath);
|
|
6754
|
+
rejectUnknownKeys(record4, ["cue", "maxPlays", "minGapMs", "minPlays"], scenarioPath, objectPath);
|
|
6755
|
+
if (typeof record4.cue !== "string" || record4.cue.trim() === "")
|
|
6756
|
+
throw invalidScenario(scenarioPath, `Assertion '${objectPath}.cue' must be a non-empty string.`);
|
|
6757
|
+
const bound = (name) => {
|
|
6758
|
+
const raw = record4[name];
|
|
6759
|
+
if (raw === void 0) return void 0;
|
|
6760
|
+
if (typeof raw !== "number" || !Number.isInteger(raw) || raw < 0)
|
|
6761
|
+
throw invalidScenario(scenarioPath, `Assertion '${objectPath}.${name}' must be a non-negative integer.`);
|
|
6762
|
+
return raw;
|
|
6763
|
+
};
|
|
6764
|
+
const minPlays = bound("minPlays");
|
|
6765
|
+
const maxPlays = bound("maxPlays");
|
|
6766
|
+
const minGapMs = bound("minGapMs");
|
|
6767
|
+
if (minPlays !== void 0 && maxPlays !== void 0 && maxPlays < minPlays) {
|
|
6768
|
+
throw invalidScenario(
|
|
6769
|
+
scenarioPath,
|
|
6770
|
+
`Assertion '${objectPath}' cannot require at least ${minPlays} play(s) and at most ${maxPlays}.`
|
|
6771
|
+
);
|
|
6772
|
+
}
|
|
6773
|
+
return {
|
|
6774
|
+
cue: record4.cue,
|
|
6775
|
+
...maxPlays === void 0 ? {} : { maxPlays },
|
|
6776
|
+
...minGapMs === void 0 ? {} : { minGapMs },
|
|
6777
|
+
...minPlays === void 0 ? {} : { minPlays }
|
|
6778
|
+
};
|
|
6779
|
+
}
|
|
6429
6780
|
function validateWorldAssertion(value, scenarioPath) {
|
|
6430
6781
|
rejectUnknownKeys(value, ["runtime", "seed"], scenarioPath, "assert.world");
|
|
6431
6782
|
if (!hasKey(value, "seed") || value.seed !== null && (typeof value.seed !== "number" || !Number.isFinite(value.seed))) {
|
|
@@ -6592,6 +6943,24 @@ function validateOccludedAssertion(value, scenarioPath, objectPath) {
|
|
|
6592
6943
|
...present("target", optionalString(record4, "target", scenarioPath, objectPath))
|
|
6593
6944
|
};
|
|
6594
6945
|
}
|
|
6946
|
+
function validateGeometryCaptureRequest(value, scenarioPath, objectPath) {
|
|
6947
|
+
const record4 = requireRecord(value, scenarioPath, objectPath);
|
|
6948
|
+
rejectUnknownKeys(record4, ["limit", "sort", "timeoutMs"], scenarioPath, objectPath);
|
|
6949
|
+
if (record4.limit !== void 0 && (typeof record4.limit !== "number" || !Number.isInteger(record4.limit) || record4.limit < 1 || record4.limit > 500)) {
|
|
6950
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.limit' must be an integer from 1 to 500, received ${describeValue(record4.limit)}.`);
|
|
6951
|
+
}
|
|
6952
|
+
if (record4.sort !== void 0 && record4.sort !== "triangles" && record4.sort !== "draws" && record4.sort !== "projected") {
|
|
6953
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.sort' must be one of triangles, draws, projected, received ${describeValue(record4.sort)}.`);
|
|
6954
|
+
}
|
|
6955
|
+
if (record4.timeoutMs !== void 0 && (typeof record4.timeoutMs !== "number" || !Number.isFinite(record4.timeoutMs) || record4.timeoutMs <= 0)) {
|
|
6956
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.timeoutMs' must be a positive finite number, received ${describeValue(record4.timeoutMs)}.`);
|
|
6957
|
+
}
|
|
6958
|
+
return {
|
|
6959
|
+
...record4.limit === void 0 ? {} : { limit: record4.limit },
|
|
6960
|
+
...record4.sort === void 0 ? {} : { sort: record4.sort },
|
|
6961
|
+
...record4.timeoutMs === void 0 ? {} : { timeoutMs: record4.timeoutMs }
|
|
6962
|
+
};
|
|
6963
|
+
}
|
|
6595
6964
|
|
|
6596
6965
|
// src/scenario.ts
|
|
6597
6966
|
async function loadPlaytestScenario(projectPath, scenarioPath) {
|
|
@@ -6714,4 +7083,4 @@ function reachabilityEnvelope(value) {
|
|
|
6714
7083
|
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;
|
|
6715
7084
|
}
|
|
6716
7085
|
|
|
6717
|
-
export { DEVICE_METRICS_CADENCE_MS, DEVICE_METRICS_MAX_SAMPLES, DeviceMetricsError, DeviceMetricsRecorder, HOT_START_TEMPERATURE_C, PLAYTEST_ADVANCE_TICK_BUDGET_MS, PLAYTEST_ASSERTION_REGISTRY, PLAYTEST_BRIDGE_GLOBAL, PLAYTEST_CAPABILITY_REGISTRY, PLAYTEST_FROZEN_MARKER, PLAYTEST_PROTOCOL_LIMITS, PLAYTEST_PROTOCOL_VERSION, PLAYTEST_STARTUP_COMPILE_BUDGET_MS, PLAYTEST_STARTUP_READY_TIMEOUT_MS, PlaytestScenarioError, assertJsonSafe, evaluateRichPlaytestAssertions, invalidScenario, jsonByteLength, loadPlaytestScenario, missingPlaytestCapabilities, parseDeviceBattery, parseDeviceCurrent, parseDevicePowerRails, parseDeviceThermal, playtestDiagnostic, playtestStepHoldTicks, playtestStepWaitTicks, rejectUnknownKeys, requiredPlaytestCapabilities, resolveDiagnosticsPolicy, summarizeDeviceMetrics, unknownPlaytestCapabilities };
|
|
7086
|
+
export { DEVICE_METRICS_CADENCE_MS, DEVICE_METRICS_MAX_SAMPLES, DeviceMetricsError, DeviceMetricsRecorder, HOT_START_TEMPERATURE_C, PLAYTEST_ADVANCE_TICK_BUDGET_MS, PLAYTEST_ASSERTION_REGISTRY, PLAYTEST_BRIDGE_GLOBAL, PLAYTEST_CAPABILITY_REGISTRY, PLAYTEST_FRAME_PASS_KINDS, PLAYTEST_FROZEN_MARKER, PLAYTEST_PROTOCOL_LIMITS, PLAYTEST_PROTOCOL_VERSION, PLAYTEST_STARTUP_COMPILE_BUDGET_MS, PLAYTEST_STARTUP_READY_TIMEOUT_MS, PlaytestScenarioError, assertJsonSafe, evaluateRichPlaytestAssertions, invalidScenario, jsonByteLength, loadPlaytestScenario, missingPlaytestCapabilities, parseDeviceBattery, parseDeviceCurrent, parseDevicePowerRails, parseDeviceThermal, playtestDiagnostic, playtestStepHoldTicks, playtestStepWaitTicks, rejectUnknownKeys, requiredPlaytestCapabilities, resolveDiagnosticsPolicy, summarizeDeviceMetrics, unknownPlaytestCapabilities };
|