mirror of
https://github.com/morluto/rea.git
synced 2026-10-28 10:25:42 +00:00
Expose the existing WABT command deadline as an optional validated per-call CLI/MCP budget, preserving its 30000 ms default and fixed safety allowances. Retain selected execution profiles in success and rejected-module Evidence. Keep typed timeout recovery through cleanup failures without duplicating command output or making incomplete cleanup retryable. Verified focused tests, real WABT CLI/MCP workflows and actual Codex recovery/blocked controls; detailed measurements and qualification limits are recorded in issue #5797. Merge uses the explicitly authorized maintainer override with pending CI and unchecked human-review attestations disclosed on PR #5798. Closes #5797 Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing)
90 lines
3.3 KiB
TypeScript
90 lines
3.3 KiB
TypeScript
import { compareWasmInterfaces } from "../application/wasm/WasmInterfaceComparisonService.js";
|
|
import { parseCliJsonInput } from "../cliJsonInput.js";
|
|
import { CLI_COMMANDS } from "../cliCommandNames.js";
|
|
import { z } from "incur";
|
|
import { wasmArtifactModule } from "../composition/wasm.js";
|
|
import { logCliCommand } from "../cliLogging.js";
|
|
import { projectAnalysisError } from "../domain/analysisErrorProjection.js";
|
|
import type { Logger } from "pino";
|
|
import type { CliInstance } from "./types.js";
|
|
import { withCommandCancellation } from "./commandCancellation.js";
|
|
import { absoluteCallerPath } from "../filesystem/callerPath.js";
|
|
import { finishAnalysisCommand } from "./finishAnalysisCommand.js";
|
|
import { inspectWasmArtifactInputSchema } from "../domain/wasm/wasmArtifact.js";
|
|
|
|
/** Resolve all caller-selected artifact paths through the shared workflow. */
|
|
export const registerWasmCommands = (
|
|
cli: CliInstance,
|
|
logger: Logger,
|
|
environment: Readonly<NodeJS.ProcessEnv>,
|
|
): void => {
|
|
cli.command(CLI_COMMANDS.compareWasmInterfaces, {
|
|
description:
|
|
"Compare core WASM interfaces from two exact inspection Evidence records",
|
|
args: z.object({
|
|
input: z
|
|
.string()
|
|
.describe(
|
|
"Inline JSON or input file containing left/right complete Evidence and required scope",
|
|
),
|
|
}),
|
|
run: ({ args }) =>
|
|
withCommandCancellation(async (signal) =>
|
|
logCliCommand(logger, CLI_COMMANDS.compareWasmInterfaces, async () => {
|
|
const input = await parseCliJsonInput(
|
|
args.input,
|
|
"compare_wasm_interfaces",
|
|
);
|
|
if (!input.ok) return input.error;
|
|
const result = await compareWasmInterfaces(input.value, { signal });
|
|
return result.ok ? result.value : projectAnalysisError(result.error);
|
|
}),
|
|
),
|
|
});
|
|
const service = wasmArtifactModule.create(environment);
|
|
cli.command(wasmArtifactModule.cliCommand, {
|
|
description: "Inspect an explicit local WASM artifact with WABT",
|
|
args: z.object({
|
|
path: z.string().describe("Local WASM artifact"),
|
|
}),
|
|
options: z.object({
|
|
commandTimeoutMs: inspectWasmArtifactInputSchema.shape.command_timeout_ms,
|
|
glue_paths: z
|
|
.array(z.string())
|
|
.optional()
|
|
.describe("Selected local JavaScript glue paths"),
|
|
candidate_paths: z
|
|
.array(z.string())
|
|
.optional()
|
|
.describe("Explicit local WASM candidates"),
|
|
}),
|
|
run: ({ args, options }) =>
|
|
withCommandCancellation((signal) =>
|
|
logCliCommand(logger, wasmArtifactModule.cliCommand, () =>
|
|
finishAnalysisCommand(
|
|
() =>
|
|
service.inspect(
|
|
{
|
|
path: absoluteCallerPath(args.path),
|
|
...(options.commandTimeoutMs === undefined
|
|
? {}
|
|
: { command_timeout_ms: options.commandTimeoutMs }),
|
|
glue_paths: options.glue_paths?.map((path) =>
|
|
absoluteCallerPath(path),
|
|
),
|
|
candidate_paths: options.candidate_paths?.map((path) =>
|
|
absoluteCallerPath(path),
|
|
),
|
|
},
|
|
{ signal },
|
|
),
|
|
service,
|
|
"wabt-artifact",
|
|
"inspect_wasm_artifact",
|
|
signal,
|
|
),
|
|
),
|
|
),
|
|
});
|
|
};
|