@cotal-ai/runtime 0.41.4 → 0.42.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,7 +1,8 @@
1
- import { type CheckpointRef, type CheckpointSettleFact } from "@cotal-ai/core";
1
+ import { type CheckpointRef, type CheckpointSettleFact, type EpCaller } from "@cotal-ai/core";
2
+ import type { NatsConnection } from "@nats-io/transport-node";
2
3
  import type { JetStreamClient, JetStreamManager } from "@nats-io/jetstream";
3
- import type { KV } from "@nats-io/kv";
4
- import { EffectRefused, type WaitRequest, type CheckpointRaw, type CheckpointRequest, type EffectContext, type JournalEntry, type NotifyRequest, type SleepRequest } from "@cotal-ai/lang";
4
+ import { type KV } from "@nats-io/kv";
5
+ import { type AskRequest, type AgentHandleValue, type ChannelHandleValue, type ConclaveRequest, type WaitRequest, type CheckpointRaw, type CheckpointRequest, type EffectContext, type JournalEntry, type MonitorRequest, type NotifyRequest, type SleepRequest, type SpawnRequest, type TurnRequest, type TurnResultValue } from "@cotal-ai/lang";
5
6
  /** Who this handler acts as, and where. All of it is the DRIVER's identity, not the program's. */
6
7
  export interface MeshHandlerBinding {
7
8
  readonly space: string;
@@ -18,6 +19,14 @@ export interface MeshHandlerBinding {
18
19
  * the caller hands `drive()` a run id and a handler together.
19
20
  */
20
21
  readonly runId: string;
22
+ /**
23
+ * The caller triple this run's durable ACTIONS ride: goal facts key on
24
+ * `epf.<e>.goal.<owner>.<actor>.<uid>.<goalId>.result`, so the triple that submits a spawn must
25
+ * be the triple that reads its terminal back after a crash — on any host, at any epoch. It is
26
+ * therefore RUN-STABLE by contract: derive it from the run id (the run-command derivation), never
27
+ * from the process identity, or a resumed run polls a subject its own submission never wrote.
28
+ */
29
+ readonly caller: EpCaller;
21
30
  readonly instanceId: string;
22
31
  readonly epoch: number;
23
32
  /**
@@ -63,14 +72,67 @@ export interface SettleWatcher {
63
72
  */
64
73
  awaitSettle(ref: CheckpointRef): Promise<CheckpointSettleFact>;
65
74
  }
75
+ /**
76
+ * The one subject the remaining seam is gated by: `turn` and `wait(replied)` both ride the turn
77
+ * machinery an agent handle answers through (`spawn`, `conclave`, `ask`, `monitor` and
78
+ * `wait(down)` perform). Named once so the refusals cannot drift apart.
79
+ */
66
80
  export declare class MeshHandler {
81
+ private readonly nc;
67
82
  private readonly kv;
68
83
  private readonly js;
69
84
  private readonly jsm;
70
85
  private readonly binding;
71
86
  private readonly watcher;
72
87
  private readonly clock;
73
- constructor(kv: KV, js: JetStreamClient, jsm: JetStreamManager, binding: MeshHandlerBinding, watcher: SettleWatcher, clock?: () => number);
88
+ constructor(nc: NatsConnection, kv: KV, js: JetStreamClient, jsm: JetStreamManager, binding: MeshHandlerBinding, watcher: SettleWatcher, clock?: () => number);
89
+ /**
90
+ * The resolved manager service, memoized as a PROMISE so concurrent branches share one describe
91
+ * round-trip — and dropped on failure, so a resolve that lost to a manager restart is retried by
92
+ * the next effect instead of poisoning every spawn for the handler's lifetime.
93
+ */
94
+ private managerService;
95
+ private manager;
96
+ /** The branded goal-fact context over this handler's own connection, memoized the same way. */
97
+ private actions;
98
+ private actionCtx;
99
+ private presenceKvOpen;
100
+ private presenceRegistry;
101
+ private membersKvOpen;
102
+ private membersRegistry;
103
+ private channelsKvOpen;
104
+ private channelRegistry;
105
+ /** The chat stream's current last sequence — a conclave join/leave cursor (SPEC §7 interval). */
106
+ private chatFrontier;
107
+ /** The open conclaves this process performed, keyed by the scope's request id, so the close that
108
+ * follows the body reads the SAME plan the open executed. A crash loses the map and loses
109
+ * nothing: the plan was bound as the entry's external state before a single row was written,
110
+ * and a re-entered open repopulates the map from `ctx.resume`. */
111
+ private readonly conclaves;
112
+ /** The run's roster: every agent this run spawned, by name — the handle a handoff resolves to,
113
+ * and the owner/actor address a `turn` targets (absent when the spawn's acceptance floor was
114
+ * never served; a `turn` on such an agent refuses loudly rather than guessing an address).
115
+ * Seeded live by `spawn`, rebuilt at adoption from the journal's settled spawn entries. */
116
+ private readonly roster;
117
+ /** Turns this run has dispatched per handle composite, live and seeded — what a `turns` permit is spent against. */
118
+ private readonly turnsTaken;
119
+ /** Handle composites a `monitor` registered, live and seeded — what makes `down(agent)` observable. */
120
+ private readonly monitored;
121
+ /** The most recent unhonored handoff yield per SCOPE (lang §5.3): the goal-chain linkage memo.
122
+ * `"ambiguous"` when two pending handoffs in one scope named the same agent — ambiguity records
123
+ * no linkage at all. Spent (deleted) by the next `turn` in the scope, honored or not: honoring
124
+ * is immediate-only. Rebuilt at adoption by replaying the same two rules over the journal. */
125
+ private readonly handoffMemos;
126
+ /** This run's turn goals per handle composite ("name#uid") — the observable `wait(replied)`
127
+ * rides. Fed by `turn` at submission and adoption, reseeded from journal turn entries. */
128
+ private readonly turnGoals;
129
+ /** The last agent this run spawned into each logical worktree — what the L4008 guard reads.
130
+ * Fed by `spawn` and reseeded from journal spawn results at adoption. */
131
+ private readonly worktreeHolders;
132
+ /** Seats a committed migration handed to this program under `--adopt`, keyed by persona and
133
+ * handed out in journal order: the next `spawn` of that persona receives the recorded seat
134
+ * instead of minting one. Fed by {@link adoptMigratedSeats}; spent by `spawn`. */
135
+ private readonly adoptable;
74
136
  now(): number;
75
137
  /**
76
138
  * WHAT to repair when this process takes a run over. The driver decides WHEN and calls this.
@@ -83,6 +145,104 @@ export declare class MeshHandler {
83
145
  * cannot advance it.
84
146
  */
85
147
  adopted(entries: readonly JournalEntry[]): Promise<string[]>;
148
+ /**
149
+ * Hand this program the seats a committed migration kept for it under `--adopt` (spec §11.2).
150
+ * The orphaned spawn's settled entry is the whole hand-over: the next `spawn` of its persona
151
+ * returns that entry's handle, binds that entry's floor, and submits nothing, so the seat keeps
152
+ * its identity, its worktree and its turn history across the edit. Called by the driver on the
153
+ * migrated run before the program runs; a map with no entry for a persona changes nothing.
154
+ */
155
+ adoptMigratedSeats(seats: ReadonlyMap<string, readonly JournalEntry[]>): void;
156
+ /**
157
+ * Rebuild the in-memory run memos an adopted run needs to keep performing `turn`: the roster
158
+ * (from every settled ok `spawn`, its result the handle and its bound floor the address), the
159
+ * worktree holders (a settled spawn holds its tree by identity, a spawn still in flight by the
160
+ * reservation its bound request took) and the handoff memos (replaying, in journal order, the
161
+ * same two rules the live path applies — a turn's begin spends its scope's memo, a settled
162
+ * handoff yield writes one, a second pending handoff to the same name in one scope makes it
163
+ * ambiguous). Deterministic from the journal alone.
164
+ */
165
+ private seedRunMemos;
166
+ /**
167
+ * The runtime half of "two agents MUST NOT share a worktree concurrently" (spec 6.5; the
168
+ * validator owns the literal case as L3022). The registry records who holds each logical
169
+ * worktree this run spawned into — the live seat, or the spawn still bringing one up — and a
170
+ * new spawn CLAIMS the tree here before anything is submitted: a tree nobody holds is taken in
171
+ * the same synchronous step that read it, so two branches spawning into one computed id cannot
172
+ * both pass; a tree held by a spawn in flight refuses; a tree held by a seat is admitted only
173
+ * when that holder is no longer live on presence, and re-read after the liveness wait, because
174
+ * a sibling may have claimed it meanwhile. Sequential reuse is legal, concurrency is data loss.
175
+ * The liveness read is the same witness `wait(down)` and a conclave join use, so "still
176
+ * holding" and "down" are one definition — a discharged loser or a crashed seat releases its
177
+ * tree the moment its presence row is gone, with no bookkeeping of its own.
178
+ */
179
+ private claimWorktree;
180
+ /** One turn goal registered under its handle composite — what `wait(replied)` observes. */
181
+ private recordTurnGoal;
182
+ /** One handoff yield's memo write: most-recent-wins across different names, ambiguous when a
183
+ * pending handoff to the SAME name is already waiting (lang §5.3 — ambiguity records nothing). */
184
+ private recordHandoffMemo;
185
+ /**
186
+ * End the external state of a cancelled scope's LOSERS: the world half of the discharge the
187
+ * scope entry's `cancel.issued` records (§7.6, and the driver's `dischargeCancellations` is the
188
+ * caller). The entries handed in are the losers' subtrees; what has external state to end is the
189
+ * three pause kinds — a pause's timer is claimed so its armed schedule cannot fire into a run
190
+ * that moved on, and a wait's durable consumer is deleted because a cancelled wait replays as
191
+ * cancelled and nothing will ever read its position.
192
+ *
193
+ * IDEMPOTENT BY THE PLANE: `cancelTimer` declines a pause that is not waiting, the consumer
194
+ * delete tolerates one already gone, and both tolerate a loser that cleaned up after itself on
195
+ * the live path — this is the durable backstop for the process that died before its own cleanup
196
+ * landed, and the flip to `issued: true` happens only after it returns.
197
+ */
198
+ discharge(entries: readonly JournalEntry[]): Promise<void>;
199
+ /**
200
+ * Withdraw a cancelled `notify`'s undelivered notices.
201
+ *
202
+ * A notice is world state exactly as a live seat or an armed timer is: it sits on the run
203
+ * waiting to be rendered ahead of its addressee's next turn. A branch the run cancelled decided
204
+ * nothing, and a decision the run withdrew must not arrive at an agent afterwards — which is
205
+ * what happened, because the discharge released seats, memberships and timers and walked past
206
+ * this one kind.
207
+ *
208
+ * Withdrawn is spelled as CONSUMED, by the discharge rather than by a turn. The notice's status
209
+ * is a closed record with one meaning — this notice will not be delivered again — and that is
210
+ * the fact being recorded; `by` says which cancelled step withdrew it, so a reader tracing a
211
+ * notice finds the withdrawal instead of a delivery that never happened. It also puts the
212
+ * migration verdict where it belongs: an orphaned `notify` is rejected only while its notice is
213
+ * still owed to somebody, and this one is not owed to anybody any more.
214
+ *
215
+ * IDEMPOTENT BY THE PLANE, like the rest of the discharge: the consumption write is create-only,
216
+ * so a notice a turn already carried, or that an earlier discharge pass already withdrew, is
217
+ * left exactly as it is.
218
+ */
219
+ private dischargeNotify;
220
+ /**
221
+ * Release a cancelled spawn's AGENT (§8.6.4): the world half a loser `spawn` leaves behind is a
222
+ * seat the run will never address, so the discharge despawns it. The goal's identity re-derives
223
+ * from the entry alone — the request id IS the goalId (the pinned envelope id) unless the entry
224
+ * bound another (an adopted seat's), and the caller triple is run-stable — so a crash before the
225
+ * acceptance was even bound still finds its goal.
226
+ *
227
+ * The terminal is what says whether a seat exists. No goal at all: the submission never landed,
228
+ * nothing to release. Accepted but not terminal: the manager owes a terminal within the accepted
229
+ * readiness window, so this waits it out (bounded by the recorded window plus one poll of slack)
230
+ * and THROWS if none lands — an unfinished discharge must not be flipped to `issued`, and the
231
+ * driver's next sweep retries idempotently. `succeeded` and `uncertain` both despawn (an
232
+ * uncertain readiness verdict leaves the process running); `failed` was reaped by the manager
233
+ * and `cancelled` means a despawn already drove the teardown, so both are already released.
234
+ */
235
+ private dischargeSpawn;
236
+ /**
237
+ * Release a cancelled conclave's MEMBERSHIP (spec §7.5): a cancelled body performs no new
238
+ * effect, so it never closed its room, and the release travels this recovery path like every
239
+ * other branch-local resource. The entry's own `closed` fact is the gate — a conclave whose
240
+ * body failed but whose close acknowledged holds nothing. An entry with no bound plan created
241
+ * nothing (rows are written only after the bind), so there is nothing to release and no retry
242
+ * that could learn more. Failures are raised: an unfinished release must not be flipped to
243
+ * `issued`, and the driver's next sweep retries idempotently.
244
+ */
245
+ private dischargeConclave;
86
246
  /**
87
247
  * `sleep` is a checkpoint nobody answers.
88
248
  *
@@ -105,6 +265,13 @@ export declare class MeshHandler {
105
265
  * It returns the RAW outcome and never the program's result. Whether an expiry throws or returns
106
266
  * is `onExpiry`, which is computed from today's source on the live path and the replay path
107
267
  * alike; deciding it here would bake one answer into the journal.
268
+ *
269
+ * WHAT IT ASKS IS BOUND ON THE ENTRY, and that is not decoration. A pause the reference calls
270
+ * "a durable pause a human or an agent resolves from anywhere" is answered by address (`run`
271
+ * plus step key), and the prompt lived only in the source: everything durable held the input
272
+ * HASH, so whoever was asked saw a token and had to go find the program to learn the question.
273
+ * `to` rides with it for the same reason — an escalation names an addressee, and an addressee
274
+ * nothing records is an addressee nobody can be shown.
108
275
  */
109
276
  checkpoint(req: CheckpointRequest, ctx: EffectContext): Promise<CheckpointRaw>;
110
277
  /**
@@ -119,10 +286,56 @@ export declare class MeshHandler {
119
286
  * resumed 20-minute wait with 30 seconds left has 30 seconds left. A timeout resolves `null` and
120
287
  * never throws: `??` is `otherwise`.
121
288
  *
122
- * `replied(agent)` and `down(agent)` are not here. They address an agent handle, which only
123
- * `spawn` produces, so they refuse through the same named seam as the durable actions.
289
+ * `down(agent)` and `replied(agent)` are agent-addressed events with no channel, so they branch
290
+ * to `waitDown` and `waitReplied` before any of the channel machinery.
124
291
  */
125
292
  wait(req: WaitRequest, ctx: EffectContext): Promise<unknown | null>;
293
+ /**
294
+ * `wait(down(agent))` — the death of one incarnation, read off presence liveness.
295
+ *
296
+ * The handle pins `<name>#<lifecycleUid>` and DOWN is a fact about the INCARNATION. The mesh's
297
+ * liveness witness is the presence row a seat heartbeats — TTL'd out of the bucket when the
298
+ * heartbeats stop — and it is the same source conclave membership resolves members through, so
299
+ * "down" here and "down or gone" at a conclave join are one definition. No live row carrying
300
+ * the name AND this incarnation is the death, with the reason split by what the name shows now:
301
+ * `"lapsed"` when nothing live holds the name any more, `"superseded"` when a live row holds it
302
+ * under a DIFFERENT incarnation — this incarnation dead with a successor already up.
303
+ *
304
+ * NOTHING BINDS, because a death is re-observable where a matched message is not: a lifecycle
305
+ * uid is minted once per incarnation and never heartbeats again after its row lapses, so a
306
+ * crash between the observation and the settle re-observes the same death on resume — at worst
307
+ * with the reason upgraded from `"lapsed"` to `"superseded"` by a successor that appeared in
308
+ * between. `at` is the time of OBSERVATION: presence records no time of death, and inventing
309
+ * one would be a value the planes cannot back.
310
+ *
311
+ * The TIMEOUT is the same mediated pause every wait arms — minted once with an absolute
312
+ * deadline under the step's own request id, so a resume ATTACHES to the recorded deadline
313
+ * rather than restarting the clock — and it resolves `null`, never a throw: `??` is
314
+ * `otherwise`. The discharge and the adoption re-arm already speak this wait's tokens (the
315
+ * `wait` kind arms under its request id), so a cancelled or adopted down-wait needs nothing of
316
+ * its own.
317
+ */
318
+ private waitDown;
319
+ /**
320
+ * `wait(replied(agent))` — the agent finished a reply, observed over THIS RUN's turn terminals.
321
+ *
322
+ * The honest observable a run holds for "finished a reply" is the terminal fact of a turn it
323
+ * relayed itself: a `succeeded` turn goal IS a completed reply, durable on the goal plane. The
324
+ * wait resolves off the run's turn-goal registry for the handle — fed by `turn` at submission
325
+ * and reseeded from the journal on adoption — and REPLIED IS A LEVEL, exactly as `down` is: a
326
+ * reply that already exists resolves the wait at once (the latest, by the yield's own `at`
327
+ * stamp), and a wait that begins before any reply parks for the next terminal. A denied or
328
+ * cancelled turn is not a reply — the agent never finished one — so it leaves the wait parked.
329
+ * A handle outside the run's roster with no recorded turn can never be observed (only this
330
+ * run's turns are), so it refuses loudly instead of parking on nothing.
331
+ *
332
+ * NOTHING BINDS, for `down`'s reason: goal terminals are durable facts, so a crash between the
333
+ * observation and the settle re-observes the same reply on resume — at worst a NEWER reply
334
+ * completed in between. The value is the observation record, `down`-shaped:
335
+ * `{ agent, status, note?, at }`, where `at` is the yield's own stamp. The TIMEOUT is the same
336
+ * mediated pause every wait arms, resolving `null`, never a throw.
337
+ */
338
+ private waitReplied;
126
339
  /**
127
340
  * `notify` writes one bounded decision record per addressee, onto the run.
128
341
  *
@@ -134,39 +347,242 @@ export declare class MeshHandler {
134
347
  * **One call to N agents is N records, and a retry lands on its own.** The id is derived from the
135
348
  * step's request id and the addressee, so a crash between the second and third write is repaired
136
349
  * by re-running the call: the first two creates find their own bytes and return, the third
137
- * happens. Nothing is written twice and nothing needs a memo of how far it got.
350
+ * happens. Nothing is written twice and nothing needs a memo of how far it got. That holds only
351
+ * because the instant every notice carries is bound with the step rather than read from the
352
+ * clock again, which is the one field a second pass could otherwise change.
138
353
  *
139
354
  * The fact's bound is the language's and is enforced BEFORE this is reached (L3043 at the effect
140
355
  * boundary), so a fact that could not be rendered as one table row cannot arrive here.
141
356
  */
142
357
  notify(req: NotifyRequest, ctx: EffectContext): Promise<null>;
143
- spawn(_req: unknown, _ctx: EffectContext): Promise<never>;
144
- turn(_req: unknown, _ctx: EffectContext): Promise<never>;
145
- ask(_req: unknown, _ctx: EffectContext): Promise<never>;
146
- monitor(_req: unknown, _ctx: EffectContext): Promise<never>;
147
358
  /**
148
- * A conclave, refused with the rest and this one is an OVER-refusal, stated rather than hidden.
359
+ * `spawn` is the manager's spawn ACTION, submitted under the step's own identity.
360
+ *
361
+ * **The request id is the goalId.** The envelope id is pinned to `ctx.requestId`, and the
362
+ * manager binds its goal under the envelope id — so a resumed run that re-submits is served the
363
+ * RECORDED acceptance (same fingerprint, same goal) instead of allocating a second seat, and the
364
+ * goal's terminal fact sits on a subject this run can re-derive from nothing but its journal.
365
+ *
366
+ * The ACCEPTANCE is bound as the entry's external state before the terminal is awaited, so a
367
+ * crash mid-await resumes straight into the poll — it must NOT re-invoke, because by then the
368
+ * manager may have restarted and a fresh submission would be judged against a live seat rather
369
+ * than served from its acceptance cache. The terminal await itself is a read of a durable fact,
370
+ * deliberately not `submitAndFollowGoal`: a live progress subscription dies with the process,
371
+ * and the fact is the thing a resume can still read.
372
+ *
373
+ * `permits`, `supervise` and `onFork` are POLICY, not identity (§6.4): they ride the journalled
374
+ * request and are enforced where they bind (`permits` at `turn`, `supervise` by `monitor`, an
375
+ * `onFork` at fork adoption) — nothing about them travels in the submission.
376
+ */
377
+ spawn(req: SpawnRequest, ctx: EffectContext): Promise<AgentHandleValue>;
378
+ /**
379
+ * A spawn that ends without a handle gives its tree back. The one exception is a cancellation
380
+ * while parked on an ACCEPTED submission: the seat may well be up in the tree until its
381
+ * discharge lands, so the reservation becomes a hold by the accepted identity, which presence
382
+ * liveness then releases the way it releases any holder.
383
+ */
384
+ private releaseWorktree;
385
+ /** Poll the goal's durable terminal fact, observing cancellation on the poll cadence — the same
386
+ * discipline as `wait`: a race decided against this branch stops parking within one poll, and
387
+ * the seat its acceptance may have produced is the DISCHARGE's to release, not this branch's. */
388
+ private goalTerminal;
389
+ /**
390
+ * `turn` wakes ONE AGENT for one turn, over the manager's relay (a seat is not an endpoint):
391
+ * the manager accepts the goal, parks the rendered context durably, the seat pulls and yields
392
+ * under its own self reach, and the yield is this goal's terminal. The request id is the goalId,
393
+ * the same recovery discipline as `spawn`: a resumed run re-enters the poll, never re-submits.
394
+ *
395
+ * THREE AUTHORITIES END IT, one per ending. The seat's yield is the manager's `succeeded`
396
+ * terminal, carrying the TurnResult. The DEADLINE is double-covered: the manager arms a
397
+ * goal-bound hold (its expiry commits `failed` reason `turn-deadline`), and this client arms its
398
+ * OWN pause under the step's request id — the L4003 authority that survives a dead manager.
399
+ * DEATH likewise: the manager's reap hook fails pending turns `agent-down`, and this client
400
+ * watches presence itself (the L4002 authority when the manager died with the seat).
401
+ *
402
+ * Handoff honoring (lang §5.3) happens HERE: the scope's pending memo is spent at every turn's
403
+ * begin, and when this turn targets its `to`, the link rides the submission (`handoffFrom`, the
404
+ * manager mirrors it into the terminal) and the bound external state. A handoff YIELD is
405
+ * validated against the run roster: an addressee outside it is L4005, one in a different
406
+ * worktree is L4004.
407
+ */
408
+ turn(req: TurnRequest, ctx: EffectContext): Promise<TurnResultValue>;
409
+ /** Map a turn goal's terminal onto the effect's contract: `succeeded` carries the TurnResult
410
+ * (a handoff addressee resolved against the roster — L4005 outside it, L4004 across
411
+ * worktrees), `failed` splits on the manager's recorded reason, `cancelled` unwinds. The
412
+ * consumed notices are marked HERE, by the goal that carried them, tolerating the re-entry
413
+ * conflict (a crash between the terminal and the mark re-marks on resume). */
414
+ /**
415
+ * A yielded handoff's refusal class: L4005 when the addressee is not in this run's roster,
416
+ * L4004 when it sits in a different worktree than the seat handing off, undefined when the
417
+ * handoff is honorable. One reading for the turn that raises it and the `wait(replied)` that
418
+ * must not count it, so the two observers never diverge on a spoofed or misdirected `to`.
419
+ */
420
+ private handoffRefusal;
421
+ private turnOutcome;
422
+ /**
423
+ * `ask` is a schema-checked pause the ADDRESSED AGENT is expected to answer.
424
+ *
425
+ * Each attempt is one checkpoint-plane pause — the same mint, settle and answer record a
426
+ * `checkpoint` rides, answered through the run driver's `resolveCheckpoint` (`cotal run
427
+ * answer`), which is how "the agent publishes a record" reaches a holder-bound plane: the agent,
428
+ * or anyone the run's ACL admits on its behalf, answers through the driver exactly as a human
429
+ * answers a checkpoint. What `ask` adds is the handler-side contract of §6.5: the schema is read
430
+ * as the SHORTHAND (refused L4022 when it cannot be), every answer is checked against it, a
431
+ * non-conforming answer costs one attempt and the refusal reason is bound onto the entry for the
432
+ * answerer to read, and exhausted attempts are the effect's own catchable L4006.
433
+ *
434
+ * **One absolute deadline for the whole ask**, computed once and bound with the first attempt: a
435
+ * re-ask does not restart the clock, or a stream of non-conforming answers could stretch the
436
+ * pause forever. The deadline elapsing with no conforming answer is the ask's own L4006, the
437
+ * same outcome exhausted attempts name: the budget it ran out of is the ask's, and L4003 belongs
438
+ * to a `turn` whose own deadline elapsed.
439
+ *
440
+ * **Attempt N's token derives from the step's request id** (attempt 1 IS the request id), and
441
+ * the CURRENT attempt's token is bound as `askToken` before its pause is armed — so a resume
442
+ * re-enters the attempt in flight, an answer judged non-conforming just before a crash is
443
+ * re-judged identically from its durable settle, and the discharge and the adoption re-arm
444
+ * address the one timer that is actually armed.
445
+ */
446
+ ask(req: AskRequest, ctx: EffectContext): Promise<unknown>;
447
+ /**
448
+ * One ask attempt's relay to the addressed seat: a `turn` goal under the attempt's token whose
449
+ * payload carries the ask (token, schema, attempt, deadline, the previous refusal), rendered by
450
+ * the seat's connector as the request to answer. The goal is the seat's to yield when it has
451
+ * answered; the ask itself settles on the checkpoint plane, so the relay's terminal is never
452
+ * read here, and it is never a reply `wait(replied)` observes. A seat the serve boundary reports
453
+ * gone is the agent-down failure (L4002).
454
+ */
455
+ private askSeat;
456
+ /**
457
+ * Where a relay to an agent of this run is addressed: the roster entry under the handle's name,
458
+ * at the handle's incarnation, with the owner/actor coordinates its acceptance floor served.
459
+ * One resolver for the three relays (`turn`, `ask`, an escalation), because the three
460
+ * dispositions differ and the lookup does not: a turn and an ask refuse, an escalation stands.
461
+ */
462
+ private seatAddress;
463
+ private relayAsk;
464
+ /**
465
+ * An escalated checkpoint, delivered to the agent it names.
149
466
  *
150
- * A conclave's members are agent handles, so the ordinary case is gated exactly like the others.
151
- * `conclave([], …)` is not: a sub-team with nobody in it is a channel, and the channel plane is
152
- * here. It is refused anyway, because shipping the empty case alone would put half a primitive on
153
- * the durable plane a program that works with no members and refuses with one is a worse thing
154
- * to explain than a primitive that is not here yet.
467
+ * `to` is legal only with `onExpiry: "escalate"` and the escalation is the SECOND mint, so this
468
+ * runs once per chain at most. The addressee is resolved through the run's own roster: a name
469
+ * this run spawned is a seat and is told, and anything else is a person the pause is
470
+ * answerable from anywhere by design, its addressee is on the entry, and refusing a program
471
+ * that escalates to a human would be this host narrowing an option the reference leaves open.
472
+ *
473
+ * The relay is the ask's, because the two are the same act: one turn on the seat, carrying what
474
+ * is asked and the token to answer under, settling on the checkpoint plane rather than on the
475
+ * relay's own terminal.
155
476
  */
156
- openConclave(_req: unknown, _ctx: EffectContext): Promise<never>;
157
- closeConclave(_req: unknown, _ctx: EffectContext): Promise<never>;
477
+ private relayEscalation;
478
+ /**
479
+ * Submit one relay to a seat as a `turn` goal, and read its acceptance.
480
+ *
481
+ * IDEMPOTENT BY THE GOAL RECORD, which is also the arbiter when the invoke does not come back:
482
+ * a relay that landed and lost its reply is a relay that landed, and re-submitting it would put
483
+ * a second turn on the seat for one request. A seat the serve boundary reports gone is the
484
+ * agent-down failure (L4002); every other refusal is this endpoint's and is uncatchable.
485
+ */
486
+ private relayToSeat;
487
+ /**
488
+ * `monitor` registers interest: after it, `down(agent)` is an event a branch can await (§5.9).
489
+ *
490
+ * THE REGISTRATION IS THE JOURNAL ENTRY, and that is the whole mechanism. Death is a STATE on
491
+ * this mesh — the monitored incarnation's presence row gone (see `waitDown`) — not a message
492
+ * that must find a standing mailbox, so there is no subscription to create, nothing to arm, and
493
+ * nothing for a discharge or a migration to release: `wait(down(...))` reads the same fact
494
+ * whenever it is asked, and the migration table's row for `monitor` ("nothing outlives it")
495
+ * stays true. What the step performs is the validation a registration owes: the value must BE
496
+ * an agent handle, refused loudly when it is not, because a wait parked on a malformed handle
497
+ * would poll for a death nothing can ever report.
498
+ *
499
+ * Monitoring an agent that is ALREADY dead succeeds — Erlang's monitor of a dead process
500
+ * delivers its DOWN rather than failing, and the rescue idiom (race work against
501
+ * `wait(down(...))`) needs exactly that: the death is observed by the wait, immediately.
502
+ */
503
+ monitor(req: MonitorRequest, ctx: EffectContext): Promise<null>;
504
+ /**
505
+ * `conclave` open: mint (or take) the channel and join the members as durable membership rows.
506
+ *
507
+ * **The plan is the recovery identity.** Everything the close and the discharge need — the
508
+ * channel, whether this open minted its registry row, and per member the resolved principal,
509
+ * incarnation, generation and whether THIS conclave created the row — is computed first, bound
510
+ * as the entry's external state, and only then executed. A crash before the bind created
511
+ * nothing (rows are written after it); a crash after it re-enters with `ctx.resume` carrying
512
+ * the plan, and the execute converges idempotently without re-resolving anything: the members
513
+ * may have died since, and the recorded plan — not the world's current shape — is what a
514
+ * release answers to.
515
+ *
516
+ * **The channel is handler-derived** when the program names none: `conclave-` plus a digest of
517
+ * the step's own request id, so a resumed run re-derives the same room instead of opening a
518
+ * second one. A program-named channel is taken as-is (validated concrete) and its registry row
519
+ * is left alone — naming a room is not creating one, and the close must not tear down a channel
520
+ * the run merely borrowed.
521
+ *
522
+ * **Members resolve through presence.** A handle carries `<name>#<lifecycleUid>`; the row that
523
+ * maps it to the principal a membership record needs is the seat's own self-published presence —
524
+ * the same source DM name-resolution reads, and the witness the manager's readiness gate
525
+ * requires before a spawn reports `succeeded`. A member with no matching row is down or gone,
526
+ * which is the effect's own catchable failure (L4002), not a handler fault.
527
+ *
528
+ * A member already durably in the channel (a pinned pre-existing room) is planned `joined:
529
+ * false`: the conclave neither re-joins nor — at close — evicts a membership it did not create.
530
+ */
531
+ openConclave(req: ConclaveRequest, ctx: EffectContext): Promise<ChannelHandleValue>;
532
+ /**
533
+ * `conclave` close: release exactly what the recorded plan says the open created — tombstone
534
+ * the memberships planned `joined: true`, delete the registry row when this conclave minted the
535
+ * channel. A member that left and rejoined on its own since carries a newer generation, and the
536
+ * stale-write guard makes this leave a no-op for it: the membership is theirs now.
537
+ *
538
+ * Idempotent by the plane (a tombstone at or below an existing leave cursor is a no-op), so the
539
+ * re-entry that retries an unacknowledged close converges. The failure mode is the interpreter's
540
+ * `CloseOwed`: a close that throws leaves the entry pending, which IS the durable "a close is
541
+ * still owed".
542
+ */
543
+ closeConclave(_req: ConclaveRequest, ctx: EffectContext): Promise<null>;
544
+ /** Compute the conclave plan from the world: derive or validate the channel, resolve every
545
+ * member handle to its principal, and read each existing membership row so the join generation
546
+ * and the created-by-us fact are decided BEFORE anything is written. Duplicate handles collapse
547
+ * to one planned member — one identity is one membership row. */
548
+ private planConclave;
549
+ /** Execute a conclave plan against the registries, idempotently: the registry row is a merge
550
+ * the re-entry rewrites byte-identical, and a member row is committed only where the plan's
551
+ * generation is NEWER than what is stored — a re-entry must not roll a landed row's join
552
+ * cursor forward (the members were mid-conversation when the host died), and a row the world
553
+ * moved past (an independent leave or rejoin) is theirs, not this conclave's. */
554
+ private executeConclavePlan;
555
+ /** The world half of ending a conclave, shared by the close and the discharge: tombstone the
556
+ * memberships this conclave created, then delete the registry row it minted. Idempotent, and
557
+ * tolerant of exactly one foreign move — a NEWER generation on a row (the member left and
558
+ * rejoined on its own), which the stale-write guard reports and this leave must not evict. */
559
+ private releaseConclave;
560
+ /** Every live presence row that decodes. Foreign bytes in the bucket are skipped — a peer's
561
+ * malformed self-publish must not break another agent's name resolution — and what an ABSENT
562
+ * row means belongs to the caller: `resolveMemberPrincipal` refuses the join loudly, and
563
+ * `waitDown` reads it as the death it is waiting for. */
564
+ private presenceRows;
158
565
  /**
159
566
  * Arm this pause, or ATTACH to the one already recorded under the same token.
160
567
  *
161
- * A mint is idempotent only if the whole spec is identical, so the recorded deadline is the
162
- * authority and a resume may not recompute one: `now() + duration` is a different deadline a
163
- * second later, and the plane reads a different deadline as a different intent. The pause holds
164
- * it; a second copy anywhere else is a second thing to disagree.
568
+ * A mint is idempotent only if the whole spec is identical, so the recorded spec is the
569
+ * authority for BOTH halves of the mint's identity and a resume may not recompute either. The
570
+ * deadline, because `now() + duration` is a different deadline a second later, and the plane
571
+ * reads a different deadline as a different intent. And the HOLDER, because a resumed run does
572
+ * not necessarily arrive under the principal that minted its pause: the CLI mints a fresh holder
573
+ * per invocation, and a cross-host adoption is a different principal by definition. Only the
574
+ * recorded holder itself may mint again — completing its own crash between the spec and the
575
+ * status, where the identical spec is exactly what makes the retry idempotent. Everyone else
576
+ * attaches. Measured before the repair, through the CLI: one `resume` of a checkpoint-parked
577
+ * run re-minted under its own fresh holder, the plane refused ("a token is minted once"), and
578
+ * the interpreter recorded that infrastructure refusal as the step's own failure (L4000) — a
579
+ * stranded run whose journal blames the program.
165
580
  *
166
581
  * An already-passed deadline cannot be minted at all, correctly, because a due pause is not being
167
582
  * armed. It needs its schedule re-emitted at the status's current generation, which is the
168
- * reconciler's job. A spec with no status and an elapsed deadline is unrepairable from here, so it
169
- * is raised rather than waited on.
583
+ * reconciler's job the same operation an attaching successor needs, so the two share the exit.
584
+ * A spec with no status that this holder cannot complete is unrepairable from here, so it is
585
+ * raised rather than waited on.
170
586
  */
171
587
  private arm;
172
588
  /** Push a live deadline out — the idle window restarting. The heartbeat CAS-advances the
@@ -209,6 +625,10 @@ export declare class MeshHandler {
209
625
  * already in the past.
210
626
  */
211
627
  private settle;
628
+ /** Reject with `Cancelled` the moment this branch's signal fires, then claim the pause so its
629
+ * armed schedule cannot fire into a run that has moved on. The claim also writes the one-use
630
+ * settle, which is what lets an abandoned `awaitSettle` poll loop see a fact and end. */
631
+ private settleCancelled;
212
632
  /** Take this deadline's fire for as long as somebody is waiting on it. */
213
633
  private pumpFires;
214
634
  }
@@ -225,19 +645,6 @@ export declare function waitConsumerName(requestId: string): string;
225
645
  * this wait's to see.
226
646
  */
227
647
  export declare function waitConsumerConfig(space: string, requestId: string, channel: string): Record<string, unknown>;
228
- /**
229
- * An effect whose durable substrate has not landed on this host.
230
- *
231
- * An honest two-exit, and deliberately not a fake success: the simulator implements these, so a
232
- * program that uses them can be written, validated and dry-run today — but a DURABLE run refuses
233
- * rather than performing them on a plane that could not recover them. A run that "succeeded" at an
234
- * effect nothing can replay would be a lie the journal then carries forever.
235
- */
236
- export declare class NotYetDurable extends EffectRefused {
237
- readonly effect: string;
238
- readonly needs: string;
239
- constructor(effect: string, needs: string);
240
- }
241
648
  /**
242
649
  * RE-ARM the timers of every pause this run is still holding, under THIS driver's coordinates.
243
650
  *
@@ -267,10 +674,10 @@ export declare function rearmOutstandingPauses(deps: {
267
674
  * later record wins — a step that settled has a settled entry after its pending one, and reading
268
675
  * only the first would re-arm timers for pauses that are already over.
269
676
  *
270
- * THE KINDS ARE THE THREE THAT ARM A TIMER, and `wait` is one of them. It mints no pause of its own
271
- * so it does not look like one, but its idle window and its timeout are mediated deadlines exactly
272
- * as `sleep`'s is, and a `wait` adopted at a new epoch would otherwise wait on a deadline no live
273
- * epoch fires.
677
+ * THE KINDS ARE THE FIVE THAT ARM A TIMER, and `wait`, `ask` and `turn` are three of them. None of
678
+ * the three mints a pause that looks like its own, but a wait's idle window and timeout, an ask
679
+ * attempt's deadline, and a turn's deadline authority are mediated deadlines exactly as `sleep`'s
680
+ * is, and one adopted at a new epoch would otherwise wait on a deadline no live epoch fires.
274
681
  *
275
682
  * An idle wait with a timeout arms TWO, and the second is DERIVED rather than recorded, so it is
276
683
  * re-derived here for the same reason the live path derives it: a resume that had to remember it
@@ -278,6 +685,11 @@ export declare function rearmOutstandingPauses(deps: {
278
685
  * is harmless by construction — the reconciler reads the checkpoint's status first and re-emits
279
686
  * nothing when there is none — and the alternative, reading the request shape back out of the
280
687
  * entry to decide, would make the repair depend on a field a replay is not guaranteed to carry.
688
+ * An ask's armed pause is its CURRENT attempt's, whose token is bound as `askToken`; before the
689
+ * first bind it is attempt 1, which is the request id itself. A `turn`'s is under its goal id,
690
+ * which is the request id: that pause is the client-side L4003 authority the run keeps for a
691
+ * manager that dies, so leaving it armed at the predecessor's coordinates would go dark in exactly
692
+ * the window recovery opens.
281
693
  */
282
694
  export declare function outstandingPauseTokens(entries: readonly JournalEntry[]): string[];
283
695
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"mesh-handler.d.ts","sourceRoot":"","sources":["../src/mesh-handler.ts"],"names":[],"mappings":"AAmBA,OAAO,EAoBL,KAAK,aAAa,EAClB,KAAK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