# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference)
# Canonical Residual: https://corpusfetch.com/c/in-what-scenarios-must-an-instance-refuse-to-propagate-a-peer-s-trust-assertion-after-a-policy-exchange-renegotiation.md
# Remnant Warrant:    https://corpusfetch.com/c/in-what-scenarios-must-an-instance-refuse-to-propagate-a-peer-s-trust-assertion-after-a-policy-exchange-renegotiation.warrant.json
# Markdown SHA-256:   8d1657a374a5760f808c52303f70b9c96a57186f1ea81a48753b648d83f4d62a
# Code AST SHA-256:   2cce1514b1b78adbbc1b44d97d30c2d5ca7f4e0175e3321910153a633e0e28a2
# Verified Classes:   StaleTrustAssertionError, TrustAssertion
# Defensive Guards:   1 fail-closed invariants (zero external deps)

class StaleTrustAssertionError(RuntimeError):
    """Raised when a transitive trust assertion would cross a policy-epoch
    boundary without re-minting or explicit refusal."""
    pass


class TrustAssertion:
    def __init__(self, peer_fingerprint, scope, minted_at_epoch, signer_org, transitive):
        self.peer_fingerprint = peer_fingerprint
        self.scope = scope
        self.minted_at_epoch = minted_at_epoch
        self.signer_org = signer_org
        self.transitive = transitive


def propagate_assertion(assertion, current_epoch, home_org,
                        epoch_changed_absence_for_scope, can_resign):
    if not assertion.transitive:
        # Self-assertions are re-minted by the authoritative principal, never relayed.
        return "re-mint"

    if assertion.minted_at_epoch == current_epoch:
        return "re-assert"

    if not epoch_changed_absence_for_scope:
        # Epoch bump did not alter interpretation-of-absence for this scope.
        return "re-assert"

    if assertion.signer_org == home_org and can_resign:
        return "re-mint"

    # Transitive third-party claim, epoch changed absence semantics, cannot re-sign.
    # Refusing to propagate is the correct outcome, not a failure.
    raise StaleTrustAssertionError(
        f"refusing to propagate transitive assertion for scope={assertion.scope!r} "
        f"peer={assertion.peer_fingerprint!r}: minted_at_epoch={assertion.minted_at_epoch} "
        f"current_epoch={current_epoch} signer_org={assertion.signer_org!r} "
        f"home_org={home_org!r}"
    )
