Skip to content

fix(backend): resolve a locked daily-recap retry from its durable record - #21310

Merged
Git-on-my-level merged 1 commit into
mainfrom
fix/daily-summary-locked-retry
Oct 12, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
fix/daily-summary-locked-retry

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Summary

This is the second half of the 2026-10-12 daily-recap recovery. #21304 fixed the gateway URL.

Once recaps were generating again, the saved cohort still stayed complete=False on every tick. This happened with only one failed recipient:

  • At 11:24:39 UTC, a worker generated and pushed that user's recap.
  • Its 41s per-user budget then ran out during the backfill walk, so the coordinator recorded it as a retry recipient.
  • A successful generation keeps the per-user/day Redis lock for its full 2h TTL. Every later retry therefore hit _DECLINE_LOCKED and raised daily summary retry still locked.

That kept the cohort incomplete, and send_daily_summary_notification never ran the current cohort behind it until the 7200s age-out. Recipients due in that window got no recap. Prod logs at 11:32 and 11:47 UTC show exactly this.

Fix: on a locked retry, read the durable record. If it exists, the worker has finished, and the existing receipt and delivery-retry logic handles it:

  • the receipt suppresses a repush;
  • a missing receipt with a pending delivery retry pushes once.

If no record exists, the recipient stays pending, as before.

Failure-Class: FC-failed-resume-renews-its-own-staleness-ttl

Verification

  • New parametrized test covers a locked retry resolved from the stored record, both with a receipt (no push) and without (one push).
  • The existing contention test still raises when no record exists.
  • pytest across all 23 daily_summary* / notifications_job* unit files: 235 passed.

🤖 Generated with Claude Code

View guided diff Turn on auto-fix

A worker that finished after its timeout keeps the day lock for its 2h TTL,
so the retry raised 'still locked' every tick, kept the saved cohort
incomplete and starved the current cohort behind it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-12T12:13:53.914396Z 60440a1 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 60440a16f3

ℹ️ 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".

Comment on lines +861 to +864
# cohort, starving every current cohort behind it (2026-10-12).
summary_data = daily_summaries_db.get_daily_summary_by_date(uid, date_str)
if not summary_data:
raise RuntimeError('daily summary retry still locked')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Don't equate a stored recap with worker completion

If the timed-out worker has persisted the recap but is still blocked in _deliver_current_day_summary, a retry with retry_delivery=True can read that same record here and send concurrently with the original worker. Persistence happens before delivery, so record existence proves generation completed—not that the lock owner finished—and can produce duplicate push notifications. The documented contract explicitly says a contended retry remains pending until its outstanding worker finishes (backend/docs/runbooks/daily-summary-cutover.md, lines 49–52); only a delivery receipt or an explicit finished-worker marker can safely bypass the lock.

AGENTS.md reference: backend/AGENTS.md:L146-L146

Useful? React with 👍 / 👎.

# A worker that finished *after* its timeout keeps the lock for the full
# TTL by design, so the durable record is the only proof it is done; without
# this read the recipient stayed "locked" for 2h and pinned the whole saved
# cohort, starving every current cohort behind it (2026-10-12).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Count the recovered record as suppressed existing

The generated/suppressed_existing outcome accounting runs before this recovery read, when summary_data is still None, so every locked retry successfully resolved from a durable record increments neither outcome. This systematically undercounts successful existing-record suppression in omi_daily_summary_recipients_total, even though that counter feeds the documented recap delivery dashboard and operational analysis; record the suppressed_existing outcome after assigning the recovered summary.

AGENTS.md reference: backend/AGENTS.md:L146-L146

Useful? React with 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit ac818dd into main Oct 12, 2026
60 of 62 checks passed
@Git-on-my-level
Git-on-my-level deleted the fix/daily-summary-locked-retry branch October 12, 2026 16:29
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.

![Recovery on
iOS](https://raw.githubusercontent.com/BasedHardware/omi/04dda1ae63f6cca9181534b01de1bfac73300b47/.agent-artifacts/ui-evidence/daily-recap-recovery-completeness/001-mobile-ios-recovery-dark.png)
![Legacy sync needs
attention](https://raw.githubusercontent.com/BasedHardware/omi/04dda1ae63f6cca9181534b01de1bfac73300b47/.agent-artifacts/ui-evidence/daily-recap-recovery-completeness/003-mobile-ios-sync-needs-attention.png)
![Confirmed
processing](https://raw.githubusercontent.com/BasedHardware/omi/04dda1ae63f6cca9181534b01de1bfac73300b47/.agent-artifacts/ui-evidence/daily-recap-recovery-completeness/004-mobile-ios-sync-processed.png)

## 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant