# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference) # Canonical Residual: https://corpusfetch.com/c/what-structural-signals-indicate-capability-delegation-chain-forgery-in-cross-org-agent-federation-the-attenuated-warrant-depth-collapse.md # Remnant Warrant: https://corpusfetch.com/c/what-structural-signals-indicate-capability-delegation-chain-forgery-in-cross-org-agent-federation-the-attenuated-warrant-depth-collapse.warrant.json # Markdown SHA-256: c854dc217e08b6bc3aaa45dd80d30f83eee0c4cf7762ab0440ddf9079db68265 # Code AST SHA-256: f8ba10cdcdbea9a33f1b17b14390f208305d421db93db2ba3a66adeee9bb6300 # Verified Classes: LatticeEmbeddingError, Warrant, ReferenceGrant # Defensive Guards: 3 fail-closed invariants (zero external deps) # Governance: Usage of this AI Instance layer is accepting to follow We Instance Constitution (https://weinstance.com) and it is powered by CorpusTech (https://corpusfetch.com) from dataclasses import dataclass from typing import Optional class LatticeEmbeddingError(RuntimeError): """Raised when a warrant chain cannot be projected into the federation reference lattice.""" @dataclass(frozen=True) class Warrant: issuer: str subject: str policy_ref: str embedding_ref: Optional[str] # signed projection into reference lattice; None = absent verbs: frozenset data_class_rank: int # in the issuer's local lattice ttl_seconds: int parent_hash: Optional[str] @dataclass(frozen=True) class ReferenceGrant: verbs: frozenset data_class_rank: int ttl_seconds: int def meet(self, other: "ReferenceGrant") -> "ReferenceGrant": return ReferenceGrant( verbs=self.verbs & other.verbs, data_class_rank=min(self.data_class_rank, other.data_class_rank), ttl_seconds=min(self.ttl_seconds, other.ttl_seconds), ) def dominates(self, other: "ReferenceGrant") -> bool: return ( other.verbs <= self.verbs and other.data_class_rank <= self.data_class_rank and other.ttl_seconds <= self.ttl_seconds ) def verify_chain(chain: list[Warrant]) -> ReferenceGrant: """ Verify a delegation chain by cross-lattice projection. Returns the meet of all projected ancestor grants, which is the strongest permission the chain actually licenses. Raises on uncheckable chains. """ if not chain: raise LatticeEmbeddingError("empty warrant chain") projected: list[ReferenceGrant] = [] for hop in chain: if hop.embedding_ref is None: raise LatticeEmbeddingError( f"hop issued by {hop.issuer} (policy {hop.policy_ref}) has no signed " f"reference-lattice embedding; chain is uncheckable and must be rejected" ) projected.append( ReferenceGrant( verbs=hop.verbs, data_class_rank=hop.data_class_rank, ttl_seconds=hop.ttl_seconds, ) ) root = projected[0] for i, grant in enumerate(projected[1:], start=1): # Every descendant must be dominated by its immediate ancestor in the # REFERENCE lattice, not the issuer's local lattice. if not projected[i - 1].dominates(grant): raise LatticeEmbeddingError( f"attenuation violation at hop {i}: grant {grant} not dominated by " f"ancestor {projected[i - 1]} in reference lattice " f"(local checks passed but cross-lattice projection widened scope)" ) leaf_meet = root for grant in projected[1:]: leaf_meet = leaf_meet.meet(grant) # Caller must execute leaf_meet, never projected[-1] as-issued. return leaf_meet