* 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>
120 lines
4.3 KiB
TypeScript
120 lines
4.3 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { Client, InMemoryTransport } from "@modelcontextprotocol/client";
|
|
import { McpServer } from "@modelcontextprotocol/server";
|
|
|
|
import { TOOL_CONTRACTS } from "../../../src/contracts/toolContracts.js";
|
|
import { GENERATED_MCP_TOOL_CATALOG } from "../../../src/generatedMcpToolCatalog.js";
|
|
import { toolRegistrationOptions } from "../../../src/server/toolRegistrationOptions.js";
|
|
|
|
describe("tool registration options", () => {
|
|
it("preserves canonical Zod parsers in the SDK schemas", () => {
|
|
for (const contract of TOOL_CONTRACTS) {
|
|
const options = toolRegistrationOptions(contract);
|
|
expect(options.inputSchema).not.toBe(contract.inputSchema);
|
|
expect(
|
|
options.inputSchema.safeParse(contract.examples[0]?.input ?? {}),
|
|
).toEqual(
|
|
contract.inputSchema.safeParse(contract.examples[0]?.input ?? {}),
|
|
);
|
|
expect(options.outputSchema).toBe(contract.outputSchema);
|
|
}
|
|
});
|
|
|
|
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)
|
|
server.registerTool(
|
|
contract.name,
|
|
toolRegistrationOptions(contract),
|
|
async () => ({
|
|
content: [{ type: "text" as const, text: "catalog-only" }],
|
|
isError: true as const,
|
|
}),
|
|
);
|
|
const client = new Client({ name: "catalog-test", version: "0" });
|
|
const [clientTransport, serverTransport] =
|
|
InMemoryTransport.createLinkedPair();
|
|
try {
|
|
await server.connect(serverTransport);
|
|
await client.connect(clientTransport);
|
|
const advertised = (await client.listTools()).tools.map((tool) => ({
|
|
name: tool.name,
|
|
title: tool.title,
|
|
description: tool.description,
|
|
inputSchema: tool.inputSchema,
|
|
outputSchema: tool.outputSchema,
|
|
annotations: tool.annotations,
|
|
}));
|
|
for (const contract of TOOL_CONTRACTS) {
|
|
const tool = advertised.find(({ name }) => name === contract.name);
|
|
expect(tool?.inputSchema.examples, contract.name).toEqual(
|
|
contract.examples.map(({ input }) => input),
|
|
);
|
|
expect(
|
|
missingPropertyDescriptions(tool?.inputSchema),
|
|
contract.name,
|
|
).toEqual([]);
|
|
}
|
|
const analyzeFunction = advertised.find(
|
|
({ name }) => name === "analyze_function",
|
|
);
|
|
expect(analyzeFunction?.inputSchema.properties).toMatchObject({
|
|
include_assembly: {
|
|
description: "Whether to include assembly in the result.",
|
|
},
|
|
max_instructions: {
|
|
description: "Maximum permitted instructions for this operation.",
|
|
},
|
|
pseudocode_offset: {
|
|
description: "Zero-based index of the first pseudocode to return.",
|
|
},
|
|
});
|
|
expect(advertised).toEqual(
|
|
GENERATED_MCP_TOOL_CATALOG.map((tool) => ({
|
|
name: tool.name,
|
|
title: tool.title,
|
|
description: tool.description,
|
|
inputSchema: tool.inputSchema,
|
|
outputSchema: tool.outputSchema,
|
|
annotations: tool.annotations,
|
|
})),
|
|
);
|
|
} finally {
|
|
await Promise.allSettled([client.close(), server.close()]);
|
|
}
|
|
});
|
|
});
|
|
|
|
const missingPropertyDescriptions = (
|
|
value: unknown,
|
|
path = "inputSchema",
|
|
): string[] => {
|
|
if (Array.isArray(value))
|
|
return value.flatMap((child, index) =>
|
|
missingPropertyDescriptions(child, `${path}[${index}]`),
|
|
);
|
|
if (!isObject(value)) return [];
|
|
|
|
const missing: string[] = [];
|
|
if (isObject(value.properties))
|
|
for (const [property, schema] of Object.entries(value.properties)) {
|
|
const propertyPath = `${path}.properties.${property}`;
|
|
if (!isObject(schema) || typeof schema.description !== "string")
|
|
missing.push(propertyPath);
|
|
missing.push(...missingPropertyDescriptions(schema, propertyPath));
|
|
}
|
|
for (const [key, child] of Object.entries(value))
|
|
if (
|
|
key !== "properties" &&
|
|
key !== "examples" &&
|
|
key !== "default" &&
|
|
key !== "const" &&
|
|
key !== "enum"
|
|
)
|
|
missing.push(...missingPropertyDescriptions(child, `${path}.${key}`));
|
|
return missing;
|
|
};
|
|
|
|
const isObject = (value: unknown): value is Readonly<Record<string, unknown>> =>
|
|
typeof value === "object" && value !== null && !Array.isArray(value);
|