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
//! Recommendation Attribution & Online Effectiveness
//!
//! This module provides types and tracking for recommendation sessions and feedback,
//! enabling the system to learn which recommendations actually help agents succeed.
//!
//! # Overview
//!
//! When the system recommends patterns or playbooks to an agent, it creates a
//! `RecommendationSession` to record what was recommended. After the agent completes
//! or abandons the task, it provides `RecommendationFeedback` indicating which
//! recommendations were used and the outcome.
//!
//! This closes the feedback loop and enables:
//! - Pattern adoption rate tracking (recommended vs. applied)
//! - Success-after-adoption rate tracking
//! - Recommendation precision metrics
//! - Improved pattern ranking based on actual effectiveness
//!
//! # Example
//!
//! ```no_run
//! use do_memory_core::memory::attribution::{
//! RecommendationTracker, RecommendationSession, RecommendationFeedback,
//! };
//! use do_memory_core::TaskOutcome;
//! use uuid::Uuid;
//! use chrono::Utc;
//!
//! # #[tokio::main]
//! # async fn main() {
//! let tracker = RecommendationTracker::new();
//!
//! // 1. Record a recommendation session when suggesting patterns
//! let session = RecommendationSession {
//! session_id: Uuid::new_v4(),
//! episode_id: Uuid::new_v4(),
//! timestamp: Utc::now(),
//! recommended_pattern_ids: vec!["pattern-123".to_string()],
//! recommended_playbook_ids: vec![],
//! };
//! let session_id = session.session_id;
//! tracker.record_session(session).await;
//!
//! // 2. Later, record feedback when the agent completes the task
//! let feedback = RecommendationFeedback {
//! session_id,
//! applied_pattern_ids: vec!["pattern-123".to_string()],
//! consulted_episode_ids: vec![],
//! outcome: TaskOutcome::Success {
//! verdict: "Task completed".to_string(),
//! artifacts: vec![],
//! },
//! agent_rating: Some(0.9),
//! };
//! tracker.record_feedback(feedback).await.unwrap();
//!
//! // 3. Get statistics on recommendation effectiveness
//! let stats = tracker.get_stats().await;
//! println!("Adoption rate: {:.1}%", stats.adoption_rate * 100.0);
//! # }
//! ```
pub use RecommendationTracker;
pub use ;