pub fn detect_identity_fork(
old_identity: &str,
new_identity: &str,
has_history: bool,
acknowledged: bool,
) -> Option<ValidationError>Expand description
Pure decision for the fork-on-edit guard on a username@hostname change. Returns
Some(IdentityWouldFork) iff the policy has snapshot history, the change was not
acknowledged, and the resolved identity actually differs. The webhook does the IO
(read the old object’s pinned identity + history, resolve the new identity) and
calls this.
use kopiur_api::validate::detect_identity_fork;
// History + a real change + no ack → fork.
assert!(detect_identity_fork("pg@billing", "pg@payments", true, false).is_some());
// No history yet (e.g. typo fixed before the first backup) → allowed.
assert!(detect_identity_fork("pg@billing", "pg@payments", false, false).is_none());
// Acknowledged → allowed.
assert!(detect_identity_fork("pg@billing", "pg@payments", true, true).is_none());
// No actual change → allowed.
assert!(detect_identity_fork("pg@billing", "pg@billing", true, false).is_none());