ravensight-playtest 0.10.3 → 0.10.4
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/package.json +1 -1
- package/src/run/avoid.js +58 -0
- package/src/run/drivers/web.js +51 -0
- package/src/run/edgePass.js +9 -3
- package/src/run/personaLoop.js +20 -3
- package/src/run/reportChecks.js +3 -2
- package/src/run/testerProbes.js +12 -4
- package/src/run/tools.js +11 -0
package/package.json
CHANGED
package/src/run/avoid.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the studio asked a run to stay out of (`--avoid`, the brief's
|
|
3
|
+
* `this_run_focus.stay_out_of`), for every input a local run sends: the
|
|
4
|
+
* persona's own (refused in the web driver before it reaches the page), the
|
|
5
|
+
* tester probes and the edge behaviour checks. One matcher, the any-game
|
|
6
|
+
* layer's (./anygame/language.js avoidedIn, every language), shared with the
|
|
7
|
+
* cloud runner (direct-runner/lib/avoid.mjs). On a paid 0.10.1 web run the
|
|
8
|
+
* probes pressed "Pull the red lever" the brief said to avoid, and the page
|
|
9
|
+
* never answered again.
|
|
10
|
+
*/
|
|
11
|
+
import { avoidedIn } from './anygame/language.js';
|
|
12
|
+
|
|
13
|
+
const clip = s => String(s ?? '').replace(/\s+/g, ' ').trim().slice(0, 80);
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The avoid lines a brief carries for this run, or [].
|
|
17
|
+
*
|
|
18
|
+
* @param {Object|null} brief
|
|
19
|
+
* @returns {string[]}
|
|
20
|
+
*/
|
|
21
|
+
export function avoidLinesOf(brief) {
|
|
22
|
+
const block = brief && typeof brief === 'object' ? (brief.fields && brief.fields.this_run_focus) || brief.this_run_focus : null;
|
|
23
|
+
const lines = block && Array.isArray(block.stay_out_of) ? block.stay_out_of : [];
|
|
24
|
+
return lines.map(line => String(line || '').trim()).filter(Boolean).slice(0, 10);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* `{ lines, skip(name), list(), line() }`: `skip` answers whether a control by
|
|
29
|
+
* that name is one to stay out of and keeps its name for the report.
|
|
30
|
+
*
|
|
31
|
+
* @param {string[]} avoid
|
|
32
|
+
*/
|
|
33
|
+
export function createAvoidGuard(avoid = []) {
|
|
34
|
+
const lines = (Array.isArray(avoid) ? avoid : []).map(line => String(line || '').trim()).filter(Boolean).slice(0, 10);
|
|
35
|
+
const skipped = new Set();
|
|
36
|
+
const named = name => lines.length > 0 && Boolean(clip(name)) && avoidedIn(String(name), lines);
|
|
37
|
+
return {
|
|
38
|
+
lines,
|
|
39
|
+
named,
|
|
40
|
+
skip(name) { if (!named(name)) return false; skipped.add(clip(name)); return true; },
|
|
41
|
+
note(name) { if (clip(name)) skipped.add(clip(name)); },
|
|
42
|
+
list: () => [...skipped],
|
|
43
|
+
line: () => (skipped.size ? `Not pressed, because the brief asks to stay out of it: ${[...skipped].map(n => `"${n.replace(/"/g, "'")}"`).join(', ')}.` : null)
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/* c8 ignore start */
|
|
48
|
+
/** Runs in the page: the name of the clickable control at a point, by its label or text, or ''. */
|
|
49
|
+
export function controlNameAt([x, y]) {
|
|
50
|
+
let el = document.elementFromPoint(x, y);
|
|
51
|
+
const control = el && el.closest('button, [role=button], a, input, select, textarea, label, summary, [onclick]');
|
|
52
|
+
el = control || el;
|
|
53
|
+
if (!el) return '';
|
|
54
|
+
return String(el.getAttribute('aria-label') || el.innerText || el.value || el.getAttribute('title') || '').replace(/\s+/g, ' ').trim().slice(0, 120);
|
|
55
|
+
}
|
|
56
|
+
/* c8 ignore stop */
|
|
57
|
+
|
|
58
|
+
export default { avoidLinesOf, createAvoidGuard, controlNameAt };
|
package/src/run/drivers/web.js
CHANGED
|
@@ -13,6 +13,7 @@ import { mkdir, rename, stat, readdir, rm, chmod } from 'node:fs/promises';
|
|
|
13
13
|
import { recordingLimits, recordingViewport, recordingDirectory, recordingMetadata, saveRecording, probeVideo, videoInfo } from './recording.js';
|
|
14
14
|
import path from 'node:path';
|
|
15
15
|
import { gameRefusal, runnerGone } from '../gameRefusal.js';
|
|
16
|
+
import { createAvoidGuard } from '../avoid.js';
|
|
16
17
|
import {
|
|
17
18
|
DEFAULT_DRAG_MS, DOUBLE_CLICK_GAP_MS, KEY_REPEAT_DELAY_MS, KEY_REPEAT_INTERVAL_MS, MAX_DRAG_MS, MAX_HOLD_MS,
|
|
18
19
|
dragPath, mouseButton, sequenceEvents, webKeyName, wheelNotches
|
|
@@ -1390,6 +1391,8 @@ export async function needsFrame(page, text) {
|
|
|
1390
1391
|
|
|
1391
1392
|
export function createWebDriver({ importer, headless = true, playtest = null, platform = process.platform, modifier = null, recording = {}, now = () => Date.now(), inspectVideo = probeVideo, freezeTime = true, touch = false, frameStrip = true } = {}) {
|
|
1392
1393
|
const editModifier = modifier === 'Meta' || modifier === 'Control' ? modifier : platformModifier(platform);
|
|
1394
|
+
// What the brief asks the run to stay out of (../avoid.js): an input on such a control is never sent (setAvoid).
|
|
1395
|
+
let avoidGuard = createAvoidGuard([]);
|
|
1393
1396
|
let browser = null;
|
|
1394
1397
|
let context = null;
|
|
1395
1398
|
let page = null;
|
|
@@ -1947,6 +1950,42 @@ export function createWebDriver({ importer, headless = true, playtest = null, pl
|
|
|
1947
1950
|
return { x: Math.round(box.x + box.width / 2), y: Math.round(box.y + box.height / 2) };
|
|
1948
1951
|
}
|
|
1949
1952
|
|
|
1953
|
+
/** The name of the control at a point on the page: the clickable thing under it, by its label or text. */
|
|
1954
|
+
const nameAtPoint = (current, point) => current.evaluate(({ x, y }) => {
|
|
1955
|
+
let el = document.elementFromPoint(x, y);
|
|
1956
|
+
const control = el && el.closest('button, [role=button], a, input, select, textarea, label, summary, [onclick]');
|
|
1957
|
+
el = control || el;
|
|
1958
|
+
if (!el) return '';
|
|
1959
|
+
return String(el.getAttribute('aria-label') || el.innerText || el.value || el.getAttribute('title') || '').replace(/\s+/g, ' ').trim().slice(0, 120);
|
|
1960
|
+
}, point).catch(() => '');
|
|
1961
|
+
|
|
1962
|
+
/** The name of the control an action spec lands on, or '' when it cannot be told without acting. */
|
|
1963
|
+
async function controlNameOf(current, spec) {
|
|
1964
|
+
try {
|
|
1965
|
+
if (!spec.ref && spec.target && typeof spec.target === 'object') return await nameAtPoint(current, { x: Number(spec.target.x), y: Number(spec.target.y) });
|
|
1966
|
+
if (!spec.ref && lastMarks && isMarkTarget(spec.target)) { const point = resolveMark(spec.target, lastMarks); return point ? await nameAtPoint(current, point) : ''; }
|
|
1967
|
+
const resolved = await targetFor(current, spec);
|
|
1968
|
+
if (resolved && resolved.point) return await nameAtPoint(current, resolved.point);
|
|
1969
|
+
return await resolved.evaluate(el => String(el.getAttribute('aria-label') || el.innerText || el.value || el.getAttribute('title') || '').replace(/\s+/g, ' ').trim().slice(0, 120), null, { timeout: 2000 });
|
|
1970
|
+
} catch {
|
|
1971
|
+
return '';
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
|
|
1975
|
+
/** The control an action would press that the brief asks to stay out of, by name, or null. */
|
|
1976
|
+
async function avoidedTargetOf(current, action) {
|
|
1977
|
+
if (!avoidGuard.lines.length || !action) return null;
|
|
1978
|
+
const specs = ['click', 'hover', 'type', 'select'].includes(action.kind) ? [action] : ['drag', 'swipe'].includes(action.kind) ? [endSpec(action.from), endSpec(action.to)] : [];
|
|
1979
|
+
for (const spec of specs) {
|
|
1980
|
+
const text = typeof spec.target === 'string' ? spec.target : '';
|
|
1981
|
+
if (text && avoidGuard.named(text)) return text.replace(/^[a-z]+\s+"(.*)"$/, '$1');
|
|
1982
|
+
if (!spec.ref && !spec.target) continue;
|
|
1983
|
+
const name = await controlNameOf(current, spec);
|
|
1984
|
+
if (name && avoidGuard.named(name)) return name;
|
|
1985
|
+
}
|
|
1986
|
+
return null;
|
|
1987
|
+
}
|
|
1988
|
+
|
|
1950
1989
|
/** One end of a drag as pointFor takes it: a ref, a name or a point. */
|
|
1951
1990
|
function endSpec(end) {
|
|
1952
1991
|
if (end && typeof end === 'object') return { target: end };
|
|
@@ -3045,6 +3084,12 @@ export function createWebDriver({ importer, headless = true, playtest = null, pl
|
|
|
3045
3084
|
if (pendingDialog) return answerDialog(current, action);
|
|
3046
3085
|
await assertAlive(current);
|
|
3047
3086
|
await settled();
|
|
3087
|
+
// A control the brief asks the run to stay out of is never pressed, whoever chose the input: refused, and kept for the report.
|
|
3088
|
+
const avoidedName = await avoidedTargetOf(current, action);
|
|
3089
|
+
if (avoidedName) {
|
|
3090
|
+
avoidGuard.note(avoidedName);
|
|
3091
|
+
return { ok: false, changed: false, refused: 'avoided', name: avoidedName, error: `the brief asks to stay out of "${avoidedName}", so the runner did not send that input` };
|
|
3092
|
+
}
|
|
3048
3093
|
const attemptsBefore = offSiteCount;
|
|
3049
3094
|
// The game runs while an action plays and stands still while the
|
|
3050
3095
|
// persona thinks, on a game drawn in a canvas.
|
|
@@ -3077,6 +3122,12 @@ export function createWebDriver({ importer, headless = true, playtest = null, pl
|
|
|
3077
3122
|
return outcome;
|
|
3078
3123
|
},
|
|
3079
3124
|
|
|
3125
|
+
/** The brief's avoid lines for this run (../avoid.js): an input on a control they name is refused before the page. */
|
|
3126
|
+
setAvoid(lines) { avoidGuard = createAvoidGuard(lines); },
|
|
3127
|
+
|
|
3128
|
+
/** The controls an input was refused on because the brief asks to stay out of them, by name. */
|
|
3129
|
+
avoidedControls() { return avoidGuard.list(); },
|
|
3130
|
+
|
|
3080
3131
|
/**
|
|
3081
3132
|
* Every attempt to leave the build since the last call, claimed by an
|
|
3082
3133
|
* action or not (a timer redirect between actions has no action), for the
|
package/src/run/edgePass.js
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
// defect by itself) or not_checked (with the reason, which is a limit of the
|
|
11
11
|
// runner). A check never guesses: a problem is only what was measured.
|
|
12
12
|
import { pngFingerprint, screenDelta, significant } from './pixels.js';
|
|
13
|
+
import { createAvoidGuard, controlNameAt } from './avoid.js';
|
|
13
14
|
import { flatShare, BLANK_SHARE, runnerFinding, stepsBefore } from './honesty.js';
|
|
14
15
|
|
|
15
16
|
/** The heading the checks are written under in report.md. */
|
|
@@ -345,7 +346,9 @@ export function blankCapabilityNote(checks = []) {
|
|
|
345
346
|
return { input: 'blank screen check', reason: `the blank screen part of ${held.map(check => check.title).join(', ')} could not be made: ${why}` };
|
|
346
347
|
}
|
|
347
348
|
|
|
348
|
-
export async function runEdgePass({ driver, actionRecords = [], screenshots = [], observation = null, signal = null, log = () => {}, sleep = ms => new Promise(resolve => setTimeout(resolve, ms)), timing = EDGE_TIMING, sizes = EDGE_SIZES }) {
|
|
349
|
+
export async function runEdgePass({ driver, actionRecords = [], screenshots = [], observation = null, signal = null, log = () => {}, sleep = ms => new Promise(resolve => setTimeout(resolve, ms)), timing = EDGE_TIMING, sizes = EDGE_SIZES, avoid = [] }) {
|
|
350
|
+
// What the brief asks the run to stay out of (./avoid.js): no check clicks a control it names.
|
|
351
|
+
const guard = createAvoidGuard(avoid);
|
|
349
352
|
const session = driver.edgeSession();
|
|
350
353
|
const { context } = session;
|
|
351
354
|
// Reads of the page are bounded: one that never answers reads as nothing.
|
|
@@ -599,7 +602,9 @@ export async function runEdgePass({ driver, actionRecords = [], screenshots = []
|
|
|
599
602
|
if (!stopped()) {
|
|
600
603
|
const title = 'rapid input';
|
|
601
604
|
const keys = usedKeysOf(actionRecords);
|
|
602
|
-
const
|
|
605
|
+
const lastPoint = lastClickPoint(actionRecords);
|
|
606
|
+
// The point play last clicked is not clicked again when the control there is one the brief says to stay out of.
|
|
607
|
+
const point = lastPoint && guard.lines.length && guard.skip(await page.evaluate(controlNameAt, [lastPoint.x, lastPoint.y]).catch(() => '')) ? null : lastPoint;
|
|
603
608
|
let sent = 0;
|
|
604
609
|
for (let i = 0; i < timing.burstKeys && !stopped(); i += 1) {
|
|
605
610
|
if (session.dialogOpen && session.dialogOpen()) break;
|
|
@@ -680,7 +685,7 @@ export async function runEdgePass({ driver, actionRecords = [], screenshots = []
|
|
|
680
685
|
if (session.dismissDialogs) session.dismissDialogs(false);
|
|
681
686
|
await session.parkClock().catch(() => {});
|
|
682
687
|
}
|
|
683
|
-
return { checks, restored, elapsedMs: Date.now() - started };
|
|
688
|
+
return { checks, restored, elapsedMs: Date.now() - started, avoided: guard.list() };
|
|
684
689
|
}
|
|
685
690
|
|
|
686
691
|
/**
|
|
@@ -724,6 +729,7 @@ export function edgeMarkdown(edge) {
|
|
|
724
729
|
return [
|
|
725
730
|
...edge.checks.map(check => `- **${check.title}**: ${STATUS_WORD[check.status] || check.status}. ${String(check.detail || '').replace(/\.?$/, '.')}${check.screenshot ? ` (${check.screenshot})` : ''}`),
|
|
726
731
|
'',
|
|
732
|
+
...(Array.isArray(edge.avoided) && edge.avoided.length ? [`Not pressed, because the brief asks to stay out of it: ${edge.avoided.map(name => `"${String(name).replace(/"/g, "'")}"`).join(', ')}.`, ''] : []),
|
|
727
733
|
'These checks are scripted. A problem here was measured, not judged; a check that could not tell says so.'
|
|
728
734
|
].join('\n');
|
|
729
735
|
}
|
package/src/run/personaLoop.js
CHANGED
|
@@ -22,6 +22,7 @@ import { runEdgePass, edgeFindings, edgeMarkdown, EDGE_HEADING, blankCapabilityN
|
|
|
22
22
|
// Tester techniques (./testerLedger.js): a coverage map, the game's own numbers and placeholder text, kept by the runner.
|
|
23
23
|
import { createTesterLedger, testerFindings, testedMarkdown, TESTED_HEADING } from './testerLedger.js';
|
|
24
24
|
import { runTesterProbes, probeFindings, probesMarkdown, probeObserver, PROBES_HEADING } from './testerProbes.js';
|
|
25
|
+
import { avoidLinesOf } from './avoid.js';
|
|
25
26
|
import { runGodotTesterProbes, godotProbesMarkdown } from './godotTesterProbes.js';
|
|
26
27
|
import { runGodotEdgePass } from './godotEdgePass.js';
|
|
27
28
|
import { recordingMetadata, saveRecording } from './drivers/recording.js';
|
|
@@ -356,6 +357,8 @@ export async function runPersona(args) {
|
|
|
356
357
|
// that rather than still holding `queued`.
|
|
357
358
|
await advance('launching');
|
|
358
359
|
if ('traceSecrets' in driver) driver.traceSecrets = secretsOf(localBrief);
|
|
360
|
+
// What the brief asks the run to stay out of: the driver refuses an input on it, whoever chose the input (./avoid.js).
|
|
361
|
+
if (typeof driver.setAvoid === 'function') driver.setAvoid(avoidLinesOf(brief));
|
|
359
362
|
await driver.launch({ target, runDir: runDirectory, recordVideo, viewport, signal: args.signal });
|
|
360
363
|
// A web run keeps its inputs, in this process only, so its findings can be replayed after the report.
|
|
361
364
|
if (driverName === 'playwright_web' && typeof args.replayDriver === 'function' && args.replayFindings !== false) traceWebInputs(driver, { fingerprint: pngFingerprint });
|
|
@@ -1550,7 +1553,7 @@ async function playLoop({
|
|
|
1550
1553
|
const probing = edgePass && !gameEnded && !canceled && !budgetExceeded && typeof driver.edgeSession === 'function' && driverName === 'playwright_web' && !(argsSignal && argsSignal.aborted);
|
|
1551
1554
|
if (probing) {
|
|
1552
1555
|
try {
|
|
1553
|
-
honesty.probes = await runTesterProbes({ driver, actionRecords, screenshots, observation: observations.length, signal: argsSignal, log });
|
|
1556
|
+
honesty.probes = await runTesterProbes({ driver, actionRecords, screenshots, observation: observations.length, signal: argsSignal, log, avoid: avoidLinesOf(brief) });
|
|
1554
1557
|
transcript.write({ kind: 'tester_probes', elapsed_ms: honesty.probes.elapsedMs, checks: honesty.probes.checks.map(check => ({ name: check.name, status: check.status, detail: check.detail })) });
|
|
1555
1558
|
} catch (error) {
|
|
1556
1559
|
transcript.write({ kind: 'tester_probes_failed', message: String(error && error.message) });
|
|
@@ -1566,7 +1569,7 @@ async function playLoop({
|
|
|
1566
1569
|
// has been saved. A canceled run and a game that already ended skip it.
|
|
1567
1570
|
if (edgePass && !probesStopped && !gameEnded && !canceled && !budgetExceeded && typeof driver.edgeSession === 'function' && !(argsSignal && argsSignal.aborted)) {
|
|
1568
1571
|
try {
|
|
1569
|
-
honesty.edge = await runEdgePass({ driver, actionRecords, screenshots, observation: observations.length, signal: argsSignal, log });
|
|
1572
|
+
honesty.edge = await runEdgePass({ driver, actionRecords, screenshots, observation: observations.length, signal: argsSignal, log, avoid: avoidLinesOf(brief) });
|
|
1570
1573
|
transcript.write({ kind: 'edge_pass', restored: honesty.edge.restored, elapsed_ms: honesty.edge.elapsedMs, checks: honesty.edge.checks.map(check => ({ name: check.name, status: check.status, detail: check.detail })) });
|
|
1571
1574
|
for (const finding of edgeFindings(honesty.edge, { actionRecords, action: actions })) honesty.findings.push(finding);
|
|
1572
1575
|
// A check whose blank screen part could not be told from the start is a limit of the runner, never a finding.
|
|
@@ -1583,14 +1586,19 @@ async function playLoop({
|
|
|
1583
1586
|
// [tester hook] Input while the page loads: a reload, so it comes after the edge checks have asked their own reload what survived.
|
|
1584
1587
|
if (probing && honesty.probes) {
|
|
1585
1588
|
if (!probesStopped) try {
|
|
1586
|
-
const loaded = await runTesterProbes({ driver, actionRecords, screenshots, observation: observations.length, signal: argsSignal, log, loading: true });
|
|
1589
|
+
const loaded = await runTesterProbes({ driver, actionRecords, screenshots, observation: observations.length, signal: argsSignal, log, loading: true, avoid: avoidLinesOf(brief) });
|
|
1587
1590
|
honesty.probes.checks.push(...loaded.checks);
|
|
1588
1591
|
honesty.probes.suspects.push(...loaded.suspects);
|
|
1592
|
+
honesty.probes.avoided = [...new Set([...(honesty.probes.avoided || []), ...(loaded.avoided || [])])];
|
|
1589
1593
|
} catch (error) {
|
|
1590
1594
|
transcript.write({ kind: 'tester_probes_failed', message: String(error && error.message) });
|
|
1591
1595
|
}
|
|
1592
1596
|
for (const finding of probeFindings(honesty.probes, { actionRecords, action: actions })) { if (honesty.findings.some(known => known.title === finding.title)) continue; honesty.findings.push(finding); transcript.write({ kind: 'runner_finding', key: finding.runner.key, title: finding.title }); }
|
|
1593
1597
|
}
|
|
1598
|
+
// What the brief asks the run to stay out of, and what was left alone for it: the persona's own inputs the driver refused,
|
|
1599
|
+
// and the controls the probes and the edge checks did not press (./avoid.js). In the step log and in report.md.
|
|
1600
|
+
honesty.leftAlone = [...new Set([...(typeof driver.avoidedControls === 'function' ? driver.avoidedControls() : []), ...(honesty.probes?.avoided || []), ...(honesty.edge?.avoided || [])])];
|
|
1601
|
+
if (honesty.leftAlone.length) transcript.write({ kind: 'avoided', controls: honesty.leftAlone });
|
|
1594
1602
|
// [tester hook] The tester probes a keyboard can make on a Godot game (./godotTesterProbes.js), before its edge checks start it a second time.
|
|
1595
1603
|
if (edgePass && !gameEnded && !canceled && !budgetExceeded && driver.edgeKind === 'godot' && typeof driver.runFor === 'function' && !(argsSignal && argsSignal.aborted)) {
|
|
1596
1604
|
try {
|
|
@@ -2084,12 +2092,21 @@ export function writeHonesty({ report: given, markdown, honesty, driverName, not
|
|
|
2084
2092
|
}
|
|
2085
2093
|
// [tester hook] What was and was not tested, from the runner's own ledger.
|
|
2086
2094
|
if (honesty.probes) text = replaceSection(text, PROBES_HEADING, honesty.probes.godot ? godotProbesMarkdown(honesty.probes) : probesMarkdown(honesty.probes));
|
|
2095
|
+
if (Array.isArray(honesty.leftAlone) && honesty.leftAlone.length) text = replaceSection(text, AVOID_HEADING, avoidMarkdown(honesty.leftAlone));
|
|
2087
2096
|
if (honesty.tester) text = replaceSection(text, TESTED_HEADING, testedMarkdown(honesty.tester, { edge: honesty.edge, probes: honesty.probes || null }));
|
|
2088
2097
|
text = writeCapabilitySection(text, driverName, honesty.capability.list());
|
|
2089
2098
|
if (located.index.length > 0) text = replaceSection(text, EVIDENCE_HEADING, whereToLookMarkdown(located.index, honesty.video));
|
|
2090
2099
|
return { report: located.report, markdown: text, added, index: located.index };
|
|
2091
2100
|
}
|
|
2092
2101
|
|
|
2102
|
+
/** The heading what the run left alone is written under in report.md. */
|
|
2103
|
+
export const AVOID_HEADING = '## Left alone, as the brief asks (written by the runner)';
|
|
2104
|
+
|
|
2105
|
+
/** What the run left alone because the brief asks to stay out of it, as that section's body. */
|
|
2106
|
+
export function avoidMarkdown(names) {
|
|
2107
|
+
return `No part of this run pressed what the brief asks to stay out of: the persona's own inputs on it were refused before they reached the game, and the scripted checks after play left it alone. Left alone: ${names.map(name => `"${String(name).replace(/"/g, "'")}"`).join(', ')}.`;
|
|
2108
|
+
}
|
|
2109
|
+
|
|
2093
2110
|
/**
|
|
2094
2111
|
* The most findings whose picture is checked against the claim: every issue
|
|
2095
2112
|
* of a run, the most severe first, up to this many (about a third of a cent
|
package/src/run/reportChecks.js
CHANGED
|
@@ -374,7 +374,7 @@ export function traceWebInputs(driver, { fingerprint }) {
|
|
|
374
374
|
const result = await act(action);
|
|
375
375
|
let print = null;
|
|
376
376
|
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 });
|
|
377
|
+
trace.push({ action, ok: Boolean(result) && result.ok !== false && !result.refused, changed: result ? result.changed : null, print, ...(result && result.refused === 'avoided' ? { avoided: true } : {}) });
|
|
378
378
|
return result;
|
|
379
379
|
};
|
|
380
380
|
driver.webTrace = trace;
|
|
@@ -437,7 +437,8 @@ export async function replayWebFindings({ report, index = [], traceSteps = new M
|
|
|
437
437
|
for (let n = 0; n < last; n++) {
|
|
438
438
|
if (now() > deadline) break;
|
|
439
439
|
const entry = trace[n];
|
|
440
|
-
|
|
440
|
+
// An input the run refused because the brief asks to stay out of it is never sent by the replay either.
|
|
441
|
+
if (!entry.avoided) await driver.act(entry.action);
|
|
441
442
|
let after = null;
|
|
442
443
|
try { after = fingerprint(await driver.screenProbe()); } catch { after = null; }
|
|
443
444
|
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)),
|