diff --git a/docs/architecture/ARCHITECTURE-AUDIT-20261129.md b/docs/architecture/ARCHITECTURE-AUDIT-20261129.md index 29b557b..b6d7d4c 100644 --- a/docs/architecture/ARCHITECTURE-AUDIT-20261129.md +++ b/docs/architecture/ARCHITECTURE-AUDIT-20261129.md @@ -458,20 +458,25 @@ HA после RAM, не раньше. ```text 371 моделей -299 active -36 datasheets +258 product +101 support_article rejected +9 final → 44 draft_ready 2596 specs 4608 evidence ``` -Текущая очередь: +Причина низкого final: ```text -errors 0 -pending 20 -running 2 +96 product без sources/specs +40 sources, но 0 specs +51 ready для audit ``` +Note-audit worker переключён с недоступного qwen2.5:7b на qwen2.5:3b. +35 карточек добавлены как `draft_ready` (не production). +Очередь: errors 0, pending 20, running 2. + Что сделано: - 16 timeout’ов qwen возвращены в очередь; diff --git a/docs/architecture/FULL-ACTION-AUDIT-20261129.md b/docs/architecture/FULL-ACTION-AUDIT-20261129.md index 724da6d..c4af541 100644 --- a/docs/architecture/FULL-ACTION-AUDIT-20261129.md +++ b/docs/architecture/FULL-ACTION-AUDIT-20261129.md @@ -13,7 +13,7 @@ - включены compaction и tool-result-pruner в DSH; - собран полный архитектурный аудит; -- 6 ботов переведены на Tool Gateway; +- 6 ботов + Secretary intent/ask переведены на Tool Gateway; - Tool Gateway получил approvals и UID-enforcement; - Prism разобран: 30 ошибок → 0 (с оговоркой, что сетевые могут вернуться); - Stage 6 начат, выполнен реальный restore Audit 360 в temp DB; @@ -254,17 +254,28 @@ pending 0 errors 0 (на момент среза) pending 20 running 2 +final_cards 44 draft_ready ``` -Что было: +Почему было 9 финальных: -- 16 qwen timeout → requeue; -- 6 «no data» → blocked; -- 2 404/source missing → blocked; -- 6 parse/empty/timeout → retry; -- 9 сетевых повторно requeue. +```text +96 product без sources/specs +40 sources, но 0 specs +51 specs>=5/notes>=3, но 0 audits +note-audit worker ходил в qwen2.5:7b → No route to host +``` -Ошибки могут вернуться: Prism зависит от 229/ПК/сети. +Исправлено: + +- note-audit worker переключён на qwen2.5:3b + deepseek fallback; +- 20 note_audit-задач поставлено; +- 35 draft_ready карточек добавлены из реальных specs/notes/audit; +- 101 rejected — это support_article, не product; +- 110 — rerun_plan.excluded. + +Ошибки могут вернуться: Prism зависит от 229/ПК/сети. +`draft_ready` — не публикация, а очередь на ревью. --- diff --git a/docs/architecture/PRISM-AUDIT-20261129.md b/docs/architecture/PRISM-AUDIT-20261129.md new file mode 100644 index 0000000..f813f7b --- /dev/null +++ b/docs/architecture/PRISM-AUDIT-20261129.md @@ -0,0 +1,72 @@ +# Prism audit — 2026-11-29 22:20 MSK + +## До + +```text +pending: 0 +running: 0 +errors: 30 +``` + +Категории ошибок: + +| Причина | Кол-во | Действие | +|---|---:|---| +| qwen connection timed out | 16 | requeue после загрузки ПК | +| no source/specs/matrix data | 6 | не requeue: нет данных | +| Unterminated JSON | 4 | нужен разбор парсера | +| HTTP 404 | 1 | проверить источник | +| empty text | 1 | проверить | +| read timeout | 1 | проверить | +| source missing | 1 | проверить | + +## После + +```text +qwen2.5:3b загружен на ПК (2.1 GB VRAM) +requeued: 16 + 9 повторно (сетевые) +pending: 20 +running: 2 +errors: 0 (на момент проверки) +``` + +- 6 «no data» → `blocked`; +- 4 JSON + 1 empty + 1 read timeout → retry; +- 1 HTTP 404 + 1 source missing → `blocked`; +- 9 сетевых (qwen timeout/Bad Gateway/TLS) повторно requeued после загрузки ПК. + +Ошибки могут вернуться: Prism зависит от 229/ПК/сети. Это не «навсегда 0». + +## Root cause 9 финальных / 101 rejected + +Проверено по БД: + +```text +258 product + 96 без sources и specs + 40 sources есть, specs 0 + 51 specs>=5, notes>=3, audits=0 + 49 audited +``` + +- 101 rejected — это `support_article`, не product; +- 110 — `rerun_plan.excluded`; +- 9 final — строгий gate: specs>=5 + notes>=3 + audit ok. + +Note-audit worker ходил в `qwen2.5:7b` и получал `No route to host`. +Переключён на `qwen2.5:3b` (+deepseek fallback). +Поставлено 20 note_audit-задач; проходят. + +После аудита созданы **draft_ready** карточки из реальных specs/notes/audit: + +```text +final_cards: 9 → 44 draft_ready +добавлено: 35 +``` + +Это не production-публикация: состояние `draft_ready`, карточки на ревью. + + +## Ограничение + +Prism worker работает асинхронно; финальные цифры смотреть после завершения running. diff --git a/ops/scripts/prism_finalize_drafts.sql b/ops/scripts/prism_finalize_drafts.sql new file mode 100644 index 0000000..d5ac5ee --- /dev/null +++ b/ops/scripts/prism_finalize_drafts.sql @@ -0,0 +1,22 @@ +-- Prism: rebuild draft final cards from audited models. +-- Only quality_status=product, specs>=5, notes>=3, latest note_audit.ok=true. +-- State is draft_ready: nothing is auto-published. +begin; +insert into prism.final_cards(model_id,state,card,prepared_at) +select m.id,'draft_ready', +jsonb_build_object( + 'name',m.name,'vendor',m.vendor,'role',m.role,'domain',m.domain, + 'specs',coalesce((select jsonb_agg(jsonb_build_object('key',sp.key,'value',sp.value_text,'unit',sp.unit) order by sp.key) + from prism.specs sp where sp.model_id=m.id),'[]'::jsonb), + 'notes',coalesce((select jsonb_agg(jsonb_build_object('kind',n.kind,'text',n.text) order by n.kind) + from prism.model_notes n where n.model_id=m.id),'[]'::jsonb), + 'audit',coalesce((select jsonb_build_object('ok',a.ok,'issues',a.issues) from prism.note_audits a + where a.model_id=m.id order by a.id desc limit 1),'{"ok":false,"issues":[]}'::jsonb) +),now() +from prism.models m +where m.quality_status='product' +and (select count(*) from prism.specs sp where sp.model_id=m.id)>=5 +and (select count(*) from prism.model_notes n where n.model_id=m.id)>=3 +and (select a.ok from prism.note_audits a where a.model_id=m.id order by a.id desc limit 1) is true +and not exists (select 1 from prism.final_cards f where f.model_id=m.id); +commit; diff --git a/ops/scripts/prism_note_audit_worker.py b/ops/scripts/prism_note_audit_worker.py index a4667b7..a8296e2 100644 --- a/ops/scripts/prism_note_audit_worker.py +++ b/ops/scripts/prism_note_audit_worker.py @@ -49,17 +49,18 @@ while True: {specs[:1500]} """ r = L.ask(prompt, max_tokens=350, temperature=0.0, - chain=[{"name": "qwen2.5:7b", "kind": "ollama", "timeout": 300}]) + chain=[{"name": "qwen2.5:3b", "kind": "ollama", "timeout": 300}, + {"name": "deepseek-flash", "kind": "deepseek", "timeout": 120}]) mm = re.search(r"\{.*\}", r["text"], re.S) d = json.loads(mm.group(0)) if mm else {} good = bool(d.get("ok")) issues = d.get("issues") or [] cur.execute("""insert into prism.note_audits(model_id,ok,issues,model) - values (%s,%s,%s::jsonb,'qwen2.5:7b')""", + values (%s,%s,%s::jsonb,'qwen2.5:3b')""", (mid, good, json.dumps(issues, ensure_ascii=False))) cur.execute("""insert into prism.runs(model_id,kind,status,worker,model,stats,started_at,finished_at) values (%s,'note_audit7b','ok','229',%s,%s,now(),now())""", - (mid, "qwen2.5:7b", json.dumps({"issues": len(issues), "ok": good}))) + (mid, "qwen2.5:3b", json.dumps({"issues": len(issues), "ok": good}))) cur.execute("update prism.tasks set status='done', finished_at=now() where id=%s", (task_id,)) print("done", task_id, "ok", good, "issues", len(issues), flush=True) except Exception as e: @@ -67,7 +68,7 @@ while True: (str(e)[:300], task_id)) cur.execute("""insert into prism.runs(model_id,kind,status,worker,model,error,started_at,finished_at) values (%s,'note_audit7b','error','229',%s,%s,now(),now())""", - (mid, "qwen2.5:7b", str(e)[:300])) + (mid, "qwen2.5:3b", str(e)[:300])) print("error", task_id, str(e)[:150], flush=True) conn.commit() time.sleep(1)