Repository navigation
bot: stop the redundant join and full replay after a table closes - #970
Merged
Merged
Conversation
The server seats the bot at another table within 0.2 s of a table closing, but `Seat::joined` cleared only the leave, so the join the close had queued stayed set. The session loop sent `join_lobby` about 10 s later and drew `already_seated`, twice for Svanism on 2026-10-10. `joined` now clears `pending_join` as well: a seat from the server leaves nothing to join. Part of #967. Generated-by: claude-code/claude-sonnet-5-5 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The `already_seated` handler always asked for a resync from sequence 0. When the tracker already held the named table, the reply replayed the table's whole history over live state: 37 false "cannot be settled" warnings on 2026-10-10 and 2026-10-11 (one per hand played before the bot sat down, because `played_seat` matches a result by seat number), and one stored hand carrying a stale seat bet from replayed earlier hands. The handler now goes through `recover::adopt_table`: a table the tracker holds asks from its watermark, as a reconnect does, and any other table still asks from 0. The protocol spec row says so. Closes #967. Generated-by: claude-code/claude-sonnet-5-5 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The review of #967 found the call site of `Seat::joined` unpinned: the seat unit test pins the method, not the `table_joined` arm that calls it. The new handler test feeds `table_closed` then `table_joined` and asserts no join is queued; it fails when `joined` leaves the flag set. The two spec rows that said a close rejoins the lobby now say "unless `table_joined` arrives first". Part of #967. Generated-by: claude-code/claude-sonnet-5-5 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
What generated this?
Generated-by: claude-code/claude-sonnet-5-5
Motivation
Closes #967.
After a table closes the server re-seats the bot within 0.1 to 0.2 s, but the join that
table_closedqueued stayed set, becauseSeat::joinedcleared only the leave. The session loop sentjoin_lobbyabout 10 s later and drewalready_seated. The handler then asked for a resync from sequence 0 although the tracker already held the table, so the reply replayed the table's whole history over live state.Live evidence on build 7a1494c (2026-10-10 11:00 to 2026-10-11 22:12 UTC), from
artifacts/logs/svanbot10.log:already_seated(Svanism twice, Svanar once) and onealready_in_lobby.played_seatmatches a result by seat number, so an earlier occupant of the seat counts as the bot.bet_before744 against a 30-chip pot. 1 of 13,486 hands since the install.No row was lost and no action was illegal; the cost is false alarms on the one warning that exists to catch a lost row, and one polluted summary.
Solution
Three commits in
crates/apps/bot/src/client/, two for the defects and one pinning a call site the review found loose. Each defect has a test that failed before its fix, run on the unmodified code first:Seat::joinedalso clearspending_join. Test:a_seat_the_server_gives_us_makes_a_queued_join_moot(failed with "seated: nothing is left to join").already_seatedhandler goes through newrecover::adopt_table: a table the tracker holds asks from its watermark, as a reconnect does; any other table still asks from 0. Test:an_already_seated_for_the_table_we_hold_asks_from_the_watermark(failed with left 0, right 40; both halves run against a tracker that holds another table, so an implementation that ignored the table id would fail). The protocol spec row says so.handler.rsgoes from 500 to 499 lines.table_closedthentable_joinedleaves no join queued, which pins thetable_joinedarm that callsSeat::joined(it fails with the clearing line removed), and the two spec rows that said a close rejoins the lobby now say "unlesstable_joinedarrives first".Off the decision path: client lifecycle, nothing the golden snapshot or
sim pairedexercises, so no paired simulation. Not released: the running build is 7a1494c.Not changed, filed separately: the stale
resumableentry behind three other false "row is lost" warnings (#968), and the stale history store (#969).Checklist
scripts/check.sh fullpasses on this exact commit (e4e3df2), run in a worktree on the shared warmtarget/dev:docs/SPEC-protocol.md, three rows).Generated-by:is in every commit footer and in the section above.🤖 Generated with Claude Code