Clawline 线程支持(已移除)

⚠️ 2026-05-07 历史决策反转:thread / sub-channel 概念已从 Clawline 全面下架。本页保留作为决策与代码考古,不要再当作现行架构参考

反转原因(5-07)

四月份围绕 thread 做了大量加固(TH-1..TH-8、ralph/thread-discord-style 合并、ThreadSessionCard 组件、reply-dispatcher 4 层 fallback、stream-state key 拼接、thread.updated/renamed 事件、软删除孤儿处理 …),但运营上的事实是:

  • 真实使用中没人在客户端真的开 thread;多数会话还是回到「一个 channel = 一条主对话」的心智
  • thread 把 reply-dispatcher / stream-state / cursor / 未读 全部多绑一个维度,每次改路由层都要顾两条 path
  • ghost-outbound、丢消息一类可靠性问题的根因里,thread 维度的状态机增加了排查复杂度
  • Daddy 5-07 决定「现在做减法」

移除范围(4 commits + 1 hotfix,约 -4666 LOC ≈ 11% codebase)

commit内容
dc32bd5主清扫:删 thread 类型定义、threadConversationIdresolveInboundConversation thread 分支、reply-dispatcher 第 4 层 fallback、thread.* 事件全套;server.js fanOut 一并下沉到通用路径
b89bd51client-web:拆掉 ThreadSessionCard、hashchange thread 切换监听、thread 历史拉取路由、未读分维度计数
14c356cgateway:删 threads / thread_messages 表读写代码,保留旧表不动;schema migration 20260507_drop_threads.sql 把表 + 索引 + FK 都 drop(重建迁移走数据丢弃路径,不做向前兼容)
58fd43e文档清理:PRD docs/prd/thread-fix-plan.md 标 deprecated;e2e tests/e2e/threads/ 整组移除;REL-06 reliability 测试不再 carry threadId
ce3cf24 (hotfix)CC 在 dc32bd5 误删 fanOut 函数本体(只该删 thread 分支),从 dc32bd5^ 原样恢复 fanOut 主函数

合计 7 个文件 / 2499 行直接删除 + 路由层简化产生的 ~2000 LOC 减少 = -4666 LOC,约占 channel + gateway 仓 11%。1272 个 thread 相关引用(含 threadId / thread_id / threads. 各种)清零。

数据迁移

migration 20260507_drop_threads.sql 直接 DROP TABLE —— 历史 thread 消息一律不保留,不做”扁平化合并到 channel 主流”的复杂迁移(评估:薯条妈妈那种 1v1 通道根本没 thread;研究类长会话的 thread 数据也极少有人回访)。如果将来需要群聊的会话切分,重新设计 sub-conversation 模型,不复活 thread。

经验教训

  1. 加错抽象的代价是每一次维护都要交学费 —— TH-1..TH-8 一轮修完之后没有反思「这个抽象是否真的撑得起业务」,结果是又攒了 3 周状态机复杂度才砍
  2. 「先实现再观察」式的 PRD 容易让团队对一个未被验证的概念过度投入。下次类似抽象(sub-channel / 嵌套会话 / multi-room)应先 1 周纸面沙盘 + 用户访谈
  3. 下架代码也走 first-principles:4 commits 拆得很干净(type → ui → schema → docs),单 commit 出问题方便回滚;hotfix ce3cf24 演示了”AI 删代码不替你看 caller”必然踩的坑——任何超过 200 行的删除 commit 必须人审 fanOut 这种被多处 import 的核心函数

5-08 后续:Batch 2 部分回滚(clawlineBindingsProvider 以去 thread 形态恢复)

5-07 主清扫 (dc32bd5) 把 bindings.ts 整文件删了,连带 clawlineBindingsProvider(channel 注册时挂的非 thread 相关 binding 提供方)一起带走。5-08 修 /api/messages/sync scope 防呆 bug 时(commit 4754d6b,详见 clawline)发现 channel 端 bindings: clawlineBindingsProvider 仍被引用 → channel 启动失败。修法:重建 bindings.ts 但只保留通用 binding(无 thread 字段、无 thread 事件挂载),channel.ts 重新挂回 provider。属于”误删 → 以去 thread 形态恢复”,不是 thread 复活。

相关页面

  • clawline — 同日 npm 发包 + ghost-outbound 修复
  • clawline — server.js 路由层一并瘦身
  • clawline — UI 侧拆除
  • decisions — 5-07 thread 下架决策记录