nestjs · Hard · undo reconciliation
A production API needs a undoable bulk command journal repair at its service boundary. A React admin table applies bulk changes optimistically and offers Undo. Confirmations can arrive after Undo and currently reapply values the user explicitly reverted.
Task
Implement the undoable bulk command journal contract used by the supplied HTTP adapter. Maintain an intent journal where undo invalidates the target intent and later settlements cannot resurrect it.
Contract
Input is {initial,events}. apply carries intentId, ids and value; undo/confirm/fail carry intentId. Return {values,pending,failed}.
Acceptance criteria
- Apply affects only listed IDs.
- Undo removes the intent effect even after confirm.
- Failure removes only its own effect.
- Later active intents are replayed over the base state.
- Return a deterministic JSON-serializable result for the HTTP adapter.
Constraints
- Do not mutate caller-owned input.
- Keep the supplied framework adapter and public contract unchanged.
- Add candidate tests for at least one boundary not covered by the public cases.
Editable files
src/repair.js— Task-specific state or service boundarytests/candidate.test.js— Candidate-authored regression