ravensight-playtest 0.10.4 → 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/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 +40 -0
- 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 +217 -116
- package/src/run/reportChecks.js +13 -5
- package/src/run/usage.js +5 -2
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// Per-game playtest memory for a local run: the same notes, the same rules and
|
|
2
|
+
// the same server records as a cloud run, so the two paths share what they
|
|
3
|
+
// learn about a game (the platform repo's
|
|
4
|
+
// docs/superpowers/specs/2026-11-14-playtest-game-memory.md).
|
|
5
|
+
//
|
|
6
|
+
// before play the notes earlier playtests of this game kept, for the build
|
|
7
|
+
// this run plays (`GET .../playtest/memory/run-notes`), become
|
|
8
|
+
// one block in the persona's system prompt: the hosted
|
|
9
|
+
// runner's own block (./anygame/gamenotes.js), marked as notes
|
|
10
|
+
// that may be out of date, never findings, data and never
|
|
11
|
+
// instructions. It sits in the cached part of the prompt.
|
|
12
|
+
// after play the notes this run hands on are read from what it already
|
|
13
|
+
// recorded (the notebook, the measured controls, the claims
|
|
14
|
+
// its checks found to be as designed) by the same rules a
|
|
15
|
+
// cloud run uses, and go back with the run's `complete`
|
|
16
|
+
// (`game_memory`). The server validates and merges them.
|
|
17
|
+
//
|
|
18
|
+
// A note never becomes a finding: it reaches the prompt and nothing else.
|
|
19
|
+
// Memory never costs a run anything: a read that fails gives no notes and asks
|
|
20
|
+
// for none back, and no model is called here.
|
|
21
|
+
import { createHash } from 'node:crypto';
|
|
22
|
+
import { execFile } from 'node:child_process';
|
|
23
|
+
import { readdir, stat } from 'node:fs/promises';
|
|
24
|
+
import path from 'node:path';
|
|
25
|
+
import { promisify } from 'node:util';
|
|
26
|
+
import {
|
|
27
|
+
MEMORY_SCHEMA, note, startRoute, controlNotes, progressNote, measuredStuckNotes, deathTexts, ruleTexts, messageNotes, designedNotes,
|
|
28
|
+
collectNotes, earlierNotesBlock, withoutSteps
|
|
29
|
+
} from './anygame/gamenotes.js';
|
|
30
|
+
|
|
31
|
+
const execFileAsync = promisify(execFile);
|
|
32
|
+
|
|
33
|
+
// The words a claim is about (the server's own test, playtestMemoryService sameClaim): four letters or more, plain endings off.
|
|
34
|
+
const words = t => new Set(String(t || '').toLowerCase().replace(/[^a-z0-9\s]/g, ' ').split(/\s+/).filter(w => w.length >= 4).map(w => w.replace(/(ly|ing|ed|s)$/, '')));
|
|
35
|
+
/** Whether two notes or claims say the same thing: most of the shorter one's words are in the other, and at least two. */
|
|
36
|
+
export function sameClaim(a, b) {
|
|
37
|
+
const x = words(a);
|
|
38
|
+
const y = words(b);
|
|
39
|
+
if (!x.size || !y.size) return String(a).trim().toLowerCase() === String(b).trim().toLowerCase();
|
|
40
|
+
const [small, big] = x.size <= y.size ? [x, y] : [y, x];
|
|
41
|
+
let shared = 0;
|
|
42
|
+
for (const w of small) if (big.has(w)) shared += 1;
|
|
43
|
+
return shared >= Math.max(2, Math.ceil(small.size * 0.6));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const sha = text => createHash('sha256').update(text).digest('hex');
|
|
47
|
+
// What a build is not: tooling, caches and history that change without the game changing.
|
|
48
|
+
const SKIP_DIRS = new Set(['.git', '.godot', '.import', 'node_modules', '.ravensight', '.DS_Store']);
|
|
49
|
+
const MAX_LISTED = 20000;
|
|
50
|
+
|
|
51
|
+
/** Every file under a folder, as `path size mtime`, sorted; at most MAX_LISTED. */
|
|
52
|
+
async function listing(root) {
|
|
53
|
+
const out = [];
|
|
54
|
+
const walk = async dir => {
|
|
55
|
+
if (out.length >= MAX_LISTED) return;
|
|
56
|
+
let entries;
|
|
57
|
+
try { entries = await readdir(dir, { withFileTypes: true }); } catch { return; }
|
|
58
|
+
for (const entry of entries) {
|
|
59
|
+
if (out.length >= MAX_LISTED || SKIP_DIRS.has(entry.name)) continue;
|
|
60
|
+
const full = path.join(dir, entry.name);
|
|
61
|
+
if (entry.isDirectory()) await walk(full);
|
|
62
|
+
else if (entry.isFile()) {
|
|
63
|
+
try { const info = await stat(full); out.push(`${path.relative(root, full).split(path.sep).join('/')} ${info.size} ${Math.round(info.mtimeMs)}`); } catch { /* gone */ }
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
await walk(root);
|
|
68
|
+
return out.sort().join('\n');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* What this run's build is, as a SHA-256: what memory keys a note's build on,
|
|
73
|
+
* so notes from another build are marked as from an earlier one. A Godot
|
|
74
|
+
* project in git is its commit and its uncommitted changes; any other folder
|
|
75
|
+
* is its files' names, sizes and times; a URL is the URL. Never throws: a
|
|
76
|
+
* build that cannot be read is named by its location.
|
|
77
|
+
*
|
|
78
|
+
* @param {{driverName: string, target: string, projectDir?: string|null, buildDir?: string|null}} args
|
|
79
|
+
* @returns {Promise<string>}
|
|
80
|
+
*/
|
|
81
|
+
export async function buildIdentity({ driverName, target, projectDir = null, buildDir = null, exec = execFileAsync }) {
|
|
82
|
+
const folder = buildDir || (driverName === 'godot_driver' ? projectDir : null);
|
|
83
|
+
if (folder) {
|
|
84
|
+
try {
|
|
85
|
+
const head = (await exec('git', ['-C', folder, 'rev-parse', 'HEAD'], { timeout: 5000 })).stdout.trim();
|
|
86
|
+
const dirty = (await exec('git', ['-C', folder, 'status', '--porcelain', '--', '.'], { timeout: 5000, maxBuffer: 4 * 1024 * 1024 })).stdout;
|
|
87
|
+
const diff = dirty.trim() ? (await exec('git', ['-C', folder, 'diff', 'HEAD', '--', '.'], { timeout: 10000, maxBuffer: 32 * 1024 * 1024 })).stdout : '';
|
|
88
|
+
if (/^[0-9a-f]{40,64}$/.test(head)) return sha(`git ${head}\n${dirty}\n${diff}`);
|
|
89
|
+
} catch { /* not a git checkout: its files name it */ }
|
|
90
|
+
try { return sha(`files\n${await listing(folder)}`); } catch { /* fall through */ }
|
|
91
|
+
return sha(`folder ${path.resolve(folder)}`);
|
|
92
|
+
}
|
|
93
|
+
return sha(`url ${String(target || '')}`);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The notes earlier playtests of this game kept, for this build: `{ save, notes }`
|
|
98
|
+
* from the server, or null when the server has no memory route, memory could not
|
|
99
|
+
* be read, or the answer is not one. Never throws: a run never waits on memory.
|
|
100
|
+
*/
|
|
101
|
+
export async function readRunNotes(api, gameId, buildSha256, { log = () => {} } = {}) {
|
|
102
|
+
if (!api || !api.memory || typeof api.memory.runNotes !== 'function' || !/^[0-9a-f]{64}$/.test(String(buildSha256))) return null;
|
|
103
|
+
try {
|
|
104
|
+
const answer = await api.memory.runNotes(gameId, buildSha256);
|
|
105
|
+
if (!answer || typeof answer.save !== 'boolean' || !Array.isArray(answer.notes)) return null;
|
|
106
|
+
return { save: answer.save, notes: answer.notes };
|
|
107
|
+
} catch (error) {
|
|
108
|
+
log(`this game's playtest memory could not be read (${String(error && error.message ? error.message : error).slice(0, 120)}); the run plays without it and hands nothing on.`);
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** The block of earlier notes for the persona's system prompt, or ''. The hosted runner's own block, bounded the same way. */
|
|
114
|
+
export const memoryBlock = memory => earlierNotesBlock({ memory: memory || null });
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* The notes this local run hands on, from what it already recorded: `{ schema, notes }`.
|
|
118
|
+
* `digest` is the any-game record (./anygame/index.js digest: the notebook and the
|
|
119
|
+
* measured controls, the same shapes a cloud run keeps); `turnedAway` the claims the
|
|
120
|
+
* judge turned away (those found to be as designed become notes). The playtester's own
|
|
121
|
+
* words about where it lost are kept only when no claim turned away says the same thing.
|
|
122
|
+
*/
|
|
123
|
+
export function extractLocalNotes({ digest = null, turnedAway = [] } = {}) {
|
|
124
|
+
const memory = digest && digest.memory ? digest.memory : null;
|
|
125
|
+
const measured = digest && digest.controls && Array.isArray(digest.controls.measured) ? digest.controls.measured : [];
|
|
126
|
+
const away = (Array.isArray(turnedAway) ? turnedAway : []).filter(entry => entry && entry.title);
|
|
127
|
+
const notShownFalse = texts => texts.filter(t => !away.some(entry => entry.outcome !== 'as_designed' && sameClaim(entry.title, t)));
|
|
128
|
+
const all = [];
|
|
129
|
+
if (memory && memory.about) all.push(note('about', memory.about, 'playtester', { subject: 'about' }));
|
|
130
|
+
const start = startRoute(memory);
|
|
131
|
+
if (start) all.push(note('start', start, 'measured', { subject: 'start' }));
|
|
132
|
+
all.push(...controlNotes(measured));
|
|
133
|
+
all.push(progressNote(null, memory));
|
|
134
|
+
all.push(...measuredStuckNotes({ memory }));
|
|
135
|
+
for (const t of notShownFalse(deathTexts(memory)).slice(0, 2)) all.push(note('stuck', withoutSteps(t), 'playtester'));
|
|
136
|
+
all.push(...messageNotes(null, memory));
|
|
137
|
+
all.push(...notShownFalse(ruleTexts(memory)).map(t => note('rule', t, 'playtester')).filter(Boolean));
|
|
138
|
+
all.push(...designedNotes(away.map(entry => ({ outcome: entry.outcome, title: entry.title, reason: entry.reason })), sameClaim));
|
|
139
|
+
return collectNotes(all, sameClaim);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** The `game_memory` a local run's `complete` carries, or null when the game's memory did not ask for notes. */
|
|
143
|
+
export function gameMemoryBody(memory, extracted) {
|
|
144
|
+
if (!memory || memory.save !== true || !/^[0-9a-f]{64}$/.test(String(memory.buildSha256 || '')) || !extracted) return null;
|
|
145
|
+
return { schema: MEMORY_SCHEMA, build_sha256: memory.buildSha256, notes: extracted.notes };
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export default { sameClaim, buildIdentity, readRunNotes, memoryBlock, extractLocalNotes, gameMemoryBody };
|
package/src/run/honesty.js
CHANGED
|
@@ -531,11 +531,17 @@ export function attachWhereToLook(report, { observations = [], notes = [], scree
|
|
|
531
531
|
let at = null;
|
|
532
532
|
let action = null;
|
|
533
533
|
let observation = null;
|
|
534
|
+
// The latest look the finding cites (an observation, a note made on one, or a screenshot of one), and the latest input it
|
|
535
|
+
// names: a judgement made from a look is about the screen that look saw, not the screen the next input led to (honesty
|
|
536
|
+
// round 8 of the hosted runner).
|
|
537
|
+
let looked = null;
|
|
538
|
+
let input = null;
|
|
534
539
|
const later = (time, step, seen) => {
|
|
535
540
|
if (Number.isFinite(time) && (at === null || time > at)) at = time;
|
|
536
541
|
if (Number.isFinite(step) && (action === null || step > action)) action = step;
|
|
537
542
|
if (Number.isFinite(seen) && (observation === null || seen > observation)) observation = seen;
|
|
538
543
|
};
|
|
544
|
+
const look = seen => { if (Number.isFinite(seen) && byIndex.has(seen) && (looked === null || seen > looked)) looked = seen; };
|
|
539
545
|
for (const item of evidence) {
|
|
540
546
|
if (!item || typeof item.ref !== 'string') continue;
|
|
541
547
|
if (item.type === 'transcript_step') {
|
|
@@ -545,11 +551,14 @@ export function attachWhereToLook(report, { observations = [], notes = [], scree
|
|
|
545
551
|
if (seen && byIndex.has(Number(seen[1]))) {
|
|
546
552
|
const entry = byIndex.get(Number(seen[1]));
|
|
547
553
|
later(entry.at, entry.actions, entry.index);
|
|
554
|
+
look(entry.index);
|
|
548
555
|
} else if (noted && notes[Number(noted[1]) - 1]) {
|
|
549
556
|
const note = notes[Number(noted[1]) - 1];
|
|
550
557
|
later(note.at, Number(note.at_action), Number(note.observation));
|
|
558
|
+
look(Number(note.observation));
|
|
551
559
|
} else if (acted) {
|
|
552
560
|
later(NaN, Number(acted[1]), NaN);
|
|
561
|
+
if (input === null || Number(acted[1]) > input) input = Number(acted[1]);
|
|
553
562
|
}
|
|
554
563
|
}
|
|
555
564
|
}
|
|
@@ -559,9 +568,12 @@ export function attachWhereToLook(report, { observations = [], notes = [], scree
|
|
|
559
568
|
const entry = byIndex.get(Number(shot.observation));
|
|
560
569
|
// A step the finding already names stands; the picture only places it in time.
|
|
561
570
|
later(shot.at, action === null && entry ? entry.actions : NaN, Number(shot.observation));
|
|
571
|
+
look(Number(shot.observation));
|
|
562
572
|
}
|
|
563
573
|
const anchor = anchors.get(finding.id);
|
|
564
574
|
if (anchor) later(anchor.at, anchor.action, NaN);
|
|
575
|
+
// A look stands as the claim's moment unless the finding names an input after it, or is the runner's own (it saw it happen).
|
|
576
|
+
const lookEntry = looked !== null && !anchor && !(input !== null && input > Number(byIndex.get(looked).actions)) ? byIndex.get(looked) : null;
|
|
565
577
|
// The action a moment belongs to, when only its time is known.
|
|
566
578
|
if (action === null && at !== null) {
|
|
567
579
|
const before = observations.filter(entry => Number.isFinite(entry.at) && entry.at <= at);
|
|
@@ -604,7 +616,21 @@ export function attachWhereToLook(report, { observations = [], notes = [], scree
|
|
|
604
616
|
if (parts.length >= 2 && parts.every(Number.isFinite)) videoMs = parts.reduce((total, part) => total * 60 + part, 0) * 1000;
|
|
605
617
|
}
|
|
606
618
|
}
|
|
607
|
-
|
|
619
|
+
// The look's own picture: a screenshot taken on that observation (the screen the playtester saw), and its moment in the video.
|
|
620
|
+
let lookShot = null;
|
|
621
|
+
let lookMs = null;
|
|
622
|
+
if (lookEntry) {
|
|
623
|
+
// Of the screenshots on that observation, the last the finding cites, else the first taken there (nearest the look).
|
|
624
|
+
const onIt = shots.filter(shot => Number(shot.observation) === lookEntry.index);
|
|
625
|
+
const citedOnIt = cited.filter(shot => Number(shot.observation) === lookEntry.index);
|
|
626
|
+
const pick = citedOnIt.length ? citedOnIt[citedOnIt.length - 1] : onIt[0];
|
|
627
|
+
lookShot = pick ? String(pick.relativePath).replace(/\\/g, '/') : null;
|
|
628
|
+
if (video && Number.isFinite(video.startedAt) && Number.isFinite(lookEntry.at)) {
|
|
629
|
+
const offset = Math.max(0, lookEntry.at - video.startedAt);
|
|
630
|
+
if (!(Number.isFinite(video.durationMs) && video.durationMs > 0 && offset > video.durationMs + 2000)) lookMs = Math.round(Number.isFinite(video.durationMs) && video.durationMs > 0 ? Math.min(offset, video.durationMs) : offset);
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
index.push({ id: finding.id, action: Number.isFinite(action) ? action : null, screenshot, video: stamp, video_ms: videoMs, ...(lookEntry ? { look: true, look_observation: lookEntry.index, look_shot: lookShot, look_ms: lookMs, marked: Boolean(lookEntry.marked) } : {}) });
|
|
608
634
|
return { ...finding, evidence };
|
|
609
635
|
});
|
|
610
636
|
return { report: { ...report, findings }, index };
|
package/src/run/judge.js
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
// The claim judge for a local run: every issue the playtester's report names
|
|
2
|
+
// ends one of three ways, a finding, a playtester impression, or turned away
|
|
3
|
+
// with its reason. It is the hosted runner's judge (direct-runner
|
|
4
|
+
// lib/claims.mjs gateClaim and lib/judge.mjs), held to the same honesty bar,
|
|
5
|
+
// on the claims a local run makes: the issues of its own report.
|
|
6
|
+
//
|
|
7
|
+
// finding a claim of fact its frame supports: asked whether the game is
|
|
8
|
+
// at fault, the check answered "game at fault"; or the game's
|
|
9
|
+
// own events show it. A runner measurement is never judged here.
|
|
10
|
+
// impression praise, and taste whose frame shows what it rests on: kept in
|
|
11
|
+
// the playtester's own words under "Playtester impressions",
|
|
12
|
+
// never an issue, never a finding row.
|
|
13
|
+
// turned_away anything the frame or the game's own events contradict, the
|
|
14
|
+
// game responding as designed, and a claim of fact nothing
|
|
15
|
+
// confirmed. Listed under "Raised by the playtester, not
|
|
16
|
+
// confirmed" with the reason.
|
|
17
|
+
//
|
|
18
|
+
// The words of a claim and the questions its check is asked are the hosted
|
|
19
|
+
// runner's own file (./claimwords.js), and so are the rules on what the
|
|
20
|
+
// game's events say about a claim (./eventclaims.js): one rule set, two paths.
|
|
21
|
+
//
|
|
22
|
+
// What a local run cannot do the way a hosted one does, and so is turned away
|
|
23
|
+
// rather than published: a claim that nothing happens needs a replay that
|
|
24
|
+
// watched game time run with no input (the runner's own freeze watch is a
|
|
25
|
+
// measurement, and is not judged here).
|
|
26
|
+
//
|
|
27
|
+
// MONEY (owner, 2026-11-14). Taste its check could not settle, and a judgement of difficulty from the
|
|
28
|
+
// playtester's own play, were findings on a local run before this judge. Like the hosted judge, this one turns
|
|
29
|
+
// both away (TURN_AWAY_UNSETTLED): a run whose only output the judge turned away counts as having found nothing
|
|
30
|
+
// (server side, src/playtest/impressions.js JUDGE_TURNED_AWAY_KEEPS_CHARGE), so it is refunded or billed at cost
|
|
31
|
+
// as an ended-empty or thin run, and never charged for a falsehood. Local money follows the honesty bar exactly
|
|
32
|
+
// as hosted money does. With the switch off, both would be kept as `opinion` impressions instead.
|
|
33
|
+
import { claimClass, claimBasis, checkSaid, praiseClaim } from './claimwords.js';
|
|
34
|
+
import { eventsVerdict, eventsConfirmed, contradictedReason } from './eventclaims.js';
|
|
35
|
+
|
|
36
|
+
/** Turn away unsettled taste and own-play difficulty, as the hosted judge does. See MONEY above: the owner's call. */
|
|
37
|
+
export const TURN_AWAY_UNSETTLED = true;
|
|
38
|
+
|
|
39
|
+
export const ROUTES = Object.freeze(['finding', 'impression', 'turned_away']);
|
|
40
|
+
|
|
41
|
+
const text = x => String(x ?? '').replace(/[\u2013\u2014]/g, ',').replace(/\s+/g, ' ').trim();
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The class of a report issue and which question its check is asked:
|
|
45
|
+
* `{ cls, basis, question }`. `question` is `fault` for a claim of what the
|
|
46
|
+
* game did (stuck, other with a fact basis), `absence` for something missing
|
|
47
|
+
* (asked about fault too), `layout` for how a marked picture was drawn,
|
|
48
|
+
* `plain` for taste, and null when no check is asked (praise, difficulty).
|
|
49
|
+
*
|
|
50
|
+
* @param {{title?: string, description?: string, severity?: string, category?: string}} finding
|
|
51
|
+
* @param {{marked?: boolean}} [opts] marked: the picture the playtester judged from carried the runner's marks and grid
|
|
52
|
+
*/
|
|
53
|
+
export function claimShape(finding, { marked = false } = {}) {
|
|
54
|
+
const claim = { title: finding?.title || '', detail: finding?.description || '', severity: finding?.severity || null, category: finding?.category || null, marked };
|
|
55
|
+
// Praise filed as a problem is the playtester's liking; a blocker or a major is never read as praise, so its grade stands.
|
|
56
|
+
if (claim.severity === 'praise' || (!['blocker', 'major'].includes(claim.severity) && praiseClaim(claim))) return { cls: 'praise', basis: null, question: null };
|
|
57
|
+
const cls = claimClass(claim);
|
|
58
|
+
// A judgement of its own play is asked whether the frame contradicts it while local runs keep it (see MONEY), as the gate before did.
|
|
59
|
+
if (cls === 'difficulty') return { cls, basis: null, question: TURN_AWAY_UNSETTLED ? null : 'plain' };
|
|
60
|
+
const basis = cls === 'other' ? claimBasis(claim) : null;
|
|
61
|
+
const question = cls === 'absence' ? 'absence' : cls === 'layout' ? 'layout' : cls === 'stuck' || basis === 'fact' ? 'fault' : 'plain';
|
|
62
|
+
return { cls, basis, question };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// What a claim check said about an opinion, in the words of an impression's note (the hosted runner's lib/report.mjs).
|
|
66
|
+
const IMPRESSION_CHECK = { cannot_tell: 'the frame at its moment could not settle it', not_contradicted: 'the frame at its moment only did not contradict it', not_made: 'no claim check confirmed it' };
|
|
67
|
+
|
|
68
|
+
/** One sentence that says an impression is one, and why it is not a finding. */
|
|
69
|
+
export function impressionNote(kind, check, { ownPlay = false } = {}) {
|
|
70
|
+
if (kind === 'praise') return 'The playtester\'s impression, not a finding: it says something works, in its own words, and the run did not measure it.';
|
|
71
|
+
if (ownPlay) return 'The playtester\'s impression of its own play, not a finding: its inputs are planned from still pictures and are not finely timed, so it cannot tell whether a player could get through.';
|
|
72
|
+
if (!check) return 'The playtester\'s impression, not a finding: it is a matter of taste, in its own words, and the frame at its moment shows only what it rests on.';
|
|
73
|
+
return `The playtester's impression, not a finding: ${IMPRESSION_CHECK[check] || IMPRESSION_CHECK.not_made}.`;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const designedWords = check => {
|
|
77
|
+
const m = text(check?.message || '').replace(/^["'“”]+|["'“”]+$/g, '').replace(/"/g, "'").slice(0, 120);
|
|
78
|
+
return m.length >= 3 ? m : '';
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* The judge's outcome for one issue of the report.
|
|
83
|
+
*
|
|
84
|
+
* @param {Object} finding the report's finding
|
|
85
|
+
* @param {Object} opts
|
|
86
|
+
* @param {Object|null} opts.check the claim check's record: `{ says, answer, question, designed?, left_out?, message?, reason? }`, null when none was made
|
|
87
|
+
* @param {{gameEvents?: Object}|null} [opts.run] what the game's own events are read from (./events.js record)
|
|
88
|
+
* @param {number|null} [opts.step] the action the issue belongs to
|
|
89
|
+
* @param {boolean} [opts.marked]
|
|
90
|
+
* @param {boolean} [opts.turnAwayUnsettled]
|
|
91
|
+
* @returns {{route: string, outcome: string|null, reason: string|null, cls: string, basis: string|null, impression?: {kind: string, check: string|null, note: string}, evidence?: string, events?: Array}}
|
|
92
|
+
*/
|
|
93
|
+
export function judgeIssue(finding, { check = null, run = null, step = null, marked = false, turnAwayUnsettled = TURN_AWAY_UNSETTLED } = {}) {
|
|
94
|
+
const { cls, basis } = claimShape(finding, { marked });
|
|
95
|
+
const base = { cls, basis };
|
|
96
|
+
const finding_ = extra => ({ ...base, route: 'finding', outcome: null, reason: null, ...extra });
|
|
97
|
+
const away = (outcome, reason, extra = {}) => ({ ...base, route: 'turned_away', outcome, reason: text(reason), ...extra });
|
|
98
|
+
const impression = (kind, chk, opts = {}) => ({ ...base, route: 'impression', outcome: 'impression', reason: null, impression: { kind, check: chk || null, note: impressionNote(kind, chk, opts) } });
|
|
99
|
+
|
|
100
|
+
if (cls === 'praise') return impression('praise', null);
|
|
101
|
+
if (cls === 'difficulty') {
|
|
102
|
+
if (turnAwayUnsettled) return away('own_play', 'it is a judgement of difficulty from the playtester\'s own play, whose inputs are planned from still pictures and are not finely timed; playing the same inputs again repeats the same play and cannot show whether a player could do it');
|
|
103
|
+
// Kept as the gate before kept it: turned away only when its frame contradicts it.
|
|
104
|
+
const saidOf = checkSaid(check);
|
|
105
|
+
if (saidOf === 'opposite') return away('contradicted', 'the frame at its moment contradicts it');
|
|
106
|
+
return impression('opinion', saidOf === null ? 'not_made' : saidOf === 'not_contradicted' ? 'not_contradicted' : 'cannot_tell', { ownPlay: true });
|
|
107
|
+
}
|
|
108
|
+
const claim = { title: finding?.title || '', step: Number.isSafeInteger(step) ? step : null };
|
|
109
|
+
const ev = run ? eventsVerdict(run, claim) : null;
|
|
110
|
+
if (ev?.verdict === 'contradicted') return away('contradicted', contradictedReason(ev), { evidence: 'events', events: ev.events });
|
|
111
|
+
|
|
112
|
+
const said = checkSaid(check);
|
|
113
|
+
const made = said !== null;
|
|
114
|
+
const unasked = check?.reason ? `the claim check was not made (${text(check.reason).slice(0, 120)})` : 'the claim check was not made';
|
|
115
|
+
const designed = said === 'as_designed'
|
|
116
|
+
? away('as_designed', `the frame at its moment shows the game responding as designed${designedWords(check) ? `: the game said "${designedWords(check)}"` : ''}, so it describes what the playtester misunderstood, not a fault of the game`)
|
|
117
|
+
: null;
|
|
118
|
+
|
|
119
|
+
if (cls === 'other' && basis === 'opinion') {
|
|
120
|
+
if (said === 'opposite') return away('contradicted', 'the frame at its moment contradicts it');
|
|
121
|
+
if (designed) return designed;
|
|
122
|
+
if (said === 'shows' || said === 'at_fault') return impression('opinion', null);
|
|
123
|
+
if (turnAwayUnsettled) return away('unconfirmed', `it is a matter of taste or understanding, and ${made ? 'the frame at its moment could not show what it describes' : unasked}, so nothing the run saw supports it`);
|
|
124
|
+
return impression('opinion', made ? (said === 'not_contradicted' ? 'not_contradicted' : 'cannot_tell') : 'not_made');
|
|
125
|
+
}
|
|
126
|
+
if (cls === 'stuck') {
|
|
127
|
+
if (said === 'opposite') return away('contradicted', 'the frame at its moment contradicts it');
|
|
128
|
+
if (designed) return designed;
|
|
129
|
+
return away('unconfirmed', 'a claim that nothing happens is confirmed only by watching the screen while game time runs with no input, which this local run did not do for it; one still frame cannot settle it');
|
|
130
|
+
}
|
|
131
|
+
if (cls === 'absence') {
|
|
132
|
+
if (said === 'opposite') return away('contradicted', 'the frames nearest its moment show the thing it says is missing');
|
|
133
|
+
if (designed) return designed;
|
|
134
|
+
if (said === 'at_fault' && !(check?.left_out > 0)) return finding_();
|
|
135
|
+
if (said === 'at_fault') return away('unconfirmed', 'its own frame shows the game at fault, but the check had no room left to look at the screen play was on before, so the thing may be there');
|
|
136
|
+
if (said === 'shows' || said === 'not_contradicted') return away('unconfirmed', 'the check said only that the thing is not in the frames nearest its moment, not that the game is at fault for it');
|
|
137
|
+
return away('unconfirmed', made ? 'the frames nearest its moment could not settle whether the game is at fault for the thing it says is missing' : unasked);
|
|
138
|
+
}
|
|
139
|
+
if (cls === 'layout') {
|
|
140
|
+
if (said === 'opposite') return away('contradicted', 'the frame of the game itself, with none of the runner\'s marks on it, does not show it');
|
|
141
|
+
if (designed) return designed;
|
|
142
|
+
if (said === 'at_fault') return finding_();
|
|
143
|
+
if (said === 'shows' || said === 'not_contradicted') return away('unconfirmed', 'it is a judgement of how the screen is drawn, and the check said only that the frame of the game itself shows what it describes, not that the game drew it wrongly');
|
|
144
|
+
return away('unconfirmed', `it is a judgement of how the screen is drawn, made from the playtester's own copy of the picture, which carries the marks and the grid the runner draws on it, and ${made ? 'the frame of the game itself could not settle it' : unasked}`);
|
|
145
|
+
}
|
|
146
|
+
// A claim of fact about what the game did or what the screen shows.
|
|
147
|
+
if (said === 'opposite') return away('contradicted', 'the frame at its moment contradicts it');
|
|
148
|
+
if (designed) return designed;
|
|
149
|
+
const byEvents = eventsConfirmed(ev, 'fault');
|
|
150
|
+
if (byEvents) return finding_(byEvents);
|
|
151
|
+
if (said === 'at_fault') return finding_();
|
|
152
|
+
const lead = 'it is a claim that the game did something wrong, and';
|
|
153
|
+
if (said === 'shows') return away('unconfirmed', `${lead} the check said only that the frame shows what it says, not that the game is at fault there`);
|
|
154
|
+
if (said === 'not_contradicted') return away('unconfirmed', `${lead} the frame at its moment only did not contradict it, which does not show the game at fault`);
|
|
155
|
+
if (said === 'cannot_tell') return away('unconfirmed', `${lead} the frame at its moment could not settle whether the game is at fault`);
|
|
156
|
+
return away('unconfirmed', `${lead} ${unasked}`);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* The gate a run whose findings decide money elsewhere keeps (a fix's verify run, whose report the server judges for
|
|
161
|
+
* "still reproduced"; a Labs validate or feature scenario run, whose verdict counts serious findings): the checks are asked
|
|
162
|
+
* the same questions, and the answers are read as the gate before the judge read them, so no verdict or refund moves.
|
|
163
|
+
* A claim the picture contradicts is turned away; a claim of fact stands when the picture shows it (as designed or at
|
|
164
|
+
* fault included) and is turned away otherwise; anything else stands.
|
|
165
|
+
*/
|
|
166
|
+
export function legacyIssue(finding, { check = null, marked = false } = {}) {
|
|
167
|
+
const { cls, basis, question } = claimShape(finding, { marked });
|
|
168
|
+
const said = checkSaid(check);
|
|
169
|
+
const base = { cls, basis };
|
|
170
|
+
if (said === 'opposite') return { ...base, route: 'turned_away', outcome: 'contradicted', reason: 'the frame at its moment contradicts it' };
|
|
171
|
+
if (question === 'fault' || question === 'absence' || question === 'layout') {
|
|
172
|
+
if (said === 'at_fault' || said === 'as_designed' || said === 'shows') return { ...base, route: 'finding', outcome: null, reason: null };
|
|
173
|
+
return { ...base, route: 'turned_away', outcome: 'unconfirmed', reason: said ? 'it is a claim about what the screen shows, and the frame at its moment could not confirm it' : `it is a claim about what the screen shows, and ${check?.reason ? `the claim check was not made (${text(check.reason).slice(0, 120)})` : 'the claim check was not made'}, so nothing confirmed it` };
|
|
174
|
+
}
|
|
175
|
+
return { ...base, route: 'finding', outcome: null, reason: null };
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* A finding the judge kept as an impression, in report.json's `impressions` shape.
|
|
180
|
+
*
|
|
181
|
+
* @param {Object} finding
|
|
182
|
+
* @param {{kind: string, check: string|null, note: string}} impression
|
|
183
|
+
* @param {number} index 1 based
|
|
184
|
+
* @param {number|null} step
|
|
185
|
+
*/
|
|
186
|
+
export function impressionOf(finding, impression, index, step = null, placed = {}) {
|
|
187
|
+
const said = text(finding.description || finding.title).slice(0, 1000);
|
|
188
|
+
return {
|
|
189
|
+
id: `I${String(index).padStart(3, '0')}`,
|
|
190
|
+
kind: impression.kind,
|
|
191
|
+
source: 'reflection',
|
|
192
|
+
title: text(finding.title).slice(0, 120),
|
|
193
|
+
said: said || text(finding.title).slice(0, 120),
|
|
194
|
+
...(impression.kind === 'praise' ? {} : { graded: finding.severity }),
|
|
195
|
+
...(finding.category ? { category: finding.category } : {}),
|
|
196
|
+
...(Number.isSafeInteger(step) ? { step } : {}),
|
|
197
|
+
...(impression.check ? { check: impression.check } : {}),
|
|
198
|
+
note: impression.note,
|
|
199
|
+
evidence: impressionEvidence(finding, placed),
|
|
200
|
+
...(typeof finding.persona_quote === 'string' && finding.persona_quote ? { persona_quote: finding.persona_quote } : {})
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* An impression's evidence: the pictures and video moment it cites, and, as a finding gets them, the screenshot and video time
|
|
206
|
+
* the runner placed at its moment (`placed`, ./honesty.js attachWhereToLook), so the server's evidence rule keeps it.
|
|
207
|
+
*/
|
|
208
|
+
export function impressionEvidence(finding, placed = {}) {
|
|
209
|
+
const out = (Array.isArray(finding.evidence) ? finding.evidence : []).filter(e => e && (e.type === 'screenshot' || e.type === 'video_ts')).map(e => ({ type: e.type, ref: String(e.ref) }));
|
|
210
|
+
const shot = placed.look_shot || placed.screenshot;
|
|
211
|
+
if (shot && !out.some(e => e.type === 'screenshot' && e.ref === shot)) out.push({ type: 'screenshot', ref: String(shot) });
|
|
212
|
+
if (placed.video && !out.some(e => e.type === 'video_ts')) out.push({ type: 'video_ts', ref: String(placed.video) });
|
|
213
|
+
return out;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** The heading report.md lists the impressions under, the hosted runner's own. */
|
|
217
|
+
export const IMPRESSIONS_HEADING = '## Playtester impressions';
|
|
218
|
+
export const IMPRESSIONS_EXPLANATION = 'What the playtester felt and said, in its own words, that the run could not verify. None of these is a finding about the game: each is one player\'s impression, and an impression can be wrong. Findings above are only what the run measured or a check confirmed on the screen.';
|
|
219
|
+
|
|
220
|
+
/** One line of report.md for an impression: the persona's words, its step, its evidence and its note. */
|
|
221
|
+
export function impressionLine(x) {
|
|
222
|
+
const where = Number.isSafeInteger(x.step) ? `Action ${x.step}` : 'During play';
|
|
223
|
+
const graded = x.kind === 'praise' || !x.graded ? '' : `, graded ${x.graded}`;
|
|
224
|
+
const evidence = x.evidence.length ? ` Evidence: ${x.evidence.map(e => (e.type === 'video_ts' ? `the session video at ${e.ref}` : e.ref)).join(', ')}.` : '';
|
|
225
|
+
const said = x.said && x.said !== x.title ? ` ${x.said.replace(/\s*$/, '').replace(/([^.!?])$/, '$1.')}` : '';
|
|
226
|
+
return text(`- **${where}${graded}: ${x.title.replace(/[.]+$/, '')}.**${said} ${x.note}${evidence}${x.persona_quote ? ` The persona: "${x.persona_quote}"` : ''}`);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export default { TURN_AWAY_UNSETTLED, ROUTES, claimShape, impressionNote, judgeIssue, legacyIssue, impressionOf, IMPRESSIONS_HEADING, IMPRESSIONS_EXPLANATION, impressionLine };
|