Repository navigation
fix(sandbox): 沙盒孤儿清扫保护全部 bot 的 active 会话,附件清扫只扫本 bot 桶并在读不出时跳过 - #2318
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
October 25, 2026 05:37
# Conflicts: # src/daemon.ts
This was referenced Oct 25, 2026
Owner
Author
|
CI 说明(作者侧):当前 head 23aa5af 的 根因已经确定性复现: 按合码标准,偶发不靠重跑放行:已开 #2325,根治 PR 是 #2327。#2327 合入后,把 master 同步进本 PR,让 CI 在新 head 上重跑,再走合码。 这是自动评审流程中的作者说明,最终以维护者审阅为准。 |
This was referenced Oct 25, 2026
|
🚀 Released in v3.52.0 |
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.
Closes #2031,同时 closes #2189(附件 TTL 清扫收窄到本 bot 桶并 fail-closed)。
改了什么
core/sandbox-orphan-sweep.ts的runSandboxOrphanSweep):sweepOrphanSandboxes(Linux oncall / credential-only)、sweepOrphanScratchSandboxes(Linux scratch)、sweepOrphanMacScratchSandboxes(macOS scratch)。listActiveSessionIdsAcrossStores(读全部 bot 会话库里status='active'的会话 id,只查索引列)∪ 本 daemon 内存里的会话(还没落盘的也算)。listActiveSessionIdsAcrossStores和 feat(runtime): 会话 scratch 孤儿目录启动对账清扫(#1592 follow-up) #1748 的 PR(feat(runtime): 启动与周期对账清扫会话 scratch 与 MCP 网关孤儿目录 #2317)共用,两边提交内容完全相同。core/attachment-prune.ts的pruneBotAttachments):attachments/<本 bot appId>/。保护集合只读本 bot 的会话库(listSessionsStrict,含 closed 行),不再读全部会话库,也不再删别的 bot 桶里的目录。startDaemon开头(那时还不知道自己是哪个 bot)挪到本 bot 会话库首次加载之后。本 bot 的库那时已经迁移好;别的 bot 的遗留文件,包括 legacysessions.json,都不会让它永远跳过。pruneOldAttachments,它已经没有生产调用方。为什么
/root/.botmux/data,沙盒树(<dataDir>/sandboxes/<sid>、/var/tmp/botmux-scratch/<sid>)是整机共享的,但清扫只认本 daemon 的活跃会话。bot B 的会话一旦处于「仍是 active,但没有存活进程」的状态(空闲挂起、等冷恢复、worker 被 SIGKILL 后等重建),任何一个 bot A 的定时清扫过了 60 秒宽限期就会:影响面
session-store.ts新增一个只读函数;daemon.ts两处清扫调用合并为一处,附件清扫换了位置。没有动配置、命令、卡片和持久化格式。对老用户的影响
两处都属于修正错误行为:
已知限制 / follow-up
验证
bun run build:通过。bunx vitest run test/attachment-prune.test.ts test/sandbox-orphan-sweep.test.ts test/session-store-sqlite.test.ts test/sandbox.test.ts test/test-hygiene.test.ts:5 个文件 116 条全过(我在这个 worktree 里独立复跑过);bun test下两个新文件也都过。test/sandbox-orphan-sweep.test.ts在临时 dataDir 上跑真实的 Linux 清扫函数,scratch slot 指到临时目录,不碰/var/tmp/botmux-scratch:🤖 Generated with Claude Code