A webstation exit that timed out or failed may still be writing its save dump, so taking its first answer as final could leave the archive uncollected. The stop now reports whether the broker answered, and only an answered exit or a confirmed save-and-exit takes one fetch. The claim test now makes a real claim while the pull runs.
A per-emulator broker acks DELETE /launch before the emulator has flushed its saves, and a blocking save-and-exit that timed out or failed may still be killing it, so one answer from those pulls could miss the session's saves. Only a webstation exit, which answers once its dump is written, and a confirmed blocking save-and-exit take the first answer as final.
The repo caps a comment at two lines and a docstring at one sentence plus Args and Returns. Several comments and docstrings this branch wrote or edited ran to three lines or more, so they are tightened, with parameter notes moved under Args.
The pull retries to wait out an emulator still writing its saves, but every teardown stops the emulator first, so a pull after an exit with nothing new ran all five attempts and held the player's next claim for about twelve seconds. Only a background save-and-exit, where the broker may still be saving, keeps retrying.
The release and abandoned teardowns only marked the pull after the stop, the card evacuation and the state pull. On a pool the player's next claim landed on a free sibling in that window, found nothing pending and hydrated from the archive before last. The mark now goes down as soon as the teardown owns the container, and a teardown that ends without starting the pull clears it.
The marker was one bare flag per user and ROM, so when two pulls overlapped the first to finish deleted the mark the second had set, and a claim behind the second stopped waiting for it. Each mark now carries a token and the clear is a compare-and-delete.
resolve_owned_session's include_desktop was never passed, and the two
teardown helpers and stamp_launched defaulted arguments every caller
supplies. The 409 builder's holder snapshot no longer reuses the name of
the container above it.
An exit pulls the in-game save archive off the container in a detached task,
so a claim landing right behind the release hydrated the container from the
archive before last and the player lost the session they just finished.
The teardown marks the pull pending in Redis before spawning it and clears the
marker when the task ends, and a claim waits the marker out before hydrating.
The wait is capped so a wedged pull costs one stale hydrate rather than a claim
that never answers.
A crashed tab leaves a stale session, and pressing Play again sweeps it.
The sweep left the same notice a force-release does, which went to the
user, whose only tab was the one that had just claimed the container: it
read the push as its own session ending and handed the claim straight
back.
The takeover now names the claimant, and the sweep skips the notice when
it is the owner coming back. A takeover by anyone else still leaves it.
The termination notice named only the platform, so a tab could not tell
which of the account's claims had ended. One room carries them all: a
player holding two sessions from a pool, or an admin with a desktop open
alongside a game, tore down the wrong screen.
The notice now names the container it ended and whether that claim was a
desktop. Stream.vue ignores a desktop notice and one for a container it
did not claim; Desktop.vue gains the listener it never had, so a
force-released desktop says so at once instead of at the next heartbeat.
The tombstone also moves ahead of the drain in both teardown paths: the
session is over the moment the marker lands, and a poll during the
seconds of broker round trips that follow found no reason at all.
endpoints/streaming.py had grown to 3778 lines, but only about a third of
that was routes. The rest was a second copy of the layer handler/streaming
already exists to hold: broker verbs, webstation protocol translation,
state and save and memory-card transfer, session teardown.
Split it along those seams rather than by route, and give claim_session
the same treatment: its 406 lines are now four named phases.
Cross-module calls go through the module (states.pull_state_to_library,
commands.stop) instead of imported names, so one definition site is what
tests patch and what every caller reads.
No route path, scope or response model changed, so the OpenAPI schema is
untouched.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>