Skip to content

fix(runtime): fail-closed CEX envelope size and slippage - #1160

Open
proerror77 wants to merge 2 commits into
cursor/emergency-sticky-degrade-3a89from
cursor/cex-envelope-fail-closed-3a89
Open

fix(runtime): fail-closed CEX envelope size and slippage#1160
proerror77 wants to merge 2 commits into
cursor/emergency-sticky-degrade-3a89from
cursor/cex-envelope-fail-closed-3a89

Conversation

@proerror77

@proerror77 proerror77 commented Sep 12, 2026

Copy link
Copy Markdown
Owner

Change

CEX validate_cex_pre_execution now rejects missing max_slippage_bps, missing max_order_notional, and missing max_order_quantity instead of treating None as allow. require_supported_cex_execution rejects cross_spread. LiveSmall stays disabled.

Stacked on #1153 (cursor/emergency-sticky-degrade-3a89). Addresses the Codex P2 that a missing quantity ceiling still skipped validate_order_limits.

Issue relationship

None

Validation

  • cargo test -p hft-ports --locked cex_envelope_does_not_treat_missing_size_or_slippage_as_allow
  • cargo test -p hft-live --locked cross_spread_cex_execution_is_not_admitted
  • Bybit order_envelope_preserves_the_venue_link_id now carries a signed quantity ceiling

Runtime impact and rollback

Fail-closed CEX Paper/Shadow admission for unbounded size/slippage/quantity and for cross_spread. Rollback is revert of this PR. This does not enable LiveSmall. Automatic artifact publication may follow merge; that is not deployment authority.

Open in Web Open in Cursor 

@coderabbitai

coderabbitai Bot commented Sep 12, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 115fce66-7ecb-4a5d-b790-6dd4c580b35c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@proerror77
proerror77 marked this pull request as ready for review September 12, 2026 04:58
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 12, 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
📝 Code Review Completed 2026-09-12T05:04:57.592932Z 5f84842 Draft marked ready
ℹ️ 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.

@cursor
cursor Bot force-pushed the cursor/emergency-sticky-degrade-3a89 branch from 673e9e4 to c9a0d0b Compare September 12, 2026 05:03
@cursor
cursor Bot force-pushed the cursor/cex-envelope-fail-closed-3a89 branch from 5f84842 to 7f41aa6 Compare September 12, 2026 05:03

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5f848425c1

ℹ️ 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".

Comment on lines +676 to +678
if self.lifecycle.max_order_notional.is_none() {
return Err(OrderIntentRejectReason::MissingMaxOrderNotional);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Require the signed quantity ceiling at the CEX gate

当 CEX envelope 提供 max_slippage_bpsmax_order_notional、但遗漏 max_order_quantity 时,这个新 gate 仍会放行;validate_order_limits 对缺失的 quantity ceiling 也直接跳过。这样,直接到达 adapter 或丢失 engine 注入字段的 envelope 可以绕过 deployment 中 max_order_size 对应的数量限制,而本提交新增的 Bybit 成功用例正构造并接受了这种 envelope。这里也应对 max_order_quantity == None fail closed,确保最终 CEX 边界同时执行签名的 order-size 限制。

AGENTS.md reference: AGENTS.md:L26-L27

Useful? React with 👍 / 👎.

@cursor
cursor Bot force-pushed the cursor/cex-envelope-fail-closed-3a89 branch from a378696 to 24da933 Compare September 12, 2026 05:26
@cursor
cursor Bot force-pushed the cursor/emergency-sticky-degrade-3a89 branch from 1cee072 to 7b860b8 Compare September 12, 2026 05:48
cursoragent and others added 2 commits September 12, 2026 05:48
Reject missing max_slippage_bps and max_order_notional on CEX
pre-execution instead of treating None as allow. Reject cross_spread
at require_supported_cex_execution. LiveSmall stays disabled.

Co-authored-by: Wild Card <proerror77@users.noreply.github.com>
Require signed max_order_quantity at the CEX pre-execution boundary
so a missing quantity ceiling is not treated as allow. LiveSmall
stays disabled.

Co-authored-by: Wild Card <proerror77@users.noreply.github.com>
@cursor
cursor Bot force-pushed the cursor/cex-envelope-fail-closed-3a89 branch from 24da933 to 45ac55f Compare September 12, 2026 05:48
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