Repository navigation
chore(compat): exclude google_purchases _invalid fixture (closes #989) - #1024
Merged
Merged
Conversation
…rect Issue #989 reported six BQL value-diff mismatches. Investigation found that five no longer reproduce (resolved by #986/#987/#988). The single remaining case is an upstream beanquery bug: bean-query's FIRST(balance) returns different values for the same query and data depending on which other aggregators are in the SELECT list. The `balance` column mutates a shared accumulator and FIRST short-circuits operand evaluation after the first row, leaving the accumulator stale for later groups. Filed upstream as beanquery#279. rledger's pre-computed-per-row balance is correct and SELECT-shape-independent. Excluding the fixture from compat closes the harness divergence. The file is a deliberately-malformed `_invalid_journal` test fixture from jbms/beancount-import; excluding it loses no real coverage. Closes #989. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the compatibility test exclusion list to skip a specific beancount-import _invalid_journal fixture where rledger’s behavior is correct and the observed mismatch is attributed to an upstream beanquery bug in FIRST(balance) evaluation.
Changes:
- Added a new exclusion entry for
beancount-import/testdata_source_google_purchases_test_invalid_journal.beancount. - Documented the upstream
beanquerybug and rationale for excluding (rather than matching the buggy behavior).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
|
| Metric | Result |
|---|---|
| Check Compatibility | 99% |
| BQL Compatibility | 74% |
| Full AST Match | 99% |
| Total Files | 785 |
What's tested
- Check: Exit codes and error counts match
bean-check - BQL: Query results match
bean-query - Files: ~800 test files downloaded from 10+ beancount repositories
Full results available in workflow artifacts
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.
Summary
Issue #989 reported six BQL value-diff mismatches between rledger and bean-query. Investigation found:
first-balance-by-monthontestdata_source_google_purchases_test_invalid_journal.beancount. rledger is correct here — the divergence is an upstream beanquery bug.The upstream bug
bean-query's
FIRST(balance)returns different values for the same query and data depending on which other aggregators are in the SELECT list:Root cause:
balancemutates a shared accumulator on every call (beanquery/sources/beancount.py).FIRST.updateshort-circuits operand evaluation after the first row of each group, sobalance(context)is not called for later rows, leaving the accumulator stale for subsequent groups. This violates the documented contract thatbalanceis "automatically calculated based on the previous selected rows" — the rows ARE selected, but the implementation only updates the accumulator for rows where the operand was actually evaluated.rledger pre-computes
ctx.balanceper row in posting collection (crates/rustledger-query/src/executor/evaluation.rs:301-308); the column evaluator is a pure read. FIRST and LAST always agree on single-row groups, and the result is independent of which other aggregators are queried.Filed upstream as beanquery#279.
Why exclude rather than fix
The fixture is a deliberately-malformed
_invalid_journaltest file fromjbms/beancount-import— its purpose is to test how the project's importers handle bad input, not to be a balanced ledger. Excluding it from compat loses no real coverage. Matching bean-query here would mean reproducing an upstream bug.Files changed
tests/compatibility/exclusions.toml— one new entry with full investigation context inline.Closes #989.
🤖 Generated with Claude Code