Repository navigation
fix(sync): stabilize playback manifests and recover failed merges - #23904
Conversation
Failure-Class: FC-derived-audio-identity-churn
Failure-Class: FC-derived-audio-identity-churn
Failure-Class: FC-derived-audio-identity-churn
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7799c759c7
ℹ️ 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".
| except PlaybackSourceChanged: | ||
| return await _refuse_changed_playback_source(payload) |
There was a problem hiding this comment.
Require a complete archive listing before declaring source changes
For a stamped part containing raw archive fragments, a transient failure in list_packs() makes list_audio_chunks() return only encoded chunks: archive errors are swallowed unless require_archive=True, but the playback builders do not request that. resolve_sources() then raises PlaybackSourceChanged, and this new handler acknowledges the task and writes a terminal source_changed marker. A temporary archive-listing outage therefore permanently disables otherwise recoverable playback, including the new failed-merge recovery path. Require a complete archive listing for identity validation, or propagate incomplete-listing failures as retryable rather than recording a terminal verdict.
Useful? React with 👍 / 👎.
| def get_playback_failure_retry_epoch( | ||
| uid: str, conversation_id: str, audio_file_id: str | None = None, *, fingerprint: str | None = None | ||
| ) -> str | None: | ||
| """Allow an accessed failed merge one new task per marker generation. |
There was a problem hiding this comment.
Document the new playback recovery contract in the pipeline guide
This change introduces default-on playback recovery, a 15-minute cooldown, marker-generation task identities, and new terminal source-change handling, but does not update backend/docs/listen_pusher_pipeline.mdx. backend/AGENTS.md explicitly requires that guide to be updated in the same change for audio pipeline changes. Add the recovery and rollback behavior there; the generated feature-flag registry does not replace the required pipeline documentation.
AGENTS.md reference: backend/AGENTS.md:L163-L163
Useful? React with 👍 / 👎.
|
|
||
| async def _refuse_changed_playback_source(payload: dict, *, fingerprint: str | None = None): | ||
| """A replaced source cannot be repaired by retrying its old immutable key.""" | ||
| from database.legal_holds import DestructiveOperationInProgress |
There was a problem hiding this comment.
Reuse the module-level destructive-operation exception import
backend/AGENTS.md explicitly requires all imports at module scope, but this new helper adds a function-local import. DestructiveOperationInProgress is already imported at the top of this module, so remove this redundant local import and use the existing binding to comply with the backend import convention.
AGENTS.md reference: backend/AGENTS.md:L167-L167
Useful? React with 👍 / 👎.
| if payload.get('recovery_epoch'): | ||
| # The failed marker generation is stable across polls and hour changes. | ||
| # One failed retry rewrites the marker and starts a fresh cooldown. | ||
| suffix = f"-r{payload['recovery_epoch']}" |
There was a problem hiding this comment.
Preserve the dispatch namespace in recovery task names
If a per-file recovery task is enqueued with playback-on-demand disabled and delivered after PLAYBACK_ON_DEMAND_ENABLED becomes true, run_audio_merge_job() acknowledges it as deferred_until_playback and stamps a new playback_eager_epoch without changing the failure marker. This assignment overrides both the on-demand namespace and that deferral epoch, so subsequent playback requests generate the exact same task name; enqueue_named_task() swallows AlreadyExists, leaving playback pending until the tombstone or marker expires. The same collision persists after rolling the flag back. Include the dispatch mode/deferral epoch alongside the marker generation so acknowledged eager recovery tasks cannot suppress later playback requests.
Useful? React with 👍 / 👎.
The upstream blank-session retry identity explicitly includes only recording facts and excludes client_processing projections. Register that reviewed dump site without changing the upstream implementation.
Playback merges reject unchanged source chunks when late encoded uploads cover the last raw fragment: the listing switches from the sample clock back to rounded filename timestamps, invalidating the stamped hash. One affected conversation's bounded read-only metadata reproduces this for 266 of 267 current stamps; the remaining stamp stays fail-closed.
Keep identity listings on the sample clock and verify old-clock stamps against their exact generation/checksum hash. Resolve reordered listings and same-timestamp groups by hash, pin stamped downloads to their paths/buckets/generations, and refuse a true changed source without publishing bytes or exhausting attempts. Legitimate growth preserves the unchanged selected manifest and proceeds; fresh groups get stable stamps through the existing creator.
Failed merges recover on next access after a 15-minute cooldown, with one deduped task per unavailable-marker generation.
PLAYBACK_MANIFEST_RECOVERY_ENABLED=falsestops new recovery enqueues (default on); already queued jobs drain through the existing handler. Missing/empty/source-changed verdicts stay terminal. No source audio is deleted and no raw storage layout changes.Failure-Class: FC-derived-audio-identity-churn
Line-Count-Exception: backend/routers/sync.py | 4084 -> 4124 | Keep terminal source-change classification next to both existing merge task handlers and their shared destructive-operation deferral.
Line-Count-Exception: backend/utils/other/storage.py | 2693 -> 2779 | Keep source-clock listing, exact manifest-path and generation-pinned reads, and marker-generation retry inspection at their existing storage authority; no new module or storage API owner.
Validation:
BACKEND_UNIT_TEST_FILE_LIST=... BACKEND_PYTEST_WORKERS=1 bin/omi-heavy run -- nice -n 19 bash backend/test.sh(workspace heavy wrapper). CI repair delta rechecked 192 cases through/Volumes/Ephemeral/scratch/pbmerge/ci-fix-tests.txton current main.nice -n 19 bash backend/testing/e2e/run.sh.7584afe3772f154108f28aa93eba22a7b9f78e10.7799c759c7527b7d4fc90edaba473e3f3077c7d7: SHIP, no findings. Round 2 at final head7584afe3772f154108f28aa93eba22a7b9f78e10: SHIP, no findings; the reviewer independently verified the explicit trust-boundary allowlist, both storage fixtures, and zero playback production diff since round 1. The test results above are local execution evidence. Lead merge requires terminal-green GitHub checks on the final head; the live Checks tab owns CI status.Test-only old-contract updates:
test_audio_merge_tasks.pyreplaces the blanket source-text prohibition on unavailable retries with a behavioral assertion that permanent markers never enqueue;test_sync_playback_service.py,test_conversation_playback_artifact.pyandtest_sync_silent_failure.pyadd the new storage seam to their import-isolated fixtures;test_audio_durable_outbox.pyexplicitly constructs a historical filename-clock stamp so the compatibility canary still covers old persisted handles after new listings use the sample clock.test_client_processing_trust_boundary.pypins the reviewed serialization site introduced by upstream #23886:_derived_client_session_idexplicitly includes only recording facts and excludes client projection fields. New regression cases extend existingtest_repeat_work_cuts.pyandtest_playback_idempotency.py.The first CI run identified the missing stub in
test_sync_silent_failure.pyand the upstream #23886 serialization pin. This fixes main pin from #23886, specifically the reviewed_derived_client_session_iddump. Both repairs are covered by the standing test-only contract-update grant and explicit lead ruling 70d04a; the upstream owner was notified. Current main was integrated without force-push; playback production code is identical to the full-reviewed source head. No CI rerun or skip was used to hide either failure.Operator evidence: ro-prod only, one conversation's
audio_filesmetadata plus GCS object metadata, aggregate output only. Exact fields: name/generation/size/timeCreated/updated/md5Hash/crc32c; v2_start/v2_samples/v2_sample_rate/v2_playback_start/capture_start/capture_end/gap_count/channels/codec/source_layout. No audio bytes, transcripts, profiles or production writes. The mask included four extra raw descriptor keys (gap_count/channels/codec/source_layout) beyond the explicitly named span/capture keys; disclosed to lead. No further prod reads.Report:
omi-workspace/data/run-2026-10-13-two-lane-nemotron/swarm/state/refs/1028-pbmerge-report.md. Backend Cloud Run deployment belongs to the lead; this lane neither merges nor deploys. Follow-up owner lead, by 2026-10-29T02:00Z: evaluate post-train remaining unmatched-source errors. No claim of production playback acceptance.Scope correction approved by lead ruling 6fa5ba: actual module
backend/utils/cloud_tasks.pyreplaces the nonexistentbackend/utils/other/cloud_tasks.pyfrom the brief.Lead ruling 853171 also permits only the kill-switch registry entry and regenerated catalog in
config/feature-flags.yamlandbackend/docs/feature-flag-registry.md. No workflow or runtime-env changes.