fastify · Easy · set reconciliation
A production API needs a controlled membership set repair at its service boundary. A controlled React table receives a new set of selectable rows after filtering. The local reducer keeps removed IDs and emits duplicate change events.
Task
Implement the controlled membership set contract used by the supplied HTTP adapter. Reduce replace, toggle and select-all events into a valid ordered selection and a minimal list of emitted snapshots.
Contract
Input is {availableIds,initialSelected,events}. replace carries availableIds; toggle carries id; all carries checked. Return {selected,emissions}.
Acceptance criteria
- Keep selection in available-ID order.
- Ignore toggles for unavailable IDs.
- Emit only when the selected IDs actually change.
- Prune selection after replace.
- 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