Skip to content

#133: PersonNodeBehavior + person core schema (ADR-037 identity type) - #1399

Closed
mstomar125 wants to merge 2 commits into
NodeSpaceAI:mainfrom
mstomar125:issue-133-person-node-behavior
Closed

mstomar125 wants to merge 2 commits into
NodeSpaceAI:mainfrom
mstomar125:issue-133-person-node-behavior

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Implements PersonNode as a core node type — the identity primitive the ADR-037 access model builds on ("members of a restricted collection = person nodes only"). Closes #133.

Owns the type only (schema + behavior). No PersonNode instance is seeded — the first PersonNode is created + named + bound to a Supabase identity at Pro sync-onboarding (nodespace-sync#125).

Changes

  • PersonNodeBehavior (behaviors/mod.rs): validate (name/content non-empty), can_have_children=false, plain-text, name is the embeddable content (people are searchable), no parent contribution. Plus a computed display_name — custom:displayName override → content → "Unknown Person" placeholder.
  • Registered in NodeBehaviorRegistry::new().
  • person core schema (core_schemas.rs): content = name, is_core, no extra fields.
  • Tests: validation + display-name precedence; registry/schema count asserts updated.

Unblocks the Pro-side enforcement (nodespace-sync#125 auth_identities/onboarding, #126 admin) and is the person-only check for nodespace-core#1372.

cargo test (behaviors + core_schemas) green, clippy clean.

Implement PersonNode as a core node type — the identity primitive the
ADR-037 access model builds on ("members of a restricted collection =
person nodes only"). Owns the TYPE only; no instance is seeded (the first
PersonNode is created + named + bound at Pro sync-onboarding, nodespace-sync#125).

- PersonNodeBehavior: validate (name/content non-empty), can_have_children=false,
  plain-text, name is embeddable (searchable), no parent contribution, plus a
  computed display_name (custom:displayName override → content → placeholder).
- Register it in NodeBehaviorRegistry::new().
- Add the `person` core schema (content = name; no extra fields).
- Tests for validation + display name; update the registry/schema count asserts.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@mstomar125

Copy link
Copy Markdown
Contributor Author

REQUEST CHANGES ⏳

Initial review. no checks reported on the branch.

Tight, well-tested addition: PersonNodeBehavior (name-required validation, can_have_children=false, name-as-embeddable-content, no parent contribution) + a computed display_name with clear override→content→placeholder precedence, the person core schema, registry wiring, and the count asserts (16→17 behaviors, 15→16 schemas) all moved in lockstep. The display-name precedence test matrix is good. One thing to resolve and two small notes.

🟡 "person" is already in the tree as an example user-defined entity type — promoting it to a built-in is_core type changes behavior for any existing "person" node. behaviors/mod.rs:1927 documents the generic entity path as "user-defined entity types like "person", "invoice", "customer"", and models/schema.rs uses target_type: Some("person") as the illustrative relationship target. Before this PR a node typed person resolves to the generic/entity behavior; after, it resolves to PersonNodeBehavior with name-required validation (content.trim() non-empty) and can_have_children=false. For a product whose users define custom entity types, person is a very likely user-chosen name, so any pre-existing person-typed data (or core#1372's usage) would silently change validation/structural rules. The registry count assert going 16→17 confirms there's no double-registration today, but that's a code-level check, not a data-level one. Please confirm no live/user person type collides (and what happens to one if it does), and update the now-contradictory :1927 doc that still cites person as a user-defined example.

🟢 custom:displayName lands in the user-custom-field namespace: per playbook/cel.rs the custom: prefix is stripped and the key is exposed to CEL as node.displayName, and other keys in that namespace are snake_case (custom:due_date, custom:invoice_number) where this is camelCase. If displayName is meant as a system/identity override rather than a user schema field, a reserved/system prefix (and snake_case) would fit the established convention better and keep it out of CEL's user-field surface.

🟢 validate rejects empty content, but display_name still carries the "Unknown Person" fallback for empty content — so the placeholder is unreachable for any node that passed validation. Fine as defensive code (and useful if display_name is ever called on an unvalidated/mid-onboarding node), just noting the two paths disagree on whether an empty-name person is a valid thing to exist.

Scoping to the type only (no seeded instance — that's sync#125 onboarding) is the right boundary.

@mstomar125

Copy link
Copy Markdown
Contributor Author

⚠️ Discrepancy to resolve before merge — PersonNode seeding. This PR follows the #133 issue text ("No PersonNode instance is seeded locally") and adds the type only. But ADR-037 § PersonNode Seeding & Upgrade Continuity says the opposite: "Every install — free included — seeds exactly one PersonNode: the local user (auth_status: 'local')", and that upgrade binds that existing local PersonNode rather than creating one. If the ADR is canonical, #133 should also seed one local PersonNode (with auth_status: 'local') at store init, and nodespace-sync#125 becomes a single auth_identities row insert (bind), not a node creation. Flagging rather than silently choosing — please confirm which is canonical and I'll add the seed if so.

Construct-time seeding in NodeService::new: idempotently create one
person node (auth_status: "local") 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), not recreated.

Add person_seed_test covering fresh-install single-seed, the local
auth_status property, and re-open idempotency.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@mstomar125

Copy link
Copy Markdown
Contributor Author

Seeding discrepancy — resolved in favor of ADR-037 (seed the local PersonNode)

The open question on this PR was whether the local PersonNode is seeded (ADR-037) or not (the original #133 issue note). Resolved: seed it. ADR-037 is canonical here — "PersonNode Seeding & Upgrade Continuity" states every install (free included) seeds exactly one PersonNode: the local user, auth_status: "local". On Pro upgrade that node is bound to a Supabase identity (one auth_identities row insert, nodespace-sync#125), never recreated — there is no "now set up your user" migration step.

What landed (commit 46d5646)

  • NodeService::new now idempotently seeds one person node (auth_status: "local") at construction when none exists. Construct-time (not schema-seed-gated) so existing databases get backfilled on next open too.
  • Property is stored canonically namespaced: properties["person"]["auth_status"] = "local" (Issue Fix property namespace encapsulation - normalize flat properties on read/write #838 normalization).
  • New tests/person_seed_test.rs: fresh-install single-seed, the local auth_status, and re-open idempotency. All pass.

Test status

  • person_seed_test: 2/2 pass. behaviors::tests::person_*: 2/2 pass.
  • Full crate: 939 lib pass; the only 2 lib failures (test_integration_schema_id_generation, test_update_schema_add_valid_title_template — slug hyphen/underscore) are pre-existing on the base branch (verified by stashing this change) and unrelated to PersonNode work.

This unblocks nodespace-sync#125 (bind the seeded PersonNode → Supabase uid at sign-in) and #126 (auto-admin bootstrap).

@mstomar125

Copy link
Copy Markdown
Contributor Author

Superseded by #1401. Both PRs implemented issue #133 in parallel; per maintainer decision we consolidate on #1401 — it carries the fuller vertical slice (PersonNodeBehavior + person schema with name/email fields + the frontend PersonNode component, schema form, and plugin registration).

The one thing #1401 lacked — the ADR-037 local-PersonNode seed (every install seeds exactly one person, auth_status: "local") plus idempotency tests — has been grafted onto #1401 (commit 003a328), adapted to its name/email identity shape. Closing this in favor of #1401.

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.

Implement PersonNodeBehavior

1 participant