package com.correx.core.events.events

import com.correx.core.events.types.SessionId
import com.correx.core.events.types.StageId
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class LspDiagnostic(
    val path: String,
    val line: Int,
    val character: Int,
    val severity: String,
    val code: String? = null,
    val message: String,
    /** LSP `DiagnosticTag` names, lowercased ("unnecessary", "deprecated"). Lint class, not severity. */
    val tags: List<String> = emptyList(),
) {
    /** Lint-class diagnostic: reported and recorded, but never a reason to fail a stage. */
    val isLint: Boolean get() = tags.isNotEmpty()
}

/** Recorded LSP 3.17 pull-diagnostic observation; replay never re-queries a language server. */
@Serializable
@SerialName("LspDiagnosticsCompleted")
data class LspDiagnosticsCompletedEvent(
    val sessionId: SessionId,
    val stageId: StageId,
    val server: String?,
    val diagnostics: List<LspDiagnostic>,
    val skippedReason: String? = null,
) : EventPayload
