Files
reverse-engineering-anything/src/domain/artifactOperationError.ts
T
morluto cb4e5cfbff feat(analysis): make resource budgets recoverable across CLI and MCP (#9706)
* refactor(analysis): centralize resource budgets and recovery facts

* feat(analysis): expose ASAR and Ghidra runtime admission controls

* feat(artifacts): expose reader admission and preserve limited recognition

* feat(javascript): expose recoverable semantic precision budgets

* feat(web): add recoverable source-map budgets and compact retained views

* feat(web): make historical capture decoding budgets recoverable

* fix(desktop): enforce selected view policies across capture and export

* feat(runtime): make Frida and LLDB retention budgets selectable

* feat(native): expose diagnostic budgets and preserve exhaustion causes

* feat(managed): expose recoverable snapshot and representation budgets

* feat(metadata): make Go and Rust inspection budgets recoverable

* feat(wasm): expose representation and producer admissions

* feat(evm): expose per-call worker resource budgets

* feat(android): make resource and string-pool omissions recoverable

* feat(producers): expose command and recorded-capture budgets

* docs(analysis): record recovery contracts and integrated validation

* fix(docs): link calibration oracle from published verification pages

* fix(docs): restore desktop task anchors and receipt links

* test(analysis): align fixtures with selectable budget contracts

* fix(analysis): remove source-location projector dependency cycle

* test(analysis): refresh budget recovery and verifier regressions

* test(analysis): preserve format and publication recovery expectations

* test(windows): align conformance with owned runtime admission

* fix(desktop): preserve selected alias kinds in exported state

* test(analysis): align provider fixtures with recoverable budgets

* test(desktop): validate emitted alias metadata structurally

* fix(ghidra): classify bounded Windows endpoint refusals

* test(cli): assert selectable artifact admission recovery

* fix(cli): preserve capture provenance in environment builds
2026-11-10 05:11:20 -05:00

102 lines
3.4 KiB
TypeScript

import {
projectArtifactIntegrityDetails,
type ArtifactIntegrityDetails,
} from "./artifactIntegrity.js";
import {
AnalysisError,
type AnalysisErrorOptions,
} from "./analysisErrorBase.js";
import type { ArtifactReaderLimitFact } from "./artifactReaderLimits.js";
/** The resource class that refused an artifact operation. */
export type ArtifactLimitBoundary = "file-size" | "capacity" | "memory";
/** Admission named by the producing reader, with its effective byte ceiling and its source. */
export interface ArtifactAdmissionLimit {
readonly kind: "asar-header" | "asar-listing";
readonly requiredBytes?: number;
readonly maximumBytes: number;
readonly source: "default" | "setting" | "runtime";
}
/** Artifact inventory or extraction failed a typed safety boundary. */
export class ArtifactOperationError extends AnalysisError {
readonly _tag = "ArtifactOperationError";
override readonly userMessage: string | undefined;
readonly remediationAction: string | undefined;
readonly admission: ArtifactAdmissionLimit | undefined;
readonly boundary: ArtifactLimitBoundary | undefined;
readonly readerLimit: ArtifactReaderLimitFact | undefined;
constructor(
readonly operation:
| "inventory_artifact"
| "inspect_artifact"
| "inspect_desktop_application"
| "inspect_pe_resources"
| "inspect_pe_certificates"
| "inspect_elf_notes"
| "inspect_elf_unwind_ranges"
| "inspect_devicetree"
| "inspect_api_contract"
| "inspect_playwright_trace"
| "inspect_kernel_module"
| "inspect_kernel_build_config"
| "inspect_erlang_beam"
| "inspect_v8_code_cache"
| "extract_artifact"
| "decode_interface_builder"
| "inspect_asset_catalog"
| "inspect_keyed_archive"
| "trace_dylib_resolution"
| "export_web_scripts"
| "trace_web_module_imports"
| "trace_web_source_location"
| "analyze_javascript_application",
readonly reason:
| "cancelled"
| "format"
| "integrity"
| "limit"
| "path"
| "unavailable"
| "io",
readonly artifactDetails?: ArtifactIntegrityDetails,
/** The specific constraint that failed, such as the colliding path. */
readonly detail?: string,
options?: AnalysisErrorOptions & {
readonly userMessage?: string;
readonly remediationAction?: string;
readonly admission?: ArtifactAdmissionLimit;
readonly boundary?: ArtifactLimitBoundary;
readonly readerLimit?: ArtifactReaderLimitFact;
},
) {
super(
artifactDetails === undefined
? `Artifact ${operation} failed: ${reason}`
: artifactDetailsMessage(operation, reason, artifactDetails),
options,
);
this.admission = options?.admission;
this.boundary = options?.boundary;
this.readerLimit = options?.readerLimit;
this.remediationAction = options?.remediationAction;
this.userMessage =
options?.userMessage ??
(options?.admission === undefined ? undefined : detail);
}
}
const artifactDetailsMessage = (
operation: string,
reason: string,
details: ArtifactIntegrityDetails,
): string => {
const { logical_path, ...facts } = projectArtifactIntegrityDetails(details);
const description = Object.entries(facts)
.map(([key, value]) => `${key}=${String(value ?? "unavailable")}`)
.join(", ");
return `Artifact ${operation} failed: ${reason} at ${logical_path} (${description})`;
};