package com.fabledsword.minstrel.cache.db.entities

import androidx.room.Entity
import androidx.room.PrimaryKey

/**
 * One buffered device-diagnostics event (M9). The DiagnosticsReporter
 * writes rows here when the account's debug mode is on; the
 * DiagnosticsUploader drains them to POST /api/diagnostics and deletes
 * on success.
 *
 * This is a deliberate ring buffer that is NOT routed through the offline
 * MutationQueue: diagnostics are high-volume, best-effort telemetry, and
 * the bug we're chasing (roaming / dead-zone recovery) happens WHILE
 * offline — so events must persist locally through the dead zone and
 * upload on recovery, without clogging the user-data mutation replay.
 *
 * `occurredAtMillis` is the device-clock epoch-ms when the event happened
 * (the server also stamps its own received_at). `payloadJson` is an
 * opaque JSON object carrying the event sub-type + fields.
 */
@Entity(tableName = "diagnostic_events")
data class DiagnosticEventEntity(
    @PrimaryKey(autoGenerate = true) val id: Long = 0,
    val kind: String,
    val occurredAtMillis: Long,
    val payloadJson: String,
)
