Skip to main content

mur_common/
event.rs

1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3
4/// A fingerprint of a behavior observed in a session transcript.
5///
6/// Captures a distinct behavior (tool call pattern, command sequence, file edit pattern)
7/// for cross-session emergence detection. Behaviors appearing across 3+ sessions
8/// become candidates for automatic pattern creation.
9#[derive(Debug, Clone, Serialize, Deserialize)]
10pub struct BehaviorFingerprint {
11    /// Unique identifier (UUID)
12    pub id: String,
13    /// Which session this came from
14    pub session_id: String,
15    /// Short description of the behavior
16    pub behavior: String,
17    /// Extracted keywords for similarity matching
18    pub keywords: Vec<String>,
19    /// When this behavior was observed
20    pub timestamp: DateTime<Utc>,
21}
22
23/// Events emitted by MUR Core for Commander and other consumers.
24#[derive(Debug, Clone, Serialize, Deserialize)]
25pub enum MurEvent {
26    PatternCreated {
27        name: String,
28    },
29    PatternEvolved {
30        name: String,
31        old_importance: f64,
32        new_importance: f64,
33    },
34    PatternDeprecated {
35        name: String,
36    },
37    InjectionCompleted {
38        patterns: Vec<String>,
39        session_id: String,
40    },
41}
42
43/// Conversation events (used by Commander watchers, defined here for sharing).
44#[derive(Debug, Clone, Serialize, Deserialize)]
45pub enum ConversationEvent {
46    UserMessage {
47        session_id: String,
48        content: String,
49        timestamp: i64,
50    },
51    AssistantMessage {
52        session_id: String,
53        content: String,
54        timestamp: i64,
55    },
56    ToolCall {
57        session_id: String,
58        tool: String,
59        args: serde_json::Value,
60        result: Option<String>,
61        timestamp: i64,
62    },
63    SessionStart {
64        session_id: String,
65        source: String,
66    },
67    SessionEnd {
68        session_id: String,
69    },
70}