113 lines
4.9 KiB
YAML
113 lines
4.9 KiB
YAML
# Политика исполнения Hermes (V1, Фаза A)
|
|
|
|
version: 1
|
|
updated: "2026-11-05"
|
|
|
|
# ── Глобальные предохранители ─────────────────────────────────────
|
|
defaults:
|
|
single_flight: true # задача не может идти в двух экземплярах
|
|
cooldown: 10m # после запуска — пауза
|
|
retry: [0s, 2m, 10m] # три попытки, потом сдаться
|
|
circuit_breaker: 3 # 3 провала подряд → стоп до ручного сброса
|
|
alert_on: give_up # уведомлять только когда сдались
|
|
budget_per_hour: 20 # не более 20 действий в час на хост
|
|
dedup_window: 1h # одинаковое событие = одно уведомление
|
|
dry_run: true # глобально: сначала только «что бы сделал»
|
|
|
|
# ── Kill-switch ───────────────────────────────────────────────────
|
|
# Создание этого файла мгновенно останавливает все авто-действия.
|
|
kill_switch_file: /etc/hermes/KILL
|
|
|
|
# ── Лестница автономии ────────────────────────────────────────────
|
|
autonomy:
|
|
levels:
|
|
L0_suggest: "только предложение, человек делает всё"
|
|
L1_dry_run: "«я бы сделал X», пишет в журнал, ничего не меняет"
|
|
L2_safe_auto: "рестарт контейнера, повторный поиск, ротация логов"
|
|
L3_domain_auto: "старт/стоп сервисов, импорт медиа, подписи"
|
|
L4_confirm: "конфиги, чистка кэша, удаление данных — одна кнопка"
|
|
L5_full_auto: "любое whitelisted действие, только бюджет и kill-switch"
|
|
promotion: # как растёт доверие
|
|
min_runs: 20
|
|
min_success_rate: 0.95
|
|
demote_on_failure: true
|
|
default_level: L1_dry_run
|
|
|
|
# ── Правила ───────────────────────────────────────────────────────
|
|
# match — условие (проверяется детерминированно)
|
|
# action — что делает (идемпотентно)
|
|
# verify — как проверить, что помогло
|
|
# level — минимальный уровень автономии для этого действия
|
|
rules:
|
|
|
|
- id: restart-failed-ct
|
|
match: "ct.status != running"
|
|
action: "pct.start({ct})"
|
|
verify: "ct.status == running and port_open({ct.port})"
|
|
level: L2_safe_auto
|
|
max_attempts: 2
|
|
escalate_to: matrix
|
|
|
|
- id: restart-failed-container
|
|
match: "docker.state != running"
|
|
action: "docker.start({name})"
|
|
verify: "docker.state == running"
|
|
level: L2_safe_auto
|
|
cooldown: 15m
|
|
|
|
- id: docker-daemon-stuck
|
|
match: "docker.ping fails for 5m"
|
|
action: "systemctl restart docker && start_containers_by_dependency"
|
|
verify: "docker.ping ok and critical containers up"
|
|
level: L3_domain_auto
|
|
cooldown: 30m
|
|
|
|
- id: exporter-down
|
|
match: "prometheus.target == down for 10m"
|
|
action: "restart_exporter({target})"
|
|
verify: "prometheus.target == up"
|
|
level: L2_safe_auto
|
|
|
|
- id: disk-cleanup
|
|
match: "disk.used_pct > 85"
|
|
action: "rotate_logs() and docker_prune()"
|
|
verify: "disk.used_pct < 80"
|
|
level: L2_safe_auto
|
|
cooldown: 6h
|
|
escalate_to: matrix
|
|
|
|
- id: io-degradation
|
|
match: "d_state_processes > 50 within 5m"
|
|
action: "alert_only"
|
|
verify: "-"
|
|
level: L2_safe_auto
|
|
note: "ранний сигнал лавины (инцидент 04.11)"
|
|
|
|
- id: media-queue-stall
|
|
match: "radarr.queue_stalled for 6h"
|
|
action: "restart_qbittorrent() and retry_search()"
|
|
verify: "queue.progress > 0"
|
|
level: L3_domain_auto
|
|
cooldown: 6h
|
|
|
|
- id: import-missing
|
|
match: "download.completed and not imported for 1h"
|
|
action: "trigger_downloaded_movies_scan()"
|
|
verify: "movie.hasFile"
|
|
level: L3_domain_auto
|
|
|
|
- id: cert-expiring
|
|
match: "cert.days_left < 14"
|
|
action: "certbot_renew()"
|
|
verify: "cert.days_left > 30"
|
|
level: L3_domain_auto
|
|
cooldown: 24h
|
|
|
|
# ── Что НИКОГДА не автоматизируется (только L4_confirm) ───────────
|
|
forbidden_auto:
|
|
- "изменение конфигов nginx/Authentik"
|
|
- "удаление данных и медиатеки"
|
|
- "изменение политик SSO"
|
|
- "смена DNS"
|
|
- "downgrade/upgrade критичных сервисов"
|