Skip to content

fix(polymarket): bound legacy startup health - #506

Merged
proerror77 merged 3 commits into
mainfrom
codex/polymarket-legacy-start-admission-505
Jul 30, 2026
Merged

fix(polymarket): bound legacy startup health#506
proerror77 merged 3 commits into
mainfrom
codex/polymarket-legacy-start-admission-505

Conversation

@proerror77

@proerror77 proerror77 commented Jul 30, 2026

Copy link
Copy Markdown
Owner

Issue relationship

Closes #505

Change contract

Bound legacy-Python Gate startup admission to the observed completed atomic
health cadence and a target-scaled allowance for exact trades HTTP 429 errors.

Out of scope

Legacy collector or uploader behavior, shared legacy/Rust health policy,
cutover logic, CI layering, research, snapshot/#235, evaluator/MCTS, and
production mutation.

Dependency / merge order

Depends on PR #503 at base 61c959c453819d97401b699ae4c8e95af9129f3d.
Runtime issue #498 remains blocked until this PR merges and a new exact-main
artifact passes real-segment preflight and the 900-second Gate.

Focused validation

  • Red proof: the old policy rejected 18 exact trades 429s for 2,792 markets.
  • 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
  • bash -n for both changed shell scripts
  • jq -n -f deployment/aliyun/polymarket-shadow-gate-policy.jq
  • git diff --check
  • Independent spec and standards reviews: APPROVE

Counterexamples cover 2,700/2,701-second freshness, 18/2,792 acceptance,
29/2,792 rejection, 33/10,000 rejection, mixed/wrong/trailing-newline errors,
strict shared legacy policy, strict Rust policy, and preservation of original
errors in immutable Gate evidence.

Rollout / rollback impact

After merge, build a new exact-main immutable release, run a real closed-segment
preflight, then one 900-second Rust Gate. Any failure remains fail-closed with
Python active and Rust shadow stopped. No immutable release is overwritten.

Summary by CodeRabbit

  • Bug Fixes

    • Improved validation of legacy startup health snapshots using a dedicated freshness window.
    • Added dynamic limits for acceptable API errors based on the number of target markets.
    • Tightened trade-rate health checks, including absolute caps and validation of rate-limit errors.
    • Updated health policy boundaries for older snapshots.
  • Tests

    • Expanded coverage for startup health freshness, API-error limits, target-market scaling, and trade-rate scenarios.

@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: 20 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: 2c126df2-00a4-42b7-be55-c032e7a98238

📥 Commits

Reviewing files that changed from the base of the PR and between 7dd406c and da809c8.

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

Walkthrough

Legacy startup health admission now supports a 2700-second age limit and target-market-based API-error bounds. The jq policy and control-plane tests cover HTTP 429 validation, absolute caps, publication-age boundaries, constant wiring, and deterministic freshness checks.

Changes

Legacy startup health bounds

Layer / File(s) Summary
Dynamic legacy health error limits
deployment/aliyun/polymarket-raw-ops-shadow-gate.sh, deployment/aliyun/polymarket-shadow-gate-policy.jq
Legacy health validation derives API-error limits from target_markets, clamps them, and validates bounded HTTP 429 entries. The baseline publication-age bound is increased to 2700 seconds.
Startup health freshness override
deployment/aliyun/polymarket-raw-ops-shadow-gate.sh
fresh_legacy_health_observation accepts a validated age override, and legacy admission passes LEGACY_START_HEALTH_MAX_AGE_SECONDS.
Policy and observer boundary tests
deployment/aliyun/test-polymarket-raw-ops-control-plane.sh
Tests cover rate-limit ratios and caps, publication-age boundaries, constant extraction, and deterministic fake-time freshness checks.

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

Sequence Diagram(s)

sequenceDiagram
  participant LegacyHealthAdmission
  participant fresh_legacy_health_observation
  participant HealthSnapshot
  LegacyHealthAdmission->>fresh_legacy_health_observation: pass 2700-second max age
  fresh_legacy_health_observation->>HealthSnapshot: read publication timestamp
  fresh_legacy_health_observation-->>LegacyHealthAdmission: return freshness result
Loading

Possibly related issues

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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
Title check ✅ Passed The title accurately summarizes the main change: bounding legacy startup health.
Description check ✅ Passed The description covers the change contract, issue linkage, validation, and rollout, with only a minor missing template section.
Linked Issues check ✅ Passed The code matches #505 by enforcing the 2700-second startup limit and target-scaled 429 error bounds, with matching boundary tests.
Out of Scope Changes check ✅ Passed The diff is focused on the legacy startup health policy and its tests, with no clear unrelated changes.
✨ Finishing Touches 💡 1
📝 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-legacy-start-admission-505

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: 56d453449b

ℹ️ 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-raw-ops-shadow-gate.sh
@proerror77
proerror77 enabled auto-merge (squash) July 30, 2026 15:15
@proerror77
proerror77 force-pushed the codex/polymarket-legacy-start-admission-505 branch 2 times, most recently from 2dc353f to c1d6fc5 Compare July 30, 2026 15:31
@proerror77
proerror77 force-pushed the codex/polymarket-legacy-start-admission-505 branch from 2ce31c0 to da809c8 Compare July 30, 2026 15:56
@proerror77
proerror77 merged commit 919197b into main Jul 30, 2026
41 checks passed
@proerror77
proerror77 deleted the codex/polymarket-legacy-start-admission-505 branch July 30, 2026 16:05
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.

fix(polymarket): bound legacy startup health by cadence and rate-limit ratio

1 participant