use crate::artifact::{ArtifactIndex, ArtifactStore};
use crate::core::NormalizedPath;
use crate::depgraph::{
CompileContext, ContextKey, DepGraph, DepfileStrategy, SessionId, SessionManager,
SystemIncludeCache, UserDepFlags,
};
use crate::fscache::{CacheSystem, Clock};
use crate::hash::ContentHash;
use crate::ipc::{IpcConnection, IpcListener};
use crate::protocol::{ArtifactData, ArtifactOutput, ArtifactPayload, Request, Response};
use crate::watcher::{NotifyWatcher, SettleBuffer, SettledEvent};
use dashmap::DashMap;
use std::collections::{HashMap, HashSet};
use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering};
use std::sync::Arc;
use std::time::{Duration, Instant};
use tokio::sync::{Mutex, Notify};
use super::compile_journal::{
extract_outcome, miss_reason, CompileJournal, JournalContext, JournalEntry, SelfProfileSpans,
};
use super::fingerprint::FingerprintManager;
use super::process::CompilePriority;
use super::stats::{HitPhases, MissPhases, PhaseProfiler, StatsCollector};
pub(crate) struct FastHitEntry {
pub(crate) clock: Clock,
pub(crate) artifact_key_hex: String,
pub(crate) cached_at: std::time::Instant,
}
const FAST_HIT_MAX_AGE: std::time::Duration = std::time::Duration::from_secs(60);
const EPHEMERAL_CACHE_MAX_AGE: std::time::Duration = std::time::Duration::from_secs(300);
const REQUEST_CACHE_MAX_ENTRIES: usize = 4096;
const REQUEST_VALIDATION_CACHE_MAX_ENTRIES: usize = 8192;
const RSP_CACHE_MAX_ENTRIES: usize = 1024;
const RUST_MISS_PROFILE_ENV: &str = "ZCCACHE_PROFILE_RUST_MISS";
const CC_MISS_PROFILE_ENV: &str = "ZCCACHE_PROFILE_CC_MISS";
const WORKTREE_ROOT_ENV: &str = "ZCCACHE_WORKTREE_ROOT";
const PATH_REMAP_ENV: &str = "ZCCACHE_PATH_REMAP";
const REQUEST_ROOT_MARKER: &str = "$ZCCACHE_WORKTREE_ROOT";
const LINK_PATH_REMAP_AUTO_KEY_FLAG: &str = "zccache:path-remap=auto";
const LINK_PATH_REMAP_ROOT_SPECIFIC_FLAG: &str = "zccache:path-remap=root-specific";
pub use lifecycle::DepGraphSetter;
pub struct DaemonServer {
listener: IpcListener,
shutdown: Arc<Notify>,
state: Arc<SharedState>,
index_writer_rx: Option<tokio::sync::mpsc::UnboundedReceiver<(String, ArtifactIndex)>>,
}
mod cache_trim;
mod cached_artifact;
mod client_env;
mod compiler_hash;
mod connection;
mod handle_clear;
mod handle_compile;
mod handle_compile_ephemeral;
mod handle_compile_multi;
mod handle_exec;
mod handle_link;
mod handle_release_worktree_handles;
mod in_flight;
mod keys;
mod lifecycle;
mod link_helpers;
mod pch;
mod pending_writes;
mod persist;
mod private_daemon;
mod request_cache;
mod rsp_cache;
mod run;
mod rustc;
mod session;
mod state;
mod util;
mod wal;
mod watch;
pub(crate) use cache_trim::trim_fast_hit_cache;
use cache_trim::*;
use cached_artifact::*;
pub(crate) use cached_artifact::{CachedArtifact, CachedPayload};
use client_env::*;
use compiler_hash::*;
use connection::handle_connection;
use handle_clear::*;
use handle_compile::handle_compile;
use handle_compile_ephemeral::*;
use handle_compile_multi::handle_compile_multi;
use handle_exec::handle_generic_tool_exec;
use handle_link::handle_link_ephemeral;
#[cfg(test)]
use handle_link::run_post_link_deploy_hook;
use handle_release_worktree_handles::handle_release_worktree_handles;
use in_flight::*;
use keys::*;
use lifecycle::*;
use link_helpers::*;
use pch::*;
use persist::*;
use private_daemon::*;
use request_cache::*;
use rsp_cache::*;
use rustc::*;
use session::*;
use state::*;
use util::*;
use wal::*;
use watch::*;
#[cfg(test)]
mod tests;