Repository navigation
fix(validate): a transaction beancount's grammar discards moves no inventory - #3066
Merged
Merged
Conversation
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 |
This was referenced Nov 27, 2026
Merged
…ventory `Assets:A 1 $ USD` makes beancount drop the whole transaction, so a later `balance Assets:A 0 USD` holds there. rledger kept the posting under error recovery, booked it into the validator's inventory, and reported the balance failing (E2001) beside the parse error (casc3). The late transaction check now returns before the balance check and the inventory update when beancount discards the transaction (rustledger_parser::beancount_drops_directive). It asks that only for a transaction a parse error starts in, or on the line after, so a clean ledger never reads its source: rustledger_validate::SourceLines gains with_parse_errors / with_file_parse_errors / parse_error_in, and rustledger_loader::SourceMap records each file's parse-error starts (set_parse_errors / parse_error_starts), which source_lines hands on to every surface. The LSP gives the edited buffer's own. Pinned on every surface by a surface-agreement case. The semantic differential re-pins two parser-lima ledgers: beancount's `Balance failed` after a dropped transaction now matches (ErrorInTransactionLine matches outright; ErrorInPosting's next difference is its balances). WASM cache v154; the loader cache is never saved for a source with a parse error. Co-Authored-By: Claude Opus 5.5 <[email protected]>
robcohen
force-pushed
the
fix/casc3-parse-error-locations
branch
from
November 27, 2026 23:15
955d5fb to
316fd62
Compare
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
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
A transaction beancount's grammar discards now moves no inventory, so a later
balancesees its account without that transaction's postings (casc3, left open by #3064):Invalid token: '$'. beancount drops the transaction, so the balance holds.Assets:A 1under error recovery, booked it, and reportedE2001 Balance failedbeside the parse error.validate_transaction_latereturns before the balance check and the inventory update when beancount discards the transaction. That is decided byrustledger_parser::beancount_drops_directive, from the error oracle's reduction trace.Parse-error locations plumbed to the validator
The validator asks only about transactions holding a parse error, so a clean ledger never reads its source text.
rustledger_validate::SourceLinesgains:with_parse_errors(by_file), sorted per file;with_file_parse_errors(file_id, starts), which replaces one file's list (for an edited buffer);parse_error_in(file_id, range) -> Option<bool>, which returnsNonewhen the locations were not given, in which case behaviour is as before.rustledger_loader::SourceMapgainsset_parse_errorsandparse_error_starts. The loader records each file's error starts where it records the file's parse errors, andsource_lines/source_lines_overlaidhand them on. So CLI, WASM, FFI and the LSP's loaded path all get them.directive_text(compat(validate): an unbalanced transaction keeps its E3001 before an indented invalid line or an invalid-date directive, unlike beancount #2987).Tests
SourceLines::parse_error_inandwith_file_parse_errors.-D warningsis clean, and the parser, validate, loader, lsp, wasm and rustledger tests all pass.Caches
WASM cache v154. The loader cache is unchanged, since it is never saved for a source with a parse error.
Merge order
This PR is independent of the others. The cache numbers assume this order:
If this PR merges earlier, I will renumber.
🤖 Generated with Claude Code