ravensight-playtest 0.13.0 → 0.13.1

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 CHANGED
@@ -711,6 +711,14 @@ from the page: the browser driver sets `window.__RAVENSIGHT_PLAYTEST__` and
711
711
  `localStorage['ravensight.playtest']` before the game's scripts run. It is never
712
712
  sent as a request header, which would reach your game's own API too.
713
713
 
714
+ The server takes that playtest mark only with the game's live key, or from a
715
+ cloud run's runner. A web build that sends a public ingest key (`gt_pub_`) has
716
+ its SDK's session refused (403 `public_key_forbidden`), so its SDK sends no
717
+ events: the run then says plainly, in `report.md` under "Measured from the
718
+ game's own events", in `usage.json` `gameEvents.sessionRefused` and on screen,
719
+ that no game events were recorded and why. Nothing is counted as a player. A
720
+ cloud playtest of the same build records them.
721
+
714
722
  With no ingest key configured, a Godot run says "no ingest key configured, so
715
723
  no synthetic telemetry was sent". A web run says "synthetic telemetry comes from
716
724
  the game's own SDK on the page, sent with the run's playtest token" instead,
@@ -779,7 +787,16 @@ How the report step reads what happened:
779
787
  is "shows it" alone, "cannot tell" or a check that was not made. A claim
780
788
  that something is missing is also asked about the screen play was on
781
789
  before it. On a canvas game, a judgement of how the screen is drawn is
782
- asked about the game's own frame, with none of the runner's marks on it;
790
+ asked about the game's own frame, with none of the runner's marks on it.
791
+ A claim that nothing happens ("Help does nothing") is a finding only on a
792
+ web run, and only when the run measured it (the same named control was
793
+ pressed at least twice, the page took every press, the screen changed on
794
+ none and the control answered at no other moment) and the cloud runner's
795
+ own watch confirmed it: the recorded inputs are played again in a fresh
796
+ browser, twice, and on the second the screen is watched while game time
797
+ runs for 2 seconds with no input. Only when nothing on it changed is it a
798
+ finding. With the replay off, on a Godot run, or with anything less,
799
+ it is turned away, as one still frame cannot settle it;
783
800
  - a **playtester impression**: praise, and a matter of taste or clarity
784
801
  ("confusing", "unclear") whose picture shows what it rests on. Never a
785
802
  finding: `report.json` lists it under `impressions`, `report.md` under
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ravensight-playtest",
3
- "version": "0.13.0",
3
+ "version": "0.13.1",
4
4
  "description": "Local AI playtests and seeded game simulations with reports in Ravensight.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://ravensight.io/docs/playtest/",
@@ -3,6 +3,7 @@ import { pngFingerprint, screenDelta, significant } from '../pixels.js';
3
3
  import { findRegions } from '../regions.js';
4
4
  import { createMarker, isMarkTarget, marksFor, marksText, resolveMark } from '../marks.js';
5
5
  import { gameTime, timeFreezeInit } from '../timeFreeze.js';
6
+ import { createSdkSessions, sdkSessionAnswer } from '../sdkSession.js';
6
7
  import { STRIP_MIN_MS, stripNote, stripTimes, stripTokens } from '../strip.js';
7
8
  import { GAMEPAD_BUTTONS, gamepadState, virtualGamepadInit } from '../gamepad.js';
8
9
  // any-game hook: sound as measured evidence (../anygame/sound.js).
@@ -1440,6 +1441,9 @@ export function createWebDriver({ importer, headless = true, playtest = null, pl
1440
1441
  let page = null;
1441
1442
  // The game's own Ravensight SDK events, read from the track calls the page makes (read only: every call goes out unchanged).
1442
1443
  const gameEvents = createGameEvents();
1444
+ // The game's own SDK opening its session: each answer, so a refusal that leaves the run with no game events is said plainly (../sdkSession.js).
1445
+ const sdkSessions = createSdkSessions();
1446
+ const sdkSessionReads = new Set();
1443
1447
  let target = null;
1444
1448
  let runDirectory = null;
1445
1449
  let videoRequested = false;
@@ -2933,6 +2937,14 @@ export function createWebDriver({ importer, headless = true, playtest = null, pl
2933
2937
  if (typeof context.addInitScript === 'function') await context.addInitScript(capabilitySignalsInit);
2934
2938
  // The game's own SDK events: its track calls are read as they leave the page, never held, changed or answered here.
2935
2939
  if (typeof context.on === 'function') context.on('request', request => tapSdkEvents(request, gameEvents));
2940
+ // And the answer to its session request, read only: the status, the key's kind, the error code; never the key or the token.
2941
+ if (typeof context.on === 'function') {
2942
+ context.on('response', response => {
2943
+ const read = sdkSessionAnswer(response).then(answer => sdkSessions.record(answer), () => {});
2944
+ sdkSessionReads.add(read);
2945
+ read.finally(() => sdkSessionReads.delete(read));
2946
+ });
2947
+ }
2936
2948
  // The page never leaves the build, recording or not. A top-level
2937
2949
  // navigation off it (a clicked link, a form, a script) is answered with
2938
2950
  // an empty 204, which a browser treats as "stay where you are": the
@@ -3320,6 +3332,12 @@ export function createWebDriver({ importer, headless = true, playtest = null, pl
3320
3332
  */
3321
3333
  /** The game's own SDK events this run (../events.js): marked at each input, flushed before the page closes, read by the report. */
3322
3334
  gameEvents,
3335
+ /** The game's own SDK's session answers: how many opened, and each refusal (../sdkSession.js). */
3336
+ async sdkSessions() {
3337
+ // An answer still being read (its body) is waited for, briefly, so a refusal at the end of play is not missed.
3338
+ if (sdkSessionReads.size > 0) await Promise.race([Promise.allSettled([...sdkSessionReads]), new Promise(resolve => setTimeout(resolve, 2000))]);
3339
+ return sdkSessions.summary();
3340
+ },
3323
3341
  /** Mark the page clock just before input `step` (or 'end' after play), so each event is placed at the step it happened. */
3324
3342
  async markGameEvents(step) {
3325
3343
  if (!page || pendingDialog || gameGone) { gameEvents.mark(step, null); return; }
package/src/run/judge.js CHANGED
@@ -19,9 +19,14 @@
19
19
  // runner's own file (./claimwords.js), and so are the rules on what the
20
20
  // game's events say about a claim (./eventclaims.js): one rule set, two paths.
21
21
  //
22
- // What a local run cannot do the way a hosted one does, and so is turned away
23
- // rather than published: a claim that nothing happens needs a replay that
24
- // watched game time run with no input (the runner's own freeze watch is a
22
+ // A claim that nothing happens is held to the hosted gate's own evidence
23
+ // (lib/claims.mjs gateClaim, the stuck branch): a replay that played the
24
+ // recorded inputs again and watched the screen while game time ran for
25
+ // STILL_MIN_GAME_MS with no input, and saw nothing change (./stillWatch.js).
26
+ // A local web run makes that watch only for a claim the run measured: the
27
+ // same named control pressed again and again, changing nothing every time
28
+ // and answering at no other moment. Anything less is turned away, as before:
29
+ // one still frame cannot settle it (the runner's own freeze watch is a
25
30
  // measurement, and is not judged here).
26
31
  //
27
32
  // MONEY (owner, 2026-11-14). Taste its check could not settle, and a judgement of difficulty from the
@@ -32,6 +37,7 @@
32
37
  // as hosted money does. With the switch off, both would be kept as `opinion` impressions instead.
33
38
  import { claimClass, claimBasis, checkSaid, praiseClaim } from './claimwords.js';
34
39
  import { eventsVerdict, eventsConfirmed, contradictedReason } from './eventclaims.js';
40
+ import { STILL_MIN_GAME_MS } from './stillWatch.js';
35
41
 
36
42
  /** Turn away unsettled taste and own-play difficulty, as the hosted judge does. See MONEY above: the owner's call. */
37
43
  export const TURN_AWAY_UNSETTLED = true;
@@ -88,9 +94,10 @@ const designedWords = check => {
88
94
  * @param {number|null} [opts.step] the action the issue belongs to
89
95
  * @param {boolean} [opts.marked]
90
96
  * @param {boolean} [opts.turnAwayUnsettled]
97
+ * @param {{measured: Object|null, replay: Object|null}|null} [opts.still] for a claim that nothing happens: what the run measured of its input (./stillWatch.js noEffectTries) and the replay that watched it (./reportChecks.js replayWebFindings)
91
98
  * @returns {{route: string, outcome: string|null, reason: string|null, cls: string, basis: string|null, impression?: {kind: string, check: string|null, note: string}, evidence?: string, events?: Array}}
92
99
  */
93
- export function judgeIssue(finding, { check = null, run = null, step = null, marked = false, turnAwayUnsettled = TURN_AWAY_UNSETTLED } = {}) {
100
+ export function judgeIssue(finding, { check = null, run = null, step = null, marked = false, turnAwayUnsettled = TURN_AWAY_UNSETTLED, still = null } = {}) {
94
101
  const { cls, basis } = claimShape(finding, { marked });
95
102
  const base = { cls, basis };
96
103
  const finding_ = extra => ({ ...base, route: 'finding', outcome: null, reason: null, ...extra });
@@ -126,7 +133,14 @@ export function judgeIssue(finding, { check = null, run = null, step = null, mar
126
133
  if (cls === 'stuck') {
127
134
  if (said === 'opposite') return away('contradicted', 'the frame at its moment contradicts it');
128
135
  if (designed) return designed;
129
- return away('unconfirmed', 'a claim that nothing happens is confirmed only by watching the screen while game time runs with no input, which this local run did not do for it; one still frame cannot settle it');
136
+ if (!still || !still.measured) return away('unconfirmed', 'a claim that nothing happens is confirmed only by watching the screen while game time runs with no input, and the run did not press the same control again and again with nothing changing; one still frame cannot settle it');
137
+ // The hosted gate's stuck rule, word for word: reproduced counts only from a watch, since the same screen following the same input says nothing about stillness.
138
+ const replay = still.replay || null;
139
+ const detail = replay && replay.detail ? ` (${text(replay.detail)})` : '';
140
+ if (replay?.state === 'reproduced' && Number(replay.watched_ms) >= STILL_MIN_GAME_MS) return finding_({ evidence: 'still_watch' });
141
+ if (replay?.state === 'reproduced') return away('unconfirmed', 'the replay reached the same screen but did not watch it while game time ran, so it could not test a claim that nothing happens');
142
+ if (replay?.state === 'not_reproduced') return away('not_reproduced', `it did not come back when the recorded inputs were played again${detail}`);
143
+ return away('unconfirmed', `a claim that nothing happens is confirmed only by watching the screen while game time runs for ${STILL_MIN_GAME_MS / 1000} seconds with no input, and that could not be done${detail}; one still frame cannot settle it`);
130
144
  }
131
145
  if (cls === 'absence') {
132
146
  if (said === 'opposite') return away('contradicted', 'the frames nearest its moment show the thing it says is missing');
@@ -38,13 +38,15 @@ import { sweepTurnedAway } from './claimGate.js';
38
38
  import { claimShape, judgeIssue, legacyIssue, impressionOf } from './judge.js';
39
39
  import { EVENTS_RULE, eventsBlock, eventsReportLines, eventsUsage, withEventEvidence } from './events.js';
40
40
  import { memoryBlock, extractLocalNotes, gameMemoryBody } from './gameMemory.js';
41
- import { CLAIM_SYSTEM, CLAIM_WIRE, claimText, claimRead, claimMessage } from './claimwords.js';
41
+ import { CLAIM_SYSTEM, CLAIM_WIRE, checkSaid, claimText, claimRead, claimMessage } from './claimwords.js';
42
42
  import { CLAIM_FAULT_SYSTEM, claimCheckSystem, claimReply, claimFormatRepair, MAX_CLAIM_REPLY_TEXT } from './claimProtocol.js';
43
43
  import { captureNotes, createCaptureWatch, rewriteStaleEvidence, staleSentence } from './captureCheck.js';
44
44
  import { gameRefusal } from './gameRefusal.js';
45
45
  import { BUILT_IN_NOISE, expectedNoiseForPrompt, isExpectedNoise } from './noise.js';
46
- import { cutFindingFrames, moodOf, replayCapabilityNote, replayFindings, replayWebFindings, screenOf, traceWebInputs } from './reportChecks.js';
46
+ import { cutFindingFrames, moodOf, replayCapabilityNote, replayFindings, replayWebFindings, screenOf, traceWebInputs, watchClaimsStill } from './reportChecks.js';
47
47
  import { pngFingerprint, screenDelta, significant } from './pixels.js';
48
+ import { watchWebStill } from './stillWatch.js';
49
+ import { refusedEventsBody, refusedReportInstruction, sessionRefusal } from './sdkSession.js';
48
50
  import { mkdtemp } from 'node:fs/promises';
49
51
  import os from 'node:os';
50
52
  import { MIN_PASSWORD_CHARS } from '../briefLocal.js';
@@ -428,8 +430,24 @@ export async function runPersona(args) {
428
430
  if (args.signal?.aborted || heartbeat?.canceled) throw new Error('The playthrough was interrupted before reporting.');
429
431
  onProgress({ phase: 'reporting', persona: persona.slug });
430
432
 
433
+ // A web run's replays: the watch the claim judge asks for a claim that nothing happens (./stillWatch.js), and the replay of
434
+ // the findings after the report, which writes the watch's results as they are rather than playing them again.
435
+ const playMs = Date.parse(endedAt) - Date.parse(startedAt);
436
+ const differs = (a, b) => { const delta = screenDelta(a, b); return delta === null || significant(delta); };
437
+ const webReplay = args.replayFindings !== false && Array.isArray(driver.webTrace) && typeof args.replayDriver === 'function'
438
+ ? { trace: driver.webTrace, traceSteps: honesty.traceSteps, makeDriver: args.replayDriver, target, viewport, playMs, signal: args.signal, fingerprint: pngFingerprint, differs,
439
+ tempDir: () => mkdtemp(path.join(os.tmpdir(), 'rs-replay-')), watch: (replayDriver, at) => watchWebStill(replayDriver, { ...at, fingerprint: pngFingerprint, differs }) }
440
+ : null;
441
+ const watchedStill = new Map();
442
+ const stillReplay = webReplay ? async wanted => {
443
+ const answered = await watchClaimsStill({ wanted, ...webReplay });
444
+ for (const { id, title } of wanted) if (answered.get(id)?.replay) watchedStill.set(id, { title, replay: answered.get(id).replay });
445
+ return answered;
446
+ } : null;
447
+
431
448
  const written = await reportPhase({
432
449
  claimGate: args.claimGate === 'legacy' ? 'legacy' : 'judge',
450
+ stillReplay,
433
451
  client,
434
452
  jobId,
435
453
  runId,
@@ -461,11 +479,14 @@ export async function runPersona(args) {
461
479
  // the step log per finding. It never changes the report or fails the run.
462
480
  if (args.replayFindings !== false) {
463
481
  const replayed = Array.isArray(driver.webTrace)
464
- ? replayWebFindings({ report: written.report, index: written.index || [], traceSteps: honesty.traceSteps, trace: driver.webTrace, makeDriver: args.replayDriver, target, viewport, playMs: Date.parse(endedAt) - Date.parse(startedAt), transcript, signal: args.signal,
465
- fingerprint: pngFingerprint, differs: (a, b) => { const delta = screenDelta(a, b); return delta === null || significant(delta); }, tempDir: () => mkdtemp(path.join(os.tmpdir(), 'rs-replay-')),
482
+ ? replayWebFindings({ report: written.report, index: written.index || [], traceSteps: honesty.traceSteps, trace: driver.webTrace, makeDriver: args.replayDriver, target, viewport, playMs, transcript, signal: args.signal,
483
+ fingerprint: pngFingerprint, differs, tempDir: () => mkdtemp(path.join(os.tmpdir(), 'rs-replay-')),
484
+ // A finding placed at an input that changed nothing is watched on the last replay, as on a cloud run; a claim the judge
485
+ // already had watched is written as it was (only the judge's watched claims say nothing happens by their words).
486
+ ...(webReplay ? { watch: webReplay.watch } : {}), prior: watchedFor(written.report, watchedStill),
466
487
  // [tester hook] The probes that found something are run once more at the end of this one replay (./testerProbes.js probeObserver).
467
488
  observer: probeObserver({ probes: honesty.probes, report: written.report, actionRecords, signal: args.signal }) })
468
- : replayFindings({ report: written.report, index: written.index || [], traceSteps: honesty.traceSteps, runDirectory, driver, playMs: Date.parse(endedAt) - Date.parse(startedAt), transcript, signal: args.signal });
489
+ : replayFindings({ report: written.report, index: written.index || [], traceSteps: honesty.traceSteps, runDirectory, driver, playMs, transcript, signal: args.signal });
469
490
  await replayed
470
491
  .then(pass => {
471
492
  // A game that started differently on replay is a limit of the runner: a capability note, never a finding.
@@ -488,6 +509,8 @@ export async function runPersona(args) {
488
509
  // What the game's own events measured, for usage.json (./events.js eventsUsage).
489
510
  const eventRun = gameEventsRun(honesty);
490
511
  outcome.gameEvents = eventRun ? eventsUsage(eventRun) : null;
512
+ // A session the server refused: no game events, and why, in usage.json too.
513
+ if (honesty.sdkSession) outcome.gameEvents = { ...(outcome.gameEvents || { total: 0 }), sessionRefused: { status: honesty.sdkSession.status, error: honesty.sdkSession.error, key: honesty.sdkSession.key, tagged: honesty.sdkSession.tagged } };
491
514
  // The notes this run hands on to the next playtest of the game, when the game's memory asked for them (./gameMemory.js).
492
515
  if (memory && memory.save === true) {
493
516
  const handed = gameMemoryBody(memory, extractLocalNotes({ digest: honesty.anygame ? honesty.anygame.digest() : null, turnedAway: written.turnedAway || [] }));
@@ -1839,6 +1862,13 @@ async function playLoop({
1839
1862
  const kept = driver.gameEvents.record();
1840
1863
  if (kept.total > 0) transcript.write({ kind: 'game_events', total: kept.total, kept: kept.kept, clock: kept.clock, names: kept.names });
1841
1864
  }
1865
+ // The game's own SDK asked for its session and the server refused it, so none of its events reached the run (./sdkSession.js).
1866
+ const refusal = driver && typeof driver.sdkSessions === 'function' ? sessionRefusal(await Promise.resolve().then(() => driver.sdkSessions()).catch(() => null)) : null;
1867
+ if (refusal) {
1868
+ honesty.sdkSession = refusal;
1869
+ transcript.write({ kind: 'game_events_refused', status: refusal.status, error: refusal.error, key: refusal.key, tagged: refusal.tagged, times: refusal.times });
1870
+ log(refusedEventsBody(refusal));
1871
+ }
1842
1872
  if (completionRepairPending) transcript.write({ kind: 'brief_completion_repair_unavailable', reason: quitReason, detail: quitDetail, independently_verified: false });
1843
1873
  return {
1844
1874
  actionsTaken: actions,
@@ -1897,6 +1927,8 @@ async function reportPhase({
1897
1927
  endedAt,
1898
1928
  // 'judge' (the claim judge) or 'legacy' (a run whose findings decide money elsewhere: ./judge.js legacyIssue).
1899
1929
  claimGate = 'judge',
1930
+ // A web run's watch of a claim that nothing happens, asked by the judge (./stillWatch.js); null for any other run.
1931
+ stillReplay = null,
1900
1932
  log
1901
1933
  }) {
1902
1934
  // The report step never sees the test account: it has nothing to sign in
@@ -2238,7 +2270,7 @@ async function reportPhase({
2238
2270
  let impressions = [];
2239
2271
  if (!shrunk && !play.budgetExceeded) {
2240
2272
  const impressionsAllowed = Boolean(reportSchema && reportSchema.properties && reportSchema.properties.impressions);
2241
- const checked = await checkClaimsAgainstScreenshots({ client, jobId, runId, report, screenshots, runDirectory, ledger, transcript, log, frames, measured: new Set(mergedAnchors(honesty).keys()), observations, notes, index: where, run: eventRun, impressionsAllowed: impressionsAllowed && claimGate !== 'legacy', gate: claimGate, secrets });
2273
+ const checked = await checkClaimsAgainstScreenshots({ client, jobId, runId, report, screenshots, runDirectory, ledger, transcript, log, frames, measured: new Set(mergedAnchors(honesty).keys()), observations, notes, index: where, run: eventRun, impressionsAllowed: impressionsAllowed && claimGate !== 'legacy', gate: claimGate, secrets, stillReplay });
2242
2274
  report = checked.report;
2243
2275
  turnedAway = checked.turnedAway;
2244
2276
  impressions = checked.impressions;
@@ -2270,6 +2302,8 @@ async function reportPhase({
2270
2302
  const lines = eventsReportLines(eventRun, { findings: report.findings || [], turnedAway });
2271
2303
  if (lines.length > 0) markdown = replaceSection(markdown, EVENTS_HEADING, lines.slice(2).join('\n').replace(/\s+$/, ''));
2272
2304
  }
2305
+ // The game's own SDK was refused its session: said plainly where its events would be, never left to read as benign.
2306
+ if (honesty && honesty.sdkSession && !(eventRun && eventRun.gameEvents && eventRun.gameEvents.total > 0)) markdown = replaceSection(markdown, EVENTS_HEADING, refusedEventsBody(honesty.sdkSession));
2273
2307
  // What a screenshot shows comes from the picture: one taken while the picture lagged the game says so.
2274
2308
  markdown = rewriteStaleEvidence(markdown, (screenshots || []).filter(shot => shot && shot.stale && shot.relativePath));
2275
2309
  if (choiceCheck) {
@@ -2329,6 +2363,16 @@ async function reportPhase({
2329
2363
  return { report, markdown, lint, index: honest.index, turnedAway };
2330
2364
  }
2331
2365
 
2366
+ /**
2367
+ * The watch results the judge's replay made, for the findings of the written
2368
+ * report that are the claims it watched (the same id and title: a runner's own
2369
+ * finding added after the judge may take the id of a claim it turned away).
2370
+ */
2371
+ export function watchedFor(report, watched) {
2372
+ const findings = report && Array.isArray(report.findings) ? report.findings : [];
2373
+ return new Map([...watched].filter(([id, entry]) => findings.some(finding => finding && finding.id === id && finding.title === entry.title)).map(([id, entry]) => [id, entry.replay]));
2374
+ }
2375
+
2332
2376
  /** The heading of the report's section on the game's own events, the hosted runner's own. */
2333
2377
  export const EVENTS_HEADING = '## Measured from the game\'s own events';
2334
2378
 
@@ -2557,7 +2601,7 @@ export function citedAfterScreenshot(finding, screenshots) {
2557
2601
  *
2558
2602
  * @returns {Promise<{report: Object, turnedAway: Array<Object>, impressions: Array<Object>}>}
2559
2603
  */
2560
- export async function checkClaimsAgainstScreenshots({ client, jobId, runId, report, screenshots, runDirectory, ledger, transcript, log = () => {}, frames = new Map(), measured = new Set(), observations = [], notes = [], index = null, run = null, impressionsAllowed = true, gate = 'judge', secrets = [] }) {
2604
+ export async function checkClaimsAgainstScreenshots({ client, jobId, runId, report, screenshots, runDirectory, ledger, transcript, log = () => {}, frames = new Map(), measured = new Set(), observations = [], notes = [], index = null, run = null, impressionsAllowed = true, gate = 'judge', secrets = [], stillReplay = null }) {
2561
2605
  if (!report || !Array.isArray(report.findings)) return { report, turnedAway: [], impressions: [] };
2562
2606
  const placedIndex = Array.isArray(index) ? index : attachWhereToLook(report, { observations, notes, screenshots }).index;
2563
2607
  const where = new Map(placedIndex.map(entry => [entry.id, entry]));
@@ -2668,6 +2712,28 @@ export async function checkClaimsAgainstScreenshots({ client, jobId, runId, repo
2668
2712
  transcript.write({ kind: 'claim_check', id: finding.id, screenshot: shot.relativePath, ...on, ...(placed.look ? { look: true } : {}), ...record });
2669
2713
  checks.set(finding, { ...record, picture: shot.relativePath });
2670
2714
  }
2715
+ // A claim that nothing happens, which its picture did not contradict or explain: what the run measured of its input, and a replay
2716
+ // that watched the screen while game time ran (./stillWatch.js, the hosted gate's evidence). Only a web run has the hook.
2717
+ const still = new Map();
2718
+ if (gate !== 'legacy' && typeof stillReplay === 'function') {
2719
+ const wanted = judged.filter(finding => shapes.get(finding).cls === 'stuck' && !['opposite', 'as_designed'].includes(checkSaid(checks.get(finding) || null)));
2720
+ if (wanted.length > 0) {
2721
+ let answered = new Map();
2722
+ let failed = null;
2723
+ try {
2724
+ answered = await stillReplay(wanted.map(finding => ({ id: finding.id, title: finding.title, action: Number.isInteger(where.get(finding.id)?.action) ? where.get(finding.id).action : null })));
2725
+ } catch (error) {
2726
+ failed = String(error && error.message ? error.message : error).split('\n')[0].slice(0, 120);
2727
+ log(`the watch of a claim that nothing happens could not run (${failed}); such a claim is not confirmed by it.`);
2728
+ }
2729
+ for (const finding of wanted) {
2730
+ const answer = (answered instanceof Map && answered.get(finding.id)) || { measured: null, replay: null };
2731
+ still.set(finding, answer);
2732
+ // The control's name comes from the run's own inputs, kept in memory unscrubbed: scrubbed here like every other line.
2733
+ transcript.write(scrubSecrets({ kind: 'still_check', id: finding.id, measured: answer.measured || null, replay: answer.replay || null, ...(failed ? { error: failed } : {}) }, secrets));
2734
+ }
2735
+ }
2736
+ }
2671
2737
  const turnedAway = [];
2672
2738
  const impressions = [];
2673
2739
  const findings = [];
@@ -2678,7 +2744,7 @@ export async function checkClaimsAgainstScreenshots({ client, jobId, runId, repo
2678
2744
  // A run whose findings decide money elsewhere (a fix's verify, a Labs scenario) keeps the gate it had: see ./judge.js legacyIssue.
2679
2745
  const outcome = gate === 'legacy'
2680
2746
  ? legacyIssue(finding, { check: checks.get(finding) || null, marked: Boolean(placed.marked) })
2681
- : judgeIssue(finding, { check: checks.get(finding) || null, run, step, marked: Boolean(placed.marked) });
2747
+ : judgeIssue(finding, { check: checks.get(finding) || null, run, step, marked: Boolean(placed.marked), still: still.get(finding) || null });
2682
2748
  transcript.write({ kind: 'claim_judged', id: finding.id, route: outcome.route, outcome: outcome.outcome, cls: outcome.cls, ...(outcome.basis ? { basis: outcome.basis } : {}), ...(outcome.impression ? { impression: outcome.impression.kind } : {}), ...(outcome.evidence ? { evidence: outcome.evidence } : {}) });
2683
2749
  if (outcome.route === 'finding') { findings.push(finding); continue; }
2684
2750
  if (outcome.route === 'impression') {
@@ -2760,6 +2826,7 @@ export function buildReportRequest({ skill, schemas = [], persona, brief, localB
2760
2826
  '',
2761
2827
  'Network notes (failed requests the runner recorded, with the URL and the status; list them under a "Network notes" heading in report.md when there are any):',
2762
2828
  networkNoteLines(notes),
2829
+ ...(honesty && honesty.sdkSession ? [refusedReportInstruction(honesty.sdkSession)] : []),
2763
2830
  '',
2764
2831
  'Each note carries "after": the URL and title of the observation that followed it. A blocker or major finding must cite the observation index where the failure is visible, as evidence {"type": "transcript_step", "ref": "observation N"}, and must not be contradicted by its note\'s "after" state or by a later persona note: if the next screen or a later note shows the game working, it is not a blocker or a major. Cite a note as {"type": "transcript_step", "ref": "note N"}.',
2765
2832
  'Make each finding one independently supported claim, with a title and description that say the same thing. Describe directly visible content separately from a claim that something fails to change, finish or respond over time. Cite the observation that supports each claim. Do not infer that a game or value is stuck from one still picture. Preserve a temporal claim and its supporting observations when it is what you observed; do not silently replace it with a different static claim. Report only the behavior and content actually observed.',
@@ -13,6 +13,7 @@ import path from 'node:path';
13
13
 
14
14
  import { detectFfmpeg } from '../detect.js';
15
15
  import { replayTrace } from './replay.js';
16
+ import { noEffectTries } from './stillWatch.js';
16
17
  import { TRACE_FILE, parseTrace } from './trace.js';
17
18
 
18
19
  /* ------------------------------------------------------------------- mood */
@@ -398,15 +399,26 @@ export function traceWebInputs(driver, { fingerprint }) {
398
399
  * step log, as for a Godot run.
399
400
  *
400
401
  * A finding is `reproduced` when every replay showed the same screen after
401
- * its input (or, for an input that changed nothing, changed nothing again),
402
- * `diverged` when the replay was already on a different screen before that
403
- * input, `not_reproduced` when one replay matched and one did not, and
404
- * `not_run` when the replay did not reach it.
402
+ * its input, `diverged` when the replay was already on a different screen
403
+ * before that input, `not_reproduced` when one replay matched and one did
404
+ * not, and `not_run` when the replay did not reach it.
405
+ *
406
+ * A finding that says nothing happened (a claim that nothing happens, by its
407
+ * words: `stuck`; or one placed at an input that changed nothing) is held to
408
+ * the hosted replay's rule (lib/verify.mjs replayOnce and replayResult): the
409
+ * input changing nothing again says nothing alone, so the last replay, after
410
+ * the first, watches the screen while game time runs with no input (`watch`,
411
+ * ./stillWatch.js watchWebStill). It is `reproduced` only beside a watch that
412
+ * saw nothing change, with `watched_ms`, the game time the watch covered; with
413
+ * no watch it is `not_possible`, "not verifiable", and never passed.
414
+ *
415
+ * `prior` holds results already made for findings (the watch the claim judge
416
+ * asked for, before the report): each is written as it is, not replayed again.
405
417
  *
406
418
  * @param {Object} args
407
419
  * @returns {Promise<{ran: boolean, runs: number, skipped: string|null, results: Array<Object>}>}
408
420
  */
409
- export async function replayWebFindings({ report, index = [], traceSteps = new Map(), trace = [], makeDriver, target, viewport = null, playMs = 0, transcript, signal = null, fingerprint, differs, observer = null, now = Date.now, runs = REPLAY_RUNS, tempDir = null }) {
421
+ export async function replayWebFindings({ report, index = [], traceSteps = new Map(), trace = [], makeDriver, target, viewport = null, playMs = 0, transcript, signal = null, fingerprint, differs, observer = null, now = Date.now, runs = REPLAY_RUNS, tempDir = null, watch = null, stuck = new Set(), prior = new Map() }) {
410
422
  const issues = (report && Array.isArray(report.findings) ? report.findings : []).filter(finding => finding && SEVERITY_ORDER.includes(finding.severity));
411
423
  const finish = (pass, results) => {
412
424
  for (const result of results) transcript.write({ kind: 'replay_check', ...result });
@@ -414,25 +426,38 @@ export async function replayWebFindings({ report, index = [], traceSteps = new M
414
426
  return { ...pass, results };
415
427
  };
416
428
  if (issues.length === 0) return finish({ ran: false, runs: 0, skipped: 'the report has no issue to replay' }, []);
429
+ // Results the watch before the judge already made: written as they are.
430
+ const earlier = issues.filter(finding => prior.has(finding.id)).map(finding => prior.get(finding.id));
417
431
  // Findings of the runner's own scripted probes are not about one recorded input: the observer runs those probes again at the end of the replay (./testerProbes.js).
418
432
  const scripted = new Set(observer && Array.isArray(observer.ids) ? observer.ids : []);
419
- const targets = replayTargets({ ...report, findings: issues.filter(finding => !scripted.has(finding.id)) }, index, traceSteps).filter(entry => entry.trace_steps <= trace.length);
420
- const rest = issues.filter(finding => !scripted.has(finding.id) && !targets.some(entry => entry.id === finding.id)).map(finding => {
433
+ const replayed = issues.filter(finding => !prior.has(finding.id));
434
+ const targets = replayTargets({ ...report, findings: replayed.filter(finding => !scripted.has(finding.id)) }, index, traceSteps).filter(entry => entry.trace_steps <= trace.length);
435
+ const rest = replayed.filter(finding => !scripted.has(finding.id) && !targets.some(entry => entry.id === finding.id)).map(finding => {
421
436
  const tied = Number.isInteger(index.find(entry => entry.id === finding.id)?.action);
422
437
  const capped = tied && targets.length >= MAX_REPLAY_FINDINGS;
423
438
  return { id: finding.id, state: capped ? 'not_run' : 'not_possible', runs: 0, of: 0, trace_steps: 0, detail: capped ? `the replay looks at the ${MAX_REPLAY_FINDINGS} most severe findings` : 'the finding is not tied to an input the run recorded' };
424
439
  });
425
- if (targets.length === 0 && scripted.size === 0) return finish({ ran: false, runs: 0, skipped: 'no finding is tied to an input the run recorded' }, rest);
440
+ if (targets.length === 0 && scripted.size === 0) {
441
+ if (earlier.length > 0) return finish({ ran: true, runs: Math.max(...earlier.map(result => Number(result.of) || 0)), skipped: null }, [...earlier, ...rest]);
442
+ return finish({ ran: false, runs: 0, skipped: 'no finding is tied to an input the run recorded' }, rest);
443
+ }
444
+ // A finding that says nothing happened: watched on the last replay (the hosted runner's `still`).
445
+ const still = new Set(targets.filter(entry => stuck.has(entry.id) || trace[entry.trace_steps - 1]?.changed === false).map(entry => entry.id));
426
446
  // With probes to run again, the replay plays every recorded input, to the screen play ended on.
427
447
  const last = Math.max(0, ...targets.map(entry => entry.trace_steps), scripted.size > 0 ? trace.length : 0);
448
+ const lastStill = Math.max(0, ...targets.filter(entry => still.has(entry.id)).map(entry => entry.trace_steps));
428
449
  const started = now();
429
450
  const deadline = started + replayBudget(playMs);
430
451
  const verdicts = new Map([...targets.map(entry => [entry.id, []]), ...[...scripted].map(id => [id, []])]);
431
452
  const same = (a, b) => (a && b ? !differs(a, b) : null);
453
+ const seconds = ms => (ms / 1000).toFixed(1);
432
454
  let made = 0, problem = null, longest = 0;
433
455
  for (let i = 0; i < runs; i++) {
434
456
  if (i > 0 && now() + longest > deadline) break;
435
457
  if (signal && signal.aborted) { problem = 'the run was cancelled'; break; }
458
+ // The watch moves the game past the recording, so it has a run of its own: the last, after the first, played to the last finding it watches.
459
+ const watchRun = Boolean(watch) && still.size > 0 && i > 0 && i === runs - 1;
460
+ let watched = false;
436
461
  const at = now();
437
462
  const dir = tempDir ? await tempDir() : null;
438
463
  let driver = null;
@@ -442,33 +467,56 @@ export async function replayWebFindings({ report, index = [], traceSteps = new M
442
467
  await driver.observe();
443
468
  let before = null;
444
469
  try { before = fingerprint(await driver.screenProbe()); } catch { before = null; }
445
- for (let n = 0; n < last; n++) {
470
+ for (let n = 0; n < (watchRun ? lastStill : last); n++) {
446
471
  if (now() > deadline) break;
447
472
  const entry = trace[n];
448
473
  // An input the run refused because the brief asks to stay out of it is never sent by the replay either.
449
474
  if (!entry.avoided) await driver.act(entry.action);
450
475
  let after = null;
451
476
  try { after = fingerprint(await driver.screenProbe()); } catch { after = null; }
452
- for (const hit of targets.filter(candidate => candidate.trace_steps === n + 1)) {
453
- // Where the run itself stood before this input: the screen after the input before it.
454
- const was = n > 0 ? trace[n - 1].print : null;
455
- const sameBefore = n > 0 ? same(before, was) : true;
456
- let verdict, detail;
457
- if (sameBefore === false) { verdict = 'diverged'; detail = 'the replay was on a different screen before this input'; }
458
- else if (entry.changed === false) {
459
- const quiet = same(before, after);
460
- verdict = quiet === null ? 'unchecked' : quiet ? 'match' : 'no_match';
461
- detail = quiet === null ? 'the screen could not be read to compare' : quiet ? 'the input changed nothing again' : 'the input changed the screen this time';
462
- } else {
477
+ // Where the run itself stood before this input: the screen after the input before it.
478
+ const was = n > 0 ? trace[n - 1].print : null;
479
+ const sameBefore = n > 0 ? same(before, was) : true;
480
+ const hits = targets.filter(candidate => candidate.trace_steps === n + 1);
481
+ const quiet = same(before, after);
482
+ // One watch for the step, from the screen the input left, when a finding of it says nothing happened and the input changed nothing again.
483
+ let seen = null;
484
+ if (watchRun && sameBefore !== false && quiet === true && hits.some(hit => still.has(hit.id))) {
485
+ seen = await Promise.resolve().then(() => watch(driver, { from: after, deadline, now })).catch(() => ({ verifiable: false, changed: null, gameMs: 0, why: 'the screen could not be watched' }));
486
+ }
487
+ for (const hit of hits) {
488
+ let verdict, detail, gameMs;
489
+ if (still.has(hit.id)) {
490
+ if (sameBefore === false) ({ verdict, detail } = watched ? { verdict: 'unverifiable', detail: 'not verifiable: the watch of an earlier finding moved the game on, so this moment was not reached again' } : { verdict: 'diverged', detail: 'the replay was on a different screen before this input' });
491
+ // An input the brief kept the run out of was never sent, by play or by the replay: its quiet screen says nothing.
492
+ else if (entry.avoided) ({ verdict, detail } = { verdict: 'unchecked', detail: 'the recorded input was never sent, as the brief asks to stay out of it, so nothing can be compared' });
493
+ else if (quiet === null) ({ verdict, detail } = { verdict: 'unchecked', detail: 'the screen could not be read to compare' });
494
+ else if (!quiet) ({ verdict, detail } = { verdict: 'no_match', detail: stuck.has(hit.id) ? 'the screen changed when the recorded input was played again' : 'the input changed the screen this time' });
495
+ // Quiet on a replay that does not watch: it counts beside a watch that found the screen still, and says nothing alone.
496
+ else if (!watchRun) ({ verdict, detail } = { verdict: 'unwatched', detail: 'the input changed nothing again' });
497
+ else if (!seen || !seen.verifiable) ({ verdict, detail } = { verdict: 'unverifiable', detail: `not verifiable: ${seen?.why || 'the screen could not be watched while game time ran'}` });
498
+ else if (seen.changed) ({ verdict, detail } = { verdict: 'no_match', detail: `the screen changed on its own while game time ran for ${seconds(seen.gameMs)} seconds with no input` });
499
+ else ({ verdict, detail, gameMs } = { verdict: 'match', gameMs: seen.gameMs, detail: `${entry.changed === false ? 'the input changed nothing again, and ' : ''}nothing on screen changed while game time ran for ${seconds(seen.gameMs)} seconds with no input` });
500
+ } else if (watchRun && watched) {
501
+ // After a watch the game is past the recording: this moment was not reached again, which says nothing about it.
502
+ continue;
503
+ } else if (sameBefore === false) { verdict = 'diverged'; detail = 'the replay was on a different screen before this input'; }
504
+ else {
463
505
  const again = same(after, entry.print);
464
506
  verdict = again === null ? 'unchecked' : again ? 'match' : 'no_match';
465
507
  detail = again === null ? 'the run kept no picture of the screen after this input to compare with' : again ? 'the same screen followed the input' : 'a different screen followed the input';
466
508
  }
467
- verdicts.get(hit.id).push({ verdict, detail });
509
+ verdicts.get(hit.id).push({ verdict, detail, ...(Number.isFinite(gameMs) ? { gameMs } : {}) });
510
+ }
511
+ if (seen) {
512
+ // The screen the next input is made on is the one the watch left.
513
+ watched = true;
514
+ try { after = fingerprint(await driver.screenProbe()); } catch { after = null; }
468
515
  }
469
516
  before = after;
470
517
  }
471
- if (scripted.size > 0 && now() < deadline) {
518
+ // The probes are run again where play ended, which a watch replay neither reaches nor leaves as it was.
519
+ if (!watchRun && scripted.size > 0 && now() < deadline) {
472
520
  const again = await observer.end(driver).catch(() => new Map());
473
521
  for (const id of scripted) if (again.has(id)) verdicts.get(id).push({ verdict: again.get(id) ? 'match' : 'no_match', detail: again.get(id) ? 'the probe was run again at the end of the replay and the same thing happened' : 'the probe was run again at the end of the replay and it did not happen' });
474
522
  }
@@ -483,14 +531,59 @@ export async function replayWebFindings({ report, index = [], traceSteps = new M
483
531
  longest = Math.max(longest, now() - at);
484
532
  }
485
533
  const results = [...targets, ...[...scripted].map(id => ({ id, trace_steps: trace.length }))].map(entry => {
486
- const all = verdicts.get(entry.id);
487
- const usable = all.filter(item => item.verdict !== 'unchecked');
488
534
  const base = { id: entry.id, trace_steps: entry.trace_steps };
535
+ let all = verdicts.get(entry.id);
489
536
  if (all.length === 0) return { ...base, state: 'not_run', runs: 0, of: 0, detail: problem || (scripted.has(entry.id) ? 'the replay ran out of its time before the probe could be run again' : 'the replay ran out of its time before it reached this input') };
537
+ // "Nothing happened" needs a watch (the hosted replayResult): a replay that could not watch, and one that only saw the input change
538
+ // nothing again, say nothing alone. With no replay that saw the screen change and no watch that found it still, it is not verifiable.
539
+ const blind = all.filter(item => item.verdict === 'unverifiable');
540
+ const unwatched = all.filter(item => item.verdict === 'unwatched');
541
+ const negative = all.some(item => item.verdict === 'no_match');
542
+ const watchedStill = all.some(item => item.verdict === 'match' && Number.isFinite(item.gameMs));
543
+ if ((blind.length || unwatched.length) && !negative && (blind.length || !watchedStill)) {
544
+ return { ...base, state: 'not_possible', runs: 0, of: 0, detail: blind[0]?.detail || `not verifiable: the input changed nothing again on ${unwatched.length} ${unwatched.length === 1 ? 'replay' : 'replays'}, and no replay was left to watch the screen with game time running` };
545
+ }
546
+ // Beside a watch that found the screen still, a quiet replay that did not watch is one more match; beside one that saw it change, it is nothing.
547
+ all = all.filter(item => item.verdict !== 'unverifiable').map(item => (item.verdict !== 'unwatched' ? item : watchedStill && !negative ? { ...item, verdict: 'match' } : null)).filter(Boolean);
548
+ const usable = all.filter(item => item.verdict !== 'unchecked');
490
549
  if (usable.length === 0) return { ...base, state: 'not_possible', runs: 0, of: 0, detail: all[0].detail };
491
550
  const matched = usable.filter(item => item.verdict === 'match').length;
492
551
  const diverged = usable.filter(item => item.verdict === 'diverged').length;
493
- return { ...base, state: matched === usable.length ? 'reproduced' : matched === 0 && diverged > 0 ? 'diverged' : 'not_reproduced', runs: matched, of: usable.length, detail: [...new Set(usable.map(item => item.detail))].join('; ') };
552
+ const state = matched === usable.length ? 'reproduced' : matched === 0 && diverged > 0 ? 'diverged' : 'not_reproduced';
553
+ // How long game time ran, at least, in the watches that found the screen still: what lets "nothing happens" count as reproduced (./judge.js).
554
+ const watches = usable.filter(item => item.verdict === 'match' && Number.isFinite(item.gameMs));
555
+ const words = state === 'reproduced' && watches.length ? watches : usable;
556
+ return { ...base, state, runs: matched, of: usable.length, ...(state === 'reproduced' && watches.length ? { watched_ms: Math.min(...watches.map(item => item.gameMs)) } : {}), detail: [...new Set(words.map(item => item.detail))].join('; ') };
494
557
  });
495
- return finish({ ran: made > 0, runs: made, skipped: made > 0 ? null : problem, elapsed_ms: now() - started }, [...results, ...rest]);
558
+ return finish({ ran: made > 0 || earlier.length > 0, runs: Math.max(made, ...earlier.map(result => Number(result.of) || 0)), skipped: made > 0 || earlier.length > 0 ? null : problem, elapsed_ms: now() - started }, [...results, ...earlier, ...rest]);
559
+ }
560
+
561
+ /* ------------------------------------------- the watch the claim judge asks */
562
+
563
+ /**
564
+ * The evidence the claim judge needs for claims that nothing happens, on a
565
+ * web run, before the report is settled: for each, what the run measured of
566
+ * its input (./stillWatch.js noEffectTries), and for each one measured, a
567
+ * replay of the recorded inputs that watches the screen while game time runs
568
+ * (replayWebFindings with every target watched). Nothing is written here; the
569
+ * judge keeps a `still_check` line per claim, and the replay after the report
570
+ * writes the results it reuses.
571
+ *
572
+ * @param {Object} args `wanted`: [{id, action}], and replayWebFindings' own arguments
573
+ * @returns {Promise<Map<string, {measured: Object|null, replay: Object|null}>>}
574
+ */
575
+ export async function watchClaimsStill({ wanted = [], trace = [], traceSteps = new Map(), replay = replayWebFindings, ...rest }) {
576
+ const out = new Map();
577
+ const measured = new Map();
578
+ for (const { id, action } of wanted) {
579
+ const steps = Number.isInteger(action) ? traceSteps.get(action) : undefined;
580
+ const tries = noEffectTries(trace, steps);
581
+ out.set(id, { measured: tries, replay: null });
582
+ if (tries) measured.set(id, action);
583
+ }
584
+ if (measured.size === 0) return out;
585
+ const pass = await replay({ ...rest, trace, traceSteps, report: { findings: [...measured.keys()].map(id => ({ id, severity: 'major' })) },
586
+ index: [...measured].map(([id, action]) => ({ id, action })), stuck: new Set(measured.keys()), transcript: { write() {} } });
587
+ for (const result of pass.results || []) if (out.has(result.id)) out.set(result.id, { ...out.get(result.id), replay: result });
588
+ return out;
496
589
  }
@@ -0,0 +1,114 @@
1
+ // The game's own Ravensight SDK opening its session, on a local web run.
2
+ //
3
+ // A web game's SDK opens a session (POST /api/v1/session, with the build's
4
+ // ingest key in X-API-Key and the run's playtest tag) before it sends any
5
+ // event. When the server refuses that session, the SDK sends nothing: the
6
+ // run has none of the game's events to read as ground truth, and nothing is
7
+ // recorded in the game's analytics. The server refuses a playtest run's tag
8
+ // on a public key by design (a public key ships inside every build; only a
9
+ // cloud run's runner, which keeps its tag out of the page, may carry one), so
10
+ // a local run of a build with a public key records no game events.
11
+ //
12
+ // The proof run of 2026-11-19 (pt_job_7b2fcf8b8bf3eb3a000a) had exactly that,
13
+ // and its report called the 403 "the signed-out session-check pattern". Here
14
+ // the driver reads each answer to the SDK's session request (status, key
15
+ // kind, whether it carried the tag, the error code; never the key or the
16
+ // token), and the report says plainly that no game events were recorded and
17
+ // why. Nothing here changes a request or asks a model anything.
18
+
19
+ const SESSION_PATH = /\/api\/v1\/session\/?$/;
20
+ const ERROR_CODE = /^[a-z0-9_]{1,60}$/;
21
+
22
+ /** What kind of ingest key a request carried, by its prefix only; null when it carried no Ravensight key. */
23
+ function keyKind(value) {
24
+ const key = String(value || '').trim();
25
+ if (!key.startsWith('gt_')) return null;
26
+ if (key.startsWith('gt_pub_')) return 'public';
27
+ if (key.startsWith('gt_live_')) return 'live';
28
+ return 'other';
29
+ }
30
+
31
+ /**
32
+ * The answer to one request, when it is the game's own Ravensight SDK
33
+ * opening its session: `{ status, key, tagged, error }`, else null. Never
34
+ * throws.
35
+ *
36
+ * @param {any} response a Playwright response
37
+ * @returns {Promise<{status: number, key: string, tagged: boolean, error: string|null}|null>}
38
+ */
39
+ export async function sdkSessionAnswer(response) {
40
+ try {
41
+ if (!response || typeof response.request !== 'function') return null;
42
+ const request = response.request();
43
+ if (!request || typeof request.method !== 'function' || request.method() !== 'POST') return null;
44
+ const url = new URL(typeof request.url === 'function' ? request.url() : response.url());
45
+ if (!/^https?:$/.test(url.protocol) || !SESSION_PATH.test(url.pathname)) return null;
46
+ const headers = typeof request.headers === 'function' ? request.headers() || {} : {};
47
+ const key = keyKind(headers['x-api-key']);
48
+ if (!key) return null;
49
+ const status = Number(response.status());
50
+ if (!Number.isInteger(status)) return null;
51
+ let error = null;
52
+ if (status >= 400) {
53
+ const body = await Promise.resolve().then(() => response.json()).catch(() => null);
54
+ if (body && typeof body.error === 'string' && ERROR_CODE.test(body.error)) error = body.error;
55
+ }
56
+ return { status, key, tagged: Boolean(String(headers['x-ravensight-playtest'] || '').trim()), error };
57
+ } catch {
58
+ return null;
59
+ }
60
+ }
61
+
62
+ /** The run's record of the SDK's session answers: how many opened, and each kind of refusal, counted. */
63
+ export function createSdkSessions() {
64
+ let opened = 0;
65
+ const refused = new Map();
66
+ return {
67
+ record(answer) {
68
+ if (!answer || !Number.isInteger(answer.status)) return;
69
+ if (answer.status >= 200 && answer.status < 300) { opened += 1; return; }
70
+ if (answer.status < 400) return;
71
+ const id = `${answer.status}|${answer.error || ''}|${answer.key}|${answer.tagged}`;
72
+ const seen = refused.get(id) || { status: answer.status, key: answer.key, tagged: answer.tagged, error: answer.error || null, times: 0 };
73
+ seen.times += 1;
74
+ refused.set(id, seen);
75
+ },
76
+ summary() {
77
+ return { opened, refused: [...refused.values()].map(entry => ({ ...entry })) };
78
+ }
79
+ };
80
+ }
81
+
82
+ /** The refusal the run had, when the SDK asked for a session and none ever opened; null otherwise. */
83
+ export function sessionRefusal(summary) {
84
+ if (!summary || summary.opened > 0 || !Array.isArray(summary.refused) || summary.refused.length === 0) return null;
85
+ return { ...summary.refused.reduce((most, entry) => (entry.times > most.times ? entry : most)) };
86
+ }
87
+
88
+ const codeWords = refusal => `${refusal.status}${refusal.error ? ` ${refusal.error}` : ''}`;
89
+
90
+ /** Why, in plain words, for the refusals the server gives a reason for; empty for the rest. */
91
+ function because(refusal) {
92
+ if (refusal.error === 'public_key_forbidden' && refusal.tagged) return ' The build sends a public ingest key, and a public key cannot carry a local playtest run\'s tag, so a local run of this build cannot record them; a cloud playtest of the same build records them.';
93
+ if (refusal.error === 'tracking_disabled') return ' The server said tracking is switched off for this game.';
94
+ if (refusal.error === 'playtest_job_closed') return ' The server said this playtest had already finished.';
95
+ if (refusal.error === 'invalid_playtest_token') return ' The server did not accept the run\'s playtest tag for the game this build\'s key belongs to.';
96
+ return '';
97
+ }
98
+
99
+ /**
100
+ * The plain statement report.md carries under "Measured from the game's own
101
+ * events" when the SDK's session was refused.
102
+ *
103
+ * @param {{status: number, error: string|null, key: string, tagged: boolean}} refusal
104
+ */
105
+ export function refusedEventsBody(refusal) {
106
+ return `No game events were recorded in this run. The game's Ravensight SDK asked to open its session and the server refused it (${codeWords(refusal)}), so the SDK sent none of its events.${because(refusal)} Nothing in this report was measured from the game's own events.`;
107
+ }
108
+
109
+ /** What the report step is told, so its network notes say the same thing and never call the refusal benign. */
110
+ export function refusedReportInstruction(refusal) {
111
+ return `The game's own Ravensight SDK asked to open its analytics session and the server refused it (${codeWords(refusal)}), so no game events were recorded in this run.${because(refusal)} When report.md lists this request under "Network notes", say exactly that: it is not a sign-in check, never call it benign, expected or harmless, and do not write that it caused no problem. It is not a finding about the game either.`;
112
+ }
113
+
114
+ export default { sdkSessionAnswer, createSdkSessions, sessionRefusal, refusedEventsBody, refusedReportInstruction };
@@ -0,0 +1,123 @@
1
+ // A claim that nothing happens, on a local web run, held to the hosted
2
+ // runner's evidence: the run measured it (the same control pressed again and
3
+ // again, changing nothing every time and answering at no other moment), and
4
+ // a replay watched the screen while game time ran with no input and nothing
5
+ // on it changed. The watch is the hosted runner's own (the platform repo,
6
+ // infrastructure/hosted-playtest/direct-runner/lib/verify.mjs watchStill,
7
+ // and STILL_MIN_GAME_MS in lib/claims.mjs), ported: the replay plays the
8
+ // recorded inputs to the claim's input, lets game time run, and compares
9
+ // every frame with the screen the input left. The gate that reads the result
10
+ // is ./judge.js, by the hosted gate's stuck rule.
11
+ //
12
+ // Nothing here asks a model anything, and a watch that cannot show game time
13
+ // ran is never counted as still: it is "not verifiable", with the reason.
14
+ import { DEAD_END_AFTER } from './anygame/memory.js';
15
+
16
+ /** A claim that nothing happens is confirmed only when nothing on screen changed over at least this much game time with no input. */
17
+ export const STILL_MIN_GAME_MS = 2000;
18
+ /** The watch gives up after this much wall time. */
19
+ export const STILL_WALL_CAP_MS = 8 * 1000;
20
+
21
+ /* c8 ignore start */
22
+ /** Runs in the page: lets `ms` of the page's own clock pass and counts the frames it drew meanwhile. The hosted runner's own. */
23
+ export function pageClockWindow(ms) {
24
+ return new Promise(resolve => {
25
+ const t0 = performance.now();
26
+ let frames = 0, done = false;
27
+ const end = () => { if (done) return; done = true; resolve({ ms: performance.now() - t0, frames }); };
28
+ const tick = () => { frames++; if (performance.now() - t0 >= ms) end(); else requestAnimationFrame(tick); };
29
+ requestAnimationFrame(tick);
30
+ setTimeout(end, ms + 1500);
31
+ });
32
+ }
33
+ /* c8 ignore stop */
34
+
35
+ /**
36
+ * Watch the screen with no input while game time runs: the hosted watch with
37
+ * no time gate, where the page's clock is the game's and the frames it drew
38
+ * are counted, so a page that is not running is not taken for a still game.
39
+ * The caller lets go of any gate of its own first (./timeFreeze.js).
40
+ *
41
+ * @param {Object} args
42
+ * @param {(ms: number) => Promise<{ms: number, frames: number}|null>} args.clockWindow the page's clock over a window (pageClockWindow, in the page)
43
+ * @param {() => Promise<any>} args.shot the screen now, as `differs` compares it; null when it cannot be read
44
+ * @param {any} args.from the screen the input left
45
+ * @param {(a: any, b: any) => boolean} args.differs whether a player would notice a difference
46
+ * @returns {Promise<{verifiable: boolean, changed: boolean|null, gameMs: number, why: string|null}>}
47
+ */
48
+ export async function watchStill({ clockWindow, shot, from, differs, minGameMs = STILL_MIN_GAME_MS, capMs = STILL_WALL_CAP_MS, deadline = Infinity, now = Date.now }) {
49
+ const started = now();
50
+ const until = Math.min(started + capMs, deadline);
51
+ const frames = [];
52
+ let gameMs = 0, drawn = 0, why = null;
53
+ while (gameMs < minGameMs && now() < until) {
54
+ const r = await Promise.resolve().then(() => clockWindow(Math.max(100, Math.min(1000, minGameMs - gameMs)))).catch(() => null);
55
+ if (!r || !Number.isFinite(r.ms) || r.ms <= 0) { why = 'the page did not answer while it was watched'; break; }
56
+ gameMs += r.ms; drawn += Number(r.frames) || 0;
57
+ frames.push(await Promise.resolve().then(() => shot()).catch(() => null));
58
+ }
59
+ if (!why && drawn < 2) why = 'the page drew no frames while it was watched, so its time cannot be shown to have run';
60
+ if (!why && gameMs < minGameMs) why = `game time ran for ${(gameMs / 1000).toFixed(1)} of the ${(minGameMs / 1000).toFixed(1)} seconds the watch needs`;
61
+ if (!why && frames.some(frame => frame === null || frame === undefined)) why = 'the screen could not be read while it was watched';
62
+ if (why) return { verifiable: false, changed: null, gameMs: Math.round(gameMs), why };
63
+ return { verifiable: true, changed: frames.some(frame => differs(from, frame)), gameMs: Math.round(gameMs), why: null };
64
+ }
65
+
66
+ /**
67
+ * The watch on a playwright_web driver (a replay's): game time is let go for
68
+ * the watch (a canvas game's clock is parked between inputs) and parked again
69
+ * after it, whatever happens.
70
+ *
71
+ * @param {Object} driver
72
+ * @param {{from: any, fingerprint: Function, differs: Function, deadline?: number, now?: Function}} opts
73
+ */
74
+ export async function watchWebStill(driver, { from, fingerprint, differs, deadline = Infinity, now = Date.now }) {
75
+ const session = driver && typeof driver.edgeSession === 'function' ? driver.edgeSession() : null;
76
+ if (!session || !session.page || typeof session.page.evaluate !== 'function') return { verifiable: false, changed: null, gameMs: 0, why: 'this run has no page it can watch' };
77
+ await Promise.resolve().then(() => session.releaseClock && session.releaseClock()).catch(() => {});
78
+ try {
79
+ return await watchStill({
80
+ clockWindow: ms => session.page.evaluate(pageClockWindow, ms),
81
+ shot: async () => fingerprint(await driver.screenProbe()),
82
+ from, differs, deadline, now
83
+ });
84
+ } finally {
85
+ await Promise.resolve().then(() => session.parkClock && session.parkClock()).catch(() => {});
86
+ }
87
+ }
88
+
89
+ /** The control a click names, by its accessible name: a point on a canvas, or a ref read off one screen, is not one. */
90
+ function controlOf(entry) {
91
+ const action = entry && entry.action;
92
+ if (!action || action.kind !== 'click' || typeof action.target !== 'string') return null;
93
+ const name = action.target.trim();
94
+ return name ? name : null;
95
+ }
96
+
97
+ /**
98
+ * What the run measured of the input a claim that nothing happens is placed
99
+ * at: the same named control pressed at least DEAD_END_AFTER times (the
100
+ * any-game memory's own rule for a dead end), the page taking every press and
101
+ * the screen changing on none, and the control answering at no other moment
102
+ * of the run (the hosted report's rule: a control that answered once depends
103
+ * on the game's state, and is not dead). Null otherwise.
104
+ *
105
+ * @param {Array<{action: Object, ok: boolean, changed: boolean|null, avoided?: boolean}>} trace the run's web inputs (./reportChecks.js traceWebInputs)
106
+ * @param {number} steps the inputs played by the end of the claim's action (its trace length then)
107
+ * @returns {{target: string, tries: number, steps: Array<number>}|null}
108
+ */
109
+ export function noEffectTries(trace, steps, { min = DEAD_END_AFTER } = {}) {
110
+ if (!Array.isArray(trace) || !Number.isInteger(steps) || steps < 1 || steps > trace.length) return null;
111
+ const at = trace[steps - 1];
112
+ const name = controlOf(at);
113
+ if (!name || at.ok !== true || at.changed !== false || at.avoided) return null;
114
+ const key = name.toLowerCase();
115
+ const same = [];
116
+ trace.forEach((entry, i) => { if (controlOf(entry)?.toLowerCase() === key) same.push({ entry, step: i + 1 }); });
117
+ if (same.some(({ entry }) => entry.changed === true)) return null;
118
+ const tries = same.filter(({ entry }) => entry.ok === true && entry.changed === false && !entry.avoided);
119
+ if (tries.length < min) return null;
120
+ return { target: name, tries: tries.length, steps: tries.map(({ step }) => step) };
121
+ }
122
+
123
+ export default { STILL_MIN_GAME_MS, STILL_WALL_CAP_MS, pageClockWindow, watchStill, watchWebStill, noEffectTries };