Repository navigation
chore(baselines): regenerate for corpus drift, and cover {{total}} reductions end to end - #2339
Merged
Merged
Conversation
Two manifest entries moved upstream and the nightly drift check has been reporting it since 2026-09-14 (#2307): - `apyb-financeiro/financeiro_2026-08.beancount` is new and had no parser-output coverage at all since it appeared upstream; - `apyb-financeiro/financeiro_main.beancount` changed content upstream, so a different output hash is expected. Confirmed by comparing the recorded source hash against `sha256sum` before regenerating: 1782cc57... became 465d1740.... Nothing else moved: one added line, one changed line, which is what a corpus-only drift should look like. A third changed line would have meant our own parser output shifted on files nobody touched. The fetch reported 3 repository clone failures (under its abort threshold), so before regenerating I checked that every path in the manifest was still present on disk -- zero missing. A partial corpus would otherwise drop baselines for the files it failed to clone, which the script's MIN_CORPUS_SIZE=100 floor is too coarse to catch. 735 entries in, 736 out, 736 files on disk. `tests/baselines/cst-corpus.manifest` is deliberately untouched: `regen-corpus-baselines.sh` does not write it, since that baseline belongs to the parallel CST parser of #1262. `cargo test -p rustledger-parser --test corpus_baseline` passes against the regenerated manifest. Closes #2307 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
Both rules landed with unit tests inside their own crate and nothing that
exercised them through a loaded ledger or the executor. The whole repository
held one `{{total}}` reduction fixture, and it runs under
`option "booking_method" "NONE"`, which skips reduction matching entirely --
so no corpus, parity or compatibility test covered a total-cost reduction that
actually matches a lot (#2328).
Booking, through parse -> book -> validate:
- `booking_total_cost_reduction.beancount` holds the three shapes that must
book: the total NAMES its lot (two lots at 40.00 and 60.00, selling
`{{60.00 USD}}` takes the dear one, which is not the lot FIFO would pick), a
full-precision round trip through 100.00/3, and covering a short, where the
reduction has positive units and `units.abs()` is what makes it match.
- `booking_total_cost_reduction_wrong_total.beancount` holds the shape that
must not: two lots at 50.00 do not cost 90.00 together.
The first test asserts the booked posting carries 60.00 AND the dear lot's
2026-01-02 acquisition date, rather than just "no errors" -- the date drives
the short/long split in capgains, and a wrong lot with a right cost would pass
a weaker assertion.
BQL, through the executor: `date_arithmetic_test.rs` pins the behaviors
measured against beanquery 0.2.0 while #2324 was written, both deliberate
divergences from it, the leap-day span, the aggregate `max(date) - min(date)`
shape, and that `date - date` still agrees with `date_diff`.
Both fixtures were checked against Python beancount 3.2.3, which accepts the
first (leaving `1 W {40.00 USD, 2026-01-01}` in Assets:Pick, the other two
accounts empty) and rejects the second with "No position matches". Both new
loader tests were then run against sabotaged fixtures -- naming the cheap lot,
and correcting the wrong total -- and both fail there, so the assertions bind.
Closes #2328
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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 |
robcohen
added a commit
that referenced
this pull request
Oct 8, 2026
…2487) * chore(baselines): add the four corpus files upstream added (#2473) A fresh fetch of the compatibility corpus adds four files with no parser-output baseline. Regenerated with the procedure the drift issue names (fetch-compat-test-files.sh, then regen-corpus-baselines.sh). The manifest diff is exactly four added lines and nothing else: no changed output hash on any existing entry, no removals. Each new file was checked against Python beancount 3: - double-entry-generator cib_debit and ibkr, vrischmann fortuneo-bourse: both engines accept the ledger with no errors, and every posting (date, flag, payee, narration, account, position, price, tags, links) agrees between rledger query and bean-query. - vrischmann ccm-courant is an importer output fixture using the root "Actifs" with no name_assets option and one-posting transactions. Both engines reject it; the postings still agree. beancount reports "Invalid account name" for each posting, rledger reports E1001 (never opened), E3001 and E3004 for the same lines. cst-corpus.manifest is left alone, as in #2339: the regen script does not write it. Closes #2473 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr * chore(corpus): drop three repositories that no longer exist Review follow-up for #2473. tarioch/beancern, LaunchPlatform/beancount-extract and iocoop/beancount return 404 and contributed no corpus files (no manifest entry under their directories). Failing to clone on every run, they kept `.fetch-failures` at 3, and corpus-baseline-drift.py drops the whole "removed" group whenever any clone failed, so the weekly drift report could never say that upstream deleted a file. With them gone a fresh fetch records 0 failures, the corpus is the same 740 files, and `corpus-baseline-drift.py --dry-run` still reports no drift. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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.
Closes #2307. Closes #2328.
Two pieces of corpus work that share the same scripts.
Baseline drift (#2307)
The nightly drift check has reported two moved manifest entries since 2026-09-14:
apyb-financeiro/financeiro_2026-08.beancountapyb-financeiro/financeiro_main.beancountThe diff is one added line and one changed line. A third would have meant our own parser output shifted on files nobody touched, which is what this baseline exists to catch.
The fetch reported 3 repository clone failures (under its abort threshold). Before regenerating I checked that every path in the manifest was still present on disk — zero missing — because a partial corpus silently drops baselines for the files it failed to clone, and the script's
MIN_CORPUS_SIZE=100floor is far too coarse to notice. 735 entries in, 736 out, 736 files on disk.financeiro_main.beancount's change was confirmed independently by comparing the recorded source hash againstsha256sum:1782cc57…→465d1740….tests/baselines/cst-corpus.manifestis deliberately untouched —regen-corpus-baselines.shdoes not write it, since that baseline belongs to the parallel CST parser of #1262.Missing coverage (#2328)
Both rules landed with unit tests in their own crate and nothing exercising them through a loaded ledger or the executor. The entire repository held one
{{total}}reduction fixture, and it runs underoption "booking_method" "NONE", which skips reduction matching — so nothing covered a total-cost reduction that actually matches a lot.Booking, end to end through parse → book → validate:
booking_total_cost_reduction.beancount— the total names its lot (two lots at 40.00 and 60.00; selling{{60.00 USD}}takes the dear one, not the lot FIFO would pick), a full-precision round trip through 100.00/3, and covering a short, where the reduction has positive units andunits.abs()is what makes it match.booking_total_cost_reduction_wrong_total.beancount— two lots at 50.00 do not cost 90.00 together.The first test asserts the booked posting carries 60.00 and the dear lot's 2026-01-02 acquisition date, not merely "no errors": the date drives the short/long split in
report capgains, and a wrong lot with a right cost passes a weaker assertion.BQL, through the executor:
date_arithmetic_test.rspins the behaviors measured against beanquery 0.2.0 while #2324 was written, both deliberate divergences from it, a leap-day span, the aggregatemax(date) - min(date)shape, and thatdate - datestill agrees withdate_diff.Verification
1 W {40.00 USD, 2026-01-01}inAssets:Pickwith the other two accounts empty, and rejects the second withNo position matches.cargo test -p rustledger-parser --test corpus_baselinepasses against the regenerated manifest; loader and query suites pass; clippy and fmt clean at 1.98.1.🤖 Generated with Claude Code
https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr