Repository navigation
Description
Gap
#2387 added enum edge fields so a relationship can declare a closed value set, and was framed as the schema-side prerequisite for RBAC on collection↔person. It delivers that for schema-declared relationships — but the RBAC edge itself is a built-in relationship, which cannot carry declared edgeFields at all. So the RBAC work is not actually unblocked yet.
Two independent gates reject a builtin as a declaration:
reject_reserved_relationship_names(packages/core/src/schema/mod.rs) refuses any declaration named after a builtinset_schema_relationships(packages/core/src/services/node_service/schema.rs) re-checks the same predicate on the write path
BUILTIN_RELATIONSHIP_NAMES is ["member_of", "has_child", "mentions", "has_role"]. The example JSON in #2387 — {"name": "member_of", "targetType": "collection", "edge_fields": [{"name": "role", "type": "enum", ...}]} — is therefore rejected before it reaches the new validation.
This is not a defect in #2387: with no declaration there is no edge_fields to validate against, so skipping builtins on the write path is correct. The gap is that the motivating use case sits on the one kind of relationship the new machinery cannot describe.
Where roles live today
Roles already ride a builtin edge, unvalidated. Per ADR-037, the seeded owner edge is created as:
create_relationship(&local_person_id, "has_role", &settings_id,
json!({"role": "owner", "status": "active"}))So role on has_role is exactly the free-text access-control field #2387 was written about — "Owner", "owner" and "onwer" are still three distinct roles there, with no picker and no validated default.
Options
-
Model collection RBAC as a new custom relationship (e.g.
has_access, declared onpersontargetingcollection) rather than extendingmember_of. EdgeField cannot declare enum values, so RBAC roles on a relationship would be free text #2387 is then a complete prerequisite and nothing further is needed on the schema side. Cheapest, and keeps membership (member_of, structural/ordered) separate from authorization — arguably the better model regardless. The cost is a second edge alongsidemember_offor the same pair. -
Give builtin relationships a way to declare edge fields. A fixed, code-owned edge-field table keyed by builtin name (not user-declarable, since the names stay reserved), consulted by the same
validate_edge_data_against_fieldson the write path. Covershas_role.roleandhas_role.statustoo, so the existing owner edge gets validated. Larger, and needs a decision on where that table lives and whether the UI reads it through the sameedgeFieldschannel. -
Leave builtin edge data unvalidated and accept free-text roles on
has_role. Cheapest now; keeps the exact hazard EdgeField cannot declare enum values, so RBAC roles on a relationship would be free text #2387 identified, on the one field where a wrong value is security-relevant.
Option 1 looks right if authorization is genuinely separable from membership; option 2 is the better answer if roles must stay on has_role, and has the side benefit of validating the edge that already exists. Worth deciding on that basis before the collection RBAC UI is built, since the choice determines whether the role picker has a schema to read from.
Acceptance criteria
- Decide between the options above and record why
- A collection↔person access level is expressible with a declared, validated value set
- The existing
has_roleowner edge'srole/statusare either validated or explicitly documented as unvalidated, with the reason - The relationships UI can render a picker for the chosen shape
- Schema-authoring guidance reflects whichever shape is chosen (the
ENUM_EDGE_FIELDSrule currently tells agents that builtins cannot carry edge fields — that stays accurate under option 1, and needs updating under option 2)
Context
Found during code review of #2427 (the #2387 implementation), which flagged that the PR's stated motivation was not delivered by the change. The ENUM_EDGE_FIELDS agent guidance in that PR was reworded to state the builtin limit explicitly, and schema_declaring_an_edge_field_on_a_builtin_relationship_is_rejected asserts it, so the current behavior is documented and pinned rather than silently surprising — but the design question remains open.
Activity
malibio commentedon Sep 8, 2026
Frontend baseline: 233 test files passed (4900 tests), 89.24s. No pre-existing failures.
malibio commentedon Sep 8, 2026
Decision: option 2 (a code-owned edge-field table for builtin relationships)
The issue's own analysis favours option 1 (a new
has_accessrelationship onpersontargetingcollection). Reading the code and ADR-037, option 1 is not available: it would contradict an accepted architecture decision and require rewriting the Pro RLS predicate. Recording the evidence, since option 2 is the larger change.Why option 1 is not open
ADR-037 (
../nodespace-docs/decisions/037-collection-access-model.md) is accepted and already implemented on the local side. It does not merely happen to put collection permission onmember_of— it decides that, and it explicitly rejects moving it elsewhere:Three concrete dependencies follow from that, all present in the code today:
The core
collectionschema already documents the field as living there.packages/core/src/models/core_schemas.rs(restrictedToMembers): "member_of edgepermission(admin/modify/readOnly) is a free-form edge property the RLS reads directly — no schema field needed." That comment is the gap this issue describes, verbatim, at the site where it bites.The RLS predicate walks
member_of, not a second edge. ADR-037's access evaluation section: the upward walk unionsmember_ofandhas_child, and at arestrictedToMembersboundary requires "a personmember_ofedge to that collection; their level comes from the edge." Introducinghas_accessmeans the recursive predicate must walk a third edge type, and the Last-Admin Invariant trigger (aBEFORE DELETE OR UPDATEonmember_ofrelationship edges) must move to it too. That is a Pro-schema change, not a local-schema change, and this repo cannot make it.member_ofis not declarable, so the "second edge" is not free. ADR-059 records that descendants inherit an ancestor's access but never its membership. Splitting authorization onto a parallel edge means every restricted collection carries two edges per person that must be kept consistent — the membership edge deciding whether the walk finds you, and an access edge deciding your level. ADR-037 chose one edge for exactly this reason.There is a second, independent argument. Option 1 addresses only the collection axis; it leaves
has_roleuntouched. ADR-037 defines two authority axes — collection-edgepermission(admin/modify/readOnly) and tenant role onhas_role(owner/admin/editor/viewer) — and both are free text today. The seeded owner edge inNodeService::seed_database_settings_if_neededwrites{"role": "owner", "status": "active"}with nothing validating either key. Option 1 leaves that untouched; the third acceptance criterion would then have to be discharged as "explicitly documented as unvalidated", on the field where a wrong value is most security-relevant. Option 2 covers both axes with one mechanism.What option 2 costs, and why it is bounded
Less than the issue estimates, because both halves already exist:
validate_edge_data_against_fields(packages/core/src/services/node_service/relationship.rs) is already the single choke point for edge-enum validation on both the create and update paths. It takes&[EdgeField]— it does not care where the fields came from. The builtin branch ofcreate_relationshipsimply never looks any up.edgeFieldsa group carries:edgeInputKindinpackages/desktop-app/src/lib/services/edge-field-input.tsreturnsenumfor a field withcoreValues. The reason no picker appears formember_of/has_roleis thatget_node_relationships(packages/core/src/ops/rel_ops.rs) skips builtins entirely, so no group is emitted.So the change is: a code-owned table keyed by builtin name, consulted by the write path and surfaced through the same
edgeFieldschannel the UI already reads. The names stay reserved — the table is not user-declarable, and both existing rejection gates (reject_reserved_relationship_names,set_schema_relationships) stay exactly as they are. That preserves the invariant those gates protect (declarations and primitives share onerelationship_typecolumn) while removing the reason the gap existed.The
ENUM_EDGE_FIELDSagent guidance is updated accordingly: builtins still cannot be declared, but they now carry a fixed, code-owned set an agent should not try to change.Scope note
This ships the local-side validation and the picker. It does not touch the Pro RLS function or the Last-Admin trigger — those live outside this repo and are unchanged by this work, which is precisely the point: option 2 leaves the storage shape ADR-037 specified exactly where it is.
malibio commentedon Sep 8, 2026
Closing unimplemented: the premise does not hold for this repo
Investigated end to end. The gap this issue describes is real, but it is real in
nodespace-sync, not here. Closing rather than implementing, with the reasoning recorded so nobody re-derives it.Core is single-user and has no permission concept
One user, all nodes accessible. Nothing in core ever reads a permission to decide anything. That is not a missing feature — it is the design.
So a permission on a
member_ofedge is not a data shape core validates; it is a concept core does not have. RBAC representation and enforcement both belong to the Pro daemon and its Postgres RLS policies (user_can_access_node,user_can_write_node,my_collection_ids,create_invite,set_member,remove_member, the last-admin check). The chain #2387 → #2427 → #2429 assumed permissions live in core. They do not.The strongest remaining argument for putting the vocabulary here was typo divergence — that
"Admin"/"admin"/"amdin"would become three permissions in the local store. It does not survive the above: nothing local reads the value, and the component that owns the policy is also the one that writes and reads it.The vocabulary that looks like core's is Pro-gated
packages/desktop-app/src/lib/components/collaboration/collaboration-view.svelte:24declaresconst PERMISSIONS: Permission[] = ['readOnly', 'modify', 'admin'], which reads as core already owning the set. It does not:packages/desktop-app/src/lib/plugins/pro-plugin.tsmountscollaboration-tabonly under thereloginandconnectedvariants — community edition getsteaserand never reaches it. That array is Pro-surface code that happens to live in this repo.Nor is there anywhere to put a Pro-only enum:
packages/core/Cargo.tomldeclares exactly one feature,nlp. A community build would carry the vocabulary unconditionally.No builtin has a core-owned vocabulary
Option 2 (a code-owned edge-field table keyed by builtin name, consulted by the same
validate_edge_data_against_fieldsas declared relationships, surfaced through the sameedgeFieldschannel) was implemented and then discarded. The design is sound; it has no consumer here.With the collection permission excluded as Pro policy, the table ships empty:
has_childandmember_ofboth carry a numericorder— a fractional position computed by the store, not a closed vocabulary. Edge validation is enum-membership-only by deliberate design.mentionscarries nothing.has_rolecarries the tenant axis, whichnodespace-syncdocuments as an explicitly OPEN set (owner/tenant-admin/member) and decodes tolerantly. Closing it in core would make the local store reject a role the authority on roles had issued. It should stay unvalidated — which is the alternative the third acceptance criterion already offers.An empty table means an always-
Nonefunction, two never-matching call sites, arel_opsloop that emits nothing, and an uncallable helper. Tests cannot rescue it either: the table is a compile-timematchon a&str, so exercising it would mean adding a registration seam whose only purpose is to give dead production code a caller. That is a hollow abstraction, and the greenfield rules exist to prevent exactly it.The mechanism should land with its first real consumer, in the repo that owns the policy — not before.
Acceptance criteria, per criterion
has_rolerole/statusvalidated or explicitly documented as unvalidated, with the reason — satisfied by this comment, taking the documented-as-unvalidated branch: the tenant axis is an open set owned by sync.edgeFieldsa group carries (edgeInputKindinpackages/desktop-app/src/lib/services/edge-field-input.tsreturnsenumfor a field withcoreValues). It needs a vocabulary, not new UI.ENUM_EDGE_FIELDSwording ("the built-in structural names are reserved and rejected as declarations, so you cannot attach an edge field to them") stays accurate, because no mechanism is shipping.Open cross-repo question, for whoever picks this up in nodespace-sync
my_collection_ids()reads acollection_membersview keyed onuser_id, while ADR-037 describes the permission as riding themember_ofedge (relationships.properties->>'permission'). Whether those are one datum or two representations that must be kept in step is unresolved, and cannot be settled from this repo. It matters before anyone builds on either.Kept from this investigation
One genuine, unrelated bug surfaced while testing and is filed separately:
SqliteStore::add_to_collectionsilently discards every edge attribute exceptorder. That one is unambiguously core's and is live today.