Skip to content

fix(sync): stabilize playback manifests and recover failed merges - #23904

Merged
Git-on-my-level merged 8 commits into
mainfrom
lane/pbmerge
Oct 28, 2026
Merged

Git-on-my-level merged 8 commits into
mainfrom
lane/pbmerge

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

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=false stops 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:

  • 394 distinct tests passed across 14 isolated files (17 platform skips) via selected files through 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.txt on current main.
  • Coverage includes growth during merge, reordering, true replacement before/during merge, generation-pinned downloads, permanent marker reasons, kill switch, and 230-file retry fan-out across hourly task names.
  • Hermetic backend E2E: 174 passed, 3 skipped, 2 xfailed via the same heavy wrapper and nice -n 19 bash backend/testing/e2e/run.sh.
  • Local preflight: all 37 selected checks passed (including registry, Firestore guards, async/import/route checks and runtime source closure). Full push hooks, including whole-backend Pyright and the bounded unit shard, passed again at repair head 7584afe3772f154108f28aa93eba22a7b9f78e10.
  • Luna read-only full review round 1 at source head 7799c759c7527b7d4fc90edaba473e3f3077c7d7: SHIP, no findings. Round 2 at final head 7584afe3772f154108f28aa93eba22a7b9f78e10: 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.py replaces 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.py and test_sync_silent_failure.py add the new storage seam to their import-isolated fixtures; test_audio_durable_outbox.py explicitly 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.py pins the reviewed serialization site introduced by upstream #23886: _derived_client_session_id explicitly includes only recording facts and excludes client projection fields. New regression cases extend existing test_repeat_work_cuts.py and test_playback_idempotency.py.

The first CI run identified the missing stub in test_sync_silent_failure.py and the upstream #23886 serialization pin. This fixes main pin from #23886, specifically the reviewed _derived_client_session_id dump. 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_files metadata 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.py replaces the nonexistent backend/utils/other/cloud_tasks.py from the brief.

Lead ruling 853171 also permits only the kill-switch registry entry and regenerated catalog in config/feature-flags.yaml and backend/docs/feature-flag-registry.md. No workflow or runtime-env changes.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 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-28T15:59:04.163397Z 7584afe New commits
ℹ️ 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: 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".

Comment thread backend/routers/sync.py
Comment on lines +3852 to +3853
except PlaybackSourceChanged:
return await _refuse_changed_playback_source(payload)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Comment on lines +1952 to +1955
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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Comment thread backend/routers/sync.py

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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']}"

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 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.
@Git-on-my-level
Git-on-my-level merged commit 9d6d0d5 into main Oct 28, 2026
65 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/pbmerge branch October 28, 2026 16:17
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