Repository navigation
refactor(parser): classify builder checks by EntryCheck, drop RLEDGER_ERROR_ORACLE - #3093
Merged
Merged
Conversation
…_ERROR_ORACLE The error oracle's `classify` told a check beancount's builder makes of a read entry from a syntax error by the message's wording (`is_a_builder_message`: "as beancount reports", "as in beancount", prefixes; "negative prices are not allowed"; the too-many-strings prefix), so rewording a message could turn a builder check into a syntax error the reconciler drops. Each such error now carries `ParseError::check`, a new `EntryCheck`, set where the check is made; `classify` and the P4 overlay match on it, and `is_a_builder_message` / `is_a_builder_error` are gone. Codes, lines and messages are unchanged; the parser corpus baseline moves only because `ParseError`'s `Debug` prints the new field. `RLEDGER_ERROR_ORACLE=0` still changed every parse's diagnostics, and its docs described hand-modeled passes that were deleted. The env switch is removed; the drift tooling's `gate_skips_grammar` uses a scoped `oracle::without_reconciliation` instead, and the doc-hidden `cst::set_error_oracle_on_this_thread` is removed. The parse-error parity harness's `tags_after_posting_lines` stopped at the continuation line of a multi-line string in the header (or a posting or metadata value) and found no tag line; it now reads past string continuations. Self-test cases added. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
robcohen
added a commit
that referenced
this pull request
Nov 29, 2026
…#3112) #3093 added ParseError::check, which ParseError's Debug prints, so the parser corpus hash of every file with a builder-check error moved. Its regeneration ran on a local corpus that lacked parser-lima/test-cases_MetaData.MetadataTransactionRepeated and parser-lima/test-cases_TotalsAndSigns.TotalPriceWithMissing (present in CI's cached corpus), so those two entries kept their pre-#3093 hashes and the Corpus output baseline job has failed on main since. Source hashes are unchanged; the new parser hashes are exactly the ones CI reports. Co-authored-by: Claude Opus 5.5 <[email protected]>
robcohen
added a commit
that referenced
this pull request
Nov 30, 2026
A 31-digit number in a cost spec (`{N USD}`, `{{N USD}}`, either side of
`#`) was dropped with no parse error: the cost became unknown and the
only diagnostic was booking's `interpolation failed`. On a `price` or
`balance` line the directive got a generic `unexpected input` over the
line, and in a balance tolerance, a metadata, `custom` or `pushmeta`
value the number was dropped with no error at all. Each is now reported
at the number (`invalid number in cost (likely exceeds 28-digit Decimal
precision)`, `in amount`, `in metadata value`, ...), as an amount's and
an `@` price's always were (that wording is unchanged). An expression
holding such a number is reported at the number rather than as an
unevaluable expression. beancount 3.2.3 accepts these numbers: P10.
The error oracle's `divide-by-zero` (P9) and `decimal-precision` (P10)
overlays matched these errors by the start of their message. They now
match a typed discriminator, `ParseError::number_error`
(`NumberError::{UnevaluableExpression, BeyondPrecision}`, new), set at
every emitting site, following #3093's `check`. P10 is now claimed, like
P9, only on a line beancount reads and reports nothing on, so an invalid
token after such a number keeps its name.
Cost-spec numbers are checked in the shared cost-spec rule of both tree
walks and the tree builder's recorder; metadata and `pushmeta` values in
the metadata line check; `custom` values in the shared value walk.
Loader cache v86, WASM cache v170: a file that loaded clean (a cost or
metadata number beyond precision) now has a parse error.
Co-authored-by: Claude Opus 5.5 <[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.
What
Two code smells in the parser's error oracle, plus a gap in the parse-error parity harness.
(a) Builder checks are classified by a value, not by wording.
oracle/beancount/mod.rs::classifydecided whether an rledger diagnostic is a builder check (stands) or a syntax error (held to beancount's slots) partly by matching the message:convert.rs::is_a_builder_message(contains("as beancount reports"),contains("as in beancount"), several prefixes),starts_with("negative prices are not allowed"), andis_a_builder_error'sTOO_MANY_STRINGSprefix. Rewording any of those messages would have silently reclassified the error.rustledger_parser::EntryCheck(non-exhaustive) andParseError::check: Option<EntryCheck>, set withParseError::with_checkat every place a builder check is made: duplicate cost component, per-unit cost in{{ }}, negative price,@@without units, cost/price currency mismatch, tags after the first posting, duplicate metadata, too many header strings.classifyreturnsOtherfor any error with acheck; the P4 overlay (TagLineAfterFirstPosting) matchesEntryCheck::TagsAfterFirstPostinginstead of a substring.is_a_builder_message/is_a_builder_errorare deleted.P0012), messages and lines are unchanged.tests/baselines/parser-corpus.manifestmoves for 52 files only because the baseline hashesParseError'sDebug, which now prints the new field. Only rows whose source hash matches were updated; rows whose local corpus copy has drifted were left alone. No cache bump: neither cache archivesParseError, and the loader never caches a load with parse errors.(b)
RLEDGER_ERROR_ORACLE=0is removed. It still changed what every parse reported, and its docs (oracle/mod.rs, convert.rs) described hand-modeled passes that have since been deleted. The reconciliation now always runs. Only the drift tooling'sgate_skips_grammarparses without it, through a scopedoracle::without_reconciliation. The unused, doc-hiddencst::set_error_oracle_on_this_threadis removed, and the stale comments are rewritten.(c) Harness:
tags_after_posting_linesand multi-line strings. It scanned from the line after the header and stopped at the first line that wasn't indented, so a header holding a multi-line string (2024-01-02 * "x\ny") ended the scan at the string's continuation line. beancount'sTags or links not allowed after first Postingthen stayed on the header line instead of moving to the tag line. It now tracks string state across lines, so continuation lines in the header, a posting or a metadata value are skipped. Three self-test cases were added; the old function returns[]for the first one.Not changed (noted)
Two other overlays still match on message prefixes:
invalid arithmetic expression(P9) andinvalid number in amount (likely exceeds(P10). Neither is a builder check, soEntryCheckdoesn't cover them. They could get the same treatment in a follow-up.Testing
cargo test -p rustledger-parser: all pass, including the newtest_classify_reads_the_check_not_the_wordingandtest_parse_marks_each_builder_check(one input perEntryCheck).cargo clippy -p rustledger-parser --all-features --all-targets -D warningsis clean, andcargo check --workspace --all-targetspasses.compat-parse-error-parity.py --self-testand--check: 122,378 / 123,394 matched, identical to main, no regressions, manifest unchanged.compat-semantic-parity.py --check: 9,563 match, 7 mismatch, 1,116 deliberate (99.93%), unchanged, no regressions.🤖 Generated with Claude Code