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:
2026-05-26 03:01:58 +00:00
parent a0ccc7b021
commit 7c85de065a
128 changed files with 552 additions and 472 deletions

View File

@@ -53,3 +53,6 @@ serde_json = { workspace = true }
# touch rusqlite directly (P3-3 spec: kb-store-vector must not list
# rusqlite/globset as direct deps).
rusqlite = { workspace = true }
[lints]
workspace = true

View File

@@ -189,8 +189,8 @@ mod tests {
fn make_rec(chunk_idx: u8, dim: usize) -> VectorRecord {
VectorRecord {
chunk_id: ChunkId(format!("{:032x}", chunk_idx)),
embedding_id: EmbeddingId(format!("{:032x}", 0xeeeeu16 + chunk_idx as u16)),
chunk_id: ChunkId(format!("{chunk_idx:032x}")),
embedding_id: EmbeddingId(format!("{:032x}", 0xeeeeu16 + u16::from(chunk_idx))),
vector: vec![0.1_f32; dim],
doc_id: DocumentId("aaaa".repeat(8)),
text: format!("text-{chunk_idx}"),

View File

@@ -169,16 +169,13 @@ impl LanceVectorStore {
arrow_schema::DataType::FixedSizeList(_, table_dim) => {
if (*table_dim as usize) != dim {
anyhow::bail!(
"dimension mismatch: table has dim {}, records have dim {}",
table_dim,
dim
"dimension mismatch: table has dim {table_dim}, records have dim {dim}"
);
}
Ok(())
}
other => anyhow::bail!(
"embedding column has unexpected Arrow type {:?}",
other
"embedding column has unexpected Arrow type {other:?}"
),
}
}
@@ -390,19 +387,15 @@ impl VectorStore for LanceVectorStore {
// matching `query_vec.len()`. In v1 there's typically one
// model in play; if there are several we pick the first match.
let dim = query_vec.len();
let table_name = match self
let table_name = if let Some(name) = self
.runtime
.block_on(async { find_matching_table(&self.connection, dim).await })?
{
Some(name) => name,
None => {
tracing::debug!(
target: "kebab-store-vector",
dim,
"search: no Lance table matches query dim — returning empty"
);
return Ok(Vec::new());
}
.block_on(async { find_matching_table(&self.connection, dim).await })? { name } else {
tracing::debug!(
target: "kebab-store-vector",
dim,
"search: no Lance table matches query dim — returning empty"
);
return Ok(Vec::new());
};
// Pre-fetch 2*k Lance rows; we'll filter against SQLite
@@ -574,7 +567,7 @@ fn score_from_distance(distance: f32) -> f32 {
return 0.0;
}
let sim = 1.0 - distance;
(sim + 1.0) / 2.0
f32::midpoint(sim, 1.0)
}
/// Find a Lance table whose embedding column is FixedSizeList<Float32, dim>.

View File

@@ -49,13 +49,11 @@ use std::sync::Arc;
pub fn require_avx_or_panic() {
#[cfg(target_arch = "x86_64")]
{
if !std::is_x86_feature_detected!("avx") {
panic!(
"kb-store-vector integration test requires AVX-capable hardware; \
host CPU lacks AVX. Run on an AVX-capable machine. \
See crates/kb-store-vector/tests/common/mod.rs."
);
}
assert!(std::is_x86_feature_detected!("avx"),
"kb-store-vector integration test requires AVX-capable hardware; \
host CPU lacks AVX. Run on an AVX-capable machine. \
See crates/kb-store-vector/tests/common/mod.rs."
);
}
}
@@ -167,17 +165,17 @@ pub fn make_record(
model: &str,
) -> VectorRecord {
let dim = vector.len();
let chunk_id = ChunkId(format!("{:032x}", 0x1100u32 + chunk_idx as u32));
let doc_id = DocumentId(format!("{:032x}", 0xd0c0u32 + doc_idx as u32));
let chunk_id = ChunkId(format!("{:032x}", 0x1100u32 + u32::from(chunk_idx)));
let doc_id = DocumentId(format!("{:032x}", 0xd0c0u32 + u32::from(doc_idx)));
let embedding_id =
EmbeddingId(format!("{:032x}", 0xeeee0000u32 + chunk_idx as u32));
EmbeddingId(format!("{:032x}", 0xeeee0000u32 + u32::from(chunk_idx)));
VectorRecord {
chunk_id,
embedding_id,
vector,
doc_id,
text: text.to_string(),
heading_path: heading.iter().map(|s| s.to_string()).collect(),
heading_path: heading.iter().map(std::string::ToString::to_string).collect(),
model_id: EmbeddingModelId(model.to_string()),
model_version: EmbeddingVersion("v1".to_string()),
dimensions: dim,

View File

@@ -93,14 +93,12 @@ fn vector_hits_snapshot_run_1() {
// placeholder. The placeholder JSON carries a `_comment` field
// with regeneration instructions; production fixtures (a captured
// hits array) do not.
if expected.get("_comment").is_some() {
panic!(
"snapshot fixture is a placeholder — regenerate on AVX hardware then commit. \
Path: {}. To regenerate: \
`KEBAB_UPDATE_SNAPSHOTS=1 cargo test -p kb-store-vector -- --ignored snapshot`.",
fixture.display()
);
}
assert!(!expected.get("_comment").is_some(),
"snapshot fixture is a placeholder — regenerate on AVX hardware then commit. \
Path: {}. To regenerate: \
`KEBAB_UPDATE_SNAPSHOTS=1 cargo test -p kb-store-vector -- --ignored snapshot`.",
fixture.display()
);
assert_eq!(
actual, expected,

View File

@@ -67,7 +67,7 @@ fn upsert_ten_then_search_returns_five() {
// for the rest, with small per-row jitter so they stay
// distinct in the index.
let mut v = if i < 5 { dir(0) } else { dir(1) };
v[3] = (i as f32) * 0.001;
v[3] = f32::from(i) * 0.001;
let rec = make_record(i, i, v, &format!("text-{i}"), &["A"], MODEL);
env.seed_chunk(
&rec.chunk_id.0,
@@ -264,7 +264,7 @@ fn determinism_same_query_same_top_k() {
let recs: Vec<_> = (0..6u8)
.map(|i| {
let mut v = dir(i % 4);
v[3] = (i as f32) * 0.001;
v[3] = f32::from(i) * 0.001;
let rec = make_record(i, i, v, &format!("t-{i}"), &[], MODEL);
env.seed_chunk(
&rec.chunk_id.0,