Repository navigation
Implement PersonNodeBehavior - #1401
Conversation
PersonNode is pure identity: name (optional) and email (optional, format-validated when present). role and auth_status are explicitly out of scope — they live on the has_role edge to DatabaseSettingsNode. - Add person SchemaNode to core_schemas.rs (name, email, both optional) - Add PersonNodeBehavior: validate email format, compute_display_name falls back to email then "Unknown", can_have_children = false - Register PersonNodeBehavior in NodeBehaviorRegistry::new() - 14 unit tests: schema present, behavior registered, email validation, empty/absent name valid, compute_content with/without name Co-Authored-By: Claude <[email protected]>
Registers personNodePlugin in core-plugins.ts with a /person slash command, PersonNode inline component, and PersonSchemaForm for editing name and email. No custom viewer — BaseNodeViewer handles it. Updates plugin count and slash command count tests (+1 each). Co-Authored-By: Claude <[email protected]>
Code Review — PR #1401: Implement PersonNodeBehaviorReview Type: Initial Review Requirements Check (Issue #133)
Overall AssessmentThis is a clean, well-scoped implementation that correctly delivers the PersonNode identity primitive. The Rust backend is particularly well done: namespaced property access ( Findings[Improvement] Doc comment misplacement attaches NodeBehaviorRegistry thread-safety docs to PersonNodeBehavior📁 The The fix is to insert a blank non-doc line between the NodeBehaviorRegistry docs and the PersonNodeBehavior doc: // (end of NodeBehaviorRegistry thread-safety doc)
/// accessed concurrently during runtime, making external synchronization unnecessary
// ← insert a blank line or a non-/// separator here
/// Built-in behavior for person nodes
///
/// Person nodes are pure identity ...
pub struct PersonNodeBehavior;Then the NodeBehaviorRegistry doc block (lines 2005–2028) needs to be moved to immediately precede Engineering principle: Rust [Improvement]
|
| Finding | Severity | File |
|---|---|---|
Thread-safety docs misattributed to PersonNodeBehavior |
[Improvement] | packages/core/src/behaviors/mod.rs:2005–2035 |
PersonNode doesn't implement NodeComponentProps interface + dead metadata prop |
[Improvement] | packages/desktop-app/src/lib/design/components/person-node.svelte:12–26 |
Wrapper <div> with no styles |
[Improvement] | packages/desktop-app/src/lib/design/components/person-node.svelte:37 |
| Comment says "person icon" but no icon exists | Nit | packages/desktop-app/src/lib/design/components/person-node.svelte:4 |
Magic string sentinel in get_embeddable_content |
Nit | packages/core/src/behaviors/mod.rs:2091–2097 |
Recommendation: REQUEST CHANGES — the NodeComponentProps interface deviation is a contract breakage that needs to be fixed before merge. The doc comment misplacement generates incorrect rustdoc. Both are straightforward to fix.
- Restore NodeBehaviorRegistry thread-safety doc block to its struct; PersonNodeBehavior now has its own clean doc comment - PersonNode component uses NodeComponentProps interface, matching all other node components; removes dead metadata prop and wrapper div Skipped: compute_display_name Option<String> refactor — the magic string coupling is confined to one struct with full test coverage; benefit does not outweigh the API churn at this stage. Co-Authored-By: Claude <[email protected]>
Review Addressed✅ Addressed (2 of 2 important findings):
⏭️ Skipped (1 nit):
|
Construct-time seeding in NodeService::new: idempotently create one person node (auth_status: "local", under properties["person"]) representing the local user when none exists, so fresh and existing databases alike carry the identity node. On Pro upgrade this node is bound to a Supabase identity (nodespace-sync#125) via a single auth_identities row keyed on the node id, not recreated. Name/email stay absent until the user fills them in. Update PersonNodeBehavior doc to reflect auth_status on the node (role/ permission still lives on the member_of relationship). Add person_seed_test covering fresh-install single-seed, the local auth_status, and idempotency. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Grafted the ADR-037 local-PersonNode seed (commit 003a328)Consolidating issue #133 onto this PR (the parallel #1399 is now closed in favor of this one — it had a backend-only behavior with a different Added here:
Why on the node (vs relationships)ADR-037 §"PersonNode Seeding & Upgrade Continuity" requires Tests
This unblocks nodespace-sync#125 (bind the seeded PersonNode → Supabase uid at sign-in) and #126 (auto-admin bootstrap). |
- test_update_schema_add_valid_title_template created a "Person" base schema, which now collides with the core `person` schema (ADR-037 #1401) — rename the test entity to "Employee". - test_integration_schema_id_generation asserted "customer-invoice" (hyphen), but normalize_schema_id joins on '_' (its dedicated unit tests confirm; the hyphenated core ids like code-block aren't generated through it) — assert "customer_invoice" and fix the stale "→ customer-profile" doc example. cargo test -p nodespace-core --lib: 954 passed, 0 failed. Co-authored-by: Mayank Tomar <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
* Implement PersonNodeBehavior and person schema (#133) PersonNode is pure identity: name (optional) and email (optional, format-validated when present). role and auth_status are explicitly out of scope — they live on the has_role edge to DatabaseSettingsNode. - Add person SchemaNode to core_schemas.rs (name, email, both optional) - Add PersonNodeBehavior: validate email format, compute_display_name falls back to email then "Unknown", can_have_children = false - Register PersonNodeBehavior in NodeBehaviorRegistry::new() - 14 unit tests: schema present, behavior registered, email validation, empty/absent name valid, compute_content with/without name Co-Authored-By: Claude <[email protected]> * Add PersonNode frontend plugin, component, and property form (#133) Registers personNodePlugin in core-plugins.ts with a /person slash command, PersonNode inline component, and PersonSchemaForm for editing name and email. No custom viewer — BaseNodeViewer handles it. Updates plugin count and slash command count tests (+1 each). Co-Authored-By: Claude <[email protected]> * Address review: fix doc comment placement and NodeComponentProps - Restore NodeBehaviorRegistry thread-safety doc block to its struct; PersonNodeBehavior now has its own clean doc comment - PersonNode component uses NodeComponentProps interface, matching all other node components; removes dead metadata prop and wrapper div Skipped: compute_display_name Option<String> refactor — the magic string coupling is confined to one struct with full test coverage; benefit does not outweigh the API churn at this stage. Co-Authored-By: Claude <[email protected]> * #133: seed one local PersonNode on every install (ADR-037) Construct-time seeding in NodeService::new: idempotently create one person node (auth_status: "local", under properties["person"]) representing the local user when none exists, so fresh and existing databases alike carry the identity node. On Pro upgrade this node is bound to a Supabase identity (nodespace-sync#125) via a single auth_identities row keyed on the node id, not recreated. Name/email stay absent until the user fills them in. Update PersonNodeBehavior doc to reflect auth_status on the node (role/ permission still lives on the member_of relationship). Add person_seed_test covering fresh-install single-seed, the local auth_status, and idempotency. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> --------- Co-authored-by: Michael Libio <[email protected]> Co-authored-by: Claude <[email protected]> Co-authored-by: Mayank Tomar <[email protected]>
- test_update_schema_add_valid_title_template created a "Person" base schema, which now collides with the core `person` schema (ADR-037 #1401) — rename the test entity to "Employee". - test_integration_schema_id_generation asserted "customer-invoice" (hyphen), but normalize_schema_id joins on '_' (its dedicated unit tests confirm; the hyphenated core ids like code-block aren't generated through it) — assert "customer_invoice" and fix the stale "→ customer-profile" doc example. cargo test -p nodespace-core --lib: 954 passed, 0 failed. Co-authored-by: Mayank Tomar <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Closes #133