Skip to content

Carry opaque registry extensions through DatabaseInfo and drop the tray's synced label #3341

Closed

Description

@mstomar125

Summary

Add an opaque, per-database extensions map end to end, as ADR-083 §2 recommends (proposed; decision 2-A). Nothing is removed yet.

  • Registry: DatabaseEntry.extensions holds every key of a databases.toml entry that the registry does not define, verbatim through load and save.
  • Wire: DatabaseInfo.extensions (map<string, string> extensions = 10) carries the string-valued entries.
  • Desktop: the desktop DTO and the frontend DatabaseInfo both carry extensions.
  • Core reads no key from it.

This PR also deletes the tray's "synced" label. Per ADR-083 §2 and §7 item 2, that can land at any time.

The change is additive: fields 8 and 9 and the typed binding fields stay until #3342. There is no gate.

Context (lines at af8ddb61 are hints)

  • Registry. DatabaseEntry is in packages/daemon/src/services/database_manager.rs (~81-106).
    • It has no deny_unknown_fields, so today an unknown key is ignored on load and silently dropped on the next Registry::save.
    • Every registry mutation goes through mutate_and_save.
  • Serde flatten with toml 0.8.2 was checked with a probe. With #[serde(flatten)] extensions: toml::Table:
    • unknown keys, nested tables included, load into the map and are written back;
    • None fields are skipped;
    • RFC 3339 created_at strings round-trip;
    • the typed fields keep working next to the map.
  • Wire and desktop:
    • proto DatabaseInfo in packages/proto/proto/database_service.proto (~54-78);
    • daemon mapping listing_to_info in packages/daemon/src/services/database_service.rs (~58-71);
    • desktop DTO DatabaseEntry and to_entry in packages/desktop-app/src-tauri/src/commands/database.rs (~37-90);
    • frontend DatabaseInfo and IMPLICIT_BROWSER_DATABASE in packages/desktop-app/src/lib/stores/database.svelte.ts (~26-49, ~74-84).
  • Why no gate. The change is wire-additive.
    • A Pro GUI built from core HEAD talks to the pinned Pro daemon. It decodes the missing field 10 as an empty map, and fields 8 and 9 still arrive.
    • Nothing in sync constructs DatabaseEntry literals.
  • Tray. database_menu_entries in packages/daemon/src/tray.rs (~243-291) adds synced when bound_tenant_schema is set (~276-278).
    • Only the community daemon runs a tray; nodespaced-pro starts none. So the label only ever showed for a core user whose registry the Pro daemon had written.
    • Its doc (~244-256) also says "Deliberately NOT whether a database is currently open". That is stale: the open marker exists (~268-273).

Scope

  • Registry (database_manager.rs):
    • Add #[serde(flatten)] pub extensions: toml::Table to DatabaseEntry. Its doc: keys of this entry that the registry does not define, kept verbatim; core interprets none of them; an extension stores per-database values here (ADR-083).
    • Add #[serde(skip_serializing_if = "Option::is_none")] to the Option fields.
    • Set extensions: toml::Table::new() in the struct literals (~771-778, ~856-863, and the test at ~1162-1169).
  • Proto. Add to DatabaseInfo:
    // Per-database keys the registry stores for extensions, copied verbatim.
    // Core interprets none of them. Only string values are carried.
    map<string, string> extensions = 10;
  • Daemon mapping. listing_to_info fills extensions from the entry's string-valued entries and skips values of any other type.
  • DTO. Add pub extensions: std::collections::BTreeMap<String, String> (camelCase extensions) to DatabaseEntry, and copy it in to_entry.
  • Frontend:
  • Tray:
    • Delete the synced marker.
    • Rewrite the doc: the label carries the persisted default flag, the live open state and a missing-file state.
    • The test helpers listing_with_default and listing (~803-826) drop their tenant parameter. The literal sets extensions: toml::Table::new() and keeps bound_tenant_schema: None, bound_tenant_collection: None until Replace the registry's tenant-binding fields with extension keys and set_extensions #3342.
    • Rename labels_carry_default_and_synced_state to labels_carry_default_state.
    • markers_render_in_a_stable_order now expects All — default · open.
    • The two missing-entry tests drop Some("tenant_demo").

Out of scope

Steps

  1. Start. Follow core CLAUDE.md's startup sequence:
    • EnterWorktree({name: "issue-<N>-registry-extensions"});
    • bun install;
    • the bun run test baseline;
    • gh:assign, then gh:status.
  2. Make the Scope changes in this order: registry, proto, daemon mapping, DTO, frontend, tray.
  3. Add tests:
    • database_manager.rs, registry_round_trips_entry_keys_it_does_not_define. Write a databases.toml whose entry has plugin_state = "keep" and a nested [databases.extra] table.
      • Registry::load puts both in extensions, and id, name, path and created_at are intact.
      • After save and a reload, both are still there.
    • database_manager.rs, a_rename_keeps_extension_keys. DatabaseManager::rename on such an entry leaves extensions unchanged on disk.
    • database_service.rs tests, listing_to_info_carries_string_extensions_only. A string value is carried; an integer or table value is skipped.
    • commands/database.rs, to_entry_passes_extensions_through. It runs under bun run rust:test:app-units.
    • tray.rs, extension_keys_add_no_marker. An entry with extension keys renders as its plain name.
  4. Ratchet. Run bun run scripts/check-pro-boundary.ts and set BASELINES to the printed counts. Expect cloudBindState and tenantWording to drop along with the tray marker and its tenant_demo fixtures.
  5. Finish:
    • bun run test:changed, then bun run quality:fix (it includes svelte-check), then commit;
    • push to issue-<N>-registry-extensions;
    • gh pr create --repo NodeSpaceAI/nodespace-core --base main --head issue-<N>-registry-extensions, then gh:status "In Review";
    • after approval, bun run merge <PR#> in the background.

Acceptance criteria

  • An existing databases.toml loads even when an entry has keys the registry does not define, and every such key survives every registry save.
  • ListDatabases carries extensions (string values only) through the proto, the DTO and the frontend type.
  • No core code reads a specific key out of extensions.
  • The tray shows no "synced" label, and its doc matches what it renders.
  • The database switcher, Settings → Databases and the tray's database submenu work unchanged for free users.
  • bun run scripts/check-pro-boundary.ts exits 0, and BASELINES equals its printed counts.
  • Core builds, all tests pass, and svelte-check is clean.

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 database_service
  • .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 has an extra key. The daemon starts, lists the database and survives a rename, and the key is still in the file.

Dependencies

Risks and rollback

  • Serde flatten buffers the whole entry. The probe and the round-trip test cover DateTime, PathBuf, the DatabaseId newtype and nested tables.
  • Rollback. Revert the PR. Saves made while the change was live wrote unknown keys back unchanged. After the revert, the next save drops them again, which is today's behaviour.

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

    Completed in #3399 (merged). Auto-close did not fire; closing manually.

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