geesawra.industries/hydraulophone
An unofficial YouTube Music app for iPhone, iPad, and Mac.
ADR 0001: MVP boundary and InnerTube adapter
- Status: accepted for the merged MVP; broader device and service validation pending
- Date: 2026-09-22
Context
The requested MVP is an accurate AuraMusic-informed Kotlin-to-Swift protocol port with working search, playlists, and streaming, an Apple Music-style iPhone experience, and mandatory Keychain-backed cookies. InnerTube is undocumented, changes without notice, and does not have the same stability or authorization guarantees as an official API. The project guide requires transport DTOs and protocol-specific parsing to remain outside SwiftUI.
The implementation now has a native Search/Library shell, a purple theme, a
mini and full player with queue and seek state, an ordered Keychain session
boundary, and fixture-tested Core and app targets. The basic live run at
2026-09-22 13:59 local restored the Keychain session, returned 17 search
results, 11 playlists, and 100 tracks, then observed native AVPlayer
progress for at least two seconds. An extended run at 14:06–14:07 repeated
the browse path, sustained playback for 30 seconds, paused/resumed, sought to
65% of the track, and advanced to the next track with observed progress. This
validates the direct-AAC checkpoint, but not every track, physical-device
playback, or background audio. The complete evidence and the older diagnostic
result are recorded in docs/mvp-validation.md.
The protocol review consulted the GPL-3.0 AuraMusic reference at commit
185a77d31733047de06cbec619d40731755a0ec1,
specifically:
InnerTube.ktfor request headers, web configuration, retry boundaries, andSAPISIDHASH;YouTubeClient.ktfor client identities and login policy;YouTube.ktfor search and browse renderer shapes; and- the corresponding
YTPlayerUtils.ktimplementation for the bounded player profile order.
Decision
The MVP uses:
InnerTubeClientas an actor that obtains the current Music web configuration and centralizes request headers.InnerTubeRequestBuilderas a pure, fixture-testable request/signature boundary.- A defensive JSON parser that maps responsive list rows and two-row
playlist cards into stable
SongandPlaylistmodels. The Swift request and model shapes are not a mechanical copy of Kotlin source. - A first-page-only query API. Continuation tokens are opaque and are not exposed until their response envelopes have dedicated fixtures.
- Search through anonymous
WEB_REMIX; authenticated library playlists throughbrowseId = FEmusic_liked_playlists; and individual playlist pages throughVL<playlist-id>.DATASYNC_IDremains opaque, including any||components, and is not emitted asonBehalfOfUser. Captured sessionVISITOR_DATAis optional. A separate optional delegated session ID is populated only from authoritativeDELEGATED_SESSION_IDand is emitted only when present. - A bounded AuraMusic-derived playback profile sequence. Each candidate is
attempted at most once, credentials are supplied only to profiles that
explicitly support login, and
IOSis not treated as the sole fallback. Direct audio is preferred at play time; media URLs are never persisted. - No invented signature decipherer or PO-token provider. Cipher-only and
provider-dependent responses are explicit unavailable states. Native AAC
restriction and strict HTTPS host/redirect validation are merged and covered
by the direct-AAC simulator checkpoint. Playback uses a native
AVAssetResourceLoader/URLSessionbridge with full Aura request headers; this resolved the observed AVPlayer 403 in the checkpoint, but does not establish every-track or device-wide playback. AVAudioSession,AVPlayer,MPNowPlayingInfoCenter, queue/seek state, and remote commands insidePlaybackController, not in SwiftUI views.- A SwiftUI Search/Library shell with a mini player and full Now Playing surface, plus a reproducible XcodeGen project with one iPhone application. iOS 17 is the deployment floor.
The detailed endpoint contract and protocol provenance are maintained in
docs/protocol/innertube-aura-port.md.
That note is the source of truth for protocol-sensitive behavior.
Authentication decision
The owner explicitly approved an experimental InnerTube-compatible web-session
flow for this unofficial client. The login surface uses a non-persistent
WKWebView pointed at YouTube Music. When a Keychain session exists, allowed
cookies seed the ephemeral store before navigation. After a successful
YouTube-domain navigation, the app captures the allowed cookie header,
DATASYNC_ID, and optional VISITOR_DATA; SAPISID is required. The
immutable session snapshot is stored as device-only Keychain data, and
SAPISIDHASH is derived only inside the transport boundary.
On 2026-09-23, a fresh physical-iPhone login displayed Google's “This browser or app may not be secure” error. The owner confirmed that a fresh simulator login had previously succeeded with an empty Keychain. The login WebView now uses a mobile Safari-format user agent, independent of the InnerTube request profiles. After the updated device build was installed, the owner completed sign-in on the iPhone and reported that the app worked well there. This is one device observation; session restoration and repeat sign-in on that device remain to be checked. The format follows WebKit's Safari 26 user-agent note. Google documents embedded-browser OAuth failures and restricts embedded user agents, so this result does not establish a supported or durable authentication flow.
Restore and login install the service session before publishing it to the SwiftUI state. The persistent WebKit store is read only to migrate sessions from earlier builds, then cleared; it is not a second credential database. Sign-out clears playback, in-memory state, Keychain data, and owned YouTube or Google WebKit data, and surfaces a checked Keychain failure rather than claiming success.
Authenticated request bodies include a delegated session identity only for
operations and profiles that explicitly opt in, and only when the
authoritative DELEGATED_SESSION_ID value is present. Raw DATASYNC_ID is
retained but is not sent as context.user.onBehalfOfUser. Search remains
anonymous.
IOS has loginSupported = false; the bounded playback sequence does not
silently attach the account session to that or other guest profiles.
Cookie headers, signatures, DATASYNC_ID, visitor data, account responses, and
stream URLs are not logged.
DATASYNC_ID is intentionally not normalized at the session boundary. The
adapter retains the captured value unchanged, including || components, and
does not manufacture or strip a prefix during Keychain decoding. It does not
use that raw value as onBehalfOfUser. Authenticated WEB_REMIX requests use
session visitor data when available; anonymous and non-login profiles use the
anonymous web configuration visitor data. A separate delegated session value
is read only from authoritative DELEGATED_SESSION_ID and omitted when absent.
The previous ADR text claiming that prefix normalization caused the HTTP 500
was not supported as a durable protocol rule and has been removed.
The runtime uses a pinned AuraWEB_REMIX configuration path. A homepage GET
is not mandatory when the API key is absent, avoiding a 302 consent bootstrap
response being treated as the configuration source.
The simulator build is ad-hoc signed with
Resources/Hydraulophone.Simulator.entitlements. iOS 27 rejects Keychain
operations from an unsigned simulator app with errSecMissingEntitlement
(-34018), even when the app only uses its private generic-password item.
The simulator entitlement is selected only for the simulator SDK. Device
builds use the normal $(AppIdentifierPrefix)$(CFBundleIdentifier) Keychain
access group and the developer's real signing configuration.
This is not an official Google sign-in implementation. Embedded Google login, high-privilege web cookies, InnerTube impersonation, and private account access carry Google policy, App Store, and account-security risks. The app must not describe this flow as endorsed or official.
Consequences and risks
- The anonymous search, authenticated library, and playback paths can break when YouTube changes the web configuration, client profile, renderer layout, account identity, or stream policy. The latest basic and extended runs validate one direct-AAC checkpoint, but not every track or service response.
- Direct media URLs expire and can return 403/410. Playback must refresh
through
playerrather than retrying the same URL; the current slice has a bounded refresh attempt but still needs broader live validation. - The parser intentionally returns only supported rows and never treats a missing renderer as a crash. A future continuation implementation must normalize known continuation envelopes without parsing opaque tokens.
- Background audio, remote commands, route changes, interruptions, lock-screen controls, codec restrictions, and stream behavior require physical-iPhone validation. Simulator build/test is not evidence for those behaviors, and no physical iPhone was available for this MVP snapshot.
- The historical diagnostic run should not be confused with the normal app result. The temporary DATASYNC-omission diagnostic was removed after A/B verification; no active omission command is part of the MVP validation path.
- The new extended simulator command provides a bounded observed-progress check, but final range and URL-userinfo review fixes still require a new hosted test run. The current evidence is not a physical-device or background-audio result.
- InnerTube client impersonation, private account access, and bypassing stream restrictions can raise YouTube terms, App Store, and distribution issues. This project does not claim official API access or endorsement.
- Some protocol-sensitive implementation behavior, including the bounded
playback profile sequence, is adapted from AuraMusic. The applicable
GPL-3.0 provenance and distinction between adapted behavior and new Swift
code are recorded in
NOTICE, source comments, and the protocol note. - The approved YouTubeKit signature and
ndeciphering adapter is follow-up work and has not landed. It is not a prerequisite for the working direct-AAC checkpoint, but cipher-only responses remain unavailable until it does.