chore(clean up): remove unused imports, unnecessary object impls, concurrency/coroutine issues, trailing commas, etc.
This commit is contained in:
+11
-14
@@ -31,20 +31,22 @@ class DefaultInferenceRouterTest {
|
||||
override fun register(provider: InferenceProvider) = Unit
|
||||
override fun resolve(capability: ModelCapability) =
|
||||
providers.filter { p -> p.capabilities().any { it.capability == capability } }
|
||||
|
||||
override fun listAll() = providers.toList()
|
||||
override suspend fun healthCheckAll() = providers.associate { it.id to ProviderHealth.Healthy }
|
||||
}
|
||||
|
||||
private fun firstStrategy(): RoutingStrategy =
|
||||
object : RoutingStrategy {
|
||||
override fun select(candidates: List<InferenceProvider>, requiredCapabilities: Set<ModelCapability>) =
|
||||
candidates.firstOrNull() ?: throw NoEligibleProviderException(StageId("?"), emptySet())
|
||||
RoutingStrategy { candidates, _ ->
|
||||
candidates.firstOrNull() ?: throw NoEligibleProviderException(StageId("?"), emptySet())
|
||||
}
|
||||
|
||||
private fun throwingStrategy(): RoutingStrategy =
|
||||
object : RoutingStrategy {
|
||||
override fun select(candidates: List<InferenceProvider>, requiredCapabilities: Set<ModelCapability>) =
|
||||
throw NoEligibleProviderException(StageId("?"), requiredCapabilities)
|
||||
RoutingStrategy { _, requiredCapabilities ->
|
||||
throw NoEligibleProviderException(
|
||||
StageId("?"),
|
||||
requiredCapabilities,
|
||||
)
|
||||
}
|
||||
|
||||
// ── capability matching ───────────────────────────────────────────────────
|
||||
@@ -60,14 +62,9 @@ class DefaultInferenceRouterTest {
|
||||
fun `deduplicates providers that satisfy multiple required capabilities`(): Unit = runBlocking {
|
||||
val p = provider("a", ModelCapability.General, ModelCapability.Coding)
|
||||
val selected = mutableListOf<InferenceProvider>()
|
||||
val captureStrategy = object : RoutingStrategy {
|
||||
override fun select(
|
||||
candidates: List<InferenceProvider>,
|
||||
requiredCapabilities: Set<ModelCapability>,
|
||||
): InferenceProvider {
|
||||
selected.addAll(candidates)
|
||||
return candidates.first()
|
||||
}
|
||||
val captureStrategy = RoutingStrategy { candidates, _ ->
|
||||
selected.addAll(candidates)
|
||||
candidates.first()
|
||||
}
|
||||
val router = DefaultInferenceRouter(
|
||||
registryOf(p),
|
||||
|
||||
+3
-4
@@ -7,7 +7,6 @@ import com.correx.core.events.types.SessionId
|
||||
import com.correx.testing.contracts.utils.ConcurrencyRunner
|
||||
import com.correx.testing.fixtures.EventFixtures
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.yield
|
||||
@@ -39,7 +38,7 @@ abstract class EventStoreContractTest {
|
||||
|
||||
store.append(e)
|
||||
assertThrows<Exception> {
|
||||
runBlocking { store.append(e) }
|
||||
store.append(e)
|
||||
}
|
||||
Assertions.assertEquals(1, store.read(SessionId("s1")).size)
|
||||
}
|
||||
@@ -75,7 +74,7 @@ abstract class EventStoreContractTest {
|
||||
ConcurrencyRunner.run(20, 100) { t, i ->
|
||||
runBlocking {
|
||||
store.append(
|
||||
EventFixtures.newEvent(EventId("e-$i-$t"), SessionId("s1"))
|
||||
EventFixtures.newEvent(EventId("e-$i-$t"), SessionId("s1")),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -152,7 +151,7 @@ abstract class EventStoreContractTest {
|
||||
store.append(EventFixtures.newEvent(EventId("a-$t-$i"), SessionId("s1")))
|
||||
} else {
|
||||
store.appendAll(
|
||||
listOf(EventFixtures.newEvent(EventId("b-$t-$i"), SessionId("s1")))
|
||||
listOf(EventFixtures.newEvent(EventId("b-$t-$i"), SessionId("s1"))),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import com.correx.core.events.events.EventMetadata
|
||||
import com.correx.core.events.events.EventPayload
|
||||
import com.correx.core.events.events.NewEvent
|
||||
import com.correx.core.events.events.SessionPausedEvent
|
||||
import com.correx.core.events.events.SessionResumedEvent
|
||||
@@ -20,7 +19,7 @@ class SessionReplayDeterminismTest {
|
||||
|
||||
private fun build(store: EventStore) = DefaultEventReplayer(
|
||||
store,
|
||||
SessionProjector(DefaultSessionReducer())
|
||||
SessionProjector(DefaultSessionReducer()),
|
||||
)
|
||||
|
||||
@Test
|
||||
@@ -30,16 +29,16 @@ class SessionReplayDeterminismTest {
|
||||
val store1 = InMemoryEventStore()
|
||||
val store2 = InMemoryEventStore()
|
||||
|
||||
val events = mapOf<EventMetadata, EventPayload>(
|
||||
val events = mapOf(
|
||||
EventMetadata(EventId("start"), sessionId, Clock.System.now(), 1, null, null) to SessionStartedEvent(
|
||||
sessionId
|
||||
sessionId,
|
||||
),
|
||||
EventMetadata(EventId("paused"), sessionId, Clock.System.now(), 1, null, null) to SessionPausedEvent(
|
||||
sessionId
|
||||
sessionId,
|
||||
),
|
||||
EventMetadata(EventId("resumed"), sessionId, Clock.System.now(), 1, null, null) to SessionResumedEvent(
|
||||
sessionId
|
||||
)
|
||||
sessionId,
|
||||
),
|
||||
)
|
||||
|
||||
events.forEach { (meta, payload) ->
|
||||
|
||||
+1
-7
@@ -2,10 +2,8 @@ package com.correx.testing.fixtures.transitions
|
||||
|
||||
import com.correx.core.events.types.StageId
|
||||
import com.correx.core.events.types.TransitionId
|
||||
import com.correx.core.transitions.evaluation.EvaluationContext
|
||||
import com.correx.core.transitions.evaluation.TransitionConditionEvaluator
|
||||
import com.correx.core.transitions.graph.StageConfig
|
||||
import com.correx.core.transitions.graph.TransitionCondition
|
||||
import com.correx.core.transitions.graph.TransitionEdge
|
||||
import com.correx.core.transitions.graph.WorkflowGraph
|
||||
import com.correx.core.transitions.resolution.DefaultTransitionResolver
|
||||
@@ -15,11 +13,7 @@ import com.correx.testing.fixtures.WorkflowFixtures
|
||||
object TransitionFixtures {
|
||||
|
||||
fun alwaysTrueEvaluator(): TransitionConditionEvaluator {
|
||||
return object : TransitionConditionEvaluator {
|
||||
override fun evaluate(condition: TransitionCondition, context: EvaluationContext): Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return TransitionConditionEvaluator { _, _ -> true }
|
||||
}
|
||||
|
||||
fun simpleResolver(): TransitionResolver {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import com.correx.core.events.events.EventMetadata
|
||||
import com.correx.core.events.events.EventPayload
|
||||
import com.correx.core.events.events.NewEvent
|
||||
import com.correx.core.events.events.SessionCompletedEvent
|
||||
import com.correx.core.events.events.SessionPausedEvent
|
||||
@@ -26,15 +25,15 @@ class SessionReplayTest {
|
||||
fun `rebuild session from event stream`(): Unit = kotlinx.coroutines.runBlocking {
|
||||
val sessionId = SessionId("s1")
|
||||
|
||||
val metadataToPayload = mapOf<EventMetadata, EventPayload>(
|
||||
val metadataToPayload = mapOf(
|
||||
EventMetadata(EventId("start"), sessionId, Clock.System.now(), 1, null, null) to SessionStartedEvent(
|
||||
sessionId
|
||||
sessionId,
|
||||
),
|
||||
EventMetadata(EventId("paused"), sessionId, Clock.System.now(), 1, null, null) to SessionPausedEvent(
|
||||
sessionId
|
||||
sessionId,
|
||||
),
|
||||
EventMetadata(EventId("resumed"), sessionId, Clock.System.now(), 1, null, null) to SessionResumedEvent(
|
||||
sessionId
|
||||
sessionId,
|
||||
),
|
||||
EventMetadata(
|
||||
EventId("completed"),
|
||||
@@ -42,7 +41,7 @@ class SessionReplayTest {
|
||||
Clock.System.now(),
|
||||
1,
|
||||
null,
|
||||
null
|
||||
null,
|
||||
) to SessionCompletedEvent(sessionId),
|
||||
)
|
||||
|
||||
|
||||
@@ -16,14 +16,7 @@ import org.junit.jupiter.api.assertInstanceOf
|
||||
|
||||
class DefaultTransitionResolverTest {
|
||||
|
||||
private val evaluator = object : TransitionConditionEvaluator {
|
||||
override fun evaluate(
|
||||
condition: TransitionCondition,
|
||||
context: EvaluationContext,
|
||||
): Boolean {
|
||||
return condition.evaluate(context)
|
||||
}
|
||||
}
|
||||
private val evaluator = TransitionConditionEvaluator { condition, context -> condition.evaluate(context) }
|
||||
|
||||
private val resolver: TransitionResolver = DefaultTransitionResolver(evaluator)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user