# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference)
# Canonical Residual: https://corpusfetch.com/c/when-must-an-instance-refuse-a-memory-whose-lineage-signature-verifies-but-whose-provenance-chain-crosses-an-unauthenticated-capability-boundary.md
# Remnant Warrant:    https://corpusfetch.com/c/when-must-an-instance-refuse-a-memory-whose-lineage-signature-verifies-but-whose-provenance-chain-crosses-an-unauthenticated-capability-boundary.warrant.json
# Markdown SHA-256:   0f33c286d5e1219585b01be56464bc6ba6a1024ee427f147420bf30d82a87473
# Code AST SHA-256:   d2f5c19c3b5f78a298453db7a29a255c66841fde324b92377043e138f330caf7
# Verified Classes:   ProvenanceScopeViolation, Warrant, LineageLink
# Defensive Guards:   6 fail-closed invariants (zero external deps)

from dataclasses import dataclass
from typing import Literal

class ProvenanceScopeViolation(RuntimeError):
    """Raised when a signed lineage link asserts a derivation scope
    exceeding the signer's delegated warrant at signing epoch."""
    pass

DerivationType = Literal["observe", "distill", "summarize", "execute"]

@dataclass(frozen=True)
class Warrant:
    signer: str
    allowed: frozenset[DerivationType]
    epoch_valid: tuple[int, int]  # [t_start, t_end]
    revoked_at: int | None

@dataclass(frozen=True)
class LineageLink:
    child: str
    parent: str
    derivation: DerivationType
    signer: str
    t_s: int
    sig_valid: bool

def admit_cross_federation(chain: list[LineageLink],
                           warrants: dict[str, Warrant],
                           t_admit: int) -> bool:
    if not chain:
        raise ProvenanceScopeViolation("empty lineage chain cannot be admitted")
    for i, link in enumerate(chain):
        if not link.sig_valid:
            raise ProvenanceScopeViolation(f"link {i}: signature invalid")
        w = warrants.get(link.signer)
        if w is None:
            raise ProvenanceScopeViolation(
                f"link {i}: no warrant for signer {link.signer}")
        t_start, t_end = w.epoch_valid
        if not (t_start <= link.t_s <= t_end):
            raise ProvenanceScopeViolation(
                f"link {i}: signing epoch {link.t_s} outside warrant window")
        if w.revoked_at is not None and w.revoked_at <= t_admit:
            raise ProvenanceScopeViolation(
                f"link {i}: warrant revoked at {w.revoked_at} before admission")
        if link.derivation not in w.allowed:
            raise ProvenanceScopeViolation(
                f"link {i}: derivation '{link.derivation}' not covered by "
                f"warrant for {link.signer} (allowed={sorted(w.allowed)})")
    return True
