Skip to content

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

Merged
mstomar125 merged 1 commit into
mainfrom
issue-3309-pro-variant-move
Sep 30, 2026
Merged

mstomar125 merged 1 commit into
mainfrom
issue-3309-pro-variant-move

Conversation

@mstomar125

@mstomar125 mstomar125 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Closes #3309

Summary

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 new neutral module, src/lib/constants/database-settings.ts (re-exported from constants/index.ts), with a new doc: the id of the per-database settings singleton that core seeds in every database, mirroring Rust's constant, properties flat on properties, schema slug database-settings distinct from the instance id.
  • The Pro variant machine moves verbatim into src/lib/plugins/pro-sync-variant.svelte.ts (ProSyncVariant, DatabaseSettings, activeDatabaseSettings(), resolveProSyncVariant(), isProSyncActive()), with a header saying it is the variant machine of the built-in Pro extension, not part of the extension API, and leaves core with the Pro UI.
  • ui-extensions.ts and ui-extensions.svelte.ts lose the moved code and the imports only it used. ui-extensions.ts keeps a type-only import of ProSyncVariant so the variant fields still type-check (Adopt ADR-082's contribution contract: ids, when() predicates, keyed and isolated outlets #3310 deletes it). ui-extensions.svelte.ts keeps import './pro-plugin' and imports resolveProSyncVariant for the unchanged getActive* filters.
  • Importers, doc references, vi.mock paths and the pin-guard exemption key follow the moved code.
  • src/tests/plugins/ui-extensions.test.ts is renamed with git mv to pro-sync-variant.test.ts. Only its imports and the first header line change; no expectation changed.

Pure-move evidence

  • git diff -M --stat origin/main shows the test file as a rename (ui-extensions.test.ts => pro-sync-variant.test.ts).
  • The moved blocks are byte-identical to the originals (checked with diff on origin/main:ui-extensions.svelte.ts L34-106 and ui-extensions.ts L41-47 against the new file).
  • The only edits outside the moved code are import paths, doc references, and the new file/constant headers.

Deviations from the issue text

  • Module doc of ui-extensions.ts. It said the variant reactivity "lives in the sibling ui-extensions.svelte.ts wrapper", which is no longer true for resolution. I reworded that one sentence in place ("filters contributions by the resolved variant") instead of adding a new line pointing at the moved file, so it adds no marker line.
  • Header of the new file. It says what the issue asks for; I did not repeat the proSync.tier axis description there, to avoid adding a marker line that is not a relocation.

Pro-boundary ratchet (#3299)

scripts/check-pro-boundary.ts is not on origin/main yet (it is in PR #3376, the ratchet PR), so BASELINES cannot be lowered or raised in this PR. I ran the committed #3299 script (99caa1da, based on the same af8ddb61) overlaid on this branch in a throwaway checkout, with baselines taken from that script at af8ddb61. It prints:

marker af8ddb6 baseline this change delta
proSyncModule 360 370 +10
proWording 314 316 +2
proNamedFiles 16 18 +2
cloudBindState 322 321 -1
every other marker unchanged unchanged 0

Relocation raise, class 3 ("a planned move of Pro code already in core, by a Pro-boundary migration issue, that adds no behaviour"). #3332 deletes the moved code (pro-sync-variant.svelte.ts, its test, and the Pro UI) whole.

  • proNamedFiles +2: the two new pro-sync-variant.* files (the old ui-extensions.test.ts was not Pro-named).
  • proSyncModule +10 (net; the itemized lines below are gross, because some rewritten lines already matched the marker before the move, such as the resolveProSyncVariant import lines, and net out): each increase is a new import line or a renamed path string of the moved module: the resolveProSyncVariant import and the module-doc line in ui-extensions.svelte.ts, the type-only import in ui-extensions.ts, the pro-plugin.ts and database.svelte.ts doc references, the pro-sync-variant.test.ts path in two test comments, the vi.mock path in membership.test.ts, the eviction test comment, and the pin-guard key plus its three prose lines.
  • proWording +2: the two "Pro" lines in the new file's mandated header ("built-in Pro extension", "Pro UI"). The moved ProSyncVariant doc lines move 1:1 out of ui-extensions.ts.
  • cloudBindState -1: the rewritten DATABASE_SETTINGS_NODE_ID doc no longer lists sync_enabled / auth_status.

Merge-order note for the coordinator. If #3376 lands first, this PR must be rebased and its BASELINES set to the table above (proSyncModule: 370, proWording: 316, proNamedFiles: 18, cloudBindState: 321, others unchanged from whatever main holds) before it can pass the gate. If this PR lands first, #3376's baselines need the same four adjustments.

Tests

No new tests: nothing about behaviour changes, so the moved tests passing unchanged are the proof.

  • bun run test:changed passed (frontend Happy-DOM + browser tiers; rust/skill/scripts skipped for a frontend-only diff).
  • bun run --cwd packages/desktop-app test src/tests/plugins src/tests/stores src/tests/services/shared-node-store-pin-guard.test.ts src/tests/services/shared-node-store-eviction.test.ts src/tests/components/settings: 43 files, 796 tests passed.
  • bun run --cwd packages/desktop-app test:free-users: 9/9 passed.
  • bun run --cwd packages/desktop-app quality:fix: eslint, design-token check and svelte-check clean (0 errors, 0 warnings).

Mutation checks of the two retargets the issue names as risks:

  • Pin-guard key reverted to lib/plugins/ui-extensions.svelte.ts: the guard fails, naming lib/plugins/pro-sync-variant.svelte.ts as an unpinned, unexempted reader.
  • membership.test.ts vi.mock reverted to $lib/plugins/ui-extensions.svelte: the real variant machine loads and the roster tests stop controlling isPro (10+ MembershipStore tests fail).

Both were restored; the tests pass again.

Rollback

Revert the PR. No data, schema or Rust change.

🤖 Generated with Claude Code

@mstomar125

Copy link
Copy Markdown
Contributor Author

Pragmatic Code Review (medium) - Initial Review

Review Type: Initial Review

Requirements Check:

  • ✅ ui-extensions.svelte.ts no longer contains proSync, labsFlags, SharedNodeStore, activeDatabaseSettings or DATABASE_SETTINGS_NODE_ID (grep on the file returns nothing). Remaining Pro references are only the resolveProSyncVariant import and import './pro-plugin', as specified.
  • ✅ ui-extensions.ts defines neither DATABASE_SETTINGS_NODE_ID nor ProSyncVariant. It has the required import type { ProSyncVariant } from './pro-sync-variant.svelte' (type-only, erased at runtime). The only leftover mention is the pre-existing module-doc prose on proSync.tier (L11), which is not a definition and is Adopt ADR-082's contribution contract: ids, when() predicates, keyed and isolated outlets #3310's to rewrite.
  • ✅ grep -rn DATABASE_SETTINGS_NODE_ID packages/desktop-app/src | grep plugins/ui-extensions returns nothing.
  • ✅ Test file shows as a rename (git diff -M: 97% similarity, ui-extensions.test.ts => pro-sync-variant.test.ts). The only edits in it are the header line, the import block and the DATABASE_SETTINGS_NODE_ID import path. No it/expect line changed.
  • ✅ Moved code is verbatim. I diffed the new file against origin/main directly: ui-extensions.svelte.ts L34-106 (DatabaseSettings, activeDatabaseSettings, resolveProSyncVariant, isProSyncActive, including every inline comment) and ui-extensions.ts L41-47 (ProSyncVariant + doc) are byte-identical. DatabaseSettings is still a non-exported interface; resolveProSyncVariant, activeDatabaseSettings and isProSyncActive keep their original export status. No dropped comments, no logic change.
  • ✅ Tests: I re-ran the six most relevant files on this branch (pro-sync-variant, membership, shared-node-store-pin-guard, free-user-guardrail = test:free-users, account-settings, pro-sync-settings-refresh): 6 files / 66 tests pass. eslint on the touched lib/test files is clean. I did not re-run svelte-check or the full suite (the PR reports both green).
  • ✅ Ratchet (partly applicable, as agreed): I reproduced the PR's table by running Add the Pro-boundary ratchet check and the CLAUDE.md Pro/sync placement rule #3299's script (99caa1da) over a scratch export of af8ddb61 and of this branch's HEAD. Base counts equal the baselines; HEAD gives proSyncModule 370, proWording 316, proNamedFiles 18, cloudBindState 321, everything else unchanged. That is exactly +10 / +2 / +2 / -1 as the PR body claims. The hit-list diff confirms the two proNamedFiles additions are the two new pro-sync-variant.* files and that the cloudBindState drop is the rewritten constant doc. Merge-order note is correct (origin/main is still af8ddb61).

Code Review Findings:

No 🔴 Critical or 🟡 Important findings. What I checked and found sound:

  • Dangling references: none. A repo-wide grep (excluding node_modules/target/build/coverage/.claude/.git) for ui-extensions and for all five moved symbols finds no importer, vi.mock/vi.doMock/vi.importActual, dynamic import(), script, workflow or prose that still points at the old location. The remaining ui-extensions.svelte imports (app-shell.svelte, collection-node-viewer.svelte, the guardrail test and the renamed test) import getActive*, which really do still live there. src-tauri/lib.rs:618 mentions pro-sync.svelte.ts (the store), which is unaffected.
  • Module graph / reactivity: pro-sync-variant.svelte.ts keeps the .svelte.ts suffix. It imports exactly what the old wrapper imported (proSync, labsFlags, SharedNodeStore) plus the constant. There is no cycle: it imports nothing from ui-extensions*, and ui-extensions.ts only has an import type edge to it. In ui-extensions.svelte.ts the ./pro-plugin side-effect import is still first, and the store imports now load through pro-sync-variant.svelte; the registry module has no dependency on those stores, so evaluation order is not materially different. database.svelte.ts importing DATABASE_SETTINGS_NODE_ID from $lib/constants/database-settings is correct and strictly better: it no longer depends on a Pro registry file for a core constant, and the value 'database-settings-singleton' is unchanged and still matches Rust (node_service/mod.rs:60).
  • Test wiring: the membership.test.ts vi.mock now targets the module membership.svelte.ts actually imports, and the PR's mutation check (revert makes the roster tests lose control of isPro) is credible. The pin-guard REACHABLE_WITHOUT_PIN key moved to lib/plugins/pro-sync-variant.svelte.ts, which is where getNode(DATABASE_SETTINGS_NODE_ID) now lives; the second pin-guard test (the owning refreshDatabaseSettings() pin) is unaffected. Header and prose updates in the pin-guard, eviction, account-settings, settings-refresh and database.svelte.ts comments are all accurate.
  • CLAUDE.md compliance: the added lines contain no #NNNN issue references (only ADR references), no lint suppression, no any, no compat shims.

🟢 Suggestion (informational, no action needed): membership.svelte.ts, account-settings.svelte and collaboration-locked.svelte used to pull in ./pro-plugin (and so register the built-in Pro extension) transitively, because they imported ui-extensions.svelte. They now import pro-sync-variant.svelte and no longer do. This is harmless today: uiExtensionRegistry is only read through ui-extensions.svelte (app-shell.svelte, collection-node-viewer.svelte), and those files still import it, so registration still happens before any read. It does make the issue's risk line ("the module graph and evaluation order do not change") slightly imprecise. The principle: a side-effect registration should be reachable from the code that reads the registry, which is now exactly the case. #3316 removing import './pro-plugin' will make this moot.

🟢 Nit (📁 packages/desktop-app/src/lib/plugins/pro-sync-variant.svelte.ts:1-16): the new header says the variant comes from "two independent signals" and that "both source reads are reactive", but resolveProSyncVariant() first checks a third input, labsFlags.syncEnabled. The function's own doc covers it, the sentence was carried over verbatim, and the PR body explains that adding header lines would add marker lines. The file is deleted by #3332, so I would leave it.

🟢 Nit (PR body only): the itemized proSyncModule attribution lists 13 added lines against a net +10, because some rewritten lines already matched the marker before the move (for example the resolveProSyncVariant import lines) and net out. The totals are exact, so no change is needed. Worth remembering when the baselines are set at merge time.

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: APPROVE (posted as a comment, GitHub blocks self-approval). Full findings in the review comment above.

@mstomar125

Copy link
Copy Markdown
Contributor Author

Address Review - PR #3374

The pragmatic review (medium, initial) returned APPROVE with no critical or important findings. Triage of what it did raise:

Addressed: 1

Skipped: 2 (informational or nit, no code change)

  • Informational: membership.svelte.ts, account-settings.svelte and collaboration-locked.svelte no longer pull in ./pro-plugin transitively. Skipped because registration is still reachable from every registry reader: app-shell.svelte and collection-node-viewer.svelte import ui-extensions.svelte, which keeps import './pro-plugin', so it runs before any read. It only makes the issue's "evaluation order does not change" risk line slightly imprecise. Revisit if a reader of uiExtensionRegistry is ever added that does not go through ui-extensions.svelte; the import removal in the later Pro-registration cleanup makes it moot.
  • Nit: the new file's header says "two independent signals" while resolveProSyncVariant() checks the Labs toggle first. Skipped because the sentence is carried over from the original doc, the function's own doc describes the gate, and rewording risks adding Pro-marker lines to a change whose ratchet delta is deliberately kept to the mandated header plus renamed paths. The file is deleted whole with the Pro UI.

Verification state (unchanged, nothing pushed since review): head 3eb39e19, origin/main still af8ddb61, branch not behind. test:changed passed, 43 files / 796 tests pass on the targeted run, test:free-users 9/9, quality:fix clean, both retarget mutations fail when reverted.

Re-Review Decision

Decision: NO RE-REVIEW NEEDED

Rationale: No code, test or comment changed after the review; the only change is the PR description text. The review was already an APPROVE.

Merge-order note (also in the PR body): the ratchet is not on main yet, so BASELINES was not edited. Whichever of #3376 and this PR lands second needs the four baseline adjustments in the PR body (proSyncModule +10, proWording +2, proNamedFiles +2, cloudBindState -1).

… generic registry files

DATABASE_SETTINGS_NODE_ID moves to a neutral constants module, since core's
database store uses it and it is not a Pro concept. The Pro variant machine
(ProSyncVariant, DatabaseSettings, activeDatabaseSettings,
resolveProSyncVariant, isProSyncActive) moves verbatim into
pro-sync-variant.svelte.ts, which belongs to the built-in Pro extension.

The Pro test file is renamed to pro-sync-variant.test.ts. Importers, vi.mock
paths and the pin-guard exemption key follow the moved code. No logic or
expectation changes.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
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.

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

1 participant