Refuse orphan state without Domain Store authority

This commit is contained in:
ms2k 2026-07-17 08:05:17 +09:00
commit e97ab6471c

View file

@ -425,6 +425,33 @@ pub enum StateAnchorResetScope<'a> {
Selected(&'a Path),
}
/// Proves that no physical State Anchor exists under either retained Domain authority.
///
/// # Errors
/// Refuses changed authority, links, inaccessible paths, or any persistent or runtime anchor.
pub fn require_state_anchor_absent(
configuration: &ResolvedDomainConfiguration,
) -> Result<(), StateAnchorError> {
for plan in [
configuration.persistent_domain_root(),
configuration.runtime_domain_root(),
] {
let root = plan
.open_authority()
.map_err(|_| StateAnchorError::InvalidLayout("Domain authority changed"))?;
match open_directory(&root, Path::new("state-anchor")) {
Ok(_) => {
return Err(StateAnchorError::InvalidLayout(
"State Anchor exists without Domain Store authority",
));
}
Err(StateAnchorError::Io(error)) if error.kind() == io::ErrorKind::NotFound => {}
Err(error) => return Err(error),
}
}
Ok(())
}
/// Refuses an orphan reset quarantine without opening transient mount paths.
///
/// # Errors