package com.correx.core.context.compression

/**
 * Stage 3 (TOKEN_PRUNE): LLMLingua-2-style token pruning of freeform prose. A small classifier
 * scores tokens by predictability and drops the low-perplexity connective tissue, keeping the
 * load-bearing tokens — ~40-50% compression before quality drops (pipeline §1).
 *
 * [protectedSpans] (from [ProtectedSpanTagger]) must survive verbatim; the implementation may
 * not alter any substring in that set. This is what keeps pruning from becoming a hallucination
 * risk (pipeline §2). Pure prose in, pruned prose out; suspend because the reference
 * implementation is an out-of-process sidecar.
 */
interface TokenPruner {
    suspend fun prune(content: String, protectedSpans: List<String>, targetRatio: Double): String
}

/** Default when no pruner is configured (levels < 3, or sidecar unavailable): identity. */
object NoOpTokenPruner : TokenPruner {
    override suspend fun prune(content: String, protectedSpans: List<String>, targetRatio: Double): String = content
}
