fix(electron): preserve selected fuse inspection paths (#3104)

Preserve caller-selected POSIX symlink/parent paths during CLI anchoring and
Electron bundle traversal. Resolve terminal directory suffixes through checked
real directories, retaining their identities for before/after readback. Keep
the existing Windows CLI resolution, bounded scan, and output contracts.

Validation: six regressions reproduced on main 7ad75bdc8; 41 focused tests pass
with one Windows-only skip. Full static/docs checks and final main-sync fast
checks pass. Official Electron v44.7.1 release archives, extracted executable
hashes and independent fuse wires verify actual ELF/PE/Mach-O bytes. Real CLI
and stdio MCP reproduce main's wrong target and confirm corrected artifact
identity plus CLI/MCP parity; owned MCP servers exit. Equivalent direct-file
outputs remain 963-1,054 o200k tokens. Individual timing measurements and their
limits are recorded in the PR; no speedup is claimed. Native Windows/macOS REA
execution and target application execution are not claimed.

Co-authored-by: Yann Roberto <165009858+shoyann@users.noreply.github.com>
Co-authored-by: N0zoM1z0 <161784452+N0zoM1z0@users.noreply.github.com>
Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2026-10-14 12:49:17 +08:00
1 parent f4df6ab280
commit ec67aebed0
5 files changed
+304 -29

No files matched your search

+12 -2
View File
@@ -1,4 +1,4 @@
import { resolve } from "node:path";
import { isAbsolute, resolve, sep } from "node:path";
import { Cli, z } from "incur";
@@ -55,7 +55,7 @@ const registerElectronFuseCommand = (
withCommandCancellation((signal) =>
logCliCommand(logger, CLI_COMMANDS.inspectElectronFuses, async () => {
const result = await service.inspect(
{ path: resolve(args.path) },
{ path: absoluteElectronFusePath(args.path) },
{ signal },
);
return result.ok ? result.value : projectAnalysisError(result.error);
@@ -64,6 +64,16 @@ const registerElectronFuseCommand = (
});
};
/** Anchor relative input without changing which file symlink/.. selects. */
const absoluteElectronFusePath = (path: string): string => {
if (path === "") return path;
// Win32 resolves dot components before directory links, including drive-relative paths.
if (sep === "\\") return resolve(path);
if (isAbsolute(path)) return path;
const base = process.cwd();
return `${base}${base.endsWith(sep) ? "" : sep}${path}`;
};
const registerElectronActiveCommand = (
cli: ReturnType<typeof Cli.create>,
logger: Logger,