Repository navigation
chore(nix): add beanprice to dev shell for bean-price differential tests - #976
Merged
Merged
Conversation
beanprice is a separate PyPI distribution since beancount v3, and is not packaged in nixpkgs. Build it locally as a buildPythonApplication so that `bean-price` is on PATH in the dev shell — unblocks issue #967's acceptance criterion #1 (differential tests of `rledger price` against `bean-price`). Also bump pythonWithBeancount from python311 to python312: beanprice's curl-cffi 0.14.0 dependency pulls sphinx 9.1.0, which requires Python ≥ 3.12. python311 is also approaching EOL. Verified `bean-price`, `bean-check`, and `bean-query` are all in PATH; `cargo check --workspace` still passes. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the Nix flake dev shell to include the bean-price CLI (via a locally-built beanprice Python application) so the project can run differential price-discovery tests against rledger price as tracked in #967.
Changes:
- Add a local
beanpricederivation built from PyPI (sdist 2.1.0) usingbuildPythonApplication. - Add
beanpriceto the default dev shell tool list sobean-priceis onPATH. - Bump
pythonWithBeancountfrom Python 3.11 to 3.12 and update the dev-shell greeting accordingly.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
|
| Metric | Result |
|---|---|
| Check Compatibility | 99% |
| BQL Compatibility | 91% |
| Full AST Match | 99% |
| Total Files | 782 |
What's tested
- Check: Exit codes and error counts match
bean-check - BQL: Query results match
bean-query - Files: ~800 test files downloaded from 10+ beancount repositories
Full results available in workflow artifacts
This was referenced May 3, 2026
robcohen
added a commit
that referenced
this pull request
May 3, 2026
The harness in crates/rustledger/tests/bean_price_compat.rs depends on bean-price being on PATH, which is only true inside the nix dev shell (added to the flake in #976). The main Test matrix uses dtolnay/rust-toolchain + cargo nextest directly, with no nix involved, so the harness silently skipped there. Add a dedicated bean-price-compat job that uses cachix/install-nix-action and runs `cargo test -p rustledger --test bean_price_compat` inside `nix develop`. Wire it into the build aggregator's required-results list. This ensures CI actually executes the differential tests against bean-price so a flake regression (or a real divergence between rledger and bean-price discovery) breaks the PR loudly instead of silently. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
robcohen
added a commit
that referenced
this pull request
May 3, 2026
…967) (#978) * feat(test): bean-price compat harness — symbol-set differential (refs #967) Lands the keystone deliverable from issue #967's audit: a Rust integration test that runs both `rledger price` and `bean-price -n` against a fixture beancount file and asserts they discover the same set of (symbol, quote_currency) pairs to fetch. How it works: - Fixture is written to a temp file with two declared commodities carrying `price: "USD:yahoo/SYMBOL"` metadata. - `bean-price -n` (dry-run) is parsed from its tabular output. - `rledger price -f <fixture> --source-cmd <stub>` is run with a no-op stub that returns "1.00" for any symbol — no network, no fetching. - Both symbol-sets are compared; mismatch fails the test with a useful diff in the assertion message. The harness skips (with a notice) when `bean-price` is not on PATH so contributors running `cargo test` outside `nix develop` aren't blocked. CI uses the dev shell (where #976 added beanprice), so this runs there. Note on the stub source: written into a `TempDir` with a plain file (not `NamedTempFile`) — the latter holds an open write handle and Linux refuses to exec it (ETXTBSY). Once landed, every per-candidate audit item from #967 (#967 items 1-6) can add its own fixture + assertion against this harness. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * test(price): tighten compat harness — scope clarity, robustness, second fixture Self-review fixes for PR #978: 1. Scope correction. Rename "symbol-set" -> "commodity discovery". The harness uses --source-cmd, which bypasses rledger's source-resolution layer — so it cannot validate source-precedence (audit item 5), per-spec ticker preservation (#970), or fallback chains. Module docstring now states this explicitly. Validating those needs an HTTP mock or a future --dry-run flag on rledger. 2. Switch rledger output extraction to --beancount format. Stable, documented format (`<date> price <SYM> <amt> <CCY>`); decouples the parser from whatever the stub source happens to print. 3. #![cfg(unix)]. The set_mode(0o755) call needs unix::fs::PermissionsExt; without the gate, Windows builds would fail to compile. 4. Tighten extract_bean_price_jobs: require uppercase ticker shape + uppercase currency. Previously a stray log line beginning with an identifier could be wrongly interpreted as a job. 5. New CI sanity test bean_price_must_be_on_path_in_dev_shell. Without it, removing beanprice from the flake would silently turn every compat test into a no-op (skip path) and we wouldn't notice. Gated on IN_NIX_SHELL or CI env vars to avoid false failures locally. 6. New fixture FIXTURE_MIXED_CURRENCIES (USD AAPL + EUR SAP). On its first run it found a real bug — see #979: parse_simple_format hardcodes "USD" when --source-cmd output omits a currency. The stub now echoes the requested --currency back as a workaround so the harness can land independently; #979 tracks the underlying fix. 7. Drop noise docstrings on private helpers; consolidate via assert_same_commodities helper. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * test(price): shell-quote --source-cmd path (Copilot review on PR #978) rledger parses --source-cmd through shell_words::split, so a temp directory containing whitespace would cause the path to be word-split into separate tokens and the exec to fail before discovery could be compared. Quote the path with shell_words::quote before passing. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * test(price): fix CI failure — only assert bean-price PATH inside nix shell The bean_price_must_be_on_path_in_dev_shell sanity test was gated on \`IN_NIX_SHELL OR CI\`, but CI doesn't currently run inside \`nix develop\` — so on CI the gate fired but bean-price wasn't on PATH, causing the test to fail. Drop the CI env-var trigger; only assert when actually inside the dev shell. Local devs running tests via \`nix develop\` still get the flake-regression guard; making CI also run under nix is a separate workflow change. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * ci: run bean-price compat harness inside nix develop The harness in crates/rustledger/tests/bean_price_compat.rs depends on bean-price being on PATH, which is only true inside the nix dev shell (added to the flake in #976). The main Test matrix uses dtolnay/rust-toolchain + cargo nextest directly, with no nix involved, so the harness silently skipped there. Add a dedicated bean-price-compat job that uses cachix/install-nix-action and runs `cargo test -p rustledger --test bean_price_compat` inside `nix develop`. Wire it into the build aggregator's required-results list. This ensures CI actually executes the differential tests against bean-price so a flake regression (or a real divergence between rledger and bean-price discovery) breaks the PR loudly instead of silently. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * Revert "ci: run bean-price compat harness inside nix develop" This reverts commit 919fee1. * ci: enforce bean-price compat harness in pre-push hook (local only) Reverts the CI workflow approach (commit 919fee1, reverted in adad0b28) in favor of a local pre-push hook gated on relevant file changes. Why local instead of CI: running the harness in CI requires nix shell (for bean-price), which adds noticeable runtime to every PR. The harness mostly catches regressions in the price command's discovery layer or in the flake's beanprice packaging — both areas are touched rarely. Running the check pre-push when those specific files change concentrates the cost on the contributor making the relevant change. The hook fires when any of these change: - crates/rustledger/src/cmd/price/**, price_cmd.rs (discovery / source layer) - crates/rustledger/tests/bean_price_compat.rs (the harness itself) - flake.nix, flake.lock (could drop or break beanprice) Uses `nix develop --command cargo test ...` so bean-price is reliably on PATH; if nix isn't installed, the push fails loudly with a clear error rather than silently skipping. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.7 (1M context) <[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.
Summary
Adds the `bean-price` CLI to the dev shell. Unblocks #967's acceptance criterion #1 (differential tests of `rledger price` against `bean-price`).
Why
`beanprice` is a separate PyPI distribution since beancount v3 and is not packaged in nixpkgs. Without it on PATH there is no way to drive a side-by-side comparison for the bean-price compat sweep tracked in #967.
What changed
Verification
Test plan
Refs #967.