Preparing your design workspace

Loading the problem and your saved attempt…

Design a WAL-Backed Batch Log Writer

Design an in-process log writer that durably commits ordered record batches, survives crashes, and handles concurrent clients safely.

For this exercise, assume a single-process service accepts ordered batches of immutable log records. Each record has a client-supplied record ID and a string payload, and each append request has a stable request ID.

A successful batch is one logical commit: its records receive contiguous monotonically increasing offsets in request order, and no subset may become committed by itself. The writer may acknowledge success only after a checksum-protected write-ahead-log commit marker is durable.

It may copy committed records to a durable main log in the background, but recovery must make every acknowledged batch available for that copy exactly once. Retrying the same request ID with identical records returns the original receipt; reusing it with different records is an error.

Concurrent requests must have one observable commit order, while records inside each batch retain their order. An invalid or empty batch fails before durable state changes. After a crash, an incomplete or corrupt WAL tail is ignored after the last valid committed batch.

Design the object model, interfaces, and collaborations for append, background flush, retry, and recovery. Distributed replication, remote readers, retention, and log-segment rotation are outside scope.