All practice tasks

Coding (Platform)

Idempotent workflow journal

nestjs · Hard · idempotency

A production API needs a idempotent workflow journal repair at its service boundary. A board supports several rapid card moves. When one request fails, the current implementation restores the entire old board and erases later confirmed moves.

Task

Implement the idempotent workflow journal contract used by the supplied HTTP adapter. Reconcile move intents independently so failure restores only the affected intent while later confirmed order remains.

Contract

Input is {initialIds,events}. move has intentId,id,toIndex; success and failure have intentId. Return {ids,pending,failed}. Indices are clamped.

Acceptance criteria

  • Apply each move immediately.
  • Track the prior neighbor anchors for each intent.
  • Success removes only that intent.
  • Failure removes that move effect without discarding later intents.
  • 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

Idempotent workflow journal 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 hard 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.