Engineering · July 1, 2026

Sequence, don't sprawl

Between June 23 and July 1 the inbox platform behind TwinMail (Technical Preview) went from 78 passing tests to 350, and almost none of that work ran in parallel. The order came first: a master plan written on 2026-06-23 locked a harden-first sequence, defined phases P0 through P6, and required each phase to be independently shippable. The plan is an application of a simple rule: sequence, don't sprawl. A phase ships, its exact test count gets stamped into the commit body, and only then does the next phase get to exist.

Broken primitives first

Phase 0 existed because recon turned up five verified correctness bugs, each verified against source in the plan itself, most pinned to file and line. The worst two: move_message on Gmail replaced a message's entire label set instead of changing one label, and the AI draft-reply path mis-addressed replies and dropped them out of their thread. The plan's reasoning was blunt: a harden plan cannot build on broken primitives. Those fixes took the suite from 78 to 88.

One deliberate inversion came even earlier. The Postgres store landed minutes before the bug fixes, because the schema carried the arc's only long bet: every table owner-scoped by user_id from row one, while the product still had exactly one user. More on that bet below.

Trust gates before anything that acts

Foundations and audit followed: parallel fan-out triage, an auth seam, per-mailbox AI egress controls (100 tests), then health checks and security headers (105). Then P2, the phase everything later leans on. A send-confirm gate that returns 409 on new recipients, send-later, and session login landed at 113; a send rate-limit that fails closed and an agent-send guard landed at 116. The guard is the shape we want every guarantee to take: MCP send_message does not exist unless an operator sets MCP_ENABLE_SEND=1, so an agent cannot send mail by accident, because the tool is absent rather than merely declined.

P3 deepened threading and attachments (124), survived a three-lens adversarial review that found two real bugs (127), and closed at 135 while fixing a send-confirm bypass discovered along the way. P4 began by splitting the single-file dashboard into 17 native ES modules, no framework, no build step, before adding a single feature; it finished at 143 with keyboard nav, a command palette, and bulk select layered on top. Every commit named so far carries the same date: 2026-06-23.

Where the numbering bent

Strict sequence does not mean strict phase numbers. The P6 AI provider seam shipped before the P5 rules work, and the reason is the whole argument. The seam was safe to build because the send gate already held: a provider can draft, and any send that follows still passes the P2 gates. P6 closed at 174 tests on 2026-06-24, with one recorded rejection worth repeating: Anthropic's terms bar third-party use of subscription OAuth, so both providers use API keys, Fernet-encrypted at rest and never returned to the client (only the last four characters are).

Rules automation waited because it acts on the mailbox without you watching. Its evaluator is a pure function: rules_engine.py has no network, no DB, no Flask, so a future background worker inherits identical semantics. Its one-click unsubscribe path (RFC 8058) triggered a four-commit SSRF sub-arc: an initial guard, redirect blocking with a strict 2xx requirement, an IP pin against DNS rebinding, then regression tests that exercise each guard. Three review gates each found real bugs; the final cloud review surfaced 11 findings, including an undo path that could destroy pre-existing state. The phase closed at 299, and the merged suite, with a parallel 30GB archive-ingest track interleaved through the same window, sits at 350.

The first bet pays out

The owner-scoped schema from day one is why the successor roadmap, written 2026-06-26, calls multi-tenancy "mostly plumbing, not migration." That is what sequencing buys: the boring decision made at test 78 is load-bearing at test 350. And the next arc keeps the habit — its opening phase is a debt-verification gate, and its first commit renamed GeminiError to a provider-neutral AIError with a compatibility alias so nothing downstream breaks.

Explore the suite.

Sign in to manage all three.