Repository navigation
feat(player): bound budget-parked origin streams with detach and ranged resume - #100
Conversation
…ed resume Implements #94: a budget-parked direct-play origin stream now stays warm only for a bounded grace (default 25s), then deliberately detaches at the write cursor instead of suspending indefinitely under reverse-proxy send timeouts; returning demand reopens an exact-byte Range request through the shared retarget seam. Deliberate detach never advances the failure streak, outage state, or interruptions. Adds sticky high/low-water prefetch hysteresis, strong-ETag capture with If-Range validation on reopen (a full 200 against a sent validator escalates as sourceEntityChanged and discards the cached prefix instead of stashing it), delivery-gated resume threading from the V3 plan, an injectable origin-stream clock, and stats overlay diagnostics. Non-resumable deliveries keep the legacy indefinite park. Code written by OpenAI Codex CLI (gpt-5.6-sol) from a Claude-authored spec; reviewed and verified by Claude. Co-Authored-By: Claude Fable 5 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe PR adds direct-stream resume metadata, bounded origin-stream detachment and reopening, strong ETag and range validation, entity-change propagation, cache prefetch hysteresis, playback diagnostics, and focused integration tests. ChangesDirect stream resume
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related issues
Possibly related PRs
Sequence Diagram(s)sequenceDiagram
participant PlayerViewModel
participant PlaybackSourceProxy
participant PlaybackOriginStream
participant OriginServer
PlayerViewModel->>PlaybackSourceProxy: configure resume capability
PlaybackSourceProxy->>PlaybackOriginStream: reopen detached stream
PlaybackOriginStream->>OriginServer: request range with If-Range
OriginServer-->>PlaybackOriginStream: return validated or changed response
PlaybackOriginStream-->>PlaybackSourceProxy: store data or report entityChanged
PlaybackSourceProxy-->>PlayerViewModel: report interruption and recovery state
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 484f233fa0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2237e12bb5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Implements #94.
Problem
When the playback source cache hits budget, the origin stream suspends its URLSession task and leaves the HTTP response parked indefinitely. A reverse proxy with nginx's default client-facing
send_timeout 60skills that healthy-but-backpressured response, and the failure only surfaces minutes later when the cache drains onto a dead task.What this does
PlaybackOriginStreamPolicy.detachAfterSeconds, default 25s — under any sane proxy timeout), then deliberately cancels into a newdetachedstate at the exactwriteCursor. Expected cancellations are tracked by task ID so a deliberate detach never advancesunproductiveStreak, enters outage parking, or firesonOriginOutageChanged/onPlaybackSourceInterrupted. Waiters and cached bytes are preserved.Range: bytes=<cursor>-through the shared reopen seam factored out ofretarget(to:order:)(retarget resets routing state; detach-resume preserves reconnect history), with double-open guards and generation-checked scheduled reconnects (fixes a latent stale-reconnect race).shouldPrefetchis now a sticky two-threshold gate (disarm at high water, re-arm atlowWaterBytes), so cache oscillation near the budget can't cause close/reopen storms. The demand-at-cursor override is untouched.If-Range. A 200 at nonzero cursor after a sent validator means the entity changed: new.entityChangedend cause (retry cap 0), no bytes appended, escalated assourceEntityChanged— and the ViewModel discards the source-cache handoff instead of stashing it so a replaced file's prefix can never leak into recovery. With no ETag, behavior is exactly today's.rangeIgnoredpath.resumeCapable(wire deliveryoriginal_http) threaded plan → proxy → origin stream; non-resumable deliveries keep the legacy indefinite suspend.direct_stream_resume_v1server advertisement surfaced in the stats overlay for diagnostics.Coordination
Verification
New coverage (
PlaybackOriginStreamResumeTests, NWListener fake origin + fake clock): park→detach at exact cursor; demand reopen with exactRange+If-Range; deliberate detach advances no failure state; hysteresis single-connection under oscillation; entity-change gives up without cache append and escalates;resumeCapable=falseparks indefinitely (legacy behavior); weak ETags never sent asIf-Range.Live on-device validation against the dev server (iOS simulator, updated server build): route mounted with
resumeCapable=true serverAdvertisesResume=true, direct-play origin stream + chunk fetches healthy, playback clean end to end.AI Disclosure
handleCompletion/connectionEnded, the retarget-vs-detach-resume state split, and that the entity-change path discards (not stashes) the cache handoff. Full test suite re-run independently on the simulator by the reviewer.🤖 Generated with Claude Code
Summary by CodeRabbit