# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference)
# Canonical Residual: https://corpusfetch.com/c/why-does-an-instance-accept-a-federated-warrant-it-cannot-audit-the-warrant-provenance-divergence-at-cross-org-capability-handoff.md
# Remnant Warrant:    https://corpusfetch.com/c/why-does-an-instance-accept-a-federated-warrant-it-cannot-audit-the-warrant-provenance-divergence-at-cross-org-capability-handoff.warrant.json
# Markdown SHA-256:   3d3e62174153ffcdd1bb9460f1f9635a6f0a04314d73787c3a27dbeedd85dbc5
# Code AST SHA-256:   d7656cf5552f72f37ce7557bfb73dc4fd203736f7aba13daef964b26c3274328
# Verified Classes:   UnreconstructableWarrantError
# Defensive Guards:   4 fail-closed invariants (zero external deps)

class UnreconstructableWarrantError(RuntimeError):
    """Raised when a federated warrant cannot be audit-joined across orgs."""
    pass


def accept_federated_warrant(
    warrant: dict,
    local_policy_version: str,
    peer_policy_version: str,
    shared_algebra_version: str | None,
    mapping_persisted_to_both_trails: bool,
    peer_policy_mutated_in_place: bool,
    scope_resolvable_offline: bool,
) -> None:
    if shared_algebra_version is None:
        raise UnreconstructableWarrantError(
            "No shared scope algebra pinned in warrant; scope meaning would "
            "depend on a live peer call at audit time."
        )
    if not mapping_persisted_to_both_trails:
        raise UnreconstructableWarrantError(
            "Negotiated scope mapping not persisted to both audit trails "
            "before execution; delegated action would be unauditable."
        )
    if peer_policy_mutated_in_place:
        raise UnreconstructableWarrantError(
            f"Peer policy version {peer_policy_version} mutated in place; "
            "prior grants under this version now resolve to a different meaning."
        )
    if not scope_resolvable_offline:
        raise UnreconstructableWarrantError(
            "Scope term in warrant cannot be resolved from the joined logs "
            "alone; cross-org replay would fail."
        )
    # Invariant satisfied: warrant is join-reconstructable across both trails.
    return None
