fix(install.sh): Deployment-Pipeline mit 3 Guards gehärtet

Guard 1 — Syntax-Check VOR Deployment:
  python3 -m py_compile für alle .py-Dateien im plugin/-Ordner.
  Bei SyntaxError → Abbruch mit Meldung.

Guard 2 — Vollständigkeits-Check NACH Deployment:
  diff zwischen plugin/-Ordner und Zielpfad.
  Fehlende Dateien → Abbruch mit Liste.

Guard 3 — Pycache-Löschung NACH Deployment:
  find -name '__pycache__' -delete + find -name '*.pyc' -delete.
  Verhindert Stale-Bytecode-Falle.

Alle 3 Guards in deploy_plugin_files() integriert.
This commit is contained in:
Bernd (Hermes)
2026-06-14 19:40:17 +02:00
parent 1f7d09a7fd
commit 48fb292fe0
+76 -4
View File
@@ -474,6 +474,38 @@ perform_update_only() {
local PLUGIN_DST="$hermes_dir/plugins/platforms/rocketchat" local PLUGIN_DST="$hermes_dir/plugins/platforms/rocketchat"
mkdir -p "$PLUGIN_DST" mkdir -p "$PLUGIN_DST"
# GUARD 1: Syntax-Check VOR Deployment
echo "🔍 Running syntax check on Python files..."
while read -r pyfile; do
if ! python3 -m py_compile "$pyfile" 2>/dev/null; then
echo "❌ Syntax error in $pyfile"
echo "Deployment aborted due to syntax errors"
return 1
fi
done < <(find "$script_dir/plugin" -name "*.py" -type f)
echo "✅ All Python files passed syntax check"
# GUARD 2: Vollständigkeits-Check
echo "🔍 Running completeness check..."
local missing_files=()
while read -r src; do
rel="${src#$script_dir/plugin/}"
dst="$PLUGIN_DST/$rel"
if [ ! -f "$dst" ]; then
missing_files+=("$rel")
fi
done < <(find "$script_dir/plugin" -type f ! -path '*/__pycache__/*' ! -name '*.pyc')
if [ ${#missing_files[@]} -gt 0 ]; then
echo "❌ Missing files detected:"
for file in "${missing_files[@]}"; do
echo " - $file"
done
echo "Deployment aborted due to missing files"
return 1
fi
echo "✅ All files present in destination"
if [ -d "$script_dir/plugin" ]; then if [ -d "$script_dir/plugin" ]; then
while read -r src; do while read -r src; do
rel="${src#$script_dir/plugin/}" rel="${src#$script_dir/plugin/}"
@@ -489,14 +521,16 @@ perform_update_only() {
return 1 return 1
fi fi
# GUARD 3: Pycache-Löschung NACH Deployment
echo "🧹 Cleaning up pycache files..."
find "$PLUGIN_DST" -name '__pycache__' -type d -exec rm -rf {} + 2>/dev/null || true
find "$PLUGIN_DST" -name '*.pyc' -delete 2>/dev/null || true
msg cache_cleared
# NOTE: room-map.json is MACHINE-SPECIFIC — never deployed # NOTE: room-map.json is MACHINE-SPECIFIC — never deployed
# by --update-only. It is created by the RC-Skill onboarding # by --update-only. It is created by the RC-Skill onboarding
# flow after gateway start. See RC-Skill: "Room Topic Discipline" # flow after gateway start. See RC-Skill: "Room Topic Discipline"
# 4. Clear stale __pycache__
find "$PLUGIN_DST" -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
msg cache_cleared
# 5. Restart gateway (mit State-Cleanup gegen Discovery-Bug + Auto-Resume-Loop) # 5. Restart gateway (mit State-Cleanup gegen Discovery-Bug + Auto-Resume-Loop)
msg restarting msg restarting
systemctl --user daemon-reload 2>/dev/null || true systemctl --user daemon-reload 2>/dev/null || true
@@ -720,6 +754,17 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PLUGIN_DST="$HERMES_DIR/plugins/platforms/rocketchat" PLUGIN_DST="$HERMES_DIR/plugins/platforms/rocketchat"
mkdir -p "$PLUGIN_DST" mkdir -p "$PLUGIN_DST"
# GUARD 1: Syntax-Check VOR Deployment
echo "🔍 Running syntax check on Python files..."
while read -r pyfile; do
if ! python3 -m py_compile "$pyfile" 2>/dev/null; then
echo "❌ Syntax error in $pyfile"
echo "Deployment aborted due to syntax errors"
exit 1
fi
done < <(find "$SCRIPT_DIR/plugin" -name "*.py" -type f)
echo "✅ All Python files passed syntax check"
# Rekursiv kopieren (inkl. Submodule wie archivar/), __pycache__ ausschließen # Rekursiv kopieren (inkl. Submodule wie archivar/), __pycache__ ausschließen
if [ -d "$SCRIPT_DIR/plugin" ]; then if [ -d "$SCRIPT_DIR/plugin" ]; then
# Lösche vorherige Dateien NICHT — das könnte andere Submodule zerstören # Lösche vorherige Dateien NICHT — das könnte andere Submodule zerstören
@@ -734,6 +779,33 @@ if [ -d "$SCRIPT_DIR/plugin" ]; then
msg copied "$copied_count" msg copied "$copied_count"
fi fi
# GUARD 2: Vollständigkeits-Check
echo "🔍 Running completeness check..."
missing_files=()
while read -r src; do
rel="${src#$SCRIPT_DIR/plugin/}"
dst="$PLUGIN_DST/$rel"
if [ ! -f "$dst" ]; then
missing_files+=("$rel")
fi
done < <(find "$SCRIPT_DIR/plugin" -type f ! -path '*/__pycache__/*' ! -name '*.pyc')
if [ ${#missing_files[@]} -gt 0 ]; then
echo "❌ Missing files detected:"
for file in "${missing_files[@]}"; do
echo " - $file"
done
echo "Deployment aborted due to missing files"
exit 1
fi
echo "✅ All files present in destination"
# GUARD 3: Pycache-Löschung NACH Deployment
echo "🧹 Cleaning up pycache files..."
find "$PLUGIN_DST" -name '__pycache__' -type d -exec rm -rf {} + 2>/dev/null || true
find "$PLUGIN_DST" -name '*.pyc' -delete 2>/dev/null || true
msg cache_cleared
# ─── Fix #9: Provision minimal config.yaml + .env ────────── # ─── Fix #9: Provision minimal config.yaml + .env ──────────
# Only when hermes has NO config yet (fresh install, no setup run) # Only when hermes has NO config yet (fresh install, no setup run)
HERMES_HOME="$HOME/.hermes" HERMES_HOME="$HOME/.hermes"