@cotal-ai/seat 0.48.2 → 0.50.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/handle.js CHANGED
@@ -30,6 +30,12 @@ export function adoptSeatSync(record) {
30
30
  status = "exited";
31
31
  });
32
32
  });
33
+ const close = () => {
34
+ for (const u of liveUnsubs)
35
+ u();
36
+ liveUnsubs.clear();
37
+ client.close();
38
+ };
33
39
  return {
34
40
  name: record.name,
35
41
  kind: "pty",
@@ -41,6 +47,7 @@ export function adoptSeatSync(record) {
41
47
  stop: (opts) => {
42
48
  later((c) => c.stop(opts?.graceful === false ? "hard" : "graceful"));
43
49
  },
50
+ release: close,
44
51
  waitForExit: async () => {
45
52
  try {
46
53
  const c = await whenReady();
@@ -58,9 +65,7 @@ export function adoptSeatSync(record) {
58
65
  interrupt: () => {
59
66
  later((c) => c.interrupt());
60
67
  },
61
- write: (data) => {
62
- later((c) => c.write(data));
63
- },
68
+ write: async (data) => (await whenReady()).write(data),
64
69
  attach: () => {
65
70
  const sessionUnsubs = new Set();
66
71
  // Fast-exit children print and die before hello. onData must replay the
@@ -142,12 +147,7 @@ export function adoptSeatSync(record) {
142
147
  },
143
148
  };
144
149
  },
145
- close: () => {
146
- for (const u of liveUnsubs)
147
- u();
148
- liveUnsubs.clear();
149
- client.close();
150
- },
150
+ close,
151
151
  };
152
152
  }
153
153
  export async function adoptSeat(record) {
@@ -1 +1 @@
1
- {"version":3,"file":"handle.js","sourceRoot":"","sources":["../src/handle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA6BzC,MAAM,UAAU,aAAa,CAAC,MAAkB;IAC9C,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IACtC,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;IAC/B,IAAI,MAAM,GAAyB,SAAS,CAAC;IAC7C,IAAI,IAAoD,C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EAAE,CAAC,CAAC;wBACrB,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;wBACzB,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;oBACxB,CAAC,CAAC,CAAC;oBACH,OAAO,GAAG,EAAE;wBACV,SAAS,GAAG,IAAI,CAAC;wBACjB,KAAK,EAAE,CAAC;wBACR,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;wBAC5B,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;oBAC3B,CAAC,CAAC;gBACJ,CAAC;gBACD,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE;oBACd,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;gBAC9B,CAAC;gBACD,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;oBACf,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;wBAAE,OAAO;oBAC7B,IAAI,GAAG,CAAC,CAAC;oBACT,IAAI,GAAG,CAAC,CAAC;oBACT,oBAAoB,GAAG,IAAI,CAAC;oBAC5B,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;gBACnC,CAAC;aACF,CAAC;QACJ,CAAC;QACD,KAAK;KACN,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,MAAkB;IAChD,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IACrC,MAAM,MAAM,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC;IAChC,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
- export { PROTOCOL_VERSION, unsupportedTransport } from "./protocol.js";
2
- export { launchSeat, loadSeat, type LaunchSeatOpts, type SeatLaunchSpec } from "./launcher.js";
1
+ export { MAX_SOCKET_PATH, PROTOCOL_VERSION, UNATTENDED_MS, assertSocketPathFits, unattendedMs, unsupportedTransport } from "./protocol.js";
2
+ export { launchSeat, loadSeat, RUN_MARKER_FLAG, runMarker, runMarkerOf, type LaunchSeatOpts, type SeatLaunchSpec } from "./launcher.js";
3
3
  export { adoptSeat, adoptSeatSync, type SeatHandle, type SeatAttachSession } from "./handle.js";
4
- export { readRecord, recordPath, socketPath, type SeatRecord } from "./record.js";
4
+ export { assertSeatId, bootToken, processStartToken, readRecord, recordPath, seatId, socketPath, type SeatRecord } from "./record.js";
5
+ export { censusCustodians, identityVerdict, reapSeat, type CustodianSighting, type SeatReapEvidence } from "./reap.js";
5
6
  export { SeatClient } from "./client.js";
6
7
  export { runCustodian, type CustodianLaunch } from "./custodian.js";
8
+ export { StartupConfirmMatcher, normalizeConfirmText, unmatchedConfirmMessage } from "./startup-confirm.js";
7
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,KAAK,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChG,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,aAAa,EAAE,oBAAoB,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC3I,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,eAAe,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AACxI,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,KAAK,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChG,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AACtI,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,QAAQ,EAAE,KAAK,iBAAiB,EAAE,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AACvH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC"}
package/dist/index.js CHANGED
@@ -1,7 +1,9 @@
1
- export { PROTOCOL_VERSION, unsupportedTransport } from "./protocol.js";
2
- export { launchSeat, loadSeat } from "./launcher.js";
1
+ export { MAX_SOCKET_PATH, PROTOCOL_VERSION, UNATTENDED_MS, assertSocketPathFits, unattendedMs, unsupportedTransport } from "./protocol.js";
2
+ export { launchSeat, loadSeat, RUN_MARKER_FLAG, runMarker, runMarkerOf } from "./launcher.js";
3
3
  export { adoptSeat, adoptSeatSync } from "./handle.js";
4
- export { readRecord, recordPath, socketPath } from "./record.js";
4
+ export { assertSeatId, bootToken, processStartToken, readRecord, recordPath, seatId, socketPath } from "./record.js";
5
+ export { censusCustodians, identityVerdict, reapSeat } from "./reap.js";
5
6
  export { SeatClient } from "./client.js";
6
7
  export { runCustodian } from "./custodian.js";
8
+ export { StartupConfirmMatcher, normalizeConfirmText, unmatchedConfirmMessage } from "./startup-confirm.js";
7
9
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAA4C,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,SAAS,EAAE,aAAa,EAA2C,MAAM,aAAa,CAAC;AAChG,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAmB,MAAM,aAAa,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAwB,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,aAAa,EAAE,oBAAoB,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC3I,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,eAAe,EAAE,SAAS,EAAE,WAAW,EAA4C,MAAM,eAAe,CAAC;AACxI,OAAO,EAAE,SAAS,EAAE,aAAa,EAA2C,MAAM,aAAa,CAAC;AAChG,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAmB,MAAM,aAAa,CAAC;AACtI,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,QAAQ,EAAiD,MAAM,WAAW,CAAC;AACvH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAwB,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -3,14 +3,36 @@ export interface SeatLaunchSpec {
3
3
  command: string;
4
4
  args: string[];
5
5
  env?: Record<string, string>;
6
- confirm?: boolean;
6
+ confirm?: string;
7
7
  }
8
8
  export interface LaunchSeatOpts {
9
9
  root: string;
10
10
  name: string;
11
11
  spec: SeatLaunchSpec;
12
12
  cwd: string;
13
+ /** A custody id the caller minted BEFORE this launch, so a durable record of the seat can exist
14
+ * before its processes do. Omitted mints one here, as before. It names a directory under
15
+ * `root`, so it must carry the seat-id shape and must not already hold a record. */
16
+ id?: string;
13
17
  }
18
+ /**
19
+ * The RUN this launch belongs to, as an argv marker a census can read straight out of
20
+ * `/proc/<pid>/cmdline` (#1648).
21
+ *
22
+ * Orphan custodians carried the worktree path only as their cwd, so finding them meant walking
23
+ * `/proc/*\/cwd`, which needs the right uid for every pid on the box and cannot say WHICH run left
24
+ * one behind. `COTAL_RUN` names the run when a caller sets it (a suite runner, a CI job); otherwise
25
+ * the launching process's own pid names it, which is still enough to tell one run's orphans from
26
+ * another's. It goes on ARGV, not only in the environment: `/proc/<pid>/cmdline` is world-readable
27
+ * while `/proc/<pid>/environ` is readable by the owner alone, so argv is the half a census can rely
28
+ * on. It carries no secret: the launch JSON (token, provider keys) still arrives on stdin.
29
+ */
30
+ export declare const RUN_MARKER_FLAG = "--cotal-run";
31
+ export declare function runMarker(env?: NodeJS.ProcessEnv, pid?: number): string;
32
+ /** The run marker carried by a live custodian, read back from its argv. Undefined when that pid is
33
+ * not a custodian started with one. This is the read side of {@link runMarker}: the census a
34
+ * reaper takes is this call over the pids it is considering. */
35
+ export declare function runMarkerOf(pid: number): string | undefined;
14
36
  export declare function launchSeat(opts: LaunchSeatOpts): SeatRecord;
15
37
  export declare function loadSeat(root: string, id: string): SeatRecord;
16
38
  export declare function readSeatFile(path: string): SeatRecord;
@@ -1 +1 @@
1
- {"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../src/launcher.ts"],"names":[],"mappings":"AAIA,OAAO,EAAmD,KAAK,UAAU,EAAc,MAAM,aAAa,CAAC;AAG3G,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;CACb;AAwBD,wBAAgB,UAAU,CAAC,IAAI,EAAE,cAAc,GAAG,UAAU,CA8D3D;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,UAAU,CAE7D;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAErD"}
1
+ {"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../src/launcher.ts"],"names":[],"mappings":"AAIA,OAAO,EAAiE,KAAK,UAAU,EAAc,MAAM,aAAa,CAAC;AAGzH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ;;yFAEqF;IACrF,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAaD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,gBAAgB,CAAC;AA6C7C,wBAAgB,SAAS,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,EAAE,GAAG,GAAE,MAAoB,GAAG,MAAM,CAIjG;AAED;;iEAEiE;AACjE,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAW3D;AAaD,wBAAgB,UAAU,CAAC,IAAI,EAAE,cAAc,GAAG,UAAU,CA4E3D;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,UAAU,CAE7D;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAErD"}
package/dist/launcher.js CHANGED
@@ -2,8 +2,8 @@ import { spawn, spawnSync } from "node:child_process";
2
2
  import { closeSync, existsSync, mkdirSync, openSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
3
3
  import { dirname, join } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
- import { capabilityToken, recordPath, seatId, socketPath, readRecord } from "./record.js";
6
- import { unsupportedTransport } from "./protocol.js";
5
+ import { assertSeatId, capabilityToken, recordPath, seatId, socketPath, readRecord } from "./record.js";
6
+ import { unattendedMs, assertSocketPathFits, unsupportedTransport } from "./protocol.js";
7
7
  function packageRoot() {
8
8
  return dirname(dirname(fileURLToPath(import.meta.url)));
9
9
  }
@@ -14,6 +14,85 @@ function custodianEntry() {
14
14
  throw new Error(`custodian entry missing at ${path}; build @cotal-ai/seat first`);
15
15
  return path;
16
16
  }
17
+ /**
18
+ * The RUN this launch belongs to, as an argv marker a census can read straight out of
19
+ * `/proc/<pid>/cmdline` (#1648).
20
+ *
21
+ * Orphan custodians carried the worktree path only as their cwd, so finding them meant walking
22
+ * `/proc/*\/cwd`, which needs the right uid for every pid on the box and cannot say WHICH run left
23
+ * one behind. `COTAL_RUN` names the run when a caller sets it (a suite runner, a CI job); otherwise
24
+ * the launching process's own pid names it, which is still enough to tell one run's orphans from
25
+ * another's. It goes on ARGV, not only in the environment: `/proc/<pid>/cmdline` is world-readable
26
+ * while `/proc/<pid>/environ` is readable by the owner alone, so argv is the half a census can rely
27
+ * on. It carries no secret: the launch JSON (token, provider keys) still arrives on stdin.
28
+ */
29
+ export const RUN_MARKER_FLAG = "--cotal-run";
30
+ /** This process's parent, from `/proc/<pid>/stat` field 4. Undefined when the pid is gone. */
31
+ function parentOf(pid) {
32
+ try {
33
+ const stat = readFileSync(`/proc/${pid}/stat`, "utf8");
34
+ const ppid = Number(stat.slice(stat.lastIndexOf(") ") + 2).split(" ")[1]);
35
+ return Number.isInteger(ppid) && ppid > 1 ? ppid : undefined;
36
+ }
37
+ catch {
38
+ return undefined;
39
+ }
40
+ }
41
+ /**
42
+ * `COTAL_RUN` as the nearest ancestor set it, when this process no longer has it.
43
+ *
44
+ * A suite that builds a child environment scrubs every `COTAL_` key, which is the correct rule for
45
+ * connection material and takes `COTAL_RUN` with it. The run is then invisible to the launcher, the
46
+ * marker degrades to this process's pid, and the runner's census cannot attribute the custodian to
47
+ * the run that started it. Measured: a child spawned through that scrub reported
48
+ * `child_saw_COTAL_RUN: null` and `claimed_by_run_census: false`.
49
+ *
50
+ * The environment of an ancestor still has it, because the scrub copies rather than edits the
51
+ * parent. `/proc/<pid>/environ` is readable by its owner, and every process in this chain belongs to
52
+ * the same uid, so a short walk recovers the run without weakening the scrub or asking every suite
53
+ * to remember an exception. Bounded to 16 hops so a pathological chain cannot spin, and it stops at
54
+ * pid 1, which owns no run.
55
+ */
56
+ function inheritedRun(startPid) {
57
+ let pid = parentOf(startPid);
58
+ for (let hop = 0; hop < 16 && pid !== undefined; hop++) {
59
+ try {
60
+ const entry = readFileSync(`/proc/${pid}/environ`, "utf8")
61
+ .split("\0")
62
+ .find((s) => s.startsWith("COTAL_RUN="));
63
+ const value = entry?.slice("COTAL_RUN=".length).trim();
64
+ if (value)
65
+ return value;
66
+ }
67
+ catch {
68
+ // Not ours to read, or it exited mid-walk. Keep climbing: a readable ancestor may be further up.
69
+ }
70
+ pid = parentOf(pid);
71
+ }
72
+ return undefined;
73
+ }
74
+ export function runMarker(env = process.env, pid = process.pid) {
75
+ const named = env.COTAL_RUN?.trim() ?? (env === process.env ? inheritedRun(pid) : undefined);
76
+ // Newlines and spaces would split one marker into two argv-looking tokens in a census.
77
+ return named ? named.replace(/\s+/g, "_") : `pid-${pid}`;
78
+ }
79
+ /** The run marker carried by a live custodian, read back from its argv. Undefined when that pid is
80
+ * not a custodian started with one. This is the read side of {@link runMarker}: the census a
81
+ * reaper takes is this call over the pids it is considering. */
82
+ export function runMarkerOf(pid) {
83
+ let cmdline;
84
+ try {
85
+ cmdline = readFileSync(`/proc/${pid}/cmdline`, "utf8");
86
+ }
87
+ catch {
88
+ return undefined;
89
+ }
90
+ const argv = cmdline.split("\0").filter((s) => s.length > 0);
91
+ const at = argv.indexOf(RUN_MARKER_FLAG);
92
+ if (at < 0)
93
+ return undefined;
94
+ return argv[at + 1];
95
+ }
17
96
  function pidLive(pid) {
18
97
  if (typeof pid !== "number" || pid <= 0)
19
98
  return false;
@@ -30,12 +109,17 @@ export function launchSeat(opts) {
30
109
  if (process.platform !== "linux")
31
110
  throw unsupportedTransport();
32
111
  mkdirSync(opts.root, { recursive: true, mode: 0o700 });
33
- const id = seatId();
112
+ const id = assertSeatId(opts.id ?? seatId());
34
113
  const token = capabilityToken();
35
- const socket = socketPath(opts.root, id);
114
+ const socket = assertSocketPathFits(socketPath(opts.root, id));
36
115
  const recPath = recordPath(opts.root, id);
116
+ // A reserved id is spawned once. Reusing one would launch a second custodian over a live seat's
117
+ // record, and the reference the manager already recorded would then address the wrong processes.
118
+ if (existsSync(recPath))
119
+ throw new Error(`seat ${id} already holds a custody record at ${recPath}; a custody id is used for one launch`);
37
120
  mkdirSync(dirname(recPath), { recursive: true, mode: 0o700 });
38
121
  const logPath = join(dirname(recPath), "custodian.log");
122
+ const run = runMarker();
39
123
  const payload = JSON.stringify({
40
124
  id,
41
125
  name: opts.name,
@@ -47,18 +131,28 @@ export function launchSeat(opts) {
47
131
  token,
48
132
  recordPath: recPath,
49
133
  logPath,
50
- confirm: Boolean(opts.spec.confirm),
134
+ confirm: opts.spec.confirm,
135
+ run,
136
+ // Resolved HERE, not in the custodian: the custodian's environment is scrubbed to `PATH` plus the
137
+ // run marker, so it cannot read an override the caller set.
138
+ unattendedMs: unattendedMs(),
51
139
  });
52
140
  // Payload carries spec.env (provider keys) and the capability token.
53
141
  // argv is world-readable via /proc/<pid>/cmdline (0444). Inherit a 0600
54
142
  // file as stdin so the JSON never appears on argv.
143
+ //
144
+ // The run marker is the one thing deliberately ON argv, because that is the point of it: a census
145
+ // must be able to attribute an orphan without the uid needed to read `/proc/<pid>/cwd`. It names a
146
+ // run, never a credential.
55
147
  const launchPath = join(dirname(recPath), "launch.json");
56
148
  writeFileSync(launchPath, payload, { mode: 0o600 });
57
149
  const launchFd = openSync(launchPath, "r");
58
- const child = spawn(process.execPath, [custodianEntry()], {
150
+ const child = spawn(process.execPath, [custodianEntry(), RUN_MARKER_FLAG, run], {
59
151
  detached: true,
60
152
  stdio: [launchFd, "ignore", "ignore"],
61
- env: { PATH: process.env.PATH ?? "" },
153
+ // COTAL_RUN is re-exported so a custodian's own descendants stay attributable to the same run,
154
+ // and so `/proc/<pid>/environ` answers the same question argv does for a reader who can read it.
155
+ env: { PATH: process.env.PATH ?? "", COTAL_RUN: run },
62
156
  });
63
157
  closeSync(launchFd);
64
158
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"launcher.js","sourceRoot":"","sources":["../src/launcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC9G,OAAO,EAAE,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,CAAC,CAAC;AACzE,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,EAAU;IAC/C,OAAO,UAAU,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAe,CAAC;AAC9D,CAAC"}
@@ -3,9 +3,25 @@ export declare const PROTOCOL_VERSION = 1;
3
3
  export declare const DEFAULT_COLS = 120;
4
4
  export declare const DEFAULT_ROWS = 32;
5
5
  export declare const SCROLLBACK_ROWS = 1000;
6
- export declare const CONFIRM_INTERVAL_MS = 1000;
7
- export declare const MAX_CONFIRMS = 5;
6
+ /** How long a connector-declared startup prompt may take to appear before the seat fails loud. */
7
+ export declare const CONFIRM_TIMEOUT_MS = 15000;
8
8
  export declare const GRACE_MS = 3000;
9
+ /**
10
+ * How long a custodian stays up with NO authenticated controller before it stops its child and
11
+ * exits. A custodian is meant to outlive the manager that adopted it only until a successor adopts
12
+ * or reaps it; one whose manager and broker are both gone has nobody left to answer and holds ~65 MB
13
+ * for nothing. Ten minutes is long enough for a manager restart to re-adopt a detached seat and for
14
+ * a successor's reap to arrive, and short enough that a host running review lanes does not
15
+ * accumulate orphans across a day (#1648).
16
+ *
17
+ * The child is stopped rather than abandoned: the custodian owns the only reader of that PTY, so an
18
+ * exit that left the child running would trade a 65 MB orphan for a blocked one nobody can address.
19
+ */
20
+ export declare const UNATTENDED_MS: number;
21
+ /** {@link UNATTENDED_MS}, or the override in `COTAL_SEAT_UNATTENDED_MS` (milliseconds, > 0). A
22
+ * malformed or non-positive value throws rather than silently restoring the default: a test or
23
+ * operator that asks for a bound and gets the ten-minute one instead would wait on the wrong clock. */
24
+ export declare function unattendedMs(env?: NodeJS.ProcessEnv): number;
9
25
  /**
10
26
  * Max JSON body the local protocol accepts in one frame.
11
27
  * A 1000-row, 120-col 16-color serialize is ~744 KiB, and JSON-escaping that
@@ -17,6 +33,30 @@ export declare const MAX_FRAME_SIZE: number;
17
33
  /** Max undecoded residual AFTER complete frames have been drained. */
18
34
  export declare const MAX_BUFFER_SIZE: number;
19
35
  export type StopMode = "graceful" | "hard";
36
+ /**
37
+ * Longest filesystem socket path this transport accepts.
38
+ *
39
+ * `sun_path` in `struct sockaddr_un` is 108 bytes on Linux. Whether the last byte may hold a path
40
+ * character or must be the NUL is the kind of detail that is easy to assert and easy to get wrong,
41
+ * so it was measured rather than reasoned about: a 108-byte path binds and the exact file appears on
42
+ * disk; 109 creates `seat.soc`, 110 creates `seat.so`, 111 creates `seat.s`. So 108 is usable and
43
+ * truncation begins at 109.
44
+ *
45
+ * What makes this worth a named refusal is that nothing below reports the overflow: libuv copies the
46
+ * path into that fixed buffer and TRUNCATES it, then `listen` SUCCEEDS on the shortened name. The
47
+ * custodian then chmods and unlinks the path it MEANT to bind, gets ENOENT, and dies; the launcher,
48
+ * which only sees a pid that went away, reports `custodian exited before ready` and names nothing.
49
+ *
50
+ * That is not hypothetical. Two independent reviews of this issue set TMPDIR inside their review
51
+ * worktree, whose deeper path pushed the seat socket to 121 bytes, and every gate run they attempted
52
+ * died this way before reaching a single assertion. Both concluded the fix was unproven; the fix was
53
+ * fine and the transport was lying about why it could not start.
54
+ */
55
+ export declare const MAX_SOCKET_PATH = 108;
56
+ /** Refuse a socket path the kernel cannot hold, naming the limit, the overage and the cure. Called
57
+ * before any process is spawned, so an unusable custody root fails at the launch that asked for it
58
+ * rather than inside a detached process that cannot tell anyone. */
59
+ export declare function assertSocketPathFits(socket: string): string;
20
60
  export type ClientRequest = {
21
61
  id: number;
22
62
  op: "hello";
@@ -95,6 +135,7 @@ export type ServerReply = {
95
135
  id: number;
96
136
  ok: true;
97
137
  op: "write";
138
+ bytes: number;
98
139
  } | {
99
140
  id: number;
100
141
  ok: true;
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.d.ts","sourceRoot":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AAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7C,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,WAAW,CAAC;AAEtD,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAQlD;AAED,qBAAa,WAAW;IACtB,OAAO,CAAC,GAAG,CAA2B;IAEtC,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,EAAE;CAoB/B;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,GAAE,MAAyB,GAAG,KAAK,CAE/E"}
package/dist/protocol.js CHANGED
@@ -3,9 +3,33 @@ export const PROTOCOL_VERSION = 1;
3
3
  export const DEFAULT_COLS = 120;
4
4
  export const DEFAULT_ROWS = 32;
5
5
  export const SCROLLBACK_ROWS = 1000;
6
- export const CONFIRM_INTERVAL_MS = 1_000;
7
- export const MAX_CONFIRMS = 5;
6
+ /** How long a connector-declared startup prompt may take to appear before the seat fails loud. */
7
+ export const CONFIRM_TIMEOUT_MS = 15_000;
8
8
  export const GRACE_MS = 3_000;
9
+ /**
10
+ * How long a custodian stays up with NO authenticated controller before it stops its child and
11
+ * exits. A custodian is meant to outlive the manager that adopted it only until a successor adopts
12
+ * or reaps it; one whose manager and broker are both gone has nobody left to answer and holds ~65 MB
13
+ * for nothing. Ten minutes is long enough for a manager restart to re-adopt a detached seat and for
14
+ * a successor's reap to arrive, and short enough that a host running review lanes does not
15
+ * accumulate orphans across a day (#1648).
16
+ *
17
+ * The child is stopped rather than abandoned: the custodian owns the only reader of that PTY, so an
18
+ * exit that left the child running would trade a 65 MB orphan for a blocked one nobody can address.
19
+ */
20
+ export const UNATTENDED_MS = 10 * 60_000;
21
+ /** {@link UNATTENDED_MS}, or the override in `COTAL_SEAT_UNATTENDED_MS` (milliseconds, > 0). A
22
+ * malformed or non-positive value throws rather than silently restoring the default: a test or
23
+ * operator that asks for a bound and gets the ten-minute one instead would wait on the wrong clock. */
24
+ export function unattendedMs(env = process.env) {
25
+ const raw = env.COTAL_SEAT_UNATTENDED_MS;
26
+ if (raw === undefined || raw === "")
27
+ return UNATTENDED_MS;
28
+ const ms = Number(raw);
29
+ if (!Number.isFinite(ms) || ms <= 0)
30
+ throw new Error(`COTAL_SEAT_UNATTENDED_MS must be a positive number of milliseconds; got ${JSON.stringify(raw)}`);
31
+ return ms;
32
+ }
9
33
  /**
10
34
  * Max JSON body the local protocol accepts in one frame.
11
35
  * A 1000-row, 120-col 16-color serialize is ~744 KiB, and JSON-escaping that
@@ -16,6 +40,37 @@ export const GRACE_MS = 3_000;
16
40
  export const MAX_FRAME_SIZE = 8 * 1024 * 1024;
17
41
  /** Max undecoded residual AFTER complete frames have been drained. */
18
42
  export const MAX_BUFFER_SIZE = MAX_FRAME_SIZE + 4;
43
+ /**
44
+ * Longest filesystem socket path this transport accepts.
45
+ *
46
+ * `sun_path` in `struct sockaddr_un` is 108 bytes on Linux. Whether the last byte may hold a path
47
+ * character or must be the NUL is the kind of detail that is easy to assert and easy to get wrong,
48
+ * so it was measured rather than reasoned about: a 108-byte path binds and the exact file appears on
49
+ * disk; 109 creates `seat.soc`, 110 creates `seat.so`, 111 creates `seat.s`. So 108 is usable and
50
+ * truncation begins at 109.
51
+ *
52
+ * What makes this worth a named refusal is that nothing below reports the overflow: libuv copies the
53
+ * path into that fixed buffer and TRUNCATES it, then `listen` SUCCEEDS on the shortened name. The
54
+ * custodian then chmods and unlinks the path it MEANT to bind, gets ENOENT, and dies; the launcher,
55
+ * which only sees a pid that went away, reports `custodian exited before ready` and names nothing.
56
+ *
57
+ * That is not hypothetical. Two independent reviews of this issue set TMPDIR inside their review
58
+ * worktree, whose deeper path pushed the seat socket to 121 bytes, and every gate run they attempted
59
+ * died this way before reaching a single assertion. Both concluded the fix was unproven; the fix was
60
+ * fine and the transport was lying about why it could not start.
61
+ */
62
+ export const MAX_SOCKET_PATH = 108;
63
+ /** Refuse a socket path the kernel cannot hold, naming the limit, the overage and the cure. Called
64
+ * before any process is spawned, so an unusable custody root fails at the launch that asked for it
65
+ * rather than inside a detached process that cannot tell anyone. */
66
+ export function assertSocketPathFits(socket) {
67
+ const bytes = Buffer.byteLength(socket, "utf8");
68
+ if (bytes > MAX_SOCKET_PATH)
69
+ throw new Error(`seat socket path is ${bytes} bytes, over the ${MAX_SOCKET_PATH}-byte limit for a Unix socket: ${socket}. ` +
70
+ `The kernel would truncate it silently and the custodian would bind a different name than it cleans up. ` +
71
+ `Use a shorter custody root (a deep TMPDIR inside a worktree is the usual cause).`);
72
+ return socket;
73
+ }
19
74
  export function encodeFrame(value) {
20
75
  const body = Buffer.from(JSON.stringify(value), "utf8");
21
76
  if (body.length > MAX_FRAME_SIZE) {
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAElC,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAC;AAChC,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAC;AAC/B,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC;AACpC,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC;AACzC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC;AAC9B,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,CAAC;AAC9B;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAC9C,sEAAsE;AACtE,MAAM,CAAC,MAAM,eAAe,GAAG,cAAc,GAAG,CAAC,CAAC;AAoDlD,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC;IACxD,IAAI,IAAI,CAAC,MAAM,GAAG,cAAc,EAAE,CAAC;QAC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CAAC,wBAAwB,eAAe,QAAQ,CAAC,CAAC;QACnE,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AAED,MAAM,UAAU,oBAAoB,CAAC,WAAmB,OAAO,CAAC,QAAQ;IACtE,OAAO,IAAI,KAAK,CAAC,oCAAoC,QAAQ,EAAE,CAAC,CAAC;AACnE,CAAC"}
package/dist/reap.d.ts ADDED
@@ -0,0 +1,47 @@
1
+ /** What a reap proved. `absent`: no custody record exists for that seat id, so there is no process
2
+ * this package can address. `reaped`: every process the record names was either signalled and
3
+ * verified gone, or found already gone (its pid absent or held by a process with a different start
4
+ * identity, which is proof the recorded one exited). */
5
+ export type SeatReapEvidence = {
6
+ outcome: "absent";
7
+ } | {
8
+ outcome: "reaped";
9
+ custodian: "signalled" | "gone";
10
+ child: "signalled" | "gone";
11
+ group: number;
12
+ detail: string;
13
+ };
14
+ /** A pid's standing against a recorded start identity. `live` only when the process exists AND
15
+ * carries the recorded start token; a different token means the pid was reused by an unrelated
16
+ * process, which is never signalled. */
17
+ export declare function identityVerdict(pid: number, start: string): "live" | "gone";
18
+ /** One live custodian as a census sees it: its pid and the run that started it. */
19
+ export interface CustodianSighting {
20
+ pid: number;
21
+ run: string;
22
+ }
23
+ /**
24
+ * Every live seat custodian on this host, with the run that started it (#1648).
25
+ *
26
+ * This reads `/proc/<pid>/cmdline` only, which is world-readable, so a census costs one readdir plus
27
+ * one small read per pid and never needs the uid of the process it is looking at. That is the whole
28
+ * reason the marker is on argv: the orphans carried their worktree only as their CWD, and
29
+ * `/proc/<pid>/cwd` is a readlink the owner alone may follow, so a census of somebody else's
30
+ * leftovers could not even see them.
31
+ *
32
+ * `run` filters to one run's custodians. Omitted, it reports every one on the host, which is what a
33
+ * reaper sweeping before a run wants. A custodian started before this change carries no marker and
34
+ * is not reported: it cannot be attributed, and claiming it as the caller's would be a guess.
35
+ */
36
+ export declare function censusCustodians(run?: string): CustodianSighting[];
37
+ /**
38
+ * Reap one custodied seat that this process did not spawn: a crashed manager's, or a seat whose
39
+ * custodian is lingering after its child exited. Signals only a pid whose current start identity
40
+ * matches the record, verifies the custodian, the child and the child's whole process group gone,
41
+ * then removes the custody record. A record written without start identities refuses: a bare pid
42
+ * cannot be told from an unrelated process that inherited it. Linux only, like the custodian.
43
+ */
44
+ export declare function reapSeat(root: string, id: string, opts?: {
45
+ graceMs?: number;
46
+ }): Promise<SeatReapEvidence>;
47
+ //# sourceMappingURL=reap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reap.d.ts","sourceRoot":"","sources":["../src/reap.ts"],"names":[],"mappings":"AAMA;;;yDAGyD;AACzD,MAAM,MAAM,gBAAgB,GACxB;IAAE,OAAO,EAAE,QAAQ,CAAA;CAAE,GACrB;IAAE,OAAO,EAAE,QAAQ,CAAC;IAAC,SAAS,EAAE,WAAW,GAAG,MAAM,CAAC;IAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvH;;yCAEyC;AACzC,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAG3E;AAgDD,mFAAmF;AACnF,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAwBlE;AAED;;;;;;GAMG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA8DnH"}