Skip to content

fix(collector): reseed replay-safe segments after warmup - #357

Merged
proerror77 merged 2 commits into
mainfrom
codex/collector-replay-seed
Jul 24, 2026
Merged

proerror77 merged 2 commits into
mainfrom
codex/collector-replay-seed

Conversation

@proerror77

@proerror77 proerror77 commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Change contract: allow the Rust Binance market-tape collector to emit a replay-safe segment after an incomplete startup/warmup segment, while retaining fail-closed sequence-gap and stream-health checks.

Acceptance evidence:

  • cargo test -p hft-collector (all collector tests pass).
  • cargo clippy -p hft-collector --bin binance-lob-archiver -- -D warnings passes.
  • Regression test proves an incomplete first segment is followed by a replay-safe segment-open checkpoint and manifest.

Out of scope: production cutover, shadow-gate policy, snapshot/research logic, historical backfill, and any relaxation of sequence-gap/reconnect checks.

Dependency / merge order: based on merged collector/control-plane release 76107013aa6e58de2e1053b9d5cb1befd4a8b3d9; merge before building the next ECS candidate.

Focused validation: Rust collector unit/integration tests and targeted clippy. Full workspace format check remains blocked by pre-existing unrelated formatting drift; no unrelated files were changed.

Rollout / rollback impact: no production service changes on merge. Build the candidate, install it as shadow only, rerun the short test-only gate, and keep the old production collector active until a formal gate passes. Roll back by retaining the current production release and not promoting the candidate.

Summary by CodeRabbit

  • Bug Fixes
    • Improved scheduled segment rotation so replay-safe checkpoints can be seeded after an earlier incomplete segment.
    • Added stricter validation to prevent checkpoint seeding when sequence gaps or incomplete symbol continuity could affect replay reliability.
    • Ensured subsequent segments can recover correctly once capture and session readiness conditions are met.

@coderabbitai

coderabbitai Bot commented Jul 24, 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: 45 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: 31f8d1de-0337-4d71-8cf3-9ece8f7d5764

📥 Commits

Reviewing files that changed from the base of the PR and between b835e7a and d4c9934.

📒 Files selected for processing (1)
  • rust_hft/tools/collector/src/bin/binance-lob-archiver.rs
📝 Walkthrough

Walkthrough

The archiver separates scheduled seed eligibility from current-segment replay safety, adds a sequence-gap requirement to seed readiness, and tests that a later rotation seeds successfully after an initially incomplete segment.

Changes

Replay-safe segment seeding

Layer / File(s) Summary
Replay readiness predicates
rust_hft/tools/collector/src/bin/binance-lob-archiver.rs
Introduces replay_seed_ready(...) with sequence-gap validation and makes replay_checkpoint_ready(...) require both seed readiness and replay-safe segment state.
Scheduled rotation and lifecycle validation
rust_hft/tools/collector/src/bin/binance-lob-archiver.rs
Scheduled rotation uses seed readiness, and a lifecycle test verifies that a later rotation emits a replay-safe checkpoint after an incomplete initial segment.

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

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: reseeding replay-safe collector segments after warmup.
Description check ✅ Passed The description covers the required contract, out-of-scope items, dependencies, validation, and rollout, though it omits an explicit scope-exception note.
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
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/collector-replay-seed

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: 2

🤖 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/bin/binance-lob-archiver.rs`:
- Around line 4691-4701: Immediately after the initial rotate_segment call in
the test, assert that next.is_replay_safe() is false before any snapshots,
diffs, or trades mutate the scenario. Keep this assertion at the first-rotation
boundary to verify the unseeded, replay-unsafe startup behavior.
- Around line 1442-1446: Add a scheduled-rotation test case alongside the
existing sequence-gap coverage, setting reason to "scheduled" and
process_state.sequence_gaps to 1, then assert that no segment_open checkpoint is
emitted. Keep the existing stream-health setup and verify the new guard in
streams_healthy/depth_streams_healthy checkpoint eligibility independently of
reason.
🪄 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: 220b1d7b-3b79-4b5b-8628-9c4487e1da2a

📥 Commits

Reviewing files that changed from the base of the PR and between 7610701 and b835e7a.

📒 Files selected for processing (1)
  • rust_hft/tools/collector/src/bin/binance-lob-archiver.rs

Comment thread rust_hft/tools/collector/src/bin/binance-lob-archiver.rs
Comment thread rust_hft/tools/collector/src/bin/binance-lob-archiver.rs
@proerror77
proerror77 merged commit 41d08e0 into main Jul 24, 2026
38 checks passed
@proerror77
proerror77 deleted the codex/collector-replay-seed branch July 24, 2026 18:26
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