← Back to Pull requests

feat(library): queue library-wide rename and retag without blocking the API #192

Open
unknown opened this pull request with 518 lines diff across 6 files
View on GitHub
unknown unknown commented on Nov 30, 2026 14:41 UTC
Author

Why

An unscoped rename dry-run walked every library file on the Node event loop and froze production (~151k files) for about 10 minutes. There was also no safe way to rename or retag the whole library, unmapped deletion had no preview, and already-correct files were flagged because relative_path was compared with an absolute expected path.

This recovers the unfinished Cursor cloud-agent work from bc-61436faa (all 72 edits applied, then finished and tested).

What

  • Library-wide rename and retag run as low-priority commands, one artist per queue turn, with a preview first and visible progress. Dashboard: Library maintenance panel.

  • GET /api/v1/mediaFile/rename/dry-run without artist/album/edition/release scope now returns 400 and points at the background preview.

  • Rename preview compares the stored absolute file_path with the expected path (NFC-normalized).

  • Unmapped deletion is preview-then-apply and includes spatial/Atmos files. Orphan lyric/metadata sidecars (unresolved_sidecar) are eligible in scan cleanup.

  • Local track playback uses HTTP Range so the browser can start and seek without buffering the whole file. Only spatial codecs that browsers cannot decode are transcoded.

  • Edition selection on the album page sits behind an Edit button; the manage-editions dialog shows the source choice only when you ask to change it.
  • Also included

  • Recanonicalizing a recording or track no longer marks the file as needing a rename when its path has not changed.

  • An edition whose acquisition plan is in use is left unchanged for that refresh, instead of failing the whole artist.

  • Artwork recovery skips a busy database and retries with a longer write-lock wait (#188). SQLite busy command retries use a higher attempt budget.

  • Apple wrapper restart requests wait at least five minutes between attempts.
  • Tests

    yarn ci passed locally: lint (existing warning only), typecheck, 2854 API tests + 56 app test files, build.

    Out of scope / not closed by this PR

  • #170 / PR #175 and #140 / PR #143 remain open and still conflict with main. This makes unresolved sidecars eligible in the existing cleanup inventory, but does not land those PRs.

  • #188 is mitigated, not proven fixed in production.
  • <!-- CURSOR_SUMMARY -->
    ---

    [!NOTE]

    Medium Risk

    Library-wide file rename/retag and bulk unmapped/orphan deletion are destructive at scale; path and playback changes affect core media serving and catalog refresh behavior.

    > Overview

    Release 2.28.0 adds background library-wide rename and retag: low-priority commands walk one artist per queue turn with preview-then-apply APIs and a new Library maintenance panel on the dashboard. Unscoped GET …/rename/dry-run now returns 400 so a full-library preview cannot block the API.

    > Rename accuracy improves by comparing stored absolute file_path to the expected path (NFC), clearing stale needs_rename flags, and stopping recanonicalization from flagging paths that did not change.

    > Cleanup workflows add unmapped file preview/delete (including spatial/Atmos), orphan unresolved_sidecar eligibility in scan cleanup, and GET …/cleanup/latest to tie orphan delete to the latest inventory.

    > Playback serves FLAC/ALAC/WAV via HTTP Range (libraryByteStreamPlan) so local tracks can start before the full file is read; only browser-incompatible spatial codecs are transcoded.

    > Album UI collapses edition summary to a short line with an Edit flow; acquisition sources appear only after Change source.

    > Catalog refresh treats in-use acquisition plans as deferred (isDeferredEditionWrite) instead of failing the whole artist. Artwork recovery and command SQLITE_BUSY retries are more patient; Apple wrapper restart requests enforce a minimum interval between attempts.

    > <sup>Reviewed by Cursor Bugbot for commit 007393b7fa1ae089df24f265903145b8c4b0816d. Bugbot is set up for automated code reviews on this repo. Configure here.</sup>

    <!-- /CURSOR_SUMMARY -->

    Diff: 518 lines (+388 / -130) across 6 files Reviewer: cursor[bot] Review duration: 8m
    All Vouch review confidence checks passed
    Residual risk 0.33 = Change Risk (0.53) × (1 − Review Confidence (0.38)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.53 · 518 lines diff across 6 files
    0.53
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 64% · Reviewer familiarity: 35%
    37%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.374
    Shallow Review Depth shallow_review_depth
    0.344
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #192"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 37.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52.7% (MEDIUM) · Higher = larger blast radius
    52.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 37.7% · Lower = rushed or shallow review
    37.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 32.8% · Safe to merge
    32.8%