fwdloop 0.26.1 → 0.27.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 +23 -3
- package/package.json +3 -3
- package/src/authoring.js +10 -0
- package/src/canrun.js +20 -0
- package/src/declaration.js +98 -2
- package/src/drafter.js +23 -10
- package/src/launcher.js +3 -2
- package/src/learnstore.js +1 -1
- package/src/pageask.js +18 -2
- package/src/pagefetch.js +10 -5
- package/src/panel/author.js +18 -2
- package/src/panel/authorflows.js +9 -4
- package/src/panel/authorstart.js +10 -6
- package/src/panel/authortrigger.js +34 -10
- package/src/panel/data.js +39 -4
- package/src/panel/index.html +516 -60
- package/src/panel/scheduler.js +42 -6
- package/src/panel/server.js +21 -5
- package/src/panel/tickets.js +113 -0
- package/src/runner.js +51 -10
- package/src/schedule.js +5 -0
- package/src/summary-words.js +12 -4
- package/src/ticket-draft.js +87 -0
- package/src/ticket-labels.js +65 -0
- package/src/ticket-mcp.js +66 -0
- package/src/ticket-shape.js +24 -0
- package/src/trigger-files.js +1 -1
- package/src/trigger-line.js +2 -1
- package/src/trigger-tickets.js +209 -0
- package/types/canrun.d.ts +14 -0
- package/types/drafter.d.ts +186 -64
- package/types/pageask.d.ts +1 -0
- package/types/pagefetch.d.ts +6 -3
- package/types/panel/author.d.ts +8 -0
- package/types/panel/authorflows.d.ts +2 -0
- package/types/panel/authorstart.d.ts +3 -1
- package/types/panel/authortrigger.d.ts +11 -1
- package/types/panel/data.d.ts +22 -3
- package/types/panel/scheduler.d.ts +7 -2
- package/types/panel/server.d.ts +9 -2
- package/types/panel/tickets.d.ts +81 -0
- package/types/runner.d.ts +21 -3
- package/types/summary-words.d.ts +2 -1
- package/types/ticket-draft.d.ts +96 -0
- package/types/ticket-labels.d.ts +36 -0
- package/types/ticket-mcp.d.ts +40 -0
- package/types/ticket-shape.d.ts +25 -0
- package/types/trigger-files.d.ts +2 -0
- package/types/trigger-line.d.ts +7 -0
- package/types/trigger-tickets.d.ts +91 -0
package/src/panel/authorflows.js
CHANGED
|
@@ -14,6 +14,7 @@ import { lstatSync, realpathSync } from 'node:fs';
|
|
|
14
14
|
import { join } from 'node:path';
|
|
15
15
|
|
|
16
16
|
import { scrub } from '../authoring.js';
|
|
17
|
+
import { ticketNumberOf, ticketRefusals, ticketSourcesOf } from '../ticket-draft.js';
|
|
17
18
|
import { endRow, readHistory } from '../books.js';
|
|
18
19
|
import { canFlowRun, willNotRunSay } from '../canrun.js';
|
|
19
20
|
import { loadCatalogue } from '../catalogue.js';
|
|
@@ -44,7 +45,7 @@ export const editBlockedSay = (runId) => `finish or stop ${runId} first`;
|
|
|
44
45
|
export const EDIT_STARTING_SAY = 'a run is starting';
|
|
45
46
|
const NO_LIMIT = 'no monthly limit set';
|
|
46
47
|
/** The body keys a run start takes (amendment 5 item 2): the open boxes plus the hash of the second click. Any other key is refused by name. */
|
|
47
|
-
const RUN_KEYS = ['flow', 'inputs', 'runId', 'destination', 'capUsd', 'askWaits', 'hash', 'provider', 'model', 'planOf'];
|
|
48
|
+
const RUN_KEYS = ['flow', 'inputs', 'runId', 'destination', 'capUsd', 'askWaits', 'hash', 'provider', 'model', 'planOf', 'ticket'];
|
|
48
49
|
|
|
49
50
|
/**
|
|
50
51
|
* What the Run / Resume forms show of a signed flow (read from its own files, never from a model): the job lines as the signed text has them
|
|
@@ -229,6 +230,10 @@ export function createFlowsDoor(opts) {
|
|
|
229
230
|
if (Object.hasOwn(pages, r.role) && r.path !== pages[r.role]) refusals.push({ field: `inputs.${n}`, say: pageAddressRefusal(r.role, pages[r.role]) });
|
|
230
231
|
});
|
|
231
232
|
const declared = (read.arbiter.sources ?? []).map((s) => s.role);
|
|
233
|
+
// M12 piece 3 (hamr 2026-10-29): a by-hand Run on a job with a ticket list picks ONE ticket by number; any other job takes none
|
|
234
|
+
const ticketRole = ticketSourcesOf(read.arbiter.sources)[0]?.role ?? null;
|
|
235
|
+
const ticket = ticketNumberOf(body?.ticket);
|
|
236
|
+
refusals.push(...ticketRefusals(ticketRole, body));
|
|
232
237
|
for (const role of declared) {
|
|
233
238
|
if (!Object.hasOwn(pages, role) && !rows.some((r) => r.role === role)) refusals.push({ field: 'inputs', say: `This flow needs an input named "${role}". Add it.` });
|
|
234
239
|
}
|
|
@@ -246,7 +251,7 @@ export function createFlowsDoor(opts) {
|
|
|
246
251
|
flow, flowSignatureHash: read.signature.flow, runId: null, version: 0, values,
|
|
247
252
|
});
|
|
248
253
|
return {
|
|
249
|
-
ok: /** @type {true} */ (true), flow, read, declared, rows: declared.map((role) => rows.find((r) => r.role === role) ?? { role, path: pages[role] }), runId, values, differs: checked.differs || runModel !== null, hash, newPick, flowDir: join(realRoot, flow), planFrom,
|
|
254
|
+
ok: /** @type {true} */ (true), flow, read, declared, rows: declared.map((role) => rows.find((r) => r.role === role) ?? { role, path: pages[role] }), ticketRole, ticket, runId, values, differs: checked.differs || runModel !== null, hash, newPick, flowDir: join(realRoot, flow), planFrom,
|
|
250
255
|
};
|
|
251
256
|
}
|
|
252
257
|
|
|
@@ -298,7 +303,7 @@ export function createFlowsDoor(opts) {
|
|
|
298
303
|
const last = lastSources(flowDir, roles, pageAddressesOf(read.arbiter));
|
|
299
304
|
const { passed, stats } = runsOf(flowDir, name, read, roles);
|
|
300
305
|
return {
|
|
301
|
-
flow: name, capUsd: read.arbiter.capUsd, roles, pages: pageAddressesOf(read.arbiter), nextRunId: nextRunId(flowDir), lastRunId: last.runId, lastSources: last.sources, leftThisMonth: left,
|
|
306
|
+
flow: name, capUsd: read.arbiter.capUsd, roles, pages: pageAddressesOf(read.arbiter), tickets: ticketSourcesOf(read.arbiter.sources).map((x) => x.role), nextRunId: nextRunId(flowDir), lastRunId: last.runId, lastSources: last.sources, leftThisMonth: left,
|
|
302
307
|
runs: passed, stats,
|
|
303
308
|
...formFacts(read, home, flowDir),
|
|
304
309
|
// M6 am5/am6: the job as the card Reuse workflow opens (`ok:true, card`), or why the card cannot hold it (`ok:false, say`). Nothing blocks it: a reuse never changes the job it is opened from.
|
|
@@ -462,7 +467,7 @@ export function createFlowsDoor(opts) {
|
|
|
462
467
|
};
|
|
463
468
|
}
|
|
464
469
|
const started = starter.start({
|
|
465
|
-
kind: 'run', flow: s.flow, runId: s.runId, sources: s.declared.map((role) => ({ role, path: /** @type {{path: string}} */ (s.rows.find((r) => r.role === role)).path })), values, pick: s.newPick, planOf: s.planFrom,
|
|
470
|
+
kind: 'run', flow: s.flow, runId: s.runId, sources: s.declared.map((role) => ({ role, path: /** @type {{path: string}} */ (s.rows.find((r) => r.role === role)).path, ...(role === s.ticketRole ? { ticket: /** @type {number} */ (s.ticket) } : {}) })), values, pick: s.newPick, planOf: s.planFrom,
|
|
466
471
|
}, loaded);
|
|
467
472
|
// M4d amendment 7b: the pick of a flow that had no record is written only once the start succeeded (a refused start leaves none), beside the signed files, never in them
|
|
468
473
|
if (started.status === 202 && s.newPick !== null) {
|
package/src/panel/authorstart.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
// starting the child is alive and the run dir has no book row yet
|
|
17
17
|
// started the run dir has its first book row (`pids.jsonl`, written by the run itself before its first step); `state` is
|
|
18
18
|
// working / parked / ended from `runLiveness` + `ask.json` (M4c's one "is it running?" rule), never a timer
|
|
19
|
-
// refused the child is dead and the run dir never got a book row: `say` = the CLI's own sentence (scrubbed) + "Nothing spent."
|
|
19
|
+
// refused the child is dead and the run dir never got a book row (a skipped run's history row counts as one, it ended): `say` = the CLI's own sentence (scrubbed) + "Nothing spent."
|
|
20
20
|
//
|
|
21
21
|
// One click, one start: `start` is fully synchronous (check -> mkdir -> spawn -> write pid.json, no await), so two requests that
|
|
22
22
|
// arrive together run one after the other and the second sees the first's `starting` start and is refused.
|
|
@@ -29,7 +29,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
29
29
|
|
|
30
30
|
import { loadCatalogue } from '../catalogue.js';
|
|
31
31
|
import { scrub } from '../authoring.js';
|
|
32
|
-
import { readPidRows } from '../books.js';
|
|
32
|
+
import { readHistory, readPidRows } from '../books.js';
|
|
33
33
|
import {
|
|
34
34
|
PANEL_STARTS_DIR, checkRunId, claimRunId, freeRunId, readFileInside, readdirInside, resolveRunDir, runOwnsPlan, copyRunPlan, RUN_PLAN_MARKER,
|
|
35
35
|
} from '../flow.js';
|
|
@@ -77,7 +77,8 @@ export function createStarter(opts) {
|
|
|
77
77
|
const st = readJsonFile(dir, 'start.json');
|
|
78
78
|
if (!st || typeof st.flow !== 'string' || typeof st.runId !== 'string') return null;
|
|
79
79
|
const base = { startId: id, kind: st.kind, flow: st.flow, runId: st.runId };
|
|
80
|
-
const
|
|
80
|
+
const flowDir = join(realpathSync(root), st.flow);
|
|
81
|
+
const resolved = resolveRunDir(flowDir, st.runId);
|
|
81
82
|
if (!resolved.ok) return null;
|
|
82
83
|
// alive FIRST, then the book row: a child that writes its row and exits between the two reads as started, never refused
|
|
83
84
|
const alive = childRunning(dir);
|
|
@@ -97,6 +98,8 @@ export function createStarter(opts) {
|
|
|
97
98
|
} else if (readPidRows(resolved.runDir).length > 0) {
|
|
98
99
|
return { ...base, phase: 'started', state: carriedOn() };
|
|
99
100
|
} else if (alive) return { ...base, phase: 'starting' };
|
|
101
|
+
// a SKIPPED run (hamr 2026-10-30) ends before its first pid row, but its history row is a real ending: a grey one, never a refusal
|
|
102
|
+
if (readHistory(flowDir).some((h) => h.runId === st.runId && h.outcome === 'skipped')) return { ...base, phase: 'started', state: 'ended' };
|
|
100
103
|
const log = readFileInside(dir, 'child.log');
|
|
101
104
|
const tail = log.ok ? scrub(log.text, keys).trim().slice(-LOG_TAIL_CHARS).replace(/^fwdloop: /, '') : '';
|
|
102
105
|
const say = tail === '' ? ENDED_SAY : (tail.includes(NOTHING_SPENT) ? tail : `${tail}\n${NOTHING_SPENT}`);
|
|
@@ -171,7 +174,7 @@ export function createStarter(opts) {
|
|
|
171
174
|
* folder as `signed-values.json` BEFORE the spawn; the run then uses them (`pickRunValues`). None = the flow's own.
|
|
172
175
|
* `trigger` (M9): `{kind, reason, catchUp, ...}` for a start a trigger fired (kind 'trigger'): written once into the run's own folder as `trigger.json`
|
|
173
176
|
* BEFORE the spawn; `appendHistory` copies it into the run's history row (the catch-up mark, am2 item 1).
|
|
174
|
-
* @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
|
|
177
|
+
* @param {{ kind: 'run'|'sign'|'trigger', flow: string, runId: string, sources: {role: string, path: string, ticket?: number, anyway?: boolean}[], planRun?: boolean, planOf?: string|null, values?: any, pick?: {slot: string, model: string}|null, trigger?: Record<string, any>|null }} a
|
|
175
178
|
* @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
|
|
176
179
|
* @returns {{ status: number, body: any }}
|
|
177
180
|
*/
|
|
@@ -230,7 +233,8 @@ export function createStarter(opts) {
|
|
|
230
233
|
writeFileSync(join(dir, 'start.json'), `${JSON.stringify({
|
|
231
234
|
kind, flow, runId, sources, startedAt: new Date().toISOString(),
|
|
232
235
|
}, null, 2)}\n`, { mode: 0o600 });
|
|
233
|
-
|
|
236
|
+
// M12: `--ticket N` (the one ticket of the list this run reads) follows the sources
|
|
237
|
+
const argv = ['run', flow, '--root', realpathSync(root), ...sources.flatMap((s) => ['--source', `${s.role}=${s.path}`]), ...sources.flatMap((s) => (s.ticket === undefined ? [] : ['--ticket', String(s.ticket), ...(s.anyway === true ? ['--anyway'] : [])])), '--run-id', runId, ...(pick ? ['--model', pick.model, '--provider', pick.slot] : [])]; // M4d am7b: a flow with no record runs with the model picked in Chat
|
|
234
238
|
let child;
|
|
235
239
|
try {
|
|
236
240
|
child = spawnDetached({
|
|
@@ -290,7 +294,7 @@ export function createStarter(opts) {
|
|
|
290
294
|
for (const id of readdirInside(sd, '.').filter((n) => ID_RE.test(n)).sort().reverse()) {
|
|
291
295
|
if (readFileInside(join(sd, id), 'cleared.json').ok) continue;
|
|
292
296
|
const v = readStart(join(sd, id), id, keys);
|
|
293
|
-
if (v === null) continue;
|
|
297
|
+
if (v === null || v.kind === 'trigger') continue; // the Chat card never shows a start it did not make
|
|
294
298
|
return v.phase === 'started' ? null : v;
|
|
295
299
|
}
|
|
296
300
|
return null;
|
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
import { scheduleHead, scheduledWords } from '../summary-words.js';
|
|
33
33
|
import { armTrigger, nextSlot, readRows, validateSchedule } from '../trigger-clock.js';
|
|
34
34
|
import { checkTarget, createFileTrigger } from '../trigger-files.js';
|
|
35
|
+
import { WATCHABLE, ticketListsOf } from '../ticket-shape.js';
|
|
35
36
|
import { readModelRecord } from '../flowmodel.js';
|
|
36
37
|
import { pageAddressesOf, pageAddressRefusal } from '../pagefetch.js';
|
|
37
38
|
import {
|
|
@@ -45,6 +46,8 @@ import { triggerHash, triggerLine } from '../trigger-line.js';
|
|
|
45
46
|
/** A trigger in the words a row and a run reason use: `daily 09:00`, `new-file jd = file:/home/you/inbox`. @param {Trigger} t */
|
|
46
47
|
const describe = (t) => triggerLine(t).replace('guardrail: trigger ', '');
|
|
47
48
|
|
|
49
|
+
/** M12: the one tool a ticket schedule's look uses, signed with the schedule's two clicks. */
|
|
50
|
+
export const TICKET_LOOK_TOOL = 'list_issues';
|
|
48
51
|
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.';
|
|
49
52
|
const HISTORY_FILE = 'triggers.jsonl';
|
|
50
53
|
|
|
@@ -129,6 +132,14 @@ function shapeOf(t, roles) {
|
|
|
129
132
|
if (typeof p !== 'string' || p === '' || !isAbsolute(p) || /[\x00-\x1f\x7f]/.test(p)) return { ok: false, say: `The ${where} must be a full path on one line, like /home/you/inbox. Nothing was changed.` };
|
|
130
133
|
return { ok: true, trigger: /** @type {Trigger} */ (o.kind === 'new-file' ? { kind: 'new-file', role: o.role, folder: p } : { kind: 'file-updated', role: o.role, path: p }) };
|
|
131
134
|
}
|
|
135
|
+
if (o.kind === 'new-ticket') {
|
|
136
|
+
// M12 piece 2: the person picks the input; the list address, the job's server and the look's tool are filled from the signed job (inspect), never typed here
|
|
137
|
+
const extra = Object.keys(o).filter((k) => !['kind', 'role', 'watch'].includes(k));
|
|
138
|
+
if (extra.length > 0) return { ok: false, say: `A "new-ticket" trigger takes a kind and a role, not "${extra[0]}". Nothing was changed.` };
|
|
139
|
+
if (typeof o.role !== 'string' || !roles.includes(o.role)) return { ok: false, say: `This job has no input named "${String(o.role)}" (it takes: ${roles.join(', ') || 'none'}). Pick one of those. Nothing was changed.` };
|
|
140
|
+
if (o.watch !== undefined && !(Array.isArray(o.watch) && o.watch.every((w) => WATCHABLE.includes(w)))) return { ok: false, say: `A ticket schedule can watch only ${WATCHABLE.join(' and ')}. Nothing was changed.` };
|
|
141
|
+
return { ok: true, trigger: /** @type {Trigger} */ ({ kind: 'new-ticket', role: o.role, list: '', server: '', tool: '', ...(o.watch ? { watch: o.watch } : {}) }) };
|
|
142
|
+
}
|
|
132
143
|
try { return { ok: true, trigger: validateSchedule(t) }; } catch (e) { return { ok: false, say: `${/** @type {Error} */ (e).message}. Nothing was changed.` }; }
|
|
133
144
|
}
|
|
134
145
|
|
|
@@ -165,23 +176,35 @@ export function createTriggerDoor(opts) {
|
|
|
165
176
|
const roles = (read.arbiter.sources ?? []).map((s) => s.role);
|
|
166
177
|
const shaped = shapeOf(body?.trigger === undefined ? 'missing' : body.trigger, roles);
|
|
167
178
|
if (!shaped.ok) return reply(400, { refused: 'bad-trigger', say: shaped.say });
|
|
168
|
-
|
|
179
|
+
let { trigger } = shaped;
|
|
180
|
+
if (trigger !== null && trigger.kind === 'new-ticket') {
|
|
181
|
+
// M12 piece 2 (items 8; PRD ruling "a tool counts as used if a step or the signed schedule uses it"): the look's tool is `list_issues` on the server the job names
|
|
182
|
+
const list = ticketListsOf(read.arbiter)[trigger.role];
|
|
183
|
+
if (list === undefined) return reply(400, { refused: 'bad-trigger', say: `The input "${trigger.role}" is not a ticket list (a GitHub issues list address), so no new ticket can start a run from it. Nothing was changed.` });
|
|
184
|
+
const server = read.declaration?.mcp?.server;
|
|
185
|
+
if (typeof server !== 'string') return reply(400, { refused: 'bad-trigger', say: 'This job names no MCP server, so the ticket list cannot be looked at. Nothing was changed.' });
|
|
186
|
+
// signed M12 item 7: the fields to watch come from the signed job (`ticketWatch`) unless the click itself names them; a job that names none watches nothing
|
|
187
|
+
const jobWatch = read.declaration?.ticketWatch;
|
|
188
|
+
const watch = trigger.watch ?? (Array.isArray(jobWatch) && jobWatch.length > 0 ? jobWatch : undefined);
|
|
189
|
+
trigger = { kind: trigger.kind, role: trigger.role, list, server, tool: TICKET_LOOK_TOOL, ...(watch ? { watch } : {}) };
|
|
190
|
+
}
|
|
169
191
|
const flowDir = join(realRoot, flow);
|
|
170
192
|
if (trigger !== null && !hasGreenRunForJob(flowDir)) return reply(409, { refused: 'no-green-run', say: NO_GREEN_SAY });
|
|
171
193
|
// M9 am20 item 3: neither Cancel nor a new schedule is refused because a run is starting, working or waiting: a run carries on from its own copy and
|
|
172
194
|
// keeps its own signed values; the next fire uses the new schedule. (A schedule never touches the job, so there is nothing for a run to collide with.)
|
|
173
|
-
|
|
174
|
-
|
|
195
|
+
const fileTrigger = trigger !== null && (trigger.kind === 'file-updated' || trigger.kind === 'new-file') ? trigger : null;
|
|
196
|
+
if (fileTrigger !== null && Object.hasOwn(pageAddressesOf(read.arbiter), fileTrigger.role)) {
|
|
197
|
+
return reply(400, { refused: 'bad-trigger', say: `The input "${fileTrigger.role}" is a web page, not a file, so no file arrival can start a run from it. Nothing was changed.` }); // M10 am3
|
|
175
198
|
}
|
|
176
|
-
if (
|
|
199
|
+
if (fileTrigger !== null) {
|
|
177
200
|
try {
|
|
178
|
-
checkTarget(
|
|
201
|
+
checkTarget(fileTrigger.kind === 'new-file' ? 'new' : 'updated', fileTrigger.kind === 'new-file' ? fileTrigger.folder : fileTrigger.path);
|
|
179
202
|
} catch (e) {
|
|
180
203
|
return reply(400, { refused: 'bad-trigger', say: `${/** @type {Error} */ (e).message}. Nothing was changed.` });
|
|
181
204
|
}
|
|
182
205
|
// a file that does not exist yet may arrive (checkTarget allows it), but its folder must be there: a typo is caught now, not never
|
|
183
|
-
if (
|
|
184
|
-
try { realpathSync(dirname(
|
|
206
|
+
if (fileTrigger.kind === 'file-updated') {
|
|
207
|
+
try { realpathSync(dirname(fileTrigger.path)); } catch { return reply(400, { refused: 'bad-trigger', say: `The folder of ${fileTrigger.path} does not exist. Nothing was changed.` }); }
|
|
185
208
|
}
|
|
186
209
|
}
|
|
187
210
|
// M6 am5 item 3: a schedule may carry the model of the run it was made from (a run field). Checked now by the Run door's own model check; the same as
|
|
@@ -367,7 +390,7 @@ export function createTriggerDoor(opts) {
|
|
|
367
390
|
* 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).
|
|
368
391
|
* The fire / ran ledger row was written by the caller BEFORE this, so a crash loses a run and never doubles one.
|
|
369
392
|
* @param {{flow: string, flowDir: string, read: any, trigger: Trigger, schedule: Schedule}} job
|
|
370
|
-
* @param {{kind: 'clock', slot: number, catchUp: boolean, missed: number} | {kind: 'file', path: string, sha: string}} cause
|
|
393
|
+
* @param {{kind: 'clock', slot: number, catchUp: boolean, missed: number} | {kind: 'file', path: string, sha: string} | {kind: 'ticket', number: number, sha: string, role: string, list: string, why?: string, anyway?: boolean}} cause
|
|
371
394
|
* @param {{ told?: (row: Record<string, any>) => boolean, beforeStart?: () => void, holdIfCannotStart?: boolean }} [hooks] M9 am3 (a queued file): `told(row)` true = this file
|
|
372
395
|
* 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
|
|
373
396
|
* 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
|
|
@@ -381,7 +404,7 @@ export function createTriggerDoor(opts) {
|
|
|
381
404
|
const desc = describe(trigger);
|
|
382
405
|
const base = {
|
|
383
406
|
at: new Date(now()).toISOString(), flow, trigger: desc, sig: schedule.sig,
|
|
384
|
-
...(cause.kind === 'clock' ? { slot: new Date(cause.slot).toISOString(), catchUp: cause.catchUp, missed: cause.missed } : { file: cause.path, sha: cause.sha, catchUp: false }),
|
|
407
|
+
...(cause.kind === 'clock' ? { slot: new Date(cause.slot).toISOString(), catchUp: cause.catchUp, missed: cause.missed } : cause.kind === 'ticket' ? { ticket: cause.number, sha: cause.sha, catchUp: false } : { file: cause.path, sha: cause.sha, catchUp: false }),
|
|
385
408
|
};
|
|
386
409
|
const done = (/** @type {Record<string, any>} */ r) => { const row = /** @type {Record<string, any>} */ ({ ...base, ...r }); if (!(row.outcome !== 'started' && hooks.told?.(row))) appendOutcome(flowDir, row); return row; };
|
|
387
410
|
const busy = flowsDoor.scheduleBusy(flow); // M9 am8: one WORKING run at a time per job; a run waiting at its ask does not block
|
|
@@ -412,6 +435,7 @@ export function createTriggerDoor(opts) {
|
|
|
412
435
|
const sources = [];
|
|
413
436
|
const pages = pageAddressesOf(read.arbiter);
|
|
414
437
|
for (const role of roles) {
|
|
438
|
+
if (cause.kind === 'ticket' && cause.role === role) { sources.push({ role, path: pages[role], ticket: cause.number, ...(cause.anyway === true ? { anyway: true } : {}) }); continue; } // M12: this run's input is ONE ticket of the signed list
|
|
415
439
|
if (Object.hasOwn(pages, role)) { sources.push({ role, path: pages[role] }); continue; } // M10 am3: a page input is its signed address, never an earlier run's or an arriving file
|
|
416
440
|
const p = 'role' in trigger && trigger.role === role && cause.kind === 'file' ? cause.path : last[role];
|
|
417
441
|
if (!p) return done({ outcome: 'refused', why: `There is no earlier run of this job to take the input "${role}" from. Run it by hand once with that input. Nothing started.` });
|
|
@@ -439,7 +463,7 @@ export function createTriggerDoor(opts) {
|
|
|
439
463
|
if (modelSays.length > 0) return done({ outcome: 'refused', why: modelSays[0].say.replace(/ Nothing was spent\.$/, '. Nothing started.') });
|
|
440
464
|
const catchUp = base.catchUp === true;
|
|
441
465
|
const record = {
|
|
442
|
-
kind: cause.kind, trigger: desc, reason: `Started by the trigger: ${desc}${catchUp ? ' (catch-up)' : ''}`, catchUp, ...(cause.kind === 'clock' ? { slot: new Date(cause.slot).toISOString(), missed: cause.missed } : { file: cause.path, sha: cause.sha }),
|
|
466
|
+
kind: cause.kind, trigger: desc, reason: `Started by the trigger: ${desc}${catchUp ? ' (catch-up)' : ''}`, catchUp, ...(cause.kind === 'clock' ? { slot: new Date(cause.slot).toISOString(), missed: cause.missed } : cause.kind === 'ticket' ? { ticket: cause.number, sha: cause.sha, ...(cause.why ? { why: cause.why } : {}) } : { file: cause.path, sha: cause.sha }),
|
|
443
467
|
// M9 am6: typed facts for the run's Job tab and Audit (their words are built from these, in src/summary-words.js, never here)
|
|
444
468
|
triggerKind: trigger.kind, words: scheduleHead(trigger), at: base.at, ...(cause.kind === 'clock' ? { lateMin: Math.max(0, Math.round((now() - cause.slot) / 60_000)) } : {}),
|
|
445
469
|
sig: schedule.sig, ...(schedule.from ? { fromRun: schedule.from } : {}),
|
package/src/panel/data.js
CHANGED
|
@@ -47,6 +47,7 @@ import {
|
|
|
47
47
|
} from '../summary-words.js';
|
|
48
48
|
import { MAX_STRUCTURE_RETRIES } from '../drafter.js';
|
|
49
49
|
import { isResultRun, checkTypeOf, buildResult, downloadOf, readCitedChecks } from './result.js';
|
|
50
|
+
import { ticketListOf } from './tickets.js';
|
|
50
51
|
import { thinkingRuleWords, thinkingTryWords } from '../thinking.js';
|
|
51
52
|
import { readLearningsRecord } from '../flowmodel.js';
|
|
52
53
|
import { readRunThinking } from '../runfile.js';
|
|
@@ -243,7 +244,7 @@ export const CRASHED_LABEL = 'crashed after taking your answer — start a fresh
|
|
|
243
244
|
* @type {Record<string, string>}
|
|
244
245
|
*/
|
|
245
246
|
export const SIGN_WORDS = {
|
|
246
|
-
'[▶]': 'running', '[·]': 'waiting', '[II]': 'stuck', '[!]': 'expired', '[?]': 'crashed', '[✓]': 'passed', '[✗]': 'failed', '[■]': 'stopped',
|
|
247
|
+
'[▶]': 'running', '[·]': 'waiting', '[II]': 'stuck', '[!]': 'expired', '[?]': 'crashed', '[✓]': 'passed', '[✗]': 'failed', '[■]': 'stopped', '[–]': 'skipped',
|
|
247
248
|
};
|
|
248
249
|
|
|
249
250
|
/**
|
|
@@ -378,13 +379,15 @@ export function glyphPulses(g) {
|
|
|
378
379
|
* - `[?]` crashed after taking your answer (amendment 2 (f)) — the answer was
|
|
379
380
|
* consumed, the process is gone, no end row: cannot be carried on.
|
|
380
381
|
* @param {{historyRow: any, askJson: any, consumedAnswerExists: boolean, hasStateJson: boolean, resume?: any, liveness?: 'running'|'gone'|'unknown', booksFresh?: boolean, lock?: string, resumable?: boolean, stoppedAtAsk?: string|null, jobEdited?: boolean, starting?: boolean}} ctx
|
|
381
|
-
* @returns {{glyph: '[✓]'|'[✗]'|'[·]'|'[!]'|'[▶]'|'[?]'|'[II]'|'[■]', label: string}}
|
|
382
|
+
* @returns {{glyph: '[✓]'|'[✗]'|'[·]'|'[!]'|'[▶]'|'[?]'|'[II]'|'[■]'|'[–]', label: string}}
|
|
382
383
|
*/
|
|
383
384
|
export function computeGlyph({
|
|
384
385
|
historyRow, askJson, consumedAnswerExists, hasStateJson, resume, liveness, booksFresh, lock, resumable, stoppedAtAsk, jobEdited, starting,
|
|
385
386
|
}) {
|
|
386
387
|
if (historyRow) {
|
|
387
388
|
if (historyRow.outcome === 'complete') return { glyph: '[✓]', label: 'passed' };
|
|
389
|
+
// M12 piece 3 (item 9): a ticket the signed labels do not match, or a closed one: grey, never failed
|
|
390
|
+
if (historyRow.outcome === 'skipped') return { glyph: '[–]', label: typeof historyRow.skipReason === 'string' && historyRow.skipReason !== '' ? `skipped — ${historyRow.skipReason}` : 'skipped' };
|
|
388
391
|
// M6 amendment 4: a stopped (or cap-halted) run whose job was edited and signed since cannot be resumed; the words say so.
|
|
389
392
|
if (jobEdited === true && (historyRow.outcome === 'stopped' || historyRow.outcome === 'cap-halt')) return { glyph: '[■]', label: JOB_EDITED_LINE };
|
|
390
393
|
// M4e amendment 4 item 4: a run the human stopped, or one that hit its money cap and can be continued, is `[■]` stopped — never "failed".
|
|
@@ -1090,6 +1093,19 @@ export function getRunGlyph({
|
|
|
1090
1093
|
return computeGlyph(loadRunContext(root, run.flowDir, run.runDir, flow, runId, catalogue, null));
|
|
1091
1094
|
}
|
|
1092
1095
|
|
|
1096
|
+
/**
|
|
1097
|
+
* The time (ms) the run's history row was written, or null when it has none. @param {{root: string, flow: string, runId: string, catalogue: any}} opts
|
|
1098
|
+
*/
|
|
1099
|
+
function getRunEndedAt({
|
|
1100
|
+
root, flow, runId, catalogue,
|
|
1101
|
+
}) {
|
|
1102
|
+
const run = resolveRunPath(root, flow, runId);
|
|
1103
|
+
if (!run.ok) return null;
|
|
1104
|
+
const at = loadRunContext(root, run.flowDir, run.runDir, flow, runId, catalogue, null).historyRow?.at;
|
|
1105
|
+
const ms = typeof at === 'string' ? Date.parse(at) : NaN;
|
|
1106
|
+
return Number.isFinite(ms) ? ms : null;
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1093
1109
|
/**
|
|
1094
1110
|
* `GET /api/runs` — every flow under `root`, every run under each flow
|
|
1095
1111
|
* (M4a scope item 2). A flow with zero runs still gets one row (`runId:
|
|
@@ -1518,7 +1534,7 @@ function runSummary(ctx, glyph, { root, catalogue, triggerRead, now, home }) {
|
|
|
1518
1534
|
}
|
|
1519
1535
|
const send = ctx.arbiter && Array.isArray(ctx.arbiter.sends) ? ctx.arbiter.sends.find((x) => x.target && typeof x.target.path === 'string') : undefined;
|
|
1520
1536
|
const endedPlain = endedWords({
|
|
1521
|
-
outcome, died, line, destination: send ? send.target.path : null, canResume: ctx.resumable === true && ctx.sameJob === true, home,
|
|
1537
|
+
outcome, died, line, destination: send ? send.target.path : null, canResume: ctx.resumable === true && ctx.sameJob === true, home, skipReason: ctx.historyRow?.skipReason,
|
|
1522
1538
|
});
|
|
1523
1539
|
// M9 am7 item 1: ENDED opens with the run's local end date and time, then its outcome word, then today's reason (NEXT stays as it was)
|
|
1524
1540
|
const ended = endedPlain === null ? null : {
|
|
@@ -2222,13 +2238,32 @@ export function getRunResult({
|
|
|
2222
2238
|
const { run, ctx } = got;
|
|
2223
2239
|
const sig = ctx.flowRead.signature;
|
|
2224
2240
|
const plan = buildJobPlan(ctx.flowRead.declaration, ctx.arbiter.asks ?? [], run.flowDir, typeof sig?.flow === 'string' ? sig.flow : null, ctx.flowRead.lines, csvRolesOf(ctx.arbiter));
|
|
2225
|
-
|
|
2241
|
+
const result = buildResult({
|
|
2226
2242
|
flow, runId, runDir: run.runDir, root, flowRead: ctx.flowRead, arbiter: ctx.arbiter, historyRow: ctx.historyRow, auditRows: ctx.auditRows, logJson: ctx.logJson, notChecked: plan.notChecked.items, readNotes: plan.notChecked.readNotes,
|
|
2227
2243
|
setupRows: (() => { const st = readSetup(run.flowDir); return st.present ? st.rows : []; })(),
|
|
2228
2244
|
door: resultDoorOf(getRunAsks({
|
|
2229
2245
|
root, flow, runId, catalogue, resumeAttempt, now,
|
|
2230
2246
|
})),
|
|
2231
2247
|
});
|
|
2248
|
+
// M12 piece 3 (item 9): the run a ticket schedule was set from also carries the ticket list (null for every other run)
|
|
2249
|
+
const tickets = getTicketList({
|
|
2250
|
+
root, flow, runId, catalogue,
|
|
2251
|
+
});
|
|
2252
|
+
return tickets === null ? result : { ...result, tickets };
|
|
2253
|
+
}
|
|
2254
|
+
|
|
2255
|
+
/**
|
|
2256
|
+
* M12 piece 3: the ticket list of the run a ticket schedule was set from (the Result tab's, and `Run it anyway`'s check), or null.
|
|
2257
|
+
* @param {{root: string, flow: string, runId: string, catalogue: any}} a
|
|
2258
|
+
*/
|
|
2259
|
+
export function getTicketList({
|
|
2260
|
+
root, flow, runId, catalogue,
|
|
2261
|
+
}) {
|
|
2262
|
+
const run = resolveRunPath(root, flow, runId);
|
|
2263
|
+
if (!run.ok) return null;
|
|
2264
|
+
return ticketListOf({
|
|
2265
|
+
flowDir: run.flowDir, runId, runIdsOf: listRunIds, glyphOf: (id) => getRunGlyph({ root, flow, runId: id, catalogue }), atOf: (id) => getRunEndedAt({ root, flow, runId: id, catalogue }),
|
|
2266
|
+
});
|
|
2232
2267
|
}
|
|
2233
2268
|
|
|
2234
2269
|
/**
|