Repository navigation
feat(assistant-mode): 开放私聊 bot 的个人助理模式,每个会话归一个主人、按主人隔离 - #3652
Conversation
694c943 to
bfe2500
Compare
|
你好,这个 PR 的自动评审群已建,麻烦点击链接加入群聊、查看评审意见并跟进后续修改: 另外你暂时不在自动拉群名单里,也可以把 GitHub 账号和飞书信息补进名单文档,补好后后续评审会自动拉你进群:https://bytedance.larkoffice.com/wiki/WJ1nwWbtxi89erkNGNbcgkt9nUe (本条为自动流程发出的提示消息) |
deepcoldy
left a comment
There was a problem hiding this comment.
审查基线:本地 rebase 后 5f799b85b。当前仍有 3 个跨 owner 隔离问题与 1 个配置缺陷,不建议合并。
P1-1|换主窗口内,B 的附件会先落进 A 的附件桶
位置:src/daemon.ts:31003-31007,后续准入拒绝发生在 src/daemon.ts:31962。
现有会话存在时,下载器无条件优先使用 ds.session.assistantOwnerOpenId,而附件下载早于 worker 准入检查。A→B 改绑后,只要退役尚未完成或消息处理器已捕获旧 ds,B 的文件就会写入 attachments/<appId>/u/<A>/<messageId>/;之后即使输入被拒绝并提示重发,文件已经持久化在 A 可读的桶中。
**真实路由探针:**以 A 的旧 chat-scope 会话开始,改绑 B 并让 close Promise 保持未完成,再由 B 发送文件调用真实 handleThreadReply。观察到 downloadResources 的 owner 参数为 A,随后日志才是 assistant-mode: refusing input;旧 worker 未收到 message,但 bucketOwners === [A]。
**建议:**任何下载或 prepared-attachments 交接之前重新解析当前 owner;旧 ds 归属已过期时先拒绝/退役并要求重发,不得先持久化附件。回归用例应同时断言“旧桶无写入”和“旧 worker 无输入”。
P1-2|queued activation 与冷启动 init 都绕过了双准入闸
位置:
src/core/worker-pool.ts:19320-19348:double-fork 分支在助理归属检查之前直接admitQueuedActivationTail;src/core/worker-pool.ts:18802的 protected-egress 排队入口同类。src/daemon.ts:23327-23337:opening follower 也可直接写 tail。src/core/worker-pool.ts:18230-18268:promotion 在持久化 journal 后直接worker.send,没有按当前 owner 复核。src/core/worker-pool.ts:20519-20528:standalone IPC bootstrap 等待结束后直接发送首个init,也不经过sendWorkerInput。
**可控时序探针 1:**当前 owner 从 A 改为 B 后,对照 decideAssistantAdmission 返回 {kind:'reject', have:A, expected:B};同一状态下调用真实 forkWorker 再触发 promotion,结果为 {queuedOwnerB:true, sentOwnerB:true},即 B 的输入进入 A 的 tail 并发给 A 的 worker。
**可控时序探针 2:**standalone fork 在 worker_ipc_probe 后暂停,改绑 owner 再发出 worker_ipc_ready;包含原 prompt 的 init 仍被发送(探针观测 initSent === true)。远端关闭准备存在 await,且关闭失败会保留 active row,因此“换主已发生、退役尚未完成”不是不可达状态。
**建议:**统一覆盖三层,而不是只补普通消息入口:① 所有 tail 写入前;② promotion 修改 journal 前及实际发送前;③ bootstrap/重试后的 init 与 message 实际投递前。归属不符时不能把输入留在旧会话 journal 中,需退役并提示重发。保留上述两条时序作为回归用例。
P1-3|慢速 bot-token 请求跨模式切换后仍返回 app 身份凭证
位置:src/core/dashboard-ipc-server.ts:4451-4473。
getTenantAccessToken() 之前检查了实时 assistantMode,但 await 之后只复核 session/binding,没有重新读取身份策略。legacy 会话在模式关闭时发起慢请求,等待期间开启助理模式,仍可在最后收到 tenant token。
**真实 HTTP 探针:**用受控 Promise 挂起 token lookup,请求开始后令 assistantMode=true,并将 legacy ds.worker 置空模拟 worker 已停;释放 lookup 后响应仍为 200,正文包含 credential:'late-bot-token'。现有 stillValidSession 不检查 worker,也不重跑 withholding,因此停止 worker 本身不能堵住这个响应。
**建议:**token 返回前重新读取实时 bot 配置,并重复完整的 withholding/assistant-owner 判定;任何一项不再满足都返回 403。补“lookup 挂起→开模式/换主→释放 lookup”的回归用例,并断言响应正文不含 token。
P2-1|assistantLarkBotIdentity: true 的文档承诺确实失效;不建议只删第一道 403 来修
位置:src/core/dashboard-ipc-server.ts:4432-4445、src/bot-registry.ts:4543-4544、src/adapters/cli/sandbox-mode.ts:128-137。
真实路由探针设置 assistantMode:true、assistantLarkBotIdentity:true 后,mode:'bot' 仍固定返回 403 lark_tool_bot_identity_withheld,与配置 hint 和中英文文档承诺不符。
需要精确限定“死开关”的含义:是文档所述的助理模式逃生阀失效,不宜仅凭 gate2 推断所有异常/历史状态下代码都绝对不可达。并且问题不止 gate1 的实时 assistantMode 条件:配置归一化会无条件把助理模式的 sandboxWithholdBotSecret 固化为 true,所以仅给 gate1 加例外,正常助理会话仍会被冻结标志挡住。
修法取向:
- 推荐删除
assistantLarkBotIdentityknob、gate2、worker init 字段及文档/hint,与“沙盒不持任何 app 身份凭证”的隔离模型保持一致。 - 若产品必须保留逃生阀,则需要把它定义为对 #3649 凭证模型的显式例外,区分“用户显式配置 withhold”与“assistantMode 隐含 withhold”,同时调整 live/frozen 两层判定并补真实配置归一化 + token 路由测试;只改 gate1 不足。
本地验证
bun run build:通过。- 13 个相关 vitest 文件:459 passed。
- 上述探针均通过
bun scripts/fenced-run.ts -- bunx vitest ...执行;失败输出即文中观测值。探针代码已移除,工作树保持干净。
|
感谢 c6f22ca 的修复,评审里的 4 条(附件先于准入、排队/提升/首个 init 绕闸、慢 token 请求、删开关)都看过了,没有异议。 我这边在同一主题(换主时序)上又排查了一轮,在 c6f22ca 之后仍能复现下面几类「A 名下进来的输入落到 B 的会话 / 桶 / ask」的场景。补丁放在单独分支,没有推到本 PR 分支,要不要合、怎么合由你决定:
仍可复现的场景
补丁做法不再逐条路径补,而是统一一个「到达时主人」:
验证
没覆盖的
🤖 Generated with Claude Code |
|
补充说明优先级:上面这些都是低概率的边角情况,仅供参考,不阻塞本 PR 合并。 私聊不存在换主;群里认领后只有管理员手动改派才会换主,而且要恰好落在某条消息排队、下载或改投的几秒窗口内,影响也只是那一条消息。c6f22ca26 已经保证换主后旧会话退役、后续输入不再进旧会话,主路径是够的。 补丁要合、要改,还是不管,都由你决定。如果想用更省事的兜底,可以只改一处:换主时丢弃该群还在排队的消息并提示重发,不必在每条路径上核对。 🤖 Generated with Claude Code |
c6f22ca to
14a4015
Compare
deepcoldy
left a comment
There was a problem hiding this comment.
增量审查发现 3 个 P1 隔离问题与 1 个 P2 测试接线问题,当前 head 不宜 squash。以下均已在 14a401555 上用行为探针复现,临时探针已删除,工作树干净。
P1-1|assistant-only 时,macOS 最终 Seatbelt allow 会重新打开 lark-cli 密钥库
位置:src/adapters/cli/fs-policy.ts:1314(编译出口在 :1432-1437)。
sealLarkKeyStore = withholdSendCredential || assistantMode 已接入普通规则,但 finalDenyPaths 仍只由 withholdSendCredential 决定。assistantMode:true 且未显式设置 withhold 时,如果 mandatoryReadOnlyPaths 含 HOME 或 /,最终 ancestor allow 会出现在普通 keystore deny 之后,重新打开 master.key.file 与 appsecret 密文。
**探针:**构造 assistant-only、mandatoryReadOnlyPaths:['/Users/u'] 并调用真实 buildFsPolicy + compileToSeatbelt。最终 /Users/u allow 位于 16155,而 keystore deny 位于 12261;没有最终 deny 在 allow 之后,探针按预期失败。
修法:finalDenyPaths 与 sealLarkKeyStore 使用同一条件,并补 assistant-only 的编译后顺序断言:keystore deny 必须位于最终 ancestor allow 之后。
P1-2|no-transport 助理会话重新获得整个 bot 的 sessions.db
位置:src/adapters/cli/fs-policy.ts:1237-1256,尤其是 :1249。
前面的 !ctx.assistantMode 已禁止 session-store 授权,但 no-transport carve-out 又无条件加入 session-stores/<currentAppId> 的 readOnly。更深的 internal grant 覆盖 authority deny,使该目录(含其它 owner 的会话正文)重新可读。
探针:assistantMode:true + larkTransportEnabled:false 调用真实 buildFsPolicy,accessForPath(.../session-stores/cli_self/sessions.db) 实际为 readOnly,而隔离要求为 deny。
**修法:**no-transport carve-out 同样排除助理模式的 session-stores/<currentAppId>;保留其余合法的 routing/bin 等 carve-out。补 no-transport + assistant 的回归用例。
P1-3|non-ordinary IPC 与 transfer replay 仍可跨 owner 投递
位置:
src/core/worker-pool.ts:15511-15515:sendWorkerSessionInput在 bootstrap 回调里直接worker.send(annotated)。src/core/worker-pool.ts:15927-15935:replacement worker 对非 ordinary 消息直接 replay。
**探针 1(raw_input + bootstrap):**A 的会话在 worker_ipc_probe 后排队 raw_input,改绑 B 再发 worker_ipc_ready。即使 init 路径已有闸,/model opus 的 raw_input 仍被发送。
**探针 2(真实 transferSession):**transfer 期间缓存 raw_input,目标 chat owner 为 B 后完成 detach/exit。replacement worker 仍收到 /model opus。
**修法:**在这两个实际投递边界复用 assistantLiveInputAdmission。注意 sendWorkerSessionInput 的既有轻量 guard 语义:不要给 term_action、display 控制等无内容 IPC 增加 registry 查询;应对 message / raw_input 等内容输入复核,ordinary tracked 消息继续走现有 ordinary 闸。保留上述两条时序回归。
P2-1|两个 function-harness scope 缺少新依赖,当前 CI 因此失败
位置:test/worker-managed-origin-contract.test.ts:66-72、test/ordinary-im-contract-delivery.test.ts:46-58。
新增 assistantLiveInputAdmission 是 sendOrdinaryImDeliveryAttempt 的自由变量,但两个 fixture scope 都未提供它:
ordinary-im-contract-delivery.test.ts:Vitest 29 个失败(CItest (1/4))。worker-managed-origin-contract.test.ts:Vitest 6 个失败(CItest (4/4)),Bun 同样 6 个失败(bun-test (4/4))。- 错误统一为
TypeError: assistantLiveInputAdmission is not a function。
**已验证修法:**每个 fixture 提供非助理 getBot: () => ({ config: {} }),并用同一个 loadWorkerPoolFunction('assistantLiveInputAdmission', fixtureScope) 抽取真实闸函数。临时应用后分别得到 35/35 与 11/11 通过。直接注入 workerPool.assistantLiveInputAdmission 不够:它仍会读取真实 registry,并因测试 appId 未注册而失败。
已确认的结构与验证
- range-diff:8 个
=、3 个!,48 文件,diff --check通过。 - 本地
bun run build通过;冲突/隔离相关 6 个 vitest 文件 1159 条通过。 - CI run
44816421763已结束:build、binary 与其余 shards 成功;test (1/4)、test (4/4)、bun-test (4/4)及聚合 job 因上述夹具问题失败。
acaacde to
509ecd3
Compare
deepcoldy
left a comment
There was a problem hiding this comment.
同步增量审查结论:代码层面未发现新的语义共存问题,但当前 head 仍不能 squash,因为 CI 首跑未全绿。
零改写已独立确认
git range-diff 5d3d802489...acaacde67 83328b7a78...509ecd379:15/15 提交全部=,没有!。git merge-tree --write-tree acaacde67 origin/master重新计算的树为a9d61624b0e1744db15a9a3afa74fd674db38be2,与 HEAD tree 完全相同,证明 rebase 没有静默改动。- 语义检查覆盖:worker-pool 投递闸与 Antigravity 生命周期改动、
/stop与/cd//repo、worker.ts 的 USER_HOME/模板/stripRefreshToken、Session/init 字段,以及 function-harness 的新依赖键。
本地验证
bun run build:通过。- 5 个核心隔离文件:785 passed。
- 全部 29 个助理相关文件:2032 passed。
- 单独复跑 CI 失败文件
traex-auto-model.integration.test.ts:30/30 通过(约 469 秒)。因此这不是稳定回归,而是高负载下出现的时序失败。
CI 阻塞不是 #3674 的豁免形状
CI run 44843071008 的最终状态是:
- build、darwin/glibc/musl binaries、其余 Vitest/Bun shards:
test (3/4)、test (4/4)等全部成功。 bun-test (1/4)失败:test/traex-auto-model.integration.test.ts的keeps a successive input queued after the preceding write changes Working to capacity在约 39 秒后出现timeout: correction submitted;日志末尾为structured-turn-unfinished。- 聚合
bun-test因该 shard 失败而失败。
#3674 是 botmux-update-notify-delivery 的真实文件锁 ioUntil 等待,与这次 TraeX 集成用例不是同一测试或同一失败机制,不能套用“已知 #3674 偶发不重跑”的例外,也不应仅以同 SHA 重跑掩盖。需要把该 TraeX 等待问题作为独立的时序问题处理并同步出 CI 首跑全绿的新 head,之后再 squash。
本 PR 的 diff 未触碰该失败等待逻辑或该集成测试;本地同文件 30/30 通过。代码增量审查没有发现问题,但 G4 当前不满足。
A bot anyone can DM shares one cwd, one CLI memory bucket and one sandbox writable surface across all users. `assistantMode: true` turns it into "everyone's own assistant": every session has exactly one owner (DM = sender, /group session group = creator, regular group = whoever added the bot), and cwd, CLAUDE_CONFIG_DIR, fs-policy grants, attachments and host-side read commands are all narrowed to that owner. - bots.json / /botconfig: assistantMode, assistantTemplateDir, assistantLarkBotIdentity - core/assistant-mode.ts: open_id shape gate, USER_HOME/work/attachments paths, template overwrite-sync, refreshToken stripping, owner resolution - services/assistant-owner-store.ts: <dataDir>/assistant-owners/<appId>.json - im/lark/assistant-command.ts: pre-routing `/assistant status|claim|owner @x` - daemon: resolveAssistantSpawn before all six createSession entry points, owner recorded on bot-added, owner-left → suspend + unclaimed notice, assistantWorkDir wins in resolvePinnedWorkingDir, no role-library schedules - worker: fail-closed (needs oncall sandbox + BOT_HOME redirect, cwd must be owner's work/, template sync), CLI data dir = USER_HOME/claude with junk RT, fs ctx botHome = USER_HOME, no roleLibrarySubtree, per-owner attachmentsBucket - worker-pool: re-resolve ownership at every fork; mismatch/none → refuse - fs-policy: attachmentsBucket ctx; session-manager/attachment-path per-owner bucket; IPC role-switch and lark-tool bot identity → 403 for owned sessions; /cd /repo locked; botmux history/quoted/list scoped to the same owner - docs: docs-site assistant-mode.md (zh/en), slash-commands rows, docs/file-sandbox.md section, design doc Tests: assistant-mode (8), assistant-command (17), fs-policy (+4), event-dispatcher (+1); mutation-checked; vitest + bun legs. Co-Authored-By: Claude Fable 5.1 <[email protected]>
- fs-policy: in assistant mode do not grant the bot-wide session-stores (sessions.db carries lastUserPrompt) nor this bot's lark-cli appsecret/master key (would let a user mint the tenant token and bypass the bot-identity gate); grant the real BOT_HOME send-cred.json read-only - template sync never follows destination symlinks (unlink planted links, O_EXCL temp + rename) - owner resolution: the owner store wins over the /group session-group creator, so a `left` record stops service there too; owner-left falls back to killWorker when suspend is refused - owner changes (claim / admin rebind) and `/botconfig assistantMode on` retire mismatched live sessions; forkWorker retires a session it refuses - bot-added owner recording runs before the autoStart gating - `/assistant owner @x` reads raw mention `id.open_id`, ignores the bot itself - thread-reply and quoted attachment downloads use the owner bucket - CLI peer gate resolves the caller's own session via daemon IPC (fail-closed) Co-Authored-By: Claude Fable 5.1 <[email protected]>
- fs-policy: send-cred.json (plaintext larkAppSecret) is not granted in assistant mode either; `botmux send` goes through the outbox relay and needs no credential. history/quoted/list are unavailable there (documented) - worker: before provisioning, unlink owner-planted symlinks at the top of USER_HOME/claude and USER_HOME/codex; the credential copy is written O_NOFOLLOW + rename so the host never writes through a link into ~/.claude - daemon: bot re-added by a different person retires the previous owner's live sessions (same path as claim/rebind); suspend refusal falls back to closeSession (works for non-suspendable backends) instead of killWorker; thread-reply attachments resolve the owner before download when no live session exists Co-Authored-By: Claude Fable 5.1 <[email protected]>
- assistantMode 隐含 sandboxWithholdBotSecret:bot-registry 解析时补上该标志, sandboxWithholdsBotSecret() 也认 assistantMode(冻结、会议接收、工作流快照都走它) - 于是助理会话的 send / history / quoted 都由宿主代执行:history 只读本会话,quoted 只读本会话 所在群;quoted 附件在宿主落 relay-attachments/<appId>/u/<open_id>/ 再回传 - owner 的附件桶对沙盒只读、owner USER_HOME 与 outbox 在 macOS 上 pin 住(沿用开关的既有行为) - 文档:history / quoted 不再标为不可用,list 仍不可用 Co-Authored-By: Claude Opus 5.5 <[email protected]>
- 新增 core/assistant-spawn.ts:resolveAssistantSpawn 从 daemon 挪出,定时任务、会议接收共用 - fork 子会话与干净恢复继承 assistantOwnerOpenId;新话题定时任务、冷启动会议接收按 chat 的主人建会话、 cwd 固定在主人 work/,群未认领时拒绝(定时任务记为失败) - 话题延续:旧会话主人不是当前主人时不复活,直接按当前主人新建(否则准入闸关掉后下一条又复活它) - v3 工作流拒绝 assistantMode bot(工作流 worker 没有按主人的会话,会拿到整个 BOT_HOME) - 决策看板 IPC 对带主人的会话回 403(看板按 bot 汇总,不按主人隔离) - 助理模式退役会话改用 closeSessionForBackgroundCleanup 并登记到关闭点矩阵;未开助理模式时下载调用参数不变 Co-Authored-By: Claude Opus 5.5 <[email protected]>
- 工作流 worker 启动前按实时 bot 配置检查 assistantMode:暂停后才开模式的运行从存储的快照恢复, 不经过快照生成那道检查 - 独立任务(cloneIndependentLaunchPosture)复制 assistantOwnerOpenId,否则子会话被准入闸拒掉、任务不执行 Co-Authored-By: Claude Opus 5.5 <[email protected]>
- 源会话已归属主人时不走按发言人分道(分道会话没有主人、cwd 是 worktree,会被准入闸拒掉、消息丢失) - 工作流启动前的助理模式检查:本进程未注册该 bot(独立运行 / 其他 daemon 的 bot)时回落读 bots 配置 Co-Authored-By: Claude Opus 5.5 <[email protected]>
- 准入判定抽成 decideAssistantAdmission:还没跑过 CLI、未记主人的新会话直接认领给当前主人并把 cwd 改到主人 work/,不再要求每条建会话路径(文档会话、headless、工作流节点投递等)各自填主人; 开模式前跑过的存量会话、主人已变、群未认领仍拒绝并退役 - 看板任务、卡片点击、HTTP/webhook 触发器建会话时解析主人;群未认领直接拒绝(不建空会话); 触发器在助理模式下不建 worktree Co-Authored-By: Claude Opus 5.5 <[email protected]>
- 准入判定:会话沙盒形态已冻结但没冻结「不放 Bot 密钥」(开模式前冻结的)→ 拒绝并退役,不认领也不放行, 否则这个会话的沙盒会缺少进程信息限制 - 退役会话时回一条提示(这条没处理、请重发),不再静默丢消息 Co-Authored-By: Claude Opus 5.5 <[email protected]>
- sendWorkerInput:助理模式下,会话不归当前主人(开模式时没能退役的存量会话、主人已变)或没冻结「不放 Bot 密钥」 → 拒收、提示重发、再尝试退役;退役被拒时后续输入照样拒收 - IPC lark-tool 凭证:bot 已开 assistantMode 时一律不给 bot 身份令牌,不只看会话冻结的标志 Co-Authored-By: Claude Opus 5.5 <[email protected]>
- 在队列写入、promotion、bootstrap/IPC 实际投递前按实时 owner 复核 - 附件下载前退役失效会话,token 等待后重跑 withholding - 删除无效的 assistantLarkBotIdentity 配置与文档 - 补充换主竞态回归及关闭点分类 Co-Authored-By: Claude Code <[email protected]>
- finalDenyPaths 与 sealLarkKeyStore 统一,no-transport 不再回授 sessions.db - message/raw_input/inject_command 在同步及 bootstrap 投递前复核 owner,控制 IPC 不读 registry - transfer replay 在实际发送前复核 owner - 补齐两个 ordinary-delivery 夹具依赖及 Seatbelt/no-transport/时序回归 Co-Authored-By: Claude Code <[email protected]>
- finalDenyPaths 纳入助理会话库,保护 DB/WAL/SHM - finalReadOnlyPaths 过滤真实 BOT_HOME 及其祖先授权,owner 子树不受影响 - 覆盖标准与外部 BOT_HOME 的 Seatbelt 编译顺序及变异验证 Co-Authored-By: Claude Code <[email protected]>
- finalReadOnlyPaths 统一过滤 bot homes、会话库、附件与配置秘密及其祖先 - finalDenyPaths 保护全部 session-stores 与 bots/dashboard 配置秘密 - 补齐外部 BOT_HOME 下其它应用、其它 owner 与配置秘密的编译后回归 Co-Authored-By: Claude Code <[email protected]>
- function-harness 按需加载 live/transfer 两级归属判定 - deployment-continuation 手写 scope 同样接入真实判定 - 覆盖 capacity、session-contract、ordinary delivery 与 deployment 双腿回归 Co-Authored-By: Claude Code <[email protected]>
509ecd3 to
0db8b42
Compare
deepcoldy
left a comment
There was a problem hiding this comment.
最终 rebase 增量复审 head 0db8b42083d4cd781e1b267c179bd79c147cb326:确认 15 个提交只是原样移动到含全部修复的新 master,没有夹带额外逻辑变化。
独立复算与验证:
git merge-tree --write-tree 1eb362ec5 509ecd3795与git rev-parse 0db8b4208^{tree}完全一致,均为4e092c2b6270b4b391ea3be3911c046e227050b5。- range-diff 中 13 个
=、2 个!(第 8、11 提交)。两个!的 hunk 均只涉及worker-pool.tsimport 行:cli-execution-mode的既有导入上下文,以及 assistant admission import 的添加/替换;没有 admission 判定、调用参数或控制流变化。 - 最终 diff 仍为 53 个文件,全部属于助理模式实现、文档和对应测试,没有夹带 TraeX、runner teardown 或其它 master 修复。
- detached head 上运行归属闸、fs-policy、会话时序、附件换主、transfer replay、ordinary delivery、managed-origin、deployment 共 8 个测试文件:1037/1037 通过。
因此 rebase 增量没有新的代码阻塞。最终合入仍以 run 44886933638 的 attempt=1 全绿为准,不沿用旧 head、#3687 或 #3684 的绿灯。G9 macOS Seatbelt / live worker 验证继续保留为后续事项。
deepcoldy
left a comment
There was a problem hiding this comment.
#3652 的最终 head 首跑门禁已满足:run 44886933638(attempt=1,0db8b42083d4cd781e1b267c179bd79c147cb326)全部 job 成功。
- 四个
bun-testshard、四个testshard 全部通过; - build、三个 binary job、聚合 test/bun-test 全部通过;
Sandbox network boundary / network-boundary也为 SUCCESS。
结合 merge-tree / range-diff 的零逻辑变化确认、53 文件范围核对及 8 个相关测试文件 1037/1037 的验证,#3652 已具备按既定流程 squash 合入的条件。G9 macOS Seatbelt / live worker 验证继续作为后续事项,不以本次 CI 替代。
|
@xu4wang @deepcoldy 合入 master 后的 Midscene E2E 失败:Feishu live Midscene 失败。 这次运行覆盖 1eb362e…371ad146a(4 个提交),同批合入的还有 #3684 #3685 #3690,失败不一定由本 PR 引起。
|
|
🚀 Released in v3.59.27 |
背景
开放私聊的 Bot(谁都能私聊它)所有用户共用一个 cwd、一个 CLI 记忆目录、一份沙盒可写面:A 让 agent 写下的文件、A 的对话记录,B 私聊同一个 Bot 时都能让 agent 读出来。
做了什么
新增 bot 配置
assistantMode(默认关),把这类 Bot 变成「每个人自己的助理」:/group会话群 = 创建者;普通群 = 认领者(/assistant claim,管理员可/assistant owner @某人指定;主人退群后群进入待认领、停止服务)USER_HOME = <BOT_HOME>/users/<open_id>,cwd 固定在USER_HOME/work;CLAUDE_CONFIG_DIR/ codex home、fs-policy 授权、附件桶(attachments/<appId>/u/<open_id>,只读)、宿主侧读命令都只给本人的那份;可选模板目录assistantTemplateDir首次初始化(不跟随软链)assistantMode隐含 feat(sandbox): 新增 sandboxWithholdBotSecret,沙盒不放 Bot 密钥,send/history/quoted 走宿主中转 #3649 的sandboxWithholdBotSecret——沙盒里没有 App Secret、没有 lark-cli 密钥库;botmux send/history/quoted走宿主中转(宿主指定 session、quoted核对本会话所在群);会话 lark-cli 不给 bot 身份令牌(凭证接口按实时 bot 配置判,开模式前的存量会话也拿不到),--as user不受影响。list在助理模式下不可用(会列出别人的会话),文档已写明decideAssistantAdmission(core/assistant-spawn.ts),在 worker 启动(forkWorkerPrepared)和向活 worker 投递输入(sendWorkerInput)两处都判:work/(这样各条建会话路径不必各自记得填主人)/botconfig assistantMode on挂起/关闭该 bot 现有 worker,存量会话在下一条消息时由准入闸退役;认领 / 改绑主人时退役前主人的会话/assistant命令、i18n、文档(docs-site/docs/{zh,en}/assistant-mode.md、docs/file-sandbox.md、设计文档docs/design/2026-11-20-assistant-mode.md)刻意不做
assistantMode的 bot 行为不变(下载调用参数、关闭点、IPC 路由都有测试钉住;准入闸和输入闸在模式关时直接放行)sandbox: "oncall",其他沙盒档拒绝启动测试
全量单测对照(
npx vitest run --project unit,本机):本分支失败的 65 个文件里,59 个在干净 master 上同样失败(本机环境:HOME / 工具链相关);其余 6 个中 2 个是本分支引入的回归、已修(会话关闭点登记进关闭点矩阵;未开助理模式时下载调用参数不变),4 个单独重跑通过(满载偶发)。修完后没有再跑一遍全量,只跑了上面的定向集合。变异验证:新增判定逐条删掉/取反后对应测试都会失败——归属判定(认领条件、主人相等、冻结形态)、话题延续、fork 继承、工作流快照与启动两处检查(含未注册 bot 回落读配置)、按发言人分道旁路、看板/卡片/触发器三条路径的主人与未认领拒绝、活 worker 输入闸(含模式关时不生效)、凭证接口按实时配置拒绝。未被单测直接覆盖的是
forkWorkerPrepared里把adopt结果写回会话的几行(判定本身有测试)。追加修复:换主时序与凭证隔离
在
bfe25009e后追加c6f22ca26,覆盖跨 owner 隔离链的四个问题:admitQueuedActivationTail写入在 journal / FIFO 计数变化前接受统一 live-input 检查;promotion 在推进 journal 前复查;tracked IPC 与 standalone bootstrap 后的 init 在实际发送前再复查。覆盖 double-fork、protected-egress、opening follower、ACK 合并写入等入口。getTenantAccessToken()返回后重新读取实时 bot 配置,并重跑会话冻结标志 + 实时assistantMode的 withholding,慢请求跨模式切换不再发放凭证。assistantLarkBotIdentity配置、IPC gate2、init 透传、类型、/botconfig项及中英文文档;助理模式不提供 app 身份凭证例外。回归与变异证据
fenced-run执行。追加验证
bun run build:通过。ipc-lark-tool-identity88/88、close-consumer-matrix14/14、assistant-command17/17、assistant-mode15/15、fs-policy134/134)。对抗复核覆盖
对抗复核未发现新的行为缺陷,实际攻击与验证场景包括:
sessionStore.updateSession注入失败:首次不发送 IPC,tail / FIFO / activation / ledger / pendingPrompt 恢复;随后精确重试仅发送一次,不重复推进 journal。worker.send,pending delivery 清除;迟到 callback 后也不补发、不误报普通投递失败。未做真实飞书、真实 worker/CLI 与 daemon 重启后的 live 验证;上述结论来自真实组件、可控 Promise / 假时钟与故障注入。
Rebase 后增量修复:密钥库与内容 IPC
在
14a401555后追加276cd2f5d、cb62cf743、06a96d212、acaacde67(最终 headacaacde67),处理增量审查发现的四项问题:finalDenyPaths与sealLarkKeyStore统一,并覆盖全部 session-stores、bots/dashboard 配置秘密;finalReadOnlyPaths统一过滤 bot homes、session-stores、附件及其祖先授权,owner USER_HOME 与本人附件桶不受影响。session-stores/<appId>,但保留bots-info.json、bin等合法最小授权;最终 deny 同时覆盖其它 app 的 DB/WAL/SHM。message、raw_input、inject_command在同步发送及 bootstrap 后均复核 owner;transfer replay 也在实际发送前复核。term_action、display、refresh 等控制 IPC 不增加 registry 查询。assistantLiveInputAdmission is not a function与assistantTransferInputDeliveryAllowed is not defined。新增回归与变异证据
fenced-run。验证
bun run build:通过。44833385089全部 job 成功;Sandbox network boundary 44833385107成功。对抗复核覆盖
对抗复核先复现了 final allow 的同类回授,修复后按三种布局逐项解析真实
buildFsPolicy + compileToSeatbelt的最后匹配规则,未再发现问题:/Users/u;/Users/ufinal allow。核验结果:本应用及其它应用的 sessions.db/WAL/SHM、bots.json、dashboard secret、其它 owner 附件/HOME、共享 bot 凭证、lark-cli 密钥库均为 deny 或 deny-default;owner 工作目录与自有附件保持 allow。第三种布局中最终顺序明确为 ancestor allow 在前、密钥库与全部 session-stores deny 在后。
同步内容输入、bootstrap、transfer replay、控制 IPC 不读 registry 的定向用例也已复跑通过。未执行真实 macOS Seatbelt 内核或 live worker 端到端验证。
🤖 Generated with Claude Code