Files
minstrel/internal/sync/types.go
T
bvandeusenandClaude Opus 5.5 d191a28217 docs: server comments say what the code does, not how it came to be (#6277)
Comment blocks in cmd/minstrel and 30 smaller internal packages, rewritten
to rule 32's standard with each citation read in context: task, milestone
and rule ids go, and so do the stories they were attached to ("used to",
"Before #N", measurements from one install, quotes, pointers to Fabled
Librarian's records and to docs/superpowers files that are not in the
repo). Where a story wrapped a real constraint, the constraint stays as a
present-tense fact.

Comments that had gone stale are corrected:
- taste.Config: the tuned values are overlaid by internal/recsettings;
  it is no longer "a later follow-up".
- StorageConfig: the data dir holds art, caches and the stream secret,
  not only playlist covers.
- the Subsonic album list and getUser comments describe what they do
  today rather than a milestone that would change it.

Checked: the non-comment token stream of every changed file matches
HEAD, and gofmt -l is empty.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 12:15:05 -04:00

41 lines
1.4 KiB
Go

// Package sync supports the delta-sync endpoint by writing an
// append-only library_changes log alongside every mutation on tracked
// entities (artists, albums, tracks, likes, playlists, playlist_tracks).
//
// Callers MUST pass the same transaction that performed the underlying
// mutation — the change row and the mutation must commit or roll back
// together. See LogChange in changes.go.
package sync
// EntityType enumerates the entity kinds whose mutations are tracked
// by the library_changes log. Values must stay in sync with the CHECK
// constraint on library_changes.entity_type (migration 0025).
type EntityType string
const (
EntityArtist EntityType = "artist"
EntityAlbum EntityType = "album"
EntityTrack EntityType = "track"
EntityLikeTrack EntityType = "like_track"
EntityLikeAlbum EntityType = "like_album"
EntityLikeArtist EntityType = "like_artist"
EntityPlaylist EntityType = "playlist"
EntityPlaylistTrack EntityType = "playlist_track"
)
// Op is upsert or delete. Matches the CHECK constraint in migration 0025.
type Op string
const (
OpUpsert Op = "upsert"
OpDelete Op = "delete"
)
// Change is the wire shape returned by the sync endpoint to clients.
type Change struct {
ID int64 `json:"id"`
EntityType EntityType `json:"entity_type"`
EntityID string `json:"entity_id"`
Op Op `json:"op"`
}