1use crate::trit::Trit;
4use serde::{Deserialize, Serialize};
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
7#[cfg_attr(feature = "mcp", derive(schemars::JsonSchema))]
8pub enum Source {
9 Human,
10 Agent,
11}
12
13#[derive(Debug, Clone, Serialize, Deserialize)]
14#[cfg_attr(feature = "mcp", derive(schemars::JsonSchema))]
15pub struct Flag {
16 pub trit: i8,
17 pub confidence: f64,
18 pub note: String,
19 pub ts: String,
20 pub source: Source,
21 pub revises: Option<u64>,
24}
25
26impl Flag {
27 pub fn new(trit: Trit, confidence: f64, note: impl Into<String>, source: Source, ts: impl Into<String>) -> Self {
28 Flag {
29 trit: trit.as_i8(),
30 confidence: confidence.clamp(0.0, 1.0),
31 note: note.into(),
32 ts: ts.into(),
33 source,
34 revises: None,
35 }
36 }
37
38 pub fn trit(&self) -> Trit {
39 Trit::from_i8(self.trit)
40 }
41
42 pub fn revising(mut self, earlier_id: u64) -> Self {
43 self.revises = Some(earlier_id);
44 self
45 }
46}