Skip to content

armgit / rea

Public Imported from GitHub
0

Reverse engineer anything with agents, from app behavior down to native binaries.

fix(erlang): retain admission cancellation reason

morluto0e3e57756843
diff --git a/src/application/erlang/BeamService.test.ts b/src/application/erlang/BeamService.test.ts
index 12d3a8bcd..258897f3d 100644
--- a/src/application/erlang/BeamService.test.ts
+++ b/src/application/erlang/BeamService.test.ts
@@ -76,10 +76,11 @@ it("records the selected BEAM form", async () => {
it("discards an observation if the caller cancels while the provider completes", async () => {
const controller = new AbortController();
+ const reason = { source: "caller-request", operation: "cancel" };
const service = new BeamService({
identity,
inspect: () => {
- controller.abort();
+ controller.abort(reason);
return Promise.resolve(ok(report));
},
});
@@ -88,5 +89,8 @@ it("discards an observation if the caller cancels while the provider completes",
{ signal: controller.signal },
);
expect(result.ok).toBe(false);
- if (!result.ok) expect(result.error).toBeInstanceOf(AnalysisCancelledError);
+ if (!result.ok) {
+ expect(result.error).toBeInstanceOf(AnalysisCancelledError);
+ expect(result.error.cause).toBe(reason);
+ }
});
diff --git a/src/application/erlang/BeamService.ts b/src/application/erlang/BeamService.ts
index 19ab7fcd9..483ed4579 100644
--- a/src/application/erlang/BeamService.ts
+++ b/src/application/erlang/BeamService.ts
@@ -30,7 +30,11 @@ export class BeamService {
options?: ExecutionOptions,
): Promise<Result<Evidence, AnalysisError>> {
if (options?.signal?.aborted)
- return err(new AnalysisCancelledError(OPERATION));
+ return err(
+ new AnalysisCancelledError(OPERATION, {
+ cause: options.signal.reason,
+ }),
+ );
const input = inspectErlangBeamInputSchema.safeParse(rawInput);
if (!input.success)
return err(
diff --git a/tests/boundary/filesystem/erlangBeam.test.ts b/tests/boundary/filesystem/erlangBeam.test.ts
index 2d1fcec4c..e7337daf9 100644
--- a/tests/boundary/filesystem/erlangBeam.test.ts
+++ b/tests/boundary/filesystem/erlangBeam.test.ts
@@ -50,12 +50,14 @@ describe("Erlang BEAM stable filesystem boundary", () => {
const tooSmall = await service.inspect({ path, max_file_bytes: 16 });
if (tooSmall.ok) throw new Error("Expected resource budget failure");
expect(tooSmall.error._tag).toBe("AnalysisResourceConstraintError");
+ const reason = { source: "caller-request", operation: "cancel" };
const cancelled = await service.inspect(
- { path },
- { signal: AbortSignal.abort() },
+ { path: join(root, "missing.beam") },
+ { signal: AbortSignal.abort(reason) },
);
if (cancelled.ok) throw new Error("Expected cancellation");
expect(cancelled.error._tag).toBe("AnalysisCancelledError");
+ expect(cancelled.error.cause).toBe(reason);
});
it("stops combined table rows at the shared budget", async () => {