Skip to content

fix(polymarket): merge repeated sealed reference evidence - #273

Merged
proerror77 merged 2 commits into
mainfrom
codex/polymarket-reference-merge-272
Jul 23, 2026
Merged

fix(polymarket): merge repeated sealed reference evidence#273
proerror77 merged 2 commits into
mainfrom
codex/polymarket-reference-merge-272

Conversation

@proerror77

@proerror77 proerror77 commented Jul 23, 2026

Copy link
Copy Markdown
Owner

Change contract

Merge identical canonical v2 trades and identical official settlements across already validated consecutive Polymarket reference segments exactly once, preserving the first segment clocks, while retaining later-only trades and failing closed on semantic conflicts.

Out of scope

Collector deployment or polling policy; raw-row fabrication or renumbering; completion-proof relaxation; ResearchSnapshot/evaluator logic; Binance; Paper, Shadow, or Live. A PRD is unnecessary because this is the focused behavior change already specified in #272.

Dependency or merge order

Independent code PR. After merge and exact-main compiler image publication, #270 consumes the live hour 09-11 reference segments plus bounded hour 12 full/completion segments. #232 remains downstream of #270.

Focused validation

  • cargo test -p hft-collector --lib polymarket_research_import::tests:: -- --nocapture (21 passed)
  • cargo test -p hft-collector --lib (205 passed, 2 ignored)
  • cargo clippy -p hft-collector --lib --no-default-features -- -D warnings
  • deployment/aliyun/test-polymarket-raw-ops-control-plane.sh
  • Counterexamples cover conflicting duplicate trade context and conflicting settlement winner/vector semantics.

Rollout and rollback impact

Research compiler behavior only. Rollback restores strict cross-segment duplicate rejection and blocks the affected cohort; it does not modify collector services or existing immutable artifacts.

Fixes #272

Summary by CodeRabbit

  • Bug Fixes
    • Improved consolidation of trade and settlement records across reference segments.
    • Removed exact duplicate entries while preserving the earliest occurrence.
    • Added validation to reject conflicting records that share identifiers but contain inconsistent details.
    • Improved handling of merged trade histories and settlement winner consistency.

@coderabbitai

coderabbitai Bot commented Jul 23, 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: 39 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 Plus

Run ID: 58853433-5f7f-46f9-b9f3-bbc76359aee3

📥 Commits

Reviewing files that changed from the base of the PR and between 5a42954 and d3716f9.

📒 Files selected for processing (1)
  • rust_hft/tools/collector/src/polymarket_research_import.rs
📝 Walkthrough

Walkthrough

Polymarket reference consolidation now derives canonical identities for trades and settlements, merges identical records while preserving the earliest row, and rejects conflicting duplicate semantics. Tests cover later-only trades, completion proofs, conflicting trade context, and settlement winner mismatches.

Changes

Polymarket reference merge

Layer / File(s) Summary
Identity-aware merge implementation
rust_hft/tools/collector/src/polymarket_research_import.rs
Canonical trade and settlement identities are derived during combine_references; exact duplicates retain the first row, while conflicting identities are rejected.
Merge behavior validation
rust_hft/tools/collector/src/polymarket_research_import.rs
Tests cover duplicate and later-only trades, completion proofs, conflicting market context, and settlement winner consistency.

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

Sequence Diagram(s)

sequenceDiagram
  participant ReferenceSegments
  participant combine_references
  participant IdentityValidation
  ReferenceSegments->>combine_references: provide validated NDJSON rows
  combine_references->>IdentityValidation: derive canonical trade or settlement identity
  IdentityValidation-->>combine_references: return merge key and identity vector
  combine_references-->>ReferenceSegments: preserve first duplicate or reject conflict
Loading

Possibly related PRs

  • proerror77/monday#154: Updates the same Polymarket reference import module and related cross-segment trade deduplication logic.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly reflects the main change: merging repeated Polymarket reference evidence.
Description check ✅ Passed All required sections are present and the PR explains contract, scope, dependencies, validation, and rollback.
Linked Issues check ✅ Passed The change matches #272 by deduping identical trades/settlements, retaining later-only rows, rejecting semantic conflicts, and keeping validation behavior.
Out of Scope Changes check ✅ Passed Changes stay in the targeted compiler module and tests, with no obvious collector, deployment, or unrelated scope added.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/polymarket-reference-merge-272

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: 5a42954374

ℹ️ 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_research_import.rs
Comment thread rust_hft/tools/collector/src/polymarket_research_import.rs
@proerror77
proerror77 merged commit a5c2500 into main Jul 23, 2026
21 of 22 checks passed
@proerror77
proerror77 deleted the codex/polymarket-reference-merge-272 branch July 23, 2026 16:07
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.

Merge sealed Polymarket reference segments without losing point-in-time availability

1 participant