Skip to content

refactor(parser): place an error at a multi-line string in the reconciler - #3068

Merged
robcohen merged 1 commit into
mainfrom
fix/multiline-string-ends
Nov 27, 2026
Merged

robcohen merged 1 commit into
mainfrom
fix/multiline-string-ends

Conversation

@robcohen

Copy link
Copy Markdown
Member

What

Moves report_at_multi_line_string_ends (#2994) from convert.rs into the error oracle's reconciler.

The pass reported an error whose statement fails at or after a string that runs over a line end on the line where beancount reports it. It found that line from its own reading of the header grammar. The oracle already knows the line: it is the line of the beancount error the rledger error stands for.

  • Deleted: the pass.
  • New in reconcile: a syntax error that meets all of these moves to the slot's line, keeping its end and message:
    • it starts on a line with no slot of its own;
    • it holds a slot, or ends right at one, that the reference reports on a later line;
    • the text between can be one statement.
  • New argument, one_statement(from, to): keeps the reconciler format-neutral. The beancount frontend answers it with line_ends_inside_strings, which checks that every line end in the range is inside a string (backslash escapes honoured; linear in the range).
  • Behaviour kept: builder errors (class Other) are not moved, as before. An indented line after a gap fails at its indent, which is a slot on its own line, so it stays.
  • Unit test: test_reconcile_moves_an_error_to_its_slots_later_line.

Gates

No output changes:

  • parity is 122,378 of 123,394 inputs, with no re-pin;
  • the BOM matrix, STRICT_BASELINE and the parser suite are unchanged, including multi_line_string_error_line.rs and bison_recovery_model.rs;
  • workspace clippy with -D warnings is clean;
  • the validate, loader, lsp, wasm and rustledger tests pass.

Caches

WASM cache v153. This PR is independent of the others; the numbers assume this merge order: #3065 (v151), #3067 (v152), this PR (v153), #3066 (v154), then the quiet_after_invalid_tokens deletion (v155). I'll renumber if the order changes.

🤖 Generated with Claude Code

@robcohen
robcohen requested a review from a team as a code owner November 27, 2026 14: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 39.9ms ± 0.5ms 554.1ms ± 2.4ms 13.9x 45.1 MB / 51.1 MB
investment 60.7ms ± 0.5ms 2109.2ms ± 10.4ms 34.8x 47.1 MB / 59.2 MB
fifo 59.0ms ± 0.3ms 11872.5ms ± 102.2ms 201.3x 49.0 MB / 58.8 MB

vs base, measured in this run

Shape base this PR Change RSS base → PR
simple 39.9ms ± 0.4ms 39.9ms ± 0.5ms -0.1% ✅ within noise 45.1 MB → 45.1 MB (+0.1%)
investment 60.8ms ± 0.4ms 60.7ms ± 0.5ms -0.1% ✅ within noise 47.0 MB → 47.1 MB (+0.1%)
fifo 59.5ms ± 0.7ms 59.0ms ± 0.3ms -0.9% ✅ within noise 49.2 MB → 49.0 MB (-0.3%)

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

@codecov

codecov Bot commented Nov 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.52941% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
.../rustledger-parser/src/cst/oracle/beancount/mod.rs 95.45% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@github-actions

Copy link
Copy Markdown
Contributor

✅ Compatibility Test Results

Metric Result
Check Compatibility 100%
BQL Compatibility 100% (raw 93%, 179 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

…iler

convert.rs's hand-modeled report_at_multi_line_string_ends (#2994)
moved an error whose statement fails at or after a string running over
a line end to the line beancount reports it on, from its own reading of
the header grammar. The error oracle already knows that line: it is the
line of the beancount error the rledger error stands for.

The pass is deleted. The reconciler moves a syntax error that starts on
a line with no slot of its own, and holds (or ends right at) a slot the
reference reports on a later line, to that line, when the text between
can be one statement: reconcile's new one_statement argument, which the
beancount frontend answers by checking every line end between is inside
a string. Its end and message stay.

No output changes: parity 122,378 of 123,394, the BOM matrix, the
corpus baselines and the parser suite are unchanged. WASM cache v153.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@robcohen
robcohen force-pushed the fix/multiline-string-ends branch from 21ac622 to 00fdaae Compare November 27, 2026 22:24
@robcohen
robcohen merged commit a88ae1f into main Nov 27, 2026
65 of 66 checks passed
@robcohen
robcohen deleted the fix/multiline-string-ends branch November 27, 2026 22:51
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