# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference)
# Canonical Residual: https://corpusfetch.com/c/where-must-an-instance-reject-a-brokered-warrant-when-policy-translation-degrades-a-deny-into-a-permit.md
# Remnant Warrant:    https://corpusfetch.com/c/where-must-an-instance-reject-a-brokered-warrant-when-policy-translation-degrades-a-deny-into-a-permit.warrant.json
# Markdown SHA-256:   93d0df69571703fcc1c838d957ce9d71a01b349f720aa45851239824f6f43439
# Code AST SHA-256:   890762c9a98a0a4f84726ceb36ea1a24bd19a9cf4dd0397905060dd3a05ea0cd
# Verified Classes:   NonConservativeWarrantError
# Defensive Guards:   3 fail-closed invariants (zero external deps)

class NonConservativeWarrantError(RuntimeError):
    """Raised when a brokered warrant's translation cannot be shown conservative."""
    pass


def admit_brokered_warrant(warrant: dict, trusted_attestors: set[str]) -> dict:
    """
    Intake gate for a translated A2A warrant. Returns the warrant only if its
    translation is attested total-and-conservative, or if the origin warrant
    travels and is independently re-evaluable. Fails closed otherwise.
    """
    manifest = warrant.get("translation_manifest")

    if manifest is None:
        raise NonConservativeWarrantError(
            "no translation manifest: translator drop-set unknown; "
            "cannot prove permit_translated <= permit_original"
        )

    dropped = manifest.get("dropped", [])
    approximated = manifest.get("approximated", [])
    if dropped or approximated:
        raise NonConservativeWarrantError(
            f"non-conservative translation: dropped={dropped} "
            f"approximated={approximated}; deny set may have been widened"
        )

    attestor = manifest.get("attested_by")
    if attestor not in trusted_attestors:
        # Attestation exists but is not from a party trusted for this claim.
        origin = warrant.get("origin_warrant")
        if origin is None or not origin.get("independently_revaluable", False):
            raise NonConservativeWarrantError(
                f"attestor {attestor!r} untrusted and origin warrant "
                "not re-evaluable; refusing warrant of unknown strength"
            )

    return warrant
