ravensight-playtest 0.13.0 → 0.13.2

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/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');
@@ -33,18 +33,23 @@ import { recordingMetadata, saveRecording } from './drivers/recording.js';
33
33
  import { createTranscript } from './transcript.js';
34
34
  import { createUsageLedger, writeUsageFile } from './usage.js';
35
35
  import { fillPlaceholders, fillReportPlaceholders } from './placeholders.js';
36
- import { sweepTurnedAway } from './claimGate.js';
36
+ import { repeatsTurnedAway, sweepTurnedAway } from './claimGate.js';
37
+ // The intent check (./intent.js): each input held against the screen after it, a repeated miss not sent again, what the run
38
+ // played, and the in-character section held to the record.
39
+ import { annotateActionLog, createIntentWatch, goalsOf, holdInCharacter, intentReportLines, movementInput, playedScope, withPlayedLine } from './intent.js';
37
40
  // The claim judge and the hosted runner's own claim words, check questions and event rules.
38
41
  import { claimShape, judgeIssue, legacyIssue, impressionOf } from './judge.js';
39
42
  import { EVENTS_RULE, eventsBlock, eventsReportLines, eventsUsage, withEventEvidence } from './events.js';
40
43
  import { memoryBlock, extractLocalNotes, gameMemoryBody } from './gameMemory.js';
41
- import { CLAIM_SYSTEM, CLAIM_WIRE, claimText, claimRead, claimMessage } from './claimwords.js';
44
+ import { CLAIM_SYSTEM, CLAIM_WIRE, checkSaid, claimText, claimRead, claimMessage } from './claimwords.js';
42
45
  import { CLAIM_FAULT_SYSTEM, claimCheckSystem, claimReply, claimFormatRepair, MAX_CLAIM_REPLY_TEXT } from './claimProtocol.js';
43
46
  import { captureNotes, createCaptureWatch, rewriteStaleEvidence, staleSentence } from './captureCheck.js';
44
47
  import { gameRefusal } from './gameRefusal.js';
45
48
  import { BUILT_IN_NOISE, expectedNoiseForPrompt, isExpectedNoise } from './noise.js';
46
- import { cutFindingFrames, moodOf, replayCapabilityNote, replayFindings, replayWebFindings, screenOf, traceWebInputs } from './reportChecks.js';
49
+ import { cutFindingFrames, moodOf, replayCapabilityNote, replayFindings, replayWebFindings, screenOf, traceWebInputs, watchClaimsStill } from './reportChecks.js';
47
50
  import { pngFingerprint, screenDelta, significant } from './pixels.js';
51
+ import { watchWebStill } from './stillWatch.js';
52
+ import { refusedEventsBody, refusedReportInstruction, sessionRefusal } from './sdkSession.js';
48
53
  import { mkdtemp } from 'node:fs/promises';
49
54
  import os from 'node:os';
50
55
  import { MIN_PASSWORD_CHARS } from '../briefLocal.js';
@@ -212,6 +217,7 @@ export const PLAY_NOTES = [
212
217
  '- Every action answers with the screen that followed, so do not call snapshot after an action; call it only to look again after a wait.',
213
218
  '- Each turn spends the run\'s model budget, and the budget, not the action count, usually ends a run. Do not spend turns looking twice. When the next two or three inputs are plain (close a dialog, then press Start; end three turns in a row), send them as separate tool calls in ONE turn.',
214
219
  '- Say what you expect an action to do (expect). When the brief tells you to pick an option (a faction, a character, a class, a mode, a difficulty), read the options on the screen first, make exactly that choice, and check on the next screen that it is the one in effect. If it is not, say so in a note at once.',
220
+ '- On your next tool call after an input with expect, say whether the screen shows it: intent_check "met", or "missed" with instead (what the screen shows, copied as drawn). Trust the screen over what you believe: a key that brings up something else did not do what you meant, however often the screen changes. An input that missed the same result twice in a row is not sent a third time: reach the target another way first (walk to it with the arrow keys or W A S D, click it, or read what the screen says each key does).',
215
221
  '- Keep playing in scope beyond a first win or partial goal. When the brief gives explicit success criteria, complete all of them and their requested verification, then use the completion statement below to stop while preserving the requested end state. Without a completed brief, explore until your actions or budget run out or a persona stop condition fires.',
216
222
  '- When you do stop, use the brief completion statement if applicable, otherwise one short sentence, and no tool call. Never write the report here: a separate step writes it from your notes.',
217
223
  '- The screen text or the scene outline can be cut short, and a picture is only sent when the text is not enough. When you need to see the screen, call screenshot: its result shows you the picture. What this runner could not show you, could not click or does not offer is a limit of the runner: mention it in a note of kind reaction if you must, never as a bug, a confusing or a suggestion note.'
@@ -245,8 +251,11 @@ export function personaQuitDetail(text) {
245
251
  return `${space > 40 ? cut.slice(0, space) : cut}...`;
246
252
  }
247
253
 
248
- /** The stop detail when play ends to keep the report's budget. */
249
- export const RESERVE_STOP_DETAIL = 'stopped early so the rest of the model budget pays for the report';
254
+ /**
255
+ * The stop detail when play ends to keep the report's budget. A run that got here played to its budget: it is never said to
256
+ * have stopped early (the paid local run of 2026-11-20 played 39 of its 40 actions and its report said "stopped early").
257
+ */
258
+ export const RESERVE_STOP_DETAIL = 'played to its budget: play stopped so the rest of the model budget pays for the report';
250
259
 
251
260
  /**
252
261
  * @typedef {Object} PersonaRunOutcome
@@ -349,6 +358,8 @@ export async function runPersona(args) {
349
358
  videoPath: null,
350
359
  usage: null,
351
360
  runDirectory,
361
+ // The run's action limit: what "played to its budget" is said against (./intent.js).
362
+ maxActions,
352
363
  // The last state the SERVER accepted, which is not the same thing as the
353
364
  // outcome: the caller has to know whether this run ever reached
354
365
  // `reporting`, because the server's table only allows `uploading` from
@@ -396,6 +407,8 @@ export async function runPersona(args) {
396
407
  });
397
408
  imageBudget = play.imageBudget;
398
409
  outcome = { ...outcome, ...play };
410
+ // The intent check's record for usage.json (./intent.js); what the run played is added once the report has it.
411
+ outcome.intent = honesty.intent ? honesty.intent.summary() : null;
399
412
 
400
413
  const endedAt = new Date().toISOString();
401
414
  // When the recording began, read before the driver is stopped: a finding's
@@ -421,6 +434,7 @@ export async function runPersona(args) {
421
434
  // No positive remaining budget was established by the refusal.
422
435
  // Preserve the notes without authorizing another model call.
423
436
  await writeSomeReport({ outcome, runDirectory, persona, driverName, target, notes, screenshots, actionRecords, play, skill, ledger, runId, jobId, startedAt, endedAt, log, honesty, observations });
437
+ outcome.scope = scopeForUsage(honesty.scope);
424
438
  return finish(outcome, ledger, runDirectory, transcript, heartbeat);
425
439
  }
426
440
 
@@ -428,8 +442,24 @@ export async function runPersona(args) {
428
442
  if (args.signal?.aborted || heartbeat?.canceled) throw new Error('The playthrough was interrupted before reporting.');
429
443
  onProgress({ phase: 'reporting', persona: persona.slug });
430
444
 
445
+ // A web run's replays: the watch the claim judge asks for a claim that nothing happens (./stillWatch.js), and the replay of
446
+ // the findings after the report, which writes the watch's results as they are rather than playing them again.
447
+ const playMs = Date.parse(endedAt) - Date.parse(startedAt);
448
+ const differs = (a, b) => { const delta = screenDelta(a, b); return delta === null || significant(delta); };
449
+ const webReplay = args.replayFindings !== false && Array.isArray(driver.webTrace) && typeof args.replayDriver === 'function'
450
+ ? { trace: driver.webTrace, traceSteps: honesty.traceSteps, makeDriver: args.replayDriver, target, viewport, playMs, signal: args.signal, fingerprint: pngFingerprint, differs,
451
+ tempDir: () => mkdtemp(path.join(os.tmpdir(), 'rs-replay-')), watch: (replayDriver, at) => watchWebStill(replayDriver, { ...at, fingerprint: pngFingerprint, differs }) }
452
+ : null;
453
+ const watchedStill = new Map();
454
+ const stillReplay = webReplay ? async wanted => {
455
+ const answered = await watchClaimsStill({ wanted, ...webReplay });
456
+ for (const { id, title } of wanted) if (answered.get(id)?.replay) watchedStill.set(id, { title, replay: answered.get(id).replay });
457
+ return answered;
458
+ } : null;
459
+
431
460
  const written = await reportPhase({
432
461
  claimGate: args.claimGate === 'legacy' ? 'legacy' : 'judge',
462
+ stillReplay,
433
463
  client,
434
464
  jobId,
435
465
  runId,
@@ -461,11 +491,14 @@ export async function runPersona(args) {
461
491
  // the step log per finding. It never changes the report or fails the run.
462
492
  if (args.replayFindings !== false) {
463
493
  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-')),
494
+ ? replayWebFindings({ report: written.report, index: written.index || [], traceSteps: honesty.traceSteps, trace: driver.webTrace, makeDriver: args.replayDriver, target, viewport, playMs, transcript, signal: args.signal,
495
+ fingerprint: pngFingerprint, differs, tempDir: () => mkdtemp(path.join(os.tmpdir(), 'rs-replay-')),
496
+ // A finding placed at an input that changed nothing is watched on the last replay, as on a cloud run; a claim the judge
497
+ // already had watched is written as it was (only the judge's watched claims say nothing happens by their words).
498
+ ...(webReplay ? { watch: webReplay.watch } : {}), prior: watchedFor(written.report, watchedStill),
466
499
  // [tester hook] The probes that found something are run once more at the end of this one replay (./testerProbes.js probeObserver).
467
500
  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 });
501
+ : replayFindings({ report: written.report, index: written.index || [], traceSteps: honesty.traceSteps, runDirectory, driver, playMs, transcript, signal: args.signal });
469
502
  await replayed
470
503
  .then(pass => {
471
504
  // A game that started differently on replay is a limit of the runner: a capability note, never a finding.
@@ -478,6 +511,8 @@ export async function runPersona(args) {
478
511
  }
479
512
 
480
513
  outcome.report = written.report;
514
+ // What the run played, as report.md says it, for usage.json (the hosted runner's `scope`; the server's evidence report reads its line).
515
+ outcome.scope = scopeForUsage(honesty.scope);
481
516
  // What the runner met and could not do, for the complete call (./thinRun.js capabilityNotesBody).
482
517
  outcome.capabilityNotes = honesty.capability.list();
483
518
  outcome.reportMarkdown = written.markdown;
@@ -488,6 +523,8 @@ export async function runPersona(args) {
488
523
  // What the game's own events measured, for usage.json (./events.js eventsUsage).
489
524
  const eventRun = gameEventsRun(honesty);
490
525
  outcome.gameEvents = eventRun ? eventsUsage(eventRun) : null;
526
+ // A session the server refused: no game events, and why, in usage.json too.
527
+ 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
528
  // The notes this run hands on to the next playtest of the game, when the game's memory asked for them (./gameMemory.js).
492
529
  if (memory && memory.save === true) {
493
530
  const handed = gameMemoryBody(memory, extractLocalNotes({ digest: honesty.anygame ? honesty.anygame.digest() : null, turnedAway: written.turnedAway || [] }));
@@ -553,6 +590,9 @@ export async function runPersona(args) {
553
590
  }
554
591
  // Sent to the server as the run's reason, so it is as safe as the report.
555
592
  outcome.quitDetail = safeErrorDetail(error, localBrief);
593
+ // The intent check's record and what the run played, kept in usage.json for a run that did not finish its report too.
594
+ if (honesty.intent) outcome.intent = honesty.intent.summary();
595
+ if (honesty.scope) outcome.scope = scopeForUsage(honesty.scope);
556
596
  transcript.write({ kind: 'error', message: outcome.quitDetail });
557
597
  await finish(outcome, ledger, runDirectory, transcript, heartbeat);
558
598
  throw Object.assign(error, { outcome });
@@ -875,6 +915,9 @@ async function playLoop({
875
915
  const briefFields = brief && brief.fields && typeof brief.fields === 'object' ? brief.fields : brief || {};
876
916
  const anyGame = honesty.anygame || (honesty.anygame = createLocalAnyGame({ briefText: briefForPrompt(brief), controls: briefFields.build_notes && typeof briefFields.build_notes.controls === 'string' ? briefFields.build_notes.controls : null, touch: Boolean(driver && driver.touch), continuousTime: driver?.inputProfile === 'native-mobile' && driver.frozenBetweenActions === false, driverName: typeof driver.soundSelfTest === 'function' ? '' : driverName }));
877
917
  system.push({ type: 'text', text: anyGame.systemText() });
918
+ // The intent check (./intent.js): one watch a run, on the honesty record so the report step reads the same one. Every answer,
919
+ // miss and refused repeat is a line of the step log.
920
+ const intentWatch = honesty.intent || (honesty.intent = createIntentWatch({ goals: goalsOf(brief), onEvent: line => transcript.write(line) }));
878
921
  // What earlier playtests of this game learned (./gameMemory.js): the same block every request carries, so it is cached.
879
922
  const earlier = earlierMemory && earlierMemory.save !== false ? memoryBlock(earlierMemory) : '';
880
923
  if (earlier) {
@@ -1091,9 +1134,9 @@ async function playLoop({
1091
1134
  reserveStopped = true;
1092
1135
  quitReason = 'budget_exhausted';
1093
1136
  quitDetail = reserve.figures.stop_reason === 'act_projection'
1094
- ? 'stopped early because the next action reservation exceeds the remaining model budget'
1137
+ ? 'played to its budget: the next action\'s reservation would not fit in the model budget left'
1095
1138
  : reserve.figures.stop_reason === 'act_projection_and_report_reserve'
1096
- ? 'stopped early because the next action reservation and the report reserve exceed the remaining model budget'
1139
+ ? 'played to its budget: the next action\'s reservation and the report reserve would not fit in the model budget left'
1097
1140
  : RESERVE_STOP_DETAIL;
1098
1141
  transcript.write({ kind: 'budget_reserve_stop', ...reserve.figures });
1099
1142
  log(`stopping play after ${actions} action(s): ${quitDetail} (spent about $${reserve.figures.usd_spent} of $${reserve.figures.usd_max}; next action projection $${reserve.figures.act_projected_usd}; report reserve $${reserve.figures.report_reserve_usd}; reason ${reserve.figures.stop_reason}).`);
@@ -1379,6 +1422,8 @@ async function playLoop({
1379
1422
  // Every ref in this turn was read off the screen before it. Once one of
1380
1423
  // its actions changes the screen, a later ref may name something else.
1381
1424
  let screenChangedThisTurn = false;
1425
+ // The playtester's answer about its last input is read from this turn's calls until one of them plays an input (./intent.js).
1426
+ let answerOpen = true;
1382
1427
  for (const toolUse of answer.toolUses) {
1383
1428
  if (argsSignal?.aborted || heartbeat?.canceled) { canceled = true; quitReason = 'error'; quitDetail = 'the job was cancelled'; break; }
1384
1429
  if (selection && toolUse.id !== selection.toolId) { results.push({ type: 'tool_result', tool_use_id: toolUse.id, content: 'Alternative not selected. No action executed.' }); continue; }
@@ -1399,6 +1444,19 @@ async function playLoop({
1399
1444
  transcript.write({ kind: 'action_not_played', tool: toolUse.name, reason: 'tool_not_allowed_by_server' });
1400
1445
  continue;
1401
1446
  }
1447
+ // The intent check (./intent.js): the playtester's own answer about its last input, then an input that has missed the
1448
+ // same result twice in a row is not sent again; it is told what the screen showed instead and asked for another way.
1449
+ const checkedInput = toolUse.malformed ? null : redactToolInput(toolUse, secrets);
1450
+ if (answerOpen && checkedInput) intentWatch.answer(checkedInput, { first: true });
1451
+ if (checkedInput && ACTION_TOOLS.includes(toolUse.name)) {
1452
+ const repeated = intentWatch.refusal(toolUse.name, checkedInput, { turn: turns });
1453
+ if (repeated) {
1454
+ results.push(toolResult(toolUse.id, repeated));
1455
+ recentActions.push(`${toolUse.name}: not sent, it repeated a miss`);
1456
+ if (recentActions.length > 10) recentActions.shift();
1457
+ continue;
1458
+ }
1459
+ }
1402
1460
  const notesBefore = notes.length;
1403
1461
  const screenBefore = latestObservation;
1404
1462
  // A note about something wrong is about the screen as it is now, before
@@ -1476,6 +1534,13 @@ async function playLoop({
1476
1534
  };
1477
1535
  transcript.write(actionLine);
1478
1536
  actionRecords.push(actionLine);
1537
+ // The intent check: an input that reached the game is held against the screen after it (./intent.js).
1538
+ if (checkedInput && ACTION_TOOLS.includes(toolUse.name)) {
1539
+ const reached = !executed.error && !executed.refused;
1540
+ if (reached) answerOpen = false;
1541
+ intentWatch.played({ tool: toolUse.name, input: checkedInput, action: actions, turn: turns, ok: reached, changed: Boolean(executed.changed),
1542
+ pageText: executed.observation && !executed.observation.unchanged ? String(executed.observation.text || '') : '', thought: actionLine.thought || '' });
1543
+ }
1479
1544
  if (honesty.traceSteps && Number.isInteger(actionLine.trace_steps)) honesty.traceSteps.set(actions, actionLine.trace_steps);
1480
1545
  if (honesty.tester) honesty.tester.acted(actionLine); // [tester hook]
1481
1546
  if (executed.unsupported && honesty.capability.add(executed.unsupported)) {
@@ -1648,6 +1713,9 @@ async function playLoop({
1648
1713
  asides.push(stuckHint(unchanged, failedInputsOn(failedInputs, latestObservation)));
1649
1714
  }
1650
1715
 
1716
+ // The intent check: a miss the runner or the record found, and a part of the game to leave, said once (./intent.js).
1717
+ for (const notice of intentWatch.notices()) asides.push(notice);
1718
+
1651
1719
  // any-game hook: the play style once, and the notebook when screens have dropped out of context.
1652
1720
  const anyAside = anyGame.aside({ actions, dropped: staleObservationCount(observations.length, keepObservations) });
1653
1721
  if (anyAside) { asides.push(anyAside); transcript.write({ kind: 'any_game_aside', chars: anyAside.length }); }
@@ -1839,6 +1907,13 @@ async function playLoop({
1839
1907
  const kept = driver.gameEvents.record();
1840
1908
  if (kept.total > 0) transcript.write({ kind: 'game_events', total: kept.total, kept: kept.kept, clock: kept.clock, names: kept.names });
1841
1909
  }
1910
+ // The game's own SDK asked for its session and the server refused it, so none of its events reached the run (./sdkSession.js).
1911
+ const refusal = driver && typeof driver.sdkSessions === 'function' ? sessionRefusal(await Promise.resolve().then(() => driver.sdkSessions()).catch(() => null)) : null;
1912
+ if (refusal) {
1913
+ honesty.sdkSession = refusal;
1914
+ transcript.write({ kind: 'game_events_refused', status: refusal.status, error: refusal.error, key: refusal.key, tagged: refusal.tagged, times: refusal.times });
1915
+ log(refusedEventsBody(refusal));
1916
+ }
1842
1917
  if (completionRepairPending) transcript.write({ kind: 'brief_completion_repair_unavailable', reason: quitReason, detail: quitDetail, independently_verified: false });
1843
1918
  return {
1844
1919
  actionsTaken: actions,
@@ -1864,7 +1939,9 @@ async function playLoop({
1864
1939
  canceled,
1865
1940
  imageBudget,
1866
1941
  finalScreenshot: final ? final.relativePath : null,
1867
- actionLog: actionLogFrom(actionRecords)
1942
+ maxActions,
1943
+ // Each checked input's result rides on its entry of the action log (./intent.js).
1944
+ actionLog: annotateActionLog(actionLogFrom(actionRecords), intentWatch.checks())
1868
1945
  };
1869
1946
  }
1870
1947
 
@@ -1897,6 +1974,8 @@ async function reportPhase({
1897
1974
  endedAt,
1898
1975
  // 'judge' (the claim judge) or 'legacy' (a run whose findings decide money elsewhere: ./judge.js legacyIssue).
1899
1976
  claimGate = 'judge',
1977
+ // A web run's watch of a claim that nothing happens, asked by the judge (./stillWatch.js); null for any other run.
1978
+ stillReplay = null,
1900
1979
  log
1901
1980
  }) {
1902
1981
  // The report step never sees the test account: it has nothing to sign in
@@ -2238,7 +2317,7 @@ async function reportPhase({
2238
2317
  let impressions = [];
2239
2318
  if (!shrunk && !play.budgetExceeded) {
2240
2319
  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 });
2320
+ 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
2321
  report = checked.report;
2243
2322
  turnedAway = checked.turnedAway;
2244
2323
  impressions = checked.impressions;
@@ -2270,6 +2349,8 @@ async function reportPhase({
2270
2349
  const lines = eventsReportLines(eventRun, { findings: report.findings || [], turnedAway });
2271
2350
  if (lines.length > 0) markdown = replaceSection(markdown, EVENTS_HEADING, lines.slice(2).join('\n').replace(/\s+$/, ''));
2272
2351
  }
2352
+ // The game's own SDK was refused its session: said plainly where its events would be, never left to read as benign.
2353
+ if (honesty && honesty.sdkSession && !(eventRun && eventRun.gameEvents && eventRun.gameEvents.total > 0)) markdown = replaceSection(markdown, EVENTS_HEADING, refusedEventsBody(honesty.sdkSession));
2273
2354
  // What a screenshot shows comes from the picture: one taken while the picture lagged the game says so.
2274
2355
  markdown = rewriteStaleEvidence(markdown, (screenshots || []).filter(shot => shot && shot.stale && shot.relativePath));
2275
2356
  if (choiceCheck) {
@@ -2286,6 +2367,23 @@ async function reportPhase({
2286
2367
  const generatedAt = new Date().toISOString();
2287
2368
  const facts = reportFacts({ persona, driverName, target, play });
2288
2369
  markdown = stampGeneratedAt(markdown, generatedAt, facts);
2370
+ // What the run played (./intent.js), in the hosted report's words, under the stamp: a run that played to its budget is said
2371
+ // so, with how far it got and the result it aimed at and never reached.
2372
+ const scope = playScopeOf(play, honesty);
2373
+ if (scope) {
2374
+ markdown = withPlayedLine(markdown, scope.line);
2375
+ honesty.scope = scope;
2376
+ transcript.write({ kind: 'played_scope', line: scope.line });
2377
+ log(`what was played: ${scope.line}`);
2378
+ }
2379
+ // The in-character section held to the record: a sentence the record or the frames show otherwise is left out, and the
2380
+ // record's own fact said instead.
2381
+ const heldBack = holdInCharacter(markdown, { families: honesty && honesty.intent ? honesty.intent.families() : [], movedAtAll: couldMove(play.records), turnedAway, repeats: repeatsTurnedAway });
2382
+ if (heldBack.held.length > 0) {
2383
+ markdown = heldBack.markdown;
2384
+ transcript.write({ kind: 'in_character_held', sentences: heldBack.held.map(entry => ({ sentence: String(entry.sentence).slice(0, 300), fact: entry.fact })) });
2385
+ log(`held the in-character section to the run's record: ${heldBack.held.length} sentence(s) it shows otherwise left out.`);
2386
+ }
2289
2387
  // The same slots in the prose the dashboard shows from report.json.
2290
2388
  report = fillReportPlaceholders(report, { generatedAt, ...facts });
2291
2389
  // A finding the server would drop for want of an uploaded file it can
@@ -2329,9 +2427,54 @@ async function reportPhase({
2329
2427
  return { report, markdown, lint, index: honest.index, turnedAway };
2330
2428
  }
2331
2429
 
2430
+ /**
2431
+ * The watch results the judge's replay made, for the findings of the written
2432
+ * report that are the claims it watched (the same id and title: a runner's own
2433
+ * finding added after the judge may take the id of a claim it turned away).
2434
+ */
2435
+ export function watchedFor(report, watched) {
2436
+ const findings = report && Array.isArray(report.findings) ? report.findings : [];
2437
+ return new Map([...watched].filter(([id, entry]) => findings.some(finding => finding && finding.id === id && finding.title === entry.title)).map(([id, entry]) => [id, entry.replay]));
2438
+ }
2439
+
2332
2440
  /** The heading of the report's section on the game's own events, the hosted runner's own. */
2333
2441
  export const EVENTS_HEADING = '## Measured from the game\'s own events';
2334
2442
 
2443
+ /**
2444
+ * What the run played (./intent.js playedScope), from the play loop's result and the runner's record: the intent watch and the
2445
+ * game's own event names. Null with nothing to say.
2446
+ */
2447
+ export function playScopeOf(play, honesty) {
2448
+ if (!play || !honesty) return null;
2449
+ const run = gameEventsRun(honesty);
2450
+ const events = run && run.gameEvents && Array.isArray(run.gameEvents.events) ? run.gameEvents.events : [];
2451
+ // Event names are the build's own strings: only plain ones are repeated.
2452
+ const names = events.map(event => event && event.name).filter(name => typeof name === 'string' && /^[A-Za-z0-9_.:-]{1,40}$/.test(name));
2453
+ return playedScope({ watch: honesty.intent || null, actionsTaken: play.actionsTaken, maxActions: play.maxActions, quitReason: play.quitReason,
2454
+ reserveStopped: Boolean(play.reserveStopped), eventNames: names, eventTotal: run && run.gameEvents ? run.gameEvents.total : 0 });
2455
+ }
2456
+
2457
+ /** What the run played, in the shape usage.json carries it (`line` first: the server's evidence report reads it). */
2458
+ export function scopeForUsage(scope) {
2459
+ if (!scope || !scope.line) return null;
2460
+ return {
2461
+ line: scope.line,
2462
+ budget: Boolean(scope.budget),
2463
+ reached: scope.reached || null,
2464
+ not_reached: (scope.families || []).map(f => ({ expected: f.expected, input: f.input, misses: f.misses, refused: f.refused || 0, actions: f.actions, saw: f.saw })),
2465
+ parts: scope.parts || []
2466
+ };
2467
+ }
2468
+
2469
+ /**
2470
+ * Whether anything the run sent could have moved something across the game: a movement key, a held key, a drag, a stick, or
2471
+ * any pointer input (a click can walk a character in a point and click game). The in-character section is held to it.
2472
+ */
2473
+ export function couldMove(records) {
2474
+ return (Array.isArray(records) ? records : []).some(record => record && record.kind === 'action' && record.ok
2475
+ && (movementInput(record.tool, record.input || {}) || ['click', 'hover', 'drag', 'swipe', 'gamepad', 'pinch'].includes(record.tool)));
2476
+ }
2477
+
2335
2478
  /**
2336
2479
  * What the claim judge and the report read the game's own events from: one
2337
2480
  * object per run (the verdicts are kept against it), or null when the driver
@@ -2557,7 +2700,7 @@ export function citedAfterScreenshot(finding, screenshots) {
2557
2700
  *
2558
2701
  * @returns {Promise<{report: Object, turnedAway: Array<Object>, impressions: Array<Object>}>}
2559
2702
  */
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 = [] }) {
2703
+ 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
2704
  if (!report || !Array.isArray(report.findings)) return { report, turnedAway: [], impressions: [] };
2562
2705
  const placedIndex = Array.isArray(index) ? index : attachWhereToLook(report, { observations, notes, screenshots }).index;
2563
2706
  const where = new Map(placedIndex.map(entry => [entry.id, entry]));
@@ -2668,6 +2811,28 @@ export async function checkClaimsAgainstScreenshots({ client, jobId, runId, repo
2668
2811
  transcript.write({ kind: 'claim_check', id: finding.id, screenshot: shot.relativePath, ...on, ...(placed.look ? { look: true } : {}), ...record });
2669
2812
  checks.set(finding, { ...record, picture: shot.relativePath });
2670
2813
  }
2814
+ // A claim that nothing happens, which its picture did not contradict or explain: what the run measured of its input, and a replay
2815
+ // that watched the screen while game time ran (./stillWatch.js, the hosted gate's evidence). Only a web run has the hook.
2816
+ const still = new Map();
2817
+ if (gate !== 'legacy' && typeof stillReplay === 'function') {
2818
+ const wanted = judged.filter(finding => shapes.get(finding).cls === 'stuck' && !['opposite', 'as_designed'].includes(checkSaid(checks.get(finding) || null)));
2819
+ if (wanted.length > 0) {
2820
+ let answered = new Map();
2821
+ let failed = null;
2822
+ try {
2823
+ 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 })));
2824
+ } catch (error) {
2825
+ failed = String(error && error.message ? error.message : error).split('\n')[0].slice(0, 120);
2826
+ log(`the watch of a claim that nothing happens could not run (${failed}); such a claim is not confirmed by it.`);
2827
+ }
2828
+ for (const finding of wanted) {
2829
+ const answer = (answered instanceof Map && answered.get(finding.id)) || { measured: null, replay: null };
2830
+ still.set(finding, answer);
2831
+ // The control's name comes from the run's own inputs, kept in memory unscrubbed: scrubbed here like every other line.
2832
+ transcript.write(scrubSecrets({ kind: 'still_check', id: finding.id, measured: answer.measured || null, replay: answer.replay || null, ...(failed ? { error: failed } : {}) }, secrets));
2833
+ }
2834
+ }
2835
+ }
2671
2836
  const turnedAway = [];
2672
2837
  const impressions = [];
2673
2838
  const findings = [];
@@ -2678,7 +2843,7 @@ export async function checkClaimsAgainstScreenshots({ client, jobId, runId, repo
2678
2843
  // A run whose findings decide money elsewhere (a fix's verify, a Labs scenario) keeps the gate it had: see ./judge.js legacyIssue.
2679
2844
  const outcome = gate === 'legacy'
2680
2845
  ? 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) });
2846
+ : judgeIssue(finding, { check: checks.get(finding) || null, run, step, marked: Boolean(placed.marked), still: still.get(finding) || null });
2682
2847
  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
2848
  if (outcome.route === 'finding') { findings.push(finding); continue; }
2684
2849
  if (outcome.route === 'impression') {
@@ -2739,6 +2904,8 @@ export function buildReportRequest({ skill, schemas = [], persona, brief, localB
2739
2904
  'What the screens read after the actions you stated an expectation for, and at the end (their visible text, which the observation list above leaves out):',
2740
2905
  screenTextLines(play.records),
2741
2906
  '',
2907
+ // The intent check (./intent.js): what missed, what was not sent for repeating a miss, and what the run played.
2908
+ ...(honesty && honesty.intent ? (text => (text ? [text, ''] : []))(intentReportLines(honesty.intent, playScopeOf(play, honesty))) : []),
2742
2909
  CHOICE_CHECK_INSTRUCTION,
2743
2910
  ...(choiceCheck ? [choiceCheckLine(choiceCheck)] : []),
2744
2911
  ...(play.declined ? ['', declinedPrompt(play.declined, Boolean(play.declinedEnded))] : []),
@@ -2760,6 +2927,7 @@ export function buildReportRequest({ skill, schemas = [], persona, brief, localB
2760
2927
  '',
2761
2928
  '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
2929
  networkNoteLines(notes),
2930
+ ...(honesty && honesty.sdkSession ? [refusedReportInstruction(honesty.sdkSession)] : []),
2763
2931
  '',
2764
2932
  '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
2933
  '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.',
@@ -3236,7 +3404,7 @@ async function finish(outcome, ledger, runDirectory, transcript, heartbeat) {
3236
3404
  }
3237
3405
  outcome.usage = ledger.toReportUsage();
3238
3406
  outcome.duration = ledger.duration();
3239
- await writeUsageFile(runDirectory, ledger, { gameEvents: outcome.gameEvents || null, gameMemory: outcome.gameMemory || null });
3407
+ await writeUsageFile(runDirectory, ledger, { gameEvents: outcome.gameEvents || null, gameMemory: outcome.gameMemory || null, intent: outcome.intent || null, scope: outcome.scope || null });
3240
3408
  transcript.write({ kind: 'end', state: outcome.state, quit_reason: outcome.quitReason, actions: outcome.actionsTaken });
3241
3409
  await transcript.close();
3242
3410
  return outcome;
@@ -3524,7 +3692,9 @@ async function writePartialReport({ outcome, runDirectory, persona, driverName,
3524
3692
  // What the runner saw happen is kept even in a report nobody reviewed: a
3525
3693
  // crash it watched is true whatever became of the report step.
3526
3694
  const honest = writeHonesty({ report, markdown, honesty, driverName, notes, screenshots, observations });
3527
- const stamped = stampGeneratedAt(honest.markdown, new Date().toISOString(), reportFacts({ persona, driverName, target, play }));
3695
+ const scope = playScopeOf(play.maxActions ? play : { ...play, maxActions: outcome.maxActions }, honesty);
3696
+ const stamped = withPlayedLine(stampGeneratedAt(honest.markdown, new Date().toISOString(), reportFacts({ persona, driverName, target, play })), scope ? scope.line : null);
3697
+ if (scope && honesty) honesty.scope = scope;
3528
3698
  await writeReportFiles({ runDirectory, markdown: stamped, report: honest.report });
3529
3699
  outcome.report = honest.report;
3530
3700
  outcome.reportMarkdown = stamped;
@@ -3965,11 +4135,18 @@ export function introducesError(before, after) {
3965
4135
  export function actionLogLines(log) {
3966
4136
  if (!Array.isArray(log) || log.length === 0) return '(none)';
3967
4137
  const shown = log.slice(-MAX_ACTIONS_IN_REPORT);
3968
- const lines = shown.map(entry => `${entry.action}. ${entry.kind} ${entry.target}: ${entry.changed ? 'screen changed' : 'no change'}${entry.expect ? ` (you expected: ${entry.expect}${Number.isInteger(entry.observationAfter) ? `; observation ${entry.observationAfter} is what followed` : ''})` : ''}`);
4138
+ const lines = shown.map(entry => `${entry.action}. ${entry.kind} ${entry.target}: ${entry.changed ? 'screen changed' : 'no change'}${entry.expect ? ` (you expected: ${entry.expect}${Number.isInteger(entry.observationAfter) ? `; observation ${entry.observationAfter} is what followed` : ''}${intentWords(entry.intent)})` : ''}`);
3969
4139
  if (shown.length < log.length) lines.unshift(`(the first ${log.length - shown.length} are left out)`);
3970
4140
  return lines.join('\n');
3971
4141
  }
3972
4142
 
4143
+ /** What the intent check found of one action, as the action list says it (./intent.js annotateActionLog). */
4144
+ function intentWords(intent) {
4145
+ if (!intent || !intent.result) return '';
4146
+ if (intent.result === 'met') return '; you confirmed it';
4147
+ return `; it MISSED${intent.saw ? `: the screen showed ${JSON.stringify(intent.saw)} instead` : ''}`;
4148
+ }
4149
+
3973
4150
  /**
3974
4151
  * The failed requests the runner recorded, one line each, for the report
3975
4152
  * prompt's network notes.