Repository navigation
feat(macos): route all proactive notifications through the JIT ambient lane with derived intent and a paced budget - #12549
Conversation
…t lane with derived intent and a paced budget A JIT-admitted account with no standing trigger produced zero Insight/Task notifications since #12452 made an empty watchlist suppress, while the legacy director was bypassed on every context visit. The ambient lane's eight nano triages per day were also consumed within about a minute of the first activity after local midnight, leaving the lane dead for the rest of the day (owner account, 2026-08-30/31). - Empty complete watchlist falls through to the ambient lane. - Derived, expiring standing intent (open tasks, active goals, calendar presence) is compiled locally, matched deterministically, prioritised by the pacing policy, and grounds the full turn. Never a ledger row, never sent to the server. - JITAmbientPacingPolicy spreads the daily nano budget (burst of two, then active-day/budget spacing, two reserved for intent matches) at the same server-authoritative totals. - The legacy focus-nudge assistant yields while the JIT lane is active; the ambient full turn may answer focus_nudge under the Focus badge. - Every admission and delivery-phase outcome is named in telemetry (empty_watchlist, ambient_paced, delivery_* reasons were 'other'/silent). Co-Authored-By: Claude Fable 5.1 <[email protected]>
- Back off 30 minutes per local budget day after the server denies a nano reservation instead of re-reserving on every qualifying visit. - Scope the legacy/JIT focus handoff to the admitted owner and publish it at startup snapshot sync, so the two producers never overlap and a later owner never inherits it. - Emit one undeduped, content-free jit_proactivity_delivery event per terminal outcome with a bounded decision kind. - Require two discriminating keywords per derived entry and treat generic workflow words as stopwords. - Register the Windows empty-watchlist divergence in the parity register. Co-Authored-By: Claude Fable 5.1 <[email protected]>
| func entries(ownerID: String, now: Date = Date()) async -> [JITDerivedIntentEntry] { | ||
| if let cache, cache.ownerID == ownerID, now.timeIntervalSince(cache.loadedAt) < Self.refreshInterval { | ||
| return cache.entries | ||
| } | ||
| let loaded = await loader() | ||
| cache = (ownerID, loaded, now) | ||
| return loaded | ||
| } | ||
|
|
||
| func invalidate() { | ||
| cache = nil | ||
| } | ||
|
|
||
| /// Best-effort local reads. A failing source contributes nothing rather than | ||
| /// blocking admission; the ambient lane then paces as if no intent matched. | ||
| static func loadLocalIntent() async -> [JITDerivedIntentEntry] { | ||
| let tasks = (try? await ActionItemStorage.shared.getRecentActiveTasks(limit: maxTasks)) ?? [] | ||
| let goals = (try? await GoalStorage.shared.getLocalGoals(activeOnly: true)) ?? [] | ||
| return JITDerivedWatchlistCompiler.compile( | ||
| tasks: tasks.map { (identity: $0.backendId ?? "", description: $0.description) }, | ||
| goals: goals.map { (identity: $0.id, title: $0.title) }) |
There was a problem hiding this comment.
🔒 Agentic Security Review
Severity: MEDIUM
JITDerivedWatchlistSource keys its cache by the caller-supplied ownerID, but loadLocalIntent() always reads the process-current ActionItemStorage / GoalStorage pools. After the await loader(), those rows are stored under the original owner with a 600s TTL, and invalidate() is never called from RuntimeOwnerIdentity.retargetOwnerBoundLocalStorage (unlike neighboring owner-bound caches).
Impact: On a same-device account switch (A→B during the load, then back to A within 10 minutes), owner A's ambient JIT prompt can be grounded on owner B's open task descriptions and goal titles, and those labels can also appear in Focus/Insight notifications. That crosses the local owner-isolation boundary this codebase already fences elsewhere.
Reviewed by Cursor Security Reviewer for commit bb48c32. Configure here.
…ne (#13277) * fix(windows): route an empty complete JIT watchlist to the ambient lane Parity register item 5: since #12549 macOS hands a complete *empty* watchlist to the bounded ambient lane (owner decision 2026-09-01: an account with no standing trigger must not go silent). Windows still evaluated it to `none` and suppressed `empty_watchlist`, so on the Windows client every JIT-admitted account without a trigger produced no ambient candidate at all. `evaluateJitWatchlist` now returns `ambient_fallback` for an empty complete watchlist exactly like a non-empty watchlist with no match, `JitRuntime.admit` surfaces it as `no_eligible_planned_trigger` (the one planned outcome `WindowsJitAssistant` hands to `admitAmbient`), and the `empty_watchlist` reason is retired. Inactive/unauthorized authority still evaluates to `none`. The register entry is marked converged; the Windows local-budget-day gap (macOS #12798) stays listed under the JIT client floor. Failure-Class: none Co-Authored-By: Claude Fable 5.1 <[email protected]> * test(windows): pin the empty-watchlist route end to end and record the ambient pacing gap Adversarial review of this PR found that the routing change is correct but the parity claim was not. Two changes, no behaviour change: - `contracts/parity/README.md`: item 5 is no longer marked converged. macOS bounds its ambient lane with `JITAmbientPacingPolicy` (burst 2, then one per two hours, 2 triages reserved for derived intent), an `ambient_server_denied` backoff, and a local per-day nano usage read before spend; Windows `admitAmbient` has none of these (`claimJitWakeup` is called with `budget: null`). The entry now reads "routing converged; ambient pacing missing on Windows" and lists the four remaining gaps — pacing, denial backoff, local usage read, and the OCR-keyed ambient context cooldown that makes `reserveProactivity` unbounded per settled context — next to the existing budget-day gap under the JIT client floor (decision 19). - `jitAssistantDelivery.test.ts`: the four existing ambient cases all fake the runtime, so a regression inside `WindowsJitRuntime.admit` would pass them. Adds two cases that drive the REAL runtime (only the authority client and an in-memory sqlite db are supplied) through `WindowsJitAssistant.analyze` over a complete empty snapshot: one asserts the ambient lane is reached and buys exactly the single `nano_triage` reservation, one asserts an INCOMPLETE snapshot still buys nothing. Reverting the `jitTriggerRuntime.ts` routing line fails the first and leaves the second passing. Co-Authored-By: Claude Fable 5.1 <[email protected]> --------- Co-authored-by: Claude Fable 5.1 <[email protected]>


What changed and why
Measured on the owner's Omi Beta account (uid
vi7SA9ck…, localproactive_deliveries+jit_trigger_wakeup_receipts, PostHogjit_proactivity_admission): director/JIT-delivered notifications went from 8–29/day (08-21..08-27) to 1 total over 08-28..09-01 while capture volume stayed normal. Three causes, all in the JIT client path:suppressed(empty_watchlist), andJITProactivityCoordinatorreturnstrueon every suppression, so the legacy director was never reached. No Beta user has ever created a standing trigger, so every JIT-admitted account was silent. The only notifications left were Focus (legacySuggestionAssistant, deliberately independent of the director) and Memory.empty_watchlistwas not in the bounded reason set, so PostHog showedother.Owner decisions (2026-09-01): derived intent allowed; no legacy fallback ("I want to know if the new logic works"); Focus migrates in this PR; the fixed daily cap becomes a rolling budget spent at delivery moments at the same totals.
The change (macOS client only; no backend or wire change)
KnowledgeLedgerTriggerWatchlistRuntime,JITProactivityRuntime). Planned authority is untouched: server triggers still arbitrate first and still fail closed on quarantined/rejected entries.JITDerivedWatchlist.swift): open tasks (ActionItemStorage.getRecentActiveTasks), active goals (GoalStorage.getLocalGoals), and calendar presence compile into bounded local entries (≤64, ≤6 keywords, stopword-filtered, ≥2 keyword hits to match). They are not ledger rows: no action, no planned wakeup, never sent to the server, ids are opaqueJITProactivityReservation.identifiers, calendar entries carry a fixed label so event content stays local (JIT decision 25). Matches are recorded in local provenance asderived_intent_idsand ground the full turn.JITAmbientPacingPolicy.swift, pure): burst of 2, thenactiveDay(16h)/budgetspacing (2h at 8/day), last 2 reserved for intent matches; an intent match bypasses spacing but never the cap. Usage is read from the same receipts that enforce the daily cap (JITTriggerMirror.ambientNanoUsage), so pacing and the cap cannot disagree. A deferred context is not consumed, so it can be triaged at a later delivery moment. Server-authoritative totals (JIT decision 23) are unchanged.focus_nudge(planned stays insight-only);ProactiveNotificationKind.from(decisionType:)maps it to.suggestion, so the Focus badge, Settings toggle (categoryToggleAllows→SuggestionAssistantSettings.isEnabled) and journal copy are unchanged.SuggestionAssistant.isEnabledyields only whileJITProactivityLaneState.isActive, which the coordinator sets from the backend's own admission verdict per context visit — an unknown or disabled rollout keeps the legacy assistant live. The comment that warned against exactly this migration is rewritten to record the owner decision and the measurement that judges it.empty_watchlist,ambient_paced,ambient_reserved_for_intent,ambient_server_denied(still deduped per process). A new undedupedjit_proactivity_deliveryevent carriesoutcome(delivered/delivery_failed/delivery_suppressed), boundedreason(every pre-attempt and terminal exit),lane, and boundeddecision(insight/task_candidate/focus_nudge/silence), so delivered-per-kind-per-day is measurable. Content-free by construction.ambient_server_denied) instead of re-reserving on every qualifying visit (238 denied attempts on one dogfood day, 08-29).Not in this PR
jitRuntime.tsstill suppressesempty_watchlist(its ambient lane is caller-controlled and not wired). The beta cohort predicate is macOS-only and the Windows client floor is unmet, so parity is a follow-up before Windows activation (JIT decision 19).TimeZone.current; the server derives it from the profile timezone (jit_proactivity_store.py). Pre-existing for the daily cap; pacing inherits it. Follow-up: return the authoritative budget day with the policy.Independent review (codex gpt-5.6-sol, read-only, on the first commit)
Six findings; four fixed in the second commit, two recorded:
testServerNanoDenialBacksOffInsteadOfRetryingEveryVisit).JITProactivityLaneState.isActive(ownerID:)), published at startup snapshot sync, and a different or absent owner reads false without a reset.jit_proactivity_deliveryevent with bounded decision kind.review,pull,request, …) added; negative test on a real PR window title.contracts/parity/README.mddivergence register (item 5) with Windows as the losing platform.Product invariants affected
ChatContinuityInvariants.swiftgains one decision-type → badge mapping (focus_nudge→.suggestion). No continuity key, provider, viewport, or write-path behaviour changes; proactive notifications still enter the transcript undernotification:<kind>:<uuid>after journal acceptance.How it was verified
xcrun swift build -c debug --package-path Desktop— Build complete.xcrun swift test --package-path Desktop --filter 'KnowledgeLedgerTriggerRuntimeTests|JITProactivityRuntimeTests|JITProactivityDeliveryTests|JITAmbientPacingPolicyTests|JITDerivedWatchlistTests|JITProactivityPolicyTests|SuggestionAssistant|ChatContinuity|ProactiveNotification|ContextProactivity|NotificationService'— 143 tests, 0 failures.make preflight— see PR checks.omi-jit-lanebuilt from this branch, launched viarun.sh --yoloagainst the dev backend, signed-in owner-ready (omi-ctl state→appState: main). The screen locked shortly after launch so no context visit reached admission during the session; JIT admission/delivery lines are the measurement to read from the bundle log and PostHog once it runs through a working session. I did not observe a delivered notification from this build.Tests
KnowledgeLedgerTriggerRuntimeTests.testEmptyCompleteWatchlistFallsThroughToAmbient(inverts the fix: bind JIT admission on GCP dev before Beta 100% rollout #12452 guard; external source for the new expected value: owner decision 2026-09-01 and the delivered-per-day measurement above).JITProactivityRuntimeTests: empty watchlist reaches ambient admission and reads usage exactly once; unmatched context inside spacing defers withambient_pacedand buys nothing; derived match bypasses spacing but not the cap; usage read failure fails closed.JITAmbientPacingPolicyTests: burst, spacing, reserve, cap, unknown last spend.JITDerivedWatchlistTests: keyword extraction, deterministic bounded compile, two-hit match, calendar match without event titles, prompt section bounds, per-owner cache.JITProactivityDeliveryTests.testFocusNudgeIsAnAmbientOnlyDecisionUnderTheFocusBadge.Rollout / measurement
No flag or cohort change. Effect lands for the two enrolled dogfood UIDs on the next beta build. Judge by delivered-per-kind-per-day on the owner account against the 8–29/day pre-JIT baseline before any cohort expansion (readiness record:
omi-workspace:data/run-2026-09-01-overnight/02d-…).🤖 Generated with Claude Code