@descryy/runtime-orchestrator 0.2.1 → 0.4.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 (46) hide show
  1. package/LICENSE +6 -0
  2. package/dist/attach-to-running-jvm-process.d.ts +45 -98
  3. package/dist/attach-to-running-jvm-process.d.ts.map +1 -1
  4. package/dist/attach-to-running-jvm-process.js +206 -136
  5. package/dist/attach-to-running-jvm-process.js.map +1 -1
  6. package/dist/attach-to-running-node-process.d.ts +45 -103
  7. package/dist/attach-to-running-node-process.d.ts.map +1 -1
  8. package/dist/attach-to-running-node-process.js +90 -115
  9. package/dist/attach-to-running-node-process.js.map +1 -1
  10. package/dist/attach-to-running-process.d.ts +32 -70
  11. package/dist/attach-to-running-process.d.ts.map +1 -1
  12. package/dist/attach-to-running-process.js +26 -54
  13. package/dist/attach-to-running-process.js.map +1 -1
  14. package/dist/cdp-client.d.ts +8 -18
  15. package/dist/cdp-client.d.ts.map +1 -1
  16. package/dist/cdp-client.js +9 -22
  17. package/dist/cdp-client.js.map +1 -1
  18. package/dist/cgroup-partial-restriction.d.ts +42 -89
  19. package/dist/cgroup-partial-restriction.d.ts.map +1 -1
  20. package/dist/cgroup-partial-restriction.js +44 -91
  21. package/dist/cgroup-partial-restriction.js.map +1 -1
  22. package/dist/collector-version.d.ts +3 -8
  23. package/dist/collector-version.d.ts.map +1 -1
  24. package/dist/collector-version.js +3 -8
  25. package/dist/collector-version.js.map +1 -1
  26. package/dist/instrumented-execution.d.ts +30 -73
  27. package/dist/instrumented-execution.d.ts.map +1 -1
  28. package/dist/instrumented-execution.js +121 -251
  29. package/dist/instrumented-execution.js.map +1 -1
  30. package/dist/jvm-agent/build.d.ts +29 -53
  31. package/dist/jvm-agent/build.d.ts.map +1 -1
  32. package/dist/jvm-agent/build.js +34 -61
  33. package/dist/jvm-agent/build.js.map +1 -1
  34. package/dist/polling-output-source.d.ts +8 -19
  35. package/dist/polling-output-source.d.ts.map +1 -1
  36. package/dist/polling-output-source.js +14 -31
  37. package/dist/polling-output-source.js.map +1 -1
  38. package/dist/profile-backend-observation.d.ts +26 -53
  39. package/dist/profile-backend-observation.d.ts.map +1 -1
  40. package/dist/profile-backend-observation.js +26 -55
  41. package/dist/profile-backend-observation.js.map +1 -1
  42. package/dist/respawn-and-supervise.d.ts +39 -72
  43. package/dist/respawn-and-supervise.d.ts.map +1 -1
  44. package/dist/respawn-and-supervise.js +43 -84
  45. package/dist/respawn-and-supervise.js.map +1 -1
  46. package/package.json +14 -9
@@ -2,45 +2,28 @@
2
2
  * Profile-driven backend traffic observation (RT-197, DEC-271).
3
3
  *
4
4
  * `InboundProxy` (RT-192) is wired into `runInstrumentedExecution` via
5
- * `frontWithInboundProxy` — the **local, Descry-booted** half of DEC-271.
6
- * The other half, `@descryy/runtime-remote-log-ingestion`, existed with real
7
- * tests (`correlator.test.ts`, `file-log-adapter.test.ts`) and **zero
8
- * callers outside its own package** — the same "built, never wired" shape
9
- * DEC-270 found for `safety-gate.ts`'s `evaluateAction`. This module is
10
- * that missing wiring, and the decision point DEC-271's own table
11
- * describes: given an `EnvironmentProfile`, decide which of the two
12
- * mechanisms applies, and never both.
5
+ * `frontWithInboundProxy` — the local, Descry-booted half of DEC-271. This module is
6
+ * the other half: given an `EnvironmentProfile`, decide which of the two mechanisms
7
+ * (inbound proxy vs. `@descryy/runtime-remote-log-ingestion`) applies, never both.
13
8
  *
14
- * **The mutual-exclusivity guarantee is structural, not asserted.** This
15
- * file does not import `createInboundProxy` nothing in it, in any branch,
16
- * is capable of constructing a proxy. A profile whose `mode` is `"remote"`
17
- * or `"production"` can only ever reach `ingestFileLog`; a profile whose
18
- * mode is `"localBooted"` is refused here with a `validationError` before
19
- * any ingestion is attempted, on the grounds that DEC-271 names no
20
- * ingestion mechanism for a profile Descry itself booted (that profile's
21
- * proxy path is `runInstrumentedExecution`'s `frontWithInboundProxy`,
22
- * driven by `ExecutionConfiguration`, not by this function).
9
+ * **Mutual exclusivity is structural, not asserted** — this file never imports
10
+ * `createInboundProxy`, so nothing here can construct a proxy. `"localBooted"` is
11
+ * refused with a `validationError`: DEC-271 names no ingestion mechanism for a
12
+ * profile Descry itself booted (its proxy path is `frontWithInboundProxy`, not this
13
+ * function).
23
14
  *
24
- * `"localAttached"` is refused the same way, for a different reason,
25
- * disclosed rather than guessed at: DEC-271's own table names exactly two
26
- * rows "local, booted" and "remote (staging/preview) and production"
27
- * and says nothing about the third and fourth of DEC-266's four kinds.
28
- * Local-attached is not remote infra (a proxy is not structurally
29
- * forbidden the way it is for a target Descry does not own), but it is
30
- * also not a process Descry started (so `runInstrumentedExecution`'s
31
- * readiness-then-front sequencing, which RT-024 depends on, does not
32
- * apply). Inventing an answer for a case the decision text does not cover
33
- * would be exactly the guess DEC-266/DEC-271 both reject; this function
34
- * says so and refuses instead.
15
+ * `"localAttached"` is refused too, disclosed rather than guessed: DEC-271's table
16
+ * covers only "local, booted" and "remote/production", not `"localAttached"`
17
+ * (RT-024's readiness-then-front sequencing doesn't apply to a process Descry didn't
18
+ * start). Inventing an answer here would be the guess DEC-266/DEC-271 both reject.
35
19
  */
36
20
  import { EvidenceStore } from "@descryy/runtime-evidence-store";
37
21
  import { ingestFileLog } from "@descryy/runtime-remote-log-ingestion";
38
22
  import { COLLECTOR_VERSION } from "./collector-version.js";
39
23
  /**
40
- * Pure decision function — DEC-271's table read directly off
41
- * `EnvironmentProfile.mode`. Never reaches the network or the filesystem;
42
- * see `runRemoteLogObservation` below for the mechanism that actually
43
- * performs ingestion.
24
+ * Pure decision function — DEC-271's table read off `EnvironmentProfile.mode`.
25
+ * Never touches network or filesystem; `runRemoteLogObservation` below does the
26
+ * actual ingestion.
44
27
  */
45
28
  export function backendObservationMechanismFor(profile) {
46
29
  if (profile.mode === "localBooted") {
@@ -55,31 +38,22 @@ export function backendObservationMechanismFor(profile) {
55
38
  }
56
39
  return { kind: "remoteLogIngestion", config: profile.remoteLogSource };
57
40
  }
58
- // mode === "localAttached" -- see this file's header for why this is a
59
- // disclosed gap rather than a guessed answer.
41
+ // localAttached: disclosed gap, see file header.
60
42
  return {
61
43
  kind: "none",
62
44
  reason: `profile "${profile.name}" is mode "localAttached" -- DEC-271 names a mechanism for neither local-attached nor any third case; not guessed at here.`,
63
45
  };
64
46
  }
65
47
  /**
66
- * The remote/production half of DEC-271, run against one profile's
67
- * declared `remoteLogSource`. Reads the source **once** (today's only
68
- * concrete adapter, `ingestFileLog`, is one-shot per its own doc — see
69
- * `file-log-adapter.ts`) and writes every line through `EvidenceStore` as
70
- * `BACKEND_LOG` evidence, so redaction runs (plan §28) exactly the same
71
- * way it does for `LogCollector`'s local-process output.
48
+ * The remote/production half of DEC-271. Reads the profile's `remoteLogSource`
49
+ * **once** (`ingestFileLog` is one-shot, see `file-log-adapter.ts`) and writes each
50
+ * line through `EvidenceStore` as `BACKEND_LOG`, so redaction runs the same as it
51
+ * does for `LogCollector`'s local-process output.
72
52
  *
73
- * **Refuses rather than guesses** in three cases, each reported as a
74
- * `validationError` rather than a silently empty result:
75
- * 1. `profile.mode` is not `"remote"`/`"production"` (see this file's own
76
- * header for the disclosed local-attached gap).
77
- * 2. no `remoteLogSource` is declared (DEC-271's "not observable here").
78
- * 3. `remoteLogSource.location.kind` is not `"file"` — the only concrete
79
- * adapter this pass has; `"command"`/`"url"` are named-and-typed but
80
- * unbuilt, per `log-source-config.ts`'s own doc.
81
- *
82
- * **Never constructs `InboundProxy`.** This file does not import it.
53
+ * Refuses (via `validationError`, never silently empty) when: mode isn't
54
+ * remote/production; no `remoteLogSource` declared; or `location.kind` isn't
55
+ * `"file"` the only built adapter (`"command"`/`"url"` are typed but unbuilt, see
56
+ * `log-source-config.ts`). Never constructs `InboundProxy` — not imported here.
83
57
  */
84
58
  export async function runRemoteLogObservation(input) {
85
59
  const { profile, executionId, store } = input;
@@ -122,11 +96,8 @@ export async function runRemoteLogObservation(input) {
122
96
  graphNodeId: null,
123
97
  sourceLocation: null,
124
98
  stackTrace: null,
125
- // The observation itself (a line the target already logged) is not
126
- // probabilistic -- same reasoning LogCollector's own emit gives
127
- // for confidence: 1. Whether a LATER correlation to a captured
128
- // request holds is a separate, lower-confidence question
129
- // (`correlateLogLine`'s own confidence tiers), not this field's.
99
+ // the line itself isn't probabilistic; a later correlation to a captured
100
+ // request is a separate, lower-confidence question (correlateLogLine's tiers)
130
101
  confidence: 1,
131
102
  collectorVersion: COLLECTOR_VERSION,
132
103
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"profile-backend-observation.js","sourceRoot":"","sources":["../src/profile-backend-observation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,aAAa,EAAwD,MAAM,uCAAuC,CAAC;AAE5H,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAc3D;;;;;GAKG;AACH,MAAM,UAAU,8BAA8B,CAAC,OAA2B;IACxE,IAAI,OAAO,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;QACnC,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC;IAClC,CAAC;IACD,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;QAC/D,IAAI,OAAO,CAAC,eAAe,IAAI,IAAI,EAAE,CAAC;YACpC,OAAO;gBACL,IAAI,EAAE,MAAM;gBACZ,MAAM,EAAE,YAAY,OAAO,CAAC,IAAI,cAAc,OAAO,CAAC,IAAI,4FAA4F;aACvJ,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,oBAAoB,EAAE,MAAM,EAAE,OAAO,CAAC,eAAe,EAAE,CAAC;IACzE,CAAC;IACD,uEAAuE;IACvE,8CAA8C;IAC9C,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,YAAY,OAAO,CAAC,I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AE,eAAe,EAAE,4CAA4C,OAAO,CAAC,IAAI,MAAM,MAAM,EAAE,EAAE,CAAC;IACnH,CAAC;IAED,MAAM,QAAQ,GAAe,EAAE,CAAC;IAChC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,QAAQ,CAAC,IAAI,CACX,KAAK,CAAC,KAAK,CAAC;YACV,WAAW;YACX,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACrD,MAAM,EAAE,iBAAiB;YACzB,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,IAAI;YACb,SAAS,EAAE,aAAa;YACxB,OAAO,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,WAAW,EAAE,sBAAsB,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE;YACtF,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,aAAa,EAAE,IAAI;YACnB,WAAW,EAAE,IAAI;YACjB,cAAc,EAAE,IAAI;YACpB,UAAU,EAAE,IAAI;YAChB,mEAAmE;YACnE,gEAAgE;YAChE,+DAA+D;YAC/D,yDAAyD;YACzD,iEAAiE;YACjE,UAAU,EAAE,CAAC;YACb,gBAAgB,EAAE,iBAAiB;SACpC,CAAC,CACH,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC;AAC7C,CAAC"}
1
+ {"version":3,"file":"profile-backend-observation.js","sourceRoot":"","sources":["../src/profile-backend-observation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,aAAa,EAAwD,MAAM,uCAAuC,CAAC;AAE5H,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAY3D;;;;GAIG;AACH,MAAM,UA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EAAE,IAAI;YACjB,cAAc,EAAE,IAAI;YACpB,UAAU,EAAE,IAAI;YAChB,yEAAyE;YACzE,8EAA8E;YAC9E,UAAU,EAAE,CAAC;YACb,gBAAgB,EAAE,iBAAiB;SACpC,CAAC,CACH,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC;AAC7C,CAAC"}
@@ -1,54 +1,34 @@
1
1
  /**
2
- * Respawn-and-supervise: a real, separate execution mode next to attach
3
- * mode, not a change to attach mode itself.
2
+ * Respawn-and-supervise: a separate execution mode next to attach mode, not a
3
+ * change to attach mode itself.
4
4
  *
5
- * **The tradeoff this makes, stated up front, because it must never be
6
- * applied silently.** Attach mode (`attach-to-running-process.ts` and its
7
- * siblings) reaches a process that was already running, unconfined, before
8
- * Descry touched it -- `sandbox.ts`'s own module doc (`@descryhq-wq/runtime-
9
- * controller`) says plainly there is no honest way to retroactively contain
10
- * that process. This module does not try. It kills the attached target and
11
- * spawns a fresh, equivalent process through the EXISTING `spawnProcess()`
12
- * (`@descryy/runtime-controller`), which already gets full sandboxing
13
- * (`applySandbox`, `applyResourceLimits`) for anything it spawns -- the same
14
- * mechanism `ExecutionController.run()` uses, not a parallel one. The price
15
- * is real: in-memory state, open connections, anything the old process held
16
- * that was never persisted is gone the moment it is killed. A caller must
17
- * choose this explicitly; nothing in this repo switches a running attach
18
- * into a respawn on its own.
5
+ * **The tradeoff, stated up front must never apply silently.** Attach mode
6
+ * reaches an already-running, unconfined process; there is no honest way to
7
+ * retroactively sandbox it (`sandbox.ts`). This module doesn't try it kills the
8
+ * attached target and spawns a fresh equivalent via the existing `spawnProcess()`,
9
+ * which gets full sandboxing for anything it spawns. Price: in-memory state, open
10
+ * connections, anything unpersisted is gone the moment the old process is killed.
11
+ * A caller must choose this explicitly nothing upgrades an attach into a respawn
12
+ * on its own.
19
13
  *
20
- * **How this module learns what to respawn -- the design question this
21
- * lane was told not to guess past.** This repo has a standing, named
22
- * precedent for exactly this shape of question: RT-032 ("declared, never
23
- * inferred" -- `ServiceConfiguration.dependsOn`, `substitutePortPlaceholders`,
24
- * `discoverRunner`'s refusal to sniff a test framework from `package.json`).
25
- * The caller-declared path (`RespawnCommand` with `source: "caller-declared"`)
26
- * is the one this module recommends and the only one its own convenience
27
- * default reaches for. A `/proc/<pid>/cmdline` readback (Linux-only, and
28
- * genuinely insufficient on its own -- it cannot recover env vars set
29
- * programmatically before `exec`, file descriptors already open and handed
30
- * off, or a cwd that changed after launch) is real, but explicitly a
31
- * best-effort convenience, never the default: `inferRespawnCommandFromProc`
32
- * exists, is opt-in, and labels its own output `source: "proc-cmdline-
33
- * inferred"` so nothing downstream can mistake an inference for a
34
- * declaration. The two are never blurred into one shape.
14
+ * **How this learns what to respawn.** Follows RT-032's "declared, never inferred"
15
+ * precedent: caller-declared (`source: "caller-declared"`) is the recommended,
16
+ * default path. `/proc/<pid>/cmdline` readback is a real but best-effort,
17
+ * opt-in-only fallback (`inferRespawnCommandFromProc`), labelled `source:
18
+ * "proc-cmdline-inferred"` so it's never mistaken for a declaration.
35
19
  *
36
- * **Killing the old process.** `respawnAndSupervise` does not assume it owns
37
- * the target's process group -- an attached-to process was not spawned by
38
- * this runtime and may not even be its own group leader, so this signals
39
- * the individual pid only (SIGTERM, then SIGKILL after `gracePeriodMs` if
40
- * still alive), mirroring `process-manager.ts`'s own two-stage `kill()`
41
- * without reusing its group-kill (`signalGroup`), which is `spawnProcess`'s
42
- * own escape hatch for a group *it* created.
20
+ * **Killing the old process.** Doesn't assume ownership of the target's process
21
+ * group it may not even be its own group leader so this signals the individual
22
+ * pid only (SIGTERM, then SIGKILL after `gracePeriodMs`), not `spawnProcess`'s
23
+ * group-kill escape hatch (`signalGroup`), which is only valid for a group it
24
+ * created itself.
43
25
  */
44
26
  import { type ManagedProcess, type SpawnProcessOptions } from "@descryy/runtime-controller";
45
27
  export type RespawnCommandSource = "caller-declared" | "proc-cmdline-inferred";
46
28
  /**
47
- * Everything `spawnProcess` needs to relaunch an equivalent of the killed
48
- * target, plus `source` -- the one field that is never optional, so a
49
- * caller (and anything logging or auditing this decision later) can always
50
- * tell a real declaration from a best-effort guess at a glance, never by
51
- * inspecting provenance out of band.
29
+ * Everything `spawnProcess` needs to relaunch the killed target, plus `source`
30
+ * (never optional) so a real declaration is always distinguishable from a
31
+ * best-effort guess.
52
32
  */
53
33
  export interface RespawnCommand {
54
34
  readonly command: string;
@@ -61,7 +41,7 @@ export interface RespawnAndSuperviseOptions {
61
41
  readonly processId: string;
62
42
  /** The pid of the already-running, attached-to target. Verified alive before anything is killed. */
63
43
  readonly targetPid: number;
64
- /** How the replacement process is launched. See this module's own doc for why `source: "caller-declared"` is the recommended, default-reachable path. */
44
+ /** How the replacement process is launched. See file header: `source: "caller-declared"` is the recommended path. */
65
45
  readonly respawn: RespawnCommand;
66
46
  /** How long to wait for the old target to exit after SIGTERM before escalating to SIGKILL. Same default as `ManagedProcess.kill()`. */
67
47
  readonly gracePeriodMs?: number;
@@ -72,7 +52,7 @@ export interface RespawnAndSuperviseOptions {
72
52
  readonly networkPolicy?: SpawnProcessOptions["networkPolicy"];
73
53
  }
74
54
  export interface RespawnAndSuperviseResult {
75
- /** The freshly spawned, fully-supervised (and, if declared, sandboxed) replacement -- everything `spawnProcess()` itself returns, unwrapped. */
55
+ /** The freshly spawned, supervised (sandboxed if declared) replacement `spawnProcess()`'s own return, unwrapped. */
76
56
  readonly managedProcess: ManagedProcess;
77
57
  readonly killedPid: number;
78
58
  /** Whether the old target was observed to exit within `gracePeriodMs` of SIGTERM, or needed SIGKILL. Either way this does not return until the old pid is confirmed dead. */
@@ -81,39 +61,26 @@ export interface RespawnAndSuperviseResult {
81
61
  }
82
62
  /**
83
63
  * Kills the process at `options.targetPid` and spawns a fresh, supervised,
84
- * (optionally) sandboxed replacement via `spawnProcess()`.
64
+ * optionally sandboxed replacement via `spawnProcess()`.
85
65
  *
86
- * **Not a silent behavior change to attach mode.** A caller reaches this
87
- * function by name, explicitly, instead of one of the `attachToRunning*`
88
- * functions -- there is no code path in this repo that upgrades an attach
89
- * into a respawn on its own. `ATTACH_MODE_SCOPE_DISCLOSURE`
90
- * (`@descryy/runtime-controller`) still governs attach mode itself,
91
- * unconditionally, whether or not a caller ever reaches for this
92
- * alternative.
66
+ * Not a silent behavior change to attach mode reached only by explicit call,
67
+ * never an automatic upgrade path. `ATTACH_MODE_SCOPE_DISCLOSURE` still governs
68
+ * attach mode itself regardless.
93
69
  *
94
- * Throws (does not silently proceed) if `targetPid` is not alive at call
95
- * time, matching `attachToRunningProcess`'s own "refuse rather than operate
96
- * on a target that does not exist" contract.
70
+ * Throws if `targetPid` isn't alive at call time, matching `attachToRunningProcess`'s
71
+ * refuse-rather-than-operate-on-nonexistent-target contract.
97
72
  */
98
73
  export declare function respawnAndSupervise(options: RespawnAndSuperviseOptions): Promise<RespawnAndSuperviseResult>;
99
74
  /**
100
- * The opt-in, disclosed, BEST-EFFORT convenience this module's own doc
101
- * names -- never the default `respawnAndSupervise` reaches for on its own.
102
- * Reads `/proc/<pid>/cmdline`, `/proc/<pid>/cwd` and `/proc/<pid>/environ`
103
- * to reconstruct a `RespawnCommand`, labelling it `source:
104
- * "proc-cmdline-inferred"` so it can never be mistaken for a caller
105
- * declaration downstream.
75
+ * Opt-in, best-effort convenience never the default. Reads `/proc/<pid>/cmdline`,
76
+ * `/cwd` and `/environ` to reconstruct a `RespawnCommand`, labelled `source:
77
+ * "proc-cmdline-inferred"` so it's never mistaken for a caller declaration.
106
78
  *
107
- * **Real, disclosed limitations, not hypothetical ones:** Linux-only (no
108
- * `/proc` on macOS/Windows); env vars a process set on itself
109
- * programmatically after `exec` (as opposed to what it was launched with)
110
- * are invisible here, because `/proc/<pid>/environ` only ever reflects the
111
- * environment at `execve()` time; already-open file descriptors handed to
112
- * the original process (an inherited socket, a pipe from its own parent)
113
- * have no representation in a command line at all and cannot be recovered
114
- * by any means this function has. Returns `null` -- never throws, never
115
- * guesses a partial answer -- when `/proc/<pid>/cmdline` cannot be read
116
- * (platform mismatch, pid gone, permission denied) or is empty.
79
+ * Disclosed limitations: Linux-only; `/proc/<pid>/environ` reflects only the
80
+ * environment at `execve()` time, so env vars set programmatically after exec are
81
+ * invisible; already-open file descriptors (inherited sockets/pipes) have no
82
+ * command-line representation and can't be recovered. Returns `null` — never
83
+ * throws, never guesses partially when cmdline can't be read or is empty.
117
84
  */
118
85
  export declare function inferRespawnCommandFromProc(pid: number, platform?: NodeJS.Platform): RespawnCommand | null;
119
86
  //# sourceMappingURL=respawn-and-supervise.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"respawn-and-supervise.d.ts","sourceRoot":"","sources":["../src/respawn-and-supervise.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEH,OAAO,EAAgB,KAAK,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAI1G,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,GAAG,uBAAuB,CAAC;AAE/E;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IAC5D,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC;CACvC;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,oGAAoG;IACpG,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,yJAAyJ;IACzJ,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,uIAAuI;IACvI,QAAQ,CAA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AC,GAAG,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAM,CAAC,QAA2B,GAAG,cAAc,GAAG,IAAI,CA4C5H"}
@@ -1,45 +1,27 @@
1
1
  /**
2
- * Respawn-and-supervise: a real, separate execution mode next to attach
3
- * mode, not a change to attach mode itself.
2
+ * Respawn-and-supervise: a separate execution mode next to attach mode, not a
3
+ * change to attach mode itself.
4
4
  *
5
- * **The tradeoff this makes, stated up front, because it must never be
6
- * applied silently.** Attach mode (`attach-to-running-process.ts` and its
7
- * siblings) reaches a process that was already running, unconfined, before
8
- * Descry touched it -- `sandbox.ts`'s own module doc (`@descryhq-wq/runtime-
9
- * controller`) says plainly there is no honest way to retroactively contain
10
- * that process. This module does not try. It kills the attached target and
11
- * spawns a fresh, equivalent process through the EXISTING `spawnProcess()`
12
- * (`@descryy/runtime-controller`), which already gets full sandboxing
13
- * (`applySandbox`, `applyResourceLimits`) for anything it spawns -- the same
14
- * mechanism `ExecutionController.run()` uses, not a parallel one. The price
15
- * is real: in-memory state, open connections, anything the old process held
16
- * that was never persisted is gone the moment it is killed. A caller must
17
- * choose this explicitly; nothing in this repo switches a running attach
18
- * into a respawn on its own.
5
+ * **The tradeoff, stated up front must never apply silently.** Attach mode
6
+ * reaches an already-running, unconfined process; there is no honest way to
7
+ * retroactively sandbox it (`sandbox.ts`). This module doesn't try it kills the
8
+ * attached target and spawns a fresh equivalent via the existing `spawnProcess()`,
9
+ * which gets full sandboxing for anything it spawns. Price: in-memory state, open
10
+ * connections, anything unpersisted is gone the moment the old process is killed.
11
+ * A caller must choose this explicitly nothing upgrades an attach into a respawn
12
+ * on its own.
19
13
  *
20
- * **How this module learns what to respawn -- the design question this
21
- * lane was told not to guess past.** This repo has a standing, named
22
- * precedent for exactly this shape of question: RT-032 ("declared, never
23
- * inferred" -- `ServiceConfiguration.dependsOn`, `substitutePortPlaceholders`,
24
- * `discoverRunner`'s refusal to sniff a test framework from `package.json`).
25
- * The caller-declared path (`RespawnCommand` with `source: "caller-declared"`)
26
- * is the one this module recommends and the only one its own convenience
27
- * default reaches for. A `/proc/<pid>/cmdline` readback (Linux-only, and
28
- * genuinely insufficient on its own -- it cannot recover env vars set
29
- * programmatically before `exec`, file descriptors already open and handed
30
- * off, or a cwd that changed after launch) is real, but explicitly a
31
- * best-effort convenience, never the default: `inferRespawnCommandFromProc`
32
- * exists, is opt-in, and labels its own output `source: "proc-cmdline-
33
- * inferred"` so nothing downstream can mistake an inference for a
34
- * declaration. The two are never blurred into one shape.
14
+ * **How this learns what to respawn.** Follows RT-032's "declared, never inferred"
15
+ * precedent: caller-declared (`source: "caller-declared"`) is the recommended,
16
+ * default path. `/proc/<pid>/cmdline` readback is a real but best-effort,
17
+ * opt-in-only fallback (`inferRespawnCommandFromProc`), labelled `source:
18
+ * "proc-cmdline-inferred"` so it's never mistaken for a declaration.
35
19
  *
36
- * **Killing the old process.** `respawnAndSupervise` does not assume it owns
37
- * the target's process group -- an attached-to process was not spawned by
38
- * this runtime and may not even be its own group leader, so this signals
39
- * the individual pid only (SIGTERM, then SIGKILL after `gracePeriodMs` if
40
- * still alive), mirroring `process-manager.ts`'s own two-stage `kill()`
41
- * without reusing its group-kill (`signalGroup`), which is `spawnProcess`'s
42
- * own escape hatch for a group *it* created.
20
+ * **Killing the old process.** Doesn't assume ownership of the target's process
21
+ * group it may not even be its own group leader so this signals the individual
22
+ * pid only (SIGTERM, then SIGKILL after `gracePeriodMs`), not `spawnProcess`'s
23
+ * group-kill escape hatch (`signalGroup`), which is only valid for a group it
24
+ * created itself.
43
25
  */
44
26
  import { spawnProcess } from "@descryy/runtime-controller";
45
27
  import { readFileSync, readlinkSync } from "node:fs";
@@ -62,14 +44,10 @@ async function waitForDeath(pid, deadlineMs) {
62
44
  return !isProcessAlive(pid);
63
45
  }
64
46
  /**
65
- * Kills `pid` directly (not its process group -- see this module's own doc
66
- * for why), escalating from SIGTERM to SIGKILL after `gracePeriodMs`.
67
- * Resolves once the pid is confirmed dead, or throws if it survives even
68
- * SIGKILL (a defunct-but-unreapable zombie owned by another process tree,
69
- * or a permission boundary this caller's uid cannot cross) -- refusing to
70
- * report success it did not actually observe, the same discipline
71
- * `ManagedProcess.kill()` already holds for processes this runtime spawned
72
- * itself.
47
+ * Kills `pid` directly (not its process group, see file header), escalating
48
+ * SIGTERM to SIGKILL after `gracePeriodMs`. Throws if it survives even SIGKILL
49
+ * (unreapable zombie, or a permission boundary) rather than reporting an unobserved
50
+ * success.
73
51
  */
74
52
  async function killTarget(pid, gracePeriodMs) {
75
53
  if (!isProcessAlive(pid))
@@ -78,9 +56,7 @@ async function killTarget(pid, gracePeriodMs) {
78
56
  process.kill(pid, "SIGTERM");
79
57
  }
80
58
  catch {
81
- // Already gone between the isProcessAlive check and this signal -- a
82
- // real, if narrow, race; fall through to the death check below rather
83
- // than treating a caught error here as failure.
59
+ // race: already gone between the isProcessAlive check and this signal
84
60
  }
85
61
  if (await waitForDeath(pid, gracePeriodMs))
86
62
  return { killedViaSigkill: false };
@@ -88,7 +64,7 @@ async function killTarget(pid, gracePeriodMs) {
88
64
  process.kill(pid, "SIGKILL");
89
65
  }
90
66
  catch {
91
- // Same race, at the SIGKILL stage.
67
+ // same race, at the SIGKILL stage
92
68
  }
93
69
  const dead = await waitForDeath(pid, Math.max(gracePeriodMs, 2000));
94
70
  if (!dead) {
@@ -99,19 +75,14 @@ async function killTarget(pid, gracePeriodMs) {
99
75
  }
100
76
  /**
101
77
  * Kills the process at `options.targetPid` and spawns a fresh, supervised,
102
- * (optionally) sandboxed replacement via `spawnProcess()`.
78
+ * optionally sandboxed replacement via `spawnProcess()`.
103
79
  *
104
- * **Not a silent behavior change to attach mode.** A caller reaches this
105
- * function by name, explicitly, instead of one of the `attachToRunning*`
106
- * functions -- there is no code path in this repo that upgrades an attach
107
- * into a respawn on its own. `ATTACH_MODE_SCOPE_DISCLOSURE`
108
- * (`@descryy/runtime-controller`) still governs attach mode itself,
109
- * unconditionally, whether or not a caller ever reaches for this
110
- * alternative.
80
+ * Not a silent behavior change to attach mode reached only by explicit call,
81
+ * never an automatic upgrade path. `ATTACH_MODE_SCOPE_DISCLOSURE` still governs
82
+ * attach mode itself regardless.
111
83
  *
112
- * Throws (does not silently proceed) if `targetPid` is not alive at call
113
- * time, matching `attachToRunningProcess`'s own "refuse rather than operate
114
- * on a target that does not exist" contract.
84
+ * Throws if `targetPid` isn't alive at call time, matching `attachToRunningProcess`'s
85
+ * refuse-rather-than-operate-on-nonexistent-target contract.
115
86
  */
116
87
  export async function respawnAndSupervise(options) {
117
88
  if (!isProcessAlive(options.targetPid)) {
@@ -139,23 +110,15 @@ export async function respawnAndSupervise(options) {
139
110
  };
140
111
  }
141
112
  /**
142
- * The opt-in, disclosed, BEST-EFFORT convenience this module's own doc
143
- * names -- never the default `respawnAndSupervise` reaches for on its own.
144
- * Reads `/proc/<pid>/cmdline`, `/proc/<pid>/cwd` and `/proc/<pid>/environ`
145
- * to reconstruct a `RespawnCommand`, labelling it `source:
146
- * "proc-cmdline-inferred"` so it can never be mistaken for a caller
147
- * declaration downstream.
113
+ * Opt-in, best-effort convenience never the default. Reads `/proc/<pid>/cmdline`,
114
+ * `/cwd` and `/environ` to reconstruct a `RespawnCommand`, labelled `source:
115
+ * "proc-cmdline-inferred"` so it's never mistaken for a caller declaration.
148
116
  *
149
- * **Real, disclosed limitations, not hypothetical ones:** Linux-only (no
150
- * `/proc` on macOS/Windows); env vars a process set on itself
151
- * programmatically after `exec` (as opposed to what it was launched with)
152
- * are invisible here, because `/proc/<pid>/environ` only ever reflects the
153
- * environment at `execve()` time; already-open file descriptors handed to
154
- * the original process (an inherited socket, a pipe from its own parent)
155
- * have no representation in a command line at all and cannot be recovered
156
- * by any means this function has. Returns `null` -- never throws, never
157
- * guesses a partial answer -- when `/proc/<pid>/cmdline` cannot be read
158
- * (platform mismatch, pid gone, permission denied) or is empty.
117
+ * Disclosed limitations: Linux-only; `/proc/<pid>/environ` reflects only the
118
+ * environment at `execve()` time, so env vars set programmatically after exec are
119
+ * invisible; already-open file descriptors (inherited sockets/pipes) have no
120
+ * command-line representation and can't be recovered. Returns `null` — never
121
+ * throws, never guesses partially when cmdline can't be read or is empty.
159
122
  */
160
123
  export function inferRespawnCommandFromProc(pid, platform = process.platform) {
161
124
  if (platform !== "linux")
@@ -167,8 +130,7 @@ export function inferRespawnCommandFromProc(pid, platform = process.platform) {
167
130
  catch {
168
131
  return null;
169
132
  }
170
- // /proc/<pid>/cmdline is NUL-separated, with a trailing NUL -- split and
171
- // drop the empty tail entry it always produces.
133
+ // NUL-separated with a trailing NUL; drop the empty tail entry
172
134
  const parts = cmdlineRaw.split("\0").filter((part) => part !== "");
173
135
  if (parts.length === 0)
174
136
  return null;
@@ -194,11 +156,8 @@ export function inferRespawnCommandFromProc(pid, platform = process.platform) {
194
156
  }
195
157
  }
196
158
  catch {
197
- // /proc/<pid>/environ is real but commonly permission-denied for a
198
- // process owned by a different uid, even when cmdline/cwd were
199
- // readable -- degrades to no env recovered rather than failing the
200
- // whole inference, since command/args/cwd alone are still a real,
201
- // usable (if incomplete) answer.
159
+ // environ is commonly permission-denied across uids even when cmdline/cwd
160
+ // are readable; degrade to no env rather than failing the whole inference
202
161
  env = undefined;
203
162
  }
204
163
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"respawn-and-supervise.js","sourceRoot":"","sources":["../src/respawn-and-supervise.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEH,OAAO,EAAE,YAAY,EAAiD,MAAM,6BAA6B,CAAC;AAC1G,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AA2ChE,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAErC,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,E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AAuB;KAChC,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,9 +1,14 @@
1
1
  {
2
2
  "name": "@descryy/runtime-orchestrator",
3
- "version": "0.2.1",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "description": "Assembles the runtime: controller-spawned services, live process output, collectors from a RuntimeAdapter, and a CollectorContext that can resolve script origins to source roots.",
6
6
  "license": "UNLICENSED",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/descryhq-wq/descry-runtime.git",
10
+ "directory": "packages/orchestrator"
11
+ },
7
12
  "engines": {
8
13
  "node": ">=22.5"
9
14
  },
@@ -24,14 +29,14 @@
24
29
  "build": "tsc -b"
25
30
  },
26
31
  "dependencies": {
27
- "@descryy/runtime-contracts": "0.2.0",
28
- "@descryy/runtime-backend-observation": "0.2.0",
29
- "@descryy/runtime-controller": "0.2.1",
30
- "@descryy/runtime-evidence-store": "0.2.0",
31
- "@descryy/runtime-adapter-typescript": "0.2.0",
32
- "@descryy/runtime-environment-profile": "0.2.0",
33
- "@descryy/runtime-remote-log-ingestion": "0.2.0",
34
- "@descryy/runtime-external-service-observation": "0.2.0"
32
+ "@descryy/runtime-contracts": "0.3.0",
33
+ "@descryy/runtime-backend-observation": "0.3.0",
34
+ "@descryy/runtime-controller": "0.3.0",
35
+ "@descryy/runtime-evidence-store": "0.4.0",
36
+ "@descryy/runtime-adapter-typescript": "0.3.0",
37
+ "@descryy/runtime-environment-profile": "0.4.0",
38
+ "@descryy/runtime-remote-log-ingestion": "0.4.0",
39
+ "@descryy/runtime-external-service-observation": "0.3.0"
35
40
  },
36
41
  "devDependencies": {
37
42
  "@descryy/runtime-adapter-csharp": "*",