fwdloop 0.19.1 → 0.20.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 (50) hide show
  1. package/bin/fwdloop +22 -13
  2. package/package.json +1 -1
  3. package/src/authoring.js +23 -3
  4. package/src/books.js +3 -2
  5. package/src/flow.js +218 -2
  6. package/src/jobkey.js +25 -0
  7. package/src/jsonl-append.js +29 -0
  8. package/src/monthly.js +3 -2
  9. package/src/panel/author.js +44 -18
  10. package/src/panel/authorcard.js +7 -13
  11. package/src/panel/authorflows.js +118 -24
  12. package/src/panel/authorresume.js +8 -4
  13. package/src/panel/authorstart.js +63 -18
  14. package/src/panel/authortrigger.js +250 -125
  15. package/src/panel/authorvalues.js +13 -2
  16. package/src/panel/data.js +233 -36
  17. package/src/panel/index.html +330 -124
  18. package/src/panel/needsyou.js +29 -0
  19. package/src/panel/scheduler.js +21 -22
  20. package/src/panel/server.js +30 -6
  21. package/src/provider.js +3 -2
  22. package/src/runner.js +10 -10
  23. package/src/runvalues.js +10 -2
  24. package/src/schedule.js +135 -0
  25. package/src/setup.js +0 -21
  26. package/src/summary-words.js +180 -7
  27. package/src/trigger-clock.js +18 -16
  28. package/src/trigger-files.js +37 -24
  29. package/src/trigger-line.js +6 -15
  30. package/src/types.js +1 -1
  31. package/types/authoring.d.ts +32 -2
  32. package/types/flow.d.ts +106 -0
  33. package/types/jobkey.d.ts +11 -0
  34. package/types/jsonl-append.d.ts +6 -0
  35. package/types/panel/author.d.ts +47 -17
  36. package/types/panel/authorcard.d.ts +3 -6
  37. package/types/panel/authorflows.d.ts +38 -10
  38. package/types/panel/authorstart.d.ts +15 -2
  39. package/types/panel/authortrigger.d.ts +73 -41
  40. package/types/panel/authorvalues.d.ts +6 -0
  41. package/types/panel/data.d.ts +101 -19
  42. package/types/panel/needsyou.d.ts +20 -0
  43. package/types/runvalues.d.ts +5 -0
  44. package/types/schedule.d.ts +69 -0
  45. package/types/setup.d.ts +0 -19
  46. package/types/summary-words.d.ts +105 -2
  47. package/types/trigger-clock.d.ts +8 -7
  48. package/types/trigger-files.d.ts +17 -10
  49. package/types/trigger-line.d.ts +16 -8
  50. package/types/types.d.ts +1 -1
@@ -47,6 +47,10 @@ export function createAuthor(opts: {
47
47
  status: any;
48
48
  body: any;
49
49
  };
50
+ reuseCheck: (b: any) => {
51
+ status: any;
52
+ body: any;
53
+ };
50
54
  runPrepare: (body: any) => {
51
55
  status: any;
52
56
  body: any;
@@ -78,44 +82,49 @@ export function createAuthor(opts: {
78
82
  ok: boolean;
79
83
  refused: string;
80
84
  say: string;
81
- reds?: undefined;
85
+ flow?: undefined;
86
+ trigger?: undefined;
87
+ words?: undefined;
88
+ armed?: undefined;
89
+ flowHash?: undefined;
90
+ sig?: undefined;
82
91
  };
83
92
  } | {
84
93
  status: number;
85
94
  body: {
86
95
  ok: boolean;
87
- refused: string;
88
- say: string;
89
- reds: any[];
96
+ flow: any;
97
+ trigger: null;
98
+ words: string | null;
99
+ armed: boolean;
100
+ refused?: undefined;
101
+ say?: undefined;
102
+ flowHash?: undefined;
103
+ sig?: undefined;
90
104
  };
91
105
  } | {
92
106
  status: number;
93
107
  body: {
94
- say?: string | undefined;
95
108
  ok: boolean;
96
109
  flow: any;
97
- trigger: import("../trigger-line.js").Trigger | null;
110
+ trigger: import("../trigger-line.js").Trigger;
98
111
  words: string | null;
99
112
  flowHash: string;
113
+ sig: string;
100
114
  armed: boolean;
101
115
  refused?: undefined;
102
- reds?: undefined;
116
+ say?: undefined;
103
117
  };
104
118
  };
105
119
  scan(): {
106
120
  flow: string;
107
121
  flowDir: string;
108
122
  read: import("../types.js").ReadFlowOk;
109
- trigger: import("./authortrigger.js").Trigger;
123
+ schedule: import("../schedule.js").Schedule;
124
+ trigger: import("../trigger-line.js").Trigger;
125
+ sig: string;
110
126
  }[];
111
- ensureArmed(job: {
112
- flowDir: string;
113
- read: any;
114
- trigger: Trigger;
115
- }): {
116
- armed: boolean;
117
- already: boolean;
118
- };
127
+ retireStale(): void;
119
128
  busy(job: {
120
129
  flow: string;
121
130
  }): boolean;
@@ -123,17 +132,20 @@ export function createAuthor(opts: {
123
132
  flow: string;
124
133
  flowDir: string;
125
134
  trigger: Trigger;
135
+ sig: string;
126
136
  }, row: Record<string, any>): void;
127
137
  refuse(job: {
128
138
  flow: string;
129
139
  flowDir: string;
130
140
  trigger: Trigger;
141
+ sig: string;
131
142
  }, why: string): void;
132
143
  fire(job: {
133
144
  flow: string;
134
145
  flowDir: string;
135
146
  read: any;
136
147
  trigger: Trigger;
148
+ schedule: Schedule;
137
149
  }, cause: {
138
150
  kind: "clock";
139
151
  slot: number;
@@ -146,11 +158,30 @@ export function createAuthor(opts: {
146
158
  }, hooks?: {
147
159
  told?: (row: Record<string, any>) => boolean;
148
160
  beforeStart?: () => void;
161
+ holdIfCannotStart?: boolean;
149
162
  }): Record<string, any>;
150
163
  read(flow: string): {
151
164
  flow: string;
152
165
  trigger: import("../trigger-line.js").Trigger | null;
153
166
  flowHash: string;
167
+ sig: string | null;
168
+ armed: boolean;
169
+ armedAt: number | null;
170
+ nextSlotMs: number | null;
171
+ lastOutcome: any;
172
+ hasGreenRun: boolean;
173
+ } | null;
174
+ facts(flow: string): {
175
+ from: string | null;
176
+ model: string | null;
177
+ destination: string | null;
178
+ inputs: string[];
179
+ fires: any[];
180
+ allFires: any[];
181
+ flow: string;
182
+ trigger: import("../trigger-line.js").Trigger | null;
183
+ flowHash: string;
184
+ sig: string | null;
154
185
  armed: boolean;
155
186
  armedAt: number | null;
156
187
  nextSlotMs: number | null;
@@ -163,7 +194,6 @@ export function createAuthor(opts: {
163
194
  armed: boolean;
164
195
  hasGreenRun: boolean;
165
196
  refusal: string | null;
166
- editNote: string | null;
167
197
  } | null;
168
198
  };
169
199
  resumePrepare: (body: any) => any;
@@ -62,10 +62,6 @@ export function parseInputLines(text: string): {
62
62
  * @param {any} body
63
63
  */
64
64
  export function cardFields(body: any): {
65
- editOf?: {
66
- flow: any;
67
- flowHash: any;
68
- } | undefined;
69
65
  thinking?: boolean | undefined;
70
66
  provider?: string | undefined;
71
67
  model?: string | undefined;
@@ -175,13 +171,14 @@ export function destinationRefusal(dest: string, root: string): string | null;
175
171
  /**
176
172
  * Every $0 check on the card, before any spawn (scope 6). Collects all refusals so the page can name every box.
177
173
  * @param {ReturnType<typeof cardFields>} card
178
- * @param {{ root: string, keys?: string[], home?: string }} ctx `keys` = the provider key values (the keys load's scrub list): a key value typed into any box is refused; `home` = the config home Settings is read from (the cap floor)
174
+ * @param {{ root: string, keys?: string[], home?: string, runOf?: string }} ctx `keys` = the provider key values (the keys load's scrub list): a key value typed into any box is refused; `home` = the config home Settings is read from (the cap floor)
179
175
  * @returns {{ ok: true, prose: string }|{ ok: false, refusals: {field: string, say: string}[] }}
180
176
  */
181
- export function checkCard(card: ReturnType<typeof cardFields>, { root, keys, home }: {
177
+ export function checkCard(card: ReturnType<typeof cardFields>, { root, keys, home, runOf }: {
182
178
  root: string;
183
179
  keys?: string[];
184
180
  home?: string;
181
+ runOf?: string;
185
182
  }): {
186
183
  ok: true;
187
184
  prose: string;
@@ -44,6 +44,30 @@ export function createFlowsDoor(opts: {
44
44
  }): {
45
45
  /** M6 amendments 1 and 3: the sentence that says why this flow cannot be edited now, or null (the sign route's check). @param {string} name */
46
46
  editBlock(name: string): string | null;
47
+ /** M9 am8 item 1: the sentence that says why the SCHEDULE cannot start a run now (one is starting or still working; a run waiting at its ask does not count), or null. @param {string} name */
48
+ scheduleBusy(name: string): string | null;
49
+ /**
50
+ * M6 am9: is this run red, as the panel's glyph rule reads it (`[✗]` and nothing else; stopped `[■]` and waiting are not)? The server decides this itself,
51
+ * never from the page's word. False for a run that does not resolve.
52
+ * @param {string} flow @param {unknown} runId
53
+ */
54
+ runIsRed(flow: string, runId: unknown): boolean;
55
+ /**
56
+ * M6 am5/am6: the job key of the signed flow `name` (see src/jobkey.js), or null when it is not a signed flow that reads. The draft door compares a Reuse card with it.
57
+ * @param {string} name
58
+ */
59
+ signedJobKey(name: string): string | null;
60
+ /**
61
+ * `POST /api/author/reuse-check` (M6 am6 item 2): what the ONE Reuse card's button is for the fields as typed, decided here, at $0, writes nothing.
62
+ * Any job field changed (lines, guardrails, asks, steps) = `draft` (with the next free name); else a RED source run (`[✗]`, M6 am9) = `draft` with `runOf: true`; else a destination, cap or ask wait different from the
63
+ * signed value = `sign-run` (with the hash the second click carries); else `run`. Only a red run's colour enters, and the server reads it. `fromRun` (the run the card was
64
+ * opened from) is dropped before the run checks; `job` is read here and never reaches the run door.
65
+ * @param {any} body
66
+ */
67
+ reuseCheck(body: any): {
68
+ status: any;
69
+ body: any;
70
+ };
47
71
  /** M9: the source paths the newest run of this job used, role -> path (blank = none), for a start a trigger fires. @param {string} name @param {string[]} roles */
48
72
  lastSourcesOf(name: string, roles: string[]): {
49
73
  runId: null;
@@ -66,10 +90,8 @@ export function createFlowsDoor(opts: {
66
90
  ok: boolean;
67
91
  flows: {
68
92
  edit: {
69
- ok: boolean;
93
+ ok: false;
70
94
  say: string;
71
- card?: undefined;
72
- flowHash?: undefined;
73
95
  } | {
74
96
  ok: boolean;
75
97
  card: {
@@ -79,8 +101,6 @@ export function createFlowsDoor(opts: {
79
101
  capUsd: string;
80
102
  askWait: string;
81
103
  };
82
- flowHash: any;
83
- say?: undefined;
84
104
  };
85
105
  values: {
86
106
  capUsd: number;
@@ -110,6 +130,10 @@ export function createFlowsDoor(opts: {
110
130
  destination: string | null;
111
131
  askWaits: Record<string, string>;
112
132
  };
133
+ model: {
134
+ slot: any;
135
+ model: any;
136
+ } | null;
113
137
  runId: string;
114
138
  }[];
115
139
  stats: {
@@ -153,10 +177,8 @@ export function createFlowsDoor(opts: {
153
177
  ok: boolean;
154
178
  flow: {
155
179
  edit: {
156
- ok: boolean;
180
+ ok: false;
157
181
  say: string;
158
- card?: undefined;
159
- flowHash?: undefined;
160
182
  } | {
161
183
  ok: boolean;
162
184
  card: {
@@ -166,8 +188,6 @@ export function createFlowsDoor(opts: {
166
188
  capUsd: string;
167
189
  askWait: string;
168
190
  };
169
- flowHash: any;
170
- say?: undefined;
171
191
  };
172
192
  values: {
173
193
  capUsd: number;
@@ -197,6 +217,10 @@ export function createFlowsDoor(opts: {
197
217
  destination: string | null;
198
218
  askWaits: Record<string, string>;
199
219
  };
220
+ model: {
221
+ slot: any;
222
+ model: any;
223
+ } | null;
200
224
  runId: string;
201
225
  }[];
202
226
  stats: {
@@ -215,6 +239,10 @@ export function createFlowsDoor(opts: {
215
239
  destination: string | null;
216
240
  askWaits: Record<string, string>;
217
241
  };
242
+ model: {
243
+ slot: any;
244
+ model: any;
245
+ } | null;
218
246
  runId: string;
219
247
  };
220
248
  };
@@ -15,6 +15,17 @@ export function createStarter(opts: {
15
15
  say?: undefined;
16
16
  };
17
17
  startingFor: (flow: string, keys: string[], runId?: string) => string | null;
18
+ canStart: ({ flow, runId, planRun }: {
19
+ flow: string;
20
+ runId: string;
21
+ planRun?: boolean;
22
+ }, loaded: {
23
+ env: Record<string, string | undefined>;
24
+ keyNames?: string[];
25
+ }) => {
26
+ status: number;
27
+ body: any;
28
+ } | null;
18
29
  /**
19
30
  * Start `fwdloop run` for a flow whose every $0 check already passed at the calling door. Re-checks the run id here (nothing
20
31
  * awaits between this check and the spawn). 202 { startId, runId } or a refusal; a refusal creates nothing.
@@ -23,11 +34,11 @@ export function createStarter(opts: {
23
34
  * folder as `signed-values.json` BEFORE the spawn; the run then uses them (`pickRunValues`). None = the flow's own.
24
35
  * `trigger` (M9): `{kind, reason, catchUp, ...}` for a start a trigger fired (kind 'trigger'): written once into the run's own folder as `trigger.json`
25
36
  * BEFORE the spawn; `appendHistory` copies it into the run's history row (the catch-up mark, am2 item 1).
26
- * @param {{ kind: 'run'|'sign'|'trigger', flow: string, runId: string, sources: {role: string, path: string}[], values?: any, pick?: {slot: string, model: string}|null, trigger?: Record<string, any>|null }} a
37
+ * @param {{ kind: 'run'|'sign'|'trigger', flow: string, runId: string, sources: {role: string, path: string}[], planRun?: boolean, planOf?: string|null, values?: any, pick?: {slot: string, model: string}|null, trigger?: Record<string, any>|null }} a
27
38
  * @param {{ env: Record<string, string|undefined>, keyNames?: string[] }} loaded the keys load: its env is the child's env AND (with its key names) the scrub list
28
39
  * @returns {{ status: number, body: any }}
29
40
  */
30
- start({ kind, flow, runId, sources, values, pick, trigger, }: {
41
+ start({ kind, flow, runId, sources, values, pick, trigger, planRun, planOf, }: {
31
42
  kind: "run" | "sign" | "trigger";
32
43
  flow: string;
33
44
  runId: string;
@@ -35,6 +46,8 @@ export function createStarter(opts: {
35
46
  role: string;
36
47
  path: string;
37
48
  }[];
49
+ planRun?: boolean;
50
+ planOf?: string | null;
38
51
  values?: any;
39
52
  pick?: {
40
53
  slot: string;
@@ -1,25 +1,24 @@
1
- /** The folder holding the ledgers of ONE signed trigger. @param {string} flowDir @param {string} flowHash */
2
- export function triggerLedgerDir(flowDir: string, flowHash: string): string;
3
1
  /** Every fire outcome of a job, oldest first, through the safe gateway. @param {string} flowDir @returns {any[]} */
4
2
  export function readOutcomes(flowDir: string): any[];
5
3
  /** The ONE writer of `triggers.jsonl`: append-only, one line per fire outcome. @param {string} flowDir @param {Record<string, any>} row */
6
4
  export function appendOutcome(flowDir: string, row: Record<string, any>): void;
7
5
  /**
8
6
  * M9 item 1 and 2: does this job have "one green run"? The ONE function that decides it. A passed run counts when the job it ran (its own
9
- * `job/` copy) is the current job WITHOUT its trigger line: so changing only the trigger keeps the run (item 2), and an Edit that changes
10
- * the steps, a guardrail or the cap does not (am1). A run from before runs kept a job copy has none to compare, so it counts only when its
11
- * history row's signature is the job's current one (a job signed since then is not the job it ran, unless that signing only added or changed its trigger line: see signingsOf).
7
+ * `job/` copy) is the job as it is now (prose and declaration, byte for byte: a schedule is its own file, so setting one never changes the job).
8
+ * A run from before runs kept a job copy has none to compare, so it counts only when its history row's signature is the job's current one.
12
9
  * @param {string} flowDir
13
10
  */
14
11
  export function hasGreenRunForJob(flowDir: string): boolean;
15
12
  /**
16
- * The ONE writer of "this trigger was set": the starting point (am2 item 2). Idempotent. A file kind records what is already there first
17
- * (never runs), then the armed row, so a failure between the two leaves it unarmed and the next call finishes it. Throws, naming why, when
18
- * the target is not usable now.
19
- * @param {string} flowDir @param {string} flowHash @param {Trigger} trigger @param {number} now epoch ms
13
+ * The ONE writer of "this schedule was set": the starting point (am2 item 2). Idempotent per signing. A file kind records what is already there first
14
+ * (never runs; `baseline: false` = the folder is the same as the earlier signing's, whose rows were carried), then the armed row. Throws, naming why,
15
+ * when the target is not usable now.
16
+ * @param {string} flowDir @param {Schedule} schedule @param {number} now epoch ms @param {{baseline?: boolean}} [o]
20
17
  * @returns {{armed: boolean, already: boolean}}
21
18
  */
22
- export function armFor(flowDir: string, flowHash: string, trigger: Trigger, now: number): {
19
+ export function armFor(flowDir: string, schedule: Schedule, now: number, o?: {
20
+ baseline?: boolean;
21
+ }): {
23
22
  armed: boolean;
24
23
  already: boolean;
25
24
  };
@@ -55,8 +54,8 @@ export function createTriggerDoor(opts: {
55
54
  };
56
55
  };
57
56
  /**
58
- * `POST /api/author/trigger`: the second click, carrying the hash it was shown. Re-signs the SAME plan (declaration.json byte for byte,
59
- * prose.txt with only its trigger line changed) through the M6 replace path, then arms the trigger. $0: no drafter, no run.
57
+ * `POST /api/author/trigger`: the second click, carrying the hash it was shown. Writes `schedule.json` (signed by the human who clicked) and arms it, or
58
+ * (trigger null) cancels. The job's files are never opened for writing. $0: no drafter, no run. A run that is starting, working or waiting is never touched.
60
59
  * @param {any} body
61
60
  */
62
61
  set(body: any): {
@@ -70,79 +69,88 @@ export function createTriggerDoor(opts: {
70
69
  ok: boolean;
71
70
  refused: string;
72
71
  say: string;
73
- reds?: undefined;
72
+ flow?: undefined;
73
+ trigger?: undefined;
74
+ words?: undefined;
75
+ armed?: undefined;
76
+ flowHash?: undefined;
77
+ sig?: undefined;
74
78
  };
75
79
  } | {
76
80
  status: number;
77
81
  body: {
78
82
  ok: boolean;
79
- refused: string;
80
- say: string;
81
- reds: any[];
83
+ flow: any;
84
+ trigger: null;
85
+ words: string | null;
86
+ armed: boolean;
87
+ refused?: undefined;
88
+ say?: undefined;
89
+ flowHash?: undefined;
90
+ sig?: undefined;
82
91
  };
83
92
  } | {
84
93
  status: number;
85
94
  body: {
86
- say?: string | undefined;
87
95
  ok: boolean;
88
96
  flow: any;
89
- trigger: import("../trigger-line.js").Trigger | null;
97
+ trigger: import("../trigger-line.js").Trigger;
90
98
  words: string | null;
91
99
  flowHash: string;
100
+ sig: string;
92
101
  armed: boolean;
93
102
  refused?: undefined;
94
- reds?: undefined;
103
+ say?: undefined;
95
104
  };
96
105
  };
97
- /** Every signed job that has a trigger, as the scheduler needs it: `{flow, flowDir, read, trigger}`. Reads each job the way the CLI will (signature verified). */
106
+ /** Every job with a live schedule, as the scheduler needs it: `{flow, flowDir, read, schedule, trigger, sig}`. Reads each job the way the CLI will (signature verified). */
98
107
  scan(): {
99
108
  flow: string;
100
109
  flowDir: string;
101
110
  read: import("../types.js").ReadFlowOk;
102
- trigger: Trigger;
111
+ schedule: import("../schedule.js").Schedule;
112
+ trigger: import("../trigger-line.js").Trigger;
113
+ sig: string;
103
114
  }[];
104
- /** Arm this job's signed trigger if it is not armed yet (a crash between the sign and the arm). Idempotent; throws naming why. @param {{flowDir: string, read: any, trigger: Trigger}} job */
105
- ensureArmed(job: {
106
- flowDir: string;
107
- read: any;
108
- trigger: Trigger;
109
- }): {
110
- armed: boolean;
111
- already: boolean;
112
- };
113
- /** M9 am3: is a run of this job starting, running or waiting at an ask? (the same check `fire` makes first) @param {{flow: string}} job */
115
+ /** A schedule whose job was Edited since (M9 am1: By hand again) is cancelled the way Cancel does it, once. Called at the top of every scheduler tick. */
116
+ retireStale(): void;
117
+ /** M9 am3/am8: is a run of this job starting or still working? A run waiting at its ask is not busy. (the same check `fire` makes first) @param {{flow: string}} job */
114
118
  busy(job: {
115
119
  flow: string;
116
120
  }): boolean;
117
- /** M9 am3: one row for a queued file that is not a fire (deleted / changed before its turn). @param {{flow: string, flowDir: string, trigger: Trigger}} job @param {Record<string, any>} row */
121
+ /** M9 am3: one row for a queued file that is not a fire (deleted / changed before its turn). @param {{flow: string, flowDir: string, trigger: Trigger, sig: string}} job @param {Record<string, any>} row */
118
122
  note(job: {
119
123
  flow: string;
120
124
  flowDir: string;
121
125
  trigger: Trigger;
126
+ sig: string;
122
127
  }, row: Record<string, any>): void;
123
128
  /**
124
- * One row in `triggers.jsonl` that is not a fire (the trigger could not be watched). @param {{flow: string, flowDir: string, trigger: Trigger}} job @param {string} why
129
+ * One row in `triggers.jsonl` that is not a fire (the trigger could not be watched). @param {{flow: string, flowDir: string, trigger: Trigger, sig: string}} job @param {string} why
125
130
  */
126
131
  refuse(job: {
127
132
  flow: string;
128
133
  flowDir: string;
129
134
  trigger: Trigger;
135
+ sig: string;
130
136
  }, why: string): void;
131
137
  /**
132
138
  * M9 item 3-5: one fire, in this order, each outcome ONE row in `triggers.jsonl`: busy -> monthly-exhausted -> refused (an input or the keys
133
139
  * are missing) -> started through the ONE start path (kind `trigger`; the reason and the catch-up mark go into the run's own folder first).
134
140
  * The fire / ran ledger row was written by the caller BEFORE this, so a crash loses a run and never doubles one.
135
- * @param {{flow: string, flowDir: string, read: any, trigger: Trigger}} job
141
+ * @param {{flow: string, flowDir: string, read: any, trigger: Trigger, schedule: Schedule}} job
136
142
  * @param {{kind: 'clock', slot: number, catchUp: boolean, missed: number} | {kind: 'file', path: string, sha: string}} cause
137
- * @param {{ told?: (row: Record<string, any>) => boolean, beforeStart?: () => void }} [hooks] M9 am3 (a queued file): `told(row)` true = this file
143
+ * @param {{ told?: (row: Record<string, any>) => boolean, beforeStart?: () => void, holdIfCannotStart?: boolean }} [hooks] M9 am3 (a queued file): `told(row)` true = this file
138
144
  * already has a row for that outcome and reason (`why`), so none is written again (the outcome is still returned); `beforeStart` runs right before the ONE
139
- * start, once every check has passed: the scheduler writes the file's `ran` row there.
145
+ * start, once every check has passed: the scheduler writes the file's `ran` row there. `holdIfCannotStart` (a queued file, M9 am17): the starter's `canStart` is asked first, and a no writes nothing
146
+ * (no row, no `beforeStart`) and returns outcome `cannot-start`.
140
147
  */
141
148
  fire(job: {
142
149
  flow: string;
143
150
  flowDir: string;
144
151
  read: any;
145
152
  trigger: Trigger;
153
+ schedule: Schedule;
146
154
  }, cause: {
147
155
  kind: "clock";
148
156
  slot: number;
@@ -155,16 +163,41 @@ export function createTriggerDoor(opts: {
155
163
  }, hooks?: {
156
164
  told?: (row: Record<string, any>) => boolean;
157
165
  beforeStart?: () => void;
166
+ holdIfCannotStart?: boolean;
158
167
  }): Record<string, any>;
159
168
  /**
160
- * What a card shows of a job's trigger, as data (no words): the signed trigger, whether it is armed, the next slot (clock kinds), the last
161
- * fire outcome. `null` when the job is not a readable signed job.
169
+ * What a card shows of a job's schedule, as data (no words): the trigger (null = By hand), whether it is armed, the next slot (clock kinds), the last
170
+ * fire outcome of THIS signing (rows with its `sig`, never a wall-clock compare). `null` when the job is not a readable signed job.
162
171
  * @param {string} flow
163
172
  */
164
173
  read(flow: string): {
165
174
  flow: string;
166
175
  trigger: import("../trigger-line.js").Trigger | null;
167
176
  flowHash: string;
177
+ sig: string | null;
178
+ armed: boolean;
179
+ armedAt: number | null;
180
+ nextSlotMs: number | null;
181
+ lastOutcome: any;
182
+ hasGreenRun: boolean;
183
+ } | null;
184
+ /**
185
+ * M9 am6/am7: every fact the Job tab's Schedule field, a run's Audit schedule rows and the Run tab's SCHEDULE block are built from, for one job: the
186
+ * schedule, what it is bound to (the run it was set from, model, destination, inputs: what the fire reads from `schedule.json`), the fires of this signing
187
+ * (each one `triggers.jsonl` row with its `sig`) and the newest one. Data only; the words are `src/summary-words.js`'s. `null` when the job is not a readable signed job.
188
+ * @param {string} flow
189
+ */
190
+ facts(flow: string): {
191
+ from: string | null;
192
+ model: string | null;
193
+ destination: string | null;
194
+ inputs: string[];
195
+ fires: any[];
196
+ allFires: any[];
197
+ flow: string;
198
+ trigger: import("../trigger-line.js").Trigger | null;
199
+ flowHash: string;
200
+ sig: string | null;
168
201
  armed: boolean;
169
202
  armedAt: number | null;
170
203
  nextSlotMs: number | null;
@@ -173,8 +206,7 @@ export function createTriggerDoor(opts: {
173
206
  } | null;
174
207
  /**
175
208
  * What the Run card's dropdown needs of one job (M9 piece 5): the typed trigger, its words, whether it is armed, and, when the job has had
176
- * no good run, the server's refusal sentence (the page shows it and disables the dropdown; it invents no words). `editNote` is am1's
177
- * warning, set only when the job has a trigger. `null` when the job is not a readable signed job.
209
+ * no good run, the server's refusal sentence (the page shows it and disables the dropdown; it invents no words). `null` when the job is not a readable signed job.
178
210
  * @param {string} flow
179
211
  */
180
212
  card(flow: string): {
@@ -183,8 +215,8 @@ export function createTriggerDoor(opts: {
183
215
  armed: boolean;
184
216
  hasGreenRun: boolean;
185
217
  refusal: string | null;
186
- editNote: string | null;
187
218
  } | null;
188
219
  };
189
220
  export const NO_GREEN_SAY: "This job has not had a good run yet. Run it once by hand and get it right first; then you can set when it runs. Nothing was changed.";
190
221
  export type Trigger = import("../trigger-line.js").Trigger;
222
+ export type Schedule = import("../schedule.js").Schedule;
@@ -4,6 +4,11 @@
4
4
  * @param {number} spentUsd @param {number} floorUsd
5
5
  */
6
6
  export function leastResumeCapUsd(spentUsd: number, floorUsd: number): number;
7
+ /**
8
+ * The one sentence for a cap that is not above what is already spent (a Resume's door and note, and the Cap note of a card that belongs to a draft, M4d am23).
9
+ * @param {number} spentUsd @param {number} floorUsd
10
+ */
11
+ export function capAboveSpentText(spentUsd: number, floorUsd: number): string;
7
12
  /**
8
13
  * @param {object} a
9
14
  * @param {string[]} a.allowedKeys the body keys this door takes; any other key is refused by name
@@ -60,5 +65,6 @@ export function checkValues({ allowedKeys, body, base, realRoot, capOnly, floorU
60
65
  };
61
66
  export const NEW_FLOW_SAY: "Only the files, the destination, the money cap and an ask's wait can change from one run to the next. A change to a job line, an ask's words or the steps is a new flow: use New job.";
62
67
  export const RESUME_ONLY_CAP_SAY: "A resume changes only the cap. New files or a new destination or ask wait is a new run of this flow (Run a signed flow); a change to a job line or an ask is a new flow (New job).";
68
+ export function capNotAboveSpent(capUsd: number, alreadyUsd: number): boolean;
63
69
  export { valuesHash };
64
70
  import { valuesHash } from '../runvalues.js';