Repository navigation
feat(sync): operator minimal redrive mode for preserved legacy audio - #22503
Conversation
Operator payloads with redrive_mode='minimal' run the existing sync job at near-zero cost: Parakeet-only STT pinned through selected_service (no paid empty recovery; unservable language fails retryably with sync_minimal_provider_unavailable), attach-first explicit target within 10 minutes through the lifecycle owner, and one gpt-5-nano title/overview per new row instead of conversation processing (deterministic minimum on failure). Ledger, dedupe and receipts are unchanged; the job result records redrive_mode. SYNC_MINIMAL_REDRIVE_ENABLED (default on) refuses such tasks with a retryable 409 when off. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Regenerate backend/docs/feature-flag-registry.md after the conflicting registry update. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Move provider selection, paid-recovery gating and attach-first targeting behind minimal_redrive helpers; skip attach for lineage-bound segments. process_segment carries the coordinator's Pyright complexity-ceiling suppression. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
| def eligible(row: dict) -> bool: | ||
| return ( | ||
| compatible_capture(row, capture) | ||
| and not row.get('deleted') | ||
| and not row.get('sync_merged_into') | ||
| and row.get('status') == 'completed' | ||
| ) |
There was a problem hiding this comment.
🔒 Agentic Security Review
Severity: MEDIUM
Minimal redrive attach-first selects the closest same-device completed row within 10 minutes and passes it as assignment target_id. eligible() does not apply auto_mergeable or a private-visibility check, so a shared or public neighbor can be forced as canonical. Assignment then skips the user-managed fence for that explicit target and can absorb nearby private auto-mergeable donors into it.
Impact: Operator bulk redrive of preserved private sync audio can append unpublished speech onto a conversation the owner already shared or published. Anyone with the share link can then read that newly merged transcript without a further owner action.
Reviewed by Cursor Security Reviewer for commit 8c93998. Configure here.
- Declare redrive_mode as an optional Cloud Tasks payload key so budget replacements and sequencer re-dispatch keep it. - Re-raise ProviderUnavailable past process_segment and the gather loop so the task handler retries instead of consuming preserved audio. - Check the kill switch in run_sync_job before the UID sequencer lease. - Pin the title call to the company gpt-5-nano lane with BYOK cleared. - Clear structured.title_provenance and keep the stored data_protection_level on the title persist. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Keep both new feature-flag entries (SYNC_MINIMAL_REDRIVE_ENABLED and main's PARAKEET_WINDOW_STRANDED_DRIFT_SETTLE_ENABLED) and regenerate the registry doc. Main's app/web files are carried byte-for-byte (formatters left them as merged). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve process_segment signature and the coordinator cap_content_id call: keep main's cap_dispatch_lane parameter and stt_cap_dispatch_enabled(uid, 'sync') alongside redrive_mode. Main's app/web files are carried byte-for-byte. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Keep both new feature-flag entries (SYNC_MINIMAL_REDRIVE_ENABLED and main's BATCH_PIPELINE_LONG_SPEECH_HANDOFF_ENABLED) and re-render the registry as of 2026-10-20. Main's app/web files are carried byte-for-byte. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… operator minimal redrive with the pipeline Coordinator ruling 10-20 05:17Z: minimal redrive (#22503) runs only through the legacy pipeline, so C11 deletes utils/sync/minimal_redrive.py, its run_sync_job kill switch, the redrive_mode payload key, SYNC_MINIMAL_REDRIVE_ENABLED, the sync_redrive_title model config, gateway override, inventory and route fixture entries, and its tests. The cap-hold core extraction is unchanged: #22503 was the only pipeline.py change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ing 10-20) (#22769) ramp_set refuses to leave legacy_sync=on until operator minimal-mode redrives (#22503) are confirmed finished or moved to batch: draining stops new sequencer registration and C11 deletes the mode. Co-authored-by: Claude Opus 5.5 <[email protected]>




Summary
Adds an operator-only minimal redrive mode so preserved legacy sync audio (uploads retired Oct 15–17, held in
gs://syncing-local) can be re-processed through the existingcreate_sync_job→claim_sync_content→register_job→uid_sequencer.kickpath at near-zero cost. A stored Cloud Tasks payload carryingredrive_mode: 'minimal'(exact value only; anything else is the normal path) changes three things; ledger, dedupe and receipts are unchanged. Clients never set this key: it is read only from the server-built task payload in_run_sync_job_attempt.New logic lives in
backend/utils/sync/minimal_redrive.py;routers/sync.pyandutils/sync/pipeline.pyonly thread the mode through.process_segmentpin('parakeet', <lang>, 'parakeet')through the existingselected_serviceseam used by cap recovery, so no Modulate or other vendor is selected. The paid empty-segment recovery (_recover_empty_segment) is skipped: a double empty (after the existing bounded Parakeet confirmation retry) is recorded as silence. If Parakeet cannot serve the job's language, the job fails retryably with reasonsync_minimal_provider_unavailable: a typedProviderUnavailableis re-raised past the segment and gather boundaries, so the task handler's retry /failed_finalpath owns it and the preserved audio is never consumed on first attempt. A fallback to the owner's paid language provider would be a later, explicit opt-in.live_overlap.compatible_capture(source, device, lock partition), not deleted, not merged away, and statuscompleted. The lookup reuses the existing indexedget_closest_conversation_to_timestampsquery shape: a new keywordwindow_seconds(default 120, unchanged for normal traffic) and an in-memoryeligiblepost-filter. No new index or query shape is added, and the query-driver registry classifies both parameters. The match goes tolifecycle.ingest_sync_conversationas an explicittarget_id, soassign_sync_conversationstill owns the write and re-checks deletion and provenance in its transaction. The ±2 min hint and the 120 s continuity are unchanged for normal sync._reprocess_merged_conversationsis replaced byminimal_redrive.finalize:sync_redrive_titlecall returning a title and a 1–2 sentence overview. It is persisted as a partialstructuredmerge throughlifecycle.persist_processed_conversationunder thesync_content_revisionfence. That write clears the stalestructured.title_provenance, so the generated title is no longer treated as the disposable server minimum, and it keeps the row's storeddata_protection_level. The call runs in a copied context with BYOK keys cleared, so it always uses the companygpt-5-nanolane and never a user's own key or model.build_deterministic_minimum_structured, zero LLM).redrive_modeis a declared optional Cloud Tasks payload key (SYNC_JOB_OPTIONAL_TASK_PAYLOAD_KEYS), so handler-budget replacements and sequencer re-dispatch keep the mode. Client admission still never sets it.mark_sync_content_completedand legacy completion convergence. The final job and ledger result recordsredrive_mode: 'minimal'; the clientSyncLocalFilesResultResponsedrops unknown keys, so clients never see it. A repeat finds the row already titled (or the ledger already complete) and does no new work.SYNC_MINIMAL_REDRIVE_ENABLEDis on unless set tofalse/0/off. When off, a minimal payload is refused with a retryable 409 inrun_sync_job, before the UID sequencer lease (begin_job) and before any lock, download or provider call. The task, staged audio and ledger claim are kept. It is registered inconfig/feature-flags.yaml, andbackend/docs/feature-flag-registry.mdwas regenerated as of 2026-10-19.Model (approved by David 2026-10-19 ~14:55Z): the title uses a new
model_configfeature,sync_redrive_title, ongpt-5-nanowith gatewayreasoning_effort: minimal, the cheapest managed lane.gemini-2.5-flash-liteis not allowed for managed traffic (test_omi_qos_tiers.py,vertex_pt_routing.py). David approvedgpt-5-nanofor the title and short summary on 2026-10-19 (~14:55Z), with the zero-LLM deterministic title fallback. He also approved the scope for his own account: the 96 remaining contents with ≥10 s of sustained speech under both VAD runs, run one at a time, stopping on the first failure. Fleet use still waits for his separate go. The QoS tier expectations, gateway route overrides, endpoint inventory (feature and call site) and dream route snapshot are updated together.Design notes and deviations
status == 'completed'and nosync_merged_into, so it never appends into an open live row or a merge donor. This is stricter than "not deleted".process_segmentgains the same# pyright: ignore[reportGeneralTypeIssues]the coordinator already carries: even one more read of a parameter in its body crosses Pyright's analyzer complexity ceiling, which main sits just under. New branching lives in helpers inminimal_redrive.py.generate_titleimportsget_llmlazily, like the pipeline's other leaf imports, because stubbed coordinator harnesses (test_sync_geolocation_enrichment,test_phone_batch_process_now) load the pipeline without the LLM client stack.Product invariants affected
none
Failure class (fixes)
Failure-Class: none
The only
fix:commit addresses pre-merge review findings on this unshipped feature. No shipped failure recurs.Verification
All runs are local, at the unit layer, through
bin/omi-heavy run --no-priority -- nice -n 19 bash test.shwithBACKEND_UNIT_TEST_FILE_LIST:tests/unit/test_sync_minimal_redrive.py: 50 passed. It covers:'minimal'is honoured) and the kill-switch defaults;redrive_modeaccepted as an optional task payload key;ProviderUnavailableraised fromprocess_segmentand re-raised by the coordinator as a retryable task failure, with no finalize;get_prerecorded_serviceand Modulate never called;sync_minimal_provider_unavailablereason code survivingsync_failure_from_exceptionas retryable;target_idreachingingest_sync_conversation, and no attach on the normal path;redrive_mode, with the normal coordinator path unchanged.test_omi_qos_tiers,test_llm_gateway_coverage_guardrails,test_llm_gateway_config,test_dream_routing,test_generated_compute_inventory_guardrails,test_reserved_capacity_only,test_firestore_query_shapes,test_firestore_outside_query_contract,test_check_conversation_lifecycle_writes,test_sync_merge_target_selection,test_sync_cap_recovery_dispatch_signal,test_sync_reprocess_coalesce,test_sync_silent_failure,test_phone_batch_process_now,test_sync_geolocation_enrichment,test_sync_v2,test_sync_cloud_tasks,test_sync_transcription_prefs,test_sync_cap_hold,test_sync_live_overlapandtest_prerecorded_dispatch_selection.pyrightonutils/sync/pipeline.pyandutils/sync/minimal_redrive.pyreports no errors in the changed code.scripts/check_conversation_lifecycle_writes.pypassed.Review history
The Grok review (SCA-857) at 8c93998 returned FIX-FIRST with five findings; all are fixed in this head:
redrive_modeis now an optional task payload key.ProviderUnavailableis re-raised past the segment and gather boundaries.title_provenanceand keeps the storeddata_protection_level.Segment-level Parakeet runtime errors, as opposed to an unservable language, keep the normal partial-failure path. That path releases the content claim, so the operator can redrive again.
Line-count exceptions
Line-Count-Exception: backend/database/conversations.py | 4424 -> 4435 | optional window/eligible kwargs on the existing indexed candidate query (no new query shape)
Line-Count-Exception: backend/routers/sync.py | 3820 -> 3827 | parse redrive_mode and the kill-switch refusal at the task boundary; logic lives in utils/sync/minimal_redrive.py
Line-Count-Exception: backend/utils/sync/pipeline.py | 3592 -> 3617 | thread redrive_mode through the coordinator and process_segment seams; logic lives in utils/sync/minimal_redrive.py
Rollback
Set
SYNC_MINIMAL_REDRIVE_ENABLED=falseto refuse minimal payloads retryably, or revert the PR. Normal sync never reads the new mode.🤖 Generated with Claude Code