Repository navigation
feat: gate desktop-pendant call groups and continuation - #21836
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 198ba10e2f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if link_mode == 'on' and ( | ||
| call_pair(own, other_row) or reserved_for_call(own) or reserved_for_call(other_row) | ||
| ): | ||
| continue |
There was a problem hiding this comment.
Preserve shared-speech grouping on saturated pages
When DESKTOP_PENDANT_CALL_LINK_MODE=on and the candidate query returns exactly 100 rows, link_call_pair deliberately refuses every new call link as saturated, but this unconditional filter also removes every qualifying desktop/pendant pair from matches. Consequently _group_confirmed_captures never applies the pre-existing shared-speech policy even when transcript evidence confirms the pair, contrary to the stated requirement that only new call links fail closed on saturation; skip the ordinary path only when the call pair is actually reserved or linked.
Useful? React with 👍 / 👎.
| ids = {a['id'], b['id']} | ||
| if any(set(r.get('capture_group_exclusions') or ()) & ids for r in (a, b)): | ||
| continue | ||
| groups = [r.get('capture_group') or {} for r in (a, b)] | ||
| if any(g.get('id') and {m['id'] for m in g.get('members', [])} != ids for g in groups): |
There was a problem hiding this comment.
Reject call pairs already pointing outside the group
If either endpoint was previously assigned external_data.duplicate_capture_of to a third conversation, this selector still admits the desktop/pendant pair because it checks only exclusions and capture groups. The join then preserves that outside pointer, while _continue_call_group explicitly rejects any group member whose pointer targets outside the member set, leaving the newly created call group unable to accept pendant continuations and carrying conflicting event relationships. Treat such endpoints as reserved or fence the pointer transactionally.
Useful? React with 👍 / 👎.
| return { | ||
| 'decisions': dict(sorted(counts.items())), | ||
| 'score_count': len(scores), | ||
| 'scores_near_cutoff_030_040': sum(0.30 <= score <= 0.40 for score in scores), | ||
| 'wall_gap_count': len(gaps), | ||
| 'wall_gap_min_seconds': min(gaps, default=None), | ||
| 'wall_gap_max_seconds': max(gaps, default=None), | ||
| 'note': 'Counts describe proposals, not reviewed same-call labels or calibrated probabilities.', |
There was a problem hiding this comment.
Report audit truncation and revision coverage
The documented rollout command caps the export at 20,000 entries and requires reviewers to report export truncation plus service/revision coverage, but this result contains neither. A window that reaches the CLI limit can therefore look like a complete sample, and mixed or partially deployed revisions are aggregated into one verdict without visibility, making the output unsafe as rollout evidence. Include an explicit limit-reached indicator and counts from the Cloud Logging service/revision labels.
Useful? React with 👍 / 👎.
| for entry in entries: | ||
| message = entry.get('textPayload', '') | ||
| if not isinstance(message, str) or 'event=smart_merge_wallclock_shadow ' not in message: | ||
| continue |
There was a problem hiding this comment.
Parse structured Cloud Logging payloads
When any audited service emits standard log messages through Cloud Logging's structured path, the message is stored in jsonPayload.message rather than textPayload; the repository's logging rollout explicitly supports both representations. This parser silently ignores every such entry, so a mixed export can substantially undercount proposals or even report an empty audit while matching events exist. Extract the message from either payload form before applying the whitelist.
Useful? React with 👍 / 👎.
## Demand-driven processing Add default-off surface leases, immediate dispatch with tier priority under contention through existing Cloud Tasks workers, open-time promotion, and coalesced lazy memory/vector/task work. Expose `process_recent_conversations` to app chat, shared Telegram/Linq chat and hosted MCP with authenticated owner binding, six-hour/twenty-obligation bounds and a shared rate limit. Phone and Mac reporters renew explicit intent independently of audio sockets. Mac intent measures the main window. The end-of-day hook is omitted under David's updated 2026-10-16 KB rulings. Daytime merge decisions and proactive notification priority remain unchanged. ## Product invariants affected - INV-AUTH-1: lease reporting captures and revalidates the current authorization generation; it never changes Firebase session state. - INV-DATA-1: desktop deploy declarations retain the existing customer identity/data-plane authority; only default-off demand controls are added. - INV-CAP-1: capture/intake and durable audio retention are preserved; only processing dispatch changes. - INV-MEM-4: lazy work uses the existing canonical memory writer and privacy fences, without a second promotion authority. - INV-TASK-2: lazy tasks use the existing suggestion/capture policy and do not accept suggestions automatically. Failure-Class: none UI-Evidence: none -- changes report lifecycle intent; no rendered view or navigation changes. ## Rollout plan Config trains are documented in `backend/docs/runbooks/demand-driven-processing.md`: default-off image -> explicit owner client reporting and scheduler allowlist (0%) -> lazy work -> agent tool -> 1% -> 5% with >=30 minutes of clean sentinel readouts at each step -> 25/50/100 only after acceptance. No production flag change or deployment is included. Measure per-tier queue age, existing end-to-end finalization journeys, retry/dead-letter and outbox repair counts, visible quality, memory/task completeness and live p95. Qualification requires tier 0 <=1m, tier 1 p95 <=5m, tier 2 <=60m; newest 20m <=2m and newest hour <=4m on simultaneous opens. Scheduling headroom is not a measured freshness guarantee. Roll back admission flags while retaining workers/sweeps to drain durable debt. No GPU/cost saving is claimed. ## Validation - Targeted backend: **490 passed** across twelve targeted files using the repository file-list runner, one worker and `nice -n 19`. Includes tier assignment/promotion/drain/ceiling and idle-capacity dispatch, shared outbox recovery, visible/lazy split, synthetic-owner ASGI auth, registration/recovery-read avoidance, tool auth/bounds. - Flutter `listen_client_state_test.dart`: 8 passed. Focused Mac `ListenClientStateTests`: 9 passed, including URL normalization; the final incremental run compiles the regenerated additive API types. - Local HTTP smoke: real loopback HTTP -> production surface handler -> fake Redis -> recorded Cloud Tasks; open intent promoted pending work to tier 0. No live cloud acceptance is claimed. - Full backend Pyright: 0 errors, 36,017 warnings; async blocker scan: 0 findings; changed production import scan: 0 violations. - Schema inventory, full MCP transport/output schemas, prompt-cache inventory and pusher config snapshots pass. - Runtime fixture/renderer contracts: 219 passed; workflow actionlint: both changed workflows pass. Runtime compose check and dev/prod validators pass; source closure passes for all 17 images. OpenAPI and generated Swift/TypeScript contracts regenerated; Dart model freshness passes. - Final-head repository preflight passed 83 selected checks; final-head/push-hook receipts are recorded in the run handoff. Config trains, metrics, rollback and load/quality gates are in the runbook. ## Limits The earlier upstream daily-summary decoder inventory failure is fixed by #21925, now integrated from main (`bfd3a973ed4`). The Grok fix commits do not implement that unrelated client migration. Full CI is not claimed green. The tool promotes the caller's indexed recent debt and reports `ready=false`; it does not scan Firestore for pre-rollout historical work. Existing durable reconciliation owns unindexed debt. Full peak-load and provider qualification are rollout gates. The newer KB rulings remove item 5 from this PR; #21836 and lazy speaker refinement remain separate work. ## Grok fixes - Preserve production's 600-second trailing-edge sync settle when the master switch is enabled, including tier 0/open promotion, Redis-loss enqueue fallback and the durable worker claim. Appends continue to extend one outbox obligation; invisible effects retain explicit-demand bypass. - Retain close/occlusion changes during in-flight Mac and phone reports. Mac re-reads visibility after asynchronous header preparation; both clients drain queued state changes after send and retry failed closes on closed heartbeats without spinning. - Only explicit boolean `surface_open` counts as listen intent. Released iOS/Android/mobile/Mac telemetry remains unchanged when server flags turn on. - Targeted regression run: 490 backend tests passed across twelve files, one file worker at a time via `BACKEND_UNIT_TEST_FILE_LIST`, `nice -n 19`. Mac lifecycle/race tests: 9 passed. Phone lifecycle/race tests: 8 passed. Detailed receipts are recorded in the run handoff. - Merged main's #21923 telemetry (`a4cce4c3099`) while retaining strict surface intent and both documentation sections; telemetry and demand policy regression tests pass. - Merged main's T0 config train (#21887, `acfcd8ed0d4`), regenerated runtime/registry output, and verified all 96 demand defaults remain off/empty/zero while every other runtime value exactly matches main. Sync settle remains 600 seconds; 55 Helm/cohort/parity checks pass. - Continue from the lead's `fb698130b3e` merge of main, without rebasing. The two desktop deploy workflows retain only six additive default-off env lines each; **David approved these exact workflow lines in the final-main-sync instruction**. No merge, deploy or runtime configuration change is included. ## Main sync 2026-10-17 Merged `origin/main` at `6e7007e3e35` without rebasing. Resolved eight conflicts by retaining both additive config/registry/test sets and both post-persistence processing paths. Demand mode retains its 59-minute ceiling and 600-second trailing settle; upstream revision reuse alone retains its 60-minute ceiling. Both enabled use the existing demand headroom, covered by the four-way flag matrix and Redis/open-state settle tests. No intentional change to Grok-approved semantics. Targeted merge validation: **434 passed across nine files**, canonical `BACKEND_UNIT_TEST_FILE_LIST` runner, `BACKEND_PYTEST_WORKERS=1`, `nice -n 19`. All 96 demand defaults remain off/empty/zero and every other runtime value matches main. The two workflow diffs remain exactly six additive default-off lines each; David has approved these exact workflow lines. Detailed conflict resolutions and final publication receipts are appended to the run handoff. ## Final main sync Merged `origin/main` at `3a4fe148259` without rebasing. The only conflict was generated `backend/docs/feature-flag-registry.md`; regenerated it from the merged sources with `--as-of 2026-09-24`, and recomposed/checked runtime env. Seven key Grok-reviewed production files are byte-identical to `66bdc353202`; all 96 demand defaults remain off/empty/zero and every other runtime value matches main. No reviewed semantic change. **303 targeted tests passed across four files**, using `BACKEND_UNIT_TEST_FILE_LIST`, `BACKEND_PYTEST_WORKERS=1` and `nice -n 19`, serially. The workflow edits remain exactly six additive default-off `DEMAND_PROCESSING_*` lines in each approved file and are unchanged from the Grok-reviewed head. **David's scoped approval is recorded.** No PR merge or deployment is included. Final head and publication receipts are appended under “Final main sync” in the run handoff. ## Integration size exceptions Line-Count-Exception: backend/database/conversations.py | 4107 -> 4120 | Small blind metadata writer; avoids a new hot-path Firestore read and stays with database ownership. Line-Count-Exception: backend/routers/listen/receiver.py | 2618 -> 2632 | Small guarded ingestion hook reuses existing client_state; scheduling lives in its own module. Line-Count-Exception: backend/routers/users.py | 2576 -> 2598 | Small typed authenticated lifecycle endpoint; all lease logic lives in the demand module. Line-Count-Exception: backend/utils/conversations/process_conversation.py | 3566 -> 3592 | Small integration seams retain canonical memory/task writer ownership; scheduler and outbox worker are separate modules. Line-Count-Exception: backend/utils/retrieval/agentic.py | 1993 -> 1999 | Register and gate one tool implemented in its own module. Line-Count-Exception: backend/utils/sync/pipeline.py | 3385 -> 3391 | Small flag/coalescing and explicit-demand hooks preserve the existing sync owner. Line-Count-Exception: app/lib/pages/home/page.dart | 1126 -> 1127 | One startup hook starts the opt-in reporter even without a recording socket; no view construction changes. Line-Count-Exception: desktop/macos/Desktop/Sources/OmiApp.swift | 1683 -> 1684 | One startup hook starts the opt-in reporter after environment/auth setup; implementation remains in ListenClientState.
Problem and behavior
Desktop meeting captures and pendant captures of the same call can remain separate even with 44s, 59s, or long complementary-audio overlap. Capture-group membership also prevents smart merge from considering a subsequent pendant fragment.
Add default-off
DESKTOP_PENDANT_CALL_LINK_MODE=off|shadow|onand a stable owner-hash percentage cohort. Completed same-owner desktopmeeting+omicaptures qualify at ≥30s overlap and ≥50% shorter-window coverage without shared-speech confirmation. Deterministic one-to-one selection reserves existing pairs; the transaction rechecks role/windows, fences unlink exclusions, prevents group bridging and pins desktop primary. The macOS role is committed by successful detected-call session rotations, not by calendar overlap or a Telegram-specific ID.A qualifying pendant continuation can join a verified desktop/pendant capture group after the normal smart-merge checks and Jev approval. It never absorbs or rewrites either transcript. Transaction-time checks preserve user edits, starred rows, transcript corrections, device partition, discarded-row barriers, fingerprints and membership revision.
The existing finalizer cross-device seam covers both arrival orders. Ordinary cross-source grouping keeps its content confirmation. A call group's expansion requires the continuation path.
Flag plan
Ship all hosts
off; unknown mode values fail off. Shadow fleet-wide first, logging only role, overlap seconds/ratio, candidate count, decision and reason. After a reviewed sample, enable stable owner cohorts at 1%, 5%, 25%, 100%, reviewing evidence and user-separation outcomes at every stage. Set the percent before changing mode to on. Off stops new links and continuations; existing groups require sticky separation to reverse. No live config changes are included.Leave
CONVERSATION_SMART_MERGE_WALLCLOCK_GAP_MODEunchanged. The runbook includes a bounded Cloud Logging query and an offline content-free numeric audit script. Its review can use the existing smart-merge UID allowlist, which scopes the whole smart-merge step, including legacy merges.Product invariants affected
Failure-Class: none
This is a new opt-in call-link policy for an existing by-design overlap/content gate, with the existing capture-group transaction as the shared persistence primitive. The regression suites exercise that production writer and finalizer link seam; no standalone guard or failure-class registry is added.
Validation
All 508 tests across 11 targeted files passed: matcher 37, smart merge 107, capture groups 33, duplicate policy 28, finalizer/processing seam 4, audit 2, runtime validator 167, renderer 49, runtime-manifest compatibility 16, pusher config 28, cohost env diff 37. The two central config registries (
config/feature-flags.yamlandconfig/deployment-setting-classification.json) contain only the backend flag declarations and their non-secret classifications; every other changed file is underbackend/.All suites run through
taskpolicy -b ... bash backend/test.sh, one file worker, serial test processes. Offline feature-flag registry validation, generated runtime composition drift check, dev/prod runtime manifest/workflow validation, and PR metadata validation passed. Focused type checking and the full backend typed boundary passed with zero errors. The app-client OpenAPI export is up to date, with the public schema unchanged. The normal complete pre-push hooks passed on final head198ba10e2fb165161ac2c8f33e6e8b8b8f604bbe, including all 46 manifest-selected checks, the full backend typed boundary, runtime-image source closure, and the selected backend unit checks. Full integration preflight remains with the lead, per the machine-load instruction. No live provider, user-account, production or device acceptance is claimed.Next steps and limits