feat(transitions): tasks_ready predicate for execution loop

New TasksReady condition driven by EvaluationContext.readyTaskCount,
fed at resolve time via a kernel-declared ReadyTaskCounter interface
implemented in apps/server over TaskService (keeps core:kernel
decoupled from core:tasks). Loops a graph while ready>0, exits at 0.
This commit is contained in:
2026-06-29 00:45:33 +04:00
parent d26f20c316
commit c1e4c7b25e
14 changed files with 164 additions and 1 deletions
@@ -0,0 +1,9 @@
package com.correx.core.transitions.conditions
import com.correx.core.transitions.evaluation.EvaluationContext
import com.correx.core.transitions.graph.TransitionCondition
/** True while the session's project still has tasks ready to claim — the execution loop's gate. */
object TasksReady : TransitionCondition {
override fun evaluate(context: EvaluationContext) = context.readyTaskCount > 0
}
@@ -11,4 +11,5 @@ data class EvaluationContext(
val artifacts: Map<ArtifactId, ArtifactState> = emptyMap(),
val variables: Map<String, String> = emptyMap(),
val artifactContent: Map<ArtifactId, String> = emptyMap(),
val readyTaskCount: Int = 0,
)
@@ -30,6 +30,18 @@ class TransitionConditionTest {
assertTrue(AlwaysTrue.evaluate(baseContext))
}
// TasksReady
@Test
fun `TasksReady true when ready count positive`() {
assertTrue(TasksReady.evaluate(baseContext.copy(readyTaskCount = 1)))
}
@Test
fun `TasksReady false when no ready tasks`() {
assertFalse(TasksReady.evaluate(baseContext))
}
// ArtifactPresent
@Test