Skip to content

fix(collector): accept closed same-hour reference fragments - #175

Merged
proerror77 merged 1 commit into
mainfrom
codex/polymarket-same-hour-reference-fragments
Jul 20, 2026
Merged

proerror77 merged 1 commit into
mainfrom
codex/polymarket-same-hour-reference-fragments

Conversation

@proerror77

@proerror77 proerror77 commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Change contract

Accept an authenticated ordered set of closed Polymarket reference triplets when adjacent immutable fragments are from the same UTC hour or the immediately following hour; reject backward order and skipped hours.

Acceptance evidence

  • cargo test -p hft-collector --lib --locked — 182 passed, 2 ignored.
  • cargo clippy -p hft-collector --lib --tests --locked -- -D warnings — passed.
  • Counterexamples cover same-hour acceptance, consecutive-hour acceptance, skipped-hour rejection, and duplicate v2 trade IDs across same-hour fragments.

Out of scope

Raw collector discovery or deployment, OSS staging/copying, evidence publication, cohort/snapshot construction, evaluator/MCTS, and live execution.

Dependency / merge order

Implements #174 and unblocks #173. Merge before the #173 cloud artifact compilation is retried; no stacked base PR.

Rollout / rollback impact

The parser remains fail-closed for bound files, manifests, policy, duplicate trades, and completion evidence. Rollback reverts only the same-hour transition compatibility; immutable OSS artifacts are unchanged.

Summary by CodeRabbit

  • Bug Fixes
    • Reference segments from the same UTC hour are now accepted during validation.
    • Validation continues to allow consecutive UTC hours while correctly rejecting larger gaps.
    • Updated error messaging and test coverage reflect the revised time-segment rules.

@coderabbitai

coderabbitai Bot commented Jul 20, 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: 18a08294-c5f5-44c4-b666-d2841e880f9b

📥 Commits

Reviewing files that changed from the base of the PR and between 65cf635 and 2e7eb4c.

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

📝 Walkthrough

Walkthrough

Reference-segment validation now accepts segments from the same or next consecutive UTC hour. Tests cover same-hour acceptance, larger-gap rejection, updated messaging, and aligned duplicate-trade timestamps.

Changes

Reference validation

Layer / File(s) Summary
Relax UTC-hour validation
rust_hft/tools/collector/src/polymarket_research_import.rs
Reference segments are accepted when their UTC hour matches the previous segment or immediately follows it.
Update validation coverage
rust_hft/tools/collector/src/polymarket_research_import.rs
Tests cover same-hour fragments, larger-hour-gap rejection, the revised error message, and adjusted duplicate-trade timestamps.

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

Possibly related issues

Possibly related PRs

  • proerror77/monday#154 — Both PRs modify UTC-hour continuity validation for Polymarket reference segments.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately reflects the main behavior change in the collector.
Description check ✅ Passed The description covers the contract, out-of-scope work, dependency order, validation, and rollback impact, with only template heading mismatches.
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-same-hour-reference-fragments

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.

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

ℹ️ 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 +653 to +654
if current < previous || current > previous + TimeDelta::hours(1) {
bail!("reference segments must be same or consecutive UTC hours");

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 Reject backward same-hour fragments

When two fragments are in the same UTC hour, this condition accepts either order because current == previous regardless of their start_recorded_at/end_recorded_at values. A fragment recorded at 05:30 followed by one recorded at 05:10 therefore passes validation, after which combine_references concatenates them in that caller-supplied order and downstream selection retains the first metadata occurrence, making evidence provenance and output depend on an invalid ordering. Compare the authenticated timestamps for equal-hour fragments so backward inputs remain fail-closed.

Useful? React with 👍 / 👎.

Comment on lines +653 to +654
if current < previous || current > previous + TimeDelta::hours(1) {
bail!("reference segments must be same or consecutive UTC hours");

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 reference fragment identities

When an identical same-hour triplet is supplied more than once and that fragment contains no trade rows (for example, a metadata/settlement-only fragment alongside a separate trade fragment), this relaxed check accepts it and the later duplicate guard cannot detect it because it only tracks polymarket_trade record IDs. Validation then reports the same immutable source multiple times and concatenates its records multiple times, so a caller mistake changes authenticated provenance despite adding no new source data. Track and reject duplicate segment digests or file identities before combining the fragments.

Useful? React with 👍 / 👎.

@proerror77
proerror77 merged commit 552c6ca into main Jul 20, 2026
20 checks passed
@proerror77
proerror77 deleted the codex/polymarket-same-hour-reference-fragments branch July 20, 2026 14:11
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