Automatically index a vault entry into the KG and embed it. Called as a side effect of `vault_store` and `vault_store_entry`. Best-effort — logs on failure but never fails the parent operation.
(&self, path: &str)
| 231 | /// Called as a side effect of `vault_store` and `vault_store_entry`. |
| 232 | /// Best-effort — logs on failure but never fails the parent operation. |
| 233 | fn vault_auto_index(&self, path: &str) { |
| 234 | // Signed attestation blobs must not pollute semantic search, and they |
| 235 | // contribute no KG triples (vault_extract_kg early-returns empty for |
| 236 | // Attestation). Skip embedding entirely for them. |
| 237 | let is_attestation = matches!( |
| 238 | self.vault_retrieve(path), |
| 239 | Ok(Some(e)) if e.entry_type == VaultEntryType::Attestation |
| 240 | ); |
| 241 | |
| 242 | // KG indexing — safe: extract_kg returns empty for Attestation, so |
| 243 | // vault_store_kg deletes any stale rows and stores nothing. |
| 244 | if let Err(e) = self.vault_index_kg(path) { |
| 245 | log::debug!("Auto KG index for {}: {}", path, e); |
| 246 | } |
| 247 | |
| 248 | if is_attestation { |
| 249 | return; // do NOT embed |
| 250 | } |
| 251 | |
| 252 | // Embedding |
| 253 | let provider = crate::ai::resolve_embedding_provider(); |
| 254 | let config = EmbedConfig { |
| 255 | max_chunk_tokens: 512, |
| 256 | dimensions: provider.dimensions, |
| 257 | }; |
| 258 | let embed_fn = |text: &str| -> Vec<f32> { |
| 259 | provider |
| 260 | .embed_sync(&[text.to_string()]) |
| 261 | .ok() |
| 262 | .and_then(|v| v.into_iter().next()) |
| 263 | .unwrap_or_else(|| hash_embed(text, provider.dimensions)) |
| 264 | }; |
| 265 | if let Err(e) = self.vault_embed(path, &embed_fn, &config) { |
| 266 | log::debug!("Auto embed for {}: {}", path, e); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | /// Retrieve a vault entry by path. |
| 271 | pub fn vault_retrieve( |
no test coverage detected