# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference) # Canonical Residual: https://corpusfetch.com/c/what-structural-signals-indicate-warrant-chain-attenuation-loss-in-a2a-v1-0-nested-delegation.md # Remnant Warrant: https://corpusfetch.com/c/what-structural-signals-indicate-warrant-chain-attenuation-loss-in-a2a-v1-0-nested-delegation.warrant.json # Markdown SHA-256: 7df917fd51dd16a217d3e09e0c55b1ad3bd6fa27e477d482951ca7f73143cc2c # Code AST SHA-256: a45c3ddaed28dbda388c3d60b86ee6c29a8b9409e3e729e4ccce1568fcaee35b # Verified Classes: WarrantAttenuationError, Scope, Warrant # Defensive Guards: 6 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 WarrantAttenuationError(RuntimeError): """Raised when a delegated warrant does not provably attenuate its parent.""" @dataclass(frozen=True) class Scope: # Glob-style capability scopes; containment is prefix-segment based, not string based. patterns: tuple[str, ...] def contains(self, other: "Scope") -> bool: for pat in other.patterns: if not any(_glob_subsumes(parent, pat) for parent in self.patterns): return False return True def _glob_subsumes(parent: str, child: str) -> bool: # /proj/** subsumes /proj/x/** ; /proj/x/** does NOT subsume /proj/** p_segs, c_segs = parent.split("/"), child.split("/") i = 0 while i < len(p_segs): if i >= len(c_segs): return False if p_segs[i] == "**": return True if p_segs[i] != c_segs[i]: return False i += 1 return i == len(c_segs) @dataclass(frozen=True) class Warrant: id: str parent_warrant_id: Optional[str] task_id: str scope: Scope identity: str trace_parent: Optional[str] def verify_attenuation( child: Warrant, parent: Optional[Warrant], sibling_task_ids: set[str], ) -> None: if child.parent_warrant_id is None: return # root warrant; trust anchored elsewhere if parent is None: raise WarrantAttenuationError( f"warrant {child.id}: parent {child.parent_warrant_id} unresolvable; " "cannot prove attenuation, denying by default" ) if parent.id != child.parent_warrant_id: raise WarrantAttenuationError( f"warrant {child.id}: dereferenced parent id {parent.id} != declared " f"parent {child.parent_warrant_id}" ) if not parent.scope.contains(child.scope): raise WarrantAttenuationError( f"warrant {child.id}: scope {child.scope.patterns} not subset of " f"parent {parent.scope.patterns}" ) if child.identity != parent.identity: raise WarrantAttenuationError( f"warrant {child.id}: identity {child.identity} != parent {parent.identity}" ) if child.trace_parent != parent.trace_parent and parent.trace_parent is not None: raise WarrantAttenuationError( f"warrant {child.id}: trace_parent {child.trace_parent} does not chain " f"to parent trace {parent.trace_parent}" ) if child.task_id in sibling_task_ids: raise WarrantAttenuationError( f"warrant {child.id}: task_id {child.task_id} collides with sibling under " f"parent {parent.id}; audit DAG would alias distinct tasks" )