lean-ctx 3.9.19

Context Runtime for AI Agents with CCP. 79 MCP tools, 10 read modes, 95+ compression patterns, cross-session memory (CCP), persistent AI knowledge with temporal facts + contradiction detection, multi-agent context sharing, LITM-aware positioning, AAAK compact format, adaptive compression with Thompson Sampling bandits. Supports 24+ AI tools. Reduces LLM token consumption by up to 99%.
//! Local supersession helpers.

use lean_ctx_protocol::{KnowledgeObjectV1, ValidityWindow};

/// Link an existing object to the object that replaces it.
pub fn mark_superseded(object: &mut KnowledgeObjectV1, replacement_id: impl Into<String>) {
    let replacement_id = replacement_id.into();
    let validity = object.validity.get_or_insert_with(|| ValidityWindow {
        valid_from: String::new(),
        valid_until: None,
        superseded_by: None,
    });
    validity.superseded_by = Some(replacement_id);
}

/// Return whether an object has a replacement in its validity metadata.
pub fn is_superseded(object: &KnowledgeObjectV1) -> bool {
    object
        .validity
        .as_ref()
        .is_some_and(|validity| validity.superseded_by.is_some())
}