fix(auth): use config-mutation for channel reload - #101
Merged
Merged
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
NewFuture
marked this pull request as ready for review
September 6, 2026 09:46
There was a problem hiding this comment.
🔵 Needs a closer look
Authentication persistence and host reload behavior still require the documented human whole-system validation.
Pull request overview
Migrates login-triggered reloads to the host’s focused config-mutation API, preventing stale runtime snapshots from overwriting source configuration.
Changes:
- Mutates only the channel reload timestamp with automatic follow-up.
- Adds login-path, persistence, compatibility, and CI coverage.
- Documents the fix bilingually.
File summaries
| File | Description |
|---|---|
src/auth/accounts.ts |
Uses source-based config mutation. |
src/auth/account-store.test.ts |
Tests preservation and failure behavior. |
src/channel.test.ts |
Tests all login reload paths. |
scripts/check-host-compatibility.mjs |
Adds unmocked host mutation smoke test. |
scripts/check-host-compatibility.test.mjs |
Tests preservation assertions. |
.github/workflows/ci.yml |
Runs smoke tests in strict jobs. |
CHANGELOG.md |
Adds Chinese release note. |
CHANGELOG_EN.md |
Adds English release note. |
Review details
- Files reviewed: 8/8 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This was referenced Sep 6, 2026
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.
变更说明
将
triggerWeixinChannelReload从运行时配置的读取、重建和整份写回,迁移到公共openclaw/plugin-sdk/config-mutationAPI。base: "source"和afterWrite: { mode: "auto" },只修改channels.openclaw-weixin.channelConfigUpdatedAt。参考 Tencent/openclaw-weixin#251 的局部配置 API 迁移,不引入其中其他 SDK 迁移或版本门槛调整。
验收标准
Closes #97
使用公共 mutation 子路径和明确的自动重载策略;只更新时间戳,保留当前 source 的其他内容,不插入空账号占位。失败时不回退到旧整份写入,不输出原始错误文本,也不回滚凭据或账号索引。CLI/Gateway 的正常登录和已绑定别名登记分支保持原有返回时机。精确宿主的导出、调用形状、注册和磁盘保留行为均有独立于 mock 的证据。
非目标与替代方案
本 PR 是兼容性/持久化边界修复。不修改二维码登录协议、账号身份、别名映射、凭据格式、状态路径、入站调度或消息 hooks;不复制配置锁,不添加重试队列、ambient SDK 声明或旧写入回退;不提升包、插件或最低宿主版本。
考虑过让登录调用方等待写入尝试完成,但这会改变登录延迟和生命周期顺序,也不能保证 Gateway 已完成重载。因此只在 helper 内部等待 mutation,以处理写入失败;调用方继续非阻塞。
auto表达宿主后续处理意图,不是重载完成确认。关联任务与风险
关联任务:#97,已标记
agent:ready与risk:privileged。最高风险:登录后的配置持久化和宿主重载边界。真实登录、并发配置编辑及目标 Gateway 的整机行为仍待人工确认,因此本 PR 为 draft。
风险与不变量
插件/频道 ID
openclaw-weixin、账号隔离、索引、别名、状态路径、登录返回时机、轮询/abort 和消息调度均不改变。凭据先由现有流程保存,后续配置写入失败不撤销它们。配置读取、串行化、冲突处理和落盘由宿主 API 拥有;沿用redactError保留安全错误元数据。最低宿主仍为
2026.6.1,锁文件宿主仍为2026.8.2,插件版本仍为3.1.6;没有 manifest、锁文件或版本变动,也没有提交生成产物。自动化测试用例
聚焦命令:
82 个用例通过。旧 helper 在新增用例中有 7 项失败,其中原始故障表现为写回旧根配置和旧频道值、重新引入已删除字段,而不只是 mock 调用次数不匹配。
兼容性验证
本地环境:Windows x64、Node.js
24.19.0,本 PR 提交d89cbb2的代码。最后正常组合:Unknown / 未确认;旧实现的问题依赖 source/runtime 差异,不声称每次旧写入都会丢失配置。2026.6.12026.7.12026.8.22026.9.1每个非锁文件目标按以下命令形状安装精确版本,再执行 typecheck/build,而不是先 build 再替换宿主:
真实 smoke 使用
scripts\check-host-compatibility.mjs的checkHostCompatibility(rootDirectory)入口,由临时隔离 wrapper 在新的 Node 进程中调用。wrapper 在 SDK import 前设置独立 state、home、config、OAuth 和临时 cwd,并在结束后清理;未使用 Vitest mock 或注入的假 I/O。它确认规范插件/频道 ID 和单次注册,调用编译后的生产 helper,实际读写隔离配置。仓库 CI 入口为node scripts\check-host-compatibility.mjs,新增 mutation 子进程自行隔离。各宿主完成后以
npm ci恢复2026.8.2,再执行完整常规 gate;manifest 与锁文件未变。保留现有 CI 的 Node.js 22/24/26 和旧宿主覆盖,当前宿主 strict jobs 新增同一 smoke。状态格式迁移:不适用,本 PR 不改变格式或迁移路径;既有迁移用例保留。
整机实测结果
脱敏关键日志
无。尚未开展人工整机实测;自动化过程中未访问真实微信后端或运行中的 Gateway。
其他验证命令
npm run checknpm run pack:checknpm test --prefix docs\sitenpm run build --prefix docs\sitegit diff --check检查清单
npm run check。