# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference) # Canonical Residual: https://corpusfetch.com/c/what-happens-when-an-instance-attenuates-a-delegated-warrant-below-the-verifier-s-capability-floor.md # Remnant Warrant: https://corpusfetch.com/c/what-happens-when-an-instance-attenuates-a-delegated-warrant-below-the-verifier-s-capability-floor.warrant.json # Markdown SHA-256: 44d8a074acbc303490cd3c559024dbde2d09157fd2893af42da0994c6f218308 # Code AST SHA-256: 134c05e379cb14803a98f2cef0eaf8e38c0b7406da0aa77fcf6fc2c779abaf34 # Verified Classes: CapabilityFloorViolation # Defensive Guards: 4 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) class CapabilityFloorViolation(RuntimeError): """Raised when a hop attenuates a warrant dimension below the verifier's propagated floor, or when the conjunctive floor is unsatisfiable.""" pass def attenuate(parent_warrant: dict, narrowing: dict) -> dict: """Apply least-privilege narrowing to a delegated warrant. parent_warrant carries an immutable 'floor' set propagated from the root issuer. narrowing may only reduce ceiling dimensions; it may never reduce a dimension below floor[d], and it may never drop a dimension that the floor requires to be present. """ floor = parent_warrant["floor"] # immutable, non-attenuatable child = {k: v for k, v in parent_warrant.items() if k != "floor"} for dim, new_val in narrowing.items(): if dim not in child: raise CapabilityFloorViolation( f"cannot attenuate unknown dimension {dim!r}" ) # Ceiling check: narrowing must be a strict subset (monotone decrease). if not _is_subset(new_val, child[dim]): raise CapabilityFloorViolation( f"attenuation of {dim!r} broadens scope: " f"{new_val!r} not within {child[dim]!r}" ) child[dim] = new_val # Floor check: every required dimension must survive and satisfy its bound. for dim, bound in floor.items(): if dim not in child: raise CapabilityFloorViolation( f"attenuation dropped required dimension {dim!r}; " f"verifier floor requires it to be present and satisfy {bound!r}" ) if not _satisfies_floor(child[dim], bound): raise CapabilityFloorViolation( f"dimension {dim!r}={child[dim]!r} falls below verifier floor " f"{bound!r}; chain would be valid but rejected at the leaf" ) child["floor"] = floor return child def _is_subset(new_val, old_val) -> bool: if isinstance(old_val, (int, float)) and isinstance(new_val, (int, float)): return new_val <= old_val if isinstance(old_val, set) and isinstance(new_val, set): return new_val.issubset(old_val) return new_val == old_val def _satisfies_floor(value, bound) -> bool: if isinstance(bound, dict): # conjunctive floor, e.g. {"min_amount": 10, "idempotency": True} if "min_amount" in bound and value < bound["min_amount"]: return False if "idempotency" in bound and value != bound["idempotency"]: return False return True return value == bound # Trace of the observed failure, now caught at the narrowing hop: root = { "action": "refund", "amount_max": 500, "currency": "USD", "merchant": "acme", "idempotency": True, "floor": {"amount_max": {"min_amount": 10}, "idempotency": True}, } # P tries to narrow amount to 50 and drop idempotency (the observed bug): try: attenuate(root, {"amount_max": 50, "idempotency": None}) except CapabilityFloorViolation as e: # Caught here, not as a 403 at the payment service. print(f"blocked at planner hop: {e}")