Repository navigation
docs(migration): document the same-day repeated-lot divergence (#2118) - #2121
Conversation
Python's inventory is keyed by (currency, cost), so acquisitions sharing a cost, date and label pool into one position; rustledger keeps a lot per acquisition. With a third lot at a different cost acquired between them the two consume in different orders, and a holding bought twice in one day reports a different cost basis and different realized gains. We decided to keep rustledger's behavior -- it respects acquisition order, and Python's cannot, since `Cost` carries a date and no time -- so the answer is to tell people rather than to change it. Anyone reconciling against Python needs to know why the figures differ. Both the worked example and the suggested fix were run against both engines: distinct labels make the purchases separate lots on either side and the two agree. 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
Documents the same-day repeated-lot divergence between rustledger and Python beancount.
Changes:
- Adds a FIFO example showing differing cost bases.
- Explains the differing inventory models.
- Recommends distinct lot labels as a workaround.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
The block was presented as reproducible and was not: it carried no `booking_method` option and no `open` directives, so pasting it into a file reports E1001 "Account Income:Gains was never opened" and never reaches the booking behavior it exists to show. The default is STRICT, not FIFO, so even opened it would not have demonstrated the FIFO case described. I had trimmed the setup from the ledger I actually tested, which is the way to turn a verified example into an unverified one. Both engines were re-run against the block exactly as it now appears: `rledger check` is clean, rustledger leaves 10 @10.00 and 5 @20.00, and beancount leaves 5 @10.00 and 10 @20.00 -- the figures the surrounding text quotes. Reported by Copilot on #2121. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
|
Correct on both counts — fixed in 35cfc11. Reproduced before fixing: the block as written fails The cause is worth naming: I verified this example against a ledger that did carry the setup, then trimmed it for the doc. That is exactly how a verified example becomes an unverified one. The block now carries
which are the figures the surrounding prose quotes. |
The section said figures may differ. The fuzzer then showed the divergence also causes ACCEPTANCE differences in both directions: pooling changes which lots survive a reduction, so a later reduction naming an explicit cost can find its lot drained on one engine and present on the other. That is a different class of problem for someone migrating -- a ledger that does not load, reporting "Not enough units" with nothing in the message pointing at same-day repeated lots as the cause. Worth meeting in the migration guide rather than in the error. Evidence and both worked cases are on #2118. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
Closes the documentation half of #2118.
Python beancount's
Inventoryis keyed by(currency, cost), so acquisitions sharing a cost, date and label pool into a single position. rustledger keeps one lot per acquisition. When a lot at a different cost was acquired between two that pool, the engines consume in different orders — and a holding bought more than once in a day reports a different cost basis and different realized gains.We decided to keep rustledger's behavior: it respects acquisition order and Python's cannot, because
Costcarries a date and no time, so the two purchases are genuinely one lot under its model. That decision makes documenting it the deliverable — anyone reconciling figures against Python needs to know why they differ, and nothing warned them.Goes in
Known Differencesin the migration guide, which is where someone comparing the two engines will actually be looking.Both the example and the workaround were run, not reasoned about.
The worked example reproduces exactly as written: rustledger leaves
10 @10.00+5 @20.00, Python leaves5 @10.00+10 @20.00— Python consuming the third lot while the second, acquired earlier, goes untouched.The suggested fix is advice users will follow, so I checked it rather than assuming: giving the repeated purchases distinct labels makes them separate lots on both sides and the two engines then agree (
10 @10.00+5 @20.00each).Independent of #2119 and #2120 — this documents behavior that is not changing.
🤖 Generated with Claude Code
https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr