fix(browser): bound capture work and preserve observation gaps

Own service-worker CDP registrations and retry failed teardown. Admit redaction and network metadata against remaining capture capacity, retain explicit omission reasons, and preserve source URL, redirect ancestry, caller-selected content, and historical capture values. Forward CLI cancellation through provider cleanup.

Reviewed fixes: #2263, #2637, #2767, #2845, #2859, #2863, #2872, #2874, #2876, #2879, #2955, #2957, #2961, #3033.

Validation: 25 current event/network source tests passed; earlier focused browser lanes passed 201 source tests and 176 boundary tests with two skips, plus 35 Python tests. Real browser/Windows lanes were not rerun. Playwright allocation before admission remains unbounded by these retention limits.
This commit is contained in:
morluto committed 2026-10-14 08:31:29 +08:00
1 parent ec271121e4
commit f6905719c3
60 files changed
+5539 -717

No files matched your search

+57 -46
View File
@@ -16,6 +16,7 @@ import { analysisInputErrorFromIssues } from "./domain/inputIssueProjection.js";
import { projectAnalysisError } from "./domain/analysisErrorProjection.js";
import type { JsonValue } from "./domain/jsonValue.js";
import type { Logger } from "pino";
import { withCommandCancellation } from "./cli/commandCancellation.js";
const observeOptionsSchema = z.object({
runtimeKind: javascriptRuntimeKindSchema
@@ -42,30 +43,33 @@ export const registerJavaScriptRuntimeObservationCommands = (
endpoint: z.string().describe("Literal-loopback Inspector endpoint"),
}),
run: ({ args }) =>
logCliCommand(
logger,
CLI_COMMANDS.listJavaScriptRuntimeTargets,
async () => {
const context = runtimeContext();
const input = {
inspector_endpoint: args.endpoint,
};
const parsed =
listJavaScriptRuntimeTargetsInputSchema.safeParse(input);
if (!parsed.success)
return cliError(
analysisInputErrorFromIssues(
"list_javascript_runtime_targets",
parsed.error.issues,
input,
),
withCommandCancellation((signal) =>
logCliCommand(
logger,
CLI_COMMANDS.listJavaScriptRuntimeTargets,
async () => {
const context = runtimeContext();
const input = {
inspector_endpoint: args.endpoint,
};
const parsed =
listJavaScriptRuntimeTargetsInputSchema.safeParse(input);
if (!parsed.success)
return cliError(
analysisInputErrorFromIssues(
"list_javascript_runtime_targets",
parsed.error.issues,
input,
),
);
const result = await listJavaScriptRuntimeTargets(
context.provider,
parsed.data,
{ signal },
);
const result = await listJavaScriptRuntimeTargets(
context.provider,
parsed.data,
);
return result.ok ? result.value : cliError(result.error);
},
return result.ok ? result.value : cliError(result.error);
},
),
),
});
@@ -79,29 +83,36 @@ export const registerJavaScriptRuntimeObservationCommands = (
}),
options: observeOptionsSchema,
run: ({ args, options }) =>
logCliCommand(logger, CLI_COMMANDS.observeJavaScriptRuntime, async () => {
const context = runtimeContext();
const input = {
inspector_endpoint: args.endpoint,
target_id: args.targetId,
runtime_kind: options.runtimeKind,
observation_ms: options.observationMs,
};
const parsed = observeJavaScriptRuntimeInputSchema.safeParse(input);
if (!parsed.success)
return cliError(
analysisInputErrorFromIssues(
"observe_javascript_runtime",
parsed.error.issues,
input,
),
);
const result = await observeJavaScriptRuntime(
context.provider,
parsed.data,
);
return result.ok ? result.value : cliError(result.error);
}),
withCommandCancellation((signal) =>
logCliCommand(
logger,
CLI_COMMANDS.observeJavaScriptRuntime,
async () => {
const context = runtimeContext();
const input = {
inspector_endpoint: args.endpoint,
target_id: args.targetId,
runtime_kind: options.runtimeKind,
observation_ms: options.observationMs,
};
const parsed = observeJavaScriptRuntimeInputSchema.safeParse(input);
if (!parsed.success)
return cliError(
analysisInputErrorFromIssues(
"observe_javascript_runtime",
parsed.error.issues,
input,
),
);
const result = await observeJavaScriptRuntime(
context.provider,
parsed.data,
{ signal },
);
return result.ok ? result.value : cliError(result.error);
},
),
),
});
};