bareloop 0.55.0 → 0.56.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 +47 -0
- package/bareloop.context.md +4 -2
- package/package.json +2 -2
- package/src/authorflow.js +141 -264
- package/src/authoring.js +2 -3
- package/src/authorjob.js +117 -88
- package/src/authorreadout.js +9 -15
- package/src/authorrun.js +13 -4
- package/src/behaviour.js +14 -0
- package/src/blockasks.js +43 -0
- package/src/checkblock.js +772 -0
- package/src/checklist.js +128 -0
- package/src/checkpick.js +30 -312
- package/src/checkwords.js +3 -1
- package/src/declaredclose.js +30 -1
- package/src/destpoint.js +3 -1
- package/src/draftspend.js +46 -0
- package/src/facts.js +8 -1
- package/src/fitcheck.js +5 -3
- package/src/pagemap.js +15 -3
- package/src/panel/authorroutes.js +15 -3
- package/src/panel/authorsession.js +133 -46
- package/src/panel/index.html +194 -22
- package/src/panel/jobplan.js +85 -33
- package/src/panel/server.js +52 -7
- package/src/pickrecord.js +19 -1
- package/src/placerule.js +355 -0
- package/src/promptregisters.js +11 -0
- package/src/questionbox.js +112 -0
- package/src/rowedit.js +115 -0
- package/src/rubricstep.js +212 -125
- package/src/run.js +10 -2
- package/src/userrun.js +46 -1
- package/types/authorflow.d.ts +32 -139
- package/types/authorjob.d.ts +24 -6
- package/types/authorreadout.d.ts +4 -10
- package/types/behaviour.d.ts +12 -0
- package/types/blockasks.d.ts +37 -0
- package/types/checkblock.d.ts +361 -0
- package/types/checklist.d.ts +134 -0
- package/types/checkpick.d.ts +3 -140
- package/types/declaredclose.d.ts +4 -0
- package/types/destpoint.d.ts +2 -0
- package/types/draftspend.d.ts +21 -0
- package/types/fitcheck.d.ts +7 -1
- package/types/pagemap.d.ts +4 -0
- package/types/panel/authorsession.d.ts +13 -2
- package/types/panel/jobgrid.d.ts +8 -8
- package/types/panel/jobplan.d.ts +48 -10
- package/types/panel/server.d.ts +14 -13
- package/types/pickrecord.d.ts +12 -0
- package/types/placerule.d.ts +194 -0
- package/types/questionbox.d.ts +87 -0
- package/types/rowedit.d.ts +32 -0
- package/types/rubricstep.d.ts +91 -48
- package/types/run.d.ts +10 -1
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
/** the card lines: rows in, lines out. ONE pure function of the rows; nothing else may feed it. @param {Row[]} rows */
|
|
2
|
+
export function renderCard(rows: Row[]): {
|
|
3
|
+
key: any;
|
|
4
|
+
line: any;
|
|
5
|
+
by: any;
|
|
6
|
+
state: any;
|
|
7
|
+
reason: any;
|
|
8
|
+
text: string;
|
|
9
|
+
}[];
|
|
10
|
+
/**
|
|
11
|
+
* A row. `kind`: rule, fact, phrase, count, cited, numbers, floor. `by`: you (`~`), agent (`!`), default (`$`). A `~` row may carry `links` (the look's facts tied to it),
|
|
12
|
+
* `pick`, `aiReading`, `left`. `state` is built or not-checked; a not-checked row always has a plain `reason`.
|
|
13
|
+
* @typedef {Record<string, any>} Row
|
|
14
|
+
*/
|
|
15
|
+
/** the card's fixed words, one spelling (the renderer reads them; a test reads them too) */
|
|
16
|
+
export const CARD_T: Readonly<{
|
|
17
|
+
agreed: "you agreed:";
|
|
18
|
+
count: "result count";
|
|
19
|
+
cited: "every claim is backed by a quote copied from";
|
|
20
|
+
theInput: "the input";
|
|
21
|
+
numbers: "every number in the text is in a checked quote of line";
|
|
22
|
+
withWords: "with the words";
|
|
23
|
+
}>;
|
|
24
|
+
/** the four row edits an AI reply may hold */
|
|
25
|
+
export const EDIT_OPS: readonly string[];
|
|
26
|
+
/** the plain reasons code gives, in one place (the card, the Job tab and the Audit read them from the row) */
|
|
27
|
+
export const REASON: Readonly<{
|
|
28
|
+
left: "You chose to leave it Not checked, so you judge it at Accept.";
|
|
29
|
+
nothingOnPage: "Your own words are on the line; the machine has no check for them, so you judge it at Accept.";
|
|
30
|
+
cantCheck: "I can't check this on the page; waiting for your answer";
|
|
31
|
+
noRule: "No rule can check this, so you judge it at Accept.";
|
|
32
|
+
waitingPick: "waiting for your answer on the proposed check";
|
|
33
|
+
waitingReading: "waiting for your answer on the reading";
|
|
34
|
+
onePerLine: "this line finds facts, so it has no text to quote";
|
|
35
|
+
manyInputs: "the job has more than one input and code cannot pick which one the claims quote";
|
|
36
|
+
oneSidedTime: "a time limit the AI proposes must be a range, so you judge it at Accept.";
|
|
37
|
+
countNeedsFact: "a result count needs a fact to count; this line has none";
|
|
38
|
+
lookNoWords: "the page does not hold the words of the look's fact for this rule";
|
|
39
|
+
afterLast: "no more tries: Start over (rows are never changed by the AI after the last try)";
|
|
40
|
+
noPick: "No check was picked for it, so you judge it at Accept.";
|
|
41
|
+
negated: "it says what is not needed, so there is nothing to check";
|
|
42
|
+
dropped: "You dropped it.";
|
|
43
|
+
suggested: "Suggested: not in your job, so it is not checked unless you add it.";
|
|
44
|
+
}>;
|
|
45
|
+
export class CheckBlock {
|
|
46
|
+
/** @param {{texts: Record<string, string>, labels: string[], maxTries?: number, countScope?: (ruleText: string) => boolean, asks?: boolean, split?: boolean}} o the frozen input texts, their labels, how many AI replies (tries) may still change a row, whether code scopes a counting `~` rule in (a pick is asked), and whether a person can be asked at all (`asks`: false = a rule code cannot settle is Not checked, a reading code proposes is built as the AI's proposal) */
|
|
47
|
+
constructor({ texts, labels, maxTries, countScope, asks, split }: {
|
|
48
|
+
texts: Record<string, string>;
|
|
49
|
+
labels: string[];
|
|
50
|
+
maxTries?: number;
|
|
51
|
+
countScope?: (ruleText: string) => boolean;
|
|
52
|
+
asks?: boolean;
|
|
53
|
+
split?: boolean;
|
|
54
|
+
});
|
|
55
|
+
/** the product path sets it: `!` rows split into job-derived and suggested, a suggestion code cannot build is hidden (hamr 2026-11-13). Off, every `!` row is built as before (the older callers and their tests) */
|
|
56
|
+
split: boolean;
|
|
57
|
+
countScope: (ruleText: string) => boolean;
|
|
58
|
+
asks: boolean;
|
|
59
|
+
texts: Record<string, string>;
|
|
60
|
+
labels: string[];
|
|
61
|
+
maxTries: number;
|
|
62
|
+
/** @type {Row[]} the ONE store */
|
|
63
|
+
rows: Row[];
|
|
64
|
+
/** @type {{n: number, text: string}[]} */
|
|
65
|
+
lines: {
|
|
66
|
+
n: number;
|
|
67
|
+
text: string;
|
|
68
|
+
}[];
|
|
69
|
+
/** @type {any[]} the look's facts as given (a `reading` edit names one) */
|
|
70
|
+
lookFacts: any[];
|
|
71
|
+
/** @type {{facts: any[], dropped: any[]}|null} the look as the draft gate reads it (null = no look report: the gate proves a label against the list code made) */
|
|
72
|
+
look: {
|
|
73
|
+
facts: any[];
|
|
74
|
+
dropped: any[];
|
|
75
|
+
} | null;
|
|
76
|
+
/** @type {any[]} replies waiting to be applied by `drive` */
|
|
77
|
+
queue: any[];
|
|
78
|
+
/** @type {any[]} the open questions, set by `ask` */
|
|
79
|
+
open: any[];
|
|
80
|
+
/** @type {string[]} the keys of questions a person did not answer */
|
|
81
|
+
unanswered: string[];
|
|
82
|
+
tries: number;
|
|
83
|
+
/** @type {any[]} every reply's record: each edit, kept or refused with its own reason */
|
|
84
|
+
deltaLog: any[];
|
|
85
|
+
/** @type {any} */
|
|
86
|
+
closeCache: any;
|
|
87
|
+
textOf(source: string | undefined): string;
|
|
88
|
+
/** @param {number} line @param {string} [kind] */
|
|
89
|
+
rowsOn(line: number, kind?: string): Row[];
|
|
90
|
+
ruleRows(line: number): Row[];
|
|
91
|
+
/** every word the person wrote on a line: the line and its `~` rules */
|
|
92
|
+
said(line: number): string;
|
|
93
|
+
/** @param {Row} r @returns {Row} the row as stored (a repeated key gets `#2`) */
|
|
94
|
+
addRow(r: Row): Row;
|
|
95
|
+
/** @param {{n: number, text: string, rules?: string[]}[]} jobLines */
|
|
96
|
+
fromJob(jobLines: {
|
|
97
|
+
n: number;
|
|
98
|
+
text: string;
|
|
99
|
+
rules?: string[];
|
|
100
|
+
}[]): void;
|
|
101
|
+
/**
|
|
102
|
+
* @param {any[]} facts the look's kept facts @param {any[]} [dropped] the look's drops (`look.dropped`): a whole fact a page rule left out. Its plain sentence (src/pagedropwords.js)
|
|
103
|
+
* becomes the `why` of the `~` rule it was tied to, or a Not checked `!` row of its own, so every drop shows under Not checked.
|
|
104
|
+
*/
|
|
105
|
+
addLook(facts: any[], dropped?: any[]): void;
|
|
106
|
+
match(): void;
|
|
107
|
+
/** a `!` row: the agent's fact, phrase or count (a look fact tied to a rule is a link on that rule's row, never a row of its own) */
|
|
108
|
+
isBang(r: Row): boolean;
|
|
109
|
+
/**
|
|
110
|
+
* The job's own word for a `!` row: when none of its page words is in the job line or its `~` rules but a proper name the job holds (capital or digit first, 3+ characters) is a whole-word part of one
|
|
111
|
+
* page word and the page holds it, the row's words become that job word. The page's long name is kept as `pageWords`; the row's other fields are untouched.
|
|
112
|
+
*/
|
|
113
|
+
takeJobWord(r: Row): void;
|
|
114
|
+
/** are the row's words (or its count number, or the name it asks for a fact by) in the job line or its `~` rules? Normalised, case-insensitive */
|
|
115
|
+
inJob(r: Row): any;
|
|
116
|
+
/** a `~` line an agreed answer wrote (or a carried pair partner) is checked by the rule it was agreed from: one check, both numbers */
|
|
117
|
+
matchFollow(r: Row): void;
|
|
118
|
+
/** a `!` count row is built unless a `~` rule on its line already names the number */
|
|
119
|
+
matchCount(r: Row): void;
|
|
120
|
+
matchRule(r: Row): void;
|
|
121
|
+
/** a `~` rule that counts words, bullets, lines or sections: a settled pick builds it; else code proposes the check and asks */
|
|
122
|
+
matchCountRule(r: Row): void;
|
|
123
|
+
/** a `!` fact or phrase row: its words must be on the page; a version or a date is true only today, so only a place rule's fit may carry it */
|
|
124
|
+
matchBang(r: Row): void;
|
|
125
|
+
build(): any;
|
|
126
|
+
/** build the line as if this held row were on: when it builds, `offer` is the row as the card would draw it; else the row is hidden with code's reason. The rows' own state is restored */
|
|
127
|
+
trialOffer(r: Row): void;
|
|
128
|
+
/** one line's parts: a pick part per count rule, ONE fact part carrying every fact row of the line (and its result count), then the `$` defaults */
|
|
129
|
+
buildLine(l: {
|
|
130
|
+
n: number;
|
|
131
|
+
text: string;
|
|
132
|
+
}, lineParts: any[], lineRows: string[][], factLines: Set<number>): void;
|
|
133
|
+
/** the follow rows of a row (its agreed or carried `~` lines) */
|
|
134
|
+
followsOf(r: Row): Row[];
|
|
135
|
+
/**
|
|
136
|
+
* The fact(s) a fact-like row builds, checked alone through the bareguard shapes and against the facts already on the line.
|
|
137
|
+
* @param {Row} r @param {any[]} onLine the facts already built on this line @returns {{fresh: any[], src: string, names: string[]} | {why: string}}
|
|
138
|
+
*/
|
|
139
|
+
factsOf(r: Row, onLine: any[]): {
|
|
140
|
+
fresh: any[];
|
|
141
|
+
src: string;
|
|
142
|
+
names: string[];
|
|
143
|
+
} | {
|
|
144
|
+
why: string;
|
|
145
|
+
};
|
|
146
|
+
/** the `$` defaults of a line, decided from what the line ended with: a text line quotes its input (one input only) and ties its numbers to the fact lines before it */
|
|
147
|
+
buildDefaults(l: {
|
|
148
|
+
n: number;
|
|
149
|
+
}, lineParts: any[], lineRows: string[][], factLines: Set<number>): void;
|
|
150
|
+
ask(): any[];
|
|
151
|
+
hasOpenQuestions(): boolean;
|
|
152
|
+
hasPendingDelta(): boolean;
|
|
153
|
+
/** @param {string} qKey @param {string} choice @param {string} [text] @returns {{ok: true} | {ok: false, why: string}} */
|
|
154
|
+
applyAnswer(qKey: string, choice: string, text?: string): {
|
|
155
|
+
ok: true;
|
|
156
|
+
} | {
|
|
157
|
+
ok: false;
|
|
158
|
+
why: string;
|
|
159
|
+
};
|
|
160
|
+
/** the `~` row `partner` is checked by `source` (one check, both rule numbers) */
|
|
161
|
+
follow(source: Row, partner: Row): void;
|
|
162
|
+
/**
|
|
163
|
+
* Revise keeps the picks of the last draft (am17/am18/am21, `src/pickrecord.js` `matchRecord`): a kept pick settles its rule and its added `~` line follows it; a kept left rule is
|
|
164
|
+
* left; an edited added line (`pairRule`) is the row asked and its source follows it.
|
|
165
|
+
* @param {{picks?: {line: number, rule: number, check: any, added?: string, own?: boolean}[], left?: {line: number, rule: number}[]}} kept
|
|
166
|
+
* @param {{line: number, rule: number, pairRule?: number}[]} [asked] the rules still asked (a `pairRule` marks an edited added line)
|
|
167
|
+
*/
|
|
168
|
+
carry({ picks, left }: {
|
|
169
|
+
picks?: {
|
|
170
|
+
line: number;
|
|
171
|
+
rule: number;
|
|
172
|
+
check: any;
|
|
173
|
+
added?: string;
|
|
174
|
+
own?: boolean;
|
|
175
|
+
}[];
|
|
176
|
+
left?: {
|
|
177
|
+
line: number;
|
|
178
|
+
rule: number;
|
|
179
|
+
}[];
|
|
180
|
+
}, asked?: {
|
|
181
|
+
line: number;
|
|
182
|
+
rule: number;
|
|
183
|
+
pairRule?: number;
|
|
184
|
+
}[]): void;
|
|
185
|
+
/** @param {{label?: string, pre?: boolean, edits?: any[]}} delta `pre` = a reply that is not a drafter try (the suggest call): it does not count against the tries */
|
|
186
|
+
applyDelta(delta: {
|
|
187
|
+
label?: string;
|
|
188
|
+
pre?: boolean;
|
|
189
|
+
edits?: any[];
|
|
190
|
+
}): {
|
|
191
|
+
label: string | undefined;
|
|
192
|
+
pre: boolean;
|
|
193
|
+
edits: any[];
|
|
194
|
+
};
|
|
195
|
+
applyEdit(e: any, kept: {
|
|
196
|
+
adds: number;
|
|
197
|
+
}): {
|
|
198
|
+
accepted: boolean;
|
|
199
|
+
landedKey: any;
|
|
200
|
+
refusedBecause?: undefined;
|
|
201
|
+
} | {
|
|
202
|
+
refusedBecause: string;
|
|
203
|
+
};
|
|
204
|
+
editAdd(e: any): {
|
|
205
|
+
refusedBecause: string;
|
|
206
|
+
accepted?: undefined;
|
|
207
|
+
landedKey?: undefined;
|
|
208
|
+
} | {
|
|
209
|
+
accepted: boolean;
|
|
210
|
+
landedKey: any;
|
|
211
|
+
refusedBecause?: undefined;
|
|
212
|
+
};
|
|
213
|
+
/** @returns {string|null} the plain reason an add repeats what the list already holds (a look fact tied to a `~` rule, a `~` rule's own words, another `!` row), else null */
|
|
214
|
+
onTheList(line: number, name: string, words: string[]): string | null;
|
|
215
|
+
addCount(e: any): {
|
|
216
|
+
refusedBecause: string;
|
|
217
|
+
accepted?: undefined;
|
|
218
|
+
landedKey?: undefined;
|
|
219
|
+
} | {
|
|
220
|
+
accepted: boolean;
|
|
221
|
+
landedKey: any;
|
|
222
|
+
refusedBecause?: undefined;
|
|
223
|
+
};
|
|
224
|
+
/** the `~` rule rows of a line an edit names by number */
|
|
225
|
+
targetsOf(e: any): any;
|
|
226
|
+
/** the one owner of "what do the person's own words say": code's reading of a `~` rule for a money/time fact, or undefined when it cannot read it */
|
|
227
|
+
wordsReading(l: any, text: string): {
|
|
228
|
+
op: "lt" | "lte" | "gt" | "gte";
|
|
229
|
+
value: number;
|
|
230
|
+
} | {
|
|
231
|
+
op: "between";
|
|
232
|
+
lo: number | string;
|
|
233
|
+
hi: number | string;
|
|
234
|
+
} | undefined;
|
|
235
|
+
editReading(e: any): {
|
|
236
|
+
refusedBecause: string;
|
|
237
|
+
accepted?: undefined;
|
|
238
|
+
landedKey?: undefined;
|
|
239
|
+
} | {
|
|
240
|
+
accepted: boolean;
|
|
241
|
+
landedKey: any;
|
|
242
|
+
refusedBecause?: undefined;
|
|
243
|
+
};
|
|
244
|
+
editPick(e: any): {
|
|
245
|
+
refusedBecause: string;
|
|
246
|
+
accepted?: undefined;
|
|
247
|
+
landedKey?: undefined;
|
|
248
|
+
} | {
|
|
249
|
+
accepted: boolean;
|
|
250
|
+
landedKey: any;
|
|
251
|
+
refusedBecause?: undefined;
|
|
252
|
+
};
|
|
253
|
+
editNot(e: any): {
|
|
254
|
+
refusedBecause: string;
|
|
255
|
+
accepted?: undefined;
|
|
256
|
+
landedKey?: undefined;
|
|
257
|
+
} | {
|
|
258
|
+
accepted: boolean;
|
|
259
|
+
landedKey: any;
|
|
260
|
+
refusedBecause?: undefined;
|
|
261
|
+
};
|
|
262
|
+
reconcile(): any;
|
|
263
|
+
/** the loop: while a question is open or a reply waits, apply it and reconcile the WHOLE list again. `answer(q)` gives {choice, text} or null (a person who did not answer) */
|
|
264
|
+
drive({ answer }: {
|
|
265
|
+
answer: any;
|
|
266
|
+
}): this;
|
|
267
|
+
card(): {
|
|
268
|
+
key: any;
|
|
269
|
+
line: any;
|
|
270
|
+
by: any;
|
|
271
|
+
state: any;
|
|
272
|
+
reason: any;
|
|
273
|
+
text: string;
|
|
274
|
+
}[];
|
|
275
|
+
/**
|
|
276
|
+
* The rows as the close shape the card readers (`checksOfClose`, `refusedOf`, `cardOfClose`) already read: the block's stages, the picks code records and the signed list. The confirm card
|
|
277
|
+
* and the signed card read the rows through the SAME readers, so a row shown at confirm is the row signed. Reconciles first (the whole list, every time).
|
|
278
|
+
*/
|
|
279
|
+
closeView(): {
|
|
280
|
+
stages: any;
|
|
281
|
+
picks: {
|
|
282
|
+
line: number;
|
|
283
|
+
part: any;
|
|
284
|
+
}[];
|
|
285
|
+
list: {
|
|
286
|
+
[k: string]: any;
|
|
287
|
+
}[];
|
|
288
|
+
};
|
|
289
|
+
/** the picks code records: a countable part carrying the `~` rule numbers it settles @param {{parts: any[], map: {part: number, line: number}[]}} c the build @returns {{line: number, part: any}[]} */
|
|
290
|
+
picksOf(c: {
|
|
291
|
+
parts: any[];
|
|
292
|
+
map: {
|
|
293
|
+
part: number;
|
|
294
|
+
line: number;
|
|
295
|
+
}[];
|
|
296
|
+
}): {
|
|
297
|
+
line: number;
|
|
298
|
+
part: any;
|
|
299
|
+
}[];
|
|
300
|
+
/** the standing ruling "a run needs one check": one row that is not the floor is built */
|
|
301
|
+
hasBuiltCheck(): boolean;
|
|
302
|
+
/**
|
|
303
|
+
* The signed list (`closeDecl.list`): the signed fields of every row, never its words. A suggestion not added is signed `dropped` ("suggested, not added"), a suggestion code could not build
|
|
304
|
+
* `dropped` with code's reason (it is on the Audit, never on the card), and a built row carries the names of the facts it made (`facts`), so every reader can tag each fact by its row's kind.
|
|
305
|
+
*/
|
|
306
|
+
signedRows(): {
|
|
307
|
+
[k: string]: any;
|
|
308
|
+
}[];
|
|
309
|
+
/** the suggestions code has proved it can build, as the card offers them (Add): `{key, line, text}` */
|
|
310
|
+
suggestedView(): {
|
|
311
|
+
dropped?: boolean | undefined;
|
|
312
|
+
key: any;
|
|
313
|
+
line: any;
|
|
314
|
+
text: string;
|
|
315
|
+
}[];
|
|
316
|
+
/** the suggestions code could not build, in one plain sentence each: the Audit's draft lines (never the card) */
|
|
317
|
+
unbuiltSuggestions(): {
|
|
318
|
+
line: any;
|
|
319
|
+
text: string;
|
|
320
|
+
}[];
|
|
321
|
+
/**
|
|
322
|
+
* The person's Drop or Add on a `!` row (hamr 2026-11-13: instant, $0, no AI; the choice decides). The whole list is reconciled again, so an Add is judged by code like every other row.
|
|
323
|
+
* @param {string} key @param {'drop'|'add'} choice @returns {{ok: true} | {ok: false, why: string}}
|
|
324
|
+
*/
|
|
325
|
+
rowChoice(key: string, choice: "drop" | "add"): {
|
|
326
|
+
ok: true;
|
|
327
|
+
} | {
|
|
328
|
+
ok: false;
|
|
329
|
+
why: string;
|
|
330
|
+
};
|
|
331
|
+
/** the person's Drop/Add choices, tied to the line's words (not its number) and the row's own name, so a Revise keeps them @returns {{lineWords: string, occurrence: number, tail: string, choice: string}[]} */
|
|
332
|
+
choicesRecord(): {
|
|
333
|
+
lineWords: string;
|
|
334
|
+
occurrence: number;
|
|
335
|
+
tail: string;
|
|
336
|
+
choice: string;
|
|
337
|
+
}[];
|
|
338
|
+
/** a Revise keeps the last draft's Drop/Add choices on the rows that are still there (same line words, same row); code still judges every one @param {{lineWords: string, occurrence: number, tail: string, choice: string}[]} rec */
|
|
339
|
+
carryChoices(rec: {
|
|
340
|
+
lineWords: string;
|
|
341
|
+
occurrence: number;
|
|
342
|
+
tail: string;
|
|
343
|
+
choice: string;
|
|
344
|
+
}[]): void;
|
|
345
|
+
/**
|
|
346
|
+
* per line, the shape of `retentionOfList` (counts only): `aiParts` = the rows the agent proposed (and the default cited), `kept` = those built, `dropped` = the rest, `picks` = a `~` row built from a pick
|
|
347
|
+
* @returns {{line: number, aiParts: number, kept: number, dropped: number, picks: boolean}[]}
|
|
348
|
+
*/
|
|
349
|
+
retention(): {
|
|
350
|
+
line: number;
|
|
351
|
+
aiParts: number;
|
|
352
|
+
kept: number;
|
|
353
|
+
dropped: number;
|
|
354
|
+
picks: boolean;
|
|
355
|
+
}[];
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* A row. `kind`: rule, fact, phrase, count, cited, numbers, floor. `by`: you (`~`), agent (`!`), default (`$`). A `~` row may carry `links` (the look's facts tied to it),
|
|
359
|
+
* `pick`, `aiReading`, `left`. `state` is built or not-checked; a not-checked row always has a plain `reason`.
|
|
360
|
+
*/
|
|
361
|
+
export type Row = Record<string, any>;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A check that needs exact words from the input is true only while the input stays as it is when those words hold a VERSION-like token (1.2 or 1.2.3, not after a currency sign or before
|
|
3
|
+
* a percent) or a DATE-like token (2026-11-04, 04/11/2026, "Nov 4, 2026", "4 November 2026", "November 2026"). Code refuses it; a `~` rule is the person's own and is never refused by this.
|
|
4
|
+
* @param {unknown} t @returns {boolean}
|
|
5
|
+
*/
|
|
6
|
+
export function weekOnly(t: unknown): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* The version-like and date-like tokens a text holds (the very tokens {@link weekOnly} reads), each once. Pure.
|
|
9
|
+
* @param {unknown} t @returns {string[]}
|
|
10
|
+
*/
|
|
11
|
+
export function weekTokens(t: unknown): string[];
|
|
12
|
+
/** @param {{n: number, text: string, rules?: string[], rule?: string}[]} jobLines @param {Record<string, string>} texts @returns {string} */
|
|
13
|
+
export function ledgerUserText(jobLines: {
|
|
14
|
+
n: number;
|
|
15
|
+
text: string;
|
|
16
|
+
rules?: string[];
|
|
17
|
+
rule?: string;
|
|
18
|
+
}[], texts: Record<string, string>): string;
|
|
19
|
+
/**
|
|
20
|
+
* The one paid call; its spend is booked like the look's. An unusable answer is NOT a guessed list: it yields no `!` proposals and says why.
|
|
21
|
+
* @param {{jobLines: any[], texts: Record<string, string>, generate: Function, ceilingUsd?: number|null, onCall?: (c: any) => void, priorCalls?: any[], priorRaws?: any[]}} o
|
|
22
|
+
* @returns {Promise<{extra: any[], reason: string|null, calls: any[], raws: any[]}>}
|
|
23
|
+
*/
|
|
24
|
+
export function runLedgerSuggest({ jobLines, texts, generate, ceilingUsd, onCall, priorCalls, priorRaws }: {
|
|
25
|
+
jobLines: any[];
|
|
26
|
+
texts: Record<string, string>;
|
|
27
|
+
generate: Function;
|
|
28
|
+
ceilingUsd?: number | null;
|
|
29
|
+
onCall?: (c: any) => void;
|
|
30
|
+
priorCalls?: any[];
|
|
31
|
+
priorRaws?: any[];
|
|
32
|
+
}): Promise<{
|
|
33
|
+
extra: any[];
|
|
34
|
+
reason: string | null;
|
|
35
|
+
calls: any[];
|
|
36
|
+
raws: any[];
|
|
37
|
+
}>;
|
|
38
|
+
/** at most this many `!` checks come from the call */
|
|
39
|
+
export const MAX_BANG: 3;
|
|
40
|
+
/** the reason a check on a version or a date goes under Not checked: it is true only for the input as it is today */
|
|
41
|
+
export const WEEK_ONLY_WORDS: "It names a version or a date from the input, true only for the input as it is today, so you judge it at Accept.";
|
|
42
|
+
/** the label of the list call, as the drafting book and the draft log see it */
|
|
43
|
+
export const LEDGER_LABEL: "ledger-suggest";
|
|
44
|
+
export const LEDGER_TOOL: "suggest_extra_checks";
|
|
45
|
+
/** the reason the empty list is logged with */
|
|
46
|
+
export const EMPTY_LIST_WORDS: "empty list: nothing to check";
|
|
47
|
+
export function isEmptyList(rows: Row[]): boolean;
|
|
48
|
+
export function ledgerRecord(rows: Row[]): ({
|
|
49
|
+
key: string;
|
|
50
|
+
line: number;
|
|
51
|
+
rowKind: "fact" | "phrase" | "rule" | "count" | "numbers" | "cited" | "floor";
|
|
52
|
+
from: "rule" | "agent" | "default" | "pick" | "look";
|
|
53
|
+
by: "you" | "agent" | "default";
|
|
54
|
+
words: string[];
|
|
55
|
+
state: "dropped" | "not-checked" | "built" | "listed";
|
|
56
|
+
reason: string | null;
|
|
57
|
+
} | {
|
|
58
|
+
key: string;
|
|
59
|
+
line: number;
|
|
60
|
+
rowKind: string;
|
|
61
|
+
from: string;
|
|
62
|
+
by: string;
|
|
63
|
+
words: never[];
|
|
64
|
+
state: string;
|
|
65
|
+
reason: string;
|
|
66
|
+
})[];
|
|
67
|
+
/** the list call's own system text (model-facing; used only by the list call of a rubric job with input text) */
|
|
68
|
+
export const LEDGER_SYSTEM: "You look at the inputs of a job and name checks the inputs themselves support, beyond the guardrails the person wrote.\nCall suggest_extra_checks once with up to 3 entries, or with an empty list.\n- kind \"count\": how many results the input shows or the job asks for (min and/or max, whole numbers).\n- kind \"phrase\": fixed words copied verbatim from an input (phrase, and source = that input's label).\nUse only what you can see in the inputs. Do not repeat a guardrail the person wrote. If the inputs support none, send an empty list.";
|
|
69
|
+
export const LEDGER_SCHEMA: Readonly<{
|
|
70
|
+
type: "object";
|
|
71
|
+
properties: {
|
|
72
|
+
extra: {
|
|
73
|
+
type: string;
|
|
74
|
+
maxItems: number;
|
|
75
|
+
items: {
|
|
76
|
+
type: string;
|
|
77
|
+
properties: {
|
|
78
|
+
line: {
|
|
79
|
+
type: string;
|
|
80
|
+
minimum: number;
|
|
81
|
+
description: string;
|
|
82
|
+
};
|
|
83
|
+
kind: {
|
|
84
|
+
enum: string[];
|
|
85
|
+
};
|
|
86
|
+
source: {
|
|
87
|
+
type: string;
|
|
88
|
+
description: string;
|
|
89
|
+
};
|
|
90
|
+
phrase: {
|
|
91
|
+
type: string;
|
|
92
|
+
description: string;
|
|
93
|
+
};
|
|
94
|
+
min: {
|
|
95
|
+
type: string;
|
|
96
|
+
minimum: number;
|
|
97
|
+
};
|
|
98
|
+
max: {
|
|
99
|
+
type: string;
|
|
100
|
+
minimum: number;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
required: string[];
|
|
104
|
+
additionalProperties: boolean;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
required: string[];
|
|
109
|
+
additionalProperties: false;
|
|
110
|
+
}>;
|
|
111
|
+
export type Row = {
|
|
112
|
+
key: string;
|
|
113
|
+
line: number;
|
|
114
|
+
kind: "rule" | "fact" | "cited" | "count" | "phrase" | "numbers" | "floor";
|
|
115
|
+
from: "rule" | "pick" | "look" | "agent" | "default";
|
|
116
|
+
by: "you" | "agent" | "default";
|
|
117
|
+
words: string[];
|
|
118
|
+
text?: string;
|
|
119
|
+
rule?: number;
|
|
120
|
+
part?: {
|
|
121
|
+
line: number;
|
|
122
|
+
part: number;
|
|
123
|
+
};
|
|
124
|
+
source?: string;
|
|
125
|
+
name?: string;
|
|
126
|
+
min?: number;
|
|
127
|
+
max?: number;
|
|
128
|
+
pick?: string;
|
|
129
|
+
after?: number[];
|
|
130
|
+
state: "listed" | "built" | "not-checked" | "dropped";
|
|
131
|
+
reason: string | null;
|
|
132
|
+
forRule?: number;
|
|
133
|
+
reading?: import("./pagerules.js").Reading;
|
|
134
|
+
};
|
package/types/checkpick.d.ts
CHANGED
|
@@ -48,7 +48,7 @@ export function suggestUserText(lines: {
|
|
|
48
48
|
text: string;
|
|
49
49
|
}[], scoped: Rule[]): string;
|
|
50
50
|
/**
|
|
51
|
-
* The check CODE proposes for a count rule when the call yields none (R10, ours; fwd has no such fallback): a bullets / list-items / points count -> listItems N, a lines count ->
|
|
51
|
+
* The check CODE proposes for a count rule when the call yields none (R10, ours; fwd has no such fallback): a bullets / list-items / points count -> listItems N (exact; "at most / up to / no more than / fewer than / under / below" -> maxListItems, "at least / minimum / no fewer than / more than" -> minListItems, F315), a lines count ->
|
|
52
52
|
* maxLines N, ONE word number -> minWords N when the rule says "at least / minimum / more than", else maxWords N. A section count names no sections, so none is built; a rule naming two different counts ("3 bullets under 80 words") is not built either; a rule with
|
|
53
53
|
* several word numbers or a range ("between 100 and 200 words") is not guessed. The result passes `keepOrDrop`, so every number is one the rule names.
|
|
54
54
|
* @param {string} text @returns {Record<string, any>|null}
|
|
@@ -64,53 +64,6 @@ export function rowsFromAnswer(scoped: Rule[], args: any): (Rule & {
|
|
|
64
64
|
check: Record<string, any> | null;
|
|
65
65
|
why: string | null;
|
|
66
66
|
})[];
|
|
67
|
-
/**
|
|
68
|
-
* @typedef {{line: number, rule: number, source: 'look', ask: 'check'|'no-check', ruleText: string, question: string, reading?: string, check?: Record<string, any>, counted: boolean, pairRule?: number}} PickAsk
|
|
69
|
-
*/
|
|
70
|
-
/**
|
|
71
|
-
* The asks for the rows: `Line n, guardrail "<...>": I propose <check in plain words>.` for a kept check, `Line n, guardrail "<...>": I can't check this. Your own words, or
|
|
72
|
-
* Not checked?` when nothing was kept. A proposal is not counted toward the 3-ask cap; a can't-check ask is (fwd am16 (5)). Both ride the existing code-forced look ask path
|
|
73
|
-
* (`source: 'look'`), so the chat message, the answer words and the draft log rows are the look asks' own.
|
|
74
|
-
* @param {ReturnType<typeof rowsFromAnswer>} rows @returns {PickAsk[]}
|
|
75
|
-
*/
|
|
76
|
-
export function checkAsks(rows: ReturnType<typeof rowsFromAnswer>): PickAsk[];
|
|
77
|
-
/**
|
|
78
|
-
* Settle every scoped rule against the person's answers: a rule with a picked check is checked (and the `~` line an agree wrote is covered by that pick); every other rule is
|
|
79
|
-
* Not checked, with the reason (`person-left` = they chose it, `own-words` = they gave their own words, `no-pick` = nothing was picked).
|
|
80
|
-
* @param {Rule[]} rules @param {Pick[]} picks @param {{line: number, rule: number, kept?: boolean}[]} left @param {{n: number, rule?: string, rules?: string[]}[]} jobLines the lines AFTER the answers were added
|
|
81
|
-
* @returns {{checks: {line: number, text: string, check: Record<string, any>, rules: number[], kept: boolean}[], notes: (Rule & {reason: NoteReason, also: number[], kept: boolean})[]}}
|
|
82
|
-
*/
|
|
83
|
-
export function settleRules(rules: Rule[], picks: Pick[], left: {
|
|
84
|
-
line: number;
|
|
85
|
-
rule: number;
|
|
86
|
-
kept?: boolean;
|
|
87
|
-
}[], jobLines: {
|
|
88
|
-
n: number;
|
|
89
|
-
rule?: string;
|
|
90
|
-
rules?: string[];
|
|
91
|
-
}[]): {
|
|
92
|
-
checks: {
|
|
93
|
-
line: number;
|
|
94
|
-
text: string;
|
|
95
|
-
check: Record<string, any>;
|
|
96
|
-
rules: number[];
|
|
97
|
-
kept: boolean;
|
|
98
|
-
}[];
|
|
99
|
-
notes: (Rule & {
|
|
100
|
-
reason: NoteReason;
|
|
101
|
-
also: number[];
|
|
102
|
-
kept: boolean;
|
|
103
|
-
})[];
|
|
104
|
-
};
|
|
105
|
-
/**
|
|
106
|
-
* RUBRIC jobs only (the caller gates on the job's lang): a part the drafter wrote as `none` or `judged` is a thing no rule can check, so it is
|
|
107
|
-
* listed under Not checked with its own words instead of failing the whole plan (hamr's ruling 2026-11-09, as fwd lists what the drafter cannot check).
|
|
108
|
-
* A part that is a verbatim copy of one of the person's `~` rules, or lists rule numbers, gives a `refused` entry per rule no other part carries (shown as that rule's own words); a part that is NOT a verbatim copy of a rule (the job sentence itself, the drafter's own wording) also becomes one line in `notes`, so its words are never lost. Never silent, never a line-level refusal (that would silence the line's other rule reds).
|
|
109
|
-
* Runs BEFORE applyPicks, so a rule the person's picks settle gets code's own reason there. `guard` and every other class are untouched.
|
|
110
|
-
* A stage left with no parts stays: an empty stage is the legal prose stage ("what the text says - you judge it at Accept"). Pure.
|
|
111
|
-
* @param {any} declaration @param {any[]|null|undefined} jobLines @param {boolean} rubric whether the job is a rubric job (the draft gate's `lang === RUBRIC_LANG`); anything else is returned untouched, its reds stand @returns {any}
|
|
112
|
-
*/
|
|
113
|
-
export function moveUncheckable(declaration: any, jobLines: any[] | null | undefined, rubric: boolean): any;
|
|
114
67
|
/** a part of a rubric-step stage, from a pick: the check's own fields, the rule's words, and the `~` rule numbers it carries out @param {Record<string, any>} check @param {string} text @param {number[]} rules */
|
|
115
68
|
export function partOfPick(check: Record<string, any>, text: string, rules: number[]): {
|
|
116
69
|
rules: number[];
|
|
@@ -118,63 +71,6 @@ export function partOfPick(check: Record<string, any>, text: string, rules: numb
|
|
|
118
71
|
class: string;
|
|
119
72
|
check: any;
|
|
120
73
|
};
|
|
121
|
-
/**
|
|
122
|
-
* Put the person's picks into the drafted declaration (a pure function; the input is untouched): on every rubric-step stage of a line this call settles, the drafter's own
|
|
123
|
-
* word/section/line/list/phrase checks are gone (the drafter writes none, whatever it sent), a part per picked check is added carrying the `~` rule numbers it settles, and every
|
|
124
|
-
* other settled rule goes under Not checked (`refused` with a rule number and the reason). A rule a fact or guard part of the draft already carries is left to that part.
|
|
125
|
-
* With no picks settled (`null`) it only drops a `picks` record the drafter sent.
|
|
126
|
-
* @param {any} declaration @param {ReturnType<typeof settleRules>|null} settled @returns {any}
|
|
127
|
-
*/
|
|
128
|
-
export function applyPicks(declaration: any, settled: ReturnType<typeof settleRules> | null): any;
|
|
129
|
-
/**
|
|
130
|
-
* RUBRIC jobs only (the caller gates on the job's lang; anything else is returned untouched, its reds stand). Two small, mechanical steps on every rubric-step stage, run
|
|
131
|
-
* before validation (hamr's ruling 2026-11-09):
|
|
132
|
-
* F1 source fill: when the job has EXACTLY ONE input label, a `fact` part, or a `cited` part, whose `source` is missing or empty gets that label. With 2+ labels nothing is filled; a
|
|
133
|
-
* wrong non-empty source is never rewritten (its red stands).
|
|
134
|
-
* F2 fact merge: when ONE stage holds 2+ `fact` parts they become ONE fact part (where the first stood): the `facts` of all in order, the union of `rules` and of `covers`, the one shared
|
|
135
|
-
* `source`, the `text`s joined with "; ". Only when it is safe, else the parts stay and the existing second-fact-list red fires: the sources differ (after F1), two facts share a name
|
|
136
|
-
* (compared white-space and case blind), the parts' `count`s differ (a part with no count agrees with any; the merged part carries the one count), a part is not a plain object or has a
|
|
137
|
-
* field a fact part does not carry, or `facts` is not a list.
|
|
138
|
-
* Runs AFTER applyPicks (its strip of a count that restates a pick has already happened). Pure.
|
|
139
|
-
* @param {any} declaration @param {string[]|null|undefined} inputLabels the labels of the job's inputs @param {boolean} rubric the draft gate's `lang === RUBRIC_LANG` @returns {any}
|
|
140
|
-
*/
|
|
141
|
-
export function fillAndMergeFacts(declaration: any, inputLabels: string[] | null | undefined, rubric: boolean): any;
|
|
142
|
-
/**
|
|
143
|
-
* RETENTION record of one rubric draft (PRD v1.131 tick 7; record only). Per job line: `aiParts` = what the drafter wrote on it that is the AI's own check or extra (a fact counts once per
|
|
144
|
-
* fact it lists, a `cited` part, a part code later moves as `none` / `judged`; guards and the drafter's own count checks are not counted, the picks strip those), `kept` = how many of
|
|
145
|
-
* those are still in the final declaration, `dropped` = what code removed (the move to Not checked, the drop after the last try), `picks` = the line has code-matched count picks. A merge
|
|
146
|
-
* of fact parts keeps every fact, so it drops nothing. Pure; no words, only counts.
|
|
147
|
-
* @param {any} drafted the declaration as the drafter sent it @param {any} final the declaration the draft ended with @param {any[]|null|undefined} jobLines
|
|
148
|
-
* @returns {{line: number, aiParts: number, kept: number, dropped: number, picks: boolean}[]}
|
|
149
|
-
*/
|
|
150
|
-
export function retentionOf(drafted: any, final: any, jobLines: any[] | null | undefined): {
|
|
151
|
-
line: number;
|
|
152
|
-
aiParts: number;
|
|
153
|
-
kept: number;
|
|
154
|
-
dropped: number;
|
|
155
|
-
picks: boolean;
|
|
156
|
-
}[];
|
|
157
|
-
/**
|
|
158
|
-
* RUBRIC jobs only, run ONLY after the LAST try failed the gate (PRD v1.131 tick 4, hamr's ruling 2026-11-09). When EVERY red points at one part of a rubric-step stage and that part is not
|
|
159
|
-
* a code-matched pick (a part in `declaration.picks`) nor code-owned (a guard, `numbersFromFacts`), the AI's parts those reds name are dropped and listed under Not checked: a pure extra as a
|
|
160
|
-
* note with its words, a part that served a `~` rule as a `refused` entry for each rule no surviving part carries (rule numbers outside the line's rules are ignored, as moveUncheckable does).
|
|
161
|
-
* Any red on a pick / code-owned part, or any red not tied to one part, returns `{refused}` and the plan is refused as today. Pure.
|
|
162
|
-
* @param {any} declaration the declaration as the gate validated it @param {{path?: string, code?: string}[]} reds @param {any[]|null|undefined} jobLines
|
|
163
|
-
* @returns {{declaration: any, dropped: {line: number, words: string, rules: number[]}[]}|{refused: string}}
|
|
164
|
-
*/
|
|
165
|
-
export function dropExtras(declaration: any, reds: {
|
|
166
|
-
path?: string;
|
|
167
|
-
code?: string;
|
|
168
|
-
}[], jobLines: any[] | null | undefined): {
|
|
169
|
-
declaration: any;
|
|
170
|
-
dropped: {
|
|
171
|
-
line: number;
|
|
172
|
-
words: string;
|
|
173
|
-
rules: number[];
|
|
174
|
-
}[];
|
|
175
|
-
} | {
|
|
176
|
-
refused: string;
|
|
177
|
-
};
|
|
178
74
|
/** the one tool the suggestion call uses */
|
|
179
75
|
export const SUGGEST_TOOL: "suggest_checks";
|
|
180
76
|
export function isCountable(g: unknown): boolean;
|
|
@@ -185,6 +81,7 @@ export function hasRoutingInput(inputs: {
|
|
|
185
81
|
export function codeScope(inputs: {
|
|
186
82
|
value?: string;
|
|
187
83
|
}[] | null | undefined, g: string): "in" | "out";
|
|
84
|
+
export function sameRuleWords(a: unknown, b: unknown): boolean;
|
|
188
85
|
export const SUGGEST_SYSTEM: string;
|
|
189
86
|
/** the tool's parameter schema: one `anyOf` variant per offered rule, plus `none` */
|
|
190
87
|
export const SUGGEST_SCHEMA: Readonly<{
|
|
@@ -252,46 +149,12 @@ export function suggestChannel(): {
|
|
|
252
149
|
};
|
|
253
150
|
/** the can't-check ask, as the signed words say it */
|
|
254
151
|
export const CANT_CHECK_WORDS: "I can't check this. Your own words, or Not checked?";
|
|
255
|
-
|
|
256
|
-
* @typedef {{line: number, rule: number, check: Record<string, any>|null, added?: string, own?: boolean, kept?: boolean}} Pick
|
|
257
|
-
* `check` = the check the person agreed to (null for their own words); `added` = the `~` rule the answer wrote on the line; `own` = their own words
|
|
258
|
-
* @typedef {'person-left'|'own-words'|'no-pick'} NoteReason
|
|
259
|
-
*/
|
|
260
|
-
/** the one table of Not checked reasons, in the person's words (fwd src/pagedropwords.js, adapted) @type {Record<NoteReason, string>} */
|
|
261
|
-
export const NOTE_WORDS: Record<NoteReason, string>;
|
|
262
|
-
/** the reason a part the drafter could not express as a check is listed under Not checked (fwd's am16: the drafter writes no check of its own, what no rule can check is the person's to judge) */
|
|
263
|
-
export const UNCHECKABLE_WORDS: "No rule can check this, so you judge it at Accept.";
|
|
264
|
-
/** the reason a dropped AI extra is listed under Not checked */
|
|
265
|
-
export const DROPPED_WORDS: "The AI couldn't build a working check for this, so you judge it at Accept.";
|
|
152
|
+
export function HOW_TO_ANSWER(line: number, agree: boolean): string;
|
|
266
153
|
export type Rule = {
|
|
267
154
|
line: number;
|
|
268
155
|
rule: number;
|
|
269
156
|
text: string;
|
|
270
157
|
};
|
|
271
|
-
export type PickAsk = {
|
|
272
|
-
line: number;
|
|
273
|
-
rule: number;
|
|
274
|
-
source: "look";
|
|
275
|
-
ask: "check" | "no-check";
|
|
276
|
-
ruleText: string;
|
|
277
|
-
question: string;
|
|
278
|
-
reading?: string;
|
|
279
|
-
check?: Record<string, any>;
|
|
280
|
-
counted: boolean;
|
|
281
|
-
pairRule?: number;
|
|
282
|
-
};
|
|
283
|
-
/**
|
|
284
|
-
* `check` = the check the person agreed to (null for their own words); `added` = the `~` rule the answer wrote on the line; `own` = their own words
|
|
285
|
-
*/
|
|
286
|
-
export type Pick = {
|
|
287
|
-
line: number;
|
|
288
|
-
rule: number;
|
|
289
|
-
check: Record<string, any> | null;
|
|
290
|
-
added?: string;
|
|
291
|
-
own?: boolean;
|
|
292
|
-
kept?: boolean;
|
|
293
|
-
};
|
|
294
|
-
export type NoteReason = "person-left" | "own-words" | "no-pick";
|
|
295
158
|
import { plainWords } from './checkwords.js';
|
|
296
159
|
import { OFFERED } from './checkwords.js';
|
|
297
160
|
export { plainWords, OFFERED };
|