Fase 2 stap A: write-through van de Hero naar de bibliotheek (schakelaar uit), per-slide uitsnede en set in de bibliotheek

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 23:05:35 +01:00
co-authored by Claude Sonnet 5.5
parent ed0b6ad61c
commit 369bf73666
18 changed files with 332 additions and 15 deletions
@@ -1,6 +1,6 @@
# Phase 2: the Hero works through the library, and a crop per use
Status (2026-11-17): step B (crop per slide) is built on this branch (backend, frontend, tests); steps A and C and phase 3 are not built. Branch `feature/media-library-phase2` (no PR until #22 is merged). Test only; every switch is OFF by default; SLS-Main is told before every test deploy; phase 3 (dropping the old tables) only after phase 2 is verified on test and never on production without a separate go from Bryan.
Status (2026-11-17): step B (crop per slide) and step A (write-through, switch off by default) are built on this branch; step C and phase 3 are not built. Branch `feature/media-library-phase2` (no PR until #22 is merged). Test only; every switch is OFF by default; SLS-Main is told before every test deploy; phase 3 (dropping the old tables) only after phase 2 is verified on test and never on production without a separate go from Bryan.
## What Bryan wants
@@ -93,3 +93,10 @@ Switches are set through the existing deploy workflow input path (the same way a
- Test data is no longer assumed to be rebuildable: there is a recorded restore point (above). The Hero tables stay authoritative until phase 3; "reads and writes through the library" is reached in steps A and C behind switches, not by replacing the tables in one go (a one-go replacement cannot be rolled back by a switch).
- The crop per slide lives in the slide (nullable) in the Hero until phase 3 and is mirrored to `MediaUses.Crops`; moving the authority to `MediaUses` is part of phase 3.
## Step A as built (2026-11-17)
- `IMediaLibrarySync` (Core; default `NoMediaLibrarySync`) is called by the Hero after every saved change: upload (also the same photo again), focus of a photo, focus and reset of a slide, trash, restore, purge, delete, saving the hero, the renderer finishing a set (photo or slide) and the clean-up. The Media module replaces it with `MediaLibrarySync`, which runs the verified copier for the `hero` module only, one at a time, **only when `Media__Library__DualWrite=true`**, and never throws (a failure is logged; the next change or the start-up copy repairs it). The Hero's own tables are never touched by it.
- The slide as it is shown is what lands in the library: for a slide with its own crop the use gets the slide's set hash and crops (`MediaUses.SetHash`, `MediaUses.Crops`).
- Switch through the deploy workflow like the copy: dispatch input `media_library_dual_write` (unchanged, on, off; test only).
- **What Bryan can check on test with the switch on:** make any change in the Hero or the library (upload, crop a slide, save, trash, restore); then in the database `SELECT COUNT(*) FROM MediaAssets / MediaUses` equals `HeroImages` / `HeroSlides`, and for a slide with its own crop `MediaUses.SetHash` equals `HeroSlides.SetHash`. The log has no line "The write-through of hero to the media library failed". With the switch off nothing changes at all.