You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes a non-null assertion bug in Probable's WebSocket order book resolver queueing (issue #264) by extracting queue initialization into a getOrderBookQueue() helper. Also carries forward two generator fixes from #509: Python SDK class naming for underscore-delimited exchanges (Polymarket_us -> PolymarketUS), and hardcoded fetchOrderBook special-case generation in both SDK client generators.
Blast Radius
Core: probable/websocket.ts only -- no other exchanges touched
Python SDK: _exchanges.py, __init__.py, generate-python-exchanges.js -- class name change is a breaking change for Python consumers using pmxt.Polymarket_us
Both SDKs: generate-client-methods.js scripts -- adds fetchOrderBook special-case override to generators (output matches what is already in the committed client files)
Docs: API_REFERENCE.md in both SDKs -- updated to reflect FetchOrderBookParams type and close method (replacing stale testDummyMethod reference)
Test Results
Build: NOT RUN (worktree has no node_modules, npm install was blocked by permissions)
Unit tests: NOT RUN locally
CI checks: ALL PASS (6/6 -- exchange drift, SDK sync, API reference, compliance)
Findings
Polymarket_us -> PolymarketUS is a breaking change for Python consumers (sdks/python/pmxt/_exchanges.py:368, __init__.py:20). Any user doing import pmxt; client = pmxt.Polymarket_us() will get an ImportError. The exchange_name="polymarket_us" wire string is unchanged so the sidecar still works, but the public API surface changed. This may warrant a deprecation alias or a semver minor/major bump depending on project policy. Note: the old name Polymarket_us is not Pythonic (PEP 8), so the rename to PolymarketUS is correct -- but it is still a breaking symbol rename.
The test is a source-text regex guard, not a behavioral test (core/test/pipeline/probable-websocket-resolvers.test.ts:5-12). It asserts that the pattern orderBookResolvers.get(...)! does not appear in the source file. This prevents regression of the specific anti-pattern but does not verify the runtime fix. Acceptable for a regression guard, but worth noting.
Seven other websocket files have the identical unsafe pattern (baozi, opinion, kalshi [x2], myriad, polymarket, gemini-titan). These are out of scope for this issue ([non-null] probable/websocket.ts: unsafe Map.get()! assertion on orderBookResolvers #264 is Probable-specific), but the same Map.get()! bug exists there. This is informational, not a blocker.
The fetchOrderBook generator special-case duplicates existing hand-maintained logic (sdks/python/scripts/generate-client-methods.js:390-422, sdks/typescript/scripts/generate-client-methods.js:384-419). The generated output matches what is already committed in client.py and client.ts, so this is a no-op change that ensures future regeneration produces the same output. No issues found.
The toClassName regex change (core/scripts/generate-python-exchanges.js:33) splits on both - and _, and special-cases us -> US. This correctly handles polymarket_us -> PolymarketUS, kalshi-demo -> KalshiDemo, and gemini-titan -> GeminiTitan. No other exchange names contain underscores, so the blast radius is limited to polymarket_us.
PMXT Pipeline Check
Field propagation (3-layer): N/A (no new fields)
OpenAPI sync: N/A (no BaseExchange.ts changes)
Type safety: OK (non-null assertion removed, no any introduced)
Semver Impact
minor (or patch depending on policy) -- the core fix is patch-level, but the Python class rename Polymarket_us -> PolymarketUS is a breaking symbol change for Python SDK consumers. If any users reference Polymarket_us by name, they will break on upgrade. If the project treats SDK class names as part of the public API, this is technically a major change -- but given that Polymarket_us was likely a bug in the first place (non-PEP-8), treating it as minor with a changelog note seems reasonable.
Risk
Local build and tests were not run (CI passed all 6 checks)
The Python class rename has no deprecation alias -- existing pmxt.Polymarket_us users will break silently on upgrade
The 7 other websocket files with the same Map.get()! pattern remain unfixed
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
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.
Fixes #264
Changes
orderBookResolvers.get(...)!push path with an explicit queue initializer.Verification
npm --workspace=pmxt-core test -- --runTestsByPath test/pipeline/probable-websocket-resolvers.test.ts --runInBandnpx tsc -p core/tsconfig.json --noEmitnode core/scripts/check-exchange-drift.jsnode sdks/typescript/scripts/generate-client-methods.js; git diff --exit-code sdks/typescript/pmxt/client.tsnode sdks/python/scripts/generate-client-methods.js; git diff --exit-code sdks/python/pmxt/client.pypython -m py_compile sdks/python/pmxt/_exchanges.py sdks/python/pmxt/__init__.py sdks/python/pmxt/client.pygit diff --check