package com.correx.core.tools.compression

/**
 * Side-channel facts a [ToolOutputCompressor] may read when deriving a compact
 * representation of raw tool output. Compression is a pure function of
 * (raw output, [ToolOutputContext]); it reads no environment state, keeping the
 * derivation deterministic and replay-safe (invariant #6 / #8).
 *
 * Additive by design: a future Tier B compressor (e.g. shell dispatching on
 * `argv[0]`) grows this with an `argv` field without breaking callers.
 */
data class ToolOutputContext(val exitCode: Int = 0)

/**
 * Derives the context-bound representation of raw tool output. Applied on the
 * `ToolResult -> ContextEntry` path only; the raw output stays authoritative in
 * the event log (`ToolReceipt.outputSummary`). Implementations MUST NOT throw on
 * input.
 */
interface ToolOutputCompressor {
    fun compress(raw: String, ctx: ToolOutputContext): String
}

/** No-op compressor: returns raw output unchanged. The [com.correx.core.tools.contract.Tool] default. */
object IdentityCompressor : ToolOutputCompressor {
    override fun compress(raw: String, ctx: ToolOutputContext): String = raw
}
