Skip to main content

meerkat_runtime/
input_scope.rs

1//! §11 InputScope — scoping for queue filtering and input targeting.
2
3use serde::{Deserialize, Serialize};
4
5use crate::identifiers::LogicalRuntimeId;
6use meerkat_core::lifecycle::InputId;
7
8/// Scope for filtering inputs in the queue.
9#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
10#[serde(tag = "scope_type", rename_all = "snake_case")]
11#[non_exhaustive]
12pub enum InputScope {
13    /// All inputs for a specific runtime.
14    Runtime { runtime_id: LogicalRuntimeId },
15    /// A specific input by ID.
16    Specific { input_id: InputId },
17    /// All inputs (global scope).
18    All,
19}
20
21#[cfg(test)]
22#[allow(clippy::unwrap_used)]
23mod tests {
24    use super::*;
25
26    #[test]
27    fn input_scope_runtime_serde() {
28        let scope = InputScope::Runtime {
29            runtime_id: LogicalRuntimeId::new("agent-1"),
30        };
31        let json = serde_json::to_value(&scope).unwrap();
32        assert_eq!(json["scope_type"], "runtime");
33        let parsed: InputScope = serde_json::from_value(json).unwrap();
34        assert_eq!(scope, parsed);
35    }
36
37    #[test]
38    fn input_scope_specific_serde() {
39        let scope = InputScope::Specific {
40            input_id: InputId::new(),
41        };
42        let json = serde_json::to_value(&scope).unwrap();
43        assert_eq!(json["scope_type"], "specific");
44        let parsed: InputScope = serde_json::from_value(json).unwrap();
45        assert_eq!(scope, parsed);
46    }
47
48    #[test]
49    fn input_scope_all_serde() {
50        let scope = InputScope::All;
51        let json = serde_json::to_value(&scope).unwrap();
52        assert_eq!(json["scope_type"], "all");
53        let parsed: InputScope = serde_json::from_value(json).unwrap();
54        assert_eq!(scope, parsed);
55    }
56}