Status: PASSED 2026-03-16
Highest-priority test. Verifies that the state serialised by send_continuation_email() (orchestrator.py line ~1399) is fully recoverable by parse_email_message(). Catches any field name mismatches or serialisation bugs before they hit production.
All 14 fields round-tripped correctly through MIME encode/decode, including unicode content in working_note and original_subject. Test script: test_attachment_roundtrip.py.
Fields confirmed: type, original_message_id, original_subject, original_from, iteration, total_iterations, working_note (with unicode), gathered_note_keys, gathered_email_refs, failed_fetches, attempted_searches, bundle_key, current_phase, idle_count.
[2026-03-16 12:36:50] INFO Sent continuation email for <orig-1@critchley.biz> (total iterations: 7)
[2026-03-16 12:36:51] INFO Parsed continuation email: Re: Test subject with unicode — em dash (iteration 3, total 7)
PASS — all fields round-tripped correctly
Intercept SMTP rather than actually sending. Patch smtplib.SMTP with a mock that captures the MIME bytes. Feed those bytes to parse_email_message() and assert all fields round-trip.
cd ~/py/envoy && python3 test_attachment_roundtrip.py
All fields in continuation_data survive the MIME encode/decode cycle without loss or mutation.