A provider lookup paced out of the hour's budget starts no cooldown (build 67)
release-gate / verify (push) Successful in 9m26s
pauljd/davidson-ci: Davidson CI / quality (push) Failing after 13m9s
pauljd/davidson-ci: Davidson CI / ai-review (push) Failing after 3m21s

18 November 2026, After Dark's first read after the server move: it spent the hour's 190 requests, and the approvals
still waiting were counted as found-nothing and put on the 6-hour cooldown. A lookup that couldn't be made (paced out,
the server not answering) now throws past IdRepairs and records nothing, so the approval is simply tried again at the
next read. Tests for both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-18 15:30:14 +00:00
co-authored by Claude Opus 5.5
parent fb6f68258d
commit a1c66c25e9
4 changed files with 43 additions and 9 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ plugins {
id("org.jetbrains.kotlin.plugin.compose")
}
/** The release's build number: versionCode is this x 10 plus the edition's channel. */
val ORBIT_BUILD = 66
val ORBIT_BUILD = 67
android {
namespace = "tv.orbit.classic"
compileSdk = 36
@@ -479,10 +479,11 @@ internal class EmbySampleSession(private val transport: EmbyTransport, private v
if (found == null && accepted.ref.isNotEmpty()) {
// A repair kept from before is tried first; a stale one is dropped and looked up afresh, once.
for (attempt in 0..1) {
val id = IdRepairs.lookup("Movie", accepted.ref) {
// Paced out or not answering: tried again at the next read, with no cooldown.
val id = try { IdRepairs.lookup("Movie", accepted.ref) {
requests++
pickByProvider(runCatching { byProvider("Movie", accepted.ref, "&Fields=ProductionYear") }.getOrDefault(emptyList()), accepted.title, accepted.year)?.optString("Id")
} ?: break
pickByProvider(byProvider("Movie", accepted.ref, "&Fields=ProductionYear"), accepted.title, accepted.year)?.optString("Id")
} } catch (cancelled: kotlinx.coroutines.CancellationException) { throw cancelled } catch (_: Exception) { null } ?: break
if (id == accepted.id) break
requests++
found = playableFilm(id, programming.englishAudio, accepted.title, accepted.year)
@@ -498,10 +499,10 @@ internal class EmbySampleSession(private val transport: EmbyTransport, private v
// one request, only when reading it by its saved ID fails or finds nothing (18 November 2026).
fun refind(): PoolSeries? {
if (accepted.ref.isEmpty()) return null
val id = IdRepairs.lookup("Series", accepted.ref) {
val id = try { IdRepairs.lookup("Series", accepted.ref) {
requests++
pickByProvider(runCatching { byProvider("Series", accepted.ref, "&Fields=ProductionYear") }.getOrDefault(emptyList()), accepted.title, accepted.year)?.optString("Id")
}?.takeIf { it != accepted.id } ?: return null
pickByProvider(byProvider("Series", accepted.ref, "&Fields=ProductionYear"), accepted.title, accepted.year)?.optString("Id")
} } catch (cancelled: kotlinx.coroutines.CancellationException) { throw cancelled } catch (_: Exception) { null }?.takeIf { it != accepted.id } ?: return null
return runCatching { read(id) }.getOrNull()?.takeIf { it.episodes.isNotEmpty() }?.also { refound[accepted.id] = id; accepted = accepted.copy(id = id) }
?: run { IdRepairs.forget("Series", accepted.ref); null }
}
@@ -49,7 +49,7 @@ internal object IdRepairs {
/**
* The item for [ref]: the kept repair, or [fetch] (one lookup, never two at once for the same title, never during a
* cooldown). A fetch that finds nothing starts or lengthens the cooldown.
* cooldown). A fetch that finds nothing starts or lengthens the cooldown; one that throws records nothing and throws on.
*/
fun lookup(type: String, ref: String, nowMs: Long = System.currentTimeMillis(), fetch: () -> String?): String? {
if (ref.isEmpty()) return null
@@ -57,7 +57,9 @@ internal object IdRepairs {
synchronized(locks.getOrPut(k) { Any() }) {
known(type, ref)?.let { return it }
if (coolingDown(type, ref, nowMs)) return null
val id = runCatching(fetch).getOrNull()?.takeIf { EmbyClient.validId(it) }
// A lookup that couldn't be made (paced out of the hour's budget, the server not answering) isn't a lookup that
// found nothing: it throws to the caller and starts no cooldown (18 November 2026, After Dark's first read).
val id = fetch()?.takeIf { EmbyClient.validId(it) }
record(k, id, nowMs)
return id
}
@@ -99,3 +99,34 @@ class RemakeGuardTest {
} finally { EmbyServer.origin = ""; IdRepairs.resetForTest() }
}
}
/** 18 November 2026: After Dark's first read after the move ran out of the hour's budget mid-way. */
class PacedLookupTest {
@org.junit.Before fun clean() { IdRepairs.resetForTest(); EmbyServer.origin = "https://emby.example.com" }
@org.junit.After fun after() { IdRepairs.resetForTest(); EmbyServer.origin = "" }
@Test fun aLookupThatCouldntBeMadeStartsNoCooldown() {
assertThrows(PacedOut::class.java) { IdRepairs.lookup("Movie", "imdb.tt5", 0L) { throw PacedOut() } }
assertFalse(IdRepairs.coolingDown("Movie", "imdb.tt5", 1L))
assertEquals("ok", IdRepairs.lookup("Movie", "imdb.tt5", 2L) { "ok" })
}
@Test fun anApprovalPacedOutIsTriedAgainAtTheNextRead() {
var paced = true
val transport = EmbyTransport { r ->
when {
paced && "AnyProviderIdEquals" in r.path -> throw PacedOut()
"AnyProviderIdEquals=imdb.tt0100814" in r.path -> EmbyReply(200, JSONObject().put("Items", org.json.JSONArray().put(JSONObject().put("Id", "new1").put("Name", "Tremors").put("Type", "Movie"))).toString())
"Ids=new1" in r.path -> EmbyReply(200, JSONObject().put("Items", org.json.JSONArray().put(JSONObject().put("Id", "new1").put("Name", "Tremors").put("Type", "Movie")
.put("MediaSources", org.json.JSONArray().put(JSONObject().put("Id", "s1").put("Container", "mkv").put("RunTimeTicks", 90 * 60_000L * 10_000))))).toString())
else -> EmbyReply(200, JSONObject().put("Items", org.json.JSONArray()).toString())
}
}
val s = EmbySampleSession(transport, "fixture-token-private", "fixture-user", EmbySample(emptyList(), 0))
val channel = ChannelProgramming(305, "After Dark", emptyList(), filmRestMs = 1L)
val choices = ChannelChoices(listOf(Suggestion("moved-1", "Tremors", 1990, "Movie", "", "", ref = "imdb.tt0100814")))
assertTrue(s.readChannelPool(channel, null, choices).series.isEmpty())
paced = false
assertEquals(listOf("new1"), s.readChannelPool(channel, null, choices).series.map { it.id })
}
}