Skip to content

fix(research): bind sealed snapshot identity to Mission v3 - #381

Merged
proerror77 merged 2 commits into
mainfrom
codex/authenticated-v3-identity-handoff-379
Jul 26, 2026
Merged

proerror77 merged 2 commits into
mainfrom
codex/authenticated-v3-identity-handoff-379

Conversation

@proerror77

@proerror77 proerror77 commented Jul 26, 2026

Copy link
Copy Markdown
Owner

Change contract

Bind Mission v3 admission and checkpoint identity to the opaque, independently verified sealed ResearchSnapshot identity: cohort, partition, causal policy, snapshot contract/hash, and baseline source authority.

Acceptance evidence

  • cargo test -p ploy-research --lib (328 passed)
  • Focused sealed-handoff forged-partition and authority-drift counterexamples
  • Mission v3 checkpoint-version rejection tests
  • cargo fmt --package ploy-research -- --check and git diff --check

Out of scope

MCTS mechanics, evaluator metrics, collector/runtime deployment, dispatch, Paper, Shadow, Live, and result publication.

Dependency / merge order

Follow-up to merged #320 and #378. Merge before #324; #324 consumes this sealed handoff.

Rollout / rollback impact

Research-only admission boundary. It fails closed on old checkpoint schema or any identity/source drift; reverting restores the prior absence of the handoff.

Closes #379.

Summary by CodeRabbit

  • New Features
    • Added support for Prediction Research Mission v4 and pipeline smoke execution.
    • Added cohort manifest identity input to prediction execution.
    • Added stronger snapshot and mission identity verification, including partition, policy, contract, and snapshot details.
  • Bug Fixes
    • Prevented forged or mismatched snapshot and partition inputs from reaching evaluation.
    • Rejected incomplete admission identities and unsupported legacy mission mappings.
  • Documentation
    • Updated prediction-market admission guidance for Mission v4.
  • Chores
    • Refreshed example research configuration snapshot identifiers.

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

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

Next review available in: 29 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: de3d37df-22ba-4a73-8a74-141b3d49dd5e

📥 Commits

Reviewing files that changed from the base of the PR and between 7fc77a2 and 7c85cac.

📒 Files selected for processing (10)
  • docs/architecture/PREDICTION_MARKETS.md
  • rust_hft/alpha-harness/app/src/cli.rs
  • rust_hft/alpha-harness/app/src/prediction_dispatch.rs
  • rust_hft/alpha-harness/app/src/prediction_runner.rs
  • 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/bin/monday-prediction-research.rs
  • rust_hft/prediction-markets/crates/ploy-research/src/bin/monday-prediction-snapshot.rs
  • rust_hft/prediction-markets/crates/ploy-research/src/prediction_mission_v3.rs
  • rust_hft/prediction-markets/crates/ploy-research/src/research_snapshot.rs
📝 Walkthrough

Walkthrough

Mission v4 admission now binds pipeline-smoke execution to authenticated cohort, partition, policy, contract, source, and snapshot identities. CLI, dispatch, runner validation, snapshot admission, tests, fixtures, configuration, and architecture documentation were updated accordingly.

Changes

Mission v4 authenticated admission

Layer / File(s) Summary
Sealed snapshot and Mission v4 identity contract
rust_hft/prediction-markets/crates/ploy-research/src/research_snapshot.rs, rust_hft/prediction-markets/crates/ploy-research/src/prediction_mission_v3.rs
Authenticated snapshot and mission structures now carry and validate cohort, partition, policy, contract, and snapshot identities.
Snapshot admission identity binding
rust_hft/prediction-markets/crates/ploy-research/src/bin/monday-prediction-snapshot.rs
Mission validation occurs against the admitted snapshot hash, with added mismatch coverage.
Pipeline-smoke admitted identity enforcement
rust_hft/prediction-markets/crates/ploy-research/src/bin/monday-prediction-research.rs
Pipeline-smoke parsing and execution require complete admitted Mission v4 identity and validate source, policy, contract, and snapshot bindings.
Alpha-harness Mission v4 wiring
rust_hft/alpha-harness/app/src/*, rust_hft/prediction-markets/config/research_missions/*, docs/architecture/PREDICTION_MARKETS.md
CLI, dispatch, Kubernetes job arguments, runner validation, fixtures, mission policy snapshots, and LoopRun documentation use the Mission v4 cohort identity flow.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related issues

  • proerror77/monday issue 373 — Extends typed Mission admission and cohort/partition binding from Mission v3 to v4 across admission, dispatch, and execution.

Possibly related PRs

  • proerror77/monday#228 — Introduces the baseline snapshot source-kind semantics enforced by this Mission v4 pipeline-smoke flow.
  • proerror77/monday#363 — Provides authenticated snapshot materialization and sealed cache APIs consumed by the expanded identity handoff.
  • proerror77/monday#374 — Overlaps directly in snapshot admission dispatch and typed cohort/partition identity validation.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Several changes go beyond #379's research-adapter handoff scope, including dispatch/CLI wiring, runner changes, docs, and config updates. Split the dispatch/CLI/docs/config wiring into a separate PR or justify it in a broader issue, and keep #379 limited to the sealed research-adapter handoff.
Docstring Coverage ⚠️ Warning Docstring coverage is 44.83% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: binding sealed snapshot identity to Mission v3.
Description check ✅ Passed The description covers the contract, evidence, out-of-scope scope, merge order, and rollback; only the template's Scope exception section is missing.
Linked Issues check ✅ Passed The PR satisfies #379 by exposing sealed snapshot identity, rejecting drift, and adding forged-partition and authority/source-profile counterexamples.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/authenticated-v3-identity-handoff-379

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.

@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: bd2f69e7a7

ℹ️ 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".

@proerror77
proerror77 force-pushed the codex/authenticated-v3-identity-handoff-379 branch from bd2f69e to 8fd2d50 Compare July 26, 2026 12:16
@proerror77
proerror77 force-pushed the codex/authenticated-v3-identity-handoff-379 branch 2 times, most recently from 7fc77a2 to e70bd0b Compare July 26, 2026 12:48

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
rust_hft/prediction-markets/crates/ploy-research/src/bin/monday-prediction-snapshot.rs (1)

223-233: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Compare snapshot_contract_id against the admitted snapshot.

The protocol emits snapshot.snapshot_contract_id() and admits if mission.snapshot_hash matches the admitted hash, but still accepts the mission when mission.snapshot_contract_id matches request.snapshot_contract_id instead. A caller-supplied contract id can drift from the admitted snapshot; pass the admitted contract id to validate_mission_admission_identity and compare it against the mission.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@rust_hft/prediction-markets/crates/ploy-research/src/bin/monday-prediction-snapshot.rs`
around lines 223 - 233, The mission admission check currently trusts the
caller-supplied request contract ID instead of the admitted snapshot’s contract
ID. Update the call to validate_mission_admission_identity to pass
snapshot.snapshot_contract_id(), then ensure the snapshot_contract_id comparison
inside the validation condition uses that admitted value against
mission.snapshot_contract_id.
🧹 Nitpick comments (2)
rust_hft/prediction-markets/crates/ploy-research/src/research_snapshot.rs (1)

5144-5146: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use the exported schema constant instead of the literal.

PREDICTION_MISSION_V3_SCHEMA_VERSION is public; hard-coding "prediction_research_mission.v4" here means a future bump silently fails this test on the version check rather than on the identity assertions it is meant to exercise.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@rust_hft/prediction-markets/crates/ploy-research/src/research_snapshot.rs`
around lines 5144 - 5146, Update the PredictionResearchMissionV3 construction to
use the exported PREDICTION_MISSION_V3_SCHEMA_VERSION constant for
schema_version instead of the hard-coded string, preserving the test’s intended
version behavior.
rust_hft/prediction-markets/crates/ploy-research/src/prediction_mission_v3.rs (1)

316-328: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Reuse a shared lowercase-hex predicate.

This byte check duplicates validate_sha256_id's hex validation. Extracting one is_lowercase_hex(&str, len) helper keeps both digest formats from drifting.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@rust_hft/prediction-markets/crates/ploy-research/src/prediction_mission_v3.rs`
around lines 316 - 328, Extract the shared lowercase-hex validation from
validate_sha256_id into an is_lowercase_hex(&str, len) helper, then update both
validate_sha256_id and validate_snapshot_hash to reuse it with their required
lengths. Preserve each validator’s existing error messages and validation
behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@rust_hft/alpha-harness/app/src/prediction_runner.rs`:
- Around line 943-970: Strengthen
execute_rejects_forged_pipeline_partition_before_starting_the_runner by
asserting the returned error contains the expected forged partition
identity-rejection text, rather than only checking is_err(). Match the sibling
tests’ verification that the runner executable was never started, using the
existing must-not-run path, so the test specifically validates the admission
gate.

---

Outside diff comments:
In
`@rust_hft/prediction-markets/crates/ploy-research/src/bin/monday-prediction-snapshot.rs`:
- Around line 223-233: The mission admission check currently trusts the
caller-supplied request contract ID instead of the admitted snapshot’s contract
ID. Update the call to validate_mission_admission_identity to pass
snapshot.snapshot_contract_id(), then ensure the snapshot_contract_id comparison
inside the validation condition uses that admitted value against
mission.snapshot_contract_id.

---

Nitpick comments:
In
`@rust_hft/prediction-markets/crates/ploy-research/src/prediction_mission_v3.rs`:
- Around line 316-328: Extract the shared lowercase-hex validation from
validate_sha256_id into an is_lowercase_hex(&str, len) helper, then update both
validate_sha256_id and validate_snapshot_hash to reuse it with their required
lengths. Preserve each validator’s existing error messages and validation
behavior.

In `@rust_hft/prediction-markets/crates/ploy-research/src/research_snapshot.rs`:
- Around line 5144-5146: Update the PredictionResearchMissionV3 construction to
use the exported PREDICTION_MISSION_V3_SCHEMA_VERSION constant for
schema_version instead of the hard-coded string, preserving the test’s intended
version behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: fcca190c-c15e-469a-8d07-60f3d798d75a

📥 Commits

Reviewing files that changed from the base of the PR and between 7f40520 and 7fc77a2.

📒 Files selected for processing (10)
  • docs/architecture/PREDICTION_MARKETS.md
  • rust_hft/alpha-harness/app/src/cli.rs
  • rust_hft/alpha-harness/app/src/prediction_dispatch.rs
  • rust_hft/alpha-harness/app/src/prediction_runner.rs
  • 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/bin/monday-prediction-research.rs
  • rust_hft/prediction-markets/crates/ploy-research/src/bin/monday-prediction-snapshot.rs
  • rust_hft/prediction-markets/crates/ploy-research/src/prediction_mission_v3.rs
  • rust_hft/prediction-markets/crates/ploy-research/src/research_snapshot.rs

Comment thread rust_hft/alpha-harness/app/src/prediction_runner.rs
@proerror77
proerror77 force-pushed the codex/authenticated-v3-identity-handoff-379 branch from e70bd0b to 436de41 Compare July 26, 2026 13:02
@proerror77
proerror77 force-pushed the codex/authenticated-v3-identity-handoff-379 branch from 436de41 to 7c85cac Compare July 26, 2026 13:16
@proerror77
proerror77 merged commit 5a4f1c5 into main Jul 26, 2026
38 checks passed
@proerror77
proerror77 deleted the codex/authenticated-v3-identity-handoff-379 branch July 26, 2026 13:27
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.

Expose authenticated snapshot identity to Mission v3 research adapters

1 participant