Repository navigation
fix(parser): run a mid-line BOM's invalid token to the next blank, as beancount does - #2931
Merged
Merged
Conversation
… beancount does A BOM-led lexer error kept its own extent wherever it stood, so a `"`, `#!` or `#+` right after a mid-line BOM started a token of its own: `<BOM>"x"` opened a string (kept as the narration), and `<BOM>#!d`, `<BOM>#+x`, `<BOM><BOM>"x"` and `<BOM>abc` were two errors. beancount's `<INVALID>[^ \t\n\r]+` reads each as one invalid token. The own extent only matters at the start of a line, where it keeps a concatenated file's next directive lexing, so the lexer now keeps it only there (`at_line_start && span.start == last_newline_end`, in the `Err` arm), and `error_later_in_run` no longer stops at a BOM after a lone capital. The CST recovery treated every BOM-led error token as layout. Now only one that starts its line is (`is_line_start_bom_token`, one look back at the character before the token): `report_invalid_tokens_of_error_line`, `quiet_after_invalid_tokens` and `holds_an_invalid_token` count a mid-line BOM-led run as the invalid token it is, so `313<BOM>x` is two errors as in bean-check. When the line's error is another one (an invalid account), the secondary `BomInDirectiveBody` stands for the line's first BOM-led token, which is not counted twice. Parse-error parity: 78,306 of 111,323 inputs match beancount, from 78,225 (85 newly match, 4 regress on pre-existing causes: a stray mid-line `\r` and an end-of-file grammar error, both of which the old split BOM token happened to offset). Green and red agree on the whole pinned fuzz corpus. Loader cache v70, WASM cache v93. Refs #2928 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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 |
…condary BOM error stand for either kind of BOM token Review round 1 of #2931. A BOM-led invalid token where a directive's argument or account belongs (`price USD 1 <BOM>EUR`, `commodity <BOM>EUR`, `note Assets:A <BOM>"x"`, `open <BOM>Assets:C`) gave the dropped directive's generic line error and the token's inline `BomInDirectiveBody`: two errors, where main and bean-check report one. `drop_errors_inside_a_line_error` now takes an inline BOM error as an inner error too: when the header grammar first fails at that token, the inner error is dropped and the line error takes the BOM kind and hint, as an invalid token's generic error is merged there already. The secondary BOM error after another line error (an invalid account) stands for the line's first token with a stray BOM, whether the BOM leads it or sits inside it, so a later BOM-led token keeps its own error (`Ü:A x<BOM>y <BOM>z` is three errors, as in bean-check). Parse-error parity: 78,367 of 111,323 inputs match beancount (61 more than round 0, no new regressions). Refs #2928 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…unt every other stray-BOM token after an invalid account Review round 2 of #2931. When the header grammar first fails at a BOM-led token, the token's own `BomInDirectiveBody` is now the error kept, and the generic whole-node error is dropped for it, so the error has the token's span (main reported the BOM there too) rather than the directive's. The formatter still copies the directive verbatim: the token lies inside its node. After an invalid account, the secondary BOM error stands for one token with a stray BOM in it; every other such token, BOM-led or with the BOM inside it, has its own error, as in bean-check (`Ü:A <BOM>z x<BOM>y` is three errors). A BOM that starts its line is skipped when finding the line's first invalid token, so `<BOM>tApo` at the start of a line is the one token the line error stands for, as in beancount. Parse-error parity: 78,399 of 111,323 inputs match beancount (32 more than round 1; the 2 inputs that no longer match have pre-existing causes). Refs #2928 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…or stands for a line-start BOM, and pin every BOM combination against beancount Review round 3 of #2931. A BOM that starts its line keeps its own extent here, where beancount's invalid token runs on through whatever is glued to it, so it is always the line's first invalid token, the one the line error stands for. An invalid run glued to it (`<BOM>foo`) is part of that token. A run that only follows it (`<BOM> k:`) is one more token, where round 2 took it as the first: `<BOM> k: Ü:A x<BOM>y0` lost the `k:` (bean-check 3, main 3, round 2: 2). And once the line's BOM diagnostic stands for that BOM, a run with a BOM inside it later on the line has its own error (`<BOM>foo x<BOM>y` is two errors, as in bean-check and on main; round 2 gave one). Each review round found another combination that drifted, so this adds a guard. `scripts/bom-combination-matrix.py` records beancount 3.2.3's per-line counts for every combination of up to three BOM-led, inner-BOM and plain invalid tokens, with no prefix, a line-start BOM, or a line-start BOM glued to a run, in nine line contexts (1,078 inputs), and `tests/bom_combination_matrix.rs` checks rledger against it on both parse paths. The 386 inputs that still differ are listed with their cause and rledger's counts. All three causes predate #2928, and none of those inputs is further from beancount than on main. Refs #2928 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Keeps both CHANGELOG Fixed entries (#2928 and #2927). Co-Authored-By: Claude Opus 5.5 <[email protected]>
`e8844718a38e` stays a mismatch: its `<BOM> Ra` line now matches beancount (two invalid tokens), so its first differing line is a pre-existing posting-line difference and its category changes. Refs #2928 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…a line-start BOM's whole blank-free run as one token, and widen the BOM matrix Review round 4 of #2931. A BOM-led first token after a date or an indentation is the one the line's error stands for, and that error is the BOM diagnostic, so a later run with a BOM inside it has its own error (`2024-01-02 <BOM>a x<BOM>y` is two errors, as in bean-check). On an indented line whose start beancount reads, the token's own `BomInDirectiveBody` now stands for the line's first error as the generic one does, so ` <BOM>a` and ` <BOM>; c` are one and two errors, not two and three. A BOM that starts its line is one beancount token with its whole blank-free run, through tokens that lex here (`<BOM>12$`), so an invalid token in that run is not counted again. The unread rest of a `<BOM>*` heading line holds a blank and is still reported. The BOM-combination matrix gains a date-alone context, a metadata line under a header with no narration, a BOM after the indentation (glued to a run and to a `;`), and two prefixes that glue a BOM through a valid token to an invalid one: 2,598 inputs. Reverting each round-3 and round-4 fix fails it. The known list names its four causes, with the account cause corrected: it appears only after a line-start BOM. Parse-error parity: 78,461 of 111,323 inputs match beancount (62 more, no regressions). Refs #2928 Co-Authored-By: Claude Opus 5.5 <[email protected]>
… a `<BOM>*` heading's rest as beancount does, and add a seeded probe to the BOM matrix Review round 5 of #2931. Beancount's account type is `([A-Z]|{UTF-8-ONLY})...`, so a BOM glued to an account shape (`<BOM>Assets:A`, `<BOM>Ü:A`, `<BOM>1:A`) is one ACCOUNT there, and only its name is rejected, when the file loads. The account token regex no longer excludes U+FEFF from the first character, so it is one account here too, which the account-name check (`E1005`) rejects. A line-start BOM's own extent is capped at the BOM, as logos may now scan it into a failed account. A lone capital glued to a BOM (`A<BOM>b`) counts as BOM-led, so it is never left to the line's BOM diagnostic. After a `<BOM>*` heading start, the part up to the first blank is the BOM's token, and each blank-free run after it that beancount cannot read is one more error. The BOM matrix gains a BOM-led account kind and a lone-capital kind, the shapes the reviews found, and a seeded random probe of 2,000 inputs, 5,727 rows in all. Every row further from beancount than main is checked against the same input without its BOMs on main and named as such. Parse-error parity stays at 78,461 of 111,323. Refs #2928 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…o an account as its own token, and keep BOM runs linear Review round 6 of #2931. Letting U+FEFF start `Token::Account` made a line of BOMs quadratic and hid the BOM from the user (no `P0026`, no "Remove BOM" quick fix, a BOM-led account offered for completion and `open`). The account token is as on main again. Instead, a mid-line run of BOMs followed by an account-shaped word (`logos_lexer::starts_with_account`, the lexer's own account rule, read up to the next blank) keeps its own extent as a line-start BOM does: it is the `P0026` the quick fix acts on, the account lexes as one, and the error recovery counts the run as no invalid token, as beancount reads it into the account. Line-start BOMs stay one logos error each, a mid-line run is taken whole, and the recovery's account lookahead stops at the next BOM, so long BOM runs are linear end to end. `test_tokenize_long_bom_runs_are_linear` counts the bytes scanned while lexing and parsing 1 MB of BOMs, and fails on the quadratic versions. The known list now names a cause for every differing line, from a rule per cause, and unclosed `pushtag` / `pushmeta` errors are line 0 on both sides, as in the parity harness. Parse-error parity: 78,460 of 111,323 inputs match beancount. Refs #2928 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Keeps both sides of CHANGELOG.md and both cache-version notes: loader v69 (#2925) and v70 (#2928), WASM v92 (#2925) and v93 (#2928). Co-Authored-By: Claude Opus 5.5 <[email protected]>
… every count site, keep line-start bookkeeping before an account, and commit the BOM matrix classifier Review round 7 of #2931. `logos_lexer::bom_led_account` decides whether a run of BOMs starts an account as beancount does (a BOM may be an account's first character), with the lexer's own account rule on the word with a non-ASCII stand-in for the BOMs: `<BOM>assets:A`, `<BOM>1:A`, `<BOM>:A` are accounts too. When an account of rledger's follows, the BOMs keep their own token (P0026 and its quick fix, the account kept); otherwise the token ends where beancount's account does. One predicate, `is_bom_account_token`, now serves all four counting sites, the heading-rest `invalid_runs` included. A line-start BOM run before an account spends the BOM diagnostic and glues nothing after the account. The matrix gains a BOM-led account beancount reads only with its BOM, a glued tail after an account, and two line-start BOMs before every token, and records main's counts and the BOM-free analog's, so the test itself classifies each differing line (`cause`, one rule per cause) and checks the known list against it; `BOM_MATRIX_UPDATE=1` rewrites the list. The linearity guard gains a wall-clock bound that a lookahead the byte counters miss fails, and the LSP's grouped quick fix says "BOMs", not "BOM bytes". Refs #2928 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ount does, and refuse any BOM-matrix line further from beancount than main unless accepted by hand Review round 8 of #2931. A line-start BOM run followed by an account beancount reads only with its BOM (`<BOM>assets:A$x`, `<BOM>1:A$x`) glued nothing after the account, so its tail's error was lost. The run's account now ends at `bom_led_account`'s end: tokens before it are part of it, and the part of a token past it is beancount's next token, counted when it lexes as an invalid one (`$x`, `.b`), not when it lexes (`"x"`, `#t`, `;c`). Errors that start inside an error token are the lexer's own in `quiet_after_invalid_tokens`. The BOM matrix test now fails on any line rledger counts further from beancount than main unless `bom_combination_matrix_worse_than_main.tsv`, kept by hand and never written by `BOM_MATRIX_UPDATE`, lists it with a cause the test checks: the BOM-free analog for `like-main-without-bom`, a standalone match for a recovery cause, and the same difference alone for a line's own cause. All six of the reviewer's mutations of the BOM-account predicate now fail, the lexer one through a unit test that pins the kept account, and the metadata site through a new booking method test. The linearity guard's wall-clock backstop is 30 s. Refs #2928 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ails as beancount does Review round 9 of the mid-line BOM run fix. - bom_led_account reads only the characters an account can hold, so a line of BOM-led runs is linear again; the linearity guard covers the three new run shapes. - A comment ends the tail of a BOM-led account; on a line that starts with a BOM, an account inside an invalid token is no extra error. The token is masked byte for byte, so a BOM-glued account is not split off and a partly masked account is reported as written. - The BOM combination matrix gains account tails and a heading context, checks the mid-line hash-bang cause against its analog, folds in the account probe, and requires an accepted line's cause to be the cause the classifier finds. - Parse-error parity 78,461 (one explained manifest row). Refs #2928 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Take #2920 (WASM cache v94). This branch moves its WASM cache to v95, pinned at loader v70; v93 was never released. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… as beancount does
Review round 10 of the mid-line BOM run fix.
- A `;` after any BOM-led account of a tail starts beancount's comment,
so nothing after it is counted.
- After a `<BOM>*` heading, `{#` is a brace and whatever the `#` starts;
the rest's lexer resumes mid-line after the brace (new
`TokenIter::new_mid_line`), so the cost stays linear. Invalid runs are
reported from where beancount's invalid token starts.
- The BOM matrix checks the error kinds each cause names (`P0026`,
`P0006`), and verifies a glued-account line with its accounts written
as ordinary ones; it gains the comment tails, a `{#t` heading context,
the price shape and a `brace-hash-before-tag` cause.
- The linearity guard runs the 1 MB pass under a time budget from the
short pass, so a quadratic version fails instead of hanging.
- Tests pin masking to BOM-led lines and name the partly-invalid
account test as preserving main's message.
Refs #2928
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…token text
Review round 11 of the mid-line BOM run fix.
- The matrix table records beancount's count for each line alone, and a
recovery cause is asked first when the line alone counts as beancount
does alone.
- A line may have two causes (`&`): a glued BOM with a mid-line `#!` /
`#+`, or with a construct error main also makes. Each part's share is
measured in turn and the shares must be the whole difference.
- The invalid-token texts rledger reports for BOM inputs are recorded and
checked; an update that keeps counts but changes causes or texts needs
BOM_MATRIX_RELABEL=1.
- The linearity guard caps the short run at 1 s, gives the long run 10x
the linear ratio plus 5 s, and re-raises a worker's own panic.
- `invalid_runs` reads a `{#` through the common token path (a lone
capital glued to it starts beancount's invalid token, `A{#`), and the
dead heading-rest comment break is gone; `new_mid_line` is pinned.
Refs #2928
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…sions on update Review round 12 of the mid-line BOM run fix. - The matrix generator records where beancount's own lexer puts each input's BOMs (BOM-led ACCOUNT tokens, BOMs inside invalid tokens) and each line's grammar errors after its first; the test reads these instead of guessing token boundaries. - inner-bom-under-line-error now requires a BOM inside beancount's invalid token whose replacement by `$` makes rledger count the line as beancount does; one-diagnostic-per-line and the new bom-account-under-line-diagnostic are verified from the table. - kinds_hold is gone; composite share signs are documented. - An update refuses a line counted further from beancount than recorded (a new matching list tells rows that matched from new ones) unless BOM_MATRIX_RELABEL=1 and the known row carries a reason. - The linearity guard bounds the short run by a load-scaled reference. Refs #2928 Co-Authored-By: Claude Opus 5.5 <[email protected]>
robcohen
added a commit
that referenced
this pull request
Nov 11, 2026
- Rewrite the comments that still said run_validation gates on load.errors or skips on has_fatal (helpers.rs, api.rs, parsed_ledger.rs). - run_validation: drop the span-length-mismatch branch, which set refused transactions aside without noting them; load_and_book always keeps one span per directive, now a debug_assert. - CHANGELOG: Ledger::booking_refused listed under Breaking, as PluginError::failed was. - Cache notes: v93 and v96 were never released; #2931 holds v95. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…agnostic fallback Review round 13 of the mid-line BOM run fix. - The plain test checks the matching list is exactly the rows that match, and a `# total` seal line catches a cut or edited list in either mode, so a stale list cannot switch off the update guard. - one-diagnostic-per-line now needs beancount's later grammar errors to be the whole difference; pop-without-push is asked first; line-start-bom-before-comment covers every skipped line start; new eof-error-on-last-line and bom-free-line-as-on-main causes; the lines no rule explains are listed by hand with their facts. - A regression reason is written for exact counts and expires with them; a row that matched regresses from beancount's counts even with a hand-added known row. - The generator requires beancount 3.2.3. Refs #2928 Co-Authored-By: Claude Opus 5.5 <[email protected]>
robcohen
added a commit
that referenced
this pull request
Nov 11, 2026
… and escape query's option messages Review round 3 of #2945. - Loader CACHE_VERSION 69 -> 71 (WASM pin 71). Ignoring an included `documents` option (E7009) changes loader output: a v69 blob of a ledger whose include sets an existing `documents` root kept serving the `document` entries with no E7009. v70 is held by #2931 and v73 by #2944. The CostNumber and MetaValue fixture tripwires move to 71; no archived layout moved. - rledger query escapes an option diagnostic's message on the terminal path, as Diagnostic::to_line does (#2538), with a test. - CHANGELOG: ag-rledger query warnings carry optional file and line keys; rledger merge refuses a tree whose include sets documents. Refs #2925 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rs change nothing Round 19 of the review mutated cause()'s helpers. New made-up-count tests kill each mutant that can change a result: the BOM inside a header string for block_err, a poptag that does not start its line, a negative construct share, the in-error-line rule's non-BOM error, a tag after a line-start BOM, the brace rule's tag character, each eof_error_on_last_line condition, date_alone's length and BOM strip, lone_capital_glued's BOM strip, account_after_bom's colon, account_at at an earlier account, and an account role on another line for both glued causes. The rest are commented as changing no result where they stand, each with the reason: the header range, later_grammar's rl >= 1, the hash-bang check and the dead (r, b) update in parts_hold, eof's bc[eof] > 0, the inner-BOM rewrite's span filter, line_span's end, and the in-error-line rule's `>`. skipped_line_start no longer checks for a `\n` a single line cannot hold, an unknown part is unreachable!, and GLUED's own zero check is left to the shared one, which the matrix test now needs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
robcohen
added a commit
that referenced
this pull request
Nov 12, 2026
…does (#2952) * fix(wasm): restore cached ledgers holding custom directives or metadata ParsedLedger.fromCache and Ledger.fromCache threw "Deserialization failed: unaligned pointer ... alignment 8" on any ledger with a custom directive or a metadata entry. Root cause: rkyv::from_bytes reads the archive in place, so every archived value must sit at its own alignment in memory. ArchivedMetaValue needs 8 bytes (its Int(i64) variant, added in #1513), and every custom value and metadata entry archives one. The WASM cache blob puts its archive 12 bytes in, after the magic and version header, so even in a 16-aligned blob those values sat 4 bytes off. The blob itself is not aligned either: wasm-bindgen copies a JS Uint8Array into wasm memory with alignment 1. Fix: decoding copies the payload into an rkyv AlignedVec before reading it, which does not depend on where the caller's bytes lie. The cache format is unchanged, so CACHE_VERSION stays at 94 and blobs already written restore as they are. The loader's on-disk cache reads its header separately, so it does not have the offset bug, but it read the archive into a plain Vec<u8>, whose alignment is 1 by contract and 16 only because the system allocator happens to give it. It now reads straight into an AlignedVec. Its format is unchanged too. Tests: a round trip over one ledger per directive type, per metadata value type and per custom value type, plus error cases, comparing directives, errors and options on both ParsedLedger and Ledger, natively and under wasm-pack test --node; a native round trip over every .beancount file in the repository's test corpora; a decode of each payload at every offset from a 16-byte boundary; and a loader save/load of custom values and metadata. All but the loader test fail without the fix. Closes #2934 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix: make check, WASM, FFI and LSP agree on close-with-balance and after a booking error Two cases where the diagnostic surfaces disagreed (#2937), settled by bean-check 3.2.3: - Closing an account that still holds a balance (E1004). bean-check does not flag it, with or without auto_accounts / currency_accounts, and `rledger check` stays silent to match (`lint closed-nonempty` reports it). WASM, the FFI component and the LSP reported it. They now leave it out through the one predicate, `ErrorCode::is_advisory_only`. - Validation after a booking error. bean-check and `check` report an ambiguous STRICT reduction and the `Balance failed` that follows it, the refused transaction left out of the balance. WASM `validateSource` and `ParsedLedger` skipped validation on any load error, and the FFI counted the refused transaction into the balance (-1600 USD where bean-check says -2100 USD). The loader now records which transactions booking refused (`Ledger::booking_refused`), and both surfaces set them aside as the validating loader does: Early sees them, Late does not, and the session reports the account errors Early held for them. A shared case file (`rustledger-loader/tests/surface_agreement/cases.rs`) drives one drift-guard test per surface: the loader, `rledger check`, WASM (`validateSource`, `validateMultiFile`, `ParsedLedger`, `Ledger`, fresh and from cache), the FFI component (`validate`, `load`) and the LSP, each comparing codes (the FFI wire error has none: line and message), lines and messages. The WASM cache moves to v97: both payloads' archived errors change. WASM `fromCache` now reads the archive from an aligned copy: it starts 12 bytes into the blob, and the new cache round trip hit an "unaligned pointer" refusal on it. The format is unchanged. Closes #2937 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(wasm): drop the duplicate cache alignment fix in favor of #2942 The AlignedVec copy in deserialize_parsed / deserialize_ledger duplicates the fix in #2942 (#2934), which also covers the loader cache and has its own tests. #2942's branch is merged in next, so this PR's WASM cache round trip still decodes; #2947 depends on #2942 landing first. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(wasm): address #2947 review round 1 - Rewrite the comments that still said run_validation gates on load.errors or skips on has_fatal (helpers.rs, api.rs, parsed_ledger.rs). - run_validation: drop the span-length-mismatch branch, which set refused transactions aside without noting them; load_and_book always keeps one span per directive, now a debug_assert. - CHANGELOG: Ledger::booking_refused listed under Breaking, as PluginError::failed was. - Cache notes: v93 and v96 were never released; #2931 holds v95. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix: validate after a parse error on every surface, as rledger check does `rledger check` and bean-check 3.2.3 report a syntax error and still validate the entries that did parse. WASM (`validateSource`, `ParsedLedger`, `validateMultiFile`, `validateWithHost`), the FFI component (`validate`, `load`) and the LSP validated nothing once a file failed to parse, so one bad line hid every other finding. Each surface now follows the validating loader's rule, under which no load error stops validation: - WASM `load_and_book` no longer returns early on a parse error; the loader keeps what parsed and `process` books it, and `run_validation` validates it. `validateMultiFile` / `validateWithHost` report every load error, then run `process` with them cleared, as `check` does. - `LoadResult::take_parse_errors` (new) takes the parse errors out of a load so a surface reports them one by one with code and line, rather than `process` folding them into one line-less `parse errors in <path>`. WASM's single-source load, `Ledger.fromFiles` and the FFI string load use it. - The FFI's `semantic_validation_errors` drops its parse-phase gate. - The LSP's `validation_would_run` keeps only the size cap, and an open buffer with a parse error is overlaid in a multi-file ledger. The shared surface_agreement cases gain one parse error plus an unbalanced transaction and a failing balance (P0012 line 8, E3001 line 4, E2001 line 10, bean-check's three findings on the same lines), asserted on the CLI, the loader, WASM, the FFI and the LSP. WASM cache v101. Closes #2949 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix: address #2952 review round 1 - LSP: restore the #1813 guard in `ledger_diagnostics_multi`, so a buffer broken mid-edit no longer replaces the stored plugins the unopened files are validated with, and re-add `broken_current_parse_keeps_stored_plugins_for_cross_file_validation`. - LSP: keep overlaying a broken current buffer (its own diagnostics come from its text, as in `rledger check`), but hold the unopened files' diagnostics while it has a parse error, so a half-typed string that swallows an `open` cannot make them flap. Keep overlaying other broken open buffers. Pin both through `MainLoopState`. - WASM: `validateMultiFile` / `validateWithHost` take only the parse errors and leave the other load errors to `process`, as `Ledger.fromFiles` does, so they keep the code `LOAD`; drift guard `validate_and_ledger_report_load_errors_alike`. - WASM cache comment: v100 is not held by an open PR. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(lsp): validate other files against a clean view, not a held one Review round 2 of #2952. Round 1 held the unopened files' diagnostics while the edited buffer had a parse error. That hold never published the includes of a main file saved with a syntax error, let a clean buffer's edit recompute them against another broken buffer, and the restored plugin guard made a broken buffer's own diagnostics differ from rledger check on its text. Replace it with a stateless rule. Every file other than the one being published is validated against the clean view: the ledger as loaded with each open buffer that parses cleanly overlaid, a broken one left as on disk. The published buffer's own diagnostics come from the clean view plus its own text and plugins, as check reports them. For a clean buffer the two views coincide, so the all-clean path still runs one validation. didClose republishes the unopened files from disk. Removed: the hold flag, multi_file_diagnostics' with_unopened, and the parse-error plugin guard in ledger_diagnostics_multi. The changelog now names the surfaces that report parse errors one by one. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(lsp): keep a broken buffer's last clean text and every buffer's plugins in the clean view Review round 3 of #2952. - The clean view used the stored load for a broken buffer, so breaking a buffer with unsaved clean edits undid them for every other file. Each open buffer now keeps its last clean parse (dropped on close) and contributes it while its current text is broken. - The clean view applied only the published buffer's plugin lines, so one revalidation could publish a file twice with different content. ledger_diagnostics_multi now takes the view as parses: every file in it contributes its directives and its plugin lines, replaced in place. - didClose republishes every other open ledger buffer, not only the unopened files. - Docs: the own view's file set is the stored load's (an include edit takes effect on the next load); the WIT balance diff and the ffi-wasi error-phase docs no longer describe the removed parse gate. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(lsp): run a view's plugins in the loader's order, and record a clean parse only in diagnostics passes Review round 4 of #2952. - view_plugins appended the plugins of a view file that had none stored at the end, in the order the view listed its files (the published buffer first, then VFS HashMap order), so two chained rename_accounts ran in a different order than rledger check runs them and the clean view depended on which buffer was published. It now stable-sorts by file_id, the loader's order (pinned by a new loader test). - last_clean_parse was recorded by every parse_result() call, request handlers included; it is now recorded only by clean_view_parse, which only diagnostics passes call. - The wasm cache comment no longer calls v100 unreleased. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(lsp): validate a buffer saved broken as loaded, and pin the loader's plugin order on disk Review round 5 of #2952 (issue #2949). - After every successful load of the ledger (watched-file reload, root adoption), an open buffer whose current text equals the text that load read for its file drops its last clean parse: it was saved, so until it next parses cleanly its file is validated as `rledger check` validates the saved text. A buffer edited past what was saved keeps it. Before, a buffer saved broken kept validating its includes against its old clean text, hiding the E1001 `check` reports on disk. - Docs: the set AND ORDER of the files come from the last load (plugin order and same-day tie-breaks follow it), on `publish_diagnostics`, `view_plugins` and in the CHANGELOG. - Loader test: the plugin `file_id` order on disk, through the parallel pre-parse branch (a glob include matching several files). Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(lsp): forget a saved-broken buffer's clean parse when its file has a BOM The loader keeps a file's leading BOM, while editors send the buffer without it, so the round-5 "saved broken" check never matched a BOM-prefixed file and kept validating other files against its last clean text. Compare both texts with the parser's canonical `bom::strip_leading`, and pin the BOM and CRLF cases with tests. Review round 6 of #2952. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
…n or document each survivor
Round-20 review of the matrix test's classifier. `date_alone` now asks the
parser's own `parse_date` (beancount's `DATE`, slash dates and
`2024-01-021` included, and a real calendar date) and no longer strips
leading BOMs: beancount reads `<BOM>2024-01-02` as one invalid token and
reports nothing on the next line. `holds` is one match, with its two
standalone checks sharing `alone_counts`, and `parts_hold` checks the
construct sign in the construct arm.
New tests pin, on real counts where beancount and rledger differ (the
rows recorded by hand from bean-check 3.2.3, `recorded_row`) and on
made-up counts otherwise: the date shapes, each skipped line start, a
BOM-led `poptag`, each tag character after `{#`, each character after a
lone capital, the eof sum, the later-grammar difference, the glued
in-error-line difference, the `$` of the inner-BOM rewrite, the
hash-bang analog, `is_blank`, line 0 for an unclosed push, the
recovery-first `alone_matches`, both analog counts of the early
`like-main-without-bom`, main's count for `extra-construct-error`, and
every kind of cause `holds` checks.
Sweep on the final file: 451 mutants, 2 do not compile, 409 killed, 40
survive, each commented as equivalent at its site.
The WASM v102 note now says v100 and v101 were never released, and the
v104 note no longer repeats v93, v95, v100 and v101.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nce, and pin the matrix classifier's survivors
A posting's trailing-tokens check starts its error where the amount ends,
so a token glued to the currency (`1 HOOL<BOM>@ 2 USD`, `<BOM>{2 USD}`,
`<BOM>{{4 USD}} @@ 5 USD`) put it right at the token, where
`quiet_after_invalid_tokens` kept it: two errors where bean-check 3.2.3 and
main report one. A construct check's error that starts at the token and
runs past it is now treated like one that starts before it. On a header
line, a construct check around the token (a balance's malformed amount,
`1.00 <BOM>~ 0.01 USD`, `1.00 $~ 0.01 USD`) is dropped too when the
header's grammar reads up to the token (`header_grammar_reaches`, the rule
`directive_header_check` applies). 17 parity inputs now match beancount.
The matrix table gains the round-21 shapes (a BOM glued or spaced before
`@`, `@@`, `{`, `{{`, `~`, LF and CRLF; a date alone with a comment; a
line-start BOM before `*` / `#` and a BOM). `date_alone` reads beancount's
DATE token by hand (regex, Python date range, 32-bit field wrap, a `;`
comment after it) instead of asking the parser, and the
`eol-reported-on-next-line` rule needs exactly one error moved. The
classifier survivors of the round-21 review are killed by tests or
commented as equivalent; the stale-exception check and the hash-bang share
are functions with tests of their own.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every input #2931 changes has a parse error on main and here, and the loader saves a cache blob only for an error-free load, so no loader blob can hold a changed output: the v74 bump is dropped. The WASM payloads archive sources with parse errors, so WASM v104 stays, pinned to loader v73. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The glued-BOM test asserted every price gone; `{{4 USD}} @@ 5 USD` drops
only the cost the BOM stands in front of.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The known, texts and matching lists are compared through one list_diff, the known list is parsed once (parse_known_rows), and the update-only helpers (relabeled_rows, reason_holds, regressed_rows) get tests of their own. beancount_date covers every month length, and glued_boms_replace_construct the P0026s a rewrite leaves. Every other survivor of the sweep is commented as equivalent at its site. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Nov 12, 2026
compat(parser): two BOM inputs count one error away from beancount on #2931 where main matches
#2968
Closed
robcohen
added a commit
that referenced
this pull request
Nov 13, 2026
v107 is claimed by #2969; v106 is held by #2931. Co-Authored-By: Claude Opus 5.5 <[email protected]>
robcohen
added a commit
that referenced
this pull request
Nov 13, 2026
… them, and validate a scratch buffer alone (#2969) * fix(lsp): publish plugin and load errors where rledger check reports them, and validate a scratch buffer alone - #2955: a buffer outside the loaded ledger is validated as a ledger of its own text, as `rledger check` on it does, whatever else is open. It used to get the ledger's errors mapped by byte offset onto its lines, and its `plugin` lines replaced the main file's. - #2957: plugin errors keep their location and are published on the file and line `check` reports (cross-published to an unopened include); only one with no location stays at the top of the main file. - #2959: load errors (`LOAD`) are published: a missing or unreadable include and an include cycle on the `include` line in the including file, the rest in the main file. `LoadError::IncludeCycle` gains `include_site` so the loader, `check --format json` and WASM locate a cycle on that line too. While the ledger has a load error, any watched change reloads it, so creating a missing include clears the error. WASM cache v107 (v106 held by #2931); loader cache unchanged at v73. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(lsp)!: assert LSP diagnostics on the wire, and mark the IncludeCycle field as breaking - The new main_loop tests read diagnostics off the published notifications by URI instead of MainLoopState::diagnostics, whose keys differ on Windows (an open buffer's URI path `C:\..` against the loader's canonical `\\?\C:\..` for an unopened file). - CHANGELOG: LoadError::IncludeCycle's new public include_site field moves under Breaking, with `rledger check --format json` placing E0002 on the include line, and the FFI component and WASM locating the cycle. - A buffer outside the ledger is validated on its own text without its includes; docs and CHANGELOG now say so instead of claiming it matches `rledger check` on that file in general. - Comment on why plugin and load error lines drift in an edited buffer until the next reload. - check.rs locates the JSON cycle diagnostic with SourceMap::locate. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
…nvalid_tokens - quiet_after_invalid_tokens: drop an error that spans the token only when it is a construct check (the SyntaxError and indented-line conjuncts, and the construct check on an error at the token, were that and nothing more), and drop the redundant `start > at` in the other branch. Each remaining equivalent mutant is argued at its site. A header's line error after two leading BOMs is kept, as a new test pins. The `end > at` boundary is #2967. - header_grammar_reaches: pass `first` as the rule's `end`, which it never reads here; unit tests for each early return, the ancestor search, the right-biased token and the final defect check. - Tests: tab-indented postings (a glued BOM or `$` before a price, cost or tolerance), extra BOMs at the start of a file. - Matrix checker: `eol-reported-on-next-line` needs both halves at once; `regressed_rows` goes on past a new row; CRLF in data_lines; the data files hold no `\r`; two survivors commented. - WASM cache v105 note: v104 was held by #2931 and never released. Co-Authored-By: Claude Opus 5.5 <[email protected]>
WASM cache: main holds v107 (#2969), #2970 holds 108 and #2971 holds 109, so this PR moves from 106 to 110. The v107 note now says v106 was held here and never released; loader cache stays 73. Co-Authored-By: Claude Opus 5.5 <[email protected]>
robcohen
added a commit
that referenced
this pull request
Nov 13, 2026
… beside a same-cost short (#2970) * fix(booking): read an AVERAGE sale's pool-average cost as a reduction beside a same-cost short On an AVERAGE account holding a short at 101 beside longs averaging 101, a sale `-1 X {}` reduced the longs and booked as `-1 X {101 USD}`. Asked again of the inventory (any consumer realizing a posting with no recorded booking decision), the #2384 own-side exception read that cost lot by lot: it matched the short and neither long, so the booked reduction became a second short. Under AVERAGE a cost is a claim about the pool, so the exception now also treats the other side as named when its pool accepts the cost as a claim. The claim rule moves from rustledger-booking's check_average_spec into rustledger-core (average_claim_mismatch, with written_allowance and its helpers), and both booking and Inventory::is_booking_reduction call it. A written `-1 X {101 USD}` in that shape now books like `-1 X {}`. Commits the proptest seed and adds regression tests at core and validate level. WASM cache bumped to 107 (106 is held by #2931); loader cache unchanged. Closes #2958 Co-Authored-By: Claude Opus 5.5 <[email protected]> * chore(wasm): move the #2958 cache bump to v108 v107 is claimed by #2969; v106 is held by #2931. Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(booking): name covers in the #2958 rule, and state its two consequences The AVERAGE pool-claim rule applies to a buy that covers shorts as well as to a sale. Say "a sale or a cover" in compatibility.md section 14 and the v108 WASM cache note, and pin the cover with a test: holding a long at 101 beside shorts at 100 and 102, +1 X {101 USD} covers the shorts (1 long, 9 short left), where main opened a second long (2 long, 10 short). The ADR 0007 amendment now states two consequences: a claim the pool accepts only by rounding beats a lot at exactly that cost, and a ledger that loaded can now fail with E4002 on an over-reduction of the pool. Also update the adds_to_its_own_side doc comment to describe the AVERAGE pool test. Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(changelog): note the AVERAGE reduction fix (#2958) Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
robcohen
added a commit
that referenced
this pull request
Nov 13, 2026
…#2973) * fix(wasm)!: give a validation finding the hint rledger check gives it validateSource and ParsedLedger mapped a ValidationError through their own rule in validation_error_to_wasm: the hint fell back from the finding's hint to its note to its context, and the note stayed out of the message. So a failing balance (E2001) carried the hint "difference: 1, tolerance: 0", which rledger check, the multi-file WASM surfaces and the FFI do not give. The loader's conversion, which check uses, is now public as rustledger_loader::validation_error_to_ledger_error (process's ledger_errors_extend calls it), and validation_error_to_wasm takes the message, code, phase, hint and severity from it, placing the finding by its own single-source rule as before. A finding's hint is its suggested fix only, its note is folded into the message, its context is not reported, and E1005 is phase "parse", as check reports them. rledger check's output does not change. test_validation_findings_match_the_loaders pins validateSource to the loader field by field (message, code, phase, hint, file, line, column, end, severity) on a failing balance and a ledger with several findings, and one finding carrying a note, a context and a hint through both conversions. WASM cache v111 (v110 is held by #2931), since a ParsedLedger archives its findings; the loader cache stays at v73. Closes #2972 Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(wasm): pin E1005's phase, test the loader's finding conversion Review of #2973: - test_validation_findings_match_the_loaders gains an invalid-root ledger (E1005), so validateSource is compared with the loader on a parse-phase code, phase included. Forcing phase "validate" in validation_error_to_wasm now fails it. - rustledger-loader tests validation_error_to_ledger_error directly: the note folded into the message, the context dropped, the hint kept, and a parse-phase code given phase "parse". - The CHANGELOG breaking entry names every code whose context was a hint on validateSource: E2001, E2002, E2003, E8001 and E1005. Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(changelog): name E2005, E4004 and both E8001 contexts among the hints validateSource drops Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- 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
Part 1 of #2928. A BOM-led invalid token keeps its own extent only where a BOM starts its line. In the middle of a line it runs to the next space, tab or line ending, as beancount's
<INVALID>[^ \t\n\r]+does. So the quote,#!or#+after a mid-line BOM no longer starts a token of its own.logos_lexer.rs):Errarm keeps a BOM's own extent only whenat_line_start && span.start == last_newline_end.error_later_in_runno longer stops at a BOM. A run that goes on after a lone capital is never at line start, soA<BOM>"x"is one error token.cst/convert.rs,cst/green.rs):report_invalid_tokens_of_error_line,quiet_after_invalid_tokensandholds_an_invalid_token.is_line_start_bom_tokentells it apart from a mid-line one. It looks only at the character before the token, so it costs the same however long the token is.report_invalid_tokens_of_error_lineasks that rule. A line-start BOM is always on anERROR_NODEline, soholds_an_invalid_token(which walks anopenor a transaction) never meets one.quiet_after_invalid_tokenscounts it as its line's first invalid token, as beancount does, which changes no output (review round 15).holds_an_invalid_tokennow walks tokens in source order, so a token of BOMs alone is followed by the token after it.313<BOM>xwas 1 error where bean-check reports 2.BomInDirectiveBodystands for the line's first BOM-led token, so that token is not counted twice.has_stray_bom/token_has_stray_bom(the fix(parser): keep a BOM inside a string literal as string content, as beancount does #2926 rule) still classify every BOM-holdingERROR_TOKENas a stray BOM. A BOM in a string stays string content.ParseResult::is_stray_bom_atalready matches a BOM at any offset inside a longer error token, so the LSP "Remove BOM" quick fix still finds it. This is pinned by a new test.CACHE_VERSIONstays 73: every input this changes has a parse error, and the loader caches only an error-free load (round 21). v70 and v72, held here earlier, were never released.CACHE_VERSION107 to 110 (main holds v107, from fix(lsp)!: publish plugin and load errors where rledger check reports them, and validate a scratch buffer alone #2969; fix(booking): read an AVERAGE sale's pool-average cost as a reduction beside a same-cost short #2970 holds 108 and fix(wasm)!: report multi-file errors as rledger check and the FFI do #2971 holds 109),LOADER_CACHE_VERSION_PIN73. v93, v95, v100, v104 and v106, held here earlier, were never released.Why
At the start of a line the own extent keeps layout transparent: the directive of a concatenated file after a BOM still lexes, under one
P0026. In the middle of a line it does nothing for layout, and it splits one beancount token into two or more. That makes an extra error for<BOM>#!d,<BOM>#+x,<BOM><BOM>"x"and<BOM>abc, and it let a quote after a BOM open a string.Before / after (bean-check 3.2.3, full output)
The error counts are parse errors, from
rledger checkonmain(68 / 90) and on this branch. Each case is twoopenlines followed by the line shown.Invalid token: '2024-01-01')<BOM>2024-01-02 open ...(line start)P0026P0026(unchanged)<BOM> Assets:A 1 USD(BOM before indentation)P0026+ next posting)<BOM>Assets:A 1 USD(BOM in indentation, in a transaction withAssets:B -1 USD)Invalid account name: <BOM>Assets:A, a parse error), thenInvalid reference to unknown accountP0012+P0026, thenE3004,E3001P0026, thenE3004,E30012024-01-02 * <BOM>"x"Invalid token: '"x"'xwas kept as the narration2024-01-02 * "x" <BOM>#!d2024-01-02 * "x" <BOM>#+x2024-01-02 * "x" x<BOM>"y"2024-01-02 * <BOM><BOM>"x"2024-01-02 * "x" <BOM>abc2024-01-02 * "a<BOM>b"(BOM in string)313<BOM>x2024-01-01 open Assets:A USD "BAD" <BOM>xKnown change vs main: a BOM before a price or cost (#2954)
A BOM right before a posting's price or cost now loses that price or cost. Each case is two
openlines, then2024-01-02 * "x"withAssets:A 1 HOOL <tail>andAssets:B -2 USD:<tail><BOM>@ 2 USDP0026, thenE3001twice:residual 1 HOOL,residual -2 USD)<BOM>@@ 2 USD<BOM>{2 USD}HOOL<BOM>@ 2 USD,<BOM>@@,<BOM>{2 USD}, glued to the currency (round 21)The BOM's run now takes the
@or{, as beancount's invalid token does, and recovery keeps the posting without its price or cost, so the transaction no longer balances. Main already does this after any other invalid character (\x11{2 USD}). By the maintainer's decision it is fixed separately, in #2954.test_parse_bom_before_price_or_cost_drops_it_issue_2954pins the current output and names #2954, so that fix must update it on purpose. The CHANGELOG entry says so too.Parse-error parity
compat-parse-error-parity.py --checkat the pinned fuzz commit9bc79f4f:fuzzinput. Round 21 adds 78,478: 17matrixrows newly match (an invalid token glued to a balance's number before~, or inside a posting's arithmetic), so their pins are dropped.trackedandcompatare unchanged.--update. The changed rows are listed below.The lexer change alone made 52 inputs match and 21 regress (the prototype measured 48 and 16 against an older
main). Then I traced the regressions:Invalid tokenerror vanished:report_invalid_tokens_of_error_line);quiet_after_invalid_tokens).On
main, the split-off rest of the token (xafter<BOM>) carried that error by accident. None of the 21 is part 2: a#!or#+appears only inside an invalid run there, never as a mid-line token.BomInDirectiveBodyalready stood for that token. The secondary-BOM rule fixed those five.main, the BOM-led token's missing error happened to offset a different, pre-existing extra error. Each one reproduces onmainwith\x11in place of the BOM:fuzz_green_eq_red/e12a04af...(1c622c0ec38b)\ris an error here and a space in beancount. This is deliberately stricter (seestray_cr_trivia_end). The lone mid-line<BOM>is now correctly reported, so the extra\rerror shows.fuzz_green_eq_red/30086eb8...(31751db8eeca)\rcause, three stray\ron one line.fuzz_green_eq_red/09638cc2...(50cf239632e8)\rcause:...7\r<BOM>\n.fuzz_parse/ee342d5d...(c1ad7a224d1d)2<BOM>?02on the last line, with no trailing newline. beancount reports no grammar error there; rledger'sreadable_start_of_an_error_lineassumes one. Same onmainfor2\x11?02.I also measured a broader rule that reports every token holding a BOM, including ones with the BOM in the middle. It reaches 78,485 matching inputs, but it changes 640 rows and regresses 97 more. That is outside this part's scope; it would be a follow-up.
Changed manifest rows (197)
Newly matching (85), each
fuzz, was:lexer-token-split(45):00bff79e00c20a441276556929327951290d2eec4b6b1066436ccf4aaf86489840f9da40499892e6701c5d92e53e7cb35f4b321109cf6094f18ce0a060967e88f6546d6498e373da6f5c1e1a22e170af62b6b80c773af97fe52577f4dc79b08a79e796c2f6358129f1f74ec982702226532282bbbe7082b58e4ac280c6f49cf8e527af5ba8e6d3485866b3e2e15e2f29bc080f33dce9c8e376ef9566dae6b8127fc3de6a4c9d70c9e00fe268c0b6e33ba04c68d2e7d4ea695c1fe83ea93a3b5de94b1632bf3ee9bc7b54e5f4ea3cc1cbb387ee775fd6ca82ef604305392bf25486dac7a8f4b5b81417f5f5bff14ef8c6f80e8e9dfc0ff91e1a7977a2fb662b631e49fd977a96665afd985dd987a0lexer-tokens-merged(34):052e8df5723706aa84858d9309ed99ac31040c6c4c30dcbb0ee98990245712fee2c23ef71d447878aa202db18a3f58be37c5b8d62a0c45f03e75e03348143d8808bb5bf0d0ffe5396e25dee8b48a7576f439476e80b4f5b06708849286c169ae8ed73afd7272907cf8e3b3d3969c7bfe75d5a208b3588c0ba3d57fc9d089ae18aec3ec5caed6e4978392b0074bd491ebb6a8766ca2d3becbfe50174ec3f08eb81fa7cf30e1693387d36d9b92fa09dc7fb3abe0e6e9c9bfc830edeee379a457eff6c480009fbffbc119b3165cmore-on-line(6):1c1a986018575d5b977d59e9843ae81b28c09d5484f61dc4dfab5ad5342ff9dc4e5b47b4Recategorized mismatches (108), each
fuzz:lexer-token-splittolexer-tokens-merged(26):1158adc291491381daa79f1f1c2449827fa327638e95034229491c325d07453523b63b157a36fce2798a7abc598e2416804d9dfd2d4d8120079b0e2886e68ae5bf709b2f1475b5b29bded2eea40da3fa0b6b23afb7077e6df3ddbdac17d7856cbe8087979eb6ca617e441a3fcbaf9819143edaf4cd32d74bdb15a6682346db41fd554476e31fab0005cbe7dd4486909aeaa3c4e387eaf423c93142a8lexer-token-splittomore-on-line(1):d52de8e8a912lexer-token-splittorl-indented-line(64):0473ca66670812543bd1c63913cd74b502831496a74f235e272d6a0393c12f78e45f0d6c31d3c570ed403211fd1eb90f328cd9e3fa89334a85e60a0c346b801a73bf34874d1f197435ca29e300493791245e55313d5ce380df923ea7ecf06fa240725296503b431f6b6def054488494b71724ccfc041a0b14d7a3bcb8fd34e6d3239968460f828411bd864bef92afdf268f7edeaf9656b9b77b1830f6c1a5e5cee6e6e6ef32ddc257580ca7d88aa75ff0e0fca497f79be80cf968a5128a2888d8b9f2480fb1c8c4204fdfc128d060ae443808fa4bdfc0e6c90f877ec302491bcea98b61a9609441fd6f697003fbfcfa89768507e8d8a9978ff2c4d82a17eee5a750da27b20f0b7faa4df784c7c43a7ba71bdfafaa9c982f622f0aaddf79a2e85ab8ca73a43eaae7c6bf00e8ab5689fbe139eb5b4bd1986e1b82359f3c216c27c97a51265ca9b340bcd4fd15ec77bb761d9ea47088ea2edf73b46d815f0bf508d5b7af3af83130021f5201670fb1af5e20b556e79f7a15f80272effe0ec6ed399lexer-token-splittorl-top-level-line(1):7ee3ab67507blexer-tokens-mergedtolexer-token-split(8):01283cce0de00f4f2a7e48761b981a834b986e40212a877994b216c154b8c447a18bbc64c7e5825f971ee1415bc92eddlexer-tokens-mergedtorl-top-level-line(2):2e1a2755a94c9a0736d1ca77more-on-linetolexer-token-split(3):40f6d82e3e434b59f9a08e2d872c5b5c9629rl-indented-linetolexer-token-split(1):7ae55f67a8aerl-misses-linetolexer-tokens-merged(1):5502dcdbaeb7rl-top-level-linetolexer-tokens-merged(1):7f0ea757e7b5Regressed (4), each
fuzz:1c622c0ec38b(nowlexer-token-split)31751db8eeca(nowmore-on-line)50cf239632e8(nowmore-on-line)c1ad7a224d1d(nowlexer-token-split)Green / red
fuzz_green_eq_redregressions andgreen_red_propertiespass.Review round 1
1. A BOM-led token in a directive's argument or account gave 2 errors (main 1, bean-check 1). Fixed.
P0012, and the token's inlineP0026also survives.drop_errors_inside_a_line_erroronly mergedSyntaxErrors.BomInDirectiveBodyas an inner error. When the header grammar first fails at that token (grammar_failures, the same check that merges2024-01-01 open Ass'ets:A), it drops the inner error. The line error then takes the BOM kind and hint.P0026for each of these, as on main:balance(amount and currency positions);price(both currencies);commodity;note/event/document/custom/querywith a BOM before a string;open(space and tab),close,pad(both accounts),balanceandnote.is_stray_bom_atstill finds each BOM.test_parse_bom_led_argument_of_directive_is_one_errorcovers all of the above and checks the loaded directives.test_load_included_file_with_mid_line_bom_reports_one_erroris the included-file case: oneP0026inchild.beancount, and the surrounding directives load.test_parse_bom_led_run_stops_at_blank_inside_quotespins thatquery "q" <BOM>"select 1"is 2 errors. bean-check also reports 2, since its run stops at the blank.2. The secondary-BOM rule could swallow a real error. Fixed.
Ü:A x<BOM>y <BOM>zis now 3 errors, matching bean-check and main.test_parse_secondary_bom_error_stands_for_first_bom_token_of_either_kind.3. Transaction headers with an invalid token where a string belongs. Out of scope here; tracked in #2932.
This is the existing recovery model for every invalid token, not something new to BOMs. On main, the same code path already gives:
\x11)<BOM>* \x11"x"/* <BOM>"x"""""* "p" \x11"y"/* "p" <BOM>"y""p"* "p" \x11"p"The PR makes BOM-led tokens behave like every other invalid token here. Changing it means dropping any transaction whose header holds an invalid token. That conflicts with the documented recovery policy: rledger keeps the entry under its error-recovery policy (see
report_duplicate_metadata), andtest_parse_reports_no_booking_method_with_an_invalid_token_on_a_metadata_lineasserts the directive is kept. It is a separate change across the parser, now tracked in #2932.Nits
c1ad7a224d1dis left to Parse-error recovery differences from bean-check around invalid dates and column-0 markers #2872.Parity in round 1
--checkpasses after an--update.fuzzinputs where the directive's line error and the BOM token's error were both counted.Round-1 changed manifest rows (66)
lexer-token-splittolexer-tokens-merged(1):443bc94d6c76lexer-token-splittomatch(60):03acb0aeac9d0599ea4acdad11e9085784211eac62ce4a281fe24a05d1c42038e8769d602042401a006f258ff6360f102b23d2b6b9742f3ccd6944672fa154334bd8424f68d57ff1464afdb789d2494b3030da574a484b0974e74e870a62785b510af458d74b51dbe39f5e92561668ba9e9f5b065aad023760ce9d5387af67e9345292f57245d692c532748497374e7a75bf807f6b7475eaec0aa9b07606850727fb771b513cbb6e78a1a7d4e22b7a0976af058a7a4e701d2f708741751559248c5656195cb790ca025a785992b9a89d8db6937afaec0e0d9e46603298d9a01dfeea0b78a5815aba6b71a73b9eae421baa0801291abeac20a7874c8caf7b2f3e197eb43b9364f06db5dee0f8d2c0b6ce2c29d779c65251203ea2cbd17ea1c45ecc3293bcfeacce1a5977c444d3ce2bd9ec93d4964befb162d5a444bbbe8bd5ed47874216e3a54ce4fc26f000c1326f3ef125caa712f7f41f0ba2f9f5f4e6ce62b0dbfdd701707444lexer-token-splittorl-indented-line(1):cbd2aae7977flexer-token-splittorl-top-level-line(3):1c49750d2569d081dbe1aaf4d964ffbd235bmore-on-linetomatch(1):1b7174eb2559Review round 2
1. The merged
P0026was reported over the whole directive. Fixed.drop_errors_inside_a_line_error, when the header grammar first fails at a BOM-led token, the token's ownBomInDirectiveBodyis now kept and the generic whole-node error is dropped. Round 1 did the reverse: it kept the generic error and renamed it.price USD 1 <BOM>EURon line 5 reports at 5:24, where main also reports it.test_parse_bom_led_argument_error_is_at_the_tokenpins span, line and column forprice,commodity,balanceandnote, plus apriceand aneventwith metadata lines.test_format_source_keeps_directive_with_bom_led_argument.test_parse_errors_to_diagnostics_bom_led_argument_ranges_over_the_tokenchecks that the diagnostic range equals the BOM token.2. A BOM-led token before an inner-BOM token still dropped an error. Fixed with the suggested change.
had_secondary: inner-BOM tokens are left to the BOM diagnostic only when that diagnostic is the line's primary error.Ü:A <BOM>z x<BOM>y(3),Ü:A <BOM>a x<BOM>y <BOM>z(4),Ü:A x<BOM>y z<BOM>w(3) andÜ:A <BOM>a <BOM>b(3) all match bean-check. The last two were 2 and 4 on main.test_parse_secondary_bom_error_with_several_bom_tokens.The 3 regressions the suggested change caused:
fuzz_parse/c2fe8dcc...(0098545b393f)<BOM>tApoptA...), which beancount reads as one invalid token that starts the line.report_invalid_tokens_of_error_linetook the line-start BOM token as the line's first invalid token, so the run after it never counted as the one the line error stands for.test_parse_line_start_bom_glued_to_invalid_run_is_one_error.fuzz_green_eq_red/bf85c694...(441740b7ea14)R:Rꦝ...). It comes right after a line beancount could not read, and bison is still recovering there, so beancount reports no grammar error for it. rledger's line error (hereP0006) counts as that grammar error. On main and in round 1, the skipped inner-BOM token offset the extra error by accident.fuzz_parse/09ae2404...(7f5ab8dfd98e)\rerrors (stricter on purpose).Parity in round 2
--checkpasses after an--update.Round-2 changed manifest rows (57)
lexer-token-splittolexer-tokens-merged(1):e8844718a38elexer-token-splittomatch(10):036051335d4b16ab138dfd5f49129157109652a0c792ec64866909c6e5179a7db77e5488a6c0a8f87d41dd804649bb66e61fb64bccc3fc9f1bd4c97dlexer-tokens-mergedtolexer-token-split(20):0b419c04c43a1381daa79f1f17b545306a8027638e9503423d783ba3784744fc5614a263453523b63b1548d5cd4aedb37ff14715f27b804d9dfd2d4d8120079b0e2886e68ae5bf709f66f36e422da3fa0b6b23afa9bcf4c5b851bae66d5fe2d6e31fab0005cbe7dd4486909af423c93142a8f4c90421d552lexer-tokens-mergedtomatch(24):1a01923bcf8720b10d01c58c2efe8b1053ce3f279815a11947d0634fdbe3559af3dda56b5602e8a8a1c75b8fd5eb2267615176dafa936d0f54d33263717fe293a31d77dc7e3365e279653e955fbe8b4ab29c1c4890d465ff794091216601b71c96e0cceacc16aa7734c9d07cb26419f2f1e1b82b7b3d8e04ca6869a0c663cb81186cb729d40d88fbfb9de7006002de8amatchtolexer-token-split(2):441740b7ea147f5ab8dfd98eReview round 3
1. A line-start BOM glued to a run, then an inner-BOM token, lost an error. Fixed.
A BOM that starts its line keeps its own extent here, where beancount's invalid token runs on through whatever is glued to it. So
report_invalid_tokens_of_error_linenow treats it as the line's first invalid token, the one the line error stands for:<BOM>foo) is part of that token;<BOM> k:) is one more token.Once the line's BOM diagnostic stands for that BOM, a run with a BOM inside it later on the line gets its own error. This is the reviewer's suggested rule, generalised so that it also covers a BOM followed by a blank.
These now match bean-check (and main):
<BOM>foo x<BOM>y<BOM>tApo x<BOM>y<BOM>$x x<BOM>y<BOM>foo <BOM>a x<BOM>yTest:
test_parse_line_start_glued_bom_then_inner_bom_token_counts_both.2. A BOM before a metadata line's indentation lost an error. Fixed by the same rule.
<BOM> k: Ü:A <BOM>a0 x<BOM>y1is 4 and<BOM> k: Ü:A x<BOM>y0is 3, as in bean-check and main.k:as the line's first invalid token. In beancount it is the<BOM>itself, which a blank follows, sok:is one more token.test_parse_bom_before_metadata_indentation_counts_the_key.Guard:
tests/bom_combination_matrix.rs.scripts/bom-combination-matrix.pyrecords beancount 3.2.3's per-line parse-error counts intotests/data/bom_combination_matrix.tsv. It uses the parity harness's filtering. The table covers 1,078 inputs:<BOM>a, inner-BOMx<BOM>y, plain invalid$n;<BOM>glued to the line,<BOM>g(glued to a run);The prefix goes before the indentation of an indented line.
tests/data/bom_combination_matrix_known.tsv, each with rledger's counts and one of three causes. The causes are named and commented inCAUSES.The three known causes
All three predate #2928. On main, each of the 386 inputs differed from beancount by as much or more. 200 of them are closer to beancount than on main; none is further.
orphan-linesinner-bom-under-line-errorfoo x<BOM>y), is left to that diagnostic. That is one error fewer than beancount; main is the same.account-after-invalid-tokenEight inputs carry both
orphan-linesandaccount-after-invalid-token, which is why the counts add up to more than 386.I measured a fix for
inner-bom-under-line-error: report every inner-BOM token. It fixes 62 more matrix rows and 248 more fuzz inputs, but it turns 88 matching fuzz inputs into mismatches, each a difference the old count happened to offset. I left it for a change of its own.Nit: CRLF. In
query "q" <BOM>"select 1"with CRLF line endings and metadata after it, the\rafter the second"stays inside the string after formatting. Since round 0, that quote opens a string across the CRLF, as in beancount. Known, not changed.Parity in round 3
e8844718a38e. Its<BOM> Raline now matches beancount (2), so its first differing line moved to a pre-existing posting-line difference. The manifest is updated for it.--checkpasses. STRICT baselines pass.Merge. I merged
origin/main(#2927, query crate only) with a plain merge and kept both CHANGELOG Fixed entries. No rebase, no force-push.Review round 4
1. A BOM-led first token after a date or indentation did not spend the BOM diagnostic. Fixed.
When the line error stands for the line's first invalid token and that token starts with a BOM, later runs with a BOM inside them now get their own error.
These now match bean-check:
2024-01-02 <BOM>a x<BOM>y2024-01-02 <BOM>a x<BOM>y x<BOM>zA related gap showed up on indented lines inside a transaction.
<BOM>agave the posting line's generic error plus the token'sP0026, which is 2 where bean-check reports 1.drop_errors_inside_a_line_errornow applies the same "the line's grammar fails first at this token" check to an inner BOM error that it applies to a generic one: the header case from round 1, plus an indented line whose start before the token beancount reads.P0026.<BOM>; cis 2, as in bean-check.<BOM>a x<BOM>yis 2.I measured the broader variant you mentioned (spend the diagnostic for any first token that holds a BOM). It gains 11 more fuzz inputs but loses 7, so I kept the BOM-led condition.
Test:
test_parse_bom_led_first_token_spends_the_bom_diagnostic.2. A line-start BOM glued through valid tokens to an invalid one was counted twice. Fixed.
<BOM>*heading line holds a blank. That token reaches past the run, so it is still reported.<BOM><BOM><BOM><BOM>*7 Z#is 2 in bean-check, and the first version of the fix gave 1.<BOM>12$ x<BOM>y,<BOM>2024-01-02$x x<BOM>y,<BOM>USD$ x<BOM>y,<BOM>#t$ x<BOM>yand<BOM>"s"$ x<BOM>yare 2.<BOM>12<BOM>zand<BOM>2024-01-02<BOM>aare 1.test_parse_line_start_bom_run_through_valid_tokens_is_one_tokenandtest_parse_line_start_bom_heading_rest_is_not_glued.3. The matrix now guards these fixes.
I added four contexts:
2024-01-02 {T});2024-01-02 *;;.I added two prefixes that glue a valid token to an invalid one:
<BOM>12$and<BOM>USD$.The matrix is regenerated with the script: 2,598 inputs, and the test runs in about 1 s.
Reverting each fix makes the matrix test fail:
<BOM> k:taken as the first token)The
first = falseon a line-start BOM is now redundant with the prefix check: a prefix holding a BOM is never a readable start. Removing it alone changes nothing, so the guarded behaviour is the trim, which fails as shown above.The heading-rest exception is guarded by its unit test.
Known list
1,207 inputs, each with rledger's counts. None is further from beancount than on main, and 760 are closer.
orphan-linesinner-bom-under-line-erroraccount-after-line-start-bomeol-reported-on-next-lineSixteen inputs carry both
orphan-linesandaccount-after-line-start-bom, which is why the counts add up to more than 1,207.account-after-invalid-token, and the Parse-error recovery differences from bean-check around invalid dates and column-0 markers #2872 pointer is dropped.P0006appears only when the line's first token is a BOM that starts it: the line then gets the account's error and the BOM diagnostic, where beancount's one invalid token (the BOM's run) is all.eol-reported-on-next-lineis new and has nothing to do with BOMs. The date context exposed it: beancount reports a bare date'sunexpected EOLon the next line.inner-bom-under-line-error) would fix 256 more fuzz inputs and break 98.Parity in round 4
fuzz, 0 regressions.--checkpasses after an--update. STRICT baselines pass.Round-4 changed manifest rows (73)
lexer-token-splittomatch, fuzz (61):0019c86dd54703dfb80f9899082f741d17b30a86ad16d2a40d0a0810905220939c6b5fd521d920b9410924df619fcc3027f3411d07cb2dbadd56d42c39f84c1492024021abac112146d8c5cf8ef849bc5987f20a4b027f3c78174bf331a5eeae535e6205797f538f8242fa855a7afc05116e612ffb845c446a8ed08aafb6738c7b10a91a74707def4258781b3985538f7f188ad3d6148099343a9ad883dcfed07a87841cde17b86c873535c0090d8d5f925081818ef16f45970e96724bc20973999ce260cc1e9a8e03d226849ad4772675fb9c4aa6d4c9309daa0b90a6c4a152587beb97a155db2cf8aea3e27cbab418a580d681b853aa0ff0f5a607ab3cc15137d6ae79a50fb03db70f3e3d448bbe6fc1db9fc3c332d837eb8cc6ba92b14560ca159aa6e972d40c5758117ed61931d1dbe3d8679aa637c4d8d2480e585dda0b14e06365df2518c828e6e25864e96cbbe2b5a3fde783f1ad5accc03af8b06642bf94f94b1607cc5ffa6bd3f6e459lexer-token-splittorl-indented-line, fuzz (7):0fd0fbf8ebdb2ab11a7a71596f2a95563e6e6f7502e0222a9017f346aee8ad3161751e13ae0bd2457622lexer-token-splittorl-top-level-line, fuzz (3):5064df6042ffd178a244d222d6cf3b84ea47lexer-tokens-mergedtolexer-token-split, fuzz (1):39b03d391592lexer-tokens-mergedtomatch, fuzz (1):d5fd1d713a30Review round 5
A. A BOM glued to an account shape is an account now. Fixed in the lexer.
Beancount's account type is
([A-Z]|{UTF-8-ONLY})..., and a BOM is UTF-8-only. So<BOM>Assets:A,<BOM>Ü:Aand<BOM>1:Aare each one ACCOUNT there, and the BOM only makes the name invalid at load time.The canonical
Token::Accountregex no longer excludes U+FEFF from the first character, so the lexer reads the same. The account-name check (E1005) rejects the account on load.rustledger-validate'stest_validate_bom_led_account_is_invalid_account_name.<BOM>A,<BOM>USDand<BOM>Assets:are not account shapes and stay invalid tokens.Because a BOM can now start an account, logos may scan a line-start BOM into a failed account (
<BOM>2024-01-02). TheErrarm therefore caps a line-start BOM's own extent at the BOM itself and lexes the rest afresh. The concatenated-file case is unchanged.is_valid_account_namenow lexes\u{feff}Assets:Aas one account and rejects it. The lexer test pins both.Effect:
$x <BOM>Assets:A<BOM>\t<BOM>Assets:Aopen <BOM>Assets:Cand the other account positionsTest:
test_parse_bom_led_account_is_an_account. The round-1 test no longer lists account positions.B.
A<BOM>bis counted again.report_invalid_tokens_of_error_line, so it is never left to the line's BOM diagnostic.$x A<BOM>bis 2 and@ ! A<BOM>b %xis 3, as in bean-check and main.test_parse_lone_capital_glued_to_bom_is_counted.C. The heading rest after
<BOM>*is counted as beancount lexes it.The part up to the first blank belongs to the BOM's token. The text after the blank is lexed with the lossless tokenizer, and each blank-free run it cannot read whole is one more error. A run is unreadable if it holds an error token or has a lone capital glued to the token after it (beancount's
CAPITALneeds a blank).quiet_after_invalid_tokenskeeps errors that start inside such an unread token.Results, all matching bean-check:
<BOM>*7<BOM>* #tag<BOM>**<BOM>*\t"s<BOM>t"<BOM>* Heading with words<BOM><BOM><BOM><BOM>*7 Z#Test:
test_parse_line_start_bom_heading_counts_the_rest.Nit.
first = falseis removed. The comment onfirstexplains why a line-start BOM never leaves it set for the next token to read.Guard
Token kinds. The matrix gains K (
<BOM>Assets:A{i}) and C (A<BOM>b{i}). It now has every combination of up to two tokens of all five kinds, plus the three-token combinations of L/I/N, across 13 contexts and 5 prefixes: 3,769 inputs.EXTRA. Twenty hand-picked shapes from the reviews, each pinned.Seeded random probe.
PROBE_SEED = 2931, 2,000 inputs, generated by the same script.#!/#+,%, push directives, cost and price, tags, links.pushmetamakes beancount's builder raise; the script names them on stderr.Table. 5,727 rows, test about 2 s. The tab and
\rescapes are new.Known list. 2,991 rows, each with rledger's counts and a cause:
orphan-linesno-worse-than-mainlike-main-without-bominner-bom-under-line-errororphan-lines+account-after-line-start-bomorphan-lines+inner-bom-under-line-errorrecovery-after-error-lineNo row further than main, checked against a main build.
<BOM>to$,<BOM>AssetstoÜAssets). For 146 rows that line counts the same way on main as here, with beancount's count unchanged.like-main-without-bom. It covers your example<BOM>12$ 2024-01-02 open Assets:C USD #tagagainst$x 2024-01-02 ...: after a line's first invalid token, beancount keeps parsing and reports a later grammar error, where rledger reports one diagnostic per line.recovery-after-error-line) is an indented line right after a line beancount could not read. Beancount's recovery reports no grammar error there; rledger does (Parse-error recovery differences from bean-check around invalid dates and column-0 markers #2872). Its replacement analog differs only because the replacement changes the line before it.Parity in round 5
Still 78,461.
2 new matches and 2 regressions:
fuzz_parse/3d32b9d6<BOM>G:3#\x00is now an account glued to#, on an indented line after a broken one. rledger reports the glued#; beancount's recovery does not. Main did the same forG:3#\x00without a BOM.fuzz_parse/c71bf0c515 mismatches changed category.
--checkpasses after an--update. STRICT baselines pass.Round-5 changed manifest rows (19)
lexer-token-splittolexer-tokens-merged, fuzz (1):01283cce0de0lexer-token-splittomatch, fuzz (2):28cfa3f0fdd659766d726781lexer-tokens-mergedtolexer-token-split, fuzz (7):1c2449827fa39b2f1475b5b29bded2eea40dbdac17d7856cbe8087979eb6ca617e441a3fdaf4cd32d74blexer-tokens-mergedtorl-top-level-line, fuzz (1):6820e6c5d32fmatchtolexer-token-split, fuzz (2):4021abac11214b027f3c7817rl-indented-linetolexer-token-split, fuzz (6):40725296503b9978ff2c4d82a9c982f622f0d15ec77bb761d9ea47088ea2f7a15f80272eReview round 6
Change A is reverted.
Token::Accountis as on main.E1005never named the BOM;open <BOM>Assets:D.Errarm. When the text after a mid-line run of BOMs is account-shaped, the run keeps its own extent, as line-start BOMs do.Token::Account. This is checked bylogos_lexer::starts_with_account, which reads no further than the next blank. There is no new regex.open <BOM>Assets:Cis oneP0026with its quick fix again, and the directive keepsAssets:C.$x <BOM>Assets:Aand<BOM>\t<BOM>Assets:Aare 1 error, as in bean-check: beancount's own error there is the load-time account-name check, which the matrix filters out.is_bom_run_before_account). This applies in:report_invalid_tokens_of_error_line;quiet_after_invalid_tokens;holds_an_invalid_token, which holds a BOM-only token until the next one says whether it is an account.test_parse_bom_glued_to_account_keeps_the_accountreplaces round 5's account test;open <BOM>Assets:Candopen <BOM><BOM>Assets:C;rustledger-validate's round-5 test is reverted.Linear by construction, with a guard.
A line-start BOM is one logos error of one character, as on main, so nothing re-enters logos per BOM.
A mid-line run is taken whole.
The CST's lookahead checks only the character after a BOM token. A token followed by another BOM stops there.
My first version of the revert still had a quadratic lookahead in the CST: it trimmed the rest of the run for each line-start BOM, and a 1 MB line took 50 s. The guard below caught it.
New guard,
test_tokenize_long_bom_runs_are_linear:aand to an account, and with a blank beforea.Timings, release build of
parse_error_lines, best of 3:a<BOM>* Heading with some wordslines<BOM>2024-01-01 open Assets:AlinesThe heading lines are slower because each now reports beancount's 5 errors instead of main's 1: 250k errors built and printed against 50k. Lexing their rests is linear.
Known list: every differing line has a real cause.
no-worse-than-mainis gone, and so are the round-3 to round-5 names.I classified each differing line of each row with a local rule set, one rule per cause, applied line by line, and checked the
like-main-without-bomrule against a main build. The classifier is not committed; the rules are described in the TSV header and inCAUSES. A row names the causes of all its lines.Unclosed
pushtag/pushmetaerrors are now line 0 on rledger's side too, as in the parity harness (RLEDGER_EOF_CODES). That removed "pushtag reported at line 0".Rows per cause (a row with several causes counts under each):
indented-line-after-error(Parse-error recovery differences from bean-check around invalid dates and column-0 markers #2872)mid-line-hash-bang(part 2 of compat(parser): an invalid run should swallow a following quote, #! or #+ mid-line, as beancount's lexer does #2928)bom-glued-to-accountinner-bom-under-line-errorline-after-error-line(Parse-error recovery differences from bean-check around invalid dates and column-0 markers #2872)like-main-without-bominvalid-account-after-invalid-tokenone-diagnostic-per-lineextra-construct-errorfailed-push-still-pushedeol-reported-on-next-lineIn total 3,083 rows differ from bean-check, 0 unclassified.
eol-reported-on-next-lineis back.Further than main: 286 rows have at least one line further from bean-check than main. Each such line has one of these causes:
like-main-without-bomindented-line-after-errorline-after-error-linebom-glued-to-accountlike-main-without-bom, the same line in the input with each BOM replaced by an ordinary character counts the same way on main. Per your nit, a BOM run glued to an account maps toÜ(<BOM>AssetstoÜAssets), and everything else to$. All of these lines hold strictly.indented-line-after-errorandline-after-error-line, the line matches beancount when it stands alone. In context, main matched only because its BOM count offset the recovery difference.bom-glued-to-account, theP0026you asked for here is one error more than beancount's parse errors, and main swallowed the BOM in a;comment.Parity in round 6
fuzz_green_eq_red/329c733dmatched in round 5 only because A read its BOM into an account. It now counts as on main, with the same 12 errors.--checkpasses after an--update. STRICT baselines pass.Nits
like-main-without-bomdescription now states theÜmapping.account-after-line-start-bomrows are superseded by the per-line causes above.Review round 7
This push also carries the plain merge of
origin/main(#2930). Both sides ofCHANGELOG.mdare kept, and both cache notes: loader v69 (#2925) and v70 (#2928), WASM v92 and v93. The caches stay at 70/93.1 and 2: one predicate, and beancount's account rule.
logos_lexer::bom_led_accountdecides with the lexer's own account rule. It lexes the word with a non-ASCII stand-in (Ü) in the BOMs' place, so the lexer's first-character rule applies.<BOM>Assets:A,<BOM>assets:A,<BOM>1:A,<BOM>:Aand<BOM>-:Aare all accounts, as in beancount.account_follows_bom_run), the run keeps its own extent, so the BOM gets itsP0026and the account stays an account.<BOM>assets:A), the token ends where beancount's account ends, so a glued tail is one more token.cst::convert::is_bom_account_token:report_invalid_tokens_of_error_line;invalid_runs, which was missing it;quiet_after_invalid_tokens;holds_an_invalid_token.<BOM>* <BOM>Assets:A(1),<BOM>* x\t<BOM>Assets:A(2), and$xfollowed by<BOM>assets:A,<BOM>1:A,<BOM>:Aor<BOM>-:A(1 each).3: line-start bookkeeping before an account.
<BOM><BOM>Assets:A$xis now 2, and<BOM>Assets:A x<BOM>yand<BOM><BOM>Assets:A x<BOM>yare both 2. All three match bean-check.test_parse_bom_led_account_shapes_count_as_beancount.k(<BOM>assets:A{i}, an account only with its BOM);T(<BOM>Assets:A{i}$x, a glued tail after K);bom-bom, two line-start BOMs before every token. It replacesglued-currency.4: the known list is reproducible.
The classifier is now in the test:
cause()intests/bom_combination_matrix.rs, one rule per cause, each commented. For every input that differs from beancount, the test:BOM_MATRIX_UPDATE=1rewrites the list.The fixture now records, per input:
<BOM>replaced by$, a BOM run glued to an account replaced byÜ).like-main-without-bomis checkable without a main build.scripts/bom-combination-matrix.py --main-binarywrites these columns.New or refined rules for the mislabels the review found:
lone-capital-glued-to-tokensnow counts a capital glued to the\rof a CRLF line.line-start-bom-before-commentis new. A line-start BOM keeps its extent, so a;or%after it hides the rest of the line. This one comes from compat(parser): an invalid run should swallow a following quote, #! or #+ mid-line, as beancount's lexer does #2928's deliberate line-start rule, and the header and comments now say so: "all butline-start-bom-before-commentpredate compat(parser): an invalid run should swallow a following quote, #! or #+ mid-line, as beancount's lexer does #2928".indented-line-after-headingis new: an indented line after a*heading.Table: 7,429 rows. Known list: 3,995 rows. Lines per cause (a row with several causes counts under each):
indented-line-after-errormid-line-hash-bangbom-glued-to-accountinner-bom-under-line-errorlike-main-without-bomline-after-error-lineindented-line-after-headinginvalid-account-after-invalid-tokenone-diagnostic-per-linefailed-push-still-pushedextra-construct-errorlone-capital-glued-to-tokensline-start-bom-before-commenteol-reported-on-next-lineNits
trim_start_matcheson the rest of the run, which the byte counters do not see, fails it in 7 s. Every BOM-run trim in the lexer and the recovery goes through the countedleading_bom_run.Parity in round 7
--checkrun shows no row changed from round 6.Timings against main are unchanged from round 6:
aopenlinesReview round 8
1. A line-start BOM before an account beancount reads only with its BOM: fixed.
When a line-start BOM run is followed by an account in beancount's sense only (
bom_led_account:<BOM>assets:A,<BOM>1:A,<BOM>-:A,<BOM>a-b:C), the tokens up to that account's end are part of it.The part of a token past that end is beancount's next token. It counts as invalid only when it lexes so:
$x,.b,'band<BOM>$xcount;"x",#t,^l,!,@and;cdo not.Errors that start inside an rledger error token now survive
quiet_after_invalid_tokens. That one rule covers both this tail and the<BOM>*heading rest.All of these now match bean-check:
<BOM>assets:A$x,<BOM><BOM>assets:A$x,<BOM>1:A$x,<BOM>1:A:B$c,<BOM>-:A$x,<BOM>a-b:C$x,<BOM>assets:A.b,<BOM>assets:A'b,<BOM>assets:A<BOM>$x<BOM>assets:Afollowed by"x",#t,^l,!,@or;cThese shapes are
EXTRArows now, and the matrix gains kindt(<BOM>assets:A{i}$x) with every line-start prefix.2. The guard can no longer absorb a regression.
New hand-kept file:
tests/data/bom_combination_matrix_worse_than_main.tsv. Each row gives the input, the line, the cause, beancount's count for the line alone, and a one-line reason.The test fails, before any update, on any line further from bean-check than the recorded main count that is not in that file.
BOM_MATRIX_UPDATEnever writes the file, and it refuses to refresh the known list while such a line is unlisted.The file is authoritative for these lines, and the test checks that each listed cause holds:
like-main-without-bom: the analog columns equal beancount's and rledger's counts on the line.bom-glued-to-account,invalid-account-after-invalid-token,line-error-beside-bom-diagnostic): alone, rledger is off in the same direction and at least as far as in context.Seeded with today's 414 lines: 399
like-main-without-bom, each checked against the analog, and 15bom-glued-to-account. The 15 are the<BOM>; c <BOM>Assets:Arows, where main hid the BOM in a comment.Rule order is tightened.
invalid-account-after-invalid-tokenis asked beforebom-glued-to-account, and both before the recovery rules. Each rule's comment now says what it requires.The six mutations, each run with
BOM_MATRIX_UPDATE=1, which never wrote the known list:invalid_runsquiet_after_invalid_tokensline_start_boms_end = Some(range.end)holds_an_invalid_token(either branch)EXTRArowopen ... "BAD"withkk: <BOM>Assets:D; alsotest_parse_bom_account_in_metadata_keeps_booking_method_checkaccount_follows_bom_runfalsetest_parse_bom_glued_to_account_keeps_the_accountfails because the account is lostNits
bom-glued-to-accountandline-start-bom-before-commentcome from compat(parser): an invalid run should swallow a following quote, #! or #+ mid-line, as beancount's lexer does #2928's own design.Counts in round 8
Table: 8,486 rows. Known list: 4,602 rows. Accepted further-than-main lines: 414.
Parity unchanged at 78,460.
STRICT baselines pass, and green equals red on all 44,589 pinned fuzz inputs.
Timings unchanged:
aopenlinesReview round 9
1. The new quadratic: fixed, and guarded.
bom_led_accountscanned the word after a BOM run to the next blank, then lexed it, once per BOM run on the line. A long line of~<BOM>1:Arepeats made that quadratic.-,:, non-ASCII), so the word ends at the first other character, and the scan is bounded by the account it reads. The doc comment says so.test_tokenize_long_bom_runs_are_lineargains three shapes:x\n<BOM>assets:A+~<BOM>1:Arepeated, the same afterx $x, andx\n<BOM>Assets:A+ the repeats. It counts scanned bytes (at most 8 times the input) and keeps the 30 s backstop. On the round-8 lookahead it fails, with about 1 GB scanned.2. Matrix tails and the heading context.
s(<BOM>"s"),u(~<BOM>1:A) andx(<BOM>x). New context: a<BOM>*heading.3. The accepted list must name the cause the classifier finds.
check_worse_than_mainrequiresa.cause == w.causeas well as the cause's own check. An entry with a different cause fails, and so does an entry that is no longer worse than main ("remove it").4. Seed-909931 probe lines: resolved.
scripts/bom-combination-matrix.py, next to the round-5 probe (seed 2931).mid-line-hash-bangnow has a real check. The table has a sixth column: beancount's count on the input with each mid-line#!/#+replaced by a plain invalid token. rledger must count that analog exactly as beancount does.<BOM>* Heading<BOM>a-b:C{ 1<BOM>2: 2 errors, as in bean-check.<BOM><BOM>kk:<BOM>;c\t<BOM>1.5: 1 error, as in bean-check. In a tail split, a;now ends the line, so the comment is not lexed for invalid tokens.<BOM>* Heading,Ü:A: 2 errors, as in bean-check, where it was 3._, not blanked. A blank would split a word, so theFݾ:Üglued to the BOM inx\n<BOM>Fݾ:Üwould become an account of its own. That doubled the count and turned up as one changed fuzz row while the parity run was being checked. A word only partly inside an invalid token is still reported as written (Invalid account 'G:Ψ@3O+.1'), read back from the line.$x Heading,Ü:Ais not fixed. It is main's mechanism and is older than this PR, and fixing it means the broad masking that regressed those 63 rows.Nits
<BOM>:A$x: not fixed. After a line-start BOM, rledger's lexer reads a:in column 0 as an ignored line, exactly as main does. The miscount comes from that rule, not from the BOM run.bom-glued-to-accountrow now gives its own reason, not the query row's.Mutations
Each was run with
BOM_MATRIX_UPDATE=1, and none of them wrote the known list. The first nine were measured before the final masking change. That change only removed accepted rows, so the list is stricter now.;break in the tail split_(final code)Counts in round 9
Table: 11,155 rows. Known list: 5,248 rows.
Accepted further-than-main lines: 441, made up of:
like-main-without-bombom-glued-to-accountinner-bom-under-line-errormid-line-hash-bangThe byte-for-byte masking took 173 lines off the accepted list: 148
invalid-account-after-invalid-tokenand 25bom-glued-to-account. Each was an extraP0006on a BOM-glued account. One line was added,<BOM>A<BOM>b \t<BOM>Ü:A #+x A<BOM>b x<BOM>y: it islike-main-without-bom, and the cause is the mid-line#+x(part 2).Parity: 78,461, up from 78,460. One fuzz row now matches: the inner invalid account in a BOM-led invalid token is no longer counted. The manifest was updated for that one explained row, and no row regressed.
STRICT baselines pass, and green equals red on all 44,589 pinned fuzz inputs.
Timings:
aopenlines<BOM>assets:A+~<BOM>1:Arepeats$x <BOM>assets:A+ repeats<BOM>Assets:A+ repeatsReview round 10
This push also carries a plain merge of
origin/mainat d728311 (#2920), with no rebase and no force-push.CHANGELOG.mdkeeps both entries.S1. A comment inside a BOM-led tail: fixed.
invalid_runsnow also says whether a comment ended the text. The tail split breaks on that, wherever the;falls: right after the account, or after a later BOM-led account in the tail. The special case for a leading;is gone.<BOM>assets:A~<BOM>1:A;c $x: 1 error<BOM>assets:A,<BOM>a-b:C;c $x: 1 error...;c $x $y: 1 errorv(~<BOM>1:A;c $x) andw(,<BOM>a-b:C;c $x).<BOM><BOM><BOM>assets:A"x"<BOM>a-b:C;c\t<BOM>1.5, which carried the false reason, now matches bean-check (1) and is gone from the list.S2. Cause checks name the error kinds.
The test now has each line's
P0026andP0006counts.The
cause()rules ask for the kinds as well as the counts:invalid-account-after-invalid-tokenneeds aP0006for each error beyond beancount's.bom-glued-to-accountneeds aP0026for each.inner-bom-under-line-errorneeds the line'sP0026.holds()checks the same through a newkinds_hold. Forbom-glued-to-accountit also checks the rest of the line: with each account beancount reads with its BOMs written asAssets:X(ordinary_accounts, anACCOUNTto beancount either way), rledger must count the line exactly as beancount does.The dead
line-error-beside-bom-diagnosticcause is removed.Every accepted row passes the stricter check.
2024-01-02 price USD 1 <BOM>assets:A1 1is now anEXTRArow, accepted asbom-glued-to-accountand checked as above. This is not main's1 $x 1overcount:price USD 1 $x 1price USD 1 Assets:A1 1unexpected ACCOUNT)price USD 1 <BOM>Assets:A1 1P0026)price USD 1 <BOM>assets:A1 1<BOM>Assets:A1So the malformed amount stands for beancount's
unexpected ACCOUNT, and the extra error is the gluedP0026(compat(parser): an invalid run should swallow a following quote, #! or #+ mid-line, as beancount's lexer does #2928's design). Theordinary_accountscheck verifies exactly this.A new cause,
brace-hash-before-tag, covers a{#glued to a tag character outside a heading rest (foo {#t). rledger's lexer has a{#total-cost token there, on main too. It came up on the<BOM>g <BOM>* H {#t ...rows of the new heading context, which are not headings.S3.
{#in a<BOM>*heading rest: fixed.invalid_runsreads a{#as beancount does: a{, then whatever the#starts.TokenIter::new_mid_line. There is no re-scan, so the cost stays linear.<BOM>* H {#tis 1 error, as in bean-check, and<BOM>* H {#t{#$x {#"a b"is 2.heading-brace-hash(<BOM>* H {#t {T}).S4. The linearity guard fails instead of hanging.
recv_timeout.from[text.len()..].trim_start_matches(BOM).len() == from[text.len()..].len()inis_bom_account_token), the guard now fails:<BOM>*heading rest of{#t{#$xrepeats.Nits
test_parse_invalid_account_on_bom_free_line_keeps_its_p0006.Heading,Ü:Aalone is still main's oneP0006, so the N1 mutation (mask every line) now fails it.test_parse_partly_invalid_account_word_keeps_mains_message. It says it pins main's message, not beancount's behavior (beancount's account there isG:Ψ).{#t{#$xreports$x;%\0\003100now reports\0\003100, as bean-check does.invalid_runs, not the whole tail.Mutations
Each was run with
BOM_MATRIX_UPDATE=1, and none wrote the known list. They used the round-9 runner, with its targets updated to the new code.test_parse_bom_account_in_metadata_keeps_booking_method_checktest_parse_bom_glued_to_account_keeps_the_accountfailstest_parse_invalid_account_on_bom_free_line_keeps_its_p0006fails{#I don't have the definitions of N2 to N5 or Q6c, so I couldn't re-run them. Please apply them to this push.
Counts in round 10
Table: 11,821 rows (665 new). Known list: 5,538 rows.
Accepted further-than-main lines: 505, made up of:
like-main-without-bombom-glued-to-accountinner-bom-under-line-errormid-line-hash-bangThe new accepted lines come from the new tails and heading context:
like-main-without-bom. Main came closer on these only by miscounting a BOM; on 54 of them, the BOM offset main's{#tovercount.bom-glued-to-account: two<BOM>; crows and the price row.Parity: unchanged at 78,461, and
--checkpasses. Six fuzz rows changed only their token text, to bean-check's.STRICT baselines pass, and green equals red on all 44,589 pinned fuzz inputs.
Tests: parser, lsp, loader and wasm pass (1,918 passed, 0 failed), and so does
wasm-pack test --node.Timings:
aopenlines<BOM>assets:A+~<BOM>1:Arepeats$x <BOM>assets:A+ repeats<BOM>Assets:A+ repeats<BOM>* H+{#t{#$xrepeatsReview round 11
The parser's counts are unchanged this round. Parity
--checkpasses with no row changed from round 10, still 78,461. The fixes are in the guard, plus one parser cleanup and two pins.1. Recovery causes come first.
2024-01-02 *when indented, computed byalone_cellsin the script.cause()now asks a recovery cause first, beforelike-main-without-bomand before any cause of the line's own, whenever rledger counts the line alone exactly as beancount does alone. Otherwise the recovery rules are asked where they were.<alone>must also agree with the table's column.like-main-without-bomto their recovery cause, each now checked by its alone count:indented-line-after-errorline-after-error-lineindented-line-after-headingafter-error(fooand then<BOM>assets:A {T}), and anEXTRArow forfoo\n<BOM>assets:A <BOM>, nowline-after-error-line.2. Composite causes, each part verified.
&:bom-glued-to-account&mid-line-hash-bangorbom-glued-to-account&extra-construct-error.parts_holdtakes the parts out in turn and measures each share on what is left:Assets:X. This must be more than none and no more than the line'sP0026s.#!/#+is made an ordinary invalid run, against beancount's own count for that input.bom-glued-to-accountandmid-line-hash-bangchecks are the same function with one part.ordinary_accountsnow follows beancount'sACCOUNTrule. A BOM counts as a name character, and a run after a number starts an account (-2.5<BOM>a-b:C).bom-glued-to-account-in-error-line(43 known rows, none worse than main) covers a glued BOM whose rewrite turns the line into one rledger reads with a construct error of its own, a posting's trailing tokens. There, the line'sP0026s drop by exactly the difference, and one non-BOM error takes their place.glued-hash-bang(<BOM>1:A:B #+x {T}) andglued-price(price USD 1 <BOM>:A\t{1 USD} {T}).EXTRArows for the review's two examples:<BOM>1:A:B #+x#t\t{#t$xisbom-glued-to-account&mid-line-hash-bang.price USD 1 <BOM>:A\t{1 USD}#tisbom-glued-to-account&extra-construct-error.price USD 1 ...inputs: the review didn't list them, so I couldn't check them one by one. Everyprice USD 1 <BOM>...input that the newglued-pricecontext and theEXTRArows generate now has a cause, and nothing in the matrix is left unexplained.3. Token text is pinned.
test_parse_bom_line_reports_beancounts_invalid_token_text. It checks that{#t{#$xgives$x,1A$xgivesA$x,"s"$xgives$x,A{#tgivesA{#t,A{#givesA{#, and two BOM-led tails give$x.data/bom_combination_matrix_texts.tsv(8,942 rows): the invalid tokens rledger names, line by line, for every input with a BOM. A change fails the test.BOM_MATRIX_RELABEL=1, so a plainBOM_MATRIX_UPDATE=1cannot take in a weakened rule or a changed text.4. Linearity guard.
resume_unwind), not reported as "took over ... quadratic".Nits
if comment { break; }is removed: the rest runs to the end of the line.invalid_runsnow handles a{#through the same code as every other token. There is no separate lone-capital reset any more:A{#givesA{#, as in bean-check. That is the one shape where the lexer reads the capital and the{#apart, and it is pinned in the token-text test.new_mid_line'sat_line_start = falseis pinned bytest_token_iter_new_mid_line_applies_no_line_start_rule. Without it, the word and blanks before the resume point are read as anIndent.holds()checks, and describes every cause's check, composites included.Mutations
Each was run with
BOM_MATRIX_UPDATE=1, and no list was written by any of them. N2 to N5 were never defined for me; I named and ran my own versions of the S, T and Q mutations.test_parse_bom_glued_to_account_keeps_the_accountfailstest_parse_invalid_account_on_bom_free_line_keeps_its_p0006failsP0006check incause)P0026s)P0006check inholds){#)new_mid_lineat line start){#)A{#)Counts in round 11
like-main-without-bomindented-line-after-errorline-after-error-lineindented-line-after-headingbom-glued-to-account&mid-line-hash-bangbom-glued-to-accountinner-bom-under-line-errormid-line-hash-bangbom-glued-to-account&extra-construct-error--checkpasses with no rledger output changed from round 10.wasm-pack test --node(35).Review round 12
The parser is unchanged this round: parity
--checkpasses at 78,461, with no rledger output changed. All the changes are in the guard and the generator.1.
inner-bom-under-line-erroris verified, not applied by shape.The generator now reads beancount 3.2.3's own lexer (
lexer.lex_iter_string) for every input, and the table carries two new columns, as byte offsets:ACCOUNTtokens that start with a BOM;The cause now needs two things:
ACCOUNT(which admits UTF-8) no longer counts;$(still one invalid token to beancount), rledger counts the line exactly as beancount does (inner_boms_are_the_difference).The 6 accepted rows were not that. For example, in
<BOM>g 2024-01-02 * "n" <BOM>assets:A0<BOM>"s"the BOM afterA0is inside beancount's ACCOUNT. Writing those accountsAssets:Xleaves rledger at 1, so the account is not the mechanism either. The rows are nowone-diagnostic-per-line, which an accepted row must now verify:later_grammar_is_the_difference).Here that is the line diagnostic standing for the
<BOM>ginvalid token, and theunexpected ACCOUNTafter it as the whole difference. Main's 2 came from reportinggas a token of its own.New verified cause
bom-account-under-line-diagnostic(33 known rows, none worse than main): oneP0026stands for the grammar error at a BOM-led account, and with those accounts writtenAssets:Xrledger counts the line as beancount does.The known list's
inner-bom-under-line-errorlabel went from 278 rows to 153. The rest are nowone-diagnostic-per-lineorbom-account-under-line-diagnostic, each by its own check.2.
ordinary_accountsuses beancount's token boundaries.ACCOUNTtokens beancount's lexer reports, so the heuristic is gone. That covers:$<BOM>a:B,AB_<BOM>a:Band1.5.<BOM>a:B, where the BOM is in an invalid token;ab:<BOM>a:B,x 2024-01-01<BOM>a:B,-<BOM>a:Band#t<BOM>a-b:C, where an account starts.2024-01-02 custom "b" 1 <BOM>-:A\t#t<BOM>a-b:C@, are nowEXTRArows.3. Negative shares are documented. The doc of
parts_holdand the accepted file's header now say that the glued and construct shares are positive, while the#!/#+share is often negative (-2 to -3 on every glued&hash-bang row).4.
kinds_holdis gone.cause()already guarantees, and the cause equality requires them.invalid-account-after-invalid-tokenkeeps its alone check.inner-bom-under-line-errorandone-diagnostic-per-linenow have checks of their own.5. Updates refuse regressions.
BOM_MATRIX_UPDATE=1now refuses a line counted further from beancount than the known list recorded, or than beancount's own count for a row that matched at the last update. This applies even when main is no closer.data/bom_combination_matrix_matching.tsv: 64-bit FNV-1a hashes of the sources, 6,718 rows, seeded from the last commit's 6,715. A row in neither list is new to the table and has nothing to regress from.typosin.typos.toml, like the parity manifest: its hex hashes read as misspellings.BOM_MATRIX_RELABEL=1and a reason written by hand in the known row's new optional fourth column. Updates keep that reason.<BOM><BOM>kk:<BOM>\t-2.5\t-2.5).Linearity guard
Mutations
Each was run with
BOM_MATRIX_UPDATE=1, and none wrote a list.S2k is gone with
kinds_hold.Counts in round 12
like-main-without-bomindented-line-after-errorline-after-error-lineindented-line-after-headingbom-glued-to-account&mid-line-hash-bangbom-glued-to-accountone-diagnostic-per-linemid-line-hash-bangbom-glued-to-account&extra-construct-errorwasm-pack test --node(35). Caches stay at 70/95, as main is still d728311.Review round 13
The parser is unchanged again: parity
--checkpasses at 78,461. Every change is in the test harness and the generator.1. A stale or cut matching list now fails.
computedare exactly the matching list. It reports the missing and extra hashes, as the known and texts checks do.# total <n> <digest>, holds the row count and a hash of the rows, and both modes check it before the list is used. So a list cut down to its header fails even underBOM_MATRIX_UPDATE=1("the matching list has no# totalline").$n0so beancount counts 0 where rledger and main count 1, a regression from matching that is no worse than main:BOM_MATRIX_UPDATE=1fails, and so does addingBOM_MATRIX_RELABEL=1.2.
one-diagnostic-per-lineis gated.later_grammar_is_the_difference(): rledger counts beancount's count less exactly beancount's grammar errors after the line's first error.pop-without-pushis asked first. It covers 6 known rows that were mislabelled before.line-start-bom-before-commentcovers every line start rledger's lexer, like beancount, skips (skipped_line_start, as inbeancount_ignores_line):;,%,!,*,:,&,?, and a#not before a tag character. It now has 45 known rows, up from 7 (corrected in round 14: this said 46, and round 14 moves 32 of them back tobom-account-under-line-diagnostic).eof-error-on-last-line(3 rows): beancount reports an end-of-file error on the line after the last, and rledger reports the same number on the last line. Example:2024-01-02 *\n <BOM>1:A{.bom-free-line-as-on-main(5 rows): a line with no BOM that rledger counts exactly as main does.data/bom_combination_matrix_exceptions.tsvwith 16 lines that no rule explains. Each lists rledger's, beancount's and main's counts, beancount's later grammar errors, and rledger's count with the line's inner BOMs made$. A listed line that a rule explains or that now matches fails the test as stale.$rewrite does not fix, mostly indented probe lines. One is$x <BOM>Ü:A\t* A.one-diagnostic-per-linewent from 133 rows to 99.rl >= 1) now fails: 15 listed exceptions become stale.Docs
parts_holdand the accepted file's header give the measured hash-bang shares: usually -2 to -4, -1 on one row, and positive (+1) on one row.Nits
scripts/bom-combination-matrix.pyexits unlessbeancount.__version__ == "3.2.3".<for counts> <reason>as its fourth and fifth columns.BOM_MATRIX_RELABEL=1and a reason written for exactly the new counts.inner_boms_are_the_differenceno longer callsinner_in, which is removed.Mutations
Each was run with
BOM_MATRIX_UPDATE=1, and none wrote a list.Counts in round 13
wasm-pack test --nodepasses (35).Review round 14
This round merges
origin/mainand moves the WASM cache. The parser is unchanged: parity--checkpasses at 78,461, and the only source change is a comment in the lexer. Everything else is tests and the matrix guard.1. A BOM before a posting's price or cost (known change vs main, tracked in #2954).
Assets:A 1 HOOL <BOM>@ 2 USD(also<BOM>@@ 2 USDand<BOM>{2 USD}): bean-check 3.2.3 and main report 1 error. This PR reports theP0026and then twoE3001(residual 1 HOOL,residual -2 USD).@or{, and recovery keeps the posting without its price or cost. Main already does the same for any other invalid character there (\x11{2 USD}), so this is that recovery gap, newly reached.test_parse_bom_before_price_or_cost_drops_it_issue_2954asserts one parse error and a posting with no price and no cost for the three BOM shapes and\x11{2 USD}. Its doc names Recovery drops a posting's price or cost after an invalid token, then reports a spurious imbalance #2954, so the fix must update it on purpose.2. The trailing-pending rule of
holds_an_invalid_tokenis tested.test_parse_bom_alone_at_eof_after_directive_is_one_error:2024-01-03 open Assets:C USD "BAD" <BOM>at the end of the file, with no final newline, is one error (P0026) and theopenis kept. bean-check 3.2.3 reports one error too (Invalid token: '').pending_boms.is_some()madefalsefails this test.3. The line-start test in the lexer's
Errarm is tested.test_tokenize_indented_bom_runs_to_next_blank: through the publictokenize()(whitespace dropped),x\n <BOM>"y" z\ngivesError("<BOM>\"y\""),Error("z").span.start == self.last_newline_endfails it.at_line_startinstead passes every parser test (cargo test -p rustledger-parser --all-features, lib and integration). I agree it is equivalent today:last_newline_endmoves only whereat_line_startis set, andnew_mid_linealways starts past offset 0. I kept the flag and wrote this in a comment there: it keepsnew_mid_line's promise (no line-start rule for its first token) without relying on that offset.4.
line-start-bom-before-commentno longer takes BOM-led account lines.ACCOUNT(BomRoles::account_at). For<BOM>:A$x!it does, so no invalid token runs through the line, and the rule's comment did not hold.bom-account-under-line-diagnostic, which verifies them (account_grammar_error_is_the_difference). Known rows:line-start-bom-before-comment45 to 13,bom-account-under-line-diagnostic1 to 33. The round-13 text said 46; it was 45, and I corrected it there.5. Exceptions.
like-main-without-bomis also asked last, on a line no further from beancount than main: the analog columns must show beancount counting the BOM-free line as it counts this one, and main counting it as rledger does here. Asked last, it takes no line from another cause. The six lines are removed from the exceptions file, which keeps 10.reason_countsreadsrledger counts X where beancount counts Y (main Z)from every reason (a reason without it panics), andlisted-exceptionapplies only when those are the line's counts now. Otherwise the line is unexplained, and the message names the counts the listed reason was written for. The file's header says so.like-main-without-bombranch disabled: fails, 6 inputs unexplained.6. Merge and caches.
origin/main(4bc5bd8, through fix: make check, WASM, FFI and LSP agree on close-with-balance and after a booking error #2947). CHANGELOG: both sides kept. The WASM cache note conflicted; both notes are kept.CACHE_VERSION95 to 100, withLOADER_CACHE_VERSION_PIN70. The v97 note on main said "v95 is held by fix(parser): run a mid-line BOM's invalid token to the next blank, as beancount does #2931"; it now says v95 was never released. The one v100 note records that v93 and v95 were never released.CACHE_VERSIONstays at 70 (above main's 69, and claimed by no other open PR), with bothFIXTURE_VERSIONs at 70 and one v70 note.Counts in round 14
line-start-bom-before-comment45 to 13,bom-account-under-line-diagnostic1 to 33,listed-exception16 to 10,like-main-without-bom671 to 677.Gates
cargo fmt --all --check, clippy--all-features --all-targets -D warnings, andRUSTDOCFLAGS=-Dwarnings cargo doc --workspace --no-depspass.cargo test --all-features: parser 938, loader 427, lsp 404 and wasm 175 passed, 0 failed.wasm-pack test --nodepasses (38).--self-testpasses.--checkwith beancount 3.2.3 at the pinned fuzz commit9bc79f4freports no regressions, at 78,461 of 111,323 inputs.Review round 15
The parser's output does not change in this round: parity
--checkstill matches 78,461 of 111,323 inputs, and a 420,000-input differential run against the round-14 head shows no difference. The round removes two line-start checks that never changed any output, and adds tests to the matrix classifier.1. Two of the three line-start BOM checks were no-ops (F1).
holds_an_invalid_token: removed. The check can never fire. This function walks only anopenor a transaction. The node's header starts with its date, and every later line the parser takes into the node starts with indentation (is_indented_directive_continuation,is_indented_transaction_body_line). So a line that a BOM starts becomes anERROR_NODEof its own, and its BOM token is never inside the node. Thebeforetracking was only there for this check, so it goes too, andbom_token_starts_its_linefolds back intois_line_start_bom_token. A comment at the function says why it needs no line-start test.quiet_after_invalid_tokens: removed. This check is reached, but it changes nothing. Without it, a line-start BOM counts as its line's first invalid token, which is how beancount reads it. That line is always anERROR_NODEline:ERROR_TOKEN) or an invalid date.Removing the check makes this pass agree with
report_invalid_tokens_of_error_line, which already treats that BOM as the line's first invalid token. The doc comment says it changes no output today, and why.I looked for an input where either check changes the output and found none:
So the "What" section no longer says that all three places go through one rule. Only
report_invalid_tokens_of_error_lineasksis_line_start_bom_token, because only anERROR_NODEline can hold such a BOM. Its doc now says so.2. The late
like-main-without-bomrule is tested directly (F2).test_cause_like_main_without_bom_needs_beancounts_analog_countcallscause()with made-up counts for one line: rledger 1, beancount 2, main 1, and main 1 on the BOM-free analog.like-main-without-bom.None), even though main counts the analog as rledger counts the line.get(&counts.analog_bc, l) == bfrom the late branch fails this test (Some("like-main-without-bom")whereNoneis expected). As the review found, the matrix test alone still passes under that mutation.3. The "BOM in indentation" row of the Before / after table was stale (F3).
openlines, then2024-01-02 * "x"/<BOM>Assets:A 1 USD/Assets:B -1 USD. I checked each tool:4: Invalid account name: <BOM>Assets:A(aParserErrorfromparse_file, not a load-time check as the row said). It also reports the validation error3: Invalid reference to unknown account '<BOM>Assets:A'.P0012+P0026, thenE3004andE3001.P0026only, thenE3004andE3001.4.
reason_countsreads the counts only from the start of a reason (nit).rledger countsanywhere in a reason. It now strips that prefix, readsX where beancount counts Y (main Z)in order, and panics with the expected form when a reason does not start that way.test_reason_counts_reads_the_leading_counts, andtest_reason_counts_rejects_counts_not_at_the_start(should_panic).split_onceinstead ofstrip_prefix) fails the second test.5. Pre-existing BOM recovery gaps: new issue #2956.
<BOM>2024-01-02 * "x"with two postings: rledger gives 3 errors (P0026+ twoP0012), bean-check gives 1.P0026+P0012+E3004/E3001on a transaction that beancount drops, bean-check gives 1.<BOM>; c xat the start of a line: rledger gives 1 error, bean-check 3.2.3 gives 3 (Invalid token: '<BOM>;','c','x';parse_fileagrees). The review said 4.Caches. No change. The parser's output is unchanged, so WASM stays at 100 and the loader at 70 (origin/main was 4bc5bd8 at this round; see round 16).
Gates
cargo fmt --all --check, clippy--all-features --all-targets -D warnings, andRUSTDOCFLAGS=-Dwarnings cargo doc --workspace --no-depspass.cargo test --all-features: 941 parser tests (938 + 3 new), 427 loader, 404 lsp and 175 wasm passed, 0 failed.wasm-pack test --nodepasses (38).--self-testpasses.--checkwith beancount 3.2.3 at the pinned fuzz commit9bc79f4freports no regressions, at 78,461 of 111,323 inputs.Review round 16
The round found the parser's behavior clean and one test gap.
\r,\f,\v, NBSP, U+2028, U+3000 and tab variants inserted at every position of 10 templates, including CRLF copies) and 600,000 random inputs from a different generator: 0 output differences, 0 panics, 0 green/red mismatches. Instrumented, the removedholds_an_invalid_tokencheck never fired, and the removedquiet_after_invalid_tokenscheck fired about 1.2 million times with no output change.--checkreports no regressions, at 78,461 of 111,323.Fixed: half of the late
like-main-without-bomcondition was untested. Dropping&& get(&counts.analog_main, l) == rpassed every test, because the round-15 test fixed main's analog count at rledger's.late_analog_countsnow takes main's analog count, and the test (renamedtest_cause_like_main_without_bom_needs_both_analog_counts) adds a case where main counts the analog differently from rledger's count here: the line stays unexplained. With that half dropped the test fails.Merged
origin/main(e6c8054, #2950, loader options and tests only): clean, no conflict. Caches: unchanged at WASM 100 and loader 70, still above main (97 and 69) and claimed by no other open PR (WASM 98 #2944, 99 #2945 and #2946, 101 #2952; loader 71 #2945, 73 #2944).Gates:
cargo fmt --all --check, clippy on the parser--all-features --all-targets -D warnings, the matrix test file (4 passed) and a warmcargo check --workspace --all-features --all-targetspass on the new head. The review ran the full gate set on 2c9b736 (fmt, clippy, doc, parser 941, loader 427, lsp 404, wasm 175, STRICT baselines,wasm-pack test --node38); this round changes only the matrix test file.Review round 17
The round found the parser's behavior, the merge, this body and every gate clean. Its only findings were untested guards in the matrix test's classifier,
cause(): a 69-mutant sweep (each conjunct or disjunct forced true or false, or a branch removed) left 12 survivors. This round pins every one that can change a result at once, rather than one per round.New direct
cause()tests (matrix test file), on made-up counts for line 3 (line3_counts,line3_cause,with_account_role), each with a case where the rule holds and one where the guard alone turns it away:test_cause_bom_free_line_as_on_main_needs_main_count:bom-free-line-as-on-mainneedsr == m, so a BOM-free line counted differently from main (a real regression) stays unexplained.test_cause_listed_exception_needs_its_reason_counts: the first entry of the exceptions file, on its own table row's counts (row_counts, split out ofcheck_row), islisted-exception, and stops being one when main's count moves.test_cause_bom_glued_to_account_needs_an_account_on_the_lineandtest_cause_glued_in_error_line_needs_an_account_on_the_line: both glued-BOM causes need a BOM-led account on the line.test_cause_glued_in_error_line_needs_more_errors_than_beancount:bom-glued-to-account-in-error-linenever explains a line short of beancount's count.test_cause_inner_bom_under_line_error_needs_fewer_errors_and_a_bom_diagnostic:inner-bom-under-line-errorneedsr < band aP0026on the line (boms > 0, which the reviewer thought probably equivalent: it is not, as the test shows).test_cause_brace_hash_before_tag_needs_more_errors,test_cause_line_start_bom_before_comment_needs_fewer_errors,test_cause_pop_without_push_needs_fewer_errors: the direction guard of each.The reviewer's other probably-equivalent guard,
r > binbom-glued-to-account-in-error-line, is pinned by the test above: with a made-upP0026count, the rewrite can gain one and keep a non-BOM error, which the rule would otherwise take for the mirror image.Equivalent guards, verified and commented at their sites:
glued_asked):r != b(the only caller,check_row, skips a line withb == r) andboms > 0(GLUED, the first part of each glued cause, needs0 < share <= f.boms; the check only spares a parse).line-start-bom-before-comment'stext.starts_with(BOM): without a BOM before it, beancount ignores a skipped line start, sob == 0andr < balready fails. (Wrong: corrected in round 18, the guard is needed.)one-diagnostic-per-line'sr < b:later_grammar_is_the_difference'schecked_subneedsb >= r, andb == rnever reachescause.l > 0in the first recovery filter.recovery()is alreadyNoneon line 0, so the filter readsrecovery().filter(|_| facts.alone_matches()), with a comment.Full sweep, re-run on ad6bcff (one scratch copy with its own target dir, mutants run one after another; the only later change, 2a02bd6, is a clippy fix outside
cause()). 72 mutants, built afresh over the currentcause()(every atom forced true or false where that can change a path, and every branch removed): 68 killed, 4 survive, each one of the equivalent guards above.r <= b,l == 0, heading, after-error, line-after-error)like-main-without-bomfailed-push-still-pushed,eol-reported-on-next-lineinvalid-account-after-invalid-tokenaccount_intrue, branch removedr != btrueb == r)boms > 0trueGLUEDneedsshare <= boms)bom-glued-to-account-in-error-line(r > b,account_in, rewrite, branch)mid-line-hash-bang,lone-capital-glued-to-tokensbrace-hash-before-tagline-start-bom-before-comment:r < b, skipped start, account, branchline-start-bom-before-comment:starts_with(BOM)trueb == 0)inner-bom-under-line-errorbom-account-under-line-diagnosticpop-without-pushone-diagnostic-per-line: check true, branch removedone-diagnostic-per-line:r < btruechecked_subneedsb >= r)eof-error-on-last-linebom-free-line-as-on-mainlisted-exceptionextra-construct-errorlike-main-without-bomMerged
origin/main(526f833, #2945). Conflicts inCHANGELOG.mdand an LSP test module: both sides kept. Caches: main took loader v71 and WASM v99, so the loader cache moves to v72 (LOADER_CACHE_VERSION_PINand bothFIXTURE_VERSIONs too), with one v72 note naming #2931 and what a stale blob would serve; the v70 note is gone and main's v71 note now says v70 was held here and never released. WASM stays at v100, above main's v99, its note now saying loader v72. Allocated to open PRs: loader 73 (#2944); WASM 101 (#2952), 102 (#2944). (Corrected in round 18: #2946 holds no cache version.)Gates (on 2a02bd6, the cache constants moved, so the full set):
cargo fmt --all --check, clippy--all-features --all-targets -D warnings,RUSTDOCFLAGS=-Dwarnings cargo doc --workspace --no-deps, tests for parser (950 passed), loader (442), lsp (408) and wasm (178), both STRICT baselines,wasm-pack test --node(38), parity--check(no regressions, 78,461 of 111,323) and a warmcargo check --workspace --all-features --all-targets.Review round 18
The round found the parser's behavior and every gate clean. Its findings were in the cache notes, this body and the matrix test's classifier,
cause().Cache allocations corrected. #2946 holds no cache version (its diff changes no cache constant). Checked against each open PR's diff: loader 73 is held by #2944; WASM 101 by #2952 and 102 by #2944. The loader v72 note now says "(v73 is held by #2944.)", the WASM v100 note "v101 is held by #2952 and v102 by #2944", and the Caches bullets and the round-17 merge paragraph above say the same. Main's own v99 note ("v98 is held by #2944") is outside this PR's hunks and is left alone.
line-start-bom-before-comment's BOM guard is needed (round 17 called it equivalent: wrong). beancount's error for the line before can land on a skipped line start:2024-01-02 openthen;cgetsunexpected EOL, expecting ACCOUNTon the;cline (bean-check 3.2.3), sor < bholds on a BOM-free skipped start. The guard stays, its comment says why, andtest_cause_line_start_bom_before_comment_needs_a_bompins it on real counts (bean-check andparse_error_lines):;con line 4 is beancount 1, rledger 0, sobom-free-line-as-on-main;<BOM>;cis beancount 2, rledger 1 (itsP0026), soline-start-bom-before-comment. Without the guard the first becomesline-start-bom-before-comment, and the test fails.inner-bom-under-line-error, on a real row.inner_boms_are_the_differencenow checks that the line has a BOM inside an invalid token, as its doc says; the matrix test still passes, so every real row it explained has one. On counts rledger produced the check is equivalent (with no inner BOM the rewrite changes nothing, so the line countsrl, and the cause asks withrl < bc), which a comment at the site says; it keeps made-up counts from passing on an empty rewrite. The test now reads its own table row ($n0 x1<BOM>y: beancount 2, rledger 1 with oneP0026, main 1, the BOM insidex1<BOM>y) and checks it is turned away with no inner BOM, with noP0026, or with rledger counting more than beancount, plus the made-up case (rledger 0 on2024-01-02 * "x" <BOM>q, which rledger counts 1) that only the new check turns away. The glued tests' docs now say their counts and account role are made up to reach the rule.Older
cause()guards:pop-without-pushno longer strips BOMs beforepoptag/popmeta:<BOM>poptag #tis one invalid token to beancount (Invalid token: '<BOM>poptag', no pop error), so the strip was unreachable. Removed, with a comment.block_err's look past the indentation (trim_start_matches(is_blank).starts_with(BOM)) is pinned bytest_cause_indented_line_after_error_sees_an_indented_bom(made-up counts: an indented<BOM>Assets:Aline beancount counts nothing on, then an indented line rledger counts 1 and main 0).r <= b(the only caller skipsb == r, so it isr < b), and the order ofGLUEDandGLUED_HASH_BANG(both cannot hold:GLUEDalone takes the whole difference, and a hash-bang share is never zero).Full sweep, re-run on the final
cause()(one scratch copy with its own target dir, mutants run one after another): 82 mutants (every atom forced true or false where that can change a path, every branch removed, each glued entry removed, the glued order swapped, and the new in-span check forced true): 78 killed, 4 survive, each commented as equivalent at its site.l == 0, heading, after-error, line-after-error)r <= basr < bb == r)block_err(bc > 0, BOM after indentation, BOM at column 0 only)like-main-without-bomfailed-push-still-pushed,eol-reported-on-next-lineinvalid-account-after-invalid-tokenaccount_intrue, gate falser != btrueb == r)boms > 0trueGLUEDneedsshare <= boms)GLUEDandGLUED_HASH_BANGswappedbom-glued-to-account-in-error-linemid-line-hash-bang,lone-capital-glued-to-tokensbrace-hash-before-tagline-start-bom-before-comment(now withstarts_with(BOM)true)inner-bom-under-line-error, and the new in-span checkbom-account-under-line-diagnosticpop-without-pushone-diagnostic-per-line: check true, branch removedone-diagnostic-per-line:r < btruechecked_subneedsb >= r)eof-error-on-last-linebom-free-line-as-on-mainlisted-exceptionextra-construct-errorlike-main-without-bomorigin/mainhad not moved (still 526f833), so no merge.Gates:
cargo fmt --all --check, clippy--all-features --all-targets -D warnings,RUSTDOCFLAGS=-Dwarnings cargo doc --workspace --no-deps, tests for parser, loader and wasm (1572 passed, 0 failed) and a warmcargo check --workspace --all-features --all-targets.Review round 19
The round found the parser and the merge clean. Its findings were in the matrix test's classifier,
cause(), and its helpers: 123 mutants, 34 surviving, 27 of them undocumented. This round kills every one that can change a result and comments the rest at their sites.New
cause()tests (matrix test file; every count not said to be real is made up to reach the rule, and each test doc says so):test_cause_indented_line_after_error_sees_an_indented_bomgains a third case: the BOM inside the header's string (2024-01-02 * "x<BOM>"; bean-check 3.2.3 and rledger both report nothing for the input) is not a line that starts with a BOM, soblock_errstays false. Killsstarts_withascontains.test_cause_pop_without_push_needs_fewer_errorsgains2024-01-02 * "poptag": apoptagthat does not start the line is no pop, so the line staysbom-free-line-as-on-main.test_cause_glued_construct_needs_a_positive_construct_share: a glued share of 2 with a construct share of -1 adds up, but is notbom-glued-to-account&extra-construct-error; +1 is.test_cause_glued_in_error_line_needs_a_non_bom_error_in_place: theP0026s go by exactly the difference, but no non-BOM error comes in their place (2024-01-02 open Assets:Xcounts 0), sobom-glued-to-account-in-error-linedoes not hold.test_cause_line_start_bom_before_comment_needs_a_skipped_start:<BOM># cis the cause;<BOM>#tand<BOM>#-(a tag after the#) are not.test_cause_line_start_bom_before_comment_needs_no_account_at_its_start: an account on line 1 does not turn the rule away; one at the line's own start does (account_at's==).test_cause_brace_hash_before_tag_needs_more_errorsgains{#$: no tag character after the{#.test_cause_eof_error_on_last_line_needs_each_condition: each of the line check,rl[eof] == 0and the sum, dropped alone, turns a case intoeof-error-on-last-line.test_cause_eol_reported_on_next_line_needs_a_date_alone:<BOM>2024-01-02is a date alone (the BOM strip),2024-01-021is not (exactly ten characters).test_cause_lone_capital_glued_to_tokens_skips_a_leading_bom:<BOM>A$.test_cause_invalid_account_after_invalid_token_needs_an_account:<BOM>q Üx:Ais the cause,<BOM>q Üx(no:) is not.account_inforced to "any account").Equivalent, commented at the site with the reason:
eof_error_on_last_line'sbc[eof] > 0: with the other three holding andbc[eof]0, the line hasb == r, whichcheck_rowskips.ordinary_inner_boms's span filter (the reviewer's item 12): rewriting another line's inner BOM to$keeps that line an error line with the same start, indentation and strings, so the asked line's count does not move. I tried to break it with line-start, glued, header, push and pop lines before the line, each with its BOM rewritten; none moved the count. So I documented it rather than adding a test.glued_boms_replace_construct's>as>=: equality meansall_after == bc, soGLUEDholds and is asked first.3..lvs4..l(unwrap_or(3)gives line 3 anyway);later_grammar_is_the_difference'srl >= 1(onlybc0 passes without it, a line withbc == rl); the hash-bang check inparts_hold(with no mid-line#!/#+the share is 0 on the table's rows, turned away); the dead(r, b)update afterHASH_BANG(always the last part);line_span's end (no account or inner BOM starts at a\n).Simplified:
skipped_line_startno longer checks for a\nafter the first character (sis one line). An unknown part inparts_holdisunreachable!(every caller passes the three parts).GLUED'sshare <= 0is nowshare < 0, leaving zero to the shared zero check. That check is therefore no longer redundant: the matrix test fails without it. Its comment and theGLUED/GLUED_HASH_BANGorder comment now point at each other, since the order changes no result only because of the check.Sweep, re-run on the final file (each mutant applied, the matrix test binary run, the file restored, one after another): 51 mutants, covering every one listed in the review, the previously documented ones, and 17 more across the helpers. 36 killed, 15 survive, each commented as equivalent at its site:
contains, popcontains, constructshare < 0, in-error-line non-BOM conjunct,#tag exclusion and its-_/., brace tag check, eof line /rl[eof]/ sum, date>= 10and BOM strip, lone-capital strip, account:,account_at<=)share < 0/> bomsdropped, parts sum, construct sign, in-error-linegone,indentedstrip, hash-bang position and BOM filter, skipped;and*arms, eof alternatives, heading strip, block_errbc > 0, date dash,account_in, lone-capital\r)share == 0droppedbc[eof] > 0, inner span filter, in-error-line>=rl >= 1, hash-bang check, dead update, GLUED<= 0, unknown part,line_spanend)r < b, glued gater != bandboms > 0, one-diagnosticr < b)(
share == 0is counted among the 36 killed.)Merged
origin/main(8773d67, #2944). Conflicts inCHANGELOG.md(both entries kept) and the twocache.rsfiles. Caches: loader 74 (LOADER_CACHE_VERSION_PINand bothFIXTURE_VERSIONs too) and WASM 104, above main's 73 / 102 and #2952's WASM 103. One note per version: the v74 and v104 notes replace this PR's v72 and v100 notes; main's v71 note now says v70 and v72 were held here and never released, and the v104 note says v100 (here) and v101 (#2952) were never released. #2944's v98 and v102 notes are unchanged. The matrix test passes unchanged after the merge.Gates (on 2b82468):
cargo fmt --all --check, clippy--all-features --all-targets -D warnings,RUSTDOCFLAGS=-Dwarnings cargo doc --workspace --no-deps, tests for parser (973 passed), loader (442), lsp (409) and wasm (178), 0 failed, both STRICT baselines,wasm-pack test --node(42), parity--self-test, parity--check(no regressions, 78,461 of 111,323) and a warmcargo check --workspace --all-features --all-targets.Review round 20
The round's findings were all in the matrix test's classifier,
cause(), and its helpers, plus one cache note. This round's sweep is wider than the review's: 451 mutants overcause()and every helper it calls (andholds), run one after another on the final file, which was checked byte-identical after the sweep. 2 of them do not compile, 409 are killed, and 40 survive, each commented as equivalent at its site. No survivor is undocumented.Classifier changes:
date_alonenow asks the parser's ownparse_date(beancount'sDATE,[0-9]{4,}[-/][0-9]+[-/][0-9]+, that is a real calendar date) of the line with trailing blanks and a CRLF's\rtrimmed. So2024/01/02and2024-01-021(January 21 to beancount) are dates alone, as bean-check 3.2.3 reports them (itsunexpected EOLon the next line). It no longer strips leading BOMs: beancount reads<BOM>2024-01-02as one invalid token and reports nothing on the next line (bean-check and rledger both count it 1 on its own line), so the round-19 test that called it a date alone was wrong and now says the opposite. An invalid date (2024-13-45) is reported on its own line on both sides, so it is no date alone either. The matrix test's known list is unchanged by this.holdsis onematchon the cause; its two standalone checks sharealone_counts.parts_holdchecks the construct sign in the construct arm. Same behavior; the string==chains were the source of meaningless lexicographic mutants.parts_holdhash-bang comment (item 16) was wrong and is rewritten: the analog rewrites every#!/#+of the input past a line's first character, including one after a line-start BOM (<BOM>#!x $y: rledger 1, the analog 2), so the check is needed. A new made-up-count test pins it.ordinary_inner_boms's$(item 17) is not a true equivalent: anxturns$n0 t<BOM>ninto$n0 txn, which rledger counts 1, not 2. A new real-count test pins it, and the comment says why it is a$.Per finding (real counts are bean-check 3.2.3 and main's
parse_error_lines, recorded by hand in the tests throughrecorded_row; made-up counts are labeled in each test's doc):date_alonetrim2024-01-02,2024-01-02,2024-01-02 \r,2024-01-02\t,2024-01-02\r(bc 4:1, rl 3:1), both linescontains2024-01-02 openthen;c <BOM>(line 4 stayslike-main-without-bom):&?arms<BOM>:x $y,<BOM>&x $y,<BOM>?x $y, plus!,%,#(bc 2 or 3, rl 1)<BOM><BOM>;c $ypoptag2024-01-02 openthen<BOM>poptag #t(line 4 stayslike-main-without-bom); the comment at the rule cites the test"x" {#_,{#.,{#a(bc 1, rl 2); made-up{#-,{#/,{#1(rledger counts those as beancount does)==gone ==P0026going against 2, two against 1)A%y,2024-01-02 A| "x",2024-01-02 * "x" A|,2024-01-02 A" "x"(bc 1, rl 2), the\ron table rows; the other 16 made up, since rledger counts them as beancount does in every context tried (header, posting amount, price, flag, line start, open)parse_date; slash dates and2024-01-021added and tested on real countsalone_matchesonNonetest_cause_recovery_first_needs_a_matching_count_alone(made-up)<BOM>*,<BOM>#are not the cause,<BOM>;and<BOM>*xare (made-up; rledger counts each 1, as beancount does)hash_bang_analogmid_linetest_hash_bang_analog_rewrites_only_past_a_lines_startwordsfilter,ordinary_accountsname,bvsf.bc: commented;$vsx: not equivalent, killed (above)Sweep, by function (killed / survive; survivors all commented as equivalent):
cause(plus 1 not compiling)holds,alone_countsparts_holdeof_error_on_last_lineLineFactscheckslone_capital_gluedskipped_line_startbrace_hash_before_taghash_bang_analogglued_boms_replace_constructis_blankdate_alonemid_line_hash_bangBomRolesline_spanordinary_accounts,ordinary_inner_bomsaccount_after_bom,rledger_linesexceptions,reason_counts(1 not compiling),strip_boms,indented,words,standalone_countThe mutants: every comparison and
&&/||in those functions swapped (214, generated), and 237 by hand: every conjunct and disjunct dropped, every branch removed, every match arm removed or forced, every list and set member removed,starts_withandcontainsswapped, every trim removed, stripping one BOM for all, boundary moves, the glued list's entries removed and reordered, and each check inholdsforced.The 40 survivors, by argument (each commented at its site): in
cause(19), niner > b/r < bas>=/<=and twol == 0asl <= 0(the only caller skipsb == r; a line number), the recoveryr <= basr < b(twice, as an operator and by hand), the glued gate'sr != bandboms > 0(boms >= 0, and each dropped), the header range, the glued order and the one-diagnosticr < b; ineof_error_on_last_line(5), both==of the line test as>=andrl[eof] <= 0(no line pasteofhas a count; a count), andbc[eof] > 0as>=and dropped; inline_span(2),k + 1 >= l(only line 0's span changes, which nothing reads) and the end taking the\n; inparts_hold(6),GLUED's and the construct arm'sshare <= 0(three: a zero share is turned away below),bvsf.bc, the dead(r, b)update and the unknown part;glued_boms_replace_construct's>=;later_grammar'srl >= 1;account_inby an account's end (an account holds no\n); the two other account names and the span filter of the rewrites; thewordsfilter; andholds'sw.bc <= bc_alone(withalone == rlandbc == bc_alonethe first test already holds).New tests (matrix test file):
test_cause_recovery_first_needs_a_matching_count_alone,test_cause_line_start_bom_before_comment_takes_each_skipped_start,test_cause_brace_hash_before_tag_takes_each_tag_character,test_cause_one_diagnostic_per_line_needs_exactly_the_later_errors,test_cause_glued_in_error_line_needs_exactly_the_difference,test_cause_inner_bom_under_line_error_rewrites_to_no_token,test_cause_lone_capital_glued_to_tokens_takes_each_listed_character,test_hash_bang_analog_rewrites_only_past_a_lines_start,test_is_blank_takes_a_space_or_a_tab,test_rledger_lines_puts_an_unclosed_push_on_line_zero,test_cause_glued_hash_bang_needs_a_hash_bang_on_the_line,test_cause_mid_line_hash_bang_sees_one_after_a_line_start_one,test_cause_early_like_main_without_bom_needs_both_analog_counts,test_cause_extra_construct_error_needs_mains_count,test_holds_checks_each_kind_of_cause; and new cases in the eol, line-start (BOM), pop, eof, listed-exception, inner-BOM and invalid-account tests.Merged
origin/main(ab337cd, with #2952 and #2962). Conflicts inCHANGELOG.md(both entries kept) and the WASMcache.rs. Caches: loader 74 and WASM 104, above main's 73 / 103. One note per version: v102 says v100 (here) was never released, #2952's v103 note keeps "v101 was never released" and drops "v104 is held by #2931", and the v104 note holds no claim about other versions.Gates (on b89980f):
cargo fmt --all --check, clippy--all-features --all-targets -D warnings,RUSTDOCFLAGS=-Dwarnings cargo doc --workspace --no-deps, tests for parser (988 passed), loader (445), lsp (430) and wasm (178), 0 failed, both STRICT baselines,wasm-pack test --node(42), parity--self-test, parity--check(no regressions, 78,461 of 111,323) and a warmcargo check --workspace --all-features --all-targets.Review round 21
F1, a BOM glued before a price, cost or tolerance (parser, both paths).
1 HOOL<BOM>@ 2 USD(and<BOM>@@,<BOM>{2 USD},<BOM>{{4 USD}} @@ 5 USD,<BOM>~, LF and CRLF) counted 2 here where bean-check 3.2.3 and main count 1. The cause was inquiet_after_invalid_tokens, not indrop_errors_inside_a_line_error: a posting'sunexpected trailing tokenserror starts where the amount ends, which for a glued token is the token's own first byte, and only an error starting before the token was dropped as a construct check the token sits in (the spaced1 HOOL <BOM>@already was). Now a construct check's error (aSyntaxErrorthat is not anunexpected inputone) that starts at the token and runs past it is treated the same. The balance shapes (1.00<BOM>~ 0.01 USD,1.00 <BOM>~ 0.01 USD: 2 here, 1 on main and bean-check) were a header-line case the rule kept on purpose (price /6"E_X, where the grammar fails before the token). A header line's construct check around the token is now dropped too when the header grammar reads up to the token: the newheader_grammar_reachesruns the header's tokens up to the token throughfirst_header_defect, the ruledirective_header_checkapplies. This also fixes the BOM-free analogs, sobalance Assets:A 1.00 $~ 0.01 USDis 1, as in bean-check (main 2), and 17matrixinputs of the parity run newly match (balance-tol1.00 X~andtxn-expr(1 + 2)X */3X USDforXin^ $ " _ ' .). Green and red agree on every new test, the matrix rows and the parity run.The glued shape drops the price or cost the token stands in front of, as the spaced one does (a price after a dropped cost,
{{4 USD}} @@ 5 USD, is kept). #2954's body and the CHANGELOG now say so.New matrix rows (in
EXTRA, regenerated against main'sparse_error_lines): a BOM glued, and spaced, before@,@@,{,{{,{{..}} @@,~in a posting and before~in a balance, LF and CRLF (28), plus the F2/F3 shapes below (4). All 28 F1 rows match bean-check.Differential (
~/.cache/rl-tmp/r21/diff.py): a BOM inserted at, and substituted for, every position of 14 templates (open with currencies and booking, transaction header with tags and links, posting with cost and price, total cost and price, flag and expression, balance with tolerance, pad, note, price, custom, option, include, pushtag / note / poptag, metadata), LF and CRLF: 2,460 inputs, bean-check raised on none.The fix moved 34 inputs closer to bean-check and none further. The 12 before it were the F1 shapes: balance tolerance (4), cost and price (2), total cost and price (2), and 4 CRLF metadata lines. The 4 that remain are those:
k: "v"\r<BOM>\nandn: 1 USD\r<BOM>\nunder anote, inserted and substituted (bean-check 2, main 2, here 3). They are not new to this PR's logic: a\rwith a token glued after it counts one more than bean-check on main too (\r$: main 3, bean-check 2), and main counted the BOM shape right only because it read the BOM as layout. Each islike-main-without-bomby the matrix's own rule. Opened as #2966; not fixed here. No input is error-free on one side only.F2, classifier survivors. Each named mutant is killed or commented:
strip_bomstrim_matches2024-01-02 openthen<BOM>*<BOM>and<BOM>#<BOM>(line 4 staysline-start-bom-before-comment)brace_hash_before_tagis_none_or"x" {#(made-up counts) is no causeaccount_after_bomis_none_or"x" $y Üx:Awith aP0006(made-up) is no causeholdsinvalid-accountis_none_orcheck_worse_than_main(&[])reports every accepted linec == "listed-exception"stale_exceptions; killed by$n0 x1<BOM>yline 3 listed (stale) and by a row of every other single cause excepting nothingat = 1ordinary_accounts/ordinary_inner_bomsunwrap_or(1)hash_bang_share, pinned by its own testunwrap_or(1)standalone_countof a clean line is 0data_linesfor every list, pinned by its own testparse_exceptions/parse_acceptedread from text, with tests for each field, a blank reason and aTODOF3,
date_alone. It no longer asks the parser:beancount_datematches beancount 3.2.3'sDATEregex ([0-9]{4,}[-/][0-9]+[-/][0-9]+, either separator in either place) and its date rule (a Python date: year 1 to 9999, month 1 to 12, a day of that month, leap years; each field read into a wrapping 32-bit integer, as its C code does, so4294967297-01-01is year 1 there). After the date, blanks,\rand a;comment are allowed (2024-01-02 ;c,\t;c,;cglued). Every case intest_beancount_date_reads_dates_as_beancount_does(31 dates, 20 non-dates, 11 lines) was checked with bean-check 3.2.3. The rule now needs exactly one error moved: the date's line counts one more than bean-check, the next line one fewer (test_cause_eol_reported_on_next_line_needs_one_error_moved). The two rows the reviewer found are noweol-reported-on-next-line(2024-01-02 ;c<BOM>then anopen, and2024-01-02 ;<BOM>on the last line), real counts, in the table and in the test. The recovery-first test now uses a date line after an error line (its old made-up counts moved the error the wrong way).F4, cache. The loader caches only an error-free load (
result.errors.is_empty()inloadcache.rs), and every input this PR changes has a parse error on main and here (the differential finds no input error-free on one side only; every mid-line BOM outside a string or comment is an error on both). So no loader blob can hold a changed output, and the loader bump is dropped:CACHE_VERSIONstays 73, bothFIXTURE_VERSIONs are back to 73, and the v74 note is gone. The v71 note says v70 and v72 were held here and never released, and why no loader version is needed. WASM moves to 106: #2946 merged during this round with WASM 105, so this PR's change takes 106 (one note; it says loader v73, unchanged, and that v104, held here, was never released; #2946's v105 note is kept as it merged, and v103's note now says v104 was never released). The WASM payloads archive sources with parse errors, so a WASM bump is needed.LOADER_CACHE_VERSION_PINis 73. Theeof_error_on_last_linecomment no longer assumes a final\n.Sweep (on the final file, one mutant after another, the file checked byte-identical after): 834 mutants over every helper and the checker (every non-test function from
fnvtoregressed_rows,RECOVERY_CAUSES, and the matrix test's body outside itsBOM_MATRIX_UPDATE=1block, which only writes the data files; its decisions live in the helpers swept here,relabeled_rows,regressed_rows,reason_holds,known_rows). Generated (~/.cache/rl-tmp/r21/sweep/gen.py): every comparison,&&/||,+/-/*swapped; every!dropped; method swaps (is_some_and/is_none_or,any/all, the three trims,find/rfind,starts_with/ends_with,saturating_sub/checked_subtowrapping_sub,split_once/rsplit_once,min/max,first/last,abs_diff,trim); every integer literal plus and minus one; everystrip_bomsand.filterdropped; everyifcondition forced true and false; every conjunct and disjunct forced neutral; every member of a character set, list and pattern alternative dropped; every match arm forced true and false; everyboolfunction forced true and false. 731 killed, 47 do not compile, 56 survived. Of the 56, 3 are now killed by new tests (each rerun on the final file:reason_holdswith greater counts,regressed_rowsboth ways), and the 53 left are each commented as equivalent at its site: ther > b/r < b/l == 0family incause(18; the only caller skipsb == r),eof_error_on_last_line(6), theparts_holdzero shares (4),later_grammar'srl >= 1(2),beancount_date's% n <= 0(2), the one-separatorsplit_onces (3), the blank-reason trims (3), the rows guard of the matrix test (5), the failure-message-only reads incheck_row(3), andwords,lone_capital_glued,account_after_bom,line_span,glued_boms_replace_construct's>=,holds's<=and the seal'srfind(1 each). A first pass of 849 mutants on the file before this round's last tests (702 killed, 44 not compiling, 103 surviving) is what the new tests and comments answer; the 834 are on the file after them. No survivor is undocumented.Merged
origin/maintwice: a4d53b6 (#2965, CI only, no conflicts), then d38898f (#2946), with one conflict in the WASMcache.rsnotes, resolved as above.Gates: (on 41d0c28)
cargo fmt --all --check;cargo clippy --workspace --all-features --all-targets -- -D warnings;RUSTDOCFLAGS=-Dwarnings cargo doc --workspace --all-features --no-deps; tests for parser (1,019 passed, with both STRICT baselines on the copied compat corpus), loader (450), lsp (430) and wasm (181), 0 failed;wasm-pack test --node(45) after the #2946 merge; thefuzz_green_eq_redcorpus test (parse_green_eq_red_corpus) in the parser run; parity--self-test, and--checkwith no regressions, 78,478 of 111,323 (the manifest drops the 17 matrix pins that now match); the pre-pushcargo check --workspace --all-features --all-targets.Review round 22
WASM cache. v105's note ended "(v104 is held by #2931.)", against the v103 and v106 notes; it now says v104 was held here and never released. Then
origin/mainwas merged (2124386, #2969), which took WASM 107. #2970 holds 108 and #2971 holds 109, so this PR now takes 110. One note per version: the v110 note replaces this PR's v106 note and says v104 and v106 were held here and never released, and that 108 and 109 are held by #2970 and #2971; #2969's v107 note now says v106 was held here and never released. Loader stays 73 (LOADER_CACHE_VERSION_PIN73). The CHANGELOG entry says v110.quiet_after_invalid_tokensandheader_grammar_reachessurvivors. Each named mutant is now either killed by a test, or gone because the code was simplified, with the argument at its site:'\t'dropped from the indentation trimtest_parse_invalid_token_is_one_error(\tAssets:A 1 HOOL$@ 2 USD,$~,{{2 .USD}},{{2 .USD}} @@ 3 USD), and a tab indent intest_parse_bom_glued_before_price_cost_or_tolerance_is_one_error(every tail, LF and CRLF). bean-check 3.2.3 counts 1 on each.e.span.start - offto+ off(theinside_unreadlookup)test_parse_bom_run_after_the_leading_bom_counts_the_rest(<BOM><BOM><BOM><BOM>*7 Z#and two shorter forms: 2 errors each, as in bean-check)SyntaxErrorconjunct, and the(content > line_start || construct_check)conjunct (>=,<, swap, forced true)construct_checkalone. The forced-true mutant is not equivalent after all: on 781,065 inputs (below) it changes 4,619 outputs, all with two BOMs at the start of the file. There the header's line error starts past the line's start, and dropping it loses the error that names the invalid token. Killed by the newtest_parse_header_after_two_leading_boms_names_its_invalid_token. Theconstruct_check-only form changes none of the 781,065 outputs; the comment says why.construct_checkon an error that starts at the token (start-eq-at-no-construct, a survivor of this round's first sweep)e.span.start > atin the other branch (>=)binary_searchkeeps itheader_grammar_reaches: the four earlyreturn falseflipped,right_biasedtoleft_biased,.findto.next(), the token-start check (is_some_and, forced false, removed), the finalis_none_orcst::convert::tests. One covers a header token the rule reads up to, including the first token of a second directive. One covers a token the rule fails before, a metadata key, a posting account, an empty source and an offset pastu32::MAX. One covers a comment line that is leading trivia of the next directive's node..last()to.first(), andend = first, for the rule'sendendonly when it consumes no token, and it always consumes a header's first token. Sofirstis passed, with that argument at the site.first < line_endto<=;e.span.start > toto>=ERROR_NODEline with only kept errors. For the second, no error starts at a line's\n. Each changes none of the 781,065 outputs.e.span.end > atto>=>=mutant moves outputs closer to bean-check and never further. Opened as #2967: a posting's sign check that ends at an invalid token, e.g.Assets:A -$x(bean-check 1, main 2, here 2). The site points to it.The 781,065 inputs are the review's 153,634, each also with the head removed, with one and two BOMs before it, with no final newline, with tab indentation and with CRLF. The branch's final
parse_error_linesgives the same output as before this round on every one of them.Matrix helpers.
regressed_rows'continuetobreak: killed bytest_regressed_rows_goes_on_past_a_new_row(a new rowu, thentknown at3:2with bean-check3:1and now3:3: one regression)..lines()to.split('\n'): killed indata_linesby a CRLF case intest_data_lines_skips_only_headers_and_blanks.matching_hashesreads the checked-in list, so there the mutant is commented, andtest_data_files_hold_no_carriage_returnpins that no data file holds a\r.eol-reported-on-next-linenow needs both halves at once, as its docstring says: one more on the date's line AND one fewer on the next (moved_to_next_line).test_cause_eol_reported_on_next_line_needs_one_error_movedchecks both lines for each case, each half alone included. The recovery-first test's made-up counts now put beancount's error on the line after the date. The three real rows still classify.#2966 now lists the wider
\rshapes the review found. Each was checked with bean-check 3.2.3, main and this branch (counts as bean-check / main / here):\r<BOM>line after any directive: 1 / 1 / 2 (\r$is 2 on main);\r<BOM>~,\r<BOM>@and\r <BOM>~on header lines: 1 / 2 / 2; on metadata lines: 2 / 2 / 3;\r, a blank, then a token (close Assets:A\r $~): 1 / 2 / 2.Other rows from the review. The
pushmetarow (pushmeta k: "v"then2<BOM>024-01-02 close Assets:A: 1 / 1 / 2) is #2872's recovery, not this PR's BOM handling. beancount cannot read line 3 (k:is an invalid token there), and its recovery swallows the2. The BOM-free2$024is 2 on main, and after anopenthe same line is 2 in bean-check, as here. Two rows that no matrix rule explains are #2968:Assets:A $@ <BOM>xAssets:A.00(2 / 2 / 3) andclose Assets:A TRUE <BOM>x (k: #t Assets:A<BOM>~(3 / 3 / 2). Main matches bean-check's count on both.Sweep. Mutations ran one after another, each file checked byte-identical after. The kill test for
convert.rswas the whole parser suite withSTRICT_BASELINE=1, and for the helpers the matrix test. The scope wasquiet_after_invalid_tokensfrom itsinvalid.is_empty()check through the line loop, all ofheader_grammar_reaches, and the matrix helpers fromfnvthroughregressed_rows, except theBOM_MATRIX_UPDATE=1block. The generator was the review's, plus 25 hand-written mutants.convert.rsbom_combination_matrix.rsThe 3 timeouts are loops that stop advancing:
breaktocontinue, andi += 1removed or made+= 0.The 11
convert.rssurvivors are all commented:invalid.is_empty()shortcut forced false;inside_unread'ss < at,at < eandis_some_and;first < line_end;partition_pointpast the line's content (<);e.span.start > to;e.span.end > at(generated and hand-written, compat(parser): a posting's sign check that ends at an invalid token is one error more than beancount #2967);endset to 0 and tousize::MAX.Each comparison among them was also run on the 781,065 inputs: no output changes.
The 43 matrix survivors are the round-21 families, already commented. Two new comments cover
if b == rwith its operands swapped and therowscounter of the table guard.A first
convert.rspass, before thestart == atsimplification, had 126 mutants and 12 survivors.The matrix pass's 43 survivors were run again on the final file, with nothing else building, and all survive. (During part of that pass, another test build had shared the target directory, and that could only have produced false survivors.)
Gates (on d7dfa6c):
cargo fmt --all --check;cargo clippy --workspace --all-features --all-targets -- -D warnings;RUSTDOCFLAGS=-Dwarnings cargo doc --workspace --all-features --no-deps; tests for parser (1,024 passed, with both STRICT baselines on the copied compat corpus, thefuzz_green_eq_redcorpus testparse_green_eq_red_corpusamong them), loader (451), lsp (434) and wasm (181), 0 failed; parity--self-test; the pre-pushcargo check --workspace --all-features --all-targets. The finalparse_error_lines(built clean) gives the same output as before this round on all 781,065 inputs above, so the parity manifest is unchanged.How to test
Local gates that passed:
cargo fmt --check--all-features --all-targets -D warningsRUSTDOCFLAGS=-Dwarnings cargo doc --workspace --no-depswasm-pack test --node--checkNew tests:
logos_lexer:test_tokenize_mid_line_bom_runs_to_next_blanktest_tokenize_bom_after_lone_capital_runs_to_next_blanktest_tokenize_line_start_bom_keeps_own_extenttests/bom_mid_line_run.rs:test_parse_mid_line_bom_run_is_one_errortest_parse_mid_line_bom_before_quote_opens_no_stringtest_parse_line_start_bom_is_one_errortest_parse_bom_in_string_stays_contenttest_parse_bom_led_token_on_error_line_is_reportedtest_parse_bom_led_token_after_invalid_account_counts_oncetest_parse_open_with_mid_line_bom_run_reports_only_the_tokentest_is_stray_bom_at_finds_bom_inside_longer_error_tokentest_bom_removal_actions_find_bom_inside_longer_error_tokentest_header_grammar_reaches_a_header_token_the_rule_reads_up_to,test_header_grammar_reaches_is_false_off_the_header_rule,test_header_grammar_reaches_is_false_before_the_first_header_token(cst::convert::tests),test_parse_bom_run_after_the_leading_bom_counts_the_rest,test_parse_header_after_two_leading_boms_names_its_invalid_token, tab indents intest_parse_bom_glued_before_price_cost_or_tolerance_is_one_errorandtest_parse_invalid_token_is_one_error,test_regressed_rows_goes_on_past_a_new_row,test_data_files_hold_no_carriage_return, and new cases intest_data_lines_skips_only_headers_and_blanksandtest_cause_eol_reported_on_next_line_needs_one_error_moved(matrix test file)test_cause_recovery_first_needs_a_matching_count_alone,test_cause_line_start_bom_before_comment_takes_each_skipped_start,test_cause_brace_hash_before_tag_takes_each_tag_character,test_cause_one_diagnostic_per_line_needs_exactly_the_later_errors,test_cause_glued_in_error_line_needs_exactly_the_difference,test_cause_inner_bom_under_line_error_rewrites_to_no_token,test_cause_lone_capital_glued_to_tokens_takes_each_listed_character,test_hash_bang_analog_rewrites_only_past_a_lines_start,test_is_blank_takes_a_space_or_a_tab,test_rledger_lines_puts_an_unclosed_push_on_line_zero,test_cause_glued_hash_bang_needs_a_hash_bang_on_the_line,test_cause_mid_line_hash_bang_sees_one_after_a_line_start_one,test_cause_early_like_main_without_bom_needs_both_analog_counts,test_cause_extra_construct_error_needs_mains_count,test_holds_checks_each_kind_of_cause, and new cases in seven older tests (matrix test file)test_cause_glued_construct_needs_a_positive_construct_share,test_cause_glued_in_error_line_needs_a_non_bom_error_in_place,test_cause_line_start_bom_before_comment_needs_a_skipped_start,test_cause_line_start_bom_before_comment_needs_no_account_at_its_start,test_cause_eof_error_on_last_line_needs_each_condition,test_cause_eol_reported_on_next_line_needs_a_date_alone,test_cause_lone_capital_glued_to_tokens_skips_a_leading_bom,test_cause_invalid_account_after_invalid_token_needs_an_account, and new cases in five round-17 and round-18 tests (matrix test file)test_cause_line_start_bom_before_comment_needs_a_bom,test_cause_indented_line_after_error_sees_an_indented_bom, andtest_cause_inner_bom_under_line_error_needs_fewer_errors_and_a_bom_diagnosticrebuilt on its table row (matrix test file)test_cause_bom_free_line_as_on_main_needs_main_count,test_cause_listed_exception_needs_its_reason_counts,test_cause_bom_glued_to_account_needs_an_account_on_the_line,test_cause_glued_in_error_line_needs_an_account_on_the_line,test_cause_glued_in_error_line_needs_more_errors_than_beancount,test_cause_inner_bom_under_line_error_needs_fewer_errors_and_a_bom_diagnostic,test_cause_brace_hash_before_tag_needs_more_errors,test_cause_line_start_bom_before_comment_needs_fewer_errors,test_cause_pop_without_push_needs_fewer_errors(matrix test file)test_cause_like_main_without_bom_needs_both_analog_counts(round 15'stest_cause_like_main_without_bom_needs_beancounts_analog_count, renamed and given a main-analog case)test_reason_counts_reads_the_leading_counts,test_reason_counts_rejects_counts_not_at_the_start(matrix test file)test_parse_bom_before_price_or_cost_drops_it_issue_2954(pins Recovery drops a posting's price or cost after an invalid token, then reports a spurious imbalance #2954's gap),test_parse_bom_alone_at_eof_after_directive_is_one_error,test_tokenize_indented_bom_runs_to_next_blank, the account check online-start-bom-before-comment, the latelike-main-without-bomrule and the reason-count check on exceptions in the matrix testtest_parse_bom_line_reports_beancounts_invalid_token_text,test_parse_heading_rest_hash_after_brace_is_not_a_comment,test_token_iter_new_mid_line_applies_no_line_start_rule, the texts list, composite causes and the relabel guard in the matrix testtest_parse_invalid_account_on_bom_free_line_keeps_its_p0006, the renamedtest_parse_partly_invalid_account_word_keeps_mains_message, new rows intest_parse_bom_led_line_tails_count_as_beancount, the timedtest_tokenize_long_bom_runs_are_linear, and the kind checks in the matrix testtest_parse_bom_led_line_tails_count_as_beancount,test_parse_bom_glued_unicode_account_after_error_line_is_not_counted_twice,test_parse_partly_invalid_account_word_is_reported_as_written(renamed in round 10), the new shapes intest_tokenize_long_bom_runs_are_linear, and cause equality in the matrix testtest_parse_bom_account_in_metadata_keeps_booking_method_check, the accepted further-than-main list in the matrix testtest_parse_bom_led_account_shapes_count_as_beancount, and the classifier intest_parse_bom_combination_matrix_matches_beancounttest_parse_bom_glued_to_account_keeps_the_account,test_tokenize_long_bom_runs_are_lineartest_parse_lone_capital_glued_to_bom_is_counted,test_parse_line_start_bom_heading_counts_the_rest, and the extended matrix with the random probetest_parse_bom_led_first_token_spends_the_bom_diagnostic,test_parse_line_start_bom_run_through_valid_tokens_is_one_token,test_parse_line_start_bom_heading_rest_is_not_glued, and the extended matrixtest_parse_bom_combination_matrix_matches_beancount(the guard),test_parse_line_start_glued_bom_then_inner_bom_token_counts_both,test_parse_bom_before_metadata_indentation_counts_the_keytest_parse_bom_led_argument_error_is_at_the_token,test_format_source_keeps_directive_with_bom_led_argument,test_parse_secondary_bom_error_with_several_bom_tokens,test_parse_line_start_bom_glued_to_invalid_run_is_one_error, and in LSPtest_parse_errors_to_diagnostics_bom_led_argument_ranges_over_the_tokentest_parse_bom_led_argument_of_directive_is_one_error,test_parse_secondary_bom_error_stands_for_first_bom_token_of_either_kind,test_parse_bom_led_run_stops_at_blank_inside_quotes, and in loadertest_load_included_file_with_mid_line_bom_reports_one_errorOut of scope: part 2, emitting beancount's tokens for a mid-line
#!/#+.Refs #2928
🤖 Generated with Claude Code