refactor(runtime): retain complete reconciliation outputs

This commit is contained in:
morluto
2026-09-29 12:16:32 +08:00
parent 7b3c797237
commit 79ea571512
16 changed files with 106 additions and 190 deletions
@@ -205,7 +205,42 @@ describe("JavaScript export return-shape selection", () => {
});
describe("JavaScript export return-shape projection", () => {
it("marks graph field projection omissions as truncated", async () => {
it("retains more than 64 inferred return fields", async () => {
const properties = Array.from(
{ length: 70 },
(_, index) => `field${String(index)}: ${String(index)}`,
).join(",");
const root = await temporaryRoot();
await writeFile(
join(root, "parser.mjs"),
`export const parse = () => ({ ${properties} });`,
);
const analyzed = await analyzeGraph(root);
const returnShape = analyzed.graph.nodes
.flatMap(({ observations }) => observations)
.find(
({ properties: value }) =>
value.semantic_role === "export-return-shapes",
);
const shapes = returnShape?.properties.static_return_shapes;
expect(Array.isArray(shapes)).toBe(true);
if (!Array.isArray(shapes)) throw new TypeError("Missing return shapes");
const firstShape = shapes[0];
if (
firstShape === null ||
typeof firstShape !== "object" ||
Array.isArray(firstShape)
)
throw new TypeError("Missing first return shape");
expect(firstShape.fields).toHaveLength(70);
expect(returnShape?.properties.return_shape_coverage).toMatchObject({
omitted_fields: 0,
projection_complete: true,
});
});
it("keeps incomplete source property coverage partial", async () => {
const properties = [
'a_type: "item"',
...Array.from(
@@ -219,9 +254,9 @@ describe("JavaScript export return-shape projection", () => {
});
const result = compare(left, right);
expect(result.coverage.status).toBe("truncated");
expect(result.coverage.left_omitted_fields).toBeGreaterThan(0);
expect(result.coverage.right_omitted_fields).toBeGreaterThan(0);
expect(result.coverage.status).toBe("partial");
expect(result.coverage.left_omitted_fields).toBe(0);
expect(result.coverage.right_omitted_fields).toBe(0);
});
});
@@ -67,7 +67,7 @@ it("keeps byte-identical cross-layer candidates explicitly ambiguous", async ()
).toBe(2);
});
it("retains one target per capture and keeps load-state absence unknown when output is bounded", async () => {
it("retains all runtime entities and static load states without projection caps", async () => {
const fixture = await applicationFixture();
temporary.push(fixture);
const staticEvidence = await analyzeFixture(fixture);
@@ -85,11 +85,6 @@ it("retains one target per capture and keeps load-state absence unknown when out
const result = reconcileJavaScriptRuntime({
static_layers: [{ role: "application", analysis: staticEvidence }],
runtime_observations: runtimeObservations,
limits: {
max_runtime_entities: 2,
max_reconciliation_items: 2,
max_static_load_states: 20_000,
},
});
expect(result.runtime_captures).toHaveLength(2);
@@ -98,19 +93,22 @@ it("retains one target per capture and keeps load-state absence unknown when out
).toBe(2);
expect(result.summary).toMatchObject({
runtime_targets: 2,
runtime_frames: 0,
runtime_scripts: 0,
runtime_frames: 2,
runtime_scripts: 2,
runtime_workers: 0,
static_not_observed: 0,
static_not_observed: 2,
});
expect(result.coverage).toMatchObject({
status: "truncated",
truncated: true,
omitted_runtime_entities: 4,
omitted_runtime_entities: 0,
omitted_reconciliation_items: 0,
omitted_static_load_states: 0,
});
expect(
result.static_load_states.every(({ status }) => status === "unknown"),
).toBe(true);
expect(result.static_load_states).toHaveLength(
result.summary.static_loaded +
result.summary.static_resident +
result.summary.static_not_observed +
result.summary.static_unknown,
);
});
it("rejects runtime source bytes whose Evidence omits source-capture approval", async () => {
@@ -233,15 +231,6 @@ const electronRuntimeEvidence = (
target_id: targetId,
observation_ms: 100,
include_script_sources: sourceIncluded,
limits: {
max_frames: 200,
max_dom_nodes: 2_000,
max_scripts: 500,
max_resources: 2_000,
max_workers: 500,
max_script_source_bytes: 1_048_576,
max_total_script_source_bytes: 4_194_304,
},
});
return createElectronEvidence(
"inspect_electron_page",
@@ -354,15 +354,6 @@ const electronRuntimeEvidence = (
target_id: targetId,
observation_ms: 100,
include_script_sources: sourceIncluded,
limits: {
max_frames: 200,
max_dom_nodes: 2_000,
max_scripts: 500,
max_resources: 2_000,
max_workers: 500,
max_script_source_bytes: 1_048_576,
max_total_script_source_bytes: 4_194_304,
},
});
return createElectronEvidence(
"inspect_electron_page",