Repository navigation
Record each order's settlement once and deliver it after a failed credit - #373
Merged
Merged
Conversation
added 5 commits
October 2, 2026 15:17
Compose the account recovery and provider configuration change with the CILogon production deployment that landed on main. The merged deployment keeps main's variable names, its production enablement, its credential preflight that counts both entries without reading them, and its single example file, and adds the browser-approved CLI authentication settings, the issuer and URL checks, the configuration-update refresh of the unit and credentials, and the extended render fixture. The duplicate example file is dropped; the installed credential file name is unchanged. Go, SQL and documentation changes are those already on the branch; the render fixture passes inside the pinned provisioner against a retained package. GitHub issues #226, #223 and #227.
The payment decision of a terminal run was applied by an order-state write without a previous-state check and nothing recorded which run settled which order; when the write after the terminal report failed, the order stayed outstanding for good. Dispatcher schema 21 adds order_settlements, one immutable row per settled order (credit or refund, amount, currency, executor and run), and the pricing_rule column of transactions. The decision now lives in one place: the order moves from outstanding only through a conditional write, the settlement row and the earnings credit or chain refund commit with it, and a repeated or concurrent delivery leaves a settled order as it is. The maintenance loop settles terminal runs with a recorded exit code whose inline settlement failed, a bounded number per pass. A failed TEST run is refunded locally, moving nothing; TEST intents are still never refunded as a whole. Every intent records the name of the rule that priced it, and the API guide states that a USDC intent is a local record created without a chain call. GitHub issues #76, #77 and #78.
The executor's rejected-allocation test still asserted that the failed run's TEST order stays outstanding, the limitation the settlement change removes: a failed TEST run now refunds its order locally and no credit is invented. The assertion follows the new behaviour. GitHub issue #78.
ctfbruce
marked this pull request as ready for review
October 5, 2026 08:46
ctfbruce
marked this pull request as draft
October 5, 2026 09:00
The maintenance pass retried every outstanding order of a terminal run, including USDC refunds, which the terminal path sends inside the local transaction: a transfer whose response was lost or whose commit failed left the order outstanding and the next pass paid the buyer again. The pass also always listed the oldest rows, so a page of orders that keep failing kept every later order from being attempted. The pass now settles only wholly local outcomes, credits of any currency and TEST refunds, and defers a chain refund without touching the backend; chain refunds are attempted once from the terminal path until a durable transfer record takes them over. The listing continues after the last run the previous pass attempted and starts over once it is exhausted, so a failing order never blocks the ones after it. GitHub issue #78.
ctfbruce
marked this pull request as ready for review
October 5, 2026 09:21
This was referenced Oct 5, 2026
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.
Behaviour
An order's settlement is now decided in one place, recorded once, durably, and delivered reliably from the run's terminal result:
order_settlements: one immutable row per settled order (creditorrefund, amount, currency, executor and run), written in the same database transaction as the order's conditional state change and the executor's earnings credit or the chain refund. A repeated or concurrent delivery of the same decision leaves a settled order as it is.TESTorder of a failed run becomes refunded locally, moving nothing;TESTintents are still never refunded as a whole, so a refused batch keeps its intent spendable.transactions.pricing_rule,bw-s-ceil-ms-v1); rows written before the column read as the rule of the writing release. The API guide states that aUSDCintent is a local record created without any chain call.Proof
Outstandingafter the trigger was dropped and the dispatcher restarted; with this change the next maintenance pass credits it once.internal/dispatchertree andcmd/dispatcherpass under-race; generated bindings match the pinned generator.Upgrade
Dispatcher schema 21 is required: stop the dispatcher, back up the database and run the explicit upgrade (
-upgrade-database, ordeploy/ansible/upgrade-database.yml) before starting this build.Requires #364 (dispatcher schema 20) first; this branch is based on its head.
Limits
GitHub issues #76, #77 and #78.
Candidate CI
Run 37288440585 on 83de859: 16 of 16 lanes and
requiredsucceeded (an earlier head passed run 37284687485).