refactor(message-log-api): split MessageStore into read-only and mutable interfaces
ci / JVM build + tests (push) Successful in 6m14s

- Introduced `MutableMessageStore` for producers with an `append` operation, separate from read-only `MessageStore`.
- Updated all consumers and implementations to use the appropriate interface (`read-only` for observers, `mutable` for producers).
- Improves modularity and ensures compile-time guarantees against unintended write operations in the audit log.
This commit is contained in:
2026-09-20 21:08:55 +03:00
parent 2cc1d923b3
commit bd65c29b48
11 changed files with 48 additions and 25 deletions
@@ -7,7 +7,7 @@ import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import pw.binom.agentik.messageLog.MessageEvent
import pw.binom.agentik.messageLog.MessageRecord
import pw.binom.agentik.messageLog.MessageStore
import pw.binom.agentik.messageLog.MutableMessageStore
import pw.binom.agentik.messageLog.TokenStats
import kotlin.time.Instant
@@ -22,7 +22,7 @@ import kotlin.time.Instant
* любом KMP-таргете (включая iOS/native, где SQLite через Android driver
* недоступен).
*/
class InMemoryMessageStore : MessageStore {
class InMemoryMessageStore : MutableMessageStore {
private val byConv: MutableMap<String, MutableList<MessageRecord>> = mutableMapOf()
private val events = MutableSharedFlow<MessageEvent>(extraBufferCapacity = 64)
@@ -1,6 +1,6 @@
package pw.binom.agentik.storage.inmemory
import pw.binom.agentik.messageLog.MessageStore
import pw.binom.agentik.messageLog.MutableMessageStore
import pw.binom.agentik.messageStore.ConversationStore
import pw.binom.agentik.messageStore.ReflectionStore
import pw.binom.agentik.workingMemory.WorkingMemoryStore
@@ -22,7 +22,7 @@ import kotlin.time.Clock
object InMemoryStorage {
data class Bundle(
val conversationStore: ConversationStore,
val messageStore: MessageStore,
val messageStore: MutableMessageStore,
val workingMemoryStore: WorkingMemoryStore,
val reflectionStore: ReflectionStore,
)