Add title_template support for schema-driven title computation#970
Conversation
Custom entity schemas (Customer, Invoice, etc.) can now define a
`title_template` field on their SchemaNode (e.g. `{first_name} {last_name}`)
that is interpolated from node properties instead of content.
- Add `title_template: Option<String>` to `SchemaNode` with
`from_node()`/`into_node()` round-trip support (stored as `titleTemplate`
in node properties)
- Add `interpolate_title_template(template, properties)` to markdown utils;
replaces `{field_name}` tokens, coerces non-string values, collapses
whitespace, gracefully handles missing/null fields
- Add `compute_title()` helper on `NodeService` that checks for
`title_template` first, then falls back to existing content-based logic
- Replace all 3 hardcoded TODO #824 title-computation blocks with
`compute_title()`, and extend the trigger condition to include
`properties_changed` so property updates re-index the title
- Fix pre-existing test failure: `test_create_schema_multiple_relationships`
had an enum field with no values, violating the validator added in a
recent fix — added `coreValues` to make it valid
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Code Review SummaryReview Type: Initial Review This PR implements schema-driven title computation via a A few issues require attention before merge, one of which is a meaningful correctness gap. Requirements Check
Findings[Improvement] Missing Acceptance Criterion: Template Syntax Validation
The issue explicitly calls for validation of A minimal check — verifying that every [Improvement] Silent Error Swallowing in
|
malibio
left a comment
There was a problem hiding this comment.
See detailed review comment above. Two issues to address before merge: (1) missing title_template syntax validation (explicit acceptance criterion), (2) silent error swallowing in compute_title when get_schema_node fails.
…lity
- Add title_template syntax validation to SchemaNodeBehavior.validate_schema_node():
rejects unclosed '{' placeholders and empty '{}' placeholders. This was an
explicit acceptance criterion noted as missing in the review.
- Replace silent Err discard in compute_title() with tracing::warn! so schema
lookup failures are observable without blocking create/update operations.
- Add 4 unit tests covering valid template, unclosed brace, empty placeholder,
and None (no template) cases.
Skipped:
- Double normalization in create_node_with_parent: safe/idempotent, fixing it
would add complexity for negligible benefit at this stage.
- Vec<char> allocation in interpolate_title_template: not a hot path; premature
optimization.
- Test schema ID suffixes: cosmetic, tests use isolated DBs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Review Feedback Addressed✅ Addressed (2/4 findings)🟡 Missing title_template syntax validation — Added to 🟡 Silent error swallowing in ⏭️ Skipped (2/4 findings)🟢 Double normalization in 🟢 |
* feat: title_template support for schema-driven title computation (#824) Custom entity schemas (Customer, Invoice, etc.) can now define a `title_template` field on their SchemaNode (e.g. `{first_name} {last_name}`) that is interpolated from node properties instead of content. - Add `title_template: Option<String>` to `SchemaNode` with `from_node()`/`into_node()` round-trip support (stored as `titleTemplate` in node properties) - Add `interpolate_title_template(template, properties)` to markdown utils; replaces `{field_name}` tokens, coerces non-string values, collapses whitespace, gracefully handles missing/null fields - Add `compute_title()` helper on `NodeService` that checks for `title_template` first, then falls back to existing content-based logic - Replace all 3 hardcoded TODO #824 title-computation blocks with `compute_title()`, and extend the trigger condition to include `properties_changed` so property updates re-index the title - Fix pre-existing test failure: `test_create_schema_multiple_relationships` had an enum field with no values, violating the validator added in a recent fix — added `coreValues` to make it valid Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Address review: title_template validation and compute_title observability - Add title_template syntax validation to SchemaNodeBehavior.validate_schema_node(): rejects unclosed '{' placeholders and empty '{}' placeholders. This was an explicit acceptance criterion noted as missing in the review. - Replace silent Err discard in compute_title() with tracing::warn! so schema lookup failures are observable without blocking create/update operations. - Add 4 unit tests covering valid template, unclosed brace, empty placeholder, and None (no template) cases. Skipped: - Double normalization in create_node_with_parent: safe/idempotent, fixing it would add complexity for negligible benefit at this stage. - Vec<char> allocation in interpolate_title_template: not a hot path; premature optimization. - Test schema ID suffixes: cosmetic, tests use isolated DBs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Closes #824