Skip to content

fix(market-data): accept ordered same-hour references - #213

Merged
proerror77 merged 1 commit into
mainfrom
codex/polymarket-reference-fragment-order
Jul 22, 2026
Merged

proerror77 merged 1 commit into
mainfrom
codex/polymarket-reference-fragment-order

Conversation

@proerror77

@proerror77 proerror77 commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Change contract

Allow validated Polymarket evidence to bind multiple chronologically ordered, non-overlapping immutable reference fragments from the same UTC hour, while preserving fail-closed rejection of reversed, overlapping, or skipped-hour sequences.

Out of scope

Collector/importer changes, evidence byte rewrites, #210/#211 timestamp rules, ResearchSnapshot/cohort construction, factor/label changes, evaluator/MCTS, Paper/Live, 15m/1h.

Dependency / merge order

Base: main@344a9bf39a4d2036ef12335af4671b8d12b290d7. No stacked code dependency. Relates to #212; keep #212 open until the fresh exact-main ACK verifier advances through this gate. This focused fix blocks cloud completion of #173 and therefore #169.

Focused validation

  • Real red proof: ACK Job polymarket-evidence-typed-verify-173-0722x on exact-main image research-runner@sha256:6057938c3fdde14b3b7d9df467a8cd897b068b06ca96807c4b668c9fd2497cc9 rejects authenticated reference hours 10,11,11,11 with validated reference inputs must be consecutive UTC hours.
  • TDD red: seals_ordered_same_hour_reference_fragments failed before the predicate change.
  • Boundary tests: ordered same-hour accepted; reversed and overlapping same-hour rejected; adjacent-hour accepted; skipped-hour rejected.
  • cargo test -p ploy-market-data — 50 passed.
  • cargo fmt -p ploy-market-data -- --check — passed.
  • cargo clippy -p ploy-market-data --all-targets --no-deps -- -D warnings — passed.
  • Mission policy pin test — passed after mechanical BTC/SOL digest refresh.
  • Matt two-axis code review — Standards: 0 hard findings; Spec: 0 findings.

Rollout / rollback impact

Rollout publishes a new immutable research-runner image, then reruns the existing read-only ACK verifier against the exact #173 evidence digests. Rollback is a one-commit revert; no data migration, raw rewrite, or collector change.

Why no PRD

This is a small, already-specified verifier defect with one sequence predicate and targeted counterexamples, so Matt TDD is the narrowest workflow.

Summary by CodeRabbit

  • Bug Fixes

    • Improved evidence validation for same-hour data fragments.
    • Ordered, non-overlapping fragments can now be processed successfully, while reversed or overlapping fragments continue to be rejected.
    • Updated BTC and SOL research mission configurations to use refreshed search policy snapshots.
  • Tests

    • Added coverage for valid ordered fragments and invalid reversed or overlapping sequences.

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

ℹ️ 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 +696 to +698
let ordered_same_hour = next_hour == current_hour
&& parse_time(&pair[1].start_recorded_at, "start_recorded_at")?
>= parse_time(&pair[0].end_recorded_at, "end_recorded_at")?;

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 duplicate point-in-time reference fragments

When a valid same-hour segment has start_recorded_at == end_recorded_at, listing that segment twice makes the second start equal the first end, so this >= check accepts two identical fragments. This violates the non-overlap contract and can double-count or duplicate reference provenance; aggregate_reference_trade_completions will not catch it when the fragment has no completion entries. Reject repeated segment digests/identities, while still allowing distinct fragments that share a timestamp.

Useful? React with 👍 / 👎.

@coderabbitai

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

Run ID: e3ef412e-5015-4941-9a99-5ab5001ffbcd

📥 Commits

Reviewing files that changed from the base of the PR and between 344a9bf and a5c5e12.

📒 Files selected for processing (3)
  • rust_hft/prediction-markets/config/research_missions/polymarket-btc-5m.example.json
  • rust_hft/prediction-markets/config/research_missions/polymarket-sol-5m.example.json
  • rust_hft/prediction-markets/crates/ploy-market-data/src/polymarket_evidence/artifact.rs

📝 Walkthrough

Walkthrough

The PR updates search policy snapshot identifiers for Polymarket BTC and SOL 5-minute missions and changes V2 reference-fragment validation to accept ordered, non-overlapping fragments within the same UTC hour, with tests covering accepted and rejected orderings.

Changes

Reference fragment validation

Layer / File(s) Summary
Same-hour fragment ordering
rust_hft/prediction-markets/crates/ploy-market-data/src/polymarket_evidence/artifact.rs
ValidatedInputs::V2 accepts ordered same-hour fragments and rejects reversed or overlapping fragments, with unit tests for both cases.

Mission snapshot configuration

Layer / File(s) Summary
Search policy snapshot references
rust_hft/prediction-markets/config/research_missions/polymarket-{btc,sol}-5m.example.json
The BTC and SOL mission examples use updated SHA256 search_policy_snapshot_id values.

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

Possibly related issues

  • proerror77/monday issue 212: Directly addresses acceptance and testing of ordered, non-overlapping same-hour Polymarket reference fragments.

Possibly related PRs

  • proerror77/monday#154: Overlaps both the V2 reference-fragment validation changes and the Polymarket mission snapshot updates.
  • proerror77/monday#175: Covers closely related same-hour Polymarket reference-fragment acceptance and validation behavior.
  • proerror77/monday#137: Directly overlaps the BTC and SOL mission configuration snapshot updates.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the main items, but it misses the template's required Scope exception section and should state 'None' for this small change. Add a Scope exception section and set it to 'None'; the current 'Why no PRD' note can be moved there or removed.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: accepting ordered same-hour references.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/polymarket-reference-fragment-order

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Checkov (3.3.8)
rust_hft/prediction-markets/config/research_missions/polymarket-btc-5m.example.json

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'

rust_hft/prediction-markets/config/research_missions/polymarket-sol-5m.example.json

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'


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 8296ba6 into main Jul 22, 2026
28 checks passed
@proerror77
proerror77 deleted the codex/polymarket-reference-fragment-order branch July 24, 2026 08:44
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