Summary
A captured command crashes the MCP server on a musl host. @lydell/node-pty's
Linux prebuild is linked against glibc; under Alpine a gcompat shim lets the
addon load, and then forkpty faults the process that called it — which is
rea --mcp itself, so one capture_process_scenario took the server down and
every tool after it failed.
This picks the terminal backend before the native module is imported: node-pty where the runtime reports glibc, ordinary pipes where it does not. A capture on a musl host now completes, and the result says the terminal was not observed instead of claiming one.
Problem and expected behavior
Smallest trigger, on Alpine (musl), with rea --mcp serving tools:
tools/call→capture_process_scenariowith a minimal command.- The server process dies with SIGSEGV, leaving a core dump; the MCP client
reports
MCP server "rea" exited (SIGSEGV).
Invariant violated: observing a target must not kill the observer. Pipe capture still records output, exit, process samples and filesystem effects; what it cannot observe is a TTY, which the evidence now reports as a limitation and a terminal unknown.
Change and scope
src/process/capture/ProcessTerminalBackend.ts(new): backend choice (nativePtyUsable()readsprocess.report'sglibcVersionRuntime, Linux only), aPipeTerminalimplementing the subset ofIPtythe harness uses (data, exit, write, resize, kill, pause/resume, flow control), andspawnProcessTerminal()which imports node-pty only on the native path.ProcessHarness.ts: spawns throughspawnProcessTerminal()and records the backend it got.ProcessCaptureLifecycle.ts/ProcessCaptureCapability.ts: carry the backend and the "terminal not observed" limitation into the capture result.ProcessTerminalBackend.test.ts: pipe output/exit, scripted stdin, signal reporting, backend choice on a report with no glibc, and a guard that the native module is never imported on that path.
Not included: a PTY emulation for musl (a pure-JS terminal would still not be a kernel TTY), and any change to the node-pty path on glibc/macOS/Windows, which is unchanged.
Contract and boundary impact
- Semantic owner and earliest changed stage: process capture adapter; the
spawn stage inside
ProcessHarness. - Contribution scope fit and linked maintainer decision: ordinary fix inside existing capture boundaries; not applicable.
- CLI and MCP/tool-catalog contract: no new tools and no argument changes.
capture_process_scenariooutput gains the limitation and a terminal unknown on hosts without a usable PTY. - Provider, bridge, target-format, or platform compatibility: adds musl Linux support where the capture previously crashed. glibc Linux, macOS and Windows keep the node-pty backend.
- Evidence, artifact, provenance, or reconstruction contract: the capture records which backend ran and marks the terminal as not observed rather than inferring one.
- Target selection, authority, upstream behavior, and cleanup details: unchanged; the captured command runs with the same cwd, environment and arguments, and is killed the same way.
- Generated metadata (
docs/public/product-catalog.json), package, or installation impact: none; no generated catalogs change.
Expected effects (known effects):
- Launch or attach to a process.
- Read existing files or captured data.
- Inject instrumentation or run scripts/code.
- Change process memory, registers, files, or configuration.
- Contact network services.
- Recover protected code or work around protections.
- Documentation or usability only; no target interaction.
- Not sure yet; investigation or maintainer guidance needed.
Evidence and regression coverage
-
Tests added or updated:
ProcessTerminalBackend.test.ts— five tests, including "runs on pipes where the runtime reports no glibc, without importing node-pty", which makes@lydell/node-ptyunimportable and runs a command through the default backend with a report that carries no glibc. -
Base reproduction or other evidence: on Alpine,
rea --mcpdied with SIGSEGV on the firstcapture_process_scenariocall, leavingcore.<pid>in the server's working directory; the same call under the pipe backend returns output and exit status. Reverting the backend choice to unconditional makes the new test fail (observed). -
User-visible CLI/MCP output (if applicable): the capture result reports the backend and a terminal unknown instead of terminal observations.
-
Remaining proof gaps: the full
npm run typecheckcould not be completed on the 2 GB machine used for this work (the compiler is OOM-killed); a scopedtscover the changed files reported no errors in them. No real Hopper, Ghidra, browser or OS coverage was run — the change is in process spawning. -
Observed, derived, and inferred claims remain distinguishable.
-
Artifact identity, source provenance, and failed attempts remain preserved.
-
Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.
Validation performed
npx vitest run src/process/capture/ProcessTerminalBackend.test.ts— 5 tests passed.npx vitest run src/process/capture— 18 files, 189 passed, 11 skipped.- Regression check with
nativePtyUsable()forced totrue— 2 tests failed, as intended; source restored. npm run typecheck— not completed: the process was OOM-killed on a 2 GB host.
Compatibility, safety, and release
- Breaking changes or migration steps: none. A musl host that previously crashed now runs with pipes and says the terminal was not observed; callers that require terminal observations see the limitation rather than a silent change.
- Real Hopper/Ghidra, browser, or OS coverage: not applicable to a spawn-path change; not run.
- Package or release metadata impact: none.
- Security, privacy, process, or containment review: the pipe backend spawns
with the same arguments, cwd and environment through
node:child_process, and keeps the existing kill and flow-control behavior. No new privileges or network paths.
Author readiness
Human owner: @innotelinc
- I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
- I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
- I declare this PR ready for initial maintainer review.
Before merge
- This PR addresses a concrete problem or an agreed enhancement.
- Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
- The PR has one focused outcome and the title follows
type(scope): outcome. - Related issue is linked, or the reason for not linking one is stated above.
- Tests cover changed observable behavior and meaningful failure paths.
- Owning docs, contracts, and generated metadata are updated where needed.
- User-visible CLI/MCP changes include representative output.
- I checked the final diff for secrets, unrelated cleanup, and unsupported claims.
Activity
8Codex Review Summary
This comment shows the latest Codex review activity on this pull request.
| Review | Status | Commit | Review trigger |
|---|---|---|---|
| 📝 Code Review | ⚠️ Failed 2026-10-25T00:40:58.441694Z We couldn’t complete this review. Comment @codex review to try again. | 935d82b | Manual request |
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review" or "@codex security review".
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
Moved out of draft. The three findings from the first review are fixed in 935d82b:
- stdin is read via a stream with an error listener, so a command that closes it and stays alive cannot turn the next scripted write into an uncaught EPIPE;
- the pipe child is spawned detached (off Windows) so it leads its own process group, which is the group capture cleanup signals;
- the cancellation signal is checked again after the native import, before the command starts.
Each is covered by a test that fails when the fix is reverted; the description carries the commands and results.
The Author readiness declarations are left for the human owner (@innotelinc) to complete, per CONTRIBUTING. Flagging for review once that is done — @morluto.
@codex review — the previous review on 935d82b errored out (status: failed) rather than reporting on the diff, so this asks again now that the readiness declarations are filled.
Codex Review: Something went wrong. Try again later by commenting “@codex review”.
An unknown error occurredℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
[Medium impact] The PR appears safe to merge; all three previous findings are addressed and no new blocking issue was found.
Summary
The PR selects ordinary pipes on Linux runtimes without glibc, avoiding the unsafe native PTY path. Capture results mark terminal behavior as unknown when pipes are used.
Diagram
Reviews (2) · Last reviewed commit: "fix(capture): own the pipe child, its st..." · Reviewed by Greptile