fwdloop 0.31.0 → 0.33.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 (96) hide show
  1. package/bin/fwdloop +8 -2
  2. package/package.json +2 -2
  3. package/src/auditchecks.js +53 -0
  4. package/src/authoring.js +52 -12
  5. package/src/blockasks.js +44 -0
  6. package/src/blockassemble.js +140 -0
  7. package/src/blockdraft.js +91 -0
  8. package/src/blocklines.js +30 -0
  9. package/src/blockpick.js +165 -0
  10. package/src/cardlist.js +19 -0
  11. package/src/checkblock.js +804 -0
  12. package/src/checked.js +48 -9
  13. package/src/checklist.js +99 -0
  14. package/src/checklistsign.js +93 -0
  15. package/src/checkwords.js +20 -1
  16. package/src/cited-record.js +21 -1
  17. package/src/citedcheck.js +162 -7
  18. package/src/closers.js +41 -3
  19. package/src/declaration.js +25 -2
  20. package/src/declaredclose.js +4 -0
  21. package/src/draft-steps.js +3 -1
  22. package/src/drafter.js +244 -134
  23. package/src/factwords.js +112 -0
  24. package/src/inputlook.js +53 -0
  25. package/src/jsonbrace.js +21 -0
  26. package/src/labelscan.js +162 -0
  27. package/src/pageask.js +4 -1
  28. package/src/pagedropwords.js +11 -1
  29. package/src/panel/author.js +76 -5
  30. package/src/panel/authorcard.js +9 -6
  31. package/src/panel/data.js +41 -9
  32. package/src/panel/index.html +202 -13
  33. package/src/panel/result.js +4 -3
  34. package/src/panel/server.js +3 -1
  35. package/src/pickrecord.js +28 -0
  36. package/src/placerule.js +398 -0
  37. package/src/planrebuild.js +206 -0
  38. package/src/rowedit.js +118 -0
  39. package/src/rubricstep.js +264 -0
  40. package/src/runfile.js +4 -2
  41. package/src/runner.js +67 -10
  42. package/src/setup.js +10 -4
  43. package/src/sheetblock.js +6 -2
  44. package/src/sheetchecks.js +49 -64
  45. package/src/sheetclaims.js +12 -32
  46. package/src/sheetlook.js +2 -2
  47. package/src/sheetoffer.js +25 -53
  48. package/src/sheetrows.js +107 -0
  49. package/src/sheetrun.js +31 -1
  50. package/src/summary-words.js +3 -3
  51. package/src/try-checks.js +31 -12
  52. package/src/types.js +1 -0
  53. package/types/auditchecks.d.ts +24 -0
  54. package/types/authoring.d.ts +18 -1
  55. package/types/blockasks.d.ts +37 -0
  56. package/types/blockassemble.d.ts +33 -0
  57. package/types/blockdraft.d.ts +83 -0
  58. package/types/blocklines.d.ts +31 -0
  59. package/types/blockpick.d.ts +41 -0
  60. package/types/cardlist.d.ts +21 -0
  61. package/types/checkblock.d.ts +363 -0
  62. package/types/checked.d.ts +16 -2
  63. package/types/checklist.d.ts +115 -0
  64. package/types/checklistsign.d.ts +27 -0
  65. package/types/checkwords.d.ts +5 -0
  66. package/types/cited-record.d.ts +9 -0
  67. package/types/citedcheck.d.ts +33 -2
  68. package/types/closers.d.ts +24 -2
  69. package/types/declaredclose.d.ts +2 -0
  70. package/types/drafter.d.ts +15 -361
  71. package/types/factwords.d.ts +38 -0
  72. package/types/inputlook.d.ts +49 -0
  73. package/types/jsonbrace.d.ts +8 -0
  74. package/types/labelscan.d.ts +35 -0
  75. package/types/pageask.d.ts +2 -0
  76. package/types/panel/author.d.ts +41 -0
  77. package/types/panel/authorcard.d.ts +1 -1
  78. package/types/panel/data.d.ts +4 -2
  79. package/types/panel/jobgrid.d.ts +1 -1
  80. package/types/pickrecord.d.ts +22 -0
  81. package/types/placerule.d.ts +208 -0
  82. package/types/planrebuild.d.ts +52 -0
  83. package/types/provider.d.ts +1 -1
  84. package/types/rowedit.d.ts +33 -0
  85. package/types/rubricstep.d.ts +60 -0
  86. package/types/runfile.d.ts +5 -2
  87. package/types/runner.d.ts +45 -1
  88. package/types/sheetblock.d.ts +1 -0
  89. package/types/sheetchecks.d.ts +10 -17
  90. package/types/sheetclaims.d.ts +2 -1
  91. package/types/sheetoffer.d.ts +5 -5
  92. package/types/sheetrows.d.ts +73 -0
  93. package/types/sheetrun.d.ts +12 -0
  94. package/types/summary-words.d.ts +2 -1
  95. package/types/try-checks.d.ts +4 -2
  96. package/types/types.d.ts +8 -0
@@ -0,0 +1,363 @@
1
+ /** the card lines: rows in, lines out. ONE pure function of the rows; nothing else may feed it. @param {Row[]} rows */
2
+ export function renderCard(rows: Row[]): {
3
+ key: any;
4
+ line: any;
5
+ by: any;
6
+ state: any;
7
+ reason: any;
8
+ text: string;
9
+ }[];
10
+ /**
11
+ * A row. `kind`: rule, fact, phrase, count, cited, numbers, floor. `by`: you (`~`), agent (`!`), default (`$`). A `~` row may carry `links` (the look's facts tied to it),
12
+ * `pick`, `aiReading`, `left`. `state` is built or not-checked; a not-checked row always has a plain `reason`.
13
+ * @typedef {Record<string, any>} Row
14
+ */
15
+ /** the card's fixed words, one spelling (the renderer reads them; a test reads them too) */
16
+ export const CARD_T: Readonly<{
17
+ agreed: "you agreed:";
18
+ count: "result count";
19
+ cited: "every claim is backed by a quote copied from";
20
+ theInput: "the input";
21
+ numbers: "every number in the text is in a checked quote of line";
22
+ withWords: "with the words";
23
+ }>;
24
+ /** the four row edits an AI reply may hold */
25
+ export const EDIT_OPS: readonly string[];
26
+ /** the plain reasons code gives, in one place (the card, the Job tab and the Audit read them from the row) */
27
+ export const REASON: Readonly<{
28
+ left: "You chose to leave it Not checked, so you judge it at Accept.";
29
+ nothingOnPage: "Your own words are on the line; the machine has no check for them, so you judge it at Accept.";
30
+ cantCheck: "I can't check this on the page; waiting for your answer";
31
+ noRule: "No rule can check this, so you judge it at Accept.";
32
+ waitingPick: "waiting for your answer on the proposed check";
33
+ waitingReading: "waiting for your answer on the reading";
34
+ onePerLine: "this line finds facts, so it has no text to quote";
35
+ manyInputs: "the job has more than one input and code cannot pick which one the claims quote";
36
+ oneSidedTime: "a time limit the AI proposes must be a range, so you judge it at Accept.";
37
+ countNeedsFact: "a result count needs a fact to count; this line has none";
38
+ lookNoWords: "the page does not hold the words of the look's fact for this rule";
39
+ afterLast: "no more tries: Start over (rows are never changed by the AI after the last try)";
40
+ noPick: "No check was picked for it, so you judge it at Accept.";
41
+ negated: "it says what is not needed, so there is nothing to check";
42
+ dropped: "You dropped it.";
43
+ suggested: "Suggested: not in your job, so it is not checked unless you add it.";
44
+ }>;
45
+ export class CheckBlock {
46
+ /** @param {{texts: Record<string, string>, labels: string[], maxTries?: number, countScope?: (ruleText: string) => boolean, asks?: boolean, split?: boolean, cited?: boolean}} o the frozen input texts, their labels, how many AI replies (tries) may still change a row, whether code scopes a counting `~` rule in (a pick is asked), and whether a person can be asked at all (`asks`: false = a rule code cannot settle is Not checked, a reading code proposes is built as the AI's proposal) */
47
+ constructor({ texts, labels, maxTries, countScope, asks, split, cited }: {
48
+ texts: Record<string, string>;
49
+ labels: string[];
50
+ maxTries?: number;
51
+ countScope?: (ruleText: string) => boolean;
52
+ asks?: boolean;
53
+ split?: boolean;
54
+ cited?: boolean;
55
+ });
56
+ cited: boolean;
57
+ /** the product path sets it: `!` rows split into job-derived and suggested, a suggestion code cannot build is hidden (hamr 2026-11-13). Off, every `!` row is built as before (the older callers and their tests) */
58
+ split: boolean;
59
+ countScope: (ruleText: string) => boolean;
60
+ asks: boolean;
61
+ texts: Record<string, string>;
62
+ labels: string[];
63
+ maxTries: number;
64
+ /** @type {Row[]} the ONE store */
65
+ rows: Row[];
66
+ /** @type {{n: number, text: string}[]} */
67
+ lines: {
68
+ n: number;
69
+ text: string;
70
+ }[];
71
+ /** @type {any[]} the look's facts as given (a `reading` edit names one) */
72
+ lookFacts: any[];
73
+ /** @type {{facts: any[], dropped: any[]}|null} the look as the draft gate reads it (null = no look report: the gate proves a label against the list code made) */
74
+ look: {
75
+ facts: any[];
76
+ dropped: any[];
77
+ } | null;
78
+ /** @type {any[]} replies waiting to be applied by `drive` */
79
+ queue: any[];
80
+ /** @type {any[]} the open questions, set by `ask` */
81
+ open: any[];
82
+ /** @type {string[]} the keys of questions a person did not answer */
83
+ unanswered: string[];
84
+ tries: number;
85
+ /** @type {any[]} every reply's record: each edit, kept or refused with its own reason */
86
+ deltaLog: any[];
87
+ /** @type {any} */
88
+ closeCache: any;
89
+ textOf(source: string | undefined): string;
90
+ /** @param {number} line @param {string} [kind] */
91
+ rowsOn(line: number, kind?: string): Row[];
92
+ ruleRows(line: number): Row[];
93
+ /** every word the person wrote on a line: the line and its `~` rules */
94
+ said(line: number): string;
95
+ /** @param {Row} r @returns {Row} the row as stored (a repeated key gets `#2`) */
96
+ addRow(r: Row): Row;
97
+ /** @param {{n: number, text: string, rules?: string[]}[]} jobLines */
98
+ fromJob(jobLines: {
99
+ n: number;
100
+ text: string;
101
+ rules?: string[];
102
+ }[]): void;
103
+ /**
104
+ * @param {any[]} facts the look's kept facts @param {any[]} [dropped] the look's drops (`look.dropped`): a whole fact a page rule left out. Its plain sentence (src/pagedropwords.js)
105
+ * becomes the `why` of the `~` rule it was tied to, or a Not checked `!` row of its own, so every drop shows under Not checked.
106
+ */
107
+ addLook(facts: any[], dropped?: any[]): void;
108
+ match(): void;
109
+ /** a `!` row: the agent's fact, phrase or count (a look fact tied to a rule is a link on that rule's row, never a row of its own) */
110
+ isBang(r: Row): boolean;
111
+ /**
112
+ * The job's own word for a `!` row: when none of its page words is in the job line or its `~` rules but a proper name the job holds (capital or digit first, 3+ characters) is a whole-word part of one
113
+ * page word and the page holds it, the row's words become that job word. The page's long name is kept as `pageWords`; the row's other fields are untouched.
114
+ */
115
+ takeJobWord(r: Row): void;
116
+ /** are the row's words (or its count number, or the name it asks for a fact by) in the job line or its `~` rules? Normalised, case-insensitive */
117
+ inJob(r: Row): any;
118
+ /** a `~` line an agreed answer wrote (or a carried pair partner) is checked by the rule it was agreed from: one check, both numbers */
119
+ matchFollow(r: Row): void;
120
+ /** a `!` count row is built unless a `~` rule on its line already names the number */
121
+ matchCount(r: Row): void;
122
+ matchRule(r: Row): void;
123
+ /** a `~` rule that counts words, bullets, lines or sections: a settled pick builds it; else code proposes the check and asks */
124
+ matchCountRule(r: Row): void;
125
+ /** a `!` fact or phrase row: its words must be on the page; a version or a date is true only today, so only a place rule's fit may carry it */
126
+ matchBang(r: Row): void;
127
+ build(): any;
128
+ /** build the line as if this held row were on: when it builds, `offer` is the row as the card would draw it; else the row is hidden with code's reason. The rows' own state is restored */
129
+ trialOffer(r: Row): void;
130
+ /** one line's parts: a pick part per count rule, ONE fact part carrying every fact row of the line (and its result count), then the `$` defaults */
131
+ buildLine(l: {
132
+ n: number;
133
+ text: string;
134
+ }, lineParts: any[], lineRows: string[][], factLines: Set<number>): void;
135
+ /** the follow rows of a row (its agreed or carried `~` lines) */
136
+ followsOf(r: Row): Row[];
137
+ /**
138
+ * The fact(s) a fact-like row builds, checked alone through the bareguard shapes and against the facts already on the line.
139
+ * @param {Row} r @param {any[]} onLine the facts already built on this line @returns {{fresh: any[], src: string, names: string[]} | {why: string}}
140
+ */
141
+ factsOf(r: Row, onLine: any[]): {
142
+ fresh: any[];
143
+ src: string;
144
+ names: string[];
145
+ } | {
146
+ why: string;
147
+ };
148
+ /** the `$` defaults of a line, decided from what the line ended with: a text line quotes its input (one input only) and ties its numbers to the fact lines before it */
149
+ buildDefaults(l: {
150
+ n: number;
151
+ }, lineParts: any[], lineRows: string[][], factLines: Set<number>): void;
152
+ ask(): any[];
153
+ hasOpenQuestions(): boolean;
154
+ hasPendingDelta(): boolean;
155
+ /** @param {string} qKey @param {string} choice @param {string} [text] @returns {{ok: true} | {ok: false, why: string}} */
156
+ applyAnswer(qKey: string, choice: string, text?: string): {
157
+ ok: true;
158
+ } | {
159
+ ok: false;
160
+ why: string;
161
+ };
162
+ /** the `~` row `partner` is checked by `source` (one check, both rule numbers) */
163
+ follow(source: Row, partner: Row): void;
164
+ /**
165
+ * Revise keeps the picks of the last draft (am17/am18/am21, `src/pickrecord.js` `matchRecord`): a kept pick settles its rule and its added `~` line follows it; a kept left rule is
166
+ * left; an edited added line (`pairRule`) is the row asked and its source follows it.
167
+ * @param {{picks?: {line: number, rule: number, check: any, added?: string, own?: boolean}[], left?: {line: number, rule: number}[]}} kept
168
+ * @param {{line: number, rule: number, pairRule?: number}[]} [asked] the rules still asked (a `pairRule` marks an edited added line)
169
+ */
170
+ carry({ picks, left }: {
171
+ picks?: {
172
+ line: number;
173
+ rule: number;
174
+ check: any;
175
+ added?: string;
176
+ own?: boolean;
177
+ }[];
178
+ left?: {
179
+ line: number;
180
+ rule: number;
181
+ }[];
182
+ }, asked?: {
183
+ line: number;
184
+ rule: number;
185
+ pairRule?: number;
186
+ }[]): void;
187
+ /** @param {{label?: string, pre?: boolean, edits?: any[]}} delta `pre` = a reply that is not a drafter try (the suggest call): it does not count against the tries */
188
+ applyDelta(delta: {
189
+ label?: string;
190
+ pre?: boolean;
191
+ edits?: any[];
192
+ }): {
193
+ label: string | undefined;
194
+ pre: boolean;
195
+ edits: any[];
196
+ };
197
+ applyEdit(e: any, kept: {
198
+ adds: number;
199
+ }): {
200
+ accepted: boolean;
201
+ landedKey: any;
202
+ refusedBecause?: undefined;
203
+ } | {
204
+ refusedBecause: string;
205
+ };
206
+ editAdd(e: any): {
207
+ refusedBecause: string;
208
+ accepted?: undefined;
209
+ landedKey?: undefined;
210
+ } | {
211
+ accepted: boolean;
212
+ landedKey: any;
213
+ refusedBecause?: undefined;
214
+ };
215
+ /** @returns {string|null} the plain reason an add repeats what the list already holds (a look fact tied to a `~` rule, a `~` rule's own words, another `!` row), else null */
216
+ onTheList(line: number, name: string, words: string[]): string | null;
217
+ addCount(e: any): {
218
+ refusedBecause: string;
219
+ accepted?: undefined;
220
+ landedKey?: undefined;
221
+ } | {
222
+ accepted: boolean;
223
+ landedKey: any;
224
+ refusedBecause?: undefined;
225
+ };
226
+ /** the `~` rule rows of a line an edit names by number */
227
+ targetsOf(e: any): any;
228
+ /** the one owner of "what do the person's own words say": code's reading of a `~` rule for a money/time fact, or undefined when it cannot read it */
229
+ wordsReading(l: any, text: string): {
230
+ op: "lt" | "lte" | "gt" | "gte";
231
+ value: number;
232
+ } | {
233
+ op: "between";
234
+ lo: number | string;
235
+ hi: number | string;
236
+ } | undefined;
237
+ editReading(e: any): {
238
+ refusedBecause: string;
239
+ accepted?: undefined;
240
+ landedKey?: undefined;
241
+ } | {
242
+ accepted: boolean;
243
+ landedKey: any;
244
+ refusedBecause?: undefined;
245
+ };
246
+ editPick(e: any): {
247
+ refusedBecause: string;
248
+ accepted?: undefined;
249
+ landedKey?: undefined;
250
+ } | {
251
+ accepted: boolean;
252
+ landedKey: any;
253
+ refusedBecause?: undefined;
254
+ };
255
+ editNot(e: any): {
256
+ refusedBecause: string;
257
+ accepted?: undefined;
258
+ landedKey?: undefined;
259
+ } | {
260
+ accepted: boolean;
261
+ landedKey: any;
262
+ refusedBecause?: undefined;
263
+ };
264
+ reconcile(): any;
265
+ /** the loop: while a question is open or a reply waits, apply it and reconcile the WHOLE list again. `answer(q)` gives {choice, text} or null (a person who did not answer) */
266
+ drive({ answer }: {
267
+ answer: any;
268
+ }): this;
269
+ card(): {
270
+ key: any;
271
+ line: any;
272
+ by: any;
273
+ state: any;
274
+ reason: any;
275
+ text: string;
276
+ }[];
277
+ /**
278
+ * The rows as the close shape the card readers (`checksOfClose`, `refusedOf`, `cardOfClose`) already read: the block's stages, the picks code records and the signed list. The confirm card
279
+ * and the signed card read the rows through the SAME readers, so a row shown at confirm is the row signed. Reconciles first (the whole list, every time).
280
+ */
281
+ closeView(): {
282
+ stages: any;
283
+ picks: {
284
+ line: number;
285
+ part: any;
286
+ }[];
287
+ list: {
288
+ [k: string]: any;
289
+ }[];
290
+ };
291
+ /** the picks code records: a countable part carrying the `~` rule numbers it settles @param {{parts: any[], map: {part: number, line: number}[]}} c the build @returns {{line: number, part: any}[]} */
292
+ picksOf(c: {
293
+ parts: any[];
294
+ map: {
295
+ part: number;
296
+ line: number;
297
+ }[];
298
+ }): {
299
+ line: number;
300
+ part: any;
301
+ }[];
302
+ /** the standing ruling "a run needs one check": one row that is not the floor is built */
303
+ hasBuiltCheck(): boolean;
304
+ /**
305
+ * The signed list (`closeDecl.list`): the signed fields of every row, never its words. A suggestion not added is signed `dropped` ("suggested, not added"), a suggestion code could not build
306
+ * `dropped` with code's reason (it is on the Audit, never on the card), and a built row carries the names of the facts it made (`facts`), so every reader can tag each fact by its row's kind.
307
+ */
308
+ signedRows(): {
309
+ [k: string]: any;
310
+ }[];
311
+ /** the suggestions code has proved it can build, as the card offers them (Add): `{key, line, text}` */
312
+ suggestedView(): {
313
+ dropped?: boolean | undefined;
314
+ key: any;
315
+ line: any;
316
+ text: string;
317
+ }[];
318
+ /** the suggestions code could not build, in one plain sentence each: the Audit's draft lines (never the card) */
319
+ unbuiltSuggestions(): {
320
+ line: any;
321
+ text: string;
322
+ }[];
323
+ /**
324
+ * The person's Drop or Add on a `!` row (hamr 2026-11-13: instant, $0, no AI; the choice decides). The whole list is reconciled again, so an Add is judged by code like every other row.
325
+ * @param {string} key @param {'drop'|'add'} choice @returns {{ok: true} | {ok: false, why: string}}
326
+ */
327
+ rowChoice(key: string, choice: "drop" | "add"): {
328
+ ok: true;
329
+ } | {
330
+ ok: false;
331
+ why: string;
332
+ };
333
+ /** the person's Drop/Add choices, tied to the line's words (not its number) and the row's own name, so a Revise keeps them @returns {{lineWords: string, occurrence: number, tail: string, choice: string}[]} */
334
+ choicesRecord(): {
335
+ lineWords: string;
336
+ occurrence: number;
337
+ tail: string;
338
+ choice: string;
339
+ }[];
340
+ /** a Revise keeps the last draft's Drop/Add choices on the rows that are still there (same line words, same row); code still judges every one @param {{lineWords: string, occurrence: number, tail: string, choice: string}[]} rec */
341
+ carryChoices(rec: {
342
+ lineWords: string;
343
+ occurrence: number;
344
+ tail: string;
345
+ choice: string;
346
+ }[]): void;
347
+ /**
348
+ * per line, the shape of `retentionOfList` (counts only): `aiParts` = the rows the agent proposed (and the default cited), `kept` = those built, `dropped` = the rest, `picks` = a `~` row built from a pick
349
+ * @returns {{line: number, aiParts: number, kept: number, dropped: number, picks: boolean}[]}
350
+ */
351
+ retention(): {
352
+ line: number;
353
+ aiParts: number;
354
+ kept: number;
355
+ dropped: number;
356
+ picks: boolean;
357
+ }[];
358
+ }
359
+ /**
360
+ * A row. `kind`: rule, fact, phrase, count, cited, numbers, floor. `by`: you (`~`), agent (`!`), default (`$`). A `~` row may carry `links` (the look's facts tied to it),
361
+ * `pick`, `aiReading`, `left`. `state` is built or not-checked; a not-checked row always has a plain `reason`.
362
+ */
363
+ export type Row = Record<string, any>;
@@ -26,8 +26,8 @@ export function checkedLines(declaration: {
26
26
  sentences: string[];
27
27
  sheet?: ReturnType<typeof sheetLineBlocks>[number];
28
28
  }[];
29
- /** The "Not checked" block the page shows: always the label, then the drafter's items (an empty list says the drafter listed nothing). @param {unknown} items */
30
- export function notCheckedBlock(items: unknown): {
29
+ /** The "Not checked" block the page shows: always the label, then the drafter's items (an empty list says the drafter listed nothing). @param {unknown} items @param {string} [label] */
30
+ export function notCheckedBlock(items: unknown, label?: string): {
31
31
  label: string;
32
32
  items: any[];
33
33
  };
@@ -41,6 +41,20 @@ export function notCheckedView(items: unknown, declaration: any): {
41
41
  items: string[];
42
42
  readNotes: string[];
43
43
  };
44
+ /**
45
+ * The checks of one list line's step as rows `{text, by, part}` in the close's part order (the quote check's facts and count, each picked check, the numbers tie), each with the `by` of the row that built it.
46
+ * ONE reader for the plan card's sentences and the Audit's Checks fold; `part` is the index the signed list's rows point at (src/checklistsign.js). Pure.
47
+ * @param {any} declaration @param {any} st the step @param {(line: number, c: any) => string} [keptOf]
48
+ * @returns {{text: string, by: 'you'|'agent'|'default', part: number}[]}
49
+ */
50
+ export function listPartRows(declaration: any, st: any, keptOf?: (line: number, c: any) => string): {
51
+ text: string;
52
+ by: "you" | "agent" | "default";
53
+ part: number;
54
+ }[];
44
55
  /** The label that always sits with the "Not checked" list (am41 item 3: the ONE place these words live; the Job tab and the Chat card read it off their payloads). */
45
56
  export const NOT_CHECKED_LABEL: "not checked (the AI's own reading)";
57
+ /** M16 item 5 (replaces M4e am40/am41's words for the checks of a line on the list): the label of a plan that has a list */
58
+ export const LIST_NOT_CHECKED_LABEL: "Not checked";
59
+ export function notCheckedLabelOf(declaration: any): "not checked (the AI's own reading)" | "Not checked";
46
60
  import { sheetLineBlocks } from './sheetblock.js';
@@ -0,0 +1,115 @@
1
+ /**
2
+ * A check that needs exact words from the input is true only while the input stays as it is when those words hold a VERSION-like token (1.2 or 1.2.3, not after a currency sign or before
3
+ * a percent) or a DATE-like token (2026-11-04, 04/11/2026, "Nov 4, 2026", "4 November 2026", "November 2026"). Code refuses it; a `~` rule is the person's own and is never refused by this.
4
+ * @param {unknown} t @returns {boolean}
5
+ */
6
+ export function weekOnly(t: unknown): boolean;
7
+ /**
8
+ * The version-like and date-like tokens a text holds (the very tokens {@link weekOnly} reads), each once. Pure.
9
+ * @param {unknown} t @returns {string[]}
10
+ */
11
+ export function weekTokens(t: unknown): string[];
12
+ /** @param {{n: number, text: string, rules?: string[], rule?: string}[]} jobLines @param {Record<string, string>} texts @returns {string} */
13
+ export function ledgerUserText(jobLines: {
14
+ n: number;
15
+ text: string;
16
+ rules?: string[];
17
+ rule?: string;
18
+ }[], texts: Record<string, string>): string;
19
+ /** at most this many `!` checks come from the call */
20
+ export const MAX_BANG: 3;
21
+ /** the reason a check on a version or a date goes under Not checked: it is true only for the input as it is today */
22
+ export const WEEK_ONLY_WORDS: "It names a version or a date from the input, true only for the input as it is today, so you judge it at Accept.";
23
+ /** the label of the list call, as the drafting book and the draft log see it */
24
+ export const LEDGER_LABEL: "ledger-suggest";
25
+ export const LEDGER_TOOL: "suggest_extra_checks";
26
+ /** the reason the empty list is logged with */
27
+ export const EMPTY_LIST_WORDS: "empty list: nothing to check";
28
+ export function isEmptyList(rows: Row[]): boolean;
29
+ export function ledgerRecord(rows: Row[]): ({
30
+ key: string;
31
+ line: number;
32
+ rowKind: "phrase" | "rule" | "numbers" | "fact" | "cited" | "count" | "floor";
33
+ from: "default" | "agent" | "rule" | "look" | "pick";
34
+ by: "default" | "agent" | "you";
35
+ words: string[];
36
+ state: "dropped" | "built" | "listed" | "not-checked";
37
+ reason: string | null;
38
+ } | {
39
+ key: string;
40
+ line: number;
41
+ rowKind: string;
42
+ from: string;
43
+ by: string;
44
+ words: never[];
45
+ state: string;
46
+ reason: string;
47
+ })[];
48
+ /** the list call's own system text (model-facing; used only by the list call of a rubric job with input text) */
49
+ export const LEDGER_SYSTEM: "You look at the inputs of a job and name checks the inputs themselves support, beyond the guardrails the person wrote.\nCall suggest_extra_checks once with up to 3 entries, or with an empty list.\n- kind \"count\": how many results the input shows or the job asks for (min and/or max, whole numbers).\n- kind \"phrase\": fixed words copied verbatim from an input (phrase, and source = that input's label).\nUse only what you can see in the inputs. Do not repeat a guardrail the person wrote. If the inputs support none, send an empty list.";
50
+ export const LEDGER_SCHEMA: Readonly<{
51
+ type: "object";
52
+ properties: {
53
+ extra: {
54
+ type: string;
55
+ maxItems: number;
56
+ items: {
57
+ type: string;
58
+ properties: {
59
+ line: {
60
+ type: string;
61
+ minimum: number;
62
+ description: string;
63
+ };
64
+ kind: {
65
+ enum: string[];
66
+ };
67
+ source: {
68
+ type: string;
69
+ description: string;
70
+ };
71
+ phrase: {
72
+ type: string;
73
+ description: string;
74
+ };
75
+ min: {
76
+ type: string;
77
+ minimum: number;
78
+ };
79
+ max: {
80
+ type: string;
81
+ minimum: number;
82
+ };
83
+ };
84
+ required: string[];
85
+ additionalProperties: boolean;
86
+ };
87
+ };
88
+ };
89
+ required: string[];
90
+ additionalProperties: false;
91
+ }>;
92
+ export type Row = {
93
+ key: string;
94
+ line: number;
95
+ kind: "rule" | "fact" | "cited" | "count" | "phrase" | "numbers" | "floor";
96
+ from: "rule" | "pick" | "look" | "agent" | "default";
97
+ by: "you" | "agent" | "default";
98
+ words: string[];
99
+ text?: string;
100
+ rule?: number;
101
+ part?: {
102
+ line: number;
103
+ part: number;
104
+ };
105
+ source?: string;
106
+ name?: string;
107
+ min?: number;
108
+ max?: number;
109
+ pick?: string;
110
+ after?: number[];
111
+ state: "listed" | "built" | "not-checked" | "dropped";
112
+ reason: string | null;
113
+ forRule?: number;
114
+ reading?: import("./pagerules.js").Reading;
115
+ };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * The checks of one step's close in the block's part order. M16 am4: with `withSheet` (a plan whose list has sheet rows) each `close.sheet` check is a part too, after the others.
3
+ * @param {any} step @param {boolean} [withSheet] @returns {{what: string}[]}
4
+ */
5
+ export function closePartsOf(step: any, withSheet?: boolean): {
6
+ what: string;
7
+ }[];
8
+ /**
9
+ * Every red of a plan's `checkList` (a plan without one is not examined): a built row must point at a check the close really has, every check a list line's close has must have a built row
10
+ * pointing at it, and a list line's close carries no other check of its own (a `close.shape` key besides `picked`). Each red names the line. Pure.
11
+ * @param {any} declaration @returns {string[]}
12
+ */
13
+ export function checkListReds(declaration: any): string[];
14
+ /** the job lines that have a list: a plan from before M16 has no `checkList`, so none. Sheet rows (M16 am4, `kind: 'sheet'`) do not make a line a block line: a CSV job's other readers stay as they were. @param {any} declaration @returns {Set<number>} */
15
+ export function listLinesOf(declaration: any): Set<number>;
16
+ /** M16 am4: every line the plan card draws a list on - the block's lines and the sheet lines @param {any} declaration @returns {Set<number>} */
17
+ export function cardLinesOf(declaration: any): Set<number>;
18
+ /**
19
+ * Who made the check at part `idx` of a list line's close (`'you'` a `~` rule, `'agent'` a `!` row, `'default'` a `$` row), read from the row that points at it (`part`), else null.
20
+ * ONE reader of the rows' `by` for the close's parts (the readout, the plan card and the Audit tag a check through it). Pure.
21
+ * @param {any} declaration @param {number} line @param {number} idx @returns {'you'|'agent'|'default'|null}
22
+ */
23
+ export function partByOf(declaration: any, line: number, idx: number): "you" | "agent" | "default" | null;
24
+ /** who made the fact named `name` of a list line's quote check (the row that built it), else null @param {any} declaration @param {number} line @param {string} name @returns {'you'|'agent'|'default'|null} */
25
+ export function factByOf(declaration: any, line: number, name: string): "you" | "agent" | "default" | null;
26
+ /** who made the result count of a list line's quote check, else null @param {any} declaration @param {number} line @returns {'you'|'agent'|'default'|null} */
27
+ export function countByOf(declaration: any, line: number): "you" | "agent" | "default" | null;
@@ -16,3 +16,8 @@ export const OFFERED: readonly string[];
16
16
  export const LABEL_AGENT: "[agent]";
17
17
  export const LABEL_PICKED: "[you picked]";
18
18
  export function labelled(text: string, by: "agent" | "picked"): string;
19
+ /** @type {Readonly<Record<string, string>>} */
20
+ export const TAG: Readonly<Record<string, string>>;
21
+ export function tagOf(by: unknown): string;
22
+ export function tagged(text: string, by: unknown): string;
23
+ export function sheetByOf(covers: unknown[]): "you" | "agent";
@@ -17,3 +17,12 @@ export function citedLineOf({ n, part, results, check, confirmed, }: {
17
17
  * @param {string} runDir @param {Record<string, any>} line @returns {void}
18
18
  */
19
19
  export function writeCitedLine(runDir: string, line: Record<string, any>): void;
20
+ /**
21
+ * M16 R7: the quotes of earlier lines' PASSED cited checks, read from the run's own record (what the numbers tie of a later text line is checked against). A line with no record, or
22
+ * one that did not pass, is `missing`: the tie then reads "its answer is not there yet", a normal red, never a pass. Read through the safe gateway; an unreadable record is every line missing.
23
+ * @param {string} runDir @param {number[]} from @returns {{quotes: Record<string, string[]>, missing: number[]}}
24
+ */
25
+ export function quotesOfLines(runDir: string, from: number[]): {
26
+ quotes: Record<string, string[]>;
27
+ missing: number[];
28
+ };
@@ -21,9 +21,10 @@ export function factDecides(part: any): Record<string, any>[];
21
21
  * The claims bareguard reads, built from the step's `results`. The claim TEXT is written here from the values the step gave (`name: value; name: value`),
22
22
  * a phrase fact contributes its own signed words. A result that is not an object, or has no string quote, still becomes a claim (an empty one) so
23
23
  * bareguard reds it by name rather than the result vanishing.
24
- * @param {any} part @param {unknown} results @returns {{claim: string, quote: string, values?: Record<string, string>}[]}
24
+ * `asWritten` (bareloop v0.56.0): per result, per fact index, the value as the page writes it, for the claim's words of a date or amount a page form signs.
25
+ * @param {any} part @param {unknown} results @param {Record<number, string>[]} [asWritten] @returns {{claim: string, quote: string, values?: Record<string, string>}[]}
25
26
  */
26
- export function factClaims(part: any, results: unknown): {
27
+ export function factClaims(part: any, results: unknown, asWritten?: Record<number, string>[]): {
27
28
  claim: string;
28
29
  quote: string;
29
30
  values?: Record<string, string>;
@@ -39,6 +40,21 @@ export function buildCitedSpec(part: any, sha256: string): Record<string, any>;
39
40
  * @param {any} f @param {string} source @returns {string}
40
41
  */
41
42
  export function factSentence(f: any, source: string): string;
43
+ /** the `fact` part of a step's parameters, or null (a step has at most one) @param {any} params @returns {any|null} */
44
+ export function factPartOf(params: any): any | null;
45
+ /**
46
+ * The SHAPE of a `fact` part (what it may carry), pushed as reds in the same form `rubricStepShapeReds` uses. Whether the
47
+ * bareguard rubric it builds is signable is asked of bareguard itself (`checkRubricParts` builds it once at drafting).
48
+ * @param {any} part @param {string} w the path prefix @param {(code: string, path: string, detail: string) => void} red
49
+ */
50
+ export function factShapeReds(part: any, w: string, red: (code: string, path: string, detail: string) => void): void;
51
+ /**
52
+ * Where bareguard read each page-form fact's value inside each quote, as the quote spells it: from `checkStep`'s `full.evidence` (one entry per
53
+ * claim: `text` = the normalized quote the decides ran on, `spans` = where each decide read its anchor, value and unit/currency). Only a fact that
54
+ * signs `lang` or `decimal` is looked up; the span is the decide's `value` span (the one equal to the claim's own value when bareguard flags it).
55
+ * @param {any} part @param {any[]|undefined} evidence @returns {(Record<number, string>|undefined)[]} per claim index
56
+ */
57
+ export function writtenSpans(part: any, evidence: any[] | undefined): (Record<number, string> | undefined)[];
42
58
  /** @param {any} part @returns {string|null} the "N results" row of a fact part */
43
59
  export function countSentence(part: any): string | null;
44
60
  /**
@@ -99,3 +115,18 @@ export const FACT_SHAPES: readonly string[];
99
115
  export const MAX_FACTS: 10;
100
116
  export const CITED_ID: "facts";
101
117
  export function sha256Text(t: string): string;
118
+ /** the languages whose month names bareguard 0.27 reads on a `date` fact (its `lang`), each with the name a person reads; absent `lang` = ISO YYYY-MM-DD only */
119
+ export const FACT_LANGS: Readonly<{
120
+ en: "English";
121
+ de: "German";
122
+ fr: "French";
123
+ es: "Spanish";
124
+ it: "Italian";
125
+ pt: "Portuguese";
126
+ nl: "Dutch";
127
+ }>;
128
+ /** the decimal marks a number or money fact may sign (bareguard 0.27 `decimal`); absent = "." */
129
+ export const FACT_DECIMALS: readonly string[];
130
+ /** every field a part of class `fact` may carry (the shared ones are checked by rubricStepShapeReds) */
131
+ export const FACT_PART_FIELDS: readonly string[];
132
+ export function moneyForms(f: any): string[];
@@ -85,9 +85,9 @@ export function closeSoftgreen(artifact: any, shape: {
85
85
  /**
86
86
  * The one dispatcher — `close by declared class` (M2 scope item 4).
87
87
  *
88
- * @param {{ close?: { class?: string, shape?: Record<string, any>, picked?: any[], cited?: any, columns?: {source: string, column: string}[], sheet?: any[] } }} step
88
+ * @param {{ close?: { class?: string, shape?: Record<string, any>, picked?: any[], cited?: any, columns?: {source: string, column: string}[], sheet?: any[], numbersFrom?: number[] } }} step
89
89
  * @param {unknown} artifact
90
- * @param {{ reads: Record<string, any>, businessDate: string, source?: {ok: true, text: string, sha256: string}|{ok: false, red: string}|null, sheet?: any }} ctx
90
+ * @param {{ reads: Record<string, any>, businessDate: string, source?: {ok: true, text: string, sha256: string}|{ok: false, red: string}|null, sheet?: any, numbers?: {quotes: Record<string, string[]>, missing: number[]} }} ctx
91
91
  * `source` (M10 piece 4) = the run's own frozen copy a cited step reads, from `readRunSource`; only a step whose close carries `cited` reads it
92
92
  * `sheet` (M10b piece 2) = the run's own tables and recorded `tableSha`s a step with `close.sheet` is checked on, from `readRunSheets`
93
93
  * @returns {Promise<CloseVerdict>}
@@ -103,6 +103,7 @@ export function closeByClass(step: {
103
103
  column: string;
104
104
  }[];
105
105
  sheet?: any[];
106
+ numbersFrom?: number[];
106
107
  };
107
108
  }, artifact: unknown, ctx: {
108
109
  reads: Record<string, any>;
@@ -116,6 +117,27 @@ export function closeByClass(step: {
116
117
  red: string;
117
118
  } | null;
118
119
  sheet?: any;
120
+ numbers?: {
121
+ quotes: Record<string, string[]>;
122
+ missing: number[];
123
+ };
119
124
  }): Promise<CloseVerdict>;
125
+ /**
126
+ * M16 am3 (2), R7: the `$` numbers default of the check list. Every number in the answer's `text` must be in a quote an EARLIER line's cited check already passed (bareguard's `numbersInQuote`: a token match
127
+ * on the numbers, not a canonical compare, a documented limit; words are free). The quotes are the run's cited record of those lines (`ctx.numbers.quotes`, line -> quotes; `missing` = lines with none).
128
+ * Third outcomes: an answer with no `text` is `unparseable`, quotes that cannot be read (no record, a line not there yet) are `crash`; neither is ever green.
129
+ * What it throws away: only the numbers' token form is compared; a number written another way in the quote (1,000 vs 1000) is a bareguard question, not ours.
130
+ * @borrowed-from bareloop src/rubricstep.js@v0.56.0 (3383cce) gradeStep, PART 1b
131
+ * @param {any} step @param {unknown} artifact @param {number[]} from @param {{quotes: Record<string, string[]>, missing: number[]}|undefined} numbers
132
+ * @returns {{verdict: 'green'|'red'|'unparseable'|'crash', red: string|null, text: string}}
133
+ */
134
+ export function closeNumbers(step: any, artifact: unknown, from: number[], numbers: {
135
+ quotes: Record<string, string[]>;
136
+ missing: number[];
137
+ } | undefined): {
138
+ verdict: "green" | "red" | "unparseable" | "crash";
139
+ red: string | null;
140
+ text: string;
141
+ };
120
142
  export type CloseVerdict = import("./types.js").CloseVerdict;
121
143
  import { createRubric } from 'bareguard';