Repository navigation
fix(cli): CoCo writeInput 改用 paste-buffer + bracketed paste - #4
Merged
Merged
Conversation
…I 0.120.31 fresh-spawn 卡输入框 Trae CLI 0.120.31 (May 2026 build) fresh-spawn 时把密集的 send-keys -l 序列识别成开放式 paste burst, 末尾独立 Enter 也被并入 burst 当软换行处理,消息死在输入框、无 submit 无报错。 改用 pty.pasteText() (tmux load-buffer + paste-buffer -d), tmux 在 pane 启用 bracketed paste 时(Ink TUI 默认开)自动包 \e[200~...\e[201~ markers, CoCo 看到明确的 paste START/END 对,submitDelay 后的 Enter 不再被吞。 claude-code.ts 保留 send-keys-typing 路径不动——Claude Code 在 slash 命令后会 toggle bracketed paste OFF,markers 失效会让 \n 拆成多次 submit,CoCo fresh-spawn 没这个问题。 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
deepcoldy
added a commit
that referenced
this pull request
May 16, 2026
PR #4 / 59afae5 把 coco.writeInput 从 send-keys per-line 软换行改成 tmux pasteText + bracketed paste + delayed Enter,但 test/write-input.test.ts 的 coco 用例还按旧模型断言,全套跑挂 5 个。 把 coco 从 HUMAN_TYPING_ADAPTERS 拆到新的 PASTE_BUFFER_ADAPTERS,新增 BRACKETED_PASTE_FALLBACK_ADAPTERS 覆盖 claude-code/coco 共有的 raw PTY 包 \\x1b[200~ 路径。submit-confirm mock 改成在第一次 Enter 时把上一次 pasteText 的内容写进 history.jsonl;retry 用例期望 1 次提交 Enter + 3 次重试 = 4 次 Enter(旧模型是 6 次)。
bdjasonzjs
referenced
this pull request
in bdjasonzjs/Dbotmux
May 24, 2026
P1 commit #1 (spec v0.4.1 §7) — 类型层 + schema 字段铺底,**无产品逻辑改动**。 所有运行时测试都是 `it.todo` 占位,对应 product commit (#4 / deepcoldy#5) 才打开。 ## 类型 / Schema ### src/services/chat-context-store.ts - 新增 `export type TaskType = 'prd' | 'bug' | 'misc'` - `ChatContext.taskType?: TaskType`(向后兼容:旧 JSON 不写此字段; caller 没传 → undefined → JSON.stringify 不写出 → 旧 reader 不知道新字段) - `CreateOpts.taskType?: TaskType` + `create()` body 写入 ### src/services/group-creator.ts - `CreateGroupOpts.chatContext?: { taskType / relatedRefs / activeTodoRefs / rules / participants / parentDigest }` — types-only - 注释明确:(a) participants 由 caller (Playbook) 推导后传入, group-creator 只透传不推导;(b) idempotencyKey 故意不加,幂等主责 完全在 Playbook + spawn-idempotency-store(v0.4 妹妹 #2) - **body 无任何改动**(commit #4 才接 chatContext → dispatchChatCreated) ### src/im/lark/chat-created-handler.ts - `DispatchChatCreatedOpts` 加 rich fields(relatedRefs / activeTodoRefs / rules / parentDigest / taskType)— types-only - **body 无任何改动**(commit deepcoldy#5 才写入 ChatContext) ## 测试 ### test/group-creator-chatcontext.test.ts(新) - 6 tests:C1 真跑(类型 backward compat) + C2/C3/C9/C10/C-PP-pass `it.todo` - C4/C5/C6/C7/C7b/C8(v0.1-v0.3 老 case)按 v0.4 妹妹 #2 已挪到 spawn-idempotency-store / Playbook 测试 ### test/dispatch-chat-created-rich-context.test.ts(新) - 5 tests:1 个类型断言真跑(rich opts 可编译) + D1/D2/D3/D-PP `it.todo` ## 验证 - `pnpm tsc --noEmit` ✅ - focused 3 文件 / 63 pass + 9 todo / 0 fail - 全量 vitest 2579 pass / 6 fail(全部跟 commit #1 无关:3 个老 CLI binary 缺失测试 + 3 个 EMFILE 系统 fd 耗尽,错误堆栈在 `src/workflows/fanout.ts:93` 系统 watch() 直接抛,跟 schema 改动无关) - **向后兼容回归 e2e**(真飞书建群): - `botmux create-group --bot 克劳德 --name "..."` → Lark 真群建成功 - 写出 ChatContext.json 12 个旧字段全在 + `taskType` 字段缺席 (caller 没传 → JSON 不写)= 老 reader 完全感知不到 schema 变化 - dashboard `/api/topology` HTTP 200,新群被收录 (originType=bot_spawned) - 测试群已归档清理 ## 边界遵守(妹妹 review v0.1-v0.4.1 后五版定下) - group-creator 只建群 + dispatch,不知道 idempotency 概念 - Playbook 独占任务模板 + 权限校验 + 幂等(commit deepcoldy#6 实现) - CLI 是 IPC 薄壳(commit deepcoldy#7 实现) - session 真凭证从 session-store 反查,CLI 不能伪造(commit deepcoldy#6/deepcoldy#8 实现) - BOTMUX_SESSION_ID env 由 worker-spawner 唯一注入(commit deepcoldy#8 实现) 下一步: commit #2 (config mainTopicChatId + 同步 ChatTopology.rootChatId) Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bdjasonzjs
referenced
this pull request
in bdjasonzjs/Dbotmux
May 24, 2026
…ile cache) P1 commit #3 (spec v0.4.1 §2 + 测试 C-IS-1~6) — `getOrCompute(key, compute)` 单一入口,保证同 idempotencyKey 在 24h 内只调一次 compute()。 ## 设计 - **per-key in-process Promise lock**: 并发同 key 共享 inflight promise, winner 跑 compute(), 其他 await 同一 promise 拿 cacheHit=true - **24h TTL** atomic tmp+rename file cache (`~/.botmux/data/group-spawn- idempotency.json`) - compute() throw 时 inflight 清掉,下一次同 key 重试(不会被失败 entry 污染 cache — persist 在 compute resolved 之后) - gc() 扫文件清过期,可由 cron / on-demand 调 ## 架构契约(妹妹 review 系列定的) - CLI **绝不直接 import** 此文件(commit deepcoldy#7 验 CL-5)— CLI 必经 daemon IPC route 才能享受单 daemon inflight Map 的真去重 - group-creator 也不 import — 幂等主责完全在 Playbook + 此 store, group-creator 永远是"建一次群"无脑工具(spec v0.4 妹妹 #2) ## 测试 (test/spawn-idempotency-store.test.ts) | Case | 验 | |---|---| | C-IS-1 | 第一次 cacheHit=false,compute 被调 | | C-IS-2 | 第二次(< TTL)cacheHit=true,compute 不被调,返同 chatId | | C-IS-3 | 第二次(> TTL)cacheHit=false,重新跑 compute | | C-IS-4 | 5 并发同 key Promise.all → compute 恰好调 1 次;exactly 1 winner | | C-IS-5 | compute throw → inflight 清,next 调 fresh 重试 + 拿新 chatId | | C-IS-6 | 文件 atomic 持久(无 .tmp 残留)+ gc 扫过期清干净 | `pnpm vitest run test/spawn-idempotency-store.test.ts` → 6/6 pass。 下一步: commit #4 (group-creator chatContext 接入 + 打开 C2/C3/C9/C10/C-PP-pass) Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bdjasonzjs
referenced
this pull request
in bdjasonzjs/Dbotmux
May 24, 2026
P1 commit #4 (spec v0.4.1 §7) — group-creator 接入 rich chatContext **透传** (taskType / rules / relatedRefs / activeTodoRefs / participants / parentDigest) 给 dispatchChatCreated。**body 仅多 6 行透传**,不做任何派生 / 推导 / 幂等 逻辑(幂等主责在 commit deepcoldy#6 Playbook + commit #3 idempotency-store)。 ## body 改动 (src/services/group-creator.ts) 只在 dispatchChatCreated() 调用点把 opts.chatContext.* 6 个字段透传过去: ```diff await dispatchChatCreated({ chatId: r.chatId, larkAppId: opts.creatorLarkAppId, originType: 'bot_spawned', parentChatId: opts.sourceChatId ?? null, purpose: opts.purpose, + participants: opts.chatContext?.participants, + relatedRefs: opts.chatContext?.relatedRefs, + activeTodoRefs: opts.chatContext?.activeTodoRefs, + rules: opts.chatContext?.rules, + parentDigest: opts.chatContext?.parentDigest, + taskType: opts.chatContext?.taskType, }); ``` dispatchChatCreated body 仍未实现持久化 — commit deepcoldy#5 才写进 ChatContext。 本 commit dispatchChatCreated 接到字段会立刻丢(types 在 #1 接好但 body 没动), **但**调用契约已建立、spy 可以验证字段传递。 ## 测试 (test/group-creator-chatcontext.test.ts) 打开 C2/C3/C9/C10/C-PP-pass(v0.4.1 §7 spec 列的 #4 范围),全部 真跑: | Case | 验证 | |---|---| | C1 (2 cases) | 类型 backward compat + 不传 chatContext 时所有 rich 字段 undefined | | C2 | taskType/rules/relatedRefs/activeTodoRefs 转发给 dispatchChatCreated (spy) | | C3 | parentDigest + sourceChatId 一起转发 | | C9 (2 cases) | 不传 transferOwnerTo 不调 transferChatOwner / 传了才调 | | C10 (2 cases) | 不传 notifyOwnerOpenId 不调 sendMessage / 传了才调 | | C-PP-pass | participants 数组(已 Playbook 推导好)verbatim 透传给 dispatchChatCreated | mock 了 createChat / transferChatOwner / sendMessage / bindOncall / dispatchChatCreated — 都 spy 函数,不打真 Lark。 `pnpm vitest run test/group-creator-chatcontext.test.ts` → 9/9 pass ## 不破回归 - 全 focused tests 仍过(C1 backward compat 已断言) - 旧 caller (/group / dashboard create) 不传 chatContext → undefined 透传 → dispatchChatCreated 收到的 rich 字段全 undefined → 等价 commit #1 之前行为 下一步: commit deepcoldy#5 (dispatchChatCreated body 写入 ChatContext rich fields) Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bdjasonzjs
referenced
this pull request
in bdjasonzjs/Dbotmux
May 24, 2026
…MessageId) P2 commit #1 (design v0.3 §2 P2) — RootInbox 持久化 progress-item 通道 (dedup + update + close)。escalation-playbook (commit #2) 把 R1-R5 push 到此 store;commit #3 接 close 语义;commit deepcoldy#5 progress-report CLI 走 同通道。 ## 设计要点 (妹妹 review v0.3 决定) - 持久化:`~/.botmux/data/root-inbox.json` (atomic tmp+rename) - dedup key = `buildId(kind, ruleId/subChatId/slug)` 决定性,同 key 连续触发只 update 不 insert - 'closed' is **terminal**:close 后同 id 再 upsert 不复活 (避免老问题 自动 reopen),妹妹 review v0.3 #1 cooldown ≠ close 配套 - `rootCardMessageId` 字段记 Lark 主话题渲染出的卡片 messageId; commit #2 用 Lark `updateMessage(rootCardMessageId, ...)` 编辑原卡 (不是 reply 追加,妹妹 review v0.3 #2) - 三种 kind: escalation / progress / request_decision; daily_digest 走独立通道不进 RootInbox (妹妹 review v0.3 #4) ## API ```ts buildId({kind, ruleId/slug, subChatId}) // 决定性 id upsertOpen({id, kind, subChatId, subChatName, ruleId?, summary}) → {item, inserted} // 已 closed → no-op 返 existing setRootCardMessageId(id, msgId) // commit #2 用 close(id) // 幂等 listAll() / listOpen() / lookup(id) __clearForTesting() ``` ## 测试 (test/root-inbox-store.test.ts) — 16/16 pass - buildId 三种 kind 决定性 - upsertOpen 首次 inserted=true / 二次 inserted=false updated count++ - firstSeenAt 保持 / lastUpdatedAt bump - close 终态:再 upsert 不复活 - close 幂等 - setRootCardMessageId 写入 / missing id 返 null - listOpen 排除 closed / listAll 按 lastUpdatedAt desc - atomic file write 无 .tmp 残留 ## 不破回归 - 全新文件 + 测试,零现有代码改动 - 不接 sink (escalation-playbook) 也不动 — commit #2 才接 下一步: commit #2 (escalation-playbook 接 RootInbox sink + Lark updateMessage 编辑原卡) Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bdjasonzjs
referenced
this pull request
in bdjasonzjs/Dbotmux
May 24, 2026
P2 commit #3 (design v0.3 §2 P2 close 语义条 2 + 4) — RootInbox 多触发点 都能正确关 item,不依赖 cooldown(妹妹 review v0.3 #1 cooldown ≠ close 红线)。 ## 实现 ### src/services/root-inbox-store.ts - 新增 `closeAllForSubChat(subChatId)`: 批量关本 subChatId 所有 open items,返关闭数量。chat-context-store 归档触发用。 - close 已在 commit #1 实现,本 commit 加 closeAllForSubChat。 ### src/services/chat-context-store.ts - `archive(chatId)` 加 side effect: lazy-import root-inbox-store, 调 `closeAllForSubChat(chatId)`。fire-and-forget 模式,失败 log warn 不阻塞 archive 主路径。 - 理由:子群被归档 = 任务完成 / 不再讨论,挂它名下的 escalation / progress / request_decision 都自然 stale,应自动关。避免归档后 scout 又重新 fire 同 R5(不会,因为 commit deepcoldy#6 P6 已 filter archived out of escalation rules)+ 主话题卡片继续亮着的诡异状态。 ### src/dashboard.ts - 新增 `GET /api/root-inbox` (default 只返 open,?include_closed=1 全返) - 新增 `POST /api/root-inbox/:id/close` — 手动关 - 都走 cookie auth 与其他 dashboard route 一致 ## 测试 ### test/root-inbox-store.test.ts (+3 = 19/19 pass) - closeAllForSubChat:只关匹配 subChatId 的 open,返计数 - closeAllForSubChat:skip 已 closed item,返 0 - closeAllForSubChat:subChatId 无 item → 返 0 ### test/chat-context-store.test.ts 没回归 (61/61 pass) - archive() 加 side effect 但同步返值不变,旧 case 全过 ### test/escalation-playbook.test.ts 没回归 (10/10 pass) - 不涉及 close 语义 ## 不破回归 - chat-context-store.archive() 同步签名 + 同步语义 100% 不变 - side effect 走 lazy import + fire-and-forget,失败仅 log warn - 无 main-topic 配置场景下 root-inbox-store 空 → closeAllForSubChat 返 0 不抛 - dashboard 新路由不影响旧路由 下一步: commit #4 (scout 确认条件消失自动 close + scout 接 root-inbox 同 dedup) Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bdjasonzjs
referenced
this pull request
in bdjasonzjs/Dbotmux
May 24, 2026
P2 commit #4 (design v0.3 §2 close 语义条 3) — scout tick 跑完 runEscalationRules 后,对每个 open R1/R3/R5 root-inbox item 检查同 (ruleId, chatId) 是否还在 newEscalations 里;若不在 → 条件消失 → close。 R2 / R4 不参与自动 close(聚合 / count-based,false-positive 风险高)。 ## 实现 ### src/core/scout-spawner.ts - 在 enqueueEscalation 循环后加 auto-close pass: - 构 stillFiring = Set("R1:chatId" | "R3:chatId" | "R5:chatId") - 遍历 root.listOpen(): - kind != 'escalation' 跳 - ruleId 不是 R1/R3/R5 跳 - subChatId 已 archived 跳(commit #3 已关,defensive) - 不在 stillFiring → root.close(id) + 计数 - log info "auto-closed N items" - 全程 try/catch,root-inbox 失败仅 log warn 不阻塞 scout ## 测试 (test/scout-spawner-bot-spawned-filter.test.ts +1 = 6/6 pass) 新 case "P2 #4: scout auto-closes root-inbox when escalation condition stops firing": 1. 节点 summary 含 "blocked" → R5 触发 2. 手动注入 open R5:oc_x root-inbox item 3. tick 1: R5 仍触发 → 不 close(仍 open) 4. summary 改成 "CI fixed" → R5 不再触发 5. tick 2: scout 检测 stillFiring 不含 "R5:oc_x" → 自动 close → root.lookup status='closed' ## 不破回归 - 关联测试全过 (114 + 1 = 115) - R2 / R4 不动(避免聚合 escalation 误关) - root-inbox 失败包 try/catch,不阻塞 scout 主路径 下一步: commit deepcoldy#5 (botmux progress-report CLI — 主 bot 在子群完成阶段 任务时主动汇报到 root-inbox) Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bdjasonzjs
referenced
this pull request
in bdjasonzjs/Dbotmux
May 24, 2026
P2 v0.2 (妹妹 review v0.1) 4 修正: ## #1 — scout auto-close 改用 RAW condition evaluator(非 newEscalations) bug: `runEscalationRules` 返 dedup/cooldown 过滤后的 escalations。R5 cooldown 抑制了 enqueue 时 newEscalations 为空 → scout 误判"条件消失" → 错关 RootInbox item,踩了我们 P1 review 定的"cooldown ≠ close"红线。 修: - `src/core/escalation-rules.ts` 新 export `evaluateRawConditions(input): Set<string>` — 跑 R1/R3/R5 但跳过 dedup/cooldown,返 `${ruleId}:${chatId}` - `src/core/scout-spawner.ts` 自动 close 改用 evaluateRawConditions 构造 stillFiring,cooldown 时仍判"条件还在" → 不误关 ## #2 — closed escalation 加 generation suffix,允许 reopen 新 lifecycle bug: escalation id 固定 `${ruleId}:${chatId}`。一旦 close(archive/scout/ manual 任一路径),未来同子群再 R5 → sink 调 upsertOpen 会被静默吃掉, 主话题永久失声。 修(按妹妹建议方案 a — generation 后缀新 lifecycle,不复活旧卡): - `src/services/root-inbox-store.ts` `upsertOpen()` 加 `allowReopen?: boolean` - allowReopen=true + closed → 新增带 `#N+1` 后缀的新 item(新卡新 lifecycle) - allowReopen=false(progress/request_decision 走 slug 改名)→ 旧行为 - 返结果含 `reopenedGeneration?: number` 让 caller 知道这是 reopen - 内部按 baseId prefix 匹配同基础 id 的所有 generations - escalation-playbook sink 调用时 allowReopen=true ## #3 — close 三路径都更新 Lark 卡置灰 + 抽 root-inbox-card-renderer bug: chat-archive / scout auto-close / dashboard manual close 三路径只 改 store status,没 updateMessage 把主话题卡置灰 → store 关了卡仍亮, 违反 spec "close 卡片置灰" 设计。 修(同时按妹妹建议把 escalation-sink + publisher 重复 send/update/fallback 链合并): - 新 `src/services/root-inbox-card-renderer.ts`: - `renderRootInboxCard(item)` — 统一卡片 JSON layout(escalation / progress / request_decision 共用,按 kind/status emoji 区分) - `sendOrUpdateCard(larkAppId, mainTopic, item)` — send/update/fallback fresh-send 链单一来源(消灭 escalation-sink + publisher 各自一份) - `closeAndRenderClosed(id, larkAppId)` — store close + updateMessage 主话题卡 grayed 状态 (✅ + "已关闭" badge) - `closeAllForSubChatWithCards(subChatId)` — 批量关 + 每条 update card - `src/core/escalation-playbook.ts` sink 改用 sendOrUpdateCard(删自己 的 buildEscalationCard + send/update 内联逻辑) - `src/services/root-inbox-publisher.ts` publish 改用 sendOrUpdateCard (删自己的 buildCard + send/update 内联逻辑) - `src/services/chat-context-store.ts` archive 改用 closeAllForSubChatWithCards(lazy import + fire-and-forget) - `src/core/scout-spawner.ts` auto-close 改用 closeAndRenderClosed - `src/dashboard.ts` POST /api/root-inbox/:id/close 改用 closeAndRenderClosed (fallback 失败回退到 store-only close 保 dashboard 不 break) ## #4 — progress-report 删 --sub-chat-id flag,subChatId 强制 session.chatId bug: CLI `--sub-chat-id` flag 让任意 Claude session 替任意 chat 写 RootInbox 项,可伪造。 修: - `src/cli/progress-report.ts` 删 `--sub-chat-id` flag + interface 字段 - `src/daemon.ts` /api/progress-report 强制 `subChatId = session.chatId` (不再 `?? body.subChatId`) - 注释明确:如未来需要 root 代报子群,要新增独立 API + 校验 bot_spawned parent,留 follow-up ## 测试 - `test/escalation-rules.test.ts` +4 case: evaluateRawConditions 覆盖 (cooldown 时仍判 raw / R3 fire / R2 R4 skip / 无触发返空) - `test/root-inbox-store.test.ts` +4 case: allowReopen 行为 (closed+reopen=true→#2 / closed+reopen=false→旧 / open+reopen 不增 gen / 多代 close → max+1) - `test/root-inbox-card-renderer.test.ts` 新文件 10 case: renderCard 4 / sendOrUpdateCard 3 / closeAndRenderClosed 5 - 7 文件 / 138 tests / 0 fail ## 不破回归 - progress / request_decision 默认 allowReopen=false → 与 commit #1 行为完全等价 - escalation-playbook 旧 sink 行为等价(只是底层换 renderer 调用) - publisher 旧调用方等价 - 现有测试全过(chat-context-store 61 / publisher 5 / playbook 10 / scout 6 全无回归) 下一步: 等妹妹复核 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bdjasonzjs
referenced
this pull request
in bdjasonzjs/Dbotmux
May 24, 2026
妹妹 review v0.2 唯一非 blocker — `src/daemon.ts:1294` 注释还写
`Body: { ... subChatId?, ... }`,但 v0.2 #4 已删 subChatId from body
type + 强制用 session.chatId。注释更新避免读者误以为还接收该字段。
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bdjasonzjs
referenced
this pull request
in bdjasonzjs/Dbotmux
May 24, 2026
P3 commit #2 — 缇蕾每 15min 调 lark-cli 拉松松所有参与 chat 的消息流, 按 [start, end) 时间窗 + chat 排除 + tilly-message-store dedup 过滤, 返回 normalized list 供 commit #3 LLM 分析。 ## 设计 - `fetchRecentMessages(opts)`: spawn `lark-cli im +messages-search --as user --start <iso> --end <iso> --page-all --format json` - 解 JSON 中 `data.messages[]`,normalize 成 `TillyMessage` shape: messageId / chatId / chatName / chatType / senderId / senderType / msgType / content / createTime / threadId? / appLink? - 按 `opts.excludeChatIds` 过滤 - 调 `tilly-message-store.filterUnscanned()` 过 dedup - 返 fresh messages(caller 处理完才调 markScanned) - 失败抛错 — daemon cron 接住 + log + skip tick - `groupByChat(messages)`: chat → messages map + 按 createTime asc 排 (chronological),便于 LLM prompt 按 chat 组织上下文 ## 测试 (test/tilly-scout.test.ts) — 6/6 pass mock 一个 shell fake-lark-cli 写 JSON 到 stdout(不需要真 lark): - 正常 fetch + normalize 字段 - dedup 已 scanned 的 message - excludeChatIds filter - 空消息列表 - lark-cli 退码 non-zero 抛错 - groupByChat 排序 ## 不依赖 - 不分析消息内容(commit #3 LLM 才做) - 不 push 卡片(commit #4 publisher + cron 串) - 不调度 cron(commit deepcoldy#5 daemon 才接) 下一步: commit #3 (缇蕾 LLM worker — spawn codex exec 跑 prompt 抽 4 类 + JSON 输出) Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bdjasonzjs
referenced
this pull request
in bdjasonzjs/Dbotmux
May 24, 2026
P3 commit #3 — 缇蕾真 LLM 入口。给 commit #2 fetch 出来的 normalized messages,spawn `codex exec` 跑 prompt + JSON schema validation,输出 TillyDigest(todos / progress / blockers / noteworthy)。 ## 实现 src/services/tilly-llm-analyzer.ts - prompt 模板:分 4 类抽取标准(todos = 松松未做的工作 / progress = 阶段进展 / blockers = 卡点 / noteworthy = 有意思话题)+ 每类最多 5 条 + 严格 JSON 输出 - 渲染消息流:按 chat 分组 + chronological,content 超 500 字截 - 调用: ``` codex exec --ephemeral --skip-git-repo-check --dangerously-bypass-approvals-and-sandbox --output-schema /tmp/schema.json --output-last-message /tmp/out.json <prompt> ``` - 解 JSON: 直接 parse → fallback 找 JSON object 块(应对 markdown 包裹) - 输出 sanitize:required field 缺 → drop;每类 cap 5;enrich sourceChatName - 失败 fallback: 返空 digest + ok=false + error 字段(不阻塞 cron) - 5 min 超时(codex 启动 ~30s + LLM ~10s 足够) ## 测试 (test/tilly-llm-analyzer.test.ts) — 8/8 pass mock 一个 fake codex shell 写 JSON 到 --output-last-message: - empty messages → empty digest ok=true (skips codex) - dryRun → empty digest - valid 4-bucket JSON → 解析 + 字段 enrich (sourceChatName) - codex exit non-zero → fallback empty + ok=false + error - codex 输出非 JSON → parse fail → ok=false - JSON 包在 markdown 里 → 提取 + 解析 - LLM 返超过 5 条 → cap 5 - 缺 required field 的 item → drop 下一步: commit #4 (RootInbox kind='tilly_digest' + 主话题汇总卡 renderer) Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bdjasonzjs
referenced
this pull request
in bdjasonzjs/Dbotmux
May 24, 2026
…illy_digest' P3 commit #4 — 缇蕾每日 cumulative digest 持久化 + 渲染主话题汇总卡。 ## 新增 src/services/tilly-digest-store.ts - `getCurrentDigest()` — 读今日 cumulative,跨日自动 archive + reset - `mergeNewDigest(fresh)` — 每 15min tick 出来的 4 类 incoming merge 进 当日 list,按 sourceMessageId dedup (first-write-wins) - `getDateId()` — YYYY-MM-DD UTC - `totalCount(d)` — 4 类总和 - 持久化 `tilly-digest-current.json` + 7 天 archive `tilly-digest-archive.json` - 测试 6/6 pass (rollover / merge / dedup / 持久化 / totalCount) ## 新增 src/services/tilly-publisher.ts - `renderTillyCardContent(d)` — 4 section markdown (📝 待办 / ✅ 进展 / 🚧 卡点 / 💡 值得记) + 头部 today date + tick 数 + 最新 tick 时间 - `publishTillyDigest(digest, opts)` — upsertOpen `tilly_digest:<dateId>` + sendOrUpdateCard 给 mainTopic。同一天的 tick 共编辑同张卡(不刷 屏),跨日自动新卡。 - allowReopen=true: 若手动 close 后下次 tick 仍创新 lifecycle - mainTopic 未配 → 静默跳过 send(store still updated) ## src/services/root-inbox-store.ts + root-inbox-card-renderer.ts - `RootInboxKind` 加 `'tilly_digest'` to union - KIND_EMOJI / KIND_LABEL 加 🐶 / "缇蕾每日扫读" ## 不破回归 - 5 文件 root-inbox / tilly 子模块 共 55 tests 仍全过 - escalation / progress / request_decision 旧 kind 不变 下一步: commit deepcoldy#5 (daemon cron 15min trigger — fetch → analyze → merge → publish 端到端串) Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bdjasonzjs
referenced
this pull request
in bdjasonzjs/Dbotmux
May 24, 2026
P3 v0.2 — 妹妹 review v0.1 6 条全修,加上 2 个 implementation 细节 建议(analyzedMessageIds 来自 kept set / 不靠 summary hack)。 ## Blocker fixes ### #1 — prompt 加 messageId + 校验 sourceMessageId ∈ input set bug: LLM 输出 sourceMessageId 必须,但 prompt 没给真 id 让它知道,必 hallucinate;hallucinated id 进 mergeNewDigest dedup 后追溯不可信。 修 src/services/tilly-llm-analyzer.ts: - 渲染消息行加 `id=<messageId>` 前缀(hard ID anchor for LLM) - prompt 写明"sourceMessageId 必须是真实 id,造假 drop" - enrich() 增强 validate:includedIdSet.has(it.sourceMessageId) 才保留, 否则 drop + log debug - sourceChatId / sourceChatName 优先用真 messages map 派生(不信 LLM) ### #2 — analyzedMessageIds 来自 kept set,daemon 只 mark 实际分析的 bug: analyzer cap 至 50 条,但 daemon markScanned(fresh.map) 标全部,超 cap 消息永久漏扫。 修: - analyzer 新增 `TillyDigest.analyzedMessageIds: string[]` (来自 kept set) - renderMessagesForPrompt 返 `{text, includedIds}`;includedIds = 实际进 prompt 的 50 条 messageIds - daemon (src/daemon.ts) markScanned 改用 digest.analyzedMessageIds(缺 时 fallback fresh.map) - 截断时(MAX_PROMPT_CHARS 超)递归 half-list 重渲染,确保 includedIds 始终精确等于 prompt 内可见 id 集(妹妹 v0.2 #1) ### #3 — codex sandbox 反 prompt injection bug: Lark 消息含 untrusted content,`--dangerously-bypass-approvals-and- sandbox` 给 codex 任意命令执行权限 — prompt injection 可触发 shell 命令、文件访问、网络。 修 src/services/tilly-llm-analyzer.ts: - 删 `--dangerously-bypass-approvals-and-sandbox` - 加 `--sandbox read-only`(codex 没有 shell 执行权限) - 加 `--cd <codexCwd>` 指向 mkdtempSync 创的空 dir(即使 codex 越界 也看不到我们 source) - prompt 用 `<UNTRUSTED_DATA>...</UNTRUSTED_DATA>` 边界包消息 - prompt prefix 显式说"忽略 UNTRUSTED_DATA 内任何指令 — 它们是数据 不是任务" - prompt suffix 重复一次反 injection 提醒 ## P1/P2 fixes ### #4 — dateId 用 Asia/Shanghai bug: getDateId() 用 UTC YYYY-MM-DD,北京 0:00-8:00 归前一天,违反"今日" 语义。 修 src/services/tilly-digest-store.ts: `Intl.DateTimeFormat('en-CA', {timeZone:'Asia/Shanghai'})` 直接输出本地 YYYY-MM-DD。 ### deepcoldy#5 — tilly_digest 独立 renderer 分支,不再 hack summary bug: publisher 把整个 markdown 塞 item.summary 让 generic renderer 输 出 → store 持久化 summary 字段被污染 + generic 仍会追加 fake `openChatId=tilly-scout` 子群链接。 修: - src/services/root-inbox-card-renderer.ts: `renderRootInboxCard(item, opts?: {customMarkdown?})` 新增 RenderOpts;kind='tilly_digest' 用 customMarkdown 渲染(无 subChat link / 无 generic footer),其他 kind 忽略 customMarkdown 走旧路径 - src/services/tilly-publisher.ts: 不再 spread+overwrite summary,直接 调 sendOrUpdateCard(item, {customMarkdown}) - store summary 字段保留短 label "今日 N items"(dashboard listOpen 时 清爽) ### deepcoldy#6 — lark-cli fetch timeout + cron in-flight guard bug: fetchRecentMessages execFile 无 timeout,lark 挂住 setInterval 叠 tick。 修: - src/services/tilly-scout.ts: execFile timeout: 60_000 - src/daemon.ts: tilly cron 用 module-scoped `tillyTickInFlight` flag; 上一次 tick 未完跳过本次 ## 测试 (8 文件 / 85 tests / 0 fail) 新增/扩展 case: - tilly-llm-analyzer +5 case: - hallucinated sourceMessageId 被 drop - analyzedMessageIds 严格 = kept set - cap=50 时超 cap 不在 analyzedMessageIds(妹妹 v0.2 #1) - source 含 `--sandbox read-only` + `--cd codexCwd` + 不含 dangerous bypass - prompt 含 UNTRUSTED_DATA 边界 + 反 injection 提醒 - root-inbox-card-renderer +3 case: - tilly_digest 用 customMarkdown,无 openChatId=tilly-scout fake link - tilly_digest 缺 customMarkdown → fallback 提醒 - 其他 kind 忽略 customMarkdown 走旧路径 - tilly-digest-store +1 case: - getDateId Asia/Shanghai:UTC 16:30 → 当地次日;UTC 23:59 → 当地次日 ## 不破回归 - escalation-playbook / root-inbox-publisher / root-inbox-store 所有旧 case 100% 仍过 - generic kind (escalation / progress / request_decision) 渲染逻辑不变 - daemon scout cron 不变 下一步: 等妹妹复核 → e2e 跑 1 轮看真效果 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bdjasonzjs
referenced
this pull request
in bdjasonzjs/Dbotmux
May 27, 2026
…box dismiss/processed 按妹妹 v2 review #2 + #4 + deepcoldy#5: ## 新路由 1. **`GET /api/tilly-digest`** — cumulative 追溯入口 - 读 `tilly-digest-store.getCurrentDigest()` + `listArchive()` - 返 `{ current: <今日 4 类完整>, archive: [...过去 7 天 days] }` - **不读** `main-bot-digest.json` (那是 R1-R5 escalation 线,妹妹 v2 #2 强调) 2. **`POST /api/scout-inbox/:id/dismiss`** 3. **`POST /api/scout-inbox/:id/processed`** - 调 `dispositionTillyHigh(id, {status, handledBy:'dashboard:user'})` - 仅作用于 `type==='tilly_digest_high'` (store 层 dispositionTillyHigh 有类型守卫,escalation item 返 null → 路由返 404) - **不和 root-inbox.close 混** (RootInbox 是另一套 store,妹妹 v2 deepcoldy#5) - 404 message 说明 "id 不存在或不是 tilly_digest_high 类" ## 新 store API - `tilly-digest-store.ts`: 新增 `listArchive()` export (内部 readArchive 外露给 dashboard / future tests) ## 实拍 `curl /api/tilly-digest`: ``` keys: ['current', 'archive'] current.dateId: 2026-05-25 current totals: {'todos': 64, 'progress': 126, 'blockers': 76, 'noteworthy': 107} archive days: 0 (今天首发跨日 archive 还没生) ``` build+restart 完。commit 5 (前端新 tab) 把这两个路由用起来。 - src/services/tilly-digest-store.ts: + listArchive() - src/dashboard.ts: + GET /api/tilly-digest, POST /api/scout-inbox/:id/(dismiss|processed) Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bdjasonzjs
referenced
this pull request
in bdjasonzjs/Dbotmux
May 27, 2026
…DLED_TOPICS 数据源)
为 commit 4 缇蕾 prompt 注入 KNOWN_HANDLED_TOPICS 准备数据源。让 coco
LLM 看到"这些卡点松松/克劳德已经处理过 (dismissed/processed) 别再报",
跨 sourceMessageId 语义 dedup。
API: `listRecentHandledHigh({maxAgeHours=24, limit=20}): ScoutTillyHighItem[]`
约束 (妹妹 v2.1 review #4 + commit 3 challenges):
- 只取 type==='tilly_digest_high' (不混 escalation R1-R5)
- 只取 status ∈ {processed, dismissed} (pending 不算)
- 数据来源 readInbox().processed (dispositionTillyHigh 已 splice 到此)
- 按 handledAt 倒序 (最新先)
- maxAgeHours 截断老 item (默认 24h, 避免冲淡 prompt context)
- limit 截断 (默认 20, 控 prompt size — 妹妹 v2 #4 强调 capped=20)
- handledAt missing/invalid 的 item drop (不允许无时间 item 排 top —
防止脏数据假装"最新已处理")
regression test +7:
- 空 inbox → []
- type 守卫 (escalation resolved 不入结果)
- status 守卫 (pending 不入)
- 按 handledAt 倒序
- maxAgeHours 截断 (默认 24h / 显式 48h)
- limit 截断 (默认 20 / 显式 5)
- handledAt invalid drop
跑:30/30 store test pass.
- src/services/main-bot-digest-store.ts: +listRecentHandledHigh
- test/main-bot-digest-store.test.ts: +7 case
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bdjasonzjs
referenced
this pull request
in bdjasonzjs/Dbotmux
May 27, 2026
按 PRD 原设计 + 妹妹 v2.1 review #4 收紧: ## 实现 1. **PROMPT_PREFIX 加 "降噪规则" 段**: - 明确告诉 LLM: 相似已处理主题不要再次输出 - 例外: (a) 新明确人类请求 / (b) 新证据 → 仍输出 - **明确这是降噪 hint 不是 correctness gate** — 犹豫时倾向输出 2. **KNOWN_HANDLED_TOPICS 块结构化 JSON** (妹妹强调不要长自然语言): - 字段: {category, summary (150 char cap), sourceChatName (30 char cap), handledAt ISO, status} - sanitizeKnownText 剥所有 0x00-0x1F + 0x7F 控制字符 + 截断 - 空数组时 emit `<KNOWN_HANDLED_TOPICS>[]</KNOWN_HANDLED_TOPICS>` 3. **analyzeMessages 加 knownHandled opt**: - 生产路径 daemon 调 listRecentHandledHigh({maxAgeHours:24, limit:20}) 传入 - 测试直接 mock 4. **buildKnownHandledBlock** + replace PROMPT_PREFIX 的 placeholder `<KNOWN_HANDLED_TOPICS_PLACEHOLDER />` → 实际 block ## 与 store dedup 关系 - store dedup (sourceMessageId) 是 hard truth — 同 msgId 永远不重入 - LLM 降噪 (语义) 是 soft hint — 跨 msgId 同义卡点不再输出 - 两层独立:known-handled 只影响 LLM 输出,不动 store 行为 ## regression test +3 - knownHandled=[] → prompt 含 `<KNOWN_HANDLED_TOPICS>[]</...>` - knownHandled 非空 → prompt 含结构化 JSON + summary 截 150 + 控字符剥 + sourceChatName 截 30 + handledAt/category/status 字段正确 - PROMPT_PREFIX source code 含 "相似已处理跳过 / 仍要输出 / 不是 gate" 关键文案 (防未来回归改没了) 跑:17/17 analyzer test pass. build + restart 完。下一次 daemon cron tick 将首次带 KNOWN_HANDLED_TOPICS 跑,可观察 reuse % 下降。commit 5 加 e2e regression fixtures 收尾。 - src/services/tilly-llm-analyzer.ts: + buildKnownHandledBlock + sanitizeKnownText; PROMPT_PREFIX +降噪规则段 +placeholder; AnalyzeOpts +knownHandled - src/daemon.ts: tick analyze 前 listRecentHandledHigh({24h,20}) 注入 - test/tilly-llm-analyzer.test.ts: +3 case Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
deepcoldy
added a commit
that referenced
this pull request
May 27, 2026
#4 webhook 接入点搬进主 dashboard: - 新增侧边栏「接入点」+ SPA 页 web/connectors.ts(#/connectors):列出接入点、 重设计的创建表单(卡片式、与 dashboard 一致主题),支持启用/停用、删除、复制 webhook URL、创建后一次性显示密钥。 - 后端 handleConnectorApi 早已挂在 dashboard token 网关后(/api/connectors*), 无需改鉴权;新页直接调用。 - 表单按 投递模式 动态显隐(fixed→群 ID、dynamic/new-group→允许的群、 new-group→去重/状态字段、workflow→工作流 ID)。 #5 去掉「来源类型」: - ConnectorDefinition 移除 source{type,displayName}(人类标签用 promptEnvelope.sourceName); ConnectorSourceType 类型删除。 - connector-api 不再解析/校验 source.type(去掉 bad_source_type)。 - webhook 入站构造的 trigger envelope source.type='webhook'(投递渠道,与连接器无关)不受影响。 - 连接器测试 fixture 去掉 source 字段。 注:老 /team 页(含旧创建表单)将在下一步 #3 删除。connector/trigger/webhook/team 6 文件 49 测试全过、tsc+build 干净。
bdjasonzjs
referenced
this pull request
in bdjasonzjs/Dbotmux
Jun 12, 2026
收尾自检遗留 deepcoldy#5:newDepth >= MAX_SUBTASK_DEPTH 时授 spawnable 无意义—— 其子群再 spawn 必被 G2 拦,注入段还会出现「还能开 0 层」的误导文案。 create 入口直接 400(输入校验,非 fork-bomb 闸,主话题分支同样适用—— spawnable 是本特性新增字段,无存量行为可破坏)。不带 --spawnable 不受影响。 遗留 #1/#2(投递确认假阴性、finished 父群迟到消息)属 M0 传输层独立任务, #4(G6 树级限速语义)待真实使用数据,均不在本任务顺手修——见任务文档 §十。 Co-Authored-By: Claude Fable 5 <[email protected]>
sensuossss
added a commit
that referenced
this pull request
Jun 24, 2026
按多 agent review 逐条修(合入 master 前): High - #1 runtime: revisit 后 D#001/D#002 同 node.id 并发,inFlight/nodeControllers/ nodeAbortCleanups 改按 dispatchKey(instance) 存取 + 守卫删除;cancel 按 instance abort。原先无守卫 inFlight.delete(node.id) 会删掉活着的新实例 → 整 run 误崩。 - #2 host: architect 手搓 BotSnapshot 漏 disableCliBypass → 受限 bot 在 architect 步骤悄悄提权。改用权威 botToSnapshot()。 - #3 architect: 复用 attempts/001 不清旧 manifest,watcher 见旧 manifest 直接 finish('ok') → revise-dag 后修订不生效。dispatch 前 rmSync(attemptDir)。 - #4 test: 加 runWorkflow 集成测试,断言 restricted override 真的写进 worker 的 req.botSnapshot.disableCliBypass(降权红线看门)。 Medium - #5/#12 daemon-run: driveV3Run 顶部记 wasAlreadyTerminal,已终态短路,避免 coalesce 重驱 / "/start" 重试重发 gate 卡与 done/failed 消息。 - #6 security: gate handler 的 waitId 未校验就 path-join → 加 isValidWaitId (含 # 给 A#001-gate 形态) 拦 ../ 逃逸。 - #7 dashboard: catalog 前缀路由用 startsWith 误吞 runId 以 catalog 开头的 v3 run 详情页 → 改带边界正则。(本就是合并时我引入的) - #8 daemon: 线程内 "/workflow new" grill fall-through 时 cmdContent 仍是字面量, 被待回答 ask 拦截器当答案吞掉 → ask 拦截加 !threadGrill。 - #9 test: 补 manifest 软链逃逸(symlink→外部)的拒绝用例,防 realpath 被简化成 resolve。 Nit - #16 v3-blocked handler: String(formValue) 把 object/array 强转成非空垃圾过校验 → 改 typeof==='string'。 - #17 v3.ts: 抽 isTerminalRunStatus(),统一 poll/loop 的终态停轮判定(消死代码)。 校验:pnpm build 通过;v3/daemon/dashboard 相关单测全绿(含新增 2 条)。
This was referenced Jul 26, 2026
deepcoldy
added a commit
that referenced
this pull request
Aug 6, 2026
…locker) codex 二轮 review(4878071011)7 blocker,按其拍定的 v3 设计重写。核心:lease 只管 「是否允许派发」,async-trigger-store 管「调用方看到的终态」——两者职责分离,不再靠 第三份 tombstone/index,也不靠 closeSession 成功来定义业务终态。 - #6(最核心,terminal 不接进 trigger-result):async-trigger-store 扩 status pending|completed|**failed**(failed 带 errorCode:no_output, reason:dispatch_unknown)。 新增 recordFailedStrict(per-session withFileLockSync + atomicWriteFileSync durable + 抛错, 与 recordCompleted 同锁串行,completed 更强证据恒胜)。resolveAsyncTriggerState 新增 durable-failed 分支(优先级 completed > failed > closed > pending)——即使 reconcile 的 closeSession 抛错、session 保持 open,trigger-result 也收敛 failed,不永久 running。 - #1(replace 非原子撕 tombstone):idempotency-store 全部改 atomicWriteFileSync(tmp+fsync +rename,失败保留旧文件),干掉 unlink→link。 - #2(takeover 非精确 CAS + 丢 won/existing):takeover 返回 {won|existing},锁内对完整 immutable identity(owner+boot+session+trigger+requestHash+revision)精确校验;stale rev1 不能覆盖 fresh winner rev1(新增回归测试)。lease 状态精简为 reserved|attempting(terminal 移出到 async-store)。 - #3(reconcile 跨 bot):reconcileIdempotencyLeasesOnBoot(ownerLarkAppId, currentBootId) 显式传 owner,读写/close 前 fail-closed 过滤 record.ownerLarkAppId,跳过 current boot。 - #4(reconcile 在 bind 之后):移到 setActiveSessionsRegistry 之后、startIpcServer 之前 (daemon.ts)。返回 quarantine Set 传入 restoreActiveSessions,被 terminalize 的 session 排除 re-attach(防状态/执行面分叉)。 - #5(本 boot 失败留坏 lease):barrier 前失败 compareAndRemove 释放 reserved(重试可全新); barrier 后 dispatch 同步 throw → recordFailedStrict + close(durable failed,不重派)。 - #7(HTTP 契约):trigger status mapper 加 idempotency_conflict→409;idempotent 的 state:failed 视作 200(成功 HTTP 调用报终态,非请求错误)。 - 所有 claim/takeover/transition/compareAndRemove 走同一 per-key withFileLockSync(rename 只原子替换≠CAS,必须锁内 read→校验→写)。withKeyLock/ensureDir 保证 .lock 父目录存在。 验证:pnpm build 通过。测试真穿状态机崩溃点——idempotency-store 16(含 stale-rev1 竞争 / corrupt fail-closed / compareAndRemove CAS);trigger-session-idempotency 12(真 store: attempting-orphan→async failed+close+quarantine / reserved-orphan→删+close / completed 留 / current-boot 跳过 / **OTHER-owner 跨 bot 零触碰**);trigger-api 校验+范围拒绝;async-store/ state/api-only-wiring(readiness 序不变) 全绿。affected+shared-path 11 套件 327/327 绿。 docs-site build 绿。不带 key 的普通 trigger/webhook 行为零变化。 Co-Authored-By: Claude <[email protected]>
deepcoldy
added a commit
that referenced
this pull request
Aug 7, 2026
四处收口,全部 fail-closed / owner 正向背书: 1. attempt-barrier 失败释放:compareAndRemove 改返回判别式结果 (removed|absent|changed),不再吞 false/异常。干净移除→重试全新; changed→attempting(rename 落盘后 fsync 抛,即已跨越的 commit-unknown fence)→durable recordFailedStrict 并返回**可观测 state:failed**(非裸 5xx);compareAndRemove 抛(EIO/损坏)→诚实 5xx,lease 留给下轮 reconcile。 另:resolveIdempotencyHit 改以 LIVE-ness(而非 ownerBootId)判定"真正在飞": attempting/reserved + 同 boot + 无 live worker → terminal,杜绝同 boot 无限复用。 2. boot reconcile:compareAndRemoveByPath 返回判别式结果;对 changed→attempting 重分类为已跨越 fence(durable terminalize,绝不删),changed→current boot 跳过 (在飞),其余不可证明收敛→fail-closed 抛。store 侧锁内二次读取损坏由折成 false 改为 THROW。 3. 跨 bot owner 校验:async 终态证据仅在 asyncRec.ownerLarkAppId === lease owner 时采信(foreign completed/failed 一律忽略,修 A 采信 B 终态压制 A dispatch 的 确定性复现);session 读取由 getSession 改 getOwnedSession(不再跨 bot 文件回退 泄漏 chatId);terminalizeAttempting 遇 foreign-owned async 槽位跳过而非抛,避免 把 finding #4 的跨 bot 启动 DoS 形状重新引入。 4. 存储布局 owner 分区:idempotency/<sha256(owner)>/<keyHash>.json;listAll 改 listAllForOwner 只枚举本 owner 子目录。任一 foreign/未知 owner 坏文件不再阻断 本 bot 启动;本 owner 坏文件仍 throwOnCorrupt fail-closed。该文件从未进过任何 已发 tag、分支未并入 master,故无需迁移。 测试:idempotency-store 19、trigger-session-idempotency 20(补 #1 live-ness、 #2 CAS 重分类/损坏 abort/并发 takeover throw、#3 foreign-completed/failed、 #4 foreign-corrupt 不阻断)、e2e 9(补 #1 barrier pre-rename/post-rename/EIO 真穿 triggerSessionTurn 故障注入)。affected+shared 204/204 绿,pnpm build 绿, unit project 13132/13133(唯一 1 例为并发满载下的既有 timing flake,孤立运行 32/32 绿,与本改动无关)。 Co-Authored-By: Claude <[email protected]>
deepcoldy
added a commit
that referenced
this pull request
Aug 7, 2026
…locker) codex 二轮 review(4878071011)7 blocker,按其拍定的 v3 设计重写。核心:lease 只管 「是否允许派发」,async-trigger-store 管「调用方看到的终态」——两者职责分离,不再靠 第三份 tombstone/index,也不靠 closeSession 成功来定义业务终态。 - #6(最核心,terminal 不接进 trigger-result):async-trigger-store 扩 status pending|completed|**failed**(failed 带 errorCode:no_output, reason:dispatch_unknown)。 新增 recordFailedStrict(per-session withFileLockSync + atomicWriteFileSync durable + 抛错, 与 recordCompleted 同锁串行,completed 更强证据恒胜)。resolveAsyncTriggerState 新增 durable-failed 分支(优先级 completed > failed > closed > pending)——即使 reconcile 的 closeSession 抛错、session 保持 open,trigger-result 也收敛 failed,不永久 running。 - #1(replace 非原子撕 tombstone):idempotency-store 全部改 atomicWriteFileSync(tmp+fsync +rename,失败保留旧文件),干掉 unlink→link。 - #2(takeover 非精确 CAS + 丢 won/existing):takeover 返回 {won|existing},锁内对完整 immutable identity(owner+boot+session+trigger+requestHash+revision)精确校验;stale rev1 不能覆盖 fresh winner rev1(新增回归测试)。lease 状态精简为 reserved|attempting(terminal 移出到 async-store)。 - #3(reconcile 跨 bot):reconcileIdempotencyLeasesOnBoot(ownerLarkAppId, currentBootId) 显式传 owner,读写/close 前 fail-closed 过滤 record.ownerLarkAppId,跳过 current boot。 - #4(reconcile 在 bind 之后):移到 setActiveSessionsRegistry 之后、startIpcServer 之前 (daemon.ts)。返回 quarantine Set 传入 restoreActiveSessions,被 terminalize 的 session 排除 re-attach(防状态/执行面分叉)。 - #5(本 boot 失败留坏 lease):barrier 前失败 compareAndRemove 释放 reserved(重试可全新); barrier 后 dispatch 同步 throw → recordFailedStrict + close(durable failed,不重派)。 - #7(HTTP 契约):trigger status mapper 加 idempotency_conflict→409;idempotent 的 state:failed 视作 200(成功 HTTP 调用报终态,非请求错误)。 - 所有 claim/takeover/transition/compareAndRemove 走同一 per-key withFileLockSync(rename 只原子替换≠CAS,必须锁内 read→校验→写)。withKeyLock/ensureDir 保证 .lock 父目录存在。 验证:pnpm build 通过。测试真穿状态机崩溃点——idempotency-store 16(含 stale-rev1 竞争 / corrupt fail-closed / compareAndRemove CAS);trigger-session-idempotency 12(真 store: attempting-orphan→async failed+close+quarantine / reserved-orphan→删+close / completed 留 / current-boot 跳过 / **OTHER-owner 跨 bot 零触碰**);trigger-api 校验+范围拒绝;async-store/ state/api-only-wiring(readiness 序不变) 全绿。affected+shared-path 11 套件 327/327 绿。 docs-site build 绿。不带 key 的普通 trigger/webhook 行为零变化。 Co-Authored-By: Claude <[email protected]>
deepcoldy
added a commit
that referenced
this pull request
Aug 7, 2026
四处收口,全部 fail-closed / owner 正向背书: 1. attempt-barrier 失败释放:compareAndRemove 改返回判别式结果 (removed|absent|changed),不再吞 false/异常。干净移除→重试全新; changed→attempting(rename 落盘后 fsync 抛,即已跨越的 commit-unknown fence)→durable recordFailedStrict 并返回**可观测 state:failed**(非裸 5xx);compareAndRemove 抛(EIO/损坏)→诚实 5xx,lease 留给下轮 reconcile。 另:resolveIdempotencyHit 改以 LIVE-ness(而非 ownerBootId)判定"真正在飞": attempting/reserved + 同 boot + 无 live worker → terminal,杜绝同 boot 无限复用。 2. boot reconcile:compareAndRemoveByPath 返回判别式结果;对 changed→attempting 重分类为已跨越 fence(durable terminalize,绝不删),changed→current boot 跳过 (在飞),其余不可证明收敛→fail-closed 抛。store 侧锁内二次读取损坏由折成 false 改为 THROW。 3. 跨 bot owner 校验:async 终态证据仅在 asyncRec.ownerLarkAppId === lease owner 时采信(foreign completed/failed 一律忽略,修 A 采信 B 终态压制 A dispatch 的 确定性复现);session 读取由 getSession 改 getOwnedSession(不再跨 bot 文件回退 泄漏 chatId);terminalizeAttempting 遇 foreign-owned async 槽位跳过而非抛,避免 把 finding #4 的跨 bot 启动 DoS 形状重新引入。 4. 存储布局 owner 分区:idempotency/<sha256(owner)>/<keyHash>.json;listAll 改 listAllForOwner 只枚举本 owner 子目录。任一 foreign/未知 owner 坏文件不再阻断 本 bot 启动;本 owner 坏文件仍 throwOnCorrupt fail-closed。该文件从未进过任何 已发 tag、分支未并入 master,故无需迁移。 测试:idempotency-store 19、trigger-session-idempotency 20(补 #1 live-ness、 #2 CAS 重分类/损坏 abort/并发 takeover throw、#3 foreign-completed/failed、 #4 foreign-corrupt 不阻断)、e2e 9(补 #1 barrier pre-rename/post-rename/EIO 真穿 triggerSessionTurn 故障注入)。affected+shared 204/204 绿,pnpm build 绿, unit project 13132/13133(唯一 1 例为并发满载下的既有 timing flake,孤立运行 32/32 绿,与本改动无关)。 Co-Authored-By: Claude <[email protected]>
deepcoldy
added a commit
that referenced
this pull request
Aug 7, 2026
…locker) codex 二轮 review(4878071011)7 blocker,按其拍定的 v3 设计重写。核心:lease 只管 「是否允许派发」,async-trigger-store 管「调用方看到的终态」——两者职责分离,不再靠 第三份 tombstone/index,也不靠 closeSession 成功来定义业务终态。 - #6(最核心,terminal 不接进 trigger-result):async-trigger-store 扩 status pending|completed|**failed**(failed 带 errorCode:no_output, reason:dispatch_unknown)。 新增 recordFailedStrict(per-session withFileLockSync + atomicWriteFileSync durable + 抛错, 与 recordCompleted 同锁串行,completed 更强证据恒胜)。resolveAsyncTriggerState 新增 durable-failed 分支(优先级 completed > failed > closed > pending)——即使 reconcile 的 closeSession 抛错、session 保持 open,trigger-result 也收敛 failed,不永久 running。 - #1(replace 非原子撕 tombstone):idempotency-store 全部改 atomicWriteFileSync(tmp+fsync +rename,失败保留旧文件),干掉 unlink→link。 - #2(takeover 非精确 CAS + 丢 won/existing):takeover 返回 {won|existing},锁内对完整 immutable identity(owner+boot+session+trigger+requestHash+revision)精确校验;stale rev1 不能覆盖 fresh winner rev1(新增回归测试)。lease 状态精简为 reserved|attempting(terminal 移出到 async-store)。 - #3(reconcile 跨 bot):reconcileIdempotencyLeasesOnBoot(ownerLarkAppId, currentBootId) 显式传 owner,读写/close 前 fail-closed 过滤 record.ownerLarkAppId,跳过 current boot。 - #4(reconcile 在 bind 之后):移到 setActiveSessionsRegistry 之后、startIpcServer 之前 (daemon.ts)。返回 quarantine Set 传入 restoreActiveSessions,被 terminalize 的 session 排除 re-attach(防状态/执行面分叉)。 - #5(本 boot 失败留坏 lease):barrier 前失败 compareAndRemove 释放 reserved(重试可全新); barrier 后 dispatch 同步 throw → recordFailedStrict + close(durable failed,不重派)。 - #7(HTTP 契约):trigger status mapper 加 idempotency_conflict→409;idempotent 的 state:failed 视作 200(成功 HTTP 调用报终态,非请求错误)。 - 所有 claim/takeover/transition/compareAndRemove 走同一 per-key withFileLockSync(rename 只原子替换≠CAS,必须锁内 read→校验→写)。withKeyLock/ensureDir 保证 .lock 父目录存在。 验证:pnpm build 通过。测试真穿状态机崩溃点——idempotency-store 16(含 stale-rev1 竞争 / corrupt fail-closed / compareAndRemove CAS);trigger-session-idempotency 12(真 store: attempting-orphan→async failed+close+quarantine / reserved-orphan→删+close / completed 留 / current-boot 跳过 / **OTHER-owner 跨 bot 零触碰**);trigger-api 校验+范围拒绝;async-store/ state/api-only-wiring(readiness 序不变) 全绿。affected+shared-path 11 套件 327/327 绿。 docs-site build 绿。不带 key 的普通 trigger/webhook 行为零变化。 Co-Authored-By: Claude <[email protected]>
deepcoldy
added a commit
that referenced
this pull request
Aug 7, 2026
四处收口,全部 fail-closed / owner 正向背书: 1. attempt-barrier 失败释放:compareAndRemove 改返回判别式结果 (removed|absent|changed),不再吞 false/异常。干净移除→重试全新; changed→attempting(rename 落盘后 fsync 抛,即已跨越的 commit-unknown fence)→durable recordFailedStrict 并返回**可观测 state:failed**(非裸 5xx);compareAndRemove 抛(EIO/损坏)→诚实 5xx,lease 留给下轮 reconcile。 另:resolveIdempotencyHit 改以 LIVE-ness(而非 ownerBootId)判定"真正在飞": attempting/reserved + 同 boot + 无 live worker → terminal,杜绝同 boot 无限复用。 2. boot reconcile:compareAndRemoveByPath 返回判别式结果;对 changed→attempting 重分类为已跨越 fence(durable terminalize,绝不删),changed→current boot 跳过 (在飞),其余不可证明收敛→fail-closed 抛。store 侧锁内二次读取损坏由折成 false 改为 THROW。 3. 跨 bot owner 校验:async 终态证据仅在 asyncRec.ownerLarkAppId === lease owner 时采信(foreign completed/failed 一律忽略,修 A 采信 B 终态压制 A dispatch 的 确定性复现);session 读取由 getSession 改 getOwnedSession(不再跨 bot 文件回退 泄漏 chatId);terminalizeAttempting 遇 foreign-owned async 槽位跳过而非抛,避免 把 finding #4 的跨 bot 启动 DoS 形状重新引入。 4. 存储布局 owner 分区:idempotency/<sha256(owner)>/<keyHash>.json;listAll 改 listAllForOwner 只枚举本 owner 子目录。任一 foreign/未知 owner 坏文件不再阻断 本 bot 启动;本 owner 坏文件仍 throwOnCorrupt fail-closed。该文件从未进过任何 已发 tag、分支未并入 master,故无需迁移。 测试:idempotency-store 19、trigger-session-idempotency 20(补 #1 live-ness、 #2 CAS 重分类/损坏 abort/并发 takeover throw、#3 foreign-completed/failed、 #4 foreign-corrupt 不阻断)、e2e 9(补 #1 barrier pre-rename/post-rename/EIO 真穿 triggerSessionTurn 故障注入)。affected+shared 204/204 绿,pnpm build 绿, unit project 13132/13133(唯一 1 例为并发满载下的既有 timing flake,孤立运行 32/32 绿,与本改动无关)。 Co-Authored-By: Claude <[email protected]>
deepcoldy
added a commit
that referenced
this pull request
Aug 25, 2026
复核补出的第四处阻断,以及对接管修复的一处硬化。 ④ SESSION_DATA_DIR 迁移丢失(升级即丢状态,比前三处更致命): 旧 pm2 ecosystem 给每个 bot daemon 和 dashboard 都注入 SESSION_DATA_DIR=DATA_DIR (~/.botmux/data)。pm2→supervisor 迁移删掉 ecosystem 时一并删了该注入,而 supervisor 路径不补:resolveFleetDaemonEnv 只透传 process.env,spawnBot 只加 BOTMUX_BOT_INDEX, daemon/dashboard 入口也不跑 CLI 的 `SESSION_DATA_DIR ??= resolveDataDir()` 兜底。 config.session.dataDir 是惰性 getter `process.env.SESSION_DATA_DIR ?? packagedDataDir` ——无 env 时回落到包目录 <pkg>/data,不是 ~/.botmux/data。后果:从 pm2 升级到 supervisor 后,所有 daemon+dashboard 的数据根静默迁到包目录,~/.botmux/data 里现有的 会话/配对/联邦/VC 绑定全部不可见。fresh install 无旧数据不暴露(作者自测撞不到), 线上升级必中。 修:resolveFleetDaemonEnv 注入 `SESSION_DATA_DIR ??= resolveBotmuxDataDir()` (复用 CLI 的解析:env > ~/.botmux/.data-dir 面包屑 > ~/.botmux/data,与旧 DATA_DIR 一致;??= 保留显式设置的 ambient 值)。顺带补 BOTMUX_PM2_GRACEFUL_EXIT_CODE parity (严重性低,explicitStop/stopping 已覆盖显式停,仅为 dashboard 自更新等自退出路径恢复)。 ① 接管属主判据硬化(去掉 isTakeover,只靠 !children.has): 前一 commit 用 `priorPid !== process.pid` 判定接管再 reclaim 孤儿,存在 pid 复用边角 (OS 把死 supervisor 的 pid 复用给新 supervisor 时误判为非接管→退回自退出)。改为纯属主 判据:任何「online+alive 但不在本 children」的 proc 都 reclaim。同 supervisor 幂等重启时 自己的 child 必在 children 里,该判据天然 no-op;彻底消除 pid 依赖。 验证: - ④ 反向变异有牙(还原注入→REGRESSION #4 变红:env.SESSION_DATA_DIR undefined); standalone 实证修复后 daemon 继承的 config.session.dataDir 落 ~/.botmux/data - ① 硬化后 REGRESSION #1/#3 仍绿(接管重掌管、退避窗口不双 spawn 行为不变) - 新增 REGRESSION #4 回归测试(fleet-runtime.test.ts,含 ambient override 负例) - pnpm build 全绿;fleet 相关 126 用例绿 注:④ 端到端(真实 daemon 数据目录落盘)需 live 验证,现有单测覆盖注入点 + 继承解析; ③ 接管 SIGTERM+respawn 对 dashboard 有极短暂端口重叠(旧 server.close 等 WS 断最长 5s, 新 dashboard 期间 EADDRINUSE churn 自愈),接管瞬间 web 面短暂闪断,可接受。 Co-Authored-By: Claude <[email protected]>
This was referenced Aug 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/adapters/cli/coco.ts/writeInput写入路径从send-keys -l 逐行 + \⏎ 软换行 + 末尾独立 Enter改成pty.pasteText()(tmuxload-buffer+paste-buffer -d,自动包 bracketed paste markers)~/.cache/coco/history.jsonl+ retry Enter + recheck closure)原样保留根因
Trae CLI 0.120.31 (May 2026 build) 把适配器密集的 send-keys -l + 行间
\⏎软换行序列识别成开放式 paste burst,submitDelay 后那个独立 Enter 也被并入 burst 当软换行处理 → 消息死在输入框,daemon log 无 retry 警告(worker 在 deferred recheck 触发前就被 IM 卡片 Close 按钮 kill 掉了,告警 timer 没跑到)。手动 30 分钟后按 Enter 又能 submit,说明 burst window 最终会超时,但远超 4×800ms 的 retry 预算。为什么不改 claude-code.ts
claude-code 同样的路径但保留不动——Claude Code 在 slash 命令后会 toggle bracketed paste OFF,那时 markers 失效会让
\n拆成多次 submit。CoCo fresh-spawn message 没这个问题(也没有 slash 命令场景)。Test plan
pm2 restart botmux-4\n、CJK)@ 小呆呆 → CoCo 单次完整 submit,无 retry,进 Thinking 后正常回复~/.cache/coco/history.jsonl写入完整内容,不被\n拆成多次 user-mode 行submit not confirmed警告🤖 Generated with Claude Code