Repository navigation
fix(recaps): validate reads and preserve recovery responses - #21347
aryanorastar merged 6 commits into
Conversation
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. |
848ce9a to
baa6f31
Compare
…ResponseValidationError crashes Failure-Class: none
baa6f31 to
69c38cc
Compare
|
Thanks @kaleidoscopeAI — clean, well-scoped hardening fix, and the 404-instead-of-500 semantics for corrupt documents is the right call. Reviewed all three files:
Two non-blocking nits for consideration:
Checks are green and the change is read-only with no auth/scope changes. Leaving for human maintainer review before merge; nothing blocking from my side. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
…nvention The new validate-and-skip blocks in developer.py caught bare `Exception`; the sibling action-item/conversation hardening in the same file catches pydantic's `ValidationError` specifically. Tighten the two new blocks to match, addressing review nit 1.
|
Reviewed all three changed files against the head commit — this is a solid, well-scoped hardening and the approach matches the pattern already established for action items in backend/routers/developer.py — backend/routers/users.py — the list, search, and single-get endpoints get the same per-record treatment. I checked backend/tests/unit/test_daily_summary_validation_resilience.py — good hermetic coverage: corrupt nested Two minor, non-blocking notes for a follow-up if you feel like it:
Leaving this ready for a maintainer merge decision. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
…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.
|
Gentle ping for maintainer review — all 7/7 hermetic unit tests are green, and the per-record validation approach matches the pattern established in developer.py. Ready to merge whenever convenient! |
Malformed Daily Recap records can crash reads, and invalid generated content must not be saved as the completed recap that later retries reuse. This completes the existing validation PR at the read and generation/persistence boundaries.
Original validation approach and baseline tests by @kaleidoscopeAI; contributor commits remain intact. Maintainer fixes extend this same PR rather than duplicate it.
Verification
7e8af1b47faa65610f5b99667ef41346b2a797fdwithci:full: six backend unit shards and guardrails, hermetic backend E2E (165 passed, three skipped, two expected failures), both stack gauntlets, API/emulator/runtime/source contracts, formatting/hygiene, and the full Flutter analyzer/test check. The normal push gate also passed all 38 preflight checks and reported zero backend type errors. Prior 626 unit/query results at 1a6bed0 are historical evidence, not proof for this follow-up. The final diff was reviewed; fix(recaps): validate reads and preserve recovery responses #21347 remains draft for re-review as requested.Rollout: after review/merge, deploy the API backend serving recap routes and the notifications job using the changed shared producers. No new mobile build, credential or index is required. Existing malformed historical data and these customers' actual missing recaps/recording sync require separate Support investigation; these fixtures do not establish their cause or recovery.
Closes #21360 (technical work; the separate Support case stays open). Existing references: #8264, #1551.
Failure-Class: FC-malformed-doc-read
Line-Count-Exception: backend/routers/users.py | 2724 -> 2773 | Validate recap candidates at the owning producer before persistence while preserving explicit failure and retry behavior.
Line-Count-Exception: backend/routers/developer.py | 2828 -> 2834 | Validate recap candidates at the owning producer before persistence while preserving explicit failure and retry behavior.