keelgate.capabilities¶
Stability of each symbol (stable or provisional) is listed in the API contract. Narrative and semantics are in the integration contract.
Capability definitions and scoped, explicitly issued grants. Deny by default.
Budget
¶
Bases: BaseModel
A spending ceiling, in whatever cost units the tools declare.
BudgetLedger
¶
Bases: Protocol
Where a grant's remaining budget is tracked.
Implement this to share budgets across processes. Reservations must be atomic so spend can never exceed the grant.
Capability
¶
Bases: str
A validated capability string. Immutable, hashable, and still a str.
CapabilityGrant
¶
Bases: BaseModel
The verified claims of a grant. Only ever built by :class:GrantVerifier.
GrantError
¶
Bases: Exception
Base class: the presented grant cannot be used.
GrantExpiredError
¶
GrantInvalidError
¶
GrantNotYetValidError
¶
GrantRevokedError
¶
GrantSigner
¶
Holds the Ed25519 private key and signs grants. Guard it like a root key.
GrantVerifier
¶
Verifies grant tokens against a set of trusted public keys.
Holds only public keys: it can accept grants but never mint one.
verify
¶
Return the grant claims, or raise a :class:GrantError.
InMemoryBudgetLedger
¶
Atomic per-grant spend tracking.
Process-local; a shared store is needed wherever several processes honour the same grant.
InMemoryRevocationList
¶
Process-local revocations. A shared store is needed for multi-process use.
InvalidCapabilityError
¶
Bases: ValueError
Raised for a malformed capability string, including any wildcard.
RevocationList
¶
Bases: Protocol
Where revoked grant ids are recorded.
Implement this to share revocations across processes.
SignedGrant
dataclass
¶
A freshly issued grant: the bearer token and its parsed grant.
SqliteBudgetLedger
¶
Atomic per-grant spend, persisted. Implements :class:BudgetLedger.
SqliteRevocationList
¶
Persisted revocations. Implements :class:RevocationList.
UnknownKeyError
¶
issue_grant
¶
issue_grant(
signer: GrantSigner,
*,
agent_id: str,
tenant_id: str,
capabilities: Iterable[str],
max_cost: float,
ttl: timedelta,
clock: Clock = utc_now,
not_before: datetime | None = None,
max_ttl: timedelta = DEFAULT_MAX_TTL,
) -> SignedGrant
Mint a grant. Raises ValueError rather than issuing anything unsafe.
capabilities must be non-empty and wildcard-free. ttl must be
positive and no longer than max_ttl.