package com.correx.apps.server.health

import com.correx.core.events.events.HealthSubject

/**
 * A single point-in-time reading of one [subject]'s environment state. The [HealthMonitor]
 * compares [status] against the last recorded status and emits an edge event only on change,
 * so a probe is free to report the same status every tick without polluting the log.
 *
 * [metric]/[observedValue]/[threshold] describe the dimension that drove the [status] decision
 * (e.g. `total_bytes` = 5.2 GB vs a 5.0 GB threshold), and are carried verbatim into the event.
 */
data class HealthObservation(
    val subject: HealthSubject,
    val status: HealthStatus,
    val metric: String,
    val observedValue: Long,
    val threshold: Long,
    val detail: String,
)

/**
 * Reads one subject's nondeterministic environment state (filesystem, process, store). Probes
 * run only live, inside the monitor loop — never during replay; the recorded edge events are the
 * sole replay input (Invariant #8/#9). Implementations may hold per-run state (e.g. the prior
 * sample for a growth rate); that state never affects replay.
 */
interface HealthProbe {
    val subject: HealthSubject
    suspend fun observe(): HealthObservation
}
