Skip to content

fix(polymarket): reject deltas older than snapshot - #445

Merged
proerror77 merged 1 commit into
mainfrom
codex/polymarket-snapshot-stale-delta-444
Jul 29, 2026
Merged

proerror77 merged 1 commit into
mainfrom
codex/polymarket-snapshot-stale-delta-444

Conversation

@proerror77

@proerror77 proerror77 commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Change contract

Reject a Polymarket price-change delta whose source timestamp is older than the latest authenticated full-book snapshot before it can mutate cached depth. Closes #444.

This is a small, already-specified behavior correction, so a separate PRD is unnecessary; issue #444 is the scoped contract.

Out of scope

ACK Job creation or retry; collector deployment or cutover; evidence compilation; ResearchSnapshot; evaluator/MCTS; Paper, Shadow, or Live.

Dependency or merge order

Based on main bbd9405724fc00fcf825990311d99497b8fa6f93 after #442. Merge this PR before any separately authorized #313 acquisition attempt.

Focused validation

  • Red proof before the fix: first_price_change_older_than_a_full_snapshot_is_skipped failed because the first stale delta was applied.
  • cargo test --locked -p ploy-market-data --features live first_price_change_older_than_a_full_snapshot_is_skipped
  • cargo test --locked -p ploy-market-data --features live (146 passed)
  • cargo fmt -p ploy-market-data -- --check
  • git diff --check
  • Two-axis Standards/Spec review: no remaining findings.

Rollout and rollback impact

Recorder parsing only. Rollback restores the previous fail-closed reconnect behavior; no stored artifact is rewritten or deleted.

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of stale market data updates.
    • Outdated price changes are now consistently ignored when a newer order-book snapshot is available.
    • Prevented older updates from incorrectly modifying cached market depth or triggering unnecessary time-order errors.
  • Documentation

    • Updated migration tracking to include validation for outdated initial price-change updates.

@coderabbitai

coderabbitai Bot commented Jul 29, 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 Plus

Run ID: 44e14051-8a7b-4f46-b278-f85d596a07a5

📥 Commits

Reviewing files that changed from the base of the PR and between bbd9405 and ad52683.

📒 Files selected for processing (2)
  • rust_hft/prediction-markets/crates/ploy-market-data/src/feeds.rs
  • rust_hft/prediction-markets/tasks/todo.md

📝 Walkthrough

Walkthrough

The CLOB price-change path now skips deltas older than the current full-book snapshot before applying updates. Its regression test covers an uninitialized last_timestamp, and the migration tracker records the validation requirement.

Changes

CLOB staleness handling

Layer / File(s) Summary
Stale delta filtering
rust_hft/prediction-markets/crates/ploy-market-data/src/feeds.rs
Older snapshot-relative price changes are skipped unconditionally; remaining per-level timestamp checks retain backward-time error handling.
Regression validation and tracker update
rust_hft/prediction-markets/crates/ploy-market-data/src/feeds.rs, rust_hft/prediction-markets/tasks/todo.md
The test verifies that a stale BUY update does not create a bid when last_timestamp is not initialized, and the tracker records the corresponding validation rule.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

  • proerror77/monday issue 441: Both changes adjust market_updates_from_price_change to ignore stale same-token CLOB deltas instead of treating them as errors.

Possibly related PRs

  • proerror77/monday#35: Both modify CLOB market_updates_from_price_change filtering and batch-processing semantics.
  • proerror77/monday#238: Both modify timestamp-based staleness and backward-time handling in market_updates_from_price_change.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly names the main behavior change: rejecting stale deltas older than the snapshot.
Description check ✅ Passed The description covers the change, scope, merge order, validation, and rollback; only the optional scope-exception section is omitted.
Linked Issues check ✅ Passed The code change and regression test match #444 by skipping deltas older than the authenticated snapshot while preserving other late-delta handling.
Out of Scope Changes check ✅ Passed The diff is limited to the requested parsing fix, its regression test, and a related tracker note; no unrelated code changes are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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/polymarket-snapshot-stale-delta-444

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.

@proerror77
proerror77 merged commit 3f733b1 into main Jul 29, 2026
38 checks passed
@proerror77
proerror77 deleted the codex/polymarket-snapshot-stale-delta-444 branch July 29, 2026 08:06
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.

Reject price-change deltas older than the latest CLOB snapshot

1 participant