keyhog 0.5.73

GPU-accelerated secret scanner for code, Git history, cloud, containers, browser assets, and live credential verification
use super::ResolvedScanConfig;

/// Process-wide scanner settings that must be installed before hardware probes
/// or detector compilation. Keeping this transition in one object prevents the
/// scan, watch, and scan-system entry points from hashing one configuration
/// while executing another.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) struct ResolvedEngineRuntimeSettings {
    gpu_policy: keyhog_scanner::gpu::GpuRuntimePolicy,
    regex_dfa_limit: Option<usize>,
    gpu_batch_input_limit: Option<usize>,
    profile_detail: keyhog_scanner::Detail,
}

impl From<&ResolvedScanConfig> for ResolvedEngineRuntimeSettings {
    fn from(config: &ResolvedScanConfig) -> Self {
        Self {
            gpu_policy: config.gpu_runtime_policy,
            regex_dfa_limit: config.regex_dfa_limit,
            gpu_batch_input_limit: config.gpu_batch_input_limit,
            profile_detail: config.scanner.profile_detail(),
        }
    }
}

impl ResolvedEngineRuntimeSettings {
    /// Publish the resolved values before any global reader can cache hardware
    /// or sizing state. `None` selects the documented engine default.
    pub(crate) fn apply(self) {
        keyhog_scanner::gpu::set_gpu_runtime_policy(self.gpu_policy);
        keyhog_scanner::set_regex_dfa_limit(self.regex_dfa_limit.unwrap_or(0)); // LAW10: zero is the scanner API's documented compiled-default sentinel
        keyhog_scanner::set_gpu_batch_input_limit(self.gpu_batch_input_limit.unwrap_or(0)); // LAW10: zero is the scanner API's documented VRAM-adaptive-default sentinel
        keyhog_scanner::set_profile_detail(self.profile_detail);
    }
}