From d285eccb23f3986bfa88fc1af033e6dcb0dc3a65 Mon Sep 17 00:00:00 2001 From: Lorenz Leutgeb Date: Mon, 7 Sep 2026 18:21:54 +0200 Subject: [PATCH] fetch: Include the founder namespace always Read the initial identity document from the blob addressed by the repository ID and include its founder in the set of namespaces to be fetched. This lets clones resolve the identity COB root even if the founder is not a delegate anymore. --- crates/radicle-fetch/src/state.rs | 24 ++++++++++++++++++++++-- crates/radicle-node/src/tests/e2e.rs | 12 +++++++----- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/crates/radicle-fetch/src/state.rs b/crates/radicle-fetch/src/state.rs index bcec3c0d8..8a8fb2120 100644 --- a/crates/radicle-fetch/src/state.rs +++ b/crates/radicle-fetch/src/state.rs @@ -13,13 +13,13 @@ use radicle::storage::{ Remote, RemoteId, RemoteRepository, Remotes, ValidateRepository, Validations, git::Validation, }; -use crate::git; use crate::git::packfile::Keepfile; use crate::git::refs::{Applied, Update}; use crate::git::repository; use crate::sigrefs::SignedRefs; use crate::stage; use crate::stage::ProtocolStage; +use crate::{Allowed, git}; use crate::{Handle, refs, sigrefs, transport}; /// The data size limit, 5Mb, while fetching the special refs, @@ -321,7 +321,27 @@ impl FetchState { refs_at.iter().map(|r| &r.remote).cloned().collect() } None => { - let followed = handle.allowed(); + let mut followed = handle.allowed(); + + if let Allowed::Followed { remotes } = &mut followed { + // The initial identity document is addressed by the repository ID + // and was fetched with the canonical identity history. Include its + // founder so a fresh clone can resolve the identity COB root even + // if the founder is not a delegate anymore. + let repo = handle.repository(); + let blob = repo + .backend + .find_blob((*repo.id).into()) + .map_err(DocError::from) + .map_err(error::Canonical::Verified)?; + + let root = Doc::from_blob(&blob).map_err(error::Canonical::Verified)?; + if root.delegates().len() != 1 { + return Err(error::Canonical::Verified(DocError::Missing).into()); + } + remotes.insert(PublicKey::from(*root.delegates().first())); + } + log::trace!("Followed nodes {followed:?}"); let special_refs = stage::SpecialRefs { blocked: handle.blocked.clone(), diff --git a/crates/radicle-node/src/tests/e2e.rs b/crates/radicle-node/src/tests/e2e.rs index c6fc8bb82..cb8e1908b 100644 --- a/crates/radicle-node/src/tests/e2e.rs +++ b/crates/radicle-node/src/tests/e2e.rs @@ -826,13 +826,15 @@ fn clone_without_founder_namespace() { assert!(!eve.storage.contains(&rid).unwrap()); eve.handle.seed(rid, Scope::Followed).unwrap(); - assert_matches!( - eve - .handle + assert!( + eve.handle .fetch(rid, bob.id, DEFAULT_TIMEOUT, None) - .unwrap(), - FetchResult::Failed { reason } if reason == "missing identity document" + .unwrap() + .is_success() ); + + let cloned = eve.storage.repository(rid).unwrap(); + assert_eq!(cloned.identity_doc().unwrap().doc, doc); } #[test]