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

Function verify

atomic-cli/src/commands/git/binding.rs:536–607  ·  view source on GitHub ↗
(id: &str)

Source from the content-addressed store, hash-verified

534}
535
536fn verify(id: &str) -> CliResult<()> {
537 let root = find_repository_root()?;
538 let repo = Repository::open_readonly(root.clone()).map_err(CliError::from)?;
539 let git = open_git(&root)?;
540
541 let binding = if id.len() == 64 && id.chars().all(|c| c.is_ascii_hexdigit()) {
542 resolve_by_hex(&repo, id)?
543 } else {
544 resolve_by_prefix(&repo, id)?
545 };
546
547 verify_binding_cryptography(&binding).map_err(|error| {
548 CliError::Repository(atomic_repository::RepositoryError::InvalidOperation {
549 message: format!("binding {} fails cryptography: {error}", binding.id()),
550 })
551 })?;
552 verify_binding_content(&git, &binding).map_err(|error| {
553 CliError::Repository(atomic_repository::RepositoryError::InvalidOperation {
554 message: format!("binding {} does not match Git: {error}", binding.id()),
555 })
556 })?;
557
558 // Trust policy: trust is distinct from content validity.
559 let config =
560 atomic_config::RepoConfig::load(&root.join(".atomic/config.toml")).map_err(|error| {
561 CliError::Repository(atomic_repository::RepositoryError::InvalidOperation {
562 message: error.to_string(),
563 })
564 })?;
565 // Repository identity for the default trust root: the configured author
566 // identity reference (a DID when one is configured).
567 let repository_identity = config
568 .author
569 .as_ref()
570 .and_then(|author| author.identity.as_deref());
571 let content_verified = true;
572 let evaluation = evaluate_binding_trust(
573 &binding,
574 &config.git.trust,
575 BindingVerificationInput {
576 repository_identity,
577 },
578 content_verified,
579 );
580 let verdict = if evaluation.can_satisfy_publication_gate() {
581 "trusted"
582 } else {
583 "UNTRUSTED"
584 };
585 println!(
586 "binding {} commit {} origin {:?}",
587 binding.id().to_hex(),
588 binding.payload().git_commit,
589 binding.payload().origin,
590 );
591 println!(
592 "signature valid: {} · signer: {} · content: recomputed-ok · provenance: {verdict}",
593 evaluation.signature_valid,

Callers 1

runMethod · 0.70

Calls 13

find_repository_rootFunction · 0.85
resolve_by_hexFunction · 0.85
resolve_by_prefixFunction · 0.85
RepositoryClass · 0.85
verify_binding_contentFunction · 0.85
evaluate_binding_trustFunction · 0.85
as_refMethod · 0.80
open_gitFunction · 0.70
cloneMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected