Skip to content

fix(app): align orphan audio recovery and reclaim with the 60-day sync lookback - #25687

Merged
Git-on-my-level merged 1 commit into
mainfrom
lane/orphan-reclaim-60d
Nov 19, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
lane/orphan-reclaim-60d

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

What changed and why

The production offline-sync lookback (SYNC_BACKFILL_MAX_AGE_SECONDS) rises from 30 to 60 days in #25677. The phone's orphan-audio handling (#25604, #25573) was built around 30 days: auto-recovery stopped at 28 days, and stranded-orphan reclaim deleted unreferenced orphans once both clocks passed 45 days. Under a 60-day server window, orphans 28 to 60 days old would be admissible but never auto-recovered, and orphans 45 to 60 days old would be deleted while the server would still transcribe them.

All three ages now derive from one constant in app/lib/services/wals/orphan_audio_classifier.dart, so they cannot drift apart again:

Constant Value Why
serverSyncLookbackSeconds 60 days Mirrors prod SYNC_BACKFILL_MAX_AGE_SECONDS after #25677
orphanRecoveryWindowSeconds lookback − 2 days = 58 days Same two days of drain slack as the old 28/30
orphanReclaimMarginSeconds 7 days margin_days in backend/deploy/storage-lifecycle/retention_contract.json: a Delete is at least the longest hold plus the margin
orphanReclaimAgeSeconds lookback + margin = 67 days Reclaim needs both capture time and mtime strictly older than 67 days (the predicate stays <= → too young), i.e. "over 67 days". The margin also absorbs phone/server clock skew at the boundary

Other changes:

  • syncTooOldExplanation ("This recording is over 30 days old…") now reads "This recording is older than Omi's sync window, so Omi can't transcribe it. …", naming no number, because the window is 60 days in prod and 30 on dev. Changed through scripts/l10n.py set in all 49 locales; every locale already carried the English string, so they still do.
  • Comments that hard-coded 30 days for admission (sync_upload_batch.dart, local_wal_sync.dart, wal_orphan_reclaim.dart), CUSTODY.md, the INV-CAP-1 exception text and heading, the orphan_audio_reclaim_off registry note in config/feature-flags.yaml. The FC-offline-drain-newest-first-starves-recovery-deadline text also says 30 days; the failure-class protocol forbids registry edits in an instance-fix PR, so that one-line prose update goes in a separate registry-only PR.
  • Unchanged: the orphan_audio_reclaim_off kill switch (only a resolved false permits reclaim; true, unknown or unreadable retains everything), census completeness, reference checks, tombstones and batching. The orphan census telemetry age buckets (0_7 … over_45) keep their keys, so dashboards don't break; they are descriptive only.

The authority is David's 2026-11-18 decision (item 2 of the support-packet decisions in the workspace record): reclaim above the new lookback plus margin (>67 days), auto-recovery about 58 days. It replaces the 2026-11-17 orphan ruling's "server refuses >30-day uploads" premise.

Rollout

  • The reclaim ramp is not held (David's call). This PR must reach users before the orphan_audio_reclaim_off ramp reaches anyone whose unreferenced orphans are 45 to 67 days old; until it ships, builds containing fix(custody): reclaim stranded orphan audio older than 45 days #25604 still use the 45-day age wherever the flag resolves false.
  • Dev builds against a 30-day dev server will auto-adopt 30 to 58-day orphans that the server then refuses with backfill_lookback_exceeded. That is fine: the row is persisted as outsideRecoveryWindow, stays held and visible, and every byte is retained. Reclaim is unaffected on dev (it only gets later). The only cost is a refused request.
  • No new flag: this only makes an existing deletion later and an existing recovery wider.

Product invariants affected

INV-CAP-1 (product/invariants/pendant-audio-retention.md): the explicit stranded-orphan exception moves from "older than 45 days" to "older than 67 days" (narrower deletion). Anchor link in CUSTODY.md updated.

How it was verified

Written test-first. With the new constants introduced at the old values (30-day lookback, 45-day reclaim), the new tests failed for the right reasons: a 40-day orphan classified expired instead of recoverable, a 50-day orphan was deleted, and the constants test failed. With the real values:

  • flutter test test/unit/wal_orphan_reclaim_test.dart test/unit/wal_orphan_recovery_test.dart test/unit/local_wal_sync_test.dart test/pages/conversations/ test/unit/sync_status_privacy_contract_test.dart: 510 passed.
  • python3 scripts/l10n.py check: ok, 49 locales.

Layer: unit and widget tests only; not exercised on a device.

Tests

  • wal_orphan_reclaim_test.dart: new invariant test (reclaim age strictly greater than recovery window + margin, ≥ lookback + margin, recovery inside lookback, lookback 60 days); retention cases for an orphan at 50 days (both clocks), capture at 61 days, exactly 67 days (filename, fractional filename, mtime); deletion one second past 67 days.
  • wal_orphan_recovery_test.dart: the inclusive boundary is now the 58-day window, and a 40-day orphan is recoverable; the manual-upload refusal test now crosses the 60-day lookback.
  • offline_sync_recording_blocks_test.dart: asserts the new copy and that no locale's syncTooOldExplanation contains a digit.

UI evidence

Rendered by the existing offline_sync_recording_blocks_test.dart render cases (OFFLINE_SYNC_RENDER_OUTPUT), iOS, dark.

Too-old recording row
Too-old recording row, 1.5x text

Failure class (fixes)

Routine cleanup (an age timer) would destroy audio that was still recoverable.

Failure-Class: FC-audio-cleanup-before-durable-custody

🤖 Generated with Claude Code

View guided diff Turn on auto-fix

…c lookback

The server sync lookback rises to 60 days in production (#25677). Orphan
auto-recovery stopped at 28 days and reclaim deleted unreferenced orphans
over 45 days, so 28-60-day orphans were admissible but never recovered and
45-60-day orphans were deleted while the server would still accept them.

Derive both from one constant, serverSyncLookbackSeconds (60 days):
recovery window 58 days (two days inside), reclaim age 67 days (lookback
plus the retention contract's 7-day margin_days, strict). A test fails if
the reclaim age is not strictly beyond recovery plus margin. The too-old
copy no longer names a day count. Kill switch semantics unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

@kodjima33 UI changes involving Git-on-my-level require your approval. Review the current diff, then comment /approve-ui 9bff7f196bfbf9452fab36b7ce820815c5512e4e. Each new head needs a fresh approval. To withdraw it, comment /reject-ui <full head SHA>. Non-UI work and unrelated access are unaffected.

Git-on-my-level added a commit that referenced this pull request Nov 18, 2026
…e-drain class (#25689)

## What changed and why

Registry-only prose update to
`FC-offline-drain-newest-first-starves-recovery-deadline`: its
violated-contract text says the server lookback is 30 days. Production
is 60 days after #25677 (dev and the code default stay 30). Split out of
#25687 because the failure-class protocol forbids registry edits in an
instance-fix PR.

No status, family, scope or canonical-prevention change.

## Product invariants affected

none

## How it was verified

`scripts/pr-preflight --pr-body-file` on this body. JSON-only change.

## Tests

No test change: registry prose only.

## UI evidence

UI-Evidence: none -- registry text only

## Failure class (fixes)

Failure-Class: none

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/25689?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/25689?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F25689&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. -->
@Git-on-my-level

Copy link
Copy Markdown
Member Author

/approve-ui 9bff7f1

@Git-on-my-level
Git-on-my-level merged commit d6f5ba7 into main Nov 19, 2026
53 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/orphan-reclaim-60d branch November 19, 2026 04:28
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