You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 57edab8
Browse filesBrowse the repository at this point in the historyBrowse files
An album and an artist are rows, and each carries its own cover
`set_artwork` and the `artwork` table are gone. `album` and `artist` are
tables, `song.album_name` is a foreign key into the first, and the cover is an
ordinary column on each rather than a row in a table of pictures about things
that were not rows.
**Keyed by the name, not by an id**, and that decides everything else. The
mechanical reason first: `fill_auto` hands a mutation exactly *one* uuid, so no
single verb can mint an album row and a song row in the same entry — and
splitting it into two verbs would mean a client authoring a reference to a row
it has not seen confirmed. The second reason is the rebase: two peers each
adding "Water Music" offline would author two rows with two ids, one of which
loses, and every song pointing at the loser points at nothing. A name is what
both peers already agree on without being told. So there is no `create_album`
and no `create_artist` — a row appears because a song named it, which is what
lets `add_song` write it.
Which is where the covers ride: `album_art` and `artist_art`, at the end of
`add_song`'s arguments. The entry that knows a track's album is the entry that
adds the track. The demo's `ART` stays the short table it was — a cover written
once where it belongs, rather than copied onto every `Seed` row of a fifty-track
record — and `art_of` looks it up per track on the way into the log. The
scanner sends both empty until it learns to read an embedded tag.
`art_to_write` is the one last-write-wins rule in the domain, and its three
cases are indistinguishable by reading, so each is asserted:
- no row yet, make one, with whatever the entry brought — often nothing, and a
row with an empty `art` is right;
- a picture replaces a picture, because somebody who picks a better cover means
the newer one, and a total order is what makes "newer" a fact;
- **nothing replaces nothing** — an entry with no picture leaves the one that
is there, which is the case the scanner is in on every rescan and the one
that wipes a library's covers one track at a time if it is wrong.
Two things the schema found that reading would not have.
**`song.album_name` had to be nullable, and the foreign key is what said so.**
It went in `NOT NULL`, and every test writing a song with no album failed with
`writing to song: FOREIGN KEY constraint failed` — Petros enforces these. A
song on no record has nothing to point at, and `''` would need an album called
`''` to point at; inventing one would put a nameless card on the albums page
for every single somebody ever typed in. It also fixed a latent bug, since
`albums()` had been grouping every album-less song under one entry named `""`.
**Nothing has a foreign key into `artist`**, deliberately. `media.creator` is
the one kind-neutral name for whoever made a thing — a song's artist, a
sermon's speaker, a podcast's show — and a foreign key from it into a table
called `artist` would name two of those three wrongly. So `artist` holds what
is *known about* a creator, joined by name, and `artists()` still reads its
names from `media`: a new kind appears in that list without the query learning
about it. `albums()` is the same shape — which albums exist is the songs'
answer; the table is asked only for the picture.
Deleting a mutation variant is forbidden, and the exemption here is factual
rather than an override: `set_artwork` was missing from `peer!` for its entire
life, so every call was refused at apply time and no log anywhere has ever held
a `SetArtwork` entry. `log-compat` refused the removal by name and
`--write` recorded the new surface deliberately — six verbs now, with `AddSong`
two arguments longer, which is an addition the log survives.
**No `SCHEMA_VERSION` bump, and this is what that costs.** `song` lost a column
and gained another, which is exactly the shape change the bump exists for — so
an existing database keeps its old `song.album`, `migrate` will not alter it,
and every query breaks on the missing `album_name`. Anyone holding a database
reinstalls. That was the call ("still alpha"); it is a one-line change to make
the day somebody's library is worth keeping, and it is noted in CLAUDE.md as
such rather than left to be discovered.
Verified: whole suite green with `--all-features`, clippy and fmt clean, and
`log-compat` reports the rebuilt module compatible with the recorded surface.
Each new assertion falsified against the line it holds — breaking either half
of `art_to_write` fails the cover test naming the two URLs, and pointing an
album-less song at `""` fails four tests with the foreign key error above.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XcBd33WHuwVJf6eCw7CpeG
0 commit comments