Repository navigation
SCA-2229: fix(batch): answer repeated upload waits before the expensive path - #25302
Merged
Git-on-my-level merged 9 commits intoNov 15, 2026
Merged
Conversation
backend-sync answers 503 to ~80% of its requests, almost all of them the mobile upload route, and each retry redoes work that was already proven useless: - The coverage-wait memo is consulted after retain_upload, the WAL decode and the record-audio fetch, and it shares the conversation memo's 30 s TTL against a roughly three-minute phone retry cadence. - Deterministic decode failures (truncated or invalid frames, empty audio, unsupported PCM, the 128-unit bundle) reach the intake catch-all and are answered 503 forever, re-decoding and re-staging the same bytes. Consult the coverage memo before the retained copy and the decode when this upload is not already receipted, give it its own 300 s TTL, and keep the partial-coordinator wake that a hit would otherwise skip. Extend the memo key with the upload's file count and total bytes beside the content hash that already covers its basenames and bytes, so a second, different WAL for the same record never inherits the proven negative. Memoize the deterministic decode failure under the same upload identity for 300 s. The answer stays the existing retryable 503 byte for byte: no client-visible change, and the phone keeps custody exactly as today. Add bounded path=, memo= and deterministic= labels to the existing log lines so the answer mix and the memo-hit share are measurable without an identifier. Fix the blind 503-storm alert: its log metric pinned httpRequest.responseSize=266, the record-wait body is 271 bytes today and the catch-all 259, and the rule's noDataState is OK, so it read zero while 80% of the service answered 503. Route plus status on the unsampled request log is the whole predicate now. Kill switches, all default on: SYNC_RECORD_WAIT_MEMO_FIRST (order), SYNC_RECORD_COVERAGE_WAIT_MEMO (memo), SYNC_RECORD_DECODE_FAILURE_MEMO. No custody decision, retention invariant, acknowledgement authority or job invalidation changes, and no new durable state.
The wiring the pre-push gates required (composed runtime_env, pusher and backend-listen chart values, deployment-setting classification) also has to keep the Cloud Run env-state fixtures and the dev pusher literal contract true, and the two switches belong in the flag catalog beside their sibling. Failure-Class: FC-alert-never-provably-fired
The coverage memo now caches for 300 seconds, the decode memo's closed set includes the unreadable-input 400, and the upload identity is count plus bytes beside a content id that already hashes names and bytes. Failure-Class: FC-alert-never-provably-fired
# Conflicts: # backend/config/flag_budget.json
…ode-deepseek-v4/9e603165fdd9 # Conflicts: # backend/config/flag_budget.json
…ode-deepseek-v4/9e603165fdd9 # Conflicts: # backend/config/flag_budget.json
Git-on-my-level
deleted the
agent/m1-studio-opencode-deepseek-v4/9e603165fdd9
branch
November 15, 2026 04:50
Git-on-my-level
added a commit
to Git-on-my-level/omi
that referenced
this pull request
Nov 15, 2026
Brings in BasedHardware#25302 and BasedHardware#25323 (jobstore serving parity census). Conflict: tests/unit/test_jobstore_protocol_parity.py (two tests added at the same place; kept both). BasedHardware#25323 requires every public serving read of the store to be in the parity census, so the bounded ready_pending read this branch adds (used only by the staged-off sibling guard, and already implemented on the Postgres store) is registered in STORE_QUERIES. Failure-Class: none Co-Authored-By: Claude Fable 5.2 <[email protected]>
Git-on-my-level
added a commit
that referenced
this pull request
Nov 23, 2026
…mpled upload path (#26147) Multica: SCA-3909. Failure-Class: none Line-Count-Exception: backend/utils/batch_pipeline/intake.py | 1499 -> 1505 | the memo-gate comment documents why the sampled decode phase is memoizable and the probe phase is not ## What Luna's R2 review of the 24h-push decode-memo fix (SCA-2229, #25302) found a P2 that never landed: the intake memo gate recognized only phase `decode`, but a **sampled upload** (unknown-multilingual admission, legacy still on) advances the same decoder under its own phase `sample_decode` before anything is staged. A deterministic decode failure there returned the retryable 503 **uncached**, so every retry of bytes that cannot decode linked a fresh private sample and decoded them again. - `backend/utils/batch_pipeline/intake.py` — the gate now admits `sample_decode` beside `decode`. The probe phase (`language_probe`) classifies already-decoded audio, so no decoder fault can surface there; it stays out of the gate. - `backend/tests/unit/test_batch_intake_decode_failure_memo.py` — the fixture is parameterized (user row + legacy mode); a new `sampled_world` runs the unknown-multilingual admission. The regression test proves the sampled path stores the memo and the retry answers the byte-identical 503 without linking a sample directory or invoking the decoder; the kill-switch test proves `SYNC_RECORD_DECODE_FAILURE_MEMO=off` still repeats the decode. ## Contract - The 503 response is byte-for-byte the existing `_sync_unavailable_response()` on both the hit and the miss path; no new status, headers or body. - No new flags: `SYNC_RECORD_DECODE_FAILURE_MEMO` keeps its default-on state and its off-switch semantics; the memo key, 300 s TTL and NX write are untouched. - The memo read side already ran before the sampled branch (`_cached_decode_refusal`), so only the write gate changed. ## Evidence - The regression test fails on current main (no memo write on the sampled path; the retry re-decodes) and passes with the fix; live run results are recorded on the Multica issue. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/26147?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a> <a href="https://www.cubic.dev/action/auto-fix/pr/BasedHardware/omi/26147?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F26147&source=description" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img alt="Turn on auto-fix" src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
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.
Failure-Class: FC-alert-never-provably-fired
What
backend-syncanswers 503 to ~80% of its requests, nearly all of themPOST /v2/sync-local-files, and each retry redoes work the server has already proven useless.retain_upload(a create-only copy of every WAL byte), the WAL decode and the record-audio fetch, and shared the conversation memo's 30 s expiry against a roughly three-minute phone retry cadence.This change:
retain_uploadis a create-only no-op for the same bytes, so the miss that wrote the memo already did that work.content_id, which already HMACs each basename and each file's SHA-256. A second, different WAL for the same record therefore never inherits a proven negative; if the size lookup fails there is no key and the request checks in full.rearm_partial, extracted fromretain_upload'sfinally, samecustody.owns_upload+retention_windowguard). That wake is what lets a record discover chunks it already holds; dropping it would have traded wasted work for slower delivery.4xxfor these bytes is deliberately not in this PR — released client versions are unverified for that path, and it needs its own proposal with client evidence.path=/memo=/deterministic=labels to the existing log lines so the answer mix and the memo-hit share are readable. The INFO stdout family is sampled (app-stdout-info-sample90), so treat those proportions as such and pair them with the unsampled request-log metric for counts.Decode memo Redis path and cost
With
SYNC_RECORD_DECODE_FAILURE_MEMOenabled, each eligible request handled by the built-in decoder (an upload identity can be derived anddecode is None) performs one RedisGETforsync:decode_failure:v1:<hash>before decoding, including uploads that decode successfully. A cache hit repeats the existing503and performs no Redis write. If the read misses and decoding ends in the closed set of deterministic failures, the request attempts one RedisSET ... NXwith a 300-second expiry. Successful decodes and non-deterministic errors do not write the key. Redis failures fail open to the full decode and preserve the existing response. This pays one Redis read for every eligible upload to avoid decoding and staging identical deterministic failures again during the TTL.The alert was blind
omi-pipeline-upload-503-stormfilteredhttpRequest.responseSize=266. Every record-wait 503 today is 271 bytes and the intake catch-all 259, so the rule read zero while ~80% of the service answered 503, and itsnoDataState: OKkept it green. The probe confirmed it in production: zero entries at 266 B, 4,875 at 271 B and 198 at 259 B in one ten-minute window.The predicate is now route + method + status on the unsampled platform request log; the annotations, the exported rule in
alert-rules.json/pipeline-drain.jsonand the runbook are updated to match. A byte class is not a guard: it rots whenever a body string changes.Custody
No custody decision, retention invariant, acknowledgement authority or job-invalidation rule changes, and there is no new durable state: the only new keys are 300 s Redis markers. Every hit path answers the same 503 the miss produced; nothing acknowledges, releases or re-routes.
remember_coverage_waitstill has exactly one production caller, afterretain_upload.Kill switches (all default on, live env)
SYNC_RECORD_WAIT_MEMO_FIRST—offrestores the pre-change request order (memo after the copy).SYNC_RECORD_COVERAGE_WAIT_MEMO—offskips the memo entirely.SYNC_RECORD_DECODE_FAILURE_MEMO—offrestores a full decode on every retry.All three are registered in
config/flag_budget.jsonand the runtime-env manifests, and eachoffpath has a test that asserts the old behaviour.Verification
pyteston the batch/sync/monitoring unit files: 841 passed;test_cross_service_deploy_contract.py: 30 passed, 3 skipped.GETcost documented above; the goal-owner ruling on SCA-2229 (2026-11-14 17:37Z) explicitly approves that path and directs shipment after this documentation correction without a third review.POST /v2/sync-local-files, plus thememo=hitshare from the INFO sample.Product invariants affected
backend/deploy/runtime_env.yamlis in the invariant's path glob. This change adds two default-on upload kill switches to the composed env; it adds no canonical-intake path, no Short-term or Long-term transition, no consolidation route and no projection authority, so no INV-MEM-4 clause changes.Failure class
Declared:
FC-alert-never-provably-fired. The rule this incident hid behind could never fire — its expression read zero because it filtered a response byte class that no longer occurs, and a green evaluated state is indistinguishable from healthy.The memo half has no existing class. "A negative result recorded where the retry cannot reach it, under a key that does not name the upload" is a new class, and the protocol forbids an instance-fix PR from adding a definition; it needs its own registry-only follow-up PR.
Review record
The two-round independent review identified the unlisted Redis read cost. The goal-owner ruling on SCA-2229 at 2026-11-14 17:37Z approved that cost and directed this existing PR to ship after the documentation correction, without a third review. Current
main(d1fb900e5b) was integrated by a normal merge (ca45ce2656). Its only conflict wasbackend/config/flag_budget.json; resolution retained the flags from both sides and set the count to 288. The ruling correction is documentation-only (d53ec4836c).Known limits, stated not hidden
400 Audio decode failedis also raised when no input file is readable at all, so a transient local fault can be memoized for 300 s. The answer is still the identical 503 and custody is unaffected.record_router_missinganswer line does not yet carrypath=/memo=, so a strict per-path aggregation drops that one branch.partial_coordinatordoc would invalidate it sooner than necessary. Pre-existing; no custody effect.Line-Count-Exception: backend/utils/metrics.py | 1753 -> 1765 | add bounded record-wait counters to the existing metrics registry