Skip to content

feat(polymarket): verify incomplete candidate evidence - #339

Merged
proerror77 merged 2 commits into
mainfrom
codex/candidate-verifier-337
Jul 24, 2026
Merged

feat(polymarket): verify incomplete candidate evidence#339
proerror77 merged 2 commits into
mainfrom
codex/candidate-verifier-337

Conversation

@proerror77

@proerror77 proerror77 commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Change contract

Add an independent ploy-market-data verifier for event-local Polymarket candidate triplets. It authenticates the immutable triplet with the existing bound-directory/FD and digest trust anchor, validates every present row with the existing semantics, reports derived five-surface coverage while allowing absent optional surfaces, and refreshes the two checked-in BTC/SOL mission policy pins affected by the verifier sources.

Closes #337.

Out of scope

Task capability policy, catalog receipts/queries, OSS acquisition/download, snapshot/cohort construction, evaluator/MCTS behavior, deployment, and collector changes.

Dependency / merge order

Depends on #336 / PR #338 (merged as d5dabc5bee09a5ab8802754ec3aba9bf5292cede). Merge this PR before #319.

Focused validation

  • cargo test -p ploy-market-data polymarket_evidence --locked — 63 passed
  • cargo test -p ploy-market-data --locked — 69 passed
  • cargo test -p ploy-research --lib checked_in_btc_and_sol_templates_pin_current_brief_and_rust_policy --locked — 1 passed
  • cargo check -p ploy-market-data --tests --locked --target x86_64-unknown-linux-gnu — pass
  • rustfmt --check on both verifier files — pass
  • git diff --check — pass
  • Matt Standards review — PASS
  • Matt Spec review — PASS
  • Scope guardrail — 4 files, 632 additions + 48 deletions = 680 changed lines

Safety counterexamples

  • Missing Up/Down book, reference, trades, or settlement yields explicit zero coverage and no synthesized rows.
  • A corrupt present order book is rejected by the existing row validator.
  • Wrong content/manifest trust anchor is rejected before candidate verification.
  • Candidate trades may lack a completion proof only when the proof is absent; present proof data is still checked when supplied.
  • Complete evidence verification remains strict and still rejects missing required surfaces.

Rollout / rollback impact

No runtime cutover. Rollback removes only the candidate seal/verify API, its tests, and the coupled checked-in pin refresh; the complete evidence path remains unchanged.

@coderabbitai

coderabbitai Bot commented Jul 24, 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: 17 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: d9686cf2-7786-4416-9880-0e1492189e48

📥 Commits

Reviewing files that changed from the base of the PR and between d5dabc5 and 3f47a8c.

📒 Files selected for processing (4)
  • 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
  • rust_hft/prediction-markets/crates/ploy-market-data/src/polymarket_evidence/verified.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/candidate-verifier-337

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

ℹ️ 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 +748 to +752
match inputs {
ValidatedInputs::V1(inputs) if inputs.reference.trade_completions.is_empty() => {
Ok(BTreeMap::new())
}
_ => validated_reference_trade_completions(inputs),

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 Validate candidate input proofs before accepting them

When a V2 candidate supplies a completion proof with the correct market identity, row count, and record-ID digest but an invalid completeness_basis, zero stability/finalization values, or out-of-range sequence/timestamp, this path merely aggregates it and frame_ndjson accepts it. Unlike complete artifacts, candidate manifests never run the existing segment/proof validation, so the API can report a present untrusted collector proof as verified despite invalid provenance; validate all supplied input identities and proof metadata while continuing to permit the proof itself to be absent.

AGENTS.md reference: AGENTS.md:L50-L54

Useful? React with 👍 / 👎.

Comment on lines +331 to +334
let event = parsed
.coverage
.get(market_id)
.ok_or_else(|| anyhow!("candidate market has no evidence coverage"))?;

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 Return zero coverage for contract-only candidates

When collection produces the required market-contract row but none of the five optional evidence surfaces, sealing succeeds because all surface counts may be zero, but verify_rows leaves coverage empty and this lookup rejects the candidate. This contradicts the incomplete-candidate contract: a legitimate fully missing candidate should verify with all five coverage fields set to zero so downstream qualification can record the absence rather than treating the artifact as malformed.

Useful? React with 👍 / 👎.

Comment on lines +728 to +731
"orderbook_snapshot".to_owned(),
surface_counts["up_book"]
.checked_add(surface_counts["down_book"])
.context("candidate orderbook count overflow")?,

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 mismatched per-side book counts

When a candidate manifest swaps or otherwise misstates up_book and down_book while preserving their sum, this conversion collapses both claims into one orderbook_snapshot count before frame_ndjson compares the manifest to the rows. The artifact therefore verifies even when its authenticated five-surface manifest says an Up book is present but the data contains only a Down book (or vice versa); compare the derived book sides against the two manifest fields so contradictory untrusted metadata is rejected.

AGENTS.md reference: AGENTS.md:L50-L54

Useful? React with 👍 / 👎.

@proerror77
proerror77 merged commit f92678a into main Jul 24, 2026
29 checks passed
@proerror77
proerror77 deleted the codex/candidate-verifier-337 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.

Verify incomplete Polymarket candidate evidence without weakening complete evidence

1 participant