feat(kernel): inject decision journal into stage context + wire repository
This commit is contained in:
@@ -17,6 +17,7 @@ dependencies {
|
||||
implementation project(':core:artifacts-store')
|
||||
implementation project(':core:risk')
|
||||
implementation project(':core:toolintent')
|
||||
implementation(project(":core:journal"))
|
||||
implementation "org.slf4j:slf4j-api:2.0.16"
|
||||
}
|
||||
tasks.named("koverVerify").configure { enabled = false }
|
||||
|
||||
+3
-1
@@ -4,6 +4,7 @@ import com.correx.core.approvals.ApprovalOutcome
|
||||
import com.correx.core.approvals.ApprovalStatus
|
||||
import com.correx.core.approvals.model.ApprovalDecision
|
||||
import com.correx.core.inference.Tokenizer
|
||||
import com.correx.core.journal.DefaultDecisionJournalRepository
|
||||
import com.correx.core.artifacts.ArtifactState
|
||||
import com.correx.core.artifactstore.ArtifactStore
|
||||
import com.correx.core.events.events.ApprovalDecisionResolvedEvent
|
||||
@@ -40,7 +41,8 @@ class DefaultSessionOrchestrator(
|
||||
private val retryCoordinator: RetryCoordinator,
|
||||
artifactStore: ArtifactStore,
|
||||
tokenizer: Tokenizer? = null,
|
||||
) : SessionOrchestrator(repositories, engines, artifactStore), ApprovalGateway {
|
||||
decisionJournalRepository: DefaultDecisionJournalRepository,
|
||||
) : SessionOrchestrator(repositories, engines, artifactStore, decisionJournalRepository), ApprovalGateway {
|
||||
override val tokenizer: Tokenizer? = tokenizer
|
||||
override val cancellations: ConcurrentHashMap<SessionId, AtomicBoolean> =
|
||||
ConcurrentHashMap<SessionId, AtomicBoolean>()
|
||||
|
||||
@@ -2,6 +2,9 @@ package com.correx.core.kernel.orchestration
|
||||
|
||||
import com.correx.core.approvals.domain.NoOpApprovalEngine
|
||||
import com.correx.core.artifactstore.ArtifactStore
|
||||
import com.correx.core.journal.DefaultDecisionJournalRepository
|
||||
import com.correx.core.journal.model.DecisionJournalState
|
||||
import com.correx.core.sessions.projections.replay.EventReplayer
|
||||
import com.correx.core.context.model.ContextPack
|
||||
import com.correx.core.events.events.ArtifactValidatedEvent
|
||||
import com.correx.core.events.events.ArtifactValidatingEvent
|
||||
@@ -58,6 +61,9 @@ class ReplayOrchestrator(
|
||||
repositories,
|
||||
engines.copy(approvalEngine = NoOpApprovalEngine(), riskAssessor = NoOpRiskAssessor()),
|
||||
artifactStore,
|
||||
DefaultDecisionJournalRepository(object : EventReplayer<DecisionJournalState> {
|
||||
override fun rebuild(sessionId: SessionId) = DecisionJournalState()
|
||||
}),
|
||||
) {
|
||||
private val replayProvider = ReplayInferenceProvider(repositories.eventStore)
|
||||
|
||||
|
||||
+19
-1
@@ -107,6 +107,8 @@ import kotlinx.datetime.Clock
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import com.correx.core.journal.DecisionJournalRenderer
|
||||
import com.correx.core.journal.DefaultDecisionJournalRepository
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.util.*
|
||||
import java.util.concurrent.*
|
||||
@@ -129,6 +131,8 @@ abstract class SessionOrchestrator(
|
||||
repositories: OrchestratorRepositories,
|
||||
engines: OrchestratorEngines,
|
||||
private val artifactStore: ArtifactStore,
|
||||
private val decisionJournalRepository: DefaultDecisionJournalRepository,
|
||||
private val decisionJournalRenderer: DecisionJournalRenderer = DecisionJournalRenderer(),
|
||||
) {
|
||||
private val log = LoggerFactory.getLogger(this::class.java)
|
||||
private val eventStore: EventStore = repositories.eventStore
|
||||
@@ -285,7 +289,21 @@ abstract class SessionOrchestrator(
|
||||
// from currentContext.layers (a Map grouped by layer) would scramble turn order
|
||||
// across rounds; instead we grow our own ordered list and let the builder restamp
|
||||
// ordinals from it each round.
|
||||
var accumulatedEntries = systemPrompt + schemaEntries + promptEntries + steeringEntries
|
||||
val journalText = decisionJournalRenderer.render(
|
||||
decisionJournalRepository.getJournal(sessionId),
|
||||
)
|
||||
val journalEntries = if (journalText.isBlank()) emptyList() else listOf(
|
||||
ContextEntry(
|
||||
id = ContextEntryId(UUID.randomUUID().toString()),
|
||||
layer = ContextLayer.L0,
|
||||
content = journalText,
|
||||
sourceType = "decisionJournal",
|
||||
sourceId = "decision-journal",
|
||||
tokenEstimate = journalText.length / 4,
|
||||
role = EntryRole.SYSTEM,
|
||||
),
|
||||
)
|
||||
var accumulatedEntries = systemPrompt + journalEntries + schemaEntries + promptEntries + steeringEntries
|
||||
val contextPack = contextPackBuilder.build(
|
||||
id = ContextPackId(UUID.randomUUID().toString()),
|
||||
sessionId = sessionId,
|
||||
|
||||
Reference in New Issue
Block a user