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