(&self)
| 47 | |
| 48 | impl Command for IntentAttest { |
| 49 | fn run(&self) -> CliResult<()> { |
| 50 | if crate::commands::rpc::intent_attest(self)? { |
| 51 | return Ok(()); |
| 52 | } |
| 53 | |
| 54 | let root = find_repository_root()?; |
| 55 | let repo = crate::commands::open_repository_with_vault(&root)?; |
| 56 | |
| 57 | let inputs = bridge::read_intent(&repo, &self.id)?; |
| 58 | |
| 59 | // FIRST gate WITHOUT signing: refuse to sign a node that fails for a |
| 60 | // reason attestation cannot fix (unknown status, missing why, a scope |
| 61 | // declaration with no scope-out). Missing proof/attributedTo are the |
| 62 | // expected pre-attest violations — those are exactly what signing |
| 63 | // fills, so we only refuse on violations OUTSIDE that fillable set. |
| 64 | let unattested = bridge::lift(&inputs)?; |
| 65 | let pre = validate_intent(&unattested); |
| 66 | let blocking: Vec<_> = pre |
| 67 | .results |
| 68 | .iter() |
| 69 | .filter(|v| !is_fillable_by_attest(v.path.as_deref())) |
| 70 | .collect(); |
| 71 | if !blocking.is_empty() { |
| 72 | eprintln!("Cannot attest {}: the intent does not conform.", self.id); |
| 73 | eprint!("{pre}"); |
| 74 | return Err(validation_failed(format!( |
| 75 | "intent {} does not conform; fix the violations above before attesting \ |
| 76 | (run `atomic intent validate {}`)", |
| 77 | self.id, self.id |
| 78 | ))); |
| 79 | } |
| 80 | |
| 81 | // Resolve the identity the way `atomic identity sign` does. |
| 82 | let store = IdentityStore::open_default().map_err(|e| { |
| 83 | CliError::Internal(anyhow::anyhow!("Failed to open identity store: {}", e)) |
| 84 | })?; |
| 85 | let identity = if let Some(name) = &self.identity { |
| 86 | store |
| 87 | .load_by_name(name) |
| 88 | .map_err(|_| CliError::IdentityNotFound(name.clone()))? |
| 89 | } else { |
| 90 | store |
| 91 | .get_default() |
| 92 | .map_err(|e| { |
| 93 | CliError::Internal(anyhow::anyhow!("Failed to load default identity: {}", e)) |
| 94 | })? |
| 95 | .ok_or_else(|| CliError::InvalidArgument { |
| 96 | message: "No default identity set. Create one first:\n \ |
| 97 | atomic identity new <name> --email <email> --set-default" |
| 98 | .to_string(), |
| 99 | })? |
| 100 | }; |
| 101 | |
| 102 | // Signing elsewhere, step 1: say what to sign. The same preparation |
| 103 | // `lift_and_attest` does (author, content hash, canonical bytes), with |
| 104 | // no private key involved. |
| 105 | if self.prepare { |
| 106 | let prepared = prepare_attestation(unattested.to_value(), &identity.public_key); |
nothing calls this directly
no test coverage detected