Waiting approvals read again within hours; repairs kept from a channel's first read; abandoned tunes noted (build 68)

22 November 2026, after four days on the VPS: After Dark's 99 moved approvals were still waiting, because its pool
wasn't due again for a week after the read that paced out. A pool with approvals still waiting for their provider ID
(and not cooling down) is now read again after PARTIAL_POOL_RETRY_MS. Mistletoe's and Sakura's first reads (seedLoop)
found their titles but didn't keep the new IDs in their choices; every read now does (keepRefound). And every tune
that never shows a picture is noted with how long it was tried and the player's state (Limmy's Show on Orbit Three,
Eraserhead on After Dark: both fine on the server now, the reason lost with the log).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-22 21:16:50 +00:00
co-authored by Claude Opus 5.5
parent a1c66c25e9
commit 9642be0bcc
5 changed files with 85 additions and 15 deletions
@@ -317,3 +317,52 @@ class SelfHealingApprovalTest {
folder.deleteRecursively()
}
}
/** 22 November 2026: repairs kept from a channel's first read, and approvals still waiting are read again within hours. */
class WaitingApprovalsTest {
@org.junit.Before fun server() { EmbyServer.origin = "https://emby.example.com"; IdRepairs.resetForTest() }
@org.junit.After fun noServer() { EmbyServer.origin = ""; IdRepairs.resetForTest() }
private val user = "0123456789abcdef0123456789abcdef"
private fun film(id: String, name: String) = JSONObject().put("Id", id).put("Name", name).put("Type", "Movie").put("ProductionYear", 1990)
.put("MediaSources", JSONArray().put(JSONObject().put("Id", "s$id").put("Container", "mkv").put("RunTimeTicks", 90 * 60_000L * 10_000)))
private fun transport(found: () -> Boolean) = EmbyTransport { r ->
when {
found() && "AnyProviderIdEquals=imdb.tt0100814" in r.path -> EmbyReply(200, JSONObject().put("Items", JSONArray().put(film("new1", "Tremors"))).toString())
"Ids=new1" in r.path -> EmbyReply(200, JSONObject().put("Items", JSONArray().put(film("new1", "Tremors"))).toString())
"AnyProviderIdEquals=imdb.tt0094074" in r.path -> EmbyReply(200, JSONObject().put("Items", JSONArray().put(film("new2", "Tremors 2"))).toString())
"Ids=new2" in r.path -> EmbyReply(200, JSONObject().put("Items", JSONArray().put(film("new2", "Tremors 2"))).toString())
"AnyProviderIdEquals=imdb.tt0120375" in r.path -> EmbyReply(200, JSONObject().put("Items", JSONArray().put(film("new3", "Tremors 3"))).toString())
"Ids=new3" in r.path -> EmbyReply(200, JSONObject().put("Items", JSONArray().put(film("new3", "Tremors 3"))).toString())
else -> EmbyReply(200, JSONObject().put("Items", JSONArray()).toString())
}
}
private val mine = ChannelProgramming(701, "Mine", emptyList(), filmRestMs = 1L)
private val approvals = ChannelChoices(listOf(Suggestion("moved-1", "Tremors", 1990, "Movie", "", "", ref = "imdb.tt0100814"),
Suggestion("moved-2", "Tremors 2", 1990, "Movie", "", "", ref = "imdb.tt0094074"), Suggestion("moved-3", "Tremors 3", 1990, "Movie", "", "", ref = "imdb.tt0120375")))
@Test fun aChannelsFirstReadKeepsItsRepairs() {
val dir = kotlin.io.path.createTempDirectory("waiting").toFile(); val store = ScheduleStore(dir)
store.saveChoices(user, 701, approvals)
val scheduler = ChannelScheduler(store)
scheduler.seedLoop(EmbySampleSession(transport { true }, "fixture-token-private", user, EmbySample(emptyList(), 0)), user, mine)
assertEquals(setOf("new1", "new2", "new3"), store.loadChoices(user, 701).accepted.map { it.id }.toSet())
dir.deleteRecursively()
}
@Test fun anApprovalStillWaitingIsReadAgainWithinHoursNotAWeek() {
val dir = kotlin.io.path.createTempDirectory("waiting").toFile(); val store = ScheduleStore(dir)
store.saveChoices(user, 701, approvals)
var now = 1_800_000_000_000L
val scheduler = ChannelScheduler(store, clock = { now })
IdRepairs.clock = { now }
var found = false
val session = EmbySampleSession(transport { found }, "fixture-token-private", user, EmbySample(emptyList(), 0))
val loop = scheduler.seedLoop(session, user, mine) // Tremors 2 found; Tremors not yet
assertEquals(setOf("new2", "new3"), store.loadPool(user, 701)!!.series.map { it.id }.toSet())
found = true
now += PARTIAL_POOL_RETRY_MS + IdRepairs.FIRST_COOLDOWN_MS
scheduler.topUp(session, user, mine, loop)
assertEquals(setOf("new1", "new2", "new3"), store.loadPool(user, 701)!!.series.map { it.id }.toSet())
dir.deleteRecursively()
}
}