Skip to content

feat(cache): expose session byte budgets and lifecycle status - #830

Merged
superuser404notfound merged 1 commit into
superuser404notfound:mainfrom
orut34iop:codex/feat-session-cache-budget-status
Oct 21, 2026
Merged

superuser404notfound merged 1 commit into
superuser404notfound:mainfrom
orut34iop:codex/feat-session-cache-budget-status

Conversation

@orut34iop

Copy link
Copy Markdown
Contributor

Hosts can choose a forward window but cannot request an exact temporary VOD cache budget or tell whether cleanup succeeded. Add optional LoadOptions.sessionCacheByteBudget and a separate EngineDiagnostics.sessionCacheStatus snapshot with requested/effective budgets, resident bytes, protected-window overflow, producer parking, eviction and typed cleanup/failure results.

Nil preserves existing automatic sizing. Explicit requests reuse the quarter-of-available-space safeguard and RetentionClaims allocation after other sessions' unwritten claims. Unknown capacity keeps the conservative ceiling. Zero keeps the necessary working window rather than promising zero I/O; the software disk path keeps a bounded working spool. A protected fMP4 playback window may exceed the request, which the snapshot reports explicitly. The tvOS memory default and live DVR policy remain unchanged; live reports this VOD byte policy as unsupported.

State is sampled off-main from the segment ledger at the existing telemetry cadence. Cleanup may publish after stop, but session tokens reject callbacks from a superseded load/rebuild and an old startup callback cannot revive a stopped cache. Remote HLS is reported as AVPlayer/server managed, not successful zero-byte caching. Detailed snapshots cover fMP4 segment caching; software packets retain their existing telemetry.

Keep the existing #720 ENOSPC classification and #714 live DVR limits. A bounded stale-directory sweep retains the liveness marker, reports enumeration/deletion failures, and never reuses another session's bytes. This is not the cross-launch source cache discussed in #706. No UI settings or host-specific cache tiers are included.

This is independent of #827 (explicit packet-store selection), but both touch SoftwarePlaybackHost construction and the LoadOptions inventory. If #827 lands first, the requested-byte resolution belongs inside its disk factory; the memory branch and automatic platform choice must stay unchanged. No combined-branch or device performance acceptance is claimed.

Tests cover default equivalence, explicit/zero/unknown capacity, shared claims, actual segment writes and replacements, parking, hard-window overflow, bounded sweep, failed directory/write/adoption/cleanup, real engine load/stop cleanup and rejection of old-session updates.

Validation: 66 focused tests under the strict cooperative pool passed. Full serial host suite passed: 795 XCTest tests (1 existing skip) and 4,636 Swift Testing tests across 637 suites. Published documentation links and git diff --check passed. Existing Issue451 creation-time/liveness assertions remain unchanged, and a callback-type regression preserves the public zero-argument HLSVideoEngine.stop() API. Platform and optional-trait validation is left to CI; no new device acceptance is claimed.

@superuser404notfound
superuser404notfound merged commit 7e4fd03 into superuser404notfound:main Oct 21, 2026
4 checks passed
superuser404notfound pushed a commit that referenced this pull request Oct 21, 2026
…for #830

SegmentCache, PrefetchDiskBudget and the window sizing read a 0 budget
as "no byte bound", so sessionCacheByteBudget: 0 (or any request the
volume clamp reduced to 0) dropped the park and the quarter-of-free-space
guard instead of keeping only the window. An explicit request now
enforces at least 1 byte; the status still reports the clamped request.

Also restores the AE#451 ordering comment and the spared-live-dir log
line in the stale sweep, reattaches sessionRetentionBudgetBytes' doc
comment, and moves the changelog entry into Unreleased in house style.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WJcXkGQrMiBPixVEFTSBJS
superuser404notfound pushed a commit that referenced this pull request Oct 21, 2026
…s stay sweepable

The sweep rewrite in #830 skipped a session directory whose creation
date could not be read, so such a remnant was never removed; it counts
as old again, as before, and liveness still spares a held one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WJcXkGQrMiBPixVEFTSBJS
@superuser404notfound

Copy link
Copy Markdown
Owner

Merged in 7e4fd030, thanks @orut34iop. The status snapshot and the session token handling are a clean piece of work, and the tests cover the lifecycle well.

The branch predated #827, #829 and #348, so the merge resolved eight conflicts: the requested byte budget now goes through makePacketStore's disk branch from #827 (memory branch and .automatic unchanged, as the description anticipated), and the AE#348 prepare / serve split stops with .loadFailed on failure like start() does.

Follow-ups on main:

  • 2d63474a: an explicit budget of 0 reached SegmentCache, PrefetchDiskBudget and the window sizing as 0, which all three read as "no byte bound". With a large forwardBufferSegments that dropped the producer park and the quarter-of-free-space clamp instead of keeping only the window. An explicit request now enforces at least 1 byte (SessionCacheBudgetResolution.enforcedBytes); the status still reports the clamped request. Same for a request the volume clamp reduces to zero. Also restores the AE#451 ordering comment and the spared-live-dir log line in the sweep, and moves the changelog entry into Unreleased.
  • b3f3e9d2: no force unwrap on the resolved budget, and a stale directory whose creation date cannot be read is sweepable again as before the rewrite (liveness still spares a held one).

Full suite green after each step (780 XCTest, 4753 Swift Testing). Ships with the next engine release.

@superuser404notfound

Copy link
Copy Markdown
Owner

Released in 7.45.0 (52802af).

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