Repository navigation
Description
The sync endpoint (POST /v1/sync-local-files) has zero subscription checks, zero rate limiting, and zero fair-use tracking. Non-subscribers are uploading bulk audio and triggering the full LLM processing pipeline at our cost.
Current Behavior
- Any authenticated user can call
/v1/sync-local-filesunlimited times with no subscription check. - Each upload triggers 8-9 LLM calls per audio segment via
process_conversation(): structured extraction (gpt-5.1), action items (gpt-5.1), memories, trends, goals, folder assignment, app suggestion + execution, embeddings. - The same LLM pipeline runs for sync as for real-time recording, but sync has none of the gates that real-time has.
Expected Behavior
Sync should enforce the same plan limits and fair-use rules as real-time recording, with logging to distinguish the source.
Solution: Treat Sync the Same as Real-Time
Principle: sync audio costs the same to process as real-time audio — same plan limits, same fair-use pool, just log the source.
Phase 1 — Pre-check gate (top of endpoint, before any processing):
has_transcription_credits(uid)→ 402 if monthly limit reachedis_hard_restricted(uid)→ 429 if fair-use restrictedrate_limit_dependency(endpoint="sync_local_files", requests_per_window=20, window_seconds=3600)- Cost: one Firestore read + one Redis read. Blocks over-limit users with zero wasted compute.
Phase 2 — Fair-use recording (after VAD, before Deepgram):
- Calculate total speech duration from VAD segments
- Call
record_speech_ms(uid, total_speech_ms, source='sync')— same Redis buckets as real-time, same rolling windows (daily 2h, 3-day 8h, weekly 10h) - Check
check_soft_caps(uid)and trigger classifier if needed - Source='sync' is logged for traceability but does NOT create separate enforcement
Phase 3 — Usage recording (after processing completes):
- Call
record_usage(uid, transcription_seconds, speech_seconds)— same subscription budget as real-time
Why shared pool is correct:
- Cost to Omi is identical regardless of ingestion path
- Separate pools would let abusers double their effective free tier by splitting load
- The LLM classifier already detects bulk non-personal patterns (audiobook chapters, podcast episodes) from conversation metadata — works for sync-created conversations identically since they go through the same
process_conversation()
Affected Areas
| File | Line | Change |
|---|---|---|
backend/routers/sync.py |
706 | Add has_transcription_credits + is_hard_restricted pre-check |
backend/routers/sync.py |
~747 | After VAD segments, record speech_ms with source='sync' + check soft caps |
backend/routers/sync.py |
after processing | Call record_usage for subscription tracking |
backend/utils/fair_use.py |
record_speech_ms |
Add source: str = 'realtime' param, add log line for traceability |
No changes needed to: subscription.py, fair_use_classifier.py, Redis schema, Firestore schema.
by AI for @beastoin
Activity
beastoin commentedon Mar 20, 2026
Update from @anthropic-yuki (fair-use system author):
The fair-use system is designed around continuous speech-hour tracking with rolling windows and LLM classification — it does NOT cover sync API and shouldn't be extended to cover it. Sync uploads are a different pattern (file-based, bursty, storage+LLM cost driven vs transcription cost driven).
Revised recommendation: separate Redis-based daily limiter for sync, reusing the daily budget pattern from
record_dg_usage_ms()/is_dg_budget_exhausted()infair_use.py— sameINCRBY + midnight TTLpattern, tracking bytes or minutes instead of ms.Updated proposal:
sync_budget:{uid}:{YYYYMMDD}, INCRBY audio duration after VAD, TTL to midnight UTCThis is simpler than integrating with fair-use and more appropriate for the bursty file-upload pattern.
by AI for @beastoin
Batch DG usage Redis writes every 60s instead of per-chunk (#5854)
Add unit tests for DG usage batching (#5854)
Update test_fair_use_api to match batched DG usage pattern (#5854)
Batch DG usage Redis writes every 60s instead of per-chunk (BasedHard…
Add unit tests for DG usage batching (BasedHardware#5854)
Update test_fair_use_api to match batched DG usage pattern (BasedHard…