Repository navigation
feat(registration): add ModelRegistrationPayload and ModelDualRegistrationOutcome [OMN-913] - #212
Conversation
…ationOutcome [OMN-913] Add pure domain models for node registration workflows: - ModelRegistrationPayload: Typed payload for registration intents containing node identity, environment context, Consul projection, and PostgreSQL record fields - ModelDualRegistrationOutcome: Domain-level outcome of dual registration with status (success/partial/failed), individual operation results, and error information Key design decisions: - Pure data models with no I/O dependencies - Immutable (frozen=True) for thread safety - ONEX compliant (extra="forbid", from_attributes=True) - Full JSON serialization support Also adds consul_service_id and network_id to validation exceptions as these are external system identifiers (not ONEX UUIDs). Includes 45 unit tests covering construction, validation, serialization, and ONEX pattern compliance.
WalkthroughAdds a registration subpackage with two immutable Pydantic domain models, exposes the subpackage via package exports, expands the validator exemption list to include Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
Pull Request Review: feat(registration): ModelRegistrationPayload and ModelDualRegistrationOutcomeOverall Assessment ✅Status: LGTM with minor recommendations This is a well-crafted PR that adds foundational registration models for the ONEX registration workflow. The implementation demonstrates excellent adherence to ONEX patterns and project standards. Strengths 🌟1. Architecture Alignment ⭐
2. Code Quality 🏆
3. Documentation 📚
4. Test Coverage ✅
5. Integration Changes 🔧
Code Review DetailsModelRegistrationPayload (
|
| Pattern | ModelRegistrationPayload | ModelDualRegistrationOutcome |
|---|---|---|
frozen=True |
✅ | ✅ |
extra="forbid" |
✅ | ✅ |
from_attributes=True |
✅ | ✅ |
validate_assignment=True |
✅ | ✅ |
| Thread-safe | ✅ | ✅ |
| Pure domain model | ✅ | ✅ |
| Structured errors | N/A | ✅ |
| Documentation | ⭐ Exceptional | ⭐ Exceptional |
Testing Recommendations ✅
Current coverage is excellent. Consider adding (if not already covered in integration tests):
- Cross-field validation tests (if validators are added)
- Large payload stress tests (e.g., 1000+ consul_tags)
- Unicode handling tests (non-ASCII in error messages, tags)
Integration Impact ✅
No breaking changes - these are new models with no existing consumers.
Future integration points:
- Reducer nodes will emit
ModelRegistrationPayloadinModelIntentpayloads - Effect nodes will return
ModelDualRegistrationOutcomefrom registration operations - Orchestrator nodes will aggregate multiple
ModelDualRegistrationOutcomeinstances
Final Verdict ✅
APPROVED - This PR is ready to merge.
Highlights:
- ✅ Excellent code quality and adherence to ONEX patterns
- ✅ Comprehensive test coverage (783 lines)
- ✅ Outstanding documentation with diagrams and examples
- ✅ Clean architecture following Intent → Effect pattern
- ✅ Thread-safe, immutable, and type-safe
- ✅ No security or performance concerns
Minor recommendations are optional enhancements and should not block merging.
Reviewed by: Claude Sonnet 4.5 (ONEX Code Review)
Review Date: 2025-12-18
Correlation ID: Generated with Claude Code
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (3)
src/omnibase_core/models/registration/model_dual_registration_outcome.py (2)
145-171: Consider adding validation to ensurestatusis consistent with operation flags.The model allows construction of inconsistent states, e.g.,
status="success"withpostgres_applied=False. Adding amodel_validatorwould enforce domain invariants.🔎 Suggested validation:
from pydantic import model_validator class ModelDualRegistrationOutcome(BaseModel): # ... existing fields ... @model_validator(mode="after") def validate_status_consistency(self) -> "ModelDualRegistrationOutcome": """Ensure status matches the applied flags.""" both_succeeded = self.postgres_applied and self.consul_applied both_failed = not self.postgres_applied and not self.consul_applied if self.status == "success" and not both_succeeded: raise ValueError("status='success' requires both postgres_applied and consul_applied to be True") if self.status == "failed" and not both_failed: raise ValueError("status='failed' requires both postgres_applied and consul_applied to be False") if self.status == "partial" and (both_succeeded or both_failed): raise ValueError("status='partial' requires exactly one operation to succeed") return self
163-171: Consider constraining error message length.The
postgres_errorandconsul_errorfields lack length constraints. Very long error messages could impact storage and logging. Addingmax_lengthwould provide a safety bound.🔎 Suggested improvement:
postgres_error: str | None = Field( default=None, description="Error message if PostgreSQL registration failed.", + max_length=2000, ) consul_error: str | None = Field( default=None, description="Error message if Consul registration failed.", + max_length=2000, )tests/unit/models/registration/test_registration_models.py (1)
1-783: Excellent test coverage and code quality!This test file demonstrates outstanding testing practices with:
- Comprehensive coverage: 783 lines covering construction, validation, serialization, ONEX patterns, and edge cases
- Complete type annotations: All functions properly typed for mypy strict mode compliance
- Timeout protection: All test classes decorated with
@pytest.mark.timeout(5)- Parallel-safe: Tests use fixtures with no shared state, safe for pytest-xdist
- ONEX pattern compliance: Explicit verification of ConfigDict settings required by project guidelines
The PR description confirms both mypy strict mode and pyright basic mode compliance, meeting all coding guideline requirements.
Optional: Consider parameterized tests for validation
Several test methods test similar validation logic for different fields (e.g.,
test_environment_min_length,test_network_id_min_length,test_consul_service_id_min_length). These could optionally be parameterized to reduce duplication:@pytest.mark.parametrize("field,value", [ ("environment", ""), ("network_id", ""), ("consul_service_id", ""), ("consul_service_name", ""), ]) def test_min_length_validation( self, field: str, value: str, node_id: UUID, deployment_id: UUID, sample_record: BaseModel ) -> None: """Test minimum length validation for string fields.""" with pytest.raises(ValidationError) as exc_info: ModelRegistrationPayload( node_id=node_id, deployment_id=deployment_id, **{field: value, **{k: "test" for k in ["environment", "network_id", "consul_service_id", "consul_service_name"] if k != field}}, postgres_record=sample_record, ) assert field in str(exc_info.value)However, the current approach of separate test methods provides clearer failure messages and is easier to debug, so this refactor is purely optional.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
scripts/validation/validate-string-versions.py(1 hunks)src/omnibase_core/models/__init__.py(1 hunks)src/omnibase_core/models/registration/__init__.py(1 hunks)src/omnibase_core/models/registration/model_dual_registration_outcome.py(1 hunks)src/omnibase_core/models/registration/model_registration_payload.py(1 hunks)tests/unit/models/registration/__init__.py(1 hunks)tests/unit/models/registration/test_registration_models.py(1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{py,txt}
📄 CodeRabbit inference engine (CLAUDE.md)
Always use Poetry for Python package management and task execution. Never use pip or direct python commands. Use
poetry runfor all Python execution.
Files:
src/omnibase_core/models/registration/model_dual_registration_outcome.pytests/unit/models/registration/test_registration_models.pysrc/omnibase_core/models/registration/model_registration_payload.pysrc/omnibase_core/models/__init__.pyscripts/validation/validate-string-versions.pysrc/omnibase_core/models/registration/__init__.pytests/unit/models/registration/__init__.py
src/omnibase_core/**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
src/omnibase_core/**/*.py: Use structured error handling with ModelOnexError and EnumCoreErrorCode, never generic Exception. Use @standard_error_handling decorator to eliminate try/catch boilerplate.
Use protocol names for dependency injection (e.g.,container.get_service("ProtocolEventBus")) instead of concrete class names.
Implement 100% mypy strict mode compliance for all type annotations. All functions must have complete type annotations.
Use EnumNodeKind for architectural classification (EFFECT, COMPUTE, REDUCER, ORCHESTRATOR, RUNTIME_HOST) and EnumNodeType for specific implementation types (TRANSFORMER, AGGREGATOR, etc.). Do not confuse these two enums.
Do not use generic Exception or generic error types. Always inherit error handling from the error framework using ModelOnexError.
Use duck typing with protocols instead of isinstance checks. Services obtained from container are protocol implementations that should be used directly.
Avoid polling background jobs repeatedly. Use longer timeout values (e.g., 300 seconds) in single calls rather than repeated polling, or continue working on other tasks while waiting.
Maintain 100% mypy strict mode AND pyright basic mode compliance. Both checkers must pass in CI/CD pipeline.
Files:
src/omnibase_core/models/registration/model_dual_registration_outcome.pysrc/omnibase_core/models/registration/model_registration_payload.pysrc/omnibase_core/models/__init__.pysrc/omnibase_core/models/registration/__init__.py
src/omnibase_core/models/**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
Add
from_attributes=TruetoConfigDictin immutable value objects that are nested in other Pydantic models or used in parallel test execution (e.g., with pytest-xdist).
Files:
src/omnibase_core/models/registration/model_dual_registration_outcome.pysrc/omnibase_core/models/registration/model_registration_payload.pysrc/omnibase_core/models/__init__.pysrc/omnibase_core/models/registration/__init__.py
tests/**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
tests/**/*.py: Maintain minimum 60% code coverage for all tests. Run tests withpoetry run pytest tests/ --cov=src/omnibase_core --cov-report=term-missing.
Use parallel testing with pytest-xdist. Default: 4 parallel workers locally, 20 splits in CI. Each test must have timeout protection to prevent hangs.
Files:
tests/unit/models/registration/test_registration_models.pytests/unit/models/registration/__init__.py
🧠 Learnings (1)
📚 Learning: 2025-12-16T19:05:35.594Z
Learnt from: CR
Repo: OmniNode-ai/omnibase_core PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-16T19:05:35.594Z
Learning: Applies to src/omnibase_core/nodes/**/*.py : NodeReducer is FSM-driven state management using ModelIntent patterns for pure state transitions without direct side effects. NodeOrchestrator is workflow-driven coordination using ModelAction patterns with lease-based single-writer semantics.
Applied to files:
src/omnibase_core/models/registration/__init__.py
🧬 Code graph analysis (2)
tests/unit/models/registration/test_registration_models.py (2)
src/omnibase_core/models/registration/model_dual_registration_outcome.py (1)
ModelDualRegistrationOutcome(87-180)src/omnibase_core/models/registration/model_registration_payload.py (1)
ModelRegistrationPayload(88-193)
src/omnibase_core/models/registration/__init__.py (2)
src/omnibase_core/models/registration/model_dual_registration_outcome.py (1)
ModelDualRegistrationOutcome(87-180)src/omnibase_core/models/registration/model_registration_payload.py (1)
ModelRegistrationPayload(88-193)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (21)
- GitHub Check: Tests (Split 18/20)
- GitHub Check: Tests (Split 16/20)
- GitHub Check: Tests (Split 20/20)
- GitHub Check: Tests (Split 19/20)
- GitHub Check: Tests (Split 13/20)
- GitHub Check: Tests (Split 11/20)
- GitHub Check: Tests (Split 14/20)
- GitHub Check: Tests (Split 9/20)
- GitHub Check: Tests (Split 15/20)
- GitHub Check: Tests (Split 17/20)
- GitHub Check: Tests (Split 12/20)
- GitHub Check: Tests (Split 6/20)
- GitHub Check: Tests (Split 1/20)
- GitHub Check: Tests (Split 7/20)
- GitHub Check: Tests (Split 10/20)
- GitHub Check: Tests (Split 5/20)
- GitHub Check: Tests (Split 8/20)
- GitHub Check: Tests (Split 2/20)
- GitHub Check: Tests (Split 3/20)
- GitHub Check: Tests (Split 4/20)
- GitHub Check: claude-review
🔇 Additional comments (15)
scripts/validation/validate-string-versions.py (1)
110-115: LGTM! Exemptions correctly added for external system identifiers.The additions of
consul_service_idandnetwork_idto the EXTERNAL_SYSTEMS exemption set are appropriate. These fields represent external system constraints (Consul service IDs and VPC/subnet network identifiers) that should legitimately remain as strings rather than UUIDs, aligning with the newModelRegistrationPayloadmodel.src/omnibase_core/models/registration/model_registration_payload.py (1)
130-135: LGTM! ConfigDict follows coding guidelines.The configuration correctly includes
from_attributes=Trueas required by coding guidelines for immutable value objects that may be nested or used in parallel test execution.src/omnibase_core/models/registration/model_dual_registration_outcome.py (1)
131-136: LGTM! ConfigDict correctly configured.The immutable model configuration with
from_attributes=Truefollows the coding guidelines for value objects used in parallel test execution.src/omnibase_core/models/__init__.py (1)
31-31: LGTM!The
registrationsubpackage is correctly added to__all__in alphabetical order, following the established pattern of exposing domain module names without runtime imports.tests/unit/models/registration/__init__.py (1)
1-3: LGTM!The test package initializer follows project conventions with proper license header and descriptive docstring.
src/omnibase_core/models/registration/__init__.py (3)
1-86: Excellent documentation quality!The module docstring is comprehensive and well-structured, providing:
- Clear explanation of the registration domain models and their purpose
- Visual ASCII flow diagram showing the workflow
- Concrete usage examples with proper imports
- Design principles (pure, immutable, typed, serializable)
- References to related modules
This level of documentation will help developers understand the registration workflow at a glance.
88-93: LGTM!The imports are clean and properly structured, importing the two domain models from their respective submodules.
95-98: LGTM!The
__all__definition correctly exports the two domain models, making the public API explicit and clean.tests/unit/models/registration/test_registration_models.py (7)
1-34: LGTM!The file header and imports are well-organized. The module docstring clearly explains the test organization and timeout protection policy, which helps maintainers understand the test structure.
38-128: LGTM!The pytest fixtures are well-structured with:
- Complete type annotations for all fixtures
- Fresh UUID generation for each test (avoiding test interdependencies)
- Separate fixtures for different outcome scenarios (success, partial, failed)
- Proper encapsulation of test data setup
This fixture design supports parallel test execution with pytest-xdist.
134-328: LGTM!The
TestModelRegistrationPayloadclass provides comprehensive test coverage with:
- Timeout protection applied at class level
- Complete type annotations on all methods
- Thorough validation testing (required fields, min/max lengths, immutability, extra fields)
- Both positive and negative test cases
- Edge case coverage (empty strings, multiple tags, health check configurations)
The tests verify that the model correctly enforces its validation constraints.
333-448: LGTM!The
TestModelDualRegistrationOutcomeclass provides excellent coverage with:
- Timeout protection at class level
- Complete type annotations
- Tests for all three valid status values (success, partial, failed)
- Validation of optional error fields and their defaults
- Immutability and extra field rejection tests
The tests ensure the outcome model correctly represents all possible registration result states.
453-552: LGTM!The
TestSerializationRoundtripclass thoroughly tests JSON serialization with:
- Timeout protection applied
- Complete type annotations
- Round-trip consistency verification for both models
- UUID serialization as strings (JSON-compatible)
- Proper handling of nested Pydantic models with
serialize_as_any=True- Both
model_dumpandmodel_dump_jsonmethods testedThese tests ensure the models can be safely serialized for API responses and message queues.
557-644: LGTM!The
TestONEXPatternsclass validates critical ONEX pattern compliance with:
- Timeout protection applied
- Complete type annotations
- Explicit verification of all four ConfigDict settings (frozen, extra="forbid", from_attributes, validate_assignment)
- Practical tests of
from_attributesconstruction from arbitrary objectsThese tests are essential for ensuring the models meet the project's architectural requirements and support parallel test execution with pytest-xdist. As per coding guidelines,
from_attributes=Trueis required for immutable value objects used in parallel test execution.
649-783: LGTM!The
TestEdgeCasesclass provides excellent boundary and edge case coverage with:
- Timeout protection applied
- Complete type annotations
- UUID string coercion and validation
- Length constraint boundaries (min, max, over-max)
- Empty and unusual values (empty dicts, special characters)
- Large data handling (10,000 character error messages)
- Iterative testing of all valid literal values
These tests ensure the models handle edge cases gracefully and enforce validation constraints correctly.
Resolved all 4 code review issues (2 MAJOR, 2 NITPICK) from PR #212: MAJOR Fixes: - Fixed consul_health_check type from dict[str, str] to dict[str, Any] to support full Consul health check schema (booleans, integers, nested objects/arrays) Added ONEX_EXCLUDE comment with justification for dict[str, Any] usage - Fixed postgres_record type from BaseModel to ModelRegistrationRecordBase for mypy strict mode compliance (100% type safety with concrete types) NITPICK Enhancements: - Added @model_validator for status consistency in ModelDualRegistrationOutcome - Validates status="success" requires both operations succeeded - Validates status="failed" requires both operations failed - Validates status="partial" requires exactly one operation succeeded - Added max_length=2000 constraints to postgres_error and consul_error fields to prevent unbounded storage growth and improve logging performance Testing: - Added 16 new test cases (12 for validation, 4 for length constraints) - Fixed 1 existing edge case test to use correct flag combinations - All 60 registration model tests passing (100%) - Test execution time: 0.84s Code Quality: - mypy strict mode: 0 errors in 3 source files - pyright basic mode: 0 errors, 0 warnings - 100% ONEX pattern compliance verified - All pre-commit hooks passing Files Modified: - src/omnibase_core/models/registration/model_dual_registration_outcome.py (+77 lines) - src/omnibase_core/models/registration/model_registration_payload.py (+16 lines) - tests/unit/models/registration/test_registration_models.py (+348 lines) Co-authored-by: polymorphic-agent <polly@omninode.ai>
Code Review - PR #212: Registration ModelsSummaryThis PR introduces two new domain models for node registration workflows: ✅ Strengths1. Excellent Documentation ⭐
2. Strong Type Safety
3. Robust Validation
4. ONEX Pattern Compliance ⭐
5. Comprehensive Test Coverage (783 lines)
6. Clean Architecture
🔍 Observations & Suggestions1. Status Validator Logic (Minor Enhancement Opportunity)Location: The validator logic is correct but could be slightly more concise. However, the current implementation is perfectly fine and arguably more readable. This is a style preference, not a defect. 2. Validation Script UpdateLocation: ✅ Good addition of 3. Package Export IntegrationLocation: ✅ Properly added "registration" to 🎯 Best Practices Followed
🔒 Security Considerations✅ No security concerns identified
🚀 Performance Considerations✅ Good performance characteristics
Minor Observation:The 📊 Test Coverage783 lines of tests covering:
Estimated coverage: 95%+ for new code 🎓 Alignment with CLAUDE.md✅ Follows All Guidelines:
✅ Architecture Compliance:
📝 RecommendationsFor Merge:
Post-Merge (Optional):
🎯 Final Verdict✅ APPROVED This is high-quality work that:
The implementation is production-ready with no blocking issues. The suggestions above are minor enhancements and entirely optional. Congratulations on the solid contribution! 🎉 Reviewer: Claude (AI Code Review) |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/omnibase_core/models/registration/model_dual_registration_outcome.py(1 hunks)src/omnibase_core/models/registration/model_registration_payload.py(1 hunks)tests/unit/models/registration/test_registration_models.py(1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{py,txt}
📄 CodeRabbit inference engine (CLAUDE.md)
Always use Poetry for Python package management and task execution. Never use pip or direct python commands. Use
poetry runfor all Python execution.
Files:
tests/unit/models/registration/test_registration_models.pysrc/omnibase_core/models/registration/model_dual_registration_outcome.pysrc/omnibase_core/models/registration/model_registration_payload.py
tests/**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
tests/**/*.py: Maintain minimum 60% code coverage for all tests. Run tests withpoetry run pytest tests/ --cov=src/omnibase_core --cov-report=term-missing.
Use parallel testing with pytest-xdist. Default: 4 parallel workers locally, 20 splits in CI. Each test must have timeout protection to prevent hangs.
Files:
tests/unit/models/registration/test_registration_models.py
src/omnibase_core/**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
src/omnibase_core/**/*.py: Use structured error handling with ModelOnexError and EnumCoreErrorCode, never generic Exception. Use @standard_error_handling decorator to eliminate try/catch boilerplate.
Use protocol names for dependency injection (e.g.,container.get_service("ProtocolEventBus")) instead of concrete class names.
Implement 100% mypy strict mode compliance for all type annotations. All functions must have complete type annotations.
Use EnumNodeKind for architectural classification (EFFECT, COMPUTE, REDUCER, ORCHESTRATOR, RUNTIME_HOST) and EnumNodeType for specific implementation types (TRANSFORMER, AGGREGATOR, etc.). Do not confuse these two enums.
Do not use generic Exception or generic error types. Always inherit error handling from the error framework using ModelOnexError.
Use duck typing with protocols instead of isinstance checks. Services obtained from container are protocol implementations that should be used directly.
Avoid polling background jobs repeatedly. Use longer timeout values (e.g., 300 seconds) in single calls rather than repeated polling, or continue working on other tasks while waiting.
Maintain 100% mypy strict mode AND pyright basic mode compliance. Both checkers must pass in CI/CD pipeline.
Files:
src/omnibase_core/models/registration/model_dual_registration_outcome.pysrc/omnibase_core/models/registration/model_registration_payload.py
src/omnibase_core/models/**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
Add
from_attributes=TruetoConfigDictin immutable value objects that are nested in other Pydantic models or used in parallel test execution (e.g., with pytest-xdist).
Files:
src/omnibase_core/models/registration/model_dual_registration_outcome.pysrc/omnibase_core/models/registration/model_registration_payload.py
🧠 Learnings (3)
📚 Learning: 2025-12-16T19:05:35.594Z
Learnt from: CR
Repo: OmniNode-ai/omnibase_core PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-16T19:05:35.594Z
Learning: Applies to src/omnibase_core/models/**/*.py : Add `from_attributes=True` to `ConfigDict` in immutable value objects that are nested in other Pydantic models or used in parallel test execution (e.g., with pytest-xdist).
Applied to files:
tests/unit/models/registration/test_registration_models.py
📚 Learning: 2025-12-16T19:05:35.594Z
Learnt from: CR
Repo: OmniNode-ai/omnibase_core PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-16T19:05:35.594Z
Learning: Applies to src/omnibase_core/**/*.py : Implement 100% mypy strict mode compliance for all type annotations. All functions must have complete type annotations.
Applied to files:
src/omnibase_core/models/registration/model_registration_payload.py
📚 Learning: 2025-12-16T19:05:35.594Z
Learnt from: CR
Repo: OmniNode-ai/omnibase_core PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-16T19:05:35.594Z
Learning: Applies to src/omnibase_core/**/*.py : Do not use generic Exception or generic error types. Always inherit error handling from the error framework using ModelOnexError.
Applied to files:
src/omnibase_core/models/registration/model_registration_payload.py
🧬 Code graph analysis (3)
tests/unit/models/registration/test_registration_models.py (3)
src/omnibase_core/models/intents/model_registration_record_base.py (1)
ModelRegistrationRecordBase(67-146)src/omnibase_core/models/registration/model_dual_registration_outcome.py (1)
ModelDualRegistrationOutcome(87-251)src/omnibase_core/models/registration/model_registration_payload.py (1)
ModelRegistrationPayload(91-203)
src/omnibase_core/models/registration/model_dual_registration_outcome.py (1)
tests/unit/models/registration/test_registration_models.py (2)
node_id(40-42)correlation_id(52-54)
src/omnibase_core/models/registration/model_registration_payload.py (1)
src/omnibase_core/models/intents/model_registration_record_base.py (1)
ModelRegistrationRecordBase(67-146)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (21)
- GitHub Check: Tests (Split 12/20)
- GitHub Check: Tests (Split 19/20)
- GitHub Check: Tests (Split 13/20)
- GitHub Check: Tests (Split 8/20)
- GitHub Check: Tests (Split 9/20)
- GitHub Check: Tests (Split 15/20)
- GitHub Check: Tests (Split 17/20)
- GitHub Check: Tests (Split 2/20)
- GitHub Check: Tests (Split 20/20)
- GitHub Check: Tests (Split 6/20)
- GitHub Check: Tests (Split 16/20)
- GitHub Check: Tests (Split 14/20)
- GitHub Check: Tests (Split 11/20)
- GitHub Check: Tests (Split 18/20)
- GitHub Check: Tests (Split 1/20)
- GitHub Check: Tests (Split 7/20)
- GitHub Check: Tests (Split 3/20)
- GitHub Check: Tests (Split 4/20)
- GitHub Check: Tests (Split 10/20)
- GitHub Check: Tests (Split 5/20)
- GitHub Check: claude-review
🔇 Additional comments (17)
src/omnibase_core/models/registration/model_registration_payload.py (3)
1-89: Well-structured module documentation and imports.The module docstring provides excellent documentation including design pattern explanation, data flow diagram, thread safety considerations, and usage examples. The imports are minimal and appropriate.
133-203: Model configuration and field definitions follow ONEX patterns correctly.The
model_configcorrectly implements all required ONEX settings. Field definitions have appropriate type annotations, constraints, and descriptions. TheONEX_EXCLUDEcomment properly documents the exception forconsul_health_check. Thepostgres_recordfield correctly usesModelRegistrationRecordBaseas the type annotation.
206-206: Export is correctly defined.src/omnibase_core/models/registration/model_dual_registration_outcome.py (5)
1-84: Excellent module documentation and appropriate imports.The module docstring clearly explains the design pattern, outcome states, data flow, and thread safety. The
model_validatorimport is correctly included for the validation logic.
131-136: Model configuration follows ONEX patterns.
138-182: Field definitions are well-designed.The
statusfield correctly usesLiteral["success", "partial", "failed"]for type safety. Error fields have appropriatemax_length=2000constraints and default toNone. All fields have complete type annotations.
184-251: Status consistency validator is well-implemented.The
model_validatorcorrectly enforces domain invariants for all three status values. The logic is clear, the error messages are descriptive, and the comprehensive docstring with examples aids understanding.
254-254: Export is correctly defined.tests/unit/models/registration/test_registration_models.py (9)
1-34: Well-structured test module with comprehensive imports.The module docstring clearly explains what is being tested and the test organization. The imports are appropriate for testing Pydantic models.
36-129: Fixtures are well-designed for test isolation.Each fixture provides a fresh instance, ensuring test isolation. The
sample_recordfixture correctly demonstrates subclassingModelRegistrationRecordBase. All fixtures have complete type annotations and descriptive docstrings.
135-359: Comprehensive test coverage for ModelRegistrationPayload.Tests cover valid construction, default values, immutability, required fields, field constraints (min_length), extra field rejection, health check configuration, and multiple tags. Timeout protection is properly applied.
364-479: Good coverage for ModelDualRegistrationOutcome basic validation.Tests cover valid construction for all status values, immutability, required fields, invalid status rejection, extra field rejection, and default error field values. More detailed status consistency tests are appropriately separated into
TestStatusConsistencyValidation.
484-586: Serialization tests ensure data integrity across boundaries.Tests verify correct JSON serialization (UUIDs as strings), dictionary roundtrips via
model_dump/model_validate, and JSON string roundtrips. These are essential for ensuring models work correctly in distributed systems.
591-678: ONEX pattern compliance tests are thorough.Tests verify all required
ConfigDictsettings for both models and validatefrom_attributesconstruction. The attribute-based construction tests demonstrate the pattern works correctly.
683-877: Exhaustive status consistency validation tests.Tests cover all valid and invalid combinations of status values with
postgres_applied/consul_appliedflags. Error message assertions ensure the validator provides helpful feedback. This thorough coverage is essential for domain invariant enforcement.
882-1043: Edge case tests for boundary conditions are well-designed.Tests properly validate UUID string acceptance, max length constraints for
environment, empty health check dict handling, special characters in tags, and error message length boundaries. These boundary condition tests are valuable for ensuring robustness.
1076-1108: Final status values test provides good coverage.This test validates all three status values with their correct flag combinations in a single test, serving as a good integration check.
| def test_postgres_error_over_max_length_rejected( | ||
| self, node_id: UUID, correlation_id: UUID | ||
| ) -> None: | ||
| """Test postgres_error over 2000 chars raises ValidationError.""" | ||
| error_msg = "x" * 2001 | ||
| with pytest.raises(ValidationError) as exc_info: | ||
| ModelDualRegistrationOutcome( | ||
| node_id=node_id, | ||
| status="failed", | ||
| postgres_applied=False, | ||
| consul_applied=True, | ||
| postgres_error=error_msg, | ||
| correlation_id=correlation_id, | ||
| ) | ||
| assert "postgres_error" in str(exc_info.value) | ||
|
|
||
| def test_consul_error_over_max_length_rejected( | ||
| self, node_id: UUID, correlation_id: UUID | ||
| ) -> None: | ||
| """Test consul_error over 2000 chars raises ValidationError.""" | ||
| error_msg = "x" * 2001 | ||
| with pytest.raises(ValidationError) as exc_info: | ||
| ModelDualRegistrationOutcome( | ||
| node_id=node_id, | ||
| status="failed", | ||
| postgres_applied=True, | ||
| consul_applied=False, | ||
| consul_error=error_msg, | ||
| correlation_id=correlation_id, | ||
| ) | ||
| assert "consul_error" in str(exc_info.value) |
There was a problem hiding this comment.
Test cases have invalid status/flag combinations that will fail validation.
Both test_postgres_error_over_max_length_rejected and test_consul_error_over_max_length_rejected use status="failed" but with inconsistent applied flags (consul_applied=True or postgres_applied=True). The validate_status_consistency validator requires status="failed" to have both flags as False. These tests will raise ValueError from the status validator rather than testing the max_length constraint.
🔎 Proposed fix to use consistent status/flag combinations
def test_postgres_error_over_max_length_rejected(
self, node_id: UUID, correlation_id: UUID
) -> None:
"""Test postgres_error over 2000 chars raises ValidationError."""
error_msg = "x" * 2001
with pytest.raises(ValidationError) as exc_info:
ModelDualRegistrationOutcome(
node_id=node_id,
- status="failed",
+ status="partial",
postgres_applied=False,
consul_applied=True,
postgres_error=error_msg,
correlation_id=correlation_id,
)
assert "postgres_error" in str(exc_info.value)
def test_consul_error_over_max_length_rejected(
self, node_id: UUID, correlation_id: UUID
) -> None:
"""Test consul_error over 2000 chars raises ValidationError."""
error_msg = "x" * 2001
with pytest.raises(ValidationError) as exc_info:
ModelDualRegistrationOutcome(
node_id=node_id,
- status="failed",
+ status="partial",
postgres_applied=True,
consul_applied=False,
consul_error=error_msg,
correlation_id=correlation_id,
)
assert "consul_error" in str(exc_info.value)🤖 Prompt for AI Agents
In tests/unit/models/registration/test_registration_models.py around lines 1044
to 1074, the two tests set status="failed" but leave one of the applied flags
True which triggers the validate_status_consistency validator and masks the
max-length check; update both tests so that for status="failed" both
postgres_applied and consul_applied are False (e.g., postgres_applied=False and
consul_applied=False in both tests) so the ValidationError raised is for the
over-2000-character postgres_error/consul_error fields rather than the status
consistency.
Summary
ModelRegistrationPayloadfor encapsulating registration request data with validationModelDualRegistrationOutcomefor representing dual registry operation resultsTest plan
ModelRegistrationPayloadvalidation and edge casesModelDualRegistrationOutcomesuccess/failure scenariosSummary by CodeRabbit
New Features
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.