chore(audio-rooms): align catalog/announces error timing + comment (audit #5-7)

* announces() now throws UnsupportedOperationException at CALL
    time (not the first collect) on the IETF default — matches
    subscribeCatalog's timing so both can be guarded with one
    `runCatching { listener.announces() }` per session rather than
    a runCatching around every collect site (audit #6).

  * KDoc on announces() documents the deliberate hot-vs-cold
    asymmetry with subscribeSpeaker/subscribeCatalog: announce
    data is room-state with a single VM consumer (cold flow is
    sufficient), audio is per-frame playout with multi-collect
    resilience needs (hot SharedFlow with DROP_OLDEST). The
    different shapes are intentional, not accidental (audit #5).

  * MoqLiteNestsListener.wrapSubscription's "IETF SubscribeHandle
    path conventionally surfaces" comment was scoped to the audio
    track when first written; now the same body serves both audio
    and catalog. Re-frame so the comment applies to either track
    (audit #7).

Test: NestsListenerCatalogTest's announces-throws case now
asserts the call itself throws, not the collect.
This commit is contained in:
Claude
2026-04-27 02:28:24 +00:00
parent e4fe23a1e5
commit 43c5313674
3 changed files with 26 additions and 20 deletions
@@ -55,17 +55,17 @@ class NestsListenerCatalogTest {
}
@Test
fun ietfDefaultListenerAnnouncesFlowThrowsOnCollect() =
fun ietfDefaultListenerAnnouncesFlowThrowsAtCallTime() =
runTest {
// The announce-prefix channel is moq-lite only as well —
// the IETF reference path's announces() default body
// throws UnsupportedOperationException at collect time.
// Callers mixing the two protocols can `runCatching` the
// collect to no-op cleanly.
// throws UnsupportedOperationException at CALL time,
// matching subscribeCatalog's timing. Callers can
// `runCatching { listener.announces() }` once per session
// rather than wrapping every collect.
val listener = IetfStyleListener()
val flow = listener.announces()
assertFailsWith<UnsupportedOperationException> {
flow.collect { /* unreachable */ }
listener.announces()
}
}
}