Skip to content

Reword core data-model and identity docs that cite Pro, Supabase, RLS or tenants #3365

Closed

Description

@mstomar125

Summary

Reword the docs of core's data model and local identity that cite the Pro RLS layer, Supabase identity binding, tenant roles, the Postgres schema, server-side RBAC or "the cloud walk".

  • Rewrite the collection schema's restrictedToMembers comment, and the member_of permission comment in the same block, as the storage-contract statements ADR-083 (proposed) §4 prescribes.
  • Replace two strings in the free app that assume invited teammates or cloud sync:
    • the seeded person schema's email description;
    • the AI-chat plugin doc, whose claims are also wrong.

This PR changes comments, one schema description string and test fixtures. It adds one small assertion and changes no behaviour.

Context

  • ADR-081 (proposed) keeps collections, member_of and the local PersonNode in core because they have local value (§2c). ADR-083 (proposed) §4 keeps restrictedToMembers and the member_of permission levels in core as a deliberate exception (its question 6). Their docs should give their local meaning, plus the storage contract, and name no consumer.

  • core_schemas.rs, the comment above the collection schema's fields (525-529 at af8ddb6). Today it says:

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

    ADR-083 §4 gives the replacement text for both. It is a storage contract without a consumer's name:

    • restrictedToMembers is stored at properties.collection.restrictedToMembers as a JSON boolean;
    • permission is stored at properties.permission on a person's member_of edge, as one of admin, modify or readOnly.

    Core reads both locally:

    • sqlite_store/embedding_roots.rs (restricted_collection_sql) reads the flag;
    • seed_personal_ai_chat_collection_if_needed writes and reads the admin permission.
  • core_schemas.rs, the person schema's email field description (line 1312) says "required in practice for invited teammates". This text is seeded into every new database's person schema, so users and agents see it (nodespace schema get person).

  • AiChatNodeBehavior's doc (behaviors/mod.rs 1733-1735) says chats are nodes "for Stamped ACL permissions, cloud sync". The aiChatNodePlugin doc in core-plugins.ts (581-587) says the same and adds "semantic search". The next line of the Rust doc says chats are deliberately not embedded, so both claims are wrong.

  • The local person's docs. seed_local_person_if_needed, get_local_person, PersonNodeBehavior and person_seed_test explain the local person through "On Pro upgrade this node is bound to a Supabase identity via a single auth_identities row" and "tenant roles".

  • sqlite_store/conflicts.rs. The merge doc (357-363) explains a local rule through "is_deleted/deleted_at in the Postgres schema".

  • sqlite_store/embedding_roots.rs.

    • It sizes a local walk by "the cloud walk's cycle backstop (user_can_access_node in cloud-sync.md)" (16-17), and compares with the cloud walk's text comparison (23-25).
    • The access_candidate_sql doc (34-38) says a person's member_of edges are "RBAC membership, gated server-side".
  • Seeded schemas are never updated in place. seed_core_schemas_if_needed creates only missing core schemas. Existing databases keep the old email description; new databases get the new one. Per CLAUDE.md there is no migration. That is acceptable, because nothing reads this text programmatically.

  • Follow the parent's wording guide.

Scope

Line numbers are hints at af8ddb6. Locate each item by the symbol named.

  • packages/core/src/models/core_schemas.rs

    • The comment above the collection schema's fields (525-529). Replace it with ADR-083 §4's text. Keep the ADR-037 opening:
      // ADR-037: opt-in restriction, a Core-protected boolean. Default/absent =
      // false = open (organizational). Stored at
      // `properties.collection.restrictedToMembers` as a JSON boolean. 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`. It is a
      // free-form edge property, so no schema field declares it. This path and
      // these values are a storage contract: access-control layers outside core
      // read them directly and treat an absent value as `modify`.
      If the merged ADR-083 words either statement differently, use the merged text.
    • The person schema's email field description (1312). "Email address (optional)".
  • packages/core/src/behaviors/mod.rs

  • packages/desktop-app/src/lib/plugins/core-plugins.ts, the aiChatNodePlugin doc (581-587). "AI chat conversations stored as first-class knowledge graph nodes. Messages are nested properties (ADR-028), so a chat can be linked and grouped into collections like any other node. Chats are not embedded."

  • packages/core/src/services/node_service/mod.rs

  • packages/core/tests/it/person_seed_test.rs, module doc lines 3-5. "ADR-037 mandates that every install seeds exactly one local PersonNode (the local user). These tests verify:". Drop "— free included —" and the Pro/Supabase sentence.

  • packages/core/src/db/sqlite_store/conflicts.rs, the archive-the-loser step of the merge doc (357-363).

    • Keep "NOT a literal ADR-068 "deleted" tombstone: this codebase has no such lifecycle value (…)" and "introducing a new local state would invent a fourth concept…".
    • Drop the clause "ADR-042's "tombstone" turns out to be a cloud/sync-layer concept (is_deleted/deleted_at in the Postgres schema)".
  • packages/core/src/db/sqlite_store/embedding_roots.rs

    • MAX_ACCESS_WALK_DEPTH doc (16-17). "Upper bound on the upward access walk: a backstop against a member_of cycle."
    • restricted_collection_sql doc (23-25). "JSON true and the string \"true\" both count, so a flag stored as text by any writer still restricts the collection."
    • access_candidate_sql doc (34-38). Replace "A person's member_of edges are RBAC membership, gated server-side rather than by the reachability walk, so they do not classify the person node" with: "A person's member_of edges grant access to the collection (their permission); they are not content membership, so they do not classify the person node."
  • Frontend fixtures that quote the old description. They test that a field description never renders as a column header or label:

    • packages/desktop-app/src/tests/components/table-view-headers.test.ts, lines 62 and 75;
    • packages/desktop-app/src/tests/utils/schema-field-label.test.ts, line 30.

    Change the fixture text to a neutral description such as 'Email address (optional)'. Change the queryByText regex at line 75 to match the new text, so the test still proves the description is not rendered.

Out of scope

Steps

  1. Follow CLAUDE.md's startup sequence:
    • pull main;
    • EnterWorktree({name: "issue-<N>-model-docs"});
    • bun install, then the bun run test baseline;
    • self-assign at pickup and set In Progress.
  2. Confirm ADR-083 has merged: git -C <docs> fetch origin main && git -C <docs> ls-tree --name-only origin/main decisions/ | grep '^decisions/083-'. Read §4 for the final storage-contract wording and question 6's outcome.
  3. Make the edits under Scope.
  4. For table-view-headers.test.ts, check that the test still fails if the component rendered the description: temporarily render it in the header, run the test, then revert.
  5. Run bun run scripts/check-pro-boundary.ts and paste the printed BASELINES. Expected at af8ddb6, but use the real output: proWording −3, cloudWording −4, tenantWording −3, cloudBindState −2.
  6. Verify, then finish:
    • bun run quality:fix, and commit;
    • git push origin HEAD:issue-<N>-model-docs;
    • gh pr create --head issue-<N>-model-docs;
    • merge only with bun run merge <PR#> once approved.

Acceptance criteria

  • None of these contains Pro, RLS, Supabase, auth_identities, tenant, Postgres, cloud, server-side or invited teammates:
    • the collection schema comment and the person email field in core_schemas.rs;
    • the AiChatNodeBehavior and PersonNodeBehavior docs;
    • the seed_local_person_if_needed and get_local_person docs, and the multiple-has_role test comment;
    • person_seed_test.rs lines 1-5;
    • the archive-the-loser step in conflicts.rs;
    • the embedding_roots.rs docs of MAX_ACCESS_WALK_DEPTH, restricted_collection_sql and access_candidate_sql;
    • the aiChatNodePlugin doc.
  • The core_schemas.rs comment states both storage contracts from ADR-083 §4: the restrictedToMembers path, type and fail-open reading, and the permission path, values and absent-means-modify reading.
  • A new database's person schema reports the email description Email address (optional) (see the check below).
  • The AI-chat docs no longer claim chats are embedded, searchable by meaning, or cloud-synced.
  • git grep -n 'invited teammates' -- packages returns nothing.
  • BASELINES in scripts/check-pro-boundary.ts is lowered to the counts the CLI prints, and the CLI exits 0.

Tests and verification

  • cargo fmt --all --check, and cargo clippy -p nodespace-core --all-targets -- -D warnings.
  • bun run test:changed, which runs the frontend and Rust tiers.
  • Schema description check. Run .tools/bin/cargo-nextest nextest run -p nodespace-core --lib core_schemas for the schema unit tests.
    • If no test asserts field descriptions, add a small assertion to an existing core-schema test in core_schemas.rs that the person email description is "Email address (optional)".
    • Mutation-check it: restore the old string and confirm the test fails.
  • bun run --cwd packages/desktop-app test table-view-headers schema-field-label
  • bun run scripts/check-pro-boundary.ts and bun run scripts/check-code-references.ts.

Dependencies

Risks and rollback

  • Existing databases keep the old email description until they are reset, because core schemas are seeded only when missing. This is cosmetic, and nothing parses it.
  • Conflicts with Move Pro-owned data out of core's data model (ADR-083) #3345 on behaviors/mod.rs, core_schemas.rs and node_service/mod.rs. The hunks differ, so rebase.
  • Rollback. Revert the PR.

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

🤖 Generated with Claude Code

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