The LaunchBox import wrote the whole game record into three hashes: once
under its database id, and again under its title and folded title. The
Switch TitleDB import wrote every entry twice, once per id it is looked up
by. Both title indexes and the product id index now hold the id of the
record they point at, and the reader follows it.
Image lists also carried a `DatabaseID` repeating the field they are stored
under, plus a `CRC32` no lookup reads.
Measured on a full import of both dumps into the bundled valkey:
941MB -> 466MB of `used_memory`.
An index written by an earlier import still holds whole records, so a
lookup keeps answering off it until the next update rewrites the store.
Fixes#4395
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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>
The pinned sigil revision globs zstd's decompress sources as C only, so
huf_decompress_amd64.S is never assembled while huf_decompress.c still calls
into it. Building the cffi bindings fails at the shared-object link:
undefined reference to `HUF_decompress4X2_usingDTable_internal_fast_asm_loop'
relocation R_X86_64_PC32 against undefined hidden symbol ... can not be
used when making a shared object
argosy-sigil fixed this on main by selecting zstd's C fallback with
ZSTD_DISABLE_ASM. Bump the pin to pick it up.
Verified on linux/amd64 against 4b0f138: cmake build, shared-object link, the
cffi binding build under Python 3.14, and importing the module. sigil.extract
keeps the signature adapters/services/sigil.py calls.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NtfAbk9LrxmwFnBktP3NkY
`sibling_roms` matched on seven providers, the gallery's dedup window on
those plus `flashpoint_id`, and the recommendation feed on those plus
`steam_id`. Three lists, so a pair sharing only a Steam or Flashpoint id
was the same game to one reader and two games to another.
They are one list now. `rom_identity_keys` carries all nine providers,
which makes `provider_id` a varchar since `flashpoint_id` is a string,
and the dedup window's cover index grows by `steam_id` so the window
keeps its indexed plan.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A rom written between the backfill and the trigger creation got no key
rows, and nothing short of a later edit to one of its identity columns
would have noticed. Both writes skip a row that is already there, so the
two steps can overlap.
Also correct the revision the docstrings point at and the claim that
IDENTITY_ID_FIELDS contains the group_by_meta_id window's columns.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Master keyed the unique roms index on the full path digest, so the
resolution keeps its two indexes and this branch's comment on
idx_roms_sibling_cover, which no longer backs the sibling_roms view.
Both sides added a 0126 revision off 0125; rom_identity_keys moves to
0127 behind master's unique_rom_full_path.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Comment and docstring pass over the `released_days` change: cut the copies of
rationale that already live next to the thing they describe, and drop the
sentences defending obvious choices.
`RELEASED_DAY_REGEX` now carries the calendar ranges, so a match is a valid day
and `parse_released_days` needs no sentinel pair and no second range check.
`release_day_ranges` stops re-sorting what `epoch_ms_in_ranges` already sorts.
`anniversaryQuery`'s return type is a named export, so the widget imports it
instead of unwrapping a `ReturnType`, and the widget's two reset paths share
`showEmptyDay`.
`loadMore` is `loadNextPage`, since it appends one page rather than the rest.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`GET /api/roms` already does what `/roms/anniversaries` hand-rolled: it selects
ordered ids over the filtered set, takes the total from that index, hydrates
only the page asked for, and re-projects the rows into id order. So the widget
now asks it for a page rather than owning an endpoint that pulls the whole day.
`released_days` on the list endpoint takes days as "M-D", matching any year, and
`released_before_year` bounds them. Both go through `filter_roms`, so the same
day-of-year match is available to the gallery filters and to smart-collection
criteria, and the range union stays where it was: still sargable, still a
covering index range scan on `idx_roms_generated_first_release_date`, no SQL
date function and no dialect branching. Verified on a 73k-rom database that the
plan through the list endpoint's join is unchanged: `type=range`,
`Using where; Using index`, no filesort.
The filter means exactly what it says, so the calendar policy moved to the
client, where the clock it depends on already lived. `anniversaryQuery` picks
the days and the year bound off the viewer's own date: it skips 1 January,
where several providers park year-only metadata, rolls 29 February onto 28
February in a non-leap year, and bounds the years at the viewer's own. The
server no longer has to second-guess a timezone offset, so the 31 December
asked for on 1 January UTC correction is gone rather than fixed.
Consequences for the widget: the counter is the day's real total instead of one
clipped at a 500-row ceiling that no longer exists, and a card costs one page
of 24 rather than up to 4 MB up front. Paging backwards stays in memory;
only moving past the loaded pages fetches, with the spinner on the arrow so
focus is never yanked mid-page. A failed page keeps the card on screen.
`released_days` is added to the list endpoint's unscoped-cache gate: the
sidecar keys encode no filters, so a narrowed page must not be served under the
shared "all" key. Covered by a test that primes the unscoped key first.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The day's ordering breaks ties on the rom id. Every rom released on the
same calendar day carries the same timestamp, so without it the paging
order, and which rows the 500 ceiling keeps, varied between requests.
MariaDB plans it the same way: still a covering index range scan, no
filesort.
The widget clears the loaded day when a request fails, so the rollover
check retries it. Claiming the day up front held the error copy until
local midnight, and the card offers no way to ask again.
Also pins the clock in `test_defaults_to_todays_utc_date`, which failed
on 1 January and raised on 29 February; corrects the Czech 2-4 plural
form, which the locale's own rule reaches; and drops "scope" from the
endpoint docstring, where it read as a claim about the auth scope
declared right above it.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The mod_zip manifest that streams multi-file downloads is line-oriented, and
the NAME field of each record was interpolated from a rom file's full_path
verbatim. A line feed in that path would split the record and forge an extra
archive entry pointing at any internal nginx location.
sanitize_filename now drops the whole C0 range plus DEL instead of only null
bytes, so a control character cannot enter fs_name through a rename or an
upload. ZipContentLine scrubs the same range from the entry name, which is a
path and so cannot go through sanitize_filename, and rejects a location that
was not URL-encoded.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The endpoint answered with every match for the day, so response size
tracked the library rather than the request: the busiest real date on a
96k-rom library is 1,101 roms at roughly 8 KiB of SimpleRomSchema each,
and the 1 January early-return was the only thing holding that off
~23,000.
The ceiling goes on the id selection rather than the response, so it
bounds the hydration and the serialization too, which is where the weight
is. It rides the existing index-ordered range scan, so the plan does not
change and the engine stops early instead of walking the whole union.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The PICO-8 modules sat beside the view they serve, while every other v2
helper lives in v2/utils, player ones included (playerBezel, playerDisc,
playerFirmware).
scriptLoader moves with them: pico8Runtime imports it, and nothing in
v2/utils reaches into v2/views, so leaving it behind would have been the
first exception. EmulatorJS and JsDos pick it up from the new path.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The player gathered keyboard, gamepad, on-screen and mouse state inline, so
the bit tables, the btnp edge detection and the pad polling all sat in the
SFC with no way to test them. pico8Input owns that state and hands back the
per-frame snapshot; the view keeps only DOM plumbing, which drops its script
block by 92 lines.
The mouse scaling takes an offset and the canvas size rather than an event,
so the clamping is exercised without a DOM. 23 tests cover the edge
detection, the dead zone, the #3851 phantom-pad guard, the pointer-button
masks and the reset a replay depends on.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Audio ran on the main thread and rebuilt the graph every frame: an AudioBuffer
and a one-shot AudioBufferSourceNode per frame, roughly 18k nodes and 80MB of
garbage per ten minutes of play. A single AudioWorkletNode now drains a ring
buffer on the audio thread, so playback survives a stalled main thread. The
route gets no COOP/COEP, so samples cross by transfer rather than through a
SharedArrayBuffer, and the worklet hands each buffer straight back for the
player to refill: 231 posts and 231 recycles over a four-second cart, so
steady-state playback allocates nothing. The runtime fills a caller-owned
buffer instead of returning a fresh slice, which drops the last copy.
Frame pacing moves to pico8Pacer, and audio scheduling to pico8Audio, so the
two pieces most likely to be wrong are unit-testable without a component. Both
had no coverage while the wasm bindings did; they now have 19 tests between
them, including the catch-up cap and the buffer recycling.
useGamepad keeps the knowledge about raw pad state, so export isUsablePad,
PAD_BUTTON and AXIS_THRESHOLD rather than restating them here. The button
index map is now keyed by name, with the event-detail lookup derived from it.
Vite inlines assets under 4KB as data: URIs, which addModule cannot be relied
on to accept, so the worklet is pinned to a real file.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Another element taking pointer capture mid-press left the cartridge with a
stuck mouse button, and a FAKE-08 build with ABORTING_MALLOC disabled would
hand back a null pointer we wrote through.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
isPico8Rom read fs_extension, which holds only "png" for a .p8.png cart:
the backend builds multi-part extensions from letter-only segments and "p8"
has a digit. So no cartridge stored that way offered a play action. Read the
file name instead, and assert against the values the scanner really writes.
Size the screen from the row it sits in rather than from vmin, so the square
plus the on-screen controls always fit: the stage overflowed on shorter
viewports and centred overflow clipped it at the top and the bottom at once.
Keep the controls clear of the bottom tab bar, which overlays that corner on
sm-and-down.
Move the stage chrome into a bottom-right stack of icon-only buttons, a
fullscreen toggle over exit, via a new PlayerShell `stage-actions` slot. The
other players keep the shell's own quit button.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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>
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>
The canvas, the control group and the four d-pad buttons shipped English
aria-labels and tooltips. The parity check cannot see a key that was never
added, so nothing caught them.
The face buttons keep A and B as their own accessible name: those are the
canonical PICO-8 button names and are not translated.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Render through a packed-RGBA palette lookup and a 32-bit pixel view, so a
paint is two stores per framebuffer byte instead of eight clamped byte
writes, and rebind the heap views only when wasm memory grows.
Separate `advance` from `render` so a catch-up tick emulates several frames
but paints once, rather than discarding up to two full frames of pixel work
exactly when the machine is already behind.
Load the runtime and fetch the cart in parallel, reuse one input struct
instead of allocating per step, and skip disconnected gamepads, whose stale
analog values press buttons on their own in Firefox (#3851).
Replace the hand-rolled liveness flag with useIsAlive, take the canvas
geometry and the canvas background token from their existing homes, and move
the pad, axis and mouse-button mappings next to the keyboard map.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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>
A request still in flight across local midnight could resolve after the
rollover's and overwrite the new day's games with yesterday's. The
rollover had already marked the day loaded, so the timer would not ask
again for another 24 hours.
Each load now claims its day up front and commits nothing (games, error
state or the loading flag) once a newer load has claimed a different day.
Addresses the review comment on AnniversaryWidget.vue:99.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The 24-item cap was measured against the largest library available and
does not earn its place: on a 96k-rom library the day-of-year index range
scan costs 3.7 ms whether it matches 114 rows or 22,914, so the cap saved
roughly 40 ms and 0.7 MB on a typical day while truncating every single
day of the year (median 132 matches/day, and 100% of days exceed 24).
Removing it also makes the widget's counter a real total rather than a
ceiling, which was the substance of the review comment about "24 / 24"
implying a complete list.
This makes the 1 January skip load-bearing for response size as well as
accuracy: it is the one day that would otherwise answer with 22,914 rows
(28% of all dated roms), where the busiest real day is 1,101.
Addresses the "Result cap hides anniversaries" review comment on #4396.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The card is pinned to a date but was only loaded on mount, so a Home page
left open across local midnight went on showing yesterday's games. A
minute timer compares the day it loaded for against the clock, so only a
crossed midnight costs a request.
Addresses the "Widget stays stale overnight" review comment on #4396.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Clients send their own local month and day, so around the new year the
server's UTC date can name a different year. 31 December asked for on
1 January UTC bounded the search at the wrong year, letting a release
from the viewer's current year through as an anniversary of itself.
A timezone offset moves the calendar by at most a day, so 31 December /
1 January is the only pair that can disagree, and 1 January already
returns nothing.
Addresses the "Mixed clocks include new releases" review comment on #4396.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Shows games released on today's date in an earlier year, one at a time,
with arrows to page through the rest. Sits in the Home widget rail beside
Random pick and Library stats, with its own Settings toggle (default on)
and an entry in the drag-reorder list.
New endpoint GET /api/roms/anniversaries, ROMS_READ, whole-library,
returning up to 24 SimpleRomSchema oldest release first. Clients send
their own local month and day so "today" matches the calendar in front of
the user rather than the server's UTC clock.
The day-of-year match is a union of one-day ranges over
generated_first_release_date rather than MONTH()/DAY() on the value.
Ranges are sargable, so idx_roms_generated_first_release_date serves both
the match and the sort as one covering range scan: 195 rows examined and
~2 ms against 63,334 rows and ~70 ms for the function predicate on a
100k-row table. Emitting no SQL date function also means no dialect
branching and no migration.
1 January returns empty. Several providers park year-only metadata there
(ScreenScraper parses a bare year with %Y, CSDb publishes nothing else,
IGDB reports year precision as 1 January), so nothing in the stored data
tells a real 1 January release apart from an unknown day. Leap-day
releases roll onto 28 February in non-leap years.
Visibility follows /random: filter on hidden platforms and roms, then
re-check each hydrated row with perms.can_see_rom.
Closes#3440
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The e2e job copied only the fixture library, not the config.yml declaring its
platform-folder-first layout, so the seeder scanned an empty library.
Reject `.` and `..` template sections: no directory listing yields either, so a
template carrying one discovered nothing and marked the platform's roms missing.
Drop the cached `full_path` when either half is set. A scan reads it and then
renames the file in place, which left the cached pair stale.
Point `build_physical_fs_name` at the index 0126 actually creates.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The docs link carries the grammar and the examples demonstrate it, so the prose
restating both goes. Thirteen comment lines become four.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Rename `FirmwareTemplate.platform_path` to `firmware_dir`: it returns the
firmware folder, while the same name on `StructureTemplate` returns the platform
folder. Name the watcher's index for the segment it points at.
Fold the two reads of a raw structure key into `_raw_template`, and drop the
docstrings that only restated a one-line delegation or a signature.
Remove `footer-create-summary-default`, which no component references and whose
copy still named Structure A.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The banner and footer chips held either `roms/{platform}` or `{platform}/roms`
before, so their width was bounded. A configured template is not, and a nested
one overflowed its container at every viewport, clipping the path mid-segment.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`filesystem.structure` now spells out the whole layout rather than only the part
below a platform folder. A template is relative to the library root, `{platform}`
marks the platform folder, and `{game}` marks where a game begins.
Merge `{gameFile}` and `{gameDir}` into one `{game}` terminal. The information a
terminal carried was the depth, not the kind: at a declared level a file is a
game of its own and a folder is one multi-file game, which a stat answers. That
drops the two-template idiom for a level holding both, and `_discover_default_roms`
with it, since the default scan is now just `roms/{platform}/{game}`.
Retire the auto-detected `{platform}/roms` layout, along with
`filesystem.roms_folder` and `filesystem.firmware_folder`, which named one path
segment each that a template now contains. Both are refused at startup with the
template that reproduces the layout, so an instance that relied on either says so
instead of scanning an empty library and marking every rom missing. Firmware gets
its own `structure.firmware` key rather than following the rom layout implicitly.
`get_roms_fs_structure` keeps meaning the folder a platform's games start in, so
the `.physical` sentinel paths already in the database still resolve. Per-platform
overrides have to agree with `default` on where the platform folder sits;
relocating one platform needs platform discovery and the watcher to union several
roots, which is left out.
The setup wizard reports `library_ready` plus the configured template instead of
a `struct_a`/`struct_b` discriminator, so the banner shows the layout in force
rather than guessing it client-side.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Testing the custom library structure against a live library turned up four
defects, all of them a path being reduced to a bare file name.
Both exporters wrote a rom's `fs_name` alone, so every game a template nests
was exported as if it sat in the platform folder: ES-DE and Pegasus could not
find any of them. They now write the rom's path relative to the platform
folder, the folder the metadata files themselves live in, and copy exported
media into the matching subfolder so two identically named roms keep their own
artwork.
Merging into an existing gamelist.xml / metadata.pegasus.txt keyed entries by
file name too, so identically named roms in different folders both merged into
the first entry and produced duplicates. Entries are now keyed by path, with a
Pegasus block matched by the folder its listed files sit in.
Reading a gamelist.xml had the same collision: two roms sharing a file name
both took the metadata of whichever entry was parsed last. A rom's own path now
wins, and a bare file name stays a fallback key for the tools that write those,
dropped when two entries share it.
Default discovery surfaced hidden folders as multi-file games, unlike
structured discovery which skips them. exclude_multi_roms now owns that rule
for both.
Also validate `exclude`'s exclusion_type: an unknown value reached
`Config.__getattribute__` and returned a 500 rather than a 422.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Migration 0126 samples `rom_identity_keys` right after its backfill, which
on a fresh install runs while the table is still empty. The first scan then
fills it through the triggers, and MariaDB keeps planning `sibling_roms`
against the empty sample: measured on 37k key rows, one gallery page's
sibling statement takes 891.7 ms in that state against 2.1 ms once resampled,
which is worse than the 550.7 ms the view it replaces cost.
InnoDB's auto-recalc does not cover it. It fires and updates the stored row
count, but the plan does not change until the table is reopened or analyzed:
90 s after a trigger-paced fill, `mysql.innodb_table_stats` was correct and
the plan was still the block-nested-loop one.
Addresses the "Fresh Installs Keep Stale Statistics" review comment on #4394.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`idx_roms_sibling_cover` no longer backs a self-join over `roms`, only the
`group_by_meta_id` dedup window, so the index comment named a reader that
does not exist and would mislead anyone weighing whether the index can be
narrowed.
The view's per-provider columns keep their names but a row now fills only
its own provider's, so "the view's shape is unchanged" read as a promise
about the values too.
`recommendations_handler` matches on a list that is wider than the sibling
list by `steam_id`; its comment pointed at the sibling list instead.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`sibling_roms` was a view that self-joined `roms` on an OR of seven
equalities across seven columns. The compared values come from the joined
row, so no index can drive that OR: MariaDB answers it by block-nested-loop
scanning every ROM on the platform. Every gallery page paid that for its
version badges, and the gallery's "Versions" filter asked the same view for
an EXISTS over the whole library.
Migration 0126 moves the ids into `rom_identity_keys`, one narrow row per
ROM per provider it matched, and redefines `sibling_roms` as a self-join of
that table. Triggers on `roms` keep it in sync, guarded by `NEW.x <=> OLD.x`
so the writes that touch no identity id skip the resync; deletes ride the
foreign key's cascade. This is the move 0101 made for `virtual_collections`.
Matching is unchanged: the same seven providers, still scoped to a platform.
No application code changes and no API shape changes.
Measured on a clone of a real 96k-ROM, 123-platform library:
GET /api/roms?duplicate=true 977,571 ms -> 22,149 ms (45x)
PlayStation gallery (9,196) 1,039.0 ms -> 382.2 ms (2.7x)
Arcade gallery (7,719) 844.5 ms -> 296.2 ms (2.9x)
all-games gallery 3,023.9 ms -> 2,690.5 ms (1.1x)
The all-games page barely moves because its rows are drawn from 123 mostly
small platforms, so the per-platform scan was cheap per row. Its residual is
almost entirely the group_by_meta_id dedup window (2,535 ms of 2,676 ms
measured on the same clone), a separate problem.
The view deliberately has no DISTINCT: a pair matched by two providers emits
two rows, and DISTINCT would stop the view merging into the caller's query
at 11x the cost. Both readers already collapse duplicates.
The ANALYZE after the backfill is load-bearing. Without sampled statistics
the optimizer estimates thousands of rows per lookup and picks a worse join
order for the rest of the list query, leaving the gallery slower than before
this ran.
Fixes#4391
Related to #4382
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>