Repository navigation
test(core): pin STRICT_WITH_SIZE's two tie rules - #2124
Conversation
Variant sweep from #2115 and #2122, looking for the same shape -- an ordering whose secondary key nothing checks. `plan_strict_with_size` is CORRECT: it uses `min_by_key` on `(date_key, slot)` ascending, never reversing a walk, and encodes `None` dates to sort last rather than relying on `Option`'s natural order. No bug here. Both of those tie rules were unpinned, though, and its comment states each as a promise: - reversing the slot tiebreak to `Reverse(i)` left all 485 core tests passing, plus `rustledger`, `rustledger-validate` and `rustledger-query` - flipping `map_or((1, NaiveDate::MAX), ..)` so `None` sorts FIRST did the same `strict_with_size_takes_the_oldest_of_several_exact_size_lots` covers the primary date order from #2097 and stops there. Each test now kills exactly its mutant. Both fixtures put the lot that must NOT win first, so insertion order alone cannot produce the expected answer. Determinism here reaches the user: `report capgains` splits short from long on the surviving lot's date and per-lot IRR keys eligibility off it, so an arbitrary choice between two same-date lots moves tax figures. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
There was a problem hiding this comment.
Pull request overview
Adds regression tests for STRICT_WITH_SIZE lot-selection tie-breaking without changing production behavior.
Changes:
- Covers same-date exact-size lot selection.
- Verifies dated lots sort before date-less lots.
Suppressed comments (1)
crates/rustledger-core/src/inventory/booking.rs:1862
- This test name reads as “date less one” rather than “date-less,” so the scenario is hard to understand/search for. Rename it to use an unambiguous term such as
strict_with_size_prefers_a_dated_lot_over_an_undated_lot.
fn strict_with_size_prefers_a_dated_lot_over_a_date_less_one() {
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
📊 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?
|
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
"a_date_less_one" reads as "date less one" and does not match a search for "undated". Renamed to `strict_with_size_prefers_a_dated_lot_over_an_undated_lot`, with the surrounding prose aligned. Reported by Copilot on #2124. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
|
Good point on the name — taken in cdae37f. |
Variant sweep from #2115 and #2122, looking for the same shape: an ordering whose secondary key nothing checks.
plan_strict_with_sizeis correct — no bug hereIt uses
min_by_keyon(date_key, slot)ascending, never reverses a walk, and encodesNonedates to sort last rather than relying onOption's natural order:That is the same house rule
order_keyfollows — put the direction in the key, keep the tiebreak ascending. Reporting that as the result: the sibling defect I went looking for is not there.Both tie rules were unpinned
The comment above that key states each as a promise, and nothing held it:
Reverse(i)left all 485 core tests passing, plusrustledger,rustledger-validateandrustledger-queryNoneencoding so date-less lots sort first did the samestrict_with_size_takes_the_oldest_of_several_exact_size_lotscovers the primary date order from #2097 and stops there. Two size matches that share a date, and a date-less size match, both fell through.Each new test kills exactly its mutant and nothing else fails. Both fixtures put the lot that must not win first, so insertion order alone cannot produce the expected answer — otherwise they would pass for the wrong reason.
Why it matters beyond determinism-for-its-own-sake
report capgainssplits short from long on the surviving lot's acquisition date, and per-lot IRR keys eligibility off it. A reduction choosing arbitrarily between two same-date lots moves tax figures, silently — the postings still balance and no error is reported.Tests only; no behavior change. Independent of #2119, #2120, #2121 and #2123.
🤖 Generated with Claude Code
https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr