Repository navigation
feat(billing): durable refund retries and reconciliation - #5
Merged
Merged
Conversation
This was referenced Oct 16, 2026
YunfanGoForIt
force-pushed
the
codex/refund-compensation-20261016
branch
from
October 20, 2026 16:40
34b6db1 to
15e21ae
Compare
YunfanGoForIt
changed the base branch from
codex/architecture-refactor-20261016
to
main
October 20, 2026 16:40
…-quota pre-consume Sessions whose pre-consume truncated to zero had no durable refund receipt; a later Reserve debited wallet and key quota that Refund then silently skipped. Create the receipt before debiting so the durable worker can always recover the funds.
…tion Receipts inside their normal backoff window made every periodic run report failure and blocked succeeded-receipt cleanup. Count only due receipts.
YunfanGoForIt
marked this pull request as ready for review
October 20, 2026 16:56
|
维护者处理记录(2026-10-21):
本地验证: |
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.
Important
Codex 辅助设计、实现和验证,待维护者人工审阅;人工确认项保持未勾选。
📝 变更描述 / Description
BillingSession 的异步退款曾在设置内存 refunded 标记后分别退资金来源和 Key,最终失败只记日志。现在退款意图持久化后才交给异步 worker;钱包/订阅原始预扣/追加预扣与 Key 在一个 SQL 事务中退款,同时写幂等完成标记。缓存失效单独持久化为 cache_pending,重试不会再次入账。
新增一张不含 Key 明文的退款凭据表,复用原订阅幂等记录和现有 SystemTask 的调度、租约、失败记录及通知通道。失败采用持久化退避持续重试;Root 可分页对账、审阅重试或确认已核对的结果;未完成/结果不明记录受清理保护。可退款扣款直接写 SQL,避免进程内批量队列丢失原扣款而退款仍被恢复。
预扣前留下审计锚点,正常结算与退款终态分开;结果不明的预扣/结算不能按超时自动退款,保留并告警供人工核对。范围、状态契约、操作接口、清理及回滚约束见设计与测试记录。
以 PR #3 冻结提交为基线,独立分支和差异,不向 PR #3 追加提交,也不混入 Auto 标记 PR #4。基础提交进入 main 后可调整 base。
🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
📸 运行证明 / Proof of Work
保持 Draft,不合并、不部署;新表仅在隔离测试库迁移。未来回滚前需完成/导出非终态退款,不得直接让旧版本忽略待补偿状态。