Skip to content

refactor(parser): delete drop_errors_inside_a_line_error; the oracle names the invalid token - #3067

Merged
robcohen merged 1 commit into
mainfrom
fix/drop-line-error-pass
Nov 27, 2026
Merged

robcohen merged 1 commit into
mainfrom
fix/drop-line-error-pass

Conversation

@robcohen

@robcohen robcohen commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

What

Deletes convert.rs's hand-modeled drop_errors_inside_a_line_error (#2787). This is the retry: in #3063, removing it broke transaction_holds_invalid_token, and #3064 has since moved that function onto the oracle.

The pass dropped an unreadable token's own error when it sat inside its line's error, and renamed the line error after the token. The error oracle's reconciler already keeps the narrowest of rledger's errors on each token beancount reports. So the pass now decided only which of two errors survived, and what it was called.

  • Deleted: the pass, the transaction-span list it read, and its linear-time counter and test. The oracle's parse-level linear test covers these shapes.
  • Added: name_invalid_tokens in the beancount oracle. After reconciling, it names each unexpected input error that alone stands for one of beancount's lexer errors: the narrowest error on the token, and one that holds no other token. The message becomes unexpected input: invalid token 'h', matching bean-check's Invalid token: 'h'.
    • Linear: one merge over errors and slots.
    • A line error holding several tokens is not named, because each token's own error is.
  • Visible change: more errors name their token than before, for example 'freddo' in -5.65 freddo NZD and '"Lunch' in an unterminated narration. An error on a token is now reported at the token, not over its whole line.
    • The unterminated_quote tests are updated to match.
    • test_parse_line_error_names_the_invalid_token and test_parse_header_after_two_leading_boms_names_its_invalid_token pass unchanged.

Gates

  • Parity: 122,378 of 123,394 inputs match, unchanged, with no re-pin needed.
  • BOM matrix: counts are unchanged. The token texts are re-pinned (BOM_MATRIX_RELABEL=1): 679 rows now name their token. Three known rows lose a cause label, since the counts are the same.
  • STRICT_BASELINE: I re-pinned only the corpus files whose messages drifted: 11 found locally, plus double-entry-generator/example_mt_example-mt-output.beancount, which only CI's larger corpus has (fetched from upstream, blake3 matches the pinned source hash).
  • Other suites: the parser suite passes, workspace clippy with -D warnings is clean, and the validate, loader, lsp, wasm and rustledger tests pass.

Stack and caches

This PR is stacked on #3065. That PR's bom-in-account overlay keeps the one-BOM-per-line rule this pass also applied; without it, 9 BOM matrix rows regress. #3065 has merged; this PR now targets main.

WASM cache v152. The loader cache is unchanged.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

Shape rustledger beancount Speedup RSS (rledger / beancount)
simple 41.1ms ± 0.9ms 498.8ms ± 4.6ms 12.1x 45.2 MB / 51.0 MB
investment 60.3ms ± 0.5ms 2029.2ms ± 79.5ms 33.7x 47.1 MB / 59.2 MB
fifo 58.4ms ± 0.9ms 11542.1ms ± 11.8ms 197.6x 49.1 MB / 58.9 MB

vs base, measured in this run

Shape base this PR Change RSS base → PR
simple 40.9ms ± 0.6ms 41.1ms ± 0.9ms +0.6% ✅ within noise 43.1 MB → 45.2 MB (+5.0%)
investment 61.3ms ± 0.8ms 60.3ms ± 0.5ms -1.6% ✅ within noise 47.3 MB → 47.1 MB (-0.4%)
fifo 59.6ms ± 0.7ms 58.4ms ± 0.9ms -2.0% ✅ within noise 49.2 MB → 49.1 MB (-0.3%)

A difference counts only when it clears the combined spread of the two measurements, per shape (2σ: simple 0.5ms, investment 0.4ms, fifo 0.5ms), 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

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…names the invalid token

convert.rs's hand-modeled drop_errors_inside_a_line_error (#2787) dropped
an unreadable token's own error inside its line's error and renamed the
line error after the token. The error oracle's reconciler already keeps
the narrowest of rledger's errors on each token beancount reports, so the
pass only decided which of two errors survived, and its name.

The pass, its transaction-span list and its linear-time counter are
deleted. In its place the beancount oracle names, after reconciling,
each `unexpected input` error that alone stands for one of beancount's
lexer errors (the narrowest error on the token, holding no other):
`unexpected input: invalid token 'h'`, as bean-check's `Invalid token:
'h'`. So more errors name their token than before, and an error on a
token is reported at the token, not over its whole line.

Error counts and lines are unchanged: parity 122,378 of 123,394,
nothing re-pinned. The BOM matrix's token texts and three cause labels
are re-pinned (BOM_MATRIX_RELABEL), and the corpus baseline's 12
drifted files (messages only). Stacked on the bom-in-account overlay,
which keeps the one-BOM-per-line rule this pass also applied. WASM
cache v152.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@robcohen
robcohen force-pushed the fix/drop-line-error-pass branch from 5949eb0 to bcbcba2 Compare November 27, 2026 21:58
@robcohen
robcohen merged commit 739f8c2 into main Nov 27, 2026
66 of 67 checks passed
@robcohen
robcohen deleted the fix/drop-line-error-pass branch November 27, 2026 22:21
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