iomgaa
a2c6a97621
refactor(tree): extract _clean_join to keep entity-fields complexity at B
...
质量门要求新增代码复杂度不超过 B 级:将 node_entity_fields 中重复的
"清洗-去重-拼接"逻辑抽为模块级纯函数 _clean_join,主体收敛为两次
调用。radon:node_entity_fields C(13) → B(6),_clean_join A(5)。
算法 #11(树环境语义搜索)数据访问层,行为不变(既有 4 测试未改全绿)。
2026-07-11 08:56:17 -04:00
iomgaa
4e0e05210d
feat(search): append raw entity fields after view_node summary
...
view_node 按题两轮摘要(summarize_node)会吞掉 entities/visible_text
字段信号,Agent 站在证据节点上仍漏读实体(benchmark 错题 M1,案例
786-2、872-3、750-1)。dispatcher 侧在摘要后确定性追加 [实体]/[画面
文字] 原文区块,LLM 无法吞掉。
- TreeEnvironment.node_entity_fields:按层级取 card 实体字段原文,
去空白、去重、分号拼接;空字段省键;未知节点抛 KeyError
- _handle_view_node Phase 2.5:摘要后、子节点概览前追加实体区块
- 附带 ruff format 修正 test_tree_environment.py 两处既有格式
算法 #11(树环境语义搜索)数据访问层扩展,不改搜索算法本身。
2026-07-11 08:53:56 -04:00
iomgaa
d3be9b1322
refactor(tree): subtitle 迁入 L3Card/L2Card + 建树管线修正
...
- L3Card/L2Card 新增 subtitle: str 字段(L1Card 不加)
- L3Node 移除 subtitle 字段(数据迁入 Card)
- assign_subtitles_voronoi 改写 Card.subtitle + L2 聚合
- _collect_card_strings 增加 skip_fields 排除 subtitle
- _node_full_text/_node_anchored_text 保持 字幕:/[sN] 语义
- get_subtitle 读 Card.subtitle(L2/L3)
- verify.py/synthesizer.py: l3.subtitle → l3.card.subtitle
- 迁移脚本 tools/migrate_subtitle_to_card.py(幂等,300 棵树已迁移)
- 9→6 个测试文件适配(3 个无需改动)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-07-09 11:57:41 -04:00
iomgaa
96e63a3e19
feat(search): 实现 SearchToolDispatcher 工具调度器 (Task 7)
...
- 新增 app/search/tools.py:
- get_tool_descriptions() 工具描述文本(与 TRM4 一致)
- SearchToolDispatcher 类实现 ToolDispatcher Protocol
- dispatch() 按工具名路由: view_node / search_similar /
observe_frame / submit_answer / read_skill
- ValueError(未知工具)上抛,KeyError/FileNotFoundError 捕获返回错误文本
- view_node: env.get_node_text + summarize_node + get_children_info + summarize_children
- search_similar: env.search_similar + summarize_nodes_batch
- observe_frame: env.resolve_frame_paths + get_subtitle + observe_frame + 字幕前置
- 修复 app/tree/environment.py get_children_info():
- 原实现返回 _format_time_range (str) 导致 summarize_children 解包失败
- 改为返回原始数值元组 via 新增 _node_time_range_raw 静态方法
- 新增 tests/unit/test_search_tools.py (14 tests):
- get_tool_descriptions 含/不含 read_skill
- 五种工具 dispatch 路由验证
- 未知工具 ValueError + 节点不存在错误文本
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-07-07 06:07:27 -04:00
iomgaa
f0a49b08e5
style: format environment.py
2026-07-07 05:46:25 -04:00
iomgaa
2bc5dc74c2
feat(tree): add get_node_text + get_children_info to TreeEnvironment
...
- get_node_text(node_id, anchor=False): returns raw text + optional
anchor_map dict by parsing [cN]/[sN] prefixes from anchored text
- get_children_info(node_id): returns structured child list with
id/time_range/summary (description truncated to 120 chars)
- Both methods reuse existing internal helpers (_node_full_text,
_node_anchored_text, _get_children, _node_description,
_format_time_range)
- 9 new test cases across TestGetNodeText and TestGetChildrenInfo
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-07-07 05:45:48 -04:00