Skip to content

fix(polymarket): allow Rust-only Gate parity - #497

Merged
proerror77 merged 2 commits into
mainfrom
codex/polymarket-optional-legacy-parity
Jul 30, 2026
Merged

proerror77 merged 2 commits into
mainfrom
codex/polymarket-optional-legacy-parity

Conversation

@proerror77

@proerror77 proerror77 commented Jul 30, 2026

Copy link
Copy Markdown
Owner

Change contract

When the approved 15-minute Polymarket Gate has no projected legacy rows, explicitly switch final parity to rust_self and require positive, valid Rust trades, metadata, settlements, assets, rotation, health, real-segment, OSS, and immutable evidence. Any non-empty legacy projection continues to use strict overlap parity.

Out of scope

Python collector/uploader behavior, research logic, snapshots, issue #235, production cutover, and Gate duration.

Dependency / merge order

None. Based on exact main fe820c543f4304e3771bdf57456b470aecf35846 after the prior Gate unit fix.

Focused validation

  • cargo test -p hft-collector polymarket_parity --locked (27 passed)
  • deployment/aliyun/test-polymarket-raw-ops-control-plane.sh
  • bash -n and ShellCheck on changed shell scripts
  • git diff --check
  • Counterexamples: explicit Rust-self without settlements fails; any non-empty legacy projection stays in strict overlap mode; forged policy evidence fails.

Rollout / rollback impact

This changes only final Gate admission evidence. It does not mutate production. Rollback is reverting this PR; production Python remains the rollback path until a new exact artifact passes real-segment preflight and a fresh 900+601-second Gate. Runtime issue #490 remains open until exact artifact, live Gate, cutover, and cleanup evidence are complete.

Issue relationship

Refs #490

@proerror77
proerror77 enabled auto-merge (squash) July 30, 2026 10:08
@coderabbitai

coderabbitai Bot commented Jul 30, 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: 47 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: a1018a5c-291b-496b-a1e9-557bf55c0cb7

📥 Commits

Reviewing files that changed from the base of the PR and between 1d80bb7 and 69b6c61.

📒 Files selected for processing (2)
  • deployment/aliyun/polymarket-shadow-gate-policy.jq
  • deployment/aliyun/test-polymarket-raw-ops-control-plane.sh
📝 Walkthrough

Walkthrough

The parity verifier adds Rust-self mode for empty legacy windows, exposes it through the CLI and shadow gate, reports comparison mode in evidence, and updates jq policy and control-plane tests for mode-specific validation.

Changes

Shadow parity comparison

Layer / File(s) Summary
Comparison modes and evidence
rust_hft/tools/collector/src/polymarket_parity.rs
compare() selects legacy_overlap or rust_self, applies mode-specific metadata, trade, settlement, field, and rotation checks, reports the mode, and adds unit tests.
CLI and gate wiring
rust_hft/tools/collector/src/bin/polymarket-raw-ops.rs, deployment/aliyun/polymarket-raw-ops-shadow-gate.sh
The CLI accepts --allow-empty-legacy; the gate conditionally appends it through parity_args for the legacy Python path when runtime stability is disabled.
Policy and control-plane validation
deployment/aliyun/polymarket-shadow-gate-policy.jq, deployment/aliyun/test-polymarket-raw-ops-control-plane.sh
Policy validation now distinguishes comparison modes and their metrics, with tests covering overlap, Rust-self success, missing settlements, and gate invocation structure.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ShadowGate
  participant RawOpsCLI
  participant ParityCompare
  participant GatePolicy
  ShadowGate->>RawOpsCLI: invoke verify-shadow-parity with parity_args
  RawOpsCLI->>ParityCompare: pass allow_empty_legacy
  ParityCompare->>ParityCompare: select comparison_mode and evaluate parity
  ParityCompare->>GatePolicy: provide comparison evidence
  GatePolicy->>ShadowGate: accept or reject evidence
Loading

Possibly related issues

Possibly related PRs

  • proerror77/monday#34 — Introduces the parity functionality that this change extends with Rust-self mode and gate integration.
  • proerror77/monday#51 — Also updates shadow-parity comparison, evidence, policy, and control-plane validation.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly matches the main change: enabling Rust-only Gate parity.
Description check ✅ Passed The description covers the contract, validation, rollout, and issue link, but it has a duplicate Issue relationship section with a placeholder None.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Fix failing CI checks
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/polymarket-optional-legacy-parity

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: 1d80bb725a

ℹ️ 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 deployment/aliyun/polymarket-shadow-gate-policy.jq 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.

Caution

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

⚠️ Outside diff range comments (1)
deployment/aliyun/polymarket-shadow-gate-policy.jq (1)

262-291: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Bind rust_self to the non-blocking legacy baseline.

The policy permits rust_self for a runtime-stable legacy_python or rust_release baseline if legacy counts are forged to zero. Require baseline_mode == "legacy_python" and baseline_runtime_stability_required == false in the rust_self branch.

  • deployment/aliyun/polymarket-shadow-gate-policy.jq#L262-L291: constrain the rust_self metrics branch to the non-blocking legacy baseline.
  • deployment/aliyun/test-polymarket-raw-ops-control-plane.sh#L2578-L2598: add a forged runtime-stable legacy-overlap fixture mutated to rust_self with zero legacy counts and assert policy rejection.

As per coding guidelines, “Safety boundaries require a targeted counterexample test, not only workspace compilation.”

🤖 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 `@deployment/aliyun/polymarket-shadow-gate-policy.jq` around lines 262 - 291,
Constrain the rust_self branch in the policy around the comparison-mode
validation to require baseline_mode == "legacy_python" and
baseline_runtime_stability_required == false. Add the targeted forged
runtime-stable legacy-overlap fixture in
deployment/aliyun/test-polymarket-raw-ops-control-plane.sh around lines
2578-2598, mutate it to rust_self with zero legacy counts, and assert policy
rejection.

Source: Coding guidelines

🤖 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.

Outside diff comments:
In `@deployment/aliyun/polymarket-shadow-gate-policy.jq`:
- Around line 262-291: Constrain the rust_self branch in the policy around the
comparison-mode validation to require baseline_mode == "legacy_python" and
baseline_runtime_stability_required == false. Add the targeted forged
runtime-stable legacy-overlap fixture in
deployment/aliyun/test-polymarket-raw-ops-control-plane.sh around lines
2578-2598, mutate it to rust_self with zero legacy counts, and assert policy
rejection.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 07e897cc-47eb-415e-9343-b0d1683c7c4e

📥 Commits

Reviewing files that changed from the base of the PR and between fe820c5 and 1d80bb7.

📒 Files selected for processing (5)
  • deployment/aliyun/polymarket-raw-ops-shadow-gate.sh
  • deployment/aliyun/polymarket-shadow-gate-policy.jq
  • deployment/aliyun/test-polymarket-raw-ops-control-plane.sh
  • rust_hft/tools/collector/src/bin/polymarket-raw-ops.rs
  • rust_hft/tools/collector/src/polymarket_parity.rs

@proerror77
proerror77 merged commit c89d7b4 into main Jul 30, 2026
42 checks passed
@proerror77
proerror77 deleted the codex/polymarket-optional-legacy-parity branch July 30, 2026 10:30
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