diff --git a/core/context/src/main/kotlin/com/correx/core/context/builder/DefaultContextPackBuilder.kt b/core/context/src/main/kotlin/com/correx/core/context/builder/DefaultContextPackBuilder.kt index 14516d7b..6a93f634 100644 --- a/core/context/src/main/kotlin/com/correx/core/context/builder/DefaultContextPackBuilder.kt +++ b/core/context/src/main/kotlin/com/correx/core/context/builder/DefaultContextPackBuilder.kt @@ -14,7 +14,7 @@ class DefaultContextPackBuilder( private val compressor: ContextCompressor ) : ContextPackBuilder { - private val neverDropSourceTypes = setOf("steeringNote", "eventHistory") + private val neverDropSourceTypes = setOf("steeringNote", "eventHistory", "decisionJournal") override fun build( id: ContextPackId, @@ -78,6 +78,7 @@ class DefaultContextPackBuilder( "artifact" -> CompressionStrategy.Artifact "steeringNote" -> CompressionStrategy.SteeringNote "eventHistory" -> CompressionStrategy.EventHistory + "decisionJournal" -> CompressionStrategy.EventHistory else -> CompressionStrategy.Conversation() } } diff --git a/core/context/src/test/kotlin/DecisionJournalPinningTest.kt b/core/context/src/test/kotlin/DecisionJournalPinningTest.kt new file mode 100644 index 00000000..9fb40717 --- /dev/null +++ b/core/context/src/test/kotlin/DecisionJournalPinningTest.kt @@ -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" + ) + } +}