Skip to main content

MailRoute / MailGuard

Path: products/mailroute/

Email security and management tooling. The MailRoute project spans mail relay infrastructure and MailGuard — a policy engine whose rules are authored in the Glither DSL (glither.mail dialect) and compiled by the tangle compiler.

Glither-Powered MailGuard

MailGuard rulesets are written in the glither.mail dialect (flat-verdict, fold first-match) and compiled to three targets:

TargetOutputUse Case
GleamTyped, readable oracleAudit, differential conformance verification
RustStruct + dispose() functionProduction deployment; verified with cargo check
WITComponent-model interfaceMembrane contract / capability sandbox boundary

The mailguard.glith ruleset (6 rules — DMARC reject, spoof quarantine, executable quarantine, external tagging, newsletter routing, allowlisted delivery) compiles through the entire pipeline: parse, lower, infer crossing phases, check, and codegen. Rust output is verified via cargo check in the test suite.

Compiler Pipeline

mailguard.glith
│ tangle: pest parse → lower to typed IR

Typed Core IR ──► IR snapshot (CBOR + JSON)
│ derive
├──► WIT world (package glither:mail)
├──► Gleam code (auditable oracle)
└──► Rust code (production, cargo check verified)

The compiler (51 tests, zero clippy warnings) supports 4 dialects: glither.mail, glither.decision, glither.segment, and glither.articles. Each dialect registers its artifact field roots for crossing-phase inference. Validation catches unsatisfiable guards, missing liveness deadlines, unlawful lowers, and dead rules in first-match cascades.

Sub-Projects

MailGuard — Email Security Gateway

Security-focused email processing with:

  • Attack surface review — audited auth sessions, webhooks, realtime channels, subprocess surfaces, PII-in-logs, rate limiting, dependency exposure, attachment archive
  • Hardening — SQLite scope, login throttle, HTTP headers, TLS verification, Cloudflare Worker replay protection
  • Glither compilation — policy rules migrated from ad-hoc Python to the glither.mail DSL; compiled to Rust/Gleam/WIT with 51-pass test suite
  • Monetization — pricing tiers, Stripe checkout, onboarding wizard, landing page, analytics, MCP demo documentation

Proton Bridge Integration

Integration with Proton Mail's bridge protocol for secure email access. Currently blocked on community-level monetization path.

Infrastructure Components

  • Mail relay — sending and receiving mail processing
  • Threat detection — scanning and filtering pipelines
  • Archive — encrypted attachment storage

Key Completed Work

AreaCompleted Items
Glither CompilerPEG grammar, typed core IR, crossing-phase inference, dead rule detection, 3 codegen targets (Gleam/Rust/WIT), CLI with check/snapshot/gleam/wit/rust commands, Rust compilation verification, 4 fixtures across 4 dialects, 51 tests, zero clippy warnings
Security ReviewAttack surface analysis across auth, webhooks, realtime, subprocess, PII logging, rate limiting, dependency exposure, attachment archive
Security HardeningSQLite bounds, login throttle, HTTP security headers, TLS verification, Cloudflare Worker replay protection
Monetization ReadinessPricing tiers designed, Stripe checkout integration, onboarding wizard, landing page, analytics integration, MCP demonstration docs
Repository StructureFive-phase repository restructure completed
Self-Host SupportEnvironment template, install script, Makefile, README, Docker Compose cleanup, Docker Hub publishing

Technology Stack

ComponentTechnology
Policy DSLGlither (glither.mail dialect)
CompilerRust (pest parser, typed IR, dual codegen)
Codegen TargetsGleam (oracle), Rust (production), WIT (contract)
Email BridgeProton Bridge protocol
PaymentsStripe
DeploymentDocker Compose
AnalyticsSelf-hosted

Current Status

The Glither compiler spine is complete and production-ready for the glither.mail dialect. Most core MailRoute/MailGuard work is done (51+ completed tasks across compiler, security, hardening, monetization, restructuring, and self-host support). The main blocker is mailguard-monetize-proton-community (community monetization path for the Proton integration).

Relationship to Workspace

MailRoute/MailGuard is the email security pillar of the RAGBAZ portfolio, complementing:

  • products/articulate/mailstack/ — transaction mail relay for the Articulate platform
  • experiments/glither/ — the Glither compiler that powers MailGuard's policy engine
  • infra/infisical/ — secrets management shared with MailGuard
  • products/discord-bot/ — alerting surface for security events