fwdloop 0.32.0 → 0.34.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/bin/fwdloop +20 -2
- package/package.json +2 -2
- package/src/auditchecks.js +55 -0
- package/src/authoring.js +53 -12
- package/src/blockasks.js +45 -0
- package/src/blockassemble.js +159 -0
- package/src/blockdraft.js +86 -0
- package/src/blocklines.js +30 -0
- package/src/blockpick.js +175 -0
- package/src/cardlist.js +19 -0
- package/src/checkblock.js +843 -0
- package/src/checked.js +48 -9
- package/src/checklist.js +99 -0
- package/src/checklistsign.js +93 -0
- package/src/checkpick.js +7 -73
- package/src/checkwords.js +20 -1
- package/src/cited-record.js +21 -1
- package/src/citedcheck.js +162 -7
- package/src/closers.js +41 -3
- package/src/declaration.js +34 -9
- package/src/declaredclose.js +4 -0
- package/src/draft-steps.js +3 -1
- package/src/drafter.js +311 -206
- package/src/factwords.js +112 -0
- package/src/inputlook.js +53 -0
- package/src/labelscan.js +162 -0
- package/src/noteask.js +62 -0
- package/src/pageask.js +9 -69
- package/src/pagedropwords.js +11 -1
- package/src/pagedry.js +27 -4
- package/src/pagerules.js +19 -3
- package/src/panel/author.js +76 -7
- package/src/panel/authorcard.js +43 -17
- package/src/panel/data.js +41 -9
- package/src/panel/index.html +208 -13
- package/src/panel/result.js +4 -3
- package/src/panel/server.js +3 -1
- package/src/pickrecord.js +70 -54
- package/src/placerule.js +398 -0
- package/src/planrebuild.js +216 -0
- package/src/rowedit.js +148 -0
- package/src/rubricstep.js +272 -0
- package/src/runfile.js +4 -2
- package/src/runner.js +67 -10
- package/src/setup.js +11 -5
- package/src/sheetblock.js +22 -8
- package/src/sheetbuild.js +151 -0
- package/src/sheetchecks.js +52 -66
- package/src/sheetclaims.js +12 -32
- package/src/sheetfind.js +4 -4
- package/src/sheetlook.js +14 -3
- package/src/sheetoffer.js +74 -57
- package/src/sheetrows.js +123 -0
- package/src/sheetrun.js +13 -10
- package/src/summary-words.js +3 -3
- package/src/ticket-draft.js +4 -21
- package/src/ticketrows.js +100 -0
- package/src/try-checks.js +31 -12
- package/src/types.js +1 -0
- package/types/auditchecks.d.ts +25 -0
- package/types/authoring.d.ts +21 -2
- package/types/blockasks.d.ts +36 -0
- package/types/blockassemble.d.ts +50 -0
- package/types/blockdraft.d.ts +75 -0
- package/types/blocklines.d.ts +31 -0
- package/types/blockpick.d.ts +46 -0
- package/types/cardlist.d.ts +21 -0
- package/types/checkblock.d.ts +378 -0
- package/types/checked.d.ts +16 -2
- package/types/checklist.d.ts +115 -0
- package/types/checklistsign.d.ts +27 -0
- package/types/checkpick.d.ts +4 -34
- package/types/checkwords.d.ts +5 -0
- package/types/cited-record.d.ts +9 -0
- package/types/citedcheck.d.ts +33 -2
- package/types/closers.d.ts +24 -2
- package/types/declaration.d.ts +7 -0
- package/types/declaredclose.d.ts +2 -0
- package/types/drafter.d.ts +29 -715
- package/types/factwords.d.ts +38 -0
- package/types/inputlook.d.ts +49 -0
- package/types/labelscan.d.ts +35 -0
- package/types/noteask.d.ts +52 -0
- package/types/pageask.d.ts +2 -35
- package/types/pagedry.d.ts +13 -0
- package/types/pagerules.d.ts +7 -0
- package/types/panel/author.d.ts +41 -0
- package/types/panel/authorcard.d.ts +14 -9
- package/types/panel/authorflows.d.ts +4 -4
- package/types/panel/data.d.ts +5 -3
- package/types/panel/jobgrid.d.ts +1 -1
- package/types/pickrecord.d.ts +69 -13
- package/types/placerule.d.ts +208 -0
- package/types/planrebuild.d.ts +52 -0
- package/types/provider.d.ts +1 -1
- package/types/rowedit.d.ts +48 -0
- package/types/rubricstep.d.ts +63 -0
- package/types/runfile.d.ts +5 -2
- package/types/runner.d.ts +45 -1
- package/types/sheetblock.d.ts +12 -4
- package/types/sheetbuild.d.ts +84 -0
- package/types/sheetchecks.d.ts +12 -18
- package/types/sheetclaims.d.ts +2 -1
- package/types/sheetfind.d.ts +2 -2
- package/types/sheetoffer.d.ts +31 -6
- package/types/sheetrows.d.ts +81 -0
- package/types/sheetrun.d.ts +4 -4
- package/types/summary-words.d.ts +2 -1
- package/types/ticket-draft.d.ts +3 -49
- package/types/ticketrows.d.ts +61 -0
- package/types/try-checks.d.ts +4 -2
- package/types/types.d.ts +8 -0
- package/src/repairs.js +0 -38
- package/types/repairs.d.ts +0 -13
package/src/checked.js
CHANGED
|
@@ -10,9 +10,15 @@
|
|
|
10
10
|
|
|
11
11
|
/** 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). */
|
|
12
12
|
export const NOT_CHECKED_LABEL = "not checked (the AI's own reading)";
|
|
13
|
+
/** 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 */
|
|
14
|
+
export const LIST_NOT_CHECKED_LABEL = 'Not checked';
|
|
15
|
+
/** the label that sits with a plan's Not checked list: a plan with a list says "Not checked", an older plan keeps the words it was signed with @param {any} declaration */
|
|
16
|
+
export const notCheckedLabelOf = (declaration) => (listLinesOf(declaration).size > 0 ? LIST_NOT_CHECKED_LABEL : NOT_CHECKED_LABEL);
|
|
13
17
|
|
|
14
|
-
import { factRows } from './citedcheck.js';
|
|
15
|
-
import { plainWords, labelled } from './checkwords.js';
|
|
18
|
+
import { factRows, factSentence, countSentence } from './citedcheck.js';
|
|
19
|
+
import { plainWords, labelled, tagged } from './checkwords.js';
|
|
20
|
+
import { listLinesOf, partByOf, factByOf, countByOf } from './checklistsign.js';
|
|
21
|
+
import { CARD_T } from './checkblock.js';
|
|
16
22
|
import { sheetCheckRows } from './sheetchecks.js';
|
|
17
23
|
import { sheetLineBlocks } from './sheetblock.js';
|
|
18
24
|
import { splitReadNotes, signedFactNames } from './pagedropwords.js';
|
|
@@ -30,7 +36,9 @@ const list = (xs) => xs.join(', ');
|
|
|
30
36
|
export function checkedLines(declaration, { hasAsk = true, askLines, lines, csvRoles = [], keptChecks = [], keptWords = '' } = {}) {
|
|
31
37
|
const blocks = Array.isArray(lines) ? sheetLineBlocks({ declaration, lines, csvRoles }) : [];
|
|
32
38
|
const steps = Array.isArray(declaration?.steps) ? declaration.steps : [];
|
|
39
|
+
const keptOf = (/** @type {number} */ line, /** @type {any} */ c) => (keptChecks.some((k) => k.line === line && plainWords(k.check) === plainWords(c)) ? ` (${keptWords})` : '');
|
|
33
40
|
if (Array.isArray(askLines)) hasAsk = askLines.length > 0;
|
|
41
|
+
const onList = listLinesOf(declaration); // M16: a line with a list shows each check with the tag of its row
|
|
34
42
|
const lastAsk = Array.isArray(askLines) ? steps.reduce((m, st, i) => (askLines.includes(st?.fromLine) ? i : m), -1) : -1;
|
|
35
43
|
return steps.map((st, i) => {
|
|
36
44
|
const cls = st?.close?.class;
|
|
@@ -39,7 +47,11 @@ export function checkedLines(declaration, { hasAsk = true, askLines, lines, csvR
|
|
|
39
47
|
const shape = st?.close?.shape && typeof st.close.shape === 'object' ? st.close.shape : {};
|
|
40
48
|
/** @type {string[]} */
|
|
41
49
|
const out = [];
|
|
42
|
-
|
|
50
|
+
const listed = onList.has(st?.fromLine);
|
|
51
|
+
if (listed && cls === 'green' && st.close.cited && typeof st.close.cited === 'object') {
|
|
52
|
+
// M16: a list line states the quote check's lead, then each check as a row with the tag of its own row (below)
|
|
53
|
+
out.push(`Each result must be quoted word for word from the saved page "${st.close.cited.source}", and the machine checks every quote, every value and the count against that copy.`);
|
|
54
|
+
} else if (cls === 'green' && st.close.cited && typeof st.close.cited === 'object') {
|
|
43
55
|
// M10 am7 item 1: the facts the drafter wrote, as plain rows written by code from the typed fields
|
|
44
56
|
out.push(`Each result must be quoted word for word from the saved page "${st.close.cited.source}", and the machine checks every quote, every value and the count against that copy.`, ...factRows(st.close.cited).map((r) => labelled(r, 'agent')));
|
|
45
57
|
} else if (cls === 'green' && Array.isArray(st.close.sheet)) {
|
|
@@ -55,13 +67,15 @@ export function checkedLines(declaration, { hasAsk = true, askLines, lines, csvR
|
|
|
55
67
|
if (Number.isInteger(shape.linesPerInvoice)) out.push(labelled(`The output comes in blocks of ${shape.linesPerInvoice} lines.`, 'agent'));
|
|
56
68
|
if (Array.isArray(shape.mustCarry) && shape.mustCarry.length > 0) out.push(labelled(`Every block carries: ${list(shape.mustCarry)}.`, 'agent'));
|
|
57
69
|
// M10 am16: each check the person picked, in the words it was picked in (src/checkwords.js, the one place)
|
|
58
|
-
if (Array.isArray(shape.picked)) for (const c of shape.picked) out.push(labelled(`You picked: ${plainWords(c)}.${
|
|
70
|
+
if (!listed && Array.isArray(shape.picked)) for (const c of shape.picked) out.push(labelled(`You picked: ${plainWords(c)}.${keptOf(st.fromLine, c)}`, 'picked'));
|
|
59
71
|
} else {
|
|
60
72
|
if (lastAsk !== -1 && i > lastAsk) out.push('No machine check of the content; you check it after you accept.');
|
|
61
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.');
|
|
62
74
|
}
|
|
63
75
|
// M10 am22 (1)(4): the checks the person picked for a fact line, beside its fact rows
|
|
64
|
-
if (cls === 'green' && Array.isArray(st.close.picked)) for (const c of st.close.picked) out.push(labelled(`You picked: ${plainWords(c)}.${
|
|
76
|
+
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'));
|
|
77
|
+
// M16 item 5: the checks of a list line, one tagged sentence each, from the rows' own reader
|
|
78
|
+
if (listed) out.push(...listPartRows(declaration, st, keptOf).map((r) => tagged(r.text, r.by)));
|
|
65
79
|
return {
|
|
66
80
|
step: i + 1, line: Number.isInteger(st?.fromLine) ? st.fromLine : null, goal: typeof st?.goal === 'string' ? st.goal : '', class: String(cls), sentences: out,
|
|
67
81
|
...(sheet && cls === 'green' ? { sheet } : {}),
|
|
@@ -69,10 +83,10 @@ export function checkedLines(declaration, { hasAsk = true, askLines, lines, csvR
|
|
|
69
83
|
});
|
|
70
84
|
}
|
|
71
85
|
|
|
72
|
-
/** 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 */
|
|
73
|
-
export function notCheckedBlock(items) {
|
|
86
|
+
/** 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] */
|
|
87
|
+
export function notCheckedBlock(items, label = NOT_CHECKED_LABEL) {
|
|
74
88
|
const clean = Array.isArray(items) ? items.filter((x) => typeof x === 'string' && x.trim() !== '').map((x) => x.trim()) : [];
|
|
75
|
-
return { label
|
|
89
|
+
return { label, items: clean };
|
|
76
90
|
}
|
|
77
91
|
|
|
78
92
|
/**
|
|
@@ -81,7 +95,32 @@ export function notCheckedBlock(items) {
|
|
|
81
95
|
* @param {unknown} items @param {any} declaration the plan's declaration (its cited facts are the signed ones)
|
|
82
96
|
*/
|
|
83
97
|
export function notCheckedView(items, declaration) {
|
|
84
|
-
const block = notCheckedBlock(items);
|
|
98
|
+
const block = notCheckedBlock(items, notCheckedLabelOf(declaration));
|
|
85
99
|
const { notChecked, readNotes } = splitReadNotes(block.items, signedFactNames(declaration));
|
|
86
100
|
return { label: block.label, items: notChecked, readNotes };
|
|
87
101
|
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* 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.
|
|
105
|
+
* 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.
|
|
106
|
+
* @param {any} declaration @param {any} st the step @param {(line: number, c: any) => string} [keptOf]
|
|
107
|
+
* @returns {{text: string, by: 'you'|'agent'|'default', part: number}[]}
|
|
108
|
+
*/
|
|
109
|
+
export function listPartRows(declaration, st, keptOf = () => '') {
|
|
110
|
+
const close = st?.close && typeof st.close === 'object' ? st.close : {};
|
|
111
|
+
const line = st?.fromLine;
|
|
112
|
+
/** @type {{text: string, by: 'you'|'agent'|'default', part: number}[]} */
|
|
113
|
+
const out = [];
|
|
114
|
+
let idx = 0;
|
|
115
|
+
if (close.cited && typeof close.cited === 'object') {
|
|
116
|
+
const c = close.cited;
|
|
117
|
+
for (const f of Array.isArray(c.facts) ? c.facts : []) out.push({ text: factSentence(f, c.source), by: factByOf(declaration, line, f.name) ?? 'agent', part: idx });
|
|
118
|
+
const count = countSentence(c);
|
|
119
|
+
if (count) out.push({ text: count, by: countByOf(declaration, line) ?? 'agent', part: idx });
|
|
120
|
+
idx += 1;
|
|
121
|
+
}
|
|
122
|
+
const picked = Array.isArray(close.picked) ? close.picked : Array.isArray(close.shape?.picked) ? close.shape.picked : [];
|
|
123
|
+
for (const c of picked) { out.push({ text: `${plainWords(c)}.${keptOf(line, c)}`, by: partByOf(declaration, line, idx) ?? 'agent', part: idx }); idx += 1; }
|
|
124
|
+
if (Array.isArray(close.numbersFrom) && close.numbersFrom.length > 0) out.push({ text: `${CARD_T.numbers} ${close.numbersFrom.join(', ')}.`, by: partByOf(declaration, line, idx) ?? 'default', part: idx });
|
|
125
|
+
return out;
|
|
126
|
+
}
|
package/src/checklist.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// borrowed-from: bareloop src/checklist.js@v0.56.0 (3383cce) (the row vocabulary, weekOnly/weekTokens with the three month patterns written as literals, ledgerRecord and the list call's text and schema; the paid call runLedgerSuggest is NOT taken: it runs over bareloop's askStructured and makeCostBook (src/authorflow.js, which need src/text.js), and fwd meters its own calls)
|
|
2
|
+
// THE ROW VOCABULARY of a rubric job's one check list, and the call that suggests extra `!` checks. The list itself is the CheckBlock (src/checkblock.js): every check the job can have is a row there.
|
|
3
|
+
// `~` rows the person's own rules (by: you; a settled pick builds the rule's check)
|
|
4
|
+
// `!` rows checks the agent suggests once, only from what it sees in the inputs (by: agent): the look's kept facts that carry no `~` rule, plus the call's own
|
|
5
|
+
// proposals (count, phrase). Code proves a word-bearing `!` row against the input text, else drops it with a reason. A `~` always wins over a `!` on the same thing.
|
|
6
|
+
// `$` rows default checks code adds itself (by: default): every claim quotes the input (a text line with one input), the numbers tie (a text line after a fact line);
|
|
7
|
+
// the mechanical floor (file exists, text not empty) is shown as a `$` row but is never counted as a check.
|
|
8
|
+
// Nothing here decides a verdict; the list says what the drafter may build, and code builds the rest.
|
|
9
|
+
import { lineRules } from './pagebits.js';
|
|
10
|
+
|
|
11
|
+
/** at most this many `!` checks come from the call */
|
|
12
|
+
export const MAX_BANG = 3;
|
|
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
|
+
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
|
+
export const LEDGER_TOOL = 'suggest_extra_checks';
|
|
18
|
+
/** how much of each input the call is shown */
|
|
19
|
+
const SHOWN_CHARS = 8000;
|
|
20
|
+
/** the reason the empty list is logged with */
|
|
21
|
+
export const EMPTY_LIST_WORDS = 'empty list: nothing to check';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 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
|
|
25
|
+
* 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.
|
|
26
|
+
* @param {unknown} t @returns {boolean}
|
|
27
|
+
*/
|
|
28
|
+
export function weekOnly(t) {
|
|
29
|
+
return weekTokens(t).length > 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The version-like and date-like tokens a text holds (the very tokens {@link weekOnly} reads), each once. Pure.
|
|
34
|
+
* @param {unknown} t @returns {string[]}
|
|
35
|
+
*/
|
|
36
|
+
export function weekTokens(t) {
|
|
37
|
+
const s = String(t ?? '');
|
|
38
|
+
const res = [/(?<![\d.$€£])\d+\.\d+(?:\.\d+)*(?![\d.]*%)/g, /\b\d{4}-\d{2}-\d{2}\b/g, /\b\d{1,2}[/.]\d{1,2}[/.]\d{2,4}\b/g,
|
|
39
|
+
/\b(?:jan(?:uary)?|feb(?:ruary)?|mar(?:ch)?|apr(?:il)?|may|jun(?:e)?|jul(?:y)?|aug(?:ust)?|sep(?:t(?:ember)?)?|oct(?:ober)?|nov(?:ember)?|dec(?:ember)?)\.? \d{1,2}(?:st|nd|rd|th)?(?:,? \d{4})?\b/gi, /\b\d{1,2}(?:st|nd|rd|th)? (?:jan(?:uary)?|feb(?:ruary)?|mar(?:ch)?|apr(?:il)?|may|jun(?:e)?|jul(?:y)?|aug(?:ust)?|sep(?:t(?:ember)?)?|oct(?:ober)?|nov(?:ember)?|dec(?:ember)?)\.?(?: \d{4})?\b/gi, /\b(?:jan(?:uary)?|feb(?:ruary)?|mar(?:ch)?|apr(?:il)?|may|jun(?:e)?|jul(?:y)?|aug(?:ust)?|sep(?:t(?:ember)?)?|oct(?:ober)?|nov(?:ember)?|dec(?:ember)?)\.? \d{4}\b/gi];
|
|
40
|
+
return [...new Set(res.flatMap((re) => [...s.matchAll(re)].map((m) => m[0])))];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @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
|
+
* words: string[], text?: string, rule?: number, part?: {line: number, part: number}, source?: string, name?: string, min?: number, max?: number, pick?: string, after?: number[],
|
|
46
|
+
* state: 'listed'|'built'|'not-checked'|'dropped', reason: string|null, forRule?: number, reading?: import('./pagerules.js').Reading}} Row
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
/** an empty list (no row that stands but the floor) is said so, never left as no record at all @param {Row[]} rows @returns {boolean} */
|
|
50
|
+
export const isEmptyList = (rows) => !rows.some((r) => r.kind !== 'floor' && r.state !== 'dropped');
|
|
51
|
+
|
|
52
|
+
/** the record the draft log keeps, one object per row (key, line, rowKind, from, by, words, state, reason), plus ONE explicit record when nothing stands @param {Row[]} rows */
|
|
53
|
+
export const ledgerRecord = (rows) => [
|
|
54
|
+
...rows.map((r) => ({ key: r.key, line: r.line, rowKind: r.kind, from: r.from, by: r.by, words: r.kind === 'rule' ? [r.text ?? ''] : r.words, state: r.state, reason: r.reason })),
|
|
55
|
+
...(isEmptyList(rows) ? [{ key: 'empty', line: 0, rowKind: 'empty', from: 'default', by: 'default', words: [], state: 'empty', reason: EMPTY_LIST_WORDS }] : []),
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
// ---- the one paid call ---------------------------------------------------------------------------------------------------------------------
|
|
59
|
+
/** the list call's own system text (model-facing; used only by the list call of a rubric job with input text) */
|
|
60
|
+
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.
|
|
61
|
+
Call ${LEDGER_TOOL} once with up to ${MAX_BANG} entries, or with an empty list.
|
|
62
|
+
- kind "count": how many results the input shows or the job asks for (min and/or max, whole numbers).
|
|
63
|
+
- kind "phrase": fixed words copied verbatim from an input (phrase, and source = that input's label).
|
|
64
|
+
Use 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.`;
|
|
65
|
+
|
|
66
|
+
export const LEDGER_SCHEMA = Object.freeze({
|
|
67
|
+
type: 'object',
|
|
68
|
+
properties: {
|
|
69
|
+
extra: {
|
|
70
|
+
type: 'array', maxItems: MAX_BANG,
|
|
71
|
+
items: {
|
|
72
|
+
type: 'object',
|
|
73
|
+
properties: {
|
|
74
|
+
line: { type: 'integer', minimum: 1, description: 'the job line number' },
|
|
75
|
+
kind: { enum: ['count', 'phrase'] },
|
|
76
|
+
source: { type: 'string', description: 'the label of the input' },
|
|
77
|
+
phrase: { type: 'string', description: 'phrase only: words copied verbatim from the input' },
|
|
78
|
+
min: { type: 'integer', minimum: 1 },
|
|
79
|
+
max: { type: 'integer', minimum: 1 },
|
|
80
|
+
},
|
|
81
|
+
required: ['line', 'kind'],
|
|
82
|
+
additionalProperties: false,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
required: ['extra'],
|
|
87
|
+
additionalProperties: false,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
/** @param {{n: number, text: string, rules?: string[], rule?: string}[]} jobLines @param {Record<string, string>} texts @returns {string} */
|
|
91
|
+
export function ledgerUserText(jobLines, texts) {
|
|
92
|
+
const out = ['The job:'];
|
|
93
|
+
for (const l of jobLines) {
|
|
94
|
+
out.push(`${l.n}. ${l.text}`);
|
|
95
|
+
lineRules(l).forEach((r, i) => out.push(` g${i + 1}: ${r}`));
|
|
96
|
+
}
|
|
97
|
+
for (const [label, t] of Object.entries(texts)) out.push('', `Input "${label}":`, String(t).slice(0, SHOWN_CHARS));
|
|
98
|
+
return out.join('\n');
|
|
99
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// M16 (docs/wiki/the-module-ladder.md, "M16" item 2, "a check that reaches the plan is not on the list"): the sign-time and run-start proof that the checks of a plan's list lines are the list's.
|
|
2
|
+
// Equivalent of bareloop src/rubricstep.js@v0.56.0 (3383cce) `listMatchesClose`, read over fwdloop's close fields instead of a rubric-step stage: the checks of one line, in the order the check block
|
|
3
|
+
// builds them, are [close.cited (the fact part)], then each entry of close.picked / close.shape.picked, then close.numbersFrom (the numbers tie). A signed row points at one of them by `part: {line, part: <index>}`.
|
|
4
|
+
|
|
5
|
+
const isRec = (/** @type {unknown} */ v) => v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 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.
|
|
9
|
+
* @param {any} step @param {boolean} [withSheet] @returns {{what: string}[]}
|
|
10
|
+
*/
|
|
11
|
+
export function closePartsOf(step, withSheet = false) {
|
|
12
|
+
const close = isRec(step) && isRec(step.close) ? step.close : {};
|
|
13
|
+
/** @type {{what: string}[]} */
|
|
14
|
+
const parts = [];
|
|
15
|
+
if (isRec(close.cited)) parts.push({ what: 'the quote check (close.cited)' });
|
|
16
|
+
const picked = Array.isArray(close.picked) ? close.picked : isRec(close.shape) && Array.isArray(close.shape.picked) ? close.shape.picked : [];
|
|
17
|
+
picked.forEach((/** @type {unknown} */ _c, /** @type {number} */ i) => parts.push({ what: `the picked check ${i + 1} (close.picked)` }));
|
|
18
|
+
if (Array.isArray(close.numbersFrom) && close.numbersFrom.length > 0) parts.push({ what: 'the numbers tie (close.numbersFrom)' });
|
|
19
|
+
if (withSheet && Array.isArray(close.sheet)) close.sheet.forEach((/** @type {any} */ c) => parts.push({ what: `the sheet check ${isRec(c) ? String(c.id) : '?'} (close.sheet)` }));
|
|
20
|
+
return parts;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 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
|
|
25
|
+
* 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.
|
|
26
|
+
* @param {any} declaration @returns {string[]}
|
|
27
|
+
*/
|
|
28
|
+
export function checkListReds(declaration) {
|
|
29
|
+
if (!isRec(declaration) || declaration.checkList === undefined) return [];
|
|
30
|
+
const list = declaration.checkList;
|
|
31
|
+
if (!Array.isArray(list) || !list.every(isRec)) return ['declaration: "checkList" must be a list of rows'];
|
|
32
|
+
const steps = Array.isArray(declaration.steps) ? declaration.steps.filter(isRec) : [];
|
|
33
|
+
// M16 am4: a plan whose list has sheet rows is held to them for EVERY sheet check of its steps (a plan from before am4 has none: its sheet lines are not examined, as before)
|
|
34
|
+
const sheetListed = list.some((r) => r.kind === 'sheet');
|
|
35
|
+
const sheetLines = sheetListed ? steps.filter((st) => isRec(st.close) && Array.isArray(st.close.sheet) && st.close.sheet.length > 0 && Number.isInteger(st.fromLine)).map((st) => /** @type {number} */ (st.fromLine)) : [];
|
|
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
|
+
const stepsOn = (/** @type {number} */ n) => steps.filter((st) => st.fromLine === n);
|
|
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' && r.kind !== 'ticket');
|
|
40
|
+
/** @type {string[]} */
|
|
41
|
+
const reds = [];
|
|
42
|
+
for (const r of built) {
|
|
43
|
+
const ok = isRec(r.part) && r.part.line === r.line && Number.isInteger(r.part.part) && r.part.part >= 0 && r.part.part < partsOn(/** @type {number} */ (r.line)).length;
|
|
44
|
+
if (!ok) reds.push(`declaration: checkList line ${r.line}: a row points at a check the close does not run (${String(r.key)}). Nothing was signed - draft again.`);
|
|
45
|
+
}
|
|
46
|
+
for (const n of lines) {
|
|
47
|
+
partsOn(n).forEach((p, i) => {
|
|
48
|
+
if (!built.some((r) => isRec(r.part) && r.part.line === n && r.part.part === i)) reds.push(`declaration: checkList line ${n}: ${p.what} is in the close but has no row on the list. Nothing was signed - draft again.`);
|
|
49
|
+
});
|
|
50
|
+
for (const st of stepsOn(n)) {
|
|
51
|
+
const shape = isRec(st.close) && isRec(st.close.shape) ? st.close.shape : {};
|
|
52
|
+
for (const k of Object.keys(shape)) if (k !== 'picked') reds.push(`declaration: checkList line ${n}: close.shape.${k} is a check that is not on the list. Nothing was signed - draft again.`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return reds;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** 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>} */
|
|
59
|
+
export function listLinesOf(declaration) {
|
|
60
|
+
const list = isRec(declaration) && Array.isArray(declaration.checkList) ? declaration.checkList : [];
|
|
61
|
+
return new Set(list.filter((r) => isRec(r) && Number.isInteger(r.line) && r.kind !== 'sheet').map((r) => /** @type {number} */ (r.line)));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** 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>} */
|
|
65
|
+
export function cardLinesOf(declaration) {
|
|
66
|
+
const list = isRec(declaration) && Array.isArray(declaration.checkList) ? declaration.checkList : [];
|
|
67
|
+
return new Set(list.filter((r) => isRec(r) && Number.isInteger(r.line)).map((r) => /** @type {number} */ (r.line)));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** the built rows of the list on one line, the floor aside @param {any} declaration @param {number} line */
|
|
71
|
+
const builtOn = (declaration, line) => (isRec(declaration) && Array.isArray(declaration.checkList) ? declaration.checkList : []).filter((r) => isRec(r) && r.line === line && r.state === 'built' && r.kind !== 'floor');
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 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.
|
|
75
|
+
* 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.
|
|
76
|
+
* @param {any} declaration @param {number} line @param {number} idx @returns {'you'|'agent'|'default'|null}
|
|
77
|
+
*/
|
|
78
|
+
export function partByOf(declaration, line, idx) {
|
|
79
|
+
const r = builtOn(declaration, line).find((x) => isRec(x.part) && x.part.part === idx);
|
|
80
|
+
return r && (r.by === 'you' || r.by === 'agent' || r.by === 'default') ? r.by : null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** 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} */
|
|
84
|
+
export function factByOf(declaration, line, name) {
|
|
85
|
+
const r = builtOn(declaration, line).find((x) => Array.isArray(x.facts) && x.facts.includes(name));
|
|
86
|
+
return r && (r.by === 'you' || r.by === 'agent' || r.by === 'default') ? r.by : null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** 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} */
|
|
90
|
+
export function countByOf(declaration, line) {
|
|
91
|
+
const r = builtOn(declaration, line).find((x) => x.kind === 'count');
|
|
92
|
+
return r && (r.by === 'you' || r.by === 'agent' || r.by === 'default') ? r.by : null;
|
|
93
|
+
}
|
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
|
package/src/checkwords.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// M10 amendment 16: the ONE place a picked check is put in plain words (one fixed phrase per bareguard rule, written by code). The ask, the `~` line an agree writes,
|
|
2
2
|
// the plan card (src/checked.js), the softgreen close's check list (src/closers.js) and the Audit all read it; nothing else writes these words.
|
|
3
3
|
/** the rules of bareguard's list a person may pick here (text rules only: the ones a plain answer can be judged by) */
|
|
4
|
-
export const OFFERED = Object.freeze(['nonEmpty', 'maxWords', 'minWords', 'maxLines', 'listItems', 'sections', 'sectionOrder', 'sectionWords', 'mustCarry', 'blockLines']);
|
|
4
|
+
export const OFFERED = Object.freeze(['nonEmpty', 'maxWords', 'minWords', 'maxLines', 'listItems', 'maxListItems', 'minListItems', 'sections', 'sectionOrder', 'sectionWords', 'mustCarry', 'blockLines']);
|
|
5
5
|
/** M10 am22 (4): who added a check, the ONE place these two words live. The plan card, the Job tab and the Audit trail write them after the check's words. */
|
|
6
6
|
export const LABEL_AGENT = '[agent]';
|
|
7
7
|
export const LABEL_PICKED = '[you picked]';
|
|
@@ -19,6 +19,9 @@ export function plainWords(c) {
|
|
|
19
19
|
case 'minWords': return `at least ${c.value} words`;
|
|
20
20
|
case 'maxLines': return `at most ${c.value} lines`;
|
|
21
21
|
case 'listItems': return `exactly ${c.value} list items`;
|
|
22
|
+
// borrowed-from: bareloop src/checkwords.js@v0.56.0 (3383cce) (maxListItems, minListItems: bareguard 0.35)
|
|
23
|
+
case 'maxListItems': return `at most ${c.value} list items`;
|
|
24
|
+
case 'minListItems': return `at least ${c.value} list items`;
|
|
22
25
|
case 'sections': return `sections named ${listOf(c.names ?? [])}`;
|
|
23
26
|
case 'sectionOrder': return `sections named ${listOf(c.names ?? [])}, in that order`;
|
|
24
27
|
case 'sectionWords': return `sections named ${listOf(c.names ?? [])}, each about ${c.wordsPerSection} words`;
|
|
@@ -27,3 +30,19 @@ export function plainWords(c) {
|
|
|
27
30
|
default: return `a ${c.rule} check`;
|
|
28
31
|
}
|
|
29
32
|
}
|
|
33
|
+
|
|
34
|
+
// M16 item 5 (docs/wiki/the-module-ladder.md, "M16"): the tag of a check on a list line is the `by` of its row, one spelling here for the readout, the plan card, the Audit and the Job tab
|
|
35
|
+
// (replaces M10 am22 (4)'s `[you picked]` for list lines only; a sheet row keeps `labelled`).
|
|
36
|
+
/** @type {Readonly<Record<string, string>>} */
|
|
37
|
+
export const TAG = Object.freeze({ you: '[you]', agent: '[agent]', default: '[default]' });
|
|
38
|
+
/** @param {unknown} by @returns {string} the tag of a row by `you` / `agent` / `default`, '' for anything else */
|
|
39
|
+
export const tagOf = (by) => (typeof by === 'string' && Object.hasOwn(TAG, by) ? TAG[by] : '');
|
|
40
|
+
/** @param {string} text @param {unknown} by */
|
|
41
|
+
export const tagged = (text, by) => (tagOf(by) === '' ? text : `${text} ${tagOf(by)}`);
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* hamr 2026-11-14: ~ = [you], ! = [agent], $ = [default]. Where a SHEET check comes from, the ONE rule (the plan card's rows, the Job tab, the Audit, the Result tab and the signed readout all read it):
|
|
45
|
+
* a check whose `covers` names one of the person's `~` rules is `you`, a check that covers none (the AI added it) is `agent`; no code adds a `default` sheet check.
|
|
46
|
+
* @param {unknown[]} covers the person's rules the check covers @returns {'you'|'agent'}
|
|
47
|
+
*/
|
|
48
|
+
export const sheetByOf = (covers) => (Array.isArray(covers) && covers.length > 0 ? 'you' : 'agent');
|
package/src/cited-record.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// Extra keys the reader ignores and the separate checker (scripts/check-cited-run.mjs) reads: per line `check` {sha256 of the frozen text, the signed facts,
|
|
8
8
|
// the count} and per row `values`.
|
|
9
9
|
// Throws away: bareguard's evidence beyond the marks of the claim's own spans; nothing: a red line keeps its judged rows (am9); only a stopped check has none.
|
|
10
|
-
import { writeLineSection } from './line-checks.js';
|
|
10
|
+
import { writeLineSection, readLineSection } from './line-checks.js';
|
|
11
11
|
import { moneyAs } from './pageask.js';
|
|
12
12
|
import { factSentence, countSentence, CITED_ID } from './citedcheck.js';
|
|
13
13
|
|
|
@@ -117,3 +117,23 @@ export function citedLineOf({
|
|
|
117
117
|
export function writeCitedLine(runDir, line) {
|
|
118
118
|
writeLineSection(runDir, 'cited', (had) => [...had.filter((/** @type {any} */ l) => isRec(l) && l.n !== line.n), line].sort((a, b) => a.n - b.n));
|
|
119
119
|
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* 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
|
|
123
|
+
* 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.
|
|
124
|
+
* @param {string} runDir @param {number[]} from @returns {{quotes: Record<string, string[]>, missing: number[]}}
|
|
125
|
+
*/
|
|
126
|
+
export function quotesOfLines(runDir, from) {
|
|
127
|
+
const sec = readLineSection(runDir, 'cited');
|
|
128
|
+
const lines = sec.ok ? sec.lines : [];
|
|
129
|
+
/** @type {Record<string, string[]>} */
|
|
130
|
+
const quotes = {};
|
|
131
|
+
/** @type {number[]} */
|
|
132
|
+
const missing = [];
|
|
133
|
+
for (const n of from) {
|
|
134
|
+
const l = lines.find((/** @type {any} */ x) => isRec(x) && x.n === n && x.passed === true && Array.isArray(x.rows));
|
|
135
|
+
if (l) quotes[String(n)] = l.rows.map((/** @type {any} */ r) => (isRec(r) && typeof r.quote === 'string' ? r.quote : '')).filter((/** @type {string} */ q) => q !== '');
|
|
136
|
+
else missing.push(n);
|
|
137
|
+
}
|
|
138
|
+
return { quotes, missing };
|
|
139
|
+
}
|