ravensight-playtest 0.12.0 → 0.13.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.
- package/README.md +82 -0
- 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 +118 -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 +207 -24
- package/src/run/proxyClient.js +5 -1
- package/src/run/redaction.js +191 -0
- package/src/run/report.js +5 -2
- package/src/run/resume.js +30 -3
- package/src/run/state.js +3 -1
- package/src/run/tooFast.js +116 -0
- package/src/run/transcript.js +3 -1
- package/src/run/usage.js +3 -1
package/src/run/resume.js
CHANGED
|
@@ -11,7 +11,10 @@ import { buildPartialReport, readTranscript, shouldFinalize } from './regenerate
|
|
|
11
11
|
import { reconcileDroppedFindings } from './dropped.js';
|
|
12
12
|
import { createReportValidator, writeReportFiles } from './report.js';
|
|
13
13
|
import * as stateFile from './state.js';
|
|
14
|
-
import { playJob, resolvePersonas } from '../commands/run.js';
|
|
14
|
+
import { playJob, ravensightOrigins, resolvePersonas } from '../commands/run.js';
|
|
15
|
+
import { readLiveSite } from './livesite/options.js';
|
|
16
|
+
import { pinRefusal } from './livesite/run.js';
|
|
17
|
+
import { redactingLog } from './redaction.js';
|
|
15
18
|
import { serveBuildDir } from './serveBuild.js';
|
|
16
19
|
|
|
17
20
|
/** Server states that only a live process can be in, and this one is resuming it. */
|
|
@@ -58,7 +61,8 @@ const ABANDONED_MID_RUN = Object.freeze(['launching', 'playing']);
|
|
|
58
61
|
*/
|
|
59
62
|
export async function resumeJob({ api, gameId, jobId, job, runs, state, repoRoot, flags = {} }, injected = {}) {
|
|
60
63
|
const deps = injected.deps || (await getDeps());
|
|
61
|
-
|
|
64
|
+
// A live URL job's sign-in secrets never reach a printed line (./redaction.js).
|
|
65
|
+
const log = redactingLog(injected.log || (deps.ui && deps.ui.info ? message => deps.ui.info(message) : message => console.log(message)));
|
|
62
66
|
const { options } = optionsFrom(flags);
|
|
63
67
|
|
|
64
68
|
const journal = state || (await stateFile.load(repoRoot, jobId));
|
|
@@ -133,6 +137,28 @@ export async function resumeJob({ api, gameId, jobId, job, runs, state, repoRoot
|
|
|
133
137
|
}
|
|
134
138
|
}
|
|
135
139
|
const target = servedTarget || journal.target || options.buildUrl || options.godotProject;
|
|
140
|
+
// A live URL job plays under the same rules again, and signs in again: the secrets were never saved,
|
|
141
|
+
// so the same sign-in flags are asked for, read from the environment as before.
|
|
142
|
+
let liveSite = null;
|
|
143
|
+
if (journal.options?.liveUrl) {
|
|
144
|
+
const saved = journal.options.liveUrl;
|
|
145
|
+
const password = saved.signIn?.method === 'password' && (options.loginEmail !== undefined || options.loginPasswordEnv !== undefined);
|
|
146
|
+
const read = readLiveSite({
|
|
147
|
+
...options, url: saved.startUrl, buildUrl: undefined, buildDir: undefined,
|
|
148
|
+
...(password && options.signInUrl === undefined && saved.signIn.signInUrl ? { signInUrl: saved.signIn.signInUrl } : {}),
|
|
149
|
+
...(password && options.signInSelectors === undefined && saved.signIn.selectors ? { signInSelectors: JSON.stringify(saved.signIn.selectors) } : {})
|
|
150
|
+
}, injected.env || process.env);
|
|
151
|
+
if (read.error) { log(`${read.error} Nothing was replayed or charged.`); return EXIT.ENVIRONMENT; }
|
|
152
|
+
const wanted = saved.signIn?.method || 'none';
|
|
153
|
+
if (read.liveSite.signIn.method !== wanted || (wanted === 'session' && read.liveSite.signIn.kind !== saved.signIn.kind)) {
|
|
154
|
+
const flags = wanted === 'password' ? '--login-email and --login-password-env' : saved.signIn?.kind === 'header' ? '--session-header-env' : saved.signIn?.kind === 'cookie' ? '--session-cookie-env' : 'no sign-in flag';
|
|
155
|
+
log(`This job signs in to ${saved.startUrl} ${wanted === 'none' ? 'without an account' : 'with a test account'}. Pass ${flags} again to resume it. Nothing was replayed or charged.`);
|
|
156
|
+
return EXIT.ENVIRONMENT;
|
|
157
|
+
}
|
|
158
|
+
liveSite = { ...read.liveSite, ravensightOrigins: ravensightOrigins(api.apiUrl) };
|
|
159
|
+
const unpinned = liveSite.local ? null : await pinRefusal(liveSite, { lookup: injected.lookup });
|
|
160
|
+
if (unpinned) { log(`${unpinned[0]} Nothing was replayed or charged.`); return EXIT.ENVIRONMENT; }
|
|
161
|
+
}
|
|
136
162
|
if (!target) {
|
|
137
163
|
log('The journal does not say what this job was pointed at. Pass --build-url or --godot-project.');
|
|
138
164
|
return EXIT.ENVIRONMENT;
|
|
@@ -222,7 +248,8 @@ export async function resumeJob({ api, gameId, jobId, job, runs, state, repoRoot
|
|
|
222
248
|
...(Number.isInteger(journal.options?.longRunFactor) ? { longRunFactor: journal.options.longRunFactor } : {}),
|
|
223
249
|
concurrency: options.concurrency ?? (journal.options && journal.options.concurrency),
|
|
224
250
|
uploadVideo: options.uploadVideo ?? (journal.options && journal.options.uploadVideo),
|
|
225
|
-
uploadTranscript: options.uploadTranscript ?? (journal.options && journal.options.uploadTranscript)
|
|
251
|
+
uploadTranscript: options.uploadTranscript ?? (journal.options && journal.options.uploadTranscript),
|
|
252
|
+
...(liveSite ? { liveSite } : {})
|
|
226
253
|
};
|
|
227
254
|
|
|
228
255
|
let nativeLease = null;
|
package/src/run/state.js
CHANGED
|
@@ -2,6 +2,7 @@ import { randomUUID } from 'node:crypto';
|
|
|
2
2
|
import { mkdir, readFile, rename, writeFile } from 'node:fs/promises';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { jobDir, JOB_FILES } from './paths.js';
|
|
5
|
+
import { redactText } from './redaction.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* `state.json`, the resumable job journal (spec 17 section 1.8). Written
|
|
@@ -138,7 +139,8 @@ export async function save(repoRoot, state) {
|
|
|
138
139
|
async function writeOnce(target, state) {
|
|
139
140
|
await mkdir(path.dirname(target), { recursive: true });
|
|
140
141
|
state.updated_at = new Date().toISOString();
|
|
141
|
-
|
|
142
|
+
// A live URL run's sign-in secrets never reach the journal (./redaction.js).
|
|
143
|
+
const body = redactText(`${JSON.stringify(state, null, 2)}\n`);
|
|
142
144
|
const tmp = `${target}.${process.pid}.${randomUUID()}.tmp`;
|
|
143
145
|
await writeFile(tmp, body, 'utf8');
|
|
144
146
|
await rename(tmp, target);
|
|
@@ -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.
|