Repository navigation
netcode: confirm the ticks a save makes final - #242
Merged
Merged
Conversation
A save is the host's world as it ran, guesses of other seats' input included. Every peer, the host too, withdrew the ticks it had run before the save but not confirmed yet, and never confirmed them: under rollback, up to maxRollback ticks of events vanished on every page at each save (a page reloading mid-match lets the others run on guesses of its seat until it is back). The page the save seated was not affected. - The host confirms every tick it ran before its save. - The save carries the inputs its last ticks ran with (protocol version 5); a peer confirms the ticks it ran with the same inputs, from a tick both confirmed. - The rest before the save (run otherwise, confirmed otherwise, or not run) is reported by lost() with the new reason "save". - A peer ahead of the host confirms the save's tick and inputDelay more: the ledger kept one tick fewer, so lost() missed one after a resync. Tests cover a page that loads again and a hidden page under "resync-on-return", rollback and lockstep, two to eight seats, a lossy link, hitches, and an adaptive delay. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HendNe1CC9Z9F2bcbgrbaD
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HendNe1CC9Z9F2bcbgrbaD
Lockstep runs nothing on a guess, so a save names none of its ticks: it allocates nothing more per tick than before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HendNe1CC9Z9F2bcbgrbaD
SandroMaglione
force-pushed
the
claude/project-thread-vlhuzg
branch
from
November 22, 2026 00:08
e9e897c to
e8bfe10
Compare
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.
Requested by Sandro · project thread
Rebased on main after #241 (one message per frame). The protocol is now version 6, and #241's changeset says so too.
What was wrong
After a save (a page that loads again, a hidden page back under
"resync-on-return", anyresync()), confirmed events went missing. They did not go missing on the page the save seated: in 280 seeded matches (2 to 8 seats, lossy link, hitches, adaptive delay), that page confirmed every tick from the save on, exactly once. The losses were on the other pages, the host included, in the ticks just before the save.A save is the host's world as it ran, including its guesses of other seats' input. Every peer withdrew the ticks it had run but not yet confirmed (
ledger.reset()), and never confirmed them. Under rollback that is up tomaxRollbackticks per page per save. When a page reloads mid-race, the others run on guesses of its seat until it is back. With Tabletop Champions' settings that is 48 ticks (0.8 s), so a lap, a checkpoint, or a sound from that stretch never reached any page, and nothing said so. Lockstep was not affected.A second bug: a peer ahead of the host can confirm the save's own tick and
inputDelaymore. The ledger kept one tick fewer of what it had handed out, solost()missed one replaced tick after a resync.The fix
ranFromandran: the canonical keys of the inputs each of the host's last ticks ran with. A peer confirms the ticks it ran with the same inputs, from a tick both had confirmed. Whatpredicted()handed out for those ticks stands.lost()with a new reason,"save": ticks this peer ran otherwise, confirmed otherwise, or never ran. Their predictions are withdrawn. A page the save seats for its first match (one that loaded again) is told nothing of the ticks before the save.resyncReachis nowsaveDelay + 1.Breaking (types only):
EventsLost["reason"]is now"unread" | "resync" | "save". The changeset has the fix.Tests
test/Saved.test.tscovers:"resync-on-return"The host must confirm every tick it ran. Every other peer must confirm each tick once, as the host ran it, or report it through
lost(). The seated page must confirm every tick from its save on.On main (after netcode: one message per link per frame, and lighter ones #241), 14 of these 15 fail. With only the
resyncReachfix reverted, one seeded case fails.Events.test.ts: predicted ticks before the save are now confirmed. Only ticks from the save on are withdrawn.integration/netcode: the resync test now sees"save"reports on seat 1, which main dropped silently. They are recorded, and the host has none.Checks
After the rebase:
pnpm run checkpasses.pnpm --dir website buildpasses.bench:checkagainst the recorded baseline shows +33% time on the rollback frame, but main itself measures the same on this machine, so that is the machine, not this PR.🤖 Generated with Claude Code
https://claude.ai/code/session_01HendNe1CC9Z9F2bcbgrbaD