mirror of
https://github.com/morluto/rea.git
synced 2026-11-13 10:12:50 +00:00
perf(javascript): query selected source-to-bundle facts (#6128)
Select completed source-to-bundle mappings and candidates through the shared view owner, preserve reference-file provenance, and retain full Evidence. Reuse bounded JSON reading, heap admission, and cancellation before session writes. Verified public Redux Toolkit source/map facts with an independent oracle, equivalent CLI/MCP workflows, focused negative controls, and complete CI/review. Historical paired SDK context estimates fall about 64%; timing/resource tradeoffs and final verification receipts are recorded without a general speedup or actual model-token claim. Fixes #6112.
This commit is contained in:
1 parent
a0214e0e0e
commit
0583fc69be
29 files changed
+3527
-129
No files matched your search
@@ -10,41 +10,9 @@ import { AnalysisCancelledError } from "../../domain/analysisErrorCore.js";
|
||||
import { JsonInputPhysicalReadFailure } from "../JsonInputFile.js";
|
||||
import { failFileReadAfterAbort } from "../../../tests/support/failFileReadAfterAbort.js";
|
||||
import { holdFirstFileRead } from "../../../tests/support/holdFirstFileRead.js";
|
||||
import {
|
||||
estimateJsonValueBytes,
|
||||
readEvidenceFileSource,
|
||||
requireAuthenticationHeadroom,
|
||||
} from "./evidenceFileSource.js";
|
||||
import { readEvidenceFileSource } from "./evidenceFileSource.js";
|
||||
|
||||
describe("evidence-file source", () => {
|
||||
it("estimates parsed JSON at no less than its UTF-16 text", () => {
|
||||
const text = "x".repeat(1000);
|
||||
expect(estimateJsonValueBytes(text)).toBeGreaterThanOrEqual(2000);
|
||||
expect(
|
||||
estimateJsonValueBytes({ outer: [text, { inner: text }] }),
|
||||
).toBeGreaterThan(2 * estimateJsonValueBytes(text));
|
||||
});
|
||||
|
||||
it("refuses authentication when live heap headroom cannot hold its copies", () => {
|
||||
const value = { normalized_result: "y".repeat(10_000) };
|
||||
expect(
|
||||
requireAuthenticationHeadroom(value, "/tmp/capture.json", 1024),
|
||||
).toMatchObject({
|
||||
ok: false,
|
||||
error: {
|
||||
_tag: "AnalysisResourceConstraintError",
|
||||
resource: "memory",
|
||||
reportedLimits: {
|
||||
input_path: "/tmp/capture.json",
|
||||
available_heap_bytes: 1024,
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(
|
||||
requireAuthenticationHeadroom(value, "/tmp/capture.json", 1 << 30),
|
||||
).toEqual({ ok: true, value: undefined });
|
||||
});
|
||||
|
||||
it("refuses a cancelled request before reading and reads within the caller's resource scope", async () => {
|
||||
const controller = new AbortController();
|
||||
const reason = new JsonInputPhysicalReadFailure(
|
||||
|
||||
Reference in new issue
Block a user