fix(hermes): 持久化原生会话用于冷恢复#500
Open
DeepColds wants to merge 1 commit into
Open
Conversation
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.
改动说明
修复 Hermes 适配器冷恢复时使用 botmux 逻辑 sessionId 作为
hermes --resume目标,导致 Hermes 报Session not found、上下文丢失的问题。主要改动:
sourceSessionId后,复用现有cli_session_id链路持久化到 botmux session 的cliSessionId。resumeSessionId/cliSessionId,缺失时才 fallback 到 botmuxsessionId。state.db中sessions.id,并 fallback 查询messages.session_id;能确认不存在时复用 worker 现有 fresh fallback,避免 crash-loop。state.db路径,覆盖HERMES_HOME/BOTMUX_HERMES_STATE_DB/hermes-botmux-sessionprofile 场景。影响面
CliAdapter.checkResumeTargetExists参数,新增可选stateDbPath,不改变其它 CLI 既有行为。cliSessionId;多个 Hermes Bot 共享 state.db 时仍依赖现有 marker 过滤逻辑隔离。/clear导致一次 drain 绑定多个 Hermes source 时,会按顺序持久化,最后一个 source 成为后续冷恢复目标,符合恢复最新 Hermes 上下文的预期。测试验证
已通过:
补充执行:
pnpm test结果:整体测试执行到
564 passed / 567 files、9089 passed / 9095 tests,失败 6 个,均与本次 Hermes 改动无关,集中在 Linux 进程发现/worker fence 类测试:test/session-discovery.smoke.test.ts期望 node comm,实际为MainThreadtest/v3-cancel-runtime.test.ts2 个 timeouttest/v3-worker-fence.test.ts3 个进程发现结果从 one/recovered 变 ambiguous后续验证建议
发布 canary 后请在 macOS + PTY + Hermes 0.18.2 环境验证:
cliSessionId(如20260716_163643_7782fd)。hermes --resume <Hermes native id>,上下文仍可恢复。