Repository navigation
fix(omp): 冷 resume 时自动迁移 pre-#955 旧共享目录会话记录 - #990
Merged
deepcoldy merged 1 commit intoAug 24, 2026
Merged
Conversation
Contributor
Author
|
补充验证:GitHub CI 全绿(build、pnpm test、pnpm workflow-core:test);本机用该提交执行 switch:here + daemon:restart 后 8 个 PM2 进程均 online;部署后合成 legacy 正例、exact-history 跳过路径与 structured bridge 回归 17/17 通过;未对已有 divergent exact/legacy 历史执行迁移或修改。 |
5 tasks
|
🚀 Released in v3.18.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.
背景
#955 起,每个 botmux OMP 会话钉到独立的 exact 目录
~/.omp/agent/sessions/botmux/<effective-id>/,resume 只从该目录内的精确 JSONL 读取。但 #955 之前开的会话,transcript 落在旧的 cwd-derived 共享 bucket(如~/.omp/agent/sessions/-repo/)——升级后这些老会话 resume 时在 exact 目录找不到记录,退化成 fresh 会话,历史丢失。改动
在冷(非 adopt)resume OMP 会话时,于既有 adapter probe 之前插入一个 fail-safe 迁移预检
migrateLegacyOmpSession:<session_id>marker(命中本会话且不含 foreign id)+ header 校验(type=session/version/id/timestamp/cwd)+header.cwd的 realpath 与当前工作目录匹配 + 文件名后缀与内部 native-id 一致;O_CREAT|O_EXCL|O_NOFOLLOW0o600 → 边拷边算 sha256 → fsync →linkSync不覆盖发布 → 重开目标复验摘要 → fsync 目录),随后既有 resume 逻辑正常续接历史;配套:
omp-transcript.ts的visibleText提升为导出的ompMessageText(纯加法,迁移侧复用同一文本投影,单一来源);worker.ts 接线(guard:cliId==='oh-my-pi' && effectiveResume && !willReattachPersistent && !cfg.adoptMode)。安全姿态
改动触及沙盒边界 + worker 启动热路径 + 跨会话读,全程 fail-closed / fail-safe:
linkSync(内核级 EEXIST 不覆盖)保证,发布前存在检查兜底,catch 块只删临时文件、永不删已发布目标;O_NOFOLLOWopen + fstat(dev/ino/size/mtime/ctime)快照,copy 前后各复核一次;withFileLockSync按 exact 目录 hash 跨进程串行化;扫描预算封顶(256 bucket / 4096 file / 单文件 16MB / 总 128MB / 单行 1MB);botmux命名空间目录,绝不把别的 exact 会话误当 legacy bucket。影响面
cliId==='oh-my-pi'下触发,对其余 20+ CLI 完全 no-op;未改动adapters/cli/共用基类;ompMessageText重命名是纯加法,旧调用点全部改到新名,无外部消费者。adoptMode、持久后端 reattach(willReattachPersistent)、fresh 启动均跳过。O_NOFOLLOW在 Linux 完备;Windows 上NO_FOLLOW=0(第三层不存在),但不影响生产环境。测试验证
pnpm build/tsc --noEmit全绿(CI build job SUCCESS)test/oh-my-pi-legacy-migration.test.ts11 例(byte-for-byte 拷贝 + 私有权限、幂等重试、发散 exact 历史不选边、零/多/assistant-only/foreign/cwd/header/filename 全拒、symlink/special fail-closed、预算耗尽、源文件突变 TOCTOU、并发目标不覆盖、worker guard 顺序)test/fs-policy-bwrap.e2e.test.ts扩展为真 bubblewrap e2e:迁移文件沙盒内可读、legacy 源不可读test/structured-bridge-clis.test.ts补 legacy 桶不被 exact resolve 误挂后续
这是为 #955 升级断层打的过渡兼容补丁。待存量老会话自然消解后应移除此逻辑(见 follow-up issue)。