@cotal-ai/manager 0.20.0 → 0.21.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.
@@ -8,7 +8,7 @@ export interface NamedControlTarget {
8
8
  userOwner?: string;
9
9
  }
10
10
  /**
11
- * The named-target (stop/attach) authorization decision — pure, so the policy is pinnable without
11
+ * The named-target (stop/attach/input) authorization decision — pure, so the policy is pinnable without
12
12
  * a broker. The caller already passed the broker's tier admission (cred-gated publish); this
13
13
  * decides what the manager honors, fail-closed, ONLY from the subject-pinned caller principal and
14
14
  * the target's spawn-time records:
package/dist/authorize.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { parsePrincipalKey } from "@cotal-ai/core";
2
2
  /**
3
- * The named-target (stop/attach) authorization decision — pure, so the policy is pinnable without
3
+ * The named-target (stop/attach/input) authorization decision — pure, so the policy is pinnable without
4
4
  * a broker. The caller already passed the broker's tier admission (cred-gated publish); this
5
5
  * decides what the manager honors, fail-closed, ONLY from the subject-pinned caller principal and
6
6
  * the target's spawn-time records:
@@ -34,7 +34,7 @@ export async function authorizeNamedControl(opts) {
34
34
  return undefined;
35
35
  }
36
36
  return (`not authorized: ${target.name} runs under another owner - your grant covers agents under your own owner; ` +
37
- `cross-owner stop/attach needs scope "admin" on your actor. Re-grant with "admin" ADDED to your current ` +
37
+ `cross-owner stop/attach/input needs scope "admin" on your actor. Re-grant with "admin" ADDED to your current ` +
38
38
  `scope (the upsert replaces the list; see \`cotal actor list\`)`);
39
39
  }
40
40
  return `not authorized: ${target.name} was not spawned by ${caller} (admin tier required)`;
@@ -1 +1 @@
1
- {"version":3,"file":"authorize.js","sourceRoot":"","sources":["../src/authorize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAYnD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,IAW3C;IACC,MAAM,EAAE,MAAM,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AE,OAAO,SAAS,CAAC;IACjC,MAAM,WAAW,GAAG,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC;IAC1D,IAAI,WAAW,KAAK,SAAS;QAAE,OAAO,0BAA0B,IAAI,CAAC,MAAM,4BAA4B,CAAC;IACxG,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS,IAAI,IAAI,CAAC,SAAS,KAAK,WAAW;QAChE,OAAO,CACL,uBAAuB,IAAI,CAAC,KAAK,yEAAyE;YAC1G,wGAAwG;YACxG,sFAAsF,CACvF,CAAC;IACJ,OAAO,SAAS,CAAC;AACnB,CAAC"}
package/dist/commands.js CHANGED
@@ -1,16 +1,62 @@
1
+ import { existsSync, readFileSync, rmSync, writeFileSync } from "node:fs";
2
+ import { join } from "node:path";
1
3
  import { connect } from "@nats-io/transport-node";
2
4
  import { Kvm } from "@nats-io/kv";
3
- import { isReachable, epAuthBucket, mintCreds, newIdentity, standaloneConnectOpts, DEFAULT_SERVER, DEFAULT_SPACE, registry, } from "@cotal-ai/core";
4
- import { authDir, findCotalRoot, getSpaceAuth, loadManagerInstanceIdentity, soleSpaceOf, workspaceSecretStore } from "@cotal-ai/workspace";
5
+ import { isReachable, epAuthBucket, recordsBucket, instancePinnedInstrumentCapabilities, mintCreds, mintLifecycleUid, newIdentity, standaloneConnectOpts, DEFAULT_SERVER, DEFAULT_SPACE, DEV_OWNER, registry, } from "@cotal-ai/core";
6
+ import { authDir, findCotalRoot, getSpaceAuth, loadManagerInstanceIdentity, soleSpaceOf, workspaceSecretStore, MANAGER_DELIVERY_AWARE_MARKER, MANAGER_PIDFILE, } from "@cotal-ai/workspace";
5
7
  import { Manager } from "./manager.js";
6
8
  import { MANAGER_ENDPOINT } from "./manager-service-contract.js";
7
9
  import { makeManagerEndpointEvictor } from "./endpoint-evict.js";
8
10
  import { makeManagerHolderLivenessProbe } from "./holder-liveness.js";
9
11
  import { GateReconcileRefused, reconcileEndpointGate } from "./reconcile-gate.js";
12
+ import { InstanceDeregisterRefused, deregisterEndpointInstance, makeInstanceProbe } from "./deregister-instance.js";
10
13
  import { loadRoster } from "./roster.js";
11
14
  import { loadLaunchSpec, materializePersona, launchAgentToStartOpts } from "./launch.js";
12
15
  import {} from "./runtime/index.js";
13
16
  import { c } from "./ui.js";
17
+ /**
18
+ * RECORD THIS PROCESS as the running manager, and un-record it on a clean exit.
19
+ *
20
+ * The daemon writes its OWN pid because it is the only participant that knows it. Until now the
21
+ * record was written by whoever SPAWNED a manager (`cotal up`'s detached re-exec), so every other
22
+ * route to a running manager — a container entrypoint, cron, an operator typing `cotal supervise` —
23
+ * left `.cotal/manager.pid` untouched. On a box where a supervisor is respawned by anything but the
24
+ * CLI, the file then holds the pid of a manager that died some time ago while the live one runs
25
+ * unlisted, and every reader of that file is answering about a process that no longer exists.
26
+ *
27
+ * The returned release is pid-CHECKED. A manager that exits must not delete a record that already
28
+ * belongs to its successor (a fast restart writes the new pid before the old process finishes
29
+ * unwinding), so the record is removed only while it still names this process — the same rule the
30
+ * rest of the pidfile contract keeps: never delete a record you cannot prove is yours.
31
+ *
32
+ * A folder with no `.cotal/` is not a workspace and gets no record: creating one here would plant a
33
+ * stray workspace root wherever a manager happened to be started.
34
+ */
35
+ function recordManagerPid(root) {
36
+ const dir = join(root, ".cotal");
37
+ if (!existsSync(dir)) {
38
+ console.error(c.dim(`• no ${dir} here, so this manager is not recorded in a pidfile (nothing local will find it by pid)`));
39
+ return () => { };
40
+ }
41
+ const pidPath = join(dir, MANAGER_PIDFILE);
42
+ const markerPath = join(dir, MANAGER_DELIVERY_AWARE_MARKER);
43
+ const mine = String(process.pid);
44
+ writeFileSync(pidPath, mine);
45
+ // Written together and removed together: the marker proves the LIVE pid is a non-hosting build,
46
+ // and it is only meaningful while it names that same pid.
47
+ writeFileSync(markerPath, mine);
48
+ return () => {
49
+ for (const p of [markerPath, pidPath]) {
50
+ try {
51
+ if (readFileSync(p, "utf8").trim() === mine)
52
+ rmSync(p, { force: true });
53
+ }
54
+ catch {
55
+ /* already gone, or unreadable: leaving a record we cannot prove is ours is the safe error */
56
+ }
57
+ }
58
+ };
59
+ }
14
60
  /** The space to operate on: explicit `--space`, else this folder's `.cotal/auth` space, else the
15
61
  * default — so a manually-run manager matches the folder's mesh instead of assuming the default. */
16
62
  function spaceFor(v) {
@@ -83,6 +129,9 @@ async function runManager(args, defaultRuntime) {
83
129
  process.exit(1);
84
130
  }
85
131
  await mgr.start();
132
+ // AFTER start, not before: a manager that failed to come up must not leave a record claiming it
133
+ // did. `findCotalRoot` is the same root the Manager itself defaulted to.
134
+ const releasePidRecord = recordManagerPid(findCotalRoot());
86
135
  console.log(c.green("✓ manager up") +
87
136
  c.dim(` (space ${space} · ${mgr.runtimeKind})`) +
88
137
  `\n console: ${mgr.consoleUrl}` +
@@ -90,9 +139,15 @@ async function runManager(args, defaultRuntime) {
90
139
  // Register shutdown handlers before any spawning, so a Ctrl-C during the (possibly slow,
91
140
  // staggered) boot tears the manager and its spawned teammates down rather than orphaning them.
92
141
  const shutdown = () => void mgr.stop()
93
- .then(() => process.exit(0))
142
+ .then(() => {
143
+ releasePidRecord();
144
+ process.exit(0);
145
+ })
94
146
  .catch((e) => {
95
147
  process.exitCode = 1;
148
+ // The record is NOT released here: the stop did not complete, so this process may still be
149
+ // running and still holding the control plane. A record removed under a failed stop is the
150
+ // orphan-the-process defect the pidfile contract exists to prevent.
96
151
  console.error(c.red(`✗ ${e.message}`));
97
152
  });
98
153
  process.on("SIGINT", shutdown);
@@ -218,6 +273,82 @@ async function runReconcileGate(args) {
218
273
  await nc.drain().catch(() => nc.close());
219
274
  }
220
275
  }
276
+ /**
277
+ * `cotal deregister-instance` — remove the service registration of an instance whose host is gone.
278
+ *
279
+ * WHY A LOCAL OPERATOR COMMAND AND NOT AN ADMIN VERB ON THE ENDPOINT: the record to remove belongs
280
+ * to an instance that by definition answers nothing, so there is no one to ask. It runs against the
281
+ * records KV with a credential minted from the space seed on this machine, needing nothing from the
282
+ * dead instance.
283
+ *
284
+ * TWO CREDENTIALS, because they are two different authorities and neither implies the other:
285
+ * - a `control-caller-privileged` instrument PINNED to the instance, which is what can ask the
286
+ * instance's own rail whether anything is there (the guard);
287
+ * - an `endpoint-serve-executor` pinned to the same instance, which carries that registration's
288
+ * two records keys (the delete). NAMED RESIDUAL: this is the existing registration profile, so
289
+ * it also carries the endpoint's governance head and the rest of the serve-mint footprint —
290
+ * wider than the two keys used here. It is minted locally by an operator who already holds the
291
+ * space seed, is one-shot, and never leaves this command; narrowing the profile is a
292
+ * `provision.ts` change with its own review.
293
+ */
294
+ async function runDeregisterInstance(args) {
295
+ const v = args.values;
296
+ const space = spaceFor(v);
297
+ const servers = v.server ?? DEFAULT_SERVER;
298
+ const endpoint = v.endpoint ?? MANAGER_ENDPOINT;
299
+ const root = findCotalRoot();
300
+ // Same default as `reconcile-gate`: this folder's own persisted manager instance. A FOREIGN
301
+ // corpse (another machine's instance, the case this exists for) is named explicitly, and `cotal
302
+ // ps` prints the whole id for exactly that.
303
+ const instanceId = v.instance ?? loadManagerInstanceIdentity(root, space)?.instanceId;
304
+ if (!instanceId)
305
+ throw new Error(`no persisted manager instance identity under ${root} for space "${space}" - pass --instance <id> (the whole id, as \`cotal ps\` prints it)`);
306
+ const auth = await getSpaceAuth(workspaceSecretStore(root), space);
307
+ if (!auth)
308
+ throw new Error(`no space auth for "${space}" here - run this on the mesh root that holds the space's auth material`);
309
+ console.error(c.dim(`• deregistering ${endpoint}/${instanceId} on ${servers} (space ${space})`));
310
+ // The GUARD's credential: a one-shot privileged instrument pinned to this one instance, so its
311
+ // describe and its interest probe ride that instance's own `inst` rails and nothing wider.
312
+ const probeIdentity = newIdentity();
313
+ const probeUid = mintLifecycleUid();
314
+ const probeCreds = await mintCreds(auth, probeIdentity, "control-caller-privileged", {
315
+ lifecycleUid: probeUid,
316
+ endpointCapabilities: instancePinnedInstrumentCapabilities("privileged", instanceId),
317
+ });
318
+ const probeCaller = { owner: DEV_OWNER, actor: probeIdentity.id, uid: probeUid };
319
+ const probeNc = await connect({ servers, ...standaloneConnectOpts({ creds: probeCreds, tls: false }), maxReconnectAttempts: 0 });
320
+ const probeInstance = makeInstanceProbe(probeNc, { space, endpoint, instanceId, caller: probeCaller });
321
+ // The DELETE's credential: the executor whose grants name exactly this registration's two
322
+ // records keys. Minted only after the connection above exists, and used only after the guard.
323
+ const execIdentity = newIdentity();
324
+ const execCreds = await mintCreds(auth, execIdentity, "endpoint-serve-executor", {
325
+ endpointServeExecutor: { endpoint, instanceId },
326
+ });
327
+ const execNc = await connect({ servers, ...standaloneConnectOpts({ creds: execCreds, tls: false }), maxReconnectAttempts: 0 });
328
+ try {
329
+ const kv = await new Kvm(execNc).open(recordsBucket(space));
330
+ const report = await deregisterEndpointInstance({
331
+ kv, endpoint, instanceId, probeInstance, log: (l) => console.error(` ${l}`),
332
+ });
333
+ console.log(c.green(`✓ ${endpoint}/${instanceId} deregistered`) +
334
+ ` (spec revision ${report.removedSpecRevision}${report.removedStatusRevision !== undefined ? `, status revision ${report.removedStatusRevision}` : ""}).` +
335
+ ` It is gone from every class scatter in space "${space}"; if that host ever comes back, its manager registers again on start.`);
336
+ }
337
+ catch (e) {
338
+ // A refusal is the DESIGNED outcome for every state this does not repair, so it prints its
339
+ // condition by name rather than leaving the operator to guess which guard fired.
340
+ if (e instanceof InstanceDeregisterRefused) {
341
+ console.error(c.red(`✗ refused (${e.condition}): ${e.message}`));
342
+ process.exitCode = 2;
343
+ return;
344
+ }
345
+ throw e;
346
+ }
347
+ finally {
348
+ await execNc.drain().catch(() => execNc.close());
349
+ await probeNc.drain().catch(() => probeNc.close());
350
+ }
351
+ }
221
352
  /** The manager's commands: the `supervise` daemon runner, and the guarded `reconcile-gate` repair.
222
353
  * Self-registered on import; the `cotal` binary resolves them from the registry. */
223
354
  const managerCommands = [
@@ -258,6 +389,19 @@ const managerCommands = [
258
389
  ],
259
390
  run: runReconcileGate,
260
391
  },
392
+ {
393
+ kind: "command",
394
+ name: "deregister-instance",
395
+ group: "Manager",
396
+ summary: "remove the service registration of an instance whose host is gone - removes only what the broker affirms gone (nothing subscribed on its rail), and refuses if it answers or is merely quiet [--space <s>] [--server <url>] [--endpoint <e>] [--instance <id>]",
397
+ flags: [
398
+ { name: "space", type: "string", value: "<s>", description: "space the instance is registered in (default: this folder's auth space)" },
399
+ { name: "server", type: "string", value: "<url>", description: "broker URL (default: the local mesh)" },
400
+ { name: "endpoint", type: "string", value: "<e>", description: `endpoint the instance serves (default: ${MANAGER_ENDPOINT})` },
401
+ { name: "instance", type: "string", value: "<id>", description: "instance id to deregister, the whole id as `cotal ps` prints it (default: this folder's persisted manager instance)" },
402
+ ],
403
+ run: runDeregisterInstance,
404
+ },
261
405
  ];
262
406
  registry.register(...managerCommands);
263
407
  //# sourceMappingURL=commands.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"commands.js","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EACL,WAAW,EACX,YAAY,EACZ,SAAS,EACT,WAAW,EACX,qBAAqB,EACrB,cAAc,EACd,aAAa,EACb,QAAQ,GAGT,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,2BAA2B,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3I,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,M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2
+ * GUARDED DEREGISTRATION of a service instance whose host is gone (SPEC 13.5: a deleted `svc` spec
3
+ * IS the deregistration).
4
+ *
5
+ * THE STATE THIS REPAIRS. The service registry records REGISTRATION, not liveness, and no part of
6
+ * the model expires a row. An instance registers, its host dies without writing anything, and the
7
+ * record goes on claiming a live instance for as long as the bucket exists. Every class scatter in
8
+ * that space then freezes the dead slot in, and a gather that ends only when every slot has answered
9
+ * pays its whole deadline waiting for a machine that is never coming back — on every `cotal ps`,
10
+ * `stop` and `attach`, forever. A registration whose holder cooperates removes itself on a clean
11
+ * stop; this is the exit for the one that cannot, and it exists so that state can never be permanent
12
+ * on someone's laptop again.
13
+ *
14
+ * IT IS AN EXPLICIT VERB AND NEVER A SWEEP. Nothing here scans for candidates or acts on an age
15
+ * threshold: silence is not death, and a rule that deleted rows on silence would eventually delete a
16
+ * live instance that was merely slow. An operator names one instance, and the guard's job is to make
17
+ * sure they did not name a live one:
18
+ *
19
+ * 1. ASK THE INSTANCE. A pinned `describe` is the one question every endpoint must answer (§13.7),
20
+ * so an answer is proof of life and REFUSES, unconditionally.
21
+ * 2. REQUIRE THE BROKER'S AFFIRMATIVE ABSENCE. Only a no-responders verdict on the instance's own
22
+ * rail — nothing subscribed there — passes the guard. It is the same evidence `cotal ps` acts
23
+ * on, and it is the whole difference between "gone" and "quiet".
24
+ * 3. REFUSE LOUD, BY CONDITION. "Refused" without a reason sends an operator to the wrong repair.
25
+ *
26
+ * SILENCE IS NOT THE EVIDENCE. An unanswered describe is what a dead host, a wedged process and a
27
+ * slow one all look like, and a process that is merely hung still HOLDS its subscriptions — so the
28
+ * broker sees interest on its rail and cannot affirm it empty. That instance is refused, and the
29
+ * operator is told what was observed. A dead process has no connection and therefore no
30
+ * subscription, so every real corpse is still removed; a hung manager can never be deregistered out
31
+ * from under itself by an operator who cannot see it.
32
+ *
33
+ * A PROBE THAT COULD NOT RUN IS NOT A DEAD INSTANCE either: a refused publish, an unreadable store,
34
+ * or any other failure of the probe itself refuses, because none of them establish anything about
35
+ * the instance.
36
+ *
37
+ * THIS IS NOT A ONE-WAY DOOR, which is what makes the guard a proportionate one rather than an
38
+ * absolute one. The §13.1 issuance gate is untouched: the same instance re-registers on its next
39
+ * start, over the tombstone, under the same identity. Deregistering a live-but-wedged instance costs
40
+ * it its rows until it restarts; leaving a dead one costs every operator in the space a full deadline
41
+ * on every command, permanently.
42
+ */
43
+ import { type EpCaller } from "@cotal-ai/core";
44
+ import type { KV } from "@nats-io/kv";
45
+ import type { NatsConnection } from "@nats-io/transport-node";
46
+ /** Which guard refused. Printed verbatim by the command and asserted on by the smoke, so one
47
+ * refusal can never be mistaken for another. */
48
+ export type InstanceDeregisterCondition =
49
+ /** The instance ANSWERED a pinned describe: it is alive and this is never run against a live one. */
50
+ "instance-answered"
51
+ /** It did not answer, and the broker did NOT affirm its rail empty, which is what a held
52
+ * subscription looks like: a hung or slow instance rather than a departed host, and the one
53
+ * observation this command may not act on. Nothing is removed. */
54
+ | "instance-not-affirmed-gone"
55
+ /** The probe itself failed (refused, unreadable, or any non-silence error) — nothing established. */
56
+ | "liveness-unestablishable"
57
+ /** No live spec key at the coordinate: never registered, or already deregistered. */
58
+ | "not-registered"
59
+ /** A key moved between the read and its revision-pinned delete: a live writer owns this record. */
60
+ | "superseded";
61
+ /** A refusal carrying its condition as DATA, not only as prose. */
62
+ export declare class InstanceDeregisterRefused extends Error {
63
+ readonly condition: InstanceDeregisterCondition;
64
+ constructor(condition: InstanceDeregisterCondition, message: string);
65
+ }
66
+ /** What the instance probe established. `gone` is the ONLY value that removes anything; `detail` is
67
+ * printed whichever it is, so the operator sees the evidence the decision rested on. */
68
+ export type InstanceProbe =
69
+ /** It answered a pinned describe. Alive. */
70
+ {
71
+ state: "answered";
72
+ detail: string;
73
+ }
74
+ /** It did not answer AND the broker reports nothing subscribed on its rail. Affirmatively absent. */
75
+ | {
76
+ state: "gone";
77
+ detail: string;
78
+ }
79
+ /** It did not answer, and the broker did not affirm the rail empty: quiet, not gone. */
80
+ | {
81
+ state: "unknown";
82
+ detail: string;
83
+ }
84
+ /** The probe itself could not run, so nothing at all was established about the instance. */
85
+ | {
86
+ state: "unestablishable";
87
+ detail: string;
88
+ };
89
+ /**
90
+ * THE GUARD'S PROBE, built once and used by both the command and its suite — a test that rebuilt
91
+ * this by hand would be grading a copy while the shipped one drifted.
92
+ *
93
+ * `nc` must carry a credential PINNED to this instance: both questions ride its own `inst` rails.
94
+ *
95
+ * TWO QUESTIONS, AND BOTH MUST AGREE for the one verdict that licenses a delete. The describe is
96
+ * the disqualifying one, because §13.7 makes every endpoint serve it, so an answer is proof of
97
+ * life. The broker's rail check is the AUTHORIZING one: `gone` means the broker found nothing
98
+ * subscribed on this instance's rail, which is the only affirmative evidence of absence anything
99
+ * here can obtain without the instance's cooperation.
100
+ *
101
+ * A DESCRIBE THAT WENT UNANSWERED IS NOT A VERDICT BY ITSELF. `unansweredRequest` is core's marker
102
+ * for "no responder, or the deadline elapsed with nothing attributed", and a wedged process
103
+ * produces it while still holding every subscription it registered. So an unanswered describe whose
104
+ * rail check comes back anything other than `gone` is `unknown` — quiet, not absent. Every other
105
+ * failure — a refused publish, an unreadable contract store, an error reply, a rail check that
106
+ * could not run — established nothing about the instance and must not read as death.
107
+ */
108
+ export declare function makeInstanceProbe(nc: NatsConnection, args: {
109
+ space: string;
110
+ endpoint: string;
111
+ instanceId: string;
112
+ caller: EpCaller;
113
+ describeDeadlineMs?: number;
114
+ interestDeadlineMs?: number;
115
+ }): () => Promise<InstanceProbe>;
116
+ /** What was removed. Returned on success and printed by the command. */
117
+ export interface InstanceDeregisterReport {
118
+ endpoint: string;
119
+ instanceId: string;
120
+ probe: InstanceProbe;
121
+ /** Present when the record had a status key; absent when only a spec existed. */
122
+ removedStatusRevision?: number;
123
+ removedSpecRevision: number;
124
+ }
125
+ /**
126
+ * Deregister ONE instance. Every seam is injected so the command wires the real ones and the smoke
127
+ * drives the real records KV against an ephemeral broker.
128
+ *
129
+ * `probeInstance` runs BEFORE the KV is touched, and that ordering is structural rather than
130
+ * conventional: nothing below is reachable until it has returned `gone`.
131
+ */
132
+ export declare function deregisterEndpointInstance(opts: {
133
+ kv: KV;
134
+ endpoint: string;
135
+ instanceId: string;
136
+ probeInstance: () => Promise<InstanceProbe>;
137
+ log: (line: string) => void;
138
+ }): Promise<InstanceDeregisterReport>;
139
+ //# sourceMappingURL=deregister-instance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deregister-instance.d.ts","sourceRoot":"","sources":["../src/deregister-instance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,OAAO,EAEL,KAAK,QAAQ,EACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE9D;iDACiD;AACjD,MAAM,MAAM,2BAA2B;AACrC,qGAAqG;AACnG,mBAAmB;AACrB;;mEAEmE;GACjE,4BAA4B;AAC9B,qGAAqG;GACnG,0BAA0B;AAC5B,qFAAqF;GACnF,gBAAgB;AAClB,mGAAmG;GACjG,YAAY,CAAC;AAEjB,mEAAmE;AACnE,qBAAa,yBAA0B,SAAQ,KAAK;IAEhD,QAAQ,CAAC,SAAS,EAAE,2BAA2B;gBAAtC,SAAS,EAAE,2BAA2B,EAC/C,OAAO,EAAE,MAAM;CAKlB;AAED;yFACyF;AACzF,MAAM,MAAM,aAAa;AACvB,4CAA4C;AAC1C;IAAE,KAAK,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE;AACvC,qGAAqG;GACnG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE;AACnC,wFAAwF;GACtF;IAAE,KAAK,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE;AACtC,4FAA4F;GAC1F;IAAE,KAAK,EAAE,iBAAiB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,cAAc,EAClB,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,QAAQ,CAAC;IAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAAC,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAAE,GACxI,MAAM,OAAO,CAAC,aAAa,CAAC,CA0B9B;AAED,wEAAwE;AACxE,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,aAAa,CAAC;IACrB,iFAAiF;IACjF,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;GAMG;AACH,wBAAsB,0BAA0B,CAAC,IAAI,EAAE;IACrD,EAAE,EAAE,EAAE,CAAC;IACP,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC,CAAC;IAC5C,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAqDpC"}
@@ -0,0 +1,142 @@
1
+ /**
2
+ * GUARDED DEREGISTRATION of a service instance whose host is gone (SPEC 13.5: a deleted `svc` spec
3
+ * IS the deregistration).
4
+ *
5
+ * THE STATE THIS REPAIRS. The service registry records REGISTRATION, not liveness, and no part of
6
+ * the model expires a row. An instance registers, its host dies without writing anything, and the
7
+ * record goes on claiming a live instance for as long as the bucket exists. Every class scatter in
8
+ * that space then freezes the dead slot in, and a gather that ends only when every slot has answered
9
+ * pays its whole deadline waiting for a machine that is never coming back — on every `cotal ps`,
10
+ * `stop` and `attach`, forever. A registration whose holder cooperates removes itself on a clean
11
+ * stop; this is the exit for the one that cannot, and it exists so that state can never be permanent
12
+ * on someone's laptop again.
13
+ *
14
+ * IT IS AN EXPLICIT VERB AND NEVER A SWEEP. Nothing here scans for candidates or acts on an age
15
+ * threshold: silence is not death, and a rule that deleted rows on silence would eventually delete a
16
+ * live instance that was merely slow. An operator names one instance, and the guard's job is to make
17
+ * sure they did not name a live one:
18
+ *
19
+ * 1. ASK THE INSTANCE. A pinned `describe` is the one question every endpoint must answer (§13.7),
20
+ * so an answer is proof of life and REFUSES, unconditionally.
21
+ * 2. REQUIRE THE BROKER'S AFFIRMATIVE ABSENCE. Only a no-responders verdict on the instance's own
22
+ * rail — nothing subscribed there — passes the guard. It is the same evidence `cotal ps` acts
23
+ * on, and it is the whole difference between "gone" and "quiet".
24
+ * 3. REFUSE LOUD, BY CONDITION. "Refused" without a reason sends an operator to the wrong repair.
25
+ *
26
+ * SILENCE IS NOT THE EVIDENCE. An unanswered describe is what a dead host, a wedged process and a
27
+ * slow one all look like, and a process that is merely hung still HOLDS its subscriptions — so the
28
+ * broker sees interest on its rail and cannot affirm it empty. That instance is refused, and the
29
+ * operator is told what was observed. A dead process has no connection and therefore no
30
+ * subscription, so every real corpse is still removed; a hung manager can never be deregistered out
31
+ * from under itself by an operator who cannot see it.
32
+ *
33
+ * A PROBE THAT COULD NOT RUN IS NOT A DEAD INSTANCE either: a refused publish, an unreadable store,
34
+ * or any other failure of the probe itself refuses, because none of them establish anything about
35
+ * the instance.
36
+ *
37
+ * THIS IS NOT A ONE-WAY DOOR, which is what makes the guard a proportionate one rather than an
38
+ * absolute one. The §13.1 issuance gate is untouched: the same instance re-registers on its next
39
+ * start, over the tombstone, under the same identity. Deregistering a live-but-wedged instance costs
40
+ * it its rows until it restarts; leaving a dead one costs every operator in the space a full deadline
41
+ * on every command, permanently.
42
+ */
43
+ import { deregisterServiceInstance, describeEndpoint, epProbeInstanceInterest, unansweredRequest, } from "@cotal-ai/core";
44
+ /** A refusal carrying its condition as DATA, not only as prose. */
45
+ export class InstanceDeregisterRefused extends Error {
46
+ condition;
47
+ constructor(condition, message) {
48
+ super(message);
49
+ this.condition = condition;
50
+ this.name = "InstanceDeregisterRefused";
51
+ }
52
+ }
53
+ /**
54
+ * THE GUARD'S PROBE, built once and used by both the command and its suite — a test that rebuilt
55
+ * this by hand would be grading a copy while the shipped one drifted.
56
+ *
57
+ * `nc` must carry a credential PINNED to this instance: both questions ride its own `inst` rails.
58
+ *
59
+ * TWO QUESTIONS, AND BOTH MUST AGREE for the one verdict that licenses a delete. The describe is
60
+ * the disqualifying one, because §13.7 makes every endpoint serve it, so an answer is proof of
61
+ * life. The broker's rail check is the AUTHORIZING one: `gone` means the broker found nothing
62
+ * subscribed on this instance's rail, which is the only affirmative evidence of absence anything
63
+ * here can obtain without the instance's cooperation.
64
+ *
65
+ * A DESCRIBE THAT WENT UNANSWERED IS NOT A VERDICT BY ITSELF. `unansweredRequest` is core's marker
66
+ * for "no responder, or the deadline elapsed with nothing attributed", and a wedged process
67
+ * produces it while still holding every subscription it registered. So an unanswered describe whose
68
+ * rail check comes back anything other than `gone` is `unknown` — quiet, not absent. Every other
69
+ * failure — a refused publish, an unreadable contract store, an error reply, a rail check that
70
+ * could not run — established nothing about the instance and must not read as death.
71
+ */
72
+ export function makeInstanceProbe(nc, args) {
73
+ const describeMs = args.describeDeadlineMs ?? 5_000;
74
+ const interestMs = args.interestDeadlineMs ?? 2_000;
75
+ return async () => {
76
+ try {
77
+ const { responder } = await describeEndpoint(nc, args.space, args.endpoint, args.caller, { deadlineMs: describeMs, instanceId: args.instanceId });
78
+ return { state: "answered", detail: `it answered a pinned describe at epoch ${responder.epoch}` };
79
+ }
80
+ catch (e) {
81
+ if (!unansweredRequest(e))
82
+ return { state: "unestablishable", detail: `the probe itself failed: ${e.message}` };
83
+ const silence = `no answer to a pinned describe within ${describeMs}ms`;
84
+ let interest;
85
+ try {
86
+ interest = await epProbeInstanceInterest(nc, args.space, args.endpoint, args.instanceId, args.caller, { deadlineMs: interestMs });
87
+ }
88
+ catch (err) {
89
+ // The rail check is what turns silence into a verdict, so a rail check that could not RUN
90
+ // leaves the silence meaning exactly what it meant before it: nothing.
91
+ return { state: "unestablishable", detail: `${silence}, and the broker's rail check could not run: ${err.message}` };
92
+ }
93
+ return interest === "gone"
94
+ ? { state: "gone", detail: `${silence}, and the broker reports nothing subscribed on its rail` }
95
+ : {
96
+ state: "unknown",
97
+ detail: `${silence}, and the broker did NOT report its rail empty within ${interestMs}ms - a subscription is exactly what withholds that no-responders answer, so this instance is quiet rather than absent`,
98
+ };
99
+ }
100
+ };
101
+ }
102
+ /**
103
+ * Deregister ONE instance. Every seam is injected so the command wires the real ones and the smoke
104
+ * drives the real records KV against an ephemeral broker.
105
+ *
106
+ * `probeInstance` runs BEFORE the KV is touched, and that ordering is structural rather than
107
+ * conventional: nothing below is reachable until it has returned `gone`.
108
+ */
109
+ export async function deregisterEndpointInstance(opts) {
110
+ const { kv, endpoint, instanceId, log } = opts;
111
+ // ---- 1. THE GUARD. Read-only, and nothing is mutated until it passes.
112
+ //
113
+ // IT IS AN ALLOW-LIST, and the last check below is what makes that structural. The three refusals
114
+ // that follow exist to name the CONDITION an operator hit, not to be the fence: a chain of
115
+ // denials passes anything it does not recognise, so a probe that grew a fourth state, or a caller
116
+ // that hands this a state from outside the closed set, would fall through to the delete. `gone`
117
+ // is the only verdict this command may act on, so `gone` is what it tests for.
118
+ const probe = await opts.probeInstance();
119
+ const state = probe.state;
120
+ log(`instance ${endpoint}/${instanceId}: ${state} - ${probe.detail}`);
121
+ if (probe.state === "answered")
122
+ throw new InstanceDeregisterRefused("instance-answered", `${endpoint}/${instanceId} ANSWERED (${probe.detail}) - it is alive, and a live instance is never deregistered. If it is wedged rather than gone, stop the process first; its record is then removed by its own clean stop, or by re-running this once it is down.`);
123
+ if (probe.state === "unknown")
124
+ throw new InstanceDeregisterRefused("instance-not-affirmed-gone", `${endpoint}/${instanceId} did not answer, but the broker did not affirm that its rail is empty (${probe.detail}) - a process that is hung still holds its subscriptions, so this is slow or hung, not gone, and NOTHING WAS REMOVED. A registration is removed only on the broker reporting nothing subscribed on the instance's own rail. If the process is wedged, stop it: its record goes on its own clean stop, or by re-running this once it is down.`);
125
+ if (probe.state === "unestablishable")
126
+ throw new InstanceDeregisterRefused("liveness-unestablishable", `the liveness of ${endpoint}/${instanceId} could not be established (${probe.detail}) - the probe failed rather than went unanswered, so nothing was learned about the instance. Refusing: this removes a record only on the broker affirming its rail empty.`);
127
+ if (state !== "gone")
128
+ throw new InstanceDeregisterRefused("liveness-unestablishable", `the probe for ${endpoint}/${instanceId} returned "${state}", which is not a verdict this command acts on (${probe.detail}). Only a broker-affirmed \`gone\` removes a registration, so nothing was removed.`);
129
+ // ---- 2. The §13.5 delete, revision-pinned inside (status first, then spec).
130
+ const outcome = await deregisterServiceInstance(kv, { endpoint, instanceId });
131
+ if (!outcome.removed && outcome.reason === "absent")
132
+ throw new InstanceDeregisterRefused("not-registered", `${endpoint}/${instanceId} has no registration to remove - it never registered, or it was already deregistered. Check the instance id: \`cotal ps\` prints the whole id, and this takes nothing shorter.`);
133
+ if (!outcome.removed)
134
+ throw new InstanceDeregisterRefused("superseded", `the registration for ${endpoint}/${instanceId} MOVED while this ran, so the record inspected is not the record now stored - something is writing to it. Nothing was removed. Re-observe before retrying.`);
135
+ log(`✓ removed the ${endpoint} registration for ${instanceId} (spec revision ${outcome.specRevision}${outcome.statusRevision !== undefined ? `, status revision ${outcome.statusRevision}` : ", no status key"})`);
136
+ return {
137
+ endpoint, instanceId, probe,
138
+ removedSpecRevision: outcome.specRevision,
139
+ ...(outcome.statusRevision !== undefined ? { removedStatusRevision: outcome.statusRevision } : {}),
140
+ };
141
+ }
142
+ //# sourceMappingURL=deregister-instance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file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AC,CAAC;IACnN,OAAO;QACL,QAAQ,EAAE,UAAU,EAAE,KAAK;QAC3B,mBAAmB,EAAE,OAAO,CAAC,YAAY;QACzC,GAAG,CAAC,OAAO,CAAC,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,qBAAqB,EAAE,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACnG,CAAC;AACJ,CAAC"}
@@ -27,7 +27,7 @@
27
27
  * Capability labels (describe/grant vocabulary, one per tier class):
28
28
  * manager.read status / ps / inspect / models (read-only)
29
29
  * manager.spawn spawn (privileged-grade creation)
30
- * manager.lifecycle despawn / attach (owner-mode terminal/interactive)
30
+ * manager.lifecycle despawn / attach / input (owner-mode terminal/interactive)
31
31
  * manager.self stop (self-mode halt; baseline)
32
32
  * manager.persona definePersona (privileged-grade; ownership-checked)
33
33
  * manager.admin purge / launch / resume family (operator instruments only)
@@ -70,8 +70,15 @@ export declare const MANAGER_STATUS_CONTRACT: {
70
70
  * merged in ahead of the schema, so the compiled contract refused every request that carried the
71
71
  * field and the feature was unreachable through this door (executed: the compiled input validator
72
72
  * returned false for `{runId, name, spec}` while the CLI sends exactly that). ONE revision 6
73
- * covers the whole branch: when the journal-action work lands, its `action` marker and
74
- * `readinessDeadlineMs` declaration join THIS revision rather than minting a seventh. */
73
+ * covered that whole branch: when the journal-action work lands, its `action` marker and
74
+ * `readinessDeadlineMs` declaration join revision 6 rather than minting one of their own.
75
+ *
76
+ * 7 = the `input` command (C3): typing into a running seat's terminal without holding a session.
77
+ * A NEW SERVED COMMAND is what a revision is for, and it cannot fold into 6: a caller's
78
+ * `describe` reads this document to learn what the responder serves, so a surface that grew
79
+ * while the number stood still would leave a cached descriptor naming a command set that is no
80
+ * longer the served one. (Revision 6's reservation is for fields on commands it ALREADY
81
+ * declares, which is the opposite case.) */
75
82
  export declare function managerClusterDocument(): {
76
83
  urn: string;
77
84
  revision: number;
@@ -115,6 +122,7 @@ export interface ManagerServiceHandlers {
115
122
  spawn(ctx: EpServeContext): unknown | Promise<unknown>;
116
123
  despawn(ctx: EpServeContext): unknown | Promise<unknown>;
117
124
  attach(ctx: EpServeContext): unknown | Promise<unknown>;
125
+ input(ctx: EpServeContext): unknown | Promise<unknown>;
118
126
  stopSelf(ctx: EpServeContext): unknown | Promise<unknown>;
119
127
  definePersona(ctx: EpServeContext): unknown | Promise<unknown>;
120
128
  purge(ctx: EpServeContext): unknown | Promise<unknown>;