Coverage for src/lexigram/admin/rbac/types.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.15.4, created at 2026-08-24 23:18 +0800

1"""Core types for the RBAC system.""" 

2 

3from __future__ import annotations 

4 

5from dataclasses import dataclass 

6from typing import Any, Protocol, runtime_checkable 

7 

8 

9@dataclass(frozen=True) 

10class PolicyContext: 

11 """Context passed to policy evaluators.""" 

12 

13 user: Any 

14 resource_name: str 

15 action: str 

16 record: Any | None = None # For record-level/RLS policies 

17 

18 

19@runtime_checkable 

20class Policy(Protocol): 

21 """Protocol for policy evaluators.""" 

22 

23 def __call__(self, context: PolicyContext) -> bool: ...