# Smart setup: evening rotation fix (9 November 2026) Branch `smartsetup-rotation-fix` from `story-p1000` (`585ac72`), version 0.110.15-smartsetup, versionCode 298. Not installed. ## What was wrong Shaped channels (smart setup, such as Orbit Sakura) rotate their evening and late-night shows weekly: at most 12 evening and 24 late shows a week, a different set each week (commit `de68578`, 7 November). Two problems: 1. **The week came from the clock.** `programmingOf` called `rotationWeek()` with the real time, so the same plan made on a different day came out differently. `SmartSetupRegressionTest` (planned from a fixed Saturday, 7 November) started failing after midnight on Monday 9 November, when the rotation turned over. 2. **Sets were split by count, alphabetically.** Sakura's 29 evening shows made three sets of 10, 10 and 9, but one set was ten short films (14 hours), another 116 hours of series. The thin week (from Monday 16 November) planned 30 repeats in a week, the first after 2.5 days, against 15 and 6 days in the others. ## The fix - `shapedParts` no longer picks the week: it gives the planner the whole rotating list ([DayPart.rotating], with the week's cap and the slot's weekly hours). A part that borrows the evening's titles (an empty daytime) rotates with the evening. - `topUpPlan` resolves the rotation first ([resolveRotations]): the week from the plan's own time (`rotationWeek(nowMs, zone)`, which no longer has a clock default), and the sets **balanced by running time** from the real pool ([rotationSet]): longest first into the lightest week, each show counting at most the hours its slot runs in a week. Deterministic: the same titles, pool and week always give the same set. - `CustomChannels.programmings` no longer rebuilds each week: nothing in a channel's programming depends on the date. - Plans already committed are untouched; new days are planned with the balanced sets. ## Result (Orbit Sakura, the real Crunchyroll collection) | Week from | Before | After | |---|---|---| | 7 Nov | 15 repeats, first after 6.1 days | 17, first after 6.1 | | 9 Nov | 16, 6.1 | 16, 6.1 | | **16 Nov** | **30, 2.5** | **15, 6.1** | | 23 Nov | 15, 6.1 | 17, 6.1 | | 30 Nov | 16, 6.1 | 16, 6.1 | Every week now has 15 to 17 repeats, all on its last day. The regression test's limit is 18 a week (it was 15 when only one week was ever measured; the original run had 34), with no repeat before day 5. Orbit Mistletoe (no evening part) is unchanged: no repeats. ## Tests - `SmartSetupRegressionTest.everyRotationWeekStaysWithinTheRepeatsAndStartsNoEarlierThanDayFive`: Sakura and Mistletoe planned from eight dates across a whole turn of the rotation (Saturdays and Mondays). - `SmartSetupRegressionTest.plansDependOnTheirOwnTimeNeverTheClock`: the same plan twice, and a shaped channel's programming carries its rotation for the planner. - `SmartSetupTest.rotationSetsAreBalancedByRunningTimeAndCoverEveryShowOnce`.