fix(providers): keep operation environments consistent through launch

Capture one environment snapshot per admitted WABT, JADX, firmware and Wakaru operation. Use it for tool selection, session identity and child launches while preserving configuration updates between operations.

Regressions reproduce changed JVM options under an old session key, mixed engine/limiter selection and environment drift between subprocesses. Keep selected-wrapper and cleanup coverage in a shared fixture with separate scenarios.

Validation: 115 distinct focused tests passed across the final five-file selection, including seven selected-command cases after refactoring. Fresh build, typecheck, lint and formatting passed. Tests use real subprocess fixtures; no real JADX/WABT/Binwalk/Wakaru engine or native Windows verification is claimed.
This commit is contained in:
morluto
2026-10-27 00:25:22 +08:00
parent 2cdc8cb92e
commit 1d32eb3aa4
7 changed files with 394 additions and 119 deletions
+5 -2
View File
@@ -1,3 +1,4 @@
import { snapshotEnvironment } from "../../process/snapshotEnvironment.js";
import { mkdir, mkdtemp, rm } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -109,6 +110,8 @@ export class WakaruProvider implements JavaScriptRecoveryPort {
): Promise<Result<AnalysisExecution, AnalysisError>> {
const pending = await this.#retire();
if (pending !== undefined) return err(pending);
// Capture configuration after queue/cleanup admission; later requests may select updates.
const environment = snapshotEnvironment(this.environment);
let root: string | undefined;
let tree: SafeOutputTree | undefined;
let failed: { readonly cause: unknown } | undefined;
@@ -117,7 +120,7 @@ export class WakaruProvider implements JavaScriptRecoveryPort {
try {
checkRecoveryCancellation(options?.signal);
const engine = await resolveWakaruCommand(
this.environment,
environment,
this.#resources,
options?.signal,
);
@@ -149,7 +152,7 @@ export class WakaruProvider implements JavaScriptRecoveryPort {
input,
sources,
engine,
environment: this.environment,
environment,
launcher: this.launcher,
options,
deadline,