@cotal-ai/manager 0.18.0 → 0.19.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.
@@ -9304,16 +9304,23 @@ ${stack}`;
9304
9304
  "internal"
9305
9305
  ]);
9306
9306
  var EpEnvelopeError = class extends Error {
9307
- constructor(code, message, details) {
9307
+ constructor(code, message, details, outcome) {
9308
9308
  super(message);
9309
9309
  __publicField(this, "code");
9310
9310
  __publicField(this, "details");
9311
+ __publicField(this, "outcome");
9311
9312
  this.code = code;
9312
9313
  this.details = details;
9314
+ this.outcome = outcome;
9313
9315
  this.name = "EpEnvelopeError";
9314
9316
  }
9315
9317
  toEpError() {
9316
- return { code: this.code, message: this.message, ...this.details ? { details: this.details } : {} };
9318
+ return {
9319
+ code: this.code,
9320
+ message: this.message,
9321
+ ...this.details ? { details: this.details } : {},
9322
+ ...this.outcome ? { outcome: this.outcome } : {}
9323
+ };
9317
9324
  }
9318
9325
  };
9319
9326
 
package/dist/manager.d.ts CHANGED
@@ -236,12 +236,6 @@ export interface StartAgentOpts {
236
236
  hash: string;
237
237
  };
238
238
  }
239
- /**
240
- * The agent supervisor: a long-lived mesh node that owns agent process lifecycle.
241
- * It serves control requests on the "manager" service and spawns/kills agents
242
- * through a pluggable {@link Runtime} (pty by default). It does NOT proxy agent
243
- * mesh traffic — terminal I/O streams over its own attach endpoint instead.
244
- */
245
239
  /** Runtime hooks the spawn-as-action serve path (P2 item 2) injects into {@link Manager.startAgent}.
246
240
  * Roster boot and the blocking callers pass none (unchanged behavior). */
247
241
  export interface SpawnHooks {
@@ -306,6 +300,12 @@ export declare function epAwaitReply(nc: NatsConnection, space: string, caller:
306
300
  data?: unknown;
307
301
  error?: string;
308
302
  }>;
303
+ /**
304
+ * The agent supervisor: a long-lived mesh node that owns agent process lifecycle.
305
+ * It serves control requests on the "manager" service and spawns/kills agents
306
+ * through a pluggable {@link Runtime} (pty by default). It does NOT proxy agent
307
+ * mesh traffic — terminal I/O streams over its own attach endpoint instead.
308
+ */
309
309
  export declare class Manager {
310
310
  private readonly space;
311
311
  private readonly servers;
@@ -444,6 +444,22 @@ export declare class Manager {
444
444
  private leaseInfo?;
445
445
  private leaseRevision?;
446
446
  private leaseTimer?;
447
+ /** When this instance last knew the key's TTL had been REFRESHED: a successful acquire or renew, or
448
+ * a re-read showing the revision moved past the one we held (our write landed, only its ack was
449
+ * lost). The gap since then is the only thing bounding how long we may keep serving with no answer
450
+ * at all, so it must track the last TTL-refreshing WRITE and not the last successful observation.
451
+ * A re-read at the same revision is deliberately NOT a refresh: it proves the key exists at that
452
+ * instant, while the key still expires when the last landed write said it would.
453
+ *
454
+ * MONOTONIC (`performance.now`), not wall clock, because it is only ever read as an ELAPSED time.
455
+ * `Date.now` steps on an NTP correction or a suspend/resume, and a backward step would shorten the
456
+ * measured gap and let this instance serve past the TTL with no proof it still holds the key. The
457
+ * initial value is `-Infinity` so "never refreshed" reads as an infinite gap and fails closed,
458
+ * rather than as a small one at process start when a monotonic clock is still near zero. */
459
+ private leaseConfirmedAt;
460
+ /** A renew is in flight. The tick must not start a second one: both would read the same cached
461
+ * revision, so whichever lands second CASes against a sequence the first already moved. */
462
+ private leaseRenewInFlight;
447
463
  /** The class-2 renewal owner's half-TTL schedule (D5 slice 5); armed only on auth meshes. */
448
464
  private credRenewTimer?;
449
465
  private maintenanceState;
@@ -540,14 +556,38 @@ export declare class Manager {
540
556
  * and drop its dedicated connection. Best-effort by design — both exit paths (graceful stop,
541
557
  * lease-loss fail-close) must complete their remaining teardown even if the broker is gone. */
542
558
  private stopServiceServe;
543
- /** Refresh THIS instance's liveness lease before the bucket TTL expires it. On loss (missed the TTL —
544
- * this instance stalled past the renew window) FAIL CLOSED for THIS INSTANCE ONLY: stop serving +
545
- * tear down OUR managed agents + exit, so a stalled instance can't keep double-processing under a key
546
- * a same-id restart may re-acquire. Keyed per instance, so this NEVER frees or touches a sibling
547
- * manager's key and NEVER freezes the space (security pin 6) the sibling keeps serving. We do NOT
548
- * re-acquire (a same-id restart may already be live) and do NOT release the key (it may be the
549
- * restart's). A DIFFERENT instance losing ITS key is a separate, independent event. */
559
+ /** Refresh THIS instance's liveness lease before the bucket TTL expires it.
560
+ *
561
+ * A FAILED RENEW IS NOT A LOST LEASE, and the difference is the whole shape of this method. The CAS
562
+ * renew throws for reasons that prove entirely different things, and one of them proves nothing at
563
+ * all: a request that gets NO ANSWER within its deadline does not establish that the write failed,
564
+ * that the key expired, or that anyone else took it. It may even have LANDED, with only the
565
+ * acknowledgement lost. Terminating on it kills a healthy manager and takes its agents with it.
566
+ *
567
+ * So the renew failing is a question, not a verdict, and the verdict comes from RE-READING the key
568
+ * ({@link CotalEndpoint.readOwnManagerLease}, which separates "it is gone" from "I could not find
569
+ * out"). We fail closed on PROOF — the key is absent, or it is present and holds someone else — and
570
+ * otherwise keep serving, adopting whatever revision the broker actually has.
571
+ *
572
+ * WHEN NO ANSWER IS AVAILABLE AT ALL, the bound is time, not attempts: past one whole TTL with no
573
+ * renew that LANDED, the key may have expired and been re-acquired, so this instance can no longer
574
+ * claim to hold it and fails closed on that ground, said plainly. A re-read answering "still yours,
575
+ * same revision" IS an answer and we keep serving on it, but it did not touch the key, so it buys
576
+ * no time — reading a key is not refreshing it. Inside the TTL the budget affords another
577
+ * renew-and-re-read pair ({@link MANAGER_LEASE_RENEW_MS}), which is what makes waiting safe.
578
+ *
579
+ * FAILING CLOSED IS FOR THIS INSTANCE ONLY: stop serving + tear down OUR managed agents + exit, so a
580
+ * stalled instance can't keep double-processing under a key a same-id restart may re-acquire. Keyed
581
+ * per instance, so it NEVER frees or touches a sibling manager's key and NEVER freezes the space
582
+ * (security pin 6) — the sibling keeps serving. We do NOT re-acquire (a same-id restart may already
583
+ * be live) and do NOT release the key (it may be the restart's). */
550
584
  private renewLease;
585
+ /** What the broker actually says about THIS instance's lease key, right now. `unknown` is a first-class
586
+ * answer and never collapses into `gone`: not being able to look is not the same fact as looking and
587
+ * finding nothing, and only the latter may end a manager. */
588
+ private reconcileLease;
589
+ /** Stop serving and end this process, naming what was PROVED rather than what merely failed. */
590
+ private failClosedOnLeaseLoss;
551
591
  private opFinalizeResume;
552
592
  private opCommitResume;
553
593
  private opResumePreserved;
@@ -717,16 +757,6 @@ export declare class Manager {
717
757
  /** Agent names become `.cotal/agents/<name>.md` paths and mesh identities, so they must be bare
718
758
  * tokens, never a path — blocks traversal / arbitrary writes from a model-supplied name. */
719
759
  private nameError;
720
- /** First free name in the series `base`, `base-2`, `base-3`, … — checked against live slots,
721
- * in-flight (reserved) slots, names held pending retirement, AND the live mesh roster. The
722
- * roster check covers occupants this manager does not manage (a foreground `cotal spawn`, a
723
- * connector session, another manager's agent): allocating their name would mint a sibling the
724
- * broker/auth then refuses to admit, surfacing as a 30s launch-uncertain black hole instead of
725
- * the auto-number the join path gives. Presence is ADVISORY (SPEC §6) — this is an availability
726
- * choice at allocation, never an authority check (the broker still enforces): a stale
727
- * still-live-looking row only costs a numbered suffix, and a missed freshly-joined occupant is
728
- * still refused downstream exactly as before. Offline rows do NOT occupy — a properly retired
729
- * name stays reusable. */
730
760
  /** The roster's LIVE occupant names (status !== offline) — occupants this manager may NOT manage
731
761
  * (a foreground `cotal spawn`, a connector session, ANOTHER manager's agent). Allocating over any
732
762
  * of them mints a sibling the broker/auth then refuses to admit, surfacing as the 30s launch-
@@ -737,6 +767,16 @@ export declare class Manager {
737
767
  * reserves/manages/retires it OR a roster-live occupant already holds it. Pass a pre-built
738
768
  * {@link liveRosterNames} set when checking many names in one allocation. */
739
769
  private nameInUse;
770
+ /** First free name in the series `base`, `base-2`, `base-3`, … — checked against live slots,
771
+ * in-flight (reserved) slots, names held pending retirement, AND the live mesh roster. The
772
+ * roster check covers occupants this manager does not manage (a foreground `cotal spawn`, a
773
+ * connector session, another manager's agent): allocating their name would mint a sibling the
774
+ * broker/auth then refuses to admit, surfacing as a 30s launch-uncertain black hole instead of
775
+ * the auto-number the join path gives. Presence is ADVISORY (SPEC §6) — this is an availability
776
+ * choice at allocation, never an authority check (the broker still enforces): a stale
777
+ * still-live-looking row only costs a numbered suffix, and a missed freshly-joined occupant is
778
+ * still refused downstream exactly as before. Offline rows do NOT occupy — a properly retired
779
+ * name stays reusable. */
740
780
  private uniqueName;
741
781
  /** Spawn a teammate by persona ref (`name` loads `.cotal/agents/<name>.md`; the peer presents
742
782
  * under that file's own `name:`), as if a peer asked via the control plane. Used to pre-spawn the
@@ -851,11 +891,6 @@ export declare class Manager {
851
891
  * names. Static agents key `(DEV_OWNER, nkey)`; user-mode agents store the principal dot-form
852
892
  * in `id`. A uid mismatch is a superseded incarnation — never resolved to its successor. */
853
893
  private findManagedByTarget;
854
- /** Open a short-lived PROVISIONER connection, run the onboarding ops on it, and drain it (closure (ii),
855
- * residual 2). The DM/DLV consumer-create surface — the irreducible onboarding power — lives only for
856
- * this window, never as a standing grant on the long-lived supervisor. A provision-only endpoint
857
- * (no presence/consume/channel-watch) connected with memory-only `provisioner` creds; it sets its own
858
- * `inboxPrefix` so JS-API replies land on the `_INBOX_<id>.>` the provisioner cred subscribes. */
859
894
  /** Run one static §13.1 lifecycle OPERATION over an ephemeral, key-pinned `lifecycle-executor`
860
895
  * connection (Unit B): the credential's grants name exactly ONE incarnation's head/uid/gate/
861
896
  * cred-family/slot keys, so the write authority exists only for this operation's window and
@@ -1068,6 +1103,11 @@ export declare class Manager {
1068
1103
  * is non-forgeable); any OTHER principal is not a managed lifecycle (an operator instrument:
1069
1104
  * the credential tier governs, exactly as before). Never name alone, never a payload field. */
1070
1105
  private lifecycleMembershipRefusal;
1106
+ /** Open a short-lived PROVISIONER connection, run the onboarding ops on it, and drain it (closure (ii),
1107
+ * residual 2). The DM/DLV consumer-create surface — the irreducible onboarding power — lives only for
1108
+ * this window, never as a standing grant on the long-lived supervisor. A provision-only endpoint
1109
+ * (no presence/consume/channel-watch) connected with memory-only `provisioner` creds; it sets its own
1110
+ * `inboxPrefix` so JS-API replies land on the `_INBOX_<id>.>` the provisioner cred subscribes. */
1071
1111
  private withProvisioner;
1072
1112
  /** Purge the space's retained message backlog (chat, optionally DMs). Privileged — the manager mints a
1073
1113
  * short-lived "purger" cred (same destructive grant as `cotal history clear`, isolated off the
@@ -1 +1 @@
1
- {"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../src/manager.ts"],"names":[],"mappings":"AA2CA,OAAO,KAAK,EAA4E,YAAY,EAA4C,eAAe,EAAY,WAAW,EAAa,MAAM,gBAAgB,CAAC;AAC1N,OAAO,EAIL,KAAK,WAAW,EACjB,MAAM,oBAAoB,CAAC;AAsC5B,OAAO,EAsCL,KAAK,QAAQ,EAEd,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,cAAc,EAAgB,MAAM,yBAAyB,CAAC;AAoB5E;;;;;;;sDAOsD;AACtD,eAAO,MAAM,oBAAoB,QAAS,CAAC;AAsD3C,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kFAAkF;IAClF,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qEAAqE;IACrE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;iGAE6F;IAC7F,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;4GAIwG;IACxG,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uEAAuE;IACvE,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,+FAA+F;IAC/F,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,+EAA+E;IAC/E,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC;;4GAEwG;IACxG,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;;;6FAMyF;IACzF,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B;;;;;+FAK2F;IAC3F,WAAW,CAAC,EAAE,MAAM,CAAC;C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E;YAC7D,kBAAkB;IA+BhC;;;;;;;iDAO6C;YAC/B,gBAAgB;IA+B9B;;;;uEAImE;IACnE,OAAO,CAAC,gBAAgB;IAaxB;;;;;;;;;;;;;;;;;;;;;;;;;oFAyBgF;YAClE,4BAA4B;IAU1C;;;;;0EAKsE;YACxD,cAAc;IAkL5B;;iGAE6F;IAC7F,OAAO,CAAC,mBAAmB;IAM3B;;;;;;;;;;iDAU6C;YAC/B,qBAAqB;IAYnC;;;;;sGAKkG;YACpF,eAAe;IAiB7B;;;;;;wDAMoD;YACtC,qBAAqB;IAqCnC;;;;;8EAK0E;YAC5D,sBAAsB;IAoDpC;;;;;;;;yEAQqE;YACvD,yBAAyB;IAsDvC;;;;;oGAKgG;IAChG,OAAO,CAAC,0BAA0B;IAiBlC;;;;uGAImG;YACrF,eAAe;IAuB7B;;;gCAG4B;YACd,OAAO;IAgBrB;;;;;;;;4GAQwG;IACxG,OAAO,CAAC,eAAe;IAqCvB;;;;uGAImG;YACrF,gBAAgB;IAkC9B;;;;;;2GAMuG;YACzF,uBAAuB;IAmCrC,wFAAwF;IACxF;gGAC4F;IAC5F,OAAO,CAAC,IAAI;CA8Bb"}
package/dist/manager.js CHANGED
@@ -3,7 +3,7 @@ import { createHash, randomUUID, randomBytes } from "node:crypto";
3
3
  import { connect, credsAuthenticator } from "@nats-io/transport-node";
4
4
  import { existsSync, lstatSync, readFileSync, rmSync } from "node:fs";
5
5
  import { join, dirname, resolve } from "node:path";
6
- import { CotalEndpoint, DEFAULT_SERVER, DEV_OWNER, MANAGER_LEASE_TTL_MS, STANDING_RENEWABLE_TTL_SEC, agentFilePath, clearSpaceHistory, connectorServers, deprovisionAgent, firstFreeName, idFromCreds, inspectCredHealth, loadAgentFile, loadCotalConfig, mintCreds, mintLifecycleUid, mkSecretDir, newIdentity, actionContext, parsePrincipalKey, parseShareSelection, principalKey, probeConnect, provisionAgent, provisionAgentDurables, registry, resolveAuthProvider, saveAgentFile, subjectMatches, AUTH_ENDPOINT, EP_CMD_RETIRE_LIFECYCLE, epRequestSubject, epCallerReplyFilter, parseEpSubject, controlServiceSubject, } from "@cotal-ai/core";
6
+ import { CotalEndpoint, DEFAULT_SERVER, DEV_OWNER, MANAGER_LEASE_TTL_MS, MANAGER_LEASE_RENEW_MS, STANDING_RENEWABLE_TTL_SEC, agentFilePath, clearSpaceHistory, connectorServers, deprovisionAgent, firstFreeName, idFromCreds, inspectCredHealth, loadAgentFile, loadCotalConfig, mintCreds, mintLifecycleUid, mkSecretDir, newIdentity, actionContext, parsePrincipalKey, parseShareSelection, principalKey, probeConnect, provisionAgent, provisionAgentDurables, registry, resolveAuthProvider, saveAgentFile, subjectMatches, AUTH_ENDPOINT, EP_CMD_RETIRE_LIFECYCLE, epRequestSubject, epCallerReplyFilter, parseEpSubject, controlServiceSubject, } from "@cotal-ai/core";
7
7
  import { agentAuthState, agentCredsDir, agentLifecycleSecretFilePaths, agentSecretFilePaths, agentSecretKeyForFile, authDir, connectorInstallHint, DEFAULT_CONNECTOR, defaultAgentType, DELIVERY_CREDS_KEY, findCotalRoot, getSpaceAuth, hasUserAuthState, loadManagerInstanceIdentity, loadMeshes, manifestExtensionNames, materializeFromManifest, materializeSecretToFile, MEMBERSHIP_RW_CREDS_KEY, mergeLaunchOptions, remintDaemonCreds, resolveOnPath, saveManagerInstanceIdentity, SYSTEM_CREDS_FILES, userAuthStateDir, workspaceSecretStore, writeRenewalRecord } from "@cotal-ai/workspace";
8
8
  import { createRuntime, } from "./runtime/index.js";
9
9
  import { AttachEndpoint } from "./attach-endpoint.js";
@@ -140,6 +140,12 @@ export async function epAwaitReply(nc, space, caller, nonce, requestId, requestS
140
140
  catch { /* connection already down */ }
141
141
  }
142
142
  }
143
+ /**
144
+ * The agent supervisor: a long-lived mesh node that owns agent process lifecycle.
145
+ * It serves control requests on the "manager" service and spawns/kills agents
146
+ * through a pluggable {@link Runtime} (pty by default). It does NOT proxy agent
147
+ * mesh traffic — terminal I/O streams over its own attach endpoint instead.
148
+ */
143
149
  export class Manager {
144
150
  space;
145
151
  servers;
@@ -278,6 +284,22 @@ export class Manager {
278
284
  leaseInfo;
279
285
  leaseRevision;
280
286
  leaseTimer;
287
+ /** When this instance last knew the key's TTL had been REFRESHED: a successful acquire or renew, or
288
+ * a re-read showing the revision moved past the one we held (our write landed, only its ack was
289
+ * lost). The gap since then is the only thing bounding how long we may keep serving with no answer
290
+ * at all, so it must track the last TTL-refreshing WRITE and not the last successful observation.
291
+ * A re-read at the same revision is deliberately NOT a refresh: it proves the key exists at that
292
+ * instant, while the key still expires when the last landed write said it would.
293
+ *
294
+ * MONOTONIC (`performance.now`), not wall clock, because it is only ever read as an ELAPSED time.
295
+ * `Date.now` steps on an NTP correction or a suspend/resume, and a backward step would shorten the
296
+ * measured gap and let this instance serve past the TTL with no proof it still holds the key. The
297
+ * initial value is `-Infinity` so "never refreshed" reads as an infinite gap and fails closed,
298
+ * rather than as a small one at process start when a monotonic clock is still near zero. */
299
+ leaseConfirmedAt = Number.NEGATIVE_INFINITY;
300
+ /** A renew is in flight. The tick must not start a second one: both would read the same cached
301
+ * revision, so whichever lands second CASes against a sequence the first already moved. */
302
+ leaseRenewInFlight = false;
281
303
  /** The class-2 renewal owner's half-TTL schedule (D5 slice 5); armed only on auth meshes. */
282
304
  credRenewTimer;
283
305
  maintenanceState = "active";
@@ -435,6 +457,7 @@ export class Manager {
435
457
  this.leaseInfo = { holder: this.ep.ref().id, instanceId: this.managerInstanceId, runtime: this.runtime.kind, root: resolve(this.workspaceRoot), pid: process.pid };
436
458
  try {
437
459
  this.leaseRevision = await this.ep.acquireManagerLease(this.leaseInfo);
460
+ this.leaseConfirmedAt = performance.now();
438
461
  }
439
462
  catch (e) {
440
463
  // Our OWN instance id already holds a live key ⇒ refuse. Anything else (e.g. a KV/JS error) is a
@@ -446,7 +469,7 @@ export class Manager {
446
469
  ? `manager instance ${this.managerInstanceId} already serves space "${this.space}" from this workspace root (${held.runtime}, pid ${held.pid}, root ${held.root}) - stop it first before restarting the same instance`
447
470
  : `could not acquire the manager lease for space "${this.space}": ${e.message}`);
448
471
  }
449
- this.leaseTimer = setInterval(() => { void this.renewLease(); }, MANAGER_LEASE_TTL_MS / 2);
472
+ this.leaseTimer = setInterval(() => { void this.renewLease(); }, MANAGER_LEASE_RENEW_MS);
450
473
  this.leaseTimer.unref?.();
451
474
  // Unit B (static §13.1): ensure the two authority stores exist with their normative shape,
452
475
  // then sweep the durable slot rows and reconcile — re-drive any crashed activation/terminal
@@ -1124,45 +1147,131 @@ export class Manager {
1124
1147
  catch { /* best effort */ }
1125
1148
  }
1126
1149
  }
1127
- /** Refresh THIS instance's liveness lease before the bucket TTL expires it. On loss (missed the TTL —
1128
- * this instance stalled past the renew window) FAIL CLOSED for THIS INSTANCE ONLY: stop serving +
1129
- * tear down OUR managed agents + exit, so a stalled instance can't keep double-processing under a key
1130
- * a same-id restart may re-acquire. Keyed per instance, so this NEVER frees or touches a sibling
1131
- * manager's key and NEVER freezes the space (security pin 6) the sibling keeps serving. We do NOT
1132
- * re-acquire (a same-id restart may already be live) and do NOT release the key (it may be the
1133
- * restart's). A DIFFERENT instance losing ITS key is a separate, independent event. */
1150
+ /** Refresh THIS instance's liveness lease before the bucket TTL expires it.
1151
+ *
1152
+ * A FAILED RENEW IS NOT A LOST LEASE, and the difference is the whole shape of this method. The CAS
1153
+ * renew throws for reasons that prove entirely different things, and one of them proves nothing at
1154
+ * all: a request that gets NO ANSWER within its deadline does not establish that the write failed,
1155
+ * that the key expired, or that anyone else took it. It may even have LANDED, with only the
1156
+ * acknowledgement lost. Terminating on it kills a healthy manager and takes its agents with it.
1157
+ *
1158
+ * So the renew failing is a question, not a verdict, and the verdict comes from RE-READING the key
1159
+ * ({@link CotalEndpoint.readOwnManagerLease}, which separates "it is gone" from "I could not find
1160
+ * out"). We fail closed on PROOF — the key is absent, or it is present and holds someone else — and
1161
+ * otherwise keep serving, adopting whatever revision the broker actually has.
1162
+ *
1163
+ * WHEN NO ANSWER IS AVAILABLE AT ALL, the bound is time, not attempts: past one whole TTL with no
1164
+ * renew that LANDED, the key may have expired and been re-acquired, so this instance can no longer
1165
+ * claim to hold it and fails closed on that ground, said plainly. A re-read answering "still yours,
1166
+ * same revision" IS an answer and we keep serving on it, but it did not touch the key, so it buys
1167
+ * no time — reading a key is not refreshing it. Inside the TTL the budget affords another
1168
+ * renew-and-re-read pair ({@link MANAGER_LEASE_RENEW_MS}), which is what makes waiting safe.
1169
+ *
1170
+ * FAILING CLOSED IS FOR THIS INSTANCE ONLY: stop serving + tear down OUR managed agents + exit, so a
1171
+ * stalled instance can't keep double-processing under a key a same-id restart may re-acquire. Keyed
1172
+ * per instance, so it NEVER frees or touches a sibling manager's key and NEVER freezes the space
1173
+ * (security pin 6) — the sibling keeps serving. We do NOT re-acquire (a same-id restart may already
1174
+ * be live) and do NOT release the key (it may be the restart's). */
1134
1175
  async renewLease() {
1176
+ // A renew that runs long must not be overlapped by the next tick: both would CAS against the same
1177
+ // cached revision, so whichever lands second is refused over a sequence the first legitimately
1178
+ // moved — a conflict this instance manufactured itself.
1179
+ if (this.leaseRenewInFlight)
1180
+ return;
1181
+ this.leaseRenewInFlight = true;
1135
1182
  try {
1136
1183
  if (!this.leaseInfo || this.leaseRevision === undefined)
1137
1184
  return;
1138
- this.leaseRevision = await this.ep.renewManagerLease(this.leaseInfo, this.leaseRevision);
1139
- }
1140
- catch (e) {
1141
- console.error(`! manager instance ${this.managerInstanceId} lost its liveness lease for space "${this.space}" (${e.message}) - shutting down THIS instance (its serving only; siblings keep the space)`);
1142
- if (this.leaseTimer)
1143
- clearInterval(this.leaseTimer);
1144
- // Tear down our managed agents' footprints too (#159 B2) — this exit path leaks them otherwise. Do
1145
- // NOT release the lease key (it may belong to the replacement holder). Best-effort, like ep/attach.
1146
1185
  try {
1147
- if (this.maintenanceState === "active" && !this.resumeRequired)
1148
- await this.teardownManagedAgents();
1149
- else
1150
- await this.stopRetainedAgentsOnExit();
1151
- }
1152
- catch { /* best effort */ }
1153
- await this.stopServiceServe();
1154
- await this.stopGoalWriter();
1155
- await this.stopSessionPlane();
1156
- try {
1157
- await this.ep.stop();
1186
+ this.leaseRevision = await this.ep.renewManagerLease(this.leaseInfo, this.leaseRevision);
1187
+ this.leaseConfirmedAt = performance.now();
1188
+ return;
1158
1189
  }
1159
- catch { /* best effort */ }
1160
- try {
1161
- await this.attach.stop();
1190
+ catch (renewError) {
1191
+ const why = renewError.message;
1192
+ const verdict = await this.reconcileLease();
1193
+ if (verdict.kind === "held") {
1194
+ // WHETHER THIS REFILLS THE BUDGET TURNS ON ONE THING: did our write land? It did, with only
1195
+ // its acknowledgement lost, exactly when the stored revision has moved past the one we hold.
1196
+ // That write is what restarted the key's TTL, so only it may reset the clock below.
1197
+ //
1198
+ // A re-read at the SAME revision proves the key exists AT THAT INSTANT and nothing more. Our
1199
+ // write did not land, the TTL was not restarted, and the key still expires when the last
1200
+ // landed write said it would. Resetting the clock here would measure the budget from the last
1201
+ // OBSERVATION rather than from the last TTL-refreshing write, and the budget would then
1202
+ // outlive the key: a streak of same-revision re-reads keeps refilling it, and if reads then
1203
+ // stop answering too, this instance goes on serving for a further whole TTL after the key has
1204
+ // actually expired and a same-id restart has taken it. Serving on a key we can still SEE is
1205
+ // right; buying more time to serve on a key we cannot see is not.
1206
+ const landed = verdict.revision > this.leaseRevision;
1207
+ this.leaseRevision = verdict.revision;
1208
+ if (landed)
1209
+ this.leaseConfirmedAt = performance.now();
1210
+ console.error(`! manager instance ${this.managerInstanceId} could not renew its liveness lease for space "${this.space}" (${why}) - the key is still ours at revision ${verdict.revision}${landed ? ", and that renew had in fact landed" : ", though this renew did not land, so the key's TTL was not restarted"}, so this instance keeps serving`);
1211
+ return;
1212
+ }
1213
+ if (verdict.kind === "unknown") {
1214
+ const since = performance.now() - this.leaseConfirmedAt;
1215
+ if (since < MANAGER_LEASE_TTL_MS) {
1216
+ console.error(`! manager instance ${this.managerInstanceId} could not renew its liveness lease for space "${this.space}" (${why}) and could not re-read it either (${verdict.why}) - that proves nothing about the key, and its lease was last refreshed ${Math.round(since)}ms ago, so this instance keeps serving and will retry`);
1217
+ return;
1218
+ }
1219
+ return await this.failClosedOnLeaseLoss(`its lease key ${Number.isFinite(since) ? `has not been refreshed for ${Math.round(since)}ms, longer than the ${MANAGER_LEASE_TTL_MS}ms lease TTL` : "was never refreshed"}, so this instance can no longer prove it holds it (renew: ${why}; re-read: ${verdict.why})`);
1220
+ }
1221
+ return await this.failClosedOnLeaseLoss(verdict.kind === "gone"
1222
+ ? `its lease key is GONE from the bucket - expired or released (renew: ${why})`
1223
+ : `its lease key is now held by ${verdict.by} and not by this process (renew: ${why})`);
1162
1224
  }
1163
- catch { /* best effort */ }
1164
- process.exit(1);
1165
1225
  }
1226
+ finally {
1227
+ this.leaseRenewInFlight = false;
1228
+ }
1229
+ }
1230
+ /** What the broker actually says about THIS instance's lease key, right now. `unknown` is a first-class
1231
+ * answer and never collapses into `gone`: not being able to look is not the same fact as looking and
1232
+ * finding nothing, and only the latter may end a manager. */
1233
+ async reconcileLease() {
1234
+ let current;
1235
+ try {
1236
+ current = await this.ep.readOwnManagerLease(this.managerInstanceId);
1237
+ }
1238
+ catch (e) {
1239
+ return { kind: "unknown", why: e.message };
1240
+ }
1241
+ if (current === undefined)
1242
+ return { kind: "gone" };
1243
+ // The pid is what distinguishes US from a same-id restart: the logical instance id and the serve
1244
+ // identity both PERSIST across restart by design, so neither can tell the two processes apart.
1245
+ if (current.info.pid !== process.pid)
1246
+ return { kind: "taken", by: `pid ${current.info.pid} (${current.info.runtime}, root ${current.info.root})` };
1247
+ return { kind: "held", revision: current.revision };
1248
+ }
1249
+ /** Stop serving and end this process, naming what was PROVED rather than what merely failed. */
1250
+ async failClosedOnLeaseLoss(proof) {
1251
+ console.error(`! manager instance ${this.managerInstanceId} lost its liveness lease for space "${this.space}": ${proof} - shutting down THIS instance (its serving only; siblings keep the space)`);
1252
+ if (this.leaseTimer)
1253
+ clearInterval(this.leaseTimer);
1254
+ // Tear down our managed agents' footprints too (#159 B2) — this exit path leaks them otherwise. Do
1255
+ // NOT release the lease key (it may belong to the replacement holder). Best-effort, like ep/attach.
1256
+ try {
1257
+ if (this.maintenanceState === "active" && !this.resumeRequired)
1258
+ await this.teardownManagedAgents();
1259
+ else
1260
+ await this.stopRetainedAgentsOnExit();
1261
+ }
1262
+ catch { /* best effort */ }
1263
+ await this.stopServiceServe();
1264
+ await this.stopGoalWriter();
1265
+ await this.stopSessionPlane();
1266
+ try {
1267
+ await this.ep.stop();
1268
+ }
1269
+ catch { /* best effort */ }
1270
+ try {
1271
+ await this.attach.stop();
1272
+ }
1273
+ catch { /* best effort */ }
1274
+ process.exit(1);
1166
1275
  }
1167
1276
  async opFinalizeResume(rawArgs) {
1168
1277
  {
@@ -2115,16 +2224,6 @@ export class Manager {
2115
2224
  ? undefined
2116
2225
  : `unsafe name ${JSON.stringify(name)} (allowed: letters, digits, _ -)`;
2117
2226
  }
2118
- /** First free name in the series `base`, `base-2`, `base-3`, … — checked against live slots,
2119
- * in-flight (reserved) slots, names held pending retirement, AND the live mesh roster. The
2120
- * roster check covers occupants this manager does not manage (a foreground `cotal spawn`, a
2121
- * connector session, another manager's agent): allocating their name would mint a sibling the
2122
- * broker/auth then refuses to admit, surfacing as a 30s launch-uncertain black hole instead of
2123
- * the auto-number the join path gives. Presence is ADVISORY (SPEC §6) — this is an availability
2124
- * choice at allocation, never an authority check (the broker still enforces): a stale
2125
- * still-live-looking row only costs a numbered suffix, and a missed freshly-joined occupant is
2126
- * still refused downstream exactly as before. Offline rows do NOT occupy — a properly retired
2127
- * name stays reusable. */
2128
2227
  /** The roster's LIVE occupant names (status !== offline) — occupants this manager may NOT manage
2129
2228
  * (a foreground `cotal spawn`, a connector session, ANOTHER manager's agent). Allocating over any
2130
2229
  * of them mints a sibling the broker/auth then refuses to admit, surfacing as the 30s launch-
@@ -2143,6 +2242,16 @@ export class Manager {
2143
2242
  nameInUse(name, live = this.liveRosterNames()) {
2144
2243
  return this.agents.has(name) || this.reserved.has(name) || this.retiring.has(name) || live.has(name);
2145
2244
  }
2245
+ /** First free name in the series `base`, `base-2`, `base-3`, … — checked against live slots,
2246
+ * in-flight (reserved) slots, names held pending retirement, AND the live mesh roster. The
2247
+ * roster check covers occupants this manager does not manage (a foreground `cotal spawn`, a
2248
+ * connector session, another manager's agent): allocating their name would mint a sibling the
2249
+ * broker/auth then refuses to admit, surfacing as a 30s launch-uncertain black hole instead of
2250
+ * the auto-number the join path gives. Presence is ADVISORY (SPEC §6) — this is an availability
2251
+ * choice at allocation, never an authority check (the broker still enforces): a stale
2252
+ * still-live-looking row only costs a numbered suffix, and a missed freshly-joined occupant is
2253
+ * still refused downstream exactly as before. Offline rows do NOT occupy — a properly retired
2254
+ * name stays reusable. */
2146
2255
  uniqueName(base) {
2147
2256
  const live = this.liveRosterNames();
2148
2257
  return firstFreeName(base, (n) => this.nameInUse(n, live));
@@ -3322,7 +3431,7 @@ export class Manager {
3322
3431
  // resolve "uncertain"; caught by the lifecycle e2e).
3323
3432
  const wanted = this.managedPrincipal(a);
3324
3433
  // READINESS LIFECYCLE FENCE (SPEC 13.1): match the exact principal AND the exact lifecycle uid
3325
- // the manager minted for THIS spawn (presence carries it, §6/:315). The endpoint's own
3434
+ // the manager minted for THIS spawn (presence carries it, §6). The endpoint's own
3326
3435
  // register-only broker proof is gated on the CLIENT-authored `card.kind`, which a managed child
3327
3436
  // holding a valid agent credential could set to "endpoint" to skip - so it is defense-in-depth,
3328
3437
  // NOT the authority boundary. This equality is: the manager (not the child) owns the expected
@@ -3492,11 +3601,6 @@ export class Manager {
3492
3601
  }
3493
3602
  return undefined;
3494
3603
  }
3495
- /** Open a short-lived PROVISIONER connection, run the onboarding ops on it, and drain it (closure (ii),
3496
- * residual 2). The DM/DLV consumer-create surface — the irreducible onboarding power — lives only for
3497
- * this window, never as a standing grant on the long-lived supervisor. A provision-only endpoint
3498
- * (no presence/consume/channel-watch) connected with memory-only `provisioner` creds; it sets its own
3499
- * `inboxPrefix` so JS-API replies land on the `_INBOX_<id>.>` the provisioner cred subscribes. */
3500
3604
  /** Run one static §13.1 lifecycle OPERATION over an ephemeral, key-pinned `lifecycle-executor`
3501
3605
  * connection (Unit B): the credential's grants name exactly ONE incarnation's head/uid/gate/
3502
3606
  * cred-family/slot keys, so the write authority exists only for this operation's window and
@@ -4162,7 +4266,7 @@ export class Manager {
4162
4266
  // itself (`iid`, written at accept), which is the honest coordinate: a same-instanceId restart
4163
4267
  // inherits its predecessor's orphans, and a goal accepted by a DIFFERENT (possibly still-live)
4164
4268
  // sibling is left for its owner. This replaces the goal spec's `executor` pin, which existed
4165
- // only to epoch-scope the terminal subject and is gone with it (SPEC:1394).
4269
+ // only to epoch-scope the terminal subject and is gone with it (§13.2 reserved subjects).
4166
4270
  if (acceptedByIid !== this.managerInstanceId) {
4167
4271
  console.error(`goal reconcile ${ref.goalId}: accepted by instance "${acceptedByIid}", not this incarnation "${this.managerInstanceId}"; left for its owner (never a cross-instance settle)`);
4168
4272
  return;
@@ -4292,7 +4396,7 @@ export class Manager {
4292
4396
  // caller cannot publish it). TWO COMPOSED FENCES (defense in depth): must-5 (a) reads THIS
4293
4397
  // incarnation's OWN gate epoch and REFUSES a superseded commit (the currency belt), and (b)
4294
4398
  // barrier-revoke evicts this connection on takeover. The terminal lands on the ONE subject
4295
- // SPEC:1394 reserves; first-terminal-fact-wins is global, so a committed outcome is visible
4399
+ // SPEC §13.2 (reserved subjects) reserves; first-terminal-fact-wins is global, so a committed outcome is visible
4296
4400
  // to every reader in every incarnation. On success the reconcile-index entry is cleared.
4297
4401
  //
4298
4402
  // Named rather than inlined into the hooks below so the H1 post-accept fallback drives THIS
@@ -4674,6 +4778,11 @@ export class Manager {
4674
4778
  return "the caller's lifecycle is retired; a retired incarnation's credential holds no control authority (F5)";
4675
4779
  return undefined;
4676
4780
  }
4781
+ /** Open a short-lived PROVISIONER connection, run the onboarding ops on it, and drain it (closure (ii),
4782
+ * residual 2). The DM/DLV consumer-create surface — the irreducible onboarding power — lives only for
4783
+ * this window, never as a standing grant on the long-lived supervisor. A provision-only endpoint
4784
+ * (no presence/consume/channel-watch) connected with memory-only `provisioner` creds; it sets its own
4785
+ * `inboxPrefix` so JS-API replies land on the `_INBOX_<id>.>` the provisioner cred subscribes. */
4677
4786
  async withProvisioner(fn) {
4678
4787
  if (!this.auth)
4679
4788
  throw new Error("withProvisioner: no space auth (an open mesh has no scoped creds)");