mirror of
https://github.com/morluto/rea.git
synced 2026-12-03 09:34:20 +00:00
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
This commit is contained in:
1 parent
55b6d2ca20
commit
cb4e5cfbff
515 files changed
+21066
-3637
No files matched your search
@@ -1,10 +1,13 @@
|
||||
import {
|
||||
DEFAULT_BUN_READER_LIMITS,
|
||||
type BunReaderLimits,
|
||||
} from "../../domain/artifactReaderLimits.js";
|
||||
import { open, writeFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { expect, it, vi } from "vitest";
|
||||
import { createTestTempDirectory } from "../../../tests/fixtures/temporaryDirectory.js";
|
||||
import {
|
||||
probeBunStandaloneGraph,
|
||||
bunModuleCountLimit,
|
||||
BUN_GRAPH_SUFFIX_BYTES,
|
||||
} from "./BunModuleGraphLayout.js";
|
||||
import { decodeBunModuleGraph } from "./BunModuleGraphMembers.js";
|
||||
@@ -52,7 +55,7 @@ async function locate(bytes: Buffer) {
|
||||
}
|
||||
|
||||
/** Probe while counting bytes read through the handle. */
|
||||
async function probe(bytes: Buffer) {
|
||||
async function probe(bytes: Buffer, limits?: BunReaderLimits) {
|
||||
const path = join(await createTestTempDirectory("rea-bun-parser-"), "app");
|
||||
await writeFile(path, bytes);
|
||||
const handle = await open(path, "r");
|
||||
@@ -70,7 +73,12 @@ async function probe(bytes: Buffer) {
|
||||
});
|
||||
try {
|
||||
return {
|
||||
result: await probeBunStandaloneGraph(counted, bytes.length),
|
||||
result: await probeBunStandaloneGraph(
|
||||
counted,
|
||||
bytes.length,
|
||||
undefined,
|
||||
limits,
|
||||
),
|
||||
bytesRead,
|
||||
};
|
||||
} finally {
|
||||
@@ -308,7 +316,7 @@ it.each([
|
||||
},
|
||||
);
|
||||
|
||||
it("matches ELF section names in bounded time when headers share one long name", async () => {
|
||||
it("reads a shared long ELF section name once without materializing its string table", async () => {
|
||||
const shnum = 16_383;
|
||||
const stringOffset = 64;
|
||||
const strings = Buffer.alloc(1024 * 1024, 0x61);
|
||||
@@ -325,9 +333,9 @@ it("matches ELF section names in bounded time when headers share one long name",
|
||||
bytes.writeBigUInt64LE(BigInt(stringOffset), header + 24);
|
||||
bytes.writeBigUInt64LE(BigInt(strings.length), header + 32);
|
||||
}
|
||||
const started = performance.now();
|
||||
expect((await probe(bytes)).result).toEqual({ status: "absent" });
|
||||
expect(performance.now() - started).toBeLessThan(2_000);
|
||||
const observed = await probe(bytes);
|
||||
expect(observed.result).toEqual({ status: "absent" });
|
||||
expect(observed.bytesRead).toBeLessThan(shnum * 64 + 1024);
|
||||
});
|
||||
|
||||
it("refuses an excessive table count before reading or allocating the module table", async () => {
|
||||
@@ -340,7 +348,6 @@ it("refuses an excessive table count before reading or allocating the module tab
|
||||
if (result.status !== "present" || result.graph === undefined)
|
||||
throw new Error("Missing graph");
|
||||
const read = vi.fn(result.graph.data.read);
|
||||
const expected = bunModuleCountLimit(count);
|
||||
await expect(
|
||||
decodeBunModuleGraph({
|
||||
...result.graph,
|
||||
@@ -349,7 +356,80 @@ it("refuses an excessive table count before reading or allocating the module tab
|
||||
).rejects.toMatchObject({
|
||||
reason: "limit",
|
||||
boundary: "capacity",
|
||||
message: expected.message,
|
||||
readerLimit: {
|
||||
parameter: "artifact_limits.bun.module_count",
|
||||
effective_value: 100_000,
|
||||
required_value: 100_001,
|
||||
unit: "count",
|
||||
},
|
||||
});
|
||||
expect(read).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it.each([
|
||||
{
|
||||
carrier: "ELF",
|
||||
encode: elfBunSection,
|
||||
field: "recognition_table_bytes",
|
||||
needed: 192,
|
||||
},
|
||||
{
|
||||
carrier: "Mach-O",
|
||||
encode: machoBunSection,
|
||||
field: "recognition_load_command_bytes",
|
||||
needed: 152,
|
||||
},
|
||||
] as const)(
|
||||
"keeps $carrier recognition unknown at its selected boundary and recovers the same graph",
|
||||
async ({ encode, field, needed }) => {
|
||||
const bytes = encode(
|
||||
bunPrefixedPayload(
|
||||
bunModuleGraphPayload({
|
||||
modules: [{ name: "main.js", contents: Buffer.from("retained") }],
|
||||
}),
|
||||
),
|
||||
);
|
||||
const limited = await probe(bytes, {
|
||||
...DEFAULT_BUN_READER_LIMITS,
|
||||
[field]: needed - 1,
|
||||
});
|
||||
expect(limited.result).toMatchObject({
|
||||
status: "limited",
|
||||
failure: {
|
||||
reason: "limit",
|
||||
readerLimit: {
|
||||
parameter: `artifact_limits.bun.${field}`,
|
||||
effective_value: needed - 1,
|
||||
required_value: needed,
|
||||
},
|
||||
},
|
||||
});
|
||||
const recovered = await probe(bytes, {
|
||||
...DEFAULT_BUN_READER_LIMITS,
|
||||
[field]: needed,
|
||||
});
|
||||
expect(recovered.result).toMatchObject({
|
||||
status: "present",
|
||||
claim: {
|
||||
carrier: encode === elfBunSection ? "elf-section" : "mach-o-section",
|
||||
},
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
it("recognizes an ELF Bun name beyond the former string-table prefix without reading the prefix", async () => {
|
||||
const bytes = elfBunSection(
|
||||
bunPrefixedPayload(
|
||||
bunModuleGraphPayload({
|
||||
modules: [{ name: "main.js", contents: Buffer.from("retained") }],
|
||||
}),
|
||||
),
|
||||
1024 * 1024 + 8,
|
||||
);
|
||||
const observed = await probe(bytes);
|
||||
expect(observed.result).toMatchObject({
|
||||
status: "present",
|
||||
claim: { carrier: "elf-section" },
|
||||
});
|
||||
expect(observed.bytesRead).toBeLessThan(1024);
|
||||
});
|
||||
Reference in new issue
Block a user