fwdloop 0.9.0 → 0.11.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.
@@ -1,38 +1,142 @@
1
+ /**
2
+ * Resolve `<root>/<flowName>` safely — `checkFlowName` first (never a raw
3
+ * string joined into a path). `checkFlowName` rules out a flowName that
4
+ * escapes `root` lexically (no `/`, `\`, `..`), but a flow directory named
5
+ * by URL is not required to have come from `listFlowNames` first — a
6
+ * request can name a flow directly. So if `<root>/<flowName>` actually
7
+ * exists, it is re-checked with `realpathSync`: it must resolve inside the
8
+ * real `root`, same class of hole `resolveRunDir` closes for a run dir one
9
+ * level down (a symlinked flow directory would never show up in a
10
+ * `listFlowNames` listing, since a symlink dirent never reports
11
+ * `isDirectory()`, but a direct request naming it by its allow-list-legal
12
+ * name must still be refused). A not-yet-existing flow directory has
13
+ * nothing to realpath, so only the lexical result applies to it.
14
+ * Returns the flow directory, or a refusal.
15
+ * @param {string} root
16
+ * @param {string} flowName
17
+ * @returns {{ok:true, flowDir:string}|{ok:false, red:string, why?:'outside-root'}}
18
+ */
19
+ export function resolveFlowDir(root: string, flowName: string): {
20
+ ok: true;
21
+ flowDir: string;
22
+ } | {
23
+ ok: false;
24
+ red: string;
25
+ why?: "outside-root";
26
+ };
27
+ /**
28
+ * A consumed-answer marker exists for THIS ask (`askId`) — `answerAsk`'s own write
29
+ * (`src/ask.js`) renames to `answer.<askId>.consumed.json` on accept, and
30
+ * `resumeRun` (`src/runner.js`) does the same when it consumes an in-place
31
+ * `answer.json`. A directory-naming-convention check, not a "book" with its
32
+ * own single-row shape, so it lives here rather than growing a one-off
33
+ * reader in either writer's module. Per the signed rule (ladder M4a scope
34
+ * item 4) it is per the OPEN ask's askId: after redo -> re-park the old
35
+ * ask's marker stays on disk and must not answer the new ask. An ask with no
36
+ * askId (pre-M3) can be paired with no marker: false.
37
+ * @param {string} runDir
38
+ * @param {string|null} askId the open ask's own askId
39
+ * @returns {boolean}
40
+ */
41
+ export function hasConsumedAnswer(runDir: string, askId: string | null): boolean;
1
42
  /**
2
43
  * M4b piece 2: a SAVED, not-yet-consumed answer — `answer.json` (what
3
44
  * `answerAsk` writes; the resume consumes it by renaming it away, F44). Read
4
45
  * through `readFileInside` (a symlinked file is "none"). `null` when there is
5
46
  * none or it is unreadable/unparseable or names no askId.
6
47
  * @param {string} runDir
7
- * @returns {{askId: string, decision: string|null}|null}
48
+ * @returns {{askId: string, decision: string|null, answeredAt: string|null}|null}
8
49
  */
9
50
  export function readSavedAnswer(runDir: string): {
10
51
  askId: string;
11
52
  decision: string | null;
53
+ answeredAt: string | null;
12
54
  } | null;
13
55
  /**
14
56
  * M4b amendment 1 scope 2: the ONE derivation of "answer saved, resume not
15
- * started". From the books: an answer saved (`answer.json` present) and so
16
- * unconsumed. From the panel's in-memory attempt record (`attempt`, may be
57
+ * started" (now worded "your answer is saved; the run stopped before using it" — M4c-fix amendment 3 (c)).
58
+ * From the books: an answer saved (`answer.json` present) and so unconsumed. From the panel's in-memory attempt record (`attempt`, may be
17
59
  * null): whether a resume is still being started, and the resume's own refusal.
18
60
  * `null` when there is nothing to say (no saved answer and no attempt).
19
- * @param {{savedAnswer: {askId:string, decision:string|null}|null, attempt: any}} ctx
20
- * @returns {{state: 'starting'|'not-started'|'took-over', askId: string|null, tries: number|null, maxTries: number|null, reason: string|null, label: string}|null}
61
+ * M4c amendment 3: `ask` (the run's open `ask.json`, may be null; its `expiresAt` is the effective deadline). A saved
62
+ * answer for that ask that was NOT saved in time, once the deadline has passed, is not a resumable answer: it reads
63
+ * as none, so the ask is expired and offers the reopen (M4c-fix amendment 1 (b)). One with no readable time, before
64
+ * the deadline, reads `broken` (amendment 1 (a)).
65
+ * @param {{savedAnswer: {askId:string, decision:string|null, answeredAt?:string|null}|null, attempt: any, ask?: any}} ctx
66
+ * @returns {{state: 'starting'|'not-started'|'broken'|'took-over', askId: string|null, tries: number|null, maxTries: number|null, reason: string|null, label: string}|null}
21
67
  */
22
- export function deriveResumeState({ savedAnswer, attempt }: {
68
+ export function deriveResumeState({ savedAnswer: saved, attempt, ask }: {
23
69
  savedAnswer: {
24
70
  askId: string;
25
71
  decision: string | null;
72
+ answeredAt?: string | null;
26
73
  } | null;
27
74
  attempt: any;
75
+ ask?: any;
28
76
  }): {
29
- state: "starting" | "not-started" | "took-over";
77
+ state: "starting" | "not-started" | "broken" | "took-over";
30
78
  askId: string | null;
31
79
  tries: number | null;
32
80
  maxTries: number | null;
33
81
  reason: string | null;
34
82
  label: string;
35
83
  } | null;
84
+ /**
85
+ * The sign's word and the plain line after the dash. The existing plain line is kept as is; only a line that already
86
+ * opens with the word ("stuck — …") or is the word itself ("passed") loses that repeat, so it is never said twice.
87
+ * `noWord`: a run the human ended on purpose with rerun wears `[✗]` but is never called "failed" (M4b amendment 3),
88
+ * so it shows its plain line alone.
89
+ * @param {string} glyph a `computeGlyph` sign @param {string} label its plain line @param {boolean} [noWord]
90
+ * @returns {{word: string|null, line: string|null}}
91
+ */
92
+ export function signParts(glyph: string, label: string, noWord?: boolean): {
93
+ word: string | null;
94
+ line: string | null;
95
+ };
96
+ /**
97
+ * The ONE decision "is this run stuck, why, and what does it say" (M4c amendment 2 (a), amendment 3 (e), M4c-fix 15,
98
+ * 16). The answer is saved and not yet taken (`resume.state === 'not-started'`: `answer.json` is on disk; the
99
+ * panel's transient 'starting' and the `late` state are not stuck) and nothing is carrying the run on: the newest
100
+ * pid row's process is not alive AND the resume lock is not held by a live process, nor by one whose liveness
101
+ * cannot be told (`unknown`: never called stuck). The reason is typed, derived from the lock file and the saved
102
+ * answer themselves — never from a refusal string, so it is the same after a panel restart. Everything that shows
103
+ * "stuck" (computeGlyph, the Inbox, Runs, the Ask tab) reads this.
104
+ * @param {{resume?: any, liveness?: 'running'|'gone'|'unknown', lock?: string}} ctx
105
+ * @returns {{stuck: false, reason: null, label: null, why: null}|{stuck: true, reason: 'retry'|'lock-no-holder', label: string, why: string|null}}
106
+ */
107
+ export function stuckState({ resume, liveness, lock }: {
108
+ resume?: any;
109
+ liveness?: "running" | "gone" | "unknown";
110
+ lock?: string;
111
+ }): {
112
+ stuck: false;
113
+ reason: null;
114
+ label: null;
115
+ why: null;
116
+ } | {
117
+ stuck: true;
118
+ reason: "retry" | "lock-no-holder";
119
+ label: string;
120
+ why: string | null;
121
+ };
122
+ /** @param {{resume?: any, liveness?: 'running'|'gone'|'unknown', lock?: string}} ctx @returns {boolean} */
123
+ export function isStuck(ctx: {
124
+ resume?: any;
125
+ liveness?: "running" | "gone" | "unknown";
126
+ lock?: string;
127
+ }): boolean;
128
+ /**
129
+ * M4c item 1: does this sign pulse? Only `[▶]` running and `[·]` WAITING ON YOU
130
+ * do, and `[II]` stuck (M4c amendment 2: it is not a final state). The other
131
+ * `[·]` states (answered not resumed, resume starting) are not waiting on the
132
+ * human, so they stay still. The one place that decides.
133
+ * @param {{glyph: string, label: string}} g a `computeGlyph` result
134
+ * @returns {boolean}
135
+ */
136
+ export function glyphPulses(g: {
137
+ glyph: string;
138
+ label: string;
139
+ }): boolean;
36
140
  /**
37
141
  * The glyph + human-words label for one run — ported verbatim (in spirit,
38
142
  * from real derivation, not a shortcut) from `poc/m4/panel-data.mjs`'s
@@ -54,24 +158,36 @@ export function deriveResumeState({ savedAnswer, attempt }: {
54
158
  * - `[·]` answered, not resumed yet — parked, a consumed answer exists, but
55
159
  * no history row yet (resume hasn't finished) — always in words, never
56
160
  * the same line as "waiting on you", never `[?]`.
57
- * - `[?]` died / unknown — no history row, no open ask, no consumed answer:
58
- * `resume.lock` carries no pid and nothing checks liveness (M4a's own
59
- * open POC question), so a crashed resumer and a live one look the same
60
- * on disk. Never guessed into `[✗]` or `[✓]`.
61
- * - `[·]` answer saved, resume not started / starting (M4b amendment 1) —
161
+ * - `[?]` died / unknown — no history row, no open ask, and either the
162
+ * pid row's process is gone (M4c), or there is no pid row / no /proc and
163
+ * the books are older than 10 minutes. Never guessed into `[✗]` or `[✓]`.
164
+ * - `[·]` your answer is saved; the run stopped before using it / starting (M4b amendment 1) —
62
165
  * `answer.json` still on disk (`resume` = `deriveResumeState`): never
63
166
  * "waiting on you" (the human already answered) and never a success.
64
- * @param {{historyRow: any, askJson: any, consumedAnswerExists: boolean, hasStateJson: boolean, resume?: any}} ctx
65
- * @returns {{glyph: '[✓]'|'[✗]'|'[·]'|'[!]'|'[?]', label: string}}
167
+ * - `[▶]` running (M4c) — no end row, no open unanswered ask, and either the
168
+ * newest pid row's process is alive and is fwdloop (`liveness`, src/liveness.js)
169
+ * or (`liveness` unknown) the run's books changed in the last 10 minutes
170
+ * (`booksFresh`). A gone process is `[?]`. Absent `liveness`/`booksFresh`
171
+ * (a direct caller) reads as unknown / not fresh.
172
+ * - `[II]` stuck (M4c amendment 2, `isStuck`) — the answer is saved, not taken,
173
+ * and no live process (pid row or resume lock holder) carries the run on.
174
+ * A saved answer with a live process is `[▶]` working on your answer.
175
+ * - `[?]` crashed after taking your answer (amendment 2 (f)) — the answer was
176
+ * consumed, the process is gone, no end row: cannot be carried on.
177
+ * @param {{historyRow: any, askJson: any, consumedAnswerExists: boolean, hasStateJson: boolean, resume?: any, liveness?: 'running'|'gone'|'unknown', booksFresh?: boolean, lock?: string}} ctx
178
+ * @returns {{glyph: '[✓]'|'[✗]'|'[·]'|'[!]'|'[▶]'|'[?]'|'[II]', label: string}}
66
179
  */
67
- export function computeGlyph({ historyRow, askJson, consumedAnswerExists, hasStateJson, resume, }: {
180
+ export function computeGlyph({ historyRow, askJson, consumedAnswerExists, hasStateJson, resume, liveness, booksFresh, lock, }: {
68
181
  historyRow: any;
69
182
  askJson: any;
70
183
  consumedAnswerExists: boolean;
71
184
  hasStateJson: boolean;
72
185
  resume?: any;
186
+ liveness?: "running" | "gone" | "unknown";
187
+ booksFresh?: boolean;
188
+ lock?: string;
73
189
  }): {
74
- glyph: "[\u2713]" | "[\u2717]" | "[\u00B7]" | "[!]" | "[?]";
190
+ glyph: "[\u2713]" | "[\u2717]" | "[\u00B7]" | "[!]" | "[\u25B6]" | "[?]" | "[II]";
75
191
  label: string;
76
192
  };
77
193
  /**
@@ -282,9 +398,8 @@ export function summarizeSpendRows(spendRows: any[]): {
282
398
  * `GET /api/runs` — every flow under `root`, every run under each flow
283
399
  * (M4a scope item 2). A flow with zero runs still gets one row (`runId:
284
400
  * null`, an explicit `why`) — no flow is silently missing from the list.
285
- * Newest-first by history `at` where known; a row with no history row (died
286
- * or still parked) sorts after every row that has one, in flow/run order
287
- * (a real ordering, never `Date.now()` guessed in for a missing `at`).
401
+ * Ordered by `orderRuns` (waiting on you, running, then newest `at` first; a row
402
+ * with no `at` is never given a guessed one).
288
403
  * @param {{root: string, catalogue: any, resumeAttempt?: (flow: string, runId: string) => any}} opts
289
404
  * `resumeAttempt`: the panel's in-memory resume-attempt lookup (M4b piece 2); absent = none.
290
405
  * @returns {any[]}
@@ -294,6 +409,19 @@ export function listRuns({ root, catalogue, resumeAttempt }: {
294
409
  catalogue: any;
295
410
  resumeAttempt?: (flow: string, runId: string) => any;
296
411
  }): any[];
412
+ /**
413
+ * The ONE ordering of Runs — History and Workflows both render the list in the
414
+ * order given (M4c amendment 1 (c)); a flow's top row is therefore the first
415
+ * run of that flow here, so a waiting run is the parent with no second rule:
416
+ * 1 waiting on you — least time left first; a stuck run (`[II]`, amendment 2)
417
+ * after the ones with a timer;
418
+ * 2 running (`[▶]`, the glyph's own liveness rule);
419
+ * 3 everything else — finish time `at`, newest first.
420
+ * A row with no known time keeps input order at the end of its section.
421
+ * @param {any[]} rows
422
+ * @returns {any[]}
423
+ */
424
+ export function orderRuns(rows: any[]): any[];
297
425
  /**
298
426
  * `GET /api/runs/:flow/:runId` — the Run tab (M4a scope item 2): the step
299
427
  * map from `declaration.steps`, step cards -> attempts from `audit.jsonl`
@@ -428,6 +556,20 @@ export function deriveAskStepInfo(orderedAsks: any[], auditRows: any[], declStep
428
556
  line: number | null;
429
557
  why: string | null;
430
558
  }>;
559
+ /**
560
+ * M4c item 5 — the Ask tab's ONE grouping function: one block per signed ask
561
+ * line. Key = the archive's recorded `emits`, else the step the ask's own "paused" audit row names (`stepName`,
562
+ * `deriveAskStepInfo`); when the books cannot name a step (count mismatch, a
563
+ * pre-M4a-1 run) the key falls back to the question text, then to one shared
564
+ * "unknown" key — never a guessed pairing. Draft numbers are the ask's 1-based
565
+ * position within its own block (how many times this line has parked).
566
+ * `current` is the newest draft; `answers` is one row per draft that has a
567
+ * recorded decision (the newest draft only when it is not itself open),
568
+ * decision word via `DECISION_STATUS` (old `reject` files already read `redo`).
569
+ * @param {any[]} asks rows as built by `getRunAsks` (oldest first)
570
+ * @returns {any[]}
571
+ */
572
+ export function groupAskBlocks(asks: any[]): any[];
431
573
  /**
432
574
  * `GET /api/runs/:flow/:runId/asks` — the Ask tab (M4a-1 scope item 1):
433
575
  * every ask this run's books can name, in order, each carrying full
@@ -443,7 +585,7 @@ export function deriveAskStepInfo(orderedAsks: any[], auditRows: any[], declStep
443
585
  * detail carries, `null` for a finished run or nothing to say) so the Ask tab
444
586
  * can tell "open, answerable" from "answer saved" without a second fetch.
445
587
  * @param {{root: string, flow: string, runId: string, catalogue: any, resumeAttempt?: (flow: string, runId: string) => any}} opts
446
- * @returns {{flow:string, runId:string, asks:any[], resume: any}|null}
588
+ * @returns {{flow:string, runId:string, asks:any[], resume: any, blocks: any[]}|null}
447
589
  */
448
590
  export function getRunAsks({ root, flow, runId, catalogue, resumeAttempt, }: {
449
591
  root: string;
@@ -456,6 +598,7 @@ export function getRunAsks({ root, flow, runId, catalogue, resumeAttempt, }: {
456
598
  runId: string;
457
599
  asks: any[];
458
600
  resume: any;
601
+ blocks: any[];
459
602
  } | null;
460
603
  /**
461
604
  * `GET /api/inbox` — every stop (parked ask, open or past) across every
@@ -479,6 +622,53 @@ export function listStops({ root, resumeAttempt }: {
479
622
  root: string;
480
623
  resumeAttempt?: (flow: string, runId: string) => any;
481
624
  }): any[];
625
+ /**
626
+ * The ONE ordering of the Inbox (M4c item 4, hamr 2026-09-30); the page renders
627
+ * in the order given and stamps each row's `section`:
628
+ * 1 waiting on you — least time left first ("runs out first"); a stuck run
629
+ * (amendment 2: answer saved, nobody carrying it on) after the timed asks;
630
+ * 2 working on an answer you gave (`working`), or answer saved and resume not
631
+ * started (`resume`) — newest answer first;
632
+ * 3 answered and expired asks — newest first (answeredAt, else expiresAt).
633
+ * A row with no known time sorts last within its section, ties by input order.
634
+ * @param {any[]} rows
635
+ * @returns {any[]}
636
+ */
637
+ export function orderStops(rows: any[]): any[];
638
+ /**
639
+ * N for `Inbox (N)` (M4c item 3): asks open and not expired, across every flow
640
+ * and run, plus stuck runs (amendment 2: the human must act). An answered ask
641
+ * whose resume is carried on is not `waiting`, so not counted; a crashed one
642
+ * (answer taken, process gone) is not stuck and not counted;
643
+ * an expired ask is not `open`. The page only shows this number.
644
+ * @param {any[]} rows `listStops` rows
645
+ * @returns {number}
646
+ */
647
+ export function inboxOpenCount(rows: any[]): number;
482
648
  /** What the `resume` field says when the panel has no attempt record for a run
483
649
  * (it restarted since the answer was saved) — said so, never blank. */
484
650
  export const RESUME_REASON_UNKNOWN: "reason unknown: the panel restarted, so it has no record of the resume attempt";
651
+ export const WAITING_LABEL: "waiting on you (parked, unanswered)";
652
+ export const STUCK_LABEL: "stuck \u2014 your answer is saved; the run stopped before using it";
653
+ export const STUCK_LOCK_LABEL: "stuck \u2014 an old resume lock is in the way";
654
+ export const BROKEN_LABEL: "Your saved answer could not be read.";
655
+ export const BROKEN_ANSWER_WHY: "Please answer again; the broken one is kept aside.";
656
+ export const CRASHED_LABEL: "crashed after taking your answer \u2014 start a fresh run";
657
+ /**
658
+ * M4c-fix amendment 2 (g): the ONE table from a sign to its bold word. Runs, the Inbox and the run header all show
659
+ * the word this table gives (the server stamps it on every row; the page never invents one).
660
+ * @type {Record<string, string>}
661
+ */
662
+ export const SIGN_WORDS: Record<string, string>;
663
+ /** The typed reasons a stuck run can have. `retry`: nothing is wrong that the books name, so trying again is the
664
+ * action. `lock-no-holder`: the resume lock has no recorded holder, so trying again can never work. */
665
+ export const STUCK_REASONS: {
666
+ retry: {
667
+ label: string;
668
+ why: null;
669
+ };
670
+ 'lock-no-holder': {
671
+ label: string;
672
+ why: string;
673
+ };
674
+ };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Remove `<runDir>/resume.lock`, only if at THIS moment it has no recorded holder (`readResumeLock` -> `empty`;
3
+ * a live, dead or unknowable holder is never touched), and only if the lock file really sits inside this run dir
4
+ * (realpath of the run dir against realpath of `--root` at use time; a symlinked lock is unlinked as the link itself,
5
+ * never followed).
6
+ * Then one audit row through the one audit writer, shaped like the `ask-reopened` row (a pure note: cost 0, no model).
7
+ * @param {{root: string, runDir: string, nowIso?: string}} a
8
+ * @returns {{ok: true, at: string}|{ok: false, refused: 'no-lock'|'lock-has-holder'|'lock-outside-run', red: string}}
9
+ */
10
+ export function removeOldLock({ root, runDir, nowIso }: {
11
+ root: string;
12
+ runDir: string;
13
+ nowIso?: string;
14
+ }): {
15
+ ok: true;
16
+ at: string;
17
+ } | {
18
+ ok: false;
19
+ refused: "no-lock" | "lock-has-holder" | "lock-outside-run";
20
+ red: string;
21
+ };
@@ -40,6 +40,10 @@ export function createResumer(opts: {
40
40
  logPath: null;
41
41
  superseded: boolean;
42
42
  };
43
+ /** True while this run is already resuming: a resume child of this panel is alive for it, or its
44
+ * latest attempt is still starting (between tries). Routes refuse a second resume while true.
45
+ * @param {string} flow @param {string} runId */
46
+ busy(flow: string, runId: string): boolean;
43
47
  /** A copy of the run's attempt record, or null (none yet, or the panel restarted).
44
48
  * @param {string} flow @param {string} runId */
45
49
  get(flow: string, runId: string): any;
@@ -1,3 +1,29 @@
1
+ /**
2
+ * hamr's 2026-10-03 ruling "1A": the panel token is REUSED across restarts, so a bookmark of
3
+ * `http://127.0.0.1:<port>/` keeps working once the link was opened. Reads the token file (same path
4
+ * `writeTokenFile` writes); a new token only when the file is missing, unreadable, not a regular file,
5
+ * not mode 0600, not ours, or not 64 hex chars (the caller then rewrites it 0600).
6
+ * @param {{ port: number, dir?: string, env?: Record<string, string|undefined> }} a
7
+ * @returns {string}
8
+ */
9
+ export function loadOrMakeToken({ port, dir, env }: {
10
+ port: number;
11
+ dir?: string;
12
+ env?: Record<string, string | undefined>;
13
+ }): string;
14
+ /**
15
+ * M4c-fix item 2: the token's one on-disk home — `<dir>/panel-<port>.token`, dir 0700, file 0600,
16
+ * `dir` = `$XDG_RUNTIME_DIR/fwdloop`, else `~/.cache/fwdloop`. Refuses a dir that is a symlink or
17
+ * not ours. The file is replaced (unlink, then exclusive create at 0600), never rewritten in place,
18
+ * so it never exists with a looser mode. Returns the file's path.
19
+ * @param {{ port: number, token: string, dir?: string, env?: Record<string, string|undefined> }} a
20
+ */
21
+ export function writeTokenFile({ port, token, dir, env, }: {
22
+ port: number;
23
+ token: string;
24
+ dir?: string;
25
+ env?: Record<string, string | undefined>;
26
+ }): string;
1
27
  /**
2
28
  * Handle one request against the API + the page. Exported
3
29
  * separately from {@link createPanelServer} so tests can drive it without a
@@ -18,13 +44,14 @@ export function handleRequest(req: import("node:http").IncomingMessage, res: imp
18
44
  * header). Resolves once actually listening; rejects on a bind error
19
45
  * (including `EADDRINUSE`) with a `.port` field on the error for the
20
46
  * caller's message.
21
- * @param {{ port?: number, root: string, resume?: { env?: Record<string,string|undefined>, bin?: string, logDir?: string, maxTries?: number, windowMs?: number, slotMs?: number } }} opts
47
+ * @param {{ port?: number, root: string, token?: string, resume?: { env?: Record<string,string|undefined>, bin?: string, logDir?: string, maxTries?: number, windowMs?: number, slotMs?: number } }} opts
22
48
  * `resume` is for tests only (a fake env/bin, a short retry window); the CLI passes none.
23
- * @returns {Promise<{ server: import('node:http').Server, port: number, close: () => Promise<void> }>}
49
+ * @returns {Promise<{ server: import('node:http').Server, port: number, token: string, close: () => Promise<void> }>}
24
50
  */
25
51
  export function createPanelServer(opts: {
26
52
  port?: number;
27
53
  root: string;
54
+ token?: string;
28
55
  resume?: {
29
56
  env?: Record<string, string | undefined>;
30
57
  bin?: string;
@@ -36,6 +63,7 @@ export function createPanelServer(opts: {
36
63
  }): Promise<{
37
64
  server: import("node:http").Server;
38
65
  port: number;
66
+ token: string;
39
67
  close: () => Promise<void>;
40
68
  }>;
41
69
  /**
package/types/runner.d.ts CHANGED
@@ -184,9 +184,10 @@ export function makeParkingAskStep(): (opts?: any) => Promise<{
184
184
  }>;
185
185
  /**
186
186
  * M3 scope items 4-6: re-enter a parked run's SAME fold from a separate
187
- * process. Takes an exclusive `resume.lock` (refuses by name if already
188
- * held; a lock left behind by a killed resumer is a red naming it, never
189
- * stolen), re-reads the flow, refuses by name at $0 on any signature/input/
187
+ * process. Takes an exclusive `resume.lock` that records its holder's
188
+ * `{pid, procStart}` (M4c amendment 2: refuses by name if the holder is alive
189
+ * or the lock has no readable holder; a lock whose holder is gone is cleared
190
+ * and retaken, losing cleanly on a race), re-reads the flow, refuses by name at $0 on any signature/input/
190
191
  * missing-artifact mismatch, consumes `answer.json` by atomic rename BEFORE
191
192
  * acting (F44), then either cancels an expired ask ($0, nothing sent) or
192
193
  * resolves it and folds on to `complete`/the next pause/a halt.