fwdloop 0.23.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/fwdloop +31 -8
- package/package.json +1 -1
- package/src/ask.js +15 -1
- package/src/attemptdiff.js +118 -0
- package/src/audit-fold.js +2 -0
- package/src/authoring.js +32 -2
- package/src/citedwords.js +36 -2
- package/src/config.js +5 -1
- package/src/drafter.js +6 -2
- package/src/flowmodel.js +56 -1
- package/src/learn.js +952 -0
- package/src/learnstore.js +346 -0
- package/src/model-step.js +2 -0
- package/src/pagedry.js +3 -4
- package/src/pagefetch.js +9 -2
- package/src/pagerules.js +28 -5
- package/src/panel/data.js +61 -13
- package/src/panel/index.html +143 -11
- package/src/redact.js +6 -6
- package/src/runner.js +127 -17
- package/src/thinking.js +11 -0
- package/types/ask.d.ts +7 -2
- package/types/attemptdiff.d.ts +38 -0
- package/types/citedwords.d.ts +14 -0
- package/types/drafter.d.ts +6 -1
- package/types/flowmodel.d.ts +36 -0
- package/types/learn.d.ts +576 -0
- package/types/learnstore.d.ts +168 -0
- package/types/pagerules.d.ts +7 -0
- package/types/panel/data.d.ts +2 -1
- package/types/panel/result.d.ts +1 -1
- package/types/runner.d.ts +11 -2
- package/types/thinking.d.ts +11 -0
package/types/learn.d.ts
ADDED
|
@@ -0,0 +1,576 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mask secrets and strip the working-tree prefix from a text. Pure.
|
|
3
|
+
* @param {string} text @param {string|null} workdir
|
|
4
|
+
* @returns {string}
|
|
5
|
+
*/
|
|
6
|
+
export function cleanText(text: string, workdir: string | null): string;
|
|
7
|
+
/**
|
|
8
|
+
* A card/audit path made relative to the run's tree, or null when it is not inside it. The workdir is the
|
|
9
|
+
* authority; the patient-prefix shapes are the fallback for a spine read without one.
|
|
10
|
+
* @param {string} abs @param {string|null} workdir
|
|
11
|
+
* @returns {string|null}
|
|
12
|
+
*/
|
|
13
|
+
export function relPath(abs: string, workdir: string | null): string | null;
|
|
14
|
+
/**
|
|
15
|
+
* Cut at a word / sentence edge, never mid-word where avoidable. Whitespace collapsed.
|
|
16
|
+
* @param {unknown} text @param {number} n @returns {string}
|
|
17
|
+
*/
|
|
18
|
+
export function cutText(text: unknown, n: number): string;
|
|
19
|
+
/**
|
|
20
|
+
* Deep-redact every string of a plain JSON value through the ONE secret inventory (a secret in a person's repo must
|
|
21
|
+
* not enter an append-only record). Pure; returns a new value.
|
|
22
|
+
* @template T @param {T} v @returns {T}
|
|
23
|
+
*/
|
|
24
|
+
export function redactDeep<T>(v: T): T;
|
|
25
|
+
/**
|
|
26
|
+
* The flagged text of ONE quote line (wrapper stripped), or null when the line is not a flagged line.
|
|
27
|
+
* Flagged lines: `... added <id> - <text>` and `close: [<id>] <file>:<line>: <text>` (id in the allowed list), and
|
|
28
|
+
* lines with `error TS<digits>:` or `error:`.
|
|
29
|
+
* @param {string} line @returns {string|null}
|
|
30
|
+
*/
|
|
31
|
+
export function flaggedText(line: string): string | null;
|
|
32
|
+
/**
|
|
33
|
+
* The error-kind set of a quote: TS codes; `[id]` of `added <id>` and `close: [id]` lines; a mypy trailing bracket
|
|
34
|
+
* code; empty -> `other`. Also the files named, the first symbol, and whether the card is CHECK-SUSPECT.
|
|
35
|
+
* @param {string} text the (path-stripped) quote @param {string} [fullGap] the whole gap, for the suspect read
|
|
36
|
+
* @returns {{kinds: string[], files: string[], symbol: string|null, suspect: boolean}}
|
|
37
|
+
*/
|
|
38
|
+
export function errorKinds(text: string, fullGap?: string): {
|
|
39
|
+
kinds: string[];
|
|
40
|
+
files: string[];
|
|
41
|
+
symbol: string | null;
|
|
42
|
+
suspect: boolean;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* The token set of a quote's flagged lines: lowercase runs of `[a-z0-9_]` of length >= 2, union over flagged lines.
|
|
46
|
+
* File paths, line numbers, `added <id> -`, `error TS<n>:` and the trailing mypy code are already stripped.
|
|
47
|
+
* @param {string} text @returns {string[]} sorted
|
|
48
|
+
*/
|
|
49
|
+
export function flaggedTokens(text: string): string[];
|
|
50
|
+
/**
|
|
51
|
+
* @typedef {object} Card
|
|
52
|
+
* @property {string} id `<runid>:<check>:<fixed|stuck>`
|
|
53
|
+
* @property {string} runid
|
|
54
|
+
* @property {string} at the run's end (ISO)
|
|
55
|
+
* @property {string} date YYYY-MM-DD of `at`
|
|
56
|
+
* @property {string} job the workflow key
|
|
57
|
+
* @property {string|null} model
|
|
58
|
+
* @property {string} check the check / close stage name
|
|
59
|
+
* @property {'FIXED'|'NEVER_FIXED'} kind
|
|
60
|
+
* @property {string} goal Job (as written), cut
|
|
61
|
+
* @property {string|null} stepId
|
|
62
|
+
* @property {string|null} stepAction Step (as planned), cut
|
|
63
|
+
* @property {string|null} meaning the check's own catalogue sentence (code-owned)
|
|
64
|
+
* @property {string[]} said It said: <= 3 lines, paths and prefixes stripped
|
|
65
|
+
* @property {number} saidMore lines left out
|
|
66
|
+
* @property {string[]} kinds error kinds, sorted; ['other'] when none
|
|
67
|
+
* @property {string[]} files files the quote names, sorted
|
|
68
|
+
* @property {string|null} symbol
|
|
69
|
+
* @property {string[]} tokens the flagged-text token set, sorted
|
|
70
|
+
* @property {string|null} nextCheck the next failing check after this moment, if any
|
|
71
|
+
* @property {string} ended how the run ended (job-end outcome, or its escalation word)
|
|
72
|
+
* @property {string[]} fixTouched files written by the passing try (the try that followed the red, for NEVER FIXED)
|
|
73
|
+
* @property {{files: {path: string, diff: string, truncated: boolean, cutLines?: number}[], binary: string[], truncated: boolean}|null} whatChanged
|
|
74
|
+
* the passing try's attempt-diff (FIXED only), as the spine capped it
|
|
75
|
+
* @property {string} key the one-line machine key
|
|
76
|
+
*/
|
|
77
|
+
/**
|
|
78
|
+
* The one-line machine key of a card. Line numbers never appear in it.
|
|
79
|
+
* @param {{id: string, job: string, check: string, kinds: string[], files: string[], model: string|null, runid: string, date: string}} c
|
|
80
|
+
* @returns {string}
|
|
81
|
+
*/
|
|
82
|
+
export function cardKey(c: {
|
|
83
|
+
id: string;
|
|
84
|
+
job: string;
|
|
85
|
+
check: string;
|
|
86
|
+
kinds: string[];
|
|
87
|
+
files: string[];
|
|
88
|
+
model: string | null;
|
|
89
|
+
runid: string;
|
|
90
|
+
date: string;
|
|
91
|
+
}): string;
|
|
92
|
+
/**
|
|
93
|
+
* The lines of a gap a card quotes: lines that carry a path:line or an error code come first, accumulated up to
|
|
94
|
+
* ~250 characters (the cut the fold was fitted on). Pure.
|
|
95
|
+
* @param {string} gap @returns {string[]}
|
|
96
|
+
*/
|
|
97
|
+
export function quoteLines(gap: string): string[];
|
|
98
|
+
/**
|
|
99
|
+
* @typedef {object} CardBuild
|
|
100
|
+
* @property {Card[]} cards foldable cards (FIXED and NEVER FIXED), suspect and too-thin removed
|
|
101
|
+
* @property {Card[]} suspect CHECK-SUSPECT cards: listed, never folded
|
|
102
|
+
* @property {number} thin TOO-THIN count of FIXED cards only (M8 am3): no error kind and no fix files; a NEVER FIXED card is never thin
|
|
103
|
+
* @property {string|null} noise why the whole run was set aside (provider-red, close-crashed, worker-crash, no-close-spoke, no-job-end), else null
|
|
104
|
+
*/
|
|
105
|
+
/**
|
|
106
|
+
* Turn one run's record into cards. Every field is COPIED from the spine / gate audit; nothing is generated.
|
|
107
|
+
*
|
|
108
|
+
* Candidates: FIXED = a check red, then the SAME check passes later in the same run; NEVER FIXED = a check still red
|
|
109
|
+
* at run end. At most one of each per check per run (the last red before the pass; the last red). Excluded, counted:
|
|
110
|
+
* noise runs, CHECK-SUSPECT, TOO-THIN.
|
|
111
|
+
*
|
|
112
|
+
* Written files come from `attempt-diff` events (rubric `output/steps/<n>.json` included: the diff force-adds the
|
|
113
|
+
* fence) and the REAL gate audit's allow write/edit rows relative to `workdir` — never `git status`, and never a
|
|
114
|
+
* reader that drops a path it cannot place under a known patient prefix (the POC defect: a rubric job's writes read
|
|
115
|
+
* as none).
|
|
116
|
+
* `questions` is the check catalogue (stage name -> plain question, src/stagewords.js) the caller resolved from the signed
|
|
117
|
+
* spec; a check with none reads `(not in the record)`.
|
|
118
|
+
* @param {{runid: string, events: any[], audit?: any[]|null, workdir?: string|null, spec?: any, model?: string|null, questions?: Map<string, string|null>}} o
|
|
119
|
+
* @returns {CardBuild}
|
|
120
|
+
*/
|
|
121
|
+
export function buildCards({ runid, events, audit, workdir, spec, model, questions }: {
|
|
122
|
+
runid: string;
|
|
123
|
+
events: any[];
|
|
124
|
+
audit?: any[] | null;
|
|
125
|
+
workdir?: string | null;
|
|
126
|
+
spec?: any;
|
|
127
|
+
model?: string | null;
|
|
128
|
+
questions?: Map<string, string | null>;
|
|
129
|
+
}): CardBuild;
|
|
130
|
+
/** @param {{kinds: string[]}} a @param {{kinds: string[]}} b */
|
|
131
|
+
export function sharedKind(a: {
|
|
132
|
+
kinds: string[];
|
|
133
|
+
}, b: {
|
|
134
|
+
kinds: string[];
|
|
135
|
+
}): boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Do two cards agree on kind? A shared error code / kind, OR (RULED 2026-10-23 R1) both carry NO code (`other`) and both
|
|
138
|
+
* have a non-empty flagged-text token set, so the text rule alone decides. A coded card never matches a code-less one.
|
|
139
|
+
* The 60% was fitted on cards WITH codes; the code-less use is UNTESTED on real data.
|
|
140
|
+
* @param {{kinds: string[], tokens: string[]}} a @param {{kinds: string[], tokens: string[]}} b
|
|
141
|
+
*/
|
|
142
|
+
export function kindAgrees(a: {
|
|
143
|
+
kinds: string[];
|
|
144
|
+
tokens: string[];
|
|
145
|
+
}, b: {
|
|
146
|
+
kinds: string[];
|
|
147
|
+
tokens: string[];
|
|
148
|
+
}): boolean;
|
|
149
|
+
/** Jaccard of two token arrays; an empty side scores 0. @param {string[]} a @param {string[]} b */
|
|
150
|
+
export function jaccard(a: string[], b: string[]): number;
|
|
151
|
+
/**
|
|
152
|
+
* Are two cards one lesson? Same check, kinds that agree ({@link kindAgrees}: a shared code, or both code-less with text
|
|
153
|
+
* on both sides) and Jaccard >= 60% on flagged-text tokens. `sameJob: false` drops the job test (RULING 1: the cross-job rule for climbing).
|
|
154
|
+
* @param {Card} a @param {Card} b @param {{sameJob?: boolean}} [o]
|
|
155
|
+
* @returns {{match: boolean, score: number}}
|
|
156
|
+
*/
|
|
157
|
+
export function cardsMatch(a: Card, b: Card, { sameJob }?: {
|
|
158
|
+
sameJob?: boolean;
|
|
159
|
+
}): {
|
|
160
|
+
match: boolean;
|
|
161
|
+
score: number;
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* Group cards into lessons: single-link components over eligible pairs; every pair INSIDE a component is re-checked
|
|
165
|
+
* for a shared kind, and a component with any pair lacking one splits back to singletons.
|
|
166
|
+
* @param {Card[]} cards
|
|
167
|
+
* @returns {Card[][]} groups, in first-card order; each group in input order
|
|
168
|
+
*/
|
|
169
|
+
export function foldCards(cards: Card[]): Card[][];
|
|
170
|
+
/**
|
|
171
|
+
* @typedef {object} Row
|
|
172
|
+
* @property {string} id
|
|
173
|
+
* @property {string} lesson ONE sentence, template-only (see {@link lessonOf})
|
|
174
|
+
* @property {number} count runs seen; STARTS AT 1
|
|
175
|
+
* @property {Card} sample the LATEST card
|
|
176
|
+
* @property {Record<string, number>} models per-model counts (read-only information; never a filter)
|
|
177
|
+
* @property {string} workflow
|
|
178
|
+
* @property {string|null} place
|
|
179
|
+
* @property {'workflow'|'place'|'user'} level STORED as 'workflow' only; the level a reader sees is derived by {@link readableRows} from the rows memory still shows (an older file's stored value is ignored and reset on the next write)
|
|
180
|
+
* @property {'deterministic'|'rubric'} trust
|
|
181
|
+
* @property {string[]} runIds
|
|
182
|
+
* @property {string} firstSeen
|
|
183
|
+
* @property {string} lastSeen
|
|
184
|
+
* @property {string|null} specHash the signed hash the lesson was last seen under (a workflow row of another hash is never matched or read)
|
|
185
|
+
* @property {string} key check + sorted kinds (job-independent); information only since R2 removed the check-wide set-aside
|
|
186
|
+
*/
|
|
187
|
+
/**
|
|
188
|
+
* @typedef {object} Pending
|
|
189
|
+
* @property {string} runid @property {string} at @property {string} workflow @property {string|null} place
|
|
190
|
+
* @property {string|null} specHash @property {Card[]} cards
|
|
191
|
+
*/
|
|
192
|
+
/**
|
|
193
|
+
* @typedef {object} Ledger
|
|
194
|
+
* @property {1} version
|
|
195
|
+
* @property {Row[]} rows
|
|
196
|
+
* @property {Pending[]} pending holds written by v0.46.x for rubric runs, released by the human Accept (NOT counted, NOT readable); new runs never write one
|
|
197
|
+
* @property {Card[]} suspect CHECK-SUSPECT cards, listed, newest last
|
|
198
|
+
* @property {Record<string, {at: string, noise: string|null, cards: number, suspect: number, thin: number}>} health per run (idempotent by run id)
|
|
199
|
+
*/
|
|
200
|
+
/** @returns {Ledger} */
|
|
201
|
+
export function emptyLedger(): Ledger;
|
|
202
|
+
/**
|
|
203
|
+
* ONE sentence, rendered by code from the card's own fields (RULING 5, template-only).
|
|
204
|
+
* @param {Card} c @returns {string}
|
|
205
|
+
*/
|
|
206
|
+
export function lessonOf(c: Card): string;
|
|
207
|
+
/**
|
|
208
|
+
* Fold ONE run's cards into the ledger. Pure: returns a new ledger.
|
|
209
|
+
*
|
|
210
|
+
* +1 per RUN per row: the run's own cards are folded into lessons first, and a row whose `runIds` already holds the
|
|
211
|
+
* run id is never counted twice (a resumed run, one id, never double counts) but IS refreshed: the resumed leg's card
|
|
212
|
+
* replaces the sample, lesson, key, lastSeen, hash and place (a leg-1 NEVER FIXED row becomes the leg-2 FIXED one). A
|
|
213
|
+
* matching lesson replaces the row's sample, bumps the model count and appends the run id (a row last seen 56+ days ago counts +1 and is read again);
|
|
214
|
+
* otherwise it opens a new row at count 1. NEVER FIXED cards count like FIXED ones (RULING 3). A workflow row of
|
|
215
|
+
* another signed hash is never matched here: the new version opens its own rows. Nothing is ever deleted or stamped.
|
|
216
|
+
* @param {Ledger} ledger
|
|
217
|
+
* @param {{runid: string, cards: Card[], workflow: string, place: string|null, specHash: string|null, trust: 'deterministic'|'rubric', now: Date}} o
|
|
218
|
+
* @returns {Ledger}
|
|
219
|
+
*/
|
|
220
|
+
export function countLedger(ledger: Ledger, { runid, cards, workflow, place, specHash, trust, now }: {
|
|
221
|
+
runid: string;
|
|
222
|
+
cards: Card[];
|
|
223
|
+
workflow: string;
|
|
224
|
+
place: string | null;
|
|
225
|
+
specHash: string | null;
|
|
226
|
+
trust: "deterministic" | "rubric";
|
|
227
|
+
now: Date;
|
|
228
|
+
}): Ledger;
|
|
229
|
+
/**
|
|
230
|
+
* Climbing (RULING 1): the same lesson across workflows — the section-3 rule with "same job" dropped — seen in 3
|
|
231
|
+
* distinct workflows on one place climbs to `place`; in 3 distinct places, to `user`. Derived from the rows handed in
|
|
232
|
+
* alone (every row starts at `workflow`, a stored level is ignored): {@link readableRows} hands it only the rows memory
|
|
233
|
+
* still shows, so a level drops back when siblings age out. Returns copies; keeps every run id.
|
|
234
|
+
* @param {Row[]} rows @returns {Row[]}
|
|
235
|
+
*/
|
|
236
|
+
export function climb(rows: Row[]): Row[];
|
|
237
|
+
/**
|
|
238
|
+
* Hold a run's cards until a human Accept. NO LONGER CALLED for new runs (v1.112: a rubric run's lessons count at run
|
|
239
|
+
* end); kept so a hold already in a ledger file still has a writer for tests and a reader in {@link releasePending}. Pure.
|
|
240
|
+
* @param {Ledger} ledger
|
|
241
|
+
* @param {{runid: string, cards: Card[], workflow: string, place: string|null, specHash: string|null, at: string}} o
|
|
242
|
+
* @param {Date} now @returns {Ledger}
|
|
243
|
+
*/
|
|
244
|
+
export function holdPending(ledger: Ledger, { runid, cards, workflow, place, specHash, at }: {
|
|
245
|
+
runid: string;
|
|
246
|
+
cards: Card[];
|
|
247
|
+
workflow: string;
|
|
248
|
+
place: string | null;
|
|
249
|
+
specHash: string | null;
|
|
250
|
+
at: string;
|
|
251
|
+
}, now: Date): Ledger;
|
|
252
|
+
/**
|
|
253
|
+
* The human Accept releases an OLD hold (written by v0.46.x; new runs write none): its cards count now (trust `rubric`). Only forward, only here. A hold
|
|
254
|
+
* older than 60 days is dropped uncounted. Idempotent (no hold = nothing to do; run ids stop a double count).
|
|
255
|
+
* @param {Ledger} ledger @param {string} runid @param {Date} now
|
|
256
|
+
* @returns {{ledger: Ledger, released: number}}
|
|
257
|
+
*/
|
|
258
|
+
export function releasePending(ledger: Ledger, runid: string, now: Date): {
|
|
259
|
+
ledger: Ledger;
|
|
260
|
+
released: number;
|
|
261
|
+
};
|
|
262
|
+
/**
|
|
263
|
+
* Record the run's health line and CHECK-SUSPECT list (idempotent by run id). Pure.
|
|
264
|
+
* @param {Ledger} ledger @param {string} runid @param {CardBuild} build @param {string} at @param {Date} now
|
|
265
|
+
* @returns {Ledger}
|
|
266
|
+
*/
|
|
267
|
+
export function recordHealth(ledger: Ledger, runid: string, build: CardBuild, at: string, now: Date): Ledger;
|
|
268
|
+
/**
|
|
269
|
+
* The +/- content lines of a card's stored attempt-diff, in file order: only lines INSIDE a hunk that start with `+` or
|
|
270
|
+
* `-` (so `diff --git`, `index`, `---`/`+++` headers, `@@` lines, context and `\ No newline` lines never appear; a removed
|
|
271
|
+
* line that itself starts with `--` is still content once a hunk has opened). Leading indent after the sign is dropped.
|
|
272
|
+
* @param {Card['whatChanged']} wc @returns {string[]}
|
|
273
|
+
*/
|
|
274
|
+
export function changedLines(wc: Card["whatChanged"]): string[];
|
|
275
|
+
/**
|
|
276
|
+
* The line "It said:" shows (R5): the first REAL flagged source/error line of the stored quote (the same lines the fold's
|
|
277
|
+
* flagged-text rule reads, with or without the `close:` wrapper the card already stripped), else the first line when no
|
|
278
|
+
* line is flagged (a summary such as `SPAWNER red: 3 suppression(s) added ...` is only the fallback).
|
|
279
|
+
* @param {string[]} said @returns {string|undefined}
|
|
280
|
+
*/
|
|
281
|
+
export function saidLine(said: string[]): string | undefined;
|
|
282
|
+
/**
|
|
283
|
+
* Which rows may be read for this job, in reading order (THE memory filter; the ledger itself keeps every row).
|
|
284
|
+
* Excluded: pending rows, any row last seen more than 56 days ago, any row with no run id, a workflow row of another
|
|
285
|
+
* job or of another signed hash, a place row of another place. The level (this job / this place / all jobs) is
|
|
286
|
+
* derived HERE by {@link climb} over the rows not decayed at `now` only; the stored level is never read.
|
|
287
|
+
* Order: this job's, then this place's, then all-jobs LAST (R2: climbing wins, so an all-jobs hint only uses leftover
|
|
288
|
+
* room); inside each level highest count first (ties: most recent lastSeen, then id), so the order is total and stable.
|
|
289
|
+
* @param {Ledger} ledger @param {{workflow: string, place: string|null, specHash?: string|null, now: Date}} o
|
|
290
|
+
* @returns {Row[]}
|
|
291
|
+
*/
|
|
292
|
+
export function readableRows(ledger: Ledger, { workflow, place, specHash, now }: {
|
|
293
|
+
workflow: string;
|
|
294
|
+
place: string | null;
|
|
295
|
+
specHash?: string | null;
|
|
296
|
+
now: Date;
|
|
297
|
+
}): Row[];
|
|
298
|
+
/**
|
|
299
|
+
* THE one render: the block the PLANNER reads at draft and at the first replan. Byte-for-byte reproducible from the
|
|
300
|
+
* ledger as it stood. Stops at 2,000 characters; a hint is added whole or not at all; nothing readable -> empty text.
|
|
301
|
+
* @param {Ledger} ledger @param {{workflow: string, place: string|null, specHash?: string|null, now: Date}} o
|
|
302
|
+
* @returns {{text: string, ids: string[]}}
|
|
303
|
+
*/
|
|
304
|
+
export function renderHints(ledger: Ledger, o: {
|
|
305
|
+
workflow: string;
|
|
306
|
+
place: string | null;
|
|
307
|
+
specHash?: string | null;
|
|
308
|
+
now: Date;
|
|
309
|
+
}): {
|
|
310
|
+
text: string;
|
|
311
|
+
ids: string[];
|
|
312
|
+
};
|
|
313
|
+
/**
|
|
314
|
+
* Split a block {@link renderHints} wrote back into its hints. The ONLY reader of that text: it lives beside the
|
|
315
|
+
* writer ({@link hintText}, {@link lessonOf}) and a test renders real blocks and parses them back. A hint it cannot
|
|
316
|
+
* read is returned with what it could read (never thrown, never invented). Pure.
|
|
317
|
+
* @param {string} text @returns {HintParts[]}
|
|
318
|
+
*/
|
|
319
|
+
export function parseHintBlock(text: string): HintParts[];
|
|
320
|
+
/**
|
|
321
|
+
* Where a job lives, derived by code from the signed spec's inputs line 1: a website job = the URL host; a repo or
|
|
322
|
+
* plain folder/file job = that path (resolved by the caller). Null when the spec carries no inputs.
|
|
323
|
+
* @param {any} spec @param {(p: string) => string} [resolve] path resolver (the caller passes `realpath`)
|
|
324
|
+
* @returns {string|null}
|
|
325
|
+
*/
|
|
326
|
+
export function placeOf(spec: any, resolve?: (p: string) => string): string | null;
|
|
327
|
+
/** The block the planner reads is never longer than this many characters (RULING 7). */
|
|
328
|
+
export const HINT_CHARS_MAX: 2000;
|
|
329
|
+
/** MEMORY filter only (hamr 2026-10-23): a row untouched this long is not handed to the planner. The ledger keeps every row. */
|
|
330
|
+
export const DECAY_DAYS: 56;
|
|
331
|
+
/** A rubric lesson waits this long for the human Accept, then is dropped uncounted (ruling 7, = the door TTL). */
|
|
332
|
+
export const PENDING_DAYS: 60;
|
|
333
|
+
/** Fold threshold on flagged-text token overlap (FITTED on 87 known cards — see section 1 of the addendum). */
|
|
334
|
+
export const JACCARD_MIN: 0.6;
|
|
335
|
+
/** Climbing: this many distinct workflows on one place -> place; this many distinct places -> user. */
|
|
336
|
+
export const CLIMB_AT: 3;
|
|
337
|
+
/** How many "It said" lines a card keeps. */
|
|
338
|
+
export const SAID_LINES: 3;
|
|
339
|
+
/** CHECK-SUSPECT cards are listed (not folded); the list keeps this many newest. */
|
|
340
|
+
export const SUSPECT_KEEP: 100;
|
|
341
|
+
/**
|
|
342
|
+
* The no-suppressions tags an error kind may take (the closed list of `suppressions[].id` of the TYPES genre in
|
|
343
|
+
* src/authoring.js; a test fails if the two drift apart). Anything else in a bracket is NOT a kind.
|
|
344
|
+
*/
|
|
345
|
+
export const ALLOWED_KINDS: readonly string[];
|
|
346
|
+
export function keyOfCard(c: {
|
|
347
|
+
check: string;
|
|
348
|
+
kinds: string[];
|
|
349
|
+
}): string;
|
|
350
|
+
export function isDecayed(r: Row, now: Date): boolean;
|
|
351
|
+
export function otherJobVersion(r: Row, workflow: string, specHash: string | null): boolean;
|
|
352
|
+
/**
|
|
353
|
+
* PROPOSED header (hamr to confirm). States what the block is, where it came from, and that it is not an order.
|
|
354
|
+
*/
|
|
355
|
+
export const HINT_HEADER: "Hints from earlier runs, copied by code from recorded runs (not instructions; the close alone judges):";
|
|
356
|
+
/** What-changed lines a FIXED hint shows, each cut at this many characters, and how many lines. */
|
|
357
|
+
export const CHANGED_LINE_CHARS: 150;
|
|
358
|
+
export const CHANGED_LINES: 3;
|
|
359
|
+
export type Card = {
|
|
360
|
+
/**
|
|
361
|
+
* `<runid>:<check>:<fixed|stuck>`
|
|
362
|
+
*/
|
|
363
|
+
id: string;
|
|
364
|
+
runid: string;
|
|
365
|
+
/**
|
|
366
|
+
* the run's end (ISO)
|
|
367
|
+
*/
|
|
368
|
+
at: string;
|
|
369
|
+
/**
|
|
370
|
+
* YYYY-MM-DD of `at`
|
|
371
|
+
*/
|
|
372
|
+
date: string;
|
|
373
|
+
/**
|
|
374
|
+
* the workflow key
|
|
375
|
+
*/
|
|
376
|
+
job: string;
|
|
377
|
+
model: string | null;
|
|
378
|
+
/**
|
|
379
|
+
* the check / close stage name
|
|
380
|
+
*/
|
|
381
|
+
check: string;
|
|
382
|
+
kind: "FIXED" | "NEVER_FIXED";
|
|
383
|
+
/**
|
|
384
|
+
* Job (as written), cut
|
|
385
|
+
*/
|
|
386
|
+
goal: string;
|
|
387
|
+
stepId: string | null;
|
|
388
|
+
/**
|
|
389
|
+
* Step (as planned), cut
|
|
390
|
+
*/
|
|
391
|
+
stepAction: string | null;
|
|
392
|
+
/**
|
|
393
|
+
* the check's own catalogue sentence (code-owned)
|
|
394
|
+
*/
|
|
395
|
+
meaning: string | null;
|
|
396
|
+
/**
|
|
397
|
+
* It said: <= 3 lines, paths and prefixes stripped
|
|
398
|
+
*/
|
|
399
|
+
said: string[];
|
|
400
|
+
/**
|
|
401
|
+
* lines left out
|
|
402
|
+
*/
|
|
403
|
+
saidMore: number;
|
|
404
|
+
/**
|
|
405
|
+
* error kinds, sorted; ['other'] when none
|
|
406
|
+
*/
|
|
407
|
+
kinds: string[];
|
|
408
|
+
/**
|
|
409
|
+
* files the quote names, sorted
|
|
410
|
+
*/
|
|
411
|
+
files: string[];
|
|
412
|
+
symbol: string | null;
|
|
413
|
+
/**
|
|
414
|
+
* the flagged-text token set, sorted
|
|
415
|
+
*/
|
|
416
|
+
tokens: string[];
|
|
417
|
+
/**
|
|
418
|
+
* the next failing check after this moment, if any
|
|
419
|
+
*/
|
|
420
|
+
nextCheck: string | null;
|
|
421
|
+
/**
|
|
422
|
+
* how the run ended (job-end outcome, or its escalation word)
|
|
423
|
+
*/
|
|
424
|
+
ended: string;
|
|
425
|
+
/**
|
|
426
|
+
* files written by the passing try (the try that followed the red, for NEVER FIXED)
|
|
427
|
+
*/
|
|
428
|
+
fixTouched: string[];
|
|
429
|
+
/**
|
|
430
|
+
* the passing try's attempt-diff (FIXED only), as the spine capped it
|
|
431
|
+
*/
|
|
432
|
+
whatChanged: {
|
|
433
|
+
files: {
|
|
434
|
+
path: string;
|
|
435
|
+
diff: string;
|
|
436
|
+
truncated: boolean;
|
|
437
|
+
cutLines?: number;
|
|
438
|
+
}[];
|
|
439
|
+
binary: string[];
|
|
440
|
+
truncated: boolean;
|
|
441
|
+
} | null;
|
|
442
|
+
/**
|
|
443
|
+
* the one-line machine key
|
|
444
|
+
*/
|
|
445
|
+
key: string;
|
|
446
|
+
};
|
|
447
|
+
export type CardBuild = {
|
|
448
|
+
/**
|
|
449
|
+
* foldable cards (FIXED and NEVER FIXED), suspect and too-thin removed
|
|
450
|
+
*/
|
|
451
|
+
cards: Card[];
|
|
452
|
+
/**
|
|
453
|
+
* CHECK-SUSPECT cards: listed, never folded
|
|
454
|
+
*/
|
|
455
|
+
suspect: Card[];
|
|
456
|
+
/**
|
|
457
|
+
* TOO-THIN count of FIXED cards only (M8 am3): no error kind and no fix files; a NEVER FIXED card is never thin
|
|
458
|
+
*/
|
|
459
|
+
thin: number;
|
|
460
|
+
/**
|
|
461
|
+
* why the whole run was set aside (provider-red, close-crashed, worker-crash, no-close-spoke, no-job-end), else null
|
|
462
|
+
*/
|
|
463
|
+
noise: string | null;
|
|
464
|
+
};
|
|
465
|
+
export type Row = {
|
|
466
|
+
id: string;
|
|
467
|
+
/**
|
|
468
|
+
* ONE sentence, template-only (see {@link lessonOf})
|
|
469
|
+
*/
|
|
470
|
+
lesson: string;
|
|
471
|
+
/**
|
|
472
|
+
* runs seen; STARTS AT 1
|
|
473
|
+
*/
|
|
474
|
+
count: number;
|
|
475
|
+
/**
|
|
476
|
+
* the LATEST card
|
|
477
|
+
*/
|
|
478
|
+
sample: Card;
|
|
479
|
+
/**
|
|
480
|
+
* per-model counts (read-only information; never a filter)
|
|
481
|
+
*/
|
|
482
|
+
models: Record<string, number>;
|
|
483
|
+
workflow: string;
|
|
484
|
+
place: string | null;
|
|
485
|
+
/**
|
|
486
|
+
* STORED as 'workflow' only; the level a reader sees is derived by {@link readableRows} from the rows memory still shows (an older file's stored value is ignored and reset on the next write)
|
|
487
|
+
*/
|
|
488
|
+
level: "workflow" | "place" | "user";
|
|
489
|
+
trust: "deterministic" | "rubric";
|
|
490
|
+
runIds: string[];
|
|
491
|
+
firstSeen: string;
|
|
492
|
+
lastSeen: string;
|
|
493
|
+
/**
|
|
494
|
+
* the signed hash the lesson was last seen under (a workflow row of another hash is never matched or read)
|
|
495
|
+
*/
|
|
496
|
+
specHash: string | null;
|
|
497
|
+
/**
|
|
498
|
+
* check + sorted kinds (job-independent); information only since R2 removed the check-wide set-aside
|
|
499
|
+
*/
|
|
500
|
+
key: string;
|
|
501
|
+
};
|
|
502
|
+
export type Pending = {
|
|
503
|
+
runid: string;
|
|
504
|
+
at: string;
|
|
505
|
+
workflow: string;
|
|
506
|
+
place: string | null;
|
|
507
|
+
specHash: string | null;
|
|
508
|
+
cards: Card[];
|
|
509
|
+
};
|
|
510
|
+
export type Ledger = {
|
|
511
|
+
version: 1;
|
|
512
|
+
rows: Row[];
|
|
513
|
+
/**
|
|
514
|
+
* holds written by v0.46.x for rubric runs, released by the human Accept (NOT counted, NOT readable); new runs never write one
|
|
515
|
+
*/
|
|
516
|
+
pending: Pending[];
|
|
517
|
+
/**
|
|
518
|
+
* CHECK-SUSPECT cards, listed, newest last
|
|
519
|
+
*/
|
|
520
|
+
suspect: Card[];
|
|
521
|
+
/**
|
|
522
|
+
* per run (idempotent by run id)
|
|
523
|
+
*/
|
|
524
|
+
health: Record<string, {
|
|
525
|
+
at: string;
|
|
526
|
+
noise: string | null;
|
|
527
|
+
cards: number;
|
|
528
|
+
suspect: number;
|
|
529
|
+
thin: number;
|
|
530
|
+
}>;
|
|
531
|
+
};
|
|
532
|
+
/**
|
|
533
|
+
* one hint of a rendered block, split back into its fields (for the panel's Audit view)
|
|
534
|
+
*/
|
|
535
|
+
export type HintParts = {
|
|
536
|
+
/**
|
|
537
|
+
* the hint's number in the block
|
|
538
|
+
*/
|
|
539
|
+
n: number;
|
|
540
|
+
/**
|
|
541
|
+
* 'this job' | 'this place' | 'all jobs' (the words {@link renderHints} wrote)
|
|
542
|
+
*/
|
|
543
|
+
level: string;
|
|
544
|
+
/**
|
|
545
|
+
* how many runs saw it
|
|
546
|
+
*/
|
|
547
|
+
count: number;
|
|
548
|
+
/**
|
|
549
|
+
* the check's name
|
|
550
|
+
*/
|
|
551
|
+
check: string;
|
|
552
|
+
/**
|
|
553
|
+
* the error codes (empty when the hint names none)
|
|
554
|
+
*/
|
|
555
|
+
kinds: string[];
|
|
556
|
+
/**
|
|
557
|
+
* true = fixed later in the same run, false = never fixed
|
|
558
|
+
*/
|
|
559
|
+
fixed: boolean;
|
|
560
|
+
/**
|
|
561
|
+
* the "It said" line
|
|
562
|
+
*/
|
|
563
|
+
said: string | null;
|
|
564
|
+
/**
|
|
565
|
+
* the "Fix touched" text
|
|
566
|
+
*/
|
|
567
|
+
touched: string | null;
|
|
568
|
+
/**
|
|
569
|
+
* the shown What-changed lines (+/- lines), without the "(+N more)" line
|
|
570
|
+
*/
|
|
571
|
+
changed: string[];
|
|
572
|
+
/**
|
|
573
|
+
* N of "(+N more)", 0 when absent
|
|
574
|
+
*/
|
|
575
|
+
moreChanged: number;
|
|
576
|
+
};
|