Skip to content

armgit / rea

Public Imported from GitHub
0

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

fix(evm): preserve transferred cleanup ownership and bounded output

morluto07540cbcde9c
diff --git a/src/evm/EvmoleFailures.ts b/src/evm/EvmoleFailures.ts
index 63c6578aa..da1bae8d8 100644
--- a/src/evm/EvmoleFailures.ts
+++ b/src/evm/EvmoleFailures.ts
@@ -183,6 +183,9 @@ export const evmInterfaceFailure = (
{
cause,
...cleanupOptions,
+ ...(cause instanceof OwnedCommandFailure && cause.snapshot !== null
+ ? { capturedOutput: capturedEvmOutput(cause.snapshot) }
+ : {}),
diagnostics: {
phase,
path,
@@ -198,13 +201,6 @@ export const evmInterfaceFailure = (
failure_kind: cause.reason,
exit_code: cause.snapshot?.exitCode ?? null,
signal: cause.snapshot?.signal ?? null,
- stdout: cause.snapshot?.stdout.text ?? null,
- stderr: cause.snapshot?.stderr.text ?? null,
- ...(cause.snapshot === null
- ? {}
- : {
- captured_output: { ...capturedEvmOutput(cause.snapshot) },
- }),
}
: {}),
},
diff --git a/src/evm/EvmoleInterfaceProvider.ts b/src/evm/EvmoleInterfaceProvider.ts
index 362816411..1868945a9 100644
--- a/src/evm/EvmoleInterfaceProvider.ts
+++ b/src/evm/EvmoleInterfaceProvider.ts
@@ -85,6 +85,16 @@ const replySchema = z.discriminatedUnion("ok", [
type Launcher = NonNullable<Parameters<typeof runOwnedCommand>[2]>["launcher"];
type EvmOutcome = Result<EvmInterfaceExecution, AnalysisError>;
+const compactErrorProjection = (error: AnalysisError) => {
+ const projection = projectAnalysisError(error);
+ if (error.capturedOutput === undefined) return projection;
+ // The cleanup result owns this exact captured stream. Other diagnostics and
+ // partial Evidence retain their original fields, including stdout/stderr.
+ const details = { ...projection.details };
+ delete details.captured_output;
+ return { ...projection, details };
+};
+
const evmExecutionEvidence = (
input: InspectEvmInterfaceInput,
execution: EvmInterfaceExecution,
@@ -118,7 +128,7 @@ const evmCleanupFailure = (
resources,
{
reason,
- previous_error: result.ok ? null : projectAnalysisError(result.error),
+ previous_error: result.ok ? null : compactErrorProjection(result.error),
...(capturedOutput === undefined
? {}
: { captured_output: { ...capturedOutput } }),
@@ -444,7 +454,10 @@ export class EvmoleInterfaceProvider implements EvmInterfacePort {
}),
);
} catch (cause: unknown) {
- if (cause instanceof OwnedCommandFailure)
+ if (
+ cause instanceof OwnedCommandFailure &&
+ cause.cleanupOwner !== undefined
+ )
processOwner = cause.cleanupOwner;
let fileFailure: EvmFileSizeFailureEvidence | undefined;
let markerCleanupFailure: ArtifactReaderFailure | undefined;
diff --git a/tests/boundary/evm/evmoleInterfaceProvider.test.ts b/tests/boundary/evm/evmoleInterfaceProvider.test.ts
index e83a6e4c0..51b5cb54a 100644
--- a/tests/boundary/evm/evmoleInterfaceProvider.test.ts
+++ b/tests/boundary/evm/evmoleInterfaceProvider.test.ts
@@ -112,12 +112,12 @@ it.runIf(!unsupportedHost).each(["missing", "wrong"])(
if (result.ok) throw new Error("Expected launcher failure");
expect(projectAnalysisError(result.error).code).toBe("execution_failure");
expect(result.error).toMatchObject({
+ capturedOutput: { stdout: "launcher failure", truncated: false },
diagnostics: {
file_size_failure_marker: {
verified: false,
failure: expect.any(String),
},
- captured_output: { stdout: "launcher failure", truncated: false },
},
});
await expect(access(ownedPath)).rejects.toMatchObject({ code: "ENOENT" });
@@ -163,16 +163,12 @@ it.runIf(!unsupportedHost)(
const cleanup = z
.object({
reason: z.string(),
- previous_error: z
- .object({
- failure_kind: z.string(),
- stdout: z.unknown().optional(),
- stderr: z.unknown().optional(),
- })
- .transform(({ failure_kind, stdout, stderr }) => ({
- failure_kind,
- output_repeated: stdout !== undefined || stderr !== undefined,
- })),
+ previous_error: z.object({
+ code: z.string(),
+ category: z.string(),
+ message: z.string(),
+ details: z.record(z.string(), z.unknown()).optional(),
+ }),
captured_output: z.object({
truncated: z.boolean(),
stderr: z.literal(""),
@@ -182,12 +178,13 @@ it.runIf(!unsupportedHost)(
.parse(projectAnalysisError(result.error).details?.["diagnostics"]);
expect(cleanup).toEqual({
reason: "injected post-cleanup reporting failure",
- previous_error: {
- failure_kind: "output-limit",
- output_repeated: false,
- },
+ previous_error: expect.objectContaining({ code: "unreadable_output" }),
captured_output: { truncated: true, stderr: "", stdout: 1048576 },
});
+ expect(cleanup.previous_error.details?.["captured_output"]).toBeUndefined();
+ expect(JSON.stringify(cleanup.previous_error)).not.toContain(
+ "x".repeat(256),
+ );
expect(result.error.cleanupResources).toContain(ownedPath);
await access(ownedPath);
const blocked = await provider.inspect({ path, encoding: "hex" });
@@ -266,7 +263,7 @@ it.runIf(!unsupportedHost).each(["completed", "malformed-reply"] as const)(
reason: "injected retained cleanup failure",
captured_output: { stderr: "worker completed", truncated: false },
...(scenario === "malformed-reply"
- ? { previous_error: { code: "output_failure" } }
+ ? { previous_error: { code: "unreadable_output" } }
: { previous_error: null }),
});
if (scenario === "completed")