Bläddra i källkod

docs(mail): verified against a live server, and what that does not prove

Every claim in the mail section was re-measured against a real IMAP and
SMTP server rather than a fixture, and all of them held: LIST and
modified-UTF-7 decoding, EXAMINE reporting a read-only mailbox, UID
SEARCH UNSEEN, a peek fetch leaving a genuinely unseen message unseen,
the direct parse of a GOOD fetch returning NeedMore while the framed
re-parse returns Ok, no tagged line in the buffer, and a multi-uid UID
FETCH delivering zero bytes.

A send-and-read-back round trip confirmed the encoders end to end: an
accented Hungarian subject came back as two =?UTF-8?B? encoded words and
decoded exactly, quoted-printable was chosen for the accented text, a
lone "." body line arrived intact and not double-stuffed, the attachment
filename survived as an RFC 2231 parameter, and BODYSTRUCTURE numbered
the text 1.1 inside an alternative inside a mixed with the attachment
at 2.

The note also records what the flag test does NOT prove: EXAMINE alone
prevents a flag change, so a green result there confirms the read path is
safe without isolating BODY.PEEK's own contribution. Worth stating,
because the first run of that test used an already-seen message, where an
unchanged \Seen proves nothing at all.
fszontagh 1 månad sedan
förälder
incheckning
69eb778575
1 ändrade filer med 1 tillägg och 0 borttagningar
  1. 1 0
      CLAUDE.md

+ 1 - 0
CLAUDE.md

@@ -98,6 +98,7 @@ docker run -d --name svapi-dev -p 8080:8080 -e SMARTBOTIC_VECTORAPI_KEY=dev svap
 - **The mail budget has a THIRD number the embedding budget does not: `totalMs`.** An embedding call is one request/response, so bounding connect and read bounds it. A mailbox read is several round trips on one connection, and a read timeout bounds each quiet period and **not their sum** - a server answering every command just inside the read timeout holds a pooled runtime far past the run's budget without ever tripping it. `resolveMailBudget()` (`net/mail_budget.hpp`, pure) otherwise mirrors `resolveEmbedBudget()`, connect capped at half.
 - **`mailGlobalInit()` is called once from the runner's `main` before any worker starts, and FAILS CLOSED.** `curl_global_init` is not thread-safe and a lazy first-use from two pool threads is a real race. It also checks `CURL_VERSION_THREADSAFE` and refuses to start without it, in the same spirit as the runner refusing to start with no token on a non-loopback bind. **`CURLOPT_NOSIGNAL` on every handle**, or curl uses `SIGALRM` for resolution timeouts, which is unsafe off the main thread and can longjmp out of a worker - and a single-threaded test never shows it.
 - **One handle per (run, account), destroyed with the session. No `CURLSH`, no cross-tenant reuse.** A handle carries connection state and credentials. A fresh handle per command would mean a TCP connect, a TLS handshake and a LOGIN for every command, which is both slow and what gets an account throttled; a test asserts one LOGIN serves three commands.
+- **VERIFIED AGAINST A LIVE SERVER on 2026-10-08** (Dovecot-ish on `mail.onmail.hu`, IMAP 993 implicit TLS and SMTP 587 STARTTLS, credentials in `/data/dev/.env`). Everything below was measured against that server, not a fixture, and every fake-server claim in this section survived it: `LIST` and modified-UTF-7 decoding, `EXAMINE` reporting `PERMANENTFLAGS ()` read-only, `UID SEARCH` including `UNSEEN`, **a peek fetch of a genuinely UNSEEN message leaving it unseen** (the weak version of this test uses an already-seen message and proves nothing), the direct parse of a good fetch returning `NeedMore` while the framed re-parse returns `Ok`, no tagged line in the buffer, and **a multi-uid `UID FETCH` delivering zero bytes**. A full send-and-read-back round trip confirmed an accented Hungarian subject surviving as two `=?UTF-8?B?` encoded words and decoding back exactly, quoted-printable chosen for the accented text, a lone `.` body line arriving intact and not double-stuffed, an RFC 2231 attachment filename, and `BODYSTRUCTURE` part numbering of `1.1` for the text inside a `multipart/alternative` inside a `multipart/mixed` with the attachment at `2`. Note `EXAMINE` alone prevents a flag change, so that test confirms the read path is safe but does NOT isolate `BODY.PEEK`'s own contribution.
 - **The fake IMAP/SMTP servers are committed** (`runner/tests/fake_mail_server.hpp`): in-process TCP listeners on **ephemeral** ports. Ephemeral because a fixed port collides - twice during development a test reached a stale server from an earlier run and "passed" against the wrong process. They **mask credentials** before recording a transcript, and the SMTP one answers a bare `AUTH PLAIN` with a **334 challenge, not 235**: answering 235 made an earlier harness report a working login for a client that had sent no credentials. It also **un-stuffs** the leading period during DATA, as a real receiver does, or a correct client looks like it double-stuffed.
 - `src/functions/mime_words.*` is **adapted from an existing internal implementation**, is owned elsewhere, and changes flow one way INTO this repo. If a decoding bug turns up here, report it rather than fixing only this copy.