* chore(seeder): fill IGDB and ScreenScraper metadata to real-world size
Seeded provider JSON was about half the size of a real library's, so
gallery benchmarks understated decode and payload cost. IGDB now carries
keywords, platforms, realistic alternative names and always ten similar
games; ScreenScraper carries every media url and path key a match stores.
List lengths follow percentiles measured on a 9,172-game library.
New values draw from a per-game stream, so every other column, every
fill rate and the library shape match the previous seed exactly.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(seeder): wipe snapshots before the saves and states they hold
--wipe failed on any database with save-channel snapshots, because
snapshots reference saves and states with ON DELETE RESTRICT.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* chore(seeder): tighten comments to what the code shows
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(seeder): draw distinct keywords and test the snapshot wipe order
A keyword list now samples without replacement from a pool larger than the
longest measured list (213), so long lists keep their distinct values.
A test pins that snapshots are wiped before the saves and states they hold.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
* fix(seeder): apply code-review fixes to realistic metadata
Insert ROMs 100 rows per statement, seed the metadata stream from
provider and drawn facts so it follows --seed, fill search_titles and
min_age on Core-inserted rows, sample real distinct IGDB platforms, and
derive SS media kinds from SSMetadataMedia.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* refactor(seeder): simplify realistic metadata builders
Share the alias and similar-games builders between providers, pass rom
rows straight to compute_search_titles and compute_min_age, and name the
SS media kinds that carry a path. Output is unchanged for a given seed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs(seeder): humanizer pass on extra_rng comment
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(seeder): fill every scan key, match similar-game slugs, pin the main stream
Seeded IGDB and ScreenScraper metadata now carry every required key of
IGDBMetadata and SSMetadata (publishers, developers, themes, player
perspectives, rating count, physical disc), so the facet columns that
read them are populated. Similar-game slugs follow their names without
shifting the main stream, and a test pins the main stream's position
after the builders so a draw moved onto it fails loudly.
compute_derived_columns in models/rom.py now derives search_titles and
min_age from a mapping, shared by the insert listener and the seeder.
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>
* feat(seed): realistic, fast, debuggable seeded images
generate_test_data.py can now seed a library whose images look like a real
one, quickly, so gallery, sizing and image-conversion work can be tested
without anyone's private cover art. The default (--image-fidelity 1) is
unchanged: same seed, byte-identical files.
- --image-fidelity 2: covers drawn at the real-world size mix (measured
aggregates from one 8,396-cover library), the small cover made by RomM's
own resize rule, and debug art on every image: the game's title, system
and region; a box with rom id, size, kind and format; the original path;
pure-colour corner pixels, named corners, percent ticks, crop boxes, a
circle that shows stretching and a transparency ring.
- --image-fidelity 3: the same over texture calibrated to real bytes per
pixel, with 22% of big.png holding JPEG bytes as in real libraries.
- --image-weighted-every N (default 10): at level 2, every Nth rom id is
drawn at level 3, so one library serves layout and file-size work.
- --image-media: also write ScreenScraper media (sizes provisional).
- --image-workers / --image-limit: images are drawn in a process pool
from a per-rom random stream (seed, rom id), identical to one process.
2,000 roms with images seed in about 18 s instead of about 10 minutes.
- After a real run the seeder rotates the gallery's Redis cache, so a
fresh seed never serves the previous library's lists.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(seed): keep rows independent of image flags; survive a cache failure
- The screenshot count is drawn for every rom, whatever --images or
--image-limit say, so those flags no longer shift the rows that follow
(--no-images rows were already off in the previous seeder). With the
defaults the draws are unchanged: level 1 output is still byte-identical.
- A Redis error while rotating the gallery cache prints a warning instead
of aborting after the rows are committed, so the report still prints.
- Comments in seed_images.py trimmed to the repository's one-or-two-line rule.
- tests/tools/test_generate_test_data.py runs the seeder with inserts
recorded instead of written: rows match with --image-limit and
--no-images, and a cache failure still reports the saved seed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs(seed): document seeding a test library in DEVELOPER_SETUP
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(seed): code-review fixes for seeded images
pr-ready step 2 (code-review xhigh --fix):
- level-3 noise is drawn per channel and retuned, so PNG output reaches
the measured 0.9 / 1.5 / 2.0 bytes per pixel spread
- --image-media is rejected at --image-fidelity 1, where it did nothing
- paths come from rom_fs_resources_path, get_media_resources_path,
CoverSize and MetadataMediaType instead of being rebuilt
- drop the unused path_column parameter and a no-op ImageChops call
- draw a batch's images while the next batch is built and inserted
- the cache-failure test checks the rows of the failing run
- drop a duplicate media-off test
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* refactor(seed): simplify pass over seeded images
pr-ready step 3 (simplify):
- extract small_cover_size from resize_cover_to_small, so the seeder
draws the small cover at RomM's size instead of writing, reopening
and overwriting it
- draw_rom_images returns nothing and follows plan_rom_images, and
files_written is derived from the plan
- _fitted_size measures from a proportional guess instead of stepping
down one point at a time (about a quarter of level-2 draw time)
- one draw path for the pool and inline cases
- drop the ink parameter, the CORNER_RING alias, the _fade_ring wrapper
and the RomImageJob caption default; tighten comments
- trim media from the two slowest tests and use dataclasses.replace
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs(seed): humanizer pass over the seeding docs
pr-ready step 5 (humanizer).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* refactor(seed): one image pipeline, dry runs write nothing, main owns its cleanup
- level 1 mosaics go through plan_rom_images/draw_rom_images like the
other levels, so they get media, workers and RomM's small-cover size
- --dry-run plans image paths but writes no files
- main() is a thin wrapper: it registers the UTC connect listener and
removes it (disposing the pool) in a finally, and the image pool
cancels queued draws on error; the test no longer patches SQLAlchemy
- the recommendation feed cache is rotated with the gallery cache
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>
Importing any handler.auth submodule ran the package __init__, which
built the auth handlers and so loaded authlib, joserfc and Socket.IO.
models.user imports handler.auth.constants, so every process that
touched the models paid for the whole auth stack. The handler
instances now live next to their classes in handler.auth.base_handler.
utils.context imported fastapi only for annotations; that import now
sits under TYPE_CHECKING.
An idle RQ worker drops from about 118 MB to 89 MB RSS. Each job's
forked work horse now imports a little more on its own, about 0.2s
on an x86 host.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gh1SRMfuK7BZmf6YxMqSyT
* 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>
`tools/generate_test_data.py` could not run at all. It imported
`UniversalPlatformSlug` from `handler.metadata.base_handler`, where the enum
no longer lives, and it built `Rom` rows without `full_path_hash`, which is
NOT NULL, so the first insert of every run failed.
The import block's `isort: off` workaround went with the enum: it loaded the
metadata package before `adapters.services.igdb` to break a
`base_handler <-> igdb` cycle that no longer exists, since `base_handler` does
not import the igdb service. `adapters.services.igdb` can be imported first.
The digest comes from `compute_full_path_hash(fs_path, fs_name)`, the same call
the scanner writes with, computed from the row's own folder, so the seeded
library satisfies the unique index on `(platform_id, full_path_hash)`.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Folds the standalone soundtrack seeder into generate_test_data.py, where
the rest of the fake library is built: a share of roms (--soundtrack-share,
default 8%) now get tagged audio files plus their track_meta rows, so the
music endpoints and the jukebox have something to read.
Two pre-existing bugs in that script surfaced while verifying this, both
of which made it fail outright on MariaDB:
- bulk_insert used executemany, whose MariaDB bulk path silently drops all
but the first row when a column mixes NULL and non-NULL across the batch.
Every rom batch inserted one rom, and the rom_files insert then failed the
foreign key. Multi-VALUES statements per chunk keep the speed without it.
- with rows actually landing, the small title pools collide on the unique
(platform_id, fs_name) index, so repeats are now disambiguated.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The match flags on `hasheous_metadata` are keyed off Hasheous'
`SignatureSourceType` names, and two never lined up with what its API
actually returns:
* `MAMERedump`, the source holding Redump's disc images in CHD form, was
mapped to nothing at all. A CHD identified by its disc-data SHA1 matched,
got its metadata, and still read as unverified because no flag was set.
* `puredos_match` looked for `PureDOS`; the source is named `PureDOSDAT`, so
the flag was pinned to False for every ROM.
CHD matches now set `mame_redump_match`, which the verified filter counts and
which the Metadata tab folds into the existing Redump chip (same database,
different distribution format). Existing rows pick the flag up on their next
rescan.
Hasheous also exposes Pleasuredome, TotalDOSCollection, eXo, ScreenScraper and
Generic sources that RomM still maps to nothing; those are left alone since
folding them in widens what "verified" means.
Fixes#4030
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Building the filter dropdowns aggregated the facet columns straight off
`roms`. Those columns are cheap to compute since #3826, but they sit inline
with the raw provider-metadata blobs, so the aggregation read every row of a
multi-gigabyte table: seconds of pure disk reading on any database whose
buffer pool is smaller than the table (the stock 128-256 MB defaults always
are on a large library).
`roms_facets` holds only the filter values and is kept in sync by AFTER
INSERT/UPDATE triggers on `roms`, so every write path stays consistent
without an application hook. Deletes ride the ON DELETE CASCADE foreign key.
Fixes#3882
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
RomM stores soundtracks but exposes no way to consume them as a music library: a
client has to enumerate ROMs and pull each one's tracks individually, and the
per-track metadata lives in the `rom_files.audio_meta` JSON blob, which is
unindexable on MariaDB, so any library-wide filter or sort degrades to a full
scan.
This adds a queryable, music-first API for soundtracks, backed by a typed and
indexed `track_meta` table migrated from that JSON.
It also lets users upload soundtracks, manuals, and screenshots to any ROM, not
only folder-based ones. When the target is a single-file ROM, the client warns
that the upload will migrate it to a multi-file (folder) structure, then performs
that migration in place automatically.
Collapse the Role enum from viewer/editor/admin to two kinds (admin/user);
non-admin access now comes entirely from permission groups + overrides.
Backend:
- Role -> StrEnum {USER, ADMIN}, VARCHAR-backed (native_enum=False); Role.coerce
maps legacy/unknown strings (incl. in-flight invites) to USER.
- Resolver: group-less users fall back to the default group (dropped the
role-based legacy fallback); kiosk caps all non-admins to read-only.
- OIDC editor/viewer claims both map to USER (env var names unchanged).
- Migration 0092 converts the native enum to VARCHAR and normalizes
ADMIN->admin, VIEWER/EDITOR->user.
- Updated endpoints, conftest fixtures, role/oidc/parity/db-handler tests, tools.
Frontend:
- v2 + v1 user management now use admin/user (dropdowns, defaults, getRoleIcon).
- Regenerated types (Role = 'user' | 'admin'); added role-user i18n to all locales.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The char index and rom id index sidecars are cached under a key that
encodes only user/order/grouping. is_unscoped previously excluded only
scope and search, so metadata/tag/status filters and the bool flags
applied to the query bypassed the gate: a filtered all-games request
stored a narrowed id list under the shared "all" key and later
unfiltered (or differently-filtered) requests read it back, showing the
wrong set and count of games.
Treat any narrowing parameter as scoped so those sets compute live.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Relocate generate_test_data.py (from backend/scripts) and
generate_supported_platforms.py (from backend/utils) into backend/tools,
alongside the existing xml_diagnostics.py. Update their run-command
references and document backend/tools in CLAUDE.md.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>