PR #267 · pramaan-io/pramaan-functions · merged 2026-06-08
One firm, two hundred matters, twenty lawyers — and a junior who sees them all.
Firm membership was never enough. Here's what was leaking.
Query succeeds. Data is wrong. Silence.
The fix — Assign once, show the card, enter only yours.
sequenceDiagram autonumber participant app as App session participant rls as RLS predicate participant asgn as matter_assignments participant row as Matter row app->>rls: set current_firm_role rls->>asgn: can_read_matter() asgn->>rls: assignment row? rls-->>row: allow or deny
| Method | in → out | what it does |
|---|---|---|
MatterAssignment | (class) | the SQLModel table binding a user to a matter as the predicate's source of truth |
_create_assignment_table | () → None | creates the matter_assignments table inside the migration |
_create_helpers | () → None | defines shared can_read_matter and can_read_client predicates reused by every policy |
_create_current_firm_role_helper | () → None | registers the session variable that distinguishes firm admin from member |
Alembic migration that creates the matter_assignments table, defines shared can_read_matter and can_read_client predicates, registers the current_firm_role session variable, and replaces firm-only policies on matter and client rows with shared predicate calls.
| new method | signature |
|---|---|
_replace_policy | (policy, table, command, using, check) → None |
_create_helpers | () → None |
_drop_helpers | () → None |
_create_current_firm_role_helper | () → None |
_create_assignment_table | () → None |
_seed_opened_by_assignments | () → None |
_drop_assignment_table | () → None |
_upgrade_policies | () → None |
_downgrade_policies | () → None |
upgrade | () → None |
downgrade | () → None |
revision : strdown_revision : str | Sequence[str] | Nonebranch_labels : str | Sequence[str] | Nonedepends_on : str | Sequence[str] | NoneDefines the MatterAssignment SQLModel entity that records which user is assigned to which matter, serving as the source of truth for the shared RLS predicates.
| new class | signature |
|---|---|
MatterAssignment | (class) |
firm_id : UUIDmatter_id : UUIDuser_id : UUIDassigned_by_user_id : UUID | None