Skip to content

fix(collector): validate observed USD-M zero-price sentinel - #816

Merged
proerror77 merged 1 commit into
mainfrom
codex/raw-trade-observed-sentinel
Aug 11, 2026
Merged

proerror77 merged 1 commit into
mainfrom
codex/raw-trade-observed-sentinel

Conversation

@proerror77

@proerror77 proerror77 commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Change contract

Accept the observed Binance USD-M zero-price trade sentinel only when p=0, q=0, X=NA, and st=1; preserve all existing stream, identity, dual-clock, and trade-ID validation. Positive trades remain p>0,q>0, and zero events remain audit-only raw_trade_zero_price events.

Issue relationship

Refs #815

Out of scope

No Spot acceptance, negative/non-sentinel fallback, runtime/ECS/OSS/Live changes, deployment, or workflow/dependency changes.

Dependencies and merge order

None

Focused validation

  • Red on exact observed t=553104312 (stream=btcusdc@trade, p=0,q=0,X=NA,st=1) before the fix: raw trade field q is not positive.
  • cargo test -p hft-data --lib --locked: 78 passed.
  • Linux target collector check and scoped Clippy (hft-data, hft-collector --bin binance-lob-archiver --tests) pass with -D warnings.
  • Collector real-window upload-only E2E passes 1/1 in a temporary macOS libc shim (RUSAGE_SELF only); native macOS test execution remains blocked by the pre-existing libc::RUSAGE_THREAD error in polymarket_upload.rs.
  • Artifact verifier replay proves IDs 553104311-553104315 are continuous, three zero events are not counted as valid raw_trade, and the strict shape rejects malformed/mismatched fields, Spot, and negative prices.

Rollout and rollback

None; code-only PR. Runtime/deployment remains separately gated.

Scope exception

None

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of zero-price Binance USD-M trades by validating required quantity and status fields.
    • Preserved valid positive-price trades while rejecting malformed, incomplete, or negative-price events.
    • Improved continuity and event-count accuracy when processing streams containing zero-price and regular trades.
  • Tests

    • Expanded coverage for valid, malformed, and mixed real-time trade sequences across supported stream types.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

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

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

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 Plus

Run ID: 1054b3c0-f0e9-4a84-83d3-d03b49dac518

📥 Commits

Reviewing files that changed from the base of the PR and between 826c9a7 and 7bb7a6d.

📒 Files selected for processing (1)
  • rust_hft/tools/collector/src/bin/binance-lob-archiver.rs
📝 Walkthrough

Walkthrough

The change validates zero-price Binance raw trades against required sentinel fields. It adds continuity coverage for multiple zero-price events and updates USD-M archiver fixtures and upload contract assertions for realistic BTCUSDC frames.

Changes

Binance zero-price raw trades

Layer / File(s) Summary
Zero-price sentinel validation
rust_hft/data-pipelines/core/src/binance_market_tape.rs
Zero-price trades require quantity 0, execution type X = "NA", and status flag st = 1. Tests cover valid and invalid sentinel fields and positive-price quantity validation.
Market-tape continuity coverage
rust_hft/data-pipelines/core/src/binance_market_tape_artifact.rs
Fixtures and integration tests cover two regular trades around three zero-price trades and verify manifest event counts.
USD-M archiver contract fixtures
rust_hft/tools/collector/src/bin/binance-lob-archiver.rs
USD-M fixtures use observed payloads, deterministic BTCUSDC timestamps, all stream types, and assertions for two regular and three audited zero-price events.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes validation of the observed USD-M zero-price sentinel.
Description check ✅ Passed The description completes every required template section with scope, validation, dependencies, issue linkage, and rollout details.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/raw-trade-observed-sentinel

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 force-pushed the codex/raw-trade-observed-sentinel branch from 826c9a7 to 7bb7a6d Compare August 11, 2026 07:12
@proerror77
proerror77 merged commit 6c2cbd1 into main Aug 11, 2026
45 checks passed
@proerror77
proerror77 deleted the codex/raw-trade-observed-sentinel branch August 11, 2026 07:22
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