Skip to content

fix: port four upstream beancount checks found by the coverage table - #3057

Merged
robcohen merged 7 commits into
mainfrom
fix/upstream-missing-checks
Nov 27, 2026
Merged

robcohen merged 7 commits into
mainfrom
fix/upstream-missing-checks

Conversation

@robcohen

@robcohen robcohen commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

What

Fixes four of the five missing rows in the upstream check table from #3054, and one covered row whose line difference turned out to be a bug. Stacked on #3054; review that first. Once #3054 merges, this PR's diff shrinks to these commits only.

upstream check before now
booking_full.interpolate_group: Amount is zero 0 HOOL {10 USD} accepted new E4006 on the posting
grammar.Builder.cost_spec: Duplicate merge-cost spec {*, *} accepted silently parse error (duplicate merge marker)
plugin:beancount.plugins.auto refused as an unsupported Python module (E8004), then E1001 for every account it would have opened runs auto_accounts (synth pass) and implicit_prices (regular pass)
option-deprecated:allow_deprecated_none_for_tags_and_links E7001, unknown option E7004, deprecated, with beancount's message; no effect
find_documents: Invalid date on document file 2020-13-45.pdf became an invalid document, and the loader then discarded all of document discovery's output reported at the main file's line 0, as beancount does; only that file is skipped

E4005 (Cost is negative) now goes on the posting, which is where beancount reports it and where the new E4006, from the same loop, goes.

Each fix updates its row in checks.toml to covered. The row's case ledger is checked against both rledger check and bean-check, so every row asserts the same lines on both sides.

Details

  • E4006. beancount reports zero units at a cost only when the cost states a number. It accepts 0 HOOL {} (the posting drops out) and a zero-unit posting with only a price, and rledger does the same. The check runs in validate_transaction_structure (early phase), so an elided number that interpolates to zero is never flagged, again matching beancount.
  • auto. No single native plugin can belong to both passes, and test_registry_synth_and_regular_are_disjoint enforces that, so rustledger_plugin::plugin_parts expands the reference into its parts before pass classification. The LSP's "is native" check uses the same expansion.

Not fixed: needs a decision

interpolate_group: Cannot infer price for postings with units held at cost. rledger treats a bare @ USD beside a cost as inert, on purpose: a_bare_price_beside_a_cost_is_inert (#1919). beancount reports it and then crashes. The row stays missing, with a note.

Parse-error parity

The manifest pins grammar-duplicate-merge and lima-tests/ParseLots.CostRepeatedMerge as match, where they were bc-only. Verified locally against the pinned fuzz corpus: no fuzz input changes category.

Caches

  • Loader v80: it replays cached option warnings, and the option warning changes from E7001 to E7004.
  • WASM v145: validation findings and plugin output change.

How to test

cargo test -p rustledger-validate test_validate_transaction_structure_zero_units_at_cost
cargo test -p rustledger-parser --test stray_char_matrix test_parse_reports_what_beancount_rejects_in_a_cost_or_price
cargo test -p rustledger-loader --all-features --test auto_plugin_test --test document_invalid_date_test
cargo test -p rustledger-loader --lib test_set_allow_deprecated_none_for_tags_and_links_is_deprecated
RLEDGER_UPSTREAM_PYTHON=/path/to/python3-with-beancount cargo test -p rustledger --test upstream_checks_test

🤖 Generated with Claude Code

@robcohen
robcohen requested a review from a team as a code owner November 27, 2026 04:12
@robcohen
robcohen force-pushed the feat/upstream-check-coverage branch from 8838253 to 8c697b4 Compare November 27, 2026 04:59
@robcohen
robcohen force-pushed the fix/upstream-missing-checks branch from e0a0213 to 31b2f17 Compare November 27, 2026 05:01
@robcohen
robcohen force-pushed the feat/upstream-check-coverage branch from 8c697b4 to ba20d50 Compare November 27, 2026 05:59
@robcohen
robcohen force-pushed the fix/upstream-missing-checks branch from 31b2f17 to a94980e Compare November 27, 2026 06:06
Base automatically changed from feat/upstream-check-coverage to main November 27, 2026 06:44
robcohen and others added 6 commits November 27, 2026 00:45
…5 on its posting

beancount reports a posting written with zero units and a cost that states
a number as "Amount is zero" (booking_full.interpolate_group); rledger
accepted it. A cost with no number (0 HOOL {}) or a price alone is still
accepted, as there. E4005 (Cost is negative) moves to the posting, where
beancount reports it and where E4006, from the same loop, goes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
{*, *} was accepted without a word; beancount reports "Duplicate merge-cost
spec". The first * stays a deliberate extension (compatibility section 20).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t_prices

The reference was refused as an unsupported Python module (E8004). Its parts
run in different passes, so rustledger_plugin::plugin_parts expands it before
pass classification; the LSP counts it as native.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…not unknown

It was E7001 (unknown option); beancount reports it as deprecated. Now E7004
with beancount's message, read as a converter boolean, with no effect.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… rest

2020-13-45.pdf became a document with an invalid date and the loader then
discarded all of discovery's output. It is now beancount's "Invalid date on
document file", at the main file's line 0, and only that file is skipped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ches

checks.toml: five rows now covered with matching lines in rledger and
bean-check. Loader cache v80 (replayed option warning changes), WASM v144.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@robcohen
robcohen force-pushed the fix/upstream-missing-checks branch from a94980e to 97164b4 Compare November 27, 2026 06:50
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

Shape rustledger beancount Speedup RSS (rledger / beancount)
simple 52.3ms ± 1.1ms 822.2ms ± 3.6ms 15.7x 43.1 MB / 51.1 MB
investment 77.4ms ± 1.1ms 2917.5ms ± 23.6ms 37.7x 47.3 MB / 59.1 MB
fifo 75.5ms ± 1.5ms 14642.8ms ± 143.4ms 193.9x 49.3 MB / 58.8 MB

vs base, measured in this run

Shape base this PR Change RSS base → PR
simple 52.0ms ± 0.4ms 52.3ms ± 1.1ms +0.4% ✅ within noise 43.1 MB → 43.1 MB (-0.0%)
investment 78.0ms ± 1.3ms 77.4ms ± 1.1ms -0.7% ✅ within noise 47.3 MB → 47.3 MB (-0.1%)
fifo 76.9ms ± 1.7ms 75.5ms ± 1.5ms -1.8% ✅ within noise 49.2 MB → 49.3 MB (+0.1%)

A difference counts only when it clears the combined spread of the two measurements, per shape (2σ: simple 0.5ms, investment 0.8ms, fifo 1.0ms), and is at least 5%.
10,000 transactions per shape · 20 runs, 3 warmup · hyperfine

What do these numbers mean?
  • simple — Two-posting transfers, one currency. The historical workload — keep as the floor, not as the benchmark.
  • investment — Cost specs, per-unit prices and lot reductions. Exercises booking and inventory, which simple leaves at 0.3%.
  • fifo — Bare {} reductions against a FIFO account — how FIFO sells are normally written. The other four shapes reach the ordered-selection path twice in 2k transactions between them, so it was effectively unprofiled until it turned out to be quadratic (plan_ordered scans every lot per reduction: FIFO ledgers are quadratic (8.8s at 20k transactions) #2083).
  • vs base: the PR and the base-branch commit it is built on, built and measured in the same job
  • RSS: peak resident set size, a single sample — reported without a verdict because there is no spread to test it against
  • A shape with no beancount column is one bean-check reports errors on; it is timed for rledger only

@github-actions

Copy link
Copy Markdown
Contributor

✅ Compatibility Test Results

Metric Result
Check Compatibility 100%
BQL Compatibility 100% (raw 93%, 180 masked)
Full AST Match 100%
Total Files 828
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

@codecov

codecov Bot commented Nov 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.82353% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...er-plugin/src/native/plugins/document_discovery.rs 93.10% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@robcohen
robcohen merged commit 97fb5d4 into main Nov 27, 2026
68 of 69 checks passed
@robcohen
robcohen deleted the fix/upstream-missing-checks branch November 27, 2026 08:02
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