--- type: agent status: active name: homelab-core target_workspace: ssh://git@gitea.roadtotech.me:2223/kiskaadee/homelab-core project: homelab tags: - homelab - nixos - infrastructure - docker - sops - gitops - guardrails --- # Homelab Core Platform & Infrastructure Agent ## 1. Overview & Operational Scope * **Target Workspace**: `ssh://git@gitea.roadtotech.me:2223/kiskaadee/homelab-core` (`/home/kiskaadee/Homelab/Core` and worktrees) * **Primary Role**: Maintains the host foundation, platform services, NixOS server modules, ingress security boundaries, and the `appctl` deployment engine. * **Core Invariants & Boundaries**: * **Core / Sites Separation**: Core owns host infrastructure, platform services, ingress proxying, and deployment execution; independent application workloads live in `~/Sites` with declarative `app.yaml` manifests. * **GitOps Trust Boundary**: Webhook payloads cannot directly select filesystem paths or shell inputs. Webhook authentication is strictly validated. * **Docker Isolation**: Only `socket-proxy` may mount the Docker socket in read-only mode for approved capabilities; workload containers never receive direct socket access. * **SOPS Secrets Protection**: Secrets live under `/run/secrets/` via SOPS; never commit plaintext credentials or keys to Git. --- ## 2. Canonical Agent Specification The following specification represents the active behavioral contract configured for `/home/kiskaadee/Homelab/Core/AGENTS.md`: ````markdown # Homelab Core — Agent Guidelines This repository defines the host foundation and Core platform for the `roadtotech.me` homelab. It contains NixOS configuration, shared infrastructure services, orchestration tools, security policy, and operational configuration. Independent application workloads live in `~/Sites` and are integrated with Core through their application manifests and Docker Compose configuration. --- ## Architectural Invariants ### 1. Core / Sites Boundary **Core owns:** - NixOS host configuration and system services - Shared platform and infrastructure services - Ingress, identity, security boundaries, and host-level policy - Orchestration and deployment mechanics **`~/Sites` owns:** - Independently deployed application workloads - Application-specific Docker Compose configuration - Application-specific `app.yaml` metadata and workload intent Do not move workload-specific configuration into Core merely because Core consumes or manages the workload. Do not move Core-owned platform services into `~/Sites`. When ownership is unclear, consult current architecture documentation before changing the boundary. ### 2. Workload Manifests Every `~/Sites` workload is self-describing through its `app.yaml`. Do not hardcode workload-specific domains, ports, environment variables, containers, or deployment configuration inside `scripts/appctl`, `scripts/appctl_engine.py`, or GitOps logic. `app.yaml` describes workload identity, integration metadata, and deployment intent. Core owns deployment mechanics. Never introduce arbitrary command execution, host filesystem paths, privileged operations, or Docker control capabilities into workload manifests. ### 3. GitOps Trust Boundary GitOps must remain a constrained deployment mechanism. - Webhook authentication is mandatory. - Repository identity is resolved through trusted Core logic. - Filesystem paths must never be selected directly by webhook payloads. - Deployment execution must remain closed and explicitly allowlisted. - Repository-controlled configuration must never become arbitrary shell input. - Deployment serialization and superseding behavior must be preserved. Do not weaken these constraints for convenience. ### 4. Docker Isolation - `socket-proxy` is the only Core Compose service that may mount `/var/run/docker.sock`. - The socket proxy must expose only explicitly approved read-only Docker API capabilities; state-changing and command-execution endpoints must remain disabled. - Do not add `privileged: true` without an explicit architectural decision. - Workload containers must not gain direct access to the Docker socket. ### 5. Secrets & Persistent State Never commit plaintext secrets, credentials, password hashes, private keys, certificates, runtime databases, or other generated/persistent state. Secrets are managed through SOPS and projected to runtime paths under `/run/secrets/`. Do not move secrets into application manifests or source code. ### 6. Declarative Configuration vs Runtime State Git contains declarative configuration and reproducible definitions. Persistent runtime state belongs in the appropriate state directories or Docker volumes and must remain excluded from version control. Do not convert runtime state into committed configuration merely to simplify development or recovery. ### 7. Core Service Ownership Core Compose is the execution boundary for Core-owned platform services. Workload-specific services belong in `~/Sites` unless an explicit architectural decision establishes them as Core-owned. Do not introduce application-specific deployment policy into the Core stack. Do not make Core orchestration depend on implementation details of a workload when the workload's declared contract can be used instead. ### 8. License Preserve The Unlicense across Core and related Sites repositories. --- ## Verification & Architectural Integrity When a requested change conflicts with an invariant, stop and resolve the architectural conflict before implementing a workaround. Before committing architectural or security-sensitive changes: ```bash ./scripts/test nix flake check ``` Run additional validation appropriate to the change, such as: ```bash docker compose config -q ``` Architectural invariants should be encoded as tests whenever practical. Do not bypass failing invariant tests by weakening or removing the invariant unless the architecture itself has intentionally changed. --- ## Documentation Use the repository's current architecture and operational documentation as the source of truth for ownership, protocols, and system behavior. Record significant architectural decisions in the appropriate ADR or Brain documentation rather than expanding this file into an architecture manual. All documentation must remain GitHub-flavored Markdown compatible with Obsidian and the live documentation viewer. --- ## Brain Vault Capture significant: - Implementation roadmaps & plans (`~/Brain/01-plans/homelab/`) - Design trade-offs & inquiries (`~/Brain/02-discussions/homelab/`) - Incident post-mortems & RCAs (`~/Brain/03-records/debug/`) - Architectural decisions (ADRs) (`~/Brain/03-records/decisions/`) - Operational guides & runbooks (`~/Brain/04-learning/guides/homelab/`) - Engineering methodologies & durable knowledge (`~/Brain/04-learning/knowledge/`) - Staging captures (`~/Brain/00-inbox/`) Refer to the project topology hub at `~/Brain/06-projects/homelab/README.md`. Do not duplicate entire repository documentation in the Brain Vault. ```` --- ## 3. Related Resources & Context * [Homelab Architecture & Landing Page](../../06-projects/homelab/README.md) * [Homelab Operations & Troubleshooting Agent](homelab-operations.md) * [Brain GitOps & Auto-Sync Deployment Pipeline Guide](../../04-learning/guides/homelab/brain-gitops-deployment-pipeline.md) * [CI/CD Fundamentals & GitOps Knowledge Note](../../04-learning/knowledge/methods/cicd-fundamentals-and-gitops.md)