Files
LibreMail/app
JMR-dev b03e363888 perf(yahoo): respect Yahoo/AOL IMAP limits & avoid the 1-hour auth lockout
Yahoo/AOL trip an automated ~1-hour service lockout after too many rapid or
failed authentication attempts. An unguarded login repeater (notably the IDLE
reconnect loop, which starts at a 5s backoff) could fire several failed LOGINs
within the first minute and lock out a real user for an hour. Add a proactive,
Yahoo/AOL-scoped auth circuit-breaker that spaces out login attempts so we never
reach the lockout, building on the #360 reactive throttle framework rather than
reinventing it.

New (org.libremail.mail), all host-keyed so only Yahoo/AOL are gated:
- ProviderAuthPolicy: per-host AuthCadencePolicy (Yahoo/AOL enabled, everything
  else DISABLED). Also exposes the documented 5-connection and 10k-folder caps.
- AuthBackoff: pure schedule — exponential equal-jitter ramp (base 60s -> 30s
  floor after jitter, cap 15m) up to a 4-failure threshold, then a fixed 30m
  open-circuit window. Every wait stays well under the ~1h lockout.
- AuthThrottleGate (@Singleton): per-account state; onAuthFailure / onAuthSuccess
  / remainingAuthBlockMillis, PII-free logging.

Enforcement:
- ImapClient guards every real LOGIN (connect-per-op, reuse connect/reconnect,
  and the IDLE connection): skips the login (AuthBackoffException) while backing
  off, arms the gate on an AuthenticationFailedException, clears it on success.
  A transient (non-auth) connect error never arms the backoff.
- MailBackfiller skips an auth-blocked account exactly as it skips a reactively
  throttled one (#360), so BackfillPacer (#356) never spins a cooldown on it.

The 5-connection cap is already satisfied by connection reuse (#125/#357: ~1 warm
socket + 1 IDLE per account); the 10k folder truncation is respected for free by
backfill stopping when the server returns nothing older.

Tests: pure-schedule, policy-resolution, gate (virtual time, incl. composition
with #360), GreenMail enforcement (auth-fail arms / transient does not / blocked
skips), and an on-device instrumented gate test.

Closes #362
2026-07-08 19:39:13 -05:00
..