fwdloop 0.33.0 → 0.35.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.
- package/README.md +14 -0
- package/bin/fwdloop +18 -2
- package/package.json +1 -1
- package/src/action-line.js +100 -0
- package/src/action-stop.js +44 -0
- package/src/ask.js +9 -2
- package/src/auditchecks.js +6 -4
- package/src/authoring.js +28 -14
- package/src/blockasks.js +3 -2
- package/src/blockassemble.js +40 -21
- package/src/blockdraft.js +8 -13
- package/src/blockpick.js +11 -1
- package/src/checkblock.js +102 -58
- package/src/checked.js +7 -2
- package/src/checklist.js +1 -3
- package/src/checklistsign.js +1 -1
- package/src/checkpick.js +7 -73
- package/src/declaration.js +20 -35
- package/src/drafter.js +281 -208
- package/src/jobkey.js +2 -3
- package/src/noteask.js +62 -0
- package/src/pageask.js +24 -69
- package/src/pagedry.js +27 -4
- package/src/pagemap.js +8 -2
- package/src/pagerules.js +19 -3
- package/src/panel/author.js +63 -36
- package/src/panel/authorcard.js +36 -20
- package/src/panel/data.js +5 -1
- package/src/panel/index.html +66 -37
- package/src/pickrecord.js +42 -54
- package/src/planrebuild.js +16 -6
- package/src/rowedit.js +35 -5
- package/src/rubricstep.js +9 -1
- package/src/runner.js +87 -41
- package/src/runvalues.js +9 -1
- package/src/setup.js +3 -1
- package/src/sheetblock.js +17 -7
- package/src/sheetbuild.js +148 -0
- package/src/sheetchecks.js +3 -2
- package/src/sheetfind.js +4 -4
- package/src/sheetlook.js +15 -4
- package/src/sheetoffer.js +50 -5
- package/src/sheetrows.js +18 -2
- package/src/signed-text.js +1 -5
- package/src/ticket-draft.js +4 -21
- package/src/ticketrows.js +100 -0
- package/src/whole-job.js +27 -11
- package/types/action-line.d.ts +71 -0
- package/types/action-stop.d.ts +36 -0
- package/types/ask.d.ts +3 -2
- package/types/auditchecks.d.ts +2 -1
- package/types/authoring.d.ts +8 -3
- package/types/blockasks.d.ts +1 -2
- package/types/blockassemble.d.ts +20 -3
- package/types/blockdraft.d.ts +4 -12
- package/types/blockpick.d.ts +5 -0
- package/types/checkblock.d.ts +33 -17
- package/types/checked.d.ts +2 -0
- package/types/checklist.d.ts +3 -5
- package/types/checkpick.d.ts +4 -34
- package/types/declaration.d.ts +7 -0
- package/types/drafter.d.ts +23 -356
- package/types/noteask.d.ts +52 -0
- package/types/pageask.d.ts +12 -36
- package/types/pagedry.d.ts +13 -0
- package/types/pagerules.d.ts +7 -0
- package/types/panel/author.d.ts +1 -1
- package/types/panel/authorcard.d.ts +13 -8
- package/types/panel/authorflows.d.ts +4 -4
- package/types/panel/data.d.ts +2 -2
- package/types/panel/jobgrid.d.ts +1 -1
- package/types/pickrecord.d.ts +47 -13
- package/types/rowedit.d.ts +16 -1
- package/types/rubricstep.d.ts +3 -0
- package/types/sheetblock.d.ts +11 -4
- package/types/sheetbuild.d.ts +82 -0
- package/types/sheetchecks.d.ts +2 -1
- package/types/sheetfind.d.ts +2 -2
- package/types/sheetoffer.d.ts +26 -1
- package/types/sheetrows.d.ts +8 -0
- package/types/ticket-draft.d.ts +3 -49
- package/types/ticketrows.d.ts +61 -0
- package/types/whole-job.d.ts +3 -3
- package/src/added-end.js +0 -60
- package/src/repairs.js +0 -38
- package/types/added-end.d.ts +0 -62
- package/types/repairs.d.ts +0 -13
package/src/blockdraft.js
CHANGED
|
@@ -5,6 +5,7 @@ import { redactSecrets } from './redact.js';
|
|
|
5
5
|
import { newJobBlock } from './blocklines.js';
|
|
6
6
|
import { EDIT_OPS } from './checkblock.js';
|
|
7
7
|
import { isCountGuardrail } from './declaration.js';
|
|
8
|
+
import { ticketRuleField } from './ticketrows.js';
|
|
8
9
|
|
|
9
10
|
/** the cap of refusals one revise turn carries (bareloop REVISE_RED_CAP) */
|
|
10
11
|
export const REVISE_RED_CAP = 20;
|
|
@@ -32,25 +33,19 @@ export function isBuildFault(red, builtLines) {
|
|
|
32
33
|
/**
|
|
33
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.
|
|
34
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".
|
|
35
|
-
*
|
|
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, scoped?: {line: number, rule: number}[]}} o
|
|
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
|
|
37
37
|
*/
|
|
38
|
-
export function setUpBlock({ texts, jobLines, look, kept, fresh, asks, countScope,
|
|
38
|
+
export function setUpBlock({ texts, jobLines, look, kept, fresh, asks, countScope, leaveOut = [] }) {
|
|
39
39
|
const block = newJobBlock({ texts, jobLines, asks, countScope });
|
|
40
40
|
// 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
41
|
if (leaveOut.length) block.rows = block.rows.filter((r) => !(r.kind === 'rule' && leaveOut.some((x) => x.line === r.line && x.rule === r.rule)));
|
|
42
42
|
// a rule the person left is the block's own `left` row (carry, below); the look's person-left drop would say it twice
|
|
43
43
|
block.addLook(look.facts, look.dropped.filter((d) => d.reason !== 'person-left'));
|
|
44
|
-
block.carry({ picks: kept.picks, left: kept.left }
|
|
44
|
+
block.carry({ picks: kept.picks, left: kept.left });
|
|
45
45
|
const rowOf = (/** @type {number} */ line, /** @type {number} */ rule) => block.ruleRows(line).find((x) => x.rule === rule);
|
|
46
46
|
block.carry({ picks: fresh.picks, left: fresh.left });
|
|
47
47
|
for (const x of [...fresh.picks, ...fresh.left]) { const r = rowOf(x.line, x.rule); if (r && !kept.picks.some((k) => k.line === x.line && k.rule === x.rule) && !kept.left.some((k) => k.line === x.line && k.rule === x.rule)) delete r.keptFromLast; }
|
|
48
48
|
block.reconcile();
|
|
49
|
-
for (const r of scoped) {
|
|
50
|
-
const row = rowOf(r.line, r.rule);
|
|
51
|
-
if (row && !kept.askRules.some((a) => a.line === r.line && a.rule === r.rule) && !row.pick && !row.cantAsked && !row.left && !row.parent) row.folded = true;
|
|
52
|
-
}
|
|
53
|
-
block.reconcile();
|
|
54
49
|
return block;
|
|
55
50
|
}
|
|
56
51
|
|
|
@@ -82,10 +77,10 @@ export const editRecord = (rec) => rec.edits.map((e) => ({ op: e?.op, accepted:
|
|
|
82
77
|
/**
|
|
83
78
|
* M16 item 4 ("Tickets `ticketFilter` and `ticketWatch` stay as they are"): the rules of a Tickets job that are not the block's. Before M16 only a count guardrail of such a job (it signs a
|
|
84
79
|
* ticket page input, which routes its guardrails: src/checkpick.js codeScope) was picked or asked; every other rule ("priority P1 only", "run a ticket again when its state changes") was the
|
|
85
|
-
* declaration's own typed ticketFilter / ticketWatch, never asked and never listed as Not checked.
|
|
86
|
-
* @param {string} flowType @param {{n: number, rules?: string[]}[]} jobLines @
|
|
80
|
+
* declaration's own typed ticketFilter / ticketWatch, never asked and never listed as Not checked. Since M17 am6 these rules are ticket rows (src/ticketrows.js), so one the look tied to a fact is left out of the block too: it shows once, as the ticket row.
|
|
81
|
+
* @param {string} flowType @param {{n: number, rules?: string[]}[]} jobLines @returns {{line: number, rule: number}[]}
|
|
87
82
|
*/
|
|
88
|
-
export function ticketLeaveOut(flowType, jobLines
|
|
83
|
+
export function ticketLeaveOut(flowType, jobLines) {
|
|
89
84
|
if (flowType !== 'tickets') return [];
|
|
90
|
-
return jobLines.flatMap((l) => (l.rules ?? []).map((t, i) => ({ line: l.n, rule: i + 1, t })).filter((x) =>
|
|
85
|
+
return jobLines.flatMap((l) => (l.rules ?? []).map((t, i) => ({ line: l.n, rule: i + 1, t })).filter((x) => ticketRuleField(x.t) !== null && !isCountGuardrail(x.t)).map((x) => ({ line: x.line, rule: x.rule })));
|
|
91
86
|
}
|
package/src/blockpick.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// borrowed-from: bareloop src/checkpick.js@v0.
|
|
1
|
+
// borrowed-from: bareloop src/checkpick.js@v0.57.0 (c18df406)
|
|
2
|
+
// first ported from: bareloop src/checkpick.js@v0.56.0 (3383cce) (isCountable, keepOrDrop, countCheck, partOfPick, sameRuleWords and what they call; HOW_TO_ANSWER and CANT_CHECK_WORDS are fwd's own, src/checkpick.js, the same words)
|
|
2
3
|
// This file is bareloop's checkpick.js. fwd already has a src/checkpick.js (the M10 am16 pick path, whose keepOrDrop and countCheck differ from these); the check block calls THESE,
|
|
3
4
|
// so they live here under another name and the am16 module is left as it is.
|
|
4
5
|
// The pick vocabulary and its keep-or-drop: a suggested check is kept only if its rule is on bareguard's list and offered here, it carries only that rule's own fields, and every
|
|
@@ -132,6 +133,15 @@ export function keepOrDrop(guardrail, sug) {
|
|
|
132
133
|
return { kept: true, check };
|
|
133
134
|
}
|
|
134
135
|
|
|
136
|
+
/**
|
|
137
|
+
* The check a counting rule's own words already ARE ("exactly 3 list items" -> listItems 3), or null. No obvious asks (hamr 2026-11-14): such a rule is settled as written, never proposed back to the person.
|
|
138
|
+
* @param {string} text @returns {Record<string, any>|null}
|
|
139
|
+
*/
|
|
140
|
+
export function obviousCheck(text) {
|
|
141
|
+
const c = countCheck(text);
|
|
142
|
+
return c !== null && c !== undefined && sameRuleWords(text, plainWords(/** @type {any} */ (c))) ? c : null;
|
|
143
|
+
}
|
|
144
|
+
|
|
135
145
|
/**
|
|
136
146
|
* The check CODE proposes for a count rule when the call yields none (R10, ours; fwd has no such fallback): a bullets / list-items / points count -> listItems N (exact; "at most / up to / no more than / fewer than / under / below" -> maxListItems, "at least / minimum / no fewer than / more than" -> minListItems, F315), a lines count ->
|
|
137
147
|
* maxLines N, ONE word number -> minWords N when the rule says "at least / minimum / more than", else maxWords N. A section count names no sections, so none is built; a rule naming two different counts ("3 bullets under 80 words") is not built either; a rule with
|
package/src/checkblock.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// borrowed-from: bareloop src/checkblock.js@v0.
|
|
1
|
+
// borrowed-from: bareloop src/checkblock.js@v0.57.0 (c18df406)
|
|
2
|
+
// first ported from: bareloop src/checkblock.js@v0.56.0 (3383cce) + f148028e (M16 am2: an agreed answer's follower row takes its parent's check after the parts are numbered, 4 lines in build())
|
|
2
3
|
// Ported, not copied whole (M16 am3 (1)): the imports point at fwd's files (src/blockpick.js is bareloop's checkpick.js under another name), and the three patterns built from text
|
|
3
4
|
// (the whole-word test in `inText`, the number test in `inJob` and `matchCount`) are written by hand, because src/ builds no pattern from text (test/signed-text.test.js).
|
|
4
5
|
// THE CHECK BLOCK of a rubric job (hamr 2026-11-12: "goal again is simplfication and one flow one place ai suggestes ! code adds $ and code decides what worked/doable").
|
|
@@ -9,15 +10,16 @@
|
|
|
9
10
|
// Pure: no I/O, no clock, no model. Rubric jobs only (repo jobs never run through it).
|
|
10
11
|
import { countExact, countPhrase } from './pagebits.js';
|
|
11
12
|
import { checkFactWords, keptSetOf } from './factwords.js';
|
|
12
|
-
import { isCountable, keepOrDrop, countCheck, partOfPick, plainWords, sameRuleWords } from './blockpick.js';
|
|
13
|
-
import { dropRows } from './pagedropwords.js';
|
|
14
|
-
import {
|
|
13
|
+
import { isCountable, keepOrDrop, countCheck, obviousCheck, partOfPick, plainWords, sameRuleWords } from './blockpick.js';
|
|
14
|
+
import { dropRows, dropSentence } from './pagedropwords.js';
|
|
15
|
+
import { phraseInNoResult } from './pagedry.js';
|
|
16
|
+
import { boundInWords, rubricStepShapeReds, defaultCitedText, defaultNoteText, readLimit, holdsManyBounds, NEGATING_RE, WHY_OTHER_CURRENCY } from './rubricstep.js';
|
|
15
17
|
import { validReading } from './pagerules.js';
|
|
16
18
|
import { weekOnly, weekTokens, WEEK_ONLY_WORDS, MAX_BANG } from './checklist.js';
|
|
17
19
|
import { fitPlacePhrase } from './placerule.js';
|
|
18
20
|
import { ruleWords } from './pageask.js';
|
|
19
21
|
import { SIGNED_ROW_FIELDS } from './declaredclose.js';
|
|
20
|
-
import { factSentence, countSentence } from './citedcheck.js';
|
|
22
|
+
import { factSentence, countSentence, factsOfLook } from './citedcheck.js';
|
|
21
23
|
|
|
22
24
|
/**
|
|
23
25
|
* 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),
|
|
@@ -26,7 +28,7 @@ import { factSentence, countSentence } from './citedcheck.js';
|
|
|
26
28
|
*/
|
|
27
29
|
|
|
28
30
|
/** the card's fixed words, one spelling (the renderer reads them; a test reads them too) */
|
|
29
|
-
export const CARD_T = Object.freeze({
|
|
31
|
+
export const CARD_T = Object.freeze({ count: 'result count', cited: 'every claim is backed by a quote copied from', theInput: 'the input', numbers: 'every number in the text is in a checked quote of line', withWords: 'with the words' });
|
|
30
32
|
|
|
31
33
|
/** the four row edits an AI reply may hold */
|
|
32
34
|
export const EDIT_OPS = Object.freeze(['add', 'reading', 'pick', 'not-checkable']);
|
|
@@ -74,6 +76,8 @@ export const REASON = Object.freeze({
|
|
|
74
76
|
manyInputs: 'the job has more than one input and code cannot pick which one the claims quote',
|
|
75
77
|
oneSidedTime: 'a time limit the AI proposes must be a range, so you judge it at Accept.',
|
|
76
78
|
countNeedsFact: 'a result count needs a fact to count; this line has none',
|
|
79
|
+
// borrowed-from: bareloop src/checkblock.js@v0.58.0
|
|
80
|
+
countNeedsSuggested: 'a result count needs a fact to count; add the suggested fact on this line to count its results',
|
|
77
81
|
lookNoWords: "the page does not hold the words of the look's fact for this rule",
|
|
78
82
|
afterLast: 'no more tries: Start over (rows are never changed by the AI after the last try)',
|
|
79
83
|
noPick: 'No check was picked for it, so you judge it at Accept.',
|
|
@@ -86,11 +90,12 @@ export const REASON = Object.freeze({
|
|
|
86
90
|
export function renderCard(rows) {
|
|
87
91
|
return rows.filter((r) => r.kind !== 'floor' && r.state !== 'suggested' && r.state !== 'dropped' && !r.hidden).map((r) => {
|
|
88
92
|
let body;
|
|
89
|
-
if (r.kind === 'rule') body = `"${r.text}"${r.pick
|
|
93
|
+
if (r.kind === 'rule') body = `"${r.text}"${r.pick && !sameRuleWords(r.text, plainWords(r.pick)) ? ` -> ${plainWords(r.pick)}` : ''}`;
|
|
90
94
|
else if (r.kind === 'count') body = `${CARD_T.count} ${r.min ?? ''}-${r.max ?? ''}`;
|
|
91
95
|
else if (r.kind === 'cited') body = `${CARD_T.cited} "${r.source ?? CARD_T.theInput}"`;
|
|
96
|
+
else if (r.kind === 'note') body = defaultNoteText(r.line);
|
|
92
97
|
else if (r.kind === 'numbers') body = `${CARD_T.numbers} ${(r.after ?? []).join(', ')}`;
|
|
93
|
-
else body = `${r.kind} "${r.name ?? r.words?.[0] ?? ''}"${r.words?.length ? ` ${CARD_T.withWords} ${r.words.map((/** @type {string} */ w) => `"${w}"`).join(', ')}` : ''}`;
|
|
98
|
+
else body = `${r.kind} "${r.name ?? r.words?.[0] ?? ''}"${(r.grown ?? r.words)?.length ? ` ${CARD_T.withWords} ${(r.grown ?? r.words).map((/** @type {string} */ w) => `"${w}"`).join(', ')}` : ''}`;
|
|
94
99
|
return { key: r.key, line: r.line, by: r.by, state: r.state, reason: r.reason ?? null, text: `${r.by === 'you' ? '~' : r.by === 'agent' ? '!' : '$'} ${body}` };
|
|
95
100
|
});
|
|
96
101
|
}
|
|
@@ -138,12 +143,16 @@ export class CheckBlock {
|
|
|
138
143
|
this.deltaLog = [];
|
|
139
144
|
/** @type {any} */
|
|
140
145
|
this.closeCache = null;
|
|
146
|
+
/** @type {Map<number, 'yes'|'no'|'failed'>} the note question's answer per facts-only line (src/noteask.js; code decides what it means) */
|
|
147
|
+
this.notes = new Map();
|
|
141
148
|
}
|
|
142
149
|
|
|
143
150
|
textOf(/** @type {string|undefined} */ source) { return this.texts[source ?? this.labels[0] ?? ''] ?? Object.values(this.texts)[0] ?? ''; }
|
|
144
151
|
/** @param {number} line @param {string} [kind] */
|
|
145
152
|
rowsOn(line, kind) { return this.rows.filter((r) => r.line === line && (kind === undefined || r.kind === kind)); }
|
|
146
153
|
ruleRows(/** @type {number} */ line) { return this.rows.filter((r) => r.kind === 'rule' && r.line === line); }
|
|
154
|
+
/** does a `~` rule's own row say it is Not checked? Then its row is the ONE place the rule is said (its reason: the look's sentence, or the person's Drop) @param {number} line @param {number} rule */
|
|
155
|
+
saysRule(line, rule) { return this.rows.some((r) => r.kind === 'rule' && r.line === line && r.rule === rule && r.state === 'not-checked' && typeof r.reason === 'string' && r.reason !== ''); }
|
|
147
156
|
/** every word the person wrote on a line: the line and its `~` rules */
|
|
148
157
|
said(/** @type {number} */ line) { return [this.lines.find((l) => l.n === line)?.text ?? '', ...this.ruleRows(line).map((r) => r.text)].join(' '); }
|
|
149
158
|
/** @param {Row} r @returns {Row} the row as stored (a repeated key gets `#2`) */
|
|
@@ -199,8 +208,6 @@ export class CheckBlock {
|
|
|
199
208
|
if (r.kind === 'floor') continue;
|
|
200
209
|
if (r.left) r.can = { ok: false, why: REASON.left };
|
|
201
210
|
else if (r.lookWhy && r.kind === 'fact' && !r.words.length) r.can = { ok: false, why: r.lookWhy };
|
|
202
|
-
else if (r.folded) r.can = { ok: false, why: REASON.noPick };
|
|
203
|
-
else if (r.parent) this.matchFollow(r);
|
|
204
211
|
else if (r.kind === 'rule') this.matchRule(r);
|
|
205
212
|
else if (r.kind === 'fact' || r.kind === 'phrase') this.matchBang(r);
|
|
206
213
|
else if (r.kind === 'count') this.matchCount(r);
|
|
@@ -217,7 +224,7 @@ export class CheckBlock {
|
|
|
217
224
|
}
|
|
218
225
|
|
|
219
226
|
/** 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) */
|
|
220
|
-
isBang(/** @type {Row} */ r) { return r.by === 'agent' && (r.kind === 'fact' || r.kind === 'phrase' || r.kind === 'count')
|
|
227
|
+
isBang(/** @type {Row} */ r) { return r.by === 'agent' && (r.kind === 'fact' || r.kind === 'phrase' || r.kind === 'count'); }
|
|
221
228
|
|
|
222
229
|
/**
|
|
223
230
|
* 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
|
|
@@ -238,13 +245,9 @@ export class CheckBlock {
|
|
|
238
245
|
const said = this.said(r.line);
|
|
239
246
|
if (r.kind === 'count') return [r.min, r.max].filter((x) => Number.isInteger(x)).some((n) => numberIn(said, n));
|
|
240
247
|
// a fact the person asked for BY NAME ("the release heading") is in the job too: the look's page words rarely echo the job's own words
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
/** a `~` line an agreed answer wrote (or a carried pair partner) is checked by the rule it was agreed from: one check, both numbers */
|
|
245
|
-
matchFollow(/** @type {Row} */ r) {
|
|
246
|
-
const parent = this.rows.find((x) => x.key === r.parent);
|
|
247
|
-
r.can = parent?.can?.ok ? { ok: true, how: 'follow' } : { ok: false, why: parent?.can?.why ?? 'the rule it was agreed from is not checked' };
|
|
248
|
+
// borrowed-from: bareloop src/checkblock.js@v0.58.0
|
|
249
|
+
// A phrase or place is job-derived only when its own words are in the person's text: a name the AI gave it is no proof (hamr 2026-11-15, live run mwi76vh8: "friendly" for "Select flight")
|
|
250
|
+
return (r.words ?? []).some((/** @type {string} */ w) => inText(said, w)) || (r.kind === 'fact' && r.shape !== 'phrase' && r.shape !== 'place' && typeof r.name === 'string' && inText(said, r.name));
|
|
248
251
|
}
|
|
249
252
|
|
|
250
253
|
/** a `!` count row is built unless a `~` rule on its line already names the number */
|
|
@@ -263,12 +266,16 @@ export class CheckBlock {
|
|
|
263
266
|
const links = (r.links ?? []).filter((/** @type {any} */ l) => !(negated && isPhrase(l)) && l.words.some((/** @type {string} */ w) => proved(this.textOf(l.source), w)));
|
|
264
267
|
const said = this.said(r.line);
|
|
265
268
|
let ownWhy = null;
|
|
269
|
+
let otherCurrency = false;
|
|
266
270
|
for (const l of links) {
|
|
267
271
|
let reading = l.reading;
|
|
268
272
|
let ownWords = false;
|
|
269
273
|
if (l.shape === 'money' || l.shape === 'time') {
|
|
270
274
|
// the person's words win (hamr 2026-11-13): code's reading of the `~` words beats the look's and the AI's; theirs is used only when code cannot read the words
|
|
271
275
|
const rd = this.wordsReading(l, r.text);
|
|
276
|
+
// fwdloop run walk-m16-flights run-1: "under $150" on a euro fact fell back to the look's reading and checked 150 euros; a bound in another currency than the page fact is never replaced by the look's or the AI's reading
|
|
277
|
+
const lim = !rd && l.shape === 'money' ? readLimit('money', r.text, l) : null;
|
|
278
|
+
if (lim && 'why' in lim && lim.why === WHY_OTHER_CURRENCY) { otherCurrency = true; continue; }
|
|
272
279
|
if (rd) { reading = rd; ownWords = true; }
|
|
273
280
|
else if (reading === undefined) {
|
|
274
281
|
const own = readLimit(l.shape, r.text, l);
|
|
@@ -296,6 +303,7 @@ export class CheckBlock {
|
|
|
296
303
|
r.can = { ok: true, how: 'fact', link: l, reading: undefined };
|
|
297
304
|
return;
|
|
298
305
|
}
|
|
306
|
+
if (otherCurrency) { r.can = { ok: false, why: `the amount in your rule is in another currency than the page's prices, so it is not checked.` }; return; }
|
|
299
307
|
if (r.links?.length && !links.length) { r.can = { ok: false, why: REASON.lookNoWords }; return; }
|
|
300
308
|
if (r.origin === 'typed' || r.cantAsked) { r.can = { ok: false, why: r.aiReason ?? r.lookWhy ?? REASON.nothingOnPage }; return; }
|
|
301
309
|
if (r.links?.length) { r.can = { ok: false, why: r.aiReason ?? `the look tied a fact to this rule but gave no limit, and ${ownWhy ? `in your words ${ownWhy}` : 'your own words give none code can read'}, so you judge it at Accept.` }; return; }
|
|
@@ -306,6 +314,12 @@ export class CheckBlock {
|
|
|
306
314
|
matchCountRule(/** @type {Row} */ r) {
|
|
307
315
|
if (!r.pick && (r.cantAsked || !this.countScope(r.text))) { r.can = { ok: false, why: r.aiReason ?? REASON.noRule }; return; }
|
|
308
316
|
if (r.pick) { r.can = { ok: true, how: 'pick' }; return; }
|
|
317
|
+
// no obvious asks (hamr 2026-11-14): a rule whose words ARE the check ("exactly 3 list items") is settled as it stands, so a replaced rule never re-asks on a re-draft or a Reuse
|
|
318
|
+
const obvious = obviousCheck(r.text);
|
|
319
|
+
if (obvious) {
|
|
320
|
+
const res = keepOrDrop(r.text, /** @type {any} */ ({ ...obvious }));
|
|
321
|
+
if (res.kept) { r.pick = res.check; r.from = 'pick'; r.can = { ok: true, how: 'pick' }; return; }
|
|
322
|
+
}
|
|
309
323
|
const proposal = r.pickProposal ?? countCheck(r.text);
|
|
310
324
|
if (!this.asks) r.can = { ok: false, why: REASON.noRule };
|
|
311
325
|
else if (proposal) r.can = { ok: false, ask: 'check', proposal, why: REASON.waitingPick };
|
|
@@ -329,6 +343,12 @@ export class CheckBlock {
|
|
|
329
343
|
r.can = { ok: true, how: 'place', strips: fits[0] ?? [] };
|
|
330
344
|
return;
|
|
331
345
|
}
|
|
346
|
+
// fwdloop run walk-m16-flights run-1: "Rome" was on the page (search box, toggles) but in no result row, so no run could pass it. When the line's look reads result rows (a money fact), a phrase in none of them is refused with the look's own sentence (one owner: pagedry.js + pagedropwords.js)
|
|
347
|
+
// (a look fact already went through the same dry read in pagemap.js, so only the AI's own adds are read here)
|
|
348
|
+
if (r.from === 'agent' && (r.shape ?? 'phrase') === 'phrase') {
|
|
349
|
+
const money = this.lookFacts.filter((/** @type {any} */ f) => f.line === r.line && f.shape === 'money' && (!r.source || !f.source || f.source === r.source));
|
|
350
|
+
if (phraseInNoResult(text, money, provedWords[0])) { r.can = { ok: false, why: dropSentence({ line: r.line, fact: r.name ?? provedWords[0], other: provedWords[0], reason: 'phrase-no-result' }) }; return; }
|
|
351
|
+
}
|
|
332
352
|
r.can = { ok: true, how: 'bang', word: provedWords[0] };
|
|
333
353
|
}
|
|
334
354
|
|
|
@@ -348,8 +368,6 @@ export class CheckBlock {
|
|
|
348
368
|
map.push({ part: parts.length, line: l.n, rows: lineRows[i] ?? [], origin: 'code' });
|
|
349
369
|
parts.push(p);
|
|
350
370
|
});
|
|
351
|
-
// a follow row ends with its parent's check: the parent's part is known only now, after the line's parts are numbered
|
|
352
|
-
for (const f of this.rowsOn(l.n).filter((x) => x.parent)) f.part = this.rows.find((x) => x.key === f.parent)?.part ?? null;
|
|
353
371
|
}
|
|
354
372
|
// a suggestion code has not built stays off the card (Audit only, F-b); a held one is trialled: shown under Suggested only when code has proved it builds (hamr 2026-11-13)
|
|
355
373
|
for (const r of this.rows.filter((x) => x.held)) this.trialOffer(r);
|
|
@@ -391,11 +409,11 @@ export class CheckBlock {
|
|
|
391
409
|
for (const r of this.rowsOn(l.n)) {
|
|
392
410
|
if (r.kind === 'floor') continue;
|
|
393
411
|
r.part = null;
|
|
394
|
-
|
|
412
|
+
r.grown = undefined;
|
|
395
413
|
if (!r.can?.ok) { r.state = 'not-checked'; r.reason = r.can?.why ?? 'not checked'; continue; }
|
|
396
414
|
if (r.held) { r.state = 'suggested'; r.reason = r.choice === 'drop' ? REASON.dropped : REASON.suggested; continue; }
|
|
397
415
|
if (r.can.how === 'pick') {
|
|
398
|
-
const p = partOfPick(r.pick, r.text, [r.rule
|
|
416
|
+
const p = partOfPick(r.pick, r.text, [r.rule]);
|
|
399
417
|
const reds = rubricStepShapeReds({ step: l.n, parts: [p] }, 'trial');
|
|
400
418
|
if (reds.length) { r.state = 'not-checked'; r.reason = `the pick is not a legal check: ${reds[0].detail}`; continue; }
|
|
401
419
|
pickParts.push({ p, key: r.key }); r.state = 'built'; r.reason = null;
|
|
@@ -407,7 +425,7 @@ export class CheckBlock {
|
|
|
407
425
|
facts.push(...built.fresh);
|
|
408
426
|
r.factNames = built.names;
|
|
409
427
|
factRows.push({ r, src: built.src });
|
|
410
|
-
if (r.kind === 'rule') rulesCarried.push(r.rule
|
|
428
|
+
if (r.kind === 'rule') rulesCarried.push(r.rule);
|
|
411
429
|
r.state = 'built'; r.reason = null;
|
|
412
430
|
}
|
|
413
431
|
if (facts.length) {
|
|
@@ -418,19 +436,25 @@ export class CheckBlock {
|
|
|
418
436
|
};
|
|
419
437
|
const reds = rubricStepShapeReds({ step: l.n, parts: [part] }, 'trial');
|
|
420
438
|
if (reds.length) for (const x of [...factRows.map((f) => f.r), ...(countRow ? [countRow] : [])]) { x.state = 'not-checked'; x.reason = `code could not build the line's fact part: ${reds[0]?.detail}`; x.part = null; }
|
|
421
|
-
else {
|
|
422
|
-
|
|
439
|
+
else {
|
|
440
|
+
// M17 am4 (B3): the ONE writer of a place's grown phrases (fwd's signed R2c, M10 am7 item 2): the part holds EVERY phrase as a fact of its own, and the row holds the same words (`grown`),
|
|
441
|
+
// so the card (renderCard), the plan and the Job tab say what the plan checks. A place the look did not grow keeps the one word.
|
|
442
|
+
const src = factRows[0]?.src;
|
|
443
|
+
const grownOf = (/** @type {any} */ f) => {
|
|
444
|
+
const k = f && f.shape === 'phrase' ? /** @type {any[]} */ (this.lookFacts).find((x) => x.line === l.n && Array.isArray(x.phrases) && String(x.name) === f.name && (x.source === undefined || x.source === src)) : undefined;
|
|
445
|
+
return k ? factsOfLook(k) : null;
|
|
446
|
+
};
|
|
447
|
+
for (const { r } of factRows) {
|
|
448
|
+
const words = (r.factNames ?? []).flatMap((/** @type {string} */ n) => (grownOf(facts.find((f) => f.name === n)) ?? []).map((x) => String(x.phrase)));
|
|
449
|
+
r.grown = words.length ? words : undefined;
|
|
450
|
+
}
|
|
451
|
+
lineParts.push({ ...part, facts: facts.flatMap((f) => grownOf(f) ?? [f]) }); lineRows.push([...factRows.map((f) => f.r.key), ...(countRow ? [countRow.key] : [])]); factLines.add(l.n); if (countRow) { countRow.state = 'built'; countRow.reason = null; } }
|
|
452
|
+
// borrowed-from: bareloop src/checkblock.js@v0.58.0
|
|
453
|
+
} else if (countRow) { countRow.state = 'not-checked'; countRow.reason = this.rowsOn(l.n).some((x) => x.held && (x.kind === 'fact' || x.kind === 'phrase')) ? REASON.countNeedsSuggested : REASON.countNeedsFact; }
|
|
423
454
|
for (const { p, key } of pickParts) { lineParts.push(p); lineRows.push([key]); }
|
|
424
455
|
this.buildDefaults(l, lineParts, lineRows, factLines);
|
|
425
|
-
for (const f of this.rowsOn(l.n).filter((x) => x.parent)) {
|
|
426
|
-
const par = this.rows.find((x) => x.key === f.parent);
|
|
427
|
-
f.state = par?.state ?? 'not-checked'; f.reason = par?.state === 'built' ? null : (par?.reason ?? 'not checked'); // its part is set by build(), after the parts are numbered (one owner)
|
|
428
|
-
}
|
|
429
456
|
}
|
|
430
457
|
|
|
431
|
-
/** the follow rows of a row (its agreed or carried `~` lines) */
|
|
432
|
-
followsOf(/** @type {Row} */ r) { return this.rows.filter((x) => x.parent === r.key); }
|
|
433
|
-
|
|
434
458
|
/**
|
|
435
459
|
* The fact(s) a fact-like row builds, checked alone through the bareguard shapes and against the facts already on the line.
|
|
436
460
|
* @param {Row} r @param {any[]} onLine the facts already built on this line @returns {{fresh: any[], src: string, names: string[]} | {why: string}}
|
|
@@ -476,7 +500,7 @@ export class CheckBlock {
|
|
|
476
500
|
const cited = !this.cited ? null : this.rowsOn(l.n, 'cited')[0] ?? this.addRow({ key: `L${l.n}.$cited`, line: l.n, kind: 'cited', by: 'default', from: 'default', source: this.labels[0] });
|
|
477
501
|
const numbers = this.rowsOn(l.n, 'numbers')[0] ?? null;
|
|
478
502
|
if (cited) cited.part = null;
|
|
479
|
-
if (factLines.has(l.n)) { if (cited) { cited.state = 'not-checked'; cited.reason = REASON.onePerLine; } return; }
|
|
503
|
+
if (factLines.has(l.n)) { if (cited) { cited.state = 'not-checked'; cited.reason = REASON.onePerLine; } this.buildNote(l, lineParts, lineRows); return; }
|
|
480
504
|
const only = this.labels.length === 1 ? this.labels[0] : null;
|
|
481
505
|
if (cited && only) { lineParts.push({ text: defaultCitedText(only), class: 'countable', check: 'cited', source: only }); lineRows.push([cited.key]); cited.state = 'built'; cited.reason = null; }
|
|
482
506
|
else if (cited) { cited.state = 'not-checked'; cited.reason = REASON.manyInputs; }
|
|
@@ -487,6 +511,29 @@ export class CheckBlock {
|
|
|
487
511
|
lineRows.push([nr.key]); nr.state = 'built'; nr.reason = null; nr.part = null;
|
|
488
512
|
}
|
|
489
513
|
|
|
514
|
+
// borrowed-from: bareloop src/checkblock.js@v0.57.0 (c18df406) (buildNote, factOnlyLines, setNotes)
|
|
515
|
+
/**
|
|
516
|
+
* The `$` note row of a facts-only line: the one note question said yes -> a countable nonEmpty text part sits beside the facts (the existing keep-both shape), so the brief
|
|
517
|
+
* is FACTS AND TEXT and text-present is floored; no -> nothing; the call failed -> a Not checked row in plain words. One owner of the row and its part.
|
|
518
|
+
*/
|
|
519
|
+
buildNote(/** @type {{n: number}} */ l, /** @type {any[]} */ lineParts, /** @type {string[][]} */ lineRows) {
|
|
520
|
+
const ans = this.notes.get(l.n);
|
|
521
|
+
if (ans !== 'yes' && ans !== 'failed') return;
|
|
522
|
+
const row = this.rowsOn(l.n, 'note')[0] ?? this.addRow({ key: `L${l.n}.$note`, line: l.n, kind: 'note', by: 'default', from: 'default' });
|
|
523
|
+
if (ans === 'failed') { row.state = 'not-checked'; row.reason = `could not ask whether line ${l.n} also wants a note`; row.part = null; return; }
|
|
524
|
+
lineParts.push({ text: defaultNoteText(l.n), class: 'countable', check: 'nonEmpty' });
|
|
525
|
+
lineRows.push([row.key]); row.state = 'built'; row.reason = null;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
/** the job lines that ended up facts-only (a fact part and no text beside it): the lines the note question is about. Reconciles first. @returns {number[]} */
|
|
529
|
+
factOnlyLines() {
|
|
530
|
+
const c = this.reconcile();
|
|
531
|
+
return c.stages.filter((/** @type {any} */ st) => st.params.parts.some((/** @type {any} */ p) => p.class === 'fact') && !st.params.parts.some((/** @type {any} */ p) => p.class === 'countable')).map((/** @type {any} */ st) => st.params.step);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
/** the note question's answers, `{line, answer: 'yes'|'no'|'failed'}`; the whole list is reconciled again @param {{line: number, answer: 'yes'|'no'|'failed'}[]} answers */
|
|
535
|
+
setNotes(answers) { for (const a of answers) this.notes.set(a.line, a.answer); this.reconcile(); }
|
|
536
|
+
|
|
490
537
|
// 5. the code-forced questions for rows code cannot settle (a person answers; the CHOICE decides, never the words). Cap 3 is the caller's (MAX_QUESTIONS).
|
|
491
538
|
ask() {
|
|
492
539
|
this.open = [];
|
|
@@ -499,7 +546,8 @@ export class CheckBlock {
|
|
|
499
546
|
hasOpenQuestions() { return this.open.length > 0; }
|
|
500
547
|
hasPendingDelta() { return this.queue.length > 0; }
|
|
501
548
|
|
|
502
|
-
// 6. the person's answer: a row edit from the typed CHOICE (agree | drop | rule)
|
|
549
|
+
// 6. the person's answer: a row edit from the typed CHOICE (agree | drop | rule). ONE rule in, ONE rule out (hamr 2026-11-14, superseding the 2026-11-12 ruling that an agreed answer is a new `~` line):
|
|
550
|
+
// the answer REPLACES the asked rule, same line and same rule number; this list is the one owner (the job text is rebuilt from it, `jobLinesView`).
|
|
503
551
|
/** @param {string} qKey @param {string} choice @param {string} [text] @returns {{ok: true} | {ok: false, why: string}} */
|
|
504
552
|
applyAnswer(qKey, choice, text) {
|
|
505
553
|
const q = this.open.find((x) => x.key === qKey);
|
|
@@ -511,50 +559,46 @@ export class CheckBlock {
|
|
|
511
559
|
if (q.ask === 'check') {
|
|
512
560
|
const res = keepOrDrop(r.text, /** @type {any} */ ({ ...q.proposal }));
|
|
513
561
|
if (!res.kept) return { ok: false, why: String(res.why) };
|
|
514
|
-
r.pick = res.check; r.from = 'pick';
|
|
515
|
-
said =
|
|
516
|
-
} else
|
|
517
|
-
|
|
518
|
-
if (r.pairWith !== undefined) r.text = said;
|
|
519
|
-
else {
|
|
520
|
-
// F318: agreeing to words the line already holds as a `~` rule adds no second line (the pick cites the rule that is there); a reading always adds its line
|
|
521
|
-
const held = q.ask === 'check' ? this.ruleRows(r.line).filter((x) => sameRuleWords(x.text, said)).at(-1) : undefined;
|
|
522
|
-
if (held === undefined) this.addRow({ key: `L${r.line}.~${this.ruleRows(r.line).length + 1}`, line: r.line, kind: 'rule', by: 'you', from: 'rule', origin: 'agreed', parent: r.key, text: said, rule: this.ruleRows(r.line).length + 1 });
|
|
523
|
-
else if (held !== r) this.follow(r, held);
|
|
524
|
-
}
|
|
562
|
+
r.pick = res.check; r.from = 'pick';
|
|
563
|
+
said = plainWords(/** @type {any} */ (res.check));
|
|
564
|
+
} else r.agreed = true;
|
|
565
|
+
r.text = said;
|
|
525
566
|
return { ok: true };
|
|
526
567
|
}
|
|
527
568
|
if (choice === 'drop') { r.left = true; return { ok: true }; }
|
|
528
569
|
if (choice === 'rule') {
|
|
529
570
|
const said = String(text ?? '').replace(/\s+/g, ' ').trim();
|
|
530
571
|
if (!said) return { ok: false, why: 'an answer is needed' };
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
this.addRow({ key: `L${r.line}.~${n}`, line: r.line, kind: 'rule', by: 'you', from: 'rule', origin: 'typed', text: said, rule: n });
|
|
572
|
+
// the person's own words are the rule now (typed); a counting rule is judged again as written (settled when its words are the proposal), any other stays the person's to judge
|
|
573
|
+
r.text = said; r.origin = 'typed'; r.cantAsked = !isCountable(said);
|
|
534
574
|
return { ok: true };
|
|
535
575
|
}
|
|
536
576
|
return { ok: false, why: 'not one of the choices' };
|
|
537
577
|
}
|
|
538
578
|
|
|
539
|
-
/**
|
|
540
|
-
|
|
579
|
+
/**
|
|
580
|
+
* The job lines as the list now holds them: every line's `~` rules are the rule rows' own words, in rule order (a replaced rule keeps its place and number). ONE owner of the job text after an answer.
|
|
581
|
+
* @template {{n: number, text: string}} L @param {L[]} jobLines @returns {(L & {rule: string, rules: string[]})[]}
|
|
582
|
+
*/
|
|
583
|
+
jobLinesView(jobLines) {
|
|
584
|
+
return jobLines.map((l) => {
|
|
585
|
+
const rules = this.ruleRows(l.n).sort((a, b) => a.rule - b.rule).map((r) => String(r.text));
|
|
586
|
+
return { ...l, rule: rules.join('; '), rules };
|
|
587
|
+
});
|
|
588
|
+
}
|
|
541
589
|
|
|
542
590
|
/**
|
|
543
|
-
* Revise keeps the picks of the last draft (am17/am18
|
|
544
|
-
*
|
|
545
|
-
* @param {{picks?: {line: number, rule: number, check: any, added?: string, own?: boolean}[], left?: {line: number, rule: number}[]}} kept
|
|
546
|
-
* @param {{line: number, rule: number, pairRule?: number}[]} [asked] the rules still asked (a `pairRule` marks an edited added line)
|
|
591
|
+
* Revise keeps the picks of the last draft (am17/am18, `src/pickrecord.js` `matchRecord`): a kept pick settles its rule (its words are the final rule's words) and a kept left rule is left.
|
|
592
|
+
* @param {{picks?: {line: number, rule: number, check: any, own?: boolean}[], left?: {line: number, rule: number}[]}} kept
|
|
547
593
|
*/
|
|
548
|
-
carry({ picks = [], left = [] }
|
|
594
|
+
carry({ picks = [], left = [] }) {
|
|
549
595
|
const rowOf = (/** @type {number} */ line, /** @type {number} */ rule) => this.ruleRows(line).find((x) => x.rule === rule);
|
|
550
596
|
for (const p of picks) {
|
|
551
597
|
const r = rowOf(p.line, p.rule);
|
|
552
598
|
if (!r) continue;
|
|
553
|
-
if (p.check) { r.pick = p.check; r.from = 'pick'; r.keptFromLast = true;
|
|
554
|
-
if (typeof p.added === 'string') { const add = this.ruleRows(p.line).filter((x) => x !== r && !x.parent && sameRuleWords(x.text, String(p.added))).at(-1); if (add) this.follow(r, add); }
|
|
599
|
+
if (p.check) { r.pick = p.check; r.from = 'pick'; r.keptFromLast = true; } else { r.cantAsked = !isCountable(r.text); r.keptFromLast = true; }
|
|
555
600
|
}
|
|
556
601
|
for (const l of left) { const r = rowOf(l.line, l.rule); if (r) { r.left = true; r.keptFromLast = true; } }
|
|
557
|
-
for (const a of asked) if (a.pairRule !== undefined) { const r = rowOf(a.line, a.rule); if (r) { r.pairWith = a.pairRule; const src = rowOf(a.line, a.pairRule); if (src && src !== r) this.follow(r, src); } }
|
|
558
602
|
}
|
|
559
603
|
|
|
560
604
|
// 7. the AI's reply: a list of proposed ROW edits, each judged ALONE; a bad edit is refused on its own and costs the rest nothing
|
package/src/checked.js
CHANGED
|
@@ -25,6 +25,12 @@ import { splitReadNotes, signedFactNames } from './pagedropwords.js';
|
|
|
25
25
|
|
|
26
26
|
const list = (xs) => xs.join(', ');
|
|
27
27
|
|
|
28
|
+
/** The words for a step with no machine check of its content: the ONE owner (the card and the draft readout both call it). @param {boolean} hasAsk the job has a signed ask @param {boolean} afterLastAsk the step comes after the last ask */
|
|
29
|
+
export function hitlWords(hasAsk, afterLastAsk) {
|
|
30
|
+
if (afterLastAsk) return 'No machine check of the content; you check it after you accept.';
|
|
31
|
+
return hasAsk ? 'No machine check of the content: you check it at the ask.' : 'No machine check of the content; the machine checks only that the step happened.';
|
|
32
|
+
}
|
|
33
|
+
|
|
28
34
|
/**
|
|
29
35
|
* One entry per step, in plan order: the plain sentences for what its typed close checks.
|
|
30
36
|
* M10b piece 4: with `lines` (the signed job lines) a step that reads a sheet also carries `sheet`, its line's block (src/sheetblock.js `sheetLineBlocks`: guardrails,
|
|
@@ -69,8 +75,7 @@ export function checkedLines(declaration, { hasAsk = true, askLines, lines, csvR
|
|
|
69
75
|
// M10 am16: each check the person picked, in the words it was picked in (src/checkwords.js, the one place)
|
|
70
76
|
if (!listed && Array.isArray(shape.picked)) for (const c of shape.picked) out.push(labelled(`You picked: ${plainWords(c)}.${keptOf(st.fromLine, c)}`, 'picked'));
|
|
71
77
|
} else {
|
|
72
|
-
|
|
73
|
-
else out.push(hasAsk ? 'No machine check of the content: you check it at the ask.' : 'No machine check of the content; the machine checks only that the step happened.');
|
|
78
|
+
out.push(hitlWords(hasAsk, lastAsk !== -1 && i > lastAsk));
|
|
74
79
|
}
|
|
75
80
|
// M10 am22 (1)(4): the checks the person picked for a fact line, beside its fact rows
|
|
76
81
|
if (!listed && cls === 'green' && Array.isArray(st.close.picked)) for (const c of st.close.picked) out.push(labelled(`You picked: ${plainWords(c)}.${keptOf(st.fromLine, c)}`, 'picked'));
|
package/src/checklist.js
CHANGED
|
@@ -12,8 +12,6 @@ import { lineRules } from './pagebits.js';
|
|
|
12
12
|
export const MAX_BANG = 3;
|
|
13
13
|
/** 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 */
|
|
14
14
|
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.';
|
|
15
|
-
/** the label of the list call, as the drafting book and the draft log see it */
|
|
16
|
-
export const LEDGER_LABEL = 'ledger-suggest';
|
|
17
15
|
export const LEDGER_TOOL = 'suggest_extra_checks';
|
|
18
16
|
/** how much of each input the call is shown */
|
|
19
17
|
const SHOWN_CHARS = 8000;
|
|
@@ -41,7 +39,7 @@ export function weekTokens(t) {
|
|
|
41
39
|
}
|
|
42
40
|
|
|
43
41
|
/**
|
|
44
|
-
* @typedef {{key: string, line: number, kind: 'rule'|'fact'|'cited'|'count'|'phrase'|'numbers'|'floor', from: 'rule'|'pick'|'look'|'agent'|'default', by: 'you'|'agent'|'default',
|
|
42
|
+
* @typedef {{key: string, line: number, kind: 'rule'|'fact'|'cited'|'count'|'phrase'|'numbers'|'note'|'floor', from: 'rule'|'pick'|'look'|'agent'|'default', by: 'you'|'agent'|'default',
|
|
45
43
|
* words: string[], text?: string, rule?: number, part?: {line: number, part: number}, source?: string, name?: string, min?: number, max?: number, pick?: string, after?: number[],
|
|
46
44
|
* state: 'listed'|'built'|'not-checked'|'dropped', reason: string|null, forRule?: number, reading?: import('./pagerules.js').Reading}} Row
|
|
47
45
|
*/
|
package/src/checklistsign.js
CHANGED
|
@@ -36,7 +36,7 @@ export function checkListReds(declaration) {
|
|
|
36
36
|
const lines = [...new Set([...list.filter((r) => Number.isInteger(r.line)).map((r) => /** @type {number} */ (r.line)), ...sheetLines])].sort((a, b) => a - b);
|
|
37
37
|
const stepsOn = (/** @type {number} */ n) => steps.filter((st) => st.fromLine === n);
|
|
38
38
|
const partsOn = (/** @type {number} */ n) => stepsOn(n).flatMap((st) => closePartsOf(st, sheetListed));
|
|
39
|
-
const built = list.filter((r) => r.state === 'built' && r.kind !== 'floor');
|
|
39
|
+
const built = list.filter((r) => r.state === 'built' && r.kind !== 'floor' && r.kind !== 'ticket');
|
|
40
40
|
/** @type {string[]} */
|
|
41
41
|
const reds = [];
|
|
42
42
|
for (const r of built) {
|
package/src/checkpick.js
CHANGED
|
@@ -205,95 +205,29 @@ export function countCheck(text) {
|
|
|
205
205
|
/** the can't-check ask, as the signed words say it */
|
|
206
206
|
export const CANT_CHECK_WORDS = "I can't check this. Your own words, or Not checked?";
|
|
207
207
|
/** how every answer is told, once (am2 item 2's words) */
|
|
208
|
-
export const HOW_TO_ANSWER = (/** @type {number} */ line, /** @type {boolean} */ agree) => `${agree ? 'Answer "agree" to use it, or type your own words' : 'Type your own words'} (your answer
|
|
208
|
+
export const HOW_TO_ANSWER = (/** @type {number} */ line, /** @type {boolean} */ agree) => `${agree ? 'Answer "agree" to use it, or type your own words' : 'Type your own words'} (your answer replaces that ~ rule on line ${line}), or answer "drop it" to leave it Not checked.`;
|
|
209
209
|
|
|
210
210
|
/**
|
|
211
211
|
* The asks for the rows: `Line n, guardrail "<…>": I propose <check in plain words>.` for a kept check, `Line n, guardrail "<…>": I can't check this. Your own words, or
|
|
212
212
|
* Not checked?` when nothing was kept. A proposal is not counted toward am1's cap; a can't-check ask is (am16 (5)).
|
|
213
213
|
* @param {ReturnType<typeof rowsFromAnswer>} rows
|
|
214
|
-
* @returns {{
|
|
214
|
+
* @returns {{line: number, rule: number, source: 'look', ask: 'check'|'no-check', ruleText: string, question: string, reading?: string, check?: Record<string, any>, counted: boolean}[]}
|
|
215
215
|
*/
|
|
216
216
|
export function checkAsks(rows) {
|
|
217
217
|
return rows.map((r) => {
|
|
218
|
-
const pair = typeof (/** @type {any} */ (r).pairRule) === 'number' ? { pairRule: /** @type {any} */ (r).pairRule } : {}; // M10 am21: the asked line is an edited added line
|
|
219
218
|
if (r.check === null) {
|
|
220
|
-
return {
|
|
219
|
+
return { line: r.line, rule: r.rule, source: 'look', ask: 'no-check', ruleText: r.text, counted: true, question: `Line ${r.line}, guardrail "${r.text}": ${CANT_CHECK_WORDS} ${HOW_TO_ANSWER(r.line, false)}` };
|
|
221
220
|
}
|
|
222
221
|
const words = plainWords(/** @type {any} */ (r.check));
|
|
223
|
-
return {
|
|
222
|
+
return { line: r.line, rule: r.rule, source: 'look', ask: 'check', ruleText: r.text, counted: false, reading: words, check: r.check, question: `Line ${r.line}, guardrail "${r.text}": I propose ${words}. ${HOW_TO_ANSWER(r.line, true)}` };
|
|
224
223
|
});
|
|
225
224
|
}
|
|
226
225
|
|
|
227
|
-
// ---- the
|
|
226
|
+
// ---- the shape of a pick (M10 am16); the plan's checks are built by the list (src/checkblock.js), not here -------------------------------------------------------------------------------------
|
|
228
227
|
/**
|
|
229
|
-
* @typedef {{line: number, rule: number, check: Record<string, any>|null,
|
|
230
|
-
* `check` = the check the person agreed to (null for their own words); `
|
|
228
|
+
* @typedef {{line: number, rule: number, check: Record<string, any>|null, own?: boolean}} Pick
|
|
229
|
+
* `check` = the check the person agreed to (null for their own words); `own` = their own words
|
|
231
230
|
*/
|
|
232
|
-
/**
|
|
233
|
-
* Settle every scoped rule against the person's answers: a rule with a picked check is checked; the `~` line an agree wrote is covered by that pick; every other
|
|
234
|
-
* rule is Not checked, with the reason (`person-left` = they chose it, `own-words` = they gave their own words, `no-pick` = nothing was picked).
|
|
235
|
-
* @param {ReturnType<typeof scopedRules>} rules @param {Pick[]} picks @param {{line: number, rule: number}[]} left
|
|
236
|
-
* @returns {{checks: Map<number, Record<string, any>[]>, notes: {line: number, rule: number, text: string, reason: 'person-left'|'own-words'|'no-pick'}[]}}
|
|
237
|
-
*/
|
|
238
|
-
export function settleRules(rules, picks, left) {
|
|
239
|
-
/** @type {Map<number, Record<string, any>[]>} */
|
|
240
|
-
const checks = new Map();
|
|
241
|
-
/** @type {{line: number, rule: number, text: string, reason: 'person-left'|'own-words'|'no-pick'}[]} */
|
|
242
|
-
const notes = [];
|
|
243
|
-
const sameText = (/** @type {string|undefined} */ a, /** @type {string} */ b) => typeof a === 'string' && norm(a) === norm(b);
|
|
244
|
-
for (const r of rules) {
|
|
245
|
-
const own = picks.find((p) => p.line === r.line && p.rule === r.rule);
|
|
246
|
-
if (own?.check) { checks.set(r.line, [...(checks.get(r.line) ?? []), own.check]); continue; }
|
|
247
|
-
if (picks.some((p) => p.check && p.line === r.line && sameText(p.added, r.text))) continue;
|
|
248
|
-
if (left.some((l) => l.line === r.line && l.rule === r.rule)) notes.push({ ...r, reason: 'person-left' });
|
|
249
|
-
else if (own?.own || picks.some((p) => !p.check && p.own && p.line === r.line && sameText(p.added, r.text))) notes.push({ ...r, reason: 'own-words' });
|
|
250
|
-
else notes.push({ ...r, reason: 'no-pick' });
|
|
251
|
-
}
|
|
252
|
-
return { checks, notes };
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* Overwrite the drafter's check on every step of a line this call settles (a green step, which another signed part settles, is left alone): a line with picked checks
|
|
257
|
-
* is softgreen and carries exactly those checks; a line with none is hitl. Whatever `close.shape` the drafter wrote is gone. Pure: returns a new declaration.
|
|
258
|
-
* @param {any} declaration @param {ReturnType<typeof scopedRules>} rules @param {ReturnType<typeof settleRules>} settled
|
|
259
|
-
* @param {(note: {line: number, reason: 'person-left'|'own-words'|'no-pick'}) => string} sentence the one table's words for a reason
|
|
260
|
-
*/
|
|
261
|
-
export function applyPicks(declaration, rules, settled, sentence) {
|
|
262
|
-
if (!declaration || !Array.isArray(declaration.steps)) return declaration;
|
|
263
|
-
const lineSet = new Set(rules.map((r) => r.line));
|
|
264
|
-
const green = (/** @type {number} */ n) => declaration.steps.some((/** @type {any} */ st) => st?.fromLine === n && st?.close?.class === 'green');
|
|
265
|
-
const mine = (/** @type {number} */ n) => lineSet.has(n) && !green(n);
|
|
266
|
-
const steps = declaration.steps.map((/** @type {any} */ st) => {
|
|
267
|
-
// M10 am22 (1): a fact line keeps its fact close and adds the person's picks to it (`close.picked`); the line stays green
|
|
268
|
-
if (st && typeof st === 'object' && lineSet.has(st.fromLine) && green(st.fromLine)) {
|
|
269
|
-
const { picked: _own, ...close } = st.close ?? {};
|
|
270
|
-
const kept = settled.checks.get(st.fromLine) ?? [];
|
|
271
|
-
return { ...st, close: kept.length && st.close?.class === 'green' ? { ...close, picked: kept } : close };
|
|
272
|
-
}
|
|
273
|
-
if (!st || typeof st !== 'object' || !mine(st.fromLine)) return st;
|
|
274
|
-
const picked = settled.checks.get(st.fromLine) ?? [];
|
|
275
|
-
return { ...st, close: picked.length ? { class: 'softgreen', shape: { picked } } : { class: 'hitl' } };
|
|
276
|
-
});
|
|
277
|
-
const out = { ...declaration, steps };
|
|
278
|
-
// M10 am22 (3): the record of the fact lines that carry the person's picks, written here and nowhere else; whatever the drafter sent for it is gone
|
|
279
|
-
const pickedLines = [...new Set(steps.filter((/** @type {any} */ st) => Array.isArray(st?.close?.picked) && st.close.class === 'green').map((/** @type {any} */ st) => st.fromLine))].sort((a, b) => a - b);
|
|
280
|
-
if (pickedLines.length) out.pickedLines = pickedLines; else delete out.pickedLines;
|
|
281
|
-
const isRec = (/** @type {unknown} */ v) => v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
282
|
-
if (isRec(declaration.guardrailClasses)) {
|
|
283
|
-
out.guardrailClasses = { ...declaration.guardrailClasses };
|
|
284
|
-
const un = isRec(declaration.unjudgeable) ? { ...declaration.unjudgeable } : {};
|
|
285
|
-
for (const n of lineSet) {
|
|
286
|
-
if (!mine(n) || !declaration.steps.some((/** @type {any} */ st) => st?.fromLine === n)) continue;
|
|
287
|
-
const has = (settled.checks.get(n) ?? []).length > 0;
|
|
288
|
-
out.guardrailClasses[String(n)] = has ? 'softgreen' : 'hitl';
|
|
289
|
-
if (has) delete un[String(n)];
|
|
290
|
-
else un[String(n)] = [...new Set(settled.notes.filter((x) => x.line === n).map(sentence))].join(' ') || 'No check was picked for it, so you judge it at the Ask.';
|
|
291
|
-
}
|
|
292
|
-
if (isRec(declaration.unjudgeable) || Object.keys(un).length) out.unjudgeable = un;
|
|
293
|
-
}
|
|
294
|
-
return out;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
231
|
// borrowed-from: bareloop src/checkpick.js@0408a8f (retentionOf, 890affa; adapted to fwdloop's one close per line: a unit is one cited fact of the line's step)
|
|
298
232
|
/**
|
|
299
233
|
* M10 am27 (4) RETENTION record of one draft (record only, counts, no words). Per job line: `aiParts` = the cited facts the drafter wrote on that line (a `cited` close counts once per
|