Skip to content

chore(compat): pin the last four unmasked BQL pairs to their verified causes - #2361

Merged
robcohen merged 1 commit into
mainfrom
fix/bql-remaining-mismatches-2358
Sep 20, 2026
Merged

robcohen merged 1 commit into
mainfrom
fix/bql-remaining-mismatches-2358

Conversation

@robcohen

Copy link
Copy Markdown
Member

The BQL suite has reported Real mismatches: 7 at every coverage level for a while (#2358). #2359 handled three of them. This handles the last four, and takes the count to zero.

All four extend blocks that already adjudicate the same mechanism on the same fixtures. Like #2359 they went unpinned only because order-by-expression postdates those blocks (#2215, for #2177).

Causes, reproduced rather than read off the diff

Run locally against beancount 3.2.3 and beanquery 0.2.0, with the corpus plugins at the commits compat.yml pins.

missing_prices (Python list). 11.7230 NESTHIGHER {{25.61 GBP, 2017-12-14}} makes beancount re-derive the total through a division, so the interpolated leg reports -25.61000000000000000000000000 where we report -25.61. This is the @@ re-multiplication mechanism the block above it already documents, in its {{total}} form.

long_short (Rust list). Upstream recomputes the gain:

gain = (p.cost.number - p.price.number) * abs(p.units.number)   # (1 - 1.50) * 100 = -50.00

The authored 1.50 carries scale 2, so the product does. Confirmed as the plugin's and not our interpolation's by running the fixture with the plugin line removed, where beancount itself interpolates -50 at scale 0. We keep the interpolated residual and change only the account.

cool_fund_example and some_fund_example (Rust list). Two causes on the same pairs, which the comment says explicitly rather than leaving implied. Posting by posting on some_fund_example, only three rows differ:

2024-02-12 Income:SomeFund:PnL    py -25.00        rs -25.00000000000000000000000001
2024-03-07 Assets:SomeFund:Total  py -656.2499999  rs -656.2500000
2024-03-07 Income:SomeFund:PnL    py -275.00000001 rs -274.9999998999999999999999999

The middle row is the #2018 1e-7 valuation drift this block documents. The other two are new: our valuation plugin COMPUTES the PnL amount that upstream leaves to interpolation, so ours carries dust. Filed as #2360. Worth noting there that BigDecimal escalation does not fix it, since the dust is already in the rounded price:

exact rationals (price kept as 1200/1125):      units = 375   pnl = 25
from the 28dp-rounded price, then exact math:   pnl = 25.0000000000000000000000000117

Verification

Ran the harness locally on the real corpus with both real tools, over these four fixtures plus the three from #2359:

Runs tested:         133  (file × query)
Known Python diffs:  45
Known Rust diffs:    14
Real mismatches:     0
Effective match:     133/133 (100%)

No stale-mask error, so every pinned pair still genuinely diverges.

Shown able to report "dirty": removing just the long_short pin gives Known Rust diffs: 13, Real mismatches: 1, naming that exact pair. --self-test also passes, and I asserted each new pair lands in the intended registry and not the other one, with a bogus pair checked absent.

Expected on the next full run: Real mismatches 4 to 0, Known Python diffs +1, Known Rust diffs +3, with Runs matching and the raw rate unchanged, since nothing about rledger changes here.

Refs #2358, #2360.

🤖 Generated with Claude Code

https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr

… causes

All four remaining `order-by-expression` mismatches extend blocks that already
adjudicate the same mechanism on the same fixtures. Like #2359, they went
unpinned only because the query postdates those blocks.

Each cause was reproduced locally against beancount 3.2.3 and beanquery 0.2.0
with the corpus plugins at the commits CI pins, rather than read off the diff:

- `missing_prices`: `{{25.61 GBP}}` makes beancount re-derive the total through
  a division, so it reports `-25.61000000000000000000000000` where we report
  `-25.61`. Python list, with the existing `@@` re-multiplication note.
- `long_short`: upstream RECOMPUTES the gain as `(cost - price) * abs(units)`,
  and the authored `1.50` carries scale 2. Removing the plugin line shows
  beancount itself interpolating `-50` at scale 0, so the scale is the
  plugin's, not our interpolation's. Rust list, with the existing note.
- `cool_fund_example` and `some_fund_example`: the 1e-7 valuation drift of
  #2018, plus a second cause on the same pairs. Our valuation plugin computes
  the PnL amount that upstream leaves to interpolation, so it carries dust
  (`-25.00` against `-25.00000000000000000000000001`). Filed as #2360 and
  called out in the pin comment, because one pin now covers two causes.

Refs #2358.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
@codecov

codecov Bot commented Sep 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions

Copy link
Copy Markdown
Contributor

✅ Compatibility Test Results

Metric Result
Check Compatibility 100%
BQL Compatibility 100% (raw 93%, 176 masked)
Full AST Match 100%
Total Files 813
What's tested
  • Check: Exit codes and error counts match bean-check
  • BQL: Query results match bean-query
    The headline is the EFFECTIVE rate, after pairs where beanquery
    itself is wrong are masked. raw is the same run with nothing
    masked. A widening gap means the registry grew, not that rledger
    changed.
  • Files: ~800 test files downloaded from 10+ beancount repositories

Full results available in workflow artifacts

@robcohen
robcohen merged commit e53b176 into main Sep 20, 2026
43 checks passed
@robcohen
robcohen deleted the fix/bql-remaining-mismatches-2358 branch September 20, 2026 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant