Review of PR #850: "fix: a voice_leave naming its Talk and tab ends a lost connection's lingering seat"
From mnema-talk v3.3.13, rendered on this site.
Independent review by an opus reviewer, two rounds, final head 3259494b3. Verdict of the last round: MERGE. The code and tests were written by an agy worker (Gemini); the review and the checks were run separately.
Round 1: FIX
The server rule (a seatless connection's voice_leave {channel_id, tab} ends the lingering seat only for the same user, a pending grace of that Talk with the same non-empty tab, and no other connection of the user seated there) was correct and race-safe. Findings:
- Blocking: after a short network blip the browser often reconnects before the server notices the old connection is dead (the ping wait is 60 s). Then no grace exists yet and the old connection is still seated, so the leave kept the seat. The leave now also ends the seat of another connection of the same user in that Talk with the same tab id.
- A grace restored after a refused join lost its tab (
restoreGraceIfAbandonedstarted it without one). The tab is carried through. - Mutation gaps: the empty-tab guards, the "connection seated in another Talk" condition and a join racing the leave were not pinned. Tests were added.
- The client sends
{channel_id, tab}whenever a join was sent, also while connected, so a reconnected but not yet resumed connection ends the lost seat.
Round 2: MERGE
- Lock order:
leaveLostVoiceholds no lock on entry and takes onevoiceMuat a time, thenh.muinside it, the same order asendSiblingVoicesandleaveOtherRooms; no cycle.go test -race ./internal/wspasses. - Snapshot races: a connection that unregisters after the
clientsOfsnapshot is serialised by itsvoiceMuagainstdropVoiceForGrace(the grace carries the tab, or the leave comes first and the drop finds nothing); one that registers later holds no seat with this tab. - No double announce: the sibling path takes the grace, the grace step then keeps nothing to end; a test asserts exactly one leave.
- Mutation checks (overlay builds, worktree untouched) killed every guard except the two noted below.
- Not pinned, accepted: the
*cur == chIDcondition of the sibling loop,g.timer.Stop()(the timer's ownership check covers it) and the redundant zero-channel guard. A follow-up test for the first one is welcome. - Nit, not blocking: the optional variadic
tabparameter ofstartGrace. - Local checks: vet, the ws package tests, web vitest (1062) and type checks pass.