Skip to content

feat(research): share immutable event cohort partition - #331

Closed
proerror77 wants to merge 1 commit into
mainfrom
codex/event-cohort-partition-322
Closed

feat(research): share immutable event cohort partition#331
proerror77 wants to merge 1 commit into
mainfrom
codex/event-cohort-partition-322

Conversation

@proerror77

@proerror77 proerror77 commented Jul 24, 2026

Copy link
Copy Markdown
Owner

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

  • cargo test -p ploy-research: 300 library tests, 2 research binary tests, and doc tests passed.
  • cargo test -p ploy-research --features db --bin monday-prediction-evaluator: 12 tests passed.
  • cargo check -p ploy-research --features db --bin monday-prediction-evaluator passed.
  • cargo clippy -p ploy-research --all-targets --no-deps -- -D warnings passed.
  • cargo fmt -p ploy-research -- --check and git diff --check passed.
  • Fresh post-rebase Standards and Spec cleanroom reviews reported zero actionable findings at 3227f45 before the later trust-order architecture audit identified the Publish an independently verified immutable ready-event catalog #319 dependency blocker.
  • Exact-head CI completed with 27 passing, 10 skipped, and no failing checks, including heavy research, integration regressions, research binary build, and image smoke.
  • DB-enabled clippy is blocked only by pre-existing type_complexity warnings in deribit.rs:294 and factors.rs:933, outside this change.

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

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@proerror77, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 33 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: 285d64c4-21c0-4031-81b6-29625feefecc

📥 Commits

Reviewing files that changed from the base of the PR and between 2b7a69e and 3227f45.

📒 Files selected for processing (9)
  • docs/architecture/PREDICTION_MARKETS.md
  • rust_hft/prediction-markets/config/research_missions/polymarket-btc-5m.example.json
  • rust_hft/prediction-markets/config/research_missions/polymarket-sol-5m.example.json
  • rust_hft/prediction-markets/crates/ploy-research/src/autofactor.rs
  • rust_hft/prediction-markets/crates/ploy-research/src/bin/monday-prediction-evaluator.rs
  • rust_hft/prediction-markets/crates/ploy-research/src/event_cohort_partition.rs
  • rust_hft/prediction-markets/crates/ploy-research/src/factors_v2.rs
  • rust_hft/prediction-markets/crates/ploy-research/src/lib.rs
  • rust_hft/prediction-markets/crates/ploy-research/src/prediction_loop.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/event-cohort-partition-322

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 marked this pull request as draft July 24, 2026 04:01
@proerror77
proerror77 marked this pull request as ready for review July 24, 2026 04:02

@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: 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".

Comment on lines +1607 to +1611
EventCohortPartition::from_verified_snapshot(
&snapshot,
&symbols,
cohort.event_window_secs(),
cohort.boundary().timestamp_millis(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines +62 to +67
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())?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@proerror77
proerror77 marked this pull request as draft July 24, 2026 04:14
@proerror77

Copy link
Copy Markdown
Owner Author

Architecture audit blocker confirmed at exact head 3227f45: EventCohortPartition::from_verified_snapshot includes snapshot_contract_hash in the partition payload/digest, while the required flow is ready catalog -> authenticated cohort/partition manifest -> ResearchSnapshot. Making the snapshot consume this partition would therefore create a snapshot-hash -> partition-digest -> snapshot-hash cycle, and the current observation artifact does not independently prove the selected catalog universe. #331 is Draft and blocked by #319. Do not merge or patch this with a publicly forgeable event list; preserve the branch for rebase after #319.

@proerror77

Copy link
Copy Markdown
Owner Author

Superseded by merged PR #362, which implements and closes #322 from the authenticated #319 catalog. This Draft must not be rebased or merged. Preserving its branch/worktree for audit; no deletion performed.

@proerror77 proerror77 closed this Jul 26, 2026
@proerror77
proerror77 deleted the codex/event-cohort-partition-322 branch August 13, 2026 06:37
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.

Use one immutable common-time event partition across Polymarket research tasks

1 participant