Repository navigation
fix: a settlement receipt beats a skip marker; false/0/no/none are not a skip - #96
Merged
Merged
Conversation
…t a skip Port of @blockrun/llm #92 (review of the TS #89 port): settlement_skipped() ignores a marker when the response proves the payment settled (PAYMENT-RESPONSE not failed with a transaction or a positive amount / extra.chargedAmount, or X-Payment-Receipt), writing the conflict to stderr; negative values are not a marker. blockrun.ai's free-fallback receipt ({success: true, transaction: ""}, no amount) stays skipped. 8 new helper tests fail on main.
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.
Port of the TypeScript SDK's #92 (from the review of its skip-booking change, which #94 here mirrors).
Problem
tx_log.settlement_skipped()reads anyX-Settlement-Skippedvalue, orX-Payment-Waivedwhen present, as "no money moved", and every booking site then books $0. Two gaps:X-Settlement-Skipped: false(or0,no,none) was a skip.Change
settlement_skipped()ignores a marker whose value isfalse/0/no/none.PAYMENT-RESPONSEthat did not fail (successis notfalse) and names a transaction (viadecode_settlement_header, which readstransaction/signature/ …) or a positiveamount/extra.chargedAmount, or a non-emptyX-Payment-Receipt. The conflict is written to stderr and the call is booked.PAYMENT-RESPONSE {success: true, transaction: ""}with no amount and noX-Payment-Receipt(blockrunchat/completions/route.ts~4742–4777). The pm empty-result and rpc unexecuted routes return before settling. So every skip sent today still books $0, and the real free-fallback shape is a test case.X-Payment-Waivedstill counts as a skip (presence is enough).Tests
tests/unit/test_settlement_skipped.py: these now book the quote: negative values; marker + receipt with a transaction / Solana signature /chargedAmount/amount; marker +X-Payment-Receipt. A conflict writes to stderr. A free-fallback receipt and a failed receipt stay skipped and write nothing.pytest tests/unit: 1431 passed. Twotest_solana_poll_ownership.pytests failed once under machine load (a different test each run), then passed 64/64 twice on rerun; they don't touch this code.