From 17c202549e959ba93468e81a5a051b63a8b294e7 Mon Sep 17 00:00:00 2001 From: LittleGuo Date: Wed, 14 Oct 2026 19:54:53 +0800 Subject: [PATCH] =?UTF-8?q?docs(memory):=20=E8=AE=B0=E5=BD=95=E5=8F=AF?= =?UTF-8?q?=E4=BF=A1=E5=BA=A6=E4=B8=89=E4=BB=B6=E5=A5=97=E8=90=BD=E5=9C=B0?= =?UTF-8?q?=E3=80=81window=20=E5=8F=82=E6=95=B0=E5=AE=9E=E6=9C=BA=E4=BA=8B?= =?UTF-8?q?=E5=AE=9E=E4=B8=8E=20CAD=20=E8=87=AA=E5=90=AF=E5=81=8F=E5=A5=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - project_review_agent_impl:三件套链路(结构化结论删除二次抽取、确定性检查前置、 handle 交叉校验)、开关与数据结构;find_zero_length/find_duplicate_entities 的 window 参数 schema 未声明但实机生效 - feedback_preferences:需要 CAD 时自己启动(自动加载已配好),不要先问用户 --- ai.memory/MEMORY.md | 2 +- ai.memory/feedback_preferences.md | 13 ++++++++++++ ai.memory/project_review_agent_impl.md | 29 +++++++++++++++++++++++++- 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/ai.memory/MEMORY.md b/ai.memory/MEMORY.md index afade36..883805e 100644 --- a/ai.memory/MEMORY.md +++ b/ai.memory/MEMORY.md @@ -6,7 +6,7 @@ - [CADProject 图纸审查 Agent 工作](project_dwg_review_agent.md) — 基于 MCP 框架的图纸审查工具集与逐图框审查流程 - [DeepSeek API Key 泄露与轮换(已处理)](project_api_key_rotation.md) — 旧 Key 曾入 git 历史;2026-10-14 已吊销并换新 Key,验证可用 -- [LLM 识图审图 Agent 架构决策](project_review_agent_impl.md) — 混合式自研 agent、基座 B 最小集、标准化先走 stdio 桥;含 dwg_review 包结构 +- [LLM 识图审图 Agent 架构决策](project_review_agent_impl.md) — 混合式自研 agent、基座 B 最小集、可信度三件套、标准化先走 stdio 桥;含 dwg_review 包结构 - [stdio↔TCP 桥(MCP 标准化)](project_stdio_bridge.md) — mcp_bridge 包:基座协议缺口、读线程+单工作线程设计、MCP Inspector 验证方法与踩坑 - [MCP 基座 c++_dll 加载与执行的坑](project_mcp_frame_dll_loader.md) — acrxGetApiVersion 有状态不可比对、写库需文档锁、同一 DLL 只加载一次 - [用户协作偏好](feedback_preferences.md) — 调试用 Debug/R230、模型 deepseek-flash、DLL 集中在 cad_mcp_plugins 等 diff --git a/ai.memory/feedback_preferences.md b/ai.memory/feedback_preferences.md index 9588ffa..5cc018b 100644 --- a/ai.memory/feedback_preferences.md +++ b/ai.memory/feedback_preferences.md @@ -22,6 +22,19 @@ type: feedback `git push origin HEAD:refs/for/main/home-ai-dev`。每次提交后自动完成推送 + 建 PR,无需再问。 注意 `home-ai-dev` 的 upstream 常显示 `[gone]`(合并后源分支被删),这不影响该推送方式。 +## CAD 没开就自己打开,别问(自动加载已配好) + +- 规则:需要 CAD 在线(慢层 `verify_*.py` / 端到端 `python -m dwg_review`)而 + `127.0.0.1:8080` 未监听时,**自己启动 CAD,不要先问用户**。 +- **Why:** 用户(2026-10-14)明确要求:「以后遇到 cad 没有运行的情况,就直接打开, + 运行你的测试就行,我已经设置好了自动加载」。自动加载确实已配好。 +- **How to apply:** PowerShell 里 + `Start-Process "C:\Program Files\Autodesk\AutoCAD 2020\acad.exe"`,再轮询 8080 + (实测约 10 秒内监听)。自动加载链路:`bin/Debug-R230/acad.rx`(内容一行 + `cad_mcp_frame.arx`)+ 该目录已在 CAD 的搜索/信任路径中。 + **注意**:CAD 默认打开的是**空模板**(0 图元、无图框),端到端审查会因 + 「未识别到任何图框」提前退出;要跑完整审查需另开一张真实图纸。 + ## 调试用 R230 + Debug,不用 Release - 规则:涉及 CAD 版本的调试**只用 R230**,且配置用 **Debug**(非 Release)。 diff --git a/ai.memory/project_review_agent_impl.md b/ai.memory/project_review_agent_impl.md index 38392bd..0036cd2 100644 --- a/ai.memory/project_review_agent_impl.md +++ b/ai.memory/project_review_agent_impl.md @@ -1,6 +1,6 @@ --- name: LLM 识图审图 Agent —— 架构决策(已定稿) -description: cad_mcp_frame + 自研 Agent 的架构决策与分阶段路线——混合式(流水线骨架+受控只读取证子循环)、基座 B 最小集、标准化路线(先 stdio 桥) +description: cad_mcp_frame + 自研 Agent 的架构决策与分阶段路线——混合式(流水线骨架+受控只读取证子循环)、基座 B 最小集、可信度三件套(确定性检查前置/结构化结论/handle 交叉校验)、标准化路线(先 stdio 桥) type: project --- @@ -48,6 +48,29 @@ type: project (构造即 `list_tools()` 触网);一律 `make_ctx()` 注入假件。 - `verify_mcp_frame.py`:基座改动验证脚本(分帧 / 大报文 / string id / 通知 / isError)。 +## 可信度三件套(2026-10-14 落地) + +根因是**「LLM 从自由文本里回忆 handle」**:原 `review_frame` 输出无格式约束的自由文本, +再用**第二次 LLM 调用**(`extract_issues`)转 JSON,handle 靠回忆 → 批注错位或丢失。 + +改后:`review_frame` 直接输出受约束 JSON `{summary, issues[]}`(**删除**二次抽取) ++ `checks.run_deterministic_checks`(确定性,handle 来自工具/数据本身) +→ `findings.build_finding`(合并 + handle 交叉校验)→ `annotator`(只批注 verified 的 handle)。 + +- **确定性检查前置**(`dwg_review/checks.py`):`find_zero_length` / `find_duplicate_entities` + (都传 `window`)+ 纯 Python 派生(空文字、未闭合多段线 `vertex_count>=3 and closed==false`)。 + 实机验证:四类全部检出。 +- **结论结构化**:`checklist.build_system_prompt` 强约束只输出 + `{summary, issues:[{category,severity,message,handle?}]}`;`review_frame` 仅在 + 「不再请求工具」的回合解析(中间工具回合的 content 永不解析);解析失败降级 + `summary=原文, issues=[]`(信息不丢,只是不进批注)。实机验证 deepseek-flash 遵守契约。 +- **证据交叉校验**(`findings.normalize_issue`):LLM 引用的 handle 不在已采集证据中时 + **保留问题、剥掉 handle、`verified=False`**(永不批注);handle 比对统一 `upper()`。 +- 开关(`config.py`,默认全开):`DETERMINISTIC_CHECKS` / `VALIDATE_HANDLES` / + `CHECK_UNCLOSED_POLYLINES`。 +- 结构:issue = `{frame,category,severity,message,handle,handles?,source,verified}`; + findings 元素 = `{frame,sheet,summary,issues[],counts{deterministic,llm,unverified}}`。 + ## 环境事实 - **Pillow 已安装**(12.3.0)。截图下采样策略(`dwg_review/llm_client.py: downsample_image_b64`): @@ -56,6 +79,10 @@ type: project 缩放后默认输出**无损 PNG**(`IMAGE_FORMAT=png`,适合线稿),需要更小体积可设 `IMAGE_FORMAT=jpeg`。 缺少 Pillow 时自动降级为原图直传。 - 视觉模型 `deepseek-flash`。 +- **`find_zero_length` / `find_duplicate_entities` 的 `window` 参数:schema 未声明,但 C++ 侧 + `parseCommonQuery` 实际支持**(2026-10-14 实机验证生效)。Python 侧直接传 `window` 即可, + 不必改 JSON schema、不必重编 C++。注意 `find_duplicate_entities.limit` 语义是 + **最大重复组数**(非条目数),返回 `{count, groups:[{reason,type,handles[]}]}`(非分页)。 - **`DEEPSEEK_API_KEY` 设在 Windows `Machine`(系统)级**。因新设的系统变量**不会传播到已启动 的进程**,`dwg_review/config.py` 的 `_read_env()` 在进程环境读不到时**回退读注册表** (`HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment` → `HKCU\Environment`)。