docs(docs): V1-1 owner decisions N1-N9 and M1 as built
Contract: N4 voiding instead of deletion, N5 date constraints, N6 write budget per workspace under a lock, N7 effective-privilege wording and residual admin paths, N9 audit metadata limited to ids; M1 as-built notes and isolated-stack results (§8.1). SUPABASE.md §3.3 with the owner procedure to apply M1 on DEV without reset; backend architecture, test strategy, plan and CLAUDE.md lines.
This commit is contained in:
1 parent
7bf4fb6079
commit
0f8c9833cc
6 files changed
+237
-59
No files matched your search
@@ -83,12 +83,25 @@ private.has_active_entitlement(uid, capability text)
|
||||
Each helper ships with pgTAP tests in the same migration step: positive case,
|
||||
negative case, expired grant, revoked grant, wrong organization.
|
||||
|
||||
As built from V1-1 (contract `V1-1_OWNERS_ANIMALS.md` §9, BDR-073/074): the
|
||||
perimeter is a workspace, not an organization. `private.caller_workspace_ids()`
|
||||
(member, active profile, confirmed email; no parameter, `auth.uid()` only;
|
||||
EXECUTE for `authenticated`) and `private.writable_workspace_ids()` (the same,
|
||||
restricted to a write role; EXECUTE for nobody, called inside definer RPCs)
|
||||
replace `is_org_*` and `can_view_client/animal` for V1-1 records. They avoid
|
||||
RLS recursion by running as the table owner (`security definer`, owner
|
||||
`postgres`, `search_path = ''`) rather than with `row_security = off`. No
|
||||
helper or policy has a platform-role branch (D16). Every V1-1 table revokes
|
||||
all privileges from `anon` and `service_role` (N7); `postgres` keeps
|
||||
`BYPASSRLS` on the Supabase image and the service key stays a GoTrue admin
|
||||
credential, residual paths named in the contract §6.3.
|
||||
|
||||
### 4.2 Policy rules per domain (summary of §17.3)
|
||||
|
||||
| Table family | SELECT | INSERT/UPDATE/DELETE |
|
||||
|---|---|---|
|
||||
| `profiles` | own row; admins via view | own row; roles only through RPC |
|
||||
| `organizations`, `organization_members` | members | managers/owners through RPC (`add_member`, `remove_member`, `set_role`) so that "secretary cannot self-grant practitioner" is one place |
|
||||
| `workspaces`, `workspace_members` (V1-1; cabinets extend them instead of `organizations`) | members, through `caller_workspace_ids()` | none through the API: personal workspace created by trigger; cabinet membership RPCs come with Step 10 |
|
||||
| `clients`, `client_contacts`, `client_consents` | `can_view_client` | create by the practitioner who starts the relationship; core identity edits restricted (open question Q6) |
|
||||
| `animals` | `can_view_animal` | practitioner with an active relationship or grant |
|
||||
| `reports` | `can_view_report` | `can_edit_report` for drafts; completion and numbering only via RPC |
|
||||
|
||||
Reference in new issue
Block a user