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§
- Attention
Item - 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.
- Countdown
- What a presenter needs to tick a toast’s countdown without asking srv again:
time left now (relative, so clock skew never matters) and the title with
{n}where the whole seconds go. - Focus
Report - What one frontend window last reported about focus.
- Notification
- The payload Presenters render. Every string here is app-controlled or
router-sanitized. Exported to TS as
OsNotificationso it can’t shadow the DOM’s globalNotification. - Notify
Action - A button on a toast.
idis one of a closed set (keep);labelis one of two app strings. - Policy
State - Request
- A request from a source.
agent_name/bodyare 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.jsonon every step (cheap; the config watcher holds it in memory). - Shutdown
Info - What a pending shutdown’s notification needs beyond the agent’s name: it says what will happen, counts down, and offers Keep running (docs/specs/SPEC_STOP_AN_AGENT_ONE_WAY_AND_SHUTDOWN_TOAST_2026_10_23.md §3.8).
- Tray
State - Snapshot the tray renders (§4.2).
Enums§
- Action
- Family
- Input
- Notify
Kind - 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.
- SENSITIVE_
EFFECT ShutdownInfo::effectof a sensitive operation’s countdown (SPEC_SUPER_AGENT_2026_10_25.md§5): it shares the shutdown toast, with its own two words.
Functions§
- fill_
seconds templatewith its last{n}replaced by the seconds: the one that is ours. An agent’s name earlier in it may hold{n}too; the launcher fills the same one (fill_countdown), so the first frame and the ticked ones agree.- keep_
label - The two button labels (spec §3.1): “Keep running” for an agent whose session is running, “Keep open” for one that is already stopped.
- seconds_
left - Whole seconds left, rounded up, never negative.
- shutdown_
title_ template - A pending shutdown’s title with
{n}for the seconds left (spec §3.8): “Closing QTimer in {n} s”. The name arrives pre-sanitized. - 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.