1 Commits

Author SHA1 Message Date
Georges-Antoine Assi
1246d18fe3 refactor(streaming): resolve containers once, behind a broker protocol
Two shapes of streaming broker were branched on at 19 call sites, and every
consumer re-derived a container's host, key, emulator, capabilities and card
sync from the raw YAML on each call. `_containers_for_platform` re-ran host
parsing and the operator's misconfiguration warnings on every request, and
`_container_label` re-read config.yml once per listed row.

`handler/streaming/`:
- `protocol.py` gives each broker shape a class owning its route prefixes,
  timeouts, response dialect, stream-URL assembly and capability flags. A call
  site now asks `protocol.supports_disc_swap` or `protocol.save_state_accepted`
  instead of re-testing `protocol: webstation`. Instances are interned per
  subfolder so identical configs share one object.
- `capabilities.py` holds the per-platform and per-emulator slot tables and the
  state transfer limits, keyed purely by platform and emulator.
- `config.py` turns the raw list into frozen `ResolvedContainer` records with
  every question already answered, memoized until the config changes, so the
  warnings fire once per config rather than once per lookup. A container RomM
  cannot dial still resolves, with an empty key: unclaimable, but visible in
  the admin fleet view where the operator can see why.

`endpoints/streaming.py` drops ~700 lines and takes records rather than dicts
throughout; `container.emulator` and `container.protocol.session_route(...)`
replace the derivations that used to run per call.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-05 10:13:46 -04:00