refactor(test): colocate pure-domain tests and reduce test debt (#471)
* 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>
This commit is contained in:
co-authored by
Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
parent
344b9b6dff
commit
e91c8c39c2
@@ -9,10 +9,7 @@ import { z } from "zod";
|
||||
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
|
||||
import {
|
||||
composeBinarySessionFromFactory,
|
||||
composeBinarySessionFromProvider,
|
||||
} from "../../../src/application/BinarySessionComposition.js";
|
||||
import { createTestBinarySession } from "../../fixtures/binarySession.js";
|
||||
import { ArtifactProvider } from "../../../src/artifacts/ArtifactProvider.js";
|
||||
import { ARTIFACT_COMPARISON_EXAMPLE } from "../../../src/contracts/artifactComparisonExample.js";
|
||||
import { evidenceBundleSchema } from "../../../src/domain/evidenceBundle.js";
|
||||
@@ -47,7 +44,7 @@ it.each([
|
||||
await writeFile(archive, bytes);
|
||||
}
|
||||
|
||||
const session = composeBinarySessionFromProvider(new ArtifactProvider());
|
||||
const session = createTestBinarySession(new ArtifactProvider());
|
||||
const server = createServer(session, session);
|
||||
const client = new Client({ name: "asar-integrity-test", version: "1" });
|
||||
const [clientTransport, serverTransport] =
|
||||
@@ -135,9 +132,7 @@ it("records an approved mismatch, preserves verified siblings, and never reports
|
||||
bytes.write(secondChanged, secondOffset, "utf8");
|
||||
await writeFile(archive, bytes);
|
||||
|
||||
const session = composeBinarySessionFromProvider(
|
||||
new ArtifactProvider(false, true),
|
||||
);
|
||||
const session = createTestBinarySession(new ArtifactProvider(false, true));
|
||||
const server = createServer(session, session);
|
||||
const client = new Client({ name: "asar-continue-test", version: "1" });
|
||||
const [clientTransport, serverTransport] =
|
||||
@@ -252,7 +247,7 @@ it("records an approved mismatch, preserves verified siblings, and never reports
|
||||
});
|
||||
|
||||
it("rejects altered payloads that reuse session Evidence IDs", async () => {
|
||||
const session = composeBinarySessionFromFactory(() => ({
|
||||
const session = createTestBinarySession(() => ({
|
||||
health: () => Promise.resolve(),
|
||||
execute: () => Promise.resolve(observed(null)),
|
||||
close: () => Promise.resolve(),
|
||||
@@ -287,7 +282,7 @@ it("rejects altered payloads that reuse session Evidence IDs", async () => {
|
||||
});
|
||||
|
||||
it("rejects comparison Evidence that is not owned by the session", async () => {
|
||||
const session = composeBinarySessionFromFactory(() => ({
|
||||
const session = createTestBinarySession(() => ({
|
||||
health: () => Promise.resolve(),
|
||||
execute: () => Promise.resolve(observed(null)),
|
||||
close: () => Promise.resolve(),
|
||||
@@ -326,7 +321,7 @@ it("opens archives without Hopper, compares them, and exports linked evidence",
|
||||
new TextReader("changed();"),
|
||||
);
|
||||
await writeFile(changedArchive, await changedWriter.close());
|
||||
const session = composeBinarySessionFromProvider(new ArtifactProvider());
|
||||
const session = createTestBinarySession(new ArtifactProvider());
|
||||
const server = createServer(session, session);
|
||||
const client = new Client({ name: "artifact-mcp-test", version: "1" });
|
||||
const [clientTransport, serverTransport] =
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Client, InMemoryTransport } from "@modelcontextprotocol/client";
|
||||
import { afterEach, expect, it } from "vitest";
|
||||
|
||||
import { composeBinarySessionFromFactory } from "../../../src/application/BinarySessionComposition.js";
|
||||
import { createTestBinarySession } from "../../fixtures/binarySession.js";
|
||||
import type { BinarySession } from "../../../src/application/BinarySession.js";
|
||||
import { loadConfiguredPermissionAuthority } from "../../../src/application/PermissionConfiguration.js";
|
||||
import { CdpBrowserProvider } from "../../../src/browser/CdpBrowserProvider.js";
|
||||
@@ -289,7 +289,7 @@ const connectBrowser = async (browser: FakeCdpBrowser) => {
|
||||
if (!config.ok) throw config.error;
|
||||
const authority = await loadConfiguredPermissionAuthority(config.value);
|
||||
if (!authority.ok) throw authority.error;
|
||||
const session = composeBinarySessionFromFactory(() => ({
|
||||
const session = createTestBinarySession(() => ({
|
||||
execute: () => Promise.resolve(observed(null)),
|
||||
close: () => Promise.resolve(),
|
||||
}));
|
||||
|
||||
@@ -3,7 +3,7 @@ import { dirname } from "node:path";
|
||||
import { afterEach, describe, expect, test } from "vitest";
|
||||
|
||||
import type { BrowserScenarioCapturePort } from "../../../src/application/BrowserScenarioCapturePort.js";
|
||||
import { composeBinarySessionFromFactory } from "../../../src/application/BinarySessionComposition.js";
|
||||
import { createTestBinarySession } from "../../fixtures/binarySession.js";
|
||||
import { loadConfiguredPermissionAuthority } from "../../../src/application/PermissionConfiguration.js";
|
||||
import type {
|
||||
ExecutionOptions,
|
||||
@@ -189,7 +189,7 @@ describe("browser scenario MCP tool", () => {
|
||||
const authority = await loadConfiguredPermissionAuthority(configured.value);
|
||||
if (!authority.ok) throw authority.error;
|
||||
const provider = new FakeBrowserScenarioProvider();
|
||||
const session = composeBinarySessionFromFactory(() => ({
|
||||
const session = createTestBinarySession(() => ({
|
||||
execute: () => Promise.resolve(observed(null)),
|
||||
close: () => Promise.resolve(),
|
||||
}));
|
||||
|
||||
@@ -6,7 +6,7 @@ import { afterEach, describe, expect, it } from "vitest";
|
||||
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
|
||||
import { composeBinarySessionFromFactory } from "../../../src/application/BinarySessionComposition.js";
|
||||
import { createTestBinarySession } from "../../fixtures/binarySession.js";
|
||||
import { createEvidence } from "../../../src/domain/evidence.js";
|
||||
import {
|
||||
createEvidenceBundle,
|
||||
@@ -137,7 +137,7 @@ describe("bundle comparison MCP integration", () => {
|
||||
});
|
||||
|
||||
const connect = async (root: string, maxBytes = 1024 * 1024) => {
|
||||
const session = composeBinarySessionFromFactory(() => ({
|
||||
const session = createTestBinarySession(() => ({
|
||||
health: () => Promise.resolve(),
|
||||
execute: () => Promise.resolve(observed(null)),
|
||||
close: () => Promise.resolve(),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { describe, expect } from "vitest";
|
||||
|
||||
import { observed as ok } from "../../fixtures/analysisExecution.js";
|
||||
import { mcpTest } from "../../support/mcp/mcpFixture.js";
|
||||
@@ -9,10 +9,6 @@ const analysis = {
|
||||
};
|
||||
|
||||
describe("MCP server composition", () => {
|
||||
it("constructs independent MCP server instances", () => {
|
||||
expect(createServer(analysis)).not.toBe(createServer(analysis));
|
||||
});
|
||||
|
||||
mcpTest("does not advertise unavailable session tools", async ({ mcp }) => {
|
||||
const server = createServer(analysis);
|
||||
const client = await mcp.connect(server, {
|
||||
|
||||
@@ -8,7 +8,7 @@ import { z } from "zod";
|
||||
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
|
||||
import { composeBinarySessionFromFactory } from "../../../src/application/BinarySessionComposition.js";
|
||||
import { createTestBinarySession } from "../../fixtures/binarySession.js";
|
||||
import type { BinarySession } from "../../../src/application/BinarySession.js";
|
||||
import type { ElectronActiveObservationPort } from "../../../src/application/ElectronActiveObservationPort.js";
|
||||
import { loadConfiguredPermissionAuthority } from "../../../src/application/PermissionConfiguration.js";
|
||||
@@ -63,7 +63,7 @@ it("exposes root-confined Electron discovery and inspection as Evidence v2", asy
|
||||
if (!config.ok) throw config.error;
|
||||
const authority = await loadConfiguredPermissionAuthority(config.value);
|
||||
if (!authority.ok) throw authority.error;
|
||||
const session = composeBinarySessionFromFactory(() => ({
|
||||
const session = createTestBinarySession(() => ({
|
||||
execute: () => Promise.resolve(observed(null)),
|
||||
close: () => Promise.resolve(),
|
||||
}));
|
||||
@@ -218,7 +218,7 @@ it("exposes active Electron scenarios through the separately granted MCP boundar
|
||||
if (!config.ok) throw config.error;
|
||||
const authority = await loadConfiguredPermissionAuthority(config.value);
|
||||
if (!authority.ok) throw authority.error;
|
||||
const session = composeBinarySessionFromFactory(() => ({
|
||||
const session = createTestBinarySession(() => ({
|
||||
execute: () => Promise.resolve(observed(null)),
|
||||
close: () => Promise.resolve(),
|
||||
}));
|
||||
@@ -298,7 +298,7 @@ it("exposes the target-free static JavaScript application workflow", async () =>
|
||||
if (!config.ok) throw config.error;
|
||||
const authority = await loadConfiguredPermissionAuthority(config.value);
|
||||
if (!authority.ok) throw authority.error;
|
||||
const session = composeBinarySessionFromFactory(() => ({
|
||||
const session = createTestBinarySession(() => ({
|
||||
execute: () => Promise.resolve(observed(null)),
|
||||
close: () => Promise.resolve(),
|
||||
}));
|
||||
@@ -391,7 +391,7 @@ it("reports an unconfigured investigation ceiling before static analysis", async
|
||||
if (!config.ok) throw config.error;
|
||||
const authority = await loadConfiguredPermissionAuthority(config.value);
|
||||
if (!authority.ok) throw authority.error;
|
||||
const session = composeBinarySessionFromFactory(() => ({
|
||||
const session = createTestBinarySession(() => ({
|
||||
execute: () => Promise.resolve(observed(null)),
|
||||
close: () => Promise.resolve(),
|
||||
}));
|
||||
|
||||
@@ -4,7 +4,7 @@ import { describe, expect, it, vi } from "vitest";
|
||||
import { z } from "zod";
|
||||
|
||||
import { PermissionAuthority } from "../../../src/application/PermissionAuthority.js";
|
||||
import { composeBinarySessionFromFactory } from "../../../src/application/BinarySessionComposition.js";
|
||||
import { createTestBinarySession } from "../../fixtures/binarySession.js";
|
||||
import { createPermissionPolicy } from "../../../src/domain/permissionPolicy.js";
|
||||
import { observed } from "../../fixtures/analysisExecution.js";
|
||||
import { createServer } from "../../../src/server/createServer.js";
|
||||
@@ -16,7 +16,7 @@ const structured = (result: CallToolResult): Record<string, unknown> => {
|
||||
};
|
||||
|
||||
const createSession = () =>
|
||||
composeBinarySessionFromFactory(() => ({
|
||||
createTestBinarySession(() => ({
|
||||
health: () => Promise.resolve(),
|
||||
execute: () => Promise.resolve(observed(null)),
|
||||
close: () => Promise.resolve(),
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Client, InMemoryTransport } from "@modelcontextprotocol/client";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { z } from "zod";
|
||||
|
||||
import { composeBinarySessionFromFactory } from "../../../src/application/BinarySessionComposition.js";
|
||||
import { createTestBinarySession } from "../../fixtures/binarySession.js";
|
||||
import type { BinarySession } from "../../../src/application/BinarySession.js";
|
||||
import { createEvidence } from "../../../src/domain/evidence.js";
|
||||
import { observed } from "../../fixtures/analysisExecution.js";
|
||||
@@ -161,7 +161,7 @@ async function verifyResourceProtocol(
|
||||
|
||||
describe("evidence MCP resources", () => {
|
||||
it("publishes mutable snapshot changes for every Evidence mutation", () => {
|
||||
const session = composeBinarySessionFromFactory(() => ({
|
||||
const session = createTestBinarySession(() => ({
|
||||
health: () => Promise.resolve(),
|
||||
execute: () => Promise.resolve(observed(null)),
|
||||
close: () => Promise.resolve(),
|
||||
@@ -229,7 +229,7 @@ describe("evidence MCP resources", () => {
|
||||
});
|
||||
|
||||
it("contains observer failures after committing a mutation", () => {
|
||||
const session = composeBinarySessionFromFactory(() => ({
|
||||
const session = createTestBinarySession(() => ({
|
||||
health: () => Promise.resolve(),
|
||||
execute: () => Promise.resolve(observed(null)),
|
||||
close: () => Promise.resolve(),
|
||||
@@ -251,7 +251,7 @@ describe("evidence MCP resources", () => {
|
||||
|
||||
describe("evidence bundle resources", () => {
|
||||
it("retains bundles without eviction and rejects a seventeenth digest", () => {
|
||||
const session = composeBinarySessionFromFactory(() => ({
|
||||
const session = createTestBinarySession(() => ({
|
||||
health: () => Promise.resolve(),
|
||||
execute: () => Promise.resolve(observed(null)),
|
||||
close: () => Promise.resolve(),
|
||||
@@ -294,7 +294,7 @@ describe("evidence bundle resources", () => {
|
||||
});
|
||||
|
||||
it("lists and reads only evidence owned by the current session", async () => {
|
||||
const session = composeBinarySessionFromFactory(() => ({
|
||||
const session = createTestBinarySession(() => ({
|
||||
health: () => Promise.resolve(),
|
||||
execute: () => Promise.resolve(observed(null)),
|
||||
close: () => Promise.resolve(),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Client, InMemoryTransport } from "@modelcontextprotocol/client";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { composeBinarySessionFromFactory } from "../../../src/application/BinarySessionComposition.js";
|
||||
import { createTestBinarySession } from "../../fixtures/binarySession.js";
|
||||
import { FUNCTION_COMPARISON_EXAMPLE } from "../../../src/contracts/functionComparisonExample.js";
|
||||
import { createEvidence } from "../../../src/domain/evidence.js";
|
||||
import { createServer } from "../../../src/server/createServer.js";
|
||||
@@ -9,7 +9,7 @@ import { observed } from "../../fixtures/analysisExecution.js";
|
||||
|
||||
describe("function comparison MCP integration", () => {
|
||||
it("records linked comparison Evidence and an approved residual unknown", async () => {
|
||||
const session = composeBinarySessionFromFactory(() => ({
|
||||
const session = createTestBinarySession(() => ({
|
||||
health: () => Promise.resolve(),
|
||||
execute: () => Promise.resolve(observed(null)),
|
||||
close: () => Promise.resolve(),
|
||||
@@ -75,7 +75,7 @@ describe("function comparison MCP integration", () => {
|
||||
});
|
||||
|
||||
it("rejects dangling Evidence links before recording output", async () => {
|
||||
const session = composeBinarySessionFromFactory(() => ({
|
||||
const session = createTestBinarySession(() => ({
|
||||
health: () => Promise.resolve(),
|
||||
execute: () => Promise.resolve(observed(null)),
|
||||
close: () => Promise.resolve(),
|
||||
@@ -106,7 +106,7 @@ describe("function comparison MCP integration", () => {
|
||||
});
|
||||
|
||||
it("rejects Evidence IDs with the wrong operation", async () => {
|
||||
const session = composeBinarySessionFromFactory(() => ({
|
||||
const session = createTestBinarySession(() => ({
|
||||
health: () => Promise.resolve(),
|
||||
execute: () => Promise.resolve(observed(null)),
|
||||
close: () => Promise.resolve(),
|
||||
|
||||
@@ -106,7 +106,7 @@ const installationHost = (): GhidraInstallationHost => ({
|
||||
major: 21,
|
||||
home: "/usr/lib/jvm/jdk-21",
|
||||
bits: 64,
|
||||
jdk: true,
|
||||
runtime: "jdk",
|
||||
}),
|
||||
});
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Client, InMemoryTransport } from "@modelcontextprotocol/client";
|
||||
import { expect, it } from "vitest";
|
||||
import { z } from "zod";
|
||||
|
||||
import { composeBinarySessionFromFactory } from "../../../src/application/BinarySessionComposition.js";
|
||||
import { createTestBinarySession } from "../../fixtures/binarySession.js";
|
||||
import type { BinarySession } from "../../../src/application/BinarySession.js";
|
||||
import { FUNCTION_COMPARISON_EXAMPLE } from "../../../src/contracts/functionComparisonExample.js";
|
||||
import { INVESTIGATION_EXAMPLES } from "../../../src/contracts/investigationExamples.js";
|
||||
@@ -308,7 +308,7 @@ const connected = async (
|
||||
investigationInputRoots: readonly string[] = evidenceFilePolicy?.roots ?? [],
|
||||
permissionAuthority?: PermissionAuthority,
|
||||
) => {
|
||||
const session = composeBinarySessionFromFactory(() => ({
|
||||
const session = createTestBinarySession(() => ({
|
||||
health: () => Promise.resolve(),
|
||||
execute: () => Promise.resolve(observed(null)),
|
||||
close: () => Promise.resolve(),
|
||||
|
||||
@@ -6,7 +6,7 @@ import { z } from "zod";
|
||||
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
|
||||
import { composeBinarySessionFromFactory } from "../../../src/application/BinarySessionComposition.js";
|
||||
import { createTestBinarySession } from "../../fixtures/binarySession.js";
|
||||
import type { BinarySession } from "../../../src/application/BinarySession.js";
|
||||
import { FUNCTION_COMPARISON_EXAMPLE } from "../../../src/contracts/functionComparisonExample.js";
|
||||
import { INVESTIGATION_EXAMPLES } from "../../../src/contracts/investigationExamples.js";
|
||||
@@ -329,7 +329,7 @@ const connected = async (
|
||||
investigationInputRoots: readonly string[] = evidenceFilePolicy?.roots ?? [],
|
||||
permissionAuthority?: PermissionAuthority,
|
||||
) => {
|
||||
const session = composeBinarySessionFromFactory(() => ({
|
||||
const session = createTestBinarySession(() => ({
|
||||
health: () => Promise.resolve(),
|
||||
execute: () => Promise.resolve(observed(null)),
|
||||
close: () => Promise.resolve(),
|
||||
|
||||
@@ -5,7 +5,7 @@ import { pathToFileURL } from "node:url";
|
||||
import { Client, InMemoryTransport } from "@modelcontextprotocol/client";
|
||||
import { afterEach, describe, expect, test } from "vitest";
|
||||
|
||||
import { composeBinarySessionFromFactory } from "../../../src/application/BinarySessionComposition.js";
|
||||
import { createTestBinarySession } from "../../fixtures/binarySession.js";
|
||||
import { loadConfiguredPermissionAuthority } from "../../../src/application/PermissionConfiguration.js";
|
||||
import { observeJavaScriptRuntime } from "../../../src/application/JavaScriptRuntimeObservationService.js";
|
||||
import { V8InspectorProvider } from "../../../src/browser/V8InspectorProvider.js";
|
||||
@@ -45,7 +45,7 @@ describe("JavaScript runtime observation MCP tools", () => {
|
||||
if (!config.ok) throw config.error;
|
||||
const authority = await loadConfiguredPermissionAuthority(config.value);
|
||||
if (!authority.ok) throw authority.error;
|
||||
const session = composeBinarySessionFromFactory(() => ({
|
||||
const session = createTestBinarySession(() => ({
|
||||
execute: () => Promise.resolve(observed(null)),
|
||||
close: () => Promise.resolve(),
|
||||
}));
|
||||
|
||||
@@ -4,7 +4,7 @@ import { rm } from "node:fs/promises";
|
||||
import { dirname } from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
import { composeBinarySessionFromFactory } from "../../../src/application/BinarySessionComposition.js";
|
||||
import { createTestBinarySession } from "../../fixtures/binarySession.js";
|
||||
import { PermissionAuthority } from "../../../src/application/PermissionAuthority.js";
|
||||
import { createPermissionPolicy } from "../../../src/domain/permissionPolicy.js";
|
||||
import { silentLogger } from "../../../src/logger.js";
|
||||
@@ -26,7 +26,7 @@ describe("process-capture MCP elicitation handshake", () => {
|
||||
},
|
||||
]),
|
||||
);
|
||||
const session = composeBinarySessionFromFactory(() => ({
|
||||
const session = createTestBinarySession(() => ({
|
||||
execute: () => Promise.resolve(observed(null)),
|
||||
close: () => Promise.resolve(),
|
||||
}));
|
||||
|
||||
@@ -175,7 +175,7 @@ describe("process-capture MCP elicitation grants", () => {
|
||||
await mkdir(root);
|
||||
}
|
||||
const retry = await authority.authorize(scoped, "read", {
|
||||
elicitationSupported: true,
|
||||
remediation: "elicit",
|
||||
});
|
||||
expect(retry.ok).toBe(false);
|
||||
},
|
||||
|
||||
@@ -6,7 +6,7 @@ import { dirname } from "node:path";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { z } from "zod";
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
import { composeBinarySessionFromFactory } from "../../../src/application/BinarySessionComposition.js";
|
||||
import { createTestBinarySession } from "../../fixtures/binarySession.js";
|
||||
import { PermissionAuthority } from "../../../src/application/PermissionAuthority.js";
|
||||
import { createPermissionPolicy } from "../../../src/domain/permissionPolicy.js";
|
||||
import { silentLogger } from "../../../src/logger.js";
|
||||
@@ -33,7 +33,7 @@ describe("process-capture MCP elicitation handshake", () => {
|
||||
},
|
||||
]),
|
||||
);
|
||||
const session = composeBinarySessionFromFactory(() => ({
|
||||
const session = createTestBinarySession(() => ({
|
||||
execute: () => Promise.resolve(observed(null)),
|
||||
close: () => Promise.resolve(),
|
||||
}));
|
||||
|
||||
@@ -4,7 +4,7 @@ import { join } from "node:path";
|
||||
import { Client, InMemoryTransport } from "@modelcontextprotocol/client";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
|
||||
import { composeBinarySessionFromFactory } from "../../../src/application/BinarySessionComposition.js";
|
||||
import { createTestBinarySession } from "../../fixtures/binarySession.js";
|
||||
import type { AnalysisClient } from "../../../src/application/AnalysisProvider.js";
|
||||
import { compareProcessEvidenceFiles } from "../../../src/application/ProcessCli.js";
|
||||
import { PROCESS_PROVIDER } from "../../../src/application/ProcessEvidence.js";
|
||||
@@ -117,7 +117,7 @@ describe("declared trace adapter parity", () => {
|
||||
const cliEvidence = parseEvidence(
|
||||
await compareProcessEvidenceFiles(leftPath, rightPath, specificationPath),
|
||||
);
|
||||
const session = composeBinarySessionFromFactory(
|
||||
const session = createTestBinarySession(
|
||||
(_path) =>
|
||||
({
|
||||
execute: () => Promise.resolve(ok(null)),
|
||||
|
||||
@@ -5,7 +5,7 @@ import { afterEach, describe, expect, it } from "vitest";
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
|
||||
import type { AnalysisClient } from "../../../src/application/AnalysisProvider.js";
|
||||
import { composeBinarySessionFromFactory } from "../../../src/application/BinarySessionComposition.js";
|
||||
import { createTestBinarySession } from "../../fixtures/binarySession.js";
|
||||
import { ARTIFACT_COMPARISON_EXAMPLE } from "../../../src/contracts/artifactComparisonExample.js";
|
||||
import { PROCESS_CAPTURE_REFERENCE } from "../../../src/contracts/investigationExamples.js";
|
||||
import { createEvidence } from "../../../src/domain/evidence.js";
|
||||
@@ -23,7 +23,7 @@ afterEach(async () => {
|
||||
describe("guided prompt completion from live analysis", () => {
|
||||
it("reads live documents and paged procedures without ambiguous names", async () => {
|
||||
const requests: Array<Readonly<Record<string, unknown>>> = [];
|
||||
const session = composeBinarySessionFromFactory(() => client(requests));
|
||||
const session = createTestBinarySession(() => client(requests));
|
||||
directory = await createTestTempDirectory("rea-prompt-completion-");
|
||||
const target = join(directory, "fixture.hop");
|
||||
await writeFile(target, "fixture");
|
||||
@@ -58,7 +58,7 @@ describe("guided prompt completion from live analysis", () => {
|
||||
|
||||
describe("guided prompt completion from investigation records", () => {
|
||||
it("projects only validated typed identifiers from the evidence ledger", async () => {
|
||||
const session = composeBinarySessionFromFactory(() => client([]));
|
||||
const session = createTestBinarySession(() => client([]));
|
||||
const invalidCapture = createEvidence(undefined, fixtureProvider, {
|
||||
operation: "capture_process_scenario",
|
||||
parameters: {},
|
||||
@@ -137,7 +137,7 @@ describe("guided prompt completion from investigation records", () => {
|
||||
});
|
||||
|
||||
it("deduplicates, case-folds, and returns deterministic live evidence IDs", async () => {
|
||||
const session = composeBinarySessionFromFactory(() => client([]));
|
||||
const session = createTestBinarySession(() => client([]));
|
||||
for (let index = 149; index >= 0; index -= 1) {
|
||||
const evidence = createEvidence(undefined, fixtureProvider, {
|
||||
operation: `fixture-${String(index)}`,
|
||||
|
||||
@@ -8,7 +8,7 @@ import { afterEach, describe, expect, it } from "vitest";
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
|
||||
import type { AnalysisClient } from "../../../src/application/AnalysisProvider.js";
|
||||
import { composeBinarySessionFromFactory } from "../../../src/application/BinarySessionComposition.js";
|
||||
import { createTestBinarySession } from "../../fixtures/binarySession.js";
|
||||
import type { BinarySession } from "../../../src/application/BinarySession.js";
|
||||
import { PROMPT_CONTRACTS } from "../../../src/contracts/promptContracts.js";
|
||||
import { createEvidence } from "../../../src/domain/evidence.js";
|
||||
@@ -284,7 +284,7 @@ describe("guided prompt completion lifecycle", () => {
|
||||
const second = join(directory, "second.hop");
|
||||
await Promise.all([writeFile(first, "first"), writeFile(second, "second")]);
|
||||
const procedureRequests: Array<Readonly<Record<string, unknown>>> = [];
|
||||
const session = composeBinarySessionFromFactory((target) =>
|
||||
const session = createTestBinarySession((target) =>
|
||||
lifecycleClient(basename(target.path, ".hop"), procedureRequests),
|
||||
);
|
||||
const client = await connect(createServer(session, session));
|
||||
@@ -340,7 +340,7 @@ const fixtureProvider = { id: "fixture", name: "Fixture", version: "1" };
|
||||
const fixtureSession = (
|
||||
onExecute: () => void = () => undefined,
|
||||
): BinarySession =>
|
||||
composeBinarySessionFromFactory(() => ({
|
||||
createTestBinarySession(() => ({
|
||||
execute: () => {
|
||||
onExecute();
|
||||
return Promise.resolve(observed(null));
|
||||
|
||||
@@ -6,7 +6,7 @@ import { describe, expect, it } from "vitest";
|
||||
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
|
||||
import { composeBinarySessionFromFactory } from "../../../src/application/BinarySessionComposition.js";
|
||||
import { createTestBinarySession } from "../../fixtures/binarySession.js";
|
||||
import { INVESTIGATION_EXAMPLES } from "../../../src/contracts/investigationExamples.js";
|
||||
import { createEvidence } from "../../../src/domain/evidence.js";
|
||||
import { createEvidenceBundle } from "../../../src/domain/evidenceBundle.js";
|
||||
@@ -36,7 +36,7 @@ describe("reconstruction coverage MCP parity", () => {
|
||||
["investigation_workspace_read", "investigation_workspace_write"],
|
||||
["investigation_workspace_read", "investigation_workspace_write"],
|
||||
);
|
||||
const session = composeBinarySessionFromFactory(() => ({
|
||||
const session = createTestBinarySession(() => ({
|
||||
execute: () => Promise.resolve(observed(null)),
|
||||
close: () => Promise.resolve(),
|
||||
}));
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { Client, InMemoryTransport } from "@modelcontextprotocol/client";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { composeBinarySessionFromFactory } from "../../../src/application/BinarySessionComposition.js";
|
||||
import { createTestBinarySession } from "../../fixtures/binarySession.js";
|
||||
import { createEvidenceBundle } from "../../../src/domain/evidenceBundle.js";
|
||||
import { createServer } from "../../../src/server/createServer.js";
|
||||
import { observed } from "../../fixtures/analysisExecution.js";
|
||||
|
||||
describe("reconstruction obligation ledger MCP parity", () => {
|
||||
it("builds an Evidence-backed page and exposes the retained resource", async () => {
|
||||
const session = composeBinarySessionFromFactory(() => ({
|
||||
const session = createTestBinarySession(() => ({
|
||||
execute: () => Promise.resolve(observed(null)),
|
||||
close: () => Promise.resolve(),
|
||||
}));
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { Client, InMemoryTransport } from "@modelcontextprotocol/client";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { composeBinarySessionFromFactory } from "../../../src/application/BinarySessionComposition.js";
|
||||
import { createTestBinarySession } from "../../fixtures/binarySession.js";
|
||||
import { RECONSTRUCTION_READINESS_EXAMPLE } from "../../../src/contracts/reconstructionReadinessExample.js";
|
||||
import { createServer } from "../../../src/server/createServer.js";
|
||||
import { observed } from "../../fixtures/analysisExecution.js";
|
||||
|
||||
describe("reconstruction readiness MCP parity", () => {
|
||||
it("returns a passing compact result and retains the full report resource", async () => {
|
||||
const session = composeBinarySessionFromFactory(() => ({
|
||||
const session = createTestBinarySession(() => ({
|
||||
execute: () => Promise.resolve(observed(null)),
|
||||
close: () => Promise.resolve(),
|
||||
}));
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { Client, InMemoryTransport } from "@modelcontextprotocol/client";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { composeBinarySessionFromFactory } from "../../../src/application/BinarySessionComposition.js";
|
||||
import { createTestBinarySession } from "../../fixtures/binarySession.js";
|
||||
import { REPLAY_MACHINE_RUN_EXAMPLE } from "../../../src/contracts/replayMachineExample.js";
|
||||
import { createServer } from "../../../src/server/createServer.js";
|
||||
import { observed } from "../../fixtures/analysisExecution.js";
|
||||
|
||||
describe("direct replay machine MCP parity", () => {
|
||||
it("returns typed journal output and safe validation failures", async () => {
|
||||
const session = composeBinarySessionFromFactory(() => ({
|
||||
const session = createTestBinarySession(() => ({
|
||||
execute: () => Promise.resolve(observed(null)),
|
||||
close: () => Promise.resolve(),
|
||||
}));
|
||||
|
||||
@@ -3,7 +3,7 @@ import { readFile } from "node:fs/promises";
|
||||
import { Client, InMemoryTransport } from "@modelcontextprotocol/client";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { composeBinarySessionFromProvider } from "../../../src/application/BinarySessionComposition.js";
|
||||
import { createTestBinarySession } from "../../fixtures/binarySession.js";
|
||||
import {
|
||||
CATALOG_IDENTITY,
|
||||
CLI_COMMAND_NAMES,
|
||||
@@ -217,7 +217,7 @@ describe("server and catalog identity", () => {
|
||||
|
||||
describe("live server identity over MCP", () => {
|
||||
it("exposes live identity, a stable catalog, and changing availability", async () => {
|
||||
const session = composeBinarySessionFromProvider(availabilityProvider());
|
||||
const session = createTestBinarySession(availabilityProvider());
|
||||
const server = createServer(session, session);
|
||||
const client = new Client(
|
||||
{ name: "identity-test", version: "9" },
|
||||
|
||||
@@ -2,10 +2,7 @@ import { Client, InMemoryTransport } from "@modelcontextprotocol/client";
|
||||
import type { CallToolResult } from "@modelcontextprotocol/server";
|
||||
import { afterEach, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
composeBinarySessionFromFactory,
|
||||
composeBinarySessionFromProvider,
|
||||
} from "../../../src/application/BinarySessionComposition.js";
|
||||
import { createTestBinarySession } from "../../fixtures/binarySession.js";
|
||||
import type {
|
||||
AnalysisClient,
|
||||
AnalysisOperationPort,
|
||||
@@ -94,7 +91,7 @@ it("records approved trace truncation as a deduplicated residual unknown", async
|
||||
}),
|
||||
),
|
||||
};
|
||||
const session = composeBinarySessionFromProvider(
|
||||
const session = createTestBinarySession(
|
||||
providerWithCapabilities([
|
||||
"list_strings",
|
||||
"list_procedures",
|
||||
@@ -159,7 +156,7 @@ it("records approved typed capability unavailability without forwarding the flag
|
||||
);
|
||||
},
|
||||
};
|
||||
const session = composeBinarySessionFromProvider(
|
||||
const session = createTestBinarySession(
|
||||
providerWithCapabilities(["procedure_pseudo_code"]),
|
||||
);
|
||||
const server = createServer(analysis, session);
|
||||
@@ -212,7 +209,7 @@ it("records approved typed capability unavailability without forwarding the flag
|
||||
});
|
||||
|
||||
it("records approved capture disagreement as a contradicted unknown", async () => {
|
||||
const session = composeBinarySessionFromFactory(
|
||||
const session = createTestBinarySession(
|
||||
() =>
|
||||
({
|
||||
execute: () => Promise.resolve(ok(null)),
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { CallToolResult } from "@modelcontextprotocol/server";
|
||||
import { afterEach, expect, it } from "vitest";
|
||||
import { z } from "zod";
|
||||
|
||||
import { composeBinarySessionFromFactory } from "../../../src/application/BinarySessionComposition.js";
|
||||
import { createTestBinarySession } from "../../fixtures/binarySession.js";
|
||||
import type {
|
||||
AnalysisClient,
|
||||
AnalysisOperationPort,
|
||||
@@ -107,7 +107,7 @@ it("executes a realistic workflow: list methods, decompile selected, get xrefs",
|
||||
});
|
||||
|
||||
it("advertises the complete currently available inventory with a session", async () => {
|
||||
const session = composeBinarySessionFromFactory(
|
||||
const session = createTestBinarySession(
|
||||
(_path) =>
|
||||
({
|
||||
execute: () => Promise.resolve(ok(null)),
|
||||
|
||||
@@ -8,10 +8,7 @@ import { z } from "zod";
|
||||
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
|
||||
import {
|
||||
composeBinarySessionFromFactory,
|
||||
composeBinarySessionFromProvider,
|
||||
} from "../../../src/application/BinarySessionComposition.js";
|
||||
import { createTestBinarySession } from "../../fixtures/binarySession.js";
|
||||
import type {
|
||||
AnalysisClient,
|
||||
AnalysisProvider,
|
||||
@@ -52,7 +49,7 @@ describe("target-free MCP lifecycle", () => {
|
||||
const targetPath = join(directory, "mutable.hop");
|
||||
await writeFile(targetPath, "first");
|
||||
const closed: string[] = [];
|
||||
const session = composeBinarySessionFromProvider(provider(closed), {
|
||||
const session = createTestBinarySession(provider(closed), {
|
||||
resolveAnalysisProfile: () =>
|
||||
Promise.resolve(
|
||||
resultOk({ profile: SNAPSHOT_PROFILE, compatibility: {} }),
|
||||
@@ -230,9 +227,7 @@ describe("target-free MCP workflow", () => {
|
||||
describe("process residuals over MCP", () => {
|
||||
it("records approved process residuals in the unknown registry", async () => {
|
||||
if (!(await probeProcessCaptureCapability()).available) return;
|
||||
const session = composeBinarySessionFromFactory(() =>
|
||||
client("fixture", []),
|
||||
);
|
||||
const session = createTestBinarySession(() => client("fixture", []));
|
||||
const server = createServer(session, session, {
|
||||
logger: silentLogger,
|
||||
processPolicy: () => ({
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { CallToolResult } from "@modelcontextprotocol/server";
|
||||
import { expect } from "vitest";
|
||||
import { z } from "zod";
|
||||
|
||||
import { composeBinarySessionFromProvider } from "../../../src/application/BinarySessionComposition.js";
|
||||
import { createTestBinarySession } from "../../fixtures/binarySession.js";
|
||||
import { createAnalysisProfile } from "../../../src/domain/analysisProfile.js";
|
||||
import { createEvidence } from "../../../src/domain/evidence.js";
|
||||
import {
|
||||
@@ -42,7 +42,7 @@ export const createSessionMcpHarness = async (
|
||||
const second = join(root, "second.hop");
|
||||
await Promise.all([writeFile(first, "one"), writeFile(second, "two")]);
|
||||
const closed: string[] = [];
|
||||
const session = composeBinarySessionFromProvider(provider(closed), {
|
||||
const session = createTestBinarySession(provider(closed), {
|
||||
resolveAnalysisProfile: () =>
|
||||
Promise.resolve(ok({ profile: SNAPSHOT_PROFILE, compatibility: {} })),
|
||||
});
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { Client, InMemoryTransport } from "@modelcontextprotocol/client";
|
||||
import { McpServer } from "@modelcontextprotocol/server";
|
||||
import { z } from "zod";
|
||||
|
||||
import { TOOL_CONTRACTS } from "../../../src/contracts/toolContracts.js";
|
||||
import { GENERATED_MCP_TOOL_CATALOG } from "../../../src/generatedMcpToolCatalog.js";
|
||||
@@ -21,17 +20,6 @@ describe("tool registration options", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("retains the canonical parser as the SDK validation boundary", async () => {
|
||||
const contract = TOOL_CONTRACTS.find(
|
||||
({ name }) => name === "analyze_function",
|
||||
);
|
||||
expect(contract).toBeDefined();
|
||||
if (contract === undefined) return;
|
||||
|
||||
const result = await contract.inputSchema["~standard"].validate({});
|
||||
expect("issues" in result).toBe(true);
|
||||
});
|
||||
|
||||
it("generates the checked-in catalog from the SDK wire projection", async () => {
|
||||
const server = new McpServer({ name: "catalog-test", version: "0" });
|
||||
for (const contract of TOOL_CONTRACTS)
|
||||
@@ -95,39 +83,6 @@ describe("tool registration options", () => {
|
||||
await Promise.allSettled([client.close(), server.close()]);
|
||||
}
|
||||
});
|
||||
|
||||
it("delegates output validation to the SDK boundary", async () => {
|
||||
const server = new McpServer({ name: "output-test", version: "0" });
|
||||
server.registerTool(
|
||||
"invalid_output",
|
||||
{
|
||||
inputSchema: z.object({}),
|
||||
outputSchema: z.object({ value: z.string() }),
|
||||
},
|
||||
async () => ({
|
||||
content: [{ type: "text", text: "invalid" }],
|
||||
structuredContent: { value: 42 },
|
||||
}),
|
||||
);
|
||||
const client = new Client({ name: "output-test", version: "0" });
|
||||
const [clientTransport, serverTransport] =
|
||||
InMemoryTransport.createLinkedPair();
|
||||
try {
|
||||
await server.connect(serverTransport);
|
||||
await client.connect(clientTransport);
|
||||
const result = await client.callTool({ name: "invalid_output" });
|
||||
expect(result.isError).toBe(true);
|
||||
expect(result.content).toContainEqual(
|
||||
expect.objectContaining({
|
||||
type: "text",
|
||||
text: expect.stringContaining("Output validation error"),
|
||||
}),
|
||||
);
|
||||
expect(result.structuredContent).toBeUndefined();
|
||||
} finally {
|
||||
await Promise.allSettled([client.close(), server.close()]);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const missingPropertyDescriptions = (
|
||||
|
||||
Reference in New Issue
Block a user