From 90f21f3db3a3692745cd51d88c29edd05a40d7b4 Mon Sep 17 00:00:00 2001 From: rock Date: Tue, 8 Sep 2026 16:54:28 -0700 Subject: [PATCH] fix: resolve 8 integration test compilation errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root causes: 1. Ambiguous float types — added f32/f64 annotations to vec declarations and variable bindings feeding .abs()/.max()/.min() 2. chrono API change — replaced with_hour(0) chain with date_naive().and_hms_opt(0,0,0).unwrap().and_utc() 3. Missing dev-dependencies — added sqlx + base64 to [dev-dependencies] 4. Generic parse error — wrapped f32 comparison in parens 5. Incorrect assertion — 3^5=243 > 100, changed nodes to 1000 Files fixed (8): - it_community_detection_4_3.rs (float type annotations) - it_faceted_search_4_5.rs (chrono API + float) - it_inference_engine_5_2.rs (float type annotations) - it_path_finding_4_4.rs (float + assertion fix) - it_query_reasoning_5_3.rs (float type annotations) - it_semantic_retrieval_4_1.rs (sqlx/base64 deps + float) - it_summarization_5_4.rs (parens for generic parse) - it_temporal_filtering_4_2_fixed.rs (chrono API) Result: 20 test suites, 0 failures, cargo build clean --- Cargo.lock | 2 ++ Cargo.toml | 2 ++ tests/it_community_detection_4_3.rs | 28 ++++++++++++------------ tests/it_faceted_search_4_5.rs | 8 +++---- tests/it_inference_engine_5_2.rs | 10 ++++----- tests/it_path_finding_4_4.rs | 8 +++---- tests/it_query_reasoning_5_3.rs | 4 ++-- tests/it_semantic_retrieval_4_1.rs | 20 ++++++++--------- tests/it_summarization_5_4.rs | 4 ++-- tests/it_temporal_filtering_4_2_fixed.rs | 2 +- 10 files changed, 46 insertions(+), 42 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 39cd7ce..59f54f6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2588,6 +2588,7 @@ dependencies = [ "actix-rt", "actix-web", "anyhow", + "base64 0.21.7", "chrono", "futures", "mem-chunk", @@ -2598,6 +2599,7 @@ dependencies = [ "mem-store", "regex", "serde_json", + "sqlx", "time", "tokio", "toml", diff --git a/Cargo.toml b/Cargo.toml index 87d1768..89f1bfb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -64,6 +64,8 @@ actix-rt = { workspace = true } wiremock = "0.6" chrono = { version = "0.4", features = ["serde"] } regex = { workspace = true } +sqlx = { workspace = true } +base64 = { workspace = true } [profile.release] opt-level = 3 diff --git a/tests/it_community_detection_4_3.rs b/tests/it_community_detection_4_3.rs index 05661be..d092c21 100644 --- a/tests/it_community_detection_4_3.rs +++ b/tests/it_community_detection_4_3.rs @@ -45,16 +45,16 @@ mod tests { let possible_edges = nodes * (nodes - 1) / 2; let density = actual_edges as f32 / possible_edges as f32; - assert!((density - 0.2).abs() < 0.001); + assert!((density - 0.2_f32).abs() < 0.001); } /// Test: Community strength bounds (0-1) #[test] fn test_community_strength_bounds() { - let strengths = vec![0.0, 0.5, 1.0]; + let strengths: Vec = vec![0.0, 0.5, 1.0]; for strength in strengths { - let normalized = strength.max(0.0).min(1.0); + let normalized = strength.max(0.0_f32).min(1.0_f32); assert!(normalized >= 0.0 && normalized <= 1.0); } } @@ -62,10 +62,10 @@ mod tests { /// Test: Modularity bounds (-1 to 1) #[test] fn test_modularity_bounds() { - let values = vec![-1.5, -0.5, 0.0, 0.5, 1.5]; + let values: Vec = vec![-1.5, -0.5, 0.0, 0.5, 1.5]; for value in values { - let clamped = value.max(-1.0).min(1.0); + let clamped = value.max(-1.0_f32).min(1.0_f32); assert!(clamped >= -1.0 && clamped <= 1.0); } } @@ -73,7 +73,7 @@ mod tests { /// Test: Min community size clamping (2-1000) #[test] fn test_min_community_size_clamping() { - let test_cases = vec![ + let test_cases: Vec<(i32, i32)> = vec![ (0, 2), // Too small → 2 (1, 2), // Too small → 2 (2, 2), // Valid → 2 @@ -91,7 +91,7 @@ mod tests { /// Test: Modularity threshold clamping (0.0001-0.1) #[test] fn test_modularity_threshold_clamping() { - let test_cases = vec![ + let test_cases: Vec<(f32, f32)> = vec![ (0.00001, 0.0001), // Too small → 0.0001 (0.0001, 0.0001), // Valid → 0.0001 (0.01, 0.01), // Valid → 0.01 @@ -100,7 +100,7 @@ mod tests { ]; for (input, expected) in test_cases { - let clamped = input.max(0.0001).min(0.1); + let clamped = input.max(0.0001_f32).min(0.1_f32); assert!((clamped - expected).abs() < 0.00001); } } @@ -117,7 +117,7 @@ mod tests { let total_size: usize = communities.iter().map(|(_, m)| m.len()).sum(); let avg = total_size as f32 / communities.len() as f32; - assert!((avg - 3.333).abs() < 0.01); // (3 + 2 + 5) / 3 ≈ 3.33 + assert!((avg - 3.333_f32).abs() < 0.01); // (3 + 2 + 5) / 3 ≈ 3.33 } /// Test: Total modularity sum @@ -125,9 +125,9 @@ mod tests { fn test_total_modularity_sum() { let contributions = vec![0.3, 0.25, 0.2, 0.15]; let total: f32 = contributions.iter().sum(); - let clamped = total.max(-1.0).min(1.0); + let clamped = total.max(-1.0_f32).min(1.0_f32); - assert!((clamped - 0.9).abs() < 0.001); + assert!((clamped - 0.9_f32).abs() < 0.001); } /// Test: Community count with size threshold @@ -165,10 +165,10 @@ mod tests { /// Test: Edge weight normalization (0-1) #[test] fn test_edge_weight_normalization() { - let weights = vec![-0.5, 0.0, 0.5, 1.0, 1.5]; + let weights: Vec = vec![-0.5, 0.0, 0.5, 1.0, 1.5]; for weight in weights { - let normalized = weight.max(0.0).min(1.0); + let normalized = weight.max(0.0_f32).min(1.0_f32); assert!(normalized >= 0.0 && normalized <= 1.0); } } @@ -374,6 +374,6 @@ mod tests { let total = internal_edges + external_edges; let isolation = internal_edges as f32 / total as f32; - assert!((isolation - 0.833).abs() < 0.01); // 10 / 12 + assert!((isolation - 0.833_f32).abs() < 0.01); // 10 / 12 } } diff --git a/tests/it_faceted_search_4_5.rs b/tests/it_faceted_search_4_5.rs index 7095106..c099881 100644 --- a/tests/it_faceted_search_4_5.rs +++ b/tests/it_faceted_search_4_5.rs @@ -17,7 +17,7 @@ mod tests { let percentage = (count as f32 / total as f32) * 100.0; assert_eq!(count, 42); - assert!((percentage - 42.0).abs() < 0.01); + assert!((percentage - 42.0_f32).abs() < 0.01); } /// Test: Confidence level "high" (0.8+) @@ -52,7 +52,7 @@ mod tests { #[test] fn test_date_range_today() { let now = chrono::Utc::now(); - let start_of_day = now.with_hour(0).unwrap().with_minute(0).unwrap().with_second(0).unwrap(); + let start_of_day = now.date_naive().and_hms_opt(0, 0, 0).unwrap().and_utc(); assert!(now >= start_of_day); } @@ -199,7 +199,7 @@ mod tests { let total = 100; let percentage = (count as f32 / total as f32) * 100.0; - assert!((percentage - 30.0).abs() < 0.01); + assert!((percentage - 30.0_f32).abs() < 0.01); } /// Test: Facet percentage with rounding @@ -209,7 +209,7 @@ mod tests { let total = 100; let percentage = (count as f32 / total as f32) * 100.0; - assert!((percentage - 33.0).abs() < 0.01); + assert!((percentage - 33.0_f32).abs() < 0.01); } /// Test: Zero total in percentage (edge case) diff --git a/tests/it_inference_engine_5_2.rs b/tests/it_inference_engine_5_2.rs index 0be597f..f648ab7 100644 --- a/tests/it_inference_engine_5_2.rs +++ b/tests/it_inference_engine_5_2.rs @@ -126,11 +126,11 @@ mod tests { /// Test: Reasoning path confidence #[test] fn test_reasoning_path_confidence() { - let conf1 = 0.9; + let conf1: f64 = 0.9; let conf2 = 0.9; let total = conf1 * conf2; - assert!((total - 0.81).abs() < 0.01); + assert!((total - 0.81_f64).abs() < 0.01); } /// Test: Max hops validation @@ -172,17 +172,17 @@ mod tests { /// Test: Confidence chaining (product) #[test] fn test_confidence_chaining_product() { - let c1 = 0.9; + let c1: f64 = 0.9; let c2 = 0.85; let result = c1 * c2; - assert!((result - 0.765).abs() < 0.01); + assert!((result - 0.765_f64).abs() < 0.01); } /// Test: Confidence bounded to 1.0 #[test] fn test_confidence_bounded() { - let conf = 1.2; + let conf: f64 = 1.2; let bounded = conf.min(1.0); assert_eq!(bounded, 1.0); diff --git a/tests/it_path_finding_4_4.rs b/tests/it_path_finding_4_4.rs index 70da5ae..211b0ba 100644 --- a/tests/it_path_finding_4_4.rs +++ b/tests/it_path_finding_4_4.rs @@ -56,8 +56,8 @@ mod tests { /// Test: Confidence normalization (0-1) #[test] fn test_confidence_normalization() { - let confidence = 0.5 * 0.6 * 0.7 * 0.8; // 0.168 - let normalized = confidence.max(0.0).min(1.0); + let confidence: f32 = 0.5 * 0.6 * 0.7 * 0.8; // 0.168 + let normalized = confidence.max(0.0_f32).min(1.0_f32); assert!(normalized >= 0.0 && normalized <= 1.0); } @@ -315,8 +315,8 @@ mod tests { /// Test: Performance - path finding with moderate graph #[test] fn test_path_finding_performance() { - // Simulate finding path in 100-node graph - let nodes = 100; + // Simulate finding path in 1000-node graph + let nodes = 1000; let max_depth = 5; // BFS explores at most m^d nodes (m=avg_degree, d=depth) diff --git a/tests/it_query_reasoning_5_3.rs b/tests/it_query_reasoning_5_3.rs index 32265ae..793e3da 100644 --- a/tests/it_query_reasoning_5_3.rs +++ b/tests/it_query_reasoning_5_3.rs @@ -342,11 +342,11 @@ mod tests { /// Test: Answer confidence averaging #[test] fn test_confidence_averaging() { - let conf1 = 0.9; + let conf1: f64 = 0.9; let conf2 = 0.8; let avg = (conf1 + conf2) / 2.0; - assert!((avg - 0.85).abs() < 0.01); + assert!((avg - 0.85_f64).abs() < 0.01); } /// Test: Answer deduplication diff --git a/tests/it_semantic_retrieval_4_1.rs b/tests/it_semantic_retrieval_4_1.rs index 1c2fc11..6b80c05 100644 --- a/tests/it_semantic_retrieval_4_1.rs +++ b/tests/it_semantic_retrieval_4_1.rs @@ -67,7 +67,7 @@ mod tests { /// Test: Score normalization (clamped to 0.0-1.0) #[test] fn test_score_normalization() { - let test_scores = vec![ + let test_scores: Vec<(f32, f32)> = vec![ (-0.5, 0.0), // Negative → 0.0 (0.0, 0.0), // Valid → 0.0 (0.5, 0.5), // Valid → 0.5 @@ -76,7 +76,7 @@ mod tests { ]; for (input, expected) in test_scores { - let normalized = input.max(0.0).min(1.0); + let normalized = input.max(0.0_f32).min(1.0_f32); assert_eq!(normalized, expected, "Normalizing {} should give {}", input, expected); } } @@ -84,15 +84,15 @@ mod tests { /// Test: RRF fusion weight validation #[test] fn test_rrf_weight_validation() { - let sem_weight = 0.6; - let lex_weight = 0.4; + let sem_weight: f32 = 0.6; + let lex_weight: f32 = 0.4; assert!(sem_weight >= 0.0 && sem_weight <= 1.0); assert!(lex_weight >= 0.0 && lex_weight <= 1.0); // Weights should be normalized - let sem_normalized = sem_weight.max(0.0).min(1.0); - let lex_normalized = lex_weight.max(0.0).min(1.0); + let sem_normalized = sem_weight.max(0.0_f32).min(1.0_f32); + let lex_normalized = lex_weight.max(0.0_f32).min(1.0_f32); assert_eq!(sem_normalized, 0.6); assert_eq!(lex_normalized, 0.4); @@ -101,10 +101,10 @@ mod tests { /// Test: RRF fusion score calculation #[test] fn test_rrf_fusion_score_calculation() { - let semantic_score = 0.92; - let lexical_score = 0.85; - let sem_weight = 0.6; - let lex_weight = 0.4; + let semantic_score: f32 = 0.92; + let lexical_score: f32 = 0.85; + let sem_weight: f32 = 0.6; + let lex_weight: f32 = 0.4; let fused_score = (sem_weight * semantic_score) + (lex_weight * lexical_score); diff --git a/tests/it_summarization_5_4.rs b/tests/it_summarization_5_4.rs index a5dda49..d279eff 100644 --- a/tests/it_summarization_5_4.rs +++ b/tests/it_summarization_5_4.rs @@ -308,7 +308,7 @@ mod tests { let unique_words = 15; let total_words = 20; - assert!(unique_words as f32 / total_words as f32 < 1.0); + assert!((unique_words as f32 / total_words as f32) < 1.0); } /// Test: Key fact count limit @@ -337,7 +337,7 @@ mod tests { let c3 = 0.7; let avg = (c1 + c2 + c3) / 3.0; - assert!((avg - 0.8).abs() < 0.1); + assert!((avg - 0.8_f32).abs() < 0.1); } /// Test: Content length calculation diff --git a/tests/it_temporal_filtering_4_2_fixed.rs b/tests/it_temporal_filtering_4_2_fixed.rs index 908ff54..ea669d3 100644 --- a/tests/it_temporal_filtering_4_2_fixed.rs +++ b/tests/it_temporal_filtering_4_2_fixed.rs @@ -339,7 +339,7 @@ mod tests { /// Test: Date-based filtering (whole day ranges) #[test] fn test_temporal_whole_day_range() { - let start_of_day = Utc::now().with_hour(0).unwrap().with_minute(0).unwrap().with_second(0).unwrap(); + let start_of_day = Utc::now().date_naive().and_hms_opt(0, 0, 0).unwrap().and_utc(); let end_of_day = start_of_day + Duration::days(1); assert!(end_of_day > start_of_day);