Add comprehensive race condition & state conflict xfail test suite#627
Draft
Add comprehensive race condition & state conflict xfail test suite#627
Conversation
why: Document known vulnerability where two-step "create → query" pattern in new_session(), new_window(), and split() can fail if tmux state changes between the creation command and the subsequent list-* query (#624). what: - Add tests/test_race_conditions.py with 6 strict xfail tests - 3 tests for server crash between create and query (Mode A) - 3 tests for stale empty list-* response (Mode B) - All tests are parallel-safe (unique sockets, function-scoped monkeypatch) - Tests will flip to XPASS when creation methods construct objects directly from -P output instead of re-querying
… ID recycling why: Extend the race condition test suite into a comprehensive almanac of every discoverable state conflict in libtmux, beyond the initial 6 create-query tests. what: - Add Category 2: Object staleness after external mutation - Killed session active_window gives raw LibTmuxException - Killed session refresh correctly raises TmuxObjectDoesNotExist (passing) - Killed window panes gives raw LibTmuxException - Dead pane send_keys silently swallows error - Add Category 3: DX frustrations - Dead server sessions silently returns [] (bare except:pass) - Context manager rename works correctly (passing positive test) - Dead server windows/panes raise raw LibTmuxException (inconsistent) - Add Category 4: Query/filter edge cases - Filter typo field silently returns empty list - fetch_obj by mutable session_name fails after rename - Add Category 5: ID recycling after server restart - Stale ref with recycled $0 silently returns wrong session data
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #627 +/- ##
==========================================
+ Coverage 45.39% 45.57% +0.17%
==========================================
Files 22 22
Lines 2249 2249
Branches 360 360
==========================================
+ Hits 1021 1025 +4
+ Misses 1082 1080 -2
+ Partials 146 144 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tests/test_race_conditions.pywith 17 tests (15 xfail, 2 passing) documenting every discoverable state conflict in libtmuxCategories
Category 1 — Create-query races (6 xfail): Two-step "create → query" pattern fails when state changes between the tmux command and the follow-up list query.
Category 2 — Object staleness after external mutation (3 xfail, 1 pass): Cached Python objects become invalid after the underlying tmux object is killed externally. Includes killed session/window/pane access patterns.
Category 3 — DX frustrations (3 xfail, 1 pass): Natural API usage patterns that produce confusing or silent failures — dead server
sessionsreturning[], inconsistent error handling betweensessions/windows/panesproperties.Category 4 — Query/filter edge cases (2 xfail):
QueryList.filter()with typo field names silently returns empty lists;fetch_objby mutable keys fails after renames.Category 5 — ID recycling after server restart (1 xfail): Stale Python refs with recycled
$0IDs silently match wrong objects after server restart.Test plan
uv run pytest tests/test_race_conditions.py -v— 2 passed, 15 xfaileduv run ruff check tests/test_race_conditions.py— no errorsuv run mypy tests/test_race_conditions.py— no errorsuv run pytest— full suite passes (874 passed, 1 skipped, 15 xfailed)