Skip to content

fix(runtime): keep Emergency sticky against degrade - #1153

Open
proerror77 wants to merge 4 commits into
mainfrom
cursor/emergency-sticky-degrade-3a89
Open

fix(runtime): keep Emergency sticky against degrade#1153
proerror77 wants to merge 4 commits into
mainfrom
cursor/emergency-sticky-degrade-3a89

Conversation

@proerror77

@proerror77 proerror77 commented Sep 12, 2026

Copy link
Copy Markdown
Owner

Change

Emergency mode stays latched until process restart. enter_degrade_mode, Sentinel recovery/force-recover, and the gRPC degrade RPC no longer rewrite Emergency to Degraded, so ensure_accepting_new_intents continues to reject new orders.

After the first Emergency latch, Sentinel still emits a bounded number of EmergencyExit actions so an incomplete or failed emergency_stop(true) can retry venue cancels. A complete cancel stops further retries. Engine Emergency still does not cancel those leftover orders by itself.

Issue relationship

None

Validation

Smallest disproof: after emergency_exit(), enter_degrade_mode / Sentinel degrade-band check / gRPC enter_degrade_mode must leave TradingMode::Emergency and keep submit_order_intent rejected.

Cancel-retry disproof: after the first EmergencyExit, degrade-band check must keep returning EmergencyExit until the retry budget is spent or mark_emergency_cancel_complete runs, and must never return Degrade.

Owning checks: cargo test -p hft-engine --locked emergency_mode_cannot_be_downgraded, cargo test -p hft-risk --locked emergency_, cargo test -p hft-grpc-server --locked enter_degrade_mode_cannot_leave_emergency, cargo test -p hft-live --locked sentinel_degrade.

Runtime impact and rollback

Fail-closed control-plane change only. No live enablement, envelope activation, or collector/research path. Rollback is revert of this commit. Merge may awaken automatic GHCR publication of the merged SHA; that is not deployment authority.

Open in Web Open in Cursor 

@coderabbitai

coderabbitai Bot commented Sep 12, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 13a717cd-f3ef-4bb8-b87a-85035e16f3a5


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:37
@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-12T04:41:51.197971Z 8fa98f8 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.

@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: 8fa98f87d0

ℹ️ 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 +226 to +228
if self.state == SentinelState::Emergency {
return SentinelAction::Continue;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 保留紧急撤单的后续重试

当首次 emergency_stop(true) 因控制通道超时、适配器错误或部分撤单失败而返回错误或不完整报告时,这个提前返回会令后续检查永远只产生 Continue;因此 run_sentinel_loop 不会再次调用紧急撤单,而 OMS 中仍为开放状态的订单可能继续留在交易所。引擎模式保持 Emergency 并不能撤掉这些既有订单;应在锁定 Sentinel 状态的同时保留有界的 EmergencyExit 撤单重试路径。

AGENTS.md reference: AGENTS.md:L103-L104

Useful? React with 👍 / 👎.

cursoragent and others added 4 commits September 12, 2026 05:48
enter_degrade_mode, Sentinel recovery, and gRPC degrade no longer
downgrade Emergency to Degraded, so new order intents stay rejected
until restart.

Co-authored-by: Wild Card <proerror77@users.noreply.github.com>
Owning-package Clippy compiles the included proto trait, and tonic::Status
trips result_large_err. Keep Emergency degrade fail-closed without that
unrelated lint failing the crate.

Co-authored-by: Wild Card <proerror77@users.noreply.github.com>
Keep Sentinel Emergency sticky against Degrade, but emit a bounded
EmergencyExit path so an incomplete or failed emergency_stop can still
retry venue cancels. A complete cancel stops further retries.

Co-authored-by: Wild Card <proerror77@users.noreply.github.com>
Monorepo CI failed on hft-collector concurrent legacy-tape parity
(append rate below 100 rows/s). That test is outside the Emergency
sticky diff; retrigger without changing collector.

Co-authored-by: Wild Card <proerror77@users.noreply.github.com>
@cursor
cursor Bot force-pushed the cursor/emergency-sticky-degrade-3a89 branch from 1cee072 to 7b860b8 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