Repository navigation
feat(models): CDQA-08 — add ModelGoldenPath and golden_path to ModelTicketContract [OMN-2980] - #15
Conversation
…tContract - Create model_golden_path.py with ModelGoldenPath, ModelGoldenPathInput, ModelGoldenPathOutput, ModelGoldenPathAssertion (all frozen Pydantic models) - timeout_ms lives at ModelGoldenPath level only (single source of truth, default 30000) - schema_name on ModelGoldenPathOutput is optional (best-effort validation) - input_correlation_id_field and output_correlation_id_field are independent - All 6 assertion ops (eq, neq, gte, lte, in, contains) validated via Literal type - Add golden_path: ModelGoldenPath | None = None to ModelTicketContract (after emergency_bypass) - Export new models from models/__init__.py and top-level __init__.py - Update ticket_contract.template.yaml with commented golden_path example - Add pytest markers config (unit/integration/slow) to pyproject.toml - Add tests/unit/test_model_golden_path.py: 44 unit tests, all passing - check-schema-purity passes (10 files, no env/fs/network in new models) Part of CDQA-08 (OMN-2980), depends on CDQA-02 (OMN-2976).
- Wrap long description strings (E501) in model_golden_path.py - Fix helper function docstrings to imperative mood (D401) - Replace magic numbers with named constants (PLR2004) in test file
|
Caution Review failedThe pull request is closed. ℹ️ Recent review infoConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds four frozen Pydantic models to declare “golden path” input→output contract tests, exports them via package APIs, adds an optional Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
PR Review: CDQA-08 — ModelGoldenPath + golden_path field [OMN-2980]Overall this is a clean, well-structured addition. The design is sound, purity is maintained, and the test suite is comprehensive. I have a few issues worth addressing before merge, plus some minor observations. Issues1. Redundant
|
- Remove redundant model_config = ConfigDict(frozen=True) from all 4 ModelGoldenPath* classes; frozen=True class kwarg is sufficient and mypy flagged the ambiguity - Remove unused ConfigDict import - Fix AI-slop boilerplate docstring in models/__init__.py with specific content describing what the module exports
PR Review: CDQA-08 - ModelGoldenPath + golden_path on ModelTicketContractOverall this is a solid, well-scoped addition. The models are pure (D-008 compliant), the schema is backward-compatible, the test coverage is thorough, and the template update is clear. A few items worth addressing before merge: Issues1. frozen=True syntax inconsistency All existing models in the repo use model_config = ConfigDict(frozen=True). The new models switch to the class-keyword form. Both are valid Pydantic v2 syntax, but mixing the two styles inside a single package adds cognitive overhead. Recommend aligning with the existing pattern used throughout model_ticket_contract.py. 2. timeout_ms has no upper bound Only ge=1 is enforced. A value of sys.maxsize is technically valid per the schema but would make any runner hang indefinitely. Consider adding a reasonable ceiling, e.g. le=300_000 (5 minutes). 3. No cross-field validation between op and value types value: Any is necessary for flexibility, but operators gte/lte are semantically undefined when value is None, a list, or a boolean. A model_validator(mode=after) could catch the most obviously wrong combinations, or the description should explicitly document that type coherence is delegated to the runner. 4. infra defaults to real (live Kafka) Defaulting to live infrastructure means accidental omission of the infra key silently targets real Kafka in any environment. Consider whether mock is a safer default, or add a comment documenting why real is intentional. Minor Nits5. No min_length=1 on required string fields topic, fixture, and field currently accept the empty string, which is not a valid Kafka topic name or file path. Adding min_length=1 would catch empty-string inputs at validation time. 6. No validation on schema_name format schema_name is documented as a Pydantic model class name, but an empty string or a value that is not a valid Python identifier would pass. A simple @field_validator using str.isidentifier() would catch obvious mistakes early. 7. Overly indirected test constants _EXPECTED_ASSERTIONS_COUNT_1 = 1, _EXPECTED_ASSERTIONS_COUNT_2 = 2, etc. add indirection without clarity. The PLR2004 rule has a common exception for test code. Positives
The items I would want resolved before merge are #1 (style alignment with existing models), #3 (op/value contract clarification or validation), and #5 (min_length on required string fields). The rest are suggestions. |
Summary
Implements CDQA-08 (OMN-2980): extends
ModelTicketContractwith a formalgolden_pathfield for declaring event chain test contracts.src/onex_change_control/models/model_golden_path.py— introduces four frozen Pydantic models:ModelGoldenPathAssertion— single field assertion (6 ops: eq, neq, gte, lte, in, contains)ModelGoldenPathInput— input topic + fixture declarationModelGoldenPathOutput— output topic, optional schema name, assertionsModelGoldenPath— top-level declaration;timeout_mslives here only (single source of truth, default 30000ms)ModelTicketContractgainsgolden_path: ModelGoldenPath | None = Noneafteremergency_bypassmodels/__init__.pyand top-level__init__.pytemplates/ticket_contract.template.yamlupdated with commentedgolden_pathexampletests/unit/test_model_golden_path.py— 44 unit tests covering all spec requirements (126 total passing)pyproject.tomlgainsmarkersconfig forunit,integration,slowSpec compliance
frozen=True)timeout_msatModelGoldenPathlevel only (not in input/output)schema_name=Noneis valid (best-effort validation)input_correlation_id_fieldandoutput_correlation_id_fieldare independentmodel_validateModelTicketContractwith and withoutgolden_pathboth validcheck-schema-puritypasses (no env/fs/network in new models)Dependencies
Depends on CDQA-02 (OMN-2976, PR #400) — golden-path-validate skill defines the declaration format.
Test plan
poetry run pytest tests/unit/test_model_golden_path.py -v— 44 tests passpoetry run pytest tests/ -v— 126 tests passpoetry run check-schema-purity— 10 files, all passpre-commit run --all-files— all hooks passSummary by CodeRabbit
New Features
Tests
Chores