use serde::{Deserialize, Serialize};
pub type NodeId = u64;
#[derive(Clone, Debug, Serialize, Deserialize)]
pub enum ProvenanceNode {
Input {
source: String,
timestamp_ns: u64,
hash: u64,
},
Transform {
operation: String,
input_refs: Vec<NodeId>,
},
Inference {
model_id: String,
model_version: String,
confidence: f32,
output: f32,
},
Fusion {
strategy: String,
input_refs: Vec<NodeId>,
},
Action {
action_type: String,
confidence: f32,
alternatives: Vec<(String, f32)>,
},
}
impl ProvenanceNode {
pub fn timestamp_ns(&self) -> Option<u64> {
match self {
ProvenanceNode::Input { timestamp_ns, .. } => Some(*timestamp_ns),
_ => None,
}
}
pub fn type_name(&self) -> &'static str {
match self {
ProvenanceNode::Input { .. } => "Input",
ProvenanceNode::Transform { .. } => "Transform",
ProvenanceNode::Inference { .. } => "Inference",
ProvenanceNode::Fusion { .. } => "Fusion",
ProvenanceNode::Action { .. } => "Action",
}
}
}