Repository navigation
Preserve commodity-swap gains in the journal oracle - #10
Merged
Merged
Conversation
The reader discarded lot annotations attached to exchange costs, leaving inferred gains absent from the balancing pool. Retain the cost-side lot and the original exchanged-commodity contribution while booking the exact common-currency gain within the posting's own group. Normalize total-lot precision on either side so fractional inferred amounts retain their precision. The rules cite the Ledger regressions 3314_lot_gains and 3314_swap_total prepared for PR 3317. The Nix oracle build passed 1,086 jobs. All 34 focused journals and all 3,837 comparable journals in the full corpus agreed with Ledger; both detector controls passed and no unexpected skip bins were populated.
jwiegley
added a commit
to ledger/ledger
that referenced
this pull request
Nov 5, 2026
Preserve main's exact lot-gain calculations and rounding-residue bounds while retaining independent real and balanced-virtual posting groups. Cover sub-unit swap gains and total-lot precision in both groups. Pin the companion oracle correction through the flake so the new regressions participate in the full semantic comparison. Preserve the upstream removal of the lean submodule and its current parser fixes. Oracle: ledger/ledger-semantics#10
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.
The journal reader discarded lot annotations attached to an exchange cost,
so it omitted inferred gains when a commodity swap's two lots shared a base
currency. Exchanging 10 BTC at a 100 EUR basis for 20 ETH at a 50.02 EUR basis
produced no balancing offset in the oracle; Ledger correctly infers -0.4 EUR.
Retain the cost-side lot, keep the exchanged commodity's original balancing
contribution, and add the exact gain within the posting's own real or balanced
virtual group. Normalize total-lot precision on either side so fractional
inferred amounts retain their recovered precision. The rules cite the C++
implementation and the regression witnesses prepared for ledger/ledger#3317.
Validation: the Nix oracle build passed all 1,086 jobs, and all 34 focused
journals agreed with Ledger. Across the full corpus, all 3,837 comparable
journals agreed with the current Ledger integration, with no mismatches or unexpected
skips. The planted-defect and pristine-control detector checks also passed.
The correction is based on oracle revision
8342e12, preserving the quotedcommodity, bare format symbol, and account-header fixes. The downstream PR ledger/ledger#3317 will
consume it through the flake input; the removed submodule is not restored.