ravensight-playtest 0.10.3 → 0.11.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 +55 -17
- package/package.json +5 -4
- package/src/api/client.js +17 -1
- package/src/cli.js +4 -0
- package/src/commands/create.js +38 -4
- package/src/commands/fakeCore.js +2 -0
- package/src/commands/feature.js +14 -1
- package/src/commands/fix.js +2 -0
- package/src/commands/hosted.js +7 -3
- package/src/commands/run.js +34 -0
- package/src/hosted/recordedRun.js +42 -7
- package/src/run/anygame/gamenotes.js +208 -0
- package/src/run/anygame/shared-hashes.json +6 -2
- package/src/run/anygame/shared.js +8 -3
- package/src/run/avoid.js +58 -0
- package/src/run/claimGate.js +25 -73
- package/src/run/claimwords.js +242 -0
- package/src/run/drivers/godot.js +37 -1
- package/src/run/drivers/web.js +91 -0
- package/src/run/edgePass.js +9 -3
- package/src/run/eventclaims.js +246 -0
- package/src/run/events.js +354 -0
- package/src/run/gameMemory.js +148 -0
- package/src/run/honesty.js +27 -1
- package/src/run/judge.js +229 -0
- package/src/run/personaLoop.js +237 -119
- package/src/run/reportChecks.js +16 -7
- package/src/run/testerProbes.js +12 -4
- package/src/run/tools.js +11 -0
- package/src/run/usage.js +5 -2
package/src/run/reportChecks.js
CHANGED
|
@@ -99,6 +99,8 @@ export function screenOf(text, url) {
|
|
|
99
99
|
export const FRAME_AFTER_MS = 600;
|
|
100
100
|
/** How far back a second try at a frame goes when the first could not be cut. */
|
|
101
101
|
export const FRAME_RETRY_BACK_MS = 1000;
|
|
102
|
+
/** A look's frame, when its own moment cannot be cut, is tried this much earlier: the screen it saw had stood since its last input settled. */
|
|
103
|
+
export const LOOK_RETRY_BACK_MS = 300;
|
|
102
104
|
export const FRAME_WIDTH = 960;
|
|
103
105
|
export const FRAME_TIMEOUT_MS = 20000;
|
|
104
106
|
/** Frames cut for one run at most. */
|
|
@@ -149,7 +151,9 @@ export async function cutFrame({ ffmpeg, video, atMs, out, width = FRAME_WIDTH,
|
|
|
149
151
|
*/
|
|
150
152
|
export async function cutFindingFrames({ runDirectory, index = [], video = null, transcript, viewport = null, detect = detectFfmpeg, cut = cutFrame, placed = new Set() }) {
|
|
151
153
|
const frames = new Map();
|
|
152
|
-
|
|
154
|
+
// A judgement made from a look is cut at the look's own moment: the screen the playtester saw, before the next input.
|
|
155
|
+
const momentOf = entry => (entry.look && Number.isFinite(entry.look_ms) ? entry.look_ms : entry.video_ms);
|
|
156
|
+
const wanted = index.filter(entry => entry && typeof entry.id === 'string' && Number.isFinite(momentOf(entry)) && !placed.has(entry.id)).slice(0, MAX_FRAMES);
|
|
153
157
|
if (!video || !video.file || wanted.length === 0) return frames;
|
|
154
158
|
let ffmpeg = null;
|
|
155
159
|
try { ffmpeg = (await detect())?.path || null; } catch { ffmpeg = null; }
|
|
@@ -167,7 +171,11 @@ export async function cutFindingFrames({ runDirectory, index = [], video = null,
|
|
|
167
171
|
// last moments of a recording that ended under a freeze is often past
|
|
168
172
|
// the last frame the file can seek to.
|
|
169
173
|
let at = null;
|
|
170
|
-
|
|
174
|
+
const looked = entry.look && Number.isFinite(entry.look_ms);
|
|
175
|
+
const candidates = looked
|
|
176
|
+
? [Math.round(Math.min(entry.look_ms, end)), Math.round(Math.max(0, Math.min(entry.look_ms, end) - LOOK_RETRY_BACK_MS))]
|
|
177
|
+
: [Math.round(Math.min(entry.video_ms + FRAME_AFTER_MS, end)), Math.round(Math.max(0, Math.min(entry.video_ms, end) - FRAME_RETRY_BACK_MS))];
|
|
178
|
+
for (const candidate of candidates) {
|
|
171
179
|
let ok = false;
|
|
172
180
|
try { ok = await cut({ ffmpeg, video: file, atMs: candidate, out: path.join(runDirectory, relative) }); } catch { ok = false; }
|
|
173
181
|
if (ok) { at = candidate; break; }
|
|
@@ -175,11 +183,11 @@ export async function cutFindingFrames({ runDirectory, index = [], video = null,
|
|
|
175
183
|
if (at === null) {
|
|
176
184
|
// No picture, but the moment stands: the dashboard places the finding
|
|
177
185
|
// at this step rather than at whatever screenshot it happens to cite.
|
|
178
|
-
transcript.write({ kind: 'finding_frame', id: entry.id, path: null, source: 'none', reason: 'no frame could be cut from the video at this moment', video_ms: Math.round(entry
|
|
186
|
+
transcript.write({ kind: 'finding_frame', id: entry.id, path: null, source: 'none', reason: 'no frame could be cut from the video at this moment', video_ms: Math.round(momentOf(entry)), ...step, ...(looked ? { look: true } : {}) });
|
|
179
187
|
continue;
|
|
180
188
|
}
|
|
181
|
-
frames.set(entry.id, { path: relative, video_ms: at });
|
|
182
|
-
transcript.write({ kind: 'finding_frame', id: entry.id, path: relative, source: 'video', video_ms: at, ...step, ...(viewport && viewport.width > 0 && viewport.height > 0 ? { viewport: { width: viewport.width, height: viewport.height } } : {}) });
|
|
189
|
+
frames.set(entry.id, { path: relative, video_ms: at, ...(looked ? { look: true } : {}) });
|
|
190
|
+
transcript.write({ kind: 'finding_frame', id: entry.id, path: relative, source: 'video', video_ms: at, ...step, ...(looked ? { look: true } : {}), ...(viewport && viewport.width > 0 && viewport.height > 0 ? { viewport: { width: viewport.width, height: viewport.height } } : {}) });
|
|
183
191
|
}
|
|
184
192
|
return frames;
|
|
185
193
|
}
|
|
@@ -374,7 +382,7 @@ export function traceWebInputs(driver, { fingerprint }) {
|
|
|
374
382
|
const result = await act(action);
|
|
375
383
|
let print = null;
|
|
376
384
|
try { print = fingerprint(await driver.screenProbe()); } catch { print = null; }
|
|
377
|
-
trace.push({ action, ok: Boolean(result) && result.ok !== false && !result.refused, changed: result ? result.changed : null, print });
|
|
385
|
+
trace.push({ action, ok: Boolean(result) && result.ok !== false && !result.refused, changed: result ? result.changed : null, print, ...(result && result.refused === 'avoided' ? { avoided: true } : {}) });
|
|
378
386
|
return result;
|
|
379
387
|
};
|
|
380
388
|
driver.webTrace = trace;
|
|
@@ -437,7 +445,8 @@ export async function replayWebFindings({ report, index = [], traceSteps = new M
|
|
|
437
445
|
for (let n = 0; n < last; n++) {
|
|
438
446
|
if (now() > deadline) break;
|
|
439
447
|
const entry = trace[n];
|
|
440
|
-
|
|
448
|
+
// An input the run refused because the brief asks to stay out of it is never sent by the replay either.
|
|
449
|
+
if (!entry.avoided) await driver.act(entry.action);
|
|
441
450
|
let after = null;
|
|
442
451
|
try { after = fingerprint(await driver.screenProbe()); } catch { after = null; }
|
|
443
452
|
for (const hit of targets.filter(candidate => candidate.trace_steps === n + 1)) {
|
package/src/run/testerProbes.js
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
import { pngFingerprint, screenDelta, significant } from './pixels.js';
|
|
26
26
|
import { flatShare, BLANK_SHARE, runnerFinding, stepsBefore } from './honesty.js';
|
|
27
27
|
import { readings, NEVER_NEGATIVE, BOUNDED, NEVER_FALLS } from './testerLedger.js';
|
|
28
|
+
import { createAvoidGuard, controlNameAt } from './avoid.js';
|
|
28
29
|
|
|
29
30
|
/** The heading the probes are written under in report.md. */
|
|
30
31
|
export const PROBES_HEADING = '## Tester probes (run by the runner after play, no model call)';
|
|
@@ -176,7 +177,9 @@ const q = value => `"${String(value || '').replace(/"/g, "'").slice(0, 60)}"`;
|
|
|
176
177
|
* @param {Object} args
|
|
177
178
|
* @returns {Promise<{checks: Array<Object>, elapsedMs: number, canaries: Array<string>}>}
|
|
178
179
|
*/
|
|
179
|
-
export async function runTesterProbes({ driver, actionRecords = [], screenshots = [], observation = null, signal = null, log = () => {}, sleep = ms => new Promise(resolve => setTimeout(resolve, ms)), timing = PROBE_TIMING, only = null, loading = false, retries = timing.retries, save = true }) {
|
|
180
|
+
export async function runTesterProbes({ driver, actionRecords = [], screenshots = [], observation = null, signal = null, log = () => {}, sleep = ms => new Promise(resolve => setTimeout(resolve, ms)), timing = PROBE_TIMING, only = null, loading = false, retries = timing.retries, save = true, avoid = [] }) {
|
|
181
|
+
// What the brief asks the run to stay out of (./avoid.js): no probe sees a control it names, so none presses it.
|
|
182
|
+
const guard = createAvoidGuard(avoid);
|
|
180
183
|
const session = driver.edgeSession();
|
|
181
184
|
const page = session.page;
|
|
182
185
|
const started = Date.now();
|
|
@@ -199,7 +202,8 @@ export async function runTesterProbes({ driver, actionRecords = [], screenshots
|
|
|
199
202
|
const keys = { down: key => input(() => page.keyboard.down(key)), up: key => input(() => page.keyboard.up(key)), press: key => input(() => page.keyboard.press(key)) };
|
|
200
203
|
const evaluate = (fn, arg) => { if (hung) return Promise.reject(new Error(hung)); let timer; return Promise.race([Promise.resolve().then(() => page.evaluate(fn, arg)), new Promise((resolve, reject) => { timer = setTimeout(() => reject(new Error('the page did not answer')), 8000); })]).finally(() => clearTimeout(timer)); };
|
|
201
204
|
// A page that stopped answering is not asked again: each ask would wait out its own timeout.
|
|
202
|
-
const
|
|
205
|
+
const leaveAlone = c => ({ ...c, buttons: (c.buttons || []).filter(b => !guard.skip(b.name)), fields: (c.fields || []).filter(f => !guard.skip(f.name)) });
|
|
206
|
+
const controls = () => (hung ? Promise.resolve({ buttons: [], fields: [], text: '', canvas: null }) : evaluate(pageControls).then(leaveAlone).catch(() => ({ buttons: [], fields: [], text: '', canvas: null })));
|
|
203
207
|
const print = async () => { if (hung) return null; try { return pngFingerprint(await page.screenshot({ type: 'png', timeout: 10000 })); } catch { return null; } };
|
|
204
208
|
const look = async () => { const c = await controls(); return { ...c, print: await print(), sig: `${c.text}\n${c.buttons.map(b => `${b.name}|${b.disabled ? 1 : 0}`).join('\n')}` }; };
|
|
205
209
|
const differs = (a, b) => a.sig !== b.sig || (a.print && b.print ? significant(screenDelta(a.print, b.print)) : false);
|
|
@@ -506,11 +510,14 @@ export async function runTesterProbes({ driver, actionRecords = [], screenshots
|
|
|
506
510
|
await run('loading', async () => {
|
|
507
511
|
const what = 'clicks and keys were sent while the page was still loading';
|
|
508
512
|
const size = page.viewportSize() || { width: 1280, height: 720 };
|
|
513
|
+
// The centre is not clicked when a control the brief says to stay out of sits there.
|
|
514
|
+
const centre = [Math.round(size.width / 2), Math.round(size.height / 2)];
|
|
515
|
+
const centreClick = !guard.lines.length || !guard.skip(await evaluate(controlNameAt, centre).catch(() => ''));
|
|
509
516
|
const once = async () => {
|
|
510
517
|
errors();
|
|
511
518
|
const going = page.reload({ waitUntil: 'load', timeout: 15000 }).then(() => true, () => false);
|
|
512
519
|
const until = Date.now() + timing.loadInputMs;
|
|
513
|
-
while (Date.now() < until) { await mouse.click(
|
|
520
|
+
while (Date.now() < until) { if (centreClick) await mouse.click(centre[0], centre[1]).catch(() => {}); await keys.press('Enter').catch(() => {}); await keys.press(' ').catch(() => {}); await sleep(40); }
|
|
514
521
|
const loaded = await going;
|
|
515
522
|
await sleep(timing.settleMs + 400);
|
|
516
523
|
if (!loaded) return [{ oracle: 'no_load', severity: 'major', category: 'bug', title: 'The game does not load when input arrives while it is loading', description: 'With clicks and keys sent while the page was loading, it did not finish loading. It had loaded when left alone.' }];
|
|
@@ -552,7 +559,7 @@ export async function runTesterProbes({ driver, actionRecords = [], screenshots
|
|
|
552
559
|
for (const [id, title] of PROBES) if (!checks.some(c => c.name === id) && (id === 'loading') === Boolean(loading) && (!only || only.includes(id))) { checks.push({ name: id, title, status: 'not_checked', detail: hung }); log(`tester probe, ${title}: not_checked (${hung})`); }
|
|
553
560
|
}
|
|
554
561
|
if (failure && !late) throw failure;
|
|
555
|
-
return { checks: [...checks], suspects: suspects.map(({ again: _again, ...rest }) => rest), canaries: [...canaries], elapsedMs: Date.now() - started, ...(hung ? { stopped: hung } : {}) };
|
|
562
|
+
return { checks: [...checks], suspects: suspects.map(({ again: _again, ...rest }) => rest), canaries: [...canaries], elapsedMs: Date.now() - started, ...(hung ? { stopped: hung } : {}), avoided: guard.list() };
|
|
556
563
|
}
|
|
557
564
|
|
|
558
565
|
/**
|
|
@@ -612,6 +619,7 @@ export function probesMarkdown(pass) {
|
|
|
612
619
|
if (!check) return `- **${title}**: not tested. The probes ended before it.`;
|
|
613
620
|
return `- **${title}**: ${STATUS[check.status] || check.status}. ${String(check.detail || '').replace(/\.?$/, '.')}`;
|
|
614
621
|
});
|
|
622
|
+
if (Array.isArray(pass.avoided) && pass.avoided.length) lines.push('', `Not pressed, because the brief asks to stay out of it: ${pass.avoided.map(name => `"${String(name).replace(/"/g, "'")}"`).join(', ')}.`);
|
|
615
623
|
lines.push('', `A soft lock was ${pass.canaries && pass.canaries.length ? `watched for after each probe, with ${pass.canaries.length === 1 ? 'a button' : `${pass.canaries.length} buttons`} that changed the screen twice running` : 'not watched for: no button play pressed changed the screen twice running, so there was nothing to compare against'}. These probes are scripted. Not tested never means it works.`);
|
|
616
624
|
return lines.join('\n').replace(/[\u2013\u2014]/g, ',');
|
|
617
625
|
}
|
package/src/run/tools.js
CHANGED
|
@@ -732,6 +732,17 @@ export async function executeTool({ driver, toolUse, onNote, onScreenshot, stale
|
|
|
732
732
|
// The runner refused to leave the build. The persona is told so in plain
|
|
733
733
|
// text and plays on: it is a step that changed nothing, never an error and
|
|
734
734
|
// never a run failure. No observation either, because nothing moved.
|
|
735
|
+
// An input on a control the brief asks the run to stay out of: not sent. The persona is told plainly and plays on.
|
|
736
|
+
if (outcome.refused === 'avoided') {
|
|
737
|
+
return {
|
|
738
|
+
result: toolResult(toolUse.id, `Not sent: the brief asks to stay out of "${outcome.name}". Leave it alone and choose another input.`),
|
|
739
|
+
observation: null,
|
|
740
|
+
spentAction: false,
|
|
741
|
+
changed: false,
|
|
742
|
+
error: null,
|
|
743
|
+
refused: 'avoided'
|
|
744
|
+
};
|
|
745
|
+
}
|
|
735
746
|
if (outcome.refused === 'off_site') {
|
|
736
747
|
return {
|
|
737
748
|
result: toolResult(toolUse.id, offSiteRefusalText(outcome.host)),
|
package/src/run/usage.js
CHANGED
|
@@ -173,9 +173,12 @@ export function weightedUnits(usage = {}) {
|
|
|
173
173
|
* @param {ReturnType<typeof createUsageLedger>} ledger
|
|
174
174
|
* @returns {Promise<string>} the path written
|
|
175
175
|
*/
|
|
176
|
-
export async function writeUsageFile(runDirectory, ledger) {
|
|
176
|
+
export async function writeUsageFile(runDirectory, ledger, extra = {}) {
|
|
177
177
|
const target = path.join(runDirectory, RUN_FILES.usageJson);
|
|
178
|
-
|
|
178
|
+
// What the run measured beside its spend, as the hosted runner's usage.json carries it: the game's own events
|
|
179
|
+
// (`gameEvents`) and the notes it hands on to the next playtest of the game (`gameMemory`). Absent when there are none.
|
|
180
|
+
const more = Object.fromEntries(Object.entries(extra || {}).filter(([, value]) => value !== null && value !== undefined));
|
|
181
|
+
const body = `${JSON.stringify({ ...ledger.toUsageFile(), ...more }, null, 2)}\n`;
|
|
179
182
|
// Token counts and model ids should never look secret shaped, and that is
|
|
180
183
|
// the point of checking: this file is uploaded by default, so anything
|
|
181
184
|
// unexpected in it is refused rather than shipped.
|