Expand description
Shared subprocess wrapper for M2/M3 tools.
Every M2 tool spawns apr <subcommand> [...args] --json and passes stdout
through to the MCP client verbatim. Non-zero exit maps to isError: true
with stderr attached. This module centralizes that pattern so each tool is
a thin definition + a list of CLI args.
M3 (FALSIFY-MCP-006) adds run_apr_cancellable, which polls a
std::sync::mpsc::Receiver between try_wait checks and escalates to
SIGTERM → (grace window) → SIGKILL on the spawned subprocess when a
cancellation is signalled. The non-cancellable run_apr is kept as a
thin wrapper for tools that don’t support cancellation yet.
#2418: the failure path used to pick either stderr or stdout — stdout
only when stderr was empty. apr qa writes its JSON gate report to stdout
and a one-line summary to stderr, so every failing QA run (the tool’s
primary use case) reached the client as a single line with the >3 KB
report thrown away. [failure_result] now keeps the summary as the first
content block and attaches the report as a second one, so a failing gate
is as inspectable as a passing one.
Constants§
- CANCEL_
GRACE_ MS - Default grace window between SIGTERM and SIGKILL for cancelled calls.
Functions§
- run_apr
- Spawn
apr <args...>and wait synchronously. Shorthand for the non-cancellable path used by every tool exceptapr.run. - run_
apr_ cancellable - Spawn
apr <args...>cancellable viacancel_rx. - run_
apr_ streaming - Spawn
apr <args...>and stream stdout line-by-line toon_line. - run_
program - Generic-over-program variant of
run_apr.run_aprbindsprogramtocrate::apr_bin::apr_binary— the runningaprexecutable — so the version the user launched is the version that answers. - spawn_
cancellable - Generic over the binary.
run_apr_cancellablebindsprogramtocrate::apr_bin::apr_binary— the runningaprexecutable — which is what production code should use. - spawn_
streaming - Generic-over-program variant of
run_apr_streaming. Production callers passcrate::apr_bin::apr_binary; tests use it to inject a mock.