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

Method execute

atomic-cli/src/commands/intent/verify.rs:82–161  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

80
81impl IntentVerify {
82 async fn execute(&self) -> CliResult<()> {
83 let root = find_repository_root()?;
84 let repo =
85 crate::commands::open_readonly_repository(&root).map_err(CliError::Repository)?;
86
87 let inputs = bridge::read_intent(&repo, &self.id)?;
88 let node = match bridge::load_attestation(&repo, &self.id, &inputs)? {
89 bridge::Attestation::None => {
90 return Err(CliError::InvalidArgument {
91 message: format!(
92 "no attestation found for {}; run `atomic intent attest {}` first",
93 self.id, self.id
94 ),
95 })
96 }
97 bridge::Attestation::Stale(_) => {
98 return Err(CliError::InvalidArgument {
99 message: format!(
100 "the attestation for {} is stale (the intent changed since it was \
101 signed); re-run `atomic intent attest {}`",
102 self.id, self.id
103 ),
104 })
105 }
106 bridge::Attestation::Fresh(node) => *node,
107 };
108
109 // Resolve the public key to verify against. Local store first; when
110 // `--identity <name>` is given but not present locally, fall back to
111 // the configured storage server.
112 let store = IdentityStore::open_default().map_err(|e| {
113 CliError::Internal(anyhow::anyhow!("Failed to open identity store: {e}"))
114 })?;
115
116 let (public_key, source) = if let Some(name) = &self.identity {
117 match store.load_by_name(name) {
118 Ok(identity) => {
119 let did = identity.id.to_base32();
120 (
121 identity.public_key,
122 source_line(name, &did, "local identity store"),
123 )
124 }
125 Err(_) => {
126 let resolved = self.resolve_remote(name, &node).await?;
127 (resolved.key, resolved.source)
128 }
129 }
130 } else {
131 let identity = store
132 .get_default()
133 .map_err(|e| {
134 CliError::Internal(anyhow::anyhow!("Failed to load default identity: {e}"))
135 })?
136 .ok_or_else(|| CliError::InvalidArgument {
137 message: "No default identity set. Create one first:\n \
138 atomic identity new <name> --email <email> --set-default"
139 .to_string(),

Callers 1

runMethod · 0.45

Calls 10

find_repository_rootFunction · 0.85
open_readonly_repositoryFunction · 0.85
read_intentFunction · 0.85
source_lineFunction · 0.85
load_by_nameMethod · 0.80
resolve_remoteMethod · 0.80
load_attestationFunction · 0.50
verifyFunction · 0.50
to_base32Method · 0.45
get_defaultMethod · 0.45

Tested by

no test coverage detected