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/citedcheck.js
CHANGED
|
@@ -18,6 +18,7 @@ import { createRubric, checkStep } from 'bareguard';
|
|
|
18
18
|
import { plainWords } from './checkwords.js';
|
|
19
19
|
import { asList, FACT_OPS, boundOk, MAX_CURRENCIES, MAX_UNITS, MAX_UNIT_CHARS } from './pagebits.js';
|
|
20
20
|
import { ruleWords, moneyAs } from './pageask.js';
|
|
21
|
+
import { placeRuleProblem } from './placerule.js';
|
|
21
22
|
|
|
22
23
|
/** the shapes a fact may have (bareguard's value kinds, plus `phrase` = a presence decide) */
|
|
23
24
|
export const FACT_SHAPES = Object.freeze(['money', 'number', 'date', 'time', 'phrase', 'text']);
|
|
@@ -29,7 +30,8 @@ export const CITED_ID = 'facts';
|
|
|
29
30
|
|
|
30
31
|
/** every field a fact part may carry, and every field a fact may carry */
|
|
31
32
|
const PART_FIELDS = Object.freeze(['source', 'facts', 'count']);
|
|
32
|
-
|
|
33
|
+
// borrowed-from: bareloop src/facts.js@v0.56.0 (3383cce) (M16 am3 (3): the fields lang, decimal, place, aiProposal; FACT_LANGS, FACT_DECIMALS, moneyForms, factPartOf, factShapeReds, writtenSpans below; factDecides, factClaims, factSentence taken up to it)
|
|
34
|
+
const FACT_FIELDS = Object.freeze(['name', 'shape', 'unit', 'currency', 'phrase', 'anchor', 'until', 'rule', 'aiProposal', 'lang', 'decimal', 'place']);
|
|
33
35
|
const NAME_RE = /^[A-Za-z][A-Za-z _-]{0,63}$/;
|
|
34
36
|
|
|
35
37
|
const isRec = (/** @type {unknown} */ v) => v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
@@ -102,6 +104,11 @@ export function factPartReds(part) {
|
|
|
102
104
|
if (f.shape !== 'money' && (f.unit !== undefined || f.currency !== undefined)) reds.push(`${w} "${f.name}": only money has a unit or a currency`);
|
|
103
105
|
if (f.shape === 'phrase') for (const k of ['anchor', 'until', 'rule']) if (f[k] !== undefined) reds.push(`${w} "${f.name}": a phrase is fixed words the quote must contain; it has no ${k}`);
|
|
104
106
|
if (f.shape !== 'phrase' && f.phrase !== undefined) reds.push(`${w} "${f.name}": only a phrase fact carries phrase`);
|
|
107
|
+
// the four fields of bareloop v0.56.0 (M16 am3 (3)); each is checked only when present, so a fact without them is judged exactly as before
|
|
108
|
+
if (f.lang !== undefined && (f.shape !== 'date' || typeof f.lang !== 'string' || !Object.hasOwn(FACT_LANGS, f.lang))) reds.push(`${w} "${f.name}": lang is for a date fact, one of ${Object.keys(FACT_LANGS).join(', ')}`);
|
|
109
|
+
if (f.decimal !== undefined && ((f.shape !== 'number' && f.shape !== 'money') || !FACT_DECIMALS.includes(f.decimal))) reds.push(`${w} "${f.name}": decimal is for a number or money fact, "." or ","`);
|
|
110
|
+
if (f.place !== undefined) { const bad = f.shape === 'phrase' ? placeRuleProblem(f.place) : 'only a phrase fact carries a place rule'; if (bad !== null) reds.push(`${w} "${f.name}": ${bad}`); }
|
|
111
|
+
if (f.aiProposal !== undefined && typeof f.aiProposal !== 'boolean') reds.push(`${w} "${f.name}": aiProposal is true or false`);
|
|
105
112
|
if (f.until !== undefined && (f.anchor === undefined || f.shape !== 'text')) reds.push(`${w} "${f.name}": until closes a text fact that has an anchor, and nothing else`);
|
|
106
113
|
if (asList(f.currency).length > MAX_CURRENCIES) reds.push(`${w} "${f.name}": at most ${MAX_CURRENCIES} currencies`);
|
|
107
114
|
if (asList(f.unit).length > MAX_UNITS || asList(f.unit).some((u) => u.length > MAX_UNIT_CHARS)) reds.push(`${w} "${f.name}": at most ${MAX_UNITS} units of ${MAX_UNIT_CHARS} characters`);
|
|
@@ -132,6 +139,8 @@ export function factDecides(part) {
|
|
|
132
139
|
const d = { valueKind: f.shape };
|
|
133
140
|
if (f.shape === 'money') { if (f.unit !== undefined) d.unit = f.unit; if (f.currency !== undefined) d.currency = f.currency; }
|
|
134
141
|
if (f.anchor !== undefined) d.anchor = f.anchor;
|
|
142
|
+
if (f.lang !== undefined) d.lang = f.lang;
|
|
143
|
+
if (f.decimal !== undefined) d.decimal = f.decimal;
|
|
135
144
|
if (f.until !== undefined) d.until = f.until;
|
|
136
145
|
if (f.rule) {
|
|
137
146
|
d.op = f.rule.op;
|
|
@@ -145,11 +154,12 @@ export function factDecides(part) {
|
|
|
145
154
|
* The claims bareguard reads, built from the step's `results`. The claim TEXT is written here from the values the step gave (`name: value; name: value`),
|
|
146
155
|
* a phrase fact contributes its own signed words. A result that is not an object, or has no string quote, still becomes a claim (an empty one) so
|
|
147
156
|
* bareguard reds it by name rather than the result vanishing.
|
|
148
|
-
*
|
|
157
|
+
* `asWritten` (bareloop v0.56.0): per result, per fact index, the value as the page writes it, for the claim's words of a date or amount a page form signs.
|
|
158
|
+
* @param {any} part @param {unknown} results @param {Record<number, string>[]} [asWritten] @returns {{claim: string, quote: string, values?: Record<string, string>}[]}
|
|
149
159
|
*/
|
|
150
|
-
export function factClaims(part, results) {
|
|
160
|
+
export function factClaims(part, results, asWritten = []) {
|
|
151
161
|
const list = Array.isArray(results) ? results : [];
|
|
152
|
-
return list.map((/** @type {any} */ r) => {
|
|
162
|
+
return list.map((/** @type {any} */ r, /** @type {number} */ i) => {
|
|
153
163
|
const given = isRec(r) && isRec(r.values) ? r.values : null;
|
|
154
164
|
/** @type {Record<string, any>} */
|
|
155
165
|
const values = {};
|
|
@@ -160,7 +170,7 @@ export function factClaims(part, results) {
|
|
|
160
170
|
const v = given && Object.hasOwn(given, f.name) ? given[f.name] : undefined;
|
|
161
171
|
// a JSON number is the value as written ("389"): converted, never repaired; anything else is left for bareguard to red
|
|
162
172
|
const s = typeof v === 'number' && Number.isFinite(v) ? String(v) : v;
|
|
163
|
-
if (typeof s === 'string') { values[`d${j}`] = s; said.push(`${f.name}: ${s}`); } else if (s !== undefined) values[`d${j}`] = s;
|
|
173
|
+
if (typeof s === 'string') { values[`d${j}`] = s; said.push(`${f.name}: ${asWritten[i]?.[j] ?? s}`); } else if (s !== undefined) values[`d${j}`] = s;
|
|
164
174
|
});
|
|
165
175
|
return { claim: said.join('; '), quote: isRec(r) && typeof r.quote === 'string' ? r.quote : '', values };
|
|
166
176
|
});
|
|
@@ -184,19 +194,164 @@ export function buildCitedSpec(part, sha256) {
|
|
|
184
194
|
* @param {any} f @param {string} source @returns {string}
|
|
185
195
|
*/
|
|
186
196
|
export function factSentence(f, source) {
|
|
197
|
+
// PLACE RULES (v0.56.0): a check that reads WHERE the newest value sits, not what it is; the phrase shown is the signed drafting example
|
|
198
|
+
if (f.shape === 'phrase' && isRec(f.place)) return `${f.place.kind === 'headingDateAfter' ? 'date' : 'version'} in the newest "${f.place.prefix}" heading (last read ${f.phrase})`;
|
|
187
199
|
/** @type {string[]} */
|
|
188
200
|
const bits = [];
|
|
189
201
|
if (f.shape === 'phrase') bits.push('phrase', `must say "${f.phrase}"`);
|
|
190
202
|
else {
|
|
191
|
-
bits.push(f.shape === 'money' ? `money in ${
|
|
203
|
+
bits.push(f.shape === 'money' ? `money in ${moneyForms(f).join(' or ')}` : f.shape);
|
|
204
|
+
if (f.lang !== undefined) bits.push(`month names in ${FACT_LANGS[/** @type {keyof typeof FACT_LANGS} */ (f.lang)] ?? f.lang}`);
|
|
205
|
+
if (f.decimal === ',') bits.push('decimal comma');
|
|
192
206
|
if (f.rule) bits.push(ruleWords(f));
|
|
193
207
|
else if (f.anchor === undefined) bits.push('as the quote writes it');
|
|
194
208
|
if (f.anchor !== undefined) bits.push(f.until !== undefined ? `the words after "${f.anchor}" up to "${f.until}"` : `after "${f.anchor}"`);
|
|
195
209
|
}
|
|
196
210
|
bits.push(`quoted from "${source}"`);
|
|
197
|
-
return `fact · ${f.name} — ${bits.join(', ')}`;
|
|
211
|
+
return `fact · ${f.name} — ${bits.join(', ')}${f.aiProposal ? ' — AI\'s proposal — check it' : ''}`;
|
|
198
212
|
}
|
|
199
213
|
|
|
214
|
+
/** the languages whose month names bareguard 0.27 reads on a `date` fact (its `lang`), each with the name a person reads; absent `lang` = ISO YYYY-MM-DD only */
|
|
215
|
+
export const FACT_LANGS = Object.freeze({ en: 'English', de: 'German', fr: 'French', es: 'Spanish', it: 'Italian', pt: 'Portuguese', nl: 'Dutch' });
|
|
216
|
+
|
|
217
|
+
/** the decimal marks a number or money fact may sign (bareguard 0.27 `decimal`); absent = "." */
|
|
218
|
+
export const FACT_DECIMALS = Object.freeze(['.', ',']);
|
|
219
|
+
|
|
220
|
+
/** every field a part of class `fact` may carry (the shared ones are checked by rubricStepShapeReds) */
|
|
221
|
+
export const FACT_PART_FIELDS = PART_FIELDS;
|
|
222
|
+
|
|
223
|
+
const CURRENCY_SIGNS = ['$', '€', '£'];
|
|
224
|
+
|
|
225
|
+
/** @param {any} f a money fact @returns {string[]} every form the page writes the amount in: the units first (as R1L reads them), then the currency signs */
|
|
226
|
+
export const moneyForms = (f) => [...asList(f.unit), ...asList(f.currency)];
|
|
227
|
+
|
|
228
|
+
/** @param {unknown} v @returns {v is string} */
|
|
229
|
+
const nonEmpty = (v) => typeof v === 'string' && v.trim() !== '';
|
|
230
|
+
|
|
231
|
+
/** the `fact` part of a step's parameters, or null (a step has at most one) @param {any} params @returns {any|null} */
|
|
232
|
+
export function factPartOf(params) {
|
|
233
|
+
const parts = Array.isArray(params?.parts) ? params.parts : [];
|
|
234
|
+
return parts.find((/** @type {any} */ p) => isRec(p) && p.class === 'fact') ?? null;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* The SHAPE of a `fact` part (what it may carry), pushed as reds in the same form `rubricStepShapeReds` uses. Whether the
|
|
239
|
+
* bareguard rubric it builds is signable is asked of bareguard itself (`checkRubricParts` builds it once at drafting).
|
|
240
|
+
* @param {any} part @param {string} w the path prefix @param {(code: string, path: string, detail: string) => void} red
|
|
241
|
+
*/
|
|
242
|
+
export function factShapeReds(part, w, red) {
|
|
243
|
+
for (const k of Object.keys(part)) {
|
|
244
|
+
if (!['text', 'class', 'covers', 'rules', 'source', 'facts', 'count'].includes(k)) {
|
|
245
|
+
red('invalid-value', `${w}.${k}`, `"${k}" is not a field of a fact part — fields: text, class, covers, rules, ${FACT_PART_FIELDS.join(', ')}`);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
if (!(nonEmpty(part.source) && part.source.length <= 128)) red('invalid-value', `${w}.source`, 'the label of the input the quotes come from');
|
|
249
|
+
if (!Array.isArray(part.facts) || part.facts.length === 0 || part.facts.length > MAX_FACTS) {
|
|
250
|
+
red('invalid-value', `${w}.facts`, `a list of 1 to ${MAX_FACTS} facts {name, shape, ...}`);
|
|
251
|
+
} else {
|
|
252
|
+
/** @type {Set<string>} */
|
|
253
|
+
const seen = new Set();
|
|
254
|
+
part.facts.forEach((/** @type {any} */ f, /** @type {number} */ j) => {
|
|
255
|
+
const fw = `${w}.facts[${j}]`;
|
|
256
|
+
if (!isRec(f)) { red('invalid-value', fw, '{name, shape, ...}'); return; }
|
|
257
|
+
for (const k of Object.keys(f)) {
|
|
258
|
+
if (FACT_FIELDS.includes(k)) continue;
|
|
259
|
+
// L4 (smv710w8c3wdh, 3 of 3 tries): "covers" / "rules" are fields of the PART, written once, never of a fact inside it
|
|
260
|
+
red('invalid-value', `${fw}.${k}`, k === 'covers' || k === 'rules'
|
|
261
|
+
? `"${k}" is a field of the PART, not of a fact - write the numbers once on the fact part ("${k}": [..]) and take it off every fact. Fact fields: ${FACT_FIELDS.join(', ')}`
|
|
262
|
+
: `"${k}" is not a field of a fact — fields: ${FACT_FIELDS.join(', ')}`);
|
|
263
|
+
}
|
|
264
|
+
if (!(typeof f.name === 'string' && NAME_RE.test(f.name))) red('invalid-value', `${fw}.name`, 'the fact\'s name: letters, spaces, "_" or "-" only (no digits), at most 64 characters');
|
|
265
|
+
else if (seen.has(f.name)) red('invalid-value', `${fw}.name`, `the name "${f.name}" is used twice on this line`);
|
|
266
|
+
else seen.add(f.name);
|
|
267
|
+
if (!FACT_SHAPES.includes(f.shape)) { red('invalid-value', `${fw}.shape`, `one of ${FACT_SHAPES.join(' | ')}`); return; }
|
|
268
|
+
if (Object.hasOwn(f, 'aiProposal') && typeof f.aiProposal !== 'boolean') red('invalid-value', `${fw}.aiProposal`, 'true when the AI turned the person\'s words into this number');
|
|
269
|
+
const has = (/** @type {string} */ k) => Object.hasOwn(f, k);
|
|
270
|
+
if (f.shape === 'money') {
|
|
271
|
+
if (!has('unit') && !has('currency')) red('invalid-value', `${fw}.unit`, 'money names at least one of unit (words the input writes after the amount, e.g. "US dollars") or currency ("$", "€" or "£"); each may be one value or a list');
|
|
272
|
+
} else if (has('unit') || has('currency')) red('invalid-value', `${fw}.${has('unit') ? 'unit' : 'currency'}`, 'only money has a unit or a currency');
|
|
273
|
+
if (has('unit')) {
|
|
274
|
+
const us = f.unit;
|
|
275
|
+
if (Array.isArray(us) ? us.length === 0 || us.some((/** @type {unknown} */ u) => !nonEmpty(u)) : !nonEmpty(us)) red('invalid-value', `${fw}.unit`, 'a non-empty string copied from the input, or a non-empty list of them');
|
|
276
|
+
else {
|
|
277
|
+
const list = asList(us);
|
|
278
|
+
if (list.length > MAX_UNITS) red('invalid-value', `${fw}.unit`, `at most ${MAX_UNITS} units (${list.length} given)`);
|
|
279
|
+
else if (list.some((u) => u.length > MAX_UNIT_CHARS)) red('invalid-value', `${fw}.unit`, `a unit is at most ${MAX_UNIT_CHARS} characters`);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
if (has('currency')) {
|
|
283
|
+
const cs = f.currency;
|
|
284
|
+
if (Array.isArray(cs) ? cs.length === 0 || cs.some((/** @type {unknown} */ c) => !CURRENCY_SIGNS.includes(/** @type {string} */ (c))) : !CURRENCY_SIGNS.includes(cs)) red('invalid-value', `${fw}.currency`, 'one of $ | € | £, or a list of them');
|
|
285
|
+
else {
|
|
286
|
+
const list = asList(cs);
|
|
287
|
+
if (list.length > MAX_CURRENCIES) red('invalid-value', `${fw}.currency`, `at most ${MAX_CURRENCIES} currencies (${list.length} given)`);
|
|
288
|
+
else if (new Set(list).size !== list.length) red('invalid-value', `${fw}.currency`, 'the currencies are not repeated');
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
if (has('lang')) {
|
|
292
|
+
if (f.shape !== 'date') red('invalid-value', `${fw}.lang`, 'only a date fact carries lang (the language the page writes its month names in); leave it out for a date written 2026-10-26');
|
|
293
|
+
else if (typeof f.lang !== 'string' || !Object.hasOwn(FACT_LANGS, f.lang)) red('invalid-value', `${fw}.lang`, `one of ${Object.keys(FACT_LANGS).join(' | ')}`);
|
|
294
|
+
}
|
|
295
|
+
if (has('decimal')) {
|
|
296
|
+
if (f.shape !== 'number' && f.shape !== 'money') red('invalid-value', `${fw}.decimal`, 'only a number or money fact carries decimal (the mark the page writes before the decimals)');
|
|
297
|
+
else if (!FACT_DECIMALS.includes(f.decimal)) red('invalid-value', `${fw}.decimal`, 'one of "." | ","');
|
|
298
|
+
}
|
|
299
|
+
if (f.shape === 'phrase') {
|
|
300
|
+
if (!nonEmpty(f.phrase)) red('invalid-value', `${fw}.phrase`, 'the fixed words the quote must contain, copied from the input');
|
|
301
|
+
for (const k of ['anchor', 'until', 'rule']) if (has(k)) red('invalid-value', `${fw}.${k}`, 'a phrase is fixed words the quote must contain; it has no anchor, until or rule');
|
|
302
|
+
} else if (has('phrase')) red('invalid-value', `${fw}.phrase`, 'only a phrase fact carries phrase');
|
|
303
|
+
if (has('place')) {
|
|
304
|
+
const bad = f.shape === 'phrase' ? placeRuleProblem(f.place) : 'only a phrase fact carries a place rule';
|
|
305
|
+
if (bad !== null) red('invalid-value', `${fw}.place`, bad);
|
|
306
|
+
}
|
|
307
|
+
if (has('anchor') && !nonEmpty(f.anchor)) red('invalid-value', `${fw}.anchor`, 'a label copied VERBATIM from the input');
|
|
308
|
+
if (has('until') && !nonEmpty(f.until)) red('invalid-value', `${fw}.until`, 'a label copied VERBATIM from the input');
|
|
309
|
+
if (has('until') && !has('anchor') && f.shape !== 'phrase') red('invalid-value', `${fw}.until`, 'until needs an anchor');
|
|
310
|
+
if (has('until') && f.shape !== 'text' && f.shape !== 'phrase') red('invalid-value', `${fw}.until`, 'until closes a text fact only');
|
|
311
|
+
if (has('rule') && f.shape !== 'phrase') {
|
|
312
|
+
const r = f.rule;
|
|
313
|
+
if (f.shape === 'text') red('invalid-value', `${fw}.rule`, 'a text fact is bind only: it has no rule');
|
|
314
|
+
else if (!isRec(r) || !FACT_OPS.includes(r.op)) red('invalid-value', `${fw}.rule`, `{op: ${FACT_OPS.join(' | ')}, value} or {op: "between", lo, hi}`);
|
|
315
|
+
else if (r.op === 'between' ? !(boundOk(f.shape, r.lo) && boundOk(f.shape, r.hi) && !Object.hasOwn(r, 'value')) : !(boundOk(f.shape, r.value) && !Object.hasOwn(r, 'lo') && !Object.hasOwn(r, 'hi'))) {
|
|
316
|
+
red('invalid-value', `${fw}.rule`, r.op === 'between' ? 'between needs lo and hi (numbers for number/money, strings for date/time) and no value' : 'a comparison needs value (a number for number/money, a string for date/time)');
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
if (Object.hasOwn(part, 'count')) {
|
|
322
|
+
const c = part.count;
|
|
323
|
+
const ok = isRec(c) && Object.keys(c).every((k) => k === 'min' || k === 'max') && (Object.hasOwn(c, 'min') || Object.hasOwn(c, 'max'))
|
|
324
|
+
&& ['min', 'max'].every((k) => !Object.hasOwn(c, k) || (Number.isInteger(c[k]) && c[k] >= 1))
|
|
325
|
+
&& (!Object.hasOwn(c, 'min') || !Object.hasOwn(c, 'max') || c.min <= c.max);
|
|
326
|
+
if (!ok) red('invalid-value', `${w}.count`, '{min?, max?} — how many results the person asked for (integers, 1 or more, min no more than max)');
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Where bareguard read each page-form fact's value inside each quote, as the quote spells it: from `checkStep`'s `full.evidence` (one entry per
|
|
332
|
+
* claim: `text` = the normalized quote the decides ran on, `spans` = where each decide read its anchor, value and unit/currency). Only a fact that
|
|
333
|
+
* signs `lang` or `decimal` is looked up; the span is the decide's `value` span (the one equal to the claim's own value when bareguard flags it).
|
|
334
|
+
* @param {any} part @param {any[]|undefined} evidence @returns {(Record<number, string>|undefined)[]} per claim index
|
|
335
|
+
*/
|
|
336
|
+
export function writtenSpans(part, evidence) {
|
|
337
|
+
/** @type {(Record<number, string>|undefined)[]} */
|
|
338
|
+
const out = [];
|
|
339
|
+
for (const e of Array.isArray(evidence) ? evidence : []) {
|
|
340
|
+
if (!isRec(e) || !Number.isInteger(e.claim) || typeof e.text !== 'string' || !Array.isArray(e.spans)) continue;
|
|
341
|
+
/** @type {Record<number, string>} */
|
|
342
|
+
const row = {};
|
|
343
|
+
part.facts.forEach((/** @type {any} */ f, /** @type {number} */ j) => {
|
|
344
|
+
if (f.lang === undefined && f.decimal === undefined) return;
|
|
345
|
+
const mine = e.spans.filter((/** @type {any} */ sp) => isRec(sp) && sp.decide === j && sp.role === 'value' && Number.isInteger(sp.start) && Number.isInteger(sp.end));
|
|
346
|
+
const sp = mine.find((/** @type {any} */ x) => x.matched === true) ?? mine[0];
|
|
347
|
+
if (sp) row[j] = e.text.slice(sp.start, sp.end);
|
|
348
|
+
});
|
|
349
|
+
if (Object.keys(row).length) out[e.claim] = row;
|
|
350
|
+
}
|
|
351
|
+
return out;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
|
|
200
355
|
/** @param {any} part @returns {string|null} the "N results" row of a fact part */
|
|
201
356
|
export function countSentence(part) {
|
|
202
357
|
const c = isRec(part.count) ? part.count : null;
|
package/src/closers.js
CHANGED
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
// reading, flagged there as an interpretation call, not a rule from the
|
|
44
44
|
// signed text).
|
|
45
45
|
|
|
46
|
-
import { createRubric, checkStep } from 'bareguard';
|
|
46
|
+
import { createRubric, checkStep, numbersInQuote } from 'bareguard';
|
|
47
47
|
import { plainWords } from './checkwords.js';
|
|
48
48
|
import { checkCited } from './citedcheck.js';
|
|
49
49
|
import { closeSheet } from './sheetrun.js';
|
|
@@ -271,14 +271,52 @@ export async function closeSoftgreen(artifact, shape) {
|
|
|
271
271
|
/**
|
|
272
272
|
* The one dispatcher — `close by declared class` (M2 scope item 4).
|
|
273
273
|
*
|
|
274
|
-
* @param {{ close?: { class?: string, shape?: Record<string, any>, picked?: any[], cited?: any, columns?: {source: string, column: string}[], sheet?: any[] } }} step
|
|
274
|
+
* @param {{ close?: { class?: string, shape?: Record<string, any>, picked?: any[], cited?: any, columns?: {source: string, column: string}[], sheet?: any[], numbersFrom?: number[] } }} step
|
|
275
275
|
* @param {unknown} artifact
|
|
276
|
-
* @param {{ reads: Record<string, any>, businessDate: string, source?: {ok: true, text: string, sha256: string}|{ok: false, red: string}|null, sheet?: any }} ctx
|
|
276
|
+
* @param {{ reads: Record<string, any>, businessDate: string, source?: {ok: true, text: string, sha256: string}|{ok: false, red: string}|null, sheet?: any, numbers?: {quotes: Record<string, string[]>, missing: number[]} }} ctx
|
|
277
277
|
* `source` (M10 piece 4) = the run's own frozen copy a cited step reads, from `readRunSource`; only a step whose close carries `cited` reads it
|
|
278
278
|
* `sheet` (M10b piece 2) = the run's own tables and recorded `tableSha`s a step with `close.sheet` is checked on, from `readRunSheets`
|
|
279
279
|
* @returns {Promise<CloseVerdict>}
|
|
280
280
|
*/
|
|
281
281
|
export async function closeByClass(step, artifact, ctx) {
|
|
282
|
+
const base = await closeByClassOwn(step, artifact, ctx);
|
|
283
|
+
const from = step?.close?.numbersFrom;
|
|
284
|
+
return Array.isArray(from) && from.length > 0 ? withNumbers(base, closeNumbers(step, artifact, from, ctx.numbers)) : base;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* M16 am3 (2), R7: the `$` numbers default of the check list. Every number in the answer's `text` must be in a quote an EARLIER line's cited check already passed (bareguard's `numbersInQuote`: a token match
|
|
289
|
+
* on the numbers, not a canonical compare, a documented limit; words are free). The quotes are the run's cited record of those lines (`ctx.numbers.quotes`, line -> quotes; `missing` = lines with none).
|
|
290
|
+
* Third outcomes: an answer with no `text` is `unparseable`, quotes that cannot be read (no record, a line not there yet) are `crash`; neither is ever green.
|
|
291
|
+
* What it throws away: only the numbers' token form is compared; a number written another way in the quote (1,000 vs 1000) is a bareguard question, not ours.
|
|
292
|
+
* @borrowed-from bareloop src/rubricstep.js@v0.56.0 (3383cce) gradeStep, PART 1b
|
|
293
|
+
* @param {any} step @param {unknown} artifact @param {number[]} from @param {{quotes: Record<string, string[]>, missing: number[]}|undefined} numbers
|
|
294
|
+
* @returns {{verdict: 'green'|'red'|'unparseable'|'crash', red: string|null, text: string}}
|
|
295
|
+
*/
|
|
296
|
+
export function closeNumbers(step, artifact, from, numbers) {
|
|
297
|
+
const text = artifact && typeof artifact === 'object' ? /** @type {any} */ (artifact).text : undefined;
|
|
298
|
+
const words = `every number in the text is in a quote checked on line ${from.join(', ')}`;
|
|
299
|
+
if (typeof text !== 'string') return { verdict: 'unparseable', red: `numbers check: the answer must be shaped {text: string} so its numbers can be read, got ${describeArtifact(artifact)}`, text: words };
|
|
300
|
+
if (!numbers) return { verdict: 'crash', red: `numbers check crashed: the quotes of line ${from.join(', ')} are not available to this run`, text: words };
|
|
301
|
+
const gone = from.filter((n) => numbers.missing.includes(n) || !Array.isArray(numbers.quotes[String(n)]));
|
|
302
|
+
if (gone.length) return { verdict: 'red', red: `line ${gone.join(', ')}'s answer is not there yet, so the numbers in line ${step.fromLine}'s text cannot be tied to it`, text: words };
|
|
303
|
+
const t = numbersInQuote(text, from.flatMap((n) => numbers.quotes[String(n)]).join('\n'));
|
|
304
|
+
if (!t.ok) return { verdict: 'red', red: `line ${step.fromLine}: "text" has number(s) ${t.missing.join(', ')} that no checked quote of line ${from.join(', ')} holds - use only numbers from those quotes, written as they write them`, text: words };
|
|
305
|
+
return { verdict: 'green', red: null, text: words };
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/** the numbers tie beside the class's own verdict: red if either is red (both told); a third outcome of either is never turned into green, the class's own winning when it has one @param {any} base @param {ReturnType<typeof closeNumbers>} num @returns {CloseVerdict} */
|
|
309
|
+
function withNumbers(base, num) {
|
|
310
|
+
const numbersCheck = { text: num.text, ok: num.verdict === 'green', result: num.verdict === 'green' ? null : num.verdict === 'red' ? num.red : num.verdict };
|
|
311
|
+
if (base.verdict === 'crash' || base.verdict === 'unparseable') return { ...base, numbersCheck };
|
|
312
|
+
if (num.verdict === 'crash' || num.verdict === 'unparseable') return { ...num, verdict: num.verdict, red: num.red, ...(base.cited ? { cited: base.cited } : {}), numbersCheck };
|
|
313
|
+
if (num.verdict === 'green') return { ...base, numbersCheck };
|
|
314
|
+
const reds = [...(base.verdict === 'red' ? [base.red] : []), num.red].filter(Boolean);
|
|
315
|
+
return { ...base, verdict: 'red', red: reds.join('\n'), ...(base.reds || reds.length > 1 ? { reds } : {}), numbersCheck };
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/** @param {any} step @param {unknown} artifact @param {any} ctx @returns {Promise<CloseVerdict>} */
|
|
319
|
+
async function closeByClassOwn(step, artifact, ctx) {
|
|
282
320
|
const cls = step?.close?.class;
|
|
283
321
|
if (cls === 'green' && Array.isArray(step?.close?.picked) && step.close.picked.length > 0) return await closeFactAndPicks(step, artifact, ctx);
|
|
284
322
|
return await closeOne(step, artifact, ctx);
|
package/src/declaration.js
CHANGED
|
@@ -44,6 +44,8 @@ import { SHEET_RULES, MAX_SHEET_CHECKS, sheetCheckColumns, sheetCheckReds, sheet
|
|
|
44
44
|
import { lineRules } from './pagebits.js';
|
|
45
45
|
import { OFFERED as OFFERED_RULES } from './checkwords.js';
|
|
46
46
|
import { isColumnChoiceRule } from './sheetoffer.js';
|
|
47
|
+
import { checkListReds } from './checklistsign.js';
|
|
48
|
+
import { ticketListReds } from './ticketrows.js';
|
|
47
49
|
|
|
48
50
|
/** @typedef {import('./types.js').Arbiter} Arbiter */
|
|
49
51
|
/** @typedef {import('./types.js').SignedLine} SignedLine */
|
|
@@ -65,6 +67,7 @@ export const DECLARATION_FIELDS = Object.freeze([
|
|
|
65
67
|
'ticketFilter',
|
|
66
68
|
'ticketWatch',
|
|
67
69
|
'pickedLines',
|
|
70
|
+
'checkList',
|
|
68
71
|
// step level
|
|
69
72
|
'goal',
|
|
70
73
|
'primitives',
|
|
@@ -81,6 +84,7 @@ export const DECLARATION_FIELDS = Object.freeze([
|
|
|
81
84
|
'columns',
|
|
82
85
|
'sheet',
|
|
83
86
|
'picked',
|
|
87
|
+
'numbersFrom',
|
|
84
88
|
]);
|
|
85
89
|
|
|
86
90
|
const VALID_CLASSES = Object.freeze(['green', 'softgreen', 'hitl']);
|
|
@@ -91,9 +95,9 @@ const VALID_CLASSES = Object.freeze(['green', 'softgreen', 'hitl']);
|
|
|
91
95
|
// an ask's position, an ask's TTL, the egress allow-list...").
|
|
92
96
|
const ARBITER_KEYS = Object.freeze(['cap', 'ask', 'ttl', 'send', 'source', 'trigger', 'skills']);
|
|
93
97
|
|
|
94
|
-
const TOP_LEVEL_ALLOWED = Object.freeze(['steps', 'guardrailClasses', 'unjudgeable', 'refused', 'inputFacts', 'mcp', 'flowType', 'ticketFilter', 'ticketWatch', 'pickedLines']);
|
|
98
|
+
const TOP_LEVEL_ALLOWED = Object.freeze(['steps', 'guardrailClasses', 'unjudgeable', 'refused', 'inputFacts', 'mcp', 'flowType', 'ticketFilter', 'ticketWatch', 'pickedLines', 'checkList']);
|
|
95
99
|
const STEP_ALLOWED = Object.freeze(['goal', 'primitives', 'reads', 'emits', 'fromLine', 'close', 'picks', 'mcpTools']);
|
|
96
|
-
const CLOSE_ALLOWED = Object.freeze(['class', 'shape', 'cited', 'columns', 'sheet', 'picked']);
|
|
100
|
+
const CLOSE_ALLOWED = Object.freeze(['class', 'shape', 'cited', 'columns', 'sheet', 'picked', 'numbersFrom']);
|
|
97
101
|
|
|
98
102
|
/** M13 piece 4 (signed item 4): the job's flow type, set by code from the job card, signed with the job. */
|
|
99
103
|
export const FLOW_TYPES = Object.freeze(['plain', 'mcp', 'tickets']);
|
|
@@ -156,7 +160,7 @@ function checkMcp(declaration, reds) {
|
|
|
156
160
|
/** M12 piece 3 (item 4): the signed label filter, `ticketFilter: {priority?: ['P0'..'P3'], labels?: [names]}`; optional, and only on a job that lists MCP tools.
|
|
157
161
|
* Pure data: code decides at run (src/ticket-labels.js); the drafter may only suggest it and a human signs it.
|
|
158
162
|
* @param {Record<string, any>} declaration @param {string[]} reds */
|
|
159
|
-
function checkTicketFilter(declaration, reds) {
|
|
163
|
+
export function checkTicketFilter(declaration, reds) {
|
|
160
164
|
if (!Object.hasOwn(declaration, 'ticketFilter')) return;
|
|
161
165
|
const f = declaration.ticketFilter;
|
|
162
166
|
if (!isPlainObject(f) || Object.keys(f).length === 0) {
|
|
@@ -183,7 +187,7 @@ function checkTicketFilter(declaration, reds) {
|
|
|
183
187
|
|
|
184
188
|
/** M12 piece 3 (signed item 7): the ticket fields a schedule may watch, `ticketWatch: ['state'|'labels']`; optional, only on a job that lists MCP tools, typed values only.
|
|
185
189
|
* The scheduler compares (src/trigger-tickets.js); the drafter may suggest, a human signs. @param {Record<string, any>} declaration @param {string[]} reds */
|
|
186
|
-
function checkTicketWatch(declaration, reds) {
|
|
190
|
+
export function checkTicketWatch(declaration, reds) {
|
|
187
191
|
if (!Object.hasOwn(declaration, 'ticketWatch')) return;
|
|
188
192
|
const w = declaration.ticketWatch;
|
|
189
193
|
if (!Array.isArray(w) || w.length === 0) { reds.push(`declaration: "ticketWatch" must be a non-empty list of fields (${WATCHABLE.join(' and ')})`); return; }
|
|
@@ -223,7 +227,7 @@ export const SHAPE_KEYS = Object.freeze(['maxWords', 'sections', 'linesPerInvoic
|
|
|
223
227
|
export const MACHINE_SHAPE_KEYS = Object.freeze(['wordsPerSection', 'picked']);
|
|
224
228
|
|
|
225
229
|
const SHAPE_TYPE_CHECKS = Object.freeze({
|
|
226
|
-
// M10 am16: the checks the person picked, set by code (src/
|
|
230
|
+
// M10 am16: the checks the person picked, set by code (src/blockassemble.js), each one a bareguard rule with only that rule's own fields
|
|
227
231
|
picked: {
|
|
228
232
|
expected: 'a non-empty array of checks, each an object with a text rule of bareguard\'s list',
|
|
229
233
|
check: (v) => Array.isArray(v) && v.length > 0 && v.every((c) => isPlainObject(c) && typeof c.rule === 'string' && OFFERED_RULES.includes(c.rule)),
|
|
@@ -557,7 +561,7 @@ function checkShapeBuilds(shape, label, reds, redsBefore) {
|
|
|
557
561
|
}
|
|
558
562
|
|
|
559
563
|
/**
|
|
560
|
-
* M10 am22 (3): `pickedLines` is the record of the fact lines that carry the person's picks: a list of line numbers. Code writes it (src/
|
|
564
|
+
* M10 am22 (3): `pickedLines` is the record of the fact lines that carry the person's picks: a list of line numbers. Code writes it (src/blockassemble.js).
|
|
561
565
|
* @param {Record<string, any>} declaration @param {string[]} reds
|
|
562
566
|
*/
|
|
563
567
|
function checkPickedLines(declaration, reds) {
|
|
@@ -568,7 +572,7 @@ function checkPickedLines(declaration, reds) {
|
|
|
568
572
|
|
|
569
573
|
/**
|
|
570
574
|
* M10 am22: `close.picked` is the checks the person picked for a fact line, kept beside its fact check and run on the answer's `text`. Code sets it (src/checkpick.js
|
|
571
|
-
|
|
575
|
+
* assembleFromBlock); here it must be a green step's, a list of bareguard text rules that builds into a check.
|
|
572
576
|
* It is allowed ONLY on a line the signed plan records in `pickedLines` (written by code from the person's picks); a count on any other fact line is refused.
|
|
573
577
|
* @param {any} step @param {string} label @param {string} effectiveClass @param {string[]} reds @param {Record<string, any>} declaration
|
|
574
578
|
*/
|
|
@@ -586,6 +590,22 @@ function checkPickedKey(step, label, effectiveClass, reds, declaration) {
|
|
|
586
590
|
try { buildSoftgreenRubric({ picked: step.close.picked }); } catch (err) { reds.push(`${at} cannot be built into a check - ${String(err.message).replace(/^invalid rubric: /, '')}`); }
|
|
587
591
|
}
|
|
588
592
|
|
|
593
|
+
/**
|
|
594
|
+
* M16 am3 (2): `close.numbersFrom` is the numbers tie of a text step (the `$` default of the check list): the job lines, all EARLIER, whose checked quotes every number in this step's text must be in.
|
|
595
|
+
* Code sets it (src/blockassemble.js). Each line it names must be a green step that checks quotes (`close.cited`); a step that checks quotes has no text of its own to tie.
|
|
596
|
+
* @param {any} step @param {string} label @param {any[]} steps @param {string[]} reds
|
|
597
|
+
*/
|
|
598
|
+
function checkNumbersFromKey(step, label, steps, reds) {
|
|
599
|
+
const at = `declaration: ${label}.close.numbersFrom`;
|
|
600
|
+
const v = step.close.numbersFrom;
|
|
601
|
+
if (!Array.isArray(v) || v.length === 0 || !v.every((n) => Number.isInteger(n) && n > 0) || new Set(v).size !== v.length) { reds.push(`${at} must be a non-empty list of distinct job line numbers`); return; }
|
|
602
|
+
if (isPlainObject(step.close.cited)) reds.push(`${at}: line ${step.fromLine} checks quotes, so it has no text whose numbers could be tied to other lines`);
|
|
603
|
+
for (const n of v) {
|
|
604
|
+
if (!Number.isInteger(step.fromLine) || n >= step.fromLine) reds.push(`${at}: line ${n} is not before line ${step.fromLine}`);
|
|
605
|
+
else if (!steps.some((st) => isPlainObject(st) && st.fromLine === n && st.close?.class === 'green' && isPlainObject(st.close?.cited))) reds.push(`${at}: line ${n} is not a line that checks quotes, so its quotes cannot hold line ${step.fromLine}'s numbers`);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
|
|
589
609
|
/**
|
|
590
610
|
* M10 amendment 7 item 1: `close.cited` is the facts a green step checks its quotes against, written by the drafter (a fact part:
|
|
591
611
|
* `{source, facts, count?}`, src/citedcheck.js). Its SHAPE is checked in every mode (a signed flow is read the same way). With `fitJobLine` the number rules
|
|
@@ -799,10 +819,10 @@ export function validateDeclaration(declaration, context = {}) {
|
|
|
799
819
|
reds.push('declaration: "guardrailClasses" must be an object keyed by line number');
|
|
800
820
|
}
|
|
801
821
|
|
|
802
|
-
// --- unjudgeable (
|
|
822
|
+
// --- unjudgeable (M17 am4, C8: a new plan carries none; a plan signed before holds it and is read as signed) ---
|
|
803
823
|
let unjudgeable = {};
|
|
804
824
|
if (!Object.prototype.hasOwnProperty.call(declaration, 'unjudgeable')) {
|
|
805
|
-
|
|
825
|
+
// nothing to read
|
|
806
826
|
} else if (Array.isArray(declaration.unjudgeable) && declaration.unjudgeable.length === 0) {
|
|
807
827
|
// am41 item 1 (F63): an empty list carries no data; it counts as {}. A non-empty list falls to the red below.
|
|
808
828
|
} else if (isPlainObject(declaration.unjudgeable)) {
|
|
@@ -1027,6 +1047,7 @@ export function validateDeclaration(declaration, context = {}) {
|
|
|
1027
1047
|
else if (fitJobLine === true && effectiveClass === 'green' && step.close.shape !== undefined && step.close.shape !== null) {
|
|
1028
1048
|
reds.push(`declaration: ${label}.close.shape: a step that checks facts carries no count check of the drafter's own; only a check you picked (close.picked, on a line recorded in pickedLines) can sit beside its fact check`);
|
|
1029
1049
|
}
|
|
1050
|
+
if (step.close.numbersFrom !== undefined) checkNumbersFromKey(step, label, steps, reds);
|
|
1030
1051
|
if (step.close.cited !== undefined) checkCitedKey(step, label, { sourceRoles, reads, effectiveClass, lines: safeLines, fitJobLine, pageWords }, reds);
|
|
1031
1052
|
if (step.close.sheet !== undefined) checkSheetKey(step, label, { cellsRoles, reads, effectiveClass, lines: safeLines, fitJobLine, sheetWords }, reds);
|
|
1032
1053
|
if (step.close.columns !== undefined || (fitJobLine === true && sheetWords)) checkColumnsKey(step, label, { cellsRoles, reads, effectiveClass, lines: safeLines, sheetWords }, reds);
|
|
@@ -1099,6 +1120,10 @@ export function validateDeclaration(declaration, context = {}) {
|
|
|
1099
1120
|
});
|
|
1100
1121
|
});
|
|
1101
1122
|
|
|
1123
|
+
// M16 item 2: the checks of a list line are the signed list's; a plan carrying one proves it here, at sign and at run start ($0)
|
|
1124
|
+
reds.push(...checkListReds(declaration));
|
|
1125
|
+
reds.push(...ticketListReds(declaration));
|
|
1126
|
+
|
|
1102
1127
|
// --- ask slots (ported from poc/m1/slots.mjs's checkAskSlots) --------------
|
|
1103
1128
|
// (a) exactly one hitl step bound to each signed ask line.
|
|
1104
1129
|
for (const n of askLines) {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// borrowed-from: bareloop src/declaredclose.js@v0.56.0 (3383cce) (SIGNED_ROW_FIELDS only: the constant the check block names; the rest of that module (kinds, judged, ralph, validate) is not wanted here)
|
|
2
|
+
|
|
3
|
+
/** the fields of a row of the one check list that the signed close carries (`closeDecl.list`); the row's own words are never signed */
|
|
4
|
+
export const SIGNED_ROW_FIELDS = Object.freeze(['line', 'key', 'from', 'by', 'kind', 'state', 'rule', 'part', 'reason', 'facts']);
|
package/src/draft-steps.js
CHANGED
|
@@ -24,7 +24,9 @@ function money(log) {
|
|
|
24
24
|
*/
|
|
25
25
|
export function triesOf(rounds) {
|
|
26
26
|
let no = 0;
|
|
27
|
-
|
|
27
|
+
// M16: only the declaration rounds are tries; the list's own turns (ledger-suggest, row-edit) and the looks are not
|
|
28
|
+
const declared = (Array.isArray(rounds) ? rounds : []).filter((e) => ['first', 'revision', 'structure-retry'].includes(e?.kind));
|
|
29
|
+
return declared.map((e, i, all) => {
|
|
28
30
|
const again = e?.kind === 'structure-retry' && i > 0;
|
|
29
31
|
if (!again) no += 1;
|
|
30
32
|
const passed = e?.outcome === 'valid';
|