* refactor(test): colocate pure-domain tests and reduce test debt Move focused immutable domain/contracts/adapter tests from tests/composition/** beside their production owners under src/** as colocated *.test.ts/*.fixture.ts, and relocate persistence-shaped composition tests under tests/boundary/filesystem/**. Update import paths, the Vitest project topology (shared worker context for pure domain/contracts and recording-port service projects), the test migration ledger, testing docs, and AGENTS.md to match. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * docs: remove test migration ledger The cutover is complete and the ledger is no longer referenced anywhere in source, scripts, or the docs gate. Drop the standalone artifact. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * docs: clean up stale migration artifacts Remove empty directories left by the test migration and replace the "final cutover" language in docs/testing.md with standing PR guidance that no longer references the completed migration. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix: repair CI failures from schema, knip, and stale generated artifacts Three root causes fixed: 1. catalog-schemas.mjs: valuesAt only traversed anyOf from Zod's toJSONSchema, not oneOf. The webScreenshotDiffSchema change to a discriminated union produces oneOf, so the product catalog generator could not derive the web_screenshot_diff schema version. Add oneOf traversal. 2. conformancePackage.ts: the test rewrite removed the only imports of ScenarioManifest, ReplayPlan, ShimPlan, and ExpectedEvidence, making them unused exports that knip flags. Remove the dead type aliases. 3. Regenerate stale artifacts (product catalog, MCP tool catalog, skill metadata, conformance manifest) that drifted from the source changes. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
143 lines
5.1 KiB
TypeScript
143 lines
5.1 KiB
TypeScript
import { Client, InMemoryTransport } from "@modelcontextprotocol/client";
|
|
import { describe, expect, it } from "vitest";
|
|
import { copyFile, mkdir, rm } from "node:fs/promises";
|
|
import { join, resolve } from "node:path";
|
|
|
|
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
|
|
|
import { createTestBinarySession } from "../../fixtures/binarySession.js";
|
|
import { createServer } from "../../../src/server/createServer.js";
|
|
import { observed } from "../../fixtures/analysisExecution.js";
|
|
import { analyzeJavaScriptApplication } from "../../../src/application/JavaScriptApplicationService.js";
|
|
import { javascriptApplicationAnalysisResultSchema } from "../../../src/domain/javascriptApplicationAnalysis.js";
|
|
import { permissionAuthorityForRoot } from "../../fixtures/permissionAuthority.js";
|
|
|
|
describe("application workflow MCP parity", () => {
|
|
it("compares exact parser export shapes through full Evidence and session IDs", async () => {
|
|
const root = await createTestTempDirectory("rea-export-shape-mcp-");
|
|
const leftRoot = join(root, "left");
|
|
const rightRoot = join(root, "right");
|
|
await Promise.all([mkdir(leftRoot), mkdir(rightRoot)]);
|
|
await Promise.all([
|
|
copyFile(
|
|
resolve("tests/fixtures/replay/parser.mjs"),
|
|
join(leftRoot, "parser.mjs"),
|
|
),
|
|
copyFile(
|
|
resolve("tests/fixtures/replay/parser-v2.mjs"),
|
|
join(rightRoot, "parser.mjs"),
|
|
),
|
|
]);
|
|
const authority = await permissionAuthorityForRoot(
|
|
root,
|
|
["investigation_input"],
|
|
["investigation_input"],
|
|
);
|
|
const [left, right] = await Promise.all([
|
|
analyzeJavaScriptApplication(authority, {
|
|
input_path: leftRoot,
|
|
approved: true,
|
|
}),
|
|
analyzeJavaScriptApplication(authority, {
|
|
input_path: rightRoot,
|
|
approved: true,
|
|
}),
|
|
]);
|
|
if (!left.ok) throw left.error;
|
|
if (!right.ok) throw right.error;
|
|
const session = createTestBinarySession(() => ({
|
|
execute: () => Promise.resolve(observed(null)),
|
|
close: () => Promise.resolve(),
|
|
}));
|
|
const server = createServer(session, session);
|
|
const client = new Client({ name: "export-shape-test", version: "1" });
|
|
const [clientTransport, serverTransport] =
|
|
InMemoryTransport.createLinkedPair();
|
|
const selectors = {
|
|
left_module_path: "parser.mjs",
|
|
left_export_name: "default",
|
|
right_module_path: "parser.mjs",
|
|
right_export_name: "default",
|
|
};
|
|
try {
|
|
await server.connect(serverTransport);
|
|
await client.connect(clientTransport);
|
|
const full = await client.callTool({
|
|
name: "compare_javascript_export_shapes",
|
|
arguments: { left: left.value, right: right.value, ...selectors },
|
|
});
|
|
expect(full.isError).not.toBe(true);
|
|
expect(full.structuredContent).toMatchObject({
|
|
result: {
|
|
summary: { added: 1, removed: 0, changed: 0, unknown: 0 },
|
|
changes: [
|
|
{
|
|
status: "added",
|
|
path: "/depth",
|
|
right: { availability: "literal", value: 1 },
|
|
},
|
|
],
|
|
},
|
|
});
|
|
expect(session.exportEvidenceBundle().records).toEqual(
|
|
expect.arrayContaining([
|
|
expect.objectContaining({
|
|
operation: "compare_javascript_export_shapes",
|
|
predicate_type: "rea.javascript-export-shape-comparison/v1",
|
|
}),
|
|
]),
|
|
);
|
|
|
|
const byId = await client.callTool({
|
|
name: "compare_javascript_export_shapes",
|
|
arguments: {
|
|
left_evidence_id: left.value.evidence_id,
|
|
right_evidence_id: right.value.evidence_id,
|
|
...selectors,
|
|
},
|
|
});
|
|
expect(byId.isError).not.toBe(true);
|
|
expect(byId.structuredContent).toMatchObject({
|
|
result: {
|
|
evidence_links: [left.value.evidence_id, right.value.evidence_id],
|
|
changes: [expect.objectContaining({ path: "/depth" })],
|
|
},
|
|
});
|
|
|
|
const analyzed = javascriptApplicationAnalysisResultSchema.parse(
|
|
left.value.normalized_result,
|
|
);
|
|
if (analyzed.schema_version !== 2)
|
|
throw new TypeError("Expected semantic application Evidence");
|
|
const seed = analyzed.semantic_graph.relations[0]?.source_node_id;
|
|
if (seed === undefined)
|
|
throw new TypeError("Expected at least one semantic relation");
|
|
const semantic = await client.callTool({
|
|
name: "trace_javascript_semantics",
|
|
arguments: {
|
|
application: left.value,
|
|
query: {
|
|
seed: { kind: "semantic-node", node_id: seed },
|
|
direction: "forward-influence",
|
|
include_ambiguous_dynamic_edges: true,
|
|
},
|
|
},
|
|
});
|
|
expect(semantic.isError).not.toBe(true);
|
|
expect(semantic.structuredContent).toMatchObject({
|
|
result: {
|
|
schema_version: 1,
|
|
source_evidence_id: left.value.evidence_id,
|
|
source_graph_id: analyzed.semantic_graph.graph_id,
|
|
summary: { retained_seed_matches: 1 },
|
|
},
|
|
});
|
|
} finally {
|
|
await client.close();
|
|
await server.close();
|
|
await session.close();
|
|
await rm(root, { recursive: true, force: true });
|
|
}
|
|
});
|
|
});
|