iomgaa
3ae3d5ab50
feat(search): app/search/vision.py — 两轮 VLM 帧观察模块
...
从 TRM4 core/tree/vision.py 迁移 observe_frame,关键变更:
- VLM 调用走 VLMProvider.chat_with_images Protocol(images 传 Path)
- OCR 调用走 OCRProvider.transcribe_frames 异步 Protocol
- 遥测字段 session_id / parent_call_id 透传
- 帧文件存在性前置校验
12 个单元测试覆盖:两轮正常、仅提取、OCR 注入/失败降级/None、
VLM 提取失败、VLM 验证失败降级、帧缺失、stats 完整性、
分歧/弃权标记、遥测透传。
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-07-07 05:52:54 -04:00
iomgaa
86b19d1e07
feat(adapters): OCRProvider Protocol + MonkeyOCRClient 异步适配器
...
- app/ports.py: 新增 OCRProvider Protocol(runtime_checkable,与
EmbeddingProvider 同级),定义 async transcribe_frames 端口
- adapters/ocr.py: 从 TRM4 core/tree/ocr.py 保真迁移 MonkeyOCRClient
- assert → ValueError(P5 防御性校验)
- 公开方法改 async(asyncio.to_thread 包装同步 HTTP)
- 内部逻辑不变:多端点轮询、线程安全 Session、单帧降级、行去重
- tests/unit/test_ocr_adapter.py: 17 个测试覆盖 Protocol 合规、
构造校验、健康检查、转录、降级、去重、轮询
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-07-07 05:47:55 -04:00
iomgaa
60e737e2fc
feat(search): app/search/skills.py — 技能注册表与 frontmatter 解析
...
从 TRM4 core/search/skills.py 保真迁移。提供 parse_frontmatter、
strip_frontmatter、SkillRegistry、discover_skills 四个公共 API。
逻辑完全一致,仅调整导入路径并添加中文 docstring。
17 个单元测试全部通过,覆盖正常/异常/边界场景。
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-07-07 05:46:25 -04:00
iomgaa
82f1607195
style: format environment.py
2026-07-07 05:46:25 -04:00
iomgaa
44ee62867d
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
iomgaa
d8a903fb54
feat(question_gen): QuestionGenerator Protocol + 模块公开 API
...
app/ports.py 追加 QuestionGenerator Protocol(预留 LLM 出题接口)。
app/question_gen/__init__.py re-export load_benchmark 和 stratified_sample。
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-07-07 04:48:21 -04:00
iomgaa
8d515ff01f
feat(question_gen): stratified_sample — 分层采样 + 题型保底
...
算法 100% 保真 TRM4: task_types 过滤、correctness.get(id, False) 语义、
对题在前返回顺序、min_per_class 遍历 pool 全部题型(含稀疏类)。
所有参数显式传入,无默认值。
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-07-07 04:45:19 -04:00
iomgaa
dea8a7d3f6
feat(question_gen): load_benchmark — benchmark JSON 加载
...
从 JSON 目录 glob *.json 加载题目,stem 作 video_id。
legacy schema 无 difficulty 字段时赋 _LEGACY_DEFAULT_DIFFICULTY 常量。
options/source_nodes 转 tuple 配合 frozen dataclass。
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-07-07 04:41:25 -04:00
iomgaa
4686adf266
feat(tree/repair): 检测器扩展 — visible_entities/ongoing_actions/spatial_layout 为空也触发修复
2026-07-07 03:15:42 -04:00
iomgaa
18971a794b
feat(tree/repair): Q&A 反向补全 — 从 TRM4 supplement 迁移
...
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-07-07 02:37:50 -04:00
iomgaa
edaa0d8290
feat(tree): VideoTreeBuilder 保真 #1 #2 #3 + 复杂度重构
...
- 从 reference/video_tree_trm/video_tree_builder.py (994行) 迁移
- 保真算法 #1 : L2 轴心建树策略 (asyncio.gather 链式并发)
- 保真算法 #2 : VLM 批量帧描述 + JSON fallback (_L3_BATCH_SIZE=5)
- 保真算法 #3 : 断点续跑 (progress.json + L1 中间 JSON)
- 新增: VLMProvider/LLMProvider Protocol 替代 LLMClient
- 新增: 结构化 JSON 输出 → L1Card/L2Card/L3Card
- 新增: L2 代表帧复用 L3 帧 (_sample_representative_frames)
- 新增: 字幕注入 + Voronoi 分配
- 重构: 提取 _load_resume_state/_assemble_roots 降低 _build_async 复杂度 D(21)→C(14)
- 44 个单元测试全部通过
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-07-07 02:17:50 -04:00
iomgaa
12f20493c1
feat(tree): 质量校验 — 交叉验证 entities/visible_text
...
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-07-07 01:57:32 -04:00
iomgaa
fb6f9964d8
feat(tree): 字幕模块 — SRT 解析 + 完整性检查 + Voronoi 分配
...
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-07-07 01:54:09 -04:00
iomgaa
c1680447c0
feat(adapters): EmbeddingProvider Protocol + local/remote 双后端实现
...
- app/ports.py: 添加 EmbeddingProvider Protocol(runtime_checkable,dim 属性 + embed 方法)
- adapters/embedding.py: 从参考代码迁移,拆分为 LocalEmbeddingProvider 和 RemoteEmbeddingProvider
- Local: sentence-transformers 冻结推理,维度校验
- Remote: OpenAI 兼容 API,L2 归一化,按 index 排序
- 两者均提供 embed() 和 embed_tensor() 统一接口
- tests/unit/test_embedding_adapter.py: Protocol 满足性、形状校验、导入测试
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-07-07 01:45:09 -04:00
iomgaa
547c9ddd84
feat(tree): TreeConfig 配置 dataclass
...
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-07-07 01:41:50 -04:00
iomgaa
e0f7851975
fix(tree): from_dict 增加 ID 唯一性校验
...
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-07-07 01:40:46 -04:00
iomgaa
c136de076d
refactor(tree): extract _embed_l2_subtree to reduce embed_all complexity
...
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-07-07 01:37:09 -04:00
iomgaa
22ad014973
feat(tree): TreeIndex 数据结构 — Card 体系 + 节点 + 序列化
...
- 新增三级 frozen Card dataclass: L3Card(6字段), L2Card(7字段), L1Card(7字段)
- 节点重构: L3Node/L2Node/L1Node 使用 Card 替代原始字符串字段
- 添加 @property 兼容层: description/summary 代理到 Card 字段
- L3Node 新增 subtitle 字段(字幕集成预留)
- JSON 序列化/反序列化支持 Card 结构 + embedding base64 编解码
- load_json 新增 ID 唯一性校验(重复 ID 抛 ValueError)
- 移除 pickle 序列化(仅保留 JSON)
- 日志从 log_msg 迁移到 loguru
- 17 个单元测试全部通过
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-07-07 01:35:10 -04:00
iomgaa
e60823de1a
build: add README, pyproject.toml, package skeletons and smoke test
...
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-07-06 11:37:59 -04:00