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:
@@ -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")
|
||||
)
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user