Skip to content

fix(market): 结算事实必须绑定本订单托管账腿(#71 切片) - #151

Merged
LIghtJUNction merged 1 commit into
mainfrom
fix/escrow-slice-20260928
Sep 28, 2026
Merged

LIghtJUNction merged 1 commit into
mainfrom
fix/escrow-slice-20260928

Conversation

@LIghtJUNction

Copy link
Copy Markdown
Contributor

摘要

  • [P1] 确定性清算、银行边界、报价兑换与 Entitlement #71 的一个窄切片,不关闭 issue。只补了托管结算里缺的一个确定性校验,没做 ServerOffer→Listing 重命名、没改 schema、没改生产资金。
  • 问题:validate_projection 只核对了 order_settlements.receipts 里的收据确实存在于 money_ledger,没核对它们是不是本订单的托管账腿。这样一条伪造的退款事实(比如引用本单的入金收据,并同时改好可变投影 state/receipt_refs/settled_at)会被 contract() 当作已退款,而托管账户里的钱其实还没动。
  • 修复:结算事实必须满足 order_id 一致、refund_minor/release_minor 是非负整数,并且每张收据都要按顺序精确对应 settle() 产生的账腿(kind、从本单 escrow_subject 转出、收款方为买家或卖家、金额、币种、order_refund:/order_release: 引用)。

改动范围

  • src/msg/market/policy.py:validate_projection 增加账腿绑定校验。
  • tests/test_market_71.py:伪造「复用入金收据的退款事实」会被 order_settlement_mismatch 拒绝;真实超时退款仍能通过 contract(),且守恒成立。

测试计划

  • 未加修复时,新测试失败(DID NOT RAISE),说明这个缺口真实存在。
  • python -m pytest tests/test_market_71.py:4 passed(真实 PostgreSQL)。
  • 市场/订单回归:lifecycle、arbitration、recovery、delivery、lease_deadlines、manual_flow、integration、contracts、rationale、paths、order_paths、orders、escrow_decisions,共 88 passed。
  • 完整 CI

Refs #71(切片,不关闭)

Made with Cursor

An authentic receipt reused from funding could make a still-held escrow
look refunded; each settlement receipt must now be the exact refund or
release leg debiting this order's escrow account.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copilot AI lite review requested due to automatic review settings September 28, 2026 16:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-09-28T16:22:36.885804Z 4a8f10c PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@LIghtJUNction
LIghtJUNction merged commit e52ec57 into main Sep 28, 2026
11 checks passed
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.

2 participants