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>
112 lines
4.1 KiB
Rust
112 lines
4.1 KiB
Rust
//! Integration: kebab_app::ingest_file_with_config copies external file
|
|
//! to _external/, ingests as single asset, idempotent on second call.
|
|
|
|
use std::fs;
|
|
|
|
use kebab_config::Config;
|
|
|
|
#[test]
|
|
fn ingest_file_copies_external_md_and_reports_new() {
|
|
let dir = tempfile::tempdir().unwrap();
|
|
let workspace = dir.path().join("notes");
|
|
let data = dir.path().join("data");
|
|
fs::create_dir_all(&workspace).unwrap();
|
|
fs::create_dir_all(&data).unwrap();
|
|
|
|
let mut cfg = Config::defaults();
|
|
cfg.workspace.root = workspace.to_string_lossy().into_owned();
|
|
cfg.storage.data_dir = data.to_string_lossy().into_owned();
|
|
cfg.models.embedding.provider = "none".to_string();
|
|
cfg.models.embedding.dimensions = 0;
|
|
|
|
// Source file outside the workspace.
|
|
let external_src = dir.path().join("source.md");
|
|
fs::write(&external_src, "# Hello\n\nbody.").unwrap();
|
|
|
|
let report = kebab_app::ingest_file_with_config(cfg.clone(), &external_src).unwrap();
|
|
assert_eq!(report.scanned, 1, "{report:?}");
|
|
assert_eq!(report.new, 1, "{report:?}");
|
|
assert_eq!(report.unchanged, 0, "{report:?}");
|
|
|
|
// _external/ dir created, file copied with hash prefix.
|
|
let ext_dir = workspace.join("_external");
|
|
assert!(ext_dir.is_dir());
|
|
let entries: Vec<_> = fs::read_dir(&ext_dir)
|
|
.unwrap()
|
|
.filter_map(std::result::Result::ok)
|
|
.collect();
|
|
assert_eq!(entries.len(), 1, "exactly one file in _external/");
|
|
let name = entries[0].file_name().to_string_lossy().into_owned();
|
|
assert!(name.ends_with(".md"));
|
|
|
|
// .kebabignore has _external/ line.
|
|
let ki = fs::read_to_string(workspace.join(".kebabignore")).unwrap();
|
|
assert!(ki.lines().any(|l| l.trim() == "_external/"));
|
|
}
|
|
|
|
#[test]
|
|
fn ingest_file_idempotent_on_second_call() {
|
|
let dir = tempfile::tempdir().unwrap();
|
|
let workspace = dir.path().join("notes");
|
|
let data = dir.path().join("data");
|
|
fs::create_dir_all(&workspace).unwrap();
|
|
fs::create_dir_all(&data).unwrap();
|
|
|
|
let mut cfg = Config::defaults();
|
|
cfg.workspace.root = workspace.to_string_lossy().into_owned();
|
|
cfg.storage.data_dir = data.to_string_lossy().into_owned();
|
|
cfg.models.embedding.provider = "none".to_string();
|
|
cfg.models.embedding.dimensions = 0;
|
|
|
|
let src = dir.path().join("doc.md");
|
|
fs::write(&src, "# A\n\nbody.").unwrap();
|
|
|
|
let r1 = kebab_app::ingest_file_with_config(cfg.clone(), &src).unwrap();
|
|
assert_eq!(r1.new, 1);
|
|
|
|
let r2 = kebab_app::ingest_file_with_config(cfg.clone(), &src).unwrap();
|
|
assert_eq!(r2.new, 0, "{r2:?}");
|
|
assert_eq!(r2.unchanged, 1, "{r2:?}");
|
|
}
|
|
|
|
#[test]
|
|
fn ingest_file_errors_on_missing_path() {
|
|
let dir = tempfile::tempdir().unwrap();
|
|
let workspace = dir.path().join("notes");
|
|
let data = dir.path().join("data");
|
|
fs::create_dir_all(&workspace).unwrap();
|
|
fs::create_dir_all(&data).unwrap();
|
|
|
|
let mut cfg = Config::defaults();
|
|
cfg.workspace.root = workspace.to_string_lossy().into_owned();
|
|
cfg.storage.data_dir = data.to_string_lossy().into_owned();
|
|
cfg.models.embedding.provider = "none".to_string();
|
|
cfg.models.embedding.dimensions = 0;
|
|
|
|
let nonexistent = dir.path().join("nope.md");
|
|
let err = kebab_app::ingest_file_with_config(cfg, &nonexistent).unwrap_err();
|
|
assert!(err.to_string().contains("does not exist"), "{err}");
|
|
}
|
|
|
|
#[test]
|
|
fn ingest_file_errors_on_unsupported_extension() {
|
|
let dir = tempfile::tempdir().unwrap();
|
|
let workspace = dir.path().join("notes");
|
|
let data = dir.path().join("data");
|
|
fs::create_dir_all(&workspace).unwrap();
|
|
fs::create_dir_all(&data).unwrap();
|
|
|
|
let mut cfg = Config::defaults();
|
|
cfg.workspace.root = workspace.to_string_lossy().into_owned();
|
|
cfg.storage.data_dir = data.to_string_lossy().into_owned();
|
|
cfg.models.embedding.provider = "none".to_string();
|
|
cfg.models.embedding.dimensions = 0;
|
|
|
|
let docx = dir.path().join("doc.docx");
|
|
fs::write(&docx, b"fake docx bytes").unwrap();
|
|
|
|
let err = kebab_app::ingest_file_with_config(cfg, &docx).unwrap_err();
|
|
assert!(err.to_string().contains("unsupported extension"), "{err}");
|
|
assert!(err.to_string().contains(".docx") || err.to_string().contains("docx"), "{err}");
|
|
}
|