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

Method vault_delete

atomic-repository/src/repository/vault.rs:408–466  ·  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

406
407 /// Delete a vault entry by path. Also updates the manifest.
408 pub fn vault_delete(&self, path: &str) -> Result<bool, RepositoryError> {
409 self.ensure_project_identity(atomic_core::kg::project_id::MintReason::Upgrade)?;
410 let mut txn = self
411 .pristine
412 .write_txn()
413 .map_err(|e| RepositoryError::Database(e.to_string()))?;
414 use atomic_core::pristine::{EmbeddingsMutTxnT, KgMutTxnT, VaultMutTxnT, VaultTxnT};
415
416 let previous_entry = txn
417 .get_vault_entry(path)
418 .map_err(|e| RepositoryError::Database(e.to_string()))?;
419 let now = chrono::Utc::now().to_rfc3339();
420 let cascade_updates = if let Some(previous_entry) = previous_entry.as_ref() {
421 unlink_goal_from_intent_entries(&mut txn, path, previous_entry, &now)?
422 } else {
423 Vec::new()
424 };
425
426 txn.init_kg()
427 .map_err(|e| RepositoryError::Database(e.to_string()))?;
428
429 let existed = txn
430 .del_vault_entry(path)
431 .map_err(|e| RepositoryError::Database(e.to_string()))?;
432
433 // KG and embeddings are derived from the Vault entry. Clean both even
434 // if the source entry is already missing so a retry repairs stale data.
435 // Remove projected child nodes (tasks, acceptance criteria, scope,
436 // constraints) before the subject so an intent deletion does not orphan
437 // them or their SATISFIES/TOUCHES edges. No-op for non-intent subjects.
438 super::vault_triples::delete_vault_projection(&mut txn, path)?;
439 txn.del_embeddings(path)
440 .map_err(|e| RepositoryError::Database(e.to_string()))?;
441
442 if existed {
443 let mut manifest = txn
444 .get_vault_manifest()
445 .map_err(|e| RepositoryError::Database(e.to_string()))?;
446 update_manifest_for_delete(&mut manifest, path, previous_entry.as_ref(), &now);
447 apply_cascaded_intent_manifest_updates(&mut manifest, &cascade_updates, &now);
448 txn.put_vault_manifest(&manifest)
449 .map_err(|e| RepositoryError::Database(e.to_string()))?;
450 }
451
452 txn.commit()
453 .map_err(|e| RepositoryError::Database(e.to_string()))?;
454 self.vault_reindex_kg()?;
455 for update in cascade_updates {
456 self.vault_auto_index(&update.path);
457 if let Err(error) = self.vault_materialize(&update.path) {
458 log::warn!(
459 "Failed to materialize Intent '{}' after Goal deletion: {}",
460 update.path,
461 error
462 );
463 }
464 }
465 Ok(existed)

Calls 15

delete_vault_projectionFunction · 0.85
write_txnMethod · 0.80
as_refMethod · 0.80
del_vault_entryMethod · 0.80
del_embeddingsMethod · 0.80
put_vault_manifestMethod · 0.80
vault_reindex_kgMethod · 0.80
vault_auto_indexMethod · 0.80