test(clients): check configured MCP catalogs in native harnesses (#15121)

* test(clients): check configured MCP catalogs in native harnesses

* test(opencode): resolve the native CLI in the isolated home

* ci(clients): identify native catalog discovery in the job log

* test(ci): isolate native clients and preserve registration failures
This commit is contained in:
morluto authored and GitHub committed 2026-11-29 18:03:55 +00:00
1 parent 7025845302
commit 8e18bdecef
11 files changed
+530 -43

No files matched your search

+43 -12
View File
@@ -1,3 +1,4 @@
import { clientCatalogFixture } from "./verify/clients/catalog.mjs";
import assert from "node:assert/strict";
import { verifyClientSetupAndReadSkillBody } from "./verify/clients/setup.mjs";
import { createHash } from "node:crypto";
@@ -5,7 +6,6 @@ import { mkdir, writeFile } from "node:fs/promises";
import { join } from "node:path";
import { fileURLToPath } from "node:url";
import Ajv2020 from "ajv/dist/2020.js";
import { TOOL_CONTRACTS } from "../dist/contracts/toolContracts.js";
import { isPathWithinRoot } from "../dist/domain/localPath.js";
import { createVerifierCommands } from "./lib/verify-commands.mjs";
import { saveVerifierCommandOutput } from "./lib/verifier-command-output.mjs";
@@ -37,8 +37,8 @@ const command = process.env.REA_VERIFY_OPENCODE_COMMAND ?? "opencode";
const mode = process.argv[2] ?? "call";
const configFormat = process.env.REA_VERIFY_OPENCODE_CONFIG_FORMAT ?? "jsonc";
assert(
["chat", "call"].includes(mode),
"Usage: verify-opencode-client.mjs [chat|call]",
["chat", "scoped-chat", "call"].includes(mode),
"Usage: verify-opencode-client.mjs [chat|scoped-chat|call]",
);
const configFilename = new Map([
["json", "opencode.json"],
@@ -48,6 +48,7 @@ assert(
configFilename !== undefined,
"REA_VERIFY_OPENCODE_CONFIG_FORMAT must be json or jsonc",
);
const catalogFixture = clientCatalogFixture(mode);
const verifier = createVerifierRun();
const { path: lab } = await VerifierFixture.keepArtifacts({
prefix: "rea-opencode-client-",
@@ -82,6 +83,7 @@ let expectedSkillBody;
let evidenceSeen = false;
let finalSeen = false;
let catalogSize = null;
let catalogSearchRequested = false;
let schemasChecked = 0;
let artifactDigest;
const commands = await createVerifierCommands();
@@ -93,7 +95,9 @@ await withVerifierCleanup(async () => {
stdin: "pipe",
});
const environment = {
HOME: account,
USERPROFILE: account,
PATH: process.env.PATH ?? "",
OPENCODE_CONFIG_DIR: profile,
XDG_CONFIG_HOME: join(lab, "config"),
XDG_CACHE_HOME: join(lab, "cache"),
@@ -130,19 +134,45 @@ await withVerifierCleanup(async () => {
const analysis = tools.find((t) =>
t.name.endsWith("analyze_javascript_application"),
);
if (
!analysis &&
mode === "scoped-chat" &&
tools.some((tool) => tool.name === "execute")
) {
if (!catalogSearchRequested) {
catalogSearchRequested = true;
return toolCallMessage("call_rea_catalog", "execute", {
code: `const paths = []; let offset = 0;
do {
const page = await search({ namespace: "rea", offset });
paths.push(...page.items.map(item => item.path));
if (!page.next) break;
if (page.next.offset <= offset) throw Error("OpenCode catalog cursor did not advance");
offset = page.next.offset;
} while (true);
return { reaCatalogPaths: paths };`,
});
}
const result = findClientResult(
body.messages.filter((message) => message.role === "tool"),
(value) => Array.isArray(value.reaCatalogPaths),
);
assert(
result,
"OpenCode must return its native REA namespace search results",
);
catalogFixture.assertNames(result.reaCatalogPaths, "tools.rea.");
catalogSize = result.reaCatalogPaths.length;
finalSeen = true;
return { role: "assistant", content: "REA_CLIENT_COMPATIBILITY_OK" };
}
assert(analysis, "OpenCode must expose the REA analysis tool");
const prefix = analysis.name.slice(
0,
-"analyze_javascript_application".length,
);
const expected = TOOL_CONTRACTS.map((t) => prefix + t.name).sort();
const reaTools = tools.filter((t) => expected.includes(t.name));
const reaTools = catalogFixture.check(tools, prefix);
catalogSize = reaTools.length;
assert.deepEqual(
reaTools.map((t) => t.name).sort(),
expected,
"OpenCode must forward the complete REA catalog",
);
if (schemasChecked === 0) {
for (const tool of reaTools) {
assert(
@@ -175,7 +205,7 @@ await withVerifierCleanup(async () => {
await writeFile(join(lab, "opencode-evidence.json"), bytes);
evidenceSeen = true;
}
if (mode === "chat" || evidenceSeen) {
if (mode !== "call" || evidenceSeen) {
finalSeen = true;
return { role: "assistant", content: "REA_CLIENT_COMPATIBILITY_OK" };
}
@@ -235,6 +265,7 @@ await withVerifierCleanup(async () => {
);
await writeFile(configPath, original);
expectedSkillBody = await verifyClientSetupAndReadSkillBody({
setupArguments: catalogFixture.setupArguments,
client: "opencode",
commands,
runtimeRoot,
@@ -260,7 +291,7 @@ await withVerifierCleanup(async () => {
"json",
"--model",
"rea-fixture/rea-client-fixture",
mode === "chat"
mode !== "call"
? "Say hello briefly."
: `Use REA to analyze the JavaScript directory ${target}. Report the result.`,
],