@descryy/runtime-controller 0.3.7 → 0.3.8

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 (73) hide show
  1. package/package.json +5 -5
  2. package/dist/attach-fencing.d.ts +0 -109
  3. package/dist/attach-fencing.d.ts.map +0 -1
  4. package/dist/attach-fencing.js +0 -215
  5. package/dist/attach-fencing.js.map +0 -1
  6. package/dist/capability-registry.d.ts +0 -9
  7. package/dist/capability-registry.d.ts.map +0 -1
  8. package/dist/capability-registry.js +0 -32
  9. package/dist/capability-registry.js.map +0 -1
  10. package/dist/collector-version.d.ts +0 -3
  11. package/dist/collector-version.d.ts.map +0 -1
  12. package/dist/collector-version.js +0 -5
  13. package/dist/collector-version.js.map +0 -1
  14. package/dist/container-sandbox.d.ts +0 -104
  15. package/dist/container-sandbox.d.ts.map +0 -1
  16. package/dist/container-sandbox.js +0 -152
  17. package/dist/container-sandbox.js.map +0 -1
  18. package/dist/controller.d.ts +0 -138
  19. package/dist/controller.d.ts.map +0 -1
  20. package/dist/controller.js +0 -449
  21. package/dist/controller.js.map +0 -1
  22. package/dist/dependency-version-check.d.ts +0 -36
  23. package/dist/dependency-version-check.d.ts.map +0 -1
  24. package/dist/dependency-version-check.js +0 -72
  25. package/dist/dependency-version-check.js.map +0 -1
  26. package/dist/env.d.ts +0 -10
  27. package/dist/env.d.ts.map +0 -1
  28. package/dist/env.js +0 -12
  29. package/dist/env.js.map +0 -1
  30. package/dist/environment-metadata.d.ts +0 -15
  31. package/dist/environment-metadata.d.ts.map +0 -1
  32. package/dist/environment-metadata.js +0 -63
  33. package/dist/environment-metadata.js.map +0 -1
  34. package/dist/environment-version-check.d.ts +0 -40
  35. package/dist/environment-version-check.d.ts.map +0 -1
  36. package/dist/environment-version-check.js +0 -176
  37. package/dist/environment-version-check.js.map +0 -1
  38. package/dist/execution-safety.d.ts +0 -96
  39. package/dist/execution-safety.d.ts.map +0 -1
  40. package/dist/execution-safety.js +0 -140
  41. package/dist/execution-safety.js.map +0 -1
  42. package/dist/index.d.ts +0 -31
  43. package/dist/index.d.ts.map +0 -1
  44. package/dist/index.js +0 -17
  45. package/dist/index.js.map +0 -1
  46. package/dist/orchestration.d.ts +0 -55
  47. package/dist/orchestration.d.ts.map +0 -1
  48. package/dist/orchestration.js +0 -219
  49. package/dist/orchestration.js.map +0 -1
  50. package/dist/preflight.d.ts +0 -121
  51. package/dist/preflight.d.ts.map +0 -1
  52. package/dist/preflight.js +0 -163
  53. package/dist/preflight.js.map +0 -1
  54. package/dist/process-collector.d.ts +0 -20
  55. package/dist/process-collector.d.ts.map +0 -1
  56. package/dist/process-collector.js +0 -116
  57. package/dist/process-collector.js.map +0 -1
  58. package/dist/process-identity.d.ts +0 -46
  59. package/dist/process-identity.d.ts.map +0 -1
  60. package/dist/process-identity.js +0 -186
  61. package/dist/process-identity.js.map +0 -1
  62. package/dist/process-manager.d.ts +0 -137
  63. package/dist/process-manager.d.ts.map +0 -1
  64. package/dist/process-manager.js +0 -365
  65. package/dist/process-manager.js.map +0 -1
  66. package/dist/readiness.d.ts +0 -122
  67. package/dist/readiness.d.ts.map +0 -1
  68. package/dist/readiness.js +0 -214
  69. package/dist/readiness.js.map +0 -1
  70. package/dist/sandbox.d.ts +0 -94
  71. package/dist/sandbox.d.ts.map +0 -1
  72. package/dist/sandbox.js +0 -228
  73. package/dist/sandbox.js.map +0 -1
@@ -1,365 +0,0 @@
1
- /**
2
- * Process manager (§5): command execution, cwd, env, process-group tracking,
3
- * stdout/stderr capture, exit-code capture, graceful shutdown, orphan prevention.
4
- *
5
- * Orphan prevention and group-kill use POSIX process groups (`detached: true` +
6
- * `process.kill(-pid, signal)`) -- not portable to Windows, out of scope for the V1
7
- * fixture-app slice (§34).
8
- */
9
- import { execFile, spawn } from "node:child_process";
10
- import { readFileSync } from "node:fs";
11
- import { createServer } from "node:net";
12
- import { promisify } from "node:util";
13
- import { applyResourceLimits } from "./execution-safety.js";
14
- import { applySandbox } from "./sandbox.js";
15
- import { applyContainerSandbox } from "./container-sandbox.js";
16
- import { computeAttachFence } from "./attach-fencing.js";
17
- /**
18
- * Binds port 0, reads it, releases immediately. A real gap remains between "free
19
- * when checked" and "still free when the child binds it" (RT-024's gap, one layer
20
- * down) -- unavoidable without binding the real service directly to the probe
21
- * socket, which the child-process model doesn't support.
22
- *
23
- * **Examined and deliberately not "fixed".** Holding the probe socket longer widens
24
- * the window rather than narrowing it (the child can't bind while we hold it).
25
- * Instead, `awaitReadiness` names the endpoint it probed, so a collision reads as
26
- * "nothing answered on this port" rather than an unexplained failure. Window is a
27
- * handful of ms in practice; a genuine collision still fails loudly, just correctly
28
- * attributed.
29
- */
30
- export function allocateEphemeralPort() {
31
- return new Promise((resolve, reject) => {
32
- const probe = createServer();
33
- probe.once("error", reject);
34
- probe.listen(0, () => {
35
- const address = probe.address();
36
- if (address === null || typeof address === "string") {
37
- probe.close();
38
- reject(new Error("could not determine an ephemeral port"));
39
- return;
40
- }
41
- const { port } = address;
42
- probe.close(() => resolve(port));
43
- });
44
- });
45
- }
46
- const DEFAULT_GRACE_PERIOD_MS = 5000;
47
- /**
48
- * RT-261: `outputBuffer += chunk` grew without bound for the process's whole
49
- * life -- a chatty service (or one stuck in a crash-log loop) grew Descry's
50
- * own memory, not the app's. Bounded to head + tail per service instead: the
51
- * first bytes usually carry the startup/config story, the last bytes carry
52
- * whatever just happened, and the (likely repetitive) middle is the part a
53
- * reader least needs verbatim. Starting values, not measurements.
54
- */
55
- const OUTPUT_HEAD_BYTES = 64 * 1024;
56
- const OUTPUT_TAIL_BYTES = 1024 * 1024;
57
- /** Marks the gap between head and tail; never confused with real process output because it names its own bound. */
58
- function truncationMarker(totalBytes, keptBytes) {
59
- return `\n\n...[Descry truncated ${String(totalBytes - keptBytes)} of ${String(totalBytes)} bytes of output here -- head/tail kept, middle dropped]...\n\n`;
60
- }
61
- export function spawnProcess(options) {
62
- let startedAt = "";
63
- let exitedAt = null;
64
- let exitCode = null;
65
- let signal = null;
66
- // Bounded head/tail buffer (RT-261) -- see OUTPUT_HEAD_BYTES/OUTPUT_TAIL_BYTES.
67
- let headBuffer = "";
68
- let tailBuffer = "";
69
- let totalBytesSeen = 0;
70
- let killStarted = false;
71
- let child;
72
- let settled = false;
73
- // Set only for the container backend -- see kill() for why it needs a separate
74
- // stop mechanism from bwrap's group-kill.
75
- let containerName = null;
76
- let resolveExit;
77
- let exitPromise;
78
- // Everything a (re)spawn needs to reset, in one place -- construction and
79
- // restart() must not drift into resetting different subsets of this state.
80
- function spawnChild() {
81
- startedAt = new Date().toISOString();
82
- exitedAt = null;
83
- exitCode = null;
84
- signal = null;
85
- headBuffer = "";
86
- tailBuffer = "";
87
- totalBytesSeen = 0;
88
- killStarted = false;
89
- settled = false;
90
- exitPromise = new Promise((resolve) => {
91
- resolveExit = resolve;
92
- });
93
- // "container" skips applyResourceLimits entirely (see SpawnProcessOptions.
94
- // sandboxBackend) -- "bwrap" (default) is unchanged.
95
- const wrapped = options.sandboxBackend === "container"
96
- ? applyContainerSandbox({
97
- interpreterCommand: options.command,
98
- command: options.command,
99
- args: options.args ?? [],
100
- cwd: options.cwd ?? process.cwd(),
101
- processEnv: { ...process.env, ...options.env },
102
- ...(options.filesystemPolicy === undefined ? {} : { filesystemPolicy: options.filesystemPolicy }),
103
- ...(options.networkPolicy === undefined ? {} : { networkPolicy: options.networkPolicy }),
104
- })
105
- : applySandbox({
106
- interpreterCommand: options.command,
107
- ...applyResourceLimits(options.command, options.args ?? [], options.resourceLimits),
108
- cwd: options.cwd ?? process.cwd(),
109
- ...(options.filesystemPolicy === undefined ? {} : { filesystemPolicy: options.filesystemPolicy }),
110
- ...(options.networkPolicy === undefined ? {} : { networkPolicy: options.networkPolicy }),
111
- });
112
- containerName = wrapped.containerName ?? null;
113
- child = spawn(wrapped.command, wrapped.args, {
114
- cwd: options.cwd,
115
- env: { ...process.env, ...options.env },
116
- detached: true,
117
- stdio: ["ignore", "pipe", "pipe"],
118
- });
119
- // Shared by both streams -- stdout/stderr are already interleaved into one
120
- // combined buffer (this module's existing contract), so head/tail bounding
121
- // applies to the combined stream, not per-fd.
122
- function appendOutput(chunk) {
123
- totalBytesSeen += chunk.length;
124
- if (headBuffer.length < OUTPUT_HEAD_BYTES) {
125
- headBuffer += chunk.toString("utf8");
126
- if (headBuffer.length > OUTPUT_HEAD_BYTES) {
127
- headBuffer = headBuffer.slice(0, OUTPUT_HEAD_BYTES);
128
- }
129
- }
130
- tailBuffer += chunk.toString("utf8");
131
- if (tailBuffer.length > OUTPUT_TAIL_BYTES) {
132
- tailBuffer = tailBuffer.slice(tailBuffer.length - OUTPUT_TAIL_BYTES);
133
- }
134
- }
135
- child.stdout?.on("data", appendOutput);
136
- child.stderr?.on("data", appendOutput);
137
- // A bad command (ENOENT) surfaces as an `'error'` event, not a thrown exception,
138
- // and per Node's docs `'exit'` may never fire after `'error'`. Both events settle
139
- // the same promise exactly once, so a failed spawn reads as an ordinary
140
- // never-became-ready process rather than crashing the caller or hanging cleanup.
141
- function settle(info) {
142
- if (settled)
143
- return;
144
- settled = true;
145
- exitedAt = new Date().toISOString();
146
- exitCode = info.exitCode;
147
- signal = info.signal;
148
- resolveExit(info);
149
- }
150
- child.once("exit", (code, exitSignal) => settle({ exitCode: code, signal: exitSignal }));
151
- child.once("error", () => settle({ exitCode: null, signal: null }));
152
- }
153
- spawnChild();
154
- function handle() {
155
- return {
156
- processId: options.processId,
157
- command: options.command,
158
- pid: child.pid ?? null,
159
- startedAt,
160
- exitedAt,
161
- exitCode,
162
- signal,
163
- serviceName: options.serviceName ?? null,
164
- port: options.port ?? null,
165
- };
166
- }
167
- async function kill(gracePeriodMs = DEFAULT_GRACE_PERIOD_MS) {
168
- if (killStarted || exitedAt !== null) {
169
- await exitPromise;
170
- return;
171
- }
172
- killStarted = true;
173
- const pid = child.pid;
174
- if (pid === undefined) {
175
- return;
176
- }
177
- if (containerName !== null) {
178
- // Found via escape testing: the local `docker` CLI process is not the
179
- // container -- it runs under `dockerd`, a separate process tree.
180
- // Signaling the CLI's process group left a real orphaned container running.
181
- // `docker stop` (by name) is the real stop mechanism here; `--rm` then
182
- // removes it. Still falls through to group-kill below as a CLI backstop.
183
- try {
184
- await execFileAsync("docker", ["stop", "--time", String(Math.max(1, Math.round(gracePeriodMs / 1000))), containerName]);
185
- }
186
- catch {
187
- // Already stopped/removed -- not worth surfacing.
188
- }
189
- }
190
- signalGroup(pid, "SIGTERM");
191
- const exited = await Promise.race([exitPromise.then(() => true), sleep(gracePeriodMs).then(() => false)]);
192
- if (!exited) {
193
- signalGroup(pid, "SIGKILL");
194
- await exitPromise;
195
- }
196
- }
197
- async function restart(gracePeriodMs = DEFAULT_GRACE_PERIOD_MS) {
198
- // Safe regardless of the old process's state -- kill() is idempotent, and this
199
- // waits for it to be fully gone before spawnChild() reassigns state, so no
200
- // outgoing event can land on the incoming process.
201
- await kill(gracePeriodMs);
202
- spawnChild();
203
- }
204
- function readOutput() {
205
- const droppedBytes = totalBytesSeen - headBuffer.length - tailBuffer.length;
206
- if (droppedBytes <= 0) {
207
- // No real gap yet -- tailBuffer alone already covers everything seen so
208
- // far (headBuffer is a redundant prefix of it in this regime, since it
209
- // hasn't been outgrown by the tail window sliding past it).
210
- return tailBuffer;
211
- }
212
- return headBuffer + truncationMarker(totalBytesSeen, headBuffer.length + tailBuffer.length) + tailBuffer;
213
- }
214
- function outputInfo() {
215
- return { totalBytesSeen, truncated: totalBytesSeen > headBuffer.length + tailBuffer.length };
216
- }
217
- return {
218
- handle,
219
- readOutput,
220
- outputInfo,
221
- waitForExit: () => exitPromise,
222
- kill,
223
- restart,
224
- // A spawned process has no output that predates this runtime observing it.
225
- attachFence: () => null,
226
- };
227
- }
228
- /**
229
- * `process.kill(pid, 0)` sends no signal, only asks the kernel if delivery is
230
- * possible. `ESRCH` = no such pid; `EPERM` = a pid we don't own but that exists.
231
- *
232
- * Deliberate second copy of `orchestrator/src/attach-to-running-process.ts`'s
233
- * same-named function, not an import -- `orchestrator` depends on `controller`, so
234
- * the reverse import would be circular. Tiny and pure enough to duplicate safely.
235
- */
236
- export function isProcessAlive(pid) {
237
- try {
238
- process.kill(pid, 0);
239
- return true;
240
- }
241
- catch (error) {
242
- return error.code === "EPERM";
243
- }
244
- }
245
- const DEFAULT_ATTACH_POLL_INTERVAL_MS = 50;
246
- /**
247
- * `ManagedProcess` for a service attached to rather than spawned. Reads
248
- * `attach.logFilePath` fresh on every `readOutput()` -- same growing-whole-buffer
249
- * contract as a spawned process's in-memory pipe buffer.
250
- *
251
- * **`kill()` is a deliberate no-op, not a stub.** Descry did not spawn this process,
252
- * and `ATTACH_MODE_SCOPE_DISCLOSURE` is unconditional: attach mode never executes
253
- * code in or applies changes to what it observes. Ending observation is the honest
254
- * equivalent of "stop" -- the target keeps running. `restart()` throws for the same
255
- * reason: no command exists to relaunch it with.
256
- *
257
- * **Attach fencing (RT-N3).** `computeAttachFence` snapshots, at construction time
258
- * (i.e. the moment of attach), how much of `logFilePath` already existed and
259
- * whether some other process also holds it open -- see `attach-fencing.ts`. Exposed
260
- * via `attachFence()` for a caller building a `ProcessOutputSource` over
261
- * `readOutput()` to mark pre-existing content instead of reporting it as freshly
262
- * observed. `readOutput()` itself additionally refuses (rather than silently
263
- * mis-reading) if the file is ever found shorter than the largest size already
264
- * seen -- the same "cannot reconstruct a rotated/truncated buffer" rule
265
- * `orchestrator/src/polling-output-source.ts` enforces one layer up, duplicated
266
- * here for the same reason `isProcessAlive` is: this module cannot depend on
267
- * that one without a cycle, and the check is small and pure enough to repeat.
268
- */
269
- export function attachManagedProcess(options) {
270
- const { pid, logFilePath } = options.attach;
271
- if (!isProcessAlive(pid)) {
272
- throw new Error(`attachManagedProcess: pid ${String(pid)} for "${options.processId}" is not running — attach requires ` +
273
- `a target that already exists.`);
274
- }
275
- const fence = computeAttachFence(pid, logFilePath);
276
- let maxObservedByteLength = fence.attachOffsetBytes;
277
- const startedAt = new Date().toISOString();
278
- let exitedAt = null;
279
- let exitPromise = null;
280
- function handle() {
281
- if (exitedAt === null && !isProcessAlive(pid)) {
282
- exitedAt = new Date().toISOString();
283
- }
284
- return {
285
- processId: options.processId,
286
- // No real command to report -- disclosed rather than guessed.
287
- command: `<attached: pid ${String(pid)}, ${logFilePath}>`,
288
- pid,
289
- startedAt,
290
- exitedAt,
291
- // Not observable for a process we don't spawn or reap.
292
- exitCode: null,
293
- signal: null,
294
- serviceName: options.serviceName ?? null,
295
- port: options.port ?? null,
296
- attached: true,
297
- };
298
- }
299
- function readOutput() {
300
- let content;
301
- try {
302
- content = readFileSync(logFilePath, "utf8");
303
- }
304
- catch (error) {
305
- const detail = error instanceof Error ? error.message : String(error);
306
- throw new Error(`attachManagedProcess: could not read log file "${logFilePath}" for pid ${String(pid)}: ${detail}`);
307
- }
308
- const byteLength = Buffer.byteLength(content, "utf8");
309
- if (byteLength < maxObservedByteLength) {
310
- throw new Error(`attachManagedProcess: log file "${logFilePath}" for pid ${String(pid)} shrank from ${String(maxObservedByteLength)} ` +
311
- `to ${String(byteLength)} bytes between reads -- this looks like log rotation or truncation, not new output. ` +
312
- "The file-tail contract can't reconstruct a rotated/truncated buffer without either duplicating or dropping " +
313
- `lines. Reported rather than guessed. (This run's own attach offset was ${String(fence.attachOffsetBytes)} bytes.)`);
314
- }
315
- maxObservedByteLength = byteLength;
316
- return content;
317
- }
318
- function waitForExit() {
319
- exitPromise ??= new Promise((resolve) => {
320
- const poll = () => {
321
- if (!isProcessAlive(pid)) {
322
- exitedAt ??= new Date().toISOString();
323
- resolve({ exitCode: null, signal: null });
324
- return;
325
- }
326
- setTimeout(poll, DEFAULT_ATTACH_POLL_INTERVAL_MS);
327
- };
328
- poll();
329
- });
330
- return exitPromise;
331
- }
332
- function kill() {
333
- // Deliberate no-op -- see module doc above.
334
- return Promise.resolve();
335
- }
336
- function restart() {
337
- return Promise.reject(new Error(`attachManagedProcess: cannot restart an attached process (pid ${String(pid)}) — Descry did not spawn ` +
338
- `it and has no command to relaunch it with.`));
339
- }
340
- /**
341
- * RT-261's head/tail bound is a spawnProcess concern -- this path re-reads
342
- * `logFilePath` fresh on every call rather than accumulating a growing
343
- * in-memory buffer, so there is nothing here for that bound to apply to.
344
- * `truncated` stays honestly false; `totalBytesSeen` reports the real file
345
- * size observed on the most recent read (0 before the first one).
346
- */
347
- function outputInfo() {
348
- return { totalBytesSeen: maxObservedByteLength, truncated: false };
349
- }
350
- return { handle, readOutput, outputInfo, waitForExit, kill, restart, attachFence: () => fence };
351
- }
352
- const execFileAsync = promisify(execFile);
353
- function signalGroup(pid, signal) {
354
- try {
355
- // Negative pid targets the whole process group (orphan-prevention mechanism).
356
- process.kill(-pid, signal);
357
- }
358
- catch {
359
- // Group already gone -- not an error.
360
- }
361
- }
362
- function sleep(ms) {
363
- return new Promise((resolve) => setTimeout(resolve, ms));
364
- }
365
- //# sourceMappingURL=process-manager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"process-manager.js","sourceRoot":"","sources":["../src/process-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAoB,MAAM,qBAAqB,CAAC;AAE3E;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,KAAK,GAAG,YAAY,EAAE,CAAC;QAC7B,KAA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ACT,CAAC;gBACD,UAAU,CAAC,IAAI,EAAE,+BAA+B,CAAC,CAAC;YACpD,CAAC,CAAC;YACF,IAAI,EAAE,CAAC;QACT,CAAC,CAAC,CAAC;QACH,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,SAAS,IAAI;QACX,4CAA4C;QAC5C,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED,SAAS,OAAO;QACd,OAAO,OAAO,CAAC,MAAM,CACnB,IAAI,KAAK,CACP,iEAAiE,MAAM,CAAC,GAAG,CAAC,2BAA2B;YACrG,4CAA4C,CAC/C,CACF,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACH,SAAS,UAAU;QACjB,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IACrE,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC;AAClG,CAAC;AAED,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAE1C,SAAS,WAAW,CAAC,GAAW,EAAE,MAAsB;IACtD,IAAI,CAAC;QACH,8EAA8E;QAC9E,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,sCAAsC;IACxC,CAAC;AACH,CAAC;AAED,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC"}
@@ -1,122 +0,0 @@
1
- /**
2
- * Readiness (§6): "readiness must not equal 'process exists.'" Mechanisms: HTTP
3
- * check, TCP/port check, log pattern, subprocess command, or a caller hook
4
- * (consolidates the plan's "framework readiness hook" and "user-defined readiness"
5
- * into one predicate shape).
6
- *
7
- * **`command` is not `custom-hook` (RT-193).** `custom-hook` runs a caller's
8
- * in-process predicate; `command` runs a real subprocess and reads its exit code --
9
- * built once so a caller with a real CLI health check (`pg_isready`) doesn't have to
10
- * shell out from inside a hand-written hook.
11
- *
12
- * **What `ready: true` does not claim (RT-024).** All mechanisms answer "is
13
- * something listening/responding," none confirm it's the process *this* spawn
14
- * produced -- a stale listener from an already-dead run satisfies `http`/`tcp-port`
15
- * identically. `log-pattern` only carries the stronger this-run guarantee if `read`
16
- * is wired to this execution's own `readOutput()` (caller discipline, not enforced
17
- * by the type). An ephemeral port closes this gap by construction; a fixed,
18
- * guessable port doesn't. Found via a real 30s collector timeout that looked like a
19
- * Playwright bug and was actually a wait on an orphaned process from a dead session
20
- * (RT-024).
21
- *
22
- * **A single probe attempt cannot outlive `timeoutMs` (RT-030).** `http`/`tcp-port`
23
- * bind I/O to the remaining time until `deadline`, not a fresh per-attempt budget --
24
- * measured: an unbound `fetch` here let `awaitReadiness` run 8s+ past a 3s budget.
25
- * `command` gets the same treatment via `execFile`'s `timeout`. `custom-hook` is not
26
- * wrapped this way -- a caller predicate owns its own timeout, same as every other
27
- * `Collector` callback contract here.
28
- */
29
- export declare const READINESS_MECHANISMS: readonly ["http", "tcp-port", "log-pattern", "command", "custom-hook"];
30
- export type ReadinessMechanism = (typeof READINESS_MECHANISMS)[number];
31
- /**
32
- * How strongly a successful readiness result establishes that the answering
33
- * process is THIS run's own -- RT-024. `"verified"`: a real kernel-state
34
- * check (`process-identity.ts`) or a mechanism that is this-run-bound by
35
- * construction (a directly-executed `command`, or `log-pattern` reading a
36
- * branded `ProcessOutputReader`) confirmed it. `"unverified"`: the mechanism
37
- * succeeded but nothing confirmed identity -- disclosed, not hidden.
38
- * `"not-applicable"`: nothing succeeded, so no identity claim is being made.
39
- */
40
- export declare const READINESS_IDENTITY_LEVELS: readonly ["verified", "unverified", "not-applicable"];
41
- export type ReadinessIdentity = (typeof READINESS_IDENTITY_LEVELS)[number];
42
- export interface HttpReadinessCheck {
43
- readonly kind: "http";
44
- readonly url: string;
45
- readonly expectedStatus?: number;
46
- /**
47
- * The pid this run spawned (or attached to) for this service. When set, a
48
- * successful connection is only accepted once `verifyListeningSocketOwner`
49
- * confirms this pid actually owns the listening socket -- otherwise the
50
- * probe reports not-ready rather than trusting whoever answered. Omitted
51
- * means the caller has no pid to bind to (or the mechanism backing this
52
- * service, e.g. a container, can't be verified this way) and the result is
53
- * disclosed as `identity: "unverified"`, never silently upgraded.
54
- */
55
- readonly expectedPid?: number;
56
- }
57
- export interface TcpPortReadinessCheck {
58
- readonly kind: "tcp-port";
59
- readonly host: string;
60
- readonly port: number;
61
- /** See `HttpReadinessCheck.expectedPid` -- same guarantee, same disclosure. */
62
- readonly expectedPid?: number;
63
- }
64
- declare const PROCESS_OUTPUT_READER_BRAND: unique symbol;
65
- /**
66
- * A `LogPatternReadinessCheck.read` may only be one of these, and the only
67
- * way to make one is `createProcessOutputReader`. This is RT-024's own
68
- * finding turned into a type: "log-pattern only carries the stronger
69
- * this-run guarantee if `read` is wired to this execution's own
70
- * `readOutput()` -- caller discipline, not enforced by the type." A plain
71
- * `() => string` closure -- however it's actually wired -- no longer
72
- * type-checks; a caller must go through the constructor below, which exists
73
- * precisely so the only inputs are a real `ManagedProcess.readOutput` (or an
74
- * equivalent this execution actually owns).
75
- */
76
- export interface ProcessOutputReader {
77
- readonly [PROCESS_OUTPUT_READER_BRAND]: true;
78
- read(): string;
79
- }
80
- /** The only way to mint a `ProcessOutputReader` -- wrap the real output source this execution owns (`ManagedProcess.readOutput`, or an equivalent). */
81
- export declare function createProcessOutputReader(readOutput: () => string): ProcessOutputReader;
82
- export interface LogPatternReadinessCheck {
83
- readonly kind: "log-pattern";
84
- /**
85
- * Tested against `read.read()`'s full return value on every poll. Backed by
86
- * `readOutput()`, an unbounded, growing stdout+stderr buffer -- an unbounded
87
- * quantifier before an absent-able literal (the ReDoS shape RT-069/RT-070 already
88
- * fixed elsewhere) would backtrack catastrophically here on every poll. Disclosed
89
- * risk, not fixed: the regex is the caller's to bound, not this module's.
90
- */
91
- readonly pattern: RegExp;
92
- /** A `ProcessOutputReader` — see that type's doc. Only `createProcessOutputReader` can produce one, which is what makes this-execution's-own-output a type guarantee rather than a convention. */
93
- readonly read: ProcessOutputReader;
94
- }
95
- export interface CommandReadinessCheck {
96
- readonly kind: "command";
97
- readonly command: string;
98
- readonly args?: readonly string[];
99
- /** Defaults to this process's own `cwd` (`execFile`'s own default) when omitted. */
100
- readonly cwd?: string;
101
- }
102
- export interface CustomHookReadinessCheck {
103
- readonly kind: "custom-hook";
104
- readonly check: () => Promise<boolean>;
105
- }
106
- export type ReadinessCheck = HttpReadinessCheck | TcpPortReadinessCheck | LogPatternReadinessCheck | CommandReadinessCheck | CustomHookReadinessCheck;
107
- export interface ReadinessResult {
108
- readonly ready: boolean;
109
- /** Which mechanism succeeded — null when none did within the timeout. */
110
- readonly mechanism: ReadinessMechanism | null;
111
- readonly elapsedMs: number;
112
- readonly reason: string | null;
113
- /** How strongly `ready: true` establishes this-run's-own-process (RT-024). See `ReadinessIdentity`. `"not-applicable"` whenever `ready` is `false` — nothing succeeded, so no identity claim is made either way. */
114
- readonly identity: ReadinessIdentity;
115
- }
116
- export interface AwaitReadinessOptions {
117
- readonly timeoutMs: number;
118
- readonly pollIntervalMs?: number;
119
- }
120
- export declare function awaitReadiness(checks: readonly ReadinessCheck[], options: AwaitReadinessOptions): Promise<ReadinessResult>;
121
- export {};
122
- //# sourceMappingURL=readiness.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"readiness.d.ts","sourceRoot":"","sources":["../src/readiness.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAMH,eAAO,MAAM,oBAAoB,wEAAyE,CAAC;AAC3G,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvE;;;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