Skip to content

Implement type-namespaced properties (Issue #397) - #399

Merged
malibio merged 5 commits into
mainfrom
feature/issue-397-type-namespaced-properties
Nov 4, 2025
Merged

malibio merged 5 commits into
mainfrom
feature/issue-397-type-namespaced-properties

Conversation

@malibio

@malibio malibio commented Nov 4, 2025

Copy link
Copy Markdown
Collaborator

Summary

Refactored node properties from flat structure to type-namespaced format, enabling property preservation across node type conversions.

Changes

Backend (Rust)

  • TaskNodeBehavior validation updated for nested properties (properties.task.*)
  • Backward compatibility maintained - accepts both flat and nested formats
  • default_metadata() updated to return nested structure
  • All behavior unit tests updated and passing (18/18)

Frontend (TypeScript/Svelte)

  • SchemaPropertyForm component updated with backward compatibility
  • Property reads check nested format first, fall back to flat
  • Property writes use new nested format
  • Supports both formats seamlessly

Property Structure

Old format (deprecated):

{
  "status": "OPEN",
  "due_date": "2025-10-25"
}

New format:

{
  "task": {
    "status": "OPEN",
    "due_date": "2025-10-25"
  }
}

Benefits

✅ Property Preservation - Task → text → task conversion preserves task properties
✅ Multi-Type Support - Node can store properties for multiple types simultaneously
✅ Backward Compatible - Existing flat format still works during transition
✅ Clean Separation - Type-specific properties are isolated and well-defined

Testing

  • Backend: 18/18 behavior tests passing
  • Frontend: Property form component tested with both formats
  • Pre-existing test failures (4 Rust, 8 frontend) are unrelated

Migration Path

  • New nodes automatically use nested format
  • Existing nodes continue working with flat format
  • Future: Add migration helper to auto-upgrade on first update

Acceptance Criteria (from #397)

  • Node behaviors validate properties.{type}.* instead of properties.*
  • Backward compatibility maintained during transition
  • All backend tests pass with new format
  • Frontend can read/write nested properties
  • Frontend tests updated (minimal changes needed)
  • Documentation updated

Closes #397

🤖 Generated with Claude Code

malibio and others added 5 commits November 4, 2025 15:37
**Schema Completeness:**
- Add code-block, quote-block, ordered-list schemas (were missing)
- Add version and description fields to all schemas for frontend compatibility

**Changes:**
1. Remove headerLevel property from header schema (markdown nodes store syntax in content)
2. Add missing schemas: code-block, quote-block, ordered-list (all with empty fields)
3. Add version (1) and description to all schemas (required by TypeScript SchemaDefinition interface)

**Why These Changes:**
- Markdown nodes (text, header, code-block, quote-block, ordered-list) store formatting in content field, not properties
- Frontend SchemaDefinition interface requires: isCore, version, description, fields
- Missing version/description breaks schema-driven UI

**Test Updates:**
- Update test_core_schemas_seeded to expect 9 schemas (was 6)
- Update test_schema_seeding_idempotency to expect 9 schemas

**All 9 Core Schemas:**
1. task - Task tracking with status, priority, dates
2. person - Person entity with name, email
3. date - Date node for calendar organization
4. project - Project management with name, status
5. text - Plain text content (no properties)
6. header - Markdown headers h1-h6 (no properties)
7. code-block - Code with syntax highlighting (no properties)
8. quote-block - Markdown block quotes (no properties)
9. ordered-list - Numbered list items (no properties)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
)

## Completed in This Session
- [x] Updated TaskNodeBehavior validation to support type-namespaced properties
- [x] Added backward compatibility for old flat format during transition
- [x] Updated TaskNodeBehavior default_metadata to use nested structure
- [x] Updated all behavior tests to use new nested format
- [x] All behavior unit tests passing (18/18)

## Remaining Work
- [ ] Update frontend property access patterns (task-list, schema forms, etc.)
- [ ] Update frontend tests
- [ ] Add migration helper for auto-upgrading old format on first update
- [ ] Documentation updates

## Current State
- Files modified: packages/core/src/behaviors/mod.rs
- Tests status: All behavior tests passing, 4 pre-existing test failures unrelated to this change
- Backend validation: Accepts both `properties.status` (old) and `properties.task.status` (new)
- New nodes: Use nested format `properties.task.*`

## Context for Next Session
Backend validation is complete with full backward compatibility. The TaskNodeBehavior
now validates properties in both formats (old flat, new nested), with new nodes using
the nested structure. Next step is updating frontend to read/write nested properties
while maintaining compatibility with existing data.

## Acceptance Criteria Status
From issue #397:
- [x] Node behaviors validate `properties.{type}.*` instead of `properties.*`
- [x] Backward compatibility maintained during transition
- [x] All backend tests pass with new format
- [ ] Frontend can read/write nested properties
- [ ] All frontend tests pass with new format
- [ ] Documentation updated with new property structure

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
## Summary
Refactored node properties from flat structure to type-namespaced format,
enabling property preservation across node type conversions (e.g., task → text → task).

## Changes

### Backend (Rust)
- **TaskNodeBehavior** validation updated for nested properties (`properties.task.*`)
- **Backward compatibility** maintained - accepts both flat and nested formats
- **default_metadata()** updated to return nested structure
- All behavior unit tests updated and passing (18/18)

### Frontend (TypeScript/Svelte)
- **SchemaPropertyForm** component updated:
  - Added `getPropertyValue()` helper with backward compatibility
  - Read operations check nested format first, fall back to flat
  - Write operations use new nested format
- Property access now supports both formats seamlessly

## Property Structure

**Old format (deprecated):**
```json
{
  "status": "OPEN",
  "due_date": "2025-10-25"
}
```

**New format:**
```json
{
  "task": {
    "status": "OPEN",
    "due_date": "2025-10-25"
  }
}
```

## Benefits
✅ **Property Preservation** - Task → text → task conversion preserves task properties
✅ **Multi-Type Support** - Node can store properties for multiple types simultaneously
✅ **Backward Compatible** - Existing flat format still works during transition
✅ **Clean Separation** - Type-specific properties are isolated and well-defined

## Testing
- Backend: 18/18 behavior tests passing
- Frontend: Property form component tested with both formats
- Pre-existing test failures (4 Rust, 8 frontend) are unrelated to this change

## Migration Path
- New nodes automatically use nested format via `default_metadata()`
- Existing nodes continue working with flat format (backward compatibility)
- Future: Add migration helper to auto-upgrade on first update

## Acceptance Criteria Status (from #397)
- [x] Node behaviors validate `properties.{type}.*` instead of `properties.*`
- [x] Backward compatibility maintained during transition
- [x] All backend tests pass with new format
- [x] Frontend can read/write nested properties
- [ ] Frontend tests updated (minimal changes needed)
- [ ] Documentation updated with new property structure

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
## Changes Made

### 1. Backend Testing
- **Added test_type_conversion_preserves_properties()** (behaviors/mod.rs)
  - Validates core value proposition: properties survive type conversions
  - Tests task → text → task conversion without data loss
  - Addresses reviewer requirement for explicit test coverage

### 2. Frontend Auto-Migration
- **Implemented one-time auto-migration** (schema-property-form.svelte)
  - Migrates old flat format to new nested format on first write
  - Prevents mixed-format properties within same node
  - Ensures clean data migration path
  - Includes proper TypeScript type guards

### 3. Documentation
- **Created comprehensive migration guide** (type-namespaced-properties-migration.md)
  - Explains old vs. new property format
  - Documents backward compatibility strategy
  - Provides code examples for developers
  - Includes testing and future enhancement sections

- **Updated storage architecture docs** (storage-architecture.md)
  - Added example showing new nested format
  - Referenced migration guide for details

- **Updated node type guide** (how-to-add-new-node-type.md)
  - Shows proper type-namespaced format for new node types
  - Prevents future developers from using deprecated flat format

### 4. Code Quality Fixes
- **Fixed inaccurate test comment** (behaviors/mod.rs)
  - Clarified that enum validation is future functionality
  - Prevents misleading developers about current capabilities

## Reviewer Recommendations Addressed

✅ **Add type conversion preservation test** (Required)
✅ **Add architecture documentation** (Required)
✅ **Implement auto-migration on first write** (Suggested - Important)
✅ **Fix inaccurate test comment** (Nitpick)

⏭️ **Skipped: Backend fallback logic edge case** (Nitpick)
   - Rationale: Functionally correct, improvement would add complexity
     for marginal semantic benefit. Current validation handles all cases
     correctly. Will revisit if actual bugs occur in production.

## Testing

- ✅ Backend: All task node behavior tests pass (4/4)
- ✅ Frontend: Quality checks pass (lint, format, type-check)
- ✅ New test validates property preservation explicitly
- ⚠️ 1 unrelated test failure (OCC performance overhead - flaky test)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@malibio

malibio commented Nov 4, 2025

Copy link
Copy Markdown
Collaborator Author

Code Review Recommendations Addressed

I've successfully addressed the pragmatic code review recommendations. Here's a summary:

✅ Addressed (4 recommendations)

  1. Added Type Conversion Preservation Test (Required)

    • New test: test_type_conversion_preserves_properties() in behaviors/mod.rs
    • Validates core value proposition: properties survive type conversions (task → text → task)
    • All behavior tests passing (4/4)
  2. Implemented Auto-Migration on First Write (Suggested - Important)

    • Updated updateProperty() in schema-property-form.svelte
    • Automatically migrates old flat format to new nested format on first property edit
    • Prevents mixed-format properties within same node
    • Ensures clean data migration path
  3. Created Comprehensive Documentation (Required)

    • New: docs/architecture/development/type-namespaced-properties-migration.md
    • Updated: docs/architecture/data/storage-architecture.md
    • Updated: docs/architecture/development/how-to-add-new-node-type.md
    • Covers migration strategy, code examples, testing, and future enhancements
  4. Fixed Inaccurate Test Comment (Nitpick)

    • Clarified that enum validation is future functionality, not current implementation
    • Prevents misleading developers about current capabilities

⏭️ Skipped (1 recommendation)

Backend: Backward Compatibility Fallback Logic Edge Case (Nitpick)

  • Rationale: The reviewer correctly noted "functionally correct but semantically imprecise." The current implementation handles all cases correctly with graceful fallbacks. The suggested improvement would add complexity for marginal semantic benefit without measurable functional improvement.
  • Condition to revisit: If actual bugs related to empty property validation occur in production.

Testing Results

  • ✅ Backend: All task node behavior tests pass (4/4)
  • ✅ Frontend: Quality checks pass (lint, format, type-check)
  • ✅ New test: Explicitly validates property preservation during type conversions
  • ⚠️ Note: 1 unrelated test failure (test_occ_performance_overhead - flaky performance test)

Commit

All changes committed in: a382b57 - "Address code review: Add tests, auto-migration, and documentation"


Ready for re-review or merge decision.

@malibio
malibio merged commit aa75db7 into main Nov 4, 2025
@malibio
malibio deleted the feature/issue-397-type-namespaced-properties branch November 4, 2025 16:15
malibio added a commit that referenced this pull request Feb 4, 2026
* Add missing core schema definitions and required fields (Issue #397)

**Schema Completeness:**
- Add code-block, quote-block, ordered-list schemas (were missing)
- Add version and description fields to all schemas for frontend compatibility

**Changes:**
1. Remove headerLevel property from header schema (markdown nodes store syntax in content)
2. Add missing schemas: code-block, quote-block, ordered-list (all with empty fields)
3. Add version (1) and description to all schemas (required by TypeScript SchemaDefinition interface)

**Why These Changes:**
- Markdown nodes (text, header, code-block, quote-block, ordered-list) store formatting in content field, not properties
- Frontend SchemaDefinition interface requires: isCore, version, description, fields
- Missing version/description breaks schema-driven UI

**Test Updates:**
- Update test_core_schemas_seeded to expect 9 schemas (was 6)
- Update test_schema_seeding_idempotency to expect 9 schemas

**All 9 Core Schemas:**
1. task - Task tracking with status, priority, dates
2. person - Person entity with name, email
3. date - Date node for calendar organization
4. project - Project management with name, status
5. text - Plain text content (no properties)
6. header - Markdown headers h1-h6 (no properties)
7. code-block - Code with syntax highlighting (no properties)
8. quote-block - Markdown block quotes (no properties)
9. ordered-list - Numbered list items (no properties)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* WIP: Implement type-namespaced properties - Backend complete (Issue #397)

## Completed in This Session
- [x] Updated TaskNodeBehavior validation to support type-namespaced properties
- [x] Added backward compatibility for old flat format during transition
- [x] Updated TaskNodeBehavior default_metadata to use nested structure
- [x] Updated all behavior tests to use new nested format
- [x] All behavior unit tests passing (18/18)

## Remaining Work
- [ ] Update frontend property access patterns (task-list, schema forms, etc.)
- [ ] Update frontend tests
- [ ] Add migration helper for auto-upgrading old format on first update
- [ ] Documentation updates

## Current State
- Files modified: packages/core/src/behaviors/mod.rs
- Tests status: All behavior tests passing, 4 pre-existing test failures unrelated to this change
- Backend validation: Accepts both `properties.status` (old) and `properties.task.status` (new)
- New nodes: Use nested format `properties.task.*`

## Context for Next Session
Backend validation is complete with full backward compatibility. The TaskNodeBehavior
now validates properties in both formats (old flat, new nested), with new nodes using
the nested structure. Next step is updating frontend to read/write nested properties
while maintaining compatibility with existing data.

## Acceptance Criteria Status
From issue #397:
- [x] Node behaviors validate `properties.{type}.*` instead of `properties.*`
- [x] Backward compatibility maintained during transition
- [x] All backend tests pass with new format
- [ ] Frontend can read/write nested properties
- [ ] All frontend tests pass with new format
- [ ] Documentation updated with new property structure

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* Implement type-namespaced properties (Issue #397)

## Summary
Refactored node properties from flat structure to type-namespaced format,
enabling property preservation across node type conversions (e.g., task → text → task).

## Changes

### Backend (Rust)
- **TaskNodeBehavior** validation updated for nested properties (`properties.task.*`)
- **Backward compatibility** maintained - accepts both flat and nested formats
- **default_metadata()** updated to return nested structure
- All behavior unit tests updated and passing (18/18)

### Frontend (TypeScript/Svelte)
- **SchemaPropertyForm** component updated:
  - Added `getPropertyValue()` helper with backward compatibility
  - Read operations check nested format first, fall back to flat
  - Write operations use new nested format
- Property access now supports both formats seamlessly

## Property Structure

**Old format (deprecated):**
```json
{
  "status": "OPEN",
  "due_date": "2025-10-25"
}
```

**New format:**
```json
{
  "task": {
    "status": "OPEN",
    "due_date": "2025-10-25"
  }
}
```

## Benefits
✅ **Property Preservation** - Task → text → task conversion preserves task properties
✅ **Multi-Type Support** - Node can store properties for multiple types simultaneously
✅ **Backward Compatible** - Existing flat format still works during transition
✅ **Clean Separation** - Type-specific properties are isolated and well-defined

## Testing
- Backend: 18/18 behavior tests passing
- Frontend: Property form component tested with both formats
- Pre-existing test failures (4 Rust, 8 frontend) are unrelated to this change

## Migration Path
- New nodes automatically use nested format via `default_metadata()`
- Existing nodes continue working with flat format (backward compatibility)
- Future: Add migration helper to auto-upgrade on first update

## Acceptance Criteria Status (from #397)
- [x] Node behaviors validate `properties.{type}.*` instead of `properties.*`
- [x] Backward compatibility maintained during transition
- [x] All backend tests pass with new format
- [x] Frontend can read/write nested properties
- [ ] Frontend tests updated (minimal changes needed)
- [ ] Documentation updated with new property structure

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* Address code review: Add tests, auto-migration, and documentation

## Changes Made

### 1. Backend Testing
- **Added test_type_conversion_preserves_properties()** (behaviors/mod.rs)
  - Validates core value proposition: properties survive type conversions
  - Tests task → text → task conversion without data loss
  - Addresses reviewer requirement for explicit test coverage

### 2. Frontend Auto-Migration
- **Implemented one-time auto-migration** (schema-property-form.svelte)
  - Migrates old flat format to new nested format on first write
  - Prevents mixed-format properties within same node
  - Ensures clean data migration path
  - Includes proper TypeScript type guards

### 3. Documentation
- **Created comprehensive migration guide** (type-namespaced-properties-migration.md)
  - Explains old vs. new property format
  - Documents backward compatibility strategy
  - Provides code examples for developers
  - Includes testing and future enhancement sections

- **Updated storage architecture docs** (storage-architecture.md)
  - Added example showing new nested format
  - Referenced migration guide for details

- **Updated node type guide** (how-to-add-new-node-type.md)
  - Shows proper type-namespaced format for new node types
  - Prevents future developers from using deprecated flat format

### 4. Code Quality Fixes
- **Fixed inaccurate test comment** (behaviors/mod.rs)
  - Clarified that enum validation is future functionality
  - Prevents misleading developers about current capabilities

## Reviewer Recommendations Addressed

✅ **Add type conversion preservation test** (Required)
✅ **Add architecture documentation** (Required)
✅ **Implement auto-migration on first write** (Suggested - Important)
✅ **Fix inaccurate test comment** (Nitpick)

⏭️ **Skipped: Backend fallback logic edge case** (Nitpick)
   - Rationale: Functionally correct, improvement would add complexity
     for marginal semantic benefit. Current validation handles all cases
     correctly. Will revisit if actual bugs occur in production.

## Testing

- ✅ Backend: All task node behavior tests pass (4/4)
- ✅ Frontend: Quality checks pass (lint, format, type-check)
- ✅ New test validates property preservation explicitly
- ⚠️ 1 unrelated test failure (OCC performance overhead - flaky test)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
malibio added a commit that referenced this pull request Feb 5, 2026
* Add missing core schema definitions and required fields (Issue #397)

**Schema Completeness:**
- Add code-block, quote-block, ordered-list schemas (were missing)
- Add version and description fields to all schemas for frontend compatibility

**Changes:**
1. Remove headerLevel property from header schema (markdown nodes store syntax in content)
2. Add missing schemas: code-block, quote-block, ordered-list (all with empty fields)
3. Add version (1) and description to all schemas (required by TypeScript SchemaDefinition interface)

**Why These Changes:**
- Markdown nodes (text, header, code-block, quote-block, ordered-list) store formatting in content field, not properties
- Frontend SchemaDefinition interface requires: isCore, version, description, fields
- Missing version/description breaks schema-driven UI

**Test Updates:**
- Update test_core_schemas_seeded to expect 9 schemas (was 6)
- Update test_schema_seeding_idempotency to expect 9 schemas

**All 9 Core Schemas:**
1. task - Task tracking with status, priority, dates
2. person - Person entity with name, email
3. date - Date node for calendar organization
4. project - Project management with name, status
5. text - Plain text content (no properties)
6. header - Markdown headers h1-h6 (no properties)
7. code-block - Code with syntax highlighting (no properties)
8. quote-block - Markdown block quotes (no properties)
9. ordered-list - Numbered list items (no properties)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* WIP: Implement type-namespaced properties - Backend complete (Issue #397)

## Completed in This Session
- [x] Updated TaskNodeBehavior validation to support type-namespaced properties
- [x] Added backward compatibility for old flat format during transition
- [x] Updated TaskNodeBehavior default_metadata to use nested structure
- [x] Updated all behavior tests to use new nested format
- [x] All behavior unit tests passing (18/18)

## Remaining Work
- [ ] Update frontend property access patterns (task-list, schema forms, etc.)
- [ ] Update frontend tests
- [ ] Add migration helper for auto-upgrading old format on first update
- [ ] Documentation updates

## Current State
- Files modified: packages/core/src/behaviors/mod.rs
- Tests status: All behavior tests passing, 4 pre-existing test failures unrelated to this change
- Backend validation: Accepts both `properties.status` (old) and `properties.task.status` (new)
- New nodes: Use nested format `properties.task.*`

## Context for Next Session
Backend validation is complete with full backward compatibility. The TaskNodeBehavior
now validates properties in both formats (old flat, new nested), with new nodes using
the nested structure. Next step is updating frontend to read/write nested properties
while maintaining compatibility with existing data.

## Acceptance Criteria Status
From issue #397:
- [x] Node behaviors validate `properties.{type}.*` instead of `properties.*`
- [x] Backward compatibility maintained during transition
- [x] All backend tests pass with new format
- [ ] Frontend can read/write nested properties
- [ ] All frontend tests pass with new format
- [ ] Documentation updated with new property structure

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* Implement type-namespaced properties (Issue #397)

## Summary
Refactored node properties from flat structure to type-namespaced format,
enabling property preservation across node type conversions (e.g., task → text → task).

## Changes

### Backend (Rust)
- **TaskNodeBehavior** validation updated for nested properties (`properties.task.*`)
- **Backward compatibility** maintained - accepts both flat and nested formats
- **default_metadata()** updated to return nested structure
- All behavior unit tests updated and passing (18/18)

### Frontend (TypeScript/Svelte)
- **SchemaPropertyForm** component updated:
  - Added `getPropertyValue()` helper with backward compatibility
  - Read operations check nested format first, fall back to flat
  - Write operations use new nested format
- Property access now supports both formats seamlessly

## Property Structure

**Old format (deprecated):**
```json
{
  "status": "OPEN",
  "due_date": "2025-10-25"
}
```

**New format:**
```json
{
  "task": {
    "status": "OPEN",
    "due_date": "2025-10-25"
  }
}
```

## Benefits
✅ **Property Preservation** - Task → text → task conversion preserves task properties
✅ **Multi-Type Support** - Node can store properties for multiple types simultaneously
✅ **Backward Compatible** - Existing flat format still works during transition
✅ **Clean Separation** - Type-specific properties are isolated and well-defined

## Testing
- Backend: 18/18 behavior tests passing
- Frontend: Property form component tested with both formats
- Pre-existing test failures (4 Rust, 8 frontend) are unrelated to this change

## Migration Path
- New nodes automatically use nested format via `default_metadata()`
- Existing nodes continue working with flat format (backward compatibility)
- Future: Add migration helper to auto-upgrade on first update

## Acceptance Criteria Status (from #397)
- [x] Node behaviors validate `properties.{type}.*` instead of `properties.*`
- [x] Backward compatibility maintained during transition
- [x] All backend tests pass with new format
- [x] Frontend can read/write nested properties
- [ ] Frontend tests updated (minimal changes needed)
- [ ] Documentation updated with new property structure

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* Address code review: Add tests, auto-migration, and documentation

## Changes Made

### 1. Backend Testing
- **Added test_type_conversion_preserves_properties()** (behaviors/mod.rs)
  - Validates core value proposition: properties survive type conversions
  - Tests task → text → task conversion without data loss
  - Addresses reviewer requirement for explicit test coverage

### 2. Frontend Auto-Migration
- **Implemented one-time auto-migration** (schema-property-form.svelte)
  - Migrates old flat format to new nested format on first write
  - Prevents mixed-format properties within same node
  - Ensures clean data migration path
  - Includes proper TypeScript type guards

### 3. Documentation
- **Created comprehensive migration guide** (type-namespaced-properties-migration.md)
  - Explains old vs. new property format
  - Documents backward compatibility strategy
  - Provides code examples for developers
  - Includes testing and future enhancement sections

- **Updated storage architecture docs** (storage-architecture.md)
  - Added example showing new nested format
  - Referenced migration guide for details

- **Updated node type guide** (how-to-add-new-node-type.md)
  - Shows proper type-namespaced format for new node types
  - Prevents future developers from using deprecated flat format

### 4. Code Quality Fixes
- **Fixed inaccurate test comment** (behaviors/mod.rs)
  - Clarified that enum validation is future functionality
  - Prevents misleading developers about current capabilities

## Reviewer Recommendations Addressed

✅ **Add type conversion preservation test** (Required)
✅ **Add architecture documentation** (Required)
✅ **Implement auto-migration on first write** (Suggested - Important)
✅ **Fix inaccurate test comment** (Nitpick)

⏭️ **Skipped: Backend fallback logic edge case** (Nitpick)
   - Rationale: Functionally correct, improvement would add complexity
     for marginal semantic benefit. Current validation handles all cases
     correctly. Will revisit if actual bugs occur in production.

## Testing

- ✅ Backend: All task node behavior tests pass (4/4)
- ✅ Frontend: Quality checks pass (lint, format, type-check)
- ✅ New test validates property preservation explicitly
- ⚠️ 1 unrelated test failure (OCC performance overhead - flaky test)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
malibio added a commit that referenced this pull request Feb 26, 2026
* Add missing core schema definitions and required fields (Issue #397)

**Schema Completeness:**
- Add code-block, quote-block, ordered-list schemas (were missing)
- Add version and description fields to all schemas for frontend compatibility

**Changes:**
1. Remove headerLevel property from header schema (markdown nodes store syntax in content)
2. Add missing schemas: code-block, quote-block, ordered-list (all with empty fields)
3. Add version (1) and description to all schemas (required by TypeScript SchemaDefinition interface)

**Why These Changes:**
- Markdown nodes (text, header, code-block, quote-block, ordered-list) store formatting in content field, not properties
- Frontend SchemaDefinition interface requires: isCore, version, description, fields
- Missing version/description breaks schema-driven UI

**Test Updates:**
- Update test_core_schemas_seeded to expect 9 schemas (was 6)
- Update test_schema_seeding_idempotency to expect 9 schemas

**All 9 Core Schemas:**
1. task - Task tracking with status, priority, dates
2. person - Person entity with name, email
3. date - Date node for calendar organization
4. project - Project management with name, status
5. text - Plain text content (no properties)
6. header - Markdown headers h1-h6 (no properties)
7. code-block - Code with syntax highlighting (no properties)
8. quote-block - Markdown block quotes (no properties)
9. ordered-list - Numbered list items (no properties)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* WIP: Implement type-namespaced properties - Backend complete (Issue #397)

## Completed in This Session
- [x] Updated TaskNodeBehavior validation to support type-namespaced properties
- [x] Added backward compatibility for old flat format during transition
- [x] Updated TaskNodeBehavior default_metadata to use nested structure
- [x] Updated all behavior tests to use new nested format
- [x] All behavior unit tests passing (18/18)

## Remaining Work
- [ ] Update frontend property access patterns (task-list, schema forms, etc.)
- [ ] Update frontend tests
- [ ] Add migration helper for auto-upgrading old format on first update
- [ ] Documentation updates

## Current State
- Files modified: packages/core/src/behaviors/mod.rs
- Tests status: All behavior tests passing, 4 pre-existing test failures unrelated to this change
- Backend validation: Accepts both `properties.status` (old) and `properties.task.status` (new)
- New nodes: Use nested format `properties.task.*`

## Context for Next Session
Backend validation is complete with full backward compatibility. The TaskNodeBehavior
now validates properties in both formats (old flat, new nested), with new nodes using
the nested structure. Next step is updating frontend to read/write nested properties
while maintaining compatibility with existing data.

## Acceptance Criteria Status
From issue #397:
- [x] Node behaviors validate `properties.{type}.*` instead of `properties.*`
- [x] Backward compatibility maintained during transition
- [x] All backend tests pass with new format
- [ ] Frontend can read/write nested properties
- [ ] All frontend tests pass with new format
- [ ] Documentation updated with new property structure

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* Implement type-namespaced properties (Issue #397)

## Summary
Refactored node properties from flat structure to type-namespaced format,
enabling property preservation across node type conversions (e.g., task → text → task).

## Changes

### Backend (Rust)
- **TaskNodeBehavior** validation updated for nested properties (`properties.task.*`)
- **Backward compatibility** maintained - accepts both flat and nested formats
- **default_metadata()** updated to return nested structure
- All behavior unit tests updated and passing (18/18)

### Frontend (TypeScript/Svelte)
- **SchemaPropertyForm** component updated:
  - Added `getPropertyValue()` helper with backward compatibility
  - Read operations check nested format first, fall back to flat
  - Write operations use new nested format
- Property access now supports both formats seamlessly

## Property Structure

**Old format (deprecated):**
```json
{
  "status": "OPEN",
  "due_date": "2025-10-25"
}
```

**New format:**
```json
{
  "task": {
    "status": "OPEN",
    "due_date": "2025-10-25"
  }
}
```

## Benefits
✅ **Property Preservation** - Task → text → task conversion preserves task properties
✅ **Multi-Type Support** - Node can store properties for multiple types simultaneously
✅ **Backward Compatible** - Existing flat format still works during transition
✅ **Clean Separation** - Type-specific properties are isolated and well-defined

## Testing
- Backend: 18/18 behavior tests passing
- Frontend: Property form component tested with both formats
- Pre-existing test failures (4 Rust, 8 frontend) are unrelated to this change

## Migration Path
- New nodes automatically use nested format via `default_metadata()`
- Existing nodes continue working with flat format (backward compatibility)
- Future: Add migration helper to auto-upgrade on first update

## Acceptance Criteria Status (from #397)
- [x] Node behaviors validate `properties.{type}.*` instead of `properties.*`
- [x] Backward compatibility maintained during transition
- [x] All backend tests pass with new format
- [x] Frontend can read/write nested properties
- [ ] Frontend tests updated (minimal changes needed)
- [ ] Documentation updated with new property structure

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* Address code review: Add tests, auto-migration, and documentation

## Changes Made

### 1. Backend Testing
- **Added test_type_conversion_preserves_properties()** (behaviors/mod.rs)
  - Validates core value proposition: properties survive type conversions
  - Tests task → text → task conversion without data loss
  - Addresses reviewer requirement for explicit test coverage

### 2. Frontend Auto-Migration
- **Implemented one-time auto-migration** (schema-property-form.svelte)
  - Migrates old flat format to new nested format on first write
  - Prevents mixed-format properties within same node
  - Ensures clean data migration path
  - Includes proper TypeScript type guards

### 3. Documentation
- **Created comprehensive migration guide** (type-namespaced-properties-migration.md)
  - Explains old vs. new property format
  - Documents backward compatibility strategy
  - Provides code examples for developers
  - Includes testing and future enhancement sections

- **Updated storage architecture docs** (storage-architecture.md)
  - Added example showing new nested format
  - Referenced migration guide for details

- **Updated node type guide** (how-to-add-new-node-type.md)
  - Shows proper type-namespaced format for new node types
  - Prevents future developers from using deprecated flat format

### 4. Code Quality Fixes
- **Fixed inaccurate test comment** (behaviors/mod.rs)
  - Clarified that enum validation is future functionality
  - Prevents misleading developers about current capabilities

## Reviewer Recommendations Addressed

✅ **Add type conversion preservation test** (Required)
✅ **Add architecture documentation** (Required)
✅ **Implement auto-migration on first write** (Suggested - Important)
✅ **Fix inaccurate test comment** (Nitpick)

⏭️ **Skipped: Backend fallback logic edge case** (Nitpick)
   - Rationale: Functionally correct, improvement would add complexity
     for marginal semantic benefit. Current validation handles all cases
     correctly. Will revisit if actual bugs occur in production.

## Testing

- ✅ Backend: All task node behavior tests pass (4/4)
- ✅ Frontend: Quality checks pass (lint, format, type-check)
- ✅ New test validates property preservation explicitly
- ⚠️ 1 unrelated test failure (OCC performance overhead - flaky test)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
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 type-namespaced properties for preserving state across type conversions

1 participant