diff --git a/ops/work/web/combine_core.py b/ops/work/web/combine_core.py index 4ebeaf8..c521ed2 100644 --- a/ops/work/web/combine_core.py +++ b/ops/work/web/combine_core.py @@ -274,6 +274,83 @@ class Core: d = self.POSITIONS_ROLE.get(role, {"in": ["LAN"], "out": ["—"]}) return list(d["in"]), list(d["out"]) or ["—"], "role" + # ── прослеживаемость данных (как lineage в data-платформах) ── + def lineage(self, name): + """По каждому атрибуту: значение, источник, файл, свежесть.""" + import os + import time + k = norm(name) + out = [] + sources = [ + ("manual", "overrides.yaml", "ручной ввод"), + ("verified", "interfaces_verified.yaml", "выверено по даташиту"), + ("values", "values.yaml", "извлечено из даташита"), + ("extra", "specs_extra.yaml", "доп. даташит"), + ("llm", "specs_extract.yaml", "извлечено LLM"), + ] + for kind, fname, label in sources: + p = os.path.join(BASE, fname) + try: + age_h = round((time.time() - os.path.getmtime(p)) / 3600, 1) + except OSError: + continue + out.append({"source": kind, "file": fname, "label": label, + "file_age_hours": age_h}) + attrs = self.attrs.get(k, {}) + rows = [] + for attr, val in sorted(attrs.items()): + src = "values" + if (getattr(self, "manual", {}) or {}).get(k, {}).get(attr) is not None: + src = "manual" + elif (getattr(self, "iface_map", {}) or {}).get(k) and attr.startswith(("ports.", "network.")): + src = "verified" + rows.append({"attr": attr, "value": val, "source": src, + "verified": src in ("manual", "verified")}) + verified_count = sum(1 for r in rows if r["verified"]) + return {"device": self.devices.get(k, {}).get("name") or name, + "attributes": rows, "total": len(rows), + "verified": verified_count, + "trust_pct": round(100.0 * verified_count / max(len(rows), 1), 1), + "files": out, + "package": self.package(name), + "completeness": self.completeness(k)} + + # ── единый список проблем (clash detection) ── + def issues(self, host_key, items, infra=None): + hk = norm(host_key) + host = self.devices.get(hk, {}).get("name") or host_key + out = [] + cap = self.capacity(hk, items, infra or []) + for i in cap["issues"]: + out.append({"level": "blocker", "kind": "capacity", "text": i}) + if cap["missing_power"]: + out.append({"level": "warning", "kind": "data", + "text": "нет данных о питании: " + ", ".join(cap["missing_power"][:6])}) + sig = self.signal_chains(hk, items) + for r in sig["chains"]: + if not r["ok"]: + out.append({"level": "blocker", "kind": "signal", + "text": "%s: %s" % (r["device"], r["reason"])}) + plan = self.port_plan(hk, items) + if plan["unresolved"]: + out.append({"level": "blocker", "kind": "port", + "text": "нет порта для: " + ", ".join(plan["unresolved"])}) + comp = self.completeness(hk) + if comp["level"] != "full": + out.append({"level": "warning", "kind": "data", + "text": "неполные данные: " + comp["note"]}) + for row in items: + pk = self.package(row[0]) + if not pk["items"]: + out.append({"level": "info", "kind": "package", + "text": "%s: комплектация неизвестна" % row[0]}) + blockers = sum(1 for i in out if i["level"] == "blocker") + warnings = sum(1 for i in out if i["level"] == "warning") + return {"host": host, "issues": out, "blockers": blockers, + "warnings": warnings, "ready": blockers == 0, + "by_kind": {k: sum(1 for i in out if i["kind"] == k) + for k in {i["kind"] for i in out}}} + # ── ручной ввод характеристики ── ALLOWED_ATTRS = { "audio.pickup_m": "м", "audio.spl_max": "dB SPL", diff --git a/ops/work/web/index.html b/ops/work/web/index.html index 8063fd1..4cffbb9 100644 --- a/ops/work/web/index.html +++ b/ops/work/web/index.html @@ -83,6 +83,7 @@ svg{width:100%;height:520px;background:#0a0e13;border:1px solid var(--line);bord
Документы
План комнаты
Покрытие
+
Проблемы
Спросить
@@ -216,6 +217,23 @@ svg{width:100%;height:520px;background:#0a0e13;border:1px solid var(--line);bord + + + + + +