Permissions¶
techrevati.runtime.permissions ¶
Permissions — Role-based tool access gating.
Deny-first authorization: denied_tools is checked first, then mode comparison, then the allowed_tools whitelist. Each role has a PermissionMode that determines which tools it can use.
This module is configuration-free by design; callers supply their own RolePermissionConfig and tool_requirements.
PermissionMode ¶
Bases: IntEnum
Ordered permission levels. Higher grants more access.
PermissionOutcome
dataclass
¶
PermissionOutcome(
allowed, reason=None, active_mode="", required_mode=""
)
Result of a permission check.
RolePermissionConfig
dataclass
¶
RolePermissionConfig(
role, mode, allowed_tools=None, denied_tools=list()
)
Permission configuration for a single role.
PermissionPolicy ¶
PermissionPolicy(
role_configs=None,
tool_requirements=None,
*,
default_allow_unknown_roles=False,
)
Evaluates tool access based on role configs and tool requirements.
A role is identified by its exact name. A name that only matches a
configured role after folding case, Unicode form, or invisible characters is
denied, whatever default_allow_unknown_roles says: treating it as that role
could grant access its caller was not given, and treating it as unknown could
escape that role's deny list.
A role with no config at all is denied unless default_allow_unknown_roles is
set, so a typo in a role name cannot silently grant every tool.
Tool names match regardless of those spellings, so a deny list cannot be escaped by respelling. Keys that collide after folding are rejected at construction.