refactor(tools): remove artificial analysis ceilings

This commit is contained in:
morluto
2026-09-29 16:29:23 +08:00
parent 36aeec9586
commit 2f08c7c932
202 changed files with 2314 additions and 3072 deletions
@@ -133,6 +133,33 @@ describe("Apple application projection", () => {
second.value.normalized_result,
);
expect(left).toEqual(right);
const longPath = `Payload/${"deep/".repeat(1_000)}Fixture.app`;
expect(
appleApplicationProjectionResultSchema.parse({
...left,
application_roots: [longPath],
}).application_roots,
).toEqual([longPath]);
expect(
appleApplicationProjectionResultSchema.parse({
...left,
limitations: ["x".repeat(5_000)],
}).limitations,
).toEqual(["x".repeat(5_000)]);
const [framework, ...otherFrameworks] = left.components.frameworks;
if (framework === undefined) throw new Error("Expected framework fixture");
expect(
appleApplicationProjectionResultSchema.parse({
...left,
components: {
...left.components,
frameworks: [
{ ...framework, format: "x".repeat(500) },
...otherFrameworks,
],
},
}).components.frameworks[0]?.format,
).toBe("x".repeat(500));
expect(left).toMatchObject({
root_format: "ipa",
application_roots: ["Payload/Fixture.app"],
@@ -178,7 +205,9 @@ describe("Apple application projection", () => {
error: { _tag: "AnalysisInputError" },
});
});
});
describe("Apple application projection completeness", () => {
it("returns every component, inventory page, and bridge hypothesis", async () => {
const projection = await createCompleteAppleProjection();
expect(projection.components.frameworks).toHaveLength(1_001);
@@ -193,12 +222,6 @@ describe("Apple application projection", () => {
});
expect(projection).not.toHaveProperty("omitted_components");
expect(projection).not.toHaveProperty("omitted_bridge_candidates");
expect(
appleApplicationProjectionResultSchema.parse({
...projection,
limitations: Array.from({ length: 101 }, (_, index) => `fact ${index}`),
}).limitations,
).toHaveLength(101);
});
it("infers an application root when the IPA omits directory entries", async () => {
@@ -59,23 +59,33 @@ const evidencePages = (
),
);
const changedArtifactComparison = async () => {
const parent = await createTestTempDirectory("rea-artifact-compare-");
const leftPath = join(parent, "left.app");
const rightPath = join(parent, "right.app");
await Promise.all([mkdir(leftPath), mkdir(rightPath)]);
await Promise.all([
writeFile(join(leftPath, "main.js"), "old();"),
writeFile(join(leftPath, "same.txt"), "same"),
writeFile(join(rightPath, "main.js"), "newer();"),
writeFile(join(rightPath, "same.txt"), "same"),
writeFile(join(rightPath, "added.txt"), "added"),
]);
const left = await observe(leftPath);
const right = await observe(rightPath);
return {
left,
right,
result: compareArtifacts(left, right),
};
};
describe("artifact comparison", () => {
it("classifies deterministic path changes and cites both inventories", async () => {
const parent = await createTestTempDirectory("rea-artifact-compare-");
const leftPath = join(parent, "left.app");
const rightPath = join(parent, "right.app");
await Promise.all([mkdir(leftPath), mkdir(rightPath)]);
await Promise.all([
writeFile(join(leftPath, "main.js"), "old();"),
writeFile(join(leftPath, "same.txt"), "same"),
writeFile(join(rightPath, "main.js"), "newer();"),
writeFile(join(rightPath, "same.txt"), "same"),
writeFile(join(rightPath, "added.txt"), "added"),
]);
const left = await observe(leftPath);
const right = await observe(rightPath);
const first = compareArtifacts(left, right);
const second = compareArtifacts(left, right);
const firstObservation = await changedArtifactComparison();
const secondObservation = await changedArtifactComparison();
const first = firstObservation.result;
const second = secondObservation.result;
expect(first).toEqual(second);
expect(artifactComparisonResultSchema.parse(first)).toMatchObject({
status: "changed",
@@ -85,8 +95,8 @@ describe("artifact comparison", () => {
]),
});
expect(first.changes[0]?.evidence_links).toEqual([
left.evidence_id,
right.evidence_id,
firstObservation.left.evidence_id,
firstObservation.right.evidence_id,
]);
expect(first.changes).toEqual(
expect.arrayContaining([
@@ -103,6 +113,30 @@ describe("artifact comparison", () => {
);
});
it("accepts all reported comparison dimensions", async () => {
const result = (await changedArtifactComparison()).result;
const firstChange = result.changes[0];
if (firstChange === undefined) throw new Error("Expected artifact change");
const dimensions = [
"content",
"kind",
"format",
"size",
"executable",
"relations",
"metadata",
"availability",
"integrity",
] as const;
expect(
artifactComparisonResultSchema.parse({
...result,
changes: [{ ...firstChange, dimensions }, ...result.changes.slice(1)],
}).changes[0]?.dimensions,
).toEqual(dimensions);
});
it("reports incomplete inventory as truncated, never unchanged", async () => {
const root = await createTestTempDirectory("rea-artifact-truncated-");
await writeFile(join(root, "one.txt"), "one");
@@ -138,7 +172,9 @@ describe("artifact comparison", () => {
"Left artifact inventory is incomplete.",
);
});
});
describe("artifact comparison completeness", () => {
it("compares every graph member for inventories larger than 500 entries", async () => {
const root = await createTestTempDirectory("rea-artifact-pages-");
await Promise.all(
@@ -61,8 +61,7 @@ const nonHopperProvider = (operations: string[]): AnalysisProvider => {
requestId: 7,
operation: "analyze_function",
elapsedMs: 31_000,
timeoutMs: 30_000,
callerState: "timed_out",
callerState: "cancelled",
},
queuedRequests: 2,
},
@@ -136,7 +135,7 @@ describe("binary session", () => {
},
},
analysis_activity: {
status: "timed_out_busy",
status: "busy",
providers: [
{
provider: { id: "fixture", name: "Fixture", version: "1" },
@@ -144,8 +143,7 @@ describe("binary session", () => {
request_id: 7,
operation: "analyze_function",
elapsed_ms: 31_000,
timeout_ms: 30_000,
caller_state: "timed_out",
caller_state: "cancelled",
},
queued_requests: 2,
},
@@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest";
import { projectManagedApplicationGraphEvidence } from "../../../src/application/ManagedApplicationGraphService.js";
import { managedApplicationGraphReferenceInputSchema } from "../../../src/contracts/managedWorkflowToolContracts.js";
import { MANAGED_APPLICATION_GRAPH_EXAMPLE } from "../../../src/contracts/managedWorkflowExamples.js";
import { traceApplicationFeatureEvidence } from "../../../src/application/JavaScriptApplicationWorkflowService.js";
import { MANAGED_STATIC_PROVIDER } from "../../../src/application/InvestigationProviders.js";
import { createEvidence, parseEvidence } from "../../../src/domain/evidence.js";
@@ -161,11 +162,11 @@ describe("managed application graph projection", () => {
});
describe("managed application graph request", () => {
it("accepts any nonempty set of sources and rejects duplicate IDs", () => {
const id = `ev_${"a".repeat(64)}`;
it("accepts any nonempty set of inline sources and rejects duplicates", () => {
const evidence = MANAGED_APPLICATION_GRAPH_EXAMPLE.managed_members;
expect(
managedApplicationGraphReferenceInputSchema.safeParse({
managed_members_evidence_id: id,
managed_members: evidence,
}).success,
).toBe(true);
expect(
@@ -173,8 +174,8 @@ describe("managed application graph request", () => {
).toBe(false);
expect(
managedApplicationGraphReferenceInputSchema.safeParse({
managed_members_evidence_id: id,
managed_native_boundaries_evidence_id: id,
managed_members: evidence,
managed_native_boundaries: evidence,
}).success,
).toBe(false);
});
@@ -26,6 +26,15 @@ it("reconstructs package, Electron roles, Webpack/Rspack modules, and cross-laye
expect(Reflect.get(globalThis, "__rea_bundle_executed")).toBeUndefined();
expect(result.input_path).toBe(root);
const longPath = `/${"deep/".repeat(4_000)}application`;
const { electron_summary: summary, ...analysisResult } = result;
expect(
javascriptApplicationAnalysisResultSchema.parse({
...analysisResult,
summary,
input_path: longPath,
}).input_path,
).toBe(longPath);
expect(result.statistics).toMatchObject({
modules: 4,
parse_failures: 0,