diff --git a/crates/aiwar-ingest/src/encounter_round.rs b/crates/aiwar-ingest/src/encounter_round.rs index f917caacb..03dd39ffa 100644 --- a/crates/aiwar-ingest/src/encounter_round.rs +++ b/crates/aiwar-ingest/src/encounter_round.rs @@ -78,10 +78,10 @@ pub fn confidence_for_file(filename: &str) -> f64 { fn version_for_file(filename: &str) -> u32 { // Check for explicit version numbers v31..v99 let re = Regex::new(r"v(\d{2,})").expect("valid regex"); - if let Some(caps) = re.captures(filename) { - if let Ok(v) = caps[1].parse::() { - return v; - } + if let Some(caps) = re.captures(filename) + && let Ok(v) = caps[1].parse::() + { + return v; } if filename.contains("aiwar_full") { 0 @@ -273,10 +273,7 @@ pub fn load_encounter_rounds(cypher_dir: &Path) -> Result, s let confidence = confidence_for_file(&filename); let (nodes, edges) = parse_cypher(&text); - let name = filename - .trim_end_matches(".cypher") - .replace('_', " ") - .to_string(); + let name = filename.trim_end_matches(".cypher").replace('_', " "); rounds.push(EncounterRound { version, @@ -358,8 +355,8 @@ mod tests { assert_eq!(edges.len(), 0); assert_eq!(nodes[0].id, "Maven"); assert_eq!(nodes[0].labels, vec!["System"]); - assert_eq!(nodes[0].properties.get("name").unwrap(), "Project Maven"); - assert_eq!(nodes[0].properties.get("year").unwrap(), "2017"); + assert_eq!(&nodes[0].properties["name"], "Project Maven"); + assert_eq!(&nodes[0].properties["year"], "2017"); } #[test] @@ -383,7 +380,7 @@ mod tests { assert_eq!(edges[0].source, "A"); assert_eq!(edges[0].target, "B"); assert_eq!(edges[0].rel_type, "DEVELOPED_BY"); - assert_eq!(edges[0].properties.get("weight").unwrap(), "3"); + assert_eq!(&edges[0].properties["weight"], "3"); // both endpoints were also declared as nodes assert_eq!(nodes.len(), 2); } @@ -442,7 +439,7 @@ mod tests { assert_eq!(full_edges[0].target, "Hegseth"); assert_eq!(full_edges[0].rel_type, "PERSON_LINK"); assert_eq!( - full_edges[0].properties.get("label").unwrap(), + &full_edges[0].properties["label"], "appointed SecDef" ); } @@ -450,17 +447,17 @@ mod tests { #[test] fn test_parse_property_block() { let props = parse_property_block("id: 'test', name: 'Hello World', weight: 42"); - assert_eq!(props.get("id").unwrap(), "test"); - assert_eq!(props.get("name").unwrap(), "Hello World"); - assert_eq!(props.get("weight").unwrap(), "42"); + assert_eq!(&props["id"], "test"); + assert_eq!(&props["name"], "Hello World"); + assert_eq!(&props["weight"], "42"); } #[test] fn test_parse_set_clause() { let props = parse_set_clause("r.label='test edge', r.weight=5, r.source='Reuters'"); - assert_eq!(props.get("label").unwrap(), "test edge"); - assert_eq!(props.get("weight").unwrap(), "5"); - assert_eq!(props.get("source").unwrap(), "Reuters"); + assert_eq!(&props["label"], "test edge"); + assert_eq!(&props["weight"], "5"); + assert_eq!(&props["source"], "Reuters"); } #[test] diff --git a/crates/aiwar-ingest/src/lib.rs b/crates/aiwar-ingest/src/lib.rs index d740223b6..496a89b47 100644 --- a/crates/aiwar-ingest/src/lib.rs +++ b/crates/aiwar-ingest/src/lib.rs @@ -351,17 +351,17 @@ pub fn load_with_enrichment( cypher_dir: &Path, ) -> Result { let mut graph = load_from_file(graph_json_path)?; - if cypher_dir.is_dir() { - if let Ok(rounds) = encounter_round::load_encounter_rounds(cypher_dir) { - for round in &rounds { - graph.apply_round(round); - } - tracing::info!( - "aiwar-ingest: applied {} enrichment rounds from {}", - rounds.len(), - cypher_dir.display() - ); + if cypher_dir.is_dir() + && let Ok(rounds) = encounter_round::load_encounter_rounds(cypher_dir) + { + for round in &rounds { + graph.apply_round(round); } + tracing::info!( + "aiwar-ingest: applied {} enrichment rounds from {}", + rounds.len(), + cypher_dir.display() + ); } tracing::info!( "aiwar-ingest: loaded {} nodes, {} edges", @@ -406,11 +406,11 @@ mod tests { assert_eq!(maven.label, "Project Maven"); // non id/name fields preserved verbatim assert_eq!( - maven.properties.get("year").unwrap(), + &maven.properties["year"], &serde_json::json!(2017) ); assert_eq!( - maven.properties.get("MLTask").unwrap(), + &maven.properties["MLTask"], &serde_json::json!("object-detection") ); @@ -433,7 +433,7 @@ mod tests { assert_eq!(dev.target, "Palantir"); assert_eq!(dev.weight, 3.0); assert_eq!( - dev.properties.get("label").unwrap(), + &dev.properties["label"], &serde_json::json!("builds") ); @@ -553,6 +553,6 @@ mod tests { assert_eq!(g.node_count(), 4); let maven = g.nodes.iter().find(|n| n.id == "Maven").unwrap(); // a real number is preserved verbatim (sanitizer only touches non-finite). - assert_eq!(maven.properties.get("year").unwrap(), &serde_json::json!(2017)); + assert_eq!(&maven.properties["year"], &serde_json::json!(2017)); } } diff --git a/crates/cockpit-server/src/main.rs b/crates/cockpit-server/src/main.rs index 37b3cac10..927816376 100644 --- a/crates/cockpit-server/src/main.rs +++ b/crates/cockpit-server/src/main.rs @@ -17,7 +17,7 @@ use std::sync::Arc; use std::time::Duration; use axum::extract::State; -use axum::http::{StatusCode, header}; +use axum::http::StatusCode; use axum::response::sse::{Event, Sse}; use axum::response::{Html, IntoResponse, Response}; use axum::routing::{get, post}; @@ -1015,7 +1015,7 @@ async fn style_handler( async fn strategy_check_handler() -> Json { // Run in a blocking thread since strategy checks may be CPU-intensive let result = - tokio::task::spawn_blocking(|| notebook_query::diagnostics::run_strategy_checks()).await; + tokio::task::spawn_blocking(notebook_query::diagnostics::run_strategy_checks).await; match result { Ok(matrix) => Json(serde_json::to_value(matrix).unwrap_or_default()), @@ -1345,19 +1345,18 @@ async fn orchestrator_step_handler( let mut orch = get_orchestrator().lock().unwrap(); // If quality is provided, record the outcome of the previous step. - if let Some(Json(body)) = body { - if let Some(quality) = body.get("quality").and_then(|v| v.as_f64()) { - if let Some(style_name) = body.get("style").and_then(|v| v.as_str()) { - let style = match style_name { - "plan" => notebook_query::orchestrator::AgentStyle::Plan, - "act" => notebook_query::orchestrator::AgentStyle::Act, - "explore" => notebook_query::orchestrator::AgentStyle::Explore, - "reflex" => notebook_query::orchestrator::AgentStyle::Reflex, - _ => notebook_query::orchestrator::AgentStyle::Plan, - }; - orch.record_outcome(style, quality as f32); - } - } + if let Some(Json(body)) = body + && let Some(quality) = body.get("quality").and_then(|v| v.as_f64()) + && let Some(style_name) = body.get("style").and_then(|v| v.as_str()) + { + let style = match style_name { + "plan" => notebook_query::orchestrator::AgentStyle::Plan, + "act" => notebook_query::orchestrator::AgentStyle::Act, + "explore" => notebook_query::orchestrator::AgentStyle::Explore, + "reflex" => notebook_query::orchestrator::AgentStyle::Reflex, + _ => notebook_query::orchestrator::AgentStyle::Plan, + }; + orch.record_outcome(style, quality as f32); } let result = orch.select_next(); @@ -1414,7 +1413,7 @@ async fn analyst_analyze_handler( /// Run all 6 analysis buckets. async fn analyst_full_handler() -> Json { - let result = tokio::task::spawn_blocking(|| notebook_query::analyst::full_analysis()).await; + let result = tokio::task::spawn_blocking(notebook_query::analyst::full_analysis).await; match result { Ok(analyses) => Json(serde_json::to_value(analyses).unwrap_or_default()), @@ -1465,7 +1464,7 @@ async fn data_status_handler() -> Json { .map(|entries| { entries .filter_map(|e| e.ok()) - .filter(|e| e.path().extension().map_or(false, |ext| ext == "cypher")) + .filter(|e| e.path().extension().is_some_and(|ext| ext == "cypher")) .count() }) .unwrap_or(0); diff --git a/crates/cockpit-server/src/openai.rs b/crates/cockpit-server/src/openai.rs index 1d8da4018..f4fed68e5 100644 --- a/crates/cockpit-server/src/openai.rs +++ b/crates/cockpit-server/src/openai.rs @@ -387,7 +387,7 @@ async fn create_chat_completion( .iter() .filter(|m| m.role == "user") .filter_map(|m| m.content.as_deref()) - .last() + .next_back() .unwrap_or(""); Json(ChatCompletionResp { @@ -417,7 +417,7 @@ async fn create_chat_completion( } async fn create_embedding( - State(state): State, + State(_state): State, Json(req): Json, ) -> Json { let model = req.model.unwrap_or_else(|| "gpt2".into()); @@ -441,7 +441,7 @@ async fn create_embedding( } async fn create_image( - State(state): State, + State(_state): State, Json(req): Json, ) -> Json { let n = req.n.unwrap_or(1); diff --git a/crates/cockpit-server/src/osint_gotham.rs b/crates/cockpit-server/src/osint_gotham.rs index 18f2c485f..629a8d816 100644 --- a/crates/cockpit-server/src/osint_gotham.rs +++ b/crates/cockpit-server/src/osint_gotham.rs @@ -537,11 +537,11 @@ fn theme_stem(source_file: &str) -> String { s = t.to_string(); continue; } - if let Some((head, tail)) = s.rsplit_once('_') { - if is_version_token(tail) { - s = head.to_string(); - continue; - } + if let Some((head, tail)) = s.rsplit_once('_') + && is_version_token(tail) + { + s = head.to_string(); + continue; } break; } @@ -1125,10 +1125,10 @@ pub fn osint_soa_bytes(graph: &AiWarGraph, rounds: &[EncounterRound]) -> Vec // — no synthetic hub, no self-loop on the anchor itself. for (i, r) in rows.iter().enumerate() { let basin = (r.key.family_v2() & 0xFF) as u8; - if let Some(&a) = anchor_idx.get(&basin) { - if a != i { - push_edge(&mut edges, i, a, rel_code("member-of")); - } + if let Some(&a) = anchor_idx.get(&basin) + && a != i + { + push_edge(&mut edges, i, a, rel_code("member-of")); } let ifaces: std::collections::BTreeSet = r .edges @@ -1139,10 +1139,10 @@ pub fn osint_soa_bytes(graph: &AiWarGraph, rounds: &[EncounterRound]) -> Vec .filter(|&b| b != 0 && b != basin) .collect(); for b in ifaces { - if let Some(&a) = anchor_idx.get(&b) { - if a != i { - push_edge(&mut edges, i, a, rel_code("interfaces")); - } + if let Some(&a) = anchor_idx.get(&b) + && a != i + { + push_edge(&mut edges, i, a, rel_code("interfaces")); } } } @@ -1154,7 +1154,7 @@ pub fn osint_soa_bytes(graph: &AiWarGraph, rounds: &[EncounterRound]) -> Vec // foveal view can show "Fortify", not just a class. Old readers stop after // `edges`; new readers consume this tail. let mut labels: Vec = Vec::new(); - let mut push_label = |buf: &mut Vec, s: &str| { + let push_label = |buf: &mut Vec, s: &str| { let b = s.as_bytes(); let l = b.len().min(255); buf.push(l as u8); diff --git a/crates/cockpit-server/src/osm_features.rs b/crates/cockpit-server/src/osm_features.rs index 4570b58ea..4bfdb8a3a 100644 --- a/crates/cockpit-server/src/osm_features.rs +++ b/crates/cockpit-server/src/osm_features.rs @@ -793,11 +793,11 @@ fn feature_ordinals(bytes: &[u8], idx: usize) -> (Vec, Vec, Vec) let mut key_ordinals = Vec::new(); let mut value_ordinals = Vec::new(); for (_slot, facet) in osm_soa_bake::cluster::facets(row) { - if let osm_soa_bake::cluster::Facet::Tag { member, key, value } = facet { - if member == ordinal { - key_ordinals.push(key); - value_ordinals.push(value); - } + if let osm_soa_bake::cluster::Facet::Tag { member, key, value } = facet + && member == ordinal + { + key_ordinals.push(key); + value_ordinals.push(value); } } (vec![ordinal], key_ordinals, value_ordinals) @@ -1647,11 +1647,11 @@ async fn tile_sources<'a>( }; ordinals.push(ordinal); for (_slot, facet) in osm_soa_bake::cluster::facets(&rows[i]) { - if let osm_soa_bake::cluster::Facet::Tag { member, key, value } = facet { - if member == ordinal { - key_ordinals.push(key); - value_ordinals.push(value); - } + if let osm_soa_bake::cluster::Facet::Tag { member, key, value } = facet + && member == ordinal + { + key_ordinals.push(key); + value_ordinals.push(value); } } } @@ -1938,7 +1938,7 @@ mod tests { let books_path = dir.path().join("region.books"); { use lance_graph_contract::identity_quad::IdentityCodebook; - use osm_soa_bake::codebook::{Books, Header}; + use osm_soa_bake::codebook::Books; let books = Books { identities: IdentityCodebook::try_new(vec!["node/1".into()]).unwrap(), tag_keys: IdentityCodebook::try_new(vec!["highway".into()]).unwrap(), @@ -2465,7 +2465,7 @@ mod tests { /// /// What went wrong, recorded so it is not repeated: the first fix replaced /// head-truncation with stride sampling and asserted the result covered - /// >=95% of the tile's EXTENT. That assertion is unfalsifiable for this + /// \>=95% of the tile's EXTENT. That assertion is unfalsifiable for this /// defect. A uniform stride covers ~100% of a bounding box at ANY stride — /// measured on this very fixture shape, the >=0.95 assertion passes while /// keeping 25% of rows, and still passes while keeping 5.9%. It certified diff --git a/crates/cockpit-server/src/osm_lance.rs b/crates/cockpit-server/src/osm_lance.rs index 48d8963cb..45765cd9a 100644 --- a/crates/cockpit-server/src/osm_lance.rs +++ b/crates/cockpit-server/src/osm_lance.rs @@ -232,15 +232,15 @@ pub async fn ensure_lance_local(slab_path: &Path) -> Option { // the stale directory cannot be removed, do NOT write into it (that // is exactly how a 4-file `data/` happens) — keep serving from the // `.soa` unchanged. - if dest.exists() { - if let Err(e) = remove_stale_dataset(&dest) { - tracing::error!( - path = %dest.display(), error = %e, - "osm lance: cannot remove the stale dataset; refusing to write \ - into it — the raw .soa slab keeps serving the map" - ); - return None; - } + if dest.exists() + && let Err(e) = remove_stale_dataset(&dest) + { + tracing::error!( + path = %dest.display(), error = %e, + "osm lance: cannot remove the stale dataset; refusing to write \ + into it — the raw .soa slab keeps serving the map" + ); + return None; } tracing::info!( diff --git a/crates/cockpit-server/src/osm_slab_hydrate.rs b/crates/cockpit-server/src/osm_slab_hydrate.rs index 97a1f1e66..d0d51f710 100644 --- a/crates/cockpit-server/src/osm_slab_hydrate.rs +++ b/crates/cockpit-server/src/osm_slab_hydrate.rs @@ -291,9 +291,7 @@ pub async fn ensure_slab_local() -> Option { crate::osm_region_catalogue::publish(catalogue, active); - let Some(slab) = active_path else { - return None; - }; + let slab = active_path?; tracing::info!(path = %slab.display(), "osm slab: hydrated and verified"); Some(slab) } diff --git a/crates/cockpit-server/src/osm_tiles.rs b/crates/cockpit-server/src/osm_tiles.rs index bc74e8c73..17f4bdfcd 100644 --- a/crates/cockpit-server/src/osm_tiles.rs +++ b/crates/cockpit-server/src/osm_tiles.rs @@ -289,7 +289,7 @@ mod tests { // Asserting `== y` directly would fail; asserting the *raw* recovered // value equals some constant would pass against a key that mirrors the // world about the equator. Neither is what we want to pin. - let (z, x, y) = (HHTL_DEPTH, 0x00AB_12u32, 0x00CD_34u32); + let (z, x, y) = (HHTL_DEPTH, 0x0000_AB12_u32, 0x0000_CD34_u32); let h = tile_to_hhtl(z, x, y); let code = (u64::from(h.heel) << 48) | (u64::from(h.hip) << 32) diff --git a/crates/cockpit-server/src/shader_stream.rs b/crates/cockpit-server/src/shader_stream.rs index afd9da5f0..0913dca7d 100644 --- a/crates/cockpit-server/src/shader_stream.rs +++ b/crates/cockpit-server/src/shader_stream.rs @@ -57,7 +57,7 @@ use serde::Serialize; use tokio::sync::RwLock; use lance_graph_contract::cognitive_shader::{ - CognitiveShaderDriver, ShaderBus, ShaderCrystal, ShaderDispatch, ShaderResonance, ShaderSink, + CognitiveShaderDriver, ShaderBus, ShaderCrystal, ShaderResonance, ShaderSink, }; use lance_graph_contract::cycle_accumulator::{AccumulatorAction, CycleAccumulator}; diff --git a/crates/neural-debug/src/diagnosis.rs b/crates/neural-debug/src/diagnosis.rs index b50611566..193a59d59 100644 --- a/crates/neural-debug/src/diagnosis.rs +++ b/crates/neural-debug/src/diagnosis.rs @@ -5,7 +5,7 @@ use std::collections::{HashMap, HashSet}; use serde::{Deserialize, Serialize}; use crate::registry::{FunctionMeta, ModuleSummary, NeuronState}; -use crate::instrument::{self, CallStats}; +use crate::instrument; /// Diagnosis for a single function. #[derive(Debug, Clone, Serialize, Deserialize)] diff --git a/crates/neural-debug/src/instrument.rs b/crates/neural-debug/src/instrument.rs index 4628b95b3..4b9acf118 100644 --- a/crates/neural-debug/src/instrument.rs +++ b/crates/neural-debug/src/instrument.rs @@ -50,7 +50,7 @@ fn counters() -> parking_lot::MutexGuard<'static, Option> { #[inline] pub fn track(_function_id: &str, f: impl FnOnce() -> T) -> T { #[cfg(not(feature = "instrument"))] - { return f(); } + { f() } #[cfg(feature = "instrument")] { @@ -72,7 +72,7 @@ pub fn track(_function_id: &str, f: impl FnOnce() -> T) -> T { #[inline] pub fn track_numeric(_function_id: &str, value: f32) -> f32 { #[cfg(not(feature = "instrument"))] - { return value; } + { value } #[cfg(feature = "instrument")] { @@ -98,7 +98,7 @@ pub fn track_numeric(_function_id: &str, value: f32) -> f32 { #[inline] pub fn track_numeric_f64(_function_id: &str, value: f64) -> f64 { #[cfg(not(feature = "instrument"))] - { return value; } + { value } #[cfg(feature = "instrument")] { diff --git a/crates/pampa/tests/integration/test.rs b/crates/pampa/tests/integration/test.rs index 0d217fa2d..03ae61596 100644 --- a/crates/pampa/tests/integration/test.rs +++ b/crates/pampa/tests/integration/test.rs @@ -38,7 +38,7 @@ fn unit_test_simple_qmd_parses() { ) .unwrap(); let ast = String::from_utf8(buf).expect("Invalid UTF-8 in output"); - println!("{}", &ast); + println!("{}", ast); assert!(true, "Parsed successfully"); } } @@ -67,7 +67,7 @@ fn test_unnumbered_section_specifier() { ) .unwrap(); let ast = String::from_utf8(buf).expect("Invalid UTF-8 in output"); - println!("Output AST: {}", &ast); + println!("Output AST: {}", ast); // The output should contain the "unnumbered" class assert!( diff --git a/crates/pampa/tests/integration/test_treesitter_coverage.rs b/crates/pampa/tests/integration/test_treesitter_coverage.rs index 1cfeea670..20f7eee50 100644 --- a/crates/pampa/tests/integration/test_treesitter_coverage.rs +++ b/crates/pampa/tests/integration/test_treesitter_coverage.rs @@ -73,7 +73,7 @@ fn test_block_quote_outside_list() { assert!( matches!(&pandoc.blocks[0], Block::BlockQuote(_)), "Expected BlockQuote, got {:?}", - &pandoc.blocks[0] + pandoc.blocks[0] ); } diff --git a/crates/quarto-core/src/engine/capture_splice.rs b/crates/quarto-core/src/engine/capture_splice.rs index 97c66599a..015818fb2 100644 --- a/crates/quarto-core/src/engine/capture_splice.rs +++ b/crates/quarto-core/src/engine/capture_splice.rs @@ -439,7 +439,7 @@ mod tests { }; assert_eq!(s.text, "hello edited"); } else { - panic!("expected paragraph, got {:?}", &out.blocks[0]); + panic!("expected paragraph, got {:?}", out.blocks[0]); } // Second block is the spliced wrapper. assert_eq!(first_div_marker(&out.blocks[1]), Some("X1")); diff --git a/crates/quarto-core/src/pipeline.rs b/crates/quarto-core/src/pipeline.rs index 99864f1fb..bd0656bdb 100644 --- a/crates/quarto-core/src/pipeline.rs +++ b/crates/quarto-core/src/pipeline.rs @@ -1537,21 +1537,21 @@ mod tests { .html .contains("def"), "expected hl-keyword span around `def`; got:\n{}", - &output.html, + output.html, ); assert!( output .html .contains("print"), "expected hl-function-builtin span around `print`; got:\n{}", - &output.html, + output.html, ); // The raw `data-hl-spans` attribute must not leak to the container. assert!( !output.html.contains("data-hl-spans="), "container should not carry the raw data-hl-spans attr; got:\n{}", - &output.html, + output.html, ); // The `.sourceCode` marker should be present so default themes @@ -1683,7 +1683,7 @@ mod tests { assert!( output.html.contains("test_files/styles.css"), "expected `` from the resolver; got:\n{}", - &output.html, + output.html, ); } @@ -1724,19 +1724,19 @@ mod tests { .html .contains("def"), "expected hl-keyword span around `def` on the CLI path; got:\n{}", - &output.html, + output.html, ); assert!( output .html .contains("print"), "expected hl-function-builtin span around `print` on the CLI path; got:\n{}", - &output.html, + output.html, ); assert!( !output.html.contains("data-hl-spans="), "container should not carry the raw data-hl-spans attr; got:\n{}", - &output.html, + output.html, ); } @@ -2327,17 +2327,17 @@ mod tests { assert!( output.html.contains("Replayed Heading"), "rendered HTML must contain the replay engine's heading; got:\n{}", - &output.html, + output.html, ); assert!( output.html.contains("Replayed body marker XYZ"), "rendered HTML must contain the replay marker; got:\n{}", - &output.html, + output.html, ); assert!( !output.html.contains("Original body"), "rendered HTML must not contain the original body — replay should override; got:\n{}", - &output.html, + output.html, ); } diff --git a/crates/quarto-core/src/transforms/shortcode_resolve.rs b/crates/quarto-core/src/transforms/shortcode_resolve.rs index f2ef0c289..f5136589e 100644 --- a/crates/quarto-core/src/transforms/shortcode_resolve.rs +++ b/crates/quarto-core/src/transforms/shortcode_resolve.rs @@ -2393,7 +2393,7 @@ mod tests { panic!("Expected Paragraph"); }; let Inline::Str(s) = ¶.content[0] else { - panic!("Expected resolved Str, got {:?}", ¶.content[0]); + panic!("Expected resolved Str, got {:?}", para.content[0]); }; assert_eq!(s.text, "Hello typed"); match &s.source_info { diff --git a/crates/quarto-core/tests/integration/replay_engine.rs b/crates/quarto-core/tests/integration/replay_engine.rs index 6b6845d9b..b332f2efc 100644 --- a/crates/quarto-core/tests/integration/replay_engine.rs +++ b/crates/quarto-core/tests/integration/replay_engine.rs @@ -171,12 +171,12 @@ fn replay_capture_in_options_overrides_engine_through_render_to_file() { assert!( html.contains("Replayed Heading"), "rendered HTML must carry replay heading; got first 400 chars:\n{}", - &html.chars().take(400).collect::() + html.chars().take(400).collect::() ); assert!( html.contains("Distinct replay marker QQQ"), "rendered HTML must carry replay marker; got first 400 chars:\n{}", - &html.chars().take(400).collect::() + html.chars().take(400).collect::() ); assert!( !html.contains("Original body line"), diff --git a/crates/quarto-core/tests/integration/website_post_render.rs b/crates/quarto-core/tests/integration/website_post_render.rs index 066d9dccd..90dede680 100644 --- a/crates/quarto-core/tests/integration/website_post_render.rs +++ b/crates/quarto-core/tests/integration/website_post_render.rs @@ -530,7 +530,7 @@ fn pipeline_website_post_render_substitutes_listing_placeholders() { assert!( !host.contains("desc-begin(5A0113B34292)"), "begin marker must be stripped from rendered host; got first 800 chars:\n{}", - &host.chars().take(800).collect::() + host.chars().take(800).collect::() ); assert!( !host.contains("desc-end(5A0113B34292)"), @@ -658,7 +658,7 @@ fn pipeline_default_project_does_not_substitute_listing_placeholders() { assert!( html.contains("desc-begin(5A0113B34292)"), "default project must not invoke L7 substitution; markers should survive. Got first 800 chars:\n{}", - &html.chars().take(800).collect::() + html.chars().take(800).collect::() ); assert!( html.contains("desc-end(5A0113B34292)"), diff --git a/crates/quarto-hub/src/auth.rs b/crates/quarto-hub/src/auth.rs index 3769bfdb7..29492ffdc 100644 --- a/crates/quarto-hub/src/auth.rs +++ b/crates/quarto-hub/src/auth.rs @@ -453,8 +453,7 @@ fn validate_discovery_document( // loopback + --allow-insecure-auth gate in AuthConfig::new(), so an // http issuer here is evidence of an explicitly-insecure dev setup. let issuer_is_http_loopback = url::Url::parse(configured_issuer) - .ok() - .is_some_and(|u| u.scheme() == "http" && u.host_str().is_some_and(is_loopback_host)); + .is_ok_and(|u| u.scheme() == "http" && u.host_str().is_some_and(is_loopback_host)); let jwks_is_http_loopback = jwks_url.scheme() == "http" && jwks_url.host_str().is_some_and(is_loopback_host); if issuer_is_http_loopback && jwks_is_http_loopback { diff --git a/crates/quarto-trace/tests/roundtrip.rs b/crates/quarto-trace/tests/roundtrip.rs index a483759c9..445cb9048 100644 --- a/crates/quarto-trace/tests/roundtrip.rs +++ b/crates/quarto-trace/tests/roundtrip.rs @@ -157,14 +157,14 @@ fn test_writer_emits_compact_json_on_disk() { assert!( !s.contains("\n "), "trace file appears to be pretty-printed (found indented line); first 200 bytes: {:?}", - &s.chars().take(200).collect::() + s.chars().take(200).collect::() ); // Pretty output also starts with `{\n "schema_version"`; compact // starts with `{"schema_version"`. assert!( s.starts_with("{\"schema_version\""), "expected compact start, got: {:?}", - &s.chars().take(40).collect::() + s.chars().take(40).collect::() ); // Sanity: still parses back to an equivalent doc. diff --git a/crates/stubs/graph-flow/src/storage.rs b/crates/stubs/graph-flow/src/storage.rs index f8e396dc9..351a629e3 100644 --- a/crates/stubs/graph-flow/src/storage.rs +++ b/crates/stubs/graph-flow/src/storage.rs @@ -13,6 +13,12 @@ pub struct Session { current_node: String, } +impl Default for Session { + fn default() -> Self { + Self::new() + } +} + impl Session { pub fn new() -> Self { Self { @@ -50,6 +56,12 @@ pub struct SessionContext { data: Arc>>, } +impl Default for SessionContext { + fn default() -> Self { + Self::new() + } +} + impl SessionContext { pub fn new() -> Self { Self { diff --git a/crates/stubs/notebook-query/src/analyst.rs b/crates/stubs/notebook-query/src/analyst.rs index 28a487d3d..9f2f76940 100644 --- a/crates/stubs/notebook-query/src/analyst.rs +++ b/crates/stubs/notebook-query/src/analyst.rs @@ -5,9 +5,7 @@ //! relationships, runs NARS deduction/abduction/induction, builds //! causal chains, and projects forward. -use crate::reasoning::{ - infer_edges, nars_deduction, InferenceType, TruthEdge, TruthValue, -}; +use crate::reasoning::{infer_edges, TruthEdge, TruthValue}; use serde::{Deserialize, Serialize}; use std::collections::HashMap; @@ -80,7 +78,16 @@ struct RawGraph { } #[derive(Debug, Deserialize)] -struct RawNode { id: Option, name: Option, #[serde(rename = "type")] node_type: Option } +struct RawNode { + id: Option, + name: Option, + // Kept, though nothing reads it: this struct documents the shape of + // `aiwar_graph.json`, and dropping the field would make the type a + // partial and misleading record of the file it parses. + #[expect(dead_code, reason = "documents the on-disk JSON shape")] + #[serde(rename = "type")] + node_type: Option, +} #[derive(Debug, Deserialize)] struct RawEdge { source: Option, target: Option, label: Option } @@ -305,7 +312,7 @@ fn build_chains(edges: &[TruthEdge], node_map: &HashMap (ProbeStatus::Error, Some(format!("{:?}", e)), vec![]), Err(panic) => { let msg = panic.downcast_ref::() - .map(|s| s.clone()) + .cloned() .or_else(|| panic.downcast_ref::<&str>().map(|s| s.to_string())) .unwrap_or_else(|| "unknown panic".to_string()); if msg.contains("not yet implemented") || msg.contains("todo") { diff --git a/crates/stubs/notebook-query/src/lib.rs b/crates/stubs/notebook-query/src/lib.rs index a70beeb51..04c16ace2 100644 --- a/crates/stubs/notebook-query/src/lib.rs +++ b/crates/stubs/notebook-query/src/lib.rs @@ -279,33 +279,33 @@ fn execute_graph_query(source: &str, language: QueryLanguage) -> Result { - let elapsed_ms = t0.elapsed().as_millis() as u64; - return Ok(QueryResult { - language, - raw_output: format!( - "{lang_name} → Cypher: {cypher}\n\n{}", - batch_to_text(&batch) - ), - html: Some(format!( - "
\ -
{lang_name} → Cypher
\ -
{cypher}
{}
", - batch_to_html(&batch) - )), - graph_json: aiwar_graph_json().ok(), - elapsed_ms, - planner_info, - }); - } - Err(e) => { - eprintln!( - "[gremlin] transpiled `{cypher}` failed: {e} — falling back to graph echo" - ); - } + if language == QueryLanguage::Gremlin + && let Some(cypher) = gremlin::gremlin_to_cypher(source) + { + match run_cypher_on_aiwar(&cypher) { + Ok(batch) => { + let elapsed_ms = t0.elapsed().as_millis() as u64; + return Ok(QueryResult { + language, + raw_output: format!( + "{lang_name} → Cypher: {cypher}\n\n{}", + batch_to_text(&batch) + ), + html: Some(format!( + "
\ +
{lang_name} → Cypher
\ +
{cypher}
{}
", + batch_to_html(&batch) + )), + graph_json: aiwar_graph_json().ok(), + elapsed_ms, + planner_info, + }); + } + Err(e) => { + eprintln!( + "[gremlin] transpiled `{cypher}` failed: {e} — falling back to graph echo" + ); } } } @@ -1471,10 +1471,16 @@ pub fn extract_graph_truth_edges() -> Result, String> if let (Some(source), Some(target)) = (src, tgt) { // Check for weight column - let (freq, conf) = if let Some(wi) = schema.index_of("weight").ok() { + let (freq, conf) = if let Ok(wi) = schema.index_of("weight") { get_string_value(batch, wi, row) .and_then(|w| w.parse::().ok()) - .map(|w| (w.min(1.0).max(0.0), *default_conf)) + // `clamp` is not the same as the old + // `.min(1.0).max(0.0)` for a non-finite weight: + // that chain silently turned NaN into 1.0, i.e. + // maximum confidence. Drop non-finite weights + // and fall back to the default instead. + .filter(|w| w.is_finite()) + .map(|w| (w.clamp(0.0, 1.0), *default_conf)) .unwrap_or((*default_freq, *default_conf)) } else { (*default_freq, *default_conf) diff --git a/crates/stubs/notebook-query/src/mri.rs b/crates/stubs/notebook-query/src/mri.rs index a718e4f88..38367a29d 100644 --- a/crates/stubs/notebook-query/src/mri.rs +++ b/crates/stubs/notebook-query/src/mri.rs @@ -15,9 +15,7 @@ use serde::{Deserialize, Serialize}; use std::collections::HashMap; use super::osint_audit::{osint_registry, OsintCounterSnapshot}; -use super::reasoning::{ - nars_abduction, nars_deduction, nars_induction, InferenceType, TruthEdge, TruthValue, -}; +use super::reasoning::{InferenceType, TruthEdge, TruthValue}; // ============================================================================ // Brain Region Model @@ -229,7 +227,7 @@ pub fn run_brain_mri( .iter() .map(|(style, cluster, count, quality)| { let effectiveness = if *count > 0 { - TruthValue::new(*quality as f64, (*count as f64 / (*count as f64 + 1.0))) + TruthValue::new(*quality as f64, *count as f64 / (*count as f64 + 1.0)) } else { TruthValue::new(0.5, 0.0) }; diff --git a/crates/stubs/notebook-query/src/orchestrator.rs b/crates/stubs/notebook-query/src/orchestrator.rs index 2a5670bf5..59341a010 100644 --- a/crates/stubs/notebook-query/src/orchestrator.rs +++ b/crates/stubs/notebook-query/src/orchestrator.rs @@ -360,6 +360,9 @@ pub struct GraphSensorium { impl GraphSensorium { /// Compute from raw graph statistics. + // The arity mirrors the upstream API this stub stands in for; grouping the + // counters into a struct here would diverge from it. + #[expect(clippy::too_many_arguments, reason = "mirrors the upstream signature")] pub fn compute( active_triplets: usize, contradictions: usize, @@ -714,6 +717,12 @@ pub struct StyleTopology { edges: HashMap<(AgentStyle, AgentStyle), TopologyEdge>, } +impl Default for StyleTopology { + fn default() -> Self { + Self::new() + } +} + impl StyleTopology { pub fn new() -> Self { let mut edges = HashMap::new(); diff --git a/crates/stubs/notebook-query/src/osint_audit.rs b/crates/stubs/notebook-query/src/osint_audit.rs index b9cd34c99..4ef81d0ed 100644 --- a/crates/stubs/notebook-query/src/osint_audit.rs +++ b/crates/stubs/notebook-query/src/osint_audit.rs @@ -7,10 +7,8 @@ //! Exposed via q2 cockpit-server at `/api/debug/osint`. use serde::{Deserialize, Serialize}; -use std::collections::HashMap; use std::sync::atomic::{AtomicU64, Ordering}; use std::sync::OnceLock; -use std::time::Instant; // ── Global OSINT Pipeline Registry ────────────────────────────────────────── @@ -32,6 +30,12 @@ pub struct OsintCounter { pub triplets_produced: AtomicU64, } +impl Default for OsintCounter { + fn default() -> Self { + Self::new() + } +} + impl OsintCounter { pub const fn new() -> Self { Self { @@ -63,11 +67,7 @@ impl OsintCounter { calls, successes: self.successes.load(Ordering::Relaxed), failures: self.failures.load(Ordering::Relaxed), - avg_latency_us: if calls > 0 { - total_ns / calls / 1000 - } else { - 0 - }, + avg_latency_us: total_ns.checked_div(calls).map(|q| q / 1000).unwrap_or(0), triplets_produced: self.triplets_produced.load(Ordering::Relaxed), } } @@ -98,6 +98,12 @@ pub struct OsintRegistry { pub xai_api_call: OsintCounter, } +impl Default for OsintRegistry { + fn default() -> Self { + Self::new() + } +} + impl OsintRegistry { pub fn new() -> Self { Self { diff --git a/crates/stubs/notebook-query/src/reasoning.rs b/crates/stubs/notebook-query/src/reasoning.rs index 776ec2451..82791443a 100644 --- a/crates/stubs/notebook-query/src/reasoning.rs +++ b/crates/stubs/notebook-query/src/reasoning.rs @@ -236,7 +236,7 @@ pub fn compute_seal_status(_prev: &GraphSnapshot, current: &GraphSnapshot) -> Se /// /// If an edge (src, dst, rel_type) appears in both `existing` and `incoming`, /// their truth values are combined via Bayesian revision. -pub fn revise_edges(existing: &mut Vec, incoming: &[TruthEdge]) -> usize { +pub fn revise_edges(existing: &mut [TruthEdge], incoming: &[TruthEdge]) -> usize { let mut revised_count = 0; let mut incoming_map: HashMap<(&str, &str, &str), &TruthValue> = HashMap::new(); diff --git a/crates/stubs/notebook-query/tests/gremlin_e2e.rs b/crates/stubs/notebook-query/tests/gremlin_e2e.rs index e7189ef65..69b6c694b 100644 --- a/crates/stubs/notebook-query/tests/gremlin_e2e.rs +++ b/crates/stubs/notebook-query/tests/gremlin_e2e.rs @@ -7,15 +7,12 @@ use notebook_query::{execute, QueryLanguage}; fn aiwar_data_path() -> Option<&'static str> { - for p in [ + [ "/home/user/q2/cockpit/public/aiwar_graph.json", "/home/user/aiwar-neo4j-harvest/data/aiwar_graph.json", - ] { - if std::path::Path::new(p).exists() { - return Some(p); - } - } - None + ] + .into_iter() + .find(|p| std::path::Path::new(p).exists()) } #[test]