Skip to content

fix(polymarket): bound production Gate to 900 seconds - #501

Merged
proerror77 merged 2 commits into
mainfrom
codex/polymarket-gate-900-total
Jul 30, 2026
Merged

fix(polymarket): bound production Gate to 900 seconds#501
proerror77 merged 2 commits into
mainfrom
codex/polymarket-gate-900-total

Conversation

@proerror77

@proerror77 proerror77 commented Jul 30, 2026

Copy link
Copy Markdown
Owner

Change contract

Run the production Polymarket Rust shadow Gate for exactly 900 seconds total, with the 601-second parity tail contained inside that window, after a fail-fast real-segment preflight capped at 300 seconds.

The Gate still requires a policy-clean atomic Python health publication at admission, captures and checks Python PID/InvocationID/NRestarts for the whole Gate, and validates Rust health, real-segment upload/readback, parity, immutable evidence, and wall-clock bounds. It does not wait for another Python collection cycle. If no Python comparison rows fall inside the Gate window, the user-approved Rust-self mode remains fail-closed on stable Python identity plus nonzero, valid Rust trade and settlement evidence.

Out of scope

Dependency / merge order

Focused validation

  • bash -n deployment/aliyun/polymarket-raw-ops-shadow-gate.sh
  • bash -n deployment/aliyun/test-polymarket-raw-ops-control-plane.sh
  • shellcheck deployment/aliyun/polymarket-raw-ops-shadow-gate.sh deployment/aliyun/test-polymarket-raw-ops-control-plane.sh
  • jq -n -f deployment/aliyun/polymarket-shadow-gate-policy.jq
  • bash deployment/aliyun/test-polymarket-raw-ops-control-plane.sh
  • cargo test --manifest-path rust_hft/Cargo.toml -p hft-collector polymarket_parity (27 passed)
  • Independent spec review: APPROVE
  • Independent standards review: APPROVE

Counterexamples cover 899-second rejection, pre-Gate parity rejection, unelapsed 900-second wall-clock rejection, disabled Python health/identity rejection, and timer ordering after the Rust shadow PID/InvocationID baseline exists.

Rollout / rollback impact

After merge, build a new exact-main artifact, perform a <=300-second preflight, run one 900-second Gate, cut over the three Rust services, and supervise a 300-second production smoke. Any Gate failure keeps Python and stops shadow; any smoke failure invokes the existing cutover rollback using the exact cutover evidence directory.

Issue relationship

Refs #498

@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: 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: 5251365d-fed3-4491-afa9-f211bacac043

📥 Commits

Reviewing files that changed from the base of the PR and between 3214966 and 0645ad1.

📒 Files selected for processing (4)
  • 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/polymarket_parity.rs
📝 Walkthrough

Walkthrough

The shadow gate now uses a bounded 900-second observation window, stricter legacy baseline admission and identity checks, revised preflight budgeting, updated parity evidence handling, and matching policy and control-plane contract tests.

Changes

Shadow Gate Control Flow

Layer / File(s) Summary
Bounded gate timing and policy validation
deployment/aliyun/polymarket-raw-ops-shadow-gate.sh, deployment/aliyun/polymarket-shadow-gate-policy.jq, deployment/aliyun/test-polymarket-raw-ops-control-plane.sh
Gate duration, parity-window bounds, loop termination, policy timestamp constraints, and short-window evidence tests are updated for the revised timing contract.
Legacy health admission and preflight
deployment/aliyun/polymarket-raw-ops-shadow-gate.sh, deployment/aliyun/test-polymarket-raw-ops-control-plane.sh
Legacy health observations and baseline identity are validated fail-closed around admission and preflight, with revised runtime budget and observer contract tests.
Baseline stability and parity evidence
deployment/aliyun/polymarket-raw-ops-shadow-gate.sh, deployment/aliyun/polymarket-shadow-gate-policy.jq, deployment/aliyun/test-polymarket-raw-ops-control-plane.sh
Legacy eligibility requires health start and runtime stability, parity allows empty legacy evidence for legacy mode, and forged-evidence and identity-bypass tests are tightened.

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

Possibly related issues

  • proerror77/monday#499 — Covers the same 900-second gate, preflight, legacy admission, identity stability, and Rust-self evidence changes.
  • proerror77/monday#498 — Covers the strict 900-second gate, bounded preflight, and legacy identity/stability checks.
  • proerror77/monday#486 — Covers the 900-second gate, 601-second parity interval, and expedited legacy admission.
  • proerror77/monday#490 — Covers non-blocking legacy behavior and removal of extra freshness/runtime waits.

Possibly related PRs

🚥 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 and concisely summarizes the main change: bounding the production Gate to 900 seconds.
Description check ✅ Passed The description covers the required contract, issue relationship, out-of-scope work, dependencies, validation, and rollout details.
✨ 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-gate-900-total

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: 3214966fa0

ℹ️ 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
Comment thread deployment/aliyun/polymarket-raw-ops-shadow-gate.sh Outdated
Comment thread deployment/aliyun/polymarket-raw-ops-shadow-gate.sh Outdated
Comment thread deployment/aliyun/polymarket-raw-ops-shadow-gate.sh
Comment thread deployment/aliyun/polymarket-raw-ops-shadow-gate.sh Outdated
@proerror77

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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