Skip to content

feat(mcp): add scoped People rename and cleanup tools - #15669

Merged
aryanorastar merged 22 commits into
mainfrom
feat/8369-mcp-people-cleanup
Oct 5, 2026
Merged

aryanorastar merged 22 commits into
mainfrom
feat/8369-mcp-people-cleanup

Conversation

@aryanorastar

@aryanorastar aryanorastar commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • add hosted MCP and REST operations to rename a recognized person and dismiss a false-positive person
  • require people.rename for corrections and an explicit opt-in people.cleanup scope for dismissal
  • keep existing and default API keys backward-compatible without silently granting cleanup access
  • preserve dismissed records, aliases, history, and speech data while excluding them from normal People reads
  • publish the new routes in the OpenAPI contract, generated desktop/web clients, and MCP documentation

Behavior and safety

Rename

rename_person updates the display name while retaining the prior name in a bounded alias list. It is owner-scoped and returns only the person ID and corrected name; it does not return transcript samples.

Dismiss

dismiss_person is deliberately a soft cleanup operation. It records is_dismissed, dismissed_at, and updated_at, and normal People reads skip the record. The operation is idempotent, preserves the original dismissal timestamp, and maps missing or concurrently deleted records to a not-found response.

This PR does not hard-delete a person, speech samples, audio, or historical data. Portability exports explicitly include dismissed people so cleanup does not remove user data from export.

Authorization

  • people.read remains the read scope.
  • people.rename is included in the compatibility/default scope set so existing clients retain safe correction behavior.
  • people.cleanup is supported by OAuth and API keys but is never added implicitly to legacy, default, or newly created keys.
  • API-key creation accepts recognized explicit scopes and rejects unknown scopes.
  • tools/list hides dismiss_person unless the caller has people.cleanup.
  • runtime tool dispatch and REST routes independently enforce the required scope.
  • REST calls retain the existing fail-closed per-app/per-key MCP rate limit.

API surface

  • hosted MCP tools: rename_person, dismiss_person
  • PATCH /v1/mcp/people/{person_id}/name
  • POST /v1/mcp/people/{person_id}/dismiss
  • reviewed route-policy entries for both REST operations
  • regenerated app-client OpenAPI, macOS Swift, Windows TypeScript, and web TypeScript bindings

Test evidence

  • 216 focused backend tests across People storage, MCP tools/REST, OAuth/API-key scopes, key creation, and dependency boundaries
  • targeted GDPR/data-export coverage confirms dismissed and locked user data remains exportable
  • tool descriptor, tools/list, allowed/denied scope, validation, not-found, idempotency, concurrent deletion, transcript-leak, and legacy/default-key regression coverage
  • public, app-client, and integration OpenAPI freshness checks
  • TypeScript, Swift, and Dart generated-client freshness checks
  • Python compile/format and diff hygiene checks
  • full local repository preflight (46 selected checks)

The local Node 26 run uses NODE_OPTIONS=--no-experimental-webstorage so Vitest/jsdom owns localStorage; this only avoids a Node runtime collision and does not alter product behavior.

Product invariants affected

  • INV-MEM-3 — the export path continues to use the universal memory authority; this change only makes People export include soft-dismissed records and does not add a legacy memory read path.

Failure class

Failure-Class: none

This is a new, scoped cleanup capability rather than a change to an existing runtime failure class.

Closes #8369

Review in cubic

Line-Count-Exception: backend/database/users.py | 2366 -> 2380 | Add soft-dismissal filtering to the existing People read authority without introducing a second persistence path.

@mintlify

mintlify Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
omi 🟢 Ready View Preview Oct 5, 2026, 2:45 PM

💡 Tip: Enable Automations to automatically generate PRs for you.

@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks @aryanorastar — this is one of the more carefully scoped permission changes I've reviewed on this repo. The opt-in design for people.cleanup holds up end to end, and I want to walk through why before raising three product questions that need a maintainer call.

What I verified

  • backend/utils/mcp_scopes.py — normalize_mcp_scopes now returns default ∪ (requested ∩ MCP_OPT_IN_SCOPES). This is the crucial line: lazy repair of legacy keys flows through it, so existing keys can never silently acquire people.cleanup. Renaming MCP_FULL_ACCESS_SCOPES → MCP_DEFAULT_API_KEY_SCOPES with a compat re-export is a good move.
  • backend/routers/api_key_management.py — unknown scopes rejected with 400 before persistence; explicit scopes=["people.cleanup"] at creation is the only path to a cleanup key.
  • backend/routers/mcp_sse.py — dismiss_person is hidden from tools/list without the scope (_tools_for_scopes) and re-checked at tools/call (_require_tool_scope), so neither endpoint trusts the other. The scope-permission strings ("Dismiss false-positive people…") are honest about impact.
  • backend/dependencies.py / backend/routers/mcp.py — require_mcp_api_key_scope returns only the owner UID, and each REST route pins a distinct scope dependency; test_rest_people_routes_use_matching_scope_dependencies locks that wiring in.
  • backend/database/person_aliases.py — dismissal transaction is soft (is_dismissed/dismissed_at only), idempotent (early-return preserves the first timestamp), and maps concurrent deletion to 404 rather than 500. find_person_by_name dropping .limit(1) is fine since it now iterates to the first non-dismissed match.
  • backend/services/users/data_export.py — exports pass include_dismissed=True, so cleanup never removes data from the user's portable archive. Good privacy-preserving default pairing.
  • backend/route_policy_manifest.yaml, backend/utils/mcp_people.py, backend/utils/mcp_analytics.py — manifest entries match the implemented auth/rate-limit placement; mcp_people.py keeps descriptors and execution co-located with DESTRUCTIVE_WRITE_ANNOTATIONS on dismiss; analytics events wired for the new tools.
  • Generated clients (OmiApi.generated.swift, the four omiApi.generated.ts) and app-client-openapi.json are consistent regenerations.

Product questions for a maintainer (not blockers from me, but they decide the shape of the feature):

  1. people.rename joins the default grant (MCP_DEFAULT_API_KEY_SCOPES). Every existing key gains rename on its next auth via lazy repair, silently. "Corrections are safe" is defensible, but it's a write capability arriving on legacy keys without any user action — and it invites the symmetric question: if rename is default-safe, why isn't cleanup? Worth an explicit product decision rather than an implicit one.
  2. One-way dismissal. The record survives in storage and export, but there's no un-dismiss path in the app, REST, or MCP — a wrong dismissal means support intervention. Is that acceptable for v1?
  3. get_people semantics reach beyond MCP. backend/database/users.py now filters dismissed people by default, and callers include the core app people list (routers/users.py), speaker matching (routers/listen/speakers.py), and person-creation dedupe (get_person_by_name). The last one is the sharpest edge: re-creating the same name now produces a duplicate person instead of resurrecting the dismissed one. Reasonable default, but the blast radius is the app, not just MCP — worth confirming that's the intended product behavior.

One small non-blocking note: require_mcp_api_key_scope hardcodes policy_name="mcp:read" for the rename/dismiss dependencies. The manifest matches, so it's consistent today — just flagging that writes ride a read-named policy.

Docs note: the MCP docs (introduction.mdx, tools.mdx, setup.mdx) now advertise rename/dismiss to AI agents. I checked each claim against the enforcement code above and they're accurate, including that people.cleanup is never granted by default — good, since these docs directly steer agent tool selection. The destructive-write annotation on dismiss is the right conservative signal.

Backend checks are green (one desktop contract check still queued at review time). Leaving the three questions above for maintainer product decisions before merge.

🤖 Automated review on behalf of the maintainers.


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 Git-on-my-level added security-review Touches auth, provider routing, secrets, or security-sensitive surfaces needs-maintainer-review Needs a human maintainer to sign off before merge backend Backend Task (python) labels Sep 22, 2026
…cleanup

# Conflicts:
#	backend/route_policy_manifest.yaml
#	desktop/macos/Desktop/Sources/Generated/OmiApi.generated.swift
#	desktop/windows/src/renderer/src/lib/omiApi.generated.ts
#	web/admin/lib/services/omi-api/omiApi.generated.ts
#	web/app/src/lib/omiApi.generated.ts
#	web/personas-open-source/src/lib/omiApi.generated.ts
@aryanorastar

Copy link
Copy Markdown
Collaborator Author

Conflict resolved on ad9ca18094 — merge of current main, no change to this diff.

Six files conflicted, and only one needed a decision. route_policy_manifest.yaml was the familiar list-head collision: main added POST /v1/mobile/feedback at the same position this branch adds the two MCP People routes, and git spliced the three entries into each other rather than picking one. Resolved as the union, with each entry rebuilt whole rather than stitched — a half-merged policy entry would claim the wrong auth mechanism for a route, which is the one failure this file cannot afford.

Verified by parsing rather than by eye: 157 entries against main's 155, the two added are this PR's (PATCH /v1/mcp/people/{person_id}/name, POST /v1/mcp/people/{person_id}/dismiss), none dropped, no duplicate paths.

The other five are generated clients, so they were regenerated, not merged. OmiApi.generated.swift and the four omiApi.generated.ts files were rewritten from the committed contract via generate_swift_openapi_types.py and generate_ts_openapi_types.py. Hand-resolving generated output produces a file that matches neither side and drifts from its source the moment anyone re-runs the generator.

Verification on the merged head:

  • generate_ts_openapi_types.py --check, generate_swift_openapi_types.py --check, generate_dart_models.py --all --check — all up to date, exit 0
  • export_openapi.py --surface app-client --check — app-client-openapi.json is up to date
  • route_policy_inventory.py --check clean; check_route_policy_baseline.py --base-ref origin/main — baseline current, 0 stale entries
  • the eight test files this PR touches, each in isolation: 404 passed (test_mcp_data_endpoints 89, test_mcp_oauth 62, test_daily_memory_sweep 195, plus the API-key, auth-context, people-500s, update-person and dependency-boundary suites)
  • git diff origin/main...HEAD unchanged in shape at 31 files, backend, docs and generated clients only

One note on that test evidence, since the number moved while I was checking: running all eight files in a single pytest process produces 47 failures, and the same kind of cross-file interference reproduces on main with its own file set. Every file passes alone, which is the standard the sharded backend lanes hold them to. I am reporting that rather than only the green number.

Nothing here touches the three product questions from the review — whether people.rename belongs in the default grant, whether one-way dismissal is acceptable for v1, and whether get_people filtering dismissed records app-wide (notably the create-person dedupe path) is the intended blast radius. Those are still maintainer calls, and the merge does not change any of them.

@Git-on-my-level

Copy link
Copy Markdown
Member

Follow-up verification after the merge of current main at ad9ca18 (the earlier automated review was pre-merge).

Independently re-checked the rebase rather than taking it on trust:

  • backend/route_policy_manifest.yaml parses clean: 157 entries, no duplicate (method, path) pairs, and the two added entries (PATCH /v1/mcp/people/{person_id}/name -> people.rename, POST /v1/mcp/people/{person_id}/dismiss -> people.cleanup) carry the dependency-placed auth and fail-closed mcp:read rate limit the code actually implements - no half-spliced policy entries survived the conflict resolution.
  • The four regenerated omiApi.generated.ts clients are byte-identical to each other and consistent with the app-client-openapi.json additions (McpPersonMutationResponse, McpPersonRenameRequest, optional scopes on McpApiKeyCreate); OmiApi.generated.swift matches the same contract.
  • Diff shape vs base is unchanged: 31 files, backend + docs + generated clients only.
  • Security envelope re-verified at this head and unchanged from the earlier review: normalize_mcp_scopes still returns default + explicitly requested opt-in, so legacy-key lazy repair cannot mint people.cleanup; tools/list filtering and the tools/call re-check in backend/routers/mcp_sse.py remain independent; the REST dependencies in backend/routers/mcp.py pin one scope per route and return only the owner UID. All checks are green on this head, including the desktop contract lane that was still queued last time.

The three product questions from the earlier review are the remaining merge gate, and the merge changed none of them: (1) whether people.rename should join the default grant that legacy keys acquire silently on next auth, (2) whether one-way dismissal with no un-dismiss path is acceptable for v1, and (3) whether filtering dismissed records in get_people app-wide - including the create-person dedupe path in get_person_by_name - is the intended blast radius beyond MCP. Those are direction calls, not code defects; the implementation of what this PR claims to do checks out.

Docs: introduction.mdx/tools.mdx/setup.mdx now advertise rename_person and dismiss_person to connecting AI agents. Each claim still matches the enforcement code, and the dismiss_person descriptor carries the destructive-write annotation in the tool listing itself - accurate agent-facing guidance.

🤖 Automated review on behalf of the maintainers.


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 Git-on-my-level added the positive-signal Automation verified a genuine fix/quality contribution label Sep 23, 2026
…cleanup

# Conflicts:
#	desktop/macos/Desktop/Sources/Generated/OmiApi.generated.swift
#	desktop/windows/src/renderer/src/lib/omiApi.generated.ts
#	web/admin/lib/services/omi-api/omiApi.generated.ts
#	web/app/src/lib/omiApi.generated.ts
#	web/personas-open-source/src/lib/omiApi.generated.ts
@aryanorastar

Copy link
Copy Markdown
Collaborator Author

Conflicts resolved on e65ae17040 — merge of current main, no change to this diff. Back to MERGEABLE at 31 files, +1205/−69, the same shape as before the merge.

All five conflicts were generated clients, so they were regenerated, not merged: OmiApi.generated.swift and the four omiApi.generated.ts. Hand-resolving generated output produces a file that matches neither side and drifts from its source the moment anyone re-runs the generator. Each conflicted file was reset to main's copy first, then rebuilt from the committed contract via generate_ts_openapi_types.py and generate_swift_openapi_types.py.

docs/api-reference/app-client-openapi.json auto-merged cleanly and kept both routes and both schemas (/v1/mcp/people/{person_id}/name, /v1/mcp/people/{person_id}/dismiss, McpPersonMutationResponse, McpPersonRenameRequest), so the regeneration had the right source.

One thing worth stating plainly, since it looks like a regression at a glance: OmiApi.generated.swift contains no McpPerson* type names. That is correct — the Swift generator types request and response bodies as OmiAnyCodable rather than emitting named structs. Both routes are there as renamePersonV1McpPeoplePersonIdNamePatch and dismissPersonV1McpPeoplePersonIdDismissPost, and the file's own footer moved from Total: 444 to Total: 446 Swift client methods generated.

main advanced by two commits partway through verification, so those were merged as well; the branch is at 0 behind main.

Verification on the merged head

check result
generate_ts_openapi_types.py --check rc=0
generate_swift_openapi_types.py --check rc=0
generate_dart_models.py --all --check rc=0
export_openapi.py --surface app-client --check app-client-openapi.json is up to date
check_route_policy_baseline.py --base-ref origin/main route policy missing-route baseline is current

route_policy_manifest.yaml verified by parsing rather than by eye: 158 entries against main's 156, no duplicate (method, path) pairs, exactly two added (PATCH …/name, POST …/dismiss), none dropped.

The eight test files this PR touches, each run in isolation — 404 passed: test_mcp_data_endpoints 89, test_mcp_oauth 62, test_daily_memory_sweep 195, test_api_key_route_contract 11, test_dependency_async_boundaries 12, test_mcp_api_key_auth_context 8, test_people_conversations_500s 16, test_update_person_missing 11.

Two things I did not carry into this PR

backend/routers/apps.py and backend/tests/unit/test_apps_exception_hardening.py are not clean under this repo's own pinned Python formatter — running it on main's committed bytes reformats both. The pre-commit hook therefore rewrites them whenever a merge stages them. This branch does not touch either file, so both were reverted to main's exact bytes rather than letting unrelated reformatting ride along in the diff. Flagging it because it will keep happening to every merge that touches them.

route_policy_inventory.py --check fails locally here, but it fails identically in a separate checkout on an unrelated branch, so it is an environment condition rather than anything this PR introduced. The delta check that is scoped to this change — check_route_policy_baseline --base-ref origin/main — passes.

Nothing in this merge touches the three product questions from the review: whether people.rename belongs in the default grant, whether one-way dismissal is acceptable for v1, and whether get_people filtering dismissed records app-wide (notably the create-person dedupe path) is the intended blast radius. Those remain maintainer calls.

aryanorastar and others added 2 commits September 24, 2026 12:55
…notates

mcp-category-filter-tests fails in the CI Hygiene lane with

  AttributeError: module 'requests' has no attribute 'Response'
  mcp/src/mcp_server_omi/server.py:136, in _response_json

That lane installs only pyyaml, so the real requests is absent and
_ensure_third_party_imports falls back to _fake_requests_module(). The stub
carries HTTPError, get, post, delete and patch -- every attribute the tests
call -- but not Response, which server.py names in the _response_json
signature. Python evaluates that annotation at import time before 3.14's
deferred evaluation (PEP 649), so importing the module under the stub raises
before a single test runs.

The check passes on a developer machine whose python3 is 3.14, which is why
this reached CI: on 3.14 the annotation is never evaluated. Reproduced on
3.11.15, the pin in backend/.python-version, and verified on all three paths:
3.11 + stub, 3.11 + real requests, 3.14 + real requests.

Co-Authored-By: Claude Opus 5 <[email protected]>
@aryanorastar

Copy link
Copy Markdown
Collaborator Author

Hygiene is green-able again on 32c37c8a89. The failing check was mcp-category-filter-tests, and the cause is a latent bug in that test's own harness rather than anything in this diff — but it is worth spelling out, because the reason it reached CI at all is a Python version difference that will bite the next person the same way.

What failed

AttributeError: module 'requests' has no attribute 'Response'
  mcp/src/mcp_server_omi/server.py:136, in _response_json

The Hygiene job installs only pyyaml, so the real requests is absent and _ensure_third_party_imports() falls back to _fake_requests_module(). That stub carries HTTPError, get, post, delete and patch — every attribute the tests call — but not Response, which server.py names in a signature:

def _response_json(response: requests.Response):

Before 3.14's deferred annotation evaluation (PEP 649), Python evaluates that annotation at import time, so importing the module under the stub raises before a single test runs.

Why it passed locally and failed in CI

My python3 is 3.14.6, where the annotation is never evaluated, so the check passed here. CI pins 3.11.15 via backend/.python-version, where it is evaluated eagerly. I reproduced the exact CI AttributeError on 3.11.15 by hiding requests to force the stub path, then verified the fix on all three combinations:

interpreter requests result
3.11.15 stub (the CI path) 8 tests OK
3.11.15 real 8 tests OK
3.14.6 real 8 tests OK

The fix

One attribute on the stub, in its own commit (18ec74f58b) separate from the merge, per the root AGENTS.md:

class Response:
    """Annotation target for server.py's _response_json signature."""

module.Response = Response

Why this PR is the one carrying it

This PR touches neither of that check's triggers (mcp/**, .github/checks-manifest.yaml). It got selected because merging current main brought in 8e8f3f80bb, which edits .github/checks-manifest.yaml — so the merge put a trigger path into the changed-file set CI computes. Any PR that merges main past that commit will select this check and hit the same import error, which is why I fixed it here rather than just re-running. A plain re-run of the job failed identically, as expected.

Diff is now 32 files — the PR's 31, unchanged, plus mcp/tests/test_category_filters.py. Current main merged again (it moved five commits mid-verification); branch is at 0 behind. Generated-client freshness re-checked after that merge: generate_ts_openapi_types --check, generate_swift_openapi_types --check and export_openapi --surface app-client --check all rc=0.

The three product questions from the review are still untouched and still maintainer calls.

@aryanorastar

Copy link
Copy Markdown
Collaborator Author

Backend unit shard 3/4 is red here, but the break is on main, not in this PR. Evidence rather than assertion:

FAILED tests/unit/test_app_client_schema_inventory.py::test_inventory_openapi_route_response_decode_migration_complete
AssertionError: assert not response_violations

The single violation is app/lib/backend/http/api/conversations.dart:549, route /v1/conversations/{param}/capture-group/separate — a raw response decode with no generated-model backing. This PR touches neither that file nor that route; git diff origin/main HEAD -- docs/api-reference/app-client-openapi.json has zero capture-group hits, and the diff contains no app/ files at all.

Bisected to the commit

I checked out pristine trees and ran the same test:

tree result
origin/main @ 29b3c32299 1 failed, 11 passed
373126c05e — feat(app): one row per recorded event and a compact conversation page on mobile (#17297) 1 failed, 11 passed
373126c05e^ 12 passed

So 373126c05e introduced it, and current main still carries it. Any PR that merges main past that commit inherits this red, which is why it appeared here one merge after it appeared everywhere else.

I have not touched it. The fix belongs in the Flutter client — either routing that decode through a generated model or recording it the way the inventory expects — which is outside this PR's scope and outside what I work on. Flagging it so it gets an owner rather than being mistaken for fallout from this change.

The Backend unit suite failure is the same shard rolled up; there is no second cause.

For the record, everything this PR is responsible for still passes on the current head 32c37c8a89: the eight touched test files at 404 passed in isolation, mcp-category-filter-tests OK after the stub fix, and generate_ts_openapi_types --check, generate_swift_openapi_types --check and export_openapi --surface app-client --check all rc=0.

@aryanorastar

Copy link
Copy Markdown
Collaborator Author

The Backend unit shard 3/4 red here is fixed by #18491, opened against main.

That PR migrates separateConversationFromCaptureGroup to decode through a generated GeneratedStatusResponse instead of a raw jsonDecode + body['status'], which is what test_inventory_openapi_route_response_decode_migration_complete has been failing on since 373126c05e. Since the break is on main, it unblocks every PR that merges past that commit, not just this one — which is why it is a separate PR rather than a commit bundled in here. This PR's diff stays at the 32 files described above.

Nothing on this branch changes as a result.

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

feat(mcp): new People rename/dismiss capability with scoped auth -- feature, approve-only per policy regardless of score. Backend unit shard 3/4 and Backend unit suite are currently failing.

…cleanup

# Conflicts:
#	desktop/macos/Desktop/Sources/Generated/OmiApi.generated.swift
#	desktop/windows/src/renderer/src/lib/omiApi.generated.ts
#	web/admin/lib/services/omi-api/omiApi.generated.ts
#	web/app/src/lib/omiApi.generated.ts
#	web/personas-open-source/src/lib/omiApi.generated.ts
@aryanorastar

Copy link
Copy Markdown
Collaborator Author

Conflicts resolved on 006c64bb42 — merge of current main (19 commits), no change to this diff. Back to MERGEABLE at 32 files, +1214/−69.

Same five generated clients conflicted as last time, handled the same way: reset each to main's copy and rebuilt from the committed contract rather than hand-merging. docs/api-reference/app-client-openapi.json auto-merged cleanly and kept both routes and both schemas, so the regeneration had the right source.

Verification on the merged head

check result
generate_ts_openapi_types.py --check rc=0
generate_swift_openapi_types.py --check rc=0
generate_dart_models.py --all --check rc=0
export_openapi.py --surface app-client --check rc=0

route_policy_manifest.yaml parsed rather than eyeballed: 165 entries against main's 163, no duplicate (method, path) pairs, exactly two added (PATCH …/name, POST …/dismiss), none dropped.

The eight test files this PR touches, each in isolation: 404 passed, unchanged. mcp-category-filter-tests OK.

One thing kept out of the diff

The pre-commit hook reformatted backend/tests/unit/test_shared_action_items.py — a file this branch does not touch. main's committed bytes for it are not clean under the repo's own pinned Python formatter, so any merge that stages it picks up the reformat. Reverted to main's exact bytes, same as backend/routers/apps.py in the previous merge. Worth a look at why those files and the pinned formatter disagree, since it will keep happening.

The remaining red (Backend unit suite, Backend unit shard 3/4) is still main's schema-inventory break from 373126c05e, fixed by #18491 and not by anything on this branch. It will clear here once that lands and main is merged again.

The three product questions from the review are untouched and still maintainer calls.

@aryanorastar

Copy link
Copy Markdown
Collaborator Author

The Backend unit shard 4/4 red here is another main-side break, not this PR's, and it is fixed by #18719.

tests/unit/test_shared_action_items.py fails with TypeError: accept_shared_action_items() got an unexpected keyword argument 'payload'. Reproduced on a pristine origin/main checkout: 6 failed. Bisected to b2c9cfb199 (#17830), the commit that added the file — the tests were written against an API that does not exist (payload= vs the handler's request, verify_task_share_token vs get_task_share, get_action_items_by_ids vs get_action_item), so they have never passed since they landed.

This branch does not touch that file — its bytes here are identical to main's. #18719 rewrites the tests against the handler they actually test; no production behavior changes.

Nothing on this branch changes as a result.

@aryanorastar

Copy link
Copy Markdown
Collaborator Author

Review follow-up: the OAuth metadata path now advertises the full supported scope set (including opt-in people.cleanup), and default person reads hide soft-dismissed records while explicit internal reads can opt in. Generated clients and the relevant backend contracts were refreshed; focused tests and the full local pre-push gate passed. Fresh CI is running.

@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks @aryanorastar — reviewed the full cumulative diff at 4deb6a9. This is a careful, privacy-conscious scope rework:

  • backend/utils/mcp_scopes.py / backend/config/mcp_scopes.py: people.cleanup is a true opt-in — excluded from the default grant, the legacy full-access alias, and lazy key repair; normalize_mcp_scopes() only unions requested scopes from MCP_OPT_IN_SCOPES, so nothing outside the supported set can enter a key.
  • backend/routers/api_key_management.py: unknown scopes are rejected with 400 before persistence.
  • backend/database/mcp_oauth.py / mcp_token_cache.py / mcp_client_metadata.py: validators widened to MCP_SUPPORTED_SCOPES so a consented cleanup grant survives token-cache hits and is not stripped by lazy repair.
  • backend/database/person_aliases.py: dismissal is transactional, idempotent (keeps the first dismissed_at), and never deletes the record; backend/services/users/data_export.py keeps dismissed people in the portable archive.
  • backend/utils/mcp_server/registry.py / handlers/other.py: dismiss_person advertises destructiveHint and is hidden from tools/list without the scope; rename responses deliberately omit transcript samples.
  • docs/doc/developer/mcp/tools.mdx / setup.mdx / introduction.mdx: documented behavior matches the implementation, including the opt-in semantics. Note these docs are consumed by AI agents connected through MCP, so agents with existing default keys will discover rename_person immediately.

Two non-blocking observations:

  1. get_people_by_ids and count_people in backend/database/users.py are not dismissed-aware, so a soft-dismissed person can still surface through ID-fetch and count paths. Not reachable from the new MCP surface, but an inconsistency in the soft-delete boundary.
  2. people.rename is granted to every legacy/default MCP key on next authentication via lazy repair. The code comments argue rename is safe and reversible and the response leaks no transcript samples, but silently granting a new write capability to all existing agent keys without re-consent is a product call for maintainers.

Checks (backend suite, Hermetic E2E, CodeQL, Desktop Swift) all pass at this head. Leaving the final merge call with the maintainers given the scope-model and consent questions 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.

…cleanup

# Conflicts:
#	backend/database/users.py
#	backend/routers/mcp.py
#	backend/tests/support/firestore_conversation_callers.json
#	desktop/macos/Desktop/Sources/Generated/OmiApi.generated.swift
#	desktop/windows/src/renderer/src/lib/omiApi.generated.ts
#	web/admin/lib/services/omi-api/omiApi.generated.ts
#	web/app/src/lib/omiApi.generated.ts
#	web/personas-open-source/src/lib/omiApi.generated.ts
@aryanorastar

Copy link
Copy Markdown
Collaborator Author

Merged current main (2015b0f).

  • backend/database/users.py: main now runs every person read through project_person_learning. get_people and get_person_by_name keep this PR's soft-dismissal filtering (list_people / find_person_by_name) and apply main's projection to each result, with one shared projection cache for the list.
  • backend/routers/mcp.py: main moved REST routes to registry-driven require_mcp_scope(TOOL_REQUIRED_SCOPE[...]), which is the same check as this PR's require_mcp_api_key_scope. The rename and dismiss routes now use TOOL_REQUIRED_SCOPE["rename_person"] / ["dismiss_person"] like every other route, and the duplicate helper is removed from dependencies.py. The two tests that referenced it are retargeted.
  • main's new test_mcp_rest_scope_matrix.py now covers both routes. Full access is expected to get 403 on dismiss, since people.cleanup is opt-in by design.
  • firestore_conversation_callers.json was deleted on main (fix(backend): declare single-field collection-group indexes and bring Firestore index debt to zero #20161); this branch only bumped a digest in it, so it stays deleted.
  • Regenerated the five API clients; TS/Swift/Dart/OpenAPI checks clean.
  • Updated the users.py Line-Count-Exception to 2364 -> 2375 against current main.
  • MCP, people, dependency, Firestore shape/witness/index, and memory-sweep tests pass, each file in its own process.

@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks @aryanorastar — this is a carefully built authorization change, and the safety design holds up under static review on 2015b0f. Highlights and two maintainer-attention notes below.

What checks out:

  • config/mcp_scopes.py keeps people.cleanup in MCP_OPT_IN_SCOPES, outside the legacy full-access alias, and normalize_mcp_scopes in utils/mcp_scopes.py can only add it when explicitly requested at key-creation time; routers/api_key_management.py rejects unknown scopes with 400 before persistence.
  • database/person_aliases.py dismiss transaction is idempotent, preserves the first dismissed_at, never deletes the record, and maps concurrent deletion to 404; services/users/data_export.py passes include_dismissed=True so portability exports keep dismissed people.
  • The REST routes enforce people.rename / people.cleanup through require_mcp_scope with the existing fail-closed per-app/per-key rate limit (route_policy_manifest.yaml), and utils/mcp_server/registry.py correctly tags dismiss_person with destructiveHint while tools/list hides it without the opt-in scope (covered by tests).
  • The rename response deliberately excludes speaker-sample/transcript data — good minimal-disclosure choice.

Two notes I'd want a maintainer to consciously decide on (not implementation bugs):

  1. Legacy-key repair: every existing MCP API key silently gains people.rename on its next authentication (database/mcp_api_key.py repair path). Reversible and arguably the right compatibility call, but it widens write consent for all keys without re-consent — worth explicit sign-off on the consent model.
  2. Dismissal is not enforced in all read paths: get_people_by_ids and count_people, which back chat context (utils/llm/chat.py), RAG (utils/retrieval/rag.py), and conversation rendering (routers/conversations.py), do not filter is_dismissed. A dismissed false-positive still surfaces in those derived views and quota counts, which is inconsistent with the "normal reads hide dismissed people" contract. If that's intentional history preservation, a short code comment or doc line saying so would help; otherwise those paths need the same filter.

Docs note: the introduction/tools/setup .mdx additions match the implementation (verified against config/mcp_scopes.py and registry.py) — since these docs steer what AI agents believe they may call, they effectively advertise the new write surface; keeping them accurate to the opt-in model matters, and they currently are.

No blocking issues found from automation. Because this widens MCP write authorization over user people data, final merge sign-off on the consent model above belongs to a human maintainer.


This review was produced by AI automation operating on David's behalf.


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

The Search overview badge used count_people, which counted every speaker
profile, while the list it opens (get_people) hides soft-dismissed ones. Count
the dismissed profiles server-side and subtract them so the badge matches the
list. Document why get_people_by_ids keeps returning dismissed people: its
callers resolve person IDs already stored on past segments, and dismissal
hides a profile from lists without rewriting that history.

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

Copy link
Copy Markdown
Collaborator Author

Pushed 0de59e8 for the second note (dismissal across read paths):

  • count_people now subtracts soft-dismissed profiles (a second server-side aggregation on is_dismissed == True), so the Search overview People badge matches the list it opens, which get_people already filters. tests/routers/test_search.py covers the subtraction and the filter.
  • get_people_by_ids keeps returning dismissed people on purpose, and its docstring now says why: every caller (conversation rendering, chat/RAG context, memories, trends) resolves person IDs already stored on past segments. Filtering there would turn already-attributed speech into unknown speakers, and dismissal hides a profile from lists without rewriting that history.
  • Updated the users.py Line-Count-Exception to 2364 -> 2378. Search and Firestore query-shape/witness/index tests pass.

The first note (legacy keys gaining people.rename on repair) is a consent-model call for a human maintainer, as the review says; no code change for it here.

…cleanup

# Conflicts:
#	desktop/macos/Desktop/Sources/Generated/OmiApi.generated.swift
#	desktop/windows/src/renderer/src/lib/omiApi.generated.ts
#	web/admin/lib/services/omi-api/omiApi.generated.ts
#	web/app/src/lib/omiApi.generated.ts
#	web/personas-open-source/src/lib/omiApi.generated.ts
@aryanorastar

Copy link
Copy Markdown
Collaborator Author

Merged current main (15a118d).

  • Only the five generated API clients conflicted. Took main's copies and re-ran the TS and Swift generators; both --check clean, and the OpenAPI specs and Dart models were already up to date.
  • The two red Desktop Swift checks on 0de59e8 weren't caused by this PR, whose only desktop change is the regenerated client. One was ProcessingConversationWatcherTests.test_failedOutcome_doesNotEnterSettling on a timing assertion, which passes locally 6/6. The other was the launcher-script step taking 565s against its 360s runner budget. The Static & Test Contracts job failed only because it depends on those. This push re-runs them.

@Git-on-my-level

Copy link
Copy Markdown
Member

Follow-up on the current head (15a118d, previously reviewed at 2015b0f). Both maintainer-attention notes from the last automated review are now resolved or settled:

Resolved — dismissal consistency in read paths. 0de59e80 makes count_people subtract soft-dismissed profiles via a second server-side aggregation on is_dismissed == True (clamped with max(total - dismissed, 0)), so the Search overview People badge now matches the filtered list get_people serves. tests/routers/test_search.py verifies the aggregation shape and keeps the no-stream() invariant. The other half of that note — get_people_by_ids still resolving dismissed IDs — is now explicitly documented in the docstring as a deliberate choice (history stored on past segments is not rewritten by dismissal), which is the right disposition: rendering/conversation history stays intact while lists, direct lookups, and counts hide the record.

Settled — rename consent. The remaining product call from the earlier review (legacy keys silently gaining people.rename through lazy repair) is unchanged and already flagged for maintainers; no new information to add there.

New at this head, verified:

  • 15a118da is a main-merge touching only the five generated clients, regenerated from the committed contract — no hand-written logic changes.
  • 4deb6a96 registers the list_people / find_person_by_name query shapes in firestore_query_driver_registry.py (with include_dismissed marked as a post-read neutral), keeping the Firestore query-coverage contract honest about the refactor of get_people/get_person_by_name into person_aliases.
  • Full checks green at this head, including Backend Hermetic Merge Gate and CodeQL.

Automation has no blocking concerns on this head. What it still needs is a fresh human approval: the last maintainer approval (2026-09-30) predates the query-shape registration, the count fix, and several main merges, and the PR carries security-review for a capability-expanding change — that final consent-model sign-off is a maintainer decision, not an automation one.


This review was produced by AI automation operating on David's behalf.


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

…cleanup

# Conflicts:
#	desktop/macos/Desktop/Sources/Generated/OmiApi.generated.swift
#	desktop/windows/src/renderer/src/lib/omiApi.generated.ts
#	web/admin/lib/services/omi-api/omiApi.generated.ts
#	web/app/src/lib/omiApi.generated.ts
#	web/personas-open-source/src/lib/omiApi.generated.ts
@aryanorastar

Copy link
Copy Markdown
Collaborator Author

Merged current main (456d1e2).

  • Only the five generated API clients conflicted. Took main's copies and re-ran the TS and Swift generators; both --check clean, and the OpenAPI specs and Dart models were already up to date.
  • main grew backend/database/users.py by two lines, so the Line-Count-Exception now reads 2366 -> 2380 (this PR's +14 is unchanged).
  • Every test_mcp_* file, tests/routers/test_search.py, the Firestore query-shape and caller-witness suites, test_dependency_async_boundaries.py, and test_daily_memory_sweep.py pass, each in its own process.

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

feat(mcp): scoped People rename/cleanup tools — well-documented new capability (fail-closed scopes, no hard-delete, extensive tests). This is a feature not a bug fix, so approve-only per policy even though trusted author. mergeStateStatus is DIRTY so not merging.

@aryanorastar
aryanorastar merged commit c0e877b into main Oct 5, 2026
61 checks passed
@aryanorastar
aryanorastar deleted the feat/8369-mcp-people-cleanup branch October 5, 2026 15:27
aryanorastar added a commit to aryanorastar/omi that referenced this pull request Oct 5, 2026
BasedHardware#20003, BasedHardware#19815 and BasedHardware#15669 each regenerated the clients against their own
base and merged cleanly, leaving main's "Total: 478 client methods" header
one short of the 479 the spec now generates. The knowledge-ledger client
schema contract compares the checked-in artifacts and failed on every branch
that merged main. Regenerated; only the five total lines change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
aryanorastar added a commit to aryanorastar/omi that referenced this pull request Oct 5, 2026
main's generated clients carry "Total: 478 client methods" while the merged
spec generates 479 (BasedHardware#20003, BasedHardware#19815 and BasedHardware#15669 each regenerated against their
own base). The knowledge-ledger client schema contract fails on every branch
that merges main. Regenerated; only the five total lines change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Git-on-my-level added a commit that referenced this pull request Oct 12, 2026
…mbient listening (#11801)

* feat(desktop): hands-free wake word to command the assistant during ambient listening

Add an opt-in Wake Word feature: say "Omi" followed by a command while
ambient listening is active and the assistant runs the command hands-free.

- WakeWordService: parses and gates wake-word triggers (cooldown, segment
  dedup, user-speech and busy-conversation guards) and submits the stripped
  command to the assistant
- WakeWordSegmentParser: extracts wake phrase + 2-word-minimum command
- Wire incoming transcript segments from AppState+ListenEvents
- Settings > General: opt-in Wake Word toggle with dynamic subtitle
- AssistantSettings: persisted wakeWordEnabled/Phrase/Cooldown (default off)
- Tests: WakeWordServiceTests + WakeWordSegmentParserTests (15 cases green)

* style(desktop): format WakeWord sources with pinned swift-format; add e2e flow coverage

Fix the two Desktop Swift CI failures:
- desktop-e2e-flow-coverage: cover WakeWordService.swift and
  WakeWordSegmentParser.swift under capture-lifecycle.yaml (the
  capture_test_transcript seam drives the same AppState+ListenEvents
  funnel the wake word observes).
- desktop-swift-format-lint: add missing trailing newlines to the four
  WakeWord source/test files per pinned swift-format 602.0.0.

Verified: run_checks.py macos lane passes e2e-flow-coverage,
swift-format-lint, and swiftlint; WakeWord 15 tests pass
(WakeWordSegmentParserTests 7 + WakeWordServiceTests 8).

* fix(desktop): match speech-to-text renderings of the wake phrase

The wake word only matched the literal string "omi", but speech-to-text
spells the phrase by sound. A live mic session transcribed "Omi, how are
you?" as "Oh me, how are you?" (Parakeet v3, conf=0.92) and the wake word
silently never fired -- the recognizer heard the user correctly and the
parser rejected it.

Accept the renderings recognizers actually emit ("oh me", "omni", "ohmi",
"oh mi", "omee", "o me", "oh-me") as the same phrase, expanded through the
existing greeting prefixes so "hey oh me, ..." works too. The downstream
guards (user speech only, 2+ word command, cooldown, segment dedup) still
bound the false-positive cost of the wider match.

The existing unit tests passed before and after this change because they
fed the parser the string "Omi" -- which is exactly what the microphone
never produces.

Verification
- swift test --filter WakeWordSegmentParserTests -> 10 passed
- Added the exact failing string from the live session as a regression test,
  plus negatives proving the wider match does not swallow ordinary speech
  ("Omnibus schedule changed" and a bare "Oh me" still do not fire).

* fix(desktop): make the wake word survive the real ambient transcript

Three defects found by running the feature against a live ambient session
rather than constructed segments. Each failed silently, so a wake word that
never fired was indistinguishable from one that was never spoken.

1. Diarization attribution. The trigger required `segment.isUser`, but the
   backend only sets `is_user` once a speech profile is enrolled. A live
   session logged `Speaker 0: "Omi, what's the weather?"` with is_user=false,
   so the wake word was structurally dead for every user without an enrolled
   profile. VoiceBargeInPolicy already gates on `isUser || speaker == 0` and
   documents speaker 0 as the primary user; the two entry points disagreed
   about what "the user" means. Align on the sibling's contract.

2. Segment dedup. The backend re-delivers one growing segment under a single
   id (observed: [206.0s-217.1s] -> [206.0s-228.9s]). Deduping on the id alone
   dropped every later command that landed inside an id that had already
   fired. Key on the id plus the extracted command so a re-sent segment is
   still suppressed but a new instruction inside it runs.

3. Cooldown. The cooldown exists to swallow a rapid repeat of the same
   utterance, but it gated on elapsed time alone. The ambient transcript lane
   runs ~35s behind live speech (measured over 11 segments, 34.3-36.6s), so
   several genuinely distinct commands routinely arrive inside one 30s window
   and were discarded as "repeats" -- two consecutive "what time is it"
   attempts were both lost this way. Gate on a repeat of the same command.

Also name the reason a segment was ignored. Every guard returned silently;
the diagnostics are what located defects 1 and 2, and the demo runbook
depends on the log explaining a beat that did not fire. Only segments that
actually carry the wake phrase are reported, so ordinary speech stays quiet.

Verification
- swift test --filter WakeWordServiceTests -> 11 passed
- Regression tests added for each defect, carrying the live values that
  exposed them (speaker 0 with is_user=false, a reused segment id, a distinct
  command inside the cooldown).
- Confirmed live after the fix: `WakeWord: submitting 'can you order food for
  me?' to the assistant`, and the re-delivered segment correctly suppressed.

Honest gaps
- The ~35s ambient latency is server-side (client ships audio every 100ms via
  audioBufferSize=3200); it is not addressed here and needs the realtime lane.
- Not verified against an account with an enrolled speech profile.

* fix(desktop): speak the assistant's reply to a wake word

The wake word dispatched with `fromVoice: false`, which is the flag that
decides whether the assistant speaks its answer or only renders text. A wake
word is a hands-free entry point by definition -- the user's hands and eyes
are elsewhere -- so a silent reply strands the interaction the feature exists
to enable. Observed live: the trigger fired and answered correctly, and the
user heard nothing.

PushToTalkManager already passes `fromVoice: true` for the same reason.

Verification
- swift build -> clean
- swift test --filter 'WakeWordServiceTests|WakeWordSegmentParserTests' -> 21 passed

Honest gaps
- Voice follow-up is still unavailable from the wake word. `sendFollowUpQuery`
  exists and PushToTalkManager uses it with a voiceTurnID, but the wake word
  always opens a fresh query, and `guard !isConversationActive` suppresses the
  trigger while a turn is live. Wiring multi-turn to the wake word needs the
  realtime lane, not the ~35s ambient lane; tracked separately.

* fix(desktop): accept aspirated renderings of the wake phrase

On-device recognition has no keyword list, so it fronts the vowel with an
aspirate. Observed live from one speaker in a single session:

    "Homi what's the weather? outworking."
    "Homie, can you order food for me? Street drive to children dance."

Adds "homi" and "hommi". Deliberately excludes "homie": it is an ordinary
English word, and accepting it as the wake phrase would fire on real speech.

Scope note: this list is a safety net, not the fix. `TranscriptionService`
already seeds ["Omi", "OMI"] into the STT keyword boost, and on the cloud lane
the phrase transcribes exactly every time. These misses only occur on the
on-device lane, which takes no keyword list -- the durable fix is keyword
boosting on the recognizer, not a longer list here.

Verification
- swift test --filter WakeWordSegmentParserTests -> 10 passed

* fix(desktop): stop a growing transcript segment re-firing the wake word

A backend segment is re-delivered as it grows, in place and under one id. The
previous dedup keyed on the exact extracted command, so every growth counted as
a new instruction and fired again with a longer string. Worse, the assistant's
own spoken reply is captured by the microphone and appended to the same
segment, so each re-fire submitted a more polluted command. Observed live:

    12:41:32  submitting 'what time it is? You speak English. Got it.'
    12:41:33  submitting 'what time it is? You speak English. Got it. Handed you this'
    12:41:39  Transcript [ADD] Speaker 1: Handed you this An agent is getting started on that.

The query actually dispatched was the polluted string, which is not what the
user asked and cannot be answered usefully.

Deduping on the id alone is also wrong -- it drops a genuinely new instruction
that lands in a reused id. Treat a command that extends one already fired for
that segment as the same instruction, and anything else as new.

Verification
- swift test --filter WakeWordServiceTests -> 12 passed
- Regression test carries the live growth case.
- Confirmed live: one clean `submitting 'what time it is?'`, and the following
  re-delivery correctly `ignored — already fired`.

Honest gaps
- The microphone capturing the assistant's own speech is a separate defect and
  is not addressed here; this change only stops it corrupting the command.

* fix(desktop): restore wake word dispatch broken by fromVoice

An earlier commit on this branch switched the wake word to
`openAIInputWithQuery(command, fromVoice: true)` so the assistant would speak
its answer. That silently disabled the feature end to end.

`openAIInputWithQuery` gates the voice path on a turn it does not mint:

    if fromVoice {
      guard let voiceTurnID,
        VoiceTurnCoordinator.shared.requireCurrentOwner(for: voiceTurnID) != nil
      else { return }

`fromVoice: true` with no `voiceTurnID` fails that guard and returns with no log
and no user-visible effect. Every wake word therefore logged `submitting` and
dispatched nothing -- the trigger looked healthy in the log while the assistant
was never invoked.

`fromVoice: true` belongs to callers that own a voice-turn lifecycle:
PushToTalkManager begins a turn and passes both arguments. The wake word submits
an already-transcribed command and owns no turn, exactly like
DesktopAutomationBridge, which passes `fromVoice: false` for the same reason.

Verification
- swift build -> clean
- swift test --filter 'WakeWordServiceTests|WakeWordSegmentParserTests' -> 22 passed
- Confirmed live: `WakeWord: submitting 'what time is it?'` followed 1.3s later by
  `WakeWord: ignored — assistant already busy`, i.e. the turn actually engaged.
  With `fromVoice: true` that second line never appeared on any attempt.

Honest gaps
- The reply is no longer spoken aloud; it renders in the floating bar. Restoring
  spoken replies requires minting a VoiceTurnID via
  `VoiceTurnCoordinator.begin(intent:)` before dispatch and threading it through,
  which is a separate change and is not attempted here.

* fix(desktop): require a pause after a homophone wake phrase

Review feedback on this PR: with "oh me" accepted as the wake phrase, an ordinary
sentence like "oh me and my friend went hiking" parses to the 2-word command
"and my friend went hiking" and auto-sends it. That false-positive surface was
introduced by the homophone table earlier in this branch.

The homophones and the literal spelling are not the same kind of evidence. Saying
"Omi" is deliberate -- nobody produces it mid-sentence by accident -- so
"Omi order food" needs no corroboration. A homophone is the recognizer guessing,
and its guesses are ordinary English, so it needs something more.

A bare homophone now has to be followed by a punctuation break: the recognizer's
own signal that the speaker addressed something and then paused. Every homophone
hit observed live carried one ("Oh me, how are you?"). A greeting prefix is
corroboration in its own right -- "hey oh me" is not said by accident -- so those
forms keep the ordinary word boundary.

    "Omi order food"                    fires    (literal, unchanged)
    "Oh me, how are you?"               fires    (homophone + break)
    "hey oh me order pizza"             fires    (greeting corroborates)
    "oh me and my friend went hiking"   ignored  (bare homophone, no break)
    "o me it has been a long day"       ignored

This only ever makes the wake word fire less, so the risk it carries is a missed
trigger, never a spurious one.

Verification
- swift test --filter 'WakeWordSegmentParserTests|WakeWordServiceTests' -> 25 passed
  (13 parser + 12 service; 3 new, every prior case still green)
- New cases use the reviewer's example sentence and the exact strings observed live.
- Confirmed live on the dev serving plane after the change, both forms in one session:

      20:44:35  Transcript: "Hey Omi what's the time"
                WakeWord: submitting 'what's the time' to the assistant
      20:44:37  Transcript: "Omi, what is the time?"
                WakeWord: ignored — assistant already busy

  The second line is the trigger being correctly suppressed while the turn opened
  by the first was still live, which is also proof the dispatch engaged.

Honest gaps
- Punctuation is a proxy for a spoken pause and depends on the recognizer emitting
  it. A homophone rendered without punctuation will now be missed rather than
  misfire, which is the safer direction but is still a miss.
- Does not address a wake phrase transcribed in a non-Latin script (the socket runs
  language=multi); matching remains ASCII-only.

* fix(ci): bypass stalled Azure apt mirror

The hosted runner's Azure Ubuntu mirror repeatedly stalled Redis setup until the 20-minute gauntlet deadline. Use the existing archive.ubuntu.com fallback directly for each Redis-dependent gauntlet.\n\nVerification:\n- actionlint -config-file .github/actionlint.yaml .github/workflows/backend-hermetic-e2e.yml\n- python3 backend/scripts/check_workflow_contracts.py --changed-files .github/workflows/backend-hermetic-e2e.yml\n- git diff --check\n\nFailure-Class: none

* fix(ci): bypass stalled Azure apt mirror in Linux package helper smoke

Same stall as backend-hermetic-e2e's Redis install (69e5a9e): the
hosted runner's Azure Ubuntu mirror hangs InRelease fetches, this time
in desktop-windows-ci's Linux runtime dependency install, until the
job's 6-hour default timeout cancels it. Drop the mirror the same way,
falling back to archive.ubuntu.com directly.

Verification:
- actionlint -config-file .github/actionlint.yaml .github/workflows/desktop-windows-ci.yml
- git diff --check
Failure-Class: none

* chore(ci): retrigger hermetic suite after a scope-detect runner cancellation

Detect Hermetic Backend Scope was cancelled mid-run by a runner race, so
Backend Hermetic Merge Gate read SCOPE_RESULT: cancelled and failed
closed. Distinct from the apt-mirror stall in #11848 — this one never
reaches a package fetch. No code change; the branch has no admin rights
to rerun the workflow directly.

* feat(desktop): recognize evidence-backed Omie wake-word transcripts

* fix(desktop): end an on-device transcription window when the speaker pauses

The wake word's latency was not the cloud ambient lane. On Apple Silicon
`STTSessionState.resolveMode` picks the on-device Parakeet path by default, and
`LocalTranscriptionService` only closed a window on a fixed 10s boundary — so a
spoken command waited for wherever it happened to land in that window.

Measured live on a MacBook Air, real microphone, identical utterances:

  before   1.08s / 6.18s / 7.65s   (~5s expected, ~10s worst case)
  after    0.66s / 0.76s / 0.82s / 0.89s / 0.89s / 1.04s

Three changes, all in the on-device path:

- A window closes early once the buffer holds a second of voiced audio followed
  by 0.6s of quiet. The minimum is measured in voiced samples, not buffer
  length: a mostly-quiet window with one blip in it is what Parakeet answers
  with a hallucinated word (a 1.1s window at rms 0.0067 decoded to "Yeah.").
- Silence ahead of the first speech is dropped, advancing the emitted-seconds
  cursor over it so absolute timestamps stay exact. Otherwise quiet counted
  against the 10s cap and the window filled partway through the next sentence —
  observed cutting "Omi, what time is it now" down to "Now".
- The pump ticks at 0.5s rather than 1s, since it is now the floor on how soon
  a finished utterance can be transcribed rather than a poll for a full window.

The 10s cap is unchanged and still bounds continuous speech.

Verification:
- xcrun swift test --package-path Desktop --filter
  'LocalTranscriptionEndpointTests|LocalTranscriptionDuplicatePolicyTests|WakeWord'
  -> 42 tests, 0 failures
- Eight timed utterances through the real microphone on a named dev bundle,
  wake word enabled, on-device Parakeet: every one dispatched, full text, in
  0.66-1.04s from the end of speech.

Failure-Class: none

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

* feat(desktop): speak the wake word's answer and keep the conversation going

Two things a hands-free trigger needs that it did not have: the answer came
back as text only, and every command opened a fresh conversation.

Both came from one boundary being drawn in the wrong place.
`openAIInputWithQuery` selected the `.voiceOnly` surface on `fromVoice`, and
that surface requires a `VoiceTurnID` — so a voice query that owns no turn was
dropped with no diagnostic, which is why the wake word had to pass
`fromVoice: false` and therefore stayed silent. Selecting `.voiceOnly` on
`voiceTurnID` instead says what the branch actually means. Push-to-talk owns a
turn and is unchanged; the wake word falls through to the visible surface,
where `fromVoice` still marks it a voice query and the answer is spoken.
`sendFollowUpQuery` had the same guard and now applies the turn-optional rule
`routeQuery` already uses, so a second command continues the conversation.

`WakeWordService` dispatches through the new `submitSpokenCommand`, which is
both: spoken answer, conversation continuity.

Speaking the answer creates a feedback path that did not exist before — the
microphone hears Omi and it lands in the transcript as the user's own speech.
Observed live: `Transcript [ADD] Speaker 0: It's 8 57 p.m. on Sunday...` was
Omi. An answer carrying the wake phrase would command the assistant with its
own words, so the trigger is suppressed while playback is active. That is not
a wall in front of the user: `VoiceBargeInPolicy` halts playback the moment
they speak, so `isSpeaking` is already false when their transcript arrives.

`handleBackendSegments` now reads `isSpeaking` once, before the barge-in check.
Reading it afterwards reports false for the very segment that stopped playback.

Verification:
- xcrun swift test --package-path Desktop --filter
  'WakeWord|LocalTranscriptionEndpoint|VoiceBargeIn|LocalTranscriptionDuplicate'
  -> 51 tests, 0 failures
- Live on a named dev bundle, real microphone, on-device Parakeet:
  "Omi, what time is it now" -> answered aloud (the mic transcribed Omi's own
  reply back: "It's 8 57 p.m. on Sunday, August 23rd, 2026, in India, IST"),
  then "Omi, and what about tomorrow" -> "Tomorrow is Monday, August 24, 2026".
  A bare anaphoric follow-up resolved against the previous answer, and the
  telemetry surface moved from floating_text to floating_voice with a tts_start
  stage in both traces.
- A six-turn spoken session ordering food held one conversation throughout
  (cache_read 29953 -> 40968 -> 52003).

Failure-Class: none

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

* fix(desktop): stop ambient capture treating Omi's own voice as the user

Omi speaks into a room Omi is also recording. Ambient capture returns the
playback as a transcript segment attributed to the primary speaker — observed
live, `Transcript [ADD] Speaker 0: It's 8 57 p.m. on Sunday...` was Omi, not a
person. Four consumers then act on it as if the user had spoken:

- barge-in halts the very playback that produced it. Three times in one
  six-turn session, which is why a long answer stops partway: "I can help, but
  I need two details first. 1. Maya's delivery address" and no item 2.
- the wake word can be commanded by an answer carrying the wake phrase
- the conversation record gains speech nobody said
- memory extraction reads it

One guard at ingest, where all four route through, rather than four guards.

Dropping the whole segment is not enough. While Omi is talking there is no
pause to close the transcription window on, so a barge-in lands inside the same
window as the playback — measured: `1. Ganges Ganga, India's most sacred river,
and a vital water source. Omi, stop that and tell me the time is.` One
9-second window, two speakers. Discarding it would eat the interruption, which
is the one utterance that must never be lost. `VoicePlaybackEchoPolicy`
consumes the playback off both ends and keeps what the user said in between,
sliced from the original string so the punctuation the wake-word parser reads
survives.

Matching is loose about wording and strict about length, because speech-to-text
does not return what the synthesiser was handed: "Omi open my tasks now" came
back as "Only open my tasks now", "8:57 PM" as "8 57 p.m.", and a numbered list
goes out as "1." and returns as "One." It errs toward not-echo throughout — a
missed echo costs what the app already does today; a false echo deletes
something the user said.

Verification:
- xcrun swift test --package-path Desktop --filter
  'VoicePlaybackEcho|WakeWord|LocalTranscription|VoiceBargeIn' -> 68 tests,
  0 failures. Every echo string in the new suite was captured live.
- Full desktop suite: 5790 tests, 2 failures, both pre-existing order
  dependence unrelated to this change (FloatingBarNotificationPreviewPolicy,
  RewindCaptureExclusionGeneration) — they fail identically on the merge base
  under the same filter and pass in isolation.
- Live, named dev bundle, real microphone, wake word answering aloud:
  "Omi, list five major cities in India with one short fact each" dropped seven
  echo segments across both the microphone and system-audio channels, logged
  zero barge-ins where the previous build logged three, and spoke all five
  cities through to "Five, Chennai, a key center for automobiles, culture, and
  South Indian cinema" instead of stopping at the first.
- Speaking over a live answer still interrupts it and still dispatches:
  `WakeWord: submitting 'stop that and tell me the time instead.'` with
  `Transcription [BARGE-IN]` on the same segment.

Failure-Class: none

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

* fix(desktop): recognize a wake word spoken after something else, and stop deleting the user's speech

Three defects, all from one live session of twelve spoken attempts of which
only four fired.

The wake phrase had to open the segment. Windows now close on the speaker's
pause rather than a fixed boundary, so a segment is no longer one utterance and
whatever was said in the same breath shares it: `It's not working man. Omi what
time it is?` carried a literal wake phrase and a valid command and matched
nothing. The parser now also tries each sentence inside the segment. A sentence
boundary, not any position — the phrase has to *open* an utterance, which is
the same evidence class the punctuation-break rule already uses and keeps
`I told Omi to order food` from parsing to "to order food".

Echo suppression deleted something the user said. `Sorry my mistake it's
taking` was dropped as playback. Two causes: one shared deadline kept the whole
300-word history alive and refreshed it on every chunk, so several turns of
speech stayed matchable at once and a few hundred words of ordinary English
align with almost any short sentence; and discarding a segment did not require
the match to actually cover it. Words now expire individually after 15s — an
echo arrives a second or two behind the audio, so that is all it has to outlive
— and a whole-segment drop requires 0.8 coverage, which real echoes measured
0.80–1.00 against. The same eviction also explains a leak in the other
direction: Omi's own error copy, "Omi's AI service didn't respond...", was
heard back, parsed as a wake word, and submitted as a command, twice.

The wake word's own "assistant is speaking" guard is removed. It blocked a real
barge-in — `Omi you are not picking my messages now`, spoken while Omi was
talking, was refused and had to be repeated. Whether Omi is speaking is not the
question; whether *this segment* is Omi is, and `VoicePlaybackEchoPolicy`
answers that directly.

Verification:
- xcrun swift test --package-path Desktop --filter
  'WakeWord|VoicePlaybackEcho|LocalTranscription|VoiceBargeIn' -> 70 tests,
  0 failures
- Live, named dev bundle, real microphone, all four in one session:
  "It's not working, man. Omi, what is today's weather?" ->
  `WakeWord: submitting 'what is today's weather?'`;
  "Sorry my mistake it's taking" reached the transcript instead of being
  dropped; the spoken time answer was dropped as echo on both the microphone
  and system-audio channels; and "Omi's AI service didn't respond..." was
  dropped instead of commanding the assistant.

Failure-Class: none

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

* fix(desktop): anchor echo matching to the sentence, not to the ends of the history

Two failures from a twenty-utterance measurement run, both from the same
assumption: that an echo begins where the playback history begins.

Parakeet returned "Your current save task appears to be testing the protocol
product." twice in one segment, and the second copy survived as if the user had
said it — the backward walk started at the end of the history, and Omi had kept
talking past that sentence. Both walks now try every position where the
utterance's first word occurs and take the best alignment, so an echo of
something said in the middle of an answer is still recognised as one. That also
recovers a command spoken over playback: the user's words are isolated between
the matched runs instead of being dropped with them.

Speech-to-text mangles the tail of a long answer, so it stops matching what was
synthesised and was kept as the user's words: Omi's own "Based on today's
recording active for roughly about one hour" reached the transcript as
speech the user never said. A garbled continuation runs straight on from the
matched text; a person interrupting starts a new sentence, and the recognizer
marks that, so a surviving residue now has to begin one.

A single word matching on its own is coincidence, not the echo continuing —
"the" and "and" occur in every answer. Committing the match on one word let the
backward walk eat "the time" off the end of a user's command; two in a row is a
run.

Verification:
- xcrun swift test --package-path Desktop --filter
  'VoicePlaybackEchoPolicy|WakeWord|LocalTranscription|VoiceBargeIn'
  -> 74 tests, 0 failures. The four new cases are the captured strings above.
- Twenty spoken utterances through the real microphone across five voices, the
  same script and 16s pacing as the run before this change:
  10 of 20 dispatched, against 9 of 20; the two segments where Omi's own words
  had been kept as the user's are now correctly dropped (0 of 20, was 2 of 20);
  and two commands that the previous build lost inside a dropped echo window
  were recovered by residue extraction ("Your ten most recent memories. Only
  open my rewind time line." -> "Only open my rewind time line.").
  Every remaining miss is the recognizer writing something other than the wake
  phrase, five of them "Only".

Failure-Class: none

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

* fix(desktop): stop "ok"/"okay" corroborating a misheard wake phrase

Raised in review: a homophone needs a punctuation break to fire on its own, but
a greeting prefix waived that — and the greeting list included "ok" and "okay".
So "okay oh me and my friend went hiking" fired with the command "and my friend
went hiking", which is the exact false positive the punctuation rule exists to
prevent.

"hey" is a vocative: "hey <name>" addresses someone, and nobody produces it in
front of a misheard word by accident. "ok" and "okay" are discourse markers
people open sentences with constantly. Only "hey" corroborates a homophone now.
Both still corroborate the literal spelling, where the phrase is already the
evidence.

This only ever makes the wake word fire less.

Verification:
- xcrun swift test --package-path Desktop --filter WakeWord -> 33 tests,
  0 failures, including the reviewer's sentence in both "ok" and "okay" forms
  and the two forms that must still fire.

Failure-Class: none

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

* feat(desktop): route a wake word into the realtime session behind a flag

Maintainer request: try the realtime model instead of the text path, on the
grounds that it should be a more natural interaction. Off by default —
`wakeWordUsesRealtime` — so the measured text path is untouched and the two can
be compared on the same machine.

Detection does not move. Both paths read the same ambient transcript, so this
changes nothing about the 60% recognition ceiling documented earlier. What
moves is the exchange: the model speaks its own answer instead of TTS reading a
text reply, and the session keeps conversational context across turns.

Push-to-talk owns a physical hold, so it streams audio and commits on release.
A wake word owns no hold and its audio is long gone by the time the transcript
fires, so it mints an `.automation` turn — the shape the headless harness
already uses — and hands over the transcribed command.

Two ordering constraints, both found by running it:

- The Gemini activity window is opened by `beginInputTurn`, which runs inside
  `commitTurn()`, not at `beginTurn`. Waiting for the window before sending
  simply times out; the send has to happen first and be flushed by the commit.
  Before this was understood the text sat in the buffer and no answer came.
- A turn with no route is refused at commit as a stale physical commit
  ("rejected duplicate/stale physical commit before provider side effects"), so
  `.selectRoute(.hub)` has to be published before `beginTurn`.

Gemini also rejects a pure-text activity window with a 1007 precondition, so
two 100 ms silence frames open it, matching the harness.

Verification:
- xcrun swift test --package-path Desktop --filter
  'WakeWord|VoicePlaybackEcho|Realtime' -> 306 tests, 0 failures
- Live on a named dev bundle, real microphone, flag on:

    WakeWord: submitting 'tell me one interesting fact about the ocean.'
    RealtimeHub[gemini:gemini-3.1-flash-live-preview]: turn begin (activityStart)
    RealtimeHub[gemini:gemini-3.1-flash-live-preview]: wake word command sent (45 chars)
    Transcript [ADD] Speaker 0: The pressure at the bottom of the ocean is so intense...

  The last line is the microphone hearing Gemini speak its own answer. ~1.2s
  from end of speech to the command reaching the model. A second command 51s
  later ran the same path, so the turn terminalizes and does not wedge the
  trigger behind `activeTurnID`.

Known gap on this path: `VoicePlaybackEchoPolicy` does not cover it. The hub
plays its audio natively rather than through `FloatingBarVoicePlaybackService`,
so nothing records what was said and Gemini's spoken answer lands in the
transcript as the user — visible in the trace above. The same defect the echo
policy fixes for the TTS path, reappearing on this one. Left as a known gap
while the path is off by default and under evaluation.

Failure-Class: none

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

* fix(desktop): give the realtime wake-word turn a real user message and a silent echo

Two defects in the realtime path, both visible in the chat panel and both found
by watching it rather than by reading the code.

The assistant's own answer was recorded as the user. `VoicePlaybackEchoPolicy`
reads what this app has recently said out loud, and that history was only ever
written by `FloatingBarVoicePlaybackService`. The realtime session plays its
audio natively, so nothing recorded it, the microphone heard it, and ambient
capture attributed Gemini's reply to the user — the same defect the echo policy
exists to prevent, reappearing on a path it could not see. Text emitted by the
session is now recorded there too. It arrives as a stream and providers differ
on whether each event is the new fragment or the whole reply so far, so only
the part that extends what was already recorded is kept: a padded history
matches more of what a person says, which is the direction that deletes real
speech.

The user's message was whatever the provider imagined. A wake-word turn hands
over already-transcribed words and only enough silence to satisfy Gemini's
non-empty activity window, so the provider has no user speech to transcribe and
journals its own hallucination. Live, `¿Qué es el número de serie?` appeared as
the user's message on two consecutive turns; nobody said it. What was asked is
not in doubt, so it is supplied rather than recognised, reusing the existing
transcript-override policy through a production-scoped property that push-to-
talk clears alongside the test one.

Verification:
- xcrun swift test --package-path Desktop --filter
  'WakeWord|VoicePlaybackEcho|Realtime|LocalTranscription' -> 324 tests,
  0 failures
- Live on a named dev bundle, real microphone, realtime path on:

    WakeWord: submitting 'tell me one short fact about the moon.'
    RealtimeHub[gemini]: wake word command sent (38 chars)
    Transcription [ECHO]: dropped Omi's own playback heard back:
      The moon is slowly moving away from Earth by about an inch a...

  The echo line was a `Transcript [ADD] Speaker 0` before this change. On the
  following turn the chat panel showed "tell me one short fact about volcanoes."
  as the user's message where the previous turn still shows the Spanish
  sentence.

Known limit, not fixed here: the provider forms its own input transcript from
the silence regardless of what we journal, and Gemini Live keeps session
context, so a hallucinated transcript persists — after the Spanish turns the
model kept offering to reply in Spanish. Supplying the text fixes the record,
not the model's memory of the turn. The real remedy is a text turn that opens
no audio activity at all (`clientContent` rather than `realtimeInput`), which
is a wire-format change and out of scope while this path is off by default.

Failure-Class: none

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

* fix(desktop): warm the realtime session before a wake-word turn

The warm session tears itself down after an idle period, so a wake word
arriving in a quiet stretch found nothing to talk to and fell through to the
chat path. Observed live as the third of three consecutive commands answering
in a text box while the first two spoke aloud.

Warming and waiting briefly before minting the turn also avoids creating a turn
that cannot be used, which would otherwise leave `activeTurnID` set and make
`defaultIsConversationActive` refuse every later wake word.

Verification:
- xcrun swift test --package-path Desktop --filter
  'WakeWord|VoicePlaybackEcho|Realtime|LocalTranscription' -> 324 tests,
  0 failures
- Live on a named dev bundle, real microphone: three consecutive commands
  ("how are you today", "tell me one fact about rivers", "name one famous
  painter") each reached `wake word command sent` with no fallback, where the
  previous build dropped the third to the chat path.

Failure-Class: none

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

* feat(desktop): answer a wake word from the notch instead of opening a panel

Hands and eyes are elsewhere — that is the premise of a wake word — so growing
the bar into a response panel covered a fifth of the screen for no one's
benefit. The response glow already signals that Omi is working and the answer
is spoken, so the exchange is recorded without being put in front of the user.
The panel remains the fallback when the hands-free path cannot run.

Two things made this harder than it looks, both found by instrumenting rather
than reading:

The panel is opened from four places — the query starting, the answer arriving,
the content-height observer, and the agent-chat resize. Suppressing any one of
them left it showing, because whichever was missed put it straight back. The
guard is now at `resizeAnchored`, the single point they all reach, and blocks
only expansion so collapsing back to the pill still works.

`prepareVisibleQueryState` runs twice for one query: once from `routeQuery` to
show the thinking state, once from `sendAIQuery`. A one-shot latch consumed by
the first call meant the second reset the flag and reopened the panel —
`presentsSurface=false` immediately followed by `presentsSurface=true` in the
same millisecond. It may now only ever set quiet; the entry points that do want
a panel (typed follow-ups, `submitSpokenCommand`) clear it.

Verification:
- xcrun swift test --package-path Desktop --filter
  'WakeWord|VoicePlaybackEcho|FloatingControlBarState|Realtime' -> 335 tests,
  0 failures
- Live on a named dev bundle, real microphone, two consecutive commands:
  the bar stays at 62px throughout (`resizeToFrame to (351.0, 62.0)`), no
  `430x381` expansion, and both answers were spoken — the microphone
  transcribed Omi saying "The capital of Portugal is Lisbon." and "The sun
  contains about 99.86% of the total mass in our solar system."
  The previous build logged `resizeToFrame to (430.0, 381.0)` on every command.

Failure-Class: none

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

* test(desktop): repin the beginVisibleMainQuery contract to its wrapped signature

ccaaebb7 added `presentsSurface: Bool = true`, which pushed the parameter list
onto its own line under swift-format. The contract test pinned the declaration
as one string:

    func beginVisibleMainQuery(_ message: String, fromVoice: Bool, animated: Bool = true)

so it stopped matching and took both required Desktop Swift checks red. The
production behavior was never affected -- the view's call site still passes
defaults.

Pinned in two parts so a wrap cannot break it again, and `presentsSurface:
Bool = true` is now pinned with the rest: that default is what keeps a typed
send presenting the panel, which is the load-bearing behavior of this surface.

Checked the pin still guards rather than passing vacuously -- flipping the
expected default to false fails the assertion at line 1088; restoring it
passes. AgentPillLifecycleTests 84/84.

Failure-Class: none

* feat(desktop): recognize the wake word on the default on-device path

The wake word is only as good as the recognizer that hears it, and on the
default path the recognizer cannot be told its own name. Ambient transcription
runs on-device on Apple Silicon, and `AsrManager.transcribe(_:decoderState:
language:)` takes a language hint and nothing else — no keyword or vocabulary
parameter. The cloud lane does not have that problem: `/v4/listen` prepends
"Omi" to the STT keyword vocabulary server-side in
`backend/utils/listen_session_bootstrap.py`.

Measured on one machine, same script and voices, only the lane changed: the
phrase was usable in 12 of 20 utterances on-device against 19 of 20 on the
cloud lane. Seven of the eight on-device misses came back as "Only".

Two changes, both aimed at that gap.

`WakeWordSegmentParser` gains a third corroboration class. "Only" cannot ride
the existing punctuation-break rule: a scan of 1,919 stored local segments
found 15 sentence-initial "Only", every one a misrendered wake word, and not
one carried a break after it — they read "Only what is on my calendar", "Only
open my rewind timeline". The same scan found 8 ordinary uses of "only", all
mid-sentence. So `.commandHead` gates on what follows instead: an interrogative,
or a request verb aimed at the speaker's own things ("show me", "open my",
"remind me"). Every imperative reads fine under a restriction — "only do that
once", "only tell him if he asks" — but none of them ask for the speaker's own
calendar.

`AssistantSettings.wakeWordPrefersCloudSTT` is the opt-in for users who would
rather buy the remaining accuracy with cloud transcription. Off by default: it
trades on-device transcription for cloud transcription while the wake word is
enabled, which is a privacy and cost decision, not a technical one. FluidAudio
does ship term biasing, but only on `SlidingWindowAsrManager`, which is a
different streaming architecture and pulls a second set of CTC models — that is
the upgrade path out of this flag.

Verified on the running app through the hermetic capture seam, which reaches
`WakeWordService.observe` on the real path: 14 ordinary uses of "only" injected,
zero fired; 3 verbatim misrenderings injected, 3 parsed. The cloud opt-in was
confirmed live by the lane actually switching — `TranscriptionService:
Connecting to wss://api.omiapi.com/v4/listen` in place of on-device Parakeet.

Tests: 26 in WakeWordSegmentParserTests, 14 in STTSessionStateTests, and the
full 716-suite run, all passing.

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

* fix(desktop): stop a re-delivered segment from interrupting the answer to it

A backend segment is re-delivered as it grows, in place and under one id, and the
re-delivery arrives whether or not the speaker added anything. `VoiceBargeInPolicy`
treated any non-empty user text as speech, so an unchanged re-delivery counted as
the user talking over the assistant.

Observed live: the second turn of a conversation was cut off 4.4s into playback by a
re-delivery of the very segment that asked the question, byte-identical to the copy
already stored.

    13:16:41.117  Chat response complete
    13:16:45.491  BARGE-IN: User spoke mid-playback; interrupting voice output
    13:16:45.501  Transcript [UPDATE] Speaker 0: I'm fine. What about you? Omi, I'm fine. What about you?

The first turn escaped only by timing — its answer finished speaking before the
re-delivery landed. From the second turn on, the re-delivery falls inside the playback
window every time, which is why it reads as "the second question always gets cut off".

`shouldInterrupt` now takes the text already stored for that segment id and interrupts
only on what the segment gained. Growth that adds nothing but punctuation or spacing is
the recognizer tidying up, not speech. A segment that no longer extends what was stored
counts as new in full: there is no way to tell a revision from a continuation, and
missing a real barge-in is the worse failure.

Failure-Class: none

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

* fix(desktop): count a garbled word inside an echo as part of it

Omi's own answer was reaching the transcript as a second speaker, so the reply was
heard once from the speakers and again as if a person had said it.

`walk` only commits a matched word once two match in a row — a guard that exists
because a single common word ("the", "and") matching by coincidence once let the
backward walk eat "the time" off the end of a user's command. But an utterance's
closing word can never reach two-in-a-row when the word before it was garbled, so
the last word of a short answer was permanently uncountable.

Measured live: Omi said "I don't know the details of Wake Word yet." and the
microphone returned "WakeMore" for the product name. The trailing "yet" followed
that one mismatch and could not commit, so coverage came out 6 of 8 = 0.75, under
the 0.80 floor, and the segment was kept.

    19:37:59.241  Transcript [ADD] Speaker 1: I don't know the details of WakeMore yet.
    19:38:00.576  ECHO: dropped ... I don't know the details of WakeMore yet. Feature you design

Confirmed against the real strings before and after: `keep` became `drop` for every
rendering of what was actually spoken.

The final token may now commit on a single match, but only after `minimumWordCount`
words have already matched in a run, so a lone coincidental word still cannot start
or extend an echo. Forward walk only: the reversed walk measures the playback that
follows a barge-in, where the "final" token is the first word the user said, and
committing it on one match would eat the start of the interruption.

Failure-Class: none

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

* chore(desktop): drop the changelog fragment that already shipped

`20260823-local-transcription-pause-endpointing.json` is byte-identical to the entry
released in v0.12.221, which shipped through #12181 when pause endpointing was split
off this branch. Leaving it here would re-announce an already-released change at the
next consolidation.

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

* fix(desktop): stop an abandoned hands-free command from quieting the next query

`suppressNextVisibleSurface` is a one-shot latch consumed only by
`prepareVisibleQueryState`. Three exits from `openAIInputWithQuery` return before
reaching it — no window, no active provider, and the `.voiceOnly` branch, which
renders nothing and so never consumes it at all. A wake word that fires while the
bar is torn down or unprovisioned therefore leaves the latch set, and the next
typed question is silently answered in the notch.

Clear the latch on every exit that abandons the query.

Separately, `beginVisibleMainQuery` only ever *sets* `answersQuietly` (clearing
there would let the second `prepareVisibleQueryState` call undo the first), so the
reset has to live at the query entry points. The closure re-wired in
`openAIInputWithQuery` does it; the default wiring installed at setup did not, so a
quiet wake-word answer leaked its silence into the next typed question on that path.

Verification: `swift build` in `desktop/macos/Desktop` — clean. No behavioral test
added: both paths run through `FloatingControlBarWindow` (an NSPanel) with no
injectable seam, and the existing coverage here is source-scrape pins, which
AGENTS.md calls a static tripwire rather than behavioral coverage.

Failure-Class: none

* test(desktop): re-pin the quiet-answer latch after the typed-send rewrite

My merge resolution took main's side of `AgentPillLifecycleTests.swift` wholesale.
That was right for the file — main retired `AskAIInputView` and the test source-pinned
against it — but it silently removed the only guard this feature has. Nothing in the
678 test files on that head pinned `presentsSurface`, `answersQuietly`, or
`suppressNextVisibleSurface` any more, so the wake word's notch behavior could be
refactored away without failing anything.

The replacement pins the same contract against `FloatingControlBarWindow.swift`, where
the logic actually lives, rather than a view that has now been retired twice:

- `presentsSurface` defaults true, so an ordinary typed send presents the panel
- `beginVisibleMainQuery` only ever sets quiet, never clears (it runs twice per query)
- the one-shot latch is armed by the wake word and consumed by the visible path
- all three abandoning exits clear it, asserted by count
- both `onSendQuery` wirings reset `answersQuietly`

Verification: passes on this head. Mutation-checked rather than assumed — deleting the
`.voiceOnly` latch clear fails it with `("2") is not equal to ("3")`, and restoring it
returns green.

Failure-Class: none

* docs(desktop): name the real path that opens the Gemini activity window

Review on #11801 caught the comment in runWakeWordTurn still pointing at
`beginInputTurn` as the thing `commitTurn()` calls. Main's voice-handoff rework
moved that: `commitTurn()` now reaches the window through
`commitClaimedHubInput` -> `beginLiveInputTurn`, the controller wrapper, which
then calls the session's `beginInputTurn`.

The old wording was not wrong about which primitive opens the window, but a
reader following it into `commitClaimedHubInput` would not find the name it
gave. Both names are now in the comment, in the order the calls actually happen,
so neither reads as stale next time the wrapper is renamed.

Comment only; no behavior change. 339 tests, 0 failures across the WakeWord,
RealtimeHub, VoicePlaybackEcho and Interject suites.

* fix(desktop): end a quiet wake-word answer's latch with the answer, not never

The wake word's quiet answer matched PTT's notch geometry while it ran — the
same 386x62 glow island, the same spoken delivery, the same idle settle — but
the state it left behind did not. Two leaks, both measured live on a named
bundle (omi-wwnotch-11801, head b82eff7157):

1. The answer's own presentation sites — the sendAIQuery streaming sink and
   the completion tail — called present(.mainResponse) while the quiet latch
   blocked only the resize. The bar settled with showingAIConversation=true
   against a 362x62 island: the hover menu was dead
   (NotchHoverSurfacePolicy.allowsMenu), notification cards stopped mounting
   (the view gates them on !showingAIConversation), and #13337's surface floor
   deferred as conversationOpen indefinitely. PTT never leaves this state.

2. answersQuietly outlived its query. Nothing cleared it after the answer
   completed — the typed-send resets the PR pinned are automation-only now —
   so the next agent chat opened through the pills-observer fallback
   (430x148, resizable=false) instead of its own surface (430x400,
   resizable=true; the clean-state counterfactual on the same bundle).

The fix keeps the latch per-query at the same choke points the PR already
used: the quiet answer's two presentation sites now skip presenting entirely
(like their adjacent resize guards), and present(_:) — the single authority
for opening a surface — clears quiet, so an agent chat, a tapped
notification, or a restored conversation can never inherit a dead answer's
silence. The latch cannot clear mid-answer: the quiet path presents nothing.

Verification:
- desktop/macos/Desktop: xcrun swift build -c debug — clean.
- xcrun swift test --filter FloatingControlBarStateTests|AgentPillLifecycleTests
  — 114 tests, 0 failures (incl. the new behavioral
  testPresentingAnOpenSurfaceEndsAQuietAnswer and the extended latch tripwire).
- xcrun swift test --filter WakeWord|VoicePlaybackEcho|VoiceBargeIn|
  STTSessionState|LocalTranscription — pass; FloatingBarSurfaceFloorTests|
  VoiceTurnCoordinatorTests|PushToTalk — 94 tests, 0 failures.
- ./scripts/agent-logic-harness.sh --swift-only — passed (158.7s).
- swiftlint 0 violations; pinned swift-format adds 0 new findings (175
  pre-existing on the synced head, unchanged); check_desktop_test_quality.py
  at baseline.
- Live, named bundle omi-wwnotch-11801 (worktree
  pr-11801-sync-20260910): wake word via the capture seam answered quietly —
  submit glow 386x62 at 17:30:46, settle 362x62 with showingAIConversation
  false and surfaceFloorSatisfied true — then open_seeded_subagent produced
  resizeToFrame to (430.0, 400.0) resizable=true (pre-fix: 430x148
  resizable=false). A second wake word stayed quiet, and a PTT turn
  (ptt_manager_turn) kept its 474x62 → 386x62 → settle lifecycle with
  conv=false.

* docs(desktop): say the parser recovers an "Only" misrendering

The resolveMode doc comment and its test's doc comment both said the
on-device "Only" misrendering "cannot be accepted as a rendering". The
same commit that wrote that (21f1e50ff2) also added
WakeWordSegmentParser.commandShapedRenderings, which does accept "Only"
when a command follows it (an interrogative, or a request verb aimed at
me/my), pinned by the "Only" cases in WakeWordSegmentParserTests.

Both comments now describe what the parser does, and say the 12 of 20
on-device measurement was taken before that recovery existed.

Comment-only change, no behavior change.

Verification:
- desktop/macos/scripts/swift-format-wrapper.sh lint on both files:
  exit 0, no findings.

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

* fix(desktop): stop Omi's own first words from cutting off its answer

Live, on-device lane, noisy room: "Omi, tell me a fun fact" was answered
"Fun fact: A day on Venus is longer than a year on Venus—it rotates so
slowly…", and playback stopped after the first sentence. The microphone
window closed on the answer's first two words, and `Fun fact.` reached
barge-in as the user speaking:

  14:43:13.369 Transcription [BARGE-IN]: User spoke mid-playback;
               interrupting voice output
  14:43:13.375 Transcript [ADD] Speaker 0 [200.0s-210.0s]: Fun fact.

VoicePlaybackEchoPolicy.classify will not attribute fewer than four words
to playback, because deleting a short utterance from the transcript risks
deleting the user. Barge-in carries the opposite risk, so it now also asks
whether an utterance under that floor is an exact, contiguous run of what
playback said in the last few seconds. Transcript handling is unchanged.
A short interruption that is not a run of the answer ("Stop.", "Wait,
what?"), or answer words out of order, still interrupts.

Verification:
- Xcode 26.6 (17F113): VoiceBargeInPolicyTests (16, six new from the live
  strings), VoicePlaybackEchoPolicyTests (23), WakeWordServiceTests (12):
  51 tests, 0 failures.
- Mutation: with the new check replaced by `return true`, exactly the two
  live-case tests fail (VoiceBargeInPolicyTests.swift:121, :127).
- Live, named bundle, capture_test_transcript seam, real playback:
  before the fix, injecting the answer's first two words during playback
  interrupted it 3 of 3. After the fix, injected once playback had
  started speaking: no interruption 3 of 3, and a "Stop." injected right
  after interrupted 3 of 3. Same result on an instrumented build that
  logged spokenWords=15/21/28 at each check.
- swift-format lint clean; check_desktop_test_quality.py at baseline.

Failure-Class: none

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

* fix(desktop): hear "Oh me", "Owe me" and "How me" said without a pause

Live, on-device lane, real voice: 3 of 6 spoken commands were dropped
without a trace. The recognizer wrote the wake word as

  Oh me what time it is.
  Owe me what time it is.
  How me what day is it today?

"oh me" only counted with a punctuation break after it, and "owe me" and
"how me" were not accepted at all.

The stored local segments show this is the common case, not a one-off:
of 1,961 unique segments, 29 distinct sentences open with "oh me",
"o me", "owe me" or "how me", every one of them the user addressing Omi,
none of them ordinary speech. 15 have no break after the phrase, so all
15 were dropped.

These renderings now join "only" in commandShapedRenderings: said
without a pause, they count when what follows opens like a command (a
question, or a request aimed at the speaker's own things). 14 of the 15
pass. The one that does not is "O me order Thai food for Maya.", because
"order" is not a self-addressed request. "oh me" and "o me" are still
homophones, so with a comma they need no command shape, as before.
"oh my" stays out: the same scan found it once, as "Oh my god."

Verification:
- Xcode 26.6 (17F113): WakeWordSegmentParserTests (28, two new from the
  live strings), WakeWordServiceTests (12): 40 tests, 0 failures.
- Mutation: without the four new renderings, only the live-miss test
  fails (7 of 7 strings). With the command-head check switched off, the
  new ordinary-speech test fails along with four existing ones.
- Live, named bundle built with this commit and the next (which only
  adds a log line), capture test seam (speaker 0, the path live speech
  takes): "Owe me what time it is.", "How me what day is it today?",
  "Oh me what time it is." and "O me who am I?" each fired and were
  answered correctly, 5.5-8.9 s after the command. "O me order Thai food
  for Maya.", "How me and my brother met is a long story." and "Owe me a
  favor and we're even." did not fire and never reached the chat.
- swift-format lint clean; check_desktop_test_quality.py at baseline.

Failure-Class: none

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

* fix(desktop): log a wake word the parser turned down

A sentence that opened with a rendering of the wake phrase but carried
no accepted command left no trace, so a missed "Omi" looked exactly like
one that was never said. Finding the misses fixed in the previous commit
took a scan of the stored transcripts; the app log had nothing.

WakeWordService now logs the rendering, and only the rendering, never
the words after it:

  WakeWord: ignored — 'o me' opened a sentence, but no command followed it

The rejections that were already logged (disabled, busy, not the user,
dedup, too short, cooldown) are unchanged.

Verification:
- Xcode 26.6 (17F113): WakeWordSegmentParserTests (30, two new),
  WakeWordServiceTests (12): 42 tests, 0 failures.
- Mutation: with openingRendering never naming anything, only its test
  fails (2 assertions).
- Live, named bundle, capture test seam: "O me order Thai food for
  Maya.", "How me and my brother met is a long story." and "Owe me a
  favor and we're even." each logged the line above with 'o me',
  'how me' and 'owe me', and did not fire.
- swift-format lint clean; check_desktop_test_quality.py at baseline.

Failure-Class: none

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

* chore(desktop): fold the wake word's changelog entries into what ships

The branch carried seven entries for one unreleased feature. Five of
them described states nobody outside this PR ever saw: answers that
opened a panel before they moved to the notch, a realtime path behind a
setting with no UI, and a fix for a notch bug that only existed on this
branch. The release notes would have listed the feature and then
corrections to it.

Two entries remain: the wake word as it ships, and the echo fix, which
also changes push-to-talk answers heard during ambient listening.

Verification: desktop-changelog.py validate OK; check-desktop-changelog.py
finds the fragment.

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

* test(desktop): inject wake-word settings instead of mutating shared defaults

main's desktop-test-quality ratchet caps direct UserDefaults.standard mutations
in tests at 323 -- #13260 showed suites racing on shared auth domains -- and
WakeWordServiceTests added ten, all in setUp/tearDown plus one in the disabled
test. That blocked the push at 333.

The test wrote to .standard only because WakeWordService read its settings
through AssistantSettings.shared, which reads .standard directly. The service
already injects `now` and `onTrigger` as closures, so its three settings now
follow the same pattern: isEnabled, wakePhrase and cooldown, each defaulting to
the same AssistantSettings.shared property read at call time. Production
behaviour is identical. The test injects plain values and touches no defaults.

Not an integration-boundary waiver: this suite exercises parsing, triggering
and cooldown, not the defaults integration, so the annotation would have been
the wrong escape hatch.

Verified: desktop-test-quality back to the 323 baseline with zero sites in this
suite; swift build clean; WakeWordServiceTests 12 passed. Mutation-checked --
making the service ignore the injected isEnabled fails the disabled-setting
test, so the injection is what the suite actually exercises.

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

* fix(desktop): close wake-word review gaps

* fix(desktop): hand a wake word command back when the realtime commit is not accepted

runWakeWordTurn waited only for a session object, and discarded commitTurn's
result before returning true. A reconnecting or replaced transport keeps the
session but defers the commit, replaying buffered audio only, so the command
text was lost while WakeWordService believed it was handed off and skipped
the chat fallback.

- Wait for a usable transport with waitUntilActive, not just a session.
- Treat the command as handed off only when the commit is accepted or
  already owned; otherwise cancel the turn and return false so the caller
  answers on the chat path.

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

* chore(api): regenerate client method totals after concurrent merges

#20003, #19815 and #15669 each regenerated the clients against their own
base and merged cleanly, leaving main's "Total: 478 client methods" header
one short of the 479 the spec now generates. The knowledge-ledger client
schema contract compares the checked-in artifacts and failed on every branch
that merged main. Regenerated; only the five total lines change.

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

* docs(desktop): track wake word UI evidence in the repository layout

Main now requires UI screenshots for changed UI source under
.agent-artifacts/ui-evidence/<pr>/ with an evidence.json manifest. Copy the
existing before/after screenshots from the docs-assets branch unchanged.

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

* fix(desktop): keep wake word commands with the account that spoke them

The realtime path waits up to five seconds for its transport, then sends the
command or falls back to chat. An account switch in that window could send
account A's command as account B. Capture the runtime-owner authorization
when the wake word fires and re-check it after the warm-up, before the
command is sent to the realtime session, and before the chat fallback.

Failure-Class: none

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

* fix(desktop): carry the wake word's account through the chat route

The default (non-realtime) wake-word route went through the floating bar's chat
path, which can queue a command behind an in-flight reply and dispatch it later
with no account check. Pass the authorization snapshot captured when the wake
word fires through submitHandsFreeCommand/submitSpokenCommand, sendFollowUpQuery,
openAIInputWithQuery, routeQuery and the pending follow-up queue, and re-check
it at each send (dispatchChatQuery and the direct sendAIQuery hop). Other
callers pass no snapshot and are unchanged.

Failure-Class: none

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

* fix(desktop): scope wake-word requests through the bar's queue and latch

- HandsFreeRequest carries the speaking account and a request id through the
  chat route in place of a bare snapshot.
- The pending follow-up becomes RequestBoundSlot: a queued hands-free query is
  handed out at most once, and only while its account is still current
  (including after a same-account sign-out and sign-in).
- The global "next query is quiet" flag becomes QuietSurfaceLatch, armed and
  consumed per request. A request rejected before presenting releases only its
  own arm, so it can no longer hide the next typed answer, and an older request
  can never clear a newer one's.
- After the awaited realtime send, WakeWordSendOutcome re-checks the account
  and the turn: a stale completion neither commits nor cancels a replacement.

Failure-Class: none

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

* test(desktop): re-pin the quiet-answer latch to the request-scoped QuietSurfaceLatch

---------

Co-authored-by: Claude Opus 5 <[email protected]>
Co-authored-by: David Zhang <[email protected]>
Co-authored-by: David Zhang <[email protected]>

This branch was successfully deployed

1 active deployment
staging - docs — 456d1e2c Deployed Oct 5, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Backend Task (python) positive-signal Automation verified a genuine fix/quality contribution security-review Touches auth, provider routing, secrets, or security-sensitive surfaces

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Follow up after canonical memory rollout: safe MCP People/entity cleanup tools

4 participants