@cotal-ai/manager 0.166.3 → 0.168.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/attach-endpoint.d.ts.map +1 -1
  2. package/dist/attach-endpoint.js +2 -0
  3. package/dist/attach-endpoint.js.map +1 -1
  4. package/dist/console/app.js +12 -1
  5. package/dist/console/session-bundle.js +2 -0
  6. package/dist/lease-keeper.d.ts +98 -0
  7. package/dist/lease-keeper.d.ts.map +1 -0
  8. package/dist/lease-keeper.js +257 -0
  9. package/dist/lease-keeper.js.map +1 -0
  10. package/dist/managed-static-lifecycle.d.ts +247 -0
  11. package/dist/managed-static-lifecycle.d.ts.map +1 -0
  12. package/dist/managed-static-lifecycle.js +926 -0
  13. package/dist/managed-static-lifecycle.js.map +1 -0
  14. package/dist/manager-timeout.d.ts +5 -0
  15. package/dist/manager-timeout.d.ts.map +1 -0
  16. package/dist/manager-timeout.js +11 -0
  17. package/dist/manager-timeout.js.map +1 -0
  18. package/dist/manager.d.ts +201 -508
  19. package/dist/manager.d.ts.map +1 -1
  20. package/dist/manager.js +337 -3086
  21. package/dist/manager.js.map +1 -1
  22. package/dist/names-capacity.d.ts +125 -0
  23. package/dist/names-capacity.d.ts.map +1 -0
  24. package/dist/names-capacity.js +236 -0
  25. package/dist/names-capacity.js.map +1 -0
  26. package/dist/retirement.d.ts +221 -0
  27. package/dist/retirement.d.ts.map +1 -0
  28. package/dist/retirement.js +480 -0
  29. package/dist/retirement.js.map +1 -0
  30. package/dist/seat-custody.d.ts +100 -0
  31. package/dist/seat-custody.d.ts.map +1 -0
  32. package/dist/seat-custody.js +320 -0
  33. package/dist/seat-custody.js.map +1 -0
  34. package/dist/serve-plane.d.ts +228 -0
  35. package/dist/serve-plane.d.ts.map +1 -0
  36. package/dist/serve-plane.js +664 -0
  37. package/dist/serve-plane.js.map +1 -0
  38. package/dist/session-recovery.d.ts +115 -0
  39. package/dist/session-recovery.d.ts.map +1 -0
  40. package/dist/session-recovery.js +350 -0
  41. package/dist/session-recovery.js.map +1 -0
  42. package/package.json +12 -12
package/dist/manager.d.ts CHANGED
@@ -1,7 +1,10 @@
1
1
  import { type DeprovisionResourceAccounting, type IssuedBinding } from "@cotal-ai/core";
2
2
  import { type SeatCap } from "@cotal-ai/workspace";
3
- import type { PersonaEndpoint, ControlReply, EpCaller, EpErrorCode, InlinePersona, ManagerLeaseInfo, MeshLaunchAgent, RuntimeReference, SecretStore } from "@cotal-ai/core";
3
+ import type { PersonaEndpoint, ControlReply, EpCaller, EpErrorCode, InlinePersona, LaunchOpts, MeshLaunchAgent, RuntimeReference, SecretStore } from "@cotal-ai/core";
4
4
  import { type AgentHandle, type RuntimeMode } from "./runtime/index.js";
5
+ export { STATIC_RECONCILE_RETRY_DELAYS_MS } from "./managed-static-lifecycle.js";
6
+ export { ManagerInstanceLeaseHeld } from "./lease-keeper.js";
7
+ import { type ContinuityAssignment } from "./launch.js";
5
8
  import { type EpServeGrant, type GoalRef, type Identity } from "@cotal-ai/core";
6
9
  import { type ManagerStopImpact } from "./manager-service-contract.js";
7
10
  /** Backstop for the detached-launch readiness race (#159 B1). `startAgent` waits on two REAL outcomes —
@@ -42,11 +45,6 @@ export declare const RUNTIME_NO_TERMINAL_DETAIL = "ai.cotal.manager.runtime-no-t
42
45
  * seat re-reads its file only once a minute and nothing pushes the renewal to it: a tick that
43
46
  * lands in the window's last minute can come too late for the seat to adopt it. */
44
47
  export declare function credRenewIntervalMs(ttlSeconds: number): number;
45
- /** One initial terminal entry plus three re-drives. The short first retry absorbs a one-shot
46
- * broker/eviction blip; the wider later spacing avoids hammering a persistently unavailable
47
- * authority. The finite ~36s window is intentionally not a liveness inference: exhausting it
48
- * leaves the durable alias held and requires a later manager start. */
49
- export declare const STATIC_RECONCILE_RETRY_DELAYS_MS: readonly [1000, 5000, 30000];
50
48
  export interface ManagerOptions {
51
49
  space: string;
52
50
  /** Assert the embedding generation matches this Manager. Installed first-party connectors
@@ -276,19 +274,6 @@ export interface ManagerStopOptions {
276
274
  * proves it gone. A detachable seat that already exited is retired by this stop. */
277
275
  withAgents?: boolean;
278
276
  }
279
- /** `start()`'s refusal when this manager instance's lease is held (#3915): by another live process
280
- * on this workspace root, or by a holder on another root. A restart whose predecessor on this root
281
- * is dead, this process's own earlier start included, waits the key out instead (#4092). The
282
- * message is the operator copy; `held` and `sameRoot` are the data, so no caller parses it. A
283
- * lease that could not be read or written is a plain `Error`. */
284
- export declare class ManagerInstanceLeaseHeld extends Error {
285
- readonly instanceId: string;
286
- readonly space: string;
287
- readonly held: ManagerLeaseInfo;
288
- readonly sameRoot: boolean;
289
- readonly name = "ManagerInstanceLeaseHeld";
290
- constructor(message: string, instanceId: string, space: string, held: ManagerLeaseInfo, sameRoot: boolean);
291
- }
292
277
  /** Public identity selected by this manager before constructing its endpoint. Not a grant. */
293
278
  export interface ManagerServiceIdentity {
294
279
  endpoint: string;
@@ -364,7 +349,7 @@ export type ManagerResumeIdentity = {
364
349
  };
365
350
  /** A resumed seat's fork provenance: the session it forked, that session's title when it has one,
366
351
  * and the SHA-256 the connector took over the source transcript it read. */
367
- interface ForkProvenance {
352
+ export interface ForkProvenance {
368
353
  source: string;
369
354
  title?: string;
370
355
  transcriptSha256: string;
@@ -438,6 +423,16 @@ export interface ManagerResumeAgent {
438
423
  * held no local space authority to read the frontier at the cut (a remote-authority manager). */
439
424
  backfillFloor?: number;
440
425
  }
426
+ /** A crash restart of a supervised seat (#4094): its policy, the deaths counted against it including
427
+ * this one, and the roster timestamp a new heartbeat must pass to count as its readiness. */
428
+ export interface SupervisedRestart {
429
+ policy: {
430
+ restarts: number;
431
+ windowMs: number;
432
+ };
433
+ crashes: number[];
434
+ joinedAfter: number;
435
+ }
441
436
  export interface ManagerResumeInventory {
442
437
  version: "cotal-manager-resume/v2";
443
438
  space: string;
@@ -604,6 +599,150 @@ export interface StartAgentOpts {
604
599
  parent: string;
605
600
  };
606
601
  }
602
+ interface ManagedLaunch {
603
+ source: ManagerResumeAgent["launch"]["source"];
604
+ /** The runtime kind this seat was launched on. Absent means the manager's own runtime. */
605
+ runtime?: string;
606
+ cwd: string;
607
+ model?: string;
608
+ variant?: string;
609
+ prompt?: string;
610
+ subscribe?: string[];
611
+ allowSubscribe: string[];
612
+ allowPublish?: string[];
613
+ capabilities?: string[];
614
+ /** The persona's endpoint commands, as minted. Renewal re-mints their rows. */
615
+ endpoints?: PersonaEndpoint[];
616
+ events: boolean;
617
+ eventPayloads?: boolean;
618
+ shareTools?: readonly string[];
619
+ forkSource?: string;
620
+ /** Read from {@link resumeRecordPath} once the seat has written it, then kept. */
621
+ resumed?: ForkProvenance;
622
+ /** A carried resume's claim (#1499): the digest the manager staged, which the seat's fork record
623
+ * must name before {@link resumed} is set, the host it came from, and when it was staged. */
624
+ carried?: {
625
+ transcriptSha256: string;
626
+ host: string;
627
+ transferredAt: string;
628
+ };
629
+ /** The connector's {@link LaunchSpec.resumeRecordPath} for this seat's fork. */
630
+ resumeRecordPath?: string;
631
+ sessionId?: string;
632
+ unresolvedLaunchOptionKeys?: string[];
633
+ }
634
+ export interface ManagedAgent {
635
+ name: string;
636
+ role?: string;
637
+ agent: string;
638
+ /** The seat-private Claude home a carried resume launched in (#1499), removed when the seat is freed. */
639
+ seatHome?: string;
640
+ /** Stable id the manager assigned this agent at spawn: the nkey public key (static auth), or
641
+ * the owner+actor principal dot-form (user mode). */
642
+ id: string;
643
+ /** This incarnation's lifecycle UID (SPEC §13.1), minted once per spawn: the uid its
644
+ * lifecycle-keyed broker footprint (`dm_…-<uid>`/`dlv_…-<uid>`/ACL row) carries and the ONLY
645
+ * incarnation its teardown credential may name — a replayed teardown cannot reach a same-name
646
+ * successor (its uid differs). */
647
+ lifecycleUid: string;
648
+ /** Private nkey seed, kept so a later step can mint matching creds for this id. Static auth
649
+ * only — a user-mode agent has no static identity (its credential is its bearer). */
650
+ seed?: string;
651
+ /** The SPEC 13.15 issuance of a static agent's credential: the generation its rails carry and
652
+ * the accepted-row token its endpoint discovers it by. A renewal keeps both (the ceiling is
653
+ * unchanged by construction); absent on a user-mode or open agent. */
654
+ issued?: IssuedBinding;
655
+ /** Set for a USER-MODE agent: its derived owner. Marks the slot for user-mode teardown (ledger
656
+ * revoke + token/sentinel/health file removal) and the auth-health read in {@link list}. */
657
+ userOwner?: string;
658
+ /** Launched under a delegated user intent (SPEC 13.16). Only {@link Manager.retireDelegatedAgent}
659
+ * retires it: this holder's own prepare and requester bind to the holder's owner. */
660
+ delegated?: true;
661
+ /** The FS materialization paths of THIS incarnation's secret family, recorded at spawn (the
662
+ * lifecycle-keyed derivation) or at adoption (the resume inventory's recorded paths — possibly a
663
+ * previous generation's name-keyed layout). Teardown, preservation, and health reads consume
664
+ * THESE, never a re-derivation by name alone, so a stale/replayed teardown can only ever address
665
+ * this incarnation's own files — the manager-local half of the SPEC 13.1 name-disjoint
666
+ * discipline (the broker half is the uid-pinned deprovisioner). Present per mode: static =
667
+ * `creds`; user = `actorToken`/`sentinelCreds`/`health`; open = absent. Absent (never `{}`)
668
+ * when nothing was recorded, so teardown's uid-keyed derivation fallback stays reachable. */
669
+ secretPaths?: {
670
+ creds?: string;
671
+ actorToken?: string;
672
+ sentinelCreds?: string;
673
+ health?: string;
674
+ };
675
+ /** Authenticated id of the peer that requested this spawn (the control-plane `req.from.id`),
676
+ * or the manager's own id for roster/pre-spawn. Non-forgeable — set by `handle()`. The spawner
677
+ * ledger (P4b) keys own-children despawn + reap-on-parent-exit off this. */
678
+ spawner: string;
679
+ authorityParent?: string;
680
+ startedAt: number;
681
+ handle: AgentHandle;
682
+ /** This agent's local control endpoint (path + first-frame auth token), when its connector runs
683
+ * one. Kept in memory only (never persisted — token hygiene) so a graceful stop on a signal-less
684
+ * runtime (ConPTY/Windows) can send a cooperative `{op:"shutdown"}` over it instead of a hard
685
+ * kill that would deny the agent its clean mesh-leave. */
686
+ control?: {
687
+ path: string;
688
+ token: string;
689
+ };
690
+ /** Set when `Runtime.spawnDelegated` started this seat outside the manager's filesystem. Its
691
+ * handle's `stop()` is the fenced close by lifecycle key, which retirement runs only after the
692
+ * host revoked the grant, never from the stop door. */
693
+ handedOff?: true;
694
+ launch: ManagedLaunch;
695
+ /** The bounded launch wait elapsed without a join. Process liveness is separate, and an
696
+ * exact-incarnation late join clears this diagnostic without stopping the seat. */
697
+ joinIssue?: string;
698
+ /** Set on a manifest `continuity: exact` seat once its first session was proven: the coordinates
699
+ * its assignment is recorded under, kept current at every later proven rebind and at its stop. */
700
+ continuity?: Omit<ContinuityAssignment, "version" | "sessionId">;
701
+ /** In-memory process-recovery input. It is never persisted with secret values: preservation
702
+ * reconstructs it from the validated inventory and current config. Continuation-capable
703
+ * connectors (pi) receive it by default; any connector receives it when spawn carries
704
+ * `supervise`. */
705
+ restart?: {
706
+ opts: LaunchOpts;
707
+ sessionStatePath?: string;
708
+ crashes: number[];
709
+ recovering: boolean;
710
+ armed: boolean;
711
+ /** Present when spawn carried `supervise`; recoverManagedSession takes its budget from it.
712
+ * Absent on the pi path without a policy, which keeps SESSION_RESTART_LIMIT / WINDOW_MS. */
713
+ policy?: {
714
+ restarts: number;
715
+ windowMs: number;
716
+ };
717
+ };
718
+ /** Set on a `once` seat: the goal of its one task, and why this manager stopped the seat, if it
719
+ * did. The task is cancelled with that reason when the seat's exit is proved before it ended. */
720
+ once?: {
721
+ ref: GoalRef;
722
+ stopReason?: string;
723
+ retire?: string;
724
+ };
725
+ /** The connector's clause when this seat's startup ended `ready` on a connector whose idle wake
726
+ * needs a confirmed startup: mesh traffic does not wake the seat. On the spawn reply and the ps row. */
727
+ startupNotice?: string;
728
+ /** Preservation and a not-yet-confirmed resume retain broker/auth state if the process exits. */
729
+ suppressCleanup?: boolean;
730
+ /** The TERMINALIZING latch: flipped SYNCHRONOUSLY before the first await on every
731
+ * stop/despawn path (stopHandle + freeSlot are the chokepoints). Once set, this principal's
732
+ * control ops refuse and no later renewal is admitted. A renewal already admitted drains before
733
+ * the durable terminal begins, so its row and material are included in revocation and cleanup. */
734
+ terminalizing?: boolean;
735
+ /** Why this manager stopped the seat, set with {@link terminalizing} by the first stop. The exit
736
+ * watcher frees the slot with it, so an exit the stop caused is not logged or ended as the
737
+ * seat's own. */
738
+ stopCause?: FreeSlotCause;
739
+ /** Set while the manager has logged this seat off the mesh with its slot still held (#1208);
740
+ * cleared when the seat is logged back on. */
741
+ offMesh?: boolean;
742
+ /** The one renewal admitted before terminalization. Retirement drains it before revocation and
743
+ * cleanup; callers arriving after the latch never join it. */
744
+ staticCredentialRenewal?: Promise<void>;
745
+ }
607
746
  /** Runtime hooks the spawn-as-action serve path injects into {@link Manager.startAgent}.
608
747
  * Roster boot and the blocking callers pass none (unchanged behavior). */
609
748
  export interface SpawnHooks {
@@ -734,55 +873,9 @@ export declare class Manager {
734
873
  private readonly preserveStopTimeoutMs;
735
874
  private readonly endpointServeExecutorExpiresInSeconds?;
736
875
  private readonly agents;
737
- /** Names whose spawn is in flight (reserved synchronously before the provision await) — counted
738
- * toward the ceiling (once per name, see {@link Manager.occupancy}) so two concurrent same-name
739
- * spawns can't both pass the gate (P4a). Each name carries the OWNER its launch was admitted
740
- * for, so the per-owner ceiling ({@link Manager.ownerSeats}) counts a launch from the moment it
741
- * is reserved; a cap read only off `agents` would let a burst of concurrent spawns overshoot it,
742
- * because none of them has a seat yet when the next one checks. */
743
- private readonly reserved;
744
- /** Reserved names whose launch already put its seat in `agents`. The name stays reserved until
745
- * the launch settles, so no other spawn can take it, but the ceiling counts that seat through
746
- * `agents` and, if it frees young, its cooling stamp, never through the reservation (#906). */
747
- private readonly reservedLive;
748
- /** Every numbered name {@link uniqueName} has issued. A suffix carries nothing but arrival order,
749
- * so reissuing a freed one would give a later principal the name an earlier one posted under, and
750
- * a reader of that name could not tell the two apart (#382). Never pruned in-process: one string
751
- * per numbered spawn. */
752
- private readonly issuedNumberedNames;
753
876
  /** Lifecycle UIDs already handed to `Runtime.spawnDelegated`: a lifecycle is handed off at most
754
877
  * once, so a lost create acknowledgement can never become a second create. */
755
878
  private readonly delegatedLaunched;
756
- /** Expiry stamps (`startedAt + MIN_LIFETIME`) for slots that freed while still young — a
757
- * count-only, lazily-pruned recycle floor (P4c). Pruned + summed into the ceiling gate. */
758
- private cooling;
759
- /** Names RESERVED PENDING RETIREMENT: a despawned agent's name stays held until
760
- * the auth plane confirms its lifecycle's retirement TERMINAL over the auth-admin rail — the
761
- * alias-reuse gate that closes the same-name despawn→respawn race at its root. An UNCERTAIN
762
- * outcome (rail down, timeout) keeps the hold with the last attempt's copy; a same-name spawn
763
- * refuses legibly AND re-fires the request. In-memory: across a manager restart the durable
764
- * truth is the auth-side lifecycle head itself (an unretired head refuses issuance — the
765
- * named residual this belt narrows, not replaces). */
766
- private retiring;
767
- /** Exact predecessor incarnations whose full hosted retirement reached a terminal answer. Presence
768
- * is advisory and can retain that old lifecycle briefly after its process exits. Resume may ignore
769
- * only this exact (alias, principal, lifecycleUid) row when adopting a different lifecycle; every
770
- * unknown, current, or differently identified live row still refuses. A later retirement of the
771
- * same alias replaces its prior predecessor coordinate. */
772
- private readonly confirmedRetiredPredecessors;
773
- /** SINGLE-FLIGHT guard for {@link requestRetirement} (audit #1): one in-flight rail round-trip per
774
- * (name, lifecycleUid). The detached `deprovision` call and every same-name-spawn nudge for THAT
775
- * lifecycle JOIN the same promise instead of stacking independent requests that dual-enter the
776
- * barrier; a fresh trigger after it settles re-drives. Keyed by (name, uid) — NOT name alone — so a
777
- * same-name SUCCESSOR (which can spawn after the hold clears but before this flight's `nc.close`
778
- * yield settles) never joins the predecessor's rail request and skips its own retirement. */
779
- private retiringFlight;
780
- /** Wire principals of RETIRED static incarnations: populated at every completed
781
- * static terminal and from the boot sweep's retired slot rows, so a copied credential of a
782
- * retired incarnation is refused at the control surface even across a manager restart. The
783
- * durable truth is the slot row + principal-keyed head; this set is the in-memory index of it
784
- * (one string per retired incarnation — bounded by lifecycle count, never pruned in-process). */
785
- private readonly retiredPrincipals;
786
879
  /** This manager process's own incarnation uid (SPEC 13.1; minted once per supervisor process,
787
880
  * never reused across restarts) — the endpoint's presence key AND the `managerInstance` audit
788
881
  * coordinate every static activation records. */
@@ -845,11 +938,6 @@ export declare class Manager {
845
938
  /** Renews the session signing key long before its window closes. A key that expires unattended
846
939
  * takes the whole session plane down until the manager is restarted, which kills live sessions. */
847
940
  private sessionKeyRenewTimer?;
848
- /** Maps credentialId → the nkey that credential was minted for, for the live per-session
849
- * SERVING credentials. The §13.1 ledger row records the holder principal, and the row is written
850
- * at stage time (after the mint), so the two steps need this one hop. Entries are dropped at
851
- * revoke; a session that never staged drops its entry when the manager exits. */
852
- private readonly sessionServingKeys;
853
941
  /** The STABLE session-LEDGER identity (auth mode) — minted once at registration
854
942
  * alongside the serve + goal-writer identities; a renewal re-mints the SAME nkey with a fresh
855
943
  * bounded exp and re-stages its distinct credId into the §13.1 revocation family. The current
@@ -929,33 +1017,6 @@ export declare class Manager {
929
1017
  private connectorStatuses;
930
1018
  /** The boot inventory's warnings, printed once start completes, so a refused start prints none. */
931
1019
  private bootNotes;
932
- /** Static aliases whose startup exact-op terminal is still in flight. Scoped per alias: control
933
- * serves during the sweep, but no caller can reuse or attach an alias the sweep still owns. */
934
- private readonly reconcilingAliases;
935
- /** In-flight static chat-session terminals, by lifecycle UID, so every caller that retires one
936
- * session joins one terminal instead of racing its CAS sequence. */
937
- private readonly chatRetirements;
938
- /** The expiry side of every chat session this process admitted and nothing retired sooner. */
939
- private readonly chatExpiry;
940
- /** Current failed/recovered static reconciliation coordinates. This is an operator snapshot, not
941
- * lifecycle authority: every re-drive re-reads broker KV and re-runs planStaticSlotResume. */
942
- private readonly staticReconcileItems;
943
- private staticReconcileLastSweep?;
944
- staticReconcileLastSweepResources?: {
945
- slots: {
946
- examined: number;
947
- retired: number;
948
- preservedForeign: number;
949
- preservedAdopted: number;
950
- deferred: number;
951
- terminalized: number;
952
- failed: number;
953
- };
954
- deprovision?: DeprovisionResourceAccounting;
955
- };
956
- private staticReconcileSweepsInFlight;
957
- private staticReconcileDrainWaiters;
958
- private staticReconcileStopping;
959
1020
  /** The complete boot task. stop() joins it after fencing static reconciliation, so a registration
960
1021
  * already past an earlier shutdown check cannot finish after stop() returns. */
961
1022
  private startTask?;
@@ -968,14 +1029,6 @@ export declare class Manager {
968
1029
  /** Held as an instance field so broker-owning smokes can compress the schedule without changing
969
1030
  * production semantics. It is never a fence expiry: the durable non-retired row stays authoritative. */
970
1031
  private staticReconcileRetryDelaysMs;
971
- /** SINGLE-FLIGHT guard for {@link deprovision} (INT-2/C): one in-flight teardown per
972
- * (name, lifecycleUid). The detached freeSlot teardown and every same-name-spawn nudge that
973
- * re-drives it JOIN one promise instead of launching a SECOND, concurrent teardown. Without it,
974
- * two teardowns race the NAME-KEYED ledger revoke: once the first frees the alias and a successor
975
- * mints its own row, the second's delayed revoke (which carries no lifecycle coordinate) would
976
- * delete the SUCCESSOR's standing authority. Keyed by (name, uid) so a later same-name lifecycle
977
- * gets its own flight; a fresh trigger after settle re-drives only if the hold still stands. */
978
- private deprovisioningFlight;
979
1032
  /** Retirements holding one of the {@link RETIREMENT_CONCURRENCY} slots. */
980
1033
  private retirementsRunning;
981
1034
  /** Retirements waiting for a slot, oldest first. */
@@ -992,19 +1045,21 @@ export declare class Manager {
992
1045
  /** True on a USER-AUTH space (the on-disk marker; cross-checked against the registry at start).
993
1046
  * Gates the whole spawn path: user mode grants ledger actors + bearer plumbing, never static mints. */
994
1047
  private userMode;
995
- private leaseInfo?;
996
- private leaseRevision?;
997
- private leaseTimer?;
998
- /** What the last renew tick learned about this instance's key. Only a CHANGE of state is printed
999
- * (see {@link noteLease}), so an outage of hours is one line going in and one line coming out. */
1000
- private leaseState;
1001
- /** A renew is in flight. The tick must not start a second one: both would read the same cached
1002
- * revision, so whichever lands second CASes against a sequence the first already moved. */
1003
- private leaseRenewInFlight;
1004
- /** The promise a currently in-flight `renewLease()` is running, so `stop()` can await it before
1005
- * releasing the key instead of racing it: a renew that lands after the cached revision was read
1006
- * for release would otherwise move the row out from under a same-cached-revision CAS delete. */
1007
- private leaseRenewTask?;
1048
+ private readonly namesCapacity;
1049
+ private readonly servePlane;
1050
+ private resolveServeTarget;
1051
+ private readonly retirement;
1052
+ private readonly lease;
1053
+ private get leaseInfo();
1054
+ private set leaseInfo(value);
1055
+ private get leaseRevision();
1056
+ private set leaseRevision(value);
1057
+ private get leaseTimer();
1058
+ private set leaseTimer(value);
1059
+ private get leaseRenewTask();
1060
+ private acquireInstanceLease;
1061
+ private renewLease;
1062
+ private releaseOwnManagerLease;
1008
1063
  /** Set at the top of `stop()`. `renewLease` returns at once once this is set, and its `gone` arm
1009
1064
  * does not re-acquire: a manager that is stopping never puts its own key back. It also closes the
1010
1065
  * lifecycle fence ({@link beginLifecycle}), so no spawn can launch a seat the stop never sees. */
@@ -1069,6 +1124,33 @@ export declare class Manager {
1069
1124
  /** Initial NATS timeout is per dial, not per server list. Keep the aggregate deadline too, and
1070
1125
  * close a late result rather than letting an abandoned preflight or recovery install a transport. */
1071
1126
  private dialRemoteStanding;
1127
+ private readonly seatCustody;
1128
+ private readonly sessionRecovery;
1129
+ get staticReconcileLastSweepResources(): {
1130
+ slots: {
1131
+ examined: number;
1132
+ retired: number;
1133
+ preservedForeign: number;
1134
+ preservedAdopted: number;
1135
+ deferred: number;
1136
+ terminalized: number;
1137
+ failed: number;
1138
+ };
1139
+ deprovision?: DeprovisionResourceAccounting;
1140
+ } | undefined;
1141
+ set staticReconcileLastSweepResources(value: {
1142
+ slots: {
1143
+ examined: number;
1144
+ retired: number;
1145
+ preservedForeign: number;
1146
+ preservedAdopted: number;
1147
+ deferred: number;
1148
+ terminalized: number;
1149
+ failed: number;
1150
+ };
1151
+ deprovision?: DeprovisionResourceAccounting;
1152
+ } | undefined);
1153
+ private readonly staticLifecycle;
1072
1154
  constructor(opts: ManagerOptions);
1073
1155
  get runtimeKind(): string;
1074
1156
  /** Whether this manager's runtime opens a terminal stream on the seats it spawns, so a caller
@@ -1288,8 +1370,6 @@ export declare class Manager {
1288
1370
  * preserveState and stop close it before their first await, so work is either counted or rejected. */
1289
1371
  private beginLifecycle;
1290
1372
  private releaseLifecycle;
1291
- /** A cleanup spawned by accepted active-mode work is part of that work for maintenance draining,
1292
- * even where the ordinary control reply remains fire-and-forget. */
1293
1373
  private trackDeprovision;
1294
1374
  private awaitLifecycleDrain;
1295
1375
  private maintenanceError;
@@ -1342,29 +1422,10 @@ export declare class Manager {
1342
1422
  private adoptReleasedSeats;
1343
1423
  private adoptReleasedSeat;
1344
1424
  private stopRetainedAgentsOnExit;
1345
- /** Create THIS instance's lease key, waiting out a dead predecessor's row first (#4092).
1346
- *
1347
- * A manager SIGKILLed on this host cannot release its key, so a restart inside the key's TTL
1348
- * loses the create. When the row names this workspace root and a pid that is not running here
1349
- * (or is this process's own pid, which a live predecessor cannot hold), the holder is dead and
1350
- * the restart waits for the bucket TTL to remove the row, then creates again. It never writes
1351
- * over the row: a live holder renews it inside the TTL, and the wait then refuses on that write.
1352
- * Any other conflict refuses at once, as before. */
1353
- private acquireInstanceLease;
1354
1425
  /** Every call joins the first stop and settles with it. A call that asks for a different
1355
1426
  * `withAgents` is refused, since the running stop has already applied its own policy. */
1356
1427
  stop(options?: ManagerStopOptions): Promise<void>;
1357
1428
  private stopOnce;
1358
- /** Release this instance's liveness lease key on a clean stop, at the broker's own revision
1359
- * rather than a cached one that a renew still in flight moments ago may have already moved past.
1360
- * Re-reads the row and releases only what is PROVABLY this process's (absent, or another pid's,
1361
- * is left alone — the same test {@link reconcileLease} uses).
1362
- *
1363
- * A read or delete that gets no answer, as during a reconnect, is tried again until the delete is
1364
- * acknowledged or {@link LEASE_RELEASE_BUDGET_MS} has passed (#3916). Nothing here throws: a stop
1365
- * must complete either way, and a row that could not be released is left for the bucket TTL, with
1366
- * one line of warning so the cost (a same-root restart waiting out the TTL) is not silent. */
1367
- private releaseOwnManagerLease;
1368
1429
  /**
1369
1430
  * REMOVE THIS INSTANCE'S SERVICE REGISTRATION on a clean stop (§13.5 deregistration).
1370
1431
  *
@@ -1403,39 +1464,6 @@ export declare class Manager {
1403
1464
  * connection's subscriptions. If the status stream itself fails, the transport can no longer be
1404
1465
  * observed, so it counts as down. */
1405
1466
  private trackTransport;
1406
- /** Keep this instance's liveness key fresh, and end the process only when another process holds it.
1407
- *
1408
- * A renew that throws is a question, not a verdict: the request may have timed out with the write
1409
- * landed and only its acknowledgement lost, the key may have expired during a stall, or a same-id
1410
- * process may hold it. The verdict comes from RE-READING the key ({@link reconcileLease}), and each
1411
- * answer has one response:
1412
- * - `held`: adopt the broker's revision and carry on.
1413
- * - `gone`: the key expired or was released while this process was still here, so put it back. The
1414
- * create is atomic, so a same-id process that got there first shows up as `taken` next tick.
1415
- * - `taken`: a different process holds this instance's key, so it took this instance over while
1416
- * this one stalled. This process is the superseded one and stops serving by exiting (SPEC 13.1).
1417
- * An open mesh has no barrier that would evict its serve connection, so nothing else stops it.
1418
- * - `unknown`: the broker could not be asked. Keep serving and ask again next tick, for as long as it
1419
- * takes. A manager that cannot reach its broker gains nothing by ending itself, and the seats it
1420
- * holds lose everything (a pty child dies with its parent).
1421
- *
1422
- * This replaces a fail-close that ended the process one tick past the lease TTL with no answer, which
1423
- * on a live mesh turned a ten-second broker or KV outage into a manager outage that lasted until an
1424
- * operator noticed. */
1425
- private renewLease;
1426
- /** The renew attempt itself, split out from {@link renewLease} only so `stop()` can hold the
1427
- * promise a renew already in flight is running ({@link leaseRenewTask}) and await it before
1428
- * releasing the key: releasing against a cached revision a live renew has since moved is a CAS
1429
- * the broker correctly refuses, silently, forever. */
1430
- private renewLeaseAttempt;
1431
- /** Print `what` only when the lease state CHANGES. The renew ticks every few seconds, so a long
1432
- * outage would otherwise print the same line thousands of times; an operator needs the line going
1433
- * in and the line coming out, with the instance and the space on both. */
1434
- private noteLease;
1435
- /** What the broker actually says about THIS instance's lease key, right now. `unknown` is a first-class
1436
- * answer and never collapses into `gone`: not being able to look is not the same fact as looking and
1437
- * finding nothing. */
1438
- private reconcileLease;
1439
1467
  private opFinalizeResume;
1440
1468
  private opCommitResume;
1441
1469
  private opResumePreserved;
@@ -1670,11 +1698,6 @@ export declare class Manager {
1670
1698
  /** Whether a roster record is this seat's own: the readiness fence's exact principal and
1671
1699
  * incarnation, so a same-named foreign peer or an older incarnation never speaks for it (#1208). */
1672
1700
  private isOwnPresence;
1673
- /** Drop a live agent's slot. When `floor` is set and the agent died young (lived less than
1674
- * MIN_LIFETIME), push a cooling stamp so the freed slot still counts toward the ceiling until it
1675
- * expires — flooring the RECYCLE, not the call, so both free paths (despawn + exit/reap) are
1676
- * covered (P4c). Floor self + own-child despawn and natural exit; NEVER admin despawn (operator
1677
- * emergency-kill stays unthrottled) and NEVER the reserved-rollback path (no cold-start paid). */
1678
1701
  private freeSlot;
1679
1702
  /** Remove one lifecycle's inline snapshot by the path its uid derives, never by a recorded one, so a
1680
1703
  * resume inventory cannot point the removal at another file. Returns whether the file is gone. A
@@ -1683,46 +1706,12 @@ export declare class Manager {
1683
1706
  /** A live agent's teardown target, built field by field so the rest of its record (handle, seed,
1684
1707
  * restart state) never rides into the detached teardown or its single-flight map. */
1685
1708
  private teardownTarget;
1686
- /** Tear down a departed agent's minted footprint (#159 B2, auth mode): its local-principal durables
1687
- * (`dm_local-<id>`, `dlv_local-<id>`), its read-ACL row, and its creds file — everything the spawn's
1688
- * `provisionAgent` + creds-write left behind. Mints an EPHEMERAL, TARGET-PINNED `deprovisioner` cred
1689
- * (mirrors the ephemeral `provisioner`/`purger`): it can delete only THIS agent's local-principal footprint,
1690
- * never a peer's and never the role-shared `svc_<role>` (which its siblings still bind). Open mesh →
1691
- * no-op (nothing was minted). Idempotent at the broker (missing consumer / ACL row = no-op) and on
1692
- * disk (`force` tolerates an absent creds file, e.g. a ledgered deploy that wrote none).
1693
- *
1694
- * Removing the creds file is footprint REDUCTION, not revocation: a JWT copied off disk before exit
1695
- * keeps its inline publish/live-sub/control grants until key rotation or JWT expiry — cred revocation
1696
- * is the separate per-user-auth work, not this. Tearing down the durables + ACL row still shrinks the
1697
- * delivery surface a stale copy could use. */
1698
1709
  private deprovision;
1699
1710
  /** Run one retirement in a {@link RETIREMENT_CONCURRENCY} slot, oldest first: a seat's deprovision, a
1700
1711
  * chat session's terminal and a static reconcile's terminal all take one. No retirement awaits
1701
1712
  * another, so the bounded pool cannot deadlock. */
1702
1713
  private withRetirementSlot;
1703
- /** The actual footprint teardown (wrapped by {@link deprovision}'s single-flight). */
1704
- private driveDeprovision;
1705
- /** Request the auth-side retirement of a departed agent's lifecycle: an ephemeral
1706
- * `retirement-requester` credential (request + reply only), the generic `retireLifecycle` op,
1707
- * a STABLE opId (derived from the lifecycleUid, so every retry re-drives the SAME operation),
1708
- * and the four-outcome handling in operator vocabulary. */
1709
- private requestRetirement;
1710
- /** The rail round-trip for one retirement (wrapped by {@link requestRetirement}'s single-flight). */
1711
- private driveRetirement;
1712
- /** Apply one terminal retirement answer. The predecessor coordinate is recorded only when the
1713
- * answer clears this exact lifecycle's hold, never for an ABA-late answer or an incomplete hosted
1714
- * teardown whose standing authority still lives. */
1715
1714
  private confirmRetirement;
1716
- /** The teardown's ASYNC BROKER PHASE: mint the ephemeral target-pinned deprovisioner cred and
1717
- * delete the agent's broker footprint (dm_/dlv_ durables + read-ACL row). Split from
1718
- * {@link deprovision} because it runs LAST in the ordered teardown chain — after the creds/secret
1719
- * shred and the awaited ledger revoke, which precede it in that same single-flighted chain (the
1720
- * revoke is awaited and can be deliberately slow, so it is not merely a synchronous prefix). The name
1721
- * is NOT freed while any teardown phase is still in flight — the hold clears only after the
1722
- * standing-authority revoke AND the lifecycle retirement both confirm (see {@link driveRetirement}) —
1723
- * but the deletes here are still lifecycle-uid-pinned so even a replayed/stale teardown can never
1724
- * reach a same-name successor's footprint (its names embed a different uid). Each call reports its
1725
- * own accounting: the return value, or the {@link DeprovisionError} it throws once the deletes ran. */
1726
1715
  private deprovisionBroker;
1727
1716
  /** Narrow the retiring lifecycle's read-ACL row to no reads ({@link fenceLifecycleAcl}) through a
1728
1717
  * `deprovisioner` credential pinned to it. Returns undefined once fenced, or the reason it was not. */
@@ -1735,48 +1724,20 @@ export declare class Manager {
1735
1724
  * never omit a child that may still be alive. Recursive descendants are scheduled before their parent
1736
1725
  * slot can disappear. */
1737
1726
  private reapChildrenOf;
1738
- private readSessionStatePath;
1739
1727
  private readManagedSessionState;
1740
- /** Upgrade bridge: inventories written before sessionId existed can still resume exactly after
1741
- * the old Pi seat has loaded the new extension once and written its lifecycle-keyed state file. */
1742
1728
  private retainedSessionId;
1743
- /** A resumed seat's fork provenance (#1500). The seat forks after it launches, so this reads the
1744
- * record its connector named once the seat has written it, and keeps it on the launch so the
1745
- * resume document carries it across a manager restart. Until the seat has written it, or when the
1746
- * record cannot be read or does not name this seat's source, it is absent: `ps` then shows the
1747
- * source id alone rather than failing the listing for every other seat. */
1748
1729
  private forkProvenance;
1749
- private readForkRecord;
1750
- /** Design section 9: a carried seat must fork the bytes the operator carried. Wait for its fork
1751
- * record and hold it to the claim; on a match it becomes the seat's provenance, otherwise the
1752
- * refusal is returned. A seat that writes no record cannot be shown to have forked the claim. */
1753
1730
  private refuseCarriedFork;
1754
- /** A carried seat whose launch was uncertain is held to the claim once it joins, as a started one
1755
- * is; the wait ends when the seat stops or exits, which its exit watcher reaps. */
1756
1731
  private refuseLateCarriedFork;
1757
1732
  private readManagedSession;
1758
- /** Re-record an exact seat's assignment at a proven session, so crash recovery, a preserved resume
1759
- * and the next manifest launch never pick different sessions. */
1760
1733
  private recordContinuity;
1761
- /** At a stop boundary the connector's session record is the last proof of the session an exact
1762
- * seat ran, including one it switched to itself. A failed write is logged; the stop goes on. */
1763
1734
  private recordContinuityAtStop;
1764
- private awaitManagedSessionState;
1765
- /** Bind a continuation-capable connector only after its process is ready. The file proves the
1766
- * latest in-process session (including Pi /resume); the authenticated socket proves this process
1767
- * owns that session now. Presence may lead session_start by milliseconds, so both proofs are
1768
- * awaited within a bounded readiness window rather than read once. */
1769
1735
  private armSessionRecovery;
1770
- private awaitRecoveredSession;
1771
1736
  /** Why an inline seat's snapshot no longer matches its launch, or `undefined` when it does or the
1772
1737
  * seat is not inline. The recorded path and the relaunch's path must both be this lifecycle's
1773
1738
  * snapshot path, as the resume cut requires, and the file there must still be a private regular
1774
1739
  * file with the recorded digest. */
1775
1740
  private inlineSnapshotChange;
1776
- /** Restart one managed process in place. Identity, lifecycle, credentials, durables, children,
1777
- * and the manager row remain owned; only the process handle/control endpoint change. Budget
1778
- * comes from `restart.policy` when spawn carried `supervise`; otherwise the Pi session-recovery
1779
- * constants. Spending the budget falls through to normal retirement. */
1780
1741
  private recoverManagedSession;
1781
1742
  /** A managed agent's process exited: on its own (crash, /exit, finished), or after a stop this
1782
1743
  * manager started, whose recorded cause then frees the slot. Continuation-capable Pi seats
@@ -1784,36 +1745,8 @@ export declare class Manager {
1784
1745
  * way, without classifying a session-state file. Every other exit follows the existing terminal
1785
1746
  * path. */
1786
1747
  private onAgentExit;
1787
- /** Agent names become `.cotal/agents/<name>.md` paths and mesh identities, so they must be bare
1788
- * tokens, never a path — blocks traversal / arbitrary writes from a model-supplied name. In user
1789
- * mode the name is ALSO the actor, which is a narrower alphabet still; {@link spawnNameError}
1790
- * holds both halves so this door and the auto-numbering that feeds it cannot disagree. */
1791
1748
  private nameError;
1792
- /** The roster's LIVE occupant names (status !== offline) — occupants this manager may NOT manage
1793
- * (a foreground `cotal spawn`, a connector session, ANOTHER manager's agent). Allocating over any
1794
- * of them mints a sibling the broker/auth then refuses to admit, surfacing as the 30s launch-
1795
- * uncertain black hole. */
1796
- private liveRosterNames;
1797
- /** THE single name-liveness predicate both the hard-pinned collision refuse and
1798
- * uniqueName's numbering consult, so they can never drift: a name is taken if this manager
1799
- * reserves/manages/retires it OR a roster-live occupant already holds it. Pass a pre-built
1800
- * {@link liveRosterNames} set when checking many names in one allocation. */
1801
1749
  private nameInUse;
1802
- /** First free name in the series `base`, `base_2`, `base_3`, … — checked against live slots,
1803
- * in-flight (reserved) slots, names held pending retirement, AND the live mesh roster. The
1804
- * roster check covers occupants this manager does not manage (a foreground `cotal spawn`, a
1805
- * connector session, another manager's agent): allocating their name would mint a sibling the
1806
- * broker/auth then refuses to admit, surfacing as a 30s launch-uncertain black hole instead of
1807
- * the auto-number the join path gives. Presence is ADVISORY (SPEC §6) — this is an availability
1808
- * choice at allocation, never an authority check (the broker still enforces): a stale
1809
- * still-live-looking row only costs a numbered suffix, and a missed freshly-joined occupant is
1810
- * still refused downstream exactly as before. Offline rows do NOT occupy — a properly retired
1811
- * name stays reusable. A row this manager itself confirmed retired (its alias, principal, and
1812
- * lifecycleUid all matching a {@link confirmedRetiredPredecessors} entry) does not occupy
1813
- * either, even while its advisory presence record ages out. A numbered name is never reissued
1814
- * ({@link issuedNumberedNames}), even after its holder retired. The requested base is exempt
1815
- * from that history: it is the persona's own name, which stays reusable even when it once came
1816
- * out of another persona's numbering. */
1817
1750
  private uniqueName;
1818
1751
  /** Spawn a teammate by persona ref (`name` loads `.cotal/agents/<name>.md`; the peer presents
1819
1752
  * under that file's own `name:`), as if a peer asked via the control plane. Used to pre-spawn the
@@ -2035,21 +1968,8 @@ export declare class Manager {
2035
1968
  * its children (P4b/P4c). The watch is bound to the current handle: a restart swaps in a new one
2036
1969
  * and watches it, so a late exit proved for the old handle must not retire the row. */
2037
1970
  private watchExit;
2038
- /** Prune expired cooling stamps (drop those at/before now) and return the live count — the
2039
- * recycle floor's contribution to the ceiling (P4c). Lazy: pruned only when the gate consults it. */
2040
- private coolingCount;
2041
- /** What holds the ceiling's slots, one count per seat (#906). A launching seat sits in `reserved`
2042
- * from accept until its launch settles, in `agents` once its process exists, and in `cooling`
2043
- * if it then frees young, so a reservation stops counting once it reaches `agents`. `managed` is
2044
- * what this manager's `ps` lists, `reserved` is the accepted launches that have no process yet,
2045
- * and `launching` is every unsettled launch that still holds a slot through `reserved` or
2046
- * `agents`. A launch whose seat already freed holds no slot but its cooling stamp, so its
2047
- * failure can free nothing. */
2048
1971
  private occupancy;
2049
1972
  private occupancyText;
2050
- /** The capacity refusal states the split it enforces and whether waiting can free a slot: a
2051
- * cooling slot frees at a known time, an unsettled launch frees one only if it fails, and a
2052
- * managed seat frees one only when it is stopped. */
2053
1973
  private capacityRefusal;
2054
1974
  /**
2055
1975
  * The owner a launch belongs to, read ONCE so the per-owner ceiling, the agent's addressing
@@ -2145,8 +2065,6 @@ export declare class Manager {
2145
2065
  * seats, as `ps` lists them ({@link psOwnerFilter}), so a person reading a shared Manager does not
2146
2066
  * learn how many seats other owners hold on it. */
2147
2067
  private managerStatusData;
2148
- /** Render the current operator snapshot. Recovered rows live until the next sweep starts, then
2149
- * clear, so recovery is visible without becoming stale process-lifetime history. */
2150
2068
  private staticReconciliationStatus;
2151
2069
  /** Complete a crashed predecessor's FROZEN registration gate before this incarnation starts a
2152
2070
  * new one (#783 item 3 / #871). The CLI `cotal reconcile-gate` already does this; a successor
@@ -2160,45 +2078,7 @@ export declare class Manager {
2160
2078
  * is a no-op (the successor's own freeze comes next). A committed spec under that freeze is
2161
2079
  * finished at the committed registrationRevision; only a definite no-commit abort-reopens. */
2162
2080
  private healFrozenRegistrationGate;
2163
- /** #2073: dial the manager's ONE control-plane connection and serve its typed command surface on
2164
- * it, exactly the shape `registerManagerService` used inline before this lane. Shared by the
2165
- * initial registration AND the closed-connection recovery path ({@link onServeConnectionClosed}),
2166
- * so there is one place that dials and serves this endpoint. Attaches {@link
2167
- * onServeConnectionClosed} as the close handler in both cases: a closed serve connection is
2168
- * always a fault this manager acts on, never a bare log line. */
2169
2081
  private dialServeConnection;
2170
- /** #2073: re-mint the SAME `endpoint-serve` identity through the SAME scoped one-shot executor and
2171
- * §13.1 mint fence `renewDaemonCreds`'s serve branch uses — never a second copy of that mint. Used
2172
- * by both the periodic renewal pass and the closed-connection recovery path below, so a
2173
- * superseded instance's re-mint fails the SAME gate CAS in both places and lands in the exit
2174
- * path rather than needing a second epoch check. */
2175
- private remintServeCreds;
2176
- /** #2073: a closed serve connection is a FAULT the manager acts on, not a log line: this is the
2177
- * control plane a report showed staying dead for hours while the process kept its liveness
2178
- * lease and answered nothing (#2073). `stop()` sets `leaseStopping` BEFORE it tears down this
2179
- * connection, so a close landing from OUR OWN graceful teardown returns here at once. Any other
2180
- * close re-dials with the current credential (a transport blip needs nothing new), re-mints
2181
- * through the existing serve branch when the credential itself has expired, and re-serves on the
2182
- * new connection — bounded by {@link STATIC_RECONCILE_RETRY_DELAYS_MS}. Exhausting every attempt
2183
- * releases this process's lease and exits loud (without `withAgents`, so seats stay up, the path
2184
- * `supervise`'s signal handler already uses) so a restart can serve: a manager that holds the
2185
- * lease and answers nothing is the worst of the three states this issue named, and holding the
2186
- * connection open under unbounded reconnects (the transport-drop case) never reaches this method
2187
- * at all — `nc.closed()` does not resolve until the client itself gives up. */
2188
- private onServeConnectionClosed;
2189
- /** Register the manager as an ordinary v0.4 `service` endpoint and serve its typed
2190
- * command surface on the ep rails - the manager's ONLY control door. On an AUTH mesh
2191
- * the whole credential path is the SAME one an ordinary endpoint traverses (the enforcement
2192
- * test that keeps "ordinary" honest): provision the §13.1 issuance gate, drive the
2193
- * registration BARRIER's gate CAS, then release the serve credential only on the mint FENCE's
2194
- * revision-pinned CAS win — all over the scoped one-shot executor ({@link
2195
- * withEndpointServeExecutor}), never a seed-signed shortcut. Holding the signing seed only
2196
- * AUTHORIZES the reserved single-label name (`manager`, operator name authority, DEV_OWNER).
2197
- * On an OPEN mesh the same gate/registration/serve-grant ceremony runs over bare one-shot
2198
- * connections and NO credential is ever minted: there is no credential system to issue from,
2199
- * so the gate legitimately keeps an empty `epcred` family (the §13.1 fence is issuance-only)
2200
- * and the serve connection is bare — the broker enforces nothing on an open mesh, exactly the
2201
- * old open-mesh ctl trust ("open = single-trusted-host"). */
2202
2082
  private registerManagerService;
2203
2083
  /** Mint the standing `goal-writer` credential and STAGE it into this
2204
2084
  * instance's §13.1 revocation family (`epcred.<e>.<iid>`), over the passed executor's `authKv`
@@ -2236,67 +2116,8 @@ export declare class Manager {
2236
2116
  private startGoalWriter;
2237
2117
  /** Retire the goal-writer connection (best-effort, both exit paths). */
2238
2118
  private stopGoalWriter;
2239
- /** Mint the standing `session-ledger` credential and STAGE it into this instance's
2240
- * §13.1 revocation family (`epcred.<e>.<iid>`), over the passed executor's `authKv`, following the
2241
- * {@link mintAndStageGoalWriter} pattern under the same open-and-commit fence.
2242
- *
2243
- * This credential carries the DEDICATED sessions-bucket ledger rows and no session rail at all.
2244
- * It therefore takes no epoch pin: §13.6 makes it the durable revocation authority that must
2245
- * outlive the serving endpoint, so scoping it to one serving epoch would defeat its purpose. The
2246
- * epoch lives where it belongs, on the per-session serving credentials, which are minted per
2247
- * redemption into this same family. Because `mintCreds` stamps a random `issuance:` tag on
2248
- * `session-ledger` (`userTags`), re-minting the SAME nkey on renewal or restart signs distinct
2249
- * bytes and stages a distinct ledger row (per-JWT `credentialId` digest) even within one
2250
- * second. */
2251
2119
  private mintAndStageSessionLedger;
2252
- /** #2073: dial the session-ledger's ONE standing connection — shared by the initial start and the
2253
- * closed-connection recovery ({@link onSessionLedgerConnectionClosed}), the same shape {@link
2254
- * dialGoalWriter} uses for its rail. The KV/JetStream clients the session plane opened from the
2255
- * connection at start stay bound to it for this incarnation's life; a redial refreshes the
2256
- * standing authenticator connection the credential renewal presents onto (mirroring `sw.creds`),
2257
- * which is what a closed-connection fault on this rail needs restored. */
2258
- private dialSessionLedgerConnection;
2259
- /** #2073: the session-ledger rail's closed-connection fault, the same bounded shape {@link
2260
- * onGoalWriterConnectionClosed} uses: re-dial with the current credential, re-mint through the
2261
- * existing session-ledger renewal branch when the credential itself has expired, then re-attach.
2262
- * Exhaustion logs and leaves the credential to the next renewal pass; it never exits the process
2263
- * (brief step 4: only the serve rail is the control plane the report lost). */
2264
- private onSessionLedgerConnectionClosed;
2265
- /** Stand up the ONE §13.6 session plane on its own standing connection. Mode-dual,
2266
- * mirroring {@link startGoalWriter}: an AUTH mesh presents the scoped `session-ledger` cred
2267
- * already minted + family-staged inside registration's run block ({@link mintAndStageSessionLedger});
2268
- * an OPEN mesh uses a bare connection (no credential system to mint from). The connection presents
2269
- * the CURRENT credential on every (re)connect, so a half-TTL renewal is adopted without reconnecting.
2270
- *
2271
- * The offer SIGNER is a per-incarnation in-memory keypair: the static collapsed path mints AND
2272
- * redeems the offer in one call ({@link ManagerSessionPlane.establishAttach}), so the manager
2273
- * self-signs and self-verifies its own §13.6 grants and the keypair never leaves the process — a
2274
- * holder never verifies the signature (it presents the grant back over the rail; the broker's
2275
- * per-session caller cred is the holder's real fence). The plane's ledger lives in the DEDICATED
2276
- * sessions bucket (createEndpointStreams provisioned it at registration). */
2277
2120
  private startSessionPlane;
2278
- /**
2279
- * The per-session SERVING credential seam (SPEC 13.6): the manager mints, gate-stages,
2280
- * connects and revokes ONE credential per live session, replacing a standing credential that held
2281
- * `eps.manager.*.<epoch>.{in,out}` and so reached every live session's bytes at its epoch.
2282
- *
2283
- * Each session gets its OWN nkey identity, so the §13.1 barrier's evict-by-holderPrincipal reaches
2284
- * it individually, and each is staged into `epcred.manager.<instanceId>` — the SAME family the
2285
- * ledger and goal-writer creds join. That is how manager takeover still kills a deposed manager's
2286
- * sessions: the barrier enumerates the family, revokes every row, and evicts every holder, so the
2287
- * per-session creds die with the incarnation exactly as the standing one did, with the blast
2288
- * radius of a leaked credential cut from "every session at this epoch" to "one dead session".
2289
- *
2290
- * OPEN MESH: no credential system exists to mint from, so the seam mints nothing and opens a bare
2291
- * connection. That is not a degraded auth path — an open mesh has no broker enforcement at all —
2292
- * and it is still per-session: the connection and the ledger row are still one-per-session, so
2293
- * teardown behaves identically in both modes.
2294
- */
2295
- private sessionServingCredentials;
2296
- /** Tear the session plane down (best-effort, both exit paths): end every live bridge with the
2297
- * honest `manager-restart` reason (this incarnation is going away; any successor takes a new epoch
2298
- * and refuses these grants), then drain each session's own connection and retire the ledger
2299
- * connection ({@link retireConnection}). */
2300
2121
  private stopSessionPlane;
2301
2122
  /** The boot reconcile: a fresh incarnation (a manager restart takes a NEW
2302
2123
  * instanceId, so the in-memory acceptance map starts empty) inherits the endpoint's accepted-but-
@@ -2534,157 +2355,30 @@ export declare class Manager {
2534
2355
  * despawn (the process teardown is authoritative for the agent; this settles the GOAL honestly).
2535
2356
  * Cancel rides the despawn's own authorizeNamed reach - there is no cancel-by-goalId. */
2536
2357
  private cancelAgentGoal;
2537
- /** Re-record the custody reference of a managed agent's CURRENT handle on its active slot: a
2538
- * same-lifecycle restart or a resume binds a new custody under the old uid, and the successor's
2539
- * reap must address the live one. Static auth only; a runtime without durable custody records
2540
- * nothing (there is nothing to reap by reference). */
2541
2358
  private recordSlotRuntime;
2542
- /** Record one custody reference on an agent's ACTIVE slot. Split from {@link recordSlotRuntime}
2543
- * so a restart or a resume can record the reference it RESERVED before spawning, while no
2544
- * handle exists yet. Static auth only; a runtime without durable custody reserves nothing.
2545
- * Throws when the slot does not take the reference: a slot left on the previous one reaps that
2546
- * seat, already gone, so a successor would retire the lifecycle over the new one. */
2547
2359
  private recordSlotCustody;
2548
- /** Mint the custody reference for a seat this manager is about to spawn, BEFORE the processes
2549
- * exist. Absent for a runtime with no durable custody (there is nothing a successor could reap
2550
- * by reference), which is the only case that still spawns unreserved. */
2551
2360
  private reserveCustody;
2552
- /** Spawn under a reserved reference and prove the runtime honoured it. A runtime that minted its
2553
- * own id instead would leave every durable record addressing a seat that does not exist, so the
2554
- * mismatch tears the new seat down and throws rather than returning an unaddressable handle. */
2555
2361
  private spawnCustodied;
2556
2362
  /** Keep launch provenance independent of status and runtime wire contracts. */
2557
2363
  private watchConnectorHolder;
2558
- /** Persist what a successor needs to take this seat back if this process ends without stopping
2559
- * it: a supervised seat, which a successor restarts (#4094), and a seat on a runtime that can adopt
2560
- * it by reference, which a successor adopts while it still runs (#4095). Static meshes only: a
2561
- * successor finds the seat through its active slot row, and only a static mesh keeps one. Throws
2562
- * when a supervised seat's entry could not be resumed, because a policy this host cannot keep
2563
- * across a manager restart is one it cannot enforce. */
2564
2364
  private recordSeat;
2565
- /** Bring a running seat's record up to date after its credential or restart count changed. A
2566
- * record that cannot be rewritten is removed, so a successor retires the seat rather than taking
2567
- * it back from a stale one. */
2568
2365
  private refreshSeatRecord;
2569
2366
  private dropSeatRecord;
2570
2367
  /** True when a default stop wrote a runtime reference for this exact lifecycle and it is still
2571
2368
  * there. That file is what a later manager adopts, so a slot free must not remove it before the
2572
2369
  * retirement that confirms the lifecycle is gone. */
2573
2370
  private releasedSeatPending;
2574
- /** The seat record behind one active slot this instance owns, when it describes that exact
2575
- * incarnation on this runtime. Anything else is left to the ordinary terminal. */
2576
2371
  private seatRecordFor;
2577
- /** Take back a seat that outlived its manager (#4095): the runtime reattaches to the exact seat
2578
- * the slot names, and this manager holds it under the record's identity and launch, with no
2579
- * relaunch. Returns why it could not, and the caller then retires the lifecycle, which reaps the
2580
- * seat by the same reference. */
2581
2372
  private adoptSeat;
2582
- /** Restart a supervised seat whose manager ended without stopping it (#4094), as one restart of
2583
- * its own policy. It goes through the resume launch, so the seat comes back under the same name,
2584
- * lifecycle uid, credential, persona and cwd, and a pending turn addressed to it is served to it.
2585
- * Returns why it could not, and the caller then retires the lifecycle. */
2586
2373
  private restartSupervisedSeat;
2587
- /** The terminal's process step: an orphan (no live handle in THIS process) is reaped by the custody
2588
- * reference the slot recorded, before its footprint goes. A successor must never retire a
2589
- * lifecycle and free its alias while the predecessor's seat process is still running outside
2590
- * every manager. The runtime verifies the process identity against its own record and proves the
2591
- * exit; a runtime that cannot reap refuses by name and the lifecycle stays terminalizing. A row
2592
- * with no recorded reference has nothing this manager can address. */
2593
2374
  private reapOrphanSeat;
2594
- /** The static terminal for one departed incarnation: delegates the gate/head CAS
2595
- * sequence to the shared core saga over the executor transport; the footprint teardown (creds
2596
- * file + broker durables/ACL) runs INSIDE the barrier as its cleanup step. On completion the
2597
- * wire principal joins {@link retiredPrincipals} (the retired-principal refusal index) and the name hold
2598
- * clears (ABA-guarded by uid). A lifecycle with no slot row (spawned before the
2599
- * durable registry existed) has nothing to terminalize: its footprint teardown runs directly
2600
- * and the hold clears, the honest upgrade path. `onDeprovision` receives the accounting of the
2601
- * broker teardown this call ran, on success or on a {@link DeprovisionError}. */
2602
2375
  private driveStaticRetirement;
2603
- /** `chat-session-open`: admit one static chat session. The manager draws the `chat_` alias and a
2604
- * fresh nkey identity, then runs the same native steps a static spawn does: the slot intent and
2605
- * the shared activation saga, the provisioner's bind-only DM and DELIVER durables plus the ACL
2606
- * row, and the agent-profile mint. The leaf carries the spawn's three lists under the spawn's
2607
- * rules (`resolveReadAcl`, a default-deny post list, the foreign event-channel refusal) and
2608
- * nothing else: no role (so no TASK queue), no capabilities, no endpoint rows, no issuance. It
2609
- * expires at `ttl` with no renewal, because no managed row exists to renew it.
2610
- *
2611
- * The session is registered with the tracker before the first durable write and scheduled for
2612
- * its expiry before the reply is sent, or after a rollback that did not complete, so this
2613
- * process retires it at the expiry even when the reply is lost or the client never retires.
2614
- *
2615
- * The credential is ledgered before it leaves this process (slot credentialId, then the `cred.`
2616
- * row), so the static terminal marks the row revoked and verify-evicts the session's principal;
2617
- * the broker keeps accepting the leaf until its expiry. The direct ledger write is deliberate:
2618
- * the leaf is not an issuance, so the issuance seam, which writes the same row inside its
2619
- * finalization, never runs for it, and without the row the terminal's eviction set would be
2620
- * empty. The credential leaves only sealed to `sealTo`, bound to the space, this instance and
2621
- * the reply's fields, so a reply printed anywhere carries no usable credential. A failure at
2622
- * any step drives the terminal before the refusal is returned, and the refusal says whether it
2623
- * completed. */
2624
2376
  private openStaticChatSession;
2625
- /** `chat-session-retire`: end one static chat session through the native static terminal (ledger
2626
- * row marked revoked, verified eviction of its principal's live connections, footprint cleanup,
2627
- * gate and head retirement). It refuses before any effect unless {@link admitChatRetirement}
2628
- * admits the request. A terminal that cannot complete answers `failed` with the reason, never
2629
- * success; the slot stays held. The broker keeps accepting the leaf until its expiry either way. */
2630
2377
  private retireStaticChatSession;
2631
- /** The expiry cleanup's retirement of one session this process admitted. It is lifecycle work, so
2632
- * it is admitted like a control call and a stop drains it. A throw is a failure the tracker
2633
- * retries; a slot that is no longer this instance's to retire ends the tracking instead. */
2634
- private expireStaticChatSession;
2635
- /** The ownership admission shared by `chat-session-retire`, the expiry and the stop. It throws a
2636
- * not-executed refusal unless the alias is a chat alias whose slot this logical instance owns
2637
- * at the requested UID and actor. An already retired slot ends its expiry tracking. */
2638
- private admitChatRetirement;
2639
- /** One static terminal per chat session UID, however many callers ask: the explicit retire, the
2640
- * expiry cleanup and the open's rollback join it instead of racing its CAS sequence. A completed
2641
- * terminal ends the expiry tracking. `channels` names the membership rows to delete by name;
2642
- * without it the delivery inventory alone finds them. */
2643
- private chatTerminal;
2644
- /** Whether `row` is a chat slot this process registered, at its exact alias, actor and UID,
2645
- * under this logical instance and this process's incarnation. */
2646
- private holdsLiveChatSlot;
2647
- /** The stop's retirement of every chat session this process still tracks, through the same
2648
- * ownership admission and terminal as `chat-session-retire`, at most
2649
- * {@link CHAT_EXPIRY_CONCURRENCY} at a time. It runs after the lifecycle fence closed and every
2650
- * admitted operation drained, as the seat teardown does, and mints nothing the terminal does not
2651
- * already mint. Every outcome is logged. It throws, naming each one, when any session was not
2652
- * retired; that session stays held until the next start of this manager instance. */
2653
2378
  private retireChatSessionsOnStop;
2654
- /** Name, at a stop that does not retire them, each chat session this process still tracks. */
2655
2379
  private reportChatSessionsLeftAtStop;
2656
- /** Push renewal of ONE live managed-static credential: re-mint the SAME nkey
2657
- * identity with the SAME scope (recorded on the managed row at spawn) and a fresh bounded
2658
- * exp, ledger the new credentialId (slot record first, then the row, then the file — a
2659
- * credential is never materialized before its ledger row exists), and re-sign the SAME
2660
- * lifecycle-keyed file the agent endpoint's source seam re-reads. Never advances the epoch;
2661
- * renewal remains the THIRD transition. */
2662
2380
  private renewManagedStaticCred;
2663
- private driveManagedStaticCredRenewal;
2664
- /** The static-slot reconciliation ("no active orphan"): ensure the authority stores, then sweep
2665
- * every durable slot row and act by the TOTAL resume table — `provisioning`/`terminalizing`
2666
- * re-drive the exact-op terminal; an `active` row survives ONLY when a LIVE managed agent this
2667
- * manager process owns backs it at the same uid (`adopted`), else no managed owner claimed it and
2668
- * its broker authority is contained and terminalized; `retired` rows seed the retired-principal refusal index. Two call sites: the BOOT sweep
2669
- * (`postAdoption=false`, under the lease before control serving) DEFERS active-non-adopted
2670
- * slots while a resume is still pending (adoption runs after it); the POST-ADOPTION sweep
2671
- * (`postAdoption=true`, inside finalizeResume while `resumeRequired` still fences ordinary
2672
- * spawns) terminalizes any active slot the resume did not claim. */
2673
- private staticReconcileKey;
2674
- /** Read one retry coordinate from the durable slot store. The status snapshot never authorizes a
2675
- * re-drive: every timer comes through this fresh read before the planner and exact terminal. */
2676
2381
  private readStaticReconcileSlot;
2677
- private scheduleStaticReconcileRetry;
2678
- private retryStaticReconcile;
2679
- private driveStaticReconcileRetry;
2680
- /** Enter one exact terminal at most once per coordinate. Sweep and timer triggers join the same
2681
- * promise. A settled failed item keeps its original per-process budget; a restart builds a fresh
2682
- * map from the still-authoritative durable row. */
2683
- private attemptStaticReconcile;
2684
- private releaseStaticReconcileSweep;
2685
- /** Shutdown accepts no new static reconciliation work, then drains every sweep and exact-terminal
2686
- * flight that crossed the fence before stop(). A sweep can discover several rows before its first
2687
- * await, so the serial loop also consults the fence and never starts a later row after shutdown. */
2688
2382
  private awaitStaticReconcileDrain;
2689
2383
  private reconcileStaticLifecycles;
2690
2384
  /** The membership gate: decide a control caller by its
@@ -2802,5 +2496,4 @@ export declare class Manager {
2802
2496
  * owner-domain bound); undefined = unbounded. {@link NO_OWNER_MATCHES} matches nothing. */
2803
2497
  private list;
2804
2498
  }
2805
- export {};
2806
2499
  //# sourceMappingURL=manager.d.ts.map