Mailbox Leases for Reliable AI Email Tests
Описание и применение
В тестах AI для проверки email часто возникает нестабильность из‑за общего почтового ящика. Решение – выдавать каждому запуску временный lease, фиксировать курсор и сохранять отчёт об ошибке, что обеспечивает владение, изоляцию и понятные логи.
Задача
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