pub fn effective_repository_ref(
snap: &Snapshot,
policy: &SnapshotPolicySpec,
policy_ns: &str,
) -> Result<RepositoryRef, ValidationError>Expand description
THE repository a policy-child Snapshot runs against, resolved from the
mint-time pin + the referenced policy’s repository set. Pure. This is
the single decision every launch/deletion/pin/preflight path shares, so
multi-repo pin semantics cannot fork between consumers.
The rule, in order:
- No
policyRef— this is NOT a policy child (aSnapshotReplicationcopy CR, or a discovered row): thepolicyargument is not this row’s recipe and is ignored; the row’s own derivation (repository_ref_for: status pin → spec pin → owner ref) answers, or [ValidationError::SnapshotRepositoryUnresolvable] when it has none. - Pin present (
spec.repository) — the pin wins, but it must still be a member of the policy’s CURRENT repository set (compared by normalizedrepo_keyagainstpolicy_ns); a pin the recipe no longer lists is the terminal [ValidationError::SnapshotPinNotInPolicy] (“the recipe was edited out from under this Snapshot’s pin”), never a silent re-target. - No pin, single-repo policy — the policy’s one
spec.repository, verbatim (byte-identical to the pre-multi-repo behavior). - No pin, multi-repo policy —
[
ValidationError::MultiRepoSnapshotUnpinned]: the controller-side backstop of the admission rule; repository #1 is never guessed.
A malformed policy (neither/both repository shapes) surfaces as its
[ValidationError::PolicyRepositoryExactlyOne].