@threenative/playtest 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +556 -127
- package/dist/runner/cli.js +2033 -216
- package/dist/runner/index.js +2036 -230
- package/dist/three/index.js +523 -8
- package/package.json +1 -1
- package/dist/diagnostics-Ckm_5lrw.d.ts +0 -549
- package/dist/index.d.ts +0 -25
- package/dist/protocol-CeC1lz_G.d.ts +0 -130
- package/dist/runner/cli.d.ts +0 -20
- package/dist/runner/index.d.ts +0 -390
- package/dist/three/index.d.ts +0 -65
package/dist/index.js
CHANGED
|
@@ -18,10 +18,11 @@ var PLAYTEST_CAPABILITY_REGISTRY = [
|
|
|
18
18
|
capability("runtime.audio", "Samples application-owned audio runtime state."),
|
|
19
19
|
capability("runtime.components", "Samples registered JSON-safe component state."),
|
|
20
20
|
capability("runtime.contacts", "Samples bounded collision and trigger contacts."),
|
|
21
|
-
capability("runtime.diagnostics", "
|
|
21
|
+
capability("runtime.diagnostics", "Captures application runtime errors."),
|
|
22
22
|
capability("runtime.events", "Drains bounded application event observations."),
|
|
23
23
|
capability("runtime.fixedStep", "Advances an application-owned deterministic tick."),
|
|
24
24
|
capability("runtime.physics", "Samples bounded application-owned physics observations."),
|
|
25
|
+
capability("runtime.performance", "Samples bounded per-render frame cost and renderer counts."),
|
|
25
26
|
capability("runtime.resources", "Reads and writes registered JSON-safe application state."),
|
|
26
27
|
capability("runtime.state", "Samples application-owned state-machine state."),
|
|
27
28
|
capability("runtime.tags", "Samples bounded application-owned entity tags."),
|
|
@@ -42,6 +43,30 @@ function capability(name, description) {
|
|
|
42
43
|
|
|
43
44
|
// src/assertions.ts
|
|
44
45
|
var PLAYTEST_ASSERTION_REGISTRY = [
|
|
46
|
+
{
|
|
47
|
+
description: "Samples the framebuffer on every render frame inside a labeled loading window and requires every coarse-grid RGB sample to match the declared backdrop.",
|
|
48
|
+
example: {
|
|
49
|
+
framebufferCoverage: {
|
|
50
|
+
backdrop: [5, 7, 11],
|
|
51
|
+
grid: { columns: 32, rows: 18 },
|
|
52
|
+
tolerance: 8,
|
|
53
|
+
window: { endStep: "loading-end", startStep: "loading-start" }
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
fields: [
|
|
57
|
+
{ description: "Backdrop RGB byte channels every sampled pixel must match.", name: "backdrop", required: true, type: "[integer 0..255, integer 0..255, integer 0..255]" },
|
|
58
|
+
{ description: "Coarse sample grid. Defaults to 32x18, which catches the loading leak while limiting synchronous readback work.", name: "grid", type: "{ columns: positive integer <= 256, rows: positive integer <= 256 }" },
|
|
59
|
+
{ description: "Maximum absolute difference allowed for each RGB channel.", name: "tolerance", required: true, type: "integer 0..255" },
|
|
60
|
+
{ description: "Inclusive labeled-step boundaries for the loading-covered interval.", name: "window", required: true, type: "{ startStep: string, endStep: string }" }
|
|
61
|
+
],
|
|
62
|
+
cardinality: "object",
|
|
63
|
+
kind: "framebufferCoverage",
|
|
64
|
+
observationPath: "framebufferCoverage",
|
|
65
|
+
requiredCapabilities: ["browser.screenshot"],
|
|
66
|
+
resultIdPrefix: "framebufferCoverage",
|
|
67
|
+
supportedOn: ["web", "desktop", "bevy"],
|
|
68
|
+
triviality: "not-applicable"
|
|
69
|
+
},
|
|
45
70
|
{
|
|
46
71
|
description: "Checks every consecutive platform against a measured static movement-envelope fit; it does not simulate traversal, walls, ceilings, run-up, or air control.",
|
|
47
72
|
example: { reachability: { artifact: "artifacts/character-envelope/player.json", entities: ["platform.a", "platform.b"] } },
|
|
@@ -94,7 +119,7 @@ var PLAYTEST_ASSERTION_REGISTRY = [
|
|
|
94
119
|
description: "Proves the subject moved, reached a minimum velocity, or changed rotation during held input.",
|
|
95
120
|
example: { movement: { entity: "player", minDistance: 0.5, minVelocity: 0.01, rotationChanged: true } },
|
|
96
121
|
fields: [
|
|
97
|
-
{ description: "
|
|
122
|
+
{ description: "Optional entity id to measure; when omitted, choose an observed mover.", name: "entity", type: "string" },
|
|
98
123
|
{ description: "Require distance to a fixed world position to decrease by at least min.", name: "closesDistanceToPosition", type: "{ position: [number, number, number], min: number }" },
|
|
99
124
|
{ description: "Maximum yaw error from resolved movement direction.", name: "facesMovementWithinDegrees", type: "number" },
|
|
100
125
|
{ description: "Expected movement axis: x, y, or z.", name: "axis", type: "string" },
|
|
@@ -214,10 +239,10 @@ var PLAYTEST_ASSERTION_REGISTRY = [
|
|
|
214
239
|
triviality: "not-applicable"
|
|
215
240
|
},
|
|
216
241
|
{
|
|
217
|
-
description: "Proves an entity's final runtime-owned state-machine state.",
|
|
218
|
-
example: { states: [{
|
|
242
|
+
description: "Proves an observed entity's final runtime-owned state-machine state.",
|
|
243
|
+
example: { states: [{ equals: "completed" }] },
|
|
219
244
|
fields: [
|
|
220
|
-
{ description: "
|
|
245
|
+
{ description: "Optional entity id; when omitted, choose an observed state candidate.", name: "entity", type: "string" },
|
|
221
246
|
{ description: "Expected current state name.", name: "equals", required: true, type: "string" }
|
|
222
247
|
],
|
|
223
248
|
cardinality: "array",
|
|
@@ -274,6 +299,8 @@ var PLAYTEST_ASSERTION_REGISTRY = [
|
|
|
274
299
|
{ description: "Fail on captured console errors.", name: "noConsoleErrors", type: "boolean" },
|
|
275
300
|
{ description: "Fail on captured network errors.", name: "noNetworkErrors", type: "boolean" },
|
|
276
301
|
{ description: "Fail on runtime diagnostics.", name: "noRuntimeDiagnostics", type: "boolean" },
|
|
302
|
+
{ description: "Required bounded justification when noConsoleErrors is false.", name: "consoleErrorsOptOutReason", type: "non-empty string" },
|
|
303
|
+
{ description: "Required bounded justification when noNetworkErrors is false.", name: "networkErrorsOptOutReason", type: "non-empty string" },
|
|
277
304
|
{ description: "Required bounded justification when noRuntimeDiagnostics is false.", name: "runtimeDiagnosticsOptOutReason", type: "non-empty string" },
|
|
278
305
|
{ description: "Require runtime readiness.", name: "runtimeReady", type: "boolean" }
|
|
279
306
|
],
|
|
@@ -285,6 +312,22 @@ var PLAYTEST_ASSERTION_REGISTRY = [
|
|
|
285
312
|
supportedOn: ["web"],
|
|
286
313
|
triviality: "not-applicable"
|
|
287
314
|
},
|
|
315
|
+
{
|
|
316
|
+
description: "Proves a live render sample exists and optionally bounds frame time, draw calls, and triangles.",
|
|
317
|
+
example: { performance: { maxDrawCalls: 100, maxFrameMsP95: 33, maxTriangles: 1e4 } },
|
|
318
|
+
fields: [
|
|
319
|
+
{ description: "Maximum nearest-rank 95th-percentile frame time in milliseconds.", name: "maxFrameMsP95", type: "number" },
|
|
320
|
+
{ description: "Maximum observed renderer draw-call count.", name: "maxDrawCalls", type: "number" },
|
|
321
|
+
{ description: "Maximum observed renderer triangle count.", name: "maxTriangles", type: "number" }
|
|
322
|
+
],
|
|
323
|
+
cardinality: "object",
|
|
324
|
+
kind: "performance",
|
|
325
|
+
observationPath: "performanceSeries",
|
|
326
|
+
requiredCapabilities: ["runtime.performance"],
|
|
327
|
+
resultIdPrefix: "performance.",
|
|
328
|
+
supportedOn: ["web", "desktop", "bevy"],
|
|
329
|
+
triviality: "not-applicable"
|
|
330
|
+
},
|
|
288
331
|
{
|
|
289
332
|
description: "Proves projected entity visibility in the viewport.",
|
|
290
333
|
example: { visibility: [{ entity: "player", minProjectedPixels: 1200, maxOffscreenRatio: 0.05 }] },
|
|
@@ -322,7 +365,7 @@ var PLAYTEST_ASSERTION_REGISTRY = [
|
|
|
322
365
|
example: { contacts: [{ entity: "player", with: "pickup", kind: "trigger", minCount: 1 }] },
|
|
323
366
|
fields: [
|
|
324
367
|
{ description: "Retained step label to inspect instead of the full observation history.", name: "atStep", type: "string" },
|
|
325
|
-
{ description: "
|
|
368
|
+
{ description: "Optional entity id; when omitted, choose an observed contact candidate.", name: "entity", type: "string" },
|
|
326
369
|
{ description: "Other entity or tag token expected in the contact evidence.", name: "with", type: "string" },
|
|
327
370
|
{ description: "Contact kind token, such as contact or trigger.", name: "kind", type: "string" },
|
|
328
371
|
{ description: "Minimum number of matching observations.", name: "minCount", type: "number" },
|
|
@@ -338,10 +381,10 @@ var PLAYTEST_ASSERTION_REGISTRY = [
|
|
|
338
381
|
triviality: "not-applicable"
|
|
339
382
|
},
|
|
340
383
|
{
|
|
341
|
-
description: "Proves matching physics bodies
|
|
342
|
-
example: { settled: [{ atStep: "fall-and-settle",
|
|
384
|
+
description: "Proves an observed cohort of matching physics bodies is asleep in a retained physics-debug sample.",
|
|
385
|
+
example: { settled: [{ atStep: "fall-and-settle", minBodies: 15 }] },
|
|
343
386
|
fields: [
|
|
344
|
-
{ description: "
|
|
387
|
+
{ description: "Optional exact entity id or stable entity-id prefix; when omitted, choose an observed cohort.", name: "entity", type: "string" },
|
|
345
388
|
{ description: "Optional labeled step whose physics-debug sample must be used.", name: "atStep", type: "string" },
|
|
346
389
|
{ description: "Minimum number of matching bodies required.", name: "minBodies", type: "positive integer" },
|
|
347
390
|
{ description: "Optional earlier labeled step whose matching body positions are compared.", name: "compareToStep", type: "string" },
|
|
@@ -403,7 +446,7 @@ var PLAYTEST_SETUP_REGISTRY = [
|
|
|
403
446
|
];
|
|
404
447
|
function requiredPlaytestCapabilities(scenario) {
|
|
405
448
|
const required = /* @__PURE__ */ new Set();
|
|
406
|
-
if (scenario.steps.some((step) => step.kind !== "wait" && (step.press !== void 0 || step.pointerPosition !== void 0))) {
|
|
449
|
+
if (scenario.steps.some((step) => step.kind !== "wait" && (step.press !== void 0 || step.pointerPosition !== void 0 || step.pointers !== void 0))) {
|
|
407
450
|
required.add("browser.input");
|
|
408
451
|
}
|
|
409
452
|
if (scenario.artifacts?.screenshots !== false) {
|
|
@@ -428,10 +471,75 @@ function requiredPlaytestCapabilities(scenario) {
|
|
|
428
471
|
}
|
|
429
472
|
return [...required].sort();
|
|
430
473
|
}
|
|
474
|
+
function resolveDiagnosticsPolicy(policy) {
|
|
475
|
+
return {
|
|
476
|
+
...policy?.consoleErrorsOptOutReason === void 0 ? {} : { consoleErrorsOptOutReason: policy.consoleErrorsOptOutReason },
|
|
477
|
+
...policy?.networkErrorsOptOutReason === void 0 ? {} : { networkErrorsOptOutReason: policy.networkErrorsOptOutReason },
|
|
478
|
+
noConsoleErrors: policy?.noConsoleErrors ?? true,
|
|
479
|
+
noNetworkErrors: policy?.noNetworkErrors ?? true,
|
|
480
|
+
noRuntimeDiagnostics: policy?.noRuntimeDiagnostics ?? true,
|
|
481
|
+
...policy?.runtimeReady === void 0 ? {} : { runtimeReady: policy.runtimeReady },
|
|
482
|
+
...policy?.runtimeDiagnosticsOptOutReason === void 0 ? {} : { runtimeDiagnosticsOptOutReason: policy.runtimeDiagnosticsOptOutReason }
|
|
483
|
+
};
|
|
484
|
+
}
|
|
431
485
|
function evaluateRichPlaytestAssertions(input) {
|
|
432
486
|
const assertions = [];
|
|
433
487
|
const diagnostics = [];
|
|
434
488
|
const scenarioAssertions = input.scenario.assert ?? {};
|
|
489
|
+
if (scenarioAssertions.framebufferCoverage !== void 0) {
|
|
490
|
+
const observation = input.report.observations?.framebufferCoverage;
|
|
491
|
+
const started = observation?.windowStarted === true;
|
|
492
|
+
const completed = observation?.windowCompleted === true;
|
|
493
|
+
const framesObserved = (observation?.frameCount ?? 0) > 0;
|
|
494
|
+
const readable = observation?.unreadableReason === void 0;
|
|
495
|
+
const violation = observation?.firstViolation;
|
|
496
|
+
const evidenceComplete = violation === void 0 || violation.grid.samples.length === violation.grid.columns * violation.grid.rows && violation.screenshotPath.length > 0;
|
|
497
|
+
const pass = started && completed && framesObserved && readable && violation === void 0 && evidenceComplete;
|
|
498
|
+
assertions.push({
|
|
499
|
+
details: {
|
|
500
|
+
boundarySource: observation?.boundarySource ?? null,
|
|
501
|
+
evidenceComplete,
|
|
502
|
+
firstViolation: violation ?? null,
|
|
503
|
+
frameCount: observation?.frameCount ?? 0,
|
|
504
|
+
unreadableReason: observation?.unreadableReason ?? null,
|
|
505
|
+
windowCompleted: completed,
|
|
506
|
+
windowStarted: started
|
|
507
|
+
},
|
|
508
|
+
id: "framebufferCoverage",
|
|
509
|
+
pass
|
|
510
|
+
});
|
|
511
|
+
if (!readable) {
|
|
512
|
+
diagnostics.push({
|
|
513
|
+
code: "TN_PLAYTEST_FRAMEBUFFER_PIXELS_UNREADABLE",
|
|
514
|
+
message: `Framebuffer pixels could not be read: ${observation?.unreadableReason}.`,
|
|
515
|
+
severity: "error",
|
|
516
|
+
suggestion: "On headless Linux, prefix the command with xvfb-run -a -s '-screen 0 1600x900x24'."
|
|
517
|
+
});
|
|
518
|
+
} else if (!started || !completed) {
|
|
519
|
+
diagnostics.push({
|
|
520
|
+
code: "TN_PLAYTEST_FRAMEBUFFER_WINDOW_NOT_REACHED",
|
|
521
|
+
message: !started ? "The run never reached the declared framebuffer coverage window." : "The run entered but never completed the declared framebuffer coverage window.",
|
|
522
|
+
severity: "error",
|
|
523
|
+
suggestion: "Check the assertion's startStep/endStep labels and keep the run alive through the complete loading interval."
|
|
524
|
+
});
|
|
525
|
+
} else if (!framesObserved) {
|
|
526
|
+
diagnostics.push({
|
|
527
|
+
code: "TN_PLAYTEST_FRAMEBUFFER_FRAMES_MISSING",
|
|
528
|
+
message: "The framebuffer coverage window completed without observing any render frames.",
|
|
529
|
+
severity: "error",
|
|
530
|
+
suggestion: "Keep at least one requestAnimationFrame-driven frame inside the labeled loading window."
|
|
531
|
+
});
|
|
532
|
+
} else if (violation !== void 0) {
|
|
533
|
+
diagnostics.push({
|
|
534
|
+
artifactPath: violation.screenshotPath,
|
|
535
|
+
code: evidenceComplete ? "TN_PLAYTEST_FRAMEBUFFER_COVERAGE_FAILED" : "TN_PLAYTEST_FRAMEBUFFER_EVIDENCE_MISSING",
|
|
536
|
+
message: evidenceComplete ? `Framebuffer coverage first diverged from the declared backdrop at frame ${violation.frameIndex}.` : `Framebuffer coverage diverged at frame ${violation.frameIndex}, but its grid or screenshot evidence is incomplete.`,
|
|
537
|
+
observedRuntimePath: "observations.json/framebufferCoverage/firstViolation/grid",
|
|
538
|
+
severity: "error",
|
|
539
|
+
suggestion: "Inspect the violating-frame screenshot and RGB sample grid; fix the render pass that drew during the loading-covered window."
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
}
|
|
435
543
|
if (scenarioAssertions.reachability !== void 0) {
|
|
436
544
|
const { entities, envelope } = scenarioAssertions.reachability;
|
|
437
545
|
for (let index = 0; index < entities.length - 1; index += 1) {
|
|
@@ -485,8 +593,17 @@ function evaluateRichPlaytestAssertions(input) {
|
|
|
485
593
|
suggestion: "Inspect observations.json/overlayNodes and verify the overlay subscription, selector, attribute, and computed style."
|
|
486
594
|
});
|
|
487
595
|
}
|
|
488
|
-
const
|
|
489
|
-
|
|
596
|
+
const captureFailure = input.report.observations?.visual?.captureFailure;
|
|
597
|
+
const hasVisualSamples = input.report.observations?.visual !== void 0 && captureFailure === void 0;
|
|
598
|
+
if ((scenarioAssertions.visual?.length ?? 0) > 0 && captureFailure !== void 0) {
|
|
599
|
+
for (const [index] of scenarioAssertions.visual.entries()) {
|
|
600
|
+
assertions.push({
|
|
601
|
+
details: { captureFailure, reason: "not-evaluated" },
|
|
602
|
+
id: `visual.${index}`,
|
|
603
|
+
pass: true
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
} else if ((scenarioAssertions.visual?.length ?? 0) > 0 && !hasVisualSamples) {
|
|
490
607
|
for (const [index] of scenarioAssertions.visual.entries()) {
|
|
491
608
|
assertions.push({ id: `visual.${index}`, pass: false, details: { reason: "target-unsupported", target: input.scenario.target } });
|
|
492
609
|
diagnostics.push(assertionNotEvaluatedDiagnostic(`visual.${index}`, `target '${input.scenario.target}' does not expose visual assertion samples`));
|
|
@@ -535,6 +652,15 @@ function evaluateRichPlaytestAssertions(input) {
|
|
|
535
652
|
if (!pass) diagnostics.push({ code: "TN_PLAYTEST_ENTITY_VISIBILITY_DROPPED", message: `Entity '${visual.entityVisible.entity}' dropped below ${visual.entityVisible.minProjectedPixels} projected pixels.`, severity: "error", suggestion: "Check per-frame visibility, camera clipping, scale, and renderer state." });
|
|
536
653
|
}
|
|
537
654
|
}
|
|
655
|
+
if (scenarioAssertions.performance !== void 0) {
|
|
656
|
+
const result = evaluatePerformanceAssertion(
|
|
657
|
+
scenarioAssertions.performance,
|
|
658
|
+
input.report.observations?.performanceSeries,
|
|
659
|
+
input.scenario.sourcePath
|
|
660
|
+
);
|
|
661
|
+
assertions.push(...result.assertions);
|
|
662
|
+
diagnostics.push(...result.diagnostics);
|
|
663
|
+
}
|
|
538
664
|
for (const assertion of scenarioAssertions.resources ?? []) {
|
|
539
665
|
if (assertion.anyOf !== void 0) {
|
|
540
666
|
const result = evaluateResourceAnyOfAssertion(assertion, input.report.observations?.resources[assertion.id], {
|
|
@@ -714,31 +840,27 @@ function evaluateRichPlaytestAssertions(input) {
|
|
|
714
840
|
diagnostics.push(result.diagnostic);
|
|
715
841
|
}
|
|
716
842
|
}
|
|
717
|
-
for (const assertion of scenarioAssertions.states ?? []) {
|
|
718
|
-
const result = evaluateStateAssertion(assertion, input.report.observations
|
|
843
|
+
for (const [stateIndex, assertion] of (scenarioAssertions.states ?? []).entries()) {
|
|
844
|
+
const result = evaluateStateAssertion(assertion, input.report.observations, input.scenario, stateIndex);
|
|
719
845
|
assertions.push(result.assertion);
|
|
720
846
|
if (result.diagnostic !== void 0) {
|
|
721
847
|
diagnostics.push(result.diagnostic);
|
|
722
848
|
}
|
|
723
849
|
}
|
|
724
850
|
{
|
|
725
|
-
const diagnosticsPolicy =
|
|
726
|
-
...scenarioAssertions.diagnostics,
|
|
727
|
-
noRuntimeDiagnostics: scenarioAssertions.diagnostics?.noRuntimeDiagnostics ?? true
|
|
728
|
-
};
|
|
851
|
+
const diagnosticsPolicy = resolveDiagnosticsPolicy(scenarioAssertions.diagnostics);
|
|
729
852
|
const policyDiagnostics = evaluateDiagnosticsPolicy(input.report, diagnosticsPolicy);
|
|
730
853
|
diagnostics.push(...policyDiagnostics);
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
}
|
|
854
|
+
assertions.push({
|
|
855
|
+
details: {
|
|
856
|
+
consoleErrors: consoleErrors(input.report.observations?.console ?? []).length,
|
|
857
|
+
networkErrors: input.report.observations?.network.length ?? 0,
|
|
858
|
+
policy: diagnosticsPolicy,
|
|
859
|
+
runtimeDiagnostics: runtimeDiagnostics(input.report.observations?.runtimeDiagnostics).length
|
|
860
|
+
},
|
|
861
|
+
id: "diagnostics",
|
|
862
|
+
pass: policyDiagnostics.length === 0
|
|
863
|
+
});
|
|
742
864
|
}
|
|
743
865
|
if (scenarioAssertions.movement?.minVelocity !== void 0) {
|
|
744
866
|
const velocity = input.report.frames <= 0 ? 0 : input.report.distance / input.report.frames;
|
|
@@ -756,7 +878,7 @@ function evaluateRichPlaytestAssertions(input) {
|
|
|
756
878
|
if (scenarioAssertions.movement?.minDistance !== void 0) {
|
|
757
879
|
const pass = input.report.distance >= scenarioAssertions.movement.minDistance;
|
|
758
880
|
assertions.push({
|
|
759
|
-
details: { distance: input.report.distance, minimum: scenarioAssertions.movement.minDistance },
|
|
881
|
+
details: { distance: input.report.distance, entity: input.report.entity, minimum: scenarioAssertions.movement.minDistance },
|
|
760
882
|
id: "movement.distance",
|
|
761
883
|
pass
|
|
762
884
|
});
|
|
@@ -984,36 +1106,48 @@ function evaluateRichPlaytestAssertions(input) {
|
|
|
984
1106
|
diagnostics.push(result.diagnostic);
|
|
985
1107
|
}
|
|
986
1108
|
}
|
|
987
|
-
for (const assertion of scenarioAssertions.contacts ?? []) {
|
|
988
|
-
const entity = assertion.entity ?? input.scenario.subject
|
|
1109
|
+
for (const [contactIndex, assertion] of (scenarioAssertions.contacts ?? []).entries()) {
|
|
1110
|
+
const entity = assertion.entity ?? input.scenario.subject;
|
|
1111
|
+
const anonymous = entity === void 0;
|
|
989
1112
|
if (assertion.requiredOn !== void 0 && !assertion.requiredOn.includes(input.scenario.target)) {
|
|
990
1113
|
assertions.push({
|
|
991
|
-
details: { entity, requiredOn: assertion.requiredOn, skipped: true, target: input.scenario.target },
|
|
992
|
-
id: `contact.${entity}`,
|
|
1114
|
+
details: { entity: entity || "anonymous", requiredOn: assertion.requiredOn, skipped: true, target: input.scenario.target },
|
|
1115
|
+
id: assertion.entity === void 0 ? `contact.${contactIndex}` : `contact.${entity}`,
|
|
993
1116
|
pass: true
|
|
994
1117
|
});
|
|
995
1118
|
continue;
|
|
996
1119
|
}
|
|
997
1120
|
const tokens = [entity, assertion.with, assertion.kind].filter((item) => item !== void 0);
|
|
998
1121
|
const selectedSample = assertion.atStep === void 0 ? void 0 : input.report.observations?.physicsDebugSeries?.find((sample) => sample.label === assertion.atStep);
|
|
999
|
-
const
|
|
1122
|
+
const runtimeStepAvailable = assertion.atStep === void 0 || runtimeGameplayAtStep(input.report.observations?.runtimeObservations, assertion.atStep) !== void 0;
|
|
1123
|
+
const stepAvailable = assertion.atStep === void 0 || selectedSample !== void 0 || runtimeStepAvailable;
|
|
1000
1124
|
const effectEvidence = assertion.atStep === void 0 ? mergeEffectLogs(input.report.effectLog, input.report.observations?.effectLogSeries) : [];
|
|
1001
1125
|
const effectCount = countMatchingEntries(effectEvidence, tokens);
|
|
1002
1126
|
const runtimeCount = assertion.atStep === void 0 ? countRuntimeContacts(input.report.observations?.runtimeObservations, entity, assertion.with, assertion.kind) : 0;
|
|
1003
|
-
const
|
|
1004
|
-
const
|
|
1127
|
+
const physicsEvidence = assertion.kind === void 0 || assertion.kind === "contact" ? physicsDebugContactEvidence(input.report.observations, entity, assertion.with, selectedSample?.snapshot) : { candidates: [], count: 0 };
|
|
1128
|
+
const runtimeEvidence = runtimeContactEvidence(
|
|
1129
|
+
input.report.observations?.runtimeObservations,
|
|
1130
|
+
entity,
|
|
1131
|
+
assertion.with,
|
|
1132
|
+
assertion.kind,
|
|
1133
|
+
assertion.atStep
|
|
1134
|
+
);
|
|
1135
|
+
const candidates = [.../* @__PURE__ */ new Set([...physicsEvidence.candidates, ...runtimeEvidence.candidates])];
|
|
1136
|
+
const count = effectCount + physicsEvidence.count + (assertion.atStep === void 0 ? runtimeCount : runtimeEvidence.count);
|
|
1005
1137
|
const minCount = assertion.minCount ?? (assertion.maxCount === void 0 ? 1 : 0);
|
|
1006
|
-
const
|
|
1007
|
-
|
|
1138
|
+
const candidatesAvailable = !anonymous || candidates.length > 0;
|
|
1139
|
+
const pass = stepAvailable && candidatesAvailable && count >= minCount && (assertion.maxCount === void 0 || count <= assertion.maxCount);
|
|
1140
|
+
const resultEntity = entity || "anonymous";
|
|
1141
|
+
assertions.push({ details: { atStep: assertion.atStep, candidates, count, entity: resultEntity, kind: assertion.kind, maxCount: assertion.maxCount, minCount, with: assertion.with }, id: assertion.entity === void 0 ? `contact.${contactIndex}` : `contact.${resultEntity}`, pass });
|
|
1008
1142
|
if (!pass) {
|
|
1009
1143
|
const partial = summarizeMatchingEntries(effectEvidence, [entity, assertion.with].filter((item) => item !== void 0));
|
|
1010
1144
|
const hasPhysicsDebugEvidence = input.report.observations?.physicsDebug !== void 0 || (input.report.observations?.physicsDebugSeries?.length ?? 0) > 0;
|
|
1011
1145
|
diagnostics.push({
|
|
1012
1146
|
artifactPath: partial !== void 0 || !hasPhysicsDebugEvidence ? "effect-log.json" : "observations.json",
|
|
1013
|
-
code: !stepAvailable ? "TN_PLAYTEST_CONTACT_STEP_NOT_OBSERVED" : assertion.maxCount !== void 0 && count > assertion.maxCount ? "TN_PLAYTEST_CONTACT_COUNT_EXCEEDED" : "TN_PLAYTEST_CONTACT_NOT_OBSERVED",
|
|
1014
|
-
message: !stepAvailable ? `Contact assertion step '${assertion.atStep}' was not retained.` : assertion.maxCount !== void 0 && count > assertion.maxCount ? `Contact/trigger for '${
|
|
1015
|
-
observedRuntimePath: `observations.json/physicsDebugSeries/artifact/primitives[category=contact,entity=${
|
|
1016
|
-
path: `${input.scenario.sourcePath ?? "playtest"}/assert/contacts/${
|
|
1147
|
+
code: !stepAvailable ? "TN_PLAYTEST_CONTACT_STEP_NOT_OBSERVED" : !candidatesAvailable ? "TN_PLAYTEST_CONTACT_CANDIDATES_UNAVAILABLE" : assertion.maxCount !== void 0 && count > assertion.maxCount ? "TN_PLAYTEST_CONTACT_COUNT_EXCEEDED" : "TN_PLAYTEST_CONTACT_NOT_OBSERVED",
|
|
1148
|
+
message: !stepAvailable ? `Contact assertion step '${assertion.atStep}' was not retained.` : !candidatesAvailable ? "No observed contact candidate was retained for the anonymous contact assertion." : assertion.maxCount !== void 0 && count > assertion.maxCount ? `Contact/trigger for '${resultEntity}' was observed ${count} time(s), above allowed ${assertion.maxCount}.` : `Expected contact/trigger for '${resultEntity}' was not observed ${minCount} time(s).`,
|
|
1149
|
+
observedRuntimePath: `observations.json/physicsDebugSeries/artifact/primitives[category=contact,entity=${resultEntity}] | effect-log.json/entries[kind=service|event,entity=${resultEntity}]`,
|
|
1150
|
+
path: `${input.scenario.sourcePath ?? "playtest"}/assert/contacts/${resultEntity}`,
|
|
1017
1151
|
severity: "error",
|
|
1018
1152
|
...input.scenario.sourcePath === void 0 ? {} : { sourcePath: input.scenario.sourcePath },
|
|
1019
1153
|
...partial?.systemId === void 0 ? {} : { systemId: partial.systemId, sourcePath: partial.sourcePath },
|
|
@@ -1021,34 +1155,39 @@ function evaluateRichPlaytestAssertions(input) {
|
|
|
1021
1155
|
});
|
|
1022
1156
|
}
|
|
1023
1157
|
}
|
|
1024
|
-
for (const assertion of scenarioAssertions.settled ?? []) {
|
|
1158
|
+
for (const [settledIndex, assertion] of (scenarioAssertions.settled ?? []).entries()) {
|
|
1025
1159
|
if (assertion.requiredOn !== void 0 && !assertion.requiredOn.includes(input.scenario.target)) {
|
|
1026
1160
|
assertions.push({
|
|
1027
|
-
details: { entity: assertion.entity, requiredOn: assertion.requiredOn, skipped: true, target: input.scenario.target },
|
|
1028
|
-
id: `settled.${assertion.entity}`,
|
|
1161
|
+
details: { entity: assertion.entity ?? "anonymous", requiredOn: assertion.requiredOn, skipped: true, target: input.scenario.target },
|
|
1162
|
+
id: `settled.${assertion.entity ?? "anonymous"}`,
|
|
1029
1163
|
pass: true
|
|
1030
1164
|
});
|
|
1031
1165
|
continue;
|
|
1032
1166
|
}
|
|
1033
1167
|
const snapshot = assertion.atStep === void 0 ? input.report.observations?.physicsDebugSeries?.at(-1)?.snapshot ?? input.report.observations?.physicsDebug : input.report.observations?.physicsDebugSeries?.find((sample) => sample.label === assertion.atStep)?.snapshot;
|
|
1034
|
-
const bodies = physicsDebugSleepStates(snapshot, assertion.entity);
|
|
1035
1168
|
const minimum = assertion.minBodies ?? 1;
|
|
1169
|
+
const candidate = settledCandidate(snapshot, assertion.entity);
|
|
1170
|
+
const bodies = candidate?.bodies ?? [];
|
|
1171
|
+
const omittedBodies = physicsDebugOmittedBodies(snapshot);
|
|
1036
1172
|
const sleeping = bodies.filter((body) => body.sleeping).length;
|
|
1037
1173
|
const comparisonSnapshot = assertion.compareToStep === void 0 ? void 0 : input.report.observations?.physicsDebugSeries?.find((sample) => sample.label === assertion.compareToStep)?.snapshot;
|
|
1038
|
-
const
|
|
1174
|
+
const selectedEntity = candidate?.selector ?? assertion.entity ?? "";
|
|
1175
|
+
const poseDistance = assertion.compareToStep === void 0 ? void 0 : physicsDebugMeanPoseDistance(snapshot, comparisonSnapshot, selectedEntity);
|
|
1039
1176
|
const posePass = assertion.minMeanPoseDistance === void 0 || poseDistance !== void 0 && poseDistance.sharedBodies >= minimum && poseDistance.mean >= assertion.minMeanPoseDistance;
|
|
1040
|
-
const
|
|
1177
|
+
const complete = omittedBodies === 0;
|
|
1178
|
+
const pass = complete && candidate !== void 0 && bodies.length >= minimum && sleeping === bodies.length && posePass;
|
|
1179
|
+
const resultEntity = candidate?.selector ?? assertion.entity ?? "anonymous";
|
|
1041
1180
|
assertions.push({
|
|
1042
|
-
details: { atStep: assertion.atStep, bodies: bodies.length, compareToStep: assertion.compareToStep, entity:
|
|
1043
|
-
id: `settled.${assertion.entity}`,
|
|
1181
|
+
details: { atStep: assertion.atStep, bodies: bodies.length, candidates: candidate?.candidates ?? [], compareToStep: assertion.compareToStep, entity: resultEntity, minimum, omittedBodies, poseDistance, sleeping },
|
|
1182
|
+
id: assertion.entity === void 0 ? `settled.${settledIndex}` : `settled.${assertion.entity}`,
|
|
1044
1183
|
pass
|
|
1045
1184
|
});
|
|
1046
1185
|
if (!pass) diagnostics.push({
|
|
1047
1186
|
artifactPath: "observations.json",
|
|
1048
|
-
code: !posePass ? "TN_PLAYTEST_RAGDOLL_POSE_NOT_DISTINCT" : "TN_PLAYTEST_PHYSICS_NOT_SETTLED",
|
|
1049
|
-
message: !posePass ? `Expected mean settled-pose distance for '${
|
|
1187
|
+
code: !complete ? "TN_PLAYTEST_PHYSICS_EVIDENCE_TRUNCATED" : !posePass ? "TN_PLAYTEST_RAGDOLL_POSE_NOT_DISTINCT" : "TN_PLAYTEST_PHYSICS_NOT_SETTLED",
|
|
1188
|
+
message: !complete ? `Physics evidence omitted ${omittedBodies} bod${omittedBodies === 1 ? "y" : "ies"}; settled cannot pass on a partial snapshot.` : !posePass ? `Expected mean settled-pose distance for '${resultEntity}' to reach ${assertion.minMeanPoseDistance}m from step '${assertion.compareToStep}'; observed ${poseDistance?.mean ?? "unavailable"}m across ${poseDistance?.sharedBodies ?? 0} bodies.` : `Expected at least ${minimum} physics bod${minimum === 1 ? "y" : "ies"} matching '${resultEntity}' to be asleep; observed ${sleeping} of ${bodies.length}.`,
|
|
1050
1189
|
observedRuntimePath: "observations.json/physicsDebugSeries/artifact/primitives[category=sleep]",
|
|
1051
|
-
path: `${input.scenario.sourcePath ?? "playtest"}/assert/settled/${
|
|
1190
|
+
path: `${input.scenario.sourcePath ?? "playtest"}/assert/settled/${resultEntity}`,
|
|
1052
1191
|
severity: "error",
|
|
1053
1192
|
...input.scenario.sourcePath === void 0 ? {} : { sourcePath: input.scenario.sourcePath },
|
|
1054
1193
|
suggestion: "Allow a longer settle window or fix damping, contacts, joints, and persistent forces that keep the bodies awake."
|
|
@@ -1108,7 +1247,7 @@ function evaluateRichPlaytestAssertions(input) {
|
|
|
1108
1247
|
assertions.push({ details: { reason: "registered-without-evaluator" }, id, pass: false });
|
|
1109
1248
|
diagnostics.push(assertionNotEvaluatedDiagnostic(id, "the registered assertion produced no evaluator result"));
|
|
1110
1249
|
}
|
|
1111
|
-
if (assertions.length === 0) {
|
|
1250
|
+
if (assertions.length === 0 || scenarioAssertions.diagnostics === void 0 && !assertions.some(({ id }) => id !== "diagnostics")) {
|
|
1112
1251
|
const id = "scenario.assertions";
|
|
1113
1252
|
assertions.push({ details: { reason: "no-evaluated-assertions" }, id, pass: false });
|
|
1114
1253
|
diagnostics.push({
|
|
@@ -1136,28 +1275,57 @@ function movementEnvelopeHorizontalLimit(envelope, rise) {
|
|
|
1136
1275
|
if (envelope.maxRise === 0) return rise === 0 ? envelope.forwardReach : void 0;
|
|
1137
1276
|
return envelope.forwardReach * (1 + Math.sqrt(dropFromApex / envelope.maxRise));
|
|
1138
1277
|
}
|
|
1139
|
-
function
|
|
1278
|
+
function physicsDebugContactEvidence(observations, entity, withEntity, selectedSnapshot) {
|
|
1140
1279
|
const snapshots = selectedSnapshot === void 0 ? [
|
|
1141
1280
|
observations?.physicsDebug,
|
|
1142
1281
|
...(observations?.physicsDebugSeries ?? []).map((sample) => sample.snapshot)
|
|
1143
1282
|
] : [selectedSnapshot];
|
|
1144
|
-
|
|
1283
|
+
const candidates = [];
|
|
1145
1284
|
for (const snapshot of snapshots) {
|
|
1146
1285
|
if (!isRecord(snapshot) || !isRecord(snapshot.artifact) || !Array.isArray(snapshot.artifact.primitives)) continue;
|
|
1147
|
-
|
|
1148
|
-
if (!isRecord(primitive) || primitive.category !== "contact" || typeof primitive.id !== "string")
|
|
1149
|
-
|
|
1150
|
-
|
|
1286
|
+
for (const primitive of snapshot.artifact.primitives) {
|
|
1287
|
+
if (!isRecord(primitive) || primitive.category !== "contact" || typeof primitive.id !== "string") continue;
|
|
1288
|
+
if (primitive.id.includes(entity ?? "") && (withEntity === void 0 || primitive.id.includes(withEntity))) {
|
|
1289
|
+
candidates.push(primitive.id);
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1151
1292
|
}
|
|
1152
|
-
return count;
|
|
1293
|
+
return { candidates: [...new Set(candidates)], count: candidates.length };
|
|
1294
|
+
}
|
|
1295
|
+
function settledCandidate(snapshot, entity) {
|
|
1296
|
+
const bodies = physicsDebugSleepStates(snapshot, entity);
|
|
1297
|
+
if (entity !== void 0) {
|
|
1298
|
+
return bodies.length === 0 ? void 0 : { bodies, candidates: bodies.map(({ entity: body }) => body), selector: entity };
|
|
1299
|
+
}
|
|
1300
|
+
const groups = /* @__PURE__ */ new Map();
|
|
1301
|
+
for (const body of bodies) {
|
|
1302
|
+
const selector2 = bodySelector(body.entity);
|
|
1303
|
+
const group = groups.get(selector2) ?? [];
|
|
1304
|
+
group.push(body);
|
|
1305
|
+
groups.set(selector2, group);
|
|
1306
|
+
}
|
|
1307
|
+
const selected = [...groups.entries()].sort(([leftSelector, leftBodies], [rightSelector, rightBodies]) => rightBodies.length - leftBodies.length || leftSelector.localeCompare(rightSelector))[0];
|
|
1308
|
+
if (selected === void 0) return void 0;
|
|
1309
|
+
const [selector, selectedBodies] = selected;
|
|
1310
|
+
return { bodies: selectedBodies, candidates: selectedBodies.map(({ entity: body }) => body), selector };
|
|
1311
|
+
}
|
|
1312
|
+
function bodySelector(entity) {
|
|
1313
|
+
return /\d$/.test(entity) ? entity.replace(/\d+$/, "") : entity;
|
|
1153
1314
|
}
|
|
1154
1315
|
function physicsDebugSleepStates(snapshot, entity) {
|
|
1155
1316
|
if (!isRecord(snapshot) || !isRecord(snapshot.artifact) || !Array.isArray(snapshot.artifact.primitives)) return [];
|
|
1156
1317
|
return snapshot.artifact.primitives.flatMap((primitive) => {
|
|
1157
|
-
if (!isRecord(primitive) || primitive.category !== "sleep" || typeof primitive.entity !== "string" || primitive.entity !== entity && !primitive.entity.startsWith(entity) || typeof primitive.value !== "number") return [];
|
|
1318
|
+
if (!isRecord(primitive) || primitive.category !== "sleep" || typeof primitive.entity !== "string" || entity !== void 0 && primitive.entity !== entity && !primitive.entity.startsWith(entity) || typeof primitive.value !== "number") return [];
|
|
1158
1319
|
return [{ entity: primitive.entity, sleeping: primitive.value >= 1 }];
|
|
1159
1320
|
});
|
|
1160
1321
|
}
|
|
1322
|
+
function physicsDebugOmittedBodies(snapshot) {
|
|
1323
|
+
if (!isRecord(snapshot) || !isRecord(snapshot.artifact) || !isRecord(snapshot.artifact.overflow)) {
|
|
1324
|
+
return 0;
|
|
1325
|
+
}
|
|
1326
|
+
const omitted = snapshot.artifact.overflow.omittedBodies;
|
|
1327
|
+
return typeof omitted === "number" && Number.isInteger(omitted) && omitted >= 0 ? omitted : 1;
|
|
1328
|
+
}
|
|
1161
1329
|
function physicsDebugMeanPoseDistance(snapshot, comparisonSnapshot, entity) {
|
|
1162
1330
|
const positions = physicsDebugBodyPositions(snapshot, entity);
|
|
1163
1331
|
const comparison = physicsDebugBodyPositions(comparisonSnapshot, entity);
|
|
@@ -1214,22 +1382,85 @@ function evaluateTagCountAssertion(assertion, observations) {
|
|
|
1214
1382
|
}
|
|
1215
1383
|
};
|
|
1216
1384
|
}
|
|
1217
|
-
function evaluateStateAssertion(assertion, observations) {
|
|
1218
|
-
const gameplay = gameplayObservations(observations);
|
|
1385
|
+
function evaluateStateAssertion(assertion, observations, scenario, index) {
|
|
1386
|
+
const gameplay = gameplayObservations(runtimeObservationValue(observations));
|
|
1219
1387
|
const states = isRecord(gameplay?.states) ? gameplay.states : void 0;
|
|
1220
|
-
const
|
|
1221
|
-
const
|
|
1222
|
-
const
|
|
1388
|
+
const candidates = Object.entries(states ?? {}).filter((entry) => typeof entry[1] === "string");
|
|
1389
|
+
const matching = assertion.entity === void 0 ? candidates.filter(([, state]) => state === assertion.equals) : candidates.filter(([entity]) => entity === assertion.entity);
|
|
1390
|
+
const terminalStep = assertion.entity === void 0 ? terminalContactStep(scenario, assertion.equals) : void 0;
|
|
1391
|
+
const terminal = terminalStep === void 0 ? { contactObserved: true, historyComplete: true, preExisting: false, preExistingEntities: [], step: null } : terminalStateEvidence(terminalStep, observations, scenario, matching.map(([entity]) => entity));
|
|
1392
|
+
const selected = matching.find(([entity]) => !terminal.preExistingEntities.includes(entity)) ?? matching[0];
|
|
1393
|
+
const selectedEntity = selected?.[0] ?? assertion.entity;
|
|
1394
|
+
const observed = selected?.[1];
|
|
1395
|
+
const selectedPreExisting = selected === void 0 ? terminal.preExisting : terminal.preExistingEntities.includes(selected[0]);
|
|
1396
|
+
const pass = observed === assertion.equals && terminal.contactObserved && terminal.historyComplete && !selectedPreExisting;
|
|
1397
|
+
const result = {
|
|
1398
|
+
details: {
|
|
1399
|
+
candidates: candidates.map(([entity, state]) => ({ entity, state })),
|
|
1400
|
+
entity: selectedEntity ?? "anonymous",
|
|
1401
|
+
expected: assertion.equals,
|
|
1402
|
+
observed: observed ?? null,
|
|
1403
|
+
terminal: { contactObserved: terminal.contactObserved, historyComplete: terminal.historyComplete, preExisting: selectedPreExisting, step: terminal.step }
|
|
1404
|
+
},
|
|
1405
|
+
id: assertion.entity === void 0 ? `states.${index}` : `states.${assertion.entity}`,
|
|
1406
|
+
pass
|
|
1407
|
+
};
|
|
1223
1408
|
return pass ? { assertion: result } : {
|
|
1224
1409
|
assertion: result,
|
|
1225
1410
|
diagnostic: {
|
|
1226
|
-
code: "TN_PLAYTEST_STATE_ASSERTION_FAILED",
|
|
1227
|
-
message: `
|
|
1411
|
+
code: observed === assertion.equals && (!terminal.contactObserved || !terminal.historyComplete || selectedPreExisting) ? "TN_PLAYTEST_STATE_ORDERING_FAILED" : "TN_PLAYTEST_STATE_ASSERTION_FAILED",
|
|
1412
|
+
message: observed === assertion.equals && (!terminal.contactObserved || !terminal.historyComplete || selectedPreExisting) ? `Terminal state '${assertion.equals}' was not observed after retained contact evidence at '${terminal.step ?? "an unavailable step"}'.` : `Entity '${selectedEntity ?? "anonymous"}' state ${observed === void 0 ? "was unavailable" : `'${observed}'`} did not equal '${assertion.equals}'.`,
|
|
1228
1413
|
severity: "error",
|
|
1229
1414
|
suggestion: "Ensure the entity has a StateMachine component and inspect runtimeObservations.gameplay.states in the playtest artifact."
|
|
1230
1415
|
}
|
|
1231
1416
|
};
|
|
1232
1417
|
}
|
|
1418
|
+
function terminalContactStep(scenario, expectedState) {
|
|
1419
|
+
if (expectedState !== "won") return void 0;
|
|
1420
|
+
return [...scenario.assert?.contacts ?? []].reverse().find((assertion) => {
|
|
1421
|
+
const minimum = assertion.minCount ?? (assertion.maxCount === void 0 ? 1 : 0);
|
|
1422
|
+
return assertion.atStep !== void 0 && minimum > 0 && (assertion.requiredOn === void 0 || assertion.requiredOn.includes(scenario.target));
|
|
1423
|
+
})?.atStep;
|
|
1424
|
+
}
|
|
1425
|
+
function terminalStateEvidence(contactStep, observations, scenario, candidateEntities) {
|
|
1426
|
+
const contactAssertion = [...scenario.assert?.contacts ?? []].reverse().find((assertion) => assertion.atStep === contactStep);
|
|
1427
|
+
const contactObserved = contactAssertion === void 0 ? false : contactAssertionSatisfiedAtStep(contactAssertion, observations, scenario);
|
|
1428
|
+
const labeledSteps = scenario.steps.flatMap(({ label }) => label === void 0 ? [] : [label]);
|
|
1429
|
+
const contactIndex = labeledSteps.indexOf(contactStep);
|
|
1430
|
+
const samples = runtimeGameplaySeries(observations);
|
|
1431
|
+
const samplesByLabel = new Map(samples.map((sample) => [sample.label, sample.states]));
|
|
1432
|
+
const historyComplete = contactIndex >= 0 && labeledSteps.slice(0, contactIndex + 1).every((label) => samplesByLabel.has(label));
|
|
1433
|
+
const preExistingEntities = candidateEntities.filter((entity) => {
|
|
1434
|
+
if (contactIndex < 0) return false;
|
|
1435
|
+
return labeledSteps.slice(0, contactIndex).some((label) => samplesByLabel.get(label)?.[entity] === "won");
|
|
1436
|
+
});
|
|
1437
|
+
return {
|
|
1438
|
+
contactObserved,
|
|
1439
|
+
historyComplete,
|
|
1440
|
+
preExisting: preExistingEntities.length > 0,
|
|
1441
|
+
preExistingEntities,
|
|
1442
|
+
step: contactStep
|
|
1443
|
+
};
|
|
1444
|
+
}
|
|
1445
|
+
function contactAssertionSatisfiedAtStep(assertion, observations, scenario) {
|
|
1446
|
+
const selectedSample = physicsDebugSeries(observations).find((sample) => sample.label === assertion.atStep);
|
|
1447
|
+
const runtimeSamples = runtimeGameplaySeries(observations);
|
|
1448
|
+
const runtimeStepAvailable = runtimeSamples.some(({ label }) => label === assertion.atStep);
|
|
1449
|
+
const stepAvailable = selectedSample !== void 0 || runtimeStepAvailable;
|
|
1450
|
+
const entity = assertion.entity ?? scenario.subject;
|
|
1451
|
+
const anonymous = assertion.entity === void 0 && scenario.subject === void 0;
|
|
1452
|
+
const physicsEvidence = assertion.kind === void 0 || assertion.kind === "contact" ? physicsDebugContactEvidence(
|
|
1453
|
+
observationsForPhysics(observations),
|
|
1454
|
+
entity,
|
|
1455
|
+
assertion.with,
|
|
1456
|
+
selectedSample?.snapshot
|
|
1457
|
+
) : { candidates: [], count: 0 };
|
|
1458
|
+
const runtimeEvidence = runtimeContactEvidence(observations, entity, assertion.with, assertion.kind, assertion.atStep);
|
|
1459
|
+
const candidates = [.../* @__PURE__ */ new Set([...physicsEvidence.candidates, ...runtimeEvidence.candidates])];
|
|
1460
|
+
const count = physicsEvidence.count + runtimeEvidence.count;
|
|
1461
|
+
const minimum = assertion.minCount ?? (assertion.maxCount === void 0 ? 1 : 0);
|
|
1462
|
+
return stepAvailable && (!anonymous || candidates.length > 0) && count >= minimum && (assertion.maxCount === void 0 || count <= assertion.maxCount);
|
|
1463
|
+
}
|
|
1233
1464
|
function evaluateWorldAssertion(assertion, observations) {
|
|
1234
1465
|
const gameplay = gameplayObservations(observations);
|
|
1235
1466
|
const world = isRecord(gameplay?.world) ? gameplay.world : void 0;
|
|
@@ -1267,12 +1498,57 @@ function gameplayObservations(value) {
|
|
|
1267
1498
|
const gameplay = value.gameplay;
|
|
1268
1499
|
return isRecord(gameplay) ? gameplay : void 0;
|
|
1269
1500
|
}
|
|
1501
|
+
function runtimeObservationValue(value) {
|
|
1502
|
+
if (!isRecord(value) || !Object.hasOwn(value, "runtimeObservations")) return value;
|
|
1503
|
+
return value.runtimeObservations;
|
|
1504
|
+
}
|
|
1505
|
+
function runtimeGameplaySamples(value) {
|
|
1506
|
+
const runtime = runtimeObservationValue(value);
|
|
1507
|
+
if (!isRecord(runtime) || !Array.isArray(runtime.gameplaySeries)) return [];
|
|
1508
|
+
return runtime.gameplaySeries.flatMap((entry) => {
|
|
1509
|
+
if (!isRecord(entry) || typeof entry.label !== "string") return [];
|
|
1510
|
+
const direct = isRecord(entry.gameplay) ? entry.gameplay : void 0;
|
|
1511
|
+
const nested = isRecord(entry.snapshot) && isRecord(entry.snapshot.gameplay) ? entry.snapshot.gameplay : void 0;
|
|
1512
|
+
return direct === void 0 && nested === void 0 ? [] : [{ gameplay: direct ?? nested, label: entry.label }];
|
|
1513
|
+
});
|
|
1514
|
+
}
|
|
1515
|
+
function runtimeGameplaySeries(value) {
|
|
1516
|
+
return runtimeGameplaySamples(value).map(({ gameplay, label }) => ({
|
|
1517
|
+
label,
|
|
1518
|
+
states: isRecord(gameplay.states) ? Object.fromEntries(Object.entries(gameplay.states).filter((entry) => typeof entry[1] === "string")) : {}
|
|
1519
|
+
}));
|
|
1520
|
+
}
|
|
1521
|
+
function runtimeGameplayAtStep(value, atStep) {
|
|
1522
|
+
const runtime = runtimeObservationValue(value);
|
|
1523
|
+
if (atStep === void 0) return gameplayObservations(runtime);
|
|
1524
|
+
return runtimeGameplaySamples(runtime).find(({ label }) => label === atStep)?.gameplay;
|
|
1525
|
+
}
|
|
1526
|
+
function physicsDebugSeries(value) {
|
|
1527
|
+
if (!isRecord(value) || !Array.isArray(value.physicsDebugSeries)) return [];
|
|
1528
|
+
return value.physicsDebugSeries.flatMap((sample) => {
|
|
1529
|
+
if (!isRecord(sample) || typeof sample.label !== "string") return [];
|
|
1530
|
+
return [{ label: sample.label, snapshot: sample.snapshot }];
|
|
1531
|
+
});
|
|
1532
|
+
}
|
|
1533
|
+
function observationsForPhysics(value) {
|
|
1534
|
+
return isRecord(value) ? value : void 0;
|
|
1535
|
+
}
|
|
1536
|
+
function runtimeContactEvidence(observations, entity, withEntity, kind, atStep) {
|
|
1537
|
+
const gameplay = runtimeGameplayAtStep(observations, atStep);
|
|
1538
|
+
if (!Array.isArray(gameplay?.contacts)) return { candidates: [], count: 0 };
|
|
1539
|
+
const candidates = [];
|
|
1540
|
+
for (const contact of gameplay.contacts) {
|
|
1541
|
+
if (!isRecord(contact) || typeof contact.entity !== "string" || typeof contact.with !== "string" || typeof contact.kind !== "string" || entity !== void 0 && contact.entity !== entity || withEntity !== void 0 && contact.with !== withEntity || kind !== void 0 && contact.kind !== kind) continue;
|
|
1542
|
+
candidates.push(`${contact.entity}:${contact.with}:${contact.kind}`);
|
|
1543
|
+
}
|
|
1544
|
+
return { candidates: [...new Set(candidates)], count: candidates.length };
|
|
1545
|
+
}
|
|
1270
1546
|
function countRuntimeContacts(observations, entity, withEntity, kind) {
|
|
1271
1547
|
const gameplay = gameplayObservations(observations);
|
|
1272
1548
|
if (!Array.isArray(gameplay?.contacts)) return 0;
|
|
1273
1549
|
return gameplay.contacts.filter((contact) => {
|
|
1274
1550
|
if (!isRecord(contact)) return false;
|
|
1275
|
-
return contact.entity === entity && (withEntity === void 0 || contact.with === withEntity) && (kind === void 0 || contact.kind === kind);
|
|
1551
|
+
return (entity === void 0 || contact.entity === entity) && (withEntity === void 0 || contact.with === withEntity) && (kind === void 0 || contact.kind === kind);
|
|
1276
1552
|
}).length;
|
|
1277
1553
|
}
|
|
1278
1554
|
function runtimeAnimationObservations(value) {
|
|
@@ -1534,7 +1810,7 @@ function evaluateDiagnosticsPolicy(report, policy) {
|
|
|
1534
1810
|
});
|
|
1535
1811
|
}
|
|
1536
1812
|
const capturedConsoleErrors = consoleErrors(report.observations?.console ?? []);
|
|
1537
|
-
if (policy
|
|
1813
|
+
if (policy.noConsoleErrors && capturedConsoleErrors.length > 0) {
|
|
1538
1814
|
diagnostics.push({
|
|
1539
1815
|
code: "TN_PLAYTEST_CONSOLE_ERROR",
|
|
1540
1816
|
message: `${capturedConsoleErrors.length} browser console error(s) were captured during playtest.`,
|
|
@@ -1542,7 +1818,7 @@ function evaluateDiagnosticsPolicy(report, policy) {
|
|
|
1542
1818
|
suggestion: "Open console.json in the playtest artifact directory and fix the first runtime error."
|
|
1543
1819
|
});
|
|
1544
1820
|
}
|
|
1545
|
-
if (policy
|
|
1821
|
+
if (policy.noNetworkErrors && (report.observations?.network.length ?? 0) > 0) {
|
|
1546
1822
|
diagnostics.push({
|
|
1547
1823
|
code: "TN_PLAYTEST_NETWORK_ERROR",
|
|
1548
1824
|
message: `${report.observations?.network.length ?? 0} failed network request(s) were captured during playtest.`,
|
|
@@ -1551,7 +1827,7 @@ function evaluateDiagnosticsPolicy(report, policy) {
|
|
|
1551
1827
|
});
|
|
1552
1828
|
}
|
|
1553
1829
|
const runtimeErrors = runtimeDiagnostics(report.observations?.runtimeDiagnostics);
|
|
1554
|
-
if (policy
|
|
1830
|
+
if (policy.noRuntimeDiagnostics && runtimeErrors.length > 0) {
|
|
1555
1831
|
diagnostics.push({
|
|
1556
1832
|
code: "TN_PLAYTEST_RUNTIME_DIAGNOSTIC",
|
|
1557
1833
|
message: `${runtimeErrors.length} runtime diagnostic error(s) were captured during playtest.`,
|
|
@@ -1633,6 +1909,86 @@ function countMatchingEntries(effectLog, tokens) {
|
|
|
1633
1909
|
return tokens.every((token) => text.includes(token));
|
|
1634
1910
|
}).length;
|
|
1635
1911
|
}
|
|
1912
|
+
function evaluatePerformanceAssertion(assertion, series, sourcePath) {
|
|
1913
|
+
const samples = series ?? [];
|
|
1914
|
+
const validSamples = samples.length > 0 && samples.every(isRuntimeDiagnosticsSample);
|
|
1915
|
+
const observed = validSamples ? samples : [];
|
|
1916
|
+
const frameTimes = observed.map(({ frameMs }) => frameMs);
|
|
1917
|
+
const drawCalls = observed.flatMap(({ drawCalls: value }) => value === void 0 ? [] : [value]);
|
|
1918
|
+
const triangles = observed.flatMap(({ triangles: value }) => value === void 0 ? [] : [value]);
|
|
1919
|
+
const frameMsP95 = nearestRank(frameTimes, 0.95);
|
|
1920
|
+
const maxObservedDrawCalls = drawCalls.length === 0 ? void 0 : Math.max(...drawCalls);
|
|
1921
|
+
const maxObservedTriangles = triangles.length === 0 ? void 0 : Math.max(...triangles);
|
|
1922
|
+
const results = [];
|
|
1923
|
+
const diagnostics = [];
|
|
1924
|
+
const path = `${sourcePath ?? "playtest"}/observations.json/performanceSeries`;
|
|
1925
|
+
const samplesPass = validSamples;
|
|
1926
|
+
results.push({
|
|
1927
|
+
details: { sampleCount: samples.length, valid: validSamples },
|
|
1928
|
+
id: "performance.samples",
|
|
1929
|
+
pass: samplesPass
|
|
1930
|
+
});
|
|
1931
|
+
if (!samplesPass) {
|
|
1932
|
+
diagnostics.push({
|
|
1933
|
+
code: "TN_PLAYTEST_PERFORMANCE_SAMPLES_MISSING",
|
|
1934
|
+
message: samples.length === 0 ? "Performance assertion received no render samples." : "Performance assertion received an invalid render sample series.",
|
|
1935
|
+
observedRuntimePath: path,
|
|
1936
|
+
severity: "error",
|
|
1937
|
+
sourcePath,
|
|
1938
|
+
suggestion: "Run the scenario against the real render loop and keep the performance bridge provider installed."
|
|
1939
|
+
});
|
|
1940
|
+
}
|
|
1941
|
+
const addBound = (id, expected, actual, unit, pass) => {
|
|
1942
|
+
results.push({ details: { actual: actual ?? null, expected, sampleCount: samples.length, unit }, id, pass });
|
|
1943
|
+
if (!pass) diagnostics.push({
|
|
1944
|
+
code: "TN_PLAYTEST_PERFORMANCE_ASSERTION_FAILED",
|
|
1945
|
+
message: `${id} expected at most ${expected} ${unit}, observed ${actual ?? "unavailable"}.`,
|
|
1946
|
+
observedRuntimePath: path,
|
|
1947
|
+
severity: "error",
|
|
1948
|
+
sourcePath,
|
|
1949
|
+
suggestion: "Inspect the recorded frame-cost series and reduce the authored scene cost that owns the regression."
|
|
1950
|
+
});
|
|
1951
|
+
};
|
|
1952
|
+
if (assertion.maxFrameMsP95 !== void 0) {
|
|
1953
|
+
addBound(
|
|
1954
|
+
"performance.maxFrameMsP95",
|
|
1955
|
+
assertion.maxFrameMsP95,
|
|
1956
|
+
frameMsP95,
|
|
1957
|
+
"ms",
|
|
1958
|
+
samplesPass && frameMsP95 !== void 0 && frameMsP95 <= assertion.maxFrameMsP95
|
|
1959
|
+
);
|
|
1960
|
+
}
|
|
1961
|
+
if (assertion.maxDrawCalls !== void 0) {
|
|
1962
|
+
addBound(
|
|
1963
|
+
"performance.maxDrawCalls",
|
|
1964
|
+
assertion.maxDrawCalls,
|
|
1965
|
+
maxObservedDrawCalls,
|
|
1966
|
+
"draw calls",
|
|
1967
|
+
samplesPass && drawCalls.length === samples.length && maxObservedDrawCalls !== void 0 && maxObservedDrawCalls <= assertion.maxDrawCalls
|
|
1968
|
+
);
|
|
1969
|
+
}
|
|
1970
|
+
if (assertion.maxTriangles !== void 0) {
|
|
1971
|
+
addBound(
|
|
1972
|
+
"performance.maxTriangles",
|
|
1973
|
+
assertion.maxTriangles,
|
|
1974
|
+
maxObservedTriangles,
|
|
1975
|
+
"triangles",
|
|
1976
|
+
samplesPass && triangles.length === samples.length && maxObservedTriangles !== void 0 && maxObservedTriangles <= assertion.maxTriangles
|
|
1977
|
+
);
|
|
1978
|
+
}
|
|
1979
|
+
return { assertions: results, diagnostics };
|
|
1980
|
+
}
|
|
1981
|
+
function isRuntimeDiagnosticsSample(value) {
|
|
1982
|
+
if (!isRecord(value) || typeof value.frameMs !== "number" || !Number.isFinite(value.frameMs) || value.frameMs <= 0) {
|
|
1983
|
+
return false;
|
|
1984
|
+
}
|
|
1985
|
+
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);
|
|
1986
|
+
}
|
|
1987
|
+
function nearestRank(values, percentile) {
|
|
1988
|
+
if (values.length === 0) return void 0;
|
|
1989
|
+
const sorted = [...values].sort((left, right) => left - right);
|
|
1990
|
+
return sorted[Math.max(0, Math.ceil(values.length * percentile) - 1)];
|
|
1991
|
+
}
|
|
1636
1992
|
function mergeEffectLogs(effectLog, series) {
|
|
1637
1993
|
return {
|
|
1638
1994
|
entries: [effectLog, ...(series ?? []).map((sample) => sample.snapshot)].flatMap((log) => isRecord(log) && Array.isArray(log.entries) ? log.entries : [])
|
|
@@ -2053,46 +2409,6 @@ function reachabilityEnvelope(value) {
|
|
|
2053
2409
|
const measurement = isRecord2(value.jump) ? value.jump : value;
|
|
2054
2410
|
return typeof measurement.maxRise === "number" && Number.isFinite(measurement.maxRise) && measurement.maxRise >= 0 && typeof measurement.forwardReach === "number" && Number.isFinite(measurement.forwardReach) && measurement.forwardReach >= 0 && typeof measurement.fallDistanceToGround === "number" && Number.isFinite(measurement.fallDistanceToGround) && measurement.fallDistanceToGround >= measurement.maxRise ? { fallDistanceToGround: measurement.fallDistanceToGround, forwardReach: measurement.forwardReach, maxRise: measurement.maxRise } : void 0;
|
|
2055
2411
|
}
|
|
2056
|
-
function oneShotScenario(options) {
|
|
2057
|
-
return {
|
|
2058
|
-
assert: {
|
|
2059
|
-
...options.expectMoved || options.expectAxis !== void 0 ? { movement: { axis: options.expectAxis, entity: options.subject, minDistance: options.expectMoved ? options.movementThreshold : void 0 } } : {},
|
|
2060
|
-
...options.follow === void 0 ? {} : { camera: { entity: options.follow.entityId, follows: options.subject, within: options.follow.within } }
|
|
2061
|
-
},
|
|
2062
|
-
name: `${safeFilePart(options.subject)}-${safeFilePart(options.press)}`,
|
|
2063
|
-
schemaVersion: 1,
|
|
2064
|
-
steps: [{ holdFrames: options.frames, press: options.press, release: true }],
|
|
2065
|
-
subject: options.subject,
|
|
2066
|
-
target: options.target ?? "web",
|
|
2067
|
-
viewport: options.viewport ?? { height: 720, width: 1280 },
|
|
2068
|
-
warmupFrames: 0
|
|
2069
|
-
};
|
|
2070
|
-
}
|
|
2071
|
-
function applyScenarioOverrides(scenario, overrides) {
|
|
2072
|
-
return {
|
|
2073
|
-
...scenario,
|
|
2074
|
-
...overrides.target === void 0 ? {} : { target: overrides.target },
|
|
2075
|
-
...overrides.viewport === void 0 ? {} : { viewport: overrides.viewport }
|
|
2076
|
-
};
|
|
2077
|
-
}
|
|
2078
|
-
function parsePlaytestTarget(value) {
|
|
2079
|
-
if (value === void 0) {
|
|
2080
|
-
return void 0;
|
|
2081
|
-
}
|
|
2082
|
-
return value === "web" || value === "desktop" || value === "bevy" ? value : void 0;
|
|
2083
|
-
}
|
|
2084
|
-
function parseViewport(value) {
|
|
2085
|
-
if (value === void 0) {
|
|
2086
|
-
return void 0;
|
|
2087
|
-
}
|
|
2088
|
-
const match = /^(\d+)x(\d+)$/.exec(value);
|
|
2089
|
-
if (match === null) {
|
|
2090
|
-
return void 0;
|
|
2091
|
-
}
|
|
2092
|
-
const width = Number(match[1]);
|
|
2093
|
-
const height = Number(match[2]);
|
|
2094
|
-
return Number.isInteger(width) && width > 0 && Number.isInteger(height) && height > 0 ? { height, width } : void 0;
|
|
2095
|
-
}
|
|
2096
2412
|
function validatePlaytestScenario(value, scenarioPath, absolutePath) {
|
|
2097
2413
|
if (!isRecord2(value)) {
|
|
2098
2414
|
throw invalidScenario(scenarioPath, "Scenario root must be a JSON object.");
|
|
@@ -2249,6 +2565,7 @@ function validateStep(value, scenarioPath, index) {
|
|
|
2249
2565
|
"label",
|
|
2250
2566
|
"overlayMessage",
|
|
2251
2567
|
"pointerPosition",
|
|
2568
|
+
"pointers",
|
|
2252
2569
|
"press",
|
|
2253
2570
|
"release",
|
|
2254
2571
|
"screenshot",
|
|
@@ -2268,12 +2585,16 @@ function validateStep(value, scenarioPath, index) {
|
|
|
2268
2585
|
x: value.pointerPosition.x,
|
|
2269
2586
|
y: value.pointerPosition.y
|
|
2270
2587
|
} : void 0;
|
|
2588
|
+
const pointers = Array.isArray(value.pointers) ? value.pointers.map((pointer, pointerIndex) => validatePointer2(pointer, scenarioPath, index, pointerIndex)) : void 0;
|
|
2271
2589
|
if (isRecord2(value.overlayMessage)) {
|
|
2272
2590
|
rejectUnknownKeys(value.overlayMessage, ["overlayId", "payload", "type"], scenarioPath, `steps[${index}].overlayMessage`);
|
|
2273
2591
|
}
|
|
2274
2592
|
if (isRecord2(value.pointerPosition)) {
|
|
2275
2593
|
rejectUnknownKeys(value.pointerPosition, ["buttons", "x", "y"], scenarioPath, `steps[${index}].pointerPosition`);
|
|
2276
2594
|
}
|
|
2595
|
+
if (pointers !== void 0 && new Set(pointers.map(({ id }) => id)).size !== pointers.length) {
|
|
2596
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} pointers must use unique ids.`);
|
|
2597
|
+
}
|
|
2277
2598
|
const holdFrames = positiveInteger(value.holdFrames);
|
|
2278
2599
|
const holdTicks = positiveInteger(value.holdTicks);
|
|
2279
2600
|
const waitFrames = positiveInteger(value.waitFrames);
|
|
@@ -2301,6 +2622,9 @@ function validateStep(value, scenarioPath, index) {
|
|
|
2301
2622
|
if (value.pointerPosition !== void 0 && pointerPosition === void 0) {
|
|
2302
2623
|
throw invalidStep(scenarioPath, `Scenario step ${index} pointerPosition must define normalized x and y values from 0 through 1.`);
|
|
2303
2624
|
}
|
|
2625
|
+
if (value.pointers !== void 0 && pointers === void 0) {
|
|
2626
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} pointers must be an array.`);
|
|
2627
|
+
}
|
|
2304
2628
|
if (value.screenshot !== void 0 && screenshot === void 0) {
|
|
2305
2629
|
throw invalidStep(scenarioPath, `Scenario step ${index} screenshot must be a stable file-safe name.`);
|
|
2306
2630
|
}
|
|
@@ -2310,8 +2634,8 @@ function validateStep(value, scenarioPath, index) {
|
|
|
2310
2634
|
if (value.window !== void 0 && window === void 0) {
|
|
2311
2635
|
throw invalidStep(scenarioPath, `Scenario step ${index} window must define minimize, restore, or resize with positive width and height.`);
|
|
2312
2636
|
}
|
|
2313
|
-
if (press === void 0 && overlayMessage === void 0 && pointerPosition === void 0 && window === void 0 && waitFrames === void 0 && waitTicks === void 0) {
|
|
2314
|
-
throw invalidStep(scenarioPath, `Scenario step ${index} must define press, overlayMessage, pointerPosition, window, or waitFrames/waitTicks.`);
|
|
2637
|
+
if (press === void 0 && overlayMessage === void 0 && pointerPosition === void 0 && pointers === void 0 && window === void 0 && waitFrames === void 0 && waitTicks === void 0) {
|
|
2638
|
+
throw invalidStep(scenarioPath, `Scenario step ${index} must define press, overlayMessage, pointerPosition, pointers, window, or waitFrames/waitTicks.`);
|
|
2315
2639
|
}
|
|
2316
2640
|
if (value.holdFrames !== void 0 && holdFrames === void 0) {
|
|
2317
2641
|
throw invalidStep(scenarioPath, `Scenario step ${index} holdFrames must be a positive integer.`);
|
|
@@ -2341,6 +2665,7 @@ function validateStep(value, scenarioPath, index) {
|
|
|
2341
2665
|
...typeof value.label === "string" ? { label: value.label } : {},
|
|
2342
2666
|
...overlayMessage === void 0 ? {} : { overlayMessage },
|
|
2343
2667
|
...pointerPosition === void 0 ? {} : { pointerPosition },
|
|
2668
|
+
...pointers === void 0 ? {} : { pointers },
|
|
2344
2669
|
...press === void 0 ? {} : { press },
|
|
2345
2670
|
release: typeof value.release === "boolean" ? value.release : true,
|
|
2346
2671
|
...screenshot === void 0 ? {} : { screenshot },
|
|
@@ -2349,6 +2674,26 @@ function validateStep(value, scenarioPath, index) {
|
|
|
2349
2674
|
...window === void 0 ? {} : { window }
|
|
2350
2675
|
};
|
|
2351
2676
|
}
|
|
2677
|
+
function validatePointer2(value, scenarioPath, stepIndex, pointerIndex) {
|
|
2678
|
+
const path = `steps[${stepIndex}].pointers[${pointerIndex}]`;
|
|
2679
|
+
if (!isRecord2(value)) throw invalidStep(scenarioPath, `${path} must be an object.`);
|
|
2680
|
+
rejectUnknownKeys(value, ["buttons", "id", "x", "y"], scenarioPath, path);
|
|
2681
|
+
if (!Number.isInteger(value.id) || value.id < 1) {
|
|
2682
|
+
throw invalidStep(scenarioPath, `${path}.id must be a positive integer.`);
|
|
2683
|
+
}
|
|
2684
|
+
if (typeof value.x !== "number" || !Number.isFinite(value.x) || value.x < 0 || value.x > 1 || typeof value.y !== "number" || !Number.isFinite(value.y) || value.y < 0 || value.y > 1) {
|
|
2685
|
+
throw invalidStep(scenarioPath, `${path} must define normalized x and y values from 0 through 1.`);
|
|
2686
|
+
}
|
|
2687
|
+
if (value.buttons !== void 0 && (!Number.isInteger(value.buttons) || value.buttons < 1)) {
|
|
2688
|
+
throw invalidStep(scenarioPath, `${path}.buttons must be a positive integer when present.`);
|
|
2689
|
+
}
|
|
2690
|
+
return {
|
|
2691
|
+
...typeof value.buttons === "number" ? { buttons: value.buttons } : {},
|
|
2692
|
+
id: value.id,
|
|
2693
|
+
x: value.x,
|
|
2694
|
+
y: value.y
|
|
2695
|
+
};
|
|
2696
|
+
}
|
|
2352
2697
|
function validateStepLabels(steps, assertions, scenarioPath) {
|
|
2353
2698
|
const labels = /* @__PURE__ */ new Set();
|
|
2354
2699
|
for (const [index, step] of steps.entries()) {
|
|
@@ -2388,6 +2733,18 @@ function validateStepLabels(steps, assertions, scenarioPath) {
|
|
|
2388
2733
|
requireLabel(assertion.compareToStep, `assert.settled[${index}].compareToStep`);
|
|
2389
2734
|
}
|
|
2390
2735
|
requireLabel(assertions.movement?.reachesPositionWithin?.atStep, "assert.movement.reachesPositionWithin.atStep");
|
|
2736
|
+
requireLabel(assertions.framebufferCoverage?.window.startStep, "assert.framebufferCoverage.window.startStep");
|
|
2737
|
+
requireLabel(assertions.framebufferCoverage?.window.endStep, "assert.framebufferCoverage.window.endStep");
|
|
2738
|
+
if (assertions.framebufferCoverage !== void 0) {
|
|
2739
|
+
const startIndex = steps.findIndex(({ label }) => label === assertions.framebufferCoverage?.window.startStep);
|
|
2740
|
+
const endIndex = steps.findIndex(({ label }) => label === assertions.framebufferCoverage?.window.endStep);
|
|
2741
|
+
if (endIndex < startIndex) {
|
|
2742
|
+
throw invalidScenario(
|
|
2743
|
+
scenarioPath,
|
|
2744
|
+
"Assertion 'assert.framebufferCoverage.window.endStep' must not precede startStep."
|
|
2745
|
+
);
|
|
2746
|
+
}
|
|
2747
|
+
}
|
|
2391
2748
|
}
|
|
2392
2749
|
function playtestStepHoldTicks(step, fallback = 1) {
|
|
2393
2750
|
if (step.press === void 0 || step.holdFrames !== void 0 || step.waitFrames !== void 0) return 0;
|
|
@@ -2406,12 +2763,25 @@ function validateAssertions(value, scenarioPath) {
|
|
|
2406
2763
|
const movement = isRecord2(value.movement) ? value.movement : void 0;
|
|
2407
2764
|
const camera = isRecord2(value.camera) ? value.camera : void 0;
|
|
2408
2765
|
const diagnostics = isRecord2(value.diagnostics) ? value.diagnostics : void 0;
|
|
2766
|
+
const performance = isRecord2(value.performance) ? validatePerformanceAssertion(value.performance, scenarioPath, "assert.performance") : void 0;
|
|
2767
|
+
const framebufferCoverage = isRecord2(value.framebufferCoverage) ? validateFramebufferCoverageAssertion(
|
|
2768
|
+
value.framebufferCoverage,
|
|
2769
|
+
scenarioPath,
|
|
2770
|
+
"assert.framebufferCoverage"
|
|
2771
|
+
) : void 0;
|
|
2409
2772
|
const world = isRecord2(value.world) ? value.world : void 0;
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2773
|
+
const optOuts = [
|
|
2774
|
+
["noConsoleErrors", "consoleErrorsOptOutReason"],
|
|
2775
|
+
["noNetworkErrors", "networkErrorsOptOutReason"],
|
|
2776
|
+
["noRuntimeDiagnostics", "runtimeDiagnosticsOptOutReason"]
|
|
2777
|
+
];
|
|
2778
|
+
for (const [policyKey, reasonKey] of optOuts) {
|
|
2779
|
+
if (diagnostics?.[policyKey] === false && (typeof diagnostics[reasonKey] !== "string" || diagnostics[reasonKey].trim() === "")) {
|
|
2780
|
+
throw invalidScenario(
|
|
2781
|
+
scenarioPath,
|
|
2782
|
+
`Assertion 'assert.diagnostics.${policyKey}' may be false only when '${reasonKey}' explains the bounded exception.`
|
|
2783
|
+
);
|
|
2784
|
+
}
|
|
2415
2785
|
}
|
|
2416
2786
|
return {
|
|
2417
2787
|
...Array.isArray(value.aerodynamics) ? { aerodynamics: value.aerodynamics.map(validateAerodynamicsAssertion).filter((item) => item !== void 0) } : {},
|
|
@@ -2435,11 +2805,15 @@ function validateAssertions(value, scenarioPath) {
|
|
|
2435
2805
|
...typeof diagnostics.noConsoleErrors === "boolean" ? { noConsoleErrors: diagnostics.noConsoleErrors } : {},
|
|
2436
2806
|
...typeof diagnostics.noNetworkErrors === "boolean" ? { noNetworkErrors: diagnostics.noNetworkErrors } : {},
|
|
2437
2807
|
...typeof diagnostics.noRuntimeDiagnostics === "boolean" ? { noRuntimeDiagnostics: diagnostics.noRuntimeDiagnostics } : {},
|
|
2808
|
+
...typeof diagnostics.consoleErrorsOptOutReason === "string" ? { consoleErrorsOptOutReason: diagnostics.consoleErrorsOptOutReason } : {},
|
|
2809
|
+
...typeof diagnostics.networkErrorsOptOutReason === "string" ? { networkErrorsOptOutReason: diagnostics.networkErrorsOptOutReason } : {},
|
|
2438
2810
|
...typeof diagnostics.runtimeDiagnosticsOptOutReason === "string" ? { runtimeDiagnosticsOptOutReason: diagnostics.runtimeDiagnosticsOptOutReason } : {},
|
|
2439
2811
|
...typeof diagnostics.runtimeReady === "boolean" ? { runtimeReady: diagnostics.runtimeReady } : {}
|
|
2440
2812
|
}
|
|
2441
2813
|
},
|
|
2442
2814
|
...Array.isArray(value.hud) ? { hud: value.hud.map(validatePathAssertion).filter((item) => item !== void 0) } : {},
|
|
2815
|
+
...performance === void 0 ? {} : { performance },
|
|
2816
|
+
...framebufferCoverage === void 0 ? {} : { framebufferCoverage },
|
|
2443
2817
|
...movement === void 0 ? {} : {
|
|
2444
2818
|
movement: {
|
|
2445
2819
|
...typeof movement.axis === "string" ? { axis: movement.axis } : {},
|
|
@@ -2542,7 +2916,7 @@ function validateSettledAssertion(value, scenarioPath, objectPath) {
|
|
|
2542
2916
|
return {
|
|
2543
2917
|
...present("atStep", optionalString(record2, "atStep", scenarioPath, objectPath)),
|
|
2544
2918
|
...present("compareToStep", optionalString(record2, "compareToStep", scenarioPath, objectPath)),
|
|
2545
|
-
entity
|
|
2919
|
+
...present("entity", optionalString(record2, "entity", scenarioPath, objectPath)),
|
|
2546
2920
|
...present("minBodies", optionalPositiveInteger(record2, "minBodies", scenarioPath, objectPath)),
|
|
2547
2921
|
...present("minMeanPoseDistance", optionalPositiveNumber(record2, "minMeanPoseDistance", scenarioPath, objectPath)),
|
|
2548
2922
|
...present("requiredOn", optionalTargetArray(record2, "requiredOn", scenarioPath, objectPath))
|
|
@@ -2712,6 +3086,14 @@ function optionalNumber(value, key, scenarioPath, objectPath) {
|
|
|
2712
3086
|
}
|
|
2713
3087
|
return raw;
|
|
2714
3088
|
}
|
|
3089
|
+
function optionalNonNegativeNumber(value, key, scenarioPath, objectPath) {
|
|
3090
|
+
const raw = value[key];
|
|
3091
|
+
if (raw === void 0) return void 0;
|
|
3092
|
+
if (typeof raw !== "number" || !Number.isFinite(raw) || raw < 0) {
|
|
3093
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.${key}' must be a finite non-negative number, received ${describeValue(raw)}.`);
|
|
3094
|
+
}
|
|
3095
|
+
return raw;
|
|
3096
|
+
}
|
|
2715
3097
|
function optionalNonNegativeInteger(value, key, scenarioPath, objectPath) {
|
|
2716
3098
|
const raw = value[key];
|
|
2717
3099
|
if (raw === void 0) return void 0;
|
|
@@ -2752,11 +3134,61 @@ function optionalTargetArray(value, key, scenarioPath, objectPath) {
|
|
|
2752
3134
|
function present(key, value) {
|
|
2753
3135
|
return value === void 0 ? {} : { [key]: value };
|
|
2754
3136
|
}
|
|
3137
|
+
function validatePerformanceAssertion(value, scenarioPath, objectPath) {
|
|
3138
|
+
const record2 = requireRecord(value, scenarioPath, objectPath);
|
|
3139
|
+
rejectUnknownKeys(record2, ["maxDrawCalls", "maxFrameMsP95", "maxTriangles"], scenarioPath, objectPath);
|
|
3140
|
+
return {
|
|
3141
|
+
...present("maxDrawCalls", optionalNonNegativeNumber(record2, "maxDrawCalls", scenarioPath, objectPath)),
|
|
3142
|
+
...present("maxFrameMsP95", optionalNonNegativeNumber(record2, "maxFrameMsP95", scenarioPath, objectPath)),
|
|
3143
|
+
...present("maxTriangles", optionalNonNegativeNumber(record2, "maxTriangles", scenarioPath, objectPath))
|
|
3144
|
+
};
|
|
3145
|
+
}
|
|
3146
|
+
function validateFramebufferCoverageAssertion(value, scenarioPath, objectPath) {
|
|
3147
|
+
const record2 = requireRecord(value, scenarioPath, objectPath);
|
|
3148
|
+
rejectUnknownKeys(record2, ["backdrop", "grid", "tolerance", "window"], scenarioPath, objectPath);
|
|
3149
|
+
const backdrop = requireArray(record2, "backdrop", scenarioPath, objectPath);
|
|
3150
|
+
if (backdrop.length !== 3 || backdrop.some((channel) => typeof channel !== "number" || !Number.isInteger(channel) || channel < 0 || channel > 255)) {
|
|
3151
|
+
throw invalidScenario(
|
|
3152
|
+
scenarioPath,
|
|
3153
|
+
`'${objectPath}.backdrop' must be three integer RGB channels from 0 to 255.`
|
|
3154
|
+
);
|
|
3155
|
+
}
|
|
3156
|
+
const tolerance = optionalNonNegativeInteger(record2, "tolerance", scenarioPath, objectPath);
|
|
3157
|
+
if (tolerance === void 0 || tolerance > 255) {
|
|
3158
|
+
throw invalidScenario(scenarioPath, `'${objectPath}.tolerance' must be an integer from 0 to 255.`);
|
|
3159
|
+
}
|
|
3160
|
+
const window = requireRecord(record2.window, scenarioPath, `${objectPath}.window`);
|
|
3161
|
+
rejectUnknownKeys(window, ["endStep", "startStep"], scenarioPath, `${objectPath}.window`);
|
|
3162
|
+
const gridValue = record2.grid;
|
|
3163
|
+
let grid;
|
|
3164
|
+
if (gridValue !== void 0) {
|
|
3165
|
+
const gridRecord = requireRecord(gridValue, scenarioPath, `${objectPath}.grid`);
|
|
3166
|
+
rejectUnknownKeys(gridRecord, ["columns", "rows"], scenarioPath, `${objectPath}.grid`);
|
|
3167
|
+
const columns = optionalPositiveInteger(gridRecord, "columns", scenarioPath, `${objectPath}.grid`);
|
|
3168
|
+
const rows = optionalPositiveInteger(gridRecord, "rows", scenarioPath, `${objectPath}.grid`);
|
|
3169
|
+
if (columns === void 0 || rows === void 0 || columns > 256 || rows > 256) {
|
|
3170
|
+
throw invalidScenario(
|
|
3171
|
+
scenarioPath,
|
|
3172
|
+
`'${objectPath}.grid' columns and rows must be positive integers no greater than 256.`
|
|
3173
|
+
);
|
|
3174
|
+
}
|
|
3175
|
+
grid = { columns, rows };
|
|
3176
|
+
}
|
|
3177
|
+
return {
|
|
3178
|
+
backdrop,
|
|
3179
|
+
...grid === void 0 ? {} : { grid },
|
|
3180
|
+
tolerance,
|
|
3181
|
+
window: {
|
|
3182
|
+
endStep: requireString(window, "endStep", scenarioPath, `${objectPath}.window`),
|
|
3183
|
+
startStep: requireString(window, "startStep", scenarioPath, `${objectPath}.window`)
|
|
3184
|
+
}
|
|
3185
|
+
};
|
|
3186
|
+
}
|
|
2755
3187
|
function validateStateAssertion(value, scenarioPath, objectPath) {
|
|
2756
3188
|
const record2 = requireRecord(value, scenarioPath, objectPath);
|
|
2757
3189
|
rejectUnknownKeys(record2, ["entity", "equals"], scenarioPath, objectPath);
|
|
2758
3190
|
return {
|
|
2759
|
-
entity
|
|
3191
|
+
...present("entity", optionalString(record2, "entity", scenarioPath, objectPath)),
|
|
2760
3192
|
equals: requireString(record2, "equals", scenarioPath, objectPath)
|
|
2761
3193
|
};
|
|
2762
3194
|
}
|
|
@@ -2933,9 +3365,6 @@ function validateNumberTuple(value, length) {
|
|
|
2933
3365
|
}
|
|
2934
3366
|
return value;
|
|
2935
3367
|
}
|
|
2936
|
-
function safeFilePart(value) {
|
|
2937
|
-
return value.replace(/[^A-Za-z0-9._-]+/g, "-");
|
|
2938
|
-
}
|
|
2939
3368
|
function isRecord2(value) {
|
|
2940
3369
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2941
3370
|
}
|
|
@@ -3054,4 +3483,4 @@ function validateNestedAssertionKeys(kind, value, scenarioPath, suffix) {
|
|
|
3054
3483
|
}
|
|
3055
3484
|
}
|
|
3056
3485
|
|
|
3057
|
-
export { PLAYTEST_ASSERTION_REGISTRY, PLAYTEST_BRIDGE_GLOBAL, PLAYTEST_CAPABILITY_REGISTRY, PLAYTEST_PROTOCOL_LIMITS, PLAYTEST_PROTOCOL_VERSION,
|
|
3486
|
+
export { PLAYTEST_ASSERTION_REGISTRY, PLAYTEST_BRIDGE_GLOBAL, PLAYTEST_CAPABILITY_REGISTRY, PLAYTEST_PROTOCOL_LIMITS, PLAYTEST_PROTOCOL_VERSION, PlaytestScenarioError, assertJsonSafe, evaluateRichPlaytestAssertions, invalidScenario, jsonByteLength, loadPlaytestScenario, missingPlaytestCapabilities, parseReplayRecording, playtestDiagnostic, playtestStepHoldTicks, playtestStepWaitTicks, rejectUnknownKeys, requiredPlaytestCapabilities, resolveDiagnosticsPolicy, unknownPlaytestCapabilities };
|