@cotal-ai/manager 0.174.3 → 0.175.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.
- package/dist/boot.d.ts +3 -19
- package/dist/boot.d.ts.map +1 -1
- package/dist/boot.js +51 -67
- package/dist/boot.js.map +1 -1
- package/dist/broker-transport.d.ts +6 -12
- package/dist/broker-transport.d.ts.map +1 -1
- package/dist/broker-transport.js +21 -27
- package/dist/broker-transport.js.map +1 -1
- package/dist/command-dispatch.d.ts +6 -7
- package/dist/command-dispatch.d.ts.map +1 -1
- package/dist/command-dispatch.js +19 -13
- package/dist/command-dispatch.js.map +1 -1
- package/dist/console/session-bundle.js +2 -0
- package/dist/credential-renewal.d.ts +38 -63
- package/dist/credential-renewal.d.ts.map +1 -1
- package/dist/credential-renewal.js +42 -73
- package/dist/credential-renewal.js.map +1 -1
- package/dist/goal-writer.d.ts +3 -5
- package/dist/goal-writer.d.ts.map +1 -1
- package/dist/goal-writer.js +10 -12
- package/dist/goal-writer.js.map +1 -1
- package/dist/harness-resolution.d.ts +3 -13
- package/dist/harness-resolution.d.ts.map +1 -1
- package/dist/harness-resolution.js +14 -24
- package/dist/harness-resolution.js.map +1 -1
- package/dist/lease-keeper.d.ts +3 -3
- package/dist/lease-keeper.d.ts.map +1 -1
- package/dist/lease-keeper.js +8 -8
- package/dist/lease-keeper.js.map +1 -1
- package/dist/managed-static-lifecycle.d.ts +4 -9
- package/dist/managed-static-lifecycle.d.ts.map +1 -1
- package/dist/managed-static-lifecycle.js +25 -30
- package/dist/managed-static-lifecycle.js.map +1 -1
- package/dist/manager-config.d.ts +55 -0
- package/dist/manager-config.d.ts.map +1 -0
- package/dist/manager-config.js +2 -0
- package/dist/manager-config.js.map +1 -0
- package/dist/manager-parts.d.ts +2 -0
- package/dist/manager-parts.d.ts.map +1 -1
- package/dist/manager-service-contract.d.ts +5 -1
- package/dist/manager-service-contract.d.ts.map +1 -1
- package/dist/manager-service-contract.js +13 -2
- package/dist/manager-service-contract.js.map +1 -1
- package/dist/manager.d.ts +8 -81
- package/dist/manager.d.ts.map +1 -1
- package/dist/manager.js +104 -158
- package/dist/manager.js.map +1 -1
- package/dist/names-capacity.d.ts +3 -3
- package/dist/names-capacity.d.ts.map +1 -1
- package/dist/names-capacity.js +4 -3
- package/dist/names-capacity.js.map +1 -1
- package/dist/persona-catalog.d.ts +3 -7
- package/dist/persona-catalog.d.ts.map +1 -1
- package/dist/persona-catalog.js +10 -14
- package/dist/persona-catalog.js.map +1 -1
- package/dist/preservation.d.ts +3 -9
- package/dist/preservation.d.ts.map +1 -1
- package/dist/preservation.js +16 -22
- package/dist/preservation.js.map +1 -1
- package/dist/preserved-resume.d.ts +3 -15
- package/dist/preserved-resume.d.ts.map +1 -1
- package/dist/preserved-resume.js +48 -60
- package/dist/preserved-resume.js.map +1 -1
- package/dist/readiness-wait.d.ts +3 -3
- package/dist/readiness-wait.d.ts.map +1 -1
- package/dist/readiness-wait.js +6 -6
- package/dist/readiness-wait.js.map +1 -1
- package/dist/retirement.d.ts +4 -12
- package/dist/retirement.d.ts.map +1 -1
- package/dist/retirement.js +14 -22
- package/dist/retirement.js.map +1 -1
- package/dist/seat-custody.d.ts +4 -6
- package/dist/seat-custody.d.ts.map +1 -1
- package/dist/seat-custody.js +11 -13
- package/dist/seat-custody.js.map +1 -1
- package/dist/seat-launch.d.ts +3 -11
- package/dist/seat-launch.d.ts.map +1 -1
- package/dist/seat-launch.js +16 -26
- package/dist/seat-launch.js.map +1 -1
- package/dist/seat-start.d.ts +3 -8
- package/dist/seat-start.d.ts.map +1 -1
- package/dist/seat-start.js +27 -32
- package/dist/seat-start.js.map +1 -1
- package/dist/seat-stop.d.ts +3 -9
- package/dist/seat-stop.d.ts.map +1 -1
- package/dist/seat-stop.js +9 -15
- package/dist/seat-stop.js.map +1 -1
- package/dist/serve-plane.d.ts +3 -11
- package/dist/serve-plane.d.ts.map +1 -1
- package/dist/serve-plane.js +22 -30
- package/dist/serve-plane.js.map +1 -1
- package/dist/session-recovery.d.ts +3 -4
- package/dist/session-recovery.d.ts.map +1 -1
- package/dist/session-recovery.js +7 -8
- package/dist/session-recovery.js.map +1 -1
- package/dist/spawn-goal.d.ts +4 -8
- package/dist/spawn-goal.d.ts.map +1 -1
- package/dist/spawn-goal.js +7 -11
- package/dist/spawn-goal.js.map +1 -1
- package/dist/start-doors.d.ts +3 -9
- package/dist/start-doors.d.ts.map +1 -1
- package/dist/start-doors.js +10 -16
- package/dist/start-doors.js.map +1 -1
- package/dist/status-and-models.d.ts +3 -11
- package/dist/status-and-models.d.ts.map +1 -1
- package/dist/status-and-models.js +13 -21
- package/dist/status-and-models.js.map +1 -1
- package/dist/terminal-input.d.ts +16 -5
- package/dist/terminal-input.d.ts.map +1 -1
- package/dist/terminal-input.js +35 -8
- package/dist/terminal-input.js.map +1 -1
- package/dist/user-provision.d.ts +4 -8
- package/dist/user-provision.d.ts.map +1 -1
- package/dist/user-provision.js +29 -33
- package/dist/user-provision.js.map +1 -1
- package/package.json +12 -12
package/dist/manager.js
CHANGED
|
@@ -63,7 +63,7 @@ const ONCE_RETIRE_MS = 60_000;
|
|
|
63
63
|
* liveness-inferring timer. This is only the last-resort bound for "neither happened in time": the launch
|
|
64
64
|
* is then reported UNCERTAIN (a non-success reply that does NOT deprovision — it may still be booting, or
|
|
65
65
|
* stuck before connector startup). Generous, since a real cold agent join can take several seconds. Held
|
|
66
|
-
*
|
|
66
|
+
* on the Manager's config ({@link ManagerConfig.readinessTimeoutMs}) so a test can shorten it. Exported so the
|
|
67
67
|
* launch-parity smoke can assert every launch client's request timeout OUTLIVES this window — the tier
|
|
68
68
|
* rule forbids the clients importing it directly. */
|
|
69
69
|
export const READINESS_TIMEOUT_MS = 30_000;
|
|
@@ -109,6 +109,12 @@ async function awaitStartupOutcome(a, launchedAt, readinessTimeoutMs, stopping)
|
|
|
109
109
|
await new Promise((resolve) => setTimeout(resolve, 250));
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
+
/** The seed, typed as the whole config. The parts are built from field initializers that run before
|
|
113
|
+
* the constructor body, so they receive the object while it holds only the seed; the constructor
|
|
114
|
+
* assigns every other member before it returns, and no part reads one during construction. */
|
|
115
|
+
function seededConfig(seed) {
|
|
116
|
+
return seed;
|
|
117
|
+
}
|
|
112
118
|
/**
|
|
113
119
|
* The agent supervisor: a long-lived mesh node that owns agent process lifecycle.
|
|
114
120
|
* It serves control requests on the "manager" service and spawns/kills agents
|
|
@@ -118,53 +124,32 @@ async function awaitStartupOutcome(a, launchedAt, readinessTimeoutMs, stopping)
|
|
|
118
124
|
export class Manager {
|
|
119
125
|
/** The parts, filled at the end of the constructor once every part exists. Parts read a peer from it at use. */
|
|
120
126
|
parts = {};
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
maxSessions;
|
|
132
|
-
/** The operator-set per-owner seat ceiling (see {@link ManagerOptions.seatCap}). */
|
|
133
|
-
seatCap;
|
|
134
|
-
/** The ONE secret store for every kind this manager touches (daemon-cred remint + agent kinds).
|
|
135
|
-
* See {@link ManagerOptions.secretStore}. */
|
|
136
|
-
secrets;
|
|
137
|
-
/** Named identity of {@link secrets}: the same coordinate the delivery daemon must reload from.
|
|
138
|
-
* Set at construction for an injected store; the workspace store is named on first challenge. */
|
|
139
|
-
secretStoreIdentity;
|
|
127
|
+
/** The Manager's identity, operator settings and timing (see {@link ManagerConfig}). Declared ahead of
|
|
128
|
+
* the parts so each part built below receives this object; the constructor fills the rest in. */
|
|
129
|
+
config = seededConfig({
|
|
130
|
+
managerLifecycleUid: mintLifecycleUid(),
|
|
131
|
+
startedAtMs: Date.now(),
|
|
132
|
+
shutdownReadiness: new AbortController(),
|
|
133
|
+
readinessTimeoutMs: READINESS_TIMEOUT_MS,
|
|
134
|
+
staticReconcileRetryDelaysMs: STATIC_RECONCILE_RETRY_DELAYS_MS,
|
|
135
|
+
goalAcceptanceRetentionMs: TURN_ANSWER_RETENTION_MS,
|
|
136
|
+
});
|
|
140
137
|
/** See {@link ManagerOptions.installedExtensions}. */
|
|
141
138
|
installedExtensions;
|
|
142
|
-
expectedConnectorGeneration;
|
|
143
|
-
machineSetupCommand;
|
|
144
|
-
executionState;
|
|
145
139
|
/** One backend per kind a seat has asked for, beside {@link runtime}. The manager's own runtime
|
|
146
140
|
* stays the default and is never replaced by a later seat's choice. */
|
|
147
141
|
runtimes = new Map();
|
|
148
|
-
/** Hosted pooled control, recorded so a later seat cannot add a custodial runtime the constructor
|
|
149
|
-
* already refused for the manager's own. */
|
|
150
|
-
pooled;
|
|
151
142
|
/** Internal test seam. Production leaves this undefined and uses the scoped delivery-admin evictor. */
|
|
152
143
|
staticLifecycleEvict;
|
|
153
|
-
preserveStopTimeoutMs;
|
|
154
|
-
endpointServeExecutorExpiresInSeconds;
|
|
155
144
|
agents = new Map();
|
|
156
145
|
/** Lifecycle UIDs already handed to `Runtime.spawnDelegated`: a lifecycle is handed off at most
|
|
157
146
|
* once, so a lost create acknowledgement can never become a second create. */
|
|
158
147
|
delegatedLaunched = new Set();
|
|
159
|
-
/** This manager process's own incarnation uid (SPEC 13.1; minted once per supervisor process,
|
|
160
|
-
* never reused across restarts) — the endpoint's presence key AND the `managerInstance` audit
|
|
161
|
-
* coordinate every static activation records. */
|
|
162
|
-
managerLifecycleUid = mintLifecycleUid();
|
|
163
148
|
/** The persisted LOGICAL instance id (SPEC 13.6 item 7): STABLE across restart, so a
|
|
164
149
|
* restart re-registers the SAME id with an ADVANCED epoch through the §13.1 gate (the successor
|
|
165
150
|
* fences the predecessor's epoch — the (i) fence bites on a real restart). It is the registration
|
|
166
151
|
* instanceId, the served-status id, the goal spec's executor.instanceId, the epe route, and the
|
|
167
|
-
* resolveExecutorEpoch key — DISTINCT from {@link managerLifecycleUid} (per-process: the presence
|
|
152
|
+
* resolveExecutorEpoch key — DISTINCT from {@link ManagerConfig.managerLifecycleUid} (per-process: the presence
|
|
168
153
|
* node uid + the managerInstance audit coordinate every static activation records). Set in start(). */
|
|
169
154
|
managerInstanceId;
|
|
170
155
|
/** The persisted serve nkey identity: reusing the SAME principal across restart keeps
|
|
@@ -174,7 +159,6 @@ export class Manager {
|
|
|
174
159
|
/** The local instance identity {@link admitExecutionState} already resolved. The ordinary start
|
|
175
160
|
* adopts it instead of reading the same record again. */
|
|
176
161
|
admittedLocalIdentity;
|
|
177
|
-
onServiceIdentity;
|
|
178
162
|
/** The manager's v0.4 service-endpoint serve state — the serve handle +
|
|
179
163
|
* its dedicated connection, the STABLE serve identity (renewals re-mint the same nkey), the
|
|
180
164
|
* branded serve grant, and the CURRENT credential (the connection's authenticator reads it on
|
|
@@ -227,13 +211,10 @@ export class Manager {
|
|
|
227
211
|
/** The acceptance replied for each goal this incarnation accepted, by {@link goalKey}, so an
|
|
228
212
|
* idempotent same-goalId retry serves the IDENTICAL acceptance (same allocated name/triple)
|
|
229
213
|
* without a second spawn. An entry lives while its goal is in flight and for
|
|
230
|
-
* {@link goalAcceptanceRetentionMs} after its terminal commits; a later retry, or one at another
|
|
214
|
+
* {@link ManagerConfig.goalAcceptanceRetentionMs} after its terminal commits; a later retry, or one at another
|
|
231
215
|
* incarnation, is answered from the goal index while the goal runs and from its committed
|
|
232
216
|
* result fact once it has ended. */
|
|
233
217
|
goalAcceptances = new Map();
|
|
234
|
-
/** How long a terminal goal's acceptance stays in {@link goalAcceptances}: the retry window its
|
|
235
|
-
* turn twin keeps a settled answer for. An instance field so a test can shorten it. */
|
|
236
|
-
goalAcceptanceRetentionMs = TURN_ANSWER_RETENTION_MS;
|
|
237
218
|
/** The boot reconcile of the durable goal index runs ONCE at start (a
|
|
238
219
|
* fresh incarnation inherits the endpoint's accepted-but-unterminal goals from any predecessor).
|
|
239
220
|
* Spawn-as-action REFUSES to accept until it completes, so the sweep never races a live goal's
|
|
@@ -247,12 +228,12 @@ export class Manager {
|
|
|
247
228
|
return this.turnRelayInstance ??= new TurnRelay({
|
|
248
229
|
goalWriter: () => this.goalWriter,
|
|
249
230
|
serviceServe: () => this.serviceServe,
|
|
250
|
-
space: this.space,
|
|
231
|
+
space: this.config.space,
|
|
251
232
|
managerInstanceId: () => this.managerInstanceId,
|
|
252
233
|
execution: this.execution,
|
|
253
234
|
executionRefusal: this.executionRefusal(),
|
|
254
235
|
goalReconcileDone: () => this.goalReconcileDone,
|
|
255
|
-
readinessTimeoutMs: () => this.readinessTimeoutMs,
|
|
236
|
+
readinessTimeoutMs: () => this.config.readinessTimeoutMs,
|
|
256
237
|
adoptsSeats: () => this.auth !== undefined && !this.userMode,
|
|
257
238
|
onceSeatReconciling: (uid) => this.staticLifecycle.pendingLifecycle(uid),
|
|
258
239
|
assertGoalWriterEpochCurrent: (epoch) => this.assertGoalWriterEpochCurrent(epoch),
|
|
@@ -270,8 +251,6 @@ export class Manager {
|
|
|
270
251
|
participants = new Map();
|
|
271
252
|
/** Once tasks whose seat's exit is watched: that exit, not the spawn's outcome, settles the debt. */
|
|
272
253
|
onceWatched = new Set();
|
|
273
|
-
/** Process start, for the served `status` uptime. */
|
|
274
|
-
startedAtMs = Date.now();
|
|
275
254
|
/** The complete boot task. stop() joins it after fencing static reconciliation, so a registration
|
|
276
255
|
* already past an earlier shutdown check cannot finish after stop() returns. */
|
|
277
256
|
startTask;
|
|
@@ -281,9 +260,6 @@ export class Manager {
|
|
|
281
260
|
* of `agents` before they have exited, so a second teardown would find none and report success
|
|
282
261
|
* while the first still waits on a live seat. */
|
|
283
262
|
stopTask;
|
|
284
|
-
/** Held as an instance field so broker-owning smokes can compress the schedule without changing
|
|
285
|
-
* production semantics. It is never a fence expiry: the durable non-retired row stays authoritative. */
|
|
286
|
-
staticReconcileRetryDelaysMs = STATIC_RECONCILE_RETRY_DELAYS_MS;
|
|
287
263
|
/** Retirements holding one of the {@link RETIREMENT_CONCURRENCY} slots. */
|
|
288
264
|
retirementsRunning = 0;
|
|
289
265
|
/** Retirements waiting for a slot, oldest first. */
|
|
@@ -293,15 +269,11 @@ export class Manager {
|
|
|
293
269
|
/** Space trust material when the mesh runs in auth mode (`.cotal/auth` present);
|
|
294
270
|
* the manager mints per-agent creds from it at spawn. Undefined when the mesh is open. */
|
|
295
271
|
auth;
|
|
296
|
-
/** Readiness-race backstop (#159 B1) — the {@link READINESS_TIMEOUT_MS} constant, held as an instance
|
|
297
|
-
* field so a test can shorten it (the join/exit signals are event-driven; only the backstop is timed).
|
|
298
|
-
* Production leaves it at the constant. */
|
|
299
|
-
readinessTimeoutMs = READINESS_TIMEOUT_MS;
|
|
300
272
|
/** True on a USER-AUTH space (the on-disk marker; cross-checked against the registry at start).
|
|
301
273
|
* Gates the whole spawn path: user mode grants ledger actors + bearer plumbing, never static mints. */
|
|
302
274
|
userMode = false;
|
|
303
|
-
namesCapacity = new NamesCapacity(namesCapacityDeps(this));
|
|
304
|
-
servePlane = new ServePlane(servePlaneDeps(this), this.parts);
|
|
275
|
+
namesCapacity = new NamesCapacity(this.config, namesCapacityDeps(this));
|
|
276
|
+
servePlane = new ServePlane(this.config, servePlaneDeps(this), this.parts);
|
|
305
277
|
resolveServeTarget(t) {
|
|
306
278
|
if (this.remoteAuthority) {
|
|
307
279
|
const key = principalKey(t.owner, t.actor).key;
|
|
@@ -323,29 +295,15 @@ export class Manager {
|
|
|
323
295
|
return { lifecycleUid: a.lifecycleUid, mappingRevision: 0 };
|
|
324
296
|
return undefined;
|
|
325
297
|
}
|
|
326
|
-
retirement = new Retirement(retirementDeps(this));
|
|
327
|
-
lease = new LeaseKeeper(leaseKeeperDeps(this));
|
|
298
|
+
retirement = new Retirement(this.config, retirementDeps(this));
|
|
299
|
+
lease = new LeaseKeeper(this.config, leaseKeeperDeps(this));
|
|
328
300
|
/** Set at the top of `stop()`. `renewLease` returns at once once this is set, and its `gone` arm
|
|
329
301
|
* does not re-acquire: a manager that is stopping never puts its own key back. It also closes the
|
|
330
302
|
* lifecycle fence ({@link beginLifecycle}), so no spawn can launch a seat the stop never sees. */
|
|
331
303
|
leaseStopping = false;
|
|
332
|
-
shutdownReadiness = new AbortController();
|
|
333
304
|
/** The class-2 renewal owner's half-TTL schedule; armed only on auth meshes. */
|
|
334
305
|
credRenewTimer;
|
|
335
306
|
resumeCredRenewal;
|
|
336
|
-
/** #2073: the `endpoint-serve` credential's OWN renewal, armed from its `[renewAt, exp)` window
|
|
337
|
-
* (`credsRenewalDelayMs`) rather than left to `credRenewTimer`'s boot-phased TTL/4 tick, which can
|
|
338
|
-
* miss the window by ordering. Re-armed at registration and after every successful re-mint;
|
|
339
|
-
* cleared in `stop()` beside `credRenewTimer`. */
|
|
340
|
-
endpointServeRenewalTimer;
|
|
341
|
-
/** #1634: does THIS manager own the delivery daemon's credential renewal? True only while the
|
|
342
|
-
* daemon reloads from this manager's store AND this manager holds the per-space renewal lease.
|
|
343
|
-
* Starts false: a manager that has not proved both must not remint. */
|
|
344
|
-
daemonRenewalOwner = false;
|
|
345
|
-
/** #2561: may the lease heartbeat contend at all? Set by every claim, false while the daemon names
|
|
346
|
-
* another store or the challenge refused. Without it the heartbeat re-takes the lease the claim
|
|
347
|
-
* just released and holds it against every manager and `doctor auth --fix` that can remint. */
|
|
348
|
-
daemonRenewalEligible = false;
|
|
349
307
|
daemonRenewalLeaseTimer;
|
|
350
308
|
maintenanceState = "active";
|
|
351
309
|
lifecycleInFlight = 0;
|
|
@@ -354,64 +312,56 @@ export class Manager {
|
|
|
354
312
|
preservationAttemptId;
|
|
355
313
|
unverifiedStops = [];
|
|
356
314
|
preservationInventory;
|
|
357
|
-
resumeAttemptId;
|
|
358
315
|
resumeRequired = false;
|
|
359
316
|
resumeDurableCommitToken;
|
|
360
317
|
remoteAuthority;
|
|
361
|
-
remoteExecutorCreds;
|
|
362
|
-
remoteSupervisorCreds;
|
|
363
|
-
remoteBundleRenewal;
|
|
364
|
-
remoteBundleAdoption;
|
|
365
|
-
finishRemoteBundleAdoption;
|
|
366
|
-
/** A refused or failed standing candidate is cleanup debt, never a silent loss: the last-good
|
|
367
|
-
* family stays live and this records what the host may have signed but the manager never adopted. */
|
|
368
|
-
remoteRenewalDebt;
|
|
369
318
|
/** {@link BrokerTransport.dial}. */
|
|
370
319
|
dial(...args) { return this.brokerTransportComponent.dial(...args); }
|
|
371
320
|
/** {@link BrokerTransport.dialRemoteStanding}. */
|
|
372
321
|
dialRemoteStanding(...args) { return this.brokerTransportComponent.dialRemoteStanding(...args); }
|
|
373
|
-
seatCustody = new SeatCustody(seatCustodyDeps(this));
|
|
374
|
-
sessionRecovery = new SessionRecovery(sessionRecoveryDeps(this));
|
|
322
|
+
seatCustody = new SeatCustody(this.config, seatCustodyDeps(this));
|
|
323
|
+
sessionRecovery = new SessionRecovery(this.config, sessionRecoveryDeps(this));
|
|
375
324
|
get staticReconcileLastSweepResources() { return this.staticLifecycle.resources(); }
|
|
376
325
|
set staticReconcileLastSweepResources(value) { this.staticLifecycle.setResources(value); }
|
|
377
|
-
staticLifecycle = new ManagedStaticLifecycle(managedStaticLifecycleDeps(this));
|
|
326
|
+
staticLifecycle = new ManagedStaticLifecycle(this.config, managedStaticLifecycleDeps(this));
|
|
378
327
|
/** User-mode provisioning owns no manager state: each dependency reads through at its use. */
|
|
379
|
-
userProvision = new UserProvision(userProvisionDeps(this));
|
|
328
|
+
userProvision = new UserProvision(this.config, userProvisionDeps(this));
|
|
380
329
|
/** Seat stop, exit, recursive reap and named despawn. Every dependency reads through at its use. */
|
|
381
|
-
seatStopComponent = new SeatStop(seatStopDeps(this));
|
|
330
|
+
seatStopComponent = new SeatStop(this.config, seatStopDeps(this));
|
|
382
331
|
/** The typed command table and its admission. Every dependency reads through at its use. */
|
|
383
|
-
commandDispatch = new CommandDispatch(commandDispatchDeps(this));
|
|
332
|
+
commandDispatch = new CommandDispatch(this.config, commandDispatchDeps(this));
|
|
384
333
|
/** The spawn and launch goal path. Every dependency reads through at its use. */
|
|
385
|
-
spawnGoalComponent = new SpawnGoal(spawnGoalDeps(this));
|
|
334
|
+
spawnGoalComponent = new SpawnGoal(this.config, spawnGoalDeps(this));
|
|
386
335
|
/** The persona catalog doors. Every dependency reads through at its use. */
|
|
387
|
-
personaCatalogComponent = new PersonaCatalog(personaCatalogDeps(this));
|
|
336
|
+
personaCatalogComponent = new PersonaCatalog(this.config, personaCatalogDeps(this));
|
|
388
337
|
/** Seat terminal input and attach sessions. Every dependency reads through at its use. */
|
|
389
|
-
terminalInputComponent = new TerminalInput(terminalInputDeps(this));
|
|
338
|
+
terminalInputComponent = new TerminalInput(this.config, terminalInputDeps(this));
|
|
390
339
|
/** Status, seat list and model catalog reads. Every dependency reads through at its use. */
|
|
391
|
-
statusAndModelsComponent = new StatusAndModels(statusAndModelsDeps(this), this.parts);
|
|
340
|
+
statusAndModelsComponent = new StatusAndModels(this.config, statusAndModelsDeps(this), this.parts);
|
|
392
341
|
/** The launch readiness race and exit watch. Every dependency reads through at its use. */
|
|
393
|
-
readinessWaitComponent = new ReadinessWait(readinessWaitDeps(this));
|
|
342
|
+
readinessWaitComponent = new ReadinessWait(this.config, readinessWaitDeps(this));
|
|
394
343
|
/** Broker dials and scoped executor connections. Every dependency reads through at its use. */
|
|
395
|
-
brokerTransportComponent = new BrokerTransport(brokerTransportDeps(this));
|
|
344
|
+
brokerTransportComponent = new BrokerTransport(this.config, brokerTransportDeps(this), this.parts);
|
|
396
345
|
/** The start and launch control doors. Every dependency reads through at its use. */
|
|
397
|
-
startDoorsComponent = new StartDoors(startDoorsDeps(this));
|
|
346
|
+
startDoorsComponent = new StartDoors(this.config, startDoorsDeps(this));
|
|
398
347
|
/** Connector and harness resolution for a launch. Every dependency reads through at its use. */
|
|
399
|
-
harnessResolutionComponent = new HarnessResolution(harnessResolutionDeps(this), this.parts);
|
|
348
|
+
harnessResolutionComponent = new HarnessResolution(this.config, harnessResolutionDeps(this), this.parts);
|
|
400
349
|
/** The connector inventory. It owns the connector rows and the boot notes. */
|
|
401
350
|
connectorInventory;
|
|
402
351
|
/** Manager preservation and released-seat adoption. Every dependency reads through at its use. */
|
|
403
|
-
preservationComponent = new Preservation(preservationDeps(this));
|
|
352
|
+
preservationComponent = new Preservation(this.config, preservationDeps(this));
|
|
404
353
|
/** Preserved-manager resume and its control doors. Every dependency reads through at its use. */
|
|
405
|
-
preservedResumeComponent = new PreservedResume(preservedResumeDeps(this), this.parts);
|
|
354
|
+
preservedResumeComponent = new PreservedResume(this.config, preservedResumeDeps(this), this.parts);
|
|
406
355
|
/** The goal-writer connection and the goal index it reconciles. Every dependency reads through at its use. */
|
|
407
|
-
goalWriterComponent = new GoalWriter(goalWriterDeps(this));
|
|
356
|
+
goalWriterComponent = new GoalWriter(this.config, goalWriterDeps(this));
|
|
408
357
|
/** Renewal of the manager's standing credentials. Every dependency reads through at its use. */
|
|
409
|
-
credentialRenewal = new CredentialRenewal(credentialRenewalDeps(this));
|
|
358
|
+
credentialRenewal = new CredentialRenewal(this.config, credentialRenewalDeps(this));
|
|
410
359
|
/** The launch pipeline's leaf steps. Every dependency reads through at its use. */
|
|
411
|
-
seatLaunch = new SeatLaunch(seatLaunchDeps(this), this.parts);
|
|
360
|
+
seatLaunch = new SeatLaunch(this.config, seatLaunchDeps(this), this.parts);
|
|
412
361
|
/** Manager boot: execution admission, connect, registration and lease. Every dependency reads through at its use. */
|
|
413
|
-
bootComponent = new ManagerBoot(bootDeps(this), this.parts);
|
|
362
|
+
bootComponent = new ManagerBoot(this.config, bootDeps(this), this.parts);
|
|
414
363
|
constructor(opts) {
|
|
364
|
+
const config = this.config;
|
|
415
365
|
if (opts.expectedConnectorGeneration !== undefined && opts.expectedConnectorGeneration !== MANAGER_VERSION)
|
|
416
366
|
throw new Error(`expected connector generation ${opts.expectedConnectorGeneration} differs from this Manager's loaded generation ${MANAGER_VERSION}; restart from the installed CLI`);
|
|
417
367
|
if (opts.onServiceIdentity !== undefined && typeof opts.onServiceIdentity !== "function")
|
|
@@ -429,61 +379,61 @@ export class Manager {
|
|
|
429
379
|
throw new Error("pooled control requires signerless remote authority and an explicit non-PTY runtime; local custodial execution is forbidden");
|
|
430
380
|
if (opts.pooled && !opts.remoteAuthority?.renewStandingBundle)
|
|
431
381
|
throw new Error("pooled control requires a closed host-issued all-duty renewal callback before construction");
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
382
|
+
config.space = opts.space;
|
|
383
|
+
config.servers = opts.servers;
|
|
384
|
+
config.name = opts.name ?? "manager";
|
|
385
|
+
config.workspaceRoot = opts.workspaceRoot ?? findCotalRoot();
|
|
386
|
+
config.onServiceIdentity = opts.onServiceIdentity;
|
|
387
|
+
config.eventsRequired = opts.eventsRequired === true;
|
|
388
|
+
config.eventPayloadsWithheld = opts.eventPayloadsWithheld === true;
|
|
389
|
+
config.maxSessions = opts.maxSessions;
|
|
390
|
+
config.seatCap = opts.seatCap ?? DEFAULT_SEAT_CAP;
|
|
441
391
|
this.remoteAuthority = opts.remoteAuthority;
|
|
442
|
-
this.remoteExecutorCreds = opts.remoteAuthority?.executorCreds;
|
|
443
|
-
this.remoteSupervisorCreds = opts.remoteAuthority?.supervisorCreds;
|
|
392
|
+
this.credentialRenewal.remoteExecutorCreds = opts.remoteAuthority?.executorCreds;
|
|
393
|
+
this.credentialRenewal.remoteSupervisorCreds = opts.remoteAuthority?.supervisorCreds;
|
|
444
394
|
if (opts.pooled && (!opts.remoteAuthority?.accountPublicKey ||
|
|
445
395
|
accountFromCreds(opts.remoteAuthority.supervisorCreds) !== opts.remoteAuthority.accountPublicKey))
|
|
446
396
|
throw new Error("pooled control requires a proved assigned account for its initial supervisor credential");
|
|
447
397
|
if (opts.remoteAuthority)
|
|
448
|
-
|
|
449
|
-
|
|
398
|
+
config.managerLifecycleUid = opts.remoteAuthority.lifecycleUid;
|
|
399
|
+
config.secrets = opts.secretStore ?? workspaceSecretStore(this.config.workspaceRoot);
|
|
450
400
|
if (opts.secretStore)
|
|
451
|
-
this.secretStoreIdentity = injectedSecretStoreIdentity(opts.secretStore);
|
|
401
|
+
this.credentialRenewal.secretStoreIdentity = injectedSecretStoreIdentity(opts.secretStore);
|
|
452
402
|
this.installedExtensions = opts.installedExtensions ?? false;
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
403
|
+
config.expectedConnectorGeneration = MANAGER_VERSION;
|
|
404
|
+
config.machineSetupCommand = opts.machineSetupCommand;
|
|
405
|
+
config.pooled = opts.pooled === true;
|
|
406
|
+
config.execution = opts.execution === "none" ? "none" : "runtime";
|
|
457
407
|
if (!this.remoteAuthority) {
|
|
458
408
|
// A fresh root has no execution record, so construction does not read the identity. Records
|
|
459
409
|
// survive identity retirement; only the currently stored identity's record can be claimed.
|
|
460
|
-
const prefix = `manager-execution.${spaceKey(this.space)}.`;
|
|
461
|
-
const dir = join(this.workspaceRoot, ".cotal");
|
|
410
|
+
const prefix = `manager-execution.${spaceKey(this.config.space)}.`;
|
|
411
|
+
const dir = join(this.config.workspaceRoot, ".cotal");
|
|
462
412
|
const hasRecord = existsSync(dir) && readdirSync(dir).some((name) => name.startsWith(prefix) && name.endsWith(".json"));
|
|
463
413
|
if (hasRecord) {
|
|
464
|
-
const local = loadManagerInstanceIdentity(this.workspaceRoot, this.space);
|
|
414
|
+
const local = loadManagerInstanceIdentity(this.config.workspaceRoot, this.config.space);
|
|
465
415
|
if (local && existsSync(this.executionRecordPath(local.instanceId))) {
|
|
466
416
|
this.claimExecutionRecord(local.instanceId);
|
|
467
417
|
this.admittedLocalIdentity = local;
|
|
468
418
|
}
|
|
469
419
|
}
|
|
470
420
|
}
|
|
471
|
-
if (this.
|
|
472
|
-
this.runtime = createRuntime(opts.runtime ?? "auto", `cotal-${this.space}`);
|
|
473
|
-
if (opts.pooled && this.
|
|
421
|
+
if (this.config.execution === "runtime")
|
|
422
|
+
this.runtime = createRuntime(opts.runtime ?? "auto", `cotal-${this.config.space}`);
|
|
423
|
+
if (opts.pooled && this.config.execution === "runtime" && isCustodialRuntime(this.requiredRuntime))
|
|
474
424
|
throw new Error(`pooled control refuses custodial runtime "${this.requiredRuntime.kind}" before starting agents`);
|
|
475
|
-
|
|
476
|
-
|
|
425
|
+
config.preserveStopTimeoutMs = opts.preserveStopTimeoutMs ?? PRESERVE_STOP_TIMEOUT_MS;
|
|
426
|
+
config.endpointServeExecutorExpiresInSeconds = opts.endpointServeExecutorExpiresInSeconds;
|
|
477
427
|
if (opts.resumeAttemptId && !/^[A-Za-z0-9_-]{1,128}$/.test(opts.resumeAttemptId))
|
|
478
428
|
throw new Error("resumeAttemptId must be a safe token (letters, digits, _, -; max 128)");
|
|
479
429
|
if (opts.resumeDurableCommitToken && !/^[a-f0-9]{64}$/.test(opts.resumeDurableCommitToken))
|
|
480
430
|
throw new Error("resumeDurableCommitToken must be a lowercase 32-byte token");
|
|
481
431
|
if (opts.resumeDurableCommitToken && !opts.resumeAttemptId)
|
|
482
432
|
throw new Error("resumeDurableCommitToken requires resumeAttemptId");
|
|
483
|
-
|
|
433
|
+
config.resumeAttemptId = opts.resumeAttemptId;
|
|
484
434
|
this.resumeRequired = opts.resumeAttemptId !== undefined;
|
|
485
435
|
this.resumeDurableCommitToken = opts.resumeDurableCommitToken;
|
|
486
|
-
|
|
436
|
+
config.wsPort = opts.wsPort;
|
|
487
437
|
this.attach = new AttachEndpoint(() => this.list(),
|
|
488
438
|
// Initial /feed replay for a connecting console: the current peer roster.
|
|
489
439
|
() => [{ event: "roster", data: this.ep?.getRoster() ?? [] }], opts.consolePort ?? 0,
|
|
@@ -497,9 +447,10 @@ export class Manager {
|
|
|
497
447
|
// explicit decision; every other caller — an embedded Manager, a bare `cotal supervise` —
|
|
498
448
|
// keeps the loopback-only console it always had.
|
|
499
449
|
opts.attachHost ?? "127.0.0.1");
|
|
500
|
-
this.connectorInventory = new ConnectorInventory({ execution: this.execution, installedExtensions: this.installedExtensions, machineSetupCommand: this.machineSetupCommand, expectedConnectorGeneration: this.expectedConnectorGeneration }, this.parts, (resumeOperation) => this.beginLifecycle(resumeOperation));
|
|
450
|
+
this.connectorInventory = new ConnectorInventory({ execution: this.execution, installedExtensions: this.installedExtensions, machineSetupCommand: this.config.machineSetupCommand, expectedConnectorGeneration: this.config.expectedConnectorGeneration }, this.parts, (resumeOperation) => this.beginLifecycle(resumeOperation));
|
|
501
451
|
Object.assign(this.parts, {
|
|
502
452
|
connectorInventory: this.connectorInventory,
|
|
453
|
+
credentialRenewal: this.credentialRenewal,
|
|
503
454
|
harnessResolution: this.harnessResolutionComponent,
|
|
504
455
|
lease: this.lease,
|
|
505
456
|
seatLaunch: this.seatLaunch,
|
|
@@ -507,23 +458,23 @@ export class Manager {
|
|
|
507
458
|
});
|
|
508
459
|
}
|
|
509
460
|
get runtimeKind() {
|
|
510
|
-
return this.
|
|
461
|
+
return this.config.execution === "none" ? "none" : this.requiredRuntime.kind;
|
|
511
462
|
}
|
|
512
463
|
/** Whether this manager's runtime opens a terminal stream on the seats it spawns, so a caller
|
|
513
464
|
* knows before it asks whether `attach` can open one here. A control instance with no execution
|
|
514
465
|
* spawns no seat, so it streams no terminal either. */
|
|
515
466
|
get streamsTerminal() {
|
|
516
|
-
return this.
|
|
467
|
+
return this.config.execution !== "none" && this.requiredRuntime.streamsTerminal;
|
|
517
468
|
}
|
|
518
469
|
get execution() {
|
|
519
|
-
return this.
|
|
470
|
+
return this.config.execution;
|
|
520
471
|
}
|
|
521
472
|
executionRefusal() {
|
|
522
473
|
return EXECUTION_NONE_REFUSAL;
|
|
523
474
|
}
|
|
524
475
|
/** A defensive last barrier, not a substitute Runtime. Entry admission runs before effects. */
|
|
525
476
|
get requiredRuntime() {
|
|
526
|
-
if (this.
|
|
477
|
+
if (this.config.execution === "none")
|
|
527
478
|
throw new EpEnvelopeError("unimplemented", this.executionRefusal());
|
|
528
479
|
return this.runtime;
|
|
529
480
|
}
|
|
@@ -536,11 +487,11 @@ export class Manager {
|
|
|
536
487
|
* resolves only what its root imported. The refusal names an official runtime's package. */
|
|
537
488
|
async loadSeatRuntime(kind) {
|
|
538
489
|
const asked = kind?.trim();
|
|
539
|
-
if (!this.installedExtensions || this.
|
|
490
|
+
if (!this.installedExtensions || this.config.execution === "none" || !asked || asked === "auto" || asked === "pty" || asked === this.runtime.kind)
|
|
540
491
|
return;
|
|
541
492
|
if (!manifestExtensionNames("runtime").includes(asked))
|
|
542
493
|
throw new Error(runtimeInstallHint(asked));
|
|
543
|
-
await materializeFromManifest({ kind: "runtime", name: asked }, { hint: (ref) => runtimeInstallHint(ref.name), expectedGeneration: this.expectedConnectorGeneration });
|
|
494
|
+
await materializeFromManifest({ kind: "runtime", name: asked }, { hint: (ref) => runtimeInstallHint(ref.name), expectedGeneration: this.config.expectedConnectorGeneration });
|
|
544
495
|
}
|
|
545
496
|
/** The backend one seat launches, restarts, and is reaped through. An omitted or blank choice is
|
|
546
497
|
* this manager's own runtime. A named one is created once, cached by its resolved kind, and reused
|
|
@@ -548,7 +499,7 @@ export class Manager {
|
|
|
548
499
|
* unreachable runtime throws, and pooled control refuses a custodial one by the same rule the
|
|
549
500
|
* constructor applied to the manager's own. */
|
|
550
501
|
runtimeFor(kind) {
|
|
551
|
-
if (this.
|
|
502
|
+
if (this.config.execution === "none")
|
|
552
503
|
throw new EpEnvelopeError("unimplemented", this.executionRefusal());
|
|
553
504
|
const asked = kind?.trim();
|
|
554
505
|
if (!asked)
|
|
@@ -560,8 +511,8 @@ export class Manager {
|
|
|
560
511
|
const cached = this.runtimes.get(asked);
|
|
561
512
|
if (cached)
|
|
562
513
|
return cached;
|
|
563
|
-
const runtime = createRuntime(asked, `cotal-${this.space}`);
|
|
564
|
-
if (this.pooled && isCustodialRuntime(runtime))
|
|
514
|
+
const runtime = createRuntime(asked, `cotal-${this.config.space}`);
|
|
515
|
+
if (this.config.pooled && isCustodialRuntime(runtime))
|
|
565
516
|
throw new Error(`pooled control refuses custodial runtime "${runtime.kind}" before starting agents`);
|
|
566
517
|
this.runtimes.set(runtime.kind, runtime);
|
|
567
518
|
return runtime;
|
|
@@ -608,8 +559,8 @@ export class Manager {
|
|
|
608
559
|
if (!this.managerInstanceId || !this.managerServeIdentity)
|
|
609
560
|
throw new Error("manager native service identity has not been selected");
|
|
610
561
|
const principal = this.remoteAuthority
|
|
611
|
-
? { owner: this.remoteAuthority.owner, actor: this.remoteAuthority.actors.serve, uid: this.managerLifecycleUid }
|
|
612
|
-
: { owner: DEV_OWNER, actor: this.managerServeIdentity.id, uid: this.managerLifecycleUid };
|
|
562
|
+
? { owner: this.remoteAuthority.owner, actor: this.remoteAuthority.actors.serve, uid: this.config.managerLifecycleUid }
|
|
563
|
+
: { owner: DEV_OWNER, actor: this.managerServeIdentity.id, uid: this.config.managerLifecycleUid };
|
|
613
564
|
return Object.freeze({ endpoint: MANAGER_ENDPOINT, instanceId: this.managerInstanceId, principal: Object.freeze(principal) });
|
|
614
565
|
}
|
|
615
566
|
/** The console page URL (manager-hosted, loopback). */
|
|
@@ -692,7 +643,7 @@ export class Manager {
|
|
|
692
643
|
return wrapped;
|
|
693
644
|
}
|
|
694
645
|
executionRecordPath(instanceId) {
|
|
695
|
-
return join(this.workspaceRoot, ".cotal", `manager-execution.${spaceKey(this.space)}.${instanceId}.json`);
|
|
646
|
+
return join(this.config.workspaceRoot, ".cotal", `manager-execution.${spaceKey(this.config.space)}.${instanceId}.json`);
|
|
696
647
|
}
|
|
697
648
|
/** {@link ManagerBoot.claimExecutionRecord}. */
|
|
698
649
|
claimExecutionRecord(...args) { return this.bootComponent.claimExecutionRecord(...args); }
|
|
@@ -710,11 +661,6 @@ export class Manager {
|
|
|
710
661
|
claimDaemonRenewalOwnership(...args) { return this.credentialRenewal.claimDaemonRenewalOwnership(...args); }
|
|
711
662
|
/** {@link CredentialRenewal.scheduleServeRenewal}. */
|
|
712
663
|
scheduleServeRenewal(...args) { return this.credentialRenewal.scheduleServeRenewal(...args); }
|
|
713
|
-
credentialPushRetry;
|
|
714
|
-
credentialPushes = new Map();
|
|
715
|
-
supervisorCredentialPush;
|
|
716
|
-
pendingCredentialPushes = new Set();
|
|
717
|
-
supervisorCredentialPushPending = false;
|
|
718
664
|
/** {@link CredentialRenewal.boundedReconnect}. */
|
|
719
665
|
boundedReconnect(...args) { return this.credentialRenewal.boundedReconnect(...args); }
|
|
720
666
|
/** {@link CredentialRenewal.renewDaemonCreds}. */
|
|
@@ -758,7 +704,7 @@ export class Manager {
|
|
|
758
704
|
if (this.leaseStopping)
|
|
759
705
|
return "manager is stopping; new lifecycle/control work is fenced";
|
|
760
706
|
if (this.resumeRequired)
|
|
761
|
-
return `manager is waiting for resume attempt ${this.resumeAttemptId}; ordinary lifecycle/control work is fenced`;
|
|
707
|
+
return `manager is waiting for resume attempt ${this.config.resumeAttemptId}; ordinary lifecycle/control work is fenced`;
|
|
762
708
|
return `manager is in ${this.maintenanceState} mode; new lifecycle/control work is fenced`;
|
|
763
709
|
}
|
|
764
710
|
/** {@link Preservation.preparePreservation}. */
|
|
@@ -834,9 +780,9 @@ export class Manager {
|
|
|
834
780
|
}
|
|
835
781
|
async stopOnce(withAgents) {
|
|
836
782
|
this.leaseStopping = true;
|
|
837
|
-
this.shutdownReadiness.abort();
|
|
838
|
-
clearTimeout(this.credentialPushRetry);
|
|
839
|
-
this.credentialPushRetry = undefined;
|
|
783
|
+
this.config.shutdownReadiness.abort();
|
|
784
|
+
clearTimeout(this.credentialRenewal.credentialPushRetry);
|
|
785
|
+
this.credentialRenewal.credentialPushRetry = undefined;
|
|
840
786
|
this.transcripts?.stop();
|
|
841
787
|
this.staticLifecycle.stop();
|
|
842
788
|
const starting = this.startTask;
|
|
@@ -846,8 +792,8 @@ export class Manager {
|
|
|
846
792
|
clearInterval(this.lease.leaseTimer);
|
|
847
793
|
if (this.credRenewTimer)
|
|
848
794
|
clearInterval(this.credRenewTimer);
|
|
849
|
-
if (this.endpointServeRenewalTimer)
|
|
850
|
-
clearTimeout(this.endpointServeRenewalTimer);
|
|
795
|
+
if (this.credentialRenewal.endpointServeRenewalTimer)
|
|
796
|
+
clearTimeout(this.credentialRenewal.endpointServeRenewalTimer);
|
|
851
797
|
if (this.daemonRenewalLeaseTimer)
|
|
852
798
|
clearInterval(this.daemonRenewalLeaseTimer);
|
|
853
799
|
if (this.sessionKeyRenewTimer)
|
|
@@ -858,7 +804,7 @@ export class Manager {
|
|
|
858
804
|
await this.lease.leaseRenewTask?.catch(() => { });
|
|
859
805
|
// Join the bounded Manager renewal. Its stop/deadline fence refuses late adoption, but the
|
|
860
806
|
// host still owns any submitted issuance and its outcome can remain unknown after timeout.
|
|
861
|
-
await this.remoteBundleRenewal?.catch(() => { });
|
|
807
|
+
await this.credentialRenewal.remoteBundleRenewal?.catch(() => { });
|
|
862
808
|
// A spawn admitted before the fence closed may still be launching. Its seat must be in the
|
|
863
809
|
// snapshot below, or it would outlive a stop that reported success.
|
|
864
810
|
await this.awaitLifecycleDrain();
|
|
@@ -975,7 +921,7 @@ export class Manager {
|
|
|
975
921
|
}
|
|
976
922
|
catch (e) {
|
|
977
923
|
console.error(`! could not deregister manager instance ${iid}: ${rejectionText(e)}\n` +
|
|
978
|
-
` Its registration now outlives this process and will be frozen into every class scatter in space "${this.space}", each paying the full deadline.\n` +
|
|
924
|
+
` Its registration now outlives this process and will be frozen into every class scatter in space "${this.config.space}", each paying the full deadline.\n` +
|
|
979
925
|
` NEXT: once this process is gone, start this manager again and stop it cleanly; on a static space \`cotal endpoint deregister manager ${iid} --yes\` from the space's own root also removes it.`);
|
|
980
926
|
}
|
|
981
927
|
}
|
|
@@ -1064,7 +1010,7 @@ export class Manager {
|
|
|
1064
1010
|
if (this.remoteAuthority && !this.remoteAuthority.runHosting)
|
|
1065
1011
|
throw new EpEnvelopeError("unimplemented", "this manager does not host workflow runs: its issuing host supplied no closed run callbacks, and a remote-authority manager mints no run-driver credentials (SPEC 14.6); drive the run from a terminal with `cotal run start --local --file <program>`");
|
|
1066
1012
|
if (this.userMode && !this.remoteAuthority?.runHosting)
|
|
1067
|
-
throw new EpEnvelopeError("unimplemented", `user-auth space "${this.space}" hosts no workflow runs yet: a hosted run's seats would be spawned under the static owner, which a user mesh refuses; run programs on a static-auth mesh`);
|
|
1013
|
+
throw new EpEnvelopeError("unimplemented", `user-auth space "${this.config.space}" hosts no workflow runs yet: a hosted run's seats would be spawned under the static owner, which a user mesh refuses; run programs on a static-auth mesh`);
|
|
1068
1014
|
throw new EpEnvelopeError("unavailable", "the manager is still booting its workflow-run host; retry shortly (SPEC 14.3)");
|
|
1069
1015
|
}
|
|
1070
1016
|
/** The answerer a `run-answer` records (SPEC 14.5): the caller as this manager knows them. A
|
|
@@ -1224,7 +1170,7 @@ export class Manager {
|
|
|
1224
1170
|
caller,
|
|
1225
1171
|
admin,
|
|
1226
1172
|
userMode: this.userMode,
|
|
1227
|
-
scopeOf: (owner, actor) => resolveAuthProvider().actorScope({ dir: userAuthStateDir(this.workspaceRoot, this.space), owner, actor }),
|
|
1173
|
+
scopeOf: (owner, actor) => resolveAuthProvider().actorScope({ dir: userAuthStateDir(this.config.workspaceRoot, this.config.space), owner, actor }),
|
|
1228
1174
|
});
|
|
1229
1175
|
}
|
|
1230
1176
|
/** The wire principal of a managed agent: {@link managedPrincipal}. */
|
|
@@ -1247,7 +1193,7 @@ export class Manager {
|
|
|
1247
1193
|
async shredUserSecrets(unshredded, family) {
|
|
1248
1194
|
for (const path of [family.actorToken, family.sentinelCreds])
|
|
1249
1195
|
if (path)
|
|
1250
|
-
await attemptCleanup(unshredded, `secret ${path}`, () => this.secrets.delete(agentSecretKeyForFile(path, this.space)));
|
|
1196
|
+
await attemptCleanup(unshredded, `secret ${path}`, () => this.config.secrets.delete(agentSecretKeyForFile(path, this.config.space)));
|
|
1251
1197
|
for (const path of [family.actorToken, family.sentinelCreds, family.health])
|
|
1252
1198
|
if (path)
|
|
1253
1199
|
await attemptCleanup(unshredded, `file ${path}`, () => rmSync(path, { force: true }));
|
|
@@ -1321,7 +1267,7 @@ export class Manager {
|
|
|
1321
1267
|
const source = a.launch.source;
|
|
1322
1268
|
if (source.kind !== "inline")
|
|
1323
1269
|
return undefined;
|
|
1324
|
-
const path = resolve(inlineSnapshotPath(this.workspaceRoot, a.lifecycleUid));
|
|
1270
|
+
const path = resolve(inlineSnapshotPath(this.config.workspaceRoot, a.lifecycleUid));
|
|
1325
1271
|
if (resolve(source.configPath) !== path)
|
|
1326
1272
|
return `its recorded inline persona snapshot ${source.configPath} is not this lifecycle's snapshot path`;
|
|
1327
1273
|
if (a.restart !== undefined && resolve(a.restart.opts.configPath ?? "") !== path)
|
|
@@ -1424,7 +1370,7 @@ export class Manager {
|
|
|
1424
1370
|
/** {@link PreservedResume.resumePreservedAgent}. */
|
|
1425
1371
|
resumePreservedAgent(...args) { return this.preservedResumeComponent.resumePreservedAgent(...args); }
|
|
1426
1372
|
probeStaticCredential(creds) {
|
|
1427
|
-
return probeConnect(this.servers ?? DEFAULT_SERVER, { creds, timeoutMs: 5_000 });
|
|
1373
|
+
return probeConnect(this.config.servers ?? DEFAULT_SERVER, { creds, timeoutMs: 5_000 });
|
|
1428
1374
|
}
|
|
1429
1375
|
/** {@link ReadinessWait.awaitReadiness}. */
|
|
1430
1376
|
awaitReadiness(...args) { return this.readinessWaitComponent.awaitReadiness(...args); }
|
|
@@ -1524,7 +1470,7 @@ export class Manager {
|
|
|
1524
1470
|
const generation = a?.lifecycleUid === seat.uid ? a.issued?.generation : participant?.generation;
|
|
1525
1471
|
const caller = { owner: seat.owner, actor: seat.actor, uid: seat.uid, ...(generation !== undefined ? { generation } : {}) };
|
|
1526
1472
|
try {
|
|
1527
|
-
serve.nc.publish(turnNoticeSubject(this.space, this.managerInstanceId, serve.grant.epoch, caller), new TextEncoder().encode(JSON.stringify({ v: 1 })));
|
|
1473
|
+
serve.nc.publish(turnNoticeSubject(this.config.space, this.managerInstanceId, serve.grant.epoch, caller), new TextEncoder().encode(JSON.stringify({ v: 1 })));
|
|
1528
1474
|
}
|
|
1529
1475
|
catch (e) {
|
|
1530
1476
|
console.error(`! turn notice for ${seat.actor} failed: ${rejectionText(e)}`);
|
|
@@ -1648,7 +1594,7 @@ export class Manager {
|
|
|
1648
1594
|
const connector = await this.resolveConnector(r.connector);
|
|
1649
1595
|
if (!connector.retireAfterExit)
|
|
1650
1596
|
throw new Error(`the ${r.connector} connector cannot prove seat ${r.name}'s launched processes gone`);
|
|
1651
|
-
return withTimeout(connector.retireAfterExit({ space: this.space, name: r.name, lifecycleUid: r.uid, workspaceRoot: this.workspaceRoot }), ONCE_RETIRE_MS, `seat ${r.name}'s launched processes were not proved gone within ${ONCE_RETIRE_MS}ms`);
|
|
1597
|
+
return withTimeout(connector.retireAfterExit({ space: this.config.space, name: r.name, lifecycleUid: r.uid, workspaceRoot: this.config.workspaceRoot }), ONCE_RETIRE_MS, `seat ${r.name}'s launched processes were not proved gone within ${ONCE_RETIRE_MS}ms`);
|
|
1652
1598
|
}
|
|
1653
1599
|
/** Make an adopted seat a once seat again: its exit settles its task, and the task is served to
|
|
1654
1600
|
* it. A task that ended before the restart owes the stop the predecessor may not have made. */
|
|
@@ -1680,7 +1626,7 @@ export class Manager {
|
|
|
1680
1626
|
* retirement that confirms the lifecycle is gone. */
|
|
1681
1627
|
releasedSeatPending(a) {
|
|
1682
1628
|
try {
|
|
1683
|
-
return readReleasedSeatReference(this.workspaceRoot, this.space, a.name)?.lifecycleUid === a.lifecycleUid;
|
|
1629
|
+
return readReleasedSeatReference(this.config.workspaceRoot, this.config.space, a.name)?.lifecycleUid === a.lifecycleUid;
|
|
1684
1630
|
}
|
|
1685
1631
|
catch {
|
|
1686
1632
|
return false;
|