fix(javascript): preserve selected inputs and completed source evidence

This commit is contained in:
morluto committed 2026-10-26 17:39:29 +08:00
1 parent 3864c7d667
commit 721dd3d1aa
11 files changed
+453 -177

No files matched your search

@@ -132,28 +132,6 @@ describe("JavaScript recovery workflow", () => {
expect(cancelled.error.cause).toBe(reason);
}
});
it("rejects additional_paths repeating path or each other", async () => {
const service = new JavaScriptRecoveryService({
recover: async () => {
throw new Error("port must not execute");
},
});
for (const additional_paths of [
[artifact.path],
["/tmp/dir/../bundle.js", "/tmp/bundle.js"],
["/tmp/shared.js", "/tmp/shared.js"],
]) {
const result = await service.recover({
...input,
additional_paths,
});
if (result.ok) throw new Error("expected duplicate rejection");
expect(result.error._tag).toBe("AnalysisInputError");
expect(result.error).toMatchObject({
issues: [{ path: ["additional_paths"], reason: "invalid_format" }],
});
}
});
it("rejects relative additional_paths before acquiring the port", async () => {
let invoked = false;
const service = new JavaScriptRecoveryService({
@@ -1,5 +1,5 @@
import { parseAnalysisInput } from "../AnalysisInput.js";
import { isAbsolute, resolve } from "node:path";
import { isAbsolute } from "node:path";
import {
AnalysisInputError,
@@ -59,24 +59,6 @@ export class JavaScriptRecoveryService {
})),
]),
);
const selectedInputs = new Set(
[parsed.value.path, ...(parsed.value.additional_paths ?? [])].map(
(path) => resolve(path),
),
);
if (
selectedInputs.size !==
1 + (parsed.value.additional_paths ?? []).length
)
return err(
new AnalysisInputError(OPERATION, undefined, [
{
path: ["additional_paths"],
reason: "invalid_format",
message: "additional_paths must not repeat path or each other.",
},
]),
);
const execution = await this.provider.recover(parsed.value, options);
if (!execution.ok) return execution;
const result = javascriptRecoveryResultSchema.safeParse(