Build verified Polymarket + Chainlink baseline snapshots - #228
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughAdds an opt-in Polymarket + Chainlink baseline snapshot path. It validates exclusive CLI modes, omits Binance-derived surfaces, derives aligned Polymarket ticks, records baseline manifest metadata, handles nullable factors as NaN, and updates wrapper forwarding and mission snapshot identifiers. ChangesBaseline snapshot pipeline
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant CLI as monday-prediction-snapshot
participant Evidence as VerifiedPolymarketEvidenceSet
participant Builder as baseline snapshot builder
participant Snapshot as ResearchSnapshot
CLI->>Evidence: verify anchored Polymarket artifacts
CLI->>Builder: request baseline snapshot
Builder->>Evidence: read books, settlements, and Chainlink evidence
Builder->>Snapshot: bind observations and write baseline manifest
Snapshot-->>CLI: return sealed ResearchSnapshot
Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Checkov (3.3.8)rust_hft/prediction-markets/config/research_missions/polymarket-btc-5m.example.jsonTraceback (most recent call last): rust_hft/prediction-markets/config/research_missions/polymarket-sol-5m.example.jsonTraceback (most recent call last): 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: 39f1c84712
ℹ️ 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 observations = | ||
| crate::factors::build_unlabeled_factor_observations_with_lob_sampled_and_source_clocks( | ||
| &polymarket_updates, | ||
| &[], | ||
| &[], | ||
| options.max_quote_age_secs, | ||
| options.observation_sample_secs, | ||
| ); |
There was a problem hiding this comment.
Use the accepted pre-open Chainlink reference
With the default max_quote_age_secs=30 and a valid artifact containing the verifier's required pre-open reference per event, project_verified_polymarket_evidence forwards only references whose source time is before the event start, while the factor builder does not set chainlink_price_to_beat until it sees a post-start reference. Consequently the book-driven observations created here all have chainlink_reference_fresh == false, and baseline binding rejects every row, so this mode cannot build a snapshot from the evidence contract it claims to support. Bind the verified pre-open reference directly or introduce a causal boundary transition that does not require an unavailable post-start reference.
Useful? React with 👍 / 👎.
| ensure!( | ||
| polymarket.event_start_gte() <= options.start && polymarket.event_start_lt() >= options.end, | ||
| "verified Polymarket evidence does not cover the baseline snapshot window" |
There was a problem hiding this comment.
Reject gaps inside the requested evidence window
When repeated anchored artifacts omit an intermediate range, this aggregate min/max check still passes because VerifiedPolymarketEvidenceSet explicitly permits gaps between members (polymarket_evidence/set.rs:390-404). For example, members covering 05:30 and 05:40 can satisfy a 05:30–05:45 request while the 05:35 cohort is absent; the remaining per-contract checks can pass and the sealed manifest still claims the entire requested interval. Validate that member ranges or selected five-minute contract slots are contiguous across [start, end) before constructing the snapshot.
Useful? React with 👍 / 👎.
| } else { | ||
| anyhow::bail!("baseline token book identity does not match its event contract"); | ||
| } | ||
| if has_up && has_down && emitted.insert(book.ts) { |
There was a problem hiding this comment.
Require contemporaneous books before emitting baseline ticks
When the Up and Down streams are separated by more than max_quote_age_secs, these persistent booleans still emit a tick as soon as each side has appeared at least once and continue emitting after either stream stops. The factor builder permits a row when only one ask remains fresh, so such ticks produce one-sided observations with fair_prob_up and related Polymarket probability fields set to NaN while the baseline manifest still reports the CLOB surface as sampled and healthy. Track the latest timestamp for each side and emit only when both token books are fresh at the candidate tick.
Useful? React with 👍 / 👎.
Closes #226
Parent: #225
Follow-up consumer admission: #227
Change contract
Add one explicit verified Polymarket + Chainlink baseline profile that builds and seals the existing ResearchSnapshot from anchored Polymarket evidence while recording every Binance surface as intentionally omitted and leaving all current evaluator, trainer, and full-surface behavior fail-closed and unchanged.
Out of scope
Evaluator or MCTS admission; consumer component eligibility; collector code or deployment; fabricated or historical Binance backfill; Paper or Live; OMS or RiskGate; 15-minute or 1-hour products; profitability claims; #189 retirement.
Dependency or merge order
Depends only on verified immutable Polymarket evidence and ResearchSnapshot seams already on main. Merge this PR before starting #227. #227 is the separate consumer rollout unit and must not be merged first.
Focused validation
cargo test -p ploy-research— 282 passedcargo test -p ploy-research --features db --bin monday-prediction-snapshot— 7 passedcargo test -p alpha-harness prediction_snapshot::tests— 7 passedcargo clippy --locked -p ploy-research --features ml --all-targets --no-deps -- -D warningscargo clippy --locked -p alpha-harness -- -D warningscargo fmt --check --package ploy-researchcargo fmt --check --package alpha-harnessTargeted counterexamples prove that baseline mode rejects Binance segment arguments, requires both Up and Down token books, rejects stale Chainlink availability, clears all unavailable CEX and continuous-path numeric features to NaN, and round-trips the sealed baseline manifest plus both snapshot digests.
Rollout or rollback impact
Rollout is opt-in through
--polymarket-chainlink-baseline; no existing command selects it implicitly. Current evaluator, MCTS, report, and trainer paths continue rejecting the reduced-authority profile. Rollback removes the profile and builder; immutable baseline snapshots remain provenance-readable but are not reclassified or admitted to research consumers.Summary by CodeRabbit
New Features
Bug Fixes