ravensight-playtest 0.12.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 +100 -1
- package/docs/MOBILE.md +1 -1
- package/package.json +3 -3
- package/src/api/client.js +10 -1
- package/src/cli.js +29 -2
- package/src/commands/hosted.js +15 -0
- package/src/commands/run.js +89 -8
- package/src/run/anygame/index.js +1 -1
- package/src/run/args.js +24 -0
- package/src/run/budgetReserve.js +70 -8
- package/src/run/choiceCheck.js +26 -7
- package/src/run/drivers/web.js +136 -5
- package/src/run/judge.js +19 -5
- package/src/run/livesite/browser.js +316 -0
- package/src/run/livesite/hosts.js +107 -0
- package/src/run/livesite/network.js +117 -0
- package/src/run/livesite/options.js +167 -0
- package/src/run/livesite/resolver.js +78 -0
- package/src/run/livesite/run.js +113 -0
- package/src/run/personaLoop.js +282 -32
- package/src/run/proxyClient.js +5 -1
- package/src/run/redaction.js +191 -0
- package/src/run/report.js +5 -2
- package/src/run/reportChecks.js +119 -26
- package/src/run/resume.js +30 -3
- package/src/run/sdkSession.js +114 -0
- package/src/run/state.js +3 -1
- package/src/run/stillWatch.js +123 -0
- package/src/run/tooFast.js +116 -0
- package/src/run/transcript.js +3 -1
- package/src/run/usage.js +3 -1
|
@@ -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 };
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A game timer that ran out because the playtester was still deciding.
|
|
3
|
+
*
|
|
4
|
+
* On a driver that does not stop the game while the model thinks (a native
|
|
5
|
+
* Android or iOS run, a web page that is not a frozen canvas, `--realtime`),
|
|
6
|
+
* every turn costs the game several seconds of its own time. A question with a
|
|
7
|
+
* 10 second timer can run out between two inputs however well it is played. A1
|
|
8
|
+
* of the November 19 mobile proofs (pt_run_c0605d330084a582db91) filed exactly
|
|
9
|
+
* that as a major "softlock" (F001) and a balance finding (F003): the timer did
|
|
10
|
+
* what it was built to do, and the playtester was slower than a player.
|
|
11
|
+
*
|
|
12
|
+
* That is a limit of the runner, never a finding about the game: the persona
|
|
13
|
+
* skill's `[too_fast]` capability note ("reactions faster than a turn"). The
|
|
14
|
+
* persona loop moves such a claim out of the findings into that note, on a run
|
|
15
|
+
* whose game kept running while the model thought (./personaLoop.js). This
|
|
16
|
+
* module only reads the words, and says the note.
|
|
17
|
+
*
|
|
18
|
+
* Phrases, not single words: "time", "timer" and "clock" are ordinary words in
|
|
19
|
+
* a game, and a timer the game draws wrongly, or a crash when it runs out, is
|
|
20
|
+
* about the game.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/** The capability tag the persona skill writes, and `run` prints the fix of (./readiness.js). */
|
|
24
|
+
export const TOO_FAST_TAG = 'too_fast';
|
|
25
|
+
|
|
26
|
+
/** What the runner's own capability list calls it (./honesty.js "Inputs this run could not send"). */
|
|
27
|
+
export const TOO_FAST_INPUT = 'fast reactions';
|
|
28
|
+
|
|
29
|
+
const TIMED_WINDOW = '(?:timing|time|answer|reaction|response|question)[ -]windows?';
|
|
30
|
+
|
|
31
|
+
/** Words that say a game timer ran out, or left too little time for the input. */
|
|
32
|
+
const TIMER_RAN_OUT = [
|
|
33
|
+
/\btime(?:'s|\s+is|\s+was)?\s+up\b/i,
|
|
34
|
+
/\b(?:ran|run|runs|running)\s+out\s+of\s+time\b/i,
|
|
35
|
+
/\btime\s+(?:ran|runs|run|running)\s+out\b/i,
|
|
36
|
+
/\b(?:timer|countdown|time\s+limit)\b[^.!?\n]{0,60}\b(?:ran\s+out|runs?\s+out|running\s+out|expir\w*|hits?\s+zero|reach(?:ed|es)?\s+zero|elapsed|too\s+(?:short|tight|fast|quick|strict)|very\s+(?:short|tight|strict))/i,
|
|
37
|
+
new RegExp(`\\b${TIMED_WINDOW}\\b[^.!?\\n]{0,30}\\b(?:short|tight|strict|narrow|unforgiving|unreliable)`, 'i'),
|
|
38
|
+
new RegExp(`\\b(?:short|tight|strict|narrow|unforgiving|unreliable)\\b[^.!?\\n]{0,20}\\b${TIMED_WINDOW}\\b`, 'i'),
|
|
39
|
+
new RegExp(`\\bmiss(?:ed|es|ing)?\\b[^.!?\\n]{0,30}\\b${TIMED_WINDOW}\\b`, 'i'),
|
|
40
|
+
/\b(?:not\s+enough|too\s+little|no)\s+time\s+to\s+(?:answer|react|respond|tap|click|press|choose|pick|read|decide)\b/i
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
/** "Timed out" says a timer ran out only beside the words of a timed challenge: a request or a load times out too. */
|
|
44
|
+
const TIMED_OUT = /\btim(?:e|ed|es|ing)[ -]?outs?\b/i;
|
|
45
|
+
const TIMED_CHALLENGE = /\b(?:questions?|answers?|quiz\w*|rounds?|turns?|levels?|stages?|puzzles?|prompts?|hearts?|li(?:fe|ves)|timers?|countdowns?)\b/i;
|
|
46
|
+
|
|
47
|
+
/** A crash or a fault of the game is its own claim, whatever the timer did. */
|
|
48
|
+
const GAME_FAILURE = /\b(?:crash\w*|exceptions?|force[ds]?\s+(?:quit|clos\w+))\b/i;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Whether a finding's or a note's words say a game timer ran out, or that its
|
|
52
|
+
* time was too short for the playtester's input.
|
|
53
|
+
*
|
|
54
|
+
* @param {string} text a title and description, or a note
|
|
55
|
+
* @returns {boolean}
|
|
56
|
+
*/
|
|
57
|
+
export function timerExpiryClaim(text) {
|
|
58
|
+
const words = String(text == null ? '' : text);
|
|
59
|
+
if (!words.trim() || GAME_FAILURE.test(words)) return false;
|
|
60
|
+
if (TIMER_RAN_OUT.some(pattern => pattern.test(words))) return true;
|
|
61
|
+
return TIMED_OUT.test(words) && TIMED_CHALLENGE.test(words);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const seconds = ms => Math.round(ms / 100) / 10;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* How long the playtester took to decide, over the turns the game kept running
|
|
68
|
+
* through: the median and the longest, to a tenth of a second.
|
|
69
|
+
*
|
|
70
|
+
* @param {Array<number>} thinkMs milliseconds per turn
|
|
71
|
+
* @returns {{turns: number, medianSeconds: number|null, maxSeconds: number|null}}
|
|
72
|
+
*/
|
|
73
|
+
export function thinkingTime(thinkMs = []) {
|
|
74
|
+
const kept = (Array.isArray(thinkMs) ? thinkMs : []).filter(ms => Number.isFinite(ms) && ms > 0).sort((a, b) => a - b);
|
|
75
|
+
if (kept.length === 0) return { turns: 0, medianSeconds: null, maxSeconds: null };
|
|
76
|
+
const middle = Math.floor(kept.length / 2);
|
|
77
|
+
const median = kept.length % 2 === 1 ? kept[middle] : (kept[middle - 1] + kept[middle]) / 2;
|
|
78
|
+
return { turns: kept.length, medianSeconds: seconds(median), maxSeconds: seconds(kept[kept.length - 1]) };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const clip = (text, max) => {
|
|
82
|
+
const value = String(text == null ? '' : text).replace(/\s+/g, ' ').trim();
|
|
83
|
+
return value.length > max ? `${value.slice(0, max - 3)}...` : value;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/** What the playtester's thinking did to the game's clock, in one clause. */
|
|
87
|
+
function thinkingClause(timing) {
|
|
88
|
+
return timing && timing.turns > 0 && timing.medianSeconds !== null
|
|
89
|
+
? `The game kept running while the playtester thought, about ${timing.medianSeconds} s a turn and up to ${timing.maxSeconds} s`
|
|
90
|
+
: 'The game kept running while the playtester thought';
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The `[too_fast]` line report.md carries under "What this run didn't cover",
|
|
95
|
+
* for what the runner moved out of the findings. `run` prints it with its fix.
|
|
96
|
+
*
|
|
97
|
+
* @param {Array<{id: string, title: string}>} moved the findings or notes it moved
|
|
98
|
+
* @param {{turns: number, medianSeconds: number|null, maxSeconds: number|null}} timing
|
|
99
|
+
* @returns {string}
|
|
100
|
+
*/
|
|
101
|
+
export function tooFastLine(moved, timing) {
|
|
102
|
+
const named = (Array.isArray(moved) ? moved : []).map(entry => `${entry.id} (${clip(entry.title, 90)})`).join('; ');
|
|
103
|
+
return `- \`[${TOO_FAST_TAG}]\` A game timer ran out while the playtester was still deciding, a limit of the playtest tool and not a finding${named ? `: ${named}` : ''}. ${thinkingClause(timing)}, so a countdown that short runs out between its inputs. Whether a player has enough time was not tested.`;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The runner's capability note for its own list (./honesty.js), never a finding.
|
|
108
|
+
*
|
|
109
|
+
* @param {{turns: number, medianSeconds: number|null, maxSeconds: number|null}} timing
|
|
110
|
+
* @returns {{input: string, reason: string}}
|
|
111
|
+
*/
|
|
112
|
+
export function tooFastNote(timing) {
|
|
113
|
+
return { input: TOO_FAST_INPUT, reason: `${thinkingClause(timing).replace(/^The game/, 'the game')}, so a game timer that ran out between its inputs says nothing about the game and is not reported as a finding [${TOO_FAST_TAG}]` };
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export default { TOO_FAST_TAG, TOO_FAST_INPUT, timerExpiryClaim, thinkingTime, tooFastLine, tooFastNote };
|
package/src/run/transcript.js
CHANGED
|
@@ -3,6 +3,7 @@ import { mkdir } from 'node:fs/promises';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { RUN_FILES } from './paths.js';
|
|
5
5
|
import { scanForSecrets } from './secretScan.js';
|
|
6
|
+
import { redactText } from './redaction.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* `transcript.jsonl`, one JSON object per line.
|
|
@@ -52,7 +53,8 @@ export function createTranscript(runDirectory) {
|
|
|
52
53
|
*/
|
|
53
54
|
write(line) {
|
|
54
55
|
if (!stream) throw new Error('transcript is not open');
|
|
55
|
-
|
|
56
|
+
// A live URL run's sign-in secrets are replaced as the last step (./redaction.js).
|
|
57
|
+
const body = redactText(JSON.stringify({ t: Date.now(), ...line }));
|
|
56
58
|
const secrets = scanForSecrets(body);
|
|
57
59
|
lines += 1;
|
|
58
60
|
if (secrets.length > 0) {
|
package/src/run/usage.js
CHANGED
|
@@ -2,6 +2,7 @@ import { writeFile } from 'node:fs/promises';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { RUN_FILES } from './paths.js';
|
|
4
4
|
import { assertNoSecrets } from './secretScan.js';
|
|
5
|
+
import { redactText } from './redaction.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Token accounting for one run, and `usage.json`.
|
|
@@ -178,7 +179,8 @@ export async function writeUsageFile(runDirectory, ledger, extra = {}) {
|
|
|
178
179
|
// What the run measured beside its spend, as the hosted runner's usage.json carries it: the game's own events
|
|
179
180
|
// (`gameEvents`) and the notes it hands on to the next playtest of the game (`gameMemory`). Absent when there are none.
|
|
180
181
|
const more = Object.fromEntries(Object.entries(extra || {}).filter(([, value]) => value !== null && value !== undefined));
|
|
181
|
-
|
|
182
|
+
// A live URL run's sign-in secrets are replaced as the last step (./redaction.js).
|
|
183
|
+
const body = redactText(`${JSON.stringify({ ...ledger.toUsageFile(), ...more }, null, 2)}\n`);
|
|
182
184
|
// Token counts and model ids should never look secret shaped, and that is
|
|
183
185
|
// the point of checking: this file is uploaded by default, so anything
|
|
184
186
|
// unexpected in it is refused rather than shipped.
|