ravensight-playtest 0.13.2 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +99 -4
  2. package/addons/ravensight_driver/driver.gd +472 -28
  3. package/docs/godot-driver.md +66 -2
  4. package/package.json +7 -5
  5. package/src/api/README.md +8 -1
  6. package/src/api/client.js +24 -1
  7. package/src/cli.js +14 -0
  8. package/src/commands/check.js +5 -2
  9. package/src/commands/fix.js +1 -1
  10. package/src/commands/run.js +26 -4
  11. package/src/commands/setup.js +176 -0
  12. package/src/packs/index.js +37 -5
  13. package/src/packs/keys.json +11 -0
  14. package/src/packs/pack-signing-hashes.json +7 -0
  15. package/src/packs/pack-signing-vectors.json +119 -0
  16. package/src/packs/signature.js +186 -0
  17. package/src/run/anygame/gamenotes.js +74 -12
  18. package/src/run/anygame/index.js +97 -34
  19. package/src/run/anygame/language.js +100 -10
  20. package/src/run/anygame/memory.js +70 -13
  21. package/src/run/anygame/shared-hashes.json +7 -7
  22. package/src/run/anygame/sound.js +59 -16
  23. package/src/run/args.js +2 -0
  24. package/src/run/claimwords.js +43 -7
  25. package/src/run/drivers/godot-cursor.js +96 -0
  26. package/src/run/drivers/godot-observation.js +29 -5
  27. package/src/run/drivers/godot.js +60 -5
  28. package/src/run/drivers/web.js +124 -14
  29. package/src/run/eventclaims.js +102 -6
  30. package/src/run/events.js +64 -6
  31. package/src/run/gameMemory.js +14 -5
  32. package/src/run/honesty.js +49 -2
  33. package/src/run/judge.js +22 -10
  34. package/src/run/liveFeed.js +254 -0
  35. package/src/run/personaLoop.js +103 -25
  36. package/src/run/pixels.js +491 -2
  37. package/src/run/replay.js +11 -0
  38. package/src/run/sdkSession.js +279 -16
  39. package/src/run/synthetic.js +12 -8
  40. package/src/run/tools.js +2 -2
@@ -19,7 +19,7 @@ import { redactText } from './redaction.js';
19
19
  import { ACTION_TOOLS, NEW_TOOL_NAMES, REPORT_TOOLS, executeTool, expectationOf, modelFrameOf, toolResult, toolsFor, NEWEST_TOOL_NAMES } from './tools.js';
20
20
  import {
21
21
  CAPABILITY_HEADING, DIALOGS_HEADING, EVIDENCE_HEADING, MAX_WIN_CONTINUES, RUNNER_FINDINGS_HEADING, WIN_TEXT,
22
- addRunnerFindings, attachWhereToLook, blankFinding, capabilityPrompt, createBlankWatch, createCapabilityLedger, describeInput, dialogNote, gameEndedFinding, gameEndedOf, mergeRunnerDuplicates,
22
+ addRunnerFindings, attachWhereToLook, uniqueFindingIds, blankFinding, capabilityPrompt, createBlankWatch, createCapabilityLedger, describeInput, dialogNote, gameEndedFinding, gameEndedOf, mergeRunnerDuplicates,
23
23
  playOnText, replaceSection, runnerFinding, runnerFindingsMarkdown, stepsBefore, videoTime, whereToLookMarkdown, writeCapabilitySection
24
24
  } from './honesty.js';
25
25
  import { runEdgePass, edgeFindings, edgeMarkdown, EDGE_HEADING, blankCapabilityNote } from './edgePass.js';
@@ -41,7 +41,7 @@ import { annotateActionLog, createIntentWatch, goalsOf, holdInCharacter, intentR
41
41
  import { claimShape, judgeIssue, legacyIssue, impressionOf } from './judge.js';
42
42
  import { EVENTS_RULE, eventsBlock, eventsReportLines, eventsUsage, withEventEvidence } from './events.js';
43
43
  import { memoryBlock, extractLocalNotes, gameMemoryBody } from './gameMemory.js';
44
- import { CLAIM_SYSTEM, CLAIM_WIRE, checkSaid, claimText, claimRead, claimMessage } from './claimwords.js';
44
+ import { CLAIM_SYSTEM, CLAIM_WIRE, checkSaid, claimText, claimRead, claimMessage, readsEnglish } from './claimwords.js';
45
45
  import { CLAIM_FAULT_SYSTEM, claimCheckSystem, claimReply, claimFormatRepair, MAX_CLAIM_REPLY_TEXT } from './claimProtocol.js';
46
46
  import { captureNotes, createCaptureWatch, rewriteStaleEvidence, staleSentence } from './captureCheck.js';
47
47
  import { gameRefusal } from './gameRefusal.js';
@@ -49,12 +49,13 @@ import { BUILT_IN_NOISE, expectedNoiseForPrompt, isExpectedNoise } from './noise
49
49
  import { cutFindingFrames, moodOf, replayCapabilityNote, replayFindings, replayWebFindings, screenOf, traceWebInputs, watchClaimsStill } from './reportChecks.js';
50
50
  import { pngFingerprint, screenDelta, significant } from './pixels.js';
51
51
  import { watchWebStill } from './stillWatch.js';
52
- import { refusedEventsBody, refusedReportInstruction, sessionRefusal } from './sdkSession.js';
52
+ import { TAG_RECORD_TAG, playtestTagBody, playtestTagRecord, playtestTagReportInstruction, playtestTagUsage, playtestTagging, refusedEventsBody, refusedReportInstruction, sessionRefusal } from './sdkSession.js';
53
53
  import { mkdtemp } from 'node:fs/promises';
54
54
  import os from 'node:os';
55
55
  import { MIN_PASSWORD_CHARS } from '../briefLocal.js';
56
56
  // any-game hook: the run's notebook, control learning, language, kind of game and sound (./anygame/index.js).
57
57
  import { createLocalAnyGame } from './anygame/index.js';
58
+ import { TOOL_TEXT_OTHER, NO_SOUND_OTHER } from './anygame/language.js';
58
59
  import { staleObservationCount } from './context.js';
59
60
 
60
61
  /**
@@ -405,10 +406,14 @@ export async function runPersona(args) {
405
406
  imageBudget = next;
406
407
  }
407
408
  });
409
+ // Play is over: the live view ends with it (the server ends the stream when the run leaves `playing`).
410
+ if (args.live) args.live.close();
408
411
  imageBudget = play.imageBudget;
409
412
  outcome = { ...outcome, ...play };
410
413
  // The intent check's record for usage.json (./intent.js); what the run played is added once the report has it.
411
414
  outcome.intent = honesty.intent ? honesty.intent.summary() : null;
415
+ // Whether the game's own events were tagged as this playtest, for usage.json and the run summary (./sdkSession.js); null with no record.
416
+ outcome.playtestTag = honesty.playtestTag || null;
412
417
 
413
418
  const endedAt = new Date().toISOString();
414
419
  // When the recording began, read before the driver is stopped: a finding's
@@ -527,7 +532,7 @@ export async function runPersona(args) {
527
532
  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 } };
528
533
  // The notes this run hands on to the next playtest of the game, when the game's memory asked for them (./gameMemory.js).
529
534
  if (memory && memory.save === true) {
530
- const handed = gameMemoryBody(memory, extractLocalNotes({ digest: honesty.anygame ? honesty.anygame.digest() : null, turnedAway: written.turnedAway || [] }));
535
+ const handed = gameMemoryBody(memory, extractLocalNotes({ digest: honesty.anygame ? honesty.anygame.digest() : null, turnedAway: written.turnedAway || [], gameEvents: outcome.gameEvents }));
531
536
  if (handed) {
532
537
  outcome.gameMemory = handed;
533
538
  transcript.write({ kind: 'game_memory', notes: handed.notes.length, kinds: Object.fromEntries([...new Set(handed.notes.map(n => n.kind))].map(kind => [kind, handed.notes.filter(n => n.kind === kind).length])) });
@@ -808,7 +813,17 @@ export const RUNNER_LIMIT_TEXT = new RegExp([
808
813
  * @returns {boolean} true when the finding's own words are about the runner
809
814
  */
810
815
  export function aboutRunnerLimit(finding) {
811
- return RUNNER_LIMIT_TEXT.test(`${(finding && finding.title) || ''}\n${(finding && finding.description) || ''}`);
816
+ const text = `${(finding && finding.title) || ''}\n${(finding && finding.description) || ''}`;
817
+ // The same rules in the report's language when it is not English (./anygame/language.js, shared with the hosted runner).
818
+ return RUNNER_LIMIT_TEXT.test(text) || TOOL_TEXT_OTHER.test(text) || NO_SOUND_OTHER.test(text);
819
+ }
820
+
821
+ /** A line added to a tool result the persona is about to read (a string or a list of blocks). Changes it in place. */
822
+ export function withResultLine(result, line) {
823
+ if (!result || typeof line !== 'string' || !line) return result;
824
+ if (Array.isArray(result.content)) result.content.push({ type: 'text', text: line });
825
+ else if (typeof result.content === 'string') result.content = `${result.content}\n${line}`;
826
+ return result;
812
827
  }
813
828
 
814
829
  /* ------------------------------------- a game timer the playtester's own thinking ran out (./tooFast.js) */
@@ -887,6 +902,8 @@ async function playLoop({
887
902
  imageBudget,
888
903
  keepObservations,
889
904
  heartbeat,
905
+ // The job's live view (./liveFeed.js): handed each played input; never awaited, never throws.
906
+ live = null,
890
907
  onProgress = () => {},
891
908
  onBudgetWarning = null,
892
909
  // The run's model budget in USD, from register (`limits.model_usd`). With it
@@ -913,7 +930,7 @@ async function playLoop({
913
930
  const noisePatterns = (localBrief && Array.isArray(localBrief.expected_noise)) ? localBrief.expected_noise : [];
914
931
  // any-game hook: one notebook a run, on the honesty record so the report step reads the same one.
915
932
  const briefFields = brief && brief.fields && typeof brief.fields === 'object' ? brief.fields : brief || {};
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 }));
933
+ 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), reportLanguageHint: briefFields.play && typeof briefFields.play.report_language === 'string' ? briefFields.play.report_language : null, continuousTime: driver?.inputProfile === 'native-mobile' && driver.frozenBetweenActions === false, driverName: typeof driver.soundSelfTest === 'function' ? '' : driverName }));
917
934
  system.push({ type: 'text', text: anyGame.systemText() });
918
935
  // The intent check (./intent.js): one watch a run, on the honesty record so the report step reads the same one. Every answer,
919
936
  // miss and refused repeat is a line of the step log.
@@ -1572,7 +1589,15 @@ async function playLoop({
1572
1589
  if (ACTION_TOOLS.includes(toolUse.name)) {
1573
1590
  // any-game hook: the input is tallied by kind and the page's sound is read for it.
1574
1591
  anyGame.afterAction({ tool: toolUse.name, input: toolUse.input, changed: Boolean(executed.changed), place: executed.observation.title || '', label: inputLabel(redactToolInput(toolUse, secrets), toolUse.name), action: actions, text: executed.observation.text, driverError: Boolean(executed.driverError) });
1575
- if (typeof driver.soundRead === 'function') anyGame.afterSound(actions, await Promise.resolve().then(() => driver.soundRead()).catch(() => null), { changed: Boolean(executed.changed) });
1592
+ if (typeof driver.soundRead === 'function') {
1593
+ // Each action's sound is a line of the step log, and, once the game has made a sound, a line of the tool result:
1594
+ // evidence about feedback ("no feedback when pressing jump"), never a finding of its own. No audio is kept or sent.
1595
+ const heard = anyGame.afterSound(actions, await Promise.resolve().then(() => driver.soundRead()).catch(() => null), { changed: Boolean(executed.changed) });
1596
+ if (heard) {
1597
+ transcript.write({ kind: 'sound', action: actions, sound: heard.state });
1598
+ if (heard.say) withResultLine(executed.result, heard.say);
1599
+ }
1600
+ }
1576
1601
  // A hover that shows nothing is a look, not a stuck game.
1577
1602
  // An input the runner could not send (a target it could not resolve, a stale ref, a hold this driver
1578
1603
  // lacks) never reached the game: it says nothing about the game being stuck and is not an input that
@@ -1594,6 +1619,17 @@ async function playLoop({
1594
1619
  }
1595
1620
  }
1596
1621
  }
1622
+ // The live view: the step just played and, when the screen changed, the picture the driver has of it.
1623
+ if (live && ACTION_TOOLS.includes(toolUse.name)) {
1624
+ const seen = executed.observation;
1625
+ live.step({
1626
+ n: actions,
1627
+ label: describeInput({ tool: toolUse.name, input: redactToolInput(toolUse, secrets) }),
1628
+ intent: actionLine.expect || actionLine.thought || '',
1629
+ changed: typeof executed.changed === 'boolean' ? executed.changed : null,
1630
+ screen: screenNow || ''
1631
+ }, { image: executed.changed && seen && typeof seen.screenshotBase64 === 'string' ? { data: seen.screenshotBase64 } : null });
1632
+ }
1597
1633
  // A screen that showed the game, went one flat colour and stayed so
1598
1634
  // through the next inputs is a blank screen, found by the runner.
1599
1635
  if (executed.observation && !executed.observation.dialog && (ACTION_TOOLS.includes(toolUse.name) || toolUse.name === 'wait') && typeof driver.screenProbe === 'function') {
@@ -1716,7 +1752,9 @@ async function playLoop({
1716
1752
  // The intent check: a miss the runner or the record found, and a part of the game to leave, said once (./intent.js).
1717
1753
  for (const notice of intentWatch.notices()) asides.push(notice);
1718
1754
 
1719
- // any-game hook: the play style once, and the notebook when screens have dropped out of context.
1755
+ // any-game hook: the game's own events into the notebook's record (a numbered note is carried only once the record holds it),
1756
+ // then the play style once, and the notebook when screens have dropped out of context.
1757
+ anyGame.seeEvents(driver && driver.gameEvents, actions);
1720
1758
  const anyAside = anyGame.aside({ actions, dropped: staleObservationCount(observations.length, keepObservations) });
1721
1759
  if (anyAside) { asides.push(anyAside); transcript.write({ kind: 'any_game_aside', chars: anyAside.length }); }
1722
1760
  // The game's own analytics events since the last turn, measured and not read off the picture (./events.js): only when there are new ones.
@@ -1809,12 +1847,7 @@ async function playLoop({
1809
1847
  honesty.findings.push(finding);
1810
1848
  transcript.write({ kind: 'runner_finding', key: 'blank_screen', title: finding.title, since_action: stillBlank.sinceAction });
1811
1849
  }
1812
- // any-game hook: what the sound record supports is the runner's own finding; what it could not check is a capability note.
1813
- for (const f of anyGame.soundFindings()) {
1814
- const finding = runnerFinding({ severity: f.severity, category: f.category, key: `sound:${f.title}`, title: f.title, description: f.description, steps: stepsBefore(actionRecords.filter(record => record && record.kind === 'action')), screenshot: final ? final.relativePath : null, action: Number.isInteger(f.action) ? f.action : actions });
1815
- honesty.findings.push(finding);
1816
- transcript.write({ kind: 'runner_finding', key: 'sound', title: finding.title });
1817
- }
1850
+ // any-game hook: sound is evidence, never a finding of its own; what it could not check is a capability note.
1818
1851
  for (const note of anyGame.capabilityNotes()) if (honesty.capability.add(note)) transcript.write({ kind: 'capability_note', input: note.input, reason: note.reason });
1819
1852
  transcript.write({ kind: 'any_game', record: anyGame.digest() });
1820
1853
  // What the game asked for that the runner could not give.
@@ -1907,13 +1940,21 @@ async function playLoop({
1907
1940
  const kept = driver.gameEvents.record();
1908
1941
  if (kept.total > 0) transcript.write({ kind: 'game_events', total: kept.total, kept: kept.kept, clock: kept.clock, names: kept.names });
1909
1942
  }
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;
1943
+ // The game's own SDK's session requests, as the driver read them (./sdkSession.js).
1944
+ const sessionRecord = driver && typeof driver.sdkSessions === 'function' ? await Promise.resolve().then(() => driver.sdkSessions()).catch(() => null) : null;
1945
+ // The game's own SDK asked for its session and the server refused it, so none of its events reached the run.
1946
+ const refusal = sessionRefusal(sessionRecord);
1912
1947
  if (refusal) {
1913
1948
  honesty.sdkSession = refusal;
1914
1949
  transcript.write({ kind: 'game_events_refused', status: refusal.status, error: refusal.error, key: refusal.key, tagged: refusal.tagged, times: refusal.times });
1915
1950
  log(refusedEventsBody(refusal));
1916
1951
  }
1952
+ // Whether the game's own events were tagged as this playtest: said only from the session requests the run saw.
1953
+ const tag = playtestTagging(sessionRecord, honesty.events ? honesty.events.record().total : 0);
1954
+ if (tag) {
1955
+ honesty.playtestTag = tag;
1956
+ if (tag.state !== 'none') transcript.write({ kind: 'game_events_tag', state: tag.state, sessions: tag.sessions, untagged: tag.untagged, events: tag.events, sdk: tag.sdk, given: tag.given });
1957
+ }
1917
1958
  if (completionRepairPending) transcript.write({ kind: 'brief_completion_repair_unavailable', reason: quitReason, detail: quitDetail, independently_verified: false });
1918
1959
  return {
1919
1960
  actionsTaken: actions,
@@ -2174,11 +2215,16 @@ async function reportPhase({
2174
2215
  }
2175
2216
  droppedByRunner = runnerDrop.dropped;
2176
2217
  const contradicted = runnerDrop.report ? downgradeContradictedFindings(runnerDrop.report, play.actionLog) : { report: null, downgraded: [] };
2177
- const candidate = contradicted.report;
2218
+ let candidate = contradicted.report;
2178
2219
  for (const entry of contradicted.downgraded) {
2179
2220
  transcript.write({ kind: 'finding_downgraded', id: entry.id, from: entry.from, to: entry.to, control: entry.control, action: entry.action });
2180
2221
  }
2181
2222
  downgradedByRunner = contradicted.downgraded;
2223
+ // any-game hook: a finding about missing feedback says whether a sound played at the action it cites (evidence, never a finding).
2224
+ if (candidate && honesty && honesty.anygame) {
2225
+ const heard = honesty.anygame.soundEvidence(candidate);
2226
+ if (heard.changed.length) { candidate = heard.report; transcript.write({ kind: 'finding_sound_noted', attempt, ids: heard.changed }); }
2227
+ }
2182
2228
  if (contradicted.downgraded.length > 0) {
2183
2229
  log(`downgraded ${contradicted.downgraded.length} finding(s) the action log contradicts: ${contradicted.downgraded.map(entry => `${entry.id} (${entry.from} to ${entry.to}, ${entry.control} clicked at step ${entry.action})`).join(', ')}`);
2184
2230
  }
@@ -2286,6 +2332,16 @@ async function reportPhase({
2286
2332
  // after the report is settled, so a refusal can cost the check and never
2287
2333
  // the report.
2288
2334
  report = scrubSecrets(report, secrets);
2335
+ // Every finding gets its own id before anything is placed, judged or cut by id (./honesty.js uniqueFindingIds).
2336
+ {
2337
+ const before = (report.findings || []).map(finding => finding && finding.id);
2338
+ report = uniqueFindingIds(report);
2339
+ const renamed = (report.findings || []).map((finding, i) => [before[i], finding && finding.id]).filter(([from, to]) => from !== to);
2340
+ if (renamed.length > 0) {
2341
+ transcript.write({ kind: 'finding_ids_renamed', renamed: renamed.map(([from, to]) => ({ from, to })) });
2342
+ log(`the report repeated a finding id; renamed ${renamed.map(([from, to]) => `${from} to ${to}`).join(', ')}`);
2343
+ }
2344
+ }
2289
2345
  const submittedSchemaValid = validator.validate(report).ok;
2290
2346
  // Preserve the submitted account before attribution or judgement changes it.
2291
2347
  // Bounded and scrubbed; a truncated audit is explicitly not a full draft.
@@ -2317,7 +2373,7 @@ async function reportPhase({
2317
2373
  let impressions = [];
2318
2374
  if (!shrunk && !play.budgetExceeded) {
2319
2375
  const impressionsAllowed = Boolean(reportSchema && reportSchema.properties && reportSchema.properties.impressions);
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 });
2376
+ 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, reportLanguage: honesty && honesty.anygame ? honesty.anygame.report?.code || null : null });
2321
2377
  report = checked.report;
2322
2378
  turnedAway = checked.turnedAway;
2323
2379
  impressions = checked.impressions;
@@ -2344,11 +2400,22 @@ async function reportPhase({
2344
2400
  // The playtester's impressions go into report.json beside the findings, never among them.
2345
2401
  if (impressions.length > 0) report = { ...report, impressions: impressions.map(({ finding, ...impression }) => impression) };
2346
2402
  // A finding the game's own events confirmed says so, and the report has a section on what they measured.
2403
+ // Beside them, whether those events were tagged as this playtest, said only from the session requests the run saw (./sdkSession.js).
2404
+ const tagBody = honesty ? playtestTagBody(honesty.playtestTag) : null;
2405
+ let eventsSection = false;
2347
2406
  if (eventRun) {
2348
2407
  withEventEvidence(report.findings || [], eventRun);
2349
2408
  const lines = eventsReportLines(eventRun, { findings: report.findings || [], turnedAway });
2350
- if (lines.length > 0) markdown = replaceSection(markdown, EVENTS_HEADING, lines.slice(2).join('\n').replace(/\s+$/, ''));
2409
+ if (lines.length > 0) {
2410
+ const body = lines.slice(2);
2411
+ if (tagBody) body.splice(1, 0, '', tagBody);
2412
+ markdown = replaceSection(markdown, EVENTS_HEADING, body.join('\n').replace(/\s+$/, ''));
2413
+ eventsSection = true;
2414
+ }
2351
2415
  }
2416
+ // An untagged session that sent no events still counts as a real player, and a record the run cannot read is said as
2417
+ // such, so both are said even with nothing measured.
2418
+ if (!eventsSection && tagBody && honesty.playtestTag.state !== 'tagged') markdown = replaceSection(markdown, EVENTS_HEADING, tagBody);
2352
2419
  // The game's own SDK was refused its session: said plainly where its events would be, never left to read as benign.
2353
2420
  if (honesty && honesty.sdkSession && !(eventRun && eventRun.gameEvents && eventRun.gameEvents.total > 0)) markdown = replaceSection(markdown, EVENTS_HEADING, refusedEventsBody(honesty.sdkSession));
2354
2421
  // What a screenshot shows comes from the picture: one taken while the picture lagged the game says so.
@@ -2622,7 +2689,8 @@ const WIDEST_CLAIM = Object.freeze({ severity: 'blocker', title: 'x'.repeat(160)
2622
2689
  * @returns {Object} a request body
2623
2690
  */
2624
2691
  export function claimCheckSizingRequest(frame) {
2625
- const questions = [{ cls: 'absence', fault: true }, { cls: 'other', fault: true }, { cls: 'layout', fault: false }, { cls: 'other', fault: false }].map(moment => claimText(WIDEST_CLAIM, moment));
2692
+ // A claim in another language is asked the same questions with one more paragraph (./claimwords.js UNSORTED): the reserve covers it.
2693
+ const questions = [{ cls: 'absence', fault: true }, { cls: 'other', fault: true }, { cls: 'layout', fault: false }, { cls: 'other', fault: false }, { cls: 'other', fault: true, english: false }, { cls: 'other', fault: false, english: false }].map(moment => claimText(WIDEST_CLAIM, moment));
2626
2694
  const question = questions.reduce((longest, text) => (text.length > longest.length ? text : longest), '');
2627
2695
  const system = [CLAIM_SYSTEM, CLAIM_FAULT_SYSTEM].reduce((longest, text) => (text.length > longest.length ? text : longest), '');
2628
2696
  return {
@@ -2700,12 +2768,15 @@ export function citedAfterScreenshot(finding, screenshots) {
2700
2768
  *
2701
2769
  * @returns {Promise<{report: Object, turnedAway: Array<Object>, impressions: Array<Object>}>}
2702
2770
  */
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 }) {
2771
+ 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, reportLanguage = null }) {
2704
2772
  if (!report || !Array.isArray(report.findings)) return { report, turnedAway: [], impressions: [] };
2705
2773
  const placedIndex = Array.isArray(index) ? index : attachWhereToLook(report, { observations, notes, screenshots }).index;
2706
2774
  const where = new Map(placedIndex.map(entry => [entry.id, entry]));
2707
2775
  const judged = report.findings.filter(finding => finding && (CLAIM_SEVERITIES.includes(finding.severity) || finding.severity === 'praise') && !measured.has(finding.id));
2708
- const shapes = new Map(judged.map(finding => [finding, claimShape(finding, { marked: Boolean(where.get(finding.id)?.marked) })]));
2776
+ // The report's language (./anygame/language.js reportLanguage): the playtester's claims are written in it, and English words are read only in English.
2777
+ // The legacy gate decides money elsewhere and keeps exactly the rules it had (./judge.js legacyIssue), in every language.
2778
+ const english = gate === 'legacy' || readsEnglish(reportLanguage);
2779
+ const shapes = new Map(judged.map(finding => [finding, claimShape(finding, { marked: Boolean(where.get(finding.id)?.marked), english })]));
2709
2780
  // Every issue a question is asked about, the most severe first; praise and a judgement of its own play are not asked.
2710
2781
  const issues = judged.filter(finding => shapes.get(finding).question !== null || (gate === 'legacy' && shapes.get(finding).cls === 'difficulty'))
2711
2782
  .sort((a, b) => CLAIM_SEVERITIES.indexOf(a.severity) - CLAIM_SEVERITIES.indexOf(b.severity));
@@ -2744,7 +2815,7 @@ export async function checkClaimsAgainstScreenshots({ client, jobId, runId, repo
2744
2815
  .reverse().find(entry => entry.relativePath !== shot.relativePath);
2745
2816
  if (before) pictures.push(before.relativePath);
2746
2817
  }
2747
- const question = claimText(finding, { cls: shape.cls === 'difficulty' ? 'other' : shape.cls, fault: shape.question !== null && shape.question !== 'plain' && shape.question !== 'layout' });
2818
+ const question = claimText(finding, { cls: shape.cls === 'difficulty' ? 'other' : shape.cls, fault: shape.question !== null && shape.question !== 'plain' && shape.question !== 'layout', ...(english ? {} : { english: false }) });
2748
2819
  const answers = [];
2749
2820
  let formatRepairUsed = false;
2750
2821
  for (const picture of pictures) {
@@ -2843,7 +2914,7 @@ export async function checkClaimsAgainstScreenshots({ client, jobId, runId, repo
2843
2914
  // A run whose findings decide money elsewhere (a fix's verify, a Labs scenario) keeps the gate it had: see ./judge.js legacyIssue.
2844
2915
  const outcome = gate === 'legacy'
2845
2916
  ? legacyIssue(finding, { check: checks.get(finding) || null, marked: Boolean(placed.marked) })
2846
- : judgeIssue(finding, { check: checks.get(finding) || null, run, step, marked: Boolean(placed.marked), still: still.get(finding) || null });
2917
+ : judgeIssue(finding, { check: checks.get(finding) || null, run, step, marked: Boolean(placed.marked), still: still.get(finding) || null, english });
2847
2918
  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 } : {}) });
2848
2919
  if (outcome.route === 'finding') { findings.push(finding); continue; }
2849
2920
  if (outcome.route === 'impression') {
@@ -2928,6 +2999,7 @@ export function buildReportRequest({ skill, schemas = [], persona, brief, localB
2928
2999
  '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):',
2929
3000
  networkNoteLines(notes),
2930
3001
  ...(honesty && honesty.sdkSession ? [refusedReportInstruction(honesty.sdkSession)] : []),
3002
+ ...(honesty && playtestTagReportInstruction(honesty.playtestTag) ? [playtestTagReportInstruction(honesty.playtestTag)] : []),
2931
3003
  '',
2932
3004
  '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"}.',
2933
3005
  '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.',
@@ -2946,7 +3018,10 @@ export function buildReportRequest({ skill, schemas = [], persona, brief, localB
2946
3018
  ].join('\n');
2947
3019
  // The prompt is built from notes, observations and the action log; none
2948
3020
  // of them may carry the test account password into the report step.
3021
+ // The game's SDK sessions as data in their own element: the SDK name the page sent never enters the instructions (./sdkSession.js).
3022
+ const tagRecord = honesty ? playtestTagRecord(honesty.playtestTag) : null;
2949
3023
  return { system, messages: [{ role: 'user', content: [{ type: 'text', text: scrubSecrets(text, secrets) },
3024
+ ...(tagRecord ? [{ type: 'text', text: `<${TAG_RECORD_TAG}>\n${JSON.stringify(tagRecord)}\n</${TAG_RECORD_TAG}>` }] : []),
2950
3025
  // This is the public pack contract, not local-account or gameplay data.
2951
3026
  // Keep its exact keys/constraints identical to the validator's schema.
2952
3027
  ...(reportSchema ? [{ type: 'text', text: `<report_json_schema>\n${JSON.stringify(reportSchema)}\n</report_json_schema>` }] : [])] }] };
@@ -3404,7 +3479,10 @@ async function finish(outcome, ledger, runDirectory, transcript, heartbeat) {
3404
3479
  }
3405
3480
  outcome.usage = ledger.toReportUsage();
3406
3481
  outcome.duration = ledger.duration();
3407
- await writeUsageFile(runDirectory, ledger, { gameEvents: outcome.gameEvents || null, gameMemory: outcome.gameMemory || null, intent: outcome.intent || null, scope: outcome.scope || null });
3482
+ // Whether the game's own events were tagged as this playtest, beside them, on every path that played (./sdkSession.js).
3483
+ const tagUsage = playtestTagUsage(outcome.playtestTag);
3484
+ const gameEvents = tagUsage ? { ...(outcome.gameEvents || {}), playtestTag: tagUsage } : outcome.gameEvents || null;
3485
+ await writeUsageFile(runDirectory, ledger, { gameEvents, gameMemory: outcome.gameMemory || null, intent: outcome.intent || null, scope: outcome.scope || null });
3408
3486
  transcript.write({ kind: 'end', state: outcome.state, quit_reason: outcome.quitReason, actions: outcome.actionsTaken });
3409
3487
  await transcript.close();
3410
3488
  return outcome;