5.1 KiB
type, project, date, tags
| type | project | date | tags | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| journal | homelab | 2026-09-21 |
|
Daily Journal: 2026-09-21
Wins
Architecture & TDD: appctl Engine V2 Domain Modeling and Test Suite Scaffold
Initiated a comprehensive architectural rework of scripts/appctl_engine.py to elevate the homelab control utility into clean, type-safe engineering code (appctl_engine_v2.py). Development is conducted in an isolated Git worktree at ~/Projects/active/appctl-refactor.
Key Architectural Decisions & Progress
-
Standardized YAML Parsing & Custom Exception Handling
- Replaced Custom Parser: Deprecated the hand-rolled
parse_yaml_simple()in favor of standardyaml.safe_load()using PyYAML. - Explicit Failure Boundary: Defined
class ManifestError(Exception): passto cleanly catch and isolate malformed YAML syntax without crashing the whole application inventory.
- Replaced Custom Parser: Deprecated the hand-rolled
-
Explicit Domain Model Hierarchy
- Base Domain Model: Established
@dataclass class Apprepresenting common operational primitives (name,description,domain,dir_path,has_compose). - Layer-Specific Models:
SitesApp(App): Represents dynamic~/Sites/*workloads withapp.yamlmetadata (aliases,visible,auth,networks,env,homepage,manifest_error).CoreService(App): Represents Core platform services (container,weight,icon).HomepageConfig: Strongly-typed representation for dashboard cards.
- Base Domain Model: Established
-
Pure Normalization Boundary
- Extracted
sites_app_from_manifest(app_dir, manifest, manifest_error) -> SitesAppas a pure normalization seam. - Separates filesystem discovery from domain instantiation, enabling unit tests to verify manifest coercion without disk I/O.
- Extracted
-
Domain-Agnostic Infrastructure & Strict Validation
- Decoupled hardcoded personal domains by parameterizing
HOMELAB_DOMAIN = os.environ.get("HOMELAB_DOMAIN") or os.environ.get("DOMAIN", ""). - Added
validate_environment()to fail fast if mandatory environment variables or Core directories are missing.
- Decoupled hardcoded personal domains by parameterizing
-
TDD Test Suite Scaffold
- Created
tests/unit/test_appctl_engine_v2.pywith custom Pytest fixtures:mock_sites_dir&mock_core_dir: Isolated temporary directories with automaticmonkeypatchteardown.AppFactory: Object Mother/Factory class to generate test app directories withapp.yamland Compose manifests in one line.
- Verified passing tests for resolution hierarchy, manifest overrides, and type normalization.
- Established failing (Red) acceptance criteria for upcoming Docker inspection and Homepage YAML compilation.
- Created
Incidents & Debugging
-
Remediation: Gitea Actions CI Runner Container Initialization Failure (Missing /bin/sleep)
- Issue: Gitea Actions runner failed at job initialization with
exec: "/bin/sleep": stat /bin/sleep: no such file or directory. - Root Cause: Minimal
nixos/nixcontainer image lacks the Linux Filesystem Hierarchy Standard (FHS) paths expected byact_runnerat container entrypoint initialization. - Remediation: Transitioned CI base image to
nixery.dev/shell/coreutils/git/nix/nodejs:latest, restoring standard/binutilities while preserving declarative Nix tooling.
- Issue: Gitea Actions runner failed at job initialization with
-
GitOps Dispatcher Webhook Signature Mismatch: Epistemic Root Cause Analysis
- Issue: Automated GitOps dispatcher rejected repository push deliveries with
Authentication failed: Signature mismatch. - Root Cause: Payload serialization divergence in
adnanh/webhookparameter extraction combined with secret synchronization mismatch between Gitea webhook settings and the server's SOPS age secret. - Remediation: Corrected raw payload extraction, synchronized SOPS secrets, and implemented constant-time HMAC-SHA256 signature verification in
gitops_dispatcher.py.
- Issue: Automated GitOps dispatcher rejected repository push deliveries with
Mistakes and Lessons Learned
Python str(None) Truthiness Trap
Calling str(manifest.get("key")) or "fallback" returns "None" (a truthy string) when the key is missing, completely breaking fallback evaluation. Safe normalization requires checking manifest.get("key") is not None before string casting.
Nix Function Call Syntax in Lists
Calling python3.withPackages inside Nix lists [ ... ] requires outer parentheses (python3.withPackages (ps: [ ... ])), otherwise Nix evaluates the function and lambda as two separate invalid list elements.
FHS Invariant for Gitea act_runner
act_runner assumes a standard FHS environment (like /bin/sleep and /bin/sh) for container setup scripts. Bare Nix store container images must be supplemented with core utilities to satisfy runner bootstrap requirements.
Next Objectives
- Implement inspection layer in
scripts/appctl_engine_v2.py(Docker status, Git sync status, SSL checks). - Port CLI command handlers (
cmd_sync_homepage,cmd_list,cmd_info,cmd_ssl). - Turn remaining unit tests green and swap V2 into production
Core/scripts/appctl_engine.py.