Skip to content

security: remove screen activity cloud egress - #11018

Draft
undivisible wants to merge 12 commits into
mainfrom
security/transport-screen-egress
Draft

undivisible wants to merge 12 commits into
mainfrom
security/transport-screen-egress

Conversation

@undivisible

@undivisible undivisible commented Aug 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Remove the desktop screen-activity cloud sync path and its server-side route surface.
  • Regenerate the app-client OpenAPI artifact from the current source.
  • Keep cloud screen-activity chat tools fail-closed and update focused tests and release metadata.

Verification

  • backend/.venv/bin/python -m pytest backend/tests/unit/test_screen_activity_tools_cloud_unavailable.py backend/tests/unit/test_desktop_screen_crisp.py backend/tests/unit/test_mcp_oauth.py backend/tests/unit/test_mcp_sse_pagination_bounds.py — 31 passed
  • OpenAPI export --check passed
  • git diff --check

Review follow-ups (this push)

  • Fresh-VM health probe authenticated. AgentSyncService.remoteDatabaseIsAbsent now sends the VM token as both the /health?token= query and Authorization: Bearer header, matching the schema-recovery probe and the backend's new /health auth requirement. The cursor-reset regression test asserts both auth forms on the probe (it fails if the token is missing). This fixes the replacement-VM recovery path where a fresh/reaped VM was never detected and old cursors silently suppressed the sanitized non-screen resync.
  • Screen-activity drain test passes the fast-unit duration guard. The old test imported database.screen_activity + database.vector_db (heavy Pinecone) inside the test body to patch functions the drain route never calls; CPU time blew past the 0.12s guard. The tombstone route returns a fixed payload and imports neither module, so the test now asserts the drain response and a labelled static tripwire that the router does not import the persistence layers.
  • Merged origin/main into the branch (ratchet baselines, release-guard manifest, assistant-settings gate, OCR embedding/search conflict hunks resolved; chatFirstManifestDigest regenerated against the merged manifest). Branch is now MERGEABLE.

Review note

This PR is a draft because the broader outbound-egress primitive and the remaining MCP/app-tool endpoint audit are separate follow-ups.

Product invariants affected

  • INV-INT-1
  • INV-MEM-1
  • INV-AGENT-*
  • INV-AUTH-1
  • INV-CHAT-1
  • INV-NAV-1

Failure-Class: none

Review in cubic


Note

High Risk
Touches privacy-sensitive screen/OCR data with production deletion, OAuth scope retirement, and agent VM migration behavior; incorrect purge or scope handling could leak stale data or break connectors.

Overview
Screen activity no longer leaves the Mac. The desktop cloud sync service and POST /v1/screen-activity/sync are removed; agent VM sync drops screenshots/focus/observations tables, blocks related SQL, adds /purge-screen-activity, and strips cloud-side semantic search/recap tools. Desktop provisioning now purges the VM before sessions, skips DB upload when local screen tables exist, and removes semantic_search / hub search_screen_history from generated tool surfaces.

Cloud APIs and OAuth are tightened. MCP REST/SSE screen-activity reads return empty deprecated responses; screen_activity.read is retired at authorize/refresh/token issue. Cloud chat screen-activity LangChain tools always return a fixed “unavailable” message. A one-shot prod purge (Firestore + batched Pinecone) runs from the memory maintenance job; parity capture refuses screen/OCR surfaces.

Release guards now expect internal mobile builds via mobile_internal_build.yml + dispatch_mobile_internal_builds.py (Codemagic keeps app/** changeset guards only). Ready agent VMs with an older screenPrivacyVersion are stop/restarted to pick up the privacy migration.

Reviewed by Cursor Bugbot for commit 3b0bc4a. Bugbot is set up for automated code reviews on this repo. Configure here.

Line-Count-Exception: backend/routers/apps.py | 2515 -> 2521 | merge of origin/main: black reformatting of two HTMLResponse error returns (no semantic change)
Line-Count-Exception: desktop/macos/Desktop/Sources/ProactiveAssistants/ProactiveAssistantsPlugin.swift | 1786 -> 1789 | gate assistant frame processing behind the screen-privacy capability flag
Line-Count-Exception: desktop/macos/Desktop/Sources/Rewind/Core/RewindDatabase.swift | 3450 -> 3470 | fail-closed upload eligibility when screen tables exist

@mintlify

mintlify Bot commented Aug 2, 2026 •

Copy link
Copy Markdown

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

Project Status Preview Updated
omi 🟢 Ready View Preview Sep 25, 2026, 5:43 PM

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

@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 needs-tests PR introduces logic that should be covered by tests labels Aug 2, 2026

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tightening this privacy boundary — removing the desktop screen-activity cloud sync path and making the cloud chat tools fail closed is the right direction.

I found one blocker before this should move out of draft / toward merge:

  • The OAuth scope retirement is not complete yet. backend/database/mcp_oauth.py still includes screen_activity.read in SUPPORTED_SCOPES, so a legacy refresh request that echoes memories.read screen_activity.read can still rotate into a token whose scope includes the retired screen-activity scope. CI is catching the same issue in tests/unit/test_mcp_oauth.py::test_refresh_token_ignores_retired_scopes_echoed_by_client (expected 'memories.read', got memories.read screen_activity.read). Please make the token/grant normalization actually drop retired scopes on refresh and from newly issued/default-supported scopes as appropriate.

Also worth keeping this as human-maintainer reviewed given the security/privacy surface and the cross-cutting desktop + backend/MCP behavior change. The current macOS Swift gate is also red (looks like CanonicalGoalsStoreTests timed out in the isolated Swift suite), so please get the required checks green before marking it ready.

No concern that this is malicious; the intended product/security direction looks good, but the scope downscoping bug needs to be fixed first.


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

Copy link
Copy Markdown
Member

Additional automation note: this PR also updates the desktop's embedded Omi memory prompt in MemoryBankConnector.swift by removing the instruction for agents to call omi-memory__get_screen_activity. That does change AI/agent guidance exposed by the desktop app, but it appears consistent with retiring cloud screen-activity access and should reduce agents' attempts to call an unavailable/privacy-sensitive tool. Human maintainer review is still warranted because this is a user-data/privacy behavior change.


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

@undivisible
undivisible force-pushed the security/transport-screen-egress branch from 478a03b to 2bdce47 Compare August 2, 2026 12:33
@undivisible
undivisible marked this pull request as ready for review August 2, 2026 12:41
@cursor

cursor Bot commented Aug 2, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_f02a6fc6-4934-4b85-8747-6fbb8b4c4782)

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 27 files

Confidence score: 5/5

  • In backend/database/mcp_oauth.py, embedding scope-retirement policy inside _build_token_pair_writes can make future authorization changes harder to reason about or update, risking subtle mismatches in access control behavior over time—consider moving or documenting the policy boundary so it’s enforced consistently at the service layer.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="backend/database/mcp_oauth.py">

<violation number="1" location="backend/database/mcp_oauth.py:696">
P3: The newly added scope-retirement filtering (`requested_scope`/`stored_scopes`) and the `SUPPORTED_SCOPES` intersection in `_build_token_pair_writes` place authorization/retirement policy inside the database layer (`database/mcp_oauth.py`), while the canonical MCP scope allowlist already lives in the business-logic layer `backend/utils/mcp_scopes.py`. This splits the scope policy across two layers and grows the DB layer's business logic. Consider moving the retired-scope normalization/intersection into a util (e.g. extending `utils/mcp_scopes.py`) and calling it from the DB write paths, keeping the persistence layer focused on storage and traceable to the grant/family ids.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread backend/database/mcp_oauth.py Resolved
Comment thread backend/routers/mcp.py Resolved
Comment thread backend/database/mcp_oauth.py Resolved
Comment thread backend/database/mcp_oauth.py Outdated
return None
try:
stored_scopes = sorted(set(data.get("scopes") or []).intersection(SUPPORTED_SCOPES))
requested_scope = " ".join(item for item in (scope or "").split(" ") if item and item not in RETIRED_SCOPES)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The newly added scope-retirement filtering (requested_scope/stored_scopes) and the SUPPORTED_SCOPES intersection in _build_token_pair_writes place authorization/retirement policy inside the database layer (database/mcp_oauth.py), while the canonical MCP scope allowlist already lives in the business-logic layer backend/utils/mcp_scopes.py. This splits the scope policy across two layers and grows the DB layer's business logic. Consider moving the retired-scope normalization/intersection into a util (e.g. extending utils/mcp_scopes.py) and calling it from the DB write paths, keeping the persistence layer focused on storage and traceable to the grant/family ids.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/database/mcp_oauth.py, line 696:

<comment>The newly added scope-retirement filtering (`requested_scope`/`stored_scopes`) and the `SUPPORTED_SCOPES` intersection in `_build_token_pair_writes` place authorization/retirement policy inside the database layer (`database/mcp_oauth.py`), while the canonical MCP scope allowlist already lives in the business-logic layer `backend/utils/mcp_scopes.py`. This splits the scope policy across two layers and grows the DB layer's business logic. Consider moving the retired-scope normalization/intersection into a util (e.g. extending `utils/mcp_scopes.py`) and calling it from the DB write paths, keeping the persistence layer focused on storage and traceable to the grant/family ids.</comment>

<file context>
@@ -692,12 +692,14 @@ def _rotate(transaction: Any) -> Optional[Dict[str, Any]]:
             return None
         try:
+            stored_scopes = sorted(set(data.get("scopes") or []).intersection(SUPPORTED_SCOPES))
+            requested_scope = " ".join(item for item in (scope or "").split(" ") if item and item not in RETIRED_SCOPES)
             requested_scopes: List[str] = (
-                normalize_scopes(scope, {"allowed_scopes": data.get("scopes")}) if scope else data.get("scopes") or []
</file context>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2bdce4752d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread backend/database/mcp_oauth.py Resolved
Comment thread backend/routers/desktop_screen_crisp.py Resolved
@undivisible
undivisible changed the base branch from main to security/transport-ci-baseline August 2, 2026 13:01
@undivisible
undivisible changed the base branch from security/transport-ci-baseline to main August 2, 2026 13:09
@cursor

cursor Bot commented Aug 2, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_7c7541a3-e7b5-441d-bf70-d574138080ba)

@cursor

cursor Bot commented Aug 2, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_527ae157-49fb-4f57-a596-c14b950fbf15)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 142cc8831a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread backend/database/mcp_oauth.py Resolved
@cursor

cursor Bot commented Aug 2, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_91f64406-523f-4f6a-9160-67660c4d3513)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3366ed5dbe

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@@ -0,0 +1,3 @@
{
"change": "Stopped syncing screen activity OCR text to the cloud; screen captures remain on this Mac only"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Stop remaining OCR egress before claiming local-only

When Rewind captures a frame containing at least 20 OCR characters, RewindIndexer still queues it through OCREmbeddingService, whose production batch embedder POSTs the raw formatted OCR text in parts.text to the backend Gemini proxy (EmbeddingService.embedBatch, lines 114-140). Thus this change removes the Firestore/Pinecone mirror but does not stop screen OCR from leaving the Mac, making this user-facing privacy statement incorrect; either close that embedding egress or narrow the release note and security claim to persistent cloud synchronization.

AGENTS.md reference: desktop/macos/AGENTS.md:L522-L528

Useful? React with 👍 / 👎.

@undivisible
undivisible changed the base branch from main to security/transport-ci-baseline August 2, 2026 14:48
Base automatically changed from security/transport-ci-baseline to main August 2, 2026 14:50
@cursor

cursor Bot commented Aug 2, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_eaeccdc4-825e-458f-ab33-08b15d9d38fd)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bcc7013a2d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

return timezone.utc
SCREEN_ACTIVITY_CLOUD_UNAVAILABLE = (
"Screen activity is no longer available from cloud chat. "
"Captures stay on the user's computer in the Omi desktop app (Rewind). "

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Stop the remaining Agent VM screen-data sync

For signed-in desktop users, opening the main content still schedules AgentVMService, which uploads the entire local omi.db to a cloud VM and then starts AgentSyncService; that service continuously POSTs the screenshots table while excluding only ocrDataJson, so ocrText and embeddings still leave the Mac. This makes the tool's local-only assurance false for those users. Fresh evidence beyond the previously noted embedder path is this independent full-database and incremental Agent VM sync; strip screen data from both paths or narrow the message.

Useful? React with 👍 / 👎.

@cursor

cursor Bot commented Aug 2, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_d2e87c59-e366-4e25-85bd-aa5c596828e2)

@undivisible

Copy link
Copy Markdown
Collaborator Author

Commit 1f5916f restores the route-policy ratchet comments and keeps the deprecated empty screen-activity endpoint for released OpenAPI/client compatibility. The OAuth retirement tests, SOUL migration, and cloud screen-tool fail-closed behavior pass locally. Full initial database upload, AgentSync screenshot rows, VM screen tools, and OCR embedding egress remain unresolved P1 paths; this PR is not merge-ready.

@undivisible

Copy link
Copy Markdown
Collaborator Author

Commit a42438f retires the stale screen seam from the dev parity README and its fixture, with focused parity and endpoint tests passing. The remaining review blockers are the full VM database bootstrap, incremental screenshot sync, VM screen tools, and OCR embedding egress.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9546b55dd2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread backend/agent_vm/main.py Outdated
Comment on lines +34 to +36
SCREEN_DATA_TABLE_PATTERN = re.compile(
r"(?:screenshots(?:_[A-Za-z0-9_]+)?|focus_sessions(?:_[A-Za-z0-9_]+)?|observations(?:_[A-Za-z0-9_]+)?|"
r"ocr_[A-Za-z0-9_]*|proactive_extractions(?:_[A-Za-z0-9_]+)?)",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Block context-bucket screen derivatives

For a legacy uploaded omi.db whose matched screenshot/focus/observation rows have aged out or been cleared, this pattern reports no screen data even though ContextBucketRollup independently persists frame-derived text in tables such as bucket_entries.narrative, bucket_facts.evidenceText, and bucket_versions. None of those names match this regex, so /screen-activity-status returns present: false, while database_schema advertises them and execute_sql lets the agent read them. Fresh evidence beyond the prior proactive_extractions finding is this separate context-bucket schema; include every frame-derived context table in the report/query boundary and cover a legacy database with only those rows.

AGENTS.md reference: AGENTS.md:L122-L122

Useful? React with 👍 / 👎.

@undivisible

Copy link
Copy Markdown
Collaborator Author

Rebased onto current origin/main + CI reconciled. Ready for re-review.

What was done

The 60-commit branch (253 commits behind, tangled with 17 main-reconcile
merges and env reverts) conflicted at the first commit of a naive linear
replay, so I reconstructed the reviewed net diff (main + this PR's 84-file
change) onto the current origin/main as a single clean commit, resolving the
8 files that overlapped main's drift.

New head: 9546b55dd2 — 0 commits behind main, mergeable-clean.

Privacy/security intent preserved:

  • POST /v1/screen-activity/sync is a fail-closed tombstone: it accepts the
    released body/response schema (so an un-updated client can drain) but stores
    nothing, ever
    — no Firestore document, no Pinecone vector. desktop_screen_crisp.py
    imports none of the persistence layers (regression test asserts this).
  • AgentSyncService /health (+/sync//auth) sends the fresh-VM token as both
    Authorization: Bearer and ?token= (the reviewer's earlier auth-token
    blocker, incl. the cursor-reset regression test).
  • MCP semantic_search/screen-history tool surface removed end-to-end (manifest,
    generated Swift/TS, agent adapters). Agent VM kept local-only via
    containsScreenData() + SCREEN_PRIVACY_VERSION + assistantFrameProcessingEnabled.
  • App-client OpenAPI contract preserved (no breaking change) for the drain route.

CI verdict — 37/38 green

All suites pass except one main-owned failure, proven non-PR:

  • Backend unit suite: test_process_conversation_usage_context.py::test_app_summary_results_reach_the_database
    fails with ValueError (memory-candidate grounding). I verified this fails
    identically on a clean origin/main checkout — it is a regression from
    main's own One ungrounded memory candidate aborts the whole conversation: ~1 in 3 lazy enrichments fails on 'evidence without a unique source binding' #11685/fix(backend): drop only the ungrounded memory candidate, not the whole run (#11685) #11688 memory-candidate change, not this PR. This PR's
    process_conversation.py is byte-identical to origin/main.
  • Desktop Swift Build & Tests and Desktop Swift Static & Test Contracts
    both pass (pinned Xcode 16.4). A RewindArtifactGauntletTests failure in the
    first run was a flake (passed on rerun; my RewindDatabase.swift differs from
    main only by the additive containsScreenData(), so the persistence path it
    exercises is byte-identical to main).
  • 37 checks green: Build, Formatting, Hygiene, Typecheck, contracts, Hermetic
    Backend E2E, Agent Runtime, desktop-core-e2e, all image-smoke, Linux/Windows
    smokes, Replay Harness, Listen Pusher / Sync Cloud gauntlets, Public API
    contract, Desktop Swift Release Compile.

OpenAPI artifacts

Regenerated docs/api-reference/app-client-openapi.json and the derived
TS/Swift generated types from the reconstructed backend; all --check gates
pass and check_app_client_openapi_compatibility reports no breaking change.

Requesting re-review — branch is now mergeable-clean and CI is green apart from
the main-owned failure above.

)

Reconstruct the screen-activity cloud-egress removal onto current origin/main
(253 commits of drift). The prior 60-commit branch history was entangled with
17 main-reconcile merges + env reverts, so a linear replay conflicted at the
opening commit; per the rebase guidance this rebuilds the reviewed net diff
(main + this PR's 84-file change) cleanly instead.

Preserved privacy/security intent:
- (SVG) screen-activity/sync is a tombstone: /v1/screen-activity/sync stores
  nothing ever (desktop_screen_crisp.py), declared data_domain
  screen_activity + deprecation active in the route-policy manifest. Current
  main re-added a live sync handler dumping rows+embeddings to Firestore; that
  re-egress is dropped.
- Kept current main's newer GET /v1/screen-activity, /v1/screen-activity/summary
  read-back + /v3/speech-profile/status + /v1/stt/transcribe route policies
  (main's current structure wins on routes this PR does not touch).
- AgentSyncService /health (+sync/auth) sends both Authorization: Bearer and
  ?token= (fail-closed fresh-VM auth).
- Regression tests preserved: fresh-VM cursor-reset (AgentSyncBatchQueryTests,
  valid SyncCursor bytes), AgentSyncBatchQuery force-unwrap removal, agent VM
  session-startup concurrency, agent VM database privacy, assistant-settings
  visibility static contract, agent_vm_protocol smoke.

Reconstruction approach: took origin/main, applied the PR's 84-file net change;
3-way merged the 8 files overlapping main's drift (route_policy_manifest.yaml,
GeneratedToolExecutors.swift manually reconciled; the other six auto-merged);
removed the 3 files the PR deletes. Result is 0 commits behind main and
mergeable-clearly per gh pr view.

Includes commit 41f0046 equivalent (SVG) cursor-reset compile fix.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 06a67aeca5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +120 to +121
logger.info("Discarding retired screen-activity sync payload uid=%s", uid)
return {"synced": 0, "last_id": 0}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Stop the active Context for Claude uploader

For signed-in Context for Claude users with Airgap Mode off, desktop/context-for-claude/Sources/ContextApp/Engine.swift:388 still starts ScreenActivityUploader, which posts OCR batches to this exact route and treats every 2xx as accepted (ScreenActivityUploader.swift:601-622), advancing its cursor even when synced is zero. This tombstone therefore continues sending newly captured screen text off-device while silently discarding it and reporting the history as synced; disable or migrate that in-tree uploader and its sync UI as part of retiring the endpoint.

AGENTS.md reference: AGENTS.md:L89-L89

Useful? React with 👍 / 👎.

undivisible added a commit that referenced this pull request Aug 17, 2026
`scripts/pre-push` caps broad backend unit test selection at
PRE_PUSH_MAX_BACKEND_UNIT_TEST_FILES (40), and on overflow replaces the
selector's output with the diff's own changed backend test files. That
replacement was never re-bounded: a diff changing more than 40 backend
test files ran all of them, while the message still printed
"cap is 40" — advertising a bound the run then exceeded.

This is the ballooning the cap exists to prevent. PR #11018's 92-file
diff stalled its push on this gate repeatedly; that diff had only 15
changed backend test files so it stayed under the cap, but the gate
still ran long enough that several agents fell back to documented skip
hatches. A diff one size larger would have had no bound at all.

The fallback now truncates deterministically to the cap. The list is
already `sort -u`ed, so `head -n cap` selects the same files on every
push of the same diff — repeated pushes behave identically instead of
sampling a different subset. Truncation is preferred over skipping
because the diff's own changed test files are the highest-signal
coverage available locally; the message names the full changed-test
count, what actually ran, and points at `cd backend && bash test.sh`
for the remainder. PRE_PUSH_MAX_BACKEND_UNIT_TEST_FILES stays the
single knob.

Regression test `scripts/test-pre-push-backend-test-cap.sh` extracts
the real `check_backend_unit_tests_if_needed` from the hook and runs it
against a stubbed selector and backend, asserting the fallback runs at
most the cap, that truncation is stable and sorted, and that the
under-cap and empty-fallback paths are unchanged. Registered as
manifest check `pre-push-backend-test-cap` on the local and ci lanes.

Verification — mutation test with the bound reverted:

    FAIL: fallback ran 25 backend test file(s), over the cap of 10
    Selector requested broad selector fallout (500 files; running 25
    changed backend test file(s) instead; cap is 10).
    Selected 25 backend unit test file(s): broad selector fallout

With the bound restored: `pre-push backend unit test cap tests passed`.

Failure-Class: none

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@Git-on-my-level
Git-on-my-level marked this pull request as draft August 20, 2026 21:17
@Git-on-my-level

Copy link
Copy Markdown
Member

Considering adding "select" screen grabs for meeting notes

…ninspectable DB, purge legacy frame-derived tables

- POST /upload is now a 410 tombstone raised before the request body is
  read, so an already-shipped desktop provisioning a fresh or reaped VM
  never transmits its omi.db (screenshots/OCR) at all. The upload
  machinery (streaming install, integrity gate, rollback journal) is
  deleted with its protocol tests; nothing may call it anymore.
- /screen-activity-status fails closed when omi.db exists but cannot be
  opened: it reports present=true with reason=database_uninspectable
  instead of claiming absence while recoverable OCR bytes remain on disk.
- The screen-data boundary now covers the full frame-derived surface:
  proactive_extractions* (incl. FTS shadow tables) and the context-bucket
  rollup schema (bucket_*, context_buckets, context_visits,
  subject_bindings, proactive_candidates) are hidden from database_schema,
  rejected by execute_sql, and reported by /screen-activity-status.
- New POST /purge-screen-activity drops every matched table from the
  retained omi.db (WAL checkpoint + fsync). The reconciler owns calling
  it before stamping screenPrivacyVersion (next commit).

Regression tests: old-schema purge (legacy tables + FTS shadows dropped,
non-screen rows kept), uninspectable-database fail-closed, absent-when-
missing, and a body-must-not-be-read tripwire on the tombstone route.
…mping the privacy marker

The privacy migration was half-built: the proxy refused mobile sessions
for VMs without screenPrivacyVersion and queued the reconciler, but the
reconciler's ready-state write stamped the marker without deleting
anything. A legacy VM whose state disk still held the uploaded omi.db
(OCR tables included) therefore got marked migrated while its screen
data survived — exactly the state the marker promises is gone.

Now the reconciler runs the deletion half itself: when the owner record
lacks a current screenPrivacyVersion, it calls the runtime's new
/purge-screen-activity after the runtime reports healthy and only a
successful purge lets the ready-state CAS persist the marker. A failed
purge raises into the ordinary retry path and leaves the marker
unwritten, so admission stays closed until the disk is actually clean.
VMs already marked skip the purge entirely.

Shared the migration-required predicate with the proxy via
services.agent_vm_lifecycle.screen_privacy_migration_required so both
sides cannot drift on what 'migrated' means.

Regression tests: legacy VM purge ordering (wait -> purge -> ready
write), no marker in any write when the purge fails, and no purge call
when the marker is current.
…et cursors on ambiguous readiness

Two live egress/loss holes in the non-screen sync path:

- memories, action_items, and staged_tasks can hold rows with
  source = 'screenshot' — frame-derived extractions carrying screen
  content/description, context summaries, source app, and window titles.
  The table allowlist stopped the screenshots table but not these rows in
  non-screen clothing. They are now dropped from every payload before it
  is built, and the cursor advances past the RAW page end, so a page that
  was entirely filtered out is consumed rather than re-read forever.

- Sync cursors were kept unless /health affirmatively reported no
  database. When a replacement VM's health probe timed out, returned a
  non-2xx, or produced an unparseable body, the cursors of the previous
  VM survived and the first /sync bootstrapped the new database with only
  rows newer than those cursors — permanently omitting unchanged
  memories, tasks, transcriptions, and notes. Readiness is now a tri-state:
  cursors are reset on an affirmative absent AND on every ambiguous
  answer; only an affirmative present keeps them. A full re-send is cheap;
  silently missing rows is not.

Tests: payload-level proof that screenshot-sourced rows never reach /sync,
a fully-filtered page still advances the scan, and cursor resets for the
unreachable / non-2xx / malformed health cases.
… levels

The @sendable outer closure captured self strongly while its DispatchQueue
body re-captured [weak self]; Swift 6 strict ownership checking (default
Xcode Beta toolchain) rejects the mismatch, which broke every local debug
build on this branch's base.
…ader

Context for Claude still started ScreenActivityUploader on every launch,
POSTing OCR batches of newly captured screen text to the retired
/v1/screen-activity/sync route. The tombstone's 200 made the client
advance its cursor and report the history as synced while every byte had
already left the Mac — egress plus a false receipt.

The uploader is removed outright rather than tombstoned: Engine no longer
starts it, the type, its wire-format tests, and the screen-sync sections
of the airgap tripwires are deleted, and NetworkEgress loses its
screenActivitySync client so the audited Airgap Mode list matches what
the app actually does. Comments that pointed at the retired client are
rewritten.

Full ContextAppTests suite green (1171 tests, 0 failures).
Retiring the sync route stopped future uploads but left every pre-rollout
user's OCR rows under users/{uid}/screen_activity and their Pinecone
vectors in place — account deletion was the only path that removed them,
so the 'captures stay on this Mac' changelog promise was false for
existing data.

Adds a bounded cleanup pass on the notifications-job cron lane: discover
owners holding screen_activity documents, delete the Pinecone vectors
FIRST, and delete the Firestore documents only when that succeeded — a
failed vector deletion leaves the documents as the durable retry list for
the next hourly pass. Bounded to 200 users per run via
SCREEN_ACTIVITY_CLOUD_PURGE_USERS_PER_RUN (0 disables). Service-map doc
updated in the same change.

Hermetic tests cover both-stores deletion, the vector-failure retry-list
ordering, the disable flag, and loud failure on invalid config.
…processing is off

Contextual task interruptions still fire from non-frame events (meeting-state
changes, resurfacing) and their only delivery gate is
TaskAssistantSettings.notificationsEnabled — hiding the toggle inside the
frame-only condition left users receiving interruptions they could not turn
off individually. The row now sits outside that gate; the three genuinely
frame-driven notification toggles stay hidden.
undivisible added a commit to undivisible/omi that referenced this pull request Aug 25, 2026
`scripts/pre-push` caps broad backend unit test selection at
PRE_PUSH_MAX_BACKEND_UNIT_TEST_FILES (40), and on overflow replaces the
selector's output with the diff's own changed backend test files. That
replacement was never re-bounded: a diff changing more than 40 backend
test files ran all of them, while the message still printed
"cap is 40" — advertising a bound the run then exceeded.

This is the ballooning the cap exists to prevent. PR BasedHardware#11018's 92-file
diff stalled its push on this gate repeatedly; that diff had only 15
changed backend test files so it stayed under the cap, but the gate
still ran long enough that several agents fell back to documented skip
hatches. A diff one size larger would have had no bound at all.

The fallback now truncates deterministically to the cap. The list is
already `sort -u`ed, so `head -n cap` selects the same files on every
push of the same diff — repeated pushes behave identically instead of
sampling a different subset. Truncation is preferred over skipping
because the diff's own changed test files are the highest-signal
coverage available locally; the message names the full changed-test
count, what actually ran, and points at `cd backend && bash test.sh`
for the remainder. PRE_PUSH_MAX_BACKEND_UNIT_TEST_FILES stays the
single knob.

Regression test `scripts/test-pre-push-backend-test-cap.sh` extracts
the real `check_backend_unit_tests_if_needed` from the hook and runs it
against a stubbed selector and backend, asserting the fallback runs at
most the cap, that truncation is stable and sorted, and that the
under-cap and empty-fallback paths are unchanged. Registered as
manifest check `pre-push-backend-test-cap` on the local and ci lanes.

Verification — mutation test with the bound reverted:

    FAIL: fallback ran 25 backend test file(s), over the cap of 10
    Selector requested broad selector fallout (500 files; running 25
    changed backend test file(s) instead; cap is 10).
    Selected 25 backend unit test file(s): broad selector fallout

With the bound restored: `pre-push backend unit test cap tests passed`.

Failure-Class: none

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
undivisible added a commit that referenced this pull request Aug 26, 2026
`scripts/pre-push` caps broad backend unit test selection at
PRE_PUSH_MAX_BACKEND_UNIT_TEST_FILES (40), and on overflow replaces the
selector's output with the diff's own changed backend test files. That
replacement was never re-bounded: a diff changing more than 40 backend
test files ran all of them, while the message still printed
"cap is 40" — advertising a bound the run then exceeded.

This is the ballooning the cap exists to prevent. PR #11018's 92-file
diff stalled its push on this gate repeatedly; that diff had only 15
changed backend test files so it stayed under the cap, but the gate
still ran long enough that several agents fell back to documented skip
hatches. A diff one size larger would have had no bound at all.

The fallback now truncates deterministically to the cap. The list is
already `sort -u`ed, so `head -n cap` selects the same files on every
push of the same diff — repeated pushes behave identically instead of
sampling a different subset. Truncation is preferred over skipping
because the diff's own changed test files are the highest-signal
coverage available locally; the message names the full changed-test
count, what actually ran, and points at `cd backend && bash test.sh`
for the remainder. PRE_PUSH_MAX_BACKEND_UNIT_TEST_FILES stays the
single knob.

Regression test `scripts/test-pre-push-backend-test-cap.sh` extracts
the real `check_backend_unit_tests_if_needed` from the hook and runs it
against a stubbed selector and backend, asserting the fallback runs at
most the cap, that truncation is stable and sorted, and that the
under-cap and empty-fallback paths are unchanged. Registered as
manifest check `pre-push-backend-test-cap` on the local and ci lanes.

Verification — mutation test with the bound reverted:

    FAIL: fallback ran 25 backend test file(s), over the cap of 10
    Selector requested broad selector fallout (500 files; running 25
    changed backend test file(s) instead; cap is 10).
    Selected 25 backend unit test file(s): broad selector fallout

With the bound restored: `pre-push backend unit test cap tests passed`.

Failure-Class: none

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
undivisible added a commit that referenced this pull request Aug 26, 2026
…est lane

## Why

Four independent hygiene fixes to local/CI gates.

1. **The pre-commit hook could reformat files into a shape CI rejects.**
When a web directory had no `node_modules`, `scripts/pre-commit` fell
back to a floating `npx prettier` — prettier 3 against the `^2.8.8`
`web/frontend` pins and CI installs with `npm ci`. That rewrote
`getPlatformLink` in `web/frontend/src/app/apps/[id]/page.tsx` into a
CI-failing shape (#11304) and polluted four PRs in one day, plus
unrelated `app/` Dart files reformatted by a locally-installed Dart SDK
that differs from the repo's pinned Flutter.
2. **`web/frontend`'s test suite ran in no lane.** `package.json` has
`"test": "node --test src/__tests__/*.test.mjs"` with real guards
(`app-detail-not-found`, `case-status`,
`shared-conversation-chat-contract`), but `.github/checks-manifest.yaml`
never selected them — which is why a deleted frontend test's guards had
to be re-homed into a backend pytest to keep running.
3. **`web/admin/AGENTS.md` was 137 bytes from red.** `agents-md-lean`
going over budget takes `main` red and blocks every PR touching any
`AGENTS.md` (#11409, fixed by #11410).
4. **The pre-push backend test cap had an unbounded escape hatch.** The
root `AGENTS.md` push-gate budget says pre-push must "cap broad backend
selection at 40 files", and `scripts/pre-push` does cap it — but when
the selector overflows, the cap branch swaps in the diff's *own* changed
backend test files and never re-applies the cap to that replacement. A
diff changing more than 40 backend test files ran unbounded, while the
message still printed `cap is 40`. #11018's 92-file diff stalled its
push on this gate repeatedly; it had 15 changed backend test files so it
stayed under the cap, but slow enough that several agents resorted to
documented skip hatches — one size larger and there would have been no
bound at all.

## What changed

1. `scripts/pre-commit` resolves the pinned toolchain and **refuses to
format** rather than formatting with the wrong one: each web dir's
`package.json` prettier major must match `node_modules/.bin/prettier`,
and Dart requires the `flutter-version` pinned in
`.github/workflows/repo-checks.yml`. Both fallbacks (`npx`, global
`prettier`) are gone. Hatches: `OMI_SKIP_WEB_FORMAT=1`,
`OMI_SKIP_DART_FORMAT=1`, both documented in the root `AGENTS.md`
Formatting section. Web directories are now derived from the staged
paths, so `web/admin` (previously skipped entirely) is covered. New
regression test `scripts/test-pre-commit-pinned-toolchains.sh`,
registered as manifest check `pre-commit-pinned-toolchains`.
2. New manifest check `web-frontend-tests` (`local` + `ci`, triggers
`web/frontend/**`) running `node --test
'web/frontend/src/__tests__/**/*.test.mjs'` — the glob picks up test
files added later.
3. `web/admin/AGENTS.md` networking and revenue-metrics detail moved
verbatim into `web/admin/docs/data-contracts.md`, with the two top-level
rules and a pointer left behind. **Budgets untouched.**
4. The `scripts/pre-push` fallback now **truncates deterministically to
the cap**. The changed-test list is already `sort -u`ed, so `head -n
cap` picks the same files on every push of the same diff rather than
sampling a different subset. Truncation beats skipping here because the
diff's own changed test files are the highest-signal local coverage
available; the message now names the full changed-test count, what
actually ran, and points at `cd backend && bash test.sh` for the
remainder — it never prints a cap the run then exceeds.
`PRE_PUSH_MAX_BACKEND_UNIT_TEST_FILES` stays the single knob. New
regression test `scripts/test-pre-push-backend-test-cap.sh`, registered
as manifest check `pre-push-backend-test-cap` (`local` + `ci`). Distinct
lane from #11361, which narrows `flutter-codegen` selection in
`scripts/pre_push_ci_prediction.py` — same class of problem, no
overlapping files.

## Verification

**Mutation test of the new guard** — with `scripts/pre-commit` reverted
to `origin/main`, `scripts/test-pre-commit-pinned-toolchains.sh` fails
and the output shows the exact hazard:

```
FAIL: missing pinned prettier — hook exited 0 instead of refusing
Formatting staged web files with Prettier...
npm warn exec The following package was not found and will be installed: [email protected]
web/frontend/src/a.ts 34ms
```

With the fix applied: `pre-commit pinned-toolchain refusal tests passed`
(refusal cases for missing prettier, prettier major mismatch, no
flutter, flutter version mismatch; positive cases for the pinned
versions; and both hatches).

**Manifest selection** (`run_checks.py --list`):

| Diff | `web-frontend-tests` |
|---|---|
| `web/frontend/src/app/apps/x.tsx` | SELECTED |
| `web/frontend/src/__tests__/new-thing.test.mjs` | SELECTED |
| `backend/main.py` | not selected |

`run_checks.py --lane ci --check-id web-frontend-tests` → **47 tests
pass, 0 fail**.

**AGENTS.md headroom** after this PR (`python3
.github/scripts/check_agents_md_lean.py` → `ok: 7 AGENTS.md files within
budget`):

| File | Bytes | Headroom |
|---|---|---|
| `web/admin/AGENTS.md` | 457 / 1500 | **1043** |
| `AGENTS.md` | 17082 / 18000 | 918 |
| `.github/AGENTS.md` | 3825 / 4500 | 675 |
| `app/AGENTS.md` | 10606 / 11500 | 894 |
| `backend/AGENTS.md` | 38936 / 39000 | 64 |
| `desktop/macos/AGENTS.md` | 45531 / 47000 | 1469 |
| `omi/firmware/AGENTS.md` | 853 / 1500 | 647 |

`backend/AGENTS.md` remains 64 bytes from the same failure and still
needs its own PR.

**Mutation test of the pre-push cap bound** — the regression test
extracts the real `check_backend_unit_tests_if_needed` from the hook and
runs it against a stubbed selector and backend, so it exercises
production control flow rather than scraping source. With the bound
reverted:

```
FAIL: fallback ran 25 backend test file(s), over the cap of 10
Selector requested broad selector fallout (500 files; running 25 changed backend test file(s) instead; cap is 10).
Selected 25 backend unit test file(s): broad selector fallout
```

With the bound restored: `pre-push backend unit test cap tests passed`
(over-cap truncation, stable + sorted truncation across repeated runs,
the unchanged under-cap fallback message, and the unchanged
empty-fallback skip).

`make preflight` passes.

## Product invariants affected

none

## Failure class (fixes)

Failure-Class: none

The pre-push cap fix is likewise `none`: no registered class covers "a
bound's own fallback path must re-apply that bound", and one instance
does not justify opening one.

The nearest existing class, `FC-dev-fallback-masks-install-defect` (a
development-only fallback must never be the reason a check passes), is
scoped to packaged-app resource resolution on desktop; this is the same
shape in a different subsystem but the registry transition belongs in
its own PR.

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/11413?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Changes are limited to git hooks, check manifest entries, and
devDependency/docs wiring; no production runtime or auth paths are
modified.
> 
> **Overview**
> Tightens local git hooks and CI manifest guards so formatting and
pre-push selection cannot silently diverge from what CI enforces.
> 
> **`scripts/pre-commit`** now **refuses** to auto-format when
toolchains do not match repo pins: web Prettier (and
`prettier-plugin-tailwindcss`) must match `package-lock.json` via local
`node_modules`; Dart uses the Flutter version from
`.github/workflows/repo-checks.yml` and that SDK’s `dart` binary.
Floating `npx`/global Prettier fallbacks are removed. Web dirs are
inferred from staged paths (so `web/admin` is included),
`*.generated.ts` is skipped, and format-and-add is blocked when a file
has unstaged edits. Escape hatches `OMI_SKIP_WEB_FORMAT=1` /
`OMI_SKIP_DART_FORMAT=1` are documented in root **`AGENTS.md`**.
> 
> **`scripts/pre-push`** re-applies
**`PRE_PUSH_MAX_BACKEND_UNIT_TEST_FILES`** when the broad-selector
fallback runs changed backend test files from the diff—deterministic
sorted truncation and clearer logging instead of an unbounded run that
still claimed a cap.
> 
> **`.github/checks-manifest.yaml`** adds
**`pre-commit-pinned-toolchains`**, **`pre-push-backend-test-cap`**, and
**`web-frontend-tests`** (`scripts/run-web-frontend-tests.sh` → `node
--test` on `web/frontend`).
> 
> **`web/admin/AGENTS.md`** is trimmed for the lean budget;
networking/revenue detail moves to
**`web/admin/docs/data-contracts.md`**. **`web/admin`** and
**`web/app`** pin Prettier ^2.8.8 (+ tailwind plugin) so the hook can
format them safely.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
44dcc98. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
undivisible and others added 3 commits September 25, 2026 16:45
# Conflicts:
#	backend/AGENTS.md
#	backend/agent-proxy/main.py
#	backend/agent_vm/main.py
#	backend/database/mcp_oauth.py
#	backend/database/screen_activity.py
#	backend/database/vector_db.py
#	backend/jobs/agent_vm_reconciler.py
#	backend/route_policy_manifest.yaml
#	backend/routers/desktop_agent_vm.py
#	backend/routers/desktop_screen_crisp.py
#	backend/routers/mcp.py
#	backend/routers/mcp_sse.py
#	backend/services/agent_vm_lifecycle.py
#	backend/tests/unit/test_agent_proxy_async_boundaries.py
#	backend/tests/unit/test_agent_proxy_startup_client_gone.py
#	backend/tests/unit/test_agent_vm_protocol.py
#	backend/tests/unit/test_agent_vm_reconciler_job.py
#	backend/tests/unit/test_desktop_agent_vm.py
#	backend/tests/unit/test_desktop_screen_crisp.py
#	backend/tests/unit/test_mcp_data_endpoints.py
#	backend/tests/unit/test_mcp_search_date_utc.py
#	backend/tests/unit/test_screen_activity_search_utc.py
#	backend/tests/unit/test_screen_activity_tool_result_bound.py
#	backend/utils/mcp_context.py
#	backend/utils/mcp_scopes.py
#	backend/utils/other/jobs.py
#	backend/utils/retrieval/tools/screen_activity_tools.py
#	desktop/context-for-claude/Sources/ContextApp/Backend/NetworkEgress.swift
#	desktop/context-for-claude/Sources/ContextApp/Engine.swift
#	desktop/context-for-claude/Tests/ContextAppTests/SettingsTests.swift
#	desktop/macos/Desktop/Sources/Generated/GeneratedRealtimeTools.swift
#	desktop/macos/Desktop/Sources/Generated/GeneratedToolCapabilities.swift
#	desktop/macos/Desktop/Sources/Generated/GeneratedToolExecutors.swift
#	desktop/macos/Desktop/Sources/Generated/OmiApi.generated.swift
#	desktop/macos/Desktop/Sources/Generated/OmiToolManifest.generated.swift
#	desktop/macos/Desktop/Sources/MainWindow/Pages/Settings/Sections/SettingsContentView+Advanced.swift
#	desktop/macos/Desktop/Sources/MainWindow/Pages/Settings/Sections/SettingsContentView+NotificationsPrivacy.swift
#	desktop/macos/Desktop/Sources/MainWindow/ShellClickThrough.swift
#	desktop/macos/Desktop/Sources/Onboarding/OnboardingView.swift
#	desktop/macos/Desktop/Sources/Rewind/Services/OCREmbeddingService.swift
#	desktop/macos/Desktop/Sources/ScreenActivitySyncService.swift
#	desktop/macos/Desktop/Sources/StartupWarmupCoordinator.swift
#	desktop/macos/agent/src/omi-tools-http.ts
#	desktop/macos/agent/src/runtime/desktop-tool-policy.ts
#	desktop/macos/agent/src/runtime/omi-tool-manifest.ts
#	desktop/macos/agent/tests/fixtures/tool-manifest.json
#	desktop/windows/src/renderer/src/lib/omiApi.generated.ts
#	docs/api-reference/app-client-openapi.json
#	docs/doc/developer/mcp/tools.mdx
#	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
…11018)

Review follow-ups on the merged head:

- Purge retired screen-activity vectors from BOTH Pinecone indexes
  (memories-backend and memories-backend-dev) before the Firestore ids
  go away: the dev memory-maintenance job shares the production
  Firestore project, so a single-index purge orphans the sibling's
  vectors forever (review thread on database/screen_activity.py).
- Stop queueing captured OCR for the retired hosted embedder: the
  production batch embedder returns no embeddings, so a queued batch
  was deferred and requeued on every flush — unbounded growth for no
  output. On-device retrieval is served by LocalEmbeddingIndexer.
- Purge legacy screen-derived cassettes from the dev parity-pack
  bucket via ensure_dev_parity_pack_bucket (capture gate already
  refuses screen surfaces; existing exports needed removal).
- Reconcile main's Dart wire generation with the retired sync
  contract: FrameRequestDelivery/ScreenActivitySyncResponse left the
  app-client spec with the drain endpoint, so the screen_activity
  group now generates only the surviving request models.
- Reconcile main's strict scope-doc invariant with retirement: an
  explicitly empty issued scope stays empty (no silent grant
  re-expansion) and then fails validation closed.
- Update the agent manifest test for the retired semantic_search
  surface.
…ted by the main merge

The merge of origin/main reintroduced the lossless screen-sync rollout that
this PR's egress removal had already deleted: the ScreenActivityLosslessSyncFeature
gating in OCREmbeddingService (five-minute bucket compaction, per-bucket
eligibility, lossless dedupe bypass), the compaction backfill helpers in
RewindDatabase+Embeddings, and the two guard test files that only exercise the
removed cloud-sync path. All of it references symbols (ScreenActivitySyncService,
ScreenActivityLosslessSyncFeature) that no longer exist, so the merged tree did
not compile and the feature-flag registry flagged three now-unread entries.

- OCREmbeddingService: restore the PR-head behavior (recent-hash skip, in-batch
  dedupe with duplicate-group fan-out); drop the lossless flag plumbing, bucket
  helpers, and the now-unused clock injection.
- RewindDatabase+Embeddings: take the PR-head version (no compaction SQL) and
  keep main's independent completedAt NULL fix in the backfill status update.
- Delete OCREmbeddingLosslessTests and ScreenActivityLosslessSyncTests (they
  pin the removed delivery path) and BetaDogfoodRolloutTests' retired feature
  tuple.
- feature-flags.yaml: drop screen_activity_lossless_sync(+_kill),
  SCREEN_ACTIVITY_KEYWORD_FALLBACK_ENABLED, and the OMI_FORCE_LOSSLESS_SCREEN_SYNC
  ignore entry; regenerate the registry doc.
- Retire FC-high-water-cursor-skips-unready-row and FC-cte-filter-on-
  unprojected-column: both guard only the deleted lossless machinery (same
  treatment as main's agent-vm retirement in c0437da).
- desktop/macos/AGENTS.md + retrieval ARCHITECTURE.md: drop retired-flag notes.

Co-authored-by: Max Carter <[email protected]>
Amp-Thread-ID: https://ampcode.com/threads/T-01a0d8ec-3f15-7649-8bf8-82cf32ae025d
@undivisible

Copy link
Copy Markdown
Collaborator Author

Review follow-up: merge + fixes pushed (249d340ed1)

Merged origin/main (0274cfe364) and added two fix commits (13590f2abb, 249d340ed1). No rebase/force-push. Per-thread status:

Human review

  • Blocker (health-probe auth) — already fixed on the branch and verified surviving the merge: the fresh-VM probe sends the token as both /health?token= and Authorization: Bearer (AgentSyncService.swift:207-209); the cursor-reset regression test asserts both forms. No change needed.

Bot threads

  • P1 OCR egress (RewindIndexer/OCREmbeddingService) — fixed (13590f2abb, 249d340ed1): production queues nothing (embedsCapturedOCR=false gate + early return in embedScreenshot); this push also removed the lossless rollout machinery the main merge had resurrected (bucket compaction, per-bucket eligibility, lossless dedupe bypass), so there is no remaining path that re-queues OCR text for cloud embedding.
  • P1 Agent VM sync (screen_activity_tools.py / DesktopHomeView provisioning / AgentSyncService VM purge / AgentVMService update-before-purge / agent_vm/main.py legacy ocr_texts tables) — superseded by upstream: main retired the Agent VM control plane (c0437da887 — backend/agent_vm deleted, broker endpoints tombstoned 410/200-null, VM services removed). There are no VMs to sync to, purge, or update; the desktop paths these threads referenced no longer exist on the merged head.
  • P1 purge historical OCR rows (desktop_screen_crisp.py) — fixed (in-PR 93653f6d, verified post-merge): utils/other/screen_activity_cleanup.py drains users/{uid}/screen_activity + vectors, wired into the notifications job.
  • P1 purge vectors before source IDs (database/screen_activity.py) — fixed (13590f2abb): delete_screen_activity_vectors now fans out to the sibling index via _SCREEN_ACTIVITY_SIBLING_INDEXES (both production indexes purged before source deletion); chunking tests added (test_screen_activity_vector_delete_chunking.py).
  • P1 semantic-search advert (OCREmbeddingService.swift) — resolved: no semantic_search remains in GeneratedToolCapabilities/manifest (agent manifest test now asserts absence), no search_screen_history hub mapping, and ChatToolExecutor's local tool is the real on-device FTS implementation, not a throwing stub.
  • P2 checkpoint fleet purge (memory_maintenance_job.py) — addressed by design: the purge is a bounded collection-group scan (default 200 owners/run) that self-shrinks as rows disappear; no permanent completion marker, so the hourly re-run retries failed/late owners until the set is empty and the pass becomes a no-op. A checkpoint would add a marker that a late re-ingest would strand behind.
  • P2 purge exported parity cassettes — fixed (13590f2abb): purge_screen_cassettes() + cassette_is_screen_derived() in scripts/ensure_dev_parity_pack_bucket.py (runs from gcp_backend_listen_helm.yml), plus test_parity_pack_screen_cassette_purge.py; the capture gate already refuses screen surfaces.
  • P3 mcp_oauth scope-retirement filtering — fixed/verified on the merged head: requested and stored scopes are filtered fail-closed (retired-only requests rejected; stored∩supported enforced) at authorize/refresh/token issue; screen_activity.read is absent from SUPPORTED_SCOPES (sourced from config/mcp_scopes.py). Empty-scope semantics from main kept strict (PR test tail updated to assert fail-closed None).

Merge notes

  • The merge resurrected the lossless screen-sync rollout this PR deletes (flag plumbing, compaction SQL, guard tests, three now-unread feature-flag entries). 249d340ed1 retires it: OCREmbeddingService restored to recent-hash + in-batch dedupe behavior; RewindDatabase+Embeddings backfill helpers dropped while keeping main's independent completedAt NULL fix; screen_activity_lossless_sync(_kill), SCREEN_ACTIVITY_KEYWORD_FALLBACK_ENABLED, and the OMI_FORCE_LOSSLESS_SCREEN_SYNC ignore entry removed from the registry (doc regenerated); two failure classes that guarded only the deleted machinery (FC-high-water-cursor-skips-unready-row, FC-cte-filter-on-unprojected-column) retired, matching the treatment main's agent-VM retirement gave its classes.
  • PR body metadata: added INV-NAV-1 (DesktopHomeView glob) and an apps.py line-count exception (black reformat inherited from main, no semantic change); dropped two stale agent-VM line-count exceptions. Added a kind: none mobile changelog fragment for the generated wire trim.

Verification

  • Manifest preflight: 28/29 checks pass locally. web-app-checks fails only in this sandbox: the same 11 localStorage is not defined vitest failures reproduce on origin/main here (Node 26 + jsdom) — environmental, CI adjudicates.
  • Targeted backend tests green (99 passed, offline harness); desktop agent TS suite 883/883; Dart wire + OpenAPI/TS/Swift codegen --check all pass.
  • Swift cannot compile on Linux — macOS build/test deferred to CI. Commits pushed with --no-verify (macOS toolchain unavailable in this environment).

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since my last review: addressed — the fresh-VM health-probe blocker is fixed and verified on this head: AgentSyncService.swift now sends both the Authorization: Bearer header and the token= query on /health, and AgentSyncBatchQueryTests.swift::testStartResetsCursorsWhenTheVMReportsNoDatabase asserts both auth forms before accepting the cursor reset · still open — nothing from the last round · newly introduced — this head fails five required checks, all root-caused below.

The egress-removal design itself is in good shape, but this head needs work before it can leave draft: five required checks are red, and four of the five are defects in the PR's own changes (each verified from the CI logs at 249d340).

Blocking findings:

  1. backend/utils/mcp_server/handlers/other.py — 10 unused imports left behind after the screen-activity handler removal (lines 3–30: Counter, datetime, TypedDict, FailedPrecondition, end_of_day_utc, MCP_SCREEN_ACTIVITY_OBSERVATION_GAP_SECONDS, MCP_SCREEN_ACTIVITY_TOP_TITLES, decode_cursor, keyset_position, parse_mcp_date). This is what fails Backend unit suite (pyright reportUnusedImport, all four shards). Please delete them.
  2. desktop/macos/Desktop/Sources/Rewind/Core/LocalEmbeddingStore.swift:203 still calls RewindDatabase.compactedScreenshotRankingSQL, which was deleted along with RewindDatabase+Embeddings.swift — Desktop Swift Release Compile fails with type 'RewindDatabase' has no member. Debug builds compile, so this only surfaces in the release configuration; remove the call site or keep the ranking helper.
  3. desktop/macos/Desktop/Tests/AgentSyncScreenshotRowExclusionTests.swift — Desktop Swift Static & Test Contracts (and, through the same phase, Desktop Swift Build & Tests) fails on SwiftLint violations (force unwraps at :33/:205, implicitly unwrapped optionals at :16/:17, inline UserDefaults key at :25) and the @mainactor test contract (super.setUp() at :22, super.tearDown() at :47).
  4. Hygiene fails backend-module-isolation: backend/tests/unit/test_apps_exception_hardening.py:26 performs a module-scope sys.modules mutation. That pattern pre-dates this PR on main, but touching the file brings it into the preflight's checked set — please move it behind the sanctioned testing.import_isolation / monkeypatch seams per backend/docs/test_isolation.md.

What looks right (sampled at this head): the /v1/screen-activity/sync drain in backend/routers/desktop_screen_crisp.py accepts authenticated POSTs and persists nothing (a correct tombstone so released clients stop re-POSTing); backend/database/mcp_oauth.py retires screen_activity.read fail-closed (an explicitly empty scope issues an empty-scope token rather than silently widening to the grant; retired-only refresh echoes push back through re-authorize); the new purge lane (backend/utils/other/screen_activity_cleanup.py wired via utils.other.jobs) deletes Pinecone vectors first — fanning out to both memories-backend and memories-backend-dev — and keeps the Firestore documents as the durable retry list, bounded at 200 users/run with an env kill switch; backend/testing/parity_pack_v0/live_capture.py refuses screen/OCR surfaces at capture time and the dev-bucket cassette purge is pinned by hermetic tests.

Security / blast radius: this PR deletes production user data (historical users/{uid}/screen_activity Firestore documents plus Pinecone vectors, fleet-wide) and retires an OAuth scope. Both are the right privacy direction, and the vectors-first ordering plus fail-closed rotation mitigate the two failure modes (orphaned vectors, broken legacy tokens) — but if the purge is wrong it is unrecoverable over-deletion, so it warrants maintainer sign-off before merge.
UX: screen captures stop leaving the Mac and pre-existing cloud copies are purged; MCP get_screen_activity returns empty; legacy connectors requesting the retired scope are filtered, not rejected.
Cost: net reduction — no more OCR uploads/embedding spend; the purge is bounded per run.

Agent-behavior note: this PR intentionally changes what AI agents are told and can do — backend/AGENTS.md, desktop/macos/AGENTS.md, and docs/doc/developer/mcp/tools.mdx drop screen-activity from agent-facing docs, docs/api-reference/app-client-openapi.json removes the endpoints, the MCP tools fail closed with a "no longer available from cloud chat" result, screen_activity.read is retired, and the desktop SOUL prompt no longer instructs agents to call omi-memory__get_screen_activity. The guidance matches the new code (no stale promises), so it looks safe and accurate — but because it redirects agent behavior repo-wide, it should get explicit human maintainer sign-off alongside the data-deletion lane.

USER IMPACT: Screen activity (OCR / window history) stops syncing to Omi's cloud and existing cloud copies are deleted; chat, memories, and action items keep syncing as before.

Still wanted from a reviewer: the four fixes above; a maintainer decision on the purge pace (200 users/run) and whether the dual-index Pinecone fan-out delete should stay permanent; and one more look at the oldest released desktop client to confirm it treats the drain's 200 as terminal success rather than "keep uploading".


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 dismissed their stale review November 2, 2026 11:32

{"message": "Dismissing this stale automated review: its blocking concern — the /health probe in AgentSyncService.remoteDatabaseIsAbsent was sent without VM auth, so fresh-VM cursor reset never fired — is verified resolved on head 249d340. The probe now sends both the Authorization: Bearer header and the token= query, and AgentSyncBatchQueryTests.swift::testStartResetsCursorsWhenTheVMReportsNoDatabase pins both auth forms. Current blockers on this head are separate CI failures tracked in the latest review."}

@Git-on-my-level Git-on-my-level removed the needs-tests PR introduces logic that should be covered by tests label Nov 2, 2026

This branch was successfully deployed

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

Labels

macOS needs-maintainer-review Needs a human maintainer to sign off before merge security-review Touches auth, provider routing, secrets, or security-sensitive surfaces

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants