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

Function fetch

atomic-cli/src/commands/git/binding.rs:741–872  ·  view source on GitHub ↗

Closure acquisition through the CLI (CB-6B, RFC §8.6): Atomic remote first, the binding's bounded `changes.pack` as verified fallback.

(id: &str, remote: Option<String>, timeout: u64, insecure: bool)

Source from the content-addressed store, hash-verified

739/// Closure acquisition through the CLI (CB-6B, RFC §8.6): Atomic remote
740/// first, the binding's bounded `changes.pack` as verified fallback.
741fn fetch(id: &str, remote: Option<String>, timeout: u64, insecure: bool) -> CliResult<()> {
742 use atomic_repository::{ClosureReadiness, IncompletenessReason};
743
744 let root = find_repository_root()?;
745 let mut repo =
746 Repository::open_for_workspace_transaction(&root).map_err(CliError::Repository)?;
747 let workspace = enter_workspace(&mut repo, boundary_mode(false))?;
748
749 let git = open_git(&root)?;
750 let binding = resolve_published_binding(&git, id)?;
751
752 // Cryptography + structural verification first: a tampered binding is
753 // never a source of truth for a closure fetch.
754 verify_binding_cryptography(&binding).map_err(|error| {
755 CliError::Repository(atomic_repository::RepositoryError::InvalidOperation {
756 message: format!("binding {} fails cryptography: {error}", binding.id()),
757 })
758 })?;
759 verify_binding_content(&git, &binding).map_err(|error| {
760 CliError::Repository(atomic_repository::RepositoryError::InvalidOperation {
761 message: format!("binding {} does not match Git: {error}", binding.id()),
762 })
763 })?;
764
765 // Trust is informational here: unknown-signer content remains
766 // independently verifiable; provenance stays untrusted (RFC §5.6).
767 let config = atomic_config::RepoConfig::load(&root.join(".atomic/config.toml"))
768 .map_err(|error| git_map(error.to_string()))?;
769 let repository_identity = config.author.as_ref().and_then(|a| a.identity.as_deref());
770 let evaluation = evaluate_binding_trust(
771 &binding,
772 &config.git.trust,
773 BindingVerificationInput {
774 repository_identity,
775 },
776 true,
777 );
778
779 let wanted = repo
780 .missing_closure_objects(&binding)
781 .map_err(CliError::Repository)?;
782 println!(
783 "Fetching closure for binding {} ({} change(s), {} missing)",
784 binding.id().to_hex(),
785 binding.payload().ordered_changes.len(),
786 wanted.len()
787 );
788
789 let mut source: Option<HttpBindingChangeSource> =
790 build_remote_source(&repo, remote.as_deref(), timeout, insecure)?;
791
792 let outcome = match source.as_mut() {
793 Some(source) => repo
794 .fetch_binding_closure(
795 &git,
796 &binding,
797 Some(source),
798 &BindingPackLimits::default_limits(),

Callers 1

runMethod · 0.85

Calls 15

find_repository_rootFunction · 0.85
boundary_modeFunction · 0.85
RepositoryClass · 0.85
verify_binding_contentFunction · 0.85
evaluate_binding_trustFunction · 0.85
build_remote_sourceFunction · 0.85
print_successFunction · 0.85
print_hintFunction · 0.85
print_warningFunction · 0.85
print_infoFunction · 0.85

Tested by

no test coverage detected