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

Method vault_intent_delete

atomic-repository/src/repository/vault_intent.rs:557–643  ·  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

555 /// goals can be deleted. Started work should be closed or superseded
556 /// instead of removed from the vault.
557 pub fn vault_intent_delete(
558 &self,
559 intent_id: &str,
560 ) -> Result<IntentDeleteResult, RepositoryError> {
561 let full_id = self.normalize_intent_id(intent_id)?;
562 let intent_file =
563 self.find_intent_path(&full_id)?
564 .ok_or_else(|| RepositoryError::InvalidOperation {
565 message: format!("Intent '{}' not found", full_id),
566 })?;
567
568 let manifest = self.vault_manifest()?;
569 let summary =
570 manifest
571 .intents
572 .get(&full_id)
573 .ok_or_else(|| RepositoryError::InvalidOperation {
574 message: format!("Intent '{}' not found", full_id),
575 })?;
576
577 if summary.status != "backlog" {
578 return Err(RepositoryError::InvalidOperation {
579 message: format!(
580 "Intent '{}' has status '{}'; only backlog intents can be deleted",
581 full_id, summary.status
582 ),
583 });
584 }
585
586 let referenced_goals = manifest
587 .goals
588 .values()
589 .filter(|goal| {
590 goal.intent
591 .as_deref()
592 .is_some_and(|id| id.eq_ignore_ascii_case(&full_id))
593 })
594 .count() as u32;
595 let linked_goals = summary.goals.max(referenced_goals);
596
597 if linked_goals > 0 {
598 return Err(RepositoryError::InvalidOperation {
599 message: format!(
600 "Intent '{}' is linked to {} goal(s); unlink or close the work instead",
601 full_id, linked_goals
602 ),
603 });
604 }
605
606 let deleted = self.vault_delete(&intent_file)?;
607 if !deleted {
608 return Err(RepositoryError::InvalidOperation {
609 message: format!("Intent '{}' not found", full_id),
610 });
611 }
612
613 {
614 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
commitMethod · 0.80
vault_dirMethod · 0.80
parentMethod · 0.80
getMethod · 0.65
removeMethod · 0.65