System Case Study

J5 Mail

An email attention firewall combining typed Jev model judgments with deterministic routing, explainable decisions, and scoped feedback learning. Built as a Next.js web app and native SwiftUI client; live in private beta.

Visit Live Product
Applied AINext.jsTypeScriptJevPolicy EnginesZodPostgresDrizzle ORMSwiftUIGmail API

What Deserves Your Attention?

J5 Mail is an attention firewall for email. Instead of generating another summary of an overflowing inbox, it asks which messages actually need the recipient, which are worth knowing, and which can wait. Every decision includes a reason.

Product: j5-mail.com — private, allowlisted beta. The native iOS client is available to internal TestFlight testers.

The Product Decision

Importance, urgency, relevance, and a request for action are not the same thing. A sales email can sound urgent without creating an obligation. An automated security notification can matter even when the recipient has never interacted with the sender.

The system separates those judgments instead of asking one model to decide everything and perform mailbox actions. The goal is to reduce noise without hiding a genuine obligation.

Model Judgment, Deterministic Policy

  1. Normalize: fetch unread Gmail Inbox mail and retain a bounded, sanitized excerpt alongside sender and authentication information. Threads are the unit of work; new replies can reopen them.
  2. Evaluate: Jev, from TypeSafe AI, answers eight typed questions covering category, required action, consequences, solicitation, time sensitivity, relevance, preferences, and uncertainty.
  3. Route: a versioned deterministic policy combines those scores with scoped preferences and sender authentication. The model does not choose or execute a Gmail write.
  4. Explain: the card exposes the policy's reason, rather than presenting a generated answer as an unquestionable verdict.
  5. Learn: a member's feedback re-routes related open mail through narrowly scoped sender preferences, with safety exceptions for consequential messages.

The five visible levels are Needs you, Worth knowing, You asked for this, To review, and Set aside. Ambiguity stays visible. A claimed billing or security event from a sender that failed authentication goes to review rather than becoming a verified alert or silently disappearing.

Human Control Over Side Effects

J5 Mail does not send, archive, or delete email. When enabled through the member's Gmail grant and the application's write gate, answering a message can mark it read. Undo is available for five seconds.

A model judgment is evidence for the application, not permission to change a mailbox. Reading and routing can evolve independently from the much narrower write capability.

Architecture

LayerResponsibility
Next.js web appInbox, welcome profile, decision details, Gmail OAuth, member API, and synchronization
SwiftUI clientNative inbox, feedback and undo, with Keychain session storage and PKCE sign-in
Shared Zod contractsMail, triage, preferences, and profile schemas
Pure triage packageTyped questions, policy, learned preferences, provider adapter, and evaluation harness
Provider boundaryGmail normalization, incremental sync, and explicitly gated mark-read operations
Data servicesMember-scoped authorization, Drizzle/Postgres persistence, and encrypted excerpts and refresh tokens

The Bun monorepo keeps the policy engine independent of network and storage I/O. Local tests can use embedded Postgres without production credentials. Web and native clients share the same member API rather than maintaining separate decision logic.

Treating Email as Untrusted Input

Email text is fenced as evidence, never instructions to the model or application. Stored excerpts are bounded to 2,000 characters and encrypted at rest. Full message bodies are fetched on demand and not persisted.

The web reader sanitizes email HTML and uses a sandboxed frame that blocks scripts and remote content. The iOS reader disables JavaScript. Member authorization lives in data services, not just route handlers, and unsigned development identity is restricted to local use.

Evaluation Before Expansion

The repository includes policy regression tests and a small, hand-labeled golden evaluation set reporting accuracy, missed required actions, false suppressions, latency, and estimated cost. That is a regression foundation, not proof of broad mailbox accuracy. The next useful step is a larger set of redacted, real feedback cases.

CI checks types, lint, migrations, builds, and phone/desktop browser flows. Native changes have a separate Swift test/build path and a signed TestFlight release workflow.

Current State and Boundaries

J5 Mail is running on my own mailbox across web and iOS. It is not an open, generally available service. Spend controls and account deletion are identified next steps before broader onboarding; Gmail push notifications and an opt-in digest are future work, not current capabilities.

What This Work Demonstrates

The engineering problem is not simply classifying email. It is deciding which judgments can be probabilistic, which rules must remain deterministic, how feedback changes future behavior, and where human permission must stay explicit. J5 Mail turns those boundaries into an everyday product rather than leaving them in a design document.