sbom_tools/diff/engine_config.rs
1//! Configuration types for the diff engine.
2
3use crate::matching::CrossEcosystemConfig;
4
5/// Configuration for large SBOM optimization.
6#[derive(Debug, Clone)]
7pub struct LargeSbomConfig {
8 /// Minimum component count to enable LSH-based matching
9 pub lsh_threshold: usize,
10 /// Cross-ecosystem matching configuration
11 pub cross_ecosystem: CrossEcosystemConfig,
12 /// Per-component candidate budget, same value on both sides of the
13 /// `lsh_threshold` size gate. Above the gate it bounds the TOTAL across
14 /// all strategies (index + LSH + cross-ecosystem); below the gate it
15 /// bounds the index candidates (cross-ecosystem candidates there are
16 /// budgeted separately by `CrossEcosystemConfig::max_candidates`)
17 pub max_candidates: usize,
18}
19
20impl Default for LargeSbomConfig {
21 fn default() -> Self {
22 Self {
23 lsh_threshold: 500,
24 cross_ecosystem: CrossEcosystemConfig::default(),
25 // Matches the budget the sub-threshold path has always used, so
26 // candidate volume no longer jumps ~3.5x (50 -> up to 175) when
27 // an SBOM crosses the size gate (candidates are quality-ranked,
28 // so the marginal recall of slots 51..100 is negligible next to
29 // their cost).
30 max_candidates: 50,
31 }
32 }
33}
34
35impl LargeSbomConfig {
36 /// Check if cross-ecosystem matching is enabled.
37 #[must_use]
38 pub const fn enable_cross_ecosystem(&self) -> bool {
39 self.cross_ecosystem.enabled
40 }
41
42 /// Aggressive optimization for very large SBOMs (1000+)
43 #[must_use]
44 pub fn aggressive() -> Self {
45 Self {
46 lsh_threshold: 300,
47 cross_ecosystem: CrossEcosystemConfig::default(),
48 max_candidates: 25,
49 }
50 }
51
52 /// Conservative settings (for accuracy over speed)
53 #[must_use]
54 pub fn conservative() -> Self {
55 Self {
56 lsh_threshold: 1000,
57 cross_ecosystem: CrossEcosystemConfig::disabled(),
58 max_candidates: 150,
59 }
60 }
61}