Mailsink architecture
Mailsink captures and emulates transactional email. It never delivers to the outside world. Two usages share one engine:
- E2E / CI: ephemeral workspaces provisioned per test worker through the Admin API, idle TTL, chaos overrides, assertions through the Capture API or MCP.
- Staging / QA: persistent workspaces with drop-in Resend, Brevo and SMTP endpoints, plus a web UI to inspect rendered emails, SMTP transcripts, API calls and webhooks.
Documents
Section titled “Documents”- Project tree
- Database schema (Drizzle)
- Contracts and critical routes (Zod)
- End-to-end sequence
- Incremental roadmap
- Provider fidelity analysis (Resend, Brevo)
Key architecture decisions
Section titled “Key architecture decisions”Decisions marked owner were taken or approved by the product owner. Decisions marked proposition are the architect’s or an agent’s defaults, open to veto, each tracked in an issue.
| # | Decision | Status |
|---|---|---|
| D1 | Every HTTP surface lives inside the TanStack Start app (server routes): Admin, native /v1, Resend, Brevo, Capture, SSE, MCP. No separate Fastify/Elysia server. |
owner |
| D2 | Issues/PRs/commits in French; code, README and docs in English. Public repo, MIT. | owner |
| D3 | One Node process: an idempotent runtime (migrations, SMTP listener, workers) runs next to the HTTP handler. Single-instance by design; horizontal scaling is out of scope for v1. Boot mechanism (spike #9): the custom server entry src/server.ts alone is not enough, because the Nitro build imports it lazily at the first HTTP request (SMTP would stay closed until then). A Nitro plugin (src/runtime/nitro-plugin.ts, registered in nitro.config.ts) boots the runtime at process start and stops it on Nitro’s close hook; src/server.ts only makes requests wait for the runtime. A globalThis slot keeps one runtime across Vite HMR and across the two production bundles. In vite dev, editing runtime code restarts the runtime by itself (runtime/restart.ts: stop, then boot from the new code, restarts within 500 ms coalesced, requests meanwhile wait for the new runtime; D63). In vite dev the runtime lives in Nitro’s worker thread where signals never arrive, so the close hook is the stop path there. Shutdown in production (#55): srvx traps SIGTERM/SIGINT, drains in-flight HTTP (SERVER_SHUTDOWN_TIMEOUT, 5 s) then fires the close hook, which stops SMTP, the worker and the database; the Mailsink signal handler waits for that stop, then exits 0 (a second signal or a 17 s overrun exits 1). With CI or TEST set, srvx skips its drain and the handler stops the runtime itself. |
owner (boot mechanism approved 22/11, #56; dev restart 23/11, #72) |
| D4 | Domain logic lives in framework-agnostic packages (core, db, contracts); server routes and server functions are thin adapters. The SMTP server and MCP call the same services. |
owner |
| D5 | Postgres-backed job queue (jobs table, FOR UPDATE SKIP LOCKED) for delivery simulation and webhook retries. Works identically on Postgres and PGlite, survives restarts, no Redis. |
owner |
| D6 | In-process event bus feeds SSE, wait=true long-polling and MCP wait_for_email. Postgres LISTEN/NOTIFY bridge kept as a later option. |
owner |
| D7 | Rate limiter: in-memory token bucket per connection (single instance, D3). Headers follow the IETF draft names already used by providers. | owner |
| D8 | Binary data (attachments, raw EML) in a content-addressed blobs table (bytea), behind a BlobStore interface so a filesystem/S3 driver can follow. |
owner |
| D9 | Every message gets a raw EML: parsed from SMTP, composed with Nodemailer MailComposer for API ingestion. The UI and GET /messages/:id always have a MIME source. |
owner |
| D10 | Per-recipient status (message_recipients), aggregated on the message. Matches Brevo semantics, makes suppression and deterministic rules exact. |
owner |
| D11 | Credentials: msk_ keys stored as SHA-256 (high entropy, no slow hash needed); SMTP passwords stored with scrypt and an in-memory verified-credential cache. Webhook secrets (whsec_) stored in clear because they sign payloads. |
owner |
| D12 | Capture/MCP auth: any active key of the workspace (connection key msk_ or workspace key mskw_). The Admin key may act on any workspace with X-Mailsink-Workspace. Workspace keys exist so SMTP-only workspaces can use Capture/MCP. |
owner |
| D13 | Web UI auth: admin-key login exchanged for a signed, http-only session cookie. MAILSINK_UI_AUTH=none for local/CI. User accounts (Better Auth) are an idea for later, tracked in an issue. |
owner |
| D14 | MCP over stdio is a thin CLI (mailsink mcp) that proxies to the HTTP MCP endpoint, so stdio never needs DB access. |
owner |
| D15 | Admin and Capture routes use plain prefixes /admin/… and /capture/… (no leading _, which TanStack Router reserves for pathless layouts). No conflict with the UI, which lives under /, /login and /w/…. |
owner |
| D16 | Activity tracking (last_activity_at) is throttled in memory (one write per workspace every 15 s at most) to avoid write amplification under load. |
owner |
| D17 | i18n with Lingui (@lingui/react + macros, Vite plugin, PO catalogs). FR and EN shipped from day one; every user-facing UI string goes through Lingui. Translation PRs follow docs/contributing/translations.md. |
owner |
| D18 | Lingui source locale is English (code and docs are English); FR is a full catalog. UI locale: user choice (cookie) > Accept-Language > en. CI fails on missing FR/EN translations (lingui extract + compile --strict). |
owner |
| D19 | API, SMTP and MCP responses are not translated (stable machine-readable codes and English messages, like the providers they emulate). Only the web UI is localized. | owner |
| D20 | Ingestion channel and outgoing webhook format are strictly decoupled. Each endpoint has a scope (connectionId or null = Workspace) and a payloadFormat (unified, resend, brevo), defaulted to the connection kind for resend/brevo, unified for smtp or Workspace scope, always explicitly settable. The UI form prefills the format from the scope, adapts event labels and previews payload and signature headers; the delivery log shows the format, the exact headers and body. |
owner |
| D21 | Formatters live in packages/core/src/webhooks/formatters/ (not src/server/… inside the app) to keep D4: the dispatcher, the replay and the MCP all share them. |
owner |
| D22 | Events stored canonical only, mapped both ways per format (table in 03-contracts). email.failed added as canonical; Resend maps soft bounces to email.delivery_delayed and emits nothing for email.suppressed; Brevo emits nothing for email.failed (now invalid_email, D277); on a format change, unrepresentable events are kept but reported as unsupportedEvents. |
owner |
| D23 | Brevo webhooks are not signed (as Brevo): bearer token, basic auth and custom headers only; no X-Sib-Signature. Brevo date uses the workspace timezone (default UTC); id is a numeric endpoint id. |
owner |
| D24 | Body serialized once and stored; every attempt re-signs it with its own timestamp (Svix behaviour). Replay keeps the body bytes; mode exact (owner request, default) also copies the headers and signature, mode resign refreshes timestamp and signature. Unified signature covers "<timestamp>.<body>". |
owner |
| D25 | Identifiers stay prefixed text (con_…, UUIDv7 body) rather than raw uuid, including connectionId on endpoints. |
owner |
| D26 | Blob references use on delete cascade (attachments.blob_id) and on delete set null (messages.raw_blob_id) instead of no action, which makes the single-statement workspace cascade fail (doc 02, « blobs »). |
owner (22/11, #56) |
| D27 | newId(prefix) lives in packages/db/src/ids.ts (lowest package that needs ids: fixtures, repositories); core reuses it instead of owning core/ids.ts. |
owner (22/11, #56) |
| D28 | Fail fast at startup: when the runtime cannot start (invalid configuration, database unreachable, migration failure, SMTP port taken), the process logs the cause and exits with code 1; Docker or the orchestrator restarts it. An HTTP port already taken also exits 1 (Nitro). Migrations run at every boot, before the SMTP listener opens (#11). | owner (22/11, #56) |
| D29 | Listener variables: PORT (read by Nitro) replaces MAILSINK_HTTP_PORT; MAILSINK_SMTP_HOST (default 0.0.0.0) sits next to MAILSINK_SMTP_PORT. The environment is validated by Zod at boot (runtime/config.ts); errors name the variable, never its value. |
owner (22/11, #56) |
| D30 | Retention bounded to 60 s .. 365 days (Retention in settings.ts). |
owner (22/11, #56, PR #51) |
| D31 | Id bodies match [A-Za-z0-9-]{1,64} after the prefix; msk_ / mskw_ keys carry 16 to 128 characters after the prefix. |
owner (22/11, #56, PR #51) |
| D32 | Every custom Zod refinement carries a stable code in params.code (issue() / issueCode()), returned in validation_error details; new error code internal_error for unexpected 500s. |
owner (22/11, #56, PR #51) |
| D33 | Native API uses replyTo (camelCase); the native batch is validated item by item and accepts partial success. |
owner (22/11, #56, PR #51) |
| D34 | idleTtlSeconds on a persistent workspace is refused (idle_ttl_requires_ephemeral). |
owner (22/11, #56, PR #51) |
| D35 | Views gain description, keyPreview, baseUrl and urls { ui, capture, mcp }. |
owner (22/11, #56, PR #51) |
| D36 | Lingui config lives at the repo root (shared by the app and the pnpm i18n:* scripts); macros are compiled by Lingui 6’s native transform (no Babel or SWC plugin), recommended for Vite 8. |
owner (22/11, #56, PR #52) |
| D37 | UI locale cookie mailsink_locale (httpOnly, 1 year); the locale switcher shows endonyms, never translated (« English », « Français »). |
owner (22/11, #56, PR #52) |
| D38 | i18n:check requires complete EN and FR catalogs only; other (community) locales may be partial and fall back to English. |
owner (22/11, #56) |
| D39 | defineApi() pipeline (src/http/handler.ts): request id, authentication first, then the afterAuth extensions (rate limit #24, activity #20), then Zod parsing of params, query and body, then the handler; onResponse extensions (request log #35, rate limit headers) see every response, errors included. Authenticating before parsing keeps validation details away from anonymous callers. Every response carries X-Request-Id: req_<uuidv7>, always generated server-side (an incoming X-Request-Id is ignored). |
owner (23/11, #61) |
| D40 | HTTP status per error code (core/errors.ts): unauthorized 401 (+ WWW-Authenticate: Bearer), forbidden 403, validation_error 422 (400 for an unreadable JSON body or a missing X-Mailsink-Workspace), not_found 404, conflict and idempotency_mismatch 409, wait_timeout 408, payload_too_large 413, rate_limited 429, chaos_injected and internal_error 500 (a DomainError may override the status). Anything that is not a DomainError is logged with its request id and answered as a bare internal_error. |
owner (23/11, #61) |
| D41 | Auth rules (src/http/auth.ts): the credential is Authorization: Bearer, else the Brevo api-key header, on every route. Admin routes accept the Admin key only. Ingestion routes need a msk_ connection key: the Admin key or a mskw_ key gets 403, so does a disabled connection. A key sent with an X-Mailsink-Workspace of another workspace gets 403. Unknown, revoked or prefix-inconsistent keys get 401. When MAILSINK_ADMIN_KEY is unset, the Admin key matches nothing and a warning is logged at boot (no « local mode » yet). |
owner (23/11, #61) |
| D42 | GET /healthz reports liveness and readiness: { status, uptimeSeconds, checks: { database } }, HTTP 503 when select 1 fails or takes more than 2 s. The build copies packages/db/migrations to .output/server/migrations (Nitro compiled hook) and the runtime finds it next to the server entry (globalThis.__nitro_main__). |
owner (23/11, #61) |
| D43 | Without MAILSINK_ADMIN_KEY the admin key is disabled (warning at boot, Admin API answers 401); there is no implicit « local mode ». |
owner (23/11, #61) |
| D44 | workspaces.simulation defaults to the contract’s full default (SimulationSettings.parse({})); migration 0001 completes existing rows (defaults || simulation). Code writing JSON settings goes through the parsed contract output. |
owner (23/11, #61) |
| D45 | Design delivery brand-1 (« Jaune Poste », logo « Le Bac ») is the visual reference; its arbitrations B1-1 to B1-7 are binding: forced simulated statuses in the events API, webhook test send, demo messages, light theme by default (remembered, not following the system), self-hosted fonts, product-variant README, brief 2 for login and language switcher. See docs/design/README.md. |
owner (22/11, #36) |
| D46 | Design brief 2 (sign-in screen, header « Language and session » menu) is binding with its arbitrations B2-1 to B2-7: no remaining-attempts count exposed, 429 + Retry-After on the sign-in endpoint, new tokens --ms-danger and --ms-control-h-xl. See docs/design/README.md. |
owner (23/11, #63) |
| D47 | Job lifecycle (D5): a job done is deleted; a failing job is retried with exponential backoff (5 s, x2, capped at 15 min) and its last_error, then given up after 5 attempts (or at once on a PermanentJobError): it stays with last_error and run_at = 9999-12-31. Delivery is at least once, so handlers are idempotent. Only kinds with a handler are claimed. On stop, the tick signal aborts and claimed but unstarted jobs are handed back. |
owner (23/11, #72) |
| D48 | Message status aggregation (D10): suppressed recipients are ignored unless all are; while any recipient is in flight the least advanced in-flight status wins (queued < deferred < sent); once all are final, the most severe wins (failed > hard_bounce > soft_bounce > complained > delivered). The simulation writes sent then the final event per recipient (origin simulation) in one transaction with the message row locked; settings (#21) plug in as a DeliveryPlanner. |
owner (23/11, #72) |
| D49 | Retention pass every MAILSINK_RETENTION_INTERVAL_SECONDS (default 60): messages past the connection retention_seconds, else the workspace one; max_messages keeps the newest per workspace; orphan blobs; expired idempotency keys; api_logs and smtp_sessions with the same effective retention, rows without a workspace with the default (7 days). |
owner (23/11, #72) |
| D50 | Admin API generated values: slug <slugified name>-<6 [a-z0-9]> when absent; msk_ / mskw_ keys of 32 random bytes base64url, keyPreview = prefix + 8 characters + …; a taken slug or SMTP username answers 409 conflict (doc 03, « Admin »). |
owner (23/11, #72) |
| D51 | No msk_ key for an smtp connection: it only has its SMTP credentials (keyPreview: null); the workspace key mskw_ serves Capture and MCP (D12). |
owner (23/11, #72) |
| D52 | .env snippet variables per connection kind: RESEND_API_KEY / RESEND_BASE_URL, BREVO_API_KEY / BREVO_BASE_URL, SMTP_HOST / SMTP_PORT / SMTP_USER / SMTP_PASS. Admin listings paginate with a keyset cursor (the id of the last row). |
owner (23/11, #72) |
| D53 | Idempotency: a replayed response carries Idempotent-Replayed: true; a key over 256 characters is a 400; the request fingerprint includes the route and ignores the order of JSON keys. |
owner (23/11, #72) |
| D54 | An address listed several times in one message keeps its first kind (to > cc > bcc). | owner (23/11, #72) |
| D55 | A message whose recipients are all suppressed gets status suppressed and no simulation job. |
owner (23/11, #72) |
| D56 | A native batch with no valid item still answers 207 (not 422). | owner (23/11, #72) |
| D57 | MAILSINK_MAX_MESSAGE_BYTES caps the whole batch body first, then each composed message. |
owner (23/11, #72) |
| D58 | Composed messages get Message-ID: <msg_…@mailsink>; at most 500 links are extracted per message. |
owner (23/11, #72) |
| D59 | Capture wait=true is refused with 422 (wait_not_supported) until long polling lands (#26), rather than accepted and ignored. Superseded by D83 (wait=true implemented). |
owner (23/11, #72) |
| D60 | Capture downloads (raw EML, attachments) carry X-Content-Type-Options: nosniff, Content-Security-Policy: sandbox; default-src 'none' and Cache-Control: private, no-store: captured content is untrusted and served from the app origin. |
owner (23/11, #72) |
| D61 | hasAttachments counts real attachments only (inline cid: images do not); the Capture to filter searches to, cc and bcc, email or name. |
owner (23/11, #72) |
| D62 | docker-compose keeps PGlite data in the named volume pglite-data rather than a mounted data/ folder (a mounted folder must be writable by uid 1001 of the image). |
owner (23/11, #72) |
| D63 | vite dev restarts the runtime by itself when its code changes (debounce 500 ms, D3). |
owner (23/11, #72) |
| D64 | The e2e English fallback test uses a test locale de injected at build time by a patch of two source files, never shipped; a list of test locales behind a build flag stays the sturdier alternative. |
owner (23/11, #72) |
| D65 | Failed jobs: failJob sets jobs.failed_at; the retention pass deletes failed jobs older than MAILSINK_JOBS_FAILED_RETENTION_SECONDS (7 days by default) and warns [mailsink] jobs: N failed job(s) kept for diagnosis whenever that count changes. Visibility through the logs rather than an Admin or Capture endpoint: jobs are an operator concern with no contract yet, a count in the logs needs no new API surface, and the Phase 4 UI can add a view on the same countFailedJobs. Migration 0002 starts the grace period of jobs failed before it. |
owner (23/11, #78, see D100 to D104) |
| D66 | MAILSINK_SMTP_PUBLIC_HOST / MAILSINK_SMTP_PUBLIC_PORT override the SMTP host and port written in credentials and snippets (behind a port mapping the bound port is not the reachable one); unset, the hostname of MAILSINK_PUBLIC_URL and the bound port apply as before. Job runner tunables are MAILSINK_JOBS_* (poll interval, batch size, lease, attempts, backoff base and cap, failed retention), defaults in DEFAULT_JOB_SETTINGS (core) equal to the former constants; the backoff cap may not be below its base. |
owner (23/11, #78, see D100 to D104) |
| D67 | newId is monotonic within one process: RFC 9562 method 1, a 42-bit counter (the 12 rand_a bits and the top 30 rand_b bits) seeded at random with its top bit clear on each new millisecond and incremented within the same one; the last 32 bits stay random. Ids made in one transaction (connections of one workspace) keep their creation order. |
owner (23/11, #78, see D100 to D104) |
| D68 | Test fixtures live in @mailsink/db/testing (createTestWorkspace, createTestConnection, createTestWorkspaceWithConnection, createTestMessage, createTestRecipients, createTestBlob, createTestSuppression, pgCode): plain direct inserts; domain-shaped fixtures (captured message, queued message, ingestion target) build on them in their module. @mailsink/db re-exports its repositories by name, never export *, so a name clash fails the build. |
owner (23/11, #78, see D100 to D104) |
| D69 | Migration 0002: messages_ws_created_idx becomes (workspace_id, created_at, id) ascending (backward scan serves the capture keyset without a sort); messages_search_gin indexes to_tsvector('simple', left(subject text html, 100000)), so only the first 100 000 characters of a message are searchable (a tsvector is capped at 1 MB); retention deletes are range scans per workspace and connection instead of correlated subqueries (measured in doc 02). |
owner (23/11, #78, see D100 to D104) |
| D70 | Simulation timing (#21): the first simulate_delivery run decides every queued recipient (rules, then weighted draw) and moves it to sent at once; the final status is written once its delay is over (rule delayMs, else a latency draw), by a follow-up job the run enqueues at the earliest pending decision. Ingestion keeps enqueueing the first job at once (doc 04 showed run_at = now + latency: latency is per recipient, so it is applied by the worker). The decision snapshot { seed, overrideIds, sources, recipients[email] } is stored in messages.simulation; the run result lists its transitions with their event ids for the event bus (#26). |
owner (23/11, #82) |
| D71 | Draw and rules (#21): deferred, soft_bounce, hard_bounce, complained, failed take their rate in that order, the remainder (100 minus their sum) goes to delivered, whatever delivered declares. Rule globs match the whole address, case-insensitive, * any run (@ included), ? one character; the first match wins; a rule without status keeps the drawn status but applies its delayMs and smtpCode. Each recipient draws from its own Mulberry32 generator seeded by FNV-1a(`seed |
|
| D72 | Deferred re-queue (#21): deferred is written (event and recipient status), then the recipient is decided again 1 s plus a new delay later, with the settings in force at that moment; past 3 deferrals a 4th deferred ends as soft_bounce (reason deferred 3 times). |
owner (23/11, #82) |
| D73 | Settings resolver (#21): a field is taken whole from the first layer defining it (rates are never merged per status); openRate / clickRate come from the settings layers only, chaos from the overrides only (null by default), rateLimit from the four layers (null = unlimited). |
owner (23/11, #82) |
| D74 | Override API (#22): the three routes answer 200 with the OverrideState; activation closes the open override of the scope (expired one included, history kept) and inserts the new one in one transaction, a concurrent activation of the same scope answers 409 conflict; reset is idempotent; a connection of another workspace answers 404; expired overrides are ignored at read time and closed every 5 s by the override expiry scheduler (reset_at = expires_at). |
owner (23/11, #82) |
| D75 | Suppression list (#23): the simulation adds hard_bounce and complained addresses (first row kept on conflict); GET /capture/suppressions lists newest first with a keyset cursor (last id) and an email substring filter; DELETE /capture/suppressions?email= removes one exact address, without email the whole list; both answer { count }. |
owner (23/11, #82) |
| D80 | Stream frames: one message_events row gives one frame whose SSE id: is the row id, live and on replay (accepted -> message.created with the current summary, any other type -> message.event); derived frames (aggregated message.status with recipient: null, messages.purged, override.changed, workspace.deleted) carry no id: and are never replayed. Frames have no event: field, so every one reaches EventSource.onmessage. StreamEvent gains workspace.deleted; webhook.delivery, log.api, log.smtp wait for their view contracts (#33, #35). |
owner (23/11, #82) |
| D81 | Publication on the bus (D6) only after commit: ingestion collects its frames inside the transaction and publishes them once it committed (none for an idempotent replay); the simulate_delivery handler diffs the message event ids before and after the run (the simulation result carries no event id) and skips both queries while nobody listens to the workspace. Partly superseded by D95 (the handler no longer diffs event ids). |
owner (23/11, #82) |
| D82 | Last-Event-ID replay: the stream subscribes first and buffers live frames while it reads the 500 rows after that id in (occurred_at, id) order (events_ws_time_idx, no migration), then drops the buffered frames already replayed. An unknown id replays nothing; a client more than 500 events behind resyncs through the Capture API. A client that leaves 1 000 frames unread is disconnected. |
owner (23/11, #82) |
| D83 | wait=true: without since, since = request time; every frame of the workspace re-runs the query (coalesced), so a status filter wakes on a simulation; 408 wait_timeout after timeout, 404 if the workspace is deleted meanwhile. Lifts the D59 refusal. |
owner (23/11, #82) |
| D84 | Stream filters: types keeps the listed StreamEventTypes; connectionId drops message frames of another connection or of none; messages.purged, override.changed and workspace.deleted always pass. |
owner (23/11, #82) |
| D85 | Activity throttle (D16) is leading and trailing edge: the first touch of a 15 s window writes at once, the latest later touch is written with its own timestamp when the window closes, and a write never moves last_activity_at back. The GC pass writes pending touches first (at most one extra write per workspace per pass), so recent activity is never collected. |
owner (23/11, #82) |
| D86 | Every defineApi() call authenticated on a workspace touches it (afterAuth extension activity, awaited); Admin-only calls do not. An open SSE stream is not activity by itself: only its opening request touches, so an idle ephemeral workspace expires even with a tab open, and the GC closes the stream. |
owner (23/11, #82) |
| D87 | Ephemeral GC every 30 s (constant, no env variable): deletes ephemeral AND expires_at < now() (cascade) and publishes workspace.deleted per deleted workspace. The Admin DELETE /admin/workspaces/:id does not publish it yet. |
owner (23/11, #82) |
| D90 | Rate limit (#24): one in-memory token bucket per connection (D7), capacity burst ?? limit, continuous refill at limit / windowSeconds per second; the limit of a call is the effective rateLimit of its connection from the settings resolver (D73), so a workspace-level limit is applied per connection, not shared by the workspace. A bucket whose effective settings change starts over full. Idle full buckets are dropped above 10 000. |
owner (23/11, #87) |
| D91 | Rate limit headers: X-RateLimit-Limit = limit, X-RateLimit-Remaining = whole tokens left, X-RateLimit-Reset = seconds until the bucket is full again, Retry-After on 429 = seconds until one token is back (at least 1). No header while the effective rateLimit is null (unlimited). |
owner (23/11, #87) |
| D92 | Ingestion guard order: authentication, effective settings, rate limit, chaos draw, then body parsing. Every authenticated call spends a token (a call later refused by validation or by chaos included); a refused call reads no body and stores nothing. Applied through INGESTION_EXTENSIONS on ingestion routes only, never Admin nor Capture. |
owner (23/11, #87) |
| D93 | HTTP chaos (#25): hit when random() * 100 < errorRate, then one of httpCodes drawn uniformly; the body code is chaos_injected whatever the status (also for a drawn 429, which carries no Retry-After); the server logs one console.info line with errorCode=chaos_injected until the api_logs writer (#35). The chaos source runtime.chaosRandom and the limiter clock are injectable. |
owner (23/11, #87) |
| D94 | SMTP replies exposed for #31 (smtpGuardReply): rate limit 451 4.7.1 Rate limit exceeded, retry in Ns; chaos 421 4.3.2 Service not available, 451 4.3.0 Local error in processing, 452 4.3.1 Insufficient system storage, 550 5.7.1 Message rejected, each suffixed (chaos injected), shaped { responseCode, message } as smtp-server errors. |
owner (23/11, #87) |
| D95 | The simulate_delivery run result carries the message_events rows it wrote (with their ids, in write order) and the message connectionId; the job handler builds its frames from them and reads nothing back. Replaces the before/after diff of D81: no query per job, and a subscriber arriving during the run gets every frame, not only the aggregated status. |
owner (23/11, #87) |
| D96 | override.changed is published with the new OverrideState after every successful activation and reset of the Override API (an idempotent reset included), and by the override expiry scheduler once per workspace that lost an override in a pass (skipped when nobody listens, nothing for a workspace deleted meanwhile). The frame connectionId is the changed scope (null for the workspace or several scopes at once). |
owner (23/11, #87) |
| D97 | DELETE /admin/workspaces/:id publishes workspace.deleted like the ephemeral GC (closing open streams, ending wait=true with 404) and drops the workspace activity state; removeWorkspace resolves with the deleted id. Completes D87. |
owner (23/11, #87) |
| D98 | E2E recipe (docs/guides/e2e.md): one ephemeral workspace per Playwright worker through the Admin API (idle TTL 10 min as the safety net, DELETE at worker teardown), reset before each test (purge, override reset, suppression list emptied), assertions with wait=true and an explicit since taken before the action. The e2e server of the repository runs with a fixed, non-secret admin key (E2E_ADMIN_KEY overrides it) and MAILSINK_JOBS_POLL_INTERVAL_MS=100. |
owner (23/11, #87) |
| D99 | Known limit, no fix: a crash between the commit of a simulation run and the deletion of its job replays the job, which may enqueue a second follow-up job for the same pending decision; that job later completes without effect (doc 02). | owner (23/11, #87) |
| D100 | Failed jobs as in D65: jobs.failed_at, purged by retention after MAILSINK_JOBS_FAILED_RETENTION_SECONDS (7 days); visible through a log warning whenever their count changes, no new endpoint (countFailedJobs can feed a Phase 4 view). |
owner (23/11, #78) |
| D101 | Job runner tunables MAILSINK_JOBS_* (batch size, lease, attempts, backoff, poll period) keep the former values as defaults, with bounds (D66). |
owner (23/11, #78) |
| D102 | newId monotonic within the millisecond as in D67 (RFC 9562 method 1, 42-bit counter), guaranteed per process, consistent with the single instance (D3). |
owner (23/11, #78) |
| D103 | Test fixtures grouped in @mailsink/db/testing as in D68; @mailsink/db re-exports its repositories by name. |
owner (23/11, #78) |
| D104 | Full text search indexed (GIN) on the first 100 000 characters of a message as in D69; beyond, text is not searched (unbounded, the index makes the insert of a very large message fail). | owner (23/11, #78) |
| D105 | Request body cap of 1 MiB by default for Admin and Capture routes; ingestion keeps MAILSINK_MAX_MESSAGE_BYTES (maxBodyBytes: 'message', doc 03 « Errors »). |
owner (23/11, #78) |
| D106 | The CI e2e job waits for check and reuses its build (artifact), at the cost of no longer running in parallel. |
owner (23/11, #78) |
| D107 | Statuses queued and sent use --ms-text-muted (the charter gives them no color). |
owner (23/11, #78) |
| D108 | Integration tokens for values hard-coded in the prototype: --ms-switch-thumb, --ms-shadow-thumb, --ms-overlay, --ms-shadow-sheet, --ms-shadow-popover. |
owner (23/11, #78) |
| D109 | One theme-color meta tag that follows the chosen theme, instead of two media tags (the system preference is not followed, B1-4). |
owner (23/11, #78) |
| D110 | Home page: title = the international baseline, its second sentence in --ms-accent-text; the hook becomes the subtitle. |
owner (23/11, #78) |
| D111 | Theme cookie mailsink_theme; Biome parses CSS with css.parser.tailwindDirectives. |
owner (23/11, #78) |
| D112 | Language selector as a restyled native <select> until the « Language and session » menu (#37). |
owner (23/11, #78) |
| D113 | Fonts (B1-5): only the Latin and Latin Extended subsets of Geist and JetBrains Mono, woff2 only, declared in apps/mailsink/src/styles/fonts.css with the @fontsource unicode ranges (the @fontsource latin-*.css files carry none, so both subsets would always download); other scripts fall back to system fonts. Build output: 10 font files, 121 kB (was 43 files, 413 kB). |
owner (23/11, #87) |
| D114 | og:url (path of the deepest route match) and og:image are absolute, built on MAILSINK_PUBLIC_URL by the root loader during SSR; og:image:width / og:image:height are declared. |
owner (23/11, #87) |
| D115 | docker-compose passes MAILSINK_SMTP_PUBLIC_PORT = MAILSINK_SMTP_HOST_PORT and MAILSINK_SMTP_PUBLIC_HOST (empty = unset) to the container, and MAILSINK_PUBLIC_URL defaults to http://localhost:${MAILSINK_HTTP_PORT}; the smoke test checks the port of SMTP credentials. |
owner (23/11, #87) |
| D120 | Resend ids: the Resend id of a message is the UUIDv7 of its msg_ id (also stored as provider_message_id), so GET /emails/:id reads by primary key with no lookup table; it answers any message of the workspace, whatever its source. |
owner (23/11, #95) |
| D121 | POST /emails/batch honours x-batch-validation as Resend: strict (SDK default) stores all or nothing and answers the first refused email (message prefixed emails[i]: ), permissive stores the valid ones and lists the others in errors; batch emails take no attachments. |
owner (23/11, #95) |
| D122 | Resend errors: { statusCode, name, message } from the stable codes (http/dialects/resend/errors.ts), the dialect’s own names passed in details.resend; validation as Resend (422 missing_required_field, 400 validation_error), a key of another connection kind 403 restricted_api_key, unknown key 401 validation_error; INGESTION_EXTENSIONS (rate limit and chaos) on the three routes, GET included, plus ratelimit-* copied from X-RateLimit-*. |
owner (23/11, #95) |
| D123 | Not emulated by the Resend dialect: hosted templates (template, refused), attachment path URLs (refused, Mailsink fetches nothing), the delay of scheduled_at (accepted, ignored), the plain text generated from html, topic_id. |
owner (23/11, #95) |
| D124 | Official SDK contract tests run the resend package (devDependency of @mailsink/app) against the Resend routes behind an in-process node:http listener on an ephemeral loopback port. |
owner (23/11, #95) |
| D125 | Brevo dialect (#29): POST /v3/smtp/email needs the msk_ key of a brevo connection (another kind, mskw_ or Admin key: 403); one message per message version in one transaction, messageId = the Message-ID header <msg_…@mailsink> (messageIds in version order); each tag string becomes { name: 'tag', value }; url attachments are never fetched (listed in metadata.brevo.attachmentUrls, with scheduledAt and batchId); scheduledAt does not delay the simulation; sender.id is not supported; idempotency from the Idempotency-Key header or an IdempotencyKey entry of the body headers. |
owner (23/11, #95) |
| D126 | Brevo placeholder renderer (core/templates/render.ts): only {{ params.path }} and {{ contact.X }} with the filters default, upper, lower, safe; own properties of plain objects and array indexes only; unknown variables render empty; values HTML-escaped in the html body unless safe; contact.EMAIL = first to address, other contact attributes empty; any other tag or block left verbatim. Applied to subject, html and text with or without a template. |
owner (23/11, #95) |
| D127 | Brevo error bodies { code, message } (no requestId in the body): every invalid body is a 400 (missing_parameter, out_of_range, else invalid_parameter), unknown templateId 400 invalid_parameter, forbidden -> permission_denied, not_found -> document_not_found, conflict / idempotency_mismatch -> duplicate_parameter / duplicate_request (400 duplicate_parameter since D279), payload_too_large -> 413 out_of_range, rate_limited -> 429 too_many_requests (code not documented by Brevo), chaos keeps chaos_injected (D93). Responses also carry x-sib-ratelimit-limit/remaining/reset, copies of X-RateLimit-*. |
owner (23/11, #95) |
| D128 | Templates Admin API (#30): /admin/workspaces/:id/templates[/:templateId], Admin key only, addressed by the numeric externalId; ascending externalId keyset; a missing externalId takes the highest of the workspace plus one; a taken one is 409; a patch may not leave a template without html nor text (422). |
owner (23/11, #95) |
| D129 | Template seed at provisioning (#30): CreateWorkspaceRequest.templates (at most 500, the content of a JSON file) inserted in the workspace transaction; explicit ids kept, the others numbered after the highest explicit one in order; a duplicate id is 409 and nothing is created. No server-side seed file (the Admin API caller reads its file). |
owner (23/11, #95) |
| D130 | SMTP DATA mapping (#31): recipients are the RCPT TO addresses, with the kind and display name of the To / Cc header that lists them, bcc otherwise; a header address never given in RCPT TO is not a recipient. Sender = From header, else MAIL FROM (none: 550 5.6.0). Bodies as sent (no html/text conversion, cid: links kept). headers keeps every header but the address, subject and MIME structure ones, names lower-cased, repeated ones joined with , . No tags nor metadata. |
owner (23/11, #95) |
| D131 | SMTP AUTH (#31): PLAIN and LOGIN, accepted without TLS (a test sink, clients often lack a trusted certificate). Unknown user, wrong password and disabled connection all answer 535 5.7.8 Authentication credentials invalid, and an unknown user still costs one scrypt. Verified-credential cache (D11): per connection, an HMAC of the password under a per-process random key bound to the stored hash (a rotation invalidates it), 10 000 entries, oldest dropped first; the connection row is still read at every AUTH. |
owner (23/11, #95) |
| D132 | SMTP guard (#31): settings, rate limit and chaos run on MAIL FROM, one token per transaction, before any byte of the message is read; activity is touched after AUTH and on every accepted MAIL FROM (throttled by D16). A connection deleted after AUTH answers 421 4.7.0 Connection no longer available. Unexpected failures answer 451 4.3.0 Local error in processing. |
owner (23/11, #95) |
| D133 | SMTP session record (#31, for #35): RecordSmtpSession(record) receives one SmtpSessionRecord shaped like the smtp_sessions row after the connection closed (no-op by default, errors logged). Transcript from the smtp-server protocol log, AUTH arguments and continuations /* secured */, at in epoch ms, at most 500 lines of 1 000 characters then one [mailsink] N more lines not recorded line. clientHostname is the EHLO name (reverse DNS disabled). Outcome: accepted (a message stored), else error, else auth_failed (AUTH failed, never succeeded), else rejected; error = last 4xx/5xx reply. |
owner (23/11, #95) |
| D134 | STARTTLS (#31): MAILSINK_SMTP_TLS_CERT and MAILSINK_SMTP_TLS_KEY are PEM file paths, both or neither (config error otherwise), read at boot (an unreadable file fails the boot, D28); STARTTLS is advertised only when they are set, never required. Size cap: smtp-server advertises SIZE and answers 552 with its own text (Error: message exceeds fixed maximum message size N). |
owner (23/11, #95) |
| D135 | Webhook event names are validated against the resolved format: dialect names, canonical names and, for Brevo, the aliases sent, soft_bounce, hard_bounce; an unknown name is a 422 unknown_webhook_event. The view events lists the subscription names (Brevo hardBounce, not hard_bounce). |
owner (23/11, #95) |
| D136 | Webhook secrets: the unified HMAC key is the whole whsec_… string; secretPreview = prefix + 4 characters; rotation is PATCH { rotateSecret: true }; leaving the brevo format issues a new secret, entering it drops it; creation and rotation answer the clear secret once. brevoAuth other than none on another format is a 422; the view returns the auth type and the basic username only. |
owner (23/11, #95) |
| D137 | Custom headers are sent on every format, under the format’s own headers; content-type, content-length, host, authorization, svix-* and x-mailsink-* are refused (422 reserved_webhook_header). |
owner (23/11, #95) |
| D138 | Webhook retries are the delivery’s own schedule: one deliver_webhook job per attempt, a failed attempt enqueues the next after min(2^(n-1) * 5 s, 1 h) ± 20 % (first retry 5 s), 8 attempts; the job queue backoff (D47) only covers database errors. Redirects are not followed (3xx fails); network errors and timeouts go to the attempt error. |
owner (23/11, #95) |
| D139 | Replay: replayOf points to the first delivery of the chain, whose id stays the signing id (svix-id, X-Mailsink-Delivery-Id); exact reuses the headers of the chosen attempt for every attempt of the replay, and is a 409 on a delivery without attempts; the API answers 202 with the pending delivery, the worker sends it. |
owner (23/11, #95) |
| D140 | Test send (B1-2): a sample message, a delivery with messageId / eventId null, one attempt sent at once and never retried, answer = WebhookDeliveryDetail; default event email.delivered. Preview: signed with a throwaway secret, signature and Authorization values masked. |
owner (23/11, #95) |
| D141 | Fan-out of a simulation run happens after its commit, in a separate transaction (a crash in between loses those deliveries, the run is not replayed); manual events fan out in their own transaction. Disabled endpoints get no new delivery; deliveries already created are still attempted. Ingestion suppressed events are not fanned out yet. Superseded for the simulation run by D152 and for ingestion by D153. |
owner (23/11, #95) |
| D142 | Manual events: an omitted recipient targets every recipient not suppressed; an unknown recipient is a 404, a suppressed one (or all suppressed) a 409; origin api. A forced status writes the recipient status and reason, the aggregate and the suppression list (hard_bounce, complained) like the simulation, but leaves the decision snapshot alone: a pending decision of a recipient forced to deferred may still apply later. |
owner (23/11, #95) |
| D143 | Automatic engagement: after each simulation run, each recipient it delivered opens when a draw < openRate and clicks when a draw < clickRate and the message has links (one picked at random; a click implies an open); events 1 ms and 2 ms after delivered, origin simulation, user agent Mozilla/5.0 (Mailsink simulation), draws seeded by FNV-1a(seed|email|engagement). |
owner (23/11, #95) |
| D144 | webhook.delivery frames (no SSE id) are published when a delivery is created and after each attempt, bound to the endpoint scope (a Workspace endpoint’s frames are dropped by a connectionId stream filter). MessageDetail.webhookDeliveries is newest first, at most 200. Resend email_id = provider id when it is a UUID, else the msg_ UUID body; Brevo message-id = provider id when <…@…>, else <uuid@smtp-relay.mailin.fr>; Brevo tags = tag values (name when empty). |
owner (23/11, #95) |
| D145 | Request log scope: every defineApi() call of /v1, /emails, /v3, /admin, /capture and /mcp writes one api_logs row (id = X-Request-Id), refused calls included with their error code (unauthorized, rate_limited, chaos_injected…, internal_error for an unexpected failure); GET /capture/logs/**, GET /capture/stream and /healthz are not logged (a logged log read would feed itself through log.api). Each stored row of a workspace publishes log.api, each SMTP session log.smtp (derived frames, no SSE id). Admin calls and failed authentications are kept without workspace, unreadable through Capture. |
owner (23/11, #95) |
| D146 | Request log mechanics: a request-log extension first in DEFAULT_EXTENSIONS; its afterAuth reads a clone of the JSON or text body in the background (authenticated callers only, bounded by MAILSINK_MAX_MESSAGE_BYTES; read once since D157), its onResponse clones a JSON or text response (up to 1 MiB) and queues the row on runtime.logs (createLogWriter), inserted after the response; a failed write is logged, never sent; the runtime stop flushes pending writes before closing the database. Stored: headers with credentials reduced to scheme and key prefix, cookies redacted; bodies with attachment contents replaced by their size, secret-looking keys and Mailsink keys in strings redacted, beyond 32 768 JSON characters a { truncated, size, preview }; message ids of ingestion responses. SMTP: recordSmtpSession(session) caps the transcript (1 000 lines, 1 000 characters per line) and redacts AUTH secrets and 334 answers. |
owner (23/11, #95) |
| D147 | Log read API: GET /capture/logs/api and /capture/logs/smtp (plus /:id for headers, bodies and transcript), workspace scope, filters (connection, dialect, status code or class, error code, method, path substring, message id, time range; SMTP: outcome, address/host/user substring), sort by time (API also by duration and status), page-number pagination with a count(*) total ({ data, total, page, pageSize }, pageSize up to 200) for the UI pager, unlike the keyset cursors of the other lists. |
owner (23/11, #95) |
| D148 | vite dev restart drain (#86): server.ts runs every request in withRuntime(), which counts it and pins its runtime with an AsyncLocalStorage lease (whenRuntimeReady() answers the leased runtime inside it). A request arriving while a restart is debounced or running waits for the new runtime; the restart waits up to 10 s for the requests in flight, warns when some still run, then stops the old runtime. A wait=true long poll longer than that is cut short. |
owner (23/11, #95) |
| D149 | The theme React context is created once per process (globalThis, Symbol.for('mailsink.theme-context')) instead of once per module evaluation, so an SSR render concurrent with a hot update never pairs a provider and a useTheme from two evaluations (#86). |
owner (23/11, #95) |
| D150 | MAILSINK_WEBHOOK_BLOCK_PRIVATE=true refuses webhook endpoint URLs whose host is, or resolves to, a private, loopback or link-local address, at creation and update (422 private_webhook_url on url) and before each attempt. Off by default: a test sink posts to local receivers. |
owner (23/11, #95) |
| D151 | GET /admin/logs/api (Admin key) reads the API log rows without workspace (failed authentication, Admin API calls), with the filters, sort and pagination of /capture/logs/api. |
owner (23/11, #95) |
| D152 | The engagement events and the webhook fan-out of a simulation run are written in the run’s own transaction (simulation/fan-out-run.ts, called by simulateDelivery): the run, its opened / clicked rows, its deliveries and their deliver_webhook jobs commit together, which closes the loss window of D141. The job handler only publishes them after the commit. |
owner (23/11, #100) |
| D153 | Ingestion fans out its suppressed events in the ingestion transaction (persistEmails): one email.suppressed delivery per suppressed recipient and subscribed endpoint (Brevo blocked; the Resend format has no such event); the webhook.delivery frames join the ingestion frames published after the commit. |
owner (23/11, #100) |
| D154 | Webhook delivery retention: a finished delivery (succeeded, failed) is purged with its attempts once older than the effective retention of its endpoint scope (the connection’s retention_seconds when the endpoint is scoped to a connection that sets one, else the workspace’s), by the retention pass; deliveries in flight (pending, retrying) wait for their outcome. A purged message leaves its deliveries until then (message_id set null). |
owner (23/11, #100) |
| D155 | D150 mechanics (webhooks/url-guard.ts, node:net BlockList): blocked ranges are 0.0.0.0/8, 10/8, 100.64/10 (carrier-grade NAT), 127/8, 169.254/16, 172.16/12, 192.168/16, ::, ::1, fc00::/7, fe80::/10 and IPv4-mapped forms; any blocked address among the resolved ones refuses the URL; a host that does not resolve is let through (the request fails on its own). At send time a refusal is a final failed attempt (error: blocked: …, no retry, nothing sent). The check resolves the host separately from the request, so DNS rebinding between the two is not covered. |
owner (23/11, #100) |
| D156 | D151 details: GET /admin/logs/api/:id reads one such row (a workspace’s row is a 404); reading /admin/logs is not logged, like /capture/logs (D145). SMTP sessions without workspace (failed AUTH) have no Admin read yet. |
owner (23/11, #100) |
| D157 | The request log reads a request body once: limitBody keeps the bytes it buffered for the handler (bufferedBodyOf), the log reuses them; a body nothing consumed (call refused by rate limit or chaos) is read at response time; a body cut by the 413 cap logs null. request.ip (srvx) reaches the handlers on the build: ip is the socket address (X-Forwarded-For is not read unless MAILSINK_TRUST_PROXY, D185). |
owner (23/11, #100) |
| D158 | Resend auth errors: a request without credential answers 401 missing_api_key “Missing API Key” (the shared auth sets details.credential: missing or invalid, also visible in native error bodies); an unknown key answers 400 validation_error on reads and keeps 401 on sending. GET /emails/:id answers the Message-ID an SMTP client wrote itself, else the composed one. |
owner (23/11, #100) |
| D159 | SMTP size refusals keep two texts: a SIZE declared at MAIL FROM above the cap is refused by smtp-server itself, before onMailFrom, with 552 Error: message exceeds fixed maximum message size N (no enhanced code: enabling them would double the codes Mailsink writes); an undeclared size crossing the cap during DATA answers 552 5.3.4 Message exceeds the N bytes limit. docker-compose mounts MAILSINK_SMTP_TLS_DIR read-only on /app/tls (an empty volume when unset) and passes MAILSINK_SMTP_TLS_CERT / _KEY. |
owner (23/11, #100) |
| D160 | Web UI session (#37): stateless signed cookie mailsink_session = v1.<expires>.<nonce>.<HMAC-SHA256>, nothing stored server side. Secret MAILSINK_SESSION_SECRET (32 characters at least), else derived from the admin key (HMAC(adminKey, 'mailsink-ui-session-v1'), never the key itself), so rotating either ends every session. Lifetime MAILSINK_SESSION_TTL (7 days by default, absolute, not sliding). Cookie HttpOnly, SameSite=Lax, Secure when MAILSINK_PUBLIC_URL is https, Max-Age = lifetime + 30 days so an expired session is recognised and the sign-in page shows L1d. Signing out drops this browser’s cookie only. MAILSINK_UI_AUTH=none: every visitor is signed in, POST /login answers 404. |
owner (23/11, #100) |
| D161 | Sign-in limiter (B2-2, B2-3): per socket address, MAILSINK_UI_LOGIN_MAX_ATTEMPTS (5) refused keys within MAILSINK_UI_LOGIN_LOCK_SECONDS (60) pause that address for the same duration; the failure that reaches the threshold already answers 429 with Retry-After; during the pause the key is not even checked and the pause is not extended (the L1e countdown stays true); a success clears the count. In memory (single process, D3). X-Forwarded-For is not trusted unless MAILSINK_TRUST_PROXY (D185): without it, behind a reverse proxy every visitor shares one budget. |
owner (23/11, #100) |
| D162 | POST /login is a server handler of the /login route, not a defineApi() route: no Bearer authentication, not written to api_logs, no X-Request-Id; JSON body { key } (4 KiB at most), errors { error: { code, message } } (unauthorized, rate_limited, validation_error, not_found), never the remaining attempts. |
owner (23/11, #100) |
| D163 | UI server functions check the session themselves (function middleware signedIn, route guards redirect to /login?redirect= first). Opening a workspace (/w/$workspaceSlug, server function openWorkspaceFn) touches its activity like an authenticated API call (D86) and stores its slug in mailsink_last_workspace (httpOnly, 1 year), the page signing in leads to when there is no page to return to; listing workspaces touches nothing. |
owner (23/11, #100) |
| D164 | Workspace picker: the / page (search params PickerSearch, ?ephemeral=true reveals ephemeral workspaces, Base UI Switch) and the header popover of the prototype (switch in local state, on when the open workspace is ephemeral); at most 500 workspaces listed, newest first. Header tabs Logs and Settings link to their routes since #102 (screens with #41 and #43). The 500 limit hiding persistent workspaces (bug #104) is replaced by D206: sections read apart, searched and paged. The instance block shows MAILSINK_PUBLIC_URL and the app package version. Workspace data goes through TanStack Query, prefetched by route loaders during SSR (@tanstack/react-router-ssr-query). |
owner (23/11, #100) |
| D165 | MCP over HTTP (#44): POST /mcp builds a fresh McpServer and a WebStandardStreamableHTTPServerTransport with sessionIdGenerator: undefined per request (stateless, no Mcp-Session-Id, any instance can answer), MCP TypeScript SDK v2 (@modelcontextprotocol/server and /client). GET and DELETE /mcp answer 405 with Allow: POST (no standalone stream, no session). The route goes through defineApi() with auth: 'workspace', so auth (D12, D41), activity touch and the request log (dialect mcp) are those of Capture; JSON-RPC bodies are capped at 1 MiB. |
owner (23/11, #100) |
| D166 | MCP tool answers: the HTTP JSON as text plus structuredContent; a failure is an isError result whose text is the HTTP error body { error: { code, message, details? } } (non-domain errors logged and answered internal_error). Arguments are parsed again with the full contract schema (refinements such as since_after_until, details.in = 'arguments'); plain schema mismatches are answered by the SDK before the tool runs. Events and overrides created through MCP have origin mcp; state-changing tools publish on the bus exactly like their HTTP twins. |
owner (23/11, #100) |
| D167 | MCP tool shapes: root input schemas are plain objects (some clients refuse a root oneOf), so trigger_email_event takes { id, event } and get_delivery_logs takes { source: 'api' | 'smtp', id?, apiFilters?, smtpFilters? } (API request log and SMTP sessions of #35). wait_for_email waits 30 s by default (the API maximum) instead of the 5 s of wait=true, agents usually trigger the email right before. |
owner (23/11, #100) |
| D168 | Read-only MCP tools beyond the roadmap list: get_override_config, get_webhook_deliveries (list, or one delivery with its attempts) and list_suppressions, on the same services as GET /capture/override, /capture/webhooks/deliveries and /capture/suppressions. |
owner (23/11, #100) |
| D169 | MCP lifecycle and stdio: each HTTP exchange subscribes to its workspace channel; on workspace.deleted the calls in flight get 1 s to answer (a pending wait_for_email fails with not_found), then the server is closed; it is also closed when the response ends or the client aborts. mailsink mcp reads JSON-RPC lines on stdin and forwards each message with the SDK StreamableHTTPClientTransport (Authorization: Bearer, optional X-Mailsink-Workspace, negotiated MCP-Protocol-Version), writes answers on stdout, answers a refused or unreachable request with JSON-RPC error -32000 quoting the Mailsink error body, and exits once stdin ended and every request was answered. Options --url/MAILSINK_URL (base URL or /mcp, default http://localhost:3000), --key/MAILSINK_KEY, --workspace/MAILSINK_WORKSPACE (Admin key only). |
owner (23/11, #100) |
| D170 | Workspace creation from the UI (#38): « + New workspace » of the picker (header popover and /) opens the prototype dialog « New persistent workspace »; the UI creates persistent workspaces only (created_via = 'ui', ephemeral ones stay on the Admin API, whose curl is shown in the dialog). The slug follows slugify(name) (no random suffix) until edited; a taken one is reported on its field. Retention presets 1h / 24h / 7d / 30d, rate limit typed in requests per second (window 1 s, empty = unlimited). The optional first connection is created in the same transaction, named after its kind; a second step shows the mskw_ workspace key and the connection credentials once, then opens the connections page (or the workspace without connection). |
owner (23/11, #105) |
| D171 | Connection management UI (#38): page /w/$workspaceSlug/connections (?connection=<id> or new, ConnectionsSearch), list on the left, panel on the right; every change goes through session-checked server functions on the core services (never the HTTP API with the admin key), names the workspace by slug and touches its activity. Secrets of a creation or rotation stay in the page memory only (shown until the page is left or reloaded); otherwise the panel shows the key preview, the SMTP username, host and port, and a .env snippet with the secret masked. The rate limit override is offered for every kind, the SMTP username (optional, generated) for smtp only. Deletion and rotation ask for a confirmation. |
owner (23/11, #105) |
| D172 | Rotation (#38): resend / brevo get a new msk_ key and every previous key of the connection is revoked in the same transaction, without grace period; smtp gets a new password with the same username (the verified-credential cache is keyed by the stored hash, so the old password is refused at once). Admin twin: POST /admin/workspaces/:id/connections/:connectionId/rotate, 200 CreatedConnection. The other connection operations have no Admin route yet. |
owner (23/11, #105) |
| D173 | Disable / enable sets or clears connections.disabled_at (HTTP 403, SMTP 535 while disabled); deleting a connection is a hard delete (keys, webhook endpoints and overrides cascade, messages and logs keep a null connection). |
owner (23/11, #105) |
| D174 | Workspace edit and delete from the UI (#38), ephemeral ones included: name, description, default retention (a non-preset value shows as an extra segment) and rate limit; the slug is immutable (it is in URLs, snippets and CI configuration). Deleting asks to type the slug and publishes workspace.deleted like DELETE /admin/workspaces/:id. The connections route is declared non-nested (w.$workspaceSlug_.connections.tsx, own header) while the workspace layout renders no <Outlet />. New generic @mailsink/ui components: Dialog, SegmentedControl. |
owner (23/11, #105) |
| D175 | Web UI inbox data paths (#39, #40): server functions call the core capture services (session checked, workspace by slug, activity touched); what a browser cannot fetch with a Bearer key goes through same-origin routes authenticated by the UI session cookie: /w/$workspaceSlug/m/stream (the /capture/stream events, Last-Event-ID header or ?lastEventId=), /w/$workspaceSlug/m/$messageId/raw, /attachments/$attachmentId (always as attachment) and /html?scheme=. 401 without session, 404 for an unknown slug or another workspace’s message. The cookie never authenticates /capture/**. |
owner (23/11, #105) |
| D176 | HTML preview (#40): <iframe sandbox=""> without any allowance, document served with the download CSP extended to what an email needs (style-src 'unsafe-inline' https: http:, img-src data: https: http:, font-src data: https: http:; scripts, frames, forms and connections stay forbidden), nosniff, no-store, no-referrer. Inline cid: images are embedded as data: URLs (5 MB per message) because the opaque-origin frame does not send the SameSite=Lax session cookie; <base target="_blank"> makes links inert inside the frame (no allow-popups); the light / dark background sets <meta name="color-scheme"> like a mail client. Remote images do load: a tracking pixel reaches its host. |
owner (23/11, #105) |
| D177 | Inbox filters (#39): InboxSearch (q, status, connectionId, tag, m, tab), invalid values dropped. Search box: to: / from: operators, a lone word containing @ searches recipients, the rest is the Capture full text q (whole words). Connection segments: one per connection of the workspace, labelled by kind (plus the name when two share a kind), filtering on connectionId; status chips: delivered, hard_bounce, soft_bounce, complained, suppressed, failed always, the other statuses once present. Counts cover the whole inbox (new reads countMessageFacets, countWorkspaceLogs, listMessageExcerpts); the Logs tab counts API calls, SMTP sessions and webhook deliveries. List rows add a 160-character plain text preview (text body, else the HTML stripped). |
owner (23/11, #105) |
| D178 | Real-time cache (#39): the workspace layout opens one stream; message.created is prepended to every cached list whose filters the browser can check (status, connection, tag) and the lists with a search refetch; previews of new rows are fetched in one batch; message.status is written in place; other frames invalidate their queries, coalesced over 250 ms. When EventSource gives up, the stream is reopened from the last event id after 1, 2, 5, 10 then 30 s; after any interruption every inbox query is invalidated (derived frames are never replayed). workspace.deleted shows a banner and stops the stream. |
owner (23/11, #105) |
| D179 | Message viewer (#40): on ?m= (plus ?tab=) next to the list rather than a child route; without ?m= the newest message of the list shows. The viewer leaves out metadata and the simulation snapshot; the MIME source is shown up to 512 KB (download complete). « Simulate » Opened / Clicked (a link of the message or a custom http(s) URL) / Hard Bounce use the manual events service with origin ui and publish like the Capture route. « Purge the inbox » (two clicks, the confirmation lapses after 6 s) deletes every message of the workspace and keeps the logs (includeLogs: false, unlike the Capture default). |
owner (23/11, #105) |
| D180 | State-changing actions shared by the Capture API and MCP publish from core: triggerAndPublishEvent (events, aggregate status, webhook deliveries), purgeAndPublish (messages.purged), activateAndPublishOverride / resetAndPublishOverride (override.changed) take { db, bus } (LiveDeps) and publish after commit; routes and tools only adapt input and output. MCP content: get_email answers absolute rawUrl and downloadUrl (on MAILSINK_PUBLIC_URL, given to the MCP context); get_email_source answers the raw EML as an embedded message/rfc822 resource and get_email_attachment one attachment (text types as text, others base64), each with a JSON summary first and the absolute download URL as resource URI; both are capped only by the ingestion cap. |
owner (23/11, #105) |
| D181 | Release version read from one place: the version of the root package.json, exported as MAILSINK_VERSION by @mailsink/contracts (version.ts); the MCP serverInfo.version and the instance block of the UI read it (instead of 0.0.0 and the app package version of D164). Workspace packages stay private at 0.0.0. A release bumps the root version only. |
owner (23/11, #105) |
| D182 | D185 mechanics (http/client-ip.ts): with MAILSINK_TRUST_PROXY=true the client address is the last X-Forwarded-For entry, the one appended by the proxy in front of Mailsink (earlier entries come from the client and can be forged); without a usable header, the socket address. One trusted hop: a chain of proxies needs the closest one to overwrite the header. |
owner (23/11, #105) |
| D183 | UI head and SSR: each page sets a localized <title> (Page · Mailsink, seo/page-title.ts: pageTitle(matches, msg\…`)translates with the catalog of the root loader, the deepest title wins; the root keepsMailsink); og:imageandog:localefollow the page locale (fr: FR image, any other: EN). Undervite devthe theme and locale server helpers readgetCookie/setCookie/getRequestHeaderfrom a complete@tanstack/react-start/server namespace (http/start-server.ts: import, then wait up to 5 s for the namespace a route tree edit leaves partial), which removed the getCookie is not a function500s (0 out of 300 requests while editing__root.tsx`, 3 to 8 out of 60 before). |
owner (23/11, #105) |
| D184 | Faint text contrast: --ms-text-faint is overridden in tokens-ext.css (delivery untouched) with the same hue at the lowest value reading 4.5:1 on --ms-bg, --ms-panel and --ms-raised (the criterion of the charter for accent text): #6e7075 in light (was #989ba1, 2.5:1), #7b808a in dark (was #5f636b, 3.2:1); hover rows stay above 4.1:1. It remains a step below --ms-text-muted. Checked by tokens.test.ts and in the browser (smoke-theme.spec.ts). |
owner (23/11, #105) |
| D185 | MAILSINK_TRUST_PROXY (off by default): when set, the sign-in limiter and the ip of the request log read the client address from X-Forwarded-For (D182) instead of the socket address (D157, D161). |
owner (23/11, #100) |
| D186 | Admin API parity with the web UI (#105, #106): PATCH /admin/workspaces/:id (name, description, retention, rate limit), POST /admin/workspaces/:id/connections, PATCH (rename, disable / enable) and DELETE /admin/workspaces/:id/connections/:connectionId, on the core services the UI server functions call (core/connections/manage.ts, core/workspaces/update.ts). |
owner (23/11, #105) |
| D187 | « Block remote images » in the HTML preview (#105, #106): a switch of the preview toolbar, off by default, remembered per browser (localStorage); on, the preview document is served with ?remote=blocked and a CSP of style-src 'unsafe-inline'; img-src data:; font-src data:, so no remote image, stylesheet or font (tracking pixel) loads while inline cid: images still show. The iframe waits for the stored choice before loading. |
owner (23/11, #105) |
| D190 | Logs explorer URL (#41): LogsSearch keys are all optional (defaults resolved by features/logs/search-query.ts: tab api, sort -createdAt, page 1, 50 rows) and an invalid value is dropped. The HTTP status facet is code, not status: TanStack Router types an untargeted search={(prev) => …} with the union of every route’s search, and an array status would break the inbox links typed on InboxSearch.status. Multi-value facets (dialect, code, outcome) accept an array or comma-separated text; the webhook facets (delivery, format, endpointId) take one value, as the delivery log does. A filter change goes back to the first page and closes the sheet; a tab change drops the other tab’s facets. |
owner (23/11, #113) |
| D191 | Logs explorer data (#41): session-checked server functions (server-fns/logs-fns.ts) on the core services of /capture/logs/** and the delivery log, workspace by slug, activity touched (D163). API and SMTP tables use page numbers with the total (D147); the webhook table keeps the keyset cursor of the delivery log (cursor, « Newest » / « Older », no total). Tab counts: API and SMTP totals, webhooks = countWorkspaceLogs minus both. Navigations within the page do not wait for the loader (cause: 'stay'): rows stay dimmed, the sheet says « Loading… ». The SMTP sort is time only; the webhook table has no sort. |
owner (23/11, #113) |
| D192 | Webhook inspector (#41, #47): payloadFormat, canonical and dialect events, every attempt with its exact headers (Authorization masked as <scheme> •••••••• behind « Show », also in API log headers), the target response and the exact body. Signature validity is computed by the server function: the exact body signed again with the endpoint’s current secret and the id and timestamp the attempt sent, compared with the header it sent (valid, invalid after a rotation, unsigned for a Brevo endpoint without auth, missing); the secret shows as its preview (prefix + 4). API log response headers are not stored, so the API inspector shows status, error code and body only. |
owner (23/11, #113) |
| D193 | Replay from the UI (#41, D139): mode exact by default when the delivery has an attempt (its last one is copied), resign otherwise; with exact, a copied timestamp older than 5 minutes shows the Svix tolerance warning (Resend and unified formats). Optimistic: a pending placeholder row is prepended to the cached first pages whose filters it matches, swapped for the server row on success, removed on refusal; the replay is published on the bus like the Capture route. |
owner (23/11, #113) |
| D194 | Logs live updates and table components (#41): features/logs/apply-log-event.ts, called by the stream cache helper of the workspace layout, refetches the API or SMTP list and the counts on log.api / log.smtp, writes a webhook.delivery frame in place then refetches the webhook views, and refetches every logs query on messages.purged and after a stream gap. Generic @mailsink/ui components on TanStack Table v9 (@tanstack/react-table): DataTable (server-side sort, row selection by click or Enter), DataTableFacet (checkbox popover, shows the choice before the URL catches up), DataTablePagination (page numbers or keyset). |
owner (23/11, #113) |
| D195 | Override UI (#42): the header shows « Override… » (outline) when nothing is overridden, else an --ms-override pill naming the scope (workspace, the connection name, or « N scopes ») that opens the panel, and a × that resets every active scope at once, without confirmation (prototype). The panel is the right sheet « Override settings ». Data goes through session-checked server functions (readOverrideFn, applyOverrideFn, resetOverrideFn) calling activateAndPublishOverride / resetAndPublishOverride with origin ui, so the UI publishes override.changed like the Capture API. One query ['override', slug] (state, connections, workspace settings) is updated optimistically (rolled back on failure) and written whole from every override.changed frame of the workspace stream. It is not prefetched by the layout loader: the pill appears after hydration. |
owner (23/11, #113) |
| D196 | Override panel content (#42): every section (status rates, latency, chaos, rate limit, recipient rules) has a switch and only the sections turned on are sent in OverrideConfig, the others keep inheriting; at least one is required. Starting values: the active override of the target (its sections on), else the settings in force there (workspace settings for the whole workspace, resolved effective settings for a connection); changing target reloads them. Expiry presets 15 min, 1 h (default) and « Until reset » (no ttl). « Reset to defaults » resets the selected target only, after an inline confirmation (prototype); the pill × resets them all. |
owner (23/11, #113) |
| D197 | Override fields (#42): delivered is not typed, the remainder (100 minus the other rates) is shown and sent as delivered, a total above 100 blocks « Apply ». A rule’s effect is one simulated status or a delay in ms; smtpCode and status plus delay rules are not editable from the UI (the API keeps them). Rate limit per second or per minute, no burst field. Chaos codes among the contract’s (HTTP 429, 500, 502, 503; SMTP 421, 451, 452, 550), 500 and 451 by default. |
owner (23/11, #113) |
| D198 | Suppression list UI (#42): page /w/$workspaceSlug/suppressions (SuppressionsSearch, ?email= case-insensitive substring), newest first by server pages of 50 (keyset cursor of the core service) with « Load more »; columns address, reason (badge in the colour of hard_bounce, complained, or suppressed for manual), message (link to the inbox ?m=), since. Removing one address is optimistic; « Reset the list » asks for a confirmation and empties the whole list whatever the filter. Plain table, not the generic DataTable built in parallel. No stream frame exists for suppressions: the page refetches on mount and focus. Until a tab or settings link exists, the override panel links to it. |
owner (23/11, #113) |
| D199 | Override form mechanics (#42, TanStack Form 1.33): the Zod schema runs at form level on change only. Errors written by a form-level onSubmit validator, or on a path that is not a field, outlive their fix and block submission, so the « rates above 100 » issue is set on each non-zero rate field and an empty override is stopped in onSubmit with a footer message. |
owner (23/11, #113) |
| D200 | Settings page (#43): /w/$workspaceSlug/settings?section= (SettingsSearch: connections by default, webhooks, retention, simulation, templates, mcp), the section list of the prototype on the left, nested in the workspace layout. The connections section lists them and links to /w/$workspaceSlug/connections (#38), which stays their management page. Every read and change goes through session-checked server functions (server-fns/{settings,webhooks,templates}-fns.ts) on the core services, workspace by slug, activity touched (D163, D175); the open section’s data is prefetched during SSR. New generic @mailsink/ui components: Select (Base UI), Textarea. |
owner (23/11, #113) |
| D201 | Workspace defaults from the UI (#43): UpdateWorkspaceRequest gains maxMessages (positive, null = unbounded) and simulation (complete SimulationSettings, replaced whole), written by updateWorkspaceSettings. The simulation form edits the drawn rates (deferred, soft_bounce, hard_bounce, complained, failed; delivered shown as the remainder and not stored, D71), latency and open / click rates, and keeps the stored recipient rules unchanged (no rule editor for the defaults yet); the default rate limit is typed as requests per window, window in seconds and optional burst. |
owner (23/11, #113) |
| D202 | Webhook endpoint form (#43): events are held canonical and shown as the subscription names of the chosen format (eventCatalog, built server side from the core mapping); a chip toggles every canonical event its name stands for (Resend email.delivery_delayed = deferred + soft bounced) and the canonical names are sent (always accepted, D135). The three formats are always offered; changing the scope prefills defaultPayloadFormat (D20) until a format is picked by hand (an existing endpoint counts as picked). Events the format cannot emit stay selected with a warning (D22). Brevo credentials are write-only: blank fields on edit keep them. The card’s « Reveal » reads the stored whsec_ secret through a session-checked server function (the web UI session has the admin key’s powers); the Capture API still never returns it. « Test send » is offered on enabled endpoints only, as in the prototype. Core validation refusals (reserved header, private URL…) come back as field issues instead of failures. |
owner (23/11, #113) |
| D203 | Brevo template screen (#43): list (up to 1 000, pages of 200), editor dialog (numeric id at creation only, blank = next free one; name, subject, sender Name <email>, html, text), a taken id shown on its field. The preview renders the unsaved fields on the server with renderTemplate (D126), sample params typed as JSON and contact.EMAIL, debounced 300 ms; the html shows in an <iframe sandbox=""> through srcdoc (remote images do load, like D176). |
owner (23/11, #113) |
| D204 | MCP section (#43): the workspace’s Streamable HTTP endpoint (urls.mcp on MAILSINK_PUBLIC_URL) and the client snippets of docs/guides/mcp.md (Claude Code HTTP, stdio and .mcp.json; Claude Desktop with node or Docker; Cursor HTTP and stdio) with copy buttons. The workspace key is never stored in clear, so snippets carry the mskw_... placeholder and the page says where the key comes from. |
owner (23/11, #113) |
| D205 | Stream and delivery views (#106): message.event frames carry the messageId of their event, so the browser refetches only the viewer of that message; WebhookDeliveryView gains endpointUrl (the endpoint’s current URL, read by a second query, null in frames of producers that do not know it) and durationMs (last attempt, null before the first one), additive for the HTTP API, MCP and the stream. |
owner (23/11, #113) |
| D206 | Workspace picker (#104): persistent and ephemeral workspaces are read apart, 50 per page with a keyset cursor and « Show more », filtered by a case-insensitive substring of slug or name (search box of the popover and of /, local state, not in the URL); every page carries ephemeralCount, one aggregate count. |
owner (23/11, #113) |
| D207 | Workspace key rotation (#106): rotateWorkspaceKey revokes every active mskw_ key of the workspace and inserts a new one in one transaction, no grace period (as D172); POST /admin/workspaces/:id/key/rotate answers RotatedWorkspaceKey { workspaceKey, keyPreview }; the connections page shows the active key preview (MAILSINK_KEY, the name of the MCP guide) and rotates it behind a confirmation, the new key shown once. |
owner (23/11, #113) |
| D208 | Design system (#106): a Toast on Base UI (ToastProvider at the root, useToast()), one toast at a time, bottom center, 2.6 s, ink on the page background in mono (prototype); copy buttons confirm through it (useCopy) instead of « Copied » in place. SegmentedControl (Base UI radio group) is the only segmented control: it gains rich labels, title and fill, and the inbox Segmented becomes a thin adapter (filters and preview toggles are now radios). No duplicate Dialog exists (Sheet is the side panel). |
owner (23/11, #113) |
| D209 | Workspace UI (#106): below 768 px the tabs get their own scrolling row under the header (same NavTabs, bar variant); a « Connections » tab joins Messages, Logs and Settings until Settings hosts it; ephemeral workspaces show the prototype TTL banner (live countdown, idle TTL left, openWorkspace answers the expiry restarted by its own touch); titles Inbox · <slug>, Connections · <slug>, <slug> for other children; the Headers & MIME tab opens on « Payload |
owner (23/11, #113) |
| D210 | Demo messages (#62): POST /capture/demo (SeedDemoRequest { locale }, 201 SeedDemoResponse { count, messageIds }) and the server function behind « Load demo messages » of the empty inbox call seedDemoMessages (core/demo): eight transactional messages of a fictional product (« Fieldnote ») through persistEmails (raw EML, blobs, links, suppression check, simulation jobs, webhook fan-out, stream frames), created 52 to 3 minutes ago, spread over the enabled connections in turn (source = connection kind; none: native without connection), with HTML, links, a PDF and a CSV attachment, an inline cid: image, several recipients, tags category and demo, metadata.demo. Data set in English and French; the UI sends its locale, a community locale gets English. Seeding again adds the set again. |
owner (23/11, #119) |
| D211 | Temporary rule set of a message (#62): messages.simulation may start as { rules: RecipientRule[] }; the settings planner applies those rules ahead of every stored layer, for that message only (messageRules). The demo uses it for its planned outcomes (hard_bounce 550, complained, soft_bounce 452, failed, then * delivered), so its statuses never depend on the workspace settings and no override or setting is touched. |
owner (23/11, #119) |
| D212 | Live UI follow-ups (#112): the workspace layout loader also loads the override query (the pill renders with the page); onResync refetches the override and the suppression list besides the inbox and logs; a message.status frame of hard_bounce or complained refetches the suppression list (no new frame type); message.created and log.api frames restart, in the cache, the idle TTL of an ephemeral workspace shown by its banner (max(expiresAt, now + idleTtlSeconds), at most 15 s ahead of the stored value because of the activity throttle D16). |
owner (23/11, #119) |
| D213 | Logs explorer follow-ups (#112): the delivery log answers total and pages by number with page (the cursor is ignored then, still accepted for older links), so every tab has the same pager; LogsSearch gains messageId (every tab), since and until (API, SMTP), method and errorCode (API), set in a « More filters » popover (TanStack Form, Zod). Every link to the logs is a typed Link: the viewer’s « See in the logs » opens the API log or SMTP session (inspect), a delivery of the History tab opens its webhook inspector, « See in the logs explorer » lists the webhook deliveries of the message. |
owner (23/11, #119) |
| D214 | Suppression list follow-ups (#112): ListSuppressionsResponse carries total (addresses matching the filter) and each SuppressionView the connectionId of the message that listed it (left join, null without message or connection). The page uses the generic DataTable (rows rendered only in view beyond 200), shows the total, and is reached from the « Retention & suppression » settings section (count and link, prototype) and from the override panel. |
owner (23/11, #119) |
| D215 | Request log response headers (#112): migration 0003 adds api_logs.response_headers (jsonb, nullable, no backfill), written by the request log extension with the redaction rules of the request headers; ApiLogDetail.responseHeaders ({} for older rows) is shown by the API inspector. |
owner (23/11, #119) |
| D216 | DataTable additions (#112): hiddenColumns (ids left out), rowLabel (explicit accessible name of a row, which Chromium otherwise cuts from the cell texts) and virtual (spacer rows, fixed 38 px rows, beyond a threshold of 200). Below 768 px (useMediaQuery) the log tables drop the type, connection and duration columns and their 860 px minimum width. Superseded by D229: hiddenColumns and useMediaQuery gave way to the CSS narrow prop. |
owner (23/11, #119) |
| D217 | Workspace defaults in one place (#112): retention, quota, rate limit and simulation are edited on the settings page only; the « Edit » dialog of the connections page keeps name and description and links to the « Retention & suppression » section. PATCH /admin/workspaces/:id already accepts maxMessages and simulation (same UpdateWorkspaceRequest): now tested and documented. |
owner (23/11, #119) |
| D218 | Creator of a workspace (#112): metadata.createdBy, free text given to POST /admin/workspaces (« github-actions · run #8841 »), is answered by openWorkspace as createdBy and shown by the ephemeral banner (« created by … through POST /admin/workspaces »); without it the banner keeps its generic text. |
owner (23/11, #119) |
| D219 | Component dedupe (#112): the inbox Segmented adapter is gone (callers use SegmentedControl); CopyButton and Count live in features/shell (the source panel copies through CopyButton); one useNow(tickMs) serves relative times and the TTL countdown; the rule effect of the override panel is the design system Select. Brevo templates are read by pages of 200 with « Load more » (no 1 000 cap); the connection panel lists the endpoints scoped to it with « Manage / Add a webhook → » (prototype). |
owner (23/11, #119) |
| D220 | Releases (#45): release-please in manifest mode (release-please-config.json, .release-please-manifest.json), one package at the root, release type node, so a release bumps the root package.json only (D181); tags vX.Y.Z without component. The manifest starts at 0.0.0 with initial-version 0.1.0: the first release is 0.1.0 (owner, 23/11) and its changelog covers the whole history. Below 1.0.0, feat bumps the minor, fix the patch, a breaking change the minor. |
owner (23/11, #119) |
| D221 | CHANGELOG.md (#45): generated by release-please only, from the French commit descriptions as written; sections Features (feat), Bug Fixes (fix), Performance (perf), Reverts (revert); docs, chore, refactor, test, build, ci and style are hidden (internal architecture notes, tooling). |
owner (23/11, #119) |
| D222 | Image publication (#45): ghcr.io/devitek/mailsink, published only when a release is created, by the release-image workflow called from release-please (tags and releases made with GITHUB_TOKEN start no workflow; it also runs by hand for an existing tag). linux/amd64 and linux/arm64 (Buildx with QEMU), tags X.Y.Z, X.Y and latest (no major tag below 1.0.0, no image per commit), OCI labels and index annotations from docker/metadata-action (source, revision, version, license), provenance (mode=max) and SBOM attestations, GitHub Actions cache. The job checks that the tag matches the root package.json version and is the only one with packages: write. The docker workflow keeps building and smoke-testing without pushing. |
owner (23/11, #119) |
| D223 | docker/docker-compose.yml defaults to ghcr.io/devitek/mailsink:latest (#45), MAILSINK_IMAGE picks another tag. The build section stays: Compose pulls first and builds the checkout only when the pull fails; MAILSINK_IMAGE=mailsink:local … up --build runs a local build. docker/smoke-test.sh and the docker workflow keep their local tags. |
owner (23/11, #119) |
| D224 | README installation (#45): no clone, the Compose file is downloaded from main and runs the GHCR image (PGlite profile first, Postgres second); docker run of the image as the alternative, building from a clone last. |
owner (23/11, #119) |
| D225 | Pull requests are squash merged (merge commits and rebase disabled, branches deleted after merge): the squash commit is the PR title alone (PR_TITLE, empty body), so the PR title must be a valid Conventional Commit (type(scope): description (#N), no space before the colon) for release-please to list it once in CHANGELOG.md. The 0.1.0 changelog, built from earlier merge commits, is cleaned by hand in its release PR. The release PR opened with GITHUB_TOKEN runs no checks, accepted. |
owner (23/11, #119) |
| D226 | npm packages of Mailsink are published under the @devitek scope (@mailsink is taken on npm), live in this monorepo and are versioned with the server (one version, D181, D220). v0.2 scope: TypeScript SDK, Playwright helpers, Vitest/Jest helpers, CLI commands for CI, OpenAPI specification (Phase 5, 05-roadmap.md). |
owner (23/11, #122) |
| D227 | Multi-platform image (#118): every Dockerfile stage but the runtime runs on $BUILDPLATFORM, so pnpm install and the build never run under QEMU; only the runtime stage file operations (user, symlink) run on the target platform, under QEMU for arm64. Valid because the Nitro output (JavaScript and PGlite WASM) and the CLI deploy carry no native binary; the build stage fails if a .node addon reaches its output. Native ubuntu-24.04-arm runners are not needed. |
owner (23/11, #133) |
| D228 | Demo messages come with their log line (#118): the seeder writes, in its transaction and at the time of each message, one api_logs row in the dialect of the connection it goes through (POST /v1/emails, /emails or /v3/smtp/email, the dialect payload with attachment contents stripped, the dialect response, user-agent: mailsink-demo), or one accepted smtp_sessions row with a short transcript for an SMTP connection, and publishes their log.* frames. « See in the logs » and the logs explorer then work on the demo. |
owner (23/11, #133) |
| D229 | Server-rendered layouts follow CSS breakpoints, not JavaScript media queries (#118): the DataTable narrow prop (columns hidden and widths below 768 px, through classes and CSS variables) replaces hiddenColumns and useMediaQuery (D216), so a phone gets its layout from the first paint. The ephemeral banner restarts the idle TTL from the server time carried by the frame (log.api and message.created createdAt), not the browser clock: it shows the purge time, which the stored expires_at reaches when the activity throttle window closes (D85). |
owner (23/11, #133) |
| D230 | OpenAPI generation (#124): a package @mailsink/openapi (zod-openapi on Zod 4 JSON Schema) keeps @mailsink/contracts free of generator dependencies. One registry (registry.ts, a RouteSpec per route and method) is the only place a route is described; components keep the contract export names, request schemas with transforms stay inline. |
owner (23/11, #133) |
| D231 | GET /openapi.json is public (no credential): it describes routes and holds no data. servers[0] is MAILSINK_PUBLIC_URL, the document is built once, answered with Access-Control-Allow-Origin: * (Swagger UI or an editor on another origin) and Cache-Control: public, max-age=300; it is not written to the request log. |
owner (23/11, #133) |
| D232 | Routes left out of the document: /mcp (MCP Streamable HTTP, described by MCP), POST /login and the /w/$workspaceSlug/… routes (web UI session cookie). A test scans apps/mailsink/src/routes and fails on a server route neither documented nor excluded, and on a documented or excluded route no file serves. |
owner (23/11, #133) |
| D233 | Error responses are derived per route from D40: auth (401, 403), inputs (404, 422, 400 unreadable body or missing X-Mailsink-Workspace, 413), ingestion (409, 429, chaos 500/502/503), listed codes, 500; dialect bodies and statuses (Resend 400 for an unknown key on a read, Brevo 400 for validation). X-Request-Id, WWW-Authenticate, Retry-After, X-RateLimit-* and the provider copies are components.headers. Outgoing webhook payloads are the document’s webhooks. |
owner (23/11, #133) |
| D234 | pnpm openapi [file] writes the document (default openapi.json where pnpm runs, git ignored, servers from MAILSINK_PUBLIC_URL else http://localhost:3000); the release workflow attaches it to each GitHub release. |
owner (23/11, #133) |
| D235 | TypeScript SDK (#125): npm package @devitek/mailsink in this monorepo (packages/sdk), versioned with the server (the root package.json, D181; release-please bumps packages/sdk/package.json through extra-files). ESM only, plain fetch, no Node-only API (its sources are typechecked without Node typings), so it runs in Node 20+ and browsers. The private @mailsink/contracts is bundled at build (tsdown) into the code and the declarations; zod is its only dependency. publishConfig points exports to dist/, files: ["dist"], MIT, access: public; publication is #128. Usage guide: docs/guides/sdk.md. |
owner (23/11, #122, #133) |
| D236 | SDK client shape (#125): createMailsink({ url, key?, adminKey?, workspace?, fetch?, headers?, validate? }) answers namespaced clients (admin.workspaces, admin.connections, admin.templates, admin.logs, messages, overrides, suppressions, webhooks with deliveries, logs.api, logs.smtp, stream) and with(patch) for a client with other options (the workspace just created). Admin calls send the admin key; workspace calls send key, else the admin key with X-Mailsink-Workspace; a missing credential fails before any request. Bodies are typed z.input of their contract, answers z.output, list queries the output type with every key optional and Date accepted for since, until, before; arrays go comma-separated. Response validation against the contracts is off by default (validate: true). overrides.with(config, fn, { connectionId?, ttl? }) activates, runs fn and resets the same scope in finally. Binary reads: messages.raw answers the EML as text, messages.attachment { filename, contentType, data }. |
owner (23/11, #133) |
| D237 | messages.waitFor(filters, { timeout?, since?, signal? }) (#125): wait=true with since defaulting to the time of the call (the README pitfall: start the wait before the action, or pass since taken before it; since is the client clock). Default timeout 10 s; a wait over the server maximum (30 s) is split into successive long polls until the deadline. Answers the earliest message of the matching page (the first that arrived) as a full MessageDetail, read with messages.get; no match: MailsinkError wait_timeout whose message and details carry the filters. |
owner (23/11, #133) |
| D238 | SDK errors (#125): one MailsinkError with code, status, requestId, details. code is the server ErrorCode (D40) read from the contract body, plus network_error (no answer, status null) and invalid_response (non-JSON answer, or a failed validation with the Zod issues in details); an error answer without the contract body (proxy page) gets the code of its status (D40 read backwards, internal_error otherwise). requestId comes from X-Request-Id, else the body. An aborted call rethrows the abort reason. isMailsinkError(e, code?) narrows. |
owner (23/11, #133) |
| D239 | SDK stream and helpers (#125): stream.subscribe(handler, { types?, connectionId?, lastEventId?, retryMs?, signal?, onOpen?, onError? }) reads GET /capture/stream over fetch (own SSE parser, no EventSource, so headers work everywhere), hands each StreamEvent with its frame id (null for derived frames), and reconnects after the server retry: (3 s) or retryMs with Last-Event-ID; a 400, 401, 403, 404 or 422 stops it (ready and done reject), workspace.deleted ends it, handler failures go to onError. Helpers on a message: extractLinks (server links, then HTML hrefs with entities decoded, then text URLs; http(s), once each), `findLink(message, substring |
RegExp |
| D240 | Playwright helpers (#126): npm package @devitek/mailsink-playwright (packages/playwright), versioned with the server like the SDK (D235), built on @devitek/mailsink (dependency) with @playwright/test >= 1.47 as peer dependency (fixture box, matcher timeout). It exports a test (@playwright/test extended with the fixtures) and an expect (with the matchers), meant for mergeTests / mergeExpects, plus the helpers. ESM, built with tsdown; publishConfig points to dist/. Usage guide: docs/guides/e2e.md. |
owner (24/11, #142) |
| D241 | Workspace fixtures (#126): worker option mailsinkOptions (url and adminKey default to MAILSINK_URL and MAILSINK_ADMIN_KEY, connections to one Resend connection app, idleTtlSeconds to 600, metadata.createdBy to playwright · worker N, name to playwright-wN, other POST /admin/workspaces fields through workspace); worker fixture mailsinkWorkspace (ids, key, connections with credentials, merged .env of the connections with the first one winning, SDK clients client and admin) deleted at worker teardown (404 counts as done, retried on a network error). A file asking for other connections gets its own workers (test.use). |
owner (24/11, #142) |
| D242 | Test fixtures (#126): before each test, mailsink purges the messages, resets every active override (workspace and per connection, read from GET /capture/override) and empties the suppression list (option mailsinkReset: true, false or per part); since is the start of the test (runner clock). withOverride(config, options?) lasts until the test ends (the scopes it touched are reset at teardown, a deleted workspace tolerated), withOverride(config, fn) is the SDK overrides.with; option mailsinkOverride activates one for every test of a file or group. |
owner (24/11, #142) |
| D243 | expectEmail(filters, { timeout?, since? }) (#126): the SDK waitFor with since defaulting to the start of the test and status accepting a single value; wrapped in a boxed test.step. On wait_timeout it throws an error listing the emails received since since (at most 10: recipients, subject, status, id). |
owner (24/11, #142) |
| D244 | Matchers and links (#126): toHaveLink(matcher?), toHaveAttachment(expected) (a file name, a RegExp, or { filename?, contentType? }), toHaveStatus(status, { recipient?, timeout? }) (one status or several); an email answered by expectEmail remembers how to read itself again (a WeakMap), so toHaveStatus polls it every 200 ms up to the expect timeout, any other object is checked as is. getLink and getCode are the SDK findLink and extractCode throwing an explanatory error instead of null; openLink(page, email, matcher?, { rebase? }) is page.goto on the link, rebase replacing its origin. No generic hydration helper: what proves a page interactive depends on the application. |
owner (24/11, #142) |
| D245 | Vitest and Jest helpers (#127): one npm package @devitek/mailsink-vitest (name confirmed) in packages/vitest, versioned with the server, ESM only, Node 20+. Entries: . (Vitest fixtures, injectMailsink, matchers, workspace helpers), ./setup (Vitest setupFiles, registers the matchers), ./global-setup (Vitest globalSetup), ./jest and ./matchers (neither loads Vitest). @devitek/mailsink is a dependency (not bundled), vitest >= 5 an optional peer (the Matchers<R, T> augmentation of Vitest 5). Built with tsdown, publishConfig points to dist/. Guide: docs/guides/vitest-jest.md. |
owner (24/11, #142) |
| D246 | Test workspace (#127): createEphemeralWorkspace({ url?, adminKey?, fetch?, workspace? }) reads MAILSINK_URL and MAILSINK_ADMIN_KEY by default and creates an ephemeral workspace (the idle TTL purges it when a run dies before its teardown), named Tests with one Resend connection Test unless workspace says otherwise, metadata.createdBy @devitek/mailsink-vitest. Handle { url, workspace, workspaceKey, connections, client, credentials(kind?), dispose() }; dispose deletes once and ignores not_found. connectWorkspace(data) wraps the serializable part (a global setup’s) with a dispose that deletes nothing. |
owner (24/11, #142) |
| D247 | Runner integration (#127): Vitest test and createMailsinkTest(options | () => options, 'file' | 'worker') give a mailsink fixture created on first use and deleted at file (default) or worker teardown, which Vitest runs after every afterAll; such fixtures must be declared at the top level of a module. @devitek/mailsink-vitest/global-setup (or mailsinkGlobalSetup(options)) creates one workspace for the run, provide('mailsink', data), and injectMailsink() reads it. Jest: useMailsinkWorkspace(options, hooks?) registers beforeAll/afterAll (a workspace per test file, from a test file or a setupFilesAfterEnv module), mailsinkWorkspace() reads it (kept on globalThis under a Symbol.for key), installMailsinkMatchers(expect?). |
owner (24/11, #142) |
| D248 | Matchers (#127), plain expect.extend functions using only this.isNot, so Vitest and Jest share them: await toHaveReceivedEmail(filters?, { timeout = 5 000, since }) on a client or a handle waits with messages.waitFor and since defaulting to the epoch (every message of the workspace counts, unlike waitFor alone), lists the five latest messages on failure, and under .not checks once without waiting; toHaveStatus(status | status[], { recipient? }) reads the aggregate or one recipient synchronously (a later status is a status filter of toHaveReceivedEmail); toHaveLink(substring | RegExp | predicate?) uses the SDK findLink/extractLinks and lists the links on failure. Types: the package augments Vitest’s Matchers; Jest users augment expect (or jest.Matchers) with the exported MailsinkMatchers<R> (documented). |
owner (24/11, #142) |
| D249 | Tests of the helpers (#127): matchers on plain values with a fake client; workspace, matchers and global setup against the real HTTP routes (SDK harness) on both drivers; fixtures on PGlite only (top-level scoped fixtures cannot follow describeDb). Jest example project packages/vitest/test/jest-project (*.jest.mjs, out of Vitest’s include) run by a Vitest test with node --experimental-vm-modules Jest 30 on a tsdown bundle of src/jest.ts, against the in-process server; it checks three passing tests and no workspace left. jest is a dev dependency of the package; the install script of @parcel/watcher (Jest’s watcher, prebuilt binaries) is denied in pnpm-workspace.yaml. |
owner (24/11, #142) |
| D250 | Piloting CLI commands (#50): mailsink workspace create|list|delete, wait, override set|reset and purge call the HTTP API through the SDK (bundled into the bin), never the database. Settings: flag first, then MAILSINK_URL (default http://localhost:3000), MAILSINK_ADMIN_KEY (workspace commands), MAILSINK_KEY (workspace or connection key), MAILSINK_WORKSPACE (with the Admin key only). Human output by default, the API answer with --json. workspace create prints .env lines (MAILSINK_URL, MAILSINK_WORKSPACE_ID, MAILSINK_WORKSPACE_SLUG, MAILSINK_KEY = the mskw_ key, then each connection’s envSnippet), ready for >> "$GITHUB_ENV"; --connection <kind>[:<name>] repeats, the name defaults to the kind; the workspace name defaults to mailsink-cli. |
owner (24/11, #142) |
| D251 | CLI distribution (#50): packages/cli is renamed @devitek/mailsink-cli (scope D226, version of the server D181), npx @devitek/mailsink-cli installs only zod and the MCP client. migrate and mcp are lazy chunks; drizzle-orm, pg and @electric-sql/pglite become optional peer dependencies (dev dependencies in the monorepo), so the piloting commands never need them, and migrate without them exits 1 with a message naming the missing package. The Docker image provides them: pnpm --filter @mailsink/db deploy --prod /deploy/db copied to /app/node_modules, where Node resolves them from /app/packages/cli/dist. Rejected: lazy import alone (npx would still download PGlite), optional dependencies (npm installs them by default), migrate only in the image (two builds of one package). |
owner (24/11, #142) |
| D252 | CLI exit codes (#50): 0 success, 1 failure (API error, network, refused key, migrate failure), 2 invalid command line (unknown command or option, invalid value, missing credential), 3 mailsink wait timed out. Errors go to stderr as <code>: <message> (request <id>) for API errors, never with a key. The unknown command exit code moves from 1 to 2. |
owner (24/11, #142) |
| D253 | mailsink wait (#50): the filters of GET /capture/messages (--to, --from, --subject, --tag, --q, --connection), --timeout (default 10s; 500ms, 5s, 2m, a bare number is seconds), --since (ISO date, now, or a duration ago such as 5m). Unlike the SDK (D237), since defaults to the epoch: a shell script runs the action before the command, so a message stored earlier counts; --since now waits for a new one. The answer is the SDK’s (the first matching message, as a full detail); --json adds extractedLinks (SDK extractLinks) and link; --link <substring> prints only the first matching link (exit 1 when none matches). |
owner (24/11, #142) |
| D254 | mailsink override set (#50): status rates as percentages (--delivered, --deferred, --soft-bounce, --hard-bounce, --complained, --failed), --latency <min>-<max> in ms (or one value), --error-rate (chaos), --rule '<glob>=<status>' (repeats), and --config <json> for any other OverrideConfig field, the flags merged over it. --ttl and --connection scope it; override reset [--connection] mirrors POST /capture/override/reset. mailsink purge [--connection] [--before <iso>] [--keep-logs] mirrors DELETE /capture/messages. |
owner (24/11, #142) |
| D255 | npm packages (#128): a workspace package is published when its packages/*/package.json is not private and is named @devitek/* (.github/scripts/public-packages.mjs, dependencies first), so a new package joins without editing the workflows. The CI packages job and the release run the same pack-public.sh: build, pnpm pack (it rewrites workspace: ranges and applies publishConfig), the root LICENSE copied in, then check-pack.mjs (every entry point present, no workspace: range, no private @mailsink/* dependency, README and LICENSE, MIT, public access, repository URL) and a version equal to the server (each package is in the release-please extra-files). |
owner (24/11, #142) |
| D256 | npm publication (#128): job npm of release-please.yml calls release-npm.yml (also runnable by hand for a tag), after the tag check, with npm >= 11.5.1. Trusted publishing (OIDC, id-token: write on the caller and the callee) first, the NPM_TOKEN secret as fallback (first publish of a package, before a trusted publisher can be set); provenance attestations either way. npm checks the calling workflow, so each package trusts release-please.yml and release-npm.yml. Versions already on npm are skipped, a rerun is safe. No dependency cache in publishing jobs. |
owner (24/11, #142) |
| D257 | openapi.json release asset (#128, D234): job openapi of release-please.yml calls release-openapi.yml (also by hand), which generates the document of the tag (pnpm openapi), checks info.version against the tag and uploads it with gh release upload --clobber. |
owner (24/11, #142) |
| D258 | SDK Node support in CI (#128, #132): the SDK declares Node >= 20 but Vitest 5 runs on Node 22.12+ only. Job sdk-node (matrix 20, 22, 24): installs with .node-version, runs the SDK Vitest suite on 22 and 24 (PGlite; Postgres stays in check), and on every version installs the packed SDK of the packages job in an empty project and runs .github/scripts/sdk-smoke.mjs (node:assert, fake fetch). The Dockerfile deploys the CLI by folder (--filter ./packages/cli), not by name. |
owner (24/11, #142) |
| D259 | SDK declarations and test imports (#132): Mailsink is an interface (was ReturnType<typeof createMailsink>), so index.d.ts names the API types instead of inlining every response (226 KB to 138 KB). The Zod schema declarations behind z.input/z.output remain (about 80 KB); dropping them needs generated plain types (done by D260). The SDK tests import the app through its test-only export @mailsink/app/testing (runtime fixtures, stopRuntime, routesDir), no relative path into apps/. |
owner (24/11, #142) |
| D260 | SDK plain types (#132): packages/sdk/src/contract-types.ts derives the request and response types from the Zod contracts (z.input/z.output); pnpm --filter @devitek/mailsink generate:types (scripts/generate-types.ts) expands each one into a plain object type through the TypeScript declaration emitter (a value typed Expand<T> prints structurally) and writes src/types.ts, which the SDK code and the published declarations use. test/types-fidelity.ts, generated with it, asserts that each plain type and its Zod source stay mutually assignable, so pnpm typecheck fails when the contracts change without a regeneration. index.d.ts drops from 138 KB to 63 KB (226 KB before D259) and no longer carries Zod schemas; the server error codes are exported as ErrorCode. The JSDoc of contract fields, dropped by the emitter, is put back by scripts/type-docs.ts (#146): it reads each field’s documentation from the Zod-derived types through the TypeScript 7 API (typescript/unstable/sync, read only) and writes it above the same property path of the emitted text, arrays and unions being transparent. |
owner (24/11, #146) |
| D261 | Server clock (#132): createServerClock (@mailsink/contracts) estimates the server time from the Date header of answers. A header (one second precision, written between request and answer) bounds the offset to [date - receivedAt, date + 1 s - sentAt]; successive bounds are intersected (reset when they disagree) and the client clock is corrected by the smallest offset they allow, so only a proven skew is applied, never more than about a second of error. The SDK transport feeds it from every answer; mailsink.now() reads it (shared by with() on the same URL); waitFor defaults since to it, and the Playwright fixture takes the test start from it. Before any answer, or for a cross-origin browser call (the header is not exposed), it is the client clock. The web UI measures it once per page load from GET /healthz (useServerNow) for the ephemeral countdown. |
owner (24/11, #146) |
| D262 | OpenAPI response check (#132): packages/sdk/test/openapi-responses.test.ts records the real answers of a representative set of routes (admin, templates, messages, events, overrides, suppressions, webhooks, deliveries, logs, a 404 and a 422) through the SDK on both drivers, then checks that the document declares each status for its operation and that each JSON body parses with the registry schema (ApiErrorBody for errors) and equals its parsed value, so an undocumented field fails. |
owner (24/11, #146) |
| D263 | Hydration marker (#132): the root route sets data-hydrated on <html> in an effect once React owns the page. The e2e helper gotoHydrated(page, url) (tests/e2e/goto-hydrated.ts) navigates then waits for it, and every UI scenario that runs JavaScript navigates with it, so no click lands on the inert server HTML. The UI scenarios create their workspaces through the SDK (tests/e2e/workspace-api.ts, ex recipe/api-context.ts); the raw adminContext stays for assertions on HTTP itself. |
owner (24/11, #146) |
| D264 | Test suite budgets (#141): projects running database suites merge vitest.shared.ts (testTimeout 30 s, hookTimeout 60 s; directory projects do not inherit the root config); the root config runs 2 workers when CI is set (4 vCPU runners shared with the Postgres service), the default elsewhere. The Vitest fixture suite runs on both drivers from two files (fixtures.test.ts, fixtures.postgres.test.ts) calling fixtureSuite(driver) at their top level, since file and worker fixtures cannot be declared inside describeDb. |
owner (24/11, #146) |
| D265 | Documentation website (#144): Astro Starlight in apps/docs (@mailsink/docs, private, not published), English only. Chosen over VitePress for its built-in search (Pagefind, static), the plugins it needs here (OpenAPI reference, link validation), dark mode and later i18n; it also stays outside the Vue stack. pnpm docs:dev / pnpm docs:build; the root pnpm build leaves it out (CI check and the Docker image do not build it, docs.yml does). |
proposition (#144) |
| D266 | Single source for the website (#144): apps/docs/scripts/sync.ts, run by dev, build and typecheck, renders the files listed in scripts/pages.ts (README sections Installation to Features as « Getting started », docs/guides/, docs/architecture/, CONTRIBUTING.md, docs/contributing/) into the git-ignored Starlight collection: the first # heading becomes the title, editUrl points to the source on GitHub, relative links to a rendered page become its site path (hash kept), other repository paths become GitHub URLs, and a link to a missing path fails the sync. The landing page (src/content/docs/index.mdx, committed) imports the README introduction and first Compose commands from the same sync. The API reference is rendered by starlight-openapi from the document createOpenApiDocument() produces at sync (no server URL, so independent of MAILSINK_PUBLIC_URL): native Starlight pages, in the search and the theme, without the client-side bundle Scalar or Redoc would add. |
proposition (#144) |
| D267 | Website brand (#144): Starlight colors map to the --ms-* tokens of docs/design/brand-1/tokens/tokens.css (src/styles/brand.css); both use data-theme on <html>, so one mapping covers light and dark. Accent fills (current sidebar page, primary button) are yellow with ink text in both themes. Geist and JetBrains Mono come from @fontsource (self-hosted), the logo is the brand mark next to the lowercase mailsink title, the favicon is the brand favicon. |
proposition (#144) |
| D268 | Website deployment (#144): .github/workflows/docs.yml builds on pull requests touching its sources (apps/docs, docs, README.md, CONTRIBUTING.md, contracts, openapi, lockfile) and builds then deploys on every push to main (upload-pages-artifact + deploy-pages, pages: write and id-token: write on the deploy job only), so no source can change without a redeploy. Served at the root of mailsink.devitek.fr (public/CNAME, no base, trailing slashes). |
proposition (#144) |
| D269 | Website link checks (#144): starlight-links-validator fails the build on a broken internal link or hash (local localhost links allowed, the injected /api/ routes excluded), and the sync fails on a relative link to a missing repository file. External URLs are not checked. |
proposition (#144) |
| D270 | Mermaid on the website (#150, #155): ```mermaid blocks stay in the Markdown sources (GitHub renders them) and stay diagram code in the site’s HTML, drawn in the reader’s browser; no browser runs at build (the first approach, inline SVG rendered at build in a headless Playwright Chromium, was refused by the owner). A Sätteri mdast plugin (apps/docs/src/mermaid/plugin.ts, added to Astro’s Markdown processor by src/integrations/mermaid.ts, before Expressive Code) turns each block into a <figure class="ms-mermaid"> holding the escaped source, after parsing it with Mermaid in Node (src/mermaid/parse.ts). The same integration injects a small page script (src/mermaid/client.ts, about 6 kB) that does nothing on a page without a figure and otherwise loads Mermaid (bundled with the site, no CDN) and draws every diagram with the base theme, its variables read at build from the light and dark blocks of tokens.css (no hard-coded color), following Starlight’s data-theme and drawing again when the theme selector changes it; until then, or if drawing fails, the figure shows the source. A wide diagram fits the column down to 70 % of its size, then scrolls (src/styles/mermaid.css). Considered: astro-mermaid, which hooks remark and rehype (this site uses Sätteri) and maps to Mermaid’s stock themes rather than the tokens. astro build fails on a diagram that does not parse, and build-checks fails it when a page holds a mermaid code block or fewer figures with a non-empty source than its source has blocks (counts written by the sync); astro dev warns and keeps the figure. docs:dev draws the diagrams too (Mermaid pre-bundled by Vite). A ; in a message ends a Mermaid statement: the sequence diagrams used some, now commas. |
owner (24/11, #153) |
| D271 | Website version (#148): the site keeps documenting main (deployed on every push, D268) rather than the latest tag or several versions: GitHub Pages serves one site, a per-tag build would hold documentation fixes back until a release, and a version selector needs one build per version. Every page but the landing page (adjusted 24/11, #153: the splash page keeps its hero alone), API reference included, carries a Starlight banner (route middleware src/route-data.ts, content src/banner.ts) saying so, with the latest release from the root package.json (bumped by release-please, synced to src/generated/release.json) linked to its tag and changelog. To revisit when a release line needs its own docs. |
owner (24/11, #153) |
| D272 | Website link checks, extending D269 (#148): build-checks (astro:build:done) checks every root-relative href and src of the built pages against dist/, so the /api/ routes injected by starlight-openapi, which starlight-links-validator cannot see, are covered too (/pagefind/ excepted, written later). External links: pnpm --filter @mailsink/docs check:external requests each http(s) link of dist/ once (HEAD, then GET), local hosts, reserved example domains, the site itself and the repository’s own GitHub URLs skipped (the sync checks repository paths; release links exist only once cut). Only 404 or 410 fails; 401, 403, 429, 5xx and network errors are reported as unreachable, an error with --strict only. Successes are cached a week in apps/docs/.cache/ (an actions/cache entry saved on every run). The step blocks pull requests, not the deployment on main. |
owner (24/11, #153) |
| D273 | Website housekeeping (#148): astro.config.ts is typechecked by its own project (tsconfig.config.json: lib ESNext and no strict null checks, the two options starlight-openapi’s TypeScript sources need; what the config imports from src/ stays under the strict tsconfig.json). The Docker build context keeps only apps/docs/package.json (the workspace still matches the lockfile) and the image install filters !@mailsink/docs; pnpm fetch still downloads its packages into the cached store layer. Build warnings removed: an i18n collection (src/content/i18n/en.json, the edit link label) and a committed 404.md, a draft so only Starlight’s /404 route renders it. The url.parse() deprecation printed while building the API reference comes from httpsnippet inside starlight-openapi. |
owner (24/11, #153) |
| D274 | One favicon source (#148): docs/design/brand-1/logo/ holds the brand files. The website copies favicon.svg at sync (git-ignored in apps/docs/public/); the app keeps its served copies in apps/mailsink/public/ (fixed URLs, manifest icons) and src/public-assets.test.ts fails when one differs from its brand source. |
owner (24/11, #153) |
| D275 | Brevo GET /v3/smtp/emails (#149): one item per message and recipient (to, cc, bcc) sent through the calling brevo connection only (a Brevo account is one connection), filtered by recipient email, templateId or messageId (one required, missing_parameter), between startDate and endDate (UTC calendar days, both or none, at most one calendar month, else out_of_range), the past 30 days without dates; sort (default desc), limit (default and max 500), offset; answers { count, transactionalEmails } with uuid = the recipient row id and tags = tag values (omitted when empty). |
owner (24/11, #153) |
| D276 | Brevo blocked contacts (#149): GET /v3/smtp/blockedContacts reads the workspace suppression list (D75) by offset (limit default 50, max 100; dates both or none and never in the future; senders comma separated or repeated, matched on the sender of the message that listed the address), newest first unless sort=asc; reasons hard_bounce -> hardBounce, complained -> contactFlaggedAsSpam, manual -> adminBlocked. DELETE /v3/smtp/blockedContacts/{email} removes one address (204), 404 document_not_found when it is not listed, as Brevo documents. |
owner (24/11, #153) |
| D277 | Invalid recipient address (#149, #153), replacing the first proposition (no new canonical event, email.failed as Brevo invalid_email): Mailsink simulates the providers faithfully, so what exists at Brevo exists in its connector. A canonical event email.invalid and a simulated status invalid are added: drawn from the rates, set by a recipient rule (*+invalid@*), forced through the events API, the MCP tool and the UI « Simulate » bar, offered by the CLI (--invalid), typed in the contracts, the OpenAPI document and the SDK. Brevo receives it as invalid_email (subscription invalid); email.failed is emitted to Brevo as error, as Brevo does (amends D22). Resend and unified mapping, subscription name of error and suppression list: D280, D283. |
owner (24/11, #153) |
| D278 | Basic auth in a webhook URL (#149): Brevo accepts https://user:pass@host/…, which fetch refuses. On create and PATCH, credentials in a brevo endpoint url are taken out (percent-decoded) and stored as brevoAuth basic, sent as Authorization: Basic by every attempt (test send and replays included); another format answers 422 url_credentials_require_brevo, credentials next to a bearer or basic brevoAuth 422 conflicting_webhook_auth. A row stored before still delivers (the send moves the credentials to the header) and views redact its URL. |
owner (24/11, #153) |
| D279 | Brevo idempotency (#149, #153), as Brevo documents it (« Idempotency for batch emails »): the key is the idempotencyKey entry (any case) of the headers body field and must be a UUID (else 400 invalid_parameter); it lives 30 minutes per connection (a Brevo account; stored as brevo:<connectionId>:<key> so it never meets a native or Resend key); any reuse within that window, same body or not, answers 400 duplicate_parameter (Request already processed: …, Brevo documents the code, not the message) and nothing is stored; a request refused before being stored does not consume its key. The Idempotency-Key HTTP header is ignored on the Brevo route. The native and Resend dialects keep D53 (runIdempotent takes a refuse policy for Brevo, replay by default). |
owner (24/11, #153) |
| D280 | Failure events per format (#153, D277): Brevo documents the error payload but its webhook API lists no subscription name for it; Mailsink accepts error (stored email.failed). Resend has no invalid-address event and documents invalid recipients under email.failed, so email.invalid is emitted as email.failed with failed.reason (Invalid recipient address unless a reason is given); subscribing to Resend email.failed stores email.failed and email.invalid (in toCanonical, a dialect name of the format now wins over the canonical name it shadows), and migration 0004 adds email.invalid to the Resend endpoints already subscribed to email.failed. Unified emits email.invalid as is. Resend last_event reads failed for an invalid recipient. |
owner (24/11, #178) |
| D281 | URL credentials stored before D278 (#153): migration 0004 moves user:password@ out of the URL of brevo endpoints with brevo_auth = 'none' into brevo_auth = 'basic', percent-decoded like decodeURIComponent (a part that does not decode is kept as written, like the create path); the URL keeps the rest as written (no host normalization). Rows of another format, or with an explicit bearer or basic auth, are left as they are: create and PATCH refuse them today (422), so they keep the send-time fallback and the redacted views of D278 instead of losing credentials. |
owner (24/11, #178) |
| D282 | invalid in the product (#153): drawn after failed (rates order deferred, soft_bounce, hard_bounce, complained, failed, invalid); in the message aggregate it ranks just below failed (failed > invalid > hard_bounce…). Its colour is a new extension token --ms-status-invalid (packages/ui/src/styles/tokens-ext.css, light oklch(0.52 0.1 200), dark oklch(0.76 0.1 200): a teal at the lightness of the delivered statuses, away from the reds of failed and hard_bounce), tested for every status in both themes. The viewer « Simulate » bar gets an « Invalid » action next to « Hard Bounce » (neutral style: it does not suppress). Status names stay technical values, never translated. |
owner (24/11, #178) |
| D283 | Invalid addresses and the suppression list (#153): not listed, like failed. Brevo’s blocked contacts only carry hard bounces, spam complaints, unsubscriptions and admin blocks (reason.code of GET /v3/smtp/blockedContacts), so an invalid address never shows there; the simulation and forced statuses keep listing hard_bounce and complained only. |
owner (24/11, #178) |
| D284 | Brevo read days (#153, D23): startDate and endDate of GET /v3/smtp/emails and GET /v3/smtp/blockedContacts are calendar days of the workspace timezone (local midnight to local midnight, daylight saving included, UTC when the zone is unknown), the zone Brevo dates its webhooks in. « Not in the future » is checked in core against today in that zone; the contract keeps a coarse check (after today at UTC+14 is refused) since it does not know the workspace. |
owner (24/11, #178) |