mirror of
https://github.com/morluto/rea.git
synced 2026-11-11 01:13:39 +00:00
refactor(javascript): own coverage facts and reuse block prefixes
Separate syntax, semantic uncertainty, examination limits and observed Electron applicability at the static producer, then preserve them through worker, graph and retained/inline summary views. Derive the established parse_status from the same facts and leave historical measurements unknown. Give semantic resource-limit classifications one schema owner. Replace repeated block-prefix searches and copies with collector-scoped syntax indexes. Keep invocation environments separate, charge indexing/replay to the existing work budget and yield during prefix work. Remove the superseded synchronous collector entrypoint. Validated producer, worker, CLI/MCP, historical and partial-coverage regressions, plus actual cancellation during indexing. Bounded authored 128/256-call controls preserved all prior facts while replacing repeated search/copy work with one index pass; this is not a throughput or agent-token benchmark.
This commit is contained in:
1 parent
c8269ca497
commit
f62a2baad8
21 files changed
+898
-125
No files matched your search
@@ -0,0 +1,61 @@
|
||||
import { expect, it } from "vitest";
|
||||
import { completeJavaScriptAnalysisSteps } from "./JavaScriptAnalysisControl.js";
|
||||
import { collectElectronWrappedCallPathsSteps } from "../../domain/javascript/electronWrappedCallPaths.js";
|
||||
import {
|
||||
indexJavaScriptBindingsWithReceiversSteps,
|
||||
indexJavaScriptElectronIdentitySteps,
|
||||
} from "../../domain/javascript/javascriptSemanticAnalysis.js";
|
||||
import { completeSemanticSteps } from "../../domain/javascript/javascriptSemanticTraversal.js";
|
||||
import { parseJavaScriptSource } from "../../domain/javascript/javascriptSourceParser.js";
|
||||
import { createJavaScriptAnalysisAccumulator } from "../../domain/javascript/javascriptStaticAnalysisState.js";
|
||||
|
||||
it("cancels actual call-path work while its first seed indexes a long block", async () => {
|
||||
const source = `const e = require("electron"); {
|
||||
e.ipcMain.on("first", event => event.sender.copy());
|
||||
${"0;".repeat(2048)}
|
||||
}`;
|
||||
const parsed = parseJavaScriptSource(source);
|
||||
if (parsed === null) throw new Error("Expected parsed source");
|
||||
const index = completeSemanticSteps(
|
||||
indexJavaScriptBindingsWithReceiversSteps(parsed.program),
|
||||
);
|
||||
const identity = completeSemanticSteps(
|
||||
indexJavaScriptElectronIdentitySteps(parsed.program, index.bindings),
|
||||
);
|
||||
const accumulator = createJavaScriptAnalysisAccumulator(source.length);
|
||||
const work = collectElectronWrappedCallPathsSteps(
|
||||
parsed.program,
|
||||
index.bindings,
|
||||
source,
|
||||
accumulator,
|
||||
identity,
|
||||
);
|
||||
// The first candidate has not yet been expanded: this checkpoint is inside
|
||||
// its block indexing, before the walker's completed batch is yielded.
|
||||
expect(work.next()).toEqual({ done: false, value: undefined });
|
||||
expect(accumulator.ipc).toEqual([]);
|
||||
const controller = new AbortController();
|
||||
const reason = { request: "cancel prefix indexing" };
|
||||
controller.abort(reason);
|
||||
await expect(
|
||||
completeJavaScriptAnalysisSteps(work, controller.signal),
|
||||
).rejects.toMatchObject({ reason: "cancelled", cause: reason });
|
||||
expect(work.next()).toEqual({ done: true, value: undefined });
|
||||
expect(accumulator.ipc).toEqual([]);
|
||||
expect(accumulator.electronCallPathLimitReached).toBeUndefined();
|
||||
|
||||
// A new analysis owns a new index and can still complete the same source.
|
||||
const completed = createJavaScriptAnalysisAccumulator(source.length);
|
||||
expect(
|
||||
completeSemanticSteps(
|
||||
collectElectronWrappedCallPathsSteps(
|
||||
parsed.program,
|
||||
index.bindings,
|
||||
source,
|
||||
completed,
|
||||
identity,
|
||||
),
|
||||
),
|
||||
).toContainEqual(expect.objectContaining({ entry: "first", conditions: [] }));
|
||||
expect(completed.electronCallPathLimitReached).toBeUndefined();
|
||||
});
|
||||
Reference in new issue
Block a user