From 457f95d3b13ebaa1f1b04cd5df8f41e390c1e16b Mon Sep 17 00:00:00 2001 From: architect Date: Fri, 27 Nov 2026 21:08:39 +0300 Subject: [PATCH] [STAGE5] Model Registry v0 + health --- docs/architecture/REGISTRY/models.yaml | 21 ++++++++++++ docs/architecture/STAGE-5.md | 35 ++++++++++++++++++++ ops/media-alpha/media_alpha.py | 45 +++++++++++++++++++++++++- 3 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 docs/architecture/REGISTRY/models.yaml create mode 100644 docs/architecture/STAGE-5.md diff --git a/docs/architecture/REGISTRY/models.yaml b/docs/architecture/REGISTRY/models.yaml new file mode 100644 index 0000000..61cc9a4 --- /dev/null +++ b/docs/architecture/REGISTRY/models.yaml @@ -0,0 +1,21 @@ +version: 1 +source: "stage5 model registry v0" +models: + - id: deepseek-chat + provider: deepseek + role: primary-reasoning + endpoint: "https://api.deepseek.com" + health: external + note: "ключ только на сервере" + - id: qwen2.5:3b + provider: ollama-pc + role: local-fast + endpoint: "http://192.168.1.194:11434" + health: ollama + note: "ПК, модель может быть выгружена" + - id: qwen2.5:3b + provider: ollama-host + role: local-fallback + endpoint: "http://192.168.1.10:11434" + health: ollama + note: "host fallback" diff --git a/docs/architecture/STAGE-5.md b/docs/architecture/STAGE-5.md new file mode 100644 index 0000000..0dc7042 --- /dev/null +++ b/docs/architecture/STAGE-5.md @@ -0,0 +1,35 @@ +# Stage 5 — AI Factory & Agents + +Статус: начат 2026-11-27. +Gate G5: агент не имеет production-доступа вне Tool Gateway. + +## Сделано + +Model Registry v0: + +```text +http://192.168.1.10:9161/alpha/models +GET /v1/models +``` + +- реестр моделей/провайдеров; +- external/Ollama health; +- PC-Ollama offline показывается как down; +- без выдачи агентам production-доступа. + +## Задачи + +| Код | Задача | Статус | +|---|---|---| +| S5-01 | Model Registry v0 | done | +| S5-02 | GPU leases | open | +| S5-03 | Evals / golden set | open | +| S5-04 | Memory | open | +| S5-05 | Night Shift | open | +| S5-06 | Tool Gateway / agent approvals | open | +| S5-07 | Gate G5 | open | + +## Ограничение + +- GPU leases, evals, memory, Tool Gateway — ещё не реализованы. +- Model Registry read-only, не выдаёт доступ к моделям. diff --git a/ops/media-alpha/media_alpha.py b/ops/media-alpha/media_alpha.py index dce81c5..d1c355f 100644 --- a/ops/media-alpha/media_alpha.py +++ b/ops/media-alpha/media_alpha.py @@ -236,6 +236,7 @@ def acceptance_status(): SERVICES_PATH = Path("/root/buryan-infra/docs/architecture/REGISTRY/services.yaml") +MODELS_PATH = Path("/root/buryan-infra/docs/architecture/REGISTRY/models.yaml") def service_health(svc): @@ -279,6 +280,29 @@ def mission_services(): "down": sum(1 for x in rows if x["up"] is False), "items": rows} +def model_health(m): + if m.get("health") == "external": + return {"up": None, "loaded": None, "error": "external provider"} + endpoint = (m.get("endpoint") or "").rstrip("/") + try: + with urllib.request.urlopen(endpoint + "/api/tags", timeout=3) as r: + body = json.loads(r.read().decode("utf-8", "replace")) + names = [x.get("name") for x in body.get("models") or []] + return {"up": True, "loaded": m.get("id") in names, "models": names[:10]} + except Exception as e: + return {"up": False, "loaded": None, "error": str(e)[:120]} + + +def model_registry(): + import yaml + data = yaml.safe_load(MODELS_PATH.read_text()) + rows = [] + for m in data.get("models") or []: + h = model_health(m) + rows.append({**{k: m.get(k) for k in ("id", "provider", "role", "endpoint", "health", "note")}, **h}) + return {"ok": all(x.get("up") is not False for x in rows), "total": len(rows), "items": rows} + + def request_check(q): qn = (q or "").strip().lower() if not qn: @@ -587,6 +611,15 @@ class H(BaseHTTPRequestHandler): if u.path == "/mission": self.out(200, PAGE_MISSION, "text/html") return + if u.path == "/v1/models": + try: + self.out(200, model_registry()) + except Exception as e: + self.out(502, {"ok": False, "error": str(e)[:300]}) + return + if u.path == "/models": + self.out(200, PAGE_MODELS, "text/html") + return if u.path == "/request": self.out(200, PAGE_REQUEST, "text/html") return @@ -731,6 +764,16 @@ 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_MODELS = """ +Models — Buryans + +

Model Registry

Read-only реестр моделей и health. Агенты не получают production-доступ через эту страницу. · Mission Control →
+
загрузка…
+""" + PAGE_MISSION = """ Mission Control — Buryans @@ -743,7 +786,7 @@ h1{font-size:28px;margin:0 0 6px}.mut{color:#8b949e} .ok{color:#3fb950}.bad{color:#f85149}.unk{color:#d29922} a{color:#58a6ff} -

Mission Control

Read-only карта сервисов. Health, tier, owner, endpoints. Без изменения сервисов.
+

Mission Control

Read-only карта сервисов. Health, tier, owner, endpoints. Без изменения сервисов. · Models →
загрузка…