Governance
RBAC & multi-tenancy
Scope which tools an agent may use by role and tenant. Authorization is enforced at the gateway — the chokepoint where actions actually execute.
Roles & principals
rbac.py
from antraft.access import AccessControl, Principal, Role access = AccessControl([ Role("viewer", tools={"read_db", "search_web"}, tenant="acme"), Role("admin", tools={"*"}), # "*" grants all tools]) analyst = Principal(id="u_123", roles=["viewer"], tenant="acme")Run as a principal
rbac.py
runtime = ( Antraft.agent(model, tools, task="...") .allow(["read_db", "delete_db"]) # policy may allow a tool ... .as_principal(analyst, access) # ... but RBAC still rejects it .build())Note
A tool the principal's roles don't grant is rejected at the gateway. The rejection is reported back to the agent (not fatal), so the model can adapt and the run continues.
Tenant isolation
A tenant-scoped role only applies when the principal's tenant matches. A viewer in tenant acme cannot use tools through that role from any other tenant.
rbac.py
access.can_use_tool(analyst, "read_db") # True (acme viewer)access.can_use_tool(analyst, "delete_db") # False (not granted) other = Principal(id="u_999", roles=["viewer"], tenant="other")access.can_use_tool(other, "read_db") # False (wrong tenant)Direct checks
rbac.py
from antraft.access import AccessDenied access.authorize(analyst, "delete_db") # raises AccessDenied