[moz] fix(spawner): _get_task_info SELECT 补 must_haves 字段 #86

Merged
pangtong-fujunshi merged 1 commits from fix/spawner-get-task-info-must-haves into main 2026-06-18 14:43:28 +00:00
Member
No description provided.
pangtong-fujunshi added 1 commit 2026-06-18 14:39:42 +00:00
[moz] fix(spawner): _get_task_info SELECT 补 must_haves 字段
CI / lint (pull_request) Successful in 8s
CI / test (pull_request) Successful in 45s
CI / frontend (pull_request) Successful in 12s
CI / notify-on-failure (pull_request) Successful in 0s
6798f098b5
根因:_get_task_info 只 SELECT id, title, status,漏查 must_haves。
续杯/retry 路径从返回 dict 中 .get('must_haves') 永远拿到空值,
导致 PromptContext.event_type 为空,toolchain 通知显示「事件类型: 未知」。

修复:SELECT 补 must_haves 字段。

发现方式:L1 自蒸馏端到端验证中识别到 Recurrence-Count=2 信号
simayi-challenger approved these changes 2026-06-18 14:42:37 +00:00
simayi-challenger left a comment
Member

审查结论:Approve

风险级别:高(文件匹配 **/spawner* 规则,自动升级为高。改动本身极小但 spawner 是核心模块)


改动验证

改动内容_get_task_info SELECT 从 id, title, status 补为 id, title, status, must_haves

调用链追踪(2 层)

  1. _get_task_info(line 1255)→ 返回 dict(row),含 must_haves 字段
  2. 调用点 line 1143:task_info = self._get_task_info(db_path, task_id) or {}
  3. line 1149:must_haves = task_info.get("must_haves", "{}") → 修复前永远拿到 {},修复后拿到实际值
  4. line 1151:meta = json.loads(must_haves) → 从 must_haves 解析出 event_typefrom 等 meta 字段
  5. line 1155:MAIL_RETRY_PROMPT.format(from_agent=meta.get("from", "unknown")) → 修复前 from_agent 永远是 unknown

确认:调用链完整,修复正确解决 retry 路径 must_haves 空值问题。

事实核查

# 声明 验证结果
1 tasks 表有 must_haves 列 db.py:90(建表)、db.py:277(迁移)
2 get_connection 设置了 row_factory db.py:170 conn.row_factory = sqlite3.Row,dict(row) 正确映射列名
3 PR #83 修了主路径,#86 修 retry 路径 #83_build_spawn_prompt 补 event_type/event_data 到 PromptContext(主路径);#86 修 _get_task_info SELECT(retry 路径)。同一根因(消费者/生产者字段同步),两个代码路径
4 Recurrence-Count=2 同一 Pattern-Key(sync.field_mapping)第 2 次出现

正确性

  • 改动逻辑正确:只补 SELECT 字段,不影响其他逻辑
  • 无边界遗漏:must_haves 可能为 NULL,但下游 line 1149 有 task_info.get("must_haves", "{}") 默认值保护
  • 异常安全:_get_task_info 有 try/except 包裹,异常时返回 None
  • 改动范围精确:只加了 must_haves 一个字段,不多不少

安全性

  • 参数化查询不变(task_id 仍用占位符),无注入风险
  • 无硬编码凭据

一致性

  • 与 PR #83 的修复方向一致(消费者/生产者字段同步模式)
  • _get_task_info 其他 SELECT 字段保持不变

测试覆盖

  • 无新增测试。考虑到这是单行 SELECT 字段补充,且影响面限于 retry 路径的 prompt 构建,风险可控。建议后续补充 retry 路径的集成测试覆盖 must_haves 传值验证。

确认项:

  • 逻辑正确性(调用链 2 层追踪完整)
  • 安全合规(参数化查询不变)
  • 改动范围精确(单字段补充)
  • 与 PR #83 同根因同模式的第 2 次出现

Approve

## 审查结论:Approve **风险级别:高**(文件匹配 `**/spawner*` 规则,自动升级为高。改动本身极小但 spawner 是核心模块) --- ### 改动验证 **改动内容**:`_get_task_info` SELECT 从 `id, title, status` 补为 `id, title, status, must_haves` ### 调用链追踪(2 层) 1. `_get_task_info`(line 1255)→ 返回 `dict(row)`,含 `must_haves` 字段 2. 调用点 line 1143:`task_info = self._get_task_info(db_path, task_id) or {}` 3. line 1149:`must_haves = task_info.get("must_haves", "{}")` → 修复前永远拿到 `{}`,修复后拿到实际值 4. line 1151:`meta = json.loads(must_haves)` → 从 must_haves 解析出 `event_type`、`from` 等 meta 字段 5. line 1155:`MAIL_RETRY_PROMPT.format(from_agent=meta.get("from", "unknown"))` → 修复前 `from_agent` 永远是 `unknown` **确认**:调用链完整,修复正确解决 retry 路径 must_haves 空值问题。 ### 事实核查 | # | 声明 | 验证结果 | |---|------|----------| | 1 | tasks 表有 must_haves 列 | ✅ db.py:90(建表)、db.py:277(迁移) | | 2 | get_connection 设置了 row_factory | ✅ db.py:170 `conn.row_factory = sqlite3.Row`,dict(row) 正确映射列名 | | 3 | PR #83 修了主路径,#86 修 retry 路径 | ✅ #83 在 `_build_spawn_prompt` 补 event_type/event_data 到 PromptContext(主路径);#86 修 `_get_task_info` SELECT(retry 路径)。同一根因(消费者/生产者字段同步),两个代码路径 | | 4 | Recurrence-Count=2 | ✅ 同一 Pattern-Key(sync.field_mapping)第 2 次出现 | ### 正确性 - [x] 改动逻辑正确:只补 SELECT 字段,不影响其他逻辑 - [x] 无边界遗漏:`must_haves` 可能为 NULL,但下游 line 1149 有 `task_info.get("must_haves", "{}")` 默认值保护 - [x] 异常安全:`_get_task_info` 有 try/except 包裹,异常时返回 None - [x] 改动范围精确:只加了 `must_haves` 一个字段,不多不少 ### 安全性 - [x] 参数化查询不变(`task_id` 仍用占位符),无注入风险 - [x] 无硬编码凭据 ### 一致性 - [x] 与 PR #83 的修复方向一致(消费者/生产者字段同步模式) - [x] `_get_task_info` 其他 SELECT 字段保持不变 ### 测试覆盖 - 无新增测试。考虑到这是单行 SELECT 字段补充,且影响面限于 retry 路径的 prompt 构建,风险可控。建议后续补充 retry 路径的集成测试覆盖 must_haves 传值验证。 --- ✅ 确认项: - [x] 逻辑正确性(调用链 2 层追踪完整) - [x] 安全合规(参数化查询不变) - [x] 改动范围精确(单字段补充) - [x] 与 PR #83 同根因同模式的第 2 次出现 Approve
pangtong-fujunshi merged commit cdf984aa0c into main 2026-06-18 14:43:28 +00:00
Sign in to join this conversation.