ravensight-playtest 0.10.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,236 @@
1
+ // The gate a playtester's own claim passes before it is published as a finding,
2
+ // the CLI's copy of the hosted runner's rule (direct-runner lib/claims.mjs).
3
+ //
4
+ // Each issue the report names is shown once with the picture of its moment
5
+ // and asked whether the picture shows what the claim says, contradicts it, or
6
+ // cannot settle it (personaLoop.js checkClaimsAgainstScreenshots). Then:
7
+ //
8
+ // - a claim the picture contradicts is never a finding, at any severity:
9
+ // lowering it would still publish it;
10
+ // - a claim of FACT about what the screen shows (its text, its layout,
11
+ // something there or missing, the game's state) is published only when the
12
+ // picture shows it: "cannot tell", or a check that could not be made,
13
+ // confirms nothing;
14
+ // - an OPINION of taste or difficulty ("confusing", "too hard", "feels slow")
15
+ // is not something a still picture can settle, so it is published when the
16
+ // check could not settle it, and never when the picture contradicts it.
17
+ //
18
+ // What the gate turns away is never lost. It leaves report.json, so it feeds
19
+ // no count, ranking, aggregate or uploaded model, and report.md lists it under
20
+ // "Raised by the playtester, not confirmed" with the reason. Every other part
21
+ // of report.md that rested on it (top issues, the success criteria line, what
22
+ // the run did not cover, the suggested next step) is swept of it here.
23
+ //
24
+ // No model is asked anything in this module.
25
+ import { fillPlaceholders } from './placeholders.js';
26
+
27
+ /** The heading report.md lists what the gate turned away under; the hosted runner's own. */
28
+ export const NOT_CONFIRMED_HEADING = '## Raised by the playtester, not confirmed';
29
+
30
+ export const NOT_CONFIRMED_EXPLANATION = 'None of these is a finding about the game. Each is something the playtester said, and the reason it is not reported as a finding: the picture of its moment contradicts it, or it is a claim about what the screen shows that the picture could not confirm. They are not counted, ranked or sent as findings.';
31
+
32
+ /** Words of difficulty: the playtester's own play, which a still picture cannot settle. */
33
+ const DIFFICULTY = /\b(too (?:hard|difficult|slow|fast|quick|quickly|short|long|tight|punishing|steep|strict|precise|easy)|(?:nearly|almost|virtually|practically) (?:impossible|unbeatable|unwinnable|unreachable)|impossible|unbeatable|unwinnable|unfair|unforgiving|punishing|(?:very|overly|extremely|really|quite) (?:strict|tight|hard|difficult|precise|punishing|easy|slow)|(?:timing|window|jump|gap)\b[^.]{0,40}\b(?:strict|tight|precise|inconsistent|hard|difficult)|difficulty|(?:attempts?|tries|retries)\b[^.]{0,60}\bfail(?:ed|s|ing)?|hard to (?:time|clear|cross|land|beat))\b/i;
34
+
35
+ /** Words of taste: how a game feels to play, not what its screen shows. */
36
+ const TASTE = /\b(confus(?:ing|ed|es)?|bewilder\w*|boring|bland|dull|tedious|repetitive|grind\w*|frustrat\w*|annoying|irritating|unsatisfying|underwhelming|unrewarding|not (?:fun|engaging|satisfying|rewarding|intuitive)|unintuitive|counter.?intuitive|feels?|felt|pacing|slow.?paced|drags?|overwhelming|intimidating|uninviting|(?:hard|difficult) to (?:understand|follow|tell|learn|know|grasp|figure)|not (?:obvious|clear) (?:what|how|why|where|which|that)|unclear (?:what|how|why|where|which|whether)|could be (?:clearer|better|more)|would (?:benefit|be (?:better|nicer|clearer))|i (?:wish|expected|would like|would prefer))\b/i;
37
+
38
+ /**
39
+ * Whether a finding is an opinion of taste or difficulty, or a claim of fact
40
+ * about what the screen shows. A bug is always a fact; so is anything that is
41
+ * not plainly taste or difficulty: the stricter rule is the default.
42
+ *
43
+ * @param {{title?: string, description?: string, category?: string}} finding
44
+ * @returns {'fact'|'opinion'}
45
+ */
46
+ export function claimKind(finding) {
47
+ if (!finding || finding.category === 'bug') return 'fact';
48
+ if (finding.category === 'balance') return 'opinion';
49
+ const title = String(finding.title || '');
50
+ const first = String(finding.description || '').split(/(?<=[.!?])\s/)[0] || '';
51
+ if (DIFFICULTY.test(title) || TASTE.test(title)) return 'opinion';
52
+ // The title says what is claimed; the description's first sentence only decides when the title names no fact.
53
+ if (/^(?:no|missing|there is no|nothing)\b|\b(?:is not|isn't|not) (?:shown|displayed|visible)|\b(?:shows?|displays?|reads?|says?|overlaps?|cut off|clipped|blank|frozen|stuck|wrong|incorrect|missing|disappears?|never (?:appears?|shows?))\b/i.test(title)) return 'fact';
54
+ if (DIFFICULTY.test(first) || TASTE.test(first)) return 'opinion';
55
+ return 'fact';
56
+ }
57
+
58
+ /**
59
+ * The gate for one finding, from its claim check.
60
+ *
61
+ * @param {Object} finding
62
+ * @param {{answer: 'shows'|'contradicts'|'unclear'|'skipped', reason?: string, picture?: string}|null} check
63
+ * @returns {{publish: boolean, kind: 'fact'|'opinion', outcome: string|null, reason: string|null}}
64
+ */
65
+ export function gateFinding(finding, check) {
66
+ const kind = claimKind(finding);
67
+ const answer = check && check.answer;
68
+ const picture = check && check.picture ? ` (${check.picture})` : '';
69
+ if (answer === 'contradicts') return { publish: false, kind, outcome: 'contradicted', reason: `the picture of its moment${picture} contradicts it` };
70
+ if (answer === 'shows') return { publish: true, kind, outcome: null, reason: null };
71
+ if (kind === 'opinion') return { publish: true, kind, outcome: null, reason: null };
72
+ if (answer === 'unclear') return { publish: false, kind, outcome: 'unconfirmed', reason: `it is a claim about what the screen shows, and the picture of its moment${picture} could not confirm it` };
73
+ return { publish: false, kind, outcome: 'unconfirmed', reason: `it is a claim about what the screen shows, and the claim check was not made${check && check.reason ? ` (${String(check.reason).slice(0, 120)})` : ''}, so nothing confirmed it` };
74
+ }
75
+
76
+ /** One sentence for report.md about a claim the gate turned away. */
77
+ export function turnedAwayLine(entry) {
78
+ const title = fillPlaceholders(String(entry.title || '')).replace(/\s+/g, ' ').trim().replace(/[.]+$/, '');
79
+ return `${entry.id}: the playtester raised "${title}"${entry.severity ? `, graded ${entry.severity}` : ''}. It is not reported as a finding, because ${entry.reason}.`;
80
+ }
81
+
82
+ /* --------------------------------------------------------- sweeping report.md */
83
+
84
+ const STOP = new Set(('the a an of to on in for or and that it its is are was were be not without there any at all my your by with from this has have does do did can cannot still also only just than then them they their what which who how when while into onto out over under very more most some such each other these those would could should will may might been being as so if but no yes one two '
85
+ + 'play played playing plays game games screen screens visible during player players session sessions run runs persona playtester shown show shows showed seen see').split(' '));
86
+
87
+ /** A text's words, without the common ones, stemmed as the dashboard stems them. */
88
+ export function claimWords(value) {
89
+ return new Set(String(value ?? '').toLowerCase().replace(/[^a-z0-9 ]+/g, ' ').split(/\s+/)
90
+ .filter(word => word.length > 2 && !STOP.has(word)).map(word => word.replace(/(?:ing|ed|es|s)$/, '')));
91
+ }
92
+
93
+ /** A finding's own words: its title, and the first sentence of its description, which says the claim. */
94
+ function wordsOf(finding) {
95
+ const first = String(finding.description || '').split(/(?<=[.!?])\s/)[0] || '';
96
+ return { title: claimWords(finding.title), claim: claimWords(`${finding.title || ''} ${first}`) };
97
+ }
98
+
99
+ const namesId = (text, id) => new RegExp(`(^|[^A-Za-z0-9])${String(id).replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?![0-9])`).test(text);
100
+
101
+ /**
102
+ * Whether a sentence of report.md repeats a turned-away claim: it names the
103
+ * finding's id, or it shares the claim's own words: at least one of its title
104
+ * and five of its claim, or two of its title and four of its claim. Tuned on
105
+ * the paid web run pt_job_64a04aaf0b357764ebda, where a true "Level 1 of 12"
106
+ * on every screen was reported missing: the sentences that repeated the claim
107
+ * are caught, and the true ones about levels and keys are not.
108
+ *
109
+ * @param {string} sentence
110
+ * @param {{id: string, words: {title: Set<string>, claim: Set<string>}}} claim
111
+ * @param {{loose?: boolean}} [opts] loose for a suggested next step, which names a fix and not the claim
112
+ */
113
+ export function repeatsClaim(sentence, claim, { loose = false } = {}) {
114
+ if (claim.id && namesId(sentence, claim.id)) return true;
115
+ const words = claimWords(sentence);
116
+ let title = 0, shared = 0;
117
+ for (const word of words) {
118
+ if (claim.words.title.has(word)) title += 1;
119
+ if (claim.words.claim.has(word)) shared += 1;
120
+ }
121
+ if (loose) return title >= 2 || (title >= 1 && shared >= 3);
122
+ return (title >= 1 && shared >= 5) || (title >= 2 && shared >= 4);
123
+ }
124
+
125
+ /** The sections of report.md a turned-away claim is swept out of. The in-character section is the playtester's own voice and stays. */
126
+ const SWEPT = /^##\s+(?:What worked|Top issues|What this run didn't cover|Persona summary|Evidence)\b/i;
127
+ const NEXT_STEP = /^##\s+Suggested next step\b/i;
128
+ const LIST_ITEM = /^(\s*(?:[-*+]|\d+[.)])\s+)(.*)$/;
129
+
130
+ /** A line's sentences, split where one ends and the next begins. */
131
+ function sentencesOf(text) {
132
+ return String(text).split(/(?<=[.!?])\s+(?=["'(\[*A-Z0-9])/);
133
+ }
134
+
135
+ /**
136
+ * report.md with every turned-away claim taken out of the parts of it that
137
+ * stand for the run's findings, a runner-written next step where the old one
138
+ * rested on one, and the claims listed under {@link NOT_CONFIRMED_HEADING}.
139
+ *
140
+ * @param {string} markdown
141
+ * @param {Array<Object>} turnedAway entries with id, title, severity, reason and the finding
142
+ * @param {Array<Object>} kept the findings still in report.json
143
+ * @returns {string}
144
+ */
145
+ export function sweepTurnedAway(markdown, turnedAway, kept = []) {
146
+ if (!Array.isArray(turnedAway) || turnedAway.length === 0) return markdown;
147
+ const claims = turnedAway.map(entry => ({ id: entry.id, words: wordsOf(entry.finding || entry) }));
148
+ const keptIds = kept.map(finding => finding && String(finding.id)).filter(Boolean);
149
+ const repeats = (text, opts) => claims.some(claim => repeatsClaim(text, claim, opts)) && !keptIds.some(id => namesId(text, id));
150
+ const lines = withoutSection(String(markdown || '').replace(/\s+$/, ''), NOT_CONFIRMED_HEADING).split('\n');
151
+ const out = [];
152
+ let mode = null;
153
+ let removed = 0;
154
+ let listed = 0;
155
+ let nextStepAt = -1;
156
+ let nextStepRests = false;
157
+ const closeSection = () => {
158
+ if (mode === 'swept' && removed > 0 && listed === 0) {
159
+ let blanks = 0;
160
+ while (out.length > 0 && out[out.length - 1].trim() === '') { out.pop(); blanks += 1; }
161
+ // Only a section left with nothing under its heading says so.
162
+ if (/^##\s/.test(out[out.length - 1] || '')) out.push('- None that the checks confirmed. See "Raised by the playtester, not confirmed" below.');
163
+ for (let i = 0; i < blanks; i += 1) out.push('');
164
+ }
165
+ };
166
+ for (const line of lines) {
167
+ if (/^##\s/.test(line)) {
168
+ closeSection();
169
+ mode = SWEPT.test(line) ? 'swept' : NEXT_STEP.test(line) ? 'next' : null;
170
+ removed = 0;
171
+ listed = 0;
172
+ if (mode === 'next') nextStepAt = out.length;
173
+ out.push(line);
174
+ continue;
175
+ }
176
+ if (mode === 'next') {
177
+ if (line.trim() && repeats(line, { loose: true })) nextStepRests = true;
178
+ out.push(line);
179
+ continue;
180
+ }
181
+ if (mode !== 'swept' || !line.trim() || /^\s*\|/.test(line)) {
182
+ if (mode === 'swept' && LIST_ITEM.test(line)) listed += 1;
183
+ out.push(line);
184
+ continue;
185
+ }
186
+ const item = line.match(LIST_ITEM);
187
+ const lead = item ? item[1] : '';
188
+ const body = item ? item[2] : line;
189
+ // A list item that names a turned-away finding is about it, whatever else it says.
190
+ if (item && claims.some(claim => namesId(body, claim.id)) && !keptIds.some(id => namesId(body, id))) { removed += 1; continue; }
191
+ const sentences = sentencesOf(body);
192
+ const left = sentences.filter(sentence => !repeats(sentence));
193
+ if (left.length === sentences.length) {
194
+ if (item) listed += 1;
195
+ out.push(line);
196
+ continue;
197
+ }
198
+ // A bold label that opens the line ("**Success criteria:**") stays with what is left of it.
199
+ const label = (body.match(/^(\*\*[^*]+\*\*:?\s*)/) || [])[1] || '';
200
+ const rest = left.join(' ').trim();
201
+ if (!rest || rest === label.trim()) { removed += 1; continue; }
202
+ const text = label && !rest.startsWith(label.trim()) ? `${label}${rest}` : rest;
203
+ if (item) listed += 1;
204
+ out.push(`${lead}${text}`);
205
+ }
206
+ closeSection();
207
+ if (nextStepRests && nextStepAt >= 0) {
208
+ let end = nextStepAt + 1;
209
+ while (end < out.length && !/^##\s/.test(out[end])) end += 1;
210
+ out.splice(nextStepAt + 1, end - nextStepAt - 1, runnerNextStep(kept), '');
211
+ }
212
+ const tail = ['', NOT_CONFIRMED_HEADING, NOT_CONFIRMED_EXPLANATION, '', ...turnedAway.map(entry => `- ${turnedAwayLine(entry)}`)];
213
+ return `${out.join('\n').replace(/\s+$/, '')}\n${tail.join('\n')}\n`;
214
+ }
215
+
216
+ const SEVERITY_ORDER = ['blocker', 'major', 'minor', 'cosmetic'];
217
+
218
+ /** The next step the runner writes when the report's own rested on a claim it turned away. */
219
+ export function runnerNextStep(kept = []) {
220
+ const issues = kept.filter(finding => finding && SEVERITY_ORDER.includes(finding.severity))
221
+ .sort((a, b) => SEVERITY_ORDER.indexOf(a.severity) - SEVERITY_ORDER.indexOf(b.severity));
222
+ if (issues.length === 0) return 'No issue this run raised was confirmed, so there is nothing here to fix first. Read what the playtester raised and why it was not confirmed (below), and play the part of the game this run did not reach. (Written by the runner: the next step the report suggested rested on a claim the checks turned away.)';
223
+ const top = issues[0];
224
+ return `Start with ${top.id}, ${fillPlaceholders(String(top.title || '')).replace(/[.]+$/, '')} (${top.severity}): it is the most severe issue this run confirmed. (Written by the runner: the next step the report suggested rested on a claim the checks turned away.)`;
225
+ }
226
+
227
+ function withoutSection(markdown, heading) {
228
+ const lines = markdown.split('\n');
229
+ const start = lines.findIndex(line => line.trim() === heading);
230
+ if (start === -1) return markdown;
231
+ let end = lines.findIndex((line, index) => index > start && /^##\s/.test(line));
232
+ if (end === -1) end = lines.length;
233
+ return [...lines.slice(0, start), ...lines.slice(end)].join('\n').replace(/\s+$/, '');
234
+ }
235
+
236
+ export default { NOT_CONFIRMED_HEADING, claimKind, gateFinding, turnedAwayLine, claimWords, repeatsClaim, sweepTurnedAway, runnerNextStep };
@@ -251,7 +251,7 @@ export function stepsBefore(actionRecords, max = MAX_REPRO_STEPS) {
251
251
  * @param {Object} args
252
252
  * @returns {Object}
253
253
  */
254
- export function runnerFinding({ severity, category = 'bug', title, description, steps = [], screenshot = null, action = null, key = null }) {
254
+ export function runnerFinding({ severity, category = 'bug', title, description, steps = [], screenshot = null, action = null, key = null, at = null }) {
255
255
  const evidence = [];
256
256
  if (screenshot) evidence.push({ type: 'screenshot', ref: String(screenshot).replace(/\\/g, '/') });
257
257
  if (Number.isInteger(action)) evidence.push({ type: 'transcript_step', ref: `action ${action}` });
@@ -263,7 +263,8 @@ export function runnerFinding({ severity, category = 'bug', title, description,
263
263
  repro_steps: steps.length > 0 ? steps : ['Start the game from its first screen.'],
264
264
  evidence,
265
265
  // Kept off the report: how the runner tells its own findings apart.
266
- runner: { key: key || String(title), at: Date.now(), ...(Number.isInteger(action) ? { action } : {}) }
266
+ // `at` is the moment it happened when the caller knows it (the input the game ended under), else now.
267
+ runner: { key: key || String(title), at: Number.isFinite(at) ? at : Date.now(), ...(Number.isInteger(action) ? { action } : {}) }
267
268
  };
268
269
  }
269
270
 
@@ -287,7 +288,7 @@ export async function gameEndedOf(driver, error) {
287
288
  }
288
289
 
289
290
  /** A crash or a freeze as the runner's finding, with the inputs that led to it. */
290
- export function gameEndedFinding(ended, { actionRecords = [], screenshot = null, action = 0, errors = [] } = {}) {
291
+ export function gameEndedFinding(ended, { actionRecords = [], screenshot = null, action = 0, errors = [], at = null } = {}) {
291
292
  const inputs = (actionRecords || []).filter(record => record && record.kind === 'action' && record.tool !== 'snapshot' && record.tool !== 'screenshot');
292
293
  const last = inputs[inputs.length - 1];
293
294
  const crashed = ended.kind === 'crashed';
@@ -306,7 +307,8 @@ export function gameEndedFinding(ended, { actionRecords = [], screenshot = null,
306
307
  ].filter(Boolean).join(' '),
307
308
  steps: stepsBefore(actionRecords),
308
309
  screenshot,
309
- action
310
+ action,
311
+ at
310
312
  });
311
313
  }
312
314
 
@@ -326,6 +328,102 @@ export function blankFinding(blank, { actionRecords = [], screenshot = null, act
326
328
  });
327
329
  }
328
330
 
331
+ /* --------------------------------------------- one event, reported twice */
332
+
333
+ /** The kinds of event the runner watches happen, and the words a persona reports each in. */
334
+ const EVENT_WORDS = Object.freeze({
335
+ game_frozen: /\b(froze|frozen|freez\w*|hang|hangs|hung|unresponsive|stopped (?:responding|answering|reacting)|not respon\w+|no longer respon\w+|locked up|lock(?:s|ed)? up|stuck)\b/i,
336
+ game_crashed: /\b(crash\w*|closed itself|quit (?:by )?itself|shut down|exited|went away|disappeared)\b/i,
337
+ blank_screen: /\b(blank|black screen|white screen|empty screen|went (?:black|white|dark)|nothing (?:is )?(?:drawn|shown|on (?:the )?screen))\b/i
338
+ });
339
+
340
+ /** A persona finding this many actions from the runner's own is about the same moment. */
341
+ export const SAME_EVENT_ACTIONS = 2;
342
+ /** Or this many milliseconds. */
343
+ export const SAME_EVENT_MS = 5000;
344
+
345
+ /** The latest action a finding cites, or null. */
346
+ function citedAction(finding, observations = []) {
347
+ const byIndex = new Map(observations.map(entry => [entry.index, entry]));
348
+ let latest = null;
349
+ for (const item of Array.isArray(finding && finding.evidence) ? finding.evidence : []) {
350
+ if (!item || item.type !== 'transcript_step') continue;
351
+ const ref = String(item.ref || '');
352
+ const acted = ref.match(/^\s*(?:action|step)\s*#?\s*(\d+)\s*$/i);
353
+ const seen = ref.match(/^\s*observation\s*#?\s*(\d+)\s*$/i);
354
+ // The screen an observation shows is the one the next input is played on.
355
+ const n = acted ? Number(acted[1]) : seen && byIndex.has(Number(seen[1])) ? Number(byIndex.get(Number(seen[1])).actions) + 1 : null;
356
+ if (Number.isFinite(n) && (latest === null || n > latest)) latest = n;
357
+ }
358
+ return latest;
359
+ }
360
+
361
+ /** The latest moment a finding cites, in milliseconds, or null. */
362
+ function citedTime(finding, observations = []) {
363
+ const byIndex = new Map(observations.map(entry => [entry.index, entry]));
364
+ let latest = null;
365
+ for (const item of Array.isArray(finding && finding.evidence) ? finding.evidence : []) {
366
+ const seen = item && item.type === 'transcript_step' ? String(item.ref || '').match(/^\s*observation\s*#?\s*(\d+)\s*$/i) : null;
367
+ const at = seen && byIndex.has(Number(seen[1])) ? Number(byIndex.get(Number(seen[1])).at) : NaN;
368
+ if (Number.isFinite(at) && (latest === null || at > latest)) latest = at;
369
+ }
370
+ return latest;
371
+ }
372
+
373
+ const SEVERITY_RANK = Object.freeze({ blocker: 0, major: 1, minor: 2, cosmetic: 3, praise: 4 });
374
+
375
+ /**
376
+ * One finding for one event. When the runner saw the game freeze, crash or go
377
+ * blank, and the persona's report names the same thing (the same kind of
378
+ * event, at the same step or within a few seconds, or citing no moment at
379
+ * all), the two are one bug and are counted once: the persona's finding keeps
380
+ * its id and its words, takes the higher severity, the runner's evidence and
381
+ * steps, and the runner's moment, so its video time is the time it happened.
382
+ * A paid web run (0.10.0) listed one freeze twice, F002 major from the persona
383
+ * and F003 blocker from the runner, and the dashboard said "2 issues".
384
+ *
385
+ * @param {Object} report
386
+ * @param {Array<Object>} runnerFindings from {@link runnerFinding}, with their `runner` anchors
387
+ * @param {{observations?: Array<Object>}} [context]
388
+ * @returns {{report: Object, rest: Array<Object>, merged: Array<{id: string, key: string, anchor: Object}>}}
389
+ */
390
+ export function mergeRunnerDuplicates(report, runnerFindings = [], { observations = [] } = {}) {
391
+ if (!report || !Array.isArray(report.findings) || runnerFindings.length === 0) return { report, rest: runnerFindings, merged: [] };
392
+ const merged = [];
393
+ const used = new Set();
394
+ const findings = report.findings.map(finding => {
395
+ if (!finding || !(finding.severity in SEVERITY_RANK) || finding.severity === 'praise') return finding;
396
+ const text = `${finding.title || ''}. ${finding.description || ''}`;
397
+ const title = String(finding.title || '').trim().toLowerCase();
398
+ const action = citedAction(finding, observations);
399
+ const at = citedTime(finding, observations);
400
+ const twin = runnerFindings.find(candidate => {
401
+ if (used.has(candidate)) return false;
402
+ const key = candidate.runner && candidate.runner.key;
403
+ // The same title (a report that copied the runner's), or the words of the same kind of event.
404
+ const named = title && title === String(candidate.title || '').trim().toLowerCase();
405
+ const words = EVENT_WORDS[key];
406
+ if (!named && !(words && words.test(text))) return false;
407
+ const ranAt = candidate.runner && Number.isInteger(candidate.runner.action) ? candidate.runner.action : null;
408
+ const ranTime = candidate.runner && Number.isFinite(candidate.runner.at) ? candidate.runner.at : null;
409
+ if (action === null && at === null) return true;
410
+ if (action !== null && ranAt !== null && Math.abs(action - ranAt) <= SAME_EVENT_ACTIONS) return true;
411
+ return at !== null && ranTime !== null && Math.abs(at - ranTime) <= SAME_EVENT_MS;
412
+ });
413
+ if (!twin) return finding;
414
+ used.add(twin);
415
+ const severity = SEVERITY_RANK[twin.severity] < SEVERITY_RANK[finding.severity] ? twin.severity : finding.severity;
416
+ // The persona's own observation refs stay; its screenshot and video time give way to the runner's, which are of the moment itself.
417
+ const own = (Array.isArray(finding.evidence) ? finding.evidence : []).filter(item => item && item.type === 'transcript_step' && /observation|note/i.test(String(item.ref || '')));
418
+ const evidence = [...twin.evidence, ...own];
419
+ const description = `${String(finding.description || '').replace(/\s+$/, '')}\n\nThe runner saw this happen too: ${twin.description}`;
420
+ merged.push({ id: finding.id, key: twin.runner.key, anchor: twin.runner, from: finding.severity, severity });
421
+ return { ...finding, severity, category: twin.category || finding.category, description, repro_steps: twin.repro_steps, evidence };
422
+ });
423
+ if (merged.length === 0) return { report, rest: runnerFindings, merged };
424
+ return { report: { ...report, findings }, rest: runnerFindings.filter(candidate => !used.has(candidate)), merged };
425
+ }
426
+
329
427
  /** The heading the runner lists its own findings under. */
330
428
  export const RUNNER_FINDINGS_HEADING = '## Found by the runner (seen happen, not the persona\'s opinion)';
331
429
 
@@ -356,9 +454,9 @@ export function addRunnerFindings(report, findings = []) {
356
454
  }
357
455
 
358
456
  /** The runner's findings as a markdown section body. */
359
- export function runnerFindingsMarkdown(added = []) {
457
+ export function runnerFindingsMarkdown(added = [], twins = new Set()) {
360
458
  return added.map(finding => [
361
- `### ${finding.id} [${finding.severity}/${finding.category}] ${finding.title}`,
459
+ `### ${finding.id} [${finding.severity}/${finding.category}] ${finding.title}${twins.has(finding.id) ? ' (the playtester reported it too; one finding)' : ''}`,
362
460
  finding.description,
363
461
  '',
364
462
  'Steps:',