Skip to content

fix(backend): mobile conversations never lose extracted tasks to Candidate review - #12014

Merged
mdmohsin7 merged 1 commit into
mainfrom
fix/mobile-task-capture-visibility
Aug 21, 2026
Merged

mdmohsin7 merged 1 commit into
mainfrom
fix/mobile-task-capture-visibility

Conversation

@mdmohsin7

@mdmohsin7 mdmohsin7 commented Aug 21, 2026 •

Copy link
Copy Markdown
Member

Problem

A user reported action items appearing inside conversations but never on the Tasks page. Their account (uid redacted) had 3 conversations from Aug 20 with 6 extracted action items, 0 rows in action_items, and 0 documents in candidates — the items existed only on the conversation documents.

Since 5724a10084 ("feat: converge universal memory and task authority", Aug 11) capture_enabled() returns bool(uid), so every conversation's action items route through the Candidate lifecycle. That exposed two defects fleet-wide.

1. Negative segment offsets abort the whole save, silently

Segment offsets are relative to conversation start, and audio-merge arithmetic lands them below zero — -1.8e-07 routinely, -17.33s when a synced file predates the conversation. EvidenceRef pins start_seconds/end_seconds to ge=0, so building evidence raised ValidationError.

That call is the first statement of _save_action_items, so the compatibility writer below it never ran either: the conversation produced no task at all. Nothing reads the postprocess_executor Future, so the traceback was discarded — no log line, no metric, no error.

Replaying the reporter's three conversations through the adapter reproduces it on every one:

ValidationError: 1 validation error for EvidenceRef
start_seconds  Input should be greater than or equal to 0 [input_value=-17.329691410064697]
  at conversation_capture.py:92 in _capture_decision

2. A pending_candidate create is invisible to every client except macOS

Items at policy tier pending_candidate (a direct_request or a lower-confidence clear_commitment) are written to candidates/ and wait for review. A task row only exists once a Candidate is accepted. The only client that reads the Candidate review surface is the macOS app (/v1/staged-tasks, /v1/candidates?surface=suggested); the Flutter app only calls GET /v1/action-items. On mobile, "pending review" means "discarded, forever".

Blast radius

Read-only audit of 44 recently active users over 3 days — 234 conversations with extracted action items (302 items):

outcome conversations items
reached Tasks (compatibility writer) 126 264 visible
reached Tasks (Candidate accepted) 58
wrote nothing (defect 1) 25 30 lost
pending-only (defect 2) 25 34 hidden

21% of conversations with action items produced tasks the user could never see.

Change

  • _evidence_seconds clamps evidence offsets to zero. Evidence offsets are absolute positions in the recording, so a marginally negative merge artifact is a floor, not a validation error.
  • Conversation-surface create proposals resolve on capture instead of parking. Mutations of an existing task (update/complete) still require explicit review, so nothing silently edits or completes a task the user already has.
  • _save_action_items falls back to the compatibility writer when the capture adapter raises, and records the fallback (record_fallback) instead of dropping the conversation's tasks.
  • prepare_wake_word_capture_gate (Recognize Hey Omi task commands at conversation finalization #11980, landed while this was open) is fenced the same way. It runs an LLM adjudication ahead of the compatibility writer, so a provider error there drops the conversation's tasks by exactly the mechanism this PR exists to remove; on failure capture proceeds ungated, which is the no-wake-word-detected path. The call stays above the empty-extraction return so its task_command_without_extraction metric still fires.
  • submit_with_context logs background-task exceptions. Callers overwhelmingly discard the Future; that is why this class of failure ran for ten days without a single log line.

Product invariants

  • INV-MEM-4 — canonical promotion remains the sole Long-term authority. This change does not alter promotion or memory admission; it only decides whether a task Candidate waits for a review surface the client does not have.

Verification

python -m pytest tests/unit/test_backend_candidate_capture.py -q   # rebased onto main
37 passed, 8 warnings in 2.25s

New regressions, all of which fail on main:

  • test_capture_survives_negative_segment_offsets — the reporter's real offsets (-17.329691410064697, -1.8e-07) produce evidence clamped to 0.0 instead of raising.
  • test_pending_tier_create_is_accepted_so_the_task_is_visible — asserts the tier is still pending_candidate and that capture accepts it anyway.
  • test_task_mutation_still_waits_for_review — an update targeting an existing task creates a Candidate and is not accepted.
  • test_capture_exception_falls_back_to_the_compatibility_writer — a raising adapter still writes the action item rows and emits the fallback event.

Two existing tests were updated, both harness-only:

  • test_conversation_capture_resolves_every_create_without_notifications (renamed from test_read_mode_creates_pending_and_silently_accepts_commitment_without_notifications) asserts the new contract — this behavior change is the fix, justified by the production evidence above, not by a rewritten expectation.
  • test_repeated_descriptions_use_semantic_occurrences_without_order_dependent_candidate_keys now stubs accept_candidate; it stubbed only create_candidate and reached real Firestore once creates began accepting. Its assertions are unchanged.

Not in this PR

Recovery of already-affected accounts is forward-only here. Two backfills are needed and are prod writes, tracked separately: reprocessing conversations that wrote nothing, and accepting pending conversation-surface create Candidates for clients with no review surface.

Line-Count-Exception: backend/utils/conversations/process_conversation.py | 2375 -> 2403 | both fences must wrap their calls in place; moving the task writer out of its coordinator mid-incident would be a larger change than the fix

Failure-Class: FC-derived-state-gate-without-legacy-source-path

…idate review

Two defects made conversation action items vanish from the Tasks page after
capture went universal (5724a10 flipped capture_enabled to every uid):

1. Segment offsets are relative to conversation start and audio-merge arithmetic
   lands them below zero (-1.8e-07 routinely, -17.3s when a synced file predates
   the conversation). EvidenceRef pins start_seconds/end_seconds to ge=0, so the
   adapter raised ValidationError. It raises from the first statement of
   _save_action_items, so the compatibility writer never ran either and the
   conversation produced no task at all — silently, because nothing reads the
   postprocess Future.
2. A create proposal at policy tier 'pending_candidate' waits for review, and the
   only client that reads the Candidate review surface is macOS. On mobile the
   task was written to candidates/ and never projected anywhere visible.

Fixes: clamp evidence offsets to zero; accept every conversation-surface create
on capture, leaving only mutations of existing tasks (update/complete) for
review; fall back to the compatibility writer when the adapter raises; and log
background-task exceptions so an executor failure is never silent again.

Prod evidence (uid redacted, reported by a user): 3 conversations, 6 extracted
items, 0 rows in action_items, 0 candidates. Replaying those conversations
through the adapter reproduces the ValidationError on every one. A read-only
audit of 44 recently active users over 3 days: 234 conversations with extracted
items, of which 25 wrote nothing (30 items lost) and 25 parked pending-only
(34 items hidden) — 21% of conversations.

Verification: python -m pytest tests/unit/test_backend_candidate_capture.py -q
-> 22 passed, including the four added regressions (negative offsets, pending
create acceptance, mutations still gated, adapter-raise fallback).

Failure-Class: FC-derived-state-gate-without-legacy-source-path
@mdmohsin7
mdmohsin7 force-pushed the fix/mobile-task-capture-visibility branch from f5c7554 to 9068c47 Compare August 21, 2026 17:55
@mdmohsin7
mdmohsin7 merged commit c0e97b3 into main Aug 21, 2026
40 checks passed
@mdmohsin7
mdmohsin7 deleted the fix/mobile-task-capture-visibility branch August 21, 2026 18:33
cursor Bot pushed a commit that referenced this pull request Aug 23, 2026
Conflicts were in conversation capture (#12014 auto-accept + writer
fallback vs INV-TASK-2 propose-only), the candidate-capture tests,
and ConversationDetailView (#12042 summary sections vs Add to Tasks).

Keep INV-TASK-2: extraction never accepts or writes a task. Keep
#12014's evidence clamp and #11980's wake-word gate. Keep both
summary sections and the suggestion-only action-item rows.

Wake-word fixture scoring now treats policy_capture_kind ==
explicit_command as the command-admitted signal (create_direct is gone).

Co-authored-by: David Zhang <[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