docs(records): add P0 GitOps trust boundary logs, Stalwart deployment journal, and terminal decision
Brain Structural Validation / Validate Markdown Structure & Links (push) Successful in 8s

Record the completion logs for Homelab Core Milestone P0, document the
full-stack Stalwart mail server and SnappyMail deployment, and preserve
the terminal workspace subsystem ADR.
This commit is contained in:
kiskaadee committed 2026-09-15 21:43:35 -05:00
1 parent 743b688445
commit 13146809b2
4 files changed
+438

No files matched your search

@@ -0,0 +1,169 @@
---
type: decision
status: accepted
project: nixos
tags: [terminal, tmux, niri, alacritty, sessionizer, architecture]
date: 2026-09-14
---
# Architectural Decision Record: Terminal Workspace Subsystem
## 1. Context & Problem Statement
On the `laptop` NixOS mobile workstation, terminal usage encompasses two fundamentally different intents:
1. **Ephemeral work**: Short-lived shells, quick inspections, one-off scripts, and debugging snippets that should start instantly, remain isolated, and terminate upon exit.
2. **Persistent project workspaces**: Long-running development contexts (`Config`, `Brain`, `Core`, `bitetrack-api`) with active background daemons, compilers, Neovim sessions, and multi-pane layouts that must survive graphical window closures.
Previously, tmux had to be started and attached manually, or terminals risked being hardwired to tmux globally. We needed a clean, deterministic architecture that decouples terminal emulation, graphical window tiling, workspace discovery, and session persistence without creating friction across tools, subshells, or desktop layers.
---
## 2. Considered Models
### Model A: Alacritty Globally Spawns Tmux (`shell.program = "tmux"` or `.bashrc` exec)
- **Concept**: Every Alacritty terminal instance attaches or creates a tmux session automatically.
- **Why Rejected**: Converts a workflow preference into a rigid application-level policy. Breaks tools executing `$SHELL` (Neovim `:terminal`, Git diff tools, IDE terminals), causes SSH nested-session collisions, couples unrelated windows to shared session geometries, and eliminates ephemeral scratch terminals.
### Model B: Niri Manages Tmux Sessions Directly
- **Concept**: Niri keybindings hardcode specific project sessions (e.g. `Mod+B -> tmux bitetrack`, `Mod+C -> tmux config`).
- **Why Rejected**: Pollutes compositor configuration with project-specific routing. Violates separation of concerns; Niri should manage graphical windows, not workspace identity.
### Model C: Decoupled Project-Driven Sessionizer (Chosen)
- **Concept**: Niri exposes two distinct entry points: `Mod+Return` for an ephemeral shell and `Mod+T` for a persistent workspace. The workspace entry point launches Alacritty running a dedicated control plane (`tmux-sessionizer` / `ts`) that discovers projects, validates uniqueness, and manages tmux sessions.
---
## 3. Chosen Architecture & Layer Separation
```text
"Where does the window live?"
│
▼
Niri (Window Manager)
│
"How is the terminal rendered?"
│
▼
Alacritty (Terminal Emulator)
│
"Where am I working?"
│
▼
Sessionizer (`ts` Control Plane)
│
"Which persistent context is that?"
│
▼
Tmux (Multiplexer Engine)
```
### Responsibility Boundaries
| Layer | Primary Responsibility | Explicit Boundaries |
| :--- | :--- | :--- |
| **Niri** | GUI window layout, focus, scrolling columns, application lifecycle. | Does NOT know project names or tmux session semantics. |
| **Alacritty** | GPU rendering, PTY allocation, font metrics, raw keyboard/mouse input. | Does NOT auto-start tmux globally; remains a clean terminal emulator. |
| **Sessionizer** | Workspace discovery, name normalization, collision safety, CLI resolution, attach/switch. | Does NOT orchestrate applications (no auto-starting Neovim, compilers, or servers). |
| **Tmux** | Headless process persistence, split panes, windows, layouts, client connections. | Does NOT manage GUI window placement or compositor layout. |
---
## 4. Design Principles
1. **Explicit persistence**: Persistent terminal state is opt-in through the workspace entry point (`Mod+T`); ordinary terminals (`Mod+Return`) remain ephemeral.
2. **Deterministic identity**: A workspace directory maps to a deterministic tmux session name derived from its basename.
3. **Refuse ambiguity**: The system fails rather than guessing when workspace identity cannot be determined uniquely.
4. **Separation of concerns**: GUI management, terminal emulation, workspace resolution, and terminal persistence remain independent responsibilities.
5. **Context without orchestration**: The sessionizer establishes workspace context (working directory and session) but does not dictate which project processes should run.
6. **Preserve existing state**: Reconnecting to an existing workspace restores the existing tmux environment rather than reconstructing or resetting it.
7. **Declarative integration**: The subsystem is packaged and integrated through NixOS/Home Manager (`pkgs.writeShellApplication`) with explicit runtime dependencies, avoiding mutable host state.
---
## 5. Architectural Invariants
The following invariants are normative for the subsystem:
- **INV-001 (Layer Separation)**: Niri owns GUI lifecycle; Alacritty owns emulation; Sessionizer owns workspace resolution; Tmux owns persistent terminal state.
- **INV-002 (Deterministic Naming)**: A workspace directory's basename MUST always normalize to the exact same tmux session identifier.
- **INV-003 (Unique Workspace Identity)**: Within the validated workspace registry, each normalized session name MUST correspond to exactly one workspace directory.
- **INV-004 (Strict Ambiguity Refusal)**: The sessionizer MUST refuse ambiguous workspace resolutions and session-name collisions before taking action.
- **INV-005 (No Nested Tmux)**: Invoking `ts` inside an existing tmux session MUST switch clients (`switch-client`) rather than creating a nested client.
- **INV-006 (Existing-Session Preservation)**: Resolving an existing session MUST NOT change its current working directory or reset its state.
- **INV-007 (Creation Establishes CWD)**: The target workspace directory establishes the working directory only when a new tmux session is created.
- **INV-008 (Independent Workspaces)**: Explicit workspace registration does not depend on Git repository metadata.
- **INV-009 (Supplemental Discovery)**: Git discovery supplements explicit workspace roots rather than replacing them.
- **INV-010 (No Project Orchestration)**: The sessionizer establishes context; it does not orchestrate project applications.
- **INV-011 (Side-Effect-Free Cancellation)**: Cancelling interactive selection (`Escape` in `fzf`) terminates cleanly with code `0` without creating or modifying sessions.
- **INV-012 (Hermetic Dependencies)**: The packaged executable (`tmux-sessionizer`) provides its required runtime dependencies explicitly via Nix `runtimeInputs`.
- **INV-013 (Resolution Snapshot)**: Workspace discovery and normalization MUST produce a single registry snapshot that is validated before resolution. Resolution MUST operate against that snapshot rather than rediscovering workspaces during the same invocation.
---
## 6. Workspace Discovery, Normalization & Collisions
### 6.1 Discovery Hierarchy
1. **Explicit Workspaces**: Registered roots (`$HOME/Config`, `$HOME/Brain`, `$HOME/Homelab/Core`).
2. **Git Repositories**: Discovered by searching for `.git` directories (depth 4) beneath `$HOME/Projects` and `$HOME/Homelab`.
3. **Deduplication**: Directory paths are deduplicated into an associative map before normalization.
### 6.2 Normalization Contract
```bash
normalize_name() {
local raw="$1"
local name
name=$(basename "$raw" | tr '[:upper:]' '[:lower:]' | sed -E 's/[ .]+/-/g; s/[^a-z0-9_-]//g; s/[-_]+$//')
[[ -z "$name" ]] && return 1
echo "$name"
}
```
### 6.3 Global Collision Policy (Strict Refusal)
If multiple paths yield identical normalized session names (e.g. `/home/kiskaadee/Homelab/Core` and `/home/kiskaadee/Projects/archive/core`), validation fails globally:
```text
ERROR: workspace name collision: 'core'
/home/kiskaadee/Homelab/Core
/home/kiskaadee/Projects/archive/core
```
The sessionizer aborts before resolution occurs. Interactive mode does not guess between collided names.
### 6.4 Direct Path Bypass Property
Direct filesystem paths (e.g. `ts ~/some/path`) bypass repository discovery but still undergo canonicalization (`realpath`) and deterministic session-name normalization, allowing persistent sessions in arbitrary locations.
---
## 7. Resolution Algorithm Precedence
When invoked with `ts <argument>`:
1. **Existing Directory**: Direct path match via `realpath`.
2. **Exact Session Name**: Case-insensitive exact match against the normalized session name column.
3. **Exact Basename**: Case-insensitive match against directory basename.
4. **Unique Substring Match**: Substring match across session names and paths. Ambiguous matches list all candidates and fail.
5. **No Match**: Aborts with exit code `1`.
---
## 8. Client Context Awareness & Persistence
```text
Outside Tmux:
Alacritty → ts → fzf → exec tmux attach-session -t <session>
Inside Tmux:
Shell → ts → fzf → tmux switch-client -t <session>
```
Persistence resides strictly in the tmux server:
```text
Alacritty closes → PTY client disconnects → tmux server retains session & jobs
ts <workspace> → reconnects to existing session without resetting state
```
---
## 9. Verification Summary
The implementation is verified via:
1. `shellcheck`: 0 warnings, 0 errors.
2. `nix flake check`: All linters and checks pass.
3. `nix build .#nixosConfigurations.laptop.config.system.build.toplevel --no-link`: Closure evaluates and builds cleanly with `tmux-sessionizer.drv`.
@@ -0,0 +1,60 @@
---
type: journal
date: 2026-09-13
project: homelab
tags:
- homelab
- gitops
- security
- architecture
---
# Homelab Core — Milestone P0: GitOps Trust Boundary Implementation
**Plan Reference:** [`projects/homelab/plans/architecture-consolidation-implementation-guide.md`](file:///home/kiskaadee/Brain/projects/homelab/plans/architecture-consolidation-implementation-guide.md)
**Status:** Completed & Proven (All P0 Deliverables 1.1–1.5 achieved)
---
## 🏛️ Completed Deliverables & Commit Chain
1. **Deliverable 1.1 — Remove Arbitrary `custom` Execution**
- **Commit:** [`29dd186`](file:///home/kiskaadee/Projects/active/homelab/Core) `refactor(gitops): remove arbitrary custom execution`
- **Actions:** Removed `shell=True` and `custom:` execution handler from `scripts/gitops_dispatcher.py`. Unsupported actions fail closed.
2. **Deliverable 1.2 — Trusted Repository Resolution**
- **Commit:** [`01acdb4`](file:///home/kiskaadee/Projects/active/homelab/Core) `feat(gitops): add trusted repository resolution`
- **Actions:** Implemented `resolve_repository(repo_name)` enforcing canonical path resolution, strict regex naming (`^[a-zA-Z0-9][a-zA-Z0-9._-]*$`), directory traversal rejection (`../../etc`), symlink escape rejection, and allowed root containment (`~/Sites`, `~/Brain`).
3. **Deliverable 1.3 — Webhook Authentication**
- **Commit:** [`fa8054a`](file:///home/kiskaadee/Projects/active/homelab/Core) `feat(gitops): add webhook authentication`
- **Actions:** Configured HMAC-SHA256 signature verification (`X-Gitea-Signature`) using constant-time comparison (`hmac.compare_digest`). Generated shared secret encrypted via SOPS/Age in `nixos/secrets.yaml` and projected to `/run/secrets/gitops/webhook_secret` via `homeserver.nix`.
4. **Deliverable 1.4 — Repository, Event, and Branch Admission**
- **Commit:** [`c265c3e`](file:///home/kiskaadee/Projects/active/homelab/Core) `feat(gitops): enforce repository/event/branch admission`
- **Actions:** Implemented `admit_deployment()` verifying event type (`push` only), ref structure (`refs/heads/*` only; tags/PRs rejected), trusted repository identity, manifest validity, and target branch matching policy.
5. **Deliverable 1.5 — Serialized Asynchronous Deployment with Superseding**
- **Commit:** [`5aae4ef`](file:///home/kiskaadee/Projects/active/homelab/Core) `feat(gitops): add serialized asynchronous deployment`
- **Actions:** Separated HTTP admission from background execution. Incoming webhooks write atomic pending files and return HTTP 200 immediately. Workers acquire non-blocking per-repository `flock` locks, sequentially running deployments and automatically superseding intermediate pending commits (A running, B queued, C replaces B -> A deploys, then C deploys).
6. **Deliverables 3.1, 3.2, 3.6 — Automated Testing & CI Invariants**
- **Commits:**
- [`142697a`](file:///home/kiskaadee/Projects/active/homelab/Core) `test(architecture): add structural invariants and test runner`
- [`f4b676b`](file:///home/kiskaadee/Projects/active/homelab/Core) `test(architecture): add compose and socket proxy security invariants`
- [`3351466`](file:///home/kiskaadee/Projects/active/homelab/Core) `ci: run architecture and security validation in flake check and gitea actions`
- **Actions:** Added automated test runner [`scripts/test`](file:///home/kiskaadee/Projects/active/homelab/Core/scripts/test), structural invariant checks (`tests/structural/`), Compose security invariant checks (`tests/security/test_security_invariants.py`), Nix flake check integration (`checks.x86_64-linux.test-suite` in `flake.nix`), and Gitea Actions CI workflow (`.gitea/workflows/ci.yaml`).
7. **Documentation Synchronization**
- **Commit:** [`534ea9e`](file:///home/kiskaadee/Projects/active/homelab/Core) `docs: sync repository documentation with GitOps hardening and automated test invariants`
- **Actions:** Synchronized [`README.md`](file:///home/kiskaadee/Projects/active/homelab/Core/README.md) and [`SECURITY.md`](file:///home/kiskaadee/Projects/active/homelab/Core/SECURITY.md) with the hardened GitOps architecture, automated test runner instructions, Docker socket isolation guarantees, and declarative NixOS SOPS checklist.
---
## 🧪 Verification & Invariant Proofs
- **Pytest Suite**: 31 passing tests in 0.09s (`tests/security/`, `tests/structural/`).
- **One-Command Test Runner**: `./scripts/test` (linting + unit tests + Nix flake check).
- **Ruff Code Health**: Zero lint or formatting warnings across the entire repository.
- **NixOS Evaluation & Pure Sandbox Check**: `nix flake check` passing with zero errors.
- **Continuous Integration**: Machine-enforced via Gitea Actions on every push and PR.
@@ -0,0 +1,68 @@
---
type: journal
date: 2026-09-14
project: homelab
tags:
- homelab
- gitops
- security
- architecture
---
# Homelab Core — Milestone P0: Final Closure and P1 Transition
**Plan Reference:** [`projects/homelab/plans/architecture-consolidation-implementation-guide.md`](file:///home/kiskaadee/Brain/projects/homelab/plans/architecture-consolidation-implementation-guide.md)
**Status:** 🔒 100% SEALED & FROZEN (All P0 Deliverables 1.1–1.5 fully hardened and closed)
**Latest Commits:** [`f8cbe08`](file:///home/kiskaadee/Projects/homelab/Core) & [`4c9e7a4`](file:///home/kiskaadee/Projects/homelab/Core)
---
## 🛡️ Resolution of Reviewer Feedback & Final P0 Hardening
Following architectural review of Milestone P0 (GitOps Trust Boundary), two execution-path considerations were addressed:
1. **Temporal Boundary: Revision-Consistent Manifest Validation**
- **Problem:** Manifest validation performed strictly during the admission phase examined the working tree at admission time (`HEAD-A`), while background deployment executes after a `git pull` updates the working tree to the target revision (`HEAD-B`). If an untrusted commit updated `app.yaml` with unsupported strategies or changed branch policies, the pre-pull check would have missed it.
- **Fix:** In [`scripts/gitops_dispatcher.py`](file:///home/kiskaadee/Projects/homelab/Core/scripts/gitops_dispatcher.py), the worker re-reads and re-validates `app.yaml` immediately after `git pull` updates the working directory. If the pulled manifest contains unsupported actions or invalid branch constraints, deployment fails closed before any commands execute. Validated actions from the pulled revision are adopted for execution.
- **Coverage:** Added automated tests verifying rejection of unsupported actions and policy mismatches introduced post-pull, and adoption of valid updated actions.
2. **Observable Worker Execution State**
- **Implementation:** Added atomic status persistence writing to `~/.local/state/homelab/gitops/<target>.status.json` containing target, branch, commit SHA, success status, and UTC timestamp.
3. **HMAC Signature Specification**
- **Documentation:** Explicitly documented signature headers and formats: `X-Gitea-Signature` uses a bare 64-character hex digest, while `X-Hub-Signature-256` uses the `sha256=<hex>` format.
---
## 🧪 Test Suite & Invariant Status
- **Automated Tests:** 35 passing tests (expanded from 31 to 35).
- **Tooling Verification:**
- `./scripts/test` passes cleanly (Ruff linting + Pytest suite + Pure Nix sandbox check).
- `nix flake check` passes without warnings or failures.
- Gitea Actions CI workflow configured for automated PR/push enforcement.
---
## 📋 P0 Commit Summary
- [`29dd186`](file:///home/kiskaadee/Projects/homelab/Core) `refactor(gitops): remove arbitrary custom execution`
- [`01acdb4`](file:///home/kiskaadee/Projects/homelab/Core) `feat(gitops): add trusted repository resolution`
- [`fa8054a`](file:///home/kiskaadee/Projects/homelab/Core) `feat(gitops): add webhook authentication`
- [`c265c3e`](file:///home/kiskaadee/Projects/homelab/Core) `feat(gitops): enforce repository/event/branch admission`
- [`5aae4ef`](file:///home/kiskaadee/Projects/homelab/Core) `feat(gitops): add serialized asynchronous deployment`
- [`142697a`](file:///home/kiskaadee/Projects/homelab/Core) `test(architecture): add structural invariants and test runner`
- [`f4b676b`](file:///home/kiskaadee/Projects/homelab/Core) `test(architecture): add compose and socket proxy security invariants`
- [`3351466`](file:///home/kiskaadee/Projects/homelab/Core) `ci: run architecture and security validation in flake check and gitea actions`
- [`534ea9e`](file:///home/kiskaadee/Projects/homelab/Core) `docs: sync repository documentation with GitOps hardening and automated test invariants`
- [`f8cbe08`](file:///home/kiskaadee/Projects/homelab/Core) `fix(gitops): enforce revision-consistent manifest validation and worker status observation`
- [`4c9e7a4`](file:///home/kiskaadee/Projects/homelab/Core) `docs: document revision-consistent manifest validation and worker status observation`
---
## 🎯 Next Milestone: P1 Manifest Contract v1
With Milestone P0 sealed, work transitions to Milestone P1:
- **Deliverable 2.1:** Repository identity authority & strict alias collision rejection (centralized registry vs self-derived names).
- **Deliverable 2.2–2.5:** Author `docs/architecture/manifest-specification.md` and JSON schema v1 for `app.yaml`.
- **Phase 4:** Dedicated `gitops` system user and systemd confinement.
@@ -0,0 +1,141 @@
---
type: journal
project: homelab
date: 2026-09-15
tags: [homelab, email, stalwart, snappymail, lldap, authelia, brevo, dns, deliverability]
---
# Complete Self-Hosted Email Infrastructure & Webmail Deployment (Stalwart, LLDAP, Brevo, SnappyMail)
## 1. Executive Summary
Today we successfully engineered, deployed, and verified a production-grade, zero-cost, self-hosted email infrastructure for `roadtotech.me` within **Homelab Core**. The stack bridges modern mail protocols (JMAP, IMAP, SMTP, Sieve) with our existing centralized LLDAP directory, terminates TLS via Traefik, solves residential ISP deliverability through an authenticated Brevo Smart Host relay, and provides a lightweight browser-based webmail client (SnappyMail).
Both inbound direct delivery from Google's MX servers and outbound relay delivery to external Gmail inboxes were tested and verified with 100% deliverability, valid DKIM signatures, and zero spam-flagging.
```mermaid
flowchart TD
subgraph Internet ["Public Internet & DNS (Dynu)"]
GmailIn["External Inbound<br/>(Gmail / Outlook / Proton)"]
GmailOut["External Inboxes<br/>(Gmail Primary Inbox)"]
Brevo["Brevo Outbound Smart Host<br/>smtp-relay.brevo.com:587"]
DNS["Dynu DNS (ns1.dynu.com)<br/>MX, SPF, DKIM1/2, DMARC"]
end
subgraph Router ["Edge Gateway (MitraStar)"]
NAT25["NAT Port 25 -> 192.168.1.36:25"]
NAT443["NAT Port 443 -> 192.168.1.36:443"]
end
subgraph Core ["Homelab Core (server-remote)"]
Traefik["Traefik v3.6 (Reverse Proxy)<br/>Let's Encrypt Wildcard TLS"]
Snappy["SnappyMail Webmail<br/>https://webmail.roadtotech.me"]
Stalwart["Stalwart Mail Server v0.16.22<br/>MTA / IMAP / JMAP / Sieve / RocksDB"]
LLDAP["LLDAP Directory<br/>ldap://lldap:3890"]
Authelia["Authelia SSO<br/>https://auth.roadtotech.me"]
Homepage["Homepage Dashboard<br/>https://dashboard.roadtotech.me"]
end
GmailIn -->|Port 25| NAT25 --> Stalwart
Snappy -->|"Internal IMAPS: 993 / SMTPS: 465"| Stalwart
Stalwart -->|"Auth & JIT Provisioning"| LLDAP
Stalwart -->|"Outbound Relay (Port 587)"| Brevo --> GmailOut
Traefik -->|Port 8888| Snappy
Traefik -->|Port 8080| Stalwart
NAT443 --> Traefik
```
---
## 2. Key Accomplishments & Technical Milestones
### A. Authelia Session Extension
- Extended Authelia session and JWT timeouts in [`Core/config/authelia/configuration.yml`](file:///home/kiskaadee/Homelab/Core/config/authelia/configuration.yml):
- `expiration: 7d` (7 days maximum session lifetime).
- `inactivity: 3d` (3 days idle timeout).
- `remember_me: 1M` (1 month persistent cookie).
- Live cookie header verified: `authelia_session=...; expires=Tue, 22 Sep 2026`.
### B. Stalwart Mail Server Core Infrastructure
- Deployed **Stalwart Mail Server** (`stalwartlabs/stalwart:v0.16.22`) to [`Core/docker-compose.yml`](file:///home/kiskaadee/Homelab/Core/docker-compose.yml) on `proxy-net`.
- **Port Bindings**:
- `25:25`: Standard Inbound SMTP from external MTAs.
- `465:465`: SMTPS (Implicit TLS Submission).
- `587:587`: SMTP Submission (STARTTLS).
- `993:993`: IMAPS (Encrypted IMAP).
- `4190:4190`: ManageSieve (Server-side mail sorting).
- Internal `8080`: Traefik HTTPS routing for `https://mail.roadtotech.me`.
- **Persistent Storage**:
- Configured RocksDB database under `/var/lib/stalwart` mapped to local host directory `./config/stalwart/data`.
- Declared `systemd.tmpfiles.rules` in [`Core/nixos/modules/homeserver.nix`](file:///home/kiskaadee/Homelab/Core/nixos/modules/homeserver.nix) to ensure permanent directory permissions (`0777`) across machine reboots, rebuilds, or fresh disaster recoveries.
### C. LLDAP Directory Integration & JIT Provisioning
- Integrated Stalwart with the internal LLDAP instance (`ldap://lldap:3890`):
- **Base DN**: `dc=roadtotech,dc=me`.
- **Bind Authentication**: Enabled (`bindAuthentication = true`), avoiding cleartext password exposure.
- **Schema Alignment**: Configured user filters for LLDAP's `person` objectClass (`(&(objectClass=person)(|(mail=?)(uid=?)))`) and groups for `groupOfUniqueNames`.
- **Just-in-Time (JIT) Provisioning**: Verified that logging in with `kiskaadee@roadtotech.me` dynamically materializes the mailbox and user profile inside Stalwart without manual pre-provisioning.
### D. Deliverability Architecture (Residential IP + Smart Host)
- **Problem Solved**: Dynamic residential IPs (`PPPoE-Internet`) are blocked by default on Spamhaus PBL / Zen and lack custom reverse DNS (PTR) records, causing direct sends to fail or land in spam.
- **Solution**: Integrated **Brevo** as an authenticated Smart Host outbound relay:
- Secrets encrypted via SOPS in `nixos/secrets.yaml` (`brevo/smtp_login` and `brevo/smtp_key`) and injected into runtime environment templates.
- Configured Stalwart MTA Outbound Route `brevo` pointing to `smtp-relay.brevo.com:587` with STARTTLS.
- Updated MTA Outbound Strategy: local domains (`roadtotech.me`) deliver locally (`'local'`), while all external recipients route through `'brevo'`.
- **DNS Records Verified on Dynu (`ns1.dynu.com`)**:
- `MX 10 mail.roadtotech.me.`
- `TXT @` $\rightarrow$ `v=spf1 mx include:spf.brevo.com ~all`
- `CNAME brevo1._domainkey` $\rightarrow$ `b1.roadtotech-me.dkim.brevo.com`
- `CNAME brevo2._domainkey` $\rightarrow$ `b2.roadtotech-me.dkim.brevo.com`
- `TXT _dmarc` $\rightarrow$ `v=DMARC1; p=none; rua=mailto:rua@dmarc.brevo.com`
- *Dynu Quota Optimization*: Bypassed Dynu's 4-CNAME free tier limitation by omitting optional marketing tracking subdomains (`send`, `r.send`), keeping all authentication records intact.
### E. Webmail Client (SnappyMail) Deployment
- Deployed **SnappyMail** (`v2.38.2`) as a lightweight (~30MB RAM) companion in `Core/docker-compose.yml` exposed at `https://webmail.roadtotech.me`.
- Pre-configured `roadtotech.me.json` domain profile to communicate internally with `stalwart:993` (IMAP) and `stalwart:465` (SMTP).
- Added service tiles for both **Stalwart Mail** and **Webmail** to the Homepage dashboard at `https://dashboard.roadtotech.me`.
---
## 3. Verification & Live Testing Results
1. **Inbound Email**:
- Sent test email from external Gmail account (`fcortesbio@gmail.com`) to `kiskaadee@roadtotech.me`.
- Router forwarded Port 25 $\rightarrow$ `192.168.1.36:25`.
- Stalwart accepted message, validated recipient, and delivered directly to local mailbox (`queueName = "local"`).
- Message appeared in SnappyMail inbox.
2. **Outbound Email**:
- Composed reply from `kiskaadee@roadtotech.me` in SnappyMail to `fcortesbio@gmail.com`.
- Stalwart routed message through `smtp-relay.brevo.com:587`.
- Arrived in Gmail primary inbox within minutes.
- Header inspection confirmed:
- `signed-by: roadtotech.me` (DKIM valid)
- `mailed-by: ha.d.sender-sib.com` (Brevo authenticated)
- `security: Standard encryption (TLS)`
- Zero spam flags.
---
## 4. Operational Runbook & Settings Reference
| Service / Interface | URL / Endpoint | Port(s) | Credentials / Auth |
| :--- | :--- | :--- | :--- |
| **Webmail** | `https://webmail.roadtotech.me` | 443 (HTTPS) | LLDAP Email (`kiskaadee@roadtotech.me`) + LLDAP Password |
| **Stalwart Admin** | `https://mail.roadtotech.me/account` | 443 (HTTPS) | Admin Account / Recovery Admin (`admin`) |
| **Inbound SMTP** | `mail.roadtotech.me` | 25 (TCP) | Unauthenticated / Opportunistic STARTTLS |
| **Client IMAP** | `mail.roadtotech.me` | 993 (TCP) | SSL/TLS, LLDAP credentials or App Password |
| **Client SMTP** | `mail.roadtotech.me` | 587 (TCP) | STARTTLS, LLDAP credentials or App Password |
| **Outbound Relay** | `smtp-relay.brevo.com` | 587 (TCP) | Authenticated Brevo SMTP Login & Key |
---
## 5. Next Steps & Future Enhancements
1. **Authelia Live Password Reset Integration**:
- Update [`Core/config/authelia/configuration.yml`](file:///home/kiskaadee/Homelab/Core/config/authelia/configuration.yml) to replace `notifier: filesystem` with `notifier: smtp` (`submission://stalwart:587`), enabling instant password reset emails for all LLDAP users.
2. **Gitea Mailer Configuration**:
- Configure `[mailer]` in Gitea (`Sites/homelab-gitea/`) to send commit, issue, and review notifications from `git@roadtotech.me`.
3. **Automated System Alerts**:
- Configure Diun (Docker image updates) and backup health scripts to dispatch summary digests to `admin@roadtotech.me`.
4. **Client Autoconfig (RFC 6186 / Mozilla ISPDB)**:
- Add standard DNS SRV records (`_imaps._tcp.roadtotech.me`, `_submission._tcp.roadtotech.me`) and Autoconfig XML endpoints for zero-touch Thunderbird and Apple Mail setup.