Repository navigation
fix(loader)!: validate options in included files as beancount does, and locate every option diagnostic - #2945
Merged
Merged
Conversation
…nd locate every option diagnostic beancount parses each included file with its own Builder and fresh options: every value an option's converter rejects is an error at the included file's line (bean-check exits 1), and only the top-level file's values are kept. rledger reported every included option as the E7009 warning, valid or not, and exited 0. set_scoped_inner now reads an included non-accumulating option into a scratch Options, keeps its diagnostics and drops the value. E7009 is left for a value the converter accepts. An included name_* root still does not root that file's own accounts (E1005), a deliberate deviation now commented and pinned. Every option diagnostic (E7001 to E7011) carries the option's file and line: OptionWarning gains `site`, stamped by set_scoped_at, and E7006 / E7010 are located from the applied values. rledger check (text, JSON, and ag-rledger check through it), the LSP (diagnostic on the option line, in the file it is in), WASM option_errors and multi-file Ledger errors read it. WASM validateMultiFile now reports option diagnostics at all. Drift guards pin check's JSON and text, the LSP's two paths and WASM's two multi-file paths to the loader's sites. WASM cache v99; the loader cache never stores a ledger with option diagnostics, so it stays at v69. Refs #2925 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
📊 Benchmark Results
vs base, measured in this run
A difference counts only when it clears the combined spread of the two measurements, per shape (2σ: What do these numbers mean?
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Contributor
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
…er's options off unrelated LSP buffers Review round 1 of #2945. - rustledger_loader::option_warnings_to_errors maps OptionWarning::site to LedgerError::location (column 1). rledger check, the LSP and WASM (via From<LedgerError>) read it; the WASM helper is a one-argument wrapper and single-source entry points drop the file with without_files. - LSP: a buffer the ledger does not include gets its own options' diagnostics, never the ledger's drawn on its lines. - LSP option range stops before a `; comment`; the live-buffer limitation is documented. - Options::locate is by occurrence, so a repeated documents value is located at each of its lines. - validate_with_filesystem reports option diagnostics beside a fatal load error or a processing failure. Refs #2925 Co-Authored-By: Claude Opus 5.5 <[email protected]>
robcohen
added a commit
that referenced
this pull request
Nov 11, 2026
Review round 1 of #2946. - The WIT `error` record gains `code` and `filename`, filled for every error with a location (an included file's own path, the name given to `load` for source text, a plugin's placeholder name), so a line can say which file it is in. A record change: package rustledger:[email protected], `API_VERSION` 4.0, docs cite @4.x. - Query surfaces (`query`, `query-file`, `batch`, `batch-file`, `session.query`) list a rejected booking_method as the refusal again, in place of its plain E7002, through one loader canonical, `Ledger::query_option_errors`; `load` and `info()` keep the plain E7002. - Option diagnostics come from #2945's located `option_warnings_to_errors` (this branch is rebased onto it), so they carry the option's file and line on every surface, and the drift guard pins those lines. - Validation findings leave out the advisory-only E1004 on every surface, as `rledger check` does, and are kept beside an unrun plugin's error (E8001, E8004, E8005), as `check` keeps them. - The host-plugin tests assert `check_commodity`'s exact finding, so the mutations that put option errors in the plugin gate fail them. - The file-id span rule cites its WASM twin, and the WASM rule cites it. No cache payload changes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nd locate query's option diagnostics Review round 2 of #2945. - documents leaves ACCUMULATE_ACROSS_INCLUDES: beancount 3.2.3 keeps only the top-level file's (load_file gives documents == [] for an included root and bean-check exits 0 with it missing), so an included value is read by the scratch converter and ignored with E7009, never scanned or checked (no E7006). - rledger query prints option diagnostics through the canonical mapping, with file and line; ag-rledger's query warnings carry them. - WASM Ledger::from_file_map's processing-error arm keeps the option diagnostics, as validate_with_filesystem does. - LSP option_error_file_id uses SourceFile::id. - Tests pin site_of's last-line choice (E7010), without_locations clearing every site, and included documents. Refs #2925 Co-Authored-By: Claude Opus 5.5 <[email protected]>
… 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]>
Brings in #2939 and #2942. CHANGELOG conflict in Fixed resolved by keeping both entries. Cache versions unchanged: loader 71, WASM 99. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 took loader v71 and WASM v99, so this branch keeps loader v73 and moves WASM to v102 (v100 and v101 are held by #2931 and #2952). 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
Main took loader cache v71 and WASM cache v99 (#2945, for #2925). This PR's loader cache moves to v72 (v70 was never released), its WASM cache stays v100, and the WASM loader pin and both loader fixture versions follow to 72. The CHANGELOG and LSP test conflicts keep both sides. Co-Authored-By: Claude Opus 5.5 <[email protected]>
robcohen
added a commit
that referenced
this pull request
Nov 12, 2026
Resolve the WASM conflicts so both behaviors hold: #2945's located option diagnostics (`option_warnings_to_errors`, through the loader's canonical mapping) on validateMultiFile, validateWithHost and Ledger.fromFiles, and this branch's validation of whatever loaded after a parse or load error. - validate_with_filesystem: drop the early stop on a "fatal" load error. `rledger check` reports and validates past a missing, unreadable or directory include, a duplicate include, an include cycle and an empty glob, and stops only when the entry file cannot be loaded (the `Err` arm here). Option diagnostics follow the ledger's errors, in the same order as Ledger.fromFiles. - load_and_book: the parse-error early return stays deleted; a source with a parse error gets its located option diagnostics from the loader. - Ledger::from_file_map: parse errors, then ledger errors, then options. - WASM cache: main's v99 note, then this branch's v101 (loader v71). - LSP: adapt #2945's option_diagnostics_are_located_like_check to the view form of ledger_diagnostics_multi. - CHANGELOG: keep both entries; reword for the merged behavior. Co-Authored-By: Claude Opus 5.5 <[email protected]>
robcohen
added a commit
that referenced
this pull request
Nov 12, 2026
…heck does (#2946) * fix(loader)!: validate options in included files as beancount does, and locate every option diagnostic beancount parses each included file with its own Builder and fresh options: every value an option's converter rejects is an error at the included file's line (bean-check exits 1), and only the top-level file's values are kept. rledger reported every included option as the E7009 warning, valid or not, and exited 0. set_scoped_inner now reads an included non-accumulating option into a scratch Options, keeps its diagnostics and drops the value. E7009 is left for a value the converter accepts. An included name_* root still does not root that file's own accounts (E1005), a deliberate deviation now commented and pinned. Every option diagnostic (E7001 to E7011) carries the option's file and line: OptionWarning gains `site`, stamped by set_scoped_at, and E7006 / E7010 are located from the applied values. rledger check (text, JSON, and ag-rledger check through it), the LSP (diagnostic on the option line, in the file it is in), WASM option_errors and multi-file Ledger errors read it. WASM validateMultiFile now reports option diagnostics at all. Drift guards pin check's JSON and text, the LSP's two paths and WASM's two multi-file paths to the loader's sites. WASM cache v99; the loader cache never stores a ledger with option diagnostics, so it stays at v69. Refs #2925 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(loader): one canonical option-diagnostic mapping, and keep a ledger's options off unrelated LSP buffers Review round 1 of #2945. - rustledger_loader::option_warnings_to_errors maps OptionWarning::site to LedgerError::location (column 1). rledger check, the LSP and WASM (via From<LedgerError>) read it; the WASM helper is a one-argument wrapper and single-source entry points drop the file with without_files. - LSP: a buffer the ledger does not include gets its own options' diagnostics, never the ledger's drawn on its lines. - LSP option range stops before a `; comment`; the live-buffer limitation is documented. - Options::locate is by occurrence, so a repeated documents value is located at each of its lines. - validate_with_filesystem reports option diagnostics beside a fatal load error or a processing failure. Refs #2925 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(ffi): report option errors, and validate file loads as rledger check does The FFI component never reported a ledger's option diagnostics (E7001 to E7011): ffi-wasi built `errors` from `ledger.errors` only. They now travel in a separate, non-gating `option_errors` list on `LoadResult` and `FileLoad`, mapped by `rustledger_loader::option_warnings_to_errors`, the canonical function the WASM surface now calls too, and are appended to the outgoing `errors` last, after the host's plugins and validation have run, so an invalid option neither skips validation, nor stops session plugins, nor counts in `parse-error-count`. `valid` and the host-plugin gate go by severity, which fixes two older bugs: a ledger plugin's warning skipped the host's plugins, and `valid` was false over a warning alone. Query results list the option diagnostics, as the WASM query does, and so no longer list the booking-method refusal beside its E7002 (#2929). `load-file` reported no validation errors and `validate-file` validated the entry file's text as one source. Both now validate through the canonical pipeline (`load_file_with_fs(..., validate: true)`), and the validator's findings, told apart by the new `LedgerError::is_validation_finding`, are kept out of the host-plugin gate, so a failed balance does not stop the host's plugins. Each finding keeps its own file and line. A source-text finding maps to a line only when its span is in the text (file id 0), as on WASM; a plugin directive's finding was mapped to an unrelated line (#2935). A drift guard pins `rledger check` and the component's `load`, `load-file`, `validate` and `validate-file` to one list of diagnostics (codes, messages, files and lines) on a multi-file and a single-file ledger with a balance failure, a padded cost lot and invalid options, run natively and through the built wasip2 component. WIT contract rustledger:[email protected] (behavior only, no shape change). No cache payload changes. Closes #2929 Closes #2935 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(ffi)!: WIT 4.0.0 error code and filename, and keep the query refusal Review round 1 of #2946. - The WIT `error` record gains `code` and `filename`, filled for every error with a location (an included file's own path, the name given to `load` for source text, a plugin's placeholder name), so a line can say which file it is in. A record change: package rustledger:[email protected], `API_VERSION` 4.0, docs cite @4.x. - Query surfaces (`query`, `query-file`, `batch`, `batch-file`, `session.query`) list a rejected booking_method as the refusal again, in place of its plain E7002, through one loader canonical, `Ledger::query_option_errors`; `load` and `info()` keep the plain E7002. - Option diagnostics come from #2945's located `option_warnings_to_errors` (this branch is rebased onto it), so they carry the option's file and line on every surface, and the drift guard pins those lines. - Validation findings leave out the advisory-only E1004 on every surface, as `rledger check` does, and are kept beside an unrun plugin's error (E8001, E8004, E8005), as `check` keeps them. - The host-plugin tests assert `check_commodity`'s exact finding, so the mutations that put option errors in the plugin gate fail them. - The file-id span rule cites its WASM twin, and the WASM rule cites it. No cache payload changes. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(loader): ignore an included documents option as beancount does, and locate query's option diagnostics Review round 2 of #2945. - documents leaves ACCUMULATE_ACROSS_INCLUDES: beancount 3.2.3 keeps only the top-level file's (load_file gives documents == [] for an included root and bean-check exits 0 with it missing), so an included value is read by the scratch converter and ignored with E7009, never scanned or checked (no E7006). - rledger query prints option diagnostics through the canonical mapping, with file and line; ag-rledger's query warnings carry them. - WASM Ledger::from_file_map's processing-error arm keeps the option diagnostics, as validate_with_filesystem does. - LSP option_error_file_id uses SourceFile::id. - Tests pin site_of's last-line choice (E7010), without_locations clearing every site, and included documents. Refs #2925 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(ffi): locate each parse error and host plugin error, as rledger check does Review round 2 of #2946. - A plugin the host asks for (`load-file`, `session.from-file`) reported its errors as a bare message: no code, file, line or severity, and its text unescaped. The loader's per-error mapping is now the public `rustledger_loader::plugin_error_to_ledger_error`, which `record_plugin_errors` and ffi-wasi's `apply_plugins` (which gains the load's `source_map`) both use. A drift test compares a host-requested and a ledger-declared `leafonly`. - Parse errors were one line-less `parse errors in <path>`, an included file's too. `LoadResult::take_parse_errors` (the same method as #2952) takes them out before `process`, and the new `rustledger_loader::parse_errors_to_ledger_errors` reports each with its code, file, line and column, as `check` does. `load(src, name)` names the given file on them. New shared case `parse-error-in-include`. - `batch` and a session from source name their errors `<stdin>`, as their entries, not the loader's `<string>`. - `query_option_errors` shares `query_refusal_error`'s conversion. - Pin the refusal's site match (an include repeating the main file's bad `booking_method` keeps its plain E7002) and the refusal's phase on every query surface; both mutation-checked. - world.wit: both behaviors for a plugin-made directive's finding, line 0 as the exception to 1-based, and the `version()` example is "4.0". Stale comments fixed in ffi-wasi `Error` and the parity cases. - ffi-component-tests compile the component once per test binary (`compiled_component`). Every `parity` / `corpus_parity` test compiled the 93 MB debug component on its own `Engine`, the check-parity test once per case, many at once on parallel threads: the `parity` binary held 10-12 GB for 20+ minutes. The crate's tests now take 26 s at 0.9 GB peak. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(ffi-component-tests): use parking_lot for the shared compiled component CI's Sync Primitives check forbids std::sync locks in non-test library code (#1076), and `compiled_component` lives in the crate's lib. Switch it to parking_lot::Mutex (no poisoning, so the PoisonError recovery goes), end the guard explicitly after the first compile, and split the doc's first paragraph for clippy. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(wasm): list query option errors through the canonical, and pin columns (#2946 review round 3) - WASM query surfaces (free `query`, `ParsedLedger.query`, `queryMultiFile`, `Ledger.query`) list option diagnostics through `Ledger::query_option_errors`, as the FFI does: the rejected `booking_method`'s E7002 is the refusal. Shared drift guard `rustledger-loader/tests/query_option_errors/cases.rs` across the loader, the FFI and WASM. WASM cache v105 (both payloads archive what a query lists). A source that fails to parse still differs (#2960), documented at both sites. - The check parity rows compare `column`; `load` and `validate` now give a validation finding its column, as `check` does. A mid-line parse error after a two-byte character pins character columns. - Paired comments between `parse_errors_to_ledger_errors` and `check`'s inline parse-error arm. - Pin `batch` errors named `<stdin>` and the host-plugin `source_map` argument (file names with a tab). - `session.from-entries` option errors carry code E7002. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(ffi,wasm): locate every finding through one canonical, and count WASM columns in characters (#2946 review round 4) - loader: `SourceMap::locate(file_id, offset)` replaces the private `error_location`; the loader, the FFI component's validation findings and the WASM surface all locate through it. - ffi-component: `semantic_validation_errors` calls `SourceMap::locate` instead of re-deriving it. - check parity: BOM-prefixed cases (LF and CRLF) put a line-1 finding at column 2, so a hardcoded column 1 no longer passes. - wasm: `validateSource`, `ParsedLedger.getErrors`, `parse` and `format` counted columns in bytes (4 after a BOM); parse errors now go through the loader's `LineIndex` and validation findings through `SourceMap::locate`. `LineLookup` keeps lines only. Native and wasm-bindgen tests pin a BOM and a multi-byte character before an error. - WIT: the `error` record's doc says `column` is 1-based in characters and 0 at a plugin placeholder (doc only). Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(ffi,wasm): pin a parse error's refusal, WASM's file-id rule and end positions, and map WASM parse errors once (#2946 review round 5) - query_option_errors/cases.rs: new refused-by-parse-error-alone case (a parse error and no option diagnostic must refuse), run by the canonical, the FFI query surfaces and every WASM query surface, queryMultiFile included; the component's query_short_circuits_on_parse_error gains the same ledger. Moves a comment glued to `},` onto its own line. - wasm: test_a_plugin_directives_finding_maps_to_no_source_line, the counterpart of the FFI test; end_line/end_column pinned natively and in wasm_error_columns on every surface. - wasm: parse_error_fields maps a parse error's message, code, phase and hint once for parse_error_to_wasm and load_errors_to_errors, with paired comments against the loader's parse_errors_to_ledger_errors and a drift guard (parse_error_mapping_parity). - The multi-file path prefix on parse error messages points at #2961. Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(wasm,loader): say why WASM keeps its own parse-error mapping (#2946 review round 6) The paired comments at parse_error_fields and parse_errors_to_ledger_errors said a LedgerError has no end position. It does: source_span and file_id carry it; only ErrorLocation is a point. The copy exists because WASM's single-source surfaces build no LoadError or SourceMap. The multi-file surfaces report null ends for validation findings only because From<LedgerError> for Error does not locate them, and that conversion also drops the hint: both pre-existing, now issue #2964, cited from the comments, the From impl and wasm_error_columns.rs. The revisit condition is now "if the single-source surfaces come to build a LoadError". The load_errors_to_errors comment also names parse_error_mapping_parity as a test that strips the #2961 path prefix. Formats the include!d ffi_check_parity/cases.rs with rustfmt (a chain from the #2952 merge exceeded the chain width). 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 2 of #2925 (part 1 was #2930).
Builderand fresh options. It reports every value an option's converter rejects as an error at the included file's line (exit 1). Then it keeps only the top-level file's values. rledger reported every included option as theE7009warning, valid or not, and exited 0.Options::set_scoped_innernow reads an included non-accumulating option into a scratchOptionsthat starts from the defaults. It keeps that option's diagnostics (E7008,E7002, andE7004for a deprecated option) and discards the value.E7009is left for a value the converter accepts, which is still ignored with that warning.E7011warning and theE7009(both warnings, as bean-check is clean).booking_methodstays in the scratch, so it refuses no query: the top-level method governs.name_*root does not root that file's own accounts.option "name_equity" "Capital"followed byopen Capital:Zin the same included file is stillE1005(bean-check is clean; beancount loads the account with no account type). AStricter than Pythoncomment sits inset_scoped_innerand inerrors.md. The test isincluded_name_option_does_not_root_its_own_file.OptionWarninggainssite: Option<OptionSite>.set_scoped_atstamps every warning the option raises with its site.E7006andE7010are raised after all options are set. They get their option's site from the applied values (Options::locate,Options::site_of).Options::setandOptions::set_scopedstill give no site.rledger checkprintsfile:line: error[E7002]: ....ag-rledger checkgets both through the CLI.all_diagnosticsandledger_diagnostics_multi) publish each option diagnostic in the file its option is in, with the range on theoptionline, trimmed. An included file's go on that file. A warning with no site stays at the top of the main file.option_errorsand the single-sourceparsecarry the line and column 1 (no file, as their other errors), and a multi-fileLedger's errors carry the file too;end_lineandend_columnare null, as on everyLedgerError-derived error.validateMultiFileandvalidateWithHostleft option diagnostics out entirely, so a tree with an invalid option validated clean; they now report them (beside a fatal load error too), and such a tree isvalid: false.rustledger_loader::option_warnings_to_errorsfrom this PR, which carries the location.rledger merge/splitcompare options withOptions::without_locations(), since moving anoptionline to another file must not count as a different ledger.Why
Each row below was a difference from bean-check 3.2.3, and none of rledger's option diagnostics had a location, where all of beancount's do.
Before / after
Each row is a
main.beancountholdinginclude "sub.beancount"and2024-01-01 open Assets:A, withsub.beancountholding one line,option "<key>" "<value>". bean-check 3.2.3 is fromnix develop .#bench. rledger ischeck --no-cache, frommain(d728311) and from this branch. Cells are exit code then codes.name_equitycapitalname_equityCapitalaccount_previous_balancesbad leafaccount_previous_balancesOpeningaccount_roundingbad leafinferred_tolerance_defaultUSD:-0.01inferred_tolerance_defaultUSD:0.01tolerance_multiplierabctolerance_multiplier0.6inferred_tolerance_multiplierabcbooking_methodfifobooking_methodFIFOplugin_processing_modeweirdplugin_processing_moderawrender_commasbogusrender_commasTRUEtitleSubdisplay_precisionUSD:-0.01(accumulates)name_equity "capital",booking_method "fifo",inferred_tolerance_default "USD:-0.01"name_equity "Capital"+open Capital:Zin the includeA 32-line include covering every option family gives the same errors on the same lines as bean-check, plus the
E7011andE7009warnings. (In round 1 rledger also gaveE7006for the include's missingdocumentsroot; since round 2 that is theE7009warning, as bean-check ignores it.)Location,
booking_method "fifo"in the include:checktextwarning[E7009]: ...(no location).../sub.beancount:1: error[E7002]: ...check --format json"file": ".../main.beancount", "line": 1"file": ".../sub.beancount", "line": 1sub.beancount, on the option lineLedgererrorsfile: "sub.beancount",line: 1Canonical-function check
There is one source of truth for the location:
OptionWarning::site, set by the loader. Every surface reads it.Drift guards compare each surface with the loader's sites end to end, on a two-file tree. The tree has an
E7003in the main file, and an invalidE7008and a validE7009in the include:cli_commands_test::test_check_option_diagnostics_are_located_like_the_loader: check's JSON(code, file, line)equals the loader's, and the text lines start withfile:line: severity[code].diagnostics::tests::option_diagnostics_are_located_like_check(LSP): bothledger_diagnostics_multiandall_diagnostics(each file as the current one) give the loader's(code, file, line), and the option-line range is checked.parsed_ledger::...::ledger_option_errors_are_located_like_checkandapi::...::validate_reports_option_errors_located_like_check(WASM).helpers::...::both_paths_agree_for_every_option_codenow compares the line and file of the WASM single-source paths too.Caches
CACHE_VERSIONgoes 97 (main) to 99. Both payloads archive the option diagnostics, which move: they gain lines and files, and an included invalid option is now an error. v97 is now main's (fix: make check, WASM, FFI and LSP agree on close-with-balance and after a booking error #2947), v95 is held by fix(parser): run a mid-line BOM's invalid token to the next blank, as beancount does #2931 and v98 by fix(parser): keep each header string in its own field after an invalid token #2944.CACHE_VERSIONgoes 69 to 71, with the WASM pin at 71 (round 3). The option diagnostics themselves are never cached (loadcache.rswrites only whenoptions.warningsis empty), but ignoring an includeddocumentsoption changes what a clean load produces: a v69 blob of a ledger whose include sets an existingdocumentsroot would keep serving thedocumententries found under it, with noE7009. v70 is held by fix(parser): run a mid-line BOM's invalid token to the next blank, as beancount does #2931 and v73 by fix(parser): keep each header string in its own field after an invalid token #2944.value_sitesis transient and not cached, likewarnings.How to test
Gates, all exit 0:
cargo fmt --check--all-features --all-targets -D warningsRUSTDOCFLAGS=-Dwarnings cargo doc --workspace --no-depscargo test --all-features --no-fail-fastfor loader, validate, lsp, wasm, ffi-wasi, ffi-component and rustledgerwasm-pack test --nodeReview round 1
Commit 18dd60c.
current_file_idisNone) tookhere = 0, so the main file's option diagnostics were drawn on the unrelated buffer's lines. WithNonethe ledger's option warnings are no longer attached; the buffer's own options go through the single-file fallback. Pinned bya_buffer_outside_the_ledger_gets_only_its_own_option_diagnostics: a ledger with an E7003 at line 3 and a scratch buffer of threeopens gives no option diagnostic, and the buffer's ownoption "nosuch"is E7001 on its line 2.rustledger_loader::option_warnings_to_errors(&[OptionWarning]) -> Vec<LedgerError>(the name and signature fix(ffi)!: report option errors, and validate file loads as rledger check does #2946 uses) is now the single mapping. It mapsOptionWarning::sitetoLedgerError::locationasErrorLocation { file, line, column: 1 }.rledger check(text and JSON) and the LSP (file matching, range, severity) read the mappedLedgerError.option_warnings_to_errorsis a one-argument wrapper through the existingError::from(LedgerError). The single-source entry points clearfilewithwithout_filesinstead of aname_filesflag.lineandcolumn(1) and nullend_line/end_column, as everyLedgerError-derived WASM error. Documented on the WASM helper. (They hadend_line=linebefore.) The CLI JSON keepsend_line=line,end_column=column, as its other diagnostics always fill them.test_option_warnings_to_errors_carries_the_site(loader); the existing drift guards now go through the mapping.Nits:
validateWithHostbesidevalidateMultiFile.; commentoutside a string (option_line_extent, with a test; the multi-file guard's fixture now has a comment containing a quoted;). The limitation that the line comes from the loaded ledger while the range is drawn on the live buffer is documented onoption_error_to_diagnostic; it is the same for every diagnostic the loaded ledger locates.Options::locateis by occurrence: the n-th warning for an(option, value)gets the n-th site that applied it, so the samedocumentsvalue in two files is located at both. Pinned bytest_locate_is_by_occurrence.site_of(last applied) remains for E7010, which is about the last value.validate_with_filesystemreads the option diagnostics right after the load, so they are reported beside a fatal load error and a processing failure too. Pinned byvalidate_reports_option_errors_beside_a_fatal_load_error.Main has not moved; caches stay WASM 99 and loader 69.
Gates were re-run, all exit 0:
fmt --check, clippy--all-features --all-targets -D warnings,RUSTDOCFLAGS=-Dwarnings cargo doc,cargo test --all-features --no-fail-fastfor loader, validate, lsp, wasm, ffi-wasi, ffi-component and rustledger, andwasm-pack test --node.Review round 2
Commit e4f6388, then a merge of
origin/main(3d52f7b, bringing in #2941 and #2943, no conflicts). No history was rewritten.documentsin an included file is ignored, as in beancount.loader.load_filegivesdocuments == []for an included root.main:0."documents"is removed fromACCUMULATE_ACROSS_INCLUDES. An included value now goes through the scratch converter and gets E7009. It is never applied, so nothing is scanned under it and there is no E7006.Options::documents, which an include no longer reaches.aggregate_options_map:operating_currencyis merged,display_precisiongoes into the mergeddcontext, andinsert_pythonpathbecomespythonpath. This is documented on the constant.display_precisionin an include, bean-check 3.2.3 itself crashes (_FixedPrecisionContexthas nofractional_dist), so that row has no reference.test_load_included_documents_is_ignored: E7009 at sub:1,documentsempty, no errors.test_load_documents_in_both_files_is_one_e7006: the same root in both files gives E7009 for the include and one E7006 at the top-level line, where bean-check also gives one error.included_files_still_contribute_accumulating_optionsnow expectsdocumentsto be ignored.errors.mdand theOptions::locaterustdoc are updated.test_locate_is_by_occurrencenow repeats the value within one file (lines 4 and 9).site_ofwithout.rev():test_rooted_leaf_warning_is_at_the_last_line_that_set_itsets the sameaccount_previous_balances "Equity:Open"on lines 2 and 5 and expects E7010 at 5.without_locationsnot clearing sites:test_without_locations_drops_every_sitebuilds the same options at other lines and files, with an E7001, a rejectedbooking_methodand a value site. The originals differ, the stripped copies are equal, and every site is gone.api.rs"Processing error" arm (and the same arm infrom_file_map) is not tested, because no input reaches it.processreturnsErronly fromrun_plugins'?, and noProcessErroris constructed anywhere in the loader: plugin and booking failures are pushed asLedgerErrors andapply_plugin_opsreturnsOk(()). Both arms now carry the option diagnostics anyway.Nits:
Ledger::from_file_map: reads the option diagnostics beforeprocess, so its processing-error arm reports them, asvalidate_with_filesystemdoes.option_error_file_id: usesSourceFile::id.errors.md: now says bean-check reports a missingdocumentsroot at line 0 of the main file, where rledger reports it at the option's line.rledger query: prints option diagnostics through the canonical mapping, asfile:line: CODE: message, and the ag-rledger envelope's warnings carryfileandline.test_query_option_diagnostics_are_located.query_warnings_match_what_rledger_query_printsnow rebuilds the location from the envelope.without_files: not added.ErrorLocation::fileis aPathBuf, not optional, so a loader helper could only drop the whole location (losing the line) or invent an empty path. WASM'swithout_filesworks on its own wire type, wherefileisOption. The FFI's single-source path can do the same on its wire type.Caches: WASM stays at 99 and the loader at 69 (unbumped). Nothing archived changes in this round, and the merged main commits move neither cache.
Gates:
cargo fmt --check--all-features --all-targets -D warningsRUSTDOCFLAGS=-Dwarnings cargo doc --workspace --no-depscargo test -p rustledger-loadercargo test -p rustledger-validatecargo test -p rustledger-lspcargo test -p rustledger-wasmcargo test -p rustledger-ffi-wasicargo test -p rustledger-ffi-componentcargo test -p rustledgerwasm-pack test --nodeAll
cargo testruns use--all-features --no-fail-fast. fmt, clippy and doc were re-run after the merge.Review round 3
Commit b316d6b (added on top; no history rewritten).
documentsoption is ignored with E7009) changes loader output, and round 2 wrongly left the loader at 69. Repro:main.beancountincludessub.beancount, which setsoption "documents" "docs", withdocs/Assets/A/2024-02-01.receipt.pdfpresent. A main build'srledger checkwrites the v69 blob ("No errors found"); the fixed build then rejects it and reportssub.beancount:1: warning[E7009], andrledger query main.beancount 'SELECT date, type FROM #entries'returns only theopenrow.CACHE_VERSION71 inrustledger-loaderandLOADER_CACHE_VERSION_PIN71 inrustledger-wasm. 71 is the lowest number no open PR holds: fix(parser): run a mid-line BOM's invalid token to the next blank, as beancount does #2931 holds 70 and fix(parser): keep each header string in its own field after an invalid token #2944 holds 73.CostNumberandMetaValuefixture tripwires move to 71. No archived layout moved.rledger queryescapes option messages on the terminal path, asDiagnostic::to_linedoes (Escape control characters in ledger strings on output #2538). These messages quote option keys and values. Test:test_query_option_diagnostic_message_is_escaped, where an ESC in aname_equityvalue prints as\u{1b}.ag-rledger querywarnings now carry optionalfileandlinekeys.rledger mergenow refuses a tree whose include setsdocuments, because inlining would make that root effective. Checked:merge -nreports that the directive stream differs (adocumententry appears) and writes nothing.Left as they are: the "mixed locations" nit and the non-UTF-8 path nit.
Gates:
cargo fmt --all --check--all-features --all-targets -D warningsRUSTDOCFLAGS=-Dwarnings cargo doc --workspace --no-depscargo test -p rustledger-loadercargo test -p rustledger-wasmcargo test -p rustledgerwasm-pack test --nodeCloses #2925
Merge of origin/main (99d51d0)
Brings in #2939 and #2942. One conflict, in the CHANGELOG's Fixed section, resolved by keeping both entries. No history rewritten. Neither merged commit moves a cache version (main is still loader 69, WASM 94), so this PR stays at loader 71 (with the WASM pin and both
FIXTURE_VERSIONtripwires at 71) and WASM 99.Gates, all exit 0:
cargo fmt --all --check, clippy--all-features --all-targets -D warnings,RUSTDOCFLAGS=-Dwarnings cargo doc --workspace --no-deps,cargo test --all-featuresfor loader, wasm, validate, lsp and rustledger, andwasm-pack test --node.Merge of origin/main (b6ce2d4)
Brings in #2947. Conflicts, resolved keeping both sides: the CHANGELOG's Fixed section (both entries kept); the WASM cache version note (main's v97 note kept, this PR's v99 note after it, and its held-numbers remark now reads v98 held by #2944); and the error lists in WASM
validate_with_filesystemandLedger(main'sreported_ledger_errors, which leaves out advisory-only E1004, plus this PR's located option diagnostics). Main is now loader 69, WASM 97, so this PR stays at loader 71 and WASM 99.Gates re-run, all exit 0:
cargo fmt --all --check, clippy--all-features --all-targets -D warnings,RUSTDOCFLAGS=-Dwarnings cargo doc --workspace --no-deps,cargo test --all-featuresfor loader, wasm, validate, lsp and rustledger, andwasm-pack test --node.🤖 Generated with Claude Code