procurement-ingest/lambdas/po/email_processor/tests
Adam Moussa 8d52cfadef
Some checks are pending
Deploy / deploy (push) Waiting to run
feat: Python derived-field classifier with shadow telemetry (PO PR 2) (#106)
* feat: Python derived-field classifier with shadow telemetry for PO ingest

Port the site_code/trade/fiscal_year rules from EXTRACTION_PROMPT into a
pure, total derived_fields module applied in the shared enrich_parsed()
post-stage. Python fills gaps on both parse paths (the template path has
no LLM values, closing the derived-field gap opened by the PR #105
two-PR split) and never overwrites a non-null LLM value; on ai_fallback
a DerivedFieldAgreement EMF record per field shadows Python against the
LLM during the bake. Rules hardened against a full-corpus backtest
(3,422 real emails vs the LLM-written baseline): site_code 99.4% with
zero Python-wrong cases, fiscal_year 100%, trade 96.8% ex-deliberate.
Also: quantity/price now declared numeric in the prompt, and
derived_fields.py added to the po_stack bundling copy (deploy-time
ImportError otherwise).

* fix: security-review hardening — EMF value length clamp, aggregate trade CPU budget

sh-security-review (4 detectors + proof-or-kill verifier): PASS, 0
confirmed critical/high. Fixes the one confirmed low (unbounded
LLM-value str() into the DerivedFieldAgreement EMF log line, clamped to
64 chars) and adds the verifier-recommended defense-in-depth aggregate
character budget across line items in derive_trade (per-item caps alone
allowed ~10s full-core on a pathological direct-call input; unreachable
through the deployed handler but cheap to bound). Bundling cp list now
carries a warning comment (GPT-4.1 cross-review FIX).
2026-07-17 11:47:33 -04:00
..
fixtures feat: template-first PO parser with fail-closed gate and Bedrock fallback (#105) 2026-07-16 17:50:59 -04:00
_po_parser_support.py feat: Python derived-field classifier with shadow telemetry (PO PR 2) (#106) 2026-07-17 11:47:33 -04:00
conftest.py feat: template-first PO parser with fail-closed gate and Bedrock fallback (#105) 2026-07-16 17:50:59 -04:00
test_po_bedrock_fallback.py feat: Python derived-field classifier with shadow telemetry (PO PR 2) (#106) 2026-07-17 11:47:33 -04:00
test_po_derived_fields.py feat: Python derived-field classifier with shadow telemetry (PO PR 2) (#106) 2026-07-17 11:47:33 -04:00
test_po_derived_wiring.py feat: Python derived-field classifier with shadow telemetry (PO PR 2) (#106) 2026-07-17 11:47:33 -04:00
test_po_parser.py feat: template-first PO parser with fail-closed gate and Bedrock fallback (#105) 2026-07-16 17:50:59 -04:00
test_po_validation_gate.py feat: template-first PO parser with fail-closed gate and Bedrock fallback (#105) 2026-07-16 17:50:59 -04:00