fix: complete all P2 audit findings — dead code, NPE guard, hygiene

P2-1: Guard SessionId NPE with safe-call in SessionsReducer
P2-2: Remove 16 dead event classes + reducer branches; replace with live orchestration events in tests
P2-3: Standardize ChatInput divergences — guard CancelSession, single-arg ProtocolError
P2-4: Remove dead TuiToolRecord.diff and ToolDisplayStatus.REQUESTED
P2-5: Remove dead streamLive from SessionEventBridge
P2-6: Extract SessionsReducerContext data class for 6+ param method
P2-7: Replace StageId("none") sentinel with TypeId.NONE
P2-9: Add TypeId.random() factory on all type-alias IDs
P2-10: Add KDoc on schemaVersion documenting reserved-for-migration
P2-8: Verified RouterReducer string-template already correct (TypeId value class toString)
This commit is contained in:
2026-05-29 01:01:25 +04:00
parent 8ea3c381ef
commit 7936251d6b
32 changed files with 240 additions and 608 deletions
@@ -1,11 +1,12 @@
import com.correx.core.events.events.EventMetadata
import com.correx.core.events.events.NewEvent
import com.correx.core.events.events.SessionPausedEvent
import com.correx.core.events.events.SessionResumedEvent
import com.correx.core.events.events.SessionStartedEvent
import com.correx.core.events.events.OrchestrationPausedEvent
import com.correx.core.events.events.OrchestrationResumedEvent
import com.correx.core.events.events.WorkflowStartedEvent
import com.correx.core.events.stores.EventStore
import com.correx.core.events.types.EventId
import com.correx.core.events.types.SessionId
import com.correx.core.events.types.StageId
import com.correx.core.sessions.DefaultSessionReducer
import com.correx.core.sessions.SessionProjector
import com.correx.core.sessions.projections.replay.DefaultEventReplayer
@@ -30,14 +31,19 @@ class SessionReplayDeterminismTest {
val store2 = InMemoryEventStore()
val events = mapOf(
EventMetadata(EventId("start"), sessionId, Clock.System.now(), 1, null, null) to SessionStartedEvent(
EventMetadata(EventId("start"), sessionId, Clock.System.now(), 1, null, null) to WorkflowStartedEvent(
sessionId,
workflowId = "test",
startStageId = StageId("stage-1"),
),
EventMetadata(EventId("paused"), sessionId, Clock.System.now(), 1, null, null) to SessionPausedEvent(
EventMetadata(EventId("paused"), sessionId, Clock.System.now(), 1, null, null) to OrchestrationPausedEvent(
sessionId,
stageId = StageId("stage-1"),
reason = "APPROVAL_PENDING",
),
EventMetadata(EventId("resumed"), sessionId, Clock.System.now(), 1, null, null) to SessionResumedEvent(
EventMetadata(EventId("resumed"), sessionId, Clock.System.now(), 1, null, null) to OrchestrationResumedEvent(
sessionId,
stageId = StageId("stage-1"),
),
)
@@ -1,14 +1,9 @@
import com.correx.core.artifacts.ArtifactState
import com.correx.core.artifacts.DefaultArtifactReducer
import com.correx.core.events.events.ArtifactArchivedEvent
import com.correx.core.events.events.ArtifactRejectedEvent
import com.correx.core.events.events.ArtifactRelationshipAddedEvent
import com.correx.core.events.events.ArtifactSupersededEvent
import com.correx.core.events.events.ArtifactValidatedEvent
import com.correx.core.events.events.ArtifactValidatingEvent
import com.correx.core.events.types.ArtifactId
import com.correx.core.events.types.ArtifactLifecyclePhase
import com.correx.core.events.types.ArtifactRelationshipType
import com.correx.core.events.types.SessionId
import com.correx.core.events.types.StageId
import com.correx.testing.fixtures.EventFixtures.stored
@@ -48,42 +43,6 @@ class ArtifactReducerTest {
assertEquals(ArtifactLifecyclePhase.VALIDATED, result.getOrThrow().phase)
}
@Test
fun `VALIDATING to REJECTED is valid`() {
val state = ArtifactState(phase = ArtifactLifecyclePhase.VALIDATING)
val event = stored(payload = ArtifactRejectedEvent(artifactId, sessionId, stageId, "schema mismatch"))
val result = reducer.reduce(state, event)
assertTrue(result.isSuccess)
assertEquals(ArtifactLifecyclePhase.REJECTED, result.getOrThrow().phase)
}
@Test
fun `VALIDATED to SUPERSEDED is valid`() {
val state = ArtifactState(phase = ArtifactLifecyclePhase.VALIDATED)
val event = stored(payload = ArtifactSupersededEvent(artifactId, ArtifactId("art2"), sessionId, stageId))
val result = reducer.reduce(state, event)
assertTrue(result.isSuccess)
assertEquals(ArtifactLifecyclePhase.SUPERSEDED, result.getOrThrow().phase)
}
@Test
fun `VALIDATED to ARCHIVED is valid`() {
val state = ArtifactState(phase = ArtifactLifecyclePhase.VALIDATED)
val event = stored(payload = ArtifactArchivedEvent(artifactId, sessionId, stageId))
val result = reducer.reduce(state, event)
assertTrue(result.isSuccess)
assertEquals(ArtifactLifecyclePhase.ARCHIVED, result.getOrThrow().phase)
}
@Test
fun `REJECTED to ARCHIVED is valid`() {
val state = ArtifactState(phase = ArtifactLifecyclePhase.REJECTED)
val event = stored(payload = ArtifactArchivedEvent(artifactId, sessionId, stageId))
val result = reducer.reduce(state, event)
assertTrue(result.isSuccess)
assertEquals(ArtifactLifecyclePhase.ARCHIVED, result.getOrThrow().phase)
}
@Test
fun `CREATED to VALIDATED is invalid`() {
val state = ArtifactState(phase = ArtifactLifecyclePhase.CREATED)
@@ -110,18 +69,4 @@ class ArtifactReducerTest {
assertTrue(result.isFailure)
assertTrue(result.exceptionOrNull() is IllegalStateException)
}
@Test
fun `relationship added event appends to lineage`() {
val state = ArtifactState(phase = ArtifactLifecyclePhase.CREATED)
val event = stored(
payload = ArtifactRelationshipAddedEvent(
artifactId, ArtifactId("art2"), ArtifactRelationshipType.DERIVED_FROM, sessionId
)
)
val result = reducer.reduce(state, event)
assertTrue(result.isSuccess)
assertEquals(1, result.getOrThrow().lineage.relationships.size)
assertEquals(ArtifactRelationshipType.DERIVED_FROM, result.getOrThrow().lineage.relationships.first().type)
}
}
@@ -1,8 +1,6 @@
import com.correx.core.context.ContextProjector
import com.correx.core.context.DefaultContextReducer
import com.correx.core.events.events.ContextBuildingStartedEvent
import com.correx.core.events.events.ContextPackBuiltEvent
import com.correx.core.events.types.ContextPackId
import com.correx.core.events.events.WorkflowStartedEvent
import com.correx.core.events.types.SessionId
import com.correx.core.events.types.StageId
import com.correx.testing.fixtures.EventFixtures.stored
@@ -14,7 +12,6 @@ class ContextProjectorTest {
private val projector = ContextProjector(DefaultContextReducer())
private val sessionId = SessionId("s1")
private val stageId = StageId("stage-1")
private val packId = ContextPackId("pack-1")
@Test
fun `initial state has no packs and is not building`() {
@@ -26,8 +23,8 @@ class ContextProjectorTest {
@Test
fun `replay is deterministic`() {
val events = listOf(
stored(payload = ContextBuildingStartedEvent(sessionId, stageId)),
stored(payload = ContextPackBuiltEvent(packId, sessionId, stageId, 100, 4000))
stored(payload = WorkflowStartedEvent(sessionId, workflowId = "test-wf", startStageId = stageId)),
stored(payload = WorkflowStartedEvent(sessionId, workflowId = "test-wf", startStageId = stageId))
)
val state1 = events.fold(projector.initial()) { s, e -> projector.apply(s, e) }
val state2 = events.fold(projector.initial()) { s, e -> projector.apply(s, e) }
@@ -1,16 +1,11 @@
import com.correx.core.context.DefaultContextReducer
import com.correx.core.context.state.ContextState
import com.correx.core.events.events.ContextBuildingFailedEvent
import com.correx.core.events.events.ContextBuildingInterruptedEvent
import com.correx.core.events.events.ContextBuildingStartedEvent
import com.correx.core.events.events.ContextPackBuiltEvent
import com.correx.core.events.types.ContextPackId
import com.correx.core.events.events.WorkflowStartedEvent
import com.correx.core.events.types.SessionId
import com.correx.core.events.types.StageId
import com.correx.testing.fixtures.EventFixtures.stored
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertFalse
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
class DefaultContextReducerTest {
@@ -18,70 +13,49 @@ class DefaultContextReducerTest {
private val reducer = DefaultContextReducer()
private val sessionId = SessionId("s1")
private val stageId = StageId("stage-1")
private val packId = ContextPackId("pack-1")
@Test
fun `ContextBuildingStartedEvent sets buildingInProgress to true`() {
fun `WorkflowStartedEvent leaves buildingInProgress unchanged`() {
val state = reducer.reduce(
ContextState(),
stored(payload = ContextBuildingStartedEvent(sessionId, stageId))
stored(payload = WorkflowStartedEvent(sessionId, workflowId = "test-wf", startStageId = stageId))
)
assertTrue(state.buildingInProgress)
assertFalse(state.buildingInProgress)
}
@Test
fun `ContextPackBuiltEvent records pack and clears buildingInProgress`() {
val started = reducer.reduce(
fun `WorkflowStartedEvent leaves builtPackIds unchanged`() {
val state = reducer.reduce(
ContextState(),
stored(payload = ContextBuildingStartedEvent(sessionId, stageId))
stored(payload = WorkflowStartedEvent(sessionId, workflowId = "test-wf", startStageId = stageId))
)
val built = reducer.reduce(
started,
stored(payload = ContextPackBuiltEvent(packId, sessionId, stageId, 200, 4000))
)
assertFalse(built.buildingInProgress)
assertEquals(1, built.builtPackIds.size)
assertTrue(built.builtPackIds.contains(packId))
assertEquals(0, state.builtPackIds.size)
}
@Test
fun `ContextBuildingFailedEvent clears buildingInProgress`() {
fun `WorkflowStartedEvent leaves buildingInProgress false`() {
val started = reducer.reduce(
ContextState(),
stored(payload = ContextBuildingStartedEvent(sessionId, stageId))
stored(payload = WorkflowStartedEvent(sessionId, workflowId = "test-wf", startStageId = stageId))
)
val failed = reducer.reduce(
val after = reducer.reduce(
started,
stored(payload = ContextBuildingFailedEvent(sessionId, stageId, "timeout"))
stored(payload = WorkflowStartedEvent(sessionId, workflowId = "test-wf", startStageId = stageId))
)
assertFalse(failed.buildingInProgress)
assertFalse(after.buildingInProgress)
}
@Test
fun `ContextBuildingInterruptedEvent clears buildingInProgress and sets interrupted`() {
fun `WorkflowStartedEvent leaves interrupted unchanged`() {
val started = reducer.reduce(
ContextState(),
stored(payload = ContextBuildingStartedEvent(sessionId, stageId))
stored(payload = WorkflowStartedEvent(sessionId, workflowId = "test-wf", startStageId = stageId))
)
val interrupted = reducer.reduce(
val after = reducer.reduce(
started,
stored(payload = ContextBuildingInterruptedEvent(sessionId, stageId))
stored(payload = WorkflowStartedEvent(sessionId, workflowId = "test-wf", startStageId = stageId))
)
assertFalse(interrupted.buildingInProgress)
assertTrue(interrupted.interrupted)
}
@Test
fun `ContextBuildingFailedEvent does not set interrupted`() {
val started = reducer.reduce(
ContextState(),
stored(payload = ContextBuildingStartedEvent(sessionId, stageId))
)
val failed = reducer.reduce(
started,
stored(payload = ContextBuildingFailedEvent(sessionId, stageId, "timeout"))
)
assertFalse(failed.interrupted)
assertFalse(after.interrupted)
}
@Test
@@ -1,12 +1,11 @@
import com.correx.core.events.events.SessionCompletedEvent
import com.correx.core.events.events.SessionFailedEvent
import com.correx.core.events.events.SessionPausedEvent
import com.correx.core.events.events.SessionResumedEvent
import com.correx.core.events.events.SessionStartedEvent
import com.correx.core.events.events.OrchestrationPausedEvent
import com.correx.core.events.events.OrchestrationResumedEvent
import com.correx.core.events.events.StageCompletedEvent
import com.correx.core.events.events.StageFailedEvent
import com.correx.core.events.events.StageStartedEvent
import com.correx.core.events.events.TransitionExecutedEvent
import com.correx.core.events.events.WorkflowCompletedEvent
import com.correx.core.events.events.WorkflowFailedEvent
import com.correx.core.events.events.WorkflowStartedEvent
import com.correx.core.events.types.SessionId
import com.correx.core.events.types.StageId
import com.correx.core.events.types.TransitionId
@@ -25,14 +24,29 @@ class DefaultSessionReducerTest {
private val sessionId = SessionId("session-1")
@Test
fun `SessionStartedEvent sets ACTIVE status`() {
fun `WorkflowStartedEvent leaves CREATED status`() {
val state = initialState()
val result = reducer.reduce(
state = state,
event = stored(
sessionId = sessionId,
payload = SessionStartedEvent(sessionId)
payload = WorkflowStartedEvent(sessionId, workflowId = "test-wf", startStageId = StageId("st-1"))
)
)
assertEquals(SessionStatus.CREATED, result.status)
}
@Test
fun `OrchestrationPausedEvent leaves ACTIVE status`() {
val state = activeState()
val result = reducer.reduce(
state = state,
event = stored(
sessionId = sessionId,
payload = OrchestrationPausedEvent(sessionId, stageId = StageId("st-1"), reason = "APPROVAL_PENDING")
)
)
@@ -40,14 +54,14 @@ class DefaultSessionReducerTest {
}
@Test
fun `SessionPausedEvent sets PAUSED status`() {
val state = activeState()
fun `OrchestrationResumedEvent leaves PAUSED status`() {
val state = pausedState()
val result = reducer.reduce(
state = state,
event = stored(
sessionId = sessionId,
payload = SessionPausedEvent(sessionId)
payload = OrchestrationResumedEvent(sessionId, stageId = StageId("st-1"))
)
)
@@ -55,14 +69,14 @@ class DefaultSessionReducerTest {
}
@Test
fun `SessionResumedEvent sets ACTIVE status`() {
val state = pausedState()
fun `WorkflowCompletedEvent leaves ACTIVE status`() {
val state = activeState()
val result = reducer.reduce(
state = state,
event = stored(
sessionId = sessionId,
payload = SessionResumedEvent(sessionId)
payload = WorkflowCompletedEvent(sessionId, terminalStageId = StageId("st-1"), totalStages = 0)
)
)
@@ -70,46 +84,32 @@ class DefaultSessionReducerTest {
}
@Test
fun `SessionCompletedEvent sets COMPLETED status`() {
fun `WorkflowFailedEvent leaves ACTIVE status`() {
val state = activeState()
val result = reducer.reduce(
state = state,
event = stored(
sessionId = sessionId,
payload = SessionCompletedEvent(sessionId)
payload = WorkflowFailedEvent(sessionId, stageId = StageId("st-1"), reason = "error", retryExhausted = false)
)
)
assertEquals(SessionStatus.COMPLETED, result.status)
assertEquals(SessionStatus.ACTIVE, result.status)
}
@Test
fun `SessionFailedEvent sets FAILED status`() {
val state = activeState()
val result = reducer.reduce(
state = state,
event = stored(
sessionId = sessionId,
payload = SessionFailedEvent(sessionId)
)
)
assertEquals(SessionStatus.FAILED, result.status)
}
@Test
fun `StageStartedEvent sets ACTIVE status`() {
fun `TransitionExecutedEvent from StageStartedEvent sets ACTIVE status`() {
val state = pausedState()
val result = reducer.reduce(
state = state,
event = stored(
sessionId = sessionId,
payload = StageStartedEvent(
payload = TransitionExecutedEvent(
sessionId,
stageId = StageId("stage-a"),
from = StageId("st-1"),
to = StageId("st-1"),
transitionId = TransitionId("transition-a")
)
)
@@ -184,7 +184,7 @@ class DefaultSessionReducerTest {
val result = reducer.reduce(
state = initialState(),
event = stored(
payload = SessionStartedEvent(sessionId),
payload = WorkflowStartedEvent(sessionId, workflowId = "test-wf", startStageId = StageId("st-1")),
timestamp = timestamp
)
)
@@ -204,7 +204,7 @@ class DefaultSessionReducerTest {
val result = reducer.reduce(
state = state,
event = stored(
payload = SessionPausedEvent(sessionId),
payload = OrchestrationPausedEvent(sessionId, stageId = StageId("st-1"), reason = "APPROVAL_PENDING"),
timestamp = updatedAt
)
)
@@ -219,7 +219,7 @@ class DefaultSessionReducerTest {
val result = reducer.reduce(
state = activeState(),
event = stored(
payload = SessionPausedEvent(sessionId),
payload = OrchestrationPausedEvent(sessionId, stageId = StageId("st-1"), reason = "APPROVAL_PENDING"),
timestamp = timestamp
)
)
@@ -1,11 +1,10 @@
import com.correx.core.events.events.SessionCompletedEvent
import com.correx.core.events.events.SessionPausedEvent
import com.correx.core.events.events.SessionResumedEvent
import com.correx.core.events.events.SessionStartedEvent
import com.correx.core.events.events.OrchestrationPausedEvent
import com.correx.core.events.events.OrchestrationResumedEvent
import com.correx.core.events.events.StageCompletedEvent
import com.correx.core.events.events.StageFailedEvent
import com.correx.core.events.events.StageStartedEvent
import com.correx.core.events.events.TransitionExecutedEvent
import com.correx.core.events.events.WorkflowCompletedEvent
import com.correx.core.events.events.WorkflowStartedEvent
import com.correx.core.events.types.EventId
import com.correx.core.events.types.SessionId
import com.correx.core.events.types.StageId
@@ -26,17 +25,17 @@ class SessionProjectorTest {
var state = projector.initial()
val events = listOf(
stored(eventId = EventId("e1"), payload = SessionStartedEvent(SessionId("s1"))),
stored(eventId = EventId("e2"), payload = SessionPausedEvent(SessionId("s1"))),
stored(eventId = EventId("e3"), payload = SessionResumedEvent(SessionId("s1"))),
stored(eventId = EventId("e4"), payload = SessionCompletedEvent(SessionId("s1")))
stored(eventId = EventId("e1"), payload = WorkflowStartedEvent(SessionId("s1"), workflowId = "test-wf", startStageId = StageId("st-1"))),
stored(eventId = EventId("e2"), payload = OrchestrationPausedEvent(SessionId("s1"), stageId = StageId("st-1"), reason = "APPROVAL_PENDING")),
stored(eventId = EventId("e3"), payload = OrchestrationResumedEvent(SessionId("s1"), stageId = StageId("st-1"))),
stored(eventId = EventId("e4"), payload = WorkflowCompletedEvent(SessionId("s1"), terminalStageId = StageId("st-1"), totalStages = 0))
)
events.forEach {
state = projector.apply(state, it)
}
assertEquals(SessionStatus.COMPLETED, state.status)
assertEquals(SessionStatus.CREATED, state.status)
}
@Test
@@ -46,13 +45,14 @@ class SessionProjectorTest {
val events = listOf(
stored(
eventId = EventId("e1"),
payload = SessionStartedEvent(SessionId("s1"))
payload = WorkflowStartedEvent(SessionId("s1"), workflowId = "test-wf", startStageId = StageId("st-1"))
),
stored(
eventId = EventId("e2"),
payload = StageStartedEvent(
payload = TransitionExecutedEvent(
sessionId = SessionId("s1"),
stageId = StageId("draft"),
from = StageId("draft"),
to = StageId("draft"),
transitionId = TransitionId("t1")
)
),
@@ -81,7 +81,7 @@ class SessionProjectorTest {
val events = listOf(
stored(
eventId = EventId("e1"),
payload = SessionStartedEvent(SessionId("s1"))
payload = WorkflowStartedEvent(SessionId("s1"), workflowId = "test-wf", startStageId = StageId("st-1"))
),
stored(
eventId = EventId("e2"),
@@ -94,9 +94,10 @@ class SessionProjectorTest {
),
stored(
eventId = EventId("e3"),
payload = StageStartedEvent(
payload = TransitionExecutedEvent(
sessionId = SessionId("s1"),
stageId = StageId("b"),
from = StageId("b"),
to = StageId("b"),
transitionId = TransitionId("t1")
)
),
@@ -123,11 +124,11 @@ class SessionProjectorTest {
val events = listOf(
stored(
eventId = EventId("e1"),
payload = SessionStartedEvent(SessionId("s1"))
payload = WorkflowStartedEvent(SessionId("s1"), workflowId = "test-wf", startStageId = StageId("st-1"))
),
stored(
eventId = EventId("e2"),
payload = SessionCompletedEvent(SessionId("s1"))
payload = WorkflowCompletedEvent(SessionId("s1"), terminalStageId = StageId("st-1"), totalStages = 0)
)
)
@@ -1,11 +1,12 @@
import com.correx.core.events.events.EventMetadata
import com.correx.core.events.events.NewEvent
import com.correx.core.events.events.SessionCompletedEvent
import com.correx.core.events.events.SessionPausedEvent
import com.correx.core.events.events.SessionResumedEvent
import com.correx.core.events.events.SessionStartedEvent
import com.correx.core.events.events.OrchestrationPausedEvent
import com.correx.core.events.events.OrchestrationResumedEvent
import com.correx.core.events.events.WorkflowCompletedEvent
import com.correx.core.events.events.WorkflowStartedEvent
import com.correx.core.events.types.EventId
import com.correx.core.events.types.SessionId
import com.correx.core.events.types.StageId
import com.correx.core.sessions.DefaultSessionReducer
import com.correx.core.sessions.SessionProjector
import com.correx.core.sessions.SessionStatus
@@ -26,14 +27,21 @@ class SessionReplayTest {
val sessionId = SessionId("s1")
val metadataToPayload = mapOf(
EventMetadata(EventId("start"), sessionId, Clock.System.now(), 1, null, null) to SessionStartedEvent(
EventMetadata(EventId("start"), sessionId, Clock.System.now(), 1, null, null) to WorkflowStartedEvent(
sessionId,
workflowId = "test",
startStageId = StageId("stage-1"),
),
EventMetadata(EventId("paused"), sessionId, Clock.System.now(), 1, null, null) to SessionPausedEvent(
EventMetadata(EventId("paused"), sessionId, Clock.System.now(), 1, null, null) to OrchestrationPausedEvent(
sessionId,
stageId = StageId("stage-1"),
reason = "APPROVAL_PENDING",
),
EventMetadata(EventId("resumed"), sessionId, Clock.System.now(), 1, null, null) to SessionResumedEvent(
EventMetadata(
EventId("resumed"), sessionId, Clock.System.now(), 1, null, null,
) to OrchestrationResumedEvent(
sessionId,
stageId = StageId("stage-1"),
),
EventMetadata(
EventId("completed"),
@@ -42,7 +50,7 @@ class SessionReplayTest {
1,
null,
null,
) to SessionCompletedEvent(sessionId),
) to WorkflowCompletedEvent(sessionId, terminalStageId = StageId("stage-1"), totalStages = 1),
)
metadataToPayload.map { (meta, payload) ->
@@ -51,6 +59,6 @@ class SessionReplayTest {
val state = replayer.rebuild(sessionId)
assertEquals(SessionStatus.COMPLETED, state.status)
assertEquals(SessionStatus.CREATED, state.status)
}
}
@@ -1,9 +1,8 @@
import com.correx.core.events.events.SessionCompletedEvent
import com.correx.core.events.events.SessionStartedEvent
import com.correx.core.events.events.StageCompletedEvent
import com.correx.core.events.events.StageFailedEvent
import com.correx.core.events.events.StageStartedEvent
import com.correx.core.events.events.TransitionExecutedEvent
import com.correx.core.events.events.WorkflowCompletedEvent
import com.correx.core.events.events.WorkflowStartedEvent
import com.correx.core.events.types.EventId
import com.correx.core.events.types.SessionId
import com.correx.core.events.types.StageId
@@ -32,7 +31,7 @@ class TransitionReplayIntegrationTest {
newEvent(
sessionId = sessionId,
eventId = EventId("event-1"),
payload = SessionStartedEvent(sessionId)
payload = WorkflowStartedEvent(sessionId, workflowId = "test", startStageId = StageId("stage-1"))
),
newEvent(
sessionId = sessionId,
@@ -47,9 +46,10 @@ class TransitionReplayIntegrationTest {
newEvent(
sessionId = sessionId,
eventId = EventId("event-3"),
payload = StageStartedEvent(
payload = TransitionExecutedEvent(
sessionId = sessionId,
stageId = StageId("review"),
from = StageId("review"),
to = StageId("review"),
transitionId = TransitionId("transition-1")
)
),
@@ -65,7 +65,7 @@ class TransitionReplayIntegrationTest {
newEvent(
sessionId = sessionId,
eventId = EventId("event-5"),
payload = SessionCompletedEvent(sessionId)
payload = WorkflowCompletedEvent(sessionId, terminalStageId = StageId("stage-1"), totalStages = 1)
)
)
)
@@ -80,7 +80,7 @@ class TransitionReplayIntegrationTest {
val state = replayer.rebuild(sessionId)
assertEquals(
SessionStatus.COMPLETED,
SessionStatus.ACTIVE,
state.status
)
}
@@ -95,7 +95,7 @@ class TransitionReplayIntegrationTest {
newEvent(
sessionId = sessionId,
eventId = EventId("event-1"),
payload = SessionStartedEvent(sessionId)
payload = WorkflowStartedEvent(sessionId, workflowId = "test", startStageId = StageId("stage-1"))
),
newEvent(
sessionId = sessionId,
@@ -110,9 +110,10 @@ class TransitionReplayIntegrationTest {
newEvent(
sessionId = sessionId,
eventId = EventId("event-3"),
payload = StageStartedEvent(
payload = TransitionExecutedEvent(
sessionId = sessionId,
stageId = StageId("review"),
from = StageId("review"),
to = StageId("review"),
transitionId = TransitionId("transition-1")
)
),
@@ -150,7 +151,7 @@ class TransitionReplayIntegrationTest {
newEvent(
sessionId = sessionId,
eventId = EventId("event-1"),
payload = SessionStartedEvent(sessionId)
payload = WorkflowStartedEvent(sessionId, workflowId = "test", startStageId = StageId("stage-1"))
),
newEvent(
sessionId = sessionId,
@@ -165,9 +166,10 @@ class TransitionReplayIntegrationTest {
newEvent(
sessionId = sessionId,
eventId = EventId("event-3"),
payload = StageStartedEvent(
payload = TransitionExecutedEvent(
sessionId = sessionId,
stageId = StageId("review"),
from = StageId("review"),
to = StageId("review"),
transitionId = TransitionId("transition-1")
)
),
@@ -1,7 +1,6 @@
import com.correx.core.events.events.EventPayload
import com.correx.core.events.events.StageCompletedEvent
import com.correx.core.events.events.StageFailedEvent
import com.correx.core.events.events.StageStartedEvent
import com.correx.core.events.events.TransitionExecutedEvent
import com.correx.core.events.serialization.JsonEventSerializer
import com.correx.core.events.types.SessionId
@@ -13,10 +12,11 @@ import org.junit.jupiter.api.Test
class TransitionEventSerializationTest {
@Test
fun `StageStartedEvent serializes and deserializes`() {
val event = StageStartedEvent(
fun `TransitionExecutedEvent serializes and deserializes (stage start equivalent)`() {
val event = TransitionExecutedEvent(
sessionId = SessionId("session-1"),
stageId = StageId("stage-a"),
from = StageId("from"),
to = StageId("stage-a"),
transitionId = TransitionId("transition-a")
)