deerflow2/.planning/phases/06-/06-06-PLAN.md

82 lines
3.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
phase: 06-
plan: 06
type: execute
wave: 5
depends_on:
- 06-05
gap_closure: true
files_modified:
- backend/packages/harness/deerflow/agents/middlewares/uploads_middleware.py
- backend/tests/test_uploads_middleware_core_logic.py
autonomous: true
requirements:
- ATREF-04
must_haves:
truths:
- "提及文件ref_kind=mention发送时不应被识别为本次新上传文件。"
- "<uploaded_files> 的 new_files 区块仅包含真实上传附件,不包含 mention 引用。"
artifacts:
- path: "backend/packages/harness/deerflow/agents/middlewares/uploads_middleware.py"
provides: "按 metadata 区分真实上传与 mention 引用"
contains: "_files_from_kwargs"
- path: "backend/tests/test_uploads_middleware_core_logic.py"
provides: "mention 引用过滤回归测试"
contains: "ref_kind"
---
<objective>
关闭 UAT 新增 gap修复“ref_kind=mention, ref_source=upload 被当作本次上传文件”的误判。
Purpose: 保持提及文件与真实上传附件在后端语义分离,避免 injected <uploaded_files> 误导模型。
Output: Middleware 仅接收真实上传文件为 new_filesmention 引用不再进入 uploaded_files state update。
</objective>
<context>
@.planning/phases/06-/06-UAT.md
@backend/packages/harness/deerflow/agents/middlewares/uploads_middleware.py
@backend/tests/test_uploads_middleware_core_logic.py
</context>
<tasks>
<task type="auto">
<name>Task 1: 过滤 mention 引用,避免误判为新上传</name>
<files>backend/packages/harness/deerflow/agents/middlewares/uploads_middleware.py</files>
<action>
`_files_from_kwargs` 解析 `additional_kwargs.files` 时,若条目 `ref_kind == "mention"` 则直接跳过,不纳入 `new_files`。保留现有 filename 校验、size/path 归一化、磁盘存在性检查逻辑。
</action>
<acceptance_criteria>
- `ref_kind=mention` 条目不会进入返回列表。
- 普通上传条目(无 ref_kind行为不变。
- `before_agent``<uploaded_files>` 注入仅反映真实上传。
</acceptance_criteria>
</task>
<task type="auto">
<name>Task 2: 补充回归测试覆盖 mention 过滤</name>
<files>backend/tests/test_uploads_middleware_core_logic.py</files>
<action>
新增测试:当 files 中包含 `ref_kind=mention`(含 `ref_source=upload`)时,`_files_from_kwargs` 不返回该条目;并验证 mixed list 下真实上传仍可保留。
</action>
<acceptance_criteria>
- 新增测试在修复前失败、修复后通过。
- 不影响已有核心 middleware 测试。
</acceptance_criteria>
</task>
</tasks>
<verification>
- `cd backend && pytest -q tests/test_uploads_middleware_core_logic.py -k "mention or files_from_kwargs"`
</verification>
<success_criteria>
- UAT 新增 gap 的 root cause 与修复措施一一对应。
- 计划可直接由 `/gsd-execute-phase 6 --gaps-only` 执行。
</success_criteria>
<output>
After completion, create `.planning/phases/06-/06-06-SUMMARY.md`
</output>