MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / vault_auto_index

Method vault_auto_index

atomic-repository/src/repository/vault.rs:301–336  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

299 /// Called as a side effect of `vault_store` and `vault_store_entry`.
300 /// Best-effort — logs on failure but never fails the parent operation.
301 fn vault_auto_index(&self, path: &str) {
302 // Signed attestation blobs must not pollute semantic search, and they
303 // contribute no KG triples (vault_extract_kg early-returns empty for
304 // Attestation). Skip embedding entirely for them.
305 let is_attestation = matches!(
306 self.vault_retrieve(path),
307 Ok(Some(e)) if e.entry_type == VaultEntryType::Attestation
308 );
309
310 // KG indexing — safe: extract_kg returns empty for Attestation, so
311 // vault_store_kg deletes any stale rows and stores nothing.
312 if let Err(e) = self.vault_index_kg(path) {
313 log::debug!("Auto KG index for {}: {}", path, e);
314 }
315
316 if is_attestation {
317 return; // do NOT embed
318 }
319
320 // Embedding
321 let provider = crate::ai::resolve_embedding_provider();
322 let config = EmbedConfig {
323 max_chunk_tokens: 512,
324 dimensions: provider.dimensions,
325 };
326 let embed_fn = |text: &str| -> Vec<f32> {
327 provider
328 .embed_sync(&[text.to_string()])
329 .ok()
330 .and_then(|v| v.into_iter().next())
331 .unwrap_or_else(|| hash_embed(text, provider.dimensions))
332 };
333 if let Err(e) = self.vault_embed(path, &embed_fn, &config) {
334 log::debug!("Auto embed for {}: {}", path, e);
335 }
336 }
337
338 /// Retrieve a vault entry by path.
339 pub fn vault_retrieve(

Callers 3

vault_storeMethod · 0.80
vault_store_entryMethod · 0.80
vault_deleteMethod · 0.80

Calls 7

hash_embedFunction · 0.85
vault_index_kgMethod · 0.80
embed_syncMethod · 0.80
vault_embedMethod · 0.80
nextMethod · 0.45
into_iterMethod · 0.45

Tested by

no test coverage detected