feat(context): compression pipeline stage 1 — level policy + deterministic stages
Additive CompressionPolicy (levels 1-9), ProtectedSpanTagger (regex load-bearing spans), FormatCompressor (json→dotted lines), ContextClassifier (static/structured/freeform). Stage 1 (FORMAT_COMPRESS) wired into DefaultContextPackBuilder behind the policy; structured entries only, lossless. PromptRenderer repetition-anchoring of steering directives.
This commit is contained in:
@@ -70,6 +70,33 @@ class PromptRendererOrderingTest {
|
||||
assertEquals(listOf("system" to "memory", "user" to "question"), messages.map { it.role to it.content })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `steering directives are re-anchored as a trailing user reminder`() {
|
||||
// A steering note folds into the leading system block AND is restated at the tail so a
|
||||
// weak local model still sees the active constraint next to the final query.
|
||||
val pack = ContextPack(
|
||||
id = ContextPackId("p"),
|
||||
sessionId = sessionId,
|
||||
stageId = stageId,
|
||||
layers = mapOf(
|
||||
ContextLayer.L0 to listOf(entry("sys", ContextLayer.L0, EntryRole.SYSTEM, "systemPrompt")),
|
||||
ContextLayer.L2 to listOf(entry("directive", ContextLayer.L2, EntryRole.SYSTEM, "steeringNote")),
|
||||
ContextLayer.L1 to listOf(entry("question", ContextLayer.L1, EntryRole.USER, "chat")),
|
||||
),
|
||||
budgetUsed = 30,
|
||||
budgetLimit = 4000,
|
||||
)
|
||||
val messages = PromptRenderer.render(pack)
|
||||
assertEquals(
|
||||
listOf(
|
||||
"system" to "sys\n\ndirective",
|
||||
"user" to "question",
|
||||
"user" to "Reminder — active steering directive(s):\ndirective",
|
||||
),
|
||||
messages.map { it.role to it.content },
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `non-L0 SYSTEM entries fold into the single leading system message`() {
|
||||
// Strict chat templates (Qwen) 400 on any system message after index 0. Recalled L3
|
||||
|
||||
Reference in New Issue
Block a user