fix(ci): repair cross-platform package verification
This commit is contained in:
@@ -28,6 +28,28 @@ export const runWithStatus = async (command, args, env) => {
|
||||
/** Parse JSON from a command output string. */
|
||||
export const json = (text) => JSON.parse(text);
|
||||
|
||||
/** Verify that the advertised MCP catalog matches the session's available tools. */
|
||||
export const verifyAvailableToolCatalog = async (client, options) => {
|
||||
const listed = await client.listTools(undefined, options);
|
||||
const status = await client.callTool(
|
||||
{ name: "binary_session", arguments: { detail: "full" } },
|
||||
options,
|
||||
);
|
||||
const availability = status.structuredContent?.result?.tool_availability;
|
||||
if (!Array.isArray(availability))
|
||||
throw new Error("packaged MCP omitted tool availability");
|
||||
const expected = availability
|
||||
.filter(({ available }) => available === true)
|
||||
.map(({ name }) => name)
|
||||
.sort();
|
||||
const observed = listed.tools.map(({ name }) => name).sort();
|
||||
if (JSON.stringify(observed) !== JSON.stringify(expected))
|
||||
throw new Error(
|
||||
"packaged MCP tool inventory diverged from session availability",
|
||||
);
|
||||
return observed;
|
||||
};
|
||||
|
||||
/** Check whether a path exists on disk. */
|
||||
export const pathExists = async (path) => {
|
||||
try {
|
||||
|
||||
@@ -6,26 +6,15 @@ import { promisify } from "node:util";
|
||||
import { Client } from "@modelcontextprotocol/client";
|
||||
import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";
|
||||
import * as prompts from "./verify-package-prompts.mjs";
|
||||
import { json } from "./lib/verify-package-core.mjs";
|
||||
import {
|
||||
json,
|
||||
verifyAvailableToolCatalog,
|
||||
} from "./lib/verify-package-core.mjs";
|
||||
|
||||
const execute = promisify(execFile);
|
||||
|
||||
const verifyMcpToolsAndPrompts = async (client, mcpOptions) => {
|
||||
const listed = await client.listTools(undefined, mcpOptions);
|
||||
const status = await client.callTool(
|
||||
{ name: "binary_session", arguments: { detail: "full" } },
|
||||
mcpOptions,
|
||||
);
|
||||
const availability = status.structuredContent?.result?.tool_availability;
|
||||
if (!Array.isArray(availability))
|
||||
throw new Error("packaged MCP omitted tool availability");
|
||||
const expected = availability
|
||||
.filter(({ available }) => available === true)
|
||||
.map(({ name }) => name)
|
||||
.sort();
|
||||
const observed = listed.tools.map(({ name }) => name).sort();
|
||||
if (JSON.stringify(observed) !== JSON.stringify(expected))
|
||||
throw new Error("packaged MCP tool inventory diverged from contracts");
|
||||
await verifyAvailableToolCatalog(client, mcpOptions);
|
||||
await prompts.verifyPromptCatalog(client, mcpOptions, prompts.names);
|
||||
await prompts.verifyPromptCompletion(client, mcpOptions, false);
|
||||
};
|
||||
|
||||
@@ -9,7 +9,7 @@ import { promisify } from "node:util";
|
||||
import { Client } from "@modelcontextprotocol/client";
|
||||
import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";
|
||||
|
||||
import { TOOL_CONTRACTS } from "../dist/contracts/toolContracts.js";
|
||||
import { verifyAvailableToolCatalog } from "./lib/verify-package-core.mjs";
|
||||
import { completeVerifierRun, createVerifierRun } from "./lib/verifier-run.mjs";
|
||||
|
||||
const exec = promisify(execFile);
|
||||
@@ -81,19 +81,10 @@ try {
|
||||
stderr: "pipe",
|
||||
});
|
||||
const client = new Client({ name: "rea-windows-package", version: "1.0.0" });
|
||||
let toolCount = 0;
|
||||
try {
|
||||
await client.connect(server);
|
||||
const catalog = await client.listTools();
|
||||
const expected = TOOL_CONTRACTS.map(({ name }) => name).sort(
|
||||
(left, right) => left.localeCompare(right),
|
||||
);
|
||||
const actual = catalog.tools
|
||||
.map(({ name }) => name)
|
||||
.sort((left, right) => left.localeCompare(right));
|
||||
if (JSON.stringify(actual) !== JSON.stringify(expected))
|
||||
throw new Error(
|
||||
"Packaged Windows MCP catalog drifted from TOOL_CONTRACTS",
|
||||
);
|
||||
toolCount = (await verifyAvailableToolCatalog(client)).length;
|
||||
} finally {
|
||||
await client.close();
|
||||
}
|
||||
@@ -104,7 +95,7 @@ try {
|
||||
ok: true,
|
||||
platform: process.platform,
|
||||
package: packageResult.filename,
|
||||
tools: TOOL_CONTRACTS.length,
|
||||
tools: toolCount,
|
||||
ghidra_bridge: "present",
|
||||
})}\n`,
|
||||
);
|
||||
|
||||
@@ -16,9 +16,13 @@ export const matchesOwnedProcessCommand = (
|
||||
if (platform !== "darwin") return false;
|
||||
const actualExecutable = actualCommand.split(/\s+/u, 1)[0];
|
||||
const expectedExecutable = expectedCommand.split(/\s+/u, 1)[0];
|
||||
const normalizedActualExecutable =
|
||||
actualExecutable?.startsWith("(") === true && actualExecutable.endsWith(")")
|
||||
? actualExecutable.slice(1, -1)
|
||||
: actualExecutable;
|
||||
return (
|
||||
actualExecutable !== undefined &&
|
||||
normalizedActualExecutable !== undefined &&
|
||||
expectedExecutable !== undefined &&
|
||||
basename(actualExecutable) === basename(expectedExecutable)
|
||||
basename(normalizedActualExecutable) === basename(expectedExecutable)
|
||||
);
|
||||
};
|
||||
|
||||
@@ -70,6 +70,9 @@ describe("owned process-group cleanup", () => {
|
||||
"darwin",
|
||||
),
|
||||
).toBe(true);
|
||||
expect(
|
||||
matchesOwnedProcessCommand("(node)", "/opt/node/bin/node", "darwin"),
|
||||
).toBe(true);
|
||||
expect(
|
||||
matchesOwnedProcessCommand(
|
||||
"node /tmp/fake-launcher.mjs",
|
||||
@@ -84,6 +87,9 @@ describe("owned process-group cleanup", () => {
|
||||
"linux",
|
||||
),
|
||||
).toBe(false);
|
||||
expect(
|
||||
matchesOwnedProcessCommand("(node)", "/opt/node/bin/node", "linux"),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("signals only a group whose every member carries the run token", async () => {
|
||||
|
||||
Reference in New Issue
Block a user