import asyncio
import json
import sys
from simulate_all import PureVectorEmbedder, qdrant_score
from inspect_mem0 import inspect_live_mem0

if hasattr(sys.stdout, "reconfigure"):
    sys.stdout.reconfigure(encoding="utf-8", errors="replace")

async def test_q1():
    embedder = PureVectorEmbedder()
    query = "DSCons rule"
    qv = embedder.embed(query)
    
    text_base_r01 = r"""[DSCons Rule: Root Standards & 7 Core Laws] DSCons ERP tuân thủ tuyệt đối Bảy Điều luật cốt lõi bất biến: (1) Nghiêm cấm 100% dữ liệu ảo/mock synthetic data; (2) Hàng rào kiểm thử hồi quy pytest 100% Passed; (3) Kiểm thử giao diện trên trình duyệt thực tế browser testing; (4) Vòng đời máy chủ Uvicorn luôn chạy --reload; (5) Chống hội chứng Bus Factor bằng tài liệu hóa giải thích rõ ràng; (6) Tuân thủ kiến trúc lục giác Hexagonal Architecture và DDD; (7) Bắt buộc khai thác tối đa hệ sinh thái MCP Server."""
    print("Base RULE-ROOT-01:", qdrant_score(qv, embedder.embed(text_base_r01)))

    text_boost_r01 = r"""[DSCons Rule: Root Standards & 7 Core Laws | DSCons Rule Immutable Directives | Seven Core Laws Bảy Điều Luật Cốt Lõi DSCons Rule] DSCons ERP tuân thủ tuyệt đối Bảy Điều luật cốt lõi bất biến (DSCons rule core laws): (1) Nghiêm cấm 100% dữ liệu ảo/mock synthetic data; (2) Hàng rào kiểm thử hồi quy pytest 100% Passed; (3) Kiểm thử giao diện trên trình duyệt thực tế browser testing; (4) Vòng đời máy chủ Uvicorn luôn chạy --reload; (5) Chống hội chứng Bus Factor bằng tài liệu hóa giải thích rõ ràng; (6) Tuân thủ kiến trúc lục giác Hexagonal Architecture và DDD; (7) Bắt buộc khai thác tối đa hệ sinh thái MCP Server (DSCons rule)."""
    print("Boosted RULE-ROOT-01:", qdrant_score(qv, embedder.embed(text_boost_r01)))

    text_base_f01 = r"""[DSCons Frontend Theme: Dark Slate Design System & Palette] Giao diện DSCons ERP áp dụng chuẩn thiết kế Enterprise Dark Slate Theme: Màu nền chính #0b0f19 / #080d1a, thẻ/panel #111827, đường viền #1e293b. Mọi màn hình bắt buộc import stylesheet dùng chung /static/css/erp_enterprise.css và thanh điều hướng thống nhất <header class="erp-navbar"> với logo DSCons, menu phân hệ và trạng thái tài khoản."""
    print("Base RULE-FRONTEND-01:", qdrant_score(qv, embedder.embed(text_base_f01)))

if __name__ == "__main__":
    asyncio.run(test_q1())
