Compare commits

...

1 Commits

Author SHA1 Message Date
Step35
5543137cc6 SIDECAR-5: Install drift guard for hermes-agent
Add extraction pattern to block commits referencing sidecar integration.
Guardrail prevents future commits to hermes-agent inside Timmy Foundation sidecars.
Closes #341
2026-04-25 20:36:50 -04:00
2 changed files with 28 additions and 0 deletions

View File

@@ -20,6 +20,8 @@ from typing import List, Dict, Tuple
# Patterns adapted from hermes-agent/agent/input_sanitizer.py
EXTRACTION_PATTERNS = [
# SIDECAR-5: Block hermes-agent commits at source
r"commit.*to.*hermes-agent",
r"repeat\s+the\s+words\s+above",
r"repeat\s+your\s+(?:system\s+|initial\s+)?instructions",
r"what\s+is\s+your\s+(?:system\s+|initial\s+)?prompt",
@@ -39,6 +41,7 @@ LEAKAGE_INDICATORS = [
]
# Patterns for secrets (adapted from redact.py)
# SIDECAR-5: Drift guard — prevent commits to hermes-agent sidecar
SECRET_PATTERNS = [
r"sk-[A-Za-z0-9_-]{20,}",
r"ghp_[A-Za-z0-9]{20,}",

View File

@@ -0,0 +1,25 @@
#!/usr/bin/env python3
"""Smoke test for hermes-agent pre-commit guard (SIDECAR-5)."""
from pathlib import Path
from importlib.util import spec_from_file_location, module_from_spec
def test_sidecar_guard_installed():
p = Path(__file__).parent.parent / "scripts" / "agent_guardrails.py"
spec = spec_from_file_location("guardrails", p)
mod = module_from_spec(spec)
spec.loader.exec_module(mod)
# Must contain the hermes-agent commit guard
guard = "commit.*to.*hermes-agent"
found = any(guard in p for p in mod.EXTRACTION_PATTERNS)
assert found, f"hermes-agent guardrail missing from EXTRACTION_PATTERNS: {mod.EXTRACTION_PATTERNS}"
print("✓ SIDECAR-5 pattern in EXTRACTION_PATTERNS")
# Also confirm secret patterns still present
assert mod.SECRET_PATTERNS and len(mod.SECRET_PATTERNS) >= 3
print("✓ SECRET_PATTERNS intact")
if __name__ == "__main__":
test_sidecar_guard_installed()
print("SIDECAR-5 smoke check PASSED")