Skip to content

fix: make check, WASM, FFI and LSP agree on close-with-balance and after a booking error - #2947

Merged
robcohen merged 6 commits into
mainfrom
fix/surface-agreement
Nov 11, 2026
Merged

robcohen merged 6 commits into
mainfrom
fix/surface-agreement

Conversation

@robcohen

@robcohen robcohen commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

What changed

Two cases where rledger check, WASM, the FFI component and the LSP disagreed (#2937), each settled by what bean-check 3.2.3 reports.

1. Closing an account that still holds a balance (E1004). bean-check 3.2.3 does not flag it: on a plain ledger, under beancount.plugins.auto_accounts, and under beancount.plugins.currency_accounts, it exits 0 and prints nothing. check already stays silent to match, by design (ErrorCode::is_advisory_only), and rledger lint closed-nonempty reports the advisory. So the other surfaces were the wrong ones:

  • WASM validateSource / ParsedLedger ran their own ValidationSession and never filtered E1004. validateMultiFile, validateWithHost and Ledger.fromFiles went through the loader's validating process, which does emit E1004 (the lint reads it from there), and passed every error through.
  • FFI validate / load (semantic_validation_errors) ran a session without filtering.
  • The LSP (run_ledger_validation) ran a session without filtering.

Each now leaves it out through the canonical predicate (ErrorCode::is_advisory_only / is_advisory_only_code), as check and rledger query already did. WASM gains one helper, reported_ledger_errors, which validateMultiFile, Ledger.fromFiles and query share.

2. Validation after a booking error. For a STRICT ledger with an ambiguous reduction, bean-check reports the booking error and the Balance failed that follows it (accumulated -2100 USD, the refused sale left out). check reports the same two findings: the validating loader runs Early and Late no matter which errors came before, and sets the transaction booking refused aside (Late does not see it, and note_refused_by_booking reports the account errors Early held for it).

  • WASM run_validation returned nothing on any severity-error in load.errors, so it reported only the booking error.
  • The FFI did validate, but over the refused transaction too, so it reported got -1600 USD, where check and bean-check give -2100.

To use the CLI's rule rather than re-derive it, the loader now records what it set aside: Ledger::booking_refused, the refused transactions' indices in Ledger::directives, computed in finalize where the refused ones are merged back into the sorted stream. The tagged sort only runs when something was refused. WASM run_validation and the FFI's semantic_validation_errors now set those transactions aside exactly as process does: Early over everything, note the refused ones, Late over the rest. The has_fatal gate is gone. A source that failed to parse has no directives on that path, so it still validates nothing. The FFI change is one field on ffi-wasi's LoadResult (booking_refused) plus the session split, kept small because of the parallel LoadResult work in #2929 / #2935.

Depends on #2942. The new WASM cache round trip (ParsedLedger / Ledger fromCache on these cases) hits the unaligned pointer decode bug that #2942 (#2934) fixes. That branch (fix/wasm-cache-alignment) is merged into this one, so #2942 should land first. This PR does not carry its own copy of that fix.

Cache: WASM CACHE_VERSION 94 -> 97. Both payloads' archived error lists change. 95, 96 and 98 are claimed by open PRs. The loader cache is unchanged, because Ledger is not archived.

Not changed (noted for follow-up)

check and bean-check also validate after a parse error, over the entries that did parse. WASM (load_and_book returns no directives on a parse error), the FFI and the LSP skip validation there. That is a separate divergence, outside this issue's booking case.

Tests

One shared case file, crates/rustledger-loader/tests/surface_agreement/cases.rs, has four ledgers: close-with-balance plain, under auto_accounts, under currency_accounts, and the STRICT ambiguous reduction followed by a balance. Each case lists the exact findings (code, 1-based line, message prefix) that bean-check's answer implies. Every surface's drift guard include!s it and asserts exactly those findings:

  • loader: tests/surface_agreement_test.rs. The validating load gives them, E1004 is raised (and filtered), and booking_refused names exactly the refused sell transaction.
  • CLI: crates/rustledger/tests/surface_agreement_test.rs. rledger check --format json reports codes, lines and messages and the exit code, and rledger lint closed-nonempty reports the E1004 on exactly the close cases, so they cannot pass vacuously.
  • WASM: tests/wasm_surface_agreement.rs (wasm-bindgen, node). It covers validateSource, validateMultiFile, ParsedLedger (fresh and fromCache), and Ledger.fromFiles (fresh and fromCache).
  • FFI component: convert::surface_agreement. It covers validate, plus load with and without expand_pads. The wire error has no code, so findings are matched on line and message.
  • LSP: handlers::diagnostics::surface_agreement, via all_diagnostics.

bean-check places the booking error on the transaction's line (14). Every rledger surface places it on the posting's line (15, #2330). The cases pin rledger's line and say so.

Review round 1

  • Stale comments: the comments that still said run_validation gates on load.errors or skips on has_fatal are rewritten. They were in the WASM helpers.rs (option_errors docs and two tests), api.rs (validateSource) and parsed_ledger.rs (ParsedLedger::new and a test).
  • run_validation span-mismatch branch removed: that branch dropped refused transactions without calling note_refused_by_booking. It was unreachable, because load_and_book unzips one span per directive from the loader's stream. A debug_assert_eq! now pins that, and the spanned path is the only path.
  • CHANGELOG: Ledger::booking_refused is listed under Breaking, as PluginError::failed is, because Ledger is not #[non_exhaustive].
  • Cache notes: v93 and v96 were never released, and fix(parser): run a mid-line BOM's invalid token to the next blank, as beancount does #2931 holds v95. CACHE_VERSION stays 97.

How to test

cargo test -p rustledger-loader --test surface_agreement_test
cargo test -p rustledger --test surface_agreement_test
cargo test -p rustledger-ffi-component --lib surface_agreement
cargo test -p rustledger-lsp --lib surface_agreement
(cd crates/rustledger-wasm && wasm-pack test --node)

Locally green: cargo fmt --check, workspace clippy --all-features --all-targets -D warnings, RUSTDOCFLAGS=-Dwarnings cargo doc --workspace --no-deps, cargo test for loader / wasm / ffi-wasi / ffi-component / lsp, the CLI's cli_commands_test, and wasm-pack test --node.

Closes #2937

🤖 Generated with Claude Code

robcohen and others added 2 commits November 11, 2026 00:57
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]>
…ter 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]>
@robcohen
robcohen requested a review from a team as a code owner November 11, 2026 07:57
robcohen and others added 2 commits November 11, 2026 02:01
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]>
#2947's WASM cache round trip needs #2942's aligned decode.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@codecov

codecov Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Patch % Lines
crates/rustledger-lsp/src/handlers/diagnostics.rs 96.77% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

Shape rustledger beancount Speedup RSS (rledger / beancount)
simple 40.4ms ± 2.2ms 569.3ms ± 5.4ms 14.1x 45.0 MB / 50.9 MB
investment 60.0ms ± 0.7ms 2096.4ms ± 8.2ms 34.9x 46.9 MB / 59.0 MB
fifo 58.1ms ± 0.4ms 11815.1ms ± 69.0ms 203.5x 48.9 MB / 58.8 MB

vs base, measured in this run

Shape base this PR Change RSS base → PR
simple 40.2ms ± 0.3ms 40.4ms ± 2.2ms +0.6% ✅ within noise 45.0 MB → 45.0 MB (+0.0%)
investment 60.3ms ± 0.4ms 60.0ms ± 0.7ms -0.5% ✅ within noise 47.1 MB → 46.9 MB (-0.3%)
fifo 58.5ms ± 0.4ms 58.1ms ± 0.4ms -0.7% ✅ within noise 48.8 MB → 48.9 MB (+0.3%)

A difference counts only when it clears the combined spread of the two measurements, per shape (2σ: simple 1.0ms, investment 0.3ms, fifo 0.3ms), and is at least 5%.
10,000 transactions per shape · 20 runs, 3 warmup · hyperfine

What do these numbers mean?
  • simple — Two-posting transfers, one currency. The historical workload — keep as the floor, not as the benchmark.
  • investment — Cost specs, per-unit prices and lot reductions. Exercises booking and inventory, which simple leaves at 0.3%.
  • fifo — Bare {} reductions against a FIFO account — how FIFO sells are normally written. The other four shapes reach the ordered-selection path twice in 2k transactions between them, so it was effectively unprofiled until it turned out to be quadratic (plan_ordered scans every lot per reduction: FIFO ledgers are quadratic (8.8s at 20k transactions) #2083).
  • vs base: the PR and the base-branch commit it is built on, built and measured in the same job
  • RSS: peak resident set size, a single sample — reported without a verdict because there is no spread to test it against
  • A shape with no beancount column is one bean-check reports errors on; it is timed for rledger only

@github-actions

Copy link
Copy Markdown
Contributor

✅ Compatibility Test Results

Metric Result
Check Compatibility 100%
BQL Compatibility 100% (raw 93%, 179 masked)
Full AST Match 100%
Total Files 826
What's tested
  • Check: Exit codes and error counts match bean-check
  • BQL: Query results match bean-query
    The headline is the EFFECTIVE rate, after pairs where beanquery
    itself is wrong are masked. raw is the same run with nothing
    masked. A widening gap means the registry grew, not that rledger
    changed.
  • Files: ~800 test files downloaded from 10+ beancount repositories

Full results available in workflow artifacts

- 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]>
Brings in #2942 (aligned cache decode), which #2947 depends on.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@robcohen
robcohen merged commit 4bc5bd8 into main Nov 11, 2026
67 of 68 checks passed
@robcohen
robcohen deleted the fix/surface-agreement branch November 11, 2026 22:41
robcohen added a commit that referenced this pull request Nov 11, 2026
#2947 merged as 4bc5bd8. Its hunks take main's side; this PR's own
changes (6c601dd..00c8866) are applied on top. In the test tail of
the LSP main loop, #2941's coalescing tests and this PR's tests are both
kept, and change_doc flushes the debounced diagnostics pass before the
publishes are read.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
robcohen added a commit that referenced this pull request Nov 12, 2026
Brings in #2947. Conflicts resolved keeping both sides:
- CHANGELOG Fixed section: both entries kept.
- rustledger-wasm cache.rs: main's v97 note kept, this branch's v99
  note follows it (v98 is held by #2944). CACHE_VERSION stays 99.
- rustledger-wasm api.rs and parsed_ledger.rs: main's
  reported_ledger_errors (drops advisory-only E1004) plus this branch's
  located option diagnostics.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
robcohen added a commit that referenced this pull request Nov 12, 2026
#2945, which this branch carried, is squash-merged as 526f833; its
hunks take main's final form (loader cache v71, `escape_untrusted_text`
in `rledger query`, its CHANGELOG notes).

With #2947: the FFI's `semantic_validation_errors` keeps #2947's
`booking_refused` set-aside and its `is_advisory_only` filter, which
replaces this branch's equivalent one. `convert::surface_agreement` now
matches each finding's code too (the 4.0.0 wire error carries it) and
runs `validate-file` and `load-file` over the shared cases, so the file
surfaces are pinned to leave out E1004 and set a refused transaction
aside.

No cache moves: the loader cache stores only error-free raw loads, and
this branch changes no WASM output.

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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: rledger check, WASM, FFI and LSP disagree on close-with-balance and on validation after a booking error

1 participant