geesawra.industries/hydraulophone
An unofficial YouTube Music app for iPhone, iPad, and Mac.
ADR 0007: Encoded caches, explicit downloads, and Offline Only
Date: 2026-09-24. Status: accepted; simulator acceptance recorded below. Owner requested both qualities, a configurable cache limit, track/album downloads and an offline-only toggle.
Lifetimes and privacy
Public player JavaScript uses a separate anonymous URLSession and 64 MiB disk
URLCache, following HTTP freshness/revalidation. No cookies, credential store,
watch-page bodies, authenticated API responses, proof tokens or signed media
URLs enter that cache. In-memory prepared code is bound to the exact script,
client profile/session generation, HTTP freshness and a 30-minute upper bound.
Stale decipher/probe failures invalidate preparation and force fresh discovery.
The streaming audio cache is encoded bytes, bounded by the Settings limit (default 1 GB; Off, 250 MB, 500 MB, 1 GB, 2 GB, 5 GB). Opus identity includes video ID, itag, lastModified and complete byte length. Atomic manifests record 64 KiB chunks; only a fully assembled file is available for offline playback. Complete High replaces cached Standard. Open readers can finish after eviction.
Explicit downloads use the same encoded storage abstractions under Application Support, outside the stream LRU. They are retained until removal/sign-out and excluded from backup. Metadata includes only song/album identity, title, artist, artwork and progress; no reusable credentials or durable signed stream URLs. Artwork is fetched anonymously from allowlisted image hosts, capped at 2 MiB. Downloads share partial encoded data where possible. High fetches bounded 1 MiB ranges and splits them into the common 64 KiB storage units. Completed streaming-cache Opus and local AAC assets can be copied into download storage without resolving another stream. Their source readers stay open while copying; cancellation and destination-generation checks prevent stale completion.
The coordinator serializes songs, supports pause/resume/retry/remove and fetches all album pages before enqueuing its songs. Restart restores completed assets and pending work. A foreground background-task assertion provides time to finish; on expiration pending work pauses. Unlimited unattended background downloading is not promised. Downloads have no arbitrary user cap; storage failures remain visible and resumable. The configurable limit applies to automatic caching.
Offline behavior
A domain service gate rejects network work and cancels in-flight requests. Offline Only also cancels prewarm, downloads and Last.fm network work and disables remote artwork. Browsing/search use locally stored download metadata. Playback looks for completed local assets before resolution; offline playback can fall back to the other saved quality. Missing audio gets an actionable paused state. Existing Keychain authentication remains required; no anonymous product mode is introduced. Toggling back online restores network policy and pending downloads.
Reference comparison
Metrolist at 28fa8f042bfabb880bdecc0d9fa37e86cf72b90e:
MusicService.kt
uses explicit downloads before its playback cache and upstream data source.
App.kt
prewarms extraction. InnerTubeX cc74e737b6ae2875343fb2e31c7283e39e1cf72e
prepares code/proof/config and bounds reuse. These are reference behaviors, not
an official YouTube contract. See docs/protocol/high-startup-latency.md for
pinned AuraMusic and InnerTubeX protocol sources and measurements.
This is an original Swift implementation. No Android runtime dependency, copied Kotlin implementation, transcoding service or server is introduced.
Validation
Formal tests are deferred by owner instruction; briefs are in
docs/test-briefs/downloads-offline-and-listening.md. Simulator High playback
and both High and Standard download/offline diagnostics passed: completed audio,
saved artwork, local playback and a 65% seek, network request rejection and
catalog restoration. The public JavaScript cache reported a disk hit after an
app process restart. Hardware/background validation is deferred because the
owner prohibited phone use overnight. Album pagination and interruption edge
cases remain in the formal test briefs.
Standard implementation decision
The observed selected Standard rendition is finite, unencrypted packed AAC:
ADTS frames preceded by an ID3 tag, despite segment filenames ending in .ts.
The source master has audio groups but no audio-only AVAssetVariant.
The system asset downloader rejected the selected child playlist; a synthetic
custom-scheme master also failed. A file-based HLS playlist was not accepted by
AVFoundation for offline playback. Those experiments are not shipped paths.
The selected implementation recognizes packed AAC by its bytes, strips the
bounded leading ID3 tag and retains original ADTS frames in a local .aac file.
It also supports AAC extraction from MPEG-TS through PAT/PMT/PES parsing;
that alternate container branch has not been exercised by the live source.
There is no decode/re-encode step,
video download, local HTTP server or stream-URL persistence. Unsupported HLS
shapes fail explicitly rather than being interpreted as another format. See
RFC 8216, particularly sections
3.2 and 3.4 on MPEG-TS and packed audio, for the container boundary. Live source
selection still follows the pinned AuraMusic/InnerTube profile notes.
Standard automatic caching performs a separate bounded fill alongside AVPlayer; this can duplicate fetched audio. It is disabled on cellular/expensive or constrained paths. High caches bytes from its actual native streaming reads. Explicit downloads are deliberate user actions and remain available under the normal online gate. Sharing AVPlayer's Standard byte requests is a future optimization; it must not delay the first audio sample or introduce a server.