fix(document-processors): correct cascade escalation metric + review nits

Address round-1 review on PR #914:
- Attribute the OCR hop in a fast->structured->ocr inline cascade to
  from_tier="structured" (not a second "fast" escalation), so
  astrolabe_document_escalation_total per-tier counts stay accurate.
- Add test_inline_fast_structured_ocr_cascade pinning that two-hop path and the
  metric attribution.
- Note in classify_from_text that its doc-level control ratio is over full_text
  (all pages), not the sampled subset classify_pdf uses.
- Clarify that corrupt_glyphs never lands in the suppressed-escalation counter.
- Dedupe the glyph-corrupt test string into tests/fixtures/glyph_corruption.py.
- Use pytest.approx for the control-char-ratio zero checks (SonarCloud S1244).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Chris Coutinho
2026-06-16 20:17:56 +02:00
co-authored by Claude Opus 4.8
parent cf7209cd85
commit d5286e39d6
6 changed files with 65 additions and 18 deletions
@@ -287,7 +287,9 @@ document_escalation_total = Counter(
document_escalation_suppressed_total = Counter(
"astrolabe_document_escalation_suppressed_total",
"Would-be tier escalations suppressed because the target tier is disabled",
# reason: low_confidence | empty_text
# reason: low_confidence | empty_text. (corrupt_glyphs never appears here: it
# targets the structured tier, which has no enabled-gate -- if registered it
# runs, else there is nothing to suppress -- so it only ever hops or returns.)
["from_tier", "to_tier", "reason"],
)