Commit Graph

5456 Commits

Author SHA1 Message Date
Sam Dornan
0a25b384fd fix(auth): hash passwords with bcrypt directly and upgrade to bcrypt 5 (#4916) 2026-09-30 10:51:32 -04:00
Sam Dornan
6226e50dbe fix: serialize single-file ROM promotion across gunicorn workers (#4898) 2026-09-29 22:39:47 -04:00
Sam Dornan
54bec6ed48 fix(scan): reuse unchanged empty files on quick scan (#4949)
* fix(scan): reuse unchanged empty files on quick scan

An empty file hashes to the default digest, which _make_file_hash stores
as a blank md5. rom_file_unchanged required a non-blank md5 on hashable
platforms, so an empty top-level file in a folder ROM (for example an
MSU-1 .msu) never counted as unchanged. The whole folder was re-hashed
and the ROM re-emitted on every quick scan, pushing it to the front of
Recently added.

Treat a zero-byte file as already hashed. Stored hashes stay blank so the
empty-input digest never feeds hash-based metadata matching.

Fixes #4933

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Mre6qcBuXvGJzBJjJfkDvy

* docs(scan): name _make_file_hash as the source of blank empty-file hashes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Mre6qcBuXvGJzBJjJfkDvy

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 12:56:01 -05:00
Sam Dornan
4cbf43acab perf(gamelist): validate media tag paths once per directory (#4943)
* perf(gamelist): validate media tag paths once per directory

A full-platform gamelist parse ran validate_path on every media tag,
about a dozen lstat calls each, which added up to tens of seconds per
platform on NFS/SMB mounts.

FSHandler.cached_path_validator returns a validate_path equivalent that
runs the lexical checks per call but hits the disk once per distinct
parent directory. The leaf needs no syscall: validate_path accepts a
symlinked leaf, and a plain one resolves inside its checked directory.
The gamelist parse builds one per pass and threads it to the media tag
and directory-entry checks.

On a 1,500-entry gamelist with six media tags per entry, lstat calls
drop from 108,140 to 200.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U5CmSdodtG5s2MiH9y65LE

* test(gamelist): pin one validate_path call per media folder

Condense cached_path_validator's docstring to one sentence, and assert
the exact per-folder call counts in the gamelist parse test, with the
media index stubbed so only the parse's own validation is counted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U5CmSdodtG5s2MiH9y65LE

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 10:15:14 -05:00
Sam Dornan
7c8778cc77 perf(scan): read only the selected ROMs' gamelist entries (#4940)
* perf(scan): read only the selected ROMs' gamelist entries

A scan of hand-picked ROMs warmed the gamelist cache by parsing the
platform's whole gamelist.xml. Every media tag of every entry goes
through validate_path, which stats each path component, so a 1,500
entry gamelist costs ~160k lstat calls. On a network mount that stalled
a one-ROM rescan for ~45 seconds before hashing started.

populate_cache now takes the file names to limit the parse to, and the
cache records that scope so a lookup outside it (a ROM renamed mid-scan,
or an overlapping library scan) still parses the full file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KakznhQRBWTSARmmsYLXHQ

* perf(scan): widen a limited gamelist cache instead of reparsing it all

A selected ROM renamed mid-scan (Switch title-ID embedding) is looked up
under a name outside the cache's scope, which fell back to a full parse
and brought the stall back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KakznhQRBWTSARmmsYLXHQ

* perf(scan): widen a limited gamelist cache by the missing names only

Each widening re-resolved every name already cached, so a batch of
Switch ROMs renamed mid-scan cost quadratic media resolution. Only the
names the cache lacks are read now, merged into the cached entries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KakznhQRBWTSARmmsYLXHQ

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 09:22:55 -05:00
Georges-Antoine Assi
8b7a6464fb fix(auth): address Greptile review on OIDC identity matching
- Match on (issuer, sub) with exact collation, so subjects from another
  provider or differing only in case never match.
- Refuse a login whose email is linked to another subject at the same
  issuer instead of rebinding the account; relink only across issuers.
- Check the account is enabled before saving identity changes.
- Keep the old email when it is claimed between the check and the write.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 17:34:14 -04:00
Georges-Antoine Assi
9d4bb40a6d fix(auth): match OIDC users by their sub claim so an email change still logs in
Store the provider's `sub` on a new nullable users.oidc_sub column, look users
up by it first and fall back to email, backfilling the sub on the next login. A
user matched by sub gets their stored email updated, unless another account
already holds it.

Fixes #1690

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 17:34:14 -04:00
Georges-Antoine Assi
de0eff320c test(auth): narrow userinfo before indexing it
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 17:34:13 -04:00
Georges-Antoine Assi
b69207cc66 fix(oidc): address Greptile review on the UserInfo fallback
Keep email_verified tied to the email it came with, and fall back to the
ID token claims when provider discovery fails as well.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 17:34:13 -04:00
Georges-Antoine Assi
83bd57a5d1 fix(oidc): fetch claims missing from the ID token from the UserInfo endpoint
Providers like Authelia follow OIDC Core 5.4 and return scope claims
(email, preferred_username, groups) only from the UserInfo endpoint.
When any claim RomM reads is absent from the ID token, fetch UserInfo
with the access token, check that its sub matches, and merge it under
the ID token claims.

Fixes #1927

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 17:34:13 -04:00
Georges-Antoine Assi
8a0c6dc7e4 Merge pull request #4891 from rommapp/fix/oidc-ca-bundle-1589
fix(auth): trust OIDC_TLS_CACERTFILE alongside the default CAs
2026-09-28 17:18:44 -04:00
Georges-Antoine Assi
8d7566e567 fix(auth): address Greptile review on OIDC CA bundle loading
Skip CA files that can't be read instead of failing startup, type the
PKI test fixture, and declare certifi as a direct dependency.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 16:53:03 -04:00
Sam Dornan
33c10f5d6c Run the chroma-key placeholder check off the event loop (#4899)
* Run the chroma-key placeholder check off the event loop

_discard_if_chroma_key decoded every stored media image synchronously
inside an async method, so each check (about 15 to 35 ms for a 1024px
screenshot or box face) stalled the event loop and every other request or
scan task running on it. The decode now runs through asyncio.to_thread,
like the cover and logo work in the same handler.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vP3HFKWQsJZv9F9SKeAWu

* Hold the file lock across the chroma-key check and delete

With the check awaited on a worker thread, a concurrent writer could
replace the file between the verdict and the delete, and the replacement
was then removed on the old file's verdict. The existence check, the
decode and the unlink now run under the path's lock, and a test replaces
the file mid-check to prove the new artwork survives.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vP3HFKWQsJZv9F9SKeAWu

* Make the chroma-key replacement test independent of timing

The test slept 0.2s and hoped the writer had run by then; a slow writer
would let unlocked code pass. It now asserts the path lock is held during
the check before the writer starts, and that the writer cannot finish
while the check runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vP3HFKWQsJZv9F9SKeAWu

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 15:36:14 -05:00
Sam Dornan
6d9438b456 Add an opt-in setting to show the game logo in place of the title on the v2 game page (#4888)
* Show the scraped game logo in place of the title on the v2 game page

When a ROM has a ScreenScraper wheel (ss_metadata.logo_path), the details
header renders it inside the h1, with the game name as alt text, and falls
back to the text title when there is no logo or it fails to load.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vP3HFKWQsJZv9F9SKeAWu

* Trim the transparent border off stored game logos

ScreenScraper wheels often sit on a padded 1024x512 canvas, so a logo shown
in place of the game title looked indented and smaller than its neighbours.
store_metadata_media now crops each logo to its visible pixels, including
logos already on disk, so a rescan fixes existing libraries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vP3HFKWQsJZv9F9SKeAWu

* Put the logo-as-title display behind a UI setting, off by default

Adds a showLogoTitle entry to useUISettings (synced to the user's
ui_settings like the other display preferences) and a 'Show logo as
title' toggle in the Gallery section of the User Interface settings, with
the new strings translated in every locale. GameHeader shows the logo only
when the setting is on. Also clears the existing em-dashes from
UserInterface.vue comments, which the lint rule flags once the file changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vP3HFKWQsJZv9F9SKeAWu

* Outline the title logo so dark or light lettering stays readable

Some ScreenScraper wheels carry thin black text (A Link to the Past's
subtitle) that vanished on the dark theme, and white lettering has the same
problem on the light one. The logo now gets a 1px rim in the theme's text
colour, replacing the soft drop shadow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vP3HFKWQsJZv9F9SKeAWu

* Size the title logo by area so square logos match wide ones

A shared 128px height cap left near-square wheels (A Link to the Past,
Aria of Sorrow) with about half the area of wide ones. Once the logo loads,
GameHeader now sets its width so every logo covers roughly the same area
(40,000 px, 22,000 on phones), within a 176px (120px) height cap and the
existing 420px width cap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vP3HFKWQsJZv9F9SKeAWu

* pr-ready step 2 (code-review): harden logo trimming and logo retry

- Share one IMAGE_DECODE_ERRORS tuple (adds SyntaxError and
  DecompressionBombError) across the image helpers, so a broken or
  oversized logo no longer aborts store_metadata_media.
- Trim under the per-file lock and replace the file atomically, so a failed
  save keeps the original and a hardlinked source is never cropped.
- Skip every multi-frame image, and crop in the image's own mode so palette
  logos stay compact.
- Reset the header's logo failure and ratio whenever the logo URL changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vP3HFKWQsJZv9F9SKeAWu

* pr-ready step 3 (simplify): share the resource URL helper, trim dead code

- Add versionedResourceUrl to v2/utils/romFiles and use it from GameHeader,
  romArtwork and ManualSubtab, so the scraped-media cache-bust rule has one
  home.
- Key the header's logo load state on the URL (failedSrc, loadedLogo)
  instead of resetting two refs from a watch; hoist the shared 420px cap.
- Drop logo CSS the inline sizing made dead (display, height, object-fit,
  object-position).
- Read the alpha bbox with getbbox instead of a full RGBA copy, and check
  transparency before counting frames.
- Use a handler fixture in TestTrimTransparentBorder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vP3HFKWQsJZv9F9SKeAWu

* pr-ready step 4 (review-polish): drop a filler comment

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vP3HFKWQsJZv9F9SKeAWu

* pr-ready step 5 (humanizer): state three comments directly

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vP3HFKWQsJZv9F9SKeAWu

* Bound logo trimming by pixel count and test phone logo sizing

- Skip trimming a logo above MAX_TRIM_PIXELS (16M), checked from the image
  header before any pixel is decoded, so a large download under Pillow's
  decompression-bomb threshold can't exhaust worker memory mid-scan.
- Cover the xs area and height cap in GameHeader's sizing tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vP3HFKWQsJZv9F9SKeAWu

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 15:01:30 -05:00
Sam Dornan
d344662eac Keep ScreenScraper disc art for every disc of a multi-disc game (#4885)
* Keep ScreenScraper disc art for every disc of a multi-disc game

ScreenScraper tags each disc's support-2D art with a "support" number,
but the extractor kept only the first support-2D it met, so discs 2 and
up were never downloaded or shown.

The first disc still fills physical_url/physical_path, which the cover
art, disc-spin animation and exporters read. Every later disc goes to a
new ss_metadata.physical_extra_discs list, is downloaded next to it as
physical/physical_disc<N>.png, and gets its own entry on the v2 Artwork
subtab.

Existing ROMs pick up the extra discs on their next metadata refresh.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018qtuXherdgoU89KtrSeU22

* Type the extra-disc test metadata so mypy can index it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018qtuXherdgoU89KtrSeU22

* Label the first disc's art on multi-disc games

ss_metadata now records which disc physical_url shows, so the Artwork
subtab can label it "Physical media (disc N)" alongside the later discs.
It stays plain "Physical media" for single-disc games, gamelist art, or
when no later disc's art is on disk.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018qtuXherdgoU89KtrSeU22

* pr-ready step 2 (code-review): harden disc numbers and rematch cleanup

- Read ScreenScraper's disc number with safe_int and clamp it to 1, so
  a zero, negative or non-string "support" value counts as the first disc.
- Remove the physical folder on an ss_id change when only later discs
  had art, so a rematch doesn't keep the old game's disc images.
- Collapse store_metadata_media's two result lists into one target list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018qtuXherdgoU89KtrSeU22

* pr-ready step 3 (simplify): one home for the media a provider dict records

- Add FSResourcesHandler.recorded_media, which lists every recorded file
  including a <type>_extra_discs list, so store_metadata_media and the
  update_rom cleanup share one rule and neither special-cases physical.
- Skip stripping a disc's URL once a better region already supplied it.
- Share the ScreenScraper disc tests' patch setup in an _extract helper
  and spell out each test's discs instead of slicing a fixture.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018qtuXherdgoU89KtrSeU22

* Refetch media whose source changed and keep shared art on rematch

- A scan now deletes each stored media file whose recorded URL changed,
  or a later disc's file the new metadata dropped, before storing, so a
  physical.png saved from another disc's art is fetched again instead of
  showing under a "(disc 1)" label.
- A rematch deletes a later disc's own file instead of the whole physical
  folder, so gamelist art sharing that folder survives.

Addresses the Greptile review on this PR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018qtuXherdgoU89KtrSeU22

* Keep a shared media file a higher-priority provider still records

The stale-media check could delete a shared file such as physical.png
because a lower-priority provider's URL for it changed, even though the
file held a higher-priority provider's unchanged art. Each provider now
leaves alone the paths the providers before it still record.

Addresses the second Greptile review on this PR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018qtuXherdgoU89KtrSeU22

* Decide stale shared media by which provider owns the path

The previous rule kept any path a higher-priority provider recorded, so
when ScreenScraper newly claimed a physical.png that still held older
gamelist art, neither provider refetched it. A shared path's file now
belongs to the first provider, in priority order, that records it, and
the file is refetched when that owner or its URL differs between the
previous and current metadata. Every provider is compared in one pass,
including ones outside this scan's sources.

Addresses the third Greptile review on this PR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018qtuXherdgoU89KtrSeU22

* Name the fields of recorded media instead of using bare tuples

RecordedMedia was a four-item tuple alias that callers unpacked by
position, with a comment spelling out what each slot held. It is now a
NamedTuple with explicit fields and a path property, and the per-path
ownership claim in remove_stale_media gets the same treatment.

Addresses review feedback on this PR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018qtuXherdgoU89KtrSeU22

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 13:59:07 -05:00
Georges-Antoine Assi
da36796f75 fix(auth): trust OIDC_TLS_CACERTFILE alongside the default CAs
OIDC_TLS_CACERTFILE was handed to httpx as verify=<path>, which builds a
context trusting only that file. A directory needed OpenSSL hashed names,
and DER or .p7b bundles failed to load, so two-tier PKI setups got a 500
on SSO. Build an SSL context from certifi and the system store, then add
every certificate found in the file or directory (PEM, DER, or PKCS#7).

Fixes #1589

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 14:38:39 -04:00
Sam Dornan
3399c736e7 fix(tests): redact provider credentials when recording VCR cassettes (#4886)
* fix(tests): scrub ScreenScraper dev credentials from VCR cassettes

ScreenScraper echoes the full request URL, credentials included, back in
its JSON (the header's commandRequested and every media URL). The VCR
config had no filters, so four cassettes carried the real devid and
devpassword in plain text.

vcr_config now masks every key in SENSITIVE_KEYS: filter_query_parameters
for request URIs and a before_record_response hook for response bodies.
The existing cassettes are scrubbed with the same 30-x placeholder the
ssid/sspassword and OAuth cassettes already use, and a guard test fails
if any cassette still holds a credential.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(tests): give the VCR scrub helper a typed return for strict mypy

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(tests): redact credential headers when recording VCR cassettes

vcr_config now also passes SENSITIVE_KEYS to filter_headers, so a
re-record with a real IGDB or SteamGridDB key no longer commits its
Authorization or Client-ID header. The existing Authorization values
were fake test tokens; they now hold the shared placeholder, and a
guard test checks every cassette's request headers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(tests): match credential keys in VCR bodies case-insensitively

SENSITIVE_KEYS_REGEX and strip_sensitive_query_params already ignore
case; the body scrubber now does too, so an echoed SSID= or
DEVPASSWORD= is masked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 12:47:41 -05:00
Claude
42e5b5d119 Remove the no-emdash Trunk linter after a one-time sweep
The linter ran over every Markdown file and Python comment, so full-repo
trunk runs on master kept failing on em-dashes that predate it. Replace
the existing ones once and drop the check. The AGENTS.md rule stays, the
v2 ESLint rule stays, and pr-ready's humanizer pass catches new ones in
prose.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RyamrxVw5BzEidVzm68LY7
2026-09-28 16:59:56 +00:00
Georges-Antoine Assi
3b2d677724 Merge pull request #4878 from rommapp/fix/grouped-hidden-representative-4466
fix(roms): pick grouped representatives among siblings the user can see
2026-09-28 11:42:54 -04:00
Sam Dornan
f6a919e11c ci: coverage upload, Docker PR check, API type drift check and other CI maintenance (#4875) 2026-09-28 11:29:26 -04:00
Georges-Antoine Assi
185e0ca03f test(roms): cover a status-filtered grouped sort
Addresses Greptile's review on #4878: a sibling the status filter drops
must not drive its group's last_played position.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 10:55:49 -04:00
Georges-Antoine Assi
8474aa6344 fix(platforms): rename c128 and videopac-g7400 rows scanned with the sibling name
Addresses Greptile's review on #4874: a quick scan skips platforms that
already have a row, so installs that scanned these folders kept the wrong
name until a full rescan.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 10:51:29 -04:00
Georges-Antoine Assi
389b420d14 fix(roms): pick grouped representatives among siblings the user can see
The grouped gallery's dedup window ranked every sibling before the
per-user status/hidden filter ran, so hiding the rom that won row_num = 1
removed the whole group even when visible siblings existed. The same
happened with a status filter matching only a non-primary sibling.

Build the per-user visibility predicate once and use it to rank matching
siblings first in the window, mask the group sort aggregate, and filter
the outer query. The window's base subquery is unchanged, so the covered
dedup plan is unaffected.

Fixes #4466

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 10:41:13 -04:00
Georges-Antoine Assi
350009855c fix(platforms): stop labeling C128 and Videopac+ G7400 with their sibling's name
ScreenScraper has no dedicated system for the Commodore 128 or the
Videopac+ G7400, so both reuse a sibling's system ID (C64 and G7000).
The mapping copied the sibling's name too, and since IGDB has neither
platform, that ScreenScraper name won the display-name fallback. The
setup wizard and platform picker then listed the c128 slug as
"Commodore 64" and videopac-g7400 as "Videopac G7000".

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 10:38:02 -04:00
Sam Dornan
ed405495b0 chore(trunk): upgrade plugins and linters, automate upgrades, scan all files weekly (#4870) 2026-09-28 10:23:42 -04:00
Georges-Antoine Assi
07d983f75c Merge remote-tracking branch 'origin/master' into feat/streaming-retroarch-core-states
# Conflicts:
#	backend/tests/test_migrations.py
2026-09-28 09:55:44 -04:00
Sam Dornan
bf6f6667ef Consolidate agent instructions into AGENTS.md and add a shared dev environment setup (#4869) 2026-09-28 09:33:32 -04:00
Sam Dornan
b4901551c8 fix(scan): stop rescans inflating live platform game counts (#4867) 2026-09-28 08:54:50 -04:00
Georges-Antoine Assi
d033921efe Merge pull request #4868 from rommapp/fix/7z-stall-guard
fix(scan): kill a stalled 7-Zip extractor at the timeout
2026-09-28 08:18:01 -04:00
Georges-Antoine Assi
d5301ac8fd Merge pull request #4854 from rommapp/fix/rom-file-category-anchor
fix(scan): anchor rom file category to the folder below the rom root
2026-09-28 08:12:17 -04:00
Georges-Antoine Assi
1027cc3832 Merge pull request #4852 from rommapp/fix/7z-hash-timeout-scales-with-size
fix(scan): raise the 7-Zip timeout default and keep partial bytes out of the fallback hash
2026-09-28 08:08:07 -04:00
Georges-Antoine Assi
c276b62134 test(rom_files): seed folder categories like a scan would
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 08:07:02 -04:00
Georges-Antoine Assi
c7425b58b4 fix(scan): kill a stalled 7-Zip extractor at the timeout
The timeout was checked only after a chunk arrived, so an extractor that
stopped writing blocked the read forever and the deadline never fired. A
watchdog thread now kills the process once the deadline passes.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 08:04:05 -04:00
Georges-Antoine Assi
005bf42577 Merge remote-tracking branch 'origin/master' into pr-4854 2026-09-28 08:03:58 -04:00
Georges-Antoine Assi
d6530463f6 fix(scan): raise the default SEVEN_ZIP_TIMEOUT to 180 seconds
Sixty seconds cut off extraction of mid-sized disc images, so their scan
fell back to hashing the archive itself.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 07:55:49 -04:00
Georges-Antoine Assi
847b222b3f fix(scan): keep partial 7z member bytes out of the raw-archive hash
When extracting the largest member of a .7z failed partway, the bytes already
streamed stayed in the file and ROM-level hashers, and the raw-archive
fallback was appended on top, giving a hash that matched neither. The hashers
are now restored to their pre-extraction state before the fallback runs.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 07:53:39 -04:00
Georges-Antoine Assi
5f244afe8f Merge pull request #4851 from rommapp/fix/validate-emulator-path-segment
fix(assets): reject emulator names that are not a single folder on upload
2026-09-28 07:48:30 -04:00
Georges-Antoine Assi
c868d15827 Merge pull request #4849 from rommapp/fix/win9x-screenscraper-id
fix(ss): map Win9x to ScreenScraper's generic Windows system
2026-09-27 20:47:52 -04:00
Sam Dornan
d828706ef9 perf(backend): pipeline multi-command Redis writes (#4858)
* perf(backend): pipeline multi-command Redis writes

- upload_chunk records a chunk with SADD, EXPIRE and SCARD in one
  transaction instead of three round trips, so a failure between them
  can no longer leave the chunk set without a TTL.
- bind_to_login_session does its SADD and EXPIRE in one transaction for
  the same reason.
- close_login_sessions reads and deletes a session's socket set in one
  transaction, so a socket binding in between is not dropped unseen.
- Logout deletes the session and removes it from the user's set in one
  pipeline.
- complete_chunked_upload reads the chunk set once instead of SCARD then
  SMEMBERS; cancel and invalidate_filter_values_cache delete their keys
  in one call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T2WxB8t3Shv4TZmHFdSMHv

* fix(backend): refuse a socket bind that lands after its session's revocation

- bind_to_login_session checks the login session still exists in the
  same transaction as its SADD. Revocation deletes the session before it
  reads the socket set, so a bind that finds it gone removes itself and
  authenticate treats the socket as anonymous.
- complete_chunked_upload keeps its SCARD fast path and reads the
  members only to name the missing chunks.
- cancel_chunked_upload removes the temporary files before touching
  Redis.
- Tests check each pipelined write executes as one MULTI/EXEC.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T2WxB8t3Shv4TZmHFdSMHv

* fix(backend): close an upload session before removing its files on cancel

A chunk PUT that passes the session check after the temporary directory
is gone fails with a 500; deleting the session first turns it into a 404.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T2WxB8t3Shv4TZmHFdSMHv

* fix(backend): answer a chunk write cut short by a cancel with 404

A PUT that passed the session check before the cancel removed its
directory fails writing; it now re-reads the session and returns the
same 404 as a PUT that arrives after the cancel, instead of a 500.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T2WxB8t3Shv4TZmHFdSMHv

* chore(backend): remove a stray Redis snapshot

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T2WxB8t3Shv4TZmHFdSMHv

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 19:41:49 -05:00
Georges-Antoine Assi
0e35dc8d17 fix(scan): address Greptile review on the rom file category anchor
Recompute the folder category for rows a Quick scan reuses, so files
categorized before the anchor fix are corrected without a Complete scan,
and annotate the new tests' parameters.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-27 20:23:51 -04:00
Georges-Antoine Assi
c10ae9815b fix(mypy): type the spec path helper in streaming tests
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-27 20:21:56 -04:00
Georges-Antoine Assi
96ede4f04b Merge remote-tracking branch 'origin/master' into feat/streaming-retroarch-core-override 2026-09-27 20:19:32 -04:00
Georges-Antoine Assi
837da4c1a0 chore(ss): address Greptile review on the Win9x comment
Reword the mapping comment so the platform is the subject.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-27 20:12:50 -04:00
Sam Dornan
29220cd59e fix(backend): restart the log forwarder and harden three Redis call sites (#4847) 2026-09-27 20:10:06 -04:00
Zach Clendenen
da6edad29a fix(streaming): address Greptile review of the RetroArch state core
A broker too old to name its core also doesn't refuse a pushed state from
another core, so hydration with no core filter now only sends a newest
state that has no recorded core, and otherwise sends nothing.
2026-09-27 17:55:25 -05:00
Zach Clendenen
9e2dbc207d feat(streaming): hydrate and resume only states the booted core can load
A RetroArch container's core filter comes from the core activate reports
booting, or before launch from the configured core and the broker's
default (asked over its cores route and cached for a minute). Hydration,
an explicit resume and the config payload all apply it, so a state
written by one core never lands where another core's quick-load reads it.
A resume the booted core cannot load launches fresh, and the resume
endpoint refuses such a state up front with a 400.
2026-09-27 16:42:02 -05:00
Zach Clendenen
288ad2e5de feat(streaming): record the RetroArch core that wrote each state
States gain a nullable `core` column (migration 0141). A pulled state keeps
the core the broker names in its X-State-Core header, and a pushed state
names its core on the way down so a broker running another one refuses it.
NULL keeps meaning the platform's default core, which wrote every state
stored before cores were recorded.
2026-09-27 16:41:43 -05:00
Zach Clendenen
21c5b65d17 fix(streaming): address Greptile review of the RetroArch core override
- Retry the exit once when a broker boots the wrong core and the first exit
  fails: the broker refuses every activate while that game runs, and the
  released claim leaves nothing behind to stop it.
- Stamp the launch's core tier on the session and report it through the
  status poll, so a tab that missed launch-ready still warns about an
  untested or broken core, once.
- Translate the core-untested and core-blocked warnings in every locale.
2026-09-27 16:41:38 -05:00
Georges-Antoine Assi
2b4dfebab5 fix(mypy): drop redis generic args after the stubs upgrade
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-27 16:28:47 -04:00
Georges-Antoine Assi
41767a6a44 Merge remote-tracking branch 'origin/master' into feat/device-push-install 2026-09-27 16:13:58 -04:00