feat(bots): 建立轻量伙伴核心 - #2829
Draft
zqchris wants to merge 5 commits into
Draft
Conversation
cursor Bot
pushed a commit
to zqchris/cindy
that referenced
this pull request
Aug 28, 2026
PR makecindy#2829 QA defect A: a deliver() that never settles pinned the serial drain loop forever, so every Bot's queue died with it (one completion receipt wedged global delivery for 64 minutes), and because lease reclaim only ran inside the drain loop, the 60s sending lease was never enforced either. - Race each deliver call against a deliverTimeoutMs watchdog (defaults to sendingLeaseMs); a timeout is failed as retryable DELIVERY_TIMEOUT and retried with normal backoff. A late-settling adapter call can no longer resurrect the row: its writes CAS on status='sending', which no longer matches, and late settlement is only logged. - Move expired-lease reclaim to a dedicated interval sweeper (sendingLeaseMs/2, unref'd, dispose'd) that schedules a drain after reclaiming, so reclaim no longer depends on drain liveness. The reclaim CAS stays safe against a live drain. - Keep retrySafe=false external-dispatch markers authoritative: a timed-out local-adapter dispatch dead-letters as DELIVERY_OUTCOME_UNKNOWN instead of retrying. - Add delivery lifecycle logs (attempt started/delivered/failed/lease expired requeued) with id/kind/errorCode only — no message content. Signed-off-by: nana <823073145@qq.com>
cursor Bot
pushed a commit
to zqchris/cindy
that referenced
this pull request
Aug 28, 2026
PR makecindy#2829 QA defect B: delegation completion archived the child task through a generic sessions.setStatus write, which the bot-lifecycle guard in tx.ts rejects for source='bot' rows — and the error was swallowed, so the child stayed active forever and the guardian reported a supervision anomaly on every settle. bots.finishDelegation already flips bot_session_links to history inside the terminal transaction; archive sessions.status there too (guarded by source='bot' AND status='active', so the delegation CAS keeps it idempotent). Drop the archiveSession dep and its drizzle fallback from the delegation service and the register.ts wiring: a failure inside the transaction now fails the delegation settle itself instead of being silently discarded. Signed-off-by: nana <823073145@qq.com>
cursor Bot
pushed a commit
to zqchris/cindy
that referenced
this pull request
Aug 28, 2026
PR makecindy#2829 QA defect C: sendToSessionLocks entries were released in the holder's finally, so one critical section that never settled pinned the map entry forever — outbox retries and guardian inbox dispatch queued behind waitPrev eternally while UI direct sends (which bypass the lock) kept working and masked the deadlock. Extract the lock into sendToSessionLock.ts with a leak watchdog: warn after 30s and bail the map entry after 5min, so later senders proceed while the stuck holder finishes as a zombie. That is the lesser evil — its writes are DB-backed with clientId dedup and turn-start guards, the same protections that already tolerate lock-external UI sends. Bail warnings carry the holder's current lockStage so the original hang point (queue-restore / live-send / …) is identifiable from logs. Map entries never reject; late zombie settlement cannot clobber or resurrect a successor entry. Signed-off-by: nana <823073145@qq.com>
cursor Bot
pushed a commit
to zqchris/cindy
that referenced
this pull request
Aug 28, 2026
Bring makecindy#2829 up to current makecindy/cindy main without rebasing Nanaco/Chris history. Conflict resolution keeps Bot Mode behavior and folds in main's API/type/contract updates. - Keep unpublished bot schema intent; regenerate it as 0098 after main's frozen 0096/0097 FTS and companion migrations. - Preserve bot canonical replacement lock, bot deliverable cards, workspace read-only Pi flags, and Engine glossary term. - Take main's review liveness, generated-files incremental stat plus turnSealed, hook workspace prefs, and Harness glossary term. Signed-off-by: Chris <4436110+zqchris@users.noreply.github.com> Co-authored-by: Chris Zhang <zqchris@users.noreply.github.com>
伙伴是永久 Profile + 可替换物理 Session 的两层结构:SOUL/记忆/自有技能落在 账号隔离的 Bot Home,canonical 卷每日 04:00 CAS 换代并归档,模型走 1-5 项 候选链,只有「候选不可用」才推进。运行时按 allowlist 装配能力:不继承 Cindy 全局 Skill/MCP/项目上下文;pi 关闭原生 subagent 扩展并传 --no-context-files,codex 置 project_doc_max_bytes=0,显式挂载 docs 工具集 时 cindy_docs 才进入 MCP allowlist —— 提示词承诺与工具面同进同退。 数据库为 6 张只增量新表(migration 0101)。 Signed-off-by: zqchris <chrisz83@gmail.com>
协作只有一个直接入口 collaborate_with_bot:status 查空闲,notify 发不追踪 的消息,delegate 委派给另一个伙伴,start_task 把大活开成一条真正的 Cindy 任务(出现在主任务列表、走自己的权限门)。两种委派共用同一张 bot_delegations 表(target_bot_id 为空即 Cindy 任务)、同一张实时协作卡与同一条完成信号。 完成信号重做:不再往时间线落机读文本,改为 synthetic-trigger 隐藏行 —— 对模型是接手指令,对用户不可见,可见终态由协作卡承载;发起方父卷被每日 换卷归档时改投该伙伴当前 canonical 卷,不静默丢失。委派服务不再依赖 automation 上下文、token 预算层、投递 outbox 与 IM 路由。 Signed-off-by: zqchris <chrisz83@gmail.com>
左侧伙伴名册(IM 式未读)、复用真实任务与 ChatInput 的聊天面、@伙伴结构化 引用,以及只剩三页的设置(成长/模型/维护)。创建收敛成「名字 + 自动色相 头像 + 人设文本」,不暴露 Session、压缩、fallback 等工程概念;记忆与自学 技能在设置页可见、可删。五语言 i18n 同步。 Signed-off-by: zqchris <chrisz83@gmail.com>
《Cindy 伙伴运行时》契约与工程完成矩阵按 v1 范围重写:Bot Home 权威边界、 每日换卷、模型候选链、能力 allowlist、委派与完成信号的呈现契约;设计规范 登记伙伴头像色相与未读徽章的窄作用域 token,并把头像图收敛为保留命名空间。 Signed-off-by: zqchris <chrisz83@gmail.com>
worktree 回收器与通用任务生命周期入口跳过 source='bot' 的会话 —— 伙伴卷的 归档与替换只归 Bot Renew 管;崩溃恢复快照剥离 Bot 宿主瞬态引用。 Signed-off-by: zqchris <chrisz83@gmail.com>
zqchris
force-pushed
the
cindy-bot-mode-mvp
branch
from
September 2, 2026 15:21
c1a79fd to
3760cb6
Compare
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.
这次改了什么
摘要
按产品校准把本 Draft 从 +109k / 559 文件重建为 +54.9k / 365 文件、5 个干净 commit(基于最新 main 重放,历史已重写)。目标一句话:建立轻量伙伴核心——伙伴是永久档案 + 可替换会话卷的数字同事,最懂的三件事是控制自己(记忆/技能/配置)、找别的伙伴协作、把大活开成真正的 Cindy 任务;对用户不暴露任何工程概念。
核心设计修复(相对上一版):
subagent扩展对伙伴关闭、pi 传--no-context-files、codex 置project_doc_max_bytes=0——伙伴不再吸入项目/全局 AGENTS.md,也看不到 harness 的 worker 面(此前实测泄漏的根因)。cindy_docs真实进入 MCP allowlist。collaborate_with_bot增加start_task——把大活开成一条普通 Cindy 任务(出现在主任务列表、走自己的权限门),与 Bot×Bot 委派同卡、同信号(bot_delegations.target_bot_id可空即 Cindy 任务)。变更类型
feat新功能范围
collaborate_with_bot(status/notify/delegate/start_task)+ 协作卡 + 隐藏完成信号;上下文隔离与能力 allowlist;6 张只增量新表(migration 0101)。规模构成:生产代码约 +27.4k,测试 + drizzle 生成快照约 +23.8k,五语言 i18n 约 +3.7k。入口规模闸三问自查通过(单一完整产品目标;档案基座/聊天面/委派卡三者拆开任一都不可用;按 2026-08-11「大工程用长 Draft 累积」裁决继续以本 Draft 承载)。
UI 变化
伙伴名册/聊天/设置/协作卡均为新增界面,Light/Dark 双模式全部走语义 token。截图待真实验收时补(见「未执行的验证」)。
--bot-avatar-*-bg九色相、--bot-unread-bg/fg未读徽章,本 PR 一并登记);「Reserved artwork namespace — Bot avatar sentinels」(头像图收敛为保留命名空间 + 中性首字母兜底);间距/圆角/零阴影沿用共享 8px/12px/pill 基线。无硬编码颜色(已扫描)。怎么验证的
自动验证
未跑全仓
pnpm test:unit/test:unit:related:按 2026-08-07 裁决本地禁止无界全仓并发(实踩卡死机器),以上为低并发定向验证,完整门禁交本 PR 的 CI。已知与本 PR 无关的主干基线红(在 pristine main 上复验同样失败):
messagesWriteReadback、messagesClearRace、sessionAutoTitlePersist、orcaTeamStore、drizzle-proxy-perf、drizzle-split.spike、sessionsRestoreIfArchived(2 个上游用例)。手工验证
未执行(见下)。
未执行的验证
真实验收五项仍待产品负责人在场完成(正本见
docs/product-rules/cindy-bots-completion-matrix.md):①伙伴会话上下文无项目 AGENTS.md/无 subagent 工具的实机确认;②delegate全链(卡片实时更新→隐藏回执→自动接手);③start_task全链;④docs 工具集挂载后真实做出文档;⑤Desktop Light/Dark 双模式目检。双模式已在实现层全部走语义 token,实机目检未做,按仓库规则如实注明。风险
风险分类
影响与回滚
botRuntimeProfile存在时),普通会话零变化——maker-core 既有测试未改动全绿。提交前检查
git commit -s,见 DCO)