Skip to content

Merge person and series spellings, and undo a merge, in one transaction - #560

Merged
KodeStar merged 8 commits into
mainfrom
burndown/srv-merge
Nov 22, 2026
Merged

KodeStar merged 8 commits into
mainfrom
burndown/srv-merge

Conversation

@KodeStar

Copy link
Copy Markdown
Owner

Merging spellings of an author, a narrator or a series in the console is now one server request in one transaction, and so is its Undo. A failure or a closed tab no longer leaves some books merged and others not.

  • POST /admin/books/merge (catalog/merge.go): whole-credit matching (a co-credit naming the spelling keeps it), every matching book changed or none, through bulk edit's per-book path (a refused book is named). Capped at 5,000 books (400 too_large); an unknown library is 404, a podcast library 409 not_book_library. Audited as "Merged spellings" with the spellings and the scope.
  • POST /admin/books/merge/undo (catalog.UndoMerge): the console posts the merge's reply back; the books go back in one transaction, books edited since are listed as changed and books moved by a scan as not_found, the rest are restored. Its own audit entry.
  • Console: Library > Authors / Narrators merge and Health's series spellings send one request each; the toast's Undo runs once, a partial Undo names the paths left, a failed one can be retried.
  • Admin routes only: nothing on the player wire, no migration, paths never books.id.

Part of #224 ("People merge isn't atomic").

Verified live, 17/17 (console in a real browser, en, de, fr, it): a server killed 0.2 s into a 4,500-book merge wrote nothing; a book refused by a trigger rolled back all 4,500; 5,001 books answer too_large; a 4,500-book merge took 0.55 s and its Undo 0.51 s; Undo after an edit and after a rescan move; 404, 409, 403 and 401. Gate: build-admin (1,951 console tests), go build/vet/test -race/golangci-lint on the pure-Go and native SQLite engines.

Docs: KodeStar/audiosilo-docs (paired PR).

Merging spellings of a person or a series is now one admin request that rewrites every affected book in one transaction, so a failure or a closed tab no longer leaves some books merged and others not. Undo restores the prior values and their sources through the existing bulk-edit path. Fixes part of #224 (People merge isn't atomic).
MergeSpellings copied EditBooks' loop over editTx but dropped the path that EditBooks adds to a refused book's error, so a refused merge did not say which book. Both now call editRefsTx.

Part of #224.
A merge's Undo sends one bulk edit per prior override and per 1,000 books. The first failed request stopped the rest, leaving later books merged with no way to retry. Every step now runs, and the error toast offers Undo again for only the books whose step failed.

Part of #224.
The IN list was sized to the number of spellings, so each count prepared a new statement and churned the per-connection statement cache. The spellings now go through json_each, and the transaction closure no longer assigns the outer err.

Part of #224.
The series-spellings and MergeSuggestion comments still sent readers to the bulk edit, which no longer applies a merge.

Part of #224.
The repeat merge shadowed the reply body, so hoisting that line would have left the Undo loop checking nothing.

Part of #224.
The console undid a merge with one bulk edit per group of up to 1,000
books, so a closed tab lost the rest, one book a scan had moved failed its
whole group with a 404 that named no book, and Undo overwrote a book
edited since the merge. POST /admin/books/merge/undo takes the merge's
reply back and puts every book that still carries the merged spelling
back in one transaction; a book gone from the index or edited since is
left as it is and named in "skipped", and the console says which.

A merge now changes at most 5,000 books (400 too_large, nothing written),
so its transaction stays short on a slow disk and its Undo fits one
request, and a merge scoped to a missing library answers 404 (a podcast
library 409) instead of an empty success.

Part of #224.
The merge's audit entry named only the target and the book count, so the
log could not say which spellings were folded in or whether one library
or all of them were touched. It now lists the sources (the first 20, each
cut at 120 characters) as "Merged spellings" and the library when the
merge was scoped to one.

Part of #224.
@KodeStar
KodeStar merged commit 84556dd into main Nov 22, 2026
6 checks passed
@KodeStar
KodeStar deleted the burndown/srv-merge branch November 22, 2026 18:24
@KodeStar KodeStar moved this from Backlog to Done in AudioSilo Nov 22, 2026
@github-project-automation github-project-automation Bot moved this to Backlog in AudioSilo Nov 22, 2026
KodeStar added a commit to KodeStar/audiosilo-docs that referenced this pull request Nov 22, 2026
Documents KodeStar/audiosilo-server#560: merging author, narrator and
series spellings changes every matching book or none, and Undo puts them
back in one request.

- Admin pages: Library > Authors and Narrators ("Merging two spellings":
whole-credit matching, the 5,000-book limit, what Undo puts back and
what it leaves and names), Health's series spellings (its own library
only, linking to the author section), the audit log's "Merged spellings"
and "Reverted" entries.
- Developer pages: `POST /admin/books/merge` and `POST
/admin/books/merge/undo` in the API reference (shapes, `too_large`, 404,
409 `not_book_library`, `changed` / `not_found`, the audit entries), the
console page, the scanner page's note on merged names.
- `scripts/server-names.json`: the two new admin routes, pinned to the
merged server commit.

No screenshots change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant