feat(context,infra): compression pipeline stages 4-5 — token pruning + relevance + ToMe

- build() is now suspend: pipeline runs all stages in fixed order, each gated by level
- TOKEN_PRUNE (level 3): TokenPruner interface + LLMLingua-2 sidecar (sidecars/llmlingua)
  + HttpTokenPruner adapter (fails open if sidecar down); prunes freeform, preserves
  protected spans, skips tier-0 turns when TIER_SPLIT on
- TOME_MERGE (level 8): ToMeMerger collapses near-duplicate freeform turns (Jaccard)
- Stage 5 selection: RelevanceScorer + EmbeddingRelevanceScorer (cosine over Embedder);
  query-conditioned reorder so least-relevant freeform drops first under budget
- [orchestration] compression_level + token_pruner_url config, wired in Main
- suspend ripple fixed across builder callers/stubs
This commit is contained in:
2026-07-01 14:29:56 +04:00
parent e0c222392c
commit 047e2a4070
25 changed files with 509 additions and 65 deletions
+1
View File
@@ -43,6 +43,7 @@ dependencies {
implementation project(':core:toolintent')
implementation project(':infrastructure:tools')
implementation project(':infrastructure:tools:filesystem')
implementation project(':infrastructure:compression')
implementation "com.github.ajalt.clikt:clikt:5.0.1"
@@ -17,6 +17,8 @@ import com.correx.core.config.OperatorProfile
import com.correx.core.config.ProfileLoader
import com.correx.core.config.ProviderConfig
import com.correx.core.context.builder.DefaultContextPackBuilder
import com.correx.core.context.compression.CompressionPolicy
import com.correx.infrastructure.compression.HttpTokenPruner
import com.correx.core.context.compression.DefaultContextCompressor
import com.correx.core.context.model.TokenBudget
import com.correx.core.events.EventDispatcher
@@ -291,7 +293,11 @@ fun main() {
val engines = OrchestratorEngines(
transitionResolver = DefaultTransitionResolver { condition, ctx -> condition.evaluate(ctx) },
contextPackBuilder = DefaultContextPackBuilder(DefaultContextCompressor()),
contextPackBuilder = DefaultContextPackBuilder(
DefaultContextCompressor(),
policy = CompressionPolicy(correxConfig.orchestration.compressionLevel),
tokenPruner = HttpTokenPruner(baseUrl = correxConfig.orchestration.tokenPrunerUrl),
),
inferenceRouter = inferenceRouter,
validationPipeline = ValidationPipeline(
validators = listOf(