refactor(admission): own inspector, web, and CLI state per host (#8058)

* refactor(admission): own inspector, web, and CLI state per host

Replace the process-global inspector, web-bundle, guidance, and JavaScript
counters with objects a host passes in, so independent instances do not
share admission or cleanup.

* fix(admission): keep worker and file cleanup on the host

Web-bundle and JavaScript workers retry only their host registry, and
each Inspector admission authorizes and closes its own file scope.
Browser providers can share one web-bundle admission.

* test(inspector): gate one admission's file cleanup

The isolation test delayed the first ArtifactResourceScope.retryCleanup
call, so a second call on a shared ElectronFileScope still finished.
Hold first.files.retryCleanup until the other admission's close
finishes, then release and join before restoring the method.

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
This commit is contained in:
morlutoandCursor Agent authored and GitHub committed 2026-10-30 05:23:33 +08:00
1 parent b663c79552
commit 395b598383
21 files changed
+782 -269

No files matched your search

+10 -4
View File
@@ -6,6 +6,7 @@ import {
observeJavaScriptRuntime,
} from "../application/javascript/JavaScriptRuntimeObservationService.js";
import { createJavaScriptRuntimeObservationProvider } from "../composition/javascriptRuntimeObservation.js";
import { V8InspectorAdmission } from "../inspector/V8InspectorProvider.js";
import { CLI_COMMANDS } from "../cliCommandNames.js";
import { logCliCommand } from "../cliLogging.js";
import {
@@ -40,6 +41,13 @@ export const registerJavaScriptRuntimeObservationCommands = (
logger: Logger,
environment: Readonly<Record<string, string | undefined>>,
): void => {
const admission = new V8InspectorAdmission();
const providerForCommand = () =>
createJavaScriptRuntimeObservationProvider(
environment,
undefined,
admission,
);
cli.command(CLI_COMMANDS.listJavaScriptRuntimeTargets, {
description: "List Node/Electron V8 Inspector targets",
args: z.object({
@@ -51,8 +59,7 @@ export const registerJavaScriptRuntimeObservationCommands = (
logger,
CLI_COMMANDS.listJavaScriptRuntimeTargets,
async () => {
const provider =
createJavaScriptRuntimeObservationProvider(environment);
const provider = providerForCommand();
const input = {
inspector_endpoint: args.endpoint,
};
@@ -97,8 +104,7 @@ export const registerJavaScriptRuntimeObservationCommands = (
logger,
CLI_COMMANDS.observeJavaScriptRuntime,
async () => {
const provider =
createJavaScriptRuntimeObservationProvider(environment);
const provider = providerForCommand();
const input = {
inspector_endpoint: args.endpoint,
target_id: args.targetId,