Compare commits
20
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d5ba44f676 | ||
|
|
dcacf976bf | ||
|
|
61a2798d4f | ||
|
|
2bf0635ba9 | ||
|
|
7d516579ef | ||
|
|
6997da3a58 | ||
|
|
1d196cbdd5 | ||
|
|
fe4111a628 | ||
|
|
fae36700b7 | ||
|
|
4786bbe1ca | ||
|
|
fbfbe9375f | ||
|
|
ea0ce0b1d6 | ||
|
|
66c5e4280a | ||
|
|
68c149d9af | ||
|
|
ec0a461b2e | ||
|
|
5ed61acf32 | ||
|
|
93feb0d3f2 | ||
|
|
8356819f08 | ||
|
|
0d9a2ce511 | ||
|
|
667f8d19b9 |
No files matched your search
@@ -1,9 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
set -euo pipefail
|
||||
|
||||
# ==============================================================================
|
||||
# Homelab Core Pre-Commit Invariant & Quality Gate Hook
|
||||
# Runs linter (Ruff) and architecture & security test suite (Pytest)
|
||||
# Runs linter (Ruff), static type checker (Pyright), and test suite (Pytest)
|
||||
# ==============================================================================
|
||||
|
||||
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
@@ -13,26 +13,24 @@ echo "🔍 [pre-commit] Executing Homelab Core invariant checks..."
|
||||
|
||||
# 1. Run Ruff Linter
|
||||
echo " ↳ Linting repository with Ruff..."
|
||||
if command -v uv >/dev/null 2>&1; then
|
||||
uv run ruff check .
|
||||
elif command -v ruff >/dev/null 2>&1; then
|
||||
if command -v ruff >/dev/null 2>&1; then
|
||||
ruff check .
|
||||
elif command -v nix >/dev/null 2>&1 && [ -f flake.nix ]; then
|
||||
nix develop --command ruff check .
|
||||
else
|
||||
echo "⚠️ [pre-commit] Neither uv, ruff, nor nix found; skipping ruff"
|
||||
echo "⚠️ [pre-commit] Neither ruff nor nix found; skipping ruff"
|
||||
fi
|
||||
|
||||
# 2. Run Pytest Suite
|
||||
echo " ↳ Running structural and security test suite with Pytest..."
|
||||
if command -v uv >/dev/null 2>&1; then
|
||||
uv run --with pytest --with pyyaml pytest tests/
|
||||
if [ -x ".venv/bin/pytest" ]; then
|
||||
.venv/bin/pytest tests/
|
||||
elif command -v pytest >/dev/null 2>&1; then
|
||||
pytest tests/
|
||||
elif command -v nix >/dev/null 2>&1 && [ -f flake.nix ]; then
|
||||
nix develop --command pytest tests/
|
||||
else
|
||||
echo "⚠️ [pre-commit] Neither uv, pytest, nor nix found; skipping pytest"
|
||||
echo "⚠️ [pre-commit] Neither pytest nor nix found; skipping pytest"
|
||||
fi
|
||||
|
||||
echo "✅ [pre-commit] All repository checks passed successfully!"
|
||||
@@ -5,6 +5,7 @@ secrets.txt
|
||||
backup.zip
|
||||
.envrc
|
||||
.direnv
|
||||
.venv
|
||||
|
||||
# SSL / ACME Certificates & Keys
|
||||
config/letsencrypt/*
|
||||
|
||||
@@ -1,165 +1,91 @@
|
||||
# Homelab Core — Agent Guidelines
|
||||
|
||||
This repository defines the host foundation and Core platform for the
|
||||
`roadtotech.me` homelab.
|
||||
## 1. Project Overview & Architectural Boundaries
|
||||
|
||||
It contains NixOS configuration, shared infrastructure services, orchestration
|
||||
tools, security policy, and operational configuration.
|
||||
**Homelab Core** defines the declarative NixOS host foundation, shared platform infrastructure services, security boundaries, and the `appctl` operational control plane. Independent application workloads live in `~/Sites/<app>` and integrate through declarative `app.yaml` manifests and workload-scoped Docker Compose files.
|
||||
|
||||
Independent application workloads live in `~/Sites` and are integrated with
|
||||
Core through their application manifests and Docker Compose configuration.
|
||||
### Core vs. `~/Sites` Ownership
|
||||
- **Core owns**: NixOS host configuration, shared platform services (edge ingress, SSO/LDAP, mail, log/update monitors), platform-level ports and security policy, and orchestration/deployment mechanics.
|
||||
- **`~/Sites` owns**: Independently deployed application workloads, workload-specific `docker-compose.yml` topologies, and workload intent (`app.yaml`).
|
||||
- **Boundary Rule**: Never hardcode *workload-specific* domains, ports, containers, environment variables, or deployment policies in Core (`scripts/appctl*`, GitOps, or Core `docker-compose.yml`), and never move Core platform services into `~/Sites`. When ownership is ambiguous, consult [`docs/architecture.md`](docs/architecture.md) before changing the boundary.
|
||||
|
||||
### Context Discovery Hierarchy
|
||||
Before proposing or implementing changes, establish context in this order:
|
||||
1. **Architectural Decisions (`docs/decisions/`)**: Check [`docs/decisions/README.md`](docs/decisions/README.md) and local ADRs for binding design commitments.
|
||||
2. **Runtime Contracts (`docs/`)**: Consult [`docs/architecture.md`](docs/architecture.md), [`docs/appctl.md`](docs/appctl.md), [`docs/gitops.md`](docs/gitops.md), and [`docs/secrets-and-state.md`](docs/secrets-and-state.md) for current behavior.
|
||||
3. **Trajectory & Active Work (`ROADMAP.md`, `todo.txt`, `git log`)**: Verify whether a capability belongs to the current baseline or a planned milestone before modifying code.
|
||||
|
||||
When a requested change conflicts with an architectural invariant or accepted ADR, **stop and surface the conflict** before implementing a workaround.
|
||||
|
||||
---
|
||||
|
||||
## Architectural Invariants
|
||||
## 2. Build, Lint & Verification Commands
|
||||
|
||||
### 1. Core / Sites Boundary
|
||||
The Python environment (`python3`, `pytest`, `pydantic`, `pyyaml`, `types-pyyaml`) and static analysis tools (`ruff`, `pyright`) are provisioned hermetically by `flake.nix` and automatically symlinked to `.venv` via the Nix `devShell` hook (`.envrc`). Do not create separate `uv` or `pip` virtual environments that split from the Nix store environment.
|
||||
|
||||
**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:
|
||||
Every implementation step must close with the automated verification gate before proposing a commit:
|
||||
|
||||
```bash
|
||||
# Full verification gate: Ruff + Pyright + Pytest (124+ tests) + nix flake check + NixOS drv eval
|
||||
./scripts/test
|
||||
nix flake check
|
||||
|
||||
# Targeted fast iteration commands (inside direnv / nix develop, or via .venv)
|
||||
ruff check .
|
||||
pyright
|
||||
.venv/bin/pytest tests/
|
||||
```
|
||||
|
||||
Run additional validation appropriate to the change, such as:
|
||||
When modifying container or Compose definitions, also validate Compose syntax:
|
||||
|
||||
```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.
|
||||
## 3. Code Style & Contract Guidelines
|
||||
|
||||
- **Fail-Closed Validation (`scripts/core_manifest.py`)**: All external inputs (`app.yaml` manifests, webhook payloads, CLI arguments, daemon payloads) must be validated through strict Pydantic v2 models (`ConfigDict(extra="forbid")`).
|
||||
- **Explicit Error Handling**: Never swallow diagnostic `stderr` silently (e.g., avoid blind `2>/dev/null` on engine or manifest commands). Surface actionable validation errors while redacting sensitive material.
|
||||
- **Platform Genericism**: Keep all code, templates, tests, and documentation strictly instance-agnostic:
|
||||
- Inject routing and service identities at runtime via environment variables (`HOMELAB_DOMAIN`, `DOMAIN_SUFFIX`).
|
||||
- Use RFC 2606 placeholders (`example.com`, `example.org`, `example.test`) in tests and configuration examples—never personal domains or operator usernames.
|
||||
- In historical documentation or milestone records, use descriptive phrasing (e.g., *"the configured `smtp.<domain>` endpoint"*) rather than fabricating placeholder domains as historical facts.
|
||||
|
||||
---
|
||||
|
||||
## Documentation
|
||||
## 4. Testing Instructions (TDD)
|
||||
|
||||
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.
|
||||
- **TDD-First**: Write or update failing unit, structural, or security tests in `tests/` before or alongside implementation changes.
|
||||
- **No Tautological Tests**: Every test must import and execute real production modules or scripts (`core_manifest`, `appctl_engine`, `gitops_dispatcher`, `scripts/appctl`) and assert on observable outcomes. Never write tests that only inspect local mock strings, hardcode expected outputs into the fixture under test, or continue passing when the production invariant is broken.
|
||||
- **Protect Invariants**: Do not bypass failing tests by weakening or deleting an invariant assertion unless the architecture itself has intentionally changed via an approved ADR.
|
||||
|
||||
---
|
||||
|
||||
## Architectural & Engineering Knowledge Preservation
|
||||
## 5. Security & State Invariants
|
||||
|
||||
When engineering changes in Core yield durable architectural insights, security posture shifts, non-obvious root causes, or transferable operational heuristics, knowledge preservation is governed by the global skill **`documentation-router`**:
|
||||
- Architectural commitments are recorded in ADRs (`03-records/decisions/`).
|
||||
- Exploratory design inquiries and trade-offs are recorded in Discussions (`02-discussions/`).
|
||||
- Empirical incident RCAs are recorded in Debug Records (`03-records/debug/`).
|
||||
- Implementation roadmaps are recorded in Plans (`01-plans/`).
|
||||
- Routine maintenance, configuration adjustments, and self-explanatory fixes require no external documentation.
|
||||
- Preserve repository-local documentation (`docs/`, inline comments, commit rationale) as the primary source of truth for runtime behavior.
|
||||
1. **Workload Manifests (`app.yaml`)**: Describe declarative workload identity, routing metadata, and deployment intent only. Never introduce arbitrary command execution, host filesystem paths, privileged flags, or Docker control capabilities into `app.yaml`.
|
||||
2. **GitOps Trust Boundary (`scripts/gitops_dispatcher.py`)**:
|
||||
- Webhook admission requires cryptographic authentication (HMAC-SHA256).
|
||||
- Repository identity and filesystem paths must be resolved strictly through trusted Core configuration (`config/deployments.yaml`)—never directly from webhook payloads.
|
||||
- Execution must remain allowlisted, serialized (`flock`), pre-validated by the Compose AST security checker, and free of shell interpolation (`shell=False`, no `eval`).
|
||||
3. **Docker & Privilege Isolation**:
|
||||
- `socket-proxy` is the **only** service permitted to mount `/var/run/docker.sock` (strictly `:ro`, read-only API capabilities only; `POST=0`, `DELETE=0`, `BUILD=0`, `EXEC=0`).
|
||||
- Never add `privileged: true`, host namespace sharing, or direct Docker socket mounts to workload or control-plane containers.
|
||||
4. **Declarative Configuration vs. Secrets & Runtime State**:
|
||||
- Git stores declarative configuration and reproducible definitions only. Never commit plaintext secrets, keys, password hashes, certificates, or runtime databases.
|
||||
- Host secrets are managed via SOPS (`sops-nix`) and projected to `/run/secrets/`.
|
||||
- Persistent mutable runtime state belongs in dedicated host state directories (`~/var/lib/homelab/<app>/`) or Docker volumes excluded from version control.
|
||||
|
||||
---
|
||||
|
||||
## Live Task Tracking (`todo.txt`)
|
||||
|
||||
For multi-step engineering milestones and complex refactors:
|
||||
- Maintain a standard, comment-free `todo.txt` in the repository root formatted for `tuxedo` / `todo.sh`.
|
||||
- Prioritize deliverables using standard priorities (`(A)`, `(B)`, `(C)`), projects (`+<component>`), and contexts (`@<area>`).
|
||||
- Keep `todo.txt` synchronized with code reality: when a deliverable is implemented and verified, mark it completed (`x YYYY-MM-DD ...`) immediately. Never leave verified work marked as pending or untracked.
|
||||
## 6. Documentation, Task Tracking & Git Workflow
|
||||
|
||||
- **Synchronize Documentation (`docs/`)**: Update repository documentation alongside code changes that alter behavior, contracts, or operations. Keep all Markdown formatted in GitHub-Flavored Markdown compatible with both Obsidian and the live documentation viewer.
|
||||
- **Architecture Decision Records (`docs/decisions/`)**: Record binding repository-level architectural decisions in MADR 4.0 format (`NNNN-slug.md`) and register them in [`docs/decisions/README.md`](docs/decisions/README.md).
|
||||
- **Live Task Tracking (`todo.txt`)**: Maintain a comment-free root `todo.txt` formatted for `tuxedo` / `todo.sh` (`(A)`–`(C)` priorities, `+<project>`, `@<context>`) reflecting the current milestone. Mark verified deliverables completed (`x YYYY-MM-DD ...`) immediately.
|
||||
- **Git & Commits**:
|
||||
- Never commit directly to `main`/`master`.
|
||||
- Never run destructive Git commands (`reset --hard`, `restore`, `clean -fd`, `push --force`) without explicit user confirmation.
|
||||
- Stage atomic changes and use Conventional Commits (`feat`, `fix`, `refactor`, `test`, `docs`, `chore`), waiting for user approval before committing.
|
||||
- Preserve [The Unlicense](UNLICENSE) across the repository.
|
||||
@@ -1,96 +1,19 @@
|
||||
# 🏛️ Homelab Core & Appctl Operational Control Plane
|
||||
# Homelab Core
|
||||
|
||||
**Homelab Core** defines the host foundation, platform infrastructure services, security boundaries, and operational control plane for the `roadtotech.me` homelab appliance.
|
||||
**Homelab Core** is the declarative NixOS host foundation, shared platform infrastructure stack, and `appctl` operational control plane for a self-hosted homelab appliance.
|
||||
|
||||
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`.
|
||||
It is designed around a strict two-tier boundary:
|
||||
1. **Homelab Core (this repository)**: Owns NixOS operating system configuration, edge TLS ingress, SSO/LDAP directory identity, mail routing, read-only Docker socket isolation, and orchestration/deployment mechanics.
|
||||
2. **Workload Repositories (`~/Sites/<app>`)**: Independently deployed application stacks that integrate with Core through self-describing `app.yaml` manifests and workload-scoped `docker-compose.yml` definitions.
|
||||
|
||||
All platform definitions are strictly instance-agnostic; domain names (`HOMELAB_DOMAIN`) and secrets (`/run/secrets/`) are injected declaratively at runtime.
|
||||
|
||||
> [!NOTE]
|
||||
> **Current Implementation Baseline vs. Target Architecture**: This README documents the **currently implemented CLI and runtime baseline (Milestone P3)**. Under [Milestone P4 in `ROADMAP.md`](ROADMAP.md), `appctl` is transitioning from a host CLI orchestrator into a dedicated daemon service (`homelab-appctl.service`) exposing a unified logical API across local Unix socket and HTTP transports. See [`ROADMAP.md`](ROADMAP.md) for the full baseline-to-target matrix.
|
||||
|
||||
---
|
||||
|
||||
## 🧭 Architectural Direction & Mental Model
|
||||
|
||||
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**.
|
||||
|
||||
### 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** | Authoritative dataclass engine (`scripts/appctl_engine.py`) with two-axis inspection and schema v1.0 parser (`core_manifest.py`). | 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
|
||||
## System Architecture at a Glance
|
||||
|
||||
```text
|
||||
Internet
|
||||
@@ -98,129 +21,149 @@ To maintain clarity during development, this repository explicitly separates wha
|
||||
▼
|
||||
┌───────────────────────────────┐
|
||||
│ Traefik Edge Proxy (:443) │
|
||||
│ Wildcard TLS (*.roadtotech.me)│
|
||||
│ Wildcard TLS (*.example.com) │
|
||||
└───────┬───────────────┬───────┘
|
||||
│ │
|
||||
Public Traffic │ │ ForwardAuth Protected
|
||||
(e.g., mail, landing) │ │ (authelia-auth@docker)
|
||||
(e.g., SMTP, public) │ │ (authelia-auth@docker)
|
||||
▼ ▼
|
||||
[ Public Services ] [ Authelia SSO / 2FA ]
|
||||
│ │ (LDAP -> LLDAP)
|
||||
│ │
|
||||
▼ ▼
|
||||
┌───────────────────────────────┐
|
||||
│ Docker proxy-net │
|
||||
├───────────────────────────────┤
|
||||
│ • Core Services (Homepage, │
|
||||
│ Dozzle, etc.) │
|
||||
│ Dozzle, Stalwart, etc.) │
|
||||
│ • Workload Apps (~/Sites/*) │
|
||||
└───────────────────────────────┘
|
||||
│
|
||||
(Protected API via TCP:2375)
|
||||
└───────────────┬───────────────┘
|
||||
│ (Read-Only API via TCP:2375)
|
||||
▼
|
||||
┌───────────────────────────────┐
|
||||
│ Docker socket-proxy │
|
||||
│ (socket-net, Read-Only) │
|
||||
└───────────────┬───────────────┘
|
||||
│ (read-only mount)
|
||||
│ (read-only mount :ro)
|
||||
▼
|
||||
/var/run/docker.sock
|
||||
▲
|
||||
│ (Host Orchestration & CD)
|
||||
┌───────────────┴───────────────┐
|
||||
│ Host Control Plane Baseline │
|
||||
│ • appctl CLI + Engine │
|
||||
│ • homelab-gitops.service │
|
||||
└───────────────────────────────┘
|
||||
```
|
||||
|
||||
### Core Services (`docker-compose.yml`)
|
||||
| Service | Domain / Ingress | Function | Auth Policy |
|
||||
For detailed runtime layers, network segmentation, and the P4 control-plane transport architecture, see [`docs/architecture.md`](docs/architecture.md) and [`ROADMAP.md`](ROADMAP.md).
|
||||
|
||||
### Core Platform Services (`docker-compose.yml`)
|
||||
|
||||
| Service | Default Endpoint | Role | Access Policy |
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| **`traefik`** | `traefik.roadtotech.me` | Edge reverse proxy, Dynu DNS-01 ACME TLS | Authelia Guard |
|
||||
| **`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) *(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 |
|
||||
| **`traefik`** | `traefik.${HOMELAB_DOMAIN}` | Edge reverse proxy & DNS-01 ACME wildcard TLS | Authelia Guard |
|
||||
| **`socket-proxy`** | Internal (`socket-net:2375`) | Read-only Docker API security barrier (`POST=0`, `DELETE=0`) | Internal Only |
|
||||
| **`lldap`** | `users.${HOMELAB_DOMAIN}` | Central LDAP user directory | Authelia Guard |
|
||||
| **`authelia`** | `auth.${HOMELAB_DOMAIN}` | Single Sign-On (SSO), 2FA & ForwardAuth | Public (Auth Endpoint) |
|
||||
| **`stalwart`** | `smtp.${HOMELAB_DOMAIN}` | Mail server (SMTP/IMAP/JMAP/Sieve) | Native / LLDAP |
|
||||
| **`homepage`** | `dashboard.${HOMELAB_DOMAIN}` | Service portal dynamically synced via `appctl` | Authelia Guard |
|
||||
| **`dozzle`** | `logs.${HOMELAB_DOMAIN}` | Real-time container log viewer (via `socket-proxy`) | Authelia Guard |
|
||||
| **`watchtower`** | Internal | Automated container image updater | Internal Only |
|
||||
| **`diun`** | Internal | Container image update notifier | Internal Only |
|
||||
|
||||
---
|
||||
|
||||
## ⚡ Quick Start & Operator Workflows (Current Baseline)
|
||||
## Repository Structure
|
||||
|
||||
```text
|
||||
.
|
||||
├── flake.nix # NixOS host configuration, devShell (.venv symlink), and CI checks
|
||||
├── docker-compose.yml # Core platform service stack
|
||||
├── nixos/ # Declarative NixOS modules, systemd units, and SOPS secret wiring
|
||||
├── config/ # Service configurations (Traefik, Authelia, Homepage, deployments.yaml)
|
||||
├── scripts/
|
||||
│ ├── appctl # Operational CLI entrypoint and Compose environment orchestrator
|
||||
│ ├── appctl_engine.py # Discovery, two-axis provenance, TLS inspection, and Homepage sync engine
|
||||
│ ├── core_manifest.py # Authoritative Pydantic v2 schema v1.0 parser for workload app.yaml
|
||||
│ ├── gitops_dispatcher.py # Authenticated webhook CD engine with Compose AST security validation
|
||||
│ └── test # Automated verification gate (Ruff, Pyright, Pytest, Nix flake checks)
|
||||
├── tests/ # Unit, structural, and security invariant test suites
|
||||
└── docs/ # Architecture references, operational runbooks, and MADR decisions
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Quickstart & Operations (Current CLI Baseline)
|
||||
|
||||
### Development & Verification
|
||||
|
||||
Entering the directory via `direnv` (`use flake`) or `nix develop` provisions the hermetic Nix Python environment and symlinks `.venv` for IDE static analysis:
|
||||
|
||||
### Host & System Operations
|
||||
```bash
|
||||
# Rebuild and switch NixOS configuration
|
||||
sudo nixos-rebuild switch --flake ~/Core#server
|
||||
# or use the built-in shell alias:
|
||||
nix-switch
|
||||
# Run full automated verification (Ruff + Pyright + Pytest + nix flake check + NixOS drv eval)
|
||||
./scripts/test
|
||||
|
||||
# Inspect systemd platform services
|
||||
systemctl status homeserver-core.service # Core Compose stack
|
||||
systemctl status homelab-gitops.service # GitOps webhook engine
|
||||
systemctl status dynu-monitor.service # Smart DDNS IP monitor
|
||||
systemctl status dynu-monitor.timer # DDNS timer (every 30m)
|
||||
# Run individual checks directly
|
||||
ruff check .
|
||||
pyright
|
||||
.venv/bin/pytest tests/
|
||||
```
|
||||
|
||||
### Workload Management (`appctl` CLI)
|
||||
|
||||
```bash
|
||||
# List all application stacks with container health, Git tracking, and provenance status
|
||||
# List all workloads with container health and local Git checkout status
|
||||
appctl list
|
||||
|
||||
# Fetch upstream changes across all repos and inspect with SSL certificates
|
||||
# Include upstream Git provenance (--fetch), TLS certificate expiry (--ssl), and Core services (--core)
|
||||
appctl list --fetch --ssl --core
|
||||
|
||||
# Inspect full diagnostic metadata for a service
|
||||
appctl info jellyfin
|
||||
# Inspect detailed manifest, provenance, and container diagnostics for a workload
|
||||
appctl info <service>
|
||||
|
||||
# Start, stop, or restart an application or Core service
|
||||
appctl up docs
|
||||
appctl down mongodb
|
||||
appctl restart traefik
|
||||
# Manage workload or Core service lifecycle (executes docker compose locally in the current baseline)
|
||||
appctl up <service|core>
|
||||
appctl down <service|core>
|
||||
appctl restart <service|core>
|
||||
|
||||
# Sequential stack update (clean working tree check -> git pull -> compose pull -> up -> sync)
|
||||
appctl update docs
|
||||
appctl update core
|
||||
# Full stack update (clean tree check -> git pull --ff-only -> compose pull -> recreate -> sync)
|
||||
appctl update <service|core>
|
||||
|
||||
# Recompile Homepage services.yaml from active app.yaml manifests
|
||||
# Recompile Homepage dashboard configuration from discovered app.yaml manifests
|
||||
appctl sync
|
||||
```
|
||||
|
||||
### Testing & Verification
|
||||
```bash
|
||||
# Run the complete test suite (Ruff linter + Pytest invariants + Nix flake check)
|
||||
./scripts/test
|
||||
### Host System Management
|
||||
|
||||
# Run pure Nix flake evaluation and checks
|
||||
nix flake check
|
||||
```bash
|
||||
# Rebuild and activate the NixOS host configuration
|
||||
sudo nixos-rebuild switch --flake .#server
|
||||
|
||||
# Inspect platform systemd units
|
||||
systemctl status homeserver-core.service
|
||||
systemctl status homelab-gitops.service
|
||||
systemctl status dynu-monitor.service
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📚 Documentation Navigation & Ownership
|
||||
## Documentation Index
|
||||
|
||||
| Document | Ownership & Epistemic Role |
|
||||
| Document | Scope |
|
||||
| :--- | :--- |
|
||||
| [**`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. |
|
||||
| [**`docs/architecture.md`**](docs/architecture.md) | Runtime layers, network segmentation, and Core / `~/Sites` boundaries. |
|
||||
| [**`docs/decisions/README.md`**](docs/decisions/README.md) | Architecture Decision Records (MADR 4.0) governing platform evolution. |
|
||||
| [**`ROADMAP.md`**](ROADMAP.md) | Phased engineering milestones (P0–P7) and baseline-to-target architecture matrix. |
|
||||
| [**`docs/appctl.md`**](docs/appctl.md) | Current `appctl` CLI commands, resolution hierarchy, and `app.yaml` schema v1.0 contract. |
|
||||
| [**`docs/gitops.md`**](docs/gitops.md) | Webhook admission pipeline, HMAC verification, Compose AST validation, and locking. |
|
||||
| [**`docs/secrets-and-state.md`**](docs/secrets-and-state.md) | SOPS secret management, `/run/secrets/` projections, and persistent state paths. |
|
||||
| [**`docs/operations.md`**](docs/operations.md) | Day-2 operational runbook, updates, backups, and recovery procedures. |
|
||||
| [**`docs/setup_guide.md`**](docs/setup_guide.md) | Bare-metal NixOS installation and host bootstrapping guide. |
|
||||
| [**`SECURITY.md`**](SECURITY.md) | Security controls, Docker socket isolation, and threat model. |
|
||||
| [**`AGENTS.md`**](AGENTS.md) | Architectural invariants, TDD rules, and verification gates for contributors and agents. |
|
||||
|
||||
---
|
||||
|
||||
## 🧠 Governance & Knowledge Architecture
|
||||
|
||||
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.
|
||||
|
||||
---
|
||||
|
||||
## 📄 License
|
||||
## License
|
||||
|
||||
This repository is released into the public domain under [The Unlicense](UNLICENSE).
|
||||
+35
-24
@@ -4,11 +4,7 @@ This document serves as the repository-facing projection of the authoritative **
|
||||
|
||||
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)
|
||||
> **Governing Architectural Decisions**: See [`docs/decisions/README.md`](docs/decisions/README.md) for the authoritative ADR index (Control Plane Architecture, 3-Tier Provenance Model, and Pydantic v2 Runtime Validation).
|
||||
|
||||
---
|
||||
|
||||
@@ -24,16 +20,30 @@ It describes the implementation trajectory and phased engineering milestones for
|
||||
|
||||
---
|
||||
|
||||
## 🔍 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** | Move Stalwart to `smtp.roadtotech.me`; migrate SnappyMail to `~/Sites/snappymail` with zero data loss. |
|
||||
| **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, authoritative `core_manifest.py` library, two-axis status inspection, engine promotion. |
|
||||
| **P4** | **Control Plane Daemon** | API & Dispatch | 🎯 **Current / Up Next** | `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. |
|
||||
| **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. |
|
||||
|
||||
@@ -44,9 +54,9 @@ It describes the implementation trajectory and phased engineering milestones for
|
||||
### 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.
|
||||
* 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.
|
||||
|
||||
---
|
||||
|
||||
@@ -57,8 +67,8 @@ It describes the implementation trajectory and phased engineering milestones for
|
||||
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.
|
||||
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.
|
||||
|
||||
---
|
||||
@@ -79,31 +89,32 @@ It describes the implementation trajectory and phased engineering milestones for
|
||||
**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`)*: Strongly-typed manifest parsing, transport scheme validation (`https://`, `ssh://`, `git@`), and explicit ref semantics (moving branches vs. pinned tags vs. commit SHAs).
|
||||
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*: Promote `scripts/appctl_engine_v2.py` to `scripts/appctl_engine.py` with complete behavioral test coverage.
|
||||
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.
|
||||
* **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. *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.
|
||||
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**: Implement least-privilege identity boundaries and dynamic secret projection.
|
||||
* **Objective**: Expand the P4 authorization gate with directory-backed RBAC identity providers 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`).
|
||||
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.
|
||||
|
||||
|
||||
+3
-3
@@ -13,8 +13,8 @@ This document outlines the security controls, container isolation rules, and ope
|
||||
* Traefik and Dozzle query Docker metrics and metadata via `tcp://socket-proxy:2375` rather than direct socket mounts.
|
||||
|
||||
### B. Identity & Access Management (`lldap` & `authelia`)
|
||||
* **Directory Service**: User accounts and group memberships are stored in LLDAP (`users.roadtotech.me`).
|
||||
* **ForwardAuth**: Traefik intercepts incoming HTTP/HTTPS requests and validates sessions with Authelia (`auth.roadtotech.me`) before routing to protected backends.
|
||||
* **Directory Service**: User accounts and group memberships are stored in LLDAP (`users.${HOMELAB_DOMAIN}`).
|
||||
* **ForwardAuth**: Traefik intercepts incoming HTTP/HTTPS requests and validates sessions with Authelia (`auth.${HOMELAB_DOMAIN}`) before routing to protected backends.
|
||||
* **MFA Support**: Supports TOTP and FIDO2 authentication.
|
||||
|
||||
### C. Network Segmentation
|
||||
@@ -51,7 +51,7 @@ This document outlines the security controls, container isolation rules, and ope
|
||||
## 3. Verification Checklist
|
||||
|
||||
- [x] Secrets encrypted in `nixos/secrets.yaml` via Age / SOPS.
|
||||
- [x] User identities managed in LLDAP (`users.roadtotech.me`).
|
||||
- [x] User identities managed in LLDAP (`users.${HOMELAB_DOMAIN}`).
|
||||
- [x] `socket-proxy` configured with `POST=0`, `DELETE=0`, `BUILD=0`, `EXEC=0`.
|
||||
- [x] Webhook HMAC signature verification active on port 9000.
|
||||
- [x] Invariant test runner (`./scripts/test`) passing on changes.
|
||||
|
||||
+72
-63
@@ -3,18 +3,19 @@
|
||||
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 engine (`scripts/appctl_engine.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).
|
||||
> **Implementation Reference**: This document serves as the **current implementation manual (Milestone P3)** for the `appctl` Bash CLI wrapper (`scripts/appctl`), metadata/provenance engine (`scripts/appctl_engine.py`), and Pydantic v2 manifest parser (`scripts/core_manifest.py`).
|
||||
> For the platform's planned Milestone P4 control-plane daemon transition and phased engineering roadmap, see [`ROADMAP.md`](../ROADMAP.md) and the [Architecture Decision Index](decisions/README.md).
|
||||
|
||||
---
|
||||
|
||||
## 1. How `appctl` Works
|
||||
|
||||
`appctl` consists of two cooperating scripts:
|
||||
1. **`scripts/appctl`** (Bash CLI wrapper): Handles command-line arguments, sources secret environment templates, dispatches `docker compose` commands, and provides shell autocompletions.
|
||||
2. **`scripts/appctl_engine.py`** (Python metadata engine): Scans directories in `~/Sites`, parses `app.yaml` manifests, computes Git synchronization status against remotes, queries SSL/TLS certificate validity, and compiles the Homepage dashboard configuration.
|
||||
`appctl` consists of three cooperating modules in `scripts/`:
|
||||
1. **[`scripts/appctl`](../scripts/appctl)** (Bash CLI wrapper): Parses CLI arguments, sources runtime secret templates, injects validated workload environment variables, dispatches `docker compose` commands, and provides shell autocompletions.
|
||||
2. **[`scripts/appctl_engine.py`](../scripts/appctl_engine.py)** (Discovery, Provenance & TLS Engine): Scans `~/Sites/*`, evaluates **two-axis status** (local deployment checkout state vs. upstream software provenance), inspects live container health and TLS certificates, and compiles the Homepage dashboard configuration.
|
||||
3. **[`scripts/core_manifest.py`](../scripts/core_manifest.py)** (Schema v1.0 Parser & Validator): Enforces fail-closed Pydantic v2 validation (`ConfigDict(extra="forbid")`) on `app.yaml` manifests, validates upstream Git transport schemes (`https://`, `ssh://`, `git@`), classifies reference mutability (branch, tag, commit SHA), and blocks reserved host environment keys (`PATH`, `LD_PRELOAD`, `IFS`, `CORE_DIR`, `SITES_DIR`, etc.).
|
||||
|
||||
```
|
||||
```text
|
||||
┌───────────────────────────────┐
|
||||
│ appctl <command> │
|
||||
└───────────────┬───────────────┘
|
||||
@@ -27,8 +28,8 @@ The `appctl` tool is the command-line orchestrator and metadata engine for the *
|
||||
┌──────────────────────────┴──────────────────────────┐
|
||||
▼ ▼
|
||||
[ appctl_engine.py resolve ] [ Source Secrets ]
|
||||
Resolves aliases, domain, /run/secrets/traefik-deployments.env
|
||||
and manifest parameters /run/secrets/homeserver.env
|
||||
• Parses app.yaml via core_manifest.py /run/secrets/traefik-deployments.env
|
||||
• Fails closed on manifest_error /run/secrets/homeserver.env
|
||||
│ │
|
||||
└──────────────────────────┬──────────────────────────┘
|
||||
▼
|
||||
@@ -37,7 +38,7 @@ and manifest parameters /run/secrets/homeserver.en
|
||||
│ • PROXY_NETWORK │
|
||||
│ • SERVICE_DOMAIN / DOMAIN │
|
||||
│ • CONTAINER_NAME │
|
||||
│ • Custom manifest env │
|
||||
│ • Validated manifest env │
|
||||
└──────────────┬──────────────┘
|
||||
▼
|
||||
┌─────────────────────────────┐
|
||||
@@ -52,26 +53,27 @@ and manifest parameters /run/secrets/homeserver.en
|
||||
### Status & Inspection
|
||||
|
||||
#### `appctl list` / `appctl status`
|
||||
Lists applications discovered in `~/Sites` with container status, Git synchronization badge, routed domain, and filesystem path.
|
||||
Lists applications discovered in `~/Sites` using **two-axis inspection**:
|
||||
- **`DEPLOYMENT` (Axis 1 — Local Checkout)**: Inspects the local `~/Sites/<app>` Git working tree (`✓ Synced`, `* Dirty`, `⬇ Behind`, `⚠️ Non-Git`).
|
||||
- **`PROVENANCE` (Axis 2 — Upstream Software)**: Evaluates upstream software provenance for Class A (Source-Backed) vs. Class B (`— Image-Only`) workloads.
|
||||
|
||||
**Options**:
|
||||
* `--fetch` (`-f`): Runs `git fetch --quiet` across repositories before computing sync badges.
|
||||
* `--core` (`-c`): Includes Core infrastructure services (`traefik`, `authelia`, `lldap`, `stalwart`, etc.) in the output.
|
||||
* `--ssl` (`-s`): Queries SSL/TLS certificates for each domain and displays status and expiration days.
|
||||
* `--all` (`-a`): Equivalent to `--core`.
|
||||
* `--fetch` (`-f`): Queries upstream Git remotes (`git ls-remote` with a 10s timeout) and fetches local deployment tracking branches before computing provenance badges.
|
||||
* `--core` (`-c` / `--all` / `-a`): Appends Core infrastructure services (`traefik`, `authelia`, `lldap`, `stalwart`, `homepage`, `dozzle`, `watchtower`) to the output.
|
||||
* `--ssl` (`-s`): Queries SSL/TLS certificates over port 443 for each public domain and appends a `CERT` column.
|
||||
|
||||
**Example Output**:
|
||||
```text
|
||||
SERVICE STATUS GIT SYNC DOMAIN DIRECTORY
|
||||
------- ------ -------- ------ ---------
|
||||
docs 🟢 Running (1) ✓ Synced docs.roadtotech.me ~/Sites/homelab-docs
|
||||
jellyfin 🟢 Running (1) ✓ Synced jellyfin.roadtotech.me ~/Sites/homelab-jellyfin
|
||||
gitea 🟢 Running (2) ⬇ 1 Behind gitea.roadtotech.me ~/Sites/homelab-gitea
|
||||
mongodb 🔴 Stopped ✓ Synced * mongodb.roadtotech.me ~/Sites/homelab-mongodb
|
||||
SERVICE DEPLOYMENT PROVENANCE STATUS DOMAIN
|
||||
------- ---------- ---------- ------ ------
|
||||
docs ✓ Synced (main) ✓ Synced 🟢 Running (1) docs.example.com
|
||||
jellyfin ✓ Synced (main) — Image-Only 🟢 Running (1) jellyfin.example.com
|
||||
gitea ✓ Synced (main) ⬆ Update Available 🟢 Running (2) gitea.example.com
|
||||
mongodb * Dirty (1) (main) — Image-Only 🔴 Stopped mongodb.example.com
|
||||
```
|
||||
|
||||
#### `appctl ssl [service]`
|
||||
Inspects SSL/TLS certificates over port 443. If a service is specified, shows detailed issuer, subject, and expiration data; otherwise, inspects all homelab domains.
|
||||
Inspects SSL/TLS certificates over port 443. If a service is specified, shows detailed issuer, subject, and expiration data; otherwise, inspects all non-internal homelab domains.
|
||||
|
||||
```bash
|
||||
# Check all domains
|
||||
@@ -81,14 +83,13 @@ appctl ssl
|
||||
appctl ssl jellyfin
|
||||
```
|
||||
|
||||
#### `appctl info <service>`
|
||||
Displays diagnostic information for a workload or Core service:
|
||||
* Canonical name, directory, and aliases.
|
||||
* Docker container running status.
|
||||
* Primary routed domain and Authelia guard status.
|
||||
* Git tracking details: branch, upstream remote, uncommitted file count.
|
||||
* Injected environment variable defaults.
|
||||
* Homepage card configuration.
|
||||
#### `appctl info <service> [--ssl]`
|
||||
Displays comprehensive two-axis diagnostics for a workload or Core service:
|
||||
* Canonical name, directory path, aliases, and workload class (`Class A (Source-Backed)` vs. `Class B (Image-Only)`).
|
||||
* Primary routed domain, networks, and Authelia guard status.
|
||||
* **Axis 1 (Local Deployment Checkout)**: Branch, commit hash, dirty file count, and sync status.
|
||||
* **Axis 2 (Upstream Software Provenance)**: Upstream Git URL, tracked ref (`branch`, `tag`, or `commit`), resolved remote commit, and running container OCI revision label.
|
||||
* Injected environment variable defaults and Homepage card metadata.
|
||||
* SSL certificate details (when `--ssl` is passed).
|
||||
|
||||
```bash
|
||||
@@ -101,22 +102,22 @@ appctl info docs --ssl
|
||||
|
||||
#### `appctl up <service|core>`
|
||||
Starts the specified service stack in detached mode (`--remove-orphans`).
|
||||
* For a workload in `~/Sites`: starts containers and calls `appctl sync`.
|
||||
* For a workload in `~/Sites`: starts containers and triggers `appctl sync`.
|
||||
* For `core`: starts the entire Core Compose stack using `/run/secrets/homeserver.env`.
|
||||
* For an individual Core service (e.g. `appctl up traefik`): starts that specific container.
|
||||
* For an individual Core service (e.g., `appctl up traefik`): starts that specific container.
|
||||
|
||||
#### `appctl down <service|core>`
|
||||
Stops and removes containers defined in the target's Compose file.
|
||||
Stops and removes containers defined in the target's Compose file (or stops the targeted Core container).
|
||||
|
||||
#### `appctl restart <service|core>`
|
||||
Restarts the target stack or individual container.
|
||||
* `appctl restart docs`: Restarts the docs workload.
|
||||
Restarts the target stack or individual container:
|
||||
* `appctl restart docs`: Recreates the `docs` workload stack and syncs Homepage.
|
||||
* `appctl restart core`: Restarts all Core Compose services.
|
||||
* `appctl restart traefik`: Restarts only the Traefik container.
|
||||
|
||||
#### `appctl update <service|core>`
|
||||
Performs a sequential update workflow:
|
||||
1. Checks that the local git working tree is clean (aborts if uncommitted changes exist).
|
||||
1. Verifies that the local Git working tree is clean (aborts if uncommitted changes exist).
|
||||
2. Runs `git pull --ff-only` to fast-forward the current branch.
|
||||
3. Runs `docker compose pull` to fetch updated container images.
|
||||
4. Runs `docker compose up -d --remove-orphans` to recreate containers.
|
||||
@@ -126,31 +127,32 @@ Performs a sequential update workflow:
|
||||
Pulls latest container images and recreates the target service.
|
||||
|
||||
#### `appctl logs <service|core>`
|
||||
Streams container logs (`docker compose logs -f`).
|
||||
* Supports passing container names: `appctl logs core traefik` or `appctl logs stalwart`.
|
||||
Streams container logs (`docker compose logs -f`). Supports passing specific container names (`appctl logs core traefik` or `appctl logs stalwart`).
|
||||
|
||||
#### `appctl config <service|core>`
|
||||
Renders the resolved Docker Compose configuration with all injected variables.
|
||||
Validates the manifest and renders the resolved Docker Compose configuration with all injected variables. Fails closed if `app.yaml` is missing or invalid.
|
||||
|
||||
#### `appctl sync`
|
||||
Scans all `~/Sites/*/app.yaml` manifests and re-generates `config/homepage/services.yaml`.
|
||||
Scans all valid `~/Sites/*/app.yaml` manifests and compiles `config/homepage/services.yaml`.
|
||||
|
||||
#### `appctl completion [bash]`
|
||||
Outputs the bash autocompletion script.
|
||||
|
||||
---
|
||||
|
||||
## 3. `app.yaml` Fields Consumed by `appctl` and GitOps
|
||||
## 3. `app.yaml` Schema v1.0 Contract
|
||||
|
||||
`app.yaml` files in `~/Sites` are read by `appctl_engine.py` and `gitops_dispatcher.py` for the following fields:
|
||||
Workload manifests in `~/Sites/<app>/app.yaml` are validated by [`scripts/core_manifest.py`](../scripts/core_manifest.py) using strict Pydantic v2 models (`extra="forbid"`). Any unknown field, invalid transport URL, or prohibited deployment action causes validation to fail closed.
|
||||
|
||||
```yaml
|
||||
schema_version: "1.0" # Schema version (only "1.0" is supported)
|
||||
|
||||
# ── Identity & Routing ────────────────────────────────────────────────────────
|
||||
name: "jellyfin" # Canonical service name (defaults to folder name minus homelab-)
|
||||
aliases: # Alternate CLI aliases
|
||||
name: "jellyfin" # Canonical name: ^[a-zA-Z0-9][a-zA-Z0-9._-]*$
|
||||
aliases: # Optional CLI aliases
|
||||
- "media"
|
||||
- "movies"
|
||||
domain: "jellyfin.roadtotech.me" # Primary routed domain (defaults to <name>.roadtotech.me)
|
||||
domain: "jellyfin.example.com" # Primary routed domain (defaults to <name>.${HOMELAB_DOMAIN})
|
||||
description: "Media Streaming Server"
|
||||
|
||||
# ── Platform Integration ──────────────────────────────────────────────────────
|
||||
@@ -159,30 +161,36 @@ auth: false # Authelia ForwardAuth protection (default:
|
||||
networks: # Docker networks to join (default: [proxy-net])
|
||||
- proxy-net
|
||||
|
||||
# ── Upstream Software Provenance (Optional: Defines Class A vs. Class B) ─────
|
||||
# Omit 'source' for Class B (Image-Only third-party workloads).
|
||||
# Include 'source' for Class A (Source-Backed workloads):
|
||||
source:
|
||||
url: "https://github.com/example/jellyfin-app.git" # Strictly https://, ssh://, or git@host:path
|
||||
ref: "main" # Branch, v* tag, or 40-char commit SHA
|
||||
|
||||
# ── Injected Environment Defaults ─────────────────────────────────────────────
|
||||
# Injected into the Compose environment when appctl commands run
|
||||
# Keys must match ^[a-zA-Z_][a-zA-Z0-9_]*$ and cannot override reserved host keys
|
||||
# (PATH, LD_PRELOAD, IFS, SHELL, USER, HOME, CORE_DIR, SITES_DIR, etc.)
|
||||
env:
|
||||
MEDIA_PATH: "/media"
|
||||
JELLYFIN_TZ: "UTC"
|
||||
JELLYFIN_PUID: "1000"
|
||||
JELLYFIN_PGID: "1000"
|
||||
|
||||
# ── GitOps Deployment Policy ──────────────────────────────────────────────────
|
||||
# Evaluated by scripts/gitops_dispatcher.py upon webhook reception
|
||||
# Evaluated by scripts/gitops_dispatcher.py upon webhook admission
|
||||
deployment:
|
||||
branch: "main" # Target branch that triggers deployment
|
||||
strategy: "compose" # Deployment strategy (only 'compose' is permitted)
|
||||
actions: # Strictly allowlisted actions
|
||||
- git_pull
|
||||
strategy: "compose" # Only 'compose' strategy is permitted
|
||||
actions: # Strictly allowlisted: git_pull, compose_pull,
|
||||
- git_pull # compose_up, compose_build, compose_restart
|
||||
- compose_up
|
||||
|
||||
# ── Homepage Dashboard Metadata ───────────────────────────────────────────────
|
||||
homepage:
|
||||
title: "Jellyfin" # Card title
|
||||
group: "Media & Productivity" # Group name
|
||||
group: "Media & Productivity" # Dashboard group name
|
||||
icon: "jellyfin.png" # Icon name (matched against config/homepage/icons/)
|
||||
container: "jellyfin" # Container name for live status widget
|
||||
weight: 10 # Card sort weight
|
||||
weight: 10 # Card sort weight (lower sorts first)
|
||||
```
|
||||
|
||||
---
|
||||
@@ -191,26 +199,27 @@ homepage:
|
||||
|
||||
When `appctl` executes commands against a workload, environment variables are resolved in this sequence:
|
||||
|
||||
1. **Global Secrets & Templates**: Sourced from `/run/secrets/homeserver.env` and `/run/secrets/traefik-deployments.env` (or `/run/secrets/rendered/*` fallbacks).
|
||||
2. **Infrastructure Defaults**:
|
||||
1. **Global Secrets & Templates**: Sourced from `/run/secrets/rendered/homeserver.env` and `/run/secrets/rendered/traefik-deployments.env` (with `/run/secrets/*` fallbacks).
|
||||
2. **Canonical Root Domain Lock**: `HOMELAB_DOMAIN` is locked at startup using precedence `HOMELAB_DOMAIN -> DOMAIN_SUFFIX -> DOMAIN` so per-workload `DOMAIN` exports cannot corrupt the platform apex domain.
|
||||
3. **Infrastructure Defaults**:
|
||||
- `PROXY_NETWORK` (defaults to `proxy-net`)
|
||||
- `CERT_RESOLVER` (defaults to `myresolver`)
|
||||
- `DOMAIN_SUFFIX` (defaults to `roadtotech.me`)
|
||||
3. **Application Identity**:
|
||||
- `DOMAIN_SUFFIX` (defaults to `$HOMELAB_DOMAIN`)
|
||||
4. **Application Identity**:
|
||||
- `SERVICE_NAME` = `<canonical-name>`
|
||||
- `CONTAINER_NAME` = `<canonical-name>`
|
||||
- `SERVICE_DOMAIN` = `<resolved-domain>`
|
||||
- `DOMAIN` = `<resolved-domain>`
|
||||
4. **Manifest Variables**: Declared under the `env:` block in `app.yaml`.
|
||||
5. **Local Repository Files**: Sourced from `$APP_DIR/.env` and `$APP_DIR/app.env` if present.
|
||||
5. **Manifest Variables**: Validated key-value pairs from the `env:` block in `app.yaml` (emitted via null-delimited stream without shell `eval`).
|
||||
6. **Local Repository Files**: Sourced from `$APP_DIR/.env` and `$APP_DIR/app.env` if present.
|
||||
|
||||
---
|
||||
|
||||
## 5. Homepage Dashboard Compilation
|
||||
|
||||
When `appctl sync` runs:
|
||||
1. `appctl_engine.py` reads all `~/Sites/*/app.yaml` files.
|
||||
2. Core services (`traefik`, `authelia`, `lldap`, `stalwart`, `snappymail`, `dozzle`) are assigned to `Core Infrastructure`.
|
||||
3. Workload applications with `visible: true` are grouped by their `homepage.group` (ordered: `Core Infrastructure`, `Knowledge & Notes`, `Media & Productivity`, `Development & AI`, `Applications`).
|
||||
4. Custom icons matching files in `config/homepage/icons/` (SVG or PNG) are mapped to `/icons/<name>`.
|
||||
1. `appctl_engine.py` scans all `~/Sites/*/app.yaml` manifests (skipping any workload with a `manifest_error`).
|
||||
2. Core services (`traefik`, `authelia`, `lldap`, `stalwart`, `homepage`, `dozzle`, `watchtower`) are assigned to `Core Infrastructure`.
|
||||
3. Workload applications with `visible: true` are grouped by their `homepage.group` (ordered: `Core Infrastructure`, `Knowledge & Notes`, `Media & Productivity`, `Development & AI`, `Applications`) and sorted by `(weight, title)`.
|
||||
4. Custom icons matching files in `config/homepage/icons/` (`.svg` or `.png`) are mapped to `/icons/<name>`.
|
||||
5. The compiled configuration is written to `config/homepage/services.yaml`.
|
||||
+29
-30
@@ -1,10 +1,10 @@
|
||||
# 🏛️ Homelab Core — Architecture & System Design
|
||||
|
||||
This document details the architectural structure, component roles, networking models, and security controls of the **Homelab Core** platform for `roadtotech.me`.
|
||||
This document details the architectural structure, component roles, networking models, and security controls of the **Homelab Core** platform.
|
||||
|
||||
> [!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).
|
||||
> **Implementation Scope**: This document details the **current runtime architecture (Milestone P3)**, edge routing, container topologies, and network isolation models of Homelab Core.
|
||||
> For the planned Milestone P4 control-plane daemon transition and phased engineering milestones, see [`ROADMAP.md`](../ROADMAP.md) and the [Architecture Decision Index](decisions/README.md).
|
||||
|
||||
---
|
||||
|
||||
@@ -14,12 +14,12 @@ To understand how the system is organized, three architectural dimensions are di
|
||||
|
||||
### A. Ownership Boundary
|
||||
* **Core (`~/Core`) owns**: NixOS host configuration, shared platform services, edge ingress, identity boundaries, secrets distribution, and deployment orchestration mechanics.
|
||||
* **Workload Plane (`~/Sites`) owns**: Independent application codebases, application-specific Docker Compose files, application-specific `app.yaml` metadata, and application data/state.
|
||||
* **Workload Plane (`~/Sites`) owns**: Independent application deployments, workload-specific Docker Compose files, declarative `app.yaml` manifests, and workload-scoped runtime state (`~/var/lib/homelab/<app>/`).
|
||||
|
||||
### B. Four Runtime Layers
|
||||
The runtime environment consists of four functional layers:
|
||||
|
||||
```
|
||||
```text
|
||||
┌────────────────────────────────────────────────────────────────────────┐
|
||||
│ 1. EDGE GATEWAY & INGRESS │
|
||||
│ Traefik (v3.6) · Let's Encrypt Wildcard TLS · Dynu DNS-01 Provider │
|
||||
@@ -28,7 +28,7 @@ The runtime environment consists of four functional layers:
|
||||
▼
|
||||
┌────────────────────────────────────────────────────────────────────────┐
|
||||
│ 2. CONTROL & PLATFORM SERVICES (Core Compose Stack) │
|
||||
│ Authelia SSO · LLDAP Directory · Stalwart Mail · SnappyMail │
|
||||
│ Authelia SSO · LLDAP Directory · Stalwart Mail Server │
|
||||
│ Homepage Dashboard · Dozzle · Watchtower · Diun │
|
||||
│ socket-proxy (Read-Only Docker API Barrier) │
|
||||
└───────────────────────────────────┬────────────────────────────────────┘
|
||||
@@ -36,7 +36,7 @@ The runtime environment consists of four functional layers:
|
||||
▼
|
||||
┌────────────────────────────────────────────────────────────────────────┐
|
||||
│ 3. WORKLOAD PLANE (~/Sites) │
|
||||
│ Autonomous Workload Repositories (Jellyfin, Docs, Gitea, DBs, etc.) │
|
||||
│ Autonomous Workload Repositories (SnappyMail, Docs, Gitea, etc.) │
|
||||
│ Declarative app.yaml Manifests & Compose Stacks │
|
||||
└───────────────────────────────────┬────────────────────────────────────┘
|
||||
│
|
||||
@@ -49,9 +49,9 @@ 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`)**: 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.
|
||||
Orchestration coordinates operations across the runtime layers:
|
||||
* **`appctl` CLI, Provenance Engine & Schema Parser (`scripts/appctl`, `scripts/appctl_engine.py`, `scripts/core_manifest.py`)**: Current CLI implementation coordinating workload discovery, fail-closed Pydantic v2 `app.yaml` validation, two-axis provenance inspection, and Homepage compilation across workloads and Core. Under Milestone P4, this transitions 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, verifies HMAC-SHA256 signatures, enforces the `config/deployments.yaml` allowlist and Compose AST security checks, and dispatches serialized deployment actions for `~/Sites` workloads.
|
||||
|
||||
---
|
||||
|
||||
@@ -59,7 +59,7 @@ Orchestration coordinates operations across the runtime layers without being a r
|
||||
|
||||
### A. Edge Gateway (`traefik`)
|
||||
* **Role**: Ingress proxy for incoming HTTP (80) and HTTPS (443) traffic.
|
||||
* **TLS Management**: Employs Traefik's native ACME resolver using the Dynu DNS-01 challenge provider (`myresolver`) to obtain and renew wildcard certificates for `*.roadtotech.me` and `roadtotech.me`. Certificate data is stored at `config/letsencrypt/acme.json` (mode `0600`).
|
||||
* **TLS Management**: Employs Traefik's native ACME resolver using the Dynu DNS-01 challenge provider (`myresolver`) to obtain and renew wildcard certificates for `*.${HOMELAB_DOMAIN}` and `${HOMELAB_DOMAIN}` (e.g., `*.example.com`). Certificate data is stored at `config/letsencrypt/acme.json` (mode `0600`).
|
||||
* **Redirection**: Automatically upgrades HTTP traffic to HTTPS via the `https-redirect@docker` middleware.
|
||||
* **Dynamic Routing**: Discovers routers and services dynamically by reading Docker container labels via `socket-proxy` (`tcp://socket-proxy:2375`).
|
||||
|
||||
@@ -69,36 +69,36 @@ Orchestration coordinates operations across the runtime layers without being a r
|
||||
- Mounted read-only: `/var/run/docker.sock:/var/run/docker.sock:ro`.
|
||||
- State-modifying and execution endpoints disabled: `POST=0`, `DELETE=0`, `BUILD=0`, `EXEC=0`, `COMMIT=0`, `CONFIGS=0`, `DISTRIBUTION=0`, `NODES=0`, `PLUGINS=0`, `SECRETS=0`, `SWARM=0`, `SYSTEM=0`.
|
||||
- Read-only inspection endpoints enabled: `CONTAINERS=1`, `NETWORKS=1`, `SERVICES=1`, `TASKS=1`, `IMAGES=1`, `VOLUMES=1`, `INFO=1`, `EVENTS=1`, `PING=1`, `VERSION=1`.
|
||||
* **Network**: Attached exclusively to `socket-net`. Application containers in `~/Sites` are not attached to `socket-net`.
|
||||
* **Network**: Attached exclusively to `socket-net`. Application containers in `~/Sites` are never attached to `socket-net`.
|
||||
|
||||
### C. Identity & Directory Services (`lldap` & `authelia`)
|
||||
* **`lldap`**: Lightweight LDAP directory service storing user accounts, password hashes, and groups. Web UI exposed at `users.roadtotech.me` (protected by Authelia). SQLite database stored in `config/lldap/data/users.db`.
|
||||
* **`authelia`**: Authentication and SSO gateway (`auth.roadtotech.me`).
|
||||
* **`lldap`**: Lightweight LDAP directory service storing user accounts, password hashes, and groups. Web UI exposed at `users.${HOMELAB_DOMAIN}` (protected by Authelia). SQLite database stored in `config/lldap/data/users.db`.
|
||||
* **`authelia`**: Authentication and SSO gateway (`auth.${HOMELAB_DOMAIN}`).
|
||||
- Configured with an LDAP authentication backend querying `ldap://lldap:3890`.
|
||||
- Exposes the ForwardAuth endpoint (`/api/verify?rd=https://auth.roadtotech.me/`), registered as the `authelia-auth@docker` Traefik middleware.
|
||||
- Exposes the ForwardAuth endpoint (`/api/verify?rd=https://auth.${HOMELAB_DOMAIN}/`), registered as the `authelia-auth@docker` Traefik middleware.
|
||||
- Passes user identity headers (`Remote-User`, `Remote-Groups`, `Remote-Email`, `Remote-Name`) upon successful session verification.
|
||||
|
||||
### D. Mail Subsystem (`stalwart` & `snappymail`)
|
||||
* **`stalwart`**: All-in-one mail server handling inbound SMTP (25), SMTPS (465), SMTP Submission (587), IMAPS (993), and ManageSieve (4190).
|
||||
- WebAdmin & JMAP UI accessible at `mail.roadtotech.me` via Traefik.
|
||||
### D. Mail Subsystem (`stalwart`)
|
||||
* **`stalwart`**: Core mail transport and storage server handling inbound SMTP (25), SMTPS (465), SMTP Submission (587), IMAPS (993), and ManageSieve (4190).
|
||||
- WebAdmin & JMAP endpoint accessible at `smtp.${HOMELAB_DOMAIN}` via Traefik.
|
||||
- Authenticates users against the LLDAP directory.
|
||||
- Outbound mail relay configured to route through an external smart host (Brevo SMTP relay via SOPS secrets).
|
||||
* **`snappymail`**: Webmail client accessible at `webmail.roadtotech.me` routing to Stalwart.
|
||||
- *(Note: User-facing webmail, such as SnappyMail, runs as an independent Class B workload in `~/Sites/snappymail` with isolated state under `~/var/lib/homelab/snappymail/`.)*
|
||||
|
||||
### E. Portal & Observability (`homepage`, `dozzle`)
|
||||
* **`homepage`**: Service dashboard at `dashboard.roadtotech.me`. Synchronized from `app.yaml` manifests in `~/Sites` by `appctl sync`.
|
||||
* **`dozzle`**: Log viewing interface at `logs.roadtotech.me`, connecting through `socket-proxy`.
|
||||
* **`homepage`**: Service dashboard at `dashboard.${HOMELAB_DOMAIN}`. Synchronized from `app.yaml` manifests in `~/Sites` by `appctl sync`.
|
||||
* **`dozzle`**: Real-time container log viewer at `logs.${HOMELAB_DOMAIN}`, connecting read-only through `socket-proxy`.
|
||||
|
||||
### F. Host Foundation & Daemons
|
||||
* **`homeserver-core.service`**: Systemd unit managing the Core Docker Compose stack (`/home/kiskaadee/Core/docker-compose.yml`) using secrets projected to `/run/secrets/homeserver.env`.
|
||||
* **`homelab-gitops.service`**: Systemd unit listening on port 9000 executing `scripts/gitops_dispatcher.py`.
|
||||
* **`homeserver-core.service`**: Systemd unit managing the Core Docker Compose stack (`~/Core/docker-compose.yml`) using secrets projected to `/run/secrets/homeserver.env`.
|
||||
* **`homelab-gitops.service`**: Systemd unit listening on port 9000 executing `scripts/gitops_dispatcher.py` under strict systemd sandboxing (`ProtectSystem=strict`, `ProtectHome=read-only`).
|
||||
* **`dynu-monitor.service` & `dynu-monitor.timer`**: IP change monitor executing `nixos/scripts/monitor.py` every 30 minutes to detect WAN IP changes and update DNS via `ddclient`.
|
||||
|
||||
---
|
||||
|
||||
## 3. Network Segmentation
|
||||
|
||||
Homelab Core configures two bridge networks:
|
||||
Homelab Core configures two isolated Docker bridge networks:
|
||||
|
||||
```text
|
||||
┌────────────────────────────────────────────────────────────────────────┐
|
||||
@@ -110,8 +110,7 @@ Homelab Core configures two bridge networks:
|
||||
│ │ │ │
|
||||
│ │ • traefik (router) • authelia (sso) │ │
|
||||
│ │ • lldap (directory) • stalwart (mail) │ │
|
||||
│ │ • snappymail (webmail) • homepage (dashboard) │ │
|
||||
│ │ • dozzle (logs) │ │
|
||||
│ │ • homepage (dashboard) • dozzle (logs) │ │
|
||||
│ │ • All User Workloads (~/Sites/*) │ │
|
||||
│ └──────────────────────────────┬───────────────────────────────┘ │
|
||||
│ │ │
|
||||
@@ -129,7 +128,7 @@ Homelab Core configures two bridge networks:
|
||||
```
|
||||
|
||||
1. **`proxy-net`**: Ingress routing network. Traefik directs traffic to backend service containers on this network. Workload containers in `~/Sites` join `proxy-net`.
|
||||
2. **`socket-net`**: Isolated Docker socket proxy network. Only Core infrastructure components needing container metadata join this network.
|
||||
2. **`socket-net`**: Isolated Docker socket proxy network. Only Core infrastructure components needing read-only container metadata join this network.
|
||||
|
||||
---
|
||||
|
||||
@@ -156,9 +155,9 @@ Application containers in `~/Sites` do not bind host ports directly; they receiv
|
||||
|
||||
## 5. Workload Integration Model
|
||||
|
||||
Workloads in `~/Sites/<app>` integrate with Core through two mechanisms:
|
||||
Workloads in `~/Sites/<app>` integrate with Core through three mechanisms:
|
||||
|
||||
1. **Manifest Metadata (`app.yaml`)**: Declares identity, routed domain, environment variable defaults, homepage card layout, and deployment policy.
|
||||
1. **Manifest Metadata (`app.yaml`)**: Validated by `scripts/core_manifest.py` (Schema v1.0). Declares canonical identity, routed domain, upstream source provenance (`source.url`, `source.ref`), environment defaults, Homepage card layout, and allowlisted GitOps deployment policy.
|
||||
2. **Compose Configuration (`docker-compose.yml`)**:
|
||||
- Attaches to the external `proxy-net` network.
|
||||
- Declares Traefik routing labels:
|
||||
@@ -176,4 +175,4 @@ Workloads in `~/Sites/<app>` integrate with Core through two mechanisms:
|
||||
# If auth is required:
|
||||
- "traefik.http.routers.${CONTAINER_NAME}.middlewares=authelia-auth@docker"
|
||||
```
|
||||
3. **Execution**: The `appctl` CLI and GitOps dispatcher supply environment variables (such as `SERVICE_DOMAIN`, `CONTAINER_NAME`, and projected secrets) when invoking Docker Compose.
|
||||
3. **Execution & State Isolation**: `appctl` and `gitops_dispatcher.py` validate the manifest and Compose AST (blocking privilege escalation and out-of-bounds mounts) before supplying runtime environment variables (`SERVICE_DOMAIN`, `CONTAINER_NAME`, and projected secrets). Persistent mutable workload data resides strictly under `~/var/lib/homelab/<app>/`.
|
||||
@@ -0,0 +1,96 @@
|
||||
---
|
||||
type: decision
|
||||
status: accepted
|
||||
project: homelab-core
|
||||
date: 2026-10-15
|
||||
tags: [architecture, appctl, validation, pydantic, security, api]
|
||||
---
|
||||
|
||||
# ADR 0003: Centralized Runtime Validation & Serialization via Pydantic v2
|
||||
|
||||
## Context and Problem Statement
|
||||
|
||||
As Homelab Core transitions from decoupled CLI scripts into an authoritative operational control plane (`homelab-appctl.service`, Milestone P4), the system must process untrusted inputs across two distinct ingestion boundaries:
|
||||
1. Declarative workload manifests (`app.yaml`) authored in `~/Sites` by independent workloads or external repository webhooks.
|
||||
2. Command-oriented API requests sent across dual transports (host Unix Domain Socket `/run/homelab/appctl.sock` and network HTTP listener).
|
||||
|
||||
Previously, manifest parsing relied on Python standard library dataclasses combined with manual regex checking and dictionary traversals in `scripts/core_manifest.py`. While functional for basic validation, manual ad-hoc validation created subtle security and maintainability risks:
|
||||
- Input parsing logic was duplicated across `core_manifest.py`, `appctl_engine.py`, and `gitops_dispatcher.py`.
|
||||
- Validation errors varied in structure and could inadvertently reflect unvalidated raw payloads (potentially leaking secrets or host paths).
|
||||
- Future daemon API endpoints would require writing independent request/response serialization, type-checking, and error-handling routines for every operation.
|
||||
|
||||
The central architectural question is: **How should the control plane enforce strict, fail-closed type safety and consistent serialization across workload manifests and daemon API endpoints without duplicating validation logic or leaking secrets?**
|
||||
|
||||
## Decision Drivers
|
||||
|
||||
* **Fail-Closed Type Safety**: Unrecognized fields, unexpected types, or invalid operations must be rejected immediately at the transport boundary before reaching the operational router.
|
||||
* **Unified Contract Enforcement**: Workload manifests (`app.yaml`) and control plane API payloads must share a common, declarative schema definition rather than separate parser implementations.
|
||||
* **Prevention of Information Disclosure**: Error payloads returned to clients or logged to audit streams must describe schema violations without echoing raw input values, environment variables, or credentials.
|
||||
* **Dual-Transport Parity**: The same validated contract must govern both local Unix Domain Socket calls (CLI) and remote HTTP calls (GitOps dispatcher, Web UI).
|
||||
* **Maintainability & Performance**: Minimizing bespoke parsing code while maintaining fast validation overhead suitable for daemon and CLI operations.
|
||||
|
||||
## Considered Options
|
||||
|
||||
* **Option 1: Standard Library Dataclasses with Custom Manual Validators**: Continue relying solely on Python `dataclasses` and manual validation functions (`isinstance`, regexes).
|
||||
* **Option 2: JSON Schema (`jsonschema`) with Manual Object Deserialization**: Use JSON Schema definitions to validate raw dicts, then manually map validated dicts to dataclasses.
|
||||
* **Option 3: Pydantic v2 with Strict Mode & Fail-Closed Configuration (Adopted)**: Introduce Pydantic v2 as the authoritative validation and serialization engine across manifests and API models.
|
||||
|
||||
## Decision Outcome
|
||||
|
||||
Chosen option: **Option 3: Pydantic v2 with Strict Mode & Fail-Closed Configuration**, because:
|
||||
|
||||
> *"We opted for centralizing runtime validation and serialization across workload manifest and daemon API around Pydantic models to enforce fail-closed type safety, strict schema-based contract boundaries and consistent serialization and error handling without leaking secrets."*
|
||||
|
||||
### Summary of Architectural Commitments
|
||||
|
||||
1. **Single Schema & Validation Layer**:
|
||||
All domain entities—including workload manifest configurations (`SourceConfig`, `DeploymentConfig`, `HomepageConfig`, `Manifest`) and control plane API command payloads (requests, responses, errors)—are defined exclusively as Pydantic v2 models inheriting from `pydantic.BaseModel`.
|
||||
2. **Fail-Closed Schema Boundaries (`extra="forbid"`)**:
|
||||
Every model enforces `ConfigDict(extra="forbid")`. Any payload containing unexpected, undocumented, or extraneous fields is rejected at the transport boundary with zero execution.
|
||||
3. **Strict Typing Policy (`strict=True`)**:
|
||||
To prevent unexpected coercion bugs (e.g. string `"false"` coercing to boolean `True`, or floats coercing to ints), API operations, target identifiers, flags (`recreate`, `remove_orphans`, `visible`, `auth`), and tokens enforce strict types. Explicit field validators handle string trimming/normalization where intentional.
|
||||
4. **Information Disclosure Prevention**:
|
||||
Transport adapters intercept `pydantic.ValidationError` and map it into structured `ERR_VALIDATION_FAILED` (HTTP 400) responses. Error messages report violating field names and failure rules, but strictly sanitize and redact raw input values to prevent leaking secrets, credentials, or filesystem paths.
|
||||
5. **Dual-Transport Parity**:
|
||||
The identical Pydantic request and response models govern both Unix domain socket messages and HTTP API endpoints. Neither transport performs custom validation outside the shared Pydantic models.
|
||||
6. **Host Runtime Alignment**:
|
||||
Pydantic is packaged into the NixOS system environment (`nixos/configuration.nix`), systemd unit paths (`nixos/modules/homeserver.nix`), Nix flake development shells, and repository test dependencies (`pyproject.toml`) constrained to major version range `>=2.0,<3.0`.
|
||||
|
||||
## Pros and Cons of the Options
|
||||
|
||||
### Option 1: Standard Library Dataclasses with Custom Manual Validators
|
||||
* Good, because it requires zero external dependencies and uses Python standard library modules.
|
||||
* Bad, because validation code must be manually implemented for every field, nested structure, and API payload.
|
||||
* Bad, because it is error-prone and historically led to parser duplication across `core_manifest.py`, `appctl_engine.py`, and `gitops_dispatcher.py`.
|
||||
* Bad, because serialization and deserialization (e.g. JSON to model and back) require bespoke helper methods.
|
||||
|
||||
### Option 2: JSON Schema (`jsonschema`) with Manual Object Deserialization
|
||||
* Good, because JSON Schema is a standardized language-agnostic specification.
|
||||
* Bad, because it requires maintaining two separate artifacts for every entity: a JSON Schema document and a corresponding Python dataclass or class.
|
||||
* Bad, because mapping validated JSON Schema dicts to Python typed objects adds runtime boilerplate and cognitive overhead.
|
||||
* Bad, because error messages from `jsonschema` can be difficult to sanitize and format into uniform domain error structures.
|
||||
|
||||
### Option 3: Pydantic v2 with Strict Mode & Fail-Closed Configuration (Adopted)
|
||||
* Good, because it provides declarative, unified model definitions that handle validation, type-checking, and JSON serialization in a single class.
|
||||
* Good, because Pydantic v2's Rust core (`pydantic-core`) delivers high-performance validation with minimal latency impact on the daemon.
|
||||
* Good, because built-in `ValidationError` metadata makes structured error mapping straightforward and consistent.
|
||||
* Good, because `model_dump(mode="json")` and `model_validate_json()` provide deterministic, standardized serialization across dual transports.
|
||||
* Bad, because it introduces a third-party dependency into the Core platform that must be maintained across NixOS packages, development shells, and CI pipelines (mitigated by locking `>=2.0,<3.0` in `pyproject.toml` and Nix flake checks).
|
||||
|
||||
## Consequences
|
||||
|
||||
### Positive Consequences
|
||||
* Eliminates fragmented parsing code: all callers (`appctl_engine.py`, `gitops_dispatcher.py`, `homelab-appctl.service`) validate against the same authoritative schemas in `core_manifest.py`.
|
||||
* Pre-P4 security posture is substantially hardened: unvalidated fields and type confusion attacks are blocked at ingestion.
|
||||
* Clean separation of concerns: transport adapters focus on wire protocol handling while Pydantic guarantees valid domain objects for the operational router.
|
||||
* Client error payloads are structured, actionable, and safe from secret leakage.
|
||||
|
||||
### Negative Consequences & Accepted Trade-offs
|
||||
* Core depends on `pydantic` in host NixOS environment; all host Python environments executing `appctl` or `homelab-gitops` must have `python3Packages.pydantic` available.
|
||||
* Schema evolution requires strict versioning: since `extra="forbid"` is enforced, extending manifests or API payloads with new fields requires coordinated model updates.
|
||||
|
||||
## More Information
|
||||
|
||||
* **Governing Readiness Plan**: [`docs/plans/p4-readiness-plan.md`](../plans/p4-readiness-plan.md) (Section 2.B)
|
||||
* **Governing Roadmap**: [`ROADMAP.md`](../../ROADMAP.md) (Milestone P4)
|
||||
* **Platform Security Invariants**: [`AGENTS.md`](../../AGENTS.md) (Invariants #1, #2, #3)
|
||||
@@ -1,8 +1,8 @@
|
||||
# 🏛️ 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**.
|
||||
This document serves as the authoritative repository 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.
|
||||
Repository-level architectural decisions are recorded in `docs/decisions/` using the MADR 4.0 specification. Foundational platform ADRs (0001 and 0002) are summarized inline below alongside full MADR records (0003+).
|
||||
|
||||
---
|
||||
|
||||
@@ -10,15 +10,29 @@ In accordance with platform governance, authoritative ADRs are maintained in the
|
||||
|
||||
| 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. |
|
||||
| [**ADR-0003: Centralized Runtime Validation & Serialization via Pydantic v2**](0003-pydantic-v2-runtime-validation.md) | `accepted` | 2026-10-15 | Adopts Pydantic v2 as the single runtime schema and validation authority across workload manifests and daemon API to enforce fail-closed type safety, strict schema-based boundaries, and secret-safe serialization. |
|
||||
| [**ADR-0002: 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. |
|
||||
| [**ADR-0001: 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
|
||||
|
||||
### Centralized Runtime Validation & Serialization via Pydantic v2
|
||||
* **Canonical Document**: [`0003-pydantic-v2-runtime-validation.md`](0003-pydantic-v2-runtime-validation.md)
|
||||
* **Status**: `accepted` (Active)
|
||||
* **Governing Implementation Plan**: [ROADMAP.md](../../ROADMAP.md) (Milestone P4)
|
||||
* **Core Commitments**:
|
||||
1. **Single Schema & Validation Layer**: Workload manifests (`core_manifest.py`) and API command models inherit from `pydantic.BaseModel`.
|
||||
2. **Fail-Closed Extra Fields (`extra="forbid"`)**: Immediate rejection of unexpected or undocumented payload properties.
|
||||
3. **Strict Typing Policy (`strict=True`)**: Coercion forbidden on operations, targets, identifiers, and flags.
|
||||
4. **Secret-Safe Error Transformation**: Transport-level conversion of `ValidationError` into standard `ERR_VALIDATION_FAILED` (400) with raw input values redacted.
|
||||
5. **Dual-Transport Parity**: Identical validated models across Unix domain socket and HTTP transports.
|
||||
|
||||
### Homelab Operational Control Plane & Deployment Model Architecture
|
||||
* **Canonical Document**: `03-records/decisions/homelab-appctl-control-plane-architecture.md`
|
||||
|
||||
* **Decision ID**: `ADR-0002`
|
||||
* **Status**: `accepted` (Active)
|
||||
* **Governing Implementation Plan**: [ROADMAP.md](../../ROADMAP.md) (Roadmap v5)
|
||||
* **Core Commitments**:
|
||||
@@ -34,7 +48,7 @@ In accordance with platform governance, authoritative ADRs are maintained in the
|
||||
---
|
||||
|
||||
### Homelab 3-Tier Architecture & Deployment Provenance Model
|
||||
* **Canonical Document**: `03-records/decisions/homelab-3tier-architecture-and-provenance.md`
|
||||
* **Decision ID**: `ADR-0001`
|
||||
* **Status**: `accepted` (Active)
|
||||
* **Governing Implementation Plan**: [ROADMAP.md](../../ROADMAP.md) (Roadmap v5)
|
||||
* **Core Commitments**:
|
||||
|
||||
+26
-12
@@ -1,6 +1,6 @@
|
||||
# ⚡ Homelab Core — GitOps Continuous Deployment Engine
|
||||
|
||||
Homelab Core includes an automated GitOps deployment engine implemented in [`scripts/gitops_dispatcher.py`](../scripts/gitops_dispatcher.py). It processes Git push webhooks from Gitea (or external Git forges) and executes declared deployment actions for workloads in `~/Sites` or data vaults (such as `~/Brain`).
|
||||
Homelab Core includes an automated GitOps deployment engine implemented in [`scripts/gitops_dispatcher.py`](../scripts/gitops_dispatcher.py). It processes Git push webhooks from Gitea (or external Git forges) and executes declared deployment actions strictly for admitted application workloads in `~/Sites`.
|
||||
|
||||
---
|
||||
|
||||
@@ -26,9 +26,9 @@ The GitOps engine is invoked via the `homelab-gitops.service` systemd unit runni
|
||||
│
|
||||
▼
|
||||
┌───────────────────────────────────────────────┐
|
||||
│ 3. Canonical Repository Identity Resolution │
|
||||
│ Maps logical names to trusted local paths │
|
||||
│ Rejects path traversal & symlink escapes │
|
||||
│ 3. Authoritative Registry Resolution │
|
||||
│ Maps names via Core/config/deployments.yaml│
|
||||
│ Fails closed; zero dynamic discovery on host│
|
||||
└───────────────────────┬───────────────────────┘
|
||||
│
|
||||
▼
|
||||
@@ -53,7 +53,8 @@ The GitOps engine is invoked via the `homelab-gitops.service` systemd unit runni
|
||||
┌───────────────────────────────────────────────┐
|
||||
│ 7. Revision-Consistent Validation & Execution │
|
||||
│ git pull -> re-validate manifest on-tree │
|
||||
│ Execute allowlisted actions -> write status│
|
||||
│ Compose AST security validator (containment│
|
||||
│ & privilege checks) -> compose up -> status│
|
||||
└───────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
@@ -71,13 +72,13 @@ The GitOps engine is invoked via the `homelab-gitops.service` systemd unit runni
|
||||
* Signatures are verified using HMAC-SHA256 with `hmac.compare_digest` against the shared secret stored in `nixos/secrets.yaml` (projected to `/run/secrets/gitops/webhook_secret`).
|
||||
* Missing, empty, or mismatched signatures are rejected.
|
||||
|
||||
### C. Trusted Repository Resolution
|
||||
* Webhook payloads identify targets by logical name (e.g. `docs`, `homelab-docs`), never by raw filesystem path.
|
||||
* The engine resolves names against a trusted mapping derived from:
|
||||
1. Authoritative Data Vaults (`~/Brain` via aliases `second-brain`, `Brain`, `brain`).
|
||||
2. Workload directories in `~/Sites` by parsing `app.yaml`.
|
||||
* **Input Validation**: Names must match `^[a-zA-Z0-9][a-zA-Z0-9._-]*$`. Slashes, backslashes, and `..` are rejected.
|
||||
* **Containment Check**: Resolved target paths must reside within `~/Sites` or `~/Brain`. Symlinks pointing outside these roots are rejected.
|
||||
### C. Authoritative Repository Registry (`deployments.yaml`)
|
||||
* Webhook payloads identify targets strictly by logical name (e.g. `docs`, `homelab-docs`), never by raw filesystem path.
|
||||
* `Core/config/deployments.yaml` is the **sole admission authority** for GitOps workloads.
|
||||
* **No Dynamic Discovery**: Scanning `~/Sites` dynamically is strictly prohibited. An unapproved directory created on disk cannot receive webhook deployment rights merely by providing an `app.yaml`.
|
||||
* **Fail-Closed Guarantee**: If `deployments.yaml` is missing, unreadable, or malformed, the dispatcher fails closed and admits zero repositories.
|
||||
* **Input Validation**: Names must match `^[a-zA-Z0-9][a-zA-Z0-9._-]*$`. Slashes, backslashes, and path traversal sequences (`..`) are rejected.
|
||||
* **Containment Check**: Declared repository paths must resolve strictly within `~/Sites`. Paths escaping `~/Sites` are rejected during registry loading.
|
||||
|
||||
### D. Revision-Consistent Manifest Validation
|
||||
* When a webhook is admitted, an initial policy check verifies that the pushed branch matches the declared `deployment.branch`.
|
||||
@@ -85,8 +86,21 @@ The GitOps engine is invoked via the `homelab-gitops.service` systemd unit runni
|
||||
* The engine **re-reads and re-validates `app.yaml` from the newly pulled working tree** before running subsequent container actions (`compose_up`, `compose_build`, etc.).
|
||||
* If the pulled commit introduces an invalid action, unsupported strategy, or changes the target branch away from the pushed branch, deployment is aborted.
|
||||
|
||||
### E. Compose AST Security Validation
|
||||
Before executing `docker compose up -d`, `validate_compose_security()` parses the application's Compose file and enforces platform security invariants:
|
||||
* **File Integrity**: `docker-compose.yml` and `app.yaml` must be regular files, not symlinks escaping the workload root.
|
||||
* **Privilege Containment**: Rejects `privileged: true`, `cap_add` capabilities, `devices` mounts, and `security_opt: ["apparmor:unconfined"]`.
|
||||
* **Namespace Isolation**: Rejects host namespaces (`network_mode: host`, `pid: host`, `ipc: host`, `uts: host`, `userns_mode: host`).
|
||||
* **Docker Socket Ban**: Rejects direct bind mounts of `/var/run/docker.sock` (reserved exclusively for Core `socket-proxy:ro`).
|
||||
* **Top-Level Directives**: Rejects top-level `include:` directives to prevent out-of-tree file inclusions.
|
||||
* **Bind-Mount & State Isolation**:
|
||||
- Resolves all bind mounts (both relative and absolute) against the authorized workload directory.
|
||||
- Bind mounts are strictly restricted to **either** the workload root (`~/Sites/<app>/`) **or** the dedicated per-workload persistent state root (`~/var/lib/homelab/<app>/`).
|
||||
- Cross-tenant mounts (mounting another application's directory under `~/var/lib/homelab/`) are rejected fail-closed.
|
||||
|
||||
---
|
||||
|
||||
|
||||
## 3. Asynchronous Queueing, Serialization & Superseding
|
||||
|
||||
To avoid blocking HTTP connections and handle overlapping pushes:
|
||||
|
||||
+7
-7
@@ -158,7 +158,7 @@ appctl config docs
|
||||
User accounts and group memberships are managed dynamically in **LLDAP** rather than static configuration files.
|
||||
|
||||
### Accessing the Directory
|
||||
1. Open `https://users.roadtotech.me` in your browser.
|
||||
1. Open `https://users.${HOMELAB_DOMAIN}` (e.g., `https://users.example.com`) in your browser.
|
||||
2. Authenticate using your admin credentials (`admin` / password configured in `nixos/secrets.yaml`).
|
||||
3. From the LLDAP UI, you can:
|
||||
- Create and delete user accounts.
|
||||
@@ -167,7 +167,7 @@ User accounts and group memberships are managed dynamically in **LLDAP** rather
|
||||
- Assign users to groups (e.g. `admin`, `users`, `media`).
|
||||
|
||||
### Authelia Session & Authentication
|
||||
* **URL**: `https://auth.roadtotech.me`
|
||||
* **URL**: `https://auth.${HOMELAB_DOMAIN}` (e.g., `https://auth.example.com`)
|
||||
* **Session Lifetime**: 7 days maximum session, 3 days inactivity timeout.
|
||||
* **ForwardAuth Guard**: Applications requiring authentication attach the `authelia-auth@docker` middleware.
|
||||
|
||||
@@ -193,12 +193,12 @@ User accounts and group memberships are managed dynamically in **LLDAP** rather
|
||||
```
|
||||
|
||||
### B. Dynamic DNS (WAN IP) Drift
|
||||
* **Symptom**: External domain `roadtotech.me` does not resolve to the current ISP WAN address.
|
||||
* **Symptom**: External domain (`${HOMELAB_DOMAIN}`) does not resolve to the current ISP WAN address.
|
||||
* **Diagnosis**:
|
||||
```bash
|
||||
# Check current public IP vs resolved DNS IP
|
||||
curl -s https://api.ipify.org
|
||||
dig +short roadtotech.me @1.1.1.1
|
||||
dig +short example.com @1.1.1.1
|
||||
|
||||
# Check dynu-monitor logs
|
||||
systemctl status dynu-monitor
|
||||
@@ -263,7 +263,7 @@ To back up the homelab, create secure snapshots of the following state directori
|
||||
| **User Directory** | `~/Core/config/lldap/data/` | LLDAP SQLite database (`users.db`) |
|
||||
| **Auth Database** | `~/Core/config/authelia/db.sqlite3` | Authelia session database |
|
||||
| **Mail Storage** | `~/Core/config/stalwart/` | Stalwart database, mailboxes, and DKIM keys |
|
||||
| **Webmail State** | `~/Core/config/snappymail/data/` | SnappyMail configuration and sessions |
|
||||
| **Workload State** | `~/var/lib/homelab/<app>/` | Per-workload persistent runtime state (e.g., `snappymail`) |
|
||||
| **Dashboard State** | `~/Core/config/homepage/` | Homepage configuration and custom icons |
|
||||
|
||||
### Host Recovery Requirements
|
||||
@@ -272,10 +272,10 @@ To bring up a replacement host from version control:
|
||||
2. **Restore the host SSH private key** to `/etc/ssh/ssh_host_ed25519_key` (mode `0600`) before running `nixos-install`, as `sops-nix` requires this key during system evaluation and activation.
|
||||
3. Install NixOS targeting the server flake:
|
||||
```bash
|
||||
nixos-install --flake /mnt/home/kiskaadee/Core#server
|
||||
nixos-install --flake /mnt/home/<operator>/Core#server
|
||||
reboot
|
||||
```
|
||||
4. Restore persistent data directories (`config/` backups) and start the Core stack:
|
||||
4. Restore persistent data directories (`config/` and `~/var/lib/homelab/` backups) and start the Core stack:
|
||||
```bash
|
||||
sudo systemctl start homeserver-core
|
||||
```
|
||||
@@ -1,6 +1,6 @@
|
||||
# 📋 Control Plane Milestone P4: Readiness Plan & Boundary Specifications
|
||||
|
||||
**Status**: ✅ **Approved & Locked (Ready for P4 Daemon Implementation)**
|
||||
**Status**: ✅ **Approved & Locked (Pre-P4 Security Gate Complete; Ready for Daemon Implementation)**
|
||||
**Target Milestone**: [Milestone P4: Appctl Control Plane Daemon & API](../../ROADMAP.md#milestone-p4-appctl-control-plane-daemon--command-oriented-api)
|
||||
**Governing ADR**: [`homelab-appctl-control-plane-architecture.md`](../decisions/README.md)
|
||||
|
||||
@@ -10,11 +10,16 @@
|
||||
|
||||
Before initiating code implementation for `homelab-appctl.service`, this readiness plan formalizes the operational contracts, execution boundaries, and security invariants that P4 depends upon.
|
||||
|
||||
Milestones P0–P3 established the core foundation:
|
||||
Milestones P0–P3 and the Pre-P4 Security Gate established the core foundation:
|
||||
- **P0**: Baseline consolidation & Pytest/Nix test harness.
|
||||
- **P1**: Zero-data-loss mail realignment & state isolation (`~/var/lib/homelab/snappymail`).
|
||||
- **P2**: GitOps repository registry (`deployments.yaml`), AST security validation, and Systemd sandboxing.
|
||||
- **P3**: Manifest Schema v1.0 ([`core_manifest.py`](../../scripts/core_manifest.py)), two-axis inspection ([`provenance.py`](../../scripts/provenance.py)), and promoted authoritative engine ([`appctl_engine.py`](../../scripts/appctl_engine.py)).
|
||||
- **P3**: Manifest Schema v1.0 ([`core_manifest.py`](../../scripts/core_manifest.py)), two-axis inspection ([`provenance.py`](../../scripts/provenance.py)), and authoritative engine ([`appctl_engine.py`](../../scripts/appctl_engine.py)).
|
||||
- **Pre-P4 Security Gate (Completed)**:
|
||||
- Eliminated shell `eval` and unvalidated environment injection in `scripts/appctl`.
|
||||
- Enforced `Core/config/deployments.yaml` as sole GitOps registry authority, removing dynamic host discovery.
|
||||
- Hardened Compose AST validator against relative traversal, cross-tenant mounts, and host capability escapes.
|
||||
- Unified manifest parsing on `core_manifest.py` and enforced fail-closed `cmd_resolve` behavior.
|
||||
|
||||
This plan resolves the six architectural prerequisites necessary to implement P4 as a secure, fail-closed operational control plane rather than discovering boundaries ad-hoc during coding.
|
||||
|
||||
@@ -41,8 +46,8 @@ This plan resolves the six architectural prerequisites necessary to implement P4
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| [`scripts/appctl`](../../scripts/appctl) | Bash | **Active CLI Client** | CLI entry point; secret environment sourcing (`homeserver.env`, `traefik-deployments.env`); resolves metadata via engine; directly runs `docker compose` and `git pull` subprocesses. |
|
||||
| [`scripts/appctl_engine.py`](../../scripts/appctl_engine.py) | Python 3 | **Authoritative Engine** | Domain models (`SitesApp`, `CoreService`); schema v1.0 parsing (`core_manifest.py`); two-axis inspection (`provenance.py`); SSL cert inspection; Homepage compilation; metadata serialization (`resolve`). |
|
||||
| [`scripts/appctl_engine_v2.py`](../../scripts/appctl_engine_v2.py) | Python 3 | **Compatibility Shim** | Thin backward-compatibility wrapper re-exporting all symbols from `appctl_engine.py`. No unique domain logic. |
|
||||
| [`scripts/core_manifest.py`](../../scripts/core_manifest.py) | Python 3 | **Schema Library** | Strongly-typed Manifest dataclasses; transport validation (`https://`, `ssh://`, `git@`); ref semantics classification (`branch`, `tag`, `commit`). |
|
||||
|
||||
| [`scripts/provenance.py`](../../scripts/provenance.py) | Python 3 | **Provenance Library** | Two-axis status engine; local checkout inspection (`git status`, commit SHA); bounded upstream query (`git ls-remote` with 10s timeout). |
|
||||
| [`scripts/gitops_dispatcher.py`](../../scripts/gitops_dispatcher.py) | Python 3 | **Independent Service** | Webhook listener (port 9000); HMAC validation; flock serialization; independent AST validation; executes its own `docker compose` and `git pull` subprocesses. |
|
||||
|
||||
@@ -79,7 +84,8 @@ This plan resolves the six architectural prerequisites necessary to implement P4
|
||||
|
||||
### D. Architectural Findings & Migration Deductions
|
||||
|
||||
1. **V1 Engine is Fully Superseded**: `scripts/appctl_engine.py` is now identical to the modern dataclass implementation. `scripts/appctl_engine_v2.py` is merely an alias and can be deprecated/retired once the daemon is active.
|
||||
1. **V1 Engine is Fully Superseded & V2 Shim Retired**: `scripts/appctl_engine.py` is the single authoritative metadata engine. The `scripts/appctl_engine_v2.py` compatibility shim has been retired.
|
||||
|
||||
2. **Duplicated Operational Logic in GitOps**: `scripts/gitops_dispatcher.py` and `scripts/appctl` maintain **separate, duplicate implementations** of `git pull` and `docker compose up`. This violates Invariant #1 (*Single Operational Truth*). In P4, GitOps webhook handlers must delegate execution to the control-plane daemon via its internal client.
|
||||
3. **Environment Injection Vulnerability in Bash**: The current Bash CLI constructs shell exports dynamically using `eval "$(python3 ...)"`. The daemon replaces this subprocess string interpolation with in-process, typed dictionary manipulation.
|
||||
|
||||
@@ -112,7 +118,18 @@ Every client (local CLI, remote CLI, GitOps dispatcher, and future Operations UI
|
||||
• platform.health
|
||||
```
|
||||
|
||||
### B. Typed Request and Response Models
|
||||
### B. Typed Request and Response Models (Target Architecture: Pydantic v2 Pipeline)
|
||||
|
||||
All control plane API requests, responses, error payloads, and workload manifest schemas will be defined and validated through **Pydantic v2** (`pydantic.BaseModel`, `pydantic.Field`, `ConfigDict(extra="forbid", strict=True)`). While the dependency has been integrated into runtime environments, the schema migration and model definitions are the first implementation deliverables of Milestone P4:
|
||||
|
||||
- **Runtime Validation Boundary**: Incoming payloads over both Unix Domain Socket and HTTP endpoints are validated at the transport boundary before reaching the operational router.
|
||||
- **Fail-Closed Extra Fields (`extra="forbid"`)**: Rejects any undeclared or unknown fields immediately.
|
||||
- **Strict Typing vs. Coercion Rules**:
|
||||
- *Strict Validation*: Operations (`operation`), target identifiers (`target`), boolean flags (`recreate`, `remove_orphans`, `visible`, `auth`), and authentication tokens require strict types (`strict=True` or `StrictStr`, `StrictBool`). Coercion (e.g. converting `"true"` or `1` to `True`, or floats to ints) is strictly forbidden for control plane commands to prevent ambiguous execution.
|
||||
- *Permitted Coercion / Sanitization*: Only explicitly defined string stripping/normalization (e.g. whitespace trimming) is permitted via field validators.
|
||||
- **Structured Error Transformation**: Transport handlers intercept `pydantic.ValidationError` and map it to canonical `ERR_VALIDATION_FAILED` (`400 Bad Request`) responses.
|
||||
- **Information Disclosure Prevention**: Error details must include field names and validation issue descriptions, but must strictly redact and omit raw input values to prevent leaking secrets, credentials, or host filesystem paths.
|
||||
- **Contract Enforcement**: Manifest definitions in `core_manifest.py` migrate to Pydantic v2 models, guaranteeing uniform schema enforcement across the CLI, daemon, and GitOps engines.
|
||||
|
||||
All requests and responses use strict JSON payloads with explicit schema versioning (`version: "1.0"`):
|
||||
|
||||
@@ -172,7 +189,7 @@ The platform defines three hierarchical authorization tiers:
|
||||
|
||||
| Role | Permitted Operations | Typical Principals |
|
||||
| :--- | :--- | :--- |
|
||||
| `homelab-admin` | All operations (including Core platform mutation, daemon reload, secret regeneration). | Break-glass admin token, human interactive operator (`kiskaadee`). |
|
||||
| `homelab-admin` | All operations (including Core platform mutation, daemon reload, secret regeneration). | Break-glass admin token, human interactive operator (`operator`). |
|
||||
| `homelab-operator` | Workload mutations (`deploy`, `stop`, `restart`, `update`, `pull`, `sync_homepage`). Cannot mutate Core platform infrastructure. | GitOps webhook runner token, automation scripts. |
|
||||
| `homelab-viewer` | Read-only operations (`list`, `get`, `resolve`, `config`, `logs`, `ssl`, `health`). Zero mutations permitted. | Homepage dashboard status monitor, read-only diagnostic CLI. |
|
||||
|
||||
@@ -227,14 +244,25 @@ Following the pattern established in Milestone P2 for `homelab-gitops.service`,
|
||||
- `ProtectSystem = "strict"`: Host filesystem is read-only.
|
||||
- `ProtectHome = "read-only"`: User home is read-only by default.
|
||||
- `ReadWritePaths`: Explicitly allowlisted writable roots:
|
||||
- `/home/kiskaadee/Sites` (workload definitions and Git checkouts)
|
||||
- `/home/kiskaadee/var/lib/homelab` (workload persistent state roots)
|
||||
- `/home/kiskaadee/Core/config/homepage` (Homepage services.yaml destination)
|
||||
- `/var/log/homelab/appctl` or `/home/kiskaadee/.local/state/homelab/appctl` (audit log directory)
|
||||
- `/home/<operator>/Sites` (workload definitions and Git checkouts)
|
||||
- `/home/<operator>/var/lib/homelab` (workload persistent state roots)
|
||||
- `/home/<operator>/Core/config/homepage` (Homepage services.yaml destination)
|
||||
- `/var/log/homelab/appctl` or `/home/<operator>/.local/state/homelab/appctl` (audit log directory)
|
||||
- `/run/homelab` (socket runtime directory)
|
||||
- `PrivateTmp = true`: Isolated temporary directories.
|
||||
- `NoNewPrivileges = true`: Disallows privilege escalation.
|
||||
|
||||
### C. Platform Genericism & Domain Decoupling
|
||||
Per Invariant #8 in `AGENTS.md`, the control plane and all platform components must remain strictly instance-agnostic:
|
||||
- **No Hardcoded Domains**: Personal domain names must never appear hardcoded in Python modules, NixOS definitions, or default configurations.
|
||||
- **Canonical Precedence & Dynamic Resolution**: All domain resolutions follow strict, fail-closed precedence:
|
||||
1. `HOMELAB_DOMAIN` (Primary platform apex domain)
|
||||
2. `DOMAIN_SUFFIX` (Secondary routing suffix fallback)
|
||||
3. `DOMAIN` (Legacy environment fallback)
|
||||
If none are set, the platform fails closed rather than defaulting to hardcoded values.
|
||||
- **Generic Placeholders & Test Fixtures**: Test fixtures, documentation examples, and schema defaults must use RFC 2606 reserved domains (`example.com`, `example.org`, `example.test`).
|
||||
|
||||
|
||||
---
|
||||
|
||||
## 5. Audit Telemetry Semantics (P4 Prerequisite)
|
||||
@@ -251,7 +279,7 @@ Every operation lifecycle event is emitted as a structured JSON object to `audit
|
||||
"timestamp": "2026-10-13T18:32:05.112Z",
|
||||
"phase": "COMPLETED",
|
||||
"principal": {
|
||||
"identity": "kiskaadee",
|
||||
"identity": "operator",
|
||||
"role": "homelab-admin",
|
||||
"token_id": "tok_99fa1b",
|
||||
"auth_method": "bearer_token"
|
||||
@@ -309,4 +337,5 @@ Before marking Milestone P4 complete, the following automated regression suite m
|
||||
| **Truthful Error Reporting** | `test_execution_failure_audit`: Mock failing Docker compose run (exit 1). Assert daemon returns `ERR_EXECUTION_FAILED` (500) and records `phase: FAILED` in audit log. | Reject PR |
|
||||
| **Audit Persistence Gate** | `test_audit_failure_blocks_mutation`: Mock read-only audit log. Assert mutating command fails closed with zero Docker invocations. | Block Release |
|
||||
| **Daemon Crash Recovery** | `test_daemon_restart_preserves_state`: Kill and restart `homelab-appctl.service`. Assert running container stacks are undisturbed and desired Git state remains intact. | Reject PR |
|
||||
| **Existing Invariant Regression** | Run `./scripts/test`: All 86 existing unit, security, and nix flake tests pass with 0 regressions. | Block Merge |
|
||||
| **Existing Invariant Regression** | Run `./scripts/test`: All 121 existing unit, security, structural, and Nix flake sandbox tests pass with 0 regressions. | Block Merge |
|
||||
|
||||
@@ -43,7 +43,7 @@ This document explains the secrets distribution architecture, runtime projection
|
||||
|
||||
### A. Core Platform Environment (`/run/secrets/homeserver.env`)
|
||||
Generated by `nixos/modules/homeserver.nix`. Supplies credentials to the Core Compose stack:
|
||||
* `DOMAIN`: Apex domain (`roadtotech.me`).
|
||||
* `DOMAIN`: Apex domain (e.g., `example.com`).
|
||||
* `DYNU_API_KEY`: API key for Dynu DNS-01 ACME Let's Encrypt validation.
|
||||
* `ACME_EMAIL`: Account email for Let's Encrypt certificates.
|
||||
* `AUTHELIA_SESSION_SECRET`: Authelia cookie encryption secret.
|
||||
@@ -98,7 +98,7 @@ sudo nixos-rebuild switch --flake ~/Core#server
|
||||
Homelab Core separates **user identity** from **static platform secrets**:
|
||||
|
||||
* **Static Secrets**: Stored in `nixos/secrets.yaml` (system API keys, JWT secrets, database passwords).
|
||||
* **Dynamic User Directory**: User accounts, credentials, and group memberships are managed live in **LLDAP** (`https://users.roadtotech.me`). User account updates do not require editing `secrets.yaml` or rebuilding NixOS.
|
||||
* **Dynamic User Directory**: User accounts, credentials, and group memberships are managed live in **LLDAP** (`https://users.${HOMELAB_DOMAIN}`). User account updates do not require editing `secrets.yaml` or rebuilding NixOS.
|
||||
* **Authelia Integration**: Authelia queries LLDAP over LDAP (`ldap://lldap:3890`) at runtime using credentials projected from `/run/secrets/homeserver.env`.
|
||||
|
||||
---
|
||||
@@ -114,7 +114,7 @@ Homelab Core separates **user identity** from **static platform secrets**:
|
||||
| **User Directory** | `~/Core/config/lldap/data/` | ❌ No | LLDAP SQLite database (`users.db`) |
|
||||
| **Auth Database** | `~/Core/config/authelia/db.sqlite3` | ❌ No | Authelia session database |
|
||||
| **Mail Data & Keys** | `~/Core/config/stalwart/` | ❌ No | Stalwart mail storage, DKIM keys, mailboxes |
|
||||
| **Webmail Storage** | `~/Core/config/snappymail/data/` | ❌ No | SnappyMail configuration and sessions |
|
||||
| **Workload State Root** | `~/var/lib/homelab/<app>/` | ❌ No | Per-workload persistent runtime state (e.g., `snappymail`) |
|
||||
| **Container Volumes** | Docker volume `dozzle_data` | ❌ No | Dozzle UI preferences and state |
|
||||
| **DDNS History** | `/var/lib/dynu/ip_history.jsonl` | ❌ No | Historical WAN IP transitions log |
|
||||
| **GitOps State** | `~/.local/state/homelab/gitops/` | ❌ No | Deployment locks, pending JSONs, status logs |
|
||||
+6
-4
@@ -12,10 +12,10 @@ When provisioning bare-metal hardware or a virtual machine from a NixOS Minimal
|
||||
1. Partition and format disks according to `nixos/hardware-configuration.nix` (e.g. boot EFI partition and root filesystem).
|
||||
2. Mount partitions under `/mnt`.
|
||||
3. **Restore Host Secrets Key**: Copy the host SSH private key to `/mnt/etc/ssh/ssh_host_ed25519_key` (mode `0600`). This is required because `sops-nix` decrypts `nixos/secrets.yaml` during system activation.
|
||||
4. Clone the Core repository to `/mnt/home/kiskaadee/Core`.
|
||||
4. Clone the Core repository to `/mnt/home/<operator>/Core`.
|
||||
5. Run the NixOS installer:
|
||||
```bash
|
||||
nixos-install --flake /mnt/home/kiskaadee/Core#server
|
||||
nixos-install --flake /mnt/home/<operator>/Core#server
|
||||
reboot
|
||||
```
|
||||
|
||||
@@ -69,7 +69,7 @@ docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
|
||||
```
|
||||
|
||||
### Step 6: Initialize LLDAP Directory
|
||||
1. Navigate to `https://users.roadtotech.me`.
|
||||
1. Navigate to `https://users.${HOMELAB_DOMAIN}` (e.g., `https://users.example.com`).
|
||||
2. Authenticate using `admin` and the password configured in `nixos/secrets.yaml` (`lldap/admin_password`).
|
||||
3. Create standard user accounts and assign them to required groups.
|
||||
|
||||
@@ -89,10 +89,11 @@ git init
|
||||
### Step 2: Create `app.yaml` Manifest
|
||||
Create `~/Sites/homelab-myapp/app.yaml`:
|
||||
```yaml
|
||||
schema_version: "1.0"
|
||||
name: "myapp"
|
||||
aliases:
|
||||
- "app"
|
||||
domain: "myapp.roadtotech.me"
|
||||
domain: "myapp.example.com"
|
||||
description: "My New Application Service"
|
||||
visible: true
|
||||
auth: false
|
||||
@@ -104,6 +105,7 @@ env:
|
||||
|
||||
deployment:
|
||||
branch: "main"
|
||||
strategy: "compose"
|
||||
actions:
|
||||
- git_pull
|
||||
- compose_up
|
||||
|
||||
Generated
+7
-7
@@ -2,11 +2,11 @@
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1791734076,
|
||||
"narHash": "sha256-0dNcyVeoD61zhucIpt5BAQ+ytd6JzF641Z+A9bgltLo=",
|
||||
"rev": "7fd4004d0511991fff3a0524856a9be09e28c5f0",
|
||||
"lastModified": 1791956154,
|
||||
"narHash": "sha256-gJX2+xcImvxBCI3bp7zXKLUX2AwsdTxMgJ1UX/5Hm/o=",
|
||||
"rev": "55bfb4d7437bd4e09ab7cba58a43bd68eb310044",
|
||||
"type": "tarball",
|
||||
"url": "https://releases.nixos.org/nixos/unstable/nixos-26.11pre1090327.7fd4004d0511/nixexprs.tar.zst"
|
||||
"url": "https://releases.nixos.org/nixos/unstable/nixos-26.11pre1092090.55bfb4d7437b/nixexprs.tar.zst"
|
||||
},
|
||||
"original": {
|
||||
"type": "tarball",
|
||||
@@ -26,11 +26,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1791710405,
|
||||
"narHash": "sha256-mVD4XIc5JkqMW2K04IkFUzHgHmyJZlzw5ktfgMDCbKU=",
|
||||
"lastModified": 1792056300,
|
||||
"narHash": "sha256-YU1LjDe1o2Ymg5zEiCHbmMXLkDCtxHQRiVqZ3nC5GGk=",
|
||||
"owner": "Mic92",
|
||||
"repo": "sops-nix",
|
||||
"rev": "ee48786c6f9160d2c1a084aac841f68195b8420c",
|
||||
"rev": "44931708c62937c2b1bf7953902989fa5bb9ee1b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
description = "Homelab Core — Turnkey Declarative NixOS Appliance for roadtotech.me";
|
||||
description = "Homelab Core — Turnkey Declarative NixOS Appliance";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "https://channels.nixos.org/nixos-unstable/nixexprs.tar.zst";
|
||||
@@ -14,6 +14,12 @@
|
||||
let
|
||||
system = "x86_64-linux";
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
pythonEnv = pkgs.python3.withPackages (ps: with ps; [
|
||||
pyyaml
|
||||
types-pyyaml
|
||||
pytest
|
||||
pydantic
|
||||
]);
|
||||
in
|
||||
{
|
||||
nixosConfigurations.server = nixpkgs.lib.nixosSystem {
|
||||
@@ -27,16 +33,16 @@
|
||||
|
||||
devShells.${system}.default = pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
(python3.withPackages (ps: with ps; [
|
||||
pyyaml
|
||||
types-pyyaml
|
||||
pytest
|
||||
]))
|
||||
pythonEnv
|
||||
pyright
|
||||
ruff
|
||||
];
|
||||
shellHook = ''
|
||||
git config core.hooksPath .githooks 2>/dev/null || true
|
||||
if [ -d .venv ] && [ ! -L .venv ]; then
|
||||
rm -rf .venv
|
||||
fi
|
||||
ln -sfn ${pythonEnv} .venv
|
||||
'';
|
||||
};
|
||||
|
||||
@@ -44,9 +50,7 @@
|
||||
test-suite = pkgs.runCommand "core-tests" {
|
||||
nativeBuildInputs = with pkgs; [
|
||||
git
|
||||
python3
|
||||
python3Packages.pytest
|
||||
python3Packages.pyyaml
|
||||
pythonEnv
|
||||
ruff
|
||||
];
|
||||
} ''
|
||||
|
||||
@@ -127,9 +127,10 @@
|
||||
# Secrets tooling (required for sops-nix secret decryption and manual re-encryption)
|
||||
sops
|
||||
age
|
||||
# Python runtime (hard requirement for appctl and gitops_dispatcher.py)
|
||||
# Python runtime (hard requirement for appctl, core_manifest, and gitops_dispatcher.py)
|
||||
(python3.withPackages (ps: with ps; [
|
||||
pyyaml
|
||||
pydantic
|
||||
]))
|
||||
# Modern shell utilities
|
||||
eza # ls replacement
|
||||
|
||||
@@ -66,7 +66,15 @@
|
||||
wants = [ "network-online.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
||||
path = with pkgs; [ git docker docker-compose python3 coreutils bash openssh ];
|
||||
path = with pkgs; [
|
||||
git
|
||||
docker
|
||||
docker-compose
|
||||
(python3.withPackages (ps: with ps; [ pyyaml pydantic ]))
|
||||
coreutils
|
||||
bash
|
||||
openssh
|
||||
];
|
||||
|
||||
environment = {
|
||||
GITOPS_SECRET_FILE = config.sops.secrets."gitops/webhook_secret".path;
|
||||
|
||||
+8
-4
@@ -3,10 +3,14 @@ name = "homelab-core"
|
||||
version = "0.1.0"
|
||||
description = "Homelab Core platform and orchestration"
|
||||
requires-python = ">=3.13"
|
||||
dependencies = []
|
||||
dependencies = [
|
||||
"pyyaml>=6.0",
|
||||
"pydantic>=2.0,<3.0",
|
||||
]
|
||||
|
||||
[tool.pyright]
|
||||
include = ["scripts"]
|
||||
extraPaths = ["scripts"]
|
||||
exclude = [
|
||||
"scripts/appctl_engine.py",
|
||||
]
|
||||
venvPath = "."
|
||||
venv = ".venv"
|
||||
|
||||
+33
-24
@@ -8,6 +8,7 @@ set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
ENGINE="$SCRIPT_DIR/appctl_engine.py"
|
||||
PYTHON_BIN="${PYTHON_BIN:-python3}"
|
||||
ENV_FILE="/run/secrets/rendered/traefik-deployments.env"
|
||||
if [ ! -f "$ENV_FILE" ] && [ -f "/run/secrets/traefik-deployments.env" ]; then
|
||||
ENV_FILE="/run/secrets/traefik-deployments.env"
|
||||
@@ -36,7 +37,8 @@ if [ -f "$ENV_FILE" ]; then
|
||||
fi
|
||||
|
||||
# Lock the homelab root domain before setup_app_env can mutate $DOMAIN
|
||||
export HOMELAB_DOMAIN="${HOMELAB_DOMAIN:-${DOMAIN_SUFFIX:-${DOMAIN:-roadtotech.me}}}"
|
||||
# Canonical precedence: HOMELAB_DOMAIN -> DOMAIN_SUFFIX -> DOMAIN
|
||||
export HOMELAB_DOMAIN="${HOMELAB_DOMAIN:-${DOMAIN_SUFFIX:-${DOMAIN:-}}}"
|
||||
|
||||
# Show help usage
|
||||
show_help() {
|
||||
@@ -63,7 +65,7 @@ show_help() {
|
||||
setup_app_env() {
|
||||
local query="$1"
|
||||
local resolved_json
|
||||
resolved_json=$(python3 "$ENGINE" resolve "$query" 2>/dev/null || true)
|
||||
resolved_json=$("$PYTHON_BIN" "$ENGINE" resolve "$query" || true)
|
||||
|
||||
if [ -z "$resolved_json" ]; then
|
||||
echo "❌ Error: Service '$query' not found under $SITES_DIR or Core"
|
||||
@@ -71,10 +73,10 @@ setup_app_env() {
|
||||
fi
|
||||
|
||||
# Extract fields via python json
|
||||
TARGET_TYPE=$(python3 -c "import json, sys; d=json.loads(sys.argv[1]); print(d.get('type', 'app'))" "$resolved_json")
|
||||
APP_DIR=$(python3 -c "import json, sys; d=json.loads(sys.argv[1]); print(d['dir_path'])" "$resolved_json")
|
||||
CANONICAL_NAME=$(python3 -c "import json, sys; d=json.loads(sys.argv[1]); print(d['name'])" "$resolved_json")
|
||||
TARGET_CONTAINER=$(python3 -c "import json, sys; d=json.loads(sys.argv[1]); print(d.get('container', ''))" "$resolved_json")
|
||||
TARGET_TYPE=$("$PYTHON_BIN" -c "import json, sys; d=json.loads(sys.argv[1]); print(d.get('type', 'app'))" "$resolved_json")
|
||||
APP_DIR=$("$PYTHON_BIN" -c "import json, sys; d=json.loads(sys.argv[1]); print(d['dir_path'])" "$resolved_json")
|
||||
CANONICAL_NAME=$("$PYTHON_BIN" -c "import json, sys; d=json.loads(sys.argv[1]); print(d['name'])" "$resolved_json")
|
||||
TARGET_CONTAINER=$("$PYTHON_BIN" -c "import json, sys; d=json.loads(sys.argv[1]); print(d.get('container', ''))" "$resolved_json")
|
||||
|
||||
if [ "$TARGET_TYPE" = "core" ] || [ "$TARGET_TYPE" = "core_service" ]; then
|
||||
if [ ! -d "$CORE_DIR" ]; then
|
||||
@@ -92,13 +94,13 @@ setup_app_env() {
|
||||
return
|
||||
fi
|
||||
|
||||
RESOLVED_DOMAIN=$(python3 -c "import json, sys; d=json.loads(sys.argv[1]); print(d['domain'])" "$resolved_json")
|
||||
RESOLVED_DOMAIN=$("$PYTHON_BIN" -c "import json, sys; d=json.loads(sys.argv[1]); print(d['domain'])" "$resolved_json")
|
||||
|
||||
# 1. Base infrastructure defaults
|
||||
export PROXY_NETWORK="${PROXY_NETWORK:-proxy-net}"
|
||||
export NETWORK_NAME="${NETWORK_NAME:-$PROXY_NETWORK}"
|
||||
export CERT_RESOLVER="${CERT_RESOLVER:-myresolver}"
|
||||
export DOMAIN_SUFFIX="${DOMAIN_SUFFIX:-roadtotech.me}"
|
||||
export DOMAIN_SUFFIX="${DOMAIN_SUFFIX:-$HOMELAB_DOMAIN}"
|
||||
|
||||
# 2. Canonical application identity
|
||||
export SERVICE_NAME="$CANONICAL_NAME"
|
||||
@@ -107,14 +109,21 @@ setup_app_env() {
|
||||
export DOMAIN="$RESOLVED_DOMAIN"
|
||||
|
||||
# 3. Dynamic environment variables from app.yaml (e.g. PROJECT_PATH, MEDIA_PATH, etc.)
|
||||
eval "$(python3 -c "
|
||||
import json, sys
|
||||
while IFS= read -r -d '' k && IFS= read -r -d '' v; do
|
||||
export "$k=$v"
|
||||
done < <("$PYTHON_BIN" -c "
|
||||
import json, re, sys
|
||||
RESERVED = {'PATH', 'LD_PRELOAD', 'IFS', 'SHELL', 'USER', 'CORE_DIR', 'SITES_DIR', 'ENV_FILE', 'HOMESERVER_ENV'}
|
||||
d = json.loads(sys.argv[1])
|
||||
env_dict = d.get('env', {})
|
||||
for k, v in env_dict.items():
|
||||
if v != '' and v is not None:
|
||||
print(f'export {k}=\"{v}\"')
|
||||
" "$resolved_json")"
|
||||
if isinstance(env_dict, dict):
|
||||
for k, v in env_dict.items():
|
||||
k_str = str(k).strip()
|
||||
if not re.match(r'^[a-zA-Z_][a-zA-Z0-9_]*$', k_str) or k_str in RESERVED:
|
||||
continue
|
||||
if v is not None and v != '':
|
||||
sys.stdout.buffer.write(k_str.encode('utf-8') + b'\0' + str(v).encode('utf-8') + b'\0')
|
||||
" "$resolved_json")
|
||||
|
||||
# 4. Source local .env if present
|
||||
if [ -f "$APP_DIR/.env" ]; then
|
||||
@@ -143,23 +152,23 @@ APP=$2
|
||||
|
||||
case "$COMMAND" in
|
||||
list|status)
|
||||
python3 "$ENGINE" list "${@:2}"
|
||||
"$PYTHON_BIN" "$ENGINE" list "${@:2}"
|
||||
;;
|
||||
ssl)
|
||||
python3 "$ENGINE" ssl "${@:2}"
|
||||
"$PYTHON_BIN" "$ENGINE" ssl "${@:2}"
|
||||
;;
|
||||
info)
|
||||
if [ -z "$APP" ]; then echo "❌ Error: Service name required"; exit 1; fi
|
||||
python3 "$ENGINE" info "${@:2}"
|
||||
"$PYTHON_BIN" "$ENGINE" info "${@:2}"
|
||||
;;
|
||||
sync)
|
||||
python3 "$ENGINE" sync "${@:2}"
|
||||
"$PYTHON_BIN" "$ENGINE" sync "${@:2}"
|
||||
;;
|
||||
complete)
|
||||
python3 "$ENGINE" complete "${@:2}"
|
||||
"$PYTHON_BIN" "$ENGINE" complete "${@:2}"
|
||||
;;
|
||||
resolve)
|
||||
python3 "$ENGINE" resolve "${@:2}"
|
||||
"$PYTHON_BIN" "$ENGINE" resolve "${@:2}"
|
||||
;;
|
||||
completion)
|
||||
cat <<'EOF'
|
||||
@@ -234,7 +243,7 @@ EOF
|
||||
else
|
||||
echo "🚀 Starting $CANONICAL_NAME ($APP_DIR)..."
|
||||
cd "$APP_DIR" && docker compose up -d --remove-orphans "${@:3}"
|
||||
python3 "$ENGINE" sync >/dev/null 2>&1 || true
|
||||
"$PYTHON_BIN" "$ENGINE" sync >/dev/null 2>&1 || true
|
||||
fi
|
||||
;;
|
||||
down)
|
||||
@@ -249,7 +258,7 @@ EOF
|
||||
else
|
||||
echo "🛑 Stopping $CANONICAL_NAME ($APP_DIR)..."
|
||||
cd "$APP_DIR" && docker compose down "${@:3}"
|
||||
python3 "$ENGINE" sync >/dev/null 2>&1 || true
|
||||
"$PYTHON_BIN" "$ENGINE" sync >/dev/null 2>&1 || true
|
||||
fi
|
||||
;;
|
||||
restart)
|
||||
@@ -269,7 +278,7 @@ EOF
|
||||
else
|
||||
echo "🔄 Restarting $CANONICAL_NAME ($APP_DIR)..."
|
||||
cd "$APP_DIR" && docker compose down && docker compose up -d "${@:3}"
|
||||
python3 "$ENGINE" sync >/dev/null 2>&1 || true
|
||||
"$PYTHON_BIN" "$ENGINE" sync >/dev/null 2>&1 || true
|
||||
fi
|
||||
;;
|
||||
update)
|
||||
@@ -310,7 +319,7 @@ EOF
|
||||
echo "🚀 Recreating container stack..."
|
||||
cd "$APP_DIR" && docker compose up -d --remove-orphans "${@:3}"
|
||||
|
||||
python3 "$ENGINE" sync >/dev/null 2>&1 || true
|
||||
"$PYTHON_BIN" "$ENGINE" sync >/dev/null 2>&1 || true
|
||||
echo "✨ $CANONICAL_NAME successfully updated!"
|
||||
;;
|
||||
pull)
|
||||
|
||||
+128
-148
@@ -19,7 +19,13 @@ from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
import yaml
|
||||
from core_manifest import Manifest, ManifestValidationError, parse_manifest
|
||||
from core_manifest import (
|
||||
HomepageConfig,
|
||||
Manifest,
|
||||
ManifestValidationError,
|
||||
SourceConfig,
|
||||
parse_manifest,
|
||||
)
|
||||
from provenance import (
|
||||
get_local_checkout_status,
|
||||
inspect_workload_two_axis,
|
||||
@@ -50,8 +56,8 @@ def validate_environment() -> None:
|
||||
|
||||
if not HOMELAB_DOMAIN:
|
||||
errors.append(
|
||||
"• Missing 'HOMELAB_DOMAIN' (or 'DOMAIN') environment variable.\n"
|
||||
" Please export it (e.g. export HOMELAB_DOMAIN='roadtotech.me') or set it in your environment file."
|
||||
"• Missing 'HOMELAB_DOMAIN' (or 'DOMAIN_SUFFIX' / 'DOMAIN') environment variable.\n"
|
||||
" Please export it (e.g. export HOMELAB_DOMAIN='example.com') or set it in your environment file."
|
||||
)
|
||||
|
||||
if not os.path.isdir(CORE_DIR):
|
||||
@@ -64,39 +70,15 @@ def validate_environment() -> None:
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
class ManifestError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
@dataclass
|
||||
class HomepageConfig:
|
||||
title: str
|
||||
group: str = "Applications"
|
||||
icon: str = "default.png"
|
||||
container: str = ""
|
||||
weight: int = 50
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
return asdict(self)
|
||||
|
||||
|
||||
@dataclass
|
||||
class SourceConfig:
|
||||
"""Upstream source provenance descriptor."""
|
||||
type: str = "git" # "git"
|
||||
url: str = "" # e.g., "https://git.roadtotech.me/kiskaadee/bitetrack.git"
|
||||
ref: str = "main" # Branch (e.g. "main"), tag (e.g. "v1.0.0"), or commit SHA
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
return asdict(self)
|
||||
ManifestError = ManifestValidationError
|
||||
|
||||
|
||||
@dataclass
|
||||
class App:
|
||||
name: str # Canonical identifier (e.g., "traefik", "jellyfin")
|
||||
description: str # Human-readable summary for dashboards and CLI info
|
||||
domain: str # Routing FQDN (e.g., "auth.roadtotech.me") or "internal".
|
||||
dir_path: str # Filesystem directory (CORE_DIR for Core, or ~/Sites/<app> for Sites).
|
||||
description: str = "" # Human-readable summary for dashboards and CLI info
|
||||
domain: str = "" # Routing FQDN (e.g., "auth.example.com") or "internal".
|
||||
dir_path: str = "" # Filesystem directory (CORE_DIR for Core, or ~/Sites/<app> for Sites).
|
||||
|
||||
@property
|
||||
def is_internal(self) -> bool:
|
||||
@@ -131,116 +113,80 @@ class SitesApp(App):
|
||||
env: dict[str, Any] = field(default_factory=dict) # Environment variable overrides
|
||||
homepage: HomepageConfig | None = None # Dashboard Card Configuration
|
||||
manifest_error: str | None = None # Captured syntax/loading errors
|
||||
manifest_obj: Manifest | None = None # Parsed authoritative Manifest
|
||||
app_type: str = "app"
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
"""Serialize for JSON consumption by scripts/appctl"""
|
||||
data = asdict(self)
|
||||
data.pop("manifest_obj", None)
|
||||
if self.source is not None:
|
||||
data["source"] = self.source.to_dict() if hasattr(self.source, "to_dict") else self.source.model_dump()
|
||||
if self.homepage is not None:
|
||||
data["homepage"] = self.homepage.to_dict() if hasattr(self.homepage, "to_dict") else self.homepage.model_dump()
|
||||
data["type"] = getattr(self, "app_type", "app")
|
||||
return data
|
||||
|
||||
def load_manifest(manifest_path: str) -> dict[str, Any]:
|
||||
"""Load and parse the app manifest file."""
|
||||
if not os.path.isfile(manifest_path):
|
||||
raise FileNotFoundError(f"Manifest file not found at {manifest_path}")
|
||||
|
||||
try:
|
||||
with open(manifest_path, "r", encoding="utf-8") as file:
|
||||
manifest_data = yaml.safe_load(file) or {}
|
||||
except (yaml.YAMLError, OSError) as err:
|
||||
raise ManifestError(f"YAML parsing failed: {err}") from err
|
||||
|
||||
if not isinstance(manifest_data, dict):
|
||||
raise ManifestError(f"Invalid manifest root: expected `dict`, got `{type(manifest_data).__name__}`")
|
||||
|
||||
return manifest_data
|
||||
|
||||
|
||||
def sites_app_from_manifest(
|
||||
app_dir: str,
|
||||
manifest: dict[str, Any],
|
||||
manifest: Manifest | dict[str, Any] | None = None,
|
||||
manifest_error: str | None = None,
|
||||
) -> SitesApp:
|
||||
"""Construct and normalize a SitesApp domain model from raw manifest data."""
|
||||
"""Construct and normalize a SitesApp domain model from an authoritative Manifest or raw data."""
|
||||
raw_dir_name = os.path.basename(app_dir)
|
||||
canonical_name = str(manifest.get("name") or raw_dir_name.replace("homelab-", ""))
|
||||
|
||||
# Normalize aliases into list[str]
|
||||
raw_aliases = manifest.get("aliases") or []
|
||||
if isinstance(raw_aliases, str):
|
||||
aliases = [raw_aliases]
|
||||
elif isinstance(raw_aliases, list):
|
||||
aliases = [str(alias) for alias in raw_aliases]
|
||||
else:
|
||||
aliases = []
|
||||
|
||||
# Homepage card normalization
|
||||
homepage_config: HomepageConfig | None = None
|
||||
raw_hp = manifest.get("homepage")
|
||||
if isinstance(raw_hp, dict):
|
||||
homepage_config = HomepageConfig(
|
||||
title=str(raw_hp.get("title") or canonical_name),
|
||||
group=str(raw_hp.get("group") or "Applications"),
|
||||
icon=str(raw_hp.get("icon") or "default.png"),
|
||||
container=str(raw_hp.get("container") or canonical_name),
|
||||
weight=int(raw_hp.get("weight", 50)),
|
||||
)
|
||||
|
||||
if isinstance(manifest, Manifest):
|
||||
has_compose = (
|
||||
os.path.isfile(os.path.join(app_dir, "docker-compose.yaml")) or
|
||||
os.path.isfile(os.path.join(app_dir, "docker-compose.yml"))
|
||||
)
|
||||
|
||||
# Manifest Data parsing
|
||||
raw_desc = manifest.get("description")
|
||||
app_desc: str = str(raw_desc) if raw_desc is not None else ""
|
||||
|
||||
raw_dom = manifest.get("domain")
|
||||
app_dom = str(raw_dom) if raw_dom is not None else f"{canonical_name}.{HOMELAB_DOMAIN}"
|
||||
|
||||
app_net = manifest.get("networks")
|
||||
if not isinstance(app_net, list):
|
||||
app_net = ["proxy-net"]
|
||||
|
||||
app_env = manifest.get("env")
|
||||
if not isinstance(app_env, dict):
|
||||
app_env = {}
|
||||
|
||||
def _as_bool(value: Any, default: bool) -> bool:
|
||||
if isinstance(value, bool):
|
||||
return value
|
||||
return default
|
||||
|
||||
app_vis = _as_bool(manifest.get("visible"), True)
|
||||
app_auth = _as_bool(manifest.get("auth"), True)
|
||||
|
||||
# Source provenance normalization
|
||||
source_config: SourceConfig | None = None
|
||||
raw_source = manifest.get("source")
|
||||
if isinstance(raw_source, dict):
|
||||
source_url = str(raw_source.get("url") or "")
|
||||
allowed_schemes = ("https://", "ssh://", "git@")
|
||||
if source_url:
|
||||
if not any(source_url.startswith(s) for s in allowed_schemes):
|
||||
err = f"Invalid source.url scheme: must start with {', '.join(allowed_schemes)}"
|
||||
manifest_error = f"{manifest_error}; {err}" if manifest_error else err
|
||||
else:
|
||||
source_config = SourceConfig(
|
||||
type=str(raw_source.get("type") or "git"),
|
||||
url=source_url,
|
||||
ref=str(raw_source.get("ref") or "main"),
|
||||
)
|
||||
|
||||
canonical_name = manifest.name
|
||||
domain = manifest.domain or f"{canonical_name}.{HOMELAB_DOMAIN}"
|
||||
return SitesApp(
|
||||
name=canonical_name,
|
||||
dir_name=raw_dir_name,
|
||||
source=source_config,
|
||||
description=app_desc,
|
||||
domain=app_dom,
|
||||
source=manifest.source,
|
||||
description=manifest.description,
|
||||
domain=domain,
|
||||
dir_path=app_dir,
|
||||
has_compose=has_compose,
|
||||
aliases=aliases,
|
||||
visible=app_vis,
|
||||
auth=app_auth,
|
||||
networks=app_net,
|
||||
env=app_env,
|
||||
homepage=homepage_config,
|
||||
aliases=list(manifest.aliases),
|
||||
visible=manifest.visible,
|
||||
auth=manifest.auth,
|
||||
networks=list(manifest.networks),
|
||||
env=dict(manifest.env),
|
||||
homepage=manifest.homepage,
|
||||
manifest_error=manifest_error,
|
||||
manifest_obj=manifest,
|
||||
)
|
||||
|
||||
if isinstance(manifest, dict):
|
||||
try:
|
||||
parsed = parse_manifest(manifest)
|
||||
return sites_app_from_manifest(app_dir, parsed, manifest_error)
|
||||
except ManifestValidationError as err:
|
||||
manifest_error = f"{manifest_error}; {err}" if manifest_error else str(err)
|
||||
canonical_name = str(manifest.get("name") or raw_dir_name.replace("homelab-", ""))
|
||||
return SitesApp(
|
||||
name=canonical_name,
|
||||
dir_name=raw_dir_name,
|
||||
domain=f"{canonical_name}.{HOMELAB_DOMAIN}",
|
||||
description=str(manifest.get("description", "")),
|
||||
dir_path=app_dir,
|
||||
manifest_error=manifest_error,
|
||||
)
|
||||
|
||||
canonical_name = raw_dir_name.replace("homelab-", "")
|
||||
return SitesApp(
|
||||
name=canonical_name,
|
||||
dir_name=raw_dir_name,
|
||||
description="",
|
||||
domain=f"{canonical_name}.{HOMELAB_DOMAIN}",
|
||||
dir_path=app_dir,
|
||||
manifest_error=manifest_error or "Missing app.yaml manifest",
|
||||
)
|
||||
|
||||
|
||||
@@ -256,15 +202,36 @@ def get_sites_apps(sites_dir: str | None = None) -> list[SitesApp]:
|
||||
if entry.startswith(".") or not os.path.isdir(app_dir):
|
||||
continue
|
||||
manifest_path = os.path.join(app_dir, "app.yaml")
|
||||
manifest: dict[str, Any] = {}
|
||||
manifest_error: str | None = None
|
||||
manifest_file = Path(manifest_path)
|
||||
|
||||
if not manifest_file.is_file():
|
||||
apps.append(
|
||||
sites_app_from_manifest(
|
||||
app_dir=app_dir,
|
||||
manifest=None,
|
||||
manifest_error="Missing app.yaml manifest",
|
||||
)
|
||||
)
|
||||
continue
|
||||
|
||||
if os.path.isfile(manifest_path):
|
||||
try:
|
||||
manifest = load_manifest(manifest_path=manifest_path)
|
||||
except ManifestError as err:
|
||||
manifest_error = str(err)
|
||||
apps.append(sites_app_from_manifest(app_dir, manifest, manifest_error))
|
||||
manifest_obj = parse_manifest(manifest_file)
|
||||
apps.append(sites_app_from_manifest(app_dir=app_dir, manifest=manifest_obj))
|
||||
except (ManifestValidationError, yaml.YAMLError, OSError, ValueError, KeyError) as err:
|
||||
raw_data = None
|
||||
with (
|
||||
contextlib.suppress(Exception),
|
||||
open(manifest_path, "r", encoding="utf-8") as f,
|
||||
):
|
||||
raw_data = yaml.safe_load(f)
|
||||
app_dict = raw_data if isinstance(raw_data, dict) else {}
|
||||
apps.append(
|
||||
sites_app_from_manifest(
|
||||
app_dir=app_dir,
|
||||
manifest=app_dict,
|
||||
manifest_error=str(err),
|
||||
)
|
||||
)
|
||||
|
||||
return apps
|
||||
|
||||
@@ -518,7 +485,8 @@ def check_ssl_cert(domain: str, port: int = 443, timeout: float = 3.0) -> dict[s
|
||||
socket.create_connection((domain, port), timeout=timeout) as sock,
|
||||
ctx.wrap_socket(sock, server_hostname=domain) as ssock,
|
||||
):
|
||||
cert = ssock.getpeercert() or {}
|
||||
raw_cert = ssock.getpeercert()
|
||||
cert = raw_cert if isinstance(raw_cert, dict) else {}
|
||||
|
||||
not_after_str = str(cert.get("notAfter", ""))
|
||||
days_remaining = None
|
||||
@@ -531,14 +499,27 @@ def check_ssl_cert(domain: str, port: int = 443, timeout: float = 3.0) -> dict[s
|
||||
days_remaining = (expiry_dt - now_dt).days
|
||||
formatted_expiry = expiry_dt.strftime("%Y-%m-%d")
|
||||
|
||||
issuer_raw = cert.get("issuer", ())
|
||||
issuer_dict = dict(x[0] for x in issuer_raw) if issuer_raw else {}
|
||||
issuer_dict: dict[str, str] = {}
|
||||
issuer_raw = cert.get("issuer")
|
||||
if isinstance(issuer_raw, (list, tuple)):
|
||||
for rdn in issuer_raw:
|
||||
if isinstance(rdn, (list, tuple)) and rdn:
|
||||
entry = rdn[0]
|
||||
if isinstance(entry, (list, tuple)) and len(entry) >= 2:
|
||||
issuer_dict[str(entry[0])] = str(entry[1])
|
||||
issuer = str(issuer_dict.get("organizationName") or issuer_dict.get("commonName") or "Unknown")
|
||||
|
||||
subject_raw = cert.get("subject", ())
|
||||
subject_dict = dict(x[0] for x in subject_raw) if subject_raw else {}
|
||||
subject_dict: dict[str, str] = {}
|
||||
subject_raw = cert.get("subject")
|
||||
if isinstance(subject_raw, (list, tuple)):
|
||||
for rdn in subject_raw:
|
||||
if isinstance(rdn, (list, tuple)) and rdn:
|
||||
entry = rdn[0]
|
||||
if isinstance(entry, (list, tuple)) and len(entry) >= 2:
|
||||
subject_dict[str(entry[0])] = str(entry[1])
|
||||
subject = str(subject_dict.get("commonName") or domain)
|
||||
|
||||
|
||||
if days_remaining is not None:
|
||||
if days_remaining < 0:
|
||||
status = f"🔴 Expired ({abs(days_remaining)}d ago)"
|
||||
@@ -728,22 +709,17 @@ def cmd_list(args: list[str]) -> None:
|
||||
app_path = Path(app.dir_path)
|
||||
docker_status = get_docker_status(app_path)
|
||||
|
||||
manifest_file = app_path / "app.yaml"
|
||||
if manifest_file.is_file():
|
||||
try:
|
||||
manifest_obj = parse_manifest(manifest_file)
|
||||
except (ManifestValidationError, yaml.YAMLError, OSError, ValueError, KeyError):
|
||||
manifest_obj = Manifest(name=app.name, domain=app.domain)
|
||||
if app.manifest_error:
|
||||
dep_str = "⚠️ Manifest Error"
|
||||
prov_str = "⚠️ Invalid Manifest"
|
||||
else:
|
||||
manifest_obj = Manifest(name=app.name, domain=app.domain)
|
||||
|
||||
manifest_obj = app.manifest_obj or Manifest(name=app.name, domain=app.domain)
|
||||
two_axis = inspect_workload_two_axis(
|
||||
app_dir=app_path,
|
||||
manifest=manifest_obj,
|
||||
fetch_upstream=should_fetch,
|
||||
docker_status=docker_status,
|
||||
)
|
||||
|
||||
dep_str = two_axis.checkout.status_label
|
||||
prov_str = two_axis.provenance.status.value
|
||||
|
||||
@@ -803,8 +779,12 @@ def cmd_info(args: list[str]) -> None:
|
||||
print(f"Description: {app.description}")
|
||||
return
|
||||
|
||||
if not isinstance(app, SitesApp):
|
||||
return
|
||||
|
||||
# SitesApp
|
||||
print(f"ℹ️ Workload Overview: {app.name}")
|
||||
|
||||
print("-" * 50)
|
||||
print(f"Directory: {app.dir_path}")
|
||||
print(f"Domain: {app.domain}")
|
||||
@@ -816,15 +796,12 @@ def cmd_info(args: list[str]) -> None:
|
||||
print(f"Auth Protected: {app.auth}")
|
||||
print(f"Dashboard: {'Visible' if app.visible else 'Hidden'}")
|
||||
|
||||
if app.manifest_error:
|
||||
print(f"\n⚠️ Manifest Validation Error:\n {app.manifest_error}")
|
||||
return
|
||||
|
||||
app_path = Path(app.dir_path)
|
||||
manifest_file = app_path / "app.yaml"
|
||||
if manifest_file.is_file():
|
||||
try:
|
||||
manifest_obj = parse_manifest(manifest_file)
|
||||
except (ManifestValidationError, yaml.YAMLError, OSError, ValueError, KeyError):
|
||||
manifest_obj = Manifest(name=app.name, domain=app.domain)
|
||||
else:
|
||||
manifest_obj = Manifest(name=app.name, domain=app.domain)
|
||||
manifest_obj = app.manifest_obj or Manifest(name=app.name, domain=app.domain)
|
||||
|
||||
two_axis = inspect_workload_two_axis(
|
||||
app_dir=app_path,
|
||||
@@ -869,6 +846,9 @@ def cmd_resolve(args: list[str]) -> None:
|
||||
app = resolve_app(args[0])
|
||||
if not app:
|
||||
sys.exit(1)
|
||||
if isinstance(app, SitesApp) and app.manifest_error:
|
||||
print(f"❌ Error: Workload '{app.name}' has invalid manifest: {app.manifest_error}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
print(json.dumps(app.to_dict()))
|
||||
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
appctl_engine_v2.py - Backward-compatibility shim pointing to appctl_engine.py.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
|
||||
from appctl_engine import *
|
||||
from appctl_engine import main
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
+181
-144
@@ -2,21 +2,30 @@
|
||||
core_manifest.py — Authoritative Workload Manifest Schema (v1.0) & Parser Library
|
||||
|
||||
Governs the contract for all ~/Sites workloads:
|
||||
- Strongly-typed dataclass representations (Manifest, SourceConfig, DeploymentConfig, HomepageConfig)
|
||||
- Strongly-typed Pydantic v2 representations (Manifest, SourceConfig, DeploymentConfig, HomepageConfig)
|
||||
- Strict source transport scheme validation (https://, ssh://, git@)
|
||||
- Explicit ref classification (moving branches vs. pinned tags vs. commit SHAs)
|
||||
- Workload classification: Class A (Source-Backed) vs. Class B (Image-Only)
|
||||
- Fail-closed schema enforcement with ConfigDict(extra="forbid")
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from dataclasses import asdict, dataclass, field
|
||||
from enum import Enum
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from pydantic import (
|
||||
BaseModel,
|
||||
ConfigDict,
|
||||
Field,
|
||||
ValidationError,
|
||||
field_validator,
|
||||
model_validator,
|
||||
)
|
||||
|
||||
try:
|
||||
import yaml
|
||||
except ImportError:
|
||||
@@ -49,6 +58,11 @@ COMMIT_SHA_RE = re.compile(r"^[0-9a-fA-F]{40}$")
|
||||
SHORT_SHA_RE = re.compile(r"^[0-9a-fA-F]{7,12}$")
|
||||
SEMVER_TAG_RE = re.compile(r"^v?[0-9]+(\.[0-9]+)+([a-zA-Z0-9._-]*)$")
|
||||
SCP_URL_RE = re.compile(r"^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+:([0-9]+/)?([a-zA-Z0-9._-]+/)*[a-zA-Z0-9._-]+(\.git)?$")
|
||||
ENV_KEY_RE = re.compile(r"^[a-zA-Z_][a-zA-Z0-9_]*$")
|
||||
RESERVED_ENV_KEYS = {
|
||||
"PATH", "LD_PRELOAD", "IFS", "SHELL", "USER",
|
||||
"CORE_DIR", "SITES_DIR", "ENV_FILE", "HOMESERVER_ENV"
|
||||
}
|
||||
|
||||
ALLOWED_STRATEGIES = {"compose"}
|
||||
ALLOWED_ACTIONS = {"git_pull", "compose_up", "compose_build", "compose_restart"}
|
||||
@@ -97,7 +111,7 @@ def validate_transport(url: str) -> tuple[TransportScheme, str]:
|
||||
raise ManifestValidationError(f"Insecure HTTP source URL rejected (HTTPS or SSH required): '{clean_url}'")
|
||||
|
||||
raise ManifestValidationError(
|
||||
f"Unsupported source URL scheme: '{clean_url}'. "
|
||||
f"Invalid source.url scheme: '{clean_url}'. "
|
||||
"Allowed transports are https://, ssh://, or git@<host>:<path>."
|
||||
)
|
||||
|
||||
@@ -137,15 +151,41 @@ def classify_ref(ref_str: str) -> tuple[RefType, str]:
|
||||
return RefType.BRANCH, ref
|
||||
|
||||
|
||||
@dataclass
|
||||
class SourceConfig:
|
||||
class SourceConfig(BaseModel):
|
||||
"""Upstream source provenance descriptor."""
|
||||
model_config = ConfigDict(extra="forbid")
|
||||
|
||||
url: str
|
||||
ref: str = "main"
|
||||
type: str = "git"
|
||||
ref_type: RefType = RefType.BRANCH
|
||||
transport: TransportScheme = TransportScheme.HTTPS
|
||||
|
||||
@model_validator(mode="before")
|
||||
@classmethod
|
||||
def validate_source(cls, data: Any) -> Any:
|
||||
if isinstance(data, dict):
|
||||
src_type = str(data.get("type", "git")).strip().lower()
|
||||
if src_type != "git":
|
||||
raise ManifestValidationError(f"Unsupported source type '{src_type}'. Only 'git' is supported.")
|
||||
data["type"] = src_type
|
||||
|
||||
raw_url = data.get("url")
|
||||
if raw_url is not None:
|
||||
transport, validated_url = validate_transport(str(raw_url))
|
||||
data["url"] = validated_url
|
||||
if "transport" not in data or data["transport"] is None:
|
||||
data["transport"] = transport
|
||||
|
||||
raw_ref = data.get("ref", "main")
|
||||
if raw_ref is not None:
|
||||
ref_type, clean_ref = classify_ref(str(raw_ref))
|
||||
data["ref"] = clean_ref
|
||||
if "ref_type" not in data or data["ref_type"] is None:
|
||||
data["ref_type"] = ref_type
|
||||
|
||||
return data
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
return {
|
||||
"type": self.type,
|
||||
@@ -156,49 +196,156 @@ class SourceConfig:
|
||||
}
|
||||
|
||||
|
||||
@dataclass
|
||||
class DeploymentConfig:
|
||||
class DeploymentConfig(BaseModel):
|
||||
"""Continuous deployment strategy and action policy."""
|
||||
model_config = ConfigDict(extra="forbid")
|
||||
|
||||
strategy: str = "compose"
|
||||
branch: str = "main"
|
||||
actions: list[str] = field(default_factory=lambda: ["git_pull", "compose_up"])
|
||||
actions: list[str] = Field(default_factory=lambda: ["git_pull", "compose_up"])
|
||||
|
||||
@field_validator("strategy", mode="before")
|
||||
@classmethod
|
||||
def validate_strategy(cls, v: Any) -> str:
|
||||
clean = str(v).strip().lower()
|
||||
if clean not in ALLOWED_STRATEGIES:
|
||||
raise ManifestValidationError(
|
||||
f"Unsupported deployment strategy '{clean}'. Allowed: {sorted(ALLOWED_STRATEGIES)}"
|
||||
)
|
||||
return clean
|
||||
|
||||
@field_validator("actions", mode="before")
|
||||
@classmethod
|
||||
def validate_actions(cls, v: Any) -> list[str]:
|
||||
if isinstance(v, list):
|
||||
actions: list[str] = []
|
||||
for act in v:
|
||||
act_str = str(act).strip().lower()
|
||||
if act_str not in ALLOWED_ACTIONS:
|
||||
raise ManifestValidationError(
|
||||
f"Prohibited deployment action '{act_str}'. Allowed: {sorted(ALLOWED_ACTIONS)}"
|
||||
)
|
||||
actions.append(act_str)
|
||||
if not actions:
|
||||
return ["compose_up"]
|
||||
return actions
|
||||
return ["compose_up"]
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
return asdict(self)
|
||||
return self.model_dump(mode="python")
|
||||
|
||||
|
||||
@dataclass
|
||||
class HomepageConfig:
|
||||
class HomepageConfig(BaseModel):
|
||||
"""Dashboard card metadata for Homepage."""
|
||||
model_config = ConfigDict(extra="forbid")
|
||||
|
||||
title: str
|
||||
group: str = "Applications"
|
||||
icon: str = "default.png"
|
||||
container: str = ""
|
||||
weight: int = 50
|
||||
|
||||
@field_validator("weight", mode="before")
|
||||
@classmethod
|
||||
def normalize_weight(cls, v: Any) -> int:
|
||||
try:
|
||||
return int(v)
|
||||
except (ValueError, TypeError):
|
||||
return 50
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
return asdict(self)
|
||||
return self.model_dump(mode="python")
|
||||
|
||||
|
||||
@dataclass
|
||||
class Manifest:
|
||||
class Manifest(BaseModel):
|
||||
"""
|
||||
Authoritative Workload Manifest Model (Schema v1.0).
|
||||
Represents the full contract declared in a workload's app.yaml.
|
||||
"""
|
||||
model_config = ConfigDict(extra="forbid", populate_by_name=True)
|
||||
|
||||
name: str
|
||||
schema_version: str = "1.0"
|
||||
schema_version: str = Field(default="1.0", alias="schemaVersion")
|
||||
domain: str = ""
|
||||
description: str = ""
|
||||
aliases: list[str] = field(default_factory=list)
|
||||
aliases: list[str] = Field(default_factory=list)
|
||||
visible: bool = True
|
||||
auth: bool = True
|
||||
networks: list[str] = field(default_factory=lambda: ["proxy-net"])
|
||||
env: dict[str, Any] = field(default_factory=dict)
|
||||
deployment: DeploymentConfig = field(default_factory=DeploymentConfig)
|
||||
networks: list[str] = Field(default_factory=lambda: ["proxy-net"])
|
||||
env: dict[str, str] = Field(default_factory=dict)
|
||||
deployment: DeploymentConfig = Field(default_factory=DeploymentConfig)
|
||||
source: SourceConfig | None = None
|
||||
homepage: HomepageConfig | None = None
|
||||
|
||||
@model_validator(mode="before")
|
||||
@classmethod
|
||||
def prepare_manifest(cls, data: Any) -> Any:
|
||||
if isinstance(data, dict):
|
||||
raw_name = data.get("name")
|
||||
if raw_name is None or not isinstance(raw_name, str) or not raw_name.strip():
|
||||
raise ManifestValidationError("Manifest is missing mandatory string field 'name'.")
|
||||
clean_name = raw_name.strip()
|
||||
if not NAME_RE.match(clean_name):
|
||||
raise ManifestValidationError(
|
||||
f"Invalid workload name '{clean_name}'. Must be alphanumeric with optional '.' '_' '-', starting with alphanumeric."
|
||||
)
|
||||
data["name"] = clean_name
|
||||
|
||||
# Source: treat empty dict or missing url as None
|
||||
src = data.get("source")
|
||||
if isinstance(src, dict) and not src.get("url"):
|
||||
data["source"] = None
|
||||
|
||||
# Homepage default propagation
|
||||
hp = data.get("homepage")
|
||||
if isinstance(hp, dict):
|
||||
hp.setdefault("title", clean_name)
|
||||
hp.setdefault("container", clean_name)
|
||||
|
||||
return data
|
||||
|
||||
@field_validator("visible", "auth", mode="before")
|
||||
@classmethod
|
||||
def cast_bool(cls, v: Any) -> bool:
|
||||
if v is None:
|
||||
return True
|
||||
return bool(v)
|
||||
|
||||
@field_validator("aliases", mode="before")
|
||||
@classmethod
|
||||
def normalize_aliases(cls, v: Any) -> list[str]:
|
||||
|
||||
if isinstance(v, str):
|
||||
return [v.strip()] if v.strip() else []
|
||||
if isinstance(v, list):
|
||||
return [str(a).strip() for a in v if isinstance(a, str) and str(a).strip()]
|
||||
return []
|
||||
|
||||
@field_validator("networks", mode="before")
|
||||
@classmethod
|
||||
def normalize_networks(cls, v: Any) -> list[str]:
|
||||
if isinstance(v, list):
|
||||
clean = [str(n).strip() for n in v if str(n).strip()]
|
||||
if clean:
|
||||
return clean
|
||||
return ["proxy-net"]
|
||||
|
||||
@field_validator("env", mode="before")
|
||||
@classmethod
|
||||
def validate_env(cls, v: Any) -> dict[str, str]:
|
||||
if not isinstance(v, dict):
|
||||
return {}
|
||||
env: dict[str, str] = {}
|
||||
for raw_k, raw_v in v.items():
|
||||
k_str = str(raw_k).strip()
|
||||
if not ENV_KEY_RE.match(k_str) or k_str in RESERVED_ENV_KEYS:
|
||||
raise ManifestValidationError(
|
||||
f"Invalid or reserved environment variable key '{k_str}'. "
|
||||
f"Keys must match ^[a-zA-Z_][a-zA-Z0-9_]*$ and cannot be reserved."
|
||||
)
|
||||
env[k_str] = str(raw_v) if raw_v is not None else ""
|
||||
return env
|
||||
|
||||
@property
|
||||
def is_class_a(self) -> bool:
|
||||
"""Class A: Source-backed workload requiring upstream repository checkout & build."""
|
||||
@@ -272,132 +419,22 @@ def parse_manifest(raw_input: str | Path | dict[str, Any]) -> Manifest:
|
||||
if not isinstance(data, dict):
|
||||
raise ManifestValidationError("Manifest root must be a YAML dictionary mapping.")
|
||||
|
||||
# 1. Name validation
|
||||
raw_name = data.get("name")
|
||||
if not raw_name or not isinstance(raw_name, str):
|
||||
raise ManifestValidationError("Manifest is missing mandatory string field 'name'.")
|
||||
name = raw_name.strip()
|
||||
if not NAME_RE.match(name):
|
||||
raise ManifestValidationError(
|
||||
f"Invalid workload name '{name}'. Must be alphanumeric with optional '.' '_' '-', starting with alphanumeric."
|
||||
)
|
||||
|
||||
# 2. Schema Version
|
||||
schema_version = str(data.get("schemaVersion", "1.0")).strip()
|
||||
|
||||
# 3. Domain & Description
|
||||
domain = str(data.get("domain", "")).strip()
|
||||
description = str(data.get("description", "")).strip()
|
||||
|
||||
# 4. Aliases
|
||||
aliases_raw = data.get("aliases", [])
|
||||
aliases: list[str] = []
|
||||
if isinstance(aliases_raw, str):
|
||||
aliases = [aliases_raw.strip()]
|
||||
elif isinstance(aliases_raw, list):
|
||||
for a in aliases_raw:
|
||||
if isinstance(a, str) and a.strip():
|
||||
aliases.append(a.strip())
|
||||
|
||||
# 5. Flags (visible, auth)
|
||||
visible = bool(data.get("visible", True))
|
||||
auth = bool(data.get("auth", True))
|
||||
|
||||
# 6. Networks
|
||||
networks_raw = data.get("networks", ["proxy-net"])
|
||||
networks: list[str] = []
|
||||
if isinstance(networks_raw, list):
|
||||
networks = [str(n).strip() for n in networks_raw if str(n).strip()]
|
||||
if not networks:
|
||||
networks = ["proxy-net"]
|
||||
|
||||
# 7. Environment overrides
|
||||
env_raw = data.get("env", {})
|
||||
env = dict(env_raw) if isinstance(env_raw, dict) else {}
|
||||
|
||||
# 8. Deployment Policy
|
||||
deployment_raw = data.get("deployment")
|
||||
deployment = DeploymentConfig()
|
||||
if isinstance(deployment_raw, dict):
|
||||
strategy = str(deployment_raw.get("strategy", "compose")).strip().lower()
|
||||
if strategy not in ALLOWED_STRATEGIES:
|
||||
raise ManifestValidationError(
|
||||
f"Unsupported deployment strategy '{strategy}'. Allowed: {sorted(ALLOWED_STRATEGIES)}"
|
||||
)
|
||||
|
||||
branch = str(deployment_raw.get("branch", "main")).strip()
|
||||
actions_raw = deployment_raw.get("actions", ["compose_up"])
|
||||
actions: list[str] = []
|
||||
if isinstance(actions_raw, list):
|
||||
for act in actions_raw:
|
||||
act_str = str(act).strip().lower()
|
||||
if act_str not in ALLOWED_ACTIONS:
|
||||
raise ManifestValidationError(
|
||||
f"Prohibited deployment action '{act_str}'. Allowed: {sorted(ALLOWED_ACTIONS)}"
|
||||
)
|
||||
actions.append(act_str)
|
||||
if not actions:
|
||||
actions = ["compose_up"]
|
||||
|
||||
deployment = DeploymentConfig(strategy=strategy, branch=branch, actions=actions)
|
||||
|
||||
# 9. Source Provenance (Class A vs Class B)
|
||||
source_raw = data.get("source")
|
||||
source: SourceConfig | None = None
|
||||
if isinstance(source_raw, dict) and source_raw.get("url"):
|
||||
raw_url = str(source_raw.get("url", "")).strip()
|
||||
transport, validated_url = validate_transport(raw_url)
|
||||
|
||||
raw_ref = str(source_raw.get("ref", "main")).strip()
|
||||
ref_type, clean_ref = classify_ref(raw_ref)
|
||||
|
||||
src_type = str(source_raw.get("type", "git")).strip().lower()
|
||||
if src_type != "git":
|
||||
raise ManifestValidationError(f"Unsupported source type '{src_type}'. Only 'git' is supported.")
|
||||
|
||||
source = SourceConfig(
|
||||
url=validated_url,
|
||||
ref=clean_ref,
|
||||
type=src_type,
|
||||
ref_type=ref_type,
|
||||
transport=transport,
|
||||
)
|
||||
|
||||
# 10. Homepage configuration
|
||||
homepage_raw = data.get("homepage")
|
||||
homepage: HomepageConfig | None = None
|
||||
if isinstance(homepage_raw, dict):
|
||||
title = str(homepage_raw.get("title", name)).strip()
|
||||
group = str(homepage_raw.get("group", "Applications")).strip()
|
||||
icon = str(homepage_raw.get("icon", "default.png")).strip()
|
||||
container = str(homepage_raw.get("container", name)).strip()
|
||||
try:
|
||||
weight = int(homepage_raw.get("weight", 50))
|
||||
except (ValueError, TypeError):
|
||||
weight = 50
|
||||
|
||||
homepage = HomepageConfig(
|
||||
title=title,
|
||||
group=group,
|
||||
icon=icon,
|
||||
container=container,
|
||||
weight=weight,
|
||||
)
|
||||
|
||||
return Manifest(
|
||||
name=name,
|
||||
schema_version=schema_version,
|
||||
domain=domain,
|
||||
description=description,
|
||||
aliases=aliases,
|
||||
visible=visible,
|
||||
auth=auth,
|
||||
networks=networks,
|
||||
env=env,
|
||||
deployment=deployment,
|
||||
source=source,
|
||||
homepage=homepage,
|
||||
)
|
||||
return Manifest.model_validate(data)
|
||||
except ValidationError as e:
|
||||
for err in e.errors():
|
||||
ctx = err.get("ctx", {})
|
||||
orig_err = ctx.get("error")
|
||||
if isinstance(orig_err, ManifestValidationError):
|
||||
raise orig_err from e
|
||||
first_error = e.errors()[0]
|
||||
msg = first_error.get("msg", str(e))
|
||||
if msg.startswith("Value error, "):
|
||||
msg = msg.removeprefix("Value error, ")
|
||||
loc = ".".join(str(p) for p in first_error.get("loc", []))
|
||||
if loc and first_error.get("type") == "extra_forbidden":
|
||||
raise ManifestValidationError(f"Manifest contains unrecognized or forbidden field '{loc}'.") from e
|
||||
raise ManifestValidationError(msg) from e
|
||||
|
||||
|
||||
def _parse_yaml_basic(content: str) -> dict[str, Any]:
|
||||
|
||||
+145
-70
@@ -156,13 +156,17 @@ def get_trusted_repository_mapping() -> dict[str, Path]:
|
||||
"""
|
||||
Build authoritative mapping of logical repository identities to local paths.
|
||||
Webhook payloads can only select repositories defined in this mapping.
|
||||
Prioritizes Core Authoritative Registry (deployments.yaml) over dynamic discovery.
|
||||
Core Authoritative Registry (deployments.yaml) is the sole admission authority.
|
||||
Fails closed if the registry is missing, unreadable, or malformed.
|
||||
"""
|
||||
mapping: dict[str, Path] = {}
|
||||
|
||||
# 1. Authoritative Core Repository Registry (deployments.yaml)
|
||||
registry_file = DEPLOYMENTS_FILE if DEPLOYMENTS_FILE.is_file() else (CONFIG_DIR / "deployments.yaml")
|
||||
if registry_file.is_file():
|
||||
if not registry_file.is_file():
|
||||
logger.error(f"Authoritative registry {registry_file} not found. Failing closed with zero admitted repositories.")
|
||||
return mapping
|
||||
|
||||
yaml_errors = (yaml.YAMLError,) if yaml is not None else ()
|
||||
try:
|
||||
content = registry_file.read_text(encoding="utf-8")
|
||||
registry = (yaml.safe_load(content) if yaml else parse_yaml_simple(content)) or {}
|
||||
@@ -187,59 +191,19 @@ def get_trusted_repository_mapping() -> dict[str, Path]:
|
||||
mapping[alias.strip()] = p
|
||||
else:
|
||||
logger.warning(f"Rejecting out-of-bounds path in deployments.yaml for '{reg_name}': {p}")
|
||||
except (OSError, UnicodeDecodeError, ValueError, KeyError, AttributeError) as e:
|
||||
logger.warning(f"Failed to parse authoritative registry {registry_file}: {e}")
|
||||
else:
|
||||
logger.error(f"Malformed repositories block in {registry_file}: expected dictionary mapping.")
|
||||
return {}
|
||||
except (OSError, UnicodeDecodeError, ValueError, KeyError, AttributeError, TypeError, *yaml_errors) as e:
|
||||
logger.critical(f"Failed to parse authoritative registry {registry_file}: {e}. Failing closed.")
|
||||
return {}
|
||||
|
||||
# 2. Dynamic Discovery in SITES_DIR (for workloads not explicitly registered)
|
||||
if SITES_DIR.is_dir():
|
||||
sites_canonical = SITES_DIR.resolve()
|
||||
for entry in SITES_DIR.iterdir():
|
||||
if not entry.is_dir():
|
||||
continue
|
||||
|
||||
# Defense-in-depth: resolve symlinks and ensure target is strictly inside SITES_DIR
|
||||
resolved_entry = entry.resolve()
|
||||
if not resolved_entry.is_relative_to(sites_canonical):
|
||||
logger.warning(f"Rejecting repository symlink escape: {entry} -> {resolved_entry}")
|
||||
continue
|
||||
|
||||
manifest_file = resolved_entry / "app.yaml"
|
||||
if not manifest_file.is_file():
|
||||
continue
|
||||
|
||||
# Register entry directory name if not already mapped
|
||||
dir_name = entry.name
|
||||
if dir_name not in mapping:
|
||||
mapping[dir_name] = resolved_entry
|
||||
|
||||
# Parse app.yaml for canonical name and aliases
|
||||
manifest = {}
|
||||
try:
|
||||
manifest_text = manifest_file.read_text(encoding="utf-8")
|
||||
manifest = (yaml.safe_load(manifest_text) if yaml else parse_yaml_simple(manifest_text)) or {}
|
||||
except (OSError, UnicodeDecodeError, ValueError, KeyError, AttributeError) as e:
|
||||
logger.warning(f"Failed to parse {manifest_file}: {e}")
|
||||
|
||||
canonical_name = manifest.get("name")
|
||||
if canonical_name and isinstance(canonical_name, str):
|
||||
canonical_name = canonical_name.strip()
|
||||
if canonical_name not in mapping:
|
||||
mapping[canonical_name] = resolved_entry
|
||||
alias_with_prefix = f"homelab-{canonical_name}" if not canonical_name.startswith("homelab-") else canonical_name.replace("homelab-", "", 1)
|
||||
if alias_with_prefix not in mapping:
|
||||
mapping[alias_with_prefix] = resolved_entry
|
||||
|
||||
aliases = manifest.get("aliases", [])
|
||||
if isinstance(aliases, str):
|
||||
aliases = [aliases]
|
||||
if isinstance(aliases, list):
|
||||
for alias in aliases:
|
||||
if isinstance(alias, str) and alias.strip() and alias.strip() not in mapping:
|
||||
mapping[alias.strip()] = resolved_entry
|
||||
|
||||
return mapping
|
||||
|
||||
|
||||
|
||||
def resolve_repository(repo_name: str) -> Path | None:
|
||||
"""
|
||||
Resolve a logical repository identity to a trusted local directory.
|
||||
@@ -314,26 +278,49 @@ ALLOWED_ACTIONS = {"git_pull", "compose_up", "compose_build", "compose_restart"}
|
||||
ALLOWED_STRATEGIES = {"compose"}
|
||||
|
||||
|
||||
def validate_compose_security(compose_file: Path, allowed_root: Path) -> tuple[bool, str | None]:
|
||||
PROHIBITED_HOST_NAMESPACES = {"host"}
|
||||
DANGEROUS_SECURITY_OPTS = {"unconfined", "apparmor:unconfined", "seccomp:unconfined"}
|
||||
|
||||
|
||||
def validate_compose_security(
|
||||
compose_file: Path,
|
||||
allowed_root: Path,
|
||||
app_name: str | None = None,
|
||||
) -> tuple[bool, str | None]:
|
||||
"""
|
||||
Pre-flight AST inspection of workload docker-compose.yml to reject security violations:
|
||||
1. privileged: true
|
||||
2. /var/run/docker.sock bind mounts
|
||||
3. network_mode: host
|
||||
4. host root bind mounts outside allowed state root or workload directory
|
||||
Pre-flight AST inspection of workload docker-compose.yml enforcing Core platform security invariants:
|
||||
1. File Integrity: regular file, non-symlink (or strictly contained symlink).
|
||||
2. Privilege Containment: blocks 'privileged: true', 'cap_add', 'devices', and 'security_opt: unconfined'.
|
||||
3. Host Namespace Isolation: blocks 'pid: host', 'ipc: host', 'uts: host', 'userns_mode: host', 'network_mode: host'.
|
||||
4. Docker Socket Ban: blocks direct mounts of /var/run/docker.sock.
|
||||
5. Top-Level Inclusion Ban: blocks top-level 'include' directives.
|
||||
6. Bind-Mount & Tenant State Isolation: resolves all relative and absolute host paths. Requires containment
|
||||
strictly within either the workload root (allowed_root) OR the workload's dedicated state root
|
||||
(~/var/lib/homelab/<app_name>/). Cross-tenant state mounts are rejected fail-closed.
|
||||
"""
|
||||
if not compose_file.is_file():
|
||||
if not compose_file.exists():
|
||||
return True, None
|
||||
|
||||
if not compose_file.is_file():
|
||||
return False, f"Compose file '{compose_file}' is not a regular file."
|
||||
|
||||
canonical_allowed_root = allowed_root.resolve()
|
||||
|
||||
if compose_file.is_symlink():
|
||||
resolved_compose = compose_file.resolve()
|
||||
if not resolved_compose.is_relative_to(canonical_allowed_root):
|
||||
return False, f"Compose file symlink escapes workload root: {compose_file} -> {resolved_compose}"
|
||||
|
||||
try:
|
||||
content = compose_file.read_text(encoding="utf-8")
|
||||
except OSError as e:
|
||||
return False, f"Failed to read compose file {compose_file}: {e}"
|
||||
|
||||
yaml_errors = (yaml.YAMLError,) if yaml is not None else ()
|
||||
if yaml is not None:
|
||||
try:
|
||||
data = yaml.safe_load(content) or {}
|
||||
except yaml.YAMLError as e:
|
||||
except yaml_errors as e:
|
||||
return False, f"Failed to parse compose YAML {compose_file}: {e}"
|
||||
else:
|
||||
# Fallback regex inspection if yaml module is not present
|
||||
@@ -343,16 +330,29 @@ def validate_compose_security(compose_file: Path, allowed_root: Path) -> tuple[b
|
||||
return False, "Docker socket mounts are prohibited in workload compose files."
|
||||
if re.search(r"^\s*network_mode:\s*[\"']?host[\"']?", content, re.MULTILINE | re.IGNORECASE):
|
||||
return False, "Host networking (network_mode: host) is prohibited in workload compose files."
|
||||
if re.search(r"^\s*cap_add:\s*", content, re.MULTILINE | re.IGNORECASE):
|
||||
return False, "Linux capabilities (cap_add) are prohibited in workload compose files."
|
||||
if re.search(r"^\s*devices:\s*", content, re.MULTILINE | re.IGNORECASE):
|
||||
return False, "Host device mounts (devices) are prohibited in workload compose files."
|
||||
if re.search(r"^\s*include:\s*", content, re.MULTILINE | re.IGNORECASE):
|
||||
return False, "Top-level include directives are prohibited in workload compose files."
|
||||
return True, None
|
||||
|
||||
if not isinstance(data, dict):
|
||||
return False, f"Invalid compose root in {compose_file}: expected mapping"
|
||||
|
||||
if "include" in data:
|
||||
return False, "Top-level 'include' directives are prohibited in workload compose files."
|
||||
|
||||
services = data.get("services")
|
||||
if not isinstance(services, dict):
|
||||
return True, None
|
||||
|
||||
state_root = Path(os.environ.get("HOMELAB_STATE_ROOT", Path.home() / "var/lib/homelab")).resolve()
|
||||
target_app_name = app_name or allowed_root.name
|
||||
target_state_root = (state_root / target_app_name).resolve()
|
||||
|
||||
top_volumes = set(data.get("volumes", {}).keys()) if isinstance(data.get("volumes"), dict) else set()
|
||||
|
||||
for svc_name, svc in services.items():
|
||||
if not isinstance(svc, dict):
|
||||
@@ -361,9 +361,54 @@ def validate_compose_security(compose_file: Path, allowed_root: Path) -> tuple[b
|
||||
if svc.get("privileged") is True:
|
||||
return False, f"Service '{svc_name}' specifies prohibited 'privileged: true'."
|
||||
|
||||
net_mode = str(svc.get("network_mode", "")).strip().lower()
|
||||
if net_mode == "host":
|
||||
return False, f"Service '{svc_name}' specifies prohibited 'network_mode: host'."
|
||||
cap_add = svc.get("cap_add")
|
||||
if cap_add:
|
||||
return False, f"Service '{svc_name}' specifies prohibited 'cap_add' capabilities: {cap_add}."
|
||||
|
||||
devices = svc.get("devices")
|
||||
if devices:
|
||||
return False, f"Service '{svc_name}' specifies prohibited host device mount: {devices}."
|
||||
|
||||
sec_opts = svc.get("security_opt", [])
|
||||
if isinstance(sec_opts, str):
|
||||
sec_opts = [sec_opts]
|
||||
if isinstance(sec_opts, list):
|
||||
for opt in sec_opts:
|
||||
if any(bad in str(opt).lower() for bad in ("unconfined", "disable")):
|
||||
return False, f"Service '{svc_name}' specifies prohibited security_opt: {opt}."
|
||||
|
||||
raw_env_files = svc.get("env_file")
|
||||
if raw_env_files:
|
||||
env_file_list: list[str] = []
|
||||
if isinstance(raw_env_files, str):
|
||||
env_file_list = [raw_env_files]
|
||||
elif isinstance(raw_env_files, list):
|
||||
for item in raw_env_files:
|
||||
if isinstance(item, str):
|
||||
env_file_list.append(item)
|
||||
elif isinstance(item, dict) and "path" in item:
|
||||
env_file_list.append(str(item["path"]))
|
||||
elif isinstance(raw_env_files, dict) and "path" in raw_env_files:
|
||||
env_file_list = [str(raw_env_files["path"])]
|
||||
|
||||
for env_path in env_file_list:
|
||||
clean_env = env_path.strip()
|
||||
if not clean_env:
|
||||
continue
|
||||
if clean_env.startswith("~"):
|
||||
resolved_env = Path(clean_env).expanduser().resolve()
|
||||
elif Path(clean_env).is_absolute():
|
||||
resolved_env = Path(clean_env).resolve()
|
||||
else:
|
||||
resolved_env = (allowed_root / clean_env).resolve()
|
||||
|
||||
if not (allowed_root.is_dir() and resolved_env.is_relative_to(canonical_allowed_root)):
|
||||
return False, f"Service '{svc_name}' specifies prohibited env_file escaping workload root: '{clean_env}'."
|
||||
|
||||
for ns_key in ("network_mode", "pid", "ipc", "uts", "userns_mode"):
|
||||
val = str(svc.get(ns_key, "")).strip().lower()
|
||||
if val in PROHIBITED_HOST_NAMESPACES:
|
||||
return False, f"Service '{svc_name}' specifies prohibited host namespace '{ns_key}: {val}'."
|
||||
|
||||
volumes = svc.get("volumes", [])
|
||||
if isinstance(volumes, list):
|
||||
@@ -381,18 +426,37 @@ def validate_compose_security(compose_file: Path, allowed_root: Path) -> tuple[b
|
||||
if vol.get("type") == "bind":
|
||||
host_path = src
|
||||
|
||||
# Evaluate host_path escapes
|
||||
if host_path and host_path.startswith(("/", "~")):
|
||||
if not host_path:
|
||||
continue
|
||||
|
||||
# Declared top-level named volume without path separators
|
||||
if host_path in top_volumes and not (host_path.startswith((".", "/", "~")) or "/" in host_path or "\\" in host_path):
|
||||
continue
|
||||
|
||||
# Undeclared named volumes or bare identifiers not starting with ., /, ~ or containing / are prohibited
|
||||
if not (host_path.startswith((".", "/", "~")) or "/" in host_path or "\\" in host_path):
|
||||
return False, f"Service '{svc_name}' specifies undeclared named volume or ambiguous path: '{host_path}'."
|
||||
|
||||
# Host bind mount evaluation
|
||||
if host_path.startswith("~"):
|
||||
expanded = Path(host_path).expanduser().resolve()
|
||||
# Allowed if inside the workload directory or inside the state root
|
||||
is_in_workload = allowed_root.is_dir() and expanded.is_relative_to(allowed_root.resolve())
|
||||
is_in_state = state_root.is_dir() and expanded.is_relative_to(state_root)
|
||||
if not (is_in_workload or is_in_state):
|
||||
elif Path(host_path).is_absolute():
|
||||
expanded = Path(host_path).resolve()
|
||||
else:
|
||||
# Relative path resolved against workload root
|
||||
expanded = (allowed_root / host_path).resolve()
|
||||
|
||||
# Containment check: strictly within workload directory or dedicated state root
|
||||
is_in_workload = allowed_root.is_dir() and expanded.is_relative_to(canonical_allowed_root)
|
||||
is_in_own_state = expanded.is_relative_to(target_state_root)
|
||||
|
||||
if not (is_in_workload or is_in_own_state):
|
||||
return False, f"Service '{svc_name}' specifies prohibited host bind mount: '{host_path}'."
|
||||
|
||||
return True, None
|
||||
|
||||
|
||||
|
||||
def validate_manifest_deployment(manifest: dict) -> tuple[bool, str]:
|
||||
"""
|
||||
Validate deployment policy inside app.yaml.
|
||||
@@ -435,6 +499,14 @@ def execute_deployment(target_dir: Path, deployment_config: dict, branch: str) -
|
||||
logger.info(f"Skipping deployment: pushed branch '{branch}' != target branch '{expected_branch}'")
|
||||
return True
|
||||
|
||||
canonical_app_name = target_dir.name.removeprefix("homelab-")
|
||||
manifest_file = target_dir / "app.yaml"
|
||||
if manifest_file.is_file():
|
||||
with contextlib.suppress(Exception):
|
||||
pre_manifest = (yaml.safe_load(manifest_file.read_text(encoding="utf-8")) if yaml else parse_yaml_simple(manifest_file.read_text(encoding="utf-8"))) or {}
|
||||
if isinstance(pre_manifest, dict) and pre_manifest.get("name"):
|
||||
canonical_app_name = str(pre_manifest["name"]).strip()
|
||||
|
||||
logger.info(f"🚀 Deploying '{target_dir.name}' at {target_dir} (branch: {expected_branch})...")
|
||||
actions = deployment_config.get("actions", ["git_pull"])
|
||||
|
||||
@@ -465,6 +537,9 @@ def execute_deployment(target_dir: Path, deployment_config: dict, branch: str) -
|
||||
logger.error(f"❌ Post-pull manifest validation failed for '{target_dir.name}': {err_msg}")
|
||||
return False
|
||||
|
||||
if isinstance(fresh_manifest, dict) and fresh_manifest.get("name"):
|
||||
canonical_app_name = str(fresh_manifest["name"]).strip()
|
||||
|
||||
fresh_config = fresh_manifest.get("deployment")
|
||||
if isinstance(fresh_config, dict):
|
||||
fresh_branch = fresh_config.get("branch", "main")
|
||||
@@ -484,7 +559,7 @@ def execute_deployment(target_dir: Path, deployment_config: dict, branch: str) -
|
||||
if not compose_file.is_file():
|
||||
compose_file = target_dir / "docker-compose.yaml"
|
||||
if compose_file.is_file():
|
||||
valid_sec, sec_err = validate_compose_security(compose_file, target_dir)
|
||||
valid_sec, sec_err = validate_compose_security(compose_file, target_dir, app_name=canonical_app_name)
|
||||
if not valid_sec:
|
||||
logger.error(f"❌ Compose security validation failed for '{target_dir.name}': {sec_err}")
|
||||
return False
|
||||
@@ -498,7 +573,7 @@ def execute_deployment(target_dir: Path, deployment_config: dict, branch: str) -
|
||||
if not compose_file.is_file():
|
||||
compose_file = target_dir / "docker-compose.yaml"
|
||||
if compose_file.is_file():
|
||||
valid_sec, sec_err = validate_compose_security(compose_file, target_dir)
|
||||
valid_sec, sec_err = validate_compose_security(compose_file, target_dir, app_name=canonical_app_name)
|
||||
if not valid_sec:
|
||||
logger.error(f"❌ Compose security validation failed for '{target_dir.name}': {sec_err}")
|
||||
return False
|
||||
@@ -516,7 +591,7 @@ def execute_deployment(target_dir: Path, deployment_config: dict, branch: str) -
|
||||
if not compose_file.is_file():
|
||||
compose_file = target_dir / "docker-compose.yaml"
|
||||
if compose_file.is_file():
|
||||
valid_sec, sec_err = validate_compose_security(compose_file, target_dir)
|
||||
valid_sec, sec_err = validate_compose_security(compose_file, target_dir, app_name=canonical_app_name)
|
||||
if not valid_sec:
|
||||
logger.error(f"❌ Compose security validation failed for '{target_dir.name}': {sec_err}")
|
||||
return False
|
||||
|
||||
+12
-3
@@ -8,14 +8,23 @@ echo "🔍 Running code linters (ruff)..."
|
||||
if command -v ruff &>/dev/null; then
|
||||
ruff check .
|
||||
else
|
||||
nix-shell -p ruff --run "ruff check ."
|
||||
nix develop --command ruff check .
|
||||
fi
|
||||
|
||||
echo "🔎 Running static type analysis (pyright)..."
|
||||
if command -v pyright &>/dev/null; then
|
||||
pyright
|
||||
else
|
||||
nix develop --command pyright
|
||||
fi
|
||||
|
||||
echo "🧪 Running architecture & security test suite (pytest)..."
|
||||
if command -v pytest &>/dev/null; then
|
||||
if [ -x ".venv/bin/pytest" ]; then
|
||||
.venv/bin/pytest tests/
|
||||
elif command -v pytest &>/dev/null; then
|
||||
pytest tests/
|
||||
else
|
||||
nix-shell -p python3Packages.pytest python3Packages.pyyaml --run "pytest tests/"
|
||||
nix develop --command pytest tests/
|
||||
fi
|
||||
|
||||
echo "❄️ Verifying NixOS flake & sandbox checks..."
|
||||
|
||||
@@ -7,6 +7,8 @@ import sys
|
||||
from pathlib import Path
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
# Add Core to path so scripts can be imported
|
||||
CORE_ROOT = Path(__file__).resolve().parent.parent.parent
|
||||
sys.path.insert(0, str(CORE_ROOT / "scripts"))
|
||||
@@ -122,7 +124,14 @@ def test_resolve_repository_resolves_valid_manifest(tmp_path: Path, monkeypatch)
|
||||
encoding="utf-8"
|
||||
)
|
||||
|
||||
registry = tmp_path / "deployments.yaml"
|
||||
registry.write_text(
|
||||
f'schemaVersion: "1.0"\nrepositories:\n homelab-docs:\n path: "{app_dir}"\n aliases:\n - docs\n - doc2site\n - notes\n',
|
||||
encoding="utf-8"
|
||||
)
|
||||
|
||||
monkeypatch.setattr(gitops_dispatcher, "SITES_DIR", sites_dir)
|
||||
monkeypatch.setattr(gitops_dispatcher, "DEPLOYMENTS_FILE", registry)
|
||||
|
||||
canonical = app_dir.resolve()
|
||||
assert gitops_dispatcher.resolve_repository("homelab-docs") == canonical
|
||||
@@ -131,6 +140,7 @@ def test_resolve_repository_resolves_valid_manifest(tmp_path: Path, monkeypatch)
|
||||
assert gitops_dispatcher.resolve_repository("notes") == canonical
|
||||
|
||||
|
||||
|
||||
def test_resolve_repository_rejects_vault(tmp_path: Path, monkeypatch):
|
||||
"""Ensure data vault identities (Brain / second-brain) are not recognized by GitOps."""
|
||||
sites_dir = tmp_path / "Sites"
|
||||
@@ -179,6 +189,57 @@ repositories:
|
||||
assert "escaped-app" not in mapping
|
||||
|
||||
|
||||
def test_unregistered_sites_directory_rejected_when_registry_active(tmp_path: Path, monkeypatch):
|
||||
"""Ensure unregistered directories in ~/Sites cannot be resolved when deployments.yaml is active."""
|
||||
sites_dir = tmp_path / "Sites"
|
||||
registered_dir = sites_dir / "homelab-docs"
|
||||
unregistered_dir = sites_dir / "rogue-workload"
|
||||
registered_dir.mkdir(parents=True)
|
||||
unregistered_dir.mkdir(parents=True)
|
||||
(registered_dir / "app.yaml").write_text("name: docs\n", encoding="utf-8")
|
||||
(unregistered_dir / "app.yaml").write_text("name: rogue\n", encoding="utf-8")
|
||||
|
||||
registry = tmp_path / "deployments.yaml"
|
||||
registry.write_text(
|
||||
f'schemaVersion: "1.0"\nrepositories:\n docs:\n path: "{registered_dir}"\n',
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
monkeypatch.setattr(gitops_dispatcher, "SITES_DIR", sites_dir)
|
||||
monkeypatch.setattr(gitops_dispatcher, "DEPLOYMENTS_FILE", registry)
|
||||
|
||||
assert gitops_dispatcher.resolve_repository("docs") == registered_dir.resolve()
|
||||
# Unregistered workload must be rejected despite having app.yaml in Sites
|
||||
assert gitops_dispatcher.resolve_repository("rogue") is None
|
||||
assert gitops_dispatcher.resolve_repository("rogue-workload") is None
|
||||
|
||||
|
||||
def test_missing_or_corrupt_registry_fails_closed(tmp_path: Path, monkeypatch):
|
||||
"""Ensure missing or corrupted deployments.yaml fails closed without falling back to directory scanning."""
|
||||
sites_dir = tmp_path / "Sites"
|
||||
app_dir = sites_dir / "valid-app"
|
||||
app_dir.mkdir(parents=True)
|
||||
(app_dir / "app.yaml").write_text("name: valid\n", encoding="utf-8")
|
||||
|
||||
missing_registry = tmp_path / "nonexistent-deployments.yaml"
|
||||
monkeypatch.setattr(gitops_dispatcher, "SITES_DIR", sites_dir)
|
||||
monkeypatch.setattr(gitops_dispatcher, "DEPLOYMENTS_FILE", missing_registry)
|
||||
monkeypatch.setattr(gitops_dispatcher, "CONFIG_DIR", tmp_path / "nonexistent-config")
|
||||
|
||||
# Missing registry must fail closed: empty mapping, no resolution
|
||||
assert gitops_dispatcher.get_trusted_repository_mapping() == {}
|
||||
assert gitops_dispatcher.resolve_repository("valid") is None
|
||||
|
||||
# Corrupt YAML registry must also fail closed
|
||||
corrupt_registry = tmp_path / "corrupt-deployments.yaml"
|
||||
corrupt_registry.write_text("schemaVersion: 1.0\nrepositories: [bad list syntax", encoding="utf-8")
|
||||
monkeypatch.setattr(gitops_dispatcher, "DEPLOYMENTS_FILE", corrupt_registry)
|
||||
|
||||
assert gitops_dispatcher.get_trusted_repository_mapping() == {}
|
||||
assert gitops_dispatcher.resolve_repository("valid") is None
|
||||
|
||||
|
||||
|
||||
def test_webhook_verification_valid_signature():
|
||||
"""Ensure valid HMAC-SHA256 signature passes verification."""
|
||||
import hashlib
|
||||
@@ -323,7 +384,13 @@ def test_admission_rejects_branch_mismatch(tmp_path: Path, monkeypatch):
|
||||
"name: docs\ndeployment:\n branch: production\n",
|
||||
encoding="utf-8"
|
||||
)
|
||||
registry = tmp_path / "deployments.yaml"
|
||||
registry.write_text(
|
||||
f'schemaVersion: "1.0"\nrepositories:\n docs:\n path: "{app_dir}"\n',
|
||||
encoding="utf-8",
|
||||
)
|
||||
monkeypatch.setattr(gitops_dispatcher, "SITES_DIR", sites_dir)
|
||||
monkeypatch.setattr(gitops_dispatcher, "DEPLOYMENTS_FILE", registry)
|
||||
|
||||
payload = {
|
||||
"ref": "refs/heads/staging",
|
||||
@@ -343,7 +410,13 @@ def test_admission_rejects_unsupported_strategy(tmp_path: Path, monkeypatch):
|
||||
"name: docs\ndeployment:\n branch: main\n strategy: kubernetes\n",
|
||||
encoding="utf-8"
|
||||
)
|
||||
registry = tmp_path / "deployments.yaml"
|
||||
registry.write_text(
|
||||
f'schemaVersion: "1.0"\nrepositories:\n docs:\n path: "{app_dir}"\n',
|
||||
encoding="utf-8",
|
||||
)
|
||||
monkeypatch.setattr(gitops_dispatcher, "SITES_DIR", sites_dir)
|
||||
monkeypatch.setattr(gitops_dispatcher, "DEPLOYMENTS_FILE", registry)
|
||||
|
||||
payload = {
|
||||
"ref": "refs/heads/main",
|
||||
@@ -363,7 +436,13 @@ def test_admission_rejects_unsupported_actions(tmp_path: Path, monkeypatch):
|
||||
"name: docs\ndeployment:\n branch: main\n actions:\n - git_pull\n - evil_action\n",
|
||||
encoding="utf-8"
|
||||
)
|
||||
registry = tmp_path / "deployments.yaml"
|
||||
registry.write_text(
|
||||
f'schemaVersion: "1.0"\nrepositories:\n docs:\n path: "{app_dir}"\n',
|
||||
encoding="utf-8",
|
||||
)
|
||||
monkeypatch.setattr(gitops_dispatcher, "SITES_DIR", sites_dir)
|
||||
monkeypatch.setattr(gitops_dispatcher, "DEPLOYMENTS_FILE", registry)
|
||||
|
||||
payload = {
|
||||
"ref": "refs/heads/main",
|
||||
@@ -383,7 +462,13 @@ def test_admission_admits_valid_push(tmp_path: Path, monkeypatch):
|
||||
"name: docs\ndeployment:\n branch: main\n actions:\n - git_pull\n - compose_up\n",
|
||||
encoding="utf-8"
|
||||
)
|
||||
registry = tmp_path / "deployments.yaml"
|
||||
registry.write_text(
|
||||
f'schemaVersion: "1.0"\nrepositories:\n docs:\n path: "{app_dir}"\n',
|
||||
encoding="utf-8",
|
||||
)
|
||||
monkeypatch.setattr(gitops_dispatcher, "SITES_DIR", sites_dir)
|
||||
monkeypatch.setattr(gitops_dispatcher, "DEPLOYMENTS_FILE", registry)
|
||||
|
||||
payload = {
|
||||
"ref": "refs/heads/main",
|
||||
@@ -391,6 +476,7 @@ def test_admission_admits_valid_push(tmp_path: Path, monkeypatch):
|
||||
}
|
||||
admitted, target_dir, config, branch, reason = gitops_dispatcher.admit_deployment(payload, event_type="push")
|
||||
assert admitted is True
|
||||
|
||||
assert "Admitted" in reason
|
||||
assert target_dir == app_dir.resolve()
|
||||
assert branch == "main"
|
||||
@@ -702,6 +788,188 @@ def test_validate_compose_security_nonexistent_file(tmp_path: Path):
|
||||
assert err is None
|
||||
|
||||
|
||||
@pytest.mark.parametrize("malicious_volume", [
|
||||
"../../etc/passwd:/mnt/passwd:ro",
|
||||
"./../../Core/nixos/secrets.yaml:/secrets.yaml",
|
||||
"../other-workload/data:/data",
|
||||
])
|
||||
def test_validate_compose_security_blocks_relative_traversal(
|
||||
tmp_path: Path, malicious_volume: str
|
||||
):
|
||||
"""Ensure relative path traversals in volume mounts cannot escape workload root."""
|
||||
app_dir = tmp_path / "my-app"
|
||||
app_dir.mkdir(parents=True)
|
||||
|
||||
compose_file = app_dir / "docker-compose.yml"
|
||||
compose_file.write_text(
|
||||
f"services:\n web:\n image: nginx\n volumes:\n - '{malicious_volume}'\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
valid, err = gitops_dispatcher.validate_compose_security(compose_file, app_dir, app_name="my-app")
|
||||
assert valid is False, f"Expected relative traversal '{malicious_volume}' to be rejected!"
|
||||
assert err is not None and "prohibited host bind mount" in err
|
||||
|
||||
|
||||
def test_validate_compose_security_blocks_cross_tenant_state_mounts(
|
||||
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
||||
):
|
||||
"""Ensure workload 'my-app' cannot mount another workload's state directory ('other-app')."""
|
||||
sites_dir = tmp_path / "Sites"
|
||||
app_dir = sites_dir / "my-app"
|
||||
app_dir.mkdir(parents=True)
|
||||
|
||||
state_root = tmp_path / "var/lib/homelab"
|
||||
(state_root / "my-app").mkdir(parents=True)
|
||||
(state_root / "other-app").mkdir(parents=True)
|
||||
monkeypatch.setenv("HOMELAB_STATE_ROOT", str(state_root))
|
||||
|
||||
# Cross-tenant state mount
|
||||
compose_file = app_dir / "docker-compose.yml"
|
||||
compose_file.write_text(
|
||||
f"services:\n web:\n image: nginx\n volumes:\n - '{state_root}/other-app:/data'\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
valid, err = gitops_dispatcher.validate_compose_security(compose_file, app_dir, app_name="my-app")
|
||||
assert valid is False, "Expected cross-tenant state mount to be rejected!"
|
||||
assert err is not None and ("prohibited host bind mount" in err or "cross-tenant" in err.lower())
|
||||
|
||||
# Authorized own state mount must pass
|
||||
compose_file.write_text(
|
||||
f"services:\n web:\n image: nginx\n volumes:\n - '{state_root}/my-app:/data'\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
valid_own, err_own = gitops_dispatcher.validate_compose_security(compose_file, app_dir, app_name="my-app")
|
||||
assert valid_own is True, f"Own state mount should be permitted, got error: {err_own}"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("unsafe_directive", [
|
||||
"cap_add:\n - SYS_ADMIN",
|
||||
"pid: host",
|
||||
"ipc: host",
|
||||
"userns_mode: host",
|
||||
"devices:\n - /dev/sda:/dev/sda",
|
||||
"security_opt:\n - apparmor:unconfined",
|
||||
])
|
||||
def test_validate_compose_security_blocks_privilege_escalation_primitives(
|
||||
tmp_path: Path, unsafe_directive: str
|
||||
):
|
||||
"""Ensure dangerous container breakout capabilities and host namespaces are blocked."""
|
||||
compose_file = tmp_path / "docker-compose.yml"
|
||||
compose_file.write_text(
|
||||
f"services:\n app:\n image: alpine\n {unsafe_directive}\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
valid, err = gitops_dispatcher.validate_compose_security(compose_file, tmp_path, app_name="app")
|
||||
assert valid is False, f"Directive should be blocked:\n{unsafe_directive}"
|
||||
assert err is not None
|
||||
|
||||
|
||||
def test_validate_compose_security_rejects_top_level_include(tmp_path: Path):
|
||||
"""Ensure top-level Compose include directives are rejected to prevent out-of-tree includes."""
|
||||
compose_file = tmp_path / "docker-compose.yml"
|
||||
compose_file.write_text("""
|
||||
include:
|
||||
- /etc/shadow
|
||||
services:
|
||||
app:
|
||||
image: alpine
|
||||
""", encoding="utf-8")
|
||||
valid, err = gitops_dispatcher.validate_compose_security(compose_file, tmp_path, app_name="app")
|
||||
assert valid is False
|
||||
assert err is not None and "include" in err.lower()
|
||||
|
||||
|
||||
def test_validate_compose_security_rejects_symlink_escape(tmp_path: Path):
|
||||
"""Ensure docker-compose.yml cannot be a symlink escaping the workload directory."""
|
||||
app_dir = tmp_path / "my-app"
|
||||
app_dir.mkdir(parents=True)
|
||||
outside_file = tmp_path / "outside-compose.yml"
|
||||
outside_file.write_text("services:\n app:\n image: alpine\n", encoding="utf-8")
|
||||
|
||||
compose_link = app_dir / "docker-compose.yml"
|
||||
compose_link.symlink_to(outside_file)
|
||||
|
||||
valid, err = gitops_dispatcher.validate_compose_security(compose_link, app_dir, app_name="my-app")
|
||||
assert valid is False
|
||||
assert err is not None and "symlink" in err.lower()
|
||||
|
||||
|
||||
def test_validate_compose_security_rejects_escaping_env_file(tmp_path: Path):
|
||||
"""Ensure services cannot use env_file to read secrets outside the workload root."""
|
||||
app_dir = tmp_path / "my-app"
|
||||
app_dir.mkdir(parents=True)
|
||||
(app_dir / "valid.env").write_text("A=1\n", encoding="utf-8")
|
||||
|
||||
# 1. Escaping absolute path
|
||||
compose_file = app_dir / "docker-compose.yml"
|
||||
compose_file.write_text("""
|
||||
services:
|
||||
app:
|
||||
image: alpine
|
||||
env_file: /run/secrets/homeserver.env
|
||||
""", encoding="utf-8")
|
||||
valid, err = gitops_dispatcher.validate_compose_security(compose_file, app_dir, app_name="my-app")
|
||||
assert valid is False
|
||||
assert err is not None and "env_file" in err.lower()
|
||||
|
||||
# 2. Escaping relative path in list
|
||||
compose_file.write_text("""
|
||||
services:
|
||||
app:
|
||||
image: alpine
|
||||
env_file:
|
||||
- valid.env
|
||||
- ../../Core/.env
|
||||
""", encoding="utf-8")
|
||||
valid, err = gitops_dispatcher.validate_compose_security(compose_file, app_dir, app_name="my-app")
|
||||
assert valid is False
|
||||
assert err is not None and "env_file" in err.lower()
|
||||
|
||||
# 3. Valid local env_file
|
||||
compose_file.write_text("""
|
||||
services:
|
||||
app:
|
||||
image: alpine
|
||||
env_file: valid.env
|
||||
""", encoding="utf-8")
|
||||
valid, err = gitops_dispatcher.validate_compose_security(compose_file, app_dir, app_name="my-app")
|
||||
assert valid is True
|
||||
assert err is None
|
||||
|
||||
|
||||
def test_validate_compose_security_rejects_undeclared_named_volumes(tmp_path: Path):
|
||||
"""Ensure ambiguous volume paths not declared in top-level volumes are rejected."""
|
||||
compose_file = tmp_path / "docker-compose.yml"
|
||||
compose_file.write_text("""
|
||||
services:
|
||||
app:
|
||||
image: alpine
|
||||
volumes:
|
||||
- rogue_named_volume:/data
|
||||
""", encoding="utf-8")
|
||||
valid, err = gitops_dispatcher.validate_compose_security(compose_file, tmp_path, app_name="my-app")
|
||||
assert valid is False
|
||||
assert err is not None and "undeclared" in err.lower()
|
||||
|
||||
|
||||
def test_validate_compose_security_handles_string_security_opt(tmp_path: Path):
|
||||
"""Ensure security_opt specified as string instead of list is strictly checked."""
|
||||
compose_file = tmp_path / "docker-compose.yml"
|
||||
compose_file.write_text("""
|
||||
services:
|
||||
app:
|
||||
image: alpine
|
||||
security_opt: "apparmor:unconfined"
|
||||
""", encoding="utf-8")
|
||||
valid, err = gitops_dispatcher.validate_compose_security(compose_file, tmp_path, app_name="my-app")
|
||||
assert valid is False
|
||||
assert err is not None and "security_opt" in err.lower()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
Security invariant tests for Docker Compose and container isolation.
|
||||
"""
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import yaml
|
||||
@@ -10,6 +14,7 @@ CORE_ROOT = Path(__file__).resolve().parent.parent.parent
|
||||
|
||||
|
||||
def test_socket_proxy_is_strictly_read_only():
|
||||
|
||||
"""Ensure socket-proxy container blocks state-modifying requests (POST=0, DELETE=0)."""
|
||||
compose_path = CORE_ROOT / "docker-compose.yml"
|
||||
with open(compose_path, encoding="utf-8") as f:
|
||||
@@ -77,3 +82,116 @@ def test_portainer_is_deprecated_and_absent():
|
||||
|
||||
volumes = compose.get("volumes", {}) or {}
|
||||
assert "portainer_data" not in volumes, "Deprecated volume 'portainer_data' must not exist in docker-compose.yml"
|
||||
|
||||
|
||||
def test_no_eval_in_appctl_script():
|
||||
"""Ensure scripts/appctl never uses eval on dynamic environment or manifest payloads."""
|
||||
appctl_path = CORE_ROOT / "scripts" / "appctl"
|
||||
content = appctl_path.read_text(encoding="utf-8")
|
||||
assert "eval " not in content, "Dangerous 'eval' detected in scripts/appctl!"
|
||||
|
||||
|
||||
def test_appctl_env_injection_resilience(tmp_path: Path):
|
||||
"""Ensure environment values from app.yaml cannot execute shell commands via command substitution
|
||||
|
||||
in scripts/appctl during environment setup. Executes scripts/appctl directly with a mock docker binary.
|
||||
"""
|
||||
canary = tmp_path / "pwned.txt"
|
||||
payload = f"$(touch {canary})"
|
||||
|
||||
# 1. Setup mock Sites directory with vulnerable app.yaml and docker-compose.yml
|
||||
sites_dir = tmp_path / "Sites"
|
||||
app_dir = sites_dir / "vuln-app"
|
||||
app_dir.mkdir(parents=True)
|
||||
|
||||
app_yaml = f"""
|
||||
name: vuln-app
|
||||
domain: vuln.example.test
|
||||
env:
|
||||
INJECTION_TEST: '{payload}'
|
||||
NORMAL_VAR: 'safe_value'
|
||||
"""
|
||||
|
||||
(app_dir / "app.yaml").write_text(app_yaml.strip(), encoding="utf-8")
|
||||
(app_dir / "docker-compose.yml").write_text("services:\n web:\n image: nginx\n", encoding="utf-8")
|
||||
|
||||
# 2. Setup mock docker binary to capture environment without requiring a running Docker daemon
|
||||
mock_bin = tmp_path / "bin"
|
||||
mock_bin.mkdir()
|
||||
mock_docker = mock_bin / "docker"
|
||||
bash_bin = shutil.which("bash") or "bash"
|
||||
|
||||
mock_docker_script = f"""#!{bash_bin}
|
||||
if [ "$1" = "compose" ] && [ "$2" = "config" ]; then
|
||||
echo "MOCK_DOCKER_COMPOSE_CONFIG"
|
||||
echo "CAPTURED_INJECTION=$INJECTION_TEST"
|
||||
echo "CAPTURED_NORMAL=$NORMAL_VAR"
|
||||
exit 0
|
||||
fi
|
||||
exit 0
|
||||
"""
|
||||
mock_docker.write_text(mock_docker_script, encoding="utf-8")
|
||||
mock_docker.chmod(0o755)
|
||||
|
||||
# 3. Execute scripts/appctl config vuln-app directly
|
||||
appctl_path = CORE_ROOT / "scripts" / "appctl"
|
||||
env = os.environ.copy()
|
||||
if "NIX_PYTHONPATH" in env and "PYTHONPATH" not in env:
|
||||
env["PYTHONPATH"] = env["NIX_PYTHONPATH"]
|
||||
env["PATH"] = f"{mock_bin}:{Path(sys.executable).parent}:{env['PATH']}"
|
||||
env["PYTHON_BIN"] = sys.executable
|
||||
env["SITES_DIR"] = str(sites_dir)
|
||||
env["HOMELAB_DOMAIN"] = "example.test"
|
||||
env["CORE_DIR"] = str(CORE_ROOT)
|
||||
|
||||
res = subprocess.run(
|
||||
[bash_bin, str(appctl_path), "config", "vuln-app"],
|
||||
env=env,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=False,
|
||||
)
|
||||
|
||||
|
||||
# 4. Assertions: command substitution was not executed, script ran, and mock docker received literal value
|
||||
assert not canary.exists(), "Command substitution was executed on the host during environment setup!"
|
||||
assert res.returncode == 0, f"appctl config failed: {res.stderr}\nStdout: {res.stdout}"
|
||||
assert "MOCK_DOCKER_COMPOSE_CONFIG" in res.stdout
|
||||
assert f"CAPTURED_INJECTION={payload}" in res.stdout
|
||||
assert "CAPTURED_NORMAL=safe_value" in res.stdout
|
||||
assert "/dangerous/override" not in res.stdout
|
||||
|
||||
|
||||
def test_platform_genericism_no_hardcoded_personal_domains_in_scripts_and_tests():
|
||||
"""Ensure personal domains and operator usernames are absent from scripts, tests, and documentation."""
|
||||
forbidden = ["roadtotech.me", "kiskaadee"]
|
||||
root_dirs = [CORE_ROOT / "scripts", CORE_ROOT / "tests", CORE_ROOT / "docs"]
|
||||
root_files = [
|
||||
CORE_ROOT / "README.md",
|
||||
CORE_ROOT / "ROADMAP.md",
|
||||
CORE_ROOT / "AGENTS.md",
|
||||
CORE_ROOT / "SECURITY.md",
|
||||
CORE_ROOT / "flake.nix",
|
||||
]
|
||||
violations = []
|
||||
|
||||
candidate_files = list(root_files)
|
||||
for root_dir in root_dirs:
|
||||
candidate_files.extend(root_dir.rglob("*"))
|
||||
|
||||
for file_path in candidate_files:
|
||||
if (
|
||||
file_path.is_file()
|
||||
and file_path.suffix in (".py", ".sh", ".bash", ".yml", ".yaml", ".md", ".nix", "")
|
||||
and file_path.name != "test_security_invariants.py"
|
||||
):
|
||||
content = file_path.read_text(encoding="utf-8", errors="ignore")
|
||||
for term in forbidden:
|
||||
if term in content:
|
||||
violations.append(f"{file_path.relative_to(CORE_ROOT)}: contains prohibited literal '{term}'")
|
||||
|
||||
assert not violations, "Platform genericism violations detected:\n" + "\n".join(violations)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ def test_sites_app_normalization(app_factory: AppFactory):
|
||||
dir_name="homelab-custom",
|
||||
manifest_yaml="""
|
||||
name: testapp
|
||||
# Missing domain - should fallback to <name>.roadtotech.me
|
||||
# Missing domain - should fallback to <name>.<HOMELAB_DOMAIN>
|
||||
aliases: single-string-alias # should become a list[str]
|
||||
auth: "False" # should evaluate based on boolean casting
|
||||
homepage:
|
||||
@@ -129,7 +129,7 @@ def test_sites_app_source_provenance_normalization(app_factory: AppFactory):
|
||||
name: bitetrack
|
||||
source:
|
||||
type: git
|
||||
url: https://git.roadtotech.me/kiskaadee/bitetrack.git
|
||||
url: https://git.example.com/operator/bitetrack.git
|
||||
ref: v1.2.0
|
||||
"""
|
||||
)
|
||||
@@ -139,7 +139,7 @@ def test_sites_app_source_provenance_normalization(app_factory: AppFactory):
|
||||
manifest_yaml="""
|
||||
name: doc2site
|
||||
source:
|
||||
url: https://git.roadtotech.me/kiskaadee/doc2site.git
|
||||
url: https://git.example.com/operator/doc2site.git
|
||||
"""
|
||||
)
|
||||
# 3. Image-only app (no source block)
|
||||
@@ -156,7 +156,7 @@ def test_sites_app_source_provenance_normalization(app_factory: AppFactory):
|
||||
assert bitetrack is not None
|
||||
assert bitetrack.source is not None
|
||||
assert bitetrack.source.type == "git"
|
||||
assert bitetrack.source.url == "https://git.roadtotech.me/kiskaadee/bitetrack.git"
|
||||
assert bitetrack.source.url == "https://git.example.com/operator/bitetrack.git"
|
||||
assert bitetrack.source.ref == "v1.2.0"
|
||||
assert bitetrack.to_dict()["source"]["ref"] == "v1.2.0"
|
||||
|
||||
@@ -349,8 +349,8 @@ def test_homepage_sync_core_services_domain_isolation(
|
||||
hp_config_dir = mock_core_dir / "config" / "homepage"
|
||||
hp_config_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
monkeypatch.setattr(engine, "HOMELAB_DOMAIN", "roadtotech.me")
|
||||
monkeypatch.setenv("DOMAIN", "mermaid.roadtotech.me")
|
||||
monkeypatch.setattr(engine, "HOMELAB_DOMAIN", "example.com")
|
||||
monkeypatch.setenv("DOMAIN", "mermaid.example.com")
|
||||
|
||||
engine.cmd_sync_homepage(["--homepage-dir=" + str(hp_config_dir)])
|
||||
|
||||
@@ -358,10 +358,10 @@ def test_homepage_sync_core_services_domain_isolation(
|
||||
assert output_file.exists()
|
||||
content = output_file.read_text()
|
||||
|
||||
assert "https://dashboard.roadtotech.me" in content
|
||||
assert "https://traefik.roadtotech.me" in content
|
||||
assert "https://auth.roadtotech.me" in content
|
||||
assert "mermaid.roadtotech.me" not in content
|
||||
assert "https://dashboard.example.com" in content
|
||||
assert "https://traefik.example.com" in content
|
||||
assert "https://auth.example.com" in content
|
||||
assert "mermaid.example.com" not in content
|
||||
|
||||
|
||||
def test_resolve_core_stack_type():
|
||||
@@ -378,3 +378,88 @@ def test_resolve_core_stack_type():
|
||||
assert traefik is not None
|
||||
assert traefik.to_dict()["type"] == "core_service"
|
||||
assert traefik.container == "traefik"
|
||||
|
||||
|
||||
def test_manifest_parsing_delegates_to_core_manifest_and_validates_env(app_factory: AppFactory):
|
||||
"""Ensure manifest parsing uses core_manifest and catches invalid env keys."""
|
||||
app_factory.create(
|
||||
dir_name="homelab-badenv",
|
||||
manifest_yaml="""
|
||||
name: badenv
|
||||
env:
|
||||
PATH: /override/bin
|
||||
""",
|
||||
)
|
||||
apps = engine.get_sites_apps()
|
||||
app = engine.resolve_app("badenv", apps)
|
||||
assert app is not None
|
||||
assert app.manifest_error is not None
|
||||
assert "Invalid or reserved environment variable key" in app.manifest_error
|
||||
|
||||
|
||||
def test_cmd_resolve_fails_closed_on_manifest_error(app_factory: AppFactory, capsys: pytest.CaptureFixture):
|
||||
"""Ensure cmd_resolve exits with non-zero on workload with manifest errors."""
|
||||
app_factory.create(
|
||||
dir_name="homelab-corrupt",
|
||||
manifest_yaml="""
|
||||
name: corrupt
|
||||
env:
|
||||
ILLEGAL-KEY: forbidden
|
||||
""",
|
||||
)
|
||||
with pytest.raises(SystemExit) as exc_info:
|
||||
engine.cmd_resolve(["corrupt"])
|
||||
assert exc_info.value.code != 0
|
||||
captured = capsys.readouterr()
|
||||
assert "invalid manifest" in captured.err.lower() or "error" in captured.err.lower()
|
||||
|
||||
|
||||
def test_cmd_resolve_fails_closed_on_missing_app_yaml(mock_sites_dir: Path):
|
||||
"""Ensure cmd_resolve exits with non-zero if workload has no app.yaml."""
|
||||
no_manifest_dir = mock_sites_dir / "homelab-nomanifest"
|
||||
no_manifest_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
with pytest.raises(SystemExit) as exc_info:
|
||||
engine.cmd_resolve(["nomanifest"])
|
||||
assert exc_info.value.code != 0
|
||||
|
||||
|
||||
def test_unification_uses_core_manifest_dataclasses(app_factory: AppFactory):
|
||||
"""Ensure SitesApp uses core_manifest SourceConfig and HomepageConfig."""
|
||||
import core_manifest
|
||||
|
||||
app_factory.create(
|
||||
dir_name="homelab-unified",
|
||||
manifest_yaml="""
|
||||
name: unified
|
||||
source:
|
||||
url: https://git.example.com/operator/unified.git
|
||||
ref: v1.0.0
|
||||
homepage:
|
||||
title: Unified App
|
||||
weight: 30
|
||||
""",
|
||||
)
|
||||
apps = engine.get_sites_apps()
|
||||
app = engine.resolve_app("unified", apps)
|
||||
assert app is not None
|
||||
assert isinstance(app.source, core_manifest.SourceConfig)
|
||||
assert isinstance(app.homepage, core_manifest.HomepageConfig)
|
||||
assert app.source.ref_type == core_manifest.RefType.TAG
|
||||
assert app.source.transport == core_manifest.TransportScheme.HTTPS
|
||||
|
||||
|
||||
def test_cmd_list_flags_manifest_error(app_factory: AppFactory, capsys: pytest.CaptureFixture):
|
||||
"""Ensure cmd_list flags workloads with manifest errors instead of swallowing them."""
|
||||
app_factory.create(
|
||||
dir_name="homelab-broken",
|
||||
manifest_yaml="""
|
||||
name: broken
|
||||
env:
|
||||
SHELL: /bin/sh
|
||||
""",
|
||||
)
|
||||
engine.cmd_list([])
|
||||
captured = capsys.readouterr()
|
||||
assert "Manifest Error" in captured.out
|
||||
|
||||
@@ -12,6 +12,7 @@ CORE_ROOT = Path(__file__).resolve().parent.parent.parent
|
||||
sys.path.insert(0, str(CORE_ROOT / "scripts"))
|
||||
|
||||
from core_manifest import (
|
||||
Manifest,
|
||||
ManifestValidationError,
|
||||
RefType,
|
||||
TransportScheme,
|
||||
@@ -22,25 +23,26 @@ from core_manifest import (
|
||||
|
||||
|
||||
def test_validate_transport_https():
|
||||
scheme, url = validate_transport("https://gitea.roadtotech.me/kiskaadee/homelab-snappymail.git")
|
||||
|
||||
scheme, url = validate_transport("https://git.example.com/operator/homelab-snappymail.git")
|
||||
assert scheme == TransportScheme.HTTPS
|
||||
assert url == "https://gitea.roadtotech.me/kiskaadee/homelab-snappymail.git"
|
||||
assert url == "https://git.example.com/operator/homelab-snappymail.git"
|
||||
|
||||
|
||||
def test_validate_transport_ssh():
|
||||
scheme, url = validate_transport("ssh://git@gitea.roadtotech.me:2223/kiskaadee/homelab-docs.git")
|
||||
scheme, url = validate_transport("ssh://git@git.example.com:2223/operator/homelab-docs.git")
|
||||
assert scheme == TransportScheme.SSH
|
||||
assert url == "ssh://git@gitea.roadtotech.me:2223/kiskaadee/homelab-docs.git"
|
||||
assert url == "ssh://git@git.example.com:2223/operator/homelab-docs.git"
|
||||
|
||||
|
||||
def test_validate_transport_git_scp():
|
||||
scheme, url = validate_transport("git@github.com:kiskaadee/custom-workload.git")
|
||||
scheme, url = validate_transport("git@github.com:operator/custom-workload.git")
|
||||
assert scheme == TransportScheme.GIT_SCP
|
||||
assert url == "git@github.com:kiskaadee/custom-workload.git"
|
||||
assert url == "git@github.com:operator/custom-workload.git"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("insecure_url", [
|
||||
"http://insecure.roadtotech.me/repo.git",
|
||||
"http://insecure.example.com/repo.git",
|
||||
"http://github.com/repo.git",
|
||||
])
|
||||
def test_validate_transport_rejects_http(insecure_url: str):
|
||||
@@ -50,7 +52,7 @@ def test_validate_transport_rejects_http(insecure_url: str):
|
||||
|
||||
@pytest.mark.parametrize("traversal_url", [
|
||||
"../../etc/shadow",
|
||||
"/home/kiskaadee/secret",
|
||||
"/home/operator/secret",
|
||||
"~/vault",
|
||||
"file:///etc/passwd",
|
||||
])
|
||||
@@ -83,7 +85,7 @@ schemaVersion: "1.0"
|
||||
name: "bitetrack"
|
||||
aliases:
|
||||
- "bt"
|
||||
domain: "bitetrack.roadtotech.me"
|
||||
domain: "bitetrack.example.com"
|
||||
description: "Nutrition and macro tracking application"
|
||||
visible: true
|
||||
auth: true
|
||||
@@ -93,7 +95,7 @@ env:
|
||||
PORT: 8080
|
||||
source:
|
||||
type: git
|
||||
url: "https://git.roadtotech.me/kiskaadee/bitetrack.git"
|
||||
url: "https://git.example.com/operator/bitetrack.git"
|
||||
ref: "v1.2.0"
|
||||
deployment:
|
||||
strategy: compose
|
||||
@@ -116,7 +118,7 @@ homepage:
|
||||
assert manifest.is_class_b is False
|
||||
assert manifest.is_internal is False
|
||||
assert manifest.source is not None
|
||||
assert manifest.source.url == "https://git.roadtotech.me/kiskaadee/bitetrack.git"
|
||||
assert manifest.source.url == "https://git.example.com/operator/bitetrack.git"
|
||||
assert manifest.source.ref == "v1.2.0"
|
||||
assert manifest.source.ref_type == RefType.TAG
|
||||
assert manifest.source.transport == TransportScheme.HTTPS
|
||||
@@ -128,7 +130,7 @@ homepage:
|
||||
def test_parse_manifest_class_b_image_only():
|
||||
raw_yaml = """
|
||||
name: "snappymail"
|
||||
domain: "mail.roadtotech.me"
|
||||
domain: "mail.example.com"
|
||||
description: "Webmail Client"
|
||||
deployment:
|
||||
actions:
|
||||
@@ -144,7 +146,7 @@ deployment:
|
||||
|
||||
def test_parse_manifest_rejects_missing_name():
|
||||
with pytest.raises(ManifestValidationError, match="missing mandatory string field 'name'"):
|
||||
parse_manifest("domain: test.roadtotech.me\n")
|
||||
parse_manifest("domain: test.example.com\n")
|
||||
|
||||
|
||||
def test_parse_manifest_rejects_invalid_name():
|
||||
@@ -181,3 +183,81 @@ def test_parse_manifest_from_path(tmp_path: Path):
|
||||
manifest = parse_manifest(manifest_file)
|
||||
assert manifest.name == "file-app"
|
||||
assert manifest.is_internal is True
|
||||
|
||||
|
||||
@pytest.mark.parametrize("invalid_key", [
|
||||
"123_BAD",
|
||||
"INVALID-KEY",
|
||||
"FOO;BAR",
|
||||
"KEY WITH SPACE",
|
||||
"PATH",
|
||||
"LD_PRELOAD",
|
||||
"IFS",
|
||||
"CORE_DIR",
|
||||
"SITES_DIR",
|
||||
])
|
||||
def test_parse_manifest_rejects_invalid_or_reserved_env_keys(invalid_key: str):
|
||||
raw_yaml = f"""
|
||||
name: "app"
|
||||
env:
|
||||
"{invalid_key}": "some_value"
|
||||
"""
|
||||
with pytest.raises(ManifestValidationError, match="Invalid or reserved environment variable key"):
|
||||
parse_manifest(raw_yaml)
|
||||
|
||||
|
||||
def test_parse_manifest_accepts_valid_env_keys():
|
||||
raw_yaml = """
|
||||
name: "app"
|
||||
env:
|
||||
PROJECT_PATH: "/mnt/data"
|
||||
CUSTOM_PORT_1: "8080"
|
||||
_INTERNAL_FLAG: "true"
|
||||
"""
|
||||
manifest = parse_manifest(raw_yaml)
|
||||
assert manifest.env["PROJECT_PATH"] == "/mnt/data"
|
||||
assert manifest.env["CUSTOM_PORT_1"] == "8080"
|
||||
assert manifest.env["_INTERNAL_FLAG"] == "true"
|
||||
|
||||
|
||||
def test_parse_manifest_rejects_extra_fields():
|
||||
"""Ensure extra='forbid' rejects unrecognized top-level manifest keys."""
|
||||
raw_yaml = """
|
||||
name: "app"
|
||||
unrecognized_field: "should_fail"
|
||||
"""
|
||||
with pytest.raises(ManifestValidationError, match="unrecognized or forbidden field"):
|
||||
parse_manifest(raw_yaml)
|
||||
|
||||
|
||||
def test_parse_manifest_rejects_extra_fields_in_nested_blocks():
|
||||
"""Ensure extra='forbid' rejects unrecognized keys in nested configuration blocks."""
|
||||
raw_yaml = """
|
||||
name: "app"
|
||||
deployment:
|
||||
strategy: compose
|
||||
unknown_deploy_option: "forbidden"
|
||||
"""
|
||||
with pytest.raises(ManifestValidationError):
|
||||
parse_manifest(raw_yaml)
|
||||
|
||||
|
||||
def test_manifest_pydantic_serialization():
|
||||
"""Ensure Manifest operates as a Pydantic v2 model with correct serialization."""
|
||||
from pydantic import BaseModel
|
||||
|
||||
raw_yaml = """
|
||||
name: "serialized-app"
|
||||
domain: "app.example.test"
|
||||
description: "Pydantic serialization test"
|
||||
"""
|
||||
manifest = parse_manifest(raw_yaml)
|
||||
assert isinstance(manifest, Manifest)
|
||||
assert isinstance(manifest, BaseModel)
|
||||
|
||||
dumped = manifest.model_dump(by_alias=True)
|
||||
assert dumped["name"] == "serialized-app"
|
||||
assert dumped["schemaVersion"] == "1.0"
|
||||
assert manifest.to_dict()["name"] == "serialized-app"
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ def test_resolve_upstream_provenance_image_only():
|
||||
|
||||
def test_resolve_upstream_provenance_synced():
|
||||
source = SourceConfig(
|
||||
url="https://git.roadtotech.me/kiskaadee/app.git",
|
||||
url="https://git.example.com/operator/app.git",
|
||||
ref="main",
|
||||
ref_type=RefType.BRANCH,
|
||||
transport=TransportScheme.HTTPS,
|
||||
@@ -106,7 +106,7 @@ def test_resolve_upstream_provenance_synced():
|
||||
|
||||
def test_resolve_upstream_provenance_update_available():
|
||||
source = SourceConfig(
|
||||
url="https://git.roadtotech.me/kiskaadee/app.git",
|
||||
url="https://git.example.com/operator/app.git",
|
||||
ref="main",
|
||||
ref_type=RefType.BRANCH,
|
||||
transport=TransportScheme.HTTPS,
|
||||
@@ -157,7 +157,7 @@ def test_resolve_upstream_provenance_unreachable():
|
||||
def test_resolve_upstream_provenance_pinned_commit():
|
||||
sha = "1234567890abcdef1234567890abcdef12345678"
|
||||
source = SourceConfig(
|
||||
url="https://git.roadtotech.me/app.git",
|
||||
url="https://git.example.com/app.git",
|
||||
ref=sha,
|
||||
ref_type=RefType.COMMIT,
|
||||
transport=TransportScheme.HTTPS,
|
||||
|
||||
@@ -11,3 +11,23 @@ x 2026-10-13 (A) Close authorization design enforcing token-everywhere policy in
|
||||
x 2026-10-13 (B) Specify daemon execution and privilege boundaries for Docker, subprocesses, and filesystem roots in docs/plans/p4-readiness-plan.md +security @p4-gate
|
||||
x 2026-10-13 (B) Define append-only audit telemetry schema, lifecycle, and failure handling semantics in docs/plans/p4-readiness-plan.md +audit @p4-gate
|
||||
x 2026-10-13 (C) Establish P4 acceptance test matrix and definition of done before daemon implementation in docs/plans/p4-readiness-plan.md +test @p4-gate
|
||||
x 2026-10-14 (A) Eliminate eval in scripts/appctl and enforce strict env key validation in scripts/core_manifest.py +security @appctl
|
||||
x 2026-10-15 (A) Enforce deployments.yaml as sole registry and remove dynamic discovery fallback in scripts/gitops_dispatcher.py +registry @gitops
|
||||
x 2026-10-15 (A) Harden validate_compose_security in scripts/gitops_dispatcher.py blocking relative traversal, cross-tenant mounts, and privilege escalation +compose @gitops
|
||||
x 2026-10-15 (A) Unify manifest parsing on core_manifest.py and eliminate duplicate parsers in scripts/appctl_engine.py +manifest @engine
|
||||
x 2026-10-15 (A) Codify Platform Genericism invariant in AGENTS.md and add Pydantic to flake.nix, pyproject.toml, and scripts/test +invariant @core
|
||||
x 2026-10-15 (A) Add pydantic to host NixOS runtime and constrain dependency range in flake.nix and nixos/configuration.nix +nixos @core
|
||||
x 2026-10-15 (A) Wire app_name and harden compose validator for env_file and undeclared volumes in scripts/gitops_dispatcher.py +compose @gitops
|
||||
x 2026-10-15 (B) Scrub hardcoded domain defaults across scripts and tests enforcing instance-agnostic parameterization +generic @core
|
||||
x 2026-10-15 (A) De-tautologize appctl env injection test to execute scripts/appctl directly with mock docker in tests/security/test_security_invariants.py +test @security
|
||||
x 2026-10-15 (A) Clarify Pydantic v2 target architecture, strict typing rules, and domain precedence in docs/plans/p4-readiness-plan.md +docs @p4-gate
|
||||
x 2026-10-15 (A) Migrate core_manifest.py to Pydantic v2 models for strict type validation and serialization +manifest @schema
|
||||
(A) Scaffold asyncio daemon server with Pydantic request/response models supporting dual transports in scripts/appctl_daemon.py +daemon @p4
|
||||
|
||||
(A) Implement unit and integration tests for dual-transport requests and error handling in tests/unit/test_appctl_daemon.py +test @p4
|
||||
(B) Implement command-oriented operational router wiring domain actions to in-process appctl_engine.py methods and fixed subprocess executions +router @p4
|
||||
(B) Implement token authentication middleware validating user-scoped Bearer tokens for mutating requests +auth @p4
|
||||
(B) Implement append-only audit logger writing structured RFC JSONL records with fail-closed disk guard +audit @p4
|
||||
(B) Scrub remaining hardcoded domain references across NixOS modules, Compose stack, and repository documentation +generic @core
|
||||
(C) Re-implement scripts/appctl as a thin client dispatching JSON requests to the daemon Unix domain socket +cli @p4
|
||||
(C) Create NixOS systemd unit module for homelab-appctl.service with strict sandboxing and socket management +nixos @p4
|
||||
@@ -2,7 +2,185 @@ version = 1
|
||||
revision = 5
|
||||
requires-python = ">=3.13"
|
||||
|
||||
[[package]]
|
||||
name = "annotated-types"
|
||||
version = "0.8.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/5f/56/a8120250d128bed162cd73c76d45f6ef9991f3e068f62a8ee060afa3104a/annotated_types-0.8.0.tar.gz", hash = "sha256:13b2beaad985e05e2d6407ee4c4f35590b11f8d693a258a561055cac8f64cab7", size = 15893, upload-time = "2026-07-23T20:16:13.995Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/99/91/8acff4f5e50511b911bbccb72b8628a49c68ce14148cd9f6431094859a90/annotated_types-0.8.0-py3-none-any.whl", hash = "sha256:f072f4d804ea359e4eaf198b1af7a8b0943881a87f31bb764f8bf219bb9419e0", size = 13427, upload-time = "2026-07-23T20:16:12.938Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "homelab-core"
|
||||
version = "0.1.0"
|
||||
source = { virtual = "." }
|
||||
dependencies = [
|
||||
{ name = "pydantic" },
|
||||
{ name = "pyyaml" },
|
||||
]
|
||||
|
||||
[package.metadata]
|
||||
requires-dist = [
|
||||
{ name = "pydantic", specifier = ">=2.0,<3.0" },
|
||||
{ name = "pyyaml", specifier = ">=6.0" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pydantic"
|
||||
version = "2.14.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "annotated-types" },
|
||||
{ name = "pydantic-core" },
|
||||
{ name = "typing-extensions" },
|
||||
{ name = "typing-inspection" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/7c/0b/8e10b2e693af8ec54346a14caf36221334775975a747c9ceaa3f8371d96d/pydantic-2.14.1.tar.gz", hash = "sha256:94f478203dd03404682a1ada216965651dd74b1d2d5ffd62e00e0837caab5c26", size = 900362, upload-time = "2026-10-11T18:37:55.396Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/35/ea/a56b9fe5066f3537b7882f77e9c5dfb26d8c2eefdaed9b5fc73d57b4dc22/pydantic-2.14.1-py3-none-any.whl", hash = "sha256:9195d967ec791692a04438115466764fb8b9a27b31f14a760437694f40d6b454", size = 488106, upload-time = "2026-10-11T18:37:53.437Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pydantic-core"
|
||||
version = "2.50.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "typing-extensions" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/a6/24/af4ec4be49fbc810f35b0bdcacc3d433b56bbfa469fd3bfd4ae116cd9bf1/pydantic_core-2.50.1.tar.gz", hash = "sha256:e50d7b94baac6c7d09927fa5ca5800a0c7ee5015c7fcff65beb3a1931b5a6e09", size = 513515, upload-time = "2026-10-11T18:35:44.82Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/ae/57/0e237d7091d2cd44a35d243b7344227f90440166860469cd036afc23a04d/pydantic_core-2.50.1-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:d5e062c01286d861fd6a1c4ff6e063547b3e713067f2df033c0ff97ac2ca006b", size = 2222774, upload-time = "2026-10-11T18:32:43.103Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/f7/b9/c720e56858d4e1539503297ed37063e0c08e0f3541c41b777f6a800f75fa/pydantic_core-2.50.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:0c003c3b7f49debb893d2d85ae099ac5959c9839e2f330fadb1fcdf7a6594482", size = 2024738, upload-time = "2026-10-11T18:32:44.587Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/4d/b8/fbfc25875219cc060e613170ff10e850c6d8924beb4910da57c2ee3ba1d2/pydantic_core-2.50.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:409e0ea40ec30d9158f33574fd758e689f6045a0f2596701828c27816ca9687d", size = 2047049, upload-time = "2026-10-11T18:32:46.164Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d7/43/34210124d504c553688f2f04b48500b131237528ac545b445e0d6d30e0d5/pydantic_core-2.50.1-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:131059670f1d2444269b8585cb888963994871932447c08b39ac6a51fcfef658", size = 2173415, upload-time = "2026-10-11T18:32:47.722Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/65/cf/6e178e8fdc11da5965bef980983bf46326a42f436871dd51ba0a57f39df1/pydantic_core-2.50.1-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:6dbcbee53bf17196a7f745aa9bf5a9603953a1e365b1f020be3207c676a3e7c4", size = 2361719, upload-time = "2026-10-11T18:32:49.217Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/11/14/bd5169d356aa91bf777e28ba0b281c192d286d03c2812c9c9db023a2f00e/pydantic_core-2.50.1-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:325c23f3e35cfbf0fe3486fa5f7260d1e45885173002d30a28ca019994124255", size = 2439803, upload-time = "2026-10-11T18:32:51.025Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/1c/bc/d79d000e5203ebef39af839f2ce77a777fcad6e08ad26af9a2fcd114ffc8/pydantic_core-2.50.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:17e722e156d0444ecaefbe640bdb60928752bf2013e2b7a11cdb099aaae19bec", size = 2158402, upload-time = "2026-10-11T18:32:52.714Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/1b/a5/4902cb5fd599422c130bd3124ab31ee8b771199bd56662702eed07d3fec7/pydantic_core-2.50.1-cp313-cp313-manylinux_2_31_riscv64.whl", hash = "sha256:aa8224f10880d9bf1b5993988ba153d42a8b4f3f4f511f93b1f09c93ff613c72", size = 2229755, upload-time = "2026-10-11T18:32:54.126Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/1a/f5/c1481f8669f6060d89110c9b1374173fc8767ca276b84f4870bd8acd5e3f/pydantic_core-2.50.1-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:41bc8237121bd8dc8d888dfd6279fc166ffc88c1f1bf3a8bf00869680533ca4c", size = 2242303, upload-time = "2026-10-11T18:32:55.641Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/04/f9/77fc3c7653ba9b6e42049e17e96b25388187d4a7c274ab1cb07f58ac8419/pydantic_core-2.50.1-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:45c6266d071c241f2a168d45bf8c54344f0effce35e7e6b73afdec11f3687568", size = 2278345, upload-time = "2026-10-11T18:32:57.38Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/95/9b/0579c5d12e7f2b16b27e6782427987341fcce07b0725e02ddb0b74add0c4/pydantic_core-2.50.1-cp313-cp313-musllinux_1_1_armv7l.whl", hash = "sha256:1deeacb112d14d3f4fcb16b165f7dbaf76c70ba6e82f37ba042bdab51970a0b8", size = 2449947, upload-time = "2026-10-11T18:32:58.896Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a8/ac/1b677db91eba54cc5922f4de6edc46ba45c2bd712dfdc0130382d158e214/pydantic_core-2.50.1-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:1c96fd793b73d1b92e65570132505498fe7b21eaef73cdf74e67e5dfba7ac9e4", size = 2476889, upload-time = "2026-10-11T18:33:00.665Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/4d/2a/3a9f6624ee3ea9ccba5249dde11418bb4c35780a7a92608f8768bd3fea39/pydantic_core-2.50.1-cp313-cp313-win32.whl", hash = "sha256:06ead20d39ffd6f2f6f2a8f8a6de67ff8bb1b4f14a8a30e058502514ee2ac685", size = 2101118, upload-time = "2026-10-11T18:33:02.329Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/2d/1f/323f78ddd9d9938aac420c1abb4e8ba799fc8bdab0acc67c0593b837c979/pydantic_core-2.50.1-cp313-cp313-win_amd64.whl", hash = "sha256:7816e98acc08119dc0f340ab167048ecc54126316330c1f0caf7c6756c88e28f", size = 2170840, upload-time = "2026-10-11T18:33:03.919Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/cb/09/8497c52a739ae425c3ac2f7f56414cbc711c67d374346174f40fe2062644/pydantic_core-2.50.1-cp313-cp313-win_arm64.whl", hash = "sha256:c17799a62c142d61b8a3c51752a7cbc87fe2ad4ccfab10e628a77b405075c662", size = 2161633, upload-time = "2026-10-11T18:33:05.518Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/49/33/28b96e81677153715e3eafb9f26663a80841e859fde282a380359b0d3fa1/pydantic_core-2.50.1-cp314-cp314-macosx_10_12_x86_64.whl", hash = "sha256:1cf41f1ae3fa155cf167a72689ad044bcc1e3c97e064123677149bdfb5dafc4a", size = 2224428, upload-time = "2026-10-11T18:33:07.153Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/94/40/15c06410c9b7b8da5805d27b64e09bd3f900e986728106db2689dbc51513/pydantic_core-2.50.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:4df197990c15b5a37c5a277d131d9f2c67de6133f2e5dafd80d9bba4b99f46f9", size = 2023740, upload-time = "2026-10-11T18:33:08.763Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a1/4e/5eb629f6efc2a27e421d789dd4bfacbb5f6d09c80c28b13d1e87d73163d5/pydantic_core-2.50.1-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0036473f5583e6a60e50b8b21651511564277a3f05cc5dab8cf579f552cd5f6c", size = 2049435, upload-time = "2026-10-11T18:33:10.366Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ba/8e/f195aebec49ad12318876ac2368c197a7939f5d52f8e156d2238ef8a4588/pydantic_core-2.50.1-cp314-cp314-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:992c3514ec891fa7858099183e4d64e6bd5a5d4ff452fae29df22faa77a006bb", size = 2172975, upload-time = "2026-10-11T18:33:12.368Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/e0/f5/7ad9fb83010cd5ea0948409db105676ed779c4e709e2d3d89b9fe2558794/pydantic_core-2.50.1-cp314-cp314-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:739dc730e6be3bd5ec2f4ab5cfc7eb047cc45fc1497b3bafec74ff2ed07df597", size = 2364197, upload-time = "2026-10-11T18:33:14.244Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ca/fb/bf0aab3e78301d202b82a0322ec968cd703b11fc0623fde9a28708936f62/pydantic_core-2.50.1-cp314-cp314-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:32fad3a91e51b6d2039c572db04a5a873260b399f6bd62c3552671fa7a4a2899", size = 2444259, upload-time = "2026-10-11T18:33:15.79Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/45/35/38f6d6564fae57d9b12e5676dfa947e0e7d5c46dbeaa7eb3352261d6d299/pydantic_core-2.50.1-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:42b54c2c90ad348b5e3a85e03e715d572c1fde357ef104cdfe3b03b697a404ea", size = 2159857, upload-time = "2026-10-11T18:33:17.51Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/65/a0/fb0a3ca10f139dcf765b2d312d10cf0f65c57c59993229d00ad12b14ceff/pydantic_core-2.50.1-cp314-cp314-manylinux_2_31_riscv64.whl", hash = "sha256:2df1ff41884de2bc4b307bafd7c40a691094fad2ff8e767e5b45a319257bcf4e", size = 2233954, upload-time = "2026-10-11T18:33:19.591Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/8c/6a/e63842252702aa4ec6e6b7178ca85e541a77459076592c23ebe2d9840b33/pydantic_core-2.50.1-cp314-cp314-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:fe90228920fd8ff2be62622b6bb8a2b11acd65046d50c6b130614b5879605a20", size = 2243876, upload-time = "2026-10-11T18:33:21.393Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/39/25/5991cf8318b37e0dfab47b87541619a1df8501a793cba0d978846cba37a7/pydantic_core-2.50.1-cp314-cp314-musllinux_1_1_aarch64.whl", hash = "sha256:844b869f118e22a41a091bdcedda8a71bc1b0f62c38d1a0c3211cece47e1d8fc", size = 2277908, upload-time = "2026-10-11T18:33:23.324Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a7/3e/3ee8baaa6cc25a6961c69168cf9ff0f002d56f4e0d541ad6724c18fb61f3/pydantic_core-2.50.1-cp314-cp314-musllinux_1_1_armv7l.whl", hash = "sha256:2eb75304506894a281d346220a4f7481a1b8729577c5ed2a05395991966a8396", size = 2449285, upload-time = "2026-10-11T18:33:24.942Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/c0/c7/acbec6deac13fe697a80c275a9b6661db62c4d323bac8a47347b1f39c7cd/pydantic_core-2.50.1-cp314-cp314-musllinux_1_1_x86_64.whl", hash = "sha256:6b20a4bffabdad0db2927ac034ae3b8a681b1f7a0182f3e60b479ad2fde21ebb", size = 2479013, upload-time = "2026-10-11T18:33:26.925Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/10/08/21a3f237b264389f6219d053ee78fc1b5c2fd402c1b1cb2b6cb8b85f9834/pydantic_core-2.50.1-cp314-cp314-pyemscripten_2026_0_wasm32.whl", hash = "sha256:99ba9bc2b8062ea0c326a990f7f00e6530c23579de66dd246e72c4cafef950a5", size = 1484400, upload-time = "2026-10-11T18:33:28.693Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/09/ce/077a6d262d12ef09108377ac0717f029f420d773ace63cafd6143af75568/pydantic_core-2.50.1-cp314-cp314-win32.whl", hash = "sha256:cf356f70551d40374eaffb1aa63f1eb6d2006681cbd7a9faea173ce0f4dd7cd2", size = 2103222, upload-time = "2026-10-11T18:33:30.326Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/14/4c/350a2415209c43d670eb71d3c040f332c04a30583d39e311b05c7ac15762/pydantic_core-2.50.1-cp314-cp314-win_amd64.whl", hash = "sha256:d32f3acc081cc3923386d88f422cde8892335e95f034e0104bb4cf9310d9915f", size = 2171586, upload-time = "2026-10-11T18:33:32.139Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/bf/92/9bea6ca96580a0902fed366f064f0829e404f41889b34543279a1162b888/pydantic_core-2.50.1-cp314-cp314-win_arm64.whl", hash = "sha256:bed5163e03b98bc1fa2eb05d74c63d9c5c95d8ed6254985481640fbf5e237dea", size = 2155773, upload-time = "2026-10-11T18:33:33.896Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/86/8c/f121f073cf32bdd5cba7e6230b1ce0ac845b0cf43e44dd597d95af272db2/pydantic_core-2.50.1-cp314-cp314t-macosx_10_12_x86_64.whl", hash = "sha256:9572c1369e9c9da2d64a7b7992c786d90ff295abc93964cfe3125e4290768070", size = 2234017, upload-time = "2026-10-11T18:33:35.588Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a4/69/2bb2bcd6146cffe98d760a46c42ae71efd5151d9b2f9c9bf6619a3b32083/pydantic_core-2.50.1-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:2005207aafe1231315718bf6ed5d064a7300fb4772754af35ee72fc68159492e", size = 2001016, upload-time = "2026-10-11T18:33:37.57Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/20/b3/fbf854c7d07ec114260c26e9e2071a4381740f9ae09641dbfcbdf2a18c45/pydantic_core-2.50.1-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:64f6047f62a6c5ae08d0a6afb035667aa2d97c3d20d69762e034c5ea144d92a5", size = 2023015, upload-time = "2026-10-11T18:33:39.433Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/65/20/6de55b2f92cdb614b745c6e9ced639fc4fd7e1e77604825a88bdece6fcbd/pydantic_core-2.50.1-cp314-cp314t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:1ef800dd7d85bcdadf4c3076e4c94e43939493558a3b69a1ea830c706d4617bb", size = 2192543, upload-time = "2026-10-11T18:33:41.381Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/0c/d9/19e91c94bd5c405945ce2f15526808aea37e162c253160de8ed7bf70b406/pydantic_core-2.50.1-cp314-cp314t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b0135bcdcaa0f23573f286e4cb5e0fd2962700964ed13df085b85f2b97aeab9e", size = 2388704, upload-time = "2026-10-11T18:33:43.167Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b6/bc/2e24c8415eae1a25ee5a5484946a917123bad2e9d01689a759236928175a/pydantic_core-2.50.1-cp314-cp314t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:0b3a6f334c6a2345ca15318ff894502a90012536404b37c844a976c76c846e0b", size = 2464118, upload-time = "2026-10-11T18:33:44.856Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/bd/1f/945b8053cb061c64e102bcaf7bfb9ed740c0bd4349f9bb978a7d4ddff4ab/pydantic_core-2.50.1-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:06e01fbbfdb9be777b316a71b6c49efaf4a08b615d0a98d678cda3023f79d019", size = 2150142, upload-time = "2026-10-11T18:33:46.661Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/2b/78/96a3e50bf0d64aaae781107eb9335b7529d05a85793ed6e7241c4cd1d931/pydantic_core-2.50.1-cp314-cp314t-manylinux_2_31_riscv64.whl", hash = "sha256:a29a061fec0b4e2d714f277e70a3a18125ecff803f2fea6eade2f2e53711d112", size = 2245577, upload-time = "2026-10-11T18:33:48.574Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/7a/5d/a6038a0322232758a6ebfa709f4ca14a60bf5b93940cd0b345056a557da4/pydantic_core-2.50.1-cp314-cp314t-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:f5187624823423e1d1b82b1072ac41dc837389e18d3d0572cc19bbee46cd550a", size = 2263728, upload-time = "2026-10-11T18:33:50.527Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/0d/4b/76ded3333a457a9344c4f2d63f2d82d0101654b05178fa4ddfe7d3627674/pydantic_core-2.50.1-cp314-cp314t-musllinux_1_1_aarch64.whl", hash = "sha256:3e46a9eb0a0901dd6275e6b06ac3a464885ef350ec4121fe486869de8053e4bb", size = 2293630, upload-time = "2026-10-11T18:33:52.362Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a9/00/9eca378335c9c1b72bc779bf6e4c2a82ce784f14ec48a0e87102c9870e05/pydantic_core-2.50.1-cp314-cp314t-musllinux_1_1_armv7l.whl", hash = "sha256:756d669f04e62ec4148ecfe22be6a4484d9b1181a6ef32e205ebfd200540858b", size = 2468048, upload-time = "2026-10-11T18:33:54.118Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/35/ca/e3832e9cf93651251de43c8c5c029ed680a3c1a0a1b17ee26c81bed08cbd/pydantic_core-2.50.1-cp314-cp314t-musllinux_1_1_x86_64.whl", hash = "sha256:c516cc5367ca3448995d42cb994bf3f4c9002d2a7c22eac9622551269ad1b807", size = 2512159, upload-time = "2026-10-11T18:33:55.99Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/4b/f2/773469b5a10a39116a2cb17edaf6d722f017dd8da07161b371465311c542/pydantic_core-2.50.1-cp314-cp314t-win32.whl", hash = "sha256:9d1bed94af6a63835461f3cf7502058eb166c58c4778e11d0f433cfb1bd69e19", size = 2098406, upload-time = "2026-10-11T18:33:58.043Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ee/42/0bb74f8f25204b259b11ab7c12dc7f180893b6bd706118b385147fb6efd5/pydantic_core-2.50.1-cp314-cp314t-win_amd64.whl", hash = "sha256:c8dce1f1e0e5358b682a6ad3fa5e31b31d4560997b8e61417e9217c8d60f8a0c", size = 2148481, upload-time = "2026-10-11T18:33:59.913Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/47/0d/d801646c9679a4e630e15cf521d4108b93854b42a6e6e02391bd4c6b1095/pydantic_core-2.50.1-cp314-cp314t-win_arm64.whl", hash = "sha256:ceff0acc940be2715bd6ad17b24c0e5304abf44f6efd0f81ee8499e640f9dc86", size = 2174972, upload-time = "2026-10-11T18:34:01.875Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b2/84/23984b763d8862a02a13d27a44b6e8169428fd85ecfed88f54c29108604d/pydantic_core-2.50.1-cp315-cp315-macosx_10_12_x86_64.whl", hash = "sha256:8a6791afa2245e6c6b180122d105941644f5bd410bb18623b408808cc41a3102", size = 2224599, upload-time = "2026-10-11T18:34:04.016Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/4d/90/a63cf8586abc1d1a3f6d9b18f0224789ebf003851f092ebda3c7c863fd32/pydantic_core-2.50.1-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:84f34323a61a365b4e9295de6028474754829aaddd59c7bf1a040e7487ef8f3c", size = 2024191, upload-time = "2026-10-11T18:34:05.901Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a6/6a/f34bff9808ffb4907fbf5f5040457d253cacf2da7fce9efbc99ca1b1a44d/pydantic_core-2.50.1-cp315-cp315-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:23edad659e8dbd8ca7e4e877fe6c81573abbdf215bd25a68b53e1272f58b80c7", size = 2048252, upload-time = "2026-10-11T18:34:07.757Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b2/54/13f419bf1eb59852003818e25935aaf175687d978f4c4bca70e08fe40a3b/pydantic_core-2.50.1-cp315-cp315-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:3a5fce22f1e87d181e924e12da7d81cfe031fb3881a5ddf26ad28f141756ca43", size = 2173376, upload-time = "2026-10-11T18:34:09.592Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/6d/6c/b5a34d24cd0c81669d8f8339d74e6815abcf2f8fb48ab4b49b84c09be1d5/pydantic_core-2.50.1-cp315-cp315-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c73622ef819328873b53109ee4f77ceb598bffedd02daf916102be3228866b78", size = 2364559, upload-time = "2026-10-11T18:34:11.534Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/eb/8d/d64d6216a8df365082665927ff923f183056f9049fee08e9777c9ac05296/pydantic_core-2.50.1-cp315-cp315-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:ce8c25ca38cc0e3d7753ba180808de2c0c8cb24eae0df64491e40921454e9831", size = 2444697, upload-time = "2026-10-11T18:34:13.535Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b8/0d/1b1149f60a00ea21ba5f70e28acbd40feb4598af414f80f53c921fac07c9/pydantic_core-2.50.1-cp315-cp315-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7689580e72a642ab5ec64d5f55b2e33636fa43b4ebe63c0c2c965ef307c7d1aa", size = 2159961, upload-time = "2026-10-11T18:34:15.56Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/1e/35/f236549299dcc78e71e945495d7ec67e78d20844d0999c60601685003031/pydantic_core-2.50.1-cp315-cp315-manylinux_2_31_riscv64.whl", hash = "sha256:d5c0e32fdbce7f1e8ef4d11f655694bf5f4175c757a9f1dc2be09b8864e5bcf5", size = 2234581, upload-time = "2026-10-11T18:34:17.502Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/6a/85/26901a490522b7f75ef9bb9a7afb73e5bb550f0e1cb5b99a0069183e2eb9/pydantic_core-2.50.1-cp315-cp315-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:40f523349960fa30f3ea51404308ff50f9997a90df639590f47a057c1f32b415", size = 2244090, upload-time = "2026-10-11T18:34:19.402Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ca/2c/481bcfc70ceeb77a778ca6e5b705fe592cb64735c108157f81b7dd9c280e/pydantic_core-2.50.1-cp315-cp315-musllinux_1_1_aarch64.whl", hash = "sha256:d4193206b6587047437f6f11d7e776df23e1c1e23af2a54d9347275614791e10", size = 2277948, upload-time = "2026-10-11T18:34:21.317Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/24/eb/f1e09333faa7ba447cde967310f758430cc7c5e987bdab5228816c70030d/pydantic_core-2.50.1-cp315-cp315-musllinux_1_1_armv7l.whl", hash = "sha256:84bc765b282a9d5b7fe0348b8648904f25a6a04b2139da52b1dd30c8ac3a2c8f", size = 2449688, upload-time = "2026-10-11T18:34:23.321Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d1/b3/036bde636db8f76d92996e81aefc75678ab5cec4a07eea1ad0c72a893fc3/pydantic_core-2.50.1-cp315-cp315-musllinux_1_1_x86_64.whl", hash = "sha256:ed1e728b39a383c81035b2459cfcb35d99dfb01f7d6ebe3a913bc1cc5b81e459", size = 2479286, upload-time = "2026-10-11T18:34:25.214Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d0/a3/07f018294ee18d144afeb6df1a47d9e92960f014be45c5ed13519fa5af95/pydantic_core-2.50.1-cp315-cp315-win32.whl", hash = "sha256:bc94f474417604bd383d2cd445d071b07dd55fedceed3ce33407bf1fcc107290", size = 2103683, upload-time = "2026-10-11T18:34:27.42Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/5f/98/f9bd7e1f9b6709f155acb9ef826d9c3884fe925f811fd8e55b9b52280bad/pydantic_core-2.50.1-cp315-cp315-win_amd64.whl", hash = "sha256:983a662de2571cb2502fc8ff47b6770b03d025d2eb314c92f77b3f07c74720ed", size = 2171681, upload-time = "2026-10-11T18:34:29.508Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/10/87/4bb3e1e7f385c076ab5af4d6dd0571b22042cd8207eb810d5b9fef15ae31/pydantic_core-2.50.1-cp315-cp315-win_arm64.whl", hash = "sha256:94845ff54dc5193f228cab81b2662a04bfbb892e95bdc15edf7399000ce57d54", size = 2156251, upload-time = "2026-10-11T18:34:31.455Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/47/47/83643225b08f2aef6c8cc4bbe6e3f79c5e139c4364a6e450d0f399d87774/pydantic_core-2.50.1-cp315-cp315t-macosx_10_12_x86_64.whl", hash = "sha256:4a53d13cdfbedbfa87f08b83c1a0a5efcc767d785a4b41934fa9cb672670493a", size = 2234363, upload-time = "2026-10-11T18:34:33.65Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/5e/66/127ca649ba2f2462039dc1e694c6c01e00a3689f023a617364d3507e6d97/pydantic_core-2.50.1-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:efbecf43d321f7b9281441f1f213f7c21c66988b0e06c2730ba13ed47a46bb08", size = 2000972, upload-time = "2026-10-11T18:34:36.037Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/5e/4f/e421e0a5d653b1203b090b2e48745976988d7338a647940704b5b9c2b399/pydantic_core-2.50.1-cp315-cp315t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bc1f08f68dac9f9e83845a8039880aba2ab553eb9b2259c3243a313182c253fe", size = 2022925, upload-time = "2026-10-11T18:34:37.972Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d5/4e/ea5568e2491e1a71100f15ae8c2d01ef52db42a184a2d4e716bc79e5eb8f/pydantic_core-2.50.1-cp315-cp315t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:5dfe41f232befddb9c4377f6cfc702b51595e2d78ed082672adf8758d2c4619f", size = 2192867, upload-time = "2026-10-11T18:34:39.921Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ae/5e/3b8c3a35acbe219909ada5defad5d7d9fed845fb2b37bd5ec518f453c119/pydantic_core-2.50.1-cp315-cp315t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:adc06d218a1cadfd2ec4628424d7d79ce4eba69c2965e7e7b55106f0da5208c8", size = 2388687, upload-time = "2026-10-11T18:34:42.184Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b6/aa/7889b4e515f91a2e8c0ae6b5081fec0feb30c4398d1434e14793c60f173a/pydantic_core-2.50.1-cp315-cp315t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2cf91809d0721ab81592ba67bea7694821679c10b1a2e3c3460082b286c1918a", size = 2464415, upload-time = "2026-10-11T18:34:44.384Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/08/78/93449e628eb8a6fdcce3eff9043081179d1bc7ce6f1bff32dc5006f41e00/pydantic_core-2.50.1-cp315-cp315t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:23923ab9292c40da026330b1ecf4dc2618c8e86e0422e5d1fbf50d94d64ca4f8", size = 2150823, upload-time = "2026-10-11T18:34:46.392Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/f4/f1/72c5bc129fceb0d00f05dc1e67f518c1728de1928c55f81fc13d7690de39/pydantic_core-2.50.1-cp315-cp315t-manylinux_2_31_riscv64.whl", hash = "sha256:f3377c8c2b3ce898423c5e5dd94c7982e30aa7717a7e6ab2470b9de364963709", size = 2245806, upload-time = "2026-10-11T18:34:48.805Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/28/2a/922a0e78f3aa6ab837b59f88190233fb8dad546c17995fde9bb3ed3b9b49/pydantic_core-2.50.1-cp315-cp315t-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:455a773617b5913bf5c20d0692e5787b119e52c4d40ea644ca31f5758fd31be2", size = 2264160, upload-time = "2026-10-11T18:34:50.876Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/52/a8/0f1449e3e1b20941c9372faa18e7b6a092e30cdfa841902473f7989532ac/pydantic_core-2.50.1-cp315-cp315t-musllinux_1_1_aarch64.whl", hash = "sha256:1a9006395dece0e32e704c315eff8a00bede494f6108546cfc5539c89fef4f9a", size = 2294031, upload-time = "2026-10-11T18:34:52.876Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d1/d0/1031f492857de70355fb16524bbb03efce5fd34c93ed4a1ec60be07e0d4b/pydantic_core-2.50.1-cp315-cp315t-musllinux_1_1_armv7l.whl", hash = "sha256:d2d82aa62521c55ddfb000ae70f88cdd8de974078f6024e821dfe5addd0c818f", size = 2468423, upload-time = "2026-10-11T18:34:54.995Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/46/52/269ffffa645b8e47906395a39cf9db1151ae9fa4bcd7f47b960bc31baf37/pydantic_core-2.50.1-cp315-cp315t-musllinux_1_1_x86_64.whl", hash = "sha256:009634b83993777ddcd69cad0ffcace43dabde692109528e35f0fde91e386a8b", size = 2512598, upload-time = "2026-10-11T18:34:57.149Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/31/5c/e47e28281f20326ff6f3c31d626f0a83e615d2d94ba41bb0ad6ec237184a/pydantic_core-2.50.1-cp315-cp315t-win32.whl", hash = "sha256:3fde4fdc6487a58d944ca87cf5adc95d5f266e872c19599f5f4c0a8a1b1f9f9f", size = 2098535, upload-time = "2026-10-11T18:34:59.313Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/03/ad/759e181e69c1b472c60b2049e5f61d5da1deefdd5ce1df4bb2ebcf771f25/pydantic_core-2.50.1-cp315-cp315t-win_amd64.whl", hash = "sha256:1c8632d4ac04e6f91128fca584b3a8a507d81604c24eeaaad00d4be42765c32b", size = 2148645, upload-time = "2026-10-11T18:35:01.571Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/6d/56/8a702c27e5be9f47e5f19d8669227424290e4c024e7c370279cbaf244b4e/pydantic_core-2.50.1-cp315-cp315t-win_arm64.whl", hash = "sha256:c3ede305158e75510be50869b319550ab072008c13d64d4ab1e094fb286b6f44", size = 2175297, upload-time = "2026-10-11T18:35:04.079Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pyyaml"
|
||||
version = "6.0.3"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/05/8e/961c0007c59b8dd7729d542c61a4d537767a59645b82a0b521206e1e25c2/pyyaml-6.0.3.tar.gz", hash = "sha256:d76623373421df22fb4cf8817020cbb7ef15c725b9d5e45f17e189bfc384190f", size = 130960, upload-time = "2025-09-25T21:33:16.546Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/d1/11/0fd08f8192109f7169db964b5707a2f1e8b745d4e239b784a5a1dd80d1db/pyyaml-6.0.3-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:8da9669d359f02c0b91ccc01cac4a67f16afec0dac22c2ad09f46bee0697eba8", size = 181669, upload-time = "2025-09-25T21:32:23.673Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b1/16/95309993f1d3748cd644e02e38b75d50cbc0d9561d21f390a76242ce073f/pyyaml-6.0.3-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:2283a07e2c21a2aa78d9c4442724ec1eb15f5e42a723b99cb3d822d48f5f7ad1", size = 173252, upload-time = "2025-09-25T21:32:25.149Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/50/31/b20f376d3f810b9b2371e72ef5adb33879b25edb7a6d072cb7ca0c486398/pyyaml-6.0.3-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ee2922902c45ae8ccada2c5b501ab86c36525b883eff4255313a253a3160861c", size = 767081, upload-time = "2025-09-25T21:32:26.575Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/49/1e/a55ca81e949270d5d4432fbbd19dfea5321eda7c41a849d443dc92fd1ff7/pyyaml-6.0.3-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:a33284e20b78bd4a18c8c2282d549d10bc8408a2a7ff57653c0cf0b9be0afce5", size = 841159, upload-time = "2025-09-25T21:32:27.727Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/74/27/e5b8f34d02d9995b80abcef563ea1f8b56d20134d8f4e5e81733b1feceb2/pyyaml-6.0.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0f29edc409a6392443abf94b9cf89ce99889a1dd5376d94316ae5145dfedd5d6", size = 801626, upload-time = "2025-09-25T21:32:28.878Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/f9/11/ba845c23988798f40e52ba45f34849aa8a1f2d4af4b798588010792ebad6/pyyaml-6.0.3-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:f7057c9a337546edc7973c0d3ba84ddcdf0daa14533c2065749c9075001090e6", size = 753613, upload-time = "2025-09-25T21:32:30.178Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/3d/e0/7966e1a7bfc0a45bf0a7fb6b98ea03fc9b8d84fa7f2229e9659680b69ee3/pyyaml-6.0.3-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:eda16858a3cab07b80edaf74336ece1f986ba330fdb8ee0d6c0d68fe82bc96be", size = 794115, upload-time = "2025-09-25T21:32:31.353Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/de/94/980b50a6531b3019e45ddeada0626d45fa85cbe22300844a7983285bed3b/pyyaml-6.0.3-cp313-cp313-win32.whl", hash = "sha256:d0eae10f8159e8fdad514efdc92d74fd8d682c933a6dd088030f3834bc8e6b26", size = 137427, upload-time = "2025-09-25T21:32:32.58Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/97/c9/39d5b874e8b28845e4ec2202b5da735d0199dbe5b8fb85f91398814a9a46/pyyaml-6.0.3-cp313-cp313-win_amd64.whl", hash = "sha256:79005a0d97d5ddabfeeea4cf676af11e647e41d81c9a7722a193022accdb6b7c", size = 154090, upload-time = "2025-09-25T21:32:33.659Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/73/e8/2bdf3ca2090f68bb3d75b44da7bbc71843b19c9f2b9cb9b0f4ab7a5a4329/pyyaml-6.0.3-cp313-cp313-win_arm64.whl", hash = "sha256:5498cd1645aa724a7c71c8f378eb29ebe23da2fc0d7a08071d89469bf1d2defb", size = 140246, upload-time = "2025-09-25T21:32:34.663Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/9d/8c/f4bd7f6465179953d3ac9bc44ac1a8a3e6122cf8ada906b4f96c60172d43/pyyaml-6.0.3-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:8d1fab6bb153a416f9aeb4b8763bc0f22a5586065f86f7664fc23339fc1c1fac", size = 181814, upload-time = "2025-09-25T21:32:35.712Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/bd/9c/4d95bb87eb2063d20db7b60faa3840c1b18025517ae857371c4dd55a6b3a/pyyaml-6.0.3-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:34d5fcd24b8445fadc33f9cf348c1047101756fd760b4dacb5c3e99755703310", size = 173809, upload-time = "2025-09-25T21:32:36.789Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/92/b5/47e807c2623074914e29dabd16cbbdd4bf5e9b2db9f8090fa64411fc5382/pyyaml-6.0.3-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:501a031947e3a9025ed4405a168e6ef5ae3126c59f90ce0cd6f2bfc477be31b7", size = 766454, upload-time = "2025-09-25T21:32:37.966Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/02/9e/e5e9b168be58564121efb3de6859c452fccde0ab093d8438905899a3a483/pyyaml-6.0.3-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:b3bc83488de33889877a0f2543ade9f70c67d66d9ebb4ac959502e12de895788", size = 836355, upload-time = "2025-09-25T21:32:39.178Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/88/f9/16491d7ed2a919954993e48aa941b200f38040928474c9e85ea9e64222c3/pyyaml-6.0.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c458b6d084f9b935061bc36216e8a69a7e293a2f1e68bf956dcd9e6cbcd143f5", size = 794175, upload-time = "2025-09-25T21:32:40.865Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/dd/3f/5989debef34dc6397317802b527dbbafb2b4760878a53d4166579111411e/pyyaml-6.0.3-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:7c6610def4f163542a622a73fb39f534f8c101d690126992300bf3207eab9764", size = 755228, upload-time = "2025-09-25T21:32:42.084Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d7/ce/af88a49043cd2e265be63d083fc75b27b6ed062f5f9fd6cdc223ad62f03e/pyyaml-6.0.3-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:5190d403f121660ce8d1d2c1bb2ef1bd05b5f68533fc5c2ea899bd15f4399b35", size = 789194, upload-time = "2025-09-25T21:32:43.362Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/23/20/bb6982b26a40bb43951265ba29d4c246ef0ff59c9fdcdf0ed04e0687de4d/pyyaml-6.0.3-cp314-cp314-win_amd64.whl", hash = "sha256:4a2e8cebe2ff6ab7d1050ecd59c25d4c8bd7e6f400f5f82b96557ac0abafd0ac", size = 156429, upload-time = "2025-09-25T21:32:57.844Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/f4/f4/a4541072bb9422c8a883ab55255f918fa378ecf083f5b85e87fc2b4eda1b/pyyaml-6.0.3-cp314-cp314-win_arm64.whl", hash = "sha256:93dda82c9c22deb0a405ea4dc5f2d0cda384168e466364dec6255b293923b2f3", size = 143912, upload-time = "2025-09-25T21:32:59.247Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/7c/f9/07dd09ae774e4616edf6cda684ee78f97777bdd15847253637a6f052a62f/pyyaml-6.0.3-cp314-cp314t-macosx_10_13_x86_64.whl", hash = "sha256:02893d100e99e03eda1c8fd5c441d8c60103fd175728e23e431db1b589cf5ab3", size = 189108, upload-time = "2025-09-25T21:32:44.377Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/4e/78/8d08c9fb7ce09ad8c38ad533c1191cf27f7ae1effe5bb9400a46d9437fcf/pyyaml-6.0.3-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:c1ff362665ae507275af2853520967820d9124984e0f7466736aea23d8611fba", size = 183641, upload-time = "2025-09-25T21:32:45.407Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/7b/5b/3babb19104a46945cf816d047db2788bcaf8c94527a805610b0289a01c6b/pyyaml-6.0.3-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6adc77889b628398debc7b65c073bcb99c4a0237b248cacaf3fe8a557563ef6c", size = 831901, upload-time = "2025-09-25T21:32:48.83Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/8b/cc/dff0684d8dc44da4d22a13f35f073d558c268780ce3c6ba1b87055bb0b87/pyyaml-6.0.3-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:a80cb027f6b349846a3bf6d73b5e95e782175e52f22108cfa17876aaeff93702", size = 861132, upload-time = "2025-09-25T21:32:50.149Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b1/5e/f77dc6b9036943e285ba76b49e118d9ea929885becb0a29ba8a7c75e29fe/pyyaml-6.0.3-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:00c4bdeba853cc34e7dd471f16b4114f4162dc03e6b7afcc2128711f0eca823c", size = 839261, upload-time = "2025-09-25T21:32:51.808Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ce/88/a9db1376aa2a228197c58b37302f284b5617f56a5d959fd1763fb1675ce6/pyyaml-6.0.3-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:66e1674c3ef6f541c35191caae2d429b967b99e02040f5ba928632d9a7f0f065", size = 805272, upload-time = "2025-09-25T21:32:52.941Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/da/92/1446574745d74df0c92e6aa4a7b0b3130706a4142b2d1a5869f2eaa423c6/pyyaml-6.0.3-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:16249ee61e95f858e83976573de0f5b2893b3677ba71c9dd36b9cf8be9ac6d65", size = 829923, upload-time = "2025-09-25T21:32:54.537Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/f0/7a/1c7270340330e575b92f397352af856a8c06f230aa3e76f86b39d01b416a/pyyaml-6.0.3-cp314-cp314t-win_amd64.whl", hash = "sha256:4ad1906908f2f5ae4e5a8ddfce73c320c2a1429ec52eafd27138b7f1cbe341c9", size = 174062, upload-time = "2025-09-25T21:32:55.767Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/f1/12/de94a39c2ef588c7e6455cfbe7343d3b2dc9d6b6b2f40c4c6565744c873d/pyyaml-6.0.3-cp314-cp314t-win_arm64.whl", hash = "sha256:ebc55a14a21cb14062aa4162f906cd962b28e2e9ea38f9b4391244cd8de4ae0b", size = 149341, upload-time = "2025-09-25T21:32:56.828Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typing-extensions"
|
||||
version = "4.16.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/f6/cc/6253133b5bb138fc3306cebfbda2c520f545d36b5be2c7255cc528bb45d6/typing_extensions-4.16.0.tar.gz", hash = "sha256:dc983d19a509c94dba722ee6abd33940f7c05a89e243c47e907eb4db6f1a43e5", size = 113555, upload-time = "2026-07-02T08:40:05.92Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/49/d3/b8441a820a491ddfc024b0b0cf0393375b75ea13866d9c66727e54c2fc80/typing_extensions-4.16.0-py3-none-any.whl", hash = "sha256:481caa481374e813c1b176ada14e97f1f67a4539ce9cfeb3f350d78d6370c2e8", size = 45571, upload-time = "2026-07-02T08:40:04.659Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typing-inspection"
|
||||
version = "0.4.4"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "typing-extensions" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/a3/26/b09b8010994eccc3c09092e6b34058f36a460eea2d4c3e8b910c695975a0/typing_inspection-0.4.4.tar.gz", hash = "sha256:547274fa6b0a561ccf549cc9524b999a578e737d015d8709d021f9d0d13bea47", size = 76928, upload-time = "2026-08-12T12:37:25.997Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/67/81/4add07e5172b7ac40d8ed5ff580409a7801a4fe26d529bdd915401dabfbe/typing_inspection-0.4.4-py3-none-any.whl", hash = "sha256:65b8397ba37ccbce054456aaccddfc91e6e3083c92824df348d96ca832f3f147", size = 14750, upload-time = "2026-08-12T12:37:24.648Z" },
|
||||
]
|
||||
Reference in new issue
Block a user