feat(context): pin decisionJournal source type through compression
This commit is contained in:
+2
-1
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user