From b8bd12cd2bd7229f4c6852c6b2bca37dac742d36 Mon Sep 17 00:00:00 2001 From: kiskaadee Date: Sat, 17 Oct 2026 14:39:32 -0500 Subject: [PATCH] decision(homelab): align control plane ADR and project hub with Roadmap v6 Reconcile ADR-0002 (homelab-appctl-control-plane-architecture.md) and related cross-references with locked decisions DEC-01 through DEC-05: - Update ADR-0002 to codify single POST /v1/operations endpoint across dual HTTP/1.1 transports, Bearer token auth + SO_PEERCRED viewer fallback, dedicated homelab-appctl service isolation, and fail-closed audit log. - Align Roadmap v6, evolutionary knowledge article, and discussions to reference 13 canonical domain operations. - Update 06-projects/homelab README to index active discussions and categorize superseded appctl refactoring plans. --- .../architecture-consolidation-roadmap-v6.md | 19 +++++---- .../control-plane-and-engine-modernization.md | 2 +- ...melab-3tier-architecture-and-provenance.md | 2 +- ...melab-appctl-control-plane-architecture.md | 40 +++++++++---------- ...omelab-control-plane-evolution-v1-to-v6.md | 2 +- 06-projects/homelab/README.md | 16 ++++---- 6 files changed, 44 insertions(+), 37 deletions(-) diff --git a/01-plans/homelab/consolidation/architecture-consolidation-roadmap-v6.md b/01-plans/homelab/consolidation/architecture-consolidation-roadmap-v6.md index eecbe15..b2a49c7 100644 --- a/01-plans/homelab/consolidation/architecture-consolidation-roadmap-v6.md +++ b/01-plans/homelab/consolidation/architecture-consolidation-roadmap-v6.md @@ -24,8 +24,9 @@ tags: > - Core Roadmap Projection: `~/Homelab/Core/ROADMAP.md` > > **Architectural Decision Records**: -> - [`homelab-appctl-control-plane-architecture.md`](../../../03-records/decisions/homelab-appctl-control-plane-architecture.md) -> - [`homelab-3tier-architecture-and-provenance.md`](../../../03-records/decisions/homelab-3tier-architecture-and-provenance.md) +> - [`homelab-appctl-control-plane-architecture.md`](../../../03-records/decisions/homelab-appctl-control-plane-architecture.md) (`~/Homelab/Core/docs/decisions/0002-appctl-control-plane-architecture.md`) +> - [`homelab-3tier-architecture-and-provenance.md`](../../../03-records/decisions/homelab-3tier-architecture-and-provenance.md) (`~/Homelab/Core/docs/decisions/0001-3tier-architecture-and-provenance.md`) +> - `~/Homelab/Core/docs/decisions/0003-pydantic-v2-runtime-validation.md` > > **Evolutionary History**: > - [`homelab-control-plane-evolution-v1-to-v6.md`](../../../04-learning/knowledge/methods/homelab-control-plane-evolution-v1-to-v6.md) @@ -68,7 +69,7 @@ flowchart TB HTTP_IN["HTTP Listener (127.0.0.1:9001)
Strictly loopback in P4"] end - API_ROUTER["Single Command-Oriented Operational Router
• POST /v1/operations (12 Canonical Operations)
• GET /v1/health (Liveness Probe)"] + API_ROUTER["Single Command-Oriented Operational Router
• POST /v1/operations (13 Canonical Operations)
• GET /v1/health (Liveness Probe)"] subgraph PIPELINE["Unified Fail-Closed Pipeline"] direction TB @@ -135,14 +136,18 @@ flowchart TB - Mutating operations append a `DISPATCHED` record before touching Docker or Git. If the disk write fails, the request immediately terminates with `500 ERR_EXECUTION_FAILED`. 7. **Git is the Authoritative Source of Deployment State**: - Approved `DeploymentModels` are committed to Git. `appctl` reconciles desired Git state into running containers. -8. **AI Authoring Boundary**: +8. **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}$. +9. **AI Authoring Boundary**: - AI agents are strictly upstream proposal generators (`DeploymentProposal`) with zero execution authority. Human operators approve the intent. -9. **KISS Primitives & Linear Control Paths**: - - Control flow remains strictly linear and local. No message brokers (RabbitMQ/Kafka) or deployment databases are introduced. +10. **Secret Reference Invariant & Clean Persistent State Root**: + - Deployment definitions store secret references (`secretKeyRef`) resolved at runtime via `SecretProvider`, never plaintext credentials; mutable runtime data resides strictly under `~/var/lib/homelab//`, isolated from Git repositories. +11. **KISS Primitives & Linear Control Paths**: + - Control flow remains strictly linear and local. No message brokers (RabbitMQ/Kafka) or deployment databases are introduced. --- -## 3. The 12 Canonical Domain Operations +## 3. The 13 Canonical Domain Operations | Domain Operation | Type | Required Role (`Sites` / `Core`) | Timeout | Subprocess / Engine | | :--- | :--- | :--- | :--- | :--- | diff --git a/02-discussions/homelab/control-plane-and-engine-modernization.md b/02-discussions/homelab/control-plane-and-engine-modernization.md index 9d290c9..45d206f 100644 --- a/02-discussions/homelab/control-plane-and-engine-modernization.md +++ b/02-discussions/homelab/control-plane-and-engine-modernization.md @@ -130,4 +130,4 @@ The exploration converged on a clear architectural trajectory: **move operationa This exploration informed the formal architectural commitments and implementation phasing recorded in: - **Architectural Decision Record**: [`03-records/decisions/homelab-appctl-control-plane-architecture.md`](../../03-records/decisions/homelab-appctl-control-plane-architecture.md) — Formally adopts the daemon control plane, typed metadata engine, Unix domain socket transport, and `SecretProvider` boundary. -- **Implementation Roadmap**: [`01-plans/homelab/consolidation/architecture-consolidation-roadmap-v5.md`](../../01-plans/homelab/consolidation/architecture-consolidation-roadmap-v5.md) — Organizes the migration into concrete, incremental phases (P0 through P4). +- **Implementation Roadmap**: [`01-plans/homelab/consolidation/architecture-consolidation-roadmap-v6.md`](../../01-plans/homelab/consolidation/architecture-consolidation-roadmap-v6.md) — Organizes the migration and locked P4 daemon boundaries (`DEC-01`–`DEC-05`) into concrete phases (P0 through P7). diff --git a/03-records/decisions/homelab-3tier-architecture-and-provenance.md b/03-records/decisions/homelab-3tier-architecture-and-provenance.md index 40376ee..3508956 100644 --- a/03-records/decisions/homelab-3tier-architecture-and-provenance.md +++ b/03-records/decisions/homelab-3tier-architecture-and-provenance.md @@ -107,5 +107,5 @@ Chosen option: **Option 3: Bounded 3-Tier Platform with OCI Provenance Labels & ## More Information * **Informing Discussion & Rationale**: [`02-discussions/homelab/architecture-migration-v3-to-v4.md`](../../02-discussions/homelab/architecture-migration-v3-to-v4.md) -* **Governed Implementation Roadmap**: [`01-plans/homelab/consolidation/architecture-consolidation-roadmap-v4.md`](../../01-plans/homelab/consolidation/architecture-consolidation-roadmap-v4.md) +* **Governed Implementation Roadmap**: [`01-plans/homelab/consolidation/architecture-consolidation-roadmap-v6.md`](../../01-plans/homelab/consolidation/architecture-consolidation-roadmap-v6.md) * **Project Hub**: [`06-projects/homelab/README.md`](../../06-projects/homelab/README.md) diff --git a/03-records/decisions/homelab-appctl-control-plane-architecture.md b/03-records/decisions/homelab-appctl-control-plane-architecture.md index 310f749..74f1b7a 100644 --- a/03-records/decisions/homelab-appctl-control-plane-architecture.md +++ b/03-records/decisions/homelab-appctl-control-plane-architecture.md @@ -100,29 +100,29 @@ Chosen option: **Option 3: Homelab Operational Control Plane with Stable Deploym Runtime Reconciliation ``` -#### 1. One Logical Control-Plane API across Dual Transports +#### 1. One Logical Control-Plane API across Dual Transports (`DEC-01`) * `appctl` transitions from a collection of local shell scripts into the authoritative **operational control plane service** for Homelab Core, managed as a systemd service (`homelab-appctl.service`). -* The control plane exposes **one logical, command-oriented API** (e.g. `POST /operations/deploy`, `POST /operations/restart`, `GET /workloads`, `GET /workloads/{id}/status`, `POST /operations/sync`). +* The control plane exposes **one logical, command-oriented HTTP/1.1 API** dispatched through a single canonical operation endpoint: `POST /v1/operations` (covering all 13 canonical domain operations) and `GET /v1/health` (liveness probe), validated by strict Pydantic v2 contracts (`extra="forbid"`, `strict=True`). Multi-route REST aliases are rejected. * Transport is decoupled from contract: - * **Unix Domain Socket** (`/run/homelab/appctl.sock`): Used by local host clients (local CLI). - * **HTTP Listener** (Localhost / LAN fronted by Traefik): Used by remote clients (remote CLI, Operations UI, GitOps dispatcher). + * **Unix Domain Socket** (`/run/homelab/appctl.sock`, mode `0660`, `homelab-appctl:homelab-operators`): Used by local host clients (thin-client CLI and `gitops_dispatcher.py` worker). + * **HTTP Listener** (`127.0.0.1:9001` in P4; LAN/Traefik ingress in P5+): Used by network clients (remote CLI, Operations UI). * Both local and remote clients invoke the exact same logical API schema. -#### 2. Identity, Authentication & Host Authority Decoupling -* **Host Access Does Not Confer Appctl Authority**: Entering the server via SSH is merely host access; it does not substitute for appctl authentication. **Every mutating appctl operation requires an explicit, authenticated user-scoped token**, regardless of transport. +#### 2. Identity, Authentication, Service Isolation & Fail-Closed Audit (`DEC-02`, `DEC-03`) +* **Host Access Does Not Confer Appctl Mutation Authority**: Entering the server via SSH is merely host access; it does not substitute for appctl mutation authentication. **Every mutating appctl operation and sensitive read (`workload.config`, `workload.logs`) requires an explicit, authenticated Bearer token**, regardless of transport. * **Authentication Modes**: - * *Interactive Web / Operations UI*: Ingress routes via Traefik and Authelia (ForwardAuth). The control plane accepts identity from trusted headers (`Remote-User`, `Remote-Groups`). - * *Remote & Local CLI*: Authenticates via explicit user-scoped API tokens (`Authorization: Bearer `) mapped to an LLDAP user profile. - * *GitOps Dispatcher*: Authenticates via cryptographic HMAC-SHA256 signatures with the webhook shared secret. -* **Role-Based Access Control (RBAC)**: Maps LLDAP groups to permissions (`homelab-admin`, `homelab-operator`, `homelab-viewer`). -* **Telemetry & Append-Only Audit Log**: Every operation records an append-only audit entry distinguishing four orthogonal dimensions: - * `Principal`: Human username (e.g. `fabian`) or service account (`gitops-bot`). - * `Action` & `Target`: The requested operation and workload. - * `Transport`: `unix_socket` vs. `http`. - * `Network Origin`: `local`, `internal_network`, `external_network`. - * `Client`: `local_cli`, `remote_cli`, `web_ui`, `gitops`. - * `Timestamp`, `Duration`, and `Result`. -* Filesystem permissions on `audit.jsonl` are restricted (`0600`), daemon-only writeable, with optional cryptographic hash chaining (`prev_hash`) for tamper evidence. + * *SOPS-Projected Bearer Tokens (P4 Baseline)*: Validated via constant-time SHA-256 comparison (`hmac.compare_digest`) against `/run/secrets/appctl/tokens.json` (`0400`). Required for all mutations, sensitive reads, and HTTP requests. + * *Local UDS `SO_PEERCRED` Viewer Fallback (`DEC-02`)*: Tokenless local Unix socket connections extract kernel peer credentials (`SO_PEERCRED`) and fall back strictly to `homelab-viewer` read-only privileges (`list`, `get`, `resolve`, `ssl`, `health`), preserving zero-friction CLI inspection and shell tab-completion while blocking all mutations (`401`/`403`). + * *GitOps Ingress & Worker (`DEC-04`)*: `gitops_dispatcher.py` verifies Gitea webhook HMAC-SHA256 signatures, enforces `config/deployments.yaml` admission, and delegates `workload.update` over `/run/homelab/appctl.sock` using its `homelab-operator` Bearer token. + * *Interactive Web / LLDAP Directory Integration (P5)*: Expands the P4 gate with LLDAP user-scoped token lifecycle and authenticated Traefik/Authelia ForwardAuth headers (`Remote-User`, `Remote-Groups`). +* **Role-Based Access Control (RBAC)**: Enforces three tiers: `homelab-admin` (all targets including `core`/`core_service`), `homelab-operator` (restricted strictly to workloads in `config/deployments.yaml`), and `homelab-viewer` (non-sensitive reads only). +* **Dedicated Service Identity (`DEC-03`)**: The daemon runs as `homelab-appctl` (`Group = "homelab-operators"`), isolating `/run/secrets/appctl/tokens.json` (`0400`) and `/var/log/homelab/appctl/audit.jsonl` (`0600`) from unprivileged processes and AI coding sessions running under the operator's SSH UID. +* **Telemetry & Fail-Closed Append-Only Audit Log (`/var/log/homelab/appctl/audit.jsonl`)**: Every mutating operation, sensitive read, and denied request records structured JSONL lifecycle events (`DISPATCHED`, `COMPLETED`, `FAILED`, `DENIED`) capturing: + * `Principal`: Identity, role, token ID, and auth method (`bearer_token` vs. `unix_peercred`). + * `Action` & `Target`: The requested canonical operation and workload. + * `Transport` & `Origin`: `unix_socket` (`peer_uid_`) vs. `http` (`client_ip`). + * `Client`, `Timestamp`, `Duration`, `Commit SHA`, and secret-redacted `Parameters`/`Result`. + * **Fail-Closed Disk Guard**: Mutating operations must write and flush a `DISPATCHED` record before any Docker or Git subprocess executes; if the write fails, the operation aborts immediately with `500 ERR_EXECUTION_FAILED`. #### 3. Declarative Git Truth as Authoritative Deployment State * **Git is the Authoritative Source of Deployment State**: @@ -144,7 +144,7 @@ Chosen option: **Option 3: Homelab Operational Control Plane with Stable Deploym * The AI analyzes repositories and drafts `DeploymentProposal` candidates. * The operator edits, selects, and approves the proposal into a `DeploymentModel`. * **After human approval, the AI is completely out of the loop.** - * The control plane API exposes standard endpoints (`POST /models/validate`, `POST /operations/deploy`), giving the AI zero special administrative endpoints. + * The control plane API exposes only standard authenticated operations (`POST /v1/operations`), giving the AI zero special administrative endpoints or ambient host privileges. #### 6. Platform Capability Model & Architectural Invariants Authoring workflows reason against an explicit platform contract: @@ -222,5 +222,5 @@ Authoring workflows reason against an explicit platform contract: ## More Information * **Companion Architecture Decision**: [`homelab-3tier-architecture-and-provenance.md`](homelab-3tier-architecture-and-provenance.md) -* **Governed Implementation Roadmap**: [`01-plans/homelab/consolidation/architecture-consolidation-roadmap-v5.md`](../../01-plans/homelab/consolidation/architecture-consolidation-roadmap-v5.md) +* **Governed Implementation Roadmap**: [`01-plans/homelab/consolidation/architecture-consolidation-roadmap-v6.md`](../../01-plans/homelab/consolidation/architecture-consolidation-roadmap-v6.md) * **Project Hub**: [`06-projects/homelab/README.md`](../../06-projects/homelab/README.md) diff --git a/04-learning/knowledge/methods/homelab-control-plane-evolution-v1-to-v6.md b/04-learning/knowledge/methods/homelab-control-plane-evolution-v1-to-v6.md index eacda6a..2626bdf 100644 --- a/04-learning/knowledge/methods/homelab-control-plane-evolution-v1-to-v6.md +++ b/04-learning/knowledge/methods/homelab-control-plane-evolution-v1-to-v6.md @@ -176,7 +176,7 @@ To eliminate ambiguity, five binding architectural decisions were codified: #### 1. Single Command-Oriented Operational Router (`DEC-01`) Instead of dozens of disparate REST endpoints, the daemon exposes **one canonical endpoint**: -- `POST /v1/operations`: Dispatches all 12 canonical domain operations (both read-only and mutating) using strict Pydantic v2 schemas (`extra="forbid"`, `strict=True`). +- `POST /v1/operations`: Dispatches all 13 canonical domain operations (both read-only and mutating) using strict Pydantic v2 schemas (`extra="forbid"`, `strict=True`). - `GET /v1/health`: A simple convenience probe for orchestrator liveness. - Logs are strictly bounded (`tail: 1..1000`, max 256 KiB output buffer); live SSE streaming is deferred to Milestone P7. diff --git a/06-projects/homelab/README.md b/06-projects/homelab/README.md index 3dc4376..c0af9eb 100644 --- a/06-projects/homelab/README.md +++ b/06-projects/homelab/README.md @@ -51,6 +51,9 @@ The homelab is organized into four decoupled architectural layers to isolate fai Architectural inquiries and problem statements currently under evaluation that have **not yet produced an active implementation plan**: +* ❓ [**Multi-User Houston Architecture via Dynamic Container Spawner and LLDAP/Authelia**](../../02-discussions/homelab/houston-multiuser-spawner-architecture.md) + - **Focus**: Evaluates a dynamic container spawner and LLDAP/Authelia ForwardAuth proxy architecture to provide per-user isolated Houston engine pods (`~/Sites/houston`). + - **Current Status**: Open inquiry analyzing container lifecycle management, per-tenant state volume isolation, and idle spin-down semantics. * ❓ [**WhatsApp & Telegram AI Assistant Backend Architecture**](../../02-discussions/homelab/chatbot-assistant-design.md) - **Focus**: Evaluates architecture, webhook ingress, and trade-offs between Telegram Bot API and WhatsApp Cloud API for a personal AI assistant microservice (`~/Sites/homelab-assistant`) connected to the Brain vault. - **Current Status**: Open inquiry examining authorization models, message formatting, cron triggers, and RAG search capabilities before formalizing an implementation plan. @@ -69,13 +72,9 @@ Implementation roadmaps currently in progress (`status: active`) that are active - Implementing a standalone Rust daemon with 30-second polling and round-robin public DNS resolution across 5 independent providers (Cloudflare, Quad9, Google, OpenDNS, Dynu). 3. 🟡 [**Custom API Security Hardening & Threat Analysis**](../../01-plans/homelab/api-security-hardening.md) `[Active]` - Defense-in-depth security hardening for custom microservice APIs (Learning Hub and Minecraft dashboard) using Authelia ForwardAuth, token validation, and rate limiting. -4. 🟡 [**Smart Selective Deployment Pipeline for Homelab Core**](../../01-plans/homelab/appctl/smart-deployment-pipeline.md) `[Active]` - - Enhancing `appctl` and Gitea Actions with change-aware selective container restarts to prevent unnecessary service interruptions during routine deployments. -5. 🟡 [**appctl Engine V2: Architectural Modernization & Type-Safe Refactoring Plan**](../../01-plans/homelab/appctl/appctl-engine-v2-refactoring.md) `[Active]` - - Modernizing the homelab control utility into a clean, typed Python 3 engine with PyYAML parsing, explicit domain models, and a TDD test suite. -6. 🟡 [**GitHub to Gitea Automated Batch Migration Plan**](../../01-plans/homelab/gitea/github-to-gitea-migration-plan.md) `[Active]` +4. 🟡 [**GitHub to Gitea Automated Batch Migration Plan**](../../01-plans/homelab/gitea/github-to-gitea-migration-plan.md) `[Active]` - Automated migration tooling using `gh` and `tea` APIs to migrate ~35 repositories from GitHub to self-hosted Gitea with push mirrors for redundancy. -7. 🟡 [**LVM Storage Optimization & Partition Resizing Strategy**](../../01-plans/homelab/server-24-7/lvm-storage-optimization-and-resizing.md) `[Active]` +5. 🟡 [**LVM Storage Optimization & Partition Resizing Strategy**](../../01-plans/homelab/server-24-7/lvm-storage-optimization-and-resizing.md) `[Active]` - Storage space audit, disk cleanup runbooks, and a non-destructive LVM logical volume expansion procedure for the server's root filesystem. --- @@ -104,6 +103,7 @@ Operational runbooks and procedures for daily administration: Archived and foundational documentation for completed milestones: ### Resolved Architectural Discussions +* [**Homelab Control Plane Modernization & Separation of Responsibilities**](../../02-discussions/homelab/control-plane-and-engine-modernization.md) — Evaluated script-based orchestration vs unified control plane daemon (`homelab-appctl.service`); resolved via ADR-0002 and Roadmap v5/v6. * [**Stalwart Mail Server Evaluation for Homelab Core**](../../02-discussions/homelab/mail-server-evaluation-stalwart.md) — Evaluated Stalwart vs Mailcow, Poste.io, and Postfix; resolved via Stalwart deployment. * [**Hostinger Business Email vs. Self-Hosted Stalwart**](../../02-discussions/homelab/hostinger-vs-stalwart-email-evaluation.md) — Compared cloud SaaS mail vs self-hosted mail with smart host relay. * [**Dual-Email Schema: Internal Mailboxes vs External Recovery**](../../02-discussions/homelab/dual-email-schema-lldap-stalwart.md) — Solved password recovery loops in identity directories with separate `mail` and `recovery_email` attributes. @@ -120,8 +120,10 @@ Archived and foundational documentation for completed milestones: * [**Core Service Qualification & Portainer Deprecation**](../../02-discussions/homelab/core-service-qualification-and-portainer-deprecation.md) — Evaluated platform service qualification criteria; resolved via complete deprecation of Portainer and retaining Gitea and CI runner decoupled. * [**Migrating from Legacy Multirepo (v3) to 3-Tier Provenance Architecture (v4)**](../../02-discussions/homelab/architecture-migration-v3-to-v4.md) — Evaluated multirepo friction (source pollution, repo inflation, state co-location) vs 3-tier decoupling; resolved via Roadmap v4 adoption. -### Completed Plans +### Completed & Superseded Plans * 🟢 [**Architecture Consolidation & Control Plane Roadmap v5**](../../01-plans/homelab/consolidation/architecture-consolidation-roadmap-v5.md) (Superseded by v6; established 5-stage DeploymentModel lifecycle and control-plane architecture) +* 🟢 [**appctl Engine V2: Architectural Modernization & Type-Safe Refactoring Plan**](../../01-plans/homelab/appctl/appctl-engine-v2-refactoring.md) (Superseded by Roadmap v5/v6 Phases P0 and P3; engine promoted to `scripts/appctl_engine.py`) +* 🟢 [**Smart Selective Deployment Pipeline for Homelab Core**](../../01-plans/homelab/appctl/smart-deployment-pipeline.md) (Superseded by Roadmap v5/v6 Phase P4 control-plane reconciliation) * 🟢 [**Architecture Consolidation & Hardening Roadmap & Execution Plan v4**](../../01-plans/homelab/consolidation/architecture-consolidation-roadmap-v4.md) (Superseded by v5; established 3-tier architecture, OCI provenance model, and execution guide unification) * 🟢 [**Homelab Architecture Consolidation Documents Reorganization**](../../01-plans/homelab/architecture-docs-reorganization.md) — Reorganized consolidation documentation across the epistemic triad (ADR MADR 4.0, narrative Discussion, authoritative Plan) and created `01-plans/homelab/consolidation/` lineage directory. * 🟢 [**Architecture Consolidation & Hardening Roadmap v3**](../../01-plans/homelab/consolidation/architecture-consolidation-roadmap-v3.md) (Superseded by v4; established controller authority, mail relocation plan, and manifest convergence)