Skip to content

Harden phone capture against silent audio loss - #20902

Merged
Git-on-my-level merged 9 commits into
BasedHardware:mainfrom
Git-on-my-level:lane/audio-loss-hardening
Oct 7, 2026
Merged

Git-on-my-level merged 9 commits into
BasedHardware:mainfrom
Git-on-my-level:lane/audio-loss-hardening

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

What changed and why

Hardens the never-lose-audio paths on the phone:

  • Capture liveness watchdog: while the coordinator believes capture is
    live, a watchdog now detects "socket down or no audio frames flowing" and
    forces recovery at a WAL boundary instead of silently continuing to
    believe audio is being captured.
  • Stale-WAL reconciliation: local WALs stuck in miss past a threshold
    are reported at startup/foreground instead of only retrying silently, so
    uploads that never land are visible.
  • Calendar capture-gap monitor: while a calendar meeting the user is
    attending is active and capture is not owning, the app records a
    capture-gap signal through the existing calendar capture telemetry —
    post-capture visibility, not the conversation-list placeholders removed
    in Remove the not-captured calendar gap UI from conversations #20884.
  • Backend loss accounting: conversation finalize emits a counter with
    capture_evidence.coverage and covered-span vs wall-span seconds, so
    partial captures are countable in metrics.

Why

A real 120-minute meeting produced zero server-side audio for its first 70
minutes (device made no server contact), and nothing in the product noticed.
The server cannot transcribe audio it never receives, so the fix is at the
capture client: notice silence-while-live, surface not-owning-during-meeting,
and account for partial coverage server-side.

Failure-Class

Failure-Class: none

Product invariants affected

  • INV-CAP-1 — this PR's diff touches app/lib/services/capture/** and
    app/lib/services/wals/**. It adds no pause, unsubscribe, or fence: the
    watchdog only forces recovery (WAL finalize + new session) when frames
    have already stopped flowing, and the gap monitor is telemetry-only.
    Every audio frame captured still reaches the socket or a durable WAL
    write; nothing discards frames.
  • INV-MEM-4 — backend/utils/conversations/process_conversation.py is in
    its path globs. The change adds a telemetry emission next to finalization;
    it does not create an intake route, promote, archive, or fast-track any
    memory, and canonical intake routing is untouched.
  • INV-TASK-2 — backend/utils/conversations/process_conversation.py is in
    its path globs. The change adds no capture proposal surface; task
    suggestion policy and its Suggested surfaces are untouched.

Line-Count-Exception

Line-Count-Exception: app/lib/services/capture/capture_controller.dart | 4081 -> 4211 | watchdog state hooks, suspension invalidation and socket-aware recovery callbacks; split deferred to the #9838 follow-up
Line-Count-Exception: app/lib/services/capture/capture_coordinator.dart | 2842 -> 2932 | watchdog wiring, socket-aware recovery dispatch and suspension-gap tracking
Line-Count-Exception: app/lib/services/wals/local_wal_sync.dart | 2576 -> 2636 | stale-miss reporting and reconciliation on startup and foreground
Line-Count-Exception: backend/utils/conversations/process_conversation.py | 3574 -> 3577 | three-line coverage counter emission at conversation finalize

Test plan

  • app: capture/watchdog/WAL-stale suites — 138 spine + 412 affected tests
    pass (coordinator re-runs the load-bearing subset before review)
  • backend: tests/unit/test_capture_loss_accounting.py — 14 passed

UI-Evidence

UI-Evidence: none -- no user-visible surface changed in this PR; the gap monitor is telemetry-only and recovery is behavior-preserving at equal UX.

Known limitations

  • The watchdog detects loss while the app runs; a killed/backgrounded app
    before capture starts is covered by the calendar gap monitor's signal,
    not prevention — prevention (meeting-aware capture nudge) is a follow-up.
  • Backend counter is in-process until scraped; no dashboard yet.

Review round 1 fixes (grok REQUEST CHANGES → addressed)

  • P1: calendar gap polling now only fires for locally known uncaptured meetings (from cached calendar-list responses), with 60s→10min exponential backoff — zero steady-state polling when no meeting is imminent or capture is owning (b92a4d2).
  • P2: liveness failures now carry the observed wall-gap and are invalidated across app suspension; onAppResumed clears pending failures before the reducer can apply them — no mid-sentence mic stop after screen lock (0f58880).
  • P2: recovery branch chosen from current socket readiness at check time; socket-down prefers reconnect, and a keepalive-restored socket discards a queued failure instead of restarting the mic (f9e1475).
  • P3: finalize accounting test now exercises the internal Pydantic CaptureEvidenceMetadata path (faf763f).

@Git-on-my-level
Git-on-my-level merged commit 633a466 into BasedHardware:main Oct 7, 2026
52 of 53 checks passed
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