@cotal-ai/manager 0.90.1 → 0.91.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 (48) hide show
  1. package/dist/chat-session.d.ts +165 -0
  2. package/dist/chat-session.d.ts.map +1 -0
  3. package/dist/chat-session.js +281 -0
  4. package/dist/chat-session.js.map +1 -0
  5. package/dist/commands.d.ts +3 -0
  6. package/dist/commands.d.ts.map +1 -1
  7. package/dist/commands.js +374 -163
  8. package/dist/commands.js.map +1 -1
  9. package/dist/endpoint-evict.d.ts +2 -0
  10. package/dist/endpoint-evict.d.ts.map +1 -1
  11. package/dist/endpoint-evict.js +1 -0
  12. package/dist/endpoint-evict.js.map +1 -1
  13. package/dist/holder-liveness.d.ts +1 -0
  14. package/dist/holder-liveness.d.ts.map +1 -1
  15. package/dist/holder-liveness.js.map +1 -1
  16. package/dist/index.d.ts +4 -2
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +1 -0
  19. package/dist/index.js.map +1 -1
  20. package/dist/manager-service-contract.d.ts +52 -1
  21. package/dist/manager-service-contract.d.ts.map +1 -1
  22. package/dist/manager-service-contract.js +138 -4
  23. package/dist/manager-service-contract.js.map +1 -1
  24. package/dist/manager.d.ts +105 -2
  25. package/dist/manager.d.ts.map +1 -1
  26. package/dist/manager.js +515 -49
  27. package/dist/manager.js.map +1 -1
  28. package/dist/operator-deregister.d.ts +4 -0
  29. package/dist/operator-deregister.d.ts.map +1 -0
  30. package/dist/operator-deregister.js +75 -0
  31. package/dist/operator-deregister.js.map +1 -0
  32. package/dist/service-adapter.d.ts +12 -0
  33. package/dist/service-adapter.d.ts.map +1 -0
  34. package/dist/service-adapter.js +174 -0
  35. package/dist/service-adapter.js.map +1 -0
  36. package/dist/service-child.d.ts +37 -0
  37. package/dist/service-child.d.ts.map +1 -0
  38. package/dist/service-child.js +195 -0
  39. package/dist/service-child.js.map +1 -0
  40. package/dist/service-observation.d.ts +19 -0
  41. package/dist/service-observation.d.ts.map +1 -0
  42. package/dist/service-observation.js +97 -0
  43. package/dist/service-observation.js.map +1 -0
  44. package/dist/static-lifecycle.d.ts +8 -6
  45. package/dist/static-lifecycle.d.ts.map +1 -1
  46. package/dist/static-lifecycle.js +19 -8
  47. package/dist/static-lifecycle.js.map +1 -1
  48. package/package.json +13 -12
@@ -0,0 +1,4 @@
1
+ import { type EndpointDeregisterAction } from "@cotal-ai/workspace";
2
+ /** Reuse the shipped guard and native key-pinned executor. Do not copy either into another CLI. */
3
+ export declare const endpointDeregisterAction: EndpointDeregisterAction;
4
+ //# sourceMappingURL=operator-deregister.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operator-deregister.d.ts","sourceRoot":"","sources":["../src/operator-deregister.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,KAAK,wBAAwB,EAC9B,MAAM,qBAAqB,CAAC;AAG7B,mGAAmG;AACnG,eAAO,MAAM,wBAAwB,EAAE,wBAEtC,CAAC"}
@@ -0,0 +1,75 @@
1
+ import { Kvm } from "@nats-io/kv";
2
+ import { DEV_OWNER, dialerFor, epAuthBucket, mintCreds, mintLifecycleUid, newIdentity, recordsBucket, standaloneConnectOpts, } from "@cotal-ai/core";
3
+ import { CommandFailure, authDir, canonicalRoot, findCotalRoot, getSoleSpaceAuth, getSpaceAuth, hasUserAuthState, isCommandFailure, workspaceSecretStore, } from "@cotal-ai/workspace";
4
+ import { InstanceDeregisterRefused, deregisterEndpointInstance, makeInstanceProbe } from "./deregister-instance.js";
5
+ /** Reuse the shipped guard and native key-pinned executor. Do not copy either into another CLI. */
6
+ export const endpointDeregisterAction = {
7
+ kind: "endpoint-action", name: "deregister", run: deregister,
8
+ };
9
+ async function deregister(request) {
10
+ const { root, space, endpoint, instanceId } = request;
11
+ const target = { space, endpoint, instanceId };
12
+ let auth;
13
+ try {
14
+ if (hasUserAuthState(root, space, { readOnly: true }))
15
+ throw new CommandFailure("refused", "UNSUPPORTED", "a user-auth target cannot use a static signer as a substitute for its supported operator authority", { target });
16
+ const selected = await getSpaceAuth(workspaceSecretStore(root), space);
17
+ if (!selected || selected.account.pub !== request.account)
18
+ throw new CommandFailure("refused", "CONFLICT", "the selected static authority changed or is absent; no other account or root was substituted", { target });
19
+ auth = selected;
20
+ const cwd = findCotalRoot();
21
+ const current = canonicalRoot(cwd) === canonicalRoot(root) ? auth : await getSoleSpaceAuth(workspaceSecretStore(cwd), authDir(cwd));
22
+ if (current && (current.space !== space || current.account.pub !== auth.account.pub))
23
+ throw new CommandFailure("refused", "CONFLICT", "the current folder and selected space hold different account authorities; nothing was deregistered", { target });
24
+ }
25
+ catch (error) {
26
+ if (isCommandFailure(error))
27
+ throw error;
28
+ throw new CommandFailure("refused", "SCHEMA_INVALID", "the selected static authority could not be validated; no native record deletion was attempted", { target });
29
+ }
30
+ let probeNc, execNc;
31
+ let enteredGuard = false;
32
+ let result;
33
+ let failure;
34
+ const warnings = [];
35
+ try {
36
+ const identity = newIdentity(), uid = mintLifecycleUid();
37
+ const probeCreds = await mintCreds(auth, identity, "control-caller-privileged", { lifecycleUid: uid, endpointCapabilities: [{ endpoint, command: "describe", instanceId, instanceOnly: true, routes: [] }] });
38
+ const caller = { owner: DEV_OWNER, actor: identity.id, uid };
39
+ probeNc = await dialerFor(request.server)({ servers: request.server, ...standaloneConnectOpts({ creds: probeCreds, tls: request.tlsRequired }), maxReconnectAttempts: 0 });
40
+ const executorCreds = await mintCreds(auth, newIdentity(), "endpoint-serve-executor", { endpointServeExecutor: { endpoint, instanceId } });
41
+ execNc = await dialerFor(request.server)({ servers: request.server, ...standaloneConnectOpts({ creds: executorCreds, tls: request.tlsRequired }), maxReconnectAttempts: 0 });
42
+ const kv = await new Kvm(execNc).open(recordsBucket(space));
43
+ const authKv = await new Kvm(execNc).open(epAuthBucket(space));
44
+ enteredGuard = true;
45
+ const report = await deregisterEndpointInstance({ kv, authKv, endpoint, instanceId, probeInstance: makeInstanceProbe(probeNc, { space, endpoint, instanceId, caller }), log: () => { } });
46
+ result = { kind: "endpoint-deregistered", space, endpoint, instanceId, probe: "broker-affirmed-gone", removedSpecRevision: report.removedSpecRevision, removedStatusRevision: report.removedStatusRevision ?? null, processStopped: false, issuanceGateChanged: false };
47
+ }
48
+ catch (error) {
49
+ if (isCommandFailure(error))
50
+ failure = error;
51
+ else if (error instanceof InstanceDeregisterRefused) {
52
+ if (error.condition === "superseded")
53
+ failure = new CommandFailure("unknown", "OPERATION_UNKNOWN", "the registration moved during guarded deletion; its spec was not removed, but an older status may already have been removed", { target: { ...target, condition: error.condition }, remedy: "re-observe the same registration and gate; no delete was retried" });
54
+ else
55
+ failure = new CommandFailure("refused", error.condition === "not-registered" ? "TARGET_NOT_FOUND" : error.condition === "liveness-unestablishable" ? "TARGET_UNAVAILABLE" : "LIFECYCLE_BLOCKED", `the native deregistration guard refused: ${error.condition}; no record was removed`, { target: { ...target, condition: error.condition }, remedy: "a quiet or unreachable instance is not a broker-affirmed empty instance rail; inspect the exact target before trying again" });
56
+ }
57
+ else
58
+ failure = new CommandFailure(enteredGuard ? "unknown" : "refused", enteredGuard ? "OPERATION_UNKNOWN" : "TARGET_UNAVAILABLE", enteredGuard ? "the native guarded deletion did not return a confirmed result; no delete was retried" : "the selected native probe/executor connections could not be prepared; no record deletion was attempted", { target, remedy: "inspect this full instance and its registration, never replace it with a prefix or another account" });
59
+ }
60
+ finally {
61
+ for (const nc of [execNc, probeNc]) {
62
+ try {
63
+ if (nc)
64
+ await nc.close();
65
+ }
66
+ catch {
67
+ warnings.push({ code: "DEREGISTER_CONNECTION_CLEANUP_UNCONFIRMED", target, message: "One operation connection's cleanup was not confirmed; the recorded native deletion outcome is unchanged." });
68
+ }
69
+ }
70
+ }
71
+ if (failure)
72
+ throw failure;
73
+ return { ...result, warnings };
74
+ }
75
+ //# sourceMappingURL=operator-deregister.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operator-deregister.js","sourceRoot":"","sources":["../src/operator-deregister.ts"],"names":[],"mappings":"AA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CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,oBAAoB,EAAE,YAAY,CAAC,CAAC,CAAC,sFAAsF,CAAC,CAAC,CAAC,wGAAwG,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,oGAAoG,EAAE,CAAC,CAAC;IACnd,CAAC;YAAS,CAAC;QACT,KAAK,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;YACnC,IAAI,CAAC;gBAAC,IAAI,EAAE;oBAAE,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC;YAAC,CAAC;YACjC,MAAM,CAAC;gBAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,2CAA2C,EAAE,MAAM,EAAE,OAAO,EAAE,0GAA0G,EAAE,CAAC,CAAC;YAAC,CAAC;QAC9M,CAAC;IACH,CAAC;IACD,IAAI,OAAO;QAAE,MAAM,OAAO,CAAC;IAC3B,OAAO,EAAE,GAAG,MAAO,EAAE,QAAQ,EAAE,CAAC;AAClC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { type LocalProcess, type ServiceAdapterAttempt, type ServiceAdapterContext, type ServicePreset } from "@cotal-ai/workspace";
2
+ export declare const managerPreset: ServicePreset;
3
+ /** Whether this root's maintenance journal, if any, admits this launch, as the broker adapter
4
+ * decides for its own. An attempt launch is admitted only for the journal's own attempt, in a
5
+ * state that starts or relaunches the manager, for the cut's manager instance whose newest start
6
+ * row the attempt journaled and has not settled. A launch without an attempt is decided by
7
+ * `maintenanceAdmitsStackWork`, which admits only a settled active controller restore of this
8
+ * root's own stack, as the broker and a service restart decide. Every other journal, legacy
9
+ * custody included, refuses. The journal is only read. */
10
+ export declare function maintenanceAdmits(root: string, server: string, context: ServiceAdapterContext, attempt: ServiceAdapterAttempt | undefined): boolean;
11
+ export declare const managerService: LocalProcess;
12
+ //# sourceMappingURL=service-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-adapter.d.ts","sourceRoot":"","sources":["../src/service-adapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAMgB,KAAK,YAAY,EAAiC,KAAK,qBAAqB,EAAE,KAAK,qBAAqB,EAE7H,KAAK,aAAa,EACnB,MAAM,qBAAqB,CAAC;AAI7B,eAAO,MAAM,aAAa,EAAE,aAG3B,CAAC;AAKF;;;;;;2DAM2D;AAC3D,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,qBAAqB,GAAG,SAAS,GAAG,OAAO,CASnJ;AAsED,eAAO,MAAM,cAAc,EAAE,YAgD5B,CAAC"}
@@ -0,0 +1,174 @@
1
+ import { setTimeout as delay } from "node:timers/promises";
2
+ import { registry } from "@cotal-ai/core";
3
+ import { CommandFailure, MANAGER_PIDFILE, MANAGER_SHUTDOWN_INTENT, armManagerShutdownIntent, assertRecordIdentity, canonicalLocalProcessPath, canonicalRoot, clearRefusedServiceStopRequest, colorEnabled, commandIsCotalSupervisor, controllerAttemptBinding, cutController, localProcessPath, maintenanceAdmitsStackWork, publishServiceStopRequest, readLocalRecordSource, readMaintenanceJournal, readPidfile, readProcessRecord, readServiceStopReceipts, reserveNativeServiceStop, resolveNativeServiceTarget, serviceAdapterAttempt, serviceMetadataDigest, stopReservationPath, } from "@cotal-ai/workspace";
4
+ import { managerServiceLaunchSpec, managerServicePreservedExitScope, managerServiceStopScope } from "./service-child.js";
5
+ import { managerServiceReadiness, observeManagerService } from "./service-observation.js";
6
+ export const managerPreset = {
7
+ kind: "service-preset", name: "manager", adapter: "manager-service", timeoutMs: 60000,
8
+ summary: "native manager with selected-root custody; caller-attributed agent impact, or the child's local receipt on an open space",
9
+ };
10
+ /** Journal states in which a controller attempt starts or relaunches its manager. */
11
+ const ATTEMPT_LAUNCH_STATES = ["resume-intent", "commit-intent", "resume-committed", "manager-committed"];
12
+ /** Whether this root's maintenance journal, if any, admits this launch, as the broker adapter
13
+ * decides for its own. An attempt launch is admitted only for the journal's own attempt, in a
14
+ * state that starts or relaunches the manager, for the cut's manager instance whose newest start
15
+ * row the attempt journaled and has not settled. A launch without an attempt is decided by
16
+ * `maintenanceAdmitsStackWork`, which admits only a settled active controller restore of this
17
+ * root's own stack, as the broker and a service restart decide. Every other journal, legacy
18
+ * custody included, refuses. The journal is only read. */
19
+ export function maintenanceAdmits(root, server, context, attempt) {
20
+ if (!attempt)
21
+ return maintenanceAdmitsStackWork(root, context.space, server, context.stack);
22
+ const journal = readMaintenanceJournal(root);
23
+ if (!journal)
24
+ return true;
25
+ const attemptId = "ordinaryResume" in journal ? journal.ordinaryResume.attemptId : "restore" in journal ? journal.restore.attemptId : undefined;
26
+ const manager = cutController(journal.cut)?.members.find((member) => member.role === "manager");
27
+ const row = [...controllerAttemptBinding(journal)?.started ?? []].reverse().find((entry) => entry.role === "manager");
28
+ return ATTEMPT_LAUNCH_STATES.includes(journal.state) && attempt.attemptId === attemptId && manager?.instanceId === context.instanceId &&
29
+ row?.instanceId === context.instanceId && row.outcome === undefined;
30
+ }
31
+ async function prepareStop(context) {
32
+ if (context.preserved && context.withAgents)
33
+ throw new CommandFailure("refused", "USAGE_INVALID", "a preserved-exit stop retains agents; --with-agents cannot be combined with it");
34
+ const observation = await observeManagerService(context);
35
+ if (!observation)
36
+ throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "the exact native manager has no complete attributed startup observation; no stop was submitted");
37
+ const registration = observation.registration;
38
+ // An attributed status names the binding the manager holds and must equal the request. An open
39
+ // space's local receipt keeps its older shape, so the request is digested and the native child
40
+ // recomputes the scope against its own binding at acceptance.
41
+ const held = observation.stopImpact.preservation ?? context.preserved;
42
+ const scopeSha256 = context.preserved ? managerServicePreservedExitScope(observation, context.preserved, held) : managerServiceStopScope(observation, context.withAgents);
43
+ return {
44
+ scopeSha256, observedAt: new Date().toISOString(), withAgents: context.withAgents,
45
+ native: { endpoint: registration.endpoint, instanceId: registration.instanceId, epoch: registration.epoch, owner: registration.principal.owner, actor: registration.principal.actor, lifecycleUid: registration.principal.uid },
46
+ subjects: observation.stopImpact.agents.map((row) => ({ name: row.name, id: row.id, lifecycleUid: row.lifecycleUid, action: context.withAgents ? row.withAgentsAction : row.defaultAction })),
47
+ ...(observation.evidence ? { evidence: observation.evidence } : {}),
48
+ ...(context.preserved ? { preserved: { attemptId: context.preserved.attemptId, inventorySha256: context.preserved.inventorySha256 } } : {}),
49
+ };
50
+ }
51
+ /** The reservation is retained after any unconfirmed submission. Only a known refusal or both a
52
+ * native returned receipt and the exact process exit can release it. There is no force kill. */
53
+ async function stop(context) {
54
+ const root = String(context.options.root), pidPath = canonicalLocalProcessPath(MANAGER_PIDFILE, { root, space: context.space });
55
+ const reservation = reserveNativeServiceStop(stopReservationPath(pidPath));
56
+ let submitted = false, releasable = true;
57
+ try {
58
+ const current = await prepareStop(context);
59
+ if (current.scopeSha256 !== context.plan.scopeSha256 || current.withAgents !== context.withAgents || current.evidence !== context.plan.evidence || serviceMetadataDigest(current.native) !== serviceMetadataDigest(context.plan.native) || serviceMetadataDigest(current.preserved ?? null) !== serviceMetadataDigest(context.plan.preserved ?? null))
60
+ throw new CommandFailure("refused", "CONFLICT", "the manager impact or native incarnation changed after confirmation; no signal was sent");
61
+ const legacyPid = readLocalRecordSource(pidPath, 128, true)?.toString("utf8").trim();
62
+ if (legacyPid !== String(context.process.pid) || assertRecordIdentity(context.process).kind !== "match")
63
+ throw new CommandFailure("refused", "CONFLICT", "the native manager PID custody changed; no signal was sent");
64
+ const intent = canonicalLocalProcessPath(MANAGER_SHUTDOWN_INTENT, { root, space: context.space });
65
+ if (readLocalRecordSource(intent, 8192, true) !== undefined)
66
+ throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "an earlier native shutdown intent is retained; it was not overwritten or adopted");
67
+ const request = { schemaVersion: 1, space: context.space, instanceId: context.instanceId, launchRequestId: context.launchRequestId, requestId: context.requestId, target: { ...context.process }, stopper: reservation.stopper, withAgents: context.withAgents, scopeSha256: current.scopeSha256, ...(context.preserved ? { preserved: { attemptId: context.preserved.attemptId, inventorySha256: context.preserved.inventorySha256 } } : {}) };
68
+ context.signal.throwIfAborted();
69
+ // Publication can succeed before a durability error reaches us. Retain custody from here.
70
+ releasable = false;
71
+ publishServiceStopRequest(context, request);
72
+ if (context.withAgents)
73
+ armManagerShutdownIntent({ root, space: context.space }, { target: context.process, stopper: { pid: reservation.stopper.pid, marker: stopReservationPath(pidPath) } });
74
+ context.signal.throwIfAborted();
75
+ if (assertRecordIdentity(context.process).kind !== "match")
76
+ throw new CommandFailure("unknown", "OPERATION_UNKNOWN", "the manager process changed after its stop handoff; no successor was signalled");
77
+ submitted = true;
78
+ process.kill(context.process.pid, "SIGTERM");
79
+ const deadline = Date.now() + 30000;
80
+ while (Date.now() < deadline) {
81
+ context.signal.throwIfAborted();
82
+ const phases = readServiceStopReceipts(context, request);
83
+ if (phases.some((row) => row.phase === "refused")) {
84
+ clearRefusedServiceStopRequest(context, request);
85
+ releasable = true;
86
+ throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "the native manager refused the changed request or impact before stopping; inspect again before a new confirmation");
87
+ }
88
+ if (phases.some((row) => row.phase === "failed"))
89
+ throw new CommandFailure("unknown", "OPERATION_UNKNOWN", "the native manager reported a failed stop; process and cleanup completion remain unconfirmed and the original request was retained");
90
+ const completed = phases.find((row) => row.phase === "completed");
91
+ const identity = assertRecordIdentity(context.process);
92
+ if (completed && (identity.kind === "gone" || identity.kind === "mismatch")) {
93
+ releasable = true;
94
+ return { requestId: request.requestId, scopeSha256: request.scopeSha256, process: { ...request.target }, nativeStop: request.preserved ? "preserved-exit-returned" : "returned", cleanup: "not-checked", observedAt: completed.observedAt };
95
+ }
96
+ if (!completed && (identity.kind === "gone" || identity.kind === "mismatch"))
97
+ throw new CommandFailure("unknown", "OPERATION_UNKNOWN", "the original manager process exited without its native returned receipt; disappearance was not treated as a completed stop or cleanup");
98
+ await delay(100, undefined, { signal: context.signal });
99
+ }
100
+ throw new CommandFailure("unknown", "OPERATION_UNKNOWN", "the original native manager stop did not confirm both return and process exit; its request/reservation were retained, without force kill or restart");
101
+ }
102
+ catch (error) {
103
+ if (error instanceof CommandFailure)
104
+ throw error;
105
+ throw new CommandFailure(submitted || !releasable ? "unknown" : "refused", submitted || !releasable ? "OPERATION_UNKNOWN" : "LIFECYCLE_BLOCKED", submitted || !releasable ? "the native manager stop submission or observation was not confirmed; its original request was retained and not retried" : "the native manager preflight did not establish its exact current scope; no stop was submitted");
106
+ }
107
+ finally {
108
+ if (releasable)
109
+ reservation.release();
110
+ }
111
+ }
112
+ export const managerService = {
113
+ kind: "local-process", name: "manager-service", label: "manager service", order: 10, controllerOnly: true,
114
+ pidFile: MANAGER_PIDFILE, isOwnCommand: commandIsCotalSupervisor,
115
+ service: {
116
+ abiVersion: 1, requiresCli: true, readiness: "endpoint", stop: "native",
117
+ capabilities: { multiInstance: false, foreground: true, logs: true }, paths: { root: "directory", launch: "private-file", roster: "file" },
118
+ optionsSchema: { type: "object", additionalProperties: false, required: ["root", "runtime"], properties: {
119
+ root: { type: "string", minLength: 1, maxLength: 4096, description: "registered mesh root holding this manager's native custody" },
120
+ runtime: { type: "string", minLength: 1, maxLength: 200, description: "explicit installed runtime; no runtime is installed or selected implicitly" },
121
+ server: { type: "string", minLength: 1, maxLength: 4096, description: "optional repeat of the registered broker URL; another broker refuses" },
122
+ "console-port": { type: "integer", minimum: 0, maximum: 65535, description: "explicit console port; zero allocates a port" },
123
+ "console-host": { type: "string", minLength: 1, maxLength: 253, description: "explicit console bind host; omitted keeps native loopback binding" },
124
+ "ws-port": { type: "integer", minimum: 1, maximum: 65535, description: "explicit prepared broker websocket listener port" },
125
+ "max-sessions": { type: "integer", minimum: 1, maximum: Number.MAX_SAFE_INTEGER, description: "explicit positive native live-session ceiling" },
126
+ launch: { type: "string", minLength: 1, maxLength: 4096, description: "existing private resolved native launch spec for the selected space" },
127
+ "launch-sha256": { type: "string", minLength: 64, maxLength: 64, description: "full SHA-256 of the exact resolved launch file; required with launch" },
128
+ roster: { type: "string", minLength: 1, maxLength: 4096, description: "existing roster file whose agents the manager starts at each launch; a resumed manager takes none" },
129
+ } },
130
+ },
131
+ buildServiceLaunch(context) {
132
+ if (!context.cliInvocation?.length)
133
+ throw new CommandFailure("refused", "UNSUPPORTED", "the manager service requires the verified cotal entry; no PATH binary was selected");
134
+ if (context.credentialRef)
135
+ throw new CommandFailure("refused", "UNSUPPORTED", "the native manager uses its selected root's supported service authority; a generic credential reference was not substituted");
136
+ const root = String(context.options.root), target = resolveNativeServiceTarget(root, context.space, context.options.server);
137
+ const path = localProcessPath(MANAGER_PIDFILE, { root: target.root, space: context.space });
138
+ const raw = readPidfile(path), state = readProcessRecord(path, commandIsCotalSupervisor);
139
+ if (raw === "" || !["absent", "dead"].includes(state.state))
140
+ throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "a native manager record is live, foreign or unresolved; no legacy manager was adopted, stopped or replaced");
141
+ if (typeof context.options["console-host"] === "string" && /[\u0000- \u007f]/u.test(context.options["console-host"]))
142
+ throw new CommandFailure("refused", "USAGE_INVALID", "the declared console host contains whitespace or controls; no native child was launched");
143
+ const extra = [];
144
+ for (const name of ["console-port", "console-host", "ws-port", "max-sessions"])
145
+ if (context.options[name] !== undefined)
146
+ extra.push(`--${name}`, String(context.options[name]));
147
+ // A controller resume passes only its attempt and, when present, the protected token handoff
148
+ // path and digest. Never the token, and never with a launch spec.
149
+ const attempt = context.attempt === undefined ? undefined : serviceAdapterAttempt(context.attempt, ["resumeCommit"]);
150
+ if (attempt && (context.options.launch !== undefined || context.options["launch-sha256"] !== undefined))
151
+ throw new CommandFailure("refused", "USAGE_INVALID", "a resumed manager takes no launch spec; no native child was launched");
152
+ if (attempt && context.options.roster !== undefined)
153
+ throw new CommandFailure("refused", "USAGE_INVALID", "a resumed manager boots no roster; retained agents resume through the attempt. No native child was launched");
154
+ if (!maintenanceAdmits(canonicalRoot(target.root), target.server, context, attempt))
155
+ throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "this root retains a maintenance or recovery attempt; the manager service did not substitute an ordinary lifecycle");
156
+ if (attempt)
157
+ extra.push("--resume-attempt", attempt.attemptId, ...(attempt.resumeCommit ? ["--resume-commit-file", attempt.resumeCommit.path, "--resume-commit-sha256", attempt.resumeCommit.sha256] : []));
158
+ if (context.options.launch !== undefined || context.options["launch-sha256"] !== undefined) {
159
+ if (typeof context.options.launch !== "string" || typeof context.options["launch-sha256"] !== "string")
160
+ throw new CommandFailure("refused", "USAGE_INVALID", "a manager launch requires both its private native spec and full SHA-256; neither was inferred");
161
+ managerServiceLaunchSpec(context.options.launch, context.options["launch-sha256"], context.space);
162
+ extra.push("--launch", context.options.launch, "--launch-sha256", context.options["launch-sha256"]);
163
+ }
164
+ if (context.options.roster !== undefined)
165
+ extra.push("--roster", String(context.options.roster));
166
+ const [executable, ...self] = context.cliInvocation;
167
+ return { executable: executable, cwd: target.root, args: [...self, ...(colorEnabled() ? [] : ["--no-color"]), "__service-manager", "--root", target.root, "--space", context.space, "--server", target.server, "--runtime", String(context.options.runtime), "--service-instance", context.instanceId, "--launch-request", context.launchRequestId, "--state-directory", context.stateDirectory, ...extra] };
168
+ },
169
+ checkServiceReadiness: managerServiceReadiness,
170
+ prepareServiceStop: prepareStop,
171
+ stopService: stop,
172
+ };
173
+ registry.register(managerService, managerPreset);
174
+ //# sourceMappingURL=service-adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-adapter.js","sourceRoot":"","sources":["../src/service-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EACL,cAAc,EAAE,eAAe,EAAE,uBAAuB,EAAE,wBAAwB,EAClF,oBAAoB,EAAE,yBAAyB,E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from "@cotal-ai/core";
2
+ import { type NativeServiceStopRequest, type ServiceAdapterContext } from "@cotal-ai/workspace";
3
+ import type { Manager, ManagerOptions, ManagerServiceObservation, StartAgentOpts } from "./manager.js";
4
+ export interface ManagerServiceChild {
5
+ readonly root: string;
6
+ readonly context: Pick<ServiceAdapterContext, "space" | "instanceId" | "launchRequestId" | "stateDirectory">;
7
+ readonly launchSpec?: MeshLaunchSpec;
8
+ /** The roster's agents, parsed once here like the launch spec. */
9
+ readonly roster?: readonly StartAgentOpts[];
10
+ }
11
+ /** Read one private, content-pinned manifest once. The child keeps these parsed bytes rather than
12
+ * reopening a path after asynchronous authority preparation. */
13
+ export declare function managerServiceLaunchSpec(path: string, digest: string, space: string): MeshLaunchSpec;
14
+ /** Hidden runner inputs contain public coordinates only, never credentials or console URLs. */
15
+ export declare function managerServiceChild(args: ParsedArgs): ManagerServiceChild;
16
+ /** Shared by the native child and its caller-attributed controller preflight. Dynamic
17
+ * observation time is excluded; identity, policy, agents and pending work remain bound. */
18
+ export declare function managerServiceStopScope(observation: ManagerServiceObservation, withAgents: boolean): string;
19
+ /** The preserved-exit counterpart of {@link managerServiceStopScope}, shared by the native child and
20
+ * the controller. It accepts only a fully preserved, whole-manager, quiescent embedding whose
21
+ * preservation binding is the requested attempt and inventory. The ordinary scope is unchanged. */
22
+ export declare function managerServicePreservedExitScope(observation: ManagerServiceObservation, preserved: {
23
+ attemptId: string;
24
+ inventorySha256: string;
25
+ }, held: {
26
+ attemptId: string;
27
+ inventorySha256: string;
28
+ } | undefined): string;
29
+ /** All guards and acceptance publication are synchronous. The caller invokes mgr.stop in the
30
+ * same event-loop turn, before another native lifecycle callback can change this scope. */
31
+ export declare function acceptManagerServiceStop(manager: Manager, service: ManagerServiceChild): NativeServiceStopRequest;
32
+ export declare function bindManagerServiceIdentity(service: ManagerServiceChild): NonNullable<ManagerOptions["onServiceIdentity"]>;
33
+ /** Answer request-bound local observations addressed to this exact process. Arm it only after the
34
+ * manager-serving startup is published. It answers nothing until the manager has its own serve
35
+ * registration, and stops on dispose. Errors leave the request unanswered, never ready. */
36
+ export declare function armManagerServiceObserver(manager: Manager, service: ManagerServiceChild): () => void;
37
+ //# sourceMappingURL=service-child.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-child.d.ts","sourceRoot":"","sources":["../src/service-child.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAML,KAAK,wBAAwB,EAAE,KAAK,qBAAqB,EAC1D,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAIvG,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,qBAAqB,EAAE,OAAO,GAAG,YAAY,GAAG,iBAAiB,GAAG,gBAAgB,CAAC,CAAC;IAC7G,QAAQ,CAAC,UAAU,CAAC,EAAE,cAAc,CAAC;IACrC,kEAAkE;IAClE,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;CAC7C;AAED;iEACiE;AACjE,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,cAAc,CAUpG;AAED,+FAA+F;AAC/F,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,UAAU,GAAG,mBAAmB,CAqCzE;AAED;4FAC4F;AAC5F,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,yBAAyB,EAAE,UAAU,EAAE,OAAO,GAAG,MAAM,CAqB3G;AAED;;oGAEoG;AACpG,wBAAgB,gCAAgC,CAAC,WAAW,EAAE,yBAAyB,EAAE,SAAS,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,MAAM,CAAA;CAAE,EAAE,IAAI,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,GAAG,MAAM,CAuB5N;AAED;4FAC4F;AAC5F,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,mBAAmB,GAAG,wBAAwB,CA0BjH;AAED,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,mBAAmB,GAAG,WAAW,CAAC,cAAc,CAAC,mBAAmB,CAAC,CAAC,CAEzH;AAED;;4FAE4F;AAC5F,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,mBAAmB,GAAG,MAAM,IAAI,CASpG"}
@@ -0,0 +1,195 @@
1
+ import { createHash } from "node:crypto";
2
+ import { lstatSync } from "node:fs";
3
+ import { isAbsolute, join } from "node:path";
4
+ import { CommandFailure, MANAGER_PIDFILE, answerServiceObservations, assertRecordIdentity, canonicalLocalProcessPath, consumeManagerShutdownIntent, protectedCredentialReference, protectedLocalDirectory, publishServiceIdentity, publishServiceStopReceipt, readLocalRecordSource, readServiceIdentity, readServiceStopReceipts, readServiceStopRequest, resolveNativeServiceTarget, serviceMetadataDigest, serviceOperationId, serviceStopRequestPath, stopReservationPath, } from "@cotal-ai/workspace";
5
+ import { parseLaunchSpec } from "./launch.js";
6
+ import { loadRoster } from "./roster.js";
7
+ /** Read one private, content-pinned manifest once. The child keeps these parsed bytes rather than
8
+ * reopening a path after asynchronous authority preparation. */
9
+ export function managerServiceLaunchSpec(path, digest, space) {
10
+ if (!isAbsolute(path) || path.length > 4096 || /[\u0000-\u001f\u007f]/u.test(path) || !/^[0-9a-f]{64}$/.test(digest))
11
+ throw new CommandFailure("refused", "USAGE_INVALID", "an owned manager launch requires an absolute private spec and its full SHA-256");
12
+ protectedCredentialReference(path);
13
+ const bytes = readLocalRecordSource(path, 256 * 1024, true);
14
+ if (!bytes || createHash("sha256").update(bytes).digest("hex") !== digest)
15
+ throw new CommandFailure("refused", "CONFLICT", "the owned manager launch spec is absent or changed from its declared digest; no agent launch was selected");
16
+ let spec;
17
+ try {
18
+ spec = parseLaunchSpec(JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes)), "owned manager launch");
19
+ }
20
+ catch {
21
+ throw new CommandFailure("refused", "SCHEMA_INVALID", "the owned manager launch spec is not valid native launch data; document contents were not echoed");
22
+ }
23
+ if (spec.space !== space)
24
+ throw new CommandFailure("refused", "CONFLICT", "the owned manager launch spec names another space; no target was substituted");
25
+ return spec;
26
+ }
27
+ /** Hidden runner inputs contain public coordinates only, never credentials or console URLs. */
28
+ export function managerServiceChild(args) {
29
+ const values = args.values;
30
+ for (const key of ["root", "space", "server", "runtime", "service-instance", "launch-request", "state-directory"]) {
31
+ if (typeof values[key] !== "string" || !values[key] || values[key].length > 4096 || /[\u0000-\u001f\u007f]/u.test(values[key]))
32
+ throw new CommandFailure("refused", "USAGE_INVALID", "the native manager child requires its explicit public target, runtime and full launch coordinates");
33
+ }
34
+ if (args.positionals.length)
35
+ throw new CommandFailure("refused", "USAGE_INVALID", "the native manager child takes no positional targets");
36
+ const root = String(values.root), stateDirectory = String(values["state-directory"]);
37
+ if (process.platform !== "linux" || !isAbsolute(root) || !isAbsolute(stateDirectory))
38
+ throw new CommandFailure("refused", "UNSUPPORTED", "the native manager child requires protected absolute paths and Linux process creation identity");
39
+ protectedLocalDirectory(root);
40
+ protectedLocalDirectory(join(root, ".cotal"));
41
+ protectedLocalDirectory(stateDirectory);
42
+ const directory = lstatSync(stateDirectory);
43
+ if (directory.uid !== process.getuid() || (directory.mode & 0o077) !== 0)
44
+ throw new CommandFailure("refused", "PERMISSION_DENIED", "the native manager launch state must be an owned private directory");
45
+ const target = resolveNativeServiceTarget(root, String(values.space), String(values.server));
46
+ const context = Object.freeze({ space: target.space, instanceId: serviceOperationId(values["service-instance"]), launchRequestId: serviceOperationId(values["launch-request"]), stateDirectory });
47
+ for (const [field, minimum, maximum] of [["console-port", 0, 65535], ["ws-port", 1, 65535], ["max-sessions", 1, Number.MAX_SAFE_INTEGER]]) {
48
+ const value = values[field];
49
+ if (value !== undefined && (typeof value !== "string" || !/^(0|[1-9][0-9]*)$/.test(value) || !Number.isSafeInteger(Number(value)) || Number(value) < minimum || Number(value) > maximum))
50
+ throw new CommandFailure("refused", "USAGE_INVALID", "the native manager child requires valid explicit ports and a positive session ceiling");
51
+ }
52
+ if (values["console-host"] !== undefined && (typeof values["console-host"] !== "string" || !values["console-host"] || values["console-host"].length > 253 || /[\u0000- \u007f]/u.test(values["console-host"])))
53
+ throw new CommandFailure("refused", "USAGE_INVALID", "the native manager child requires a bounded explicit console host without controls");
54
+ let launchSpec;
55
+ if (values.launch !== undefined || values["launch-sha256"] !== undefined) {
56
+ if (typeof values.launch !== "string" || typeof values["launch-sha256"] !== "string")
57
+ throw new CommandFailure("refused", "USAGE_INVALID", "the native manager child requires both its private launch spec and full digest");
58
+ launchSpec = managerServiceLaunchSpec(values.launch, values["launch-sha256"], target.space);
59
+ }
60
+ if (values["resume-attempt"] !== undefined && (typeof values["resume-attempt"] !== "string" || !/^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/.test(values["resume-attempt"])))
61
+ throw new CommandFailure("refused", "USAGE_INVALID", "the native manager child requires a safe resume attempt token");
62
+ if ((values["resume-commit-file"] !== undefined || values["resume-commit-sha256"] !== undefined) && (values["resume-attempt"] === undefined || typeof values["resume-commit-file"] !== "string" || !isAbsolute(values["resume-commit-file"]) || values["resume-commit-file"].length > 4096 || /[\u0000-\u001f\u007f]/u.test(values["resume-commit-file"]) || typeof values["resume-commit-sha256"] !== "string" || !/^[0-9a-f]{64}$/.test(values["resume-commit-sha256"])))
63
+ throw new CommandFailure("refused", "USAGE_INVALID", "the native manager child requires its resume attempt, an absolute resume commit file and its full digest together");
64
+ if ((values["resume-attempt"] !== undefined) && (values.launch !== undefined || values["launch-sha256"] !== undefined))
65
+ throw new CommandFailure("refused", "USAGE_INVALID", "a resumed native manager takes no launch spec; retained agents resume through the attempt-bound control operation");
66
+ let roster;
67
+ if (values.roster !== undefined) {
68
+ if (typeof values.roster !== "string" || !isAbsolute(values.roster) || values.roster.length > 4096 || /[\u0000-\u001f\u007f]/u.test(values.roster))
69
+ throw new CommandFailure("refused", "USAGE_INVALID", "the native manager child requires an absolute roster file path without controls");
70
+ if (values["resume-attempt"] !== undefined)
71
+ throw new CommandFailure("refused", "USAGE_INVALID", "a resumed native manager boots no roster; retained agents resume through the attempt-bound control operation");
72
+ try {
73
+ roster = loadRoster(values.roster);
74
+ }
75
+ catch (error) {
76
+ throw new CommandFailure("refused", "SCHEMA_INVALID", `the manager roster was not loaded: ${error.message}`);
77
+ }
78
+ }
79
+ serviceStopRequestPath(context);
80
+ return Object.freeze({ root: target.root, context, ...(launchSpec ? { launchSpec } : {}), ...(roster ? { roster } : {}) });
81
+ }
82
+ /** Shared by the native child and its caller-attributed controller preflight. Dynamic
83
+ * observation time is excluded; identity, policy, agents and pending work remain bound. */
84
+ export function managerServiceStopScope(observation, withAgents) {
85
+ const impact = observation.stopImpact;
86
+ const pending = { lifecycleInFlight: impact.lifecycleInFlight, reservedLaunches: impact.reservedLaunches, retirementsPending: impact.retirementsPending, deprovisioningInFlight: impact.deprovisioningInFlight, staticReconciliationInFlight: impact.staticReconciliationInFlight };
87
+ const blockers = [
88
+ ...(impact.agentScope !== "manager" ? ["owner-filtered-visibility"] : []),
89
+ ...(impact.maintenance !== "active" ? ["maintenance"] : []),
90
+ ...(impact.resumeRequired ? ["resume-required"] : []),
91
+ ...(impact.stopping ? ["stop-in-progress"] : []),
92
+ ...Object.entries(pending).filter(([, count]) => count !== 0).map(([name]) => name),
93
+ ];
94
+ if (blockers.length)
95
+ throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", impact.agentScope !== "manager" ? "the native manager returned owner-filtered impact; no whole-manager stop policy was accepted" : "the native manager did not meet its full-scope quiescence checks; no stop policy was accepted", {
96
+ target: { managerInstanceId: observation.registration.instanceId },
97
+ native: { detail: { phase: "manager-stop-preflight", blockers, agentScope: impact.agentScope, maintenance: impact.maintenance, resumeRequired: impact.resumeRequired, stopping: impact.stopping, pending } },
98
+ remedy: impact.agentScope !== "manager" ? "ask the stack operator to stop this shared manager, or use an authorized admin-scoped caller; no wider caller was substituted" : "inspect the reported blockers and this manager's native status before another stop; no stop was submitted",
99
+ });
100
+ const agents = impact.agents.map((row) => ({ ...row })).sort((a, b) => {
101
+ const first = JSON.stringify([a.name, a.id, a.lifecycleUid]), second = JSON.stringify([b.name, b.id, b.lifecycleUid]);
102
+ return first < second ? -1 : first > second ? 1 : 0;
103
+ });
104
+ const { observedAt: _observedAt, ...policy } = impact;
105
+ return serviceMetadataDigest({ registration: observation.registration, withAgents, impact: { ...policy, agents } });
106
+ }
107
+ /** The preserved-exit counterpart of {@link managerServiceStopScope}, shared by the native child and
108
+ * the controller. It accepts only a fully preserved, whole-manager, quiescent embedding whose
109
+ * preservation binding is the requested attempt and inventory. The ordinary scope is unchanged. */
110
+ export function managerServicePreservedExitScope(observation, preserved, held) {
111
+ const impact = observation.stopImpact;
112
+ const pending = { lifecycleInFlight: impact.lifecycleInFlight, reservedLaunches: impact.reservedLaunches, retirementsPending: impact.retirementsPending, deprovisioningInFlight: impact.deprovisioningInFlight, staticReconciliationInFlight: impact.staticReconciliationInFlight };
113
+ const blockers = [
114
+ ...(impact.agentScope !== "manager" ? ["owner-filtered-visibility"] : []),
115
+ ...(impact.maintenance !== "preserved" ? ["not-preserved"] : []),
116
+ ...(impact.stopping ? ["stop-in-progress"] : []),
117
+ ...Object.entries(pending).filter(([, count]) => count !== 0).map(([name]) => name),
118
+ ...(!held || held.attemptId !== preserved.attemptId || held.inventorySha256 !== preserved.inventorySha256 ? ["preservation-mismatch"] : []),
119
+ ];
120
+ if (blockers.length)
121
+ throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "the native manager is not the fully preserved, quiescent embedding this preserved-exit stop names; no stop policy was accepted", {
122
+ target: { managerInstanceId: observation.registration.instanceId },
123
+ native: { detail: { phase: "manager-preserved-exit-preflight", blockers, agentScope: impact.agentScope, maintenance: impact.maintenance, stopping: impact.stopping, pending } },
124
+ remedy: "inspect this manager's native status and the maintenance journal before another preserved stop; no stop was submitted",
125
+ });
126
+ const agents = impact.agents.map((row) => ({ ...row })).sort((a, b) => {
127
+ const first = JSON.stringify([a.name, a.id, a.lifecycleUid]), second = JSON.stringify([b.name, b.id, b.lifecycleUid]);
128
+ return first < second ? -1 : first > second ? 1 : 0;
129
+ });
130
+ // The binding is named once, outside the impact, so both sides digest the same shape whether or
131
+ // not their observation carried it.
132
+ const { observedAt: _observedAt, preservation: _preservation, ...policy } = impact;
133
+ return serviceMetadataDigest({ registration: observation.registration, kind: "preserved-exit", attemptId: preserved.attemptId, inventorySha256: preserved.inventorySha256, impact: { ...policy, agents } });
134
+ }
135
+ /** All guards and acceptance publication are synchronous. The caller invokes mgr.stop in the
136
+ * same event-loop turn, before another native lifecycle callback can change this scope. */
137
+ export function acceptManagerServiceStop(manager, service) {
138
+ const request = readServiceStopRequest(service.context);
139
+ if (!request)
140
+ throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "this managed manager has no request-bound native stop handoff; no stop was started");
141
+ if (readServiceStopReceipts(service.context, request).length)
142
+ throw new CommandFailure("unknown", "OPERATION_UNKNOWN", "this native manager stop request already has phase evidence; it was not replayed");
143
+ const refuse = () => {
144
+ publishServiceStopReceipt(service.context, request, "refused");
145
+ throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "the native manager stop target, reservation or reviewed scope changed; no stop was started");
146
+ };
147
+ if (request.target.pid !== process.pid || assertRecordIdentity(request.target).kind !== "match")
148
+ throw new CommandFailure("unknown", "OPERATION_UNKNOWN", "the native manager stop handoff does not name this process; no phase was attributed to it");
149
+ const binding = readServiceIdentity(service.context, request.target);
150
+ const observation = manager.localServiceObservation();
151
+ if (!binding || !observation || serviceMetadataDigest(binding.native) !== serviceMetadataDigest({ endpoint: observation.registration.endpoint, instanceId: observation.registration.instanceId, principal: observation.registration.principal }))
152
+ return refuse();
153
+ const pidPath = canonicalLocalProcessPath(MANAGER_PIDFILE, { root: service.root, space: service.context.space });
154
+ const pid = readLocalRecordSource(pidPath, 128, true)?.toString("utf8").trim();
155
+ const stopper = readLocalRecordSource(stopReservationPath(pidPath), 128, true)?.toString("utf8");
156
+ if (pid !== String(request.target.pid) || stopper !== String(request.stopper.pid) || assertRecordIdentity(request.stopper).kind !== "match")
157
+ return refuse();
158
+ let scope;
159
+ // A preserved request selects the preserved-exit scope. A preserved request that also asks to
160
+ // reap agents is refused, and so is any request the embedding's own state does not support.
161
+ if (request.preserved && request.withAgents)
162
+ return refuse();
163
+ try {
164
+ scope = request.preserved ? managerServicePreservedExitScope(observation, request.preserved, manager.localPreservation()) : managerServiceStopScope(observation, request.withAgents);
165
+ }
166
+ catch {
167
+ return refuse();
168
+ }
169
+ if (scope !== request.scopeSha256)
170
+ return refuse();
171
+ const decision = consumeManagerShutdownIntent({ root: service.root, space: service.context.space });
172
+ if (decision.warning || decision.withAgents !== request.withAgents)
173
+ return refuse();
174
+ publishServiceStopReceipt(service.context, request, "accepted");
175
+ return request;
176
+ }
177
+ export function bindManagerServiceIdentity(service) {
178
+ return (identity) => publishServiceIdentity(service.context, identity);
179
+ }
180
+ /** Answer request-bound local observations addressed to this exact process. Arm it only after the
181
+ * manager-serving startup is published. It answers nothing until the manager has its own serve
182
+ * registration, and stops on dispose. Errors leave the request unanswered, never ready. */
183
+ export function armManagerServiceObserver(manager, service) {
184
+ const timer = setInterval(() => {
185
+ try {
186
+ if (!manager.localServiceObservation())
187
+ return;
188
+ answerServiceObservations(service.context, () => manager.localServiceObservation());
189
+ }
190
+ catch { /* unanswered: the controller times out with no evidence */ }
191
+ }, 200);
192
+ timer.unref();
193
+ return () => clearInterval(timer);
194
+ }
195
+ //# sourceMappingURL=service-child.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-child.js","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