@cotal-ai/cli 0.16.0 → 0.17.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 (104) hide show
  1. package/dist/command.d.ts.map +1 -1
  2. package/dist/command.js +13 -0
  3. package/dist/command.js.map +1 -1
  4. package/dist/commands/agents.d.ts +5 -15
  5. package/dist/commands/agents.d.ts.map +1 -1
  6. package/dist/commands/agents.js +133 -72
  7. package/dist/commands/agents.js.map +1 -1
  8. package/dist/commands/clean.d.ts.map +1 -1
  9. package/dist/commands/clean.js +4 -3
  10. package/dist/commands/clean.js.map +1 -1
  11. package/dist/commands/describe.d.ts +72 -0
  12. package/dist/commands/describe.d.ts.map +1 -0
  13. package/dist/commands/describe.js +148 -0
  14. package/dist/commands/describe.js.map +1 -0
  15. package/dist/commands/doctor.d.ts.map +1 -1
  16. package/dist/commands/doctor.js +27 -8
  17. package/dist/commands/doctor.js.map +1 -1
  18. package/dist/commands/down-manifest.d.ts.map +1 -1
  19. package/dist/commands/down-manifest.js +38 -18
  20. package/dist/commands/down-manifest.js.map +1 -1
  21. package/dist/commands/down.d.ts +9 -0
  22. package/dist/commands/down.d.ts.map +1 -1
  23. package/dist/commands/down.js +38 -10
  24. package/dist/commands/down.js.map +1 -1
  25. package/dist/commands/ext.d.ts.map +1 -1
  26. package/dist/commands/ext.js +16 -10
  27. package/dist/commands/ext.js.map +1 -1
  28. package/dist/commands/join.d.ts.map +1 -1
  29. package/dist/commands/join.js +2 -4
  30. package/dist/commands/join.js.map +1 -1
  31. package/dist/commands/meshes-add.d.ts.map +1 -1
  32. package/dist/commands/meshes-add.js +23 -0
  33. package/dist/commands/meshes-add.js.map +1 -1
  34. package/dist/commands/models.d.ts.map +1 -1
  35. package/dist/commands/models.js +2 -2
  36. package/dist/commands/models.js.map +1 -1
  37. package/dist/commands/spawn-manifest.d.ts.map +1 -1
  38. package/dist/commands/spawn-manifest.js +22 -12
  39. package/dist/commands/spawn-manifest.js.map +1 -1
  40. package/dist/commands/spawn.d.ts +5 -0
  41. package/dist/commands/spawn.d.ts.map +1 -1
  42. package/dist/commands/spawn.js +4 -2
  43. package/dist/commands/spawn.js.map +1 -1
  44. package/dist/commands/status.js +25 -5
  45. package/dist/commands/status.js.map +1 -1
  46. package/dist/commands/up.d.ts +17 -2
  47. package/dist/commands/up.d.ts.map +1 -1
  48. package/dist/commands/up.js +640 -49
  49. package/dist/commands/up.js.map +1 -1
  50. package/dist/console/app.d.ts +1 -1
  51. package/dist/console/app.d.ts.map +1 -1
  52. package/dist/console/app.js +16 -5
  53. package/dist/console/app.js.map +1 -1
  54. package/dist/console/commands.d.ts.map +1 -1
  55. package/dist/console/commands.js +5 -5
  56. package/dist/console/commands.js.map +1 -1
  57. package/dist/console/root.d.ts.map +1 -1
  58. package/dist/console/root.js +6 -1
  59. package/dist/console/root.js.map +1 -1
  60. package/dist/index.d.ts.map +1 -1
  61. package/dist/index.js +23 -0
  62. package/dist/index.js.map +1 -1
  63. package/dist/lib/attach-client.d.ts +37 -4
  64. package/dist/lib/attach-client.d.ts.map +1 -1
  65. package/dist/lib/attach-client.js +88 -18
  66. package/dist/lib/attach-client.js.map +1 -1
  67. package/dist/lib/auth-proc.d.ts +3 -1
  68. package/dist/lib/auth-proc.d.ts.map +1 -1
  69. package/dist/lib/auth-proc.js +15 -4
  70. package/dist/lib/auth-proc.js.map +1 -1
  71. package/dist/lib/connect.d.ts +1 -1
  72. package/dist/lib/connect.d.ts.map +1 -1
  73. package/dist/lib/connect.js +1 -1
  74. package/dist/lib/connect.js.map +1 -1
  75. package/dist/lib/control.d.ts +42 -11
  76. package/dist/lib/control.d.ts.map +1 -1
  77. package/dist/lib/control.js +251 -44
  78. package/dist/lib/control.js.map +1 -1
  79. package/dist/lib/delivery-proc.d.ts +19 -4
  80. package/dist/lib/delivery-proc.d.ts.map +1 -1
  81. package/dist/lib/delivery-proc.js +129 -43
  82. package/dist/lib/delivery-proc.js.map +1 -1
  83. package/dist/lib/manager-proc.d.ts +48 -5
  84. package/dist/lib/manager-proc.d.ts.map +1 -1
  85. package/dist/lib/manager-proc.js +131 -30
  86. package/dist/lib/manager-proc.js.map +1 -1
  87. package/dist/lib/manifest/ledger.d.ts +52 -8
  88. package/dist/lib/manifest/ledger.d.ts.map +1 -1
  89. package/dist/lib/manifest/ledger.js +77 -19
  90. package/dist/lib/manifest/ledger.js.map +1 -1
  91. package/dist/lib/manifest/live.d.ts +21 -16
  92. package/dist/lib/manifest/live.d.ts.map +1 -1
  93. package/dist/lib/manifest/live.js +33 -20
  94. package/dist/lib/manifest/live.js.map +1 -1
  95. package/dist/lib/restore.d.ts.map +1 -1
  96. package/dist/lib/restore.js +21 -3
  97. package/dist/lib/restore.js.map +1 -1
  98. package/dist/view/mesh-view.js +2 -2
  99. package/dist/view/mesh-view.js.map +1 -1
  100. package/package.json +4 -3
  101. package/dist/lib/pid.d.ts +0 -23
  102. package/dist/lib/pid.d.ts.map +0 -1
  103. package/dist/lib/pid.js +0 -39
  104. package/dist/lib/pid.js.map +0 -1
@@ -1,50 +1,77 @@
1
1
  import { spawn } from "node:child_process";
2
2
  import { existsSync, openSync, closeSync, writeFileSync, readFileSync, rmSync } from "node:fs";
3
3
  import { DEFAULT_SERVER, mintCreds, newIdentity, waitForDeliveryLease, } from "@cotal-ai/core";
4
- import { DELIVERY_CREDS_KEY, authDir, findCotalRoot, getSoleSpaceAuth, listSpaceAccounts, workspaceSecretStore } from "@cotal-ai/workspace";
4
+ import { DELIVERY_CREDS_KEY, authDir, findCotalRoot, getSoleSpaceAuth, listSpaceAccounts, parsePid, probeLiveness, workspaceSecretStore } from "@cotal-ai/workspace";
5
5
  import { selfArgv } from "./self-exec.js";
6
6
  import { resolveSpace } from "./status.js";
7
7
  import { cotalPath } from "./paths.js";
8
- import { ensureManager, managerHasDeliveryMarker, managerUp, stopManager } from "./manager-proc.js";
8
+ import { MANAGER_PID_PATH, ensureManager, managerHasDeliveryMarker, managerLiveness, stopManager } from "./manager-proc.js";
9
9
  const PID_PATH = () => cotalPath("delivery.pid");
10
10
  // The daemon's cred goes through the secret-store seam; the shared key (== the filename, so the
11
11
  // file stays `.cotal/delivery.creds`) comes from workspace — never a hand-copied literal.
12
12
  const credsStore = () => workspaceSecretStore(findCotalRoot());
13
- function alive(pid) {
14
- try {
15
- process.kill(pid, 0);
16
- return true;
17
- }
18
- catch {
19
- return false;
20
- }
21
- }
22
- /** True if the delivery daemon we started for this folder is still running (pid file + liveness). */
23
- export function deliveryUp() {
13
+ /** The recorded daemon's liveness, THREE-VALUED plus absent. See {@link managerLiveness} for why the
14
+ * boolean collapse is the defect: `unknown` is reachable on a real kernel (a seccomp
15
+ * `SECCOMP_RET_ERRNO` filter or an LSM policy answers `kill(pid, 0)` with an arbitrary errno and
16
+ * libuv preserves it), and both ways of folding it into a boolean fail silently. */
17
+ export function deliveryLiveness(probe = probeLiveness) {
24
18
  const p = PID_PATH();
25
19
  if (!existsSync(p))
26
- return false;
27
- const pid = Number(readFileSync(p, "utf8").trim());
28
- return Number.isFinite(pid) && alive(pid);
20
+ return "absent";
21
+ const raw = readFileSync(p, "utf8").trim();
22
+ if (raw === "")
23
+ return "absent";
24
+ const pid = parsePid(raw);
25
+ if (pid === undefined)
26
+ return "unattributable"; // see managerLiveness: never fold this into absent
27
+ return probe(pid);
28
+ }
29
+ /** True only if the daemon is PROVABLY running. Callers that ACT on the answer take
30
+ * {@link deliveryLiveness} instead; this cannot express "cannot tell". */
31
+ export function deliveryUp() {
32
+ return deliveryLiveness() === "alive";
29
33
  }
30
34
  /** True when this folder runs an authed mesh — the only mode with a delivery daemon (Plane-3 needs the
31
35
  * trusted reader; open dev mode is live-only). */
32
36
  function hasAuth() {
33
37
  return listSpaceAccounts(authDir(findCotalRoot())).length > 0;
34
38
  }
35
- /** True if an OLD (pre-delivery-daemon) Plane-3-hosting manager is live: a `manager.pid` that is alive
36
- * but carries no delivery-aware marker. Such a manager still calls `startPlane3` and would double-bind
37
- * `fanout`/`reader` against the new daemon. */
38
- function oldHostingManagerLive() {
39
- return managerUp() && !managerHasDeliveryMarker();
39
+ /** The cutover preflight's verdict, THREE-VALUED, because the boolean it replaced was read before the
40
+ * refusal boundary and therefore defeated it.
41
+ *
42
+ * `managerUp()` folds `unknown` to false, so an unattributable manager with no marker (which IS the
43
+ * old Plane-3-hosting shape) read as "no old manager", the preflight skipped, and `ensureDelivery`
44
+ * went on to mint a credential, write a pidfile and start a second daemon. Only afterwards did
45
+ * `ensureManager` throw. Everything the refusal was supposed to prevent had already happened, and
46
+ * the daemon's own lease cannot help: it is a delivery-daemon-only mechanism and can neither prove
47
+ * nor exclude an old manager still hosting Plane 3.
48
+ *
49
+ * A guard that runs after the work is not a guard, so this one reads the tri-state directly and the
50
+ * caller refuses BEFORE anything is minted, written or started. */
51
+ function oldHostingManagerVerdict(probe = probeLiveness) {
52
+ const state = managerLiveness(probe);
53
+ if (state === "unknown" || state === "unattributable")
54
+ return "indeterminate";
55
+ if (state !== "alive")
56
+ return "proceed"; // dead or absent: nothing is hosting Plane 3
57
+ return managerHasDeliveryMarker() ? "proceed" : "stop-it"; // alive: the marker decides
40
58
  }
41
59
  /** Cutover preflight — the FIRST action, BEFORE the daemon can bind: stop any old Plane-3-hosting
42
60
  * manager (live `manager.pid` without the delivery-aware marker) so it never double-binds the
43
61
  * daemon's durables. A delivery-aware (this-build) manager is left running. No-op on a fresh install. */
44
- export function stopOldHostingManagerIfPresent() {
45
- if (oldHostingManagerLive()) {
62
+ export async function stopOldHostingManagerIfPresent(probe = probeLiveness, signal) {
63
+ const verdict = oldHostingManagerVerdict(probe);
64
+ // FIRST action, before any mint/write/start, so the refusal actually fences the daemon.
65
+ if (verdict === "indeterminate")
66
+ throw new Error(`the recorded manager pid (${readFileSync(MANAGER_PID_PATH(), "utf8").trim()}) cannot be attributed, so the delivery cutover preflight cannot run: the kernel answered neither "running" nor "no such process" (a seccomp filter or LSM policy does this inside some sandboxes).\n` +
67
+ `Refusing before the daemon starts. If that manager is an old Plane-3-hosting one it is still bound to fanout/reader, and starting the daemon anyway would double-bind them; the daemon's own lease cannot detect that.\n` +
68
+ `NEXT: verify the process yourself (\`ps -p <pid>\`). If it is gone, remove \`.cotal/manager.pid\` and re-run. If it is running, stop it with \`cotal down\` first.`);
69
+ if (verdict === "stop-it") {
46
70
  console.error("• stopping an old Plane-3-hosting manager before starting the delivery daemon (cutover preflight)");
47
- stopManager();
71
+ // stopManager THROWS rather than reporting a stop it did not achieve (EPERM, or a process that
72
+ // outlived SIGTERM), so reaching the next line is the proof the old manager is gone. Letting that
73
+ // throw propagate is the point: the daemon must not start beside a manager still bound to Plane 3.
74
+ await stopManager(probe, signal);
48
75
  }
49
76
  }
50
77
  /** Start the delivery daemon detached (pid in `.cotal/delivery.pid`, output to `.cotal/delivery.log`),
@@ -60,6 +87,15 @@ export function startDeliveryDetached(o = {}) {
60
87
  o.space ?? resolveSpace(process.cwd()),
61
88
  "--server",
62
89
  o.server ?? DEFAULT_SERVER,
90
+ // Propagate the broker's transport decision. The daemon cannot derive it: it learns everything
91
+ // from argv by design - it is a pre-minted scoped-cred client, injectable behind a SecretStore,
92
+ // and making it read the machine-local mesh registry to pick a transport would couple a
93
+ // hosted-composable daemon to a workstation artifact. So the launcher, which DOES know, tells it.
94
+ //
95
+ // Without this the daemon connects plaintext-capable to a TLS broker and nothing looks wrong,
96
+ // because it still upgrades on the server's INFO. It holds a STANDING credential and reconnects
97
+ // unattended, so that exposure would repeat on every reconnect with nobody watching.
98
+ ...(o.tls ? ["--tls"] : []),
63
99
  ];
64
100
  // Internal child re-exec (the `up` that reached here already seeded); the delivery daemon does not
65
101
  // launch agents, so it skips the connector seed on boot (a direct `cotal deliver` still seeds).
@@ -74,10 +110,10 @@ export function startDeliveryDetached(o = {}) {
74
110
  * never double-binds. Mints a SCOPED `delivery` cred from the local signer ONCE, writes it to
75
111
  * `.cotal/delivery.creds` (0600), and launches the daemon WITHOUT signer access. Best-effort — callers
76
112
  * treat it as non-fatal (a missing daemon degrades durable delivery, never live). */
77
- export async function ensureDelivery(o = {}) {
113
+ export async function ensureDelivery(o = {}, probe = probeLiveness) {
78
114
  if (!hasAuth())
79
115
  return { running: false }; // open dev mode — no daemon, agents are live-only
80
- if (oldHostingManagerLive()) {
116
+ if (oldHostingManagerVerdict(probe) === "stop-it") {
81
117
  console.error("✗ delivery: an old Plane-3-hosting manager is still live (no delivery-aware marker). Refusing to start the daemon - run `cotal down` first, then retry.");
82
118
  return { running: false };
83
119
  }
@@ -90,7 +126,15 @@ export async function ensureDelivery(o = {}) {
90
126
  const creds = await mintCreds(auth, id, "delivery");
91
127
  const space = o.space ?? resolveSpace(process.cwd());
92
128
  const server = o.server ?? DEFAULT_SERVER;
93
- if (!deliveryUp()) {
129
+ const deliveryState = deliveryLiveness(probe);
130
+ // Same refusal as the manager: an unattributable pid must not be silently reused (a daemon
131
+ // reported running that is not there) nor silently replaced (two daemons on one fanout).
132
+ if (deliveryState === "unknown" || deliveryState === "unattributable")
133
+ throw new Error(`the recorded delivery daemon pid (${readFileSync(PID_PATH(), "utf8").trim()}) cannot be attributed: the kernel answered neither "running" nor "no such process".\n` +
134
+ `A seccomp filter or LSM policy that intercepts \`kill(pid, 0)\` does this, so it is expected inside some sandboxes and containers.\n` +
135
+ `Cotal will not guess: reusing it would report a daemon that is not there, and starting a second would put two daemons on one fanout.\n` +
136
+ `NEXT: verify the process yourself (\`ps -p <pid>\`). If it is gone, remove \`.cotal/delivery.pid\` and re-run. If it is running, use it or stop it.`);
137
+ if (deliveryState !== "alive") {
94
138
  // The store's put hardens `.cotal/` first (the cred is born under a private ACL, no race) and
95
139
  // lands it atomically — same path and bytes as before the seam.
96
140
  await credsStore().put(DELIVERY_CREDS_KEY, creds);
@@ -109,25 +153,67 @@ export async function ensureDelivery(o = {}) {
109
153
  * kill runs even if the creds delete fails (finally) — a delete error must never leave the daemon
110
154
  * alive to outlive the teardown and reattach to a restarted broker; the error still propagates
111
155
  * after the kill so the caller can surface it. */
112
- export async function stopDelivery() {
113
- try {
156
+ export async function stopDelivery(probe = probeLiveness, signal) {
157
+ const send = signal ?? ((pid, sig) => process.kill(pid, sig));
158
+ const p = PID_PATH();
159
+ // ORDER MATTERS, AND IT USED TO BE BACKWARDS. The credential was deleted FIRST, in a try whose
160
+ // finally then signalled and removed the pidfile unconditionally. Under a refused signal that left
161
+ // a LIVE daemon with no pidfile and no standing credential: still connected, still serving, and its
162
+ // reconnect and renewal source deleted out from under it, while the function returned success.
163
+ // Nothing is removed now until the process is proven gone.
164
+ // Once death is PROVEN, both records are stale and the pidfile goes first: a creds-delete failure
165
+ // (a blocked path, a store error) must still propagate loudly, but it must not leave behind a
166
+ // pidfile for a process that is definitely gone. delivery-teardown.smoke.ts pins exactly that
167
+ // combination, and caught this when the first version of this fix ordered them the other way.
168
+ const removeRecords = async () => {
169
+ rmSync(p, { force: true });
114
170
  await credsStore().delete(DELIVERY_CREDS_KEY);
171
+ };
172
+ if (!existsSync(p)) {
173
+ await credsStore().delete(DELIVERY_CREDS_KEY); // no pid recorded: no live daemon to strand
174
+ return;
175
+ }
176
+ const raw = readFileSync(p, "utf8").trim();
177
+ const pid = parsePid(raw);
178
+ if (pid === undefined) {
179
+ if (raw === "") {
180
+ await removeRecords(); // pre-protocol husk, nothing behind it
181
+ return;
182
+ }
183
+ // See the manager helper: unattributable content may front a live daemon, and clearing it here
184
+ // would also delete the standing credential of a process still using it.
185
+ throw new Error(`the delivery pidfile at ${p} is unattributable (${JSON.stringify(raw)}): it may still front a running daemon nobody can identify.\n` +
186
+ `Refusing to remove it or its standing credential, and refusing to report a clean stop.\n` +
187
+ `NEXT: find and stop that process, then remove the file by hand.`);
188
+ }
189
+ const before = probe(pid);
190
+ if (before === "dead") {
191
+ await removeRecords();
192
+ return;
193
+ }
194
+ if (before === "unknown")
195
+ throw new Error(`refusing to stop the delivery daemon (pid ${pid}): its liveness cannot be determined (a seccomp filter or LSM policy answers kill(pid,0) with an arbitrary errno).\n` +
196
+ `The pidfile and standing credential are LEFT IN PLACE: removing them would strand a daemon that may still be connected, with its renewal source gone.\n` +
197
+ `NEXT: verify with \`ps -p ${pid}\`, then stop it yourself or remove \`.cotal/delivery.pid\` if it is gone.`);
198
+ try {
199
+ send(pid, "SIGTERM");
115
200
  }
116
- finally {
117
- const p = PID_PATH();
118
- if (existsSync(p)) {
119
- const pid = Number(readFileSync(p, "utf8").trim());
120
- if (Number.isFinite(pid)) {
121
- try {
122
- process.kill(pid, "SIGTERM");
123
- }
124
- catch {
125
- /* already gone */
126
- }
127
- }
128
- rmSync(p);
201
+ catch (e) {
202
+ const code = e.code;
203
+ if (code === "ESRCH") {
204
+ await removeRecords(); // raced to exit between probe and signal
205
+ return;
129
206
  }
207
+ throw new Error(`refusing to stop the delivery daemon (pid ${pid}): the signal was rejected (${code ?? "unknown error"}).\n` +
208
+ `EPERM means it belongs to another user, so it is running and not ours to stop. The pidfile and standing credential are LEFT IN PLACE.\n` +
209
+ `NEXT: stop it as its owner, or remove \`.cotal/delivery.pid\` if you are certain it is gone.`);
130
210
  }
211
+ const deadline = Date.now() + 15_000;
212
+ while (probe(pid) !== "dead" && Date.now() < deadline)
213
+ await new Promise((r) => setTimeout(r, 100));
214
+ if (probe(pid) !== "dead")
215
+ throw new Error(`the delivery daemon (pid ${pid}) accepted SIGTERM but its death could not be confirmed; its pidfile and credential were preserved rather than recording a stop that did not happen.`);
216
+ await removeRecords();
131
217
  }
132
218
  /** Bring up the control plane in the correct cutover order: OLD-manager preflight → delivery daemon
133
219
  * (auth only, fails closed on a live old manager) → manager (lifecycle, writes the delivery-aware
@@ -135,7 +221,7 @@ export async function stopDelivery() {
135
221
  * first only to close the old-manager double-bind window and so freshly-spawned agents find the
136
222
  * `ctl.delivery` responder for their boot self-join (a miss honest-degrades to live-only). */
137
223
  export async function ensureControlPlane(o = {}) {
138
- stopOldHostingManagerIfPresent();
224
+ await stopOldHostingManagerIfPresent();
139
225
  await ensureDelivery(o);
140
226
  return ensureManager(o);
141
227
  }
@@ -1 +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AO,KAAK,CAAC,GAAG,CAAC,KAAK,MAAM,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ;QAAE,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;IACpG,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,MAAM;QACvB,MAAM,IAAI,KAAK,CACb,4BAA4B,GAAG,sJAAsJ,CACtL,CAAC;IACJ,MAAM,aAAa,EAAE,CAAC;AACxB,CAAC;AAED;;;;+FAI+F;AAC/F,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,IAAU,EAAE;IACnD,MAAM,8BAA8B,EAAE,CAAC;IACvC,MAAM,cAAc,CAAC,CAAC,CAAC,CAAC;IACxB,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC;AAC1B,CAAC"}
@@ -1,4 +1,19 @@
1
- /** True if the manager we started for this folder is still running (pid file + liveness). */
1
+ import { type LivenessProbe } from "@cotal-ai/workspace";
2
+ /** Exported so the delivery cutover preflight can NAME the pid it refused on: an error that says
3
+ * "cannot be attributed" without saying which pid is not actionable. */
4
+ export declare const MANAGER_PID_PATH: () => string;
5
+ /** The recorded manager's liveness, THREE-VALUED plus absent, because collapsing it to a boolean is
6
+ * what made this dangerous. Both collapses are silent and both are wrong:
7
+ * `!== "dead"` -> an `unknown` reports UP forever; no retry clears it and nothing starts.
8
+ * `=== "alive"` -> an `unknown` reports DOWN and a second manager launches onto a possibly-live one.
9
+ * `unknown` is REACHABLE on a real kernel, not just under a test shim: a Linux seccomp filter
10
+ * (`SECCOMP_RET_ERRNO`) or an LSM policy can return an arbitrary errno for `kill(pid, 0)` without
11
+ * executing it at all, and libuv preserves it. Proven with a live seccomp BPF filter, not by
12
+ * interposition. So the caller has to SEE the third state and refuse. */
13
+ export declare function managerLiveness(probe?: LivenessProbe): "alive" | "dead" | "unknown" | "absent" | "unattributable";
14
+ /** True only if the manager is PROVABLY running. `unknown` is not up, and callers that would ACT on
15
+ * that answer must use {@link managerLiveness} instead: this boolean cannot express the difference
16
+ * between "not running" and "cannot tell", and acting on the difference is the whole point. */
2
17
  export declare function managerUp(): boolean;
3
18
  /** True if the live manager carries a delivery-aware marker BOUND to its current pid (i.e. it's THIS
4
19
  * build, non-hosting). Fail-closed: the marker stores the pid it was written for, and this requires it
@@ -20,11 +35,20 @@ export declare function startManagerDetached(o?: {
20
35
  attachHost?: string;
21
36
  resumeAttempt?: string;
22
37
  resumeCommitToken?: string;
38
+ wsPort?: number;
23
39
  }): number;
24
40
  /** Make the control plane available: reuse a manager already running for this folder, else start
25
41
  * one detached. Best-effort — callers treat it as non-fatal. A caller that needs THE manager to
26
42
  * carry a runtime/launch spec (`up -f`) must stop any leftover manager first — a reused one is
27
43
  * taken as-is. */
44
+ /** Refuse to stand a manager up OVER a record we cannot read or attribute.
45
+ *
46
+ * Exported because `ensureManager` is not the only path that starts one: `cotal spawn -f` calls
47
+ * `startManagerDetached` directly after its own lease checks, and so skipped this entirely. A lease
48
+ * says nobody is ANSWERING; it does not say the recorded pid is dead. Overwriting an unknown or
49
+ * unattributable record is the same defect as deleting it, reached through a different verb, which
50
+ * is the third time that shape has appeared in this change. Any future starter calls this first. */
51
+ export declare function assertManagerRecordReplaceable(probe?: LivenessProbe): void;
28
52
  export declare function ensureManager(o?: {
29
53
  space?: string;
30
54
  server?: string;
@@ -34,10 +58,29 @@ export declare function ensureManager(o?: {
34
58
  attachHost?: string;
35
59
  resumeAttempt?: string;
36
60
  resumeCommitToken?: string;
37
- }): {
61
+ wsPort?: number;
62
+ }, probe?: LivenessProbe): {
38
63
  running: boolean;
39
64
  };
40
- /** Stop the detached (pty) manager if we started one. Used when switching to the cmux-tab manager
41
- * so the two don't both answer the control plane (queue-grouped requests would split between them). */
42
- export declare function stopManager(): void;
65
+ /** A signal, injectable for the same reason the probe is: `EPERM` from `kill` is producible only by
66
+ * another user's process or by kernel policy, so the branch that handles it is otherwise unreachable
67
+ * from a test. Production passes nothing. */
68
+ export type SignalFn = (pid: number, signal: NodeJS.Signals) => void;
69
+ /** What a stop actually achieved, because "void" let this function claim success it had not earned. */
70
+ export type StopVerdict = "stopped" | "already-gone";
71
+ /** Blocking sleep. DO NOT reintroduce this for death-waiting: it blocks the event loop, so a child
72
+ * of this process is never reaped, remains a signalable zombie, and reads `alive` forever. That
73
+ * turned `cotal up` + Ctrl-C into an exit-1 that left the broker running. Death-waits await. */
74
+ /** Stop the detached (pty) manager if we started one, and remove its records ONLY once it is gone.
75
+ *
76
+ * THIS USED TO CATCH EVERY SIGNAL FAILURE AS "already gone" AND DELETE THE RECORDS ANYWAY. That was
77
+ * survivable while `EPERM` was misread as dead, because the caller never got here: the cutover
78
+ * preflight skipped a manager it thought was not running. Resolving `EPERM` to `alive` (the fix this
79
+ * change exists for) makes the preflight recognise ANOTHER USER's live manager and call this, at
80
+ * which point the old code sent a signal it was not permitted to send, swallowed the refusal, and
81
+ * deleted the pidfile and marker of a process that was still running and still bound to Plane 3.
82
+ * A correct fix upstream reaching a latent destructive bug downstream is the worst shape available,
83
+ * so this refuses instead: records are removed only on proven death, never on a signal we could not
84
+ * send or a death we could not confirm. Found by review, with a kernel seccomp proof. */
85
+ export declare function stopManager(probe?: LivenessProbe, signal?: SignalFn | undefined): Promise<StopVerdict>;
43
86
  //# sourceMappingURL=manager-proc.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"manager-proc.d.ts","sourceRoot":"","sources":["../../src/lib/manager-proc.ts"],"names":[],"mappings":"AAwBA,6FAA6F;AAC7F,wBAAgB,SAAS,IAAI,OAAO,CAKnC;AAED;;;;2CAI2C;AAC3C,wBAAgB,wBAAwB,IAAI,OAAO,CAOlD;AAED;;;;0FAI0F;AAC1F,wBAAgB,oBAAoB,CAClC,CAAC,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,EA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@ -4,29 +4,46 @@ import { DEFAULT_SERVER } from "@cotal-ai/core";
4
4
  import { selfArgv } from "./self-exec.js";
5
5
  import { resolveSpace } from "./status.js";
6
6
  import { cotalPath } from "./paths.js";
7
- const PID_PATH = () => cotalPath("manager.pid");
7
+ import { parsePid, probeLiveness } from "@cotal-ai/workspace";
8
+ /** Exported so the delivery cutover preflight can NAME the pid it refused on: an error that says
9
+ * "cannot be attributed" without saying which pid is not actionable. */
10
+ export const MANAGER_PID_PATH = () => cotalPath("manager.pid");
11
+ const PID_PATH = MANAGER_PID_PATH;
8
12
  /** Sibling marker of `manager.pid`: written by THIS build's manager (which no longer hosts Plane-3 —
9
13
  * the server-side delivery daemon does). Its presence beside a live `manager.pid` proves the manager is
10
14
  * "delivery-aware" / non-hosting. A live `manager.pid` WITHOUT this marker is an OLD (pre-delivery-daemon)
11
15
  * manager that still calls `startPlane3` — the delivery preflight stops it before the daemon binds, so an
12
16
  * old hosting manager never double-binds `fanout`/`reader` against the new daemon. */
13
17
  const DELIVERY_AWARE_MARKER = () => cotalPath("manager.delivery-aware");
14
- function alive(pid) {
15
- try {
16
- process.kill(pid, 0); // signal 0: liveness probe, doesn't actually signal
17
- return true;
18
- }
19
- catch {
20
- return false;
21
- }
22
- }
23
- /** True if the manager we started for this folder is still running (pid file + liveness). */
24
- export function managerUp() {
18
+ /** The recorded manager's liveness, THREE-VALUED plus absent, because collapsing it to a boolean is
19
+ * what made this dangerous. Both collapses are silent and both are wrong:
20
+ * `!== "dead"` -> an `unknown` reports UP forever; no retry clears it and nothing starts.
21
+ * `=== "alive"` -> an `unknown` reports DOWN and a second manager launches onto a possibly-live one.
22
+ * `unknown` is REACHABLE on a real kernel, not just under a test shim: a Linux seccomp filter
23
+ * (`SECCOMP_RET_ERRNO`) or an LSM policy can return an arbitrary errno for `kill(pid, 0)` without
24
+ * executing it at all, and libuv preserves it. Proven with a live seccomp BPF filter, not by
25
+ * interposition. So the caller has to SEE the third state and refuse. */
26
+ export function managerLiveness(probe = probeLiveness) {
25
27
  const p = PID_PATH();
26
28
  if (!existsSync(p))
27
- return false;
28
- const pid = Number(readFileSync(p, "utf8").trim());
29
- return Number.isFinite(pid) && alive(pid);
29
+ return "absent";
30
+ const raw = readFileSync(p, "utf8").trim();
31
+ if (raw === "")
32
+ return "absent"; // a pre-protocol husk: nothing is behind it
33
+ const pid = parsePid(raw);
34
+ // NOT `absent`. Folding non-empty corrupt content into "no manager recorded" is what let the
35
+ // ensure paths OVERWRITE it and launch a replacement, which is the same defect as deleting it:
36
+ // that record may front a live process nobody can identify. `absent` means no pidfile (or an
37
+ // empty husk); corrupt content is its own state and every action path must refuse on it.
38
+ if (pid === undefined)
39
+ return "unattributable";
40
+ return probe(pid);
41
+ }
42
+ /** True only if the manager is PROVABLY running. `unknown` is not up, and callers that would ACT on
43
+ * that answer must use {@link managerLiveness} instead: this boolean cannot express the difference
44
+ * between "not running" and "cannot tell", and acting on the difference is the whole point. */
45
+ export function managerUp() {
46
+ return managerLiveness() === "alive";
30
47
  }
31
48
  /** True if the live manager carries a delivery-aware marker BOUND to its current pid (i.e. it's THIS
32
49
  * build, non-hosting). Fail-closed: the marker stores the pid it was written for, and this requires it
@@ -79,6 +96,8 @@ export function startManagerDetached(o = {}) {
79
96
  ...(o.launch ? ["--launch", o.launch] : []),
80
97
  ...(o.resumeAttempt ? ["--resume-attempt", o.resumeAttempt] : []),
81
98
  ...(o.resumeCommitToken ? ["--resume-commit-token", o.resumeCommitToken] : []),
99
+ // P2 item 6: the broker ws listener port (loopback) for the console session client's wsUrl.
100
+ ...(o.wsPort !== undefined ? ["--ws-port", String(o.wsPort)] : []),
82
101
  ];
83
102
  // This is an INTERNAL child re-exec: the `up`/`spawn` that reached here already ran the first-run
84
103
  // connector seed, so the manager skips it on boot (a direct `cotal supervise` still seeds).
@@ -95,28 +114,110 @@ export function startManagerDetached(o = {}) {
95
114
  * one detached. Best-effort — callers treat it as non-fatal. A caller that needs THE manager to
96
115
  * carry a runtime/launch spec (`up -f`) must stop any leftover manager first — a reused one is
97
116
  * taken as-is. */
98
- export function ensureManager(o = {}) {
99
- if (managerUp())
117
+ /** Refuse to stand a manager up OVER a record we cannot read or attribute.
118
+ *
119
+ * Exported because `ensureManager` is not the only path that starts one: `cotal spawn -f` calls
120
+ * `startManagerDetached` directly after its own lease checks, and so skipped this entirely. A lease
121
+ * says nobody is ANSWERING; it does not say the recorded pid is dead. Overwriting an unknown or
122
+ * unattributable record is the same defect as deleting it, reached through a different verb, which
123
+ * is the third time that shape has appeared in this change. Any future starter calls this first. */
124
+ export function assertManagerRecordReplaceable(probe = probeLiveness) {
125
+ const state = managerLiveness(probe);
126
+ if (state === "unattributable")
127
+ throw new Error(`the manager pidfile at ${PID_PATH()} holds content that is not a pid (${JSON.stringify(readFileSync(PID_PATH(), "utf8").trim())}).\n` +
128
+ `Refusing to start a manager over it: that record may front a live process nobody can identify, and overwriting it would orphan the process while reporting a healthy control plane.\n` +
129
+ `NEXT: find and stop that process, then remove \`.cotal/manager.pid\` by hand.`);
130
+ if (state === "unknown")
131
+ throw new Error(`the recorded manager pid (${readFileSync(PID_PATH(), "utf8").trim()}) cannot be attributed: the kernel answered neither "running" nor "no such process" (a seccomp filter or LSM policy does this inside some sandboxes).\n` +
132
+ `Refusing to start a manager over it: it may still be running and bound to the control plane.\n` +
133
+ `NEXT: verify with \`ps -p <pid>\`. If it is gone, remove \`.cotal/manager.pid\` and re-run.`);
134
+ }
135
+ export function ensureManager(o = {}, probe = probeLiveness) {
136
+ const state = managerLiveness(probe);
137
+ if (state === "alive")
100
138
  return { running: true };
139
+ assertManagerRecordReplaceable(probe); // refuses on unknown / unattributable
101
140
  startManagerDetached(o);
102
141
  return { running: true };
103
142
  }
104
- /** Stop the detached (pty) manager if we started one. Used when switching to the cmux-tab manager
105
- * so the two don't both answer the control plane (queue-grouped requests would split between them). */
106
- export function stopManager() {
143
+ /** Blocking sleep. DO NOT reintroduce this for death-waiting: it blocks the event loop, so a child
144
+ * of this process is never reaped, remains a signalable zombie, and reads `alive` forever. That
145
+ * turned `cotal up` + Ctrl-C into an exit-1 that left the broker running. Death-waits await. */
146
+ // (sleepSync removed: see above.)
147
+ /** Stop the detached (pty) manager if we started one, and remove its records ONLY once it is gone.
148
+ *
149
+ * THIS USED TO CATCH EVERY SIGNAL FAILURE AS "already gone" AND DELETE THE RECORDS ANYWAY. That was
150
+ * survivable while `EPERM` was misread as dead, because the caller never got here: the cutover
151
+ * preflight skipped a manager it thought was not running. Resolving `EPERM` to `alive` (the fix this
152
+ * change exists for) makes the preflight recognise ANOTHER USER's live manager and call this, at
153
+ * which point the old code sent a signal it was not permitted to send, swallowed the refusal, and
154
+ * deleted the pidfile and marker of a process that was still running and still bound to Plane 3.
155
+ * A correct fix upstream reaching a latent destructive bug downstream is the worst shape available,
156
+ * so this refuses instead: records are removed only on proven death, never on a signal we could not
157
+ * send or a death we could not confirm. Found by review, with a kernel seccomp proof. */
158
+ export async function stopManager(probe = probeLiveness, signal = undefined) {
159
+ const send = signal ?? ((pid, sig) => process.kill(pid, sig));
107
160
  const p = PID_PATH();
108
- rmSync(DELIVERY_AWARE_MARKER(), { force: true }); // drop the marker with the pid (gone either way)
109
- if (!existsSync(p))
110
- return;
111
- const pid = Number(readFileSync(p, "utf8").trim());
112
- if (Number.isFinite(pid)) {
113
- try {
114
- process.kill(pid, "SIGTERM");
161
+ const marker = DELIVERY_AWARE_MARKER();
162
+ const clear = () => {
163
+ rmSync(marker, { force: true });
164
+ rmSync(p, { force: true });
165
+ };
166
+ if (!existsSync(p)) {
167
+ rmSync(marker, { force: true }); // a marker with no pid records nothing
168
+ return "already-gone";
169
+ }
170
+ const raw = readFileSync(p, "utf8").trim();
171
+ const pid = parsePid(raw);
172
+ if (pid === undefined) {
173
+ // An EMPTY pidfile is a pre-protocol husk with nothing behind it, and clearing it is safe. ANY
174
+ // OTHER unattributable content (garbled, fractional, out of range) may still front a LIVE
175
+ // process we cannot identify or signal, so removing it would orphan that process while
176
+ // reporting a clean stop. The contract at the top of pid.ts says such content is never a pid to
177
+ // delete a record against; this is that rule at the destructive end, matching down.ts:298-311
178
+ // and stopAuthService, which already refuse. My first version cleared it.
179
+ if (raw === "") {
180
+ clear();
181
+ return "already-gone";
115
182
  }
116
- catch {
117
- /* already gone */
183
+ throw new Error(`the manager pidfile at ${p} is unattributable (${JSON.stringify(raw)}): it may still front a running process nobody can identify.\n` +
184
+ `Refusing to remove it or report a clean stop; the delivery-aware marker is preserved with it.\n` +
185
+ `NEXT: find and stop that process, then remove the file by hand.`);
186
+ }
187
+ const before = probe(pid);
188
+ if (before === "dead") {
189
+ clear();
190
+ return "already-gone";
191
+ }
192
+ if (before === "unknown")
193
+ throw new Error(`refusing to stop manager pid ${pid}: its liveness cannot be determined (the kernel answered neither "running" nor "no such process"; a seccomp filter or LSM policy does this).\n` +
194
+ `The pidfile and delivery-aware marker are LEFT IN PLACE: deleting them would orphan a process that may still be bound to the control plane.\n` +
195
+ `NEXT: verify with \`ps -p ${pid}\`, then stop it yourself or remove \`.cotal/manager.pid\` if it is gone.`);
196
+ try {
197
+ send(pid, "SIGTERM");
198
+ }
199
+ catch (e) {
200
+ const code = e.code;
201
+ if (code === "ESRCH") {
202
+ clear(); // died between the probe and the signal, which is an ordinary race and genuinely gone
203
+ return "already-gone";
118
204
  }
205
+ throw new Error(`refusing to stop manager pid ${pid}: the signal was rejected (${code ?? "unknown error"}).\n` +
206
+ `EPERM here means the process belongs to another user, so it is running and NOT ours to stop. The pidfile and marker are LEFT IN PLACE.\n` +
207
+ `NEXT: stop it as its owner, or remove \`.cotal/manager.pid\` if you are certain it is gone.`);
119
208
  }
120
- rmSync(p);
209
+ // The signal was accepted, which is not the same as the process being gone. Prove it before
210
+ // removing the record, bounded, because a record deleted while its process lives is the defect.
211
+ // AWAIT, never a blocking sleep: this process spawned the manager, so the event loop must run
212
+ // for it to be reaped. A blocked loop leaves a zombie that still answers kill(pid,0).
213
+ for (let i = 0; i < 40 && probe(pid) === "alive"; i++)
214
+ await new Promise((r) => setTimeout(r, 50));
215
+ const after = probe(pid);
216
+ if (after !== "dead")
217
+ throw new Error(`manager pid ${pid} accepted SIGTERM but was still ${after === "alive" ? "running" : "unattributable"} after 2s.\n` +
218
+ `The pidfile and marker are LEFT IN PLACE rather than recording a stop that did not happen.\n` +
219
+ `NEXT: check \`ps -p ${pid}\` and stop it directly if it is wedged.`);
220
+ clear();
221
+ return "stopped";
121
222
  }
122
223
  //# sourceMappingURL=manager-proc.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"manager-proc.js","sourceRoot":"","sources":["../../src/lib/manager-proc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC1G,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;AAChD;;;;uFAIuF;AACvF,MAAM,qBAAqB,GAAG,GAAG,EAAE,CAAC,SAAS,CAAC,wBAAwB,CAAC,CAAC;AAExE,SAAS,KAAK,CAAC,GAAW;IACxB,IAAI,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,oDAAoD;QAC1E,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,SAAS;IACvB,MAAM,CAAC,GAAG,QAAQ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