Skip to content

fix(collector): exclude noncausal Polymarket research trades - #113

Merged
proerror77 merged 1 commit into
mainfrom
codex/polymarket-drop-noncausal-trades
Jul 17, 2026
Merged

proerror77 merged 1 commit into
mainfrom
codex/polymarket-drop-noncausal-trades

Conversation

@proerror77

@proerror77 proerror77 commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Change contract: Normalized Polymarket research evidence omits a canonical trade whenever either received_at or the envelope recorded_at precedes trade_ts, while malformed clocks and zero-causal-trade event coverage still fail closed.

Out of scope: Fixing the raw collector stamping source, relaxing the semantic verifier, changing ECS/reference-recovery, deployment, or republishing immutable evidence.

Dependency or merge order: Depends only on main. Merge before republishing the real Linux evidence artifact; the raw collector clock-source fix remains a separate focused PR.

Focused validation: TDD counterexamples cover each noncausal clock independently, malformed recorded_at despite a noncausal received_at, and an event whose only trade is noncausal. cargo test -p hft-collector --lib: 153 passed, 2 ignored. cargo clippy -p hft-collector --lib -- -D warnings, cargo fmt --check -p hft-collector, and git diff --check pass. Real Linux raw replay changed 24,121 rows to 23,233 by omitting exactly 888 noncausal trades while retaining 4 events and 2,180 books; new deterministic content SHA-256 is c1f46cc6bc464d771a20dcda0dae6be3b363480b61bc62ca48cc6e3937d72382.

Rollout/rollback impact: New evidence publications become stricter; existing immutable artifacts are unchanged. Roll back by reverting this PR and do not publish the resulting weaker artifact. The downstream verifier remains unchanged and fail closed.

Summary by CodeRabbit

  • Bug Fixes
    • Prevented trade evidence from being published when timestamps indicate it was received or recorded before the trade occurred.
    • Improved availability timing to reflect the latest relevant timestamp.
    • Added validation so malformed recording timestamps are rejected consistently.
    • Updated completeness handling when noncausal trade data is encountered.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 69e9aa61-fb84-4ac7-96ab-2ba86d2ddd95

📥 Commits

Reviewing files that changed from the base of the PR and between a9e02b6 and 70eea69.

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

📝 Walkthrough

Walkthrough

Polymarket trade normalization now parses source, received, and recorded timestamps, excludes noncausal trades, and computes evidence availability from received and recorded times. Tests add pending-trade construction and validate filtering, completeness, and malformed timestamp behavior.

Changes

Polymarket timestamp causality

Layer / File(s) Summary
Timestamp gating and evidence emission
rust_hft/tools/collector/src/polymarket_research_normalize.rs
trade_rows parses relevant timestamps, skips trades where received or recorded time predates the source trade, and emits available_at from the latest valid timestamp.
Timestamp behavior validation
rust_hft/tools/collector/src/polymarket_research_normalize.rs
Tests add a Pending trade helper and cover noncausal filtering, surface incompleteness, and malformed recorded_at errors.

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

Sequence Diagram(s)

sequenceDiagram
  participant PendingTrade
  participant trade_rows
  participant TimestampClocks
  participant EvidenceRow
  PendingTrade->>trade_rows: provide trade_ts, received_at, recorded_at
  trade_rows->>TimestampClocks: parse timestamp values
  TimestampClocks-->>trade_rows: return clocks
  trade_rows->>EvidenceRow: emit causal trade with latest availability timestamp
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: excluding noncausal Polymarket research trades.
Description check ✅ Passed The description covers the required template topics with clear contract, out-of-scope, dependencies, validation, and rollback 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/polymarket-drop-noncausal-trades

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 merged commit 24137c9 into main Jul 17, 2026
17 checks passed
@proerror77
proerror77 deleted the codex/polymarket-drop-noncausal-trades branch July 17, 2026 21:10
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