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.
This commit is contained in:
Lorenz Leutgeb
2026-09-07 18:54:53 +02:00
parent 90f448241e
commit d285eccb23
2 changed files with 29 additions and 7 deletions
+22 -2
View File
@@ -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(),
+7 -5
View File
@@ -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]