feat(gateway)!: unify inclusive token accounting and explicit caps - #50
Merged
Conversation
tangletools
approved these changes
Sep 9, 2026
tangletools
left a comment
There was a problem hiding this comment.
Reviewed the changed dispatch, settlement, reservation, and recovery paths at e6a98ac. Inclusive input/output totals own new charges; explicit detail caps remain enforced. Historical additive records retain their original arithmetic, and incomplete historical receipts now fail closed in both payment recovery and A2A finalization. Reviewed the 16-versus-22-unit settlement and acknowledgement-loss regressions, plus the historical missing-detail correction. Reported validation: 488 tests, typecheck/build, and both configured CI runtime lanes pass. Live payment failure receipt propagation remains a separate tracked follow-up; this change does not claim that proof.
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.
Input and output usage now represent inclusive provider totals, so reasoning and tool details are not charged twice.
The gateway omits separate detail caps unless the host explicitly supplies them; explicit caps, including zero, still require measured usage and enforcement.
New quotes use inclusive totals and the provider-cost ceiling.
Historical payment outbox and A2A finalization records retain their original additive accounting and settlement amounts.
New records persist an inclusive accounting basis.
Incomplete historical receipts fail rather than substituting zero for missing details.
The README documents the 0.11.0 adapter migration and historical-record constraints.
Validation: 488 tests pass under Node 24.18.0 and 22.22.2; typecheck and build pass.
Real payment/recovery fixtures cover inclusive settlement, explicit caps, omitted details, acknowledgement loss, repeated recovery, and incomplete historical receipts.
Three deliberate mutations fail: invented detail caps, reinterpretation of historical accounting, and double billing of detail counts.