Repository navigation
fix(sync): keep phone uploads the server cannot byte-match as durable receipts instead of refusing them forever (admission off by default) - #25444
Merged
Git-on-my-level merged 13 commits intoNov 16, 2026
Conversation
Commit verified all-file originals, stable receipts and pending obligations before returning 202. Preserve privacy erasure and polling across rollback; leave source alignment and paid processing for phase 2. Failure-Class: FC-pre-durability-audio-eviction Co-Authored-By: Claude Opus 5.5 <[email protected]>
Use tagged bundle and per-file intake rows with atomic obligations and outbox wakes. Existing erasure discovery owns both kinds; no independent work-state collection or scheduler is introduced. Offload metadata adapters at the async boundary as required by the blocking-I/O guard. Failure-Class: FC-pre-durability-audio-eviction Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve existing intake collections through the batch store and keep WAL orphan cleanup inside its explicit privacy storage purge. Exercise the real handoff/status with Firestore and local verified originals through restart and erasure, without production access. Failure-Class: FC-pre-durability-audio-eviction Co-Authored-By: Claude Opus 5.5 <[email protected]>
Keep source-alignment holds on the existing five-minute custody cadence, including surface-open polling and poll-backoff rollback. The generic processing adapter must not shorten this pending-only obligation to 20s. Failure-Class: FC-pre-durability-audio-eviction Co-Authored-By: Claude Opus 5.5 <[email protected]>
Keep canonical intake reference construction inside its transaction class and expose header-only Opus sample counting from the codec module. The WAL handoff uses public boundaries rather than reaching into private members. Failure-Class: FC-pre-durability-audio-eviction Co-Authored-By: Claude Opus 5.5 <[email protected]>
Install the receipt-capable artifact with admission off before enabling any new handles, then ramp admission on the same artifact. A pre-protocol binary cannot serve status for accepted WAL obligations. Failure-Class: FC-pre-durability-audio-eviction Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve archive bucket identity in pure configuration and keep crash-orphan erasure independent of sync/provider imports. Preserve worker reader policy and batch-stage snapshot boundaries. Record the fenced base upload revision alongside the committed revision for subsequent reconciliation. Failure-Class: FC-pre-durability-audio-eviction Co-Authored-By: Claude Opus 5.5 <[email protected]>
Use bounded generation-pinned GCS deletion and convergence verification for the dedicated WAL prefix, matching batch storage erasure. Avoid pulling account-reader imports into the separately deployed GPU worker. Failure-Class: FC-pre-durability-audio-eviction Co-Authored-By: Claude Opus 5.5 <[email protected]>
Use the storage SDK's typed retry policy with a ten-second deadline for owner-prefix discovery and convergence checks. Deletion stays generation pinned and one-attempt; failures leave privacy purge retryable. Failure-Class: FC-pre-durability-audio-eviction Co-Authored-By: Claude Opus 5.5 <[email protected]>
Default WAL admission off until every serving reader is capable. Route plain status polling directly to its Firestore receipt independently of jobstore adapters. Sweep all conversation-original generations before erasing metadata. Reserve per-owner and global bytes/files before copying originals, including interrupted attempts; release quota only with retryable privacy erasure. Count Opus packet duration from framing headers without a native decoder dependency. Failure-Class: FC-pre-durability-audio-eviction Co-Authored-By: Claude Opus 5.5 <[email protected]>
The pipeline scanner reads all four quota names directly. Reserve helper-backed registry metadata for names read through registered helpers, keeping the quota owner and review deadline without broadening the guard's helper allowlist. Failure-Class: FC-pre-durability-audio-eviction Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e in delete test The A2 seam test pins exactly one shadow_from_env(FirestoreStore(...)) in get_durable_job_status; WAL receipt lookups move to a helper that builds the plain Firestore store. The developer delete test stubs the new WAL storage sweep (no ADC in unit tests) and asserts the conversation's WAL is erased. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
What broke
Native-owned phone WAL uploads repeatedly returned
record_capture_pending / audio_coverage_unproven. Exact decoded-PCM equality cannot generally identify independently decoded Opus files or reconcile phone/server clocks, and a WAL can contain audio never sent live. Retrying the same bytes did not create a durable recovery obligation.Change
Before conversation/coverage refusal memos and decoding, scoped admission rechecks the existing
batch_live_v1owner, source/device, consent, privacy generation and deletion intent. It validates every original WAL, creates encrypted immutable originals under the existing account/conversation archive owner, and verifies generation, stored length/CRC32C and plaintext length/SHA-256. Create collisions verify the complete original identity, including metadata; encryption retries reuse the first ciphertext generation.One transaction commits a versioned all-file receipt, the record upload revision, stable per-file entries, pending obligations and outbox wakes. Rebundled files reuse their obligations. Object-only interrupted attempts stay unaccepted; committed-reply loss replays the same handle without recopying. Originals and outstanding metadata have no routine TTL. Erasure discovers the dedicated media prefix, crash orphans and the new rows in the existing intake receipt collection. The retention contract forbids lifecycle age deletion of
record-wal/originals.The existing 202 wire contract returns a stable
bp_wh_polling handle. Its durable status remainsprocessing / source_alignment_pending, independent of a completed native job. It never returns an empty covered 200 or completion for these new originals. The existing token-lease wrapper clears its optional fence without scheduling a partial recovery from this receipt. Phase 1 does not decode audio or create paid STT work.Custody argument
A 202 follows verification of every original and the atomic receipt/work/wake commit. Failure on file two, malformed framing, changed bytes, checksum/generation/metadata conflict, fence loss or a privacy race cannot accept a partial bundle. Privacy changes during or after storage recheck authority and remove invalidated writes; authoritative deletion overrides retention. Current clients keep their local files at 202. Clearing upload-stall eligibility proves upload progress, not recovered transcript or phone disk reclamation.
Rollout and rollback
RECORD_WAL_HANDOFF_ENABLEDis a default-offconfig_switch. Unset, false,0, off, no and unknown values keep admission off, including intervening main or
image-only deployments. Accepted receipts, headerless status readers and erasure
remain live with admission off. Only true/1/on/yes admit new handoffs.
Release owns this proposed rollout; the quality lead reviews its evidence. No
activation or deployment is authorized by this PR:
admission off, including every sync/status and erasure-serving revision.
Verify image/source identity and Cloud Run
status.traffic, not theservice spec: every revision receiving sync/status traffic must be capable.
Complete synthetic staging custody, headerless polling and conversation/
account erasure checks. Leave admission off if any serving reader is old.
RECORD_WAL_HANDOFF_ENABLED=trueon backend-sync only, using a revisionof the same artifact. Start with synthetic staging/internal test capture,
then ramp 1%, 10%, 50%, 100% of backend-sync traffic against the capable
admission-off base. Each step requires a full clean 60-minute lookback;
quality lead reviews before expansion. Finish or explicitly stop the ramp
by 2026-11-18 00:00 UTC; no automatic expansion or flag promotion.
no missing known handle, no premature completed status), no unexpected paid
work, fresh pending samples, pending bytes below 80% of the 4 GiB global
cap and oldest pending age below 6 hours. Sync 5xx must not increase over
the preceding admission-off 60-minute baseline. Watch pending file counts,
omi_record_wal_handoff_pending_bytes,oldest_age_seconds,sampled_at_seconds, fixed-scopecapacity_refusals_total{scope=owner|global}and sync 5xx. A capacity refusal keeps phone custody but stops expansion.
Stop new admission immediately on a custody/status/erasure violation,
stale metrics, 5xx regression or an age/volume breach. By 2026-11-18 UTC
Release and the quality lead review every outstanding hold; any oldest age
reaching 24 hours requires admission off and a phase-2 recovery plan.
Rollback sets admission false and retains receipt-capable readers and erasure
at 100% traffic. It never routes known handles to an incapable binary. A capable
revision handles the released app's ordinary headerless status request directly
from Firestore, independently of ordinary jobstore shadow/index adapters.
An incapable revision cannot interpret
bp_wh_: it can return 404/unknown-job,or a legacy reader that treats the receipt as an ordinary intake can error
(500 on missing ordinary-job fields). Neither is a valid processing response;
this is why the traffic proof must precede the first admission.
Validation and limits
Synthetic unit and real loopback Firestore-emulator proofs cover all-file failure injection, encrypted create-only replay, ambiguous committed replies, concurrent rebundles, privacy races, status polling and admission rollback. Related coverage, custody, privacy, erasure, router, metrics and Firestore guard suites are run one file per pytest process. The required premerge guards, CI manifest and installed pre-push dispatcher are run locally; final commands/results are recorded in
q12-as-wal-handoff.mdalongside this draft.R27 follow-up verification: 68 handoff unit tests, 16 erasure unit tests,
and 9 real Firestore-emulator cases passed with synthetic audio. The Opus
header helper no longer needs libopus. Ordinary runs skip the emulator file
when
FIRESTORE_EMULATOR_HOSTis not a loopback address, with the explicitreason
isolated loopback Firestore emulator required; the separately launcheddemo-q12-walrun actually exercises it. Storage verification/erasure uses thelocal archive adapter; all-generation GCS behavior is covered by SDK doubles,
not a live bucket.
The required slow premerge sweep currently has an unrelated failure already
present on the pinned base:
SYNC_FUTURE_CAPTURE_CLAMP_ENABLEDpassed its2026-11-15 flag-budget review deadline on the UTC date rollover. This PR does
not invent a renewal for that owner's separate flag. Final manifest/dispatcher
results and exact-head logs are recorded in the implementation report.
No production reads/writes, user audio, pushes, PR creation, merges, deploys or
.github/changes. No staging/device or production improvement is claimed.Phase 2 adds source-frame overlap/gap proof, original-job and in-flight coverage seeding, same-owner interval reservations, missing-audio recovery/projection and terminal status only when every obligation is settled. Ambiguous audio remains held without paid work.
Bounds and pending-work exit
New handoff limits: MAX_FILES — initial 20 per bundle; MAX_FILE_BYTES — initial 16,777,216 per original; MAX_BUNDLE_BYTES — initial 167,772,160 per request; MAX_FRAMES — initial 200,000 per original. These are defensive admission bounds, not scheduler/provider capacity changes. Above a bound, no partial bundle is accepted and the phone keeps its originals. The exact-request fence initially lasts 600 seconds. The phase-1 pending obligation exits only through explicit privacy erasure; phase 2 adds proved redundancy or committed missing-audio projection as processing exits. No timer silently marks held audio completed.
Capacity is reserved atomically before the first object write, once per
stable original file. The per-owner defaults are 256 MiB (268,435,456 bytes)
and 200 files; the global defaults are 4 GiB (4,294,967,296 bytes) and
10,000 files. Both stage namespaces share the global and owner ledgers in
the existing production intake collection. Limits are configurable through
RECORD_WAL_PENDING_OWNER_BYTES,RECORD_WAL_PENDING_OWNER_FILES,RECORD_WAL_PENDING_GLOBAL_BYTES, andRECORD_WAL_PENDING_GLOBAL_FILES.Zero closes new capacity; negative values close it and malformed values refuse
safely. Bytes conservatively include the original length plus 32 bytes for the
current encryption envelope, even for standard protection.
An exceeded owner or global cap returns the existing strict
record_capture_pending503 before copying any file; the fixed-scope capacitycounter increments and the phone keeps its audio. Exact retries and rebundles
reuse reservations. Object-only crashes remain charged, without expiry, so a
fresh nonce or interrupted write cannot bypass the bound. Media erasure must
succeed before its reservation and counters are released atomically. Failed
attempts can consume capacity until explicit privacy erasure; phase 1 has no
unsafe timer-based reclaim. Pending bytes include these conservative holds.
Account and conversation erasure sweep every generation of the exact
record-wal/{uid}/{conversation_id}/prefix (or the owner prefix for accountpurge), including crash orphans, before metadata/quota cleanup. The handoff's
sole write target is the configured
BUCKET_PRIVATE_CLOUD_SYNCarchive bucket;both purge paths derive that same target. The resumable conversation purge
uses bounded pages and its existing gated, generation-pinned remote deletion
units, re-lists after restart, and cannot acknowledge a failed/unknown erase.
No historical bucket migration or live bucket policy has been verified here.
The existing stage-qualified intake collection stores an explicitly tagged bundle receipt and stable per-file receipt rows. Each file row contains the durable pending obligation and outbox wake in the same write;
wal_pending_sinceis the bounded indexed discovery surface. Ordinary job dispatch does not consume these rows. No new Firestore collection or independent scheduler is introduced. Existing intake erasure discovers both kinds and exact media URIs. Quota reservations are tagged separately until the all-file receipt commits.Line-Count-Exception: backend/routers/sync.py | 4113 -> 4123 | A lazy archive callback preserves archival before destructive legacy decoding while allowing verified handoff replay to avoid recopying; no new route is added.
Line-Count-Exception: backend/utils/other/storage.py | 2684 -> 2756 | The scoped verified writer shares this module's canonical create-only encryption, tombstone and owner gates; prefix erasure must cover uncommitted crash orphans.
Failure-Class: FC-pre-durability-audio-eviction
🤖 Generated with Claude Code