From c5e35f0b18cf3ae6992276d2e3254e50ef02cd44 Mon Sep 17 00:00:00 2001 From: Roman Buryan Date: Thu, 5 Nov 2026 22:40:24 +0300 Subject: [PATCH] =?UTF-8?q?[SPRINT-V1][F]=20=D0=9D=D0=B5=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D0=B0=D1=8F=20=D1=81=D0=B2=D0=BE=D0=B4=D0=BA=D0=B0?= =?UTF-8?q?=20(=D0=B3=D0=B8=D0=B3=D0=B8=D0=B5=D0=BD=D0=B0+=D1=80=D0=B0?= =?UTF-8?q?=D0=B7=D0=B2=D0=B8=D1=82=D0=B8=D0=B5+=D0=B4=D0=BE=D0=B2=D0=B5?= =?UTF-8?q?=D1=80=D0=B8=D0=B5+=D0=B7=D0=B0=D0=B4=D0=B0=D1=87=D0=B8),=20?= =?UTF-8?q?=D1=8D=D0=BF=D0=B8=D0=B7=D0=BE=D0=B4=D0=B8=D1=87=D0=B5=D1=81?= =?UTF-8?q?=D0=BA=D0=B0=D1=8F=20=D0=BF=D0=B0=D0=BC=D1=8F=D1=82=D1=8C=20?= =?UTF-8?q?=D0=B2=20RAG=20(=D0=B6=D1=83=D1=80=D0=BD=D0=B0=D0=BB=20=D0=B4?= =?UTF-8?q?=D0=B5=D0=B9=D1=81=D1=82=D0=B2=D0=B8=D0=B9=20+=20=D0=BE=D1=82?= =?UTF-8?q?=D1=87=D1=91=D1=82=D1=8B=20=D0=B0=D0=B3=D0=B5=D0=BD=D1=82=D0=BE?= =?UTF-8?q?=D0=B2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ops/hermes/jobs.yaml | 6 ++ ops/scripts/rag_index.py | 25 ++++++- ops/scripts/weekly_report.py | 124 ++++++++++++++++++++++++++++++++++ ops/weekly/WEEKLY-2026-W45.md | 47 +++++++++++++ 4 files changed, 201 insertions(+), 1 deletion(-) create mode 100755 ops/scripts/weekly_report.py create mode 100644 ops/weekly/WEEKLY-2026-W45.md diff --git a/ops/hermes/jobs.yaml b/ops/hermes/jobs.yaml index 051ae72..22bb638 100644 --- a/ops/hermes/jobs.yaml +++ b/ops/hermes/jobs.yaml @@ -94,3 +94,9 @@ trust-report: notify_on_success: false timeout: 120 retries: 0 +weekly-report: + command: /usr/bin/python3 /root/buryan-infra/ops/scripts/weekly_report.py + daily_at: 08:05 + notify_on_success: false + timeout: 180 + retries: 0 diff --git a/ops/scripts/rag_index.py b/ops/scripts/rag_index.py index 84e298a..3d6deb3 100755 --- a/ops/scripts/rag_index.py +++ b/ops/scripts/rag_index.py @@ -58,14 +58,37 @@ def collect_files(): if not os.path.isdir(base): continue for dirpath, dirnames, filenames in os.walk(base): + # исключаем только служебное; отчёты гигиены/развития/доверия — это ЭПИЗОДИЧЕСКАЯ память dirnames[:] = [x for x in dirnames if x not in - (".git", "node_modules", "rag", "topology", "hygiene", "__pycache__")] + (".git", "node_modules", "__pycache__", "index.db")] for fn in filenames: if fn.endswith((".md", ".txt", ".yml", ".yaml")) and not fn.startswith("."): p = os.path.join(dirpath, fn) if os.path.getsize(p) < 200: continue files.append(p) + # эпизодическая память: журнал действий агента + journal = "/var/log/hermes/actions.jsonl" + if os.path.isfile(journal): + try: + eps = [] + lines = open(journal, encoding="utf-8", errors="ignore").readlines()[-400:] + for ln in lines: + try: + e = json.loads(ln) + except Exception: + continue + if e.get("event") not in ("done", "failed", "denied"): + continue + eps.append("%s | %s | %s | %s" % ( + e.get("ts", ""), e.get("rule", ""), e.get("event", ""), + str(e.get("reason") or e.get("detail") or "")[:200])) + if eps: + ep_path = ROOT + "/ops/rag/episodes-actions.txt" + open(ep_path, "w", encoding="utf-8").write("\n".join(eps)) + files.append(ep_path) + except Exception: + pass for f in EXTRA_FILES: p = os.path.join(ROOT, f) if os.path.isfile(p): diff --git a/ops/scripts/weekly_report.py b/ops/scripts/weekly_report.py new file mode 100755 index 0000000..70c092a --- /dev/null +++ b/ops/scripts/weekly_report.py @@ -0,0 +1,124 @@ +#!/usr/bin/env python3 +"""Недельный сводный отчёт: гигиена + развитие + доверие + состояние. + +Собирает свежие отчёты агентов и формирует единый документ для владельца. +Отчёт: ops/weekly/WEEKLY-YYYY-WNN.md +""" +import glob +import json +import os +import re +import subprocess +from datetime import date + +ROOT = "/root/buryan-infra" +OUT = ROOT + "/ops/weekly" + + +def sh(cmd, timeout=60): + try: + r = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=timeout) + return (r.stdout or "").strip() + except Exception: + return "" + + +def latest(pattern): + files = sorted(glob.glob(pattern)) + return files[-1] if files else None + + +def counts_from(path, prefix=r"находок|Найдено"): + if not path: + return None + try: + text = open(path, encoding="utf-8").read() + except Exception: + return None + m = re.search(r"(?:находок|Найдено):\s*\*\*(\d+)\*\*", text, re.I) + m2 = re.search(r"· high: (\d+) · medium: (\d+) · low: (\d+) · info: (\d+)", text) + if not m: + return None + return {"total": m.group(1), "high": (m2.group(1) if m2 else "?")} + + +def main(): + os.makedirs(OUT, exist_ok=True) + iso = date.today().isocalendar() + path = os.path.join(OUT, "WEEKLY-%d-W%02d.md" % (iso[0], iso[1])) + + hyg = latest(ROOT + "/ops/hygiene/report-*.md") + evo = latest(ROOT + "/ops/evolution/report-*.md") + trust = latest(ROOT + "/ops/trust/report-*.md") + + L = ["# Недельная сводка — %s" % date.today().isoformat(), ""] + + # состояние + L += ["## Состояние", ""] + up = sh("pct list | grep -c running") + total = sh("pct list | tail -n +2 | wc -l") + failed = sh("systemctl --failed --no-legend --no-pager | wc -l") + mem = sh("free -h | awk '/^Mem:/{print $3\" / \"$2}'") + L += ["| Метрика | Значение |", "|---|---|", + "| Контейнеры | %s из %s |" % (up, total), + "| Упавших юнитов | %s |" % failed, + "| Память | %s |" % mem, + "| Uptime | %s |" % sh("uptime -p"), + ""] + + # гигиена + L += ["## Гигиена", ""] + hc = counts_from(hyg) + if hc: + L.append("- находок: **%s** (high: %s)" % (hc["total"], hc["high"])) + L.append("- отчёт: `%s`" % os.path.basename(hyg)) + else: + L.append("- отчёт не найден") + L.append("") + + # развитие + L += ["## Развитие", ""] + if evo: + try: + text = open(evo, encoding="utf-8").read() + m = re.search(r"RETIRE-кандидатов: (\d+)", text) or re.search(r"Сервисов в реестре \| (\d+)", text) + L.append("- отчёт: `%s`" % os.path.basename(evo)) + row = [ln for ln in text.splitlines() if ln.startswith("| `")] + if row: + L.append("- кандидаты/сервисы: %d строк" % len(row)) + except Exception: + L.append("- отчёт не читается") + else: + L.append("- отчёт не найден") + L.append("") + + # доверие + L += ["## Доверие агента", ""] + if trust: + text = open(trust, encoding="utf-8").read() + m = re.search(r"готовы к повышению: \*\*(\d+)\*\*", text) + m2 = re.search(r"требуют внимания: \*\*(\d+)\*\*", text) + L.append("- готовы к повышению: %s" % (m.group(1) if m else "?")) + L.append("- требуют внимания: %s" % (m2.group(1) if m2 else "?")) + L.append("- отчёт: `%s`" % os.path.basename(trust)) + else: + L.append("- отчёт не найден") + L.append("") + + # задачи владельцу + L += ["## Задачи владельцу", ""] + todo = ROOT + "/ops/OWNER-TODO.md" + if os.path.exists(todo): + for ln in open(todo, encoding="utf-8").read().splitlines(): + if ln.strip().startswith("- [ ]"): + L.append(ln.replace("- [ ]", "- ☐")) + L.append("") + + open(path, "w", encoding="utf-8").write("\n".join(L) + "\n") + print("отчёт:", path) + print("контейнеры: %s/%s | упавших: %s | память: %s" % (up, total, failed, mem)) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/ops/weekly/WEEKLY-2026-W45.md b/ops/weekly/WEEKLY-2026-W45.md new file mode 100644 index 0000000..245d702 --- /dev/null +++ b/ops/weekly/WEEKLY-2026-W45.md @@ -0,0 +1,47 @@ +# Недельная сводка — 2026-11-05 + +## Состояние + +| Метрика | Значение | +|---|---| +| Контейнеры | 32 из 33 | +| Упавших юнитов | 6 | +| Память | 11Gi / 15Gi | +| Uptime | up 42 minutes | + +## Гигиена + +- находок: **19** (high: 1) +- отчёт: `report-2026-11-05.md` + +## Развитие + +- отчёт: `report-2026-11-05.md` +- кандидаты/сервисы: 27 строк + +## Доверие агента + +- готовы к повышению: 0 +- требуют внимания: 1 +- отчёт: `report-2026-11-05.md` + +## Задачи владельцу + +- ☐ Сделано +- ☐ Убрать остатки (скажу команду) +- ☐ Вернуть сервис +- ☐ **Debrid** (Real-Debrid / AllDebrid / TorBox) — качает из кэша, сидов не нужно +- ☐ **RuTracker** — зарегистрировать аккаунт, дать логин/пароль (Cloudflare блокирует автовход) +- ☐ **Telegram-каналы с кино** — назвать 2–3 канала, userbot будет искать и складывать +- ☐ Докупить RAM +- ☐ Ограничить лимиты контейнерам (скажу, каким) +- ☐ Ничего не делать (риск повторится) +- ☐ Внедрять (скажу, что делают) +- ☐ Законсервировать +- ☐ Удалить +- ☐ AtlasDesign SMART (~4 000 ₽ × 8) +- ☐ Переход на Sonoff/другую систему (дешевле, смена рамок) +- ☐ «Реле где влезет» — нужны фото подрозетников +- ☐ Получить новый OAuth-токен → положу в `/root/.yandex-token`, включу обратно +- ☐ Не нужен — оставить выключенным +