feat(events): add JournalCompactedEvent + serialization registration
This commit is contained in:
@@ -0,0 +1,15 @@
|
|||||||
|
package com.correx.core.events.events
|
||||||
|
|
||||||
|
import com.correx.core.events.types.ArtifactId
|
||||||
|
import com.correx.core.events.types.SessionId
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
@SerialName("JournalCompacted")
|
||||||
|
data class JournalCompactedEvent(
|
||||||
|
val sessionId: SessionId,
|
||||||
|
val coversThroughSequence: Long,
|
||||||
|
val summaryArtifactId: ArtifactId,
|
||||||
|
val lowSalienceOmittedCount: Int,
|
||||||
|
) : EventPayload
|
||||||
@@ -14,6 +14,7 @@ import com.correx.core.events.events.SessionWorkspaceBoundEvent
|
|||||||
import com.correx.core.events.events.ContextTruncatedEvent
|
import com.correx.core.events.events.ContextTruncatedEvent
|
||||||
import com.correx.core.events.events.EventPayload
|
import com.correx.core.events.events.EventPayload
|
||||||
import com.correx.core.events.events.ExecutionPlanLockedEvent
|
import com.correx.core.events.events.ExecutionPlanLockedEvent
|
||||||
|
import com.correx.core.events.events.JournalCompactedEvent
|
||||||
import com.correx.core.events.events.FileWrittenEvent
|
import com.correx.core.events.events.FileWrittenEvent
|
||||||
import com.correx.core.events.events.L3MemoryRetrievedEvent
|
import com.correx.core.events.events.L3MemoryRetrievedEvent
|
||||||
import com.correx.core.events.events.InferenceCompletedEvent
|
import com.correx.core.events.events.InferenceCompletedEvent
|
||||||
@@ -93,6 +94,7 @@ val eventModule = SerializersModule {
|
|||||||
subclass(L3MemoryRetrievedEvent::class)
|
subclass(L3MemoryRetrievedEvent::class)
|
||||||
subclass(ContextTruncatedEvent::class)
|
subclass(ContextTruncatedEvent::class)
|
||||||
subclass(ExecutionPlanLockedEvent::class)
|
subclass(ExecutionPlanLockedEvent::class)
|
||||||
|
subclass(JournalCompactedEvent::class)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+26
@@ -0,0 +1,26 @@
|
|||||||
|
package com.correx.core.events.serialization
|
||||||
|
|
||||||
|
import com.correx.core.events.events.EventPayload
|
||||||
|
import com.correx.core.events.events.JournalCompactedEvent
|
||||||
|
import com.correx.core.events.types.ArtifactId
|
||||||
|
import com.correx.core.events.types.SessionId
|
||||||
|
import kotlin.test.Test
|
||||||
|
import kotlin.test.assertEquals
|
||||||
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
|
class JournalCompactedEventSerializationTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `JournalCompactedEvent round-trips as polymorphic EventPayload`() {
|
||||||
|
val sample: EventPayload = JournalCompactedEvent(
|
||||||
|
sessionId = SessionId("s1"),
|
||||||
|
coversThroughSequence = 42L,
|
||||||
|
summaryArtifactId = ArtifactId("summary-1"),
|
||||||
|
lowSalienceOmittedCount = 7,
|
||||||
|
)
|
||||||
|
val encoded = eventJson.encodeToString(EventPayload.serializer(), sample)
|
||||||
|
assertTrue(encoded.contains("\"type\":\"JournalCompacted\""), "SerialName must be present: $encoded")
|
||||||
|
val decoded = eventJson.decodeFromString(EventPayload.serializer(), encoded)
|
||||||
|
assertEquals(sample, decoded)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user