Skip to content

[ahma_mcp/http_bridge/tui] Orphan-stdio prevention, bridge client-response routing, daemon/TUI tool routing#263

Merged
paulirotta merged 2 commits into
mainfrom
feature/fixup2
Jun 17, 2026
Merged

[ahma_mcp/http_bridge/tui] Orphan-stdio prevention, bridge client-response routing, daemon/TUI tool routing#263
paulirotta merged 2 commits into
mainfrom
feature/fixup2

Conversation

@paulirotta

Copy link
Copy Markdown
Owner

Summary

A multi-area reliability/correctness pass ("fixup2") covering MCP process lifecycle, HTTP-bridge request routing, daemon/TUI tool routing, and the simplify analyzer. New behavior is codified in SPEC.md (R-LIFECYCLE.2, R10.6–R10.8, R-SETUP.1/2).

Frontend orphan prevention — orphaned ahma serve stdio storm (SPEC R-LIFECYCLE.2)

  • New ahma_mcp/src/utils/parent_watchdog.rs: the IDE-facing stdio frontend polls getppid() and exit(0)s within a few seconds when reparented (parent IDE hard-killed without closing stdin).
  • Handshake deadline: if the client never sends its initialize within FRONTEND_HANDSHAKE_DEADLINE_SECS (default 30, test-overridable), the spawned-and-abandoned frontend exits. Disarmed once the first message is forwarded, so live-but-idle sessions are never killed.
  • The detached bridge/daemon are deliberately not watched — they outlive their spawner by design and self-terminate via idle-timeout.

HTTP bridge: client response → request mapping (SPEC R10.6)

  • The bridge now tracks outstanding server→client JSON-RPC request IDs (roots/list, sampling/createMessage). A client result only triggers roots-parsing / sandbox-lock when its ID matches an outstanding roots/list. Keepalive-ping and sampling responses no longer spuriously parse roots or emit invalid-roots warnings.
  • Covered by new ahma_http_bridge/tests/client_response_routing_test.rs.

Daemon & TUI chat MCP base-URL resolution (SPEC R10.7, R10.8)

  • Background daemon agent tasks resolve McpChatConfig.base_url to the local MCP bridge endpoint (not the LLM provider URL), so local tool calls (e.g. read_file) route back to the bridge.
  • TUI window/subtask chat tasks are given the resolved McpChatConfig for proper tool routing / sampling. Includes a substantial ahma_tui/src/llm_bridge.rs simplification.

Setup/timeouts documentation (SPEC R-SETUP.1/2)

  • Documents that terminal hooks and the MCP server are complementary (sandbox different command streams), and the configurable 600s command timeout.

Misc

  • simplify analyzer: new analysis/conversion.rs, lizard/model tweaks.
  • Dependency bumps (Cargo.lock/Cargo.toml), deny.toml, install-script touch-ups.

Verification (local, macOS)

  • cargo fmt --all --check — clean
  • cargo clippy --all-targets — clean
  • cargo nextest run2612/2616 pass, 2 skipped, 4 failing

The 4 failures are pre-existing, environment-induced, and unrelated to this branch — all are macOS Seatbelt sandbox-enforcement tests that require an OS sandbox the local shell cannot apply (nested/unavailable sandbox-exec):

  • progress_token_http_integration_test::{test_http_progress_token_is_echoed…, test_http_no_progress_token…}confirmed failing identically on main (bridge can't start under sandbox-exec → health timeout).
  • sandbox_security_red_team_test::red_team_command_write_escape_blocked and sandbox_roots_handshake_test::test_working_directory_outside_sandbox_rejected — fail because Seatbelt isn't enforced here, so an out-of-scope write is not OS-blocked. These pass on CI runners where the sandbox is active (Landlock/Seatbelt).

No source files involved in these tests were changed by this branch.

🤖 Generated with Claude Code

@paulirotta paulirotta merged commit 932ddf3 into main Jun 17, 2026
12 checks passed
@paulirotta paulirotta deleted the feature/fixup2 branch June 17, 2026 03:49
@paulirotta paulirotta restored the feature/fixup2 branch June 17, 2026 03:49
@paulirotta paulirotta deleted the feature/fixup2 branch June 17, 2026 03:50
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.

1 participant