//! ix — sub-millisecond code search via sparse trigram indexing.
//!
//! `ix` pre-computes a byte-level trigram index to narrow search candidates
//! to a fraction of the total file set, then verifies matches with a
//! memory-constant streaming architecture. This eliminates the linear-scan
//! bottleneck of traditional tools on large codebases.
//!
//! # Installation
//!
//! ```bash
//! cargo install moeix
//! ```
//!
//! # Quick Start
//!
//! ```bash
//! ix --build /path/to/repo
//! ix "fn validate"
//! ix --regex "fn\\s+\\w+_handler" --context 3
//! ```
//!
//! # Library Usage
//!
//! ```rust,ignore
//! use ix::reader::Reader;
//! use ix::executor::{Executor, QueryOptions};
//! use ix::planner::Planner;
//!
//! let reader = Reader::open(".ix/shard.ix")?;
//! let plan = Planner::plan("struct Config", false)?;
//! let mut executor = Executor::new(&reader);
//! let (matches, stats) = executor.execute(&plan, &QueryOptions::default())?;
//! ```
//!
//! # Module Declaration Order (alphabetical, as declared in source)
//!
//! `api` · `archive` · `bloom` · `builder` · `cache_policy` · `config` ·
//! `daemon` · `daemon_sock` · `decompress` · `error` · `executor` ·
//! `format` · `idle` · `neg_cache` · `planner` · `posting` ·
//! `posting_cache` · `reader` · `regex_pool` · `scanner` · `streaming` ·
//! `string_pool` · `trigram` · `varint` · `watcher`
//!
//! # Dependency order (build pipeline: leaf-first)
//!
//! `format` → `varint` → `trigram` → `bloom` → `posting` →
//! `string_pool` → `builder` → `reader` → `planner` → `executor` → `scanner`
//!
//! Cache layer: `posting_cache` · `neg_cache` · `regex_pool` (used by `executor`)
//!
//! Policy: `cache_policy` (standalone, adapts to `ResourceGuard` pressure)
//!
//! Support: `scanner` (fallback, no index) · `streaming` (line/mmap alternatives) ·
//! `api` (convenience wrapper) · `config` (`.ixd.toml`)
//!
//! # See Also
//!
//! - [GitHub README](https://github.com/moeshawky/ix) — install, quick start, daemon
//! - [Socket API](https://github.com/moeshawky/ix/blob/main/docs/SOCKET-API.md) — daemon IPC protocol
//!
//! # Feature Flags
//!
//! - **`notify`** (default) — File watcher + daemon (`ixd`) + Unix domain socket IPC
//! - **`decompress`** — gz/zst/bz2/xz decompression
//! - **`archive`** — zip/tar archive support
//! - **`full`** — All optional features

// Lint configuration — Tier 1 security hardened, pedantic with pragmatic allow
#![warn(clippy::pedantic)]
#![allow(clippy::cast_possible_truncation)] // 64-bit target; try_from guards runtime
#![allow(clippy::cast_possible_wrap)] // controlled internal values
#![allow(clippy::cast_sign_loss)] // controlled internal values
#![allow(clippy::module_name_repetitions)] // module::Type is idiomatic
#![allow(clippy::too_many_lines)] // scanner/executor are well-structured
#![warn(missing_docs)] // enterprise: every public item documented
#![cfg_attr(test, allow(missing_docs))] // tests: no doc needed for test fns
#![warn(clippy::semicolon_if_nothing_returned)]
#![warn(clippy::non_ascii_literal)]
#![warn(clippy::unimplemented)]
#![warn(clippy::use_self)]
#![warn(clippy::string_slice)]
#![warn(clippy::clone_on_ref_ptr)]

extern crate llmosafe;

/// HTTP API surface for programmatic index access.
pub mod api;
/// ZIP and tar archive indexing support.
pub mod archive;
/// Bloom filter implementation for fast membership testing.
pub mod bloom;
/// Index builder — coordinates the pipeline from file discovery to shard serialization.
pub mod builder;
/// Adaptive cache policy driven by `ResourceGuard` memory pressure.
#[cfg_attr(docsrs, doc(cfg(feature = "notify")))]
pub mod cache_policy;
/// Runtime and build configuration, including `.ixd.toml` parsing.
pub mod config;
/// Background daemon that watches for file changes and rebuilds the index.
#[cfg(all(feature = "notify", unix))]
#[cfg_attr(docsrs, doc(cfg(feature = "notify")))]
pub mod daemon;
/// Unix domain socket IPC between the daemon and CLI clients.
#[cfg(all(feature = "notify", unix))]
#[cfg_attr(docsrs, doc(cfg(feature = "notify")))]
pub mod daemon_sock;
/// Decompression support for gz, zst, bz2, and xz files.
pub mod decompress;
/// Error types for the ix crate.
pub mod error;
/// Query executor — runs a search plan against the index.
pub mod executor;

pub use executor::ProgressiveBatch;
/// Index file format definitions and magic bytes.
pub mod format;
/// Idle timeout tracker for the daemon process.
#[cfg(feature = "notify")]
#[cfg_attr(docsrs, doc(cfg(feature = "notify")))]
pub mod idle;
/// Negative result cache — skips re-verification of known non-matching files.
pub mod neg_cache;
/// Query planner — converts a pattern string into an execution plan.
pub mod planner;
/// Posting list storage for trigram-to-file mappings.
pub mod posting;
/// LRU cache for decoded posting lists, keyed by trigram.
pub mod posting_cache;
/// Index reader — loads and queries a pre-built shard.
pub mod reader;
/// Compiled regex pool — caches `Regex` objects to avoid recompilation.
pub mod regex_pool;
/// File scanner — fallback linear search when no index is available.
pub mod scanner;
/// Alternative streaming file search implementations — line-based and
/// mmap-windowed verification with context support.
pub mod streaming;
/// Deduplicated string storage for file paths and identifiers.
pub mod string_pool;
/// Trigram extraction and byte-level pattern matching.
pub mod trigram;
/// Variable-length integer encoding for compact index storage.
pub mod varint;
/// Filesystem watcher — monitors directories for file changes.
#[cfg(feature = "notify")]
#[cfg_attr(docsrs, doc(cfg(feature = "notify")))]
pub mod watcher;

#[cfg(feature = "notify")]
#[cfg_attr(docsrs, doc(cfg(feature = "notify")))]
pub use crate::builder::Builder;
#[cfg(all(feature = "notify", unix))]
#[cfg_attr(docsrs, doc(cfg(feature = "notify")))]
pub use crate::daemon_sock::{
    ClientMessage, DaemonClient, DaemonServer, FileChange, FileOp, SearchResultsIter, ServerMessage,
};
#[cfg(feature = "notify")]
#[cfg_attr(docsrs, doc(cfg(feature = "notify")))]
pub use crate::format::Beacon;
#[cfg(feature = "notify")]
#[cfg_attr(docsrs, doc(cfg(feature = "notify")))]
pub use crate::idle::IdleTracker;
#[cfg(feature = "notify")]
#[cfg_attr(docsrs, doc(cfg(feature = "notify")))]
pub use crate::watcher::Watcher;
