Skip to content

research: audit verified prediction artifacts - #139

Merged
proerror77 merged 21 commits into
mainfrom
codex/polymarket-verified-artifact-audit
Jul 18, 2026
Merged

research: audit verified prediction artifacts#139
proerror77 merged 21 commits into
mainfrom
codex/polymarket-verified-artifact-audit

Conversation

@proerror77

@proerror77 proerror77 commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Change contract

Build the governed six-surface prediction-market data audit directly from private typed VerifiedBinanceMarketTape and VerifiedPolymarketEvidenceSet handles, failing closed on invalid windows, causality or delay, missing event-local opening references, incomplete two-sided book buckets, or settlement absence while emitting canonical snapshot-consumable metrics.

Out of scope

  • Building or serializing ResearchSnapshot
  • CLI or alpha-harness wiring
  • Artifact acquisition, downloading, sealing, or aggregation
  • Collector, runtime, deployment, promotion, or live-execution changes

Dependency or merge order

Focused validation

  • Exact-head formal Linux CI: https://github.com/proerror77/monday/actions/runs/29656545262
  • Focused Linux cloud proof: https://github.com/proerror77/monday/actions/runs/29655064341
  • Scope: 6 files and 749 changed lines, strictly below the 750-line split guardrail.
  • Targeted safety counterexamples include:
    • rejecting misaligned five-minute snapshot bounds
    • requiring a non-carried-forward Chainlink tick strictly before every event start
    • keeping valid opening-reference coverage canonical when extra post-open rows exist, while rejected-only events remain Critical
    • rejecting one-sided or source-delay-violating Polymarket books
    • keeping valid book coverage canonical when an extra stale row exists, while stale-only buckets remain Critical
    • using book source_time for event-lifetime buckets even when availability is delayed
    • failing 999/1000 book coverage even when the isolated gap is only 60 seconds
    • binding the audit, diagnostics evaluator, and verified-set invariants into governed policy identity

Rollout / rollback impact

Research-only typed audit seam. Roll forward by calling it inside the next snapshot adapter from the same verified handles. Roll back by reverting this PR only; immutable artifacts, collectors, deployment, live execution, and production ECS are unchanged, and live execution remains disabled.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a verified-artifact audit builder for Binance and Polymarket evidence, exposes its API, validates coverage and event completeness, incorporates related sources into policy identity hashing, updates mission snapshot pins, and records the migration task.

Changes

Verified artifact audit

Layer / File(s) Summary
Audit validation and coverage observations
rust_hft/prediction-markets/crates/ploy-research/src/verified_artifact_audit.rs
Validates BTCUSDT/SOLUSDT requests and aligned windows, checks artifact coverage, and computes Binance, Chainlink, Polymarket book, and settlement observations.
Audit gating tests
rust_hft/prediction-markets/crates/ploy-research/src/verified_artifact_audit.rs
Tests request alignment, per-event Chainlink reference requirements, and per-token Polymarket orderbook lifetime coverage.
Public API and policy identity wiring
rust_hft/prediction-markets/crates/ploy-research/src/lib.rs, rust_hft/prediction-markets/crates/ploy-research/src/prediction_loop.rs
Exports the audit builder and request type, expands policy identity sources, and updates identity assertions.
Mission snapshot pins and migration tracking
rust_hft/prediction-markets/config/research_missions/*.example.json, rust_hft/prediction-markets/tasks/todo.md
Updates BTC and SOL search policy snapshot identifiers and adds the verified-artifact audit migration task.

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

Sequence Diagram(s)

sequenceDiagram
  participant BinanceTape
  participant PolymarketEvidence
  participant AuditBuilder
  participant AuditReport
  BinanceTape->>AuditBuilder: provide verified market evidence
  PolymarketEvidence->>AuditBuilder: provide contracts, references, books, and settlements
  AuditBuilder->>AuditBuilder: validate windows and compute audit observations
  AuditBuilder->>AuditReport: return PredictionMarketDataAuditReport
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 17.39% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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 is concise and clearly describes the main change: auditing verified prediction artifacts.
Description check ✅ Passed The description covers the required contract, out-of-scope, dependencies, validation, and rollout sections, with only Scope exception omitted.
✨ 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-verified-artifact-audit

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: 654d751834

ℹ️ 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".

@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.

Actionable comments posted: 4

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

Inline comments:
In
`@rust_hft/prediction-markets/crates/ploy-research/src/verified_artifact_audit.rs`:
- Around line 319-353: Update the reference validation loop around event_index
and present so each Chainlink reference is accepted only when its source_time
falls within the matching contract event’s governed reference window, rejecting
stale and post-event evidence before present.insert. Add counterexamples
covering both out-of-window cases and verify they do not mark the event bucket
as covered.
- Around line 501-516: Update the settlement validation predicate around
winner_matches so it requires the declared winner’s price to be Decimal::ONE and
the opposing token’s price to be Decimal::ZERO, while preserving token-ID
matching and the existing resolved/sum checks. Use the winning_side distinction
to validate the corresponding up or down price rather than accepting either
resolved assignment.
- Around line 416-448: Update the order-book loop around the visible book
filtering to validate book.available_at against book.source_time before payload
and bucket accounting: track and reject causality violations where available_at
precedes source_time, and track and reject books whose source delay exceeds the
configured source-delay gate. Ensure these rejections occur before row_count,
invalid-payload, usable-row, coverage, and bucket updates, using the existing
audit counters and delay configuration symbols.

In `@rust_hft/prediction-markets/tasks/todo.md`:
- Line 41: Update the migration checklist entry for building the prediction data
audit from externally verified artifacts to reflect the implemented audit
builder: mark the task complete, or rewrite it to specify only the remaining
deferred integration work.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e520f964-aa93-4f10-b4b7-ae2d06c018fd

📥 Commits

Reviewing files that changed from the base of the PR and between f5dc517 and 38478ca.

📒 Files selected for processing (6)
  • 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-research/src/lib.rs
  • rust_hft/prediction-markets/crates/ploy-research/src/prediction_loop.rs
  • rust_hft/prediction-markets/crates/ploy-research/src/verified_artifact_audit.rs
  • rust_hft/prediction-markets/tasks/todo.md

Comment thread rust_hft/prediction-markets/crates/ploy-research/src/verified_artifact_audit.rs Outdated
Comment thread rust_hft/prediction-markets/tasks/todo.md Outdated
@proerror77
proerror77 merged commit ac5a540 into main Jul 18, 2026
26 checks passed
@proerror77
proerror77 deleted the codex/polymarket-verified-artifact-audit branch July 19, 2026 04:27
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