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 RepoKnowledgeHit(
    val path: String,
    val text: String,
    val score: Float,
)

/**
 * Result of semantic retrieval over the embedded repo map for a stage (invariant #9):
 * recorded at retrieval time; replay and downstream context assembly read the hits from
 * this event, never re-query the vector index.
 */
@Serializable
@SerialName("RepoKnowledgeRetrieved")
data class RepoKnowledgeRetrievedEvent(
    val sessionId: SessionId,
    val stageId: StageId,
    val query: String,
    val hits: List<RepoKnowledgeHit>,
) : EventPayload

/**
 * Candidates that scored above the L3 index's own top-k cutoff but below the retriever's
 * minimum-similarity floor, so were never rendered to the agent as "relevant." Without this,
 * a hit below the floor is indistinguishable from one that was never a candidate — recorded
 * per invariant #9 since the embedding-similarity score is itself an environment observation.
 */
@Serializable
@SerialName("RepoKnowledgeHitsFiltered")
data class RepoKnowledgeHitsFilteredEvent(
    val sessionId: SessionId,
    val query: String,
    val threshold: Float,
    val dropped: List<RepoKnowledgeHit>,
) : EventPayload
