From 6b7391d1b70a2739ddf72f4701ea6e83b154e1bd Mon Sep 17 00:00:00 2001 From: Yaojia Wang Date: Wed, 8 Jul 2026 11:47:26 +0200 Subject: [PATCH] =?UTF-8?q?docs:=20=E7=99=BB=E8=AE=B0=20WFW-9=20M2=20?= =?UTF-8?q?=E6=95=B4=E7=AB=A0=E9=87=8D=E5=86=99=E9=A2=84=E6=A3=80=E6=BE=84?= =?UTF-8?q?=E6=B8=85=E2=80=94=E2=80=94=E5=A5=91=E7=BA=A6=20C-Clarify=20?= =?UTF-8?q?=E6=89=A9=20+=20PROGRESS=20=E5=8F=B0=E8=B4=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PROGRESS.md | 1 + memory/contracts.md | 2 ++ 2 files changed, 3 insertions(+) diff --git a/PROGRESS.md b/PROGRESS.md index 9252728..1317207 100644 --- a/PROGRESS.md +++ b/PROGRESS.md @@ -63,6 +63,7 @@ | WFW-7 首次 AI 写作前极轻 genre 采集 + 无大纲降级 | ✅ | @frontend | WFW-0 | — | `3dd7d28` 无题材首次写章前弹 GenrePicker(临时并入本次 directive 不落库) + chapters 空时「尚无大纲,将按设定自由生成」提示,杜绝无题材 slop | | WFW-8 整章级「再沟通/重写」(对话式迭代) | ✅ | @backend·@llm·@frontend | — | 新#1 | `6ed9c89`(后端)+`542c2ab`(前端)。后端 SSE `POST .../rewrite`(`rewrite.md` 教条 + `rewrite_node` + `RewriteStreamRequest`,复用 assemble 记忆注入,只读不写库、工具非写节点、守 #3/#7/#9);前端 `useChapterRewrite`(版本栈)+`ChapterRewritePanel`+底栏「整章重写」:给意见→流式重写整章→多轮迭代→接受某版才替换正文(HITL)。契约 C-Rewrite。用户反馈「整章不满意要跟 AI 交流」 | | WFW-9 M1 AI 反问澄清(refine 侧,路线A 两阶段) | ✅ | @backend·@llm·@frontend | — | 新#2 | `1652ad9`(后端)+`e30c933`(前端)。多agent并行(后端整片‖ChoiceChips)+主线集成。非流式预检 `POST .../refine/clarify`→`ClarifyDecision`(结构化,analyst,只读,失败回退放行)+clarify_refine spec/教条(SPECS#24);既有 refine 未改。前端 `useClarify`+`ChoiceChips`+`clarify.ts`(foldClarifications/门控)+RefinePanel 门控接线:意见<10字或点「帮我理清方向」→AI反问选项→折答案进instruction→走既有refine。契约 C-Clarify。**M2 rewrite 侧两阶段 + M3 UX/E2E 待办**。调研计划见 scratchpad/clarify-dialogue-DEVPLAN.md(ephemeral) | +| WFW-9 M2 AI 反问澄清(rewrite 侧,路线A 两阶段) | ✅ 后端 | @llm·@backend | WFW-8·WFW-9 M1 | 新#2 | `4a09f27`(llm)+`6fd6375`(后端)。镜像 M1:非流式预检 `POST .../rewrite/clarify`←`RewriteClarifyRequest{feedback(必给),prior_draft(可选)}`→`ClarifyDecision`(复用同一 schema,analyst,只读,失败回退放行)+`clarify_rewrite_spec`/教条 `clarify_rewrite.md`(segment→整章,SPECS#25);既有 `.../rewrite` SSE 未改。端点只喂 prior_draft 开头 3000 字摘录(不整章入 LLM)、日志脱敏。契约 C-Clarify(扩)。门禁绿:后端 ruff/format·mypy229·pytest948·alembic 无漂移。**前端仍欠 `pnpm gen:api`+M2 UI 接线(仿 RefinePanel 门控 ChapterRewritePanel) + M3 UX/E2E 待办** | --- diff --git a/memory/contracts.md b/memory/contracts.md index 8b8d1b5..0271ae7 100644 --- a/memory/contracts.md +++ b/memory/contracts.md @@ -377,3 +377,5 @@ - [2026-07-08] @backend 改 C3(CR-H9 输入大小上界 + 请求体守卫):给用户请求字符串字段补 `max_length`(`Field(...,max_length=)` / `StringConstraints(max_length=)`,保留既有 `min_length`,命名常量无魔数)——`providers.py`{provider≤64,model≤128,api_key≤512}、`generation.py`{brief≤10_000}、`projects.py`{title≤200,final_text/draft/text≤200_000}、`style.py`{segment≤20_000,samples 列表≤20 且每条≤20_000}、`foreshadow.py`{code≤100,title≤500}、`rules.py`{content≤10_000}、`templates.py`{`NonBlankStr`→`NonBlankTitle`(≤200)+`NonBlankBody`(≤20_000)};`ProjectPlanGenerateRequest`/`RewriteStreamRequest`/`RefineClarifyRequest` 早前已有上界,未动。**新增错误码** `ErrorCode.PAYLOAD_TOO_LARGE`(413)(`ww_shared.errors`,`ErrorBody.code` 为裸 str → **OpenAPI schema 不变**)+ 应用级 `body_size_limit_middleware`(`apps/api/ww_api/middleware.py`,`MAX_BODY_BYTES=2 MiB`,按 `Content-Length` 拦超大 body 直接自建 413 信封——用户中间件跑在 AppError 处理器外;chunked 无 Content-Length 为原型可接受限制)+ `main.py` 在 `request_id_middleware` 后注册。**无 DDL/无迁移**。超界 → 422(字段 ValidationError)/ 413(整体 body)。→ 影响 @frontend:请求字段现有 `maxLength`,须 **`pnpm gen:api`** 重生成 TS 客户端(**本 cluster 不代跑**)。 - [2026-07-08] @backend/@llm/@frontend 立 C-Clarify(WFW-9 M1 refine 侧 AI 反问澄清,路线A 两阶段):新增 **`POST /projects/{project_id}/chapters/{chapter_no}/refine/clarify`**(**非流式** JSON 预检)← `RefineClarifyRequest{segment:str(1..20000), instruction:str(默认"",0..2000)}` → **`ClarifyDecision`**{need_clarification:bool, questions:[ClarifyQuestion{question, options:[ClarifyOption{label,value}](0..4), allow_free_text:bool}](0或1,v1硬上限1问), verification:str|null}。tier=**analyst**,结构化输出(instructor),**只读不写库**(末尾 commit 仅记 usage_ledger,不变量 #3);判别/校验失败**确定性回退 need_clarification=false**(放行)。`ClarifyDecision` 定义在 `ww_agents`(供 producer+端点共用),注册 `clarify_refine_spec`(SPECS #24)+SCHEMA_CATALOG+金标准。**既有 `POST .../refine`(RefineRequest/RefineResponse)完全未改**。→ 影响 @frontend(已 gen:api;`useClarify` 映射 snake→VM + `ChoiceChips` 选项芯片 + `RefinePanel` 门控预检:意见<10字或点按钮→预检→needClarification 则渲染选项→答案 foldClarifications 折进 instruction→走既有 refine)。**无 DDL/无迁移**。门禁绿:后端 ruff/mypy227/pytest900/alembic;前端 tsc/lint/vitest654/build/cov95.36%。M2(rewrite 侧两阶段)/M3(UX+E2E) 待办。 + +- [2026-07-08] @llm/@backend 扩 C-Clarify(WFW-9 M2 **rewrite 侧** AI 反问澄清,镜像 M1):新增 **`POST /projects/{project_id}/chapters/{chapter_no}/rewrite/clarify`**(**非流式** JSON 预检)← `RewriteClarifyRequest{feedback:str(1..4000), prior_draft:str|null(0..200000)}` → **`ClarifyDecision`**(复用 M1 同一 schema:{need_clarification, questions[0或1,硬上限1问], verification?})。tier=**analyst**,结构化输出,**只读不写业务表**(末尾 commit 仅记 usage_ledger,不变量 #3);判别/校验失败**确定性回退 need_clarification=false**(放行)。端点只把 `prior_draft` **开头 3000 字摘录**喂预检(不整章入 LLM),日志只记 `feedback_len`(脱敏)。注册 `clarify_rewrite_spec`(analyst,reads=()/writes=(),SPECS **#25**)+SCHEMA_CATALOG(复用 ClarifyDecision)+教条 `prompts/clarify_rewrite.md`(segment→整章)+金标准(仅新增 1 条哈希,无漂移)。**既有 `POST .../rewrite`(RewriteStreamRequest, SSE)完全未改**。→ 影响 @frontend:**须 `pnpm gen:api`** 纳入新端点,再仿 M1 `RefinePanel` 在 `ChapterRewritePanel` 接门控预检(意见含糊/极短→预检→needClarification 则选项芯片→折答案进 feedback→走既有 rewrite SSE)。**无 DDL/无迁移**。门禁绿:后端 ruff/format 干净·mypy **229**·pytest **948**·alembic 无漂移。M2 前端 UI 接线 + M3(UX/E2E) 待办。