New ValueRecognitionRequired, parallel to LayoutMappingRequired, closes
a real silent gap: a statement whose header resolves but whose every
value fails to parse (the CAD bug's own failure mode) previously
returned a plain 200 with transactions:[] and no error at all. Carries
one representative candidate row (table_extract.value_recognition_preview,
built on the existing header_candidate_geometry) for the frontend to
show a user, so they can correct values without drawing a single
column region.
value_patterns threads through extract_pdf/extract_page as a new,
independent forced_mapping field (composes with auto-detection, since
a mapping with only valuePatterns and no columnMap behaves like plain
auto-detection). _money_value() gained an optional `patterns` list
tried at two breadths - discovery (every distinct pattern, used by
clustering/_dominant_money_marker, neither of which knows field
identity yet) vs. classification (just one field's own pattern, once
_classify_money already knows the field) - a first, field-scoped-only
design was caught during plan review as not actually fixing anything,
since clustering runs on raw text before any field is known.
Two more real bugs caught by this stage's own testing: the pattern
strip didn't account for a leading "-" (every negative amount silently
failed to parse even with a correct pattern); the preview's own rough
fallback zone used the wrong padding asymmetry and bled into the next
column's values.
Verified: a synthetic bare-3-letter-currency-code statement (a format
the existing symbol-based fallback genuinely can't recognize) triggers
ValueRecognitionRequired correctly, then extracts all 3 transactions
correctly once valuePatterns are supplied with zero columnMap. The
earlier CA$-fix and USD-regression tests re-run clean. measure.py
byte-identical to baseline.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>