@descryy/runtime-orchestrator 0.4.7 → 0.4.9

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 (49) hide show
  1. package/package.json +7 -7
  2. package/dist/attach-to-running-jvm-process.d.ts +0 -86
  3. package/dist/attach-to-running-jvm-process.d.ts.map +0 -1
  4. package/dist/attach-to-running-jvm-process.js +0 -408
  5. package/dist/attach-to-running-jvm-process.js.map +0 -1
  6. package/dist/attach-to-running-node-process.d.ts +0 -80
  7. package/dist/attach-to-running-node-process.d.ts.map +0 -1
  8. package/dist/attach-to-running-node-process.js +0 -290
  9. package/dist/attach-to-running-node-process.js.map +0 -1
  10. package/dist/attach-to-running-process.d.ts +0 -83
  11. package/dist/attach-to-running-process.d.ts.map +0 -1
  12. package/dist/attach-to-running-process.js +0 -86
  13. package/dist/attach-to-running-process.js.map +0 -1
  14. package/dist/cdp-client.d.ts +0 -27
  15. package/dist/cdp-client.d.ts.map +0 -1
  16. package/dist/cdp-client.js +0 -98
  17. package/dist/cdp-client.js.map +0 -1
  18. package/dist/cgroup-partial-restriction.d.ts +0 -80
  19. package/dist/cgroup-partial-restriction.d.ts.map +0 -1
  20. package/dist/cgroup-partial-restriction.js +0 -189
  21. package/dist/cgroup-partial-restriction.js.map +0 -1
  22. package/dist/collector-version.d.ts +0 -7
  23. package/dist/collector-version.d.ts.map +0 -1
  24. package/dist/collector-version.js +0 -9
  25. package/dist/collector-version.js.map +0 -1
  26. package/dist/index.d.ts +0 -19
  27. package/dist/index.d.ts.map +0 -1
  28. package/dist/index.js +0 -10
  29. package/dist/index.js.map +0 -1
  30. package/dist/instrumented-execution.d.ts +0 -129
  31. package/dist/instrumented-execution.d.ts.map +0 -1
  32. package/dist/instrumented-execution.js +0 -547
  33. package/dist/instrumented-execution.js.map +0 -1
  34. package/dist/jvm-agent/build.d.ts +0 -48
  35. package/dist/jvm-agent/build.d.ts.map +0 -1
  36. package/dist/jvm-agent/build.js +0 -129
  37. package/dist/jvm-agent/build.js.map +0 -1
  38. package/dist/polling-output-source.d.ts +0 -43
  39. package/dist/polling-output-source.d.ts.map +0 -1
  40. package/dist/polling-output-source.js +0 -64
  41. package/dist/polling-output-source.js.map +0 -1
  42. package/dist/profile-backend-observation.d.ts +0 -67
  43. package/dist/profile-backend-observation.d.ts.map +0 -1
  44. package/dist/profile-backend-observation.js +0 -107
  45. package/dist/profile-backend-observation.js.map +0 -1
  46. package/dist/respawn-and-supervise.d.ts +0 -86
  47. package/dist/respawn-and-supervise.d.ts.map +0 -1
  48. package/dist/respawn-and-supervise.js +0 -171
  49. package/dist/respawn-and-supervise.js.map +0 -1
@@ -1,547 +0,0 @@
1
- /**
2
- * The assembly wiring the runtime's pieces together in production code (previously
3
- * only connected ad hoc by tests). Runs an `ExecutionController` over a `services`
4
- * configuration; wraps each spawned process in a live `ProcessOutputSource`
5
- * (polls the buffer, yields each line once); builds a `CollectorContext` with a
6
- * real `resolveSourceRoot` closed over the execution's own processes; starts,
7
- * drains and stops the adapter's collectors; writes every emitted item through
8
- * `EvidenceStore` so redaction runs (plan §28).
9
- *
10
- * Deliberately does not decide whether a finding exists, correlate to graph
11
- * nodes, or drive a browser — separate stages, separate contracts.
12
- */
13
- import { delimiter } from "node:path";
14
- import { resolveServiceRootForOrigin } from "@descryy/runtime-contracts";
15
- import { createInboundProxy } from "@descryy/runtime-backend-observation";
16
- import { createExternalRequestCollector } from "@descryy/runtime-external-service-observation";
17
- import { ExecutionController, checkDependencyVersions, checkEnvironmentVersion, } from "@descryy/runtime-controller";
18
- import { EvidenceStore } from "@descryy/runtime-evidence-store";
19
- import { createPollingProcessOutputSource } from "./polling-output-source.js";
20
- import { COLLECTOR_VERSION } from "./collector-version.js";
21
- /**
22
- * Every spawned service's captured output, read off the controller at the
23
- * moment the result is built. Keyed by service name, which is also the only
24
- * thing that can be joined back to `ExecutionConfiguration.services`; a handle
25
- * with no service name has nothing to key on and is skipped.
26
- */
27
- function captureServiceOutput(controller) {
28
- const output = {};
29
- for (const handle of controller.execution.processes) {
30
- if (handle.serviceName === null)
31
- continue;
32
- output[handle.serviceName] = controller.readProcessOutput(handle.serviceName);
33
- }
34
- return output;
35
- }
36
- /**
37
- * Builds the origin → source-root lookup a collector reads through
38
- * `CollectorContext.resolveSourceRoot`. Closes over the execution's own
39
- * processes, which is what makes the port→service join possible at all — under
40
- * ephemeral ports only the running process knows its own port.
41
- */
42
- export function createSourceRootResolver(processes, configuration) {
43
- return (origin) => resolveServiceRootForOrigin(origin, { processes, configuration });
44
- }
45
- /**
46
- * Rewrites every spawnable service so it launches with outbound
47
- * instrumentation in place.
48
- *
49
- * The declaration comes from the adapter and names no language; this function
50
- * applies it and also names none. `attach`-mode services are skipped: their
51
- * process is already running, so there is no launch left to influence, and
52
- * pretending otherwise would claim instrumentation that is not there.
53
- */
54
- export function applyOutboundLaunch(execution, launch) {
55
- const services = {};
56
- for (const [name, service] of Object.entries(execution.configuration.services)) {
57
- if (service.command === undefined) {
58
- services[name] = service;
59
- continue;
60
- }
61
- const prepend = new Set(launch.prependToExisting ?? []);
62
- const env = { ...service.env };
63
- for (const [key, value] of Object.entries(launch.env ?? {})) {
64
- // extend, don't replace, a variable the target relies on (PYTHONPATH is the
65
- // live case) -- replacing it breaks the app's own module resolution
66
- const existing = prepend.has(key) ? (service.env?.[key] ?? process.env[key] ?? "") : "";
67
- env[key] = existing === "" ? value : `${value}${delimiter}${existing}`;
68
- }
69
- services[name] = {
70
- ...service,
71
- ...(Object.keys(env).length === 0 ? {} : { env }),
72
- ...(launch.interpreterArgs === undefined || launch.interpreterArgs.length === 0
73
- ? {}
74
- : { interpreterArgs: [...(service.interpreterArgs ?? []), ...launch.interpreterArgs] }),
75
- };
76
- }
77
- return { ...execution, configuration: { ...execution.configuration, services } };
78
- }
79
- export async function runInstrumentedExecution(input) {
80
- // outbound observation needs two things: a collector to read the marker lines,
81
- // and a launch that installs client instrumentation before app code can capture
82
- // an unpatched client. The launch is adapter-declared and language-specific; an
83
- // adapter that declares nothing gets neither.
84
- //
85
- // budget clock starts here, not at controller.run() -- marginally earlier than
86
- // the controller's own timer, so a caller never waits past its declared bound
87
- const budgetStartedAt = Date.now();
88
- const outboundLaunch = input.adapter.outboundHttpLaunch?.() ?? null;
89
- const launchedExecution = outboundLaunch === null ? input.execution : applyOutboundLaunch(input.execution, outboundLaunch);
90
- const configuration = launchedExecution.configuration;
91
- // closure, not repeated per-return: there are four returns, and one quietly
92
- // reporting a different number is the bug this field exists to catch
93
- const budgetOutcome = (observedForMs) => {
94
- const elapsedMs = Date.now() - budgetStartedAt;
95
- return {
96
- declaredMs: configuration.timeoutMs,
97
- elapsedMs,
98
- requestedObservationMs: input.observeForMs,
99
- observedForMs,
100
- exceeded: elapsedMs > configuration.timeoutMs,
101
- };
102
- };
103
- const controller = ExecutionController.create(launchedExecution);
104
- // B7: the execution row, minted here and nowhere else in production.
105
- // `EvidenceStore.recordExecution` was complete and tested since the
106
- // `executions` table was added -- schema, redaction, environment capture,
107
- // upsert -- but this repo's and descry-core's own sources together held
108
- // exactly two callers of it outside its own tests, both in
109
- // evidence-store's test suite. Every evidence row this run is about to
110
- // write carries `controller.execution.executionId`, so the parent row
111
- // must exist before the first of them does; `controller.execution` is
112
- // real the moment `create()` returns (it mints the id synchronously),
113
- // which is before `controller.run()` -- and therefore before this
114
- // function's own first `store.write()`, in the catch block just below.
115
- input.store.recordExecution({
116
- executionId: controller.execution.executionId,
117
- application: controller.execution.application,
118
- repository: controller.execution.repository,
119
- commit: controller.execution.commit,
120
- configuration: controller.execution.configuration,
121
- });
122
- // RT-219: controller.run()'s one throw path (spawnProcess catch/rethrow, after
123
- // recording the failure in serviceStartResults) used to reject this whole
124
- // function uncaught -- zero evidence trail. Caught here and written through
125
- // EvidenceStore tagged "harness", same "resolves normally" contract RT-219
126
- // established for collector.start(). controller.execution/serviceStartResults
127
- // are both already real at this point (run() mutates state before it throws).
128
- let execution;
129
- try {
130
- execution = await controller.run(input.runOptions);
131
- }
132
- catch (error) {
133
- const detail = error instanceof Error ? `${error.name}: ${error.message}` : String(error);
134
- const harnessEvidence = input.store.write({
135
- executionId: controller.execution.executionId,
136
- timestamp: new Date().toISOString(),
137
- source: "harness",
138
- service: null,
139
- process: null,
140
- eventType: "COLLECTOR_ERROR",
141
- payload: {
142
- raw: `ExecutionController.run() threw instead of resolving: ${detail}`,
143
- error: detail,
144
- },
145
- traceId: null,
146
- requestId: null,
147
- correlationId: null,
148
- graphNodeId: null,
149
- sourceLocation: null,
150
- stackTrace: null,
151
- confidence: 1,
152
- collectorVersion: COLLECTOR_VERSION,
153
- });
154
- return {
155
- execution: controller.execution,
156
- evidence: [harnessEvidence],
157
- collectorCapabilities: [],
158
- validationError: `ExecutionController.run() threw: ${detail}`,
159
- budget: budgetOutcome(0),
160
- // The throw path is where output matters most: whatever the service
161
- // printed before the run came apart is the only account of it there is.
162
- serviceOutput: captureServiceOutput(controller),
163
- };
164
- }
165
- if (controller.validationError !== null) {
166
- return {
167
- execution,
168
- evidence: [],
169
- collectorCapabilities: [],
170
- validationError: controller.validationError,
171
- budget: budgetOutcome(0),
172
- // Refused before spawning, so nothing can have been said. Empty here is
173
- // the true answer, not a default standing in for one.
174
- serviceOutput: {},
175
- };
176
- }
177
- // a handle with no serviceName can't be attributed to a config entry -- skipped
178
- // declared before the sources close over it: the flip lets stop() finish rather
179
- // than wait forever on a source still watching a live buffer
180
- let finished = false;
181
- const sources = [];
182
- // second, independent source per process -- NOT shared with the backend
183
- // collector's: createPollingProcessOutputSource yields each line exactly once,
184
- // so sharing means two collectors race for it. Measured: sharing made the
185
- // backend log collector eat every DESCRY_EXTERNAL_REQUEST line and the outbound
186
- // collector report nothing, reading as "no outbound calls".
187
- const namedSources = [];
188
- for (const handle of execution.processes) {
189
- if (handle.serviceName === null)
190
- continue;
191
- const serviceName = handle.serviceName;
192
- // stamped here, at construction -- by the time evidence reaches
193
- // correlateExecution the handle is out of scope and this association is gone
194
- sources.push(createPollingProcessOutputSource({
195
- processId: handle.processId,
196
- serviceName,
197
- readOutput: () => controller.readProcessOutput(serviceName),
198
- isFinished: () => finished,
199
- }));
200
- namedSources.push({
201
- serviceName,
202
- source: createPollingProcessOutputSource({
203
- processId: handle.processId,
204
- serviceName,
205
- readOutput: () => controller.readProcessOutput(serviceName),
206
- isFinished: () => finished,
207
- }),
208
- });
209
- }
210
- const backendCollectors = input.adapter.createBackendCollectors(sources);
211
- // only started when the launch above actually installed instrumentation --
212
- // otherwise it would report "no outbound calls" for a service making them,
213
- // worse than declining to look. createExternalRequestCollector names no
214
- // language itself; the adapter's stack parser is the only language-specific bit.
215
- const outboundCollectors = outboundLaunch === null
216
- ? []
217
- : namedSources.map(({ source, serviceName }) => createExternalRequestCollector({
218
- source,
219
- service: serviceName,
220
- stackTraceParser: input.adapter.stackTraceParser,
221
- }));
222
- const emitted = [];
223
- // dependency/environment version-mismatch checks (DEC-NEXT-fault-layer-empirical-
224
- // confirmation.md): tagged "dependency-check"/"environment-check" rather than the
225
- // service's own source, so a reader can tell version drift from an app
226
- // observation. Run once per service (own cwd/lockfile/engines.node),
227
- // unconditionally, but only emitted as evidence on an actual mismatch.
228
- //
229
- // observedNodeVersion is process.version captured once during controller.run();
230
- // never re-probed here.
231
- const observedNodeVersion = execution.environmentMetadata?.nodeVersion ?? process.version;
232
- for (const handle of execution.processes) {
233
- if (handle.serviceName === null)
234
- continue;
235
- const serviceConfig = configuration.services[handle.serviceName];
236
- if (serviceConfig === undefined)
237
- continue;
238
- const dependencyResult = checkDependencyVersions(serviceConfig.cwd);
239
- for (const mismatch of dependencyResult.mismatches) {
240
- emitted.push(input.store.write({
241
- executionId: execution.executionId,
242
- timestamp: new Date().toISOString(),
243
- source: "dependency-check",
244
- service: handle.serviceName,
245
- process: handle.processId,
246
- eventType: "DEPENDENCY_VERSION_MISMATCH",
247
- payload: {
248
- raw: `dependency "${mismatch.name}": lockfile declares ${mismatch.declaredVersion}, resolved ${mismatch.resolvedVersion}`,
249
- name: mismatch.name,
250
- declaredVersion: mismatch.declaredVersion,
251
- resolvedVersion: mismatch.resolvedVersion,
252
- },
253
- traceId: null,
254
- requestId: null,
255
- correlationId: null,
256
- graphNodeId: null,
257
- sourceLocation: null,
258
- stackTrace: null,
259
- confidence: 1,
260
- collectorVersion: COLLECTOR_VERSION,
261
- }));
262
- }
263
- const environmentResult = checkEnvironmentVersion(serviceConfig.cwd, observedNodeVersion);
264
- if (environmentResult.mismatch) {
265
- emitted.push(input.store.write({
266
- executionId: execution.executionId,
267
- timestamp: new Date().toISOString(),
268
- source: "environment-check",
269
- service: handle.serviceName,
270
- process: handle.processId,
271
- eventType: "ENVIRONMENT_VERSION_MISMATCH",
272
- payload: {
273
- raw: `declared node version ${environmentResult.declaredVersion ?? "unknown"} (${environmentResult.declaredSource ?? "unknown"}), observed ${environmentResult.observedVersion}`,
274
- declaredVersion: environmentResult.declaredVersion,
275
- declaredSource: environmentResult.declaredSource,
276
- observedVersion: environmentResult.observedVersion,
277
- },
278
- traceId: null,
279
- requestId: null,
280
- correlationId: null,
281
- graphNodeId: null,
282
- sourceLocation: null,
283
- stackTrace: null,
284
- confidence: 1,
285
- collectorVersion: COLLECTOR_VERSION,
286
- }));
287
- }
288
- }
289
- // opt-in InboundProxy wiring (RT-192, DEC-271), see frontWithInboundProxy's doc.
290
- // Built after controller.run() returns, so readiness already exists in
291
- // serviceStartResults -- this loop reads that answer, never re-derives it.
292
- const proxies = [];
293
- if (input.frontWithInboundProxy !== undefined) {
294
- for (const handle of execution.processes) {
295
- const serviceName = handle.serviceName;
296
- if (serviceName === null)
297
- continue;
298
- if (input.frontWithInboundProxy[serviceName] !== true)
299
- continue;
300
- const readinessOutcome = controller.serviceStartResults.find((result) => result.serviceName === serviceName && result.stage === "readiness");
301
- if (readinessOutcome?.succeeded !== true || handle.port === null) {
302
- // requested but never proven live -- reported as COLLECTOR_ERROR, not a
303
- // silent no-proxy fallback (plan §17: "not observed" vs "nothing there")
304
- emitted.push(input.store.write({
305
- executionId: execution.executionId,
306
- timestamp: new Date().toISOString(),
307
- source: "backend-process",
308
- service: serviceName,
309
- process: handle.processId,
310
- eventType: "COLLECTOR_ERROR",
311
- payload: {
312
- raw: `service "${serviceName}" was flagged frontWithInboundProxy but its own readiness never succeeded -- never fronting a process that was not proven live`,
313
- collectorId: `inbound-proxy:${handle.processId}`,
314
- },
315
- traceId: null,
316
- requestId: null,
317
- correlationId: null,
318
- graphNodeId: null,
319
- sourceLocation: null,
320
- stackTrace: null,
321
- confidence: 1,
322
- collectorVersion: COLLECTOR_VERSION,
323
- }));
324
- continue;
325
- }
326
- proxies.push({
327
- serviceName,
328
- proxy: createInboundProxy({
329
- targetHost: "127.0.0.1",
330
- targetPort: handle.port,
331
- processId: handle.processId,
332
- service: serviceName,
333
- }),
334
- });
335
- }
336
- }
337
- const collectors = [...backendCollectors, ...outboundCollectors, ...proxies.map((entry) => entry.proxy.collector)];
338
- const context = {
339
- executionId: execution.executionId,
340
- configuration,
341
- // redaction runs here, on the way in -- EvidenceStore.write() is the only
342
- // path that sets redactionStatus (plan §28)
343
- emit: (evidenceInput) => {
344
- emitted.push(input.store.write({ ...evidenceInput, executionId: execution.executionId }));
345
- },
346
- resolveSourceRoot: createSourceRootResolver(execution.processes, configuration),
347
- };
348
- // RT-219: collector.start()'s documented failure path resolves {available:
349
- // false, reason}, handled below. A collector that instead THROWS out of
350
- // start() is a different claim -- the harness's own machinery breaking, not
351
- // "I looked and could not" -- so it's caught here and tagged "harness" rather
352
- // than the collector's domain source, instead of aborting this Promise.all
353
- // uncaught with zero evidence trail.
354
- const startOutcomes = await Promise.all(collectors.map(async (collector) => {
355
- try {
356
- return { collector, result: await collector.start(context), threw: false };
357
- }
358
- catch (error) {
359
- const detail = error instanceof Error ? `${error.name}: ${error.message}` : String(error);
360
- emitted.push(input.store.write({
361
- executionId: execution.executionId,
362
- timestamp: new Date().toISOString(),
363
- source: "harness",
364
- service: null,
365
- process: null,
366
- eventType: "COLLECTOR_ERROR",
367
- payload: {
368
- raw: `collector "${collector.collectorId}" threw during start() instead of resolving {available:false}: ${detail}`,
369
- collectorId: collector.collectorId,
370
- error: detail,
371
- },
372
- traceId: null,
373
- requestId: null,
374
- correlationId: null,
375
- graphNodeId: null,
376
- sourceLocation: null,
377
- stackTrace: null,
378
- confidence: 1,
379
- collectorVersion: COLLECTOR_VERSION,
380
- }));
381
- return { collector, result: { available: false, reason: `start() threw: ${detail}` }, threw: true };
382
- }
383
- }));
384
- // a thrown start() was already reported above under "harness" -- excluded here
385
- // to avoid double-reporting the same failure under "backend-process"
386
- const unavailable = startOutcomes.filter((entry) => !entry.threw && !entry.result.available);
387
- // reported, never silently absent (plan §17: "not observed" vs "nothing there")
388
- for (const entry of unavailable) {
389
- emitted.push(input.store.write({
390
- executionId: execution.executionId,
391
- timestamp: new Date().toISOString(),
392
- source: "backend-process",
393
- service: null,
394
- process: null,
395
- eventType: "COLLECTOR_ERROR",
396
- payload: {
397
- raw: `collector "${entry.collector.collectorId}" reported unavailable at start: ${entry.result.available ? "" : (entry.result.reason ?? "no reason given")}`,
398
- collectorId: entry.collector.collectorId,
399
- },
400
- traceId: null,
401
- requestId: null,
402
- correlationId: null,
403
- graphNodeId: null,
404
- sourceLocation: null,
405
- stackTrace: null,
406
- confidence: 1,
407
- collectorVersion: COLLECTOR_VERSION,
408
- }));
409
- }
410
- // proxies with available:false above never reach here -- port stayed null
411
- const proxyPorts = {};
412
- for (const entry of proxies) {
413
- const port = entry.proxy.port();
414
- if (port !== null)
415
- proxyPorts[entry.serviceName] = port;
416
- }
417
- // Wrapped because a throw above teardown used to leak the whole execution.
418
- // onReady is caller code, documented not to be caught -- but "not caught" and
419
- // "not cleaned up" are different promises: when onReady threw, finished stayed
420
- // false, so collector.stop()/controller.stop() were skipped, sources kept
421
- // polling, the spawned child was never killed, and the timer held the event
422
- // loop open. Measured: rejects in 270ms, process then never exits. Exception
423
- // still propagates unchanged to the caller; only the leak goes away.
424
- //
425
- // Found the hard way: a worktree missing node_modules made a test's onReady
426
- // throw after a correctly bounded readiness wait, then the suite hung for
427
- // twenty minutes.
428
- let observationMs = 0;
429
- let bodyFailure = null;
430
- let teardownFailure = null;
431
- try {
432
- await input.onReady?.({ execution, proxyPorts });
433
- // observation window is bounded by the declared budget, not just observeForMs
434
- // -- unconditionally sleeping the full window used to leave timeoutMs bounding
435
- // only the service, not the wait; measured, a 1500ms budget with a 12000ms
436
- // window returned after 12288ms with zero evidence (services dead the whole
437
- // remainder). Clamped rather than aborted: teardown still owns OS resources
438
- // and must run; the overshoot is reported via budget.exceeded, not hidden.
439
- const remainingMs = budgetStartedAt + configuration.timeoutMs - Date.now();
440
- observationMs = Math.max(0, Math.min(input.observeForMs, remainingMs));
441
- if (observationMs > 0) {
442
- await new Promise((resolve) => setTimeout(resolve, observationMs));
443
- }
444
- // rule 7: cut-short window is a labelled degradation. execution.state's
445
- // TIMED_OUT says the services stopped early, not that observation did --
446
- // tagged "harness"/COLLECTOR_ERROR to keep "found nothing" apart from
447
- // "stopped looking".
448
- if (observationMs < input.observeForMs) {
449
- emitted.push(input.store.write({
450
- executionId: execution.executionId,
451
- timestamp: new Date().toISOString(),
452
- source: "harness",
453
- service: null,
454
- process: null,
455
- eventType: "COLLECTOR_ERROR",
456
- payload: {
457
- raw: `the observation window was cut short by the declared whole-execution budget: ` +
458
- `observed for ${String(observationMs)}ms of the ${String(input.observeForMs)}ms requested, ` +
459
- `against a ${String(configuration.timeoutMs)}ms budget. Evidence from this run is partial — ` +
460
- `absence of an event is not evidence the application did not produce one.`,
461
- collectorId: "orchestrator:execution-budget",
462
- },
463
- traceId: null,
464
- requestId: null,
465
- correlationId: null,
466
- graphNodeId: null,
467
- sourceLocation: null,
468
- stackTrace: null,
469
- confidence: 1,
470
- collectorVersion: COLLECTOR_VERSION,
471
- }));
472
- }
473
- }
474
- catch (error) {
475
- // held, not handled -- rethrown below, unchanged, once teardown has run
476
- bodyFailure = { error };
477
- }
478
- finally {
479
- // order matters: sources must be told the process is done before stop()
480
- // awaits their drain, or it waits forever on a generator polling a live buffer
481
- finished = true;
482
- try {
483
- await Promise.all(collectors.map((collector) => collector.stop()));
484
- // timeout() vs stop() is decided here, not left to whichever of this
485
- // function's clamp or the controller's own timer fires first -- measured
486
- // TIMED_OUT at 1534ms and COMPLETED at 1515ms for the same case under load.
487
- // descry-core's observe_runtime reads this to choose ok vs timed_out, so
488
- // losing that race silently hid a real truncation; this function already
489
- // knows the answer (observationMs < input.observeForMs) and states it
490
- // directly instead.
491
- if (observationMs < input.observeForMs) {
492
- await controller.timeout();
493
- }
494
- else {
495
- await controller.stop();
496
- }
497
- }
498
- catch (teardownError) {
499
- // held and rethrown below rather than thrown inside finally, which can
500
- // discard an in-flight exception
501
- if (bodyFailure === null) {
502
- teardownFailure = { error: teardownError };
503
- }
504
- else {
505
- // caller's error is the actionable one; a teardown failure must not
506
- // silently replace it -- written to the evidence store instead (tagged
507
- // "harness", RT-219) rather than thrown. Not in the returned array, but
508
- // the store is durable so the record survives the throw.
509
- input.store.write({
510
- executionId: execution.executionId,
511
- timestamp: new Date().toISOString(),
512
- source: "harness",
513
- service: null,
514
- process: null,
515
- eventType: "COLLECTOR_ERROR",
516
- payload: {
517
- raw: "teardown also failed while unwinding from an earlier failure, and is recorded rather than " +
518
- `thrown so it does not mask it: ${teardownError instanceof Error ? `${teardownError.name}: ${teardownError.message}` : String(teardownError)}`,
519
- collectorId: "orchestrator:teardown",
520
- },
521
- traceId: null,
522
- requestId: null,
523
- correlationId: null,
524
- graphNodeId: null,
525
- sourceLocation: null,
526
- stackTrace: null,
527
- confidence: 1,
528
- collectorVersion: COLLECTOR_VERSION,
529
- });
530
- }
531
- }
532
- }
533
- // rethrown untouched, same object/stack; caller's failure wins over teardown's
534
- if (bodyFailure !== null)
535
- throw bodyFailure.error;
536
- if (teardownFailure !== null)
537
- throw teardownFailure.error;
538
- return {
539
- execution: controller.execution,
540
- evidence: emitted,
541
- collectorCapabilities: collectors.map((collector) => ({ collectorId: collector.collectorId, capabilities: collector.capabilities() })),
542
- validationError: null,
543
- budget: budgetOutcome(observationMs),
544
- serviceOutput: captureServiceOutput(controller),
545
- };
546
- }
547
- //# sourceMappingURL=instrumented-execution.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"instrumented-execution.js","sourceRoot":"","sources":["../src/instrumented-execution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAUtC,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AAEzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAE,8BAA8B,EAAE,MAAM,+CAA+C,CAAC;AAC/F,OAAO,EACL,mBAAmB,EAGnB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAEhE,OAAO,EAAE,gCAAgC,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAgG3D;;;;;GAKG;AACH,SAAS,oBAAoB,CAAC,UAA+B;IAC3D,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,KAAK,MAAM,MAAM,IAAI,UAAU,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC;QACpD,IAAI,MAAM,CAAC,WAAW,KAAK,IAAI;YAAE,SAAS;QAC1C,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,UAAU,CAAC,iBAAiB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAChF,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CACtC,SAAmC,EACnC,aAAqC;IAErC,OAAO,CAAC,MAAc,EAAE,EAAE,CAAC,2BAA2B,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC,C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,IAAI,KAAK,aAAa,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE;wBAChJ,WAAW,EAAE,uBAAuB;qBACrC;oBACD,OAAO,EAAE,IAAI;oBACb,SAAS,EAAE,IAAI;oBACf,aAAa,EAAE,IAAI;oBACnB,WAAW,EAAE,IAAI;oBACjB,cAAc,EAAE,IAAI;oBACpB,UAAU,EAAE,IAAI;oBAChB,UAAU,EAAE,CAAC;oBACb,gBAAgB,EAAE,iBAAiB;iBACpC,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IAED,+EAA+E;IAC/E,IAAI,WAAW,KAAK,IAAI;QAAE,MAAM,WAAW,CAAC,KAAK,CAAC;IAClD,IAAI,eAAe,KAAK,IAAI;QAAE,MAAM,eAAe,CAAC,KAAK,CAAC;IAE1D,OAAO;QACL,SAAS,EAAE,UAAU,CAAC,SAAS;QAC/B,QAAQ,EAAE,OAAO;QACjB,qBAAqB,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,EAAE,WAAW,EAAE,SAAS,CAAC,WAAW,EAAE,YAAY,EAAE,SAAS,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;QACtI,eAAe,EAAE,IAAI;QACrB,MAAM,EAAE,aAAa,CAAC,aAAa,CAAC;QACpC,aAAa,EAAE,oBAAoB,CAAC,UAAU,CAAC;KAChD,CAAC;AACJ,CAAC"}
@@ -1,48 +0,0 @@
1
- /**
2
- * Compiles `Agent.java` into `agent.jar` and `Attacher.java` into `Attacher.class`,
3
- * once, only when source is newer than build output (same mtime-cache rule
4
- * `kotlin-server/build.ts` uses). This is shipped product code —
5
- * `attach-to-running-jvm-process.ts` runs the compiled artifacts, never compiles
6
- * them at call time.
7
- *
8
- * **`tools.jar` is JDK-8-only.** `com.sun.tools.attach.VirtualMachine` shipped in
9
- * `tools.jar` through JDK 8; from JDK 9 it's in the `jdk.attach` module, no extra
10
- * jar needed. `findToolsJarIfPresent` returns `null` when absent (JDK 9+ or no
11
- * `tools.jar`) and `Attacher.java` compiles/runs with no extra classpath entry —
12
- * correct for JDK 9+, but only exercised against JDK 8 on this machine (disclosed
13
- * gap, see this module's decisions-inbox entry).
14
- *
15
- * **ByteBuddy is vendored** (same pattern as `junit-platform-console-standalone`
16
- * for the JUnit reporter): one pinned version, fetched once from Maven Central,
17
- * checksum-verified, never a build tool. `Agent.java` needs real bytecode
18
- * manipulation for `DispatcherServlet` method-entry advice (RT-201) — hand-written
19
- * ASM isn't realistic, and Maven/Gradle would mean resolving a dependency tree for
20
- * one library. The plain `net.bytebuddy:byte-buddy` artifact (not `byte-buddy-dep`)
21
- * is used because it repackages its own ASM under `net.bytebuddy.jar.asm.*`
22
- * (verified via `unzip -l`) — one self-contained jar. **A version bump changes the
23
- * URL AND the digest, in one reviewable diff** (plus `MANIFEST.MF`'s `Class-Path`
24
- * line, which is static and version-pinned, not generated). `byte-buddy-*.jar`
25
- * sits beside `agent.jar` because the JDK resolves an agent JAR's `Class-Path`
26
- * relative to the agent JAR's own location.
27
- *
28
- * **`Agent.java`/`Attacher.java`/`MANIFEST.MF` live in `packages/orchestrator/jvm-agent/`,
29
- * a sibling of `src/`/`dist/`, NOT inside `src/jvm-agent/`.** Found the hard way:
30
- * `tsc` only emits `.js`/`.d.ts`, so a `.java` file nested inside `src/jvm-agent/`
31
- * has no `dist/` counterpart and `import.meta.url`-relative resolution would point
32
- * at a source-only directory. A relative URL walking OUT of `src/`/`dist/` to a
33
- * shared sibling resolves identically from either, since both sit at the same
34
- * depth under `packages/orchestrator/`.
35
- */
36
- export declare const JVM_AGENT_DIR: string;
37
- export declare const BYTEBUDDY_JAR: string;
38
- /** Fetches the pinned ByteBuddy jar if absent or its checksum no longer matches — refuses a mismatch rather than proceeding, since this jar is both compiled against and loaded into a target JVM. */
39
- export declare function ensureByteBuddyJar(): Promise<string>;
40
- /** `$JAVA_HOME/lib/tools.jar` if it exists, else derived from `java`'s own reported `java.home`. `null` when neither yields a real file — the JDK 9+, no-`tools.jar` case. */
41
- export declare function findToolsJarIfPresent(): string | null;
42
- /** Compiles `Agent.java` and packages it as `agent.jar` with `Agent-Class` in its manifest. Returns the jar's path. */
43
- export declare function buildJvmAgentJar(): Promise<string>;
44
- /** Compiles `Attacher.java` to `Attacher.class` in this same directory. Returns the directory to put on the classpath (the class itself, not a jar — one file, no packaging step needed). */
45
- export declare function buildAttacherClass(): string;
46
- /** Ensures a directory exists (for the caller's tmp output file), mirroring the small helper every attach module in this package already needs once for its own scratch state. */
47
- export declare function ensureDir(path: string): void;
48
- //# sourceMappingURL=build.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/jvm-agent/build.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAQH,eAAO,MAAM,aAAa,QAA6D,CAAC;AAMxF,eAAO,MAAM,aAAa,QAA6D,CAAC;AAMxF,sMAAsM;AACtM,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC,CAe1D;AAMD,8KAA8K;AAC9K,wBAAgB,qBAAqB,IAAI,MAAM,GAAG,IAAI,CAYrD;AAED,uHAAuH;AACvH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC,CAuBxD;AAED,6LAA6L;AAC7L,wBAAgB,kBAAkB,IAAI,MAAM,CAY3C;AAED,kLAAkL;AAClL,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAE5C"}