//! Escalation primitive: severity-routed ticket raise + resolve.
//!
//! Phase B (M6) ships:
//!  - Trait + default `JobQueueEscalation` impl.
//!  - Three reference channel adapters (Log, Webhook, JobQueue passthrough).
//!  - OpsEvent variants for ticket lifecycle.
//!
//! Channel adapters live alongside this module under `channels/`. M6
//! follow-up tasks land them in parallel with this foundation commit.

pub mod channels;
mod jobqueue;
mod trait_;

pub use channels::{ChannelAdapter, ChannelError, JobQueueChannel, LogChannel, WebhookChannel};
pub use jobqueue::JobQueueEscalation;
pub use trait_::{
    Escalation, EscalationError, EscalationFilter, EscalationId, EscalationState, EscalationTicket,
    ProvenanceRef, Resolution, ResolutionOutcome, Severity,
};

/// Construct a [`JobQueueEscalation`] with `with_audit` auto-wired from
/// the active `SupervisedAgent` run context. Outside a run scope, returns
/// an unaudited instance — no behavioural break.
pub fn audited_escalation(jobs: std::sync::Arc<dyn klieo_core::JobQueue>) -> JobQueueEscalation {
    let base = JobQueueEscalation::new(jobs);
    if let Some(ctx) = crate::run_context::current_run_context() {
        base.with_audit(ctx.episodic, ctx.run_id)
    } else {
        base
    }
}
