All practice tasks

Coding (Platform)

Stream consumer reconciliation

nestjs · Medium · stream processing

A production API needs a stream consumer reconciliation repair at its service boundary. A React search surface receives streamed chunks. Retries may replay chunks and an older stream may close after a new query starts.

Task

Implement the stream consumer reconciliation contract used by the supplied HTTP adapter. 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.
  • 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 boundary
  • tests/candidate.test.js — Candidate-authored regression

What this task practices

Stream consumer reconciliation is a coding (platform) interview exercise that trains prompt interpretation, explicit assumptions, a concrete response, and a clear explanation of tradeoffs. The catalog marks it as medium difficulty. It focuses on State Modeling, Regression Testing, Technical Reasoning. The signed-in workspace provides the tools for the round and evaluates the attempt against task-specific criteria. Reference solutions, hidden checks, evaluator instructions, and candidate work remain private.

Sign in to startThe workspace and evaluation open after sign in.