Repository navigation
Conversation
…aries #1902 Phase 1, the last uncovered crate. Miri excludes this one for rowan reasons that are not going away, so this is the compensating coverage. The existing properties ask whether the same input gives the same answer twice. These ask whether the answer is RIGHT, via relationships that hold whatever the ledger contains - so they need no expected value, which is what makes them checkable over generated input: - WHERE p and WHERE NOT p must PARTITION the unfiltered rows. Neither half may invent, lose or double-count. A predicate that misevaluates in one direction only shows up as a union that no longer reconstructs the whole. - Grouping must preserve the total: SUM(number) GROUP BY account, summed back over groups, equals the ungrouped SUM. That is the invariant #1177 broke - rows right, group-key sidecar wrong. - ORDER BY must permute, never add, drop or alter. Sorting is where a comparator that is not a total order loses rows, and the null-ordering tests next door pin WHICH order rather than that the multiset survived. Aimed where this crate actually breaks: #1177 was a grouping/parallel divergence, and the two bugs found by hand this cycle (#1963, #1966) were both in evaluation rather than parsing. Also widens the amount generator, which sabotaging the partition property is how I found. Swapping `number > 0` for `number > 1` changed NOTHING - because with a uniform -1_000_000..1_000_000 range, landing in (0, 1] needs |n| <= 10^scale, at most 1000 of two million draws, about 0.3 expected hits across a whole run. There was nothing between 0 and 1 to lose. Now three magnitude bands, and that same sabotage fails. Every property sabotage-verified: overlapping halves fail the partition, a wrong total fails the grouping, a dropped row fails the permutation, and the boundary case fails now where it did not before.
📊 Benchmark Results
vs main branch (2026-08-07)
What do these numbers mean?
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
This PR expands verification coverage in rustledger-query by adding property-based “algebraic invariant” tests (partitioning predicates, grouping totals, and ORDER BY permutation) and by strengthening the generated amount distribution so boundary-adjacent values are exercised.
Changes:
- Improve the proptest amount generator to cover multiple magnitude bands, increasing the likelihood of boundary hits around 0 and 1.
- Add algebraic property tests for
WHERE p/WHERE NOT ppartitioning, grouping total preservation, andORDER BYbeing a permutation of the unordered results.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| prop_assert!(!g.rows.is_empty(), "grouping must produce at least one group"); | ||
| prop_assert_eq!(t.rows.len(), 1, "an ungrouped SUM is a single row"); | ||
|
|
|
| Metric | Result |
|---|---|
| Check Compatibility | 100% |
| BQL Compatibility | 95% (raw 89%, 162 masked) |
| Full AST Match | 100% |
| Total Files | 812 |
What's tested
- Check: Exit codes and error counts match
bean-check - BQL: Query results match
bean-query
The headline is the EFFECTIVE rate, after pairs where beanquery
itself is wrong are masked. raw is the same run with nothing
masked. A widening gap means the registry grew, not that rledger
changed. - Files: ~800 test files downloaded from 10+ beancount repositories
Full results available in workflow artifacts
|
Superseded by #1983 — same commits plus Copilot's per-key grouping assertion, on |
#1902 Phase 1 — the last uncovered crate. Miri excludes
rustledger-queryforrowan reasons that are not going away, so this is the compensating coverage.
Three algebraic properties
The existing properties ask whether the same input gives the same answer twice.
These ask whether the answer is right, using relationships that hold whatever
the ledger contains — so they need no expected value, which is what makes them
checkable over generated input.
WHERE pandWHERE NOT ppartition the unfiltered rowsORDER BYis a permutationAimed where this crate actually breaks: #1177 was a grouping/parallel-path
divergence, and the two bugs found by hand this cycle (#1963, #1966) were both
in evaluation rather than parsing. The neighbouring null-ordering tests pin
which order; none pinned that the multiset survived it.
The generator was the more interesting finding
Sabotaging the partition property is how it surfaced. Swapping
number > 0fornumber > 1— a filter that should lose every row between them — changednothing.
With a uniform
-1_000_000..1_000_000, landing in(0, 1]needs|n| <= 10^scale: at most 1000 of two million draws, roughly 0.3 expectedhits across an entire run. There was nothing between 0 and 1 to lose.
The amount strategy now spans three magnitude bands, and that same sabotage
fails. This affects the pre-existing determinism properties too, which were
sampling the same narrow band.
Sabotage-verified
number > 1(boundary)Worth noting the third and fourth: my first two attempts at sabotaging the
partition were no-ops — one because the generator filters zero amounts, one
because it never produced boundary values. A sabotage that doesn't fail is
either a bad sabotage or a real gap, and telling those apart is where the
generator weakness came from.
cargo test --workspace— 132 suites, 0 failures. Clippy clean.