Commit Graph

447 Commits

Author SHA1 Message Date
Sam Dornan
864a0769fc chore(deps): bump uv to 0.12.19 and relax required-version for Dependabot (#4832) 2026-09-27 10:23:19 -04:00
Sam Dornan
6002b8fdaa chore(docker): verify downloads with ADD --checksum and pin RAHasher by commit (#4781) 2026-09-26 11:35:02 -04:00
Georges-Antoine Assi
e1052665c1 feat(streaming): run the session reaper on a streaming queue with a worker of its own
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 09:46:35 -04:00
zurdi
5cccceea60 fix(audit): close the gaps left open by the pr-ready review
- A failed login keeps the attempted username only when it names an
  account, so a password typed into the username box is never stored.
- Gunicorn trusts X-Forwarded-For only from loopback and private ranges
  (FORWARDED_ALLOW_IPS, documented in env.template), so a client can no
  longer choose the address the audit log and rate limits see.
- A player's fetch (purpose=play) is recorded as rom.player_load instead
  of being skipped, so the marker can't hide a download.
- Play-session ingest treats a rom hidden from the caller as unknown, so
  its session and rom.play event don't name it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 08:08:53 +02:00
zurdi
5cd71a244c simplify: pin the RQ worker PID write with a plain substring check
The test checks the one line the watchdog relies on, next to the keepalive
pair instead of between it, and the comment states RQ's late write once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 21:17:21 +02:00
zurdi
ce36d3f0fb review: guard the RQ worker PID file and comment it where it is written
Adds a test that start_rq_worker records $! instead of passing --pid, and
moves the comment next to the line it explains.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 21:14:34 +02:00
zurdi
87ab23fd38 fix(docker): record the RQ workers' PID as soon as they start
The watchdog restarts any process whose PID file is missing, and RQ's --pid
writes that file only after importing the worker class. Since RomMWorker
imports tasks.tasks (and with it config, SQLAlchemy and the auth and socket
handlers), reaching that point takes seconds on a cold, bytecode-less image,
so on a slower host the watchdog started a fresh pair of workers every 5 s
and each one lived on as a duplicate. The init script now writes $! like it
does for the cron scheduler and the watchers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 21:12:09 +02:00
Georges-Antoine Assi
95599dadbe Merge pull request #4687 from tmgast/fix/sigil-nintendo-disc-platform
fix(sigil): bump the pin so GameCube save targets name a .gci on disk
2026-09-22 22:54:27 -04:00
Georges-Antoine Assi
e2a1a08ce8 Merge branch 'master' into claude/njs-vm-init-notice-c4d538
master refreshed the Alpine 3.23 digest and added the python-runtime
stage; this branch moves the same pins to Alpine 3.24 and nginx 1.30.5.
Kept 3.24 and re-resolved every tag to its current manifest-list digest,
so the base images carry the patches master was reaching for.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-22 08:19:43 -04:00
nendo
a10a62a29a fix(sigil): bump the pin so gamecube save targets name a gci on disk 2026-09-22 08:01:57 +09:00
Sam Dornan
5fe383641f fix(docker): move the bases to Alpine 3.24 and nginx 1.30.5
The image logs a spurious notice on every start:

  [notice] 113#113: js vm init njs: 00007F16E1CA0B00

njs logs one line per config VM it initialises (nginx/ngx_js.c) and the
config imports a single VM at the http level, so it is noise rather than
a symptom. njs 0.9.7 removed the line (nginx/njs#1042, nginx/njs#1047),
but nginx:1.29.8-alpine was built six days earlier and ships njs 0.9.6.
nginx:1.30.5-alpine3.24 ships njs 1.0.1.

1.30 is nginx's stable branch: 1.29.8 was the last mainline of that tree
and 1.30.0 the same code a week later. Both branches carry the same-day
CVE-2026-90439 fix, so the move gives up no security fix.

The nginx tag is what forces the Alpine move: each nginx release ships
one Alpine flavour and there is no 1.29.8-alpine3.24. Alpine 3.24 is
supported to 2028-06-01, 3.23 only to 2027-11-01.

Verified: the repo's own config logs the notice on 1.29.8-alpine and
does not on 1.30.5-alpine3.24; mod_zip compiles against release-1.30.5
on the new base; every apk add list in this file resolves on 3.24.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-17 15:44:10 -05:00
Georges-Antoine Assi
43ad55624b fix(docker): keep the release cache from serving a stale apk upgrade
Release builds import a persistent registry cache, and an `apk upgrade` off a
fixed base digest has no changing input, so the layer would be reused from a
previous release and reship its package set.

`no-cache-filters` forces both upgrade stages to run on every release. The
Python-side upgrade moves into its own `python-runtime` stage so that busting
it does not also rebuild the venv and the sigil bindings.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-17 13:18:51 -04:00
Georges-Antoine Assi
6c7e5875ba fix(docker): take the Alpine security patches the pinned bases do not carry
The base images are pinned by digest, so the image ships whatever packages
were current when upstream last rebuilt them. Alpine backports fixes to its
3.23 repo well ahead of that, leaving known-vulnerable curl, openssl,
libexpat, util-linux, libpng and nghttp2 in the published image.

`apk upgrade` in production-stage takes those patches, and the same call in
python-alias keeps the /usr/lib copy from putting stale libs back. The Alpine
digest is also refreshed to 3.23.5, for the builder stages.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-17 13:08:10 -04:00
Georges-Antoine Assi
b5cd86e3f7 fix(frontend): restate the player isolation URLs instead of reading nginx
The vite plugin parsed the COOP/COEP patterns out of the nginx template at
config load, but the Dockerfile's frontend-build stage copies frontend/
alone, so the config threw ENOENT and the image build failed.

Restate the two patterns in the plugin and let its test assert they still
match the template's map, which also drops the dev container mount that
existed only to feed that read.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-17 09:13:32 -04:00
Georges-Antoine Assi
8ecb4dd0c5 refactor(v2): fold the cleanup pass findings into the launch path
The dev server now parses the isolated URLs out of the nginx template
instead of restating them, and refuses a template that yields none.

js-dos skips the runtime preload on the leg it is about to reload away,
records its play session on pagehide, and takes the relaunch marker from
the composable that defines it.

Also drops a redundant parameter and a duplicated derivation from
applyLaunchIntent, collapses the repeated id checks in isLaunchIntent,
gives the js-dos asset bases one home, and trims the comments.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-17 08:18:20 -04:00
Zurdi
8bcf72df7d Merge pull request #4567 from rommapp/claude/v2-spa-launch-view
feat(v2): open the EmulatorJS and js-dos launch views without a page load
2026-09-17 13:49:01 +02:00
zurdi
8d4e856360 fix(v2): close the gaps the code review found in the player launch path
Findings from the review pass over the SPA launch change, plus the two bot
reviews on the PR.

Correctness:
- Presence stops were addressed to the device, not to a rom, so a view that
  never announced anything could clear what another tab was playing. A stop now
  needs a started session, and happens once; `useActivityPresence` grows the
  `stop()` the two call sites were spelling out by hand.
- The EmulatorJS exit read `window.EJS_emulator`, which a departure taken while
  the loader was still injecting would not see yet, so the runtime could be left
  in a document a later launch then failed to load into. It tracks the injection
  itself.
- js-dos resolved its asset base per view: a second launch in a document whose
  runtime came from the CDN looked for the payloads locally. Two views mounting
  at once could also both inject the runtime. Both now go through one
  document-level loader, which resolves with the base it served from and lets a
  later mount retry a failed load.
- A blocked sessionStorage threw while every EmulatorJS view was initialising.
  Storage that cannot be read is an absent intent, and one that cannot be
  written cancels the relaunch rather than losing the selection to it.
- Outside a secure context the headers cannot expose SharedArrayBuffer, so the
  reload only delayed the same error by a round trip. It is refused up front.
- The dev server mirrored one of the two nginx isolation entries, leaving the
  console player unisolated there.

Reuse and cover:
- `usePlayerExit` owns the whole rule again: `departing` moved in, so both views
  use `guard` rather than one of them restating it, and the `leaving` flag it
  never needed is gone.
- Resolving an intent back into a selection is a pure pair in `launchIntent.ts`
  with its own tests, rather than closures the view kept to itself.
- The Vite plugin is a script beside `precompress`, so the regexes that have to
  track nginx are tested.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R1VFUvsR5wYK3axxR1gebc
2026-09-17 05:33:30 +02:00
nendo
33c3011ef6 fix(docker): clone sigil from its rommapp home 2026-09-17 07:07:07 +09:00
nendo
ca17bfe7dd fix(docker): bump sigil to read lowercase and irregular PSX/PS2 boot serials 2026-09-16 21:22:47 +09:00
Georges-Antoine Assi
3bafae8286 Merge remote-tracking branch 'origin/master' into claude/bump-uv-0.12.13
# Conflicts:
#	docker/Dockerfile
2026-09-15 09:30:31 -04:00
Georges-Antoine Assi
0f4db4dfc2 Merge pull request #4471 from rommapp/claude/precompress-static-assets
perf(frontend): precompress built assets and serve them with gzip_static
2026-09-14 21:56:28 -04:00
Sam Dornan
b48f6003b5 fix(nginx): scope gzip_static to the build output
In the http block gzip_static was inherited by every location, including
the internal /library/ and /cache/ ones that serve downloads. RomM handles
.gz and .tar.gz ROMs, so a library holding both Game.nes and Game.nes.gz
answered a request for the first with the second's bytes under
Content-Encoding: gzip. Reproduced against nginx with a real upstream
issuing X-Accel-Redirect: the download returned 73 bytes of gzip instead
of the 3000-byte ROM. Clients that do not transparently decode, and Range
resumes over /cache/, would have written the wrong file to disk.

It now sits in the three locations that serve the frontend build, where a
.gz sibling can only be one the build wrote. Verified both directions: the
ROM download returns the plain 3000 bytes with no Content-Encoding, and a
fingerprinted asset is still served from its precompressed sibling.

The test now guards the invariant rather than the directive's presence:
gzip_static must be absent from the http block and from every location
serving files the build did not produce.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HDXxq3vAxJVGhm1pQuK8V7
2026-09-12 02:04:03 +00:00
Sam Dornan
b91a1af13e perf(nginx): drop open_file_cache and guard the keepalive precondition
open_file_cache keyed descriptors by path, so a cover replaced via
os.replace() kept serving the old inode until the validity window expired,
and the ?ts= buster does not change the filesystem key. The comment beside
it claimed the opposite. The benefit was never measured either: the cache
saves an open() and an fstat() per request, which is microseconds on a
local file, and covers are served immutable so repeat hits are rare.
Removing it is simpler than scoping it away from the one tree it was
supposed to help.

The keepalive test asserted gunicorn outlives nginx's idle timeout without
checking that nginx pools upstream connections at all, which it only does
by default from 1.29.7, so a downgrade would have left the test green and
the pooling silently gone. It now checks the pinned version too.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HDXxq3vAxJVGhm1pQuK8V7
2026-09-12 01:44:25 +00:00
Sam Dornan
76ab7ac7c7 perf(frontend): precompress built assets and serve them with gzip_static
The SPA bundle was compressed on every cold page load. Writing a .gz
sibling at build time and turning on gzip_static moves that work to the
build: serving the 1.6 MB main bundle drops from ~71ms to ~9ms per
request, measured over 25 requests against a local nginx.

Level 9 is affordable when it runs once, though it lands within a percent
of what nginx produces at runtime, so the win is the CPU rather than the
bytes. Anything without a .gz sibling still compresses on the fly.

The step is chained into build rather than a postbuild hook because
frontend/.npmrc sets ignore-scripts, which stops npm running pre and post
hooks at all. Node's zlib does the work, so no new dependency.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HDXxq3vAxJVGhm1pQuK8V7
2026-09-12 01:30:10 +00:00
Sam Dornan
5d58170bb0 docs(nginx): correct why the gunicorn keep-alive has to be raised
The comment and test docstring said a short keep-alive makes nginx reuse a
connection gunicorn is closing and return 502. Reproducing the race says
otherwise: across 320 requests timed against the close boundary, GET and
POST alike, nothing failed and nginx logged nothing. It notices the closed
idle connection and opens a fresh one.

What the short value does cost is the connection pool. Measured with a
counting upstream behind nginx, eight requests three seconds apart opened
eight upstream connections at a 2s idle close and one at 65s, so below
nginx's idle timeout the keepalive it now enables by default never pays off.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HDXxq3vAxJVGhm1pQuK8V7
2026-09-12 01:08:18 +00:00
Sam Dornan
376fb71cae chore(docker): bump uv to 0.12.13
The build pinned 0.11.2, a full minor series behind. uv is a build-time
tool here: it lands in the backend-build stage and the shipped image
takes only /src/.venv from it, so this does not change the runtime image.

0.12.0 carries breaking changes, but none reach this project. Locking
from scratch with 0.11.2 and 0.12.13 resolves the same 178 packages and
writes byte-identical files apart from how a relative exclude-newer is
recorded, and each version reads a lock written by the other.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HDXxq3vAxJVGhm1pQuK8V7
2026-09-12 00:31:40 +00:00
Sam Dornan
cd598a8f7a perf(nginx): compress wasm/svg, cache open files, buffer access log
The emulator cores are the largest assets the image serves and nginx maps
them to application/wasm, which is not in gzip_types, so they went out
uncompressed. Player logos (image/svg+xml) had the same problem.

A cover grid opens hundreds of small files and writes an access log line
for each, so cache the descriptors and buffer the log writes. Negative
lookups stay uncached so a freshly scraped cover still appears at once.

Also drop TLSv1/TLSv1.1 from ssl_protocols, which scanners flag even
though this nginx never terminates TLS, and raise worker_connections off
the old Debian default.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HDXxq3vAxJVGhm1pQuK8V7
2026-09-12 00:10:39 +00:00
Sam Dornan
da6ea1dd16 fix(docker): bump nginx to 1.29.8 and raise gunicorn keep-alive
nginx 1.29.7 is a security release (CVE-2026-27654, CVE-2026-27784,
CVE-2026-32647, CVE-2026-27651, CVE-2026-28753, CVE-2026-28755) and also
enables upstream keepalive by default, defaulting proxy_http_version to
1.1. That removes a TCP connect and teardown per /api request, which the
config never opted into.

It also makes the gunicorn keep-alive too short: nginx now holds idle
upstream connections for up to 60s while gunicorn closed them after 2,
so nginx could send a request on a connection gunicorn was closing and
return 502. Raise the default past nginx's idle timeout.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HDXxq3vAxJVGhm1pQuK8V7
2026-09-12 00:10:32 +00:00
Sam Dornan
1608a8964b ci: build each arch on a native runner and cache layers (#4437) 2026-09-10 20:41:56 -05:00
Sam Dornan
77a0ee8fe5 fix(docker): bump the production image's sigil pin too
The release and preview image workflows build docker/Dockerfile for
linux/amd64 through the same sigil path, so they hit the same zstd asm
link failure the dev image did.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-09 16:11:43 -05:00
Georges-Antoine Assi
609f1bcb3d chore(dev): provision the browser emulator runtimes in the dev image
Fetch EmulatorJS, Ruffle, js-dos and FAKE-08 in the dev Dockerfile, on the
same pins and checksums as the emulator stage of docker/Dockerfile, into
/opt/romm/emulators. The ./frontend bind mount hides anything the build
writes under /app/frontend, so entrypoint.sh links each runtime into the
assets tree the dev server serves, leaving names held by checked-in art
alone. The runtime directories join the dev watcher's ignore list so
chokidar does not crawl them.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-08 21:27:04 -04:00
Georges-Antoine Assi
2f21105a70 polish(pico8): trim comments, name the bit tables, type the canvas fake
Cut the comment that compared the pixel loop to the byte-store version it
replaced, and the two three-line notes on the runtime fetch and the script
loader, keeping only what a reader cannot recover from the code.

Rename padButtonMap, padAxisMap and mouseButtonMap to *Bits: they are pair
lists of masks, not records like keyboardMap next to them.

Give the test's fake canvas context a real ImageData return so it fails if
the runtime starts reading width or height, and drop the imports that
change orphaned.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-08 20:42:05 -04:00
Bee
f50eacfcbd feat: add browser PICO-8 player
Add v2 browser playback for .p8 and .p8.png cartridges, backed by the
FAKE-08 WebAssembly runtime, with canvas rendering, audio, fullscreen and
keyboard, gamepad, mouse and touch input. Wires up platform detection,
play actions, routing, localization, gallery navigation, play-session
tracking and lifecycle cleanup.

The runtime is fetched in the emulator stage of docker/Dockerfile, pinned
by source commit and verified with sha256, so it is provisioned the same
way as EmulatorJS, Ruffle and js-dos rather than committed to the repo.

DISABLE_PICO8 gates the player, matching the existing DISABLE_EMULATOR_JS,
DISABLE_RUFFLE_RS and DISABLE_JSDOS toggles.

Based on #4383.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-08 17:59:52 -04:00
Spinnich
424d1ebc1c fix(server): default to 4 API workers instead of 1
A single worker was the reason a lone user loading a gallery measured
6.474 s worst-case TTFB against 1.939 s at 4 workers. The multi-worker
path is already supported: the log forwarder takes a Redis lock so
exactly one worker relays.

Only installs that never set WEB_SERVER_CONCURRENCY move; any explicit
value is preserved.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-07 16:56:48 +00:00
Georges-Antoine Assi
a3aecdf045 chore(python): restore the C accelerators lost on 3.14
The runtime moved to 3.14 but the pinned versions did not, so packages
without cp314 wheels silently resolved to their pure-Python universal
wheels. Bump each to the first release that ships cp314 wheels, all
within the existing pyproject specs:

- SQLAlchemy 2.0.41 -> 2.0.52 (cyextension, and greenlet is back so
  sqlalchemy.ext.asyncio is functional rather than merely importable)
- multidict, propcache, frozenlist (aiohttp/yarl accelerators)
- wrapt 1.17.2 -> 1.17.3 (OpenTelemetry instrumentation proxies)
- coverage 7.9.2 -> 7.16.0 (CTracer, and CI runs the suite under --cov)
- mysql-connector-python 9.3.0 -> 9.7.0 (C extension protocol)
- debugpy 1.8.14 -> 1.8.21 (pydevd accelerators)
- pyinstrument 5.0.3 -> 5.1.3 (no longer compiled from sdist on every
  `uv sync --all-extras`, which broke the no-toolchain dev setup)
- anyio 4.9.0 -> 4.14.2, dropping a PEP 765 SyntaxWarning printed on
  every process start

Run pytest and the migrations workflow when the runtime or the lock
changes: nothing in the 3.14 bump lives under `backend/`, so neither
workflow triggered on it. `e2e.yml` already listed those paths.

Make `.python-version` the single home for the version: `uv python
install` and `actions/setup-python` both read it. In the dev Dockerfile
that also fixes the interpreter layer not being invalidated when the pin
changes, and the sigil install now derives site-packages from the venv.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-05 21:48:52 -04:00
Sam Dornan
3c547dfbd0 chore(python): move the backend to Python 3.14
Bumps the runtime everywhere it is pinned: requires-python, the
.python-version uv reads, both Dockerfiles (with the python:3.14-alpine3.23
and uv 3.14 image digests), the six workflows that install Python, and the
contributor docs.

Several locked C-extension versions had no cp314 wheels, so the Alpine
image fell back to building them from source and failed on the missing
C++ and Rust toolchains. Those packages are upgraded within their existing
pyproject ranges: pydantic 2.11.7 -> 2.13.5 (pydantic-core 2.46.5), uvloop
0.22.1, grpcio 1.83.1, httptools 0.8.0, inflate64 1.0.4, markupsafe 3.0.3,
pyyaml 6.0.3 and streaming-form-data 1.20.0. The lockfile also drops the
3.13-only resolution branches.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-05 08:57:10 -05:00
Georges-Antoine Assi
dc7d14f31d refactor(scan): let RQ discard the scan dispatch, and say the guard once
The dispatch job was hidden from the task list by a meta flag the endpoint
had to look for on every job in every queue and registry. RQ already has
the rule the flag was implementing: `result_ttl=0` deletes a job the moment
it succeeds, while a failed one still lands in the failed registry under
its own TTL. Registering the scan entry with it drops the marker, the
predicate, its four filter sites and the two Redis reads each one cost.

The concurrency guard is now one call. `get_blocking_library_scans()` says
which scans a second one has to wait for, so the socket handler no longer
assembles that rule out of two helpers in two shapes, and `ALL_QUEUES` sits
with the queues it lists rather than in the API layer.

Also merges the finished and failed registry sweeps, which were the same
loop, trims comments that explained the design rather than the code, and
drops two socket tests that duplicated their neighbours.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 12:29:58 -04:00
Georges-Antoine Assi
ffc8dffc20 Merge upstream master into claude/rq-scan-queue-split
Master landed #4274 with the review changes that came out of it, and those
moved the code this branch was built on. Scan job bookkeeping now lives in
`handler/scan_jobs.py`, every enqueue goes through `enqueue_task`, cron
entries carry their own name and result TTL, and the watcher builds its two
rescans from one helper.

Resolved by putting this branch's changes where that code now lives:

- The scan queue, the scoped-scan check and the second scheduled registry
  moved into `handler/scan_jobs.py`, keeping master's single-round-trip
  reads (`get_job_ids` plus one `fetch_many`, and `get_jobs_to_schedule`
  for the stale sweep) across both registries.
- `enqueue_scheduled_scan` sits next to `enqueue_task` in the registry and
  is built from it, rather than hand-rolling the same enqueue in
  `tasks/tasks.py`. Its tests moved with it.
- Cron keeps master's per-entry name and result TTL, and adds the scan
  dispatch on top: `TASK_TIMEOUT` for the dispatch, the task's own timeout
  (now `SCAN_TIMEOUT`) for the scan it enqueues.
- The watcher's `schedule_rescan` helper enqueues on the scan queue with
  the abandoned-job callback.
- `PeriodicTask.func` is gone from master, so the scheduled rescan declares
  only its timeout. `tasks.registry.enqueue_scheduled_scan` joins the func
  paths an RQ worker has to be able to import.
- The job stubs shared by the discovery tests grew the scan queue and a
  scoped-scan job; the duplicated stale-sweep tests are master's.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 12:16:44 -04:00
Georges-Antoine Assi
32f9e338e7 Merge pull request #4274 from sdornan/claude/rq-native-scheduler
refactor(tasks): schedule with RQ instead of rq-scheduler
2026-09-03 11:50:20 -04:00
Georges-Antoine Assi
787bbba2b4 refactor(tasks): give every enqueue one home
Scheduling moved onto RQ, which left the task catalog with two identity
schemes: the registry key a job payload now carries, and the dotted func
path each PeriodicTask still declared. Nothing read the latter, so it is
gone, along with the test that guarded paths no payload names.

Four sites built the same enqueue by hand and had already drifted: the
startup backfills passed the global timeout and no result_ttl, so an
auto-enqueued conversion fell out of the task list after RQ's default
500s while the same task triggered by an admin lived for TASK_RESULT_TTL.
They now go through enqueue_task, which derives timeout, ttl and meta
from the task itself.

Scan discovery paid a Redis round trip per queued job to re-read a status
the fetch already carried, and the stale sweep read every delayed job to
find the few past due. Both now ask Redis once.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-02 21:03:30 -04:00
Georges-Antoine Assi
bcafc3d504 refactor(scan): tighten the sigil title id plumbing
Rename embedding now goes through the handler's own rename primitive
(`rename_fs_rom`), so it inherits the library-root path validation and
per-path locking every other write in that class gets, and builds the new
name with the repo's multi-part extension helpers.

Extraction no longer reads files it can never parse: archives, manuals,
soundtracks and screenshots are skipped, and on non-Switch platforms it
stops after the first result, since only Switch looks at a per-file
content type.

Also collapses the two rom-level branches (dropping a closure), gives the
Switch family one home in RomM's own terms instead of deriving it from
sigil's slug string, logs an unrecognized save target layout instead of
dropping it silently, deletes the `ScannedFSRomValues` mirror of `FSRom`,
drops a dead `rom.version` locale key, and slims the sigil Docker builds
to one layer with a filtered clone.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-02 16:34:36 -04:00
Sam Dornan
3593d2398a perf(scan): give scans their own queue and worker
A library scan runs for hours on the same worker as everything else, so
every cleanup, conversion and metadata refresh waited behind it. Scans go
on a queue of their own, consumed by a second worker, and the queues that
serve the rest of the app keep moving while a scan runs.

One worker on one queue also makes "one scan at a time" structural rather
than something the socket handler has to enforce, and it leaves another
worker running to notice when the scan worker dies.

Which is what the second half of this does. A worker killed mid-scan
never reaches the handler that reports the scan ended, so clients kept
showing a scan that no longer existed. RQ hands an abandoned job to its
failure callback when a surviving worker reaps it, so scans carry one
that emits `scan:done_ko`. Only for AbandonedJobError: every other
failure is already reported by the scan as it unwinds, and emitting here
too would report it twice. The scheduled rescan is not covered, because
rq cron cannot attach callbacks.

Scan discovery still reads the other queues, so a scan enqueued before
this change is still found and still runs.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-02 15:02:16 -05:00
Sam Dornan
4e3ca0611f fix(docker): read REDIS_SSL as the boolean the app reads it as
The shell built the connection URL with `redis${REDIS_SSL:+s}`, which
only asks whether the variable is set. `env.template` ships
`REDIS_SSL=false`, so following the documented value pointed the worker
at `rediss://` while the app parsed the same variable through
`safe_str_to_bool` and connected in plaintext. Adding the cron process
put a second process behind it.

Parse the value in both entrypoints, matching the truthy set the app
accepts.

Also clear the old scheduler's lock and instance keys even when its
registry held no jobs: a scheduler that never queued anything still
registered itself, and only the orphan-job work needs the registry.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-02 15:02:04 -05:00
Sam Dornan
4e59217275 refactor(tasks): schedule with RQ instead of rq-scheduler
rq-scheduler has one release since 2023, 109 open issues, and RomM ran a
fork of it for Redis username and SSL options that upstream never took.
Everything it was here for now ships with RQ.

Its two failure modes were the reason for the workarounds in 9e9f59c04.
It reads a job's function name before taking the job out of its registry,
so one unreadable job stalls it for good; RQ's scheduler removes every id
it looked at whether or not the job could be read. And cancelling a
delayed job needed both `Scheduler.cancel` and `Job.cancel`, because the
first left the status alone and the second left the registry entry, which
the scheduler then queued anyway; `Job.cancel` on its own now clears the
scheduled registry.

Delayed jobs, which is how the watcher defers a rescan, go onto the queue
with `Queue.enqueue_in` and are released by the worker running with
`--with-scheduler`. Periodic tasks are declared in `tasks/cron_config.py`
and loaded by an `rq cron` process, replacing `rqscheduler`. A task is
registered only when it is enabled and has a cron string, so the
schedule-then-unschedule dance around the env toggles is gone, and with
it `PeriodicTask.init/schedule/unschedule`.

Jobs are enqueued by task name through `run_task_by_name`, resolved
against a catalog in `tasks/registry.py`. Nothing pickles a task instance
into Redis any more, which is what made a payload unreadable across
upgrades in the first place. The catalog also gives the tasks endpoint
one home for what a task is, rather than a list of its own.

Scan discovery keys off the type a job carries rather than the scheduled
rescan's function name, since every task now shares one entry point. That
also drops SCAN_LIBRARY_TASK_FUNC, which only existed to name a function
across an import cycle.

The watcher's dedupe worked on `job.args[0]` while scans are enqueued with
keyword arguments, so it never matched and every filesystem change
scheduled another scan. It reads `platform_ids` from the payload now, and
deliberately ignores a scan already running: that one may have walked past
the folder that just changed.

Startup clears what the old scheduler left in Redis, once.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-02 15:02:04 -05:00
nendo
e04b6035f2 Merge upstream master into feature/sigil-title-ids
Upstream took 0113, so the sigil migration rechains onto
0113_roms_locked_fields as 0114. The sigil build stage keeps its place
ahead of the emulator stage, which upstream renamed for js-dos.
2026-08-31 11:39:53 +09:00
Georges-Antoine Assi
025febc17f fix(nginx): keep cross-origin isolation when a player URL carries a query
$request_uri includes the query string, so the end-anchored player pattern
missed /rom/<id>/jsdos?x=1 and nginx dropped COOP and COEP, leaving the
threaded runtime without SharedArrayBuffer. Accept an optional query instead
of anchoring at the path end.

Matching stays on $request_uri: try_files rewrites $uri to /index.html before
add_header runs, so a $uri map would match no player URL at all.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-29 11:56:40 -04:00
Georges-Antoine Assi
4142fbc018 refactor: dedupe js-dos emulation checks and player plumbing
usePlatformPlayable is the platform-level twin of useCanPlay, but only the
latter learned about js-dos, so win3x/win9x games offered Play while their
platform tile showed no playable badge and sorted into the unplayable bucket.
Teach resolveEmulator about js-dos and derive `playable`/`isPlayable` from it
instead of hand-maintained OR chains.

Collapse the duplication the new backend introduced: a shared
resolvePlatformSlug in utils, a supportedBy factory for useCanPlay's three
identical computeds, one COOP/COEP nginx pattern per map, and a single
hard-navigation branch in useGameActions that reuses the canPlay useCanPlay
already returns.

In JsDos.vue, share the teardown tail between leavePlayer and onBeforeUnmount,
collapse four derivations of the route rom id into one, start the js-dos
runtime alongside the rom request rather than behind it, and hold the rom in a
shallowRef since the view only reads scalars off it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-29 10:20:47 -04:00
Georges-Antoine Assi
29bad62e58 chore: trim unused js-dos assets from the image
The js-dos release bundle ships a demo index.html that would be served
unauthenticated under /assets/jsdos, plus source maps, Emscripten symbol
tables and type declarations that no runtime code loads.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-29 09:57:35 -04:00
Georges-Antoine Assi
eed9549a2a Merge branch 'master' into 3143-jsdos-backend
Resolve conflicts in useCanPlay and its useGameActions tests, where master
added the has_file_on_disk gate to the play checks while this branch added
the js-dos route. Keep both: js-dos also boots from the ROM file, so it gets
the same gate as EmulatorJS and Ruffle.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-29 09:33:18 -04:00
nendo
a057c886ae feat(scan): extract PS3, Xbox and Xbox 360 title ids via sigil
sigil gained an Xbox extractor and learned to read PS3, PS Vita, Xbox 360
and Wii U out of their containers, so the three platforms it could
already name are now reachable from a scan. All three are non-hashable
or partly so, which is where a binary id earns the most: it is the only
identity those libraries carry. The extractors are flagged experimental
upstream.
2026-08-28 10:54:58 +09:00