Skip to content

fix(collector): align live shadow parity windows - #51

Merged
proerror77 merged 2 commits into
mainfrom
codex/polymarket-parity-live-fix
Jul 16, 2026
Merged

proerror77 merged 2 commits into
mainfrom
codex/polymarket-parity-live-fix

Conversation

@proerror77

@proerror77 proerror77 commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Summary

  • compare only mature Polymarket trade events while keeping the common retrieval cutoff
  • join trade metadata by market ID and bind cross-lane governed values
  • require/type-check governed metadata fields with fee-disabled null normalization
  • emit and enforce actionable trade/settlement mismatch evidence

Validation

  • cargo test -p hft-collector polymarket_parity (18 passed)
  • cargo clippy -p hft-collector --all-targets --features collector-binance -- -D warnings
  • cargo test -p hft-collector --features collector-binance (106 passed, 1 ignored in lib; all binary suites passed)
  • deployment/aliyun/test-polymarket-raw-ops-control-plane.sh
  • cargo fmt -p hft-collector -- --check
  • ShellCheck / bash -n / git diff --check

Production stays fail-closed: this PR does not cut over the Rust collector. A fresh one-hour shadow gate is required after merge and immutable artifact publication.

Summary by CodeRabbit

  • New Features

    • Improved shadow parity verification for trades and settlements.
    • Added stricter checks for trade IDs, metadata, timing, fees, outcomes, sizes, ticks, and risk settings.
    • Added detailed mismatch reporting, including affected markets and records.
    • Expanded parity evidence with trade and settlement timing details.
  • Bug Fixes

    • Prevented incomplete or inconsistent parity results from passing validation.
    • Added safeguards for missing records, duplicate trades, and metadata mismatches.
  • Tests

    • Added negative test coverage confirming invalid parity data is rejected.

@coderabbitai

coderabbitai Bot commented Jul 16, 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: 48 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: 3c184304-1cfe-4e3c-bc9a-1b4652b97471

📥 Commits

Reviewing files that changed from the base of the PR and between 99a5553 and 9c4bb8e.

📒 Files selected for processing (3)
  • deployment/aliyun/polymarket-raw-ops-shadow-gate.sh
  • deployment/aliyun/polymarket-shadow-gate-policy.jq
  • deployment/aliyun/test-polymarket-raw-ops-control-plane.sh
📝 Walkthrough

Walkthrough

Polymarket shadow parity now applies a 10-minute trade maturity lag, compares joined market context, reports explicit mismatch IDs, validates stricter settlement metadata contracts, emits expanded evidence metrics, and enforces these results through jq policy rejection tests.

Changes

Polymarket parity validation

Layer / File(s) Summary
Governed metadata contract
rust_hft/tools/collector/src/polymarket_parity.rs, deployment/aliyun/test-polymarket-raw-ops-control-plane.sh, deployment/aliyun/README.md
Required metadata fields, numeric and boolean validation, fee normalization, and settlement governed-field requirements are expanded.
Mature trade and context comparison
rust_hft/tools/collector/src/polymarket_parity.rs
Trade comparisons use event-time maturity separately from recording cutoffs, join trades to market metadata, collect mismatch IDs, and test event-window and context behavior.
Settlement parity and evidence output
rust_hft/tools/collector/src/polymarket_parity.rs
Settlement context checks use mismatch IDs, and evidence includes mismatch arrays, timing values, and only-ID fields.
Gate policy enforcement
deployment/aliyun/polymarket-shadow-gate-policy.jq, deployment/aliyun/test-polymarket-raw-ops-control-plane.sh
The gate requires exact mature ID parity, valid timing, empty mismatch arrays, and matching trade and settlement contexts; negative tests cover rejected metrics.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ParityCompare
  participant TradeMap
  participant MarketMetadata
  participant GatePolicy
  ParityCompare->>TradeMap: apply event maturity and recording cutoff
  TradeMap->>MarketMetadata: resolve metadata for referenced markets
  MarketMetadata-->>ParityCompare: return governed context
  ParityCompare->>GatePolicy: publish parity metrics and mismatch IDs
  GatePolicy-->>ParityCompare: accept or reject evidence
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main collector change: aligning live shadow parity windows.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/polymarket-parity-live-fix

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.

@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: 99a555357a

ℹ️ 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 thread rust_hft/tools/collector/src/polymarket_parity.rs

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@deployment/aliyun/polymarket-shadow-gate-policy.jq`:
- Around line 84-88: Update the maturity assertions in the gate policy to
require that trade_event_window_started_at_unix is less than or equal to
trade_event_window_ended_at_unix, preventing empty mature windows when the
parity window is no longer than the 600-second lag. Add a rejection test
covering a derived end before the start.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2f19f4a6-9065-44a7-ac82-9d52fe5463d5

📥 Commits

Reviewing files that changed from the base of the PR and between f6ded79 and 99a5553.

📒 Files selected for processing (4)
  • deployment/aliyun/README.md
  • deployment/aliyun/polymarket-shadow-gate-policy.jq
  • deployment/aliyun/test-polymarket-raw-ops-control-plane.sh
  • rust_hft/tools/collector/src/polymarket_parity.rs

Comment thread deployment/aliyun/polymarket-shadow-gate-policy.jq
@proerror77
proerror77 merged commit a1bb19f into main Jul 16, 2026
21 checks passed
@proerror77
proerror77 deleted the codex/polymarket-parity-live-fix branch July 16, 2026 01:52
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