Skip to content

Remove the tenant-binding root fallback from the collections tree #3330

Closed

Description

@mstomar125

Summary

Stop core's collections tree from hiding the Pro tenant's workspace root.

After #3314, collectionsTree hides two sets of collections:

  • the union of every extension's collectionTreeRoots() (ADR-082 §2.2, proposed);
  • a transitional core fallback: databaseStore.activeDatabase?.boundTenantCollection || ROOT_COLLECTION_ID.

This PR deletes the fallback, the ROOT_COLLECTION_ID constant and the databaseStore import. The Pro frontend supplies the root itself (ADR-083 §2, proposed).

No extension point is created here, and EXTENSION_API_VERSION does not change.

Context

Line numbers are at main @ af8ddb6. #3314 changes this code first, so locate it by symbol.

packages/desktop-app/src/lib/stores/collections.svelte.ts

Symbol Lines at af8ddb6
import { databaseStore } from '$lib/stores/database.svelte' 6
The collectionsTree getter, with the bound-root fallback and its comment 147-170 (fallback and comment at 153-163)
ROOT_COLLECTION_ID ('c0000000-0000-0000-0000-000000000001') and its doc 564-578
The buildCollectionsTree doc, and its root parameter, which defaults to ROOT_COLLECTION_ID 580-600
The parent filter and its comment 620-623
The top-level filter and its comment 644-652
  • The import. databaseStore is used only for the bound root. database.svelte.ts imports collections.svelte, so removing the import also breaks a store import cycle.
  • Why the fallback is Pro-only. Core never creates either collection.
    • The Pro daemon mints the per-install "My Workspace" root. It makes every pushed node and collection member_of that root, for row-level-security visibility.
    • The legacy id is the root of the old shared tenant. In core's Rust it appears only in two node_service tests.
  • What ADR-083 §2 says.
    • collectionsTree stops reading boundTenantCollection.
    • ROOT_COLLECTION_ID moves to the Pro package.
    • The Pro frontend's collectionTreeRoots returns the bound collection, falling back to the legacy id.
  • What Add the collectionTreeRoots extension point to the sidebar collection tree #3314 did.
    • It added the contribution and its registry accessor. The accessor takes the union across extensions and is throw-safe.
    • It routed collectionsTree through them, and buildCollectionsTree now takes a set of root ids.
    • It kept the fallback, so nothing changed until this PR.

Scope

collections.svelte.ts

  • Delete import { databaseStore }.

  • In collectionsTree, delete the fallback root and its comment, and pass only the contributed roots.

  • Delete ROOT_COLLECTION_ID and its doc.

  • In buildCollectionsTree, if the roots parameter still defaults to ROOT_COLLECTION_ID (or to a set containing it), default it to an empty set.

  • Rewrite buildCollectionsTree's doc, the parent-filter comment and the top-level-filter comment neutrally. They should say that:

    • a root is a container collection that the tree does not show;
    • a collection whose only parent is a root shows at the top level;
    • with no roots, nothing is hidden.

    Leave out tenant, per-install, RLS and "My Workspace" wording.

src/tests/stores/collections.test.ts

  • Drop the ROOT_COLLECTION_ID import.

  • Rework the "buildCollectionsTree dynamic bound-root filtering" describe. It is at lines 638-746 at af8ddb6, unless Add the collectionTreeRoots extension point to the sidebar collection tree #3314 has changed it.

    • Rename it "buildCollectionsTree root filtering".
    • Rename PER_INSTALL_ROOT to ROOT, and reword the comments neutrally.
    • Keep the cases where a root is passed:
      • its members render as top-level peers;
      • the root itself is excluded, even when it has content members;
      • real sub-collections still nest.
    • Rewrite "would WRONGLY nest them under the root when the stale legacy constant is used" as "with no roots, a container collection is an ordinary top-level collection with its members nested under it". Call it with no roots, instead of with ROOT_COLLECTION_ID.
    • Replace "falls back to the legacy ROOT_COLLECTION_ID when no root id is given (public/legacy tenant)" with "does not special-case the legacy workspace-root id":
      • use a fixture collection whose id is the literal 'c0000000-0000-0000-0000-000000000001', and whose members list it as their parent;
      • with no roots, it renders at the top level with its members nested under it.
  • In "collectionsTree hide-empty filter", add a case with no extension registered:

    • call collectionsData._setTestData with a container collection and its member collections;
    • the tree shows the container at the top, with its members nested under it.

    Add the collectionTreeRoots extension point to the sidebar collection tree #3314's tests cover the contributed-roots path.

Ratchet

Run bun run scripts/check-pro-boundary.ts and paste the printed BASELINES.

Out of scope

Steps

  1. Startup, per core's CLAUDE.md:
    • On the primary checkout, run git status, then git fetch origin && git pull origin main.
    • Run EnterWorktree({name: "issue-<N>-drop-tenant-root-fallback"}).
    • Inside the worktree, run bun install, then bun run test for the baseline.
    • Run bun run gh:comment <N> "Frontend: X passed", bun run gh:assign <N> "@me" and bun run gh:status <N> "In Progress".
  2. Confirm that Add the collectionTreeRoots extension point to the sidebar collection tree #3314 is on main, so collectionsTree reads the contributed roots.
  3. Make the collections.svelte.ts changes.
  4. Update the tests.
  5. Run the full frontend suite with bun run test. Removing the store import changes which modules a test pulls in as a side effect. In particular, daemon-reconnect-retry.test.ts imports collections.svelte on its own.
  6. Run the searches under Acceptance criteria, then the ratchet.
  7. Finish:
    • Run bun run test:changed.
    • Run bun run --cwd packages/desktop-app quality:fix, then commit.
    • Run git push origin HEAD:issue-<N>-drop-tenant-root-fallback.
    • Run gh pr create --repo NodeSpaceAI/nodespace-core --base main --head issue-<N>-drop-tenant-root-fallback, then bun run gh:status <N> "In Review".
    • Run /pragmatic-code-review, then /address-review.
    • Merge only after the user approves. Run bun run merge <PR#> in the background, then ExitWorktree.

Standards:

  • ADR-049: no $effect for derivations.
  • Use createLogger.
  • Run tests with bun run test, never bun test.

Acceptance criteria

  • rg -n -i 'ROOT_COLLECTION_ID|boundTenant|databaseStore|tenant|per-install' packages/desktop-app/src/lib/stores/collections.svelte.ts finds nothing.
  • rg -n ROOT_COLLECTION_ID packages/desktop-app/src finds nothing.
  • buildCollectionsTree hides exactly the roots it is given, and nothing by default.
  • With no extension registered, collectionsData.collectionsTree hides nothing, including a collection with the legacy id.
  • Add the collectionTreeRoots extension point to the sidebar collection tree #3314's contributed-roots tests still pass.
  • EXTENSION_API_VERSION is unchanged.
  • In the free app, a database that was never synced shows the same sidebar tree as before.
  • BASELINES in scripts/check-pro-boundary.ts is lowered to the printed counts, and bun run scripts/check-pro-boundary.ts exits 0.
  • bun run test and bun run --cwd packages/desktop-app quality:fix pass.

Tests and verification

  • bun run --cwd packages/desktop-app test src/tests/stores/collections.test.ts src/tests/stores/daemon-reconnect-retry.test.ts
  • bun run test
  • Free-app check: run bun run tauri:dev with an isolated NODESPACE_HOME, and open a database that was never synced. The sidebar tree matches main's.
  • Pro check, in nodespace-sync's pin-bump PR, with SYNC counterpart (c) from the parent: open a bound database. "My Workspace" is not listed, and its member collections appear as top-level peers.

Dependencies

Risks and rollback

  • Deliberate behaviour change (ADR-083). Take a database that the Pro daemon bound, and open it in core without the Pro frontend.
    • Its workspace root now shows as a top-level collection, with every collection nested under it.
    • That is accurate, because it is a real collection.
    • The free app with a never-synced database is unaffected.
  • Pro build at a pin past this commit, without counterpart (c): the root reappears and nests everything. The pin gate keeps this out of Pro releases until sync's pin-bump PR carries (c).
  • Rollback: revert the PR.

Plan key: C6.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 Oct 1, 2026

    @mstomar125
    ContributorAuthor

    Frontend baseline at 066fac4: 308 test files, 5606 tests passed

  4. added a commit that references this issue on Oct 1, 2026
    d97fd10
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