bareloop 0.57.0 → 0.58.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 (49) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/bareloop.context.md +11 -8
  3. package/package.json +1 -1
  4. package/src/authorflow.js +50 -62
  5. package/src/authorjob.js +100 -30
  6. package/src/authorreadout.js +88 -0
  7. package/src/authorrun.js +63 -24
  8. package/src/authorscout.js +9 -1
  9. package/src/blockasks.js +11 -16
  10. package/src/checkblock.js +227 -31
  11. package/src/checkpick.js +0 -5
  12. package/src/declaredclose.js +38 -6
  13. package/src/draftspend.js +20 -4
  14. package/src/fencepointcall.js +76 -0
  15. package/src/guarddescriptions.js +14 -0
  16. package/src/kinds.js +5 -1
  17. package/src/pagemap.js +7 -29
  18. package/src/panel/authorroutes.js +6 -1
  19. package/src/panel/authorsession.js +108 -32
  20. package/src/panel/index.html +38 -13
  21. package/src/panel/jobplan.js +49 -16
  22. package/src/panel/server.js +66 -6
  23. package/src/planrun.js +2 -0
  24. package/src/promptregisters.js +5 -0
  25. package/src/questionbox.js +32 -20
  26. package/src/reviewdoor.js +1 -1
  27. package/src/rowresults.js +69 -0
  28. package/src/rubricstep.js +110 -22
  29. package/src/stagewords.js +24 -0
  30. package/types/authorflow.d.ts +42 -79
  31. package/types/authorjob.d.ts +3 -2
  32. package/types/authorreadout.d.ts +44 -0
  33. package/types/authorrun.d.ts +20 -0
  34. package/types/blockasks.d.ts +5 -10
  35. package/types/checkblock.d.ts +115 -11
  36. package/types/checkpick.d.ts +0 -3
  37. package/types/declaredclose.d.ts +3 -1
  38. package/types/draftspend.d.ts +16 -2
  39. package/types/fencepointcall.d.ts +68 -0
  40. package/types/guarddescriptions.d.ts +7 -0
  41. package/types/kinds.d.ts +1 -0
  42. package/types/pagemap.d.ts +2 -5
  43. package/types/panel/authorsession.d.ts +3 -2
  44. package/types/panel/jobplan.d.ts +13 -1
  45. package/types/panel/server.d.ts +41 -16
  46. package/types/questionbox.d.ts +20 -6
  47. package/types/rowresults.d.ts +23 -0
  48. package/types/rubricstep.d.ts +34 -7
  49. package/types/stagewords.d.ts +11 -0
@@ -1,9 +1,9 @@
1
1
  // The question box of the drafting chat (hamr 2026-11-12, as fwdloop M10 am29/am30/am31): a question asked while drafting gets its own box in the panel, with the question,
2
- // its own buttons where the question offers choices (the person's intent is a typed choice, never words read), and one line to type in. This file is the ONE owner of what the
2
+ // its own buttons (the person's intent is a typed choice, never words read). A check question (a look's reading, a proposed check) is BUTTONS ONLY (hamr 2026-11-15): no box to type in; a rule is changed by Revise.
3
+ // The drafter's own try-3 questions and the Destination question have no button to answer with, so they keep one line to type in. This file is the ONE owner of what the
3
4
  // panel shows for a pending question and of which choices a question offers (the page draws it, never works it out). The CLI (src/authorrun.js) is a sibling caller of the same
4
5
  // questions and keeps typing words; the stored question text never changes, only the panel's copy of it is cut.
5
- import { readingTail, cantCheckTail, DROP_IT } from './pagemap.js';
6
- import { HOW_TO_ANSWER } from './checkpick.js';
6
+ import { DROP_IT } from './pagemap.js';
7
7
  import { DEST_ANSWER } from './destpoint.js';
8
8
 
9
9
  /** the door's refusals, word for word (fwd am31); a refusal leaves the question open and writes nothing */
@@ -11,40 +11,48 @@ export const CHOICE_SAYS = Object.freeze({
11
11
  bad: 'That answer is not one of the choices. Nothing was saved.',
12
12
  notOffered: 'That choice is not offered for this question. Nothing was saved.',
13
13
  outOfDate: 'This page is out of date. Reload it and answer again. Nothing was saved.',
14
- noRule:'That question is about the job line, not one of your ~ rules, so there is nothing to drop. Agree, or type your own words. Nothing was saved.',
14
+ noRule:'That question is about the job line, not one of your ~ rules, so there is nothing to drop. Nothing was saved.',
15
15
  blank: 'An answer is needed here — there is no skip. Type it in the box and press Send.',
16
16
  });
17
17
 
18
18
  /**
19
19
  * Which buttons a look question offers. Agree only when it carries a proposal (a reading ask with its reading, a check-pick ask with its check); Drop it only where "drop it" leaves
20
- * one of the person's own `~` rules Not checked (a can't-check ask or a check-pick ask about a rule number).
20
+ * one of the person's own `~` rules Not checked (a reading or check-pick ask about a rule number). A rule with nothing to agree to is not asked at all (src/checkblock.js).
21
21
  * @param {{source?: string, ask?: string, reading?: unknown, check?: unknown, rule?: unknown}} q @returns {{agree: boolean, drop: boolean}}
22
22
  */
23
23
  export function offersOf(q) {
24
24
  const look = q.source === 'look';
25
25
  const agree = look && ((q.ask === 'reading' && typeof q.reading === 'string') || (q.ask === 'check' && q.check !== null && typeof q.check === 'object'));
26
- const drop = look && Number.isInteger(q.rule) && (q.ask === 'cant-check' || q.ask === 'check' || q.ask === 'no-check');
26
+ const drop = look && Number.isInteger(q.rule) && (q.ask === 'check' || q.ask === 'reading');
27
27
  return { agree, drop };
28
28
  }
29
29
 
30
30
  /**
31
- * A look question as the PANEL shows it: the code's own answer words (`Answer "agree"...` / `Answer "drop it"...`) cut off the end, because the buttons and the box say it.
32
- * Only the known tails are cut, matched exactly as a suffix (never a pattern over the prose); a question that ends in none of them is returned whole.
31
+ * A question as the PANEL shows it: the Destination question's own typed-answer words (`DEST_ANSWER`) cut off the end, because its buttons and box say it. A look question carries no answer words
32
+ * (its buttons say it); it is returned whole. Only the known tail is cut, matched exactly as a suffix (never a pattern over the prose).
33
33
  * @param {{question: string, line?: number, source?: string}} q @returns {string}
34
34
  */
35
35
  export function panelQuestionText(q) {
36
36
  const text = String(q.question);
37
37
  if (q.source === 'dest-point') return text.endsWith(DEST_ANSWER) ? text.slice(0, text.length - DEST_ANSWER.length) : text;
38
- if (q.source !== 'look' || !Number.isInteger(q.line)) return text;
39
- const n = /** @type {number} */ (q.line);
40
- const hit = [readingTail(n), cantCheckTail(n), ` ${HOW_TO_ANSWER(n, true)}`, ` ${HOW_TO_ANSWER(n, false)}`].find((t) => text.endsWith(t));
41
- return hit === undefined ? text : text.slice(0, text.length - hit.length);
38
+ return text;
39
+ }
40
+
41
+ /**
42
+ * What a try-3 answer DOES, in the words the ask shows (Addendum 2026-11-14 (c) piece 5): `replaces` = the old words of the `~` rule the answer replaces; `adds` = the answer is a new rule of the line.
43
+ * Null when the question says neither (a code-forced look question has its own words). ONE owner: the panel's box, its chat line and the CLI print it.
44
+ * @param {{replaces?: unknown, adds?: unknown, line?: unknown}} step @returns {string|null}
45
+ */
46
+ export function answerEffectWords(step) {
47
+ if (typeof step.replaces === 'string' && step.replaces !== '') return `This replaces: ${step.replaces}`;
48
+ if (step.adds === true && Number.isInteger(step.line)) return `This adds a new rule to line ${step.line}`;
49
+ return null;
42
50
  }
43
51
 
44
52
  /**
45
53
  * What the panel's question box shows for one pending ask. Only a question the person answers (`kind: 'answer'`) has a box; every other ask (language, menu, install)
46
54
  * keeps the chat input. `sendChoice` = the choice the box's own Send posts.
47
- * @param {{kind: string, source?: string, index?: number, total?: number, question?: string, line?: number, offers?: {agree: boolean, drop: boolean}, folder?: string, current?: string}} step
55
+ * @param {{kind: string, source?: string, ask?: string, index?: number, total?: number, question?: string, line?: number, offers?: {agree: boolean, drop: boolean}, folder?: string, current?: string, replaces?: string, adds?: boolean}} step
48
56
  * @returns {{head: string, line: string, text: string, choices: {choice: string, label: string}[], orLabel: string|null, sendChoice: string}|null}
49
57
  */
50
58
  export function boxFor(step) {
@@ -62,27 +70,31 @@ export function boxFor(step) {
62
70
  const choices = [];
63
71
  if (step.offers?.agree) choices.push({ choice: 'agree', label: 'Agree' });
64
72
  if (step.offers?.drop) choices.push({ choice: 'drop', label: 'Drop it' });
73
+ const buttonsOnly = step.source === 'look';
65
74
  return {
66
75
  head: before ? 'A question before drafting' : `A question the plan raised (${step.index ?? 1} of ${step.total ?? 1})`,
67
- line: Number.isInteger(step.line) ? `About job line ${step.line}` : '',
76
+ line: `${Number.isInteger(step.line) ? `About job line ${step.line}` : ''}${answerEffectWords(step) === null ? '' : `${Number.isInteger(step.line) ? '. ' : ''}${answerEffectWords(step)}`}`,
68
77
  text: panelQuestionText({ question: step.question, source: step.source, ...(Number.isInteger(step.line) ? { line: step.line } : {}) }),
69
78
  choices,
70
- orLabel: choices.length > 0 ? 'Or type a new rule:' : 'Type your answer:',
79
+ // a proposed-check question is buttons only (no box); a READING question also takes the person's correction (hamr 2026-11-15 ruling); the drafter's own question has no button, so it keeps the one line to type in
80
+ orLabel: buttonsOnly ? (step.ask === 'reading' ? 'Or type the right reading:' : null) : 'Type your answer:',
71
81
  sendChoice: 'rule',
72
82
  };
73
83
  }
74
84
 
75
- /** the choices each kind of question's typed answer may name */
76
- const CHOICES = { look: ['agree', 'drop', 'rule'], 'dest-point': ['yes', 'no', 'path'] };
85
+ /** the choices each kind of question's answer may name: a check question has its buttons only (hamr 2026-11-15); the drafter's own question and the Destination question keep typed words */
86
+ const CHOICES = { look: ['agree', 'drop', 'rule'], 'dest-point': ['yes', 'no', 'path'], typed: ['rule'] };
77
87
 
78
88
  /**
79
89
  * The door's check of a choice sent for the pending ask. Null = accepted; else the refusal words.
80
- * @param {{kind: string, source?: string, rule?: unknown, offers?: {agree: boolean, drop: boolean}}} step @param {unknown} choice @returns {string|null}
90
+ * @param {{kind: string, source?: string, ask?: string, rule?: unknown, offers?: {agree: boolean, drop: boolean}}} step @param {unknown} choice @returns {string|null}
81
91
  */
82
92
  export function refuseChoice(step, choice) {
83
93
  if (step.kind !== 'answer') return CHOICE_SAYS.notOffered;
84
- const own = /** @type {string[]|undefined} */ (/** @type {Record<string, string[]>} */ (CHOICES)[step.source === 'dest-point' ? step.source : 'look']);
85
- if (typeof choice !== 'string' || !(own ?? CHOICES.look).includes(choice)) return CHOICE_SAYS.bad;
94
+ const own = step.source === 'dest-point' ? CHOICES['dest-point'] : step.source === 'look' ? CHOICES.look : CHOICES.typed;
95
+ if (typeof choice !== 'string' || !own.includes(choice)) return CHOICE_SAYS.bad;
96
+ // the box's own words are for a READING question only; a proposed check has its buttons
97
+ if (choice === 'rule' && step.source === 'look' && step.ask !== 'reading') return CHOICE_SAYS.notOffered;
86
98
  if (step.source === 'dest-point') return null;
87
99
  if (choice === 'agree' && step.offers?.agree !== true) return CHOICE_SAYS.notOffered;
88
100
  if (choice === 'drop' && step.offers?.drop !== true) return step.source === 'look' && !Number.isInteger(step.rule) ? CHOICE_SAYS.noRule : CHOICE_SAYS.notOffered;
package/src/reviewdoor.js CHANGED
@@ -281,7 +281,7 @@ async function proveMechanically({ job, workdir, events, closeTimeoutMs, closeDi
281
281
  if (!seedRef) {
282
282
  return { ok: false, detail: 'this run left no seed on its spine (`close-decl.seedRef`), and a declared close measures against a seed — re-proving against a guessed baseline would grade a tree nobody chose', reading: { ran: 0, verdict: null, stage: null, stages: [] } };
283
283
  }
284
- v = await runDeclaredStages(stages, redactSecrets, { timeoutMs: closeTimeoutMs, cwd: workdir, seedRef });
284
+ v = await runDeclaredStages(stages, redactSecrets, { timeoutMs: closeTimeoutMs, cwd: workdir, seedRef, list: Array.isArray(job.closeDecl?.list) ? job.closeDecl.list : null });
285
285
  } else {
286
286
  v = await runStages(stages, redactSecrets, { timeoutMs: closeTimeoutMs, cwd: workdir, closeDir });
287
287
  }
@@ -0,0 +1,69 @@
1
+ // PER-ROW RESULTS of the one check list (Addendum 2026-11-14 (c) piece 4, hamr's pick b): each row of a rubric line gets its OWN pass or fail, from bareguard's own structured gaps for that line's step
2
+ // file, never a result shared by the line. Pure; no I/O. A gap is mapped to the ONE row that owns the check it names, by a rule that never guesses:
3
+ // p<part>-facts, item `#<r>:d<fact>:<reason>` -> the row(s) that built that fact (the signed row's `facts` names it)
4
+ // p<part>-count-min|max -> the count row that points at that part
5
+ // p<part>-<countable check> -> the row(s) that point at that part (a pick, the cited default, the numbers default, the note)
6
+ // text-present / happened -> the line's floor row
7
+ // the numbers tie (gradeStep's extra lines) -> the line's `$ numbers` row
8
+ // A gap that names no single row (a quote-level gap of a fact part: the quote carries no fact index; a part with no results at all) is NEVER spread over rows: it is returned in `unclaimed`, in plain words,
9
+ // and the line shows it as its own item. When the file itself could not be read (the floor is red), the line's other rows were not looked at: they read `unread`, never passed.
10
+ import { plainFactItem } from './facts.js';
11
+ import { plainStepGap } from './rubricstep.js';
12
+
13
+ const isRec = (/** @type {unknown} */ v) => v !== null && typeof v === 'object' && !Array.isArray(v);
14
+
15
+ /** the check kinds a row may be, for the rows a step file is judged by */
16
+ const LINE_KINDS = ['rule', 'fact', 'phrase', 'count', 'cited', 'numbers', 'note', 'floor'];
17
+
18
+ /**
19
+ * @typedef {{key: string, result: 'passed'|'failed'|'unread', why?: string}} RowResult
20
+ * @param {any[]|null|undefined} list the signed list (`closeDecl.list`) @param {{step: number, parts: any[]}} params the rubric-step stage's params
21
+ * @param {{verdict?: string, rawGaps?: any[], extraGaps?: string[], detail?: Record<string, any>}} graded `gradeStep`'s answer
22
+ * @returns {{rows: RowResult[], unclaimed: string[]}}
23
+ */
24
+ export function rowResultsOf(list, params, graded) {
25
+ const n = params.step;
26
+ const rows = (Array.isArray(list) ? list : []).filter((/** @type {any} */ r) => isRec(r) && r.line === n && r.state === 'built' && LINE_KINDS.includes(r.kind));
27
+ /** @type {Map<string, string[]>} the plain reasons each red row has */
28
+ const red = new Map();
29
+ /** @type {string[]} */
30
+ const unclaimed = [];
31
+ const hit = (/** @type {any} */ r, /** @type {string} */ why) => red.set(r.key, [...(red.get(r.key) ?? []), why]);
32
+ const why0 = typeof graded.detail?.why === 'string' ? graded.detail.why : 'empty';
33
+ /** the rows that carry part `pi`: a row points at its part, or a `~` rule row is named in the part's own `rules` */
34
+ const rowsOfPart = (/** @type {number} */ pi) => rows.filter((r) => r.kind !== 'floor' && ((isRec(r.part) && r.part.part === pi) || (r.kind === 'rule' && Array.isArray(params.parts[pi]?.rules) && params.parts[pi].rules.includes(r.rule))));
35
+ for (const g of graded.rawGaps ?? []) {
36
+ const id = String(g.id ?? g.check);
37
+ const plain = () => plainStepGap(n, why0, g, params).split('\n').join(' ');
38
+ if (id === 'text-present' || id === 'happened') { for (const r of rows.filter((x) => x.kind === 'floor')) hit(r, plain()); if (!rows.some((x) => x.kind === 'floor')) unclaimed.push(plain()); continue; }
39
+ const m = /^p(\d+)-(.+)$/.exec(id);
40
+ const pi = m ? Number(m[1]) - 1 : -1;
41
+ const part = params.parts[pi];
42
+ if (!m || !isRec(part)) { unclaimed.push(plain()); continue; }
43
+ if (part.class === 'fact' && m[2] === 'facts') {
44
+ const items = Array.isArray(g.items) ? g.items : [];
45
+ if (g.kind !== 'unsupported' || items.length === 0) { unclaimed.push(plain()); continue; }
46
+ for (const it of items) {
47
+ const im = /^#(\d+):d(\d+):/.exec(String(it));
48
+ const fname = im ? part.facts?.[Number(im[2])]?.name : undefined;
49
+ const owners = fname === undefined ? [] : rows.filter((r) => Array.isArray(r.facts) && r.facts.includes(fname));
50
+ if (owners.length === 0) { unclaimed.push(plainFactItem(String(it), part)); continue; }
51
+ for (const r of owners) hit(r, plainFactItem(String(it), part));
52
+ }
53
+ continue;
54
+ }
55
+ const owners = part.class === 'fact' ? rows.filter((r) => r.kind === 'count' && isRec(r.part) && r.part.part === pi) : rowsOfPart(pi);
56
+ if (owners.length === 0) { unclaimed.push(plain()); continue; }
57
+ for (const r of owners) hit(r, plain());
58
+ }
59
+ // the numbers tie of a text line (gradeStep's own lines): the line's `$ numbers` row owns it
60
+ for (const line of graded.extraGaps ?? []) {
61
+ const owner = rows.find((r) => r.kind === 'numbers');
62
+ if (owner) hit(owner, line); else unclaimed.push(line);
63
+ }
64
+ const unreadable = rows.some((r) => r.kind === 'floor' && red.has(r.key));
65
+ return {
66
+ rows: rows.map((r) => (red.has(r.key) ? { key: r.key, result: /** @type {const} */ ('failed'), why: /** @type {string[]} */ (red.get(r.key)).join(' ') } : { key: r.key, result: unreadable && r.kind !== 'floor' ? /** @type {const} */ ('unread') : /** @type {const} */ ('passed') })),
67
+ unclaimed,
68
+ };
69
+ }
package/src/rubricstep.js CHANGED
@@ -4,6 +4,8 @@ import { join, dirname } from 'node:path';
4
4
  import { createRubric, checkStep, renderGaps, numbersInQuote } from 'bareguard';
5
5
  import { dropRows, dropLine } from './pagedropwords.js';
6
6
  import { OFFERED, plainWords } from './checkwords.js';
7
+ import { GUARD_DESCRIPTIONS } from './guarddescriptions.js';
8
+ import { stageQuestionsByName, guardQuestionText, fenceQuestionText } from './stagewords.js';
7
9
  import { factPartOf, factShapeReds, factDecides, factClaims, factRows, plainFactItem, factBrief, writtenSpans } from './facts.js';
8
10
 
9
11
  // PART 1a (docs/product/ITEM33-BUILD.md, "Addendum 2026-10-12"): the rubric job on LOCAL FILES — what one job line leaves
@@ -476,7 +478,7 @@ export function plainStepGap(step, why, g, params = null) {
476
478
  * the manifest's recorded sha via `inputShas`.
477
479
  * @param {Record<string, string>} inputShas the manifest's recorded sha256 per cited label
478
480
  * @returns {Promise<{verdict: 'green'|'red'|'stopped', gapLines: string[], fault: string|null, detail: Record<string, any>,
479
- * evidence?: any[], evidenceTotal?: number}>} `evidence`/`evidenceTotal` are bareguard's `full.evidence` (what each `cited` check read), carried out
481
+ * rawGaps?: any[], extraGaps?: string[], evidence?: any[], evidenceTotal?: number}>} `evidence`/`evidenceTotal` are bareguard's `full.evidence` (what each `cited` check read), carried out
480
482
  * for the report-only `rubric-evidence` spine record; no verdict, gap or count above is derived from them
481
483
  */
482
484
  export async function gradeStep({ params, bytes, outputBytes, inputs, factQuotes = {}, factMissing = [] }, inputShas) {
@@ -528,8 +530,10 @@ export async function gradeStep({ params, bytes, outputBytes, inputs, factQuotes
528
530
  ...(Array.isArray(r.full.evidence) && r.full.evidence.length > 0 ? { evidence: r.full.evidence } : {}),
529
531
  ...(typeof r.full.evidenceTotal === 'number' ? { evidenceTotal: r.full.evidenceTotal } : {}),
530
532
  };
531
- if (r.verdict === 'green' && extra.length === 0) return { verdict: 'green', gapLines: [], fault: null, detail, ...seen };
532
- return { verdict: 'red', gapLines: [...extra, ...r.gaps.flatMap((g) => plainStepGap(params.step, parsed.why ?? 'empty', g, params).split('\n'))], fault: null, detail, ...seen };
533
+ // bareguard's own structured gaps (id, check, field, kind, items) and the tie's own lines: what the per-row results (src/rowresults.js) read; no verdict or sentence is derived from them here
534
+ const raw = { rawGaps: r.full.gaps, extraGaps: extra };
535
+ if (r.verdict === 'green' && extra.length === 0) return { verdict: 'green', gapLines: [], fault: null, detail, ...raw, ...seen };
536
+ return { verdict: 'red', gapLines: [...extra, ...r.gaps.flatMap((g) => plainStepGap(params.step, parsed.why ?? 'empty', g, params).split('\n'))], fault: null, detail, ...raw, ...seen };
533
537
  }
534
538
 
535
539
  // ── R11: the sorting rules, applied at DRAFTING ──────────────────────────────────────────────────────────────────────
@@ -878,6 +882,7 @@ const DEFAULT_ROW_WORDS = Object.freeze({ cited: 'every claim quotes its input',
878
882
  */
879
883
  export function listRowName(kind, key, words) {
880
884
  const k = typeof kind === 'string' && kind ? kind : 'check';
885
+ if (k === 'prose') return '';
881
886
  if (k === 'cited' || k === 'numbers' || k === 'note') return DEFAULT_ROW_WORDS[k];
882
887
  const tail = key.replace(/^L\d+\.(?:[^.]*\.)?/, '').trim();
883
888
  const w = Array.isArray(words) && words.length ? words : [tail || key];
@@ -899,6 +904,8 @@ export function ruleNotCheckedItems(closeDecl, jobLines, ledger = null) {
899
904
  const text = Number.isInteger(r.rule) ? lineRules((jobLines ?? []).find((/** @type {any} */ l) => isRec(l) && l.n === r.line))[/** @type {number} */ (r.rule) - 1] : (r.label ?? null);
900
905
  const by = r.by ? { by: r.by } : {};
901
906
  // a list row that is not a fact or a rule is named by its words, as the Job tab names it (one owner: listRowName)
907
+ // a `prose` row is said by its own reason alone ("line N: what the text says — you judge it at Accept")
908
+ if (r.kind === 'prose' || (r.kind === 'stage' && !Number.isInteger(r.rule))) return { text: `line ${r.line}: ${r.reason}`, ...by };
902
909
  if (!text && r.fromList && r.key) return { text: `line ${r.line}: ${listRowName(r.kind, r.key, ledger?.find((x) => x.key === r.key)?.words)} — ${r.reason}`, ...by };
903
910
  return { text: `line ${r.line}: ${text ? `"${text}"` : `rule ${r.rule ?? r.kind}`} — ${r.reason}`, ...by };
904
911
  });
@@ -915,10 +922,15 @@ export function refusedOf(closeDecl) {
915
922
  const old = (isRec(closeDecl) && Array.isArray(closeDecl.refused) ? closeDecl.refused : []).filter((/** @type {any} */ r) => isRec(r) && Number.isInteger(r.line) && typeof r.reason === 'string');
916
923
  const list = isRec(closeDecl) && Array.isArray(closeDecl.list) ? closeDecl.list : null;
917
924
  if (list === null) return old.map((/** @type {any} */ r) => ({ line: r.line, ...(Number.isInteger(r.rule) ? { rule: r.rule } : {}), reason: r.reason, fromList: false }));
918
- const rows = list.filter((/** @type {any} */ r) => isRec(r) && r.state === 'not-checked' && Number.isInteger(r.line) && typeof r.reason === 'string' && r.kind !== 'floor').map((/** @type {any} */ r) => ({
925
+ // a `$` default that does not apply to a line kind is not a Not checked item: a facts line's cited default ("this line finds facts, so it has no text to quote") is said by the line's floor row (one-list closes)
926
+ const factLines = new Set((Array.isArray(closeDecl.stages) ? closeDecl.stages : []).filter((/** @type {any} */ st) => isRec(st) && st.kind === 'rubric-step' && isRec(st.params) && factPartOf(st.params)).map((/** @type {any} */ st) => st.params.step));
927
+ const notApplicable = (/** @type {any} */ r) => carriesOneList(closeDecl) && r.kind === 'cited' && r.by === 'default' && factLines.has(r.line);
928
+ const rows = list.filter((/** @type {any} */ r) => isRec(r) && r.state === 'not-checked' && Number.isInteger(r.line) && typeof r.reason === 'string' && r.kind !== 'floor' && !notApplicable(r)).map((/** @type {any} */ r) => ({
919
929
  line: r.line, ...(Number.isInteger(r.rule) ? { rule: r.rule } : {}), kind: String(r.kind), key: String(r.key), ...(['you', 'agent', 'default'].includes(r.by) ? { by: r.by } : {}), ...(r.kind === 'fact' ? { label: String(r.key).split('.').slice(2).join('.') } : {}), reason: r.reason, fromList: true,
920
930
  }));
921
- const seen = (/** @type {any} */ r) => rows.some((x) => x.line === r.line && x.rule === (Number.isInteger(r.rule) ? r.rule : undefined) && Number.isInteger(r.rule));
931
+ // a line-level refusal a repo job's list already holds as its own `!` Not checked row (same line, same reason) is not told twice
932
+ const seen = (/** @type {any} */ r) => rows.some((x) => x.line === r.line && x.rule === (Number.isInteger(r.rule) ? r.rule : undefined) && Number.isInteger(r.rule))
933
+ || (!Number.isInteger(r.rule) && rows.some((x) => x.kind === 'stage' && x.line === r.line && x.reason === r.reason));
922
934
  return [...rows, ...old.filter((/** @type {any} */ r) => !seen(r)).map((/** @type {any} */ r) => ({ line: r.line, ...(Number.isInteger(r.rule) ? { rule: r.rule } : {}), reason: r.reason, fromList: false }))];
923
935
  }
924
936
 
@@ -933,9 +945,11 @@ export function proseNotChecked(closeDecl) {
933
945
 
934
946
  /** the same items as {@link proseNotChecked} with the job line each belongs to (the stage's own `step`) @param {any} closeDecl @returns {{line: number, text: string}[]} */
935
947
  export function proseNotCheckedItems(closeDecl) {
948
+ // a list-built close (Addendum 2026-11-14 (c), Q2) says it from its signed `prose` rows, which `refusedOf` reads; only an older close derives it from its stages
949
+ if (carriesOneList(closeDecl)) return [];
936
950
  const stages = isRec(closeDecl) && Array.isArray(closeDecl.stages) ? closeDecl.stages : [];
937
951
  return stages.filter((/** @type {any} */ st) => isRec(st) && st.kind === 'rubric-step' && isRec(st.params) && Array.isArray(st.params.parts) && !factPartOf(st.params))
938
- .map((/** @type {any} */ st) => ({ line: st.params.step, text: `line ${st.params.step}: what the text says — you judge it at Accept` }));
952
+ .map((/** @type {any} */ st) => ({ line: st.params.step, text: `line ${st.params.step}: ${PROSE_WORDS}` }));
939
953
  }
940
954
 
941
955
  // ── the sign-vs-run invariant: the checks the person is SHOWN are the checks the signed close RUNS ───────────────────
@@ -988,15 +1002,58 @@ export function lineCarriesText(closeDecl, n) {
988
1002
  && !(factPartOf(st.params) && !st.params.parts.some((/** @type {any} */ x) => isRec(x) && x.class === 'countable')));
989
1003
  }
990
1004
 
1005
+ /**
1006
+ * Does this signed close carry the ONE list in full (Addendum 2026-11-14 (c)): a list that holds its job-level guard rows? Such a close is built by the check block alone, so every view reads its rows and
1007
+ * the model's free-text `notes` (which the block never writes) are not a source; an older close (no list, or a list with no guard row) keeps today's display.
1008
+ * @param {any} closeDecl @returns {boolean}
1009
+ */
1010
+ export const carriesOneList = (closeDecl) => isRec(closeDecl) && Array.isArray(closeDecl.list) && closeDecl.list.some((/** @type {any} */ r) => isRec(r) && r.kind === 'guard');
1011
+
1012
+ /** the key of a job-level guard row: `J.$guard.<name>` (the one list, Addendum 2026-11-14 (c) piece 2) @param {string} name @returns {string} */
1013
+ export const guardKeyOf = (name) => `J.$guard.${name}`;
1014
+ /** the guard a row key names, or '' @param {unknown} key @returns {string} */
1015
+ export const guardNameOfKey = (key) => (typeof key === 'string' && key.startsWith('J.$guard.') ? key.slice('J.$guard.'.length) : '');
1016
+ /** the key of a repo job's `!` work-stage row (Addendum 2026-11-15 (d)) and the stage a key names, or '' */
1017
+ export const stageKeyOf = (/** @type {string} */ name) => `S.${name}`;
1018
+ export const stageNameOfKey = (/** @type {unknown} */ key) => (typeof key === 'string' && key.startsWith('S.') ? key.slice(2) : '');
1019
+ /** the words of a text line's `prose` row: the person judges what the text says at Accept (the same words the stage-derived line always used) */
1020
+ export const PROSE_WORDS = 'what the text says — you judge it at Accept';
1021
+ /** the key of the job-level write fence row (the one list, hamr 2026-11-15: the fence is a `$` row like every other rule) */
1022
+ export const FENCE_KEY = 'J.$fence';
1023
+ /** the words of the fence row: its plain question (src/stagewords.js, the one owner) @param {string[]} scope @returns {string} */
1024
+ export const fenceRowText = (scope) => fenceQuestionText(scope);
1025
+ /** the fence a close's row names: `closeDecl.fence` (the confirm card's view of it) or the allowed prefixes its own `changed-from-seed` guard stage signs @param {any} closeDecl @returns {string[]|null} */
1026
+ export function fenceOfClose(closeDecl) {
1027
+ if (!isRec(closeDecl)) return null;
1028
+ if (Array.isArray(closeDecl.fence) && closeDecl.fence.length) return closeDecl.fence.map(String);
1029
+ const g = (Array.isArray(closeDecl.stages) ? closeDecl.stages : []).find((/** @type {any} */ st) => isRec(st) && st.name === 'changed-from-seed' && isRec(st.params));
1030
+ return g && Array.isArray(g.params.allowPrefixes) && g.params.allowPrefixes.length ? g.params.allowPrefixes.map(String) : null;
1031
+ }
1032
+ /** the words of a guard row: its plain question (src/stagewords.js, the one owner); a guard with none keeps its name and its one frozen line (GUARD_DESCRIPTIONS) @param {string} name @returns {string} */
1033
+ export const guardRowText = (name) => guardQuestionText(name) ?? `${name} — ${GUARD_DESCRIPTIONS[name] ?? name}`;
1034
+
1035
+ /**
1036
+ * The words of a line's `$` floor row (Addendum 2026-11-14 (c) piece 1), written by code from the signed close: the line's file must exist and be complete JSON, and carry text only when the close
1037
+ * really puts a text check on it ({@link lineCarriesText}); a facts-only line says it has none. ONE owner: the card, the Job tab and the Audit read it.
1038
+ * @param {any} closeDecl @param {number} n @returns {string}
1039
+ */
1040
+ export function floorText(closeDecl, n) { return floorWords(n, lineCarriesText(closeDecl, n)); }
1041
+
1042
+ /** the one spelling of the floor row's words (the check block's own card view reads it with the line's `carriesText`) @param {number} n @param {boolean} carriesText @returns {string} */
1043
+ export function floorWords(n, carriesText) {
1044
+ return `its file ${stepFileRel(n)} must exist, be complete JSON${carriesText ? ', and carry text' : '; this line finds facts, so it has no text check'}`;
1045
+ }
1046
+
991
1047
  /**
992
1048
  * The checks a signed close actually runs, per job line, in plain code-written sentences: one per countable part of every
993
1049
  * rubric-step stage. This is the ONE reader both the plan card and the sign-time invariant use.
994
1050
  * Each row says who added the check (`by`): `you` = one of the person's picks, as the signed close's own record (`closeDecl.picks`) names it; `agent` = the drafter's;
995
1051
  * `default` = code's own (the one list's `$` rows: the cited part written by `defaultCitedText`, and the numbers tie of a text step).
996
- * @param {any} closeDecl
997
- * @returns {{line: number, text: string, by: 'agent'|'you'|'default', key?: string}[]}
1052
+ * A repo job's list (Addendum 2026-11-15 (d)) adds its rows here: an `!` row per work stage (the stage's name) and a `~` row the write fence keeps (the rule in the person's words, from `jobLines`; else its number), `fence` holding the path.
1053
+ * @param {any} closeDecl @param {any[]|null} [jobLines] the person's numbered lines, so a `~` row reads in their own words
1054
+ * @returns {{line: number, text: string, by: 'agent'|'you'|'default', key?: string, pick?: true, fence?: string}[]}
998
1055
  */
999
- export function checksOfClose(closeDecl) {
1056
+ export function checksOfClose(closeDecl, jobLines = null) {
1000
1057
  const stages = isRec(closeDecl) && Array.isArray(closeDecl.stages) ? closeDecl.stages : [];
1001
1058
  const record = isRec(closeDecl) && Array.isArray(closeDecl.picks) ? closeDecl.picks : [];
1002
1059
  const list = isRec(closeDecl) && Array.isArray(closeDecl.list) ? closeDecl.list.filter((/** @type {any} */ r) => isRec(r) && r.state === 'built') : [];
@@ -1010,20 +1067,46 @@ export function checksOfClose(closeDecl) {
1010
1067
  const r = list.find((/** @type {any} */ x) => x.line === line && x.kind === 'count' && isRec(x.part) && x.part.part === pi);
1011
1068
  return r ? { by: /** @type {'agent'|'you'|'default'} */ (r.by), key: String(r.key) } : null;
1012
1069
  };
1013
- return stages.flatMap((/** @type {any} */ st) => (isRec(st) && st.kind === 'rubric-step' && isRec(st.params) && Array.isArray(st.params.parts)
1014
- ? st.params.parts.flatMap((/** @type {any} */ p, /** @type {number} */ pi) => {
1070
+ // the `$` floor of a line (piece 1): its signed row, built; the words are code's (floorText). A close with no list (an older job) has no floor row to read, so none is drawn
1071
+ const floorOf = (/** @type {any} */ st) => {
1072
+ const r = list.find((/** @type {any} */ x) => x.kind === 'floor' && x.line === st.params.step);
1073
+ return r ? [{ line: st.params.step, text: floorText(closeDecl, st.params.step), by: /** @type {'default'} */ ('default'), key: String(r.key) }] : [];
1074
+ };
1075
+ // a repo job's own row kinds (the list is built by the one CheckBlock, src/checkblock.js `repo` type): the `!` work stages in the order the close runs them, then the `~` rules the write fence keeps, each on its line
1076
+ // an `!` stage row reads the stage's plain question (src/stagewords.js, the one owner the Audit and the Result tab read), the stage's own name only when no honest question exists
1077
+ const questions = stageQuestionsByName({ closeDecl });
1078
+ const repoRows = [
1079
+ ...list.filter((/** @type {any} */ x) => x.kind === 'stage' && stageNameOfKey(x.key) !== '').map((/** @type {any} */ x) => ({ line: Number(x.line), text: questions.get(stageNameOfKey(x.key)) ?? stageNameOfKey(x.key), by: /** @type {'agent'} */ ('agent'), key: String(x.key) })),
1080
+ ...list.filter((/** @type {any} */ x) => x.kind === 'rule' && typeof x.fence === 'string').map((/** @type {any} */ x) => {
1081
+ const said = lineRules((jobLines ?? []).find((/** @type {any} */ l) => isRec(l) && l.n === x.line))[Number(x.rule) - 1];
1082
+ return { line: Number(x.line), text: `${said ? `"${said}"` : `rule ${x.rule}`} \u2014 kept by the write fence: ${x.fence} is outside the places the run may change`, by: /** @type {'you'} */ ('you'), key: String(x.key), fence: String(x.fence) };
1083
+ }),
1084
+ ].sort((a, b) => a.line - b.line);
1085
+ // the job-level `$` guard rows (piece 2): once for the whole job, line 0, after every line's rows
1086
+ const guardRows = list.filter((/** @type {any} */ x) => x.kind === 'guard' && guardNameOfKey(x.key) !== '').map((/** @type {any} */ x) => ({ line: 0, text: guardRowText(guardNameOfKey(x.key)), by: /** @type {'default'} */ ('default'), key: String(x.key) }));
1087
+ // the job-level `$` write fence row (hamr 2026-11-15): once, after the guards; its words need the fence the close signs
1088
+ const fence = fenceOfClose(closeDecl);
1089
+ const fenceRows = fence ? list.filter((/** @type {any} */ x) => x.kind === 'fence').map((/** @type {any} */ x) => ({ line: 0, text: fenceRowText(fence), by: /** @type {'default'} */ ('default'), key: String(x.key) })) : [];
1090
+ return [...stages.flatMap((/** @type {any} */ st) => (isRec(st) && st.kind === 'rubric-step' && isRec(st.params) && Array.isArray(st.params.parts)
1091
+ ? [...st.params.parts.flatMap((/** @type {any} */ p, /** @type {number} */ pi) => {
1015
1092
  if (!isRec(p) || (p.class !== 'countable' && p.class !== 'fact')) return [];
1016
1093
  /** @type {'agent'|'you'|'default'} */
1017
1094
  const by = p.check === 'numbersFromFacts' || isDefaultNote(p, st.params.step) || (p.check === 'cited' && p.text === defaultCitedText(p.source)) ? 'default' : record.some((/** @type {any} */ x) => isRec(x) && x.line === st.params.step && sameJson(x.part, p)) ? 'you' : 'agent';
1018
1095
  // a fact part is one plan row per fact (and one for its count): the person signs the rows, the close runs the same list
1019
- if (p.class !== 'fact') return [{ line: st.params.step, text: partSentence(p), by }];
1096
+ if (p.class !== 'fact') {
1097
+ // the built row that carries this countable part (piece 3: every check is a row): a row points at its part, or a `~` rule row is named in the part's own `rules`; the first one keys it
1098
+ const row = list.find((/** @type {any} */ x) => ['rule', 'cited', 'numbers', 'note'].includes(x.kind) && x.line === st.params.step
1099
+ && ((isRec(x.part) && x.part.line === st.params.step && x.part.part === pi) || (x.kind === 'rule' && Array.isArray(p.rules) && p.rules.includes(x.rule))));
1100
+ // `pick`: the person's own count/word pick (the confirm card draws it once, from the picks record, never also as this row)
1101
+ return [{ line: st.params.step, text: partSentence(p), by, ...(row ? { key: String(row.key) } : {}), ...(by === 'you' ? { pick: true } : {}) }];
1102
+ }
1020
1103
  const facts = Array.isArray(p.facts) ? p.facts : [];
1021
1104
  return factRows(p).map((/** @type {string} */ text, /** @type {number} */ i) => {
1022
1105
  const own = i < facts.length ? factBy(st.params.step, facts[i]?.name) : countBy(st.params.step, pi);
1023
1106
  return { line: st.params.step, text, by: own?.by ?? by, ...(own ? { key: own.key } : {}) };
1024
1107
  });
1025
- })
1026
- : []));
1108
+ }), ...floorOf(st)]
1109
+ : [])), ...repoRows, ...guardRows, ...fenceRows];
1027
1110
  }
1028
1111
 
1029
1112
  /**
@@ -1042,16 +1125,16 @@ export function signedFactNames(closeDecl) {
1042
1125
  * steps' "you judge it at Accept" lines and the refusals (`ruleNotChecked`, which reads the list's not-checked rows when the close carries the list). Nothing the confirm turn said is merged
1043
1126
  * in: a rubric confirm turn plans the goal only, so a check can never be shown and then silently dropped (run mv5bk400).
1044
1127
  * @param {{closeDecl: any, jobLines?: any[]|null, ledger?: {key: string, words: string[]}[]|null}} o `jobLines` the person's numbered lines, so a ~ rule reads in the person's own words; `ledger` the draft log's final list rows, so a phrase row is named by its words
1045
- * @returns {{checkItems: {text: string, fromLine: number[], by: 'agent'|'you'|'default', key?: string}[], notChecked: string[], notCheckedBy: Record<string, 'you'|'agent'|'default'>}}
1128
+ * @returns {{checkItems: {text: string, fromLine: number[], by: 'agent'|'you'|'default', key?: string, pick?: true}[], notChecked: string[], notCheckedBy: Record<string, 'you'|'agent'|'default'>}}
1046
1129
  */
1047
1130
  export function cardOfClose({ closeDecl, jobLines = null, ledger = null }) {
1048
- const notes = isRec(closeDecl) && Array.isArray(closeDecl.notes) ? closeDecl.notes.filter((/** @type {any} */ n) => typeof n === 'string' && n) : [];
1131
+ const notes = isRec(closeDecl) && !carriesOneList(closeDecl) && Array.isArray(closeDecl.notes) ? closeDecl.notes.filter((/** @type {any} */ n) => typeof n === 'string' && n) : [];
1049
1132
  const items = ruleNotCheckedItems(closeDecl, jobLines, ledger);
1050
1133
  /** @type {Record<string, 'you'|'agent'|'default'>} */
1051
1134
  const notCheckedBy = {};
1052
1135
  for (const i of items) if (i.by) notCheckedBy[i.text] = i.by;
1053
1136
  return {
1054
- checkItems: checksOfClose(closeDecl).map((c) => ({ text: c.text, fromLine: [c.line], by: c.by, ...(c.key ? { key: c.key } : {}) })),
1137
+ checkItems: checksOfClose(closeDecl, jobLines).map((c) => ({ text: c.text, fromLine: [c.line], by: c.by, ...(c.key ? { key: c.key } : {}), ...(c.pick ? { pick: true } : {}) })),
1055
1138
  notChecked: [...new Set([...notes, ...proseNotChecked(closeDecl), ...items.map((i) => i.text)])],
1056
1139
  notCheckedBy,
1057
1140
  };
@@ -1068,8 +1151,13 @@ export function listMatchesClose(closeDecl) {
1068
1151
  if (list === null) return { ok: true };
1069
1152
  const stages = Array.isArray(closeDecl.stages) ? closeDecl.stages : [];
1070
1153
  const partsOn = (/** @type {number} */ n) => stages.filter((/** @type {any} */ st) => isRec(st) && st.kind === 'rubric-step' && isRec(st.params) && st.params.step === n && Array.isArray(st.params.parts)).flatMap((/** @type {any} */ st) => st.params.parts);
1071
- const built = list.filter((/** @type {any} */ r) => isRec(r) && r.state === 'built' && r.kind !== 'floor');
1072
- const bad = built.filter((/** @type {any} */ r) => !(isRec(r.part) && r.part.line === r.line && Number.isInteger(r.part.part) && isRec(partsOn(r.line)[r.part.part])));
1154
+ // a job-level guard row (line 0) points at a guard STAGE the close runs, by name; it has no part
1155
+ const stageNames = stages.filter((/** @type {any} */ st) => isRec(st)).map((/** @type {any} */ st) => st.name);
1156
+ const guardBad = list.filter((/** @type {any} */ r) => isRec(r) && r.kind === 'guard' && r.state === 'built' && !stageNames.includes(guardNameOfKey(r.key)));
1157
+ // a repo job's rows (Addendum 2026-11-15 (d)): an `!` stage row names a stage the close runs; a `~` rule row the fence keeps points at no part (`fence` holds the path)
1158
+ const stageBad = list.filter((/** @type {any} */ r) => isRec(r) && r.kind === 'stage' && r.state === 'built' && !stageNames.includes(stageNameOfKey(r.key)));
1159
+ const built = list.filter((/** @type {any} */ r) => isRec(r) && r.state === 'built' && r.kind !== 'floor' && r.kind !== 'guard' && r.kind !== 'fence' && r.kind !== 'stage' && !(r.kind === 'rule' && typeof r.fence === 'string'));
1160
+ const bad = [...guardBad, ...stageBad, ...built.filter((/** @type {any} */ r) => !(isRec(r.part) && r.part.line === r.line && Number.isInteger(r.part.part) && isRec(partsOn(r.line)[r.part.part])))];
1073
1161
  const lines = [...new Set(stages.filter((/** @type {any} */ st) => isRec(st) && st.kind === 'rubric-step' && isRec(st.params)).map((/** @type {any} */ st) => st.params.step))];
1074
1162
  const bare = lines.flatMap((/** @type {number} */ n) => partsOn(n).map((/** @type {any} */ p, /** @type {number} */ i) => ({ n, i, p })))
1075
1163
  .filter(({ p }) => isRec(p) && (p.class === 'countable' || p.class === 'fact'))
@@ -1086,12 +1174,12 @@ export function listMatchesClose(closeDecl) {
1086
1174
  /**
1087
1175
  * The sign-time invariant: the checks the person was shown (`shown`, from the plan card) are exactly the checks the signed
1088
1176
  * close runs (`checksOfClose`), per line. Pure.
1089
- * @param {{text: string, fromLine: number[]|null}[]} shown @param {any} closeDecl
1177
+ * @param {{text: string, fromLine: number[]|null}[]} shown @param {any} closeDecl @param {any[]|null} [jobLines] the person's numbered lines (a repo job's `~` row reads the rule in their words)
1090
1178
  * @returns {{ok: true}|{ok: false, error: string}}
1091
1179
  */
1092
- export function planMatchesClose(shown, closeDecl) {
1180
+ export function planMatchesClose(shown, closeDecl, jobLines = null) {
1093
1181
  const key = (/** @type {number|null|undefined} */ line, /** @type {string} */ text) => `line ${line ?? '?'}: ${text}`;
1094
- const ran = checksOfClose(closeDecl).map((c) => key(c.line, c.text));
1182
+ const ran = checksOfClose(closeDecl, jobLines).map((c) => key(c.line, c.text));
1095
1183
  const saw = shown.map((c) => key(Array.isArray(c.fromLine) ? c.fromLine[0] : null, c.text));
1096
1184
  const onlyShown = saw.filter((k) => !ran.includes(k));
1097
1185
  const onlyRan = ran.filter((k) => !saw.includes(k));
package/src/stagewords.js CHANGED
@@ -152,3 +152,27 @@ export function stageQuestionsByName(spec) {
152
152
  }
153
153
  return out;
154
154
  }
155
+
156
+ /**
157
+ * The plain question of the `$ [default]` write-fence row, built from the signed fence itself: `src/**` reads `src/`; an entry that is a glob this cannot read as a folder or file is quoted as it was signed.
158
+ * @param {string[]} scope @returns {string}
159
+ */
160
+ export function fenceQuestionText(scope) {
161
+ const places = scope.map((e) => {
162
+ const folder = /^(.+?)\/\*\*?$/.exec(e);
163
+ const base = folder ? `${folder[1]}/` : e;
164
+ return /[*?[\]{}]/.test(base) ? e : base;
165
+ });
166
+ return `only files in ${places.join(', ')} changed?`;
167
+ }
168
+
169
+ /**
170
+ * The plain question of a job-level `$ [default]` guard row (the one list's guard rows, by guard NAME) — the one owner the plan card, Job tab, Audit, Result and the CLI print read, in place of the guard's raw name and its
171
+ * long frozen sentence (GUARD_DESCRIPTIONS stays the older confirm-turn "protections" line). `null` for a guard with no line here: the caller keeps the old words, never an invented question.
172
+ * @param {string} name @returns {string|null}
173
+ */
174
+ export function guardQuestionText(name) {
175
+ if (name === 'changed-from-seed') return 'did the run change a file?';
176
+ if (name === 'no-suppressions') return 'no checker silenced (@ts-ignore, eslint-disable, # type: ignore)?';
177
+ return null;
178
+ }