DurableStore

interface DurableStore

A durable, typed-key store that persists serialized CRDT state across process restarts.

The store is key-addressed: each CRDT in WarpTelemetry lives under its own StoreKey. Reads and writes are opaque byte arrays — the store knows nothing about CRDT internals; serialization lives in the callers.

Durability contract

write returns only after the bytes are durably committed. A crash after write returns implies the bytes survive a restart and are returned by the next read. This is the foundation of the key inversion in WarpTelemetry: export() returns success the moment write returns — not on delivery to a backend.

Platform implementations

PlatformSuggested WALStatus
JVM / AndroidFileChannel.force(true) + atomic renameShips in this module (#800)
iOS / macOSNSFileManager atomic-writeFollow-up issue filed (#802)
wasmJsIndexedDB IDBObjectStoreFollow-up issue filed (#801)

Tests inject InMemoryDurableStore; production code wires a platform WAL.

Inheritors

Functions

Link copied to clipboard
abstract suspend fun delete(key: StoreKey)

Remove the entry for key. No-op if the key is absent.

Link copied to clipboard
abstract suspend fun read(key: StoreKey): ByteArray?

Read the bytes stored under key, or null if the key has never been written.

Link copied to clipboard
abstract suspend fun write(key: StoreKey, bytes: ByteArray)

Durably write bytes under key, overwriting any previous value.