Design and Implement an Active-Passive Key-Value Store
Model and implement an in-memory key-value store whose writes commit to active and passive replicas together or fail without changing either.
For this exercise, assume one in-process key-value service owns an active replica and a passive replica. One writer and one reader may call the service concurrently. The writer can put or delete non-empty string keys, while the reader can get a key and receive either its committed string value and version or NotFound.
Every successful mutation receives the next monotonically increasing version and must be visible on both replicas before success is returned. If the passive replica rejects a mutation or is unavailable, the mutation fails, neither replica changes, and the version does not advance.
Deleting a missing key returns NotFound and does not advance the version. Reads must never expose a mutation that ultimately fails. Design the objects, responsibilities, interfaces, state transitions, and interactions, then implement the bounded in-memory mutation and read core.
Use an injectable passive-replica failure hook so tests can exercise success and failure deterministically.
Persistence, networking, automatic failover, replica promotion, and more than one writer or reader are outside scope; a follow-up asks how the design would evolve when the replicas move to separate processes and promotion is required.