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,7 @@
|
||||
package com.correx.core.artifacts
|
||||
|
||||
import com.correx.core.artifacts.model.ArtifactRelationship
|
||||
import com.correx.core.events.events.ArtifactArchivedEvent
|
||||
import com.correx.core.events.events.ArtifactCreatedEvent
|
||||
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.events.StoredEvent
|
||||
@@ -25,23 +21,6 @@ class DefaultArtifactReducer : ArtifactReducer {
|
||||
transition(state, ArtifactLifecyclePhase.VALIDATING, ArtifactLifecyclePhase.CREATED)
|
||||
is ArtifactValidatedEvent ->
|
||||
transition(state, ArtifactLifecyclePhase.VALIDATED, ArtifactLifecyclePhase.VALIDATING)
|
||||
is ArtifactRejectedEvent ->
|
||||
transition(state, ArtifactLifecyclePhase.REJECTED, ArtifactLifecyclePhase.VALIDATING)
|
||||
is ArtifactSupersededEvent ->
|
||||
transition(state, ArtifactLifecyclePhase.SUPERSEDED, ArtifactLifecyclePhase.VALIDATED)
|
||||
is ArtifactArchivedEvent ->
|
||||
transitionFromAny(
|
||||
state,
|
||||
ArtifactLifecyclePhase.ARCHIVED,
|
||||
ArtifactLifecyclePhase.VALIDATED,
|
||||
ArtifactLifecyclePhase.REJECTED,
|
||||
)
|
||||
is ArtifactRelationshipAddedEvent -> {
|
||||
val rel = ArtifactRelationship(p.sourceId, p.targetId, p.relationshipType)
|
||||
Result.success(
|
||||
state.copy(lineage = state.lineage.copy(relationships = state.lineage.relationships + rel))
|
||||
)
|
||||
}
|
||||
else -> Result.success(state)
|
||||
}
|
||||
|
||||
@@ -59,19 +38,4 @@ class DefaultArtifactReducer : ArtifactReducer {
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private fun transitionFromAny(
|
||||
state: ArtifactState,
|
||||
to: ArtifactLifecyclePhase,
|
||||
vararg validFrom: ArtifactLifecyclePhase,
|
||||
): Result<ArtifactState> =
|
||||
if (state.phase in validFrom) {
|
||||
Result.success(state.copy(phase = to))
|
||||
} else {
|
||||
Result.failure(
|
||||
IllegalStateException(
|
||||
"Invalid artifact transition: ${state.phase} → $to (expected one of ${validFrom.toList()})"
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user