Files
nixos-core/ROADMAP.md
T
kiskaadee 2bf0635ba9 docs(core): rewrite AGENTS.md and README.md for self-contained governance
- Structure AGENTS.md around the 6-section agents.md framework covering
  context discovery hierarchy, Core vs. ~/Sites ownership boundaries,
  anti-tautology TDD rules, verification gates (./scripts/test and pyright),
  declarative-vs-runtime state invariants, and MADR/Git hygiene.
- Redesign README.md into a 5-section instance-agnostic entrypoint explicitly
  scoped to the current CLI baseline, with a pointer to ROADMAP.md for the
  Milestone P4 daemon transition.
- Move the Current Baseline vs. Target Architecture matrix to ROADMAP.md,
  use descriptive phrasing for P1 historical endpoints, and define the
  explicit P4-to-P5 authorization gate handoff.
2026-10-15 19:27:09 -05:00

14 KiB

🗺️ 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.

Governing Architectural Decisions: See docs/decisions/README.md for the authoritative ADR index (Control Plane Architecture, 3-Tier Provenance Model, and Pydantic v2 Runtime Validation).


🎯 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.

🔍 Current Implementation Baseline vs. Target Architecture

Architectural Area Current Implementation Baseline (Milestone P3) Target Architecture (Roadmap v5)
appctl Architecture Bash CLI wrapper (scripts/appctl) driving local subprocesses (docker compose, git) and Python engine. Dedicated daemon service (homelab-appctl.service) exposing one logical API over Unix socket and HTTP.
Operational Auth Host Unix permissions; sourcing runtime secrets from /run/secrets/. Mandatory auth middleware in daemon (P4 admission gate); LLDAP directory RBAC, user-scoped API tokens, and Authelia ForwardAuth (P5).
Metadata & Schema Engine Unified engine (scripts/appctl_engine.py) with two-axis provenance and fail-closed Pydantic v2 schema v1.0 parser (scripts/core_manifest.py). Control-plane daemon invokes core_manifest.py / appctl_engine.py through a stable internal Python interface.
Deployment Model Direct authoring of app.yaml and docker-compose.yml in ~/Sites/<app>/. 5-stage lifecycle (planned in P6): DeploymentProposal \to operator-approved DeploymentModel in Git \to appctl materialization.
GitOps Engine Webhook dispatcher (scripts/gitops_dispatcher.py) with HMAC-SHA256 auth, Compose AST security validator, and flock serialization. Integrated into control-plane admission, invoking central reconciliation endpoints.
Secret Distribution 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 via SecretProvider (planned in P5).
Dashboard appctl sync compiles config/homepage/services.yaml from app.yaml manifests. Homepage consumes read-only live status from appctl; dedicated Operations UI client for management (planned in P7).

📊 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 ✅ Completed Re-homed Stalwart to the dedicated smtp. subdomain; migrated SnappyMail to ~/Sites/snappymail with zero data loss.
P2 GitOps Hardening Ingress Security ✅ Completed Authoritative Core repository registry (deployments.yaml), Compose AST security validator, systemd sandboxing.
P3 Manifest Contract Domain Engine ✅ Completed Schema v1.0 with Pydantic v2 fail-closed models (core_manifest.py), two-axis status inspection, unified appctl_engine.py.
P4 Control Plane Daemon API & Dispatch 🎯 Current / Up Next homelab-appctl.service daemon, dual transports (socket + HTTP), mandatory auth admission gate, thin-client CLI, append-only audit log.
P5 Identity & Secrets Auth & Providers ⏳ Planned LLDAP RBAC group mapping, Authelia ForwardAuth header integration, user-scoped token lifecycle, 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 with strongly-typed models (SitesApp, CoreService, SourceConfig) and Docker status inspection.
  • Formalized the control-plane ADR and Roadmap v5; marked legacy roadmaps as superseded.
  • Verified test suite and NixOS flake sandbox evaluation.

Milestone P1: Mail Topology Realignment & Zero-Data-Loss Migration

Status: ✅ Completed

  • 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: Updated Stalwart public endpoint in Core/docker-compose.yml to the configured smtp.<domain> subdomain; removed SnappyMail from Core stack.
    5. Live Verification: Verified webmail at the configured mail.<domain> endpoint, 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: ✅ Completed

  • 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. Decouple Data Vault from Workload GitOps: Evict vault special-casing (BRAIN_DIR) from GitOps engine; continuous deployment strictly manages Sites container workloads.
    3. Compose AST Security Validator: Pre-flight parser rejecting privileged: true, Docker socket bind mounts, host networking, and host mounts outside workload root or state root.
    4. Systemd Sandboxing: Apply ProtectSystem=strict, ProtectHome=read-only, ReadWritePaths, 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: ✅ Completed

  • 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): Fail-closed Pydantic v2 manifest validation (ConfigDict(extra="forbid")), 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 & Cleanup: Promoted unified engine to scripts/appctl_engine.py, retired scripts/appctl_engine_v2.py shim, and achieved zero Pyright static analysis warnings.
  • Exit Criteria: Manifest validation active in CI; all provenance resolution tests passing.

Milestone P4: Appctl Control Plane Daemon & Command-Oriented API

Status: 🎯 Current / Up Next

  • Objective: Evolve appctl from a collection of local shell scripts into the authoritative platform daemon while enforcing authorization gates from day one.
  • 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. Mandatory Authorization Gate: Establish the authentication/authorization middleware interface before exposing mutating routes; reject unauthenticated mutations across both Unix socket and HTTP transports.
    3. 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) invoking core_manifest.py and appctl_engine.py via internal interfaces.
    4. Thin-Client CLI: Re-implement scripts/appctl as a lightweight dispatch client communicating with the local daemon socket.
    5. 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; unauthenticated mutation attempts rejected across both transports; audit log capturing multi-dimensional telemetry.

Milestone P5: Identity, RBAC & SecretProvider Interface

Status: ⏳ Planned

  • Objective: Expand the P4 authorization gate with directory-backed RBAC identity providers and dynamic secret projection.
  • Key Deliverables:
    1. Identity Provider Integration: Plug Traefik/Authelia trusted headers (Remote-User, Remote-Groups) for web requests, LLDAP user-scoped API token lifecycle for CLI requests, and HMAC-SHA256 verification for GitOps webhooks into the P4 authorization middleware.
    2. Role-Based Authorization Engine: Enforce LLDAP 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.