Skip to content

feat: ACP stdio NDJSON transport layer - #1020

Merged
malibio merged 1 commit into
mainfrom
feature/issue-1001-acp-transport
Apr 3, 2026
Merged

malibio merged 1 commit into
mainfrom
feature/issue-1001-acp-transport

Conversation

@malibio

@malibio malibio commented Apr 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Implements StdioTransport for external ACP agent communication over stdio
  • NDJSON framing with JSON-RPC 2.0 protocol
  • Graceful shutdown (close → SIGTERM → SIGKILL)
  • Process crash detection and error handling

Closes #1001

Co-Authored-By: Claude [email protected]

Implements StdioTransport for communicating with external ACP agents
over stdio using newline-delimited JSON-RPC 2.0. Includes process
spawning, NDJSON framing, graceful shutdown, and error handling.

Co-Authored-By: Claude <[email protected]>
@malibio
malibio merged commit e77899c into main Apr 3, 2026
@malibio
malibio deleted the feature/issue-1001-acp-transport branch April 3, 2026 22:55
@malibio

malibio commented Apr 3, 2026

Copy link
Copy Markdown
Collaborator Author

Post-Merge Code Review: PR #1020 (ACP stdio NDJSON transport layer)

Verdict: Clean -- no critical issues found.

Findings

Suggested Improvements

  • Shutdown race window: In shutdown(), the Notify::notify_waiters() is a one-shot signal. If a background task hasn't yet reached its notified() await point, it may miss the signal. Since kill_on_drop(true) is set and stdin is dropped (which closes the pipe), this is self-healing in practice. However, consider using tokio_util::sync::CancellationToken instead of Notify for shutdown coordination -- it doesn't have the "must be awaiting at signal time" constraint. Priority: Low -- the 3-phase shutdown (stdin close -> SIGTERM -> SIGKILL) provides sufficient defense-in-depth.

  • unsafe SIGTERM call: The libc::kill() call is necessary and correctly gated behind #[cfg(unix)]. The child.id() returns Option<u32> which correctly handles the case where the PID isn't available. No action needed.

Notes

  • Good test coverage (10 tests covering echo, partial line, invalid JSON, broken pipe, env vars, shutdown idempotency).
  • Architecture is solid: reader/writer tasks decoupled via mpsc channels, stderr captured separately.
  • kill_on_drop(true) is a good safety net.

No follow-up fixes required.

malibio added a commit that referenced this pull request Jun 22, 2026
Implements StdioTransport for communicating with external ACP agents
over stdio using newline-delimited JSON-RPC 2.0. Includes process
spawning, NDJSON framing, graceful shutdown, and error handling.

Co-authored-by: Michael Libio <[email protected]>
Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ACP stdio NDJSON transport layer

1 participant