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:
+2
-1
@@ -61,7 +61,8 @@ class DefaultSessionOrchestrator(
|
||||
private val compactionService: JournalCompactionService? = null,
|
||||
artifactKindRegistry: ArtifactKindRegistry? = null,
|
||||
repoKnowledgeRetriever: RepoKnowledgeRetriever? = null,
|
||||
) : SessionOrchestrator(repositories, engines, artifactStore, decisionJournalRepository, artifactKindRegistry = artifactKindRegistry, repoKnowledgeRetriever = repoKnowledgeRetriever), ApprovalGateway {
|
||||
readyTaskCounter: ReadyTaskCounter? = null,
|
||||
) : SessionOrchestrator(repositories, engines, artifactStore, decisionJournalRepository, artifactKindRegistry = artifactKindRegistry, repoKnowledgeRetriever = repoKnowledgeRetriever, readyTaskCounter = readyTaskCounter), ApprovalGateway {
|
||||
override val tokenizer: Tokenizer? = tokenizer
|
||||
override val cancellations: ConcurrentHashMap<SessionId, AtomicBoolean> =
|
||||
ConcurrentHashMap<SessionId, AtomicBoolean>()
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.correx.core.kernel.orchestration
|
||||
|
||||
import com.correx.core.events.types.SessionId
|
||||
|
||||
/**
|
||||
* How many tasks are ready to claim for a session's project, read at transition-resolution time
|
||||
* (invariant #9: the observation is taken when the predicate runs). Implemented in apps/server over
|
||||
* the task projection — core:kernel stays decoupled from core:tasks. Null injection ⇒ count 0, so
|
||||
* the [com.correx.core.transitions.conditions.TasksReady] predicate is simply false.
|
||||
*/
|
||||
fun interface ReadyTaskCounter {
|
||||
fun count(sessionId: SessionId): Int
|
||||
}
|
||||
+2
@@ -187,6 +187,7 @@ abstract class SessionOrchestrator(
|
||||
private val decisionJournalRenderer: DecisionJournalRenderer = DecisionJournalRenderer(),
|
||||
private val artifactKindRegistry: ArtifactKindRegistry? = null,
|
||||
private val repoKnowledgeRetriever: RepoKnowledgeRetriever? = null,
|
||||
private val readyTaskCounter: ReadyTaskCounter? = null,
|
||||
) {
|
||||
private val log = LoggerFactory.getLogger(this::class.java)
|
||||
private val eventStore: EventStore = repositories.eventStore
|
||||
@@ -1856,6 +1857,7 @@ abstract class SessionOrchestrator(
|
||||
currentStage = currentStageId,
|
||||
artifacts = artifacts,
|
||||
artifactContent = artifactContent,
|
||||
readyTaskCount = readyTaskCounter?.count(sessionId) ?: 0,
|
||||
)
|
||||
return transitionResolver.resolve(graph, ctx)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
+1
@@ -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,
|
||||
)
|
||||
|
||||
+12
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user