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

Method run

atomic-cli/src/commands/intent/attest.rs:34–222  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

32
33impl Command for IntentAttest {
34 fn run(&self) -> CliResult<()> {
35 let root = find_repository_root()?;
36 let repo = Repository::open(&root).map_err(CliError::Repository)?;
37
38 let inputs = bridge::read_intent(&repo, &self.id)?;
39
40 // FIRST gate WITHOUT signing: refuse to sign a node that fails for a
41 // reason attestation cannot fix (unknown status, missing why, a scope
42 // declaration with no scope-out). Missing proof/attributedTo are the
43 // expected pre-attest violations — those are exactly what signing
44 // fills, so we only refuse on violations OUTSIDE that fillable set.
45 let unattested = bridge::lift(&inputs)?;
46 let pre = validate_intent(&unattested);
47 let blocking: Vec<_> = pre
48 .results
49 .iter()
50 .filter(|v| !is_fillable_by_attest(v.path.as_deref()))
51 .collect();
52 if !blocking.is_empty() {
53 eprintln!("Cannot attest {}: the intent does not conform.", self.id);
54 eprint!("{pre}");
55 return Err(validation_failed(format!(
56 "intent {} does not conform; fix the violations above before attesting \
57 (run `atomic intent validate {}`)",
58 self.id, self.id
59 )));
60 }
61
62 // Resolve identity + keypair the way `atomic identity sign` does.
63 let store = IdentityStore::open_default().map_err(|e| {
64 CliError::Internal(anyhow::anyhow!("Failed to open identity store: {}", e))
65 })?;
66 let identity = if let Some(name) = &self.identity {
67 store
68 .load_by_name(name)
69 .map_err(|_| CliError::IdentityNotFound(name.clone()))?
70 } else {
71 store
72 .get_default()
73 .map_err(|e| {
74 CliError::Internal(anyhow::anyhow!("Failed to load default identity: {}", e))
75 })?
76 .ok_or_else(|| CliError::InvalidArgument {
77 message: "No default identity set. Create one first:\n \
78 atomic identity new <name> --email <email> --set-default"
79 .to_string(),
80 })?
81 };
82 let keypair = store.load_keypair(&identity.id, None).map_err(|e| {
83 CliError::Internal(anyhow::anyhow!(
84 "Failed to load keypair for '{}': {}",
85 identity.name,
86 e
87 ))
88 })?;
89
90 // Attest: lift + fill attributedTo (from the identity's did:atomic when
91 // absent) + hash + sign.

Callers

nothing calls this directly

Calls 15

find_repository_rootFunction · 0.85
read_intentFunction · 0.85
validate_intentFunction · 0.85
lift_and_attestFunction · 0.85
vault_path_forFunction · 0.85
writeFunction · 0.85
normalized_idFunction · 0.85
load_by_nameMethod · 0.80
load_keypairMethod · 0.80
parentMethod · 0.80
vault_storeMethod · 0.80
vault_materializeMethod · 0.80

Tested by

no test coverage detected