"""run.py — Lab 03 demo (offline). Processes the four synthetic documents and
shows the confidence gate, validation, the human-review queue, and the STP rate.

    python run.py
"""
from __future__ import annotations

from idp import SAMPLE_DOCS, IDPPipeline


def main() -> None:
    pipe = IDPPipeline()
    print("=" * 70)
    for name, raw in SAMPLE_DOCS.items():
        doc = pipe.process(raw)
        status = "STRAIGHT-THROUGH" if doc.straight_through else "-> HUMAN REVIEW"
        print(f"\n{name:<18} [{doc.doc_type}]  {status}")
        print(f"  fields    : {doc.extracted}")
        print(f"  validation: {doc.validation}")
        if doc.review_fields:
            print(f"  review    : {doc.review_fields}  (low confidence or failed validation)")
    print("\n" + "=" * 70)
    print(f"Straight-through-processing (STP) rate: {pipe.stp_rate():.0%}")
    print(f"Documents in human-review queue: {len(pipe.review_queue)}")
    print("\nNote: 'statement_bad_row' fails the opening+txns==closing check (an OCR")
    print("misread), and 'id_lowconf' has a blurry name + an EXPIRED id — both are")
    print("caught and routed to review instead of being auto-posted.")


if __name__ == "__main__":
    main()
