feat(config): normalize enable flags and add extraction.ocr subtable - #735
Conversation
There was a problem hiding this comment.
Pull request overview
This PR normalizes extraction-related config enable flags, adds a dedicated OCR subtable for independent OCR control, and wires OCR settings into the extraction pipeline, while also cleaning up duration formatting and documentation around timeouts.
Changes:
- Rename
extraction.enabled→extraction.enablewith TOML/env deprecation + migration; add[extraction.ocr](enable,confidence_threshold) and validate threshold range. - Update extraction pipeline defaults/constructors to conditionally include OCR extractors and optionally filter OCR TSV output by confidence.
- Remove
extraction.text_timeoutfrom the config surface and improveFormatDurationoutput for whole minutes/hours; update docs/tests accordingly.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
internal/extract/pipeline_test.go |
Updates pipeline tests for the expanded DefaultExtractors signature. |
internal/extract/pipeline.go |
Updates default extractor fallback to include new OCR-enabled/threshold parameters. |
internal/extract/ocr_test.go |
Adds unit tests for TSV confidence filtering behavior. |
internal/extract/ocr_progress_test.go |
Updates progress extraction tests for the expanded DefaultExtractors signature. |
internal/extract/ocr_coverage_test.go |
Updates coverage tests for the expanded DefaultExtractors signature. |
internal/extract/ocr.go |
Adds filterTSVByConfidence helper to drop low-confidence OCR rows. |
internal/extract/extractor_test.go |
Extends tests for OCR enable/disable and confidence passthrough. |
internal/extract/extractor.go |
Extends DefaultExtractors, adds OCR confidence threshold handling in OCR extractors. |
internal/config/show_test.go |
Updates expectations for FormatDuration, enable key, and removal of text_timeout. |
internal/config/show.go |
Adds extraction.enabled deprecation mapping and improves FormatDuration formatting. |
internal/config/config_test.go |
Updates extraction enable env/key tests; adds migration tests and OCR config tests/validation coverage. |
internal/config/config.go |
Introduces Extraction.Enable, keeps deprecated Enabled, adds Extraction.OCR subtable, removes TextTimeout, adds OCR validation, adds TOML/env migration for renamed keys. |
docs/content/docs/reference/configuration.md |
Updates configuration reference for new keys, removed text_timeout, and corrects llm.timeout semantics. |
cmd/micasa/main.go |
Wires OCR enable/threshold into DefaultExtractors; stops exposing text_timeout. |
.claude/codebase/types.md |
Updates codebase type docs to reflect new config shape. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "extraction.enabled is deprecated -- use extraction.enable instead", | ||
| ) | ||
| } | ||
| cfg.Extraction.Enabled = nil // never propagate the deprecated field | ||
|
|
There was a problem hiding this comment.
extraction.enabled is being cleared in migrateRenamedKeys, but the deprecated Enabled field can be repopulated by applyEnvOverrides when MICASA_EXTRACTION_ENABLED is set. That leaves both Extraction.Enable and Extraction.Enabled populated, which can cause duplicated/confusing output in ShowConfig (both enable and deprecated enabled keys showing as set). Consider clearing cfg.Extraction.Enabled after env overrides as well (and/or explicitly skipping env application for deprecated fields) so the deprecated field never propagates in the resolved config.
Rename extraction.enabled -> extraction.enable and add extraction.ocr subtable with enable and confidence_threshold fields. Add TOML key and env var deprecation entries so existing configs continue to work with warnings. - Rename Extraction.Enabled to Extraction.Enable (TOML: enable) - Keep deprecated Enabled field for backward compat migration - Add OCR struct with Enable and ConfidenceThreshold - Add filterTSVByConfidence to drop low-confidence OCR words - DefaultExtractors now accepts ocrEnabled and confidenceThreshold - Wire OCR config through cmd/main.go to extractors - Add migration tests, OCR config tests, confidence filter tests - Update docs and example TOML closes #729 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
pdftotext is fast enough that a user-configurable timeout adds no value. The 30s safety net remains as an internal default in the extract package (DefaultTextTimeout) but is no longer exposed as a config field, env var, or documented option. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
FormatDuration now handles whole-minute and whole-hour multiples (e.g. "5m" instead of "5m0s", "2h" instead of "2h0m0s"). Also corrects docs that incorrectly described llm.timeout as a 5s quick-op timeout — it's actually a 5m HTTP response timeout. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
applyEnvOverrides repopulates Extraction.Enabled from MICASA_EXTRACTION_ENABLED after migrateRenamedKeys already cleared it. Clear it again post-env-overrides so both fields never coexist in the resolved config. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
6b5244c to
eb4f3f3
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| var deprecatedPaths = map[string]string{ | ||
| "documents.cache_ttl_days": "documents.cache_ttl", | ||
| "extraction.enabled": "extraction.enable", | ||
| "extraction.model": "llm.extraction.model", | ||
| "extraction.thinking": "llm.extraction.thinking", |
There was a problem hiding this comment.
deprecatedPaths includes extraction.enabled, but the loader migrates and then always clears cfg.Extraction.Enabled (both in migrateRenamedKeys and again after env overrides). As a result, ShowConfig can never emit the deprecated enabled = ... line with a DEPRECATED annotation, making this entry effectively dead. Either preserve the deprecated field for display (consistent with other deprecated keys like extraction.model) or remove this deprecatedPaths entry to avoid misleading future readers.
Codecov Report❌ Patch coverage is Additional details and impacted files
🚀 New features to boost your workflow:
|
…735) ## Summary - Rename `extraction.enabled` to `extraction.enable` with TOML key migration and env var deprecation (`MICASA_EXTRACTION_ENABLED` -> `MICASA_EXTRACTION_ENABLE`) - Add `[extraction.ocr]` subtable with `enable` (bool) and `confidence_threshold` (int) fields for independent OCR control - Wire OCR config through `DefaultExtractors` — OCR extractors conditionally included based on `extraction.ocr.enable`, low-confidence words filtered by `confidence_threshold` - Remove `text_timeout` from the config surface — pdftotext is fast, the 30s safety net stays as an internal `DefaultTextTimeout` constant - Fix `FormatDuration` to produce clean notation for whole minutes/hours (`5m` not `5m0s`) - Fix docs that incorrectly described `llm.timeout` as a 5s quick-op timeout (it is a 5m HTTP response timeout) closes #729 --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Summary
extraction.enabledtoextraction.enablewith TOML key migration and env var deprecation (MICASA_EXTRACTION_ENABLED->MICASA_EXTRACTION_ENABLE)[extraction.ocr]subtable withenable(bool) andconfidence_threshold(int) fields for independent OCR controlDefaultExtractors— OCR extractors conditionally included based onextraction.ocr.enable, low-confidence words filtered byconfidence_thresholdtext_timeoutfrom the config surface — pdftotext is fast, the 30s safety net stays as an internalDefaultTextTimeoutconstantFormatDurationto produce clean notation for whole minutes/hours (5mnot5m0s)llm.timeoutas a 5s quick-op timeout (it is a 5m HTTP response timeout)closes #729