Skip to content

feat(desktop): route screen embeddings and summaries by plan capabilities - #22141

Merged
Git-on-my-level merged 3 commits into
mainfrom
feat/desktop-ladder-local-capabilities
Oct 18, 2026
Merged

Git-on-my-level merged 3 commits into
mainfrom
feat/desktop-ladder-local-capabilities

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

Free and Plus macOS screen capture, queued embeddings, backfill and search now stay on-device/FTS and cannot spend Gemini, including under hard kill. Pro/Architect and server-grandfathered Neo retain cloud embeddings and local retrieval. All Gemini proxy clients advertise local-embedding capability unless hard-killed. Stable defaults local embeddings and available local summaries on; funded conversation uploads retain their existing behavior.

Local summary attachment consumes the existing allowance snapshot and schema-v1 display-only client_processing contract. No backend code, production flag, deploy, account, or release channel was changed. Unknown plans deny cloud vectors; unknown paid processing allowance stays server-decided. Legacy and lossless sync deliver vectorless OCR and acknowledge late vectors independently of the legacy cursor; retries and owner changes cannot acknowledge unsent vectors. Owner-scoped cursors start at zero and never adopt the unowned historical key; a bounded one-time OCR re-delivery is intentional. Screen cloud grants expire after five minutes, refresh outside capture, and bind to the authenticated session. Recovery retries cold/expired grants at a 60-second floor, probes completed markers for new missing vectors every five minutes, and retains AC, owner, 100-document batch and process-launch attempt caps (500 lossless / 5000 legacy). Every single/batch embedding pins that session before auth and revalidates before HTTP.

Keep DRAFT. Backend dependency: #21488 plus its follow-up folding BASIC_PLAN_GATE_PROXY_EMBED_ENABLED, BASIC_PLAN_GATE_EAGER_EXTRACTION_ENABLED and FREE_TIER_LOCAL_PROCESSING into ladder entitlements/capabilities. The client derives cloud-screen eligibility until the server exposes cloud_screen_vectors. Summary routing requires recognized exhaustion reasons: allowance_unavailable/usage_invalid never reroute paid processing. Paid legacy STT-only caps remain server-owned until the follow-up exposes a dedicated funding signal; ladder usage_budget_exhausted already has a client hook.

Rollout: release to Beta first; verify local/hybrid/FTS decision changes, vectorless OCR delivery and allowance-preserving summary uploads, then parent/operator explicitly promotes Stable. Rollback local embeddings with OMI_LOCAL_EMBEDDINGS=0 / localEmbeddingsEnabled=false or hard kill OMI_DISABLE_LOCAL_EMBEDDINGS=1 / disableLocalEmbeddings=true. Hard kill omits X-Omi-Local-Embeddings but never grants cloud-vector entitlement. Stop summary attachment with OMI_FREE_TIER_LOCAL_PROCESSING=0 / freeTierLocalProcessing=false; stop generation with OMI_DISABLE_LOCAL_INFERENCE=1 / disableLocalInference=true. The existing remote free-tier-kill-switch-v1 also stops local vectors and summary attachment through a cache-only, exposure-free client read; FREE_TIER_EMERGENCY_STOP remains backend-owned. Parent backend follow-up should add macOS to the existing flag registry surfaces. This PR makes no remote configuration change.

Acceptance gates not met: current real-Rewind-DB retrieval/latency measurement, actual eight-hour energy measurement, physical macOS 14 acceptance, live AFM quality, production/backend end-to-end admission and signed release verification. Synthetic fixtures establish behavior, not energy or model quality. Historical #13473 one-Beta-DB measurements are not current evidence. The default-on change follows David's explicit 2026-10-18 ruling despite these outstanding measurements.

INV-AUTH-1: capture retains owner snapshots and local vector writes retain mutation authorization; outbound embedding and sync requests also pin owner authority through auth and dispatch; cached paid hints cannot authorize a replacement owner.
INV-MEM-1: local vectors remain retrieval projections; local summaries stay display-only client_processing and do not write canonical memory/tasks.
INV-CHAT-1: Rewind/chat share the screen search router; no conversation timeline or journal changes.
Failure-Class: none

UI-Evidence: none -- retrieval routing and capture/upload behavior only; no visual controls, styling, or layout changed. Hermetic behavior tests cover the production APIs; isolated runtime acceptance remains a reported gate.

INV-TASK-2: automatic task capture admission remains unchanged; only retrieval-projection embedding calls and writes are bound to their originating owner

INV-UI-1: existing Rewind appearance and controls are unchanged; search results use the shared router
INV-UI-2: no navigation, confirmation, date, or control contract changes

Live flush and recovery share tokenized row reservations through provider dispatch and persistence. Recovery excludes live work and closed-window checks keep it out of recent captures; the flush rechecks stored-vector admission before spending. Regression tests drive queued, live-in-flight and recovery-in-flight orderings on both sync paths and require one provider dispatch. Storage fixtures use an empty-engine runtime, so deterministic fake-engine tests do not compete with abandoned real NLCE work; their existing capture and park deadlines remain unchanged.

Line-Count-Exception: desktop/macos/Desktop/Sources/Providers/ChatToolExecutor.swift | 3961 -> 3966 | Pass owner authorization and the shared screen policy through existing tool calls; implementation stays in feature files

Validation: serial targeted Swift suites ran 415 tests with six skipped and zero failures on the final source; the live/recovery coordination subset and capture fixtures also passed in isolation. No detached-drain timeout messages occurred after fixture isolation. Commands used xcrun swift test --package-path desktop/macos/Desktop with the LocalInference, embedding, projection, Rewind, ScreenActivity, owner-authority and subscription filters, under nice and omi-heavy. Real-device and release acceptance remain the gates stated above.

View guided diff Turn on auto-fix

@Git-on-my-level
Git-on-my-level marked this pull request as ready for review October 18, 2026 21:04
@Git-on-my-level
Git-on-my-level merged commit 6d4ddac into main Oct 18, 2026
48 checks passed
@Git-on-my-level
Git-on-my-level deleted the feat/desktop-ladder-local-capabilities branch October 18, 2026 21:04
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T21:13:36.016025Z 2fa7dc8 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: 2fa7dc82b8

ℹ️ 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".

let authorization = RuntimeOwnerIdentity.captureAuthorizationSnapshot()
let subscription = try await APIClient.shared.getUserSubscription(authorizationSnapshot: authorization)
if let authorization {
guard RuntimeOwnerIdentity.isAuthorizationCurrent(authorization) else { return }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Clear the loading flag when authorization expires

If the user signs out, switches owners, or reauthenticates while this subscription request is in flight, this guard returns without resetting isLoadingSubscription, which was set before launching the task. The Plan & Usage page then remains in its loading state and its reload control stays disabled because subsequent loadSubscriptionInfo() calls exit at the initial loading guard. Clear the flag on this stale-authorization path while still avoiding publication of the stale response.

Useful? React with 👍 / 👎.

AND id < COALESCE((SELECT MIN(id) FROM screenshots WHERE id > ? AND
(CAST(strftime('%s', timestamp) AS INTEGER) / 300 + 1) * 300 > ?), 9223372036854775807))
OR (screenActivitySyncState = 1 AND embedding IS NOT NULL AND ?)
ORDER BY CASE screenActivitySyncState WHEN 1 THEN 0 ELSE 1 END, id ASC LIMIT ?

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 Prioritize pending OCR over late vector receipts

When a legacy-sync user upgrades or embedding recovery fills a backlog, this ordering puts every textSynced late-vector row ahead of unsent pending OCR under the shared 100-row limit. A 5,000-row recovery can therefore delay newly captured text for roughly 50 sync intervals, and continued late-vector work can keep text starved, even though the cursor and receipt states were introduced specifically to make OCR delivery independent of embeddings. Order pending text first or reserve separate capacity for it.

AGENTS.md reference: desktop/macos/AGENTS.md:L231-L234

Useful? React with 👍 / 👎.

Comment on lines +93 to +94
guard cloudEmbeddingAllowed(authorization) else {
throw EmbeddingError.serverError(statusCode: 402, body: "plan_gated")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Retry task backfill after the entitlement cache warms

When TaskAssistant starts before ScreenCloudEntitlementService has been seeded, allowsCloud starts a background subscription refresh but returns false immediately, so this gate throws plan_gated. EmbeddingService.backfillIfNeeded() catches that error and exits, and its only production caller runs once during task-assistant initialization; therefore an entitled Pro/Architect user who hits this normal startup race never backfills missing action-item or staged-task embeddings for the rest of the launch. Schedule a retry after the entitlement refresh, as the OCR backfill path does, or trigger task backfill when a paid response is accepted.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant