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

Method vault_intent_delete

atomic-repository/src/repository/vault_intent.rs:573–659  ·  view source on GitHub ↗

Delete an unstarted backlog intent. This is intentionally conservative: only backlog intents with no linked goals can be deleted. Started work should be closed or superseded instead of removed from the vault.

(
        &self,
        intent_id: &str,
    )

Source from the content-addressed store, hash-verified

571 /// goals can be deleted. Started work should be closed or superseded
572 /// instead of removed from the vault.
573 pub fn vault_intent_delete(
574 &self,
575 intent_id: &str,
576 ) -> Result<IntentDeleteResult, RepositoryError> {
577 let full_id = self.normalize_intent_id(intent_id)?;
578 let intent_file =
579 self.find_intent_path(&full_id)?
580 .ok_or_else(|| RepositoryError::InvalidOperation {
581 message: format!("Intent '{}' not found", full_id),
582 })?;
583
584 let manifest = self.vault_manifest()?;
585 let summary =
586 manifest
587 .intents
588 .get(&full_id)
589 .ok_or_else(|| RepositoryError::InvalidOperation {
590 message: format!("Intent '{}' not found", full_id),
591 })?;
592
593 if summary.status != "backlog" {
594 return Err(RepositoryError::InvalidOperation {
595 message: format!(
596 "Intent '{}' has status '{}'; only backlog intents can be deleted",
597 full_id, summary.status
598 ),
599 });
600 }
601
602 let referenced_goals = manifest
603 .goals
604 .values()
605 .filter(|goal| {
606 goal.intent
607 .as_deref()
608 .is_some_and(|id| id.eq_ignore_ascii_case(&full_id))
609 })
610 .count() as u32;
611 let linked_goals = summary.goals.max(referenced_goals);
612
613 if linked_goals > 0 {
614 return Err(RepositoryError::InvalidOperation {
615 message: format!(
616 "Intent '{}' is linked to {} goal(s); unlink or close the work instead",
617 full_id, linked_goals
618 ),
619 });
620 }
621
622 let deleted = self.vault_delete(&intent_file)?;
623 if !deleted {
624 return Err(RepositoryError::InvalidOperation {
625 message: format!("Intent '{}' not found", full_id),
626 });
627 }
628
629 {
630 let mut txn = self

Calls 15

remove_empty_dirs_up_toFunction · 0.85
normalize_intent_idMethod · 0.80
find_intent_pathMethod · 0.80
vault_manifestMethod · 0.80
vault_deleteMethod · 0.80
write_txnMethod · 0.80
put_vault_manifestMethod · 0.80
vault_dirMethod · 0.80
parentMethod · 0.80
getMethod · 0.65
removeMethod · 0.65
countMethod · 0.45