fix(turn): log reorder + deathSave (BUG-7)

reorderParticipants returned log:null → handler skipped logAction → drag
invisible in combat log, no undo payload. Now returns
log:{ message, undo:{ participants, turnOrderIds, currentTurnParticipantId }}.
App.js handleDrop calls logAction on logged reorders.

Found second gap: deathSave also returned null log (both branches).
Fixed — message + undo (participants snapshot).

Added logging contract test (turn.logging.test.js):
- all mutating ops logged (start/next/pause/add/remove/toggle/hp/deathsave/
  condition/reorder/end)
- no-ops return null log (same-id, cross-init, cross-pointer blocks)
- undo payloads valid + restore prior state
- documents addParticipants + updateParticipant gaps (null log, intentional)

235 tests green.
This commit is contained in:
david raistrick
2026-07-04 17:22:52 -04:00
parent 5a09f71d4c
commit ab9f8fa2e7
5 changed files with 281 additions and 7 deletions
+7 -3
View File
@@ -4,9 +4,13 @@ Backlog of bugs + long-term items. Milestones live in REWORK_PLAN.md.
## Open bugs
### BUG-7: reorderParticipants has no undo
- `reorderParticipants` returns `log: null`. Other ops return `log.undo`.
- Cannot undo drag-drop. Candidate for undo system (M6).
### BUG-7: reorderParticipants not logged
- FIXED — now returns `log: { message, undo }`. Handler calls logAction.
Undo snapshots participants[] + turnOrderIds + pointer.
- Found second gap: deathSave also returned null log. Fixed (message + undo).
- Logging contract test added: turn.logging.test.js (all mutating ops logged,
no-ops null, undo payloads valid). Documents addParticipants +
updateParticipant gaps (null log, intentional).
## Open features