Mailbox Leases for Reliable AI Email Tests
说明与用途
AI 邮件测试常因共享收件箱导致不稳定。解决方案是为每个运行分配临时租约,设置消息游标,并记录失败收据,确保所有权、隔离和清晰日志。
问题
AI email tests suffer from flaky results because multiple runs share a mailbox, leading to ownership ambiguity and race conditions.
结果
Tests become deterministic, retries are meaningful, and failure logs contain actionable context without exposing sensitive data.
工作流
- Acquire a mailbox lease with a TTL
- Create a cursor before sending the signup request
- Trigger the signup request using the lease address
- Wait for a message after the cursor with a subject filter
- Assert the message belongs to the run
- Open the verification URL in a browser
- Release the lease in a finally block
证据
A lease is simply a record that says: this run owns this mailbox until a known expiry time.
The cursor matters as much as the address. If a retry asks for “the newest message,” an old token can win a race against the new one.
- 记录日期: 2026-10-08T21:55:59.376Z