feat(events): RefinementIterationEvent + orchestration state counter
This commit is contained in:
@@ -7,6 +7,7 @@ plugins {
|
||||
dependencies {
|
||||
testImplementation(project(":core:events"))
|
||||
testImplementation(project(":core:journal"))
|
||||
testImplementation(project(":core:kernel"))
|
||||
testImplementation(project(":core:sessions"))
|
||||
testImplementation(project(":core:transitions"))
|
||||
testImplementation(project(":core:validation"))
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
import com.correx.core.events.events.EventMetadata
|
||||
import com.correx.core.events.events.NewEvent
|
||||
import com.correx.core.events.events.RefinementIterationEvent
|
||||
import com.correx.core.events.types.EventId
|
||||
import com.correx.core.events.types.SessionId
|
||||
import com.correx.core.kernel.orchestration.DefaultOrchestrationReducer
|
||||
import com.correx.core.kernel.orchestration.OrchestrationProjector
|
||||
import com.correx.core.sessions.projections.replay.DefaultEventReplayer
|
||||
import com.correx.infrastructure.persistence.InMemoryEventStore
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.datetime.Clock
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class RefinementIterationReplayTest {
|
||||
|
||||
private fun meta(sessionId: SessionId, id: String) =
|
||||
EventMetadata(EventId(id), sessionId, Clock.System.now(), 1, null, null)
|
||||
|
||||
@Test
|
||||
fun `refinement iteration counter tracks last value per cycle`(): Unit = runBlocking {
|
||||
val sessionId = SessionId("s")
|
||||
val store = InMemoryEventStore()
|
||||
store.append(NewEvent(meta(sessionId, "i1"), RefinementIterationEvent(sessionId, "impl->review", 1, 3)))
|
||||
store.append(NewEvent(meta(sessionId, "i2"), RefinementIterationEvent(sessionId, "impl->review", 2, 3)))
|
||||
|
||||
val replayer = DefaultEventReplayer(
|
||||
store,
|
||||
OrchestrationProjector(DefaultOrchestrationReducer()),
|
||||
)
|
||||
val state = replayer.rebuild(sessionId)
|
||||
|
||||
assertEquals(2, state.refinementIterations["impl->review"])
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user