fix(wechat): detect repeated iLink send rejection - #3299
Conversation
Signed-off-by: fico-hub <fico@xd.com>
|
| Filename | Overview |
|---|---|
| apps/desktop/src/main/im/wechat/WechatIM.ts | 增加按绑定和时间窗累计发送拒绝的健康状态,并将其接入直接发送、媒体、outbox 与 epoch 生命周期。 |
| packages/wechat-ilink/src/apiClient.ts | 将 iLink 发送拒绝分类为稳定的 SEND_REJECTED,并识别发送及上传响应中的 AUTH_REPLACED。 |
| packages/wechat-ilink/src/errors.ts | 扩展安全错误码联合类型以包含 SEND_REJECTED。 |
| apps/desktop/src/main/im/wechat/tests/WechatIM.test.ts | 覆盖拒绝阈值、成功重置、媒体与 outbox 成功边界,以及 epoch 失效后的状态和任务收口。 |
| packages/wechat-ilink/src/tests/protocol.test.ts | 覆盖文本、媒体及上传接口的新错误分类和 retryable 属性。 |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[执行 iLink 发送或媒体上传] --> B{操作结果}
B -->|成功| C{是否达到完整成功边界}
C -->|是| D[清除当前 binding 的拒绝证据]
C -->|否| E[保留拒绝证据]
B -->|AUTH_EXPIRED 或 AUTH_REPLACED| F[立即进入 needs_reauth]
B -->|SEND_REJECTED| G[记录当前 binding 的窗口内拒绝]
G --> H{五分钟内累计三次?}
H -->|否| I[保留重试路径]
H -->|是| F
F --> J[中止当前 epoch 并收口交互与活跃任务]
Reviews (9): Last reviewed commit: "fix(wechat): release lease when pump los..." | Re-trigger Greptile
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3b3d192c6d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@fico-hub 👋 这个 PR 还有 1 条 review conversation 没 resolve(apps/desktop/src/main/im/wechat/WechatIM.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。 如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。 |
|
这条 PR 被维护者确认门拦住了(架构): 确认方式:维护者在本 PR 上 Approve;若要改,请 Request Changes,改完后再 Approve。 |
Signed-off-by: fico-hub <fico@xd.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 96e36d218c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@fico-hub 👋 这个 PR 还有 2 条 review conversation 没 resolve(apps/desktop/src/main/im/wechat/WechatIM.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。 如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。 |
Signed-off-by: fico-hub <fico@xd.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 43450b15cb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Signed-off-by: fico-hub <fico@xd.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4620a223c3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Signed-off-by: fico-hub <fico@xd.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f2c434499e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Signed-off-by: fico-hub <fico@xd.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b71baa97e6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Signed-off-by: fico-hub <fico@xd.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1f41320ebd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Signed-off-by: fico-hub <fico@xd.com>
dashhuang
left a comment
There was a problem hiding this comment.
发现一处需要先修的 P1 竞态:发送拒绝 abort 当前 epoch 后,#taskPump 可能正从 #pollBarrier 或 leaseNextTask() 返回;这两个 await 后没有重新确认 binding/signal 仍属于当前 epoch,因此会继续为旧 binding 派发新的 Agent turn。现有清理发生时该任务尚未加入 #activeTasks,覆盖不到它。
请在 barrier 和 lease 返回后统一检查 current epoch;若 lease 已取得 task,则先 releaseDispatch 再退出,并补一条 abort × lease 的交错回归测试。修复前暂不 Approve。
After a send rejection aborts the current epoch, #taskPump can still be awaiting the poll barrier or leaseNextTask(). When those resolve for the dead binding the stale pump could dispatch an Agent turn that epoch cleanup cannot cancel. Re-check the send epoch after both awaits. Release any leased task before returning so work is not lost, and cover the abort/lease interleaving with a deterministic regression test. Signed-off-by: fico-hub <fico@xd.com>
|
@dashhuang 已在 0909f06 修复该 P1: 本机 qwen3.8-27b 验证:WechatIM 33/33、Desktop typecheck、targeted ESLint、DCO 与 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0909f06a4c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (!this.#isSendEpochCurrent(binding.bindingEpoch, signal)) { | ||
| if (task) { | ||
| await this.#requireStore().releaseDispatch(task.bindingEpoch, task.id); | ||
| } |
There was a problem hiding this comment.
当 leaseNextTask 返回后 epoch 仍有效、但 #processTask 中的命令或交互回复路径正在等待数据库操作时,并发的 outbox/直接发送可能触发第三次拒绝并中止 epoch;这里的检查已经通过,而这些路径尚未加入 #activeTasks,所以拒绝清理无法停止它们。随后 /new、权限命令等仍会修改会话并为已失效的 binding 提交回复,回复无法发送且会在重新认证清理旧 binding 时被删除;应在进入相关处理及其关键 await 后再次校验该任务仍属于当前 epoch,或让中止信号贯穿这些路径。
Useful? React with 👍 / 👎.
|
@fico-hub 👋 这个 PR 还有 1 条 review conversation 没 resolve(apps/desktop/src/main/im/wechat/WechatIM.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。 如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。 |
这次改了什么
摘要
微信 iLink 在凭证仍看似有效、但发送端持续返回确定性拒绝时,原先会一直把消息留在重试队列,界面却仍显示已连接。本 PR 为发送失败增加稳定、无敏感信息的分类,并仅在同一绑定连续出现 3 次确定性拒绝时进入现有的
needs_reauth状态;单次未知拒绝仍可重试,成功发送会重置计数。媒体上传仍参与鉴权失效判断;直接发送只在实际消息成功后清除证据,outbox 则只在同一 item 的文本和全部媒体都投递成功后统一清除,避免中间成功掩盖后续媒体拒绝。变更类型
feat新功能fix缺陷修复refactor/perf重构或性能优化docs/test/chore文档、测试或工程维护范围
UI 变化
不涉及:仅修改桌面主进程中的微信连接健康判断与协议错误分类,没有视觉、交互布局或文案改动。
怎么验证的
自动验证
手工验证
不涉及:问题需要 iLink 服务端拒绝态,已用 API client 与 WechatIM 单元测试覆盖。
未执行的验证
未执行真实微信账号的服务端拒绝复现,避免触碰真实绑定;使用确定性响应 fixture 验证。
风险
风险分类
影响与回滚
needs_reauth,其他确定性拒绝需在同一绑定 5 分钟内累计 3 次。提交前检查
git commit -s,见 DCO)