Skip to content

fix(collector): split transport reconnects from manifest request_failures - #593

Merged
proerror77 merged 2 commits into
mainfrom
codex/manifest-failure-split
Aug 2, 2026
Merged

proerror77 merged 2 commits into
mainfrom
codex/manifest-failure-split

Conversation

@proerror77

@proerror77 proerror77 commented Aug 2, 2026

Copy link
Copy Markdown
Owner

Change contract

The uploader manifest now counts only integrity-domain failures (websocket_payload and any other non-websocket_receive kind, including dirty-isolation rows) in quality.request_failures, and reports transport-lifecycle rows separately as quality.transport_reconnects. canonical/segment_complete (and the upload gate, which reads the same counter) therefore pass tapes whose only failure rows are websocket_receive transport provenance, while any integrity failure still fails closed. Tape row schema is unchanged.

Out of scope

Dependency or merge order

Implements the owner-approved kind-aware gate evolution on #313 (2026-08-02). Single commit on 9dfe84bc.

Focused validation

  • Updated mixed-kind test retains_request_failure_but_marks_segment_incomplete: a tape with one websocket_connect + one websocket_receive row now reports request_failures: 1, transport_reconnects: 1, and remains non-canonical (mixed tape rejected).
  • New transport_reconnects_do_not_block_complete_segment: a complete tape carrying only websocket_receive rows reports request_failures: 0, transport_reconnects: 2, and is canonical/segment_complete (transport-only tape accepted).
  • Zero-failure tapes unchanged (regression).
  • cargo test -p hft-collector: 268 + 72 + 4 passed, 0 failed. cargo fmt --check clean for the changed file (four pre-existing files in the crate fail the newer rustfmt rules at base — untouched and byte-identical to base). Clippy: no new warnings.

Rollout/rollback impact

Manifest semantics change only: downstream gates reading request_failures automatically get the kind-aware meaning approved on #313; consumers needing transport counts can read transport_reconnects. Already-published manifests are not rewritten by this change. Rollback = revert.

Issue relationship

Refs #592

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of WebSocket connection interruptions during data collection.
    • Reconnect events no longer incorrectly reduce quote coverage or completeness results.
  • New Features
    • Added transport reconnect metrics to collection manifests.
  • Tests
    • Expanded coverage for reconnect handling, metric reporting, and other failure scenarios.

…ures

A bare websocket_receive reset is reconnection lifecycle evidence, not
an integrity failure: post-resync book state is rebuilt by the CLOB
snapshot replay, so counting those rows in request_failures made the
canonical and segment_complete gates unreachable on a venue that
resets roughly every 25 minutes.

Manifest quality now counts only integrity-domain failures (every
quote_collection_failure kind except websocket_receive) in
request_failures and reports the receive rows separately as
transport_reconnects. quote_coverage_complete, canonical, and
segment_complete therefore pass for tapes whose only failure rows are
transport reconnects, while any integrity-domain failure still blocks
them. Tape row schema, upload identity, and all other manifest fields
are unchanged, and failure rows keep being recorded as before.

Verification: cargo test -p hft-collector (364 passed across all
suites, 0 failed, incl. new transport_reconnects counterexamples and
the updated mixed-kind rejection test); cargo fmt --check clean;
cargo clippy -D warnings clean.

Refs #592
@coderabbitai

coderabbitai Bot commented Aug 2, 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: 33 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: 1eee2d07-9f4c-41c5-9b5c-ebc53f604df3

📥 Commits

Reviewing files that changed from the base of the PR and between 1f34770 and 7b5bce0.

📒 Files selected for processing (2)
  • rust_hft/prediction-markets/crates/ploy-market-data/src/feeds.rs
  • rust_hft/tools/collector/src/polymarket_upload.rs
📝 Walkthrough

Walkthrough

The collector now classifies WebSocket receive failures as transport reconnects. Manifests report transport_reconnects. Tests verify that reconnect-only failures preserve coverage and canonical completeness, while HTTP failures retain their existing classification.

Changes

Polymarket reconnect accounting

Layer / File(s) Summary
Classify reconnects and report metrics
rust_hft/tools/collector/src/polymarket_upload.rs
The tape scanner counts transport reconnects, classifies websocket_receive failures separately, and adds transport_reconnects to manifest quality metrics.
Validate reconnect behavior
rust_hft/tools/collector/src/polymarket_upload.rs
Tests verify reconnect-only failures preserve quote coverage, segment completeness, and canonical status. HTTP failures report zero transport reconnects. Binance test tape setup is condensed without behavior changes.

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

Possibly related issues

Possibly related PRs

  • proerror77/monday#238 — Modifies Polymarket quote-collection failure handling and manifest metrics for WebSocket reconnects.
  • proerror77/monday#341 — Tracks WebSocket reconnects separately in another collector implementation.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: separating transport reconnects from manifest request failures.
Description check ✅ Passed The description covers the change, issue, scope, dependencies, validation, and rollback, but omits the template's Scope exception section.
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 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/manifest-failure-split

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.

@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/tools/collector/src/polymarket_upload.rs`:
- Around line 1459-1467: The error handling around websocket_receive in the
upload completeness logic must require evidence of post-reconnect tape
reconstruction. Add and consume a post-resync snapshot/recovery record in the
raw manifest, or count websocket_receive in request_failures until that evidence
exists; do not allow transport_reconnects alone to preserve canonical
completeness.
🪄 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 Plus

Run ID: eadd7b5b-bb0d-4b64-a38d-a2dc635068ca

📥 Commits

Reviewing files that changed from the base of the PR and between 9dfe84b and 1f34770.

📒 Files selected for processing (1)
  • rust_hft/tools/collector/src/polymarket_upload.rs

Comment thread rust_hft/tools/collector/src/polymarket_upload.rs

@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: 1f34770b00

ℹ️ 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 rust_hft/tools/collector/src/polymarket_upload.rs Outdated
Comment thread rust_hft/tools/collector/src/polymarket_upload.rs Outdated
P1 (manifest): a websocket_receive or transport_reconnect row is now
excused from request_failures only when the same token later records a
successful quote in tape order, proving the resync actually recovered.
Transport rows without that recovery evidence still count as
request_failures, keeping canonical and segment_complete false for
tapes where a token never came back. The error_kind whitelist accepts
the new transport_reconnect value.

P2 (feed): the hot-path receive-error arm no longer maps every stream
error to websocket_receive. Bare transport drops (io close-family
kinds, plus TCP resets surfaced as
ProtocolError::ResetWithoutClosingHandshake) classify as
transport_reconnect, while genuine protocol violations (other protocol
errors, UTF-8, capacity, non-close io kinds) classify as
websocket_payload, matching the manifest's integrity domain. Tape row
schema is unchanged and the fail-closed empty quote emission is
untouched.

Verification: cargo test -p hft-collector (365 passed, 0 failed, incl.
recovery-gate counterexamples); cargo test -p ploy-market-data (71
passed) and with --features live (168 passed, incl. the receive-error
classification test) under the pinned 1.91 toolchain; fmt clean on
both touched files; clippy unchanged (hft-collector 0, ploy-market-data
36 pre-existing lines).

Refs #592
@proerror77

Copy link
Copy Markdown
Owner Author

Both findings addressed in 7b5bce0: (P1) transport-kind rows (websocket_receive/transport_reconnect) are exempted only when the same token shows a subsequent success quote in tape order — a receive row left as the final event for a token falls back into request_failures; (P2) stream errors are now classified: I/O close-family and ResetWithoutClosingHandshake become transport_reconnect, while protocol/UTF-8/capacity errors become websocket_payload (integrity). hft-collector 365, ploy live 168, default 71 all green.

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