Repository navigation
ci: add merge_group trigger for GitHub Merge Queue - #1
Merged
Merged
Conversation
robcohen
enabled auto-merge
January 5, 2026 16:14
robcohen
disabled auto-merge
January 5, 2026 16:21
robcohen
enabled auto-merge
January 5, 2026 16:21
robcohen
added this pull request to the merge queue
Jan 5, 2026
robcohen
added a commit
that referenced
this pull request
Jan 14, 2026
ci: add merge_group trigger for GitHub Merge Queue
robcohen
added a commit
that referenced
this pull request
Jan 14, 2026
ci: add merge_group trigger for GitHub Merge Queue
2 tasks done
robcohen
added a commit
that referenced
this pull request
Feb 16, 2026
- Sort metadata keys for deterministic output order (#3) - Escape strings in option/include/plugin formatting (#2) - Preserve leading blank lines at file start (#1) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
3 tasks done
robcohen
added a commit
that referenced
this pull request
Mar 31, 2026
Issue #1: Fix release asset names to include version Issue #5: Add docs for `add` and `config` commands Issue #6: Add missing CLI options to check/query docs check command: added -q/--quiet, -C/--no-cache, -a/--auto, --plugin query command: added -F/--query-file, -o/--output, -m/--numberify, -q/--no-errors, beancount format option Co-Authored-By: Claude Opus 4.5 <[email protected]>
robcohen
added a commit
that referenced
this pull request
Mar 31, 2026
Issue #1: Fix release asset names to include version Issue #5: Add docs for `add` and `config` commands Issue #6: Add missing CLI options to check/query docs check command: added -q/--quiet, -C/--no-cache, -a/--auto, --plugin query command: added -F/--query-file, -o/--output, -m/--numberify, -q/--no-errors, beancount format option Co-Authored-By: Claude Opus 4.5 <[email protected]>
robcohen
added a commit
that referenced
this pull request
Apr 12, 2026
- Fix #1: Build SourceMap with buffer content in single-file mode so run_plugins() can preserve directive source locations - Fix #2: Anchor Python plugin warning to the plugin directive span and filter by current_file_id to avoid noise in multi-file mode - Fix #3: Only show plugin errors in the main file (file_id 0) to prevent duplication across open documents - Fix #4: Correct diagnostic message — non-native plugins are skipped in LSP, not "may be slower" (run_plugins only runs native plugins) - Fix #5: Merge fresh buffer plugin declarations with ledger plugins, mirroring the directive overlay approach for unsaved edits Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
robcohen
added a commit
that referenced
this pull request
Apr 23, 2026
…tability - Change ValidationOptions.document_dirs from Vec<String> to Vec<PathBuf> to store resolved paths instead of raw values - Add #[non_exhaustive] to ValidationOptions to prevent breaking changes when new fields are added - Resolve document paths against source_map base_dir in run_validation() and build_validation_options_from_loader() to match run_plugins() behavior - Use Path::join() instead of string concatenation for portable paths - Fix test to use doc_subdir.join() instead of format! for path construction Addresses Copilot review comments #1, #2, #3, #4, #5, #7 on PR #899
robcohen
added a commit
that referenced
this pull request
Apr 23, 2026
…tability - Change ValidationOptions.document_dirs from Vec<String> to Vec<PathBuf> to store resolved paths instead of raw values - Add #[non_exhaustive] to ValidationOptions to prevent breaking changes when new fields are added - Resolve document paths against source_map base_dir in run_validation() and build_validation_options_from_loader() to match run_plugins() behavior - Use Path::join() instead of string concatenation for portable paths - Fix test to use doc_subdir.join() instead of format! for path construction Addresses Copilot review comments #1, #2, #3, #4, #5, #7 on PR #899
robcohen
added a commit
that referenced
this pull request
Apr 23, 2026
…tability - Change ValidationOptions.document_dirs from Vec<String> to Vec<PathBuf> to store resolved paths instead of raw values - Add #[non_exhaustive] to ValidationOptions to prevent breaking changes when new fields are added - Resolve document paths against source_map base_dir in run_validation() and build_validation_options_from_loader() to match run_plugins() behavior - Use Path::join() instead of string concatenation for portable paths - Fix test to use doc_subdir.join() instead of format! for path construction Addresses Copilot review comments #1, #2, #3, #4, #5, #7 on PR #899
robcohen
added a commit
that referenced
this pull request
Apr 23, 2026
…tability - Change ValidationOptions.document_dirs from Vec<String> to Vec<PathBuf> to store resolved paths instead of raw values - Add #[non_exhaustive] to ValidationOptions to prevent breaking changes when new fields are added - Resolve document paths against source_map base_dir in run_validation() and build_validation_options_from_loader() to match run_plugins() behavior - Use Path::join() instead of string concatenation for portable paths - Fix test to use doc_subdir.join() instead of format! for path construction Addresses Copilot review comments #1, #2, #3, #4, #5, #7 on PR #899
robcohen
added a commit
that referenced
this pull request
Apr 28, 2026
Five substantive issues raised by the Copilot review on PR #945: 1. **Custom cache directories now created automatically.** `BEANCOUNT_LOAD_CACHE_FILENAME` patterns can resolve to a directory that doesn't exist (e.g. `~/.cache/rledger/{filename}.cache` on a fresh install). `save_cache_entry` now `create_dir_all`s the parent eagerly so caching isn't silently disabled. 2. **`BEANCOUNT_DISABLE_LOAD_CACHE` is now honored at the loader level.** Previously only the CLI checked it, so any external consumer of `rustledger-loader::{load,save}_cache_entry` would silently bypass the kill switch. Both functions now early-return when the env var is set to a non-empty value (matching Python beancount semantics). The CLI check stays as an early-out optimization. 3. **`default_cache_path` exposed as a pure helper.** `cache_path()` reads process env, which makes any test that calls `save_cache_entry`/`invalidate_cache` env-sensitive. `default_cache_path()` returns the dotfile path with no env lookup — useful for tests and library consumers that need determinism. 4. **Doc accuracy.** I had claimed cache invalidation was "content-based" in `docs/commands/check.md` and `docs/reference/architecture.md`, but `compute_hash` actually hashes file path + mtime + size. Reworded both pages to describe the real metadata-based behavior (and noted content-based hashing as a possible future improvement). 5. **Module rustdoc clarified** to state explicitly that the env vars are honored at the loader level, not just by CLI callers. Tests: - New integration test `save_creates_missing_parent_directory` covers the regression in #1. - New integration test `disable_env_makes_load_return_none_and_save_no_op` covers the loader-level enforcement in #2. - In-module roundtrip/invalidate tests now `assert_clean_cache_env()` at the top so a developer with locally-set cache env vars sees a clear failure rather than mysterious behavior. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
robcohen
added a commit
that referenced
this pull request
Apr 28, 2026
…elf-review) Self-review of PR #945 surfaced five issues; this commit addresses all of them. 1. **Match Python beancount on `BEANCOUNT_DISABLE_LOAD_CACHE`.** Python's check is `os.getenv(...) is None`, which means *any* presence — empty string included — disables the cache. We required a non-empty value; that's a silent divergence for users who write `EXPORT FOO=` in their shell. Switched to `is_some()` to match. 2. **Normalize the disable check between loader and CLI.** Both now go through the new `cache_disabled_by_env()` helper, exported from the loader so any downstream consumer (LSP, MCP, future tools) gets the same semantics for free. 3. **`invalidate_cache` now also removes the legacy sidecar.** `save_cache_entry` already cleans up the pre-#939 visible file when it writes a new dotfile cache; `invalidate_cache` was missing the same logic, so a `rledger check --invalidate-cache` (hypothetical or programmatic invalidate) would leave the legacy file behind. 4. **`with_env` is now panic-safe.** Replaced the inline save/restore pattern with an `EnvGuard` Drop type. A test that panics mid-body no longer leaks its mutated env into the next test in the binary. 5. **`disable_env_makes_load_return_none_and_save_no_op` was vacuous.** It asserted `load_cache_entry → None`, but the cache file didn't exist (because save was a no-op), so the test would have passed even if `load_cache_entry` ignored the env entirely. Restructured to: (a) write a real cache with the env unset, (b) set the env and verify load returns None despite the cache being on disk, (c) verify save doesn't touch the existing file (mtime invariant). Plus one new test: `empty_disable_env_value_still_disables` locks in the Python-beancount-compatible empty-value semantics from #1. And one new test: `test_invalidate_cache_removes_legacy_sidecar` covers the new behavior in #3. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
robcohen
added a commit
that referenced
this pull request
Apr 28, 2026
…loses #939) (#945) * fix(cache): hide cache file as dotfile and honor beancount env vars (closes #939) `rledger check` wrote a visible `<file>.cache` next to every ledger, creating clutter that surprised users (#939). Match Python beancount's established convention instead: - Default cache filename is now `.<file>.cache` (hidden dotfile), mirroring beancount's `.{filename}.picklecache`. - Honor `BEANCOUNT_DISABLE_LOAD_CACHE` to opt out persistently. - Honor `BEANCOUNT_LOAD_CACHE_FILENAME` to redirect the cache; supports `{filename}` substitution and resolves relative paths against the source directory, matching beancount semantics. - Empty `BEANCOUNT_LOAD_CACHE_FILENAME` is treated as unset to prevent every ledger's cache from collapsing onto the same file. - After writing the new dotfile cache, opportunistically delete the legacy visible `<file>.cache` (silent on failure) so upgrading users don't have to clean up by hand. The `--no-cache` / `-C` CLI flag continues to work for one-shot opt-out. Tests: - New unit tests for `resolve_cache_pattern` and `legacy_cache_path`. - New `tests/cache_env_var_test.rs` integration test that exercises the env var path end-to-end. Lives in a separate test binary because mutating process env requires `unsafe` since Rust 2024 and the workspace forbids `unsafe_code`. - Updated `test_load_cache_invalid_magic` to write the malformed cache at the new dotfile path so it actually exercises the load path. Docs: - `docs/commands/check.md` — added a Cache File section with naming, env vars, and migration note. - `docs/reference/architecture.md` — refreshed the Binary Cache section with the dotfile location, content-based invalidation note, and env var pointer. - `cache.rs` module-level rustdoc updated. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * docs(cache): refresh remaining stale references to old cache filename Pick up two spots missed in the initial #939 fix: - `.gitignore`: keep matching legacy `<file>.beancount.cache` (gitignored for users upgrading from earlier versions) and add an explicit dotfile pattern with a comment explaining the rationale. The bare `*` pattern already matched dotfiles per gitignore semantics, but the explicit pattern makes the intent clear. - `performance-roadmap.md`: cache location example was still showing the visible filename — updated to the dotfile form with an env-var pointer. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * fix(cache): address Copilot review feedback on #945 Five substantive issues raised by the Copilot review on PR #945: 1. **Custom cache directories now created automatically.** `BEANCOUNT_LOAD_CACHE_FILENAME` patterns can resolve to a directory that doesn't exist (e.g. `~/.cache/rledger/{filename}.cache` on a fresh install). `save_cache_entry` now `create_dir_all`s the parent eagerly so caching isn't silently disabled. 2. **`BEANCOUNT_DISABLE_LOAD_CACHE` is now honored at the loader level.** Previously only the CLI checked it, so any external consumer of `rustledger-loader::{load,save}_cache_entry` would silently bypass the kill switch. Both functions now early-return when the env var is set to a non-empty value (matching Python beancount semantics). The CLI check stays as an early-out optimization. 3. **`default_cache_path` exposed as a pure helper.** `cache_path()` reads process env, which makes any test that calls `save_cache_entry`/`invalidate_cache` env-sensitive. `default_cache_path()` returns the dotfile path with no env lookup — useful for tests and library consumers that need determinism. 4. **Doc accuracy.** I had claimed cache invalidation was "content-based" in `docs/commands/check.md` and `docs/reference/architecture.md`, but `compute_hash` actually hashes file path + mtime + size. Reworded both pages to describe the real metadata-based behavior (and noted content-based hashing as a possible future improvement). 5. **Module rustdoc clarified** to state explicitly that the env vars are honored at the loader level, not just by CLI callers. Tests: - New integration test `save_creates_missing_parent_directory` covers the regression in #1. - New integration test `disable_env_makes_load_return_none_and_save_no_op` covers the loader-level enforcement in #2. - In-module roundtrip/invalidate tests now `assert_clean_cache_env()` at the top so a developer with locally-set cache env vars sees a clear failure rather than mysterious behavior. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * fix(cache): tighten env handling and panic-safe test plumbing (#945 self-review) Self-review of PR #945 surfaced five issues; this commit addresses all of them. 1. **Match Python beancount on `BEANCOUNT_DISABLE_LOAD_CACHE`.** Python's check is `os.getenv(...) is None`, which means *any* presence — empty string included — disables the cache. We required a non-empty value; that's a silent divergence for users who write `EXPORT FOO=` in their shell. Switched to `is_some()` to match. 2. **Normalize the disable check between loader and CLI.** Both now go through the new `cache_disabled_by_env()` helper, exported from the loader so any downstream consumer (LSP, MCP, future tools) gets the same semantics for free. 3. **`invalidate_cache` now also removes the legacy sidecar.** `save_cache_entry` already cleans up the pre-#939 visible file when it writes a new dotfile cache; `invalidate_cache` was missing the same logic, so a `rledger check --invalidate-cache` (hypothetical or programmatic invalidate) would leave the legacy file behind. 4. **`with_env` is now panic-safe.** Replaced the inline save/restore pattern with an `EnvGuard` Drop type. A test that panics mid-body no longer leaks its mutated env into the next test in the binary. 5. **`disable_env_makes_load_return_none_and_save_no_op` was vacuous.** It asserted `load_cache_entry → None`, but the cache file didn't exist (because save was a no-op), so the test would have passed even if `load_cache_entry` ignored the env entirely. Restructured to: (a) write a real cache with the env unset, (b) set the env and verify load returns None despite the cache being on disk, (c) verify save doesn't touch the existing file (mtime invariant). Plus one new test: `empty_disable_env_value_still_disables` locks in the Python-beancount-compatible empty-value semantics from #1. And one new test: `test_invalidate_cache_removes_legacy_sidecar` covers the new behavior in #3. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
robcohen
added a commit
that referenced
this pull request
Apr 29, 2026
Four issues raised by Copilot review:
1. **Interpolated postings were silently dropped from the activity check.**
`Loader::new().load(...)` returns the unprocessed `LoadResult`, where
auto-balanced postings (units missing in source, filled in by booking)
have `units == None`. The active-commodity filter only sees postings
with `posting.amount() == Some(_)`, so a transaction like
2024-02-01 * "Buy AAPL"
Assets:Brokerage ; interpolated
Equity:Opening -100 AAPL
would mark AAPL as inactive (the asset side has no explicit amount,
the equity side is filtered out as non-balance-sheet).
Switched to `rustledger_loader::load(file, &LoadOptions { run_plugins:
false, validate: false, ..default() })`, which runs the booking pass
so every posting has explicit units. Plugins/validation are skipped
here because price discovery shouldn't be blocked on plugin failures
in an otherwise-loadable file.
2. **`--source-cmd` ignored per-commodity quote currency.** The external
command path built `PriceRequest` with `args.currency` directly,
bypassing the per-symbol `effective_currency` resolution that the
network path already uses. Threaded the discovery map through and
applied the same lookup so quote_currency / price: metadata work
uniformly across all source types.
3. **Misleading mapping-precedence comment.** Said "highest precedence
first" but the code starts with config (lowest) and inserts CLI
(highest) last. Reworded to "in increasing precedence" and called
out the high-to-low effective order explicitly.
4. **Doc inaccuracy on activity scope.** `docs/commands/price.md` said
activity is "any open account", but the implementation restricts to
Assets/Liabilities (with the rationale that Equity:Opening retains
inverse balances of every commodity ever held). Refreshed the prose
to match the actual behavior and rationale.
New regression test `active_filter_handles_explicit_amounts_on_balance_sheet_side`
locks in the post-booking shape that #1 relies on.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
robcohen
added a commit
that referenced
this pull request
Apr 29, 2026
#951) * feat(price): metadata-driven, active-commodity discovery (closes #948) Issue #948 asks for `bean-price`-style symbol discovery: read the ledger, fetch prices for the commodities you actually hold, and use per-commodity `price:` metadata to drive source/ticker selection. Three changes in one PR: 1. `price:` metadata on commodity directives drives source/ticker. Format: `"<quote>:<source>/<ticker>"`, comma-chained for fallback. 2. `quote_currency:` metadata sets a per-commodity quote currency. 3. Active-only filtering by default. A commodity is fetched only if at least one open Assets/Liabilities account ends with non-zero balance in it. Restricting to balance-sheet accounts (vs any account) is the correct definition: Equity:Opening retains inverse balances of every commodity ever held, so including Equity would mark closed positions as still active. The `--all-commodities` flag opts out of the filter. Backward compat: commodities without metadata still pass the ticker-shape heuristic; CLI symbols pass through unchanged. New module: `crates/rustledger/src/cmd/price/discovery.rs`. 8 new unit tests, 2 new CLI parsing tests. Docs updated in `docs/commands/price.md`. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * fix(price): address Copilot review feedback on #951 Four issues raised by Copilot review: 1. **Interpolated postings were silently dropped from the activity check.** `Loader::new().load(...)` returns the unprocessed `LoadResult`, where auto-balanced postings (units missing in source, filled in by booking) have `units == None`. The active-commodity filter only sees postings with `posting.amount() == Some(_)`, so a transaction like 2024-02-01 * "Buy AAPL" Assets:Brokerage ; interpolated Equity:Opening -100 AAPL would mark AAPL as inactive (the asset side has no explicit amount, the equity side is filtered out as non-balance-sheet). Switched to `rustledger_loader::load(file, &LoadOptions { run_plugins: false, validate: false, ..default() })`, which runs the booking pass so every posting has explicit units. Plugins/validation are skipped here because price discovery shouldn't be blocked on plugin failures in an otherwise-loadable file. 2. **`--source-cmd` ignored per-commodity quote currency.** The external command path built `PriceRequest` with `args.currency` directly, bypassing the per-symbol `effective_currency` resolution that the network path already uses. Threaded the discovery map through and applied the same lookup so quote_currency / price: metadata work uniformly across all source types. 3. **Misleading mapping-precedence comment.** Said "highest precedence first" but the code starts with config (lowest) and inserts CLI (highest) last. Reworded to "in increasing precedence" and called out the high-to-low effective order explicitly. 4. **Doc inaccuracy on activity scope.** `docs/commands/price.md` said activity is "any open account", but the implementation restricts to Assets/Liabilities (with the rationale that Equity:Opening retains inverse balances of every commodity ever held). Refreshed the prose to match the actual behavior and rationale. New regression test `active_filter_handles_explicit_amounts_on_balance_sheet_side` locks in the post-booking shape that #1 relies on. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
9 tasks done
robcohen
added a commit
that referenced
this pull request
Jun 19, 2026
Follow-up to the review on #1435. Instead of running the plugin and relabeling the failure by name-shape, detect a bare module-name reference *before* invoking the runtime: - Correctness (#1): the old error-path relabel discarded the real error `e` for any dotted/non-.py name — masking genuine failures such as a corrupt runtime download (`PythonRuntime::new()` fails before module discovery). Now module names are rejected up front, so the `Err(e)` arm only fires for real plugin files and surfaces `e` verbatim (E8002). - Altitude (#2): no runtime is downloaded/compiled (and no "10-100x slower" warning printed) for a request that is rejectable from the name alone. - Reuse/consistency (#3): both E8004 sites now share `module_ref_message`, so the "not supported by module name; reference the file directly" guidance is identical everywhere. - Discriminator (#4): one `is_python_module_name` helper using `eq_ignore_ascii_case`, not the pre-lowercased `ext` (fixes a latent case-sensitivity coupling). - Docs (#5): document E8002/E8004/E8005 in docs/reference/errors.md. - Cleanup (#6,#7): static example path (drops the dead `unwrap_or` and the `./.py` trailing-dot edge); drop the redundant `is_python_available()` guard (`suggest_module_path` already handles a missing interpreter). fmt + clippy (-D warnings, python-plugins) clean; loader suite 64/64. Co-Authored-By: Claude Opus 4.8 <[email protected]>
robcohen
added a commit
that referenced
this pull request
Jun 19, 2026
* fix(loader): actionable error for module-name Python plugin refs A Python plugin declared by module name (beancount's `plugin "pkg.mod"`) is unsupported by design — only file-path references load (see `discover_module_source`). It routes into the Python-plugin branch (the name contains a dot), runs, and fails inside `execute_module`, surfacing as `E8002: Python plugin 'pkg.mod' execution failed: Python plugin module not found: pkg.mod` — doubly misleading, reading as a venv/PYTHONPATH problem the user cannot fix. Detect the bare-module-name case in the error path and emit an actionable `E8004` instead: name the unsupported form and point at the file path, resolving it via system Python (`suggest_module_path`) when possible, else a generic hint that also notes the sandbox cannot see the host venv (the plugin must be self-contained). This also unifies the code with the parallel unknown-plugin branch (both `E8004`). The existing `suggest_module_path`/`E8004` hint was unreachable for real module names because they always contain a dot and were diverted into the Python branch first. Closes #1432 (Gap 1). Co-Authored-By: Claude Opus 4.8 <[email protected]> * docs(plugins): document Python plugin file-path + self-contained model Gaps 2-3 of #1432. Document that: - Built-in names resolve to the native Rust plugin regardless of the `beancount.plugins.` prefix (so `plugin "beancount.plugins.auto_accounts"` is unchanged), but a custom Python plugin must be referenced by file path — the module-name form is rejected. - Python plugins run in a CPython-WASI sandbox that never mounts the host venv / site-packages, so they must be self-contained (stdlib + the bundled beancount compat shim); anything heavier needs a native Rust plugin. Adds a "Referencing a Python Plugin" + "Plugin Sandbox" section to docs/reference/plugins.md and a file-path note to docs/migration/from-beancount.md (clarifying that the existing auto_accounts example works because it resolves to a native plugin, not Python). Co-Authored-By: Claude Opus 4.8 <[email protected]> * refactor(loader): reject module-name plugins up front; address review Follow-up to the review on #1435. Instead of running the plugin and relabeling the failure by name-shape, detect a bare module-name reference *before* invoking the runtime: - Correctness (#1): the old error-path relabel discarded the real error `e` for any dotted/non-.py name — masking genuine failures such as a corrupt runtime download (`PythonRuntime::new()` fails before module discovery). Now module names are rejected up front, so the `Err(e)` arm only fires for real plugin files and surfaces `e` verbatim (E8002). - Altitude (#2): no runtime is downloaded/compiled (and no "10-100x slower" warning printed) for a request that is rejectable from the name alone. - Reuse/consistency (#3): both E8004 sites now share `module_ref_message`, so the "not supported by module name; reference the file directly" guidance is identical everywhere. - Discriminator (#4): one `is_python_module_name` helper using `eq_ignore_ascii_case`, not the pre-lowercased `ext` (fixes a latent case-sensitivity coupling). - Docs (#5): document E8002/E8004/E8005 in docs/reference/errors.md. - Cleanup (#6,#7): static example path (drops the dead `unwrap_or` and the `./.py` trailing-dot edge); drop the redundant `is_python_available()` guard (`suggest_module_path` already handles a missing interpreter). fmt + clippy (-D warnings, python-plugins) clean; loader suite 64/64. Co-Authored-By: Claude Opus 4.8 <[email protected]> * fix(loader): recognize forward-slash plugin paths on Windows + unit tests Addresses the Copilot review note: is_python_module_name checked only std::path::MAIN_SEPARATOR (`\` on Windows), so a forward-slash file ref like "plugins/foo" could be misclassified as a module name there. Check both `/` and the platform separator. Adds direct unit tests for is_python_module_name (module vs .py vs path-separated vs existing-file, case-insensitive ext) and module_ref_message (both the resolved-path and fallback branches — also covering the line codecov flagged). Co-Authored-By: Claude Opus 4.8 <[email protected]> --------- Co-authored-by: Claude Opus 4.8 <[email protected]>
This was referenced Jun 20, 2026
robcohen
added a commit
that referenced
this pull request
Jun 25, 2026
dhat profiling (the new profiling data branch) ranked tokenize_inner and lossless_kind_tokens as the #1/#2 allocators -- both grew an unsized Vec via push, reallocating ~17x. Reserve Vec::with_capacity(source.len() / 4) (~4 bytes per beancount token). Measured on a 10k-txn workload: total heap allocated 158.7MB -> 141.6MB (-10.8%); tokenize_inner 17 allocations -> 1. Parser tests + clippy clean; allocation-only, behavior-preserving.
robcohen
added a commit
that referenced
this pull request
Jun 25, 2026
… (-10.8% heap) (#1587) * perf(parser): pre-size lexer token vectors to kill reallocation churn dhat profiling (the new profiling data branch) ranked tokenize_inner and lossless_kind_tokens as the #1/#2 allocators -- both grew an unsized Vec via push, reallocating ~17x. Reserve Vec::with_capacity(source.len() / 4) (~4 bytes per beancount token). Measured on a 10k-txn workload: total heap allocated 158.7MB -> 141.6MB (-10.8%); tokenize_inner 17 allocations -> 1. Parser tests + clippy clean; allocation-only, behavior-preserving. * perf(parser): cap the token-vector reservation (avoid pathological over-reserve)
robcohen
added a commit
that referenced
this pull request
Jun 25, 2026
…23MB, -2.6%) currency_occurrences/account_occurrences are consumed only by the LSP, but the loader/CLI pipeline collected them anyway -- walk_descendants_once built a Spanned<Account>/Spanned<Currency> (+ an in-ERROR_NODE ancestor walk) per ACCOUNT/CURRENCY token, the #1 allocation-count site. Add parse_without_occurrences (collect_occurrences=false) and point the loaders two parse sites at it; parse() is unchanged so the LSP keeps full data. Measured on 10k txns: -23.6MB heap (-14.9%), -40072 allocations, -29.1M instructions (-2.6%). Regression test + 280 parser / 89 loader tests pass.
robcohen
added a commit
that referenced
this pull request
Jun 25, 2026
…23MB, -2.6%) currency_occurrences/account_occurrences are consumed only by the LSP, but the loader/CLI pipeline collected them anyway -- walk_descendants_once built a Spanned<Account>/Spanned<Currency> (+ an in-ERROR_NODE ancestor walk) per ACCOUNT/CURRENCY token, the #1 allocation-count site. Add parse_without_occurrences (collect_occurrences=false) and point the loaders two parse sites at it; parse() is unchanged so the LSP keeps full data. Measured on 10k txns: -23.6MB heap (-14.9%), -40072 allocations, -29.1M instructions (-2.6%). Regression test + 280 parser / 89 loader tests pass.
robcohen
added a commit
that referenced
this pull request
Jun 25, 2026
…23MB, -2.6%) currency_occurrences/account_occurrences are consumed only by the LSP, but the loader/CLI pipeline collected them anyway -- walk_descendants_once built a Spanned<Account>/Spanned<Currency> (+ an in-ERROR_NODE ancestor walk) per ACCOUNT/CURRENCY token, the #1 allocation-count site. Add parse_without_occurrences (collect_occurrences=false) and point the loaders two parse sites at it; parse() is unchanged so the LSP keeps full data. Measured on 10k txns: -23.6MB heap (-14.9%), -40072 allocations, -29.1M instructions (-2.6%). Regression test + 280 parser / 89 loader tests pass.
robcohen
added a commit
that referenced
this pull request
Jun 25, 2026
…23MB heap, -2.6% instructions) (#1590) * perf(parser): skip LSP-only occurrence collection on the load path (-23MB, -2.6%) currency_occurrences/account_occurrences are consumed only by the LSP, but the loader/CLI pipeline collected them anyway -- walk_descendants_once built a Spanned<Account>/Spanned<Currency> (+ an in-ERROR_NODE ancestor walk) per ACCOUNT/CURRENCY token, the #1 allocation-count site. Add parse_without_occurrences (collect_occurrences=false) and point the loaders two parse sites at it; parse() is unchanged so the LSP keeps full data. Measured on 10k txns: -23.6MB heap (-14.9%), -40072 allocations, -29.1M instructions (-2.6%). Regression test + 280 parser / 89 loader tests pass. * test(parser): compare full directive/error/option contents (not just counts) * docs(parser): drop private intra-doc link to walk_descendants_once parse_via_cst_opts is pub; rustdoc -D warnings rejects a public doc linking to the private walk_descendants_once. Use a plain code span instead of a link.
robcohen
added a commit
that referenced
this pull request
Jun 25, 2026
…6% load) (#1594) * perf(parser): green-tree walker foundation + offset/span oracle (PR1 wip) First increment of the green-conversion rewrite (profiling sizing spike: CST->AST convert is ~74% of load, ~33% of it red-node traversal that allocs a NodeData per node touch). Adds cst/green.rs: a top-down green-tree walk threading the absolute byte offset, with a differential test proving its top-level node spans are byte-identical to the red node_span across BOM/multi-byte/error-recovery cases. De-risks offset drift (the #1 hazard) before directive-body conversion is layered on. Not yet wired into the parse path. * perf(parser): green transaction-header conversion + field oracle (PR1 wip) Adds convert_transaction_header: a single fused green pass extracting date / flag / payee+narration / tags / links / span with no red-node allocation, reusing the now-shared text parsers (parse_date_token, decode_string_token extracted from StringLit::text_decoded so red+green share one decoder). A field-level oracle pins every header field byte-identical to the red parse() across flag variants, multi-string, tags/links, escapes, and multi-byte cases. Postings/metadata/comments/error-recovery next. 282 parser tests pass. * perf(parser): green simple-posting conversion + oracle (PR1 wip) Adds convert_simple_posting + simple_amount: a green pass building a Posting (account + non-arithmetic units + posting_span + same-line trailing comments) with no red-node allocation, reusing the shared parse_decimal_token / is_comment_kind (now pub(super)). Bails (None) on flag/cost/price/metadata/ arithmetic/multi-amount postings (later increments; the oracle corpus excludes them). Field oracle pins the full Posting + span byte-identical to red across simple/elided/negative/trailing-comment/decimal cases. clippy clean; 283 tests. * perf(parser): green cost-spec + price-annotation conversion + oracle (PR1 wip) Adds green convert_cost_spec (forms {N CCY} / {{T CCY}} / {N # T CCY} / {*} merge, + date + label, via a fused pass mirroring convert_cost_spec + cost_total_after_hash) and convert_price_annotation (@@->Total/@->Unit + amount, bailing on arithmetic amounts). Wired into convert_simple_posting (cost/price no longer bail). Oracle corpus extended with all cost-spec forms + @/@@ prices + cost+price together; full Posting+span byte-identical to red. clippy clean, 283 tests. * perf(parser): assemble + wire green transaction conversion (PR1, -16% load) Adds green::convert_transaction (header + simple postings, bailing to red on txn-metadata / direct-child comments / deprecated-pipe / unparseable amount / posting flag-meta-arithmetic) and wires it into parse_via_cst_opts dispatch with a red fallback: green is used only when its output is identical to red, so the hybrid is output-equivalent. Measured on the 10k-txn load: 1,062,145,403 -> 891,072,035 I refs (-16.1%) -- the lossless-CST-tax recovery the sizing spike predicted, from converting transactions off the green tree instead of red-node cursors. 283 parser + 57 integration + 89 loader + booking tests pass. * test(parser): green_eq_red differential test + fuzz target (PR1) Adds parse_red_only (forces the red conversion path), a parse_green_eq_red_corpus differential unit test (green-wired parse == red across the green path + every fallback trigger), and the fuzz_green_eq_red fuzz target (registered in fuzz.yml) generalizing the invariant to arbitrary input. The hybrid is verified output-equivalent to pure red. * docs(parser): address review on green conversion (PR1) - drop crate-root re-export of parse_red_only (stays at cst::parse_red_only, a doc-hidden test/fuzz hook) so it doesn't widen the crate public API - replace module-level allow(dead_code) with a targeted one on the test-only top_level_node_spans helper, so real dead code elsewhere is still caught - fix stale docs: convert_simple_posting now handles cost/price; convert_cost_spec tolerates an unparseable number (number: None, matching red) * fix(parser): green must latch the FIRST date token, not first-success fuzz_green_eq_red found a divergence: for input with an invalid first date (e.g. `3333/33/3`, month 33) followed by a valid-looking later date token, red drops the directive (InvalidDateValue on node.date()), but green's `date.is_none()` guard kept scanning DATE tokens and latched a later valid one — keeping a transaction red discards. Fix: latch on the first date token seen (date_seen flag); if it fails to parse, date stays None and the directive bails to red, matching node.date() semantics. Same latch fix applied to cost-spec date/label. Regression cases added to parse_green_eq_red_corpus. Also fixes the CI build/Clippy failure: 3 collapsible_if warnings in test helpers (missed locally — needed clippy --all-targets, not bare -p).
robcohen
added a commit
that referenced
this pull request
Jun 25, 2026
Re-implements walk_descendants_once on the green tree — the #1 allocation site (red descendants_with_tokens() heap-allocates a NodeData per node, over EVERY token in the file). A recursive green walker threads the byte offset, an in_error_node flag (replacing red's per-token parent_ancestors() ERROR_NODE probe — green has no parent pointers), and the linear preceded_by_ws column-0 comment state, producing a byte-identical DescendantsWalkResult (inline errors, top-level comments, currency/account occurrences). Wired into parse_via_cst_inner behind use_green. Unlike the directive conversion this runs on EVERY directive, so it extends the win on the standard workload. Differential (parse_green_eq_red_corpus + fuzz_green_eq_red) extended to compare account/currency occurrences. clippy --all-targets clean, 284+ tests.
robcohen
added a commit
that referenced
this pull request
Jun 25, 2026
Re-implements walk_descendants_once on the green tree — the #1 allocation site (red descendants_with_tokens() heap-allocates a NodeData per node, over EVERY token in the file). A recursive green walker threads the byte offset, an in_error_node flag (replacing red's per-token parent_ancestors() ERROR_NODE probe — green has no parent pointers), and the linear preceded_by_ws column-0 comment state, producing a byte-identical DescendantsWalkResult (inline errors, top-level comments, currency/account occurrences). Wired into parse_via_cst_inner behind use_green. Unlike the directive conversion this runs on EVERY directive, so it extends the win on the standard workload. Differential (parse_green_eq_red_corpus + fuzz_green_eq_red) extended to compare account/currency occurrences. clippy --all-targets clean, 284+ tests.
robcohen
added a commit
that referenced
this pull request
Jun 25, 2026
#1599) * perf(cli): mimalloc global allocator for the rledger binary (-7% load) Post-green-conversion, the cachegrind breakdown shows allocator machinery is the #1 cost (~14%) of the load — the pipeline makes many small short-lived allocations that glibc malloc handles poorly. Set mimalloc as the rledger binary's global allocator: -7.0% instructions on the 10k-txn workload (likely more wall-clock), process-wide so every command benefits. Binary-only (never the library — embedders choose their own allocator), gated off wasm (C lib), default-on via a new mimalloc feature (opt out with --no-default-features). Pure-Rust allocators evaluated + rejected (ferroc won't compile on the toolchain; talc v5 is embedded-oriented). rledger check smoke test: identical output. * chore: regenerate cargo-vet exemptions * perf(cli): make mimalloc opt-in (non-default), not forced on lib consumers Review fix (Copilot): mimalloc was in the rustledger crate default features, but the crate has a [lib] target published to crates.io — default features apply to library consumers, forcing a vendored C dependency (+ C toolchain) on every embedder. Move it out of default to an opt-in mimalloc feature; the binary global allocator is still gated on it (+ not wasm). Release binaries enable it explicitly (follow-up wires --features mimalloc into release-build.yml). --------- Co-authored-by: rustledger-bot[bot] <257329324+rustledger-bot[bot]@users.noreply.github.com>
This was referenced Jun 27, 2026
robcohen
added a commit
that referenced
this pull request
Jul 1, 2026
…p oversell (#1666, #1668) (#1669) #1666 — reducing a labeled cost lot dropped the matched lot's label (single-lot path set label: None while the multi-lot path preserved it), so the reduction didn't net against its augmenting lot and left a phantom unlabeled negative lot in the holdings view. Carry the matched lot's label onto the reduction posting (as the date already was). rustledger-booking/src/book.rs. #1668 #2 — a balance asserted in a currency the account doesn't allow only got a confusing 'Balance failed ... got 0 EUR'. Add a dedicated 'Invalid currency ... for Balance directive' diagnostic (E-code CurrencyNotAllowed) in validate_balance_early, mirroring the transaction currency check; only when the account constrains its currencies. #1668 #1 — an oversell reported 'Not enough units' twice via the FFI: booking (inside load_source) reports it WITH transaction context, and the #1663 validation session re-derived it context-free (its reduce-check is a standalone-validation safety net). Drop the session's copy when a load error already conveys it. The CLI never doubled (it partitions booking-failed txns out before late validation). #1668 #3 — investigated, no change: rustledger already flags duplicate open across includes (E1002 on the CLI), and #1663 made the FFI load path validate too, so it is caught there as well; the report reflects the pre-#1663 non-validating load. Tests: booking reduction-label netting; balance wrong-currency (+ unconstrained no-false-positive); FFI parity oversell-single-error. 94 validate + 106 booking + 19 FFI parity pass; clippy -D warnings + fmt clean. Closes #1666 Co-authored-by: Claude Opus 4.8 <[email protected]>
robcohen
added a commit
that referenced
this pull request
Aug 11, 2026
#2008 cases 1 and 2, stacked on the transaction-header PR. #1 `10 AAPL {, 100.0 USD, , }` beancount: unexpected COMMA, expecting HASH or CAPITAL or CURRENCY #2 `1.1 AAPL {45.23 USD / 2015-07-16 / "blabla"}` beancount: unexpected SLASH, expecting RCURL or COMMA beancount's cost spec is a comma-separated component list where each component is a compound_amount, DATE, STRING or `*`. An empty component is not a component, and CURRENCY completes a compound_amount so nothing but `,` or a closer may follow it. The obvious reading of case 2 - "SLASH is illegal in a cost spec" - is wrong and would have been worse than the bug. `/` is a number_expr operator: `{10.00 * 3 USD}` is valid and archives 30.00 (#1939/#1942), so a token ban would have passed both fixtures and broken every ledger that divides in a cost spec. The defect is positional, which is what beancount's own message says ("expecting RCURL or COMMA"). `*` is left as ordinary content for the same reason - it is both the "any lot" component and multiplication, and reading it as a complete component turns `{10.00 * 3 USD}` into junk. The corpus caught the one I did get wrong. A first draft recognized only `}` as a closer and fired on 42 real `{{total}}` specs across the 731-file sweep. With `{{`/`}}`/`{#` in the brace sets the sweep produces exactly two diagnostics: the two target fixtures, no false positives. That case is now a unit test rather than something the sweep alone covers. No green mirror this time, and that is not an oversight: the check rides the existing whole-tree COST_SPEC scan next to `extract_unclosed_cost_brace_errors`, which sits outside the `use_green` branch and already runs for both paths. One walker, nothing to drift. Case 5 (`{USD}`, `{ # USD}`) is deliberately still accepted. beancount rejects it from the BOOKER - "Too many missing numbers for currency group" - which is a judgment across a currency group, not a property of one spec's tokens, so it cannot be decided here. A unit test asserts it stays clean so the split is explicit rather than an omission. Honest about what this does NOT fix: `rledger check` still reports the downstream `E3001 does not balance` alongside the new parse error, because we continue processing where beancount stops at the syntax error. The real cause is now named first and `rledger query` refuses the file (matching bean-query), but fully removing the invented-cost residual means dropping the directive, which is a booking-layer change and not this PR. Cache 25 -> 26 (wasm 11 -> 12, pins with them) - a separate bump from v25 because a cache written between the two lands carries v25 and is still stale for this change. Refs #2008 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018bGRsKA42peqSnz4VMreBG
robcohen
added a commit
that referenced
this pull request
Aug 11, 2026
#2008 cases 1 and 2, stacked on the transaction-header PR. #1 `10 AAPL {, 100.0 USD, , }` beancount: unexpected COMMA, expecting HASH or CAPITAL or CURRENCY #2 `1.1 AAPL {45.23 USD / 2015-07-16 / "blabla"}` beancount: unexpected SLASH, expecting RCURL or COMMA beancount's cost spec is a comma-separated component list where each component is a compound_amount, DATE, STRING or `*`. An empty component is not a component, and CURRENCY completes a compound_amount so nothing but `,` or a closer may follow it. The obvious reading of case 2 - "SLASH is illegal in a cost spec" - is wrong and would have been worse than the bug. `/` is a number_expr operator: `{10.00 * 3 USD}` is valid and archives 30.00 (#1939/#1942), so a token ban would have passed both fixtures and broken every ledger that divides in a cost spec. The defect is positional, which is what beancount's own message says ("expecting RCURL or COMMA"). `*` is left as ordinary content for the same reason - it is both the "any lot" component and multiplication, and reading it as a complete component turns `{10.00 * 3 USD}` into junk. The corpus caught the one I did get wrong. A first draft recognized only `}` as a closer and fired on 42 real `{{total}}` specs across the 731-file sweep. With `{{`/`}}`/`{#` in the brace sets the sweep produces exactly two diagnostics: the two target fixtures, no false positives. That case is now a unit test rather than something the sweep alone covers. No green mirror this time, and that is not an oversight: the check rides the existing whole-tree COST_SPEC scan next to `extract_unclosed_cost_brace_errors`, which sits outside the `use_green` branch and already runs for both paths. One walker, nothing to drift. Case 5 (`{USD}`, `{ # USD}`) is deliberately still accepted. beancount rejects it from the BOOKER - "Too many missing numbers for currency group" - which is a judgment across a currency group, not a property of one spec's tokens, so it cannot be decided here. A unit test asserts it stays clean so the split is explicit rather than an omission. Honest about what this does NOT fix: `rledger check` still reports the downstream `E3001 does not balance` alongside the new parse error, because we continue processing where beancount stops at the syntax error. The real cause is now named first and `rledger query` refuses the file (matching bean-query), but fully removing the invented-cost residual means dropping the directive, which is a booking-layer change and not this PR. Cache 25 -> 26 (wasm 11 -> 12, pins with them) - a separate bump from v25 because a cache written between the two lands carries v25 and is still stale for this change. Refs #2008 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018bGRsKA42peqSnz4VMreBG
robcohen
added a commit
that referenced
this pull request
Aug 11, 2026
* fix(parser): reject malformed cost-spec component lists #2008 cases 1 and 2, stacked on the transaction-header PR. #1 `10 AAPL {, 100.0 USD, , }` beancount: unexpected COMMA, expecting HASH or CAPITAL or CURRENCY #2 `1.1 AAPL {45.23 USD / 2015-07-16 / "blabla"}` beancount: unexpected SLASH, expecting RCURL or COMMA beancount's cost spec is a comma-separated component list where each component is a compound_amount, DATE, STRING or `*`. An empty component is not a component, and CURRENCY completes a compound_amount so nothing but `,` or a closer may follow it. The obvious reading of case 2 - "SLASH is illegal in a cost spec" - is wrong and would have been worse than the bug. `/` is a number_expr operator: `{10.00 * 3 USD}` is valid and archives 30.00 (#1939/#1942), so a token ban would have passed both fixtures and broken every ledger that divides in a cost spec. The defect is positional, which is what beancount's own message says ("expecting RCURL or COMMA"). `*` is left as ordinary content for the same reason - it is both the "any lot" component and multiplication, and reading it as a complete component turns `{10.00 * 3 USD}` into junk. The corpus caught the one I did get wrong. A first draft recognized only `}` as a closer and fired on 42 real `{{total}}` specs across the 731-file sweep. With `{{`/`}}`/`{#` in the brace sets the sweep produces exactly two diagnostics: the two target fixtures, no false positives. That case is now a unit test rather than something the sweep alone covers. No green mirror this time, and that is not an oversight: the check rides the existing whole-tree COST_SPEC scan next to `extract_unclosed_cost_brace_errors`, which sits outside the `use_green` branch and already runs for both paths. One walker, nothing to drift. Case 5 (`{USD}`, `{ # USD}`) is deliberately still accepted. beancount rejects it from the BOOKER - "Too many missing numbers for currency group" - which is a judgment across a currency group, not a property of one spec's tokens, so it cannot be decided here. A unit test asserts it stays clean so the split is explicit rather than an omission. Honest about what this does NOT fix: `rledger check` still reports the downstream `E3001 does not balance` alongside the new parse error, because we continue processing where beancount stops at the syntax error. The real cause is now named first and `rledger query` refuses the file (matching bean-query), but fully removing the invented-cost residual means dropping the directive, which is a booking-layer change and not this PR. Cache 25 -> 26 (wasm 11 -> 12, pins with them) - a separate bump from v25 because a cache written between the two lands carries v25 and is still stale for this change. Refs #2008 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018bGRsKA42peqSnz4VMreBG * fix(parser): fuse the cost-spec shape check into the existing scan Both #2022 review comments, and the second was more than wording. I documented the check as riding the existing whole-tree COST_SPEC scan and then gave it its own `descendants()` walk - so the doc was false AND the code did the thing the doc was written to avoid. That scan already sits behind a `contains('{')` guard precisely because `descendants()` allocates a red node per node; profiling once flagged it as ~50k wasted allocations on cost-spec-free ledgers. A second identical pass doubles a cost the codebase deliberately profiled down. Now genuinely fused into `extract_unclosed_cost_brace_errors`' loop: one walk, and the module doc describes what the code does. An unclosed spec skips the shape check - reporting a component defect on a truncated spec is noise about the truncation. The other comment: the trailing-junk message hardcoded "only `,` or `}` may follow", but a `{{total}}` spec closes with `}}`. Naming the wrong delimiter in a message about malformed syntax is the same species of misdirection #2008 is about. It says "the closing brace" now. Also gives the cost-spec path the same non-char-boundary fallback the header path got in the #2020 review, instead of an empty-quoted message. Re-swept the 731-file corpus after the restructure: exactly six diagnostics, the six target fixtures, no false positives. Refs #2008 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018bGRsKA42peqSnz4VMreBG * chore(baselines): update CostWithSlashes for the reworded diagnostic The parser-output baseline hashes the diagnostics too, so changing "only `,` or `}` may follow" to "the closing brace" moved this fixture's output hash. One row, source hash unchanged, and the locally regenerated hash matches the prefix CI reported. Refs #2008 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018bGRsKA42peqSnz4VMreBG --------- Co-authored-by: Claude Opus 5 <[email protected]>
1 of 2 tasks
This was referenced Nov 27, 2026
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.
Summary
merge_groupevent trigger to CI workflowTest plan