Skip to content

fix(desktop): enrich from-segments uploads instead of deferring them as CAPTURE_END - #19788

Merged
undivisible merged 1 commit into
BasedHardware:mainfrom
kduailabs:fix/desktop-from-segments-enrichment
Oct 19, 2026
Merged

undivisible merged 1 commit into
BasedHardware:mainfrom
kduailabs:fix/desktop-from-segments-enrichment

Conversation

@kduailabs

@kduailabs kduailabs commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

What

Fixes #19705. macOS desktop local_segments recordings upload and land completed but get no summary, no action items, no events, empty overview, category other — the reported fingerprint.

Root cause

POST /v1/conversations/from-segments → _create_conversation_from_segments (routers/developer.py) called process_conversation(...) with no trigger, so it ran as ProcessingTrigger.CAPTURE_END (run_now=False). That let the legacy desktop capture-time deferral fire (utils/conversations/process_conversation.py:2834-2850): for source=desktop + should_defer_desktop_processing(uid) it stored _build_deferred_structured — title = first 8 transcript words, empty overview, category=other, no action items/events — and returned before _get_structured and speaker resolution.

Device sessions are exempt by source; desktop cloud_reconcile is exempt because /finalize and /v1/conversations pass CLIENT_FINALIZE (run_now=True). from-segments was the only desktop finalize entering with run_now=False — hence only these rows are empty. (language=multi, segment size, and the crash_recovery/recording_disabled reasons are bystanders; ruled out with evidence in #19783.)

Fix

Pass trigger=ProcessingTrigger.CLIENT_FINALIZE at the from-segments call sites, matching the sibling /finalize path. The client already uploaded an already-final transcript, so it should not be treated as an open capture. This does not bypass the free-tier policy gate (process_conversation.py:2760-2821, which deliberately ignores force/reprocess and remains the deny path when FREE_TIER_LOCAL_PROCESSING is on), and does not change relevance (_ASSESS) or JIT-first-open.

Product note (please confirm)

from-segments now spends at upload for desktop_free users, exactly like the desktop cloud_reconcile /finalize path already does — this makes the two desktop finalize paths consistent. If the intended freemium behaviour is that from-segments uploads also stay deferred, this is a product change, not a bug fix — instruct and I'll switch to the alternative (exempt explicit client uploads inside the gate) or withdraw.

Coordination

_create_conversation_from_segments is also touched by the open (stalled, dirty) PR #10796. Happy to rebase onto it or coordinate if it revives.

Tests

  • test_from_segments_runs_as_client_finalize_not_capture_end — asserts the call-site trigger.
  • test_free_tier_entrypoint_matrix.py — the from-segments entry now records trigger=CLIENT_FINALIZE, plus a new desktop entry so the previously-untested desktop upload cell is covered (old CAPTURE_END → legacy_defer placeholder; fixed → same behaviour as /finalize).
  • Updated the from-segments mock call sites to accept the kwarg.

Verification

test_developer_from_segments_idempotency.py (112) + test_free_tier_entrypoint_matrix.py (118) pass locally: 230/230.

Failure-Class: none

Review in cubic

Line-Count-Exception: backend/routers/developer.py | 2636 -> 2642 | pass ProcessingTrigger.CLIENT_FINALIZE at the from-segments call sites (+import +comment) so a client-uploaded final transcript is enriched instead of deferred

@kduailabs

Copy link
Copy Markdown
Contributor Author

Bounty proposal with the full analysis + evidence: #19783 ($50 proposed).

@Git-on-my-level

Copy link
Copy Markdown
Member

Verified against the tree at the head commit — the root-cause analysis in the description holds up everywhere I checked.

  • backend/routers/developer.py:2144 — passing trigger=ProcessingTrigger.CLIENT_FINALIZE here is the right fix. I confirmed process_conversation defaults to CAPTURE_END (utils/conversations/process_conversation.py:2681), whose mode has run_now=False (utils/conversations/processing_trigger.py:55), and force_process=mode.run_now (process_conversation.py:2692). Pre-PR, that left from-segments as the only desktop finalize path entering the legacy deferral elif at process_conversation.py:2834 (not force_process ... should_defer_desktop_processing), which stores the title-only placeholder and returns before enrichment — exactly the empty-overview fingerprint in macOS desktop: uploaded recordings complete with no summary, no action items and no diarization (empty overview, category 'other') — follow-up to #19328 #19705.
  • Sibling consistency confirmed: /v1/conversations create (backend/routers/conversations.py:585) and finalize via request_finalization (:670) already pass CLIENT_FINALIZE, so this brings from-segments in line rather than introducing a new behavior.
  • Free-tier gate not bypassed: the flag-on policy branch (process_conversation.py:2760-2821) decides on free_tier_local_processing_enabled(uid), source, and client projection — never on trigger — so identified-basic denies still land at the deterministic minimum, and the trial-paywall check (:2730) still short-circuits before everything.
  • One behavioral note for the record: with run_now now True, the flag-off eager-extraction gate (process_conversation.py:2859, force_process or is_reprocess) also consults this path when BASIC_PLAN_GATE_EAGER_EXTRACTION_ENABLED is on. That matches the sibling finalize paths and the flag is default-off, so no action needed — just flagging that the trigger change reaches one more gated branch than the deferral alone.
  • Tests are well aimed: test_from_segments_runs_as_client_finalize_not_capture_end pins the trigger passthrough (and the existing _process stubs were correctly widened to **kwargs), and the free-tier entrypoint matrix gains a dedicated desktop from-segments case while fixing the stale 1776 line reference to 2142.

The product note in the description (from-segments now spends at upload for desktop_free users, matching /finalize) is the one thing needing maintainer sign-off — the code is consistent with the existing desktop finalize paths, but confirming the spend-timing intent for free-tier uploads is a maintainer decision, so this is left for human review rather than automated sign-off.

Thanks for the exceptionally well-documented root-cause work — the bystander eliminations from #19783 made review straightforward.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level

Copy link
Copy Markdown
Member

Verified against the code at the current head — the root-cause analysis holds and the fix is consistent with the sibling finalize paths. File by file:

  • backend/routers/developer.py: the trigger=ProcessingTrigger.CLIENT_FINALIZE kwarg is set in the shared _create_conversation_from_segments helper, so both the developer-API-key route and the Firebase-authed /v1/conversations/from-segments route are covered by the single change. Confirmed CLIENT_FINALIZE maps to run_now=True in PROCESSING_MODES, and the legacy desktop deferral in process_conversation requires not force_process, so it no longer fires — the macOS desktop: uploaded recordings complete with no summary, no action items and no diarization (empty overview, category 'other') — follow-up to #19328 #19705 placeholder path is correctly closed.
  • backend/tests/unit/test_developer_from_segments_idempotency.py: test_from_segments_runs_as_client_finalize_not_capture_end asserts the call-site trigger through a monkeypatched process_conversation; the remaining edits are mechanical **kwargs acceptance in existing mocks.
  • backend/tests/unit/test_free_tier_entrypoint_matrix.py: the from-segments entry now records trigger=CLIENT_FINALIZE, and the new developer_from_segments_desktop cell covers the previously-untested desktop upload path.

I also verified the claim that this does not bypass the free-tier policy gate: resolve_free_tier_processing_plan explicitly discards force_process/is_reprocess when resolving the plan, so an identified-basic deny still lands at the deterministic minimum / stored projection under FREE_TIER_LOCAL_PROCESSING. And /finalize plus /v1/conversations in routers/conversations.py already pass CLIENT_FINALIZE, so from-segments was indeed the odd one out.

One nuance worth knowing (no change requested): with force_process now true on this path, the flag-off BASIC_PLAN_GATE_EAGER_EXTRACTION branch in process_conversation becomes reachable from from-segments for desktop users. It is default-off and unreachable while FREE_TIER_LOCAL_PROCESSING is on, so it is non-blocking — just something to keep in mind if that gate is ever enabled.

The remaining open point is the product question raised in the description: on the legacy flag-off path, freemium desktop from-segments uploads now spend enrichment at upload rather than deferring to first-open. That consistency call is the one thing needing a maintainer decision before merge.

Feedback is automated and sent on the maintainers' behalf; a human maintainer should confirm the freemium spend-timing decision above.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

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

9128caf45663 — backend/routers/developer.py still calls process_conversation from the segments path with no trigger, so a finished upload takes the CAPTURE_END deferral. This head sets CLIENT_FINALIZE. The test asserts that trigger. 17 checks passed, none failing.

@undivisible
undivisible merged commit bfde108 into BasedHardware:main Oct 19, 2026
58 of 61 checks passed
Git-on-my-level added a commit that referenced this pull request Oct 19, 2026
Five unit files fail on current main. Each one passed on its own PR's base
and broke when main moved underneath it; none is a product regression.

- test_request_context.py (#19738): tested the JIT budget surface that
  #22209 removed from llm_gateway/gateway/request_context.py. Keep the
  request-id tests; drop the tests for removed code.
- test_users_joan_followup_tombstone_guard.py (#19867): called
  delete_person_endpoint, but the joan followup route is
  delete_followup_question_endpoint.
- test_developer_from_segments_idempotency.py (#21265): process fakes
  rejected the trigger=CLIENT_FINALIZE kwarg the router passes since #19788.
- test_external_tools_sanitization.py (#19406): the stubbed utils package
  lacked utils.generated_compute (#21488) and utils.model_text. Stub the
  default-off gate as disabled and load the stdlib-only model_text for real.
- test_batch_upload_storage.py: the database.vector_db stub lacked
  delete_action_item_vectors_batch, which merge_conversations imports since
  #15953.

Failure-Class: none

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Git-on-my-level added a commit that referenced this pull request Oct 19, 2026
)

* fix(backend): restore pyright-clean main after #22207 and #22326

Main's backend unit shards fail the enforced pyright lane:

- database/desktop_previews.py (#22207): 16 reportUnnecessaryIsInstance
  errors. The runtime guards stay; they move into validators that take
  `object` (_payload, _string, _expected_generation, _datetime), so the
  checks are meaningful to pyright. Public signatures, error messages and
  check order are unchanged.
- utils/sync/pipeline.py:process_segment (#22326 on top of #22452):
  "code is too complex to analyze". Behaviour-neutral split: the two
  identical cap-hold defer blocks become one hold_for_cap closure, and the
  final-pass / speaker-identification block moves to
  _assign_segment_speakers with the same exception handling.

Failure-Class: none

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(backend): repair unit tests that drifted from main across merges

Five unit files fail on current main. Each one passed on its own PR's base
and broke when main moved underneath it; none is a product regression.

- test_request_context.py (#19738): tested the JIT budget surface that
  #22209 removed from llm_gateway/gateway/request_context.py. Keep the
  request-id tests; drop the tests for removed code.
- test_users_joan_followup_tombstone_guard.py (#19867): called
  delete_person_endpoint, but the joan followup route is
  delete_followup_question_endpoint.
- test_developer_from_segments_idempotency.py (#21265): process fakes
  rejected the trigger=CLIENT_FINALIZE kwarg the router passes since #19788.
- test_external_tools_sanitization.py (#19406): the stubbed utils package
  lacked utils.generated_compute (#21488) and utils.model_text. Stub the
  default-off gate as disabled and load the stdlib-only model_text for real.
- test_batch_upload_storage.py: the database.vector_db stub lacked
  delete_action_item_vectors_batch, which merge_conversations imports since
  #15953.

Failure-Class: none

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

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

backend Backend Task (python) needs-maintainer-review Needs a human maintainer to sign off before merge positive-signal Automation verified a genuine fix/quality contribution

Projects

None yet

4 participants