react · Medium · streaming state
A React search surface receives streamed chunks. Retries may replay chunks and an older stream may close after a new query starts.
Task
Reconcile chunk events by stream ID and sequence without duplicating or reordering rows.
Contract
Input is {events}. start carries streamId and query; chunk carries streamId, sequence and rows; end/fail carry streamId. Return {query,rows,status,error}.
Acceptance criteria
- Only the latest stream may commit.
- Ignore replayed sequence numbers.
- Apply chunks in sequence order once gaps arrive.
- A stale end or failure changes nothing.
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