Repository navigation
feat: Implement namespaced properties for type-safe node type changes (Issue #794) - #799
Conversation
… (Issue #794) ## Summary When a node's type changes (e.g., `task` → `text`), old type's properties now remain dormant under their namespace rather than being orphaned or conflicting. Properties are now stored as `properties[node_type][field_name]` instead of flat `properties[field_name]`. ## Changes ### Core Storage Changes (node_service.rs) - Update `apply_schema_defaults_with_fields()` to write defaults under type namespace - Update `validate_node_with_fields()` to read from type namespace (removed flat fallback) - Update property merge in `update_node()` and `update_with_version_check()` to deep-merge within type namespaces, preserving dormant type properties - Update `backfill_schema_version()` to only add version for types with schema fields, and store in type namespace - Update `create_node()` to store _schema_version in type namespace - Update `apply_lazy_migration()` to read version from type namespace ### Query Service Changes (query_service/mod.rs) - Update `build_property_filter()` to use namespaced paths (`properties.task.status`) - Update `resolve_field()` to use namespaced paths for non-metadata fields - Update `compare_nodes_by_field()` for in-memory sorting via namespaced access - Wildcard queries (*) fall back to flat access since type is unknown at query time ### Test Updates - Update query_service_test.rs tests to use namespaced property format - Update nodes_test.rs typed response tests for namespaced properties - Update version_tracking_tests to verify text/date nodes (no schema fields) do not get _schema_version ## Benefits 1. Old type's properties preserved when type changes (dormant, not orphaned) 2. No property name conflicts between types 3. Can restore previous type's data if user changes back 4. Clear separation of concerns 5. Indexes work correctly (`properties.task.completed` vs `properties.invoice.status`) Closes #794 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Pragmatic Code Review - PR #799Review Type: Initial Review SummaryThis PR implements namespaced properties for type-safe node type changes (Issue #794). The changes correctly move properties from a flat structure ( Overall Assessment: This is a solid implementation that correctly addresses the core architectural concern. The changes are well-structured and properly update all affected components. There are a few improvements to consider for long-term maintainability. Requirements ValidationPhase 1: Core Storage Changes
Phase 2: Query & Index Updates
Phase 3: Serialization/Deserialization
Phase 4: Quality
Findings🟡 Important - Missing Explicit Type Change TestsLocation: The acceptance criteria specifically requests:
While the existing tests have been updated to use the namespaced format, there are no explicit tests that verify the core value proposition: when a node changes type, the old type's properties are preserved as dormant data. Recommended test scenarios: #[tokio::test]
async fn test_type_change_preserves_old_properties() {
// 1. Create a task node with properties
// 2. Change type to text
// 3. Verify task properties still exist under "task" namespace
// 4. Change type back to task
// 5. Verify original task properties are restored
}
#[tokio::test]
async fn test_same_property_name_different_types() {
// Verify task.status and invoice.status don't conflict
}Engineering Principle: Tests should verify the intent of a feature, not just that the code executes. The namespaced properties feature exists specifically for type-change preservation, which should be explicitly tested. 🟡 Important - Migration Registry IncompatibilityLocation: The let current_version = node
.properties
.get("_schema_version") // <-- Reads flat, not namespaced
.and_then(|v| v.as_u64())Meanwhile,
Impact: If migration functions are used (they appear to be for future use), this will break. Recommendation: Either update 🟡 Important - Schema.surql Has Flat _schema_version FieldLocation: DEFINE FIELD IF NOT EXISTS _schema_version ON TABLE node TYPE int DEFAULT 1;This defines Recommendation: This field definition should either be:
🟢 Suggestion - Code Duplication in update_node FunctionsLocation:
The property merge logic is duplicated in both functions (identical 25-line block). Consider extracting to a helper method: fn deep_merge_namespaced_properties(
existing: &mut serde_json::Value,
new: serde_json::Value,
) {
// Shared deep-merge logic
}Engineering Principle: DRY (Don't Repeat Yourself) - duplicated logic increases maintenance burden and risk of divergent behavior. 🟢 Suggestion - Frontend Backward Compatibility LayerLocation:
The frontend has backward compatibility code that checks both nested and flat formats: const taskProps = properties[node.nodeType] as Record<string, unknown> | undefined;
const status = taskProps?.status || properties.status; // Support both nested and flat formatsPer CLAUDE.md pre-release policy: "NO backward compatibility code - Delete old patterns immediately when replaced" Since this is a clean break with namespaced properties, the flat fallback paths could be removed to simplify the code. However, this is marked as a suggestion since the current code works correctly and removing fallbacks is low-risk cleanup. 🟢 Nit - Comment DocumentationLocation: The comment block for /// Issue #794: Properties are now stored in namespaced format:
/// properties[node_type][field_name] instead of properties[field_name]
///
/// NOTE: Wildcard queries (*) cannot use namespaced paths because the
/// node type is unknown at query time. These queries fall back to flat
/// property access, which may return no results for namespaced data.
Test Results
Final RecommendationREQUEST CHANGES The implementation is architecturally sound and correctly implements the namespaced property pattern. However, before merge:
These changes ensure the implementation is complete and future-proof. The core functionality is correct - these are completeness items aligned with the acceptance criteria. Review conducted following the Pragmatic Quality framework. Focus on substance over perfection. |
malibio
left a comment
There was a problem hiding this comment.
See detailed review comment above. Review status: REQUEST CHANGES
Required before merge:
- Add explicit tests for type-change property preservation (acceptance criteria Phase 4)
- Fix MigrationRegistry to read _schema_version from namespaced format (or document as known limitation)
- Address schema.surql _schema_version field definition conflict
…ssue #794) ## Changes Made ### 🔴 Critical - Added Type Change Tests (Acceptance Criteria Phase 4) - Added test_type_change_preserves_old_type_properties: Verifies properties are preserved as dormant data when node type changes and restored when changed back - Added test_same_property_name_different_types_no_conflict: Verifies task.status and custom.status coexist without conflict - Added test_updating_current_type_preserves_dormant_properties: Verifies updates to current type don't affect dormant properties from previous types ### 🔴 Critical - Fixed MigrationRegistry Namespaced Format - Updated apply_migrations() to read _schema_version from namespaced location (properties[node_type]._schema_version instead of properties._schema_version) - Updated all test helpers and migration functions to use namespaced format - Updated doc examples to reflect namespaced property structure ### 🟡 Important - Cleaned Up schema.surql - Removed flat _schema_version field definition that conflicted with namespaced storage format - Added documentation explaining the namespaced format ### 🟢 Suggestion - Extracted Property Merge Helper - Created deep_merge_namespaced_properties() helper function - Eliminated code duplication between update_node() and update_with_version_check() ### 🟢 Suggestion - Removed Frontend Backward Compatibility - Removed flat property fallback in core-plugins.ts extractMetadata() - Removed flat property fallback in task-node.ts toTaskNode() - Removed flat property fallback in schema-property-form.svelte getPropertyValue() ## Test Results - Rust: 681 tests pass (3 new tests added) - Frontend: 3431 tests pass - Quality checks pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Review Recommendations AddressedSummary of Changes
Changes Made🔴 Critical - Added Type Change Tests (Acceptance Criteria Phase 4)
🔴 Critical - Fixed MigrationRegistry Namespaced Format
🟡 Important - Cleaned Up schema.surql
🟢 Suggestion - Extracted Property Merge Helper
🟢 Suggestion - Removed Frontend Backward Compatibility
Test Results
Skipped Recommendation#6 - Comment documentation for wildcard queries: The existing comment already explains the Issue #794 changes. Adding more detail about wildcard limitations has marginal value since the code behavior is clear from context. Re-Review DecisionDecision: RE-REVIEW NEEDED Rationale:
Run |
Pragmatic Code Review - PR #799 (Re-Review)Review Type: Re-Review (Delta Review) Previous Review SummaryThe initial review identified 6 recommendations:
Summary: 5/6 recommendations properly addressed. The skipped nit is acceptable. Verification of Addressed Items1. ✅ Type Change Tests (Critical)Location: Three comprehensive tests were added that verify the core value proposition:
Assessment: Well-documented tests with clear step-by-step verification. Tests the intent of the feature, not just mechanics. 2. ✅ MigrationRegistry Fix (Critical)Location:
Assessment: Clean implementation with proper abstraction via helper function. 3. ✅ schema.surql Cleanup (Important)Location:
Assessment: Properly resolved the architectural inconsistency. 4. ✅ Property Merge Helper (Suggestion)Location:
Assessment: Eliminates code duplication, follows DRY principle. 5. ✅ Frontend Backward Compatibility Removal (Suggestion)Locations:
Assessment: Per CLAUDE.md pre-release policy, backward compatibility code was properly removed. Requirements Validation (Issue #794)Phase 1: Core Storage Changes
Phase 2: Query & Index Updates
Phase 3: Serialization/Deserialization
Phase 4: Quality
New Issues IdentifiedNone. The fixes are clean and do not introduce new problems. Test Results
Final RecommendationAPPROVE ✅ All critical and important issues from the initial review have been properly addressed. The implementation:
This PR is ready to merge. Re-review conducted following the Pragmatic Quality framework. Delta review focused on verifying addressed recommendations. |
malibio
left a comment
There was a problem hiding this comment.
Re-Review Status: APPROVE (via comment)
All critical and important issues from the initial review have been properly addressed. The implementation correctly addresses all acceptance criteria from Issue #794, adds comprehensive tests, and improves code quality.
Recommendation: Ready to merge.
(Note: GitHub prevents self-approval, so this approval is recorded as a comment.)
Resolved conflict in node_service.rs: kept namespaced property format for backfill_schema_version function (Issue #794). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
… (Issue #794) (#799) * feat: Implement namespaced properties for type-safe node type changes (Issue #794) ## Summary When a node's type changes (e.g., `task` → `text`), old type's properties now remain dormant under their namespace rather than being orphaned or conflicting. Properties are now stored as `properties[node_type][field_name]` instead of flat `properties[field_name]`. ## Changes ### Core Storage Changes (node_service.rs) - Update `apply_schema_defaults_with_fields()` to write defaults under type namespace - Update `validate_node_with_fields()` to read from type namespace (removed flat fallback) - Update property merge in `update_node()` and `update_with_version_check()` to deep-merge within type namespaces, preserving dormant type properties - Update `backfill_schema_version()` to only add version for types with schema fields, and store in type namespace - Update `create_node()` to store _schema_version in type namespace - Update `apply_lazy_migration()` to read version from type namespace ### Query Service Changes (query_service/mod.rs) - Update `build_property_filter()` to use namespaced paths (`properties.task.status`) - Update `resolve_field()` to use namespaced paths for non-metadata fields - Update `compare_nodes_by_field()` for in-memory sorting via namespaced access - Wildcard queries (*) fall back to flat access since type is unknown at query time ### Test Updates - Update query_service_test.rs tests to use namespaced property format - Update nodes_test.rs typed response tests for namespaced properties - Update version_tracking_tests to verify text/date nodes (no schema fields) do not get _schema_version ## Benefits 1. Old type's properties preserved when type changes (dormant, not orphaned) 2. No property name conflicts between types 3. Can restore previous type's data if user changes back 4. Clear separation of concerns 5. Indexes work correctly (`properties.task.completed` vs `properties.invoice.status`) Closes #794 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]> * Address code review: Complete namespaced properties implementation (Issue #794) ## Changes Made ### 🔴 Critical - Added Type Change Tests (Acceptance Criteria Phase 4) - Added test_type_change_preserves_old_type_properties: Verifies properties are preserved as dormant data when node type changes and restored when changed back - Added test_same_property_name_different_types_no_conflict: Verifies task.status and custom.status coexist without conflict - Added test_updating_current_type_preserves_dormant_properties: Verifies updates to current type don't affect dormant properties from previous types ### 🔴 Critical - Fixed MigrationRegistry Namespaced Format - Updated apply_migrations() to read _schema_version from namespaced location (properties[node_type]._schema_version instead of properties._schema_version) - Updated all test helpers and migration functions to use namespaced format - Updated doc examples to reflect namespaced property structure ### 🟡 Important - Cleaned Up schema.surql - Removed flat _schema_version field definition that conflicted with namespaced storage format - Added documentation explaining the namespaced format ### 🟢 Suggestion - Extracted Property Merge Helper - Created deep_merge_namespaced_properties() helper function - Eliminated code duplication between update_node() and update_with_version_check() ### 🟢 Suggestion - Removed Frontend Backward Compatibility - Removed flat property fallback in core-plugins.ts extractMetadata() - Removed flat property fallback in task-node.ts toTaskNode() - Removed flat property fallback in schema-property-form.svelte getPropertyValue() ## Test Results - Rust: 681 tests pass (3 new tests added) - Frontend: 3431 tests pass - Quality checks pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]> --------- Co-authored-by: Claude Opus 4.5 <[email protected]>
… (Issue #794) (#799) * feat: Implement namespaced properties for type-safe node type changes (Issue #794) ## Summary When a node's type changes (e.g., `task` → `text`), old type's properties now remain dormant under their namespace rather than being orphaned or conflicting. Properties are now stored as `properties[node_type][field_name]` instead of flat `properties[field_name]`. ## Changes ### Core Storage Changes (node_service.rs) - Update `apply_schema_defaults_with_fields()` to write defaults under type namespace - Update `validate_node_with_fields()` to read from type namespace (removed flat fallback) - Update property merge in `update_node()` and `update_with_version_check()` to deep-merge within type namespaces, preserving dormant type properties - Update `backfill_schema_version()` to only add version for types with schema fields, and store in type namespace - Update `create_node()` to store _schema_version in type namespace - Update `apply_lazy_migration()` to read version from type namespace ### Query Service Changes (query_service/mod.rs) - Update `build_property_filter()` to use namespaced paths (`properties.task.status`) - Update `resolve_field()` to use namespaced paths for non-metadata fields - Update `compare_nodes_by_field()` for in-memory sorting via namespaced access - Wildcard queries (*) fall back to flat access since type is unknown at query time ### Test Updates - Update query_service_test.rs tests to use namespaced property format - Update nodes_test.rs typed response tests for namespaced properties - Update version_tracking_tests to verify text/date nodes (no schema fields) do not get _schema_version ## Benefits 1. Old type's properties preserved when type changes (dormant, not orphaned) 2. No property name conflicts between types 3. Can restore previous type's data if user changes back 4. Clear separation of concerns 5. Indexes work correctly (`properties.task.completed` vs `properties.invoice.status`) Closes #794 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]> * Address code review: Complete namespaced properties implementation (Issue #794) ## Changes Made ### 🔴 Critical - Added Type Change Tests (Acceptance Criteria Phase 4) - Added test_type_change_preserves_old_type_properties: Verifies properties are preserved as dormant data when node type changes and restored when changed back - Added test_same_property_name_different_types_no_conflict: Verifies task.status and custom.status coexist without conflict - Added test_updating_current_type_preserves_dormant_properties: Verifies updates to current type don't affect dormant properties from previous types ### 🔴 Critical - Fixed MigrationRegistry Namespaced Format - Updated apply_migrations() to read _schema_version from namespaced location (properties[node_type]._schema_version instead of properties._schema_version) - Updated all test helpers and migration functions to use namespaced format - Updated doc examples to reflect namespaced property structure ### 🟡 Important - Cleaned Up schema.surql - Removed flat _schema_version field definition that conflicted with namespaced storage format - Added documentation explaining the namespaced format ### 🟢 Suggestion - Extracted Property Merge Helper - Created deep_merge_namespaced_properties() helper function - Eliminated code duplication between update_node() and update_with_version_check() ### 🟢 Suggestion - Removed Frontend Backward Compatibility - Removed flat property fallback in core-plugins.ts extractMetadata() - Removed flat property fallback in task-node.ts toTaskNode() - Removed flat property fallback in schema-property-form.svelte getPropertyValue() ## Test Results - Rust: 681 tests pass (3 new tests added) - Frontend: 3431 tests pass - Quality checks pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]> --------- Co-authored-by: Claude Opus 4.5 <[email protected]>
… (Issue #794) (#799) * feat: Implement namespaced properties for type-safe node type changes (Issue #794) ## Summary When a node's type changes (e.g., `task` → `text`), old type's properties now remain dormant under their namespace rather than being orphaned or conflicting. Properties are now stored as `properties[node_type][field_name]` instead of flat `properties[field_name]`. ## Changes ### Core Storage Changes (node_service.rs) - Update `apply_schema_defaults_with_fields()` to write defaults under type namespace - Update `validate_node_with_fields()` to read from type namespace (removed flat fallback) - Update property merge in `update_node()` and `update_with_version_check()` to deep-merge within type namespaces, preserving dormant type properties - Update `backfill_schema_version()` to only add version for types with schema fields, and store in type namespace - Update `create_node()` to store _schema_version in type namespace - Update `apply_lazy_migration()` to read version from type namespace ### Query Service Changes (query_service/mod.rs) - Update `build_property_filter()` to use namespaced paths (`properties.task.status`) - Update `resolve_field()` to use namespaced paths for non-metadata fields - Update `compare_nodes_by_field()` for in-memory sorting via namespaced access - Wildcard queries (*) fall back to flat access since type is unknown at query time ### Test Updates - Update query_service_test.rs tests to use namespaced property format - Update nodes_test.rs typed response tests for namespaced properties - Update version_tracking_tests to verify text/date nodes (no schema fields) do not get _schema_version ## Benefits 1. Old type's properties preserved when type changes (dormant, not orphaned) 2. No property name conflicts between types 3. Can restore previous type's data if user changes back 4. Clear separation of concerns 5. Indexes work correctly (`properties.task.completed` vs `properties.invoice.status`) Closes #794 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]> * Address code review: Complete namespaced properties implementation (Issue #794) ## Changes Made ### 🔴 Critical - Added Type Change Tests (Acceptance Criteria Phase 4) - Added test_type_change_preserves_old_type_properties: Verifies properties are preserved as dormant data when node type changes and restored when changed back - Added test_same_property_name_different_types_no_conflict: Verifies task.status and custom.status coexist without conflict - Added test_updating_current_type_preserves_dormant_properties: Verifies updates to current type don't affect dormant properties from previous types ### 🔴 Critical - Fixed MigrationRegistry Namespaced Format - Updated apply_migrations() to read _schema_version from namespaced location (properties[node_type]._schema_version instead of properties._schema_version) - Updated all test helpers and migration functions to use namespaced format - Updated doc examples to reflect namespaced property structure ### 🟡 Important - Cleaned Up schema.surql - Removed flat _schema_version field definition that conflicted with namespaced storage format - Added documentation explaining the namespaced format ### 🟢 Suggestion - Extracted Property Merge Helper - Created deep_merge_namespaced_properties() helper function - Eliminated code duplication between update_node() and update_with_version_check() ### 🟢 Suggestion - Removed Frontend Backward Compatibility - Removed flat property fallback in core-plugins.ts extractMetadata() - Removed flat property fallback in task-node.ts toTaskNode() - Removed flat property fallback in schema-property-form.svelte getPropertyValue() ## Test Results - Rust: 681 tests pass (3 new tests added) - Frontend: 3431 tests pass - Quality checks pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]> --------- Co-authored-by: Claude Opus 4.5 <[email protected]>
Summary
task→text), old type's properties remain dormant under their namespaceproperties[node_type][field_name]instead of flatproperties[field_name]Changes
Core Storage Changes
apply_schema_defaults_with_fields()to write defaults under type namespacevalidate_node_with_fields()to read from type namespace (removed flat fallback)update_node()to deep-merge within type namespacesbackfill_schema_version()to only add version for types with schema fieldscreate_node()to store _schema_version in type namespaceQuery Service Changes
properties.task.status)Test Updates
Benefits
properties.task.statusvsproperties.invoice.status)Test plan
Closes #794
🤖 Generated with Claude Code