A game added today had no edges until the 5:30 AM rebuild, so its "Similar
games" section was empty and nothing could reach it from a feed.
`build_for` scores a handful of ROMs against the current library instead of
sweeping every pair, and folds them into the stored neighbour lists of the
games they matched so the new game is reachable from both directions. The
full build is the same sweep with every ROM as a target, so the two paths
share one implementation rather than drifting.
The scan hands over the ids it wrote. Past MAX_TOP_UP_ROMS the incremental
path saves nothing, so that case queues a rebuild rather than blocking the
scan on work a rebuild would redo.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The engine carried its tuning history in its comments: measurement logs for
PIVOT_B, the weight a facet held before the company split, the shape of the
cold-start feed before the Bayesian average. None of that describes what the
code does now, and it belongs in the history rather than beside the values.
Also folds serving's ROM loader into feed's, which differed only by the
visibility filter applied afterwards.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Merge 0123/0124/0125 into one migration. Each added STORED generated
columns to `roms`, and 0125 already dropped and re-added several, so
upgrading rewrote the widest table three times and restated the
`roms_metadata` view three times. One ALTER TABLE now carries the Steam
rebuild, the three IGDB tag columns and the rating count, and the view is
recreated once. Verified upgrade/downgrade/upgrade on MariaDB and Postgres.
Score each unordered pair once. Candidate generation is symmetric, so
every pair had its dot product computed twice. The sweep now runs in
ascending id order and scores only from the lower id, which also makes a
ROM's edges final the moment the sweep passes it, so the incremental
flush survives. Only the target's quality bonus differs by direction, so
one content score is blended twice. The per-ROM candidate ceiling moves
into `candidate_ids`, taking the rarest posting lists first, where it
bounds work instead of being applied after the cost was already paid.
Read identity off one list. `sibling_roms` decides "same title" from
seven provider ids; the suppression here used two, so a pair matched only
by MobyGames was a sibling everywhere else in RomM and a recommendation
for itself here. `IDENTITY_ID_FIELDS` on the model is now the one home,
consumed unscoped by the builder since a reissue on other hardware is no
more a suggestion than a second copy on the same platform.
Make the facet vocabulary a StrEnum. It was spelled out in five places,
two of them already stale, and `facet: str` kept it out of the API
contract, so an unmapped facet silently rendered a raw value. It reaches
OpenAPI as a closed union and the frontend maps are keyed by it, so
adding a facet now fails the typecheck until the UI handles it.
Give each surface one serving entry point. `similar_roms` and
`recommended_roms` own the over-fetch, hydration, visibility filter,
series cap and cache that the two endpoints and the inspection tool each
re-implemented with three different over-fetch constants; the cache moves
in with them so no caller can rank a feed without populating it.
Endpoints now do ORM-to-schema only.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Backend, wasted work:
- `_score_one` computed `content_similarity` twice per candidate on the
trim path and built `shared_reasons` for every candidate clearing the
score floor, discarding almost all of them. Compute content once and
build reasons only for the edges actually stored.
- `get_feature_rows` outer-joined `RomMetadata`, a view over the wide
`roms` table, defeating the point of reading the narrow facet mirror.
Read the generated columns off the `Rom` join already present.
- Feed cache invalidation ran a keyspace SCAN on every `rom_user` write.
Put graph and per-user version counters in the key so it is one INCR,
matching `invalidate_filter_values_cache`.
Backend, reuse:
- Route the five name comprehensions beside `_expanded_names` through it.
- `_recency_factor` reimplemented `to_utc`.
- `replace_similarity_edges` hand-rolled `itertools.batched`.
- Derive `TASTE_FACETS` from `FACET_WEIGHTS` instead of restating its keys.
Backend, dead code:
- `ScoredNeighbour`, `BuildStats.to_dict`, `delete_all_similarity_edges`,
the unread `difficulty`/`completion`/`backlogged` affinity fields,
`FACET_ORDER` and `RomInfo.rom_id`, and a no-op `column_type` ternary.
Frontend:
- Extract `RecommendationReason` from the two byte-identical copies in
`Home.vue` and `SimilarGamesGrid.vue`, dropping the repeated
`primaryReason` calls and their non-null assertions.
- Cap the caption with `--r-card-art-w` rather than a `158px` literal that
does not track the per-breakpoint card width.
- Key the similar-games fetch on the ROM id: `watchEffect` refetched on
every optimistic mutation of `currentRom`.
- One home for the similar-games limit.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The duplicate check keyed on igdb_id alone, so two copies of one Steam
game with no IGDB match (a bundle and a standalone, an installer and a
portable) could recommend each other and take two slots. Each ROM now
carries a set of provider:id tokens from every identity provider that
matched it, and two ROMs sharing any token are one game.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Drop a comment that narrated the per-series cap changing rather than
describing what the cap does, merge two adjacent comments in the builder
that both explained candidates colliding with each other, and refresh the
library statistics quoted in the migrations and the backfill tool so they
match the shelf the numbers were last taken from.
The two measurements in `scoring.py` still cite the 12.7k library they were
run on, since that is where they were run.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The second pass deduped candidates against each other by igdb_id but
compared titles only against the source, and IGDB gives every port its
own id. A shelf holding Monopoly on both the GB and the NES spent two of
six slots naming the same game.
Found by sampling the index at random rather than by reading the code:
it was the first entry of a 40-game sample.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`companies` flattens every IGDB involvement role into one list, so the studio
that made a game is indistinguishable from the label that shipped it or the
regional distributor that boxed it. Those carry very different weight: a
studio's games genuinely resemble each other, while a publisher spans
everything it ever released.
It is not a marginal distinction. On a 12.7k-game library the second most
common "company" is Tec Toy, Sega's Brazilian distributor, on 768 games, with
Playtronic (Nintendo's) on 350 -- dense enough that IDF does not suppress
them, so matches were coming out as "same distributor". Super Metroid's
cross-franchise suggestions were all justified by Playtronic.
IGDB returns developer/publisher booleans on involved_companies and the
scanner never requested them. Requesting them turns that noise into signal:
Super Metroid now matches on Nintendo R&D1, the studio behind it, Super Mario
Land and Wario Land. Gunstar Heroes returns Alien Soldier and Dynamite Headdy
-- the rest of Treasure's catalogue.
Developer keeps the 0.7 the merged facet already carried, so splitting the
roles redistributes that weight rather than adding new influence, and
publisher drops to 0.25. Sweeping developer from 1.0 to 0.4 barely moved
anything: a tight studio's games also share genre and theme, so the developer
token is not what carries them. The one place it shows is a wide-ranging
studio -- Tony Hawk's Pro Skater now surfaces Neversoft's unrelated titles
where it used to find other skateboarding games through a keyword.
`companies` is untouched for display, and the scorer falls back to it when a
game was matched by a provider that reports no roles, so emitting both never
double-counts one studio. Coverage is 72% developers and 78% publishers,
ahead of every facet already in use.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The per-series cap keyed on a game's first franchise. IGDB lists franchises
in no stable order and a game often carries several, so one series split
across several counters and each spelling got its own allowance.
Sports libraries show it worst, since they hold every yearly release. Madden
titles carry both "Madden" and "NFL": some resolved to one, some to the other,
and a cap of two returned four Madden games. Tony Hawk's Pro Skater 2 returned
four Tony Hawks, and Mario Kart 64 filled its remaining slots with Mario Golf
and Mario Tennis via the broader "Mario" franchise.
A candidate is now measured against every franchise and collection it lists,
and is held back if any one of them is already at the cap. The same fix
applies to the build-time reservation, which picked its slots the same way.
The three now return two same-series entries followed by something else:
NCAA Football and Tiger Woods for Madden, Skate It and Grind Session for Tony
Hawk (matched on the skateboarding keyword), F-Zero X and Wave Race for Mario
Kart.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
IGDB carries three descriptors the scanner never requested: community
keywords ("metroidvania", "shmup"), curated themes (Horror, Survival, Open
world) and player perspectives (Side view, First person). They describe how a
game plays, which genre and franchise cannot: on a 12.7k library only these
three connect Castlevania to Symphony of the Night rather than to the
platformers, Ocarina of Time to Super Mario 64 via Open world, EarthBound to
Chrono Trigger via Fantasy, and GoldenEye to Perfect Dark via Stealth plus
First person.
Coverage beats the existing facets: 66% of matched games carry keywords
against 59% for franchises.
They reach the index the same way every other facet does -- a STORED
generated column, the roms_metadata view, then the trigger-maintained
roms_facets -- so the builder still never reads the wide roms table.
Weight a facet by the values it holds. A game's franchise weight is now split
across however many franchises it carries, so one counts for more than one of
six. Compilations and crossovers previously matched strongly on every
franchise they touched: the SNES Mario compilation pulled in Mario Tennis and
Mario Party ahead of the 2D platformers, and Project X Zone surfaced against
Resident Evil at 0.305 rather than 0.197. Splitting by sqrt rather than the
count keeps three genres worth more in total than one.
Rank keywords last when explaining a match. They are the rarest tokens and so
carry the highest IDF, which had them explaining a Castlevania pairing with
"frankenstein's monster" instead of the shared series.
Existing libraries carry none of this until it is fetched, so
tools/backfill_igdb_tags.py asks IGDB for only the three missing fields in
batches of 500 -- 12,118 games in 36 seconds, against the twelve thousand
requests a rescan would make.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Validating the index against a 12.7k-game library surfaced four problems a
synthetic fixture could not, because each depends on the shape of real
metadata.
Stop penalising well-documented games. Vectors were L2-normalised, on the
assumption that facet counts behave like document length in text retrieval.
They do not: a long document repeating a word is not more relevant, but a game
tagged with three genres and two franchises genuinely has more in common than
one carrying a single tag. Normalising by a vector's own length made every top
match a sparsely-tagged entry -- a Mario compilation matched Golf, F-1 Race and
Pinball (6-8 tokens each) while the actual Mario platformers (12-16 tokens)
were nowhere in the list. Scaling by the library average instead returns
Yoshi's Island, Super Mario 64 and Donkey Kong.
Two hypotheses were measured and rejected on the way: franchise coherence via
genre entropy (Metroid scored higher than Mario, so no signal) and the
franchise/genre weight ratio (five configurations, none of which moved the
result).
Suppress duplicates against each other, not just against the source. Two discs
of one release share an igdb_id and platform, so both took a slot in the same
list. The same game ported to another platform gets its own igdb_id, so it
needs a title comparison rather than an id one.
Diversify across series. Similarity ranking alone made the section a franchise
filter -- five Metroid games for Super Metroid. Slots are reserved at build
time so the stored graph always carries cross-series options, and the per-
series cap is applied when serving so the policy can change without a rebuild.
Capped-out entries backfill a short list in score order.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Recommendations came straight from IGDB's `similar_games`, which mostly
names titles the server does not hold and is absent entirely for anything
IGDB never matched.
`rom_similarity` holds a precomputed item-item graph blending four signals:
IDF-weighted metadata overlap, the IGDB prior resolved against the library,
collection co-membership and co-play. Scores are library-relative, so a
shelf full of arcade games learns on its own that "Action" says nothing
while "Metroidvania" says a great deal, with no tuning.
Each edge stores the facets that produced it, so the UI can explain a
recommendation rather than showing an unattributed row of covers.
Candidate generation runs off an inverted index with a document-frequency
cap, avoiding the all-pairs comparison. The graph is rebuilt wholesale by a
scheduled task because the IDF weighting shifts as the library grows, and
writes commit in batches so a task that dies leaves stale edges rather than
an empty table.
The personalised feed is ranked on demand from those edges plus live play
history, since a nightly feed would ignore the game played an hour ago.
Ratings below the scale midpoint act as negative seeds, results are
diversified per franchise and platform, and owned-but-unplayed games are
boosted.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>