2026-11-18 15:17:50 +00:00
|
|
|
# Development
|
|
|
|
|
|
|
|
|
|
[Project overview](../README.md) · [Installation](setup.md) · [Admin UI conventions](admin-ui.md)
|
|
|
|
|
|
|
|
|
|
## Architecture
|
|
|
|
|
|
|
|
|
|
Furumusic is written in Rust on the
|
|
|
|
|
[Cot](https://cot.rs) web framework. PostgreSQL stores the catalog, accounts,
|
|
|
|
|
playlists, configuration, and background-job state. Audio inspection uses
|
|
|
|
|
Symphonia, torrent downloads use librqbit, and the shared `music-dht`/Frid
|
|
|
|
|
protocol stack provides decentralized catalog search, media transfer, and
|
|
|
|
|
connected-device synchronization.
|
|
|
|
|
|
|
|
|
|
The browser interface and JSON API are served by the same application. Import,
|
|
|
|
|
artwork, metadata enrichment, similarity indexing, and maintenance run as
|
|
|
|
|
durable background jobs rather than blocking playback requests.
|
|
|
|
|
|
|
|
|
|
## Build profiles
|
|
|
|
|
|
|
|
|
|
Development and test builds use basic optimization (`opt-level = 1`) for
|
|
|
|
|
dependencies to keep macOS unwind tables below the compact-unwind size limit.
|
|
|
|
|
Application code stays unoptimized; debug symbols, assertions and panic
|
|
|
|
|
unwinding remain enabled. The first build compiles dependencies with these
|
|
|
|
|
settings, then reuses them from Cargo's cache. Dependency stepping in a debugger
|
|
|
|
|
can be less exact because of optimization. Release settings are independent.
|
|
|
|
|
|
|
|
|
|
See the [Cargo profile override documentation](https://doc.rust-lang.org/cargo/reference/profiles.html#overrides) for dependency-specific settings.
|
|
|
|
|
|
|
|
|
|
## Container builds and CI
|
|
|
|
|
|
|
|
|
|
CI uses Rust 1.97.0 and cargo-chef 0.1.74 to cache compiled dependencies separately
|
|
|
|
|
from application sources. Buildx imports and exports intermediate layers through
|
|
|
|
|
`ultradesu/furumusic:buildcache` (`mode=max`). After the first build, changes to
|
|
|
|
|
source code, templates or prompts reuse the dependency layer when its recipe and
|
|
|
|
|
toolchain are unchanged. Both dependency and application builds use `--locked`.
|
|
|
|
|
Update the pinned build tools in `Dockerfile`; changing them rebuilds the cache.
|
|
|
|
|
|
|
|
|
|
## Contributing
|
|
|
|
|
|
|
|
|
|
Bug reports, design discussions, and patches are welcome. Before submitting a
|
|
|
|
|
change, run:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
cargo fmt --all -- --check
|
|
|
|
|
cargo clippy --all-targets -- -D warnings
|
|
|
|
|
cargo test --all-targets
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Last.fm database tests use temporary tables on a disposable PostgreSQL database:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
FURUMUSIC_LASTFM_TEST_DATABASE_URL=postgres://user:pass@localhost/test_db \
|
|
|
|
|
cargo test lastfm_popularity -- --include-ignored
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Access and sharing tests
|
|
|
|
|
|
2026-11-22 16:05:37 +02:00
|
|
|
Podcast regressions include browser-store tests in `tests/podcasts.test.cjs` and an
|
|
|
|
|
isolated PostgreSQL fixture for multiuser subscriptions, progress generations,
|
|
|
|
|
retention and administrator actions:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
node --test tests/podcasts.test.cjs
|
2026-11-22 17:49:23 +02:00
|
|
|
FURU_PODCAST_RENDER_FIXTURE=1 cargo test renders_podcast_navigation_and_views
|
|
|
|
|
node tests/browser-podcast-ui.cjs
|
2026-11-22 16:05:37 +02:00
|
|
|
FURU_PODCAST_TEST_DATABASE_URL=postgresql://... cargo test podcasts -- --include-ignored
|
2026-11-22 17:11:37 +02:00
|
|
|
FURU_PODCAST_TEST_DATABASE_URL=postgresql://... cargo test admin_unicode_search -- --include-ignored
|
2026-11-22 16:05:37 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Use a disposable database. The PostgreSQL test creates and drops a unique schema;
|
|
|
|
|
its audio files use a unique temporary directory. Normal podcast tests need no network.
|
2026-11-22 17:11:37 +02:00
|
|
|
The podcast fixture includes real Frid v4 subscription operations, snapshot exchange,
|
|
|
|
|
offline unsubscribe replay, legacy-peer filtering, and private Unicode search. The
|
|
|
|
|
admin fixture exercises list counts, all three catalogue lists and the track picker
|
|
|
|
|
with Cyrillic and Greek searches. Use a PostgreSQL build with ICU support; running
|
|
|
|
|
these fixtures on a database created with locale `C` covers the locale regression.
|
2026-11-22 17:49:23 +02:00
|
|
|
The browser UI fixture checks direct list/detail hashes on first load and reload,
|
|
|
|
|
back navigation, RSS artwork and broken-image fallbacks, explicit subscriptions,
|
|
|
|
|
compact search cards and mobile layout. It uses isolated API fixtures with the
|
|
|
|
|
rendered application. Set `PLAYWRIGHT_MODULE` and `CHROME_PATH` as for the other
|
|
|
|
|
browser tests. Optional `ALPINE_FIXTURE` points to a local Alpine.js bundle for
|
|
|
|
|
offline browser runs; otherwise the page loads Alpine from its normal CDN.
|
2026-11-22 16:05:37 +02:00
|
|
|
|
2026-11-18 15:17:50 +00:00
|
|
|
The access regression suite uses a disposable migrated database and a local OIDC
|
|
|
|
|
provider with signed tokens and PKCE:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
node --test tests/*.test.cjs
|
|
|
|
|
FURU_ACCESS_TEST_DATABASE_URL=postgresql://... cargo test postgres_approval_survives_sso_changes_without_implicit_grants -- --ignored
|
|
|
|
|
# Fresh disposable instance on :18048, media root /tmp/furumi-access-media,
|
|
|
|
|
# PostgreSQL container furumi-access-test-pg, database furumi_access_test:
|
|
|
|
|
node tests/browser-access-sharing.cjs
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
The browser test requires Playwright (`PLAYWRIGHT_MODULE`) and Chrome
|
|
|
|
|
(`CHROME_PATH`), and uses local port 18049 for its OIDC provider. It checks
|
|
|
|
|
approval, SSO precedence and group removal, guest playback and downloads,
|
|
|
|
|
unauthorized track substitution, and desktop/mobile player behavior.
|
|
|
|
|
|
|
|
|
|
## Statistics tests
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
node --test tests/*.test.cjs
|
|
|
|
|
cargo test admin:: -- --skip postgres_statistics_drilldown_and_pagination
|
|
|
|
|
# Use a disposable PostgreSQL; this test creates connection-local temporary tables.
|
|
|
|
|
FURU_STATISTICS_TEST_DATABASE_URL=postgresql://... cargo test postgres_statistics_drilldown_and_pagination -- --ignored
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
`tests/browser-statistics.cjs` additionally exercises a fresh disposable instance
|
|
|
|
|
at `FURU_TEST_URL` (default `http://127.0.0.1:3018`) and seeds the disposable Docker
|
|
|
|
|
container `furumi-statistics-test-pg`. It requires Playwright (or
|
|
|
|
|
`PLAYWRIGHT_MODULE`) and Chrome (or `CHROME_PATH`). Never point this test at a
|
|
|
|
|
live service.
|
|
|
|
|
|
|
|
|
|
## Metadata Repair tests
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
node --test tests/admin_metadata_repair.test.cjs
|
|
|
|
|
cargo test admin::metadata_fix::tests
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
`tests/browser-metadata-repair.cjs` checks the chat and plan updates, a four-release
|
|
|
|
|
merge, deletion and restoration of tracks and artist credits, playlists, playback
|
|
|
|
|
queues, and undo conflicts. Run it only against a disposable instance and a
|
|
|
|
|
PostgreSQL container named `furumi-repair-test-pg`, with database
|
|
|
|
|
`furumi_repair_test`. Set `FURU_TEST_URL`, `FURU_REPAIR_TEST_PG`, `CHROME_PATH`, and
|
|
|
|
|
`PLAYWRIGHT_MODULE` as needed. It seeds `tests/metadata_repair_fixture.sql` after
|
|
|
|
|
creating the test administrator. Set `FURU_REPAIR_SKIP_SEED=1` for a seeded database.
|
|
|
|
|
With `FURU_REPAIR_TEST_MODEL=1`, it additionally checks the reported release-only
|
|
|
|
|
selection and full ordered tracklist against the configured model, applies and
|
|
|
|
|
undoes that plan, and verifies individual track exclusions.
|
|
|
|
|
|
|
|
|
|
## Import destination tests
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
node --test tests/import_playlists.test.cjs
|
|
|
|
|
# Disposable PostgreSQL; both tests use temporary tables.
|
|
|
|
|
FURU_IMPORT_TEST_DATABASE_URL=postgresql://... cargo test import_destinations -- --ignored
|
|
|
|
|
FURU_IMPORT_TEST_DATABASE_URL=postgresql://... cargo test torrent_playlist -- --ignored
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
`tests/browser-import-playlists.cjs` checks the file upload flow, database
|
|
|
|
|
reconciliation and the torrent picker on desktop and mobile. It requires a fresh
|
|
|
|
|
migrated instance with the import agent disabled at `FURU_TEST_URL` (default
|
|
|
|
|
`http://127.0.0.1:3019`), the disposable PostgreSQL container
|
|
|
|
|
`furumi-import-playlist-test-pg` with database `furumi_import_test`, and Playwright
|
|
|
|
|
and Chrome configured as above. It uses a local torrent preview fixture and
|
|
|
|
|
simulated imported tracks, without downloading external torrents.
|
2026-11-26 16:05:42 +02:00
|
|
|
|
|
|
|
|
## Library import tests
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
cargo test library_import
|
|
|
|
|
# Disposable PostgreSQL with ICU support; each test creates and drops a unique schema.
|
|
|
|
|
FURU_LIBRARY_IMPORT_TEST_DATABASE_URL=postgresql://... cargo test library_import -- --include-ignored
|
|
|
|
|
```
|
|
|
|
|
|
2026-11-26 16:30:07 +02:00
|
|
|
The database tests cover per-user isolation, repeated and similar source playlists,
|
|
|
|
|
storing a 5000-entry export, exclusive claims, lease ownership, cancellation,
|
|
|
|
|
history deletion that keeps target playlists, resumption after a worker stops
|
2026-11-26 16:55:27 +02:00
|
|
|
without a server restart once its lease expires, continuing the same Spotify
|
|
|
|
|
API import after the user signs in again, and resolving a small library with
|
|
|
|
|
federation disabled: local matches get content ids from `agent_storage_dir`,
|
|
|
|
|
known federated tracks match without the network, and a federation stub that
|
2026-11-26 17:16:21 +02:00
|
|
|
panics proves no network access without consent. Peer catalogues come from a
|
|
|
|
|
fake catalogue source: the tests cover matches through the original, folded and
|
|
|
|
|
split artist names, repeated failed searches, lost catalogues, the budget of a
|
|
|
|
|
pass, a stopped node, manual choices with tampered candidates, and cancellation
|
|
|
|
|
that leaves no catalogue request running. The database needs the `pg_trgm`
|
|
|
|
|
extension; the tests install it into `public`.
|
|
|
|
|
|
2026-11-26 17:46:47 +02:00
|
|
|
The publisher tests (`src/library_import/tests/publisher.rs`) run against the
|
|
|
|
|
Device Sync tables of the same schema. They cover source order, repeats, empty
|
|
|
|
|
playlists, a second pass that adds nothing, Resync appending at the end, tracks
|
2026-11-26 19:05:30 +02:00
|
|
|
removed by the user or by a committed but not yet applied operation, a
|
|
|
|
|
federated track removed in the web player by its content id, deleted
|
2026-11-26 17:46:47 +02:00
|
|
|
target playlists and recreation, an entry failing after its operation was
|
|
|
|
|
recorded, registers written concurrently, deletions from the web and from
|
|
|
|
|
another device during a batch, older operations that arrive during a batch,
|
|
|
|
|
concurrent operations that must keep registers and playlist rows consistent,
|
|
|
|
|
two imports of one user publishing in turn, and the Device Sync budget for
|
|
|
|
|
tracks and playlists. `library_import_measures_the_outgoing_device_sync_line`
|
|
|
|
|
prints the measured line for 3,200 published tracks with `--nocapture`.
|
|
|
|
|
|
2026-11-26 17:16:21 +02:00
|
|
|
`cargo test federation::client` checks bounded artist catalogue lookups without a
|
|
|
|
|
database: at most 16 owners and the given number of parallel requests, timeouts,
|
|
|
|
|
errors, oversized catalogues, and that dropping a lookup stops its search and
|
|
|
|
|
requests.
|
2026-11-26 16:55:27 +02:00
|
|
|
|
|
|
|
|
The matcher's reference table (`src/library_import/matcher/tests.rs`) runs
|
|
|
|
|
without a database and documents the matching rules case by case.
|
2026-11-26 16:30:07 +02:00
|
|
|
|
2026-11-26 19:05:30 +02:00
|
|
|
The import page has browser-store tests and a browser scenario on the rendered
|
|
|
|
|
player with isolated API fixtures; neither needs a server or a database:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
node --test tests/library_import.test.cjs
|
|
|
|
|
FURU_LIBRARY_IMPORT_RENDER_FIXTURE=1 cargo test library_import::tests::web
|
|
|
|
|
node tests/browser-library-import.cjs
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
The store tests unzip real archives with the vendored fflate and cover the
|
|
|
|
|
archive limits (size, entries, playlist files and declared sizes, checked
|
|
|
|
|
before decompression), the request limit, the selection of repeated, similar
|
|
|
|
|
and unavailable playlists, federated consent, polling, the Spotify sign-in
|
|
|
|
|
return and removing a federated track from a playlist. The browser scenario
|
|
|
|
|
checks the menu order on desktop and mobile, history polling, that only
|
|
|
|
|
`Playlist*.json` and `YourLibrary.json` from a ZIP with listening history reach
|
|
|
|
|
the server, the wizard, details, a manual choice, Retry unmatched, history
|
|
|
|
|
deletion, continuing a Spotify import after a new sign-in, federated track
|
|
|
|
|
removal in a playlist and reduced motion. Set `PLAYWRIGHT_MODULE` and
|
|
|
|
|
`CHROME_PATH` as for the other browser tests; `FURU_SCREENSHOT_DIR` chooses
|
|
|
|
|
where screenshots go (default `target/`).
|
|
|
|
|
|
|
|
|
|
`src/player/vendor/fflate-0.8.2.min.js` is `umd/index.js` of the npm package
|
|
|
|
|
`fflate@0.8.2` (MIT, `src/player/vendor/fflate-LICENSE`), served unchanged at
|
|
|
|
|
`/vendor/fflate-0.8.2.js` and loaded only when a user picks an archive.
|
|
|
|
|
|
2026-11-26 16:30:07 +02:00
|
|
|
The Spotify export fixture in `src/library_import/adapters/fixtures/spotify_export/`
|
|
|
|
|
is synthetic. Add a fresh anonymized real export next to it before relying on the
|
|
|
|
|
parser for a new export format.
|