Files
reverse-engineering-anything/tests/boundary/rust/rustBinaryBudget.test.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

71 lines
2.8 KiB
TypeScript

import { writeFile } from "node:fs/promises";
import { join } from "node:path";
import { expect, it } from "vitest";
import { projectAnalysisError } from "../../../src/domain/analysisErrorProjection.js";
import { RustBinaryProvider } from "../../../src/rust/RustBinaryProvider.js";
import {
createRustImage,
createRustHashOverflowImage,
} from "../../fixtures/rust/image.js";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
it("reports a recoverable compiler prefix without refusing the dependency report", async () => {
const root = await createTestTempDirectory("rea-rust-hash-budget-");
const path = join(root, "many-hashes.elf");
await writeFile(path, createRustHashOverflowImage());
const result = await new RustBinaryProvider().inspect({ path });
if (!result.ok) throw result.error;
expect(result.value.rustc_commit?.coverage).toMatchObject({
reason: "max_rustc_hashes",
effective_limit: 64,
});
expect(result.value.auditable_metadata?.packages).toHaveLength(2);
expect(result.value.limitations).toContainEqual(
expect.stringContaining("--max-rustc-hashes"),
);
});
it("recovers the same complete Rust image after input and report budget changes", async () => {
const root = await createTestTempDirectory("rea-rust-input-budget-");
const path = join(root, "selected.elf");
await writeFile(path, createRustImage({ format: "elf" }));
const provider = new RustBinaryProvider();
try {
const smallInput = await provider.inspect({
path,
producer_limits: { input_bytes: 4095 },
});
if (smallInput.ok) throw new Error("Expected input admission refusal");
const projectedInput = projectAnalysisError(smallInput.error);
expect(projectedInput).toMatchObject({
code: "resource_constraint",
details: { reported_limits: { maximum_input_bytes: 4095 } },
});
expect(projectedInput.remediation.action).toContain(
"producer_limits.input_bytes",
);
const smallReport = await provider.inspect({
path,
producer_limits: { input_bytes: 4096, output_bytes: 16 },
});
if (smallReport.ok) throw new Error("Expected report admission refusal");
const projectedReport = projectAnalysisError(smallReport.error);
expect(projectedReport).toMatchObject({
code: "resource_constraint",
details: { reported_limits: { maximum_output_bytes: 16 } },
});
expect(projectedReport.remediation.action).toContain(
"producer_limits.output_bytes",
);
const recovered = await provider.inspect({
path,
producer_limits: { input_bytes: 4096, output_bytes: 16384 },
});
if (!recovered.ok) throw recovered.error;
expect(recovered.value.auditable_metadata?.packages).toHaveLength(2);
expect(recovered.value.artifact.bytes).toBe(4096);
} finally {
await provider.close();
}
});