refactor(config): OCR 중복 제거 — 공유 [ingest.ocr] 엔진 블록 + v4→v5 마이그레이션
Phase 2 Unit 1. OcrCfg(image) 13필드가 PdfOcrCfg(pdf) 와 전부 중복(image 고유 0, pdf 고유 4) + apply_env 에 KEBAB_IMAGE_OCR_*/KEBAB_PDF_OCR_* 27 arm 복제를 제거한다. - 신규 SharedOcrEngineCfg(13 공유 필드, 전부 Option, default None) = [ingest.ocr]. 엔진 설정 단일 출처. image/pdf 블록은 on/off 토글 + override. - load-time resolution(Config::resolve_ocr, from_file 호출): 공유 필드가 Some 이고 미디어 블록이 그 키 미명시면 concrete OcrCfg/PdfOcrCfg 로 overlay(presence 는 toml::Value 로 판정; 미디어 > 공유 > 내장 default). struct 필드는 그대로 두고 엔진 필드에 #[serde(default)] 만 추가(slim 블록 파싱) → image(gemma4:e4b/1600) vs pdf(qwen2.5vl:3b/2048) 미디어별 기본값 보존. - resolver Config::image_ocr()/pdf_ocr() 추가. consumer(kebab-parse-image, kebab-app build_*_ocr_engine·ingest gate·pdf_ocr_apply·ingest_config_signature)가 전부 경유 → god-struct 직접 read 제거. - apply_env: 27 arm → 공유 KEBAB_OCR_* 12 arm(image+pdf 동시) + pdf 고유 4 arm + 미디어별 KEBAB_IMAGE_OCR_ENABLED/KEBAB_PDF_OCR_ENABLED. - step_4_to_5: [ingest.image.ocr] 12 엔진 키를 [ingest.ocr] 로 move_table(enabled 제외). pdf 블록 무손상(reconcile 이 채워 공유 overlay 오염 X). annotated_default 도 동일 통합으로 v5 canonical 형상. CURRENT_SCHEMA_VERSION=5. - v4→v5 round-trip 테스트(비-default image engine 보존 + pdf 오염 X + 멱등). effective OCR 바이트 동일 → ingest_config_signature 불변 → 강제 재색인 없음. 검증: clippy --workspace --all-targets 0 / kebab-config·kebab-parse-image· kebab-parse-pdf·kebab-app 테스트 pass. surface: README [ingest.ocr] 절 + SMOKE config 블록 + DOGFOOD env + HOTFIXES dated entry. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012Mc6W1fgsrbFKTsqA6P8La
This commit is contained in:
@@ -354,15 +354,16 @@ fn from_parts_clamps_max_pixels_into_legal_range() {
|
||||
/// Run with:
|
||||
///
|
||||
/// ```sh
|
||||
/// KEBAB_IMAGE_OCR_ENDPOINT=http://192.168.0.47:11434 \
|
||||
/// KEBAB_OCR_ENDPOINT=http://192.168.0.47:11434 \
|
||||
/// cargo test -p kebab-parse-image --test ocr ocr_integration -- --ignored
|
||||
/// ```
|
||||
#[tokio::test]
|
||||
#[ignore = "hits a real Ollama daemon; opt in via `cargo test -- --ignored`"]
|
||||
async fn ocr_integration_real_ollama_transcribes_text() {
|
||||
let endpoint = std::env::var("KEBAB_IMAGE_OCR_ENDPOINT")
|
||||
// v5: shared KEBAB_OCR_* env (manual harness reads it directly).
|
||||
let endpoint = std::env::var("KEBAB_OCR_ENDPOINT")
|
||||
.unwrap_or_else(|_| "http://192.168.0.47:11434".to_string());
|
||||
let model = std::env::var("KEBAB_IMAGE_OCR_MODEL").unwrap_or_else(|_| "gemma4:e4b".to_string());
|
||||
let model = std::env::var("KEBAB_OCR_MODEL").unwrap_or_else(|_| "gemma4:e4b".to_string());
|
||||
|
||||
// Generate a fixture with known text. If the DejaVu font is
|
||||
// missing from this dev box, skip rather than crash.
|
||||
|
||||
Reference in New Issue
Block a user