fix(hopper): add bounded analysis recovery
This commit is contained in:
@@ -60,6 +60,7 @@ export const projectAnalysisError = (
|
||||
};
|
||||
|
||||
const errorCode = (error: AnalysisError): AnalysisErrorProjection["code"] => {
|
||||
if (error.cleanupIncomplete) return "cleanup_incomplete";
|
||||
if (error instanceof ReplayPlanStaleError) return "plan_stale";
|
||||
if (error instanceof PermissionRequiredError) return "permission_required";
|
||||
if (error instanceof ProviderSelectionError)
|
||||
@@ -295,6 +296,12 @@ const providerErrorDetails = (
|
||||
return {
|
||||
provider_id: error.providerId,
|
||||
operation: error.operation,
|
||||
...(error.cleanupIncomplete
|
||||
? {
|
||||
cleanup: "incomplete",
|
||||
resources: [...error.cleanupResources],
|
||||
}
|
||||
: {}),
|
||||
...(error.diagnostics === undefined
|
||||
? {}
|
||||
: { diagnostics: error.diagnostics }),
|
||||
|
||||
@@ -143,6 +143,18 @@ const boundedSchema = <T extends z.ZodType>(item: T) =>
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/** Provider-neutral bounded raw-instruction window for one analyzed function. */
|
||||
export const functionInstructionWindowSchema = z
|
||||
.object({
|
||||
procedure: procedureIdentitySchema,
|
||||
instructions: boundedSchema(z.string()),
|
||||
instructions_scanned: z.number().int().min(0),
|
||||
instruction_scan_truncated: z.boolean(),
|
||||
limitations: z.array(z.string()),
|
||||
})
|
||||
.strict();
|
||||
|
||||
const availableReferenceKindSchema = z
|
||||
.object({
|
||||
available: z.literal(true),
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import { ProviderAdapterError } from "./errors.js";
|
||||
import type { JsonValue } from "./jsonValue.js";
|
||||
|
||||
/** Provider resources could not be proven closed after bounded cleanup. */
|
||||
export class ProviderCleanupError extends ProviderAdapterError {
|
||||
override readonly cleanupIncomplete = true;
|
||||
override readonly cleanupResources: readonly string[];
|
||||
override readonly userMessage =
|
||||
"Provider cleanup could not be fully confirmed. Review the reported local resources before opening another target.";
|
||||
|
||||
constructor(
|
||||
providerId: string,
|
||||
resources: readonly string[],
|
||||
diagnostics: Readonly<Record<string, JsonValue>>,
|
||||
options?: ErrorOptions,
|
||||
) {
|
||||
super(providerId, "close_binary", { ...options, diagnostics });
|
||||
this.cleanupResources = [...resources];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user