0.99.14: read-only source diagnostics for the series inspection (Beerus check)
pauljd/davidson-ci: Davidson CI / quality (push) Failing after 1m48s
pauljd/davidson-ci: Davidson CI / ai-review (push) Failing after 1m20s

Per-source codec, profile, resolution, audio and subtitle tracks, decoder verdict with reasons, completeness; safe labels
only, nothing sensitive logged. Scheduling untouched: all 30 booking fingerprints identical to 0.99.13.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-11-04 14:34:15 +00:00
co-authored by Claude Opus 5.5
parent f93f79823f
commit 0780e15dc2
10 changed files with 244 additions and 13 deletions
@@ -0,0 +1,53 @@
package tv.orbit.classic
import org.json.JSONArray
import org.json.JSONObject
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
class SourceDiagnosticsTest {
private val minute = 600_000_000L
private fun stream(vararg pairs: Pair<String, Any>) = JSONObject(pairs.toMap())
private fun source(container: String, id: String = "8016760", ticks: Long = 23 * minute, vararg streams: JSONObject) = JSONObject(mapOf(
"Id" to id, "Container" to container, "RunTimeTicks" to ticks, "Path" to "/mnt/media/anime/Dragon Ball Super Beerus - S01E01.mkv",
"DirectStreamUrl" to "/videos/8016760/stream.mkv?api_key=SECRET", "MediaStreams" to JSONArray(streams.toList())))
private val h264 = stream("Type" to "Video", "Codec" to "h264", "Profile" to "High", "Width" to 1920, "Height" to 1080, "BitDepth" to 8, "Title" to "1080p from /mnt/media")
private val jaAac = stream("Type" to "Audio", "Codec" to "aac", "Language" to "jpn", "Channels" to 2, "IsDefault" to true, "DisplayTitle" to "Japanese AAC")
private val enEac3 = stream("Type" to "Audio", "Codec" to "eac3", "Language" to "eng", "Channels" to 6)
private val enAss = stream("Type" to "Subtitle", "Codec" to "ass", "Language" to "eng", "IsDefault" to true, "DeliveryUrl" to "/Videos/1/Subtitles/2/Stream.ass?api_key=SECRET")
private val srtExternal = stream("Type" to "Subtitle", "Codec" to "srt", "Language" to "por", "IsExternal" to true, "Path" to "/mnt/media/subs.srt")
private fun describe(s: JSONObject, canDecode: (String) -> Boolean = { true }, has: (String) -> Boolean = { true }, failed: Boolean = false) = describeSource(s, 0, canDecode, has, failed)
@Test fun aPlayableSourceIsDescribedInFull() {
val line = describe(source("mkv", streams = *arrayOf(h264, jaAac, enEac3, enAss, srtExternal)), has = { it != "audio/eac3" })
assertEquals("inspect source=8016760 container=mkv min=23 video=h264 profile=High 1920x1080 8bit decoder=yes " +
"audio=2[aac jpn 2ch default, eac3 eng 6ch no-decoder] english=yes subs=2[ass eng default, srt por external] verdict=playable", line)
}
@Test fun rejectionsGiveTheirReasons() {
val line = describe(source("avi", id = "bad/id", ticks = 0, h264), canDecode = { it != "h264" }, failed = true)
assertTrue(line, line.contains("decoder=no"))
assertTrue(line, line.endsWith("verdict=rejected(container avi not played directly; no usable source id; no h264 decoder on this box; runtime unknown or too long; failed to play here before)"))
}
@Test fun theVerdictMatchesWhatTheSchedulerAccepts() {
val cases = listOf(source("mkv", streams = *arrayOf(h264, jaAac)), source("avi", streams = *arrayOf(h264)), source("mkv", ticks = 0, streams = *arrayOf(h264)),
source("mp4", streams = *arrayOf(stream("Type" to "Video", "Codec" to "vc1"))))
val canDecode = { codec: String -> codec != "vc1" }
for (s in cases) {
val row = JSONObject(mapOf("MediaSources" to JSONArray(listOf(s))))
assertEquals(s.toString(), playableSource(row, canDecode) != null, describe(s, canDecode).endsWith("verdict=playable"))
}
}
@Test fun nothingSensitiveReachesTheLog() {
val hostile = stream("Type" to "Audio", "Codec" to "aac?api_key=SECRET", "Language" to "/mnt", "Profile" to "x")
val video = stream("Type" to "Video", "Codec" to "h264", "Profile" to "https://host/stream?api_key=SECRET")
val line = describe(source("mkv", streams = *arrayOf(video, hostile, enAss, srtExternal)))
for (secret in listOf("SECRET", "/mnt", "api_key", "http", "Beerus", "Stream.ass", "subs.srt", "1080p", "Japanese")) assertFalse("$secret in $line", line.contains(secret))
assertTrue(line, line.contains("profile=unknown") && line.contains("audio=1[unknown und]"))
}
}