fwdloop 0.36.0 → 0.38.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 +6 -20
- package/bin/fwdloop +35 -12
- package/package.json +3 -3
- package/src/action-stop.js +1 -1
- package/src/auditchecks.js +41 -9
- package/src/authoring.js +78 -20
- package/src/blockasks.js +10 -12
- package/src/blockassemble.js +49 -46
- package/src/blockdraft.js +4 -2
- package/src/blockpick.js +10 -0
- package/src/canrun.js +2 -1
- package/src/cardlist.js +28 -5
- package/src/checkblock.js +598 -61
- package/src/checked.js +27 -33
- package/src/checklistsign.js +3 -3
- package/src/checklook.js +45 -0
- package/src/checkrows.js +202 -0
- package/src/cited-record.js +2 -2
- package/src/citedcheck.js +53 -12
- package/src/citedwords.js +7 -4
- package/src/closers.js +49 -2
- package/src/declaration.js +34 -10
- package/src/drafter.js +99 -74
- package/src/factwords.js +7 -4
- package/src/globprefix.js +26 -0
- package/src/isrec.js +2 -0
- package/src/line-checks.js +1 -2
- package/src/minrule.js +16 -0
- package/src/model-step.js +22 -4
- package/src/pageask.js +0 -3
- package/src/pagedropwords.js +3 -11
- package/src/pagedry.js +75 -1
- package/src/pagefetch.js +11 -6
- package/src/pagelook.js +2 -1
- package/src/pagerules.js +8 -2
- package/src/panel/author.js +33 -8
- package/src/panel/data.js +3 -2
- package/src/panel/index.html +177 -37
- package/src/panel/result.js +34 -1
- package/src/pickrecord.js +14 -0
- package/src/planrebuild.js +55 -19
- package/src/ratelimit.js +117 -0
- package/src/report.js +14 -2
- package/src/rowresults.js +111 -0
- package/src/rubricstep.js +65 -2
- package/src/runner.js +38 -5
- package/src/shapebuild.js +281 -0
- package/src/shapelook.js +91 -0
- package/src/shapemenu.js +64 -0
- package/src/shaperesult.js +104 -0
- package/src/shaperows.js +263 -0
- package/src/shapewords.js +140 -0
- package/src/sheet-record.js +1 -2
- package/src/sheetblock.js +1 -2
- package/src/sheetbuild.js +41 -29
- package/src/sheetchecks.js +1 -2
- package/src/sheetclaims.js +1 -2
- package/src/sheetoffer.js +1 -1
- package/src/sheetrows.js +10 -64
- package/src/sheetrun.js +1 -2
- package/src/ticketrows.js +2 -3
- package/src/try-checks.js +39 -6
- package/src/types.js +1 -0
- package/src/whole-job.js +24 -8
- package/types/action-stop.d.ts +1 -1
- package/types/auditchecks.d.ts +13 -2
- package/types/authoring.d.ts +21 -2
- package/types/blockasks.d.ts +6 -10
- package/types/blockassemble.d.ts +12 -13
- package/types/blockdraft.d.ts +3 -2
- package/types/blockpick.d.ts +4 -0
- package/types/cardlist.d.ts +18 -2
- package/types/checkblock.d.ts +276 -27
- package/types/checked.d.ts +15 -6
- package/types/checklook.d.ts +36 -0
- package/types/checkrows.d.ts +119 -0
- package/types/citedcheck.d.ts +4 -2
- package/types/closers.d.ts +10 -1
- package/types/drafter.d.ts +9 -4
- package/types/globprefix.d.ts +5 -0
- package/types/isrec.d.ts +1 -0
- package/types/minrule.d.ts +6 -0
- package/types/model-step.d.ts +43 -2
- package/types/pageask.d.ts +0 -1
- package/types/pagedropwords.d.ts +0 -1
- package/types/pagedry.d.ts +27 -0
- package/types/pagefetch.d.ts +3 -2
- package/types/pagerules.d.ts +4 -0
- package/types/panel/result.d.ts +16 -1
- package/types/pickrecord.d.ts +10 -0
- package/types/ratelimit.d.ts +59 -0
- package/types/report.d.ts +2 -1
- package/types/rowresults.d.ts +28 -0
- package/types/rubricstep.d.ts +21 -0
- package/types/runner.d.ts +3 -1
- package/types/shapebuild.d.ts +97 -0
- package/types/shapelook.d.ts +76 -0
- package/types/shapemenu.d.ts +40 -0
- package/types/shaperesult.d.ts +40 -0
- package/types/shaperows.d.ts +102 -0
- package/types/shapewords.d.ts +43 -0
- package/types/sheetbuild.d.ts +31 -13
- package/types/sheetrows.d.ts +5 -36
- package/types/ticketrows.d.ts +1 -1
- package/types/try-checks.d.ts +2 -1
- package/types/types.d.ts +4 -0
- package/types/whole-job.d.ts +20 -4
package/src/citedwords.js
CHANGED
|
@@ -73,12 +73,15 @@ export function factWordReds({
|
|
|
73
73
|
}
|
|
74
74
|
if (f.until !== undefined) dropRed('closing label', f.until);
|
|
75
75
|
if (f.until !== undefined && countExact(text, f.until) < 1) red('word-missing', `${who}: ${JSON.stringify(f.until)} is not in the input "${src}". Copy the closing words from the input, or leave them out.`);
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
// M19 am5: a several-word phrase fact (anyOf) holds when the page says ANY of its words; the count of results is the words' counts together
|
|
77
|
+
const phraseOf = f.shape === 'phrase' ? (Array.isArray(f.anyOf) ? f.anyOf : typeof f.phrase === 'string' ? [f.phrase] : null) : null;
|
|
78
|
+
if (phraseOf) {
|
|
79
|
+
const shown = Array.isArray(f.anyOf) ? phraseOf.map((/** @type {string} */ x) => JSON.stringify(x)).join(', ') : JSON.stringify(f.phrase);
|
|
80
|
+
const seen = phraseOf.reduce((/** @type {number} */ n, /** @type {string} */ x) => n + countPhrase(text, x), 0);
|
|
81
|
+
if (seen < 1) red('word-missing', `${who}: ${shown} is not in the input "${src}". Copy the words the input really uses, or remove the check.`);
|
|
79
82
|
else if (Number.isInteger(part.count?.min) && seen < part.count.min) {
|
|
80
83
|
const n = part.count.min;
|
|
81
|
-
red('phrase-rare', `${who}: the words ${
|
|
84
|
+
red('phrase-rare', `${who}: the words ${shown} are in the input "${src}" only ${seen} time${seen === 1 ? '' : 's'}, but this line asks for ${n} results - each result's own quote must say them. Pick words every result says, or drop this check.`);
|
|
82
85
|
}
|
|
83
86
|
}
|
|
84
87
|
for (const u of asList(f.unit)) dropRed('unit', u);
|
package/src/closers.js
CHANGED
|
@@ -47,6 +47,8 @@ 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';
|
|
50
|
+
import { shapeItemCheck, SHAPE_FIELD } from './shaperows.js';
|
|
51
|
+
import { plainStepGap } from './rubricstep.js';
|
|
50
52
|
|
|
51
53
|
/** @typedef {import('./types.js').CloseVerdict} CloseVerdict */
|
|
52
54
|
|
|
@@ -87,6 +89,46 @@ export async function closeCited(part, artifact, source) {
|
|
|
87
89
|
}
|
|
88
90
|
}
|
|
89
91
|
|
|
92
|
+
/**
|
|
93
|
+
* M19 S5: the list-of-items check of a line's close (`close.itemShape`, the signed shape part {fields, minItems?, maxItems?}; never `close.shape`, which stays the text shape of M10): ONE bareguard `itemShape` check over the
|
|
94
|
+
* answer's `results`. On a facts+shape line (`close.cited` beside it) the check is closed and also lists `quote` and `values`, and the item count stays with the fact part (src/shaperows.js `shapeItemCheck`), so a count fault is
|
|
95
|
+
* told once. A red names the item and the field in the tag's words (src/shapewords.js). Third outcomes, never green: an answer that is not an object (`unparseable`), a shape bareguard cannot build or a check that stopped (`crash`).
|
|
96
|
+
* `shapeGaps` carries bareguard's own gaps (names, counts and bounds, never a value) for the views that mark an item or a field.
|
|
97
|
+
* @param {any} step @param {unknown} artifact @returns {Promise<CloseVerdict>}
|
|
98
|
+
*/
|
|
99
|
+
export async function closeItemShape(step, artifact) {
|
|
100
|
+
try {
|
|
101
|
+
if (!artifact || typeof artifact !== 'object' || Array.isArray(artifact)) {
|
|
102
|
+
return /** @type {CloseVerdict} */ ({ verdict: 'unparseable', red: 'itemShape artifact must be an object shaped {results: [...]}' });
|
|
103
|
+
}
|
|
104
|
+
const fact = step?.close?.class === 'green' && step.close.cited ? step.close.cited : null;
|
|
105
|
+
const rubric = createRubric({ schema: 1, goal: 'shape', inputs: [], checkpoints: { close: { gating: true, checks: [shapeItemCheck(step.close.itemShape, 'shape', fact)] } } });
|
|
106
|
+
const res = await checkStep(rubric, 'close', Object.hasOwn(artifact, SHAPE_FIELD) ? { [SHAPE_FIELD]: /** @type {any} */ (artifact)[SHAPE_FIELD] } : {});
|
|
107
|
+
if (res.verdict === 'stopped') {
|
|
108
|
+
const fault = /** @type {NonNullable<typeof res.fault>} */ (res.fault);
|
|
109
|
+
return { verdict: 'crash', red: `itemShape close crashed: the ${fault.id} check stopped (${fault.kind}${fault.detail ? `: ${fault.detail}` : ''})` };
|
|
110
|
+
}
|
|
111
|
+
if (res.verdict === 'red') {
|
|
112
|
+
// an answer with no `results` at all reads to bareguard as an empty artifact (`happened`): it is the tag's whole-field gap `missing`
|
|
113
|
+
const gaps = res.gaps.map((/** @type {any} */ g) => (g.check === 'happened' ? { ...g, check: 'itemShape', kind: 'missing', field: SHAPE_FIELD } : g));
|
|
114
|
+
const reds = gaps.map((/** @type {any} */ g) => plainStepGap(step.fromLine, 'empty', g)).flatMap((/** @type {string} */ t) => t.split('\n'));
|
|
115
|
+
return { verdict: 'red', red: reds.join('\n'), reds, shapeGaps: gaps };
|
|
116
|
+
}
|
|
117
|
+
return { verdict: 'green', red: null };
|
|
118
|
+
} catch (err) {
|
|
119
|
+
return { verdict: 'crash', red: `itemShape close crashed: ${err.message}` };
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** the items check beside the facts line's own verdict: red if either is red (both told, the fact half first); a third outcome of either is never turned into green, the fact half's winning when it has one @param {any} base @param {any} sh @returns {CloseVerdict} */
|
|
124
|
+
function withItemShape(base, sh) {
|
|
125
|
+
if (base.verdict === 'crash' || base.verdict === 'unparseable') return base;
|
|
126
|
+
if (sh.verdict === 'crash' || sh.verdict === 'unparseable') return { ...sh, ...(base.cited ? { cited: base.cited } : {}) };
|
|
127
|
+
if (sh.verdict === 'green') return base;
|
|
128
|
+
const reds = [...(base.verdict === 'red' ? String(base.red).split('\n') : []), ...sh.reds];
|
|
129
|
+
return { ...base, verdict: 'red', red: reds.join('\n'), reds, shapeGaps: sh.shapeGaps };
|
|
130
|
+
}
|
|
131
|
+
|
|
90
132
|
/**
|
|
91
133
|
* M4e amendment 18: the soft checks run on bareguard 0.21.0. `softgreenSpec(shape)` is the ONE place a declared shape
|
|
92
134
|
* becomes a rubric spec (signing and the run both build through `buildSoftgreenRubric`, so a shape that signs is a shape
|
|
@@ -271,7 +313,7 @@ export async function closeSoftgreen(artifact, shape) {
|
|
|
271
313
|
/**
|
|
272
314
|
* The one dispatcher — `close by declared class` (M2 scope item 4).
|
|
273
315
|
*
|
|
274
|
-
* @param {{ close?: { class?: string, shape?: Record<string, any>, picked?: any[], cited?: any, columns?: {source: string, column: string}[], sheet?: any[], numbersFrom?: number[] } }} step
|
|
316
|
+
* @param {{ close?: { class?: string, shape?: Record<string, any>, picked?: any[], cited?: any, itemShape?: any, columns?: {source: string, column: string}[], sheet?: any[], numbersFrom?: number[] } }} step
|
|
275
317
|
* @param {unknown} artifact
|
|
276
318
|
* @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
319
|
* `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
|
|
@@ -348,7 +390,12 @@ async function closeFactAndPicks(step, artifact, ctx) {
|
|
|
348
390
|
/** @param {any} step @param {unknown} artifact @param {{ reads: Record<string, any>, businessDate: string, source?: any, sheet?: any }} ctx @returns {Promise<CloseVerdict>} */
|
|
349
391
|
async function closeOne(step, artifact, ctx) {
|
|
350
392
|
const cls = step?.close?.class;
|
|
351
|
-
if (cls === 'green' && step?.close?.cited)
|
|
393
|
+
if (cls === 'green' && step?.close?.cited) {
|
|
394
|
+
const base = await closeCited(step.close.cited, artifact, ctx.source);
|
|
395
|
+
return step.close.itemShape ? withItemShape(base, await closeItemShape(step, artifact)) : base;
|
|
396
|
+
}
|
|
397
|
+
// M19 S5, O1: a list of items and no quote reads `results` only (class green: option (ii); class softgreen: option (i)); which class code signs for it is `SHAPE_ONLY_CLASS`, src/blockassemble.js
|
|
398
|
+
if ((cls === 'green' || cls === 'softgreen') && step?.close?.itemShape && !step.close.cited && !Array.isArray(step.close.sheet)) return await closeItemShape(step, artifact);
|
|
352
399
|
if (cls === 'green' && Array.isArray(step?.close?.sheet)) return await closeSheet(step.close.sheet, artifact, ctx.sheet);
|
|
353
400
|
if (cls === 'green') return { verdict: 'crash', red: 'closeByClass: a green step with no close.sheet or close.cited is the retired cell cite' };
|
|
354
401
|
if (cls === 'softgreen') return await closeSoftgreen(artifact, step?.close?.shape ?? {});
|
package/src/declaration.js
CHANGED
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
import { WATCHABLE } from './ticket-shape.js';
|
|
40
40
|
import { buildSoftgreenRubric, isCellsPath } from './closers.js';
|
|
41
41
|
import { factPartReds } from './citedcheck.js';
|
|
42
|
+
import { shapeShapeReds } from './shaperows.js';
|
|
42
43
|
import { numberRuleReds, countReds, citedWordReds } from './citedwords.js';
|
|
43
44
|
import { SHEET_RULES, MAX_SHEET_CHECKS, sheetCheckColumns, sheetCheckReds, sheetCheckWordReds, sheetNoClaimReds, sheetCoversReds } from './sheetchecks.js';
|
|
44
45
|
import { lineRules } from './pagebits.js';
|
|
@@ -85,6 +86,7 @@ export const DECLARATION_FIELDS = Object.freeze([
|
|
|
85
86
|
'sheet',
|
|
86
87
|
'picked',
|
|
87
88
|
'numbersFrom',
|
|
89
|
+
'itemShape',
|
|
88
90
|
]);
|
|
89
91
|
|
|
90
92
|
const VALID_CLASSES = Object.freeze(['green', 'softgreen', 'hitl']);
|
|
@@ -97,7 +99,7 @@ const ARBITER_KEYS = Object.freeze(['cap', 'ask', 'ttl', 'send', 'source', 'trig
|
|
|
97
99
|
|
|
98
100
|
const TOP_LEVEL_ALLOWED = Object.freeze(['steps', 'guardrailClasses', 'unjudgeable', 'refused', 'inputFacts', 'mcp', 'flowType', 'ticketFilter', 'ticketWatch', 'pickedLines', 'checkList']);
|
|
99
101
|
const STEP_ALLOWED = Object.freeze(['goal', 'primitives', 'reads', 'emits', 'fromLine', 'close', 'picks', 'mcpTools']);
|
|
100
|
-
const CLOSE_ALLOWED = Object.freeze(['class', 'shape', 'cited', 'columns', 'sheet', 'picked', 'numbersFrom']);
|
|
102
|
+
const CLOSE_ALLOWED = Object.freeze(['class', 'shape', 'cited', 'columns', 'sheet', 'picked', 'numbersFrom', 'itemShape']);
|
|
101
103
|
|
|
102
104
|
/** M13 piece 4 (signed item 4): the job's flow type, set by code from the job card, signed with the job. */
|
|
103
105
|
export const FLOW_TYPES = Object.freeze(['plain', 'mcp', 'tickets']);
|
|
@@ -339,8 +341,8 @@ export function checkShapes(declaration) {
|
|
|
339
341
|
* safe); an invented proposal is a red, never normalised to hitl.
|
|
340
342
|
* Returns `{ ok: true, class }` or `{ ok: false, error }`.
|
|
341
343
|
*/
|
|
342
|
-
function resolveGuardrailClass(line, guardrailClasses) {
|
|
343
|
-
if (!line || !line.guardrail) {
|
|
344
|
+
function resolveGuardrailClass(line, guardrailClasses, added = new Set()) {
|
|
345
|
+
if (!line || (!line.guardrail && !added.has(line.n))) {
|
|
344
346
|
return { ok: true, class: 'hitl' };
|
|
345
347
|
}
|
|
346
348
|
const key = String(line.n);
|
|
@@ -361,7 +363,7 @@ function resolveGuardrailClass(line, guardrailClasses) {
|
|
|
361
363
|
/** Same shape as poc/m0/validator.mjs's `deriveFromLine`: a step with no
|
|
362
364
|
* `fromLine` is silence -> hitl; a malformed or non-existent `fromLine` is
|
|
363
365
|
* a red; otherwise the class derives from that line's guardrail proposal. */
|
|
364
|
-
function deriveFromLine(fromLine, lines, guardrailClasses) {
|
|
366
|
+
function deriveFromLine(fromLine, lines, guardrailClasses, added = new Set()) {
|
|
365
367
|
if (fromLine === null || fromLine === undefined) {
|
|
366
368
|
return { ok: true, class: 'hitl', line: null };
|
|
367
369
|
}
|
|
@@ -372,7 +374,7 @@ function deriveFromLine(fromLine, lines, guardrailClasses) {
|
|
|
372
374
|
if (!line) {
|
|
373
375
|
return { ok: false, error: `fromLine ${fromLine} does not name any of the signed numbered lines` };
|
|
374
376
|
}
|
|
375
|
-
const resolved = resolveGuardrailClass(line, guardrailClasses);
|
|
377
|
+
const resolved = resolveGuardrailClass(line, guardrailClasses, added);
|
|
376
378
|
if (!resolved.ok) return { ok: false, error: resolved.error };
|
|
377
379
|
return { ok: true, class: resolved.class, line };
|
|
378
380
|
}
|
|
@@ -573,12 +575,13 @@ function checkPickedLines(declaration, reds) {
|
|
|
573
575
|
/**
|
|
574
576
|
* 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
|
|
575
577
|
* assembleFromBlock); here it must be a green step's, a list of bareguard text rules that builds into a check.
|
|
578
|
+
* M19 am10: a green step with item fields (`close.itemShape`) and no quote keeps its picks the same way (the step is checked on its `results` and on each pick over `text`).
|
|
576
579
|
* 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.
|
|
577
580
|
* @param {any} step @param {string} label @param {string} effectiveClass @param {string[]} reds @param {Record<string, any>} declaration
|
|
578
581
|
*/
|
|
579
582
|
function checkPickedKey(step, label, effectiveClass, reds, declaration) {
|
|
580
583
|
const at = `declaration: ${label}.close.picked`;
|
|
581
|
-
if (step.close.class !== 'green' || effectiveClass !== 'green' || !(isPlainObject(step.close.cited) || Array.isArray(step.close.sheet))) {
|
|
584
|
+
if (step.close.class !== 'green' || effectiveClass !== 'green' || !(isPlainObject(step.close.cited) || Array.isArray(step.close.sheet) || isPlainObject(step.close.itemShape))) {
|
|
582
585
|
reds.push(`${at} is for a step that checks facts (quotes or a sheet) only; this step's check is "${step.close.class ?? effectiveClass}"`);
|
|
583
586
|
return;
|
|
584
587
|
}
|
|
@@ -590,6 +593,24 @@ function checkPickedKey(step, label, effectiveClass, reds, declaration) {
|
|
|
590
593
|
try { buildSoftgreenRubric({ picked: step.close.picked }); } catch (err) { reds.push(`${at} cannot be built into a check - ${String(err.message).replace(/^invalid rubric: /, '')}`); }
|
|
591
594
|
}
|
|
592
595
|
|
|
596
|
+
/**
|
|
597
|
+
* M19 S5: `close.itemShape` is the signed list-of-items check of a line (a shape part `{fields, minItems?, maxItems?}`, src/shaperows.js), one bareguard `itemShape` check over the answer's `results`; never `close.shape`, which stays the text
|
|
598
|
+
* shape of M10 (amendment E). Code sets it (src/blockassemble.js). Beside `close.cited` (a green step) it is a facts+shape line; its fields are named legally and once, its kinds are on the menu and bareguard itself builds the check.
|
|
599
|
+
* @param {any} step @param {string} label @param {string} effectiveClass @param {string[]} reds
|
|
600
|
+
*/
|
|
601
|
+
function checkItemShapeKey(step, label, effectiveClass, reds) {
|
|
602
|
+
const at = `declaration: ${label}.close.itemShape`;
|
|
603
|
+
const part = step.close.itemShape;
|
|
604
|
+
if (!isPlainObject(part)) { reds.push(`${at} must be an object {fields, minItems, maxItems}`); return; }
|
|
605
|
+
for (const k of Object.keys(part)) if (!['fields', 'minItems', 'maxItems'].includes(k)) reds.push(`${at}: "${k}" is not a field of a list-of-items check (fields, minItems, maxItems)`);
|
|
606
|
+
if (step.close.class !== effectiveClass) reds.push(`${at}: this step's check is "${step.close.class ?? effectiveClass}", which is not the class its line earns`);
|
|
607
|
+
if (step.close.class === 'hitl') reds.push(`${at} is for a step whose answer is checked; this step's check is "hitl"`);
|
|
608
|
+
const fact = isPlainObject(step.close.cited) ? step.close.cited : null;
|
|
609
|
+
if (fact === null && step.close.class === 'softgreen' && step.close.shape !== undefined) reds.push(`${at}: a list-of-items line whose check reads its reply cannot also carry a text check (close.shape); its answer has no text`);
|
|
610
|
+
if (fact === null && Array.isArray(step.close.sheet)) reds.push(`${at}: a line is a list-of-items line or a sheet line, not both`);
|
|
611
|
+
shapeShapeReds(part, at, (_c, path, d) => reds.push(`${path}: ${d}`), fact);
|
|
612
|
+
}
|
|
613
|
+
|
|
593
614
|
/**
|
|
594
615
|
* 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
616
|
* 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.
|
|
@@ -798,6 +819,8 @@ export function validateDeclaration(declaration, context = {}) {
|
|
|
798
819
|
|
|
799
820
|
// --- guardrailClasses (REQUIRED — the harness always writes it; empty {}
|
|
800
821
|
// is fine, missing entirely is not) ------------------------------------
|
|
822
|
+
// M19 am15 (F257): a line with no `~` of the person's own may carry a class only when the plan's list holds a built `!` check on that line (one the person Added, or one code built from the line's own words, M19 am15a)
|
|
823
|
+
const addedLines = new Set((Array.isArray(declaration.checkList) ? declaration.checkList : []).filter((r) => isPlainObject(r) && r.by === 'agent' && r.state === 'built' && r.kind !== 'floor' && Number.isInteger(r.line)).map((r) => r.line));
|
|
801
824
|
let guardrailClasses = {};
|
|
802
825
|
if (!Object.prototype.hasOwnProperty.call(declaration, 'guardrailClasses')) {
|
|
803
826
|
reds.push('declaration: "guardrailClasses" is required (an object keyed by line number; {} is fine)');
|
|
@@ -806,7 +829,7 @@ export function validateDeclaration(declaration, context = {}) {
|
|
|
806
829
|
for (const key of Object.keys(guardrailClasses)) {
|
|
807
830
|
const n = Number(key);
|
|
808
831
|
const line = Number.isInteger(n) ? safeLines.find((l) => l.n === n) : undefined;
|
|
809
|
-
if (!line || !line.guardrail) {
|
|
832
|
+
if (!line || (!line.guardrail && !addedLines.has(n))) {
|
|
810
833
|
reds.push(`declaration: guardrailClasses key "${key}" does not name a signed line with a guardrail`);
|
|
811
834
|
continue;
|
|
812
835
|
}
|
|
@@ -1011,7 +1034,7 @@ export function validateDeclaration(declaration, context = {}) {
|
|
|
1011
1034
|
if (fromLine !== null && typeof fromLine !== 'number') {
|
|
1012
1035
|
reds.push(`declaration: ${label}.fromLine must be an integer or null`);
|
|
1013
1036
|
} else {
|
|
1014
|
-
const resolved = deriveFromLine(fromLine, safeLines, guardrailClasses);
|
|
1037
|
+
const resolved = deriveFromLine(fromLine, safeLines, guardrailClasses, addedLines);
|
|
1015
1038
|
if (!resolved.ok) {
|
|
1016
1039
|
reds.push(`declaration: ${label} ${resolved.error}`);
|
|
1017
1040
|
} else {
|
|
@@ -1049,6 +1072,7 @@ export function validateDeclaration(declaration, context = {}) {
|
|
|
1049
1072
|
}
|
|
1050
1073
|
if (step.close.numbersFrom !== undefined) checkNumbersFromKey(step, label, steps, reds);
|
|
1051
1074
|
if (step.close.cited !== undefined) checkCitedKey(step, label, { sourceRoles, reads, effectiveClass, lines: safeLines, fitJobLine, pageWords }, reds);
|
|
1075
|
+
if (step.close.itemShape !== undefined) checkItemShapeKey(step, label, effectiveClass, reds);
|
|
1052
1076
|
if (step.close.sheet !== undefined) checkSheetKey(step, label, { cellsRoles, reads, effectiveClass, lines: safeLines, fitJobLine, sheetWords }, reds);
|
|
1053
1077
|
if (step.close.columns !== undefined || (fitJobLine === true && sheetWords)) checkColumnsKey(step, label, { cellsRoles, reads, effectiveClass, lines: safeLines, sheetWords }, reds);
|
|
1054
1078
|
}
|
|
@@ -1063,7 +1087,7 @@ export function validateDeclaration(declaration, context = {}) {
|
|
|
1063
1087
|
// M4d amendment 8: a step whose check is green (every figure cites a source cell) must read an input with cells; a text
|
|
1064
1088
|
// output of an earlier step has no cells to cite.
|
|
1065
1089
|
// M10 am7: a green step that cites quotes (`close.cited`) reads a web page, which has no cells; its source is checked above.
|
|
1066
|
-
if (fitJobLine === true && effectiveClass === 'green' && reads !== null && !reads.some((r) => cellsRoles.includes(r)) && !isPlainObject(step.close?.cited)) {
|
|
1090
|
+
if (fitJobLine === true && effectiveClass === 'green' && reads !== null && !reads.some((r) => cellsRoles.includes(r)) && !isPlainObject(step.close?.cited) && !isPlainObject(step.close?.itemShape)) {
|
|
1067
1091
|
const n = fromLine;
|
|
1068
1092
|
const reading = reads.length === 0 ? 'it reads nothing' : `it reads only ${reads.join(', ')}`;
|
|
1069
1093
|
const want = cellsRoles.length === 0 ? 'a spreadsheet input, and this job signs none' : cellsRoles.join(' or ');
|
|
@@ -1073,7 +1097,7 @@ export function validateDeclaration(declaration, context = {}) {
|
|
|
1073
1097
|
// M10b piece 5 (item 8): the old cell cite retires for CSV. A green step that reads a spreadsheet answers in bareguard's claim boxes (`close.sheet`);
|
|
1074
1098
|
// one with neither `close.sheet` nor `close.cited` would be the old cite close, which a new plan no longer offers. Signed flows keep running (fitJobLine only).
|
|
1075
1099
|
if (fitJobLine === true && effectiveClass === 'green' && reads !== null && reads.some((r) => cellsRoles.includes(r))
|
|
1076
|
-
&& !isPlainObject(step.close?.cited) && !Array.isArray(step.close?.sheet)) {
|
|
1100
|
+
&& !isPlainObject(step.close?.cited) && !isPlainObject(step.close?.itemShape) && !Array.isArray(step.close?.sheet)) {
|
|
1077
1101
|
reds.push(`declaration: Line ${fromLine}'s check cannot cite cells any more. Line ${fromLine} must carry close.sheet: bareguard's checks of ${reads.filter((r) => cellsRoles.includes(r)).join(' or ')}.`);
|
|
1078
1102
|
}
|
|
1079
1103
|
|