fwdloop 0.31.0 → 0.33.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.
Files changed (96) hide show
  1. package/bin/fwdloop +8 -2
  2. package/package.json +2 -2
  3. package/src/auditchecks.js +53 -0
  4. package/src/authoring.js +52 -12
  5. package/src/blockasks.js +44 -0
  6. package/src/blockassemble.js +140 -0
  7. package/src/blockdraft.js +91 -0
  8. package/src/blocklines.js +30 -0
  9. package/src/blockpick.js +165 -0
  10. package/src/cardlist.js +19 -0
  11. package/src/checkblock.js +804 -0
  12. package/src/checked.js +48 -9
  13. package/src/checklist.js +99 -0
  14. package/src/checklistsign.js +93 -0
  15. package/src/checkwords.js +20 -1
  16. package/src/cited-record.js +21 -1
  17. package/src/citedcheck.js +162 -7
  18. package/src/closers.js +41 -3
  19. package/src/declaration.js +25 -2
  20. package/src/declaredclose.js +4 -0
  21. package/src/draft-steps.js +3 -1
  22. package/src/drafter.js +244 -134
  23. package/src/factwords.js +112 -0
  24. package/src/inputlook.js +53 -0
  25. package/src/jsonbrace.js +21 -0
  26. package/src/labelscan.js +162 -0
  27. package/src/pageask.js +4 -1
  28. package/src/pagedropwords.js +11 -1
  29. package/src/panel/author.js +76 -5
  30. package/src/panel/authorcard.js +9 -6
  31. package/src/panel/data.js +41 -9
  32. package/src/panel/index.html +202 -13
  33. package/src/panel/result.js +4 -3
  34. package/src/panel/server.js +3 -1
  35. package/src/pickrecord.js +28 -0
  36. package/src/placerule.js +398 -0
  37. package/src/planrebuild.js +206 -0
  38. package/src/rowedit.js +118 -0
  39. package/src/rubricstep.js +264 -0
  40. package/src/runfile.js +4 -2
  41. package/src/runner.js +67 -10
  42. package/src/setup.js +10 -4
  43. package/src/sheetblock.js +6 -2
  44. package/src/sheetchecks.js +49 -64
  45. package/src/sheetclaims.js +12 -32
  46. package/src/sheetlook.js +2 -2
  47. package/src/sheetoffer.js +25 -53
  48. package/src/sheetrows.js +107 -0
  49. package/src/sheetrun.js +31 -1
  50. package/src/summary-words.js +3 -3
  51. package/src/try-checks.js +31 -12
  52. package/src/types.js +1 -0
  53. package/types/auditchecks.d.ts +24 -0
  54. package/types/authoring.d.ts +18 -1
  55. package/types/blockasks.d.ts +37 -0
  56. package/types/blockassemble.d.ts +33 -0
  57. package/types/blockdraft.d.ts +83 -0
  58. package/types/blocklines.d.ts +31 -0
  59. package/types/blockpick.d.ts +41 -0
  60. package/types/cardlist.d.ts +21 -0
  61. package/types/checkblock.d.ts +363 -0
  62. package/types/checked.d.ts +16 -2
  63. package/types/checklist.d.ts +115 -0
  64. package/types/checklistsign.d.ts +27 -0
  65. package/types/checkwords.d.ts +5 -0
  66. package/types/cited-record.d.ts +9 -0
  67. package/types/citedcheck.d.ts +33 -2
  68. package/types/closers.d.ts +24 -2
  69. package/types/declaredclose.d.ts +2 -0
  70. package/types/drafter.d.ts +15 -361
  71. package/types/factwords.d.ts +38 -0
  72. package/types/inputlook.d.ts +49 -0
  73. package/types/jsonbrace.d.ts +8 -0
  74. package/types/labelscan.d.ts +35 -0
  75. package/types/pageask.d.ts +2 -0
  76. package/types/panel/author.d.ts +41 -0
  77. package/types/panel/authorcard.d.ts +1 -1
  78. package/types/panel/data.d.ts +4 -2
  79. package/types/panel/jobgrid.d.ts +1 -1
  80. package/types/pickrecord.d.ts +22 -0
  81. package/types/placerule.d.ts +208 -0
  82. package/types/planrebuild.d.ts +52 -0
  83. package/types/provider.d.ts +1 -1
  84. package/types/rowedit.d.ts +33 -0
  85. package/types/rubricstep.d.ts +60 -0
  86. package/types/runfile.d.ts +5 -2
  87. package/types/runner.d.ts +45 -1
  88. package/types/sheetblock.d.ts +1 -0
  89. package/types/sheetchecks.d.ts +10 -17
  90. package/types/sheetclaims.d.ts +2 -1
  91. package/types/sheetoffer.d.ts +5 -5
  92. package/types/sheetrows.d.ts +73 -0
  93. package/types/sheetrun.d.ts +12 -0
  94. package/types/summary-words.d.ts +2 -1
  95. package/types/try-checks.d.ts +4 -2
  96. package/types/types.d.ts +8 -0
@@ -25,7 +25,7 @@ export function parseJobBox(text: string): {
25
25
  * that line's own `~` lines (several answers for one line keep their order). The job box's own lines are untouched; the card -> prose path
26
26
  * (`cardToProse`) then writes the answer as that line's guardrail, so it reaches the signed text and the hash. Pure. An answer for a line
27
27
  * the box does not have is NOT added (the caller sees the count). An answer equal (exact string, after trim) to a `~` rule already on that line is not added
28
- * again, and still counts: it is taken, the line already says it.
28
+ * again (case, spacing and trailing punctuation aside; also not when it is one `; ` part of a `~` line), and still counts: it is taken, the line already says it.
29
29
  * @param {string} job @param {{ line: number, answer: string }[]} answers
30
30
  * @returns {{ job: string, added: number }}
31
31
  */
@@ -658,7 +658,7 @@ export function getDraftBlock(flowDir: string, runDir: string): {
658
658
  * shared-sidecar contamination risk here the way bareloop's gate-audit
659
659
  * sidecar had). `null` when the flow/runId doesn't resolve (404).
660
660
  * @param {{root: string, flow: string, runId: string, scheduleRead?: (flow: string) => any, home?: string, catalogue?: any, resumeAttempt?: (flow: string, runId: string) => any, startingRun?: (flow: string, runId: string) => boolean, now?: () => number}} opts
661
- * @returns {{flow:string, runId:string, rows:any[], groups:any[], draft:ReturnType<typeof getDraftBlock>, learnings: any[], needsLeft: string|null, schedule: ReturnType<typeof scheduleAuditWords>, empty:boolean, why:string|null}|null}
661
+ * @returns {{flow:string, runId:string, rows:any[], groups:any[], draft:ReturnType<typeof getDraftBlock>, auditChecks: ReturnType<typeof auditChecksOf>, learnings: any[], needsLeft: string|null, schedule: ReturnType<typeof scheduleAuditWords>, empty:boolean, why:string|null}|null}
662
662
  */
663
663
  export function getRunAudit({ root, flow, runId, scheduleRead, home, catalogue, resumeAttempt, startingRun, now, }: {
664
664
  root: string;
@@ -676,6 +676,7 @@ export function getRunAudit({ root, flow, runId, scheduleRead, home, catalogue,
676
676
  rows: any[];
677
677
  groups: any[];
678
678
  draft: ReturnType<typeof getDraftBlock>;
679
+ auditChecks: ReturnType<typeof auditChecksOf>;
679
680
  learnings: any[];
680
681
  needsLeft: string | null;
681
682
  schedule: ReturnType<typeof scheduleAuditWords>;
@@ -756,7 +757,7 @@ export function getJobGrid({ root, flow, catalogue, now, }: {
756
757
  name: string;
757
758
  title: string | null;
758
759
  number: number | null;
759
- bucket: "wait" | "done" | "skip" | "stop";
760
+ bucket: "wait" | "skip" | "done" | "stop";
760
761
  glyph: string;
761
762
  at: number;
762
763
  ex: "r" | "n" | "g" | "q";
@@ -960,5 +961,6 @@ export const RUNS_LIST_LIMITS: Readonly<{
960
961
  export const NO_DRAFT_WORDS: "no draft record";
961
962
  /** M6: what the Job tab says for a run that started before runs kept a copy of their job. */
962
963
  export const NO_JOB_COPY_WORDS: "This run started before runs kept a copy of their job, so this shows the job as it is now.";
964
+ import { auditChecksOf } from '../auditchecks.js';
963
965
  import { scheduleAuditWords } from '../summary-words.js';
964
966
  import { downloadOf } from './result.js';
@@ -69,7 +69,7 @@ export function buildJobGrid({ runs, anyway, now }: {
69
69
  name: string;
70
70
  title: string | null;
71
71
  number: number | null;
72
- bucket: "wait" | "done" | "skip" | "stop";
72
+ bucket: "wait" | "skip" | "done" | "stop";
73
73
  glyph: string;
74
74
  at: number;
75
75
  ex: "r" | "n" | "g" | "q";
@@ -66,6 +66,28 @@ export function matchRecord(entries: Entry[], lines: {
66
66
  * @param {string} file @returns {Entry[]|null}
67
67
  */
68
68
  export function readRecordFile(file: string): Entry[] | null;
69
+ /**
70
+ * The Drop/Add choices a draft's person made on the confirm card (hamr 2026-11-13, N-2), carried the same way as the picks: tied to the line's words and the row's own name, never to a number.
71
+ * @param {string} file @returns {{lineWords: string, occurrence: number, tail: string, choice: string}[]|null}
72
+ */
73
+ export function readRowChoices(file: string): {
74
+ lineWords: string;
75
+ occurrence: number;
76
+ tail: string;
77
+ choice: string;
78
+ }[] | null;
79
+ /**
80
+ * The sheet checks the person dropped from a plan (hamr 2026-11-14: a Revise keeps a sheet Drop), carried like the page-row choices: the record's `sheetDropped` entries, each `{key, line, index, check, text}`;
81
+ * the next draft drops a new check with the same id again. Read through readFileInside; a missing or unreadable record is no record.
82
+ * @param {string} file @returns {{key: string, line: number, index: number, check: Record<string, any>, text: string}[]|null}
83
+ */
84
+ export function readSheetDropped(file: string): {
85
+ key: string;
86
+ line: number;
87
+ index: number;
88
+ check: Record<string, any>;
89
+ text: string;
90
+ }[] | null;
69
91
  /** the record's file, inside a drafting folder only (never a run folder) */
70
92
  export const RECORD_FILE: "picks-record.json";
71
93
  /** the exact words a kept pick is marked with in the draft log, the Audit and the plan card (M10 am17 (6)) */
@@ -0,0 +1,208 @@
1
+ /**
2
+ * @typedef {{kind: 'headingBetween'|'headingDateAfter', prefix: string, end: string, shape: string, skip: string[]}} PlaceRule
3
+ * @typedef {{found: true, value: string, lineIndex: number}|{found: false, reason: string}} PlaceRead
4
+ */
5
+ /**
6
+ * Why a rule is not a legal place rule, or null when it is. Pure.
7
+ * @param {unknown} rule @returns {string|null}
8
+ */
9
+ export function placeRuleProblem(rule: unknown): string | null;
10
+ /**
11
+ * Heading lines at the rule's level: lines outside ``` / ~~~ fences that start with the level mark (for example "## "). Pure.
12
+ * @param {string} text @param {string} prefix @returns {{i: number, line: string}[]}
13
+ */
14
+ export function levelLines(text: string, prefix: string): {
15
+ i: number;
16
+ line: string;
17
+ }[];
18
+ /**
19
+ * The mixed-level guard: every non-fenced heading line is scanned; semver-carrying headings at MORE THAN ONE level mean mixed. A heading with no
20
+ * semver (a "# Changelog" title, "### Fixed") is ignored. It only ever turns a read into not found, never into a value.
21
+ * @param {string} text @returns {boolean}
22
+ */
23
+ export function mixedLevels(text: string): boolean;
24
+ /**
25
+ * Read one rule against one input text: the run-start function, code only. A rule that is not legal throws (the signed spec was validated, so a bad one
26
+ * is a defect, never a read).
27
+ * @param {PlaceRule} rule @param {string} text @returns {PlaceRead}
28
+ */
29
+ export function readPlace(rule: PlaceRule, text: string): PlaceRead;
30
+ /**
31
+ * Fit a place rule to a fact's own words, by CODE, at drafting. The words must be exactly one version (X.Y.Z) or exactly one ISO date; the frozen
32
+ * candidates are walked in order, and the first whose strict first-heading read on the input's own text returns exactly those words wins. Null =
33
+ * no fit (a version and a date together, any other words, another date form, a mixed-level file, no text, or no candidate reading them): the caller
34
+ * refuses the words as week-only exactly as before. Only the two kinds are handled. Pure.
35
+ * @param {string} words @param {string|null|undefined} text
36
+ * @returns {PlaceRule|null}
37
+ */
38
+ export function fitPlaceRule(words: string, text: string | null | undefined): PlaceRule | null;
39
+ /**
40
+ * STRIP (P1b, hamr 2026-11-11): the words of a phrase fact that are a piece of the newest release heading ("## [0.54.1]", "[0.54.1] -", "0.54.1",
41
+ * "2026-11-04", "## [0.54.1] - 2026-11-04") are stripped by code to their value(s). The words hold exactly one version (X.Y.Z, an optional leading v) and/or
42
+ * exactly one ISO date and nothing else but heading marks; each value is fitted with {@link fitPlaceRule} on the input's own text, and when both are
43
+ * present both must sit on the SAME first release heading line. Returns the values (version first) each with its rule, or null: two versions, two dates,
44
+ * any other word, another date form, a value that is not at the first release heading, no text. Pure.
45
+ * @param {string} words @param {string|null|undefined} text
46
+ * @returns {{kind: 'version'|'date', value: string, rule: PlaceRule}[]|null}
47
+ */
48
+ export function fitPlacePhrase(words: string, text: string | null | undefined): {
49
+ kind: "version" | "date";
50
+ value: string;
51
+ rule: PlaceRule;
52
+ }[] | null;
53
+ /**
54
+ * @typedef {{key: string, name: string, source: string, stage: number, part: number, fact: number, place: PlaceRule, phrase: string}} PlaceFact
55
+ */
56
+ /**
57
+ * Every place-rule fact of a spec, in stage / part / fact order. The key is the stage's name and the fact's name (both stable across the runs of one
58
+ * workflow), so an earlier run's record finds the same fact. Pure.
59
+ * @param {any} spec @returns {PlaceFact[]}
60
+ */
61
+ export function placeFactsOf(spec: any): PlaceFact[];
62
+ /**
63
+ * fwd's shape of {@link placeFactsOf}: a place fact lives on a step's `close.cited.facts[]` (the fact part of a green step that quotes an input), not in a
64
+ * bareloop closeDecl stage. Same PlaceFact record (`stage` = the step's index, `part` = 0, `fact` = the fact's index); the key is the step's `emits` and the fact's name.
65
+ * Pure. @param {any[]} steps @returns {PlaceFact[]}
66
+ */
67
+ export function citedPlaceFactsOf(steps: any[]): PlaceFact[];
68
+ /**
69
+ * A copy of the steps with each place fact's phrase replaced by the value the run read (fwd's shape of {@link bindPlaceValues}). The input is never touched, so the
70
+ * signed declaration and its hash stay as signed. A key with no value keeps the signed drafting words. @param {any[]} steps @param {Record<string, string>} values @returns {any[]}
71
+ */
72
+ export function bindCitedPlaceValues(steps: any[], values: Record<string, string>): any[];
73
+ /**
74
+ * A copy of the spec with each place fact's phrase replaced by the value the run read. The input spec is never touched (the signed spec and its hash
75
+ * stay as signed); the copy is for this run's planner and close only. A key with no value is left as the signed drafting words.
76
+ * @param {any} spec @param {Record<string, string>} values place-fact key to the value read @returns {any}
77
+ */
78
+ export function bindPlaceValues(spec: any, values: Record<string, string>): any;
79
+ /**
80
+ * The value the drafting words themselves hold for this rule: the first version for headingBetween, the first ISO date for headingDateAfter. Null when
81
+ * the words hold none. Used as "last read" when no earlier run has one.
82
+ * @param {PlaceRule} rule @param {string} words @returns {string|null}
83
+ */
84
+ export function valueInWords(rule: PlaceRule, words: string): string | null;
85
+ /**
86
+ * Re-read EVERY place fact against the run's own input text, one by one, before any spend. A row is same / new / notfound. Any notfound stops the run;
87
+ * otherwise the run proceeds with the new words.
88
+ * @param {{fact: PlaceFact, text: string|null, was: string|null}[]} items `text` null = the input could not be read
89
+ * @returns {{proceed: boolean, rows: {key: string, name: string, kind: string, found: boolean, value: string|null, was: string|null, reason: string|null}[], values: Record<string, string>}}
90
+ */
91
+ export function readPlaceRules(items: {
92
+ fact: PlaceFact;
93
+ text: string | null;
94
+ was: string | null;
95
+ }[]): {
96
+ proceed: boolean;
97
+ rows: {
98
+ key: string;
99
+ name: string;
100
+ kind: string;
101
+ found: boolean;
102
+ value: string | null;
103
+ was: string | null;
104
+ reason: string | null;
105
+ }[];
106
+ values: Record<string, string>;
107
+ };
108
+ /**
109
+ * The words of the $0 stop, plain words from code. Every rule is listed, found or not: "<name>: found <value>" (with "(was <last>)" when the value is
110
+ * new) or "<name>: not found (<plain reason>)", then the closing line. The reasons come only from the closed list.
111
+ * @param {{name: string, found: boolean, value: string|null, was: string|null, reason: string|null}[]} rows @returns {string}
112
+ */
113
+ export function stopWords(rows: {
114
+ name: string;
115
+ found: boolean;
116
+ value: string | null;
117
+ was: string | null;
118
+ reason: string | null;
119
+ }[]): string;
120
+ /**
121
+ * The values of the LAST `place-rules` record in a run's own events (key to value): what a RESUME of that run rebinds, since a resume does not re-read. Null when
122
+ * there is no record, or any of its rows was not found.
123
+ * @param {any[]} events @returns {Record<string, string>|null}
124
+ */
125
+ export function placeValuesOfEvents(events: any[]): Record<string, string> | null;
126
+ /**
127
+ * What the newest EARLIER run of the same workflow read, per fact key: "last read". `rows` are the run list's rows (file order, oldest first). Candidates are
128
+ * the rows of the same job, newest first, at most {@link LAST_READ_LOOK} of them; the first whose spine holds a `place-rules` record of the same workflow key
129
+ * answers. An unreadable spine is skipped. Empty when there is none (the caller falls back to the drafting words).
130
+ * @param {{rows: {runid: string, job: string, spine: string}[], job: string, workflowKey: string, runid: string}} o @returns {Record<string, string>}
131
+ */
132
+ export function lastPlaceRead({ rows, job, workflowKey, runid }: {
133
+ rows: {
134
+ runid: string;
135
+ job: string;
136
+ spine: string;
137
+ }[];
138
+ job: string;
139
+ workflowKey: string;
140
+ runid: string;
141
+ }): Record<string, string>;
142
+ /**
143
+ * fwd's "last read" (bareloop's lastPlaceRead reads spines; fwd has none): per fact key, the value the newest EARLIER run of the same flow recorded in its run.json
144
+ * `placeRules` (runs are `run-<n>`; at most {@link LAST_READ_LOOK} earlier runs are looked at; a run with no record, or an unreadable one, is skipped). Empty when none.
145
+ * @param {{flowDir: string, runId: string}} o @returns {Record<string, string>}
146
+ */
147
+ export function lastRunPlaceRead({ flowDir, runId }: {
148
+ flowDir: string;
149
+ runId: string;
150
+ }): Record<string, string>;
151
+ /** the two rule kinds on the menu: the version in a heading, and the date on the same heading line */
152
+ export const PLACE_KINDS: readonly string[];
153
+ /** the end-of-line end mark */
154
+ export const EOL: "$EOL";
155
+ /** the field a place rule may carry */
156
+ export const PLACE_FIELDS: readonly string[];
157
+ /** the closed list of reasons a read can end not found */
158
+ export const PLACE_REASONS: readonly string[];
159
+ /** plain words for each reason, from code (the person never reads a raw code) */
160
+ export const PLAIN_REASONS: Readonly<{
161
+ 'mixed-levels': "the file writes its version headings at more than one level";
162
+ 'no-heading-line': "the file has no heading at the level the rule reads";
163
+ 'first-heading-mismatch': "the newest heading does not start the way the rule says";
164
+ 'end-mark-missing': "the newest heading does not have the mark the rule reads up to";
165
+ 'capture-not-shape': "the newest heading does not carry a version number";
166
+ 'only-skipped-headings': "the file has only an Unreleased heading and no release after it";
167
+ 'no-date-on-line': "the newest heading line carries no date";
168
+ 'no-file': "the input could not be read";
169
+ 'empty-text': "the input is empty";
170
+ }>;
171
+ /** the frozen candidate list: 9 prefixes crossed with 3 ends, prefix-major (27) */
172
+ export const PLACE_CANDIDATES: readonly Readonly<{
173
+ prefix: string;
174
+ end: string;
175
+ }>[];
176
+ /** the end of the stop words: what the person can do, and that nothing ran or was spent */
177
+ export const STOP_TAIL: "Reuse workflow and adjust the rules, or check the input. The run did not start. Nothing spent.";
178
+ /** the plain words of the door's refusal when a place-rule run has no record of the values it read */
179
+ export const NO_PLACE_RECORD_WORDS: "This run has no record of the values it read, so it cannot be checked again. Use Reuse workflow.";
180
+ /** the spine event a run writes, once, after job-start */
181
+ export const PLACE_EVENT: "place-rules";
182
+ /** how many earlier runs of the job are looked at for "last read" */
183
+ export const LAST_READ_LOOK: 25;
184
+ export type PlaceRule = {
185
+ kind: "headingBetween" | "headingDateAfter";
186
+ prefix: string;
187
+ end: string;
188
+ shape: string;
189
+ skip: string[];
190
+ };
191
+ export type PlaceRead = {
192
+ found: true;
193
+ value: string;
194
+ lineIndex: number;
195
+ } | {
196
+ found: false;
197
+ reason: string;
198
+ };
199
+ export type PlaceFact = {
200
+ key: string;
201
+ name: string;
202
+ source: string;
203
+ stage: number;
204
+ part: number;
205
+ fact: number;
206
+ place: PlaceRule;
207
+ phrase: string;
208
+ };
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Rebuild the block of a saved plan at $0. `choices` = the Drop/Add choices the plan was made with (its record's `rowChoices`).
3
+ * @param {{planDir: string, asks: boolean}} o
4
+ * @returns {{ok: true, block: import('./checkblock.js').CheckBlock, declaration: any, lines: any[], lineSet: Set<number>, parsed: any, texts: Record<string, string>, look: {facts: any[], dropped: any[]}, record: any, log: any, proseText: string}|{ok: false, say: string}}
5
+ */
6
+ export function rebuildBlock({ planDir, asks }: {
7
+ planDir: string;
8
+ asks: boolean;
9
+ }): {
10
+ ok: true;
11
+ block: import("./checkblock.js").CheckBlock;
12
+ declaration: any;
13
+ lines: any[];
14
+ lineSet: Set<number>;
15
+ parsed: any;
16
+ texts: Record<string, string>;
17
+ look: {
18
+ facts: any[];
19
+ dropped: any[];
20
+ };
21
+ record: any;
22
+ log: any;
23
+ proseText: string;
24
+ } | {
25
+ ok: false;
26
+ say: string;
27
+ };
28
+ /**
29
+ * Drop or Add a row of a saved plan, at $0. Returns the files of the NEW plan folder (the caller writes them once); the old plan is never touched.
30
+ * @param {{planDir: string, op: 'drop'|'add', key: string, asks?: boolean}} o
31
+ * @returns {{ok: true, files: Record<string, string>, pages: Record<string, string>, logRow: Record<string, any>, hash: string}|{ok: false, say: string, refused?: string}}
32
+ */
33
+ export function rowEditPlan({ planDir, op, key, asks }: {
34
+ planDir: string;
35
+ op: "drop" | "add";
36
+ key: string;
37
+ asks?: boolean;
38
+ }): {
39
+ ok: true;
40
+ files: Record<string, string>;
41
+ pages: Record<string, string>;
42
+ logRow: Record<string, any>;
43
+ hash: string;
44
+ } | {
45
+ ok: false;
46
+ say: string;
47
+ refused?: string;
48
+ };
49
+ /** what a person is told when the saved inputs no longer give the saved list: nothing is written */
50
+ export const REBUILD_CHANGED_SAY: "The inputs of this plan have changed since it was drafted, so its checks cannot be changed here. Draft again from the card. Nothing was changed.";
51
+ /** a plan that has no list (drafted before M16) */
52
+ export const NO_LIST_SAY: "This plan has no list of checks to change. Nothing was changed.";
@@ -138,7 +138,7 @@ export function ceilingCostUsd(rates: {
138
138
  * (the one that matters — the signed hash records the request, not what
139
139
  * ran); `unreported` the provider told us nothing.
140
140
  */
141
- export function classifyModelId(requested: any, returned: any): "unreported" | "match" | "prefix" | "substituted";
141
+ export function classifyModelId(requested: any, returned: any): "prefix" | "unreported" | "match" | "substituted";
142
142
  /**
143
143
  * Sum every round of one model attempt into one meter. Money honesty in the
144
144
  * strict direction: if ANY round has no priced cost, `costUsd` is `null` —
@@ -0,0 +1,33 @@
1
+ /**
2
+ * The ONE user message: the person's job lines (their `~` rules numbered), the look, the inputs (bounded).
3
+ * @param {{jobLines: any[], look: any, texts: Record<string, string>}} o
4
+ * @returns {string}
5
+ */
6
+ export function rowEditUserText({ jobLines, look, texts }: {
7
+ jobLines: any[];
8
+ look: any;
9
+ texts: Record<string, string>;
10
+ }): string;
11
+ export const TICKET_FILTER_SCHEMA_WORDS: "REQUIRED when a job line names a priority or a label (leave it out only when none does). The person signs it; code decides at run start. Listing the line under \"refused\" does not filter anything: only this key does";
12
+ /** the tool a row-edit reply is delivered through */
13
+ export const ROW_EDIT_TOOL: "submit_edits";
14
+ /** what an acknowledged reply returns (the loop ends the call the moment the tool fires) */
15
+ export const ROW_EDIT_ACK: "edits received";
16
+ /** the drafter's system text for the row-edit turn (a prompt register: src/promptregisters.js) */
17
+ export const ROW_EDIT_SYSTEM: string;
18
+ /** the fixed sentence that follows the refusals in a revise turn (the turn carries each refusal's own reason and nothing else) */
19
+ export const ROW_EDIT_REVISE: "Send corrected edits only (an empty \"edits\" list is a good answer).";
20
+ export function rowEditChannel(ticket?: boolean): {
21
+ name: string;
22
+ instruction: string;
23
+ textPath: string;
24
+ tool: (box: {
25
+ calls: any[];
26
+ }) => {
27
+ name: string;
28
+ description: string;
29
+ parameters: Record<string, any>;
30
+ execute: (args: any) => Promise<string>;
31
+ };
32
+ };
33
+ export function editsOf(artifact: any): any[];
@@ -0,0 +1,60 @@
1
+ /**
2
+ * The SHAPE of a `rubric-step` stage's parameters — what a part may carry — and nothing about which class is allowed in
3
+ * this build (that is `checkRubricParts`, which also sees the whole job). Pure, never throws.
4
+ * @param {unknown} p the stage's `params`
5
+ * @param {string} at the path prefix for reds, e.g. `stages[1].params`
6
+ * @returns {ShapeRed[]}
7
+ */
8
+ export function rubricStepShapeReds(p: unknown, at: string): ShapeRed[];
9
+ /**
10
+ * 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
11
+ * reading edit both use: "under $450 or over $900" is two limits, and one reading of it would be a wrong check.
12
+ * @param {string} shape @param {string} text @returns {boolean}
13
+ */
14
+ export function holdsManyBounds(shape: string, text: string): boolean;
15
+ /**
16
+ * 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).
17
+ * @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)
18
+ * @returns {{reading: {op: 'lt'|'lte'|'gt'|'gte', value: number} | {op: 'between', lo: number|string, hi: number|string}} | {why: string}}
19
+ */
20
+ export function readLimit(shape: string, text: string, fact?: any): {
21
+ reading: {
22
+ op: "lt" | "lte" | "gt" | "gte";
23
+ value: number;
24
+ } | {
25
+ op: "between";
26
+ lo: number | string;
27
+ hi: number | string;
28
+ };
29
+ } | {
30
+ why: string;
31
+ };
32
+ /**
33
+ * 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
34
+ * (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
35
+ * not examined here. Pure.
36
+ * @param {any} closeDecl @returns {{ok: true}|{ok: false, error: string}}
37
+ */
38
+ export function listMatchesClose(closeDecl: any): {
39
+ ok: true;
40
+ } | {
41
+ ok: false;
42
+ error: string;
43
+ };
44
+ /** the closed set of classes a part is sorted into; `none` = "I could not sort this one" (a red, in plain words, never a guess) */
45
+ export const PART_CLASSES: readonly string[];
46
+ /**
47
+ * The counted/quoted checks a `countable` part may name, with the fields each needs — read off bareguard's own rule table
48
+ * (`rubricVocabulary`): the names are bareguard's, so a check this build cannot run is inexpressible, not rejected late.
49
+ * (`max`/`min` need a numeric field the step file does not have, so they are not offered.)
50
+ * @type {Readonly<Record<string, readonly string[]>>}
51
+ */
52
+ export const COUNT_CHECKS: Readonly<Record<string, readonly string[]>>;
53
+ export function boundInWords(b: unknown, said: string): boolean;
54
+ export const NEGATING_RE: RegExp;
55
+ export function defaultCitedText(label: string): string;
56
+ export type ShapeRed = {
57
+ code: string;
58
+ path: string;
59
+ detail: string;
60
+ };
@@ -33,9 +33,9 @@ export function readRunInputs(runDir: string | null): {
33
33
  * M8b item 1: the ONE writer of `run.json`, called once when a fresh run has frozen its inputs (`runFlow`); never over an existing record. `model` is the pick
34
34
  * the run started on (M4d am33; null = the section is left out), `thinking` the job's "Thinking on" box as it was at the start (M4d am25: written for every fresh
35
35
  * run, ticked or not), `inputs` the manifest `freezeInputs` returned. A fresh run always has `thinking` and `inputs`.
36
- * @param {string} runDir @param {{ model: { slot: string, model: string }|null, thinking: boolean, inputs: any[], rerun?: {decision: 'rerun', words: string, afterStep: string|null}|null }} start
36
+ * @param {string} runDir @param {{ model: { slot: string, model: string }|null, thinking: boolean, inputs: any[], rerun?: {decision: 'rerun', words: string, afterStep: string|null}|null, placeRules?: {rows: any[]}|null }} start
37
37
  */
38
- export function writeRunStart(runDir: string, { model, thinking, inputs, rerun }: {
38
+ export function writeRunStart(runDir: string, { model, thinking, inputs, rerun, placeRules }: {
39
39
  model: {
40
40
  slot: string;
41
41
  model: string;
@@ -47,6 +47,9 @@ export function writeRunStart(runDir: string, { model, thinking, inputs, rerun }
47
47
  words: string;
48
48
  afterStep: string | null;
49
49
  } | null;
50
+ placeRules?: {
51
+ rows: any[];
52
+ } | null;
50
53
  }): void;
51
54
  /** the file's name in the run's folder */
52
55
  export const RUN_FILE: "run.json";
package/types/runner.d.ts CHANGED
@@ -151,6 +151,48 @@ export function freezeInputs(runDir: string, sources: Array<{
151
151
  skip: string | null;
152
152
  red?: undefined;
153
153
  }>;
154
+ /**
155
+ * M16 item 1: read every place-rule fact of the job's steps from the run's OWN frozen copy of its input, by code, before any provider call. `{ok:false, words}` = a rule
156
+ * was not found (bareloop's stop words); `{ok:true, rows, values}` = the rows to record in run.json and the key-to-value map to bind in memory. No place fact = nothing read.
157
+ * @param {string} runDir @param {any[]} steps @param {any[]} manifest freezeInputs' manifest @param {Record<string, string>} [earlier] key to the value the newest earlier run read ("was")
158
+ */
159
+ export function readRunPlaceRules(runDir: string, steps: any[], manifest: any[], earlier?: Record<string, string>): {
160
+ ok: true;
161
+ rows: null;
162
+ values: {};
163
+ words?: undefined;
164
+ } | {
165
+ ok: false;
166
+ words: string;
167
+ rows?: undefined;
168
+ values?: undefined;
169
+ } | {
170
+ ok: true;
171
+ rows: {
172
+ key: string;
173
+ kind: string;
174
+ found: boolean;
175
+ value: string | null;
176
+ was: string | null;
177
+ reason: string | null;
178
+ }[];
179
+ values: Record<string, string>;
180
+ words?: undefined;
181
+ };
182
+ /**
183
+ * M16 item 1: the steps a RESUMED / continued run carries on with: the signed steps, each place fact's phrase set to the value its own run.json recorded at the start.
184
+ * A job with no place fact returns its steps as they are; a run whose record is missing or has a rule not found is `{ok:false, words: NO_PLACE_RECORD_WORDS}`.
185
+ * @param {string} runDir @param {any[]} steps
186
+ */
187
+ export function stepsWithRecordedPlaces(runDir: string, steps: any[]): {
188
+ ok: true;
189
+ steps: any[];
190
+ words?: undefined;
191
+ } | {
192
+ ok: false;
193
+ words: string;
194
+ steps?: undefined;
195
+ };
154
196
  /**
155
197
  * The sources a rerun re-freezes: each input's original source. M13 item 9.1: a ticket input's source is the ticket's own address; it goes back as its LIST address with the
156
198
  * ticket mark, so the rerun reads the ticket through the job's MCP tools and the signed filter, not as a web page.
@@ -573,10 +615,11 @@ import { readTicketMcp } from './ticket-mcp.js';
573
615
  * @param {string|null} [opts.prevStepId] - the id of step stepNo-1 (null for step 1): the step a "stopped after step N-1" row is filed under
574
616
  * @param {number} [opts.triesDone] - tries a Stop already closed on this step (they count against its limit)
575
617
  * @param {string|null} [opts.runDir] - M4d am29 item 2: the run's folder, where each try saves its checks
618
+ * @param {any[]} [opts.checkList] - M16 item 5: the plan's signed list; a list line's checks carry the row's `by`
576
619
  * @param {Record<string, any>} [opts.mcpGranted] - M13 item 5: this step's signed MCP tools, already bound to its bridge (`runStepRalph` builds them); handed to the model with the verbs
577
620
  * @returns {Promise<{ok:true, artifact:any, attempts:number, hitl?:boolean} | {ok:false, outcome:string, red:string, stop?:{where:string, book:Record<string, any>, step?:string|null}}>}
578
621
  */
579
- declare function runStepTries({ step, primitivesMap, readsMap, businessDate, modelStep, spent, capUsd, ceilingUsd, recordAudit, initialGap, attemptOffset, thinkingBox, learnHints, now, readStop, stepNo, triesDone, runDir, prevStepId, mcpGranted, }: {
622
+ declare function runStepTries({ step, primitivesMap, readsMap, businessDate, modelStep, spent, capUsd, ceilingUsd, recordAudit, initialGap, attemptOffset, thinkingBox, learnHints, now, readStop, stepNo, triesDone, runDir, prevStepId, mcpGranted, checkList, }: {
580
623
  step: any;
581
624
  primitivesMap?: Record<string, any> | undefined;
582
625
  readsMap: Record<string, any>;
@@ -605,6 +648,7 @@ declare function runStepTries({ step, primitivesMap, readsMap, businessDate, mod
605
648
  prevStepId?: string | null | undefined;
606
649
  triesDone?: number | undefined;
607
650
  runDir?: string | null | undefined;
651
+ checkList?: any[] | undefined;
608
652
  mcpGranted?: Record<string, any> | undefined;
609
653
  }): Promise<{
610
654
  ok: true;
@@ -113,4 +113,5 @@ export const SHEET_OP_NAMES: Readonly<{
113
113
  rowMath: "row math";
114
114
  }>;
115
115
  export function rulesOfLine(l: any): string[];
116
+ export function sheetPlainText(name: string, words: string, cw: string): string;
116
117
  export function coversWords(rules: string[]): string;
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Every column name one check holds: its own `column`, `keyColumn`, `groupColumn`, `result`, a row-math operand `a` / `b` (a name; `{const}` is no column), the
3
- * date cells `from` / `to` / `cell`, and the column of each `where` condition and `dateFormats` entry.
2
+ * Every column name one check holds, read from bareguard's own vocabulary: each field of the check's rule that carries `columnAt` ("self": a name; "self.column": a cell
3
+ * `{column, row}`; "each.column": a list of `{column}`; "each": a list of names). A row-math `b` of `{const}` is no column. bareguard owns which fields these are.
4
4
  * @param {any} check @returns {string[]}
5
5
  */
6
6
  export function sheetCheckColumns(check: any): string[];
@@ -28,9 +28,10 @@ export function sheetCoversReds(checks: any[], jobLine: {
28
28
  /** The rows for a step's `close.sheet`, one per check, in order. @param {unknown} sheet @returns {string[]} */
29
29
  export function sheetCheckRows(sheet: unknown): string[];
30
30
  /**
31
- * The $0 sign-time test of one step's sheet checks (M10b item 4): bareguard's `createRubric` is given the checks and the signed fingerprint of each sheet
32
- * they read (`tableSha` of the drafting copy's table). A refusal is a red that names the job line (and the check). A column that is no header of its sheet is
33
- * a red naming the line and the column. Never throws.
31
+ * The $0 sign-time test of one step's sheet checks (M10b item 4): bareguard's `checkTables` is given the checks and the signed fingerprint of each sheet they read
32
+ * (`tableSha` of the drafting copy's table) and returns every problem; each becomes a red that names the job line (and the check) in fwdloop's words. A sheet with no
33
+ * saved copy, a sheet bareguard cannot read as a table, or a column that is no header of its sheet is reported first; a check bareguard refuses only when none of those is.
34
+ * Never throws.
34
35
  * @param {any[]} checks the step's `close.sheet` (already known to be a list of objects) @param {number} line the job line the step comes from
35
36
  * @param {Record<string, {header: string[], rows: any[]}>} tables the drafting copy's table of each sheet role @returns {string[]} reds, each naming the line
36
37
  */
@@ -39,10 +40,10 @@ export function sheetCheckReds(checks: any[], line: number, tables: Record<strin
39
40
  rows: any[];
40
41
  }>): string[];
41
42
  /**
42
- * M10b piece 3: a number or a date in a check comes from the job, never from the model. Every number in a `where` condition (gt gte lt lte eq between) must be a
43
- * number the person said on the job line or its `~` rules (the SAME reader as the page number rules, src/citedwords.js `numbersSaid`: a bare number or an amount,
44
- * not a piece of a time, a date or another amount), and every date (`asOf`, and the values of before / after / dateOn / dateBetween) must be a date they wrote
45
- * exactly. Throws away: a text value (`equals`, `needle`), band bounds, `n`, `tolerance`, `range` are not read here (the job's words do not have to carry them).
43
+ * M10b piece 3: a number or a date in a check comes from the job, never from the model. bareguard's `groundedLiterals` judges every number and date the check carries
44
+ * against the person's words on the job line or its `~` rules (one string, `wordsSaidOn`); each literal it reports missing becomes a red in fwdloop's words. A literal of the
45
+ * wrong type or an unreadable condition is not "not in your words": `createRubric` refuses it (sheetCheckReds), so it is no red here.
46
+ * Throws away: a text value (`equals`, `needle`), band bounds, `n`, `tolerance`, `range` are not read (bareguard does not read them either).
46
47
  * @param {any[]} checks the step's `close.sheet` @param {{n: number, text?: string, rule?: string, rules?: string[]}} jobLine @returns {string[]} reds, each naming the line
47
48
  */
48
49
  export function sheetCheckWordReds(checks: any[], jobLine: {
@@ -60,11 +61,3 @@ export function sheetNoClaimReds(checks: any[], line: number): string[];
60
61
  export const SHEET_RULES: readonly string[];
61
62
  /** most checks one step may carry */
62
63
  export const MAX_SHEET_CHECKS: 20;
63
- /** the fields of a check that hold a column name as a plain string (the ONE list: {@link sheetCheckColumns} reads it, the drafter's tool schema offers a header enum on each) */
64
- export const COLUMN_STRING_FIELDS: readonly string[];
65
- /** the row-math operands: a column name, or (for `b`) `{const}` */
66
- export const COLUMN_OPERAND_FIELDS: readonly string[];
67
- /** the date-cell fields: `{column, row}` */
68
- export const COLUMN_CELL_FIELDS: readonly string[];
69
- /** the list fields whose entries hold a `column` */
70
- export const COLUMN_LIST_FIELDS: readonly string[];
@@ -9,7 +9,8 @@ export function sheetClaims(checks: any[]): Array<{
9
9
  ops: string[];
10
10
  }>;
11
11
  /**
12
- * The `emit_artifact` tool's properties for a step that reads a sheet: one typed box per claim, each required. (`done` is added by the caller, as for every step.)
12
+ * The `emit_artifact` tool's properties for a step that reads a sheet: one typed box per claim, each required, the box's schema bareguard's `claimSchema` of the check
13
+ * (two checks that share a claim name share one box: their keys merge). `covers` is fwdloop's own and is stripped before bareguard reads the check. (`done` is added by the caller.)
13
14
  * @param {any[]} checks @returns {{properties: Record<string, any>, required: string[]}}
14
15
  */
15
16
  export function sheetAnswerProps(checks: any[]): {
@@ -1,7 +1,7 @@
1
1
  /**
2
- * The tool schema of `close.sheet`: a list of bareguard cells / table checks. Every field is a field of bareguard's vocabulary; every column-bearing field
3
- * (`column keyColumn groupColumn result a b from to cell where[].column dateFormats[].column`) is an enum of the sheet's exact header. `covers` is fwdloop's own field
4
- * (which `~` rules of the job line the check covers), kept and signed.
2
+ * The tool schema of `close.sheet`: a list of bareguard cells / table checks. The check's schema is bareguard's `checkSchema` (every column-bearing field an enum of the sheet's
3
+ * exact header, `table` an enum of the roles, one `op` enum); fwdloop drops what a check must not carry (the free-text `explanation` fields: a check carries no prose), puts its
4
+ * own words on id / rule / table / claim / op, and adds `covers` (which `~` rules of the job line the check covers), kept and signed.
5
5
  * @param {Record<string, {header: string[]}>} tables the drafting copy's table of each CSV input role
6
6
  * @returns {Record<string, any>|null} null when there is no sheet with a header to pick from
7
7
  */
@@ -21,5 +21,5 @@ export function sheetOpsBrief(): string[];
21
21
  export function sheetOfferRules(roles: string[]): string[];
22
22
  /** @param {unknown} rule @returns {boolean} true for the `use the column 'X' for 'Y'` rule an agreed column ask writes ({@link columnRuleWords}) */
23
23
  export function isColumnChoiceRule(rule: unknown): boolean;
24
- /** The comparisons of a `where` condition. bareguard publishes them only inside the `where` description (no list), so this is the one copy; a test proves each is named there. */
25
- export const WHERE_CMPS: readonly string[];
24
+ /** The comparisons of a `where` condition, as bareguard's vocabulary lists them. */
25
+ export const WHERE_CMPS: readonly any[];