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
@@ -624,6 +624,9 @@ object ConfigLoader {
asInt(orchestrationSection["journal_compaction_token_threshold"], 2_000),
resumeAbandonedMaxAgeMinutes =
asLong(orchestrationSection["resume_abandoned_max_age_minutes"], 1_440),
compressionLevel = asInt(orchestrationSection["compression_level"], 2),
tokenPrunerUrl =
asString(orchestrationSection["token_pruner_url"], "http://127.0.0.1:8199"),
)
val modelsSettings = ModelsSettings(
@@ -61,6 +61,13 @@ data class OrchestrationKnobs(
* 0 disables auto-resume entirely.
*/
val resumeAbandonedMaxAgeMinutes: Long = 1_440,
/**
* Context compression pipeline level (docs/plans/correx-compression-pipeline.md §5), additive
* 1..9. Default 2 = free format-compress + static cache. Raise toward the 16k wall; ≥3 needs
* the LLMLingua-2 sidecar at [tokenPrunerUrl] (fails open if absent).
*/
val compressionLevel: Int = 2,
val tokenPrunerUrl: String = "http://127.0.0.1:8199",
)
@Serializable