//! Tier and phase types (ADR-029).
//!
//! Moved from `ontoref-daemon::config` so handler-side code in
//! `ontoref-ops` can construct and pattern-match on them without
//! depending on the daemon crate. The daemon re-exports the types from
//! its own `config` module for backward compatibility with consumers
//! that imported them there.

use serde::{Deserialize, Serialize};

/// `ops` section — per-project tier and phase declaration (ADR-029, ADR-032).
///
/// `tier` controls which authoritative-state regime the project operates
/// under. `phase` is only meaningful when `tier == Tier2`. Both are
/// per-project deliberate acts; ADR-029 / `no-forced-tier-migration` and
/// `tier-transition-requires-clean-migration-state` constrain how either
/// field may change.
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Default)]
pub struct OpsConfig {
    /// Authoritative-state tier. Defaults to `Tier0` for projects that
    /// have not declared a tier in their config.
    #[serde(default)]
    pub tier: Tier,
    /// Operation phase. Only meaningful when `tier == Tier2`.
    #[serde(default)]
    pub phase: Phase,
}

/// Project authoritative-state tier (ADR-029).
///
/// Ordered Tier0 < Tier1 < Tier2 — the derive uses declaration order.
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize, Default)]
pub enum Tier {
    /// Minimal NCL adoption. NCL files are authoritative; no substrate.
    #[default]
    #[serde(rename = "Tier0")]
    Tier0,
    /// Substrate adopted. NCL + commit_layer + state_root.
    #[serde(rename = "Tier1")]
    Tier1,
    /// Operations adopted. Rust substrate authoritative.
    #[serde(rename = "Tier2")]
    Tier2,
}

/// Tier-2 phase (ADR-029).
#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize, Default)]
pub enum Phase {
    /// C-progresivo — NCL editable + save-reconciler bridges human edits.
    #[default]
    #[serde(rename = "Progressive")]
    Progressive,
    /// C-puro — NCL render-only; save-reconciler off.
    #[serde(rename = "Pure")]
    Pure,
}
