docs(architecture): realign repository documentation with control-plane baseline and roadmap v5

- Update root README.md with Appctl Core's identity, control-plane mental model, and explicit contrast between current implementation baseline and target architecture.
- Add root ROADMAP.md as repository-facing projection of Roadmap v5 (milestones P0–P7).
- Add docs/decisions/README.md as lightweight navigation index for governing ADRs.
- Add contextual implementation scope notes to docs/architecture.md and docs/appctl.md.
This commit is contained in:
kiskaadee committed 2026-10-08 00:03:56 -05:00
1 parent 2297cd5cba
commit 7ae03f2176
5 files changed
+321 -44

No files matched your search

+112 -43
View File
@@ -1,41 +1,104 @@
# 🌐 Homelab Core — Appliance & Platform Reference
# 🏛️ Homelab Core & Appctl Operational Control Plane
**Homelab Core** is the declarative NixOS appliance and platform foundation for the `roadtotech.me` homelab cluster.
**Homelab Core** defines the host foundation, platform infrastructure services, security boundaries, and operational control plane for the `roadtotech.me` homelab appliance.
It provides host operating system configuration, edge routing, automated wildcard TLS certificate issuance, identity and access management, mail transport, container socket isolation, workload orchestration, and continuous GitOps deployment.
This repository serves two primary roles:
1. **The Host Platform & Infrastructure Appliance**: Declarative NixOS operating system definitions, edge ingress routing, wildcard TLS certificates, identity/SSO directory services, mail routing, and Docker socket isolation.
2. **The Appctl Operational Control Plane**: The centralized engine governing workload lifecycle management, continuous GitOps deployment, source provenance tracking, and dashboard synchronization across independent application workloads in `~/Sites`.
---
## 🏛️ System Architecture & Boundaries
## 🧭 Architectural Direction & Mental Model
The homelab ecosystem separates **ownership**, **runtime architecture**, and **cross-cutting orchestration**:
Under the approved architectural baseline ([`ADR: Homelab Operational Control Plane`](docs/decisions/README.md#homelab-operational-control-plane--deployment-model-architecture) and [`ADR: 3-Tier Architecture & Provenance`](docs/decisions/README.md#homelab-3-tier-architecture--deployment-provenance-model)), `appctl` is evolving from a local procedural CLI wrapper into the **authoritative operational control plane service for Homelab Core**.
### 1. Ownership: Core vs. Sites
* **Core (`~/Core`) owns platform mechanics**: System services, host firewall, edge ingress, security barriers, deployment serialization, and secret distribution.
* **Workload Plane (`~/Sites`) owns application intent**: Workloads are self-describing via `app.yaml` and independent `docker-compose.yml` configurations. Workloads declare application intent; Core executes deployment.
### 2. Runtime Architecture
The system operates across four runtime layers:
1. **Host Foundation**: Headless NixOS Linux, disk configuration, Docker daemon, systemd daemons, firewall rules, and in-memory secret files under `/run/secrets/`.
2. **Edge Gateway**: Traefik (v3.6) reverse proxy terminating wildcard TLS (`*.roadtotech.me`) via Dynu DNS-01 Let's Encrypt validation.
3. **Core Platform Services**: Central services in `docker-compose.yml` (Authelia SSO, LLDAP directory, Stalwart mail, SnappyMail, Homepage dashboard, Dozzle, Watchtower, Diun, and socket-proxy).
4. **Workload Plane**: Independent application stacks in `~/Sites` connected to the platform over the `proxy-net` Docker network.
### 3. Cross-Cutting Orchestration
* **`appctl` CLI & Engine**: Coordinates discovery, environment injection, container lifecycle actions, and Homepage compilation across workloads and Core.
* **GitOps Webhook Dispatcher**: Listens on port 9000 (`homelab-gitops.service`), validating incoming Git push webhooks and executing declared deployment actions.
---
## 🗺️ System Topology & Network Architecture
### The Core Architectural Spine
```text
Human Operator / Automation
│
┌───────────────────┴───────────────────┐
│ │
Operations UI CLI (Local & Remote)
│ │
└───────────────────┬───────────────────┘
│
appctl Control Plane API
(One Logical API across Transports)
│
┌────────────┴────────────┐
│ │
Unix Socket HTTP Listener
(Host Clients) (Remote/LAN Clients)
│ │
└────────────┬────────────┘
│
┌───────────────────────────┼───────────────────────────┐
│ │ │
Authentication Deployment Model Operations
& Authorization Plane Execution
│ │ │
Token Validation & ┌──────┴──────┐ Docker Compose
LLDAP Directory RBAC │ │ Traefik Routing
AI Investigation Human Host Secrets
│ Approval Reconciliation
▼ │
DeploymentProposal │
│ ▼
└─────▶ DeploymentModel
│
▼ (Committed to Git)
Deployment Repository
(Git Truth)
│
▼ (appctl validates & materializes)
Deployment Definition
(Sites app.yaml + compose)
│
▼
Runtime Reconciliation
```
### Core Architectural Invariants
* **Single Operational Truth**: Exactly one implementation of every operational action (`deploy`, `restart`, `inspect`, `sync`, `validate`) exists in the platform. Clients (local CLI, remote CLI, web UI, GitOps) invoke the exact same logical API contract.
* **Host Access Does Not Confer Authority**: Entering the server via SSH is merely host access; it does not grant Appctl privileges. **Every mutating operation requires an explicit, authenticated user-scoped token**, regardless of transport. Unix socket peer credentials identify the transport context, not user authority.
* **Git is the Authoritative Source of Deployment State**: Approved workload configurations are versioned in Git. `appctl` reconciles desired Git state into running containers, preserving immutable revision history, commit provenance, peer reviews, and atomic rollbacks (`git revert`).
* **Five-Stage Model Lifecycle (Intent vs. Implementation)**:
$$\text{Repository} \xrightarrow{\text{Investigation}} \text{Application Profile} \xrightarrow{\text{Proposal}} \text{DeploymentProposal} \xrightarrow{\text{Human Selection}} \text{DeploymentModel (Git)} \xrightarrow{\text{appctl Materialize}} \text{Deployment Definition} \xrightarrow{\text{Reconcile}} \text{Containers}$$
* `DeploymentModel`: The operator-selected, implementation-agnostic representation of intent (ports, domains, volumes, dependencies, secret references). Free of Compose syntax and Traefik label boilerplate.
* `Deployment Definition`: Concrete platform descriptors (`app.yaml` + `docker-compose.yml`) materialized and enforced by `appctl`.
* **AI Authoring Boundary**: AI agents act strictly as upstream proposal generators with **zero execution or mutation authority**. The AI analyzes repositories and drafts `DeploymentProposals`. After human approval into a `DeploymentModel`, the AI is completely out of the loop.
* **Secret Reference Invariant**: Deployment definitions contain secret references (`secretKeyRef`), never secret material. References are resolved at runtime through a defined `SecretProvider` interface. Host platform secrets remain declarative in `sops-nix`.
* **Clean State Root**: Mutable application data lives strictly under `~/var/lib/homelab/<app>/`, isolated from Git deployment repositories.
---
## 🔍 Current Implementation Baseline vs. Target Architecture
To maintain clarity during development, this repository explicitly separates what is **currently implemented** from what is **planned in the roadmap**:
| Architectural Area | Current Implementation Baseline (Milestone P0) | Target Architecture (Roadmap v5) |
| :--- | :--- | :--- |
| **`appctl` Architecture** | Bash CLI wrapper (`scripts/appctl`) driving local subprocesses (`docker compose`, `git`) and metadata engines. | Dedicated daemon service (`homelab-appctl.service`) exposing one logical API over Unix socket and HTTP. |
| **Operational Auth** | Sudo / Unix user permissions on the host. Sourcing secrets from `/run/secrets/`. | LLDAP directory identity. Explicit user-scoped API tokens for all mutating actions; Authelia ForwardAuth for Web. |
| **Metadata Engine** | Strongly-typed dataclass engine (`scripts/appctl_engine_v2.py`) with source provenance and Docker label inspection, operating alongside legacy engine. | Single unified engine (`core_manifest.py` / `appctl_engine.py`) embedded directly within the control plane daemon. |
| **Deployment Model** | Manual authoring of `app.yaml` and `docker-compose.yml` directly in `~/Sites/<app>/`. | 5-stage lifecycle: AI/human `DeploymentProposal` $\to$ operator-approved `DeploymentModel` committed to Git $\to$ `appctl` materialization. |
| **GitOps Engine** | Webhook dispatcher (`scripts/gitops_dispatcher.py`) listening on port 9000 with HMAC-SHA256 authentication and flock serialization. | Fully integrated into control-plane admission, calling central reconciliation endpoints. |
| **Secret Distribution** | Static Age-encrypted `nixos/secrets.yaml` decrypted by `sops-nix` to tmpfs `/run/secrets/`. | Host secrets remain in `sops-nix`; workload secrets referenced by key and projected at runtime via `SecretProvider`. |
| **Dashboard** | `appctl sync` statically compiles `config/homepage/services.yaml`. | Homepage consumes read-only live status from `appctl`; dedicated Operations UI client for interactive management. |
---
## 🗺️ System Topology & Runtime Layers
```text
Internet
│
▼
┌───────────────────────────────┐
│ Traefik Edge Proxy (:443) │
│ Wildcard TLS (*.roadtotech.me│
│ Wildcard TLS (*.roadtotech.me)│
└───────┬───────────────┬───────┘
│ │
Public Traffic │ │ ForwardAuth Protected
@@ -71,8 +134,7 @@ The system operates across four runtime layers:
| **`socket-proxy`** | Internal (`socket-net:2375`) | Read-only Docker API gateway barrier | Internal Only |
| **`lldap`** | `users.roadtotech.me` | LDAP directory & user database | Authelia Guard |
| **`authelia`** | `auth.roadtotech.me` | Single Sign-On (SSO) & ForwardAuth middleware | Public (Bypass) |
| **`stalwart`** | `mail.roadtotech.me` | Mail Server (SMTP/IMAP/JMAP/Sieve) | Native / LLDAP |
| **`snappymail`** | `webmail.roadtotech.me` | Webmail client connected to Stalwart | Native / Stalwart |
| **`stalwart`** | `mail.roadtotech.me` | Mail Server (SMTP/IMAP/JMAP/Sieve) *(Moving to smtp in P1)* | Native / LLDAP |
| **`homepage`** | `dashboard.roadtotech.me` | Service portal & system dashboard | Authelia Guard |
| **`dozzle`** | `logs.roadtotech.me` | Container log viewer (via socket-proxy) | Authelia Guard |
| **`watchtower`** | Internal | Automated container image updater | Internal Only |
@@ -80,7 +142,7 @@ The system operates across four runtime layers:
---
## ⚡ Quick Start & Operator Workflows
## ⚡ Quick Start & Operator Workflows (Current Baseline)
### Host & System Operations
```bash
@@ -96,9 +158,9 @@ systemctl status dynu-monitor.service # Smart DDNS IP monitor
systemctl status dynu-monitor.timer # DDNS timer (every 30m)
```
### Workload Management (`appctl`)
### Workload Management (`appctl` CLI)
```bash
# List all application stacks with container health and Git tracking status
# List all application stacks with container health, Git tracking, and provenance status
appctl list
# Fetch upstream changes across all repos and inspect with SSL certificates
@@ -122,33 +184,40 @@ appctl sync
### Testing & Verification
```bash
# Run the repository test suite (linting + pytest + nix flake check)
# Run the complete test suite (Ruff linter + Pytest invariants + Nix flake check)
./scripts/test
# Run Nix sandbox flake evaluation and checks
# Run pure Nix flake evaluation and checks
nix flake check
```
---
## 📚 Repository Documentation Index
## 📚 Documentation Navigation & Ownership
| Document | Description |
| Document | Ownership & Epistemic Role |
| :--- | :--- |
| [**Architecture Guide**](docs/architecture.md) | Details system layers, component roles, network isolation, and security controls. |
| [**Operator Runbook**](docs/operations.md) | Day-to-day administration, updates, maintenance, troubleshooting, and recovery procedures. |
| [**Appctl Reference**](docs/appctl.md) | CLI command reference and consumed `app.yaml` manifest fields. |
| [**GitOps Engine**](docs/gitops.md) | Webhook admission pipeline, HMAC authentication, lock serialization, and execution boundaries. |
| [**Secrets & State**](docs/secrets-and-state.md) | SOPS encryption, runtime secret projections, user directory management, and persistent storage. |
| [**Setup & Provisioning**](docs/setup_guide.md) | Procedures for provisioning a server host and onboarding workloads. |
| [**Security Policy**](SECURITY.md) | Security controls, container isolation policies, and threat model. |
| [**`ROADMAP.md`**](ROADMAP.md) | **Implementation Trajectory**: Phased milestones (P0 through P7), active status, and deliverables based on Roadmap v5. |
| [**ADR Index**](docs/decisions/README.md) | **Architectural Decisions**: Navigation index to authoritative ADRs governing the control plane and 3-tier provenance. |
| [**Architecture Reference**](docs/architecture.md) | **Runtime Architecture**: Deep-dive into runtime layers, network segmentation, and component boundaries. |
| [**Appctl Reference**](docs/appctl.md) | **Current CLI Implementation**: Command syntax, arguments, resolution rules, and `app.yaml` fields consumed today. |
| [**GitOps Engine**](docs/gitops.md) | **Current CD Implementation**: Webhook admission pipeline, HMAC verification, and lock serialization. |
| [**Secrets & State**](docs/secrets-and-state.md) | **Current Runtime Secrets**: SOPS encryption, tmpfs projections, and persistent state roots. |
| [**Operator Runbook**](docs/operations.md) | **Operational Runbook**: Host maintenance, updates, garbage collection, and recovery procedures. |
| [**Setup & Provisioning**](docs/setup_guide.md) | **Host Provisioning**: Bare-metal NixOS installation and platform bootstrapping. |
| [**Agent Guidelines**](AGENTS.md) | **Agent Invariants**: Hard rules, trust boundaries, Core/Sites boundaries, and testing rules. |
| [**Security Policy**](SECURITY.md) | **Security Controls**: Docker socket isolation, threat models, and hardening checklists. |
---
## 🧠 Relationship to Brain Vault
## 🧠 Governance & Knowledge Architecture
* **Repository Documentation (`~/Core/docs/`)**: Describes *what exists* and *how to operate it*. It serves as the operational manual for the current repository.
* **Brain Vault (`~/Brain/projects/homelab/`)**: Captures *why it was built this way* — preserving architectural decision records (ADRs), historical trade-off discussions, active roadmaps, and deep debugging discoveries.
Durable architectural decisions, exploratory design trade-offs, and master execution roadmaps are governed in the operator's central knowledge vault under standard epistemic taxonomy:
* **Architectural Decisions**: Captured in MADR 4.0 format under `03-records/decisions/`.
* **Execution Roadmaps**: Phased engineering blueprints under `01-plans/`.
* **System Discussions**: Exploratory trade-off analyses under `02-discussions/`.
The repository documentation reflects the accepted architectural state and serves as the operational guide for the implementation.
---
+139
View File
@@ -0,0 +1,139 @@
# 🗺️ Homelab Core & Appctl Engineering Roadmap
This document serves as the repository-facing projection of the authoritative **Homelab Architecture Consolidation & Control Plane Roadmap (v5)**.
It describes the implementation trajectory and phased engineering milestones for transitioning Homelab Core into a unified platform driven by the `appctl` Operational Control Plane.
> **Authoritative Master Roadmap**: `01-plans/homelab/consolidation/architecture-consolidation-roadmap-v5.md` in the central knowledge vault.
>
> **Governing Architectural Decisions**:
> - `homelab-appctl-control-plane-architecture.md` (Operational Control Plane & Deployment Model)
> - `homelab-3tier-architecture-and-provenance.md` (3-Tier Architecture & Provenance)
---
## 🎯 Architectural Invariants Governing Execution
1. **Git is the Authoritative Source of Deployment State**: All workload configurations are versioned in Git. `appctl` reconciles desired Git state into running containers.
2. **One Logical API Across Dual Transports**: The control-plane API is a single logical command-oriented contract. Unix domain socket (`/run/homelab/appctl.sock`) on the host and HTTP for network clients are transport details.
3. **Host Access Does Not Confer Authority**: Entering via SSH does not bypass authentication. Every mutating operation requires an explicit, authenticated user-scoped token.
4. **Separation of Intent from Implementation**: `DeploymentModel` captures implementation-agnostic intent; concrete platform descriptors (`app.yaml` + Compose) are materialized and enforced by `appctl`.
5. **AI Authoring Boundary**: AI agents act strictly as proposal generators (`DeploymentProposal`). Humans approve the intent (`DeploymentModel`). The AI possesses zero execution authority.
6. **Secret Reference Invariant**: Deployment definitions store secret references (`secretKeyRef`), never plaintext material, resolved at runtime via `SecretProvider`.
7. **Clean State Root**: Mutable application runtime data resides strictly under `~/var/lib/homelab/<app>/`, isolated from Git repositories.
---
## 📊 Milestone Overview
| Milestone | Title | Focus Area | Status | Deliverables Summary |
| :--- | :--- | :--- | :--- | :--- |
| **P0** | **Baseline Consolidation** | Git & Architecture | ✅ **Completed** | Synchronized `refactor/appctl-rework` with `main`, recorded control plane ADR, scaffolded v2 metadata engine. |
| **P1** | **Mail Topology Realignment** | Topology & State | 🎯 **Current / Up Next** | Move Stalwart to `smtp.roadtotech.me`; migrate SnappyMail to `~/Sites/snappymail` with zero data loss. |
| **P2** | **GitOps Hardening** | Ingress Security | ⏳ **Planned** | Authoritative Core repository registry (`deployments.yaml`), HMAC verification, systemd execution sandboxing. |
| **P3** | **Manifest Contract** | Domain Engine | ⏳ **Planned** | Schema v1.0, authoritative `core_manifest.py` library, `source.ref` semantics, two-axis status inspection. |
| **P4** | **Control Plane Daemon** | API & Dispatch | ⏳ **Planned** | `homelab-appctl.service` daemon, dual transports (socket + HTTP), thin-client CLI, append-only audit log. |
| **P5** | **Identity & Secrets** | Auth & Providers | ⏳ **Planned** | ForwardAuth header parsing, user-scoped API tokens, `SecretProvider` reference resolution. |
| **P6** | **Deployment Model & AI**| Intent Authoring | ⏳ **Planned** | Capability catalog, `DeploymentProposal` $\to$ `DeploymentModel` compiler, Git commit pipeline. |
| **P7** | **Operations UI & Portal** | Client Integration | ⏳ **Planned** | Dedicated Operations UI client, Homepage read-only status integration widgets. |
---
## 🛠️ Detailed Milestones
### Milestone P0: Baseline Consolidation
**Status**: ✅ **Completed**
* Merged `refactor/appctl-rework` and `main` into a unified architectural baseline (commit `2297cd5`).
* Modernized metadata engine (`scripts/appctl_engine_v2.py`) with strongly-typed dataclasses (`SitesApp`, `CoreService`, `SourceConfig`) and Docker status inspection.
* Formalized the control-plane ADR and Roadmap v5 in the central knowledge vault; marked legacy roadmaps as superseded.
* Verified test suite (47 tests passing) and NixOS flake sandbox evaluation.
---
### Milestone P1: Mail Topology Realignment & Zero-Data-Loss Migration
**Status**: 🎯 **Current / Up Next**
* **Objective**: Segregate platform mail routing from user-facing webmail while preserving all user data and settings.
* **Key Deliverables**:
1. *State Freeze & Verified Snapshot*: Generate timestamped, SHA256-verified backup archive of `Core/config/snappymail/data`.
2. *Workload Provisioning*: Scaffold `~/Sites/snappymail/` (Class B Image-Only workload) and provision persistent state root at `~/var/lib/homelab/snappymail/`.
3. *Zero-Data-Loss State Replication*: Copy data using `cp -a` and prove byte parity (`diff -r`).
4. *Stalwart Re-homing*: Update Stalwart public endpoint in `Core/docker-compose.yml` to `smtp.roadtotech.me`; remove SnappyMail from Core stack.
5. *Live Verification*: Verify webmail at `mail.roadtotech.me`, user logins, address books, IMAP/SMTP routing, and Diun SMTPS delivery on port 465.
* **Exit Criteria**: 100% of user data survives cutover; mail flow and Diun alert delivery confirmed.
---
### Milestone P2: GitOps Privilege & Authority Hardening
**Status**: ⏳ **Planned**
* **Objective**: Close remaining trust boundaries in the webhook continuous deployment engine.
* **Key Deliverables**:
1. *Authoritative Core Registry*: Establish `Core/config/deployments.yaml` as the sole authority for admitted deployment repositories.
2. *Data Vault Pull-Only Policy*: Designate `~/Brain` as a read-only repository with `strategy: pull-only`, isolated from Docker socket access.
3. *Compose AST Security Validator*: Pre-flight parser rejecting `privileged: true`, Docker socket bind mounts, host networking, and mounts outside `~/var/lib/homelab/<app>/`.
4. *Systemd Sandboxing*: Apply `ProtectSystem=strict`, `NoNewPrivileges=true`, and private temporary directories to `homelab-gitops.service`.
* **Exit Criteria**: Path traversal rejection tests pass; Compose AST security validator rejects prohibited capabilities.
---
### Milestone P3: Manifest Contract Convergence & Provenance Engine
**Status**: ⏳ **Planned**
* **Objective**: Establish a single authoritative manifest schema and two-axis inspection engine across the platform.
* **Key Deliverables**:
1. *Schema v1.0 & Parser Library (`core_manifest.py`)*: Strongly-typed manifest parsing, transport scheme validation (`https://`, `ssh://`, `git@`), and explicit ref semantics (moving branches vs. pinned tags vs. commit SHAs).
2. *Two-Axis Inspection*: Local deployment checkout state (`✓ Synced`, `* Dirty`) evaluated independently of upstream software provenance (resolved via `git ls-remote` bounded by a 10s timeout during `--fetch`).
3. *Engine Promotion*: Promote `scripts/appctl_engine_v2.py` to `scripts/appctl_engine.py` with complete behavioral test coverage.
* **Exit Criteria**: Manifest validation active in CI; all provenance resolution tests passing.
---
### Milestone P4: Appctl Control Plane Daemon & Command-Oriented API
**Status**: ⏳ **Planned**
* **Objective**: Evolve `appctl` from a collection of local shell scripts into the authoritative platform daemon.
* **Key Deliverables**:
1. *Daemon Service (`homelab-appctl.service`)*: Systemd daemon exposing one logical API across dual transports: Unix domain socket (`/run/homelab/appctl.sock`) on host and HTTP listener for network clients.
2. *Command-Oriented Operational Router*: Strongly-typed endpoints (`POST /operations/deploy`, `POST /operations/restart`, `POST /operations/pull`, `GET /workloads`, `GET /workloads/{id}/status`, `POST /operations/sync`).
3. *Thin-Client CLI*: Re-implement `scripts/appctl` as a lightweight dispatch client communicating with the local daemon socket.
4. *Append-Only Audit Log*: Record every mutating command to `~/.local/state/homelab/appctl/audit.jsonl` with restricted `0600` permissions. Telemetry captures `principal`, `action`, `target`, `transport`, `origin`, `client`, `timestamp`, and `result`.
* **Exit Criteria**: Hermetic API test suite passing; local socket and HTTP transport tests passing; audit log correctly capturing multi-dimensional telemetry.
---
### Milestone P5: Identity, RBAC & SecretProvider Interface
**Status**: ⏳ **Planned**
* **Objective**: Implement least-privilege identity boundaries and dynamic secret projection.
* **Key Deliverables**:
1. *Authentication Gateway*: Accept trusted identity headers from Traefik/Authelia (`Remote-User`, `Remote-Groups`) for web requests; validate explicit user-scoped API tokens for all CLI requests (local and remote); validate HMAC signatures for GitOps webhooks.
2. *Role-Based Authorization Engine*: Enforce group-based access control (`homelab-admin`, `homelab-operator`, `homelab-viewer`).
3. *SecretProvider Interface*: Control plane resolves secret references (`secretKeyRef`) at container runtime, eliminating Git history pollution for workload credentials.
* **Exit Criteria**: RBAC permission matrix verified by automated tests; secret references correctly materialized into runtime environments.
---
### Milestone P6: Homelab Deployment Model & AI Authoring Workflow
**Status**: ⏳ **Planned**
* **Objective**: Enable safe, human-reviewed workload authoring from upstream repositories.
* **Key Deliverables**:
1. *Platform Capability Catalog*: Machine-readable specification of Core capabilities and security invariants.
2. *DeploymentProposal Schema*: Candidate model format produced by AI discovery workflows.
3. *DeploymentModel Git Pipeline*: Operator approves proposal into a `DeploymentModel`; the model is committed to the version-controlled deployment repository (Git).
4. *Materialization & Reconciliation*: `appctl` validates the committed model, provisions state roots, compiles platform descriptors (`app.yaml` + Compose), and reconciles running containers.
* **Exit Criteria**: Human approval gate strictly enforced; AI possesses zero execution authority; generated workloads conform to all Core invariants.
---
### Milestone P7: Operations UI & Dashboard Integration
**Status**: ⏳ **Planned**
* **Objective**: Deliver a unified web-based management experience without coupling the control plane to specific frontend engines.
* **Key Deliverables**:
1. *Operations UI Client*: Dedicated lightweight web client consuming the `appctl` API for proposal review, approval, real-time log streaming, and API token management.
2. *Homepage Status Integration*: Homepage consumes live status widgets from `appctl` live endpoints or compiled service maps.
* **Exit Criteria**: End-to-end browser and CLI deployment verification; Homepage accurately reflecting live container health.
---
## 🔒 Verification & Quality Gates
Progress across milestones is governed by explicit verification criteria:
* **Behavioral Invariant Coverage**: All defined domain, authorization, deployment, and security invariants must have automated regression tests.
* **Pre-Merge Validation**: Every commit must pass `./scripts/test` (Ruff linter + Pytest suite + Nix flake check).
* **Zero Production Regressions**: Platform migrations must include verified pre-flight snapshots, state parity proofs, and documented rollback runbooks.
+4
View File
@@ -2,6 +2,10 @@
The `appctl` tool is the command-line orchestrator and metadata engine for the **Homelab Core** platform. It coordinates interactions between independent workload repositories in `~/Sites` and platform services in `~/Core`.
> [!NOTE]
> **Implementation Reference**: This document serves as the **current implementation manual** for the `appctl` Bash CLI wrapper (`scripts/appctl`), metadata engines (`scripts/appctl_engine.py` / `scripts/appctl_engine_v2.py`), and currently consumed `app.yaml` manifest fields.
> For the platform's overarching control-plane architecture, 5-stage deployment model lifecycle, and phased engineering roadmap, see [`README.md`](../README.md), [`ROADMAP.md`](../ROADMAP.md), and the [Architecture Decision Index](decisions/README.md).
---
## 1. How `appctl` Works
+5 -1
View File
@@ -2,6 +2,10 @@
This document details the architectural structure, component roles, networking models, and security controls of the **Homelab Core** platform for `roadtotech.me`.
> [!NOTE]
> **Implementation Scope**: This document details the **current runtime architecture**, edge routing, container topologies, and network isolation models of Homelab Core.
> For the overarching control-plane architecture, 5-stage deployment model lifecycle, and phased engineering milestones, see [`README.md`](../README.md), [`ROADMAP.md`](../ROADMAP.md), and the [Architecture Decision Index](decisions/README.md).
---
## 1. System Structure: Ownership vs. Runtime Layers vs. Orchestration
@@ -46,7 +50,7 @@ The runtime environment consists of four functional layers:
### C. Cross-Cutting Orchestration
Orchestration coordinates operations across the runtime layers without being a runtime layer itself:
* **`appctl` CLI & Metadata Engine (`scripts/appctl`, `scripts/appctl_engine.py`)**: Slices across the Host Foundation (sourcing secrets from `/run/secrets/`), Workload Plane (parsing `~/Sites/*/app.yaml` and driving Docker Compose), and Platform Services (recompiling `config/homepage/services.yaml`).
* **`appctl` CLI & Metadata Engine (`scripts/appctl`, `scripts/appctl_engine.py`, `scripts/appctl_engine_v2.py`)**: Current CLI implementation coordinating discovery, Docker status inspection, and Homepage compilation across workloads and Core. In the target architecture, this evolves into the centralized operational control plane daemon (`homelab-appctl.service`).
* **GitOps Webhook Dispatcher (`scripts/gitops_dispatcher.py`)**: Governed by the `homelab-gitops.service` systemd unit, it receives webhooks on port 9000, enforces admission policies, and dispatches serialized deployment actions for workloads or data repositories.
---
+61
View File
@@ -0,0 +1,61 @@
# 🏛️ Homelab Core & Appctl Architecture Decision Index
This document serves as the repository-facing index for Architectural Decision Records (ADRs) governing **Homelab Core** and the **`appctl` Operational Control Plane**.
In accordance with platform governance, authoritative ADRs are maintained in the central knowledge vault (`03-records/decisions/`) using the MADR 4.0 specification. This index provides navigation, context, and one-line summaries without duplicating architectural specifications or creating competing sources of truth.
---
## 📋 Active Architectural Decisions
| Decision Record | Status | Date | Scope & One-Line Purpose |
| :--- | :--- | :--- | :--- |
| [**Homelab Operational Control Plane & Deployment Model Architecture**](#homelab-operational-control-plane--deployment-model-architecture) | `accepted` | 2026-10-07 | Establishes `appctl` as the central operational control plane daemon, one logical API across dual transports (Unix socket and HTTP), explicit token authentication on host, Git as authoritative deployment state, the 5-stage model lifecycle, AI proposal boundaries, and append-only audit telemetry. |
| [**Homelab 3-Tier Architecture & Deployment Provenance Model**](#homelab-3-tier-architecture--deployment-provenance-model) | `accepted` | 2026-09-28 | Establishes 3-tier separation (Software, OCI Artifact, Sites Deployment, Core Platform), two workload classes (Source-Backed vs. Image-Only), isolated state root (`~/var/lib/homelab/<app>/`), and two operational inspection axes. |
---
## 🧭 Summaries of Governing Decisions
### Homelab Operational Control Plane & Deployment Model Architecture
* **Canonical Document**: `03-records/decisions/homelab-appctl-control-plane-architecture.md`
* **Status**: `accepted` (Active)
* **Governing Implementation Plan**: [ROADMAP.md](../../ROADMAP.md) (Roadmap v5)
* **Core Commitments**:
1. **Control Plane Daemon**: `appctl` transitions from a collection of local shell scripts into the authoritative platform service (`homelab-appctl.service`).
2. **One Logical API Across Dual Transports**: Command-oriented operations exposed over a Unix domain socket (`/run/homelab/appctl.sock`) on host and an HTTP listener for network clients.
3. **Explicit Token Authentication Everywhere**: Host SSH access does not confer appctl authority; every mutating operation requires an explicit, authenticated user-scoped token.
4. **Git as Authoritative Deployment State**: Approved `DeploymentModels` are committed to Git. `appctl` acts as the reconciliation engine, validating the model, materializing platform descriptors (`app.yaml` + Compose), and reconciling running containers.
5. **Five-Stage Deployment Model Lifecycle**: Separates factual `ApplicationProfile`, candidate `DeploymentProposal`, validated `DeploymentModel` (in Git), materialized `Deployment Definition`, and runtime `Reconciliation`.
6. **AI Proposal Boundary**: AI agents act strictly as proposal generators with zero mutation or execution authority. After human approval into a `DeploymentModel`, the AI is completely out of the loop.
7. **Secret Reference Invariant**: Manifests contain secret references (`secretKeyRef`), never secret material, resolved at runtime via `SecretProvider`.
8. **Append-Only Audit Log**: Audit entries capture `principal`, `action`, `target`, `transport`, `origin`, `client`, `timestamp`, and `result`.
---
### Homelab 3-Tier Architecture & Deployment Provenance Model
* **Canonical Document**: `03-records/decisions/homelab-3tier-architecture-and-provenance.md`
* **Status**: `accepted` (Active)
* **Governing Implementation Plan**: [ROADMAP.md](../../ROADMAP.md) (Roadmap v5)
* **Core Commitments**:
1. **3-Tier Separation of Concerns**:
* *Tier 1 (Software Layer)*: Upstream application repositories owning code, tests, and CI. Zero Homelab infrastructure coupling.
* *Intermediate Provenance Artifact*: OCI container images produced by CI carrying commit provenance in metadata labels and content-addressed digests.
* *Tier 2 (Sites Deployment Layer)*: Declarative manifests (`app.yaml`) and Compose specs in `~/Sites`.
* *Tier 3 (Platform Core Appliance)*: NixOS host foundation, edge routing, SSO, and operational controllers.
2. **Two Workload Deployment Classes**:
* *Class A (Source-Backed)*: Declares upstream Git source and ref (`source.url`, `source.ref`); tracks upstream Git revisions against container labels.
* *Class B (Image-Only)*: Standard third-party tools; tracks container registry image tags and digests.
3. **Isolated Persistent State Root**: Mutable data lives strictly under `~/var/lib/homelab/<app>/`, isolated from Git repositories.
4. **Two Operational Inspection Axes**: Local deployment checkout state evaluated independently of upstream software provenance (resolved via `git ls-remote`).
---
## 📜 Superseded Historical Decisions & Lineage
The following historical plans and design iterations have been formally superseded by the active ADRs and Roadmap v5:
* **Roadmap v4 & v3** (`architecture-consolidation-roadmap-v4.md`): Superseded by Roadmap v5.
* **appctl-v2 Modernization Plan** (`appctl-engine-v2-refactoring.md`): Scaffolded and absorbed into Roadmap v5 Phases P0 and P3.
* **Smart Selective Deployment Pipeline Plan** (`smart-deployment-pipeline.md`): Absorbed into Roadmap v5 Phase P4 control-plane reconciliation.
* **Architecture Implementation Guide v3** (`architecture-consolidation-implementation-guide-v3.md`): Superseded by Roadmap v5.