Skip to content

fix(research): pin static prediction policy graph - #76

Merged
proerror77 merged 1 commit into
mainfrom
codex/prediction-policy-fingerprint
Jul 16, 2026
Merged

fix(research): pin static prediction policy graph#76
proerror77 merged 1 commit into
mainfrom
codex/prediction-policy-fingerprint

Conversation

@proerror77

@proerror77 proerror77 commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Change contract

The research-only prediction policy identity consumes a reviewed, checked-in x86_64-unknown-linux-gnu default,db dependency graph rather than recursively calling Cargo during every build. The v5 graph pins resolved package/source/checksum/feature evidence plus hashes for Cargo.lock and its four path-dependency manifests. The build script fails closed if an input, graph hash, PostgreSQL profile, or forbidden authority/SQLite/host/proc-macro package drifts. BTC and SOL templates pin the resulting policy ID.

Out of scope

Dependency / merge order

None. This is a standalone research CI fix against main. After #76 merges, #75 must rebase or rerun CI against the updated base.

Focused validation

  • cargo metadata --locked --no-deps --format-version 1
  • cargo test --locked -p ploy-research runtime_identity_uses_a_canonical_checked_in_linux_graph_with_features --lib -- --test-threads=1
  • cargo test --locked -p ploy-research checked_in_graph_validation_rejects_stale_and_forbidden_counterexamples --lib -- --test-threads=1
  • cargo test --locked -p ploy-research checked_in_btc_and_sol_templates_pin_current_brief_and_rust_policy --lib -- --test-threads=1
  • Full PLOY research-heavy sequence: feed loaders; research library default and ML; strict Clippy; research/evaluator checks; market-data audit/example; snapshot test.
  • cargo fmt --all -- --check and git diff --check.
  • Linux diagnosis: current GitHub Ubuntu and Docker research-image builds emitted the same 156-line raw graph (d1e06…); the prior mismatch was recursive Cargo-tree build-context instability, not a macOS/Linux artifact. The checked-in reviewed graph hash is sha256:3be7f78980c58e79d0ed94b61dd2ec17570fd60b73c661611fc296d10fcf539f. Final PR CI must pass both Linux build contexts.

Rollout / rollback

Research identity only; no execution behavior changes. A dependency or manifest drift stops compilation until the reviewed graph/hash and mission pins are updated atomically. Rollback is one revert, with matching mission pins restored in that same revert.

Summary by CodeRabbit

  • Enhancements

    • Strengthened prediction-policy identity verification for Linux research runs.
    • Added fail-closed checks to detect stale, modified, or unauthorized dependency metadata.
    • Updated mission templates to reference the latest reviewed policy snapshot.
  • Documentation

    • Clarified policy identity requirements, approved build evidence, and excluded dependency categories.
    • Updated migration guidance to require reviewed policy pinning.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5c112fd9-0fbc-4db5-9548-3990f68d4707

📥 Commits

Reviewing files that changed from the base of the PR and between c4ecbd6 and 9108e89.

⛔ Files ignored due to path filters (1)
  • rust_hft/prediction-markets/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (9)
  • 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/Cargo.toml
  • rust_hft/prediction-markets/crates/ploy-research/build.rs
  • rust_hft/prediction-markets/crates/ploy-research/prediction-policy-dependencies.linux.sha256
  • rust_hft/prediction-markets/crates/ploy-research/prediction-policy-dependencies.linux.txt
  • rust_hft/prediction-markets/crates/ploy-research/src/prediction_policy_identity.rs
  • rust_hft/prediction-markets/docs/ALPHA_FACTOR_SEARCH_CICD.md
  • rust_hft/prediction-markets/tasks/todo.md
🚧 Files skipped from review as they are similar to previous changes (4)
  • rust_hft/prediction-markets/crates/ploy-research/prediction-policy-dependencies.linux.sha256
  • rust_hft/prediction-markets/tasks/todo.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

📝 Walkthrough

Walkthrough

The PR replaces generated dependency fingerprints with checked-in v5 Linux dependency artifacts, validates their hashes and package composition during builds, updates runtime identity tests, and changes mission snapshot identifiers and related policy documentation.

Changes

Prediction-policy identity

Layer / File(s) Summary
Checked-in Linux graph verification
rust_hft/prediction-markets/crates/ploy-research/Cargo.toml, rust_hft/prediction-markets/crates/ploy-research/build.rs, rust_hft/prediction-markets/crates/ploy-research/prediction-policy-dependencies.linux.*
Build-time logic validates the checked-in v5 Linux graph, input manifest hashes, package restrictions, PostgreSQL features, and canonical SHA-256 value before writing the verified identity.
Runtime identity validation
rust_hft/prediction-markets/crates/ploy-research/src/prediction_policy_identity.rs
Tests verify the canonical graph hash, v5 Linux/DB markers, excluded packages, and rejection of stale-lock or manipulated graph entries.
Mission identity contract updates
rust_hft/prediction-markets/config/research_missions/*.example.json, rust_hft/prediction-markets/docs/ALPHA_FACTOR_SEARCH_CICD.md, rust_hft/prediction-markets/tasks/todo.md
Mission snapshot hashes and policy documentation are updated for the reviewed v5 Linux dependency identity.
Estimated code review effort: 3 (Moderate) ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Cargo
  participant build.rs
  participant CheckedInGraph
  participant RuntimeTests
  participant MissionConfig
  Cargo->>build.rs: execute build verification
  build.rs->>CheckedInGraph: validate graph and canonical SHA-256
  build.rs-->>RuntimeTests: expose verified dependency identity
  RuntimeTests->>RuntimeTests: compare runtime identity and rejection cases
  MissionConfig->>RuntimeTests: use updated policy snapshot identifier
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: pinning the research prediction policy graph.
Description check ✅ Passed The description covers the required contract, out of scope, merge order, validation, and rollout details; only the optional scope-exception section is omitted.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/prediction-policy-fingerprint

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: 0c9bcb3f8c

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

// The policy contract follows only target runtime dependencies.
// Build scripts and proc macros compile for the host and would
// otherwise make this Linux identity vary by developer machine.
"normal,no-proc-macro",

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 Do not drop proc-macro inputs from the policy identity

This filters all proc-macro edges out of the policy dependency fingerprint; Cargo 1.91.1 cargo tree --help documents no-proc-macro as an --edges filter, and several files that are explicitly part of the policy source set still rely on proc macros that generate target code (for example prediction_loop.rs:288 includes ploy-feed-loaders/src/database.rs, which uses #[derive(sqlx::FromRow)] at database.rs:227, and the evaluator uses #[tokio::main]). If a lockfile update changes one of those macro implementations or their parsing/codegen stack without changing the displayed normal packages, current_prediction_policy_snapshot_id() remains unchanged while the compiled evaluator/loader behavior can change, so stale missions can keep passing the content-addressed policy check.

Useful? React with 👍 / 👎.

@proerror77
proerror77 force-pushed the codex/prediction-policy-fingerprint branch from 0c9bcb3 to c4ecbd6 Compare July 16, 2026 13:45

@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

🤖 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/prediction-markets/crates/ploy-research/prediction-policy-dependencies.linux.sha256`:
- Line 1: Replace the all-zero value in
rust_hft/prediction-markets/crates/ploy-research/prediction-policy-dependencies.linux.sha256:1
with the actual Linux-generated sha256 digest, then recompute the derived search
policy snapshot ID and update search_policy_snapshot_id in
rust_hft/prediction-markets/config/research_missions/polymarket-btc-5m.example.json:17
and
rust_hft/prediction-markets/config/research_missions/polymarket-sol-5m.example.json:17
to match it.
🪄 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: 19139646-4ff1-41dd-8f5a-170ee1510b34

📥 Commits

Reviewing files that changed from the base of the PR and between 57d5e80 and c4ecbd6.

📒 Files selected for processing (7)
  • 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/Cargo.toml
  • rust_hft/prediction-markets/crates/ploy-research/build.rs
  • rust_hft/prediction-markets/crates/ploy-research/prediction-policy-dependencies.linux.sha256
  • rust_hft/prediction-markets/crates/ploy-research/src/prediction_policy_identity.rs
  • rust_hft/prediction-markets/tasks/todo.md

@@ -0,0 +1 @@
sha256:0000000000000000000000000000000000000000000000000000000000000000

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Replace placeholder hash and update dependent mission snapshot IDs.

The file prediction-policy-dependencies.linux.sha256 currently contains an all-zeros placeholder hash. Because build.rs enforces an exact hash match on native Linux hosts (if native_linux_host() && canonical_hash != generated_hash { panic!(...) }), this placeholder will cause the build to panic and fail in Linux CI environments.

Additionally, the search_policy_snapshot_id in the mission templates was likely computed using this placeholder hash and will fail validation once the true dependency hash is applied.

  • rust_hft/prediction-markets/crates/ploy-research/prediction-policy-dependencies.linux.sha256#L1-L1: Replace the all-zeros placeholder with the actual sha256: digest generated on a Linux host.
  • rust_hft/prediction-markets/config/research_missions/polymarket-btc-5m.example.json#L17-L17: Update search_policy_snapshot_id to match the new ID derived from the corrected dependency hash.
  • rust_hft/prediction-markets/config/research_missions/polymarket-sol-5m.example.json#L17-L17: Update search_policy_snapshot_id to match the new ID derived from the corrected dependency hash.
📍 Affects 3 files
  • rust_hft/prediction-markets/crates/ploy-research/prediction-policy-dependencies.linux.sha256#L1-L1 (this comment)
  • rust_hft/prediction-markets/config/research_missions/polymarket-btc-5m.example.json#L17-L17
  • rust_hft/prediction-markets/config/research_missions/polymarket-sol-5m.example.json#L17-L17
🤖 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/prediction-policy-dependencies.linux.sha256`
at line 1, Replace the all-zero value in
rust_hft/prediction-markets/crates/ploy-research/prediction-policy-dependencies.linux.sha256:1
with the actual Linux-generated sha256 digest, then recompute the derived search
policy snapshot ID and update search_policy_snapshot_id in
rust_hft/prediction-markets/config/research_missions/polymarket-btc-5m.example.json:17
and
rust_hft/prediction-markets/config/research_missions/polymarket-sol-5m.example.json:17
to match it.

@proerror77
proerror77 force-pushed the codex/prediction-policy-fingerprint branch from c4ecbd6 to 5c6888e Compare July 16, 2026 13:56
@proerror77
proerror77 marked this pull request as draft July 16, 2026 14:24
@proerror77
proerror77 force-pushed the codex/prediction-policy-fingerprint branch 3 times, most recently from 97be133 to d22c92a Compare July 16, 2026 14:33
@proerror77 proerror77 changed the title fix(research): stabilize prediction policy fingerprint fix(research): pin static prediction policy graph Jul 16, 2026
@proerror77
proerror77 force-pushed the codex/prediction-policy-fingerprint branch from d22c92a to 9108e89 Compare July 16, 2026 15:05
@proerror77
proerror77 marked this pull request as ready for review July 16, 2026 15:26
@proerror77
proerror77 merged commit 1ec9add into main Jul 16, 2026
26 checks passed
@proerror77
proerror77 deleted the codex/prediction-policy-fingerprint branch July 16, 2026 17: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