Skip to content

feat(collector): bound completion backfill to explicit markets - #166

Merged
proerror77 merged 2 commits into
mainfrom
codex/polymarket-targeted-completion-backfill
Jul 20, 2026
Merged

proerror77 merged 2 commits into
mainfrom
codex/polymarket-targeted-completion-backfill

Conversation

@proerror77

@proerror77 proerror77 commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Change contract: polymarket-raw-ops collect-reference accepts an explicit market-id allowlist and fails closed if Gamma discovery omits any requested market. When the allowlist is active, recovered collector state and trade-ID dedupe state are scoped to those markets, so an isolated historical completion backfill cannot retain unrelated markets.

Acceptance evidence: Linux CI must prove the CLI accepts the allowlist, whitespace IDs are rejected, the missing-requested-market counterexample fails closed, and recovered unrelated state is pruned; then an isolated ECS backfill for the eight BTC 5m market IDs must emit trade-completion proof without changing the live collector.

Out of scope: live collector cutover, state-limit changes, polling-rate changes, evidence publication, snapshot generation, evaluator changes, 15m/1h, and Live/Paper.

Dependency or merge order: #167 merged first. This PR was replayed unchanged onto main commit 0de5c6f and must pass CI on that base before merge.

Focused validation: existing Linux collector-focused checks and CI lanes on head b86302d; remote blob re-read confirms only the two collector files changed and the test-to-implementation stack is unchanged.

Rollout/rollback impact: Opt-in CLI only; no service unit changes. Rollback is reverting this PR or omitting --market-id.

TDD status: the first commit defines the CLI and fail-closed contract; the second implements it and adds the recovered-state and input-sanitization counterexamples.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@proerror77, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 14 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

Run ID: dff91fe6-81f5-4552-b42c-49145a885cf5

📥 Commits

Reviewing files that changed from the base of the PR and between 0de5c6f and b86302d.

📒 Files selected for processing (2)
  • rust_hft/tools/collector/src/bin/polymarket-raw-ops.rs
  • rust_hft/tools/collector/src/polymarket_raw.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/polymarket-targeted-completion-backfill

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 force-pushed the codex/polymarket-targeted-completion-backfill branch from f175a91 to 7d89bf2 Compare July 20, 2026 01:25
@proerror77
proerror77 force-pushed the codex/polymarket-targeted-completion-backfill branch from 7d89bf2 to b86302d Compare July 20, 2026 02:45
@proerror77
proerror77 marked this pull request as ready for review July 20, 2026 02:51
@proerror77
proerror77 merged commit 8e5bb9b into main Jul 20, 2026
17 checks passed
@proerror77
proerror77 deleted the codex/polymarket-targeted-completion-backfill branch July 20, 2026 02:51

@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: b86302d1b4

ℹ️ 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 on lines +2163 to +2166
if !self.config.market_ids.is_empty()
&& !self.config.market_ids.contains(market_id)
{
continue;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Account for symbols before applying the market allowlist

When the allowlist covers only a subset of config.symbols—for example, BTC-only IDs while the CLI retains its default seven symbols—this continue prevents the other successfully discovered symbols from entering discovered_target_symbols. The subsequent missing_symbols check therefore reports ETH/SOL/etc. as absent and collect-reference --once exits with a DataCompletenessError even though every requested market ID was found. Track symbol discovery before this filter or scope the completeness check to the allowlisted markets.

Useful? React with 👍 / 👎.

Comment on lines +233 to +235
if self.market_ids.iter().any(|market_id| {
market_id.is_empty() || market_id.trim() != market_id
}) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject embedded whitespace before pruning recovered state

For an ID containing internal whitespace, such as 2959 141 or an embedded tab, trim() leaves the string unchanged and validation succeeds despite the whitespace-free contract. Startup then treats this malformed value as an active allowlist and can persist a checkpoint with all recovered markets pruned before discovery eventually reports the ID as missing. Reject any char::is_whitespace() occurrence so malformed input fails before state mutation.

Useful? React with 👍 / 👎.

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