Skip to content

#1372: restrictedToMembers Core field on collection schema (ADR-037) - #1400

Merged
mstomar125 merged 1 commit into
NodeSpaceAI:mainfrom
mstomar125:issue-1372-collection-restriction
Jun 9, 2026
Merged

mstomar125 merged 1 commit into
NodeSpaceAI:mainfrom
mstomar125:issue-1372-collection-restriction

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Open-core data plane for ADR-037's opt-in restriction. Closes #1372.

Stacked on #1399 (PersonNode #133). This branch is cut from issue-133, so the PersonNode commit rides along here until #1399 merges — review only the top commit ("restrictedToMembers Core field"). The diff narrows to just this change once #1399 lands.

Per ADR-028, this covers only inert, local-first data:

  • restrictedToMembers — a Core-protected boolean on the collection schema (default false = open/organizational). The Pro RLS layer (nodespace-sync#124 / cloud#23) reads properties->>'restrictedToMembers' to gate access; core just declares the protected property.
  • member_of permission (admin/modify/readOnly, default modify) is a free-form property on the native member_of edge — the RLS reads it directly, so no schema change is needed.
  • Ops: toggle restriction = a normal node property update; add a person member with a permission = a normal member_of relationship create. No new core API needed for the data plane; the enforcement flows (auto-admin, Last-Admin trigger, onboarding) are nodespace-sync#125/Add Slash Command Entries for Code/Quote Blocks #126.

Tests: restrictedToMembers field shape; schema-count + no-fields asserts updated. cargo test green, clippy clean.

@mstomar125

Copy link
Copy Markdown
Contributor Author

REQUEST CHANGES ⏳

Initial review, top commit ceee30d9 only (the baf653c0 PersonNode commit is #1399 riding along — reviewed there). no checks reported on the branch.

Small and correct: restrictedToMembers as a Core-protected boolean on the collection schema, default false / required false, a clear description, and a focused test asserting type + protection + default. The field name matches exactly what cloud#23's RLS reads (properties->>'restrictedToMembers'), camelCase is consistent with core's other schema fields (dueDate, assignee), and scoping to inert local data per ADR-028 (no enforcement here) is the right boundary. Two minor things:

🟢 Cross-repo contract — confirm "absent" reads as open. cloud#23 gates on (properties->>'restrictedToMembers')::boolean IS TRUE, i.e. a NULL/absent property → open. So the open default only holds if an untouched collection leaves the property absent (or writes literal false) in the synced properties JSON — please confirm a default-false Core field doesn't materialize as some other shape (e.g. a stringified or nested value) that wouldn't satisfy that read. Relatedly: this being a Core-protected boolean is exactly what de-risks the ::boolean cast I flagged on cloud#23 — but keep cloud#23's predicate defensive anyway, since the cloud can't assume every writer honored the core constraint (defense in depth, not a change to this PR).

🟢 Test coupling to #1399. The "collection" → "person" swap in the no-fields list hard-depends on #1399's person schema existing, so this commit won't stand on main alone (expected, given the stack). Just flag that if #1399's person type is renamed/reworked — which my #1399 review raised re: the existing user-entity "person" collision — this test moves with it.

Otherwise good to go once the cross-repo contract above is confirmed.

Land the open-core data plane for ADR-037's opt-in restriction: a
Core-protected boolean `restrictedToMembers` on the `collection` schema
(default false = open/organizational). The Pro RLS layer reads
`properties->>'restrictedToMembers'` to gate access (nodespace-sync#124);
core only declares the inert, protected property.

The member_of edge `permission` (admin/modify/readOnly, default modify) is
a free-form property on the native member_of edge — the RLS reads it
directly, so no schema change is needed. Toggling restriction is a normal
node property update and adding a person member with a permission is a
normal member_of relationship create; the Pro-side enforcement flows
(auto-admin, last-admin, onboarding) are nodespace-sync#125/#126.

Depends on #133 (PersonNode, the person-only membership check). Tests +
schema-count asserts updated.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@mstomar125

Copy link
Copy Markdown
Contributor Author

Addressed.

Rebased onto merged main (commit f5256f3): dropped the obsolete baf653c0 person commit (issue #133 consolidated onto #1401, now merged — that PR's name+email PersonNode is canonical), so this PR is now only the restrictedToMembers field. Reconciled test_simple_schemas_have_no_fields: removed person from the no-fields list (#1401's person carries name/email fields), collection already drops out (it now has restrictedToMembers). All 11 core_schemas tests pass.

🟢 "Absent reads as open" — confirmed. create_node applies schema defaults only for task (crud.rs); every other type, including collection, is normalized without default materialization. So an untouched collection leaves restrictedToMembers absent in synced properties → cloud#23's (properties->>'restrictedToMembers')::boolean IS TRUE → NULL → false → open. When explicitly restricted it's a literal boolean true. No stringified/nested shape. The open-by-default contract holds, and cloud#23's predicate stays defensive regardless (defense in depth).

🟢 Test coupling to the person schema: now that #1401 is in main, this test stands on main as-is.

@mstomar125
mstomar125 merged commit 0f5ce70 into NodeSpaceAI:main Jun 9, 2026
malibio pushed a commit that referenced this pull request Jun 22, 2026
…37) (#1400)

Land the open-core data plane for ADR-037's opt-in restriction: a
Core-protected boolean `restrictedToMembers` on the `collection` schema
(default false = open/organizational). The Pro RLS layer reads
`properties->>'restrictedToMembers'` to gate access (nodespace-sync#124);
core only declares the inert, protected property.

The member_of edge `permission` (admin/modify/readOnly, default modify) is
a free-form property on the native member_of edge — the RLS reads it
directly, so no schema change is needed. Toggling restriction is a normal
node property update and adding a person member with a permission is a
normal member_of relationship create; the Pro-side enforcement flows
(auto-admin, last-admin, onboarding) are nodespace-sync#125/#126.

Depends on #133 (PersonNode, the person-only membership check). Tests +
schema-count asserts updated.

Co-authored-by: Mayank  Tomar <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ADR-037: Collection access model — core data plane (restrictedToMembers, member_of permission, PersonNode seeding)

1 participant