Skip to content

feat(research): add governed Burn binary lane - #41

Merged
proerror77 merged 4 commits into
mainfrom
codex/governed-burn-snapshot-inputs
Jul 15, 2026
Merged

proerror77 merged 4 commits into
mainfrom
codex/governed-burn-snapshot-inputs

Conversation

@proerror77

@proerror77 proerror77 commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Summary

  • add a Rust-only, research-only Burn 0.20.1 binary probability model with deterministic event-disjoint training and OOS metrics
  • materialize selectors, decision-time features, settlement boundaries, and official outcomes from one governed immutable research snapshot
  • persist fail-closed Burnpack plus typed manifest evidence and bind the trainer source into the current prediction policy hash
  • refresh the governed BTC/SOL mission policy snapshots and document the lane

Authority boundary

This change adds no execution, deployment, approval, promotion, collector, CI, installer, or live-trading authority. PLOY live trading remains disabled.

Validation

  • cargo fmt -p ploy-research -- --check
  • cargo metadata --locked --no-deps --format-version 1
  • cargo test --locked -p ploy-research --features ml --lib: 253 passed
  • cargo test --locked -p ploy-research --features rl --lib: 240 passed
  • cargo clippy --locked -p ploy-research --features ml --all-targets --no-deps: passed; no diagnostics in burn_binary.rs
  • git diff --check
  • policy hash readback matches both mission templates: sha256:b3f2fbe5be90a870e2615ad60eeaed265c3b2dfd895352609c566cdff42be255

Strict Clippy with -D warnings remains blocked by pre-existing warnings in untouched current-main PLOY files. Those unrelated baseline warnings are intentionally not changed in this PR.

Review

Standards review passed after binding burn_binary.rs into the policy digest and recording the task. Spec review found no remaining scope or behavior gaps.

Summary by CodeRabbit

  • New Features

    • Added a governed, research-only Rust probability-model training and inference workflow.
    • Added snapshot-bound dataset validation, event-disjoint evaluation, reproducible model bundles, and tamper detection.
    • Added point-in-time source availability and official outcome timing to research observations.
  • Bug Fixes

    • Strengthened research snapshot integrity checks and settlement evidence validation.
  • Documentation

    • Documented the Burn binary research lane, governance rules, validation steps, and handoff requirements.
    • Updated supported development scope and research task tracking.

@coderabbitai

coderabbitai Bot commented Jul 15, 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: 8 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

Run ID: ae248e7c-5cc3-4be5-afa7-07c013e25b68

📥 Commits

Reviewing files that changed from the base of the PR and between b0461d0 and 0bf6038.

📒 Files selected for processing (4)
  • products/ploy/config/research_missions/polymarket-btc-5m.example.json
  • products/ploy/config/research_missions/polymarket-sol-5m.example.json
  • products/ploy/crates/ploy-research/src/factors.rs
  • products/ploy/crates/ploy-research/src/model/supervised/burn_binary.rs
📝 Walkthrough

Walkthrough

Adds source and label availability provenance to governed research snapshots, introduces snapshot integrity verification, and implements a feature-gated Burn binary probability-model training, inference, persistence, and validation lane.

Changes

Governed Burn binary research lane

Layer / File(s) Summary
Snapshot provenance and integrity
products/ploy/crates/ploy-research/src/factors.rs, products/ploy/crates/ploy-research/src/research_snapshot.rs, test fixtures
Factor observations now retain source arrival timestamps, while research snapshots bind official outcome availability and verify content hashes and Parquet artifacts.
Burn model contracts and training
products/ploy/crates/ploy-research/src/model/supervised/burn_binary.rs
Adds governed dataset and split validation, deterministic logistic training, point-in-time feature checks, probability inference, OOS metrics, and tamper-checked model bundles.
Feature-gated crate integration
products/ploy/crates/ploy-research/Cargo.toml, products/ploy/crates/ploy-research/src/model/supervised/*, products/ploy/crates/ploy-research/src/lib.rs, products/ploy/crates/ploy-research/src/prediction_loop.rs, products/ploy/config/research_missions/*
Enables Burn dependencies, exports supervised-model APIs under ml, includes the model source in policy hashing, and updates mission policy snapshot identifiers.
Research lane documentation
products/ploy/docs/BURN_BINARY_RESEARCH.md, products/ploy/README.md, products/ploy/tasks/todo.md
Documents the governed training and inference contracts and records the lane in project scope and task tracking.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ResearchSnapshot
  participant Trainer
  participant BurnBinaryModel
  participant BundleStorage
  ResearchSnapshot->>Trainer: provide governed snapshot and event-disjoint selectors
  Trainer->>BurnBinaryModel: materialize features and train model
  BurnBinaryModel->>BundleStorage: persist manifest and Burnpack
  BundleStorage->>BurnBinaryModel: verify digests and load bundle
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 48.36% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately captures the main change: adding a governed Burn binary research lane.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/governed-burn-snapshot-inputs

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: 189aca69fa

ℹ️ 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 thread products/ploy/crates/ploy-research/src/model/supervised/burn_binary.rs Outdated
Comment thread products/ploy/crates/ploy-research/src/model/supervised/burn_binary.rs Outdated
Comment thread products/ploy/crates/ploy-research/src/model/supervised/burn_binary.rs Outdated

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

🧹 Nitpick comments (2)
products/ploy/crates/ploy-research/src/model/supervised/burn_binary.rs (2)

1068-1070: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

TrainingBackend::seed reintroduces the process-global RNG coupling the comment above says to avoid.

The comment directly above (lines 826-828) explains weights are generated from a local StdRng specifically "so determinism does not depend on a process-global backend RNG or concurrent research jobs." TrainingBackend::seed(&device, config.seed) does exactly that: per Burn's Backend trait docs, seeding is "guaranteed [for] at least the specified device," and determinism from it "should ensure deterministic execution for a single-threaded program" — i.e., it's not scoped safely across concurrent invocations in the same process. Today this has no functional effect (no other randomness is consumed during training), but it's a latent contradiction of the stated design intent, and would silently break reproducibility guarantees if two missions (e.g., BTC and SOL) are ever trained concurrently in one process, or if a future feature (e.g. dropout) is added.

Consider dropping this call (weights are already deterministically seeded locally, and nothing else here consumes backend randomness), or explicitly documenting/enforcing that concurrent calls to train_event_disjoint_binary within one process are unsupported.

🤖 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 `@products/ploy/crates/ploy-research/src/model/supervised/burn_binary.rs`
around lines 1068 - 1070, Remove the TrainingBackend::seed call from
train_event_disjoint_binary so training does not mutate or depend on
process-global backend RNG state. Keep the local deterministic initialization
through BurnBinaryLinear::<TrainingBackend>::from_seed and leave the existing
device setup and training flow unchanged.

250-255: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Avoid pattern-matching on float literals.

matches!(row.settlement_up, 0.0 | 1.0) matches literal floating-point values in a pattern, which trips Rust's illegal_floating_point_literal_pattern lint. It's not a correctness bug here (the value is authoritative governed evidence), but an explicit equality check is the idiomatic, lint-clean way to express this and keeps the crate's stated goal of a clean Clippy/build output.

♻️ Proposed fix
-        if !matches!(row.settlement_up, 0.0 | 1.0) {
+        if row.settlement_up != 0.0 && row.settlement_up != 1.0 {
             return Err(format!(
                 "snapshot event {} lacks an official binary settlement label",
                 row.event_id
             ));
         }
🤖 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 `@products/ploy/crates/ploy-research/src/model/supervised/burn_binary.rs`
around lines 250 - 255, Update the settlement validation in the surrounding
supervised snapshot-processing logic to replace the float-literal matches!
pattern with explicit equality checks for 0.0 and 1.0, while preserving the
existing error return and event_id message for all other values.
🤖 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 `@products/ploy/crates/ploy-research/src/factors.rs`:
- Around line 117-118: Update products/ploy/crates/ploy-research/src/factors.rs
lines 117-118 so FactorSourceAvailability preserves all seven clock fields in
the serialized observation contract. Update
products/ploy/crates/ploy-research/src/research_snapshot.rs lines 2153-2158 so
observations_to_frame exports every clock, and add coverage verifying JSON and
Parquet outputs retain identical source-availability provenance.

In `@products/ploy/crates/ploy-research/src/research_snapshot.rs`:
- Around line 44-77: Update the current_resolution query to rank resolved
settlement rows per (market_slug, token_id) by the effective availability
timestamp, retaining only the latest row before the market-level aggregation and
binary-row HAVING checks. Preserve append-only settlement storage, and add a
regression test using duplicate settlement history to verify the current outcome
remains available.

---

Nitpick comments:
In `@products/ploy/crates/ploy-research/src/model/supervised/burn_binary.rs`:
- Around line 1068-1070: Remove the TrainingBackend::seed call from
train_event_disjoint_binary so training does not mutate or depend on
process-global backend RNG state. Keep the local deterministic initialization
through BurnBinaryLinear::<TrainingBackend>::from_seed and leave the existing
device setup and training flow unchanged.
- Around line 250-255: Update the settlement validation in the surrounding
supervised snapshot-processing logic to replace the float-literal matches!
pattern with explicit equality checks for 0.0 and 1.0, while preserving the
existing error return and event_id message for all other values.
🪄 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

Run ID: b914c68b-3b17-49a1-a229-d77e4a9a73fd

📥 Commits

Reviewing files that changed from the base of the PR and between 899b21e and b0461d0.

⛔ Files ignored due to path filters (1)
  • products/ploy/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (20)
  • products/ploy/README.md
  • products/ploy/config/research_missions/polymarket-btc-5m.example.json
  • products/ploy/config/research_missions/polymarket-sol-5m.example.json
  • products/ploy/crates/ploy-research/Cargo.toml
  • products/ploy/crates/ploy-research/examples/event_dataset_rolling_windows.rs
  • products/ploy/crates/ploy-research/src/backtest/engine.rs
  • products/ploy/crates/ploy-research/src/dataset/builder.rs
  • products/ploy/crates/ploy-research/src/dataset/export.rs
  • products/ploy/crates/ploy-research/src/factors.rs
  • products/ploy/crates/ploy-research/src/factors_new/scan.rs
  • products/ploy/crates/ploy-research/src/factors_v2.rs
  • products/ploy/crates/ploy-research/src/lib.rs
  • products/ploy/crates/ploy-research/src/model/supervised/burn_binary.rs
  • products/ploy/crates/ploy-research/src/model/supervised/mod.rs
  • products/ploy/crates/ploy-research/src/prediction_loop.rs
  • products/ploy/crates/ploy-research/src/research_snapshot.rs
  • products/ploy/crates/ploy-research/src/signal/regime.rs
  • products/ploy/crates/ploy-research/src/signal/rules.rs
  • products/ploy/docs/BURN_BINARY_RESEARCH.md
  • products/ploy/tasks/todo.md

Comment thread products/ploy/crates/ploy-research/src/factors.rs
Comment thread products/ploy/crates/ploy-research/src/research_snapshot.rs
@proerror77
proerror77 merged commit 4f2c4c1 into main Jul 15, 2026
29 checks passed
@proerror77
proerror77 deleted the codex/governed-burn-snapshot-inputs branch July 15, 2026 16:46
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.

1 participant