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

Method vault_intent_delete

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

539 /// goals can be deleted. Started work should be closed or superseded
540 /// instead of removed from the vault.
541 pub fn vault_intent_delete(
542 &self,
543 intent_id: &str,
544 ) -> Result<IntentDeleteResult, RepositoryError> {
545 let full_id = self.normalize_intent_id(intent_id)?;
546 let intent_file =
547 self.find_intent_path(&full_id)?
548 .ok_or_else(|| RepositoryError::InvalidOperation {
549 message: format!("Intent '{}' not found", full_id),
550 })?;
551
552 let manifest = self.vault_manifest()?;
553 let summary =
554 manifest
555 .intents
556 .get(&full_id)
557 .ok_or_else(|| RepositoryError::InvalidOperation {
558 message: format!("Intent '{}' not found", full_id),
559 })?;
560
561 if summary.status != "backlog" {
562 return Err(RepositoryError::InvalidOperation {
563 message: format!(
564 "Intent '{}' has status '{}'; only backlog intents can be deleted",
565 full_id, summary.status
566 ),
567 });
568 }
569
570 let referenced_goals = manifest
571 .goals
572 .values()
573 .filter(|goal| {
574 goal.intent
575 .as_deref()
576 .is_some_and(|id| id.eq_ignore_ascii_case(&full_id))
577 })
578 .count() as u32;
579 let linked_goals = summary.goals.max(referenced_goals);
580
581 if linked_goals > 0 {
582 return Err(RepositoryError::InvalidOperation {
583 message: format!(
584 "Intent '{}' is linked to {} goal(s); unlink or close the work instead",
585 full_id, linked_goals
586 ),
587 });
588 }
589
590 let deleted = self.vault_delete(&intent_file)?;
591 if !deleted {
592 return Err(RepositoryError::InvalidOperation {
593 message: format!("Intent '{}' not found", full_id),
594 });
595 }
596
597 {
598 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