Skip to content

fix(runtime): separate liveness from readiness - #62

Merged
proerror77 merged 5 commits into
mainfrom
codex/runtime-health-readiness
Jul 16, 2026
Merged

proerror77 merged 5 commits into
mainfrom
codex/runtime-health-readiness

Conversation

@proerror77

@proerror77 proerror77 commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Change contract

Expose reconciliation/risk/data-integrity truth through readiness while keeping liveness probes independent; require authoritative venue reconciliation only for LiveSmall attribution, not simulated Paper/Shadow.

Out of scope

No account reconciliation implementation, cross-venue exposure policy, backtest changes, or alpha promotion-state transition changes.

Dependencies and merge order

Depends on #60 for the authoritative runtime-truth contract. #60 is now merged; this PR targets main.

Focused validation

  • cargo test -p hft-live runtime_attribution::tests::paper_and_shadow_snapshots_do_not_require_live_reconciliation -- --exact
  • cargo test -p hft-live runtime_attribution::tests::live_small_snapshot_decays_without_authoritative_reconciliation -- --exact
  • cargo test -p hft-infra-metrics
  • cargo test -p hft-live --test deployment_artifacts
  • cargo check -p hft-live --features clickhouse,redis,grpc --locked

Rollout and rollback

Kubernetes/Docker liveness uses /health; /readiness stays the fail-closed admission signal. Revert this PR to restore the old probe behavior.

Scope exception

None.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@proerror77, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 51 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b6ed549f-c8e0-48d2-be68-0ae514459ca1

📥 Commits

Reviewing files that changed from the base of the PR and between 2f3476b and 37b1ddc.

📒 Files selected for processing (11)
  • deploy/Dockerfile.hft
  • rust_hft/apps/live/src/helpers/metrics.rs
  • rust_hft/apps/live/src/helpers/sentinel.rs
  • rust_hft/apps/live/src/main.rs
  • rust_hft/apps/live/src/runtime_attribution.rs
  • rust_hft/apps/live/tests/deployment_artifacts.rs
  • rust_hft/apps/live/tests/deployment_envelope.rs
  • rust_hft/deployment/docker/Dockerfile.trading
  • rust_hft/docker/Dockerfile
  • rust_hft/infra-services/core/metrics/src/http_server.rs
  • rust_hft/infra-services/core/metrics/src/lib.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/runtime-health-readiness

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 changed the base branch from codex/reconciliation-account-truth to main July 16, 2026 07:32
@proerror77
proerror77 marked this pull request as ready for review July 16, 2026 07:32

@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: ba04d138ff

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

let reconciliation_ready = match truth_age_secs {
None => false,
Some(age) => {
reconciliation_complete && reconciliation_healthy && age <= max_idle_secs as f64

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 Gate reconciliation readiness only for live venues

For non-live runtimes that still expose this shared metrics server, such as hft-paper with the metrics feature (apps/paper/src/main.rs:55-66) or quote/simulated configs, no authoritative venue reconciliation snapshot is ever published because the runtime only requires it for real live venues (system_builder.rs:765-774) and reconcile(false) skips publishing runtime truth (execution_control.rs:452-462). With this unconditional reconciliation_ready requirement, /readiness stays 503 forever even while those engines are otherwise healthy; the reconciliation gate needs to be conditional on runtimes that actually have an authoritative live account to reconcile.

Useful? React with 👍 / 👎.

&& util <= max_utilization
&& reconciliation_ready
&& !risk_halted
&& data_integrity_gaps == 0;

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 Avoid treating historical data gaps as current unreadiness

This readiness check uses data_integrity_gaps as if it were a current health bit, but the engine only increments that field when a Disconnect event is seen and never clears it (market-core/engine/src/lib.rs:1057-1059). In any live session with a transient market-data disconnect, the cumulative counter remains >0, so /readiness returns 503 for the rest of the process even after streams recover; readiness should be based on an active/stale gap state or a recent window, not the all-time count.

Useful? React with 👍 / 👎.

let reconciliation_ready = match truth_age_secs {
None => false,
Some(age) => {
reconciliation_complete && reconciliation_healthy && age <= max_idle_secs as f64

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 Give reconciliation a larger readiness budget

In the checked live path, the metrics server uses readiness_max_idle_secs: 5 (apps/live/src/helpers/metrics.rs:29) while the production reconciliation interval is also 5000 ms (deployment/k8s/configmaps.yaml:29) and the task waits one full interval between reports (system_builder.rs:1276-1280). Because this line requires the reconciliation age to be <= 5s, normal scheduling jitter or reconciliation latency can make /readiness briefly return 503 every cycle even when reconciliation is healthy; use a separate reconciliation staleness threshold with headroom over the configured interval.

Useful? React with 👍 / 👎.

@proerror77
proerror77 merged commit a9b824a into main Jul 16, 2026
25 checks passed
@proerror77
proerror77 deleted the codex/runtime-health-readiness branch July 16, 2026 08:19
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