Skip to content

feat(data): verify Binance market tape artifacts - #120

Merged
proerror77 merged 2 commits into
mainfrom
codex/binance-market-tape-verifier
Jul 18, 2026
Merged

proerror77 merged 2 commits into
mainfrom
codex/binance-market-tape-verifier

Conversation

@proerror77

@proerror77 proerror77 commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Change contract
Externally authenticated content and manifest SHA-256 values seal bound Binance market-tape file descriptors; only one capture session whose manifests, immutable archived-row envelopes, clocks, LOB replay, aggregate trades, and cross-segment sequences all validate can produce an opaque VerifiedBinanceMarketTape with typed read-only projections. Manifest and archived-row envelopes are closed-world; nested frame and snapshot values remain authenticated, venue-owned raw Binance payloads and may carry additional venue fields, while only validated identity, clock, sequence, numeric, and replay surfaces enter the verified projections.

Out of scope
Collector production, downloader or OSS selector, trade backfill, research mapping, snapshot assembly, deployment, database import, Polymarket or ECS changes. Versioning a closed-world Binance raw-payload schema is also out of scope.

Dependency or merge order
#104, #118, #121, and #124 are merged. This PR is rebased on current main 9ae1ef9e and has no remaining prerequisite. It does not depend on a downloader.

Focused validation

  • cargo test --locked -p hft-data: 22 passed
  • cargo test --locked -p hft-data binance_market_tape_artifact -- --nocapture: 5 passed
  • cargo clippy --locked -p hft-data --all-targets -- -D warnings
  • cargo fmt --package hft-data -- --check
  • git diff --check
  • Counterexamples cover rewritten sibling self-authentication, cross-segment gaps, mixed capture sessions, and incomplete v1 artifacts.
  • Exact-head Standards review: no findings.
  • Exact-head Spec review: no findings after reconciling the authenticated open-world raw Binance payload boundary against real USD-M fields.
  • Scope is 732 non-generated lines plus 31 generated Cargo.lock lines, below the 750-line split threshold.

Rollout or rollback impact
No runtime rollout. This adds only a fail-closed verifier seam and opaque verified handle. Rollback removes Binance market-tape eligibility but does not alter collection, deployment, execution, or live trading.

@coderabbitai

coderabbitai Bot commented Jul 17, 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: 12 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: 3c2af898-6aca-4561-b6ee-9f5cc5f87038

📥 Commits

Reviewing files that changed from the base of the PR and between 9ae1ef9 and 780ad17.

⛔ Files ignored due to path filters (1)
  • rust_hft/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • rust_hft/data-pipelines/core/Cargo.toml
  • rust_hft/data-pipelines/core/src/binance_market_tape_artifact.rs
  • rust_hft/data-pipelines/core/src/lib.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/binance-market-tape-verifier

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.

Comment thread rust_hft/data-pipelines/core/src/binance_market_tape_artifact.rs Fixed
@proerror77
proerror77 force-pushed the codex/binance-market-tape-verifier branch from 674217c to 780ad17 Compare July 18, 2026 02:24
@proerror77
proerror77 marked this pull request as ready for review July 18, 2026 02:49
@proerror77
proerror77 merged commit 25cb490 into main Jul 18, 2026
22 checks passed
@proerror77
proerror77 deleted the codex/binance-market-tape-verifier branch July 18, 2026 02:54

@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: 780ad174f4

ℹ️ 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 +246 to +247
if aggregate_trades.is_empty() {
bail!("verified market-tape has no aggregate trades");

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 Require aggregate trades for every declared symbol

For multi-symbol artifacts, this only checks that at least one aggregate trade exists anywhere in the sealed set, so a replay-safe segment containing BTC and ETH checkpoints/books but only a BTC agg_trade can still produce a verified handle with no ETH price surface. I checked the collector path: replay_checkpoint_ready only marks a segment replay-safe after every state key appears in aggregate_trade_symbols (rust_hft/tools/collector/src/bin/binance-lob-archiver.rs:1083-1085), so the verifier should reconstruct that per-symbol coverage before accepting the manifest’s latest aggregate trade price contract.

Useful? React with 👍 / 👎.

}
checkpoints.insert(symbol.clone());
}
observe_replay(&mut replay, &symbol, event_type, raw, received_at_ns)?;

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 Reject leading checkpoint-only replay seeds

When the sealed set starts at a segment_open/checkpoint-only segment, this call lets the existing replay validator install that collector-generated checkpoint as the initial book state; I checked ReplaySequenceValidator::observe, and with no prior state it accepts a checkpoint at rust_hft/data-pipelines/core/src/binance_lob_replay.rs:214-220. That means an anchored file with just a bridged checkpoint plus one aggregate trade can verify without any raw Binance snapshot/diff evidence for the book, so leading checkpoints should be rejected unless an earlier sealed segment has already replayed the state they summarize.

Useful? React with 👍 / 👎.

Comment on lines +253 to +254
if book.bids.is_empty() || book.asks.is_empty() {
bail!("verified market-tape contains an empty replayed book");

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 Reject non-positive levels in verified books

If an anchored tape carries a snapshot/checkpoint/diff level with a zero or negative quantity (or non-positive price), the replay path only parses the decimals (rust_hft/data-pipelines/core/src/binance_lob_replay.rs:364-368) and this final check treats any non-empty side as valid. In that scenario VerifiedBinanceMarketTape can expose a replayed book containing impossible live levels, so the verifier should reject non-positive final book levels rather than only checking that each side is non-empty.

Useful? React with 👍 / 👎.

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