refactor(event-store): split into EventStore (read-only) + MutableEventStore
ci / JVM build + tests (push) Failing after 1m49s

Разделяет интерфейс на read-only (EventStore) и write (MutableEventStore).

EventStore (read-only, для consumer'ов):
  - events(after: Instant?): Flow<CommonEvent>
  - earliestEventDate(): Instant
  - close()

MutableEventStore : EventStore (для producer'ов):
  - + append(event: CommonEvent)
  - suspend, не идемпотентный, может быть silently evicted

Зачем:
  - Consumer'ы (server SSE, admin dashboard, parent agents) принимают
    EventStore — compile-time гарантия что они не могут писать в store.
  - Producer'ы (ChatAgent, sub-agents, A2A-bridge) принимают MutableEventStore.
  - Тесты могут использовать EventStore без опасности случайной модификации.

Миграция:
  - :event-store пока без implementations, поэтому ничего не сломалось.
  - Когда добавим InMemoryEventStore — он будет реализовывать оба
    (MutableEventStore = EventStore + append). Подписки получают только
    read-only projection через приведение типа.

Также: импорт обновлён AllEvent → CommonEvent (по rename в :proto).
This commit is contained in:
2026-09-20 15:46:59 +03:00
parent 1f85cde1b8
commit e2f0e434d1
7 changed files with 70 additions and 39 deletions
@@ -59,7 +59,7 @@ public interface Agent {
*
* Cold (no replay). For catchup use EventStore.
*/
fun allEvents(after: Instant): Flow<AllEvent>
fun allEvents(after: Instant): Flow<CommonEvent>
companion object {
@@ -10,7 +10,7 @@ import kotlinx.serialization.Serializable
* Useful for admin dashboards, debug tools, parent agents: one subscription
* instead of N+1. For regular UI use two separate SSE feeds
* ([AgentEvent] via /events and [Event] via /conversations/{id}/events);
* [AllEvent] is for those who need everything in one place.
* [CommonEvent] is for those who need everything in one place.
*
* Server endpoint: GET /events/all (SSE), or replay via EventStore.
*
@@ -19,7 +19,7 @@ import kotlinx.serialization.Serializable
* only.
*/
@Serializable
sealed interface AllEvent {
sealed interface CommonEvent {
val date: Instant
@Serializable
@@ -27,7 +27,7 @@ sealed interface AllEvent {
data class Agent(
override val date: Instant,
val event: AgentEvent,
) : AllEvent
) : CommonEvent
@Serializable
@SerialName("conversation")
@@ -35,5 +35,5 @@ sealed interface AllEvent {
override val date: Instant,
val conversationId: String,
val event: Event,
) : AllEvent
) : CommonEvent
}