package com.correx.core.events.events

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

/**
 * An idea the operator surfaced while rubber-ducking with the router, captured to a cross-session
 * scratchpad. Recorded as a fact (invariant #1) so the board is rebuilt from the log via
 * `eventStore.allEvents()`. Non-authoritative: an idea informs the router's context but never drives
 * the kernel — it is a note, not a decision.
 */
@Serializable
@SerialName("IdeaCaptured")
data class IdeaCapturedEvent(
    val ideaId: String,
    val sessionId: SessionId,
    val text: String,
    val timestampMs: Long,
) : EventPayload

/**
 * The operator removed an idea from the board. The event log is append-only (invariant #1), so this
 * is a tombstone — the original [IdeaCapturedEvent] stays in the log (and replays), but the idea-board
 * projection filters out any [ideaId] that has a discard. [sessionId] is wherever the discard was
 * issued (often a different session than the capture).
 */
@Serializable
@SerialName("IdeaDiscarded")
data class IdeaDiscardedEvent(
    val ideaId: String,
    val sessionId: SessionId,
) : EventPayload

/**
 * The operator promoted an idea from the cross-session board into the curated per-repo profile
 * (`<workspaceRoot>/.correx/project.toml`, as a `conventions` entry). Like [IdeaDiscardedEvent] this
 * is a tombstone — the original [IdeaCapturedEvent] stays in the log (and replays), but the idea-board
 * projection filters out any promoted [ideaId]. [sessionId] is the capturing session (so all of one
 * idea's events stay co-located); [text] records the convention text written to the profile.
 */
@Serializable
@SerialName("IdeaPromoted")
data class IdeaPromotedEvent(
    val ideaId: String,
    val sessionId: SessionId,
    val text: String,
    val timestampMs: Long,
) : EventPayload
