fix: ExchangeStatus spec drift — intra_exchange_transfers_active + exchange_index_statuses (#460)#461
Merged
Merged
Conversation
…+ exchange_index_statuses (#460) Kalshi added two fields to the ExchangeStatus schema in place, without bumping the OpenAPI version (still 3.22.0), so the nightly strict contract suite flagged additive drift the day after the 5.0.0 sync. - Re-sync specs/openapi.yaml (38-line additive diff in the exchange region) - ExchangeStatus: add optional intra_exchange_transfers_active and exchange_index_statuses (NullableList, defaults to []) - New ExchangeIndexStatus model (per-index/shard status); register in _contract_map.py (required by test_contract_map_completeness) and export from kalshi + kalshi.models - Regression tests: per-index breakdown, optional-field defaults, null->[] - Bump version 5.0.0 -> 5.0.1 + CHANGELOG Closes #460 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Code Review — ExchangeStatus spec drift fix (#460)Overall: Clean, minimal patch. The implementation is well-scoped and follows project conventions. A few observations below, mostly minor. Correctness
Test Coverage
Pattern ConsistencyThe Suggestions (non-blocking)
SummaryNo correctness issues found. The spec changes, model, contract map entry, exports, tests, version bump, and changelog are all consistent with each other and with project conventions. Ready to merge. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #460.
The nightly Spec Drift Detection run promoted additive drift to an error one day after the 5.0.0 sync. Root cause: Kalshi mutated the
ExchangeStatusschema in place — adding two fields without bumping the OpenAPIversion(still3.22.0) — so yesterday's sync genuinely couldn't have caught it. Re-runningscripts/sync_spec.pyproduced a 38-line additive diff confined to the exchange region.All changes are additive and backward-compatible (no existing field changed).
Changes
specs/openapi.yaml— re-synced from upstream (newExchangeStatusfields + newExchangeIndexStatusschema).kalshi/models/exchange.pyExchangeStatus:+ intra_exchange_transfers_active: bool | None = None,+ exchange_index_statuses: NullableList[ExchangeIndexStatus] = [](optional; absent →[], null →[]).ExchangeIndexStatusmodel — per-index/shard status (exchange_index,exchange_active,trading_active,intra_exchange_transfers_active), all required per spec.kalshi/_contract_map.py— registeredExchangeIndexStatus(required bytest_contract_map_completeness).kalshi/__init__.py,kalshi/models/__init__.py— exportExchangeIndexStatus(import +__all__).tests/test_exchange.py— 3 sync + 1 async regression tests: per-index breakdown, optional-field defaults, null→[]coercion.5.0.0 → 5.0.1(pyproject.toml+__version__) + CHANGELOG entry.The hand-written
ExchangeIndexStatusmatches thedatamodel-code-generatoroutput exactly (verified viascripts/generate.py).Verification
test_additive_drift[ExchangeStatus]now passes.mypy kalshi/clean ·ruff checkclean.🤖 Generated with Claude Code