Compare commits

..
4 Commits
Author SHA1 Message Date
kiskaadee 9d82577f48 feat(appctl): implement source provenance domain model and strict
validation

Expand the V2 metadata engine to support workload source tracking and
enforce environment validity prior to execution.

- Add SourceConfig dataclass to track upstream git repositories and
  refs
- Update SitesApp to support both Source-Backed and Image-Only workloads
- Enforce valid git transport schemes (https, ssh, git@) during
  normalization
- Implement validate_environment() to fail fast on missing domain or cor
  paths
- Add unit tests for source parsing, default injection, and error
  capture
- Stub get_docker_status and cmd_sync_homepage with xfail TDD markers
- Update Nix flake and python environments with required dependencies
2026-09-28 21:15:19 -05:00
kiskaadee 9aeb67010f merge(main): synchronize decoupled AGENTS.md and upstream changes into refactor/appctl-rework 2026-09-28 17:26:15 -05:00
kiskaadee d6e5609a29 docs(agents): decouple external knowledge capture from Brain filesystem taxonomy
Core Architecture & Invariant CI / validate (push) Successful in 45s
2026-09-28 17:25:55 -05:00
kiskaadee 9db271b348 chore(flake): update flake input and lockfile revisions 2026-09-27 14:39:27 -05:00
4 changed files with 110 additions and 18 deletions

No files matched your search

+9 -10
View File
@@ -144,16 +144,15 @@ and the live documentation viewer.
---
## Brain Vault
## Engineering Knowledge Capture
Capture significant:
Significant engineering knowledge should be externalized to the project's external knowledge base when such a system is configured:
- Architectural decisions
- Security/threat-model changes
- Debugging discoveries
- Implementation lessons
- Architectural decisions with lasting trade-offs
- Threat model or security posture modifications
- Non-obvious root cause discoveries and diagnostic breakthroughs
- Transferable implementation lessons
in the appropriate `/home/kiskaadee/Brain/homelab/` or
`/home/kiskaadee/Brain/learning/` location.
Do not duplicate entire repository documentation in the Brain Vault.
Guidelines:
- Do not duplicate repository documentation, runtime configs, or appliance manuals in external records.
- Preserve repository-local documentation (e.g., `docs/`, inline comments, commit rationale) as the primary source of truth for runtime behavior.
Generated
+7 -7
View File
@@ -2,11 +2,11 @@
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1790046670,
"narHash": "sha256-OJe62m8gZx4xEAQnMcqH1u31/uu4Xf0q2ykAEHZfgrg=",
"rev": "6774f7bc253789b113a4f39285dc0fa100abeacc",
"lastModified": 1790463110,
"narHash": "sha256-VZHcT2wKLkApBCACQ2SH4P1jVZUbbOA7jWAGi1MIViw=",
"rev": "e158d9ed9b51c98974c5e66e1ba1c9e0255fecaa",
"type": "tarball",
"url": "https://releases.nixos.org/nixos/unstable/nixos-26.11pre1077996.6774f7bc2537/nixexprs.tar.zst"
"url": "https://releases.nixos.org/nixos/unstable/nixos-26.11pre1080189.e158d9ed9b51/nixexprs.tar.zst"
},
"original": {
"type": "tarball",
@@ -26,11 +26,11 @@
]
},
"locked": {
"lastModified": 1789890976,
"narHash": "sha256-GKwH3zpy7tartuJMG0Rv/xUsdetG1QLmTVv8UKgJLmA=",
"lastModified": 1790498116,
"narHash": "sha256-rs9meAYxW3zzrh43yaW7htrqCD+X9+pupDPHN86fumI=",
"owner": "Mic92",
"repo": "sops-nix",
"rev": "7214124c20c1542c90deb54af50e2f53ae02711f",
"rev": "5efb5a6f4f5ab192817d28557dd4d650fa14d866",
"type": "github"
},
"original": {
+27 -1
View File
@@ -52,6 +52,13 @@ class HomepageConfig:
container: str = ""
weight: int = 50
@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
@dataclass
class App:
name: str # Canonical identified (e.g., "traefik", "jellyfin")
@@ -81,6 +88,7 @@ class CoreService(App):
@dataclass
class SitesApp(App):
dir_name: str = "" # directory name in ~/Sites (e.g., "homelab-vaultwarden")
source: SourceConfig | None = None # Upstream source provenance (optional; None indicates Image-Only workload)
aliases: list[str] = field(default_factory=list) # CLI resolution aliases (e.g., "vw", "vaultwarden")
visible: bool = True # Defines whether the icon is visible in the Homepage Dashboard
auth: bool = True # Authelia protection guard indicator; Defaulting to True is safer
@@ -175,9 +183,27 @@ def sites_app_from_manifest(
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"),
)
return SitesApp(
name=canonical_name,
dir_name=raw_dir_name,
source=source_config,
description=app_desc,
domain=app_dom,
dir_path=app_dir,
@@ -187,7 +213,7 @@ def sites_app_from_manifest(
auth=app_auth,
networks=app_net,
env=app_env,
homepage= homepage_config,
homepage=homepage_config,
manifest_error=manifest_error,
)
+67
View File
@@ -120,6 +120,73 @@ def test_sites_app_normalization(app_factory: AppFactory):
assert app.homepage.weight == 99
def test_sites_app_source_provenance_normalization(app_factory: AppFactory):
"""Ensure source provenance block is correctly parsed into SourceConfig"""
# 1. Source-backed app with explicit ref
app_factory.create(
dir_name="homelab-bitetrack",
manifest_yaml="""
name: bitetrack
source:
type: git
url: https://git.roadtotech.me/kiskaadee/bitetrack.git
ref: v1.2.0
"""
)
# 2. Source-backed app with default ref (main)
app_factory.create(
dir_name="homelab-doc2site",
manifest_yaml="""
name: doc2site
source:
url: https://git.roadtotech.me/kiskaadee/doc2site.git
"""
)
# 3. Image-only app (no source block)
app_factory.create(
dir_name="homelab-jellyfin",
manifest_yaml="""
name: jellyfin
"""
)
apps = engine.get_sites_apps()
bitetrack = engine.resolve_app("bitetrack", apps)
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.ref == "v1.2.0"
assert bitetrack.to_dict()["source"]["ref"] == "v1.2.0"
doc2site = engine.resolve_app("doc2site", apps)
assert doc2site is not None
assert doc2site.source is not None
assert doc2site.source.ref == "main"
jellyfin = engine.resolve_app("jellyfin", apps)
assert jellyfin is not None
assert jellyfin.source is None
assert jellyfin.to_dict()["source"] is None
# 4. App with illegal source transport (e.g. file://)
app_factory.create(
dir_name="homelab-malformed",
manifest_yaml="""
name: malformed
source:
url: file:///etc/passwd
"""
)
apps_updated = engine.get_sites_apps()
malformed = engine.resolve_app("malformed", apps_updated)
assert malformed is not None
assert malformed.source is None
assert malformed.manifest_error is not None
assert "Invalid source.url scheme" in malformed.manifest_error
## RED TESTS: TDD Goals for next implementation
@pytest.mark.xfail(reason="TDD in progress: get_docker_status not yet implemented")