fwdloop 0.39.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.
package/README.md CHANGED
@@ -28,17 +28,14 @@ change.
28
28
  It is built mainly for that shape of work: gather, decide, pause, hand off, continue. Not a
29
29
  general agent. Not a chat bot. A workflow that a person can read, approve, rerun, and edit.
30
30
 
31
- ## The machine that makes machines
31
+ ## The factory that builds the factory
32
32
 
33
- Like a CNC machine, fwdloop builds the thing that does the work, then lets a gauge it can't touch decide if the work is good, and stops for you where you said. Trust needs four things. Miss one and trust is zero. fwdloop has all four.
33
+ Software factories run a flow someone wrote in advance. fwdloop builds the flow for each job, then lets a gauge it can't touch decide if the work is good, and stops for you where you said. Trust needs four things. Miss one and trust is zero. fwdloop has all four.
34
34
 
35
- **Intent.** You write the job as plain numbered lines, and `~` rules under each say what success means. Every rule gets a check or a written reason why not. You sign before a dollar is spent.
36
-
37
- **Guide rails, not just guardrails.** Guardrails stop the agent going off the road: a money cap per run, a monthly limit, a time limit on every Ask, and a send destination you signed that it can't move. Nothing leaves the machine without that signed destination and your accept in the same run. Guide rails keep it on the road: each new try hears what earlier tries in the run did; lessons from past runs go to the drafter and to retries; a rule it can't settle comes back as a question with buttons (Agree, Drop it, or your own words), not a guess.
38
-
39
- **Verification.** The check sits outside the agent's loop: code decides, built on bareguard. For a list of items (one per flight, resume or topic), code checks each item's fields against the limits your rules give, and how many items there are when you said. Anything code can't check is listed as Not checked, and you judge it at the Ask. A red step goes back with the real gap to be fixed, up to four tries a step; the same miss twice stops it.
40
-
41
- **Evidence.** Every try, its cost and its check result is recorded, and the books balance to the cent. You can read it all in the Audit tab, including exactly what each try was told. Page facts are quoted from a saved copy of the page.
35
+ - **Intent.** You write the job as plain numbered lines, and `~` rules under each say what success means. Every rule gets a check or a written reason why not. You sign before a dollar is spent.
36
+ - **Guide rails, not just guardrails.** Guardrails stop the agent going off the road: a money cap per run, a monthly limit, a time limit on every Ask, and a send destination you signed that it can't move. Nothing leaves the machine without that signed destination and your accept in the same run. Guide rails keep it on the road: each new try hears what earlier tries in the run did; lessons from past runs go to the drafter and to retries; a rule it can't settle comes back as a question with buttons (Agree, Drop it, or your own words), not a guess.
37
+ - **Verification.** The check sits outside the agent's loop: code decides, built on bareguard. For a list of items (one per flight, resume or topic), code checks each item's fields against the limits your rules give, and how many items there are when you said. Anything code can't check is listed as Not checked, and you judge it at the Ask. A red step goes back with the real gap to be fixed, up to four tries a step; the same miss twice stops it.
38
+ - **Evidence.** Every try, its cost and its check result is recorded, and the books balance to the cent. You can read it all in the Audit tab, including exactly what each try was told. Page facts are quoted from a saved copy of the page.
42
39
 
43
40
  The one difference from a lights-out machine: a person stands at the gate. The run parks at your Ask, spending nothing, and only after your accept does it act on the world.
44
41
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fwdloop",
3
- "version": "0.39.0",
3
+ "version": "0.40.0",
4
4
  "description": "Describe a job as steps and guardrails; an agent builds the workflow, pauses for humans where you said, checks every step happened, and reruns it under budgets it cannot touch.",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
package/src/audit-fold.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // (audit.jsonl's try rows + the three diaries in src/diary.js). Nothing here calls a model ($0 replay), and the page only draws what this returns,
3
3
  // so the Audit rows, the summary and the cards can only agree. A run from before am29 has no diaries: no fold, `—` on the new lines, nothing made up.
4
4
  import { readCalls, readTools, readChecks, newestChecksOf } from './diary.js';
5
- import { isStopNote, isHumanNo } from './books.js';
5
+ import { isStopNote, isHumanNo, isAskRow } from './books.js';
6
6
 
7
7
  /** A Stop's notes are not tries: the asked/not-honoured rows, and a `stopped` row that cut no try (no attempt number). @param {any} r */
8
8
  export function isTryRow(r) {
@@ -69,7 +69,7 @@ function answerShort(r) {
69
69
  */
70
70
  export function deriveFold(group, d, info = {}) {
71
71
  const step = group.rows[0]?.step ?? null;
72
- const human = group.rows.some((r) => Object.prototype.hasOwnProperty.call(r, 'unjudgedCount'));
72
+ const human = group.rows.some(isAskRow);
73
73
  const calls = d.calls.filter((r) => r.step === step);
74
74
  const tools = d.tools.filter((r) => r.step === step);
75
75
  const checkRows = d.checks.filter((r) => r.step === step);
@@ -22,6 +22,7 @@ import { REASON } from './reasons.js';
22
22
  import { KEPT_WORDS } from './pickrecord.js';
23
23
  import { tagOf } from './checkwords.js';
24
24
  import { lineRules } from './pagebits.js';
25
+ import { dropRows, dropLine } from './pagedropwords.js';
25
26
  import { isListedNotChecked, notCheckedItem, ruleTextOf } from './checkrows.js';
26
27
  import { isRec } from './isrec.js';
27
28
 
@@ -123,10 +124,20 @@ export function assembleFromBlock({ declaration, block, lines, lineSet, askLines
123
124
  const own = block.rows.find((x) => x.key === r.key);
124
125
  if (own?.hidden) return null;
125
126
  // the reason is the signed row's own `reason` (src/checkblock.js REASON, the one table); M10 am17 (6): `kept` words
126
- const line = notCheckedItem(r, ruleTextOf(lines, r) ?? own?.text, own ? (own.name ? [own.name] : own.words) : undefined, own?.keptFromLast === true);
127
+ // M20 am9h (F238): a fact row the page look dropped tells its own drop, in the words of the look's line (this block is the one writer of it)
128
+ const line = own && own.kind === 'fact' && own.from === 'look' && own.lookWhy
129
+ ? `line ${own.line}: "${own.name}" \u2014 ${own.lookWhy}`
130
+ : notCheckedItem(r, ruleTextOf(lines, r) ?? own?.text, own ? (own.name ? [own.name] : own.words) : undefined, own?.keptFromLast === true);
127
131
  if (tagOf(r.by) !== '') notCheckedBy[line] = r.by;
128
132
  return line;
129
133
  }).filter((x) => x !== null);
134
+ // M20 am9h (F238): every drop of the page look is said once, here: a row above already tells it, else it is a line of its own (a note about a word, or a fact whose rule is checked by another)
135
+ for (const row of dropRows(block.look?.dropped ?? [])) {
136
+ const line = dropLine(row, lines, lineRules);
137
+ if (notChecked.includes(line)) continue;
138
+ notChecked.push(line);
139
+ notCheckedBy[line] = 'default';
140
+ }
130
141
  for (const l of lines) {
131
142
  if (!askLines.has(l.n) || typeof l.guardrail !== 'string') continue;
132
143
  for (const rule of lineRules({ rule: l.guardrail })) {
package/src/blockpick.js CHANGED
@@ -55,26 +55,52 @@ export function guardrailItemCount(g) {
55
55
  return /^\d+$/.test(m[1]) ? Number(m[1]) : NUMBER_WORDS[m[1].toLowerCase()];
56
56
  }
57
57
 
58
- /** a list-bound word the guardrail uses: the count it names, or the one it stands for ("more than 3" = at least 4, "fewer than 3" = at most 2) */
59
- const MORE_THAN = /(?<!\b(?:no|not)\s)\bmore\s+than\s+(\d+)\b/i;
60
-
61
- const FEWER_THAN = /(?<!\b(?:no|not)\s)\b(?:(?:fewer|less)\s+than|under|below)\s+(\d+)\b/i;
58
+ /** a list-bound word the guardrail uses: the count it names, or the one it stands for ("more than 3" = at least 4, "fewer than 3" = at most 2). The bound words are global: read them only through hasBound / firstBound / saysBound, never .test or .exec (a global regex keeps lastIndex between calls) */
59
+ const MORE_THAN = /(?<!\b(?:no|not)\s)\bmore\s+than\s+(\d+)\b/gi;
60
+
61
+ const FEWER_THAN = /(?<!\b(?:no|not)\s)\b(?:(?:fewer|less)\s+than|under|below)\s+(\d+)\b/gi;
62
+
63
+ /** M20 am9d: "over N" reads like "more than N" for a WORDS rule (a list's "over" stays unread here, am8 item 3) */
64
+ const OVER = /(?<!\b(?:no|not)\s)\bover\s+(\d+)\b/gi;
65
+
66
+ /** does `text` say N with the word of `re` (one of the strict bound words above)? @param {RegExp} re @param {string} text @param {number} n */
67
+ const saysBound = (re, text, n) => [...String(text).matchAll(re)].some((m) => Number(m[1]) === n);
68
+ /** does `text` use the bound word `re` at all? search ignores and restores lastIndex @param {RegExp} re @param {string} text */
69
+ const hasBound = (re, text) => String(text).search(re) >= 0;
70
+ /** the first match of the bound word `re` in `text`, or undefined; matchAll works on a copy, so lastIndex stays 0 @param {RegExp} re @param {string} text */
71
+ const firstBound = (re, text) => String(text).matchAll(re).next().value;
72
+ const saysMoreThan = (/** @type {string} */ text, /** @type {number} */ n) => saysBound(MORE_THAN, text, n) || saysBound(OVER, text, n);
73
+
74
+ /** M20 am9d: the whole-output word bound a rule's own words stand for: "under / fewer than / below / less than N words" is at most N-1, "more than / over N words" is at least N+1; "at most / no more than / at least / no fewer than N" stay N. @param {string} text @param {number} n @returns {{rule: 'maxWords'|'minWords', value: number}} */
75
+ function wordsCheck(text, n) {
76
+ if (/\b(at least|min(?:imum)?|no fewer than)\b/i.test(text) || hasBound(MORE_THAN, text) || hasBound(OVER, text)) return { rule: 'minWords', value: saysMoreThan(text, n) ? n + 1 : n };
77
+ return { rule: 'maxWords', value: saysBound(FEWER_THAN, text, n) ? n - 1 : n };
78
+ }
62
79
 
63
80
  /** the direction of a list-items rule's wording: 'max', 'min' or null (exact / not said) @param {string} t @returns {'max'|'min'|null} */
64
81
  function listDirection(t) {
65
- if (/\b(at\s+most|up\s+to|no\s+more\s+than|not\s+more\s+than|max(?:imum)?(?:\s+of)?)\b/i.test(t) || FEWER_THAN.test(t)) return 'max';
66
- if (/\b(at\s+least|min(?:imum)?(?:\s+of)?|no\s+fewer\s+than|not\s+fewer\s+than)\b/i.test(t) || MORE_THAN.test(t)) return 'min';
82
+ if (/\b(at\s+most|up\s+to|no\s+more\s+than|not\s+more\s+than|max(?:imum)?(?:\s+of)?)\b/i.test(t) || hasBound(FEWER_THAN, t)) return 'max';
83
+ if (/\b(at\s+least|min(?:imum)?(?:\s+of)?|no\s+fewer\s+than|not\s+fewer\s+than)\b/i.test(t) || hasBound(MORE_THAN, t)) return 'min';
67
84
  return null;
68
85
  }
69
86
 
70
87
  /** the numbers a rule may carry: the standalone numbers of the guardrail, plus N+1 for "more than N" (min) and N-1 for "fewer than N" (max) @param {string} rule @param {string} g @returns {number[]} */
71
88
  function listBoundNumbers(rule, g) {
72
89
  const named = guardrailStandaloneNumbers(g);
73
- if (rule === 'minListItems') { const m = MORE_THAN.exec(g); if (m) named.push(Number(m[1]) + 1); }
74
- if (rule === 'maxListItems') { const m = FEWER_THAN.exec(g); if (m) named.push(Number(m[1]) - 1); }
90
+ if (rule === 'minListItems') { const m = firstBound(MORE_THAN, g); if (m) named.push(Number(m[1]) + 1); }
91
+ if (rule === 'maxListItems') { const m = firstBound(FEWER_THAN, g); if (m) named.push(Number(m[1]) - 1); }
75
92
  return named;
76
93
  }
77
94
 
95
+ /** the numbers a words rule may carry: the guardrail's word numbers, but a number said with a strict word is its bound: "under N words" carries N-1 (not N: that is the rule's own edge, which fails it), "more than / over N words" carries N+1 @param {string} rule @param {string} g @returns {number[]} */
96
+ function wordBoundNumbers(rule, g) {
97
+ return guardrailWordNumbers(g).map((n) => {
98
+ if (rule === 'maxWords' && saysBound(FEWER_THAN, g, n)) return n - 1;
99
+ if (rule === 'minWords' && saysMoreThan(g, n)) return n + 1;
100
+ return n;
101
+ });
102
+ }
103
+
78
104
  /** @param {unknown} g @returns {boolean} the rule is a COUNT bareguard checks (words, list items or lines, sections): code reads it, whatever the page look said about it */
79
105
  export const isCountable = (g) => guardrailWordNumbers(g).length > 0 || guardrailItemCount(g) !== null || guardrailSectionCount(g) !== null;
80
106
 
@@ -110,7 +136,7 @@ export function keepOrDrop(guardrail, sug) {
110
136
  if (NUM_FIELDS.includes(k)) {
111
137
  const floor = rule === 'maxListItems' ? 0 : 1; // maxListItems 0 = no bullets (bareguard 0.35); every other count starts at 1
112
138
  if (!Number.isInteger(v) || v < floor) return { kept: false, why: `${k} ${JSON.stringify(v)} is not a whole number >= ${floor}` };
113
- const named = rule === 'maxWords' || rule === 'minWords' ? guardrailWordNumbers(guardrail)
139
+ const named = rule === 'maxWords' || rule === 'minWords' ? wordBoundNumbers(rule, guardrail)
114
140
  : k === 'wordsPerSection' ? [guardrailWordsPerSection(guardrail)].filter((x) => x !== null)
115
141
  : listBoundNumbers(rule, guardrail);
116
142
  if (!named.includes(v)) return { kept: false, why: `${k} ${v} is not a number the guardrail names (${named.join(', ') || 'it names none'})` };
@@ -157,11 +183,11 @@ export function countCheck(text) {
157
183
  if (items !== null && /\blines?\b/i.test(text) && !/\b(bullets?|items?|points?)\b/i.test(text)) built = { rule: 'maxLines', value: items };
158
184
  else if (items !== null) {
159
185
  const dir = listDirection(text);
160
- if (dir === 'min') built = { rule: 'minListItems', value: MORE_THAN.test(text) ? items + 1 : items };
161
- else if (dir === 'max') built = { rule: 'maxListItems', value: FEWER_THAN.test(text) ? items - 1 : items };
186
+ if (dir === 'min') built = { rule: 'minListItems', value: hasBound(MORE_THAN, text) ? items + 1 : items };
187
+ else if (dir === 'max') built = { rule: 'maxListItems', value: hasBound(FEWER_THAN, text) ? items - 1 : items };
162
188
  else built = { rule: 'listItems', value: items };
163
189
  }
164
- else if (words.length === 1 && !/\bbetween\b|\d\s*(?:-|–|to)\s*\d/i.test(text)) built = { rule: /\b(at least|min(?:imum)?|more than|over|no fewer than)\b/i.test(text) ? 'minWords' : 'maxWords', value: words[0] };
190
+ else if (words.length === 1 && !/\bbetween\b|\d\s*(?:-|–|to)\s*\d/i.test(text)) built = wordsCheck(text, words[0]);
165
191
  if (built === null) return null;
166
192
  const res = keepOrDrop(text, built);
167
193
  return res.kept ? res.check : null;
package/src/books.js CHANGED
@@ -386,40 +386,42 @@ export const HALT_FILE = 'halt.json';
386
386
  * draftRow a verdict a drafting row of the Audit can carry (anything else reads not-done)
387
387
  * notRunEnd not an end of a run (a pause, a failed stop, a skipped ticket): learnings wait
388
388
  * word the Runs list's bold word for it (`null` = none: a run the human ended with rerun)
389
- * wordUnresumed its word when the run cannot be continued (M20 am1 item 9: a cap-halt with no usable halt.json reads "capped")
389
+ * audit M20 am9: what an Audit row of this verdict shows: `sign` (`null` = none), `word` and the try `mark` it gives its try. The run's `word` and the Audit's
390
+ * differ (ask-expired reads "expired" on the run, "expired waiting for you" on the row), so they are two columns; read it through `auditSignWord`
391
+ * runOnly an ending of a run only, never a verdict of an Audit row (no `audit` column); `auditSignWord` treats it like a word the table does not hold: failed, ✗
390
392
  * Outcome (history.jsonl) and verdict (audit.jsonl) are not split: one word means one thing on either book.
391
393
  * Not here, by design: the scheduler's own words (busy, monthly-exhausted, refused fire), the closers' verdicts (done, crash,
392
394
  * unparseable), and the Run tab's ending sentences (src/summary-words.js stays their one owner).
393
395
  */
394
396
  export const ENDINGS = Object.freeze({
395
- complete: { good: true, notFailed: true, word: 'passed' },
396
- skipped: { notFailed: true, notRunEnd: true, word: 'skipped' },
397
- stopped: { resumable: true, notFailed: true, open: true, humanNo: true, word: 'stopped' },
398
- 'cap-halt': { resumable: true, notFailed: true, blocked: true, spendFloor: true, word: 'stopped', wordUnresumed: 'capped' },
399
- rerun: { notFailed: true, word: null },
400
- 'ask-expired': { notFailed: true, blocked: true, open: true, word: 'expired' },
401
- 'ask-timeout': { blocked: true, open: true, word: 'failed' },
402
- refused: { blocked: true, open: true, waiting: true, word: 'failed' },
403
- red: { blocked: true, humanNo: true, redTry: true, tryVerdict: true, draftRow: true, word: 'failed' },
404
- 'not-done': { blocked: true, redTry: true, tryVerdict: true, word: 'failed' },
405
- 'provider-red': { blocked: true, noise: true, spendFloor: true, word: 'failed' },
406
- 'pricing-red': { blocked: true, spendFloor: true, word: 'failed' },
407
- 'close-casualty': { blocked: true, noise: true, word: 'failed' },
408
- 'preflight-red': { word: 'failed' },
409
- 'struck-out': { word: 'failed' },
410
- 'attempt-fallback': { word: 'failed' },
411
- 'redo-halt': { word: 'failed' },
412
- 'stop-failed': { notRunEnd: true, word: 'failed' },
413
- green: { good: true, tryVerdict: true, draftRow: true },
414
- hitl: { good: true, tryVerdict: true },
415
- softgreen: { tryVerdict: true }, // fwd writes no such verdict today; the learnings read audits shaped like bareloop's, so it stays a try
416
- paused: { open: true, waiting: true, notRunEnd: true },
417
- 'ask-reopened': { open: true },
418
- 'lock-removed': { open: true },
419
- 'stop-asked': { open: true, stopNote: true },
420
- 'stop-not-honoured': { open: true, stopNote: true },
421
- 'stale-answer-ignored': {},
422
- 'answer-after-run': {},
397
+ complete: { good: true, notFailed: true, word: 'passed', runOnly: true },
398
+ skipped: { notFailed: true, notRunEnd: true, word: 'skipped', runOnly: true },
399
+ stopped: { resumable: true, notFailed: true, open: true, humanNo: true, word: 'stopped', audit: { sign: null, word: 'stopped by you', mark: '·' } },
400
+ 'cap-halt': { resumable: true, notFailed: true, blocked: true, spendFloor: true, word: 'capped', audit: { sign: '■', word: 'capped — money cap', mark: '■' } },
401
+ rerun: { notFailed: true, word: null, runOnly: true },
402
+ 'ask-expired': { notFailed: true, blocked: true, open: true, word: 'expired', audit: { sign: null, word: 'expired waiting for you', mark: '·' } },
403
+ 'ask-timeout': { blocked: true, open: true, word: 'failed', audit: { sign: null, word: 'expired waiting for you', mark: '·' } },
404
+ refused: { blocked: true, open: true, waiting: true, word: 'failed', audit: { sign: null, word: 'refused — no reason given', mark: '·' } },
405
+ red: { blocked: true, humanNo: true, redTry: true, tryVerdict: true, draftRow: true, word: 'failed', audit: { sign: '✗', word: 'failed', mark: '✗' } },
406
+ 'not-done': { blocked: true, redTry: true, tryVerdict: true, word: 'failed', audit: { sign: '✗', word: 'not done', mark: '✗' } },
407
+ 'provider-red': { blocked: true, noise: true, spendFloor: true, word: 'failed', audit: { sign: '✗', word: 'failed', mark: '✗' } },
408
+ 'pricing-red': { blocked: true, spendFloor: true, word: 'failed', audit: { sign: '✗', word: 'failed', mark: '✗' } },
409
+ 'close-casualty': { blocked: true, noise: true, word: 'failed', audit: { sign: '✗', word: 'failed', mark: '✗' } },
410
+ 'preflight-red': { word: 'failed', runOnly: true },
411
+ 'struck-out': { word: 'failed', runOnly: true },
412
+ 'attempt-fallback': { word: 'failed', runOnly: true },
413
+ 'redo-halt': { word: 'failed', runOnly: true },
414
+ 'stop-failed': { notRunEnd: true, word: 'failed', runOnly: true },
415
+ green: { good: true, tryVerdict: true, draftRow: true, audit: { sign: '✓', word: 'passed', mark: '✓' } },
416
+ hitl: { good: true, tryVerdict: true, audit: { sign: '✓', word: 'human check', mark: '✓' } },
417
+ softgreen: { tryVerdict: true, audit: { sign: '✗', word: 'failed', mark: '✗' } }, // fwd writes no such verdict today; the learnings read audits shaped like bareloop's, so it stays a try
418
+ paused: { open: true, waiting: true, notRunEnd: true, audit: { sign: null, word: 'paused for you', mark: '·' } },
419
+ 'ask-reopened': { open: true, audit: { sign: null, word: 'reopened by you', mark: '·' } },
420
+ 'lock-removed': { open: true, audit: { sign: null, word: 'old lock removed by you', mark: '·' } },
421
+ 'stop-asked': { open: true, stopNote: true, audit: { sign: null, word: 'stop asked by you', mark: '·' } },
422
+ 'stop-not-honoured': { open: true, stopNote: true, audit: { sign: null, word: 'stop not honoured', mark: '·' } },
423
+ 'stale-answer-ignored': { audit: { sign: '✗', word: 'failed', mark: '✗' } },
424
+ 'answer-after-run': { audit: { sign: '✗', word: 'failed', mark: '✗' } },
423
425
  });
424
426
 
425
427
  /** @param {unknown} word @param {string} flag */
@@ -450,11 +452,29 @@ export const isDraftRowVerdict = (/** @type {unknown} */ w) => endingHas(w, 'dra
450
452
  export const isNotRunEnd = (/** @type {unknown} */ w) => endingHas(w, 'notRunEnd');
451
453
  /** The outcomes a run can be continued from (M4e amendment 4 item 4): the runner leaves `halt.json` for them. */
452
454
  export const isResumableEnding = (/** @type {unknown} */ w) => endingHas(w, 'resumable');
453
- /** the Runs list's bold word for an ending (`null` for none); `resumable` false asks the word of a run that cannot be continued @param {string} w @param {boolean} [resumable] @returns {string|null} */
454
- export function endingWord(w, resumable = true) {
455
- if (!Object.hasOwn(ENDINGS, w)) return null;
456
- const e = /** @type {any} */ (ENDINGS)[w];
457
- return resumable === false && typeof e.wordUnresumed === 'string' ? e.wordUnresumed : e.word ?? null;
455
+ /** the Runs list's bold word for an ending (`null` for none) @param {string} w @returns {string|null} */
456
+ export function endingWord(w) {
457
+ return Object.hasOwn(ENDINGS, w) ? /** @type {any} */ (ENDINGS)[w].word ?? null : null;
458
+ }
459
+
460
+ /**
461
+ * M20 am9b: was this Audit row written by the Ask's answer path (the person's own paused, accept, redo, rerun, refused rows)? The runner gives that path's rows, and no other, `unjudgedCount` (F281: 41 hitl+red rows, 0 mismatches).
462
+ * @param {any} row
463
+ */
464
+ export const isAskRow = (row) => row !== null && typeof row === 'object' && Object.hasOwn(row, 'unjudgedCount');
465
+
466
+ /**
467
+ * M20 am9 / am9b: the ONE owner of an Audit row's sign, word and try mark. `closeClass`, `gap` and `human` (the row is the Ask's own, `isAskRow`) are its inputs: a `red` on a
468
+ * `hitl` step that the person wrote is their redo, no sign, "redo by you: <gap>" (mark ✗); the same red written by a model is a plain red, failed ✗. A verdict that is not a string reads "unknown" ✗; a verdict with no `audit` column (a run-only ending, or a word the table
469
+ * does not hold) reads failed ✗, as the page always drew it.
470
+ * @param {unknown} verdict @param {string|null|undefined} [closeClass] @param {string|null|undefined} [gap] @param {boolean} [human]
471
+ * @returns {{sign: '✓'|'✗'|'■'|null, word: string, mark: '✓'|'✗'|'·'|'■'}}
472
+ */
473
+ export function auditSignWord(verdict, closeClass, gap, human = false) {
474
+ if (closeClass === 'hitl' && verdict === 'red' && human) return { sign: null, word: `redo by you${gap ? `: ${gap}` : ''}`, mark: '✗' };
475
+ if (typeof verdict !== 'string') return { sign: '✗', word: 'unknown', mark: '✗' };
476
+ const col = Object.hasOwn(ENDINGS, verdict) ? /** @type {any} */ (ENDINGS)[verdict].audit : undefined;
477
+ return col ?? { sign: '✗', word: 'failed', mark: '✗' };
458
478
  }
459
479
 
460
480
  /**
package/src/checkblock.js CHANGED
@@ -240,7 +240,7 @@ export class CheckBlock {
240
240
  */
241
241
  shapeCandidates() {
242
242
  if (this.repo !== null) return [];
243
- return this.rows.filter((r) => r.kind === 'rule' && !r.left && (!r.can?.ok || r.truthRefused) && !r.can?.ask && !this.isSheetLine(r.line) && !NEGATING_RE.test(String(r.text))).map((r) => ({ line: r.line, rule: Number(r.rule) }));
243
+ return this.rows.filter((r) => r.kind === 'rule' && !r.left && (!r.can?.ok || r.truthRefused) && !r.can?.ask && !r.can?.final && !this.isSheetLine(r.line) && !NEGATING_RE.test(String(r.text))).map((r) => ({ line: r.line, rule: Number(r.rule) }));
244
244
  }
245
245
 
246
246
  /**
@@ -475,7 +475,8 @@ export class CheckBlock {
475
475
  matchRule(r) {
476
476
  this.matchTruthRule(r);
477
477
  // a truth check code picked but REFUSED when it built the line (live mwnbs3np: 4 results, a title said once) is no check: the rule is still Not checked, so it may take its shape field (hamr: shape for what code could not check)
478
- if (r.can?.ask || (r.can?.ok && !r.truthRefused)) return;
478
+ // `final`: the page itself says this rule cannot be checked (an amount in another currency than the page's prices): the AI's own answer is not a way round it, the person reads the reason
479
+ if (r.can?.ask || r.can?.final || (r.can?.ok && !r.truthRefused)) return;
479
480
  const sh = this.takesShape(r);
480
481
  if (sh === null) return;
481
482
  r.can = this.shapeDrops.rules.has(`${r.line}:${r.rule}`) ? { ok: false, why: REASON.dropped } : { ok: true, how: 'shape', name: sh.name };
@@ -531,7 +532,7 @@ export class CheckBlock {
531
532
  r.can = { ok: true, how: 'fact', link: l, reading: undefined };
532
533
  return;
533
534
  }
534
- if (otherCurrency) { r.can = { ok: false, why: `the amount in your rule is in another currency than the page's prices, so it is not checked.` }; return; }
535
+ if (otherCurrency) { r.can = { ok: false, final: true, why: `the amount in your rule is in another currency than the page's prices, so it is not checked.` }; return; }
535
536
  if (r.links?.length && !links.length) { r.can = { ok: false, why: REASON.lookNoWords }; return; }
536
537
  if (r.origin === 'typed' || r.cantAsked) { r.can = { ok: false, why: r.aiReason ?? r.lookWhy ?? REASON.noPick }; return; }
537
538
  if (r.links?.length) { r.can = { ok: false, why: r.aiReason ?? `the look tied a fact to this rule but gave no limit, and ${ownWhy ? `in your words ${ownWhy}` : 'your own words give none code can read'}, so you judge it at Accept.` }; return; }
package/src/checkpick.js CHANGED
@@ -71,7 +71,7 @@ Rules:
71
71
  - Use only a rule from the list below, with only the fields that rule takes. Do not set id, field, strict or text: code sets them.
72
72
  - Use only numbers the guardrail itself states, and only words the guardrail itself contains. Never add a section name, phrase or number the guardrail does not state.
73
73
  - Suggest \`sections\` or \`sectionWords\` only when the guardrail itself names the sections.
74
- - A guardrail like 'all under N words' or 'under N words' is about the whole answer: use maxWords N.
74
+ - A guardrail like 'all under N words' is about the whole answer. 'under / fewer than / below / less than N words': use maxWords N-1 (a rule that says under N fails at N). 'more than / over N words': use minWords N+1. 'at most / no more than / up to N words': maxWords N. 'at least / no fewer than N words': minWords N.
75
75
  - If no check on the list checks exactly what the guardrail says (it is about content, sources, prices, columns, or a count the list cannot check exactly), answer "none". A check that is weaker than, or different from, the guardrail is worse than "none".
76
76
  - Answer for every guardrail once, using the line number and the guardrail number shown.
77
77
 
package/src/drafter.js CHANGED
@@ -417,8 +417,8 @@ export async function draft({
417
417
  const ticketSources = flowType === 'tickets' ? ticketSourcesOf(arbiter.sources) : [];
418
418
  const servers = flowType === 'plain' ? [] : (mcpServers ?? userMcpServers());
419
419
  const flowReds = ticketReds({ flowType, ticketSources, pick: mcp, servers });
420
- // M19 am14b: the Tickets list address is an Inputs line; every other flow red is about the picked MCP
421
- if (flowReds.length) return fail(flowReds, { box: flowType === 'tickets' && ticketSources.length === 0 ? 'inputs' : 'mcp' });
420
+ // M19 am14b: the Tickets list address is an Inputs line; M20 am9e: every other flow red is about the picked MCP and sits under the Draft button (no box)
421
+ if (flowReds.length) return fail(flowReds, flowType === 'tickets' && ticketSources.length === 0 ? { box: 'inputs' } : {});
422
422
 
423
423
  let { provider, rates, modelId } = { provider: injected, rates: injectedRates, modelId: injectedModelId };
424
424
  let prices = null; // the one price lookup's result (live provider only); the cap check below uses the SAME price
@@ -1122,7 +1122,9 @@ export async function draft({
1122
1122
  // (`uncovered`). A drop of a prose word is no rule and stays.
1123
1123
  const ruleKey = (/** @type {string} */ t) => t.split(' \u2014 ')[0];
1124
1124
  const sheetRuleKeys = new Set(jobLines.filter((l) => sheetLineNums.includes(l.n)).flatMap((l) => lineRules(l).map((r) => `line ${l.n}: "${r}"`)));
1125
- const lookNotChecked = pageNotChecked.filter((t) => !sheetRuleKeys.has(ruleKey(t)));
1125
+ // M20 am9h (F238): the page look's own lines are told to the drafter only (pageInfoLines); the block says each drop once (src/blockassemble.js). Without a block the lines stay.
1126
+ const onSheetLine = (/** @type {string} */ t) => sheetLineNums.includes(Number(t.slice(5, t.indexOf(':'))));
1127
+ const lookNotChecked = pageNotChecked.filter((t) => !sheetRuleKeys.has(ruleKey(t)) && (!assembled || onSheetLine(t)));
1126
1128
  /** @type {Record<string, 'you'|'agent'|'default'>} */
1127
1129
  const noteBy = Object.fromEntries([...lookNotChecked, ...uncovered].map((t) => [t, 'default']));
1128
1130
  const ticketNotChecked = (ticketOnList?.notChecked ?? []).map((t) => `not checked · "${t.rule}" — ${t.reason}`);
package/src/inside.js CHANGED
@@ -16,11 +16,13 @@ import path from 'node:path';
16
16
  * (never a red) so every existing caller keeps its own "not written yet"
17
17
  * behaviour unchanged.
18
18
  *
19
+ * `fast` (M20 am9f, change stamps only): skip the realpath checks, keep the symlink refusal. The caller only lists or stamps (never opens) what comes back.
19
20
  * @param {string} baseDir
20
21
  * @param {string} relPath
21
- * @returns {{ok:true, full:string}|{ok:false, missing:true}|{ok:false, missing:false, red:string}}
22
+ * @param {boolean} [fast]
23
+ * @returns {{ok:true, full:string, stat:{size:number, mtimeMs:number}}|{ok:false, missing:true}|{ok:false, missing:false, red:string}}
22
24
  */
23
- export function resolveInside(baseDir, relPath) {
25
+ export function resolveInside(baseDir, relPath, fast = false) {
24
26
  const full = path.join(baseDir, relPath);
25
27
  let stat;
26
28
  try {
@@ -31,6 +33,7 @@ export function resolveInside(baseDir, relPath) {
31
33
  if (stat.isSymbolicLink()) {
32
34
  return { ok: false, missing: false, red: `"${relPath}" is a symlink, refused` };
33
35
  }
36
+ if (fast) return { ok: true, full, stat };
34
37
  let realBase;
35
38
  let realFull;
36
39
  try {
@@ -42,7 +45,7 @@ export function resolveInside(baseDir, relPath) {
42
45
  if (realFull !== realBase && !realFull.startsWith(realBase + path.sep)) {
43
46
  return { ok: false, missing: false, red: `"${relPath}" resolves outside its directory — refused` };
44
47
  }
45
- return { ok: true, full };
48
+ return { ok: true, full, stat };
46
49
  }
47
50
 
48
51
  /**
@@ -71,10 +74,11 @@ export function readFileInside(baseDir, relPath) {
71
74
  * would escape `baseDir`. `[]` when `relDir` doesn't exist.
72
75
  * @param {string} baseDir
73
76
  * @param {string} relDir
77
+ * @param {boolean} [fast] see `resolveInside`
74
78
  * @returns {string[]}
75
79
  */
76
- export function readdirInside(baseDir, relDir) {
77
- const resolved = resolveInside(baseDir, relDir);
80
+ export function readdirInside(baseDir, relDir, fast = false) {
81
+ const resolved = resolveInside(baseDir, relDir, fast);
78
82
  if (!resolved.ok) return [];
79
83
  let entries;
80
84
  try {
@@ -84,3 +88,19 @@ export function readdirInside(baseDir, relDir) {
84
88
  }
85
89
  return entries.filter((e) => !e.isSymbolicLink()).map((e) => e.name);
86
90
  }
91
+
92
+ /**
93
+ * M20 am9f: one string that changes when any file in `dirs` (folders of `baseDir`, `.` for itself) is written, replaced, renamed or removed: every entry's name, size and mtime.
94
+ * It only lists and stats through `resolveInside`'s `fast` form (a symlink reads `-`, nothing is opened); a missing folder adds nothing.
95
+ * @param {string} baseDir @param {string[]} dirs @returns {string}
96
+ */
97
+ export function stampsInside(baseDir, dirs) {
98
+ const out = [];
99
+ for (const dir of dirs) {
100
+ for (const n of readdirInside(baseDir, dir, true).sort()) {
101
+ const r = resolveInside(baseDir, path.join(dir, n), true);
102
+ out.push(`${dir}/${n}=${r.ok ? `${r.stat.size}:${r.stat.mtimeMs}` : '-'}`);
103
+ }
104
+ }
105
+ return out.join(',');
106
+ }
package/src/panel/data.js CHANGED
@@ -29,10 +29,10 @@ import { compareNatural } from '../natural.js';
29
29
  import { join, sep } from 'node:path';
30
30
 
31
31
  import { readFlow, readPlan, readRunPlan, readRunJobCopy, listFlowNames, listRunIds, resolveRunDir, checkFlowName } from '../flow.js';
32
- import { readFileInside, readdirInside } from '../inside.js';
32
+ import { readFileInside, readdirInside, stampsInside } from '../inside.js';
33
33
  import {
34
34
  readAudit, readHistory, endRow, readPidRows, readSavedAnswer, processStarted, readRunState, readLog, readHaltRecord, readTriggerRecord, consumedAnswerName, askIdOfConsumedName,
35
- endingWord, isBlockedEnding, isGoodEnding, isOpenEnding, isWaitingEnding, isStopNote, isResumableEnding, redWhyOf, isDraftRowVerdict, auditRowTokens, auditRowAt, auditRowTools,
35
+ endingWord, auditSignWord, isAskRow, isBlockedEnding, isGoodEnding, isWaitingEnding, isStopNote, isResumableEnding, redWhyOf, isDraftRowVerdict, auditRowTokens, auditRowAt, auditRowTools,
36
36
  } from '../books.js';
37
37
  import {
38
38
  readAsk, stopPending,
@@ -258,12 +258,12 @@ export const SIGN_WORDS = {
258
258
  * opens with the word ("stuck — …") or is the word itself ("passed") loses that repeat, so it is never said twice.
259
259
  * `noWord`: a run the human ended on purpose with rerun wears `[✗]` but is never called "failed" (M4b amendment 3),
260
260
  * so it shows its plain line alone.
261
- * @param {string} glyph a `computeGlyph` sign @param {string} label its plain line @param {boolean} [noWord] @param {{outcome: string|null|undefined, resumable: boolean}|null} [ending] the run's end row outcome and whether it can be continued
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
262
262
  * @returns {{word: string|null, line: string|null}}
263
263
  */
264
264
  export function signParts(glyph, label, noWord = false, ending = null) {
265
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, ending.resumable) : null) ?? SIGN_WORDS[glyph] ?? null);
266
+ const word = noWord ? null : ((ending && ending.outcome ? endingWord(ending.outcome) : null) ?? SIGN_WORDS[glyph] ?? null);
267
267
  if (word === null) return { word: null, line: label ?? null };
268
268
  if (typeof label !== 'string' || label === word) return { word, line: null };
269
269
  if (label.startsWith(`${word} — `)) return { word, line: label.slice(word.length + 3) };
@@ -401,9 +401,9 @@ export function computeGlyph({
401
401
  if (historyRow.outcome === 'stopped') {
402
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' };
403
403
  }
404
- if (historyRow.outcome === 'cap-halt' && resumable) return { glyph: '[■]', label: 'stopped — the money cap was reached; raise it and Resume' };
405
- // M20 am1 item 9: a cap-halt that cannot be resumed wears the stop sign with its own word, never "failed (cap-halt)"
406
- if (historyRow.outcome === 'cap-halt') return { glyph: '[■]', label: endingWord('cap-halt', false) ?? '' };
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') ?? '' };
407
407
  // M4b amendment 3: a run the human ended on purpose with rerun is not a failure.
408
408
  if (historyRow.outcome === 'rerun') return { glyph: '[✗]', label: 'stopped by you (rerun), a fresh run was started' };
409
409
  // M4c-fix amendment 1 (c): a run ended because its ask expired is `[!]` expired, never failed (it spent nothing more).
@@ -533,7 +533,7 @@ export function deriveRunModel(auditRows) {
533
533
  * @returns {'model call'|'human'|'no model call'}
534
534
  */
535
535
  export function deriveAuditAction(row) {
536
- if (row && Object.prototype.hasOwnProperty.call(row, 'unjudgedCount')) return 'human';
536
+ if (isAskRow(row)) return 'human';
537
537
  if (typeof row?.model === 'string' && row.model.length > 0) return 'model call';
538
538
  return 'no model call';
539
539
  }
@@ -678,15 +678,12 @@ export function isBlockedVerdict(verdict) {
678
678
  * resolved either way). A `refused` (blank-reason) row is its own re-ask,
679
679
  * not a resolution, so it reads as `·` like `paused` — the try it belongs to
680
680
  * is still open.
681
- * @param {string|null|undefined} verdict
681
+ * @param {{verdict: string|null|undefined, gap?: string|null}} row
682
682
  * @param {string|null|undefined} closeClass
683
- * @returns {'✓'|'✗'|'·'}
683
+ * @returns {'✓'|'✗'|'·'|'■'}
684
684
  */
685
- function markForVerdict(verdict, closeClass) {
686
- if (closeClass === 'hitl' && verdict === 'red') return '✗'; // the human's own redo
687
- if (isGoodEnding(verdict)) return '✓';
688
- if (isOpenEnding(verdict)) return '·';
689
- return '✗';
685
+ function markForVerdict(row, closeClass) {
686
+ return auditSignWord(row.verdict, closeClass, row.gap, isAskRow(row)).mark;
690
687
  }
691
688
 
692
689
  /**
@@ -698,7 +695,7 @@ function markForVerdict(verdict, closeClass) {
698
695
  * open, not resolved).
699
696
  * @param {string|null} closeClass
700
697
  * @param {Array<{verdict:string}>} rows one step's own audit rows, book order
701
- * @returns {Array<'✓'|'✗'|'·'>}
698
+ * @returns {Array<'✓'|'✗'|'·'|'■'>}
702
699
  */
703
700
  export function deriveStepTryMarks(closeClass, rows) {
704
701
  if (!rows || !rows.length) return [];
@@ -709,7 +706,7 @@ export function deriveStepTryMarks(closeClass, rows) {
709
706
  // No paused row at all is not a shape this step produces in practice
710
707
  // (guarded the same way `computeTryCount` already is) — one mark per
711
708
  // row rather than hiding that a try happened.
712
- return rows.map((r) => markForVerdict(r.verdict, closeClass));
709
+ return rows.map((r) => markForVerdict(r, closeClass));
713
710
  }
714
711
  return pausedIdxs.map((idx, i) => {
715
712
  // The resolving row is the LAST row before the next `paused` boundary
@@ -722,10 +719,10 @@ export function deriveStepTryMarks(closeClass, rows) {
722
719
  const nextPausedIdx = pausedIdxs[i + 1] ?? rows.length;
723
720
  const lastIdx = nextPausedIdx - 1;
724
721
  if (lastIdx === idx) return '·'; // still paused, no resolution row yet in this run's book
725
- return markForVerdict(rows[lastIdx].verdict, closeClass);
722
+ return markForVerdict(rows[lastIdx], closeClass);
726
723
  });
727
724
  }
728
- return rows.map((r) => markForVerdict(r.verdict, closeClass));
725
+ return rows.map((r) => markForVerdict(r, closeClass));
729
726
  }
730
727
 
731
728
  /** The name of the one group for audit rows that name no step. */
@@ -745,16 +742,31 @@ function auditStepName(step) {
745
742
  * the human asked), `stopped` (the last attempt failed for any other reason). A group only
746
743
  * ever exists for a step with at least one row, so `pending` never appears
747
744
  * here (unlike the Run tab's map, which also covers never-attempted steps).
748
- * @param {Array<{verdict:string}>} rows one step's own audit rows, book order
749
- * @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
750
749
  */
751
750
  export function deriveStepGroupState(rows) {
752
- // a Stop's notes (asked / not honoured) say nothing about the step's own state; a step with only notes reads as stopped
753
- const own = rows.filter((r) => !isStopNote(r.verdict));
754
- const last = own.length > 0 ? own[own.length - 1] : rows[rows.length - 1];
751
+ const last = lastRowOfGroup(rows);
755
752
  if (isWaitingEnding(last.verdict)) return 'waiting';
756
753
  if (last.verdict === 'stopped') return 'user-stopped';
757
- return isGoodEnding(last.verdict) ? '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;
758
770
  }
759
771
 
760
772
  /**
@@ -826,6 +838,7 @@ export function deriveAuditGroups(enrichedRows) {
826
838
  return {
827
839
  step,
828
840
  state: deriveStepGroupState(rows),
841
+ stateText: groupStateText(rows),
829
842
  closeClass,
830
843
  timeMs,
831
844
  cost,
@@ -913,14 +926,17 @@ const JOB_EDITED_LINE = 'stopped — the job was edited; start a new run';
913
926
  * @param {any} catalogue
914
927
  * @param {any} [attempt] the panel's in-memory resume-attempt record for this run, or null
915
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)
916
930
  * @returns {any}
917
931
  */
918
- function loadRunContext(root, flowDir, runDir, flowName, runId, catalogue, attempt = null, startingRun = undefined) {
919
- 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 }));
920
938
  // M4e amendment 5 item 3 / amendment 4 item 6: the run's own signed values (its newest version) lie over the flow's
921
939
  const inForce = flowRead.ok ? applyRunValues(flowRead.arbiter, flowName, flowRead.signature.flow, pickRunValues(runDir)) : null;
922
- const historyRows = readHistory(flowDir);
923
- const historyRow = endRow(historyRows, runDir, runId);
924
940
  const halt = readHaltRecord(runDir);
925
941
  const auditRows = readAudit(runDir);
926
942
  const spendRows = readSpendRows(join(runDir, 'spend.jsonl'));
@@ -1158,7 +1174,7 @@ export function listRuns({ root, catalogue, resumeAttempt, startingRun, now = Da
1158
1174
  runId,
1159
1175
  glyph,
1160
1176
  label,
1161
- ...signParts(glyph, label, ctx.historyRow?.outcome === 'rerun', ctx.historyRow ? { outcome: ctx.historyRow.outcome, resumable: ctx.resumable === true } : null),
1177
+ ...signParts(glyph, label, ctx.historyRow?.outcome === 'rerun', ctx.historyRow ? { outcome: ctx.historyRow.outcome } : null),
1162
1178
  pulse: glyphPulses({ glyph, label }),
1163
1179
  stuck: glyph === '[II]',
1164
1180
  controls,
@@ -1414,9 +1430,16 @@ function enrichAuditRows(rawRows) {
1414
1430
  thinkingPhrase: thinkingTryWords(row.thinking), // M4d am26: null for a row that kept no thinking record
1415
1431
  atWhy: deriveAuditAtWhy(row),
1416
1432
  blocked: isBlockedVerdict(row.verdict),
1433
+ ...signWordOf(row),
1417
1434
  }));
1418
1435
  }
1419
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
+
1420
1443
  /**
1421
1444
  * "try N" (map node / step-card badge) counts different things for
1422
1445
  * different close classes, and must never just be `attempts.length` (browser
@@ -1676,6 +1699,7 @@ export function getRunDetail({
1676
1699
  newLine: cardLine(group?.fold ?? null),
1677
1700
  lastAnswerAt: group?.fold?.lastAnswer?.at ?? null,
1678
1701
  groupState: group ? group.state : null,
1702
+ groupText: group ? group.stateText : null,
1679
1703
  timeMs: group ? group.timeMs : null,
1680
1704
  cost: group ? group.cost : null,
1681
1705
  costWhy: group ? group.costWhy : null,
@@ -1797,7 +1821,7 @@ export function getRunDetail({
1797
1821
  runId,
1798
1822
  glyph,
1799
1823
  label,
1800
- ...signParts(glyph, label, ctx.historyRow?.outcome === 'rerun', ctx.historyRow ? { outcome: ctx.historyRow.outcome, resumable: ctx.resumable === true } : null),
1824
+ ...signParts(glyph, label, ctx.historyRow?.outcome === 'rerun', ctx.historyRow ? { outcome: ctx.historyRow.outcome } : null),
1801
1825
  signWords: SIGN_WORDS,
1802
1826
  pulse: glyphPulses({ glyph, label }),
1803
1827
  controls: runControls(ctx, glyph, label),
@@ -1972,7 +1996,7 @@ export function getDraftBlock(flowDir, runDir) {
1972
1996
  const ended = setup.present && setup.rows.some((r) => r.kind === 'sign') ? 'done' : 'not signed';
1973
1997
  const summary = setup.present && totals ? { present: true, ...totals, ended, happened } : { present: false, why: NO_DRAFT_WORDS };
1974
1998
  return {
1975
- 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,
1976
2000
  };
1977
2001
  }
1978
2002
 
@@ -2910,12 +2934,22 @@ export function getRunAsks({
2910
2934
  */
2911
2935
  export function listStops({ root, resumeAttempt, catalogue }) {
2912
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();
2913
2942
  for (const flowName of listFlowNames(root)) {
2914
2943
  const flowDir = join(root, flowName);
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
2915
2946
  for (const runId of listRunIds(flowDir)) {
2916
2947
  const run = resolveRunPath(root, flowName, runId);
2917
2948
  if (!run.ok) continue;
2918
- const ctx = loadRunContext(root, flowDir, run.runDir, flowName, runId, catalogue, null);
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 });
2919
2953
  const end = ctx.historyRow;
2920
2954
  const hasHistoryRow = end !== null;
2921
2955
  const resume = hasHistoryRow ? null : deriveResumeState({ savedAnswer: savedAnswerOf(run.runDir), attempt: resumeAttempt?.(flowName, runId) ?? null, ask: readAsk(run.runDir) });
@@ -2948,14 +2982,21 @@ export function listStops({ root, resumeAttempt, catalogue }) {
2948
2982
  if (newest) newest.working = WORKING_WORD[newest.status];
2949
2983
  }
2950
2984
  for (const r of runAsks) rows.push(r);
2985
+ if (hasHistoryRow) seen.set(run.runDir, { sig, rows: runAsks });
2951
2986
  }
2952
2987
  }
2988
+ stopsCache.set(root, { catalogue, runs: seen });
2953
2989
  return orderStops(rows).map((r) => {
2954
2990
  const glyph = stopGlyph(r);
2955
2991
  return glyph === null ? r : { ...r, glyph, word: SIGN_WORDS[glyph] };
2956
2992
  });
2957
2993
  }
2958
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
+
2959
3000
  /** ask status -> the answer's own word, for "working on your <word>…". */
2960
3001
  const WORKING_WORD = { accepted: 'accept', redo: 'redo', reran: 'rerun' };
2961
3002
 
@@ -392,6 +392,8 @@
392
392
  .map-chip.s-stopped{border-color:var(--red);} .map-chip.s-stopped .chip-state{color:var(--red);}
393
393
  .map-chip.s-waiting{border-color:var(--amber);} .map-chip.s-waiting .chip-state{color:#b8860b;}
394
394
  .map-chip.s-user-stopped{border-color:var(--grey-dot);} .map-chip.s-user-stopped .chip-state{color:var(--grey-dot);}
395
+ .map-chip.s-capped{border-color:var(--grey-dot);} .map-chip.s-capped .chip-state{color:var(--grey-dot);}
396
+ .map-chip.s-noted{border-color:var(--grey-dot);} .map-chip.s-noted .chip-state{color:var(--grey-dot);}
395
397
  .map-chip .chip-retry{font-size:10px;color:var(--text-faint);}
396
398
  .map-chip.retry{border-style:dashed;} /* borrowed-from: bareloop src/panel/index.html@9edb3e1 */
397
399
 
@@ -1277,7 +1279,6 @@
1277
1279
  <label for="jf-mcp">MCP</label>
1278
1280
  <select id="jf-mcp" data-testid="jf-mcp" aria-label="MCP"></select>
1279
1281
  <div class="hint"><a class="link" id="jf-mcp-manage" data-testid="jf-mcp-manage" href="#">manage in Settings &gt; MCP</a></div>
1280
- <div class="jf-err" id="jf-err-mcp" data-testid="jf-err-mcp"></div>
1281
1282
  </div>
1282
1283
  <div class="field" id="jf-sched-field" data-testid="jf-sched-field">
1283
1284
  <label for="jf-sched">Schedule</label>
@@ -1928,10 +1929,12 @@
1928
1929
  // M4c-fix amendment 2 (g): a step's own sign + word come from the SAME one table the run rows use (the server's
1929
1930
  // SIGN_WORDS, sent on the run detail as `signWords`); the page keeps no table of its own. Not started: no sign.
1930
1931
  var signWords = {};
1931
- var STEP_SIGN = { done: "[\u2713]", stopped: "[\u2717]", waiting: "[\u00b7]", "user-stopped": "[\u25a0]" };
1932
- function stateWord(state){
1932
+ var STEP_SIGN = { done: "[\u2713]", stopped: "[\u2717]", waiting: "[\u00b7]", "user-stopped": "[\u25a0]", capped: "[\u25a0]" };
1933
+ function stateWord(state, text){
1933
1934
  if(state === "pending") return "not started";
1935
+ if(state === "noted") return text || state; // M20 am9a: no sign; the server's word for the last row (the owner's)
1934
1936
  var g = STEP_SIGN[state];
1937
+ if(state === "capped") return g + " " + state; // the state value IS the server's word for a cap-halt step (the table's)
1935
1938
  return g && signWords[g] ? g + " " + signWords[g] : state;
1936
1939
  }
1937
1940
  // fwdloop's close-class vocabulary (M4a scope item 4): `green` -> "cited"
@@ -1973,47 +1976,8 @@
1973
1976
  bits.push("cache-read " + (typeof spendSummary.cacheReadTokens === "number" ? spendSummary.cacheReadTokens : "unknown"));
1974
1977
  return bits.join(" &middot; ");
1975
1978
  }
1976
- // An attempt's real verdict vocabulary is wider than green/hitl/not-done
1977
- // (src/runner.js also writes `paused`, `refused`, `ask-timeout`,
1978
- // `ask-expired`, `red`, `crash`-like stops) — and the scope forbids
1979
- // rendering the raw words green/red/softgreen anywhere (coordinator's
1980
- // browser-walk fix #2). `verdictWord`/`verdictGlyph` are the ONE place
1981
- // that turns a verdict (plus the step's own close class, for telling a
1982
- // human's redo apart from a mechanical red) into plain words and a
1983
- // pass/fail glyph — used by the step cards, the map's inline attempt
1984
- // text, and the flat Audit table alike, so they can never say something
1985
- // different for the same row.
1986
- // - `paused`/`refused`/an ask timeout/expiry are NOT failures (fix #3) —
1987
- // no ✗, a plain word instead.
1988
- // - a `red` verdict on a `hitl`-classed step is the human's own redo
1989
- // (src/runner.js's redo path), not a mechanical stop — "redo by
1990
- // you: <reason>", never "verdict red" / a fail glyph (fix #3).
1991
- function verdictWord(verdict, closeClass, gap){
1992
- if(closeClass === "hitl" && verdict === "red") return "redo by you" + (gap ? ": " + gap : "");
1993
- if(verdict === "paused") return "paused for you";
1994
- if(verdict === "refused") return "refused — no reason given";
1995
- if(verdict === "ask-timeout" || verdict === "ask-expired") return "expired waiting for you";
1996
- if(verdict === "ask-reopened") return "reopened by you";
1997
- if(verdict === "lock-removed") return "old lock removed by you";
1998
- if(verdict === "stop-asked") return "stop asked by you";
1999
- if(verdict === "stopped") return "stopped by you";
2000
- if(verdict === "stop-not-honoured") return "stop not honoured";
2001
- if(verdict === "green") return "passed";
2002
- if(verdict === "hitl") return "human check";
2003
- if(verdict === "not-done") return "not done";
2004
- if(typeof verdict !== "string") return "unknown";
2005
- return "failed"; // red (non-hitl), crash-like, cap-halt, pricing/provider-red, unparseable, ...
2006
- }
2007
- function verdictPassed(verdict){ return verdict === "green" || verdict === "hitl"; }
2008
- // `null` — no glyph at all — for a verdict that is neither a pass nor a
2009
- // fail (paused/refused/expired/a human redo); a bare attempt glyph
2010
- // would misread a pause as a failure (fix #3).
2011
- function verdictGlyph(verdict, closeClass){
2012
- if(closeClass === "hitl" && verdict === "red") return null;
2013
- if(verdict === "paused" || verdict === "refused" || verdict === "ask-timeout" || verdict === "ask-expired" || verdict === "ask-reopened" || verdict === "lock-removed") return null;
2014
- if(verdict === "stop-asked" || verdict === "stopped" || verdict === "stop-not-honoured") return null; // amendment 7 item 8: a Stop is neither a pass nor a failure
2015
- return verdictPassed(verdict) ? "✓" : "✗";
2016
- }
1979
+ // M20 am9: the page derives no word or sign from a verdict. The server hands every Audit row its `sign` (null = none) and `word`, and every try its mark,
1980
+ // from the one table (src/books.js ENDINGS, `auditSignWord`): the step cards, the map's attempt text and the flat Audit table all draw those fields.
2017
1981
  // The run-row glyph strings src/panel/data.js's computeGlyph emits are
2018
1982
  // already bracketed ("[✓]", "[✗]", "[·]", "[▶]", "[?]") — this only ever picks a
2019
1983
  // CSS color class off them, never re-derives the glyph itself.
@@ -2090,7 +2054,7 @@
2090
2054
  toolsTotal: s.toolsTotal || null, toolsWhy: s.toolsWhy || null, ungranted: s.ungranted || [],
2091
2055
  stoppedReason: s.stoppedReason || null,
2092
2056
  who: s.who || null, newLine: typeof s.newLine === "string" ? s.newLine : "\u2014", lastAnswerAt: s.lastAnswerAt || null,
2093
- state: s.groupState || "pending", // the server's one decider (deriveStepGroupState); no group = no row yet = not started
2057
+ stateText: s.groupText || null, state: s.groupState || "pending", // the server's one decider (deriveStepGroupState); no group = no row yet = not started
2094
2058
  };
2095
2059
  });
2096
2060
  }
@@ -2103,7 +2067,7 @@
2103
2067
  var tries = boxRetryTry(s);
2104
2068
  var cls = "map-chip s-" + String(s.state).replace(/[^a-z-]/g, "") + (tries ? " retry" : "");
2105
2069
  var name = escapeXml(stepTitleText(idx, s));
2106
- var state = escapeXml(s.noRecord ? "no draft record" : stateWord(s.state));
2070
+ var state = escapeXml(s.noRecord ? "no draft record" : stateWord(s.state, s.stateText));
2107
2071
  // hamr review #4: each box is a clickable button tagged with the step's own `emits` id — the click listener that
2108
2072
  // jumps to the Audit tab's matching group is wired AFTER insertion (wireMapClicks), never inline here.
2109
2073
  var chip = '<button type="button" class="' + cls + ' map-step" data-emits="' + escapeXml(s.emits) + '"' + (tries ? ' data-retry="' + tries + '"' : '') +
@@ -3366,7 +3330,7 @@
3366
3330
  var stateBadge = document.createElement("span");
3367
3331
  stateBadge.className = "badge " + auditStateClass(box.state) + (STEP_SIGN[box.state] ? " sign-badge" : "");
3368
3332
  stateBadge.setAttribute("data-testid", "step-card-state-" + idx);
3369
- stateBadge.textContent = stateWord(box.state);
3333
+ stateBadge.textContent = stateWord(box.state, box.stateText);
3370
3334
  head.appendChild(stateBadge);
3371
3335
  var closeBadge = document.createElement("span");
3372
3336
  closeBadge.className = "badge cyan";
@@ -3517,9 +3481,9 @@
3517
3481
  function auditThinkingHtml(r){ return typeof r.thinkingPhrase === "string" && r.thinkingPhrase.length > 0 ? " \u00b7 " + escapeXml(r.thinkingPhrase) : ""; }
3518
3482
  function buildAuditRowEl(r, includeStep){
3519
3483
  var tr = document.createElement("tr");
3520
- var glyph = verdictGlyph(r.verdict, r.class);
3521
- var word = verdictWord(r.verdict, r.class, r.gap);
3522
- var isRejectRow = r.class === "hitl" && r.verdict === "red";
3484
+ var glyph = r.sign;
3485
+ var word = r.word;
3486
+ var isRejectRow = r.class === "hitl" && r.verdict === "red" && r.action === "human"; // the person's redo (the server's `action`); a model's red keeps its gap
3523
3487
  var badgeClass = glyph === "✓" ? "green" : (glyph === "✗" ? "red" : "amber");
3524
3488
  var action = typeof r.action === "string" && r.action.length > 0 ? r.action : r.verdict; // server always sets `action` (deriveAuditAction); this fallback is belt-and-braces only
3525
3489
  // Amendment M4a-3: append this row's own tool tally to the Action cell,
@@ -3622,7 +3586,7 @@
3622
3586
  var passed = ds.ended === "done";
3623
3587
  return {status: passed ? stateWord("done") : "not signed", state: passed ? "done" : "pending", signed: true, name: "drafting", dot: AUDIT_DOT, draftFigs: draftFigures(ds).concat([draftHumanWord(ds)]), passed: passed};
3624
3588
  }
3625
- var parts = {status: stateWord(g.state), state: g.state, signed: true, dot: AUDIT_DOT, name: g.step, cost: g.cost || "cost unknown"};
3589
+ var parts = {status: stateWord(g.state, g.stateText), state: g.state, signed: true, dot: AUDIT_DOT, name: g.step, cost: g.cost || "cost unknown"};
3626
3590
  if(!g.run) parts.tries = {n: g.tryCount, marks: g.tryMarks}; // the run's own group has no tries
3627
3591
  return parts;
3628
3592
  }
@@ -3672,7 +3636,7 @@
3672
3636
  var p = auditGroupHeaderParts(g);
3673
3637
  if(p.status !== null){
3674
3638
  var stateSpan = document.createElement("span");
3675
- stateSpan.className = "badge " + auditStateClass(p.state) + " sign-badge";
3639
+ stateSpan.className = "badge " + auditStateClass(p.state) + (p.state === "noted" ? "" : " sign-badge");
3676
3640
  stateSpan.setAttribute("data-testid", "audit-group-state");
3677
3641
  var signEnd = p.status.indexOf(" ");
3678
3642
  if(p.state === "done" && p.status.charAt(0) === "[" && signEnd > 0){
@@ -6350,8 +6314,7 @@
6350
6314
  mcpServers = names; paintMcpOptions();
6351
6315
  }, function(){ /* the list stays as it was; a pick the server cannot start is refused with its cause */ });
6352
6316
  }
6353
- flowTypeEl.addEventListener("change", function(){ paintFlowType(); byId("jf-err-flowType").textContent = ""; byId("jf-err-mcp").textContent = ""; refreshStartEnabled(); });
6354
- mcpEl.addEventListener("change", function(){ byId("jf-err-mcp").textContent = ""; });
6317
+ flowTypeEl.addEventListener("change", function(){ paintFlowType(); byId("jf-err-flowType").textContent = ""; refreshStartEnabled(); });
6355
6318
  schedEl.addEventListener("change", function(){ paintSchedule(); byId("jf-err-schedule").textContent = ""; });
6356
6319
  schedTimeEl.addEventListener("input", function(){ byId("jf-err-schedule").textContent = ""; });
6357
6320
  ["jf-sched-day", "jf-sched-role"].forEach(function(id){ byId(id).addEventListener("change", function(){ byId("jf-err-schedule").textContent = ""; }); });
@@ -25,7 +25,7 @@ export const PLAN_CHECK_RULES = Object.freeze([
25
25
  { re: /send at line \d+ .* is not granted a catalogue primitive of class "write"/, say: 'Your last line sends to your Destination, but your job puts other work on it. Make your last line the one that sends, or move that work above it, then Draft again.', fix: 'Make your last line the one that sends, or move that work above it, then Draft again.', first: true },
26
26
  { re: /send at line \d+|signed send at line|send slot/, say: 'The send step is not set up to follow your accept and write only to your destination.', fix: 'Check the Destination on the card, then Draft again.' },
27
27
  { re: /hitl after the last signed ask/, say: 'A step after your last ask would leave without your seeing it, so it is refused.', fix: 'Move the lines you want to check before your last Ask line, then Draft again.' },
28
- { re: /is a pause .* unsigned line/, say: 'A step pauses at a line you did not sign as an ask.', fix: 'Mark the line you want to stop at with Ask, then Draft again.' },
28
+ { re: /is a pause .* unsigned line/, say: 'A step in the plan has nothing to do at one of your lines.', fix: 'Draft again. If you want the run to stop for you at that line, start the line with Ask.' },
29
29
  { re: /neither served by any step/, say: 'A line of your job is not covered by any step.', fix: 'Make every line of your job say one thing to do, then Draft again.' },
30
30
  { re: /picks|inputFacts|invented name/, say: 'The plan names a field that is not in your input.', fix: 'Check the names in your Inputs and job line, then Draft again.' },
31
31
  { re: /guardrailClasses|unjudgeable|refused/, say: "The AI's notes on which lines it can check are not in a form the checker accepts.", fix: 'Draft again.' },
package/types/books.d.ts CHANGED
@@ -161,8 +161,20 @@ export function readHistory(flowDir: string): any[];
161
161
  * @param {any} logJson the run's log.json (or null) @param {any[]} auditRows @returns {string|null}
162
162
  */
163
163
  export function redWhyOf(logJson: any, auditRows: any[]): string | null;
164
- /** the Runs list's bold word for an ending (`null` for none); `resumable` false asks the word of a run that cannot be continued @param {string} w @param {boolean} [resumable] @returns {string|null} */
165
- export function endingWord(w: string, resumable?: boolean): string | null;
164
+ /** the Runs list's bold word for an ending (`null` for none) @param {string} w @returns {string|null} */
165
+ export function endingWord(w: string): string | null;
166
+ /**
167
+ * M20 am9 / am9b: the ONE owner of an Audit row's sign, word and try mark. `closeClass`, `gap` and `human` (the row is the Ask's own, `isAskRow`) are its inputs: a `red` on a
168
+ * `hitl` step that the person wrote is their redo, no sign, "redo by you: <gap>" (mark ✗); the same red written by a model is a plain red, failed ✗. A verdict that is not a string reads "unknown" ✗; a verdict with no `audit` column (a run-only ending, or a word the table
169
+ * does not hold) reads failed ✗, as the page always drew it.
170
+ * @param {unknown} verdict @param {string|null|undefined} [closeClass] @param {string|null|undefined} [gap] @param {boolean} [human]
171
+ * @returns {{sign: '✓'|'✗'|'■'|null, word: string, mark: '✓'|'✗'|'·'|'■'}}
172
+ */
173
+ export function auditSignWord(verdict: unknown, closeClass?: string | null | undefined, gap?: string | null | undefined, human?: boolean): {
174
+ sign: "\u2713" | "\u2717" | "\u25A0" | null;
175
+ word: string;
176
+ mark: "\u2713" | "\u2717" | "\u00B7" | "\u25A0";
177
+ };
166
178
  /**
167
179
  * The ONE rule for "how did this run end": the LAST history row of the run (a run that was stopped or cap-halted and
168
180
  * continued has one row per leg; history stays append-only). `null` when the run has no row yet, and also while a
@@ -238,7 +250,9 @@ export const HALT_FILE: "halt.json";
238
250
  * draftRow a verdict a drafting row of the Audit can carry (anything else reads not-done)
239
251
  * notRunEnd not an end of a run (a pause, a failed stop, a skipped ticket): learnings wait
240
252
  * word the Runs list's bold word for it (`null` = none: a run the human ended with rerun)
241
- * wordUnresumed its word when the run cannot be continued (M20 am1 item 9: a cap-halt with no usable halt.json reads "capped")
253
+ * audit M20 am9: what an Audit row of this verdict shows: `sign` (`null` = none), `word` and the try `mark` it gives its try. The run's `word` and the Audit's
254
+ * differ (ask-expired reads "expired" on the run, "expired waiting for you" on the row), so they are two columns; read it through `auditSignWord`
255
+ * runOnly an ending of a run only, never a verdict of an Audit row (no `audit` column); `auditSignWord` treats it like a word the table does not hold: failed, ✗
242
256
  * Outcome (history.jsonl) and verdict (audit.jsonl) are not split: one word means one thing on either book.
243
257
  * Not here, by design: the scheduler's own words (busy, monthly-exhausted, refused fire), the closers' verdicts (done, crash,
244
258
  * unparseable), and the Run tab's ending sentences (src/summary-words.js stays their one owner).
@@ -248,11 +262,13 @@ export const ENDINGS: Readonly<{
248
262
  good: boolean;
249
263
  notFailed: boolean;
250
264
  word: string;
265
+ runOnly: boolean;
251
266
  };
252
267
  skipped: {
253
268
  notFailed: boolean;
254
269
  notRunEnd: boolean;
255
270
  word: string;
271
+ runOnly: boolean;
256
272
  };
257
273
  stopped: {
258
274
  resumable: boolean;
@@ -260,6 +276,11 @@ export const ENDINGS: Readonly<{
260
276
  open: boolean;
261
277
  humanNo: boolean;
262
278
  word: string;
279
+ audit: {
280
+ sign: null;
281
+ word: string;
282
+ mark: string;
283
+ };
263
284
  };
264
285
  'cap-halt': {
265
286
  resumable: boolean;
@@ -267,28 +288,48 @@ export const ENDINGS: Readonly<{
267
288
  blocked: boolean;
268
289
  spendFloor: boolean;
269
290
  word: string;
270
- wordUnresumed: string;
291
+ audit: {
292
+ sign: string;
293
+ word: string;
294
+ mark: string;
295
+ };
271
296
  };
272
297
  rerun: {
273
298
  notFailed: boolean;
274
299
  word: null;
300
+ runOnly: boolean;
275
301
  };
276
302
  'ask-expired': {
277
303
  notFailed: boolean;
278
304
  blocked: boolean;
279
305
  open: boolean;
280
306
  word: string;
307
+ audit: {
308
+ sign: null;
309
+ word: string;
310
+ mark: string;
311
+ };
281
312
  };
282
313
  'ask-timeout': {
283
314
  blocked: boolean;
284
315
  open: boolean;
285
316
  word: string;
317
+ audit: {
318
+ sign: null;
319
+ word: string;
320
+ mark: string;
321
+ };
286
322
  };
287
323
  refused: {
288
324
  blocked: boolean;
289
325
  open: boolean;
290
326
  waiting: boolean;
291
327
  word: string;
328
+ audit: {
329
+ sign: null;
330
+ word: string;
331
+ mark: string;
332
+ };
292
333
  };
293
334
  red: {
294
335
  blocked: boolean;
@@ -297,78 +338,160 @@ export const ENDINGS: Readonly<{
297
338
  tryVerdict: boolean;
298
339
  draftRow: boolean;
299
340
  word: string;
341
+ audit: {
342
+ sign: string;
343
+ word: string;
344
+ mark: string;
345
+ };
300
346
  };
301
347
  'not-done': {
302
348
  blocked: boolean;
303
349
  redTry: boolean;
304
350
  tryVerdict: boolean;
305
351
  word: string;
352
+ audit: {
353
+ sign: string;
354
+ word: string;
355
+ mark: string;
356
+ };
306
357
  };
307
358
  'provider-red': {
308
359
  blocked: boolean;
309
360
  noise: boolean;
310
361
  spendFloor: boolean;
311
362
  word: string;
363
+ audit: {
364
+ sign: string;
365
+ word: string;
366
+ mark: string;
367
+ };
312
368
  };
313
369
  'pricing-red': {
314
370
  blocked: boolean;
315
371
  spendFloor: boolean;
316
372
  word: string;
373
+ audit: {
374
+ sign: string;
375
+ word: string;
376
+ mark: string;
377
+ };
317
378
  };
318
379
  'close-casualty': {
319
380
  blocked: boolean;
320
381
  noise: boolean;
321
382
  word: string;
383
+ audit: {
384
+ sign: string;
385
+ word: string;
386
+ mark: string;
387
+ };
322
388
  };
323
389
  'preflight-red': {
324
390
  word: string;
391
+ runOnly: boolean;
325
392
  };
326
393
  'struck-out': {
327
394
  word: string;
395
+ runOnly: boolean;
328
396
  };
329
397
  'attempt-fallback': {
330
398
  word: string;
399
+ runOnly: boolean;
331
400
  };
332
401
  'redo-halt': {
333
402
  word: string;
403
+ runOnly: boolean;
334
404
  };
335
405
  'stop-failed': {
336
406
  notRunEnd: boolean;
337
407
  word: string;
408
+ runOnly: boolean;
338
409
  };
339
410
  green: {
340
411
  good: boolean;
341
412
  tryVerdict: boolean;
342
413
  draftRow: boolean;
414
+ audit: {
415
+ sign: string;
416
+ word: string;
417
+ mark: string;
418
+ };
343
419
  };
344
420
  hitl: {
345
421
  good: boolean;
346
422
  tryVerdict: boolean;
423
+ audit: {
424
+ sign: string;
425
+ word: string;
426
+ mark: string;
427
+ };
347
428
  };
348
429
  softgreen: {
349
430
  tryVerdict: boolean;
431
+ audit: {
432
+ sign: string;
433
+ word: string;
434
+ mark: string;
435
+ };
350
436
  };
351
437
  paused: {
352
438
  open: boolean;
353
439
  waiting: boolean;
354
440
  notRunEnd: boolean;
441
+ audit: {
442
+ sign: null;
443
+ word: string;
444
+ mark: string;
445
+ };
355
446
  };
356
447
  'ask-reopened': {
357
448
  open: boolean;
449
+ audit: {
450
+ sign: null;
451
+ word: string;
452
+ mark: string;
453
+ };
358
454
  };
359
455
  'lock-removed': {
360
456
  open: boolean;
457
+ audit: {
458
+ sign: null;
459
+ word: string;
460
+ mark: string;
461
+ };
361
462
  };
362
463
  'stop-asked': {
363
464
  open: boolean;
364
465
  stopNote: boolean;
466
+ audit: {
467
+ sign: null;
468
+ word: string;
469
+ mark: string;
470
+ };
365
471
  };
366
472
  'stop-not-honoured': {
367
473
  open: boolean;
368
474
  stopNote: boolean;
475
+ audit: {
476
+ sign: null;
477
+ word: string;
478
+ mark: string;
479
+ };
480
+ };
481
+ 'stale-answer-ignored': {
482
+ audit: {
483
+ sign: string;
484
+ word: string;
485
+ mark: string;
486
+ };
487
+ };
488
+ 'answer-after-run': {
489
+ audit: {
490
+ sign: string;
491
+ word: string;
492
+ mark: string;
493
+ };
369
494
  };
370
- 'stale-answer-ignored': {};
371
- 'answer-after-run': {};
372
495
  }>;
373
496
  export function isGoodEnding(w: unknown): boolean;
374
497
  export function isFailedEnding(w: unknown): boolean;
@@ -384,3 +507,4 @@ export function isSpendFloorEnding(w: unknown): boolean;
384
507
  export function isDraftRowVerdict(w: unknown): boolean;
385
508
  export function isNotRunEnd(w: unknown): boolean;
386
509
  export function isResumableEnding(w: unknown): boolean;
510
+ export function isAskRow(row: any): boolean;
package/types/inside.d.ts CHANGED
@@ -12,13 +12,19 @@
12
12
  * (never a red) so every existing caller keeps its own "not written yet"
13
13
  * behaviour unchanged.
14
14
  *
15
+ * `fast` (M20 am9f, change stamps only): skip the realpath checks, keep the symlink refusal. The caller only lists or stamps (never opens) what comes back.
15
16
  * @param {string} baseDir
16
17
  * @param {string} relPath
17
- * @returns {{ok:true, full:string}|{ok:false, missing:true}|{ok:false, missing:false, red:string}}
18
+ * @param {boolean} [fast]
19
+ * @returns {{ok:true, full:string, stat:{size:number, mtimeMs:number}}|{ok:false, missing:true}|{ok:false, missing:false, red:string}}
18
20
  */
19
- export function resolveInside(baseDir: string, relPath: string): {
21
+ export function resolveInside(baseDir: string, relPath: string, fast?: boolean): {
20
22
  ok: true;
21
23
  full: string;
24
+ stat: {
25
+ size: number;
26
+ mtimeMs: number;
27
+ };
22
28
  } | {
23
29
  ok: false;
24
30
  missing: true;
@@ -53,6 +59,13 @@ export function readFileInside(baseDir: string, relPath: string): {
53
59
  * would escape `baseDir`. `[]` when `relDir` doesn't exist.
54
60
  * @param {string} baseDir
55
61
  * @param {string} relDir
62
+ * @param {boolean} [fast] see `resolveInside`
56
63
  * @returns {string[]}
57
64
  */
58
- export function readdirInside(baseDir: string, relDir: string): string[];
65
+ export function readdirInside(baseDir: string, relDir: string, fast?: boolean): string[];
66
+ /**
67
+ * M20 am9f: one string that changes when any file in `dirs` (folders of `baseDir`, `.` for itself) is written, replaced, renamed or removed: every entry's name, size and mtime.
68
+ * It only lists and stats through `resolveInside`'s `fast` form (a symlink reads `-`, nothing is opened); a missing folder adds nothing.
69
+ * @param {string} baseDir @param {string[]} dirs @returns {string}
70
+ */
71
+ export function stampsInside(baseDir: string, dirs: string[]): string;
@@ -86,12 +86,11 @@ export function deriveResumeState({ savedAnswer: savedOnDisk, attempt, ask }: {
86
86
  * opens with the word ("stuck — …") or is the word itself ("passed") loses that repeat, so it is never said twice.
87
87
  * `noWord`: a run the human ended on purpose with rerun wears `[✗]` but is never called "failed" (M4b amendment 3),
88
88
  * so it shows its plain line alone.
89
- * @param {string} glyph a `computeGlyph` sign @param {string} label its plain line @param {boolean} [noWord] @param {{outcome: string|null|undefined, resumable: boolean}|null} [ending] the run's end row outcome and whether it can be continued
89
+ * @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
90
90
  * @returns {{word: string|null, line: string|null}}
91
91
  */
92
92
  export function signParts(glyph: string, label: string, noWord?: boolean, ending?: {
93
93
  outcome: string | null | undefined;
94
- resumable: boolean;
95
94
  } | null): {
96
95
  word: string | null;
97
96
  line: string | null;
@@ -344,11 +343,11 @@ export function isBlockedVerdict(verdict: string | null | undefined): boolean;
344
343
  * open, not resolved).
345
344
  * @param {string|null} closeClass
346
345
  * @param {Array<{verdict:string}>} rows one step's own audit rows, book order
347
- * @returns {Array<'✓'|'✗'|'·'>}
346
+ * @returns {Array<'✓'|'✗'|'·'|'■'>}
348
347
  */
349
348
  export function deriveStepTryMarks(closeClass: string | null, rows: Array<{
350
349
  verdict: string;
351
- }>): Array<"\u2713" | "\u2717" | "\u00B7">;
350
+ }>): Array<"\u2713" | "\u2717" | "\u00B7" | "\u25A0">;
352
351
  /**
353
352
  * A step group's own state word for the Audit tab's collapsed header —
354
353
  * the ONE decider of a step's state: the Run tab's map and cards read it too
@@ -359,12 +358,22 @@ export function deriveStepTryMarks(closeClass: string | null, rows: Array<{
359
358
  * the human asked), `stopped` (the last attempt failed for any other reason). A group only
360
359
  * ever exists for a step with at least one row, so `pending` never appears
361
360
  * here (unlike the Run tab's map, which also covers never-attempted steps).
362
- * @param {Array<{verdict:string}>} rows one step's own audit rows, book order
363
- * @returns {'done'|'waiting'|'stopped'|'user-stopped'}
361
+ * @param {Array<{verdict:string, class?: string|null, gap?: string|null}>} rows one step's own audit rows, book order
362
+ * `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").
363
+ * `capped` (M20 am9 item 2: the step's own last row is a `cap-halt`; the word is the table's, `endingWord('cap-halt')`).
364
+ * @returns {string} `done`, `waiting`, `stopped`, `user-stopped`, `noted`, or the table's word for a cap-halt
364
365
  */
365
366
  export function deriveStepGroupState(rows: Array<{
366
367
  verdict: string;
367
- }>): "done" | "waiting" | "stopped" | "user-stopped";
368
+ class?: string | null;
369
+ gap?: string | null;
370
+ }>): string;
371
+ /** 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 */
372
+ export function groupStateText(rows: Array<{
373
+ verdict: string;
374
+ class?: string | null;
375
+ gap?: string | null;
376
+ }>): string | null;
368
377
  /**
369
378
  * hamr's 2026-09-27 exit-check review #1: the Audit tab's grouped-by-step
370
379
  * header pieces, computed HERE (server-side) so `src/panel/index.html` only