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.
package/README.md CHANGED
@@ -721,15 +721,39 @@ How the report step reads what happened:
721
721
  enum field takes the schema's default. Each change is a runner note at the
722
722
  end of the finding's description and is listed in `report.md` under
723
723
  "Normalised by the runner". The server's schema stays strict.
724
- - After the report is written, each blocker or major (at most 3) is checked
725
- against its own evidence: the screenshot it cites taken nearest after the
726
- observation it cites is sent with its claim, and the question "does this
727
- image contradict the claim: yes, no, unclear". A yes downgrades it one step,
728
- with a note naming the screenshot, in both report files. The cost is 3
729
- calls at most, each one screenshot in and 32 tokens out, drawn from the
730
- run's own model budget (the one the 80 percent warning keeps room in for
731
- the report), never charged separately; a refusal ends the checks and keeps
732
- the report as written.
724
+ - After the report is written, every issue (the most severe first, at most 8)
725
+ is checked against the picture of its moment: the frame cut from the video
726
+ there, else the screenshot it cites, else the one the runner places at its
727
+ moment. The question is "does this picture show what the claim says: shows,
728
+ contradicts, unclear". Then, as on a cloud run:
729
+ - a claim the picture contradicts is never a finding, at any severity;
730
+ - a claim of fact about what the screen shows (its text, its layout,
731
+ something there or missing, the game's state) is a finding only when the
732
+ picture shows it; "unclear", or a check that could not be made, confirms
733
+ nothing;
734
+ - an opinion of taste or difficulty ("confusing", "too hard", "feels
735
+ slow") stands when the picture cannot settle it.
736
+
737
+ What is turned away leaves `report.json`, so it is not counted, ranked,
738
+ aggregated or sent as a finding, and every part of `report.md` that stood
739
+ on it (top issues, the success criteria line, what the run did not cover,
740
+ the suggested next step, which the runner rewrites from the issues that
741
+ stood) is cleared of it. It is listed under "Raised by the playtester, not
742
+ confirmed" with the reason. Each check is one picture in and 32 tokens out,
743
+ drawn from the run's own model budget, never charged separately; a refusal
744
+ ends the checks.
745
+ - A crash, a freeze or a blank screen the runner saw, which the report also
746
+ names (the same kind of event, at the same step or within a few seconds), is
747
+ one finding: the report's id and words, the higher severity, and the
748
+ runner's steps, evidence and moment, so its video time is when it happened.
749
+ - What the report says a screenshot shows comes from the picture. When the
750
+ game's state moved on for three inputs or more while its picture did not, a
751
+ screenshot taken then is described in `report.md` as the earlier screen it
752
+ shows ("the picture shows X while the game state reports Y"), and the
753
+ stretch is listed with the limits of the run as a capture problem of the
754
+ runner, never as a finding. A run of ten inputs or more whose pictures show
755
+ two different screens or fewer, counted by what they show, is listed there
756
+ too.
733
757
  - Console notes that match the brief's `expected_noise`, or the built in rule
734
758
  (a 401 on a who am I check while signed out), are expected noise
735
759
  and never a finding; see the `brief --from` file.
@@ -817,7 +841,7 @@ An action counts as changing the screen when the URL changed, the page loaded
817
841
  a new document, the visible tree (field values included) changed, or for typing,
818
842
  the field's own value changed, with one short second look for a navigation
819
843
  still starting. That is the "screen changed" the report step's action log and
820
- the downgrade rule read.
844
+ the action log rule reads.
821
845
 
822
846
  Every field, checkbox, radio, slider and select the persona sees carries what
823
847
  it holds now, read from the page rather than from the accessibility text:
@@ -30,7 +30,7 @@
30
30
  # it was parked, which is one of the limits docs/REPLAY.md names.
31
31
  extends Node
32
32
 
33
- const DRIVER_VERSION := "1.5.0"
33
+ const DRIVER_VERSION := "1.5.1"
34
34
  const DEFAULT_PORT := 47800
35
35
  const FEATURE_TAG := "ravensight_driver"
36
36
  const ADDON_DIR := "ravensight_driver"
@@ -102,6 +102,9 @@ var _strip_frames: Array = []
102
102
  var _strip_base: Image = null
103
103
  var _strip_ticks: Array = []
104
104
  var _step_total := 0
105
+ ## How many frames the driver drew itself because the window could not (see
106
+ ## _await_post_draw): reported by ping and with every screenshot.
107
+ var _forced_draws := 0
105
108
  const KEY_REPEAT_DELAY_MS := 500
106
109
  const KEY_REPEAT_INTERVAL_MS := 33
107
110
  const WHEEL_NOTCH := 120.0
@@ -424,6 +427,7 @@ func _rpc_ping(id: Variant) -> void:
424
427
  "tick": _sim_tick,
425
428
  "seed": _seed_value,
426
429
  "ticks_per_second": Engine.physics_ticks_per_second,
430
+ "forced_draws": _forced_draws,
427
431
  })
428
432
 
429
433
 
@@ -832,6 +836,7 @@ func _rpc_screenshot(id: Variant, params: Dictionary) -> void:
832
836
  "width": image.get_width(),
833
837
  "height": image.get_height(),
834
838
  "strip": strip_count,
839
+ "forced_draws": _forced_draws,
835
840
  "data": Marshalls.raw_to_base64(bytes),
836
841
  })
837
842
 
@@ -842,6 +847,9 @@ func _rpc_screenshot(id: Variant, params: Dictionary) -> void:
842
847
  func _strip_thumb() -> Image:
843
848
  if _is_headless():
844
849
  return null
850
+ # A window that cannot draw holds an old frame: draw the one the game is on.
851
+ if not _window_can_draw():
852
+ _draw_now()
845
853
  var image := get_viewport().get_texture().get_image()
846
854
  if image == null or image.is_empty():
847
855
  return null
@@ -1127,7 +1135,18 @@ func _list_user_files(dir_path: String, files: Array) -> void:
1127
1135
  ## The next drawn frame, or the last one. A window the desktop has covered or
1128
1136
  ## moved to another space stops drawing, frame_post_draw never fires, and an
1129
1137
  ## unbounded wait here hung the RPC until the client gave up on the run.
1138
+ ##
1139
+ ## Reading the viewport then gave the last frame the window drew, which on a
1140
+ ## minimized, covered or parked window was a frame from many inputs ago: a run
1141
+ ## played to the end of a game while every screenshot and the whole video stayed
1142
+ ## on its first screen. So a window that cannot draw, or a wait that saw no frame
1143
+ ## drawn, draws one here: the viewports are rendered without presenting them, so
1144
+ ## the picture read next is the game as it is now. Drawing runs no game code and
1145
+ ## advances no game time, so a lockstep run stays where it was.
1130
1146
  func _await_post_draw() -> void:
1147
+ if not _window_can_draw():
1148
+ _draw_now()
1149
+ return
1131
1150
  var drawn := [false]
1132
1151
  var mark := func() -> void: drawn[0] = true
1133
1152
  RenderingServer.frame_post_draw.connect(mark, CONNECT_ONE_SHOT)
@@ -1137,6 +1156,21 @@ func _await_post_draw() -> void:
1137
1156
  return
1138
1157
  if RenderingServer.frame_post_draw.is_connected(mark):
1139
1158
  RenderingServer.frame_post_draw.disconnect(mark)
1159
+ _draw_now()
1160
+
1161
+
1162
+ ## Whether the desktop lets the game's window draw a frame: false while it is
1163
+ ## minimized, and on some desktops while it is covered or on another space.
1164
+ func _window_can_draw() -> bool:
1165
+ if _is_headless():
1166
+ return false
1167
+ return DisplayServer.window_can_draw(get_window().get_window_id())
1168
+
1169
+
1170
+ ## Render every viewport once, without presenting it to the screen.
1171
+ func _draw_now() -> void:
1172
+ _forced_draws += 1
1173
+ RenderingServer.force_draw(false, 0.0)
1140
1174
 
1141
1175
 
1142
1176
  func _rpc_set_time_scale(id: Variant, params: Dictionary) -> void:
@@ -1222,8 +1256,12 @@ func _advance_lockstep() -> void:
1222
1256
  _sim_tick += 1
1223
1257
  _step_left -= 1
1224
1258
  if (_step_total - _step_left) in _strip_ticks:
1225
- # After this frame is drawn: the picture of the tick that just ran.
1226
- RenderingServer.frame_post_draw.connect(_grab_strip_frame, CONNECT_ONE_SHOT)
1259
+ # After this frame is drawn: the picture of the tick that just ran. A
1260
+ # window that cannot draw gets the frame drawn at the end of this one.
1261
+ if _window_can_draw():
1262
+ RenderingServer.frame_post_draw.connect(_grab_strip_frame, CONNECT_ONE_SHOT)
1263
+ else:
1264
+ _grab_strip_frame.call_deferred()
1227
1265
  if _step_left == 0:
1228
1266
  # A rate the game set during the step is the game's own (a hit stop,
1229
1267
  # a slow motion), so the next step resumes at it.
@@ -285,6 +285,15 @@ that sets its own `time_scale` keeps it: the scale read back when the clock is
285
285
  frozen is the one restored next. `run --realtime` turns this off for a game
286
286
  that has to keep running in real time.
287
287
 
288
+ A screenshot, a frame of the video and a frame of the strip are always the
289
+ frame the game is on. A window the desktop has minimized, covered or moved to
290
+ another space stops drawing, and reading it gave the last frame it drew, from
291
+ many inputs before (addon 1.5.0 and earlier). Since addon 1.5.1 the driver
292
+ draws the frame itself when the window cannot, rendering without presenting
293
+ and without running any game code or game time, so a lockstep run stays where
294
+ it was. `ping` and every `screenshot` answer carry `forced_draws`, how many
295
+ frames the driver has drawn that way.
296
+
288
297
  `time_scale` 0 stops what reads `delta` or a timer. A game that moves on wall
289
298
  clock time (`Time.get_ticks_msec()`) is not paused by it.
290
299
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ravensight-playtest",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "description": "Local AI playtests and seeded game simulations with reports in Ravensight.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://ravensight.io/docs/#playtest",
@@ -48,8 +48,8 @@
48
48
  "./api": "./src/api/index.js"
49
49
  },
50
50
  "scripts": {
51
- "test": "node --test --test-reporter=spec 'src/**/!(godot-real|godot-inputs.real|godot-replay.real|godot-tester.real|web.e2e|web.containment.e2e|web.inputs.e2e|web.honesty.e2e|web.followups.e2e|web.replay.e2e|web.anygame.e2e|web.tester.e2e|scaffold.godot|template3d.godot).test.js'",
52
- "test:godot": "node scripts/gated-test.mjs RAVENSIGHT_RECORDING_E2E some -- --test --test-concurrency=1 --test-reporter=spec src/run/drivers/godot-real.test.js src/run/drivers/godot-inputs.real.test.js src/run/drivers/godot-replay.real.test.js src/run/drivers/godot-tester.real.test.js src/create/scaffold.godot.test.js src/create/template3d.godot.test.js",
51
+ "test": "node --test --test-reporter=spec 'src/**/!(godot-real|godot-draw.real|godot-inputs.real|godot-replay.real|godot-tester.real|web.e2e|web.containment.e2e|web.inputs.e2e|web.honesty.e2e|web.followups.e2e|web.replay.e2e|web.anygame.e2e|web.tester.e2e|scaffold.godot|template3d.godot).test.js'",
52
+ "test:godot": "node scripts/gated-test.mjs RAVENSIGHT_RECORDING_E2E some -- --test --test-concurrency=1 --test-reporter=spec src/run/drivers/godot-real.test.js src/run/drivers/godot-draw.real.test.js src/run/drivers/godot-inputs.real.test.js src/run/drivers/godot-replay.real.test.js src/run/drivers/godot-tester.real.test.js src/create/scaffold.godot.test.js src/create/template3d.godot.test.js",
53
53
  "test:e2e": "node scripts/gated-test.mjs RAVENSIGHT_E2E all -- --test --test-reporter=spec src/run/drivers/web.e2e.test.js src/run/drivers/web.containment.e2e.test.js src/run/drivers/web.inputs.e2e.test.js src/run/drivers/web.honesty.e2e.test.js src/run/drivers/web.followups.e2e.test.js src/run/drivers/web.tester.e2e.test.js src/run/drivers/web.replay.e2e.test.js src/run/drivers/web.anygame.e2e.test.js",
54
54
  "lint": "node scripts/no-dashes.mjs"
55
55
  },
package/src/cli.js CHANGED
@@ -732,6 +732,15 @@ export function buildProgram() {
732
732
  */
733
733
  export async function main(argv = process.argv, options = {}) {
734
734
  const program = buildProgram();
735
+ // `<group> <sub> --help`, `help <group> <sub>` and `<group> help <sub>`
736
+ // print that subcommand's own help. Commander alone answered some of these
737
+ // with a parent's page (a paid proof run's "hosted run --help" printed the
738
+ // root help in 0.10.0), so the command asked about is found here first.
739
+ const asked = helpTarget(program, argv.slice(2));
740
+ if (asked) {
741
+ (options.write || (text => process.stdout.write(text)))(asked.helpInformation());
742
+ return ExitCode.OK;
743
+ }
735
744
  program.exitOverride();
736
745
  // Commander writes its own help and usage errors straight to the process
737
746
  // streams. Routing them through `options.write` lets a test drive the whole
@@ -754,6 +763,48 @@ export async function main(argv = process.argv, options = {}) {
754
763
  }
755
764
  }
756
765
 
766
+ /**
767
+ * The subcommand a help request is about, or null to leave the request (and
768
+ * every other command line) to commander. Walks the words in order: a
769
+ * subcommand's name goes one level down, an option is skipped with its value,
770
+ * and `--help`, `-h` or a bare `help` asks for help on where the walk stands.
771
+ * The root and a single command keep commander's own help.
772
+ *
773
+ * @param {import('commander').Command} program
774
+ * @param {Array<string>} args the words after the program name
775
+ * @returns {import('commander').Command|null}
776
+ */
777
+ export function helpTarget(program, args = []) {
778
+ let current = program;
779
+ let asked = false;
780
+ let depth = 0;
781
+ const optionsOf = command => {
782
+ const all = [];
783
+ for (let at = command; at; at = at.parent) all.push(...at.options);
784
+ return all;
785
+ };
786
+ for (let i = 0; i < args.length; i += 1) {
787
+ const word = String(args[i]);
788
+ if (word === '--') break;
789
+ if (word === '--help' || word === '-h') { asked = true; continue; }
790
+ if (word.startsWith('-')) {
791
+ const flag = word.split('=')[0];
792
+ const option = optionsOf(current).find(candidate => candidate.long === flag || candidate.short === flag);
793
+ const next = args[i + 1];
794
+ const isCommand = next !== undefined && current.commands.some(command => command.name() === String(next));
795
+ // A value follows an option that takes one; after an option this command does not know, a word that names no subcommand is taken as its value.
796
+ if (!word.includes('=') && next !== undefined && !String(next).startsWith('-') && (option ? option.required || (option.optional && !isCommand) : !isCommand)) i += 1;
797
+ continue;
798
+ }
799
+ const sub = current.commands.find(command => command.name() === word || command.aliases().includes(word));
800
+ if (sub) { current = sub; depth += 1; continue; }
801
+ if (word === 'help') { asked = true; continue; }
802
+ // A positional argument: the walk stands where it is.
803
+ break;
804
+ }
805
+ return asked && depth >= 2 ? current : null;
806
+ }
807
+
757
808
  /**
758
809
  * Turn a thrown thing into a printed message and an exit code.
759
810
  * @param {unknown} error
@@ -469,8 +469,11 @@ export function fakeCore({
469
469
  */
470
470
  export function fakeDriver() {
471
471
  let step = 0;
472
+ let runDir = null;
472
473
  return {
473
- async launch() {},
474
+ async launch(options) {
475
+ runDir = options && options.runDir;
476
+ },
474
477
  async observe() {
475
478
  step += 1;
476
479
  return { step, text: 'the title screen of a small game about bunnies', url: 'http://game.test/', elapsedMs: 1 };
@@ -479,7 +482,16 @@ export function fakeDriver() {
479
482
  return { ok: true, changed: true };
480
483
  },
481
484
  async screenshot(name) {
482
- return { path: `/tmp/${name}.png`, relativePath: `screenshots/01-${name}.png` };
485
+ const relativePath = `screenshots/01-${name}.png`;
486
+ // A picture on disk, so the claim checks after the report have one to be shown.
487
+ if (runDir) {
488
+ const { mkdir, writeFile } = await import('node:fs/promises');
489
+ const { join, dirname } = await import('node:path');
490
+ await mkdir(dirname(join(runDir, relativePath)), { recursive: true });
491
+ await writeFile(join(runDir, relativePath), `png ${name}`);
492
+ return { path: join(runDir, relativePath), relativePath };
493
+ }
494
+ return { path: `/tmp/${name}.png`, relativePath };
483
495
  },
484
496
  async consoleErrors() {
485
497
  return [];
@@ -0,0 +1,161 @@
1
+ // Whether the pictures of a run show the game as it was.
2
+ //
3
+ // A paid Godot run (0.10.0, pt_job_5c1b45f7a3cdfa43271d) played to victory by
4
+ // its scene tree while every picture from the faction choice on showed
5
+ // "Steps: 0 / 12": the window had stopped drawing and the runner read its last
6
+ // frame. The report then said a screenshot showed the victory text, from the
7
+ // game state and the model's belief, when the picture showed the march start.
8
+ //
9
+ // The runner already looks at the screen after every input. This module keeps
10
+ // what it saw: how many different pictures the run has had (by content, the
11
+ // same measure as ./pixels.js), and every stretch in which the game's state
12
+ // moved on and its picture did not. Such a stretch is a capture problem of the
13
+ // runner, never a finding about the game: it is listed with the limits of the
14
+ // run, and a screenshot taken inside one is described as what it is, the
15
+ // picture of an earlier moment, never as the state.
16
+ //
17
+ // No model is asked anything here.
18
+ import { createDistinct, pngFingerprint, screenDelta, significant } from './pixels.js';
19
+
20
+ /** This many inputs in a row whose state moved and whose picture did not is a stale picture, not a quiet redraw. */
21
+ export const STALE_AFTER_INPUTS = 3;
22
+ /** A run of at least this many inputs whose pictures show at most {@link FEW_PICTURES} screens is flagged. */
23
+ export const FEW_PICTURES_INPUTS = 10;
24
+ export const FEW_PICTURES = 2;
25
+
26
+ /** A line as a person reads it: the quoted text of an outline line (a label's words), else the line. */
27
+ const line = text => {
28
+ const quoted = String(text || '').match(/"([^"]+)"/);
29
+ return (quoted ? quoted[1] : String(text || '')).replace(/\s+/g, ' ').trim().slice(0, 140);
30
+ };
31
+
32
+ /**
33
+ * The first line that differs between two observation texts, from each side:
34
+ * what the screen said then, and what it says now.
35
+ *
36
+ * @returns {{then: string, now: string}|null}
37
+ */
38
+ export function textChange(before, after) {
39
+ const a = String(before || '').split('\n').map(text => text.trim()).filter(Boolean);
40
+ const b = String(after || '').split('\n').map(text => text.trim()).filter(Boolean);
41
+ const inA = new Set(a);
42
+ const inB = new Set(b);
43
+ const then = a.find(text => !inB.has(text));
44
+ const now = b.find(text => !inA.has(text));
45
+ if (!then && !now) return null;
46
+ return { then: line(then || ''), now: line(now || '') };
47
+ }
48
+
49
+ /**
50
+ * Watch the pictures of a run, one look after each input.
51
+ *
52
+ * @returns {{after: Function, staleAt: Function, summary: Function}}
53
+ */
54
+ export function createCaptureWatch() {
55
+ const distinct = createDistinct();
56
+ let inputs = 0;
57
+ let last = null;
58
+ let fresh = null;
59
+ let open = null;
60
+ const stretches = [];
61
+ const byObservation = new Map();
62
+ return {
63
+ /**
64
+ * @param {{action: number, observation: number, changed: boolean, png: Buffer|null, text: string}} look
65
+ * `changed` is the driver's own answer (its state, its text or its picture), `png` the screen now
66
+ */
67
+ after({ action, observation, changed, png, text }) {
68
+ const print = png ? pngFingerprint(png) : null;
69
+ if (!print) { last = null; return; }
70
+ inputs += 1;
71
+ distinct.add(png);
72
+ const moved = last ? significant(screenDelta(last.print, print)) : true;
73
+ if (moved || !fresh) {
74
+ fresh = { action, observation, text };
75
+ if (open) { if (open.inputs >= STALE_AFTER_INPUTS) stretches.push(open); open = null; }
76
+ } else if (changed === true) {
77
+ // The game said it changed and the picture is the one it was.
78
+ open = open || { from: action, freshAction: fresh.action, freshObservation: fresh.observation, freshText: fresh.text, inputs: 0 };
79
+ open.inputs += 1;
80
+ open.to = action;
81
+ open.toObservation = observation;
82
+ open.nowText = text;
83
+ }
84
+ if (open && open.inputs >= STALE_AFTER_INPUTS) {
85
+ // Every look since the picture last moved shows that earlier moment.
86
+ for (let index = open.freshObservation + 1; index <= observation; index += 1) byObservation.set(index, open);
87
+ }
88
+ last = { print };
89
+ },
90
+
91
+ /**
92
+ * The stale stretch a picture taken at this observation falls in, or null.
93
+ *
94
+ * @param {number} observation
95
+ */
96
+ staleAt(observation) {
97
+ const stretch = byObservation.get(observation);
98
+ return stretch && stretch.inputs >= STALE_AFTER_INPUTS ? stretch : null;
99
+ },
100
+
101
+ /** @returns {{inputs: number, pictures: number, stretches: Array<Object>}} */
102
+ summary() {
103
+ const all = open && open.inputs >= STALE_AFTER_INPUTS ? [...stretches, open] : stretches;
104
+ return { inputs, pictures: distinct.count, stretches: all };
105
+ }
106
+ };
107
+ }
108
+
109
+ /** What a stale picture shows, in the report's words. */
110
+ export function staleSentence(stretch) {
111
+ const change = textChange(stretch.freshText, stretch.nowText);
112
+ const shows = change && change.then ? `the screen as it was at action ${stretch.freshAction} ("${change.then}")` : `the screen as it was at action ${stretch.freshAction}`;
113
+ const state = change && change.now ? `"${change.now}"` : 'that it had moved on';
114
+ return `the picture shows ${shows} while the game state reports ${state}`;
115
+ }
116
+
117
+ /**
118
+ * The run's capture problems as limits of the runner (capability notes), never
119
+ * findings: a stretch in which the state moved and the picture did not, and a
120
+ * run of many inputs whose pictures barely change.
121
+ *
122
+ * @param {{inputs: number, pictures: number, stretches: Array<Object>}} summary
123
+ * @returns {Array<{input: string, reason: string}>}
124
+ */
125
+ export function captureNotes(summary) {
126
+ if (!summary) return [];
127
+ const notes = [];
128
+ const [first, ...more] = summary.stretches;
129
+ if (first) {
130
+ notes.push({ input: 'screen capture', reason: `from action ${first.from} to action ${first.to} ${staleSentence(first)}${more.length > 0 ? `, and ${more.length} more stretch(es) like it` : ''}: the game moved on and its picture did not, so the screenshots and the video of those moments are a capture problem of the runner, not something the game did` });
131
+ }
132
+ if (summary.inputs >= FEW_PICTURES_INPUTS && summary.pictures <= FEW_PICTURES) {
133
+ notes.push({ input: 'screen pictures', reason: `the pictures of this run show ${summary.pictures} different screen(s) in ${summary.inputs} inputs, counted by what they show, so they say little about how the game looked as it was played` });
134
+ }
135
+ return notes;
136
+ }
137
+
138
+ const EVIDENCE = /^##\s+Evidence\b/i;
139
+
140
+ /**
141
+ * report.md's Evidence lines for a picture taken inside a stale stretch, said
142
+ * as what the picture shows: the line names the file and says the picture is
143
+ * of an earlier moment than the state, whatever the report wrote about it.
144
+ *
145
+ * @param {string} markdown
146
+ * @param {Array<{relativePath: string, stale: Object}>} stale screenshots with their stretch
147
+ * @returns {string}
148
+ */
149
+ export function rewriteStaleEvidence(markdown, stale) {
150
+ if (!Array.isArray(stale) || stale.length === 0) return markdown;
151
+ let inEvidence = false;
152
+ return String(markdown || '').split('\n').map(text => {
153
+ if (/^##\s/.test(text)) { inEvidence = EVIDENCE.test(text); return text; }
154
+ if (!inEvidence) return text;
155
+ const shot = stale.find(entry => text.includes(entry.relativePath));
156
+ if (!shot || !/^\s*[-*+]\s/.test(text)) return text;
157
+ return `- ${shot.relativePath}: ${staleSentence(shot.stale)}. This is a capture problem of the runner, not something the game did (see the limits of this run).`;
158
+ }).join('\n');
159
+ }
160
+
161
+ export default { createCaptureWatch, captureNotes, rewriteStaleEvidence, staleSentence, textChange, STALE_AFTER_INPUTS };