faf25bf76c
Zwei zusammenhaengende Bugs, beim echten Worker-Test entdeckt:
1) HOOKS FEUERTEN FUER WORKER NIE. Kanban-Worker laufen unter IHREM Profil
(HERMES_HOME=~/.hermes/profiles/<name>) und lesen dessen config.yaml, NICHT
die Top-Level ~/.hermes/config.yaml. Die neuen Hooks waren nur oben
registriert -> fuer Worker inaktiv. FIX: ensure-profile-hooks.py registriert
pre_llm_call + pre_tool_call in jeder Worker-Profil-config (idempotent,
validiert, Backup); deploy.sh ruft es je Profil auf -> reproduzierbar.
2) FALSCHER SCOPE. Beide Hooks scopeten auf task_id == t_<hex>. Aber Worker
tragen als effective_task_id den SESSION-Zeitstempel (z.B.
20260713_224206_267304), NICHT die Kanban-t_-ID -> der Check schlug immer
fehl -> box-steckbrief injizierte nie, tabu-guard liess alles durch.
FIX:
- tabu-pfade-guard.py: Schutz jetzt UNBEDINGT (kein Task-Scope) - kein
legitimer Hermes-Agent-Flow schreibt je in Live-Checkout/Hermes-Quelle
(Werkstatt arbeitet im Workspace-Klon, Wartung ist Shell nicht Agent-Tool).
- box-steckbrief-inject.sh: Scope jetzt cwd unter ~/.hermes/kanban/workspaces/
(zuverlaessiger Worker-Signal; Lucy/Voice/CLI laufen nie dort).
Verifiziert: echter betrieb-Worker versuchte in den Live-Checkout zu schreiben
-> GEBLOCKT, Datei nicht erstellt, TABU-Meldung im Log. 26 Guard-Unit-Faelle gruen.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
73 lines
2.4 KiB
Python
73 lines
2.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Stellt sicher, dass ein Worker-Profil die Agent-Hooks kennt (Faden 8, 13.07.2026).
|
|
|
|
Kanban-Worker laufen unter IHREM Profil (HERMES_HOME=~/.hermes/profiles/<name>) und lesen
|
|
dessen config.yaml — NICHT die Top-Level ~/.hermes/config.yaml. Die worker-relevanten Hooks
|
|
(box-steckbrief-inject = Box-Wissen, tabu-pfade-guard = Schreibschutz) muessen also in JEDER
|
|
Worker-Profil-config.yaml stehen, sonst feuern sie fuer Worker nie (Bug-Fund 13.07.).
|
|
|
|
Idempotent + validiert + Backup. Setzt einen bestehenden `pre_verify`-Hook-Block als Anker
|
|
voraus (haben alle von default/werkstatt geklonten Profile); fehlt er, wird sauber
|
|
uebersprungen (exit 0), damit deploy.sh nicht bricht. Arg: Pfad zur Profil-config.yaml.
|
|
"""
|
|
import sys
|
|
import os
|
|
import datetime
|
|
import shutil
|
|
|
|
try:
|
|
import yaml
|
|
except Exception:
|
|
print(" (PyYAML fehlt — ensure-profile-hooks uebersprungen)")
|
|
sys.exit(0)
|
|
|
|
AH = os.path.expanduser("~/.hermes/agent-hooks")
|
|
WANT = {
|
|
"pre_llm_call": f"{AH}/box-steckbrief-inject.sh",
|
|
"pre_tool_call": f"{AH}/tabu-pfade-guard.py",
|
|
}
|
|
|
|
if len(sys.argv) < 2:
|
|
print(" usage: ensure-profile-hooks.py <config.yaml>")
|
|
sys.exit(0)
|
|
|
|
p = sys.argv[1]
|
|
if not os.path.isfile(p):
|
|
sys.exit(0)
|
|
|
|
txt = open(p, encoding="utf-8").read()
|
|
|
|
anchor = (" pre_verify:\n"
|
|
f" - command: {AH}/pre-verify-gates.sh\n"
|
|
" timeout: 60\n")
|
|
if txt.count(anchor) != 1:
|
|
print(f" [{os.path.basename(os.path.dirname(p))}] kein eindeutiger pre_verify-Anker — SKIP")
|
|
sys.exit(0)
|
|
|
|
add = ""
|
|
for event, cmd in WANT.items():
|
|
if cmd not in txt:
|
|
add += f" {event}:\n - command: {cmd}\n timeout: 10\n"
|
|
|
|
if not add:
|
|
print(f" [{os.path.basename(os.path.dirname(p))}] Hooks schon registriert.")
|
|
sys.exit(0)
|
|
|
|
new = txt.replace(anchor, anchor + add, 1)
|
|
try:
|
|
d = yaml.safe_load(new)
|
|
h = d["hooks"]
|
|
for event, cmd in WANT.items():
|
|
assert any(cmd in x.get("command", "") for x in h.get(event, []))
|
|
assert any("pre-verify-gates.sh" in x.get("command", "") for x in h["pre_verify"])
|
|
except Exception as exc:
|
|
print(f" [{p}] Validierung fehlgeschlagen ({exc}) — config UNVERAENDERT.")
|
|
sys.exit(0)
|
|
|
|
bak = p + ".bak-hooks-" + datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
|
|
shutil.copy2(p, bak)
|
|
tmp = p + ".tmp-hooks"
|
|
open(tmp, "w", encoding="utf-8").write(new)
|
|
os.replace(tmp, p)
|
|
print(f" [{os.path.basename(os.path.dirname(p))}] Hooks ergaenzt (Backup {os.path.basename(bak)}).")
|