fix(api): interleave album candidate-window anchors so recent media gets windows #1273
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/album-window-recent-first"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary\n- Learned-path candidate windows were generated oldest-media-first and hard-capped at
MAX_WINDOWS_PER_RUN = 500. On a real 21k-media library the last run produced exactly 500 windows covering 1972–2017 only — zero windows for 2018–2026. Because a trained model is active, the deterministic candidates are discarded entirely and suggestions are materialized only from learned windows, so recent photos could never become an album suggestion (verified in production: user's photos from 2026-10-16 produced no suggestion).\n- Anchor selection now interleaves newest/oldest ([t(n-1), t0, t(n-2), t1, …]) instead of walking strictly oldest→newest, so both ends of the timeline get windows under the cap. Window membership, kinds, gap rules, caps, dedup, and round-robin logic are unchanged;adaptive_gapsegments are still derived from time-ordered points (36h rule intact) and only their emission is interleaved.\n- Feature batch sent to the ML worker: ordering flipped tostarts_at DESC, id DESC(worker scores rows independently, so order carries no semantics) — documents/ensures that if the window cap and batch limit ever diverge, OLD windows drop out of scoring, never the newest ones (which would reintroduce this bug).\n\n## Validation\n-rtk ./gradlew :apps:api:test --tests '*AlbumSuggestion*' --tests '*AlbumShape*'→ BUILD SUCCESSFUL, 82 tests, 0 failures.\n- New regression testcandidateWindowCapInterleavesAnchorsSoNewestAndOldestMediaGetWindows: weekly media 1995–2026 (1,635 items, ≫500 candidates) asserts asame_daywindow at the newest AND oldest capture instant, with the cap still exactly 500. No existing test asserted the old ordering.\n\n## Known limitation (tracked)\n[KNOWN_ISSUES ISSUE-166] A single day with >500 photos produces no window at all (oversized windows are dropped, not trimmed) — out of scope here.