bareloop 0.56.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 (93) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/README.md +3 -3
  3. package/bareloop.context.md +75 -214
  4. package/package.json +2 -2
  5. package/src/authorflow.js +71 -136
  6. package/src/authoring.js +5 -124
  7. package/src/authorjob.js +125 -417
  8. package/src/authorreadout.js +105 -355
  9. package/src/authorrun.js +70 -234
  10. package/src/authorscout.js +9 -1
  11. package/src/blockasks.js +12 -17
  12. package/src/bundlerun.js +4 -1
  13. package/src/checkblock.js +297 -75
  14. package/src/checklist.js +1 -1
  15. package/src/checkpick.js +9 -5
  16. package/src/cli.js +3 -3
  17. package/src/declaredclose.js +45 -112
  18. package/src/destpoint.js +1 -1
  19. package/src/draftspend.js +20 -4
  20. package/src/fencepointcall.js +76 -0
  21. package/src/guarddescriptions.js +14 -0
  22. package/src/index.js +3 -43
  23. package/src/interviewrun.js +13 -8
  24. package/src/job.js +20 -1
  25. package/src/jobblock.js +11 -46
  26. package/src/judged.js +13 -1229
  27. package/src/kinds.js +10 -348
  28. package/src/noteask.js +124 -0
  29. package/src/pagedry.js +27 -5
  30. package/src/pagemap.js +7 -29
  31. package/src/pagerules.js +18 -3
  32. package/src/panel/authorroutes.js +15 -4
  33. package/src/panel/authorsession.js +201 -167
  34. package/src/panel/importrun.js +0 -1
  35. package/src/panel/index.html +43 -18
  36. package/src/panel/jobplan.js +54 -19
  37. package/src/panel/server.js +90 -69
  38. package/src/panel/status.js +3 -0
  39. package/src/pickrecord.js +15 -54
  40. package/src/planrun.js +4 -48
  41. package/src/promptregisters.js +7 -17
  42. package/src/providerrows.js +0 -36
  43. package/src/providers.js +4 -25
  44. package/src/questionbox.js +34 -30
  45. package/src/reviewdoor.js +1 -1
  46. package/src/rowresults.js +69 -0
  47. package/src/rubricstep.js +136 -28
  48. package/src/run.js +2 -15
  49. package/src/stagewords.js +24 -0
  50. package/src/userrun.js +14 -111
  51. package/types/authorflow.d.ts +51 -137
  52. package/types/authoring.d.ts +1 -14
  53. package/types/authorjob.d.ts +14 -55
  54. package/types/authorreadout.d.ts +52 -80
  55. package/types/authorrun.d.ts +20 -0
  56. package/types/blockasks.d.ts +5 -11
  57. package/types/checkblock.d.ts +147 -28
  58. package/types/checklist.d.ts +2 -2
  59. package/types/checkpick.d.ts +5 -3
  60. package/types/cli.d.ts +1 -3
  61. package/types/declaredclose.d.ts +5 -33
  62. package/types/draftspend.d.ts +16 -2
  63. package/types/fencepointcall.d.ts +68 -0
  64. package/types/guarddescriptions.d.ts +7 -0
  65. package/types/index.d.ts +2 -4
  66. package/types/job.d.ts +8 -0
  67. package/types/jobblock.d.ts +8 -38
  68. package/types/judged.d.ts +7 -357
  69. package/types/kinds.d.ts +4 -104
  70. package/types/noteask.d.ts +76 -0
  71. package/types/pagedry.d.ts +13 -0
  72. package/types/pagemap.d.ts +2 -5
  73. package/types/pagerules.d.ts +7 -0
  74. package/types/panel/authorsession.d.ts +37 -5
  75. package/types/panel/jobplan.d.ts +15 -3
  76. package/types/panel/server.d.ts +46 -13
  77. package/types/panel/status.d.ts +5 -0
  78. package/types/pickrecord.d.ts +8 -13
  79. package/types/planrun.d.ts +1 -22
  80. package/types/providerrows.d.ts +0 -31
  81. package/types/providers.d.ts +3 -19
  82. package/types/questionbox.d.ts +20 -6
  83. package/types/rowresults.d.ts +23 -0
  84. package/types/rubricstep.d.ts +43 -7
  85. package/types/run.d.ts +1 -20
  86. package/types/stagewords.d.ts +11 -0
  87. package/types/userrun.d.ts +0 -1
  88. package/src/calibrate.js +0 -702
  89. package/src/cardauthor.js +0 -502
  90. package/src/fitcheck.js +0 -168
  91. package/types/calibrate.d.ts +0 -201
  92. package/types/cardauthor.d.ts +0 -358
  93. package/types/fitcheck.d.ts +0 -119
package/src/providers.js CHANGED
@@ -169,41 +169,20 @@ export function makeProvider(providerName, { apiKey, model, baseUrl, legacyMaxTo
169
169
  }
170
170
 
171
171
  /**
172
- * Build the `{provider, providerFor, judgeProvider}` triple both authoring runners need (`src/authorrun.js` and
173
- * `src/panel/authorsession.js` call it) — ONE seam instead of two copies of the same construction. `model` is the
174
- * already-RESOLVED worker model id (the caller picked the Settings line).
175
- *
176
- * THE JUDGE IS NOT PINNED (PRD item 32.2): it is constructed through this same factory from a `judgeProviderName`/`judgeModel`
177
- * pair the CALLER resolved. `judgeApiKey` stays a SEPARATE argument: the judge may be a different provider from the worker,
178
- * and each key is read by the caller from its own row.
172
+ * Build the `{provider, providerFor}` pair both authoring runners need (`src/authorrun.js` and `src/panel/authorsession.js` call it) — ONE seam
173
+ * instead of two copies of the same construction. `model` is the already-RESOLVED worker model id (the caller picked the Settings line).
179
174
  * @param {object} args
180
175
  * @param {string} args.providerName the worker's API shape id
181
176
  * @param {string|undefined} args.apiKey the WORKER's key, read from its row's env name
182
177
  * @param {string} args.model the already-resolved worker model id
183
178
  * @param {string|undefined} [args.baseUrl] the worker row's Base URL
184
179
  * @param {boolean} [args.legacyMaxTokens] the worker row's old max_tokens tick
185
- * @param {string|undefined} args.judgeApiKey the judge's own key
186
- * @param {string} args.judgeModel the resolved judge model id
187
- * @param {string} [args.judgeProviderName] the resolved judge shape; defaults to `providerName`
188
- * @param {string|undefined} [args.judgeBaseUrl] the judge row's endpoint
189
- * @param {boolean} [args.judgeLegacyMaxTokens] the judge row's old max_tokens tick (defaults to the worker's when the judge shares its provider)
190
180
  */
191
- export function buildRunnerProviders({
192
- providerName, apiKey, model, baseUrl, legacyMaxTokens = false, judgeApiKey, judgeModel,
193
- judgeProviderName = providerName, judgeBaseUrl = undefined, judgeLegacyMaxTokens = undefined,
194
- }) {
181
+ export function buildRunnerProviders({ providerName, apiKey, model, baseUrl, legacyMaxTokens = false }) {
195
182
  const provider = makeProvider(providerName, { apiKey, model, baseUrl, legacyMaxTokens });
196
183
  // a plan step's `model` is the one schema token `sonnet` (STEP_MODELS, src/plan.js): it means THE JOB'S worker model
197
184
  const providerFor = (/** @type {string} */ _tier) => provider;
198
- // the judge goes through the SAME table as the worker. Reusing the worker instance when the identity matches exactly is not an
199
- // optimisation for its own sake: a second instance against the same endpoint/model is a second prompt-cache prefix, and cache
200
- // writes are ~41% of the bill.
201
- const judgeLegacy = judgeLegacyMaxTokens ?? (judgeProviderName === providerName ? legacyMaxTokens : false);
202
- const judgeProvider = (judgeProviderName === providerName && judgeModel === model && judgeApiKey === apiKey
203
- && judgeBaseUrl === baseUrl && judgeLegacy === legacyMaxTokens)
204
- ? provider
205
- : makeProvider(judgeProviderName, { apiKey: judgeApiKey, model: judgeModel, baseUrl: judgeBaseUrl, legacyMaxTokens: judgeLegacy });
206
- return { provider, providerFor, judgeProvider };
185
+ return { provider, providerFor };
207
186
  }
208
187
 
209
188
  /**
@@ -1,10 +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';
7
- import { FIT_ANSWER, FIT_GO_ON } from './fitcheck.js';
6
+ import { DROP_IT } from './pagemap.js';
8
7
  import { DEST_ANSWER } from './destpoint.js';
9
8
 
10
9
  /** the door's refusals, word for word (fwd am31); a refusal leaves the question open and writes nothing */
@@ -12,50 +11,53 @@ export const CHOICE_SAYS = Object.freeze({
12
11
  bad: 'That answer is not one of the choices. Nothing was saved.',
13
12
  notOffered: 'That choice is not offered for this question. Nothing was saved.',
14
13
  outOfDate: 'This page is out of date. Reload it and answer again. Nothing was saved.',
15
- 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.',
16
15
  blank: 'An answer is needed here — there is no skip. Type it in the box and press Send.',
17
16
  });
18
17
 
19
18
  /**
20
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
21
- * 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).
22
21
  * @param {{source?: string, ask?: string, reading?: unknown, check?: unknown, rule?: unknown}} q @returns {{agree: boolean, drop: boolean}}
23
22
  */
24
23
  export function offersOf(q) {
25
24
  const look = q.source === 'look';
26
25
  const agree = look && ((q.ask === 'reading' && typeof q.reading === 'string') || (q.ask === 'check' && q.check !== null && typeof q.check === 'object'));
27
- 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');
28
27
  return { agree, drop };
29
28
  }
30
29
 
31
30
  /**
32
- * 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.
33
- * 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).
34
33
  * @param {{question: string, line?: number, source?: string}} q @returns {string}
35
34
  */
36
35
  export function panelQuestionText(q) {
37
36
  const text = String(q.question);
38
- if (q.source === 'fit-check') return text.endsWith(FIT_ANSWER) ? text.slice(0, text.length - FIT_ANSWER.length) : text;
39
37
  if (q.source === 'dest-point') return text.endsWith(DEST_ANSWER) ? text.slice(0, text.length - DEST_ANSWER.length) : text;
40
- if (q.source !== 'look' || !Number.isInteger(q.line)) return text;
41
- const n = /** @type {number} */ (q.line);
42
- const hit = [readingTail(n), cantCheckTail(n), ` ${HOW_TO_ANSWER(n, true)}`, ` ${HOW_TO_ANSWER(n, false)}`].find((t) => text.endsWith(t));
43
- 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;
44
50
  }
45
51
 
46
52
  /**
47
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)
48
54
  * keeps the chat input. `sendChoice` = the choice the box's own Send posts.
49
- * @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
50
56
  * @returns {{head: string, line: string, text: string, choices: {choice: string, label: string}[], orLabel: string|null, sendChoice: string}|null}
51
57
  */
52
58
  export function boxFor(step) {
53
59
  if (step.kind !== 'answer' || typeof step.question !== 'string') return null;
54
- const before = step.source === 'fit-check' || step.source === 'dest-point';
55
- // the fit check: two buttons, no box (go on = keep drafting; stop = anything else, as typed words did)
56
- if (step.source === 'fit-check') {
57
- return { head: 'A question before drafting', line: '', text: panelQuestionText(/** @type {any} */ (step)), choices: [{ choice: 'go-on', label: 'Go on' }, { choice: 'stop', label: 'Stop' }], orLabel: null, sendChoice: 'stop' };
58
- }
60
+ const before = step.source === 'dest-point';
59
61
  // the Destination point: yes / no buttons and a box for a different Destination (checked at $0 before it is taken)
60
62
  if (step.source === 'dest-point') {
61
63
  return {
@@ -68,28 +70,32 @@ export function boxFor(step) {
68
70
  const choices = [];
69
71
  if (step.offers?.agree) choices.push({ choice: 'agree', label: 'Agree' });
70
72
  if (step.offers?.drop) choices.push({ choice: 'drop', label: 'Drop it' });
73
+ const buttonsOnly = step.source === 'look';
71
74
  return {
72
75
  head: before ? 'A question before drafting' : `A question the plan raised (${step.index ?? 1} of ${step.total ?? 1})`,
73
- 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)}`}`,
74
77
  text: panelQuestionText({ question: step.question, source: step.source, ...(Number.isInteger(step.line) ? { line: step.line } : {}) }),
75
78
  choices,
76
- 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:',
77
81
  sendChoice: 'rule',
78
82
  };
79
83
  }
80
84
 
81
- /** the choices each kind of question's typed answer may name */
82
- const CHOICES = { look: ['agree', 'drop', 'rule'], 'fit-check': ['go-on', 'stop'], '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'] };
83
87
 
84
88
  /**
85
89
  * The door's check of a choice sent for the pending ask. Null = accepted; else the refusal words.
86
- * @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}
87
91
  */
88
92
  export function refuseChoice(step, choice) {
89
93
  if (step.kind !== 'answer') return CHOICE_SAYS.notOffered;
90
- const own = /** @type {string[]|undefined} */ (/** @type {Record<string, string[]>} */ (CHOICES)[step.source === 'fit-check' || step.source === 'dest-point' ? step.source : 'look']);
91
- if (typeof choice !== 'string' || !(own ?? CHOICES.look).includes(choice)) return CHOICE_SAYS.bad;
92
- if (step.source === 'fit-check' || step.source === 'dest-point') return null;
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;
98
+ if (step.source === 'dest-point') return null;
93
99
  if (choice === 'agree' && step.offers?.agree !== true) return CHOICE_SAYS.notOffered;
94
100
  if (choice === 'drop' && step.offers?.drop !== true) return step.source === 'look' && !Number.isInteger(step.rule) ? CHOICE_SAYS.noRule : CHOICE_SAYS.notOffered;
95
101
  return null;
@@ -103,8 +109,6 @@ export function refuseChoice(step, choice) {
103
109
  export function resolveChoice(choice, text) {
104
110
  if (choice === 'agree') return { value: 'agree', shown: 'Agree' };
105
111
  if (choice === 'drop') return { value: DROP_IT, shown: 'Drop it' };
106
- if (choice === 'go-on') return { value: FIT_GO_ON, shown: 'Go on' };
107
- if (choice === 'stop') return { value: 'stop', shown: 'Stop' };
108
112
  if (choice === 'yes') return { value: 'yes', shown: 'Yes' };
109
113
  if (choice === 'no') return { value: 'no', shown: 'No' };
110
114
  const said = String(text ?? '').replace(/\s*\n\s*/g, ' ').trim();
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 ──────────────────────────────────────────────────────────────────────
@@ -669,7 +673,8 @@ export function checkRubricParts(stages, { inputLabels = null, red, picks = null
669
673
  return;
670
674
  }
671
675
  // keep-both: a fact line may carry a countable part only when it IS one of the person's recorded picks (an offered check, its `rules`, the same line, the same words)
672
- const isPick = factLine && Array.isArray(picks) && picks.some((x) => isRec(x) && x.line === step && sameJson(x.part, part)) && OFFERED.includes(part.check) && Array.isArray(part.rules);
676
+ const isNote = factLine && isDefaultNote(part, step);
677
+ const isPick = isNote || factLine && Array.isArray(picks) && picks.some((x) => isRec(x) && x.line === step && sameJson(x.part, part)) && OFFERED.includes(part.check) && Array.isArray(part.rules);
673
678
  if (factLine && !isPick) {
674
679
  red('rubric-fact-text', w, `line ${line}: '${said}' counts or quotes free text, but this line lists facts and has no text. Say it as a fact (a shape and a rule) or remove it. Nothing spent.`, { line: step, stage: label });
675
680
  return;
@@ -828,6 +833,9 @@ export function holdsManyBounds(shape, text) {
828
833
  return false;
829
834
  }
830
835
 
836
+ /** the plain reason a rule's amount is in a currency the page fact does not use; `readLimit` gives it and the check list reads it, one spelling */
837
+ export const WHY_OTHER_CURRENCY = 'the amount is in another currency than the page fact';
838
+
831
839
  /**
832
840
  * The limit the person's own words give a fact of this shape: `{reading}` or `{why}` (a plain reason; the rule then stays Not checked).
833
841
  * @param {string} shape money or time @param {string} text the `~` rule's words @param {any} [fact] the look fact (its currency and unit lists must fit)
@@ -850,7 +858,7 @@ export function readLimit(shape, text, fact = {}) {
850
858
  if (/\b(?:not|never|outside|except|without)\b/i.test(t)) return { why: 'a negated limit (not, except, without) is not read' };
851
859
  const amts = [...t.matchAll(AMOUNT_ALL_RE)];
852
860
  if (!amts.length) return { why: 'no amount with a currency sign or word in the rule' };
853
- for (const a of amts) if (!currencyFits(a[0], fact)) return { why: 'the amount is in another currency than the page fact' };
861
+ for (const a of amts) if (!currencyFits(a[0], fact)) return { why: WHY_OTHER_CURRENCY };
854
862
  if (holdsManyBounds('money', t)) return { why: 'more than one amount in the rule' };
855
863
  const b = MONEY_BETWEEN_RE.exec(t);
856
864
  if (b) { const lo = num(b[1], b[2]), hi = num(b[3], b[4]); return lo < hi ? { reading: { op: 'between', lo, hi } } : { why: 'a range whose end is not above its start is not read' }; }
@@ -864,7 +872,7 @@ export function readLimit(shape, text, fact = {}) {
864
872
  }
865
873
 
866
874
  /** the words a list row of kind `$cited` / `$numbers` carries no text for */
867
- const DEFAULT_ROW_WORDS = Object.freeze({ cited: 'every claim quotes its input', numbers: 'every number matches a quote' });
875
+ const DEFAULT_ROW_WORDS = Object.freeze({ cited: 'every claim quotes its input', numbers: 'every number matches a quote', note: 'the note' });
868
876
 
869
877
  /**
870
878
  * A check-list row named in the person's plain words: `phrase "### Fixed"`. The words are the draft log's; with none, the text after the key's kind prefix (`L1.phrase.### fixed`).
@@ -874,7 +882,8 @@ const DEFAULT_ROW_WORDS = Object.freeze({ cited: 'every claim quotes its input',
874
882
  */
875
883
  export function listRowName(kind, key, words) {
876
884
  const k = typeof kind === 'string' && kind ? kind : 'check';
877
- if (k === 'cited' || k === 'numbers') return DEFAULT_ROW_WORDS[k];
885
+ if (k === 'prose') return '';
886
+ if (k === 'cited' || k === 'numbers' || k === 'note') return DEFAULT_ROW_WORDS[k];
878
887
  const tail = key.replace(/^L\d+\.(?:[^.]*\.)?/, '').trim();
879
888
  const w = Array.isArray(words) && words.length ? words : [tail || key];
880
889
  return `${k} ${w.map((x) => `"${x}"`).join(', ')}`;
@@ -895,6 +904,8 @@ export function ruleNotCheckedItems(closeDecl, jobLines, ledger = null) {
895
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);
896
905
  const by = r.by ? { by: r.by } : {};
897
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 };
898
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 };
899
910
  return { text: `line ${r.line}: ${text ? `"${text}"` : `rule ${r.rule ?? r.kind}`} — ${r.reason}`, ...by };
900
911
  });
@@ -911,10 +922,15 @@ export function refusedOf(closeDecl) {
911
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');
912
923
  const list = isRec(closeDecl) && Array.isArray(closeDecl.list) ? closeDecl.list : null;
913
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 }));
914
- 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) => ({
915
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,
916
930
  }));
917
- 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));
918
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 }))];
919
935
  }
920
936
 
@@ -929,9 +945,11 @@ export function proseNotChecked(closeDecl) {
929
945
 
930
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}[]} */
931
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 [];
932
950
  const stages = isRec(closeDecl) && Array.isArray(closeDecl.stages) ? closeDecl.stages : [];
933
951
  return stages.filter((/** @type {any} */ st) => isRec(st) && st.kind === 'rubric-step' && isRec(st.params) && Array.isArray(st.params.parts) && !factPartOf(st.params))
934
- .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}` }));
935
953
  }
936
954
 
937
955
  // ── the sign-vs-run invariant: the checks the person is SHOWN are the checks the signed close RUNS ───────────────────
@@ -950,7 +968,7 @@ export function partSentence(part) {
950
968
  case 'maxLines': return `the text is at most ${n(part.value, 'line')}`;
951
969
  case 'sections': return `the text has the section(s): ${list(part.names)}`;
952
970
  case 'sectionWords': return `each section (${list(part.names)}) is about ${part.wordsPerSection} words`;
953
- case 'nonEmpty': return 'the text is not empty';
971
+ case 'nonEmpty': return /^line \d+ writes a note — the note must be there$/.test(String(part.text)) ? String(part.text) : 'the text is not empty';
954
972
  case 'listItems': return `the text has exactly ${n(part.value, 'list item')}`;
955
973
  case 'maxListItems': return `the text has at most ${n(part.value, 'list item')}`;
956
974
  case 'minListItems': return `the text has at least ${n(part.value, 'list item')}`;
@@ -968,15 +986,74 @@ export function partSentence(part) {
968
986
  /** the words of the default cited check code adds to a text line of a one-input job (the one list's `$` row); the card reads a part with exactly these words as `[default]` @param {string} label @returns {string} */
969
987
  export const defaultCitedText = (label) => `every claim is backed by a quote copied from "${label}"`;
970
988
 
989
+ /** the words of the default note check code adds to a facts line that also asks for written words (the one list's `$` row, build 2026-11-14 (b)); the card reads a part with exactly these words as `[default]` @param {number} n the job line @returns {string} */
990
+ export const defaultNoteText = (n) => `line ${n} writes a note — the note must be there`;
991
+ /** is this part the default note check of line `n`? */
992
+ const isDefaultNote = (/** @type {any} */ p, /** @type {number} */ n) => isRec(p) && p.class === 'countable' && p.check === 'nonEmpty' && p.text === defaultNoteText(n);
993
+
994
+ /**
995
+ * Does the signed close really put a text-present check on job line `n`'s step file? (ONE reader, derived from the close: the protections list and the brief never claim it otherwise.)
996
+ * A facts line has no text check unless a countable part (a pick, or the default note) sits beside its facts; a line with no stage has none.
997
+ * @param {any} closeDecl @param {number} n @returns {boolean}
998
+ */
999
+ export function lineCarriesText(closeDecl, n) {
1000
+ const stages = isRec(closeDecl) && Array.isArray(closeDecl.stages) ? closeDecl.stages : [];
1001
+ return stages.some((/** @type {any} */ st) => isRec(st) && st.kind === 'rubric-step' && isRec(st.params) && st.params.step === n && Array.isArray(st.params.parts)
1002
+ && !(factPartOf(st.params) && !st.params.parts.some((/** @type {any} */ x) => isRec(x) && x.class === 'countable')));
1003
+ }
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
+
971
1047
  /**
972
1048
  * The checks a signed close actually runs, per job line, in plain code-written sentences: one per countable part of every
973
1049
  * rubric-step stage. This is the ONE reader both the plan card and the sign-time invariant use.
974
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;
975
1051
  * `default` = code's own (the one list's `$` rows: the cited part written by `defaultCitedText`, and the numbers tie of a text step).
976
- * @param {any} closeDecl
977
- * @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}[]}
978
1055
  */
979
- export function checksOfClose(closeDecl) {
1056
+ export function checksOfClose(closeDecl, jobLines = null) {
980
1057
  const stages = isRec(closeDecl) && Array.isArray(closeDecl.stages) ? closeDecl.stages : [];
981
1058
  const record = isRec(closeDecl) && Array.isArray(closeDecl.picks) ? closeDecl.picks : [];
982
1059
  const list = isRec(closeDecl) && Array.isArray(closeDecl.list) ? closeDecl.list.filter((/** @type {any} */ r) => isRec(r) && r.state === 'built') : [];
@@ -990,20 +1067,46 @@ export function checksOfClose(closeDecl) {
990
1067
  const r = list.find((/** @type {any} */ x) => x.line === line && x.kind === 'count' && isRec(x.part) && x.part.part === pi);
991
1068
  return r ? { by: /** @type {'agent'|'you'|'default'} */ (r.by), key: String(r.key) } : null;
992
1069
  };
993
- return stages.flatMap((/** @type {any} */ st) => (isRec(st) && st.kind === 'rubric-step' && isRec(st.params) && Array.isArray(st.params.parts)
994
- ? 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) => {
995
1092
  if (!isRec(p) || (p.class !== 'countable' && p.class !== 'fact')) return [];
996
1093
  /** @type {'agent'|'you'|'default'} */
997
- const by = p.check === 'numbersFromFacts' || (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';
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';
998
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
999
- 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
+ }
1000
1103
  const facts = Array.isArray(p.facts) ? p.facts : [];
1001
1104
  return factRows(p).map((/** @type {string} */ text, /** @type {number} */ i) => {
1002
1105
  const own = i < facts.length ? factBy(st.params.step, facts[i]?.name) : countBy(st.params.step, pi);
1003
1106
  return { line: st.params.step, text, by: own?.by ?? by, ...(own ? { key: own.key } : {}) };
1004
1107
  });
1005
- })
1006
- : []));
1108
+ }), ...floorOf(st)]
1109
+ : [])), ...repoRows, ...guardRows, ...fenceRows];
1007
1110
  }
1008
1111
 
1009
1112
  /**
@@ -1022,16 +1125,16 @@ export function signedFactNames(closeDecl) {
1022
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
1023
1126
  * in: a rubric confirm turn plans the goal only, so a check can never be shown and then silently dropped (run mv5bk400).
1024
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
1025
- * @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'>}}
1026
1129
  */
1027
1130
  export function cardOfClose({ closeDecl, jobLines = null, ledger = null }) {
1028
- 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) : [];
1029
1132
  const items = ruleNotCheckedItems(closeDecl, jobLines, ledger);
1030
1133
  /** @type {Record<string, 'you'|'agent'|'default'>} */
1031
1134
  const notCheckedBy = {};
1032
1135
  for (const i of items) if (i.by) notCheckedBy[i.text] = i.by;
1033
1136
  return {
1034
- 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 } : {}) })),
1035
1138
  notChecked: [...new Set([...notes, ...proseNotChecked(closeDecl), ...items.map((i) => i.text)])],
1036
1139
  notCheckedBy,
1037
1140
  };
@@ -1048,8 +1151,13 @@ export function listMatchesClose(closeDecl) {
1048
1151
  if (list === null) return { ok: true };
1049
1152
  const stages = Array.isArray(closeDecl.stages) ? closeDecl.stages : [];
1050
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);
1051
- const built = list.filter((/** @type {any} */ r) => isRec(r) && r.state === 'built' && r.kind !== 'floor');
1052
- 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])))];
1053
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))];
1054
1162
  const bare = lines.flatMap((/** @type {number} */ n) => partsOn(n).map((/** @type {any} */ p, /** @type {number} */ i) => ({ n, i, p })))
1055
1163
  .filter(({ p }) => isRec(p) && (p.class === 'countable' || p.class === 'fact'))
@@ -1066,12 +1174,12 @@ export function listMatchesClose(closeDecl) {
1066
1174
  /**
1067
1175
  * The sign-time invariant: the checks the person was shown (`shown`, from the plan card) are exactly the checks the signed
1068
1176
  * close runs (`checksOfClose`), per line. Pure.
1069
- * @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)
1070
1178
  * @returns {{ok: true}|{ok: false, error: string}}
1071
1179
  */
1072
- export function planMatchesClose(shown, closeDecl) {
1180
+ export function planMatchesClose(shown, closeDecl, jobLines = null) {
1073
1181
  const key = (/** @type {number|null|undefined} */ line, /** @type {string} */ text) => `line ${line ?? '?'}: ${text}`;
1074
- const ran = checksOfClose(closeDecl).map((c) => key(c.line, c.text));
1182
+ const ran = checksOfClose(closeDecl, jobLines).map((c) => key(c.line, c.text));
1075
1183
  const saw = shown.map((c) => key(Array.isArray(c.fromLine) ? c.fromLine[0] : null, c.text));
1076
1184
  const onlyShown = saw.filter((k) => !ran.includes(k));
1077
1185
  const onlyRan = ran.filter((k) => !saw.includes(k));