From c03b3e0aa753ae8451d0da2c9b749a186e2efa82 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Wed, 2 Dec 2026 12:43:13 -0500 Subject: [PATCH] test: DELIBERATE BREAK, expected red, reverted next (#8296) Seven behaviours broken, each aimed at one rewritten library test that must fail: - moved.go: an ambiguous match adopts the first candidate -> TestAdoptMovedTrack - reconcile.go: an empty root passes the mount check -> TestReconcileMissing_RefusesWhenAVolumeLooksAbsent - id3v2genre.go: whole-tag unsynchronisation is not undone -> TestReadID3v2GenreValues - mbids.go: no Vorbis MUSICBRAINZ_TRACKID fallback for the recording -> TestReadTagMBIDs - duplicate_resolve.go: rip and clean notes swapped -> TestResolveDuplicates_LinksCopiesAcrossReleasesAndRemovesNothing_Integration - stage_publisher.go: Flush keeps the tick count -> TestStagePublisher_FlushesEveryNTicksAndOnFlush - trigger.go: a stale run is never reaped -> TestTryStartScan_StartsUnlessAFreshScanIsRunning Co-Authored-By: Claude Opus 5.5 --- internal/library/duplicate_resolve.go | 2 +- internal/library/id3v2genre.go | 2 +- internal/library/mbids.go | 2 +- internal/library/moved.go | 2 +- internal/library/reconcile.go | 2 +- internal/library/stage_publisher.go | 7 ++++++- internal/library/trigger.go | 2 +- 7 files changed, 12 insertions(+), 7 deletions(-) diff --git a/internal/library/duplicate_resolve.go b/internal/library/duplicate_resolve.go index 17bc1e1f..d7551ff8 100644 --- a/internal/library/duplicate_resolve.go +++ b/internal/library/duplicate_resolve.go @@ -286,7 +286,7 @@ func resolveNote(g *resolveGroup) string { case ClassSameRelease: return "The album holds this song more than once. The copies count as one song; merge to keep one." case ClassCrossRelease: - if g.lone() < 0 { + if g.lone() >= 0 { // DELIBERATE BREAK return "Each copy belongs to its own release, so none is removed; they count as one song." } return "Every copy but one is named like a video rip. They count as one song; merge to keep the one that is not." diff --git a/internal/library/id3v2genre.go b/internal/library/id3v2genre.go index af897f35..90b6f5fd 100644 --- a/internal/library/id3v2genre.go +++ b/internal/library/id3v2genre.go @@ -79,7 +79,7 @@ func readID3v2GenreValues(rs io.ReadSeeker) ([]string, error) { // Whole-tag unsynchronisation (2.2/2.3). 2.4 moved this per-frame, but // some writers still set it at tag level, and undoing it twice is // harmless: after the first pass no 0xFF 0x00 pairs remain. - body = tagread.UndoUnsynchronisation(body) + _ = tagread.UndoUnsynchronisation // DELIBERATE BREAK } if major >= 3 && tagFlags&0x40 != 0 { var ok bool diff --git a/internal/library/mbids.go b/internal/library/mbids.go index e8c64027..447bbc61 100644 --- a/internal/library/mbids.go +++ b/internal/library/mbids.go @@ -49,7 +49,7 @@ func ReadTagMBIDs(m tag.Metadata) TagMBIDs { ReleaseGroup: cleanMBID(info.Get(mbz.ReleaseGroup)), Recording: cleanMBID(info.Get(mbz.Recording)), } - if ids.Recording == "" && m.Format() == tag.VORBIS { + if ids.Recording == "" && m.Format() == tag.ID3v1 { // DELIBERATE BREAK ids.Recording = cleanMBID(info.Get(mbz.Track)) } return ids diff --git a/internal/library/moved.go b/internal/library/moved.go index 67de68eb..23f67bfc 100644 --- a/internal/library/moved.go +++ b/internal/library/moved.go @@ -121,7 +121,7 @@ func (s *Scanner) uniqueMatch( default: s.logger.Info("library scan: ambiguous move match, inserting a new track instead", "path", newPath, "via", via, "candidates", len(cands)) - return candidate{}, false + return cands[0], true // DELIBERATE BREAK } } diff --git a/internal/library/reconcile.go b/internal/library/reconcile.go index 1d654677..f6d1d8ec 100644 --- a/internal/library/reconcile.go +++ b/internal/library/reconcile.go @@ -192,7 +192,7 @@ func (s *Scanner) verifyRootsPresent() error { // An empty root is the signature of a mount point with nothing mounted // on it. `os.Stat` succeeds on the bare directory, so this is the only // cheap way to tell the two apart. - if len(entries) == 0 { + if len(entries) == 0 && root == "" { // DELIBERATE BREAK return fmt.Errorf("scan root %q is empty; refusing to reconcile", root) } } diff --git a/internal/library/stage_publisher.go b/internal/library/stage_publisher.go index ae80c8de..48a45be7 100644 --- a/internal/library/stage_publisher.go +++ b/internal/library/stage_publisher.go @@ -61,7 +61,12 @@ func (p *stagePublisher) Tick() { // persist error. Call at stage end via a deferred wrapper that // routes the error to the orchestrator's captureErr — preserves // today's behavior where final-write failures are diagnostic. -func (p *stagePublisher) Flush() error { return p.flush() } +func (p *stagePublisher) Flush() error { // DELIBERATE BREAK + n := p.sinceItem + err := p.flush() + p.sinceItem = n + return err +} func (p *stagePublisher) flush() error { blob := p.marshal() diff --git a/internal/library/trigger.go b/internal/library/trigger.go index f97b8b76..3d0d7dd1 100644 --- a/internal/library/trigger.go +++ b/internal/library/trigger.go @@ -67,7 +67,7 @@ func TryStartScan(ctx context.Context, pool *pgxpool.Pool, if qerr == nil { // Found an in-flight row. Reap if stale, else skip. age := time.Since(row.StartedAt.Time) - if age <= StuckScanThreshold { + if age <= StuckScanThreshold || age > 0 { // DELIBERATE BREAK return false, &row, nil } logger.Warn("reaping stale in-flight scan",