All practice tasks

Coding (Platform)

Revision-safe asynchronous update

fastify · Medium · optimistic concurrency

A production API needs a revision-safe asynchronous update repair at its service boundary. An editor saves drafts in the background. A slow confirmation for an older revision currently marks the latest text as saved, and an older failure can replace the current status.

Task

Implement the revision-safe asynchronous update contract used by the supplied HTTP adapter. Reduce edit, save, success and failure events into a truthful draft status.

Contract

Input is {events}. edit carries revision and text; save, success and failure carry revision. Return {text,revision,status,error}. Status is idle, dirty, saving, saved or failed.

Acceptance criteria

  • Only the latest revision may become saved or failed.
  • Saving an old revision does not change current status.
  • Editing clears the previous error.
  • Success must match both the current revision and latest save attempt.
  • 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

Revision-safe asynchronous update 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.