From 088f2629bd5889ea7c5aefd98b725eaca2505332 Mon Sep 17 00:00:00 2001 From: Roman Buryan Date: Tue, 17 Nov 2026 18:06:08 +0300 Subject: [PATCH] =?UTF-8?q?[SPRINT]=20=D0=92=D0=B5=D1=87=D0=B5=D1=80=D0=BD?= =?UTF-8?q?=D0=B8=D0=B9=20=D1=81=D0=BF=D1=80=D0=B8=D0=BD=D1=82:=20Tool=20G?= =?UTF-8?q?ateway=2016=20=D0=B8=D0=BD=D1=81=D1=82=D1=80=D1=83=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D1=82=D0=BE=D0=B2=20(ha.search,=20media.search/request,?= =?UTF-8?q?=20hub.service=5Fdetail,=20alerts.active,=20backup.status),=20M?= =?UTF-8?q?CP=20=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D1=91=D0=BD,=20selfch?= =?UTF-8?q?eck=2024/24.=20LLM:=20CPU-=D1=82=D1=8E=D0=BD=D0=B8=D0=BD=D0=B3?= =?UTF-8?q?=2084=20=D1=82=D0=BE=D0=BA/=D1=81=20(thread12/batch1024),=20lla?= =?UTF-8?q?ma.cpp=20CPU=2081.9=20=E2=80=94=20=D0=BD=D0=B5=20=D0=B1=D1=8B?= =?UTF-8?q?=D1=81=D1=82=D1=80=D0=B5=D0=B5;=20iGPU=20=D0=B7=D0=B0=D0=B1?= =?UTF-8?q?=D0=BB=D0=BE=D0=BA=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=20render?= =?UTF-8?q?-=D0=B3=D1=80=D1=83=D0=BF=D0=BF=D0=BE=D0=B9,=20Ollama=20=D0=B1?= =?UTF-8?q?=D0=B5=D0=B7=20GPU.=20=D0=91=D0=B5=D0=B7=D0=BE=D0=BF=D0=B0?= =?UTF-8?q?=D1=81=D0=BD=D0=BE=D1=81=D1=82=D1=8C:=20=D0=BF=D0=B0=D1=80?= =?UTF-8?q?=D0=BE=D0=BB=D1=8C=20biglibrary=20=D0=B8=D0=B7=20=D1=87=D0=B0?= =?UTF-8?q?=D1=82=D0=B0=20=D1=83=D0=B4=D0=B0=D0=BB=D1=91=D0=BD=20(redactio?= =?UTF-8?q?n),=20=D0=BD=D1=83=D0=B6=D0=BD=D0=B0=20=D1=81=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D0=B0;=20=D0=B0=D0=B2=D1=82=D0=BE=D0=B7=D0=B0=D0=B3=D1=80?= =?UTF-8?q?=D1=83=D0=B7=D0=BA=D0=B0=20=D1=81=20biglibrary=20=D0=BD=D0=B5?= =?UTF-8?q?=20=D0=B2=D1=81=D1=82=D1=80=D0=B0=D0=B8=D0=B2=D0=B0=D0=B5=D1=82?= =?UTF-8?q?=D1=81=D1=8F.=20=D0=9E=D1=82=D0=BA=D1=80=D1=8B=D1=82=D0=BE:=20?= =?UTF-8?q?=D1=81=D0=B2=D0=B5=D1=82=20(=D0=BD=D0=B5=D1=8F=D1=81=D0=BD?= =?UTF-8?q?=D0=B0=D1=8F=20=D1=81=D1=83=D1=89=D0=BD=D0=BE=D1=81=D1=82=D1=8C?= =?UTF-8?q?),=20Jellyfin=20401,=20media.request=20400?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ops/audits/EVENING-SPRINT-2026-11-17.md | 69 +++++++++++++++++++++++++ ops/automations/registry.yaml | 2 +- ops/state/version-watch-seen.json | 2 +- ops/tools/gateway.py | 38 ++++++++++++++ ops/tools/mcp_gateway.py | 5 ++ 5 files changed, 114 insertions(+), 2 deletions(-) create mode 100644 ops/audits/EVENING-SPRINT-2026-11-17.md diff --git a/ops/audits/EVENING-SPRINT-2026-11-17.md b/ops/audits/EVENING-SPRINT-2026-11-17.md new file mode 100644 index 0000000..a7e6311 --- /dev/null +++ b/ops/audits/EVENING-SPRINT-2026-11-17.md @@ -0,0 +1,69 @@ +# Вечерний спринт: P0 и ускорение LLM (17.11.2026) + +## Сделано + +### Tool Gateway (16 инструментов) + +Добавлены и проверены: + +| Инструмент | Проверка | +|---|---| +| `ha.search` | нашёл коридор/прихожую, состояния и время | +| `media.search` | Clarkson's Farm (tvdb 378165) | +| `media.request` | ловит существующий сериал; сейчас 400 от Sonarr | +| `hub.service_detail` | n8n: up, CT108, порт 5680 | +| `alerts.active` | 0 активных алертов | +| `backup.status` | backup-heartbeat ok, verify-services ok | + +MCP: новые схемы доставлены, агент видит инструменты. +Selfcheck: **24/24**, Tool Gateway healthy, tools=16. + +### LLM: ускорение + +| Проверка | Результат | +|---|---| +| CPU-тюнинг Ollama | **84 ток/с** prefill (thread=12, batch=1024), было 65 | +| 8k промпт | 21.5 с против 27.7 с | +| llama.cpp CPU | prompt **81.9 ток/с**, generation 12.6 — не быстрее Ollama | +| iGPU Intel Arc | **заблокирован правами**: `/dev/dri/renderD128` root:render, `roman` не в группе | +| Ollama GPU | собран без GPU, `num_gpu` игнорируется | +| Vulkan-драйверы | скачаны user-space, llama.cpp Vulkan готов; нужен `render` | + +Вывод: CPU-потолок ~84 ток/с; iGPU требует **одного root-действия**. + +### Безопасность + +* В чат был отправлен пароль biglibrary — сообщение **удалено (redaction)**. +* Пароль нужно **сменить**; бот использовал его и скачал 3 fb2. +* Автоматическое скачивание с biglibrary **не встраиваем** (копирайт); + можно `books.search`/`books.link`/`books.status` без логина. + +### Проблемы из чата + +* Свет: обе сущности `on` с 03:50, команды 200, физически нет — нужен ответ, + какая сущность реально коридор. +* Jellyfin: оба ключа (`-key`, `-key-new`) дают **401** — нужен новый. +* Sonarr lookup: был 503, сейчас 200; `media.request` возвращает 400 + (нужно разобрать тело ответа Sonarr). +* `media.recent` не работает из-за Jellyfin 401. + +## Что нужно от владельца (когда будет доступ) + +```bash +sudo usermod -aG render,video roman +sudo cpupower frequency-set -g performance +sudo systemctl restart ollama +``` + +После этого: +1. Перезайти под `roman` → Vulkan увидит Arc. +2. Прогнать llama.cpp Vulkan, сравнить с 84 ток/с. +3. Починить Jellyfin-ключ и `media.request`. + +## Следующие шаги + +1. Дожать iGPU (llama.cpp Vulkan) — главный шанс ускорения. +2. Починить media.request (Sonarr 400) и Jellyfin-ключ. +3. Добавить `books.search`/`books.link`/`books.status` (без скачивания). +4. Решить по свету (какая сущность). +5. Большой аудит Tool Gateway — после P0. diff --git a/ops/automations/registry.yaml b/ops/automations/registry.yaml index 02049a4..5f7109b 100644 --- a/ops/automations/registry.yaml +++ b/ops/automations/registry.yaml @@ -1,5 +1,5 @@ # Реестр автоматизаций Buryans Hub -# Сгенерировано: 2026-11-17 16:22 (ops/scripts/build_automations_registry.py) +# Сгенерировано: 2026-11-17 18:05 (ops/scripts/build_automations_registry.py) total: 168 by_source: cron.d: 49 diff --git a/ops/state/version-watch-seen.json b/ops/state/version-watch-seen.json index 3a6a346..802f639 100644 --- a/ops/state/version-watch-seen.json +++ b/ops/state/version-watch-seen.json @@ -19,7 +19,7 @@ "nats": "dig:sha256:b7752304692bc0612b7fbae6add53cdd14059ec83cad1795d78edade6025ef07", "navidrome": "dig:sha256:38dc2727bfcfd5ede290f8ada114fc90368146f265ae4701ddddbcbe2a44ee52", "nextcloud": "dig:sha256:8041f24690c5631da46d2391e1fd7efcde95c6cf08695047f3dd7ce7783934b4", - "node_red": "dig:sha256:2ccd38b4066648bd5e17430c50a2f8102c566a82fd4f2fc5c342e61664d6896f", + "node_red": "dig:sha256:0ed181c867c9ef19cf51dc4707f7fb54d1ad58a0227ab4e19732f6a3630c1b00", "npm-app-1": "dig:sha256:91277490a919c792aa73b8d291af1ca84d32be74df988e543137976515763534", "paperless_redis": "dig:sha256:7f7d30b7fdd09467bac58198a1f166dd69789d348d4fe859cccb20e0cf287fbe", "plex": "dig:sha256:06e07af2851e6a822e89062b148435495dd794d6d5aaf36247dee05fb3dcc4b8", diff --git a/ops/tools/gateway.py b/ops/tools/gateway.py index ed485ec..2c5b965 100755 --- a/ops/tools/gateway.py +++ b/ops/tools/gateway.py @@ -299,6 +299,40 @@ def t_media_request(args): "title": res.get("title"), "id": res.get("id"), "error": res if st >= 400 else None} +def t_hub_service_detail(args): + name = (args.get("name") or "").lower() + st, body = http("GET", HUB + "/status.json", timeout=30) + d = json.loads(body) + for svc in d.get("services", []): + if svc.get("name", "").lower() == name: + return svc + matches = [x for x in d.get("services", []) if name and name in x.get("name", "").lower()] + return {"found": False, "query": name, "matches": matches[:10]} + + +def t_alerts_active(args): + st, body = http("GET", "http://192.168.1.134:9093/api/v2/alerts", timeout=15) + alerts = json.loads(body) + out = [] + for a in alerts: + lb = a.get("labels") or {} + out.append({"name": lb.get("alertname"), "severity": lb.get("severity"), + "instance": lb.get("instance"), "status": (a.get("status") or {}).get("state"), + "startsAt": a.get("startsAt")}) + return {"count": len(out), "alerts": out[:50]} + + +def t_backup_status(args): + import subprocess as sp + env = dict(os.environ, PGPASSWORD=read("/root/.pg-superuser-pass")) + q = ("SELECT name, to_char(to_timestamp(last_run),'MM-DD HH24:MI'), " + "last_status, fails FROM jobs WHERE name ILIKE '%backup%' OR name ILIKE '%verify%' " + "ORDER BY name;") + r = sp.run(["psql", "-w", "-h", "192.168.1.151", "-U", "postgres", "-d", "hermes", + "-t", "-A", "-F", "|", "-c", q], capture_output=True, text=True, timeout=30, env=env) + rows = [ln.split("|") for ln in (r.stdout or "").strip().splitlines() if ln] + return {"jobs": [{"name": x[0], "last": x[1], "status": x[2], "fails": x[3]} for x in rows]} + TOOLS = { "hub.status": {"fn": t_hub_status, "scope": "read", "confirm": False}, "hub.notify": {"fn": t_hub_notify, "scope": "write", "confirm": True, @@ -317,6 +351,9 @@ TOOLS = { "media.search": {"fn": t_media_search, "scope": "read", "confirm": False}, "media.request": {"fn": t_media_request, "scope": "write", "confirm": True, "actors": ["owner", "family"]}, + "hub.service_detail": {"fn": t_hub_service_detail, "scope": "read", "confirm": False}, + "alerts.active": {"fn": t_alerts_active, "scope": "read", "confirm": False}, + "backup.status": {"fn": t_backup_status, "scope": "read", "confirm": False}, } @@ -390,6 +427,7 @@ class Handler(BaseHTTPRequestHandler): "ha.search": ["query"], "media.search": ["query"], "media.request": ["query"], + "hub.service_detail": ["name"], }.get(tool, []) missing = [k for k in required if not args.get(k)] if missing: diff --git a/ops/tools/mcp_gateway.py b/ops/tools/mcp_gateway.py index a16afb8..e9786cd 100755 --- a/ops/tools/mcp_gateway.py +++ b/ops/tools/mcp_gateway.py @@ -34,6 +34,11 @@ SCHEMAS = { "required": ["title", "start"]}), "photos.people": ("Люди в Immich", {"type": "object", "properties": {}}), "photos.albums": ("Альбомы Immich", {"type": "object", "properties": {}}), + "hub.service_detail": ("Детали одной службы хаба по имени", {"type": "object", "properties": { + "name": {"type": "string"}}, "required": ["name"]}), + "alerts.active": ("Активные алерты Alertmanager", {"type": "object", "properties": {}}), + "backup.status": ("Статус заданий бэкапа/проверки", {"type": "object", "properties": {}}), + "ha.search": ("Найти сущности Home Assistant по имени", {"type": "object", "properties": { "query": {"type": "string"}, "domain": {"type": "string"}}, "required": ["query"]}), "media.search": ("Поиск сериала или фильма в Sonarr/Radarr", {"type": "object", "properties": {