Skip to content

Commit aa59cf6

Browse files
committed
fix all 12 clippy warnings for clean CI
- empty_line_after_doc_comment: context_pack.rs - manual_clamp: dag.rs (use .clamp()) - map_entry: dag.rs (use Entry::Vacant) - type_complexity: db.rs (3 functions) - needless_borrow: runtime.rs (2 occurrences) - redundant_closure: replay.rs - unnecessary_cast: summarizer.rs (2 occurrences) - private_interfaces: dag.rs (DagGraph -> pub(crate))
1 parent ce1481e commit aa59cf6

8 files changed

Lines changed: 16 additions & 18 deletions

File tree

.github/workflows/rust.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ jobs:
1919
with:
2020
components: clippy, rustfmt
2121
- uses: Swatinem/rust-cache@v2
22-
- run: cargo clippy --lib
23-
env:
24-
RUSTFLAGS: -A warnings
22+
- run: cargo clippy --lib -- -D warnings
2523

2624
# Unit tests only (no external dependencies)
2725
unit-tests:

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/context_pack.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/// DS4-14: ContextPack importance ordering.
22
/// Wraps messages with computed importance scores and supports
33
/// Preserve, ReverseChronological, or ByImportance ordering.
4-
54
/// 0/1 knapsack selector: given items with value and cost, select the subset
65
/// within `capacity` that maximizes total value.
76
///

src/dag.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl KnowledgeDag {
6767

6868
/// In-memory snapshot of a conversation's DAG, used for batch-loaded
6969
/// context assembly (avoids N+1 DB roundtrips).
70-
struct DagGraph {
70+
pub(crate) struct DagGraph {
7171
nodes: HashMap<i64, DagNode>,
7272
children: HashMap<i64, Vec<i64>>,
7373
}
@@ -861,7 +861,7 @@ impl DagEngine {
861861
.filter(|sr| sr.source != "message")
862862
.filter(|sr| !injected_ids.contains(&sr.id))
863863
.map(|sr| {
864-
let semantic = sr.bm25_score.unwrap_or(0.5).min(1.0).max(0.0); // normalize FTS5 rank
864+
let semantic = sr.bm25_score.unwrap_or(0.5).clamp(0.0, 1.0);
865865
let dist = distances.get(&sr.id).copied();
866866
let recency = if max_id > 0.0 {
867867
(sr.id as f64 / max_id).min(1.0)
@@ -948,20 +948,18 @@ impl DagEngine {
948948

949949
while let Some(cur) = queue.pop_front() {
950950
let d = dist[&cur] + 1;
951-
// Walk children (graph.children maps node → its child node IDs)
952951
if let Some(children) = graph.children.get(&cur) {
953952
for &child in children {
954-
if !dist.contains_key(&child) {
955-
dist.insert(child, d);
953+
if let std::collections::hash_map::Entry::Vacant(e) = dist.entry(child) {
954+
e.insert(d);
956955
queue.push_back(child);
957956
}
958957
}
959958
}
960-
// Walk parents (each node's parent_ids field)
961959
if let Some(node) = graph.nodes.get(&cur) {
962960
for &pid in &node.parent_ids {
963-
if !dist.contains_key(&pid) {
964-
dist.insert(pid, d);
961+
if let std::collections::hash_map::Entry::Vacant(e) = dist.entry(pid) {
962+
e.insert(d);
965963
queue.push_back(pid);
966964
}
967965
}

src/db.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2505,6 +2505,7 @@ impl Database {
25052505
}
25062506

25072507
/// Get full failure pattern data (with all fields) by signature.
2508+
#[allow(clippy::type_complexity)]
25082509
pub fn get_failure_pattern_by_signature(
25092510
&self, conv_id: i64, signature: &str,
25102511
) -> anyhow::Result<Option<(String, String, Vec<String>, String)>> {
@@ -2722,6 +2723,7 @@ impl Database {
27222723
}
27232724

27242725
/// Query decision records for a conversation (most recent first).
2726+
#[allow(clippy::type_complexity)]
27252727
pub fn query_decision_records(&self, conv_id: i64, limit: usize) -> anyhow::Result<Vec<(i64, String, f64, Option<bool>, Option<String>, u64, Option<u64>, String)>> {
27262728
let conn = self.read_conn();
27272729
let mut stmt = conn.prepare(
@@ -2832,6 +2834,7 @@ impl Database {
28322834
/// Read all execution events for a replay session (by replay_session_id).
28332835
/// Returns (id, execution_id, event_kind, event_payload, seq_no, created_at, epoch_ms)
28342836
/// ordered by insertion order (id ascending) for deterministic replay.
2837+
#[allow(clippy::type_complexity)]
28352838
pub fn get_execution_events_by_session(
28362839
&self, session_id: &str,
28372840
) -> anyhow::Result<Vec<(i64, Option<i64>, String, String, i64, String, i64)>> {

src/replay.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ pub fn replay_session(
550550
session_id: &str,
551551
) -> Result<ReplayResult, ReplayError> {
552552
let rows = db.get_execution_events_by_session(session_id)
553-
.map_err(|e| ReplayError::Other(e))?;
553+
.map_err(ReplayError::Other)?;
554554
if rows.is_empty() {
555555
return Ok(ReplayResult { events: vec![], corrupt_count: 0 });
556556
}

src/runtime.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,7 @@ impl OnlineEvaluator {
12431243
/// Adjust a candidate's score based on historical success rate.
12441244
/// High success → boost; low success → reduce; unknown → neutral.
12451245
pub fn adjust_score(&self, candidate: &mut DecisionCandidate, rule_name: &str) {
1246-
let action = &candidate.decision.action.variant_name();
1246+
let action = candidate.decision.action.variant_name();
12471247
let rate = self.success_rate(action);
12481248
// Blend: final = score * (0.5 + 0.5 * rate)
12491249
// At rate=1.0 → score * 1.0 (no change)
@@ -1475,7 +1475,7 @@ pub fn evaluate_plan_context(
14751475
// Store a decision record so the runtime can track plan-related outcomes
14761476
let _ = db.store_decision_record(
14771477
conv_id,
1478-
&decision.action.variant_name(),
1478+
decision.action.variant_name(),
14791479
decision.confidence,
14801480
&decision.reason,
14811481
decision.estimated_token_saving,

src/summarizer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ impl Summarizer {
480480
}
481481
} else if status.as_u16() == 429 {
482482
// Rate limited — full-jitter exponential backoff
483-
let delay_ms = crate::runtime::full_jitter_backoff(2000, 60000, attempt as u32, jitter_seed());
483+
let delay_ms = crate::runtime::full_jitter_backoff(2000, 60000, attempt, jitter_seed());
484484
let delay = Duration::from_millis(delay_ms);
485485
tracing::warn!(
486486
target = "deeplossless::summarizer",
@@ -516,7 +516,7 @@ impl Summarizer {
516516
"request failed"
517517
);
518518
if e.is_timeout() || e.is_connect() {
519-
let delay_ms = crate::runtime::full_jitter_backoff(1000, 30000, attempt as u32, jitter_seed());
519+
let delay_ms = crate::runtime::full_jitter_backoff(1000, 30000, attempt, jitter_seed());
520520
let delay = Duration::from_millis(delay_ms);
521521
tokio::time::sleep(delay).await;
522522
last_error = Some(anyhow::anyhow!("{e}"));

0 commit comments

Comments
 (0)