diff --git a/docs/architecture/STAGE-4.md b/docs/architecture/STAGE-4.md new file mode 100644 index 0000000..48cd490 --- /dev/null +++ b/docs/architecture/STAGE-4.md @@ -0,0 +1,33 @@ +# Stage 4 — Mission Control & SDK + +Статус: начат 2026-11-27. +Gate G4: новый адаптер без изменения ядра. + +## Сделано + +Mission Control v0: + +```text +http://192.168.1.10:9161/alpha/mission +``` + +- read-only карта сервисов; +- tier/owner; +- health; +- endpoints; +- API `/v1/services`. + +## Задачи + +| Код | Задача | Статус | +|---|---|---| +| S4-01 | Mission Control v0 | done | +| S4-02 | Extension SDK / adapter contract | open | +| S4-03 | 3 adapters | open | +| S4-04 | Preview env + contract tests | open | +| S4-05 | Gate G4 | open | + +## Ограничение + +Mission Control пока внутри Alpha, не отдельный Nexus. +Это v0: read-only, без управления процессами. diff --git a/ops/media-alpha/media_alpha.py b/ops/media-alpha/media_alpha.py index 9d7ffe9..dce81c5 100644 --- a/ops/media-alpha/media_alpha.py +++ b/ops/media-alpha/media_alpha.py @@ -3,6 +3,7 @@ import html import http.cookiejar import json +import socket import time import urllib.error import urllib.parse @@ -234,6 +235,50 @@ def acceptance_status(): return {"ok": all(x["auto"] for x in items), "items": items} +SERVICES_PATH = Path("/root/buryan-infra/docs/architecture/REGISTRY/services.yaml") + + +def service_health(svc): + endpoint = (svc.get("endpoint") or "").strip() + started = time.time() + try: + if endpoint.startswith("http"): + try: + with urllib.request.urlopen(endpoint, timeout=4) as r: + code = r.status + except urllib.error.HTTPError as e: + code = e.code + up = code < 400 + return {"up": up, "code": code, "ms": int((time.time() - started) * 1000)} + if endpoint.startswith(("tcp://", "nats://")): + u = urllib.parse.urlsplit(endpoint) + host, port = u.hostname, u.port or 0 + with socket.create_connection((host, port), timeout=3): + pass + return {"up": True, "code": None, "ms": int((time.time() - started) * 1000)} + return {"up": None, "code": None, "ms": None, "error": "no endpoint"} + except Exception as e: + return {"up": False, "code": None, "ms": int((time.time() - started) * 1000), + "error": str(e)[:120]} + + +def mission_services(): + import yaml + data = yaml.safe_load(SERVICES_PATH.read_text()) + rows = [] + for s in data.get("services") or []: + h = service_health(s) + rows.append({ + "id": s.get("id"), "tier": s.get("tier"), "owner": s.get("owner"), + "endpoint": s.get("endpoint"), "public": s.get("public"), + "health": s.get("health"), "up": h.get("up"), "code": h.get("code"), + "ms": h.get("ms"), "error": h.get("error"), + }) + return {"ok": all(x["up"] is not False for x in rows), + "total": len(rows), "up": sum(1 for x in rows if x["up"] is True), + "down": sum(1 for x in rows if x["up"] is False), "items": rows} + + def request_check(q): qn = (q or "").strip().lower() if not qn: @@ -533,6 +578,15 @@ class H(BaseHTTPRequestHandler): if u.path == "/acceptance": self.out(200, PAGE_ACCEPTANCE, "text/html") return + if u.path == "/v1/services": + try: + self.out(200, mission_services()) + except Exception as e: + self.out(502, {"ok": False, "error": str(e)[:300]}) + return + if u.path == "/mission": + self.out(200, PAGE_MISSION, "text/html") + return if u.path == "/request": self.out(200, PAGE_REQUEST, "text/html") return @@ -562,7 +616,7 @@ button{padding:12px 16px;border-radius:8px;border:0;background:#2f81f7;color:#ff a{color:#58a6ff}

Buryans One Alpha

read-only
-
Owner-пульт → Опросник приёмки → Запросить фильм →
+
Owner-пульт → Опросник приёмки → Запросить фильм → Mission Control →

Jellyfin

фильмы и сериалы
@@ -611,6 +665,7 @@ a{color:#58a6ff}code{background:#161b22;padding:2px 5px;border-radius:4px}

Audit 360

трекер, evidence, Gate G0/G1.

Опросник приёмки

по каждому сервису: что нажать и что должно быть.

Запросить фильм

поиск по Jellyfin и кнопка запроса в Seerr.
+

Mission Control

карта сервисов, health, owners, ссылки.

На главную Alpha

поиск, новинки, сервисы.

Fitness

18 FIT-пунктов, честные статусы.

Gitea

код, PR, решения.
@@ -676,5 +731,26 @@ async function go(){const q=document.getElementById('q').value.trim();if(!q)retu document.getElementById('q').addEventListener('keydown',e=>{if(e.key==='Enter')go()}); """ +PAGE_MISSION = """ + +Mission Control — Buryans + +

Mission Control

Read-only карта сервисов. Health, tier, owner, endpoints. Без изменения сервисов.
+
загрузка…
+
+""" + if __name__ == "__main__": ThreadingHTTPServer((HOST, PORT), H).serve_forever()