docs: 登记 AC-2 契约 C3 扩(AI 对话端点)+ PROGRESS 台账

- memory/contracts.md:C3 扩(AC-2)AI 对话端点登记「稳定」——POST/GET
  /projects/{id}/ai-messages 请求/响应 schema + per-kind meta 形状 +
  冻结 schema 名;标注 @frontend AC-3 须 pnpm gen:api。
- PROGRESS.md:AC-2 标 (commit c675a74)+ 一行台账 + 变更日志。
This commit is contained in:
Yaojia Wang
2026-07-09 16:55:39 +02:00
parent c675a74f1d
commit 7c4b3c95be
2 changed files with 11 additions and 1 deletions

View File

@@ -239,6 +239,15 @@
- **lifespan reaper**M4-d`main.py` `_lifespan``seed_stub_user` 之后 `SqlJobRepo(session).reap_zombies()`(幂等、自 commit——进程重启丢 BackgroundTask 的残留 `running` 行标 `failed`,用户可见可重试。
- **T4.3 行动**`POST /style``job_repo.create(project_id,"style_learn")` + commit 返 202 `{job_id}``background_tasks.add_task(run_job, session_factory, job.id, work=<部分应用 run_style_extraction→StyleFingerprintWriteRepo.append 并返回 {version,dims_count} 摘要>)``work` 内自建 gatewayanalyst+ repo`run_job` 传入的独立 session。注入缝 `get_job_repo`/`get_session_factory` 测试经 `app.dependency_overrides` override。
### C3 扩展AC-2, 2026-07-09· AI 对话(聊天记录)端点(独立 `routers/ai_messages.py`已注册 owner @backend 状态: 稳定
- 来源:`docs/design/ai-chat-history-plan.md §3`。建于 **C2 扩(AC-1) `ai_messages` 表**之上。持久化 refine/rewrite/clarify/continue/generator 五类往复交换供每章「AI 对话」抽屉重放。**这两端点是显式的记录写入**(前端在一轮交换结束后 POST 一批——五个生成端点refine/refine·clarify/rewrite SSE/rewrite·clarify/skills·generate**逐字节不变、只读**(守不变量 #3)。`ai_messages` 是侧记录assemble()/agent 永不读它(守 #1/#6。snake_case改字段 → **@frontend AC-3 须 `cd apps/web && pnpm gen:api`**。
- **`POST /projects/{project_id}/ai-messages`** ← `AiMessageAppendRequest{thread_id:uuid, chapter_no:int(ge=1)|null=nullNULL=项目级/工具箱), kind:Literal["refine","rewrite","clarify","continue","generator"], tool_key:str|null=null, messages:list[AiMessageInput]min1,max50}`,其中 `AiMessageInput{role:Literal["author","ai"], content:str(min1,max200_000), meta:dict=(默认 {},序列化 ≤50_000 字符否则 422}`**201** `AiMessageListResponse{messages:list[AiMessageView]}`。批内 `seq`=0 基位置由 **repo** 赋值(客户端不传);同批共享 `thread_id`+`created_at`。项目不存在 → **404** `NOT_FOUND`;非法 kind/role、空 messages、content 超上限、meta 超上限 → **FastAPI 422**。append 只 flush端点写后 `commit()`
- **`GET /projects/{project_id}/ai-messages?chapter_no=&kind=` + `PageDep`limit≤200,offset≥0** → **200** `AiMessageListResponse`。**newest-first**`created_at DESC, seq DESC``chapter_no` 非空 → 本章 项目级(`chapter_no IS NULL`);缺省 → 仅项目级;可选 `kind` 过滤。每行 **完整 `content`**(抽屉 re-accept 直读)。项目不存在 → 404`GET .../style`)。只读不 commit。
- **`AiMessageView`append/list 回显,与 repo view 镜像)**`{id:uuid, project_id:uuid, chapter_no:int|null, thread_id:uuid, seq:int, kind:str, tool_key:str|null, role:str, content:str, meta:dict, created_at:datetime}`。**冻结 schema 名(前端消费码生成名,勿手写)**`AiMessageAppendRequest`/`AiMessageInput`/`AiMessageView`/`AiMessageListResponse`,信封键 **`messages`**(复数键,非 `items`)。
- **per-kind `meta` 形状(前端写、@frontend AC-3 据此,长文进 `content` 不进 `meta`**refine → author `{}`(content=原选段) / ai `{version_no,segment}`(content=重写段segment 存**每条** ai 行供任意版 re-accept 重锚)rewrite → author `{version_no}`(content=折叠意见) / ai `{version_no}`(content=版本文本)clarify → author `{}`(content=答案) / ai `{parent_kind,options:[{label,value}],allow_free_text,verification}`(content=问题文本)continue → 仅 ai `{candidate_index}`(content=候选文本,`tool_key="continue"`)generator → author `{tool_key,input_fields}`(content=brief/字段摘要) / ai `{tool_key,output_kind}`(content=渲染预览文本)。
- 位置/缝repo `packages/core/ww_core/domain/ai_message_repo.py``AiMessageRepo`/`SqlAiMessageRepo`/`AiMessageView`/`AiTurnRow`,经 `ww_core.domain` 导出;`append` 只 flush`list_for_chapter` 只读schemas `apps/api/ww_api/schemas/ai_messages.py`router `apps/api/ww_api/routers/ai_messages.py`prefix `/projects`tag `ai-messages`);注入缝 `get_ai_message_repo``services/project_deps.py`),测试经 `app.dependency_overrides` 注内存 fake。DoD 全绿ruff/format/mypy(238 files)/alembic check(无漂移,本任务不加模型)/pytest(**992 passed**);新模块 covrouter 100% / schemas 100% / repo 97%(余 Protocol `...` 桩)。
- **@frontend 行动AC-3**`cd apps/web && pnpm gen:api` 纳入 `POST/GET /projects/{id}/ai-messages` + 上述 4 个 schema。
## C4 · 编排器接口LangGraph 写章图 owner @llm 状态: 稳定M1/T1.3, 2026-06-18M2 扩四审/验收)
- 来源:`ARCHITECTURE.md §5.2`(图)/ §7.3SSE。**M1 仅单 `write` 节点**;并行四审/collect/interrupt(accept) 属 M2。
- 位置:`packages/core/ww_core/orchestrator/`