feat: Step 2-4 — Task/Mail/Toolchain Handlers + 11 PromptSections + BaseTaskHandler #25
Reference in New Issue
Block a user
Delete Branch "feat/task-type-handlers-step2-4"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
[CI] 失败
分支: 25
触发 commit:
1b0007f2443a5493d1936c6fadab1a571fd0175c失败 Job: lint
请检查 CI 日志并修复。
审查结论:APPROVED(3 条建议,无必修)
改动范围确认
PR #25 共 4 个新文件,921 行:
src/daemon/base_task_handler.py:+179(BaseTaskHandler 基类 + VerifyResult + 4步统一流程)src/daemon/task_handler.py:+330(TaskHandler + 5 PromptSections + 三信号验证 + review 流程)src/daemon/mail_handler.py:+206(MailHandler + 3 PromptSections + inform/request 区分)src/daemon/toolchain_handler.py:+206(ToolchainHandler + 3 PromptSections + Mail API 通知)✅ 设计-代码一致性验证
(task_id, agent_id, outcome, db_path)✅crashed/compact_failed/process_crash/session_stuck/compact_hanging✅PromptContext✅(task_id, db_path) -> boolTaskContextSection/PriorOutputsSection/RoleSkillSection/TaskApiSection/TaskConstraintsSection✅MailContextSection/MailApiSection/MailConstraintsSection✅ToolchainContextSection/ToolchainApiSection/ToolchainConstraintsSection✅f"请用 read 工具读取 {SKILL_BASE_PATH}/{skill_name}/SKILL.md"✅✅ 正确性验证
return后不进 verify ✅_parse_performative从must_havesJSON 解析,fallback "request" 合理 ✅UPDATE ... SET current_agent = (SELECT assignee ...) WHERE id=? AND current_agent=?条件精确 ✅BEGIN IMMEDIATE+ old/new status 审计事件 ✅pending/claimed→working,状态前置检查 ✅✅ 安全性
_mark_task_status中old_status/status来自代码内部常量,不接受用户输入 ✅?占位符),无 SQL injection ✅💡 建议(S)
S1:
get_sections返回类型不统一4 个 handler 的
get_sections返回类型标注不一致:base_task_handler.py→list[PromptSection]✅task_handler.py→list(缺泛型)mail_handler.py→List(旧式,缺泛型)toolchain_handler.py→List(同上)建议统一为
list[PromptSection]。S2:ToolchainHandler._notify_via_mail_api 使用 subprocess.run 调 curl
toolchain_handler.py:190-204使用subprocess.run(["curl", ...])发 HTTP 请求。handler 代码运行在 daemon 进程中,已有 Python 环境可用,用urllib.request或httpx更符合 Python 惯例,也避免 shell 注入风险(虽然当前 payload 是内部生成的 JSON,风险极低)。S3:ToolchainHandler 通知目标硬编码为
pangtong-fujunshitoolchain_handler.py:186"to": "pangtong-fujunshi"。设计 §17 差异收敛表写的是"通知主公"——如果"主公"指用户本人(chufeng),应通知用户对应的 agent id。如果确实应该通知庞统(由庞统转达),则当前正确。建议确认"通知主公"的语义。风险级别
新增 921 行核心 handler 代码,但均为新文件、不改动现有代码 → standard(按 §7 Step 2-4 定义的风险等级:"低,现有逻辑包一层/全新代码")
APPROVED
[CI] 失败
分支: 25
触发 commit:
4a4e99f73885efe06465221225be2eafcbb820f5失败 Job: lint
请检查 CI 日志并修复。
S1-S3 修复确认
三个建议全部验证通过:
S1 ✅: 返回类型统一为 (小写),基类保持 。
S2 ✅: → + ,零 subprocess 调用。
S3 ✅:通知内容闭环——
可以合并。