Skip to content

fix(polymarket): admit trailing completion proof inputs - #298

Merged
proerror77 merged 2 commits into
mainfrom
codex/polymarket-completion-input-hours-297
Jul 23, 2026
Merged

proerror77 merged 2 commits into
mainfrom
codex/polymarket-completion-input-hours-297

Conversation

@proerror77

@proerror77 proerror77 commented Jul 23, 2026

Copy link
Copy Markdown
Owner

Change contract

For explicit-market Polymarket evidence only, admit authenticated trailing reference segments that contain redundant metadata plus exact completion proofs but no trade or settlement history, while keeping every segment ordered/non-overlapping and every data-bearing segment consecutive by UTC hour.

Out of scope

Collector or deployment changes; evidence byte or digest formulas; snapshot sampling or factor logic; Binance inputs; evaluator/MCTS; Paper or Live.

Dependency or merge order

Base: main@23af4258bf452a94c8c630ad1f8d8d5479f6b954. Depends on the event-local sparse-reference producer contract merged in #278 and verifier fixes through #294. The unrelated frontend audit blocker was split into #299/#300 and is merged. Merge this PR before retrying #232 with an exact-main research image.

Focused validation

  • Red proof before implementation: the explicit 17:00 data plus 20:00 completion-proof shape failed with validated reference inputs must be consecutive UTC hours.
  • Focused positive/negative tests: explicit 17 -> 20 accepted; the same non-explicit shape rejected; early, reversed, ordered-interleaved, malformed, and data-gap inputs rejected.
  • cargo test -p ploy-market-data - 60 passed.
  • cargo test -p ploy-research --test mission_search_policies -- polymarket_missions_pin_current_search_policy_snapshot - passed for BTC 5m and SOL 5m governed missions.
  • cargo fmt -p ploy-market-data -- --check - passed.
  • cargo clippy -p ploy-market-data --all-targets --no-deps -- -D warnings - passed.
  • git diff --check - passed.
  • Matt two-axis read-only code review - Standards: APPROVE; Spec: APPROVE, including the required policy-pin update.

Rollout or rollback impact

Rollout publishes a new immutable exact-main research image, then reruns the unchanged #232 evidence in ACK. Rollback is a one-commit revert; no existing artifact or collector state is mutated.

Root cause

PR #278 intentionally allowed explicit event-local evidence normalization to consume nondecreasing sparse reference hours, but the downstream typed verifier retained PR #154's earlier consecutive-hour rule. This producer/verifier contract drift rejected a valid later completion-proof segment.

Why no PRD

#297 defines one already-approved verifier predicate and its counterexamples, so Matt TDD was the narrowest workflow.

Tracks #297. Cloud acceptance remains post-merge and will be recorded on the issue before it is closed.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Validation now uses explicit market selection to gate quote-collection failures and completion-only references. Reference ordering, UTC-hour constraints, event composition, test helpers, and completion-only scenarios were updated.

Changes

Explicit reference validation

Layer / File(s) Summary
Explicit-selection event gating
rust_hft/prediction-markets/crates/ploy-market-data/src/polymarket_evidence/artifact.rs
validate_inputs uses explicit selection to determine whether quote_collection_failure is an allowed event type.
Completion-only reference rules and coverage
rust_hft/prediction-markets/crates/ploy-market-data/src/polymarket_evidence/artifact.rs
Reference validation adds completion-only detection, UTC-hour ordering and sequencing checks, explicit manifest rewriting in test utilities, and coverage for valid, sparse, early, interleaved, and malformed references.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related issues

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title accurately summarizes the main change: allowing trailing completion-proof Polymarket inputs.
Description check ✅ Passed The description covers the required contract, out-of-scope, dependencies, validation, and rollout details.
✨ 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-completion-input-hours-297

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.

🧹 Nitpick comments (2)
rust_hft/prediction-markets/crates/ploy-market-data/src/polymarket_evidence/artifact.rs (2)

695-753: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Completion-only sequencing logic verified correct.

Traced this against all new/existing tests (later-only OK, sparse/non-explicit rejected, early/interleaved rejected, reversed rejected, same-hour overlap rejected): the all-references ordering check (701-711) plus the data_references-only consecutive-hour check (735-743) plus the has_prior_metadata/data_references.is_empty() guard (716-719) and the "must follow all evidence data" guard (726-733) together correctly implement "ordered & non-overlapping for all segments, consecutive UTC hours for data-bearing segments only, trailing-only completion proofs." No correctness issue found.

One coverage gap: no test exercises a chain of multiple consecutive completion-only references after the data segments (the logic appears to permit this, consistent with "trailing reference segments" being plural in the PR summary), so a regression here wouldn't be caught.

🤖 Prompt for 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.

In
`@rust_hft/prediction-markets/crates/ploy-market-data/src/polymarket_evidence/artifact.rs`
around lines 695 - 753, ​​Add a regression test covering multiple consecutive
completion-only references after the data-bearing segments in the validation
flow around the ordering and sequencing checks. Ensure the test confirms the
trailing completion-only chain is accepted while preserving the existing
requirements that completion-only references follow evidence data and remain
trailing.

1419-1549: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Good coverage of new sequencing rules; consider adding a chained completion-only test.

These four tests correctly pin down: later completion-only accepted, sparse completion-only rejected when the manifest isn't explicit, early/interleaved completion-only rejected with distinct messages, and malformed completion counts still rejected. Consider adding a case with two (or more) consecutive completion-only references trailing the data segments, since the implementation in validate_inputs (695-753) appears to permit that but it's currently untested.

🤖 Prompt for 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.

In
`@rust_hft/prediction-markets/crates/ploy-market-data/src/polymarket_evidence/artifact.rs`
around lines 1419 - 1549, Add a test alongside the existing completion-only
sequencing tests that appends at least two consecutive valid completion-only
references after the final evidence-data reference. Use the existing input
builders and sealing flow, preserve chronological ordering and valid completion
metadata, and assert that validate_inputs via seal_polymarket_evidence_triplet
succeeds.
🤖 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.

Nitpick comments:
In
`@rust_hft/prediction-markets/crates/ploy-market-data/src/polymarket_evidence/artifact.rs`:
- Around line 695-753: ​​Add a regression test covering multiple consecutive
completion-only references after the data-bearing segments in the validation
flow around the ordering and sequencing checks. Ensure the test confirms the
trailing completion-only chain is accepted while preserving the existing
requirements that completion-only references follow evidence data and remain
trailing.
- Around line 1419-1549: Add a test alongside the existing completion-only
sequencing tests that appends at least two consecutive valid completion-only
references after the final evidence-data reference. Use the existing input
builders and sealing flow, preserve chronological ordering and valid completion
metadata, and assert that validate_inputs via seal_polymarket_evidence_triplet
succeeds.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 72137ead-9e44-413e-8319-116916d64605

📥 Commits

Reviewing files that changed from the base of the PR and between 000efe1 and d965da9.

📒 Files selected for processing (1)
  • rust_hft/prediction-markets/crates/ploy-market-data/src/polymarket_evidence/artifact.rs

@proerror77
proerror77 force-pushed the codex/polymarket-completion-input-hours-297 branch from dd03fca to 95ea575 Compare July 23, 2026 22:30
@proerror77
proerror77 merged commit 7cfae3a into main Jul 23, 2026
28 checks passed
@proerror77
proerror77 deleted the codex/polymarket-completion-input-hours-297 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