Repository navigation
Closed
Labels
pro-boundaryPro/core boundary: Pro code moves to nodespace-sync (ADR-081..085)
Description
Summary
Carry out ADR-083 §1 (proposed; decision 1-A):
- Keys stay, owned by Pro.
sync_enabled,auth_status,bound_tenant_schemaandbound_tenant_collectionremain in thedatabase-settingssingleton's bucket under their current names. - Core lets go of them. It no longer declares, seeds, validates or reads them, and its six typed accessors are deleted.
- Core exposes one generic accessor pair:
NodeService::database_settings()and a publicNodeService::merge_database_settings(entries). The merge rejects keys that core itself declares. - New extension state uses
plugin:keys (ADR-083 §5, ADR-063).
The singleton itself stays in core, unchanged: its id, its seeding, the owner has_role edge from the local PersonNode, and get_local_person.
Context (lines at af8ddb61 are hints)
Where the Pro fields are handled today:
- Schema: the
database-settingsSchemaNodeinpackages/core/src/models/core_schemas.rs.- Comment ~1555-1559; fields ~1568-1664.
- Module doc, line 21: "Singleton container for database-level config (sync state, roles)".
- Test:
test_database_settings_schema_has_fields(~1976-2021).
- Behavior:
DatabaseSettingsNodeBehaviorinpackages/core/src/behaviors/mod.rs(~2317-2396).validatechecks the four keys at the top level of properties, but they are stored in the bucket, so the checks never fire on stored data.default_metadatanames two of the keys. The trait default returns{}.validatehas no trait default, so the method must stay.
- Seeding:
seed_database_settings_if_neededinpackages/core/src/services/node_service/mod.rs, doc ~1646-1652, seeded JSON ~1704-1709. - Accessors: in
node_service/mod.rs.get_bound_tenant(~2112-2139) andset_bound_tenant(~2141-2194).- The private
merge_database_settings(&self, fields: &[(&str, Value)])(~2196-2242). set_sync_enabled,set_auth_status,get_sync_enabledandget_auth_status(~2244-2311).- Core calls none of these outside tests.
nodespaced-pro(sync17f9557) calls all six public ones.
Why this lands core-first with no gate (ADR-083 §7 item 3). The Pro daemon builds against pinned core 680c35d8. At its next pin bump it switches over:
- it reads through
database_settings()and writes throughmerge_database_settings; - it takes over the defaults today's getters apply: an absent or
nullsync_enabledmeansfalse, an absent ornullauth_statusmeanslocal, and a missing or empty binding means unbound.
Why this does not wait for #3333:
- The in-core Pro UI reads the raw keys from the node store (
plugins/ui-extensions.svelte.ts:settings?.auth_status === 'connected',settings?.sync_enabled === true). An absent key behaves exactly like today's seeded default. - The pinned Pro daemon still seeds the old values anyway.
Existing databases (no migration):
- The keys stay in the bucket, inert to core.
- The stored
database-settingsschema node keeps declaring all four fields until the database is reset, becauseseed_core_schemas_if_needednever rewrites a stored core schema. It keeps validatingsync_enabled(boolean) andauth_status(localorconnected). - That is why the new guard reads the compiled definition, not the stored one.
Tests that name the fields today:
- In
node_service/mod.rs:test_seed_database_settings_singleton_with_owner_edge(asserts at ~9291-9292);test_get_set_bound_tenant_roundtrip(~10347-10387);test_set_sync_enabled_and_auth_status_roundtrip(~10389-10450);test_create_second_database_settings_is_noop(~10452-10480).
- In
behaviors/mod.rs: thedatabase_settings_*tests (~5653-5735). - In
packages/core/tests/it/person_seed_test.rs: module-doc bullet 2 (line 7) and theauth_statusabsence assertion (~31-39).
Scope
core_schemas.rs: the module doc line, the schema comment, the fields and the schema test.behaviors/mod.rs:- the
DatabaseSettingsNodeBehaviordoc,validate, and thedefault_metadataoverride; - the tests
database_settings_valid_defaults_pass,database_settings_valid_auth_status_values_pass,database_settings_invalid_auth_status_fails,database_settings_non_bool_sync_enabled_fails,database_settings_default_metadataanddatabase_settings_is_not_embeddable.
- the
node_service/mod.rs: the seed doc and seeded JSON, the seven accessors, and the four tests listed above.- New:
packages/core/tests/it/database_settings_extension_keys_test.rs, registered intests/it/main.rs. person_seed_test.rs: line 7 and ~31-39.
Out of scope
- The singleton,
DATABASE_SETTINGS_NODE_ID, the owner edge andget_local_person. - Docs that Reword core data-model and identity docs that cite Pro, Supabase, RLS or tenants #3365 rewords:
- the
seed_local_person_if_neededdoc note "auth_statuslives on DatabaseSettingsNode" (~1635); - the
PersonNodeBehaviordoc (~2265-2269); - the
get_local_persondoc; person_seed_test.rslines 3-5.
- the
- The frontend Pro readers (Move the Pro sync and collaboration UI out of core #3333).
- The registry mirror (Carry opaque registry extensions through DatabaseInfo and drop the tray's synced label #3341, Replace the registry's tenant-binding fields with extension keys and set_extensions #3342).
- Keeping the settings node out of sync, which is a sync follow-up.
- Recording the five Pro-owned bare names (the four keys on
database-settings, plusauth_statusonperson) in the Schema management doc. That belongs to the ADR-083 docs PR, not to core code.
Steps
- Start up. Follow core
CLAUDE.md's startup sequence:EnterWorktree({name: "issue-<N>-settings-extension-keys"});bun install;- the
bun run testbaseline; gh:assign, thengh:status.
- Schema.
- Set the
database-settingsSchemaNodetofields: vec![]. - Rewrite the schema comment: this is the singleton anchor for database-level configuration and for the owner
has_roleedge. Core declares no fields on it, and extensions keep namespaced keys in its bucket (ADR-083, ADR-063). - Change the module doc line to "Singleton anchor for database-level configuration and the owner role edge".
- Replace the schema test with
test_database_settings_schema_declares_no_fields. It asserts the schema exists, hasis_coreset, and has emptyfields.
- Set the
- Behavior.
- Rewrite the doc: the singleton anchor for database-level configuration and the owner
has_roleedge (ADR-037). Core declares no fields on it; extensions store their own keys throughNodeService::merge_database_settings. - Make
validatereturnOk(()). Keep no-children, no-markdown and not-embedded. - Delete the
default_metadataoverride. - Delete the five tests that check the Pro keys and their defaults.
- Change the
database_settings_is_not_embeddablefixture tojson!({}). - Add
database_settings_accepts_namespaced_extension_keys:{"plugin:example": 1}validates.
- Rewrite the doc: the singleton anchor for database-level configuration and the owner
- Seed.
- Seed the singleton with no properties (
json!({})). - Rewrite the seed doc: it seeds the singleton and one owner
has_roleedge. - Leave the owner-edge repair logic untouched.
- Seed the singleton with no properties (
- Accessors.
- Delete
get_bound_tenant,set_bound_tenant,set_sync_enabled,set_auth_status,get_sync_enabledandget_auth_status. - Add
pub async fn database_settings(&self) -> Result<serde_json::Map<String, serde_json::Value>, NodeServiceError>:- it returns the singleton's
database-settingsbucket, keys as stored; - it returns an empty map when the singleton or the bucket is absent;
- it returns
InitializationErrorwhen the bucket is not a JSON object, as the merge does.
- it returns the singleton's
- Make
merge_database_settings(&self, entries: &[(&str, serde_json::Value)])pub. Its doc names no specific key and states:- it merges into the bucket as one versioned
update_node, keeping every other key; - a JSON
nullis stored asnull, and no key is ever deleted; - a missing singleton returns
InitializationError; - a concurrent change returns the ordinary
VersionConflict, and the caller re-reads and retries; - new extension keys use the
plugin:prefix (ADR-063).
- it merges into the bucket as one versioned
- Guard. Before writing, reject any entry whose key the compiled
database-settingsdefinition declares (get_core_schemas()). ReturnNodeServiceError::InvalidUpdateand write nothing.- Put the check in a pure helper, e.g.
fn first_core_declared_key<'a>(declared: &[String], entries: &'a [(&'a str, Value)]) -> Option<&'a str>, so it can be tested with a synthetic declared list. - The compiled list is empty today, so nothing is rejected yet.
- Add a comment explaining why the guard must not read the stored schema: existing databases still declare the Pro keys there, and the guard would then reject the Pro daemon's own writes.
- Put the check in a pure helper, e.g.
- Delete
- Unit tests (`node_service/mod.rs):
test_seed_database_settings_singleton_with_owner_edge: assert thatdatabase_settings()is empty.- Delete
test_get_set_bound_tenant_roundtripandtest_set_sync_enabled_and_auth_status_roundtrip. This also removes the two uses of the legacy root idc0000000-…0001that Remove the tenant-binding root fallback from the collections tree #3330 mentions. - Add
test_merge_database_settings_keeps_other_keys: mergeplugin:a, thenplugin:b, thenplugin:a = null.database_settings()then shows both keys, withplugin:astored asnull. - Add
test_first_core_declared_key_rejects_declared_keys, which exercises the helper with a synthetic declared list. test_create_second_database_settings_is_noop: create the duplicate with{"plugin:marker": true}, and assert that the singleton's properties equal a snapshot taken before the second create.
- Legacy-shape integration test (the new module). It uses generic key names on purpose, so core keeps no Pro key names; the mechanics are identical.
- Setup, on a fresh temp database, before
NodeService::new:- Build a
database-settingsSchemaNodeshaped like an older build's declaration, with these fields:legacy_flag: boolean, defaultfalse;legacy_state: enum, required, default"a", core valuesaandb;legacy_ref_aandlegacy_ref_b: optional strings.
- Insert it with
SqliteStore::create_node(schema.into_node(), None, None). - Insert the singleton (
database-settings-singleton) with those four values in its bucket.
- Build a
- Assert:
NodeService::newsucceeds, andget_local_person()resolves, because the owner edge is repaired;database_settings()returns the four values unchanged;merge_database_settings(&[("plugin:example", json!(1))])succeeds and leaves the four values untouched;- merging
legacy_state = "z"is refused, because the stored declaration still validates (this documents the ADR-083 §1 caveat); - the stored schema node still has its four fields.
- Setup, on a fresh temp database, before
person_seed_test.rs.- Replace bullet 2 with "The seeded person carries no
personproperties until the user fills them in". - Replace the
auth_statusabsence assertion (~31-39) with an assertion that the seeded person'spersonbucket is absent or empty. This is stronger than the old check, and names no Pro key.
- Replace bullet 2 with "The seeded person carries no
- Ratchet. Run
bun run scripts/check-pro-boundary.tsand setBASELINESto the printed counts. Expect large drops incloudBindStateandtenantWording, and smaller ones incloudWordingandproWording. - Finish.
bun run test:changed, thenbun run quality:fix, then commit.- Push to
issue-<N>-settings-extension-keys. gh pr create --repo NodeSpaceAI/nodespace-core --base main --head issue-<N>-settings-extension-keys, thengh:status "In Review".- After approval, run
bun run merge <PR#>in the background.
Acceptance criteria
-
git grep -n -E 'bound_?[tT]enant|get_sync_enabled|set_sync_enabled|get_auth_status|set_auth_status' -- packages/coreprints nothing. -
git grep -n -E 'sync_?[eE]nabled|auth_?[sS]tatus' -- packages/coreprints only the two doc lines Reword core data-model and identity docs that cite Pro, Supabase, RLS or tenants #3365 owns (theseed_local_person_if_needednote and thePersonNodeBehaviordoc), and nothing once Reword core data-model and identity docs that cite Pro, Supabase, RLS or tenants #3365 has merged. - A fresh database seeds the singleton and its owner edge, and
database_settings()returns an empty map. - A legacy-shaped database opens. Core neither reads nor rewrites its values, and extension keys merge alongside them.
-
merge_database_settingsis public, keeps sibling keys, and rejects core-declared keys (proven by the helper test). -
bun run scripts/check-pro-boundary.tsexits 0, andBASELINESequals its printed counts. - Core builds and all tests pass. The free app's onboarding, local person and Settings → Databases are unchanged.
Tests and verification
bun run test:changed.tools/bin/cargo-nextest nextest run -p nodespace-core --lib database_settings.tools/bin/cargo-nextest nextest run -p nodespace-core --test it database_settings_extension_keys_test::.tools/bin/cargo-nextest nextest run -p nodespace-core --test it person_seed_test::cargo clippy -p nodespace-core --all-targets -- -D warnings -D clippy::unused-async- Mutation-check each new test:
- make the guard a no-op, and the helper test fails;
- stop preserving sibling keys, and the merge test fails.
- Manual check. Use an isolated
NODESPACE_HOMEholding a database created by the current release. The dev app opens it with no incompatible-database screen, and the onboarding identity still saves.
Dependencies
- NodeSpaceAI/nodespace-docs#92 (ADR-083) (ADR-083, proposed): decision 1-A.
- Add the Pro-boundary ratchet check and the CLAUDE.md Pro/sync placement rule #3299: the ratchet.
- No gate (ADR-083 §7 item 3).
- Sync note (not filed yet): at its next pin bump, sync replaces the six accessor calls, and takes over the defaults and the settings-node sync exclusion.
Risks and rollback
- Sync's pin bump fails to compile until it switches to the accessor pair. That failure is the intended signal.
- Existing databases keep validating two Pro keys through their stored schema. The Pro daemon must keep to the values it writes today. A new state needs a new
plugin:key (ADR-083 §1). - Rollback: revert the PR. Databases created while the change was live lack the seeded defaults, but the restored getters already treat absent values as
falseandlocal.
Plan key: C7.4 (pro-boundary DAG).
🤖 Generated with Claude Code
Metadata
Metadata
Assignees
Labels
pro-boundaryPro/core boundary: Pro code moves to nodespace-sync (ADR-081..085)
Activity
mstomar125 commentedon Sep 30, 2026
Completed in #3378 (merged). Auto-close did not fire; closing manually.