Repository navigation
fix(core): infer display precision from the numbers beancount samples - #3072
Merged
Merged
Conversation
This was referenced Nov 27, 2026
Contributor
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
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?
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
robcohen
force-pushed
the
fix/display-precision-sampling
branch
from
November 27, 2026 16:56
5df3347 to
ed4bc07
Compare
A compound cost {143.3998 # 4.61 USD} was sampled as a single 0 (its total
fell through to a zero default), a 0 dp sample nobody wrote, where
beancount samples 143.3998 and 4.61; and a balance tolerance
(4773.26 ~ 0.05 USD) was sampled beside its amount, where beancount
samples the amount only. Either could move a currency most common
precision, which queries and reports render amounts with. A component
left out of a compound cost is still not sampled.
Found by the semantic differential (scripts/compat-semantic-parity.py),
where it was the largest category.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
robcohen
force-pushed
the
fix/display-precision-sampling
branch
from
November 28, 2026 00:06
ed4bc07 to
e17c353
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
DisplayContext::from_directivesnow samples, for each currency, the numbers beancount's parser samples:{143.3998 # 4.61 USD}is a 4 dp and a 2 dp sample. It fell throughtotal().or_else(per_unit()).unwrap_or_default()to a single0, a 0 dp sample nobody wrote. A component left out ({# 5.60 USD}, held as a scale-0 zero) is still not sampled.4773.26 ~ 0.05 USDsamples the amount only, as beancount does.Why
Either could move a currency's most-common precision, which
rledger queryand the reports render amounts with, so the same ledger rendered with a different number of decimals than bean-query. Black-box probes of beancount 3.2.3 (options_map["dcontext"]):balance A 1 ~ 0.005 USDgives{0: 1};{1.234 # 5.6 USD}gives{3: 1, 1: 1};{# 5.6 USD}gives{1: 1}.It was the largest category of the semantic differential (#3071): 173 of 10,730 ledgers,
options|display_precision; minimized:With this PR the category drops to 5 (compat files whose
customamounts are a declared deviation's neighbours).No cache bump: neither cache archives the display context; it is rebuilt from the directives on every load.
How to test
cargo test -p rustledger-core --lib display_contextNew:
a_balance_tolerance_does_not_inform_precision,a_compound_cost_samples_both_written_numbers,an_omitted_compound_component_is_not_sampled,per_unit_and_total_costs_are_sampled_as_written. The core, query, loader, CLI and WASM suites pass.After #3071 merges, its manifest's
options|display_precisioncount is ratcheted withscripts/compat-semantic-parity.py --update(here or in a follow-up, whichever lands second).🤖 Generated with Claude Code