chore: workspace-wide cleanup — clippy::pedantic baseline + auto-fix
cut PR v0.18.0 전 마지막 정리. 사용자 요청: "전체 코드베이스를 깔끔하고 알아보기 쉽게".
## Workspace lints
- `Cargo.toml` 의 `[workspace.lints.clippy]` 에 `pedantic = "warn"` (priority -1) + 의도적 allow-list 추가:
- cast_possible_truncation / cast_possible_wrap / cast_sign_loss / cast_precision_loss — ONNX i64 / hash modular reduction 등 의도적 truncation.
- doc_markdown / missing_errors_doc / missing_panics_doc — cosmetic doc style.
- too_many_lines / module_name_repetitions / must_use_candidate / needless_pass_by_value / manual_let_else / items_after_statements / similar_names — informational only.
- format_collect / match_wildcard_for_single_variants / trivially_copy_pass_by_ref / unnecessary_wraps — intentional patterns (exhaustive match, future Result variants 등).
- default_trait_access — `Foo::default()` 가 idiomatic.
- float_cmp — NLI / RRF score 의 explicit threshold 비교 의도.
- struct_excessive_bools / case_sensitive_file_extension_comparisons / naive_bytecount / ignore_without_reason — domain-specific 의도.
- format_push_string / return_self_not_must_use / match_same_arms — builder / wire-label / hot-path 패턴 보존.
- needless_continue / used_underscore_binding / nonminimal_bool / unreadable_literal / many_single_char_names / doc_link_with_quotes / assigning_clones / collapsible_str_replace / trivial_regex / elidable_lifetime_names / range_plus_one / explicit_iter_loop / implicit_hasher / ref_option — remaining low-value style.
- 각 24 crate `Cargo.toml` 에 `[lints] workspace = true` 추가.
## Auto-fix
`cargo clippy --workspace --all-targets --fix` 적용 — 128 files changed, 552 insertions / 472 deletions. 주로:
- uninlined_format_args (~18): `format!("{}", x)` → `format!("{x}")`.
- redundant_closure_for_method_calls (~33): `.map(|x| x.foo())` → `.map(T::foo)`.
- 그 외 mechanical refactor.
## 검증
- `cargo clippy --workspace --all-targets -j 1 -- -D warnings` clean (pedantic + 모든 lint group).
- `cargo test --workspace --no-fail-fast -j 1` — **1293 tests pass + 1 pre-existing flaky fail** (`kebab-mcp::tools_call_ask_multi_hop::ask_tool_routes_multi_hop_true_to_decompose_first`, HOTFIX candidate, cleanup 무관). 회귀 0.
Wire 영향: 없음.
Behavior 영향: 없음 (mechanical refactor only).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -28,3 +28,6 @@ kebab-llm = { path = "../kebab-llm", features = ["mock"] }
|
||||
tempfile = { workspace = true }
|
||||
rusqlite = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
@@ -318,7 +318,7 @@ impl RagPipeline {
|
||||
});
|
||||
}
|
||||
let chunks_returned = u32::try_from(hits.len()).unwrap_or(u32::MAX);
|
||||
let top_score = hits.first().map(|h| h.retrieval.fusion_score).unwrap_or(0.0);
|
||||
let top_score = hits.first().map_or(0.0, |h| h.retrieval.fusion_score);
|
||||
|
||||
tracing::debug!(
|
||||
target: "kebab-rag",
|
||||
@@ -856,7 +856,7 @@ impl RagPipeline {
|
||||
});
|
||||
}
|
||||
let chunks_returned = u32::try_from(pool.len()).unwrap_or(u32::MAX);
|
||||
let top_score = pool.first().map(|h| h.retrieval.fusion_score).unwrap_or(0.0);
|
||||
let top_score = pool.first().map_or(0.0, |h| h.retrieval.fusion_score);
|
||||
|
||||
// ── 3. Score gate / no chunks ──────────────────────────────────────
|
||||
// PR-3b-ii: forward the partial hop trace into the refusal so
|
||||
@@ -1149,7 +1149,7 @@ impl RagPipeline {
|
||||
refusal_phrase_detected = matched_refusal_phrase,
|
||||
finish_reason = ?finish_reason,
|
||||
chunks_used,
|
||||
hops = answer.hops.as_ref().map(|v| v.len()).unwrap_or(0),
|
||||
hops = answer.hops.as_ref().map_or(0, std::vec::Vec::len),
|
||||
"kb-rag: multi-hop ask done"
|
||||
);
|
||||
|
||||
@@ -1388,16 +1388,13 @@ impl RagPipeline {
|
||||
let chunk_full =
|
||||
<SqliteStore as kebab_core::DocumentStore>::get_chunk(&self.docs, &hit.chunk_id)
|
||||
.context("kb-rag: docs.get_chunk")?;
|
||||
let chunk_text = match chunk_full {
|
||||
Some(c) => c.text,
|
||||
None => {
|
||||
tracing::warn!(
|
||||
target: "kebab-rag",
|
||||
chunk_id = %hit.chunk_id.0,
|
||||
"kb-rag: chunk not found in store; skipping"
|
||||
);
|
||||
continue;
|
||||
}
|
||||
let chunk_text = if let Some(c) = chunk_full { c.text } else {
|
||||
tracing::warn!(
|
||||
target: "kebab-rag",
|
||||
chunk_id = %hit.chunk_id.0,
|
||||
"kb-rag: chunk not found in store; skipping"
|
||||
);
|
||||
continue;
|
||||
};
|
||||
let header = format!(
|
||||
"[#{n}] doc={} heading={} span={}\n",
|
||||
@@ -1999,13 +1996,11 @@ fn strip_markdown_json_fence(s: &str) -> &str {
|
||||
let after_open = trimmed
|
||||
.strip_prefix("```json")
|
||||
.or_else(|| trimmed.strip_prefix("```"))
|
||||
.map(|rest| rest.trim_start_matches('\n'))
|
||||
.unwrap_or(trimmed);
|
||||
.map_or(trimmed, |rest| rest.trim_start_matches('\n'));
|
||||
let inner = after_open
|
||||
.trim_end()
|
||||
.strip_suffix("```")
|
||||
.map(|rest| rest.trim_end())
|
||||
.unwrap_or(after_open);
|
||||
.map_or(after_open, str::trim_end);
|
||||
inner.trim()
|
||||
}
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ pub fn mk_hit_with_indexed_at(
|
||||
chunk_id: ChunkId(chunk_id.to_string()),
|
||||
doc_id: DocumentId(doc_id.to_string()),
|
||||
doc_path: p.clone(),
|
||||
heading_path: heading.iter().map(|s| s.to_string()).collect(),
|
||||
heading_path: heading.iter().map(std::string::ToString::to_string).collect(),
|
||||
section_label: None,
|
||||
snippet: "snippet".to_string(),
|
||||
citation: Citation::Line {
|
||||
|
||||
@@ -68,7 +68,7 @@ fn multi_hop_decide_stop_triggers_synthesize() {
|
||||
// Three LLM calls in order: decompose → decide → synthesize.
|
||||
let lm = Arc::new(ScriptedLm::new(vec![
|
||||
r#"["q1"]"#,
|
||||
r#"[]"#,
|
||||
r"[]",
|
||||
"answer body [#1]",
|
||||
]));
|
||||
let lm_handle = lm.clone();
|
||||
@@ -131,7 +131,7 @@ fn multi_hop_decide_continue_adds_more_chunks() {
|
||||
let lm = Arc::new(ScriptedLm::new(vec![
|
||||
r#"["q1"]"#,
|
||||
r#"["q2"]"#,
|
||||
r#"[]"#,
|
||||
r"[]",
|
||||
"synthesized [#1] [#2]",
|
||||
]));
|
||||
let lm_handle = lm.clone();
|
||||
@@ -255,7 +255,7 @@ fn multi_hop_pool_chunks_dedup_by_chunk_id() {
|
||||
|
||||
let lm = Arc::new(ScriptedLm::new(vec![
|
||||
r#"["q1", "q2"]"#,
|
||||
r#"[]"#,
|
||||
r"[]",
|
||||
"merged answer [#1]",
|
||||
]));
|
||||
let lm_handle = lm.clone();
|
||||
@@ -444,7 +444,7 @@ fn multi_hop_refuse_score_gate_preserves_hops_trace() {
|
||||
// never runs because we refuse before pack_context.
|
||||
let lm = Arc::new(ScriptedLm::new(vec![
|
||||
r#"["q1"]"#,
|
||||
r#"[]"#,
|
||||
r"[]",
|
||||
]));
|
||||
let lm_handle = lm.clone();
|
||||
let lm_dyn: Arc<dyn LanguageModel> = lm;
|
||||
@@ -594,7 +594,7 @@ fn multi_hop_above_probe_gate_proceeds_to_decompose() {
|
||||
|
||||
let lm = Arc::new(ScriptedLm::new(vec![
|
||||
r#"["q1"]"#,
|
||||
r#"[]"#,
|
||||
r"[]",
|
||||
"answer [#1]",
|
||||
]));
|
||||
let lm_handle = lm.clone();
|
||||
@@ -649,7 +649,7 @@ fn happy_multi_hop_env() -> (RagEnv, Arc<ScriptedRetriever>, Arc<ScriptedLm>) {
|
||||
let retriever = Arc::new(ScriptedRetriever::new(vec![hits.clone(), hits]));
|
||||
let lm = Arc::new(ScriptedLm::new(vec![
|
||||
r#"["q1"]"#,
|
||||
r#"[]"#,
|
||||
r"[]",
|
||||
"answer body [#1]",
|
||||
]));
|
||||
(env, retriever, lm)
|
||||
|
||||
@@ -282,8 +282,7 @@ fn streaming_forwards_tokens_to_sink() {
|
||||
StreamEvent::Token { delta, .. } => Some(delta),
|
||||
_ => None,
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.join("");
|
||||
.collect::<String>();
|
||||
assert_eq!(collected, canned);
|
||||
}
|
||||
|
||||
@@ -522,7 +521,7 @@ fn answer_json_serializes_with_expected_keys() {
|
||||
let answer = pipeline.ask("what", default_opts()).unwrap();
|
||||
let v: serde_json::Value = serde_json::to_value(&answer).unwrap();
|
||||
// Stable top-level key set per `answer.v1` (§2.3).
|
||||
let keys: Vec<&str> = v.as_object().unwrap().keys().map(|s| s.as_str()).collect();
|
||||
let keys: Vec<&str> = v.as_object().unwrap().keys().map(std::string::String::as_str).collect();
|
||||
for needed in [
|
||||
"answer",
|
||||
"citations",
|
||||
|
||||
Reference in New Issue
Block a user