fix(review): align quality threshold, cap + DRY scan coverage, warn on failure
Address PR #863 review: - MIN_TEXT_QUALITY 0.45 -> 0.5 so the module/diagnostic default matches the DOCUMENT_OCR_MIN_TEXT_QUALITY setting (registry always passes the setting; this keeps classify_pdf and the test/default path on the production threshold). - image_coverage_per_page is bounded to MAX_SAMPLED_PAGES (the image pass is the costly part, so a 200-page scan isn't fully rasterised on the hot path); pages beyond the cap fall back to the text-quality signal, and page_fraction still gates over every page. - Extracted _page_image_coverage(page) helper, shared by classify_pdf and image_coverage_per_page (DRY + keeps the tiling-double-count note in one place). - Scan-detection failure logs at WARNING (not DEBUG) so a systematic failure on an OCR-enabled tenant is visible at LOG_LEVEL=INFO. - Add the missing DOCUMENT_OCR_MIN_PAGE_CHARS range-validator test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
b1f347b8fc
commit
fbc9a3a675
@@ -248,7 +248,10 @@ class ProcessorRegistry:
|
||||
try:
|
||||
image_coverage = image_coverage_per_page(content)
|
||||
except Exception:
|
||||
logger.debug(
|
||||
# Best-effort: fall back to text-only signals. WARNING
|
||||
# (not DEBUG) so a systematic scan-detection failure on an
|
||||
# OCR-enabled tenant is visible at LOG_LEVEL=INFO.
|
||||
logger.warning(
|
||||
"Scan detection failed for %s; using text-only signals",
|
||||
filename or "<bytes>",
|
||||
exc_info=True,
|
||||
|
||||
Reference in New Issue
Block a user