feat(research): share immutable event cohort partition - #331
Conversation
|
Warning Review limit reached
Next review available in: 33 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 Plus Run ID: 📒 Files selected for processing (9)
✨ 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: 3227f455f3
ℹ️ 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".
| EventCohortPartition::from_verified_snapshot( | ||
| &snapshot, | ||
| &symbols, | ||
| cohort.event_window_secs(), | ||
| cohort.boundary().timestamp_millis(), |
There was a problem hiding this comment.
Split cohort construction from evaluator execution
This hunk constructs the authenticated cohort partition inside the evaluator, while the same change also modifies MCTS training, settlement evaluation, and reprice execution to consume it. The repository explicitly requires Polymarket cohort/snapshot construction and evaluator/MCTS execution to remain separate issues, so these independently testable and rollbackable behaviors need to be split rather than shipped as one unit.
AGENTS.md reference: AGENTS.md:L39-L42
Useful? React with 👍 / 👎.
| let authenticated_snapshot_digest = snapshot | ||
| .manifest | ||
| .snapshot_contract_hash | ||
| .as_deref() | ||
| .or(snapshot.manifest.snapshot_hash.as_deref()) | ||
| .ok_or_else(|| "verified snapshot is missing its authenticated digest".to_string())?; |
There was a problem hiding this comment.
Handle the legacy snapshot hash format
When a valid legacy snapshot has no snapshot_contract_hash, this fallback selects snapshot_hash, but compute_snapshot_hash in research_snapshot.rs produces a 16-character hexadecimal value without a sha256: prefix. validate_sha256_id therefore rejects every such snapshot, even though load_research_snapshot explicitly supports and verifies manifests without a contract hash, causing any time-cohort evaluation using one of those snapshots to panic during partition construction. Either support the legacy identity format here or require the contract hash without offering an unusable fallback.
Useful? React with 👍 / 👎.
| label_observation_times | ||
| .get(row.event_id.as_str()) | ||
| .and_then(Option::as_ref) | ||
| .is_some_and(|observed_at| *observed_at <= cohort.boundary) |
There was a problem hiding this comment.
Reject labels observed before event completion
When an input carries an erroneous or legacy official_resolution_observed_at earlier than its canonical event end, this replacement training path now admits it as long as it precedes the cohort boundary. The previous event_disjoint_walk_forward_slices path independently required label_observed_at >= event_end, and the DB-backed snapshot binding does not enforce that invariant upstream, so such a row can leak a causally impossible settlement label into MCTS training and corrupt its reward evidence. Retain the lower-bound check in addition to the new boundary cutoff.
Useful? React with 👍 / 👎.
|
Architecture audit blocker confirmed at exact head 3227f45: |
Change contract
One authenticated event cohort deterministically yields one immutable common-time partition consumed by settlement, Up execution, and Down execution.
Current blocker
Blocked by #319. The current constructor seals the ResearchSnapshot contract hash into the partition digest, but the required trust order is ready catalog -> authenticated cohort/partition manifest -> ResearchSnapshot. Feeding this partition back into snapshot identity would create a hash cycle, and snapshot observations alone do not prove the selected catalog universe. Do not merge this head; after #319 lands, rebase and construct the partition from its authenticated catalog/cohort manifest. Do not replace that seam with a publicly forgeable event list.
Out of scope
Mission schema beyond partition reference; evaluator metrics; MCTS search policy; snapshot construction; collector, runtime, and deployment changes.
Dependency or merge order
Depends on #321, merged as #328, and is now blocked by #319. Rebase onto #319 before further implementation or review. No stacked PR is currently declared.
Focused validation
Review boundary clarification
The #322 Up/Down consumers are the typed side-bound reprice adapters. They receive one shared partition, split once, and serialize the same episode_cohorts partition digest. Redesigning the legacy generic diagnostic report suite is explicitly out of scope.
Rollout and rollback impact
Research-only and fail-closed; no live trading or deployment authority. This PR must remain Draft and unmerged until #319 provides the authenticated cohort universe and the branch is rebased onto it.
Closes #322