fix(ploeg): close a Shift and settle its Work Item in one transaction #154
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "ryangr0/ploeg-close-and-settle-atomically"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The shift engine called Store.CloseShift and then Store.SettleItem in
separate transactions. A crash between them left a leased Work Item
behind a closed Shift. EvaluateAll only repairs queued items without a
Shift and live Shifts, so nothing ever recovered it.
Store.CloseShiftAndSettle now closes the Shift, cancels its pending Runs
and settles the item in one transaction; CloseShift and SettleItem share
the same transactional steps. Only the call that wins the close settles:
replaying an already-closed Shift, including one a withdrawal closed,
changes nothing, and the engine returns before any remand or tracker
notification. Notifications stay outside the transaction.
Tests inject a fault at the close, the settle and the settle's audit
row, then sweep: each ends with the Shift closed once, the item in
awaiting_review and the ledger unchanged.
Not covered: Work Items already stranded as leased behind a closed Shift before this fix are not repaired; that needs a one-off check. The losing evaluator no longer re-settles (the atomic close makes that crash repair unnecessary).
Verified with
mise run verifyon the pinned toolchain (all gates passed).Ticket: https://vikunja.webgrip.dev/tasks/1734
🤖 Generated with Claude Code