Skip to content

feat(macos): route all proactive notifications through the JIT ambient lane with derived intent and a paced budget - #12549

Merged
Git-on-my-level merged 2 commits into
mainfrom
jit-derived-watchlist-rolling-budget
Sep 1, 2026
Merged

Git-on-my-level merged 2 commits into
mainfrom
jit-derived-watchlist-rolling-budget

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Sep 1, 2026 •

Copy link
Copy Markdown
Member

What changed and why

Measured on the owner's Omi Beta account (uid vi7SA9ck…, local proactive_deliveries + jit_trigger_wakeup_receipts, PostHog jit_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:

  1. fix: bind JIT admission on GCP dev before Beta 100% rollout #12452 made a complete empty watchlist suppressed(empty_watchlist), and JITProactivityCoordinator returns true on 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 (legacy SuggestionAssistant, deliberately independent of the director) and Memory.
  2. The ambient lane's 8 nano triages/day were consumed first-come: all 8 within ~1 minute of the first activity after local midnight (08-30 01:55–02:04, 08-31 00:19–00:20 local), then nothing for ~23 hours.
  3. 4 of 5 admitted full turns ended before a delivery attempt with no row and no telemetry, and empty_watchlist was not in the bounded reason set, so PostHog showed other.

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)

  • Empty watchlist → ambient (KnowledgeLedgerTriggerWatchlistRuntime, JITProactivityRuntime). Planned authority is untouched: server triggers still arbitrate first and still fail closed on quarantined/rejected entries.
  • Derived standing intent (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 opaque JITProactivityReservation.identifiers, calendar entries carry a fixed label so event content stays local (JIT decision 25). Matches are recorded in local provenance as derived_intent_ids and ground the full turn.
  • Pacing (JITAmbientPacingPolicy.swift, pure): burst of 2, then activeDay(16h)/budget spacing (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 on the JIT lane: ambient full turns may return 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.isEnabled yields only while JITProactivityLaneState.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.
  • Telemetry: admission gains empty_watchlist, ambient_paced, ambient_reserved_for_intent, ambient_server_denied (still deduped per process). A new undeduped jit_proactivity_delivery event carries outcome (delivered / delivery_failed / delivery_suppressed), bounded reason (every pre-attempt and terminal exit), lane, and bounded decision (insight/task_candidate/focus_nudge/silence), so delivered-per-kind-per-day is measurable. Content-free by construction.
  • Server denial backoff: when the server denies the nano reservation (its budget is cross-device), the runtime suppresses further ambient spend for that local budget day for 30 minutes (ambient_server_denied) instead of re-reserving on every qualifying visit (238 denied attempts on one dogfood day, 08-29).

Not in this PR

  • Windows jitRuntime.ts still suppresses empty_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).
  • People as a derived source: there is no cheap local people index; ledger mirror tables carry ids only.
  • Memory/Task extraction assistants are unchanged (the sweep lane that replaces them is dormant until Ledger drain never runs: memory-maintenance-job dies at its 3600s timeout every hour, so no account has ever reached writer_mode=ledger #12535).
  • Client budget day is 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:

  1. P1 server-denied nano retry storm → 30-minute per-day backoff + hermetic test (testServerNanoDenialBacksOffInsteadOfRetryingEveryVisit).
  2. P1 client/server budget-day timezone mismatch → pre-existing, recorded above as follow-up.
  3. P1 lane state was a process-global Boolean, unset before the first visit and not owner-scoped → now owner-scoped (JITProactivityLaneState.isActive(ownerID:)), published at startup snapshot sync, and a different or absent owner reads false without a reset.
  4. P1 delivery outcomes were deduped per process → separate undeduped jit_proactivity_delivery event with bounded decision kind.
  5. P2 one-keyword entries and generic PR words matched unrelated windows → entries need two discriminating keywords; workflow stopwords (review, pull, request, …) added; negative test on a real PR window title.
  6. P2 Windows still suppresses empty watchlists → registered in contracts/parity/README.md divergence register (item 5) with Windows as the losing platform.

Product invariants affected

  • INV-CHAT-1 — ChatContinuityInvariants.swift gains one decision-type → badge mapping (focus_nudge → .suggestion). No continuity key, provider, viewport, or write-path behaviour changes; proactive notifications still enter the transcript under notification:<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.
  • Dogfood: named bundle omi-jit-lane built from this branch, launched via run.sh --yolo against 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 with ambient_paced and 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

Git-on-my-level and others added 2 commits September 1, 2026 15:28
…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]>
Comment on lines +197 to +217
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) })

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 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.

Fix in Cursor Fix in Web

Reviewed by Cursor Security Reviewer for commit bb48c32. Configure here.

@Git-on-my-level
Git-on-my-level merged commit fa30a87 into main Sep 1, 2026
30 checks passed
@Git-on-my-level
Git-on-my-level deleted the jit-derived-watchlist-rolling-budget branch September 1, 2026 20:00
Git-on-my-level added a commit that referenced this pull request Sep 9, 2026
…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]>
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