@cotal-ai/manager 0.166.2 → 0.167.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.
@@ -9369,6 +9369,8 @@ ${stack}`;
9369
9369
  }
9370
9370
  var EP_AUTHZ_MODES = Object.freeze(["self", "owner", "any", "child", "ledger", "handle", "exact"]);
9371
9371
  var AUTHZ_SET = new Set(EP_AUTHZ_MODES);
9372
+ var EP_PRINCIPAL_AUTHORITIES = Object.freeze(["owner", "grant"]);
9373
+ var PRINCIPAL_AUTHORITY_SET = new Set(EP_PRINCIPAL_AUTHORITIES);
9372
9374
  function epsSubject(space, endpoint, sessionId, epoch, dir) {
9373
9375
  return assertSized(`${spacePrefix(space)}.eps.${endpointToken(endpoint)}.${assertIdToken(sessionId, "sessionId")}.${assertEpoch(epoch)}.${dir}`);
9374
9376
  }
@@ -0,0 +1,5 @@
1
+ export declare const RESTART_WORK_EXIT_MS = 10000;
2
+ /** Reject `p` with `Error(msg)` if it hasn't settled within `ms`; clears the timer when `p` settles so it
3
+ * never keeps the loop alive. Used to bound the detached deprovision so its fail-loud log is guaranteed. */
4
+ export declare function withTimeout<T>(p: Promise<T>, ms: number, msg: string): Promise<T>;
5
+ //# sourceMappingURL=manager-timeout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manager-timeout.d.ts","sourceRoot":"","sources":["../src/manager-timeout.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,QAAS,CAAC;AAE3C;6GAC6G;AAC7G,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAMjF"}
@@ -0,0 +1,11 @@
1
+ export const RESTART_WORK_EXIT_MS = 10_000;
2
+ /** Reject `p` with `Error(msg)` if it hasn't settled within `ms`; clears the timer when `p` settles so it
3
+ * never keeps the loop alive. Used to bound the detached deprovision so its fail-loud log is guaranteed. */
4
+ export function withTimeout(p, ms, msg) {
5
+ let timer;
6
+ const timeout = new Promise((_, reject) => {
7
+ timer = setTimeout(() => reject(new Error(msg)), ms);
8
+ });
9
+ return Promise.race([p.finally(() => clearTimeout(timer)), timeout]);
10
+ }
11
+ //# sourceMappingURL=manager-timeout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manager-timeout.js","sourceRoot":"","sources":["../src/manager-timeout.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC;AAE3C;6GAC6G;AAC7G,MAAM,UAAU,WAAW,CAAI,CAAa,EAAE,EAAU,EAAE,GAAW;IACnE,IAAI,KAAoC,CAAC;IACzC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE;QAC/C,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;AACvE,CAAC"}
package/dist/manager.d.ts CHANGED
@@ -1,7 +1,8 @@
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, ManagerLeaseInfo, MeshLaunchAgent, RuntimeReference, SecretStore } from "@cotal-ai/core";
4
4
  import { type AgentHandle, type RuntimeMode } from "./runtime/index.js";
5
+ import { type ContinuityAssignment } from "./launch.js";
5
6
  import { type EpServeGrant, type GoalRef, type Identity } from "@cotal-ai/core";
6
7
  import { type ManagerStopImpact } from "./manager-service-contract.js";
7
8
  /** Backstop for the detached-launch readiness race (#159 B1). `startAgent` waits on two REAL outcomes —
@@ -364,7 +365,7 @@ export type ManagerResumeIdentity = {
364
365
  };
365
366
  /** A resumed seat's fork provenance: the session it forked, that session's title when it has one,
366
367
  * and the SHA-256 the connector took over the source transcript it read. */
367
- interface ForkProvenance {
368
+ export interface ForkProvenance {
368
369
  source: string;
369
370
  title?: string;
370
371
  transcriptSha256: string;
@@ -438,6 +439,16 @@ export interface ManagerResumeAgent {
438
439
  * held no local space authority to read the frontier at the cut (a remote-authority manager). */
439
440
  backfillFloor?: number;
440
441
  }
442
+ /** A crash restart of a supervised seat (#4094): its policy, the deaths counted against it including
443
+ * this one, and the roster timestamp a new heartbeat must pass to count as its readiness. */
444
+ export interface SupervisedRestart {
445
+ policy: {
446
+ restarts: number;
447
+ windowMs: number;
448
+ };
449
+ crashes: number[];
450
+ joinedAfter: number;
451
+ }
441
452
  export interface ManagerResumeInventory {
442
453
  version: "cotal-manager-resume/v2";
443
454
  space: string;
@@ -604,6 +615,150 @@ export interface StartAgentOpts {
604
615
  parent: string;
605
616
  };
606
617
  }
618
+ interface ManagedLaunch {
619
+ source: ManagerResumeAgent["launch"]["source"];
620
+ /** The runtime kind this seat was launched on. Absent means the manager's own runtime. */
621
+ runtime?: string;
622
+ cwd: string;
623
+ model?: string;
624
+ variant?: string;
625
+ prompt?: string;
626
+ subscribe?: string[];
627
+ allowSubscribe: string[];
628
+ allowPublish?: string[];
629
+ capabilities?: string[];
630
+ /** The persona's endpoint commands, as minted. Renewal re-mints their rows. */
631
+ endpoints?: PersonaEndpoint[];
632
+ events: boolean;
633
+ eventPayloads?: boolean;
634
+ shareTools?: readonly string[];
635
+ forkSource?: string;
636
+ /** Read from {@link resumeRecordPath} once the seat has written it, then kept. */
637
+ resumed?: ForkProvenance;
638
+ /** A carried resume's claim (#1499): the digest the manager staged, which the seat's fork record
639
+ * must name before {@link resumed} is set, the host it came from, and when it was staged. */
640
+ carried?: {
641
+ transcriptSha256: string;
642
+ host: string;
643
+ transferredAt: string;
644
+ };
645
+ /** The connector's {@link LaunchSpec.resumeRecordPath} for this seat's fork. */
646
+ resumeRecordPath?: string;
647
+ sessionId?: string;
648
+ unresolvedLaunchOptionKeys?: string[];
649
+ }
650
+ export interface ManagedAgent {
651
+ name: string;
652
+ role?: string;
653
+ agent: string;
654
+ /** The seat-private Claude home a carried resume launched in (#1499), removed when the seat is freed. */
655
+ seatHome?: string;
656
+ /** Stable id the manager assigned this agent at spawn: the nkey public key (static auth), or
657
+ * the owner+actor principal dot-form (user mode). */
658
+ id: string;
659
+ /** This incarnation's lifecycle UID (SPEC §13.1), minted once per spawn: the uid its
660
+ * lifecycle-keyed broker footprint (`dm_…-<uid>`/`dlv_…-<uid>`/ACL row) carries and the ONLY
661
+ * incarnation its teardown credential may name — a replayed teardown cannot reach a same-name
662
+ * successor (its uid differs). */
663
+ lifecycleUid: string;
664
+ /** Private nkey seed, kept so a later step can mint matching creds for this id. Static auth
665
+ * only — a user-mode agent has no static identity (its credential is its bearer). */
666
+ seed?: string;
667
+ /** The SPEC 13.15 issuance of a static agent's credential: the generation its rails carry and
668
+ * the accepted-row token its endpoint discovers it by. A renewal keeps both (the ceiling is
669
+ * unchanged by construction); absent on a user-mode or open agent. */
670
+ issued?: IssuedBinding;
671
+ /** Set for a USER-MODE agent: its derived owner. Marks the slot for user-mode teardown (ledger
672
+ * revoke + token/sentinel/health file removal) and the auth-health read in {@link list}. */
673
+ userOwner?: string;
674
+ /** Launched under a delegated user intent (SPEC 13.16). Only {@link Manager.retireDelegatedAgent}
675
+ * retires it: this holder's own prepare and requester bind to the holder's owner. */
676
+ delegated?: true;
677
+ /** The FS materialization paths of THIS incarnation's secret family, recorded at spawn (the
678
+ * lifecycle-keyed derivation) or at adoption (the resume inventory's recorded paths — possibly a
679
+ * previous generation's name-keyed layout). Teardown, preservation, and health reads consume
680
+ * THESE, never a re-derivation by name alone, so a stale/replayed teardown can only ever address
681
+ * this incarnation's own files — the manager-local half of the SPEC 13.1 name-disjoint
682
+ * discipline (the broker half is the uid-pinned deprovisioner). Present per mode: static =
683
+ * `creds`; user = `actorToken`/`sentinelCreds`/`health`; open = absent. Absent (never `{}`)
684
+ * when nothing was recorded, so teardown's uid-keyed derivation fallback stays reachable. */
685
+ secretPaths?: {
686
+ creds?: string;
687
+ actorToken?: string;
688
+ sentinelCreds?: string;
689
+ health?: string;
690
+ };
691
+ /** Authenticated id of the peer that requested this spawn (the control-plane `req.from.id`),
692
+ * or the manager's own id for roster/pre-spawn. Non-forgeable — set by `handle()`. The spawner
693
+ * ledger (P4b) keys own-children despawn + reap-on-parent-exit off this. */
694
+ spawner: string;
695
+ authorityParent?: string;
696
+ startedAt: number;
697
+ handle: AgentHandle;
698
+ /** This agent's local control endpoint (path + first-frame auth token), when its connector runs
699
+ * one. Kept in memory only (never persisted — token hygiene) so a graceful stop on a signal-less
700
+ * runtime (ConPTY/Windows) can send a cooperative `{op:"shutdown"}` over it instead of a hard
701
+ * kill that would deny the agent its clean mesh-leave. */
702
+ control?: {
703
+ path: string;
704
+ token: string;
705
+ };
706
+ /** Set when `Runtime.spawnDelegated` started this seat outside the manager's filesystem. Its
707
+ * handle's `stop()` is the fenced close by lifecycle key, which retirement runs only after the
708
+ * host revoked the grant, never from the stop door. */
709
+ handedOff?: true;
710
+ launch: ManagedLaunch;
711
+ /** The bounded launch wait elapsed without a join. Process liveness is separate, and an
712
+ * exact-incarnation late join clears this diagnostic without stopping the seat. */
713
+ joinIssue?: string;
714
+ /** Set on a manifest `continuity: exact` seat once its first session was proven: the coordinates
715
+ * its assignment is recorded under, kept current at every later proven rebind and at its stop. */
716
+ continuity?: Omit<ContinuityAssignment, "version" | "sessionId">;
717
+ /** In-memory process-recovery input. It is never persisted with secret values: preservation
718
+ * reconstructs it from the validated inventory and current config. Continuation-capable
719
+ * connectors (pi) receive it by default; any connector receives it when spawn carries
720
+ * `supervise`. */
721
+ restart?: {
722
+ opts: LaunchOpts;
723
+ sessionStatePath?: string;
724
+ crashes: number[];
725
+ recovering: boolean;
726
+ armed: boolean;
727
+ /** Present when spawn carried `supervise`; recoverManagedSession takes its budget from it.
728
+ * Absent on the pi path without a policy, which keeps SESSION_RESTART_LIMIT / WINDOW_MS. */
729
+ policy?: {
730
+ restarts: number;
731
+ windowMs: number;
732
+ };
733
+ };
734
+ /** Set on a `once` seat: the goal of its one task, and why this manager stopped the seat, if it
735
+ * did. The task is cancelled with that reason when the seat's exit is proved before it ended. */
736
+ once?: {
737
+ ref: GoalRef;
738
+ stopReason?: string;
739
+ retire?: string;
740
+ };
741
+ /** The connector's clause when this seat's startup ended `ready` on a connector whose idle wake
742
+ * needs a confirmed startup: mesh traffic does not wake the seat. On the spawn reply and the ps row. */
743
+ startupNotice?: string;
744
+ /** Preservation and a not-yet-confirmed resume retain broker/auth state if the process exits. */
745
+ suppressCleanup?: boolean;
746
+ /** The TERMINALIZING latch: flipped SYNCHRONOUSLY before the first await on every
747
+ * stop/despawn path (stopHandle + freeSlot are the chokepoints). Once set, this principal's
748
+ * control ops refuse and no later renewal is admitted. A renewal already admitted drains before
749
+ * the durable terminal begins, so its row and material are included in revocation and cleanup. */
750
+ terminalizing?: boolean;
751
+ /** Why this manager stopped the seat, set with {@link terminalizing} by the first stop. The exit
752
+ * watcher frees the slot with it, so an exit the stop caused is not logged or ended as the
753
+ * seat's own. */
754
+ stopCause?: FreeSlotCause;
755
+ /** Set while the manager has logged this seat off the mesh with its slot still held (#1208);
756
+ * cleared when the seat is logged back on. */
757
+ offMesh?: boolean;
758
+ /** The one renewal admitted before terminalization. Retirement drains it before revocation and
759
+ * cleanup; callers arriving after the latch never join it. */
760
+ staticCredentialRenewal?: Promise<void>;
761
+ }
607
762
  /** Runtime hooks the spawn-as-action serve path injects into {@link Manager.startAgent}.
608
763
  * Roster boot and the blocking callers pass none (unchanged behavior). */
609
764
  export interface SpawnHooks {
@@ -756,33 +911,6 @@ export declare class Manager {
756
911
  /** Expiry stamps (`startedAt + MIN_LIFETIME`) for slots that freed while still young — a
757
912
  * count-only, lazily-pruned recycle floor (P4c). Pruned + summed into the ceiling gate. */
758
913
  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
914
  /** This manager process's own incarnation uid (SPEC 13.1; minted once per supervisor process,
787
915
  * never reused across restarts) — the endpoint's presence key AND the `managerInstance` audit
788
916
  * coordinate every static activation records. */
@@ -845,11 +973,6 @@ export declare class Manager {
845
973
  /** Renews the session signing key long before its window closes. A key that expires unattended
846
974
  * takes the whole session plane down until the manager is restarted, which kills live sessions. */
847
975
  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
976
  /** The STABLE session-LEDGER identity (auth mode) — minted once at registration
854
977
  * alongside the serve + goal-writer identities; a renewal re-mints the SAME nkey with a fresh
855
978
  * bounded exp and re-stages its distinct credId into the §13.1 revocation family. The current
@@ -968,14 +1091,6 @@ export declare class Manager {
968
1091
  /** Held as an instance field so broker-owning smokes can compress the schedule without changing
969
1092
  * production semantics. It is never a fence expiry: the durable non-retired row stays authoritative. */
970
1093
  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
1094
  /** Retirements holding one of the {@link RETIREMENT_CONCURRENCY} slots. */
980
1095
  private retirementsRunning;
981
1096
  /** Retirements waiting for a slot, oldest first. */
@@ -992,6 +1107,9 @@ export declare class Manager {
992
1107
  /** True on a USER-AUTH space (the on-disk marker; cross-checked against the registry at start).
993
1108
  * Gates the whole spawn path: user mode grants ledger actors + bearer plumbing, never static mints. */
994
1109
  private userMode;
1110
+ private readonly servePlane;
1111
+ private resolveServeTarget;
1112
+ private readonly retirement;
995
1113
  private leaseInfo?;
996
1114
  private leaseRevision?;
997
1115
  private leaseTimer?;
@@ -1069,6 +1187,8 @@ export declare class Manager {
1069
1187
  /** Initial NATS timeout is per dial, not per server list. Keep the aggregate deadline too, and
1070
1188
  * close a late result rather than letting an abandoned preflight or recovery install a transport. */
1071
1189
  private dialRemoteStanding;
1190
+ private readonly seatCustody;
1191
+ private readonly sessionRecovery;
1072
1192
  constructor(opts: ManagerOptions);
1073
1193
  get runtimeKind(): string;
1074
1194
  /** Whether this manager's runtime opens a terminal stream on the seats it spawns, so a caller
@@ -1288,8 +1408,6 @@ export declare class Manager {
1288
1408
  * preserveState and stop close it before their first await, so work is either counted or rejected. */
1289
1409
  private beginLifecycle;
1290
1410
  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
1411
  private trackDeprovision;
1294
1412
  private awaitLifecycleDrain;
1295
1413
  private maintenanceError;
@@ -1683,46 +1801,12 @@ export declare class Manager {
1683
1801
  /** A live agent's teardown target, built field by field so the rest of its record (handle, seed,
1684
1802
  * restart state) never rides into the detached teardown or its single-flight map. */
1685
1803
  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
1804
  private deprovision;
1699
1805
  /** Run one retirement in a {@link RETIREMENT_CONCURRENCY} slot, oldest first: a seat's deprovision, a
1700
1806
  * chat session's terminal and a static reconcile's terminal all take one. No retirement awaits
1701
1807
  * another, so the bounded pool cannot deadlock. */
1702
1808
  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
1809
  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
1810
  private deprovisionBroker;
1727
1811
  /** Narrow the retiring lifecycle's read-ACL row to no reads ({@link fenceLifecycleAcl}) through a
1728
1812
  * `deprovisioner` credential pinned to it. Returns undefined once fenced, or the reason it was not. */
@@ -1735,48 +1819,20 @@ export declare class Manager {
1735
1819
  * never omit a child that may still be alive. Recursive descendants are scheduled before their parent
1736
1820
  * slot can disappear. */
1737
1821
  private reapChildrenOf;
1738
- private readSessionStatePath;
1739
1822
  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
1823
  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
1824
  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
1825
  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
1826
  private refuseLateCarriedFork;
1757
1827
  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
1828
  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
1829
  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
1830
  private armSessionRecovery;
1770
- private awaitRecoveredSession;
1771
1831
  /** Why an inline seat's snapshot no longer matches its launch, or `undefined` when it does or the
1772
1832
  * seat is not inline. The recorded path and the relaunch's path must both be this lifecycle's
1773
1833
  * snapshot path, as the resume cut requires, and the file there must still be a private regular
1774
1834
  * file with the recorded digest. */
1775
1835
  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
1836
  private recoverManagedSession;
1781
1837
  /** A managed agent's process exited: on its own (crash, /exit, finished), or after a stop this
1782
1838
  * manager started, whose recorded cause then frees the slot. Continuation-capable Pi seats
@@ -2160,45 +2216,7 @@ export declare class Manager {
2160
2216
  * is a no-op (the successor's own freeze comes next). A committed spec under that freeze is
2161
2217
  * finished at the committed registrationRevision; only a definite no-commit abort-reopens. */
2162
2218
  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
2219
  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
2220
  private registerManagerService;
2203
2221
  /** Mint the standing `goal-writer` credential and STAGE it into this
2204
2222
  * instance's §13.1 revocation family (`epcred.<e>.<iid>`), over the passed executor's `authKv`
@@ -2236,67 +2254,8 @@ export declare class Manager {
2236
2254
  private startGoalWriter;
2237
2255
  /** Retire the goal-writer connection (best-effort, both exit paths). */
2238
2256
  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
2257
  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
2258
  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
2259
  private stopSessionPlane;
2301
2260
  /** The boot reconcile: a fresh incarnation (a manager restart takes a NEW
2302
2261
  * instanceId, so the in-memory acceptance map starts empty) inherits the endpoint's accepted-but-
@@ -2534,62 +2493,22 @@ export declare class Manager {
2534
2493
  * despawn (the process teardown is authoritative for the agent; this settles the GOAL honestly).
2535
2494
  * Cancel rides the despawn's own authorizeNamed reach - there is no cancel-by-goalId. */
2536
2495
  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
2496
  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
2497
  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
2498
  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
2499
  private spawnCustodied;
2556
2500
  /** Keep launch provenance independent of status and runtime wire contracts. */
2557
2501
  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
2502
  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
2503
  private refreshSeatRecord;
2569
2504
  private dropSeatRecord;
2570
2505
  /** True when a default stop wrote a runtime reference for this exact lifecycle and it is still
2571
2506
  * there. That file is what a later manager adopts, so a slot free must not remove it before the
2572
2507
  * retirement that confirms the lifecycle is gone. */
2573
2508
  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
2509
  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
2510
  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
2511
  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
2512
  private reapOrphanSeat;
2594
2513
  /** The static terminal for one departed incarnation: delegates the gate/head CAS
2595
2514
  * sequence to the shared core saga over the executor transport; the footprint teardown (creds