마지막 commit. 모든 .md 안의 `kb` 단어 일괄 갱신. - 19 개 crate 이름 (`kb-core`, `kb-app`, …) → `kebab-*` (Rust 모듈 path 표기 `kb_*` → `kebab_*` 포함). - 미래 component (`kb-tui`, `kb-desktop`, `kb-asr-whisper`, `kb-ocr`, `kb-mcp`, `kb-vlm`, `kb-rerank`, `kb-vision-ocr`, `kb-index`, `kb-smoke`, `kb-architecture`) → `kebab-*` (P6+ 가 시작될 때 같은 prefix 사용). - CLI 명령 예제: `kb ingest` / `kb search` / `kb ask` / `kb init` / `kb doctor` / `kb inspect` / `kb list` / `kb eval` → `kebab <verb>`. fenced code block + 인라인 backtick 모두. - XDG paths + env vars + binary 경로 (`target/release/kb` → `target/release/kebab`) 동기화. - design doc / 최초 보고서 / SMOKE / HOTFIXES / phase epic / task spec 모든 reference 통일. - task-decomposition.md 의 `git -c user.name=kb` 는 과거 git history 기록용 author 정보라 그대로 유지 (실제 git history 의 author 는 변경 불가). - `tasks/phase-5-evaluation.md` 의 `status: planned` → `completed` 도 같이 (P5-1 + P5-2 PR 머지 후 미반영분). ## 검증 - `grep -rEn "\bkb-[a-z]|\bkb_[a-z]|\.config/kb\b|kb\.sqlite|\bKB_[A-Z]" --include="*.md"` 0 hits (task-decomposition.md 의 git author 제외). - 모든 file path reference 살아있음 (renamed file 들 모두 새 path 로 update). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3.8 KiB
3.8 KiB
phase, title, status, depends_on, source
| phase | title | status | depends_on | source | |
|---|---|---|---|---|---|
| P2 | SQLite FTS5 lexical 검색 + citation | completed |
|
kebab_local_rust_report.md §10, §15, §17 Phase 2 |
P2 — SQLite FTS5 lexical 검색 + citation
목표
embedding/LLM 없이 FTS5 만으로 동작하는 검색 + citation 출력. kebab search "..." 가 chunk 와 source span 반환.
산출 crate
kebab-search(lexical 모드) —Retrievertrait 구현 1번째.kebab-store-sqlite확장: FTS5 virtual table + trigger.
FTS5 스키마
CREATE VIRTUAL TABLE chunks_fts USING fts5(
chunk_id UNINDEXED,
doc_id UNINDEXED,
heading_path,
text,
tokenize = 'unicode61 remove_diacritics 2'
);
CREATE TRIGGER chunks_ai AFTER INSERT ON chunks BEGIN
INSERT INTO chunks_fts(chunk_id, doc_id, heading_path, text)
VALUES (new.chunk_id, new.doc_id, new.heading_path, new.text);
END;
CREATE TRIGGER chunks_ad AFTER DELETE ON chunks BEGIN
DELETE FROM chunks_fts WHERE chunk_id = old.chunk_id;
END;
CREATE TRIGGER chunks_au AFTER UPDATE ON chunks BEGIN
DELETE FROM chunks_fts WHERE chunk_id = old.chunk_id;
INSERT INTO chunks_fts(chunk_id, doc_id, heading_path, text)
VALUES (new.chunk_id, new.doc_id, new.heading_path, new.text);
END;
scoring: bm25(chunks_fts) 사용. snippet 표시는 snippet(chunks_fts, 3, '<b>', '</b>', '…', 16).
한국어 토크나이저: unicode61 기본. CJK 향상 필요 시 trigram 보조 인덱스 검토 (P2 범위 밖, 후순위 노트).
SearchQuery / SearchHit
pub struct SearchQuery {
pub text: String,
pub mode: SearchMode, // P2: SearchMode::Lexical 만
pub k: usize, // default 10
pub filters: SearchFilters, // tag, lang, path glob
}
pub struct SearchHit {
pub chunk_id: ChunkId,
pub doc_id: DocumentId,
pub score: f32, // bm25 score 정규화
pub text: String, // snippet 또는 full chunk text
pub citation: Citation, // file path + line range
pub retrieval_method: String,// "fts5-bm25"
pub index_version: String,
}
Citation 형식: notes/rust/kebab.md:L12-L34.
인덱스 라이프사이클
- ingest 시 trigger 로 자동 동기화.
kebab index --rebuild-ftscommand 로 FTS table 재구축 (chunker version bump 후 사용).index_version은(schema_version, fts_config_hash)조합.
kebab-app facade 확장
pub fn search(query: SearchQuery) -> anyhow::Result<Vec<SearchHit>>;
CLI
kebab search "Rust workspace 설계" [--k 10] [--tag rust] [--mode lexical]
kebab index --rebuild-fts
출력 예:
1. [0.82] Rust workspace는 여러 package를 하나로 관리한다…
doc: notes/rust/kebab.md
citation: notes/rust/kebab.md:L12-L34
heading: 아키텍처 > Rust workspace
테스트
- fixture corpus 대상 known query → 기대 chunk 가 top-k 안에 들어오는지.
- citation 의 line range 가 원본 파일에서 실제 텍스트와 일치 (round-trip).
- 동일 query 재실행 시 결과 deterministic.
- empty corpus / 0건 hit 정상 처리 (panic 금지).
의존성 경계
kebab-search는kebab-store-sqlite와kebab-core만 의존.- LLM/embedding 호출 금지 (P2 단계).
- CLI 는
kebab-app통해서만 호출.
완료 조건
kebab search "..."top-k chunk 반환- 모든 결과에 citation 포함
- citation line range 가 원본과 일치
- 한영 혼합 query 동작 (한국어 토큰화 한계는 노트로)
- golden query fixture 1차 셋 정의 (P5 에서 본격 활용)
리스크 / 주의
- 한국어 형태소 분석 없음 → recall 한계. P3 vector search 가 보완.
- bm25 score 절대값은 상대 비교용. UI 노출 시 정규화 필요.
- FTS trigger 가 transaction 안에서 도는지 확인. 대량 ingest 성능에 영향.