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
@@ -1,6 +1,6 @@
1
1
  // M16 item 2 (docs/wiki/the-module-ladder.md, "M16"): "the AI sends only edits to that list; code proves each one and builds every check. The AI never writes a check."
2
2
  // The declaration of a draft with the list on keeps the AI's steps, reads, primitives and asks, and takes the CHECKS of every line the block was given from the block's built parts:
3
- // a fact part -> close.cited = {source, facts, count}, class green; the source is added to the step's reads by code
3
+ // a fact part -> close.cited = {source, facts, count, asSeen}, class green; the source is added to the step's reads by code
4
4
  // a countable part -> a picked check (M10 am22 (1)-(3)): close.shape.picked on a softgreen step, close.picked on a fact (or sheet) step with the line in pickedLines
5
5
  // the numbers tie -> close.numbersFrom (M16 am3 (2), R7)
6
6
  // no part -> hitl; the rows' Not-checked reasons are the list's own (no `unjudgeable` record, M17 am4)
@@ -11,33 +11,23 @@
11
11
  /** M17 am5 item 2 (D3): the reason a `~` rule on a signed Ask line is Not checked, the signed words */
12
12
  export const ASK_LINE_REASON = 'you judge it at the Ask';
13
13
 
14
- /** 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) */
15
- 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.';
14
+ /**
15
+ * 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
16
+ * 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.
17
+ * @type {'green'|null}
18
+ */
19
+ export const SHAPE_ONLY_CLASS = 'green';
20
+
21
+ // fwd (F251): the no-guardrail words are the check block's (src/checkblock.js), the one writer; re-exported for the readers that import them from here
22
+ export { NO_GUARDRAIL_WORDS } from './checkblock.js';
16
23
 
17
- import { REASON, renderCard } from './checkblock.js';
18
- import { dropSentence } from './pagedropwords.js';
24
+ import { REASON } from './checkblock.js';
19
25
  import { KEPT_WORDS } from './pickrecord.js';
20
26
  import { lineRules } from './pagebits.js';
27
+ import { isListedNotChecked, notCheckedItem, ruleTextOf } from './checkrows.js';
21
28
 
22
29
  const isRec = (/** @type {unknown} */ v) => v !== null && typeof v === 'object' && !Array.isArray(v);
23
30
 
24
- /** the words the card draws a row with, without its `~` / `!` / `$` mark (the one renderer, src/checkblock.js renderCard) @param {Record<string, any>} row */
25
- const rowWords = (row) => String(renderCard([{ ...row, hidden: false, state: row.state === 'suggested' || row.state === 'dropped' ? 'not-checked' : row.state }])[0]?.text ?? '').slice(2);
26
-
27
- /**
28
- * 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
29
- * Audit already had; any other reason is the block's own (what code could not build and why).
30
- * @param {string|null|undefined} reason @param {{cantAsked?: boolean}} [row]
31
- */
32
- export function notCheckedWords(reason, row = undefined) {
33
- // a rule the person answered with their own words says so, whatever bareguard-free reason the block holds for it (a countable one reads "no rule can check this")
34
- if (row?.cantAsked === true && (reason === REASON.noRule || reason === REASON.nothingOnPage)) return dropSentence({ line: 0, fact: '', reason: 'own-words' });
35
- if (reason === REASON.left) return dropSentence({ line: 0, fact: '', reason: 'person-left' });
36
- if (reason === REASON.nothingOnPage) return dropSentence({ line: 0, fact: '', reason: 'own-words' });
37
- if (reason === REASON.noRule || reason === REASON.noPick || reason === REASON.cantCheck) return dropSentence({ line: 0, fact: '', reason: 'no-pick' });
38
- return String(reason ?? 'not checked');
39
- }
40
-
41
31
  /** 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 */
42
32
  export function pickedOf(part) {
43
33
  const { text: _t, class: _c, check, rules: _r, source: _s, from: _f, oldIndex: _o, ...fields } = part;
@@ -45,11 +35,12 @@ export function pickedOf(part) {
45
35
  }
46
36
 
47
37
  /**
48
- * @param {{declaration: Record<string, any>, block: import('./checkblock.js').CheckBlock, lines: {n: number, guardrail?: string|null}[], lineSet: Set<number>, askLines?: Set<number>}} o
49
- * `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)
38
+ * @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
39
+ * `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);
40
+ * `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)
50
41
  * @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)
51
42
  */
52
- export function assembleFromBlock({ declaration, block, lines, lineSet, askLines = new Set() }) {
43
+ export function assembleFromBlock({ declaration, block, lines, lineSet, askLines = new Set(), sheetRoles = [], shapeOnlyClass = SHAPE_ONLY_CLASS }) {
53
44
  if (!isRec(declaration) || !Array.isArray(declaration.steps)) return { declaration, notChecked: [], notCheckedBy: {}, built: new Set() };
54
45
  const c = block.reconcile();
55
46
  const partsOf = (/** @type {number} */ n) => c.map.filter((m) => m.line === n).map((m) => ({ ...c.parts[m.part], oldIndex: c.map.filter((x) => x.line === n).findIndex((x) => x.part === m.part) }));
@@ -57,37 +48,53 @@ export function assembleFromBlock({ declaration, block, lines, lineSet, askLines
57
48
  /** @type {Set<number>} */ const built = new Set();
58
49
  /** @type {Map<number, Map<number, number|null>>} old part index -> new close-part index (null = the part is not in the close), per line */
59
50
  const remap = new Map();
60
- /** @type {Set<number>} */ const notSignable = new Set();
51
+ /** M19 S5 (O1): the lines whose shape part has no class to ride (a list of items and no quote, none ruled): their rows are signed Not checked @type {Set<number>} */ const noShapeClass = new Set();
61
52
  /** @type {Set<number>} */ const pickedLines = new Set(Array.isArray(declaration.pickedLines) ? declaration.pickedLines : []);
62
53
  const guardrailClasses = isRec(declaration.guardrailClasses) ? { ...declaration.guardrailClasses } : {};
54
+ /** the sheet part the block built for a sheet line, or null (no check is left on it) @param {number} n */
55
+ const sheetPartOn = (n) => { const m = c.map.find((x) => x.line === n); const p = m ? c.parts[m.part] : null; return p && p.class === 'sheet' ? p : null; };
56
+ /** @type {Set<number>} the sheet lines that already gave their checks to a step: the first green step that reads a sheet takes them */
57
+ const given = new Set();
63
58
  const steps = declaration.steps.map((/** @type {any} */ st) => {
64
59
  const n = st?.fromLine;
60
+ // M19 S3: a sheet line's checks are the block's (rows, drops), written into `close.sheet` of the line's first green step that reads a sheet; every other step of the line keeps the AI's own close
61
+ if (isRec(st) && Number.isInteger(n) && block.isSheetLine(n) && !lineSet.has(n)) {
62
+ const part = sheetPartOn(n);
63
+ const { sheet: _ai, ...close } = isRec(st.close) ? st.close : /** @type {Record<string, any>} */ ({});
64
+ if (!part || !isRec(st.close) || st.close.class !== 'green' || !Array.isArray(st.reads) || !st.reads.some((/** @type {string} */ r) => sheetRoles.includes(r)) || given.has(n)) return isRec(st.close) ? { ...st, close } : st;
65
+ given.add(n);
66
+ return { ...st, close: { ...close, sheet: part.checks.map((/** @type {any} */ x) => ({ ...x })) } };
67
+ }
65
68
  if (!isRec(st) || !Number.isInteger(n) || !lineSet.has(n)) return st;
66
69
  const parts = partsOf(n);
67
- const signable = guarded(n);
68
- const fact = signable ? parts.find((p) => p.class === 'fact') : undefined;
69
- const picks = signable ? parts.filter((p) => p.class === 'countable' && p.check !== 'cited' && p.check !== 'numbersFromFacts') : [];
70
+ // fwd (F251): the check block is the one decider that a line with no ~ guardrail holds no check (src/checkblock.js buildLine), so every part it holds is kept here
71
+ const fact = parts.find((p) => p.class === 'fact');
72
+ // M19 S5: the shape part rides the fact part (facts+shape, class green); a line with no fact part takes it only when a class is ruled for it (`shapeOnlyClass`)
73
+ const picks = parts.filter((p) => p.class === 'countable' && p.check !== 'cited' && p.check !== 'numbersFromFacts');
74
+ const shape = parts.find((p) => p.class === 'shape' && (fact !== undefined || shapeOnlyClass === 'green'));
70
75
  const tie = parts.find((p) => p.class === 'countable' && p.check === 'numbersFromFacts');
71
76
  const old = isRec(st.close) ? st.close : {};
72
77
  const sheet = Array.isArray(old.sheet) ? old.sheet : null;
73
- // the part order the close lists them in (src/checklistsign.js closePartsOf): the fact part, each pick, the tie
74
- const keptOrder = [...(fact ? [fact] : []), ...picks, ...(tie ? [tie] : [])];
78
+ // the part order the close lists them in (src/checklistsign.js closePartsOf): the fact part, the shape part, each pick, the tie
79
+ const keptOrder = [...(fact ? [fact] : []), ...(shape ? [shape] : []), ...picks, ...(tie ? [tie] : [])];
75
80
  const map = remap.get(n) ?? new Map();
76
81
  for (const p of parts) map.set(p.oldIndex, keptOrder.includes(p) ? keptOrder.indexOf(p) : null);
77
82
  remap.set(n, map);
78
- if (!signable && parts.some((p) => p !== tie)) notSignable.add(n);
83
+ if (!shape && parts.some((p) => p.class === 'shape')) noShapeClass.add(n);
79
84
  /** @type {Record<string, any>} */
80
85
  const close = { ...(sheet ? { sheet } : {}), ...(Array.isArray(old.columns) ? { columns: old.columns } : {}) };
81
86
  if (fact) {
82
87
  close.class = 'green';
83
- close.cited = { source: fact.source, facts: fact.facts, ...(isRec(fact.count) ? { count: fact.count } : {}) };
84
- } else close.class = sheet ? 'green' : picks.length ? 'softgreen' : 'hitl';
88
+ close.cited = { source: fact.source, facts: fact.facts, ...(isRec(fact.count) ? { count: fact.count } : {}), ...(isRec(fact.asSeen) ? { asSeen: fact.asSeen } : {}) };
89
+ } else close.class = sheet ? 'green' : shape ? /** @type {'green'} */ (shapeOnlyClass) : picks.length ? 'softgreen' : 'hitl';
90
+ // the list-of-items check is its own close key, never `close.shape` (amendment E): the signed fields and the item count of the part
91
+ if (shape) close.itemShape = { fields: shape.fields, ...(Number.isInteger(shape.minItems) ? { minItems: shape.minItems } : {}), ...(Number.isInteger(shape.maxItems) ? { maxItems: shape.maxItems } : {}) };
85
92
  if (picks.length) {
86
93
  const checks = picks.map(pickedOf);
87
94
  if (close.class === 'green') { close.picked = checks; pickedLines.add(n); } else close.shape = { picked: checks };
88
95
  }
89
96
  if (tie) close.numbersFrom = [...tie.from];
90
- if (fact || picks.length || tie) built.add(n);
97
+ if (fact || shape || picks.length || tie) built.add(n);
91
98
  const reads = Array.isArray(st.reads) && fact && !st.reads.includes(fact.source) ? [...st.reads, fact.source] : st.reads;
92
99
  return { ...st, reads, close };
93
100
  });
@@ -101,25 +108,24 @@ export function assembleFromBlock({ declaration, block, lines, lineSet, askLines
101
108
  }
102
109
  const served = new Set(steps.filter((/** @type {any} */ st) => isRec(st)).map((/** @type {any} */ st) => st.fromLine));
103
110
  /** the signed list: the block's signed fields per row, the parts renumbered to the close's order, a row whose check cannot ride its line signed Not checked @type {any[]} */
104
- const checkList = block.signedRows().map((/** @type {any} */ r) => {
111
+ // M19 S3: the rows of a sheet line are the block's own (state, Drop); the signed list and the Not-checked lines of a sheet line stay fwd's (src/sheetrows.js reads the close.sheet written above, src/sheetblock.js the reasons)
112
+ const checkList = block.signedRows().filter((/** @type {any} */ r) => !block.isSheetLine(r.line)).map((/** @type {any} */ r) => {
105
113
  const m = remap.get(r.line);
106
114
  const idx = isRec(r.part) && m ? m.get(r.part.part) : undefined;
107
115
  if (r.state === 'built' && r.kind !== 'floor' && (idx === null || idx === undefined)) {
108
116
  const { part: _p, ...rest } = r;
109
- return { ...rest, state: 'not-checked', reason: notSignable.has(r.line) ? NO_GUARDRAIL_WORDS : String(r.reason ?? 'not checked') };
117
+ return { ...rest, state: 'not-checked', reason: noShapeClass.has(r.line) ? (r.kind === 'rule' ? REASON.noPick : REASON.noRule) : String(r.reason ?? 'not checked') };
110
118
  }
111
119
  return isRec(r.part) && typeof idx === 'number' ? { ...r, part: { line: r.part.line, part: idx } } : r;
112
120
  });
113
121
  /** @type {Record<string, 'you'|'agent'|'default'>} the tag of each Not-checked line, by the row it tells (M16 item 5: one tag per row) */
114
122
  const notCheckedBy = {};
115
- const notChecked = checkList.filter((r) => r.state === 'not-checked' && r.kind !== 'floor').map((r) => {
123
+ // M19 am8 item 2, am9 items 1 to 4: the items are the reader's (src/checkrows.js `notCheckedItem`, the one writer): a `~` rule `line <n>: "<rule text>" \u2014 <reason>`, any other row its name (`<kind> "<words>"`)
124
+ const notChecked = checkList.filter((r) => isListedNotChecked(checkList, r)).map((r) => {
116
125
  const own = block.rows.find((x) => x.key === r.key);
117
126
  if (own?.hidden) return null;
118
- const row = own;
119
- // any other row is told in the words the card draws it with (renderCard; never the row's key)
120
- // a `~` rule is told in the signed table's form, `not checked · "<rule>" — <reason>` (M10 am16 (5)); any other row names its line
121
- const kept = row?.keptFromLast === true ? ` (${KEPT_WORDS})` : ''; // M10 am17 (6)
122
- const line = r.kind === 'rule' && row?.text ? `not checked · "${row.text}" — ${notCheckedWords(r.reason, row)}${kept}` : `line ${r.line}: ${rowWords(own ?? r)} - ${notCheckedWords(r.reason, row)}${kept}`;
127
+ // the reason is the signed row's own `reason` (src/checkblock.js REASON, the one table); M10 am17 (6): `kept` words
128
+ const line = notCheckedItem(r, ruleTextOf(lines, r) ?? own?.text, own ? (own.name ? [own.name] : own.words) : undefined, own?.keptFromLast === true);
123
129
  if (r.by === 'you' || r.by === 'agent' || r.by === 'default') notCheckedBy[line] = r.by;
124
130
  return line;
125
131
  }).filter((x) => x !== null);
package/src/blockdraft.js CHANGED
@@ -33,10 +33,12 @@ export function isBuildFault(red, builtLines) {
33
33
  /**
34
34
  * 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.
35
35
  * 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".
36
- * @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
36
+ * @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
37
37
  */
38
- export function setUpBlock({ texts, jobLines, look, kept, fresh, asks, countScope, leaveOut = [] }) {
38
+ export function setUpBlock({ texts, jobLines, look, kept, fresh, asks, countScope, leaveOut = [], sheetLines = [] }) {
39
39
  const block = newJobBlock({ texts, jobLines, asks, countScope });
40
+ // M19 S3: the lines that read a sheet are known before the first reconcile: their rules are the sheet's to decide (no pick, no question)
41
+ block.setSheetLines(sheetLines);
40
42
  // M16 item 4: a Tickets job's own guardrails (the signed ticketFilter / ticketWatch) are not rows of the list; the rule numbers of the other rules stay as written
41
43
  if (leaveOut.length) block.rows = block.rows.filter((r) => !(r.kind === 'rule' && leaveOut.some((x) => x.line === r.line && x.rule === r.rule)));
42
44
  // a rule the person left is the block's own `left` row (carry, below); the look's person-left drop would say it twice
package/src/blockpick.js CHANGED
@@ -173,3 +173,13 @@ export function partOfPick(check, text, rules) {
173
173
  return { text, class: 'countable', check: rule, ...fields, rules };
174
174
  }
175
175
 
176
+
177
+ // borrowed-from: bareloop src/checkpick.js@v0.61.0 (fc56e1f3)
178
+ /** 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[]} */
179
+ export function underNumbers(text) {
180
+ return [...String(text).matchAll(/(?<!\b(?:no|not)\s)\b(?:(?:fewer|less)\s+than|under|below)\s+(\d+)\b/gi)].map((m) => Number(m[1]));
181
+ }
182
+ /** the numbers a text says as "at most / up to / no more than / not more than N" @param {string} text @returns {number[]} */
183
+ export function atMostNumbers(text) {
184
+ return [...String(text).matchAll(/\b(?:at\s+most|up\s+to|no\s+more\s+than|not\s+more\s+than)\s+(\d+)\b/gi)].map((m) => Number(m[1]));
185
+ }
package/src/canrun.js CHANGED
@@ -93,7 +93,8 @@ export function findUnbuildableCheckStep(declaration) {
93
93
  for (const step of declaration.steps) {
94
94
  // M10b piece 5 (item 8, hamr's ruling): a green step with neither close.sheet nor close.cited is the old cell cite, which no longer runs. A job signed that
95
95
  // way is kept for reference (it still reads and displays) and is refused here, at $0, before any spend.
96
- if (step.close?.class === 'green' && !step.close.cited && !Array.isArray(step.close.sheet)) {
96
+ // M19 am11 item 5: a line whose green check holds `itemShape` is not the cell cite; `closeOne` runs it (`closeItemShape`), and a bad part was refused at sign
97
+ if (step.close?.class === 'green' && !step.close.cited && !Array.isArray(step.close.sheet) && !(step.close.itemShape && typeof step.close.itemShape === 'object')) {
97
98
  return { step, why: 'a green step with no close.sheet or close.cited is the retired cell cite', say: `This flow will not run: Line ${step.fromLine}'s check cannot cite cells any more. Draft it again to run it.` };
98
99
  }
99
100
  if (step.close?.class !== 'softgreen') continue;
package/src/cardlist.js CHANGED
@@ -3,17 +3,40 @@
3
3
  // and kept in the draft's log.json as `checkCard`. The page only draws it (bareloop src/panel/jobplan.js@v0.56.0 reads the same two readers); it never decides a check.
4
4
  // What this throws away: the rows' proofs (`can`, `pick`, parts). Only the words, the tag, the reason and whether a Drop is offered survive.
5
5
  import { renderCard } from './checkblock.js';
6
+ import { kindOfCheck } from './checklook.js';
7
+ import { planCard } from './checkrows.js';
6
8
 
7
9
  /**
8
10
  * @param {import('./checkblock.js').CheckBlock} block
9
- * @returns {{rows: {key: string, line: number, by: string, state: string, text: string, reason: string|null, drop: boolean}[], suggested: {key: string, line: number, text: string, dropped?: boolean}[]}}
11
+ * @returns {{rows: {key: string, line: number, by: string, state: string, reason: string|null, drop: boolean, kind: 'truth'|'shape'|'file'}[], suggested: {key: string, line: number, text: string, dropped?: boolean}[], restorable?: {key: string, line: number, text: string}[]}}
10
12
  */
11
13
  export function cardOfBlock(block) {
12
- const dropOffered = new Set(block.rows.filter((r) => r.state === 'built' && block.isBang(r)).map((r) => r.key));
14
+ // borrowed-from: bareloop src/panel/index.html@v0.61.0 (checkRow: a shape row has a Drop unless it is code's own) (M19 S9, section 3.7): every shape row has a Drop but code's own `$` one, the person's own `~` rule that took a field too (`droppable`, as the tag's page draws it: Drop unless `c.by` is "default"); a non-shape row is offered as before
15
+ const dropOffered = new Set(block.rows.filter((r) => r.state === 'built' && (block.isBang(r) || ((r.kind === 'shape' || r.kind === 'rule') && block.droppable(r)))).map((r) => r.key));
13
16
  return {
14
- rows: renderCard(block.rows).map((r) => ({
15
- key: r.key, line: r.line, by: r.by, state: r.state, text: r.text.replace(/^[~!$] /, ''), reason: r.reason ?? null, drop: dropOffered.has(r.key),
16
- })),
17
+ // M19 S3: the rows of a sheet line are drawn by src/sheetrows.js (`withSheetCard`), from the close the block's sheet part made; a dropped sheet check is the block's own suggested row
18
+ // M19 S6 (section 3.3, 3.7): each row carries its kind word (`kindOfCheck`: a field of a list of items is `shape`, a line's output-file floor is `file`); the floor row of each line is drawn, `[default]` `file`, in fwd's words
19
+ rows: [
20
+ ...renderCard(block.rows.filter((r) => !block.isSheetLine(r.line))).map((r) => {
21
+ const own = block.rows.find((x) => x.key === r.key);
22
+ return { key: r.key, line: r.line, by: r.by, state: r.state, reason: r.reason ?? null, drop: dropOffered.has(r.key), kind: kindOfCheck({ key: r.key, ...(own?.kind === 'shape' || own?.can?.how === 'shape' ? { shape: /** @type {true} */ (true) } : {}) }) };
23
+ }),
24
+ ...block.rows.filter((r) => r.kind === 'floor' && r.state === 'built' && !block.isSheetLine(r.line)).map((r) => ({
25
+ key: r.key, line: r.line, by: r.by, state: r.state, reason: null, drop: false, kind: kindOfCheck({ key: r.key }),
26
+ })),
27
+ ].sort((a, b) => a.line - b.line),
17
28
  suggested: block.suggestedView(),
29
+ // borrowed-from: bareloop src/panel/jobplan.js@v0.61.0 (`restorable`: the `[you]` rules the person dropped, Not checked "You dropped it."; the card gives each an Add back button) (M19 S9); only when a rule is dropped, so the saved card of every other job is byte for byte what it was
30
+ ...(block.droppedRulesView().length ? { restorable: block.droppedRulesView() } : {}),
18
31
  };
19
32
  }
33
+
34
+ /**
35
+ * M19 am6 to am9: the card a draft saves and the panel draws. The block's own card gives the suggestions, the restorable rows and the Drop flags; the rows come from the signed plan through the one reader (src/checkrows.js `planCard`),
36
+ * with the Not checked rows as a list of their own. `kept` = the picks and rules a Revise carried (the block's `keptFromLast` rows).
37
+ * @param {import('./checkblock.js').CheckBlock} block @param {any} withSheetAndTickets the block's card with the sheet and Tickets rows (src/sheetrows.js `withSheetCard`) @param {{declaration: any, lines: any[], csvRoles?: string[], log?: unknown}} plan
38
+ */
39
+ export function cardOfPlanBlock(block, withSheetAndTickets, plan) {
40
+ const kept = block.rows.filter((r) => r.keptFromLast === true && Number.isInteger(r.line) && Number.isInteger(r.rule)).map((r) => ({ line: r.line, rule: r.rule, ...(r.pick ? { check: r.pick } : {}) }));
41
+ return planCard(withSheetAndTickets, { ...plan, kept });
42
+ }