Skip to main content

Module policy

Module policy 

Source
Expand description

Pure notification policy — SPEC_OS_NOTIFICATIONS_SYSTEM_2026_09_24.md §5.

PolicyState::step(input, now_ms, &settings) -> Vec<Action> is the whole decision surface: no clocks, no I/O, no broker. router.rs owns the side effects (publishing, the tick task). Keeping it pure is what makes the debounce / dedupe / focus-gate / retract rules table-testable.

Phase 1: kinds InputWaiting / TurnCompleted / TurnErrored / Test, per-kind enable, debounce, dedupe-by-group, focus gate, retract. Phase 2: AgentCrashed / MessageNeedsReview / Summary, pause, rate limits folding into a summary, and a tray state snapshot (§4.2, §5.1).

Structs§

AttentionItem
One shown Attention item, for the tray’s “needs you” submenu. Titles are app-controlled templates, so they are safe to show in a native menu.
FocusReport
What one frontend window last reported about focus.
Live 🔒
Notification
The payload Presenters render. Every string here is app-controlled or router-sanitized. Exported to TS as OsNotification so it can’t shadow the DOM’s global Notification.
PolicyState
Request
A request from a source. agent_name / body are already resolved and sanitized by the router — the policy never sees untrusted free text it would render as a title.
Settings
Resolved settings snapshot the policy reads. Built by the router from settings.json on every step (cheap; the config watcher holds it in memory).
TrayState
Snapshot the tray renders (§4.2).

Enums§

Action
Family
Input
NotifyKind
Closed set of notification kinds. A source cannot invent a new visual treatment — every kind has an app-controlled title template (§9.1).
Preview
notify:os:preview (§9.2).
Priority
When
notify:os:when (§6.0).

Constants§

GLOBAL_MAX
GLOBAL_WINDOW_MS
PER_BLOCK_WINDOW_MS
Rate limits (§5.1 step 6). Attention is exempt from the per-block limit (an agent that finished and then immediately asks something must still reach you) but not from the global one.

Functions§

summary_title
tag_for
16 hex chars of FNV-1a over the group key — stable across restarts, short enough for every Windows toast Tag limit.
title_for
Title from a closed template set (§9.1). Only the agent name is interpolated, and it arrives pre-sanitized.