fix(_utils): scope is_caller annotation to caller's socket#22
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #22 +/- ##
==========================================
- Coverage 86.78% 86.62% -0.17%
==========================================
Files 38 38
Lines 1710 1719 +9
Branches 201 204 +3
==========================================
+ Hits 1484 1489 +5
- Misses 167 170 +3
- Partials 59 60 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
f6791c0 to
070f38f
Compare
Code reviewNo issues found. Checked for bugs and AGENTS.md compliance (repo has AGENTS.md, no CLAUDE.md). Scope:
🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
Before: `_serialize_pane`, `snapshot_pane`, and `search_panes` compared `pane.pane_id == TMUX_PANE` without consulting the tmux socket. A caller on socket A pane `%0` therefore saw `is_caller=True` for any `%0` on any other server — a false positive that polluted every read-path tool surface returning `PaneInfo` / `PaneSnapshot` / `PaneContentMatch`. The 0.1.0a2 caller-identity-scoping work already introduced `_caller_is_on_server` (realpath + macOS TMUX_TMPDIR basename fallback), but wired it into the self-kill guard only — the informational annotation kept its bare-equality implementation. This change centralizes the annotation via `_compute_is_caller(pane)` in `_utils.py`, which reuses `_caller_is_on_server(pane.server, caller)`. All three callers migrate; the now-dead `_get_caller_pane_id` helper is removed along with its two unit tests. Regression test `test_serialize_pane_is_caller_false_across_sockets` spawns two libtmux servers, points the caller at server A, and asserts a pane on server B with the same pane_id is flagged `False`. Closes #19
cb3566d to
02fef68
Compare
Code reviewRe-reviewed after force-push to No blocking issues found. Checked for bugs and AGENTS.md compliance. Scope of the re-review:
The prior review's concern about conservative-True semantics leaking into the annotation is resolved. 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
Summary
Pane serializers (
_serialize_pane,snapshot_pane,search_panes) comparedpane.pane_id == TMUX_PANEwithout consulting the tmux socket. A caller on socket A pane%0was therefore flaggedis_caller=Truefor any%0on any other server — a false positive that polluted every read-path tool returningPaneInfo/PaneSnapshot/PaneContentMatch.The 0.1.0a2 caller-identity-scoping work already shipped
_caller_is_on_server(realpath comparison + macOSTMUX_TMPDIRbasename fallback), but wired it into the self-kill guard only. This PR extends it to the informational annotation via a new_compute_is_caller(pane)helper in_utils.py, and migrates all three call sites. The now-dead_get_caller_pane_idhelper and its two unit tests are removed.Test plan
uv run ruff check . --fix --show-fixesuv run ruff format .uv run mypyuv run py.test --reruns 0 -vvvjust build-docsNew regression test
test_serialize_pane_is_caller_false_across_socketsspawns two libtmux servers via theTestServerfixture, points the caller at server A, and asserts pane%0on server B (same pane_id, different socket) is flaggedFalse. Sanity: pane%0on server A is stillTrue. The existingtest_serialize_pane_is_callerparametrization continues to pass — the no-TMUX-set conservative branch is preserved for consistency with_caller_is_on_server.Companion PRs
Part of a batch of post-0.1.0a2 smoke-test fixes. Each PR is independent and can land in any order:
asyncio.to_thread#21 — event-loop block in channel waits (closes wait_for_channel and signal_channel block the FastMCP event loop (sync subprocess.run) #18)is_callersocket-blind false positive (this PR, closes is_caller annotation gives false positives across tmux sockets #19)libtmux_test*sockets (closes list_servers exposes dozens of leaked libtmux_test* tmux daemons after test runs #20)Closes #19