← Back to Pull requests

fix(desktop): gate notification content on Runtime Host privacy policy #5002

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Sep 07, 2026 19:53 UTC
Author

Summary

Fixes #4981. The run-ended notification gated content-bearing banners (session name + reply preview, shown outside the app in Notification Center / lock screen) on settings.privacy.incognitoActive — but the local settings copy never receives privacy updates: clientOwnedSettingsPatch excludes the section and projectClientOwnedSettings keeps the host's copy. After a user enabled incognito, the stale local copy kept reading false and the banner kept exposing content.

registerNotificationsIpc now takes a mandatory privacyAuthority; the optional local-settings fallback is gone, so settings.privacy.incognitoActive is no longer consulted for this decision at all (finding 2 of the automated review). The authority resolves the verdict for the notification's own host only, which is what closes both ⚠️ findings:

  • The bridge carries the sessionId of the run that ended and main derives the owning host from the session key (resolveNotificationHostId, kept beside the rest of the gating logic so it stays unit-testable under plain node --test). The derivation lives in main on purpose: app-shell.tsx and app-shell-session-events.ts are frozen entries in the renderer architecture ledger, whose metrics may only shrink.

  • createHostPrivacyAuthority matches that host in the desktop manager entries. A reconnecting source keeps its unknown verdict instead of being filtered out of a ready-only snapshot, so it never answers runtime.policy.query and the banner is suppressed rather than leaked ([P1]).

  • A mounted session guest is never queried, since SESSION_GUEST_OPERATION_GRANTS excludes runtime.policy.query; one mounted guest can therefore no longer reject the resolution and silence unrelated local notifications ([P2]).

  • No verdict is cached and no privacy mirror is introduced.
  • Behavior change: a banner whose owning host's verdict cannot be established is now suppressed instead of raised. One consequence is not visible from the diff alone: a session id that is not a Desktop session key carries no host, so it resolves to no authority and also suppresses. If any shipped path still surfaces such an id to notifyRunEnded, that banner is now dropped rather than shown. All other notification behavior (toggle, window focus, e2e, copy, sanitization) is unchanged.

    Verification

  • apps/desktop/src/main/__tests__/notifications-policy.test.ts — 6/6 pass (node --test on the bundled module; esbuild --platform=node --external:electron). Two cases exercise the real adapter shape rather than an injected resolver: reconnecting private alongside a ready non-incognito local → suppressed with nothing queried, and ready local plus a ready shared guest whose queryRuntimePolicy throws → raised with queried exactly ['local']. The new case drives the authority from real desktopSessionKey output and covers legacy / empty / malformed ids resolving to no host.

  • tsc -p tsconfig.preload.json|tsconfig.main.json|tsconfig.renderer.json --noEmit all exit 0; biome check reports no findings on the changed files.

  • node scripts/check-renderer-architecture.mjs --base <this branch's own base> --strict-base passes: app-shell-session-events.ts is back to its recorded values exactly, and app-shell.tsx now sits below them (nonTriviaTokens 13279 → 13274, importSpecifiers back to 100). The ledger in this diff is a pure reduction; moving the best-effort .catch into the bridge pays for the one field the payload gained.

  • Counterfactual run, so "fails without it" is not just an assertion: with createHostPrivacyAuthority changed back to the old fail-open shape (a non-ready source contributes no verdict), the two real-adapter cases go red — scopes the host authority to the notification source host and attributes a notification to the host that owns its session — 4 pass / 2 fail. The temporary edit was reverted before pushing and the tree verified clean.

  • Negative finding, so this is not read as a stronger claim than it is: scripts/check-renderer-architecture.test.mjs fails 1 of 112 here ("attests the canonical main source in the final Vite entry graph"). It fails identically on a clean origin/main (0052f1cfd) worktree in the same environment, so it is not caused by this diff; the other 110 pass.

  • Not reproduced with a live OS banner or a real incognito session, and no live Electron notification E2E was run — same caveat the reviewers scoped their own findings to.
  • AI use

    Select exactly one:

  • No generative tool made a substantive contribution

  • Generative tooling made a substantive contribution
  • Tool(s) and scope: Qoder (AI coding assistant) authored the implementation and the tests on this branch and pushed the commits; the contributor of record directs the work and owns its accuracy, provenance, licensing and the merge decision. The tip commit carries Generated-by: Qoder (AI assistant), which is what a squash merge retains; the two earlier commits on this branch carry no trailer, so this PR-level statement is the authoritative disclosure for the whole change.

    Checklist

  • Tests cover the change and fail without it

  • Lint, format, typecheck and the affected suites pass locally
  • Does this PR entail a change in behavior?

  • Yes — described under Summary above

  • No
  • Diff: 650 lines (+487 / -163) across 8 files Reviewer: Adarsh-Me Review duration: 68724m
    All Vouch review confidence checks passed
    Residual risk 0.33 = Change Risk (0.59) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.59 · 650 lines diff across 8 files
    0.59
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    44%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #5002"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 44.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 59% (MEDIUM) · Higher = larger blast radius
    59%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 44.7% · Lower = rushed or shallow review
    44.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 32.6% · Safe to merge
    32.6%
    Repository