fwdloop 0.35.2 → 0.37.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 (104) hide show
  1. package/README.md +1 -1
  2. package/bin/fwdloop +5 -2
  3. package/package.json +3 -3
  4. package/src/action-stop.js +1 -1
  5. package/src/auditchecks.js +41 -9
  6. package/src/authoring.js +78 -20
  7. package/src/blockasks.js +10 -12
  8. package/src/blockassemble.js +49 -43
  9. package/src/blockdraft.js +4 -2
  10. package/src/blockpick.js +10 -0
  11. package/src/canrun.js +2 -1
  12. package/src/cardlist.js +28 -5
  13. package/src/checkblock.js +610 -64
  14. package/src/checked.js +28 -33
  15. package/src/checklistsign.js +2 -1
  16. package/src/checklook.js +45 -0
  17. package/src/checkrows.js +202 -0
  18. package/src/cited-record.js +2 -2
  19. package/src/citedcheck.js +53 -12
  20. package/src/citedwords.js +7 -4
  21. package/src/closers.js +49 -2
  22. package/src/declaration.js +26 -4
  23. package/src/drafter.js +86 -62
  24. package/src/factwords.js +7 -4
  25. package/src/globprefix.js +26 -0
  26. package/src/model-step.js +22 -4
  27. package/src/pageask.js +6 -4
  28. package/src/pagedropwords.js +3 -11
  29. package/src/pagedry.js +75 -1
  30. package/src/pagefetch.js +11 -6
  31. package/src/pagelook.js +2 -1
  32. package/src/pagerules.js +8 -2
  33. package/src/panel/author.js +20 -8
  34. package/src/panel/authorcard.js +3 -3
  35. package/src/panel/data.js +3 -2
  36. package/src/panel/index.html +176 -41
  37. package/src/panel/result.js +40 -3
  38. package/src/pickrecord.js +14 -0
  39. package/src/planrebuild.js +55 -19
  40. package/src/ratelimit.js +117 -0
  41. package/src/report.js +216 -0
  42. package/src/rowresults.js +111 -0
  43. package/src/rubricstep.js +65 -2
  44. package/src/runner.js +61 -9
  45. package/src/send.js +19 -82
  46. package/src/shapebuild.js +281 -0
  47. package/src/shapelook.js +91 -0
  48. package/src/shapemenu.js +64 -0
  49. package/src/shaperesult.js +104 -0
  50. package/src/shaperows.js +263 -0
  51. package/src/shapewords.js +140 -0
  52. package/src/sheetbuild.js +41 -29
  53. package/src/sheetclaims.js +49 -1
  54. package/src/sheetfind.js +8 -0
  55. package/src/sheetlook.js +11 -1
  56. package/src/sheetrows.js +10 -64
  57. package/src/ticketrows.js +1 -1
  58. package/src/try-checks.js +39 -6
  59. package/src/types.js +1 -0
  60. package/src/whole-job.js +108 -16
  61. package/types/action-stop.d.ts +1 -1
  62. package/types/auditchecks.d.ts +13 -2
  63. package/types/authoring.d.ts +24 -4
  64. package/types/blockasks.d.ts +6 -10
  65. package/types/blockassemble.d.ts +13 -13
  66. package/types/blockdraft.d.ts +3 -2
  67. package/types/blockpick.d.ts +4 -0
  68. package/types/cardlist.d.ts +18 -2
  69. package/types/checkblock.d.ts +278 -28
  70. package/types/checked.d.ts +15 -6
  71. package/types/checklook.d.ts +36 -0
  72. package/types/checkrows.d.ts +119 -0
  73. package/types/citedcheck.d.ts +4 -2
  74. package/types/closers.d.ts +10 -1
  75. package/types/drafter.d.ts +8 -4
  76. package/types/globprefix.d.ts +5 -0
  77. package/types/model-step.d.ts +43 -2
  78. package/types/pageask.d.ts +5 -3
  79. package/types/pagedropwords.d.ts +0 -1
  80. package/types/pagedry.d.ts +27 -0
  81. package/types/pagefetch.d.ts +3 -2
  82. package/types/pagerules.d.ts +4 -0
  83. package/types/panel/result.d.ts +19 -2
  84. package/types/pickrecord.d.ts +10 -0
  85. package/types/ratelimit.d.ts +59 -0
  86. package/types/report.d.ts +46 -0
  87. package/types/rowresults.d.ts +28 -0
  88. package/types/rubricstep.d.ts +21 -0
  89. package/types/runner.d.ts +3 -1
  90. package/types/send.d.ts +13 -12
  91. package/types/shapebuild.d.ts +97 -0
  92. package/types/shapelook.d.ts +76 -0
  93. package/types/shapemenu.d.ts +40 -0
  94. package/types/shaperesult.d.ts +40 -0
  95. package/types/shaperows.d.ts +102 -0
  96. package/types/shapewords.d.ts +43 -0
  97. package/types/sheetbuild.d.ts +31 -13
  98. package/types/sheetclaims.d.ts +16 -0
  99. package/types/sheetfind.d.ts +1 -0
  100. package/types/sheetrows.d.ts +5 -36
  101. package/types/ticketrows.d.ts +1 -1
  102. package/types/try-checks.d.ts +2 -1
  103. package/types/types.d.ts +4 -0
  104. package/types/whole-job.d.ts +69 -3
package/src/sheetrows.js CHANGED
@@ -1,17 +1,19 @@
1
1
  // M16 am4 (docs/wiki/the-module-ladder.md, "M16 amendment 4" (2)): a sheet line's checks (`close.sheet`) are rows on the plan's list, beside every other check.
2
- // The AI writes the sheet checks (M10b); code only READS them as rows: this file is the ONE writer of a sheet row, of its tag and of its card text, and of the Drop and Add of one.
2
+ // The AI writes the sheet checks (M10b); code only READS them as rows: this file is the ONE writer of a sheet row, of its tag and of its card text.
3
3
  // tag a check whose `covers` names one of the person's `~` rules is `[you]`; a check that covers none (the AI added it) is `[agent]`. (A `[default]` sheet check does not exist: no code adds one.)
4
- // Drop only an `[agent]` row; the check leaves `close.sheet` and is kept in the picks record (`sheetDropped`) so Add can put it back. A `[you]` row has no Drop.
5
- // Add puts a dropped check back at the place it had.
4
+ // Drop only an `[agent]` row, and only the check block drops it (src/checkblock.js `rowChoice`, M19 S3): the check leaves `close.sheet` and the block's `sheetDroppedRecord` keeps it in the picks record (`sheetDropped`). A `[you]` row has no Drop.
5
+ // Add the block puts a dropped check back.
6
6
  // Words are fwd's existing sheet-check words (src/sheetblock.js `sheetPlainText`); nothing here words a check. What this throws away: the check's fields (id, claim, range ...); a row keeps its line, tag, part and key.
7
7
  import { sheetLineBlocks, sheetPlainText } from './sheetblock.js';
8
8
  import { closePartsOf } from './checklistsign.js';
9
- import { isDeepStrictEqual } from 'node:util';
10
9
 
11
10
  const isRec = (/** @type {unknown} */ v) => v !== null && typeof v === 'object' && !Array.isArray(v);
12
11
 
13
12
  /** the key of a sheet row: the block's `L<line>.<tail>` shape, tail `sheet.<check id>` @param {number} line @param {string} id */
14
13
  export const sheetRowKey = (line, id) => `L${line}.sheet.${id}`;
14
+ // borrowed-from: bareloop src/sheetrows.js@v0.60.0 (`sheetCheckBody`; the tag's own header says bareloop copied the rest of that file from fwd)
15
+ /** the fields that say what a check IS: all but the names code gives it (id, claim), the rules it covers and its row tag. Two drafts name checks differently, so "the very same check" is read on these @param {any} c @returns {Record<string, any>} */
16
+ export function sheetCheckBody(c) { const { id: _i, claim: _c, covers: _v, row: _r, ...rest } = c; return rest; }
15
17
  /** @param {unknown} key @returns {boolean} the key is a sheet row's */
16
18
  export const isSheetKey = (key) => typeof key === 'string' && key.startsWith('L') && key.includes('.sheet.');
17
19
 
@@ -48,67 +50,11 @@ export function sheetRowsOf({ declaration, lines, csvRoles }) {
48
50
  }
49
51
 
50
52
  /**
51
- * The plan's card with the sheet rows on it: the sheet rows after the block's rows, a dropped sheet check among the suggestions (Add), as the block's dropped suggestions are.
52
- * @param {{rows: any[], suggested: any[]}} card the block's card (src/cardlist.js) @param {{card: any[]}} sheet `sheetRowsOf` @param {{key: string, line: number, text: string}[]} [dropped]
53
+ * The plan's card with the sheet rows on it: the sheet rows after the block's rows. A dropped sheet check is among the block's own suggestions (Add), like any dropped `!` row (src/cardlist.js).
54
+ * @param {{rows: any[], suggested: any[]}} card the block's card (src/cardlist.js) @param {{card: any[]}} sheet `sheetRowsOf`
53
55
  */
54
- export function withSheetCard(card, sheet, dropped = []) {
55
- return { ...card, rows: [...card.rows, ...sheet.card], suggested: [...card.suggested, ...dropped.map((d) => ({ key: d.key, line: d.line, text: d.text, dropped: true }))] };
56
- }
57
-
58
- /** the dropped sheet checks the picks record keeps: `{key, line, index, check, text}` @returns {any[]} */
59
- export const droppedSheetOf = (/** @type {any} */ record) => (isRec(record) && Array.isArray(record.sheetDropped) ? record.sheetDropped.filter((d) => isRec(d) && typeof d.key === 'string' && isRec(d.check) && Number.isInteger(d.line)) : []);
60
-
61
- /** the fields that say what a check is: all but the names code gives it (id, claim) and the rules it covers */
62
- const checkBody = (/** @type {any} */ c) => { const { id: _i, claim: _c, covers: _v, ...rest } = c; return rest; };
63
-
64
- /**
65
- * M17 am3: the key of the check of the line that IS a dropped one (same typed fields; code names every check, so an id says nothing across drafts), or null. A Revise keeps a Drop only for the very same check.
66
- * @param {any} declaration @param {{line: number, check: any}} d a record of `droppedSheetOf` @returns {string|null}
67
- */
68
- export function keyOfSameCheck(declaration, d) {
69
- for (const st of isRec(declaration) && Array.isArray(declaration.steps) ? declaration.steps : []) {
70
- if (!isRec(st) || st.fromLine !== d.line || !isRec(st.close) || !Array.isArray(st.close.sheet)) continue;
71
- const hit = st.close.sheet.find((/** @type {any} */ c) => isRec(c) && isDeepStrictEqual(checkBody(c), checkBody(d.check)));
72
- if (hit) return sheetRowKey(d.line, String(hit.id));
73
- }
74
- return null;
75
- }
76
-
77
- /**
78
- * The person's Drop or Add on a sheet row, applied to the declaration (a copy). Same words as the block's own refusals (src/checkblock.js `rowChoice`).
79
- * @param {{declaration: any, lines: any[], csvRoles: string[], op: 'drop'|'add', key: string, dropped: any[]}} o
80
- * @returns {{ok: true, declaration: any, dropped: any[]}|{ok: false, why: string}}
81
- */
82
- export function sheetChoice({ declaration, lines, csvRoles, op, key, dropped }) {
83
- if (op === 'drop') {
84
- const row = sheetRowsOf({ declaration, lines, csvRoles }).card.find((r) => r.key === key);
85
- if (!row) return { ok: false, why: 'there is no such check on the list' };
86
- if (row.by === 'you') return { ok: false, why: 'that check comes from a rule you wrote; edit the job to change it' };
87
- let gone = null;
88
- const steps = declaration.steps.map((/** @type {any} */ st) => {
89
- if (gone !== null || !isRec(st) || st.fromLine !== row.line || !isRec(st.close) || !Array.isArray(st.close.sheet)) return st;
90
- const index = st.close.sheet.findIndex((/** @type {any} */ c) => isRec(c) && sheetRowKey(row.line, String(c.id)) === key);
91
- if (index === -1) return st;
92
- gone = { key, line: row.line, index, check: st.close.sheet[index], text: row.text };
93
- const sheet = st.close.sheet.filter((/** @type {unknown} */ _c, /** @type {number} */ k) => k !== index);
94
- const { sheet: _s, ...close } = st.close;
95
- return { ...st, close: sheet.length > 0 ? { ...close, sheet } : close };
96
- });
97
- if (gone === null) return { ok: false, why: 'there is no such check on the list' };
98
- return { ok: true, declaration: { ...declaration, steps }, dropped: [...dropped.filter((d) => d.key !== key), gone] };
99
- }
100
- const was = dropped.find((d) => d.key === key);
101
- if (!was) return { ok: false, why: 'only a suggested check can be added' };
102
- let put = false;
103
- const steps = declaration.steps.map((/** @type {any} */ st) => {
104
- if (put || !isRec(st) || st.fromLine !== was.line || !isRec(st.close) || st.close.class !== 'green') return st;
105
- put = true;
106
- const sheet = Array.isArray(st.close.sheet) ? [...st.close.sheet] : [];
107
- sheet.splice(Math.min(was.index, sheet.length), 0, was.check);
108
- return { ...st, close: { ...st.close, sheet } };
109
- });
110
- if (!put) return { ok: false, why: 'only a suggested check can be added' };
111
- return { ok: true, declaration: { ...declaration, steps }, dropped: dropped.filter((d) => d.key !== key) };
56
+ export function withSheetCard(card, sheet) {
57
+ return { ...card, rows: [...card.rows, ...sheet.card] };
112
58
  }
113
59
 
114
60
  /**
package/src/ticketrows.js CHANGED
@@ -10,7 +10,7 @@ const isRec = (/** @type {unknown} */ v) => v !== null && typeof v === 'object'
10
10
  /** @type {readonly ('ticketFilter'|'ticketWatch')[]} */
11
11
  export const TICKET_FIELDS = Object.freeze(['ticketFilter', 'ticketWatch']);
12
12
  /** the Not-checked reason of a ticket rule no legal value was suggested for (the block's own noPick sentence is used by the caller's words) */
13
- export const NO_VALUE_WHY = 'No check was picked for it, so you judge it at the Ask.';
13
+ export const NO_VALUE_WHY = 'No check was picked for it, so you judge it at Accept.';
14
14
 
15
15
  /**
16
16
  * Which signed field a Tickets rule is the check of: `ticketWatch` (a state or labels change), `ticketFilter` (a priority P0 to P3 or a label), or null (a content rule or a count).
package/src/try-checks.js CHANGED
@@ -6,6 +6,10 @@ import { serializeArtifact } from './ask.js';
6
6
  import { labelled } from './checkwords.js';
7
7
  import { sheetRowKey } from './sheetrows.js';
8
8
  import { listLinesOf, partByOf } from './checklistsign.js';
9
+ import { rowResultsOf } from './rowresults.js';
10
+ import { stepRowsOf } from './checkrows.js';
11
+ import { itemCountOf } from './shaperows.js';
12
+ import { rulesOfLine } from './sheetblock.js';
9
13
 
10
14
  export const EVERY_STEP = 'every step';
11
15
  /** the words of the two checks every step has (#1 and #2 below): the Audit's "Always checked" rows, the plan card's and the Job tab's "Always checked" fold */
@@ -47,25 +51,28 @@ export function outputRecord(step, artifact) {
47
51
  * #3 and up: the close's own checks. A softgreen close carries each of its checks; a green close is one check over all its cited fields; a close that
48
52
  * judged nothing (`unparseable`, `crash`) is one check that could not run, with that third outcome as its result.
49
53
  * @param {any} step @param {any} artifact @param {{verdict: string, red?: string|null, checks?: Array<{text:string, ok:boolean, result:string|null}>}} closed @param {any[]} [checkList] the signed list (M16): a line on it tags its checks
54
+ * @param {any[]} [jobLines] the signed job lines (M19 am11: the words of a list line's field rows read the person's rule)
50
55
  */
51
- export function closeRecords(step, artifact, closed, checkList = undefined) {
56
+ export function closeRecords(step, artifact, closed, checkList = undefined, jobLines = undefined) {
52
57
  // M16 item 5: a check of a list line carries `by`, the row's own (`you` / `agent` / `default`); the Audit draws the tag from it. Any other line keeps the words it has.
53
58
  const decl = Array.isArray(checkList) ? { checkList } : undefined;
54
59
  const listed = decl !== undefined && listLinesOf(decl).has(step?.fromLine);
55
60
  const hasCited = step?.close?.class === 'green' && !!step?.close?.cited;
56
61
  const by = (/** @type {number} */ idx, /** @type {'you'|'agent'|'default'} */ fallback) => (listed ? { by: partByOf(decl, step.fromLine, idx) ?? fallback, part: idx } : {});
57
- const rows = factRecords(step, artifact, closed, listed ? (/** @type {number} */ idx) => partByOf(decl, step.fromLine, idx) : undefined, checkList).map((r) => (listed && hasCited && r.n === 3 ? { ...r, text: String(r.text).replace(/ \[agent\]$/, ''), ...by(0, 'agent') } : r));
62
+ const rows = factRecords(step, artifact, closed, listed ? (/** @type {number} */ idx) => partByOf(decl, step.fromLine, idx) : undefined, checkList, jobLines).map((r) => (listed && hasCited && r.n === 3 ? { ...r, text: String(r.text).replace(/ \[agent\]$/, ''), ...by(0, 'agent') } : r));
63
+ // the list's part order is the close's: the fact part, the item-fields part (M19 am10), then each pick, then the tie
64
+ const lead = (hasCited ? 1 : 0) + (step?.close?.itemShape ? 1 : 0);
58
65
  // M10 am22 (1): the picks on a fact line are rows after the fact rows, each judged on the answer's text
59
66
  const picks = Array.isArray(/** @type {any} */ (closed).pickChecks) ? /** @type {any} */ (closed).pickChecks : [];
60
- const pickRows = picks.map((/** @type {any} */ c, /** @type {number} */ i) => ({ n: rows.length + 3 + i, text: listed ? c.text : labelled(c.text, 'picked'), ok: c.ok, result: c.result, source: lineSource(step), ...by((hasCited ? 1 : 0) + i, 'you') }));
67
+ const pickRows = picks.map((/** @type {any} */ c, /** @type {number} */ i) => ({ n: rows.length + 3 + i, text: listed ? c.text : labelled(c.text, 'picked'), ok: c.ok, result: c.result, source: lineSource(step), ...by(lead + i, 'you') }));
61
68
  // M16 R7: the numbers tie of a text line is one more row
62
69
  const tie = /** @type {any} */ (closed).numbersCheck;
63
70
  const picked = Array.isArray(step?.close?.picked) ? step.close.picked.length : Array.isArray(step?.close?.shape?.picked) ? step.close.shape.picked.length : 0;
64
- return [...rows, ...pickRows, ...(tie ? [{ n: rows.length + pickRows.length + 3, text: tie.text, ok: tie.ok, result: tie.result, source: lineSource(step), ...by((hasCited ? 1 : 0) + picked, 'default') }] : [])];
71
+ return [...rows, ...pickRows, ...(tie ? [{ n: rows.length + pickRows.length + 3, text: tie.text, ok: tie.ok, result: tie.result, source: lineSource(step), ...by(lead + picked, 'default') }] : [])];
65
72
  }
66
73
 
67
- /** @param {any} step @param {any} artifact @param {any} closed @param {((idx: number) => string|null)} [partBy] set for a list line (M16): its softgreen picks carry the row's `by` instead of a label @param {any[]} [checkList] the signed list: a sheet row on it gives its check's `by` */
68
- function factRecords(step, artifact, closed, partBy = undefined, checkList = undefined) {
74
+ /** @param {any} step @param {any} artifact @param {any} closed @param {((idx: number) => string|null)} [partBy] set for a list line (M16): its softgreen picks carry the row's `by` instead of a label @param {any[]} [checkList] the signed list: a sheet row on it gives its check's `by` @param {any[]} [jobLines] */
75
+ function factRecords(step, artifact, closed, partBy = undefined, checkList = undefined, jobLines = undefined) {
69
76
  const source = lineSource(step);
70
77
  if (closed.verdict === 'unparseable' || closed.verdict === 'crash') {
71
78
  return [{
@@ -87,6 +94,7 @@ function factRecords(step, artifact, closed, partBy = undefined, checkList = und
87
94
  n: 3, text: labelled('every result is quoted from the saved copy and passes its rules', 'agent'), ok: Array.isArray(/** @type {any} */ (closed).pickChecks) && closed.cited?.check ? closed.cited.check.verdict === 'green' : closed.verdict === 'green', result: `${n} result${n === 1 ? '' : 's'}`, source,
88
95
  }];
89
96
  }
97
+ if (step?.close?.class === 'green' && step?.close?.itemShape && !step.close.cited && partBy !== undefined) return itemShapeRecords(step, closed, checkList, jobLines, source);
90
98
  if (step?.close?.class === 'green') {
91
99
  const n = Object.keys(artifact?.fields ?? {}).length;
92
100
  return [{
@@ -101,3 +109,28 @@ function factRecords(step, artifact, closed, partBy = undefined, checkList = und
101
109
  return { n: 3 + i, text: id === 'keys' ? c.text : labelled(c.text, pk ? 'picked' : 'agent'), ok: c.ok, result: c.result, source };
102
110
  });
103
111
  }
112
+
113
+ /**
114
+ * M19 am11 item 4: a list line that quotes nothing: one record per row of its shape part (each item field, the rule that sets the item count), each with the result of its OWN row (src/rowresults.js `rowResultsOf`, from bareguard's own gaps),
115
+ * its row's `key`, `by` and `part`. A red no row owns is a record of its own, in the closer's words. Never "every cited field matches its source".
116
+ * @param {any} step @param {any} closed @param {any[]|undefined} checkList @param {any[]|undefined} jobLines @param {string} source
117
+ */
118
+ function itemShapeRecords(step, closed, checkList, jobLines, source) {
119
+ const line = step.fromLine;
120
+ const list = Array.isArray(checkList) ? checkList : [];
121
+ const rows = stepRowsOf({ declaration: { checkList: list, steps: [step] }, st: step, lines: Array.isArray(jobLines) ? jobLines : [] }).rows.filter((/** @type {any} */ r) => r.idx === 0 && /:shape:/.test(String(r.part)));
122
+ const ofLine = list.filter((/** @type {any} */ r) => r?.line === line);
123
+ const rules = ofLine.filter((/** @type {any} */ r) => r.kind === 'rule' && r.state === 'built' && r.part?.part === 0).map((/** @type {any} */ r) => r.rule);
124
+ const said = rulesOfLine((Array.isArray(jobLines) ? jobLines : []).find((/** @type {any} */ l) => l?.n === line));
125
+ const ruleCounts = Object.fromEntries(rules.map((/** @type {number} */ k) => [k, itemCountOf(String(said[k - 1] ?? ''))]).filter(([, c]) => c !== null));
126
+ const graded = { verdict: closed.verdict, rawGaps: Array.isArray(closed.shapeGaps) ? closed.shapeGaps : [], ruleCounts };
127
+ const res = rowResultsOf(ofLine, { step: line, parts: [{ ...step.close.itemShape, class: 'shape', rules }] }, graded);
128
+ const got = new Map(res.rows.map((/** @type {any} */ r) => [r.key, r]));
129
+ /** @type {any[]} */
130
+ const out = rows.map((/** @type {any} */ r, /** @type {number} */ i) => {
131
+ const g = got.get(r.key);
132
+ return { n: 3 + i, text: r.text, ok: g?.result === 'passed', result: g === undefined ? 'no result' : g.result === 'passed' ? null : g.result === 'failed' ? g.why : g.result, source, by: r.by, part: r.idx, key: r.key };
133
+ });
134
+ for (const u of res.unclaimed) out.push({ n: 3 + out.length, text: u, ok: false, result: null, source, unclaimed: true });
135
+ return out;
136
+ }
package/src/types.js CHANGED
@@ -255,6 +255,7 @@
255
255
  * @property {Array<{id:string, text:string, ok:boolean, result:string|null}>} [checks] a softgreen close: every check it ran (M4d am29 item 2)
256
256
  * @property {{text: string, ok: boolean, result: string|null}} [numbersCheck] the numbers tie of a text line (M16 R7): beside the class's own verdict
257
257
  * @property {{part: any, check: any, results?: unknown}} [cited] a cited green close (M10 piece 4): the fact part and the check's own answer, for the run's cited-check record
258
+ * @property {any[]} [shapeGaps] a line with an itemShape close (M19 S5): bareguard's own gaps of the items check (names, counts and bounds, never a value)
258
259
  * @property {{inputs: Array<{name:string, sha256:string}>, claims: unknown, checks: Array<{id:string, text:string, ok:boolean, result:string|null}>}} [sheetRecord] a sheet close (M10b piece 2): what the run's sheet-check record keeps
259
260
  */
260
261
 
package/src/whole-job.js CHANGED
@@ -1,9 +1,12 @@
1
- // M13 am9: the file holds the whole job. ONE writer of the whole-job text (`wholeJobText`), ONE finder of the Ask that shows it (`wholeJobAskIndex`).
2
- // The last Ask before the added `write it out` shows every step's result in job order, built by code from each step's saved output (never picked by the AI):
3
- // a work step is one section `## Line <n>: <line words>` + `renderSentMd(<its saved output>)` (the M15 form, unchanged); an Ask before it is one line
4
- // `Line <n>: you accepted this at the Ask.`; the last Ask itself and the send line are not sections. The accepted artifact is `{text}`, so the send ships it unchanged.
5
- // Throws away: nothing of a step's saved output beyond what `renderSentMd` already drops. Third outcomes: a work step with no readable saved output refuses, naming the step.
6
- import { renderSentMd } from './send.js';
1
+ // M13 am9 / M15 am3: the file holds the whole job. ONE writer of the whole-job text (`wholeJobText`), ONE finder of the Ask that shows it (`wholeJobAskIndex`).
2
+ // The last Ask before the action shows every step's result in job order, built by code from each step's saved output (never picked by the AI). Since M15 am3 that text is the BODY of the
3
+ // run's one markdown report (`renderReportBody`, src/report.js: `## <n>. <line>`, the ~ rules, what code checked, the AI's answer under its heading; an Ask before it is one line
4
+ // `Line <n>: you accepted this at the Ask.`); the last Ask itself and the send line are not sections. The accepted artifact is `{text}`; the send adds the title and the Passed line and writes it.
5
+ // Throws away: what `renderReportBody` throws away. Third outcomes: a work step with no readable saved output refuses, naming the step; a frozen sheet the report needs that cannot be read refuses, naming it.
6
+ import { renderReportBody } from './report.js';
7
+ import { readRunSheets } from './sheetrun.js';
8
+ import { readSheetChecks } from './sheet-record.js';
9
+ import { lineRules } from './pagebits.js';
7
10
 
8
11
  /**
9
12
  * The Ask the action reads: the Ask right before the one signed send (M13 am11: the action ships the step before it). -1 = none.
@@ -39,18 +42,65 @@ export function wholeJobAskIndex({ steps, askLines, sendLines }) {
39
42
  return work.length > 0 && reads.length === work.length && work.every((e) => reads.includes(e)) ? idx : -1;
40
43
  }
41
44
 
45
+ /** the `~` rules of a signed job line, one string each: the parsed line carries them joined by "; " in `guardrail` (several `~` lines under one step are one guardrail), as the Result tab reads it @param {any} jl @returns {string[]} */
46
+ export const lineRulesOf = (jl) => (jl && typeof jl.guardrail === 'string' && jl.guardrail !== '' ? jl.guardrail.split('; ').filter(Boolean) : lineRules(jl));
47
+
42
48
  /**
43
- * @param {{ steps: { fromLine: number, goal: string, emits?: string }[], askLines: Map<number, any>, lastAskIndex: number,
44
- * readResult: (id: string) => ({ ok: true, value: any } | { ok: false, missing: true } | { ok: false, missing: false, red: string }) }} p
49
+ * Is the prose of this step checked by code (M15 am3 item 2: `### The answer` instead of the not-checked heading)? Only when code really checked the step's own text (a green close with a words-per-section
50
+ * or picked check on it) AND the signed list holds no Not checked `~` rule on the line. A non-empty / `happened` check alone is no prose check, nor is a sheet or quote check (they check cells and quotes).
51
+ * @param {any} step @param {any[]|null|undefined} [checkList] the plan's signed list (`declaration.checkList`)
52
+ * @returns {boolean}
53
+ */
54
+ export function proseCheckedOf(step, checkList) {
55
+ const rows = (Array.isArray(checkList) ? checkList : []).filter((r) => r && typeof r === 'object' && r.line === step?.fromLine);
56
+ if (rows.some((r) => r.kind === 'rule' && r.state === 'not-checked')) return false;
57
+ const c = step?.close;
58
+ if (c?.class !== 'green') return false;
59
+ const shape = c.shape && typeof c.shape === 'object' ? c.shape : {};
60
+ return shape.wordsPerSection !== undefined || (Array.isArray(shape.picked) && shape.picked.length > 0) || (Array.isArray(c.picked) && c.picked.length > 0);
61
+ }
62
+
63
+ /** the signed shape part of a step (its close's `itemShape`, M19 S5), or null: the report writes the shape section for a line that holds one (M19 amendment C) @param {any} step */
64
+ const shapeOfStep = (step) => (step?.close?.itemShape && typeof step.close.itemShape === 'object' && Array.isArray(step.close.itemShape.fields) ? step.close.itemShape : null);
65
+
66
+ /**
67
+ * What the report needs besides the steps: the signed lines' own words (the `~` rules), the run's frozen sheets and which sheet checks passed. Read once from the run folder.
68
+ * @param {{ runDir: string, steps: any[], jobLines: any[]|null|undefined, checkList?: any[]|null }} p
69
+ * @returns {{ ok: true, jobLines: any[], checkList: any[]|null, tables: Record<string, any>, okIdsOf: (n: number) => Set<string>|null } | { ok: false, red: string }}
70
+ */
71
+ export function reportContextOf({ runDir, steps, jobLines, checkList }) {
72
+ const checks = steps.flatMap((s) => (Array.isArray(s?.close?.sheet) ? s.close.sheet : []));
73
+ /** @type {Record<string, any>} */
74
+ let tables = {};
75
+ if (checks.length > 0) {
76
+ const sheet = readRunSheets(runDir, checks);
77
+ if (!sheet.ok) return { ok: false, red: `ask: the report cannot read the saved sheet — ${sheet.red}` };
78
+ tables = sheet.tables;
79
+ }
80
+ const record = checks.length > 0 ? readSheetChecks(runDir) : null;
81
+ const okIdsOf = (/** @type {number} */ n) => {
82
+ // the newest try of the line that passed: the ids of its checks that passed
83
+ const tries = (record?.lines ?? []).filter((l) => l && l.n === n && l.passed === true && Array.isArray(l.results));
84
+ const last = tries.reduce((m, l) => (m === null || l.try >= m.try ? l : m), /** @type {any} */ (null));
85
+ return last ? new Set(last.results.filter((/** @type {any} */ r) => r && r.ok === true).map((/** @type {any} */ r) => r.id)) : null;
86
+ };
87
+ return { ok: true, jobLines: Array.isArray(jobLines) ? jobLines : [], checkList: Array.isArray(checkList) ? checkList : null, tables, okIdsOf };
88
+ }
89
+
90
+ /**
91
+ * @param {{ steps: { fromLine: number, goal: string, emits?: string, close?: any }[], askLines: Map<number, any>, lastAskIndex: number,
92
+ * readResult: (id: string) => ({ ok: true, value: any } | { ok: false, missing: true } | { ok: false, missing: false, red: string }),
93
+ * context: ReturnType<typeof reportContextOf>, redPrefix?: string }} p `redPrefix` is `ask: ` (an Ask job's words, unchanged); M15 am4 gives a job with no Ask `send: `
45
94
  * @returns {{ ok: true, value: { text: string } } | { ok: false, red: string }}
46
95
  */
47
- export function wholeJobText({ steps, askLines, lastAskIndex, readResult }) {
48
- /** @type {string[]} */
49
- const parts = [];
96
+ export function wholeJobText({ steps, askLines, lastAskIndex, readResult, context, redPrefix = 'ask: ' }) {
97
+ if (!context.ok) return { ok: false, red: context.red };
98
+ /** @type {Parameters<typeof renderReportBody>[0]} */
99
+ const lines = [];
50
100
  for (let i = 0; i < lastAskIndex; i += 1) {
51
101
  const s = steps[i];
52
102
  if (askLines.has(s.fromLine)) {
53
- parts.push(`Line ${s.fromLine}: you accepted this at the Ask.`);
103
+ lines.push({ n: s.fromLine, kind: 'ask' });
54
104
  continue;
55
105
  }
56
106
  const r = readResult(/** @type {string} */ (s.emits));
@@ -58,13 +108,55 @@ export function wholeJobText({ steps, askLines, lastAskIndex, readResult }) {
58
108
  return {
59
109
  ok: false,
60
110
  red: r.missing
61
- ? `ask: the saved output "${s.emits}" of step "${s.goal}" is missing — refusing to show the whole job`
62
- : `ask: the saved output "${s.emits}" of step "${s.goal}" — ${r.red}`,
111
+ ? `${redPrefix}the saved output "${s.emits}" of step "${s.goal}" is missing — refusing to show the whole job`
112
+ : `${redPrefix}the saved output "${s.emits}" of step "${s.goal}" — ${r.red}`,
63
113
  };
64
114
  }
65
- parts.push(`## Line ${s.fromLine}: ${s.goal}\n${renderSentMd(r.value)}`);
115
+ const jl = context.jobLines.find((/** @type {any} */ l) => l && l.n === s.fromLine);
116
+ lines.push({
117
+ n: s.fromLine, kind: 'work', text: s.goal, rules: lineRulesOf(jl), artifact: r.value,
118
+ checks: Array.isArray(s.close?.sheet) ? s.close.sheet : [], okIds: context.okIdsOf(s.fromLine), proseChecked: proseCheckedOf(s, context.checkList),
119
+ shape: shapeOfStep(s),
120
+ });
121
+ }
122
+ return { ok: true, value: { text: renderReportBody(lines, context.tables) } };
123
+ }
124
+
125
+ /**
126
+ * M15 am3 item 6: the body the send writes. A plan whose last Ask shows the whole job (`wholeIdx` >= 0) was accepted AS that text: the body is `{text}` exactly, never rebuilt. A plan signed before
127
+ * M13 am9 (or a job with no Ask) sends the one step right before the send: its section is written from the accepted artifact, the line being that step's own (or, past an Ask, the step the Ask read).
128
+ * M15 am4: a job with no signed Ask (`askLines.size === 0`, no whole-job Ask) writes every work line before the send, in line order: the whole-job text over the steps before the send, the step right before it
129
+ * read from `content` (what the person accepted), the earlier ones from the run's saved outputs (`readResult`). A missing or unreadable earlier output refuses by name, in `send: ` words (never `ask: `).
130
+ * @param {{ content: any, wholeIdx: number, steps: any[], sendIndex: number, askLines: Map<number, any>, context: ReturnType<typeof reportContextOf>,
131
+ * readResult?: (id: string) => ({ ok: true, value: any } | { ok: false, missing: true } | { ok: false, missing: false, red: string }) }} p
132
+ * @returns {{ ok: true, body: string } | { ok: false, red: string }}
133
+ */
134
+ export function sendBodyOf({ content, wholeIdx, steps, sendIndex, askLines, context, readResult }) {
135
+ if (wholeIdx >= 0) {
136
+ return typeof content?.text === 'string' && Object.keys(content).length === 1
137
+ ? { ok: true, body: content.text }
138
+ : { ok: false, red: 'send: the accepted answer is not the whole-job text — refusing to write a report from it' };
139
+ }
140
+ if (!context.ok) return { ok: false, red: context.red };
141
+ const before = steps[sendIndex - 1];
142
+ if (askLines.size === 0) {
143
+ if (!readResult) return { ok: false, red: 'send: no reader for the run\'s saved outputs was given — refusing to write a report' };
144
+ const whole = wholeJobText({
145
+ steps, askLines, lastAskIndex: sendIndex, context, redPrefix: 'send: ',
146
+ readResult: (id) => (before && id === before.emits ? { ok: true, value: content } : readResult(id)),
147
+ });
148
+ return whole.ok ? { ok: true, body: whole.value.text } : whole;
66
149
  }
67
- return { ok: true, value: { text: parts.join('\n\n') } };
150
+ const made = before && askLines.has(before.fromLine) ? steps.find((x) => x.emits === (before.reads ?? [])[0]) ?? before : before;
151
+ const jl = context.jobLines.find((/** @type {any} */ l) => l && l.n === made?.fromLine);
152
+ return {
153
+ ok: true,
154
+ body: renderReportBody([{
155
+ n: made?.fromLine, kind: 'work', text: made?.goal, rules: lineRulesOf(jl), artifact: content,
156
+ checks: Array.isArray(made?.close?.sheet) ? made.close.sheet : [], okIds: context.okIdsOf(made?.fromLine), proseChecked: proseCheckedOf(made, context.checkList),
157
+ shape: shapeOfStep(made),
158
+ }], context.tables),
159
+ };
68
160
  }
69
161
 
70
162
  /**
@@ -21,7 +21,7 @@ export function lastAcceptedSha(steps: {
21
21
  emits?: string;
22
22
  }[], i: number, acceptedAskEmitsThisRun: Map<string, string | null>): string | null;
23
23
  /**
24
- * am11a 1/2: the wait of the stop. The LAST Ask's own wait when the job has an Ask before the action; else the card's Ask wait kept in the run's signed values (`arbiter.actionWaitMs`), else 1h.
24
+ * am11a 1/2: the wait of the stop. The LAST Ask's own wait when the job has an Ask before the action; else the card's Ask wait kept in the run's signed values (`sendSlot.waitMs`, src/runvalues.js), else 1h.
25
25
  * @param {{ fromLine: number }[]} steps @param {number} i @param {Map<number, {ttlMs: number}>} askLines @param {number|undefined} actionWaitMs
26
26
  */
27
27
  export function stopWaitMs(steps: {
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * @param {any} declaration the signed plan @param {any[]} diary the run's `checks` rows (src/diary.js readChecks) @param {{items?: string[], by?: Record<string, string>}|null} notChecked the sign row's Not-checked block
3
3
  * @param {{lines?: any[], csvRoles?: string[]}} [sheet] the signed job lines and CSV roles: a plan whose list has sheet rows (M16 am4) shows them here, tagged by where each comes from (hamr 2026-11-14)
4
- * @returns {{checks: AuditCheckRow[], notChecked: AuditCheckRow[], readNotes: string[], always: AuditCheckRow[]}|null} null for a plan with no list (it keeps its own Audit rows)
5
- * @typedef {{text: string, by: 'you'|'agent'|'default'|null, result: 'passed'|'failed'|'none'|'not-checked'}} AuditCheckRow
4
+ * @returns {{checks: AuditCheckRow[], notChecked: AuditCheckRow[], readNotes: string[], always: AuditCheckRow[], lines: AuditLine[], jobNotChecked: AuditCheckRow[]}|null} null for a plan with no list (it keeps its own Audit rows)
5
+ * @typedef {{n: number, text: string, checks: AuditCheckRow[], notChecked: AuditCheckRow[]}} AuditLine
6
+ * @typedef {{text: string, by: 'you'|'agent'|'default'|null, result: 'passed'|'failed'|'none'|'not-checked', kind?: 'truth'|'shape'|'file', why?: string}} AuditCheckRow
6
7
  */
7
8
  export function auditChecksOf(declaration: any, diary: any[], notChecked: {
8
9
  items?: string[];
@@ -15,11 +16,21 @@ export function auditChecksOf(declaration: any, diary: any[], notChecked: {
15
16
  notChecked: AuditCheckRow[];
16
17
  readNotes: string[];
17
18
  always: AuditCheckRow[];
19
+ lines: AuditLine[];
20
+ jobNotChecked: AuditCheckRow[];
18
21
  } | null;
19
22
  /** the words of a row no result was recorded for: never "passed" */
20
23
  export const AUDIT_NO_RESULT: "no result recorded";
24
+ export type AuditLine = {
25
+ n: number;
26
+ text: string;
27
+ checks: AuditCheckRow[];
28
+ notChecked: AuditCheckRow[];
29
+ };
21
30
  export type AuditCheckRow = {
22
31
  text: string;
23
32
  by: "you" | "agent" | "default" | null;
24
33
  result: "passed" | "failed" | "none" | "not-checked";
34
+ kind?: "truth" | "shape" | "file";
35
+ why?: string;
25
36
  };
@@ -23,7 +23,7 @@ export function specHash({ proseText, declarationText, inputFactsText, readoutTe
23
23
  * answer file counts as no answer. No questions file = `{ questions: [], open: [] }`.
24
24
  * @param {string} planDir
25
25
  * A question the page look raised (M10 piece 3) also carries `source: 'look'`, `ask` ('reading' | 'cant-check'), `ruleNo`, `ruleText` and `proposal`; an answer file carries `at`.
26
- * @returns {{ questions: {k:number, line:number, question:string, answer:string|null, at?:string, rule?:string|null, choice?:'agree'|'drop'|'rule', source?:string, ask?:string, ruleNo?:number, ruleText?:string, proposal?:string|null, check?:Record<string, any>, pairRule?:number}[], open: {k:number, line:number, question:string, answer:null}[] }}
26
+ * @returns {{ questions: {k:number, line:number, question:string, answer:string|null, at?:string, rule?:string|null, choice?:'agree'|'drop'|'rule'|'column', source?:string, ask?:string, ruleNo?:number, ruleText?:string, proposal?:string|null, check?:Record<string, any>, pairRule?:number, columns?:string[], readings?:Record<string,string>}[], open: {k:number, line:number, question:string, answer:null}[] }}
27
27
  */
28
28
  export function readQuestions(planDir: string): {
29
29
  questions: {
@@ -33,7 +33,7 @@ export function readQuestions(planDir: string): {
33
33
  answer: string | null;
34
34
  at?: string;
35
35
  rule?: string | null;
36
- choice?: "agree" | "drop" | "rule";
36
+ choice?: "agree" | "drop" | "rule" | "column";
37
37
  source?: string;
38
38
  ask?: string;
39
39
  ruleNo?: number;
@@ -41,6 +41,8 @@ export function readQuestions(planDir: string): {
41
41
  proposal?: string | null;
42
42
  check?: Record<string, any>;
43
43
  pairRule?: number;
44
+ columns?: string[];
45
+ readings?: Record<string, string>;
44
46
  }[];
45
47
  open: {
46
48
  k: number;
@@ -60,7 +62,7 @@ export function fmtTtl(ms: any): string;
60
62
  /** Zero-based indexes of the header and heading lines in a readout's text (split on "\n"): the panel renders those bold. */
61
63
  export function readoutHeadIndexes(text: any): any[];
62
64
  /** Plain-text readout of what the human is about to sign. Pure. */
63
- export function buildReadout({ declaration, arbiter, lines, name, modelId, costUsd, rounds, spendComplete, root, }: {
65
+ export function buildReadout({ declaration, arbiter, lines, name, modelId, costUsd, rounds, spendComplete, root, notChecked, notCheckedBy, suggested, checkCard, }: {
64
66
  declaration: any;
65
67
  arbiter: any;
66
68
  lines: any;
@@ -70,6 +72,23 @@ export function buildReadout({ declaration, arbiter, lines, name, modelId, costU
70
72
  rounds: any;
71
73
  spendComplete: any;
72
74
  root: any;
75
+ notChecked?: string[] | undefined;
76
+ notCheckedBy?: Record<string, string> | undefined;
77
+ suggested?: {
78
+ line: number;
79
+ text: string;
80
+ key?: string;
81
+ dropped?: boolean;
82
+ }[] | undefined;
83
+ checkCard?: {
84
+ rows: {
85
+ line: number;
86
+ by: string;
87
+ state: string;
88
+ text: string;
89
+ kind?: string;
90
+ }[];
91
+ } | null | undefined;
73
92
  }): string;
74
93
  /** Read the prose file. Refuses (a red, never a throw) on unreadable or blank. */
75
94
  export function readProseFile(file: any): {
@@ -113,7 +132,7 @@ export function writePlanFiles(dir: string, files: Record<string, string>, opts?
113
132
  * Test seam: `provider`/`rates`/`modelId` are injected; without them a live provider is built.
114
133
  * `onResult({ ok })` (M4d am32): called once, after the spend is booked and just before the result files are written (the CLI gives its monthly hold back there).
115
134
  */
116
- export function draftToDir({ proseFile, dir, root, name, slot, model, draftThinking, keyNames, env, provider, rates, modelId, noQuestions, onResult, fetchPage, leftRules, columnAnswers, carriedColumns, checkPicks, carriedPicks, carriedChoices, carriedSheetDropped, proseRead, flowType, mcpServer, mcpPick, mcpServers, actionMode, }: {
135
+ export function draftToDir({ proseFile, dir, root, name, slot, model, draftThinking, keyNames, env, provider, rates, modelId, noQuestions, onResult, fetchPage, leftRules, columnAnswers, carriedColumns, checkPicks, carriedPicks, carriedChoices, carriedSheetDropped, carriedShapeDropped, proseRead, flowType, mcpServer, mcpPick, mcpServers, actionMode, }: {
117
136
  proseFile: any;
118
137
  dir: any;
119
138
  root: any;
@@ -136,6 +155,7 @@ export function draftToDir({ proseFile, dir, root, name, slot, model, draftThink
136
155
  carriedPicks: any;
137
156
  carriedChoices: any;
138
157
  carriedSheetDropped: any;
158
+ carriedShapeDropped: any;
139
159
  proseRead: any;
140
160
  flowType?: "tickets" | "mcp" | "plain" | undefined;
141
161
  mcpServer?: string | undefined;
@@ -1,14 +1,10 @@
1
- /** @typedef {{key: string, rowKey: string, line: number, rule: number, source: 'look', ask: 'reading'|'cant-check'|'no-check'|'check', ruleText: string, question: string, counted: boolean, reading?: string, check?: Record<string, any>}} BlockAsk */
1
+ /** @typedef {{key: string, rowKey: string, line: number, rule: number, source: 'look', ask: 'reading'|'check', ruleText: string, question: string, counted: boolean, reading?: string, check?: Record<string, any>}} BlockAsk */
2
2
  /**
3
- * The questions the block has open, in the order the person meets them: the look's readings, then the look's can't-checks, then the pick path's asks (a proposal or a can't-check about a rule the pick path owns) in rule order (a proposal is not counted toward the 3-ask cap).
4
- * A can't-check about a rule the PICK path owns (`scoped`: src/checkpick.js scopedRules, every `~` rule of a file job) is the pick path's own ask, `no-check`, in fwd's words (a "Line N, guardrail ...: I can't check this" ask
5
- * whose answer the panel records as a pick, so Revise carries it: am17/am18/am21); any other can't-check is the look's own ask about a page.
6
- * @param {import('./checkblock.js').CheckBlock} block @param {{line: number, rule: number}[]} [scoped] @returns {BlockAsk[]}
3
+ * The questions the block has open, in the order the person meets them: the look's readings, then the pick path's proposals (a proposal is not counted toward the 3-ask cap).
4
+ * M19 am3: a rule no check can settle is no longer asked, so `block.open` holds only `reading` and `check` asks; any other kind is a bug and throws.
5
+ * @param {import('./checkblock.js').CheckBlock} block @returns {BlockAsk[]}
7
6
  */
8
- export function questionsOfBlock(block: import("./checkblock.js").CheckBlock, scoped?: {
9
- line: number;
10
- rule: number;
11
- }[]): BlockAsk[];
7
+ export function questionsOfBlock(block: import("./checkblock.js").CheckBlock): BlockAsk[];
12
8
  /**
13
9
  * The person's choices back into the block, one by one (the choice decides, never the words). A choice the block refuses is returned with its plain reason; the question stays open.
14
10
  * @param {import('./checkblock.js').CheckBlock} block @param {{key: string, choice: string, text?: string}[]} choices @returns {{key: string, why: string}[]}
@@ -27,7 +23,7 @@ export type BlockAsk = {
27
23
  line: number;
28
24
  rule: number;
29
25
  source: "look";
30
- ask: "reading" | "cant-check" | "no-check" | "check";
26
+ ask: "reading" | "check";
31
27
  ruleText: string;
32
28
  question: string;
33
29
  counted: boolean;
@@ -1,21 +1,14 @@
1
- /**
2
- * The words a Not-checked row says. A rule the person left, wrote in their own words, or left with no pick keeps fwd's signed table (M10 am16 (5): src/pagedropwords.js), the words the plan card and the
3
- * Audit already had; any other reason is the block's own (what code could not build and why).
4
- * @param {string|null|undefined} reason @param {{cantAsked?: boolean}} [row]
5
- */
6
- export function notCheckedWords(reason: string | null | undefined, row?: {
7
- cantAsked?: boolean;
8
- }): string;
9
1
  /** a countable part as the picked check the softgreen close runs: its own fields, the rule named `rule` (the inverse of the block's partOfPick) @param {Record<string, any>} part */
10
2
  export function pickedOf(part: Record<string, any>): {
11
3
  rule: any;
12
4
  };
13
5
  /**
14
- * @param {{declaration: Record<string, any>, block: import('./checkblock.js').CheckBlock, lines: {n: number, guardrail?: string|null}[], lineSet: Set<number>, askLines?: Set<number>}} o
15
- * `lineSet` = the lines the block was given; `lines` = the signed lines (a guardrail decides the class); `askLines` = the signed Ask lines: each `~` rule on one is a Not-checked line here, never skipped (M17 am5 item 2)
6
+ * @param {{declaration: Record<string, any>, block: import('./checkblock.js').CheckBlock, lines: {n: number, guardrail?: string|null}[], lineSet: Set<number>, askLines?: Set<number>, sheetRoles?: string[], shapeOnlyClass?: 'green'|null}} o
7
+ * `lineSet` = the lines of the list (the block's step lines that are not sheet lines); `lines` = the signed lines (a guardrail decides the class); `askLines` = the signed Ask lines: each `~` rule on one is a Not-checked line here, never skipped (M17 am5 item 2);
8
+ * `sheetRoles` = the CSV inputs: the block's sheet part of a sheet line is the `close.sheet` of the line's first green step that reads one (M19 S3: the checks the block holds, drops and all)
16
9
  * @returns {{declaration: Record<string, any>, notChecked: string[], notCheckedBy: Record<string, 'you'|'agent'|'default'>, built: Set<number>}} `built` = the lines that got a check from the block (a red naming one of them is a fault of the build)
17
10
  */
18
- export function assembleFromBlock({ declaration, block, lines, lineSet, askLines }: {
11
+ export function assembleFromBlock({ declaration, block, lines, lineSet, askLines, sheetRoles, shapeOnlyClass }: {
19
12
  declaration: Record<string, any>;
20
13
  block: import("./checkblock.js").CheckBlock;
21
14
  lines: {
@@ -24,6 +17,8 @@ export function assembleFromBlock({ declaration, block, lines, lineSet, askLines
24
17
  }[];
25
18
  lineSet: Set<number>;
26
19
  askLines?: Set<number>;
20
+ sheetRoles?: string[];
21
+ shapeOnlyClass?: "green" | null;
27
22
  }): {
28
23
  declaration: Record<string, any>;
29
24
  notChecked: string[];
@@ -46,5 +41,10 @@ export function closeUnbuiltSheetSteps(declaration: Record<string, any>, unbuilt
46
41
  };
47
42
  /** M17 am5 item 2 (D3): the reason a `~` rule on a signed Ask line is Not checked, the signed words */
48
43
  export const ASK_LINE_REASON: "you judge it at the Ask";
49
- /** what a row says when its check cannot ride a line that has no guardrail of its own (the class of a line comes from its guardrail) */
50
- export const NO_GUARDRAIL_WORDS: "This line has no guardrail of yours, so a check on it cannot be signed; you judge it at the Ask.";
44
+ /**
45
+ * M19 amendment 1 (signed 2026-11-20): a line that is a list of items and nothing else (no quote) signs class `green` with `itemShape` and no `cited`; the person's own rules on its text still ride beside it. `null` (tests only) signs no
46
+ * list-of-items check and the rows are Not checked (REASON.noRule). A facts+shape line keeps its class (green, `cited` plus `itemShape`, amendment E) whatever this says.
47
+ * @type {'green'|null}
48
+ */
49
+ export const SHAPE_ONLY_CLASS: "green" | null;
50
+ export { NO_GUARDRAIL_WORDS } from "./checkblock.js";
@@ -9,13 +9,14 @@ export function isBuildFault(red: string, builtLines: number[]): boolean;
9
9
  /**
10
10
  * The block of a draft (M16 item 2): the person's `~` rules and `$` defaults, then the look's facts, then the picks the person made (kept from the last draft, and just answered), reconciled once.
11
11
  * Fresh answers go through `carry` like the kept ones (the draft is a child process: the answer comes back as a pick or a left rule), and are not marked "kept".
12
- * @param {{leaveOut?: {line: number, rule: number}[], texts: Record<string, string>, jobLines: any[], look: {facts: any[], dropped: any[]}, kept: {picks: any[], left: any[], askRules: any[]}, fresh: {picks: any[], left: {line: number, rule: number}[]}, asks: boolean, countScope: (t: string) => boolean}} o
12
+ * @param {{leaveOut?: {line: number, rule: number}[], sheetLines?: number[], texts: Record<string, string>, jobLines: any[], look: {facts: any[], dropped: any[]}, kept: {picks: any[], left: any[], askRules: any[]}, fresh: {picks: any[], left: {line: number, rule: number}[]}, asks: boolean, countScope: (t: string) => boolean}} o
13
13
  */
14
- export function setUpBlock({ texts, jobLines, look, kept, fresh, asks, countScope, leaveOut }: {
14
+ export function setUpBlock({ texts, jobLines, look, kept, fresh, asks, countScope, leaveOut, sheetLines }: {
15
15
  leaveOut?: {
16
16
  line: number;
17
17
  rule: number;
18
18
  }[];
19
+ sheetLines?: number[];
19
20
  texts: Record<string, string>;
20
21
  jobLines: any[];
21
22
  look: {
@@ -40,6 +40,10 @@ export function partOfPick(check: Record<string, any>, text: string, rules: numb
40
40
  class: string;
41
41
  check: any;
42
42
  };
43
+ /** the numbers a text says as "under / fewer than / less than / below N" (the one reader of that wording: a list-items rule and a shape field's bound both use it) @param {string} text @returns {number[]} */
44
+ export function underNumbers(text: string): number[];
45
+ /** the numbers a text says as "at most / up to / no more than / not more than N" @param {string} text @returns {number[]} */
46
+ export function atMostNumbers(text: string): number[];
43
47
  export { plainWords };
44
48
  export function isCountable(g: unknown): boolean;
45
49
  export function sameRuleWords(a: unknown, b: unknown): boolean;