혼합 출처 KB(위키+jira 등)에서 색인은 전부 하되 질의 시 출처로 좁히는 provenance 레버. 전역 trust 곱셈가중(weighted-RRF)은 A/B 에서 반증(θ=0.85 만으로 incident MRR 0.918→0.340 절벽, 점수 압축) — 필터가 see-saw 없는 올바른 레버. - config [[workspace.sources]] (각 id/root/exclude/trust_level/source_type); 단일 root 는 implicit `default` source 로 정규화. validate: id 유일·비어있지 않음. - config schema v3→v4 (step_3_to_4, root→[[workspace.sources]] id=default 미러, 멱등) - V014 documents.source_id 컬럼+인덱스 (additive, DEFAULT 'default', 재색인 0) - Metadata.source_id + BodyHints trust precedence(frontmatter > source 기본값 > Primary) - ingest: --root 미지정 시 resolved_sources() 순회 + doc 마다 source_id/trust stamp - 검색 SearchFilters.source_type/source_id → lexical + vector 두 site (IN, OR) - CLI kebab search --source <id> / --source-type <type> (repeatable/comma-sep) 도그푸딩(620 doc, jira400+wiki220): --source wiki 로 개념 질의 MRR 0.780→0.810, --source jira 로 incident 0.918→0.975. trust precedence 실측(jira=secondary 기본값). version bump 0.28.0 → 0.29.0 (신규 CLI flag + config 키 + V014 migration → minor). follow-up: MCP search 필터 미노출 · kebab list source_id 미표시 · RAG provenance 라벨. 자세한 내용: tasks/HOTFIXES.md (2026-06-21), docs/release-notes/v0.29.0-draft.md. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012Mc6W1fgsrbFKTsqA6P8La
124 lines
4.2 KiB
Rust
124 lines
4.2 KiB
Rust
//! Integration test: kebab_app::schema_with_config returns a SchemaV1
|
|
//! that is internally consistent with a freshly-ingested TempDir KB.
|
|
|
|
use std::fs;
|
|
|
|
use kebab_config::Config;
|
|
use kebab_core::SourceScope;
|
|
|
|
fn minimal_config(data_dir: &std::path::Path, workspace_root: &std::path::Path) -> Config {
|
|
let mut config = Config::defaults();
|
|
config.workspace.root = Some(workspace_root.to_string_lossy().into_owned());
|
|
config.workspace.exclude.clear();
|
|
config.storage.data_dir = data_dir.to_string_lossy().into_owned();
|
|
config.storage.model_dir = data_dir.join("models").to_string_lossy().into_owned();
|
|
config.models.embedding.provider = "none".to_string();
|
|
config.models.embedding.dimensions = 0;
|
|
config.ingest.chunking.target_tokens = 80;
|
|
config.ingest.chunking.overlap_tokens = 20;
|
|
config
|
|
}
|
|
|
|
fn minimal_scope(workspace_root: &std::path::Path) -> SourceScope {
|
|
SourceScope {
|
|
root: workspace_root.to_path_buf(),
|
|
include: vec![],
|
|
exclude: vec![],
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn schema_report_reflects_freshly_ingested_kb() {
|
|
let temp = tempfile::tempdir().expect("tempdir");
|
|
let workspace_root = temp.path().join("workspace");
|
|
let data_dir = temp.path().join("data");
|
|
fs::create_dir_all(&workspace_root).unwrap();
|
|
fs::create_dir_all(&data_dir).unwrap();
|
|
|
|
fs::write(workspace_root.join("a.md"), "# A\n\nbody A.").unwrap();
|
|
fs::write(workspace_root.join("b.md"), "# B\n\nbody B.").unwrap();
|
|
|
|
let config = minimal_config(&data_dir, &workspace_root);
|
|
let _report =
|
|
kebab_app::ingest_with_config(config.clone(), minimal_scope(&workspace_root), false)
|
|
.unwrap();
|
|
|
|
let schema = kebab_app::schema_with_config(&config).unwrap();
|
|
|
|
assert!(!schema.kebab_version.is_empty());
|
|
assert!(
|
|
schema.wire.schemas.contains(&"schema.v1".to_string()),
|
|
"schema.v1 missing from wire.schemas: {:?}",
|
|
schema.wire.schemas
|
|
);
|
|
assert!(
|
|
schema.wire.schemas.contains(&"error.v1".to_string()),
|
|
"error.v1 missing from wire.schemas: {:?}",
|
|
schema.wire.schemas
|
|
);
|
|
assert!(schema.capabilities.json_mode);
|
|
assert!(schema.capabilities.streaming_ask); // Bug #9: streaming_ask is now true
|
|
assert!(
|
|
schema.capabilities.mcp_server,
|
|
"mcp_server should be true after fb-30",
|
|
);
|
|
assert_eq!(
|
|
schema.stats.doc_count, 2,
|
|
"expected 2 docs (a.md + b.md): {:?}",
|
|
schema.stats
|
|
);
|
|
assert!(
|
|
schema.stats.last_ingest_at.is_some(),
|
|
"last_ingest_at must be set after ingest: {:?}",
|
|
schema.stats
|
|
);
|
|
assert!(
|
|
schema.stats.chunk_count >= 2,
|
|
"expected ≥2 chunks (a.md + b.md): {:?}",
|
|
schema.stats
|
|
);
|
|
assert_eq!(
|
|
schema.stats.asset_count, 2,
|
|
"expected 2 assets (a.md + b.md): {:?}",
|
|
schema.stats
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn schema_report_on_empty_kb_has_zero_counts() {
|
|
// An empty workspace dir with no .md files: ingest_with_config scans 0
|
|
// files but still creates + migrates kebab.sqlite. This seeds the DB so
|
|
// open_existing (used inside schema_with_config) succeeds and returns
|
|
// all-zero counts.
|
|
let temp = tempfile::tempdir().expect("tempdir");
|
|
let workspace_root = temp.path().join("workspace");
|
|
let data_dir = temp.path().join("data");
|
|
fs::create_dir_all(&workspace_root).unwrap();
|
|
fs::create_dir_all(&data_dir).unwrap();
|
|
|
|
let config = minimal_config(&data_dir, &workspace_root);
|
|
// Run ingest over the empty workspace — creates kebab.sqlite, runs
|
|
// migrations, records 0 docs. schema_with_config can then open_existing.
|
|
let report =
|
|
kebab_app::ingest_with_config(config.clone(), minimal_scope(&workspace_root), false)
|
|
.unwrap();
|
|
assert_eq!(report.new, 0, "empty workspace should yield 0 new docs");
|
|
|
|
let schema = kebab_app::schema_with_config(&config).unwrap();
|
|
assert_eq!(
|
|
schema.stats.doc_count, 0,
|
|
"empty KB doc_count: {:?}",
|
|
schema.stats
|
|
);
|
|
assert_eq!(
|
|
schema.stats.chunk_count, 0,
|
|
"empty KB chunk_count: {:?}",
|
|
schema.stats
|
|
);
|
|
assert!(
|
|
schema.stats.last_ingest_at.is_none(),
|
|
"last_ingest_at must be None when no docs ingested: {:?}",
|
|
schema.stats
|
|
);
|
|
}
|