Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Fix contract audit sibling roots in worktrees
rcourtman578510cd12dd
diff --git a/scripts/release_control/contract_audit.py b/scripts/release_control/contract_audit.pyindex 9e2c9ad5f4..0fd6423b86 100644--- a/scripts/release_control/contract_audit.py+++ b/scripts/release_control/contract_audit.py@@ -12,7 +12,12 @@ from typing import Anyfrom canonical_completion_guard import REPO_ROOT, subsystem_matches_pathfrom control_plane import DEFAULT_CONTROL_PLANE-from repo_file_io import load_repo_json+from repo_file_io import (+ canonical_repo_id,+ canonical_repo_root,+ canonical_workspace_repos_root,+ load_repo_json,+)from subsystem_contracts import tracked_contract_files@@ -68,7 +73,6 @@ PATH_SUFFIXES = (".yaml",".yml",)-WORKSPACE_REPOS_ROOT = REPO_ROOT.parentdef sorted_casefold(values: list[str]) -> list[str]:@@ -110,25 +114,34 @@ def looks_like_repo_path(token: str) -> bool:return "/" in candidate or candidate.endswith(PATH_SUFFIXES)-def repo_roots_for_status(status_payload: dict[str, Any]) -> dict[str, Path]:+def repo_roots_for_status(status_payload: dict[str, Any], *, repo_root: Path | None = None) -> dict[str, Path]:+ root = repo_root or REPO_ROOT+ local_repo_id = canonical_repo_id(root)+ local_repo_root = canonical_repo_root(root)+ workspace_repos_root = canonical_workspace_repos_root(root)active_repos = [repo_idfor repo_id in status_payload.get("scope", {}).get("active_repos", [])if isinstance(repo_id, str) and repo_id.strip()]- repo_roots = {REPO_ROOT.name: REPO_ROOT}+ repo_roots = {local_repo_id: local_repo_root}for repo_id in active_repos:- if repo_id == REPO_ROOT.name:+ if repo_id == local_repo_id:continue- repo_roots[repo_id] = WORKSPACE_REPOS_ROOT / repo_id+ repo_roots[repo_id] = workspace_repos_root / repo_idreturn repo_roots-def resolve_repo_path_token(token: str, *, repo_roots: dict[str, Path]) -> Path | None:+def resolve_repo_path_token(+ token: str,+ *,+ repo_roots: dict[str, Path],+ default_repo_id: str,+) -> Path | None:raw = token.rstrip("/") if token.endswith("/") else tokenif not raw:return None- repo_id = REPO_ROOT.name+ repo_id = default_repo_idrepo_rel = rawif ":" in raw:repo_id, repo_rel = raw.split(":", 1)@@ -160,8 +173,9 @@ def validate_repo_path_token(heading: str,errors: list[str],repo_roots: dict[str, Path],+ default_repo_id: str,) -> None:- resolved = resolve_repo_path_token(token, repo_roots=repo_roots)+ resolved = resolve_repo_path_token(token, repo_roots=repo_roots, default_repo_id=default_repo_id)if resolved is None:errors.append(f"{rel} {heading} contains non-clean repo-relative path {token!r}")return@@ -203,6 +217,7 @@ def audit_contract_text(content: str,*,repo_roots: dict[str, Path],+ default_repo_id: str,) -> tuple[dict[str, Any], list[str]]:errors: list[str] = []path_references: list[dict[str, str]] = []@@ -258,6 +273,7 @@ def audit_contract_text(heading=heading,errors=errors,repo_roots=repo_roots,+ default_repo_id=default_repo_id,)path_references.append({"heading": heading, "path": token})if heading == "## Extension Points":@@ -270,6 +286,7 @@ def audit_contract_text(heading=heading,errors=errors,repo_roots=repo_roots,+ default_repo_id=default_repo_id,)path_references.append({"heading": heading, "path": token})@@ -325,6 +342,7 @@ def audit_contract_payload(registry_payload: dict[str, Any],status_payload: dict[str, Any],contract_texts: dict[str, str],+ repo_root: Path | None = None,) -> dict[str, Any]:errors: list[str] = []warnings: list[str] = []@@ -348,7 +366,9 @@ def audit_contract_payload(for subsystem in registry_subsystemsif isinstance(subsystem, dict) and isinstance(subsystem.get("contract"), str)}- repo_roots = repo_roots_for_status(status_payload)+ local_repo_root = repo_root or REPO_ROOT+ default_repo_id = canonical_repo_id(local_repo_root)+ repo_roots = repo_roots_for_status(status_payload, repo_root=local_repo_root)expected_subsystem_ids = {str(subsystem.get("id", "")).strip()for subsystem in registry_subsystems@@ -367,7 +387,12 @@ def audit_contract_payload(seen_subsystem_ids: set[str] = set()for rel in sorted(actual_contracts):- parsed, parse_errors = audit_contract_text(rel, contract_texts[rel], repo_roots=repo_roots)+ parsed, parse_errors = audit_contract_text(+ rel,+ contract_texts[rel],+ repo_roots=repo_roots,+ default_repo_id=default_repo_id,+ )errors.extend(parse_errors)metadata = parsed.get("metadata")subsystem = expected_contracts.get(rel)@@ -491,6 +516,7 @@ def audit_contract_payload(heading="## Shared Boundaries",errors=errors,repo_roots=repo_roots,+ default_repo_id=default_repo_id,)actual_shared_paths.append(shared_path)if shared_path in seen_shared_paths:diff --git a/scripts/release_control/contract_audit_test.py b/scripts/release_control/contract_audit_test.pyindex 7e34ca2ef5..63feaf5005 100644--- a/scripts/release_control/contract_audit_test.py+++ b/scripts/release_control/contract_audit_test.py@@ -1,9 +1,26 @@+import os+from pathlib import Path+import subprocess+import tempfileimport unittest-from contract_audit import audit_contract_payload, parse_args+from contract_audit import audit_contract_payload, parse_args, repo_roots_for_statusclass ContractAuditTest(unittest.TestCase):+ def git(self, repo_root: Path, *args: str) -> subprocess.CompletedProcess:+ env = os.environ.copy()+ for name in ("GIT_DIR", "GIT_WORK_TREE", "GIT_INDEX_FILE", "GIT_COMMON_DIR"):+ env.pop(name, None)+ return subprocess.run(+ ["git", *args],+ cwd=repo_root,+ check=True,+ capture_output=True,+ text=True,+ env=env,+ )+def test_parse_args_accepts_staged_flag(self) -> None:args = parse_args(["--check", "--staged"])self.assertTrue(args.check)@@ -367,6 +384,106 @@ Cross-repo relay ownership is explicit.self.assertEqual(report["errors"], [])+ def test_audit_contract_payload_resolves_sibling_repos_from_linked_worktree(self) -> None:+ with tempfile.TemporaryDirectory() as tmpdir:+ workspace = Path(tmpdir) / "workspace"+ repo_root = workspace / "repos" / "pulse"+ sibling_root = workspace / "repos" / "pulse-mobile"+ linked_worktree = workspace / ".worktrees" / "pulse-contract-audit-sibling-roots"+ repo_root.mkdir(parents=True)+ sibling_file = sibling_root / "src" / "relay" / "client.ts"+ sibling_file.parent.mkdir(parents=True)+ sibling_file.write_text("export const relayClient = true;\n", encoding="utf-8")++ self.git(repo_root, "init")+ (repo_root / "README.md").write_text("pulse\n", encoding="utf-8")+ self.git(repo_root, "add", "README.md")+ self.git(+ repo_root,+ "-c",+ "user.name=Pulse Test",+ "-c",+ "[email protected]",+ "commit",+ "-m",+ "initial",+ )+ self.git(repo_root, "worktree", "add", "--detach", str(linked_worktree), "HEAD")++ status_payload = {+ "scope": {+ "active_repos": ["pulse", "pulse-mobile"],+ },+ "lanes": [{"id": "L7"}],+ }+ repo_roots = repo_roots_for_status(status_payload, repo_root=linked_worktree)+ self.assertEqual(repo_roots["pulse"], repo_root.resolve())+ self.assertEqual(repo_roots["pulse-mobile"], sibling_root.resolve())++ registry_payload = {+ "subsystems": [+ {+ "id": "relay-runtime",+ "lane": "L7",+ "contract": "docs/release-control/v6/internal/subsystems/relay-runtime.md",+ }+ ]+ }+ contract_texts = {+ "docs/release-control/v6/internal/subsystems/relay-runtime.md": """# Relay Runtime Contract++## Contract Metadata++```json+{+ "subsystem_id": "relay-runtime",+ "lane": "L7",+ "contract_file": "docs/release-control/v6/internal/subsystems/relay-runtime.md",+ "status_file": "docs/release-control/v6/internal/status.json",+ "registry_file": "docs/release-control/v6/internal/subsystems/registry.json",+ "dependency_subsystem_ids": []+}+```++## Purpose++Own relay runtime truth.++## Canonical Files++1. `pulse-mobile:src/relay/client.ts`++## Shared Boundaries++1. None.++## Extension Points++1. Add mobile relay reconnect behavior through `pulse-mobile:src/relay/`++## Forbidden Paths++1. Ad hoc mobile relay reconnect state.++## Completion Obligations++1. Keep mobile relay runtime changes tied to tests.++## Current State++Cross-repo relay ownership is explicit.+""",+ }++ report = audit_contract_payload(+ registry_payload=registry_payload,+ status_payload=status_payload,+ contract_texts=contract_texts,+ repo_root=linked_worktree,+ )++ self.assertEqual(report["errors"], [])+def test_audit_contract_payload_rejects_missing_extension_point_reference(self) -> None:registry_payload = {"subsystems": [