feat(server-02): promote EventStore to global-sequence store with subscribeAll

StoredEvent gains sessionSequence: Long (per-session monotonic); existing
sequence field becomes the global monotonic cursor across the entire store.
SqliteEventStore allocates both counters inside the same BEGIN IMMEDIATE
transaction and emits to a global MutableSharedFlow after commit.
InMemoryEventStore mirrors this with an AtomicLong global counter and a
suspend-on-overflow SharedFlow. EventStore interface gains subscribeAll()
and lastGlobalSequence(). Contract tests updated and extended to cover
global-sequence and cross-session subscribeAll invariants.
This commit is contained in:
2026-05-24 22:23:43 +04:00
parent 0cfb784187
commit 70420083ac
8 changed files with 184 additions and 77 deletions
@@ -34,6 +34,7 @@ object EventFixtures {
payload: EventPayload = ToolInvokedEvent("write"),
sessionId: SessionId = SessionId("s1"),
sequence: Long = 1L,
sessionSequence: Long = sequence,
timestamp: Instant = Instant.parse("2026-01-01T00:00:00Z")
): StoredEvent {
return StoredEvent(
@@ -46,8 +47,8 @@ object EventFixtures {
correlationId = null
),
sequence = sequence,
sessionSequence = sessionSequence,
payload = payload
)
}
}