Skip to content

feat(research): verify signed arrival-cost evidence - #788

Merged
proerror77 merged 57 commits into
mainfrom
codex/runtime-latency-evidence
Aug 10, 2026
Merged

feat(research): verify signed arrival-cost evidence#788
proerror77 merged 57 commits into
mainfrom
codex/runtime-latency-evidence

Conversation

@proerror77

@proerror77 proerror77 commented Aug 9, 2026

Copy link
Copy Markdown
Owner

Change contract

Verify immutable signed LiveSmall lifecycle evidence, select PIT-available market/account/symbol fills, and calculate real arrival-price latency-cost percentiles without duplicate reweighting.

Issue relationship

Closes #796

Out of scope

Runtime instrumentation, derivatives execution, fee-account mapping, materialization, deployment activation, and order placement.

Dependencies and merge order

PR #787 / issue #795 merged into main as 0bd446d.

Focused validation

  • Signed-event verification covers LiveSmall admission, Shadow rejection, account/symbol/Spot venue/PIT binding, canonical duplicate suppression, conflicting duplicates, and overflow.
  • Mixed logs skip fills without an arrival benchmark.
  • USD-M fails closed until a reachable real derivatives execution path exists.
  • Linux test binaries compile; native macOS execution remains blocked by the existing libc::RUSAGE_THREAD path.

Rollout and rollback

Research verifier only; no runtime mutation. Revert the squash commit to remove admission of lifecycle evidence.

Scope exception

None.

Summary by CodeRabbit

  • New Features
    • Added verification for signed runtime latency evidence.
    • Validates event authenticity, timing, health, market conditions, and data consistency.
    • Filters invalid, duplicate, conflicting, shadow, and unsupported currency events.
    • Reports latency and slippage percentiles from verified observations.
    • Enforces evidence size limits and required data integrity checks.

Sonic Shih and others added 30 commits August 10, 2026 02:31
…ntract-v2

# Conflicts:
#	agent-worktree.yml
…to codex/runtime-latency-evidence

# Conflicts:
#	agent-worktree.yml
…eatures

# Conflicts:
#	agent-worktree.yml
#	rust_hft/research-core/manifest/src/lib.rs
…to codex/runtime-latency-evidence

# Conflicts:
#	agent-worktree.yml
…-evidence

# Conflicts:
#	agent-worktree.yml
…ation' into codex/runtime-latency-evidence

# Conflicts:
#	agent-worktree.yml
#	rust_hft/market-core/engine/src/execution_worker.rs
#	rust_hft/market-core/ports/src/events.rs
* feat(research): define CEX replay snapshot V2

* fix(research): bind V2 snapshot evidence timelines

* fix(research): keep V1 writer until consumers migrate

* fix(research): harden V2 PIT evidence bounds

* fix(research): bind complete PIT evidence sets

* fix(research): close V2 evidence coverage gaps

* fix(research): bind fee evidence to account

* feat(research): materialize aggregate trade flow

* feat(research): verify real lifecycle latency evidence

* fix(research): bind V2 series identity

* chore: refresh trade feature stack base

* chore: refresh trade feature stack base

* fix(research): bind latency evidence to fee account

* refactor(research): pass prebuilt source lineage

* chore: refresh latency evidence stack base

* test(research): keep aggregate trade ids contiguous

* chore: refresh latency evidence stack base

* fix(research): bind real arrival latency evidence

* fix(research): authenticate runtime instrument market

---------

Co-authored-by: Sonic Shih <sonic.shih@mandonothing.com>
Sonic Shih added 2 commits August 10, 2026 06:45
…-instrumentation

# Conflicts:
#	agent-worktree.yml
…ation' into codex/runtime-latency-evidence

# Conflicts:
#	agent-worktree.yml
@proerror77

Copy link
Copy Markdown
Owner Author

@codex review exact head d2c48ca after integrating final #787: verify bounded streaming signed Fill evidence, market/account selection, duplicate rejection, and realized arrival-slippage percentiles.

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

ℹ️ 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 thread rust_hft/alpha-harness/domain/src/runtime_latency_evidence.rs
@proerror77

Copy link
Copy Markdown
Owner Author

@codex review exact head 661093c against current base afc533b. The verifier streams digest-anchored signed LiveSmall fill evidence, binds Spot venue/account/symbol/PIT times, deduplicates selected events, rejects overflow, and now explicitly rejects USD-M until a real derivatives execution path exists.

@proerror77

Copy link
Copy Markdown
Owner Author

@codex review exact head 07fda95 against base 2135b0e. The verifier is unchanged except for the explicit fail-closed USD-M boundary; current arrival-quote provenance is integrated.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 07fda954e6

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

Base automatically changed from codex/runtime-arrival-instrumentation to main August 9, 2026 23:36
…-evidence

# Conflicts:
#	agent-worktree.yml
@proerror77

Copy link
Copy Markdown
Owner Author

@codex review exact head 1998f8f after integrating merged arrival-evidence main. Verify signed-event trust, PIT/account/venue binding, duplicate handling, overflow, and explicit USD-M fail-closed behavior.

@proerror77
proerror77 enabled auto-merge (squash) August 9, 2026 23:38

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

🤖 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/tools/collector/src/runtime_latency_evidence.rs`:
- Around line 107-156: Move the event ID digest insertion and conflict
comparison to immediately after verify_runtime_attribution_event succeeds,
before the mode, identity, timing, and slippage selection filters. Continue only
with selected records when populating signed_events and observations, and add a
fixture containing conflicting records where one is filtered out to verify
rejection.
- Around line 35-212: Move verify_runtime_latency_evidence,
VerifiedRuntimeLatencyEvidence, and the percentile calculation from the
collector into rust_hft/alpha-harness, preserving their existing verification
and percentile behavior. Keep collector responsibilities limited to acquiring or
supplying the runtime evidence, then update module exports, dependencies, and
call sites to use the alpha-harness verifier.
- Around line 214-220: Update read_sha256_anchored to avoid unbounded
std::fs::read: open the file, read incrementally into a buffer capped at the
trusted-key size limit, and update the SHA-256 digest as chunks arrive. Reject
inputs exceeding the limit, verify the finalized digest against expected, then
parse or return only the bounded buffer.
🪄 Autofix

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 Plus

Run ID: 710252e4-85e4-4176-9a33-f393c9b9cd36

📥 Commits

Reviewing files that changed from the base of the PR and between 0bd446d and 1998f8f.

⛔ Files ignored due to path filters (1)
  • rust_hft/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • agent-worktree.yml
  • rust_hft/tools/collector/Cargo.toml
  • rust_hft/tools/collector/src/lib.rs
  • rust_hft/tools/collector/src/runtime_latency_evidence.rs

Comment thread rust_hft/alpha-harness/domain/src/runtime_latency_evidence.rs
Comment thread rust_hft/tools/collector/src/runtime_latency_evidence.rs Outdated
Comment thread rust_hft/alpha-harness/domain/src/runtime_latency_evidence.rs
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 1998f8f257

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

@proerror77

Copy link
Copy Markdown
Owner Author

@codex review exact head ae46546. The verifier now lives in alpha-harness/domain, rejects conflicting IDs before any selection filter, bounds and incrementally hashes trusted-key input, and passes 7 focused domain tests.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: ae4654665c

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

@proerror77

Copy link
Copy Markdown
Owner Author

@codex review exact head after the trust-source binding. Focused tests 7/7 and alpha-domain strict Clippy both pass.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 5d1bcb2ed8

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

@proerror77
proerror77 merged commit bd402f4 into main Aug 10, 2026
50 checks passed
@proerror77
proerror77 deleted the codex/runtime-latency-evidence branch August 10, 2026 00:21
proerror77 pushed a commit that referenced this pull request Aug 10, 2026
Materialize verified Binance Spot/USD-M market tapes into the V3 outer
materialization carrying CexReplaySnapshotV2: PIT instrument rules,
account-bound maker/taker fees, independent funding and OI timelines,
aggregate-trade flow, and signed runtime lifecycle latency evidence.

Rebased onto origin/main be9e746, which already contains the signed
arrival-cost evidence (#787), its verification (#788), fee-account
binding (#789), and fee snapshot timers (#793). Refs #794.
proerror77 added a commit that referenced this pull request Aug 10, 2026
* feat(research): publish verified CEX ResearchSnapshot V2

Materialize verified Binance Spot/USD-M market tapes into the V3 outer
materialization carrying CexReplaySnapshotV2: PIT instrument rules,
account-bound maker/taker fees, independent funding and OI timelines,
aggregate-trade flow, and signed runtime lifecycle latency evidence.

Rebased onto origin/main be9e746, which already contains the signed
arrival-cost evidence (#787), its verification (#788), fee-account
binding (#789), and fee snapshot timers (#793). Refs #794.

* fix(research): close lob-pit-materializer review threads

- Delegate runtime latency verification to the hardened
  alpha_domain::runtime_latency_evidence verifier instead of a drifted
  collector-local copy: event IDs are deduplicated before filtering
  (conflicting duplicates fail closed), every fill must carry an
  authenticated instrument_market_{market} identity, and USD-M fails
  closed until a derivatives execution path exists.
- Republish verified fee and reference evidence triplets into the
  materialization artifact directory under content-addressed names so
  the digests recorded in the snapshot resolve to immutable bytes.
- Restructure the test fixture per market: the happy path is Spot
  (signed LiveSmall latency evidence exists only for Spot), a new test
  proves USD-M materialization fails closed, and the aggregate-trade
  assertions now match the (previous, current] bucket semantics.

* fix(research): anchor latency cohort and holding-interval funding

- Publish the complete digest-anchored runtime feedback log and the
  trusted-key document into the artifact directory under their content
  digests, so independent readers can reverify every signed lifecycle
  event and no resolvable-evidence gap remains for the key document.
- Charge USD-M funding settlements over each row's actual
  (current, future] holding interval, matching how the evaluator
  applies funding_bps to the held position; a settlement that precedes
  the holding interval is no longer charged and multi-bucket horizons
  collect every settlement.

---------

Co-authored-by: Sonic Shih <sonic.shih@mandonothing.com>
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 signed runtime latency-cost evidence

1 participant