Repository navigation
fix(desktop): download JIT trigger snapshot when effective=enabled - #12381
Merged
Merged
Conversation
The rollout-decision response carries the server's own admission verdict (`effective`), but the client re-derived a stricter verdict from the raw `rollout` + `kill_switch` pair, so an admitted owner could gate off and never issue GET /v1/jit/trigger-snapshot. Admission now trusts `effective`, keeps the known-good pair as the older-server fallback, and treats a missing `kill_switch` as wire compatibility rather than an unknown-off veto; a present `unknown` still fails closed. A complete trigger snapshot is also no longer blocked by the downstream ledger-mirror sync: a failing mirror now fails itself closed (bounded, content-free log) while the snapshot still returns, so the local jit_trigger_snapshot_receipts row is written. JITTriggerMirror.reconcile still requires complete == true. SCA-369 Co-authored-by: multica-agent <[email protected]>
SCA-369 Co-authored-by: multica-agent <[email protected]>
Git-on-my-level
added a commit
that referenced
this pull request
Aug 29, 2026
…Rewind (#12384) Failure-Class: new ## What changed and why The macOS client only downloaded the JIT trigger snapshot inside `JITProactivityRuntime.admission`, which is reached exclusively through `JITProactivityCoordinator.handle` after a **notify-worthy context visit** from `ContextProactivityEngine`. Live evidence on the allowlisted account after #12381 shipped in Omi Beta 0.12.240 / 12240: `jit_trigger_snapshot_receipts` = 0, UA `Omi Beta/12240` still hits `GET /v1/jit/knowledge-ledger/prompt-snapshot` but never `rollout-decision` or `trigger-snapshot` — because Sparkle replaced the signed binary and the TCC Screen Recording grant likely dropped, so the director never evaluated and the client fix could never run. Snapshot sync must not depend on screen capture. - `JITProactivityRuntime.syncTriggerSnapshot(authorizationSnapshot:)` runs the exact admission chain — `jitProactivityFlags` → guard `permitsNewLane` → `fetchJITTriggerSnapshot` → `JITTriggerMirror.reconcile` — with no observation, no evaluation, no delivery. The fail-closed gate is unchanged: unknown/disabled still performs no snapshot read. - `DesktopHomeSignedInStartup.runProductServicesIfAdmitted` fires it once after `isProductShellAdmitted`, as a detached task so a slow authority route never gates product startup. The `.task(id: productShellAdmissionToken)` restart supplies the cheap owner-change retry (the token includes `boundOwnerID`). No new timers or loops. - A complete **empty** snapshot still persists its receipt (`rowCount` 0), and the #12381 contract is preserved: the downstream ledger-mirror sync inside `fetchJITTriggerSnapshot` stays non-blocking for the receipt. ## Product invariants affected - INV-CUTOVER-1 The hook stays strictly behind the existing `isProductShellAdmitted` fence and invents no parallel cohort/generation primitive; it is a read-only, owner-bound snapshot reconcile on the already-admitted path. ## Testing - `JITProactivityRuntimeTests.testStartupSyncFetchesSnapshotAndPersistsEmptyWatchlistReceiptWithoutAContextVisit` — effective=enabled startup fetches the snapshot and writes a receipt with zero context visits and an empty watchlist. - `JITProactivityRuntimeTests.testStartupSyncFailsClosedWhenAuthorityDoesNotPermitNewLane` — unknown, rollout-disabled, kill-switch, and `effective=disabled` skip the snapshot read and write no receipt. - `JITProactivityRuntimeTests.testStartupSyncSwallowsSnapshotFailureWithoutPersistingAReceipt` — one shot, no loop: an unavailable snapshot is swallowed content-free. - `ProactiveLaneClientTests.testStartupSnapshotSyncIssuesRolloutThenSnapshotGETAndWritesReceipt` — wire-level: the runtime startup sync drives the real client routes in order (`/v1/jit/rollout-decision` then `/v1/jit/trigger-snapshot`) and persists the empty-watchlist receipt. - `ProactiveLaneClientTests.testStartupSnapshotSyncWithEffectiveDisabledNeverIssuesSnapshotGET` — wire-level: `effective=disabled` reads only the rollout decision. - Existing #12381 wire/runtime suites (`ProactiveLaneClientTests`, `JITProactivityRuntimeTests`, `JITTriggerMirrorTests`, `JITProactivityPolicyTests`, `JITProactivityDeliveryTests`, `FloatingBarLaunchPolicyTests`) all pass unchanged. Ambient proactive work still needs screen capture; this change only removes that dependency from the snapshot/receipt sync. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/12384?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. -->
Git-on-my-level
added a commit
that referenced
this pull request
Aug 31, 2026
## What changed and why Bind JIT admission on every GCP `dev` evaluator (GKE listen, Cloud Run listen, maintenance), then make first-open, ledger writes, empty-watchlist suppress, drain, and public-docs hygiene correct before flipping `jit-processing-v1` to 100% of Omi Beta / TestFlight. Empty-extraction 500s already landed in #12410. Production `api.omi.me` PostHog is unchanged. ## Product invariants affected - INV-AGENT-* - INV-DATA-1 - INV-MEM-1 - INV-MEM-4 - INV-TASK-2 ## How it was verified - `backend/.venv/bin/python -m pytest backend/tests/unit/test_backend_runtime_env_validator.py backend/tests/unit/test_conversation_jit_processing.py backend/tests/unit/test_first_open_effect_resume.py` — 131 passed after rebase onto `origin/main`. - `python3 .github/scripts/check_agent_doc_references.py` and `check_agents_md_lean.py` — OK. - `python3 backend/deploy/compose_runtime_env.py` — generated `runtime_env.yaml` matches overlays (dev TZ recon on, prod off). - Did not deploy to GCP `dev` or flip PostHog in this PR. After merge: probe a non-allowlist Beta UID, then operators flip `jit-processing-v1` to 100% on the **dev** PostHog project only. Keep the two-UID allowlist until soak. ## Tests - Runtime-env compose requires PostHog + `OMI_FIRESTORE_DATA_PLANE_PROJECT` on listen/maintenance. - `force_process=True` still defers folders/apps when rollout admits; `bypass_jit_first_open` is the explicit reprocess hatch. - Empty folders initialize then assign; first-open never `complete('folder_assignment')` on a skip. - Ledger writes use the data-plane client; unknown preference slots stay unslotted. - macOS/Windows: complete empty watchlist suppresses; incomplete snapshot consumes the visit; Insight stays gated. - Cron skips `writer_mode=ledger` dreaming; sweep continues after one unknown slot. ## Failure class (fixes) Failure-Class: FC-rollout-flag-absent-from-a-cohost-of-its-code-path Enabling `jit-processing-v1` while GKE/Cloud Run listen and maintenance lacked `POSTHOG_PROJECT_API_KEY` (and GKE listen lacked the data-plane overlay) would have produced two behaviours for the same UID: Cloud Run chat/sync admitted, listen finalized as `configuration_missing`. ## Test plan After merge, deploy this PR to GCP `dev`. Probe a **non-allowlist** Beta UID: 1. `GET /v1/jit/rollout-decision` on desktop-backend and Cloud Run `backend` → same `effective=enabled` once the flag is on for that UID (PostHog override before 100% is fine). 2. Live-finalize via GKE listen: logs are not `configuration_missing`; first-open attaches. 3. Kill-switch drill on **dev** PostHog, including allowlist, then off. 4. Chat `create_standing_trigger` appears on Mac **and** Windows snapshots. 5. Empty ledger: no ambient nano/full; Windows does not run Insight. 6. Empty extraction conversation is 200. Then flip `jit-processing-v1` to 100% on the **dev** PostHog project. Watch writer_mode drain; do not claim extraction is off until `ledger` is the majority. Keep the two-UID allowlist until soak. Windows TestFlight floor is builds that include #12381 / #12391 / #12397; older apps keep the legacy loop and cannot be remotely disabled. ## Line-count exceptions Oversized files grew by the JIT admission/sweep patches; splitting them is out of scope for this Beta-readiness PR. Line-Count-Exception: backend/routers/conversations.py | 1955 -> 1956 | pass bypass_jit_first_open through create/finalize without splitting the router Line-Count-Exception: backend/utils/conversations/process_conversation.py | 2561 -> 2572 | add bypass_jit_first_open so force_process stays a lazy-desktop hatch, not a JIT bypass Line-Count-Exception: backend/utils/memory/canonical_memory_adapter.py | 3491 -> 3496 | keep empty replace_conversation_source a no-op after #12410 rebase Line-Count-Exception: backend/utils/memory/daily_memory_sweep.py | 4994 -> 5008 | unknown-slot ValueError skips that candidate instead of aborting the day Line-Count-Exception: backend/utils/sync/pipeline.py | 2527 -> 2528 | reprocess path sets bypass_jit_first_open <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/12452?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. -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed and why
The macOS desktop client never downloaded the JIT trigger snapshot for admitted owners:
GET /v1/jit/trigger-snapshotwas gated on the client re-deriving admission from the rawrollout+kill_switchpair instead of consuming the server's owneffectiveverdict from the same/v1/jit/rollout-decisionresponse. Live evidence (2026-08-29): Omi Beta 12237 issued rollout-decision 200s against dev desktop-backendecec0c281011(contains the #12369 allowlist) with zero trigger-snapshot reads in the same window, and the local DB for the allowlisted owner had zerojit_trigger_snapshot_receiptsrows.JITProactivityFlags.permitsNewLanenow admits oneffective == .enabledand fails closed on.disabled; the known-good rollout + kill-switch pair remains the older-server fallback. A missingkill_switchis wire compatibility, not an unknown-off veto; a presentunknownstill fails closed.fetchJITTriggerSnapshotno longer lets the downstreamKnowledgeLedgerMirrorCoordinator.syncfailure block the snapshot: mirror sync must not prevent the local trigger receipt. A failing mirror now fails itself closed (bounded, content-free error-class log) and the complete snapshot still returns, soJITTriggerMirror.reconcile(stillcomplete == true-gated) writes the receipt. A complete empty watchlist decodes via the snake_case keys and persists its receipt.owner_id; foreign-owner and undecodable bodies still fail closed.Product invariants affected
none
How it was verified
xcrun swift test --package-path Desktop --filter "JITProactivityPolicyTests|JITProactivityRuntimeTests|ProactiveLaneClientTests|JITTriggerMirrorTests|JITProactivityDeliveryTests"— 86 tests, 0 failures. This includes new wire-level URLProtocol tests that drive the realjitProactivityFlags/fetchJITTriggerSnapshotagainst the router's actual response shapes, and a runtime test proving an effective-enabled authority reads the snapshot and persists the empty-watchlist receipt../scripts/swift-format-wrapper.sh lintclean on all changed files;./scripts/swiftlint-wrapper.sh lint— 0 violations across 1444 files;python3 scripts/check_desktop_test_quality.py— at baseline.Tests
ProactiveLaneClientTests: effective=enabled admits with unknown raw flags; missingkill_switch+ effective enabled admits; all-unknown and present-unknown fail closed; complete empty snake_case watchlist decodes and returns despite a throwing mirror sync (attempted exactly once); disabled stub returns its content-free receipt without touching the mirror; foreign-owner and garbage bodies fail closed.JITProactivityPolicyTests: effective-enabled admits over non-admitting raw pairs; effective-disabled blocks an otherwise-admitting pair; present-unknown kill switch without effective still fails closed; absent kill switch with enabled rollout admits via the fallback.JITProactivityRuntimeTests: effective-enabled authority with unknown raw flags reads the trigger snapshot and persists the receipt intojit_trigger_snapshot_receipts.Failure class (fixes)
Failure-Class: new
Failure-class transition narrative
New class
FC-client-rederives-authority-verdict(.github/failure-classes/FC-client-rederives-authority-verdict.json, added here withevidence_prs: []— this PR is the evidence). Violated contract: a client consuming an authority's decision response must act on the authority's verdict field, never re-derive a stricter verdict from the raw inputs beside it — the divergence is silent (200s on the decision read, no decode error, no failing test). Canonical guard: the admission predicate points ateffective(fail-closed on.disabled), the raw pair is only an older-server fallback that distinguishes absent from present-unknownkill_switch, and the truth table is covered by wire-level tests plus a runtime receipt-persistence test. The Windows client already parses and useseffectiveand was not affected.Scoped cleanups (optional)
none