| 133 | |
| 134 | #[tokio::test] |
| 135 | async fn test_vector_index_threshold() { |
| 136 | let index = VectorIndex::new(); |
| 137 | |
| 138 | let id1 = MemoryId::new(); |
| 139 | index.insert(id1.clone(), vec![1.0, 0.0, 0.0]).await; |
| 140 | |
| 141 | // Orthogonal vector should have ~0 similarity |
| 142 | let results = index |
| 143 | .search(&[0.0, 1.0, 0.0], 10, 0.5) |
| 144 | .await |
| 145 | .expect("search ok"); |
| 146 | assert!( |
| 147 | results.is_empty(), |
| 148 | "Orthogonal vector should be below threshold 0.5" |
| 149 | ); |
| 150 | |
| 151 | // Identical vector should have similarity 1.0 |
| 152 | let results = index |
| 153 | .search(&[1.0, 0.0, 0.0], 10, 0.99) |
| 154 | .await |
| 155 | .expect("search ok"); |
| 156 | assert_eq!(results.len(), 1); |
| 157 | assert!((results[0].1 - 1.0).abs() < 0.01); |
| 158 | } |
| 159 | |
| 160 | #[tokio::test] |
| 161 | async fn test_vector_index_update() { |