fix(cmux-tui-core): a tab order change validates its pane, not every tab of it

LA
1d ago
+35-2

Summary

Second cause of the base red cmux-tui-core state::group_update_latency_tests::a_persons_requests_answer_while_busy_sessions_saturate_the_registry (a person's chat tab over its 200 ms p95 while busy sessions write; red in 9 of 31 full runs I have logs of). The first cause (the public fold never pruned restated chat tabs) is #36212.

Cause (product): every tab create, move or close sends its pane's new order (SetTabOrder), and validate_touched_resource_invariants (workspace_registry/resource_store.rs) put every tab of that order into the validation set: validate_touched_tab ran once per tab of the pane, about 5 queries each, inside the writer transaction under the registry lock a person's next click waits on. A tab order change writes only positions: set_resource_tab_order requires the exact live set, and the contiguous-position check below covers the order, so no tab's own rows change. SetWorkspaceOrder was already exempted for the same reason ("validating every workspace per create cost O(n)").

Fix: SetTabOrder adds only its pane to the validation set. Tabs the patch changes are still validated through their own changes (UpsertTab, TombstoneTab, their content).

Commits: (1) red test state::group_update_latency_tests::a_chat_tab_create_validates_only_the_tabs_it_changed with a test-only counter on validate_touched_tab (a create in a 31-tab pane validated 31 tabs on the base); (2) the fix.

Testing

  • Deterministic red, test commit 2753606aef2: Linux (job 42a31ec88055136f1de61666) and macOS (job 1b0a8d844d2f77a79e413e2a): "one chat tab create in a 31-tab pane validated 31 tabs".
  • Green at 39fb532555f: Linux all filter resource (job 90677b103a2f7c679c2b003d): 339 of 339, fmt pass, clippy pass; macOS filter tab (job 87511a2fde88bde618fdf1fa): 779 of 779; panic ratchet (job 1de28e5641b7f95052901e0a) pass; full Linux (job 1276a059d6d618160a09ffcf): 17258 of 17258 pass, the latency test included.
  • python3 scripts/cmux-next/prepush-gate.py: no new violations.

Observed / Not run

  • Observed: the results above.
  • Not changed, for the owner (PL-daemon): SetTabOrder also makes every tab of the pane a journal subject (session_journal.rs collect_patch_subjects: one journal_subject_index row per tab per create). SetWorkspaceOrder dropped the same; changing it changes what a subject reader returns, so it is the owner's call.

Changelog

none


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.


Summary by cubic

A tab order change (SetTabOrder) now validates only the pane it changed, not every tab in it. Previously each tab of the pane ran about 5 validation queries inside the writer transaction under the registry lock a person's next click waits on — a second cause of the red group_update_latency_tests latency test. An order change writes only positions, covered by the exact-live-set and contiguous-position checks, so no tab's own rows change; the same rationale already exempted SetWorkspaceOrder.

Adds a regression test with a test-only counter on validate_touched_tab, asserting one create in a 31-tab pane validates only the changed tabs. SetTabOrder still makes every tab of the pane a journal subject; changing that is left to the owner of session_journal.rs.