Skip to content

feat(isolation): typed itmux subprocess client (Plan 1b Task 3)#238

Closed
NeuralEmpowerment wants to merge 2 commits into
mainfrom
feat/itmux-py-client
Closed

feat(isolation): typed itmux subprocess client (Plan 1b Task 3)#238
NeuralEmpowerment wants to merge 2 commits into
mainfrom
feat/itmux-py-client

Conversation

@NeuralEmpowerment

Copy link
Copy Markdown
Contributor

Plan 1b Task 3. Typed Python client that shells out to the itmux Rust binary - ItmuxClient (start/send/await_ready/capture/exec/stop) with an injectable runner (fake-tested, no real binary/docker needed), StartReport/AwaitResult/ExecResult Pydantic models, and binary resolution ($AGENTIC_ITMUX_BIN -> repo release path -> PATH).

Parity catches from reading main.rs/result.rs: await strips pane + exits code 2 when legitimately not-ready (treated as valid, not error); exec forwards inner exit code (never raises on non-zero); plugin dirs passed via ITMUX_CLAUDE_PLUGIN_DIRS env (itmux has no flag). 22 tests; mypy strict + ruff clean.

Merge note: shares the pydantic==2.13.4 addition with Plan 1b Task 1 (#PR); merge Task 1 first, then this one's pyproject/uv.lock resolves trivially. Tracks okrs-51p.3 / okrs-o78.

Add ItmuxClient, a typed Python wrapper around the itmux Rust binary
subprocess (start/send/await/capture/exec/stop), with Pydantic v2
models (frozen, extra=forbid) parsed from itmux's JSON stdout. The
subprocess runner is injectable so tests exercise argv construction
and JSON parsing without a real itmux binary or Docker daemon.
…env, not a flag

itmux has no --claude-plugin-dirs CLI flag; it reads the colon-separated
ITMUX_CLAUDE_PLUGIN_DIRS env var. The speculative flag was a silent no-op
that would break skill injection. Wire claude_plugin_dirs through the
subprocess environment instead, and extend the injectable ItmuxRunner
protocol with a per-call env kwarg (merged over os.environ by the real
runner). Only start sets the var; other subcommands pass env=None.
Copilot AI review requested due to automatic review settings July 6, 2026 00:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a typed Python subprocess client for the Rust itmux workspace driver binary inside agentic_isolation, including strict JSON parsing via Pydantic models and a fakeable runner for deterministic unit testing.

Changes:

  • Introduces agentic_isolation.itmux_client.ItmuxClient with typed methods for start/send/await_ready/capture/exec/stop plus binary resolution logic.
  • Adds Pydantic models (StartReport, AwaitResult, ExecResult) with strict validation (extra="forbid") to avoid untyped dict plumbing.
  • Adds unit tests using an injectable fake runner and updates packaging/lockfiles to include pydantic.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.

File Description
lib/python/agentic_isolation/agentic_isolation/itmux_client.py New typed subprocess client + Pydantic models + binary resolution/failure typing.
lib/python/agentic_isolation/tests/test_itmux_client.py New unit tests validating argv/env construction, exit-code semantics, and model strictness.
lib/python/agentic_isolation/pyproject.toml Adds pydantic as a runtime dependency.
lib/python/agentic_isolation/uv.lock Locks pydantic + transitive deps for the isolation package environment.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +23 to +25
dependencies = [
"pydantic==2.13.4",
]
Comment on lines +244 to +248
agents: list[str],
startup_timeout_s: float,
strict_startup: bool,
claude_plugin_dirs: list[str] | None = None,
) -> StartReport:
Comment on lines +259 to +261
assert argv[argv.index("--timeout") + 1] == "60.0"

def test_exit_code_2_is_not_ready_not_an_error(self) -> None:
@NeuralEmpowerment

Copy link
Copy Markdown
Contributor Author

Superseded by the consolidated Plan 1b contract PR (feat/workspace-run) - all 4 contract tasks in one coherent reviewable unit. This work is included there.

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.

2 participants