perf(hub): cache the names directory, share state builds, retry stations

Concurrent /api/state polls share one build through LiveState for a short TTL, and every POST and PATCH invalidates it, so a write is never followed by a stale view. The names directory is cached, the first transcript scan reads outside the hub lock, the graph timeline starts at the window begin, and unresolved radio stations are retried on a daemon thread every RETRY_SECONDS instead of failing until restart.

🎯 Fix: 85 %
💥 Break: 8 %
💸 Tokens: –
⏱️ Velocity: –
🛡️ Security: 100 %
🏆 Score: 78
🚦 Gate: ⛔ fix 85 % < 90, break 8 % > 5

Created-with: https://s.veen.world/skills
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kevin Veen-BirkenbachandClaude Opus 5.5 committed 2026-11-18 19:54:23 +00:00
1 parent 6c63c364bd
commit 96d4d2933c
18 files changed
+299 -32

No files matched your search

+18
View File
@@ -351,6 +351,24 @@ class TestRedirectSettings(HubCase):
self.assertEqual([stream["via"] for stream in retried["settings"]["streams"]], [["https://*.cdn.test"], ["https://*.cdn.test"]])
self.assertEqual(retried["problems"], [])
def test_an_unresolved_station_heals_without_a_save_once_due(self):
saved = self.signed_and_saved([self.station(STATION, [])])["settings"]
cdn().httpd.broken.add("station.radio.test")
self.addCleanup(cdn().httpd.broken.discard, "station.radio.test")
other = "https://station.radio.test/other"
self.signed_and_saved([*saved["streams"], self.station(other, [])])
hub = self.httpd.hub
before = self.dials()
self.assertEqual((hub.retry_stations(), self.dials() - before), ([], 0))
hub.redirects.tried[other] -= RETRY_SECONDS
self.assertEqual(hub.retry_stations(), ["DLF: answers 302 without a Location"])
self.assertIsNone(hub.settings.get()["streams"][1]["via"])
cdn().httpd.broken.discard("station.radio.test")
hub.redirects.tried[other] -= RETRY_SECONDS
self.assertEqual(hub.retry_stations(), [])
self.assertEqual([stream["via"] for stream in hub.settings.get()["streams"]], [["https://*.cdn.test"], ["https://*.cdn.test"]])
self.assertIn("https://*.cdn.test", self.media_src())
def test_a_save_that_lands_while_another_resolves_makes_that_one_fail(self):
saved = self.signed_and_saved([self.station(STATION, [])])["settings"]
slow = [*saved["streams"], self.station("https://drip.radio.test/", [])]