fix(electron): own fuse cleanup through adapters and shutdown

Adapt the prepared descriptor lifecycle repair from xu91102/rea dbb7db16. Bind exact file cleanup leases, retain typed physical failures and cancellation reasons, and join CLI/MCP finalization and active preflight. Share canonical Evidence construction and retain completed reports across reader handoff cancellation.

Scope active capture admission through shutdown and gate launch after close. Preserve successful descriptor peers and retry only unresolved owners. Separate process/transport retry ownership remains tracked in #4805.

Validation: 168 focused checks passed, one Windows-only skip; built CLI and actual stdio MCP controlled descriptor recovery; build, static and docs checks. No natural OS fault or real Electron launch/teardown claim. Ordinary full replies and Evidence IDs remain byte identical across 30 small CLI tasks.

Fixes #4658

Co-authored-by: hhang <[email protected]>
This commit is contained in:
morlutoandhhang committed 2026-10-17 21:24:00 +08:00
1 parent 2d84c800bc
commit f9de41371f
21 files changed
+1522 -354

No files matched your search

+27 -10
View File
@@ -41,7 +41,6 @@ const registerElectronFuseCommand = (
cli: ReturnType<typeof Cli.create>,
logger: Logger,
): void => {
const service = createElectronFuseService();
cli.command(CLI_COMMANDS.inspectElectronFuses, {
description:
"Inspect packaged Electron fuse bytes without launching the application",
@@ -55,11 +54,19 @@ const registerElectronFuseCommand = (
run: ({ args }) =>
withCommandCancellation((signal) =>
logCliCommand(logger, CLI_COMMANDS.inspectElectronFuses, async () => {
const result = await service.inspect(
{ path: absoluteElectronFusePath(args.path) },
{ signal },
const service = createElectronFuseService();
return finishAnalysisCommand(
() =>
service.inspect(
{ path: absoluteElectronFusePath(args.path) },
{ signal },
),
service,
service.provider.identity.id,
"inspect_electron_fuses",
undefined,
signal,
);
return result.ok ? result.value : projectAnalysisError(result.error);
}),
),
});
@@ -117,12 +124,22 @@ const registerElectronActiveCommand = (
await import("../application/javascript/ElectronActiveObservationService.js");
const { createElectronScenarioProvider } =
await import("../composition/electronScenario.js");
const result = await captureElectronScenario(
createElectronScenarioProvider(environment),
parsed.data,
{ signal },
const provider = createElectronScenarioProvider(environment);
const result = await finishAnalysisCommand(
() => captureElectronScenario(provider, parsed.data, { signal }),
{
close: async () => {
await provider.close?.();
},
},
provider.identity().id,
"capture_electron_scenario",
undefined,
signal,
);
return result.ok ? result.value : cliError(result.error);
return "code" in result
? { error: "Electron analysis failed", ...result }
: result;
},
),
),