* chore(mypy): switch to strict mode with listed exceptions
Replace the hand-picked flags with `strict = True`, turning off only the
four flags that aren't clean yet (disallow_any_generics,
warn_return_any, disallow_untyped_calls, disallow_untyped_decorators).
Any other strict flag, including those future mypy releases add to the
preset, is on by default.
That turns on no_implicit_reexport, strict_equality and extra_checks:
- Import each name from the module that defines it. About 240 test
sites patched a dependency through the module that imported it
(`scan_module.fs_rom_handler`); they now import the same object from
its source, so every patch targets what it did before. Tests that
replace a module attribute are unchanged.
- handler.streaming.memory_cards re-exports store_memory_card_version
explicitly, since endpoints call it there and tests patch it there.
- mutagen gets implicit_reexport, as it re-exports without __all__.
- Test comparisons build typed values (CoverResult, a typed expected
dict, enum .value) and the CORS lookup casts for its identity check.
- One ss_handler ** spread keeps a coded ignore: extra_checks wants its
NotRequired dump_* keys spelled out, and the media dict never has them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PLzXae5up2pYXRoBjfjn2G
* chore(mypy): give every generic its type arguments
Drop disallow_any_generics from the strict-mode exceptions and fix the
347 bare generics it reports, 230 of them in app code.
- Bare `dict` becomes `dict[str, Any]`: update payloads, raw provider
JSON and endpoint bodies map string keys to mixed values, so the Any is
real and now written down. The OpenAPI document is unchanged.
- Rom query filters take and return RomSelect; _music_facet_joins and
_exclude_hidden are generic over the Select they're given, and
_build_hash_selects returns id-only selects.
- Redis clients are typed by what they return: the decoding caches are
Redis[str], the RQ connection and binary cache Redis[bytes].
- The rest get explicit parameters: Row, Pattern, ColumnElement,
QueryableAttribute, SpooledTemporaryFile, Task, Future and friends.
Precise types reached callers that had been getting Any, which surfaced:
- The LaunchBox cache writer is fed binary-cache pipelines.
- The flashpoint and IGDB request helpers return raw JSON of varying
shape, not always a dict.
- The rom search endpoint returned dicts under a list[SearchRomSchema]
annotation; it now validates them into that schema.
- The audit filter's id subquery selects strings.
- In tests the binary cache is the non-decoding fake shared with
async_cache, so it is cast to Redis[bytes] rather than changed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PLzXae5up2pYXRoBjfjn2G
* test(upload): assert cleanup against the patched upload directory
The 409 test checked config's ROM_UPLOAD_TMP_BASE while the fixture patches
the endpoint's copy to tmp_path/uploads, so it passed even if cleanup failed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PLzXae5up2pYXRoBjfjn2G
* chore(mypy): keep the row type through the ROM filter helpers
filter_roms and its helpers also receive select(Rom.id) membership queries,
so they now take and return the caller's Select type instead of narrowing to
RomSelect. merged_ra_metadata mixes scalar and list values.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PLzXae5up2pYXRoBjfjn2G
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
- Declare the container and claimed_at query params once, with named length limits.
- Add lifecycle.start_exit_save_pull for the two callers that mark and start back to back.
- Build every claim query on the frontend through one claimParams helper.
- Drop PlayerState casts that narrowed nothing in the launch socket handlers.
- Reuse _load_session in the _drain test helper.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Port the branch's emulator labels and live-state flag onto master's typed
streaming schemas, and carry the labelled state reason into
useSaveStateTabs now that the EmulatorJS view delegates to it.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- Re-measure the phone event rows whenever a web font finishes loading,
and when a scrollbar narrows the rows, not only at mount.
- Log only the kind of an audit claim key when Redis fails, since a
failed sign-in's key holds the text typed as the username.
- Make play-session ingest take the caller's permissions explicitly, so
no caller skips the hidden-rom check by leaving them out.
- Read an empty collection cover URL as no cover, as the other fields do.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Toasts disappear after a few seconds, and nothing reaches a user who has no
tab open. Notifications are now stored per user and kept until dismissed, so
what a background job or another user did is waiting the next time RomM is
opened.
Backend:
- `notifications` table (0130) with kind, level, data, actor and read_at, capped
at the newest 200 per user.
- /api/notifications: list, mark read, dismiss one, dismiss all.
- notify()/notify_admins() store the row and push `notifications:new` to the
user's socket room; read/dismiss push to the user's other tabs.
- Producers: a scan's end (to whoever started it; an unattended scan tells
the admins when it failed or found new games), a manual task's end (to who
ran it; a scheduled task's failure to the admins), an admin ending someone's
stream, and an admin changing someone's role.
Frontend (v2):
- Unread count badge on the navbar avatar, and a Notifications entry in the
user menu and settings sidebar.
- Notifications view: marks what it shows read, links each row to what it is
about, dismiss one or all.
- Live toast for a new notification, except scans, which already toast.
- The text is rendered from the kind in the reader's language (18 locales).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A session whose heartbeat went stale was only torn down when a new claim
found every container of its platform held, so a player who left without
the pagehide release landing kept the emulator running. A scheduled task
now sweeps every configured container and hands stale sessions to the
existing abandoned-session teardown, which is made public for it.
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>