Skip to content

[bug] Imported/nested collections have no person member_of edge → invisible in the sidebar #1705

Closed

Description

@mstomar125

Split from #1703 (facet 2). #1703 fixed the duplicate-collection-nodes facet (deterministic ids, #1704).

Symptom

After nodespace import dir <docs> --auto-collection-routing, the imported sub-collections (Architecture, Components, Decisions, …) are created and linked member_of the root/default collection, and their content syncs — but no member_of edge links a person to them. In tenant_demo synced to a fresh device as demo@, the person was a member of 0 collections, so the sidebar showed only the default collection even though all sub-collection nodes were present remotely.

Root cause (to confirm)

get_all_collections (the sidebar source) returns all local collection nodes with no membership filter — so the real question is whether the sub-collection nodes sync down to the device at all. They are reachable only via the root (collection→collection member_of), not via a person member_of edge, so cloud RLS/sync reachability may not pull the collection nodes for a user who is only a member of the root. Import also has no importer-identity context, so it can't stamp the importer as a member.

Options

  1. Import stamps the importer as member_of each created collection — needs identity plumbing into the import path (daemon knows the signed-in person; core import service does not).
  2. Sidebar/sync surfaces collections reachable from a collection the user IS a member of (e.g. member of root ⇒ see root's sub-collections) regardless of an explicit person edge.

Notes

Being ground-truthed during a fresh tenant_demo re-import + membership pass; will pick the option based on the observed sync-reachability behavior.

Activity

  1. mstomar125 commented on Jul 20, 2026

    @mstomar125
    ContributorAuthor

    Investigation (2026-07-20): the pull reachability RPC already traverses nested collections

    Traced the actual sync-pull scoping. The initial/reconnect pull is scoped by the collection_reachable_node_ids(my_collection_ids) RPC, not by the open RLS. That RPC is a recursive frontier expansion starting from the collections the user is a member of, following both has_child and member_of edges to their out-nodes.

    Because cloud member_of stores the collection as the in-node and the member as the out-node, expanding from a member collection C reaches C's members — INCLUDING sub-collections that are member_of C — and recurses into them. So a user who is a member of an ancestor collection (e.g. the root/Default) already reaches the nested sub-collections and their content; they sync down, and get_all_collections (which returns ALL local collection nodes with no membership filter) then shows them in the sidebar.

    Validated the positive case live on tenant_demo: after the deduped docs re-import (20 collections) + adding the user as a member, all 20 collection nodes + member edges synced to a fresh device.

    Likely state of this bug

    The original "only the default shows" report predates the #1703 dedup fix and may reflect a user who was a member of zero collections (not even root). In a normal Pro import-then-sync the daemon auto-adds the signed-in user as a member of the root collection (observed 15 root memberships re-appear during populate), so the nested collections are reachable.

    Recommended next step

    Confirm with a root-only member: reduce a test user to membership of just the root, cold-pull, verify the sub-collections land. I could not run this here — the environment's safety classifier blocks the live-DB writes needed to set up root-only membership. If confirmed, close as fixed-by-#1703 + daemon root-membership. If not, the targeted fix is to have the import stamp the importer as a member of the root (small, no access-scope change) rather than widen user_can_access_node (which would over-grant). Deliberately not touching the RLS speculatively.

  2. mstomar125 commented on Jul 20, 2026

    @mstomar125
    ContributorAuthor

    Live-validated: RESOLVED (root-only member test, with full DB authority)

    Ran the definitive root-only-member test on tenant_demo (deleted demo@'s 19 sub-collection memberships, keeping only root):

    • my_collection_ids() for a root-only member correctly returns [root] (verified directly with the JWT claim).
    • Reachability from root returns 30,747 nodes — the recursive member_of/has_child frontier reaches every sub-collection and all content (content is member_of root here; sub-collections are member_of root, so nested collections are reachable too).
    • Cold-pulled to a fresh device as root-only demo@ → 30,747 nodes local, all 20 collection nodes present (twice, reproducibly). get_all_collections returns ALL local collection nodes (no membership filter), so the sidebar shows all 20. Content (30,690 nodes) present. No wipe.

    So a member of the root/Default collection already sees the nested sub-collections and their content. The daemon auto-adds the signed-in user as a root member on import, so this is the normal flow. The original "only the default shows" report predates the #1703 dedup fix (which removed the duplicate/again-orphaned collection nodes) — that was the actual cause.

    No code change needed — deliberately NOT widening user_can_access_node (would over-grant). Closing as resolved by #1703 + root-membership + the open-by-default RLS. (Non-blocking observation: on the very first reconnect the daemon's my_collection_ids can transiently return empty before the session is fully established; the existing "suspicious wholesale loss" guard correctly skips the reconcile in that window, and the next cycle reconciles normally — content is preserved either way.)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions