1use std::collections::HashMap;
17
18#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize, ts_rs::TS)]
21#[serde(rename_all = "snake_case")]
22#[ts(export, export_to = "../../../frontend/types/rpc/")]
23pub enum NotifyKind {
24 InputWaiting,
25 TurnCompleted,
26 TurnErrored,
27 AgentCrashed,
29 MessageNeedsReview,
32 ShutdownPending,
35 Summary,
37 Test,
38 CloudSignedOut,
42 AccountUnavailable,
47 JobFailed,
51 VaultExpiring,
56 DroneNote,
61}
62
63impl NotifyKind {
64 pub fn setting_suffix(self) -> Option<&'static str> {
66 match self {
67 NotifyKind::InputWaiting => Some("inputwaiting"),
68 NotifyKind::TurnCompleted => Some("turncompleted"),
69 NotifyKind::TurnErrored => Some("turnerrored"),
70 NotifyKind::AgentCrashed => Some("agentcrashed"),
71 NotifyKind::MessageNeedsReview => Some("messageneedsreview"),
72 NotifyKind::CloudSignedOut => Some("cloudsignedout"),
73 NotifyKind::AccountUnavailable => Some("accountunavailable"),
74 NotifyKind::JobFailed => Some("jobfailed"),
75 NotifyKind::VaultExpiring => Some("vaultexpiring"),
76 NotifyKind::DroneNote => None,
77 NotifyKind::ShutdownPending => None,
80 NotifyKind::Summary | NotifyKind::Test => None,
81 }
82 }
83
84 pub fn delay_ms(self) -> i64 {
88 match self {
89 NotifyKind::InputWaiting => 6_000,
90 NotifyKind::TurnCompleted | NotifyKind::TurnErrored | NotifyKind::AgentCrashed => 10_000,
92 NotifyKind::MessageNeedsReview => 2_000,
93 NotifyKind::ShutdownPending | NotifyKind::CloudSignedOut | NotifyKind::AccountUnavailable | NotifyKind::JobFailed | NotifyKind::VaultExpiring | NotifyKind::DroneNote => 0,
96 NotifyKind::Summary | NotifyKind::Test => 0,
97 }
98 }
99
100 pub fn priority(self) -> Priority {
101 match self {
102 NotifyKind::InputWaiting
103 | NotifyKind::AgentCrashed
104 | NotifyKind::MessageNeedsReview
105 | NotifyKind::ShutdownPending
106 | NotifyKind::CloudSignedOut
107 | NotifyKind::AccountUnavailable
108 | NotifyKind::JobFailed
109 | NotifyKind::VaultExpiring => Priority::Attention,
111 _ => Priority::Normal,
112 }
113 }
114
115 pub fn group_key(self, block_id: &str) -> String {
117 match self {
118 NotifyKind::InputWaiting => format!("input:{block_id}"),
119 NotifyKind::TurnCompleted | NotifyKind::TurnErrored | NotifyKind::AgentCrashed => {
121 format!("turn:{block_id}")
122 }
123 NotifyKind::MessageNeedsReview => format!("review:{block_id}"),
124 NotifyKind::ShutdownPending => format!("shutdown:{block_id}"),
125 NotifyKind::Summary => "summary".to_string(),
126 NotifyKind::Test => "test".to_string(),
127 NotifyKind::CloudSignedOut => "cloud".to_string(),
128 NotifyKind::AccountUnavailable | NotifyKind::JobFailed | NotifyKind::VaultExpiring | NotifyKind::DroneNote => block_id.to_string(),
130 }
131 }
132
133 fn has_summary(self) -> bool {
136 !matches!(
137 self,
138 NotifyKind::Summary
139 | NotifyKind::Test
140 | NotifyKind::CloudSignedOut
141 | NotifyKind::AccountUnavailable
142 | NotifyKind::JobFailed
143 | NotifyKind::VaultExpiring
144 | NotifyKind::DroneNote
145 )
146 }
147
148 fn rank(self) -> u8 {
152 match self {
153 NotifyKind::AgentCrashed => 2,
154 _ => 1,
155 }
156 }
157}
158
159#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize, ts_rs::TS)]
160#[serde(rename_all = "snake_case")]
161#[ts(export, export_to = "../../../frontend/types/rpc/", rename = "NotifyPriority")]
162pub enum Priority {
163 Attention,
164 Normal,
165}
166
167#[derive(Clone, Copy, Debug, PartialEq, Eq)]
169pub enum When {
170 Unfocused,
171 Always,
172 Never,
173}
174
175#[derive(Clone, Copy, Debug, PartialEq, Eq)]
177pub enum Preview {
178 Full,
179 Redacted,
180 None,
181}
182
183#[derive(Clone, Debug)]
186pub struct Settings {
187 pub enabled: bool,
188 pub when: When,
189 pub preview: Preview,
190 pub kind_enabled: HashMap<NotifyKind, bool>,
191 pub pause_until_ms: i64,
193 pub pause_allow_attention: bool,
195 pub quiet_until_ms: i64,
199 pub show_summary: bool,
201 pub external_turns: bool,
206}
207
208impl Default for Settings {
209 fn default() -> Self {
210 Settings {
211 enabled: true,
212 when: When::Unfocused,
213 preview: Preview::Redacted,
214 kind_enabled: HashMap::new(),
215 pause_until_ms: 0,
216 pause_allow_attention: false,
217 quiet_until_ms: 0,
218 show_summary: true,
219 external_turns: false,
220 }
221 }
222}
223
224pub const PER_BLOCK_WINDOW_MS: i64 = 30_000;
228pub const GLOBAL_WINDOW_MS: i64 = 60_000;
229pub const GLOBAL_MAX: usize = 4;
230
231impl Settings {
232 fn kind_on(&self, kind: NotifyKind) -> bool {
233 *self.kind_enabled.get(&kind).unwrap_or(&true)
234 }
235
236 fn summary_on(&self) -> bool {
239 self.show_summary && self.preview != Preview::None
240 }
241}
242
243#[derive(Clone, Debug, Default, PartialEq, Eq)]
245pub struct FocusReport {
246 pub window_focused: bool,
247 pub block_id: Option<String>,
248 pub window_id: Option<String>,
252}
253
254#[derive(Clone, Debug, PartialEq, Eq)]
258pub struct Request {
259 pub kind: NotifyKind,
260 pub block_id: String,
261 pub agent_name: String,
262 pub body: Option<String>,
263 pub summary: Option<String>,
266 pub shutdown: Option<ShutdownInfo>,
268}
269
270#[derive(Clone, Debug, PartialEq, Eq)]
274pub struct ShutdownInfo {
275 pub deadline_ms: i64,
277 pub effect: &'static str,
279 pub running: bool,
282 pub request_id: String,
286 pub labels: Option<(String, String)>,
288}
289
290#[derive(Clone, Debug)]
291pub enum Input {
292 Emit(Request),
294 Resolve { block_id: String, family: Family },
297 Focus { conn_id: String, report: FocusReport },
299 Disconnect { conn_id: String },
301 Ack { id: String, clicked: bool },
303 Tick,
305}
306
307#[derive(Clone, Copy, Debug, PartialEq, Eq)]
308pub enum Family {
309 Input,
310 Turn,
311 Shutdown,
313 Cloud,
315 Account,
317 Job,
319}
320
321impl Family {
322 fn matches(self, kind: NotifyKind) -> bool {
323 match self {
324 Family::Input => kind == NotifyKind::InputWaiting,
325 Family::Turn => {
326 matches!(kind, NotifyKind::TurnCompleted | NotifyKind::TurnErrored | NotifyKind::AgentCrashed)
327 }
328 Family::Shutdown => kind == NotifyKind::ShutdownPending,
329 Family::Cloud => kind == NotifyKind::CloudSignedOut,
330 Family::Account => kind == NotifyKind::AccountUnavailable,
331 Family::Job => matches!(kind, NotifyKind::JobFailed | NotifyKind::DroneNote),
332 }
333 }
334}
335
336#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize, ts_rs::TS)]
339#[ts(export, export_to = "../../../frontend/types/rpc/", rename = "NotifyAttentionItem")]
340pub struct AttentionItem {
341 pub id: String,
342 pub block_id: String,
343 pub title: String,
344 pub kind: NotifyKind,
347}
348
349#[derive(Clone, Debug, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize, ts_rs::TS)]
351#[ts(export, export_to = "../../../frontend/types/rpc/", rename = "NotifyTrayState")]
352pub struct TrayState {
353 pub attention: Vec<AttentionItem>,
354 #[ts(type = "number")]
355 pub paused_until_ms: i64,
356}
357
358#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize, ts_rs::TS)]
361#[ts(export, export_to = "../../../frontend/types/rpc/", rename = "NotifyAction")]
362pub struct NotifyAction {
363 pub id: String,
364 pub label: String,
365}
366
367#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize, ts_rs::TS)]
371#[ts(export, export_to = "../../../frontend/types/rpc/", rename = "NotifyCountdown")]
372pub struct Countdown {
373 #[ts(type = "number")]
374 pub remaining_ms: i64,
375 pub title_template: String,
376}
377
378#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize, ts_rs::TS)]
382#[ts(export, export_to = "../../../frontend/types/rpc/", rename = "OsNotification")]
383pub struct Notification {
384 pub id: String,
385 pub kind: NotifyKind,
386 pub priority: Priority,
387 pub block_id: String,
388 pub agent_name: String,
389 pub title: String,
390 pub body: Option<String>,
391 #[serde(default, skip_serializing_if = "Option::is_none")]
394 #[ts(optional)]
395 pub summary: Option<String>,
396 #[serde(default, skip_serializing_if = "Option::is_none")]
399 #[ts(optional)]
400 pub actions: Option<Vec<NotifyAction>>,
401 #[serde(default, skip_serializing_if = "Option::is_none")]
403 #[ts(optional)]
404 pub countdown: Option<Countdown>,
405 pub tag: String,
407 #[ts(type = "number")]
408 pub created_at_ms: i64,
409}
410
411#[derive(Clone, Debug, PartialEq, Eq)]
412pub enum Action {
413 Show(Notification),
414 Retract { id: String, tag: String },
415 Activate { id: String, block_id: String },
416}
417
418#[derive(Clone, Debug)]
419struct Live {
420 notification: Notification,
421 request_id: Option<String>,
425 effect_rank: u8,
426 due_at_ms: i64,
427 shown: bool,
428 replaces_shown: bool,
432}
433
434#[derive(Default)]
435pub struct PolicyState {
436 live: HashMap<String, Live>,
438 focus: HashMap<String, FocusReport>,
439 last_focused_conn: Option<String>,
442 next_seq: u64,
443 last_shown: HashMap<String, i64>,
445 recent: std::collections::VecDeque<i64>,
447 summarized: u32,
449}
450
451pub fn title_for(kind: NotifyKind, agent_name: &str) -> String {
454 match kind {
455 NotifyKind::InputWaiting => format!("{agent_name} has a question"),
456 NotifyKind::TurnCompleted => format!("{agent_name} finished"),
457 NotifyKind::TurnErrored => format!("{agent_name} stopped with an error"),
458 NotifyKind::AgentCrashed => format!("{agent_name} stopped unexpectedly"),
459 NotifyKind::MessageNeedsReview => format!("A message for {agent_name} needs your review"),
460 NotifyKind::ShutdownPending => format!("{agent_name} will shut down soon"),
461 NotifyKind::Summary => "More agent updates".to_string(),
463 NotifyKind::Test => "AgentMux notifications are working".to_string(),
464 NotifyKind::CloudSignedOut => "AgentMux is signed out of MuxBus".to_string(),
465 NotifyKind::AccountUnavailable => "An account can't run your agents".to_string(),
466 NotifyKind::JobFailed => format!("Job failed: {agent_name}"),
467 NotifyKind::VaultExpiring => format!("Expiring in the Vault: {agent_name}"),
468 NotifyKind::DroneNote => agent_name.to_string(),
469 }
470}
471
472pub const SENSITIVE_EFFECT: &str = "sensitive";
475
476pub fn shutdown_title_template(effect: &str, agent_name: &str) -> String {
479 if effect == SENSITIVE_EFFECT {
481 return format!("{agent_name} in {{n}} s");
482 }
483 let verb = if effect == "stop" { "Stopping" } else { "Closing" };
484 format!("{verb} {agent_name} in {{n}} s")
485}
486
487fn effect_rank(effect: &str) -> u8 {
489 match effect {
490 "close_pane" => 2,
491 "close_tab" => 1,
492 _ => 0,
493 }
494}
495
496pub fn fill_seconds(template: &str, secs: i64) -> String {
500 match template.rfind("{n}") {
501 Some(i) => format!("{}{}{}", &template[..i], secs, &template[i + 3..]),
502 None => template.to_string(),
503 }
504}
505
506pub fn seconds_left(remaining_ms: i64) -> i64 {
508 (remaining_ms.max(0) + 999) / 1000
509}
510
511pub fn keep_label(running: bool) -> &'static str {
514 if running { "Keep running" } else { "Keep open" }
515}
516
517pub fn summary_title(count: u32) -> String {
518 if count == 1 {
519 "1 more agent update".to_string()
520 } else {
521 format!("{count} more agent updates")
522 }
523}
524
525pub fn tag_for(group_key: &str) -> String {
528 let mut h: u64 = 0xcbf29ce484222325;
529 for b in group_key.as_bytes() {
530 h ^= *b as u64;
531 h = h.wrapping_mul(0x100000001b3);
532 }
533 format!("{h:016x}")
534}
535
536impl PolicyState {
537 pub fn new() -> Self {
538 Self::default()
539 }
540
541 pub(crate) fn app_focused(&self) -> bool {
543 self.focus.values().any(|f| f.window_focused)
544 }
545
546 fn looking_at(&self, block_id: &str) -> bool {
548 self.focus
549 .values()
550 .any(|f| f.window_focused && f.block_id.as_deref() == Some(block_id))
551 }
552
553 pub fn has_window(&self) -> bool {
555 !self.focus.is_empty()
556 }
557
558 pub fn window_open(&self, window_id: &str) -> bool {
560 self.focus.values().any(|f| f.window_id.as_deref() == Some(window_id))
561 }
562
563 pub fn raise_window(&self) -> Option<String> {
566 self.last_focused_conn
567 .as_ref()
568 .and_then(|c| self.focus.get(c))
569 .and_then(|f| f.window_id.clone())
570 .or_else(|| {
571 let mut ids: Vec<&String> = self.focus.values().filter_map(|f| f.window_id.as_ref()).collect();
572 ids.sort();
573 ids.first().map(|s| (*s).clone())
574 })
575 }
576
577 fn should_show(&self, n: &Notification, s: &Settings) -> bool {
579 if n.kind == NotifyKind::Test {
580 return true;
581 }
582 if self.looking_at(&n.block_id) {
583 return false;
584 }
585 match s.when {
586 When::Never => false,
587 When::Always => true,
588 When::Unfocused => !self.app_focused() || n.priority == Priority::Attention,
591 }
592 }
593
594 pub fn step(&mut self, input: Input, now_ms: i64, s: &Settings) -> Vec<Action> {
595 let mut out = Vec::new();
596 match input {
597 Input::Emit(req) => {
598 let is_test = req.kind == NotifyKind::Test;
599 if !is_test && (!s.enabled || !s.kind_on(req.kind)) {
600 return out;
601 }
602 let group = req.kind.group_key(&req.block_id);
603 let effect_rank = req.shutdown.as_ref().map_or(0, |i| effect_rank(i.effect));
604 if let Some(existing) = self.live.get_mut(&group) {
605 if existing.notification.kind.rank() > req.kind.rank() {
606 return out;
607 }
608 if let (Some(have), Some(info)) = (&existing.request_id, &req.shutdown) {
613 if *have == info.request_id && existing.effect_rank > effect_rank {
614 return out;
615 }
616 }
617 if existing.notification.kind == req.kind && req.kind == NotifyKind::InputWaiting {
624 if existing.notification.body.is_none() && s.preview != Preview::None {
625 existing.notification.body = req.body;
626 }
627 if existing.notification.summary.is_none() && s.summary_on() {
628 existing.notification.summary = req.summary;
629 }
630 return out;
631 }
632 }
633 let tag = tag_for(&group);
634 let replaced_shown = self.live.get(&group).map(|l| l.shown).unwrap_or(false);
637 self.next_seq += 1;
638 let id = format!("n{}-{}", now_ms, self.next_seq);
639 let (title, actions, countdown) = match (req.kind, &req.shutdown) {
640 (NotifyKind::ShutdownPending, Some(info)) => {
641 let remaining_ms = (info.deadline_ms - now_ms).max(0);
642 let template = shutdown_title_template(info.effect, &req.agent_name);
643 (
644 fill_seconds(&template, seconds_left(remaining_ms)),
645 Some(super::shutdown_buttons::actions(info)),
648 Some(Countdown { remaining_ms, title_template: template }),
649 )
650 }
651 _ => (title_for(req.kind, &req.agent_name), None, None),
652 };
653 let notification = Notification {
654 id,
655 kind: req.kind,
656 priority: req.kind.priority(),
657 block_id: req.block_id,
658 title,
659 actions,
660 countdown,
661 agent_name: req.agent_name,
662 body: match s.preview {
663 Preview::None => None,
664 _ => req.body,
665 },
666 summary: if s.summary_on() && req.kind.has_summary() { req.summary } else { None },
667 tag,
668 created_at_ms: now_ms,
669 };
670 if replaced_shown && req.kind.delay_ms() > 0 {
673 if let Some(old) = self.live.get(&group) {
674 out.push(Action::Retract { id: old.notification.id.clone(), tag: old.notification.tag.clone() });
675 }
676 }
677 self.live.insert(
678 group,
679 Live {
680 notification,
681 request_id: req.shutdown.as_ref().map(|i| i.request_id.clone()),
682 effect_rank,
683 due_at_ms: now_ms + req.kind.delay_ms(),
684 shown: false,
685 replaces_shown: replaced_shown,
686 },
687 );
688 if is_test {
689 out.extend(self.release_due(now_ms, s));
690 }
691 }
692 Input::Resolve { block_id, family } => {
693 self.drop_where(&mut out, |n| n.block_id == block_id && family.matches(n.kind));
694 }
695 Input::Focus { conn_id, report } => {
696 let looking = report.window_focused.then(|| report.block_id.clone()).flatten();
697 let app_focused = report.window_focused;
698 if app_focused {
699 self.last_focused_conn = Some(conn_id.clone());
700 }
701 self.focus.insert(conn_id, report);
702 if app_focused {
704 self.summarized = 0;
705 self.drop_where(&mut out, |n| n.kind == NotifyKind::Summary);
706 }
707 if let Some(b) = looking {
709 self.drop_where(&mut out, |n| n.block_id == b && n.kind != NotifyKind::Test);
710 }
711 }
712 Input::Disconnect { conn_id } => {
713 self.focus.remove(&conn_id);
714 if self.last_focused_conn.as_deref() == Some(conn_id.as_str()) {
715 self.last_focused_conn = None;
716 }
717 }
718 Input::Ack { id, clicked } => {
719 let group = self
720 .live
721 .iter()
722 .find(|(_, l)| l.notification.id == id)
723 .map(|(g, _)| g.clone());
724 if let Some(g) = group {
725 let l = self.live.remove(&g).expect("present");
726 if l.notification.kind == NotifyKind::Summary {
727 self.summarized = 0;
728 }
729 out.push(Action::Retract { id: l.notification.id.clone(), tag: l.notification.tag.clone() });
730 if clicked && !l.notification.block_id.is_empty() {
731 out.push(Action::Activate { id: l.notification.id, block_id: l.notification.block_id });
732 }
733 }
734 }
735 Input::Tick => out.extend(self.release_due(now_ms, s)),
736 }
737 out
738 }
739
740 fn release_due(&mut self, now_ms: i64, s: &Settings) -> Vec<Action> {
741 let mut out = Vec::new();
742 while self.recent.front().is_some_and(|t| now_ms - *t >= GLOBAL_WINDOW_MS) {
743 self.recent.pop_front();
744 }
745 let mut due: Vec<String> = self
746 .live
747 .iter()
748 .filter(|(_, l)| !l.shown && l.due_at_ms <= now_ms)
749 .map(|(g, _)| g.clone())
750 .collect();
751 due.sort_by_key(|g| (self.live[g].notification.created_at_ms, g.clone()));
753 let mut folded = 0u32;
754 for g in due {
755 let n = self.live[&g].notification.clone();
756 if !self.should_show(&n, s) || self.paused(&n, now_ms, s) {
757 self.live.remove(&g);
761 continue;
762 }
763 if self.rate_limited(&n, now_ms, self.live[&g].replaces_shown) {
764 self.live.remove(&g);
765 folded += 1;
766 continue;
767 }
768 let l = self.live.get_mut(&g).expect("present");
769 l.shown = true;
770 if n.kind != NotifyKind::Test && n.kind != NotifyKind::Summary {
771 self.last_shown.insert(n.block_id.clone(), now_ms);
772 self.recent.push_back(now_ms);
773 }
774 out.push(Action::Show(n));
775 }
776 if folded > 0 {
777 self.summarized += folded;
778 out.extend(self.show_summary(now_ms));
779 }
780 out
781 }
782
783 fn paused(&self, n: &Notification, now_ms: i64, s: &Settings) -> bool {
787 !matches!(n.kind, NotifyKind::Test | NotifyKind::ShutdownPending)
788 && now_ms < s.pause_until_ms.max(s.quiet_until_ms)
789 && !(s.pause_allow_attention && n.priority == Priority::Attention)
790 }
791
792 fn rate_limited(&self, n: &Notification, now_ms: i64, replaces_shown: bool) -> bool {
793 if matches!(n.kind, NotifyKind::Test | NotifyKind::Summary | NotifyKind::ShutdownPending | NotifyKind::VaultExpiring) {
796 return false;
797 }
798 if self.recent.len() >= GLOBAL_MAX {
799 return true;
800 }
801 n.priority != Priority::Attention
802 && !replaces_shown
803 && self.last_shown.get(&n.block_id).is_some_and(|t| now_ms - *t < PER_BLOCK_WINDOW_MS)
804 }
805
806 fn show_summary(&mut self, now_ms: i64) -> Vec<Action> {
808 let group = NotifyKind::Summary.group_key("");
809 self.next_seq += 1;
810 let n = Notification {
811 id: format!("n{}-{}", now_ms, self.next_seq),
812 kind: NotifyKind::Summary,
813 priority: Priority::Normal,
814 block_id: String::new(),
815 agent_name: String::new(),
816 title: summary_title(self.summarized),
817 body: Some("Open AgentMux to catch up.".to_string()),
818 summary: None,
819 actions: None,
820 countdown: None,
821 tag: tag_for(&group),
822 created_at_ms: now_ms,
823 };
824 self.live.insert(group, Live { notification: n.clone(), request_id: None, effect_rank: 0, due_at_ms: now_ms, shown: true, replaces_shown: false });
825 vec![Action::Show(n)]
826 }
827
828 pub fn tray_state(&self, s: &Settings, now_ms: i64) -> TrayState {
831 let mut attention: Vec<&Notification> = self
832 .live
833 .values()
834 .filter(|l| l.shown && l.notification.priority == Priority::Attention)
835 .map(|l| &l.notification)
836 .collect();
837 attention.sort_by_key(|n| (n.created_at_ms, n.id.clone()));
838 TrayState {
839 attention: attention
840 .into_iter()
841 .map(|n| AttentionItem { id: n.id.clone(), block_id: n.block_id.clone(), title: n.title.clone(), kind: n.kind })
842 .collect(),
843 paused_until_ms: if s.pause_until_ms > now_ms { s.pause_until_ms } else { 0 },
844 }
845 }
846
847 fn drop_where(&mut self, out: &mut Vec<Action>, pred: impl Fn(&Notification) -> bool) {
848 let groups: Vec<String> =
849 self.live.iter().filter(|(_, l)| pred(&l.notification)).map(|(g, _)| g.clone()).collect();
850 for g in groups {
851 let l = self.live.remove(&g).expect("present");
852 if l.shown {
853 out.push(Action::Retract { id: l.notification.id, tag: l.notification.tag });
854 }
855 }
856 }
857
858 pub fn live_by_id(&self, id: &str) -> Option<(NotifyKind, String, Option<String>)> {
862 self.live
863 .values()
864 .find(|l| l.notification.id == id)
865 .map(|l| (l.notification.kind, l.notification.block_id.clone(), l.request_id.clone()))
866 }
867
868 #[cfg(test)]
870 pub fn live_len(&self) -> usize {
871 self.live.len()
872 }
873}
874
875#[cfg(test)]
876#[path = "policy_tests.rs"]
877mod tests;