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.
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.
FocusReport
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 OsNotification so it can’t shadow the DOM’s global Notification.
NotifyAction
A button on a toast. id is one of a closed set (keep); label is one of two app strings.
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).
ShutdownInfo
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).
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.
SENSITIVE_EFFECT
ShutdownInfo::effect of 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
template with 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.