bareloop 0.55.0 → 0.57.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/CHANGELOG.md +82 -0
- package/README.md +3 -3
- package/bareloop.context.md +69 -209
- package/package.json +2 -2
- package/src/authorflow.js +164 -340
- package/src/authoring.js +7 -127
- package/src/authorjob.js +139 -472
- package/src/authorreadout.js +24 -368
- package/src/authorrun.js +21 -215
- package/src/behaviour.js +14 -0
- package/src/blockasks.js +43 -0
- package/src/bundlerun.js +4 -1
- package/src/checkblock.js +798 -0
- package/src/checklist.js +128 -0
- package/src/checkpick.js +39 -312
- package/src/checkwords.js +3 -1
- package/src/cli.js +3 -3
- package/src/declaredclose.js +38 -108
- package/src/destpoint.js +4 -2
- package/src/draftspend.js +46 -0
- package/src/facts.js +8 -1
- package/src/index.js +3 -43
- package/src/interviewrun.js +13 -8
- package/src/job.js +20 -1
- package/src/jobblock.js +11 -46
- package/src/judged.js +13 -1229
- package/src/kinds.js +5 -347
- package/src/noteask.js +124 -0
- package/src/pagedry.js +27 -5
- package/src/pagemap.js +15 -3
- package/src/pagerules.js +18 -3
- package/src/panel/authorroutes.js +24 -6
- package/src/panel/authorsession.js +222 -177
- package/src/panel/importrun.js +0 -1
- package/src/panel/index.html +198 -26
- package/src/panel/jobplan.js +87 -33
- package/src/panel/server.js +74 -68
- package/src/panel/status.js +3 -0
- package/src/pickrecord.js +34 -55
- package/src/placerule.js +355 -0
- package/src/planrun.js +2 -48
- package/src/promptregisters.js +13 -17
- package/src/providerrows.js +0 -36
- package/src/providers.js +4 -25
- package/src/questionbox.js +104 -0
- package/src/rowedit.js +115 -0
- package/src/rubricstep.js +234 -127
- package/src/run.js +11 -16
- package/src/userrun.js +60 -112
- package/types/authorflow.d.ts +41 -197
- package/types/authoring.d.ts +1 -14
- package/types/authorjob.d.ts +35 -59
- package/types/authorreadout.d.ts +10 -88
- package/types/behaviour.d.ts +12 -0
- package/types/blockasks.d.ts +36 -0
- package/types/checkblock.d.ts +376 -0
- package/types/checklist.d.ts +134 -0
- package/types/checkpick.d.ts +8 -140
- package/types/cli.d.ts +1 -3
- package/types/declaredclose.d.ts +7 -33
- package/types/destpoint.d.ts +2 -0
- package/types/draftspend.d.ts +21 -0
- package/types/index.d.ts +2 -4
- package/types/job.d.ts +8 -0
- package/types/jobblock.d.ts +8 -38
- package/types/judged.d.ts +7 -357
- package/types/kinds.d.ts +3 -104
- package/types/noteask.d.ts +76 -0
- package/types/pagedry.d.ts +13 -0
- package/types/pagemap.d.ts +4 -0
- package/types/pagerules.d.ts +7 -0
- package/types/panel/authorsession.d.ts +47 -5
- package/types/panel/jobgrid.d.ts +8 -8
- package/types/panel/jobplan.d.ts +48 -10
- package/types/panel/server.d.ts +27 -18
- package/types/panel/status.d.ts +5 -0
- package/types/pickrecord.d.ts +20 -13
- package/types/placerule.d.ts +194 -0
- package/types/planrun.d.ts +1 -22
- package/types/providerrows.d.ts +0 -31
- package/types/providers.d.ts +3 -19
- package/types/questionbox.d.ts +87 -0
- package/types/rowedit.d.ts +32 -0
- package/types/rubricstep.d.ts +100 -48
- package/types/run.d.ts +9 -19
- package/types/userrun.d.ts +0 -1
- package/src/calibrate.js +0 -702
- package/src/cardauthor.js +0 -502
- package/src/fitcheck.js +0 -166
- package/types/calibrate.d.ts +0 -201
- package/types/cardauthor.d.ts +0 -358
- package/types/fitcheck.d.ts +0 -113
package/src/rubricstep.js
CHANGED
|
@@ -3,7 +3,7 @@ import { readFile, lstat } from 'node:fs/promises';
|
|
|
3
3
|
import { join, dirname } from 'node:path';
|
|
4
4
|
import { createRubric, checkStep, renderGaps, numbersInQuote } from 'bareguard';
|
|
5
5
|
import { dropRows, dropLine } from './pagedropwords.js';
|
|
6
|
-
import { OFFERED } from './checkwords.js';
|
|
6
|
+
import { OFFERED, plainWords } from './checkwords.js';
|
|
7
7
|
import { factPartOf, factShapeReds, factDecides, factClaims, factRows, plainFactItem, factBrief, writtenSpans } from './facts.js';
|
|
8
8
|
|
|
9
9
|
// PART 1a (docs/product/ITEM33-BUILD.md, "Addendum 2026-10-12"): the rubric job on LOCAL FILES — what one job line leaves
|
|
@@ -48,6 +48,26 @@ export function stepFileContract() {
|
|
|
48
48
|
].join('\n');
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
/**
|
|
52
|
+
* R10 (fwd am28, rewritten here): what a facts+text line's worker is told about the person's picks, one plain line per pick, the values and what counts, never a verdict and never any other
|
|
53
|
+
* check. Written by code from the signed pick parts; a list item is what bareguard's listItems counts (its own line starting with "1." or "- " and a space).
|
|
54
|
+
* @param {any[]} picked countable parts (`{check, value, names, ...}`) @returns {string[]}
|
|
55
|
+
*/
|
|
56
|
+
export function toldPicks(picked) {
|
|
57
|
+
const list = (/** @type {unknown} */ v) => (Array.isArray(v) ? v.map((x) => String(x)).join(', ') : '');
|
|
58
|
+
return picked.map((p) => {
|
|
59
|
+
switch (p.check) {
|
|
60
|
+
case 'listItems': return `Your "text" must have exactly ${p.value} list items; a list item is its own line starting with "1." or "- " followed by a space and its text.`;
|
|
61
|
+
case 'maxListItems': return `Your "text" must have at most ${p.value} list items; a list item is its own line starting with "1." or "- " followed by a space and its text.`;
|
|
62
|
+
case 'minListItems': return `Your "text" must have at least ${p.value} list items; a list item is its own line starting with "1." or "- " followed by a space and its text.`;
|
|
63
|
+
case 'nonEmpty': return 'Your "text" must not be empty.';
|
|
64
|
+
case 'mustCarry': return `Your "text" must carry ${list(p.phrases)}.`;
|
|
65
|
+
case 'blockLines': return `Your "text" must be in blocks of ${p.size} lines, each carrying ${list(p.phrases)}.`;
|
|
66
|
+
default: return `Your "text" must have ${plainWords({ ...p, rule: p.check })}.`;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
51
71
|
/**
|
|
52
72
|
* What the worker is told about each line, from the close that will grade it (PART 1b item 7): a FACTS line gets its
|
|
53
73
|
* facts and its count; a TEXT line that follows a facts line is told its numbers come from that line's quotes. Written by code from
|
|
@@ -69,12 +89,16 @@ export function lineBriefs(closeDecl) {
|
|
|
69
89
|
: c.min !== undefined ? `at least ${c.min} results` : `at most ${c.max} results`;
|
|
70
90
|
// keep-both: the person's picks (countable parts) sit beside the fact on this line, so the same file also carries the "text" they limit
|
|
71
91
|
const alsoText = st.params.parts.some((/** @type {any} */ q) => isRec(q) && q.class === 'countable');
|
|
92
|
+
// R10 (fwd am28): the picks among them, as the signed close's own record names them, are told to the worker in plain words
|
|
93
|
+
const record = Array.isArray(closeDecl.picks) ? closeDecl.picks : [];
|
|
94
|
+
const picked = st.params.parts.filter((/** @type {any} */ q) => isRec(q) && q.class === 'countable' && OFFERED.includes(q.check) && record.some((/** @type {any} */ x) => isRec(x) && x.line === n && sameJson(x.part, q)));
|
|
72
95
|
out.push({
|
|
73
96
|
line: n,
|
|
74
97
|
text: [
|
|
75
98
|
alsoText
|
|
76
99
|
? `Job line ${n} is a FACTS line AND a TEXT line. Write ${stepFileRel(n)} as {"results": [{"quote": "...", "values": {...}}], "text": "..."} — the results are the facts below, the "text" is your answer to the line in your own words (its limits are in the line's ~ rules); no "cites".`
|
|
77
100
|
: `Job line ${n} is a FACTS line. Write ${stepFileRel(n)} as {"results": [{"quote": "...", "values": {...}}]} and nothing else — no "text", no "cites".`,
|
|
101
|
+
...(alsoText && picked.length ? toldPicks(picked).map((t) => ` ${t}`) : []),
|
|
78
102
|
` One result per thing you find in the input "${fp.source}": ${count}.`,
|
|
79
103
|
' "quote": ONE quote per result, copied exactly from that result\'s own text in the input (at most 4000 characters) — never joined from two results.',
|
|
80
104
|
' "values": one entry per fact below, written exactly as the quote writes it (for example "9:27 AM", not "09:27"; "389", not "389.00").',
|
|
@@ -165,6 +189,8 @@ export const COUNT_CHECKS = Object.freeze({
|
|
|
165
189
|
// R10 (bareguard 0.31, fwdloop v0.29.0 OFFERED): the five text checks a person's pick may carry; the drafter never writes them
|
|
166
190
|
nonEmpty: Object.freeze([]),
|
|
167
191
|
listItems: Object.freeze(['value']),
|
|
192
|
+
maxListItems: Object.freeze(['value']), // bareguard 0.35 (F315): an at-most / at-least bound on the list items, beside the exact listItems
|
|
193
|
+
minListItems: Object.freeze(['value']),
|
|
168
194
|
sectionOrder: Object.freeze(['names']),
|
|
169
195
|
mustCarry: Object.freeze(['phrases']),
|
|
170
196
|
blockLines: Object.freeze(['size', 'phrases']),
|
|
@@ -280,7 +306,7 @@ export function buildStepSpec(params, inputShas) {
|
|
|
280
306
|
case 'sections': checks.push({ id, rule: 'sections', field: 'text', names: [...part.names] }); break;
|
|
281
307
|
case 'sectionWords': checks.push({ id, rule: 'sectionWords', field: 'text', names: [...part.names], wordsPerSection: part.wordsPerSection }); break;
|
|
282
308
|
case 'nonEmpty': checks.push({ id, rule: 'nonEmpty', field: 'text' }); break;
|
|
283
|
-
case 'listItems': checks.push({ id, rule:
|
|
309
|
+
case 'listItems': case 'maxListItems': case 'minListItems': checks.push({ id, rule: part.check, field: 'text', value: part.value }); break;
|
|
284
310
|
case 'sectionOrder': checks.push({ id, rule: 'sectionOrder', field: 'text', names: [...part.names] }); break;
|
|
285
311
|
case 'mustCarry': checks.push({ id, rule: 'mustCarry', field: 'text', phrases: [...part.phrases] }); break;
|
|
286
312
|
case 'blockLines': checks.push({ id, rule: 'blockLines', field: 'text', size: part.size, phrases: [...part.phrases] }); break;
|
|
@@ -417,6 +443,8 @@ export function plainStepGap(step, why, g, params = null) {
|
|
|
417
443
|
if (g.check === 'minWords') return `${at}: "text" has ${g.measured} words, at least ${g.limit} are required`;
|
|
418
444
|
if (g.check === 'maxLines') return `${at}: "text" has ${g.measured} lines, at most ${g.limit} are allowed`;
|
|
419
445
|
if (g.check === 'sections') return `${at}: "text" is missing section(s): ${(g.items ?? []).join(', ')}`;
|
|
446
|
+
if (g.check === 'maxListItems') return `${at}: "text" has ${g.measured} list items, at most ${g.limit} are allowed`;
|
|
447
|
+
if (g.check === 'minListItems') return `${at}: "text" has ${g.measured} list items, at least ${g.limit} are required`;
|
|
420
448
|
if (g.check === 'listItems') return `${at}: "text" has ${g.measured} list items, exactly ${g.limit} are required`;
|
|
421
449
|
if (g.check === 'sectionOrder') return `${at}: "text" does not hold its sections in the asked order (${(g.items ?? []).map((/** @type {string} */ x) => x.replace(/^[^:]*:/, '')).join(', ')} out of place)`;
|
|
422
450
|
if (g.check === 'mustCarry') return `${at}: "text" does not carry: ${(g.items ?? []).join(', ')}`;
|
|
@@ -641,7 +669,8 @@ export function checkRubricParts(stages, { inputLabels = null, red, picks = null
|
|
|
641
669
|
return;
|
|
642
670
|
}
|
|
643
671
|
// keep-both: a fact line may carry a countable part only when it IS one of the person's recorded picks (an offered check, its `rules`, the same line, the same words)
|
|
644
|
-
const
|
|
672
|
+
const isNote = factLine && isDefaultNote(part, step);
|
|
673
|
+
const isPick = isNote || factLine && Array.isArray(picks) && picks.some((x) => isRec(x) && x.line === step && sameJson(x.part, part)) && OFFERED.includes(part.check) && Array.isArray(part.rules);
|
|
645
674
|
if (factLine && !isPick) {
|
|
646
675
|
red('rubric-fact-text', w, `line ${line}: '${said}' counts or quotes free text, but this line lists facts and has no text. Say it as a fact (a shape and a rule) or remove it. Nothing spent.`, { line: step, stage: label });
|
|
647
676
|
return;
|
|
@@ -762,117 +791,137 @@ export function checkRubricRules(stages, { jobLines = null, refused = null, red
|
|
|
762
791
|
/** a clock time as a person writes it: 7:00, 07:00, 7:00 AM, 11 PM is not matched (no minutes) */
|
|
763
792
|
const CLOCK = '\\d{1,2}:\\d{2}(?:\\s?[AaPp][Mm])?';
|
|
764
793
|
const TIME_RANGE_RE = new RegExp(`\\b(?:between|from)\\s+(${CLOCK})\\s+(?:and|to|-)\\s+(${CLOCK})`, 'i');
|
|
765
|
-
const NEGATING_RE = /\b(?:not|no|never|outside|except|before|after|without)\b/i;
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
*/
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
const facts = fp.facts.map((/** @type {any} */ f) => {
|
|
790
|
-
if (!isRec(f) || !isRec(f.rule) || f.aiProposal !== true) return f;
|
|
791
|
-
const own = (/** @type {unknown[]} */ bounds) => bounds.every((b) => boundInWords(b, said));
|
|
792
|
-
const bounds = f.rule.op === 'between' ? [f.rule.lo, f.rule.hi] : [f.rule.value];
|
|
793
|
-
const { aiProposal: _drop, ...rest } = f;
|
|
794
|
-
if (own(bounds)) return rest;
|
|
795
|
-
if (ranges.length === 1 && proposed.length === 1 && proposed[0] === f) {
|
|
796
|
-
const m = /** @type {RegExpExecArray} */ (ranges[0]);
|
|
797
|
-
return { ...rest, rule: { op: 'between', lo: m[1], hi: m[2] } };
|
|
798
|
-
}
|
|
799
|
-
return f;
|
|
800
|
-
});
|
|
801
|
-
const parts = st.params.parts.map((/** @type {any} */ x) => (x === fp ? { ...x, facts } : x));
|
|
802
|
-
return { ...st, params: { ...st.params, parts } };
|
|
803
|
-
});
|
|
804
|
-
const carried = (/** @type {number} */ line, /** @type {number} */ n) => stages.some((/** @type {any} */ st) => isRec(st) && st.kind === 'rubric-step' && isRec(st.params) && st.params.step === line
|
|
805
|
-
&& Array.isArray(st.params.parts) && st.params.parts.some((/** @type {any} */ x) => isRec(x) && Array.isArray(x.rules) && x.rules.includes(n)));
|
|
806
|
-
/** @type {any} */
|
|
807
|
-
const out = { ...declaration, stages };
|
|
808
|
-
if (Array.isArray(declaration.refused)) out.refused = declaration.refused.filter((/** @type {any} */ r) => !(isRec(r) && Number.isInteger(r.line) && Number.isInteger(r.rule) && carried(r.line, r.rule)));
|
|
809
|
-
return out;
|
|
794
|
+
export const NEGATING_RE = /\b(?:not|no|never|outside|except|before|after|without)\b/i;
|
|
795
|
+
|
|
796
|
+
// The limit reader (hamr ruling A, 2026-11-12): when the look tied a money or time fact to a `~` rule but gave no limit, CODE reads the limit
|
|
797
|
+
// from the person's own rule words. ONE amount or ONE range only; every other text is a plain reason (Not checked), never a wrong check.
|
|
798
|
+
// The direction words are the FACT_OPS words of src/facts.js (lt under, lte at most, gt over, gte at least) plus their plain synonyms.
|
|
799
|
+
const AMOUNT = '(?:[$\\u20ac\\u00a3]\\s?(\\d[\\d,]*(?:\\.\\d+)?)|(\\d[\\d,]*(?:\\.\\d+)?)\\s?(?:US\\s)?(?:dollars?|euros?|pounds?|USD|EUR|GBP)\\b)';
|
|
800
|
+
const AMOUNT_ALL_RE = new RegExp(AMOUNT, 'gi');
|
|
801
|
+
const MONEY_BETWEEN_RE = new RegExp(`\\bbetween\\s+${AMOUNT}\\s+(?:and|to|-)\\s+${AMOUNT}`, 'i');
|
|
802
|
+
const MONEY_DIRECTION_RE = new RegExp(`\\b(under|below|less than|fewer than|at most|up to|no more than|over|above|more than|at least|no less than|no fewer than)\\s+${AMOUNT}`, 'i');
|
|
803
|
+
const MONEY_OR_LESS_RE = new RegExp(`${AMOUNT}\\s+or\\s+(less|fewer|under|below|lower|more|over|above|higher)\\b`, 'i');
|
|
804
|
+
const DIRECTION_OP = /** @type {Record<string, 'lt'|'lte'|'gt'|'gte'>} */ ({ under: 'lt', below: 'lt', 'less than': 'lt', 'fewer than': 'lt', 'at most': 'lte', 'up to': 'lte', 'no more than': 'lte', over: 'gt', above: 'gt', 'more than': 'gt', 'at least': 'gte', 'no less than': 'gte', 'no fewer than': 'gte' });
|
|
805
|
+
const CURRENCY_STEM = /** @type {Record<string, string>} */ ({ $: 'dollar', '€': 'euro', '£': 'pound', usd: 'dollar', eur: 'euro', gbp: 'pound' });
|
|
806
|
+
const num = (/** @type {string|undefined} */ a, /** @type {string|undefined} */ b) => Number(String(a ?? b).replace(/,/g, ''));
|
|
807
|
+
const hhmm = (/** @type {string} */ t) => (/[AaPp][Mm]/.test(t) ? null : t.replace(/\s+/g, '').replace(/^(\d):/, '0$1:'));
|
|
808
|
+
|
|
809
|
+
/** does the amount token's currency (sign or word) fit the look fact's currency and unit lists? A fact with neither list fits anything. */
|
|
810
|
+
function currencyFits(/** @type {string} */ tok, /** @type {any} */ fact) {
|
|
811
|
+
const cur = (Array.isArray(fact?.currency) ? fact.currency : fact?.currency ? [fact.currency] : []).map(String);
|
|
812
|
+
const unit = (Array.isArray(fact?.unit) ? fact.unit : fact?.unit ? [fact.unit] : []).map((/** @type {unknown} */ u) => String(u).toLowerCase());
|
|
813
|
+
if (!cur.length && !unit.length) return true;
|
|
814
|
+
const sym = /^[$€£]/.test(tok) ? tok.charAt(0) : null;
|
|
815
|
+
const last = String(tok.trim().split(/\s+/).at(-1)).toLowerCase();
|
|
816
|
+
const stem = sym ? CURRENCY_STEM[sym] : (CURRENCY_STEM[last] ?? last.replace(/s$/, ''));
|
|
817
|
+
return (sym !== null && cur.includes(sym)) || unit.some((/** @type {string} */ u) => u.includes(String(stem)));
|
|
810
818
|
}
|
|
811
819
|
|
|
812
820
|
/**
|
|
813
|
-
*
|
|
814
|
-
*
|
|
815
|
-
*
|
|
816
|
-
* @param {any} declaration @returns {any}
|
|
821
|
+
* Does this rule text hold more than one amount (money) or more than one time range (time)? The ONE guard code's own limit read and an AI
|
|
822
|
+
* reading edit both use: "under $450 or over $900" is two limits, and one reading of it would be a wrong check.
|
|
823
|
+
* @param {string} shape @param {string} text @returns {boolean}
|
|
817
824
|
*/
|
|
818
|
-
export function
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
const
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
if (
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
825
|
+
export function holdsManyBounds(shape, text) {
|
|
826
|
+
const t = String(text ?? '');
|
|
827
|
+
if (shape === 'time') return [...t.matchAll(new RegExp(TIME_RANGE_RE.source, 'gi'))].length > 1 || (t.match(/\d{1,2}:\d{2}/g) ?? []).length > 2;
|
|
828
|
+
if (shape === 'money') { const amts = [...t.matchAll(AMOUNT_ALL_RE)]; return amts.length > 1 && !(MONEY_BETWEEN_RE.test(t) && amts.length === 2); }
|
|
829
|
+
return false;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
/** the plain reason a rule's amount is in a currency the page fact does not use; `readLimit` gives it and the check list reads it, one spelling */
|
|
833
|
+
export const WHY_OTHER_CURRENCY = 'the amount is in another currency than the page fact';
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* The limit the person's own words give a fact of this shape: `{reading}` or `{why}` (a plain reason; the rule then stays Not checked).
|
|
837
|
+
* @param {string} shape money or time @param {string} text the `~` rule's words @param {any} [fact] the look fact (its currency and unit lists must fit)
|
|
838
|
+
* @returns {{reading: {op: 'lt'|'lte'|'gt'|'gte', value: number} | {op: 'between', lo: number|string, hi: number|string}} | {why: string}}
|
|
839
|
+
*/
|
|
840
|
+
export function readLimit(shape, text, fact = {}) {
|
|
841
|
+
const t = String(text ?? '');
|
|
842
|
+
if (shape === 'time') {
|
|
843
|
+
if (NEGATING_RE.test(t)) return { why: 'a one-sided or negated time (before, after, not) is not a range code can read' };
|
|
844
|
+
if (/\b\d{1,2}(?::\d{2})?\s?[ap]\.?m\b/i.test(t)) return { why: 'a 12-hour time (am or pm) is not read, write it like 06:00' };
|
|
845
|
+
if (holdsManyBounds('time', t)) return { why: 'more than one time range in the rule' };
|
|
846
|
+
const m = TIME_RANGE_RE.exec(t);
|
|
847
|
+
if (!m) return { why: 'no range between two times in the rule' };
|
|
848
|
+
const lo = hhmm(String(m[1])), hi = hhmm(String(m[2]));
|
|
849
|
+
if (!lo || !hi) return { why: 'a 12-hour time (am or pm) is not read, write it like 06:00' };
|
|
850
|
+
if (lo >= hi) return { why: 'a range whose end is not after its start is not read' };
|
|
851
|
+
return { reading: { op: 'between', lo, hi } };
|
|
852
|
+
}
|
|
853
|
+
if (shape === 'money') {
|
|
854
|
+
if (/\b(?:not|never|outside|except|without)\b/i.test(t)) return { why: 'a negated limit (not, except, without) is not read' };
|
|
855
|
+
const amts = [...t.matchAll(AMOUNT_ALL_RE)];
|
|
856
|
+
if (!amts.length) return { why: 'no amount with a currency sign or word in the rule' };
|
|
857
|
+
for (const a of amts) if (!currencyFits(a[0], fact)) return { why: WHY_OTHER_CURRENCY };
|
|
858
|
+
if (holdsManyBounds('money', t)) return { why: 'more than one amount in the rule' };
|
|
859
|
+
const b = MONEY_BETWEEN_RE.exec(t);
|
|
860
|
+
if (b) { const lo = num(b[1], b[2]), hi = num(b[3], b[4]); return lo < hi ? { reading: { op: 'between', lo, hi } } : { why: 'a range whose end is not above its start is not read' }; }
|
|
861
|
+
const d = MONEY_DIRECTION_RE.exec(t);
|
|
862
|
+
if (d) return { reading: { op: /** @type {'lt'|'lte'|'gt'|'gte'} */ (DIRECTION_OP[String(d[1]).toLowerCase()]), value: num(d[2], d[3]) } };
|
|
863
|
+
const o = MONEY_OR_LESS_RE.exec(t);
|
|
864
|
+
if (o) return { reading: { op: /^(less|fewer|under|below|lower)$/i.test(String(o[3])) ? 'lte' : 'gte', value: num(o[1], o[2]) } };
|
|
865
|
+
return { why: 'the rule gives an amount but no direction (under, over, at most, at least, between)' };
|
|
859
866
|
}
|
|
860
|
-
return {
|
|
867
|
+
return { why: 'code reads a limit only for money or time' };
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
/** the words a list row of kind `$cited` / `$numbers` carries no text for */
|
|
871
|
+
const DEFAULT_ROW_WORDS = Object.freeze({ cited: 'every claim quotes its input', numbers: 'every number matches a quote', note: 'the note' });
|
|
872
|
+
|
|
873
|
+
/**
|
|
874
|
+
* A check-list row named in the person's plain words: `phrase "### Fixed"`. The words are the draft log's; with none, the text after the key's kind prefix (`L1.phrase.### fixed`).
|
|
875
|
+
* Never empty. Pure.
|
|
876
|
+
* @param {unknown} kind @param {string} key @param {string[]|null|undefined} words
|
|
877
|
+
* @returns {string}
|
|
878
|
+
*/
|
|
879
|
+
export function listRowName(kind, key, words) {
|
|
880
|
+
const k = typeof kind === 'string' && kind ? kind : 'check';
|
|
881
|
+
if (k === 'cited' || k === 'numbers' || k === 'note') return DEFAULT_ROW_WORDS[k];
|
|
882
|
+
const tail = key.replace(/^L\d+\.(?:[^.]*\.)?/, '').trim();
|
|
883
|
+
const w = Array.isArray(words) && words.length ? words : [tail || key];
|
|
884
|
+
return `${k} ${w.map((x) => `"${x}"`).join(', ')}`;
|
|
861
885
|
}
|
|
862
886
|
|
|
863
887
|
/**
|
|
864
888
|
* The ~ rules the drafter listed under Not checked (`refused` entries that name a `rule`), each as one line in the person's own
|
|
865
889
|
* words: `line N: "<the rule as written>" — <the drafter's reason>` (PART 1b, RF6 / RF16).
|
|
866
|
-
* @param {any} closeDecl @param {any[]|null|undefined} jobLines @returns {string[]}
|
|
890
|
+
* @param {any} closeDecl @param {any[]|null|undefined} jobLines @param {{key: string, words: string[]}[]|null} [ledger] the draft log's final list rows (`readDraftLedger`) @returns {string[]}
|
|
867
891
|
*/
|
|
868
|
-
export function ruleNotChecked(closeDecl, jobLines) {
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
892
|
+
export function ruleNotChecked(closeDecl, jobLines, ledger = null) {
|
|
893
|
+
return ruleNotCheckedItems(closeDecl, jobLines, ledger).map((i) => i.text);
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
/** the same lines as {@link ruleNotChecked}, each with who it belongs to (`by`: the row's kind, F-c) @param {any} closeDecl @param {any[]|null|undefined} jobLines @param {{key: string, words: string[]}[]|null} [ledger] @returns {{text: string, by?: 'you'|'agent'|'default'}[]} */
|
|
897
|
+
export function ruleNotCheckedItems(closeDecl, jobLines, ledger = null) {
|
|
898
|
+
return refusedOf(closeDecl).filter((r) => Number.isInteger(r.rule) || r.fromList).map((r) => {
|
|
899
|
+
const text = Number.isInteger(r.rule) ? lineRules((jobLines ?? []).find((/** @type {any} */ l) => isRec(l) && l.n === r.line))[/** @type {number} */ (r.rule) - 1] : (r.label ?? null);
|
|
900
|
+
const by = r.by ? { by: r.by } : {};
|
|
901
|
+
// a list row that is not a fact or a rule is named by its words, as the Job tab names it (one owner: listRowName)
|
|
902
|
+
if (!text && r.fromList && r.key) return { text: `line ${r.line}: ${listRowName(r.kind, r.key, ledger?.find((x) => x.key === r.key)?.words)} — ${r.reason}`, ...by };
|
|
903
|
+
return { text: `line ${r.line}: ${text ? `"${text}"` : `rule ${r.rule ?? r.kind}`} — ${r.reason}`, ...by };
|
|
873
904
|
});
|
|
874
905
|
}
|
|
875
906
|
|
|
907
|
+
/**
|
|
908
|
+
* The refusals of a signed close, as ONE reader: when the close carries the one check list (`closeDecl.list`) its not-checked rows are the refusals (a `~` rule's row names the rule, a fact row its
|
|
909
|
+
* fact name); the old `closeDecl.refused` entries a list has no row for (a line-level refusal, a rule the list never saw) are kept, so nothing the older close said is lost. A close with no list
|
|
910
|
+
* reads `refused` alone. Pure.
|
|
911
|
+
* @param {any} closeDecl
|
|
912
|
+
* @returns {{line: number, rule?: number, kind?: string, key?: string, by?: 'you'|'agent'|'default', label?: string, reason: string, fromList: boolean}[]}
|
|
913
|
+
*/
|
|
914
|
+
export function refusedOf(closeDecl) {
|
|
915
|
+
const old = (isRec(closeDecl) && Array.isArray(closeDecl.refused) ? closeDecl.refused : []).filter((/** @type {any} */ r) => isRec(r) && Number.isInteger(r.line) && typeof r.reason === 'string');
|
|
916
|
+
const list = isRec(closeDecl) && Array.isArray(closeDecl.list) ? closeDecl.list : null;
|
|
917
|
+
if (list === null) return old.map((/** @type {any} */ r) => ({ line: r.line, ...(Number.isInteger(r.rule) ? { rule: r.rule } : {}), reason: r.reason, fromList: false }));
|
|
918
|
+
const rows = list.filter((/** @type {any} */ r) => isRec(r) && r.state === 'not-checked' && Number.isInteger(r.line) && typeof r.reason === 'string' && r.kind !== 'floor').map((/** @type {any} */ r) => ({
|
|
919
|
+
line: r.line, ...(Number.isInteger(r.rule) ? { rule: r.rule } : {}), kind: String(r.kind), key: String(r.key), ...(['you', 'agent', 'default'].includes(r.by) ? { by: r.by } : {}), ...(r.kind === 'fact' ? { label: String(r.key).split('.').slice(2).join('.') } : {}), reason: r.reason, fromList: true,
|
|
920
|
+
}));
|
|
921
|
+
const seen = (/** @type {any} */ r) => rows.some((x) => x.line === r.line && x.rule === (Number.isInteger(r.rule) ? r.rule : undefined) && Number.isInteger(r.rule));
|
|
922
|
+
return [...rows, ...old.filter((/** @type {any} */ r) => !seen(r)).map((/** @type {any} */ r) => ({ line: r.line, ...(Number.isInteger(r.rule) ? { rule: r.rule } : {}), reason: r.reason, fromList: false }))];
|
|
923
|
+
}
|
|
924
|
+
|
|
876
925
|
/**
|
|
877
926
|
* The Not-checked lines code owns for the rubric-step stages of a close: a prose step's CONTENT is judged by the person at
|
|
878
927
|
* Accept, and the card says so (PART 1b, RF5). One line per prose step (a stage with no fact part).
|
|
@@ -905,8 +954,10 @@ export function partSentence(part) {
|
|
|
905
954
|
case 'maxLines': return `the text is at most ${n(part.value, 'line')}`;
|
|
906
955
|
case 'sections': return `the text has the section(s): ${list(part.names)}`;
|
|
907
956
|
case 'sectionWords': return `each section (${list(part.names)}) is about ${part.wordsPerSection} words`;
|
|
908
|
-
case 'nonEmpty': return 'the text is not empty';
|
|
957
|
+
case 'nonEmpty': return /^line \d+ writes a note — the note must be there$/.test(String(part.text)) ? String(part.text) : 'the text is not empty';
|
|
909
958
|
case 'listItems': return `the text has exactly ${n(part.value, 'list item')}`;
|
|
959
|
+
case 'maxListItems': return `the text has at most ${n(part.value, 'list item')}`;
|
|
960
|
+
case 'minListItems': return `the text has at least ${n(part.value, 'list item')}`;
|
|
910
961
|
case 'sectionOrder': return `the text has the section(s) ${list(part.names)}, in that order`;
|
|
911
962
|
case 'mustCarry': return `the text carries ${list(part.phrases)}`;
|
|
912
963
|
case 'blockLines': return `the text is in blocks of ${n(part.size, 'line')}, each carrying ${list(part.phrases)}`;
|
|
@@ -918,24 +969,59 @@ export function partSentence(part) {
|
|
|
918
969
|
}
|
|
919
970
|
}
|
|
920
971
|
|
|
972
|
+
/** the words of the default cited check code adds to a text line of a one-input job (the one list's `$` row); the card reads a part with exactly these words as `[default]` @param {string} label @returns {string} */
|
|
973
|
+
export const defaultCitedText = (label) => `every claim is backed by a quote copied from "${label}"`;
|
|
974
|
+
|
|
975
|
+
/** the words of the default note check code adds to a facts line that also asks for written words (the one list's `$` row, build 2026-11-14 (b)); the card reads a part with exactly these words as `[default]` @param {number} n the job line @returns {string} */
|
|
976
|
+
export const defaultNoteText = (n) => `line ${n} writes a note — the note must be there`;
|
|
977
|
+
/** is this part the default note check of line `n`? */
|
|
978
|
+
const isDefaultNote = (/** @type {any} */ p, /** @type {number} */ n) => isRec(p) && p.class === 'countable' && p.check === 'nonEmpty' && p.text === defaultNoteText(n);
|
|
979
|
+
|
|
980
|
+
/**
|
|
981
|
+
* Does the signed close really put a text-present check on job line `n`'s step file? (ONE reader, derived from the close: the protections list and the brief never claim it otherwise.)
|
|
982
|
+
* A facts line has no text check unless a countable part (a pick, or the default note) sits beside its facts; a line with no stage has none.
|
|
983
|
+
* @param {any} closeDecl @param {number} n @returns {boolean}
|
|
984
|
+
*/
|
|
985
|
+
export function lineCarriesText(closeDecl, n) {
|
|
986
|
+
const stages = isRec(closeDecl) && Array.isArray(closeDecl.stages) ? closeDecl.stages : [];
|
|
987
|
+
return stages.some((/** @type {any} */ st) => isRec(st) && st.kind === 'rubric-step' && isRec(st.params) && st.params.step === n && Array.isArray(st.params.parts)
|
|
988
|
+
&& !(factPartOf(st.params) && !st.params.parts.some((/** @type {any} */ x) => isRec(x) && x.class === 'countable')));
|
|
989
|
+
}
|
|
990
|
+
|
|
921
991
|
/**
|
|
922
992
|
* The checks a signed close actually runs, per job line, in plain code-written sentences: one per countable part of every
|
|
923
993
|
* rubric-step stage. This is the ONE reader both the plan card and the sign-time invariant use.
|
|
924
994
|
* Each row says who added the check (`by`): `you` = one of the person's picks, as the signed close's own record (`closeDecl.picks`) names it; `agent` = the drafter's;
|
|
925
|
-
* `
|
|
995
|
+
* `default` = code's own (the one list's `$` rows: the cited part written by `defaultCitedText`, and the numbers tie of a text step).
|
|
926
996
|
* @param {any} closeDecl
|
|
927
|
-
* @returns {{line: number, text: string,
|
|
997
|
+
* @returns {{line: number, text: string, by: 'agent'|'you'|'default', key?: string}[]}
|
|
928
998
|
*/
|
|
929
999
|
export function checksOfClose(closeDecl) {
|
|
930
1000
|
const stages = isRec(closeDecl) && Array.isArray(closeDecl.stages) ? closeDecl.stages : [];
|
|
931
1001
|
const record = isRec(closeDecl) && Array.isArray(closeDecl.picks) ? closeDecl.picks : [];
|
|
1002
|
+
const list = isRec(closeDecl) && Array.isArray(closeDecl.list) ? closeDecl.list.filter((/** @type {any} */ r) => isRec(r) && r.state === 'built') : [];
|
|
1003
|
+
/** the tag of a fact by its row's kind (hamr 2026-11-13, F-c): a fact a `~` rule built is [you], a `!` row's [agent]; `facts` on the signed row names what it built. No such row (an older close): the old reading */
|
|
1004
|
+
const factBy = (/** @type {number} */ line, /** @type {string} */ name) => {
|
|
1005
|
+
const rows = list.filter((/** @type {any} */ r) => r.line === line && Array.isArray(r.facts) && r.facts.includes(name));
|
|
1006
|
+
const r = rows.find((/** @type {any} */ x) => x.by === 'you') ?? rows[0];
|
|
1007
|
+
return r ? { by: /** @type {'agent'|'you'|'default'} */ (r.by), key: String(r.key) } : null;
|
|
1008
|
+
};
|
|
1009
|
+
const countBy = (/** @type {number} */ line, /** @type {number} */ pi) => {
|
|
1010
|
+
const r = list.find((/** @type {any} */ x) => x.line === line && x.kind === 'count' && isRec(x.part) && x.part.part === pi);
|
|
1011
|
+
return r ? { by: /** @type {'agent'|'you'|'default'} */ (r.by), key: String(r.key) } : null;
|
|
1012
|
+
};
|
|
932
1013
|
return stages.flatMap((/** @type {any} */ st) => (isRec(st) && st.kind === 'rubric-step' && isRec(st.params) && Array.isArray(st.params.parts)
|
|
933
|
-
? st.params.parts.
|
|
934
|
-
|
|
935
|
-
/** @type {'agent'|'you'|
|
|
936
|
-
const by = p.check === 'numbersFromFacts' ?
|
|
1014
|
+
? st.params.parts.flatMap((/** @type {any} */ p, /** @type {number} */ pi) => {
|
|
1015
|
+
if (!isRec(p) || (p.class !== 'countable' && p.class !== 'fact')) return [];
|
|
1016
|
+
/** @type {'agent'|'you'|'default'} */
|
|
1017
|
+
const by = p.check === 'numbersFromFacts' || isDefaultNote(p, st.params.step) || (p.check === 'cited' && p.text === defaultCitedText(p.source)) ? 'default' : record.some((/** @type {any} */ x) => isRec(x) && x.line === st.params.step && sameJson(x.part, p)) ? 'you' : 'agent';
|
|
937
1018
|
// a fact part is one plan row per fact (and one for its count): the person signs the rows, the close runs the same list
|
|
938
|
-
|
|
1019
|
+
if (p.class !== 'fact') return [{ line: st.params.step, text: partSentence(p), by }];
|
|
1020
|
+
const facts = Array.isArray(p.facts) ? p.facts : [];
|
|
1021
|
+
return factRows(p).map((/** @type {string} */ text, /** @type {number} */ i) => {
|
|
1022
|
+
const own = i < facts.length ? factBy(st.params.step, facts[i]?.name) : countBy(st.params.step, pi);
|
|
1023
|
+
return { line: st.params.step, text, by: own?.by ?? by, ...(own ? { key: own.key } : {}) };
|
|
1024
|
+
});
|
|
939
1025
|
})
|
|
940
1026
|
: []));
|
|
941
1027
|
}
|
|
@@ -952,30 +1038,51 @@ export function signedFactNames(closeDecl) {
|
|
|
952
1038
|
}
|
|
953
1039
|
|
|
954
1040
|
/**
|
|
955
|
-
*
|
|
956
|
-
*
|
|
957
|
-
*
|
|
958
|
-
*
|
|
959
|
-
* @
|
|
960
|
-
* `jobLines` — the person's numbered lines, so a ~ rule the drafter listed as Not checked reads in the person's own words
|
|
961
|
-
* @returns {{checkItems: {text: string, fromLine: number[], by: 'agent'|'you'|null}[], notChecked: string[], moved: {text: string, fromLine: number[]|null}[]}}
|
|
1041
|
+
* The plan card after drafting, read from the signed close ALONE (one source, the same the Job tab reads): its checks are `checksOfClose`; its Not checked is the close's own notes, the prose
|
|
1042
|
+
* steps' "you judge it at Accept" lines and the refusals (`ruleNotChecked`, which reads the list's not-checked rows when the close carries the list). Nothing the confirm turn said is merged
|
|
1043
|
+
* in: a rubric confirm turn plans the goal only, so a check can never be shown and then silently dropped (run mv5bk400).
|
|
1044
|
+
* @param {{closeDecl: any, jobLines?: any[]|null, ledger?: {key: string, words: string[]}[]|null}} o `jobLines` the person's numbered lines, so a ~ rule reads in the person's own words; `ledger` the draft log's final list rows, so a phrase row is named by its words
|
|
1045
|
+
* @returns {{checkItems: {text: string, fromLine: number[], by: 'agent'|'you'|'default', key?: string}[], notChecked: string[], notCheckedBy: Record<string, 'you'|'agent'|'default'>}}
|
|
962
1046
|
*/
|
|
963
|
-
export function
|
|
964
|
-
const
|
|
965
|
-
const
|
|
966
|
-
|
|
1047
|
+
export function cardOfClose({ closeDecl, jobLines = null, ledger = null }) {
|
|
1048
|
+
const notes = isRec(closeDecl) && Array.isArray(closeDecl.notes) ? closeDecl.notes.filter((/** @type {any} */ n) => typeof n === 'string' && n) : [];
|
|
1049
|
+
const items = ruleNotCheckedItems(closeDecl, jobLines, ledger);
|
|
1050
|
+
/** @type {Record<string, 'you'|'agent'|'default'>} */
|
|
1051
|
+
const notCheckedBy = {};
|
|
1052
|
+
for (const i of items) if (i.by) notCheckedBy[i.text] = i.by;
|
|
967
1053
|
return {
|
|
968
|
-
checkItems:
|
|
969
|
-
notChecked: [
|
|
970
|
-
|
|
971
|
-
...proseNotChecked(closeDecl),
|
|
972
|
-
...ruleNotChecked(closeDecl, jobLines),
|
|
973
|
-
...moved.map((m) => `${m.fromLine && m.fromLine.length ? `line ${m.fromLine.join(', ')}: ` : ''}${m.text} — nothing in this close counts it or checks it against a quote`),
|
|
974
|
-
],
|
|
975
|
-
moved,
|
|
1054
|
+
checkItems: checksOfClose(closeDecl).map((c) => ({ text: c.text, fromLine: [c.line], by: c.by, ...(c.key ? { key: c.key } : {}) })),
|
|
1055
|
+
notChecked: [...new Set([...notes, ...proseNotChecked(closeDecl), ...items.map((i) => i.text)])],
|
|
1056
|
+
notCheckedBy,
|
|
976
1057
|
};
|
|
977
1058
|
}
|
|
978
1059
|
|
|
1060
|
+
/**
|
|
1061
|
+
* The sign-time check of a close that carries the one check list: every BUILT row (the mechanical floor aside) points at a part that is really in the close, and every real check part
|
|
1062
|
+
* (countable or fact) has at least one built row pointing at it, so a check cannot be in the close with no row and a row cannot claim a check the close does not run. A close with no list is
|
|
1063
|
+
* not examined here. Pure.
|
|
1064
|
+
* @param {any} closeDecl @returns {{ok: true}|{ok: false, error: string}}
|
|
1065
|
+
*/
|
|
1066
|
+
export function listMatchesClose(closeDecl) {
|
|
1067
|
+
const list = isRec(closeDecl) && Array.isArray(closeDecl.list) ? closeDecl.list : null;
|
|
1068
|
+
if (list === null) return { ok: true };
|
|
1069
|
+
const stages = Array.isArray(closeDecl.stages) ? closeDecl.stages : [];
|
|
1070
|
+
const partsOn = (/** @type {number} */ n) => stages.filter((/** @type {any} */ st) => isRec(st) && st.kind === 'rubric-step' && isRec(st.params) && st.params.step === n && Array.isArray(st.params.parts)).flatMap((/** @type {any} */ st) => st.params.parts);
|
|
1071
|
+
const built = list.filter((/** @type {any} */ r) => isRec(r) && r.state === 'built' && r.kind !== 'floor');
|
|
1072
|
+
const bad = built.filter((/** @type {any} */ r) => !(isRec(r.part) && r.part.line === r.line && Number.isInteger(r.part.part) && isRec(partsOn(r.line)[r.part.part])));
|
|
1073
|
+
const lines = [...new Set(stages.filter((/** @type {any} */ st) => isRec(st) && st.kind === 'rubric-step' && isRec(st.params)).map((/** @type {any} */ st) => st.params.step))];
|
|
1074
|
+
const bare = lines.flatMap((/** @type {number} */ n) => partsOn(n).map((/** @type {any} */ p, /** @type {number} */ i) => ({ n, i, p })))
|
|
1075
|
+
.filter(({ p }) => isRec(p) && (p.class === 'countable' || p.class === 'fact'))
|
|
1076
|
+
// a part has its row when a built row points at it, or when the part lists (in its `rules`) the number of a built `~` row of its line (a row points at ONE part, a rule may be carried by several)
|
|
1077
|
+
.filter(({ n, i, p }) => !built.some((/** @type {any} */ r) => (isRec(r.part) && r.part.line === n && r.part.part === i)
|
|
1078
|
+
|| (r.kind === 'rule' && r.line === n && Array.isArray(p.rules) && p.rules.includes(r.rule))));
|
|
1079
|
+
if (bad.length === 0 && bare.length === 0) return { ok: true };
|
|
1080
|
+
const parts = [];
|
|
1081
|
+
if (bad.length) parts.push(`a row points at a check the close does not run: ${bad.map((/** @type {any} */ r) => r.key).join('; ')}`);
|
|
1082
|
+
if (bare.length) parts.push(`a check in the close has no row: line ${bare.map(({ n, i }) => `${n} part ${i + 1}`).join('; ')}`);
|
|
1083
|
+
return { ok: false, error: `The list of checks does not match the signed close (${parts.join(' | ')}). Nothing was signed — draft again.` };
|
|
1084
|
+
}
|
|
1085
|
+
|
|
979
1086
|
/**
|
|
980
1087
|
* The sign-time invariant: the checks the person was shown (`shown`, from the plan card) are exactly the checks the signed
|
|
981
1088
|
* close runs (`checksOfClose`), per line. Pure.
|
package/src/run.js
CHANGED
|
@@ -18,6 +18,7 @@ import { runPlan } from './planrun.js';
|
|
|
18
18
|
import { SMOKE_STORE, resolveHumanRuling } from './kinds.js';
|
|
19
19
|
import { readShimArm } from './readshim.js';
|
|
20
20
|
import { codeVersion } from './codeversion.js';
|
|
21
|
+
import { bindPlaceValues } from './placerule.js';
|
|
21
22
|
|
|
22
23
|
/** @typedef {{code: string, path: string, detail?: string}} Red */
|
|
23
24
|
|
|
@@ -99,19 +100,10 @@ async function primitiveSmoke(workdir) {
|
|
|
99
100
|
* (`ratesFor`, src/providerrows.js — USD per 1K tokens), resolved once by the door and handed to every
|
|
100
101
|
* worker/planner Loop as bare-agent's `rates` (rounds then read `rateSource:'caller'`). Absent = the
|
|
101
102
|
* built-in guess, exactly as before. A Loop-driven provider only: a native session reports its own cost.
|
|
102
|
-
* @param {
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
* wiring gap rather than grading under an identity nobody named.
|
|
107
|
-
* @param {any} [opts.judgeProvider] SOFTGREEN — the provider a JUDGED close stage runs its
|
|
108
|
-
* locate call through, built by the CALLER from the RESOLVED judge identity (PRD item
|
|
109
|
-
* 32.1: `resolveJudge`/`resolveJobJudge`, src/judged.js — the spec's signed `judge`
|
|
110
|
-
* override, else the job's own worker provider and model), never pinned. Forwarded to the plan
|
|
111
|
-
* flow. It is its own seam and not `provider`/`providerFor`, because the judge tier is
|
|
112
|
-
* never a step knob and never agent-selectable; absent, a judged stage instrument-stops as
|
|
113
|
-
* a wiring gap rather than grading on whatever binding happened to be at hand. Its spend
|
|
114
|
-
* lands on this ledger as `judge-round` (see `ACCOUNTED_ROUND_TYPES`).
|
|
103
|
+
* @param {Record<string, string>|null} [opts.placeValues] PLACE RULES (src/placerule.js): the values this run's start read for the spec's place-rule facts, by key. Bound
|
|
104
|
+
* as those facts' phrases on the run's own in-memory copy AFTER the approval check and the `job-start` record, so the hash checked and the hash recorded stay the
|
|
105
|
+
* SIGNED one and the signed spec is never changed; the planner and the close read the copy. Absent = the signed words.
|
|
106
|
+
* @param {{workflowKey: string, rows: object[]}|null} [opts.placeRead] PLACE RULES: what the run start read (rows {key, kind, found, value, was, reason}); recorded once as a `place-rules` event right after `job-start`. Absent = the job has none (or this is a resume, whose first leg wrote it).
|
|
115
107
|
* @param {number} [opts.capRuns] shell-owned iteration cap for the plan flow's
|
|
116
108
|
* CLOSE-FIX loop (a plan STEP runs under the strike ladder instead)
|
|
117
109
|
* @param {number} [opts.strikeLimit] shell-owned strike ceiling for a plan step's ladder
|
|
@@ -280,7 +272,7 @@ async function primitiveSmoke(workdir) {
|
|
|
280
272
|
* deliberately NOT in the resumable/checkpoint set (`src/reuse.js`) — an
|
|
281
273
|
* unknown in-flight state is not a known-safe resume point.
|
|
282
274
|
*/
|
|
283
|
-
export async function runJob(rawSpec, { approvals, workdir, provider, nativeProvider, providerFor,
|
|
275
|
+
export async function runJob(rawSpec, { approvals, workdir, provider, nativeProvider, providerFor, rates = null, emit, capRuns = 3, strikeLimit, shellCapUsd = 2, closeTimeoutMs, closeDir = null, layerRoot = false, readShim = false, scout = true, bridge = null, draftSpentUsd = 0, draftSpendComplete = true, priorSpentUsd = 0, priorSpendComplete = true, priorWallMs = 0, resumeSeed = null, resumeGrades = [], resumeReplans = null, resumeBranch = null, humanRuling = null, heldRuling = null, reviewDoor = null, doorRerun = null, resumable = true, stopFile = null, learnHints = null, ticketRecord = null, ticketUnsure = null, prRecord = null, placeValues = null, placeRead = null }) {
|
|
284
276
|
// THE READ SHIM's ARM, resolved at the door — the FIRST thing this entry does,
|
|
285
277
|
// before the ledger, before the approval gate, before a byte of the spec is read.
|
|
286
278
|
// An unrecognised spelling throws here at zero cost instead of being coerced by
|
|
@@ -389,7 +381,7 @@ export async function runJob(rawSpec, { approvals, workdir, provider, nativeProv
|
|
|
389
381
|
emit('job-end', { outcome: 'job-red', ...spend() });
|
|
390
382
|
return 'job-red';
|
|
391
383
|
}
|
|
392
|
-
|
|
384
|
+
let job = /** @type {any} */ (jv.job);
|
|
393
385
|
/** F103 — the two TIME figures, resolved once here and read the same way by
|
|
394
386
|
* `runPlan`'s clock. An unreadable ruling resolves to `fresh: false` and folds as
|
|
395
387
|
* it always did; `runPlan` is where it is refused, so this never has to. */
|
|
@@ -460,6 +452,9 @@ export async function runJob(rawSpec, { approvals, workdir, provider, nativeProv
|
|
|
460
452
|
? { priorReplans: Math.floor(resumeReplans.count), priorReplanGrantUsed: resumeReplans.grantUsed === true }
|
|
461
453
|
: {}),
|
|
462
454
|
});
|
|
455
|
+
// PLACE RULES: the approval was checked on the signed spec and `job-start` recorded its hash; only now does the run's own copy take the values its start read
|
|
456
|
+
if (placeValues !== null) job = bindPlaceValues(job, placeValues);
|
|
457
|
+
if (placeRead !== null) emit('place-rules', placeRead);
|
|
463
458
|
|
|
464
459
|
// F140/PRD item 28 (c) — the backstop that fires on the ABSENCE of a
|
|
465
460
|
// `job-end`. A provider promise that never settles (BA-25's class; 0.42.0
|
|
@@ -551,7 +546,7 @@ export async function runJob(rawSpec, { approvals, workdir, provider, nativeProv
|
|
|
551
546
|
// accounts it natively (F12) and the job-end money contract is unchanged.
|
|
552
547
|
{
|
|
553
548
|
const outcome = await runPlan(job, {
|
|
554
|
-
workdir, provider, nativeProvider, providerFor,
|
|
549
|
+
workdir, provider, nativeProvider, providerFor, rates, emit: meter, capRuns, ...(strikeLimit !== undefined ? { strikeLimit } : {}), closeTimeoutMs, closeDir, layerRoot, readShim, scout, bridge, priorWallMs: chainWallMs, resumeSeed, resumeGrades, resumeReplans, resumeBranch, humanRuling, heldRuling, reviewDoor, doorRerun, priorSpentUsd: chainFoldUsd, resumable, stopFile, learnHints,
|
|
555
550
|
// hamr's ruling 2026-09-28 — ONE cap covers drafting + run: the run's
|
|
556
551
|
// enforced ceiling is the signed `budgetUsd` (unchanged, still in the
|
|
557
552
|
// spec hash) MINUS whatever drafting already spent on this job before
|