Teaches AI agents to write idiomatic Kotlin (data classes, val, scope fns, Kotest) AND to make the right stack choices on JVM: Kotlin 2.3 + JDK 21 + Gradle Kotlin DSL, Ktor for HTTP, kotlinx-coroutines, DJL for ML inference, JavaCV for vision, Koog for AI agent orchestration.
95
95%
Does it follow best practices?
Impact
95%
1.23xAverage score across 10 eval scenarios
Passed
No known issues
AtomicReference<T?> for new values — while (true) { val x = ref.get(); if (x == null) { delay(20); continue }; ... } — is Java-in-Kotlinj.u.c.atomic is a lock-free primitive sized for CAS-heavy contention; the busy-poll loop is asking it to do single-writer / many-reader fan-out, which is the wrong shapedelay-based poll loop also burns timer ticks and adds latency proportional to the poll interval, neither of which a reactive signal should carryMutableStateFlow<T?> (kotlinx.coroutines.flow.MutableStateFlow) initialized to null when null means "no value yet" — the 1:1 replacement for AtomicReference<T?>MutableStateFlow<T> with that default and drop the filterNotNull() from the readerlatest.filterNotNull().collect { ... } — suspends until the next non-null value, zero CPU when idle, no polling looplatest.collect { ... } — same suspend semantics, no filterNotNull() neededlatest.value = newValue — reads naturally, no .set(...) / .get() ceremonyAtomicReference Is Still RightcompareAndSet, getAndUpdate, etc. — to coordinate across non-coroutine threadswhile (true) { val x = ref.get(); if (x == null) delay(...); continue }, replace the atomic with MutableStateFlow and the loop with .collectdo { ... } while (state == ...) busy-poll guarding against an "is the value ready yet?" condition — that's a Flow or a Channel.receive(), not an atomic and a sleeprules/coroutines-for-concurrency.mdAtomicReference<T?> + polling delay loop as a state-change signalwhile (true) { delay(...) } reader in a coroutine — coroutines are built to avoid this@Volatile var + polling — same pattern, different decoration