//! Worklog primitive: durable DAG of agent work items.

mod kv_worklog;
mod trait_;

pub use kv_worklog::KvWorkLog;
pub use trait_::{WorkDag, WorkId, WorkItem, WorkLog, WorkLogError, WorkStatus};

/// Construct a [`KvWorkLog`] 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_worklog(kv: std::sync::Arc<dyn klieo_core::KvStore>) -> KvWorkLog {
    let base = KvWorkLog::new(kv);
    if let Some(ctx) = crate::run_context::current_run_context() {
        base.with_audit(ctx.episodic, ctx.run_id)
    } else {
        base
    }
}
