ai-robot-core/docs/progress/intent-driven-mid-platform-...

5.6 KiB
Raw Blame History

意图驱动智能体中台改造IDMP- 进度文档

context:
  module: "intent-driven-mid-platform"
  feature: "IDMP"
  status: "🔄进行中"
  version: "0.3.0"
  active_ac_range: "AC-IDMP-13/14/15/19"

spec_references:
  requirements: "spec/intent-driven-mid-platform/requirements.md"
  openapi_provider: "spec/intent-driven-mid-platform/openapi.provider.yaml"
  openapi_deps: "spec/intent-driven-mid-platform/openapi.deps.yaml"
  design: "spec/intent-driven-mid-platform/design.md"
  tasks: "spec/intent-driven-mid-platform/tasks.md"
  active_version: "0.2.0-0.3.0"

overall_progress:
  - [x] Phase 1: 环境准备与文档阅读 (100%) [完成]
  - [x] Phase 2: 记忆服务增强 (100%) [AC-IDMP-13/14]
  - [x] Phase 3: 工具调用治理 (100%) [AC-IDMP-15/19]
  - [x] Phase 4: 单元测试与验证 (100%) [全部AC]

current_phase:
  goal: "实现记忆与工具治理AC-IDMP-13/14/15/19✅ 已完成"
  sub_tasks:
    - [x] 阅读规范文档 (✅)
    - [x] 创建任务文档 (✅)
    - [x] 创建 mid 模块目录结构 (✅)
    - [x] 实现 AC-IDMP-13: 记忆召回服务 (✅)
    - [x] 实现 AC-IDMP-14: 记忆更新服务 (✅)
    - [x] 实现 AC-IDMP-15: 工具调用结构化记录 (✅)
    - [x] 实现 AC-IDMP-19: Tool Registry 治理 (✅)
    - [x] 编写单元测试 (✅ 31 tests passed)
  
  next_action:
    immediate: "阶段完成,可继续实现其他 AC 或集成测试"
    details:
      file: "ai-service/app/services/mid/"
      action: "已完成 AC-IDMP-13/14/15/19 实现,可集成到 dialogue 流程"
      reference: "spec/intent-driven-mid-platform/openapi.provider.yaml"
    constraints: "遵循现有代码风格,保持接口契约一致"

technical_context:
  module_structure: |
    ai-service/app/
    ├── models/mid/
    │   ├── __init__.py          # 统一导出
    │   ├── memory.py            # AC-IDMP-13/14 记忆模型
    │   ├── tool_trace.py        # AC-IDMP-15 工具追踪模型
    │   ├── tool_registry.py     # AC-IDMP-19 工具注册表模型
    │   └── schemas.py           # 中台统一响应协议
    └── services/mid/
        ├── __init__.py           # 统一导出
        ├── memory_adapter.py     # AC-IDMP-13/14 记忆适配器
        ├── tool_call_recorder.py # AC-IDMP-15 工具调用记录器
        └── tool_registry.py      # AC-IDMP-19 工具注册表    

  key_decisions:
    - decision: "复用现有 MemoryService 架构,扩展 MemoryAdapter 实现分层记忆"
      reason: "避免重复造轮子,保持代码一致性,同时支持 profile/facts/preferences 分层"
      impact: "已实现三层记忆模型,支持 Prompt 注入"
    - decision: "Tool Registry 使用内存注册表 + 可选数据库持久化"
      reason: "高频调用的工具配置需要快速访问,同时支持动态配置更新"
      impact: "已实现 register/execute/enable/disable/auth 等治理功能"
    - decision: "工具调用记录使用结构化 Trace 模型"
      reason: "符合 OpenAPI 契约定义,便于可观测性和审计"
      impact: "已实现 ToolCallTrace 和 ToolCallBuilder支持四类状态记录"

  test_coverage:
    - "成功路径:正常 recall/update工具调用成功"
    - "超时路径recall 超时降级,工具调用超时"
    - "错误路径recall 失败降级,工具调用错误"
    - "降级路径:记忆服务不可用时继续主链路"

session_history:
  - session: "Session #1 (2026-03-03)"
    completed: ["阅读规范文档", "理解现有架构", "创建任务文档"]
    changes: ["spec/intent-driven-mid-platform/tasks.md"]
  - session: "Session #2 (2026-03-03)"
    completed:
      - "实现 MemoryAdapter (AC-IDMP-13/14)"
      - "实现 ToolCallRecorder (AC-IDMP-15)"
      - "实现 ToolRegistry (AC-IDMP-19)"
      - "编写单元测试 31 个"
    changes:
      - "ai-service/app/models/mid/memory.py (新建)"
      - "ai-service/app/models/mid/tool_trace.py (新建)"
      - "ai-service/app/models/mid/tool_registry.py (新建)"
      - "ai-service/app/models/mid/__init__.py (更新)"
      - "ai-service/app/services/mid/memory_adapter.py (新建)"
      - "ai-service/app/services/mid/tool_call_recorder.py (新建)"
      - "ai-service/app/services/mid/tool_registry.py (更新)"
      - "ai-service/app/services/mid/__init__.py (更新)"
      - "ai-service/tests/test_mid_memory_tool.py (新建)"

变更文件清单

文件路径 状态 关联 AC 说明
models/mid/memory.py 新建 AC-IDMP-13/14 记忆模型 (RecallRequest/Response/Profile/Fact/Preferences)
models/mid/tool_trace.py 新建 AC-IDMP-15 工具追踪模型
models/mid/tool_registry.py 新建 AC-IDMP-19 工具注册表模型
models/mid/__init__.py 更新 - 统一导出所有模型
services/mid/memory_adapter.py 新建 AC-IDMP-13/14 记忆适配器
services/mid/tool_call_recorder.py 新建 AC-IDMP-15 工具调用记录器
services/mid/tool_registry.py 更新 AC-IDMP-19 添加 get_tool_registry/init_tool_registry
services/mid/__init__.py 更新 - 导出新服务
tests/test_mid_memory_tool.py 新建 AC-IDMP-13/14/15/19 单元测试 (31 tests)

测试结果

======================== 31 passed, 1 warning in 3.64s ========================

覆盖路径:

  • 成功路径:正常 recall/update工具调用成功
  • 超时路径recall 超时降级,工具调用超时
  • 错误路径recall 失败降级,工具调用错误
  • 降级路径:记忆服务不可用时继续主链路