Skip to content

fix(video): escalate live reopen exhaustion for URL sources too - #343

Merged
superuser404notfound merged 1 commit into
superuser404notfound:mainfrom
tschuegy:fix/live-reopen-exhaustion-halt
Aug 10, 2026
Merged

superuser404notfound merged 1 commit into
superuser404notfound:mainfrom
tschuegy:fix/live-reopen-exhaustion-halt

Conversation

@tschuegy

@tschuegy tschuegy commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Problem

Both live reopen-exhaustion sites escalate only for the .customFactory transport that #199 introduced:

  • the barren-cycle cap in handlePumpFinished ("live source produced no segments across N reopen cycles; giving up"), and
  • the attempt cap at the end of performLiveReopen ("live reopen FAILED after N attempts; source considered permanently lost").

A URL-source live session that exhausts its reopen budget reaches the same terminal state with neither markLiveProductionHalted() nor onLiveSourceReset: the provider keeps advertising blocking reloads it can never satisfy (the -15410 shape the halt latch exists for), the playlist stays frozen, and the host is never asked to retune. That is exactly the zombie window #199 closed for engine-created ingest readers — still open on the most common transport.

Found while tracing a field freeze (same session as #340/#341/#342): the incident itself died through the live-muxerFailed hole #341 covers, but this adjacent exhaustion path has the identical failure shape for URL sources whose reopens run dry.

Fix

Extract the escalation decision as a pure function, liveReopenExhaustionEscalatesToHost(transport:), covering every reopenable transport, and use it at both sites. .none deliberately stays out: a transport-less source delegates to host retune before any reopen begins, and escalating it again would double-signal liveSourceReset.

Behavior for .customFactory is unchanged; .url now halts + signals on exhaustion instead of zombifying.

Tests

Pinned in Issue199RerouteRecoveryTests next to the existing transport-decision pins: .url and .customFactory escalate on exhaustion; .none never reaches the escalation.

🤖 Generated with Claude Code

Both reopen-exhaustion sites (the barren-cycle cap in
handlePumpFinished and the attempt cap at the end of performLiveReopen)
halted production and published onLiveSourceReset only for the
.customFactory transport superuser404notfound#199 introduced. A URL-source live session
that exhausted its reopen budget hit the same terminal state with
neither: the provider kept advertising blocking reloads it could never
satisfy, the playlist stayed frozen, and the host was never asked to
retune — the exact zombie window superuser404notfound#199 closed for engine-created ingest
readers, still open on the most common transport.

Extract the escalation decision as a pure function covering every
reopenable transport (.none stays out: it delegates to host retune
before any reopen begins, and escalating it again would double-signal
liveSourceReset) and use it at both sites.

Co-Authored-By: Claude Fable 5 <[email protected]>
@superuser404notfound
superuser404notfound merged commit f7e44af into superuser404notfound:main Aug 10, 2026
3 checks passed
superuser404notfound pushed a commit that referenced this pull request Aug 10, 2026
…is exhaustive

Follow-up to #343. The generalisation is right: a URL live source that spends
its reopen budget reaches the same dead end the factory transport does, and
#199 only ever escalated the transport it introduced.

Two things the predicate alone does not hold.

`transport != .none` classifies every transport added later by accident, and
`.none` is the standing proof that "everything except one case" was already
the wrong shape once: a future transport that delegates to host retune before
reopening (exactly what `.none` does) would inherit the escalation and signal
the host twice. Now an exhaustive switch, so the compiler asks.

And the decision was never the whole fix. Both exhaustion sites carried their
own copy of the two effects, and the halt is the half that is easy to lose:
`onLiveSourceReset` alone (what the #65 stall ladder publishes) still leaves a
dead provider advertising blocking reloads it cannot answer, which is the
-15410 the halt latch exists for. Both sites now call one method that owns the
decision and both effects together.

Tests: the two new pins go through that method on a real engine and provider,
so they fail if either effect is dropped or if `.none` starts escalating; the
predicate-only tests could not see a call site regress. Verified by mutation
(dropping the halt fails the URL pin, removing the guard fails the `.none`
pin). CHANGELOG entry, and the em-dash.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01HX5zV3Fcf7Nzq4DYGdXvQE
@superuser404notfound

Copy link
Copy Markdown
Owner

Merged. Verified onto current main (the branch was based on 6.15.3): 1689 swift-testing plus 483 XCTest green, tvOS build clean. One conflict on the way in, since #341 landed liveRecoveryBudgetDecision at the same spot; both pure decisions now sit next to each other.

The analysis holds all the way down. A .url source reaches both exhaustion sites with its provider un-halted precisely because the transport exists: shouldHaltLiveProduction returns false for the recoverable exit reasons, so the barren-cycle cap and the attempt cap are the only places left to latch it, and #199 wired only the transport it introduced. Since #342 a frozen URL live session does get a consumer-side rescue (the stall ladder publishes liveSourceReset on the final rung), but that arm never halts production, so the dead provider kept advertising blocking reloads it could not answer. This closes the producer-side half, which is the half that owns the latch.

Two things pulled in on top, in 23a5065.

transport != .none classifies any transport added later by accident, and .none is the standing proof that "everything except one case" was already the wrong shape once: a future transport that delegates to host retune before reopening (exactly what .none does) would inherit the escalation and signal the host twice. It is an exhaustive switch now, so the compiler asks instead.

Both exhaustion sites also carried their own copy of the two effects, and the halt is the half that is easy to lose. One method owns the decision and both effects now, and the two new tests go through that method on a real engine and provider, so a call site that regresses fails them where the predicate-only pins could not. Checked by mutation: dropping the halt fails the URL pin, removing the guard fails the .none pin.

Not released yet, it goes out with #340, #341 and #342.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants