Bind Polymarket evidence to trade completion proofs - #152
Conversation
|
Warning Review limit reached
Next review available in: 32 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughPolymarket collection now emits event-local trade completion proofs. Upload, import, normalization, and evidence sealing validate completion metadata against canonical trade record IDs, counts, digests, market identity, and timing. Mission snapshot references and task tracking are also updated. ChangesTrade completion proof pipeline
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant ReferenceCollector
participant PolymarketTape
participant TapeScanner
participant ResearchNormalizer
participant EvidenceSealer
ReferenceCollector->>PolymarketTape: emit trade completion proof
PolymarketTape->>TapeScanner: scan completion update
TapeScanner->>ResearchNormalizer: provide trade_completions manifest
ResearchNormalizer->>ResearchNormalizer: compare trade IDs, count, and digest
ResearchNormalizer->>EvidenceSealer: pass validated inputs and rows
EvidenceSealer->>EvidenceSealer: enforce completion linkage during sealing
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0ba046b024
ℹ️ 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".
| let (trade_count, trade_record_ids_sha256) = | ||
| if let Some(record_ids) = state.trade_seen.get(condition_id) { | ||
| ( | ||
| record_ids.len(), | ||
| trade_record_ids_sha256(record_ids.keys().map(String::as_str)), | ||
| ) |
There was a problem hiding this comment.
Scope completion proofs to the segment carrying the trades
When trades for a market are written before an hourly rotation or collector restart but the completion marker is written afterward, this hashes the cumulative state.trade_seen set, including IDs from the earlier tape. validate_event_local_trade_completions later hashes only the trade rows in the single proof-bearing reference segment, so valid boundary cohorts (for example, a 5-minute market ending at the hour) and interrupted collections are rejected as proof mismatches. The proof must reference a segment containing all hashed trades, or normalization must resolve the proof across the relevant segments.
Useful? React with 👍 / 👎.
| || !SYMBOLS.contains(&completion.symbol.as_str()) | ||
| || completion.market_window_secs != 300 |
There was a problem hiding this comment.
Filter completion identities to selected evidence markets
When the reference hour also contains a completion for an unselected symbol or a 15-minute market, this rejects the entire sealed BTC/SOL five-minute artifact even though normalization intentionally emitted no rows for that market. The reference collector accepts all configured symbols and both 300/900-second markets, while normalize_raw preserves the reference segment's complete trade_completions map in validated_inputs; therefore ordinary mixed collector segments fail here on an ETH/XRP completion or any 900-second completion. Filter the map to selected contracts before publishing, or validate scope-specific fields only for completions referenced by normalized market_contract rows.
Useful? React with 👍 / 👎.
| let (market_id, context, completion) = | ||
| validate_trade_completion(update, sequence, recorded_at, line_number)?; | ||
| if trade_completions.insert(market_id, completion).is_some() { |
There was a problem hiding this comment.
Verify each completion digest while scanning the raw tape
When an active or staged tape contains a well-formed completion marker whose count or digest contradicts its trade rows, validate_trade_completion checks only the marker's shape and this code copies the claim into the manifest without recomputing it. Consequently scan_tape and validate_reference_tape_for_recovery accept the false proof; recovery then marks the market trade_complete and stops polling, and the standalone research-segment validation can certify the artifact until a later selected-event normalization happens to catch it. Accumulate canonical trade IDs per market and compare their count, digest, and ordering to the marker before inserting the completion.
Useful? React with 👍 / 👎.
…lymarket-trade-tape-replay # Conflicts: # rust_hft/tools/collector/src/polymarket_upload.rs
Change contract:
Out of scope:
Dependency or merge order:
Focused validation:
cargo test --manifest-path rust_hft/Cargo.toml -p hft-collector --lib-> 174 passed, 2 ignored.cargo test --manifest-path rust_hft/prediction-markets/Cargo.toml -p ploy-market-data-> 39 passed.cargo test --manifest-path rust_hft/prediction-markets/Cargo.toml -p ploy-research-> 248 library tests and 2 binary tests passed.cargo clippy --manifest-path rust_hft/Cargo.toml -p hft-collector --all-targets -- -D warnings-> passed.cargo clippy --manifest-path rust_hft/prediction-markets/Cargo.toml -p ploy-market-data --all-targets --no-deps -- -D warnings-> passed.git diff --check-> passed.9270aef8and head78f62f45-> no findings.Rollout/rollback impact:
monday.polymarket.evidence_artifact.v2; strengthened v1/v2 validated-input shapes both require marker-count and completion-map consistency. Live execution remains disabled and untouched.