refactor(records): partition incident post-mortems into records/debug and unify daily journals
Brain Structural Validation / Validate Markdown Structure & Links (push) Successful in 6s

This commit is contained in:
kiskaadee committed 2026-09-23 13:46:28 -05:00
1 parent d9d68091d3
commit 30c7b29925
16 files changed
+251 -146

No files matched your search

@@ -429,7 +429,7 @@ python scripts/extract-terms.py --bench 2>/dev/null
### Phase 3 — Single Document Spot Check ### Phase 3 — Single Document Spot Check
```bash ```bash
python scripts/extract-terms.py records/journal/2026-09-18-gitea-github-mirror-dns-resolution-failure.md python scripts/extract-terms.py records/debug/2026-09-18-gitea-github-mirror-dns-resolution-failure.md
``` ```
Expected output should contain terms like: `docker`, `dns`, `resolv.conf`, `mirror`, `network-online.target`, `gitea` — not generic terms like `operations` or `homelab`. Expected output should contain terms like: `docker`, `dns`, `resolv.conf`, `mirror`, `network-online.target`, `gitea` — not generic terms like `operations` or `homelab`.
@@ -177,5 +177,5 @@ Gitea maintains an automated push mirror to GitHub (`github.com/kiskaadee/second
## 🏛️ Related References & Incident Post-Mortems ## 🏛️ Related References & Incident Post-Mortems
* [GitOps Dispatcher Webhook Signature Mismatch: Epistemic Root Cause Analysis](../../../records/journal/2026-09-21-gitops-webhook-payload-signature-mismatch.md) — Detailed investigation into `adnanh/webhook` payload serialization divergence and HMAC signature verification. * [GitOps Dispatcher Webhook Signature Mismatch: Epistemic Root Cause Analysis](../../../records/debug/2026-09-21-gitops-webhook-payload-signature-mismatch.md) — Detailed investigation into `adnanh/webhook` payload serialization divergence and HMAC signature verification.
@@ -1,5 +1,5 @@
--- ---
type: journal type: debug
project: homelab project: homelab
date: 2026-09-14 date: 2026-09-14
tags: tags:
@@ -1,5 +1,5 @@
--- ---
type: journal type: debug
project: homelab project: homelab
date: 2026-09-18 date: 2026-09-18
tags: tags:
@@ -1,5 +1,5 @@
--- ---
type: journal type: debug
project: homelab project: homelab
date: 2026-09-18 date: 2026-09-18
tags: tags:
@@ -1,5 +1,5 @@
--- ---
type: journal type: debug
project: homelab project: homelab
date: 2026-09-21 date: 2026-09-21
tags: tags:
@@ -1,5 +1,5 @@
--- ---
type: journal type: debug
project: homelab project: homelab
date: 2026-09-21 date: 2026-09-21
tags: tags:
@@ -47,24 +47,29 @@ During routine operations, pushes to the `second-brain` repository on Gitea fail
### Raw Observations (Machine Outputs) ### Raw Observations (Machine Outputs)
1. **Working Tree State**: Inspecting `~/Brain` on `server` revealed the working tree was not updating automatically: 1. **Working Tree State**: Inspecting `~/Brain` on `server` revealed the working tree was not updating automatically:
```text
On branch main ```log
Your branch is behind 'origin/main' by 4 commits, and can be fast-forwarded. On branch main
(use "git pull" to update your local branch) Your branch is behind 'origin/main' by 4 commits, and can be fast-forwarded.
``` (use "git pull" to update your local branch)
```
2. **Initial Systemd Journal Trace**: Inspecting `homelab-gitops.service` logs revealed that the webhook daemon triggered the dispatcher script, but authentication failed closed: 2. **Initial Systemd Journal Trace**: Inspecting `homelab-gitops.service` logs revealed that the webhook daemon triggered the dispatcher script, but authentication failed closed:
```text
webhook[4494]: executing /home/kiskaadee/Core/scripts/gitops_dispatcher.py with arguments [..., "<json>", "", "push"] ```log
webhook[4494]: [ERROR] [GitOps] Authentication failed: Missing signature header. webhook[4494]: executing /home/kiskaadee/Core/scripts/gitops_dispatcher.py with arguments [..., "<json>", "", "push"]
webhook[4494]: [ERROR] [GitOps] Authentication failed: Missing signature header.
webhook[4494]: [ERROR] [GitOps] ❌ Webhook authentication failed. Rejecting request. webhook[4494]: [ERROR] [GitOps] ❌ Webhook authentication failed. Rejecting request.
webhook[4494]: [webhook] error occurred: exit status 1 webhook[4494]: [webhook] error occurred: exit status 1
``` ```
3. **Secondary Systemd Journal Trace (Post-Secret Configuration)**: After configuring the shared secret in Gitea repository settings and triggering a test delivery, the daemon received the signature header but failed cryptographic verification:
```text 3. **Secondary `systemd` Journal Trace (Post-Secret Configuration)**: After configuring the shared secret in Gitea repository settings and triggering a test delivery, the daemon received the signature header but failed cryptographic verification:
webhook[4494]: executing /home/kiskaadee/Core/scripts/gitops_dispatcher.py with arguments [..., "<json>", "c98657cbabeb6d7cf54f4868163d082d2dcb622a489f16c2549cc81549b26b83", "push"]
webhook[4494]: [ERROR] [GitOps] Authentication failed: Signature mismatch. ```log
webhook[4494]: [ERROR] [GitOps] ❌ Webhook authentication failed. Rejecting request. webhook[4494]: executing /home/kiskaadee/Core/scripts/gitops_dispatcher.py with arguments [..., "<json>", "c98657cbabeb6d7cf54f4868163d082d2dcb622a489f16c2549cc81549b26b83", "push"]
``` webhook[4494]: [ERROR] [GitOps] Authentication failed: Signature mismatch.
webhook[4494]: [ERROR] [GitOps] ❌ Webhook authentication failed. Rejecting request.
```
--- ---
@@ -1,5 +1,5 @@
--- ---
type: journal type: debug
project: homelab project: homelab
date: 2026-09-22 date: 2026-09-22
tags: tags:
@@ -1,7 +1,7 @@
--- ---
type: journal type: journal
project: homelab
date: 2026-09-11 date: 2026-09-11
project: homelab
tags: tags:
- architecture - architecture
- operations - operations
@@ -11,14 +11,14 @@ tags:
- cutover - cutover
--- ---
# homelab-core NixOS Appliance Merged & Documentation Audit Complete # Daily Journal: 2026-09-11
## Overview ## Wins
### Homelab Appliance Cutover & Documentation Audit
The transformation of `homelab-core` into a turnkey, standalone declarative NixOS appliance is fully complete, validated, merged into `main`, and deployed. All documentation drift across both `homelab-core` and `Config` repositories has been resolved. The transformation of `homelab-core` into a turnkey, standalone declarative NixOS appliance is fully complete, validated, merged into `main`, and deployed. All documentation drift across both `homelab-core` and `Config` repositories has been resolved.
## Summary of Completed Actions #### 1. `homelab-core` Repository
### 1. `homelab-core` Repository
- **Merged `feat/nixos-appliance` into `main`** (Fast-forward, pushed to `origin/main`). - **Merged `feat/nixos-appliance` into `main`** (Fast-forward, pushed to `origin/main`).
- **NixOS Appliance Layer**: - **NixOS Appliance Layer**:
- `flake.nix`: 2-input flake (`nixpkgs` channel tarball + `sops-nix`). - `flake.nix`: 2-input flake (`nixpkgs` channel tarball + `sops-nix`).
@@ -35,7 +35,7 @@ The transformation of `homelab-core` into a turnkey, standalone declarative NixO
- `SECURITY.md`: Removed legacy Arch Linux / `pacman -Syu` references; documented NixOS SSH and declarative immutability guidelines. - `SECURITY.md`: Removed legacy Arch Linux / `pacman -Syu` references; documented NixOS SSH and declarative immutability guidelines.
- `AGENTS.md`: Updated secrets location invariant to `nixos/secrets.yaml`. - `AGENTS.md`: Updated secrets location invariant to `nixos/secrets.yaml`.
### 2. `Config` Repository #### 2. `Config` Repository
- **Documentation Streamlining**: - **Documentation Streamlining**:
- `README.md`: Replaced verbose Dynu flowchart and implementation details with a concise feature highlight linking to `docs/dynu-ip-monitor.md`. Updated `record.sh` description to reflect Niri sessions (removed legacy Hyprland reference). - `README.md`: Replaced verbose Dynu flowchart and implementation details with a concise feature highlight linking to `docs/dynu-ip-monitor.md`. Updated `record.sh` description to reflect Niri sessions (removed legacy Hyprland reference).
- `docs/system-maintenance.md`: Fixed remaining `.desktop` build and rebuild commands, replacing them with `.laptop`. - `docs/system-maintenance.md`: Fixed remaining `.desktop` build and rebuild commands, replacing them with `.laptop`.
@@ -43,5 +43,5 @@ The transformation of `homelab-core` into a turnkey, standalone declarative NixO
- `nix flake check` passed cleanly. - `nix flake check` passed cleanly.
- Both `server` and `laptop` configurations evaluate without errors. - Both `server` and `laptop` configurations evaluate without errors.
## Next Phase (Phase 5) ## Next Objectives
Once the server running generation has been verified over an extended period, the legacy `hosts/server/` folder and server configurations can be formally deprecated and purged from the `Config` repository. - Once the server running generation has been verified over an extended period, formally deprecate and purge the legacy `hosts/server/` folder and server configurations from the `Config` repository (Phase 5).
@@ -10,14 +10,14 @@ tags:
- gitops - gitops
--- ---
# Homelab Core — Milestone P0: GitOps Trust Boundary Implementation # Daily Journal: 2026-09-13
**Plan Reference:** [`projects/homelab/plans/architecture-consolidation-implementation-guide.md`](../../projects/homelab/plans/architecture-consolidation-implementation-guide.md) ## Wins
**Status:** Completed & Proven (All P0 Deliverables 1.1–1.5 achieved)
--- ### Homelab Core — Milestone P0: GitOps Trust Boundary Implementation
Completed and validated all deliverables (1.1–1.5 and 3.1–3.6) for Milestone P0 of the [Architecture Consolidation Plan](../../projects/homelab/plans/architecture-consolidation-implementation-guide.md).
## 🏛️ Completed Deliverables & Commit Chain #### Completed Deliverables & Commit Chain
1. **Deliverable 1.1 — Remove Arbitrary `custom` Execution** 1. **Deliverable 1.1 — Remove Arbitrary `custom` Execution**
- **Commit:** `29dd186` `refactor(gitops): remove arbitrary custom execution` - **Commit:** `29dd186` `refactor(gitops): remove arbitrary custom execution`
@@ -50,10 +50,7 @@ tags:
- **Commit:** `534ea9e` `docs: sync repository documentation with GitOps hardening and automated test invariants` - **Commit:** `534ea9e` `docs: sync repository documentation with GitOps hardening and automated test invariants`
- **Actions:** Synchronized `README.md` and `SECURITY.md` with the hardened GitOps architecture, automated test runner instructions, Docker socket isolation guarantees, and declarative NixOS SOPS checklist. - **Actions:** Synchronized `README.md` and `SECURITY.md` with the hardened GitOps architecture, automated test runner instructions, Docker socket isolation guarantees, and declarative NixOS SOPS checklist.
--- #### Verification & Invariant Proofs
## 🧪 Verification & Invariant Proofs
- **Pytest Suite**: 31 passing tests in 0.09s (`tests/security/`, `tests/structural/`). - **Pytest Suite**: 31 passing tests in 0.09s (`tests/security/`, `tests/structural/`).
- **One-Command Test Runner**: `./scripts/test` (linting + unit tests + Nix flake check). - **One-Command Test Runner**: `./scripts/test` (linting + unit tests + Nix flake check).
- **Ruff Code Health**: Zero lint or formatting warnings across the entire repository. - **Ruff Code Health**: Zero lint or formatting warnings across the entire repository.
@@ -8,19 +8,18 @@ tags:
- operations - operations
- homelab - homelab
- gitops - gitops
- troubleshooting
--- ---
# Homelab Core — Milestone P0: Final Closure and P1 Transition # Daily Journal: 2026-09-14
**Plan Reference:** [`projects/homelab/plans/architecture-consolidation-implementation-guide.md`](../../projects/homelab/plans/architecture-consolidation-implementation-guide.md) ## Wins
**Status:** 🔒 100% SEALED & FROZEN (All P0 Deliverables 1.1–1.5 fully hardened and closed)
**Latest Commits:** `f8cbe08` & `4c9e7a4`
--- ### Homelab Core — Milestone P0: Final Closure and P1 Transition
Achieved 100% frozen closure for Milestone P0 (GitOps Trust Boundary) in the [Architecture Consolidation Plan](../../projects/homelab/plans/architecture-consolidation-implementation-guide.md).
## 🛡️ Resolution of Reviewer Feedback & Final P0 Hardening #### Resolution of Reviewer Feedback & Final P0 Hardening
Following architectural review of Milestone P0, two execution-path considerations were addressed:
Following architectural review of Milestone P0 (GitOps Trust Boundary), two execution-path considerations were addressed:
1. **Temporal Boundary: Revision-Consistent Manifest Validation** 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. - **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.
@@ -33,20 +32,14 @@ Following architectural review of Milestone P0 (GitOps Trust Boundary), two exec
3. **HMAC Signature Specification** 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. - **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
## 🧪 Test Suite & Invariant Status
- **Automated Tests:** 35 passing tests (expanded from 31 to 35). - **Automated Tests:** 35 passing tests (expanded from 31 to 35).
- **Tooling Verification:** - **Tooling Verification:**
- `./scripts/test` passes cleanly (Ruff linting + Pytest suite + Pure Nix sandbox check). - `./scripts/test` passes cleanly (Ruff linting + Pytest suite + Pure Nix sandbox check).
- `nix flake check` passes without warnings or failures. - `nix flake check` passes without warnings or failures.
- Gitea Actions CI workflow configured for automated PR/push enforcement. - Gitea Actions CI workflow configured for automated PR/push enforcement.
--- #### P0 Commit Summary
## 📋 P0 Commit Summary
- `29dd186` `refactor(gitops): remove arbitrary custom execution` - `29dd186` `refactor(gitops): remove arbitrary custom execution`
- `01acdb4` `feat(gitops): add trusted repository resolution` - `01acdb4` `feat(gitops): add trusted repository resolution`
- `fa8054a` `feat(gitops): add webhook authentication` - `fa8054a` `feat(gitops): add webhook authentication`
@@ -61,9 +54,15 @@ Following architectural review of Milestone P0 (GitOps Trust Boundary), two exec
--- ---
## 🎯 Next Milestone: P1 Manifest Contract v1 ## Incidents & Debugging
With Milestone P0 sealed, work transitions to Milestone P1: - [Server Unexpected Shutdown: Epistemic Root Cause Analysis](../debug/2026-09-14-server-unexpected-shutdown-rca.md)
- **Deliverable 2.1:** Repository identity authority & strict alias collision rejection (centralized registry vs self-derived names). - **Issue**: Appliance unexpectedly shut down with loss of service availability.
- **Deliverable 2.2–2.5:** Author `docs/architecture/manifest-specification.md` and JSON schema v1 for `app.yaml`. - **Investigation**: Inspected persistent systemd journal traces across boots (`journalctl -b -1`), analyzed system thermals, evaluated ACPI events, and isolated hardware power loss vs clean software shutdown.
- **Phase 4:** Dedicated `gitops` system user and systemd confinement. - **Outcome**: Established failure profile and created durable operational diagnostics runbook in [`server-unexpected-shutdown-diagnosis.md`](../../projects/homelab/guides/server-unexpected-shutdown-diagnosis.md).
---
## Next Objectives
- Transition to Milestone P1: Manifest Contract v1 (Deliverable 2.1 registry, Deliverables 2.2–2.5 JSON schema specification).
- Phase 4: Dedicated `gitops` system user and systemd confinement.
@@ -17,11 +17,13 @@ tags:
- deliverability - deliverability
--- ---
# Complete Self-Hosted Email Infrastructure & Webmail Deployment (Stalwart, LLDAP, Brevo, SnappyMail) # Daily Journal: 2026-09-15
## 1. Executive Summary ## Wins
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). ### Self-Hosted Email Infrastructure & Webmail Deployment (Stalwart, LLDAP, Brevo, SnappyMail)
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. 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.
@@ -59,16 +61,16 @@ flowchart TD
--- ---
## 2. Key Accomplishments & Technical Milestones #### 1. Key Accomplishments & Technical Milestones
### A. Authelia Session Extension ##### A. Authelia Session Extension
- Extended Authelia session and JWT timeouts in `Core/config/authelia/configuration.yml`: - Extended Authelia session and JWT timeouts in `Core/config/authelia/configuration.yml`:
- `expiration: 7d` (7 days maximum session lifetime). - `expiration: 7d` (7 days maximum session lifetime).
- `inactivity: 3d` (3 days idle timeout). - `inactivity: 3d` (3 days idle timeout).
- `remember_me: 1M` (1 month persistent cookie). - `remember_me: 1M` (1 month persistent cookie).
- Live cookie header verified: `authelia_session=...; expires=Tue, 22 Sep 2026`. - Live cookie header verified: `authelia_session=...; expires=Tue, 22 Sep 2026`.
### B. Stalwart Mail Server Core Infrastructure ##### B. Stalwart Mail Server Core Infrastructure
- Deployed **Stalwart Mail Server** (`stalwartlabs/stalwart:v0.16.22`) to `Core/docker-compose.yml` on `proxy-net`. - Deployed **Stalwart Mail Server** (`stalwartlabs/stalwart:v0.16.22`) to `Core/docker-compose.yml` on `proxy-net`.
- **Port Bindings**: - **Port Bindings**:
- `25:25`: Standard Inbound SMTP from external MTAs. - `25:25`: Standard Inbound SMTP from external MTAs.
@@ -81,14 +83,14 @@ flowchart TD
- Configured RocksDB database under `/var/lib/stalwart` mapped to local host directory `./config/stalwart/data`. - 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` to ensure permanent directory permissions (`0777`) across machine reboots, rebuilds, or fresh disaster recoveries. - Declared `systemd.tmpfiles.rules` in `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 ##### C. LLDAP Directory Integration & JIT Provisioning
- Integrated Stalwart with the internal LLDAP instance (`ldap://lldap:3890`): - Integrated Stalwart with the internal LLDAP instance (`ldap://lldap:3890`):
- **Base DN**: `dc=roadtotech,dc=me`. - **Base DN**: `dc=roadtotech,dc=me`.
- **Bind Authentication**: Enabled (`bindAuthentication = true`), avoiding cleartext password exposure. - **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`. - **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. - **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) ##### 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. - **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: - **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. - Secrets encrypted via SOPS in `nixos/secrets.yaml` (`brevo/smtp_login` and `brevo/smtp_key`) and injected into runtime environment templates.
@@ -102,14 +104,14 @@ flowchart TD
- `TXT _dmarc` $\rightarrow$ `v=DMARC1; p=none; rua=mailto:rua@dmarc.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. - *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 ##### 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`. - 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). - 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`. - Added service tiles for both **Stalwart Mail** and **Webmail** to the Homepage dashboard at `https://dashboard.roadtotech.me`.
--- ---
## 3. Verification & Live Testing Results #### 2. Verification & Live Testing Results
1. **Inbound Email**: 1. **Inbound Email**:
- Sent test email from external Gmail account (`fcortesbio@gmail.com`) to `kiskaadee@roadtotech.me`. - Sent test email from external Gmail account (`fcortesbio@gmail.com`) to `kiskaadee@roadtotech.me`.
@@ -128,7 +130,7 @@ flowchart TD
--- ---
## 4. Operational Runbook & Settings Reference #### 3. Operational Settings Reference
| Service / Interface | URL / Endpoint | Port(s) | Credentials / Auth | | Service / Interface | URL / Endpoint | Port(s) | Credentials / Auth |
| :--- | :--- | :--- | :--- | | :--- | :--- | :--- | :--- |
@@ -141,7 +143,7 @@ flowchart TD
--- ---
## 5. Next Steps & Future Enhancements ## Next Objectives
1. **Authelia Live Password Reset Integration**: 1. **Authelia Live Password Reset Integration**:
- Update `Core/config/authelia/configuration.yml` to replace `notifier: filesystem` with `notifier: smtp` (`submission://stalwart:587`), enabling instant password reset emails for all LLDAP users. - Update `Core/config/authelia/configuration.yml` to replace `notifier: filesystem` with `notifier: smtp` (`submission://stalwart:587`), enabling instant password reset emails for all LLDAP users.
+47
View File
@@ -0,0 +1,47 @@
---
type: journal
project: homelab
date: 2026-09-18
tags:
- operations
- homelab
- troubleshooting
- gitea
- nix
- ci-cd
- dns
- docker
---
# Daily Journal: 2026-09-18
## Wins
### CI/CD Standardization & Git Mirror Resilience
Hardened the local developer platform and forge infrastructure across `homelab-core` and Gitea:
- Eliminated dynamic CI toolchain initialization delays, reducing pipeline validation runtime from >5 minute hangs to 16 seconds.
- Restored continuous outbound Git mirroring between self-hosted Gitea repositories and GitHub upstreams.
---
## Incidents & Debugging
- [Remediation: Gitea Actions CI Build Hang on Nix Installation](../debug/2026-09-18-gitea-actions-nix-runner-fix.md)
- **Issue**: The `validate` workflow job in `homelab-core` hung indefinitely (>5 minutes) at the `Install Nix` step, blocking all pull requests and pushes.
- **Root Cause**: `DeterminateSystems/nix-installer-action` attempted multi-user installation requiring systemd sockets absent in Gitea's `act_runner` container, while targeting GitHub API endpoints instead of Gitea.
- **Remediation**: Switched the workflow job container to `nixos/nix:latest`, configured `safe.directory`, and verified execution dropped to 16 seconds.
- [Incident RCA: Gitea GitHub Mirror Push Failure & Docker DNS Forwarder Resolution](../debug/2026-09-18-gitea-github-mirror-dns-resolution-failure.md)
- **Issue**: Gitea push mirrors failed with `fatal: unable to access 'https://github.com/...': Could not resolve host: github.com`.
- **Root Cause**: The embedded Docker DNS resolver (`127.0.0.11`) inside the container lost synchronization with host upstream nameservers following network reconfiguration, returning `SERVFAIL`.
- **Remediation**: Restored container network forwarding and verified successful push synchronization across all repositories.
---
## Mistakes and Lessons Learned
### Pre-Baked CI Images vs Dynamic In-Job Installers
Dynamic package and toolchain installers in containerized runners introduce unpredictable runtime dependencies on host PID 1/systemd state. Declaring explicit pre-baked container images (`container: { image: ... }`) eliminates external install flakiness and speeds up pipeline turnaround drastically.
### Container Safe Directory UID Mappings
When container runners mount workspace volumes across differing user IDs, Git strictly rejects repository operations unless `git config --global --add safe.directory "$GITHUB_WORKSPACE"` is declared prior to running flake or git commands.
@@ -1,72 +0,0 @@
---
type: journal
project: homelab
date: 2026-09-21
tags:
- homelab
- orchestration
- appctl
- python
- architecture
- testing
- pytest
---
# Architecture & TDD: appctl Engine V2 Domain Modeling and Test Suite Scaffold
## Summary & Objectives
Initiated a comprehensive architectural rework of [`scripts/appctl_engine.py`](file:///home/kiskaadee/Projects/active/appctl-refactor/scripts/appctl_engine.py) to elevate the homelab control utility into clean, type-safe engineering code (`appctl_engine_v2.py`). Development is conducted in an isolated Git worktree at `~/Projects/active/appctl-refactor`.
---
## Key Architectural Decisions & Progress
### 1. Standardized YAML Parsing & Custom Exception Handling
- **Replaced Custom Parser**: Deprecated the hand-rolled `parse_yaml_simple()` in favor of standard `yaml.safe_load()` using PyYAML.
- **Explicit Failure Boundary**: Defined `class ManifestError(Exception): pass` to cleanly catch and isolate malformed YAML syntax without crashing the whole application inventory.
### 2. Explicit Domain Model Hierarchy
- **Base Domain Model**: Established `@dataclass class App` representing common operational primitives:
```python
name: str
description: str
domain: str
dir_path: str
has_compose: bool
```
- **Layer-Specific Models**:
- `SitesApp(App)`: Represents dynamic `~/Sites/*` workloads with `app.yaml` metadata (`aliases`, `visible`, `auth`, `networks`, `env`, `homepage`, `manifest_error`).
- `CoreService(App)`: Represents Core platform services (`container`, `weight`, `icon`).
- `HomepageConfig`: Strongly-typed representation for dashboard cards.
### 3. Pure Normalization Boundary
- Extracted `sites_app_from_manifest(app_dir, manifest, manifest_error) -> SitesApp` as a pure normalization seam.
- Separates filesystem discovery from domain instantiation, enabling unit tests to verify manifest coercion without disk I/O.
### 4. Domain-Agnostic Infrastructure & Strict Validation
- Decoupled hardcoded personal domains by parameterizing `HOMELAB_DOMAIN = os.environ.get("HOMELAB_DOMAIN") or os.environ.get("DOMAIN", "")`.
- Added `validate_environment()` to fail fast if mandatory environment variables or Core directories are missing.
### 5. TDD Test Suite Scaffold
- Created `tests/unit/test_appctl_engine_v2.py` with custom Pytest fixtures:
- `mock_sites_dir` & `mock_core_dir`: Isolated temporary directories with automatic `monkeypatch` teardown.
- `AppFactory`: Object Mother/Factory class to generate test app directories with `app.yaml` and Compose manifests in one line.
- Verified passing tests for resolution hierarchy, manifest overrides, and type normalization.
- Established failing (Red) acceptance criteria for upcoming Docker inspection and Homepage YAML compilation.
---
## Key Lessons & Technical Insights
- **Nix `buildInputs` Function Call Syntax**: Calling `python3.withPackages` inside Nix lists `[ ... ]` requires outer parentheses `(python3.withPackages (ps: [ ... ]))`, otherwise Nix evaluates the function and lambda as two separate invalid list elements.
- **Python `str(None)` Truthiness Trap**: Calling `str(manifest.get("key")) or "fallback"` returns `"None"` (a truthy string) when the key is missing, completely breaking fallback evaluation. Safe normalization requires checking `manifest.get("key") is not None` before string casting.
- **Pytest Name-Based Dependency Injection**: Pytest inspects parameter names via reflection to inject fixtures. Factory helpers benefit from real helper classes (`AppFactory`) for native LSP autocompletion without separate `Protocol` stubs.
---
## Next Steps
1. Port and implement the inspection layer in `scripts/appctl_engine_v2.py`:
- `get_docker_status(dir_path, container_name)`
- `get_git_sync_status(dir_path)` & `get_git_diagnostics(dir_path)`
- `check_ssl_cert(domain)` & `check_all_ssl_certs(domains)`
2. Port CLI command handlers (`cmd_sync_homepage`, `cmd_list`, `cmd_info`, `cmd_ssl`, `cmd_resolve`, `cmd_complete`).
3. Turn remaining unit tests green and swap V2 into production [`scripts/appctl_engine.py`](file:///home/kiskaadee/Homelab/Core/scripts/appctl_engine.py).
+85
View File
@@ -0,0 +1,85 @@
---
type: journal
project: homelab
date: 2026-09-21
tags:
- homelab
- orchestration
- appctl
- python
- architecture
- testing
- pytest
- gitops
- webhook
- cryptography
---
# Daily Journal: 2026-09-21
## Wins
### Architecture & TDD: appctl Engine V2 Domain Modeling and Test Suite Scaffold
Initiated a comprehensive architectural rework of `scripts/appctl_engine.py` to elevate the homelab control utility into clean, type-safe engineering code (`appctl_engine_v2.py`). Development is conducted in an isolated Git worktree at `~/Projects/active/appctl-refactor`.
#### Key Architectural Decisions & Progress
1. **Standardized YAML Parsing & Custom Exception Handling**
- **Replaced Custom Parser**: Deprecated the hand-rolled `parse_yaml_simple()` in favor of standard `yaml.safe_load()` using PyYAML.
- **Explicit Failure Boundary**: Defined `class ManifestError(Exception): pass` to cleanly catch and isolate malformed YAML syntax without crashing the whole application inventory.
2. **Explicit Domain Model Hierarchy**
- **Base Domain Model**: Established `@dataclass class App` representing common operational primitives (`name`, `description`, `domain`, `dir_path`, `has_compose`).
- **Layer-Specific Models**:
- `SitesApp(App)`: Represents dynamic `~/Sites/*` workloads with `app.yaml` metadata (`aliases`, `visible`, `auth`, `networks`, `env`, `homepage`, `manifest_error`).
- `CoreService(App)`: Represents Core platform services (`container`, `weight`, `icon`).
- `HomepageConfig`: Strongly-typed representation for dashboard cards.
3. **Pure Normalization Boundary**
- Extracted `sites_app_from_manifest(app_dir, manifest, manifest_error) -> SitesApp` as a pure normalization seam.
- Separates filesystem discovery from domain instantiation, enabling unit tests to verify manifest coercion without disk I/O.
4. **Domain-Agnostic Infrastructure & Strict Validation**
- Decoupled hardcoded personal domains by parameterizing `HOMELAB_DOMAIN = os.environ.get("HOMELAB_DOMAIN") or os.environ.get("DOMAIN", "")`.
- Added `validate_environment()` to fail fast if mandatory environment variables or Core directories are missing.
5. **TDD Test Suite Scaffold**
- Created `tests/unit/test_appctl_engine_v2.py` with custom Pytest fixtures:
- `mock_sites_dir` & `mock_core_dir`: Isolated temporary directories with automatic `monkeypatch` teardown.
- `AppFactory`: Object Mother/Factory class to generate test app directories with `app.yaml` and Compose manifests in one line.
- Verified passing tests for resolution hierarchy, manifest overrides, and type normalization.
- Established failing (Red) acceptance criteria for upcoming Docker inspection and Homepage YAML compilation.
---
## Incidents & Debugging
- [Remediation: Gitea Actions CI Runner Container Initialization Failure (Missing /bin/sleep)](../debug/2026-09-21-gitea-actions-fhs-nix-container-fix.md)
- **Issue**: Gitea Actions runner failed at job initialization with `exec: "/bin/sleep": stat /bin/sleep: no such file or directory`.
- **Root Cause**: Minimal `nixos/nix` container image lacks the Linux Filesystem Hierarchy Standard (FHS) paths expected by `act_runner` at container entrypoint initialization.
- **Remediation**: Transitioned CI base image to `nixery.dev/shell/coreutils/git/nix/nodejs:latest`, restoring standard `/bin` utilities while preserving declarative Nix tooling.
- [GitOps Dispatcher Webhook Signature Mismatch: Epistemic Root Cause Analysis](../debug/2026-09-21-gitops-webhook-payload-signature-mismatch.md)
- **Issue**: Automated GitOps dispatcher rejected repository push deliveries with `Authentication failed: Signature mismatch`.
- **Root Cause**: Payload serialization divergence in `adnanh/webhook` parameter extraction combined with secret synchronization mismatch between Gitea webhook settings and the server's SOPS age secret.
- **Remediation**: Corrected raw payload extraction, synchronized SOPS secrets, and implemented constant-time HMAC-SHA256 signature verification in `gitops_dispatcher.py`.
---
## Mistakes and Lessons Learned
### Python `str(None)` Truthiness Trap
Calling `str(manifest.get("key")) or "fallback"` returns `"None"` (a truthy string) when the key is missing, completely breaking fallback evaluation. Safe normalization requires checking `manifest.get("key") is not None` before string casting.
### Nix Function Call Syntax in Lists
Calling `python3.withPackages` inside Nix lists `[ ... ]` requires outer parentheses `(python3.withPackages (ps: [ ... ]))`, otherwise Nix evaluates the function and lambda as two separate invalid list elements.
### FHS Invariant for Gitea `act_runner`
`act_runner` assumes a standard FHS environment (like `/bin/sleep` and `/bin/sh`) for container setup scripts. Bare Nix store container images must be supplemented with core utilities to satisfy runner bootstrap requirements.
---
## Next Objectives
1. Implement inspection layer in `scripts/appctl_engine_v2.py` (Docker status, Git sync status, SSL checks).
2. Port CLI command handlers (`cmd_sync_homepage`, `cmd_list`, `cmd_info`, `cmd_ssl`).
3. Turn remaining unit tests green and swap V2 into production `Core/scripts/appctl_engine.py`.
+42
View File
@@ -0,0 +1,42 @@
---
type: journal
project: homelab
date: 2026-09-22
tags:
- operations
- homelab
- troubleshooting
- diun
- docker
- stalwart
- smtp
- socket-proxy
---
# Daily Journal: 2026-09-22
## Wins
### Autonomous Container Image Update Alerting
Completed integration of Diun (Docker Image Update Notifier) within Homelab Core:
- Isolated container inspection through `socket-proxy`, maintaining strict read-only access without exposing the raw `/var/run/docker.sock`.
- Integrated automated email alerts to `admin@roadtotech.me` routed directly via Stalwart mail server.
---
## Incidents & Debugging
- [Incident RCA & System Integration: Diun Docker Provider Connectivity & Stalwart Mail Notification](../debug/2026-09-22-diun-socket-proxy-integration-and-stalwart-alerting.md)
- **Issue**: Diun failed with `Cannot connect to the Docker daemon at tcp://socket-proxy:2375` at startup and reported `WRN No image found` with `WRN No notifier available`.
- **Root Cause**: `diun` was not attached to the `socket-net` network bridge preventing DNS resolution to `socket-proxy:2375`, default watch policies excluded stopped or untagged containers, and SMTP alert notifications were undeclared.
- **Remediation**: Joined Diun to `socket-net` and `proxy-net`, declared container watch policies, and configured internal SMTP notifications against Stalwart on port 25.
---
## Mistakes and Lessons Learned
### Network Bridge Attachments for Daemon Proxies
When using intermediate security proxies like `socket-proxy` to isolate the Docker daemon, consumer services must explicitly attach to the dedicated socket network bridge (`socket-net`), otherwise name resolution fails closed before API negotiation starts.
### Non-Authenticated Internal SMTP Deliverability
Direct delivery from internal platform services to local mailboxes on the same domain (`kiskaadee@roadtotech.me`) does not require SASL authentication when routing within internal Docker bridges, provided the mail server treats the local subnet as trusted for local-recipient delivery.