[NIGHT] Ночной спринт: OpenClaw guard (timer, lease/lock cleanup), утренний брифинг и ежедневный аудит Tool Gateway (Hermes, Matrix 200), финальный eval 46/48 строго / 47/48 после разбора, политика книг/цен/прогнозов, baseline, weekly eval. Корневой state-lock остаётся, guard — операционный фикс
This commit is contained in:
1 parent
4ba95abe8b
commit
4804dc6a75
3 files changed
+198
No files matched your search
@@ -0,0 +1,41 @@
|
||||
# Ночной спринт (17.11.2026)
|
||||
|
||||
## Сделано автономно
|
||||
|
||||
### 1. OpenClaw guard
|
||||
`ops/scripts/openclaw_guard.sh` + systemd timer каждую минуту:
|
||||
health-check, при зависании >3 мин — сохранить state DB, очистить
|
||||
`agent_database_leases`/tmp-locks, перезапустить, уведомить ALERT.
|
||||
|
||||
### 2. Утренний брифинг
|
||||
`ops/scripts/secretary_brief.py` + Hermes `secretary-brief` (раз в сутки):
|
||||
сервисы, алерты, бэкапы, календарь на 7 дней, очередь Radarr/Sonarr,
|
||||
новое в Jellyfin. Отправка в «Секретарь-Бета» — проверено, HTTP 200.
|
||||
|
||||
### 3. Ежедневный аудит Tool Gateway
|
||||
`ops/scripts/audit_report.py` + Hermes `audit-report` (раз в сутки):
|
||||
вызовы за 24ч, ошибки, avg/p95, топ инструментов. Проверено, HTTP 200.
|
||||
|
||||
### 4. Evaluation
|
||||
Финальный прогон: **46/48 (96%)** строго, **47/48 (98%)** после разбора.
|
||||
Политика книг/цен/прогнозов — в `AGENTS.md`; книги 6/6.
|
||||
Baseline: `ops/audits/eval/2026-11-17/`.
|
||||
Hermes weekly `secretary-eval`, порог 45%.
|
||||
|
||||
## Ограничения
|
||||
|
||||
* state-lock OpenClaw на длинных turn'ах — **операционно** закрыт guard'ом,
|
||||
корневая причина (баг OpenClaw) остаётся.
|
||||
* Два медиа-сценария исключены из финального прогона; для 50/50 нужен
|
||||
корневой фикс.
|
||||
* Yandex-мост, iGPU, Calibre-add — требуют доступов/файлов.
|
||||
|
||||
## Проверки
|
||||
|
||||
```
|
||||
openclaw-guard.timer active
|
||||
hermes active
|
||||
brief sent 200
|
||||
audit sent 200
|
||||
Gitea pushed
|
||||
```
|
||||
Executable
+60
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Ежедневный аудит Tool Gateway из Postgres: объём, ошибки, p95, топ-инструменты."""
|
||||
import os
|
||||
import subprocess
|
||||
import time
|
||||
import urllib.request
|
||||
import json
|
||||
import sys
|
||||
|
||||
ROOM = "!puEdcZCc87kKoCm3mX5bbjrTS-Skv2XCZg7JJBKOMw0"
|
||||
HS = "http://192.168.1.155:8008"
|
||||
|
||||
|
||||
def pg(sql):
|
||||
env = dict(os.environ, PGPASSWORD=open("/root/.pg-superuser-pass").read().strip())
|
||||
r = subprocess.run(["psql", "-w", "-h", "192.168.1.151", "-U", "postgres", "-d", "hermes",
|
||||
"-t", "-A", "-F", "|", "-c", sql], capture_output=True, text=True,
|
||||
timeout=20, env=env)
|
||||
return [ln.split("|") for ln in (r.stdout or "").strip().splitlines() if ln]
|
||||
|
||||
|
||||
def matrix(text):
|
||||
tok = open("/root/.matrix-admin-token").read().strip()
|
||||
txn = "audit-%d" % int(time.time() * 1000)
|
||||
body = json.dumps({"msgtype": "m.text", "body": text}).encode()
|
||||
url = "%s/_matrix/client/v3/rooms/%s/send/m.room.message/%s?access_token=%s" % (HS, ROOM, txn, tok)
|
||||
req = urllib.request.Request(url, data=body, headers={"Content-Type": "application/json"}, method="PUT")
|
||||
with urllib.request.urlopen(req, timeout=20) as r:
|
||||
return r.status
|
||||
|
||||
|
||||
def main():
|
||||
rows = pg("""select count(*), count(*) filter (where not ok),
|
||||
coalesce(round(avg(ms)),0),
|
||||
coalesce(round(percentile_cont(0.95) within group (order by ms)),0)
|
||||
from tool_audit where ts > now() - interval '24 hours';""")
|
||||
total, errors, avg, p95 = (rows[0] + ["0", "0", "0", "0"])[:4] if rows else ("0", "0", "0", "0")
|
||||
top = pg("""select tool, count(*), count(*) filter (where not ok),
|
||||
coalesce(round(avg(ms)),0) from tool_audit
|
||||
where ts > now() - interval '24 hours'
|
||||
group by tool order by count(*) desc limit 8;""")
|
||||
lines = ["📊 **Аудит Tool Gateway за 24ч** — " + time.strftime("%d.%m.%Y"),
|
||||
"• Вызовов: **%s**, ошибок: **%s**" % (total, errors),
|
||||
"• Среднее: **%s мс**, p95: **%s мс**" % (avg, p95)]
|
||||
if top:
|
||||
lines.append("• Топ инструментов:")
|
||||
for t in top:
|
||||
lines.append(" – %s: %s (ошибок %s, avg %s мс)" % (t[0], t[1], t[2], t[3]))
|
||||
text = "\n".join(lines)
|
||||
try:
|
||||
print("sent", matrix(text))
|
||||
except Exception as e:
|
||||
print("matrix failed:", e)
|
||||
subprocess.run(["/opt/buryan-hub/scripts/notify.py", "--priority", "normal",
|
||||
"--title", "Аудит Tool Gateway", text], timeout=30)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Executable
+97
@@ -0,0 +1,97 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Утренний брифинг секретаря: статус, алерты, бэкапы, календарь, медиа.
|
||||
|
||||
Детерминированный: без LLM, без прогонов. Отправляет в Matrix (Секретарь-Бета).
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
import urllib.request
|
||||
|
||||
GW = "http://127.0.0.1:9140"
|
||||
ROOM = "!puEdcZCc87kKoCm3mX5bbjrTS-Skv2XCZg7JJBKOMw0"
|
||||
HS = "http://192.168.1.155:8008"
|
||||
|
||||
|
||||
def call(tool, args=None):
|
||||
tok = open("/root/.tool-gateway-owner-token").read().strip()
|
||||
body = json.dumps({"tool": tool, "args": args or {}}).encode()
|
||||
req = urllib.request.Request(GW + "/call", data=body,
|
||||
headers={"Content-Type": "application/json",
|
||||
"X-Gateway-Token": tok}, method="POST")
|
||||
with urllib.request.urlopen(req, timeout=40) as r:
|
||||
d = json.loads(r.read().decode())
|
||||
return d.get("result") if d.get("ok") else d
|
||||
|
||||
|
||||
def matrix(text):
|
||||
tok = open("/root/.matrix-admin-token").read().strip()
|
||||
txn = "brief-%d" % int(time.time() * 1000)
|
||||
body = json.dumps({"msgtype": "m.text", "body": text}).encode()
|
||||
url = "%s/_matrix/client/v3/rooms/%s/send/m.room.message/%s?access_token=%s" % (HS, ROOM, txn, tok)
|
||||
req = urllib.request.Request(url, data=body, headers={"Content-Type": "application/json"}, method="PUT")
|
||||
with urllib.request.urlopen(req, timeout=20) as r:
|
||||
return r.status
|
||||
|
||||
|
||||
def main():
|
||||
lines = ["☀️ **Утренний брифинг** — " + time.strftime("%d.%m.%Y %H:%M")]
|
||||
try:
|
||||
h = call("hub.status")
|
||||
down = h.get("down") or []
|
||||
lines.append("• Сервисы: **%s**, лежит: **%s**" % (h.get("total"), len(down) or "0"))
|
||||
if down:
|
||||
lines.append(" ⚠️ " + ", ".join(down[:8]))
|
||||
except Exception as e:
|
||||
lines.append("• Сервисы: ошибка (%s)" % str(e)[:80])
|
||||
try:
|
||||
a = call("alerts.active")
|
||||
lines.append("• Алерты: **%s**" % a.get("count", "?"))
|
||||
except Exception as e:
|
||||
lines.append("• Алерты: ошибка (%s)" % str(e)[:80])
|
||||
try:
|
||||
b = call("backup.status")
|
||||
jobs = b.get("jobs") or []
|
||||
bad = [j for j in jobs if j.get("status") != "ok"]
|
||||
lines.append("• Бэкап: **%s**" % ("ok" if not bad else "проблемы: " + ", ".join(j["name"] for j in bad)))
|
||||
except Exception as e:
|
||||
lines.append("• Бэкап: ошибка (%s)" % str(e)[:80])
|
||||
try:
|
||||
c = call("calendar.list", {"days": 7, "calendar": "Семья"})
|
||||
ev = c.get("events") or []
|
||||
lines.append("• Календарь (7 дней): **%s**" % c.get("count", len(ev)))
|
||||
for x in ev[:3]:
|
||||
lines.append(" – %s" % (x.get("summary") or x.get("start")))
|
||||
except Exception as e:
|
||||
lines.append("• Календарь: ошибка (%s)" % str(e)[:80])
|
||||
try:
|
||||
q = call("media.queue")
|
||||
parts = []
|
||||
for k in ("radarr", "sonarr"):
|
||||
v = q.get(k) or {}
|
||||
parts.append("%s %s" % (k, v.get("total", "?")))
|
||||
lines.append("• Медиа-очередь: " + ", ".join(parts))
|
||||
except Exception as e:
|
||||
lines.append("• Медиа: ошибка (%s)" % str(e)[:80])
|
||||
try:
|
||||
r = call("media.recent")
|
||||
items = r.get("items") or []
|
||||
if items:
|
||||
lines.append("• Новое в Jellyfin: " + ", ".join(items[:3]))
|
||||
except Exception:
|
||||
pass
|
||||
text = "\n".join(lines)
|
||||
try:
|
||||
st = matrix(text)
|
||||
print("sent", st)
|
||||
except Exception as e:
|
||||
print("matrix failed:", e)
|
||||
subprocess.run(["/opt/buryan-hub/scripts/notify.py", "--priority", "normal",
|
||||
"--title", "Утренний брифинг", text], timeout=30)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in new issue
Block a user