Skip to content

fix(payments): recover accepted inbox and receipts across Go process crashes (A05 WIP) - #879

Closed
LIghtJUNction wants to merge 3 commits into
mainfrom
fix/a05-payment-channel-recovery
Closed

LIghtJUNction wants to merge 3 commits into
mainfrom
fix/a05-payment-channel-recovery

Conversation

@LIghtJUNction

@LIghtJUNction LIghtJUNction commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

开发主线交接(2026-10-12)

开发默认主线现为 wip/rust-core-go-extensions;旧单体 main 与 traditional 冻结于 3948a0a1ee1cefdd016a7aa45a11851545bb4b85。分支交接不是发布、部署或验收通过。原问题、源码基线、测试与未完成项保留;旧单体路径仅作历史证据,后续先在微服务源码重新确认并按职责移植,不回灌旧数据库/权限/资金实现。

主线/S11 跟踪:#895。Extore 商品同步:#894,未验收,禁止部署,尤其禁止合并/推送 Extore main。

本 PR 的候选实现和已有验证范围保持原样;不因主线交接自动合并或标记验收完成。

范围

A05 支付恢复与宿主运行组件,目标 wip/rust-core-go-extensions。最新提交 cb3276d423bf2d81d4451180dd1e3ff18c1dd6df,继续使用原分支,不改写历史。

支付包和 Go/PostgreSQL 真实进程恢复 CI 已通过。A05 整体尚未完成,保留 Draft;没有合并、部署或真实资金操作。

修改

  • 保留 Rust 已接纳的原始支付证明。旧订单的供应商、商户、环境、币种、交易和渠道绑定不能被替换。
  • 原有改动使 Core 回执查询、退款冻结回执恢复、已接纳证明结算不再依赖 Go 渠道;实际 checkout/refund dispatch 仍需要原渠道,缺失配置不会消耗第一次发送机会,也不会抹去 UNKNOWN 和退款冻结历史。
  • 新增有界支付 Runtime:单一串行 worker、必需的依赖检查、首次成功批次后才就绪、HTTP 并发和时间限制,以及等待已接收操作退出的 drain。超时不提前释放仍在执行的请求名额。
  • 本轮补上 inbox → job 的恢复缺口。 之前在回调已入库、结算任务尚未生成时重启,缺失 Go 渠道仍会卡住已接纳付款。现在依据保存的原订单解析事件;在事务内再次检查绑定。旧记录缺少 proof ID 时只能查询已经接纳的证明,不能在恢复中接纳此前未验证的陈旧事件。
  • 新 HTTP 回调仍需要配置匹配的 adapter;未签名 API 观察也仍受原渠道限制。该改动不让 Go 取得验签或账本权限,不重新发起付款/退款。

本轮只修改 service.go、channel_recovery_test.go,新增 inbox_recovery_test.go 和 pgtest/process_recovery_test.go。整个 PR 累计九个支付文件;未修改共享宿主、账本、schema、proto、配置和 .github。

最新仓库 CI:通过

mk10-payment-safety / run 38239431197,job 114778091975,success。已读取实际日志。

测试对象是合并候选 fe5da457c4727e6864cf985e9a49aeb8fec4ce76。已核对其 Git parents:base 7ab9ee2fdfae90aa4bf5d4ac6ed3d7ac58b50ed4 + 本 PR head cb3276d4,不是沿用旧 base 的测试记录。日志确认 Go 1.25.0、独立 PostgreSQL 16.15。

在 services/extensions 通过:

go test -race -count=3 ./internal/modules/payments/... ./internal/coreclient ./internal/modules
go vet ./internal/modules/payments/... ./internal/coreclient

在 services/extensions/internal/modules/payments/pgtest 通过:

go test -race -count=1 -v ./...

原 PostgreSQL 持久化、并发、隔离测试及六个子场景通过;新增两个真实 Go 进程中断场景也实际执行通过:

终止位置 被终止的 Go PID 恢复 PID / 模拟 Core 结算调用 再次启动 PID / 模拟 Core 结算调用
inbox 已提交,job 尚未生成 11137 11145 / 1 次 11152 / 0 次
job 已保存,inbox 尚未标记完成 11161 11169 / 1 次 11177 / 0 次

父测试只终止自己创建的子进程,并等待其退出。恢复进程不配置 Go 支付 adapter。测试读回 PostgreSQL,确认同一收据、单一结算任务及原证明字节保持不变。独立 helper 在父测试进程中跳过是预期行为;父测试确实启动了以上六个不同 PID。

这些场景是真实 Go 进程 + PostgreSQL,Core 和 provider 仍是明确的模拟对象。 不据此声称 Rust 验签、真实账本入账、Rust 进程重启或真实供应商验收完成。

本地补充证据

隔离源码子集使用 Go 1.23.2:新增七项 inbox 回归后,28 个顶层测试带 -race 连续运行五轮通过(140 次);go vet 通过。新测试对旧源码出现预期失败,修复后通过。四个提交文件的 Git blob SHA 与本地测试文件一致,补丁按原基线应用检查通过。

本地 mise 仍不可用(退出码 127)。上述本地结果只是标准库源码子集;完整支付包和数据库结果来自已经通过的 GitHub CI,不能混用工具链或模拟边界。

尚未完成的 A05 项

  1. 正常宿主的 composition/config/模块注册/独立回调入口及真实支付就绪检查仍待 S11 接入。Runtime 组件通过不等于主程序已经启用支付。
  2. A03 WIP(A03): offline financial opening writer, strict replay and recovery #884 已推进到离线开账 writer(本轮核对 f18e552f),但尚未提供所需的不可变 LegacyPaymentBasis 历史退款合同;不能把 opening 余额伪装成原充值。
  3. Core 在退款 dispatch 未可靠绑定前仍拒绝释放退款 hold;不以失败事件清除 UNKNOWN 冻结金额。
  4. ePay 的 Rust 验签、其他 main 支付/订阅兼容,以及真实 Rust/Go 双进程、302 秒恢复和全账本读回仍待完成。

未访问生产数据库、未调用真实付费供应商、未改变共享工作区或其他任务文件。

Current independent review — remaining contract (2026-10-27 batch 2)

Independent current-base review keeps the full PR on HOLD. Six recovery source/test files were incorporated byte-for-byte in 79f8164e80f5698254e0ac4cc7e67a394e8114dd; subsequent mainline hardening must be retained. Normal payment host wiring and dispatch-bound Core refund release now exist, so older claims that they are entirely absent are historical. The three unincorporated Runtime files still carry payment-specific probe/first-success/readiness-expiry semantics that are neither accepted in the current composition lifecycle nor explicitly retired. Do not add a second unused Runtime or mark A05 complete from source presence. #895/A05 remains the owner of the unfinished readiness/dual-process recovery acceptance and original funds/UNKNOWN contracts. No new whole-A05 run or production acceptance is claimed.

This disposition records current code review only. Original descriptions, failures and unmerged work are retained; no CI rerun, deployment or full-project acceptance is implied.

…nnel recovery

Guard pending webhook resolution against missing adapters. Bind payment and refund operations to the original provider namespace, and avoid consuming attempts when the configured channel is unavailable. Add synthetic recovery regression tests.

A05 partial change only; final host integration, legacy refund basis and multi-process recovery remain pending.
…runtime

Keep Core-only receipt/proof recovery independent of Go provider availability while retaining original channel checks for external writes. Add a serial payment runtime with mandatory dependency probing, bounded HTTP admission, panic isolation and joined drain.

21 test functions pass in an explicit standard-library source subset with Go 1.23.2 and the race detector; runtime cases repeated 20 times and go vet passed. Four new settlement regressions fail against the prior worker and pass with this change.

A05 remains partial: normal-host shared wiring, legacy payment basis, remaining provider parity and real PG/Rust/Go process recovery are not verified. No production operation or deployment.
@LIghtJUNction LIghtJUNction changed the title fix(payments): preserve durable proofs and safe channel recovery (A05 partial) fix(payments): recover accepted payments and add bounded host runtime (A05 WIP) Oct 12, 2026
… crashes

Resolve durable inbox events against the original immutable order, rather than requiring the current Go provider adapter. Share binding checks with ingress, keep unsigned observations and external writes gated, and recover only existing Core proof acceptance.

Add seven inbox regression tests and two PostgreSQL subprocess crash scenarios. The process test kills only its own child after inbox COMMIT or job persistence, then starts independent recovery/replay processes without adapters. Its Core remains explicitly simulated.

Local standard-library source subset: 28 tests x5 with -race and go vet passed on Go 1.23.2. New PG process scenarios await repository CI; full Rust/Go recovery and A05 host/provider parity remain incomplete.
@LIghtJUNction LIghtJUNction changed the title fix(payments): recover accepted payments and add bounded host runtime (A05 WIP) fix(payments): recover accepted inbox and receipts across Go process crashes (A05 WIP) Oct 12, 2026
@LIghtJUNction

Copy link
Copy Markdown
Member Author

本轮固定核对 cb3276d423bf2d81d4451180dd1e3ff18c1dd6df,把现有支付包恢复证据与实际宿主支持分开,避免重复写第二套支付模块。

下一步明确收口在宿主接线,而不是重做包内 recovery:

  • services/extensions/internal/app/configuration.go:支付数据库、通道、回调 listener 的配置边界。
  • internal/app/run.go 和 internal/composition/runtime.go:payments 模块选择、构造、依赖探针、恢复/drain 生命周期;当前正常宿主仍未装配 payments。
  • 对照本 PR 的 payments/HOST_RUNTIME.md 接独立 callback ingress,不把供应商回调混入私有 host-token 路由。

联合验收仍需真实 Core 的能力/凭据/账本授权,以及 A03 的原付款/退款基准(不能用 opening balance 充当原支付)。现有 Go+PG 进程恢复证据的 Core/provider 是替身,不能扩写为整个支付链路已集成。

未运行远程 CI、未修改此 PR、未合并或部署;保持 Draft。来源/历史资金交接继续挂 #884 / #895。

LIghtJUNction added a commit that referenced this pull request Oct 12, 2026
…[skip ci]

Ports scoped recovery work from acdfe3d, c010035 and cb3276d (#879), authored by LIghtJUNction. Go race and isolated PostgreSQL process-crash checks passed. Host enablement and real Rust ledger joint acceptance remain unverified.
@LIghtJUNction

Copy link
Copy Markdown
Member Author

主线 79f8164 已移植本 PR 的六个持久证据/渠道/回执恢复文件,并通过 Go race、独立 PG 和真实 Go 子进程崩溃测试。但 runtime.go、runtime_test.go、HOST_RUNTIME.md 三项未接受,实际支付宿主仍未接线;进程测试使用合成 Core,真实 Rust 账本跨进程联合尚缺。因此本轮不把窄移植登记成整份 PR 合并,保留开放状态继续完成宿主合同和真实资金验收。未启用实际支付、未部署。

@LIghtJUNction

Copy link
Copy Markdown
Member Author

Current WIP payment host verification (2026-10-25)

The current WIP already contains payment composition and host callback wiring; the old PR's missing runtime.go claim is stale for this line. I ran the current focused regression:

cwd=services/extensions
command=mise exec -- go test ./internal/app ./internal/composition -run 'Payment|payment' -count=1
result=PASS
internal/app: ok (0.629s)
internal/composition: ok (10.060s)

This verifies current host configuration, callback isolation/drain and payment composition tests. It does not prove real Rust/Core cross-process financial recovery or provider checkout/refund acceptance, so this old PR remains Draft and is not merged as a whole.

Copy link
Copy Markdown
Member Author

以 superseded / migrated 关闭此旧布局 PR。实现进入 TokenNotIncluded/lmm-api-source,由配方仓库固定源码版本;配方 PR #967 已合并。 本次关闭代表迁移取代,支付能力尚未全部完成。

原候选 cb3276d423bf2d81d4451180dd1e3ff18c1dd6df 的已抽取范围及历史证据保留。当前源码已记录两项真实 Core/Go 双进程恢复和 PREPARED 状态读取验收;这些证据继续按原输入适用。支付 readiness、其余精确故障点、完整 checkout/refund/hold、资源边界及供应商验收由 #895 的 PR879-R1~R3 继续跟踪。

完整接口与验收要求见 迁移合同,13 项待办已实际写入 #895。关联的未完成 issue 保持开放。保留本 PR 正文、原始候选与历史通过/失败证据;未将本 PR 源码直接合回配方项目。

@LIghtJUNction
LIghtJUNction deleted the fix/a05-payment-channel-recovery branch November 5, 2026 07:31
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.

1 participant