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