package com.correx.infrastructure.tools.extract

/**
 * Outcome of extracting a fetched page (research-workflow-spec §5). The cleaned [markdown] is the
 * canonical fetch result that goes to CAS; raw HTML is discarded. [quality] tells the workflow
 * whether to route around a dead source ([LOW_QUALITY]) or reject an unsupported body ([REJECTED]).
 *
 * [extractorVersion] is pinned into every fetch event: heuristic improvements must never change
 * what an old event means, so replay reads the recorded artifact and never re-extracts — the same
 * discipline as the embedding-model hash.
 */
data class ExtractionResult(
    val markdown: String,
    val quality: ExtractionQuality,
    val extractorVersion: String,
    val reason: String? = null,
)

enum class ExtractionQuality {
    /** Usable content of at least the minimum length. */
    OK,

    /** Extracted, but below the minimum-length threshold — JS-rendered SPA or paywall; route around it. */
    LOW_QUALITY,

    /** Content-type the deterministic path does not handle (binary/media/pdf) — dropped at the header. */
    REJECTED,
}
