concept

Architecture decisions and governance

Fixed-window integer failure allowance and remaining count for a basis-point SLO; zero observations are no data.

Formal Syntax & Structure

artificial-intelligence syntaxartificial-intelligence
failure_budget(total, failed, target_bp)

Working Example

Example Snippetartificial-intelligence
def failure_budget(total, failed, target_bp):    # Target is good requests in basis points (10000 = 100 percent).    if any(type(v) is not int for v in (total, failed, target_bp)):        raise ValueError("integer counts required")    if total < 0 or not 0 <= failed <= total or not 0 <= target_bp <= 10000:        raise ValueError("invalid counts or target")    allowed = total * (10000 - target_bp) // 10000    return dict(allowed=allowed, remaining=allowed-failed,                status="no_data" if total == 0 else                "breached" if failed > allowed else                "exhausted" if failed == allowed else "available")
print(failure_budget(1000, 7, 9900))print(failure_budget(1000, 10, 9900))print(failure_budget(1000, 11, 9900))print(failure_budget(0, 0, 9900))