fwdloop 0.38.0 → 0.40.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.
Files changed (129) hide show
  1. package/README.md +6 -9
  2. package/bin/fwdloop +21 -19
  3. package/package.json +1 -1
  4. package/src/ask.js +70 -148
  5. package/src/audit-fold.js +6 -5
  6. package/src/auditchecks.js +6 -4
  7. package/src/authoring.js +32 -60
  8. package/src/blockasks.js +2 -1
  9. package/src/blockassemble.js +15 -3
  10. package/src/blockdraft.js +2 -2
  11. package/src/blockpick.js +42 -16
  12. package/src/books.js +237 -12
  13. package/src/checkblock.js +24 -44
  14. package/src/checklistsign.js +25 -3
  15. package/src/checklook.js +3 -1
  16. package/src/checkpick.js +6 -77
  17. package/src/cited-source.js +4 -4
  18. package/src/citedcheck.js +6 -11
  19. package/src/citedwords.js +9 -8
  20. package/src/closers.js +9 -6
  21. package/src/declaration.js +14 -49
  22. package/src/diary.js +23 -1
  23. package/src/draft-steps.js +11 -1
  24. package/src/drafter.js +18 -12
  25. package/src/draftfiles.js +127 -0
  26. package/src/draftspend.js +165 -17
  27. package/src/flow.js +42 -87
  28. package/src/flowmodel.js +1 -1
  29. package/src/index.js +3 -2
  30. package/src/inside.js +106 -0
  31. package/src/jsonl-append.js +33 -1
  32. package/src/learn.js +1 -1
  33. package/src/learnstore.js +20 -22
  34. package/src/line-checks.js +1 -1
  35. package/src/liveness.js +3 -0
  36. package/src/mcp-use.js +8 -9
  37. package/src/memo.js +13 -16
  38. package/src/model-step.js +2 -2
  39. package/src/page-words.js +8 -0
  40. package/src/pageask.js +8 -3
  41. package/src/pagebits.js +8 -1
  42. package/src/pagedropwords.js +1 -1
  43. package/src/pagerules.js +6 -3
  44. package/src/panel/author.js +99 -75
  45. package/src/panel/authorcard.js +21 -8
  46. package/src/panel/authorflows.js +3 -3
  47. package/src/panel/authorresume.js +3 -3
  48. package/src/panel/authorstart.js +15 -16
  49. package/src/panel/authortrigger.js +43 -70
  50. package/src/panel/data.js +186 -188
  51. package/src/panel/index.html +139 -115
  52. package/src/panel/jobgrid.js +3 -7
  53. package/src/panel/result.js +7 -10
  54. package/src/panel/resume.js +4 -3
  55. package/src/panel/scheduler.js +9 -9
  56. package/src/panel/server.js +8 -4
  57. package/src/panel/spawn.js +22 -11
  58. package/src/panel/tickets.js +2 -2
  59. package/src/pickrecord.js +51 -31
  60. package/src/placerule.js +3 -4
  61. package/src/plain-checks.js +1 -1
  62. package/src/planrebuild.js +19 -19
  63. package/src/primitives.js +1 -1
  64. package/src/provider.js +1 -1
  65. package/src/reasons.js +25 -0
  66. package/src/runfile.js +26 -2
  67. package/src/runner.js +57 -105
  68. package/src/runvalues.js +47 -24
  69. package/src/schedule-choices.js +41 -0
  70. package/src/schedule-shape.js +39 -0
  71. package/src/schedule.js +9 -8
  72. package/src/setup.js +20 -36
  73. package/src/shaperows.js +2 -2
  74. package/src/sheetblock.js +2 -2
  75. package/src/sheetbuild.js +5 -5
  76. package/src/sheetrun.js +4 -5
  77. package/src/summary-words.js +2 -1
  78. package/src/thinking.js +5 -2
  79. package/src/ticketrows.js +7 -28
  80. package/src/trigger-clock.js +9 -23
  81. package/src/trigger-files.js +30 -22
  82. package/src/trigger-tickets.js +15 -14
  83. package/src/try-checks.js +2 -1
  84. package/src/types.js +2 -0
  85. package/types/ask.d.ts +25 -20
  86. package/types/authoring.d.ts +7 -42
  87. package/types/blockpick.d.ts +1 -1
  88. package/types/books.d.ts +380 -4
  89. package/types/checkblock.d.ts +1 -23
  90. package/types/checklist.d.ts +3 -3
  91. package/types/checklistsign.d.ts +7 -0
  92. package/types/checkpick.d.ts +0 -21
  93. package/types/citedwords.d.ts +7 -4
  94. package/types/closers.d.ts +1 -0
  95. package/types/declaration.d.ts +4 -14
  96. package/types/diary.d.ts +14 -1
  97. package/types/draft-steps.d.ts +7 -0
  98. package/types/drafter.d.ts +1 -1
  99. package/types/draftfiles.d.ts +89 -0
  100. package/types/draftspend.d.ts +74 -0
  101. package/types/flow.d.ts +32 -54
  102. package/types/index.d.ts +3 -3
  103. package/types/inside.d.ts +71 -0
  104. package/types/jsonl-append.d.ts +20 -0
  105. package/types/learnstore.d.ts +0 -2
  106. package/types/liveness.d.ts +1 -0
  107. package/types/page-words.d.ts +6 -0
  108. package/types/pageask.d.ts +2 -0
  109. package/types/pagebits.d.ts +3 -0
  110. package/types/pagerules.d.ts +1 -0
  111. package/types/panel/author.d.ts +7 -3
  112. package/types/panel/authorcard.d.ts +0 -6
  113. package/types/panel/authorflows.d.ts +4 -4
  114. package/types/panel/authortrigger.d.ts +16 -2
  115. package/types/panel/data.d.ts +50 -16
  116. package/types/panel/spawn.d.ts +18 -2
  117. package/types/pickrecord.d.ts +29 -0
  118. package/types/reasons.d.ts +23 -0
  119. package/types/runfile.d.ts +14 -0
  120. package/types/runner.d.ts +6 -38
  121. package/types/runvalues.d.ts +17 -2
  122. package/types/schedule-choices.d.ts +9 -0
  123. package/types/schedule-shape.d.ts +15 -0
  124. package/types/sheetbuild.d.ts +1 -1
  125. package/types/thinking.d.ts +1 -0
  126. package/types/ticketrows.d.ts +0 -9
  127. package/types/trigger-clock.d.ts +3 -2
  128. package/types/trigger-files.d.ts +15 -4
  129. package/types/types.d.ts +8 -0
package/src/panel/data.js CHANGED
@@ -28,17 +28,17 @@ import { plainPlanCheck, pickPlanRed } from '../plain-checks.js';
28
28
  import { compareNatural } from '../natural.js';
29
29
  import { join, sep } from 'node:path';
30
30
 
31
+ import { readFlow, readPlan, readRunPlan, readRunJobCopy, listFlowNames, listRunIds, resolveRunDir, checkFlowName } from '../flow.js';
32
+ import { readFileInside, readdirInside, stampsInside } from '../inside.js';
31
33
  import {
32
- readFlow, readPlan, readRunPlan, readRunJobCopy, listFlowNames, listRunIds, resolveRunDir, checkFlowName, readFileInside, readdirInside,
33
- } from '../flow.js';
34
- import {
35
- readAudit, readHistory, endRow, readPidRows, auditRowTokens, auditRowAt, auditRowTools,
34
+ readAudit, readHistory, endRow, readPidRows, readSavedAnswer, processStarted, readRunState, readLog, readHaltRecord, readTriggerRecord, consumedAnswerName, askIdOfConsumedName,
35
+ endingWord, auditSignWord, isAskRow, isBlockedEnding, isGoodEnding, isWaitingEnding, isStopNote, isResumableEnding, redWhyOf, isDraftRowVerdict, auditRowTokens, auditRowAt, auditRowTools,
36
36
  } from '../books.js';
37
37
  import {
38
- readAsk, readRunState, readLog, readHaltRecord, stopPending,
38
+ readAsk, stopPending,
39
39
  } from '../runner.js';
40
40
  import { readSpendRows } from '../provider.js';
41
- import { applyRunValues, parseWaitMs, pickRunValues, VALUES_FILE_RE } from '../runvalues.js';
41
+ import { applyRunValues, listRunValues, parseWaitMs, pickRunValues } from '../runvalues.js';
42
42
  import { readSetup } from '../setup.js';
43
43
  import { parseHintBlock } from '../learn.js';
44
44
  import { checkedLines, notCheckedView, notCheckedLabelOf, listPartRows } from '../checked.js';
@@ -50,14 +50,15 @@ import { panelQuestionText, decidedWords } from '../pageask.js';
50
50
  import { csvRolesOf, askSheetCard } from '../sheetblock.js';
51
51
  import { readSheetChecks } from '../sheet-record.js';
52
52
  import {
53
- NO_COPY_SAY, catchUpWords, endedLineWords, endedWords, needsLeftWords, nextInWords, nextTimeWords, scheduleAuditWords, scheduleBlockWords, scheduleFieldWords, scheduledNextFor, scheduledWords, startedWords,
53
+ NO_COPY_SAY, catchUpWords, endedLineWords, endedWords, needsLeftWords, nextInWords, nextTimeWords, scheduleAuditWords, scheduleBlockWords, scheduleFieldWords, scheduledNextFor, scheduledWords, startedNothing, startedWords,
54
54
  } from '../summary-words.js';
55
55
  import { MAX_STRUCTURE_RETRIES } from '../drafter.js';
56
56
  import { hasResultCards, checkTypeOf, buildResult, downloadOf, readCitedChecks } from './result.js';
57
57
  import { ticketListOf, ticketScheduleOf } from './tickets.js';
58
- import { buildJobGrid } from './jobgrid.js';
59
- import { readChecks } from '../diary.js';
60
- import { readRunInputs, readRunRecord } from '../runfile.js';
58
+ import { buildJobGrid, runMoney } from './jobgrid.js';
59
+ import { readChecks, readTryStarts } from '../diary.js';
60
+ import { mmss, stepped } from '../draftspend.js';
61
+ import { readRerunWords, readRunInputs } from '../runfile.js';
61
62
  import { filterUnsure } from '../ticket-labels.js';
62
63
  import { readSchedule } from '../schedule.js';
63
64
  import { flowTypeOf } from '../declaration.js';
@@ -68,7 +69,7 @@ import {
68
69
  isTryRow, loadDiaries, deriveFold, cardLine, summaryLines,
69
70
  } from '../audit-fold.js';
70
71
  import {
71
- runLiveness, booksFresh, readResumeLock,
72
+ runLiveness, booksFresh, readResumeLock, lockMayBeHeld,
72
73
  } from '../liveness.js';
73
74
  import {
74
75
  readAskEvidence, listArchivedAsks, normalizeDecision, DECISION_STATUS, decisionStatus, answerTiming,
@@ -161,31 +162,19 @@ export function hasConsumedAnswer(runDir, askId) {
161
162
  // consumed answer that isn't really there by planting a symlink named to
162
163
  // match the pattern.
163
164
  const names = readdirInside(runDir, '.');
164
- return names.includes(`answer.${askId}.consumed.json`);
165
+ return names.includes(consumedAnswerName(askId));
165
166
  }
166
167
 
167
168
  /**
168
- * M4b piece 2: a SAVED, not-yet-consumed answer — `answer.json` (what
169
- * `answerAsk` writes; the resume consumes it by renaming it away, F44). Read
170
- * through `readFileInside` (a symlinked file is "none"). `null` when there is
171
- * none or it is unreadable/unparseable or names no askId.
169
+ * M4b piece 2: a SAVED, not-yet-consumed answer, as the panel shows it: `readSavedAnswer` (src/books.js, the one reader) read for an answer that names an ask.
170
+ * `null` when there is none or it is unreadable, unparseable or names no askId. `broken` is the reader's own field (M20 am3b item 1).
172
171
  * @param {string} runDir
173
- * @returns {{askId: string, decision: string|null, answeredAt: string|null}|null}
172
+ * @returns {{askId: string, decision: string|null, answeredAt: string|null, broken: boolean}|null}
174
173
  */
175
- export function readSavedAnswer(runDir) {
176
- const r = readFileInside(runDir, 'answer.json');
177
- if (!r.ok) return null;
178
- try {
179
- const a = JSON.parse(r.text);
180
- if (a && typeof a.askId === 'string' && a.askId.length > 0) {
181
- return {
182
- askId: a.askId,
183
- decision: typeof a.decision === 'string' ? normalizeDecision(a.decision) : null,
184
- answeredAt: typeof a.answeredAt === 'string' ? a.answeredAt : null,
185
- };
186
- }
187
- } catch { /* unparseable: not a usable answer */ }
188
- return null;
174
+ export function savedAnswerOf(runDir) {
175
+ const r = readSavedAnswer(runDir);
176
+ if (!r.ok || r.askId === null) return null;
177
+ return { askId: r.askId, decision: r.decision === null ? null : normalizeDecision(r.decision), answeredAt: r.answeredAt, broken: r.broken };
189
178
  }
190
179
 
191
180
  /** What the `resume` field says when the panel has no attempt record for a run
@@ -202,7 +191,7 @@ export const RESUME_REASON_UNKNOWN = 'reason unknown: the panel restarted, so it
202
191
  * answer for that ask that was NOT saved in time, once the deadline has passed, is not a resumable answer: it reads
203
192
  * as none, so the ask is expired and offers the reopen (M4c-fix amendment 1 (b)). One with no readable time, before
204
193
  * the deadline, reads `broken` (amendment 1 (a)).
205
- * @param {{savedAnswer: {askId:string, decision:string|null, answeredAt?:string|null}|null, attempt: any, ask?: any}} ctx
194
+ * @param {{savedAnswer: {askId:string, decision:string|null, answeredAt?:string|null, broken?: boolean}|null, attempt: any, ask?: any}} ctx
206
195
  * @returns {{state: 'starting'|'not-started'|'broken'|'took-over', askId: string|null, tries: number|null, maxTries: number|null, reason: string|null, label: string}|null}
207
196
  */
208
197
  export function deriveResumeState({ savedAnswer: savedOnDisk, attempt, ask = null }) {
@@ -216,7 +205,7 @@ export function deriveResumeState({ savedAnswer: savedOnDisk, attempt, ask = nul
216
205
  if (saved) {
217
206
  // M4c-fix amendment 1 (a): a saved answer with no readable time is broken — the resume would refuse it every
218
207
  // time. It is not stuck, not "answer saved": the doors come back with a note, and answering again sets it aside.
219
- if (Number.isNaN(Date.parse(saved.answeredAt ?? ''))) {
208
+ if (saved.broken) {
220
209
  return {
221
210
  state: 'broken', askId: saved.askId, tries: null, maxTries: null, reason: BROKEN_ANSWER_WHY, label: BROKEN_LABEL,
222
211
  };
@@ -244,6 +233,10 @@ export function deriveResumeState({ savedAnswer: savedOnDisk, attempt, ask = nul
244
233
  return null;
245
234
  }
246
235
 
236
+ /** M20 am8: the one question "is THIS ask's saved answer being picked up, or the run stopped before using it" (`resume` = `deriveResumeState`: starting or not-started, for this ask) @param {any} resume @param {unknown} askId @returns {boolean} */
237
+ export const answerPickedUp = (resume, askId) => resume != null && resume.askId === askId
238
+ && (resume.state === 'starting' || resume.state === 'not-started');
239
+
247
240
  export const WAITING_LABEL = 'waiting on you (parked, unanswered)';
248
241
  export const STUCK_LABEL = 'stuck — your answer is saved; the run stopped before using it';
249
242
  export const STUCK_LOCK_LABEL = 'stuck — an old resume lock is in the way';
@@ -257,7 +250,7 @@ export const CRASHED_LABEL = 'crashed after taking your answer — start a fresh
257
250
  * @type {Record<string, string>}
258
251
  */
259
252
  export const SIGN_WORDS = {
260
- '[▶]': 'running', '[·]': 'waiting', '[II]': 'stuck', '[!]': 'expired', '[?]': 'crashed', '[✓]': 'passed', '[✗]': 'failed', '[■]': 'stopped', '[–]': 'skipped',
253
+ '[▶]': 'running', '[·]': 'waiting', '[II]': 'stuck', '[!]': endingWord('ask-expired') ?? '', '[?]': 'crashed', '[✓]': endingWord('complete') ?? '', '[✗]': endingWord('red') ?? '', '[■]': endingWord('stopped') ?? '', '[–]': endingWord('skipped') ?? '',
261
254
  };
262
255
 
263
256
  /**
@@ -265,11 +258,12 @@ export const SIGN_WORDS = {
265
258
  * opens with the word ("stuck — …") or is the word itself ("passed") loses that repeat, so it is never said twice.
266
259
  * `noWord`: a run the human ended on purpose with rerun wears `[✗]` but is never called "failed" (M4b amendment 3),
267
260
  * so it shows its plain line alone.
268
- * @param {string} glyph a `computeGlyph` sign @param {string} label its plain line @param {boolean} [noWord]
261
+ * @param {string} glyph a `computeGlyph` sign @param {string} label its plain line @param {boolean} [noWord] @param {{outcome: string|null|undefined}|null} [ending] the run's end row outcome
269
262
  * @returns {{word: string|null, line: string|null}}
270
263
  */
271
- export function signParts(glyph, label, noWord = false) {
272
- const word = noWord ? null : (SIGN_WORDS[glyph] ?? null);
264
+ export function signParts(glyph, label, noWord = false, ending = null) {
265
+ // M20 am1 items 1 and 9: a run that has ended reads the word of its ENDING (the one table, src/books.js); a sign alone gives the word for the rest
266
+ const word = noWord ? null : ((ending && ending.outcome ? endingWord(ending.outcome) : null) ?? SIGN_WORDS[glyph] ?? null);
273
267
  if (word === null) return { word: null, line: label ?? null };
274
268
  if (typeof label !== 'string' || label === word) return { word, line: null };
275
269
  if (label.startsWith(`${word} — `)) return { word, line: label.slice(word.length + 3) };
@@ -305,7 +299,7 @@ export const STUCK_REASONS = {
305
299
  * @returns {{stuck: false, reason: null, label: null, why: null}|{stuck: true, reason: 'retry'|'lock-no-holder', label: string, why: string|null}}
306
300
  */
307
301
  export function stuckState({ resume, liveness, lock }) {
308
- if (!resume || resume.state !== 'not-started' || liveness === 'running' || lock === 'live' || lock === 'unknown') {
302
+ if (!resume || resume.state !== 'not-started' || liveness === 'running' || lockMayBeHeld(lock)) {
309
303
  return {
310
304
  stuck: false, reason: null, label: null, why: null,
311
305
  };
@@ -402,12 +396,14 @@ export function computeGlyph({
402
396
  // M12 piece 3 (item 9): a ticket the signed labels do not match, or a closed one: grey, never failed
403
397
  if (historyRow.outcome === 'skipped') return { glyph: '[–]', label: typeof historyRow.skipReason === 'string' && historyRow.skipReason !== '' ? `skipped — ${historyRow.skipReason}` : 'skipped' };
404
398
  // M6 amendment 4: a stopped (or cap-halted) run whose job was edited and signed since cannot be resumed; the words say so.
405
- if (jobEdited === true && (historyRow.outcome === 'stopped' || historyRow.outcome === 'cap-halt')) return { glyph: '[■]', label: JOB_EDITED_LINE };
399
+ if (jobEdited === true && isResumableEnding(historyRow.outcome)) return { glyph: '[■]', label: JOB_EDITED_LINE };
406
400
  // M4e amendment 4 item 4: a run the human stopped, or one that hit its money cap and can be continued, is `[■]` stopped — never "failed".
407
401
  if (historyRow.outcome === 'stopped') {
408
402
  return { glyph: '[■]', label: stoppedAtAsk ? `${stoppedAtAsk}${STOPPED_AT_ASK_START_RE.test(stoppedAtAsk) ? ';' : ' —'} Resume to go on` : 'stopped — after the step that was running; Resume to go on' };
409
403
  }
410
- if (historyRow.outcome === 'cap-halt' && resumable) return { glyph: '[■]', label: 'stopped — the money cap was reached; raise it and Resume' };
404
+ // M20 am9 item 2: every cap reads `[■] capped`; one that can be continued says why and what to do. One that cannot (M20 am1 item 9) is never "failed (cap-halt)"
405
+ if (historyRow.outcome === 'cap-halt' && resumable) return { glyph: '[■]', label: `${endingWord('cap-halt')} — money cap; raise it and Resume` };
406
+ if (historyRow.outcome === 'cap-halt') return { glyph: '[■]', label: endingWord('cap-halt') ?? '' };
411
407
  // M4b amendment 3: a run the human ended on purpose with rerun is not a failure.
412
408
  if (historyRow.outcome === 'rerun') return { glyph: '[✗]', label: 'stopped by you (rerun), a fresh run was started' };
413
409
  // M4c-fix amendment 1 (c): a run ended because its ask expired is `[!]` expired, never failed (it spent nothing more).
@@ -472,18 +468,15 @@ export function costDisplay(spentUsd, spendComplete) {
472
468
  }
473
469
 
474
470
  /**
475
- * A floor summed from whatever priced rows a run's own `spend.jsonl`
476
- * already recorded — used ONLY when there is no history row yet (died or
477
- * still parked) to show "at least $X" rather than nothing/zero. `null`
478
- * (never `$0`) when zero rows are priced yet.
479
- * @param {any[]} spendRows
480
- * @returns {string|null}
471
+ * A run's spend in the Runs list and the Run tab's words (four decimals even for an exact zero; the ticket grid writes a bare zero, src/panel/jobgrid.js `moneyWords`, on the guard's
472
+ * allow-list). The NUMBER is `runMoney`'s (M20 am3g item 24): the history row's total, else the priced spend rows as an "at least" floor (used ONLY when there is no history
473
+ * row yet), else null (never `$0` for unknown). A history row whose total is not a number gives null, never the rows' floor.
474
+ * @param {any} historyRow @param {any[]} spendRows @returns {string|null}
481
475
  */
482
- function spendFloorDisplay(spendRows) {
483
- const priced = spendRows.filter((r) => typeof r.costUsd === 'number' && Number.isFinite(r.costUsd));
484
- if (priced.length === 0) return null;
485
- const sum = priced.reduce((acc, r) => acc + r.costUsd, 0);
486
- return `at least $${sum.toFixed(4)}`;
476
+ function runSpendDisplay(historyRow, spendRows) {
477
+ const m = runMoney(historyRow ?? null, historyRow ? [] : spendRows);
478
+ const cd = m.usd === null ? null : costDisplay(m.usd, m.complete);
479
+ return cd !== null && cd.ok ? cd.display : null;
487
480
  }
488
481
 
489
482
  /**
@@ -540,7 +533,7 @@ export function deriveRunModel(auditRows) {
540
533
  * @returns {'model call'|'human'|'no model call'}
541
534
  */
542
535
  export function deriveAuditAction(row) {
543
- if (row && Object.prototype.hasOwnProperty.call(row, 'unjudgedCount')) return 'human';
536
+ if (isAskRow(row)) return 'human';
544
537
  if (typeof row?.model === 'string' && row.model.length > 0) return 'model call';
545
538
  return 'no model call';
546
539
  }
@@ -670,11 +663,8 @@ export function deriveAuditAtWhy(row) {
670
663
  * @param {string|null|undefined} verdict
671
664
  * @returns {boolean}
672
665
  */
673
- const BLOCKED_VERDICTS = new Set([
674
- 'not-done', 'red', 'refused', 'ask-timeout', 'ask-expired', 'cap-halt', 'provider-red', 'pricing-red', 'close-casualty',
675
- ]);
676
666
  export function isBlockedVerdict(verdict) {
677
- return typeof verdict === 'string' && BLOCKED_VERDICTS.has(verdict);
667
+ return isBlockedEnding(verdict);
678
668
  }
679
669
 
680
670
  /**
@@ -688,15 +678,12 @@ export function isBlockedVerdict(verdict) {
688
678
  * resolved either way). A `refused` (blank-reason) row is its own re-ask,
689
679
  * not a resolution, so it reads as `·` like `paused` — the try it belongs to
690
680
  * is still open.
691
- * @param {string|null|undefined} verdict
681
+ * @param {{verdict: string|null|undefined, gap?: string|null}} row
692
682
  * @param {string|null|undefined} closeClass
693
- * @returns {'✓'|'✗'|'·'}
683
+ * @returns {'✓'|'✗'|'·'|'■'}
694
684
  */
695
- function markForVerdict(verdict, closeClass) {
696
- if (closeClass === 'hitl' && verdict === 'red') return '✗'; // the human's own redo
697
- if (verdict === 'green' || verdict === 'hitl') return '✓';
698
- if (verdict === 'paused' || verdict === 'refused' || verdict === 'ask-timeout' || verdict === 'ask-expired' || verdict === 'ask-reopened' || verdict === 'lock-removed' || verdict === 'stop-asked' || verdict === 'stopped' || verdict === 'stop-not-honoured') return '·';
699
- return '✗';
685
+ function markForVerdict(row, closeClass) {
686
+ return auditSignWord(row.verdict, closeClass, row.gap, isAskRow(row)).mark;
700
687
  }
701
688
 
702
689
  /**
@@ -708,7 +695,7 @@ function markForVerdict(verdict, closeClass) {
708
695
  * open, not resolved).
709
696
  * @param {string|null} closeClass
710
697
  * @param {Array<{verdict:string}>} rows one step's own audit rows, book order
711
- * @returns {Array<'✓'|'✗'|'·'>}
698
+ * @returns {Array<'✓'|'✗'|'·'|'■'>}
712
699
  */
713
700
  export function deriveStepTryMarks(closeClass, rows) {
714
701
  if (!rows || !rows.length) return [];
@@ -719,7 +706,7 @@ export function deriveStepTryMarks(closeClass, rows) {
719
706
  // No paused row at all is not a shape this step produces in practice
720
707
  // (guarded the same way `computeTryCount` already is) — one mark per
721
708
  // row rather than hiding that a try happened.
722
- return rows.map((r) => markForVerdict(r.verdict, closeClass));
709
+ return rows.map((r) => markForVerdict(r, closeClass));
723
710
  }
724
711
  return pausedIdxs.map((idx, i) => {
725
712
  // The resolving row is the LAST row before the next `paused` boundary
@@ -732,10 +719,10 @@ export function deriveStepTryMarks(closeClass, rows) {
732
719
  const nextPausedIdx = pausedIdxs[i + 1] ?? rows.length;
733
720
  const lastIdx = nextPausedIdx - 1;
734
721
  if (lastIdx === idx) return '·'; // still paused, no resolution row yet in this run's book
735
- return markForVerdict(rows[lastIdx].verdict, closeClass);
722
+ return markForVerdict(rows[lastIdx], closeClass);
736
723
  });
737
724
  }
738
- return rows.map((r) => markForVerdict(r.verdict, closeClass));
725
+ return rows.map((r) => markForVerdict(r, closeClass));
739
726
  }
740
727
 
741
728
  /** The name of the one group for audit rows that name no step. */
@@ -755,16 +742,31 @@ function auditStepName(step) {
755
742
  * the human asked), `stopped` (the last attempt failed for any other reason). A group only
756
743
  * ever exists for a step with at least one row, so `pending` never appears
757
744
  * here (unlike the Run tab's map, which also covers never-attempted steps).
758
- * @param {Array<{verdict:string}>} rows one step's own audit rows, book order
759
- * @returns {'done'|'waiting'|'stopped'|'user-stopped'}
745
+ * @param {Array<{verdict:string, class?: string|null, gap?: string|null}>} rows one step's own audit rows, book order
746
+ * `noted` (M20 am9a: the last row has no sign from the owner and is none of the above, a human redo or a reopen; the heading wears the owner's word, `groupStateText`, never "failed").
747
+ * `capped` (M20 am9 item 2: the step's own last row is a `cap-halt`; the word is the table's, `endingWord('cap-halt')`).
748
+ * @returns {string} `done`, `waiting`, `stopped`, `user-stopped`, `noted`, or the table's word for a cap-halt
760
749
  */
761
750
  export function deriveStepGroupState(rows) {
762
- // a Stop's notes (asked / not honoured) say nothing about the step's own state; a step with only notes reads as stopped
763
- const own = rows.filter((r) => r.verdict !== 'stop-asked' && r.verdict !== 'stop-not-honoured');
764
- const last = own.length > 0 ? own[own.length - 1] : rows[rows.length - 1];
765
- if (last.verdict === 'paused' || last.verdict === 'refused') return 'waiting';
751
+ const last = lastRowOfGroup(rows);
752
+ if (isWaitingEnding(last.verdict)) return 'waiting';
766
753
  if (last.verdict === 'stopped') return 'user-stopped';
767
- return (last.verdict === 'green' || last.verdict === 'hitl') ? 'done' : 'stopped';
754
+ if (auditSignWord(last.verdict).sign === '■') return endingWord(last.verdict) ?? 'stopped';
755
+ if (isGoodEnding(last.verdict)) return 'done';
756
+ return auditSignWord(last.verdict, last.class, last.gap, isAskRow(last)).sign === null ? 'noted' : 'stopped';
757
+ }
758
+
759
+ /** a Stop's notes (asked / not honoured) say nothing about the step's own state; a step with only notes reads as its last row @param {Array<{verdict:string, class?: string|null, gap?: string|null}>} rows */
760
+ function lastRowOfGroup(rows) {
761
+ const own = rows.filter((r) => !isStopNote(r.verdict));
762
+ return own.length > 0 ? own[own.length - 1] : rows[rows.length - 1];
763
+ }
764
+
765
+ /** M20 am9a: the heading's own word for a `noted` group: the owner's word for its last row (`redo by you: <gap>`, `reopened by you`); `null` for any other state @param {Array<{verdict:string, class?: string|null, gap?: string|null}>} rows */
766
+ export function groupStateText(rows) {
767
+ if (deriveStepGroupState(rows) !== 'noted') return null;
768
+ const last = lastRowOfGroup(rows);
769
+ return auditSignWord(last.verdict, last.class, last.gap, isAskRow(last)).word;
768
770
  }
769
771
 
770
772
  /**
@@ -836,6 +838,7 @@ export function deriveAuditGroups(enrichedRows) {
836
838
  return {
837
839
  step,
838
840
  state: deriveStepGroupState(rows),
841
+ stateText: groupStateText(rows),
839
842
  closeClass,
840
843
  timeMs,
841
844
  cost,
@@ -923,14 +926,17 @@ const JOB_EDITED_LINE = 'stopped — the job was edited; start a new run';
923
926
  * @param {any} catalogue
924
927
  * @param {any} [attempt] the panel's in-memory resume-attempt record for this run, or null
925
928
  * @param {(flow: string, runId: string) => boolean} [startingRun] the starter's "this run's start is in phase `starting`" (absent = no)
929
+ * @param {{history?: {rows: any[]|null}, jobOnlyIfResumable?: boolean}} [opts] M20 am9f: `history` = a box shared by the runs of one flow in one call, filled by the first run that reads the flow's history (read once per flow per call); `jobOnlyIfResumable` = read and signature-check the run's job only when its ending can be resumed (only that ending compares the job; the Inbox needs nothing else of it)
926
930
  * @returns {any}
927
931
  */
928
- function loadRunContext(root, flowDir, runDir, flowName, runId, catalogue, attempt = null, startingRun = undefined) {
929
- const { read: flowRead, ownCopy } = readRunJob({ root, name: flowName, catalogue, runDir });
932
+ function loadRunContext(root, flowDir, runDir, flowName, runId, catalogue, attempt = null, startingRun = undefined, opts = {}) {
933
+ let historyRows = opts.history?.rows ?? null;
934
+ if (historyRows === null) { historyRows = readHistory(flowDir); if (opts.history) opts.history.rows = historyRows; }
935
+ const historyRow = endRow(historyRows, runDir, runId);
936
+ const noJob = opts.jobOnlyIfResumable === true && !(historyRow !== null && isResumableEnding(historyRow.outcome));
937
+ const { read: flowRead, ownCopy } = /** @type {{read: any, ownCopy: boolean}} */ (noJob ? { read: { ok: false, reds: ['not read: this run cannot be resumed'] }, ownCopy: false } : readRunJob({ root, name: flowName, catalogue, runDir }));
930
938
  // M4e amendment 5 item 3 / amendment 4 item 6: the run's own signed values (its newest version) lie over the flow's
931
939
  const inForce = flowRead.ok ? applyRunValues(flowRead.arbiter, flowName, flowRead.signature.flow, pickRunValues(runDir)) : null;
932
- const historyRows = readHistory(flowDir);
933
- const historyRow = endRow(historyRows, runDir, runId);
934
940
  const halt = readHaltRecord(runDir);
935
941
  const auditRows = readAudit(runDir);
936
942
  const spendRows = readSpendRows(join(runDir, 'spend.jsonl'));
@@ -939,7 +945,7 @@ function loadRunContext(root, flowDir, runDir, flowName, runId, catalogue, attem
939
945
  const stateJson = readRunState(runDir);
940
946
  const consumedAnswerExists = hasConsumedAnswer(runDir, askJson && typeof askJson.askId === 'string' ? askJson.askId : null);
941
947
  // A finished run has no resume to report (its history row says how it ended).
942
- const savedAnswer = historyRow ? null : readSavedAnswer(runDir);
948
+ const savedAnswer = historyRow ? null : savedAnswerOf(runDir);
943
949
  const resume = historyRow ? null : deriveResumeState({ savedAnswer, attempt, ask: askJson });
944
950
  const stuckInputs = historyRow ? { liveness: 'unknown', lock: 'none' } : readStuckInputs(runDir);
945
951
 
@@ -975,6 +981,8 @@ function loadRunContext(root, flowDir, runDir, flowName, runId, catalogue, attem
975
981
  liveness: stuckInputs.liveness,
976
982
  lock: stuckInputs.lock,
977
983
  booksFresh: historyRow ? false : booksFresh(runDir),
984
+ // M20 am1 item 8: the newest `try-start` diary row of a run with no end row (the NOW row reads it), else null
985
+ tryStart: historyRow ? null : (readTryStarts(runDir).at(-1) ?? null),
978
986
  // M4c exit walk: when the process that is working on the run started (its newest pid row's
979
987
  // own `startedAt`), so a `[▶]` run has a real time and never "parked or died". Not a book change.
980
988
  startedAt: historyRow ? null : lastPidStartedAt(runDir),
@@ -1016,7 +1024,7 @@ function lastStoppedAtAsk(runDir, auditRows, hasHistoryRow) {
1016
1024
  const stopped = auditRows.filter((r) => r.verdict === 'stopped' && typeof r.gap === 'string' && !Number.isInteger(r.attempt));
1017
1025
  const last = stopped.length > 0 ? stopped[stopped.length - 1] : null;
1018
1026
  if (!last || !STOPPED_AT_ASK_RE.test(last.gap)) return null;
1019
- const ordered = runAsksInOrder(runDir, hasHistoryRow);
1027
+ const ordered = runAsksInOrder(runDir, hasHistoryRow, auditRows);
1020
1028
  const stepOf = deriveAskStepInfo(ordered, auditRows, null);
1021
1029
  const words = stoppedAskWords(ordered, auditRows);
1022
1030
  const i = stepOf.findIndex((x) => x.step !== null && x.step === last.step);
@@ -1036,13 +1044,6 @@ function firstPidStartedAt(runDir) {
1036
1044
  return null;
1037
1045
  }
1038
1046
 
1039
- /** The run's own `trigger.json` (why it started), or null for a hand run. @param {string} runDir */
1040
- function readTriggerRecord(runDir) {
1041
- const f = readFileInside(runDir, 'trigger.json');
1042
- if (!f.ok) return null;
1043
- try { const j = JSON.parse(f.text); return j && typeof j === 'object' ? j : null; } catch { return null; }
1044
- }
1045
-
1046
1047
  /** The ONE running rule for wording is the glyph's own (`computeGlyph` -> `[▶]`, which already
1047
1048
  * folds in `runLiveness`): a run with no end row whose glyph is `[▶]` is running. */
1048
1049
  const RUNNING_WHY = 'still running — not finished yet';
@@ -1062,7 +1063,7 @@ export function runControls(ctx, glyph, label = '') {
1062
1063
  const running = isRunningNow(ctx, glyph) && (!ctx.askJson || ctx.consumedAnswerExists || ctx.resume?.state === 'not-started');
1063
1064
  // M4e amendment 13: a run waiting at its ask (open, unanswered, not expired) shows Stop too; it stops the run at the ask.
1064
1065
  const atAsk = !ctx.historyRow && !!ctx.askJson && glyph === '[·]' && label === WAITING_LABEL;
1065
- const starting = !ctx.historyRow && !ctx.askJson && readPidRows(ctx.runDir).length === 0;
1066
+ const starting = !ctx.historyRow && !ctx.askJson && !processStarted(ctx.runDir);
1066
1067
  const canResume = ctx.resumable === true && ctx.sameJob === true;
1067
1068
  return {
1068
1069
  canStop: running || atAsk,
@@ -1154,17 +1155,11 @@ export function listRuns({ root, catalogue, resumeAttempt, startingRun, now = Da
1154
1155
  const controls = runControls(ctx, glyph, label);
1155
1156
  // M4c amendment 1 (c): the ask waiting on the human, by the same rule
1156
1157
  // listStops uses (deriveAskOpenFields) — the least time left if several.
1157
- const waitingAsk = runAsksInOrder(run.runDir, !!ctx.historyRow)
1158
+ const waitingAsk = runAsksInOrder(run.runDir, !!ctx.historyRow, ctx.auditRows)
1158
1159
  .map((ask) => ({ ask, ...deriveAskOpenFields(ask, !!ctx.historyRow, ctx.resume) }))
1159
1160
  .filter((r) => r.waiting)
1160
1161
  .reduce((best, r) => (best === null || (r.timeLeftMs ?? Infinity) < (best.timeLeftMs ?? Infinity) ? r : best), /** @type {any} */ (null));
1161
- let spend;
1162
- if (ctx.historyRow) {
1163
- const cd = costDisplay(ctx.historyRow.spentUsd, ctx.historyRow.spendComplete);
1164
- spend = cd.ok ? cd.display : null;
1165
- } else {
1166
- spend = spendFloorDisplay(ctx.spendRows);
1167
- }
1162
+ const spend = runSpendDisplay(ctx.historyRow, ctx.spendRows);
1168
1163
  // browser re-walk bug #4: a parked run's ask.json holds a real,
1169
1164
  // book-held timestamp (`askedAt`) — a run with an open ask is never
1170
1165
  // "unknown", even with no history row yet. `atWhy`'s generic "no
@@ -1179,7 +1174,7 @@ export function listRuns({ root, catalogue, resumeAttempt, startingRun, now = Da
1179
1174
  runId,
1180
1175
  glyph,
1181
1176
  label,
1182
- ...signParts(glyph, label, ctx.historyRow?.outcome === 'rerun'),
1177
+ ...signParts(glyph, label, ctx.historyRow?.outcome === 'rerun', ctx.historyRow ? { outcome: ctx.historyRow.outcome } : null),
1183
1178
  pulse: glyphPulses({ glyph, label }),
1184
1179
  stuck: glyph === '[II]',
1185
1180
  controls,
@@ -1324,8 +1319,8 @@ export function needsYouOf({
1324
1319
  */
1325
1320
  function runReopenOffer(runDir, ctx) {
1326
1321
  if (ctx.historyRow || !ctx.askJson) return null;
1327
- const savedAskId = readSavedAnswer(runDir)?.askId;
1328
- for (const a of runAsksInOrder(runDir, false)) {
1322
+ const savedAskId = savedAnswerOf(runDir)?.askId;
1323
+ for (const a of runAsksInOrder(runDir, false, ctx.auditRows)) {
1329
1324
  const offer = reopenOffer(a, ctx.askJson, ctx.resume, savedAskId === a.askId);
1330
1325
  if (offer !== null) return { askId: a.askId, ...offer };
1331
1326
  }
@@ -1435,9 +1430,16 @@ function enrichAuditRows(rawRows) {
1435
1430
  thinkingPhrase: thinkingTryWords(row.thinking), // M4d am26: null for a row that kept no thinking record
1436
1431
  atWhy: deriveAuditAtWhy(row),
1437
1432
  blocked: isBlockedVerdict(row.verdict),
1433
+ ...signWordOf(row),
1438
1434
  }));
1439
1435
  }
1440
1436
 
1437
+ /** M20 am9 item 1: the sign and the word the page shows for a row (`sign` null = none), from the one table (src/books.js `auditSignWord`); the page derives neither. @param {{verdict: unknown, class?: string|null, gap?: string|null}} row */
1438
+ function signWordOf(row) {
1439
+ const { sign, word } = auditSignWord(row.verdict, row.class, row.gap, isAskRow(row));
1440
+ return { sign, word };
1441
+ }
1442
+
1441
1443
  /**
1442
1444
  * "try N" (map node / step-card badge) counts different things for
1443
1445
  * different close classes, and must never just be `attempts.length` (browser
@@ -1485,11 +1487,11 @@ function waitingLineOf(ctx) {
1485
1487
  */
1486
1488
  function jobWaitingLine(root, flowDir, flow, catalogue) {
1487
1489
  const ids = listRunIds(flowDir).sort((a, b) => compareNatural(b, a));
1488
- const history = readHistory(flowDir); // `atAsk` needs no end row (`runControls`), so an ended run is skipped by the same `endRow` rule before a context is built for it
1489
1490
  for (const id of ids) {
1490
1491
  const run = resolveRunDir(flowDir, id);
1491
- if (!run.ok || endRow(history, run.runDir, id) !== null || !readAsk(run.runDir)) continue; // eslint-disable-line no-continue
1492
+ if (!run.ok || !readAsk(run.runDir)) continue; // eslint-disable-line no-continue
1492
1493
  const ctx = loadRunContext(root, flowDir, run.runDir, flow, id, catalogue, null);
1494
+ if (ctx.historyRow !== null) continue; // `atAsk` needs no end row (`runControls`): an ended run is skipped by the same `endRow` rule
1493
1495
  const g = computeGlyph(ctx);
1494
1496
  if (runControls(ctx, g.glyph, g.label).atAsk) return waitingLineOf(ctx);
1495
1497
  }
@@ -1511,7 +1513,7 @@ function scheduleBlockOf({ root, flowDir, flow, catalogue, t, home, now }) {
1511
1513
  trigger: t && t.trigger ? t.trigger : null, home,
1512
1514
  last: lastStart ? { at: lastStart.at, runId: lastStart.runId, outcome: lastGlyph ? (SIGN_WORDS[lastGlyph.glyph] ?? 'ended') : 'ended', catchUp: !!(lastRec && lastRec.catchUp === true) } : null,
1513
1515
  nextSlotMs: t ? t.nextSlotMs : null, armed: !!(t && t.armed), waiting: !!(t && t.waiting), lookProblem: t ? t.lookProblem ?? null : null, nowMs: now(),
1514
- problem: latest && latest.outcome !== 'started' && ['busy', 'monthly-exhausted', 'refused'].includes(latest.outcome) ? latest : null,
1516
+ problem: startedNothing(latest) ? latest : null,
1515
1517
  });
1516
1518
  }
1517
1519
 
@@ -1530,11 +1532,25 @@ function jobHasRunningRun({ root, flow, catalogue, resumeAttempt, startingRun })
1530
1532
  return false;
1531
1533
  }
1532
1534
 
1535
+ // borrowed-from: bareloop src/panel/server.js@v0.63.0 (7bc2719b): nowOf (the NOW row's words and its 30 s steps); fwd reads its own report-only `try-start` diary row, and the try ends at the first audit row written at or after it (an equal time counts as ended)
1536
+ /**
1537
+ * M20 am1 item 8: the Run tab's NOW row, "AI working · M:SS", only while the run is live (`[▶]`, no end row) and a model step's try is running: the newest
1538
+ * `try-start` row has no audit row written at or after it. Anything else is null (nothing is made up between tries). The time moves in 30 s steps (`stepped`).
1539
+ * @param {any} ctx `loadRunContext`'s result @param {string} glyph `computeGlyph`'s sign @param {number} nowMs @returns {string|null}
1540
+ */
1541
+ export function nowOf(ctx, glyph, nowMs) {
1542
+ if (!isRunningNow(ctx, glyph) || !ctx.tryStart) return null;
1543
+ const from = Date.parse(ctx.tryStart.at);
1544
+ if (!Number.isFinite(from)) return null;
1545
+ if (ctx.auditRows.some((r) => typeof r.at === 'string' && r.at >= ctx.tryStart.at)) return null;
1546
+ return `AI working \u00B7 ${mmss(stepped(nowMs - from))}`;
1547
+ }
1548
+
1533
1549
  /**
1534
1550
  * M9 piece 6 (ladder M9 item 7): the summary block at the top of a run page, as data. Words come from `src/summary-words.js` only, built
1535
1551
  * from typed facts (the history row's outcome, the declared step's line, the signed trigger and its ledger). `ended` is null while the run
1536
1552
  * is live; `scheduled` is null when the job has no trigger; `canSchedule` (am3 item 1) is the trigger door's own `hasGreenRun` answer; `catchUp` is a fixed sentence when this run was started late (am2 item 1).
1537
- * @returns {{ended: {reason: string, next: string}|null, scheduled: {text: string, next: string, nextRed: boolean}|null, schedule: {line1: string, line2: string|null, red: boolean}, canSchedule: boolean, catchUp: string|null}}
1553
+ * @returns {{ended: {reason: string, next: string}|null, scheduled: {text: string, next: string, nextRed: boolean}|null, schedule: {line1: string, line2: string|null, red: boolean}, canSchedule: boolean, catchUp: string|null, now: string|null}}
1538
1554
  */
1539
1555
  function runSummary(ctx, glyph, { root, catalogue, triggerRead, now, home }) {
1540
1556
  const died = !ctx.historyRow && glyph === '[?]';
@@ -1561,12 +1577,10 @@ function runSummary(ctx, glyph, { root, catalogue, triggerRead, now, home }) {
1561
1577
  });
1562
1578
  scheduled = { text: String(scheduledWords(t.trigger, home)), next: nx.text, nextRed: nx.red };
1563
1579
  }
1564
- let rec = null;
1565
- const f = readFileInside(ctx.runDir, 'trigger.json');
1566
- if (f.ok) { try { rec = JSON.parse(f.text); } catch { rec = null; } }
1580
+ const rec = readTriggerRecord(ctx.runDir);
1567
1581
  // M9 am7 items 3-4: the SCHEDULE block replaces the SCHEDULED / NEXT rows. Words: src/summary-words.js, the same owner as the Job tab's Schedule field.
1568
1582
  const schedule = scheduleBlockOf({ root, flowDir: ctx.flowDir, flow: ctx.flowName, catalogue, t, home, now });
1569
- return { ended, scheduled, schedule, canSchedule: !!(t && t.hasGreenRun), catchUp: catchUpWords(rec) };
1583
+ return { ended, scheduled, schedule, canSchedule: !!(t && t.hasGreenRun), catchUp: catchUpWords(rec), now: nowOf(ctx, glyph, now()) };
1570
1584
  }
1571
1585
 
1572
1586
  /**
@@ -1685,6 +1699,7 @@ export function getRunDetail({
1685
1699
  newLine: cardLine(group?.fold ?? null),
1686
1700
  lastAnswerAt: group?.fold?.lastAnswer?.at ?? null,
1687
1701
  groupState: group ? group.state : null,
1702
+ groupText: group ? group.stateText : null,
1688
1703
  timeMs: group ? group.timeMs : null,
1689
1704
  cost: group ? group.cost : null,
1690
1705
  costWhy: group ? group.costWhy : null,
@@ -1695,7 +1710,7 @@ export function getRunDetail({
1695
1710
  tryMarks: group ? group.tryMarks : [],
1696
1711
  // Filled below, ONLY on the one step that actually stopped this
1697
1712
  // run (never guessed onto every step) — see stoppedStepEmits.
1698
- stoppedReason: null,
1713
+ stoppedReason: /** @type {string|null} */ (null),
1699
1714
  };
1700
1715
  });
1701
1716
  }
@@ -1731,6 +1746,7 @@ export function getRunDetail({
1731
1746
  // (`askJson` present, no consumed answer — the same test `computeGlyph`
1732
1747
  // uses for "waiting on you") reports the ask's own question as its whole
1733
1748
  // "why", never an unrelated earlier attempt's gap.
1749
+ /** @type {string|null} */
1734
1750
  let stopReason = null;
1735
1751
  let stopReasonWhy = null;
1736
1752
  if (ctx.historyRow && ctx.historyRow.outcome === 'complete') {
@@ -1747,18 +1763,11 @@ export function getRunDetail({
1747
1763
  stopReasonWhy = ctx.resume.reason ? `${ctx.resume.label}: ${ctx.resume.reason}` : ctx.resume.label;
1748
1764
  } else if (!ctx.historyRow && ctx.askJson && !ctx.consumedAnswerExists) {
1749
1765
  stopReasonWhy = `waiting on you: ${typeof ctx.askJson.question === 'string' && ctx.askJson.question.length > 0 ? ctx.askJson.question : 'no question recorded'}`;
1750
- } else if (ctx.logJson && typeof ctx.logJson.red === 'string' && ctx.logJson.red.length > 0) {
1751
- stopReason = ctx.logJson.red;
1752
1766
  } else {
1753
- // The LAST matching row, not the first — a step can fail, then redo and
1754
- // fail again differently (or fail on a later step entirely); the most
1755
- // recent stop is the one that actually describes where the run sits now.
1756
- let redRow = null;
1757
- for (const r of ctx.auditRows) {
1758
- if (r.verdict === 'not-done' || r.verdict === 'red') redRow = r;
1759
- }
1760
- if (redRow) {
1761
- stopReason = `${redRow.step}: ${redRow.gap}`;
1767
+ // the log's red, else the LAST red audit row (`redWhyOf`, the one rule the Result tab asks too)
1768
+ const why = redWhyOf(ctx.logJson, ctx.auditRows);
1769
+ if (why !== null) {
1770
+ stopReason = why;
1762
1771
  } else {
1763
1772
  stopReasonWhy = 'run has not stopped on a red/not-done step (still parked, waiting, or clean so far)';
1764
1773
  }
@@ -1796,13 +1805,7 @@ export function getRunDetail({
1796
1805
  : (ctx.historyRow ? 'history row has no wallMs recorded'
1797
1806
  : isRunningNow(ctx, glyph) ? RUNNING_WHY : 'no history row yet (parked or died before completion)');
1798
1807
 
1799
- let spend;
1800
- if (ctx.historyRow) {
1801
- const cd = costDisplay(ctx.historyRow.spentUsd, ctx.historyRow.spendComplete);
1802
- spend = cd.ok ? cd.display : null;
1803
- } else {
1804
- spend = spendFloorDisplay(ctx.spendRows);
1805
- }
1808
+ const spend = runSpendDisplay(ctx.historyRow, ctx.spendRows);
1806
1809
 
1807
1810
  // hamr's review #1 (Summary tab): model + spend.jsonl totals — read here
1808
1811
  // ONCE, off the same auditRows/spendRows this function already loaded, so
@@ -1818,7 +1821,7 @@ export function getRunDetail({
1818
1821
  runId,
1819
1822
  glyph,
1820
1823
  label,
1821
- ...signParts(glyph, label, ctx.historyRow?.outcome === 'rerun'),
1824
+ ...signParts(glyph, label, ctx.historyRow?.outcome === 'rerun', ctx.historyRow ? { outcome: ctx.historyRow.outcome } : null),
1822
1825
  signWords: SIGN_WORDS,
1823
1826
  pulse: glyphPulses({ glyph, label }),
1824
1827
  controls: runControls(ctx, glyph, label),
@@ -1919,7 +1922,7 @@ export function getDraftBlock(flowDir, runDir) {
1919
1922
  attempt, step: 'drafting', class: 'hitl', verdict: 'hitl', at: r.at ?? null, setup: true, blocked: false, action: 'human', tokensDisplay: { kind: 'no-model' }, ...extra,
1920
1923
  });
1921
1924
  const model = (r, attempt, label) => ({
1922
- attempt, step: 'drafting', class: null, verdict: r.verdict === 'green' ? 'green' : (r.verdict === 'red' ? 'red' : 'not-done'), gap: r.gap ?? '', at: r.at ?? null, setup: true, blocked: false,
1925
+ attempt, step: 'drafting', class: null, verdict: isDraftRowVerdict(r.verdict) ? r.verdict : 'not-done', gap: r.gap ?? '', at: r.at ?? null, setup: true, blocked: false,
1923
1926
  action: `${label} · ${r.model ?? 'model not recorded'}${r.hash ? ` · plan ${String(r.hash).slice(0, 8)}` : ''}`,
1924
1927
  usd: typeof r.costUsd === 'number' ? r.costUsd : undefined, spendComplete: r.spendComplete === true, tokensDisplay: { kind: 'no-model' },
1925
1928
  ...(typeof r.wallMs === 'number' ? { wallMs: r.wallMs } : {}),
@@ -1971,28 +1974,20 @@ export function getDraftBlock(flowDir, runDir) {
1971
1974
  else if (r.kind === 'sign') rows.push(human(r, n, { action: `sign (${r.signedBy ?? 'you'})`, gap: `plan ${String(r.hash ?? '').slice(0, 12)}` }));
1972
1975
  });
1973
1976
  }
1974
- const versions = [];
1975
- for (const f of readdirInside(runDir, '.')) {
1976
- const m = VALUES_FILE_RE.exec(f);
1977
- if (m !== null) versions.push({ file: f, version: m[1] === undefined ? 0 : Number(m[1]) });
1978
- }
1979
- versions.sort((a, b) => a.version - b.version);
1980
- for (const { file, version } of versions) {
1981
- const t = readFileInside(runDir, file);
1982
- let rec = null;
1983
- try { rec = t.ok ? JSON.parse(t.text) : null; } catch { rec = null; }
1984
- const v = rec && typeof rec === 'object' ? rec.values : null;
1985
- const waits = v && typeof v === 'object' && v.askWaits && typeof v.askWaits === 'object'
1986
- ? Object.entries(v.askWaits).map(([line, wait]) => ({ line, wait: String(wait), waitMs: parseWaitMs(wait) })) : [];
1987
- const head = v && typeof v === 'object' ? [`cap $${v.capUsd}`, v.destination ? `destination ${v.destination}` : null].filter(Boolean) : [];
1988
- const gap = v && typeof v === 'object'
1989
- ? [...head, waits.length ? `ask waits ${waits.map((w) => `line ${w.line}: ${w.wait}`).join(', ')}` : null].filter(Boolean).join(' · ')
1990
- : `${file} could not be read`;
1991
- happened.push(`${version === 0 ? 'signed to run' : 'signed to resume'} (${rec?.signedBy ?? 'you'})`);
1992
- rows.push(human({ at: rec?.at }, rows.length + 1, { action: `${version === 0 ? 'Sign & run' : 'Sign & resume'} (${rec?.signedBy ?? 'you'})`, gap, ...(waits.length ? { gapHead: head, gapWaits: waits } : {}) }));
1977
+ const versions = listRunValues(runDir);
1978
+ for (const e of versions) {
1979
+ // M20 am3 item 6: the run's own parser read this file; a version it refuses shows as that refusal, never as a signed row
1980
+ if (!e.ok) { rows.push(human({ at: undefined }, rows.length + 1, { action: e.red, gap: '' })); continue; } // eslint-disable-line no-continue -- a refused version is not a signed one
1981
+ const { version, record: rec } = e;
1982
+ const v = rec.values;
1983
+ const waits = Object.entries(v.askWaits).map(([line, wait]) => ({ line, wait: String(wait), waitMs: parseWaitMs(wait) }));
1984
+ const head = [`cap $${v.capUsd}`, v.destination ? `destination ${v.destination}` : null].filter(Boolean);
1985
+ const gap = [...head, waits.length ? `ask waits ${waits.map((w) => `line ${w.line}: ${w.wait}`).join(', ')}` : null].filter(Boolean).join(' · ');
1986
+ happened.push(`${version === 0 ? 'signed to run' : 'signed to resume'} (${rec.signedBy ?? 'you'})`);
1987
+ rows.push(human({ at: rec.at }, rows.length + 1, { action: `${version === 0 ? 'Sign & run' : 'Sign & resume'} (${rec.signedBy ?? 'you'})`, gap, ...(waits.length ? { gapHead: head, gapWaits: waits } : {}) }));
1993
1988
  }
1994
1989
  const lastSign = setup.present ? [...setup.rows].reverse().find((r) => r.kind === 'sign') : undefined;
1995
- const humanChecks = setup.present ? setup.rows.filter((r) => r.kind === 'note' || r.kind === 'sign' || r.kind === 'revise' || r.kind === 'redraft').length + versions.length : null;
1990
+ const humanChecks = setup.present ? setup.rows.filter((r) => r.kind === 'note' || r.kind === 'sign' || r.kind === 'revise' || r.kind === 'redraft').length + versions.filter((e) => e.ok).length : null;
1996
1991
  const totals = setup.present
1997
1992
  ? draftTotals(setup.rows.filter((r) => r.kind === 'draft' || r.kind === 'change' || r.kind === 'revise' || r.kind === 'redraft' || r.kind === 'startover'), { cardAt: setup.rows.find((r) => r.kind === 'card')?.at, signAt: lastSign?.at, humanChecks })
1998
1993
  : null;
@@ -2001,7 +1996,7 @@ export function getDraftBlock(flowDir, runDir) {
2001
1996
  const ended = setup.present && setup.rows.some((r) => r.kind === 'sign') ? 'done' : 'not signed';
2002
1997
  const summary = setup.present && totals ? { present: true, ...totals, ended, happened } : { present: false, why: NO_DRAFT_WORDS };
2003
1998
  return {
2004
- present: setup.present, why: setup.present ? null : NO_DRAFT_WORDS, rows, summary,
1999
+ present: setup.present, why: setup.present ? null : NO_DRAFT_WORDS, rows: rows.map((r) => ({ ...r, ...signWordOf(r) })), summary,
2005
2000
  };
2006
2001
  }
2007
2002
 
@@ -2018,9 +2013,8 @@ function attachFolds(groups, runDir, flowDir, { root, flow, catalogue }) {
2018
2013
  if (job.ok) steps = job.declaration.steps ?? [];
2019
2014
  }
2020
2015
  // M14 am1 item 1: a rerun's own run.json holds the reason it started with; the Audit shows it on the first step, where that reason was handed
2021
- const rec = readRunRecord(runDir);
2022
- const rr = rec.ok ? rec.rec.rerun : null;
2023
- let rerun = rr && typeof rr === 'object' && rr.decision === 'rerun' && typeof rr.words === 'string' ? { words: rr.words } : null;
2016
+ const rerunWords = readRerunWords(runDir);
2017
+ let rerun = rerunWords !== null ? { words: rerunWords } : null;
2024
2018
  for (const g of groups) {
2025
2019
  if (g.run) continue;
2026
2020
  const decl = steps?.find((x) => x.emits === g.step);
@@ -2046,7 +2040,7 @@ export function getRunAudit({
2046
2040
  const run = resolveRunPath(root, flow, runId);
2047
2041
  if (!run.ok) return null;
2048
2042
  if (!existsSync(run.runDir)) return null;
2049
- const rawRows = readAudit(run.runDir);
2043
+ const rawRows = loadRunContext(root, run.flowDir, run.runDir, flow, runId, catalogue, null).auditRows;
2050
2044
  // hamr's review #6: the Audit tab's "Action" column is derived server-side
2051
2045
  // (never guessed client-side from partial data) — `action` is added to
2052
2046
  // each row here, off that SAME row's own fields, book order preserved.
@@ -2213,7 +2207,7 @@ export function getRunJob({
2213
2207
  // per-attempt `audit.jsonl` field the Run tab's summary uses
2214
2208
  // (`deriveRunModel`) and says so plainly when it does, rather than
2215
2209
  // pretending the signed prose named it.
2216
- const auditRows = readAudit(run.runDir);
2210
+ const auditRows = loadRunContext(root, run.flowDir, run.runDir, flow, runId, catalogue, null).auditRows;
2217
2211
  const model = deriveRunModel(auditRows);
2218
2212
  // the run's own signed values (cap, send folder, ask waits) when it has them; the flow's own otherwise
2219
2213
  const applied = applyRunValues(flowRead.arbiter, flow, sig.flow, pickRunValues(run.runDir));
@@ -2464,14 +2458,12 @@ function isOpenStatus(status) {
2464
2458
  function deriveAskOpenFields(ask, hasHistoryRow, resume = null) {
2465
2459
  // M4c amendment 3: an ask past its deadline reads `expired`, but one whose answer was saved in time
2466
2460
  // (`resume` is null for a late/unreadable one, `deriveResumeState`) is still open: it can be carried on.
2467
- const answerSaved = resume != null && resume.askId === ask.askId
2468
- && (resume.state === 'starting' || resume.state === 'not-started');
2461
+ const answerSaved = answerPickedUp(resume, ask.askId);
2469
2462
  const open = (isOpenStatus(ask.status) || (ask.status === 'expired' && answerSaved)) && !hasHistoryRow;
2470
2463
  // M4b fix: the ONE decision "is this ask waiting on the human". An open ask
2471
2464
  // whose answer is already saved (`resume` = `deriveResumeState` for THIS
2472
2465
  // ask, the run's own label) is open but not waiting: the human answered.
2473
- const answered = open && resume != null && resume.askId === ask.askId
2474
- && (resume.state === 'starting' || resume.state === 'not-started');
2466
+ const answered = open && answerPickedUp(resume, ask.askId);
2475
2467
  const waiting = open && !answered;
2476
2468
  const expiresMs = waiting && typeof ask.expiresAt === 'string' ? Date.parse(ask.expiresAt) : NaN;
2477
2469
  return {
@@ -2493,7 +2485,7 @@ function deriveAskOpenFields(ask, hasHistoryRow, resume = null) {
2493
2485
  */
2494
2486
  function reopenOffer(ask, openAskJson, resume, lateAnswerSaved = false) {
2495
2487
  if (!openAskJson || openAskJson.askId !== ask.askId || ask.status !== 'expired') return null;
2496
- if (resume && resume.askId === ask.askId && (resume.state === 'starting' || resume.state === 'not-started')) return null;
2488
+ if (answerPickedUp(resume, ask.askId)) return null;
2497
2489
  // `late`: an answer was saved but came after the deadline (the page says so, instead of "nobody answered");
2498
2490
  // `why` is that line, the one the Ask tab and the Inbox row both draw.
2499
2491
  return Number.isFinite(openAskJson.waitMs)
@@ -2545,13 +2537,6 @@ function normalizeArchivedRow(a) {
2545
2537
  };
2546
2538
  }
2547
2539
 
2548
- /** `^answer\.<askId>\.consumed\.json$` — deliberately excludes
2549
- * `answer.stale.<n>.json` (no capture group would match "stale" as a real
2550
- * askId; the stale-quarantine writer in `src/ask.js` uses that different
2551
- * name specifically so this convention-based scan never mistakes a
2552
- * quarantined stale answer for a real consumed one). */
2553
- const CONSUMED_ANSWER_RE = /^answer\.(.+)\.consumed\.json$/;
2554
-
2555
2540
  /** The line under an ask that ended expired though an answer was saved: the answer came too late. */
2556
2541
  const LATE_ANSWER_WHY = 'Your answer came after the deadline.';
2557
2542
  /** The line under an expired ask nobody answered. */
@@ -2588,12 +2573,10 @@ function legacyRunAsks(runDir, hasHistoryRow) {
2588
2573
  const askJson = readAsk(runDir);
2589
2574
  const currentAskId = askJson && typeof askJson.askId === 'string' ? askJson.askId : null;
2590
2575
 
2591
- const consumedFiles = names.filter((n) => CONSUMED_ANSWER_RE.test(n)).sort();
2576
+ const consumedFiles = names.filter((n) => askIdOfConsumedName(n) !== null).sort();
2592
2577
 
2593
2578
  for (const file of consumedFiles) {
2594
- const match = CONSUMED_ANSWER_RE.exec(file);
2595
- if (!match) continue; // eslint-disable-line no-continue -- filtered by the same regex above; never actually null
2596
- const askId = match[1];
2579
+ const askId = /** @type {string} */ (askIdOfConsumedName(file));
2597
2580
  const fileRead = readFileInside(runDir, file);
2598
2581
  if (!fileRead.ok) {
2599
2582
  continue; // eslint-disable-line no-continue -- missing/symlink-refused, same as a torn write: skipped, never invented
@@ -2631,7 +2614,7 @@ function legacyRunAsks(runDir, hasHistoryRow) {
2631
2614
  // "still open" stop at that point, no matter what its own askId says.
2632
2615
  if (askJson && !hasHistoryRow) {
2633
2616
  const hasConsumed = currentAskId !== null
2634
- && consumedFiles.includes(`answer.${currentAskId}.consumed.json`);
2617
+ && consumedFiles.includes(consumedAnswerName(currentAskId));
2635
2618
  if (!hasConsumed) {
2636
2619
  if (currentAskId === null) {
2637
2620
  // A genuine pre-M3 ask.json: no askId/expiresAt at all — cannot be
@@ -2685,7 +2668,7 @@ function legacyRunAsks(runDir, hasHistoryRow) {
2685
2668
  * (hamr's 2026-09-27 live check).
2686
2669
  * @returns {any[]}
2687
2670
  */
2688
- function runAsksInOrder(runDir, hasHistoryRow, endedExpired = false, jobEdited = false) {
2671
+ function runAsksInOrder(runDir, hasHistoryRow, auditRows, endedExpired = false, jobEdited = false) {
2689
2672
  const archivedResult = listArchivedAsks(runDir);
2690
2673
  const rows = archivedResult.archived
2691
2674
  ? archivedResult.asks.map(normalizeArchivedRow)
@@ -2708,7 +2691,7 @@ function runAsksInOrder(runDir, hasHistoryRow, endedExpired = false, jobEdited =
2708
2691
  // reader of which step each ask belongs to) names for it, matched to the `stopped at the ask of step N` row written for that step.
2709
2692
  // Never by counting those rows in order: a Stop that landed before any ask parked writes one too, with no ask behind it.
2710
2693
  if (ordered.some((a) => a.status === 'stopped')) {
2711
- const words = stoppedAskWords(ordered, readAudit(runDir));
2694
+ const words = stoppedAskWords(ordered, auditRows);
2712
2695
  for (let i = 0; i < ordered.length; i++) {
2713
2696
  if (ordered[i].status === 'stopped' && words[i] !== null) ordered[i] = { ...ordered[i], statusText: words[i] };
2714
2697
  }
@@ -2860,21 +2843,20 @@ export function getRunAsks({
2860
2843
  const run = resolveRunPath(root, flow, runId);
2861
2844
  if (!run.ok) return null;
2862
2845
  if (!existsSync(run.runDir)) return null;
2863
- const histRow = endRow(readHistory(run.flowDir), run.runDir, runId) ?? undefined;
2846
+ const ctx = loadRunContext(root, run.flowDir, run.runDir, flow, runId, catalogue, null);
2847
+ const histRow = ctx.historyRow ?? undefined;
2864
2848
  const hasHistoryRow = !!histRow;
2865
2849
  // hamr's 2026-09-27 browser-walk bug #4: the Ask tab's own asks must carry
2866
2850
  // the SAME `open`/`timeLeftMs` fields listStops already computes for the
2867
2851
  // Inbox — otherwise an open ask's Ask-tab header/body falls back to the
2868
2852
  // raw status word "unanswered" and no time-left, disagreeing with the
2869
2853
  // Inbox row for that exact same ask.
2870
- const { read: flowRead } = readRunJob({
2871
- root, name: flow, catalogue, runDir: run.runDir,
2872
- });
2873
- const ordered = runAsksInOrder(run.runDir, hasHistoryRow, histRow?.outcome === 'ask-expired', runJobEdited(readHaltRecord(run.runDir), histRow ?? null, flowRead));
2874
- const auditRows = readAudit(run.runDir);
2854
+ const flowRead = ctx.flowRead;
2855
+ const auditRows = ctx.auditRows;
2856
+ const ordered = runAsksInOrder(run.runDir, hasHistoryRow, auditRows, histRow?.outcome === 'ask-expired', ctx.jobEdited);
2875
2857
  const declSteps = flowRead.ok ? flowRead.declaration.steps : null;
2876
2858
  const stepInfo = deriveAskStepInfo(ordered, auditRows, declSteps);
2877
- let resume = hasHistoryRow ? null : deriveResumeState({ savedAnswer: readSavedAnswer(run.runDir), attempt: resumeAttempt?.(flow, runId) ?? null, ask: readAsk(run.runDir) });
2859
+ let resume = hasHistoryRow ? null : deriveResumeState({ savedAnswer: savedAnswerOf(run.runDir), attempt: resumeAttempt?.(flow, runId) ?? null, ask: readAsk(run.runDir) });
2878
2860
  // M4c amendment 2: the Ask tab says what the run list says — stuck, by the one rule (`stuckState`).
2879
2861
  let runStuckNow = false;
2880
2862
  if (resume) {
@@ -2914,7 +2896,7 @@ export function getRunAsks({
2914
2896
  const asks = ordered.map(withSheet).map(withCited).map((ask, i) => ({
2915
2897
  ...ask,
2916
2898
  ...deriveAskOpenFields(ask, hasHistoryRow, resume),
2917
- reopen: reopenOffer(ask, openAskJson, resume, readSavedAnswer(run.runDir)?.askId === ask.askId),
2899
+ reopen: reopenOffer(ask, openAskJson, resume, savedAnswerOf(run.runDir)?.askId === ask.askId),
2918
2900
  stuck: runStuckNow && resume?.askId === ask.askId,
2919
2901
  index: i + 1,
2920
2902
  total: ordered.length,
@@ -2952,24 +2934,33 @@ export function getRunAsks({
2952
2934
  */
2953
2935
  export function listStops({ root, resumeAttempt, catalogue }) {
2954
2936
  const rows = [];
2937
+ // M20 am9f item 3: a run that has ended and whose files did not change since the last call is answered from the last call's rows. The clock and a live process matter only to a run
2938
+ // with no end row (an ended run's leftover ask.json is never rebuilt into an open ask, `legacyRunAsks`), so those are read again every call. The key is the run's own files and its flow's.
2939
+ const last = stopsCache.get(root);
2940
+ const cache = last !== undefined && last.catalogue === catalogue ? last.runs : new Map();
2941
+ const seen = new Map();
2955
2942
  for (const flowName of listFlowNames(root)) {
2956
2943
  const flowDir = join(root, flowName);
2957
- const historyRows = readHistory(flowDir).filter((r) => r && typeof r.runId === 'string');
2944
+ const historySig = stampsInside(flowDir, ['.']);
2945
+ const history = { rows: /** @type {any[]|null} */ (null) }; // M20 am9f item 1: each flow's history is read once per call (by the first run that needs it) and shared with its runs
2958
2946
  for (const runId of listRunIds(flowDir)) {
2959
2947
  const run = resolveRunPath(root, flowName, runId);
2960
2948
  if (!run.ok) continue;
2961
- const end = endRow(historyRows, run.runDir, runId);
2949
+ const sig = `${historySig}|${runFilesSig(run.runDir)}`;
2950
+ const hit = cache.get(run.runDir);
2951
+ if (hit && hit.sig === sig) { seen.set(run.runDir, hit); rows.push(...hit.rows); continue; }
2952
+ const ctx = loadRunContext(root, flowDir, run.runDir, flowName, runId, catalogue, null, undefined, { history, jobOnlyIfResumable: true });
2953
+ const end = ctx.historyRow;
2962
2954
  const hasHistoryRow = end !== null;
2963
- const resume = hasHistoryRow ? null : deriveResumeState({ savedAnswer: readSavedAnswer(run.runDir), attempt: resumeAttempt?.(flowName, runId) ?? null, ask: readAsk(run.runDir) });
2955
+ const resume = hasHistoryRow ? null : deriveResumeState({ savedAnswer: savedAnswerOf(run.runDir), attempt: resumeAttempt?.(flowName, runId) ?? null, ask: readAsk(run.runDir) });
2964
2956
  // M4c amendment 2: stuck by the ONE rule (`stuckState`), marked on the ask whose answer is saved.
2965
2957
  const st = runStuck(run.runDir, resume);
2966
2958
  const stuckAskId = !hasHistoryRow && st.stuck ? (resume?.askId ?? null) : null;
2967
2959
  const openAskJson = hasHistoryRow ? null : readAsk(run.runDir);
2968
- const savedAskId = readSavedAnswer(run.runDir)?.askId;
2960
+ const savedAskId = savedAnswerOf(run.runDir)?.askId;
2969
2961
  // M6 amendment 4: read the job only for a run that ended stopped / cap-halted (and only when the caller gave the catalogue to read it with)
2970
- const jobEdited = end !== null && (end.outcome === 'stopped' || end.outcome === 'cap-halt') && catalogue !== undefined
2971
- && runJobEdited(readHaltRecord(run.runDir), end, readRunJob({ root, name: flowName, catalogue, runDir: run.runDir }).read);
2972
- const runAsks = runAsksInOrder(run.runDir, hasHistoryRow, end?.outcome === 'ask-expired', jobEdited).map((ask) => ({
2962
+ const jobEdited = end !== null && isResumableEnding(end.outcome) && catalogue !== undefined && ctx.jobEdited;
2963
+ const runAsks = runAsksInOrder(run.runDir, hasHistoryRow, ctx.auditRows, end?.outcome === 'ask-expired', jobEdited).map((ask) => ({
2973
2964
  flow: flowName,
2974
2965
  runId,
2975
2966
  ...ask,
@@ -2991,14 +2982,21 @@ export function listStops({ root, resumeAttempt, catalogue }) {
2991
2982
  if (newest) newest.working = WORKING_WORD[newest.status];
2992
2983
  }
2993
2984
  for (const r of runAsks) rows.push(r);
2985
+ if (hasHistoryRow) seen.set(run.runDir, { sig, rows: runAsks });
2994
2986
  }
2995
2987
  }
2988
+ stopsCache.set(root, { catalogue, runs: seen });
2996
2989
  return orderStops(rows).map((r) => {
2997
2990
  const glyph = stopGlyph(r);
2998
2991
  return glyph === null ? r : { ...r, glyph, word: SIGN_WORDS[glyph] };
2999
2992
  });
3000
2993
  }
3001
2994
 
2995
+ /** M20 am9f: root -> the last `listStops` call's per-run rows (see there) @type {Map<string, {catalogue: any, runs: Map<string, any>}>} */
2996
+ const stopsCache = new Map();
2997
+ /** the stamp of every file in a run's folder and its asks/ and job/ folders: any file written, replaced, renamed or removed changes it @param {string} runDir */
2998
+ const runFilesSig = (runDir) => stampsInside(runDir, ['.', 'asks', 'job']);
2999
+
3002
3000
  /** ask status -> the answer's own word, for "working on your <word>…". */
3003
3001
  const WORKING_WORD = { accepted: 'accept', redo: 'redo', reran: 'rerun' };
3004
3002