Skip to content

fix(outbox): preserve rejected appends across quarantine interruptions - #2625

Merged
vastsa merged 3 commits into
vastsa:mainfrom
ZedingZhang:fix/crash-safe-outbox-quarantine
Nov 27, 2026
Merged

vastsa merged 3 commits into
vastsa:mainfrom
ZedingZhang:fix/crash-safe-outbox-quarantine

Conversation

@ZedingZhang

Copy link
Copy Markdown
Contributor

Summary / 概要

原实现先从活动队列移除被拒绝的消息,再把失败记录写入另一个文件。两次文件替换之间的进程退出或归档写入失败,都会使这次拒绝失去可恢复的副本。

本次改动先将唯一的归档标识、原始内容、拒绝时间和原因保存在活动队列中。失败队列提交成功后才清理活动记录。进程重启后,即使 Host 暂不可用,也可以按同一标识补完归档。这样既能识别已写入的失败记录,也能继续投递后来使用相同消息键的新快照。

两个文件沿用现有的 JSON 数组格式,历史记录可直接读取。每次归档会多做一次活动队列文件替换,用于保存中断恢复所需的信息。存储规格 · 对应的 E2E 场景

Requirement link / 需求关联

Closes #2624

Testing / 验证

  • 在上游基线 374317cb 上,归档前退出和归档写入失败两个用例均复现了恢复记录丢失。
  • 在候选提交 42245f9 上,68 项持久化、检查点和退出相关测试全部通过,其中 7 项为新增回归用例。覆盖失败队列文件替换前后分别退出、写入失败后重试、同键快照替换,以及清理失败后删除会话。新增回归测试
  • 桌面端 TypeScript 类型检查、pnpm lint、架构检查、pnpm check:pr-base 和 git diff --check 均通过。

复跑上述 68 项测试的命令如下。

node --test apps/desktop/test/persistence-outbox*.test.mjs \
  apps/desktop/test/inflight-checkpoint*.test.mjs \
  apps/desktop/test/confirmed-quit-teardown.test.mjs \
  apps/desktop/test/shutdown-regenerate-persistence.test.mjs

本地验证环境为 macOS 15.7.2 arm64、Node.js 26.0.0。中断测试使用真实子进程和临时文件,Host 使用测试替身。完整 Electron 界面流程和 Windows 实机强退尚未验证。

ZedingZhang and others added 2 commits November 27, 2026 14:35
Removing a rejected append before its dead letter was committed left
no recovery record if the process exited or the archive write failed.

Keep the transfer identity with the queued snapshot until the archive
commit succeeds. Recovery can then finish the handoff exactly once and
leave a newer snapshot with the same key available for delivery.
@vastsa

vastsa commented Nov 27, 2026

Copy link
Copy Markdown
Owner

已独立验证:在 da30a57b8 上用同一回归用例,归档替换前中断和归档写入失败均能复现恢复记录丢失。合并候选 b17ea511 的可执行树与本地测试树一致;持久化、真实子进程中断、检查点和退出 68 项全过。修复把归档意图先保存在源队列,归档提交后才清理,并以持久 ID 防止中断后重复归档,直接覆盖根因。已无损同步主线到 9201a06d,未改作者提交;待该提交的 CI 全绿且主线仍匹配后合入。

@ZedingZhang

Copy link
Copy Markdown
Contributor Author

@vastsa 感谢验证!CI 已经全绿而且主线仍然匹配

@vastsa

vastsa commented Nov 27, 2026

Copy link
Copy Markdown
Owner

谢谢提醒。上一轮 CI 通过后主线已推进到 cc972c3d1,我已保留作者提交、无冲突地同步到 91cdbd081。最新主线上的同树候选通过了 68 项 outbox、真实子进程中断、检查点和退出测试,基线检查也已通过。等这个新候选的 CI 全绿后再合入,不沿用旧主线的绿灯。

@vastsa
vastsa merged commit cb68af0 into vastsa:main Nov 27, 2026
6 checks passed
@ZedingZhang
ZedingZhang deleted the fix/crash-safe-outbox-quarantine branch November 28, 2026 10:30
zergfff added a commit to zergfff/PI-Desktop-fork that referenced this pull request Nov 30, 2026
Ported from vastsa/PI-Desktop v0.24.0-beta.7 (bug fixes only; the release's
features were left for a later rebase):

vastsa#2625 quarantine rejected outbox appends instead of retrying them forever
vastsa#2574 settle live turns and tool rows when the sidecar dies mid-stream
vastsa#2578 native Pi turns stay stoppable after a reload
vastsa#2634 the task badge mirrors work that is still running
vastsa#2639 let Arabic and Hebrew paragraphs choose their own side
vastsa#2640 stop a renderer crash loop with one GPU-less relaunch, then a dialog
vastsa#2642 reject differing spellings of one tool argument
vastsa#2655 compaction summaries open on demand in the transcript
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 会话消息转入失败队列时,进程中断可能丢失恢复记录

2 participants