Repository navigation
Implement Namespace Enforcement for User-Defined Properties - #401
Conversation
…sue #400) ## Summary Enforces namespace prefixes for all user-defined schema properties to prevent future collisions with core NodeSpace features. This ensures user customizations are future-proof and will never conflict with platform evolution. ## Changes ### Phase 1: SchemaService Validation - Added namespace validation to `SchemaService::add_field()` (packages/core/src/services/schema_service.rs:170-198) - User/plugin fields MUST use namespace prefix: `custom:`, `org:`, or `plugin:` - Core fields must NOT use namespace prefix (simple names like `status`, `priority`) - Clear, actionable error messages guide users to correct format with examples ### Phase 2: MCP Tool Updates - Updated `add_schema_field` MCP handler documentation (packages/core/src/mcp/handlers/schema.rs:84-120) - Added comprehensive namespace requirement documentation - Updated MCP handler tests to use namespaced field names ### Testing - Added 6 new comprehensive unit tests for namespace validation: - `test_add_user_field_with_namespace` - Valid custom: prefix - `test_add_user_field_without_namespace_rejected` - Missing prefix rejected - `test_add_user_field_with_custom_namespace` - custom: namespace - `test_add_user_field_with_org_namespace` - org: namespace - `test_add_user_field_with_plugin_namespace` - plugin: namespace - `test_core_field_with_namespace_rejected` - Core field with prefix rejected - Updated MCP handler tests to use namespaced field names - All 42 schema-related tests passing ## Benefits - **Zero Collision Risk**: User properties guaranteed never to conflict with future core features - **Clear Ownership**: Easy to distinguish core vs user vs plugin properties - **Future-Proof**: NodeSpace can evolve without breaking user schemas - **Better UX**: Helpful error messages with concrete examples ## Example Usage ```rust // ✅ Valid - User field with namespace prefix let field = SchemaField { name: "custom:estimatedHours".to_string(), protection: ProtectionLevel::User, // ... }; service.add_field("task", field).await?; // ❌ Invalid - User field without prefix let field = SchemaField { name: "estimatedHours".to_string(), // Missing namespace protection: ProtectionLevel::User, // ... }; // Error: "User properties must use namespace prefix..." // ✅ Valid - Core field without prefix let field = SchemaField { name: "status".to_string(), protection: ProtectionLevel::Core, // ... }; // ❌ Invalid - Core field with prefix let field = SchemaField { name: "custom:status".to_string(), // Core shouldn't have prefix protection: ProtectionLevel::Core, // ... }; // Error: "Core properties cannot use namespace prefix..." ``` ## Acceptance Criteria Status - [x] SchemaService rejects user fields without namespace prefix - [x] SchemaService rejects core fields with namespace prefix - [x] MCP tools enforce namespace validation - [x] Clear error messages guide users to correct format - [x] Documentation updated with namespace guidelines - [x] Unit tests cover all validation cases 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Code Review: Namespace Enforcement for User-Defined PropertiesReview Type: Initial ReviewOverall Assessment: ✅ APPROVE - Exceptional implementation demonstrating advanced engineering discipline. Requirements CheckFrom Issue #400 Acceptance Criteria:
Key Strengths1. Exceptional Error MessagingThe error messages don't just report failure - they teach the user: "User properties must use namespace prefix to prevent conflicts with future core properties.
Valid namespaces:
- 'custom:estimatedHours' for personal custom properties
- 'org:estimatedHours' for organization-specific properties
- 'plugin:name:estimatedHours' for plugin-provided properties"Why This Matters: Users see their exact field name with correct namespace applied, understand why the rule exists, and get three copy-paste examples. This reduces support burden. 2. Comprehensive Test Coverage6 new tests covering all validation paths:
Engineering Principle: Boundary testing with both valid/invalid inputs and inverse validation. 3. Clean Architecture// Clear separation: Core validation → User validation → Protection check
if field.protection == ProtectionLevel::Core {
if field.name.contains(':') { return Err(...); }
} else {
let valid_prefixes = ["custom:", "org:", "plugin:"];
if !valid_prefixes.iter().any(|p| field.name.starts_with(p)) {
return Err(...);
}
}Engineering Principle: Guard clause pattern + fail-fast validation prevents invalid state. 4. Performance Optimized
5. Excellent Documentation
Code Quality Assessment
Optional Polish (Nitpicks)🟢 Nit: Consider Adding Docs Link to Error Messageformat!(
"User properties must use namespace prefix...\n\
See: https://github.com/your-org/nodespace/docs/architecture/schema-management",
field.name
)🟢 Nit: Test Naming ConsistencyStandardize on format:
Critical IssuesNone. 🎉 Net Positive ImpactThis change definitively improves code health by:
Recommendation✅ APPROVE - Ready to merge immediately. Review conducted by: Principal Engineer AI Reviewer (Pragmatic Quality Framework) |
Review Feedback Addressed: 1. 🟢 Add documentation link to namespace error message - Added reference to schema-management-implementation-guide.md - Provides path to deeper understanding for users - Enhances already-excellent error messaging 2. 🟢 Standardize test naming for consistency - Renamed test_add_user_field_with_namespace → test_add_user_field_with_custom_namespace_succeeds - Now follows consistent pattern: test_<action>_<scenario>_<outcome> - Improves test suite readability All changes are low-risk polish improvements with zero functional impact. All 42 schema-related tests passing. Addresses reviewer recommendations from PR #401. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Review Feedback Addressed ✅Successfully implemented both optional polish recommendations from the code review: Changes Made
Verification
Commit📦 Commit Engineering Assessment: Both recommendations were worth implementing - trivial effort with clear benefits for code quality and user experience. No downside or over-engineering concerns. |
* feat: Implement namespace enforcement for user-defined properties (Issue #400) ## Summary Enforces namespace prefixes for all user-defined schema properties to prevent future collisions with core NodeSpace features. This ensures user customizations are future-proof and will never conflict with platform evolution. ## Changes ### Phase 1: SchemaService Validation - Added namespace validation to `SchemaService::add_field()` (packages/core/src/services/schema_service.rs:170-198) - User/plugin fields MUST use namespace prefix: `custom:`, `org:`, or `plugin:` - Core fields must NOT use namespace prefix (simple names like `status`, `priority`) - Clear, actionable error messages guide users to correct format with examples ### Phase 2: MCP Tool Updates - Updated `add_schema_field` MCP handler documentation (packages/core/src/mcp/handlers/schema.rs:84-120) - Added comprehensive namespace requirement documentation - Updated MCP handler tests to use namespaced field names ### Testing - Added 6 new comprehensive unit tests for namespace validation: - `test_add_user_field_with_namespace` - Valid custom: prefix - `test_add_user_field_without_namespace_rejected` - Missing prefix rejected - `test_add_user_field_with_custom_namespace` - custom: namespace - `test_add_user_field_with_org_namespace` - org: namespace - `test_add_user_field_with_plugin_namespace` - plugin: namespace - `test_core_field_with_namespace_rejected` - Core field with prefix rejected - Updated MCP handler tests to use namespaced field names - All 42 schema-related tests passing ## Benefits - **Zero Collision Risk**: User properties guaranteed never to conflict with future core features - **Clear Ownership**: Easy to distinguish core vs user vs plugin properties - **Future-Proof**: NodeSpace can evolve without breaking user schemas - **Better UX**: Helpful error messages with concrete examples ## Example Usage ```rust // ✅ Valid - User field with namespace prefix let field = SchemaField { name: "custom:estimatedHours".to_string(), protection: ProtectionLevel::User, // ... }; service.add_field("task", field).await?; // ❌ Invalid - User field without prefix let field = SchemaField { name: "estimatedHours".to_string(), // Missing namespace protection: ProtectionLevel::User, // ... }; // Error: "User properties must use namespace prefix..." // ✅ Valid - Core field without prefix let field = SchemaField { name: "status".to_string(), protection: ProtectionLevel::Core, // ... }; // ❌ Invalid - Core field with prefix let field = SchemaField { name: "custom:status".to_string(), // Core shouldn't have prefix protection: ProtectionLevel::Core, // ... }; // Error: "Core properties cannot use namespace prefix..." ``` ## Acceptance Criteria Status - [x] SchemaService rejects user fields without namespace prefix - [x] SchemaService rejects core fields with namespace prefix - [x] MCP tools enforce namespace validation - [x] Clear error messages guide users to correct format - [x] Documentation updated with namespace guidelines - [x] Unit tests cover all validation cases 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Address review: Add docs link to error and standardize test naming Review Feedback Addressed: 1. 🟢 Add documentation link to namespace error message - Added reference to schema-management-implementation-guide.md - Provides path to deeper understanding for users - Enhances already-excellent error messaging 2. 🟢 Standardize test naming for consistency - Renamed test_add_user_field_with_namespace → test_add_user_field_with_custom_namespace_succeeds - Now follows consistent pattern: test_<action>_<scenario>_<outcome> - Improves test suite readability All changes are low-risk polish improvements with zero functional impact. All 42 schema-related tests passing. Addresses reviewer recommendations from PR #401. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
* feat: Implement namespace enforcement for user-defined properties (Issue #400) ## Summary Enforces namespace prefixes for all user-defined schema properties to prevent future collisions with core NodeSpace features. This ensures user customizations are future-proof and will never conflict with platform evolution. ## Changes ### Phase 1: SchemaService Validation - Added namespace validation to `SchemaService::add_field()` (packages/core/src/services/schema_service.rs:170-198) - User/plugin fields MUST use namespace prefix: `custom:`, `org:`, or `plugin:` - Core fields must NOT use namespace prefix (simple names like `status`, `priority`) - Clear, actionable error messages guide users to correct format with examples ### Phase 2: MCP Tool Updates - Updated `add_schema_field` MCP handler documentation (packages/core/src/mcp/handlers/schema.rs:84-120) - Added comprehensive namespace requirement documentation - Updated MCP handler tests to use namespaced field names ### Testing - Added 6 new comprehensive unit tests for namespace validation: - `test_add_user_field_with_namespace` - Valid custom: prefix - `test_add_user_field_without_namespace_rejected` - Missing prefix rejected - `test_add_user_field_with_custom_namespace` - custom: namespace - `test_add_user_field_with_org_namespace` - org: namespace - `test_add_user_field_with_plugin_namespace` - plugin: namespace - `test_core_field_with_namespace_rejected` - Core field with prefix rejected - Updated MCP handler tests to use namespaced field names - All 42 schema-related tests passing ## Benefits - **Zero Collision Risk**: User properties guaranteed never to conflict with future core features - **Clear Ownership**: Easy to distinguish core vs user vs plugin properties - **Future-Proof**: NodeSpace can evolve without breaking user schemas - **Better UX**: Helpful error messages with concrete examples ## Example Usage ```rust // ✅ Valid - User field with namespace prefix let field = SchemaField { name: "custom:estimatedHours".to_string(), protection: ProtectionLevel::User, // ... }; service.add_field("task", field).await?; // ❌ Invalid - User field without prefix let field = SchemaField { name: "estimatedHours".to_string(), // Missing namespace protection: ProtectionLevel::User, // ... }; // Error: "User properties must use namespace prefix..." // ✅ Valid - Core field without prefix let field = SchemaField { name: "status".to_string(), protection: ProtectionLevel::Core, // ... }; // ❌ Invalid - Core field with prefix let field = SchemaField { name: "custom:status".to_string(), // Core shouldn't have prefix protection: ProtectionLevel::Core, // ... }; // Error: "Core properties cannot use namespace prefix..." ``` ## Acceptance Criteria Status - [x] SchemaService rejects user fields without namespace prefix - [x] SchemaService rejects core fields with namespace prefix - [x] MCP tools enforce namespace validation - [x] Clear error messages guide users to correct format - [x] Documentation updated with namespace guidelines - [x] Unit tests cover all validation cases 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Address review: Add docs link to error and standardize test naming Review Feedback Addressed: 1. 🟢 Add documentation link to namespace error message - Added reference to schema-management-implementation-guide.md - Provides path to deeper understanding for users - Enhances already-excellent error messaging 2. 🟢 Standardize test naming for consistency - Renamed test_add_user_field_with_namespace → test_add_user_field_with_custom_namespace_succeeds - Now follows consistent pattern: test_<action>_<scenario>_<outcome> - Improves test suite readability All changes are low-risk polish improvements with zero functional impact. All 42 schema-related tests passing. Addresses reviewer recommendations from PR #401. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
* feat: Implement namespace enforcement for user-defined properties (Issue #400) ## Summary Enforces namespace prefixes for all user-defined schema properties to prevent future collisions with core NodeSpace features. This ensures user customizations are future-proof and will never conflict with platform evolution. ## Changes ### Phase 1: SchemaService Validation - Added namespace validation to `SchemaService::add_field()` (packages/core/src/services/schema_service.rs:170-198) - User/plugin fields MUST use namespace prefix: `custom:`, `org:`, or `plugin:` - Core fields must NOT use namespace prefix (simple names like `status`, `priority`) - Clear, actionable error messages guide users to correct format with examples ### Phase 2: MCP Tool Updates - Updated `add_schema_field` MCP handler documentation (packages/core/src/mcp/handlers/schema.rs:84-120) - Added comprehensive namespace requirement documentation - Updated MCP handler tests to use namespaced field names ### Testing - Added 6 new comprehensive unit tests for namespace validation: - `test_add_user_field_with_namespace` - Valid custom: prefix - `test_add_user_field_without_namespace_rejected` - Missing prefix rejected - `test_add_user_field_with_custom_namespace` - custom: namespace - `test_add_user_field_with_org_namespace` - org: namespace - `test_add_user_field_with_plugin_namespace` - plugin: namespace - `test_core_field_with_namespace_rejected` - Core field with prefix rejected - Updated MCP handler tests to use namespaced field names - All 42 schema-related tests passing ## Benefits - **Zero Collision Risk**: User properties guaranteed never to conflict with future core features - **Clear Ownership**: Easy to distinguish core vs user vs plugin properties - **Future-Proof**: NodeSpace can evolve without breaking user schemas - **Better UX**: Helpful error messages with concrete examples ## Example Usage ```rust // ✅ Valid - User field with namespace prefix let field = SchemaField { name: "custom:estimatedHours".to_string(), protection: ProtectionLevel::User, // ... }; service.add_field("task", field).await?; // ❌ Invalid - User field without prefix let field = SchemaField { name: "estimatedHours".to_string(), // Missing namespace protection: ProtectionLevel::User, // ... }; // Error: "User properties must use namespace prefix..." // ✅ Valid - Core field without prefix let field = SchemaField { name: "status".to_string(), protection: ProtectionLevel::Core, // ... }; // ❌ Invalid - Core field with prefix let field = SchemaField { name: "custom:status".to_string(), // Core shouldn't have prefix protection: ProtectionLevel::Core, // ... }; // Error: "Core properties cannot use namespace prefix..." ``` ## Acceptance Criteria Status - [x] SchemaService rejects user fields without namespace prefix - [x] SchemaService rejects core fields with namespace prefix - [x] MCP tools enforce namespace validation - [x] Clear error messages guide users to correct format - [x] Documentation updated with namespace guidelines - [x] Unit tests cover all validation cases 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Address review: Add docs link to error and standardize test naming Review Feedback Addressed: 1. 🟢 Add documentation link to namespace error message - Added reference to schema-management-implementation-guide.md - Provides path to deeper understanding for users - Enhances already-excellent error messaging 2. 🟢 Standardize test naming for consistency - Renamed test_add_user_field_with_namespace → test_add_user_field_with_custom_namespace_succeeds - Now follows consistent pattern: test_<action>_<scenario>_<outcome> - Improves test suite readability All changes are low-risk polish improvements with zero functional impact. All 42 schema-related tests passing. Addresses reviewer recommendations from PR #401. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
Closes #400