All practice tasks

Coding (Platform)

Consumer page ownership

fastify · Medium · cursor pagination

A production API needs a consumer page ownership repair at its service boundary. A search screen can request several pages for one query while the user changes the query. Late pages from the previous search currently append to the new result set.

Task

Implement the consumer page ownership contract used by the supplied HTTP adapter. Reduce request and response events into visible state where only the current search generation can commit rows.

Contract

Input is {events}. Events are search{id,query}, page{id,cursor,rows,nextCursor}, failure{id,message}. Return {query,rows,nextCursor,error}. A search starts a new generation and clears rows and errors.

Acceptance criteria

  • Only events matching the latest search id may commit.
  • Append pages in event order and deduplicate by row id.
  • A current failure preserves committed rows and sets error.
  • A stale 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

Consumer page ownership 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.