Loads every model before a job resolves its task, so the mappers
configure in a work horse that imported a single task module. Moves the
httpx2 import into RemoteFilePullTask.run, builds the push-pull job meta
from its spec, gates the scheduled scan on its spec, and widens the
loaded-modules test to cover task modules and httpx2.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.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
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
Adds ENABLE_SCHEDULED_CLEANUP_ZIP_CACHE, SCHEDULED_CLEANUP_ZIP_CACHE_CRON,
ENABLE_SCHEDULED_CLEANUP_SYNC_SESSIONS and SCHEDULED_CLEANUP_SYNC_SESSIONS_CRON,
defaulting to the previous hardcoded behavior.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
rq only parses the cron when the scheduler loads it, then logs and drops
the job while cron_config had already logged it as scheduled. Validate it
up front and log an error instead. croniter was a transitive rq dependency
and is now declared directly, with its typeshed stubs for mypy.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
GET /api/play-sessions no longer narrows to the token's device when
device_id is omitted, so the all_devices flag is dropped. Reading anything
beyond the token's own device now requires devices.read, matching the
saves and device endpoints. GET /api/sync/sessions takes the shared
PageParams and gains offset paging.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Reuse the shared PageParams for limit/offset, build device tokens through
tests.factories.make_device_token (the add_device_token fixture is gone on
master), and flatten the effective device_id expression.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Bound limit/offset at 0 so negative paging returns 422 instead of a 500,
use the Annotated Query style for all_devices, clarify that the flag only
affects device-bound tokens, and cover the omitted-flag default.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(backend): build test ROMs through one make_rom factory
Tests created Rom rows by hand in dozens of places, each spelling out the
same slug and filename fields and deriving the slug inline. Production never
computes a slug from a name, so this was test-only filler duplicated across
files.
tests/factories.py adds make_rom(platform, name, *, fs_stem, fs_extension,
**overrides), which fills the slug and filename columns and persists through
db_rom_handler.add_rom. The shared conftest fixtures, scan_stubs.add_rom and
the local helpers and inline constructors across 35 test files now use it.
Each test keeps its filename shape (underscored stems in the FULLTEXT search
tests, spaced "Name (USA)" stems in the sibling tests), and fixtures shared
across files keep their exact slugs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(backend): keep extensionless filenames intact in scan_stubs.add_rom
rpartition(".") on a name with no dot returned an empty stem and the whole
name as the extension, so make_rom stored ".README" for "README".
os.path.splitext leaves such names whole.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(backend): build test saves, states and screenshots through factories
Tests built Save, State and Screenshot rows by hand across about 20 files,
each spelling out file_name_no_tags, file_name_no_ext and file_extension
although BaseAsset already derives them from file_name.
tests/factories.py adds make_save, make_state and make_screenshot. Each sets
the rom and user ids, the file name, and a default file_path under the rom's
platform, applies overrides last, and persists through the matching db
handler. The conftest asset fixtures and the persisted constructors and local
helpers now use them. Rows a test observes keep their file_path, emulator,
slot, size and hash, and a filename part stays an override wherever it
differs from what the model derives.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(backend): ban direct add_* persistence in tests via ruff TID251
The factories only stay the one home for test rows if nothing routes
around them. Ruff's banned-api rule now flags db_rom_handler.add_rom,
db_save_handler.add_save, db_state_handler.add_state and
db_screenshot_handler.add_screenshot anywhere under tests/ except
tests/factories.py. Production code is unaffected.
The remaining add_rom calls move onto make_rom: the unique-path, soundtrack
and id-index tests in test_roms_handler.py, the scan tests in
test_fastapi.py, physical and missing rows in the feed, download and model
tests, and the name=None exporter rows. Scan tests keep a filename-derived
placeholder as the name, which scan_rom treats the same as no name. Three
calls keep a noqa: the tests of how add_rom merges a partial scanned row,
and the rescan test that persists scan_rom's output as a scan does.
The backend skill and the architecture doc now point at tests/factories.py.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(backend): move the firmware and client-token factories into tests/factories.py
The add_firmware and add_device_token conftest fixtures returned a builder,
unlike the importable make_* functions. They become make_firmware and
make_device_token alongside them, with the same defaults, and their callers
import them rather than requesting a fixture. make_device_token now draws the
raw credential from auth_handler.generate_client_token, so it carries the
real rmm_ prefix instead of restating it, and the hand-built client tokens in
the auth tests use it too.
The ruff TID251 ban now also covers db_firmware_handler.add_firmware and
db_client_token_handler.add_token under tests/.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs: point at every test factory, not just the ROM and asset ones
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Search the gallery by providers' alternative titles
A search for "FF9" or "Final Fantasy 9" did not find "Final Fantasy IX":
the gallery search only matched roms.name and roms.fs_name, while the
alternative titles IGDB, MobyGames and ScreenScraper report lived in the
raw metadata blobs where no index reaches.
Add generated_search_aliases, a STORED generated column the engine fills
from those blobs, so every write path (scans, metadata refreshes, the
bulk update_rom, raw metadata edits) keeps it current with no backfill.
Migration 0145 rebuilds the MariaDB/MySQL FULLTEXT index over
(name, fs_name, aliases) and adds a pg_trgm GIN index on PostgreSQL, and
the search matches the column on both paths.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A62FTdVyav4wK5Nkj55MGy
* Compare the alias JSON type under the table's collation
On a utf8mb3_unicode_ci table, JSON_TYPE's result and the 'ARRAY'
literal carry different collations, so creating the generated column
failed with an illegal mix. CAST re-derives it, as _maria_text does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A62FTdVyav4wK5Nkj55MGy
* pr-ready step 2 (code-review): defer the alias column, share search columns
Loading a ROM no longer fetches generated_search_aliases, which only the
gallery search reads. The FULLTEXT match and the ILIKE fallback both take
their columns from one ROM_SEARCH_COLUMNS tuple.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A62FTdVyav4wK5Nkj55MGy
* pr-ready step 3 (simplify): register the search indexes, share the CAST
Both search indexes join the generated-column index registry, so any
later rebuild of the alias column puts them back instead of leaving
MariaDB's FULLTEXT index narrowed (and every MATCH failing) or the
PostgreSQL trgm index gone. 0145 shrinks to ensure_roms_columns plus
retiring 0084's index, and its downgrade guards DROP COLUMN with
has_column, since MySQL has no DROP COLUMN IF EXISTS.
_maria_char carries the collation CAST that _maria_text and the alias
expression share, the alias expression extracts each array twice
instead of three times, and the dialect test runs the handler's own
_fulltext_match.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A62FTdVyav4wK5Nkj55MGy
* Store the search aliases as plain titles
The alias column held each provider's array as JSON text, so a short
ILIKE search for '"', ',' or '[' matched every ROM with any alias. Both
engines print an array as ["a", "b"] however it was stored, so the
expression strips the brackets and quotes and keeps the titles
separated by spaces, which search terms can never match on their own.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A62FTdVyav4wK5Nkj55MGy
* Shorten the alias-search docstrings to one sentence
The migration and test-module docstrings explained the design in
several paragraphs; AGENTS.md asks for one sentence. The design notes
live in the PR description.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A62FTdVyav4wK5Nkj55MGy
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Georges-Antoine Assi <contact@me.gantoine.com>
* Hide the game Achievements tab when the ROM has no achievements
The v2 game page listed an Achievements tab with a 0/0 badge on every
ROM, including ones with no RetroAchievements match and RA games without
an achievement set. Offer the tab only when the ROM has achievements.
A ?tab=achievements the ROM has no tab for now opens the overview. The
query stays in the URL, so stepping on with prev/next to a ROM that has
achievements opens its tab again.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QdE1MDoDitrZZgZ7PQ3s1Z
* Type the achievement fixture, cover stepping between ROMs
Build the test achievement as a complete RAGameRomAchievement instead
of casting a partial object, add a test that ?tab=achievements reopens
the Achievements panel once the route moves on to a ROM with a set, and
drop a comment that restated the length check.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QdE1MDoDitrZZgZ7PQ3s1Z
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Match RetroAchievements by RA hash only, never by Hasheous' game ID
Hasheous links an RA game to a whole Hasheous game record, so every dump
grouped under it (other revisions, regions, bad dumps) got that RA ID and
its achievements, even when RA doesn't list the dump's hash as compatible.
It also bypassed RomM's own RA hash lookup and reached the priority merge
when RA was deselected or ranked below Hasheous.
Stop reading the RetroAchievements ID from the Hasheous lookup, drop the
unused RA proxy fetch (its response was discarded), and have fetch_ra_rom
always go through RA's hash list. Existing wrong matches clear on a
Complete rescan.
Fixes#4959
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QdE1MDoDitrZZgZ7PQ3s1Z
* pr-ready step 2 (code-review): cover stale and deselected-RA matches, fix stale copy
Parametrize the Banjo-Kazooie regression test over RA selected and
deselected, starting from a stale Hasheous ra_id, so it pins both the
Complete-rescan clear and the priority-merge leak. Move the RA comment
onto the hash-lookup branch, drop a merge get_igdb_game already does,
and stop the Hasheous provider description claiming it supplies
RetroAchievements IDs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QdE1MDoDitrZZgZ7PQ3s1Z
* pr-ready step 3 (simplify): reuse scan stubs in the Hasheous RA test
Build the Banjo-Kazooie platform, ROM and top-level file with the shared
add_n64_platform/add_rom/_top_level_rom_file helpers, state the expected
RA lookup as a parameter instead of branching on it, and drop a comment
that described the removed Hasheous path.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QdE1MDoDitrZZgZ7PQ3s1Z
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
typescript-eslint moves to 8.70.1, the first release in the npm age
window whose peer range (<6.1.0) admits TypeScript 6. TypeScript 6
enables noUncheckedSideEffectImports by default, so the vuetify/styles
CSS import gets an ambient module declaration.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Select/autocomplete/combobox item, selection and chip slots now pass the
raw item as `item`, so drop the `.raw`/`.title` unwrapping. VDateInput
graduated out of labs, and theme colors are typed as Color.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
TypeScript 7's npm package exports no compiler API, so vue-tsc crashes
(ERR_PACKAGE_PATH_NOT_EXPORTED './lib/tsc') and typescript-eslint 8.71.0
caps its peer range at <6.1.0. Supersedes #4926.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>