Skip to content

Hide only extension-contributed roots in the collections tree - #3406

Merged
mstomar125 merged 2 commits into
mainfrom
issue-3330-drop-tenant-root-fallback
Oct 1, 2026
Merged

mstomar125 merged 2 commits into
mainfrom
issue-3330-drop-tenant-root-fallback

Conversation

@mstomar125

@mstomar125 mstomar125 commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Closes #3330

Summary

The sidebar collections tree no longer reads the database's tenant binding. It hides only the roots that registered extensions contribute through collectionTreeRoots() (ADR-082 §2.2, ADR-083 §2, both proposed). Core contributes none, so with no extension registered nothing is hidden as a root.

Changes

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

  • Deleted import { databaseStore }. database.svelte.ts imports collections.svelte, so this also removes a store import cycle.
  • collectionsTree passes uiExtensionRegistry.collectionTreeRoots() straight to buildCollectionsTree. The boundTenantCollection || ROOT_COLLECTION_ID fallback root and its comment are gone.
  • Deleted ROOT_COLLECTION_ID and its doc.
  • buildCollectionsTree's rootCollectionIds now defaults to an empty set instead of new Set([ROOT_COLLECTION_ID]).
  • Rewrote the buildCollectionsTree doc, the parent-filter comment and the top-level-filter comment neutrally:
    • a root is a container collection the tree does not show;
    • a collection whose only parents are roots shows at the top level;
    • with no roots, nothing is hidden.

Docs that described the removed root (review follow-up, 0bfe8aa)

packages/desktop-app/src/tests/stores/collections.test.ts

  • Dropped the ROOT_COLLECTION_ID import and the databaseStore / DatabaseInfo import.
  • "collectionsTree hide-empty filter": added "hides no container collection when no extension is registered". With no extension registered, a container collection whose id is the legacy workspace-root literal shows at the top level, with its member collections nested under it.
  • "buildCollectionsTree dynamic bound-root filtering" is renamed "buildCollectionsTree root filtering". PER_INSTALL_ROOT is renamed ROOT and the comments are neutral. Changes to its cases:
    • Kept: members of a passed root render as top-level peers.
    • Kept: the root itself is excluded, even when it has content members.
    • Kept: real sub-collections still nest.
    • Kept: the two-root case and the explicit empty-set case.
    • "would WRONGLY nest them under the root when the stale legacy constant is used" is now "with no roots, a container collection is an ordinary top-level collection with its members nested under it". It is called with no roots argument.
    • "falls back to the legacy ROOT_COLLECTION_ID…" is now "does not special-case the legacy workspace-root id". It uses a fixture with the literal 'c0000000-0000-0000-0000-000000000001' id and members parented to it. With no roots, it renders at the top level with its members nested. It also asserts that a root set not naming that id leaves the tree unchanged.
    • Add the collectionTreeRoots extension point to the sidebar collection tree #3314's "does not hide the legacy root when it is absent from the set" is folded into that second assertion.
  • "collectionsTree unions extension collection-tree roots" (Add the collectionTreeRoots extension point to the sidebar collection tree #3314):

collections-tree-roots.svelte.test.ts (the derivation test from #3314) never touched the bound root and is unchanged.

Deviations from the issue

  • BASELINES not lowered. The issue's acceptance criteria say to lower BASELINES to the printed counts. The standing drain instruction overrides that: parallel PRs collide on those lines, and Drive every Pro-boundary ratchet count to zero and make the check a hard ban #3371 tightens everything at the end. Nothing rose, and the ratchet exits 0.
  • Free-app tauri:dev check done statically, not live. The dev machine is shared, so I kept builds narrow. The sidebar tree for a never-synced database is provably unchanged:
    • bound_tenant_collection is only ever set by DatabaseManager::set_bound_tenant, which is the sync-binding path. Every new registry entry starts as None.
    • So on main, a never-synced database's getter hid only ROOT_COLLECTION_ID.
    • rg -i c0000000 packages finds that id nowhere outside this PR's test fixture. No core code path creates a collection with it, so main's hidden set matched no collection.
    • This PR's hidden set is empty. The resulting tree is identical.
  • The Rust tests that the issue says use the legacy id are already gone from main (see the rg above). Nothing to leave for Move Pro-owned data out of core's data model (ADR-083) #3345 / Remove Pro, Supabase and nodespace-sync wording from core comments, docs and the skill #3372 here.

Ratchet (bun run scripts/check-pro-boundary.ts)

Exits 0. Every count moved down or stayed the same, and none rose:

marker main @ 066fac4 this PR baseline
cloudBindState 202 198 203
cloudWording 50 49 72
tenantWording 439 431 463

All other markers are unchanged. --changed reports 0 hits in collections.svelte.ts, collections.test.ts and ui-extensions.ts. Its hits in database.svelte.ts are pre-existing lines this PR doesn't add.

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.
  • A never-synced database in the free app shows the same sidebar tree as before (static proof above).
  • BASELINES lowered: intentionally not done (see Deviations). bun run scripts/check-pro-boundary.ts exits 0.
  • bun run test and bun run --cwd packages/desktop-app quality:fix pass.

Tests

  • bun run --cwd packages/desktop-app test src/tests/stores/collections.test.ts src/tests/stores/daemon-reconnect-retry.test.ts src/tests/stores/collections-tree-roots.svelte.test.ts src/tests/plugins/ui-extensions.test.ts: 4 files, 128 tests passed. daemon-reconnect-retry still passes without the store import.
  • bun run test:changed (frontend tier, the full Happy-DOM suite): passed. Happy-DOM: 308 files, 5604 tests. Browser (Chromium): 11 files, 136 tests. The baseline at 066fac4 was 5606; the -2 is 3 deleted fallback-only tests and 1 added test.
  • bun run --cwd packages/desktop-app quality:fix: eslint, design tokens and svelte-check all clean (0 errors, 0 warnings).

Mutation checks (each change applied to the store, the test file run, then the store restored):

  • A: the getter re-adds the legacy fallback root, new Set(['c0000000-…0001', ...collectionTreeRoots()]). Fails "hides no container collection when no extension is registered".
  • B: buildCollectionsTree's default goes back to the legacy id set. Fails "does not special-case the legacy workspace-root id".
  • C: the default treats every parentless container as a root. Fails 4 tests, including "with no roots, a container collection is an ordinary top-level collection…".

Risks and rollback

This is a deliberate behaviour change (ADR-083). Open a database that sync has bound in core without an extension contributing its root: the workspace root now shows as a top-level collection holding everything. That is accurate, because it is a real collection. A never-synced database is unaffected. Rollback: revert this PR.

🤖 Generated with Claude Code

@mstomar125

Copy link
Copy Markdown
Contributor Author

Pragmatic code review (medium), commit 1233c3e

Review Type: Initial Review

Requirements Check

  • ✅ rg -n -i 'ROOT_COLLECTION_ID|boundTenant|databaseStore|tenant|per-install' collections.svelte.ts finds nothing.
  • ✅ rg -n ROOT_COLLECTION_ID packages/desktop-app/src finds nothing.
    • No importer of ROOT_COLLECTION_ID or other caller of buildCollectionsTree exists anywhere in the worktree.
    • The local nodespace-sync checkout doesn't reference either, nor collections.svelte.
  • ✅ buildCollectionsTree hides exactly the roots it is given, and nothing by default. The default is new Set(). The tests cover:
    • no argument;
    • an explicit empty set;
    • two roots;
    • a root set that doesn't name the legacy id.
  • ✅ With no extension registered, collectionsTree hides nothing, including a collection with the legacy id. The new hide-empty test covers this.
  • ✅ Add the collectionTreeRoots extension point to the sidebar collection tree #3314's contributed-roots tests still pass. I ran 4 files: 128 passed.
  • ✅ EXTENSION_API_VERSION is unchanged.
  • ✅ The static free-app argument holds:
    • bound_tenant_collection is assigned only in DatabaseManager::set_bound_tenant.
    • Every new registry entry starts as None.
    • git log -S shows the legacy id only ever appeared in Rust test constants and the frontend constant.
  • ⏭️ BASELINES not lowered: a standing decision. The ratchet exits 0, and its counts match the PR table.

Code Review Findings

🟡 Important: the public extension contract still documents the core root this PR removes

📁 packages/desktop-app/src/lib/plugins/ui-extensions.ts:151-152

CollectionTreeRootsContribution's doc says "The host takes the union of every extension's list with core's own root…". After this PR, there is no core root.

This is the doc the counterpart contribution is written against. ADR-083 §2 requires that contribution to fall back to the legacy id itself, and this sentence suggests core still does it.

Recommendation: say that with no extension contributing, no collection is hidden as a root. This is comment-only, so there is no API version bump.

Principle: docs change in the same atomic change as the behaviour they describe, especially on a versioned contract surface.

🟢 Suggestion: field docs still say the frontend falls back to the well-known root id

📁 packages/desktop-app/src/lib/stores/database.svelte.ts:44-48 (also the proto and app-lib Rust field docs)

These fields belong to #3345, which deletes them. Either trim the TS doc's last two sentences here, since it's frontend-only, or note it on #3345. Leave the proto and Rust docs alone.

🟢 Nit: "nothing is hidden" overstates, because empty collections are still pruned

📁 packages/desktop-app/src/lib/stores/collections.svelte.ts:567-568, :618-622

Use the getter's precise phrasing instead: "no collection is hidden as a root".

Verified, no finding

  • Reactivity: activeDatabase fed only the deleted fallback. The getter still reads $state and calls contributors inside the caller's derivation. There is no $effect.
  • Module-init order: dropping the import breaks a real cycle. daemon-reconnect-retry.test.ts imports database.svelte explicitly, and it passes.
  • The collectionTreeRoots().size === 0 precondition is sound: the run isn't shuffled or concurrent, and the only registering describe unregisters in afterEach.
  • No coverage lost:
    • The "absent from the set" case is folded into the legacy-id test.
    • The "core's own root" test covered removed behaviour.
    • The bound-db test was deleted on request.
  • Rules: no tenant, per-install, RLS or Pro wording in new lines, and no #NNNN. Security and performance are unaffected.

Recommendation: REQUEST CHANGES. Only finding 1 blocks; the PR is otherwise correct, atomic and well tested.

@mstomar125 mstomar125 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated pragmatic-code-review of 1233c3e: REQUEST CHANGES (posted as a comment, because GitHub blocks self-review verdicts). One 🟡 contract-doc finding and two 🟢. Full findings in the review comment above.

@mstomar125

Copy link
Copy Markdown
Contributor Author

Address review: changes in 0bfe8aa

All three findings are addressed. Every change is to a comment or doc string; no code changed.

Checks after the fix

  • bun run --cwd packages/desktop-app quality:fix: clean.
  • bun run test:changed: passed (Happy-DOM and Chromium).
  • The push check passed.
  • Ratchet exits 0. tenantWording is now 431, from the trimmed doc line. No count rose.

Re-Review Decision

Decision: NO RE-REVIEW NEEDED

Rationale: every change since the reviewed commit is to a comment or doc string, with no logic touched. Each one applies the reviewer's own suggested wording. Tests and the push check are green.

@mstomar125

Copy link
Copy Markdown
Contributor Author

Pragmatic code review: re-review of 0bfe8aa (delta 1233c3e..0bfe8aa)

Review Type: Re-Review

Previous Review Summary: 3 recommendations. 3 addressed, 0 not addressed, 0 new issues found.

Findings

  1. ✅ Resolved: 🟡 extension contract doc.
    • 📁 packages/desktop-app/src/lib/plugins/ui-extensions.ts:151-153
    • The doc now says the host unions every extension's list and has no root of its own, so with no extension contributing, no collection is hidden as a root.
    • That matches the getter. A contribution author can now see that core supplies no fallback, so their contribution must include the legacy id itself (ADR-083 §2).
    • The wording has no tenant, Pro or sync terms. The change is comment-only, and EXTENSION_API_VERSION is unchanged.
  2. ✅ Resolved: 🟢 the DatabaseInfo.boundTenantCollection doc.
  3. ✅ Resolved: 🟢 "nothing is hidden" nit.
    • 📁 packages/desktop-app/src/lib/stores/collections.svelte.ts:567, :621-622
    • Both now say "no collection is hidden/dropped as a root". That matches the getter's doc and doesn't contradict the pruneEmptyCollections call that follows.
  4. Nothing new in the delta.
    • It touches 3 files, +8/−10, all comments. No logic, imports or tests changed.
    • The ratchet exits 0 and no count rose: tenantWording is 431 (was 432), cloudBindState 198, cloudWording 49.

Recommendation: APPROVE.

@mstomar125 mstomar125 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated pragmatic-code-review re-review of 0bfe8aa: APPROVE (posted as a comment, because GitHub blocks self-approval). All 3 prior findings resolved, none new. Full report in the comment above.

@mstomar125

Copy link
Copy Markdown
Contributor Author

Merge queue: #3406 was taken out of the queue — the merge gate failed on it, rebased onto main. Reproduce with git rebase origin/main and bun run test:changed, fix, push, and re-run bun run merge 3406.

test window_routing::tests::empty_database_id_is_treated_the_same_as_no_id ... ok
test window_routing::tests::no_database_id_and_no_focus_falls_back_to_the_first_label_deterministically ... ok
test window_routing::tests::no_database_id_routes_to_the_focused_window ... ok
test window_routing::tests::no_monitor_information_fails_open_rather_than_forcing_the_fallback ... ok
test window_routing::tests::no_windows_open_at_all_yields_no_targets ... ok
test window_routing::tests::only_a_sliver_of_overlap_does_not_count_as_onscreen ... ok
test window_routing::tests::registry_pin_returns_the_previous_value_and_unpin_removes_it ... ok
test window_routing::tests::resolve_focus_window_falls_back_deterministically_when_nothing_is_focused ... ok
test window_routing::tests::resolve_restore_geometry_applies_the_saved_geometry_unchanged_when_no_monitor_is_known_at_all ... ok
test window_routing::tests::resolve_restore_geometry_centers_an_offscreen_geometry_on_the_primary_monitor ... ok
test window_routing::tests::resolve_restore_geometry_falls_back_to_the_first_monitor_when_no_primary_is_identified ... ok
test window_routing::tests::resolve_restore_geometry_leaves_an_onscreen_geometry_unchanged ... ok
test window_state::tests::a_corrupt_file_is_treated_as_no_saved_state_rather_than_an_error ... ok
test window_state::tests::a_transient_non_missing_read_failure_refuses_to_save_rather_than_wiping_the_file ... ok
test window_state::tests::concurrent_saves_for_different_databases_all_survive ... ok
test window_state::tests::different_databases_do_not_clobber_each_other ... ok
test window_state::tests::is_plausible_rejects_degenerate_dimensions_but_allows_negative_position ... ok
test window_state::tests::missing_file_yields_no_saved_geometry ... ok
test window_state::tests::save_leaves_no_temp_file_behind ... ok
test window_state::tests::save_then_load_round_trips ... ok
test window_state::tests::saving_again_for_the_same_database_overwrites_its_entry ... ok
test shutdown_tests::close_requested_does_not_cancel_token_until_window_is_destroyed ... ok
failures:
---- daemon_setup::stale_socket_removal_tests::a_socket_nothing_answers_on_is_removed stdout ----
thread 'daemon_setup::stale_socket_removal_tests::a_socket_nothing_answers_on_is_removed' (11771249) panicked at packages/desktop-app/app-lib/src/daemon_setup.rs:3701:9:
assertion failed: !socket.exists()
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
failures:
    daemon_setup::stale_socket_removal_tests::a_socket_nothing_answers_on_is_removed
test result: FAILED. 279 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 2.83s
error: test failed, to rerun pass `-p nodespace-app-lib --lib`
error: script "rust:test:app-units" exited with code 101
error: script "rust:test" exited with code 101
[stage exited with code 101]

  full output: /var/folders/3w/y9kj522n1_j9wqmt6vl_sb6r0000gp/T/nodespace-gate-logs/_gate-merge-2026-10-01T07-34-33-875Z/rust-test-rust-workspace-nextest.log

✗ rust:test (Rust workspace, nextest) failed — merge blocked.
  Fix the failure, push, and re-run: bun run merge <PR#>

mstomar125 and others added 2 commits October 1, 2026 10:03
…3330)

collectionsTree passes uiExtensionRegistry.collectionTreeRoots() straight to
buildCollectionsTree and no longer reads the active database's
boundTenantCollection or falls back to ROOT_COLLECTION_ID. The constant and
the databaseStore import are deleted, which also drops the
collections <-> database store import cycle. buildCollectionsTree's roots
default to an empty set, and its doc and filter comments describe a root
neutrally: a container the tree does not show, whose members show at the top
level.

Tests: the bound-root describe becomes "buildCollectionsTree root filtering"
with neutral fixtures; the no-roots and legacy-id cases assert nothing is
hidden; a getter case checks that no container is hidden without an
extension. The extension-roots describe drops the core-root and active
database root cases and its legacy-root fixture.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…f its own

- CollectionTreeRootsContribution's doc no longer says the host unions the
  extension lists with core's own root; with no extension contributing, no
  collection is hidden as a root.
- DatabaseInfo.boundTenantCollection's doc drops the two sentences saying the
  collections store hides it and falls back to the well-known root id.
- buildCollectionsTree's doc and top-level comment say no collection is hidden
  "as a root" rather than "nothing is hidden", since empty collections are
  still pruned.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mstomar125
mstomar125 force-pushed the issue-3330-drop-tenant-root-fallback branch from 0bfe8aa to 2729a43 Compare October 1, 2026 08:03
@mstomar125
mstomar125 merged commit 25ae1ee into main Oct 1, 2026
@mstomar125
mstomar125 deleted the issue-3330-drop-tenant-root-fallback branch October 1, 2026 08:03
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.

Remove the tenant-binding root fallback from the collections tree

1 participant