feat: deliver signed SABR compatibility profiles#78
Open
Priveetee wants to merge 3 commits into
Open
Conversation
Priveetee
force-pushed
the
feat/sabr-compatibility-profile
branch
from
July 23, 2026 07:19
3d27217 to
8db93cd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds the Android delivery side of SABR compatibility profiles.
PipePipeExtractor defines and evaluates the signed profile. PipePipe Client decides when Android downloads one, how it survives process restarts, which revision a new playback session receives and how a bad revision is disabled. Existing SABR sessions and the bundled policy remain usable when the network, endpoint, cache or profile is unavailable.
The remote path is build-time opt-in. With no endpoint or public keys configured, the application schedules no update work and every session follows the bundled Extractor behavior.
Android lifecycle
AppinitializesSabrPolicyRuntimebefore playback and then startsSabrPolicyUpdateWorker.SabrSessionStoreasks the runtime for a newSabrSessionPolicyHostwhenever it creates a SABR session.A session snapshots the current immutable profile at creation time. Installing a newer revision does not mutate playback already in progress.
Build configuration
The Android build accepts three values:
SABR_COMPATIBILITY_PROFILE_PUBLIC_KEYS: up to eightkey-id=base64-public-keyentries for Ed25519 key rotationSABR_COMPATIBILITY_PROFILE_STABLE_URL: HTTPS endpoint selected by stable versionsSABR_COMPATIBILITY_PROFILE_BETA_URL: HTTPS endpoint selected by versions containing-betaStable and beta use different cache files and different monotonic revision floors. This prevents a beta profile from becoming trusted state for a stable build.
No configured URL or no configured trust roots means remote delivery is completely inactive. The worker is not scheduled, the endpoint is not contacted and
SabrPolicyRuntimereturns the bundled policy.Update behavior
SabrPolicyUpdateWorkeruses the application's existing HTTP client with redirects disabled and accepts only an HTTPS endpoint. The response body is bounded to the Extractor document limit before installation.Response handling is explicit:
200: verify and install the document204or304: no update, successful check408,425,429or5xx: ask WorkManager to retryThe endpoint distributes only a public signed document. It does not receive playback requests, cookies, PO tokens, media URLs or media bytes.
Persistence transaction
SabrProfileCacheuses AndroidAtomicFilestorage for two independent pieces of state:SabrProfileRegistry.install()verifies the downloaded document first, persists the new active/previous state, persists the new revision floor and only then exposes the revision in memory. If writing the floor fails, it restores the previous cache state instead of activating a partially committed update.Keeping the floor separate is deliberate. Corrupting or deleting the active-document cache must not allow an older signed revision to be installed later. A revision rejected by the circuit breaker also remains the floor, so recovery requires a higher signed revision rather than a replay of the document that just failed.
SabrProfileRestorerdistinguishes normal active restoration, previous-generation restoration and the circuit-breaker fallback case. Invalid, expired, corrupted or inconsistent cached state is discarded and startup continues on the bundled policy.Session selection and recovery
SabrPolicyRuntime.createSessionHost()has three outcomes:BuiltinSabrSessionPolicy;FallbackSabrSessionPolicy;When a profiled session trips its circuit breaker, that session immediately uses the bundled behavior. The registry disables the same revision for future sessions and restores the previous valid document when available.
The disable callback checks both the registry instance and the exact captured profile. A failure from an old session therefore cannot disable a newer revision installed while that session was still running.
The active document, previous document and revision floor are private application state. Diagnostics are limited to revision numbers and failure classes; request bodies, response payloads, cookies, PO tokens and media bytes are not persisted or logged.
Changes
Validation
Build validation with all profile endpoint and public-key values unset:
./gradlew --no-daemon :app:assembleDebug :app:assembleDebugAndroidTest :app:lintDebugAndroid instrumentation covers:
Real Pixel 8 playback validation:
Deployment status
This PR contains no production endpoint, signing private key or enabled trust root. It is safe by default: without build-time configuration, its runtime behavior is the existing bundled SABR policy.
The profile publisher and key-management process need to be reviewed separately before remote delivery can be enabled in a release.
Related PR