fix(providers): bound launcher diagnostics without losing byte counts
Give Ghidra and Hopper an 8 MiB aggregate retained-output budget while continuing to drain their process pipes. Expose total observed bytes at the supervisor boundary and retained bytes plus explicit truncation in provider diagnostics. Redact known transport tokens even when the retained prefix ends inside one, preserving adjacent caller path/query evidence. Existing partial-launch and cleanup ownership remain intact. Validation: 285 tests across 34 focused suites passed; the final cutoff-fixture refinement passed all 31 Ghidra/Hopper diagnostic tests. check:fast and architecture guards passed. Provider fixtures use real child processes; real Ghidra/Hopper applications were not verified.
This commit is contained in:
@@ -35,6 +35,7 @@ import { silentLogger } from "../logger.js";
|
||||
import type { Logger } from "pino";
|
||||
import { PrivateRuntimeRoot } from "../process/PrivateRuntimeRoot.js";
|
||||
import { ProviderStartupDeadline } from "../process/ProviderDeadline.js";
|
||||
import { redactCapturedTransportCredential } from "../process/ProviderDiagnosticRedaction.js";
|
||||
import { ProviderRunLineage } from "../process/ProviderRunLineage.js";
|
||||
import {
|
||||
type ProviderProcessDiagnostic,
|
||||
@@ -64,6 +65,9 @@ import {
|
||||
responseResult,
|
||||
} from "./protocol.js";
|
||||
|
||||
/** Aggregate in-memory retention budget for this provider's launcher output. */
|
||||
export const HOPPER_PROCESS_DIAGNOSTIC_BYTES = 8 * 1024 * 1024;
|
||||
|
||||
const SHUTDOWN_TIMEOUT_MS = 30_000;
|
||||
const SESSION_ROOT = process.platform === "darwin" ? "/tmp" : tmpdir();
|
||||
|
||||
@@ -609,15 +613,27 @@ export class HopperClient {
|
||||
const snapshot = this.#resources.processSupervisor?.snapshot();
|
||||
const token = this.#token;
|
||||
if (snapshot === undefined) return undefined;
|
||||
const redact = (text: string): string =>
|
||||
token === undefined
|
||||
? text
|
||||
: text.replaceAll(token, "[redacted transport credential]");
|
||||
return {
|
||||
exit_code: snapshot.exitCode ?? null,
|
||||
signal: snapshot.signal ?? null,
|
||||
stdout: { ...snapshot.stdout, text: redact(snapshot.stdout.text) },
|
||||
stderr: { ...snapshot.stderr, text: redact(snapshot.stderr.text) },
|
||||
stdout: {
|
||||
text: redactCapturedTransportCredential(
|
||||
snapshot.stdout,
|
||||
token,
|
||||
"[redacted transport credential]",
|
||||
),
|
||||
bytes: snapshot.stdout.observedBytes,
|
||||
retained_bytes: snapshot.stdout.bytes,
|
||||
},
|
||||
stderr: {
|
||||
text: redactCapturedTransportCredential(
|
||||
snapshot.stderr,
|
||||
token,
|
||||
"[redacted transport credential]",
|
||||
),
|
||||
bytes: snapshot.stderr.observedBytes,
|
||||
retained_bytes: snapshot.stderr.bytes,
|
||||
},
|
||||
output_closed: outputClosed,
|
||||
diagnostic_truncated: snapshot.diagnosticTruncated === true,
|
||||
};
|
||||
@@ -743,6 +759,7 @@ export class HopperClient {
|
||||
|
||||
#attachLauncher(launch: BridgeLaunch): void {
|
||||
this.#resources.processSupervisor = new ProviderProcessSupervisor(launch, {
|
||||
maxDiagnosticBytes: HOPPER_PROCESS_DIAGNOSTIC_BYTES,
|
||||
onDiagnostic: (event) => this.#onLauncherDiagnostic(launch, event),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user