Repository navigation
fix(loader): merge operating_currency across includes in beancount's breadth-first order, each currency once - #3041
Merged
Merged
Conversation
Contributor
📊 Benchmark Results
vs base, measured in this run
A difference counts only when it clears the combined spread of the two measurements, per shape (2σ: What do these numbers mean?
|
Contributor
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…breadth-first order, each currency once (#3038) beancount 3.2.3 parses its files breadth first and `aggregate_options_map` merges `operating_currency` in that order, `uniquify`d (first occurrence wins, the top-level file's own repeats included). rledger merged it depth first and kept repeats: `main` (MMM) including `x` (XXX, including `z` ZZZ) then `y` (YYY) gave [MMM, XXX, ZZZ, YYY] against [MMM, XXX, YYY, ZZZ], and USD in main and an include gave [USD, USD, EUR] against [USD, EUR]. Auditing the other options beancount aggregates across files: `display_precision` is merged into the top-level file's display context with `DisplayContext::update_from`, which keeps a fixed precision, so the top-level file's value wins; rledger let the last file read win (an include's USD:0.001 rendered 1.23456 USD as 1.235 where bean-query gives 1.23). `insert_pythonpath` becomes a sorted set there (no order) and has no effect in rledger. Included plugins are ignored by beancount and run by rledger deliberately; their order is unchanged. - `Options::set_in_file_at` records each merged option's values with its file; `Options::merge_across_files(ranks)` is the one merge, called by `Loader::load` over `SourceMap::parse_ranks` before the display context and the cache see the options. Every surface (CLI, LSP, WASM, FFI) reads the loader's options or the cache's merged copy. - `apply` lists a repeated operating currency once, for options set without the loader. - Loader CACHE_VERSION 77 -> 78 (cached values change), WASM pin 78, WASM CACHE_VERSION 137 (135, 136 taken by #3039, #3040). - Tests: unit tests for the merge; loader tests for the issue's trees, a duplicate include, a disk glob and a cache round trip, all checked against bean-check 3.2.3; drift guards across the loader, WASM `Ledger` (and restored), ffi-wasi, the LSP, and the CLI cold and on a cache hit (`report returns` currency, `query` precision). Closes #3038 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…docs Co-Authored-By: Claude Opus 5.5 <[email protected]>
robcohen
force-pushed
the
fix/operating-currency-order
branch
from
November 26, 2026 05:52
49c6bd2 to
adcf5ad
Compare
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.
What changed
beancount 3.2.3 parses included files breadth first and merges
option "operating_currency"in that order, dropping repeats (loader.aggregate_options_map→misc_utils.uniquify, first occurrence wins, the top-level file's own repeats included). rledger merged depth first and kept repeats.mainMMM →xXXX (→zZZZ),yYYY[MMM, XXX, YYY, ZZZ][MMM, XXX, ZZZ, YYY]mainUSD, USD, includea(USD, GBP, EUR), EUR[USD, EUR, GBP][USD, USD, EUR, USD, GBP, EUR]cincludesb, whichmainalso includes)[AAA, BBB, CCC][AAA, CCC, BBB]Audit of the other options merged across files
display_precisionalso differed. beancount merges each file's display context into the top-level file's withDisplayContext::update_from, and that keeps a fixed precision, so the top-level file's value wins. rledger applied values last-wins in depth-first order, so an include'sUSD:0.001overrode the main file'sUSD:0.01:1.23456 USDrendered as1.235 USD, where bean-query gives1.23 USD. This is fixed. For a currency that only included files fix, beancount 3.2.3 crashes inside that merge (_FixedPrecisionContexthas nofractional_dist). rledger takes the value from the first file in parse order.insert_pythonpath: beancount turns it into a sorted set of directories, so order cannot matter, and the option has no effect in rledger. Unchanged.inferred_tolerance_default,documents, and every other option are taken from the top-level file only, in both beancount and rledger. Unchanged.options_map["plugin"]comes from the top file only; verified with bean-check). rledger runs them on purpose, so beancount gives no reference order. Their order (file id, depth first) is unchanged and still matches the LSP'sview_plugins.How
Options::set_in_file_atrecords the values of the merged options (MERGED_ACROSS_FILES) together with the file each came from.Options::merge_across_files(ranks)is the only place the merge happens.Loader::loadcalls it overSourceMap::parse_ranks(fix(loader): break cross-file ties in beancount's breadth-first include order #3037) before the display context is built and before the cache archives the options. The CLI, LSP, WASM and FFI all read the loader's options, or the merged copy from the cache.applydrops a repeated operating currency, which covers options set without the loader.CACHE_VERSIONgoes 77 → 78 because cached values change. The WASM pin moves to 78 and WASMCACHE_VERSIONto 137 (135 and 136 are taken by fix(booking): prorate never rounds a nonzero half-floor share to zero #3039 and fix(parser): an orphan indented line reports beancount's indent error and each invalid token on it; pin the tag-line deviation #3040).How to test
The drift guards cover the loader, the WASM
Ledger(fresh and restored from cache), ffi-wasiload_file_with_fs(the component's options), the LSPLedgerState, and the CLI both cold and on a cache hit (thereport returnsdefault currency andqueryprecision). I checked every expected value againstbeancount.loader.load_file/ bean-check 3.2.3.Closes #3038
🤖 Generated with Claude Code