Repository navigation
Implement DatabaseSettingsNode (database-settings schema + behavior) - #1573
Conversation
Introduce the database-settings singleton that carries database-level configuration. Per ADR-037, sync_enabled (user intent) and auth_status (system-managed cloud bind state) move onto this node, and tenant role moves onto a has_role edge (PersonNode -> DatabaseSettingsNode) rather than living on PersonNode. - Add the database-settings core SchemaNode with a Core-protected boolean sync_enabled (default false) and Core-protected enum auth_status (local/connected, default local). - Implement DatabaseSettingsNodeBehavior (validates auth_status enum and boolean sync_enabled, no children, no markdown, not embeddable) and register it in NodeBehaviorRegistry. - Register has_role as a universal built-in relationship type. - Reserve a distinct instance id (database-settings-singleton) so the instance never collides with the schema node's slug id, and make create_node idempotent for database-settings (second create is a no-op returning the existing id). - Seed the singleton and its owner has_role edge (role owner, status active) to the local PersonNode at service construction, after the local person seed. Idempotent across reopen. - Add get_relationship_record to read a single edge with its properties. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
APPROVE — head Verified good:
Should-fix / verify:
Cross-layer flag (not a defect in this PR — it's correctly phased): ADR-037 moves Note (pre-existing, not this PR): Merge note: per the core policy this is review #1 (of the required multiple) — I'm not treating it as merge-ready on this pass. If you push the should-fixes, the new SHA triggers my re-review (the second pass); if it stays as-is, it still needs a second confirming review before it's pulled to merge. CI is green (both gates). |
Summary
Implements
DatabaseSettingsNodeas a core node type: thedatabase-settingsschema entry,DatabaseSettingsNodeBehavior, first-launch seeding of the singleton plus its ownerhas_roleedge, and registration ofhas_roleas a universal built-in relationship.Per ADR-037, database-level state is separated from identity:
sync_enabled(user intent) andauth_status(system-managed cloud bind state) move onto this singleton, and tenant authority moves onto ahas_roleedge (PersonNode -> DatabaseSettingsNode) instead of living on PersonNode.Fixed-ID collision (the key implementation detail)
Schema nodes store their id as the slug, so the
database-settingsschema node already occupies id"database-settings". To keep the instance deterministic without colliding, the singleton instance uses a distinct reserved id"database-settings-singleton". Determinism/idempotency (the intent behind the issue's "fixed ID" criterion) is preserved:create_nodetreats a seconddatabase-settingscreate as a no-op that returns the existing id.Acceptance criteria
database-settingsschema entry withsync_enabledand Core-protectedauth_status—packages/core/src/models/core_schemas.rs: CoreSchemaNodewithsync_enabled(boolean, defaultfalse, Core-protected) andauth_status(enumlocal/connected, defaultlocal, Core-protected).DatabaseSettingsNodeBehaviorimplements allNodeBehaviormethods and is registered —packages/core/src/behaviors/mod.rs:type_name,validate,can_have_children(false),supports_markdown(false),default_metadata({sync_enabled:false, auth_status:"local"}),get_embeddable_content/get_parent_contribution(None); registered inNodeBehaviorRegistry::new().validateenforcesauth_statusenum and booleansync_enabled— rejectsauth_statusoutside{local, connected}and non-booleansync_enabledwithInvalidProperties(same shape asAiChatNodeBehavior).can_have_children()->false— implemented.database-settings-singleton;create_nodereturns the existing id on a duplicatedatabase-settingscreate (packages/core/src/services/node_service/crud.rs).sync_enabled:false,auth_status:local, and ownerhas_roleedge to local PersonNode —seed_database_settings_if_neededinpackages/core/src/services/node_service/mod.rs, invoked fromNodeService::new()after the local person seed; owner edge carries{role:"owner", status:"active"}. Idempotent across reopen.has_rolerelationship type registered — added to the built-inmatches!set increate_relationshipand to the built-in-relationships error string (packages/core/src/services/node_service/relationship.rs).auth_status, non-boolsync_enabled, capabilities, defaults, embeddable), and async NodeService tests (seed yields exactly one node with correct defaults + exactly one ownerhas_roleedge; second create is a no-op; reopen does not reseed).cargo clippy; no lint suppression — clippy clean with-D warnings; no#[allow]/ suppression added.Out of scope (not implemented)
Pro sync writes (
auth_status=connected,sync_enabled=true), RLS enforcement,auth_identitiesbind, sync-toggle UI, and last-admin invariant enforcement.Checks
cargo test -p nodespace-core -- --test-threads=2— 985 lib + all integration + 125 doctests pass, 0 failedcargo clippy -p nodespace-core --all-targets -- -D warnings— cleancargo fmt --all --check— cleanNote: ADR-037 documents the data-model revision this implements; a docs update lives in the nodespace-docs repo (out of scope for this code PR).
Co-Authored-By: Claude Opus 4.8 [email protected]