ravensight-playtest 0.9.0 → 0.10.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/README.md +232 -34
- package/addons/ravensight_driver/driver.gd +666 -21
- package/docs/ADAPTERS.md +11 -7
- package/docs/NATIVE_RUNNER.md +3 -1
- package/docs/godot-driver.md +127 -13
- package/package.json +8 -6
- package/src/api/client.js +4 -3
- package/src/cli.js +63 -13
- package/src/commands/check.js +30 -4
- package/src/commands/hosted.js +18 -4
- package/src/commands/init.js +17 -1
- package/src/commands/run.js +209 -14
- package/src/commands/upload.js +6 -2
- package/src/commands/validate.js +1 -1
- package/src/commands/validateHosted.js +50 -5
- package/src/config.js +33 -2
- package/src/hosted/archivePreflight.js +7 -7
- package/src/hosted/buildUpload.js +89 -8
- package/src/hosted/recordedRun.js +40 -1
- package/src/run/actionSelector.js +14 -3
- package/src/run/aggregate.js +57 -3
- package/src/run/anygame/controlbook.js +179 -0
- package/src/run/anygame/genre.js +179 -0
- package/src/run/anygame/index.js +258 -0
- package/src/run/anygame/language.js +336 -0
- package/src/run/anygame/memory.js +330 -0
- package/src/run/anygame/shared-hashes.json +10 -0
- package/src/run/anygame/shared.js +24 -0
- package/src/run/anygame/sound.js +342 -0
- package/src/run/args.js +75 -8
- package/src/run/choiceCheck.js +312 -0
- package/src/run/context.js +254 -13
- package/src/run/drivers/godot-observation.js +93 -6
- package/src/run/drivers/godot.js +769 -46
- package/src/run/drivers/recording.js +24 -4
- package/src/run/drivers/web.js +1242 -77
- package/src/run/edgePass.js +731 -0
- package/src/run/fixLoop.js +5 -4
- package/src/run/focus.js +65 -0
- package/src/run/gamepad.js +108 -0
- package/src/run/godotEdgePass.js +235 -0
- package/src/run/godotTesterProbes.js +192 -0
- package/src/run/headings.js +21 -0
- package/src/run/honesty.js +544 -0
- package/src/run/inputs.js +256 -0
- package/src/run/marks.js +142 -0
- package/src/run/personaLoop.js +1000 -79
- package/src/run/phone.js +7 -0
- package/src/run/pixels.js +215 -0
- package/src/run/playClock.js +162 -0
- package/src/run/readiness.js +585 -0
- package/src/run/refusal.js +67 -0
- package/src/run/regions.js +119 -0
- package/src/run/report.js +14 -2
- package/src/run/reportChecks.js +472 -0
- package/src/run/resume.js +3 -2
- package/src/run/screenshots.js +161 -0
- package/src/run/strip.js +114 -0
- package/src/run/testerLedger.js +312 -0
- package/src/run/testerProbes.js +584 -0
- package/src/run/thinRun.js +102 -0
- package/src/run/timeFreeze.js +79 -0
- package/src/run/tools.js +454 -29
- package/src/runDefaults.js +1 -0
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
// Sound, as evidence (PE-04 in docs/playtest/PLAYTESTER_EDGE_CASES.md).
|
|
2
|
+
//
|
|
3
|
+
// The playtester does not hear the game. What it can do is measure the
|
|
4
|
+
// browser's audio graph while the game runs:
|
|
5
|
+
//
|
|
6
|
+
// - whether the game made an audio context or played an audio element at all;
|
|
7
|
+
// - whether a context ever ran, or stayed suspended after the player's inputs;
|
|
8
|
+
// - how many sounds were started, and the level of what reached the output
|
|
9
|
+
// (a tap on every node the game connects to the destination);
|
|
10
|
+
// - errors: a context that could not be made, audio that could not be
|
|
11
|
+
// decoded, an element that could not load or was refused.
|
|
12
|
+
//
|
|
13
|
+
// The page is read once a step, so each step has its own numbers: which inputs
|
|
14
|
+
// made a sound, whether sound was present all along, and where it was silent
|
|
15
|
+
// at a moment a player would expect one (the planner marks those steps; a
|
|
16
|
+
// level cleared, a win and a loss count too).
|
|
17
|
+
//
|
|
18
|
+
// A sound's start is counted in the step that started it. Its level is
|
|
19
|
+
// measured while it plays, which can be a moment later (an audio output takes
|
|
20
|
+
// time to open), so a level may be counted in the step after. "Silent where a
|
|
21
|
+
// sound was expected" is therefore decided by starts alone: no sound started
|
|
22
|
+
// in the step, and none in the step after (a late start leaves it undecided
|
|
23
|
+
// and said so). A level from an earlier sound never hides a silent moment.
|
|
24
|
+
//
|
|
25
|
+
// The limit is stated wherever this is reported: these are measurements of
|
|
26
|
+
// whether sound played and how loud, never a judgement of how it sounds, and
|
|
27
|
+
// no finding is made unless a self test showed that this browser can run and
|
|
28
|
+
// measure an audio graph at all.
|
|
29
|
+
const noDashes = s => String(s ?? '').replace(/[\u2013\u2014]/g, ',');
|
|
30
|
+
|
|
31
|
+
// The level under which the output counts as silent (linear peak; about -54 dBFS).
|
|
32
|
+
export const SILENT_PEAK = 0.002;
|
|
33
|
+
// How often the page samples its output level while audio runs.
|
|
34
|
+
export const SAMPLE_EVERY_MS = 50;
|
|
35
|
+
// Steps with sound before "silent where sound is expected" may be said at all: the game must be shown to make sound.
|
|
36
|
+
export const HEARD_STEPS_MIN = 3;
|
|
37
|
+
// Inputs played before a context that never ran is reported.
|
|
38
|
+
export const UNLOCK_INPUTS_MIN = 3;
|
|
39
|
+
// Steps in a row with sound, to the end of play, that count as "never stopped".
|
|
40
|
+
export const CONTINUOUS_MIN = 10;
|
|
41
|
+
export const MAX_ERRORS = 12;
|
|
42
|
+
|
|
43
|
+
/* c8 ignore start */
|
|
44
|
+
/** Runs in every frame before any page script, and before the time gate, so its sampler keeps real time. */
|
|
45
|
+
export function soundProbeInit(opts) {
|
|
46
|
+
if (typeof window === 'undefined' || window.__rsSound) return;
|
|
47
|
+
const SILENT = (opts && opts.silentPeak) || 0.002, EVERY = (opts && opts.everyMs) || 50, MAX_ERR = 12;
|
|
48
|
+
const nativeInterval = window.setInterval.bind(window);
|
|
49
|
+
const S = { contexts: 0, everRunning: false, runMs: 0, starts: 0, plays: 0, loudMs: 0, mediaMs: 0, peak: 0, blocked: 0, errors: [] };
|
|
50
|
+
const since = { starts: 0, plays: 0, loudMs: 0, mediaMs: 0, peak: 0, blocked: 0, errors: 0 };
|
|
51
|
+
const taps = new Map();
|
|
52
|
+
const media = new Set();
|
|
53
|
+
const err = (kind, e) => { if (S.errors.length < MAX_ERR) S.errors.push({ kind, message: String((e && (e.name || e.message)) || e || '').slice(0, 120) }); since.errors++; };
|
|
54
|
+
const tapFor = ctx => {
|
|
55
|
+
let t = taps.get(ctx);
|
|
56
|
+
if (!t) {
|
|
57
|
+
try {
|
|
58
|
+
const analyser = ctx.createAnalyser();
|
|
59
|
+
analyser.fftSize = 1024;
|
|
60
|
+
t = { analyser, buf: new Float32Array(analyser.fftSize) };
|
|
61
|
+
taps.set(ctx, t);
|
|
62
|
+
S.contexts = taps.size;
|
|
63
|
+
} catch { t = null; }
|
|
64
|
+
}
|
|
65
|
+
return t;
|
|
66
|
+
};
|
|
67
|
+
const live = ctx => typeof OfflineAudioContext === 'undefined' || !(ctx instanceof OfflineAudioContext);
|
|
68
|
+
try {
|
|
69
|
+
for (const n of ['AudioContext', 'webkitAudioContext']) {
|
|
70
|
+
const C = window[n];
|
|
71
|
+
if (typeof C !== 'function') continue;
|
|
72
|
+
window[n] = new Proxy(C, { construct(target, args, newTarget) {
|
|
73
|
+
try {
|
|
74
|
+
const c = Reflect.construct(target, args, newTarget === window[n] ? target : newTarget);
|
|
75
|
+
tapFor(c);
|
|
76
|
+
return c;
|
|
77
|
+
} catch (e) { err('context', e); throw e; }
|
|
78
|
+
} });
|
|
79
|
+
}
|
|
80
|
+
const AN = window.AudioNode && window.AudioNode.prototype;
|
|
81
|
+
if (AN) {
|
|
82
|
+
const connect = AN.connect, disconnect = AN.disconnect;
|
|
83
|
+
AN.connect = function (dest) {
|
|
84
|
+
const out = connect.apply(this, arguments);
|
|
85
|
+
try {
|
|
86
|
+
if (dest && this.context && dest === this.context.destination && live(this.context)) { const t = tapFor(this.context); if (t && this !== t.analyser) connect.call(this, t.analyser); }
|
|
87
|
+
} catch { /* a node that cannot be tapped is not measured */ }
|
|
88
|
+
return out;
|
|
89
|
+
};
|
|
90
|
+
AN.disconnect = function (dest) {
|
|
91
|
+
try { if (dest && this.context && dest === this.context.destination) { const t = taps.get(this.context); if (t) disconnect.call(this, t.analyser); } } catch { /* was not tapped */ }
|
|
92
|
+
return disconnect.apply(this, arguments);
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
for (const n of ['AudioScheduledSourceNode', 'AudioBufferSourceNode', 'OscillatorNode', 'ConstantSourceNode']) {
|
|
96
|
+
const P = window[n] && window[n].prototype;
|
|
97
|
+
if (!P || !Object.prototype.hasOwnProperty.call(P, 'start')) continue;
|
|
98
|
+
const start = P.start;
|
|
99
|
+
P.start = function () { try { if (live(this.context)) { S.starts++; since.starts++; } } catch { /* odd node */ } return start.apply(this, arguments); };
|
|
100
|
+
}
|
|
101
|
+
const BA = window.BaseAudioContext && window.BaseAudioContext.prototype;
|
|
102
|
+
if (BA && typeof BA.decodeAudioData === 'function') {
|
|
103
|
+
const decode = BA.decodeAudioData;
|
|
104
|
+
BA.decodeAudioData = function () {
|
|
105
|
+
const p = decode.apply(this, arguments);
|
|
106
|
+
if (p && typeof p.catch === 'function') p.catch(e => err('decode', e));
|
|
107
|
+
return p;
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
const ME = window.HTMLMediaElement && window.HTMLMediaElement.prototype;
|
|
111
|
+
if (ME) {
|
|
112
|
+
const play = ME.play;
|
|
113
|
+
ME.play = function () {
|
|
114
|
+
S.plays++; since.plays++;
|
|
115
|
+
media.add(this);
|
|
116
|
+
const p = play.apply(this, arguments);
|
|
117
|
+
if (p && typeof p.catch === 'function') p.catch(e => { if (e && e.name === 'NotAllowedError') { S.blocked++; since.blocked++; } else if (e && e.name !== 'AbortError') err('element', e); });
|
|
118
|
+
return p;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
window.addEventListener('error', e => { const t = e && e.target; if (t && (t.tagName === 'AUDIO' || (t.tagName === 'SOURCE' && t.parentNode && t.parentNode.tagName === 'AUDIO'))) err('load', 'an audio file could not be loaded'); }, true);
|
|
122
|
+
} catch { /* no web audio here */ }
|
|
123
|
+
nativeInterval(() => {
|
|
124
|
+
let loud = false, ran = false;
|
|
125
|
+
for (const [ctx, t] of taps) {
|
|
126
|
+
if (ctx.state !== 'running') continue;
|
|
127
|
+
ran = true;
|
|
128
|
+
try {
|
|
129
|
+
t.analyser.getFloatTimeDomainData(t.buf);
|
|
130
|
+
let peak = 0;
|
|
131
|
+
for (let i = 0; i < t.buf.length; i += 4) { const v = Math.abs(t.buf[i]); if (v > peak) peak = v; }
|
|
132
|
+
if (peak > S.peak) S.peak = peak;
|
|
133
|
+
if (peak > since.peak) since.peak = peak;
|
|
134
|
+
if (peak > SILENT) loud = true;
|
|
135
|
+
} catch { /* closed */ }
|
|
136
|
+
}
|
|
137
|
+
// A context counts as having run once it has run for a few ticks: one made and suspended at once never did.
|
|
138
|
+
if (ran) { S.runMs += EVERY; if (S.runMs >= 3 * EVERY) S.everRunning = true; }
|
|
139
|
+
if (loud) { S.loudMs += EVERY; since.loudMs += EVERY; }
|
|
140
|
+
let playing = false;
|
|
141
|
+
for (const el of media) {
|
|
142
|
+
try {
|
|
143
|
+
if (!el.paused && !el.ended && !el.muted && el.volume > 0 && el.playbackRate > 0 && el.readyState >= 2 && el.currentTime !== el.__rsAt) playing = true;
|
|
144
|
+
el.__rsAt = el.currentTime;
|
|
145
|
+
} catch { /* gone */ }
|
|
146
|
+
}
|
|
147
|
+
if (playing) { S.mediaMs += EVERY; since.mediaMs += EVERY; }
|
|
148
|
+
}, EVERY);
|
|
149
|
+
Object.defineProperty(window, '__rsSound', { value: Object.freeze({
|
|
150
|
+
/** Totals, and what happened since the last read. */
|
|
151
|
+
read() {
|
|
152
|
+
let running = 0, suspended = 0;
|
|
153
|
+
for (const ctx of taps.keys()) { if (ctx.state === 'running') running++; else if (ctx.state === 'suspended') suspended++; }
|
|
154
|
+
const out = { contexts: taps.size, running, suspended, everRunning: S.everRunning, elements: media.size, totals: { starts: S.starts, plays: S.plays, loudMs: S.loudMs, mediaMs: S.mediaMs, peak: S.peak, blocked: S.blocked }, since: { ...since }, errors: S.errors.slice() };
|
|
155
|
+
since.starts = 0; since.plays = 0; since.loudMs = 0; since.mediaMs = 0; since.peak = 0; since.blocked = 0; since.errors = 0;
|
|
156
|
+
return out;
|
|
157
|
+
}
|
|
158
|
+
}), enumerable: false });
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** In a blank page: one tone through an analyser to the output. What the probe would see of a game that makes sound. */
|
|
162
|
+
function selfTestInPage(ms) {
|
|
163
|
+
return new Promise(resolve => {
|
|
164
|
+
try {
|
|
165
|
+
const C = window.AudioContext || window.webkitAudioContext;
|
|
166
|
+
const ctx = new C();
|
|
167
|
+
const osc = ctx.createOscillator(), gain = ctx.createGain();
|
|
168
|
+
gain.gain.value = 0.2;
|
|
169
|
+
osc.connect(gain);
|
|
170
|
+
gain.connect(ctx.destination);
|
|
171
|
+
osc.start();
|
|
172
|
+
const done = () => { const r = window.__rsSound ? window.__rsSound.read() : null; const state = ctx.state; try { osc.stop(); ctx.close(); } catch { /* closing */ } resolve({ state, read: r }); };
|
|
173
|
+
const go = () => setTimeout(done, ms);
|
|
174
|
+
if (ctx.state === 'running') go(); else ctx.resume().then(go, () => done());
|
|
175
|
+
} catch (e) { resolve({ state: 'error', error: String(e && e.message).slice(0, 80), read: null }); }
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
/* c8 ignore stop */
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Whether this browser can run an audio graph and the probe can measure it:
|
|
182
|
+
* a tone played in a blank page, after a real click, must be seen at the
|
|
183
|
+
* output. `{ ok, state, peak, why }`. Free: no game, no model. Never throws.
|
|
184
|
+
*/
|
|
185
|
+
export async function soundSelfTest(browser, { ms = 350 } = {}) {
|
|
186
|
+
let context = null;
|
|
187
|
+
try {
|
|
188
|
+
context = await browser.newContext({ viewport: { width: 320, height: 240 } });
|
|
189
|
+
await context.addInitScript(soundProbeInit, { silentPeak: SILENT_PEAK, everyMs: SAMPLE_EVERY_MS });
|
|
190
|
+
const page = await context.newPage();
|
|
191
|
+
await page.goto('about:blank');
|
|
192
|
+
// A real click first: a browser may hold audio until the page has had one.
|
|
193
|
+
await page.mouse.click(10, 10);
|
|
194
|
+
const r = await page.evaluate(selfTestInPage, ms);
|
|
195
|
+
const peak = r?.read?.totals?.peak || 0;
|
|
196
|
+
const ok = r?.state === 'running' && peak > SILENT_PEAK && (r.read.totals.starts || 0) >= 1;
|
|
197
|
+
return { ok, state: r?.state || 'unknown', peak: Math.round(peak * 1000) / 1000, why: ok ? null : r?.state !== 'running' ? `a test tone's audio context was "${r?.state || 'unknown'}", not running` : 'a test tone was not measured at the output' };
|
|
198
|
+
} catch (e) {
|
|
199
|
+
return { ok: false, state: 'error', peak: 0, why: `the audio self test could not run (${String(e?.message || e).split('\n')[0].slice(0, 80)})` };
|
|
200
|
+
} finally { await context?.close().catch(() => {}); }
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** The page's sound numbers, every frame's added up. Null when the page cannot be read. */
|
|
204
|
+
export async function readSound(page, { timeoutMs = 1500 } = {}) {
|
|
205
|
+
let frames;
|
|
206
|
+
try { frames = page.frames(); } catch { return null; }
|
|
207
|
+
const within = p => Promise.race([p, new Promise(r => setTimeout(() => r(null), timeoutMs))]);
|
|
208
|
+
const reads = (await Promise.all(frames.map(f => within(f.evaluate(() => (window.__rsSound ? window.__rsSound.read() : null)).catch(() => null))))).filter(Boolean);
|
|
209
|
+
if (!reads.length) return null;
|
|
210
|
+
const sum = { contexts: 0, running: 0, suspended: 0, everRunning: false, elements: 0, totals: { starts: 0, plays: 0, loudMs: 0, mediaMs: 0, peak: 0, blocked: 0 }, since: { starts: 0, plays: 0, loudMs: 0, mediaMs: 0, peak: 0, blocked: 0, errors: 0 }, errors: [] };
|
|
211
|
+
for (const r of reads) {
|
|
212
|
+
sum.contexts += r.contexts; sum.running += r.running; sum.suspended += r.suspended; sum.elements += r.elements;
|
|
213
|
+
sum.everRunning = sum.everRunning || Boolean(r.everRunning);
|
|
214
|
+
for (const k of ['starts', 'plays', 'loudMs', 'mediaMs', 'blocked']) { sum.totals[k] += Number(r.totals?.[k]) || 0; sum.since[k] += Number(r.since?.[k]) || 0; }
|
|
215
|
+
sum.since.errors += Number(r.since?.errors) || 0;
|
|
216
|
+
sum.totals.peak = Math.max(sum.totals.peak, Number(r.totals?.peak) || 0);
|
|
217
|
+
sum.since.peak = Math.max(sum.since.peak, Number(r.since?.peak) || 0);
|
|
218
|
+
for (const e of Array.isArray(r.errors) ? r.errors : []) if (sum.errors.length < MAX_ERRORS) sum.errors.push({ kind: String(e?.kind || 'audio').slice(0, 20), message: String(e?.message || '').slice(0, 120) });
|
|
219
|
+
}
|
|
220
|
+
return sum;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const dbfs = peak => (peak > 0 ? Math.round(20 * Math.log10(peak)) : null);
|
|
224
|
+
const plural = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
|
|
225
|
+
const list = (steps, n = 8) => `${steps.slice(0, n).join(', ')}${steps.length > n ? ` and ${steps.length - n} more` : ''}`;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* The run's sound record. `add(step, sample, { input })` takes the page's
|
|
229
|
+
* read after a step; `expect(step, why)` marks a step whose result a player
|
|
230
|
+
* would expect to hear. `selfTest` is soundSelfTest's answer (null: not run).
|
|
231
|
+
*/
|
|
232
|
+
export function createSoundLog({ selfTest = null } = {}) {
|
|
233
|
+
const steps = [];
|
|
234
|
+
const expected = new Map();
|
|
235
|
+
let last = null, inputs = 0, unread = 0;
|
|
236
|
+
|
|
237
|
+
function add(step, sample, { input = true, changed = null } = {}) {
|
|
238
|
+
if (input) inputs++;
|
|
239
|
+
if (!sample) { unread++; return null; }
|
|
240
|
+
last = sample;
|
|
241
|
+
const heard = sample.since.loudMs > 0 || sample.since.mediaMs > 0;
|
|
242
|
+
const row = { step, starts: sample.since.starts + sample.since.plays, loudMs: sample.since.loudMs, mediaMs: sample.since.mediaMs, peak: sample.since.peak, heard, changed };
|
|
243
|
+
steps.push(row);
|
|
244
|
+
if (steps.length > 6000) steps.shift();
|
|
245
|
+
return row;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function expect(step, why = 'the planner expected a sound') { if (Number.isSafeInteger(step) && !expected.has(step)) expected.set(step, String(why).slice(0, 80)); }
|
|
249
|
+
|
|
250
|
+
function summary() {
|
|
251
|
+
const available = selfTest ? selfTest.ok === true : null;
|
|
252
|
+
const heardSteps = steps.filter(s => s.heard).map(s => s.step);
|
|
253
|
+
const startSteps = steps.filter(s => s.starts > 0).map(s => s.step);
|
|
254
|
+
const t = last?.totals || { starts: 0, plays: 0, loudMs: 0, mediaMs: 0, peak: 0, blocked: 0 };
|
|
255
|
+
const madeAudio = Boolean(last && (last.contexts > 0 || last.elements > 0 || t.starts > 0 || t.plays > 0));
|
|
256
|
+
// Sound in every step from some step to the end of play.
|
|
257
|
+
let tail = 0;
|
|
258
|
+
for (let i = steps.length - 1; i >= 0 && steps[i].heard; i--) tail++;
|
|
259
|
+
// A moment a sound was expected is silent when no sound was STARTED in its step. A level measured then
|
|
260
|
+
// may be the tail of an earlier sound (or music that plays throughout), so the level never clears it;
|
|
261
|
+
// and a sound the game starts late lands in the next step, so a start there leaves the moment undecided
|
|
262
|
+
// rather than called silent.
|
|
263
|
+
const rows = new Map(steps.map((s, i) => [s.step, i]));
|
|
264
|
+
const marked = heardSteps.length >= HEARD_STEPS_MIN ? [...expected.entries()].filter(([step]) => rows.has(step) && steps[rows.get(step)].starts === 0) : [];
|
|
265
|
+
const lateStart = step => { const next = steps[rows.get(step) + 1]; return Boolean(next && next.starts > 0); };
|
|
266
|
+
const silentExpected = marked.filter(([step]) => !lateStart(step)).map(([step, why]) => ({ step, why }));
|
|
267
|
+
const undecidedExpected = marked.filter(([step]) => lateStart(step)).map(([step, why]) => ({ step, why }));
|
|
268
|
+
return {
|
|
269
|
+
available, selfTest: selfTest ? { ok: selfTest.ok, state: selfTest.state, peak: selfTest.peak, why: selfTest.why || null } : null,
|
|
270
|
+
measuredSteps: steps.length, lastStep: steps.at(-1)?.step ?? 0, unreadSteps: unread, inputs,
|
|
271
|
+
madeAudio, contexts: last?.contexts || 0, elements: last?.elements || 0, everRunning: Boolean(last?.everRunning),
|
|
272
|
+
suspendedAtEnd: last?.suspended || 0,
|
|
273
|
+
soundsStarted: t.starts + t.plays, heardMs: t.loudMs + t.mediaMs, heardSteps: heardSteps.length, firstHeardStep: heardSteps[0] ?? null, lastHeardStep: heardSteps.at(-1) ?? null,
|
|
274
|
+
firstStartStep: startSteps[0] ?? null,
|
|
275
|
+
peak: Math.round((t.peak || 0) * 1000) / 1000, peakDb: dbfs(t.peak || 0), levelMeasured: t.loudMs > 0, elementOnly: t.loudMs === 0 && t.mediaMs > 0,
|
|
276
|
+
blocked: t.blocked || 0, errors: (last?.errors || []).slice(0, MAX_ERRORS),
|
|
277
|
+
continuousFromStep: tail >= CONTINUOUS_MIN && tail < steps.length ? steps[steps.length - tail].step : tail >= CONTINUOUS_MIN ? steps[0].step : null,
|
|
278
|
+
neverStopped: tail >= CONTINUOUS_MIN && tail === steps.length,
|
|
279
|
+
expectedSteps: expected.size, silentExpected, undecidedExpected,
|
|
280
|
+
inputsWithSound: steps.filter(s => s.starts > 0 || s.heard).length
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
return { add, expect, summary, get steps() { return steps; } };
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// What every sound statement carries.
|
|
288
|
+
export const SOUND_LIMIT = 'This is measured from the browser\'s audio graph (which sounds were started, and the level at the output). The playtester does not hear the game and does not judge how the sound feels, whether it fits, or whether it is the right sound.';
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* What the sound record says, for the report: `facts` (sentences for the
|
|
292
|
+
* Sound section), `findings` (evidence about the game, each stating the
|
|
293
|
+
* limit) and `notCovered` (what could not be checked). `shotFor(step)` gives a
|
|
294
|
+
* screenshot path for a step. With no working self test nothing is a finding.
|
|
295
|
+
*/
|
|
296
|
+
export function soundReport(s, { shotFor = () => null, reproFor = () => [] } = {}) {
|
|
297
|
+
const facts = [], findings = [], notCovered = [];
|
|
298
|
+
if (!s) return { facts, findings, notCovered };
|
|
299
|
+
if (s.available !== true) {
|
|
300
|
+
notCovered.push(`Sound was not checked: ${s.selfTest?.why || 'the audio self test did not run'}. Whether the game plays sound, and where it is silent, was not tested.`);
|
|
301
|
+
return { facts, findings, notCovered };
|
|
302
|
+
}
|
|
303
|
+
if (!s.measuredSteps) {
|
|
304
|
+
notCovered.push('Sound was not checked: the game\'s page could not be read for its audio after any step.');
|
|
305
|
+
return { facts, findings, notCovered };
|
|
306
|
+
}
|
|
307
|
+
const evidence = step => { const ref = shotFor(step); return ref ? [{ type: 'screenshot', ref }] : []; };
|
|
308
|
+
const finding = (f, step) => { const ev = evidence(step); if (ev.length) findings.push({ ...f, title: noDashes(f.title).slice(0, 120), description: noDashes(`${f.description} ${SOUND_LIMIT}`), repro_steps: reproFor(step), evidence: ev, step }); else facts.push(`${f.title}. ${f.description}`); };
|
|
309
|
+
const lastStep = s.lastStep;
|
|
310
|
+
|
|
311
|
+
if (!s.madeAudio) {
|
|
312
|
+
facts.push(`The game made no sound in this run: over ${plural(s.measuredSteps, 'step')} and ${plural(s.inputs, 'input')} it never created an audio context, started a sound or played an audio element.`);
|
|
313
|
+
finding({ severity: 'minor', category: 'content', title: 'No sound was played at any point in this run', description: `Across ${plural(s.inputs, 'input')} the game never created an audio context and never played an audio element, so a player would hear nothing: no music, no effect on any input. If the game has sound behind a setting this run did not turn on, or later than this run reached, this does not apply.` }, lastStep);
|
|
314
|
+
} else if (s.heardSteps === 0) {
|
|
315
|
+
if (s.contexts > 0 && !s.everRunning && s.inputs >= UNLOCK_INPUTS_MIN) {
|
|
316
|
+
facts.push(`The game created ${plural(s.contexts, 'audio context')}, and none of them ever ran: after ${plural(s.inputs, 'input')} they were still suspended, so nothing could be heard.`);
|
|
317
|
+
finding({ severity: 'minor', category: 'bug', title: 'The game\'s audio never started', description: `The game created ${plural(s.contexts, 'audio context')} that stayed suspended through ${plural(s.inputs, 'input')}. A browser holds audio until the player's first input, and a game resumes its audio on that input; this one did not, so its ${plural(s.soundsStarted, 'started sound')} could not be heard.` }, lastStep);
|
|
318
|
+
} else if (s.soundsStarted > 0) {
|
|
319
|
+
facts.push(`The game started ${plural(s.soundsStarted, 'sound')}, and the output stayed silent in every measured step (peak level ${s.peakDb === null ? 'zero' : `${s.peakDb} dBFS`}).`);
|
|
320
|
+
finding({ severity: 'minor', category: 'bug', title: 'Sounds were started but nothing reached the output', description: `The game started ${plural(s.soundsStarted, 'sound')} (first at step ${s.firstStartStep ?? 0}), and the level at the audio output never rose above silence. A volume left at zero, a muted default or sound files that are silent would each do this.` }, s.firstStartStep ?? lastStep);
|
|
321
|
+
} else facts.push(`The game set up audio (${plural(s.contexts, 'audio context')}, ${plural(s.elements, 'audio element')}) and never started a sound in this run.`);
|
|
322
|
+
} else {
|
|
323
|
+
facts.push(`The game plays sound: it was measured in ${s.heardSteps} of ${plural(s.measuredSteps, 'step')}, first at step ${s.firstHeardStep}, with ${plural(s.soundsStarted, 'sound')} started${s.levelMeasured ? ` and a peak level of ${s.peakDb} dBFS` : ''}.${s.elementOnly ? ' It plays through audio elements, whose level is not measured, only that they were playing.' : ''}`);
|
|
324
|
+
if (s.neverStopped || s.continuousFromStep !== null) facts.push(`Sound was present in every measured step from step ${s.continuousFromStep} to the end of play (music or a loop that does not pause). Whether that is meant is for the studio to say.`);
|
|
325
|
+
if (s.undecidedExpected?.length) facts.push(`At ${plural(s.undecidedExpected.length, 'moment')} where a sound would be expected (${s.undecidedExpected.length === 1 ? 'step' : 'steps'} ${list(s.undecidedExpected.map(x => x.step))}) none was started in that step and one was started in the next, so it may have come late: not counted as silent.`);
|
|
326
|
+
if (s.silentExpected.length) {
|
|
327
|
+
const steps = s.silentExpected.map(x => x.step);
|
|
328
|
+
facts.push(`At ${plural(steps.length, 'moment')} where a sound would be expected, no sound was started, in that step or the next: ${plural(steps.length, 'step')} ${list(steps)}.`);
|
|
329
|
+
finding({ severity: 'minor', category: 'ux', title: `No sound at ${plural(steps.length, 'moment')} where a player would expect one`, description: `The game does play sound (measured in ${s.heardSteps} steps), but at ${steps.length === 1 ? 'step' : 'steps'} ${list(steps)} no sound was started, in that step or the one after (${s.silentExpected.slice(0, 3).map(x => `step ${x.step}: ${x.why}`).join('; ')}). Which moments should sound is the playtester's expectation, marked before each input was played.` }, steps[0]);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
if (s.blocked > 0) facts.push(`The browser refused to start an audio element ${plural(s.blocked, 'time')} because the page had not yet had a player's input. That is the browser's rule, not a fault of the game, unless the sound was meant to follow an input.`);
|
|
333
|
+
if (s.errors.length) {
|
|
334
|
+
const kinds = { context: 'an audio context could not be created', decode: 'audio data could not be decoded', element: 'an audio element could not play', load: 'an audio file could not be loaded' };
|
|
335
|
+
const said = [...new Set(s.errors.map(e => kinds[e.kind] || 'an audio error'))];
|
|
336
|
+
facts.push(`Audio errors: ${said.join('; ')} (${plural(s.errors.length, 'error')}).`);
|
|
337
|
+
finding({ severity: 'minor', category: 'bug', title: 'The game\'s audio raised errors', description: `${plural(s.errors.length, 'audio error')} during play: ${said.join('; ')}${s.errors[0].message ? ` (first: "${noDashes(s.errors[0].message).replace(/"/g, "'")}")` : ''}. A sound that fails to load or decode is one the player never hears.` }, lastStep);
|
|
338
|
+
}
|
|
339
|
+
if (s.unreadSteps) notCovered.push(`The page's audio could not be read after ${plural(s.unreadSteps, 'step')}, so sound in those steps is not counted.`);
|
|
340
|
+
notCovered.push('How the game sounds was not judged: the run measures whether sound played and at what level, not its quality, its mix or whether it suits the moment.');
|
|
341
|
+
return { facts: facts.map(noDashes), findings, notCovered: notCovered.map(noDashes) };
|
|
342
|
+
}
|
package/src/run/args.js
CHANGED
|
@@ -29,20 +29,46 @@ const VALUED = new Map([
|
|
|
29
29
|
['--max-actions', 'maxActions'],
|
|
30
30
|
['--concurrency', 'concurrency'],
|
|
31
31
|
['--quality', 'quality'],
|
|
32
|
-
['--key-modifier', 'keyModifier']
|
|
32
|
+
['--key-modifier', 'keyModifier'],
|
|
33
|
+
// A cloud tier's allowance for a local run, its play length, and where a web build opens.
|
|
34
|
+
['--tier', 'tier'],
|
|
35
|
+
['--minutes', 'minutes'],
|
|
36
|
+
['--start', 'start']
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
/** Options that may be given several times; each value is kept, in order. */
|
|
40
|
+
const REPEATED = new Map([
|
|
41
|
+
['--focus', 'focus'],
|
|
42
|
+
['--avoid', 'avoid']
|
|
33
43
|
]);
|
|
34
44
|
|
|
35
45
|
/** Options that are just present or absent. */
|
|
36
46
|
const BOOLEAN = new Map([
|
|
37
47
|
['--upload-video', 'uploadVideo'],
|
|
38
48
|
['--record-video', 'recordVideo'],
|
|
49
|
+
// A local web or Godot run keeps a video on this machine by default.
|
|
50
|
+
['--no-record-video', 'noRecordVideo'],
|
|
51
|
+
// The scripted edge behaviour checks after play (focus loss, resize, rapid
|
|
52
|
+
// input, a short idle, a reload) are on by default on playwright_web.
|
|
53
|
+
['--no-edge-pass', 'noEdgePass'],
|
|
54
|
+
// playwright_web only: a phone sized screen played with touch (taps, finger
|
|
55
|
+
// drags, a two finger pinch) and no mouse.
|
|
56
|
+
['--phone', 'phone'],
|
|
57
|
+
// The older name for --upload-step-log; both send the step log whatever the project config says.
|
|
39
58
|
['--upload-transcript', 'uploadTranscript'],
|
|
59
|
+
['--upload-step-log', 'uploadTranscript'],
|
|
60
|
+
// The step log (transcript.jsonl) uploads with a persona run by default, so the
|
|
61
|
+
// run gets its evidence report in the dashboard; this keeps it on this machine.
|
|
62
|
+
['--no-upload-step-log', 'noUploadStepLog'],
|
|
63
|
+
// After the report, a Godot lockstep run and a web run play their findings'
|
|
64
|
+
// recorded inputs again with no model to see whether they reproduce; this skips that.
|
|
65
|
+
['--no-replay', 'noReplay'],
|
|
40
66
|
['--dry-upload', 'dryUpload'],
|
|
41
67
|
['--offline-upload', 'offlineUpload'],
|
|
42
68
|
['--headed', 'headed'],
|
|
43
69
|
['--headless', 'headless'],
|
|
44
70
|
['--verbose', 'verbose'],
|
|
45
|
-
// A long persona run: twice the actions
|
|
71
|
+
// A long persona run: twice the actions and wall time and a larger model budget than a
|
|
46
72
|
// standard run, priced by the server as its own unit.
|
|
47
73
|
['--long', 'long'],
|
|
48
74
|
// godot_driver only: let the game run in real time between actions instead
|
|
@@ -67,7 +93,7 @@ const BOOLEAN = new Map([
|
|
|
67
93
|
]);
|
|
68
94
|
|
|
69
95
|
/** Options whose value is a number. */
|
|
70
|
-
const NUMERIC = new Set(['maxActions', 'concurrency']);
|
|
96
|
+
const NUMERIC = new Set(['maxActions', 'concurrency', 'minutes']);
|
|
71
97
|
|
|
72
98
|
/**
|
|
73
99
|
* @param {string[]} argv the leftovers commander handed over
|
|
@@ -87,6 +113,14 @@ export function parseRunArgv(argv = []) {
|
|
|
87
113
|
options[BOOLEAN.get(name)] = inline === null ? true : inline !== 'false';
|
|
88
114
|
continue;
|
|
89
115
|
}
|
|
116
|
+
if (REPEATED.has(name)) {
|
|
117
|
+
const raw = inline === null ? argv[i + 1] : inline;
|
|
118
|
+
if (inline === null) i += 1;
|
|
119
|
+
if (raw === undefined) { unknown.push(`${name} needs a value`); continue; }
|
|
120
|
+
const key = REPEATED.get(name);
|
|
121
|
+
options[key] = [...(options[key] || []), String(raw)];
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
90
124
|
if (VALUED.has(name)) {
|
|
91
125
|
const key = VALUED.get(name);
|
|
92
126
|
const raw = inline === null ? argv[i + 1] : inline;
|
|
@@ -153,21 +187,54 @@ export function optionsFrom(flags = {}) {
|
|
|
153
187
|
};
|
|
154
188
|
}
|
|
155
189
|
|
|
156
|
-
/** The two run lengths the server prices: `standard`, and `long` at
|
|
190
|
+
/** The two fixed run lengths the server prices: `standard`, and `long` at its own, higher price. */
|
|
157
191
|
export const RUN_LENGTHS = Object.freeze(['standard', 'long']);
|
|
192
|
+
/** The cloud tiers a local run may be sold on (`--tier`), each with its own allowance. */
|
|
193
|
+
export const TIERS = Object.freeze(['jam', 'small', 'medium', 'large']);
|
|
158
194
|
|
|
159
195
|
/**
|
|
160
|
-
* `long`
|
|
196
|
+
* The run length the server prices: `long` with `--long`, a tier length
|
|
197
|
+
* (`tier:<tier>` or `tier:<tier>:<minutes>`) with `--tier`, otherwise
|
|
198
|
+
* `standard`. The server knows each tier's own length and bounds the minutes.
|
|
161
199
|
*
|
|
162
|
-
* @param {{long?: boolean}} options
|
|
163
|
-
* @returns {
|
|
200
|
+
* @param {{long?: boolean, tier?: string, minutes?: number}} options
|
|
201
|
+
* @returns {string}
|
|
164
202
|
*/
|
|
165
203
|
export function runLengthFor(options = {}) {
|
|
204
|
+
if (TIERS.includes(options.tier)) return Number.isSafeInteger(options.minutes) && options.minutes > 0 ? `tier:${options.tier}:${options.minutes}` : `tier:${options.tier}`;
|
|
166
205
|
return options.long === true ? 'long' : 'standard';
|
|
167
206
|
}
|
|
168
207
|
|
|
208
|
+
/** True for a run length that names a cloud tier. */
|
|
209
|
+
export const isTierLength = value => typeof value === 'string' && /^tier:(jam|small|medium|large)(:[1-9][0-9]{0,2})?$/.test(value);
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* What is wrong with --tier, --minutes, --focus, --avoid and --start, one
|
|
213
|
+
* sentence each, before anything is priced. Empty when they are fine.
|
|
214
|
+
*
|
|
215
|
+
* @param {Object} options
|
|
216
|
+
* @param {string} driverName
|
|
217
|
+
* @returns {string[]}
|
|
218
|
+
*/
|
|
219
|
+
export function scopeProblems(options = {}, driverName = '') {
|
|
220
|
+
const problems = [];
|
|
221
|
+
const plain = value => typeof value === 'string' && value.trim().length > 0 && value.length <= 200 && !/[\u0000-\u001f\u007f]/.test(value);
|
|
222
|
+
if (options.tier !== undefined && !TIERS.includes(options.tier)) problems.push(`Choose --tier from ${TIERS.join(', ')}.`);
|
|
223
|
+
if (options.minutes !== undefined && options.tier === undefined) problems.push('--minutes sets the play length of a tier. Pass --tier too, such as --tier medium --minutes 30.');
|
|
224
|
+
if (options.minutes !== undefined && (!Number.isSafeInteger(options.minutes) || options.minutes < 1 || options.minutes > 999)) problems.push('Choose --minutes as whole minutes, from the tier\'s own length up to 240.');
|
|
225
|
+
if (options.tier !== undefined && options.long === true) problems.push('Pass --tier or --long, not both: a tier has its own length.');
|
|
226
|
+
for (const [name, list] of [['--focus', options.focus], ['--avoid', options.avoid]]) {
|
|
227
|
+
if (list !== undefined && (!Array.isArray(list) || list.length > 5 || !list.every(plain))) problems.push(`Give ${name} at most five times, each plain text of at most 200 characters.`);
|
|
228
|
+
}
|
|
229
|
+
if (options.start !== undefined) {
|
|
230
|
+
if (typeof options.start !== 'string' || !/^[?#][^\s\\]{0,199}$/.test(options.start)) problems.push('Choose --start as a query or hash on the build, such as ?level=3 or #boss.');
|
|
231
|
+
else if (driverName && driverName !== 'playwright_web') problems.push(`--start opens a web build at a query or hash, and this run uses ${driverName}.`);
|
|
232
|
+
}
|
|
233
|
+
return problems;
|
|
234
|
+
}
|
|
235
|
+
|
|
169
236
|
function stripUndefined(value) {
|
|
170
237
|
return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== undefined));
|
|
171
238
|
}
|
|
172
239
|
|
|
173
|
-
export default { parseRunArgv, optionsFrom, unknownOptionNotes, runLengthFor };
|
|
240
|
+
export default { parseRunArgv, optionsFrom, unknownOptionNotes, runLengthFor, scopeProblems, isTierLength };
|