Attachment Test 5: End-to-End Continuation via inject_email

Status: PASSED 2026-03-16

Integration test using one-shot orchestrator runs. Verifies the full continuation cycle: task email → max-iterations hit → continuation sent and stored in Sent → state injected → run 2 resumes with carried-over total_iterations.

Output

=== Test 5: E2E Continuation ===

Step 1: Injecting task email...
  Injected: <177367855349...@critchley.biz>

Step 2: Running orchestrator (max-iterations 1)...
  Exit code: 0
  OK: hit max continuous iterations
  OK: continuation email sent
  total_iterations after run 1: 1

Step 3: Building and injecting continuation email...
  OK: built continuation email (total_iterations=1)
  OK: injected as UNSEEN

Step 4: Running orchestrator (default iterations)...
  Exit code: 0
  OK: continuation picked up in run 2
  OK: total_iterations reached 5 (carried over from run 1: 1)
  OK: run 2 completed without hitting limit

PASS — E2E continuation cycle completed successfully

Bug Fixed During Testing

send_continuation_email() was calling _c.login() on IMAPClient, which has no such method (__init__ auto-connects via netrc). The AttributeError was silently swallowed, so the Sent IMAP copy never appeared. Fixed by replacing the manual connect/login/logout with with _IMAPClient('imap') as _c:.

What Is Tested

1. Run 1 hits --max-iterations 1 and logs Hit max continuous iterations

2. Run 1 logs Stored continuation copy in Sent folder (IMAP copy confirmed working)

3. Continuation email is built via send_continuation_email (mocked SMTP) and injected to INBOX as UNSEEN

4. Run 2 parses it as a continuation and logs Parsed continuation email

5. Run 2's total_iterations (5) exceeds run 1's (1) — state carried over

6. Run 2 completes without hitting the limit

How to Run

cd ~/py/envoy && python3 test_e2e_continuation.py
version 3  ·  created 2026-03-16  ·  updated 2026-03-16  ·  status passed