Files
timmy-config/tests/deadman_switch/test_config_fallbacks.py

147 lines
6.0 KiB
Python
Raw Normal View History

feat: Add dead man switch emergency config fallbacks for Bezalel agent Issue #423 — Dead Man Switch Config Fallbacks - Bezalel Agent Autonomous Recovery System Add complete emergency configuration template set for the dead man switch fallback system. These files are deployed to /root/wizards/bezalel/home/.hermes/ and enable autonomous recovery when the primary inference provider (Kimi Coding) fails. New files: - wizards/bezalel/home/.hermes/config.emergency.yaml — Full minimal local-only configuration using Ollama models (gemma3:4b/12b/27b) - wizards/bezalel/home/.hermes/.env.emergency — Emergency env var template (Telegram alerts, local service endpoints) - wizards/bezalel/home/.hermes/health_status.json — Health status schema/example used by deadman-fallback.py - wizards/bezalel/home/.hermes/deadman_switch.json — Dead man switch configuration (thresholds, fallback chain, recovery policy) - wizards/bezalel/home/.hermes/DEADMAN_SWITCH_README.md — Complete documentation for operators (13 sections) Tests: - tests/deadman_switch/test_config_fallbacks.py — Validates presence, structure, required fields, consistency across files, and that emergency config uses local-only providers Config: - .gitignore: Allow .env.emergency template to be tracked (exception added for this specific file) Smallest concrete fix: Add the actual config templates so the dead man switch system can perform autonomous recovery. Infrastructure exists (bin/deadman-fallback.py, ansible roles); these are the missing deployable config files. Closes #423
2026-04-26 14:08:55 -04:00
"""
Tests for Dead Man Switch emergency config files.
Validates that all required emergency config templates exist and are syntactically
valid (YAML/JSON parse). Specific schema details are intentionally relaxed to
allow evolution of the fallback system.
feat: Add dead man switch emergency config fallbacks for Bezalel agent Issue #423 — Dead Man Switch Config Fallbacks - Bezalel Agent Autonomous Recovery System Add complete emergency configuration template set for the dead man switch fallback system. These files are deployed to /root/wizards/bezalel/home/.hermes/ and enable autonomous recovery when the primary inference provider (Kimi Coding) fails. New files: - wizards/bezalel/home/.hermes/config.emergency.yaml — Full minimal local-only configuration using Ollama models (gemma3:4b/12b/27b) - wizards/bezalel/home/.hermes/.env.emergency — Emergency env var template (Telegram alerts, local service endpoints) - wizards/bezalel/home/.hermes/health_status.json — Health status schema/example used by deadman-fallback.py - wizards/bezalel/home/.hermes/deadman_switch.json — Dead man switch configuration (thresholds, fallback chain, recovery policy) - wizards/bezalel/home/.hermes/DEADMAN_SWITCH_README.md — Complete documentation for operators (13 sections) Tests: - tests/deadman_switch/test_config_fallbacks.py — Validates presence, structure, required fields, consistency across files, and that emergency config uses local-only providers Config: - .gitignore: Allow .env.emergency template to be tracked (exception added for this specific file) Smallest concrete fix: Add the actual config templates so the dead man switch system can perform autonomous recovery. Infrastructure exists (bin/deadman-fallback.py, ansible roles); these are the missing deployable config files. Closes #423
2026-04-26 14:08:55 -04:00
"""
import json
import yaml
feat: Add dead man switch emergency config fallbacks for Bezalel agent Issue #423 — Dead Man Switch Config Fallbacks - Bezalel Agent Autonomous Recovery System Add complete emergency configuration template set for the dead man switch fallback system. These files are deployed to /root/wizards/bezalel/home/.hermes/ and enable autonomous recovery when the primary inference provider (Kimi Coding) fails. New files: - wizards/bezalel/home/.hermes/config.emergency.yaml — Full minimal local-only configuration using Ollama models (gemma3:4b/12b/27b) - wizards/bezalel/home/.hermes/.env.emergency — Emergency env var template (Telegram alerts, local service endpoints) - wizards/bezalel/home/.hermes/health_status.json — Health status schema/example used by deadman-fallback.py - wizards/bezalel/home/.hermes/deadman_switch.json — Dead man switch configuration (thresholds, fallback chain, recovery policy) - wizards/bezalel/home/.hermes/DEADMAN_SWITCH_README.md — Complete documentation for operators (13 sections) Tests: - tests/deadman_switch/test_config_fallbacks.py — Validates presence, structure, required fields, consistency across files, and that emergency config uses local-only providers Config: - .gitignore: Allow .env.emergency template to be tracked (exception added for this specific file) Smallest concrete fix: Add the actual config templates so the dead man switch system can perform autonomous recovery. Infrastructure exists (bin/deadman-fallback.py, ansible roles); these are the missing deployable config files. Closes #423
2026-04-26 14:08:55 -04:00
from pathlib import Path
HERMES_DIR = Path(__file__).parent.parent.parent / "wizards" / "bezalel" / "home" / ".hermes"
EMERGENCY_DIR = HERMES_DIR
feat: Add dead man switch emergency config fallbacks for Bezalel agent Issue #423 — Dead Man Switch Config Fallbacks - Bezalel Agent Autonomous Recovery System Add complete emergency configuration template set for the dead man switch fallback system. These files are deployed to /root/wizards/bezalel/home/.hermes/ and enable autonomous recovery when the primary inference provider (Kimi Coding) fails. New files: - wizards/bezalel/home/.hermes/config.emergency.yaml — Full minimal local-only configuration using Ollama models (gemma3:4b/12b/27b) - wizards/bezalel/home/.hermes/.env.emergency — Emergency env var template (Telegram alerts, local service endpoints) - wizards/bezalel/home/.hermes/health_status.json — Health status schema/example used by deadman-fallback.py - wizards/bezalel/home/.hermes/deadman_switch.json — Dead man switch configuration (thresholds, fallback chain, recovery policy) - wizards/bezalel/home/.hermes/DEADMAN_SWITCH_README.md — Complete documentation for operators (13 sections) Tests: - tests/deadman_switch/test_config_fallbacks.py — Validates presence, structure, required fields, consistency across files, and that emergency config uses local-only providers Config: - .gitignore: Allow .env.emergency template to be tracked (exception added for this specific file) Smallest concrete fix: Add the actual config templates so the dead man switch system can perform autonomous recovery. Infrastructure exists (bin/deadman-fallback.py, ansible roles); these are the missing deployable config files. Closes #423
2026-04-26 14:08:55 -04:00
class TestEmergencyConfigPresence:
"""All required emergency config files must exist."""
feat: Add dead man switch emergency config fallbacks for Bezalel agent Issue #423 — Dead Man Switch Config Fallbacks - Bezalel Agent Autonomous Recovery System Add complete emergency configuration template set for the dead man switch fallback system. These files are deployed to /root/wizards/bezalel/home/.hermes/ and enable autonomous recovery when the primary inference provider (Kimi Coding) fails. New files: - wizards/bezalel/home/.hermes/config.emergency.yaml — Full minimal local-only configuration using Ollama models (gemma3:4b/12b/27b) - wizards/bezalel/home/.hermes/.env.emergency — Emergency env var template (Telegram alerts, local service endpoints) - wizards/bezalel/home/.hermes/health_status.json — Health status schema/example used by deadman-fallback.py - wizards/bezalel/home/.hermes/deadman_switch.json — Dead man switch configuration (thresholds, fallback chain, recovery policy) - wizards/bezalel/home/.hermes/DEADMAN_SWITCH_README.md — Complete documentation for operators (13 sections) Tests: - tests/deadman_switch/test_config_fallbacks.py — Validates presence, structure, required fields, consistency across files, and that emergency config uses local-only providers Config: - .gitignore: Allow .env.emergency template to be tracked (exception added for this specific file) Smallest concrete fix: Add the actual config templates so the dead man switch system can perform autonomous recovery. Infrastructure exists (bin/deadman-fallback.py, ansible roles); these are the missing deployable config files. Closes #423
2026-04-26 14:08:55 -04:00
def test_config_emergency_yaml_exists(self):
path = EMERGENCY_DIR / "config.emergency.yaml"
assert path.exists(), f"Missing {path.relative_to(Path.cwd())}"
feat: Add dead man switch emergency config fallbacks for Bezalel agent Issue #423 — Dead Man Switch Config Fallbacks - Bezalel Agent Autonomous Recovery System Add complete emergency configuration template set for the dead man switch fallback system. These files are deployed to /root/wizards/bezalel/home/.hermes/ and enable autonomous recovery when the primary inference provider (Kimi Coding) fails. New files: - wizards/bezalel/home/.hermes/config.emergency.yaml — Full minimal local-only configuration using Ollama models (gemma3:4b/12b/27b) - wizards/bezalel/home/.hermes/.env.emergency — Emergency env var template (Telegram alerts, local service endpoints) - wizards/bezalel/home/.hermes/health_status.json — Health status schema/example used by deadman-fallback.py - wizards/bezalel/home/.hermes/deadman_switch.json — Dead man switch configuration (thresholds, fallback chain, recovery policy) - wizards/bezalel/home/.hermes/DEADMAN_SWITCH_README.md — Complete documentation for operators (13 sections) Tests: - tests/deadman_switch/test_config_fallbacks.py — Validates presence, structure, required fields, consistency across files, and that emergency config uses local-only providers Config: - .gitignore: Allow .env.emergency template to be tracked (exception added for this specific file) Smallest concrete fix: Add the actual config templates so the dead man switch system can perform autonomous recovery. Infrastructure exists (bin/deadman-fallback.py, ansible roles); these are the missing deployable config files. Closes #423
2026-04-26 14:08:55 -04:00
def test_env_emergency_exists(self):
path = EMERGENCY_DIR / ".env.emergency"
assert path.exists(), f"Missing {path.relative_to(Path.cwd())}"
feat: Add dead man switch emergency config fallbacks for Bezalel agent Issue #423 — Dead Man Switch Config Fallbacks - Bezalel Agent Autonomous Recovery System Add complete emergency configuration template set for the dead man switch fallback system. These files are deployed to /root/wizards/bezalel/home/.hermes/ and enable autonomous recovery when the primary inference provider (Kimi Coding) fails. New files: - wizards/bezalel/home/.hermes/config.emergency.yaml — Full minimal local-only configuration using Ollama models (gemma3:4b/12b/27b) - wizards/bezalel/home/.hermes/.env.emergency — Emergency env var template (Telegram alerts, local service endpoints) - wizards/bezalel/home/.hermes/health_status.json — Health status schema/example used by deadman-fallback.py - wizards/bezalel/home/.hermes/deadman_switch.json — Dead man switch configuration (thresholds, fallback chain, recovery policy) - wizards/bezalel/home/.hermes/DEADMAN_SWITCH_README.md — Complete documentation for operators (13 sections) Tests: - tests/deadman_switch/test_config_fallbacks.py — Validates presence, structure, required fields, consistency across files, and that emergency config uses local-only providers Config: - .gitignore: Allow .env.emergency template to be tracked (exception added for this specific file) Smallest concrete fix: Add the actual config templates so the dead man switch system can perform autonomous recovery. Infrastructure exists (bin/deadman-fallback.py, ansible roles); these are the missing deployable config files. Closes #423
2026-04-26 14:08:55 -04:00
def test_health_status_json_exists(self):
path = EMERGENCY_DIR / "health_status.json"
assert path.exists(), f"Missing {path.relative_to(Path.cwd())}"
feat: Add dead man switch emergency config fallbacks for Bezalel agent Issue #423 — Dead Man Switch Config Fallbacks - Bezalel Agent Autonomous Recovery System Add complete emergency configuration template set for the dead man switch fallback system. These files are deployed to /root/wizards/bezalel/home/.hermes/ and enable autonomous recovery when the primary inference provider (Kimi Coding) fails. New files: - wizards/bezalel/home/.hermes/config.emergency.yaml — Full minimal local-only configuration using Ollama models (gemma3:4b/12b/27b) - wizards/bezalel/home/.hermes/.env.emergency — Emergency env var template (Telegram alerts, local service endpoints) - wizards/bezalel/home/.hermes/health_status.json — Health status schema/example used by deadman-fallback.py - wizards/bezalel/home/.hermes/deadman_switch.json — Dead man switch configuration (thresholds, fallback chain, recovery policy) - wizards/bezalel/home/.hermes/DEADMAN_SWITCH_README.md — Complete documentation for operators (13 sections) Tests: - tests/deadman_switch/test_config_fallbacks.py — Validates presence, structure, required fields, consistency across files, and that emergency config uses local-only providers Config: - .gitignore: Allow .env.emergency template to be tracked (exception added for this specific file) Smallest concrete fix: Add the actual config templates so the dead man switch system can perform autonomous recovery. Infrastructure exists (bin/deadman-fallback.py, ansible roles); these are the missing deployable config files. Closes #423
2026-04-26 14:08:55 -04:00
def test_deadman_switch_json_exists(self):
path = EMERGENCY_DIR / "deadman_switch.json"
assert path.exists(), f"Missing {path.relative_to(Path.cwd())}"
feat: Add dead man switch emergency config fallbacks for Bezalel agent Issue #423 — Dead Man Switch Config Fallbacks - Bezalel Agent Autonomous Recovery System Add complete emergency configuration template set for the dead man switch fallback system. These files are deployed to /root/wizards/bezalel/home/.hermes/ and enable autonomous recovery when the primary inference provider (Kimi Coding) fails. New files: - wizards/bezalel/home/.hermes/config.emergency.yaml — Full minimal local-only configuration using Ollama models (gemma3:4b/12b/27b) - wizards/bezalel/home/.hermes/.env.emergency — Emergency env var template (Telegram alerts, local service endpoints) - wizards/bezalel/home/.hermes/health_status.json — Health status schema/example used by deadman-fallback.py - wizards/bezalel/home/.hermes/deadman_switch.json — Dead man switch configuration (thresholds, fallback chain, recovery policy) - wizards/bezalel/home/.hermes/DEADMAN_SWITCH_README.md — Complete documentation for operators (13 sections) Tests: - tests/deadman_switch/test_config_fallbacks.py — Validates presence, structure, required fields, consistency across files, and that emergency config uses local-only providers Config: - .gitignore: Allow .env.emergency template to be tracked (exception added for this specific file) Smallest concrete fix: Add the actual config templates so the dead man switch system can perform autonomous recovery. Infrastructure exists (bin/deadman-fallback.py, ansible roles); these are the missing deployable config files. Closes #423
2026-04-26 14:08:55 -04:00
def test_readme_exists(self):
path = EMERGENCY_DIR / "DEADMAN_SWITCH_README.md"
assert path.exists(), f"Missing {path.relative_to(Path.cwd())}"
feat: Add dead man switch emergency config fallbacks for Bezalel agent Issue #423 — Dead Man Switch Config Fallbacks - Bezalel Agent Autonomous Recovery System Add complete emergency configuration template set for the dead man switch fallback system. These files are deployed to /root/wizards/bezalel/home/.hermes/ and enable autonomous recovery when the primary inference provider (Kimi Coding) fails. New files: - wizards/bezalel/home/.hermes/config.emergency.yaml — Full minimal local-only configuration using Ollama models (gemma3:4b/12b/27b) - wizards/bezalel/home/.hermes/.env.emergency — Emergency env var template (Telegram alerts, local service endpoints) - wizards/bezalel/home/.hermes/health_status.json — Health status schema/example used by deadman-fallback.py - wizards/bezalel/home/.hermes/deadman_switch.json — Dead man switch configuration (thresholds, fallback chain, recovery policy) - wizards/bezalel/home/.hermes/DEADMAN_SWITCH_README.md — Complete documentation for operators (13 sections) Tests: - tests/deadman_switch/test_config_fallbacks.py — Validates presence, structure, required fields, consistency across files, and that emergency config uses local-only providers Config: - .gitignore: Allow .env.emergency template to be tracked (exception added for this specific file) Smallest concrete fix: Add the actual config templates so the dead man switch system can perform autonomous recovery. Infrastructure exists (bin/deadman-fallback.py, ansible roles); these are the missing deployable config files. Closes #423
2026-04-26 14:08:55 -04:00
class TestEmergencyConfigValidity:
"""Config files must be syntactically valid and structurally sound."""
feat: Add dead man switch emergency config fallbacks for Bezalel agent Issue #423 — Dead Man Switch Config Fallbacks - Bezalel Agent Autonomous Recovery System Add complete emergency configuration template set for the dead man switch fallback system. These files are deployed to /root/wizards/bezalel/home/.hermes/ and enable autonomous recovery when the primary inference provider (Kimi Coding) fails. New files: - wizards/bezalel/home/.hermes/config.emergency.yaml — Full minimal local-only configuration using Ollama models (gemma3:4b/12b/27b) - wizards/bezalel/home/.hermes/.env.emergency — Emergency env var template (Telegram alerts, local service endpoints) - wizards/bezalel/home/.hermes/health_status.json — Health status schema/example used by deadman-fallback.py - wizards/bezalel/home/.hermes/deadman_switch.json — Dead man switch configuration (thresholds, fallback chain, recovery policy) - wizards/bezalel/home/.hermes/DEADMAN_SWITCH_README.md — Complete documentation for operators (13 sections) Tests: - tests/deadman_switch/test_config_fallbacks.py — Validates presence, structure, required fields, consistency across files, and that emergency config uses local-only providers Config: - .gitignore: Allow .env.emergency template to be tracked (exception added for this specific file) Smallest concrete fix: Add the actual config templates so the dead man switch system can perform autonomous recovery. Infrastructure exists (bin/deadman-fallback.py, ansible roles); these are the missing deployable config files. Closes #423
2026-04-26 14:08:55 -04:00
def test_config_emergency_yaml_parses(self):
path = EMERGENCY_DIR / "config.emergency.yaml"
feat: Add dead man switch emergency config fallbacks for Bezalel agent Issue #423 — Dead Man Switch Config Fallbacks - Bezalel Agent Autonomous Recovery System Add complete emergency configuration template set for the dead man switch fallback system. These files are deployed to /root/wizards/bezalel/home/.hermes/ and enable autonomous recovery when the primary inference provider (Kimi Coding) fails. New files: - wizards/bezalel/home/.hermes/config.emergency.yaml — Full minimal local-only configuration using Ollama models (gemma3:4b/12b/27b) - wizards/bezalel/home/.hermes/.env.emergency — Emergency env var template (Telegram alerts, local service endpoints) - wizards/bezalel/home/.hermes/health_status.json — Health status schema/example used by deadman-fallback.py - wizards/bezalel/home/.hermes/deadman_switch.json — Dead man switch configuration (thresholds, fallback chain, recovery policy) - wizards/bezalel/home/.hermes/DEADMAN_SWITCH_README.md — Complete documentation for operators (13 sections) Tests: - tests/deadman_switch/test_config_fallbacks.py — Validates presence, structure, required fields, consistency across files, and that emergency config uses local-only providers Config: - .gitignore: Allow .env.emergency template to be tracked (exception added for this specific file) Smallest concrete fix: Add the actual config templates so the dead man switch system can perform autonomous recovery. Infrastructure exists (bin/deadman-fallback.py, ansible roles); these are the missing deployable config files. Closes #423
2026-04-26 14:08:55 -04:00
with open(path) as f:
yaml_str = f.read()
cfg = yaml.safe_load(yaml_str)
assert isinstance(cfg, dict), "config.emergency.yaml must parse as a dict"
assert "model" in cfg, "Missing required 'model' section"
feat: Add dead man switch emergency config fallbacks for Bezalel agent Issue #423 — Dead Man Switch Config Fallbacks - Bezalel Agent Autonomous Recovery System Add complete emergency configuration template set for the dead man switch fallback system. These files are deployed to /root/wizards/bezalel/home/.hermes/ and enable autonomous recovery when the primary inference provider (Kimi Coding) fails. New files: - wizards/bezalel/home/.hermes/config.emergency.yaml — Full minimal local-only configuration using Ollama models (gemma3:4b/12b/27b) - wizards/bezalel/home/.hermes/.env.emergency — Emergency env var template (Telegram alerts, local service endpoints) - wizards/bezalel/home/.hermes/health_status.json — Health status schema/example used by deadman-fallback.py - wizards/bezalel/home/.hermes/deadman_switch.json — Dead man switch configuration (thresholds, fallback chain, recovery policy) - wizards/bezalel/home/.hermes/DEADMAN_SWITCH_README.md — Complete documentation for operators (13 sections) Tests: - tests/deadman_switch/test_config_fallbacks.py — Validates presence, structure, required fields, consistency across files, and that emergency config uses local-only providers Config: - .gitignore: Allow .env.emergency template to be tracked (exception added for this specific file) Smallest concrete fix: Add the actual config templates so the dead man switch system can perform autonomous recovery. Infrastructure exists (bin/deadman-fallback.py, ansible roles); these are the missing deployable config files. Closes #423
2026-04-26 14:08:55 -04:00
def test_config_emergency_uses_local_provider(self):
"""Emergency config must use a local provider — external APIs unacceptable."""
path = EMERGENCY_DIR / "config.emergency.yaml"
feat: Add dead man switch emergency config fallbacks for Bezalel agent Issue #423 — Dead Man Switch Config Fallbacks - Bezalel Agent Autonomous Recovery System Add complete emergency configuration template set for the dead man switch fallback system. These files are deployed to /root/wizards/bezalel/home/.hermes/ and enable autonomous recovery when the primary inference provider (Kimi Coding) fails. New files: - wizards/bezalel/home/.hermes/config.emergency.yaml — Full minimal local-only configuration using Ollama models (gemma3:4b/12b/27b) - wizards/bezalel/home/.hermes/.env.emergency — Emergency env var template (Telegram alerts, local service endpoints) - wizards/bezalel/home/.hermes/health_status.json — Health status schema/example used by deadman-fallback.py - wizards/bezalel/home/.hermes/deadman_switch.json — Dead man switch configuration (thresholds, fallback chain, recovery policy) - wizards/bezalel/home/.hermes/DEADMAN_SWITCH_README.md — Complete documentation for operators (13 sections) Tests: - tests/deadman_switch/test_config_fallbacks.py — Validates presence, structure, required fields, consistency across files, and that emergency config uses local-only providers Config: - .gitignore: Allow .env.emergency template to be tracked (exception added for this specific file) Smallest concrete fix: Add the actual config templates so the dead man switch system can perform autonomous recovery. Infrastructure exists (bin/deadman-fallback.py, ansible roles); these are the missing deployable config files. Closes #423
2026-04-26 14:08:55 -04:00
with open(path) as f:
cfg = yaml.safe_load(f)
provider = cfg.get("model", {}).get("provider", "")
assert provider in ("ollama", "local-llama.cpp"), \
f"Provider must be local-only, got: {provider}"
# Verify template contains no real API keys
with open(path) as f:
yaml_str = f.read()
assert "ANTHROPIC_API_KEY" not in yaml_str.upper()
assert "KIMI_API_KEY" not in yaml_str.upper()
assert "OPENROUTER_API_KEY" not in yaml_str.upper()
feat: Add dead man switch emergency config fallbacks for Bezalel agent Issue #423 — Dead Man Switch Config Fallbacks - Bezalel Agent Autonomous Recovery System Add complete emergency configuration template set for the dead man switch fallback system. These files are deployed to /root/wizards/bezalel/home/.hermes/ and enable autonomous recovery when the primary inference provider (Kimi Coding) fails. New files: - wizards/bezalel/home/.hermes/config.emergency.yaml — Full minimal local-only configuration using Ollama models (gemma3:4b/12b/27b) - wizards/bezalel/home/.hermes/.env.emergency — Emergency env var template (Telegram alerts, local service endpoints) - wizards/bezalel/home/.hermes/health_status.json — Health status schema/example used by deadman-fallback.py - wizards/bezalel/home/.hermes/deadman_switch.json — Dead man switch configuration (thresholds, fallback chain, recovery policy) - wizards/bezalel/home/.hermes/DEADMAN_SWITCH_README.md — Complete documentation for operators (13 sections) Tests: - tests/deadman_switch/test_config_fallbacks.py — Validates presence, structure, required fields, consistency across files, and that emergency config uses local-only providers Config: - .gitignore: Allow .env.emergency template to be tracked (exception added for this specific file) Smallest concrete fix: Add the actual config templates so the dead man switch system can perform autonomous recovery. Infrastructure exists (bin/deadman-fallback.py, ansible roles); these are the missing deployable config files. Closes #423
2026-04-26 14:08:55 -04:00
def test_config_emergency_has_fallback_chain(self):
"""Emergency config should define a provider fallback chain for resilience."""
path = EMERGENCY_DIR / "config.emergency.yaml"
feat: Add dead man switch emergency config fallbacks for Bezalel agent Issue #423 — Dead Man Switch Config Fallbacks - Bezalel Agent Autonomous Recovery System Add complete emergency configuration template set for the dead man switch fallback system. These files are deployed to /root/wizards/bezalel/home/.hermes/ and enable autonomous recovery when the primary inference provider (Kimi Coding) fails. New files: - wizards/bezalel/home/.hermes/config.emergency.yaml — Full minimal local-only configuration using Ollama models (gemma3:4b/12b/27b) - wizards/bezalel/home/.hermes/.env.emergency — Emergency env var template (Telegram alerts, local service endpoints) - wizards/bezalel/home/.hermes/health_status.json — Health status schema/example used by deadman-fallback.py - wizards/bezalel/home/.hermes/deadman_switch.json — Dead man switch configuration (thresholds, fallback chain, recovery policy) - wizards/bezalel/home/.hermes/DEADMAN_SWITCH_README.md — Complete documentation for operators (13 sections) Tests: - tests/deadman_switch/test_config_fallbacks.py — Validates presence, structure, required fields, consistency across files, and that emergency config uses local-only providers Config: - .gitignore: Allow .env.emergency template to be tracked (exception added for this specific file) Smallest concrete fix: Add the actual config templates so the dead man switch system can perform autonomous recovery. Infrastructure exists (bin/deadman-fallback.py, ansible roles); these are the missing deployable config files. Closes #423
2026-04-26 14:08:55 -04:00
with open(path) as f:
cfg = yaml.safe_load(f)
fallback = cfg["model"].get("fallback_chain")
assert isinstance(fallback, list), "fallback_chain must be a list of providers"
assert len(fallback) >= 1, "fallback_chain cannot be empty"
feat: Add dead man switch emergency config fallbacks for Bezalel agent Issue #423 — Dead Man Switch Config Fallbacks - Bezalel Agent Autonomous Recovery System Add complete emergency configuration template set for the dead man switch fallback system. These files are deployed to /root/wizards/bezalel/home/.hermes/ and enable autonomous recovery when the primary inference provider (Kimi Coding) fails. New files: - wizards/bezalel/home/.hermes/config.emergency.yaml — Full minimal local-only configuration using Ollama models (gemma3:4b/12b/27b) - wizards/bezalel/home/.hermes/.env.emergency — Emergency env var template (Telegram alerts, local service endpoints) - wizards/bezalel/home/.hermes/health_status.json — Health status schema/example used by deadman-fallback.py - wizards/bezalel/home/.hermes/deadman_switch.json — Dead man switch configuration (thresholds, fallback chain, recovery policy) - wizards/bezalel/home/.hermes/DEADMAN_SWITCH_README.md — Complete documentation for operators (13 sections) Tests: - tests/deadman_switch/test_config_fallbacks.py — Validates presence, structure, required fields, consistency across files, and that emergency config uses local-only providers Config: - .gitignore: Allow .env.emergency template to be tracked (exception added for this specific file) Smallest concrete fix: Add the actual config templates so the dead man switch system can perform autonomous recovery. Infrastructure exists (bin/deadman-fallback.py, ansible roles); these are the missing deployable config files. Closes #423
2026-04-26 14:08:55 -04:00
def test_env_emergency_is_template(self):
""".env.emergency must be a template with placeholders, not actual secrets."""
path = EMERGENCY_DIR / ".env.emergency"
feat: Add dead man switch emergency config fallbacks for Bezalel agent Issue #423 — Dead Man Switch Config Fallbacks - Bezalel Agent Autonomous Recovery System Add complete emergency configuration template set for the dead man switch fallback system. These files are deployed to /root/wizards/bezalel/home/.hermes/ and enable autonomous recovery when the primary inference provider (Kimi Coding) fails. New files: - wizards/bezalel/home/.hermes/config.emergency.yaml — Full minimal local-only configuration using Ollama models (gemma3:4b/12b/27b) - wizards/bezalel/home/.hermes/.env.emergency — Emergency env var template (Telegram alerts, local service endpoints) - wizards/bezalel/home/.hermes/health_status.json — Health status schema/example used by deadman-fallback.py - wizards/bezalel/home/.hermes/deadman_switch.json — Dead man switch configuration (thresholds, fallback chain, recovery policy) - wizards/bezalel/home/.hermes/DEADMAN_SWITCH_README.md — Complete documentation for operators (13 sections) Tests: - tests/deadman_switch/test_config_fallbacks.py — Validates presence, structure, required fields, consistency across files, and that emergency config uses local-only providers Config: - .gitignore: Allow .env.emergency template to be tracked (exception added for this specific file) Smallest concrete fix: Add the actual config templates so the dead man switch system can perform autonomous recovery. Infrastructure exists (bin/deadman-fallback.py, ansible roles); these are the missing deployable config files. Closes #423
2026-04-26 14:08:55 -04:00
with open(path) as f:
content = f.read()
# A template either has ${VAR} placeholders or is mostly commented
assert content.count("#") >= 5, "Template should be heavily commented"
assert "API_KEY" not in content.upper() or "***" in content, \
"Template must not contain real API keys"
feat: Add dead man switch emergency config fallbacks for Bezalel agent Issue #423 — Dead Man Switch Config Fallbacks - Bezalel Agent Autonomous Recovery System Add complete emergency configuration template set for the dead man switch fallback system. These files are deployed to /root/wizards/bezalel/home/.hermes/ and enable autonomous recovery when the primary inference provider (Kimi Coding) fails. New files: - wizards/bezalel/home/.hermes/config.emergency.yaml — Full minimal local-only configuration using Ollama models (gemma3:4b/12b/27b) - wizards/bezalel/home/.hermes/.env.emergency — Emergency env var template (Telegram alerts, local service endpoints) - wizards/bezalel/home/.hermes/health_status.json — Health status schema/example used by deadman-fallback.py - wizards/bezalel/home/.hermes/deadman_switch.json — Dead man switch configuration (thresholds, fallback chain, recovery policy) - wizards/bezalel/home/.hermes/DEADMAN_SWITCH_README.md — Complete documentation for operators (13 sections) Tests: - tests/deadman_switch/test_config_fallbacks.py — Validates presence, structure, required fields, consistency across files, and that emergency config uses local-only providers Config: - .gitignore: Allow .env.emergency template to be tracked (exception added for this specific file) Smallest concrete fix: Add the actual config templates so the dead man switch system can perform autonomous recovery. Infrastructure exists (bin/deadman-fallback.py, ansible roles); these are the missing deployable config files. Closes #423
2026-04-26 14:08:55 -04:00
def test_health_status_json_parses(self):
path = EMERGENCY_DIR / "health_status.json"
feat: Add dead man switch emergency config fallbacks for Bezalel agent Issue #423 — Dead Man Switch Config Fallbacks - Bezalel Agent Autonomous Recovery System Add complete emergency configuration template set for the dead man switch fallback system. These files are deployed to /root/wizards/bezalel/home/.hermes/ and enable autonomous recovery when the primary inference provider (Kimi Coding) fails. New files: - wizards/bezalel/home/.hermes/config.emergency.yaml — Full minimal local-only configuration using Ollama models (gemma3:4b/12b/27b) - wizards/bezalel/home/.hermes/.env.emergency — Emergency env var template (Telegram alerts, local service endpoints) - wizards/bezalel/home/.hermes/health_status.json — Health status schema/example used by deadman-fallback.py - wizards/bezalel/home/.hermes/deadman_switch.json — Dead man switch configuration (thresholds, fallback chain, recovery policy) - wizards/bezalel/home/.hermes/DEADMAN_SWITCH_README.md — Complete documentation for operators (13 sections) Tests: - tests/deadman_switch/test_config_fallbacks.py — Validates presence, structure, required fields, consistency across files, and that emergency config uses local-only providers Config: - .gitignore: Allow .env.emergency template to be tracked (exception added for this specific file) Smallest concrete fix: Add the actual config templates so the dead man switch system can perform autonomous recovery. Infrastructure exists (bin/deadman-fallback.py, ansible roles); these are the missing deployable config files. Closes #423
2026-04-26 14:08:55 -04:00
with open(path) as f:
data = json.load(f)
assert "checks" in data
feat: Add dead man switch emergency config fallbacks for Bezalel agent Issue #423 — Dead Man Switch Config Fallbacks - Bezalel Agent Autonomous Recovery System Add complete emergency configuration template set for the dead man switch fallback system. These files are deployed to /root/wizards/bezalel/home/.hermes/ and enable autonomous recovery when the primary inference provider (Kimi Coding) fails. New files: - wizards/bezalel/home/.hermes/config.emergency.yaml — Full minimal local-only configuration using Ollama models (gemma3:4b/12b/27b) - wizards/bezalel/home/.hermes/.env.emergency — Emergency env var template (Telegram alerts, local service endpoints) - wizards/bezalel/home/.hermes/health_status.json — Health status schema/example used by deadman-fallback.py - wizards/bezalel/home/.hermes/deadman_switch.json — Dead man switch configuration (thresholds, fallback chain, recovery policy) - wizards/bezalel/home/.hermes/DEADMAN_SWITCH_README.md — Complete documentation for operators (13 sections) Tests: - tests/deadman_switch/test_config_fallbacks.py — Validates presence, structure, required fields, consistency across files, and that emergency config uses local-only providers Config: - .gitignore: Allow .env.emergency template to be tracked (exception added for this specific file) Smallest concrete fix: Add the actual config templates so the dead man switch system can perform autonomous recovery. Infrastructure exists (bin/deadman-fallback.py, ansible roles); these are the missing deployable config files. Closes #423
2026-04-26 14:08:55 -04:00
def test_deadman_switch_json_parses(self):
path = EMERGENCY_DIR / "deadman_switch.json"
feat: Add dead man switch emergency config fallbacks for Bezalel agent Issue #423 — Dead Man Switch Config Fallbacks - Bezalel Agent Autonomous Recovery System Add complete emergency configuration template set for the dead man switch fallback system. These files are deployed to /root/wizards/bezalel/home/.hermes/ and enable autonomous recovery when the primary inference provider (Kimi Coding) fails. New files: - wizards/bezalel/home/.hermes/config.emergency.yaml — Full minimal local-only configuration using Ollama models (gemma3:4b/12b/27b) - wizards/bezalel/home/.hermes/.env.emergency — Emergency env var template (Telegram alerts, local service endpoints) - wizards/bezalel/home/.hermes/health_status.json — Health status schema/example used by deadman-fallback.py - wizards/bezalel/home/.hermes/deadman_switch.json — Dead man switch configuration (thresholds, fallback chain, recovery policy) - wizards/bezalel/home/.hermes/DEADMAN_SWITCH_README.md — Complete documentation for operators (13 sections) Tests: - tests/deadman_switch/test_config_fallbacks.py — Validates presence, structure, required fields, consistency across files, and that emergency config uses local-only providers Config: - .gitignore: Allow .env.emergency template to be tracked (exception added for this specific file) Smallest concrete fix: Add the actual config templates so the dead man switch system can perform autonomous recovery. Infrastructure exists (bin/deadman-fallback.py, ansible roles); these are the missing deployable config files. Closes #423
2026-04-26 14:08:55 -04:00
with open(path) as f:
json.load(f)
feat: Add dead man switch emergency config fallbacks for Bezalel agent Issue #423 — Dead Man Switch Config Fallbacks - Bezalel Agent Autonomous Recovery System Add complete emergency configuration template set for the dead man switch fallback system. These files are deployed to /root/wizards/bezalel/home/.hermes/ and enable autonomous recovery when the primary inference provider (Kimi Coding) fails. New files: - wizards/bezalel/home/.hermes/config.emergency.yaml — Full minimal local-only configuration using Ollama models (gemma3:4b/12b/27b) - wizards/bezalel/home/.hermes/.env.emergency — Emergency env var template (Telegram alerts, local service endpoints) - wizards/bezalel/home/.hermes/health_status.json — Health status schema/example used by deadman-fallback.py - wizards/bezalel/home/.hermes/deadman_switch.json — Dead man switch configuration (thresholds, fallback chain, recovery policy) - wizards/bezalel/home/.hermes/DEADMAN_SWITCH_README.md — Complete documentation for operators (13 sections) Tests: - tests/deadman_switch/test_config_fallbacks.py — Validates presence, structure, required fields, consistency across files, and that emergency config uses local-only providers Config: - .gitignore: Allow .env.emergency template to be tracked (exception added for this specific file) Smallest concrete fix: Add the actual config templates so the dead man switch system can perform autonomous recovery. Infrastructure exists (bin/deadman-fallback.py, ansible roles); these are the missing deployable config files. Closes #423
2026-04-26 14:08:55 -04:00
def test_deadman_switch_has_essential_fields(self):
"""Dead man switch config must define core thresholds."""
path = EMERGENCY_DIR / "deadman_switch.json"
feat: Add dead man switch emergency config fallbacks for Bezalel agent Issue #423 — Dead Man Switch Config Fallbacks - Bezalel Agent Autonomous Recovery System Add complete emergency configuration template set for the dead man switch fallback system. These files are deployed to /root/wizards/bezalel/home/.hermes/ and enable autonomous recovery when the primary inference provider (Kimi Coding) fails. New files: - wizards/bezalel/home/.hermes/config.emergency.yaml — Full minimal local-only configuration using Ollama models (gemma3:4b/12b/27b) - wizards/bezalel/home/.hermes/.env.emergency — Emergency env var template (Telegram alerts, local service endpoints) - wizards/bezalel/home/.hermes/health_status.json — Health status schema/example used by deadman-fallback.py - wizards/bezalel/home/.hermes/deadman_switch.json — Dead man switch configuration (thresholds, fallback chain, recovery policy) - wizards/bezalel/home/.hermes/DEADMAN_SWITCH_README.md — Complete documentation for operators (13 sections) Tests: - tests/deadman_switch/test_config_fallbacks.py — Validates presence, structure, required fields, consistency across files, and that emergency config uses local-only providers Config: - .gitignore: Allow .env.emergency template to be tracked (exception added for this specific file) Smallest concrete fix: Add the actual config templates so the dead man switch system can perform autonomous recovery. Infrastructure exists (bin/deadman-fallback.py, ansible roles); these are the missing deployable config files. Closes #423
2026-04-26 14:08:55 -04:00
with open(path) as f:
dms = json.load(f)
dm = dms.get("deadman_switch", {})
for key in ["enabled", "mode", "max_consecutive_failures"]:
assert key in dm, f"Missing deadman_switch config field: {key}"
assert dm["enabled"] is True
def test_deadman_switch_fallback_chain_is_defined(self):
"""Fallback chain must exist and be ordered."""
path = EMERGENCY_DIR / "deadman_switch.json"
feat: Add dead man switch emergency config fallbacks for Bezalel agent Issue #423 — Dead Man Switch Config Fallbacks - Bezalel Agent Autonomous Recovery System Add complete emergency configuration template set for the dead man switch fallback system. These files are deployed to /root/wizards/bezalel/home/.hermes/ and enable autonomous recovery when the primary inference provider (Kimi Coding) fails. New files: - wizards/bezalel/home/.hermes/config.emergency.yaml — Full minimal local-only configuration using Ollama models (gemma3:4b/12b/27b) - wizards/bezalel/home/.hermes/.env.emergency — Emergency env var template (Telegram alerts, local service endpoints) - wizards/bezalel/home/.hermes/health_status.json — Health status schema/example used by deadman-fallback.py - wizards/bezalel/home/.hermes/deadman_switch.json — Dead man switch configuration (thresholds, fallback chain, recovery policy) - wizards/bezalel/home/.hermes/DEADMAN_SWITCH_README.md — Complete documentation for operators (13 sections) Tests: - tests/deadman_switch/test_config_fallbacks.py — Validates presence, structure, required fields, consistency across files, and that emergency config uses local-only providers Config: - .gitignore: Allow .env.emergency template to be tracked (exception added for this specific file) Smallest concrete fix: Add the actual config templates so the dead man switch system can perform autonomous recovery. Infrastructure exists (bin/deadman-fallback.py, ansible roles); these are the missing deployable config files. Closes #423
2026-04-26 14:08:55 -04:00
with open(path) as f:
dms = json.load(f)
chain = dms.get("deadman_switch", {}).get("fallback", {}).get("fallback_chain", [])
assert chain, "Fallback chain is empty"
assert "kimi" in chain, "Primary provider (kimi) must be in chain"
assert "ollama" in chain, "Local Ollama fallback must be in chain"
feat: Add dead man switch emergency config fallbacks for Bezalel agent Issue #423 — Dead Man Switch Config Fallbacks - Bezalel Agent Autonomous Recovery System Add complete emergency configuration template set for the dead man switch fallback system. These files are deployed to /root/wizards/bezalel/home/.hermes/ and enable autonomous recovery when the primary inference provider (Kimi Coding) fails. New files: - wizards/bezalel/home/.hermes/config.emergency.yaml — Full minimal local-only configuration using Ollama models (gemma3:4b/12b/27b) - wizards/bezalel/home/.hermes/.env.emergency — Emergency env var template (Telegram alerts, local service endpoints) - wizards/bezalel/home/.hermes/health_status.json — Health status schema/example used by deadman-fallback.py - wizards/bezalel/home/.hermes/deadman_switch.json — Dead man switch configuration (thresholds, fallback chain, recovery policy) - wizards/bezalel/home/.hermes/DEADMAN_SWITCH_README.md — Complete documentation for operators (13 sections) Tests: - tests/deadman_switch/test_config_fallbacks.py — Validates presence, structure, required fields, consistency across files, and that emergency config uses local-only providers Config: - .gitignore: Allow .env.emergency template to be tracked (exception added for this specific file) Smallest concrete fix: Add the actual config templates so the dead man switch system can perform autonomous recovery. Infrastructure exists (bin/deadman-fallback.py, ansible roles); these are the missing deployable config files. Closes #423
2026-04-26 14:08:55 -04:00
class TestEmergencyConfigConsistency:
"""Cross-file consistency checks."""
def test_emergency_provider_in_deadman_chain(self):
"""The emergency config's provider must be in the deadman switch fallback chain."""
import yaml
path = EMERGENCY_DIR / "config.emergency.yaml"
with open(path) as f:
feat: Add dead man switch emergency config fallbacks for Bezalel agent Issue #423 — Dead Man Switch Config Fallbacks - Bezalel Agent Autonomous Recovery System Add complete emergency configuration template set for the dead man switch fallback system. These files are deployed to /root/wizards/bezalel/home/.hermes/ and enable autonomous recovery when the primary inference provider (Kimi Coding) fails. New files: - wizards/bezalel/home/.hermes/config.emergency.yaml — Full minimal local-only configuration using Ollama models (gemma3:4b/12b/27b) - wizards/bezalel/home/.hermes/.env.emergency — Emergency env var template (Telegram alerts, local service endpoints) - wizards/bezalel/home/.hermes/health_status.json — Health status schema/example used by deadman-fallback.py - wizards/bezalel/home/.hermes/deadman_switch.json — Dead man switch configuration (thresholds, fallback chain, recovery policy) - wizards/bezalel/home/.hermes/DEADMAN_SWITCH_README.md — Complete documentation for operators (13 sections) Tests: - tests/deadman_switch/test_config_fallbacks.py — Validates presence, structure, required fields, consistency across files, and that emergency config uses local-only providers Config: - .gitignore: Allow .env.emergency template to be tracked (exception added for this specific file) Smallest concrete fix: Add the actual config templates so the dead man switch system can perform autonomous recovery. Infrastructure exists (bin/deadman-fallback.py, ansible roles); these are the missing deployable config files. Closes #423
2026-04-26 14:08:55 -04:00
cfg = yaml.safe_load(f)
provider = cfg.get("model", {}).get("provider")
dms_path = EMERGENCY_DIR / "deadman_switch.json"
with open(dms_path) as f:
feat: Add dead man switch emergency config fallbacks for Bezalel agent Issue #423 — Dead Man Switch Config Fallbacks - Bezalel Agent Autonomous Recovery System Add complete emergency configuration template set for the dead man switch fallback system. These files are deployed to /root/wizards/bezalel/home/.hermes/ and enable autonomous recovery when the primary inference provider (Kimi Coding) fails. New files: - wizards/bezalel/home/.hermes/config.emergency.yaml — Full minimal local-only configuration using Ollama models (gemma3:4b/12b/27b) - wizards/bezalel/home/.hermes/.env.emergency — Emergency env var template (Telegram alerts, local service endpoints) - wizards/bezalel/home/.hermes/health_status.json — Health status schema/example used by deadman-fallback.py - wizards/bezalel/home/.hermes/deadman_switch.json — Dead man switch configuration (thresholds, fallback chain, recovery policy) - wizards/bezalel/home/.hermes/DEADMAN_SWITCH_README.md — Complete documentation for operators (13 sections) Tests: - tests/deadman_switch/test_config_fallbacks.py — Validates presence, structure, required fields, consistency across files, and that emergency config uses local-only providers Config: - .gitignore: Allow .env.emergency template to be tracked (exception added for this specific file) Smallest concrete fix: Add the actual config templates so the dead man switch system can perform autonomous recovery. Infrastructure exists (bin/deadman-fallback.py, ansible roles); these are the missing deployable config files. Closes #423
2026-04-26 14:08:55 -04:00
dms = json.load(f)
chain = dms.get("deadman_switch", {}).get("fallback", {}).get("fallback_chain", [])
assert provider in chain, \
f"Provider '{provider}' from emergency config not in deadman fallback chain {chain}"
class TestReadmeCompleteness:
"""README should cover essential operator information."""
def test_readme_covers_key_sections(self):
path = EMERGENCY_DIR / "DEADMAN_SWITCH_README.md"
with open(path) as f:
readme = f.read()
required_phrases = ["Overview", "Recovery", "Escalation", "Manual Override"]
for phrase in required_phrases:
assert phrase in readme, f"README missing relevant section: {phrase}"