Merge pull request #4884 from rommapp/ccr-6d26a349-25wwvx

Remove the no-emdash Trunk linter after a one-time sweep
This commit is contained in:
Georges-Antoine Assi
2026-09-28 13:16:13 -04:00
committed by GitHub
28 changed files with 106 additions and 123 deletions

View File

@@ -1,9 +1,9 @@
---
name: backend-development
description: Working on the RomM Python backend (backend/) — a FastAPI app with SQLAlchemy 2.0, Alembic, RQ/Redis, and Socket.IO. Use when adding or changing API endpoints, handlers, ORM models, response schemas, metadata-provider adapters, background tasks, database migrations, or backend tests. Covers the layered architecture, conventions, auth/scopes, the OpenAPI→frontend type pipeline, and the uv/pytest/alembic/trunk workflow. Trigger on any work under backend/.
description: Working on the RomM Python backend (backend/), a FastAPI app with SQLAlchemy 2.0, Alembic, RQ/Redis, and Socket.IO. Use when adding or changing API endpoints, handlers, ORM models, response schemas, metadata-provider adapters, background tasks, database migrations, or backend tests. Covers the layered architecture, conventions, auth/scopes, the OpenAPI→frontend type pipeline, and the uv/pytest/alembic/trunk workflow. Trigger on any work under backend/.
---
# RomM Backend — FastAPI / SQLAlchemy
# RomM Backend: FastAPI / SQLAlchemy
Python 3.14+, FastAPI, SQLAlchemy 2.0 (MariaDB default; MySQL/PostgreSQL supported), Alembic, Redis + RQ for jobs/cache/sessions, Socket.IO for real-time. Managed with **uv**.
@@ -11,7 +11,7 @@ Full reference: **`docs/BACKEND_ARCHITECTURE.md`** (directory map, ER diagram, e
---
## Layered architecture — where code goes
## Layered architecture: where code goes
```txt
endpoints/ FastAPI routers: request validation, response schemas, @protected_route scopes
@@ -24,7 +24,7 @@ handler/ Business logic, decoupled from HTTP
└ filesystem/ ROM/asset/firmware file I/O, hashing, archive extraction
adapters/services/ Typed external API clients (igdb.py + igdb_types.py, screenscraper.py, …)
models/ SQLAlchemy ORM models (BaseModel adds created_at/updated_at)
tasks/ RQ jobs — scheduled/ (cron) and manual/ (on-demand); base classes in tasks.py
tasks/ RQ jobs, scheduled/ (cron) and manual/ (on-demand); base classes in tasks.py
config/ Env-var loading (__init__.py) + YAML config manager (singleton)
decorators/ @begin_session (DB session), @protected_route (auth + scopes)
exceptions/ Custom exception hierarchy
@@ -48,7 +48,7 @@ alembic/ Migrations (env.py + versions/)
- Roles: `VIEWER` (read), `EDITOR` (+write roms/platforms/assets), `ADMIN` (+users/tasks/logs). Defined on `models/user.py`; scope tiers in `handler/auth/constants.py`.
- Granular scopes: `me.read/write`, `roms.read/write`, `platforms.*`, `assets.*`, `devices.*`, `firmware.*`, `collections.*`, `users.*`, `tasks.run`, `logs.read`.
- Protect routes with `@protected_route(router.<method>, "<path>", [Scope.X])`. The frontend mirrors these scopes — keep them aligned.
- Protect routes with `@protected_route(router.<method>, "<path>", [Scope.X])`. The frontend mirrors these scopes; keep them aligned.
## Adding things
@@ -60,7 +60,7 @@ alembic/ Migrations (env.py + versions/)
## Database migrations (Alembic)
Migrations must work on **MariaDB, MySQL, and PostgreSQL** (CI runs `alembic upgrade head` on Postgres and MariaDB — `.github/workflows/migrations.yml`). Use batch mode / DB-specific SQL where needed; mirror existing migrations in `alembic/versions/`.
Migrations must work on **MariaDB, MySQL, and PostgreSQL** (CI runs `alembic upgrade head` on Postgres and MariaDB; see `.github/workflows/migrations.yml`). Use batch mode / DB-specific SQL where needed; mirror existing migrations in `alembic/versions/`.
```bash
cd backend
@@ -69,7 +69,7 @@ uv run alembic upgrade head # apply
uv run alembic downgrade -1 # verify the downgrade works
```
Always review autogenerated migrations — they miss server-default/enum/index nuances and cross-dialect differences. The `virtual_collections` DB view is excluded from migrations.
Always review autogenerated migrations: they miss server-default/enum/index nuances and cross-dialect differences. The `virtual_collections` DB view is excluded from migrations.
### Migration hygiene (recurring review fixes)

View File

@@ -3,9 +3,9 @@ name: frontend-i18n
description: Internationalization for the RomM frontend (both v1 and v2). Use whenever adding, renaming, or removing any user-visible string / translation key under frontend/src/locales/. Covers the en_US-is-source rule, the requirement to add every new key to ALL locale directories in the same change, namespace layout, and the check_i18n_locales.py validator enforced in CI. Trigger on any change to frontend/src/locales/**.
---
# RomM Frontend — i18n / Localization
# RomM Frontend: i18n / Localization
User-visible strings are **never hard-coded** in components — they come from locale files via `vue-i18n` (`$t(...)` in templates/composites; utils may call `i18n.global.t(...)`; **v2 lib primitives must not call `$t` at all** — text passes via props/slots).
User-visible strings are **never hard-coded** in components; they come from locale files via `vue-i18n` (`$t(...)` in templates/composites; utils may call `i18n.global.t(...)`; **v2 lib primitives must not call `$t` at all**, text passes via props/slots).
## Structure
@@ -17,9 +17,9 @@ User-visible strings are **never hard-coded** in components — they come from l
- **`en_US` is the source of truth**, but **every key added to `en_US` must be added to all other locale directories in the same change.** Never leave a key English-only.
- **`en_US` uses US spelling**: "favorites", "color", "canceled". British forms belong in `en_GB` only. This bites tests too: an e2e or unit assertion on a label must expect the `en_US` string.
- **Actually translate the value into each locale's language** — never paste English into non-English locales.
- **Actually translate the value into each locale's language**: never paste English into non-English locales.
- Editing an existing string counts: changing `en_US` means re-translating that key in every other locale.
- Reuse each locale's established terms — grep a sibling key for how it renders "metadata", "provider", etc.
- Reuse each locale's established terms: grep a sibling key for how it renders "metadata", "provider", etc.
- Copying the English value is a last-resort placeholder, only when no translation is available, and must be flagged to revisit.
- Removing or renaming a key means doing it across **every** locale.

View File

@@ -1,11 +1,11 @@
---
name: frontend-v2-components
description: Building or modifying components in the RomM v2 frontend (frontend/src/v2/). Use when creating/editing v2 primitives (R* components in src/v2/lib/), shared composites, or feature composites — covers the three-tier model, file/folder conventions, SFC structure, import order, barrels, Storybook requirements, and v2 anti-patterns. Trigger on any work under frontend/src/v2/.
description: Building or modifying components in the RomM v2 frontend (frontend/src/v2/). Use when creating/editing v2 primitives (R* components in src/v2/lib/), shared composites, or feature composites. Covers the three-tier model, file/folder conventions, SFC structure, import order, barrels, Storybook requirements, and v2 anti-patterns. Trigger on any work under frontend/src/v2/.
---
# RomM Frontend v2 — Component Constitution
# RomM Frontend v2: Component Constitution
This governs work inside `frontend/src/v2/`. **v1 is frozen** (`src/views/`, `src/components/`, `src/console/`, `src/layouts/`) — never refactor it; it will be deleted wholesale in a final wave. v2 is gated by `user.ui_settings.uiVersion`.
This governs work inside `frontend/src/v2/`. **v1 is frozen** (`src/views/`, `src/components/`, `src/console/`, `src/layouts/`); never refactor it; it will be deleted wholesale in a final wave. v2 is gated by `user.ui_settings.uiVersion`.
> Official language for all code, comments, identifiers, `.md`, and commit/PR messages: **English**.
@@ -17,7 +17,7 @@ Related skills: `frontend-v2-theming` (tokens/colors), `frontend-v2-input` (focu
1. **v1 is frozen.** Don't touch `src/views/`, `src/components/`, `src/console/`, `src/layouts/`. When coexistence forces a v2 fork of a store/composable/util, annotate the v1 export with `@deprecated` pointing at the v2 replacement.
2. **Three component tiers** (below).
3. **Shared resources are canonical.** Pinia stores, API services, OpenAPI types (`src/__generated__/`), locales, utils — v2 _imports_ them, never forks them. Additive changes to shared resources are allowed; changing a shared store API to work around a v2 call-site issue is not.
3. **Shared resources are canonical.** Pinia stores, API services, OpenAPI types (`src/__generated__/`), locales, utils: v2 _imports_ them, never forks them. Additive changes to shared resources are allowed; changing a shared store API to work around a v2 call-site issue is not.
4. **TypeScript strict.** Zero `any` (justify with a comment if unavoidable). No `as unknown as ...`; fix the source or define an intermediate type.
5. **Universal substitution.** When an `R*` primitive exists, use it. If it doesn't, create or extend it. Never drop to raw HTML when a primitive applies.
6. **Attribute forwarding contract.** A primitive whose root is polymorphic (`<component :is>`) or that forwards to an inner element uses `defineOptions({ inheritAttrs: false })` + `v-bind="$attrs"` + slot passthrough, so call-site attrs and listeners land on the intended node instead of vanishing silently.
@@ -38,7 +38,7 @@ Related skills: `frontend-v2-theming` (tokens/colors), `frontend-v2-input` (focu
1. Does not depend on stores, services, router, or emitter.
2. No knowledge of a product domain (ROM, Platform, Collection, User…). `RAvatar` yes, `UserAvatar` no.
3. Its API can be described without naming features — generic props/slots/events.
3. Its API can be described without naming features: generic props/slots/events.
If any fails: **shared composite** if generic across features, **feature composite** if owned by one feature. Edge cases get raised to the user, not auto-decided. Consumer count never demotes a primitive.
@@ -62,9 +62,9 @@ If any fails: **shared composite** if generic across features, **feature composi
## File & folder conventions
- **Primitive**: one per folder — `RFoo/RFoo.vue`, `RFoo/RFoo.stories.ts`, `RFoo/index.ts`, optional `RFoo/types.ts`.
- **Primitive**: one per folder: `RFoo/RFoo.vue`, `RFoo/RFoo.stories.ts`, `RFoo/index.ts`, optional `RFoo/types.ts`.
- **Composite**: flat `.vue` if one file suffices; a folder with the same internal structure (no story required) if it has sub-pieces.
- **Barrel**: `src/v2/lib/index.ts` re-exports every primitive — update it when a new primitive ships. Composites are imported directly by path; no barrel. No single-file `index.ts` that just re-exports to shorten a path.
- **Barrel**: `src/v2/lib/index.ts` re-exports every primitive; update it when a new primitive ships. Composites are imported directly by path; no barrel. No single-file `index.ts` that just re-exports to shorten a path.
### SFC structure
@@ -90,7 +90,7 @@ import GameCard from "@/v2/components/GameCard.vue";
import { useCan } from "@/v2/composables/useCan";
```
- `@v2/lib` — primitives barrel. `@/v2/...` — anything else under v2. `@/...` — canonical shared resources. Never relative paths (`../../foo`) when an alias exists.
- `@v2/lib`: primitives barrel. `@/v2/...`: anything else under v2. `@/...`: canonical shared resources. Never relative paths (`../../foo`) when an alias exists.
- Shared v2 types live in `src/v2/types/`; backend types come from `src/__generated__/`; not `src/types/` (legacy).
### Composables
@@ -99,7 +99,7 @@ import { useCan } from "@/v2/composables/useCan";
### Console logging
- `console.error` allowed for production-visible errors. `console.log`/`console.warn` must not ship. `console.debug` is dev-only — remove before PR.
- `console.error` allowed for production-visible errors. `console.log`/`console.warn` must not ship. `console.debug` is dev-only; remove before PR.
---
@@ -116,8 +116,8 @@ import { useCan } from "@/v2/composables/useCan";
## Anti-patterns (beyond what the premises already say)
1. Don't change shared store APIs to work around a v2 call-site issue. (Fix the call site; the Gallery lesson was calling `romsStore.reset()` from the view, not adding `_fetchSeq` to the store.)
2. Don't drop to inline role checks — always go through `useCan` (see `frontend-v2-patterns`).
3. Don't reinvent a surface — dialog/menu/popover/card all go through their primitive; special cases become a new prop, not a parallel surface.
2. Don't drop to inline role checks; always go through `useCan` (see `frontend-v2-patterns`).
3. Don't reinvent a surface: dialog/menu/popover/card all go through their primitive; special cases become a new prop, not a parallel surface.
4. Don't hand-roll a `<form>`; use `RForm`.
5. Don't add backwards-compat shims inside v2: delete removed code; no `// removed`, no renamed-but-unused exports, no deprecated wrappers that just call the new function.
6. Don't write redundant tests; don't touch v1; never `--no-verify` on commits.

View File

@@ -3,9 +3,9 @@ name: frontend-v2-input
description: Universal input (mouse, touch, keyboard, gamepad) and responsive/universal-viewport layout in the RomM v2 frontend. Use when adding interactive v2 components, focus management, spatial navigation, gamepad/keyboard handling, modality-gated focus rings, breakpoints, or responsive layout. Covers useInput, focus geometry primitives, the overlay scope stack, useBreakpoint, and the data-bp/data-input attributes. Trigger on interactive or responsive work under frontend/src/v2/.
---
# RomM v2 — Universal Input & Universal Viewport
# RomM v2: Universal Input & Universal Viewport
**Premise:** all v2 UI works with mouse, touch, keyboard, **and** gamepad; and every surface reads cleanly from a 320px phone to a 4K display. Both mechanisms are fixed — don't invent a parallel one.
**Premise:** all v2 UI works with mouse, touch, keyboard, **and** gamepad; and every surface reads cleanly from a 320px phone to a 4K display. Both mechanisms are fixed; don't invent a parallel one.
The input system lives in `src/v2/composables/useInput/` (bus, keyboard, gamepad, actions, scope). It generalises the original gamepad-only `src/console/` system. There are **no `/console/*` routes in v2**.
@@ -15,12 +15,12 @@ The input system lives in `src/v2/composables/useInput/` (bus, keyboard, gamepad
`useInputModality` sets `data-input="mouse|touch|key|pad"` on `<html>` from the most recent input.
- **Focus rings appear only with `key` and `pad`** (CSS in `global.css`). **Never use bare `:focus` in styles** — use the modality-gated selectors, or focus rings flash on mouse click.
- **Focus rings appear only with `key` and `pad`** (CSS in `global.css`). **Never use bare `:focus` in styles**; use the modality-gated selectors, or focus rings flash on mouse click.
- **Modality gates appearance and behaviour, never size**: focus rings, hover-reveal, autofocus. A tap is followed by compatibility mouse events, so anything sized off `data-input` resizes under the finger. Hit targets scale by breakpoint instead (below).
## Coverage — every interactive primitive participates
## Coverage: every interactive primitive participates
Buttons, list items, tabs, menu items, focusable cards, toggleable chips — all participate in spatial navigation (not optional). A new interactive primitive must:
Buttons, list items, tabs, menu items, focusable cards, toggleable chips: all participate in spatial navigation (not optional). A new interactive primitive must:
- be focusable (a natively focusable element, or a proper `tabindex`);
- react to logical actions (confirm/cancel) from `useInput`, in addition to native click;
@@ -42,7 +42,7 @@ Above per-view geometry, some elements bind globally regardless of focus locatio
## Scope (overlay stack)
When a dialog opens, push a scope; when it closes, pop. This stops Escape from closing two things at once and stops `confirm` leaking to controls beneath an overlay. `RDialog` and `RMenu` manage their scope automatically — custom overlays are an anti-pattern; go through the primitives.
When a dialog opens, push a scope; when it closes, pop. This stops Escape from closing two things at once and stops `confirm` leaking to controls beneath an overlay. `RDialog` and `RMenu` manage their scope automatically; custom overlays are an anti-pattern; go through the primitives.
---
@@ -50,7 +50,7 @@ When a dialog opens, push a scope; when it closes, pop. This stops Escape from c
- **Single breakpoint source: `useBreakpoint`** (`src/v2/composables/useBreakpoint/`). Material thresholds: `xs <600`, `sm 600–959`, `md 960–1279`, `lg 1280–1919`, `xl ≥1920`. `installBreakpointAttribute()` mirrors the active set onto `<html data-bp="…">` (from `AppLayout` and `AuthLayout` in the app, and from `.storybook/preview.ts` so stories match production CSS).
- **Layout switches live in CSS** via the attribute selector: `html[data-bp~="xs"] .foo { … }`, `html[data-bp~="sm-and-down"] .foo { … }`. **No raw `@media` for layout**: the only allowed `@media` are `prefers-reduced-motion` and print. The attribute is on `<html>` so it reaches teleported overlays. `romm/no-layout-media-query` (ESLint) enforces this in SFC styles.
- **Conditional rendering** (mount/unmount a different component per tier) uses the `useBreakpoint()` refs in `<script>` — e.g. `v-if="xs"`. Prefer mount-gating over `display:none` for focusable chrome so hidden controls never sit in the tab/spatial-nav order.
- **Conditional rendering** (mount/unmount a different component per tier) uses the `useBreakpoint()` refs in `<script>`, e.g. `v-if="xs"`. Prefer mount-gating over `display:none` for focusable chrome so hidden controls never sit in the tab/spatial-nav order.
- **`--r-row-pad` is the global horizontal gutter**, already re-scoped responsive in `global.css` (36 → 20 → 14px). Consume `var(--r-row-pad)`; don't hard-code a smaller `xs` padding per component.
- **Touch targets** scale with the breakpoint, never with `data-input`: `--r-touch-target` (44px) at `sm-and-down`, less only where the row would not fit.
- **Overlays go full-bleed on `xs`.** `RDialog` renders full-screen / bottom-sheet on phones (`fullscreenOnMobile`, default on); `RMenu` bottom-sheets large menus. Never float a 600px dialog on a 360px screen.

View File

@@ -1,11 +1,11 @@
---
name: frontend-v2-patterns
description: Cross-cutting feature patterns for the RomM v2 frontend — error/snackbar handling, loading & skeleton states, real-time Socket.IO updates, UI state persistence (URL vs localStorage vs ephemeral), pagination/infinite scroll, forms & validation, permissions (useCan), and destructive confirmations. Use when wiring up a v2 feature's behavior (not just its markup). Trigger when implementing data flows, dialogs, forms, toggles, or permission gating under frontend/src/v2/.
description: Cross-cutting feature patterns for the RomM v2 frontend: error/snackbar handling, loading & skeleton states, real-time Socket.IO updates, UI state persistence (URL vs localStorage vs ephemeral), pagination/infinite scroll, forms & validation, permissions (useCan), and destructive confirmations. Use when wiring up a v2 feature's behavior (not just its markup). Trigger when implementing data flows, dialogs, forms, toggles, or permission gating under frontend/src/v2/.
---
# RomM v2 — Architecture Patterns
# RomM v2: Architecture Patterns
How v2 features behave. Each pattern has one canonical mechanism — don't invent a parallel one.
How v2 features behave. Each pattern has one canonical mechanism; don't invent a parallel one.
---
@@ -13,7 +13,7 @@ How v2 features behave. Each pattern has one canonical mechanism — don't inven
- Single channel: `useSnackbar()` (`src/v2/composables/useSnackbar/`) with `success | error | warning | info` methods. It emits `snackbarShow`; `NotificationHost` stacks toasts.
- Something the user should still find after the toast fades (a background upload finished, a long job failed) passes `{ persist: true }`, or `{ persist: { body, link } }` with an in-app path: it also lands in their notifications.
- The **call site** decides what's significant — no global "wrap-every-promise" magic.
- The **call site** decides what's significant; no global "wrap-every-promise" magic.
- Field validation errors render **in-place**, never as a snackbar.
- Auth (401/403) is handled by the axios interceptor; no per-call-site checks.
- Successful critical actions → `success` snackbar. Routine optimistic toggles → silent on success, `error` on failure.
@@ -21,22 +21,22 @@ How v2 features behave. Each pattern has one canonical mechanism — don't inven
## B. Loading states
- **Skeleton** (`RSkeletonBlock`) for first load of a view with known layout — mimic the real shape so the layout doesn't jump.
- **Skeleton** (`RSkeletonBlock`) for first load of a view with known layout; mimic the real shape so the layout doesn't jump.
- **Inline `:loading` on the control itself** for in-flight actions (`RBtn`, `RTextField`, `RSelect`). Never put an external `RSpinner` next to a button that has its own `loading`.
- **`RSpinner` inline** when what's loading isn't a control with native `loading`.
- **Determinate progress (%)**: use `RProgressLinear` — no raw `v-progress-linear`.
- **Determinate progress (%)**: use `RProgressLinear`, not raw `v-progress-linear`.
- **Empty state ≠ loading state.** Zero items is its own UX (message, illustration, optional CTA).
- **Optimistic toggles show no spinner**: flip immediately; on failure, revert + snackbar.
- `RBtn` ships `loadingDebounce={200}` — actions resolving under 200ms never paint a spinner; loading→not-loading is immediate.
- `RBtn` ships `loadingDebounce={200}`: actions resolving under 200ms never paint a spinner; loading→not-loading is immediate.
## C. Real-time updates (Socket.IO)
- One instance: `src/services/socket.ts`. Never `new io()`.
- Subscriptions go through `useSocketEvent(event, handler)` (`src/v2/composables/useSocketEvent/`): typed payload, auto-connect by default (`{ connect: false }` opts out), cleanup via `onScopeDispose` so it also works inside a store action or a manual `effectScope`. No v2 code wires `socket.on/off` by hand; don't start.
- **Ownership rule:** state living only while a view is open → subscribe in the view; state that must outlive a view (e.g. scan badge in navbar) → a Pinia store subscribes globally and views just read.
- Reconnection is socket.io's job — don't roll your own.
- Reconnection is socket.io's job; don't roll your own.
## D. UI state persistence — three layers
## D. UI state persistence: three layers
1. **Persistent preferences** (theme, language, gallery defaults like `groupRoms`/`boxartStyle`, Home panels) → `useUISettings` (localStorage + backend `user.ui_settings` two-way sync). Add a key to `UI_SETTINGS_KEYS`.
2. **Bookmarkable session state** (active filters, search query, sort, current tab in detail views) → **URL query params**. Anyone copying the link reproduces what they see. **Active gallery filter must be in URL.**
@@ -84,7 +84,7 @@ Name a helper for what it touches: `syncCachedRom`, not `syncRom`, when it updat
- **`useCan(action, scope?)`** returns `ComputedRef<boolean>`, reactive to `permissionsStore.grants`. Without scope: "can do this anywhere."
- `stores/permissions.ts` holds normalised grants, hydrated from `authStore.user.role` via the role-map (`installPermissionsHydration()` in `AppLayout`); a future `/permissions/me` will replace it.
- **`v-if`** to hide options a user shouldn't see; **`:disabled`** with tooltip when the option must be visible but blocked.
- **Backend is source of truth** — frontend is a UX hint. Never bypass with inline `user.role === "..."`. All grants are pre-loaded (no `useCanAsync`).
- **Backend is source of truth**: frontend is a UX hint. Never bypass with inline `user.role === "..."`. All grants are pre-loaded (no `useCanAsync`).
## H. Destructive confirmations
@@ -95,7 +95,7 @@ Three friction levels:
Common rules:
- All destruction goes through a dialog — no silent destructive action.
- All destruction goes through a dialog; no silent destructive action.
- Confirm button is danger-toned; **focus starts on Cancel**; Enter cancels.
- Success → success snackbar or navigate away, dialog closes. Error → error snackbar, dialog stays open. During action → confirm shows `:loading`, cancel disabled.
- The destructive control respects `useCan(action, scope)`.

View File

@@ -3,7 +3,7 @@ name: frontend-v2-theming
description: Theming, design tokens, colors, and visual language in the RomM v2 frontend. Use when styling v2 components, picking colors, adding/using CSS variables, working with light/dark themes, or whenever you'd reach for a hex/rgba literal. Covers the token pipeline (src/v2/tokens/index.ts → build:tokens → tokens.css), the .r-v2 scope classes, the zero-hex-literal policy, and shared state semantics. Trigger on any color/theme/token work under frontend/src/v2/.
---
# RomM v2 — Tokens, Theming & Visual Language
# RomM v2: Tokens, Theming & Visual Language
**Tokens are the only source of truth for theming. Zero hex/`rgba()` literals in v2 components.** If a value is missing, add a token. Every component must work in both `v2-dark` and `v2-light`.
@@ -13,8 +13,8 @@ description: Theming, design tokens, colors, and visual language in the RomM v2
`src/v2/tokens/index.ts` is the source. It feeds two consumers:
- **`src/v2/styles/tokens.css`** — _generated_ by `scripts/build-tokens.ts` (`npm run build:tokens`, hooked into `predev`/`prebuild`). **Do not hand-edit.** This is how the vast majority of tokens are consumed: `var(--r-color-...)` in CSS.
- **Direct JS/TS imports** of named exports (`colorCanvas`, `colorCoverArt`, `layout`, …) for the few cases needing a token value in JavaScript — baking colors into an SVG string (`utils/covers`), canvas/QR backgrounds (`Player/Ruffle.vue`, `ShowQRCodeDialog`), and the virtualiser's pixel math (`Gallery/listColumns` reading `layout`).
- **`src/v2/styles/tokens.css`**: _generated_ by `scripts/build-tokens.ts` (`npm run build:tokens`, hooked into `predev`/`prebuild`). **Do not hand-edit.** This is how the vast majority of tokens are consumed: `var(--r-color-...)` in CSS.
- **Direct JS/TS imports** of named exports (`colorCanvas`, `colorCoverArt`, `layout`, …) for the few cases needing a token value in JavaScript: baking colors into an SVG string (`utils/covers`), canvas/QR backgrounds (`Player/Ruffle.vue`, `ShowQRCodeDialog`), and the virtualiser's pixel math (`Gallery/listColumns` reading `layout`).
v2 has **no Vuetify theme of its own**, and no Vuetify at all. `tokens.css` emits a palette block per theme under `.r-v2.r-v2-dark` / `.r-v2.r-v2-light`; `RomM.vue` toggles those classes on `<html>`. v2 surfaces never read Vuetify's runtime theme (`src/plugins/vuetify.ts` serves v1 only).
@@ -26,27 +26,27 @@ v2 has **no Vuetify theme of its own**, and no Vuetify at all. `tokens.css` emit
4. Run `npm run build:tokens` to regenerate `tokens.css`.
5. If the JS→CSS variable name needs an exception (e.g. `--r-nav-h`), add an entry to `NAME_OVERRIDES` in the generator.
### Where the scope classes live — and why `<html>`
### Where the scope classes live, and why `<html>`
`.r-v2`, `.r-v2-dark`, `.r-v2-light` go on `<html>` (`RomM.vue` toggles them whenever `uiVersion` or the active theme changes). The overlay primitives (`RDialog`, `RMenu`, `RTooltip`) `<Teleport to="body">`, landing **outside** the app root. Only `<html>` covers both the regular tree and the teleports; without it, overlays lose their tokens.
### Diagnostics — when `var(--r-color-...)` resolves to nothing on an overlay
### Diagnostics: when `var(--r-color-...)` resolves to nothing on an overlay
1. Check `RomM.vue`'s watch on `documentElement.classList` (load-bearing).
2. Check that the teleport target is attached to the document. `<html>` is the document root, so any in-document target inherits the scope; a detached node resolves no `var(--r-*)` at all.
3. **Never** "fix" it by swapping the token for a hex literal — that hides the bug and breaks the dual theme.
3. **Never** "fix" it by swapping the token for a hex literal; that hides the bug and breaks the dual theme.
---
## Visual language
1. **Single visual vocabulary.** Every surface (dialog, menu, popover, card, toolbar) reads as a sibling — same blur, curvature, depth. No standalone "dialog look" vs "menu look".
1. **Single visual vocabulary.** Every surface (dialog, menu, popover, card, toolbar) reads as a sibling: same blur, curvature, depth. No standalone "dialog look" vs "menu look".
2. **Canonical references when designing**: ask the user before consulting `https://mockup.thebirdcage.tv/`. They decide whether the mockup or existing primitives take priority.
3. **State semantics are shared across primitives** (don't reinvent per component):
- hover (neutral, or brand-tinted on selected rows)
- selected/checked (`--r-color-brand-primary`)
- active/favorite (`--r-color-fav`)
- focus (modality-gated; visible only on `key`/`pad` — see `frontend-v2-input`)
- focus (modality-gated; visible only on `key`/`pad`, see `frontend-v2-input`)
- busy/pending · disabled
4. **Implementation gotchas:**
- Every dialog goes through `RDialog`; every menu through `RMenu`; every tooltip through `RTooltip`. Each owns its teleport and positioning, so don't hand-roll a parallel surface. The scrim and the reference-counted body scroll lock (`lib/overlays/bodyScrollLock.ts`) belong to `RDialog` and `RDrawer` only; menus and tooltips have neither.

View File

@@ -9,7 +9,7 @@ Two passes, in order, once the change works:
1. **Polish (A–D):** shape the code the checks can't see. Derived from the
corrections a maintainer actually pushed on top of 37 approved contributor
PRs — every rule below is something that got hand-fixed after review, so
PRs: every rule below is something that got hand-fixed after review, so
applying it up front saves a round trip.
2. **Verify (E):** run the checks that match what you touched, mirroring the CI
gates so review isn't the first place a failure shows up. Polish comes
@@ -133,7 +133,7 @@ reviewer. For the frontend, that is a stock rule in `eslint.config.js`, or
(`RuleTester`, valid and invalid cases), registered in the plugin's `index.js`
and turned on in `eslint.config.js`. Test with `npx vitest run
eslint-plugin-romm` and `npm run typecheck:scripts`. A plain text pattern across
the repo can be a Trunk regex linter instead (see `no-emdash` in
the repo can be a Trunk regex linter instead (a `definitions` entry in
`.trunk/trunk.yaml`).
---
@@ -141,7 +141,7 @@ the repo can be a Trunk regex linter instead (see `no-emdash` in
## E. Verification before handoff
Run the checks that match what you touched. **Static checks don't prove a
feature works** — when UI changed, also test it in the browser. **Never
feature works**; when UI changed, also test it in the browser. **Never
`--no-verify`.**
**Commit whatever `trunk fmt` rewrites.** A "run fmt" commit landing on top of a
@@ -168,13 +168,13 @@ Run from `frontend/`:
**If you touched locales** (`src/locales/**`): `python3 frontend/src/locales/check_i18n_locales.py` must pass with zero missing/extra keys. See the `frontend-i18n` skill.
#### UI manual pass (when changes are visible) — v2
#### UI manual pass (when changes are visible): v2
With `uiVersion = "v2"`:
- **Golden path + edge cases:** empty, error, loading, no-permission, extreme data; plus nearby regressions.
- **Both themes:** `v2-dark` and `v2-light`.
- **All four input modalities:** mouse, touch, keyboard, gamepad — focus ring only on `key`/`pad`.
- **All four input modalities:** mouse, touch, keyboard, gamepad; focus ring only on `key`/`pad`.
- **Responsive sweep:** 320px → 4K across the `useBreakpoint` tiers; overlays full-bleed on `xs`.
- **Accessibility:** contrast, keyboard reachability with no traps, aria-labels on icon-only controls.
- **Performance:** lists/grids of 1000+ items stay smooth; every `v-for` has a stable `:key`.
@@ -194,7 +194,7 @@ With `uiVersion = "v2"`:
Run from `backend/`:
1. `uv run pytest <path/file>` — zero failures on the tests affected by the diff. Never run the whole suite locally (20+ minutes); see [AGENTS.md](../../../AGENTS.md) for how to pick targets. CI runs it in full.
1. `uv run pytest <path/file>`: zero failures on the tests affected by the diff. Never run the whole suite locally (20+ minutes); see [AGENTS.md](../../../AGENTS.md) for how to pick targets. CI runs it in full.
2. `trunk fmt && trunk check`: ruff/black/isort/bandit clean (CI enforces Trunk).
3. `uv run mypy --config-file ../.trunk/configs/mypy.ini .`: zero errors across the backend (CI enforces it).
4. **If you added a migration:** `uv run alembic upgrade head` then `uv run alembic downgrade -1` to prove both directions; it must work on MariaDB **and** PostgreSQL (CI runs both).

View File

@@ -1,18 +1,18 @@
---
name: security-audit
description: Audit a diff (a release tag range or a PR branch) for anything malicious or a serious security regression before shipping/merging. Use when asked to "check this release", "make sure nothing malicious slipped in", "security review this PR", or vet upstream/contributor changes. Covers supply chain, egress/exfiltration, auth/injection/traversal, CI/infra, and commit provenance — with a fast direct pass plus fanned-out deep review. Trigger on any "is this change safe?" request over a diff.
description: Audit a diff (a release tag range or a PR branch) for anything malicious or a serious security regression before shipping/merging. Use when asked to "check this release", "make sure nothing malicious slipped in", "security review this PR", or vet upstream/contributor changes. Covers supply chain, egress/exfiltration, auth/injection/traversal, CI/infra, and commit provenance, with a fast direct pass plus fanned-out deep review. Trigger on any "is this change safe?" request over a diff.
---
# Security Audit of a Diff
Goal: decide whether a set of changes contains anything **malicious** (backdoor, exfiltration, injection, obfuscated payload, supply-chain tamper) or a serious security **regression** (removed auth/ownership check). Assume most of it is legitimate work — your job is to find the needle if there is one, and give an **honest verdict**, not a vibe.
Goal: decide whether a set of changes contains anything **malicious** (backdoor, exfiltration, injection, obfuscated payload, supply-chain tamper) or a serious security **regression** (removed auth/ownership check). Assume most of it is legitimate work; your job is to find the needle if there is one, and give an **honest verdict**, not a vibe.
Two speeds, both required for anything non-trivial:
1. **Direct pass** (you, fast) — cheap high-signal sweeps that catch the obvious and scope the surface.
2. **Fanned-out deep review** (parallel subagents) — one per surface, reading actual files, when the diff is large.
1. **Direct pass** (you, fast): cheap high-signal sweeps that catch the obvious and scope the surface.
2. **Fanned-out deep review** (parallel subagents): one per surface, reading actual files, when the diff is large.
Don't skip the direct pass even when delegating — it tells you where the risk lives and cross-checks the agents.
Don't skip the direct pass even when delegating: it tells you where the risk lives and cross-checks the agents.
---
@@ -28,15 +28,15 @@ git rev-list --count $RANGE # how many commits
git diff --stat $RANGE | tail -30 # size + what area moved
```
Also pull the human context (release notes / PR description) — new env vars, new endpoints, and new deps named there tell you what to scrutinize.
Also pull the human context (release notes / PR description): new env vars, new endpoints, and new deps named there tell you what to scrutinize.
---
## 2. Direct pass — high-signal sweeps
## 2. Direct pass: high-signal sweeps
Run these yourself. The single most important signal for "malicious" is **unexpected outbound destinations**.
**Egress — every new host/IP/domain in added lines** (exclude lockfiles/tests/generated to cut noise):
**Egress: every new host/IP/domain in added lines** (exclude lockfiles/tests/generated to cut noise):
```bash
git diff $RANGE -- . ':(exclude)*.lock' ':(exclude)**/tests/**' ':(exclude)**/__generated__/**' \
@@ -45,7 +45,7 @@ git diff $RANGE -- . ':(exclude)*.lock' ':(exclude)**/tests/**' ':(exclude)**/__
| sort | uniq -c | sort -rn
```
Every hostname must resolve to a known-legit provider, the app's own origin, or a config-example placeholder. An unrecognized domain/raw IP is the finding — chase it.
Every hostname must resolve to a known-legit provider, the app's own origin, or a config-example placeholder. An unrecognized domain/raw IP is the finding; chase it.
**Code-exec / obfuscation in added lines** (ignore test files):
@@ -62,10 +62,10 @@ Base64/hex blobs, `eval(atob(...))`, hand-obfuscated strings = stop and dig. Sub
git diff $RANGE -- '**/package.json' '**/pyproject.toml' 'uv.lock' '**/package-lock.json' '**/requirements*.txt'
```
- New deps must come from the official registry. Grep the lockfile diff for `git+`, non-`pythonhosted`/`pypi.org` / non-`registry.npmjs.org` URLs, alternate index URLs — any of those is a red flag.
- New deps must come from the official registry. Grep the lockfile diff for `git+`, non-`pythonhosted`/`pypi.org` / non-`registry.npmjs.org` URLs, alternate index URLs; any of those is a red flag.
- Watch for typosquats (name one char off a popular package) and unexpected new transitive sources.
**CI / infra** — these run with secrets, so they're a prime exfil vector:
**CI / infra**: these run with secrets, so they're a prime exfil vector:
```bash
git diff $RANGE -- .github/ '**/Dockerfile' '**/*entrypoint*.sh' docker/ examples/*.yml
@@ -96,9 +96,9 @@ Do this for any non-trivial diff. The direct pass alone only catches what its pa
Typical split:
- **Backend** — new/changed endpoints missing `@protected_route` or with weakened scope/role/ownership checks; removed `assert_*_visible`; command/SQL injection; path traversal in new file ops (delete/upload/download endpoints are prime); SSRF where a request URL is user-influenced; secret handling.
- **Frontend** — off-app `fetch`/`sendBeacon`/`Image().src`/`WebSocket`; token/cookie/localStorage reads sent anywhere off-origin; `eval`/`Function`/`v-html`/`innerHTML`/dynamic `<script>`; external redirects; iframe `src`/`postMessage` trust.
- **Supply chain & provenance** — deps, lockfile sources, CI/infra, binaries, commit authorship (section 2, done thoroughly).
- **Backend**: new/changed endpoints missing `@protected_route` or with weakened scope/role/ownership checks; removed `assert_*_visible`; command/SQL injection; path traversal in new file ops (delete/upload/download endpoints are prime); SSRF where a request URL is user-influenced; secret handling.
- **Frontend**: off-app `fetch`/`sendBeacon`/`Image().src`/`WebSocket`; token/cookie/localStorage reads sent anywhere off-origin; `eval`/`Function`/`v-html`/`innerHTML`/dynamic `<script>`; external redirects; iframe `src`/`postMessage` trust.
- **Supply chain & provenance**: deps, lockfile sources, CI/infra, binaries, commit authorship (section 2, done thoroughly).
Prompt each agent to: assume legit-until-proven, cite `file:line`, say concretely whether each concern is **exploitable or benign**, and not to pad the report. See `docs/BACKEND_ARCHITECTURE.md` for the auth/scope model when judging backend changes.
@@ -106,20 +106,20 @@ Prompt each agent to: assume legit-until-proven, cite `file:line`, say concretel
## 4. Judge, then verdict
For each candidate finding, decide reachability before calling it: Is the input attacker-controlled or admin-config/DB-derived? Is the endpoint authed and scoped? Does the tainted value actually reach a sink? A scary-looking sink fed only by trusted server-side data is benign — say so.
For each candidate finding, decide reachability before calling it: Is the input attacker-controlled or admin-config/DB-derived? Is the endpoint authed and scoped? Does the tainted value actually reach a sink? A scary-looking sink fed only by trusted server-side data is benign, say so.
Deliver one consolidated verdict:
- **What you checked and cleared** — grouped by surface, so the reader sees coverage, not just a green light.
- **Findings** — ranked by severity, each with `file:line`, what it does, and why it is/ isn't exploitable.
- **What you checked and cleared**: grouped by surface, so the reader sees coverage, not just a green light.
- **Findings**: ranked by severity, each with `file:line`, what it does, and why it is/ isn't exploitable.
- **Overall:** `clean` / `needs attention` / `malicious`, plus any non-blocking belt-and-suspenders follow-ups (e.g. "enable `pinact run --check` in CI").
Be honest about coverage limits: if you verified SHA pins by publisher but didn't resolve them over the network, or sampled rather than read every file, say so.
## Anti-patterns
- Declaring "clean" from grep alone on a large diff — grep scopes risk, it doesn't clear it. Read the files at the sinks.
- Declaring "clean" from grep alone on a large diff: grep scopes risk, it doesn't clear it. Read the files at the sinks.
- Pasting raw diff dumps or agent transcripts back to the user instead of a judged summary.
- Treating a subprocess/`urlopen`/iframe as a finding without tracing whether user input reaches it.
- Ignoring CI/infra because "it's not app code" — it's where secrets leak.
- Skipping commit-authorship review — a malicious commit can hide among legitimate ones.
- Ignoring CI/infra because "it's not app code": it's where secrets leak.
- Skipping commit-authorship review: a malicious commit can hide among legitimate ones.

View File

@@ -36,7 +36,6 @@ lint:
- black@26.5.1
- checkov@3.3.20
- git-diff-check
- no-emdash
- isort@9.0.1
- osv-scanner@2.6.0
- prettier@3.9.9:
@@ -58,7 +57,7 @@ lint:
- docker/nginx/js/**
# Vendored patcherjs library
- backend/utils/rom_patcher/patcher.js
# Vendored humanizer skill, kept byte-identical to upstream (it quotes em dashes)
# Vendored humanizer skill, kept byte-identical to upstream
- .claude/skills/humanizer/**
# Intentionally malformed YAML, used as a test fixture
- backend/tests/config/fixtures/config/malformed_config.yml
@@ -75,22 +74,6 @@ lint:
- name: vue
extensions: [vue]
definitions:
# ESLint's romm/no-emdash-in-comment covers frontend/src/v2. In Python only
# text after a `#` is checked, since some string literals carry test data.
- name: no-emdash
files: [markdown, python]
commands:
- name: lint
output: regex
parse_regex: ((?P<path>.*):(?P<line>\d+):(?P<col>\d+) - (?P<message>.*))
read_output_from: stdout
run: >-
awk '{ s = FILENAME ~ /\.mdx?$/ ? 1 : index($0, "#"); i = s ? index(substr($0, s), "—") : 0 }
i { print FILENAME ":" FNR ":" (s + i - 1)
" - Replace the em dash with a comma, parentheses, or a separate sentence." }'
${target}
success_codes: [0]
batch: true
- name: eslint
files:
- javascript

View File

@@ -186,7 +186,7 @@ class RAHasherService:
# For folder-based multi-file ROMs the path ends with /*. RAHasher is
# launched without a shell (create_subprocess_exec), so it never expands
# the glob — it receives the literal "*" and fails ("Could not open
# the glob: it receives the literal "*" and fails ("Could not open
# track/file"). Resolve "/*" to a single real file: hash the largest
# archive directly when the folder holds archives (or skip for disc
# platforms that can't buffer-hash them), otherwise pick a disc
@@ -221,7 +221,7 @@ class RAHasherService:
# Folder of uncompressed disc tracks (the standard Redump
# .cue + .bin layout, .gdi sets, multi-bin) or a multi-file
# cartridge set. RAHasher never expands the "/*" glob itself,
# so resolve it to a single real file — the disc descriptor
# so resolve it to a single real file; the disc descriptor
# when present, otherwise the largest track.
resolved = await asyncio.to_thread(_pick_ra_file, folder)
if resolved is not None:

View File

@@ -13,7 +13,7 @@ router = APIRouter(
tags=["logs"],
)
# Largest backfill the buffer holds — derived from the producer's ring buffer
# Largest backfill the buffer holds, derived from the producer's ring buffer
# so the two never drift.
MAX_LOG_LIMIT = LOG_BUFFER_SIZE

View File

@@ -115,7 +115,7 @@ async def get_romfile_content(
)
# Derive content type / disposition / download name from the trusted DB
# record, never from the client-supplied file_name path param — otherwise a
# record, never from the client-supplied file_name path param; otherwise a
# caller could request the same bytes with an arbitrary extension to force a
# mismatched Content-Type while served inline (content-sniffing/XSS).
# Audio, images and videos are served inline so <audio>/<video>/<img> in the
@@ -164,7 +164,7 @@ async def get_romfile_content(
# Serve the file directly in development mode for emulatorjs
if DEV_MODE:
rom_path = fs_rom_handler.validate_path(file.full_path)
# Starlette sets Content-Length and honors Range natively — inline
# Starlette sets Content-Length and honors Range natively; inline
# disposition lets <audio> seek via Range requests.
return FileResponse(
path=rom_path,

View File

@@ -91,7 +91,7 @@ async def start_log_forwarder() -> None:
return
lock_id = str(uuid.uuid4())
# Write-only manager for emitting — the same proven path scan/sync use. It
# Write-only manager for emitting: the same proven path scan/sync use. It
# publishes the room emit to Redis; the main socket server's read-side
# manager resolves `admin` room membership and delivers.
socket_manager = socket_handler.write_manager()

View File

@@ -574,7 +574,7 @@ def with_details[**P, R](func: Callable[P, R]) -> Callable[P, R]:
noload(Rom.metadatum),
# Per-sibling is_main_sibling resolution for the
# SiblingRomSchema needs each sibling's RomUser for the
# request user — the relationship is `lazy="raise"`, so
# request user; the relationship is `lazy="raise"`, so
# it has to be eager-loaded here.
selectinload(Rom.rom_users).options(
noload(RomUser.rom), noload(RomUser.user)
@@ -1471,7 +1471,7 @@ class DBRomsHandler(DBBaseHandler):
query = query.options(selectinload(Rom.notes))
# Only load files (and the RomFile.rom backref needed by `is_top_level` /
# `file_name_for_download`) when the caller iterates them — e.g. the
# `file_name_for_download`) when the caller iterates them, e.g. the
# feed endpoints. The gallery/list and filter-value paths serialize
# SimpleRomSchema without files, so they skip this entirely.
if include_files:

View File

@@ -432,7 +432,7 @@ class FSHandler:
full_path = Path(normalized_path)
try:
# Detect a symlink anywhere in the path, not just at the leaf —
# Detect a symlink anywhere in the path, not just at the leaf:
# users may symlink an intermediate directory (e.g. the library
# root) to point at storage on another filesystem.
has_symlink_in_path = full_path.is_symlink()

View File

@@ -886,7 +886,7 @@ class FSRomsHandler(FSHandler):
# Empty, malformed, unreadable, or all-excluded archive: hash the archive
# file's raw bytes. We avoid `_calculate_rom_hashes` here because
# it would decompress based on extension and end up hashing the
# largest internal member, not the archive itself — and would
# largest internal member, not the archive itself, and would
# crash on an empty zip. `archive_members` stays None.
def _hash_raw_archive(crc: int) -> int:
for chunk in read_basic_file(rom_dir):

View File

@@ -962,8 +962,8 @@ class SSHandler(MetadataHandler):
# Files on NON_HASHABLE_PLATFORMS (or any file when SKIP_HASH_CALCULATION
# is enabled) have no hashes. jeuInfos can still identify the game from the
# filename (romnom) + platform (systemeid) — a stronger matcher than the
# jeuRecherche name search the get_rom fallback uses — so only bail out when
# filename (romnom) + platform (systemeid), which is a stronger matcher than the
# jeuRecherche name search the get_rom fallback uses, so only bail out when
# we have neither a hash nor a filename to match on.
if not (md5_hash or sha1_hash or crc_hash or rom_name):
log.info(

View File

@@ -125,7 +125,7 @@ class MetadataSource(enum.StrEnum):
# Demozoo / Pouët identify a production, not a retail game. Game catalogs
# (IGDB, Moby, ScreenScraper, SteamGridDB, …) still run and will happily
# attach a similarly titled box — "Desert Dream" → Desert Fox, "State of
# attach a similarly titled box: "Desert Dream" → Desert Fox, "State of
# the Art" → a skate game. Once a scene ID exists, only Demozoo / Pouët /
# CSDb may set name, summary, or artwork. Regular games never have those
# IDs, so they keep the usual fuzzy cover matching.

View File

@@ -58,7 +58,7 @@ LOGGING_CONFIG = {
}
# Strips ANSI SGR escapes (colors) embedded by `highlight()` — they render as
# Strips ANSI SGR escapes (colors) embedded by `highlight()`; they render as
# colors on a terminal but as garbage anywhere else (e.g. a browser log view).
_ANSI_RE = re.compile(r"\x1b\[[0-9;]*m")

View File

@@ -92,7 +92,7 @@ class Screenshot(RomAsset):
# `is_gallery` distinguishes intentionally-uploaded gallery screenshots from
# the auto-captured save/state thumbnails that also live in this table.
# `is_public` mirrors RomNote — lets other users browse a user's public
# `is_public` mirrors RomNote: it lets other users browse a user's public
# screenshots (community). Both default false; save/state thumbnails keep the
# defaults, only the gallery upload endpoint sets `is_gallery=True`.
is_gallery: Mapped[bool] = mapped_column(default=False)
@@ -125,7 +125,7 @@ class Save(RomAsset):
default=None,
index=True,
)
# `is_public` mirrors Screenshot/RomNote — lets other users browse and
# `is_public` mirrors Screenshot/RomNote: it lets other users browse and
# download a user's public saves (community). Defaults false (private).
is_public: Mapped[bool] = mapped_column(default=False)
# Owner-only annotations: favorites sort ahead of the rest, labels tell
@@ -162,7 +162,7 @@ class State(RomAsset):
)
emulator: Mapped[str | None] = mapped_column(String(length=EMULATOR_MAX_LENGTH))
# `is_public` mirrors Screenshot/RomNote — lets other users browse and
# `is_public` mirrors Screenshot/RomNote: it lets other users browse and
# download a user's public states (community). Defaults false (private).
is_public: Mapped[bool] = mapped_column(default=False)
# Owner-only annotations: favorites sort ahead of the rest, labels tell

View File

@@ -537,7 +537,7 @@ def test_delete_manual_file_tolerates_missing_disk_file(
game_folder_rom: Rom,
manual_fs_folder: Path,
):
# Don't create the file on disk — DELETE should still drop the row.
# Don't create the file on disk; DELETE should still drop the row.
manual_file = db_rom_handler.add_rom_file(
RomFile(
rom_id=game_folder_rom.id,

View File

@@ -205,19 +205,19 @@ def test_gallery_query_excludes_thumbnails_and_others_private(
admin_user: User,
editor_user: User,
):
# Own save/state thumbnail — not a gallery upload.
# Own save/state thumbnail, not a gallery upload.
_add_screenshot(
rom, platform, admin_user.id, "thumb", is_gallery=False, is_public=False
)
# Own private gallery screenshot — visible to self.
# Own private gallery screenshot, visible to self.
mine = _add_screenshot(
rom, platform, admin_user.id, "mine", is_gallery=True, is_public=False
)
# Another user's public gallery screenshot — visible (community).
# Another user's public gallery screenshot, visible (community).
others_public = _add_screenshot(
rom, platform, editor_user.id, "pub", is_gallery=True, is_public=True
)
# Another user's private gallery screenshot — hidden.
# Another user's private gallery screenshot, hidden.
_add_screenshot(
rom, platform, editor_user.id, "priv", is_gallery=True, is_public=False
)

View File

@@ -40,7 +40,7 @@ class TestUpdateRomDerivedColumns:
assert updated.fs_name == "Sonic (Europe).md"
assert updated.fs_name_no_tags == "Sonic"
assert updated.fs_name_no_ext == "Sonic (Europe)"
# The extension is resynced too — the rename endpoint used to omit it.
# The extension is resynced too; the rename endpoint used to omit it.
assert updated.fs_extension == "md"
def test_update_either_path_half_resyncs_the_digest(self, rom: Rom):

View File

@@ -494,7 +494,7 @@ class TestStripSensitiveQueryParams:
"""Non-sensitive params should keep their values and ordering."""
url = "https://api.example.com/media?systemeid=1&ssid=user&romnom=Game.zip"
result = strip_sensitive_query_params(url)
# parse rather than rely on a literal — urlencode may reorder identically-named keys
# parse rather than rely on a literal; urlencode may reorder identically-named keys
parsed = parse_qsl(urlparse(result).query, keep_blank_values=True)
assert ("systemeid", "1") in parsed
assert ("romnom", "Game.zip") in parsed

View File

@@ -164,15 +164,15 @@ class TestSearchRomGameTypeFilter:
search_term=None, fields=None, where=None, limit=None
):
if where and "game_type" not in where and not where.startswith("("):
# Primary search pass — return no results so we fall through to
# Primary search pass: return no results so we fall through to
# the expanded search
return []
if where and where.startswith("("):
# Expanded game details lookup — return both candidates
# Expanded game details lookup: return both candidates
return [ecco_dolphin, ecco_tides]
return []
# Expanded search returns two results — wrong game FIRST, correct game second
# Expanded search returns two results: wrong game FIRST, correct game second
expanded_results = [
{"game": {"id": 1799}, "name": "Ecco the Dolphin"},
{"game": {"id": 5379}, "name": "Ecco: The Tides of Time"},

View File

@@ -198,7 +198,7 @@ async def test_scan_rom_complete_clears_unselected_metadata(
newly_added=False,
)
# IGDB and RA were unselected — their id and metadata must be cleared.
# IGDB and RA were unselected; their id and metadata must be cleared.
assert result.igdb_id is None
assert result.igdb_metadata == {}
assert result.ra_id is None

View File

@@ -20,7 +20,7 @@ ALLOWED_AUDIO_EXTENSIONS = frozenset(
{".mp3", ".ogg", ".oga", ".opus", ".m4a", ".aac", ".wav", ".flac"}
)
# Skip parsing anything larger than this — mutagen mmaps the file and can
# Skip parsing anything larger than this; mutagen mmaps the file and can
# consume substantial memory on pathological inputs (e.g. a mislabeled 4GB WAV).
MAX_AUDIO_PARSE_BYTES = 512 * 1024 * 1024 # 512 MiB
@@ -152,7 +152,7 @@ def _allowed_mime_types(data: bytes) -> str:
# NOTE: the per-format tag and embedded-cover handling below (ID3 / MP4 /
# Vorbis comments / FLAC pictures) was largely AI-generated against mutagen's
# API — verify against real files when adding or changing a format.
# API; verify against real files when adding or changing a format.
def _extract_common_tags(audio: mutagen.FileType) -> dict[str, str | None]:
"""Extract common tags across formats from a single non-easy mutagen handle."""
tags = getattr(audio, "tags", None)

View File

@@ -4,7 +4,7 @@ These drive a **real running RomM instance**, unlike the Vitest specs, which mou
## Running tests
1. Have the app up and reachable (default `http://localhost:3000`, override with `E2E_BASE_URL`), with a populated library — the specs pick the first ROM they find.
1. Have the app up and reachable (default `http://localhost:3000`, override with `E2E_BASE_URL`), with a populated library; the specs pick the first ROM they find.
2. Seed the two fixture users, from the repo root: