1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//! Subscriber-side event filter over `HarnessEvent`.
//!
//! Why: The bus delivers everything to every subscriber. A given consumer (a
//! task-scoped SSE stream, a single-harness relay, a hook-only
//! aggregator) usually wants a slice of that firehose. Rather than running
//! N filtered channels, subscribers filter in their own receive loop with
//! a small predicate. Keeping the predicate beside the envelope it matches
//! on means the producer and the consumer agree on what a filter means.
//! What: A `Filter` of optional constraints (source, session, domains) plus a
//! `matches` predicate that ANDs the present constraints. An empty or
//! default filter matches everything.
//! Test: `super::tests::filter_default_matches_all`,
//! `super::tests::filter_by_source`, `super::tests::filter_by_session`,
//! `super::tests::filter_by_domain`, `super::tests::filter_combination`.
// #6846: moved verbatim from `trusty_agents_common::events::filter`.
use HarnessEvent;
use HarnessSource;
/// A conjunctive (AND) filter over `HarnessEvent`s.
///
/// Why: Subscribers express "only events from harness X, for session Y, in
/// domains Z" without bespoke matching logic at each call site. Optional
/// fields make every constraint opt-in: `None` means "don't constrain on
/// this axis", so `Filter::default()` is the match-all filter.
/// What: `source` constrains the originating harness; `session` constrains the
/// correlation key (an event with no session never matches a session
/// constraint); `domains` constrains the payload domain string
/// (`"lifecycle"`, `"hook"`, `"ping"`). `&'static str` is used for
/// `domains` because the legal domain set is fixed and known at compile
/// time, avoiding allocation for the common constants.
/// Test: `super::tests::filter_default_matches_all` and the per-axis cases.