Conversation
…gates (#…" This reverts commit f592c25.
Greptile SummaryThis PR reverts #5863 ("Sync: fair-use tracking with lock-on-exhaustion and soft cap gates"), removing the fair-use enforcement gates that were added to the Key changes:
Notable concern: The session-end flush of Confidence Score: 4/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["POST /v1/sync-local-files"] --> B["Decode & VAD segment files"]
B --> C["process_segment per path"]
C --> D{"Closest existing\nconversation?"}
D -- Yes --> E["Update conversation\nsegments & timestamps"]
D -- No --> F["Create new conversation\nvia process_conversation"]
E --> G["Return updated/new\nmemory IDs"]
F --> G
subgraph "REVERTED (was in #5863)"
R1["is_hard_restricted check → 429"]
R2["should_lock = not has_transcription_credits"]
R3["record_speech_ms(uid, speech_ms, source='sync')"]
R4["check_soft_caps + trigger_classifier"]
R5["is_locked=True on CreateConversation"]
R6["record_usage(uid, transcription_seconds=...)"]
end
subgraph "transcribe.py — restored batching (#5854)"
T1["Audio chunk received"]
T1 --> T2["dg_usage_ms_pending += chunk_ms\n(DG / Soniox / Speechmatics)"]
T2 --> T3{"60 s timer fires?"}
T3 -- Yes --> T4["record_dg_usage_ms(uid, pending)\npending = 0"]
T3 -- No --> T5{"Session end\n(finally block)?"}
T5 -- "use_custom_stt=False" --> T4
T5 -- "use_custom_stt=True\n&& session < 60s" --> T6["⚠️ usage DROPPED"]
end
|
| # Flush pending DG usage accumulator (#5854) | ||
| if FAIR_USE_ENABLED and FAIR_USE_RESTRICT_DAILY_DG_MS > 0 and dg_usage_ms_pending > 0: | ||
| record_dg_usage_ms(uid, dg_usage_ms_pending) | ||
| dg_usage_ms_pending = 0 |
There was a problem hiding this comment.
dg_usage_ms_pending not flushed for use_custom_stt sessions shorter than 60 s
The session-end flush of dg_usage_ms_pending is nested inside if not use_custom_stt and last_usage_record_timestamp:. However, the Soniox and Speechmatics code paths in flush_stt_buffer both accumulate into dg_usage_ms_pending regardless of whether use_custom_stt is True.
This means:
- For sessions using Soniox or Speechmatics where
use_custom_stt=Trueand the session ends before the 60 s periodic flush fires, any accumulateddg_usage_ms_pendingis silently discarded and never written to Redis. - The periodic flush (line ~438) is intentionally placed before the
use_custom_sttguard with a comment# Placed before use_custom_stt guard so all STT paths get flushed— the session-end flush is missing the same treatment.
A straightforward fix is to move the dg_usage_ms_pending flush outside the if not use_custom_stt block, mirroring the periodic flush's intent:
# Flush pending DG/STT usage accumulator (#5854) — covers all STT paths
if FAIR_USE_ENABLED and FAIR_USE_RESTRICT_DAILY_DG_MS > 0 and dg_usage_ms_pending > 0:
record_dg_usage_ms(uid, dg_usage_ms_pending)
dg_usage_ms_pending = 0
if not use_custom_stt and last_usage_record_timestamp:
...
Reverts #5863