fix(review): unify "scanned" flag name + log image_coverage length drift

Address PR #863 round 3:

- classify_from_text emits the "scanned" flag (was "no_text_layer") for the
  empty-text-layer case -- same name + meaning as classify_pdf, so
  astrolabe_document_classifier_flag_total isn't split across two labels for the
  same concept (and matches the metric's documented vocab).
- classify_from_text logs at DEBUG when image_coverage length != the expected
  min(pages, MAX_SAMPLED_PAGES), so a 1:1-alignment contract break (extractor
  reorders/skips pages) surfaces instead of silently misattributing coverage.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Chris Coutinho
2026-06-05 05:10:09 +02:00
co-authored by Claude Opus 4.8
parent 0287bd9175
commit 820be135fb
2 changed files with 22 additions and 3 deletions
+2 -2
View File
@@ -174,7 +174,7 @@ def test_classify_from_text_clean_routes_fast():
def test_classify_from_text_empty_routes_ocr():
c = clf.classify_from_text("", [{"page": 1, "start_offset": 0, "end_offset": 0}])
assert c.recommended_tier == "ocr"
assert "no_text_layer" in c.flags
assert "scanned" in c.flags # unified with classify_pdf's flag name
assert c.total_chars == 0
@@ -202,7 +202,7 @@ def test_classify_from_text_junk_layer_flags_bad_text_layer():
assert c.recommended_tier == "ocr"
assert c.total_chars > 0
assert "bad_text_layer" in c.flags
assert "no_text_layer" not in c.flags
assert "scanned" not in c.flags # has text, just junk -> not the empty case
# --- quality + scan escalation triggers (Deck #207) --------------------------