Skip to content

Rewrite the restrictedToMembers and member_of permission comments as storage contracts #3301

Closed

Description

@mstomar125

Summary

Rewrite the comment above the collection schema's fields in get_core_schemas (packages/core/src/models/core_schemas.rs). The new comment states the two storage contracts that ADR-083 §4 (proposed) defines, without naming a consumer:

  • restrictedToMembers;
  • the permission property on member_of edges.

Then lower the Pro-boundary baselines this pays down. The change is comment-only. It is also the first PR to lower a baseline, so it exercises the #3299 workflow end to end.

Context

  • What the comment says today. The // ADR-037: opt-in restriction… block in the collection SchemaNode (5 lines, 525-529 at af8ddb6) says:

    • "the Pro RLS layer reads properties->>'restrictedToMembers' to gate access";
    • permission is "a free-form edge property the RLS reads directly".

    It names a consumer, which ADR-081 rules out for core. It also doesn't tell a core engineer what must not change.

  • What ADR-083 decides. §4 keeps both fields in core, because they have local meaning, and turns their comments into contract statements. §7 step 2 lists this rewrite among the changes that nothing external calls, so it can land at any time.

  • What core does with them locally:

    • NodeService::seed_personal_ai_chat_collection_if_needed (node_service/mod.rs) finds the personal AI-chat collection. It looks for a collection whose properties.collection.restrictedToMembers is boolean true and that has the local person's member_of edge with permission "admin". It writes {"permission": "admin"} when it seeds that edge.
    • restricted_collection_sql (db/sqlite_store/embedding_roots.rs) treats a restricted collection as an embedding-root boundary. It accepts both JSON true and the string "true".
    • Core never validates permission.
    • The node API rejects a non-boolean restrictedToMembers, because the collection schema declares it boolean.
  • Tests already pin the core side of the contract:

    • test_collection_has_restricted_to_members_field, in mod tests of core_schemas.rs, checks the name, boolean, Core protection and the default of false.
    • core_schema_scalar_fields_are_enforced, in packages/core/tests/it/scalar_field_type_validation_test.rs, checks that a string "true" is rejected.
  • Overlap with Reword core data-model and identity docs that cite Pro, Supabase, RLS or tenants #3365. Reword core data-model and identity docs that cite Pro, Supabase, RLS or tenants #3365 also planned to rewrite these lines ("drop both RLS sentences"), but without the contract and with no permission statement. This issue owns the block, and Reword core data-model and identity docs that cite Pro, Supabase, RLS or tenants #3365 leaves it alone.

Scope

  • packages/core/src/models/core_schemas.rs:
    • in get_core_schemas, the comment block directly above fields: vec![ in the collection SchemaNode;
    • in mod tests, the leading comment of test_collection_has_restricted_to_members_field.
  • scripts/check-pro-boundary.ts: BASELINES, from the printed block.

Out of scope

Steps

  1. Read the merged ADR-083. Confirm it is merged with git -C <docs> fetch origin main, then look for decisions/083- in the output of git -C <docs> ls-tree --name-only origin/main decisions/. Read its final §4.

  2. Replace the comment block with the text below. If the merged ADR-083 words the two contract sentences differently, use its wording.

                // `restrictedToMembers` (ADR-037 opt-in restriction) is stored at
                // `properties.collection.restrictedToMembers` as a JSON boolean;
                // absent or false means open (organizational). Locally it bounds
                // embedding roots and marks the personal AI-chat collection. This
                // path and type are a storage contract: access-control layers
                // outside core read this exact path and treat any value whose text
                // form is not `true` as unrestricted. Do not rename the field, move
                // it out of the `collection` bucket, or store a non-boolean.
                //
                // A person's `member_of` edge to a collection carries
                // `properties.permission`, one of `admin`, `modify` or `readOnly`;
                // a content node's membership edge carries none. Core stores it as
                // a free-form edge property (no schema field) and does not validate
                // it; it reads `admin` back to find the personal AI-chat collection.
                // This path and these values are a storage contract: access-control
                // layers outside core read them directly and treat an absent value
                // as `modify`.
  3. Update the test's leading comment to: // ADR-037: opt-in restriction is a Core-protected boolean on collection. Its name, bucket and type are a storage contract (see the schema comment); this test pins them.

  4. Lower the baselines. Run bun run scripts/check-pro-boundary.ts and paste the printed block over BASELINES. At af8ddb6 the old block held one proWording line and two cloudWording lines, so expect 314 → 313 and 89 → 87. Take the real numbers from the check.

  5. Run bun run quality:fix, then the verification below.

Acceptance criteria

  • The block states both contracts in ADR-083 §4's wording, gives each field's local meaning, and names no consumer: no Pro, RLS, Supabase, tenant or nodespace-sync wording.
  • bun run scripts/check-pro-boundary.ts --list cloudWording and --list proWording show no line from this block.
  • Ran bun run scripts/check-pro-boundary.ts and pasted the printed BASELINES block, and the check exits 0. Only proWording and cloudWording moved, each by exactly the lines this block dropped.
  • git diff origin/main changes only comment lines in core_schemas.rs, plus the BASELINES numbers.
  • bun run scripts/check-code-references.ts passes.
  • Both contract tests pass unchanged.

Tests and verification

  • No new test. The change is comment-only, and the two tests above already pin the part of the contract that core owns. Run them:
    • .tools/bin/cargo-nextest nextest run -p nodespace-core --lib core_schemas
    • .tools/bin/cargo-nextest nextest run -p nodespace-core --test it scalar_field_type_validation_test::
  • cargo clippy -p nodespace-core --all-targets -- -D warnings -D clippy::unused-async
  • bun run scripts/check-pro-boundary.ts and bun run scripts/check-code-references.ts
  • bun run test:changed. The diff reaches packages/core and scripts/, so the Rust and scripts tiers run, and the Rust tier takes the machine slot.

Dependencies

Risks and rollback


Plan key: C1.3 (pro-boundary DAG).

🤖 Generated with Claude Code

Activity

  1. self-assigned this
    on Sep 30, 2026
  2. added
    pro-boundary
    on Sep 30, 2026
  3. mstomar125 commented on Sep 30, 2026

    @mstomar125
    ContributorAuthor

    Completed in #3389 (merged). Auto-close did not fire; closing manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

pro-boundary

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions