fwdloop 0.13.0 → 0.14.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 +25 -12
- package/package.json +2 -2
- package/src/authoring.js +68 -37
- package/src/canrun.js +71 -1
- package/src/catalogue.json +2 -2
- package/src/checked.js +50 -0
- package/src/closers.js +112 -91
- package/src/declaration.js +113 -11
- package/src/drafter.js +139 -39
- package/src/keysfile.js +4 -2
- package/src/model-step.js +1 -1
- package/src/monthly.js +139 -17
- package/src/panel/author.js +219 -63
- package/src/panel/authorcard.js +44 -1
- package/src/panel/authorflows.js +12 -7
- package/src/panel/data.js +96 -71
- package/src/panel/index.html +355 -303
- package/src/panel/server.js +4 -1
- package/src/panel/settings.js +1 -1
- package/src/runner.js +96 -47
- package/src/setup.js +21 -14
- package/types/authoring.d.ts +41 -9
- package/types/canrun.d.ts +33 -1
- package/types/checked.d.ts +23 -0
- package/types/closers.d.ts +47 -28
- package/types/declaration.d.ts +16 -2
- package/types/drafter.d.ts +146 -11
- package/types/model-step.d.ts +1 -6
- package/types/monthly.d.ts +25 -1
- package/types/panel/author.d.ts +21 -40
- package/types/panel/authorcard.d.ts +22 -0
- package/types/panel/data.d.ts +5 -54
- package/types/runner.d.ts +11 -3
- package/types/setup.d.ts +6 -12
package/types/closers.d.ts
CHANGED
|
@@ -11,52 +11,70 @@ export function closeGreen(artifact: any, ctx: {
|
|
|
11
11
|
businessDate: string;
|
|
12
12
|
}): CloseVerdict;
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* M4e amendment 18: the soft checks run on bareguard 0.21.0. `softgreenSpec(shape)` is the ONE place a declared shape
|
|
15
|
+
* becomes a rubric spec (signing and the run both build through `buildSoftgreenRubric`, so a shape that signs is a shape
|
|
16
|
+
* that builds). The checks are in this fixed order, which is the order their sentences read in:
|
|
17
|
+
* allowedKeys, maxWords, sectionOrder, sectionWords, blockLines.
|
|
18
|
+
* A key that is declared at all gets its check built, so a half-declared shape (wordsPerSection with no sections, one of
|
|
19
|
+
* linesPerInvoice/mustCarry) cannot build and is a crash at run time, never silently skipped.
|
|
17
20
|
*
|
|
18
|
-
* @param {
|
|
19
|
-
* @param {{ maxWords: number, sections: string[] }} declared
|
|
20
|
-
* @returns {CloseVerdict}
|
|
21
|
+
* @param {Record<string, any>} shape
|
|
21
22
|
*/
|
|
22
|
-
export function
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
export function softgreenSpec(shape: Record<string, any>): {
|
|
24
|
+
schema: number;
|
|
25
|
+
goal: string;
|
|
26
|
+
checkpoints: {
|
|
27
|
+
close: {
|
|
28
|
+
gating: boolean;
|
|
29
|
+
checks: Record<string, any>[];
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
/** Throws bareguard's `invalid rubric: ...` for a shape it cannot build. @param {Record<string, any>} shape @returns {ReturnType<typeof createRubric>} */
|
|
34
|
+
export function buildSoftgreenRubric(shape: Record<string, any>): ReturnType<typeof createRubric>;
|
|
26
35
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
36
|
+
* The ONE render function (amendment 18 item 4A): bareguard's typed gaps in, fwdloop's plain-English sentences out, byte for byte
|
|
37
|
+
* what the hand-written checks said before the switch (test/m4e-am18-parity.test.js proves it on 142 inputs); past bareguard's own
|
|
38
|
+
* offender-list bound the "N more" tail is ours (amendment 19 2), derived from each gap's `itemsTotal` and list length, never a number.
|
|
39
|
+
* What it throws away: bareguard bounds every offender list; past that the sentence says how many more there were.
|
|
40
|
+
* A gap it has no sentence for is still a red, worded generically, never dropped.
|
|
41
|
+
*
|
|
42
|
+
* @param {any[]} gaps
|
|
43
|
+
* @param {{ linesPerInvoice?: number, mustCarry?: string[] }} shape
|
|
44
|
+
* @returns {{ red: string, reds: string[] }}
|
|
32
45
|
*/
|
|
33
|
-
export function
|
|
34
|
-
linesPerInvoice
|
|
35
|
-
mustCarry
|
|
36
|
-
}):
|
|
46
|
+
export function renderSoftgreenGaps(gaps: any[], shape: {
|
|
47
|
+
linesPerInvoice?: number;
|
|
48
|
+
mustCarry?: string[];
|
|
49
|
+
}): {
|
|
50
|
+
red: string;
|
|
51
|
+
reds: string[];
|
|
52
|
+
};
|
|
37
53
|
/**
|
|
38
|
-
* `softgreen` close:
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
54
|
+
* `softgreen` close: the declared shape (`maxWords`, `sections`, `wordsPerSection`, `linesPerInvoice` + `mustCarry`, and the
|
|
55
|
+
* one-key rule) is checked by bareguard's rubric (amendment 18 item 1) and every failing check is reported, one sentence each
|
|
56
|
+
* (F38's rule, never widened to first-red-only). Our front door stays: an answer that is not `{text: string}` is `unparseable`
|
|
57
|
+
* before bareguard sees it. A shape that cannot be built, or a check that stopped, is `crash`: never green.
|
|
58
|
+
* Async because bareguard's `checkStep` is.
|
|
42
59
|
*
|
|
43
60
|
* @param {any} artifact
|
|
44
|
-
* @param {{ maxWords?: number, sections?: string[], linesPerInvoice?: number, mustCarry?: string[] }} shape
|
|
45
|
-
* @returns {CloseVerdict}
|
|
61
|
+
* @param {{ maxWords?: number, sections?: string[], wordsPerSection?: number, linesPerInvoice?: number, mustCarry?: string[] }} shape
|
|
62
|
+
* @returns {Promise<CloseVerdict>}
|
|
46
63
|
*/
|
|
47
64
|
export function closeSoftgreen(artifact: any, shape: {
|
|
48
65
|
maxWords?: number;
|
|
49
66
|
sections?: string[];
|
|
67
|
+
wordsPerSection?: number;
|
|
50
68
|
linesPerInvoice?: number;
|
|
51
69
|
mustCarry?: string[];
|
|
52
|
-
}): CloseVerdict
|
|
70
|
+
}): Promise<CloseVerdict>;
|
|
53
71
|
/**
|
|
54
72
|
* The one dispatcher — `close by declared class` (M2 scope item 4).
|
|
55
73
|
*
|
|
56
74
|
* @param {{ close?: { class?: string, shape?: Record<string, any> } }} step
|
|
57
75
|
* @param {unknown} artifact
|
|
58
76
|
* @param {{ reads: Record<string, any>, businessDate: string }} ctx
|
|
59
|
-
* @returns {CloseVerdict}
|
|
77
|
+
* @returns {Promise<CloseVerdict>}
|
|
60
78
|
*/
|
|
61
79
|
export function closeByClass(step: {
|
|
62
80
|
close?: {
|
|
@@ -66,5 +84,6 @@ export function closeByClass(step: {
|
|
|
66
84
|
}, artifact: unknown, ctx: {
|
|
67
85
|
reads: Record<string, any>;
|
|
68
86
|
businessDate: string;
|
|
69
|
-
}): CloseVerdict
|
|
87
|
+
}): Promise<CloseVerdict>;
|
|
70
88
|
export type CloseVerdict = import("./types.js").CloseVerdict;
|
|
89
|
+
import { createRubric } from 'bareguard';
|
package/types/declaration.d.ts
CHANGED
|
@@ -19,9 +19,21 @@ export function checkShapes(declaration: any): {
|
|
|
19
19
|
reds: any[];
|
|
20
20
|
shapedSteps: number;
|
|
21
21
|
};
|
|
22
|
+
/** Every whole-output word number in a guardrail ("3 sections, under 600 words, each heading at most 3 words" -> [600, 3]), in order; [] when
|
|
23
|
+
* there is none. Code does not decide which one is the limit: the AI picks `maxWords` and the validator checks the pick is one of these
|
|
24
|
+
* (M4e amendments 28 + 29). A "<n> words each" / "<n> words per section" is the per-section size (amendment 15), never listed here. */
|
|
25
|
+
export function guardrailWordNumbers(guardrail: any): number[];
|
|
26
|
+
/** M4e amendment 15 item 1: the "<n> words each" / "<n> words per section" size in a guardrail ("about 250 words each", "250ish each" -> 250), or null. */
|
|
27
|
+
export function guardrailWordsPerSection(guardrail: any): number | null;
|
|
28
|
+
/** M4e amendment 7 item 1: the first "<N> sections" in a guardrail (N digits, or the words one..ten), or null. */
|
|
29
|
+
export function guardrailSectionCount(guardrail: any): any;
|
|
30
|
+
/** M4e amendment 15 item 2: for each line whose guardrail gives a size for each section, a section count AND a word number,
|
|
31
|
+
* size x count more than the LARGEST word number (no possible pick fits) is a red naming the line and the numbers. $0; run before any model
|
|
32
|
+
* call, when there is no AI pick yet (amendment 29). After the draft the AI's `maxWords` is checked in checkShapeFitsJobLine. */
|
|
33
|
+
export function checkGuardrailSums(lines: any): string[];
|
|
22
34
|
/** M4e amendment 6 item 1 (+ amendment 7 item 1): a step's check cannot fight its own job line. Sections must be found in the line's words
|
|
23
|
-
* (case-insensitive substring of the goal, first occurrence) and in the line's order; `maxWords`
|
|
24
|
-
*
|
|
35
|
+
* (case-insensitive substring of the goal, first occurrence) and in the line's order; `maxWords` (the AI's pick, amendment 29) must be one
|
|
36
|
+
* of the line's guardrail word numbers when that guardrail has any. A shape key a note may still change (mustCarry, linesPerInvoice)
|
|
25
37
|
* is untouched. Pushes reds naming the step and both orders/values. */
|
|
26
38
|
export function checkShapeFitsJobLine(step: any, i: any, lines: any, reds: any): void;
|
|
27
39
|
/**
|
|
@@ -61,6 +73,8 @@ export const DECLARATION_FIELDS: readonly string[];
|
|
|
61
73
|
* exactly these four top-level keys. Anything else inside `shape` reds by
|
|
62
74
|
* name. */
|
|
63
75
|
export const SHAPE_KEYS: readonly string[];
|
|
76
|
+
/** Shape keys only the MACHINE sets (M4e amendment 15): read from the line's guardrail, never offered to the drafter's model. */
|
|
77
|
+
export const MACHINE_SHAPE_KEYS: readonly string[];
|
|
64
78
|
export type Arbiter = import("./types.js").Arbiter;
|
|
65
79
|
export type SignedLine = import("./types.js").SignedLine;
|
|
66
80
|
export type CatalogueEntry = import("./types.js").CatalogueEntry;
|
package/types/drafter.d.ts
CHANGED
|
@@ -102,6 +102,133 @@ export function buildDeclarationSchema(menu: any): {
|
|
|
102
102
|
required: string[];
|
|
103
103
|
additionalProperties: boolean;
|
|
104
104
|
};
|
|
105
|
+
/** The declaration schema plus the optional `notChecked` (every try) and, on try 3 only, `questions`. Neither is in `required`. */
|
|
106
|
+
export function buildRoundSchema(menu: any, { questions }?: {
|
|
107
|
+
questions?: boolean | undefined;
|
|
108
|
+
}): {
|
|
109
|
+
properties: {
|
|
110
|
+
notChecked: {
|
|
111
|
+
type: string;
|
|
112
|
+
items: {
|
|
113
|
+
type: string;
|
|
114
|
+
};
|
|
115
|
+
description: string;
|
|
116
|
+
};
|
|
117
|
+
steps: {
|
|
118
|
+
type: string;
|
|
119
|
+
minItems: number;
|
|
120
|
+
items: {
|
|
121
|
+
type: string;
|
|
122
|
+
properties: {
|
|
123
|
+
primitives: {
|
|
124
|
+
type: string;
|
|
125
|
+
items: {
|
|
126
|
+
type: string;
|
|
127
|
+
enum: any;
|
|
128
|
+
};
|
|
129
|
+
description: string;
|
|
130
|
+
};
|
|
131
|
+
reads: {
|
|
132
|
+
type: string;
|
|
133
|
+
items: {
|
|
134
|
+
type: string;
|
|
135
|
+
};
|
|
136
|
+
description: string;
|
|
137
|
+
};
|
|
138
|
+
emits: {
|
|
139
|
+
type: string;
|
|
140
|
+
minLength: number;
|
|
141
|
+
description: string;
|
|
142
|
+
};
|
|
143
|
+
fromLine: {
|
|
144
|
+
type: string[];
|
|
145
|
+
description: string;
|
|
146
|
+
};
|
|
147
|
+
picks: {
|
|
148
|
+
type: string;
|
|
149
|
+
additionalProperties: {
|
|
150
|
+
type: string;
|
|
151
|
+
items: {
|
|
152
|
+
type: string;
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
description: string;
|
|
156
|
+
};
|
|
157
|
+
close: {
|
|
158
|
+
type: string;
|
|
159
|
+
properties: {
|
|
160
|
+
class: {
|
|
161
|
+
type: string;
|
|
162
|
+
enum: string[];
|
|
163
|
+
description: string;
|
|
164
|
+
};
|
|
165
|
+
shape: {
|
|
166
|
+
type: string;
|
|
167
|
+
properties: {};
|
|
168
|
+
additionalProperties: boolean;
|
|
169
|
+
description: string;
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
required: string[];
|
|
173
|
+
additionalProperties: boolean;
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
required: string[];
|
|
177
|
+
additionalProperties: boolean;
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
guardrailClasses: {
|
|
181
|
+
type: string;
|
|
182
|
+
additionalProperties: {
|
|
183
|
+
type: string;
|
|
184
|
+
enum: string[];
|
|
185
|
+
};
|
|
186
|
+
description: string;
|
|
187
|
+
};
|
|
188
|
+
unjudgeable: {
|
|
189
|
+
type: string;
|
|
190
|
+
additionalProperties: {
|
|
191
|
+
type: string;
|
|
192
|
+
};
|
|
193
|
+
description: string;
|
|
194
|
+
};
|
|
195
|
+
refused: {
|
|
196
|
+
type: string;
|
|
197
|
+
items: {
|
|
198
|
+
type: string;
|
|
199
|
+
properties: {
|
|
200
|
+
line: {
|
|
201
|
+
type: string;
|
|
202
|
+
};
|
|
203
|
+
reason: {
|
|
204
|
+
type: string;
|
|
205
|
+
minLength: number;
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
required: string[];
|
|
209
|
+
additionalProperties: boolean;
|
|
210
|
+
};
|
|
211
|
+
description: string;
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
type: string;
|
|
215
|
+
required: string[];
|
|
216
|
+
additionalProperties: boolean;
|
|
217
|
+
};
|
|
218
|
+
/**
|
|
219
|
+
* Which job lines did these reds name? Reds name a line three ways: "line N" (also "ask at line N", "(line N)",
|
|
220
|
+
* "guardrailClasses key \"N\""), "steps[i]" (mapped through that declaration's steps[i].fromLine), and "step N's check"
|
|
221
|
+
* (1-based). A red naming none (a missing top-level key, an unknown key) names no line. Returns sorted real line numbers.
|
|
222
|
+
*/
|
|
223
|
+
export function linesNamedByReds(reds: any, declaration: any, lineNums: any): any[];
|
|
224
|
+
/**
|
|
225
|
+
* Amendment 25: a question is kept only if its line is one try 2's reds named; no line, a blank question or a third question is
|
|
226
|
+
* dropped. Every drop comes back with its reason, for the draft's log. Returns {kept, dropped}.
|
|
227
|
+
*/
|
|
228
|
+
export function normalizeQuestions(raw: any, failedLines: any): {
|
|
229
|
+
kept: any[];
|
|
230
|
+
dropped: any[];
|
|
231
|
+
};
|
|
105
232
|
export function buildSystemPrompt({ menu, lines, arbiter, factsInfo }: {
|
|
106
233
|
menu: any;
|
|
107
234
|
lines: any;
|
|
@@ -114,12 +241,6 @@ export function buildSystemPrompt({ menu, lines, arbiter, factsInfo }: {
|
|
|
114
241
|
* lines do not exist in the grammar. A step naming no signed line gets a fixed placeholder, never model prose.
|
|
115
242
|
*/
|
|
116
243
|
export function goalForLine(fromLine: any, lines: any): any;
|
|
117
|
-
/**
|
|
118
|
-
* M4e amendment 3 item 3 (revise the plan): the first round's user text when the human asked for a change. The model sees the
|
|
119
|
-
* current plan (its own fields only: no machine-set `goal`, no `inputFacts`) and the note; the rules above still hold, and the
|
|
120
|
-
* validator below is the ONE check that refuses a plan that touches what only the card may set.
|
|
121
|
-
*/
|
|
122
|
-
export function reviseOpening(plan: any, note: any): string;
|
|
123
244
|
/**
|
|
124
245
|
* Draft one declaration. `provider`/`rates`/`modelId` may be injected (tests,
|
|
125
246
|
* the batch); otherwise a live provider is built from `slot` (throws on a bad
|
|
@@ -129,13 +250,12 @@ export function reviseOpening(plan: any, note: any): string;
|
|
|
129
250
|
* `calls`) and right AFTER it (`inFlight: false`), with what is known so far, so the caller can book spend per call
|
|
130
251
|
* and a draft killed between rounds still has its paid rounds on disk. It may throw before a call (nothing is
|
|
131
252
|
* spent then and the draft stops); after a call it is the caller's to keep from throwing.
|
|
132
|
-
* `revise` (M4e amendment 3 item 3): `{ plan, note }` — the current green plan and the human's note; the first round then asks for the
|
|
133
|
-
* revised plan. Everything else (the $0 gates, the validator, the budget, the metering) is the same code path as a first draft.
|
|
134
253
|
*
|
|
135
254
|
* @returns {Promise<{ok:boolean, declaration:object|null, reds:string[], rounds:number, calls:number, spendComplete:boolean,
|
|
136
|
-
* costUsd:number|null, modelReturned:string|null, modelId?:string, price?:object|null, tokens?:object|null, structureRetries:number, revisions:number, stop:string|null, log:object[]
|
|
255
|
+
* costUsd:number|null, modelReturned:string|null, modelId?:string, price?:object|null, tokens?:object|null, structureRetries:number, revisions:number, stop:string|null, log:object[],
|
|
256
|
+
* questions?:{line:number, question:string}[], droppedQuestions?:object[], notChecked?:string[]}>}
|
|
137
257
|
*/
|
|
138
|
-
export function draft({ proseText, slot, model, provider: injected, rates: injectedRates, modelId: injectedModelId, env, budgetUsd, skills, makeProviderFn, onBook,
|
|
258
|
+
export function draft({ proseText, slot, model, provider: injected, rates: injectedRates, modelId: injectedModelId, env, budgetUsd, skills, makeProviderFn, onBook, offerQuestions, }: {
|
|
139
259
|
proseText: any;
|
|
140
260
|
slot?: string | undefined;
|
|
141
261
|
model: any;
|
|
@@ -147,7 +267,7 @@ export function draft({ proseText, slot, model, provider: injected, rates: injec
|
|
|
147
267
|
skills?: readonly string[] | undefined;
|
|
148
268
|
makeProviderFn?: typeof makeProvider | undefined;
|
|
149
269
|
onBook: any;
|
|
150
|
-
|
|
270
|
+
offerQuestions?: boolean | undefined;
|
|
151
271
|
}): Promise<{
|
|
152
272
|
ok: boolean;
|
|
153
273
|
declaration: object | null;
|
|
@@ -164,12 +284,27 @@ export function draft({ proseText, slot, model, provider: injected, rates: injec
|
|
|
164
284
|
revisions: number;
|
|
165
285
|
stop: string | null;
|
|
166
286
|
log: object[];
|
|
287
|
+
questions?: {
|
|
288
|
+
line: number;
|
|
289
|
+
question: string;
|
|
290
|
+
}[];
|
|
291
|
+
droppedQuestions?: object[];
|
|
292
|
+
notChecked?: string[];
|
|
167
293
|
}>;
|
|
168
294
|
export const MAX_STRUCTURE_RETRIES: 2;
|
|
169
295
|
export const MAX_REVISIONS: 2;
|
|
170
296
|
export const DRAFT_MAX_TOKENS: 16000;
|
|
171
297
|
export const DRAFT_SKILLS: readonly string[];
|
|
172
298
|
export const CLASSES: readonly string[];
|
|
299
|
+
/** The whole-output-ceiling rule, told once to the drafter (schema and prompt use this string). Amendment 29; no number words (am25). */
|
|
300
|
+
export const WHOLE_OUTPUT_CEILING_RULE: "use the guardrail's ceiling for the whole output";
|
|
301
|
+
export const MAX_QUESTIONS: 2;
|
|
302
|
+
/** What fwdloop's typed checks can really check (bareloop F174: give the model the real list, or "Not checked" is invented). */
|
|
303
|
+
export const CHECKABLE: readonly string[];
|
|
304
|
+
/** Offered on EVERY try (it is information, not asking). */
|
|
305
|
+
export const NOTCHECKED_PROMPT: string;
|
|
306
|
+
/** Try 3 only, and only after tries 1 and 2 both failed validation. No digit and no number word anywhere (a test greps this): the machine, not the prompt, bounds the count. */
|
|
307
|
+
export const QUESTIONS_PROMPT: string;
|
|
173
308
|
export const DRAFT_PROVIDER_OPTIONS: Readonly<{
|
|
174
309
|
thinking: Readonly<{
|
|
175
310
|
type: "disabled";
|
package/types/model-step.d.ts
CHANGED
|
@@ -54,14 +54,9 @@ export function buildEmitArtifactSchema(stepClass: any): Readonly<{
|
|
|
54
54
|
text: {
|
|
55
55
|
type: string;
|
|
56
56
|
};
|
|
57
|
-
lines: {
|
|
58
|
-
type: string;
|
|
59
|
-
items: {
|
|
60
|
-
type: string;
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
57
|
};
|
|
64
58
|
required: string[];
|
|
59
|
+
additionalProperties: false;
|
|
65
60
|
}> | Readonly<{
|
|
66
61
|
type: "object";
|
|
67
62
|
properties: {
|
package/types/monthly.d.ts
CHANGED
|
@@ -4,11 +4,13 @@ export function realpathLoose(p: string): string;
|
|
|
4
4
|
export function readRuns(home?: string): any[];
|
|
5
5
|
/**
|
|
6
6
|
* The Money tab's figures (piece 4 reads this) and the check's month total.
|
|
7
|
-
*
|
|
7
|
+
* `rows` (a caller that has just read the record, like the claim) saves a second parse of the same file.
|
|
8
|
+
* @param {{ home?: string, now?: () => number, rows?: any[] }} [opts]
|
|
8
9
|
*/
|
|
9
10
|
export function spendSummary(opts?: {
|
|
10
11
|
home?: string;
|
|
11
12
|
now?: () => number;
|
|
13
|
+
rows?: any[];
|
|
12
14
|
}): {
|
|
13
15
|
month: {
|
|
14
16
|
modelMinutes: number | null;
|
|
@@ -89,6 +91,28 @@ export function claimHold({ what, flow, runId, runDir, holdUsd, spentAtHold, hom
|
|
|
89
91
|
home?: string;
|
|
90
92
|
now?: () => number;
|
|
91
93
|
}): Claim;
|
|
94
|
+
/**
|
|
95
|
+
* Amendment 16 C2: a hold's process starts spending into one more run dir (a rerun's new run): name it NOW, so a process killed hard
|
|
96
|
+
* still has that dir's spend counted. Append-only; `namedDirs` dedupes, so the settle note naming it again never counts it twice.
|
|
97
|
+
* Never throws (a failed note is closed by the settle note's `alsoRunDirs` on a normal exit).
|
|
98
|
+
* @param {{ holdId: string|null, runDir: string, home?: string, now?: () => number }} a
|
|
99
|
+
*/
|
|
100
|
+
export function nameRunDir({ holdId, runDir, home, now, }: {
|
|
101
|
+
holdId: string | null;
|
|
102
|
+
runDir: string;
|
|
103
|
+
home?: string;
|
|
104
|
+
now?: () => number;
|
|
105
|
+
}): void;
|
|
106
|
+
/**
|
|
107
|
+
* I1 (amendment 16): fold the spend of every run/draft dir whose holds have ALL ended (settled, released or refused) into `rolled`
|
|
108
|
+
* rows, so the next month figure or Money load reads one record instead of one file per run. Append-only; a dir already rolled and not
|
|
109
|
+
* named since is left alone. Reads the dirs it folds exactly as `spendSummary` would, so no total changes. Never throws.
|
|
110
|
+
* @param {{ home?: string, now?: () => number }} [a]
|
|
111
|
+
*/
|
|
112
|
+
export function rollSettled({ home, now }?: {
|
|
113
|
+
home?: string;
|
|
114
|
+
now?: () => number;
|
|
115
|
+
}): void;
|
|
92
116
|
/**
|
|
93
117
|
* The run's own process ends or parks: give the hold back. Never throws (a failed settle is closed by the
|
|
94
118
|
* next check as "process gone"). `alsoRunDirs` names dirs this process also spent into (a rerun's new run).
|
package/types/panel/author.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @param {{ root: string, home?: string, skipMonthly?: boolean, loadEnv: () => { ok: boolean, env: Record<string, string|undefined>, refusal: string|null }, bin?: string }} opts
|
|
2
|
+
* @param {{ root: string, home?: string, skipMonthly?: boolean, loadEnv: () => { ok: boolean, env: Record<string, string|undefined>, refusal: string|null }, bin?: string, childRunning?: (dir: string) => boolean }} opts
|
|
3
3
|
* `loadEnv` is the keys-file door (`keysForDoor`): called before EVERY spawn and every reply that quotes a log, so editing
|
|
4
4
|
* the file needs no restart. Its `env` is BOTH the child's spawn env AND the scrub list (POC (a), M4d wiring rule).
|
|
5
5
|
*/
|
|
@@ -13,6 +13,7 @@ export function createAuthor(opts: {
|
|
|
13
13
|
refusal: string | null;
|
|
14
14
|
};
|
|
15
15
|
bin?: string;
|
|
16
|
+
childRunning?: (dir: string) => boolean;
|
|
16
17
|
}): {
|
|
17
18
|
flows: () => {
|
|
18
19
|
status: number;
|
|
@@ -231,48 +232,28 @@ export function createAuthor(opts: {
|
|
|
231
232
|
*/
|
|
232
233
|
sign(id: string, body: any): any;
|
|
233
234
|
/**
|
|
234
|
-
* `POST /api/author/:id/revise` body
|
|
235
|
-
* plan -> $0 checks
|
|
236
|
-
*
|
|
237
|
-
* draft;
|
|
235
|
+
* `POST /api/author/:id/revise` body = the card fields, as `POST /api/author/draft` takes them (M4e amendment 14): the human's edited
|
|
236
|
+
* card on a draft whose first plan was green -> the same $0 checks as a first draft -> `card-<n>.json` + `prose-<n>.txt` (write-once)
|
|
237
|
+
* -> one detached plain `fwdloop draft prose-<n>.txt --out draft-<n>` -> 202. The model gets the card only. Up to MAX_REVISES per
|
|
238
|
+
* draft; a refusal makes no model call and writes nothing. A body carrying a note (`text`/`note`) is refused: nothing the human types
|
|
239
|
+
* goes to the model as a note. Synchronous, like `start`.
|
|
238
240
|
* @param {string} id @param {any} body
|
|
239
241
|
*/
|
|
240
242
|
revise(id: string, body: any): {
|
|
241
243
|
status: number;
|
|
242
|
-
body:
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
refused: string;
|
|
254
|
-
say?: undefined;
|
|
255
|
-
draftId?: undefined;
|
|
256
|
-
n?: undefined;
|
|
257
|
-
};
|
|
258
|
-
} | {
|
|
259
|
-
status: number;
|
|
260
|
-
body: {
|
|
261
|
-
ok: boolean;
|
|
262
|
-
refused: string;
|
|
263
|
-
draftId: string;
|
|
264
|
-
say: string;
|
|
265
|
-
n?: undefined;
|
|
266
|
-
};
|
|
267
|
-
} | {
|
|
244
|
+
body: any;
|
|
245
|
+
};
|
|
246
|
+
/**
|
|
247
|
+
* `POST /api/author/:id/answer` body `{ k, answer }` (M4e amendments 24, 25): the human's answer to the plan's question `k` of `n`, one at a time.
|
|
248
|
+
* A blank answer is refused and the question stays open; there is no skip. The answer is written ONCE ('wx') as `<plan>/answer-<k>.json`. After
|
|
249
|
+
* the LAST answer the plan is drafted again as a fresh plain `fwdloop draft --no-questions` child (it never asks), from the submitted card with
|
|
250
|
+
* each answer added word for word as a `~` guardrail under its line (the one `appendAnswersToJob`, then the one `cardToProse`). It is booked as
|
|
251
|
+
* an answer redraft (`redraft-<n>.json`), not a revise: it uses none of the 2. Synchronous, like `revise`; a refusal at $0 writes nothing.
|
|
252
|
+
* @param {string} id @param {any} body
|
|
253
|
+
*/
|
|
254
|
+
answer(id: string, body: any): {
|
|
268
255
|
status: number;
|
|
269
|
-
body:
|
|
270
|
-
ok: boolean;
|
|
271
|
-
draftId: string;
|
|
272
|
-
n: number;
|
|
273
|
-
refused?: undefined;
|
|
274
|
-
say?: undefined;
|
|
275
|
-
};
|
|
256
|
+
body: any;
|
|
276
257
|
};
|
|
277
258
|
/**
|
|
278
259
|
* `GET /api/author/live`: the newest draft that is not abandoned or signed, and the newest panel start the human has not cleared
|
|
@@ -331,5 +312,5 @@ export function createAuthor(opts: {
|
|
|
331
312
|
};
|
|
332
313
|
}>;
|
|
333
314
|
};
|
|
334
|
-
/** Up to 2
|
|
335
|
-
export const
|
|
315
|
+
/** Up to 2 revises per draft (amendment 14 item 3); a revise is used once its `draft-<n>/` exists (a refusal at $0 makes none). */
|
|
316
|
+
export const MAX_REVISES: 2;
|
|
@@ -20,6 +20,28 @@ export function parseJobBox(text: string): {
|
|
|
20
20
|
say: string;
|
|
21
21
|
}[];
|
|
22
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* M4e amendment 24 item 3: the submitted job box with each answer added WORD FOR WORD as a `~` line under the job line it is about, after
|
|
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
|
+
* (`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
|
+
* the box does not have is NOT added (the caller sees the count).
|
|
28
|
+
* @param {string} job @param {{ line: number, answer: string }[]} answers
|
|
29
|
+
* @returns {{ job: string, added: number }}
|
|
30
|
+
*/
|
|
31
|
+
export function appendAnswersToJob(job: string, answers: {
|
|
32
|
+
line: number;
|
|
33
|
+
answer: string;
|
|
34
|
+
}[]): {
|
|
35
|
+
job: string;
|
|
36
|
+
added: number;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* THE one place a step's `~` lines become its guardrail: several `~` lines under one step are ONE continuous guardrail (hamr ruling 2026-10-09),
|
|
40
|
+
* each part verbatim (trimmed), in typed order, joined by "; ". An answer (am24) is one more `~` line, so it joins here too. The signed-text parser
|
|
41
|
+
* stays strict 1-for-1 because the job file never carries more than one `guardrail:` per line.
|
|
42
|
+
* @param {string[]} parts
|
|
43
|
+
*/
|
|
44
|
+
export function joinGuardrails(parts: string[]): string;
|
|
23
45
|
/** The job file lines (`N. text`, ` guardrail: text`, `N. ask <wait>: question`) for parsed steps; the wait is ALWAYS written out. @param {ReturnType<typeof parseJobBox>['steps']} steps @param {string} askWait */
|
|
24
46
|
export function jobFileLines(steps: ReturnType<typeof parseJobBox>["steps"], askWait: string): string[];
|
|
25
47
|
/**
|
package/types/panel/data.d.ts
CHANGED
|
@@ -175,10 +175,10 @@ export function glyphPulses(g: {
|
|
|
175
175
|
* A saved answer with a live process is `[▶]` working on your answer.
|
|
176
176
|
* - `[?]` crashed after taking your answer (amendment 2 (f)) — the answer was
|
|
177
177
|
* consumed, the process is gone, no end row: cannot be carried on.
|
|
178
|
-
* @param {{historyRow: any, askJson: any, consumedAnswerExists: boolean, hasStateJson: boolean, resume?: any, liveness?: 'running'|'gone'|'unknown', booksFresh?: boolean, lock?: string, resumable?: boolean}} ctx
|
|
178
|
+
* @param {{historyRow: any, askJson: any, consumedAnswerExists: boolean, hasStateJson: boolean, resume?: any, liveness?: 'running'|'gone'|'unknown', booksFresh?: boolean, lock?: string, resumable?: boolean, stoppedAtAsk?: string|null}} ctx
|
|
179
179
|
* @returns {{glyph: '[✓]'|'[✗]'|'[·]'|'[!]'|'[▶]'|'[?]'|'[II]'|'[■]', label: string}}
|
|
180
180
|
*/
|
|
181
|
-
export function computeGlyph({ historyRow, askJson, consumedAnswerExists, hasStateJson, resume, liveness, booksFresh, lock, resumable, }: {
|
|
181
|
+
export function computeGlyph({ historyRow, askJson, consumedAnswerExists, hasStateJson, resume, liveness, booksFresh, lock, resumable, stoppedAtAsk, }: {
|
|
182
182
|
historyRow: any;
|
|
183
183
|
askJson: any;
|
|
184
184
|
consumedAnswerExists: boolean;
|
|
@@ -188,6 +188,7 @@ export function computeGlyph({ historyRow, askJson, consumedAnswerExists, hasSta
|
|
|
188
188
|
booksFresh?: boolean;
|
|
189
189
|
lock?: string;
|
|
190
190
|
resumable?: boolean;
|
|
191
|
+
stoppedAtAsk?: string | null;
|
|
191
192
|
}): {
|
|
192
193
|
glyph: "[\u2713]" | "[\u2717]" | "[\u00B7]" | "[!]" | "[\u25B6]" | "[?]" | "[II]" | "[\u25A0]";
|
|
193
194
|
label: string;
|
|
@@ -483,7 +484,7 @@ export function getRunDetail({ root, flow, runId, catalogue, resumeAttempt, }: {
|
|
|
483
484
|
* What the Draft adds up to, ONE place (the Map box, the first step card and the Audit group all read it, so the three can never disagree).
|
|
484
485
|
* M4e amendment 9: `timeMs` is the card row's `at` to the sign row's `at` (the whole drafting, human time included), `null` when either has no
|
|
485
486
|
* usable `at`; never a sum of the model rows' `wallMs`. `calls` sums the rows' `calls`, a row with none counts 1 and sets `callsAtLeast`, so an
|
|
486
|
-
* unknown never shows as a smaller exact number; no model rows = `null`. `humanChecks` = the note rows + the sign row + the run's signed-values
|
|
487
|
+
* unknown never shows as a smaller exact number; no model rows = `null`. `humanChecks` = the note rows + the revise rows (each is the card the human edited and sent) + the sign row + the run's signed-values
|
|
487
488
|
* rows (the card is not a check), given by the caller as `ctx.humanChecks`. Money follows `costDisplay` ("at least $X" for a floor).
|
|
488
489
|
* @param {any[]} modelRows the draft and change rows (`kind` draft | change) of `setup.jsonl`
|
|
489
490
|
* @param {{cardAt?: any, signAt?: any, humanChecks?: number|null}} [ctx]
|
|
@@ -549,55 +550,6 @@ export function getRunAudit({ root, flow, runId }: {
|
|
|
549
550
|
empty: boolean;
|
|
550
551
|
why: string | null;
|
|
551
552
|
} | null;
|
|
552
|
-
/**
|
|
553
|
-
* `GET /api/runs/:flow/:runId/job` — the Job tab (M4a scope item 2): the
|
|
554
|
-
* signed prose, the arbiter block (cap, asks with TTL, redo cap, sends,
|
|
555
|
-
* sources), and the signature (who, when, hash). Derived purely from the
|
|
556
|
-
* flow's own signed files (`readFlow`) — fwdloop always has exactly one
|
|
557
|
-
* signed `declaration.json` + `signature.json` per flow, so there is no
|
|
558
|
-
* multi-source provenance chain to resolve (unlike bareloop's `getRunJob` —
|
|
559
|
-
* DROPPED per the fit-check). `runId` is only used to confirm the run
|
|
560
|
-
* exists at all; `null` when it doesn't (404).
|
|
561
|
-
* @param {{root: string, flow: string, runId: string, catalogue: any}} opts
|
|
562
|
-
* @returns {any|null}
|
|
563
|
-
*/
|
|
564
|
-
/**
|
|
565
|
-
* hamr's 2026-09-27 exit-check review #5: one plain-words sentence for a
|
|
566
|
-
* declared step's own close rule — the Job tab's "Success" field. Derived
|
|
567
|
-
* STRICTLY from `step.close` (and, for the "your accept" wording, whether
|
|
568
|
-
* this step is the one line `arbiter.asks[]` itself binds to) — never a
|
|
569
|
-
* fabricated cite/shape value:
|
|
570
|
-
* - `hitl`: "human check", or "human check (your accept)" when this step's
|
|
571
|
-
* own `fromLine` is a signed ask line (the ask step itself — the one a
|
|
572
|
-
* human pauses a run on, distinct from an ordinary hitl pass-through
|
|
573
|
-
* step with no ask binding).
|
|
574
|
-
* - `softgreen`: "shape: N headings (a / b / c)" when `close.shape.sections`
|
|
575
|
-
* is signed, "max W words" appended when `close.shape.maxWords` is
|
|
576
|
-
* signed, "blocks of L lines" / "must carry: a, b" for the invoice-block
|
|
577
|
-
* shape keys (`linesPerInvoice`/`mustCarry`) — every signed shape key
|
|
578
|
-
* shown, nothing invented; "shape (no shape rules signed)" when a
|
|
579
|
-
* softgreen step signs no `close.shape` at all (declaration.js allows
|
|
580
|
-
* this — an empty/absent shape is not itself a red).
|
|
581
|
-
* - `green`: "cited" — `CLOSE_ALLOWED` (`src/declaration.js`) never lets a
|
|
582
|
-
* step declare WHAT it cites ahead of time (that's the drafted
|
|
583
|
-
* artifact's own per-run field data, not signed prose), so there is
|
|
584
|
-
* never anything honest to append here.
|
|
585
|
-
* - anything else: the raw class name, named as unknown, never silently
|
|
586
|
-
* dropped or guessed into one of the three above; no class at all names
|
|
587
|
-
* that plainly too.
|
|
588
|
-
* @param {{close?: {class?: string, shape?: any}, fromLine?: number|null}} step one `declaration.steps` entry
|
|
589
|
-
* @param {Array<{line:number}>} arbiterAsks `arbiter.asks`, for the "your accept" check
|
|
590
|
-
* @returns {string}
|
|
591
|
-
*/
|
|
592
|
-
export function deriveStepSuccessText(step: {
|
|
593
|
-
close?: {
|
|
594
|
-
class?: string;
|
|
595
|
-
shape?: any;
|
|
596
|
-
};
|
|
597
|
-
fromLine?: number | null;
|
|
598
|
-
}, arbiterAsks: Array<{
|
|
599
|
-
line: number;
|
|
600
|
-
}>): string;
|
|
601
553
|
/**
|
|
602
554
|
* `GET /api/runs/:flow/:runId/job` — the Job tab (hamr's 2026-09-27
|
|
603
555
|
* exit-check review #5: bareloop-style one-field-per-piece layout,
|
|
@@ -606,8 +558,7 @@ export function deriveStepSuccessText(step: {
|
|
|
606
558
|
* signature.json/prose lines — nothing invented; a piece the books can't
|
|
607
559
|
* name carries its own why, never a blank or a guess. Field order (server
|
|
608
560
|
* order matches the page's own render order): prose, asks, model, cap
|
|
609
|
-
* (+redo cap), sources, sends, guardrails,
|
|
610
|
-
* `deriveStepSuccessText`), signature.
|
|
561
|
+
* (+redo cap), sources, sends, guardrails, plan (one row per step, amendment 34), signature.
|
|
611
562
|
* @param {{root: string, flow: string, runId: string, catalogue: any}} opts
|
|
612
563
|
* @returns {any|null}
|
|
613
564
|
*/
|
package/types/runner.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
/** The panel's one write of a stop request. `'exists'` = already asked, nothing more to do. @param {string} runDir */
|
|
2
2
|
export function requestStop(runDir: string): "written" | "exists";
|
|
3
|
-
/**
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* The ONE reader of the stop request: `{at}` (when it was asked) or `null` when none is pending. Amendment 16 C11 / amendment 17 2A: a
|
|
5
|
+
* time that is not a real date (a non-date string, a number, a missing or empty time, a torn file) is treated as made "now" (`now`,
|
|
6
|
+
* when given), one rule for all, so the stop completes with every record and the ask is never lost. Without `now` (a pending check)
|
|
7
|
+
* such a request reads `{at:null}`.
|
|
8
|
+
* @param {string} runDir @param {() => string} [now]
|
|
9
|
+
*/
|
|
10
|
+
export function readStopRequest(runDir: string, now?: () => string): {
|
|
5
11
|
at: string | null;
|
|
6
12
|
} | null;
|
|
7
13
|
/** Is a stop pending for this run? (read-only) @param {string} runDir */
|
|
@@ -240,8 +246,9 @@ export function makeParkingAskStep(): (opts?: any) => Promise<{
|
|
|
240
246
|
* @param {string} opts.businessDate
|
|
241
247
|
* @param {number} [opts.ceilingUsd]
|
|
242
248
|
* @param {() => number} [opts.nowMs] - F45 finding 3; see `runFlow`'s own.
|
|
249
|
+
* @param {(newRunDir:string) => void} [opts.onRerunStart] - amendment 16 C2: called with the new run's folder just before a `rerun` starts it.
|
|
243
250
|
*/
|
|
244
|
-
export function resumeRun({ root, name, runId, catalogue, modelStep, sendStep, primitives, primitiveReds, clock, businessDate, ceilingUsd, nowMs, }: {
|
|
251
|
+
export function resumeRun({ root, name, runId, catalogue, modelStep, sendStep, primitives, primitiveReds, clock, businessDate, ceilingUsd, nowMs, onRerunStart, }: {
|
|
245
252
|
root: string;
|
|
246
253
|
name: string;
|
|
247
254
|
runId: string;
|
|
@@ -260,6 +267,7 @@ export function resumeRun({ root, name, runId, catalogue, modelStep, sendStep, p
|
|
|
260
267
|
businessDate: string;
|
|
261
268
|
ceilingUsd?: number | undefined;
|
|
262
269
|
nowMs?: (() => number) | undefined;
|
|
270
|
+
onRerunStart?: ((newRunDir: string) => void) | undefined;
|
|
263
271
|
}): Promise<any>;
|
|
264
272
|
/**
|
|
265
273
|
* What a run has spent so far, from its own books (audit.jsonl is the source of truth): the sum of every priced row (a cap-halt
|