Repository navigation
fix(backend): stop a dead recipient from pinning the daily-summary job cursor forever (#21012) - #21020
Merged
Conversation
Git-on-my-level
added a commit
that referenced
this pull request
Oct 9, 2026
…1090) ## Daily recap outage and evidence Production summaries repeatedly reported `complete=False`, `failed=1`, and the same `cohort_utc=2026-10-03T20:03:09.672497+00:00` for six days (Oct 3–9). A persistently failing recipient caused each resume to renew the cursor TTL, delaying every current cohort. The recorded serving image `notifications-job:f1adb1c` lacked the Oct 9 fix. Evidence: [age-out fix #21020](#21020), [original fix #21012](#21012), [fix commit 071ff86](071ff86cdc), and the content-free log signature documented in `backend/docs/runbooks/daily-summary-cutover.md`. The precise token/provider failure mechanism remains unknown. These are incident observations, not a new live production probe. The age-out fix is already merged and remains unchanged. It abandons any cohort older than two hours, regardless of health; this is the registered failure-class tradeoff. ## Changes - Add bounded recipient outcome counters, cohort completion counters, and a no-label resumed-cohort age gauge. Append `cursor_age_seconds` and `resumed` to the existing summary log format. Count current-day generation separately from delivery failures; never label recipients or count backfill records as recipient generation. - Attach the pinned GMP sidecar using the existing deployment helper extended for Cloud Run Jobs. Start the Prometheus listener on loopback only when configured. A shared completion marker and final scrape/drain window let the collector exit with the job. - Add `notifications-job` to both environments' actual dedicated Stackdriver exporter namespace filters, retaining `one_of(...)` and `cluster=__run__`. Keep the existing Prometheus scrape/name normalization and update its documentation. - Provision two idempotent production Cloud Monitoring log-based policies through the notifications workflow: incomplete-cohort rate > 0 sustained for three hours (15-minute alignment), and summary heartbeat absent for 60 minutes under the continuous 15-minute schedule. Repeated deploys reconcile conditions and notification channels. No Grafana alert is added. - Add the collapsed “Daily recaps — delivery job health” row with four panels to `omi-core-features`: recipients by outcome, cohort completion, resumed age with the 7200-second TTL line, and current age stat. ## Validation - `PYTHON=.venv/bin/python bash test-preflight.sh`: 17 passed, 9 optional warnings, 0 failed. - Worktree Python 3.11: requested five suites plus monitoring workflow, sidecar helper, metrics listener and metrics-egress contracts: 169 passed, 0 failed. - `actionlint .github/workflows/gcp_notifications_job.yml`: passed. - `scripts/pr-preflight --pr-body-file /tmp/pr-body.md`: 39 checks passed. Final `OMI_PR_BODY_FILE=/tmp/pr-body.md make preflight` on the frozen commit: 39 checks passed. The recurrence ratchet reports its normal shallow-history skip; failure-class declaration validation passed. - No deployment or production account access performed. Collector image metadata was read from its public registry to verify `/bin/sh` and `/run-gmp-entrypoint` exist. ## POST-MERGE DEPLOY STEPS 1. Dispatch `gcp_notifications_job.yml` from merged `main` with `environment=prod` and `branch=<reviewed merge SHA>`. This ships the already-merged fix, new telemetry/sidecar, and both Cloud Monitoring policies. Verify the image SHA, job completion, summary logs, collector export errors, and configured notification channels. Observe at least one summary heartbeat to arm the absence policy. 2. Dispatch `gcp_cloud_run_metrics_egress.yml` from `main` with `environment=prod` to apply the expanded exporter allowlist. Dev metrics egress auto-deploys on `main`; the existing notifications job workflow is dispatch-only (there is no notifications auto-dev workflow). To validate the dev job, dispatch `gcp_notifications_job.yml` with `environment=development`. 3. Verify normalized `omi_daily_summary_*` series in Cloud Monitoring and Prometheus, then expand the Core Features daily-recap row. **Grafana panels show No-data until both the notifications-job deploy and production metrics-egress dispatch complete. The log-based alerts can page after the notifications deployment alone.** Repository checks do not prove end-to-end ingestion or paging; those require the post-merge deployments and verification above. Failure-Class: FC-failed-resume-renews-its-own-staleness-ttl ## Product invariants affected - INV-DATA-1 INV-DATA-1 ([customer data-plane continuity](https://github.com/BasedHardware/omi/blob/main/product/invariants/data-plane-continuity.md)): this workflow continues to render the same notifications job Firebase/Firestore runtime bindings and service-account identity. The helper preserves the application's env, secrets, network and task settings; collector-only runtime `K_SERVICE=$CLOUD_RUN_JOB` sets the GMP namespace. Job patch tests verify preserved settings and string-valued env round trips. This PR performs no account/data migration or historical-data writes. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/21090?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> <!-- End of auto-generated description by cubic. -->
This was referenced Oct 13, 2026
aryanorastar
added a commit
that referenced
this pull request
Oct 16, 2026
…ciliation (#21362) ## What changed and why Daily Recap recovery was unreachable on mobile/web, and successful recovery could still disappear behind an older read or remain hidden on Home. Offline Sync also left restored uploads without a job handle permanently processing and overstated what successful processing proved. Complete the recovery path and reconcile these remaining sync/reporting gaps. Fixes #11821; remaining customer-account outcomes are tracked by #21360. - Add historical-date recovery to mobile Notifications settings/Daily Recaps and web Conversations using the existing idempotent `POST /v1/users/daily-summaries` authority. No push token or enabled schedule is needed; source recordings and existing recaps are preserved. - Publish successful mobile recovery to mounted Home readers, including a previously empty Home section. Fence older reads, preserve existing cards on failures, and offer retry. A malformed list envelope is a read failure, not an empty account. - Give web recap snapshots owner-scoped cache keys and one read lease for initial load/refresh/pagination. Re-read after a creation/deletion commits before adopting an older result, retain chronological order and server offsets, reject late data after account switches, and surface recap read failures with a specific retry. - Reconcile uploaded WALs with missing/blank job handles: requeue retained audio through the existing deduplicated upload path without consuming retries; preserve unavailable rows when local audio is missing. Persist the outcome and fence asynchronous file checks on account changes. - Show **Processed** rather than inventing a created conversation for an empty/silent completed job. The legacy status card and empty-pending state no longer claim completion while another recording needs attention. Local-copy cleanup copy states the deletion period without promising a cloud audio copy. Retention behavior, storage settings, capacity controls and batching are unchanged. ## Product invariants affected INV-CAP-1 — retained recordings stay intact through orphan-job recovery. Requeueing preserves audio and retry budget; missing-file outcomes remain visible rather than being acknowledged as synced. No deletion or retention policy changes. ## How it was verified - `bash app/test.sh`: full hermetic suite passed, **5,368 passed / 21 skipped**. Analyzer ratchet passed; existing informational diagnostics remain within baseline. - Focused mobile recovery/API/Home/sync tests: **176 passed**. WAL suite also passed with `CAPTURE_EVIDENCE_V1_DARK_WRITE=true`: **146 passed**. - `make mobile-verify ARGS='fast --paths app/lib/pages/home/widgets/home_daily_recaps.dart app/lib/pages/conversations/sync_page.dart app/lib/pages/conversations/auto_sync_page.dart app/lib/services/wals/local_wal_sync.dart'`: **23 existing relevant journeys passed**. These are the seeded journey lane, separate from the new focused recovery tests. - `bun run check`: typecheck, Moonshine smoke, and the full current web suite passed: **127 files / 682 tests**. The final recap lifecycle file passed all 8 tests. - Actual WAL service lifecycle regression: restored orphaned upload → retained file requeued → upload ACK with job ID → job polling → confirmed processing/conversation result → durable index reload. Audio bytes stay unchanged; uploader/status transport are test seams, not a real-device/backend-capacity measurement. - Local HTTP smoke from the first commit exercised the real FastAPI creation/list routes and emulator storage: disabled schedule, no FCM token, missing October 4 recap beyond automatic catch-up, stable ID on retry, one generation, zero pushes, honest 400 for an empty date, and unchanged source conversation/prior recap/schedule. Only the summary provider and quota gate were fixture seams. - The recovery widget was exercised through that local API in an iOS simulator and browser preview. The final actual legacy/Auto Sync widgets were rendered with synthetic inventories and the bundled font, asserted, captured, and visually inspected. No physical customer-device or customer-account recovery test is claimed. Impeccable's final changed-target detector returned no findings. ## Tests `daily_summary_creation_test.dart` and `apiDailyRecaps.test.ts`: endpoint/date/response identity, malformed/legacy replies and status failures. `daily_recap_recovery_action_test.dart` and `GenerateRecapAction.test.tsx`: date selection, cancellation, single flight and honest failures. `home_recap_recovery_test.dart`: successful recovery from another screen reveals Home, older responses cannot hide it, and failed reads retry. `useRecapsCreation.test.ts`: ownership, creation vs initial read, reads both before and during deletion, malformed-response retry, stable identity, chronological pagination and raw server offsets. `ConversationSplitView.test.tsx` verifies the user-facing read-error retry. `local_wal_sync_test.dart` covers missing/empty/whitespace handles, durable retry state, preserved bytes, unavailable audio, and the whole retained-file upload/poll lifecycle. `sync_completion_truth_test.dart` and `sync_row_recovery_window_test.dart` execute the actual sync screens/rows and prevent false completion, conversation and cloud-copy claims. ## Release and customer verification The October scheduler/gateway/retry fixes (#21020, #21304, #21310) are already on current main. Production notifications deployments for #21304 and #21310 succeeded on October 12. They restore the known generation failures and remain required context for this report. This PR needs **merge, a mobile release containing these changes, and web deployment**. It uses existing backend contracts; **no new backend deployment is required by this PR**. macOS already uses the shared creation endpoint. The remaining customer-account checks are operational verification, not an assertion that the client PR restored customer data: confirm scheduled recaps resumed, generate/check each missing eligible date from retained server conversations, and confirm every reported recording reached processing completion on the customer's installed release. The feedback lacks a platform/version/exact sync error; do not claim the orphan-job fix is its proven cause. #21347 remains open for malformed stored recap read validation; #21319 remains open for pendant upload batching, and #21216 tracks capacity/backlog complaints. Their causes are not established for this customer. Do not duplicate those fixes or claim those separate symptoms solved by this PR. Keep #21360/Featurebase open until the account outcome is verified. Local preflight passed all 27 checks. Architecture and implementation/release checklist: `app/docs/recap-recovery.md`. ## UI evidence Synthetic inventories; screenshots contain no customer data.    ## Failure class (fixes) Failure-Class: FC-read-in-flight-across-delete-resurrects-row The existing class covers stale list adoption across a committed mutation. The shared recap read owner fences both deletion and recovery; controllable-future tests cover reads admitted before and during deletion. The orphan-upload and missing-control changes are separate concrete gaps, guarded by their service/UI regression tests. Line-Count-Exception: app/lib/services/wals/local_wal_sync.dart | 2690 -> 2728 | Keep orphan-job reconciliation, snapshot iteration, post-await row revalidation, persistence and session fencing inside the existing WAL lifecycle owner rather than splitting mutation authority.
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
Daily-summary recaps stopped generating for every recipient on 2026-10-03 and never resumed (#21012: 6 nights missing, reported by a user; production logs confirm it: zero new recaps since).
Root cause
send_daily_summary_notificationresumes its saved checkpoint cohort before it will serve the current one — and only serves the current cohort if the resumed one reportscomplete. The checkpoint's Redis key has a 2-hour TTL that is documented (daily_summary_budget.py) as the staleness bound: "a cursor no execution reached within two hours describes a population that no longer exists."That bound assumes a stale checkpoint goes untouched. It doesn't: a recipient whose push keeps reporting "delivered to no devices" (stale/invalid FCM token — permanent, no retry will ever clear it) fails on every 15-minute tick, and the failure handler re-checkpoints that same recipient with a fresh TTL every time. The TTL never expires, the resumed cohort never completes, and the current cohort is never reached — for as long as that one recipient keeps failing. Production logs show the job resuming the exact same
cohort_utc=2026-10-03T20:03:09Zon every tick through 2026-10-09, re-failing the same uid each time, with 17,243 other recipients never advancing past that cohort.Fix
Measure the resumed cohort's age from its own origin instant vs. now, independent of the Redis TTL (which a failed resume always renews). Once the age exceeds the documented 2-hour staleness bound, abandon the resume unconditionally — log it, clear the checkpoint, and let the current cohort run regardless. The abandoned recipient's missed days are still covered by the existing 7-day backfill walk once a later tick processes them normally.
Added
FC-failed-resume-renews-its-own-staleness-ttl— a new failure class — since this "checkpoint TTL defeated by its own failed resume" shape wasn't in the registry yet.What I tested
BACKEND_UNIT_TEST_FILE_LIST=... bash test.shontest_daily_summary_job_resilience.py(29/29 pass), plustest_daily_summary_race_condition.py,test_notifications_job_orchestrator.py,test_daily_summary_generation.py,test_daily_summary_schedule_fields.py(43/43 pass total) — no regressions.test_a_cursor_stuck_past_its_staleness_bound_is_abandoned_so_current_recipients_are_not_starved, which seeds a checkpoint older than the staleness bound and asserts the dead cohort is never re-queried and the checkpoint is cleared. Confirmed this test fails against the pre-fix code (reads == [3, 6]instead of[6]) — it reproduces the actual defect, not a tautology.notifications-job,based-hardware): every execution since 2026-10-03 resumescohort_utc=2026-10-03T20:03:09Z, fails the same uid withdaily summary push delivered to no devices, and never reaches a current-day cohort.Product invariants affected: none
Failure-Class: new
🤖 automated by hourly watchdog — tested and merged