Skip to content

feat(sync): operator minimal redrive mode for preserved legacy audio - #22503

Merged
Git-on-my-level merged 9 commits into
mainfrom
lane/onthway-minimal-redrive
Oct 19, 2026
Merged

Git-on-my-level merged 9 commits into
mainfrom
lane/onthway-minimal-redrive

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

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 existing create_sync_job → claim_sync_content → register_job → uid_sequencer.kick path at near-zero cost. A stored Cloud Tasks payload carrying redrive_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.py and utils/sync/pipeline.py only thread the mode through.

  1. STT: Parakeet only. The coordinator and process_segment pin ('parakeet', <lang>, 'parakeet') through the existing selected_service seam 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 reason sync_minimal_provider_unavailable: a typed ProviderUnavailable is re-raised past the segment and gather boundaries, so the task handler's retry / failed_final path 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.
  2. Attach first. Before temporal assignment, minimal mode looks for the closest compatible row of the same owner that overlaps the segment or lies within 10 minutes of it. Compatible means live_overlap.compatible_capture (source, device, lock partition), not deleted, not merged away, and status completed. The lookup reuses the existing indexed get_closest_conversation_to_timestamps query shape: a new keyword window_seconds (default 120, unchanged for normal traffic) and an in-memory eligible post-filter. No new index or query shape is added, and the query-driver registry classifies both parameters. The match goes to lifecycle.ingest_sync_conversation as an explicit target_id, so assign_sync_conversation still 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.
  3. Minimal post-processing. _reprocess_merged_conversations is replaced by minimal_redrive.finalize:
    • Updated rows keep the intake append, with no LLM call and no derived effects.
    • Each newly created row (kept, not discarded, not already titled) gets exactly one sync_redrive_title call returning a title and a 1–2 sentence overview. It is persisted as a partial structured merge through lifecycle.persist_processed_conversation under the sync_content_revision fence. That write clears the stale structured.title_provenance, so the generated title is no longer treated as the disposable server minimum, and it keeps the row's stored data_protection_level. The call runs in a copied context with BYOK keys cleared, so it always uses the company gpt-5-nano lane and never a user's own key or model.
    • If that call fails, the deterministic minimum already stored at intake stays (build_deterministic_minimum_structured, zero LLM).
    • No memories, action items, apps or integrations, goals, folders, vector upserts, webhooks or notifications.
  4. Task payload. redrive_mode is 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.
  5. Audit. Completion still goes through mark_sync_content_completed and legacy completion convergence. The final job and ledger result records redrive_mode: 'minimal'; the client SyncLocalFilesResultResponse drops unknown keys, so clients never see it. A repeat finds the row already titled (or the ledger already complete) and does no new work.
  6. Kill switch. SYNC_MINIMAL_REDRIVE_ENABLED is on unless set to false/0/off. When off, a minimal payload is refused with a retryable 409 in run_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 in config/feature-flags.yaml, and backend/docs/feature-flag-registry.md was regenerated as of 2026-10-19.

Model (approved by David 2026-10-19 ~14:55Z): the title uses a new model_config feature, sync_redrive_title, on gpt-5-nano with gateway reasoning_effort: minimal, the cheapest managed lane. gemini-2.5-flash-lite is not allowed for managed traffic (test_omi_qos_tiers.py, vertex_pt_routing.py). David approved gpt-5-nano for 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

  • Attach also requires status == 'completed' and no sync_merged_into, so it never appends into an open live row or a merge donor. This is stricter than "not deleted".
  • The 10-minute attach can chain: each segment of a job can attach to the row the previous segment created, so segments with gaps of up to 10 minutes join one conversation. This is the intended attach-first behaviour.
  • Attach is skipped for segments that already carry an explicit target or a recording-lineage binding; those keep their planned target.
  • process_segment gains 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 in minimal_redrive.py.
  • generate_title imports get_llm lazily, 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.
  • Kill switch: 409, not 503, so a disabled operator lane does not read as queue-wide overload (same reasoning as the existing backfill-pressure deferral).
  • Speaker identification, private-cloud audio finalization and voice-learning scheduling are unchanged. They use internal services, not paid vendors.
  • Audio that cap dispatch holds mid-job is later recovered by the normal cap-recovery path, not in minimal mode. Production cap enforcement is off.

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.sh with BACKEND_UNIT_TEST_FILE_LIST:

  • tests/unit/test_sync_minimal_redrive.py: 50 passed. It covers:
    • payload parsing (only 'minimal' is honoured) and the kill-switch defaults;
    • the router kill switch refusing before the sequencer lease or any lock or pipeline work, on both the direct and the sequenced path, while a normal payload is never refused;
    • redrive_mode accepted as an optional task payload key;
    • ProviderUnavailable raised from process_segment and re-raised by the coordinator as a retryable task failure, with no finalize;
    • the title call seeing no BYOK keys while the caller's context keeps them;
    • Parakeet pinned with get_prerecorded_service and Modulate never called;
    • a double empty recorded as silence with no recovery call, while the normal path still recovers;
    • the sync_minimal_provider_unavailable reason code surviving sync_failure_from_exception as retryable;
    • attach to a compatible row 5 min away against the real query builder (±600 s bound); no attach for another device, a locked or deleted row, a merged donor or a live row; an incompatible closer row not hiding a compatible one; the normal query keeping ±120 s;
    • the explicit target_id reaching ingest_sync_conversation, and no attach on the normal path;
    • finalize making one LLM call and a title-only lifecycle persist for a new row (title, overview, cleared provenance and the stored protection level), zero calls for updates, no work on repeats, deleted or review rows, and an LLM failure keeping the deterministic minimum with no write;
    • the coordinator pinning the provider, replacing post-processing and recording redrive_mode, with the normal coordinator path unchanged.
  • Also green: 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_overlap and test_prerecorded_dispatch_selection.
  • pyright on utils/sync/pipeline.py and utils/sync/minimal_redrive.py reports no errors in the changed code.
  • scripts/check_conversation_lifecycle_writes.py passed.
  • Not run locally: the full suite. It goes to m1 preflight and CI.
  • Not run at all: live behaviour (no credentials, no prod). Nothing is deployed or enabled by this PR. The mode only acts on operator payloads.

Review history

The Grok review (SCA-857) at 8c93998 returned FIX-FIRST with five findings; all are fixed in this head:

  1. redrive_mode is now an optional task payload key.
  2. ProviderUnavailable is re-raised past the segment and gather boundaries.
  3. The kill switch runs before the sequencer lease.
  4. The title call is pinned to the company lane with BYOK cleared.
  5. The title persist clears title_provenance and keeps the stored data_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=false to refuse minimal payloads retryably, or revert the PR. Normal sync never reads the new mode.

🤖 Generated with Claude Code

Git-on-my-level and others added 3 commits October 19, 2026 20:53
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]>
@chatgpt-codex-connector

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 ⚠️ Failed 2026-10-19T14:24:42.167595Z 8c93998 PR opened
ℹ️ 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

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@cursor cursor 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.

Agentic security review completed for this head. One medium finding: minimal redrive attach-first can force a non-mergeable shared or public conversation as an explicit assignment target.

Open in Web View Automation 

Sent by Cursor Security Agent: Security Reviewer

Comment on lines +113 to +119
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'
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 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.

Fix in Cursor Fix in Web

Reviewed by Cursor Security Reviewer for commit 8c93998. Configure here.

Git-on-my-level and others added 6 commits October 19, 2026 21:44
- 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]>
@Git-on-my-level
Git-on-my-level merged commit 098b971 into main Oct 19, 2026
59 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/onthway-minimal-redrive branch October 19, 2026 20:56
Git-on-my-level added a commit that referenced this pull request Oct 20, 2026
… 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]>
Git-on-my-level added a commit that referenced this pull request Oct 20, 2026
…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]>
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