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.
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. - spawn_
cancellable - Test-visible generic over the binary name.
run_apr_cancellableis the"apr"-bound wrapper clients should use in production code. - spawn_
streaming - Generic-over-program variant of
run_apr_streamingused by tests that need to inject a mock subprocess.