Skip to content

Move the Pro variant machine and DATABASE_SETTINGS_NODE_ID out of the generic registry files #3309

Closed

Description

@mstomar125

Summary

This is a pure move with no behaviour change. It empties the generic registry files of Pro logic, so that #3310 can change the registry contract in files that no longer hold any.

  • DATABASE_SETTINGS_NODE_ID moves to a neutral constants module. Core's database store uses it, and it is not a Pro concept (ADR-082 §2.2, proposed).

  • The Pro variant machine moves verbatim into a new src/lib/plugins/pro-sync-variant.svelte.ts:

    • ProSyncVariant;
    • DatabaseSettings and activeDatabaseSettings();
    • resolveProSyncVariant() and isProSyncActive().

    The file belongs to the built-in Pro extension and leaves core with it (Delete the Pro sync store, consent and relogin modals, and the Pro variant machine #3332 deletes it).

  • The Pro test file is renamed to src/tests/plugins/pro-sync-variant.test.ts with git mv, so its history follows.

  • Everything that points at the moved code is updated: every importer, every vi.mock path and the pin-guard exemption key.

The variant fields, the filters, pro-plugin.ts and every host component stay unchanged. Changing them is #3310.

Context

Paths are under packages/desktop-app/. Line hints are at af8ddb61; locate code by symbol.

src/lib/plugins/ui-extensions.ts:

  • DATABASE_SETTINGS_NODE_ID (L28-36).
    • Its doc says the singleton's properties are "database-settings-namespaced". In fact they sit flat on properties.
    • The value mirrors Rust's DATABASE_SETTINGS_NODE_ID in packages/core/src/services/node_service/mod.rs (L60).
  • ProSyncVariant (L41-47).

src/lib/plugins/ui-extensions.svelte.ts:

  • L20: import './pro-plugin'. It stays; Stop importing the Pro extension in core; register it only through the build entry #3316 removes it.
  • L22-32: the imports of proSync, labsFlags, SharedNodeStore, DATABASE_SETTINGS_NODE_ID and ProSyncVariant.
  • L34-55 DatabaseSettings and activeDatabaseSettings(); L57-95 resolveProSyncVariant(); L97-106 isProSyncActive().
  • L108-118: getActiveChromeContributions and getActiveViewerExtensions, which filter by resolveProSyncVariant().

src/tests/plugins/ui-extensions.test.ts (269 lines). All four of its describes exercise the Pro registration or the variant machine: 'registry registration', 'variant resolution', 'active contribution filtering' and 'Labs syncEnabled gate'.

Importers of the moved symbols in src/lib:

  • stores/membership.svelte.ts (isProSyncActive);
  • components/settings/sections/account-settings.svelte and components/collaboration/collaboration-locked.svelte (resolveProSyncVariant);
  • stores/database.svelte.ts (DATABASE_SETTINGS_NODE_ID, L21).

Doc references in src/lib:

  • stores/pro-sync.svelte.ts (around L233);
  • the DATABASE_SETTINGS_PIN_OWNER doc in stores/database.svelte.ts (L94-103);
  • plugins/pro-plugin.ts (L6).

Tests that reference the moved symbols:

  • free-user-guardrail.test.ts (L46-51);
  • stores/pro-sync-settings-refresh.test.ts (L51-52, and a comment at L96);
  • stores/membership.test.ts (the vi.mock at L33-35);
  • components/settings/account-settings.test.ts (L35, and a comment at L49);
  • stores/database.test.ts (L128);
  • services/shared-node-store-eviction.test.ts (L28, and a comment around L325);
  • services/shared-node-store-pin-guard.test.ts (the REACHABLE_WITHOUT_PIN key at L112-113, and prose at L49-57 and L183-186).

Scope

1. New src/lib/constants/database-settings.ts

  • Move DATABASE_SETTINGS_NODE_ID here, with its value unchanged.

  • Give it a new doc:

    • it is the id of the per-database settings singleton that core seeds in every database;
    • it mirrors Rust's DATABASE_SETTINGS_NODE_ID;
    • the node's properties sit flat on properties;
    • the schema slug is database-settings, which is distinct from this instance id.

    Do not list individual fields: ADR-083 decides which ones stay in core.

  • Re-export it from src/lib/constants/index.ts.

2. New src/lib/plugins/pro-sync-variant.svelte.ts

  • Move these verbatim, with their doc comments:
    • ProSyncVariant, from ui-extensions.ts;
    • DatabaseSettings, activeDatabaseSettings(), resolveProSyncVariant() and isProSyncActive(), from ui-extensions.svelte.ts.
  • Imports: proSync, labsFlags and SharedNodeStore, plus DATABASE_SETTINGS_NODE_ID from $lib/constants/database-settings.
  • Add a header saying:
    • this is the variant state machine of the built-in Pro extension (pro-plugin.ts);
    • it is not part of the extension API;
    • it leaves core with the Pro UI (ADR-081, ADR-082 §2.3).
  • No logic change.

3. src/lib/plugins/ui-extensions.ts

4. src/lib/plugins/ui-extensions.svelte.ts

  • Delete the moved code, and the imports that only that code used.
  • Import resolveProSyncVariant from ./pro-sync-variant.svelte for the unchanged getActive* filters.
  • Keep import './pro-plugin';.
  • In the module doc (L1-18), say that the variant machine lives in pro-sync-variant.svelte.ts.

5. Importers in src/lib

  • membership.svelte.ts, account-settings.svelte and collaboration-locked.svelte: import from $lib/plugins/pro-sync-variant.svelte.
  • database.svelte.ts: import DATABASE_SETTINGS_NODE_ID from $lib/constants/database-settings, and point the DATABASE_SETTINGS_PIN_OWNER doc at pro-sync-variant.svelte.ts.
  • pro-sync.svelte.ts and pro-plugin.ts: fix the doc references.

6. Tests

  • Rename the Pro test file: git mv src/tests/plugins/ui-extensions.test.ts src/tests/plugins/pro-sync-variant.test.ts.
  • Update the imports in every test file listed under Context.
  • membership.test.ts: retarget vi.mock('$lib/plugins/ui-extensions.svelte', …) to vi.mock('$lib/plugins/pro-sync-variant.svelte', …). Without this, the real variant machine loads, and the roster tests stop controlling isPro.
  • shared-node-store-pin-guard.test.ts: move the REACHABLE_WITHOUT_PIN key from lib/plugins/ui-extensions.svelte.ts to lib/plugins/pro-sync-variant.svelte.ts, because the getNode(DATABASE_SETTINGS_NODE_ID) read moves there. Update the prose that names the reading file.

7. Pro-boundary ratchet (#3299)

  • Run bun run scripts/check-pro-boundary.ts and paste the printed BASELINES.
  • In the PR description, declare the relocation raise under Add the Pro-boundary ratchet check and the CLAUDE.md Pro/sync placement rule #3299's relocation rule:
    • proNamedFiles rises by 2 (from 16 to 18 at af8ddb61): the two new pro-sync-variant.* files.
    • Attribute each line-marker increase to a new import line, or to a renamed path string of the moved module. Examples: the resolveProSyncVariant import in ui-extensions.svelte.ts, and the new pin-guard key.
  • Lower every marker this change reduces, such as cloudBindState, which the rewritten DATABASE_SETTINGS_NODE_ID doc lowers.

Out of scope

Steps

  1. Start up as core's CLAUDE.md describes:
    • on the primary checkout, run git status and git pull origin main;
    • enter a worktree named issue-<N>-pro-variant-move;
    • run bun install;
    • self-assign at pickup with bun run gh:assign <N> @me, never when filing.
  2. Create the constants module, and update its importers.
  3. Create pro-sync-variant.svelte.ts by cut and paste. Update its importers and the doc references.
  4. git mv the test file, and update the imports in every listed test.
  5. Update the pin-guard key and prose.
  6. Run the ratchet and paste BASELINES.
  7. Run the verification below, then quality:fix. Commit, push and open the PR.

Acceptance criteria

Generic files:

  • ui-extensions.svelte.ts no longer contains proSync, labsFlags, SharedNodeStore, activeDatabaseSettings or DATABASE_SETTINGS_NODE_ID. Its only remaining Pro references are the resolveProSyncVariant import and import './pro-plugin', and later sub-issues remove both.
  • ui-extensions.ts defines neither DATABASE_SETTINGS_NODE_ID nor ProSyncVariant.
  • grep -rn DATABASE_SETTINGS_NODE_ID packages/desktop-app/src | grep plugins/ui-extensions returns nothing.

It is a pure move:

  • git diff -M --stat origin/main shows the test file as a rename.
  • git diff --color-moved origin/main shows the moved functions unchanged.

Tests and checks:

  • Every test passes with no expectation changed: bun run test:changed and bun run --cwd packages/desktop-app test:free-users.
  • bun run --cwd packages/desktop-app quality:fix leaves eslint, the design-token check and svelte-check clean.
  • bun run scripts/check-pro-boundary.ts exits 0 and BASELINES equal its printed counts. Reduced markers are lowered, and the PR description declares the relocation raise.

Tests and verification

Nothing about behaviour changes, so there are no new tests. The moved tests, passing unchanged, are the proof.

bun run test:changed
bun run --cwd packages/desktop-app test src/tests/plugins src/tests/stores src/tests/services/shared-node-store-pin-guard.test.ts
bun run --cwd packages/desktop-app test:free-users
bun run --cwd packages/desktop-app quality:fix
bun run scripts/check-pro-boundary.ts

Dependencies

Risks and rollback

  • A stale vi.mock path silently loads the real module instead of the mock. The membership.test.ts retarget covers the one known case, and bun run test catches any others.
  • Import graph. The new module imports exactly the stores that ui-extensions.svelte.ts imported, so the module graph and evaluation order do not change.
  • Rollback. Revert the PR. It changes no data, no schema and no Rust code.

Plan key: C3.1a (pro-boundary DAG).

🤖 Generated with Claude Code

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