Skip to content

feat(desktop): group browser tabs of one site into a shared context bucket - #11592

Merged
Git-on-my-level merged 3 commits into
mainfrom
feat/bucket-destination-routing
Aug 15, 2026
Merged

Git-on-my-level merged 3 commits into
mainfrom
feat/bucket-destination-routing

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Aug 15, 2026 •

Copy link
Copy Markdown
Member

Problem

Bucket identity is sha256(appName::normalized window title) — subjectID defaults to the reference hash, so one distinct title is always exactly one bucket. Measured on a real beta profile over ~38h:

  • 742 visits → 83 buckets, 83 distinct normalized keys → 83 buckets, 1:1, zero collapsing ever occurred
  • 50 of the 83 are Google Chrome, from only 135 entries
  • X alone is 10 buckets ((4) home / x, (2) notifications / x, home / x, individual posts…)
  • 4 separate buckets for different PRs in one repository
  • 26 buckets (31%) hold exactly one entry and never accumulate
  • 74 of 83 buckets never produced a single notification

The cost is not notification noise — the dwell gate already keeps this debris out of the reasoning path. It is missed joins: nothing can connect four views of one repo, or a repo and the channel where it is discussed.

workstreamID is not the fix. It sits inside UNIQUE(subjectKind, subjectID, COALESCE(workstreamID,'')), so it can only ever partition — two different titles have different subjectIDs and stay two buckets whatever workstreamID holds. The only merge lever in the existing design is subjectID convergence via subject_bindings, which today only ever writes self-referential rows (verified: 83 rows, all subjectID == referenceHash, all workstreamID NULL).

Change

Leading unread-badge strip. The existing count regexes are $-anchored, so (4) Home / X and Home / X hash apart. Now stripped for browsers and messaging apps. The trailing form stays messaging-only — Issue (123) outside messaging is genuine identity, and ContextTitleNormalizerTests still guards that. Also fixes a shipped pattern that matched – 4 new messages but never Slack's web title - 1 new item.

Browser destination keys. Browser contexts get a key like x.com/feed or github.com/acme/repo, proposed by the extraction call that already runs and cached on the reference hash in subject_bindings. Several hashes then resolve to one bucket. The model is consulted once per novel title and never again, so identity stays stable and replayable and nothing is added to the hot path.

Riding the existing extraction call is deliberate: the backend's ProactiveOperation enum is closed, so a new lane would need a provisioned gateway lane plus its own quota. Extraction already runs at exactly the moment a bucket exists and content is known.

Why this shape

Ten configurations over 134 real contexts, scored against a label rule fixed before any model output was inspected:

approach precision recall
route against candidate buckets, all apps 38% 18%
+ richer candidate context (accumulated facts) 40% 19%
canonical key, all apps 6% 35%
canonical key, browser-scoped 61% 33%
+ deterministic site hint 76% 34%
route against candidates, browser-scoped 53% 19%
canonical key + hint, reasoning-lane model 85% 54%
+ grounding guard 89% 54%

The shipped configuration is the extraction lane's own model (gpt-5-nano, reasoning_effort: minimal → this call reads low), which lands at 74% precision / 31% recall after the guard was tightened in review. The reasoning-lane model reaches 89%/52% on the identical prompt; that is one backend routing line if dogfooding shows the error rate is too high.

Three results drove the design:

  1. Emitting a key beats matching candidates (76% vs 53%), and is order-independent — the outcome cannot depend on which buckets happened to be recent, which is the failure mode a candidate-set design carries.
  2. Browser scoping is load-bearing. Unscoped, the model answers telegram for every thread and collapses 29 distinct private conversations into one bucket: 6% precision, the worst available outcome. 26 of the 34 available merges are inside Chrome anyway, and native-app title identity is already correct.
  3. Identity signal beat context. A mechanically-extracted trailing site token was worth +15 points; feeding richer accumulated facts was worth +2.

Self-consistency was tested and rejected — 2-of-3 agreement moved precision 80%→80%, and unanimity cost 16 points of recall. The errors are systematic, not sampling noise.

Safety

Over-merging is strictly worse than under-merging: a wrong merge pollutes an accumulated fact set that the director later cites in a real notification. Every gate fails toward the existing per-title identity.

  • Unrecognized, abstained (unknown/…), browser-named, or ungrounded keys are all rejected → context keeps its own bucket
  • Grounding guard: the claimed domain must be evidenced by the title, rejecting hallucinations like scalingforever.com/inbox for a title reading …ever.com. Free, deterministic, worth +4 points
  • explicit_open bindings are never overwritten; an applied destination is never re-adjudicated
  • Entries already written are never re-parented — retroactive fact mixing is the one operation that could poison an existing bucket
  • Routing rules sit below ScreenDerivedContent.untrustedPreamble: window titles are attacker-controlled, since any page sets document.title
  • Native apps are untouched, so no code path can merge two DM threads
  • Forward-only. No migration, no history rewritten
  • Separate kill switch (context_buckets_destination_kill, fail-open) so this can be stopped without taking the pipeline down

Known residual risk: at 74% precision on the shipped lane, roughly one in four merges is wrong. The blast radius is bounded to browser buckets, and DELETE FROM subject_bindings WHERE source LIKE 'derived_destination:%' re-fragments and lazily re-derives.

Review findings, and what changed

An adversarial review (cursor, grok-4.6) found four real defects, all fixed here:

  • The grounding guard was exploitable. Domain labels were substring-matched with no length floor, so x.com reduced to "x" and grounded against any title containing that letter — fix: thing #11 · acme/omi accepted x.com/feed, permanently parking a GitHub tab in the X bucket. Short labels now must match a whole title token; only labels of 4+ characters may substring-match. Cost: 2 points of recall on the measured set.
  • Forbidden domains were matched against the whole string, so chrome.com/tabs passed while chrome/tabs was rejected. Now checked per label.
  • Web messengers were reachable through the browser path. A Chrome title like general | acme | Slack grounded slack.com/acme, merging distinct private threads — precisely the failure browser-scoping exists to prevent. Messenger hosts and messenger-looking titles are now excluded outright.
  • isBrowser used substring matching, so Ledger Live (contains "edge") and Archive Utility (contains "arc") were treated as browsers. Now an exact application-name set.

Two further issues it raised, also fixed: the join path never touched the destination bucket's lastVisitedAt/visitCount, so both stale GC and overflow GC would prefer deleting the destination over the orphan buckets feeding it — worst for exactly the visit-once titles this feature targets. And promptFragment interpolated the raw title into the rule text, so a newline in an attacker-controlled title could forge rule structure while still sitting below the preamble.

Verification

126 proactive tests pass, 23 new. Beyond the happy paths they pin: short-label grounding rejection, per-label forbidden domains, messenger exclusion, browser-substring false positives (Ledger Live, Archive Utility), newline titles not forging prompt structure, decoding a response with no destination field, a zero-row claim leaving the binding untouched, and the join path keeping the destination bucket fresh.

One bug was caught by these tests during development: a minimum-length filter on domain parts made x.com reduce to nothing after the generic TLD was dropped, silently making the single most fragmented site ineligible to merge. The fix for that is what the review then showed had gone too far the other way.

Not covered: the measurement is one dev-centric profile. The 34 available merges are almost entirely developer tools, so generalization to non-dev usage is unverified.

Failure-Class: none

Review in cubic

Git-on-my-level and others added 2 commits August 14, 2026 20:26
…ucket

Bucket identity is sha256(app::normalized window title), so every distinct tab
title becomes its own bucket. On a real beta profile that produced 83 buckets
from 742 visits, 50 of them Chrome, with X alone split ten ways and four
separate buckets for PRs in one repository. 74 of the 83 never produced a
single notification.

Two changes.

The normalizer now strips a *leading* unread badge. The existing count regexes
were `$`-anchored, so `(4) Home / X` and `Home / X` hashed apart; the trailing
form stays messaging-app-only because `Issue (123)` there is genuine identity.
It also matches Slack's web title, which reads "1 new item" rather than
"1 new message" and so never matched the shipped pattern.

Beyond that, browser contexts get a destination key -- `x.com/feed`,
`github.com/acme/repo` -- proposed by the extraction call that already runs,
then cached on the reference hash in `subject_bindings`. Several hashes can
then share one bucket. The model is consulted once per novel title and never
again, so identity stays stable and replayable; nothing is asked of it on the
hot path.

Measured over 134 real contexts against a fixed a-priori label set:

  routing over candidate buckets, all apps    38% precision / 18% recall
  destination key, all apps                    6% / 35%
  destination key, browser-scoped             61% / 33%
  ... plus deterministic site hint            76% / 34%
  ... on the reasoning lane's model           85% / 54%
  ... plus the grounding guard                89% / 54%

Three findings drove the shape. Emitting a canonical key beat matching against
candidate buckets (76% vs 53%), and is order-independent, so the result cannot
depend on which buckets happened to be recent. Scoping to browsers is what made
it viable at all: unscoped, the model answers `telegram` for every thread and
collapses unrelated private conversations, which is 6% precision and by far the
worst outcome available. And a deterministic site hint was worth +15 points
where feeding richer accumulated context was worth +2 -- the model was short of
identity signal, not context.

Failing closed always means keeping the existing per-title identity, so the
error is a surplus bucket rather than a polluted fact set. Explicit bindings
outrank derived ones, an applied destination is never re-adjudicated, entries
already written are never re-parented, and the routing rules sit below
`untrustedPreamble` because window titles are attacker-controlled. Forward-only:
existing buckets are untouched and no history is rewritten.

Failure-Class: none
Co-Authored-By: Claude Opus 5 <[email protected]>
An adversarial review of the previous commit found four ways two unrelated
contexts could still land in one bucket.

The grounding guard was the serious one. Domain labels were substring-matched
with no length floor, so `x.com` reduced to "x" and grounded against any title
containing that letter: `fix: thing #11 · acme/omi` accepted `x.com/feed`, and
because an applied destination is never re-adjudicated, one bad extraction
parked a GitHub tab in the X bucket permanently. Short labels now have to match
a whole title token; only labels of four or more characters may substring-match.
A plain length floor was the earlier attempt and was wrong in the other
direction -- it dropped `x.com` entirely and made X, the most fragmented site in
the sample, ineligible to merge.

Forbidden domains were compared against the whole domain string, so
`chrome.com/tabs` passed where `chrome/tabs` was rejected; now checked per
label. Web messengers were reachable through the browser path, where a title
like `general | acme | Slack` grounded `slack.com/acme` and merged distinct
private threads -- the exact failure browser scoping exists to prevent -- so
messenger hosts and messenger-looking titles are excluded outright. And
`isBrowser` matched substrings, which made `Ledger Live` and `Archive Utility`
browsers; it is now an exact application-name set.

Two more, also from review. The join path never touched the destination
bucket's `lastVisitedAt` or `visitCount`: `finalizeVisit` credits the per-title
bucket and `context_visits.bucketID` keeps pointing there, so stale GC and
overflow GC would both prefer deleting the destination over the orphans feeding
it -- worst for the visit-once titles this feature exists to join. And
`promptFragment` interpolated the raw title into its rule text, so a newline in
an attacker-controlled title could forge rule structure while still sitting
below the untrusted preamble.

Tightening costs 2 points of recall on the measured set (89%/54% -> 89%/52% on
the reasoning lane) and closes failure classes that sample never exercised.

126 tests pass, 23 new.

Failure-Class: none
Co-Authored-By: Claude Opus 5 <[email protected]>

@cursor cursor 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.

Performed orchestrated security review across all configured modules/runs with deduplication and threshold filtering. Reporting 2 net-new medium findings on the current head.

Open in Web View Automation 

Sent by Cursor Security Agent: Security Reviewer

let section = key.split(separator: "/", maxSplits: 1).dropFirst().joined(separator: "/")
let sectionParts = section.split(whereSeparator: { "/-_ ".contains($0) })
.map(String.init)
.filter { $0.count > 3 }

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
The grounding fallback accepts section tokens using raw substring matching (haystack.contains) without requiring domain evidence from the proposed destination. This allows attacker-controlled tab titles containing common tokens (for example feed/inbox) to pass grounding for unrelated destinations and create persistent wrong bucket bindings.

Impact: Context from unrelated tabs can be merged into the same destination bucket, polluting accumulated facts used for later proactive decisions.

Fix in Cursor Fix in Web

Reviewed by Cursor Security Reviewer for commit 8f7b5de. Configure here.

Produce a 150-400 token ambient narrative and discrete factual records. Facts are
proposals; include an identifier, surviving evidence text, and evidence ref for each.
App: \(appName)
Window: \(windowTitle ?? "")

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
windowTitle is still interpolated directly into the Window: prompt line without the single-line/control-character collapsing applied to the trailing site hint. Since page titles are attacker-controlled, newline/control characters can inject additional prompt-looking structure into extraction input.

Impact: A malicious page can steer extraction outputs and increase the chance of incorrect destination assignment or bucket-content pollution in browser-scoped context routing.

Fix in Cursor Fix in Web

Reviewed by Cursor Security Reviewer for commit 8f7b5de. Configure here.

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

7 issues found across 11 files

Confidence score: 3/5

  • In desktop/macos/Desktop/Sources/ProactiveAssistants/Core/ContextBucketRollup.swift, writeExtraction can bind to a stale authorized owner/visit if context changes mid-flight, which risks attaching extracted data to the wrong destination—revalidate the authorization snapshot before committing and fence stale writes.
  • In desktop/macos/Desktop/Sources/ProactiveAssistants/Core/ContextTitleNormalizer.swift, broad browser-name fragment matching and unconditional (number)/[number] prefix stripping can collapse unrelated app/browser titles into the same bucket, causing identity loss and incorrect grouping—restrict browser detection to controlled components and gate prefix stripping on confirmed source type.
  • In desktop/macos/Desktop/Sources/ProactiveAssistants/Core/ContextDestinationKey.swift and desktop/macos/Desktop/Tests/ContextDestinationKeyTests.swift, forbidden-label sanitization and messenger-token heuristics can both over-match and under-test (e.g., paths like google-chrome/tabs), so invalid destinations may pass while legitimate titles are rejected—tighten label/path checks and align tests with actual sanitize behavior.
  • In desktop/macos/e2e/flows/context-buckets-dogfood.yaml (and .pr-body.md), coverage/metrics claims are overstated or inconsistent, which increases uncertainty around regression detection for destination grouping—add a browser multi-tab grouping scenario and reconcile the reported recall numbers.
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=".pr-body.md">

<violation number="1" location=".pr-body.md:39">
P3: The recall number for the reasoning-lane model contradicts itself across the PR body. The table row "+ grounding guard" reports 89% / **54%** recall, but the prose below the table says "The reasoning-lane model reaches **89%/52%**". Since the body is the verification record for the merge decision, the two values must agree; reconcile 54% vs 52%.</violation>
</file>

<file name="desktop/macos/e2e/flows/context-buckets-dogfood.yaml">

<violation number="1" location="desktop/macos/e2e/flows/context-buckets-dogfood.yaml:22">
P3: The dogfood flow's steps never exercise browser destination grouping, so claiming coverage for ContextDestinationKey overstates the flow. None of S1–S7 opens a browser with multiple tabs of one site to verify they merge into one bucket; S1 actually asserts two numbered docs in the same app stay separate (the inverse of this module), and S6's browser check is URL-handle workstream identity, not destination keys. The feature is also behind the context_buckets_destination_kill switch, so the module may be inactive during the run. Either add a step that drives a browser destination merge, or drop the entry so covers reflects what the flow actually validates.</violation>
</file>

<file name="desktop/macos/Desktop/Tests/ContextDestinationKeyTests.swift">

<violation number="1" location="desktop/macos/Desktop/Tests/ContextDestinationKeyTests.swift:58">
P2: testBrowserNamedDomainsAreRejected gives false confidence that the per-label forbidden check rejects "google-chrome/tabs". ContextDestinationKey.sanitize only checks labels.first ("google") against forbiddenDomainLabels; "chrome" is the second label, so the guard passes. The assertion is nil only because the title "anything" does not ground the label. With a title that grounds "chrome" (e.g. "chrome new tab"), sanitize returns "dest:google-chrome/tabs", which this test's comment says must never become an identity. Either check every domain label against forbiddenDomainLabels in sanitize, or remove this case from the forbidden set — a grounded browser-name title can still be merged into one bucket.</violation>
</file>

<file name="desktop/macos/Desktop/Sources/ProactiveAssistants/Core/ContextBucketRollup.swift">

<violation number="1" location="desktop/macos/Desktop/Sources/ProactiveAssistants/Core/ContextBucketRollup.swift:717">
P2: If the authorized owner or visit changes while `writeExtraction` is in flight, this new destination write still binds the old extraction without rechecking authority. Revalidate the authorization snapshot and fence immediately before applying the destination.</violation>
</file>

<file name="desktop/macos/Desktop/Sources/ProactiveAssistants/Core/ContextTitleNormalizer.swift">

<violation number="1" location="desktop/macos/Desktop/Sources/ProactiveAssistants/Core/ContextTitleNormalizer.swift:25">
P2: Non-browser applications are treated as browsers when their localized names merely contain these fragments, so titles such as `(1) Account` can lose identity and merge unrelated buckets. Match a controlled set of complete browser names (or bundle IDs) before applying browser-only normalization.</violation>

<violation number="2" location="desktop/macos/Desktop/Sources/ProactiveAssistants/Core/ContextTitleNormalizer.swift:35">
P2: A legitimate browser or messaging title that starts with `(number)` or `[number]` is silently collapsed into the same bucket as the title without that prefix. Only strip the prefix when the capture source confirms it is an unread badge; otherwise preserve leading numeric title text.</violation>
</file>

<file name="desktop/macos/Desktop/Sources/ProactiveAssistants/Core/ContextDestinationKey.swift">

<violation number="1" location="desktop/macos/Desktop/Sources/ProactiveAssistants/Core/ContextDestinationKey.swift:112">
P3: `titleLooksLikeMessenger` rejects every browser title containing generic tokens from `messengerHosts` ("chat", "teams", "signal", "matrix", "element"). A legitimate browser repo named with such a token, e.g. `github.com/acme/chat-ui` PRs, silently loses destination grouping (its titles contain "chat"), so per-title fragmentation persists for exactly the busy destinations this feature targets. It fails safe, but consider narrowing the exclusion to the messenger title patterns it is meant to catch (Slack/Teams/WhatsApp conversation titles) rather than any token in that set.</violation>
</file>

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

Re-trigger cubic


func testBrowserNamedDomainsAreRejected() {
// Accepting these would merge every open tab into one bucket.
for forbidden in ["chrome/newtab", "google-chrome/tabs", "safari/start", "browser/home"] {

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: testBrowserNamedDomainsAreRejected gives false confidence that the per-label forbidden check rejects "google-chrome/tabs". ContextDestinationKey.sanitize only checks labels.first ("google") against forbiddenDomainLabels; "chrome" is the second label, so the guard passes. The assertion is nil only because the title "anything" does not ground the label. With a title that grounds "chrome" (e.g. "chrome new tab"), sanitize returns "dest:google-chrome/tabs", which this test's comment says must never become an identity. Either check every domain label against forbiddenDomainLabels in sanitize, or remove this case from the forbidden set — a grounded browser-name title can still be merged into one bucket.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At desktop/macos/Desktop/Tests/ContextDestinationKeyTests.swift, line 58:

<comment>testBrowserNamedDomainsAreRejected gives false confidence that the per-label forbidden check rejects "google-chrome/tabs". ContextDestinationKey.sanitize only checks labels.first ("google") against forbiddenDomainLabels; "chrome" is the second label, so the guard passes. The assertion is nil only because the title "anything" does not ground the label. With a title that grounds "chrome" (e.g. "chrome new tab"), sanitize returns "dest:google-chrome/tabs", which this test's comment says must never become an identity. Either check every domain label against forbiddenDomainLabels in sanitize, or remove this case from the forbidden set — a grounded browser-name title can still be merged into one bucket.</comment>

<file context>
@@ -0,0 +1,342 @@
+
+  func testBrowserNamedDomainsAreRejected() {
+    // Accepting these would merge every open tab into one bucket.
+    for forbidden in ["chrome/newtab", "google-chrome/tabs", "safari/start", "browser/home"] {
+      XCTAssertNil(
+        ContextDestinationKey.sanitize(forbidden, title: "anything"),
</file context>

rawContextKey: "\(frame.appName)\n\(frame.windowTitle ?? "")",
normalizedContextKey: ContextTitleNormalizer.identityKey(
appName: frame.appName, windowTitle: frame.windowTitle) ?? "")
await applyDestinationIfEligible(extraction: extraction, frame: frame, fence: fence)

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: If the authorized owner or visit changes while writeExtraction is in flight, this new destination write still binds the old extraction without rechecking authority. Revalidate the authorization snapshot and fence immediately before applying the destination.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At desktop/macos/Desktop/Sources/ProactiveAssistants/Core/ContextBucketRollup.swift, line 717:

<comment>If the authorized owner or visit changes while `writeExtraction` is in flight, this new destination write still binds the old extraction without rechecking authority. Revalidate the authorization snapshot and fence immediately before applying the destination.</comment>

<file context>
@@ -695,6 +714,7 @@ actor ContextBucketRollupWriter {
         rawContextKey: "\(frame.appName)\n\(frame.windowTitle ?? "")",
         normalizedContextKey: ContextTitleNormalizer.identityKey(
           appName: frame.appName, windowTitle: frame.windowTitle) ?? "")
+      await applyDestinationIfEligible(extraction: extraction, frame: frame, fence: fence)
     } catch {
       switch error as? ProactiveLaneClientError {
</file context>
Suggested change
await applyDestinationIfEligible(extraction: extraction, frame: frame, fence: fence)
guard
RuntimeOwnerIdentity.isAuthorizationCurrent(authorizationSnapshot),
await store.fenceIsValid(fence)
else { return }
await applyDestinationIfEligible(extraction: extraction, frame: frame, fence: fence)

// and `Home / X` are one page. Titles do not otherwise begin with a bare
// parenthesized number, so this stays safe outside messaging apps — unlike
// the trailing form below, where `Issue (123)` is genuinely identity.
result = replacing(#"^\s*\(\d+\)\s*"#, in: result)

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: A legitimate browser or messaging title that starts with (number) or [number] is silently collapsed into the same bucket as the title without that prefix. Only strip the prefix when the capture source confirms it is an unread badge; otherwise preserve leading numeric title text.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At desktop/macos/Desktop/Sources/ProactiveAssistants/Core/ContextTitleNormalizer.swift, line 35:

<comment>A legitimate browser or messaging title that starts with `(number)` or `[number]` is silently collapsed into the same bucket as the title without that prefix. Only strip the prefix when the capture source confirms it is an unread badge; otherwise preserve leading numeric title text.</comment>

<file context>
@@ -20,12 +20,29 @@ enum ContextTitleNormalizer {
+      // and `Home / X` are one page. Titles do not otherwise begin with a bare
+      // parenthesized number, so this stays safe outside messaging apps — unlike
+      // the trailing form below, where `Issue (123)` is genuinely identity.
+      result = replacing(#"^\s*\(\d+\)\s*"#, in: result)
+      result = replacing(#"^\s*\[\d+\]\s*"#, in: result)
+    }
</file context>

Comment on lines +25 to +28
let isBrowser =
app.contains("chrome") || app.contains("safari") || app.contains("firefox")
|| app.contains("arc") || app.contains("edge") || app.contains("brave")
|| app.contains("vivaldi") || app.contains("opera")

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: Non-browser applications are treated as browsers when their localized names merely contain these fragments, so titles such as (1) Account can lose identity and merge unrelated buckets. Match a controlled set of complete browser names (or bundle IDs) before applying browser-only normalization.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At desktop/macos/Desktop/Sources/ProactiveAssistants/Core/ContextTitleNormalizer.swift, line 25:

<comment>Non-browser applications are treated as browsers when their localized names merely contain these fragments, so titles such as `(1) Account` can lose identity and merge unrelated buckets. Match a controlled set of complete browser names (or bundle IDs) before applying browser-only normalization.</comment>

<file context>
@@ -20,12 +20,29 @@ enum ContextTitleNormalizer {
-    if app.contains("telegram") || app.contains("slack") || app.contains("discord") {
+    let isMessagingApp =
+      app.contains("telegram") || app.contains("slack") || app.contains("discord")
+    let isBrowser =
+      app.contains("chrome") || app.contains("safari") || app.contains("firefox")
+      || app.contains("arc") || app.contains("edge") || app.contains("brave")
</file context>
Suggested change
let isBrowser =
app.contains("chrome") || app.contains("safari") || app.contains("firefox")
|| app.contains("arc") || app.contains("edge") || app.contains("brave")
|| app.contains("vivaldi") || app.contains("opera")
let browserNames: Set<String> = [
"chrome", "google chrome", "safari", "safari technology preview", "firefox",
"arc", "arc browser", "edge", "microsoft edge", "brave", "brave browser",
"vivaldi", "opera",
]
let isBrowser = browserNames.contains(app)

Comment thread .pr-body.md
| canonical key + hint, reasoning-lane model | 85% | 54% |
| + grounding guard | **89%** | 54% |

The shipped configuration is the extraction lane's own model (`gpt-5-nano`, `reasoning_effort: minimal` → this call reads `low`), which lands at **74% precision / 31% recall** after the guard was tightened in review. The reasoning-lane model reaches 89%/52% on the identical prompt; that is one backend routing line if dogfooding shows the error rate is too high.

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 recall number for the reasoning-lane model contradicts itself across the PR body. The table row "+ grounding guard" reports 89% / 54% recall, but the prose below the table says "The reasoning-lane model reaches 89%/52%". Since the body is the verification record for the merge decision, the two values must agree; reconcile 54% vs 52%.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .pr-body.md, line 39:

<comment>The recall number for the reasoning-lane model contradicts itself across the PR body. The table row "+ grounding guard" reports 89% / **54%** recall, but the prose below the table says "The reasoning-lane model reaches **89%/52%**". Since the body is the verification record for the merge decision, the two values must agree; reconcile 54% vs 52%.</comment>

<file context>
@@ -1,29 +1,83 @@
+| canonical key + hint, reasoning-lane model | 85% | 54% |
+| + grounding guard | **89%** | 54% |
+
+The shipped configuration is the extraction lane's own model (`gpt-5-nano`, `reasoning_effort: minimal` → this call reads `low`), which lands at **74% precision / 31% recall** after the guard was tightened in review. The reasoning-lane model reaches 89%/52% on the identical prompt; that is one backend routing line if dogfooding shows the error rate is too high.
+
+Three results drove the design:
</file context>

- desktop/macos/Desktop/Sources/ProactiveAssistants/Core/ContextBucketStore.swift
- desktop/macos/Desktop/Sources/ProactiveAssistants/Core/ContextBucketsFeature.swift
- desktop/macos/Desktop/Sources/ProactiveAssistants/Core/ContextDeliveryAuthority.swift
- desktop/macos/Desktop/Sources/ProactiveAssistants/Core/ContextDestinationKey.swift

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 dogfood flow's steps never exercise browser destination grouping, so claiming coverage for ContextDestinationKey overstates the flow. None of S1–S7 opens a browser with multiple tabs of one site to verify they merge into one bucket; S1 actually asserts two numbered docs in the same app stay separate (the inverse of this module), and S6's browser check is URL-handle workstream identity, not destination keys. The feature is also behind the context_buckets_destination_kill switch, so the module may be inactive during the run. Either add a step that drives a browser destination merge, or drop the entry so covers reflects what the flow actually validates.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At desktop/macos/e2e/flows/context-buckets-dogfood.yaml, line 22:

<comment>The dogfood flow's steps never exercise browser destination grouping, so claiming coverage for ContextDestinationKey overstates the flow. None of S1–S7 opens a browser with multiple tabs of one site to verify they merge into one bucket; S1 actually asserts two numbered docs in the same app stay separate (the inverse of this module), and S6's browser check is URL-handle workstream identity, not destination keys. The feature is also behind the context_buckets_destination_kill switch, so the module may be inactive during the run. Either add a step that drives a browser destination merge, or drop the entry so covers reflects what the flow actually validates.</comment>

<file context>
@@ -19,6 +19,7 @@ covers:
   - desktop/macos/Desktop/Sources/ProactiveAssistants/Core/ContextBucketStore.swift
   - desktop/macos/Desktop/Sources/ProactiveAssistants/Core/ContextBucketsFeature.swift
   - desktop/macos/Desktop/Sources/ProactiveAssistants/Core/ContextDeliveryAuthority.swift
+  - desktop/macos/Desktop/Sources/ProactiveAssistants/Core/ContextDestinationKey.swift
   - desktop/macos/Desktop/Sources/ProactiveAssistants/Core/ContextDetection.swift
   - desktop/macos/Desktop/Sources/ProactiveAssistants/Core/ContextProactivityEngine.swift
</file context>


private static func titleLooksLikeMessenger(_ title: String) -> Bool {
let tokens = tokenize(title)
return tokens.contains(where: { messengerHosts.contains($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.

P3: titleLooksLikeMessenger rejects every browser title containing generic tokens from messengerHosts ("chat", "teams", "signal", "matrix", "element"). A legitimate browser repo named with such a token, e.g. github.com/acme/chat-ui PRs, silently loses destination grouping (its titles contain "chat"), so per-title fragmentation persists for exactly the busy destinations this feature targets. It fails safe, but consider narrowing the exclusion to the messenger title patterns it is meant to catch (Slack/Teams/WhatsApp conversation titles) rather than any token in that set.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At desktop/macos/Desktop/Sources/ProactiveAssistants/Core/ContextDestinationKey.swift, line 112:

<comment>`titleLooksLikeMessenger` rejects every browser title containing generic tokens from `messengerHosts` ("chat", "teams", "signal", "matrix", "element"). A legitimate browser repo named with such a token, e.g. `github.com/acme/chat-ui` PRs, silently loses destination grouping (its titles contain "chat"), so per-title fragmentation persists for exactly the busy destinations this feature targets. It fails safe, but consider narrowing the exclusion to the messenger title patterns it is meant to catch (Slack/Teams/WhatsApp conversation titles) rather than any token in that set.</comment>

<file context>
@@ -0,0 +1,290 @@
+
+  private static func titleLooksLikeMessenger(_ title: String) -> Bool {
+    let tokens = tokenize(title)
+    return tokens.contains(where: { messengerHosts.contains($0) })
+  }
+
</file context>

…indings

Five of the six PR review comments were valid. Four cost nothing: measured on
the same 134 contexts, precision and recall are identical before and after
(nano 74%/31%, reasoning lane 89%/52%).

A bare domain is now rejected. `github.com` with no section satisfied every
other guard and would have collapsed every repository into one bucket; the
prompt always asks for `<domain>/<section>`, so that contract is enforced.

Forbidden labels are checked in every position rather than only the first.
`google-chrome/tabs` hides the browser name in its second label and passed
whenever the title happened to ground it -- the existing test read as covering
this but only passed because its title grounded nothing.

A domain of nothing but generic parts is rejected, so `com/feed` can no longer
become a shared key for every site with "feed" in its title.

A generic section word can no longer stand in for domain evidence. Otherwise
`x.com/feed` grounds on any page mentioning a feed. The section fallback itself
is kept deliberately: browser titles truncate from the left, so
`fix: thing #11 · acme/omi` never contains "github", and requiring domain
evidence outright -- the literal suggestion in review -- regressed repository
grouping by 5 points of recall while removing zero false merges. Blocking only
the generic words closes the hole at no measured cost.

`legacy_explicit_open` is protected alongside `explicit_open`. The one-time
UserDefaults import records a user's own prior binding under that source, and a
derived key must not overwrite it.

The `Window:` prompt line is now flattened. It carries the raw page-controlled
title, so a newline could append text reading as prompt structure even though it
sits below the untrusted preamble. This one predates the feature, but routing
turns extraction output into an identity decision, which raises what it is worth.

132 tests pass, 29 in this file.

Failure-Class: none
Co-Authored-By: Claude Opus 5 <[email protected]>
@Git-on-my-level

Copy link
Copy Markdown
Member Author

Review comments addressed in 21fb810488

Five of six were valid and are fixed. All four structural ones measured free — precision and recall identical on the same 134 contexts before and after (nano 74%/31%, reasoning lane 89%/52%).

  • Bare domain accepted — github.com with no section satisfied every other guard and would have collapsed every repository into one bucket. The prompt always asks for <domain>/<section>; that contract is now enforced.
  • Forbidden labels checked only in first position — google-chrome/tabs hides the browser name in its second label. Good catch that my own test read as covering this but only passed because the title "anything" grounded nothing; a title like "chrome new tab" would have produced dest:google-chrome/tabs. All labels are now checked.
  • Generic-only domain — com/feed carried no site identity yet could ground via its section. Rejected outright.
  • legacy_explicit_open unprotected — correct. The one-time UserDefaults import records a user's own prior binding under that source, and the guard only covered explicit_open.
  • Raw Window: prompt line — true, and it predates this change, but routing turns extraction output into an identity decision, which raises what the vector is worth. Now flattened.

One taken in substance but not literally

The section-fallback finding identifies a real hole — x.com/feed could ground on any title containing "feed". But requiring domain evidence, as suggested, regresses the feature's motivating case. Browser titles truncate from the left, so fix: thing #11 · acme/omi never contains "github" — only the repo path. Measured:

variant nano reasoning lane
current 74% / 31% 89% / 52%
require domain evidence (as suggested) 71% / 26% 88% / 47%
block generic section words (implemented) 74% / 31% 89% / 52%

Requiring domain evidence costs 5 points of recall and removes zero false merges on the measured set. Blocking only generic section words (feed, inbox, home, builds, …) closes the hole at no measured cost:

  • x.com/feed on "My Feed - Random Site" → rejected
  • evil.com/inbox on "Inbox - Gmail" → rejected
  • github.com/acme/omi on the truncated GitHub title → still accepted

132 tests pass, 29 in ContextDestinationKeyTests. All 20 preflight gates green.

@Git-on-my-level
Git-on-my-level merged commit 68e869c into main Aug 15, 2026
26 of 27 checks passed
@Git-on-my-level
Git-on-my-level deleted the feat/bucket-destination-routing branch August 15, 2026 01:31
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