feat(mcp): support safe order reconciliation - #64
namtran1812 wants to merge 1 commit into
Conversation
|
Please enable commit signing by following the commit signing setup guide. If you have additional questions, reach out to #git-commit-signing. Reveal/hide commits without valid signatures |
Nostradamus Risk Rating — MediumThe PR modifies order submission and status-lookup logic in |
f784c26 to
3fd8999
Compare
Change Control Evidence CheckAuthorization — ❌ FailEvidence:
Testing —
|
|
Hi maintainers — this is ready for review. The local MCP test suite passes 296/296, along with typecheck and build. It looks like the remaining Semgrep/secret-scan workflows require maintainer approval to run, and the SDLC check is also looking for an internal Linear ticket. Happy to address any feedback or make changes if needed. Thanks! |
Summary
Improve order submission recovery in the MCP server by distinguishing definitive Gemini API rejections from ambiguous transport failures and allowing order status lookup by
client_order_id.This prevents the market-order fallback path from issuing a second order when the original submission's outcome is unknown.
Problem
An order submission can fail at the transport layer after the request has been sent but before the client receives a response. In that case, the client cannot safely assume that the order was rejected: Gemini may already have accepted it.
Previously, order submission errors were represented as generic
Errorinstances, and the market-order fallback identifiedInvalidOrderTypethrough error-message matching. The order-status tool also required the exchange-assignedorder_id, which may be unavailable when the submission acknowledgement is lost.Changes
GeminiApiErrorfor definitive non-2xx Gemini API responses.GeminiTransportErrorfor request-level transport failures.InvalidOrderTypeAPI responses./v1/order/statuslookup by eitherorder_idorclient_order_id.gemini_get_order_status.Gemini's
OrderStatusRequestsupportsclient_order_idas an alternative toorder_idand specifies that the two identifiers cannot be supplied together.Safety invariant
A transport failure during order submission does not imply that the order failed.
Accordingly, an ambiguous submission is never automatically replayed. Callers that supplied a
client_order_idcan instead reconcile the original submission throughgemini_get_order_statusbefore deciding whether another order should be placed.Validation
pnpm typecheckpnpm buildpnpm test— 296/296 passinggit diff --check