Skip to main content

bijux_cli/features/install/
query.rs

1#![forbid(unsafe_code)]
2//! Read-only install/runtime identity query interfaces for maintainer tooling.
3
4use super::diagnostics::install_health_report;
5
6/// Structured runtime identity diagnostics queried from install services.
7#[derive(Debug, Clone, PartialEq, Eq)]
8#[allow(clippy::struct_excessive_bools)]
9pub struct RuntimeIdentityQuery {
10    /// Active binary used for invocation.
11    pub active_binary: Option<String>,
12    /// All discovered canonical binaries in PATH order.
13    pub path_binaries: Vec<String>,
14    /// Whether PATH shadowing is present.
15    pub has_path_shadowing: bool,
16    /// Whether duplicate installs are detected across ecosystems.
17    pub has_duplicate_installs: bool,
18    /// Wrapper scripts that no longer point to a valid runtime.
19    pub stale_wrapper_scripts: Vec<String>,
20    /// Whether wheel/runtime version mismatch is detected.
21    pub has_mismatched_wheel_binary_versions: bool,
22    /// Legacy installer conflicts detected on PATH.
23    pub legacy_installer_conflicts: Vec<String>,
24    /// Whether configured active binary path is missing.
25    pub active_binary_missing: bool,
26    /// Whether configured active binary path is a broken symlink.
27    pub broken_symlink_active_binary: bool,
28}
29
30impl RuntimeIdentityQuery {
31    /// Return stale-wrapper maintenance paths using neutral naming.
32    #[must_use]
33    pub fn stale_wrapper_maintenance(&self) -> Vec<String> {
34        self.stale_wrapper_scripts.clone()
35    }
36}
37
38/// Query runtime identity diagnostics without presentation formatting.
39#[must_use]
40pub fn runtime_identity_query(
41    path_value: &str,
42    bin_override: Option<&str>,
43    wheel_version: Option<&str>,
44    runtime_version: &str,
45) -> RuntimeIdentityQuery {
46    let report = install_health_report(path_value, bin_override, wheel_version, runtime_version);
47    RuntimeIdentityQuery {
48        active_binary: report.active_binary,
49        path_binaries: report.path_binaries,
50        has_path_shadowing: report.has_path_shadowing,
51        has_duplicate_installs: report.has_duplicate_installs,
52        stale_wrapper_scripts: report.stale_wrapper_scripts,
53        has_mismatched_wheel_binary_versions: report.has_mismatched_wheel_binary_versions,
54        legacy_installer_conflicts: report.legacy_installer_conflicts,
55        active_binary_missing: report.active_binary_missing,
56        broken_symlink_active_binary: report.broken_symlink_active_binary,
57    }
58}