feat(F069,F434,F172): Welle 1 — BG-Review-Switch, venv-Stamp, Human-Tempo-Pacing
F069 (Trivial): install.sh generiert auxiliary.background_review.enabled in config.yaml — SKIP_BACKGROUND_REVIEW env-Switch deaktiviert den Self-Improvement-Loop (Hermes-Core liest dies via load_background_review_settings). Config-Aenderung, kein Code-Feature. @implements: [F-069] F434 (Standard): install.sh erkennt venv-Wechsel (Python-Version-Upgrade oder neuer venv-Pfad) via .venv_stamp State-Datei und installiert requirements.txt automatisch neu. Verdrahtet in Haupt- und Update-Flow. .venv_stamp in .gitignore. @implements: [F-434] F172 (Standard): Bot-seitiges Human-Tempo-Pacing — der zentrale Send- Chokepoint _post_message_with_retry wartet min. HUMAN_TEMPO_MIN_DELAY Sekunden (Default 2.0) zwischen Nachrichten. Konfigurierbar via HUMAN_TEMPO_MIN_DELAY / HUMAN_TEMPO_PACING, dokumentiert in templates/.env. Async, nicht-blockierend (asyncio.sleep). @implements: [F-172] Tests: 24 Unit-Tests (5 F069 + 9 F434 + 10 F172), alle gruen auf .45.
This commit is contained in:
+160
@@ -916,6 +916,143 @@ install_python_deps() {
|
||||
return 0
|
||||
}
|
||||
|
||||
# ──────────────────────────────────────────────────────────────────────────
|
||||
# F434: venv-Wechsel-Erkennung + Post-Upgrade-Dependencies
|
||||
# Erkennt, wenn sich das venv geändert hat (Python-Version-Upgrade oder
|
||||
# neuer venv-Pfad) und installiert dann requirements.txt automatisch neu.
|
||||
#
|
||||
# Mechanism:
|
||||
# - State-Datei .venv_stamp speichert {venv_pfad, python_version} des
|
||||
# letzten erfolgreichen Install-Laufs.
|
||||
# - Vergleich bei jedem Update-/Hauptlauf: weicht der aktuelle venv-Pfad
|
||||
# oder die Python-Version von der Stempeldaten ab → neu installieren.
|
||||
# - Nach dem Install wird der Stamp aktualisiert (idempotent).
|
||||
#
|
||||
# Nutzung (install.sh-main-flows):
|
||||
# check_venv_change_and_reinstall
|
||||
# setzt PIPX_VENV / VENV_PY global, ruft find_pipx_venv auf, und prüft den
|
||||
# Stamp. Bei Aenderung → pip install -r requirements.txt.
|
||||
# @implements: [F-434]
|
||||
# ──────────────────────────────────────────────────────────────────────────
|
||||
_VENV_STAMP_NAME=".venv_stamp"
|
||||
|
||||
venv_stamp_path() {
|
||||
# Stamp-Datei liegt im Repo-Root neben install.sh (überlebt venv-Neuaufbau).
|
||||
local script_dir
|
||||
script_dir="$(cd "$(dirname "$0")" && pwd)"
|
||||
echo "$script_dir/$_VENV_STAMP_NAME"
|
||||
}
|
||||
|
||||
venv_python_ver() {
|
||||
# Liefert "X.Y" der Python-Version im aktuellen venv, oder leer.
|
||||
if [ -n "${VENV_PY:-}" ] && [ -x "$VENV_PY" ]; then
|
||||
"$VENV_PY" -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")' 2>/dev/null || true
|
||||
elif [ -n "${PIPX_VENV:-}" ] && [ -x "$PIPX_VENV/bin/python" ]; then
|
||||
"$PIPX_VENV/bin/python" -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")' 2>/dev/null || true
|
||||
fi
|
||||
}
|
||||
|
||||
# Schreibt den aktuellen venv-Zustand in die Stamp-Datei (idempotent).
|
||||
venv_stamp_write() {
|
||||
local stamp="$1"
|
||||
local vpath="${PIPX_VENV:-}"
|
||||
local pyver="$(venv_python_ver)"
|
||||
if ! $DRY_RUN; then
|
||||
printf '# F434 venv-Stamp — @implements: [F-434]\nvenv=%s\npython_version=%s\n' \
|
||||
"$vpath" "$pyver" > "$stamp" 2>/dev/null
|
||||
else
|
||||
printf '%s[dry]%s stamp-write %s → venv=%s py=%s\n' \
|
||||
"$C_YELLOW" "$C_RESET" "$stamp" "$vpath" "$pyver"
|
||||
fi
|
||||
}
|
||||
|
||||
# Liest den gespeicherten venv-Zustand aus der Stamp-Datei.
|
||||
# Gibt leer aus, wenn keine gültige Stamp existiert.
|
||||
venv_stamp_read() {
|
||||
local stamp="$1"
|
||||
if [ -f "$stamp" ]; then
|
||||
sed -n 's/^venv=\(.*\)$/\1/p' "$stamp" 2>/dev/null | head -1
|
||||
fi
|
||||
}
|
||||
|
||||
venv_stamp_read_py() {
|
||||
local stamp="$1"
|
||||
if [ -f "$stamp" ]; then
|
||||
sed -n 's/^python_version=\(.*\)$/\1/p' "$stamp" 2>/dev/null | head -1
|
||||
fi
|
||||
}
|
||||
|
||||
# Main-F434-Helper: Prüft venv-Wechsel, installiert requirements neu bei Aenderung.
|
||||
check_venv_change_and_reinstall() {
|
||||
local script_dir req stamp old_path old_py cur_path cur_py
|
||||
script_dir="$(cd "$(dirname "$0")" && pwd)"
|
||||
req="$script_dir/requirements.txt"
|
||||
stamp="$(venv_stamp_path)"
|
||||
|
||||
# venv-Pfad ermitteln (falls global noch nicht gesetzt).
|
||||
if [ -z "${PIPX_VENV:-}" ]; then
|
||||
PIPX_VENV="$(find_pipx_venv 2>/dev/null)" || true
|
||||
fi
|
||||
if [ -z "${VENV_PY:-}" ] && [ -n "$PIPX_VENV" ]; then
|
||||
VENV_PY="$PIPX_VENV/bin/python"
|
||||
fi
|
||||
[ -n "${PIPX_VENV:-}" ] || { warn "F434: kein venv-Pfad ermittelbar — Stamp-Prüfung übersprungen"; return 0; }
|
||||
cur_path="$PIPX_VENV"
|
||||
cur_py="$(venv_python_ver)"
|
||||
|
||||
# Alten Stamp lesen (falls vorhanden).
|
||||
old_path="$(venv_stamp_read "$stamp")"
|
||||
old_py="$(venv_stamp_read_py "$stamp")"
|
||||
|
||||
# Erstlauf oder Wechsel → neu installieren.
|
||||
if [ -z "$old_path" ] && [ -z "$old_py" ]; then
|
||||
log "F434: kein venv-Stamp — initiale requirements-Installation"
|
||||
install_venv_requirements "$req"
|
||||
venv_stamp_write "$stamp"
|
||||
return 0
|
||||
fi
|
||||
|
||||
local changed=false
|
||||
if [ -n "$cur_path" ] && [ "$cur_path" != "$old_path" ]; then
|
||||
warn "F434: venv-Pfad geändert ($old_path → $cur_path) — requirements neu installieren"
|
||||
changed=true
|
||||
fi
|
||||
if [ -n "$cur_py" ] && [ -n "$old_py" ] && [ "$cur_py" != "$old_py" ]; then
|
||||
warn "F434: Python-Version geändert ($old_py → $cur_py) — requirements neu installieren"
|
||||
changed=true
|
||||
fi
|
||||
|
||||
if $changed; then
|
||||
install_venv_requirements "$req"
|
||||
venv_stamp_write "$stamp"
|
||||
else
|
||||
log "F434: venv unverändert ($cur_path / py$cur_py) — keine Neuinstallation nötig"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
# Installiert requirements.txt (falls vorhanden) in den aktuellen venv.
|
||||
install_venv_requirements() {
|
||||
local req="$1"
|
||||
if [ ! -f "$req" ]; then
|
||||
log "F434: $req fehlt — überspringe requirements"
|
||||
return 0
|
||||
fi
|
||||
local py="${VENV_PY:-$PIPX_VENV/bin/python}"
|
||||
log "F434: Installiere requirements.txt ($req)..."
|
||||
if ! $DRY_RUN; then
|
||||
"$py" -m pip install --quiet -r "$req" || {
|
||||
warn "F434: pip install -r $req fehlgeschlagen"
|
||||
return 1
|
||||
}
|
||||
ok "F434: requirements.txt installiert"
|
||||
else
|
||||
printf '%s[dry]%s %s -m pip install -r %s\n' "$C_YELLOW" "$C_RESET" "$py" "$req"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
# ──────────────────────────────────────────────────────────────────────────
|
||||
# 3. Plugin aus Gitea holen und kopieren
|
||||
# P3: Plugin-Pfad ist ~/.hermes/plugins/platforms/rocketchat/ (User-Space, Variante B)
|
||||
@@ -1483,6 +1620,15 @@ write_config_yaml() {
|
||||
*) providers_block="providers: {}" ;;
|
||||
esac
|
||||
|
||||
# F069: Self-Improvement-Loop (Background-Review) deaktivierbar machen.
|
||||
# Default: enabled (Hermes-Core Fail-open). Zum Deaktivieren setze
|
||||
# SKIP_BACKGROUND_REVIEW=true (env). @implements: [F-069]
|
||||
local bg_review_enabled=true
|
||||
if [ "${SKIP_BACKGROUND_REVIEW:-false}" = "true" ]; then
|
||||
bg_review_enabled=false
|
||||
log "F069: SKIP_BACKGROUND_REVIEW=true — Background-Review deaktiviert"
|
||||
fi
|
||||
|
||||
# YAML generieren. Wir nutzen eine Heredoc mit $-Expansion, weil wir
|
||||
# alle Werte kontrollieren (keine User-Eingabe mit Sonderzeichen).
|
||||
if ! $DRY_RUN; then
|
||||
@@ -1550,6 +1696,11 @@ auxiliary:
|
||||
session_search:
|
||||
provider: ${provider}
|
||||
model: ${MODEL_NAME}
|
||||
background_review:
|
||||
# F069: Self-Improvement-Loop (Background-Review) deaktivierbar — @implements: [F-069]
|
||||
# Der Core liest auxiliary.background_review.enabled via load_background_review_settings().
|
||||
# SKIP_BACKGROUND_REVIEW env-Variable (install.sh) steuert diesen Wert.
|
||||
enabled: ${bg_review_enabled}
|
||||
|
||||
# Kompression (aus env)
|
||||
compression:
|
||||
@@ -3884,6 +4035,11 @@ if $UPDATE_ONLY; then
|
||||
}
|
||||
VENV_PY="$PIPX_VENV/bin/python"
|
||||
|
||||
# F434: venv-Wechsel-Erkennung — bei Python-Version-Upgrade oder neuem
|
||||
# venv-Pfad werden requirements.txt automatisch neu installiert.
|
||||
# @implements: [F-434]
|
||||
check_venv_change_and_reinstall
|
||||
|
||||
# Ziel-Pfad: User-Space (Variante B)
|
||||
_update_dst="$HOME/.hermes/plugins/platforms/rocketchat"
|
||||
log "Update-Ziel (User-Space): $_update_dst"
|
||||
@@ -4083,6 +4239,10 @@ install_hermes_agent
|
||||
# 2b. Python-Dependencies (F98 P-179: mit $VENV_PY, nach venv-Erstellung)
|
||||
install_python_deps
|
||||
|
||||
# 2c. F434: venv-Stamp nach Erstinstallation schreiben (Für spätere
|
||||
# Wechsel-Erkennung). @implements: [F-434]
|
||||
check_venv_change_and_reinstall
|
||||
|
||||
# Ollama-Modelle (lokal für Archivar) — F98 P-181: nur die von compute_cascade
|
||||
# bestimmten Modelle (MODEL_PULL_REQUIRED), nicht mehr hardcoded qwen2.5:7b+nomic.
|
||||
if ! $SKIP_OLLAMA_MODELS && ! $DRY_RUN; then
|
||||
|
||||
Reference in New Issue
Block a user