feat(sql): add catalog list and paid query sessions - #60
Draft
johnpmitsch wants to merge 2 commits into
Draft
Conversation
SQL Explorer can now list clusters without an account key, run a drawdown query with a SIWX Bearer session, and run an MPP session query. The MPP increment is the SQL challenge amount, not per_call.
5 tasks
sql_voucher_call parsed the payment-receipt header and then discarded it whenever the status check failed, and the caller only persisted the accepted cumulative on success. When the gateway banked a voucher and then failed the query body, local spend stayed behind the gateway's accepted cumulative. Re-signing that stale value is refused, so the channel could not be used again. sql_voucher_call and query_with_mpp_session now take &mut ChannelState and advance cumulative_spent whenever the voucher reached the gateway: on a non-2xx body, and on a lost response. A connect failure leaves the channel untouched because nothing was sent. Trailing the gateway strands the channel; leading it stays recoverable. Also states the SQL increment rule without live-traffic values, drops CLI flag wording from the X402_SQL_BASE_URL doc, removes get_schema from the x402 host list (it reads the configured base and sends the API key), and adds the SQL subheadings to the TOC.
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.
Adds SQL Explorer methods for a public catalog and two paid query lanes.
list_clustersreadsGET /sql/rest/v1/clusterson a keyless client.query_with_sessionsends a SIWX Bearer token and does not sign a per-request payment.query_with_mpp_sessionposts the SQL body to the MPP session route and advances the voucher by the SQL challenge amount, notper_call.Channel accounting
query_with_mpp_sessiontakes&mut ChannelStateand advancescumulative_spentwhenever the voucher reached the gateway — a non-2xx body and a lost response included. Only a connect failure, which never puts the voucher on the wire, leaves the channel untouched.The gateway refuses a re-signed stale cumulative, so a channel left behind the gateway cannot be used again, while one slightly ahead still works. Callers persist on every outcome, not just after a 200:
Previously the
payment-receiptheader was parsed and then discarded on any non-2xx, so a gateway that banked a voucher and then failed the query body stranded the channel.Test plan
cargo test -p quicknode-sdk --features rust,payments,payments-tempo --lib sql— 13 passedcargo test -p quicknode-sdk --features rust,payments,payments-tempo --lib— 331 passedcargo fmt --checkNew coverage: a 500 carrying a receipt advances the channel to the receipt value; a 402 with no receipt advances to the signed value; a failed probe leaves the channel unchanged.
Notes
cargo clippy --all-targetsreports three pre-existingE0308errors inexamples/streams.rsandexamples/webhooks_e2e.rs(stream compression, webhook templates). Confirmed present with this branch's changes stashed; untouched here.Bindings parity for the new SQL surface (Python/Node/Ruby) is not in this PR.