use std::collections::{HashMap, HashSet};
use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
use std::sync::Arc;
use khive_retrieval::ann::corpus::{CorpusScope, WatermarkCapture};
use khive_retrieval::ann::registry::{self as ann_registry, WatermarkAuthority};
use khive_runtime::config::ann_rebuild_threshold_from_env as ann_rebuild_threshold;
use khive_runtime::{KhiveRuntime, Namespace, NamespaceToken, RuntimeError};
use khive_storage::types::{SqlStatement, SqlValue};
use super::snapshot_invalidation::invalidate_legacy_vamana_snapshots;
use khive_vamana::bridge::AnnBridgeCore;
use khive_vamana::distance::l2_normalize;
use khive_vamana::{
read_commit_info, segment_commit_digest, CorpusFingerprint, VamanaIndex, VamanaSnapshot,
};
use tokio::sync::RwLock;
use uuid::Uuid;
#[cfg(test)]
use khive_vamana::{write_external_ids_sidecar, VamanaConfig};
mod bridge_impl;
mod fresh_tail;
mod persistence;
mod segment_key;
mod snapshot;
mod state;
mod warm_and_rotate;
use bridge_impl::*;
pub(crate) use fresh_tail::*;
pub(crate) use persistence::*;
pub(crate) use snapshot::*;
pub(crate) use state::*;
pub(crate) use warm_and_rotate::*;
pub(crate) use segment_key::snapshot_key;
use segment_key::{ann_segment_dir, ann_segment_dir_from_root, decode_ann_dir_name};
pub(crate) use khive_runtime::config::sanitize_key as sanitize_model_key;
#[cfg(test)]
#[path = "vamana_owned_build_tests.rs"]
mod owned_build_tests;
#[cfg(test)]
#[path = "vamana_tests.rs"]
mod tests;
#[cfg(test)]
#[path = "vamana_corpus_statement_tests.rs"]
mod corpus_statement_tests;
#[cfg(test)]
#[path = "vamana_corpus_capture_tests.rs"]
mod corpus_capture_tests;