Skip to content

armgit / rea

Public Imported from GitHub
0

Reverse engineer anything with agents, from app behavior down to native binaries.

perf(tests): remove timed output and synchronize browser fixtures

morluto693ed332b58d
diff --git a/src/process/capture/TerminalRenderer.test.ts b/src/process/capture/TerminalRenderer.test.ts
index 39d630d3a..b5c99157a 100644
--- a/src/process/capture/TerminalRenderer.test.ts
+++ b/src/process/capture/TerminalRenderer.test.ts
@@ -50,6 +50,33 @@ it("omits trailing blank cells from visible lines without losing rows", async ()
);
});
+it("applies rendered retention cumulatively across sparse frames", async () => {
+ const renderer = new TerminalRenderer({
+ columns: 10,
+ rows: 1,
+ scrollback: 0,
+ maxBytes: 5,
+ normalize: (value) => value,
+ });
+ try {
+ renderer.write("a", 0);
+ renderer.write("b", 1);
+ const frames = await renderer.frames();
+
+ expect(frames.map(({ lines }) => lines)).toEqual([["a"]]);
+ expect(renderer.retention()).toEqual({
+ budget_bytes: 5,
+ observed_bytes: 6,
+ retained_bytes: 2,
+ observed_frames: 2,
+ retained_frames: 1,
+ });
+ expect(renderer.truncated()).toBe(true);
+ } finally {
+ await renderer.dispose();
+ }
+});
+
it("trims only after normalization sees the full-width row", async () => {
const { frames } = await renderFrames("pid 4242", (value) =>
value.replace(/4242 +$/u, "<pid>"),
diff --git a/tests/boundary/browser/cdpBrowserProvider.sensitive_data.test.ts b/tests/boundary/browser/cdpBrowserProvider.sensitive_data.test.ts
index 2a9662577..fa67368c9 100644
--- a/tests/boundary/browser/cdpBrowserProvider.sensitive_data.test.ts
+++ b/tests/boundary/browser/cdpBrowserProvider.sensitive_data.test.ts
@@ -224,6 +224,7 @@ describe("CdpBrowserProvider: explicitly requested text and payload shapes", ()
const browser = await startFakeCdpBrowser({
sensitiveShapes: true,
binaryWebSocketEvent: true,
+ eventsBeforeReply: ["Network.enable"],
});
trackBrowser(browser);
const result = await new CdpBrowserProvider().inspectPage(
diff --git a/tests/boundary/process/processTruncationAdapters.test.ts b/tests/boundary/process/processTruncationAdapters.test.ts
index a346a377e..0a9cf7d9f 100644
--- a/tests/boundary/process/processTruncationAdapters.test.ts
+++ b/tests/boundary/process/processTruncationAdapters.test.ts
@@ -63,30 +63,29 @@ const capture = async (
};
itWithCaptureCapability.each(["cli", "mcp"] as const)(
- "localizes sparse rendered-state exhaustion through %s",
+ "localizes rendered-state expansion exhaustion through %s",
async (adapter) => {
const root = await createTestTempDirectory("rea-rendered-budget-");
+ // CSI REP expands a small raw burst into a full screen, so rendered
+ // exhaustion does not depend on how the PTY batches output chunks.
+ const output = "x\u001b[79b".repeat(24);
const result = await capture(adapter, {
executable: process.execPath,
working_directory: root,
- arguments: [
- "-e",
- "let n=0;const timer=setInterval(()=>{console.log('board '+String(n).padStart(2,'0')+' completed; score '+String(n*10));if(++n===65)clearInterval(timer)},20)",
- ],
+ arguments: ["-e", `process.stdout.write(${JSON.stringify(output)})`],
+ terminal: { columns: 80, rows: 24, scrollback: 0 },
normalization: {
ports: false,
pids: false,
paths: false,
time_bucket_ms: 1,
},
- limits: { output_bytes: 30_000 },
+ limits: { output_bytes: 1_000 },
});
const details = result.truncation_details;
if (details === undefined) throw new Error("Expected producer coverage");
- expect(result.frames.map(({ data }) => data).join("")).toContain(
- "board 64 completed; score 640",
- );
- expect(details.raw_terminal.observed_bytes).toBe(2004);
+ expect(result.frames.map(({ data }) => data).join("")).toBe(output);
+ expect(details.raw_terminal.observed_bytes).toBe(Buffer.byteLength(output));
expect(details.raw_terminal.retained_bytes).toBe(
details.raw_terminal.observed_bytes,
);
@@ -94,9 +93,7 @@ itWithCaptureCapability.each(["cli", "mcp"] as const)(
expect(details.rendered_terminal.observed_frames).toBeGreaterThan(
result.rendered_frames.length,
);
- expect(details.rendered_terminal.retained_bytes).toBeLessThanOrEqual(
- 30_000,
- );
+ expect(details.rendered_terminal.retained_bytes).toBeLessThanOrEqual(1_000);
expect(details.process.coverage).toBe("sampled");
expect(processSourceTruncated(result, "terminal_raw")).toBe(false);
expect(processSourceTruncated(result, "terminal_rendered")).toBe(true);