* feat(platforms): split arcade aliases into per-emulator-family slugs
Give MAME, AdvanceMAME, FBNeo, FBA, Daphne, Singe and the arcade boards
that need their own emulator (NAOMI/NAOMI 2/NAOMI GD-ROM, Model 2/3,
Hikaru, Triforce, Lindbergh, Namco System 246/3xx, Gaelco, ...) their own
slugs with verified provider IDs. Providers without a dedicated entry fall
back to their Arcade platform via arcade_fallbacks(). MAME-only boards
(CPS1-3, System 16/32, Model 1, Namco 22) stay aliases of arcade.
Refs #5272
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(platforms): code-review pass on arcade slugs
- Retry IGDB on unmatched scans for every platform IGDB resolves, not
just slugs in IGDB_PLATFORM_LIST.
- Resolve config binding/version values through the alias table, so a
binding to a retired slug (cps2, model1, ...) still lands on a platform.
- Alias the Batocera `typex` folder to type-x.
- Build provider id->slug reverse maps before merging Arcade fallbacks.
- Share one MAME title lookup between base_handler and libretro.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* refactor(platforms): simplify pass on arcade slugs
- Alias the three RomM-keyed IGDB versions inside IGDB_PLATFORM_VERSIONS,
dropping IGDB_VERSION_SLUGS and _version_slug.
- Derive EmulatorJS arcade entries from ARCADE_SET_PLATFORMS.
- Remove the unused provider id->slug reverse maps, so the Arcade
fallback merge no longer has an ordering constraint.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs(platforms): humanizer pass on arcade slug comments
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(platforms): settle arcade slug review decisions
- Migration 0154 moves platforms still on a retired MAME-only board slug
(cps1-3, model1, system16, system32, system-32) to arcade, so no row
carries a slug the enum no longer has.
- MAME shortname expansion keys off the RomM slug via
MAME_SHORTNAME_PLATFORMS instead of per-provider arcade ids, so Daphne,
Singe, Type X and Lindbergh sets are no longer read as MAME sets. Neo Geo
now expands at ScreenScraper too, as it already did at IGDB and Moby.
- fba offers fbneo before the FinalBurn Alpha CPS cores.
- AdvanceMAME leaves the WebRcade feed; EmulatorJS and WebRcade share
PLAYABLE_ARCADE_SET_PLATFORMS.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(platforms): code-review pass (xhigh) on arcade slugs
Verify arcade-board BIOS files against the known list's arcade entries,
and make migration 0154 match retired slugs case-insensitively.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* refactor(platforms): simplify pass on arcade slugs
Apply IGDB family overrides once in get_platform instead of on each
return path.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(platforms): use a slug with no shipped icon
singe now ships an icon, so the no-icon prefetch test needs a slug that never will.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* feat(platforms): add a teknoparrot arcade slug
TeknoParrot runs PC-based arcade boards outside the MAME/FinalBurn family,
so its folder gets its own platform (RetroBat and ES-DE both use
`teknoparrot`). Providers fall back to their Arcade entry, MAME shortname
expansion skips it, and it gets a placeholder icon copied from `arcade`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* feat(platforms): give each arcade-family icon its own marquee title
Redraws the ARCADE marquee on the copied cabinet icons with each
platform's name, in the Bungee typeface with the original inline and
extrusion styling. Sega boards use Sega blue, Namco systems Namco red,
and Type X Taito blue; the rest keep the original amber.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(platforms): code-review pass (xhigh) on arcade slugs
Neo Geo BIOS lives under arcade in the known BIOS list, so map
neogeoaes and neogeomvs there too.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* refactor(platforms): simplify pass on arcade slug tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Georges-Antoine Assi <contact@me.gantoine.com>
* fix(streaming): let a container's broker_secret override STREAMING_BROKER_SECRET
STREAMING_BROKER_SECRET replaced every container's broker_secret, so a pool
of containers with different BROKER_SECRETs could not authenticate: each
broker after the first answered 403 "bad broker secret". A container's own
broker_secret now wins, and the env var is the fallback for containers that
set none. A blank broker_secret also falls back instead of becoming the
literal secret "None".
* test(streaming): cover a blank broker_secret with no env secret
Addresses Greptile review on #5259: the fallback cases all set the env
secret, so none pinned that YAML null no longer becomes the secret "None".
* Update examples/config.example.yml
---------
Co-authored-by: Georges-Antoine Assi <3247106+gantoine@users.noreply.github.com>
The reaper test now reads HOLD_CEILING_SECONDS from handler.streaming.config,
where it is defined. Merges the duplicate handler.auth.base_handler imports
the rewrite left in two test files, and shortens the comments on the hold
ceiling, the LaunchBox spec and the registry module.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gh1SRMfuK7BZmf6YxMqSyT
The registry imported every task module to read each task's title,
schedule, queue and timeout, so `rq cron` and every RQ worker parent
loaded the whole app. Task metadata now lives in the registry as
`TaskSpec`s with a dotted path to the implementation, which `get_task`
imports only when a job runs. Cron, the tasks API, enqueueing and the
worker's failure reporting read specs only.
Every log line also imported handler.metadata.base_handler, and with
it every metadata provider, for the redaction regex. The sensitive keys
and their regex now live in logger.formatter.
A test pins that importing the cron config or the worker class loads
neither handler.database, the auth handlers nor fastapi.
Measured RSS at LOGLEVEL=INFO, master -> this branch:
- rq cron: 164 MB -> 72 MB
- idle RQ worker (x3): 133 MB -> 68 MB
- gunicorn web worker: 214 MB -> 206 MB
Each job's work horse now imports its task module itself, 0.1-0.5s
more per job on an x86 host.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gh1SRMfuK7BZmf6YxMqSyT
- A label longer than the request limit no longer becomes a container's
name, so every published name is one the desktop endpoint accepts. The
limit moves to handler.streaming.config as CONTAINER_NAME_MAX_LENGTH.
- A label equal to another container's key in any case no longer names
its container, matching the case-insensitive lookup.
- An oversized broker manifest now fails the import build instead of
being dropped, which lost the state typing of the base's entries.
- A broker error body is read against a 5 second deadline, like every
other broker read.
- Type the _labelled test helper.
- config: one _keys_by_label grouping serves both the unique-label map
and the shared-label warning.
- claim_session: one abort-and-raise for either refused pick; the
newest-save lookup is a single conditional expression.
- launch: pick refusal fields off one optional ImportRefusedError.
- imports: skip_state is always true for a foreign save archive; drop an
unreachable KeyError and the unused str form of _read_member.
- webstation: ImportSpec.state_channel is a Literal.
- Stream.vue: the 400 refusal hint folds into the generic server branch;
pickableStates drops a guard nativeStreamStates already has.
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>
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 config endpoint re-derived the key filter and case-insensitive platform grouping that the pool helpers own, so the Play button row and the claim could drift apart. It now reads the first container of each platform's first pool from the same helper.
The labels map covers the ids a surface is handed rather than resolves,
and a save written under RetroArch carries "retroarch". With no entry
the asset chip showed the bare id.
Play! served PS2 sessions under the raw id "play", since it was missing from
the emulator display names, and the save and state chips showed whatever id
the broker recorded because the names never reached the frontend.
/config now ships the display names, and the chips and core group heads label
an id through them, falling back to the id for one the backend does not name.
/config listed containers with no key, so a platform whose only container is
misconfigured showed a Play button that could never stream, and it listed a
platform twice when two records spelled it in different case.
configured_emulator read the first record in the file rather than the first
member of the platform's pool, so the slot ceilings a save or load is checked
against could come from an emulator no claim ever reaches.
A platform's containers are now grouped into pools of interchangeable
members (same emulator, memory card sync, save picker and protocol), so a
lone container is a pool of one instead of a skipped non-member. Game claims,
status, heartbeats and joins still walk only the first pool, which matches
the containers they reached before.
The "not a pool member" warning fired on every lookup, one container at a
time. It now fires once per config and names every container a game claim
can never reach. Named lookups (desktop, admin release, named heartbeat)
already reach a container in any pool.
A named container is a one-entry candidate list, so the heartbeat has one lookup
and one status answer instead of a closure branching on the key, and it no longer
reads the session twice. The desktop view beats through the store wrapper, and
configured_emulator shares the platform match.
entry_for_platform backs both container_for_session and
resolve_named_container, and the fleet row's state line is assembled in
sessionState instead of split across template blocks.
Two legacy broker containers serving the same emulator stopped pooling when
one carried a clears_stale_saves the resolver had just logged as having no
effect. Comparing supports_save_picker folds in the webstation gate, so it
is the same test for a webstation pair and inert for the rest.
The save picker was gated on a hardcoded set of emulators mirroring the
webstation broker's `clears_stale_saves`, a value that lives in another
repo. A broker release that turns it on for a new emulator needed a RomM
code change before the picker appeared, and an operator on a fork or a
newer broker could not turn it on at all. The other direction was worse
because it was silent: if the broker stopped clearing, the pick still
validated, the archive still uploaded, and the container's own newer
files overwrote it with no error anywhere.
`clears_stale_saves` now joins `memory_card_sync` in
PLATFORM_OVERRIDE_KEYS, resolved per container in `_resolve_one`, which
leaves the emulator table as the default rather than the authority. It
also joins the pool-interchangeability check, since the picker is
advertised from the head of the pool and a member that keeps its own
files would take the pick and discard it.
Cut the docstrings and comments this branch added down to the one non-obvious
fact each, in the resolver and in the tests alike, and rename the new helper to
_claimable_broker_host so it says what it returns next to _derive_broker_host.
Move the three ways a raw entry fails to resolve into one helper with a guard
clause each, so none of them has to unset a broker host a sibling branch set.
The subfolder match moves onto WebstationProtocol, next to the normalization it
has to agree with, and interchangeable_with compares protocol names, the
discriminator the record already uses elsewhere.
The holder gate added with the pool ran before the stale-takeover walk, so a
player whose tab crashed was refused their own container until its TTL lapsed.
Block only on a live holder, and when the holder's own session is stale narrow
the candidates to that container so the existing takeover path reclaims it.
Also widen the proxy path check to compare the host's URL path, so a container
on another origin mounted at a path that disagrees with its subfolder is
refused the same way a bare path already was.
A same-origin entry sends the browser to `host`, but activate answers with
the room URL the broker built from its own SUBFOLDER, and that is an
absolute path, so urljoin lets it replace the path `host` carries. The two
values are therefore not independent: both have to be the container's own
SUBFOLDER.
Get them wrong and nothing complains. A container mounted at /streaming-2
while declaring /streaming resolves, claims its own key, and hands the
player a URL the proxy routes to whoever owns /streaming: a different
container, mid-session, with no trace of it in either log. The likeliest
way in is a second pool member proxied at its own path with `subfolder`
left to its default.
Resolve the entry, log it, and clear broker_host so it cannot be claimed,
matching how the other unusable configurations are handled. It stays in
the fleet view, where the operator can see what is wrong with it. A full
URL `host` is untouched; it carries an origin of its own for that absolute
path to land on, so there the two are free to differ.
interchangeable_with() compared protocol by instance identity, and
WebstationProtocol is interned per exact subfolder — so two containers
proxied at different subfolders, the normal way to run a same-origin
pool, were never recognized as pool members. Compare by type instead;
capabilities are class-level constants, so type equality is what
"same shape" actually means.
review-polish pass over the save-picker change.
The comments explaining why an older pick only lands where the broker clears
the save tree said the same thing in four places, so each one now carries only
what its own reader cannot get from the code. The save fixture in the launch
screen test becomes a typed factory, which the emulator-scoping case it did not
cover yet now uses.
Containers whose broker clears the save tree before restoring can land an
archive older than the container's own files, so offer the pick there and
validate it at claim time.
A broker's launch, join and desktop replies name the URL the browser loads
in an iframe, and urljoin keeps an absolute (or `javascript:`) URL verbatim,
so a container that answered with one could run script in RomM's origin
instead of its own. The three sites now share one resolver that drops a room
URL leaving the configured host, the stage refuses a source that is not
http(s), and the frame is sandboxed without allow-top-navigation so a
container page cannot steer the tab it sits in.
Also drop the shared secret from the config entry a resolution warning
prints, which named the misconfigured container by dumping it whole.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Session ownership and lifecycle, mostly around who a teardown belongs to:
- file the exit state, save states and state frames under the session's
owner rather than the caller, so an admin driving someone else's session
no longer collects their saves
- beat the heartbeat from the admin desktop view, which the stale sweep was
tearing down three minutes in
- take the claim through release_own_session when a launch aborts, instead
of deleting a key another player may already hold
- require the same claim to stamp a launch, so a late activate cannot revive
a drain marker with a six hour TTL
- pull the in-game save archive on every teardown path, not just the two
that remembered to
- skip draining keys in the admin force-release sweep
Plus: pool members must share a protocol, since the head's capabilities are
what the frontend renders; a claim clears terminations across the whole pool;
multiplayer is only recorded where the broker can actually seat a joiner; and
an unserializable config no longer caches forever on a repr() that repeats.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
- The five new modules each defined `log = logging.getLogger("romm")`, which is
what `logger.logger` already exports; they import it now.
- `ACK_TIMEOUT` had two homes. It is a protocol fact, so `protocol.py` owns it
and the endpoint imports it from there; the unused
`BROKER_LOAD_STATE_TIMEOUT` copy goes.
- Module and function docstrings trimmed to what the code cannot say: the
change history and the justifications belong in the commit messages they came
from.
- `asset_store` takes the union `write_file` accepts rather than `Any`.
- Four hand-rolled `setInterval` pairs (presence beat, session poll, exit
chord, live sessions, activity tick) become `useIntervalFn`, which also
cleared a real gap: the presence composable's timer had no scope teardown.
- The launch pushes are matched on the container the claim's 202 named, not on
the platform: a pool serves one platform from more than one container, so a
second tab could otherwise act on the first's launch.
- Test helpers typed: the push capture and the resume-claim tuple carry real
types, and an unused `_claim_ready` helper goes.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Two shapes of streaming broker were branched on at 19 call sites, and every
consumer re-derived a container's host, key, emulator, capabilities and card
sync from the raw YAML on each call. `_containers_for_platform` re-ran host
parsing and the operator's misconfiguration warnings on every request, and
`_container_label` re-read config.yml once per listed row.
`handler/streaming/`:
- `protocol.py` gives each broker shape a class owning its route prefixes,
timeouts, response dialect, stream-URL assembly and capability flags. A call
site now asks `protocol.supports_disc_swap` or `protocol.save_state_accepted`
instead of re-testing `protocol: webstation`. Instances are interned per
subfolder so identical configs share one object.
- `capabilities.py` holds the per-platform and per-emulator slot tables and the
state transfer limits, keyed purely by platform and emulator.
- `config.py` turns the raw list into frozen `ResolvedContainer` records with
every question already answered, memoized until the config changes, so the
warnings fire once per config rather than once per lookup. A container RomM
cannot dial still resolves, with an empty key: unclaimable, but visible in
the admin fleet view where the operator can see why.
`endpoints/streaming.py` drops ~700 lines and takes records rather than dicts
throughout; `container.emulator` and `container.protocol.session_route(...)`
replace the derivations that used to run per call.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>