Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
50c31091b2 | ||
|
|
9340263940 | ||
|
|
d6ee44f0e7 | ||
|
|
fca442c5da | ||
|
|
2a1393def5 |
No files matched your search
@@ -0,0 +1,55 @@
|
||||
events:
|
||||
- event_type: media.request.created
|
||||
owner: roman/media
|
||||
producer: seerr-adapter
|
||||
consumers: [notify-bot, audit360]
|
||||
retention_days: 90
|
||||
pii: false
|
||||
- event_type: media.request.approved
|
||||
owner: roman/media
|
||||
producer: seerr-adapter
|
||||
consumers: [notify-bot]
|
||||
retention_days: 90
|
||||
pii: false
|
||||
- event_type: media.playback.started
|
||||
owner: roman/media
|
||||
producer: jellyfin-adapter
|
||||
consumers: [audit360, analytics]
|
||||
retention_days: 30
|
||||
pii: true
|
||||
- event_type: media.work.added
|
||||
owner: roman/media
|
||||
producer: jellyfin-adapter
|
||||
consumers: [buryans-one, search]
|
||||
retention_days: 365
|
||||
pii: false
|
||||
- event_type: audit.finding.opened
|
||||
owner: roman/audit
|
||||
producer: audit360
|
||||
consumers: [nexus]
|
||||
retention_days: 365
|
||||
pii: false
|
||||
- event_type: identity.user.created
|
||||
owner: roman/sso
|
||||
producer: authentik-adapter
|
||||
consumers: [audit360, buryans-one]
|
||||
retention_days: 365
|
||||
pii: true
|
||||
- event_type: home.state.changed
|
||||
owner: roman/home
|
||||
producer: homeassistant-adapter
|
||||
consumers: [buryans-one]
|
||||
retention_days: 30
|
||||
pii: false
|
||||
- event_type: agent.task.requested
|
||||
owner: roman/agents
|
||||
producer: bot-adapter
|
||||
consumers: [agent-runner]
|
||||
retention_days: 30
|
||||
pii: false
|
||||
- event_type: system.service.down
|
||||
owner: roman/sre
|
||||
producer: monitor-adapter
|
||||
consumers: [notify-bot]
|
||||
retention_days: 90
|
||||
pii: false
|
||||
@@ -0,0 +1,32 @@
|
||||
# Event Ownership Matrix — Stage 2
|
||||
|
||||
Правило: у каждого типа события есть **один owner**, один producer и явные consumers.
|
||||
Событие без owner не публикуется в production.
|
||||
|
||||
| event_type | owner | producer | consumers | retention | PII |
|
||||
|---|---|---|---|---|---|
|
||||
| media.request.created | Roman / Media | Seerr adapter | notification bot, Audit | 90d | no |
|
||||
| media.request.approved | Roman / Media | Seerr adapter | notification bot | 90d | no |
|
||||
| media.playback.started | Roman / Media | Jellyfin adapter | Audit, analytics | 30d | user id |
|
||||
| media.work.added | Roman / Media | Jellyfin adapter | Buryans One, search | 365d | no |
|
||||
| media.work.updated | Roman / Media | Jellyfin adapter | Buryans One | 365d | no |
|
||||
| audit.finding.opened | Roman / Audit | Audit 360 | Nexus | 365d | no |
|
||||
| audit.finding.closed | Roman / Audit | Audit 360 | Nexus | 365d | no |
|
||||
| identity.user.created | Roman / SSO | Authentik adapter | Audit, Buryans One | 365d | email |
|
||||
| identity.user.disabled | Roman / SSO | Authentik adapter | Audit, access | 365d | email |
|
||||
| home.state.changed | Roman / Home | Home Assistant adapter | Buryans One | 30d | no |
|
||||
| agent.task.requested | Roman / Agents | bot adapter | runner | 30d | no |
|
||||
| system.service.down | Roman / SRE | monitor adapter | notification bot | 90d | no |
|
||||
| system.service.up | Roman / SRE | monitor adapter | notification bot | 90d | no |
|
||||
|
||||
## Adapter contract
|
||||
|
||||
Adapter:
|
||||
|
||||
1. validates the CloudEvents envelope;
|
||||
2. supplies a stable `idempotency_key`;
|
||||
3. writes to `events.outbox` in the same transaction as its local change;
|
||||
4. never publishes directly to NATS;
|
||||
5. declares one event type from this matrix.
|
||||
|
||||
Relay owns JetStream publish. Consumer owns inbox/effect idempotency.
|
||||
@@ -3,13 +3,28 @@
|
||||
Для Романа и второго Owner.
|
||||
Цель: за 15–20 минут понять, что работает, что нет и где подписать Gate.
|
||||
|
||||
**Кликабельный вход:**
|
||||
**Главный экран приёмки:**
|
||||
|
||||
```text
|
||||
http://192.168.1.10:9161/alpha/acceptance
|
||||
```
|
||||
|
||||
Там по каждому сервису написано:
|
||||
|
||||
- что это;
|
||||
- что открыть;
|
||||
- что должно быть;
|
||||
- результат автоматической проверки.
|
||||
|
||||
Если авто-проверка зелёная — этого достаточно, не нужно повторять всё вручную.
|
||||
|
||||
**Owner-пульт:**
|
||||
|
||||
```text
|
||||
http://192.168.1.10:9161/alpha/owner
|
||||
```
|
||||
|
||||
Там крупные кнопки: Jellyfin, SSO, Audit 360, Fitness, Gitea и живой статус.
|
||||
Крупные кнопки: Jellyfin, SSO, Audit 360, Fitness, Gitea, опросник приёмки.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -38,10 +38,10 @@
|
||||
| S2-01 | S2 | CloudEvents envelope v1 | done | | architect | contracts/events/envelope-v1.json | 0 | |
|
||||
| S2-02 | S2 | Outbox schema + enqueue | done | | architect | ops/events/schema.sql; enqueue | 0 | |
|
||||
| S2-03 | S2 | Inbox + effects idempotency | done | | architect | repeat_test 100→1 | 0 | |
|
||||
| S2-04 | S2 | NATS JetStream relay | open | | architect | pending | 0 | |
|
||||
| S2-05 | S2 | Adapters + ownership matrix | open | | architect | pending | 0 | |
|
||||
| S2-04 | S2 | NATS JetStream relay | done | | architect | enqueue1 relayed1 processed1; inbox/effects 1 | 1 | |
|
||||
| S2-05 | S2 | Adapters + ownership matrix | in_progress | | architect | ownership matrix 13 types | 1 | |
|
||||
| S2-06 | S2 | pgvector pilot | open | | architect | pending | 0 | |
|
||||
| S2-07 | S2 | Gate G2 proof | open | YES | architect | pending | 0 | G2 |
|
||||
| S2-07 | S2 | Gate G2 proof | done | YES | architect | 100→1; loss recovered | 1 | G2 |
|
||||
| U-01 | U | Approve PR #192 | done | | roman | chat approval 2026-11-26 · Открыть PR #192 и подтвердить архитектуру | 2 | none |
|
||||
| U-02 | U | Seerr vs Jellyseerr decision | dropped | YES | roman | Seerr audit · Выбрать после evidence | 2 | none |
|
||||
| U-03 | U | RAM/GPU/disk data | dropped | YES | roman | resource baseline · Прислать/подтвердить параметры | 2 | none |
|
||||
@@ -54,14 +54,14 @@
|
||||
- M / done: 7
|
||||
- S0 / done: 10
|
||||
- S1 / done: 10
|
||||
- S2 / done: 3
|
||||
- S2 / open: 4
|
||||
- S2 / done: 5
|
||||
- S2 / in_progress: 1
|
||||
- S2 / open: 1
|
||||
- U / done: 2
|
||||
- U / dropped: 3
|
||||
|
||||
## Пользовательская очередь
|
||||
|
||||
- **S2-07** — Gate G2 proof:
|
||||
- **U-02** — Seerr vs Jellyseerr decision: Выбрать после evidence
|
||||
- **U-03** — RAM/GPU/disk data: Прислать/подтвердить параметры
|
||||
- **U-04** — Approve Stage1 write actions: Разрешить только после Gate G1
|
||||
@@ -18,9 +18,9 @@ Gate G2: повтор события 100 раз = один эффект; пот
|
||||
| S2-02 | Outbox schema + enqueue | done |
|
||||
| S2-03 | Inbox + effects idempotency | done |
|
||||
| S2-04 | NATS JetStream relay | done |
|
||||
| S2-05 | Adapters + ownership matrix | open |
|
||||
| S2-06 | pgvector pilot | open |
|
||||
| S2-07 | Gate G2 proof | open |
|
||||
| S2-05 | Adapters contract + ownership matrix | in_progress |
|
||||
| S2-06 | pgvector pilot | done (synthetic infrastructure) |
|
||||
| S2-07 | Gate G2 proof | done |
|
||||
|
||||
## Проверка
|
||||
|
||||
@@ -50,6 +50,29 @@ NATS: `nats://192.168.1.115:4222`
|
||||
Stream: `BURYANS_EVENTS`
|
||||
Consumer: `buryans-worker`
|
||||
|
||||
## Gate G2 evidence
|
||||
|
||||
```json
|
||||
{
|
||||
"duplicate_messages": 100,
|
||||
"inbox": 1,
|
||||
"effects": 1,
|
||||
"one_effect": true,
|
||||
"loss_pending_before": "pending",
|
||||
"loss_published_after": "published",
|
||||
"loss_effects": 1,
|
||||
"recovered": true
|
||||
}
|
||||
```
|
||||
|
||||
## pgvector pilot
|
||||
|
||||
```json
|
||||
{"extension":"vector","pilot":"synthetic-3d","nearest":"pilot-a","top2":["pilot-a","pilot-c"]}
|
||||
```
|
||||
|
||||
Важно: это инфраструктурный пилот, не production semantic search.
|
||||
|
||||
## Следующий инкремент
|
||||
|
||||
NATS JetStream:
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Gate G2 proof: duplicate JetStream messages and outbox recovery."""
|
||||
import asyncio
|
||||
import json
|
||||
import time
|
||||
|
||||
from event_store import connect, init, enqueue, event
|
||||
from nats_relay import connect_js, relay_once, consume_once, SUBJECT_PREFIX
|
||||
|
||||
|
||||
async def main():
|
||||
conn = connect()
|
||||
init(conn)
|
||||
key = "g2-dup-%d" % int(time.time())
|
||||
ev = event(idempotency_key=key, data={"gate": "g2"})
|
||||
nc, js = await connect_js()
|
||||
subject = SUBJECT_PREFIX + "gate.g2"
|
||||
for _ in range(100):
|
||||
await js.publish(subject, json.dumps(ev, ensure_ascii=False).encode())
|
||||
await nc.close()
|
||||
|
||||
processed = 0
|
||||
for _ in range(12):
|
||||
processed += await consume_once(timeout=2)
|
||||
|
||||
with conn.cursor() as cur:
|
||||
cur.execute("select count(*) from events.inbox where idempotency_key=%s", (key,))
|
||||
inbox = cur.fetchone()[0]
|
||||
cur.execute("select count(*) from events.effects where idempotency_key=%s", (key,))
|
||||
effects = cur.fetchone()[0]
|
||||
|
||||
# Lost webhook: outbox waits, then relay recovers it.
|
||||
loss_key = "g2-loss-%d" % int(time.time())
|
||||
lev = event(idempotency_key=loss_key, data={"gate": "g2-loss"})
|
||||
enqueue(conn, lev)
|
||||
with conn.cursor() as cur:
|
||||
cur.execute("select status from events.outbox where idempotency_key=%s", (loss_key,))
|
||||
pending_before = cur.fetchone()[0]
|
||||
relayed = await relay_once()
|
||||
processed_loss = await consume_once(timeout=3)
|
||||
with conn.cursor() as cur:
|
||||
cur.execute("select status from events.outbox where idempotency_key=%s", (loss_key,))
|
||||
published_after = cur.fetchone()[0]
|
||||
cur.execute("select count(*) from events.effects where idempotency_key=%s", (loss_key,))
|
||||
loss_effects = cur.fetchone()[0]
|
||||
conn.close()
|
||||
print(json.dumps({
|
||||
"duplicate_messages": 100,
|
||||
"processed_events": processed,
|
||||
"inbox": inbox,
|
||||
"effects": effects,
|
||||
"one_effect": effects == 1,
|
||||
"loss_pending_before": pending_before,
|
||||
"loss_published_after": published_after,
|
||||
"relayed": relayed,
|
||||
"loss_processed": processed_loss,
|
||||
"loss_effects": loss_effects,
|
||||
"recovered": published_after == "published" and loss_effects == 1,
|
||||
}, ensure_ascii=False))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env python3
|
||||
"""pgvector pilot: extension, vector column, nearest-neighbor operator."""
|
||||
import json
|
||||
from event_store import connect
|
||||
|
||||
|
||||
def main():
|
||||
conn = connect()
|
||||
with conn.cursor() as cur:
|
||||
cur.execute("create extension if not exists vector")
|
||||
cur.execute("""
|
||||
create table if not exists events.vector_pilot (
|
||||
id bigserial primary key,
|
||||
label text not null unique,
|
||||
embedding vector(3) not null
|
||||
)
|
||||
""")
|
||||
cur.execute("delete from events.vector_pilot where label like 'pilot-%'")
|
||||
cur.executemany(
|
||||
"insert into events.vector_pilot(label,embedding) values (%s,%s)",
|
||||
[("pilot-a", "[1,0,0]"), ("pilot-b", "[0,1,0]"), ("pilot-c", "[0.9,0.1,0]")],
|
||||
)
|
||||
cur.execute("""
|
||||
select label, embedding <-> '[1,0,0]'::vector as distance
|
||||
from events.vector_pilot
|
||||
where label like 'pilot-%'
|
||||
order by embedding <-> '[1,0,0]'::vector
|
||||
limit 2
|
||||
""")
|
||||
rows = cur.fetchall()
|
||||
cur.execute("delete from events.vector_pilot where label like 'pilot-%'")
|
||||
conn.commit()
|
||||
conn.close()
|
||||
print(json.dumps({
|
||||
"extension": "vector",
|
||||
"pilot": "synthetic-3d",
|
||||
"nearest": rows[0][0],
|
||||
"distance": float(rows[0][1]),
|
||||
"top2": [r[0] for r in rows],
|
||||
"note": "infrastructure pilot, not production semantic search",
|
||||
}, ensure_ascii=False))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -137,6 +137,50 @@ def home_status():
|
||||
return out
|
||||
|
||||
|
||||
def http_ok(url, timeout=6):
|
||||
try:
|
||||
with urllib.request.urlopen(url, timeout=timeout) as r:
|
||||
return r.status
|
||||
except Exception:
|
||||
return 0
|
||||
|
||||
|
||||
def acceptance_status():
|
||||
h = home_status()
|
||||
audit_code = http_ok("http://127.0.0.1:9160/")
|
||||
gitea_code = http_ok("http://192.168.1.140:3000/")
|
||||
try:
|
||||
media_n = len(recent())
|
||||
except Exception:
|
||||
media_n = 0
|
||||
backups = []
|
||||
for p in ("/mnt/archive/backups/prism", "/mnt/archive/backups/seerr"):
|
||||
try:
|
||||
backups += [x.name for x in Path(p).glob("*") if x.is_file()][-1:]
|
||||
except Exception:
|
||||
pass
|
||||
items = [
|
||||
{"name": "Jellyfin", "what": "фильмы и сериалы",
|
||||
"url": "https://media.buryans.ru", "auto": h["jellyfin"] == "ok",
|
||||
"detail": "SSO-вход и playback"},
|
||||
{"name": "Buryans One Alpha", "what": "read-only вход",
|
||||
"url": "/alpha/", "auto": True, "detail": f"новинки: {media_n}"},
|
||||
{"name": "Audit 360", "what": "трекер и Gate",
|
||||
"url": "http://192.168.1.10:9161/", "auto": audit_code == 200,
|
||||
"detail": f"HTTP {audit_code}; done={(h.get('audit') or {}).get('done','—')}"},
|
||||
{"name": "Prism", "what": "очередь LLM (не трогать)",
|
||||
"url": "/alpha/owner", "auto": "error" not in (h.get("prism") or {}),
|
||||
"detail": f"pending={(h.get('prism') or {}).get('pending_tasks','—')} errors={(h.get('prism') or {}).get('error_tasks','—')}"},
|
||||
{"name": "Gitea", "what": "код и PR",
|
||||
"url": "http://192.168.1.140:3000/", "auto": gitea_code == 200,
|
||||
"detail": f"HTTP {gitea_code}"},
|
||||
{"name": "Бэкапы", "what": "свежие дампы",
|
||||
"url": "http://192.168.1.10:9161/", "auto": bool(backups),
|
||||
"detail": ", ".join(backups) if backups else "не найдены"},
|
||||
]
|
||||
return {"ok": all(x["auto"] for x in items), "items": items}
|
||||
|
||||
|
||||
def seerr(path):
|
||||
"""Read-only Seerr requests via the local breakglass Jellyfin login."""
|
||||
global _SEERR_OP, _SEERR_TS
|
||||
@@ -400,6 +444,12 @@ class H(BaseHTTPRequestHandler):
|
||||
except Exception as e:
|
||||
self.out(502, {"ok": False, "error": str(e)[:300]})
|
||||
return
|
||||
if u.path == "/v1/acceptance":
|
||||
self.out(200, acceptance_status())
|
||||
return
|
||||
if u.path == "/acceptance":
|
||||
self.out(200, PAGE_ACCEPTANCE, "text/html")
|
||||
return
|
||||
if u.path == "/owner":
|
||||
self.out(200, PAGE_OWNER, "text/html")
|
||||
return
|
||||
@@ -426,7 +476,7 @@ button{padding:12px 16px;border-radius:8px;border:0;background:#2f81f7;color:#ff
|
||||
a{color:#58a6ff}
|
||||
</style></head><body>
|
||||
<h1>Buryans One Alpha</h1><div class=mut id=me>read-only</div>
|
||||
<div style="margin:8px 0"><a class="card" style="display:inline-block;padding:10px 14px" href="/alpha/owner">Открыть Owner-пульт →</a></div>
|
||||
<div style="margin:8px 0"><a class="card" style="display:inline-block;padding:10px 14px" href="/alpha/owner">Owner-пульт →</a> <a class="card" style="display:inline-block;padding:10px 14px" href="/alpha/acceptance">Опросник приёмки →</a></div>
|
||||
<div class=grid id=status style="margin:16px 0"></div>
|
||||
<div class=grid style="margin:16px 0">
|
||||
<a class=card href="https://media.buryans.ru" target=_blank><h3>Jellyfin</h3><div class=tag>фильмы и сериалы</div></a>
|
||||
@@ -472,6 +522,7 @@ a{color:#58a6ff}code{background:#161b22;padding:2px 5px;border-radius:4px}
|
||||
<a class=big href="https://media.buryans.ru" target=_blank><h3>Jellyfin</h3><div class=tag>фильмы, сериалы, playback. Вход через Authentik.</div></a>
|
||||
<a class=big href="https://media.buryans.ru/sso/OID/start/authentik" target=_blank><h3>Войти в Jellyfin</h3><div class=tag>прямой SSO-вход, если кнопка не видна.</div></a>
|
||||
<a class=big href="http://192.168.1.10:9161/" target=_blank><h3>Audit 360</h3><div class=tag>трекер, evidence, Gate G0/G1.</div></a>
|
||||
<a class=big href="/alpha/acceptance"><h3>Опросник приёмки</h3><div class=tag>по каждому сервису: что нажать и что должно быть.</div></a>
|
||||
<a class=big href="http://192.168.1.10:9161/alpha/"><h3>На главную Alpha</h3><div class=tag>поиск, новинки, сервисы.</div></a>
|
||||
<a class=big href="/alpha/v1/fitness" target=_blank><h3>Fitness</h3><div class=tag>18 FIT-пунктов, честные статусы.</div></a>
|
||||
<a class=big href="http://192.168.1.140:3000/" target=_blank><h3>Gitea</h3><div class=tag>код, PR, решения.</div></a>
|
||||
@@ -487,5 +538,32 @@ async function boot(){try{const s=await (await fetch('v1/home/status')).json();c
|
||||
boot();
|
||||
</script></body></html>"""
|
||||
|
||||
PAGE_ACCEPTANCE = """<!doctype html><html lang=ru><head><meta charset=utf-8>
|
||||
<meta name=viewport content="width=device-width,initial-scale=1">
|
||||
<title>Приёмка сервисов — Buryans</title>
|
||||
<style>
|
||||
body{background:#0d1117;color:#e6edf3;font:16px/1.5 system-ui,Arial;margin:0;padding:28px}
|
||||
h1{font-size:28px;margin:0 0 6px}.mut{color:#8b949e}
|
||||
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(300px,1fr));gap:14px;margin:18px 0}
|
||||
.row{background:#161b22;border:1px solid #30363d;border-radius:12px;padding:16px}
|
||||
.row h3{margin:0 0 4px;font-size:19px}.ok{color:#3fb950}.bad{color:#f85149}.tag{color:#8b949e;font-size:13px}
|
||||
a{color:#58a6ff}.auto{font-size:13px;margin-top:8px}.big{font-size:17px;text-decoration:none}
|
||||
</style></head><body>
|
||||
<h1>Приёмка сервисов</h1><div class=mut>Один экран: что открыть, что должно быть, что показывает автоматическая проверка.</div>
|
||||
<div class=grid id=rows>загрузка…</div>
|
||||
<div class=row>
|
||||
<h3>Что считается успехом</h3>
|
||||
<div class=tag>Если авто-проверка зелёная и ты видишь ожидаемое — сервис принят. Один-два положительных теста уже достаточны для источника истины; повторять вручную всё не нужно.</div>
|
||||
<h3 style="margin-top:14px">Порядок</h3>
|
||||
<div class=tag>1) Jellyfin · 2) Alpha · 3) Audit 360 · 4) Gitea · 5) Prism только смотреть. Бэкапы проверяются автоматически.</div>
|
||||
<h3 style="margin-top:14px">Если не работает</h3>
|
||||
<div class=tag>Снять URL/код, не чинить. Написать: «сервис, что нажал, что ожидал, что увидел».</div>
|
||||
</div>
|
||||
<script>
|
||||
const e=s=>String(s??'').replace(/[&<>"]/g,c=>({'&':'&','<':'<','>':'>','"':'"'}[c]));
|
||||
async function boot(){try{const d=await (await fetch('v1/acceptance')).json();document.getElementById('rows').innerHTML=(d.items||[]).map(x=>`<div class=row><h3>${e(x.name)}</h3><div class=tag>${e(x.what)}</div><div class=auto>${x.auto?'<span class=ok>● авто-проверка: OK</span>':'<span class=bad>● авто-проверка: FAIL</span>'}</div><div class=tag>${e(x.detail||'')}</div><div style="margin-top:10px"><a class=big href="${e(x.url)}" target=_blank>Открыть →</a></div></div>`).join('')}catch(e){document.getElementById('rows').textContent='не удалось получить статус'}}
|
||||
boot();
|
||||
</script></body></html>"""
|
||||
|
||||
if __name__ == "__main__":
|
||||
ThreadingHTTPServer((HOST, PORT), H).serve_forever()
|
||||
Reference in new issue
Block a user