Repository navigation
fix(pusher): seal batch-owned recordings regardless of flushing session - #24084
Conversation
Resolve persisted ownership in the seal transaction; preserve upload failures and in-flight producer obligations across reconnects. Add an exact-job repair tool requiring retained-tail proof and a matching dry-run plan digest. Failure-Class: FC-pre-durability-audio-eviction
Keep the existing conversation and pusher modules within their size budgets. Migrate closure callers and behavioral fixtures to the dedicated record-audio metadata authority and session coordinator.
Expose the shared retained-unit reader for repair callers and keep the periodic pending-job retry wake outside the approval digest. Prove wake changes neither invalidate the reviewed capture proof nor overwrite scheduler state. Failure-Class: FC-pre-durability-audio-eviction
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Keep audio uploads running through barrier bookkeeping failures, retain failed token clears for retry, and expose separate bounded metadata-failure metrics. Register tokens only for native batch owners. Record pod/process identity and allow exact-map repair only with digest-bound pod absence/restart evidence or explicit legacy-token stoppage attestation, plus retained-tail proof. Recheck upload closure and its producer revision in the final batch admission transaction so a reconnect during staging cannot admit an earlier archive. Migrate the unchanged retained-reader environment inventory after its rename. Failure-Class: FC-pre-durability-audio-eviction
Incorporate lead-approved flag review-date renewal from PR #24085.
Preserve the non-bool numeric runtime guard while making its narrowing explicit to the backend type checker. Failure-Class: FC-pre-durability-audio-eviction
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8de3332b58
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| await record_barrier.finish_recording(conv_id) | ||
| record_close_requests.discard(conv_id) |
There was a problem hiding this comment.
Retain close requests when token clearing fails
If the token-clear transaction exhausts its retries during a transient Firestore outage, finish_recording() catches the exception and returns normally, so this caller removes the close request anyway; the durable uploader does the same. Nothing subsequently drains pending_clears without another close request for that exact conversation. After disconnect, the local retry state disappears while the persisted producer token remains, so even a clean finalize-only reconnect cannot seal the recording. Return a completion result and retain unsuccessful close requests for bounded retries rather than treating a failed clear as a completed drain.
Useful? React with 👍 / 👎.
| except Exception: | ||
| _record_failure('failure_marker') |
There was a problem hiding this comment.
Emit shared fallback telemetry when failure persistence fails
When the durable failure-marker write fails, this branch continues audio uploading with only session-local refusal state, losing the cross-session guarantee. It records only the new domain counter, so this correctness-degrading fail-open path is absent from the shared fallback telemetry. Emit record_fallback with a degraded outcome in addition to the stage counter, as required by the new-fallback rule in backend/AGENTS.md.
AGENTS.md reference: backend/AGENTS.md:L320-L320
Useful? React with 👍 / 👎.
| boot = next( | ||
| float(line.split()[1]) for line in Path('/proc/stat').read_text().splitlines() if line.startswith('btime ') | ||
| ) | ||
| fields = Path('/proc/self/stat').read_text().rsplit(')', 1)[1].split() | ||
| started = boot + int(fields[19]) / os.sysconf('SC_CLK_TCK') |
There was a problem hiding this comment.
Account for timestamp precision before proving a producer dead
When the Python process starts shortly after its container, this epoch can precede the container's actual start: /proc/stat supplies an integer-second btime, and the process start is also quantized to clock ticks. producer_tokens_dead() nevertheless treats any strictly later container timestamp as proof of a restart. I reproduced this locally with a still-running child: its recorded process epoch was about 0.75 seconds earlier than the timestamp taken before launching it, and the proof classified it as dead. Consequently, repair can clear a live producer's token and seal while that producer still has buffered audio. Use a conservative timestamp uncertainty bound or an exact process/container identity before authorizing token removal.
Useful? React with 👍 / 👎.
Register upload custody before ownership is assigned, retain bounded close retries, and conservatively prove producer death. Defer native record admission until the lead verifies the producer protocol cutover. Failure-Class: FC-pre-durability-audio-eviction
…ound (#24090) # Pusher durable projection: gone-owner no-op on NotFound + raising-frame attribution Failure-Class: none Line-Count-Exception: backend/routers/pusher.py | 1542 -> 1611 | NotFound gone-owner arm (deletion-intent read + drop without custody failure) and raising-frame attribution per lead ruling 2026-10-30 06:00Z No existing failure class covers the pusher durable-projection surface; this change stops a permanent gone-owner condition from being classified as a transient projection failure (deterministic retry churn plus `failed_recordings` poisoning at the 128-entry session cap). Adding a new class definition would require `.github/` changes, which are out of scope for this PR. ## What - `flush_refs` now catches `NotFound` before the generic projection handler. If the conversation is tombstoned (`conversation_tombstones.is_deleted`, the same read the custody write gate uses) or its conversation doc no longer exists, the purged refs drop as a gone-owner no-op: no `record_barrier.fail_recording`, no `failed_recordings` entry, no `record_failure`/`record_fallback`, no retry churn — one info line `Durable audio projection skipped; conversation gone`. - A **live** conversation keeps today's transient retry/terminal paths unchanged (NotFound on live audio is never hidden as a gone owner). The extra deletion-intent read runs only on the NotFound arm; if that read itself fails, the arm fails open to the transient path instead of propagating out of the drain loop. - The existing warning `Durable audio projection failure class: %s` now also names the innermost raising frame (walking `exc.__traceback__` to the last frame, `co_name` only — never the message or args), so the unattributed InvalidArgument minority becomes diagnosable from logs without a redeploy. ## Why Read-only verdict (2026-10-30, swarm/state/refs/projfail-verdict-2026-10-30.md): the dominant NotFound stream (~1,000 class lines/10m, ~460 conversations/h) is `read_pcm` hitting objects purged by sanctioned conversation deletion (user delete, merge, empty-recording cleanup) while the receipts still sit in the pusher durable queue. Retries are deterministic (requeue:terminal ratio 2.0 — retries rescue nothing), and every terminal conversation enters `failed_recordings`, where the 128-entry session cap flips `record_upload_failed=True` session-globally and can fail-mark later healthy conversations of the same websocket session. Chronic since #23641; made visible by #24084's class logging. No rollback indicated (attributed in the verdict); this PR removes the churn and the poisoning path. ## Tests `backend/tests/unit/test_audio_durable_outbox.py`: - `test_notfound_on_tombstoned_conversation_drops_refs_without_custody_failure` — purged read + tombstone: refs dropped on the first NotFound (no requeue), zero custody failures, zero `fail_recording` (observed via `mark_record_upload_failed`), receipts still acked and readable. - `test_notfound_on_hard_deleted_conversation_doc_drops_refs` — tombstone false + missing conversation doc: same gone-owner no-op. - `test_notfound_on_live_conversation_keeps_transient_retry_and_terminal_paths` — live conversation: exactly `1 + PROJECTION_RETRY_BUDGET` attempts, the terminal `('projection', 'transient')` drop, record close withheld, and the class line attributes `NotFound raised by purged_read` with the exception message never logged. - Existing budget/conflict/retry tests updated for the new class-line format and a message-leak assertion. Local verification (layer: backend unit suite, selected by the CI changed-file selector for this diff — 34 files, all green): ``` BACKEND_UNIT_TEST_FILE_LIST=<selection> bash backend/test.sh # 34 files, exit 0 ``` <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/24090?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/24090?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F24090&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. -->
#24107) Record-barrier Firestore retries currently occupy the shared DB pool used by transcript and audio webhook consumers. The 2026-10-30 custody verdict measured DB saturation at 24/24 after #24084, 121-163 session closures/hour, and roughly 10k transcript queue drops/hour. This isolates all four barrier dispatches (begin, clear, seal, failure marker) on a monitored `record_barrier` executor: 16 workers, 64 queued calls, asynchronous capacity waits. Existing pusher call sites inherit the isolation without editing `routers/pusher.py` or #24101's seal behavior. Shared DB capacity becomes 32 via `PUSHER_DB_EXECUTOR_WORKERS`; 32 supplies 12 workers of headroom above the verdict's pre-regression peak of 20, while isolation removes the new workload. The barrier worker count is tunable through `PUSHER_RECORD_BARRIER_EXECUTOR_WORKERS`. Adds `omi_executor_max_workers` so the Prometheus-backed Grafana pusher alert fires per scrape target at configured DB capacity for 10 minutes, summing all task labels. Both maintained and combined alert exports are updated. No production state has been accessed or changed; the lead must provision the alert and roll pusher in the same train as #24101. Shared executor defaults also apply to other processes importing `utils.executors`; no extra threads start until work is submitted. Validation: - Targeted `backend/test.sh` via `BACKEND_UNIT_TEST_FILE_LIST`, 4 workers, under `omi-heavy` and `nice -n 19`: executor, strict Firestore seal, pusher timeline, transcript dispatch, and monitoring contracts. - New behavioral test forbids shared DB submission during all four barrier operations and records the actual worker thread. - New real pusher session test drains transcript and audio webhook queues through DB-backed fake integrations while a fake barrier executor holds a transaction pending. - Based on #24101 merge `f436f8821b58`, preserving its returned seal-refusal handling and shutdown/ACK logic. After syncing #24105/main, targeted 15-file unit shard: 362 passed, including the strict custody and seal/ACK cases. The full 24-file monitoring selector passed 558 tests. Hermetic E2E on the combined tree: 175 passed, 3 skipped, 2 expected failures. Repository preflight: 38 checks passed; full ordinary push hooks run on each published head. The first CI run found two alert metadata requirements outside the initial local subset: a dashboard link and a current source-only GMP query inventory. Both failures reproduced locally. The correction adds the committed Pusher dashboard URL to both exports and regenerates the query inventory offline; it changes no executor or seal logic. All 24 files from the monitoring changed-file selector pass locally (558 tests), including both formerly failing contracts; the expanded 14-file functional set also passed 327 tests. Review: Luna full read-only round 1 at `9320e0eae81eb924f92ab5bb9d0890d8e3d86fb5` was **SHIP, no findings** (execution `exec-deputy-theme-bottom-donkey-butter-section`). Delta round 2 at reviewed implementation head `569982c171eb6d693e819c0771a0ccb8a3d72076` was also **SHIP, no findings** (execution `exec-endless-unfold-occur-october-leg-meadow`). Reviewers did not run tests; local validation is recorded above. Each published head passed ordinary push hooks; fresh exact-head terminal CI remains required for merge. Lead owns merge and deploy. No `.github/` edits, data changes, or flag changes. Main sync: #24105 added the sweeper paragraph at our executor paragraph's insertion point. Merge `8e35ec63a5146a153dac65cbcef7acefa286dabe` retains both paragraphs; the reviewed executor, seal and alert files are byte-identical to `569982c171eb` (which completed all 64 CI checks green). Lead ruling `5f2fd4` explicitly approves this docs-only resolution and reuse of both SHIP reviews without a third round. The synced head requires its own green CI before the lead merges. Rollback: restore prior worker env values through the normal release path for tuning; code rollback requires lead review to retain #24084/#24101 custody semantics. Failure-Class: none Failure-Class-Reason: The registry has no matching shared Firestore worker contention class; GPU batch/live scheduling and lifecycle ownership classes describe different contracts. The new consumer-isolation behavioral test guards this mechanism without changing registry/workflows in this urgent PR.
Completed batch recordings can remain pending forever when the final websocket session flushes no new audio metadata. Resolve persisted batch ownership in the seal transaction on every retained close, including finalize-only reconnects with live admission disabled. Legacy and unowned conversations never receive a seal.
Persist terminal upload failures across sessions. Unowned and batch-owned producers register bounded pod/process tokens before accepting audio; this also covers a finalizer claiming ownership during an earlier upload. Only their successful drain clears their token. Immutable legacy owners stay read-only. Metadata exceptions preserve audio uploading, refuse closure when necessary, and use canonical record_fallback plus a separate bounded-stage metric. Close requests retry metadata failures up to three times without another finalize. With 3-4k sessions/hour as the planning input, registering and clearing unowned/native tokens adds an estimated 6-8k metadata writes/hour. The lead accepted this tradeoff (9bc674) and will measure Firestore writes and Typesense extension invocations after deployment; this is not a measured cost.
CPU admission rechecks the closed barrier and producer revision in its final enqueue transaction. A reconnect that starts and seals again while the previous archive is staging invalidates that snapshot, leaving the job pending.
The operator repair tool is exact-job-only and dry-run by default. It requires generation/digest-pinned retained audio through current and frozen finished_at, no upload-failed marker, transactional state/privacy checks, and an approved fresh plan digest. Abandoned tokens require a digest-bound, current pusher pod inventory proving absence or a later process start, conservatively allowing two seconds for process-clock precision. Only pre-identity tokens accept an explicit producers-stopped attestation. No token expires by TTL; output contains counts and closed dispositions. No production reads or repair execution were performed.
Validation: targeted backend/test.sh shards under omi-heavy/nice, the real local listen/pusher emulator gauntlet, repository preflight and normal push hooks. The delta adds Firestore fault containment, in-flight reconnect/late-failure including pre-ownership upload, admission/staging revision and cutover refusal, automatic token-clear retries, conservative producer-time proof and repair refusal tests. Final exact-head CI and the lead-authorized focused Luna r3 are required before MERGE READY.
Deploy target: pusher, rides the listen/pusher train, plus the Cloud Run CPU reconciliation/admission consumer. REQUIRED release order (lead 34e19f/5dbd80): deploy the consumer first with BATCH_PIPELINE_RECORD_PROTOCOL_READY=false (default closed), verify its release identity serving, then finish the full pusher rollout and prove every pod is on the new digest with zero old pods. Only then may the two-lane lead open the control for all native record admissions. Closed admission retains record_pending without loss or expiry, checked before staging and final enqueue. Target open 2026-10-30T06:00:00Z, review_by 2026-11-01; lead retires the temporary control in a follow-up PR within 48h of opening. Close again to roll admission back. If proof is unavailable, opening stays blocked and the lead must report it. Keep batch at 0% during cutover; the lead re-enters 5% after proof. Percentage 0 alone is not quiescence: private cohort and desktop server-batch captures can still create native owners. Existing admitted work also drains. The reverse deploy order is unsafe. Lead owns merge, deployments and separately authorized production repair.
The archive tail check already refuses admission if the old-pod tail has not landed and its last durable end precedes current/frozen finished_at by over 100ms. It cannot prove all old-producer audio is present (gaps or audio beyond that finish); it does not replace the cutover hold.
Rollback: revert; behaviour returns to today's stuck-but-retained. Older binaries ignore the new marker contract. If both registration and failure-marker persistence fail, only the current session has fail-closed knowledge; the lead must classify the new metadata-failure metric before acceptance. This residual is tracked on the transcription initiative.
Failure-Class: FC-pre-durability-audio-eviction