diff --git a/apps/server/src/main/kotlin/com/correx/apps/server/Main.kt b/apps/server/src/main/kotlin/com/correx/apps/server/Main.kt index 2027ac83..7375b645 100644 --- a/apps/server/src/main/kotlin/com/correx/apps/server/Main.kt +++ b/apps/server/src/main/kotlin/com/correx/apps/server/Main.kt @@ -18,6 +18,7 @@ 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.core.inference.EmbeddingRelevanceScorer import com.correx.infrastructure.compression.HttpTokenPruner import com.correx.core.context.compression.DefaultContextCompressor import com.correx.core.context.model.TokenBudget @@ -291,12 +292,16 @@ fun main() { WorkspaceTools(registry = wsRegistry, executor = wsExecutor) } + // Constructed before the engines so the context builder can rank freeform turns by relevance + // to the current query (pipeline §6, query-conditioned selection). Reused by L3 retrieval below. + val embedder = InfrastructureModule.createEmbedderFromConfig(correxConfig.router.embedder) val engines = OrchestratorEngines( transitionResolver = DefaultTransitionResolver { condition, ctx -> condition.evaluate(ctx) }, contextPackBuilder = DefaultContextPackBuilder( DefaultContextCompressor(), policy = CompressionPolicy(correxConfig.orchestration.compressionLevel), tokenPruner = HttpTokenPruner(baseUrl = correxConfig.orchestration.tokenPrunerUrl), + relevanceScorer = EmbeddingRelevanceScorer(embedder), ), inferenceRouter = inferenceRouter, validationPipeline = ValidationPipeline( @@ -340,7 +345,6 @@ fun main() { val artifactKindRegistry = DefaultArtifactKindRegistry().also { reg -> configArtifactKindsEarly.forEach { reg.register(it) } } - val embedder = InfrastructureModule.createEmbedderFromConfig(correxConfig.router.embedder) val l3MemoryStore = InfrastructureModule.createL3MemoryStoreFromConfig(correxConfig.router.l3) // Rebuild the L3 metadata map from the ChatTurnEvent log before serving queries: // persisted vectors survive restart but the metadata map does not (no-op for diff --git a/core/config/src/main/kotlin/com/correx/core/config/ConfigLoader.kt b/core/config/src/main/kotlin/com/correx/core/config/ConfigLoader.kt index 066945a1..125b0a20 100644 --- a/core/config/src/main/kotlin/com/correx/core/config/ConfigLoader.kt +++ b/core/config/src/main/kotlin/com/correx/core/config/ConfigLoader.kt @@ -624,7 +624,7 @@ 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), + compressionLevel = asInt(orchestrationSection["compression_level"], 4), tokenPrunerUrl = asString(orchestrationSection["token_pruner_url"], "http://127.0.0.1:8199"), ) diff --git a/core/config/src/main/kotlin/com/correx/core/config/CorrexConfig.kt b/core/config/src/main/kotlin/com/correx/core/config/CorrexConfig.kt index d5104faf..aa33010e 100644 --- a/core/config/src/main/kotlin/com/correx/core/config/CorrexConfig.kt +++ b/core/config/src/main/kotlin/com/correx/core/config/CorrexConfig.kt @@ -64,9 +64,10 @@ data class OrchestrationKnobs( /** * 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). + * the LLMLingua-2 sidecar at [tokenPrunerUrl] (fails open if absent). Default 4 = format + + * static cache + token pruning + age-tiering, sized for a 12b on a 16k window. */ - val compressionLevel: Int = 2, + val compressionLevel: Int = 4, val tokenPrunerUrl: String = "http://127.0.0.1:8199", )