Skip to content

[codex] Propagate private cloud sync through file sync - #7894

Merged
Git-on-my-level merged 10 commits into
BasedHardware:mainfrom
tianmind-studio:codex/sync-private-cloud-audio-metadata
Jun 28, 2026
Merged

Git-on-my-level merged 10 commits into
BasedHardware:mainfrom
tianmind-studio:codex/sync-private-cloud-audio-metadata

Conversation

@tianmind-studio

@tianmind-studio tianmind-studio commented Jun 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add private_cloud_sync_enabled to CreateConversation and propagate the user's private-cloud setting through v1/v2 file sync segment processing.
  • Preserve the current main-branch private-cloud chunk storage behavior while forwarding data-protection metadata and finalizing v1 audio metadata after chunk upload.
  • Cover the new conversation creation path, v1 private-cloud/data-protection wiring, and v2 background forwarding path with unit tests.
  • Refresh sync v2 test fixtures to use timestamp-shaped segment paths and align the storage executor worker-count assertion/docs with the current 128-worker config.
  • Harden the related sync/conversation tests for Windows/lightweight local runs by stubbing optional SDK imports and avoiding a real multipart parser dependency where the test only needs to exercise the endpoint coroutine.

Current status

  • Rebased on main at cc06c20fae75e88b15e220d57402f6f47591dd72.
  • Current head: 962e7f6f55b6856cddab89aca86fcb9266c9d1c0.
  • GitHub compare reports this branch as ahead 10 / behind 0; PR is mergeable.

Validation

  • From backend/: D:\codex-omi-work\.venvs\omi-backend-vad-refresh\Scripts\python.exe -m pytest tests\unit\test_sync_transcription_prefs.py tests\unit\test_sync_v2.py tests\unit\test_conversation_model_split.py tests\unit\test_sync_silent_failure.py tests\unit\test_sync_cloud_tasks.py -q --tb=short
    • 329 passed, 28 warnings
  • D:\codex-omi-work\.venvs\omi-backend-vad-refresh\Scripts\python.exe -m py_compile models\conversation.py routers\sync.py tests\unit\test_sync_transcription_prefs.py tests\unit\test_sync_v2.py tests\unit\test_conversation_model_split.py tests\unit\test_sync_silent_failure.py
  • D:\codex-omi-work\.venvs\omi-backend-vad-refresh\Scripts\python.exe -m black --line-length 120 --skip-string-normalization --check models\conversation.py routers\sync.py tests\unit\test_sync_transcription_prefs.py tests\unit\test_sync_v2.py tests\unit\test_conversation_model_split.py tests\unit\test_sync_silent_failure.py
    • 6 files would be left unchanged
  • PYTHONUTF8=1 D:\codex-omi-work\.venvs\omi-backend-vad-refresh\Scripts\python.exe backend\scripts\scan_async_blockers.py
    • exit 0; existing async-blocker backlog reported, no new sync.py blocker
  • git diff --check origin/main...HEAD
  • scripts/pre-commit with the backend Windows venv and local Dart SDK on PATH

Not run

@greptile-apps

greptile-apps Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR closes a gap where conversations created through file sync (both v1 and v2 paths) were always written with private_cloud_sync_enabled=False, causing audio files to never be assembled from chunks for those conversations regardless of the user's setting.

  • CreateConversation model gains private_cloud_sync_enabled: bool = False; because _get_conversation_obj expands CreateConversation via **conversation.dict(), the field is carried through automatically to the stored Conversation and reaches the audio-file-assembly check in process_conversation.py.
  • sync_local_files (v1) and _run_full_pipeline_background_async (v2) each add a single run_blocking DB call to fetch the user's setting before dispatching segments, then forward it as a keyword argument to every process_segment call; run_blocking already accepts **kwargs so no wrapper changes were needed.
  • Tests cover the new conversation creation path (behavioral unit test) and the v2 background-worker forwarding path (static source inspection + behavioral test); mock signatures are also hardened to accept **kwargs so future signature additions won't silently break those stubs.

Confidence Score: 4/5

Safe to merge; the change adds a single DB read per sync request and threads a boolean flag through an already-established parameter chain with no side-effects on the merge path.

The propagation chain is complete and verified — CreateConversation carries the field, _get_conversation_obj expands it via **dict(), and process_conversation acts on it. Both sync paths fetch the flag before spawning segments and pass it consistently. The only missing coverage is a structural or behavioral test for the v1 sync_local_files path analogous to the v2 tests added here, but the code itself is correct.

No files require special attention; backend/routers/sync.py is the most complex changed file and its two new DB-fetch sites follow the established pattern for transcription_prefs.

Important Files Changed

Filename Overview
backend/models/conversation.py Adds private_cloud_sync_enabled: bool = False to CreateConversation; the field correctly propagates via **conversation.dict() expansion in _get_conversation_obj.
backend/routers/sync.py Adds one DB call per request in both the v1 and v2 paths to fetch private_cloud_sync_enabled, then passes it to every process_segment invocation; run_blocking correctly supports **kwargs.
backend/tests/unit/test_sync_transcription_prefs.py Adds a utils.cloud_tasks stub (needed for the extended import surface) and a behavioral test verifying private_cloud_sync_enabled=True is carried into CreateConversation.
backend/tests/unit/test_sync_v2.py Adds static-source and behavioral tests for the v2 background worker; updates segment path fixtures to timestamp format and fixes mock signatures to accept **kwargs; aligns executor assertion to 128 workers.
backend/AGENTS.md One-line docs update: storage_executor worker count corrected from 96 to 128 to match the actual executor configuration.

Sequence Diagram

sequenceDiagram
    participant Client
    participant sync_local_files as sync_local_files (v1)
    participant bg as _run_full_pipeline_background_async (v2)
    participant db_executor
    participant users_db
    participant process_segment
    participant process_conversation

    Client->>sync_local_files: POST /v1/sync/file
    sync_local_files->>db_executor: get_user_transcription_preferences(uid)
    db_executor->>users_db: fetch prefs
    sync_local_files->>db_executor: get_user_private_cloud_sync_enabled(uid)
    db_executor->>users_db: fetch flag
    Note over sync_local_files: private_cloud_sync_enabled = bool(result)
    sync_local_files->>process_segment: "process_segment(..., private_cloud_sync_enabled=flag)"
    process_segment->>process_conversation: "CreateConversation(private_cloud_sync_enabled=flag)"
    process_conversation-->>process_segment: "Conversation (audio files assembled if flag=True)"

    Client->>bg: POST /v2/sync/file (background)
    bg->>db_executor: get_user_transcription_preferences(uid)
    bg->>db_executor: get_user_private_cloud_sync_enabled(uid)
    Note over bg: private_cloud_sync_enabled = bool(result)
    bg->>process_segment: "process_segment(..., private_cloud_sync_enabled=flag)"
    process_segment->>process_conversation: "CreateConversation(private_cloud_sync_enabled=flag)"
    process_conversation-->>process_segment: "Conversation (audio files assembled if flag=True)"
Loading

Reviews (1): Last reviewed commit: "Document storage executor worker count" | Re-trigger Greptile

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Backend feature (propagate private cloud sync through file sync) — approve only per policy.

@tianmind-studio
tianmind-studio force-pushed the codex/sync-private-cloud-audio-metadata branch 2 times, most recently from fd5ff52 to 7ae9883 Compare June 17, 2026 08:10

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Propagate private cloud sync through file sync — approve only (re-approve)

@tianmind-studio
tianmind-studio force-pushed the codex/sync-private-cloud-audio-metadata branch from 7ae9883 to 962e7f6 Compare June 23, 2026 06:30

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-approved on new commits; approve-only per area policy. (auto-review)

@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks @tianmind-studio — nice catch on the v1 gap here.

Verified against current main (2b25e5c): the v2 background path (_run_full_pipeline_background_async) already wires private_cloud_sync_enabled + data_protection_level and calls _finalize_sync_audio_files (landed in #7981, commit 196a460). So the v2 portions of this diff are effectively no-ops against main now — the bool() wrapper and keyword-arg style are harmless consistency tweaks, just flagging so you know that work already shipped.

The genuinely valuable parts are the v1 sync_local_files wiring and the CreateConversation.private_cloud_sync_enabled field + process_segment forwarding — these close the v1 file-sync inconsistency with realtime/v2. Only Conversation had the field before; CreateConversation did not, so the v1 path could not propagate it. Good call.

The AGENTS.md worker-count correction (96w → 128w) is accurate — storage_executor is max_workers=128 in utils/executors.py.

Since this touches data-handling / private-cloud / data-protection-level propagation, I am flagging it for a security + data-handling pass before merge. No issues found on static review: settings are read via the existing trusted DB helpers and propagated correctly (data_protection_level is only fetched when private cloud is enabled, matching the v2 pattern). CI (Hermetic Backend E2E + Lint) is green.

@Git-on-my-level Git-on-my-level added security-review Touches auth, provider routing, secrets, or security-sensitive surfaces docs-accuracy Documentation or committed reports need accuracy fixes labels Jun 26, 2026

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @tianmind-studio — I did the heightened data-handling/security pass for the private-cloud sync wiring.

I’m approving this. The change is coherent and limited: it carries the existing user private-cloud setting through file sync, adds the missing CreateConversation.private_cloud_sync_enabled field so process_conversation can persist it, and only fetches data_protection_level when private-cloud sync is enabled. I don’t see new dependency/workflow risk, secret exposure, or an exfiltration path; the calls use the existing DB helpers and the final audio-file rebuild is idempotent over stored chunks.

A couple of notes for maintainers before merge:

  • The branch is based on an older main, and the v2/background-path portion already landed via #7981; after rebase, that part should mostly drop to harmless style/no-op changes.
  • The remaining valuable delta is the v1 sync_local_files path plus the CreateConversation model field and test hardening.
  • I verified a clean local merge into current main and CI is currently green on this head.

No changes requested from my side.

@Git-on-my-level
Git-on-my-level dismissed their stale review June 27, 2026 00:02

Automated approval dismissed: this PR falls into a category that should receive human maintainer/product/security judgment rather than formal auto-approval. No changes are being requested by this dismissal; prior automated feedback should be treated as an implementation review/positive signal only.

@Git-on-my-level
Git-on-my-level merged commit 4d216af into BasedHardware:main Jun 28, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs-accuracy Documentation or committed reports need accuracy fixes security-review Touches auth, provider routing, secrets, or security-sensitive surfaces

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants