use std::{collections::HashMap, sync::Arc, time::Duration};
use jiff::Timestamp;
use crate::alertd::{context::InternalContext, daemon::DaemonControl, tasks::TaskEndpoint};
#[derive(Clone)]
pub struct ServerState {
pub started_at: Timestamp,
pub pid: u32,
/// Version of the running `bestool` binary (not this crate's version), so
/// `/status` reports what self-update targets and operators recognise.
pub binary_version: String,
pub internal_context: Arc<InternalContext>,
pub watchdog_timeout: Option<Duration>,
/// Endpoints exposed by registered background tasks. Keyed by
/// `(task_name, endpoint_name)` so the `/tasks/:task/:endpoint` route can
/// dispatch in O(1) without walking the task registry per request. The whole
/// endpoint rather than its handler alone, because the route also has to
/// know whether it is guarded.
pub task_endpoints: Arc<HashMap<(String, String), TaskEndpoint>>,
/// Drives the daemon's `/reload` and `/restart` control endpoints.
pub control: DaemonControl,
/// Backup run registry, when backups are compiled in; lets `/status` list
/// in-flight runs.
pub backups: Option<Arc<crate::alertd::BackupRegistry>>,
/// Handle to the doctor task's latest sweep, when a doctor task is
/// registered; feeds per-check stats and the status census to `/metrics`.
pub metrics: Option<crate::alertd::doctor::DoctorMetricsHandle>,
/// What the canopy collection loop holds, when it is registered; feeds the
/// certificate endpoint Caddy asks during a handshake.
pub certificates: Option<Arc<crate::alertd::certificates::CertificateState>>,
}