Skip to content

armgit / rea

Public Imported from GitHub
0

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

fix(errors): exclude recovered cleanup resources

morluto3ed925e54779
diff --git a/docs/tool-design.md b/docs/tool-design.md
index dd923af34..93e4af587 100644
--- a/docs/tool-design.md
+++ b/docs/tool-design.md
@@ -103,6 +103,10 @@ providers need not expose identical state machines.
when close options change. Preserve observed child failure or activity when
another child's health is unavailable; idle plus missing coverage stays
unknown.
+ Bind cleanup failures to their exact resource owner. Resolve current cleanup
+ uncertainty only after that owner confirms release, while preserving the
+ original failure and completed observations. Later failure composition must
+ report only resources whose cleanup remains unresolved.
- Await one-shot cleanup without discarding the completed result or primary
diagnostic. Preserve partial observations, remaining resources, and the cleanup
owner's recovery instructions. CLI adapters should reuse
diff --git a/src/domain/analysisErrorCleanup.ts b/src/domain/analysisErrorCleanup.ts
index 2256c0093..3dc8ed6f7 100644
--- a/src/domain/analysisErrorCleanup.ts
+++ b/src/domain/analysisErrorCleanup.ts
@@ -30,7 +30,7 @@ export const analysisErrorWithCleanupFailure = (
reason: projected.message,
resources: [
...new Set([
- ...primary.cleanupResources,
+ ...(primary.cleanupIncomplete ? primary.cleanupResources : []),
...cleanup.cleanupResources,
]),
],
diff --git a/src/domain/providerCleanupError.test.ts b/src/domain/providerCleanupError.test.ts
index 01d8523bd..b3e24861d 100644
--- a/src/domain/providerCleanupError.test.ts
+++ b/src/domain/providerCleanupError.test.ts
@@ -1,6 +1,7 @@
import { expect, it } from "vitest";
import { ProviderCleanupError } from "./providerCleanupError.js";
import { projectAnalysisError } from "./analysisErrorProjection.js";
+import { analysisErrorWithCleanupFailure } from "./analysisErrorCleanup.js";
it("preserves the binary cleanup default and an explicitly owned nonbinary operation", () => {
expect(new ProviderCleanupError("ghidra", ["database"], {}).operation).toBe(
"close_binary",
@@ -17,3 +18,38 @@ it("preserves the binary cleanup default and an explicitly owned nonbinary opera
details: { operation: "trace_web_source_location" },
});
});
+
+it.each([false, true])(
+ "reports only live primary resources after cleanup recovery is %s",
+ (recovered) => {
+ const primary = new ProviderCleanupError("adb", ["descriptor"], {
+ reason: "descriptor close failed",
+ });
+ if (recovered) primary.resolveCleanup();
+ const cleanup = new ProviderCleanupError("adb", ["runtime-root"], {
+ reason: "root removal failed",
+ });
+ const combined = analysisErrorWithCleanupFailure(primary, cleanup);
+ expect(combined.cleanupResources).toEqual(
+ recovered ? ["runtime-root"] : ["descriptor", "runtime-root"],
+ );
+ expect(projectAnalysisError(combined)).toMatchObject({
+ code: "cleanup_incomplete",
+ details: {
+ diagnostics: {
+ primary_error: {
+ details: { diagnostics: { reason: "descriptor close failed" } },
+ },
+ cleanup_error: {
+ details: { diagnostics: { reason: "root removal failed" } },
+ },
+ },
+ },
+ });
+ expect(combined.cause).toBeInstanceOf(AggregateError);
+ expect((combined.cause as AggregateError).errors).toEqual([
+ primary,
+ cleanup,
+ ]);
+ },
+);