ravensight-playtest 0.13.3 → 0.16.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.
@@ -26,6 +26,12 @@
26
26
  // whether sound played and how loud, never a judgement of how it sounds, and
27
27
  // no finding is made unless a self test showed that this browser can run and
28
28
  // measure an audio graph at all.
29
+ //
30
+ // Sound is evidence, never a finding on its own (docs/playtest/SOUND_AND_LANGUAGES.md):
31
+ // every step is "played" or "silent" (stepSound), the report's Sound section
32
+ // states the measurements, and a finding that says an input gave no feedback
33
+ // is told whether a sound played at its step (soundEvidenceLine). Nothing of
34
+ // the audio itself is kept or sent to a model: counts, a level, played or silent.
29
35
  const noDashes = s => String(s ?? '').replace(/[\u2013\u2014]/g, ',');
30
36
 
31
37
  // The level under which the output counts as silent (linear peak; about -54 dBFS).
@@ -224,6 +230,41 @@ const dbfs = peak => (peak > 0 ? Math.round(20 * Math.log10(peak)) : null);
224
230
  const plural = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
225
231
  const list = (steps, n = 8) => `${steps.slice(0, n).join(', ')}${steps.length > n ? ` and ${steps.length - n} more` : ''}`;
226
232
 
233
+ /** One measured step: 'played' when a sound was started, or the output or an audio element was heard, in it; 'silent' otherwise. */
234
+ export function stepSound(row) {
235
+ if (!row) return null;
236
+ return row.heard || (Number(row.starts) || 0) > 0 ? 'played' : 'silent';
237
+ }
238
+
239
+ /** A step's sound from a `byStep` record (`[[step, 1 | 0], ...]`): 'played', 'silent' or null. */
240
+ export function soundAt(byStep, step) {
241
+ if (!Array.isArray(byStep) || !Number.isSafeInteger(step)) return null;
242
+ for (let i = byStep.length - 1; i >= 0; i--) if (Array.isArray(byStep[i]) && byStep[i][0] === step) return byStep[i][1] ? 'played' : 'silent';
243
+ return null;
244
+ }
245
+
246
+ // A finding that says an input gave the player no feedback, no response, or that nothing happened: in English,
247
+ // Spanish, Japanese and Russian (and a few more). Whether a sound played at its step is the evidence it lacks.
248
+ export const FEEDBACK_CLAIM = new RegExp([
249
+ "\\bno (?:visible |audible |clear )?(?:feedback|response|reaction|confirmation|indication)\\b", "\\bnothing (?:happen\\w*|changed|responded)\\b", "\\b(?:did|does|do)(?: not|n't) (?:respond|react|register|seem to (?:respond|register|work))\\b", "\\b(?:unresponsive|(?:stopped|stops|not) responding|changed nothing)\\b", "\\bwithout (?:any )?(?:feedback|response)\\b",
250
+ "(?<![\\p{L}])(?:sin (?:respuesta|reacción|retroalimentación|feedback|confirmación)|no (?:pasa|ocurre|sucede) nada|no (?:hay|da|tiene) (?:respuesta|reacción|retroalimentación|feedback)|no responde|no reacciona)(?![\\p{L}])",
251
+ "反応(?:が|は)?(?:ない|無い|なし|しない|しません|ありません)", "何も(?:起こら|起き|変わら)", "フィードバック(?:が|は)?(?:ない|無い|なし|ありません)", "無反応",
252
+ "(?<![\\p{L}])(?:нет (?:реакции|отклика|ответа|обратной связи)|ничего не (?:происходит|произошло|меняется|изменилось)|не (?:реагирует|отвечает|откликается)|без (?:реакции|отклика))(?![\\p{L}])",
253
+ "没有(?:反应|反馈)", "沒有(?:反應|回饋)", "반응이 없", "aucune (?:réaction|réponse)", "keine (?:reaktion|rückmeldung)", "nessuna (?:reazione|risposta)", "sem (?:resposta|reação|feedback)"
254
+ ].join('|'), 'iu');
255
+
256
+ /**
257
+ * The sentence a finding about missing feedback gets from its step's sound: whether sound was the feedback. Never
258
+ * a finding of its own, never a judgement of the sound. '' when the step has no sound record.
259
+ */
260
+ export function soundEvidenceLine(state, step) {
261
+ if (state !== 'played' && state !== 'silent') return '';
262
+ const at = Number.isSafeInteger(step) ? `at step ${step}` : 'at that moment';
263
+ return state === 'played'
264
+ ? `Sound ${at}: the game started or played a sound (measured from its audio, not heard), so the feedback may have been sound alone.`
265
+ : `Sound ${at}: no sound was started or heard (measured from its audio, not heard), so sound was not the feedback either.`;
266
+ }
267
+
227
268
  /**
228
269
  * The run's sound record. `add(step, sample, { input })` takes the page's
229
270
  * read after a step; `expect(step, why)` marks a step whose result a player
@@ -245,6 +286,15 @@ export function createSoundLog({ selfTest = null } = {}) {
245
286
  return row;
246
287
  }
247
288
 
289
+ /** A step's sound as measured: 'played', 'silent', or null when it was not read. */
290
+ function at(step) {
291
+ for (let i = steps.length - 1; i >= 0; i--) if (steps[i].step === step) return stepSound(steps[i]);
292
+ return null;
293
+ }
294
+
295
+ /** Every measured step as `[step, 1 | 0]` (played, silent), for a record that keeps it. */
296
+ function byStep() { return steps.map(r => [r.step, stepSound(r) === 'played' ? 1 : 0]); }
297
+
248
298
  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
299
 
250
300
  function summary() {
@@ -281,7 +331,7 @@ export function createSoundLog({ selfTest = null } = {}) {
281
331
  };
282
332
  }
283
333
 
284
- return { add, expect, summary, get steps() { return steps; } };
334
+ return { add, expect, summary, at, byStep, get steps() { return steps; } };
285
335
  }
286
336
 
287
337
  // What every sound statement carries.
@@ -289,11 +339,12 @@ export const SOUND_LIMIT = 'This is measured from the browser\'s audio graph (wh
289
339
 
290
340
  /**
291
341
  * 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.
342
+ * Sound section) and `notCovered` (what could not be checked). `findings` is
343
+ * always empty: sound is evidence for the report and for other findings
344
+ * (soundEvidenceLine), never a finding on its own. With no working self test
345
+ * nothing is said about the game's sound.
295
346
  */
296
- export function soundReport(s, { shotFor = () => null, reproFor = () => [] } = {}) {
347
+ export function soundReport(s) {
297
348
  const facts = [], findings = [], notCovered = [];
298
349
  if (!s) return { facts, findings, notCovered };
299
350
  if (s.available !== true) {
@@ -304,20 +355,14 @@ export function soundReport(s, { shotFor = () => null, reproFor = () => [] } = {
304
355
  notCovered.push('Sound was not checked: the game\'s page could not be read for its audio after any step.');
305
356
  return { facts, findings, notCovered };
306
357
  }
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
358
 
311
359
  if (!s.madeAudio) {
312
360
  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
361
  } else if (s.heardSteps === 0) {
315
362
  if (s.contexts > 0 && !s.everRunning && s.inputs >= UNLOCK_INPUTS_MIN) {
316
363
  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
364
  } 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);
365
+ facts.push(`The game started ${plural(s.soundsStarted, 'sound')} (first at step ${s.firstStartStep ?? 0}), and the output stayed silent in every measured step (peak level ${s.peakDb === null ? 'zero' : `${s.peakDb} dBFS`}). A volume left at zero, a muted default or sound files that are silent would each do this.`);
321
366
  } 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
367
  } else {
323
368
  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.' : ''}`);
@@ -325,16 +370,14 @@ export function soundReport(s, { shotFor = () => null, reproFor = () => [] } = {
325
370
  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
371
  if (s.silentExpected.length) {
327
372
  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]);
373
+ 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)} (${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.`);
330
374
  }
331
375
  }
332
376
  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
377
  if (s.errors.length) {
334
378
  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
379
  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);
380
+ facts.push(`Audio errors: ${said.join('; ')} (${plural(s.errors.length, 'error')})${s.errors[0].message ? `, the first "${noDashes(s.errors[0].message).replace(/"/g, "'")}"` : ''}. A sound that fails to load or decode is one the player never hears.`);
338
381
  }
339
382
  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
383
  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.');
package/src/run/args.js CHANGED
@@ -75,6 +75,8 @@ const BOOLEAN = new Map([
75
75
  // The step log (transcript.jsonl) uploads with a persona run by default, so the
76
76
  // run gets its evidence report in the dashboard; this keeps it on this machine.
77
77
  ['--no-upload-step-log', 'noUploadStepLog'],
78
+ // Send nothing to the job's live view in the dashboard while the run plays (../run/liveFeed.js).
79
+ ['--no-live', 'noLive'],
78
80
  // After the report, a Godot lockstep run and a web run play their findings'
79
81
  // recorded inputs again with no model to see whether they reproduce; this skips that.
80
82
  ['--no-replay', 'noReplay'],
@@ -26,6 +26,15 @@ const LAYOUT = /\b(overlap\w*|cut ?off|cuts off|clipped|clipping|truncat\w+|misa
26
26
  // grid) make the playtester's copy look like: on pt_job_81998fb24333c33ede3b "Instruction text looks like clickable buttons ...
27
27
  // underlined and boxed" was published as an opinion, and the title screen's own frame shows plain text.
28
28
  export const APPEARANCE = /\b(underlin\w*|boxed|outlined|bordered|framed|encircled|circled|highlight(?:ed|ing)?|(?:in|inside|within|with|surrounded by|drawn in) (?:a |an )?(?:box(?:es)?|frames?|borders?|outlines?|rectangles?|highlights?)|(?:styled|drawn|rendered|formatted) (?:like|as) (?:a |an )?\w+|(?:looks?|looked|looking|shown|displayed|resembl(?:es?|ing)) (?:like |as )?(?:a |an )?(?:clickable |interactive |plain |real )?(?:buttons?|links?|hyperlinks?|tabs?|controls?)|colou?red|tinted|shaded|gr[ae]yed|in (?:magenta|pink|purple|blue|cyan|red|green|yellow|bold|italics?)|bold(?:ed)?|italic\w*)\b/i;
29
+ // Whether a claim's words are read by the word rules of this file: they are English, so only a claim in a report written in
30
+ // English is sorted by them (the report's language, lib/anygame/language.mjs reportLanguage; unknown is English, the default).
31
+ // A claim in any other language is sorted only by what the playtester said about it in fields of fixed values (`kind`, `facts`,
32
+ // `taste`, its grade and category), never by its words: an English word list read over Spanish or French text both misses
33
+ // ("se congela") and misfires ("impossible" is French, "no" is Spanish). Such a claim is never given a weaker bar than an English
34
+ // one: a class its fixed fields cannot settle is `stuck`, whose gate needs a watched replay (lib/claims.mjs), and a claim in another
35
+ // language also needs "game at fault" from its frame there, so neither one frame nor one watch publishes it (`claimClass`).
36
+ export const readsEnglish = code => code === null || code === undefined || code === '' || String(code).toLowerCase().slice(0, 2) === 'en';
37
+
29
38
  const UNRELIABLE = /\b((?:sometimes|often|occasionally|randomly|silently|intermittently)( \w+)? fails?|fails? (?:sometimes|silently|randomly|repeatedly|every time|to ))\b/i;
30
39
 
31
40
 
@@ -33,14 +42,20 @@ const UNRELIABLE = /\b((?:sometimes|often|occasionally|randomly|silently|intermi
33
42
  * What kind of claim a judgement makes: `stuck`, `absence`, `difficulty`,
34
43
  * `layout` or `other`. `kind` is the playtester's own word for a notice
35
44
  * (lib/notice.mjs); the words are read in English, so a claim in another
36
- * language is `other` unless its `kind` says difficulty, and passes the
37
- * general rule only. `marked` says the playtester's copy of the picture it
38
- * judged from carried the runner's marks and grid: only then is a judgement
39
- * of how the screen is drawn its own class, `layout`.
45
+ * language (`english: false`, see `readsEnglish`) has its words left alone
46
+ * and is sorted by its fixed fields: `difficulty` when `kind` says so;
47
+ * `other` when it is plainly taste (`kind` clarity or opinion, `taste`
48
+ * true, category balance), which is never a finding; otherwise `stuck`,
49
+ * because it may be a claim that nothing happens, which one frame cannot
50
+ * show: the stuck gate's watched replay is the bar. `marked` says
51
+ * the playtester's copy of the picture it judged from carried the runner's
52
+ * marks and grid: only then is a judgement of how the screen is drawn its
53
+ * own class, `layout`.
40
54
  */
41
- export function claimClass({ title = '', detail = '', kind = null, marked = false } = {}) {
55
+ export function claimClass({ title = '', detail = '', kind = null, marked = false, english = true, taste = null, category = null } = {}) {
42
56
  const t = text(title), d = text(detail);
43
57
  if (kind === 'difficulty') return 'difficulty';
58
+ if (english === false) return kind === 'clarity' || kind === 'opinion' || taste === true || category === 'balance' ? 'other' : 'stuck';
44
59
  // Words of difficulty in the title decide whatever the playtester called it: a notice it filed as a defect is still its own failed play.
45
60
  if (DIFFICULTY.test(t)) return 'difficulty';
46
61
  if (STUCK.test(t)) return 'stuck';
@@ -95,12 +110,19 @@ export function statedFacts({ facts = null, taste = null } = {}) {
95
110
  * its category. With no sign that it is taste, a claim about the game is a
96
111
  * claim of fact: it is held to the frame.
97
112
  */
98
- export function claimBasis({ title = '', detail = '', kind = null, category = null, severity = null, fact = false, facts = null, taste = null } = {}) {
113
+ export function claimBasis({ title = '', detail = '', kind = null, category = null, severity = null, fact = false, facts = null, taste = null, english = true } = {}) {
99
114
  if (fact === true) return 'fact';
100
115
  // The playtester's own statement of the facts a notice rests on, and whether it is a matter of taste (lib/notice.mjs): it decides,
101
116
  // and the word lists below are only the fallback for a claim that came with no facts (an older reply, a look back, a test).
102
117
  const stated = statedFacts({ facts, taste });
103
118
  if (stated) return stated.taste ? 'opinion' : 'fact';
119
+ // A claim in another language: its fixed fields only, in the order below, never its words. With no sign of taste it is a fact.
120
+ if (english === false) {
121
+ if (severity === 'cosmetic' || kind === 'defect') return 'fact';
122
+ if (kind === 'clarity' || kind === 'opinion' || kind === 'difficulty') return 'opinion';
123
+ if (category === 'balance') return 'opinion';
124
+ return 'fact';
125
+ }
104
126
  const t = text(title);
105
127
  // How the words on the screen are set out (TEXT_LAYOUT) is what one frame shows, whatever the playtester called it.
106
128
  if (TEXT_LAYOUT.test(t) || TEXT_LAYOUT.test(text(detail))) return 'fact';
@@ -155,8 +177,14 @@ const COMPLAINT = /\b(but|however|although|though|except|yet|not|no|never|none|n
155
177
  * not a finding at any severity: it goes with what worked (lib/report.mjs).
156
178
  * A mixed sentence ("clear instructions but the timer is hidden") keeps its
157
179
  * complaint, so it is not praise and passes the normal gates.
180
+ *
181
+ * Praise is told by English words, so a claim in another language
182
+ * (`english: false`) is never read as praise: graded as praise it is
183
+ * praise, and graded anything else it takes the normal gates, which publish
184
+ * nothing the claim check did not confirm.
158
185
  */
159
- export function praiseClaim({ title = '', detail = '', why = '' } = {}) {
186
+ export function praiseClaim({ title = '', detail = '', why = '', english = true } = {}) {
187
+ if (english === false) return false;
160
188
  const said = `${text(title)}. ${text(detail)}`;
161
189
  // A judgement of difficulty is the playtester's own play, whatever kind word sits in it ("easy to miss" is not praise).
162
190
  if (COMPLAINT.test(said) || DIFFICULTY.test(said)) return false;
@@ -182,6 +210,12 @@ export const FAULT_QUESTION = 'The claim says the game did something wrong. Is t
182
210
  // the thing missing is a fact, and the question is whether the game is at fault for it.
183
211
  export const ABSENCE_FAULT = 'The claim says something is missing from the screen. Look for that thing in this frame. Answer "shows the opposite" if the thing is visible in the frame (the claim is wrong). Answer "as designed" if the frame shows why it is not there as the game means it: a message that explains it (such as "Too far" or "Moved"), or the plain effect of the playtester\'s own input; after "as designed:" quote that message, at most 10 words, when there is one. Answer "game at fault" only if the frame shows the game without that thing where it should be shown. Answer "cannot tell" if the frame does not settle it.';
184
212
 
213
+ // A claim in another language was not sorted by the word rules (`readsEnglish`): what they tell apart in English (that something comes
214
+ // back again and again, that something is missing, a judgement of the playtester's own play, a claim about the tester's own marks) is
215
+ // told to the check, which reads the claim in its own language. Each case that one frame cannot settle is answered "cannot tell",
216
+ // which confirms nothing (lib/claims.mjs). A claim that nothing happens is held in code, not here: its class is `stuck` (`claimClass`).
217
+ export const UNSORTED = 'The claim is not written in English, and the testing tool sorts claims by English words only, so read it yourself first. If it says something happens every time, always, or again and again, answer "cannot tell": one frame cannot show how often. If it says the playtester found something too hard, too fast or failed to do it, answer "cannot tell": one frame cannot show what a player could do. If it says something is missing, look for that thing in this frame and answer "shows the opposite" if it is there. If what it describes could only be boxes, labels or a grid drawn over the picture by the testing tool, answer "shows the opposite".';
218
+
185
219
  /** The claim as the check reads it: severity, title, description, and expected against actual when the run recorded them. */
186
220
  export function claimText(finding, moment = {}) {
187
221
  const lines = [`Claim (${finding.severity}): ${clip(finding.title, 160)}`, clip(finding.description, 1200)];
@@ -193,6 +227,8 @@ export function claimText(finding, moment = {}) {
193
227
  if (finding.beforeInput === true) lines.push('The claim is about the moment BEFORE an input. This frame is the screen just before that input; what the game showed after the input is not in it and does not settle the claim.');
194
228
  if (moment.expected) lines.push(`Expected before the input: ${moment.expected}`);
195
229
  if (moment.actual) lines.push(`Measured after the input: ${moment.actual}`);
230
+ // A claim the word rules did not sort (`moment.english` false): the check is told what they would have told apart.
231
+ if (moment.english === false) lines.push('', UNSORTED);
196
232
  // A claim that something is missing is asked about the thing itself: a frame "not contradicting" it is not the thing being absent.
197
233
  if (moment.cls === 'absence' && moment.fault) lines.push('', ABSENCE_FAULT);
198
234
  else if (moment.cls === 'absence') lines.push('', 'The claim says something is missing from the screen. Look for that thing in this frame. Answer "shows the opposite" if the thing is visible in the frame (the claim is wrong), "shows it" only if the frame clearly shows the game without that thing, "cannot tell" if the frame does not settle it.');
@@ -0,0 +1,96 @@
1
+ // Where a Godot game reads the mouse position itself, instead of waiting for
2
+ // mouse events. In a lockstep run the addon (1.7.0) keeps the run's own pointer
3
+ // in Input (its buttons and its speed) and lets no desktop mouse event reach a
4
+ // node, but a viewport's get_mouse_position and a node's
5
+ // get_global_mouse_position read the desktop's pointer inside the engine, which
6
+ // no addon can change without moving that pointer, and the runner never moves
7
+ // it. So the run names those reads: a replay that differs there may differ
8
+ // because someone moved the mouse, not because of the game.
9
+ import fs from 'node:fs/promises';
10
+ import path from 'node:path';
11
+
12
+ /** What a reader is told about a game that reads the cursor itself. */
13
+ export const CURSOR_NOTE = 'This game reads the mouse position itself. In a lockstep run, Input\'s pointer is the run\'s own, but a viewport\'s get_mouse_position and a node\'s get_global_mouse_position in the game window read the desktop\'s pointer, which the runner never moves, so a state that depends on them can differ between runs.';
14
+
15
+ // The engine's own calls that answer the desktop's pointer, in GDScript and C#.
16
+ export const CURSOR_CALLS = Object.freeze([
17
+ 'get_global_mouse_position', 'get_local_mouse_position', 'get_mouse_position', 'mouse_get_position',
18
+ 'GetGlobalMousePosition', 'GetLocalMousePosition', 'GetMousePosition', 'MouseGetPosition',
19
+ ]);
20
+ const PATTERN = new RegExp(`\\b(${CURSOR_CALLS.join('|')})\\s*\\(`);
21
+ const SKIP_DIRS = new Set(['.godot', '.import', '.git', 'node_modules', '.ravensight', 'build', 'bin', 'obj']);
22
+ const MAX_FILES = 2000;
23
+ const MAX_FILE_BYTES = 512 * 1024;
24
+
25
+ /**
26
+ * The reads, in file order, at most `limit`.
27
+ *
28
+ * @param {string} projectDir
29
+ * @param {{limit?: number}} [options]
30
+ * @returns {Promise<Array<{file: string, line: number, call: string}>>}
31
+ */
32
+ export async function cursorReads(projectDir, { limit = 10 } = {}) {
33
+ const files = [];
34
+ const walk = async (dir) => {
35
+ let entries;
36
+ try { entries = await fs.readdir(dir, { withFileTypes: true }); } catch { return; }
37
+ entries.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
38
+ for (const entry of entries) {
39
+ if (files.length >= MAX_FILES) return;
40
+ const full = path.join(dir, entry.name);
41
+ if (entry.isDirectory()) {
42
+ if (SKIP_DIRS.has(entry.name)) continue;
43
+ // Ravensight's own addons are not the game.
44
+ if (path.basename(dir) === 'addons' && entry.name.startsWith('ravensight')) continue;
45
+ await walk(full);
46
+ } else if (entry.isFile() && /\.(gd|cs)$/.test(entry.name)) files.push(full);
47
+ }
48
+ };
49
+ await walk(projectDir);
50
+ const out = [];
51
+ for (const file of files) {
52
+ let text;
53
+ try {
54
+ const stat = await fs.stat(file);
55
+ if (stat.size > MAX_FILE_BYTES) continue;
56
+ text = await fs.readFile(file, 'utf8');
57
+ } catch { continue; }
58
+ const lines = text.split('\n');
59
+ for (let i = 0; i < lines.length; i += 1) {
60
+ // A comment is no read: the code before it is what runs.
61
+ const code = lines[i].replace(file.endsWith('.cs') ? /\/\/.*$/ : /#.*$/, '');
62
+ const hit = PATTERN.exec(code);
63
+ if (!hit) continue;
64
+ out.push({ file: `res://${path.relative(projectDir, file).split(path.sep).join('/')}`, line: i + 1, call: hit[1] });
65
+ if (out.length >= limit) return out;
66
+ }
67
+ }
68
+ return out;
69
+ }
70
+
71
+ const RES_PATH = /^res:\/\/[\w./ -]{1,200}$/;
72
+
73
+ /**
74
+ * Cursor reads as a trace header carries them, kept only in their own shape: a
75
+ * trace is a file on disk, and a game or anyone who changed it could put any
76
+ * text there, which a replay result would carry to a report or a model. Plain
77
+ * objects only, at most `limit`; `file` a res:// path, `line` a positive whole
78
+ * number (an entry with either wrong is dropped), `call` one of CURSOR_CALLS or
79
+ * "unknown"; no other field is copied.
80
+ *
81
+ * @param {unknown} reads
82
+ * @returns {Array<{file: string, line: number, call: string}>}
83
+ */
84
+ export function cleanCursorReads(reads, { limit = 10 } = {}) {
85
+ if (!Array.isArray(reads)) return [];
86
+ const out = [];
87
+ for (const read of reads) {
88
+ if (out.length >= limit) break;
89
+ if (!read || typeof read !== 'object' || Array.isArray(read) || Object.getPrototypeOf(read) !== Object.prototype) continue;
90
+ const { file, line, call } = read;
91
+ if (typeof file !== 'string' || !RES_PATH.test(file)) continue;
92
+ if (!Number.isSafeInteger(line) || line < 1) continue;
93
+ out.push({ file, line, call: CURSOR_CALLS.includes(call) ? call : 'unknown' });
94
+ }
95
+ return out;
96
+ }
@@ -14,12 +14,18 @@ export const MAX_TEXT_CHARS = 12000;
14
14
  /** Shown only when a node has three coordinates, so a 2D observation never changes. */
15
15
  export const NOTE_3D = 'note: this scene is 3D. @(x,y,z) is a world position, not a place on the screen: to click one of those nodes, name its path, and never pass its numbers as x and y. Keys and input actions move the player.';
16
16
 
17
- const PRESSABLE = /Button|LineEdit|TextEdit|Slider|CheckBox|CheckButton|OptionButton|ItemList|Tree/;
17
+ const PRESSABLE = /Button|LineEdit|TextEdit|Slider|CheckBox|CheckButton|OptionButton|ItemList|Tree|TabBar|PopupMenu/;
18
18
 
19
19
  /**
20
20
  * How to read and click the outline, shown once at its head when it has a
21
21
  * Control with a size. Every word of it is about this runner, not the game.
22
22
  */
23
+ /**
24
+ * Shown when a menu is open (addon 1.6.0): its items are not nodes, so the
25
+ * outline says how one is chosen.
26
+ */
27
+ export const NOTE_MENU = 'note: a menu is open ([open menu]). Choose one of its options by clicking the option\'s text, or with select on the menu or on the button that opened it. A click anywhere else usually closes it. An item marked (submenu) opens a further menu: click it, or select the whole path, such as "Export > PNG".';
28
+
23
29
  export const NOTE_CLICK = 'note: WxH is a control\'s size, centre(x,y) is where a click on it lands. Click a node by its path, its name or its visible text when only one node has it, or by x and y. A name with slashes passes through containers that hold nothing else.';
24
30
 
25
31
  /** Container types that only lay out their children. */
@@ -52,6 +58,7 @@ export function buildObservation({
52
58
  if (state?.truncated) lines.push('note: the scene tree was truncated');
53
59
  if (kept && hasPosition3d(kept)) lines.push(NOTE_3D);
54
60
  if (kept && hasSizedControl(kept)) lines.push(NOTE_CLICK);
61
+ if (kept && hasOpenMenu(kept)) lines.push(NOTE_MENU);
55
62
  if (lines.length > 0) lines.push('');
56
63
 
57
64
  if (kept) {
@@ -140,7 +147,17 @@ export function needsVision(observation, { minChars = 200 } = {}) {
140
147
 
141
148
  /** True when the node or anything kept under it carries visible text. */
142
149
  function hasText(node) {
143
- return Boolean(node.text) || Boolean(node.label) || (node.children ?? []).some(hasText);
150
+ return Boolean(node.text) || Boolean(node.label) || hasOptions(node) || (node.children ?? []).some(hasText);
151
+ }
152
+
153
+ /** A dropdown, menu, list or tab bar with options a player reads (addon 1.5.0). */
154
+ function hasOptions(node) {
155
+ return Array.isArray(node.options) && node.options.length > 0;
156
+ }
157
+
158
+ /** True when a menu is open somewhere in the kept outline (addon 1.6.0). */
159
+ export function hasOpenMenu(node) {
160
+ return Boolean(node && node.open === true && hasOptions(node)) || (node?.children ?? []).some(hasOpenMenu);
144
161
  }
145
162
 
146
163
  /** How many enabled, visible pressable nodes have no text on them or under them. */
@@ -165,6 +182,7 @@ function prune(node, collected) {
165
182
  Boolean(node.label) ||
166
183
  Boolean(node.script) ||
167
184
  Boolean(node.scene) ||
185
+ hasOptions(node) ||
168
186
  (node.groups ?? []).length > 0 ||
169
187
  PRESSABLE.test(node.type ?? '') ||
170
188
  node.child_count > 0;
@@ -191,7 +209,9 @@ function passesThrough(node) {
191
209
 
192
210
  function render(node, depth, lines, prefix = '') {
193
211
  if (depth > 0 && passesThrough(node)) {
194
- render(node.children[0], depth, lines, `${prefix}${node.name ?? ''}/`);
212
+ // The engine names its own containers @HBoxContainer@12: no part of a path a player reads.
213
+ const name = String(node.name ?? '');
214
+ render(node.children[0], depth, lines, name.startsWith('@') ? prefix : `${prefix}${name}/`);
195
215
  return;
196
216
  }
197
217
  lines.push(`${' '.repeat(depth)}${describe(node, prefix)}`);
@@ -204,9 +224,11 @@ function describe(node, prefix = '') {
204
224
  else if (node.label) parts.push(`label=${JSON.stringify(collapse(node.label))}`);
205
225
  // What a dropdown, a list or a tab bar has chosen and offers, and where a
206
226
  // slider stands (addon 1.5.0): what a player reads off them.
207
- if (Array.isArray(node.options) && node.options.length > 0) {
227
+ // A separator came as an empty option from an addon before 1.6.0; it is not one.
228
+ const options = Array.isArray(node.options) ? node.options.map((option) => collapse(String(option))).filter(Boolean) : [];
229
+ if (options.length > 0) {
208
230
  if (node.selected) parts.push(`selected=${JSON.stringify(collapse(String(node.selected)))}`);
209
- parts.push(`options=[${node.options.slice(0, 12).map((option) => collapse(String(option))).join(' | ')}${node.options.length > 12 ? ' | ...' : ''}]`);
231
+ parts.push(`options=[${options.slice(0, 12).join(' | ')}${options.length > 12 ? ' | ...' : ''}]`);
210
232
  } else if (typeof node.value === 'number' && Array.isArray(node.range)) {
211
233
  parts.push(`value=${round(node.value * 100) / 100} (from ${node.range[0]} to ${node.range[1]})`);
212
234
  }
@@ -221,6 +243,8 @@ function describe(node, prefix = '') {
221
243
  }
222
244
  const flags = [];
223
245
  if (node.focus) flags.push('focus');
246
+ if (node.open === true) flags.push('open menu');
247
+ if (node.own_window === true) flags.push('own window, not in the screenshot');
224
248
  if (node.disabled) flags.push('disabled');
225
249
  if (node.visible === false) flags.push('hidden');
226
250
  if ((node.groups ?? []).length > 0) flags.push(`groups=${node.groups.join('|')}`);
@@ -29,6 +29,7 @@ import fs from 'node:fs/promises';
29
29
  import path from 'node:path';
30
30
 
31
31
  import { buildObservation, needsVision } from './godot-observation.js';
32
+ import { cursorReads } from './godot-cursor.js';
32
33
  // The game's own analytics events (the hosted runner's lib/events.mjs, carried unchanged).
33
34
  import { createGameEvents } from '../events.js';
34
35
  import { pngFingerprint, screenDelta, significant } from '../pixels.js';
@@ -102,7 +103,7 @@ export const PROBE_WIDTH = 320;
102
103
  /** The most nodes a click target that matched several is answered with. */
103
104
  const MAX_MATCHES_NAMED = 4;
104
105
 
105
- const PRESSABLE_TYPE = /Button|LineEdit|TextEdit|Slider|CheckBox|CheckButton|OptionButton|ItemList|Tree/;
106
+ const PRESSABLE_TYPE = /Button|LineEdit|TextEdit|Slider|CheckBox|CheckButton|OptionButton|ItemList|Tree|TabBar|PopupMenu/;
106
107
 
107
108
  /** The longest wait action, matching the browser driver's. */
108
109
  export const MAX_WAIT_MS = 10000;
@@ -255,10 +256,44 @@ const SOURCE_LINE = /^\s+at:\s*(.+)$/;
255
256
  * @param {{kind?: string, option?: string, value?: number, min?: number, max?: number}|undefined} answer
256
257
  * @returns {string|null}
257
258
  */
258
- export function selectDetail(answer) {
259
+ export function selectDetail(answer, { fromClick = false } = {}) {
259
260
  if (!answer) return null;
260
261
  if (answer.kind === 'range') return `Set it to ${Math.round(Number(answer.value) * 1000) / 1000} (it runs from ${answer.min} to ${answer.max}).`;
261
- return `Chose ${JSON.stringify(String(answer.option ?? ''))}.`;
262
+ const option = JSON.stringify(String(answer.option ?? ''));
263
+ // The option already in effect: the game was told nothing, as a player's pick tells it nothing.
264
+ if (answer.already) return `${option} was already chosen.`;
265
+ // An item that opens a further menu (addon 1.7.0): opened, as a player's hover or click opens it, and nothing chosen yet.
266
+ if (answer.kind === 'submenu') return `Opened ${option}: its items are in the outline, under it.`;
267
+ if (answer.kind === 'menu') return `Chose ${option} in ${fromClick ? 'the open menu' : 'the menu'}.`;
268
+ return `Chose ${option}.`;
269
+ }
270
+
271
+ /**
272
+ * The option of an open menu a click target names (addon 1.6.0): a menu's
273
+ * items are not nodes, so the text a persona read off the menu is matched
274
+ * here. An exact match in exactly one open menu, else null.
275
+ *
276
+ * @param {Object|null} tree the last outline's tree
277
+ * @param {string} wanted
278
+ * @returns {{path: string, option: string}|null}
279
+ */
280
+ export function openMenuOption(tree, wanted) {
281
+ const lower = String(wanted ?? '').trim().toLowerCase();
282
+ if (!lower) return null;
283
+ const found = [];
284
+ const walk = (node) => {
285
+ if (!node) return;
286
+ if (node.open === true && Array.isArray(node.options)) {
287
+ for (const shown of node.options) {
288
+ // The outline marks an option "(disabled)", "(checked)" or "(submenu)"; the item's own text is before it.
289
+ const text = String(shown).replace(/ \((?:disabled|checked|submenu)\)$/, '');
290
+ if (text.trim().toLowerCase() === lower) found.push({ path: String(node.path ?? ''), option: text });
291
+ }
292
+ }
293
+ for (const child of node.children ?? []) walk(child);
294
+ };
295
+ walk(tree);
296
+ return found.length === 1 && found[0].path ? found[0] : null;
262
297
  }
263
298
 
264
299
  export function traceableEvents(events, clicks = []) {
@@ -377,6 +412,7 @@ export class GodotDriver {
377
412
  this.deaths = null;
378
413
  this.errorCount = 0;
379
414
  this.reasserted = 0;
415
+ this.desktopPointer = 0;
380
416
  this.trace = null;
381
417
  this.traceSecrets = [];
382
418
  this.importTimeoutMs = importTimeoutMs;
@@ -757,11 +793,21 @@ export class GodotDriver {
757
793
  ticks_per_second: this.ticksPerSecond,
758
794
  headless: this.headless,
759
795
  viewport: this.viewport,
796
+ ...(await this._cursorHeader()),
760
797
  ...(this.traceHeader ?? {}),
761
798
  }, digest);
762
799
  }
763
800
  }
764
801
 
802
+ /**
803
+ * Where the game reads the mouse position itself (./godot-cursor.js), for the
804
+ * trace header: in lockstep those reads see the desktop's pointer.
805
+ */
806
+ async _cursorHeader() {
807
+ const reads = await cursorReads(this.projectDir).catch(() => []);
808
+ return reads.length > 0 ? { cursor_reads: reads } : {};
809
+ }
810
+
765
811
  /** The newest `deaths` any _ravensight_state() hook reports, null if none does. */
766
812
  _readDeaths(digest) {
767
813
  const states = digest?.game_state;
@@ -795,6 +841,8 @@ export class GodotDriver {
795
841
  const frame = this.tick;
796
842
  this.tick = answer.tick;
797
843
  if (Number.isInteger(answer.reasserted)) this.reasserted = answer.reasserted;
844
+ // Desktop mouse events that reached the engine and that the addon put back (1.7.0).
845
+ if (Number.isInteger(answer.desktop_pointer)) this.desktopPointer = answer.desktop_pointer;
798
846
  if (answer.digest) {
799
847
  this.lastDigest = answer.digest;
800
848
  this._readDeaths(answer.digest);
@@ -864,7 +912,7 @@ export class GodotDriver {
864
912
  case 'select': {
865
913
  const event = { type: 'select', node_path: action.target, ...(action.option !== undefined ? { option: action.option } : {}), ...(action.value !== undefined ? { value: action.value } : {}) };
866
914
  const answer = await this.step([event], 2 + settle, { action: 'select', args: event });
867
- this._lastDetail = selectDetail(answer.selects?.[0]);
915
+ this._lastDetail = selectDetail(answer.selects?.[0], { fromClick: action.fromClick });
868
916
  return;
869
917
  }
870
918
  case 'click': {
@@ -978,6 +1026,7 @@ export class GodotDriver {
978
1026
  errors: this.errorCount,
979
1027
  replayable: Boolean(this.trace) && !this.trace.truncated,
980
1028
  inputs_reasserted: this.reasserted,
1029
+ desktop_pointer_events: this.desktopPointer,
981
1030
  };
982
1031
  }
983
1032
 
@@ -1362,6 +1411,12 @@ export class GodotDriver {
1362
1411
  if (action.kind === 'type' && (action.replace || action.target)) {
1363
1412
  return { ok: false, error: 'replace (empty a field, then type) and a typing target are only available on playwright_web; this driver can only type more text into what has focus', changed: false };
1364
1413
  }
1414
+ // A plain click on the text of an open menu's option chooses it: the
1415
+ // option is no node to click, so it is chosen the way select chooses it.
1416
+ const menuOption = action.kind === 'click' && typeof action.target === 'string' && !action.button && !action.double && !(Number(action.holdMs) > 0) && this.addonAtLeast(1, 6)
1417
+ ? openMenuOption(this._lastTree, action.target)
1418
+ : null;
1419
+ if (menuOption) action = { kind: 'select', target: menuOption.path, option: menuOption.option, fromClick: true };
1365
1420
  if (action.kind === 'click' && typeof action.target === 'string') {
1366
1421
  // The runner could not tell which node was meant: its own failure, said
1367
1422
  // as one (driverError), so nothing downstream reads it as a broken game.
@@ -1437,7 +1492,7 @@ export class GodotDriver {
1437
1492
  case 'select': {
1438
1493
  const answer = await this.rpc.call('select', { node_path: action.target, ...(action.option !== undefined ? { option: action.option } : {}), ...(action.value !== undefined ? { value: action.value } : {}) });
1439
1494
  await this.rpc.call('wait_frames', { n: 2 });
1440
- this._lastDetail = selectDetail(answer);
1495
+ this._lastDetail = selectDetail(answer, { fromClick: action.fromClick });
1441
1496
  return;
1442
1497
  }
1443
1498
  case 'key': {