All practice tasks

Coding (Platform)

Revision-safe autosave API

react + fastify · Medium · autosave state machine

A browser and API disagree at the revision-safe autosave api 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

Repair the shared browser-to-service contract. 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.
  • Keep browser-visible state consistent with the canonical service result.

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 autosave API 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.