Files
rea/src/domain/analysisErrorCleanup.ts
T
morluto 98d8470d36 fix(io): consolidate managed snapshots and retain cleanup ownership
Reuse managed snapshot admission and hashing in sequential path comparisons, retaining caller paths and completed inspection Evidence on later failure. Preserve exact failed-close owners alongside typed read and cancellation failures, and retry them through caller-owned resource scopes. Require canonical Hopper lease identities, remove signed offset coercion, and repair stale setup cleanup expectations that failed CI.
2026-10-12 14:46:37 +08:00

44 lines
1.4 KiB
TypeScript

import { ProviderAdapterError } from "./providerAdapterError.js";
import { projectAnalysisError } from "./analysisErrorProjection.js";
import type { AnalysisError } from "./analysisErrorBase.js";
/** Preserve the original lifecycle failure alongside incomplete cleanup. */
export const analysisErrorWithCleanupFailure = (
primary: AnalysisError,
cleanup: AnalysisError,
operation = "close_binary",
): AnalysisError => {
const projected = projectAnalysisError(cleanup);
return new ProviderAdapterError(
cleanup instanceof ProviderAdapterError ? cleanup.providerId : "rea",
operation,
{
cause: new AggregateError(
[primary, cleanup],
"Analysis failed and cleanup remains incomplete.",
{ cause: primary },
),
userMessage: projectAnalysisError(primary).message,
...(primary.capturedOutput === undefined
? {}
: { capturedOutput: primary.capturedOutput }),
...(primary.partialObservation === undefined
? {}
: { partialObservation: primary.partialObservation }),
cleanup: {
reason: projected.message,
resources: [
...new Set([
...primary.cleanupResources,
...cleanup.cleanupResources,
]),
],
},
diagnostics: {
primary_error: projectAnalysisError(primary),
cleanup_error: projected,
},
},
);
};