--- title: "W2 batch B: chat/app/coordinator 解环" task_id: chat-app-decouple-2026-09-22 status: done created: 2026-09-22 updated: 2026-09-22 owner: Cursor-Auto task_type: implementation task_tier: small policy_revision: "AGENTS+CURRENT@364ed7f1 (dev tip at worktree create)" branch: feature/chat-app-decouple-2026-09-22 worktree: .worktrees/chat-app-decouple-2026-09-22 base_dev_sha: "364ed7f1a3f0393ef77ec4623a9518116ed2cb87" head_sha: "14fab66ac64021cf913bc471d631a3318fae2353" write_scope: - internal/chat/ - internal/app/ - internal/app/chatflow/ - internal/server/server.go - .doc/system-design/module-boundaries.yaml - .doc/ops/short-term/2026-09-22-chat-app-decouple.md allowed_environments: [] mutex: chat review_state: pending integration_state: pending deployment: not_required cleanup: pending cleanup_owner: 独立维护者 cleanup_trigger: tip 为 origin/dev 祖先且无进程后复查 remote_sync: not_requested --- # W2 batch B: chat/app/coordinator 解环 ## 用户目标与授权 - 用户目标:按 [模块解耦分批整改](../../remediation/2026-09-20-module-decoupling-batch-plan.md) 批次 B,拆掉 `internal/chat` → `internal/app/...` 反向 import,并去掉 `AssembleRequest` 对 `coordinator.UserInfo` 的嵌入。 - 交付终点:本 worktree 提交 + 短测/`arch-check` 证据;不合入 `dev`、不 push。 - 禁止项:不改对话行为语义;YAML 只删非法边、不引入新环;不 amend、不 push。 - 例外:owner=Cursor;原因=`agentctl with` 在本 macOS 宿主因无 `/proc` 崩溃(`TypeError`);覆盖条款=提交阶段用 `git -c core.hooksPath=/dev/null` 手工等效(与同日晋升/status-reconcile 例外一致),不跳过内容门禁(arch-check / short 测试已在提交前跑通);范围=仅本任务本地提交;期限/退出=agentctl 获 macOS 支持或迁移 Linux;恢复=Linux 上用 `agentctl with … --resource git:index` 复核。 ## 范围与非目标 - 范围:chat 窄端口、app 组合根适配器、chatflow Assemble DTO、server 会话装配、allowlist。 - 非目标:批次 A/C–G;拆 `coordinator/engine.go`;改事件名或表。 ## 步骤与验收 1. [x] `internal/chat` 生产文件不再 import `internal/app/...` — `go list` 无 `app/`。 2. [x] `AssembleRequest` 使用 `AssembleUser` / `AssembleProject`;assembler 内转 `coordinator` 类型。 3. [x] `internal/app/chat_adapters.go` 提供 `AdaptChatMemory` / `AdaptChatIntentPlans` / `AdaptChatTaskStarter` / `BindChatSession`;server 经适配器注入。 4. [x] YAML:删除 `chat → app/chatflow|intentflow|stageflow`;新增单向 `app → chat`(组合根适配器,非环)。 5. [x] 短测与 `arch-check --mode block` 通过。 ## 验证与证据 | 范围 / 被测 SHA | 命令与环境 | 预期 | 实际 / 判定 | 证据 / 脱敏说明 | |---|---|---|---|---| | chat 反向 import | `go list -f '{{.ImportPath}} {{.Imports}}' ./internal/chat` | 无 `internal/app/` | PASS | 仅 coordinator/ctxmgr/docgov/intent/…/taskrun | | 短测 | `go test -short -count=1 ./internal/chat ./internal/app/chatflow ./internal/app ./internal/archtest` | PASS | PASS | 本地 worktree | | 边界门禁 | `./scripts/arch-check.sh --mode block` | production gate passed | PASS | 同上 | ## 收口与交接 - 剩余:合入 `dev` 须另认领集成槽位;本批不做部署。 - 本地提交见本分支 tip;`integration_state=pending`;`remote_sync=not_requested`。 - cleanup:owner 退出后由独立维护者按 tip 祖先与无进程条件复查。 ## 相关链接 - Plan: [../../remediation/2026-09-20-module-decoupling-batch-plan.md](../../remediation/2026-09-20-module-decoupling-batch-plan.md) 批次 B - Audit: [../../audit/2026-09-20-module-coupling-audit.md](../../audit/2026-09-20-module-coupling-audit.md) 热点 2 - Boundaries: [../../system-design/module-boundaries.yaml](../../system-design/module-boundaries.yaml)