You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: align grantActionSchema with DB constraint and RLS policies
The Zod grant action enum ("read", "write", "delete", "admin") did not
match the DB valid_actions check constraint ("read", "create", "update",
"delete") or the RLS policy lookups. As a result, "me grant create <user>
<path> create" (the action the policies actually check on insert) was
rejected by Zod, while "write" and "admin" passed Zod but would be
rejected at the DB layer. Scoped grants for creating or updating memories
were effectively impossible through the public API.
Align the Zod enum, CLI help text, type casts, test fixtures, and docs to
the canonical RLS/DB set: read, create, update, delete. Superuser access
stays on the user.superuser column; re-granting stays on
--with-grant-option. No DB migration needed — the constraint was already
correct.
Fixes TNT-62.
Copy file name to clipboardExpand all lines: docs/access-control.md
+13-12Lines changed: 13 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,7 @@ me role add-member engineering alice
34
34
me role add-member engineering bob
35
35
36
36
# Grant access to the role (all members inherit it)
37
-
me grant create engineering work.projects readwrite create
37
+
me grant create engineering work.projects read create update
38
38
```
39
39
40
40
Roles are implemented as users with `canLogin: false`. This means grants work the same way for users and roles.
@@ -45,14 +45,14 @@ Grants control what actions a user (or role) can perform on a tree path. A grant
45
45
46
46
-**user** -- who receives the access
47
47
-**path** -- which tree path (and all descendants)
48
-
-**actions** -- what they can do: `read`, `write`, `create`, `delete`, `admin`
48
+
-**actions** -- what they can do: `read`, `create`, `update`, `delete`
49
49
50
50
```bash
51
-
# Grant read/write access to a tree branch
52
-
me grant create alice work.projects readwrite
51
+
# Grant read and create access to a tree branch
52
+
me grant create alice work.projects readcreate
53
53
54
54
# Grant full access
55
-
me grant create bob work readwrite create delete admin
55
+
me grant create bob work read create update delete
56
56
57
57
# Check access
58
58
me grant check alice work.projects.api read
@@ -65,20 +65,21 @@ Grants are hierarchical -- a grant on `work` covers `work.projects`, `work.proje
65
65
| Action | Description |
66
66
|--------|-------------|
67
67
|`read`| Search and retrieve memories |
68
-
|`write`| Update existing memories |
69
68
|`create`| Create new memories |
69
+
|`update`| Update existing memories |
70
70
|`delete`| Delete memories |
71
-
|`admin`| Manage grants and ownership |
71
+
72
+
Grant management and ownership are controlled separately: grants with `--with-grant-option` let a grantee re-grant their access, and ownership (`me owner set`) gives a user full admin access to a tree path. Superuser bootstrap is handled via the `superuser` flag on the user row, not via a grant action.
72
73
73
74
### Grant option
74
75
75
76
When creating a grant with `--with-grant-option`, the grantee can re-grant that same access to others:
76
77
77
78
```bash
78
-
me grant create alice work.projects readwrite --with-grant-option
79
+
me grant create alice work.projects readcreate --with-grant-option
79
80
```
80
81
81
-
Alice can now grant `read` and `write` on `work.projects` to other users.
82
+
Alice can now grant `read` and `create` on `work.projects` to other users.
82
83
83
84
## Ownership
84
85
@@ -134,7 +135,7 @@ me role add-member team carol
134
135
me grant create team ""read
135
136
136
137
# Grant write access to specific branches
137
-
me grant create alice work.frontend readwrite create
138
-
me grant create bob work.backend readwrite create
139
-
me grant create carol work.infra readwrite create delete admin
138
+
me grant create alice work.frontend read create update
139
+
me grant create bob work.backend read create update
140
+
me grant create carol work.infra read create update delete
Copy file name to clipboardExpand all lines: docs/cli/me-grant.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
Manage tree grants.
4
4
5
-
Grants control access to memories by tree path. A grant gives a user specific actions (read, write, create, delete, admin) on a tree path and all its descendants.
5
+
Grants control access to memories by tree path. A grant gives a user specific actions (read, create, update, delete) on a tree path and all its descendants.
6
6
7
7
## Commands
8
8
@@ -25,7 +25,7 @@ me grant create <user> <path> <actions...> [options]
25
25
|----------|----------|-------------|
26
26
|`user`| yes | User name or ID. |
27
27
|`path`| yes | Tree path to grant access to. |
28
-
|`actions...`| yes | One or more actions: `read`, `write`, `create`, `delete`, `admin`. |
28
+
|`actions...`| yes | One or more actions: `read`, `create`, `update`, `delete`. |
29
29
30
30
| Option | Description |
31
31
|--------|-------------|
@@ -34,7 +34,7 @@ me grant create <user> <path> <actions...> [options]
34
34
### Example
35
35
36
36
```bash
37
-
me grant create alice work.projects readwrite create
37
+
me grant create alice work.projects read create update
38
38
```
39
39
40
40
---
@@ -82,6 +82,6 @@ me grant check <user> <path> <action>
0 commit comments