feat(context): pin decisionJournal source type through compression

This commit is contained in:
2026-06-04 00:36:12 +04:00
parent c21bbda85f
commit bd4dd91bf1
2 changed files with 43 additions and 1 deletions
@@ -14,7 +14,7 @@ class DefaultContextPackBuilder(
private val compressor: ContextCompressor private val compressor: ContextCompressor
) : ContextPackBuilder { ) : ContextPackBuilder {
private val neverDropSourceTypes = setOf("steeringNote", "eventHistory") private val neverDropSourceTypes = setOf("steeringNote", "eventHistory", "decisionJournal")
override fun build( override fun build(
id: ContextPackId, id: ContextPackId,
@@ -78,6 +78,7 @@ class DefaultContextPackBuilder(
"artifact" -> CompressionStrategy.Artifact "artifact" -> CompressionStrategy.Artifact
"steeringNote" -> CompressionStrategy.SteeringNote "steeringNote" -> CompressionStrategy.SteeringNote
"eventHistory" -> CompressionStrategy.EventHistory "eventHistory" -> CompressionStrategy.EventHistory
"decisionJournal" -> CompressionStrategy.EventHistory
else -> CompressionStrategy.Conversation() else -> CompressionStrategy.Conversation()
} }
} }
@@ -0,0 +1,41 @@
import com.correx.core.context.builder.DefaultContextPackBuilder
import com.correx.core.context.compression.DefaultContextCompressor
import com.correx.core.context.model.ContextEntry
import com.correx.core.context.model.ContextLayer
import com.correx.core.context.model.TokenBudget
import com.correx.core.events.types.ContextEntryId
import com.correx.core.events.types.ContextPackId
import com.correx.core.events.types.SessionId
import com.correx.core.events.types.StageId
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
class DecisionJournalPinningTest {
private val compressor = DefaultContextCompressor()
private val builder = DefaultContextPackBuilder(compressor)
private val sessionId = SessionId("s1")
private val stageId = StageId("stage-1")
private val packId = ContextPackId("pack-1")
@Test
fun `decisionJournal entry survives an under-budget build`() {
val entries = listOf(
ContextEntry(
id = ContextEntryId("journal-1"),
layer = ContextLayer.L1,
content = "Decision: approved plan",
sourceType = "decisionJournal",
sourceId = "journal-1",
tokenEstimate = 100
)
)
val pack = builder.build(packId, sessionId, stageId, entries, TokenBudget(limit = 10))
val allRetained = pack.layers.values.flatten()
assertTrue(
allRetained.any { it.sourceType == "decisionJournal" },
"decisionJournal entry must be retained even when budget is exceeded"
)
}
}