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

Method vault_delete

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

Delete a vault entry by path. Also updates the manifest.

(&self, path: &str)

Source from the content-addressed store, hash-verified

366
367 /// Delete a vault entry by path. Also updates the manifest.
368 pub fn vault_delete(&self, path: &str) -> Result<bool, RepositoryError> {
369 let mut txn = self
370 .pristine
371 .write_txn()
372 .map_err(|e| RepositoryError::Database(e.to_string()))?;
373 use atomic_core::pristine::{EmbeddingsMutTxnT, KgMutTxnT, VaultMutTxnT, VaultTxnT};
374
375 let previous_entry = txn
376 .get_vault_entry(path)
377 .map_err(|e| RepositoryError::Database(e.to_string()))?;
378 let now = chrono::Utc::now().to_rfc3339();
379 let cascade_updates = if let Some(previous_entry) = previous_entry.as_ref() {
380 unlink_goal_from_intent_entries(&mut txn, path, previous_entry, &now)?
381 } else {
382 Vec::new()
383 };
384 let entry_type = previous_entry
385 .as_ref()
386 .map(|entry| entry.entry_type)
387 .unwrap_or_else(|| infer_entry_type(path));
388
389 txn.init_kg()
390 .map_err(|e| RepositoryError::Database(e.to_string()))?;
391
392 let existed = txn
393 .del_vault_entry(path)
394 .map_err(|e| RepositoryError::Database(e.to_string()))?;
395
396 // KG and embeddings are derived from the Vault entry. Clean both even
397 // if the source entry is already missing so a retry repairs stale data.
398 let node_id = super::vault_triples::entry_subject(path, entry_type);
399 // Remove projected child nodes (tasks, acceptance criteria, scope,
400 // constraints) before the subject so an intent deletion does not orphan
401 // them or their SATISFIES/TOUCHES edges. No-op for non-intent subjects.
402 super::vault_triples::delete_intent_child_nodes(&mut txn, &node_id)?;
403 txn.del_kg_node(&node_id)
404 .map_err(|e| RepositoryError::Database(e.to_string()))?;
405 txn.del_embeddings(path)
406 .map_err(|e| RepositoryError::Database(e.to_string()))?;
407
408 if existed {
409 let mut manifest = txn
410 .get_vault_manifest()
411 .map_err(|e| RepositoryError::Database(e.to_string()))?;
412 update_manifest_for_delete(&mut manifest, path, previous_entry.as_ref(), &now);
413 apply_cascaded_intent_manifest_updates(&mut manifest, &cascade_updates, &now);
414 txn.put_vault_manifest(&manifest)
415 .map_err(|e| RepositoryError::Database(e.to_string()))?;
416 }
417
418 txn.commit()
419 .map_err(|e| RepositoryError::Database(e.to_string()))?;
420 for update in cascade_updates {
421 self.vault_auto_index(&update.path);
422 if let Err(error) = self.vault_materialize(&update.path) {
423 log::warn!(
424 "Failed to materialize Intent '{}' after Goal deletion: {}",
425 update.path,

Calls 15

infer_entry_typeFunction · 0.85
entry_subjectFunction · 0.85
write_txnMethod · 0.80
as_refMethod · 0.80
del_vault_entryMethod · 0.80
del_kg_nodeMethod · 0.80
del_embeddingsMethod · 0.80
put_vault_manifestMethod · 0.80