Skip to content

Replace the registry's tenant-binding fields with extension keys and set_extensions #3342

Closed as not planned

Description

@mstomar125

Summary

Finish ADR-083 §2 (proposed; decision 2-A). Remove the typed tenant binding from core's registry, wire and frontend, and give extensions a generic registry setter.

  • Registry entries. DatabaseEntry loses bound_tenant_schema and bound_tenant_collection. Existing lines load into extensions, which Carry opaque registry extensions through DatabaseInfo and drop the tray's synced label #3341 added, and survive every save under the same key names.
  • Setter. DatabaseManager::set_bound_tenant(id, schema, collection) becomes set_extensions(id, entries):
    • entries are (key, Option<String>) pairs, and None removes a key;
    • all entries are written in one save;
    • the registry's own keys (id, name, path, created_at, last_opened_at) are rejected.
  • Wire and frontend. Proto DatabaseInfo fields 8 and 9 become reserved 8, 9;. The daemon mapping, the desktop DTO and the frontend DatabaseInfo drop the typed fields.

Context (lines at af8ddb61 are hints)

Why the pin gate.

  • Sync's release workflow and build-pro-dmg.sh build core's desktop app from core HEAD, while nodespaced-pro is pinned at 680c35d8.
  • Without one pinned rev for both, this PR would reach the Pro GUI at once. The GUI would read extensions from a Pro daemon that still sends fields 8 and 9, and would show every database as unbound (ADR-083 §7 item 4).
  • With the gate in place, core merges first and sync adapts in its pin-bump PR.

Readers that must be gone first:

Pro's side at its pin bump (sync notes, not gates). Key names do not change, so no data moves.

  • Pro daemon reads listing.entry.extensions.get("bound_tenant_schema") for the one-database-per-tenant check and for sign-out enumeration (cloud_sync/mod.rs ~1021, grpc.rs ~1130).
  • Pro daemon writes both keys with set_extensions after the node write (main.rs ~687, cloud_sync/mod.rs ~1051), passing None on unbind.
  • Pro package. Its database.row badge and its collectionTreeRoots contribution read extensions["bound_tenant_schema"] and extensions["bound_tenant_collection"] from the host API's database list.

Code:

  • DatabaseEntry fields (~96-105).
  • set_bound_tenant (~702-727), plus the docs that name it (~577, ~621).
  • Struct literals (~771-778, ~856-863, ~1162-1169, and tray.rs ~810-818).
  • Tests set_bound_tenant_mirrors_persists_and_clears (~1468-1508) and set_bound_tenant_rolls_back_when_save_fails (~1728-1772).
  • Proto fields (~69-77). The comment at ~75 also cites an issue number, which core CLAUDE.md forbids.
  • Daemon mapping in database_service.rs (~68-69).
  • DTO in commands/database.rs (~49-55, ~87-88).
  • Frontend in database.svelte.ts (~39-48, ~82-83).
  • Fixtures in database.test.ts (~140-141) and navigation-sidebar-nav-items.test.ts (~34-35).

Scope

Everything listed under Context, in core only.

Out of scope

Steps

  1. Start. Follow core CLAUDE.md's startup sequence:

    • EnterWorktree({name: "issue-<N>-registry-set-extensions"});
    • bun install;
    • the bun run test baseline;
    • gh:assign, then gh:status.

    Then confirm the preconditions:

  2. Registry.

    • Delete the two typed fields and their docs.

    • Add pub const REGISTRY_ENTRY_KEYS: [&str; 5] = ["id", "name", "path", "created_at", "last_opened_at"];.

    • Add pub async fn set_extensions(&self, id: &DatabaseId, entries: &[(&str, Option<String>)]) -> Result<()>:

      • reject any key in REGISTRY_ENTRY_KEYS with an error, before touching the registry;
      • fail an unknown id through find_or_err, as rename does;
      • otherwise run one mutate_and_save that inserts a toml::Value::String or removes the key.

      Its doc names no key. It says that a failed save leaves the previous registry live, and that a successful one notifies subscribe_changes.

    • Delete set_bound_tenant, and fix the two docs that list it.

    • Drop the typed fields from the struct literals.

  3. Proto. Delete fields 8 and 9 and their comments. Add reserved 8, 9; with the comment "Retired fields. Never reuse these numbers."

  4. Mapping, DTO and frontend. Delete:

    • the typed fields and their mapping lines;
    • the two lines in IMPLICIT_BROWSER_DATABASE;
    • the fixture lines.
  5. Tests (database_manager.rs):

    • Delete the two set_bound_tenant_* tests.
    • set_extensions_persists_and_clears: set two keys, reload from disk and see both; then pass None and see that key removed.
    • set_extensions_rolls_back_when_save_fails: follow the shape of rename_rolls_back_when_save_fails (~1675). Keep the old test's check that only a successful call notifies subscribers.
    • set_extensions_rejects_registry_keys: pass name; nothing is written.
    • set_extensions_on_unknown_id_is_not_found.
    • registry_entry_keys_match_the_serialized_entry: serialize an entry with every Option set and empty extensions into a toml::Table. Its keys must equal REGISTRY_ENTRY_KEYS, which guards the list against drift.
  6. Grep. git grep -n -E 'bound_?[tT]enant|[bB]oundTenant' -- packages prints nothing.

  7. Ratchet. Run bun run scripts/check-pro-boundary.ts and set BASELINES to the printed counts. Expect cloudBindState and tenantWording to drop.

  8. Finish.

    • bun run test:changed, then bun run quality:fix, then commit.
    • Push to issue-<N>-registry-set-extensions.
    • gh pr create --repo NodeSpaceAI/nodespace-core --base main --head issue-<N>-registry-set-extensions, then gh:status "In Review".
    • After approval, run bun run merge <PR#> in the background.

Acceptance criteria

Tests and verification

  • bun run test:changed
  • .tools/bin/cargo-nextest nextest run -p nodespace-daemon --lib database_manager
  • .tools/bin/cargo-nextest nextest run -p nodespace-daemon --lib tray
  • bun run rust:test:app-units
  • bun run --cwd packages/desktop-app test src/tests/stores/database.test.ts src/tests/components/navigation-sidebar-nav-items.test.ts
  • cargo clippy -p nodespace-daemon -p nodespace-proto --all-targets -- -D warnings -D clippy::unused-async
  • Manual check. Use an isolated NODESPACE_HOME whose databases.toml entry has bound_tenant_schema and bound_tenant_collection lines. Then:
    • the daemon starts and lists the database;
    • a rename keeps both lines in the file;
    • Settings → Databases shows no sync status.

Dependencies

Risks and rollback

  • Merging before the pin gate would make the Pro GUI show every database as unbound until the next Pro release built with a matching daemon. The gate prevents this.
  • Rollback. Revert the PR. The legacy lines are still in databases.toml, because extensions preserved them, so the restored typed fields read them again.

Plan key: C7.6 (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

    Acceptance criterion added (from #3341's review): when set_extensions (or any writer of registry extension keys) is added here, reject keys that collide with the registry entry's own field names (id, name, path, created_at, last_opened_at, and the bound_* fields while they exist). DatabaseEntry.extensions is #[serde(flatten)], so a colliding key would clobber the typed value on save.

  4. mstomar125 commented on Oct 1, 2026

    @mstomar125
    ContributorAuthor

    Superseded by #3412 (umbrella against the final ADR-081–085)

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