fix(verifiers): preserve results and own cleanup through completion

Attempt independent resource cleanup without losing primary failures, retain unresolved owners, and publish completion after release. Bound existing producer commands, preserve helper return values, and settle startup and fixture children on failure.

Validation: 29 focused boundary tests passed; actual helper-value and import-bound filesystem cleanup controls passed. The real inert-child termination control and targeted JavaScript binding checks passed, alongside typecheck, lint and formatting. Live Ghidra, Cutter, Electron GUI and Windows addon qualification was not run.
This commit is contained in:
morluto committed 2026-11-10 17:03:59 -05:00
1 parent dcee59f273
commit 4082375e73
24 files changed
+3303 -2901

No files matched your search

+33 -26
View File
@@ -1,19 +1,22 @@
import { Client } from "@modelcontextprotocol/client";
import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";
import { execFile } from "node:child_process";
import { createVerifierMcpOwner } from "./verifier-mcp-owner.mjs";
import { withVerifierCleanup } from "./verifier-cleanup.mjs";
import { readFile } from "node:fs/promises";
import { join } from "node:path";
import { promisify } from "node:util";
import { FULL_CATALOG_IDENTITY } from "../../dist/catalogIdentity.js";
import { verifyCompleteToolCatalog } from "./verify-package-core.mjs";
const execute = promisify(execFile);
/** Install the selected archive or registry specifier before any protocol deadline. */
export async function installCanaryPackage(specifier, workspace, environment) {
/** Install the selected archive or registry specifier with an owned ten-minute deadline. */
export async function installCanaryPackage(
specifier,
workspace,
environment,
commands,
) {
const prefix = join(workspace, "installed");
await execute(
await commands.exec(
"npm",
[
"install",
@@ -26,7 +29,12 @@ export async function installCanaryPackage(specifier, workspace, environment) {
prefix,
specifier,
],
{ cwd: workspace, env: environment, maxBuffer: 16 * 1024 * 1024 },
{
cwd: workspace,
env: environment,
timeout: 600000,
maxBuffer: 16 * 1024 * 1024,
},
);
return join(prefix, "node_modules", "rea-agents");
}
@@ -36,7 +44,7 @@ export async function verifyInstalledCanaryPackage(
packageRoot,
version,
workspace,
environment,
{ environment, commands },
) {
const installed = JSON.parse(
await readFile(join(packageRoot, "package.json"), "utf8"),
@@ -47,9 +55,10 @@ export async function verifyInstalledCanaryPackage(
);
const launcher = join(packageRoot, "scripts", "rea.mjs");
for (const option of ["--help", "--llms"])
await execute(process.execPath, [launcher, option], {
await commands.exec(process.execPath, [launcher, option], {
cwd: workspace,
env: environment,
timeout: 30000,
maxBuffer: 16 * 1024 * 1024,
});
const transport = new StdioClientTransport({
@@ -65,22 +74,20 @@ export async function verifyInstalledCanaryPackage(
if (stderr.length < 16_384)
stderr += chunk.toString("utf8").slice(0, 16_384 - stderr.length);
});
try {
await client.connect(transport);
const toolNames = await verifyCompleteToolCatalog(client);
return {
mcpTools: toolNames.length,
canonicalMcpTools: FULL_CATALOG_IDENTITY.counts.mcp_tools,
};
} catch (cause) {
throw new Error(`Installed package MCP verification failed: ${stderr}`, {
cause,
});
} finally {
const owner = createVerifierMcpOwner();
commands.adopt(owner, "installed package MCP transport");
return withVerifierCleanup(async () => {
try {
await client.close();
} finally {
await transport.close();
await owner.open(client, transport);
const toolNames = await verifyCompleteToolCatalog(client);
return {
mcpTools: toolNames.length,
canonicalMcpTools: FULL_CATALOG_IDENTITY.counts.mcp_tools,
};
} catch (cause) {
throw new Error(`Installed package MCP verification failed: ${stderr}`, {
cause,
});
}
}
}, [() => owner.close()]);
}