fwdloop 0.38.0 → 0.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/README.md +6 -9
  2. package/bin/fwdloop +21 -19
  3. package/package.json +1 -1
  4. package/src/ask.js +70 -148
  5. package/src/audit-fold.js +6 -5
  6. package/src/auditchecks.js +6 -4
  7. package/src/authoring.js +32 -60
  8. package/src/blockasks.js +2 -1
  9. package/src/blockassemble.js +15 -3
  10. package/src/blockdraft.js +2 -2
  11. package/src/blockpick.js +42 -16
  12. package/src/books.js +237 -12
  13. package/src/checkblock.js +24 -44
  14. package/src/checklistsign.js +25 -3
  15. package/src/checklook.js +3 -1
  16. package/src/checkpick.js +6 -77
  17. package/src/cited-source.js +4 -4
  18. package/src/citedcheck.js +6 -11
  19. package/src/citedwords.js +9 -8
  20. package/src/closers.js +9 -6
  21. package/src/declaration.js +14 -49
  22. package/src/diary.js +23 -1
  23. package/src/draft-steps.js +11 -1
  24. package/src/drafter.js +18 -12
  25. package/src/draftfiles.js +127 -0
  26. package/src/draftspend.js +165 -17
  27. package/src/flow.js +42 -87
  28. package/src/flowmodel.js +1 -1
  29. package/src/index.js +3 -2
  30. package/src/inside.js +106 -0
  31. package/src/jsonl-append.js +33 -1
  32. package/src/learn.js +1 -1
  33. package/src/learnstore.js +20 -22
  34. package/src/line-checks.js +1 -1
  35. package/src/liveness.js +3 -0
  36. package/src/mcp-use.js +8 -9
  37. package/src/memo.js +13 -16
  38. package/src/model-step.js +2 -2
  39. package/src/page-words.js +8 -0
  40. package/src/pageask.js +8 -3
  41. package/src/pagebits.js +8 -1
  42. package/src/pagedropwords.js +1 -1
  43. package/src/pagerules.js +6 -3
  44. package/src/panel/author.js +99 -75
  45. package/src/panel/authorcard.js +21 -8
  46. package/src/panel/authorflows.js +3 -3
  47. package/src/panel/authorresume.js +3 -3
  48. package/src/panel/authorstart.js +15 -16
  49. package/src/panel/authortrigger.js +43 -70
  50. package/src/panel/data.js +186 -188
  51. package/src/panel/index.html +139 -115
  52. package/src/panel/jobgrid.js +3 -7
  53. package/src/panel/result.js +7 -10
  54. package/src/panel/resume.js +4 -3
  55. package/src/panel/scheduler.js +9 -9
  56. package/src/panel/server.js +8 -4
  57. package/src/panel/spawn.js +22 -11
  58. package/src/panel/tickets.js +2 -2
  59. package/src/pickrecord.js +51 -31
  60. package/src/placerule.js +3 -4
  61. package/src/plain-checks.js +1 -1
  62. package/src/planrebuild.js +19 -19
  63. package/src/primitives.js +1 -1
  64. package/src/provider.js +1 -1
  65. package/src/reasons.js +25 -0
  66. package/src/runfile.js +26 -2
  67. package/src/runner.js +57 -105
  68. package/src/runvalues.js +47 -24
  69. package/src/schedule-choices.js +41 -0
  70. package/src/schedule-shape.js +39 -0
  71. package/src/schedule.js +9 -8
  72. package/src/setup.js +20 -36
  73. package/src/shaperows.js +2 -2
  74. package/src/sheetblock.js +2 -2
  75. package/src/sheetbuild.js +5 -5
  76. package/src/sheetrun.js +4 -5
  77. package/src/summary-words.js +2 -1
  78. package/src/thinking.js +5 -2
  79. package/src/ticketrows.js +7 -28
  80. package/src/trigger-clock.js +9 -23
  81. package/src/trigger-files.js +30 -22
  82. package/src/trigger-tickets.js +15 -14
  83. package/src/try-checks.js +2 -1
  84. package/src/types.js +2 -0
  85. package/types/ask.d.ts +25 -20
  86. package/types/authoring.d.ts +7 -42
  87. package/types/blockpick.d.ts +1 -1
  88. package/types/books.d.ts +380 -4
  89. package/types/checkblock.d.ts +1 -23
  90. package/types/checklist.d.ts +3 -3
  91. package/types/checklistsign.d.ts +7 -0
  92. package/types/checkpick.d.ts +0 -21
  93. package/types/citedwords.d.ts +7 -4
  94. package/types/closers.d.ts +1 -0
  95. package/types/declaration.d.ts +4 -14
  96. package/types/diary.d.ts +14 -1
  97. package/types/draft-steps.d.ts +7 -0
  98. package/types/drafter.d.ts +1 -1
  99. package/types/draftfiles.d.ts +89 -0
  100. package/types/draftspend.d.ts +74 -0
  101. package/types/flow.d.ts +32 -54
  102. package/types/index.d.ts +3 -3
  103. package/types/inside.d.ts +71 -0
  104. package/types/jsonl-append.d.ts +20 -0
  105. package/types/learnstore.d.ts +0 -2
  106. package/types/liveness.d.ts +1 -0
  107. package/types/page-words.d.ts +6 -0
  108. package/types/pageask.d.ts +2 -0
  109. package/types/pagebits.d.ts +3 -0
  110. package/types/pagerules.d.ts +1 -0
  111. package/types/panel/author.d.ts +7 -3
  112. package/types/panel/authorcard.d.ts +0 -6
  113. package/types/panel/authorflows.d.ts +4 -4
  114. package/types/panel/authortrigger.d.ts +16 -2
  115. package/types/panel/data.d.ts +50 -16
  116. package/types/panel/spawn.d.ts +18 -2
  117. package/types/pickrecord.d.ts +29 -0
  118. package/types/reasons.d.ts +23 -0
  119. package/types/runfile.d.ts +14 -0
  120. package/types/runner.d.ts +6 -38
  121. package/types/runvalues.d.ts +17 -2
  122. package/types/schedule-choices.d.ts +9 -0
  123. package/types/schedule-shape.d.ts +15 -0
  124. package/types/sheetbuild.d.ts +1 -1
  125. package/types/thinking.d.ts +1 -0
  126. package/types/ticketrows.d.ts +0 -9
  127. package/types/trigger-clock.d.ts +3 -2
  128. package/types/trigger-files.d.ts +15 -4
  129. package/types/types.d.ts +8 -0
@@ -40,17 +40,16 @@ export function resolveFlowDir(root: string, flowName: string): {
40
40
  */
41
41
  export function hasConsumedAnswer(runDir: string, askId: string | null): boolean;
42
42
  /**
43
- * M4b piece 2: a SAVED, not-yet-consumed answer — `answer.json` (what
44
- * `answerAsk` writes; the resume consumes it by renaming it away, F44). Read
45
- * through `readFileInside` (a symlinked file is "none"). `null` when there is
46
- * none or it is unreadable/unparseable or names no askId.
43
+ * M4b piece 2: a SAVED, not-yet-consumed answer, as the panel shows it: `readSavedAnswer` (src/books.js, the one reader) read for an answer that names an ask.
44
+ * `null` when there is none or it is unreadable, unparseable or names no askId. `broken` is the reader's own field (M20 am3b item 1).
47
45
  * @param {string} runDir
48
- * @returns {{askId: string, decision: string|null, answeredAt: string|null}|null}
46
+ * @returns {{askId: string, decision: string|null, answeredAt: string|null, broken: boolean}|null}
49
47
  */
50
- export function readSavedAnswer(runDir: string): {
48
+ export function savedAnswerOf(runDir: string): {
51
49
  askId: string;
52
50
  decision: string | null;
53
51
  answeredAt: string | null;
52
+ broken: boolean;
54
53
  } | null;
55
54
  /**
56
55
  * M4b amendment 1 scope 2: the ONE derivation of "answer saved, resume not
@@ -62,7 +61,7 @@ export function readSavedAnswer(runDir: string): {
62
61
  * answer for that ask that was NOT saved in time, once the deadline has passed, is not a resumable answer: it reads
63
62
  * as none, so the ask is expired and offers the reopen (M4c-fix amendment 1 (b)). One with no readable time, before
64
63
  * the deadline, reads `broken` (amendment 1 (a)).
65
- * @param {{savedAnswer: {askId:string, decision:string|null, answeredAt?:string|null}|null, attempt: any, ask?: any}} ctx
64
+ * @param {{savedAnswer: {askId:string, decision:string|null, answeredAt?:string|null, broken?: boolean}|null, attempt: any, ask?: any}} ctx
66
65
  * @returns {{state: 'starting'|'not-started'|'broken'|'took-over', askId: string|null, tries: number|null, maxTries: number|null, reason: string|null, label: string}|null}
67
66
  */
68
67
  export function deriveResumeState({ savedAnswer: savedOnDisk, attempt, ask }: {
@@ -70,6 +69,7 @@ export function deriveResumeState({ savedAnswer: savedOnDisk, attempt, ask }: {
70
69
  askId: string;
71
70
  decision: string | null;
72
71
  answeredAt?: string | null;
72
+ broken?: boolean;
73
73
  } | null;
74
74
  attempt: any;
75
75
  ask?: any;
@@ -86,10 +86,12 @@ export function deriveResumeState({ savedAnswer: savedOnDisk, attempt, ask }: {
86
86
  * opens with the word ("stuck — …") or is the word itself ("passed") loses that repeat, so it is never said twice.
87
87
  * `noWord`: a run the human ended on purpose with rerun wears `[✗]` but is never called "failed" (M4b amendment 3),
88
88
  * so it shows its plain line alone.
89
- * @param {string} glyph a `computeGlyph` sign @param {string} label its plain line @param {boolean} [noWord]
89
+ * @param {string} glyph a `computeGlyph` sign @param {string} label its plain line @param {boolean} [noWord] @param {{outcome: string|null|undefined}|null} [ending] the run's end row outcome
90
90
  * @returns {{word: string|null, line: string|null}}
91
91
  */
92
- export function signParts(glyph: string, label: string, noWord?: boolean): {
92
+ export function signParts(glyph: string, label: string, noWord?: boolean, ending?: {
93
+ outcome: string | null | undefined;
94
+ } | null): {
93
95
  word: string | null;
94
96
  line: string | null;
95
97
  };
@@ -316,7 +318,22 @@ export function deriveAuditToolsPhrase(row: any): string | null;
316
318
  * @returns {string|null}
317
319
  */
318
320
  export function deriveAuditAtWhy(row: any): string | null;
319
- export function isBlockedVerdict(verdict: any): boolean;
321
+ /**
322
+ * hamr's 2026-09-27 exit-check review #2: the Audit tab's Blocked filter —
323
+ * ONE server-side function naming exactly which verdicts count as "did not
324
+ * pass", derived strictly from a row's own `verdict` string (never a second,
325
+ * client-side guess). Blocked: `not-done`, `red` (a mechanical close miss OR
326
+ * a human's own redo on a hitl step — both are "this attempt did not
327
+ * pass"), `refused` (a blank redo/rerun reason), `ask-timeout` and
328
+ * `ask-expired` (the human never answered in time), `cap-halt`,
329
+ * `provider-red`, `pricing-red`, `close-casualty` (every other halt shape
330
+ * `src/runner.js` records). NOT blocked: `green`/`hitl` (passed), `paused`
331
+ * (still open — waiting, not yet failed), `stale-answer-ignored` (a book
332
+ * hygiene note about a late answer, not an attempt outcome).
333
+ * @param {string|null|undefined} verdict
334
+ * @returns {boolean}
335
+ */
336
+ export function isBlockedVerdict(verdict: string | null | undefined): boolean;
320
337
  /**
321
338
  * One mark per try, in try order — mirrors `computeTryCount`'s own pairing
322
339
  * exactly (a `hitl` step's `paused` row plus its next resolving row is ONE
@@ -326,11 +343,11 @@ export function isBlockedVerdict(verdict: any): boolean;
326
343
  * open, not resolved).
327
344
  * @param {string|null} closeClass
328
345
  * @param {Array<{verdict:string}>} rows one step's own audit rows, book order
329
- * @returns {Array<'✓'|'✗'|'·'>}
346
+ * @returns {Array<'✓'|'✗'|'·'|'■'>}
330
347
  */
331
348
  export function deriveStepTryMarks(closeClass: string | null, rows: Array<{
332
349
  verdict: string;
333
- }>): Array<"\u2713" | "\u2717" | "\u00B7">;
350
+ }>): Array<"\u2713" | "\u2717" | "\u00B7" | "\u25A0">;
334
351
  /**
335
352
  * A step group's own state word for the Audit tab's collapsed header —
336
353
  * the ONE decider of a step's state: the Run tab's map and cards read it too
@@ -341,12 +358,22 @@ export function deriveStepTryMarks(closeClass: string | null, rows: Array<{
341
358
  * the human asked), `stopped` (the last attempt failed for any other reason). A group only
342
359
  * ever exists for a step with at least one row, so `pending` never appears
343
360
  * here (unlike the Run tab's map, which also covers never-attempted steps).
344
- * @param {Array<{verdict:string}>} rows one step's own audit rows, book order
345
- * @returns {'done'|'waiting'|'stopped'|'user-stopped'}
361
+ * @param {Array<{verdict:string, class?: string|null, gap?: string|null}>} rows one step's own audit rows, book order
362
+ * `noted` (M20 am9a: the last row has no sign from the owner and is none of the above, a human redo or a reopen; the heading wears the owner's word, `groupStateText`, never "failed").
363
+ * `capped` (M20 am9 item 2: the step's own last row is a `cap-halt`; the word is the table's, `endingWord('cap-halt')`).
364
+ * @returns {string} `done`, `waiting`, `stopped`, `user-stopped`, `noted`, or the table's word for a cap-halt
346
365
  */
347
366
  export function deriveStepGroupState(rows: Array<{
348
367
  verdict: string;
349
- }>): "done" | "waiting" | "stopped" | "user-stopped";
368
+ class?: string | null;
369
+ gap?: string | null;
370
+ }>): string;
371
+ /** M20 am9a: the heading's own word for a `noted` group: the owner's word for its last row (`redo by you: <gap>`, `reopened by you`); `null` for any other state @param {Array<{verdict:string, class?: string|null, gap?: string|null}>} rows */
372
+ export function groupStateText(rows: Array<{
373
+ verdict: string;
374
+ class?: string | null;
375
+ gap?: string | null;
376
+ }>): string | null;
350
377
  /**
351
378
  * hamr's 2026-09-27 exit-check review #1: the Audit tab's grouped-by-step
352
379
  * header pieces, computed HERE (server-side) so `src/panel/index.html` only
@@ -582,6 +609,12 @@ export function listScheduled({ root, triggerRead, now, home, rows, }: {
582
609
  words: string;
583
610
  runId: string | null;
584
611
  }[];
612
+ /**
613
+ * M20 am1 item 8: the Run tab's NOW row, "AI working · M:SS", only while the run is live (`[▶]`, no end row) and a model step's try is running: the newest
614
+ * `try-start` row has no audit row written at or after it. Anything else is null (nothing is made up between tries). The time moves in 30 s steps (`stepped`).
615
+ * @param {any} ctx `loadRunContext`'s result @param {string} glyph `computeGlyph`'s sign @param {number} nowMs @returns {string|null}
616
+ */
617
+ export function nowOf(ctx: any, glyph: string, nowMs: number): string | null;
585
618
  /**
586
619
  * `GET /api/runs/:flow/:runId` — the Run tab (M4a scope item 2): the step
587
620
  * map from `declaration.steps`, step cards -> attempts from `audit.jsonl`
@@ -787,7 +820,7 @@ export function getJobGrid({ root, flow, catalogue, now, }: {
787
820
  spentUsd: number | null;
788
821
  spentComplete: boolean;
789
822
  };
790
- flowType: "tickets" | "mcp" | "plain" | null;
823
+ flowType: "mcp" | "plain" | "tickets" | null;
791
824
  } | null;
792
825
  /**
793
826
  * `GET /api/runs/:flow/:runId/download?i=<n>` (M10 am4): one saved file, or why not.
@@ -927,6 +960,7 @@ export function inboxOpenCount(rows: any[]): number;
927
960
  /** What the `resume` field says when the panel has no attempt record for a run
928
961
  * (it restarted since the answer was saved) — said so, never blank. */
929
962
  export const RESUME_REASON_UNKNOWN: "reason unknown: the panel restarted, so it has no record of the resume attempt";
963
+ export function answerPickedUp(resume: any, askId: unknown): boolean;
930
964
  export const WAITING_LABEL: "waiting on you (parked, unanswered)";
931
965
  export const STUCK_LABEL: "stuck \u2014 your answer is saved; the run stopped before using it";
932
966
  export const STUCK_LOCK_LABEL: "stuck \u2014 an old resume lock is in the way";
@@ -14,8 +14,24 @@ export function spawnDetached({ bin, argv, env, logPath, }: {
14
14
  * @param {string} dir @param {import('node:child_process').ChildProcess} child
15
15
  */
16
16
  export function writePidFile(dir: string, child: import("node:child_process").ChildProcess): void;
17
- /** One JSON file of a panel folder through the one safe gateway; null when missing, unreadable or not an object. @param {string} dir @param {string} rel */
18
- export function readJsonFile(dir: string, rel: string): any;
17
+ /**
18
+ * M20 am3 item 8: the ONE owner of "is the draft/start child alive": the child recorded in `<dir>/pid.json` (null when none is
19
+ * recorded) and whether it is ours and running now: true / false, or null when it cannot be told (no /proc). `childRunning` and the
20
+ * draft door's abandon both ask it.
21
+ * @param {string} dir
22
+ * @returns {{pid: number, procStart: string|null, startedAt: unknown, alive: boolean|null}|null}
23
+ */
24
+ export function childState(dir: string): {
25
+ pid: number;
26
+ procStart: string | null;
27
+ startedAt: unknown;
28
+ alive: boolean | null;
29
+ } | null;
30
+ /** The same question again for a child `childState` returned (the abandon loop asks it after each signal). @param {{pid: number, procStart: string|null}} child @returns {boolean|null} */
31
+ export function childAlive(child: {
32
+ pid: number;
33
+ procStart: string | null;
34
+ }): boolean | null;
19
35
  /**
20
36
  * Is the child recorded in `<dir>/pid.json` running? true / false, never null: no pid.json = nothing known to be running =
21
37
  * false; a liveness that cannot be told (no /proc) reads as running only while pid.json is fresh (M4c's rule).
@@ -132,6 +132,35 @@ export function columnsOnLines(entries: {
132
132
  word: string;
133
133
  column: string;
134
134
  }[];
135
+ /**
136
+ * M20 am3e item 19: the record's `kept` list, the ONE reader (the plan card, the setup row and the sign-time card check all ask it). `kept` is the list as written, or null
137
+ * when there is none to read (no file, refused by the gateway, not a JSON object, no list). `torn` tells an unreadable record from an empty one: the file was read and
138
+ * is not JSON. The sign-time card check skips on a torn record; the other two read it as no list.
139
+ * @param {string} dir the folder that holds the plan folder @param {string} [rel] `draft`, `draft-<n>` or `.` (the plan folder itself)
140
+ * @returns {{kept: any[]|null, torn: boolean}}
141
+ */
142
+ export function readKept(dir: string, rel?: string): {
143
+ kept: any[] | null;
144
+ torn: boolean;
145
+ };
146
+ /**
147
+ * M20 am4: the counts the person switched on with Add, from the plan's `rowChoices` (the entries `readRowChoices` gives, or the block's own `choicesRecord()`): a set of
148
+ * `<line>:min:<n>` / `<line>:max:<n>` strings, one per number of an Added `count.<min>-<max>` row, the line found by its words as the record ties it. The count check
149
+ * (src/citedwords.js `countReds`) reads a number in this set as said: the Add says it.
150
+ * @param {{lineWords: string, occurrence: number, tail: string, choice: string}[]|null|undefined} entries @param {{n: number, text: string}[]} lines @returns {Set<string>}
151
+ */
152
+ export function addedCountsOf(entries: {
153
+ lineWords: string;
154
+ occurrence: number;
155
+ tail: string;
156
+ choice: string;
157
+ }[] | null | undefined, lines: {
158
+ n: number;
159
+ text: string;
160
+ }[]): Set<string>;
161
+ /** M20 am8: the one list of a person's row choices on the plan card, and the one question "is this a legal Drop or Add choice" (the row-edit door, the record's reader and the check block ask it) */
162
+ export const ROW_CHOICES: readonly string[];
163
+ export function isRowChoice(choice: unknown): boolean;
135
164
  /** the record's file, inside a drafting folder only (never a run folder) */
136
165
  export const RECORD_FILE: "picks-record.json";
137
166
  /** the exact words a kept pick is marked with in the draft log, the Audit and the plan card (M10 am17 (6)) */
@@ -0,0 +1,23 @@
1
+ /** the plain reasons code gives, in one place (the card, the Job tab and the Audit read them from the row) */
2
+ export const REASON: Readonly<{
3
+ left: "You chose to leave it Not checked, so you judge it at Accept.";
4
+ nothingOnPage: "Your own words are on the line; the machine has no check for them, so you judge it at Accept.";
5
+ noRule: "No rule can check this, so you judge it at Accept.";
6
+ waitingPick: "waiting for your answer on the proposed check";
7
+ waitingReading: "waiting for your answer on the reading";
8
+ onePerLine: "this line finds facts, so it has no text to quote";
9
+ manyInputs: "the job has more than one input and code cannot pick which one the claims quote";
10
+ oneSidedTime: "a time limit the AI proposes must be a range, so you judge it at Accept.";
11
+ countNeedsFact: "a result count needs a fact to count; this line has none";
12
+ countNeedsSuggested: "a result count needs a fact to count; add the suggested fact on this line to count its results";
13
+ lookNoWords: "the page does not hold the words of the look's fact for this rule";
14
+ afterLast: "no more tries: Start over (rows are never changed by the AI after the last try)";
15
+ noPick: "No check was picked for it, so you judge it at Accept.";
16
+ itemCountByRule: "your rule on this line sets the item count";
17
+ negated: "it says what is not needed, so there is nothing to check";
18
+ dropped: "You dropped it.";
19
+ suggested: "Suggested: not in your job, so it is not checked unless you add it.";
20
+ sheetLine: "this line reads a sheet and its rules are checked by the sheet checks, so a row edit about it is not used";
21
+ sheetFacts: "this line reads a sheet, so it is checked by its sheet checks and not by page facts";
22
+ columnRule: "this rule only names a column; the agent's checks on this line use it";
23
+ }>;
@@ -10,6 +10,11 @@ export function readRunRecord(runDir: string | null): {
10
10
  code: "missing" | "unreadable" | "invalid";
11
11
  red: string;
12
12
  };
13
+ /**
14
+ * M20 am3 item 12: the ONE test for "this run began as a rerun": the human's words its `run.json` carries (`rerun.decision` is `rerun` and
15
+ * `rerun.words` is a string), or null. The Audit's first step and the carry memo ask it. @param {string|null} runDir @returns {string|null}
16
+ */
17
+ export function readRerunWords(runDir: string | null): string | null;
13
18
  /**
14
19
  * M4d am26: the run's OWN record of the box (`thinking` in `<run>/run.json`) and nothing else: `true`/`false`, or `null` when the run has none (a run from before am25).
15
20
  * An unreadable record is box off, as `readJobThinking` has always read it. @param {string|null} runDir @returns {boolean|null}
@@ -29,6 +34,12 @@ export function readRunInputs(runDir: string | null): {
29
34
  code: "missing" | "unreadable" | "invalid";
30
35
  red: string;
31
36
  };
37
+ /**
38
+ * M20 am3e item 16: the place-rule rows the run recorded at its start (`placeRules.rows`), or null when there are none to read (no record, a refused or torn file,
39
+ * no `placeRules` section, rows that are not a list). Each caller maps null to its own none: the carry-forward reads it as no rows, a resume refuses by name.
40
+ * @param {string|null} runDir @returns {any[]|null}
41
+ */
42
+ export function readPlaceRows(runDir: string | null): any[] | null;
32
43
  /**
33
44
  * M8b item 1: the ONE writer of `run.json`, called once when a fresh run has frozen its inputs (`runFlow`); never over an existing record. `model` is the pick
34
45
  * the run started on (M4d am33; null = the section is left out), `thinking` the job's "Thinking on" box as it was at the start (M4d am25: written for every fresh
@@ -53,3 +64,6 @@ export function writeRunStart(runDir: string, { model, thinking, inputs, rerun,
53
64
  }): void;
54
65
  /** the file's name in the run's folder */
55
66
  export const RUN_FILE: "run.json";
67
+ /** the folder inside a run that holds the frozen copy of each input */
68
+ export const INPUTS_DIR: "inputs";
69
+ export function frozenRel(name: string): string;
package/types/runner.d.ts CHANGED
@@ -12,23 +12,6 @@ export function readStopRequest(runDir: string, now?: () => string): {
12
12
  } | null;
13
13
  /** Is a stop pending for this run? (read-only) @param {string} runDir */
14
14
  export function stopPending(runDir: string): boolean;
15
- /** The one reader of halt.json: `{ok:true, halt}`, `{ok:false, missing:true}` (not resumable), or `{ok:false, red}`. @param {string} runDir */
16
- export function readHaltRecord(runDir: string): {
17
- ok: boolean;
18
- missing: boolean;
19
- red?: undefined;
20
- halt?: undefined;
21
- } | {
22
- ok: boolean;
23
- red: string;
24
- missing?: undefined;
25
- halt?: undefined;
26
- } | {
27
- ok: boolean;
28
- halt: any;
29
- missing?: undefined;
30
- red?: undefined;
31
- };
32
15
  /** @param {{goal:string, primitives?:string[], reads?:Record<string,any>, gap?:string|null, hints?:string|null, memo?:string|null}} opts `hints` (M8 am7): the earlier runs' block, text only, for a retry / redo / rerun try; `memo` (M14): what happened so far in this run, text only, every try */
33
16
  export function buildExecutorContext(opts: {
34
17
  goal: string;
@@ -400,8 +383,7 @@ export function runFlow({ root, name, runId, sources, catalogue, modelStep, askS
400
383
  nowMs?: (() => number) | undefined;
401
384
  }): Promise<any>;
402
385
  /** An ask step that never waits — it immediately tells the fold to park.
403
- * The counterpart to `makeFileAskStep`'s in-process poll (M2 scope item 6);
404
- * a caller wanting park-and-exit behaviour from a FRESH `runFlow` call
386
+ * A caller wanting park-and-exit behaviour from a FRESH `runFlow` call
405
387
  * passes this (or an equivalent) as `askStep`.
406
388
  * @returns {(opts?: any) => Promise<{decision: 'park'}>} */
407
389
  export function makeParkingAskStep(): (opts?: any) => Promise<{
@@ -538,23 +520,6 @@ export function stopParkedRun({ root, name, runId, catalogue, clock, nowMs, }: {
538
520
  clock?: (() => string) | undefined;
539
521
  nowMs?: (() => number) | undefined;
540
522
  }): Promise<any>;
541
- /**
542
- * `writeLog`'s own sibling reader (M4a piece 2, docs/wiki/the-module-
543
- * ladder.md M4a scope item 2: "one reader per book") — `null` when the run
544
- * hasn't reached an exit path yet (still running, or parked before any
545
- * halt/complete), or the file is present but not valid JSON (a torn write),
546
- * never a thrown error.
547
- * @param {string} runDir
548
- * @returns {any|null}
549
- */
550
- export function readLog(runDir: string): any | null;
551
- /**
552
- * `state.json`'s own sibling reader (same rule as {@link readLog}) — `null`
553
- * when the run has never parked, or the file is present but not valid JSON.
554
- * @param {string} runDir
555
- * @returns {any|null}
556
- */
557
- export function readRunState(runDir: string): any | null;
558
523
  /**
559
524
  * `ask.json`'s own sibling reader (same rule as {@link readLog}) — the
560
525
  * parking ask protocol's own writer lives in {@link runAskSlot} above.
@@ -583,9 +548,12 @@ export const MAX_ATTEMPTS: 4;
583
548
  * a few hundredths of a cent and up), so nothing a real tamper produces can hide inside it. */
584
549
  export const SPEND_TOLERANCE_USD: 1e-9;
585
550
  export const STOP_FILE: "stop.request";
586
- export const HALT_FILE: "halt.json";
551
+ export { HALT_FILE };
587
552
  /** where a failure of learnings work that must not stop the run is recorded (one appended row, in the run's own folder): the run-end tally (`recordRunNotes`) and the take of the draft's learnings record (`takeLearningsRecord`, in runFlow). The run itself is unaffected */
588
553
  export const LEARN_ERROR_FILE: "learn-error.jsonl";
554
+ export function endsRun(r: {
555
+ type?: unknown;
556
+ }): boolean;
589
557
  import { readTicketMcp } from './ticket-mcp.js';
590
558
  /**
591
559
  * Run one step to green (or hitl pass-through), looping under strikes and
@@ -667,4 +635,4 @@ declare function runStepTries({ step, primitivesMap, readsMap, businessDate, mod
667
635
  step?: string | null;
668
636
  };
669
637
  }>;
670
- export {};
638
+ import { HALT_FILE } from './books.js';
@@ -57,10 +57,26 @@ export function writeRunValues(runDir: string, record: {
57
57
  ok: false;
58
58
  red: string;
59
59
  };
60
+ /**
61
+ * Every signed values file in the run folder, oldest version first, each read by `readValuesFile` (the Audit lists them; a refused one
62
+ * shows as refused).
63
+ * @param {string} runDir
64
+ * @returns {Array<{file: string, version: number} & ({ok: true, record: any} | {ok: false, red: string})>}
65
+ */
66
+ export function listRunValues(runDir: string): Array<{
67
+ file: string;
68
+ version: number;
69
+ } & ({
70
+ ok: true;
71
+ record: any;
72
+ } | {
73
+ ok: false;
74
+ red: string;
75
+ })>;
60
76
  /**
61
77
  * The ONE decision "which signed version does this run use": the highest version file in the run folder.
62
78
  * `{ok:true, none:true}` = the flow's own values; `{ok:true, version, record}`; `{ok:false, red}` = a file that cannot be trusted
63
- * (unreadable, not JSON, wrong shape, a hash that does not match its fields, a name that disagrees with its version).
79
+ * (see `readValuesFile`).
64
80
  * @param {string} runDir
65
81
  * @returns {{ok: true, none: true} | {ok: true, none?: false, version: number, record: any} | {ok: false, red: string}}
66
82
  */
@@ -98,5 +114,4 @@ export function applyRunValues(arbiter: any, flow: string, flowSignatureHash: st
98
114
  * @param {string} runDir @returns {boolean} true when the file was removed
99
115
  */
100
116
  export function dropUnstartedValues(runDir: string): boolean;
101
- export const VALUES_FILE_RE: RegExp;
102
117
  export function valuesFileName(version: number): string;
@@ -0,0 +1,9 @@
1
+ /** the whole list as the page takes it: per flow type, `{kind, clock, file, label, newCardLabel}` (clock, file: the one answers of isClockKind and isFileKind) @returns {Record<string, {kind: string, clock: boolean, file: boolean, label: string, newCardLabel: string}[]>} */
2
+ export function scheduleChoices(): Record<string, {
3
+ kind: string;
4
+ clock: boolean;
5
+ file: boolean;
6
+ label: string;
7
+ newCardLabel: string;
8
+ }[]>;
9
+ export function scheduleKindsOf(flowType: unknown): string[];
@@ -0,0 +1,15 @@
1
+ /** @typedef {import('./trigger-line.js').Trigger} Trigger */
2
+ /**
3
+ * The trigger a body asks for, checked as data: null (By hand) or exactly one of the five shapes, the role one of the job's inputs, a full
4
+ * path. Returns the typed trigger or the sentence that says what to fix.
5
+ * @param {unknown} t @param {string[]} roles
6
+ * @returns {{ok: true, trigger: Trigger|null} | {ok: false, say: string}}
7
+ */
8
+ export function shapeOf(t: unknown, roles: string[]): {
9
+ ok: true;
10
+ trigger: Trigger | null;
11
+ } | {
12
+ ok: false;
13
+ say: string;
14
+ };
15
+ export type Trigger = import("./trigger-line.js").Trigger;
@@ -39,7 +39,7 @@ export function buildSheetLine({ line, tables, suggestions }: {
39
39
  * then Not checked with the no-pick sentence, never silently nothing). A suggestion that names no sheet line, or is not an object, is refused and listed with its helper.
40
40
  * @param {{lines: {n: number, text?: string, rules?: string[], guardrail?: string, rule?: string}[], tables: Record<string, {header: string[], rows: any[]}>, suggestions: any[]}} o
41
41
  * @returns {Promise<{built: Record<number, Awaited<ReturnType<typeof buildSheetLine>>>, checks: any[], notChecked: Record<string, string>, refused: {line: number|null, helper: string, why: string}[]}>}
42
- * `notChecked`: `line N: "rule"` -> the refusal that named it (or `NO_VALUE_WHY`), for each rule of a sheet line that no check holds
42
+ * `notChecked`: `line N: "rule"` -> the refusal that named it (or `REASON.noPick`), for each rule of a sheet line that no check holds
43
43
  */
44
44
  export function buildSheetChecks({ lines, tables, suggestions }: {
45
45
  lines: {
@@ -63,5 +63,6 @@ export function stepHintsWanted({ attempt, rerunReason }: {
63
63
  }): boolean;
64
64
  /** The sentence under a greyed "Thinking on" box (amendment 7 item 2). */
65
65
  export const THINKING_FIXED_SAY: "can't change this for this model";
66
+ export function isThinkingMode(mode: unknown): boolean;
66
67
  /** The note beside the Chat "Thinking on" box, before any draft, for a model bareagent has not checked (M4d am11 item 2). */
67
68
  export const THINKING_UNVERIFIED_SAY: "thinking off (not verified for this model)";
@@ -49,13 +49,4 @@ export function withTicketRows({ declaration, lines }: {
49
49
  declaration: any;
50
50
  tickets: ReturnType<typeof ticketRowsOf>;
51
51
  };
52
- /**
53
- * The proof of a plan whose list has ticket rows (a plan with none is not examined): a built ticket row needs the declaration's field, and a field the declaration holds needs a built row for it.
54
- * @param {any} declaration @returns {string[]}
55
- */
56
- export function ticketListReds(declaration: any): string[];
57
- /** @type {readonly ('ticketFilter'|'ticketWatch')[]} */
58
- export const TICKET_FIELDS: readonly ("ticketFilter" | "ticketWatch")[];
59
- /** the Not-checked reason of a ticket rule no legal value was suggested for (the block's own noPick sentence is used by the caller's words) */
60
- export const NO_VALUE_WHY: "No check was picked for it, so you judge it at Accept.";
61
52
  export function ticketRowKey(line: number, rule: number, field: string): string;
@@ -20,8 +20,6 @@ export function due(schedule: Schedule, rows: ClockRow[], now: number): Due;
20
20
  * @returns {number}
21
21
  */
22
22
  export function nextSlot(schedule: Schedule, afterMs: number): number;
23
- /** @param {string} file @param {string} [sig] M9 am20: only the rows of that schedule signing (the one schedule ledger carries every signing's rows); absent = every row @returns {ClockRow[]} every row on disk that parses, oldest first; a missing file is no rows; a line a crash tore mid-append is skipped (`appendOnce` starts each append on a fresh line, so it never glues onto the next row). */
24
- export function readRows(file: string, sig?: string): ClockRow[];
25
23
  /** The trigger was set at `now`: no slot before this ever fires. M13 piece 5: `ticketN` = the highest ticket number the first green run read; a ticket schedule's first look baselines only tickets up to it. @param {string} file @param {number} now @param {string} [sig] @param {number} [ticketN] */
26
24
  export function armTrigger(file: string, now: number, sig?: string, ticketN?: number): void;
27
25
  /**
@@ -34,6 +32,9 @@ export function recordFire(file: string, d: Due, now: number, sig?: string): voi
34
32
  /** @typedef {{fire:boolean, catchUp:boolean, missed:number, slot?:number}} Due */
35
33
  /** A slot seen MORE than this after its set time is a catch-up (M9 am2 item 1). Exactly this late is on time. */
36
34
  export const GRACE_MS: 120000;
35
+ /** M20 am6: the one list of clock schedule kinds, and the one question "is this a clock kind" */
36
+ export const CLOCK_KINDS: readonly string[];
37
+ export function isClockKind(kind: unknown): boolean;
37
38
  export type Schedule = {
38
39
  kind: "daily" | "weekdays";
39
40
  hour: number;
@@ -1,7 +1,3 @@
1
- /** Every row that parses; a line a crash tore mid-append is skipped (it counts as not written). `appendSeen` starts each append on a fresh line, so a torn line can never glue onto the next row. @param {string} file @param {string} [sig] M9 am20: only the rows of that schedule signing (the one schedule ledger carries every signing's rows); absent = every row @returns {SeenRow[]} */
2
- export function readSeen(file: string, sig?: string): SeenRow[];
3
- /** The ONE appender: write-once by id within a signing (a second row with the same id is not written). Starts on a fresh line when the file does not end in a newline (a torn last line). @param {string} file @param {SeenRow} row @param {string} [sig] stamped on the row @returns {boolean} written */
4
- export function appendSeen(file: string, row: SeenRow, sig?: string): boolean;
5
1
  /** Arrived rows are never overwritten: the 2nd arrival of a sha (after a drop) gets its own id. @param {string} ledger @param {ToRun & {name?:string}} item @param {number} at the scheduler's clock, never the file's mtime @param {string} [sig] */
6
2
  export function recordArrived(ledger: string, item: ToRun & {
7
3
  name?: string;
@@ -46,6 +42,18 @@ export function recheck(item: {
46
42
  * @param {'new'|'updated'} mode @param {string} target
47
43
  */
48
44
  export function checkTarget(mode: "new" | "updated", target: string): void;
45
+ /**
46
+ * Is a file or folder trigger's target usable now? The words say what is wrong, without the closing "Nothing was changed."; null = fine. A file that does not exist yet may arrive
47
+ * (`checkTarget` allows it), but its folder must be there: a typo is caught now, not never.
48
+ * @param {{kind: 'file-updated', path: string}|{kind: 'new-file', folder: string}} trigger @returns {string|null}
49
+ */
50
+ export function fileTriggerWhy(trigger: {
51
+ kind: "file-updated";
52
+ path: string;
53
+ } | {
54
+ kind: "new-file";
55
+ folder: string;
56
+ }): string | null;
49
57
  /**
50
58
  * M9 am16: does a trigger on this target still watch this file? New: the file sits directly in the same (real) folder. Updated: it is the same (real) file. False when the target cannot be resolved.
51
59
  * @param {'new'|'updated'} mode @param {string} target @param {string} filePath a queued file's path as the watcher recorded it (a real path)
@@ -69,6 +77,9 @@ export function createFileTrigger({ mode, target, ledger, sig }: {
69
77
  /** @typedef {{id:string, kind:'baseline'|'arrived'|'ran'|'dropped', sha:string, name:string, size:number, at:number, path?:string, why?:string, of?:string, sig?:string}} SeenRow */
70
78
  /** @typedef {{path:string, sha:string, size:number}} ToRun */
71
79
  /** @typedef {{path:string, why:string}} Refused */
80
+ /** M20 am7: the one list of file schedule kinds, and the one question "is this a file kind" */
81
+ export const FILE_KINDS: readonly string[];
82
+ export function isFileKind(kind: unknown): boolean;
72
83
  /** Consecutive polls with the same size and mtime before a file is taken. (Two matches in a row = taken on the third sighting.) */
73
84
  export const STABLE_POLLS: 2;
74
85
  export function recordRan(ledger: string, item: {
package/types/types.d.ts CHANGED
@@ -237,6 +237,14 @@ export type ReadFlowOk = {
237
237
  declaration: Record<string, any>;
238
238
  signature: Signature;
239
239
  classes: Record<string, string>;
240
+ /**
241
+ * only on `readRunJobCopy`: the verified copy's own bytes (prose.txt)
242
+ */
243
+ proseText?: string | undefined;
244
+ /**
245
+ * only on `readRunJobCopy`: the verified copy's own bytes (declaration.json)
246
+ */
247
+ declarationText?: string | undefined;
240
248
  };
241
249
  export type ReadFlowRed = {
242
250
  ok: false;