Repository navigation
fix(backend): mobile conversations never lose extracted tasks to Candidate review - #12014
Merged
Merged
Conversation
…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
force-pushed
the
fix/mobile-task-capture-visibility
branch
from
August 21, 2026 17:55
f5c7554 to
9068c47
Compare
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 incandidates— the items existed only on the conversation documents.Since
5724a10084("feat: converge universal memory and task authority", Aug 11)capture_enabled()returnsbool(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-07routinely,-17.33swhen a synced file predates the conversation.EvidenceRefpinsstart_seconds/end_secondstoge=0, so building evidence raisedValidationError.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 thepostprocess_executorFuture, 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:
2. A
pending_candidatecreate is invisible to every client except macOSItems at policy tier
pending_candidate(adirect_requestor a lower-confidenceclear_commitment) are written tocandidates/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 callsGET /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):
21% of conversations with action items produced tasks the user could never see.
Change
_evidence_secondsclamps 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.createproposals 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_itemsfalls 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 itstask_command_without_extractionmetric still fires.submit_with_contextlogs 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
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 to0.0instead of raising.test_pending_tier_create_is_accepted_so_the_task_is_visible— asserts the tier is stillpending_candidateand that capture accepts it anyway.test_task_mutation_still_waits_for_review— anupdatetargeting 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 fromtest_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_keysnow stubsaccept_candidate; it stubbed onlycreate_candidateand 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
createCandidates 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