diff --git a/pkgs/atlas-search/crates/atlas-core/src/aggregate.rs b/pkgs/atlas-search/crates/atlas-core/src/aggregate.rs index d1dde6d5d2..6dbcf3b72e 100644 --- a/pkgs/atlas-search/crates/atlas-core/src/aggregate.rs +++ b/pkgs/atlas-search/crates/atlas-core/src/aggregate.rs @@ -205,10 +205,11 @@ fn next_shard_part(shard_dir: &Path, tier: Tier, topic: &str) -> Result { let Some(stem) = p.file_stem().and_then(|s| s.to_str()) else { continue; }; - if let Some((t, tp, part)) = crate::shards::parse_shard_name(stem) { - if t == tier && tp == topic { - next = next.max(part + 1); - } + if let Some((t, tp, part)) = crate::shards::parse_shard_name(stem) + && t == tier + && tp == topic + { + next = next.max(part + 1); } } Ok(next) diff --git a/pkgs/atlas-search/crates/atlas-core/src/c8_fingerprint.rs b/pkgs/atlas-search/crates/atlas-core/src/c8_fingerprint.rs index a30fbf19f6..dbea0392cd 100644 --- a/pkgs/atlas-search/crates/atlas-core/src/c8_fingerprint.rs +++ b/pkgs/atlas-search/crates/atlas-core/src/c8_fingerprint.rs @@ -186,7 +186,7 @@ pub fn group_occurrences(occurrences: &[ErrorOccurrence]) -> Vec Vec { } fn blob_to_vector(b: &[u8]) -> Option> { - if b.is_empty() || b.len() % 4 != 0 { + if b.is_empty() || !b.len().is_multiple_of(4) { return None; } Some( - b.chunks_exact(4) + b.as_chunks::<4>() + .0 + .iter() .map(|c| f32::from_le_bytes([c[0], c[1], c[2], c[3]])) .collect(), ) diff --git a/pkgs/atlas-search/crates/atlas-core/src/eval.rs b/pkgs/atlas-search/crates/atlas-core/src/eval.rs index 5fd073f989..142d00b30f 100644 --- a/pkgs/atlas-search/crates/atlas-core/src/eval.rs +++ b/pkgs/atlas-search/crates/atlas-core/src/eval.rs @@ -989,6 +989,17 @@ mod tests { } } + /// One generated duplicate-key case: (raw runs text, signal + /// named in the error, query named, clean runs text, expected + /// surviving runs as (signal, [(query, doc ids)])). + type DupKeyCase<'a> = ( + String, + String, + String, + String, + Vec<(&'a str, Vec<(&'a str, &'a [&'a str])>)>, + ); + // Oracle: the #6390 parser invariant, property-style over // generated documents (the repo testing doctrine for parsers): // for arbitrary query ids (including ids that need JSON @@ -1058,66 +1069,60 @@ mod tests { let r2: &[&str] = &["d3"]; let ro: &[&str] = &["d9"]; - // (raw runs text, signal named in the error, query named) - let (dup_runs, dup_signal, dup_query, clean_runs, expected): ( - String, - String, - String, - String, - Vec<(&str, Vec<(&str, &[&str])>)>, - ) = match case % 3 { - 0 => ( - run_obj( - &signal, - &results_obj(&[(&q_dup, r1), (&q_dup, r2)]), - results_first, - ), - signal.clone(), - q_dup.clone(), - run_obj(&signal, &results_obj(&[(&q_dup, r1)]), results_first), - vec![(signal.as_str(), vec![(q_dup.as_str(), r1)])], - ), - 1 => ( - run_obj( - &signal, - &results_obj(&[(&q_dup, r1), (&q_other, ro), (&q_dup, r2)]), - results_first, - ), - signal.clone(), - q_dup.clone(), - run_obj( - &signal, - &results_obj(&[(&q_dup, r1), (&q_other, ro)]), - results_first, - ), - vec![( - signal.as_str(), - vec![(q_dup.as_str(), r1), (q_other.as_str(), ro)], - )], - ), - _ => ( - format!( - "{}, {}", + let (dup_runs, dup_signal, dup_query, clean_runs, expected): DupKeyCase<'_> = + match case % 3 { + 0 => ( + run_obj( + &signal, + &results_obj(&[(&q_dup, r1), (&q_dup, r2)]), + results_first, + ), + signal.clone(), + q_dup.clone(), run_obj(&signal, &results_obj(&[(&q_dup, r1)]), results_first), + vec![(signal.as_str(), vec![(q_dup.as_str(), r1)])], + ), + 1 => ( run_obj( - &signal2, - &results_obj(&[(&q_other, ro), (&q_other, r1)]), - results_first - ) + &signal, + &results_obj(&[(&q_dup, r1), (&q_other, ro), (&q_dup, r2)]), + results_first, + ), + signal.clone(), + q_dup.clone(), + run_obj( + &signal, + &results_obj(&[(&q_dup, r1), (&q_other, ro)]), + results_first, + ), + vec![( + signal.as_str(), + vec![(q_dup.as_str(), r1), (q_other.as_str(), ro)], + )], ), - signal2.clone(), - q_other.clone(), - format!( - "{}, {}", - run_obj(&signal, &results_obj(&[(&q_dup, r1)]), results_first), - run_obj(&signal2, &results_obj(&[(&q_other, ro)]), results_first) + _ => ( + format!( + "{}, {}", + run_obj(&signal, &results_obj(&[(&q_dup, r1)]), results_first), + run_obj( + &signal2, + &results_obj(&[(&q_other, ro), (&q_other, r1)]), + results_first + ) + ), + signal2.clone(), + q_other.clone(), + format!( + "{}, {}", + run_obj(&signal, &results_obj(&[(&q_dup, r1)]), results_first), + run_obj(&signal2, &results_obj(&[(&q_other, ro)]), results_first) + ), + vec![ + (signal.as_str(), vec![(q_dup.as_str(), r1)]), + (signal2.as_str(), vec![(q_other.as_str(), ro)]), + ], ), - vec![ - (signal.as_str(), vec![(q_dup.as_str(), r1)]), - (signal2.as_str(), vec![(q_other.as_str(), ro)]), - ], - ), - }; + }; let queries: Vec<&str> = vec![&q_dup, &q_other]; let err = EvalData::from_json(&document(&queries, &dup_runs)) diff --git a/pkgs/atlas-search/crates/atlas-core/src/github_comments.rs b/pkgs/atlas-search/crates/atlas-core/src/github_comments.rs index 8db274f0d8..25aa983655 100644 --- a/pkgs/atlas-search/crates/atlas-core/src/github_comments.rs +++ b/pkgs/atlas-search/crates/atlas-core/src/github_comments.rs @@ -92,7 +92,7 @@ impl CommentKind { } /// Parse the record spelling, if it is one. - pub fn from_str(s: &str) -> Option { + pub fn parse(s: &str) -> Option { match s { "issue_comment" => Some(CommentKind::IssueComment), "review_comment" => Some(CommentKind::ReviewComment), @@ -238,7 +238,7 @@ pub fn document_from_record(record: &Json) -> Option { thread_number: record.get("thread_number")?.as_u64()?, is_pr: record.get("thread_kind")?.as_str()? == "pull_request", comment_id: record.get("comment_id")?.as_u64()?, - kind: CommentKind::from_str(record.get("kind")?.as_str()?)?, + kind: CommentKind::parse(record.get("kind")?.as_str()?)?, author: record.get("author")?.as_str()?.to_string(), created_at: record.get("created_at")?.as_str()?.to_string(), updated_at: record.get("updated_at")?.as_str()?.to_string(), diff --git a/pkgs/atlas-search/crates/atlas-core/src/join.rs b/pkgs/atlas-search/crates/atlas-core/src/join.rs index d54baa22d4..e58e62ab49 100644 --- a/pkgs/atlas-search/crates/atlas-core/src/join.rs +++ b/pkgs/atlas-search/crates/atlas-core/src/join.rs @@ -388,11 +388,11 @@ fn push_highlight(highlights: &mut Vec>, range: Range) { if range.is_empty() { return; } - if let Some(last) = highlights.last_mut() { - if range.start <= last.end { - last.end = last.end.max(range.end); - return; - } + if let Some(last) = highlights.last_mut() + && range.start <= last.end + { + last.end = last.end.max(range.end); + return; } highlights.push(range); } diff --git a/pkgs/atlas-search/crates/atlas-core/src/local.rs b/pkgs/atlas-search/crates/atlas-core/src/local.rs index 325ebff6df..587a8a7cac 100644 --- a/pkgs/atlas-search/crates/atlas-core/src/local.rs +++ b/pkgs/atlas-search/crates/atlas-core/src/local.rs @@ -383,11 +383,7 @@ impl LocalBackend { let mut prepared = con .prepare(&stmt.sql) .map_err(|e| Error::backend(e.to_string()))?; - let col_names: Vec = prepared - .column_names() - .into_iter() - .map(str::to_string) - .collect(); + let col_names: Vec = prepared.column_names().map(str::to_string).collect(); let params: Vec = stmt.args.iter().map(to_rvalue).collect(); let mut rows = prepared .query(rusqlite::params_from_iter(params.iter())) diff --git a/pkgs/atlas-search/crates/atlas-core/src/search.rs b/pkgs/atlas-search/crates/atlas-core/src/search.rs index 2a6ed16e96..3223ffde06 100644 --- a/pkgs/atlas-search/crates/atlas-core/src/search.rs +++ b/pkgs/atlas-search/crates/atlas-core/src/search.rs @@ -386,23 +386,19 @@ fn run_search_impl( let mut permitted: std::collections::HashSet = std::collections::HashSet::new(); let mut withheld = 0usize; for e in &ranked { - match all_details.get(&e.chunk_id) { - Some(d) => { - let class = chunk_classification(d.eff_sensitivity.as_deref()); - if opts - .context - .permits_with_grant(class, filters.max_sensitivity) - { - permitted.insert(e.chunk_id); - } else { - withheld += 1; - } + // No detail row: the candidate renders nowhere (the + // flat/grouped paths already skip it), and it is not a + // disclosure decision, so it is not counted as withheld. + if let Some(d) = all_details.get(&e.chunk_id) { + let class = chunk_classification(d.eff_sensitivity.as_deref()); + if opts + .context + .permits_with_grant(class, filters.max_sensitivity) + { + permitted.insert(e.chunk_id); + } else { + withheld += 1; } - // No detail row: the candidate renders nowhere - // (the flat/grouped paths already skip it), and it - // is not a disclosure decision, so it is not - // counted as withheld. - None => {} } } if withheld > 0 { @@ -587,10 +583,10 @@ fn collect_served(v: Option<&Json>, acc: &mut Vec) { } } Some(Json::Object(map)) => { - if let Some(id) = map.get("chunk_id").and_then(Json::as_i64) { - if !acc.contains(&id) { - acc.push(id); - } + if let Some(id) = map.get("chunk_id").and_then(Json::as_i64) + && !acc.contains(&id) + { + acc.push(id); } for val in map.values() { if val.is_array() { diff --git a/pkgs/atlas-search/crates/atlas-core/src/shards/local.rs b/pkgs/atlas-search/crates/atlas-core/src/shards/local.rs index 7590f69f55..30f2810d68 100644 --- a/pkgs/atlas-search/crates/atlas-core/src/shards/local.rs +++ b/pkgs/atlas-search/crates/atlas-core/src/shards/local.rs @@ -20,11 +20,13 @@ use crate::types::{Row, Stmt, Value}; type RValue = rusqlite::types::Value; fn blob_to_f32(b: &[u8]) -> Option> { - if b.len() % 4 != 0 { + if !b.len().is_multiple_of(4) { return None; } Some( - b.chunks_exact(4) + b.as_chunks::<4>() + .0 + .iter() .map(|c| f32::from_le_bytes([c[0], c[1], c[2], c[3]])) .collect(), ) diff --git a/pkgs/atlas-search/crates/atlas-core/src/shingles.rs b/pkgs/atlas-search/crates/atlas-core/src/shingles.rs index d12cff9abc..e64e8e8629 100644 --- a/pkgs/atlas-search/crates/atlas-core/src/shingles.rs +++ b/pkgs/atlas-search/crates/atlas-core/src/shingles.rs @@ -262,7 +262,7 @@ pub struct RescoreReport { /// (deterministic). Entries beyond `depth` are untouched and keep /// their fused order after the union. pub fn rescore_fused( - entries: &mut Vec, + entries: &mut [FusedEntry], query: &ShingleSet, sets: &HashMap, depth: usize, diff --git a/pkgs/atlas-search/crates/atlas-core/src/stage.rs b/pkgs/atlas-search/crates/atlas-core/src/stage.rs index 5d26d33c3d..ad61a49c05 100644 --- a/pkgs/atlas-search/crates/atlas-core/src/stage.rs +++ b/pkgs/atlas-search/crates/atlas-core/src/stage.rs @@ -150,12 +150,11 @@ pub struct MergeManifest { /// database reports `_schema_version = 1` and exactly /// [`STAGE_V1_TABLES`]. pub fn provision_staging_db(path: &Path) -> Result<()> { - if let Some(parent) = path.parent() { - if !parent.as_os_str().is_empty() { - std::fs::create_dir_all(parent).map_err(|e| { - Error::backend(format!("staging: creating {}: {e}", parent.display())) - })?; - } + if let Some(parent) = path.parent() + && !parent.as_os_str().is_empty() + { + std::fs::create_dir_all(parent) + .map_err(|e| Error::backend(format!("staging: creating {}: {e}", parent.display())))?; } let conn = open(path)?; let existing = user_tables(&conn)?; @@ -715,12 +714,12 @@ impl Registry { /// Open (creating if needed) a registry at `path` and ensure its /// v1 table exists. pub fn open(path: &Path) -> Result { - if let Some(parent) = path.parent() { - if !parent.as_os_str().is_empty() { - std::fs::create_dir_all(parent).map_err(|e| { - Error::backend(format!("registry: creating {}: {e}", parent.display())) - })?; - } + if let Some(parent) = path.parent() + && !parent.as_os_str().is_empty() + { + std::fs::create_dir_all(parent).map_err(|e| { + Error::backend(format!("registry: creating {}: {e}", parent.display())) + })?; } let conn = open(path)?; ensure_registry(&conn)?; diff --git a/pkgs/atlas-search/crates/atlas-core/src/sweep.rs b/pkgs/atlas-search/crates/atlas-core/src/sweep.rs index c79b54ad10..684078691c 100644 --- a/pkgs/atlas-search/crates/atlas-core/src/sweep.rs +++ b/pkgs/atlas-search/crates/atlas-core/src/sweep.rs @@ -218,10 +218,10 @@ pub fn filter_candidate( if facts.secret_tier { return FilterOutcome::Hold(Some(ReasonCode::SecretTierHeld)); } - if let Some(address) = &facts.content_address { - if landed.contains(address) { - return FilterOutcome::Reject(ReasonCode::DuplicateContent); - } + if let Some(address) = &facts.content_address + && landed.contains(address) + { + return FilterOutcome::Reject(ReasonCode::DuplicateContent); } match class { SourceClass::BootRecords => { @@ -363,17 +363,18 @@ pub fn evaluate_guardrails(m: &Measurements, previous_throttled: bool) -> Vec 0 && m.tgt_write_rows > median.saturating_mul(2) { - events.push(GuardrailEvent { - alert: Some("guardrail/tgt-burst".to_string()), - action: GuardrailAction::PauseClass, - detail: format!( - "tgt_write_rows {} above 2x trailing median {}", - m.tgt_write_rows, median - ), - }); - } + if let Some(median) = m.class_median_write_rows + && median > 0 + && m.tgt_write_rows > median.saturating_mul(2) + { + events.push(GuardrailEvent { + alert: Some("guardrail/tgt-burst".to_string()), + action: GuardrailAction::PauseClass, + detail: format!( + "tgt_write_rows {} above 2x trailing median {}", + m.tgt_write_rows, median + ), + }); } events } @@ -565,12 +566,11 @@ impl SweepLock { std::fs::create_dir_all(state_dir) .map_err(|e| Error::backend(format!("create {}: {e}", state_dir.display())))?; let path = lock_path(state_dir, class, host); - if let Ok(text) = std::fs::read_to_string(&path) { - if let Ok(existing) = serde_json::from_str::(&text) { - if now_unix.saturating_sub(existing.at_unix) < LOCK_TTL_SECONDS { - return Ok(None); - } - } + if let Ok(text) = std::fs::read_to_string(&path) + && let Ok(existing) = serde_json::from_str::(&text) + && now_unix.saturating_sub(existing.at_unix) < LOCK_TTL_SECONDS + { + return Ok(None); } let text = serde_json::to_string(&LockFile { run_id: run_id.to_string(), @@ -588,12 +588,11 @@ impl SweepLock { impl Drop for SweepLock { fn drop(&mut self) { - if let Ok(text) = std::fs::read_to_string(&self.path) { - if let Ok(existing) = serde_json::from_str::(&text) { - if existing.run_id == self.run_id { - let _ = std::fs::remove_file(&self.path); - } - } + if let Ok(text) = std::fs::read_to_string(&self.path) + && let Ok(existing) = serde_json::from_str::(&text) + && existing.run_id == self.run_id + { + let _ = std::fs::remove_file(&self.path); } } } diff --git a/pkgs/atlas-search/crates/atlas-core/src/trace.rs b/pkgs/atlas-search/crates/atlas-core/src/trace.rs index 1c4fb455c9..85c66acf31 100644 --- a/pkgs/atlas-search/crates/atlas-core/src/trace.rs +++ b/pkgs/atlas-search/crates/atlas-core/src/trace.rs @@ -340,10 +340,10 @@ pub fn build_trace_record( // in the producing shard's atlas_manifest, or null when // the candidate carries no manifest provenance. let candidate_model = pools.candidate_models.get(&e.chunk_id); - if let Some(m) = candidate_model { - if !distinct_models.contains(m) { - distinct_models.push(m.clone()); - } + if let Some(m) = candidate_model + && !distinct_models.contains(m) + { + distinct_models.push(m.clone()); } r.insert( "embedding_model".into(), diff --git a/pkgs/atlas-search/crates/atlas-core/src/trace_ingest.rs b/pkgs/atlas-search/crates/atlas-core/src/trace_ingest.rs index 401453545c..a2c4cc3fdb 100644 --- a/pkgs/atlas-search/crates/atlas-core/src/trace_ingest.rs +++ b/pkgs/atlas-search/crates/atlas-core/src/trace_ingest.rs @@ -1037,7 +1037,11 @@ mod tests { "retry query", "hashretry", ); - let aged = write_file(&dir, "atlas-traces-2026-01-01.jsonl", &[line.clone()]); + let aged = write_file( + &dir, + "atlas-traces-2026-01-01.jsonl", + std::slice::from_ref(&line), + ); let cold_dir = dir.join(COLD_DIR_NAME); std::fs::create_dir_all(&cold_dir).expect("cold dir"); write_file(&cold_dir, "atlas-traces-2026-01-01.jsonl", &[line]); diff --git a/pkgs/atlas-search/crates/atlas-core/src/trace_stats.rs b/pkgs/atlas-search/crates/atlas-core/src/trace_stats.rs index a4545a872e..9bd6025c6b 100644 --- a/pkgs/atlas-search/crates/atlas-core/src/trace_stats.rs +++ b/pkgs/atlas-search/crates/atlas-core/src/trace_stats.rs @@ -546,7 +546,11 @@ impl WindowStats { } } -fn hot_trace_files(dir: &Path) -> Result> { +/// One hot trace file and the civil day `(year, month, day)` its +/// file name encodes. +type HotTraceFile = (PathBuf, (i64, u32, u32)); + +fn hot_trace_files(dir: &Path) -> Result> { let mut files = Vec::new(); let rd = match std::fs::read_dir(dir) { Ok(rd) => rd, @@ -681,10 +685,10 @@ pub fn aggregate_traces( embed_id: embed_id.clone(), ..Default::default() }); - if e.embed_content_hash.is_empty() { - if let Some(h) = r.get("embed_content_hash").and_then(Json::as_str) { - e.embed_content_hash = h.to_string(); - } + if e.embed_content_hash.is_empty() + && let Some(h) = r.get("embed_content_hash").and_then(Json::as_str) + { + e.embed_content_hash = h.to_string(); } e.pool_entries += 1; e.pool_queries.insert(query_id.clone()); diff --git a/pkgs/atlas-search/crates/atlas-core/tests/boundary_wiring.rs b/pkgs/atlas-search/crates/atlas-core/tests/boundary_wiring.rs index 4dd142cdb9..34092face4 100644 --- a/pkgs/atlas-search/crates/atlas-core/tests/boundary_wiring.rs +++ b/pkgs/atlas-search/crates/atlas-core/tests/boundary_wiring.rs @@ -63,12 +63,10 @@ fn staged_chunks(db: &Path, item_id: i64) -> Vec { let mut stmt = conn .prepare("SELECT text FROM chunks_raw WHERE item_id = ?1 ORDER BY idx") .unwrap(); - let rows = stmt - .query_map([item_id], |r| r.get::<_, String>(0)) + stmt.query_map([item_id], |r| r.get::<_, String>(0)) .unwrap() .collect::, _>>() - .unwrap(); - rows + .unwrap() } fn classifications(db: &Path, item_id: i64) -> Vec { diff --git a/pkgs/atlas-search/crates/atlas-core/tests/citation_conformance.rs b/pkgs/atlas-search/crates/atlas-core/tests/citation_conformance.rs index a0f39d610f..01e3ea0394 100644 --- a/pkgs/atlas-search/crates/atlas-core/tests/citation_conformance.rs +++ b/pkgs/atlas-search/crates/atlas-core/tests/citation_conformance.rs @@ -339,15 +339,15 @@ impl CitationAdapter for AliasingResolver { .records .iter() .find(|r| r.occurrence_id == req.occurrence_id); - if let Some(t) = target { - if let Some(first) = self.by_content.get(&t.content_id) { - let redirected = Request { - occurrence_id: first.occurrence_id.clone(), - version: req.version, - granted: req.granted.clone(), - }; - return self.inner.resolve(&redirected); - } + if let Some(t) = target + && let Some(first) = self.by_content.get(&t.content_id) + { + let redirected = Request { + occurrence_id: first.occurrence_id.clone(), + version: req.version, + granted: req.granted.clone(), + }; + return self.inner.resolve(&redirected); } self.inner.resolve(req) } @@ -697,7 +697,7 @@ fn fake_adapter_passes_hand_authored_corpus() { #[test] fn aliasing_implementation_is_rejected() { - let failures = run_corpus(|world| AliasingResolver::new(world)); + let failures = run_corpus(AliasingResolver::new); assert!( failures.contains(&"same_bytes_second_location"), "aliasing resolver must fail the second-location case, got: {failures:?}" diff --git a/pkgs/atlas-search/crates/atlas-core/tests/diagnostic_fixture.rs b/pkgs/atlas-search/crates/atlas-core/tests/diagnostic_fixture.rs index b57584c689..7d8640ba67 100644 --- a/pkgs/atlas-search/crates/atlas-core/tests/diagnostic_fixture.rs +++ b/pkgs/atlas-search/crates/atlas-core/tests/diagnostic_fixture.rs @@ -131,7 +131,7 @@ enum Stage { ServedSupported, /// A stage timed out or errored before the target's fate could /// be decided; the payload is the failed stage. - StageError(PipelineStage), + Error(PipelineStage), } /// Coverage confidence, returned independently of the stage: how @@ -319,7 +319,7 @@ fn diagnose_with(input: &FixtureInput, rules: Rules) -> Result Result { let failed = input.failure.map(|f| f.stage); // Masked check: the observation made by `stage` is trusted only // when no failure happened at or before it. - let trusted = |stage: PipelineStage| failed.map_or(true, |f| stage.rank() < f.rank()); + let trusted = |stage: PipelineStage| failed.is_none_or(|f| stage.rank() < f.rank()); let t = &input.target; if !trusted(PipelineStage::Enumeration) { return Ok(Diagnosis { - stage: Stage::StageError(PipelineStage::Enumeration), + stage: Stage::Error(PipelineStage::Enumeration), coverage: Coverage::Incomplete, }); } @@ -414,7 +414,7 @@ fn reference_diagnose(input: &FixtureInput) -> Result { } if !trusted(PipelineStage::Indexing) { return Ok(Diagnosis { - stage: Stage::StageError(PipelineStage::Indexing), + stage: Stage::Error(PipelineStage::Indexing), coverage, }); } @@ -426,7 +426,7 @@ fn reference_diagnose(input: &FixtureInput) -> Result { } if !trusted(PipelineStage::CandidateGeneration) { return Ok(Diagnosis { - stage: Stage::StageError(PipelineStage::CandidateGeneration), + stage: Stage::Error(PipelineStage::CandidateGeneration), coverage, }); } @@ -439,7 +439,7 @@ fn reference_diagnose(input: &FixtureInput) -> Result { } if !trusted(PipelineStage::Serving) { return Ok(Diagnosis { - stage: Stage::StageError(PipelineStage::Serving), + stage: Stage::Error(PipelineStage::Serving), coverage, }); } @@ -451,7 +451,7 @@ fn reference_diagnose(input: &FixtureInput) -> Result { } if !trusted(PipelineStage::ContextPacking) { return Ok(Diagnosis { - stage: Stage::StageError(PipelineStage::ContextPacking), + stage: Stage::Error(PipelineStage::ContextPacking), coverage, }); } @@ -463,7 +463,7 @@ fn reference_diagnose(input: &FixtureInput) -> Result { } if !trusted(PipelineStage::AnswerSupport) { return Ok(Diagnosis { - stage: Stage::StageError(PipelineStage::AnswerSupport), + stage: Stage::Error(PipelineStage::AnswerSupport), coverage, }); } @@ -650,7 +650,7 @@ fn fixtures() -> Vec { name: "stage_timeout", input: i, expected: Diagnosis { - stage: Stage::StageError(PipelineStage::CandidateGeneration), + stage: Stage::Error(PipelineStage::CandidateGeneration), coverage: Coverage::Complete, }, }); @@ -791,7 +791,7 @@ impl Rng { } fn coin(&mut self) -> bool { - self.next() % 2 == 0 + self.next().is_multiple_of(2) } fn below(&mut self, n: usize) -> usize { @@ -860,7 +860,7 @@ fn generated_world(rng: &mut Rng) -> FixtureInput { /// structurally on every generated world. #[test] fn runner_matches_reference_on_generated_corpora() { - let mut rng = Rng(0x8525_6020_F01); + let mut rng = Rng(0x0852_5602_0F01); for case in 0..4000 { let input = generated_world(&mut rng); let got = diagnose(&input).expect("generated worlds are well-formed"); @@ -877,14 +877,15 @@ fn runner_matches_reference_on_generated_corpora() { "case {case}: policy exclusion presented as absence" ); } - if let Some(f) = input.failure { - if f.stage == PipelineStage::Enumeration && !input.policy_excluded { - assert_eq!( - got.stage, - Stage::StageError(PipelineStage::Enumeration), - "case {case}: enumeration failure not surfaced" - ); - } + if let Some(f) = input.failure + && f.stage == PipelineStage::Enumeration + && !input.policy_excluded + { + assert_eq!( + got.stage, + Stage::Error(PipelineStage::Enumeration), + "case {case}: enumeration failure not surfaced" + ); } } } @@ -1055,7 +1056,7 @@ fn deterministic_replay() { served_not_in_context:ServedNotInContext/Complete;\ delivered_unsupported:ContextDeliveredUnsupported/Complete;\ served_supported:ServedSupported/Complete;\ - stage_timeout:StageError(CandidateGeneration)/Complete;\ + stage_timeout:Error(CandidateGeneration)/Complete;\ policy_excluded:PolicyExcluded/Complete"; let transcript = |table: &[NamedFixture]| { table diff --git a/pkgs/atlas-search/crates/atlas-core/tests/permission_model.rs b/pkgs/atlas-search/crates/atlas-core/tests/permission_model.rs index cf500c6a99..da5635f2a7 100644 --- a/pkgs/atlas-search/crates/atlas-core/tests/permission_model.rs +++ b/pkgs/atlas-search/crates/atlas-core/tests/permission_model.rs @@ -152,10 +152,10 @@ impl Pipeline { // Replay validates the cached entry against the CURRENT epoch // and rights: a stale entry is recomputed, never served. let key = (caller.to_string(), query.to_string()); - if let Some(cached) = self.cache.get(&key) { - if cached.epoch == world.epoch { - return cached.clone(); - } + if let Some(cached) = self.cache.get(&key) + && cached.epoch == world.epoch + { + return cached.clone(); } self.search(world, caller, query) } diff --git a/pkgs/atlas-search/crates/atlas-core/tests/placement_model.rs b/pkgs/atlas-search/crates/atlas-core/tests/placement_model.rs index 5331e84113..2262ac7f70 100644 --- a/pkgs/atlas-search/crates/atlas-core/tests/placement_model.rs +++ b/pkgs/atlas-search/crates/atlas-core/tests/placement_model.rs @@ -377,8 +377,8 @@ fn evaluate( /// `Err` carries every non-feasible decision so the caller can report /// why a proposal could not be made — an infeasible or unknown /// scenario is a result, not a crash. -fn choose<'a>( - placements: &'a [Placement], +fn choose( + placements: &[Placement], use_: Use, envelope: &Envelope, required_temp_gib: u64, @@ -415,7 +415,7 @@ fn choose<'a>( /// placement the constraints forbid, so the oracle can tell the /// reference selector apart from a plausible wrong one. #[allow(dead_code)] -fn choose_cheapest_first<'a>(placements: &'a [Placement], use_: Use) -> Option<(&'a str, Micros)> { +fn choose_cheapest_first(placements: &[Placement], use_: Use) -> Option<(&str, Micros)> { placements .iter() .filter_map(|p| { diff --git a/pkgs/atlas-search/crates/atlas-core/tests/row_detection.rs b/pkgs/atlas-search/crates/atlas-core/tests/row_detection.rs index 5dba3ac157..66a4bf2f18 100644 --- a/pkgs/atlas-search/crates/atlas-core/tests/row_detection.rs +++ b/pkgs/atlas-search/crates/atlas-core/tests/row_detection.rs @@ -635,7 +635,7 @@ fn op_strategy() -> impl proptest::strategy::Strategy { let id = 1..=6i64; let body = "[a-z]{1,8}"; prop_oneof![ - (id.clone(), body.clone()).prop_map(|(id, body)| Op::Insert { id, body }), + (id.clone(), body).prop_map(|(id, body)| Op::Insert { id, body }), (id.clone(), body).prop_map(|(id, body)| Op::Update { id, body }), id.prop_map(|id| Op::Delete { id }), ]