Skip to content

feat(alpha): harden factor evaluation evidence - #12

Merged
proerror77 merged 5 commits into
mainfrom
codex/factor-evaluation-v3
Jul 14, 2026
Merged

proerror77 merged 5 commits into
mainfrom
codex/factor-evaluation-v3

Conversation

@proerror77

@proerror77 proerror77 commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • separate label-free proposal context from evaluator-only labels
  • persist and gate IC, RankIC, ICIR, RankICIR, positive-IC ratio, and non-annualized net Sharpe
  • require predictive gates before position mapping and keep IC scale-invariant for small finite factors
  • bind sealed evaluation and promotion to canonical versioned walk-forward evidence

Validation

  • targeted rustfmt check: passed
  • git diff --check: passed
  • pre-handoff Alpha package tests and strict Clippy passed at the feature commit
  • final rebased changes intentionally not compiled locally; full GitHub CI is the authoritative validation surface

Safety

  • no live-trading activation changes
  • holdout and promotion remain fail-closed

Summary by CodeRabbit

  • New Features
    • Enabled Formula v3 evaluation with predictive-quality gates (time-series IC/RankIC, ICIR variants, and positive-IC ratio) computed before position mapping.
    • Added post-cost performance diagnostics including per-observation net Sharpe and transaction-cost-aware trade mapping.
    • Strengthened promotion and advancement to require canonical v3 walk-forward and sealed-holdout evidence, with stricter evidence/version binding.
  • Documentation
    • Updated architecture and research-integrity guidance to reflect Formula v3 workflows, gate ordering, and retained metrics/evidence rules.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@proerror77, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 51 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

Run ID: 43a72661-c677-4d35-99ee-8ac6ea1aee25

📥 Commits

Reviewing files that changed from the base of the PR and between 9e573d9 and ba4e726.

📒 Files selected for processing (1)
  • rust_hft/alpha-harness/store/src/lib.rs
📝 Walkthrough

Walkthrough

Formula evaluation now uses separate proposal and evaluation contexts, predictive metrics and gates, post-cost trading checks, and versioned Formula v3 evidence. Governance and storage require canonical walk-forward and sealed-holdout evidence before promotion.

Changes

Formula v3 evaluation hardening

Layer / File(s) Summary
Separate proposal and evaluation contexts
rust_hft/alpha-harness/engine/src/evaluation.rs, rust_hft/alpha-harness/engine/src/lib.rs, rust_hft/alpha-harness/engine/src/engines/*, rust_hft/alpha-harness/engine/src/llm.rs
Proposal engines receive label-free ProposalContext metadata, while evaluation uses its dedicated context.
Predictive evidence and metric contracts
rust_hft/alpha-harness/domain/src/lib.rs, rust_hft/alpha-harness/engine/src/lib.rs
Evaluator versions, predictive-quality thresholds, fold predictive metrics, aggregate predictive metrics, and net Sharpe validation are added.
Predictive-first evaluation pipeline
rust_hft/alpha-harness/engine/src/formula_evaluator.rs, rust_hft/alpha-harness/onnx-evaluator/src/lib.rs, docs/..., rust_hft/ARCHITECTURE.md
Predictive IC and RankIC gates run before position mapping; mapped returns then supply trading, drawdown, Sharpe, and adjusted-score checks.
Version-bound promotion evidence
rust_hft/alpha-harness/app/src/governance.rs, rust_hft/alpha-harness/store/src/lib.rs, rust_hft/alpha-harness/app/src/loop_control.rs, rust_hft/apps/live/tests/*
Governance and storage bind sealed-evaluation revisions to evaluator versions and require canonical walk-forward evidence for promotion and progression.

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

Sequence Diagram(s)

sequenceDiagram
  participant ProposalEngine
  participant FormulaEvaluator
  participant AlphaStore
  participant Governance
  ProposalEngine->>FormulaEvaluator: submit candidate with proposal metadata
  FormulaEvaluator->>AlphaStore: persist predictive and trading evidence
  AlphaStore->>Governance: provide canonical walk-forward and sealed evidence
  Governance->>Governance: validate evaluator version and holdout status
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 29.82% 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: hardening factor evaluation evidence in the alpha package.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/factor-evaluation-v3

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: 00b42e0153

ℹ️ 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/engine/src/formula_evaluator.rs Outdated
Comment thread rust_hft/alpha-harness/app/src/governance.rs
Comment thread rust_hft/alpha-harness/domain/src/lib.rs
Comment thread rust_hft/alpha-harness/domain/src/lib.rs

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
rust_hft/alpha-harness/app/src/governance.rs (1)

71-116: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Allow OnnxModel candidates through the walk-forward gate

validated_walk_forward_candidates_in_lineage rejects every non-Formula artifact before the later match that accepts CandidateArtifact::OnnxModel(_), so the ONNX branch is unreachable and ONNX candidates can never pass this check.

Proposed fix
-        if !matches!(candidate.artifact, CandidateArtifact::Formula(_)) {
+        if !matches!(
+            candidate.artifact,
+            CandidateArtifact::Formula(_) | CandidateArtifact::OnnxModel(_)
+        ) {
             continue;
         }
🤖 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/alpha-harness/app/src/governance.rs` around lines 71 - 116, The
walk-forward candidate filter in validated_walk_forward_candidates_in_lineage
rejects OnnxModel artifacts before the evaluator-version match; remove or
broaden the earlier Formula-only check so both Formula and OnnxModel candidates
reach the existing artifact/version validation, preserving the matching
evaluator-version requirements.
🤖 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/alpha-harness/engine/src/formula_evaluator.rs`:
- Around line 73-130: Update predictive_gates to accept evaluator_version and
gate ICIR/RankICIR based on the same matches! evaluator-version check used by
CandidateEvaluation::validate(), not ranges.len(). Ensure single-fold
walk-forward evaluations still compute and record both ICIR failures so
validation returns a normal failed evaluation rather than
InvalidEvaluationEvidence.

In `@rust_hft/alpha-harness/store/src/lib.rs`:
- Around line 822-860: Update has_canonical_walk_forward_evidence so
deserialization failures from serde_json::from_value and validation failures
from evaluation.validate are converted to Ok(false), matching the function’s
graceful “not canonical evidence” behavior. Preserve propagation for unrelated
storage errors and continue allowing callers such as
sealed_passed_candidate_for_mission to inspect other candidates.

---

Outside diff comments:
In `@rust_hft/alpha-harness/app/src/governance.rs`:
- Around line 71-116: The walk-forward candidate filter in
validated_walk_forward_candidates_in_lineage rejects OnnxModel artifacts before
the evaluator-version match; remove or broaden the earlier Formula-only check so
both Formula and OnnxModel candidates reach the existing artifact/version
validation, preserving the matching evaluator-version requirements.
🪄 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: a10795c6-f5bd-4a57-9f14-afcb51327334

📥 Commits

Reviewing files that changed from the base of the PR and between c325546 and 00b42e0.

📒 Files selected for processing (18)
  • docs/superpowers/specs/2026-07-11-loop-engineer-production-hardening-design.md
  • rust_hft/ARCHITECTURE.md
  • rust_hft/alpha-harness/README.md
  • rust_hft/alpha-harness/app/src/governance.rs
  • rust_hft/alpha-harness/app/src/loop_control.rs
  • rust_hft/alpha-harness/domain/src/lib.rs
  • rust_hft/alpha-harness/engine/src/engines/bayesian.rs
  • rust_hft/alpha-harness/engine/src/engines/gp.rs
  • rust_hft/alpha-harness/engine/src/engines/mcts.rs
  • rust_hft/alpha-harness/engine/src/engines/offline_rl.rs
  • rust_hft/alpha-harness/engine/src/evaluation.rs
  • rust_hft/alpha-harness/engine/src/formula_evaluator.rs
  • rust_hft/alpha-harness/engine/src/lib.rs
  • rust_hft/alpha-harness/engine/src/llm.rs
  • rust_hft/alpha-harness/onnx-evaluator/src/lib.rs
  • rust_hft/alpha-harness/store/src/lib.rs
  • rust_hft/apps/live/tests/deployment_artifacts.rs
  • rust_hft/apps/live/tests/deployment_envelope.rs

Comment thread rust_hft/alpha-harness/engine/src/formula_evaluator.rs
Comment thread rust_hft/alpha-harness/store/src/lib.rs
@proerror77

Copy link
Copy Markdown
Owner Author

@codex review

@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

if sealed.registry_kind != "sealed_evaluation"
|| sealed.asset_id != bundle.candidate_id
|| stored_mission_id != Some(promotion.mission_id.as_str())
|| stored_candidate_hash != Some(bundle.candidate_content_hash.as_str())
|| stored_dataset != Some(bundle.dataset_manifest_id.as_str())

P2 Badge Require canonical sealed revision IDs

When callers use AlphaStore::promote_candidate directly, a valid v3 sealed_evaluation stored under a legacy or arbitrary revision_id still passes this binding check because only the kind, asset id, and payload fields are compared. That bypasses the new version-bound sealed_evaluation_revision_id contract and can create promotions whose sealed_evaluation_id the governance CLI would never produce, so the store should reject ids other than sealed-evaluation:<evaluator_version>:<candidate_id>.

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

Fixed the latest sealed-revision finding in 9e573d9: direct promotion now requires sealed-evaluation:<evaluator_version>:<candidate_id>, the holdout-progression query enforces the same fail-closed contract, and the regression test verifies no partial promotion/bundle writes and no false HoldoutPassed.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 9e573d9cfd

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

Remote cargo fmt --check identified one layout-only diff; ba4e726 applies that exact rustfmt output. The canonical sealed-revision fix and regression coverage are unchanged.

@codex review

@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 (1)
rust_hft/alpha-harness/engine/src/lib.rs (1)

559-560: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low value

Avoid cloning the JSON payload.

serde_json::from_value requires taking ownership of the Value, which necessitates payload.clone(). Since &serde_json::Value implements Deserializer, you can deserialize directly from the reference without cloning the entire JSON DOM.

♻️ Proposed refactor
-    let evaluation: CandidateEvaluation =
-        serde_json::from_value(payload.clone()).map_err(|error| error.to_string())?;
+    use serde::Deserialize;
+    let evaluation = CandidateEvaluation::deserialize(payload)
+        .map_err(|error| error.to_string())?;
🤖 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/alpha-harness/engine/src/lib.rs` around lines 559 - 560, Update the
CandidateEvaluation deserialization in the surrounding evaluation flow to
deserialize directly from the borrowed payload reference instead of cloning the
serde_json::Value. Preserve the existing error-to-string mapping and propagation
behavior while removing the unnecessary payload.clone() allocation.
🤖 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/alpha-harness/engine/src/lib.rs`:
- Around line 559-560: Update the CandidateEvaluation deserialization in the
surrounding evaluation flow to deserialize directly from the borrowed payload
reference instead of cloning the serde_json::Value. Preserve the existing
error-to-string mapping and propagation behavior while removing the unnecessary
payload.clone() allocation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d53d6c49-4000-4242-9578-51cb698678bb

📥 Commits

Reviewing files that changed from the base of the PR and between 00b42e0 and 9e573d9.

📒 Files selected for processing (6)
  • docs/superpowers/specs/2026-07-11-loop-engineer-production-hardening-design.md
  • rust_hft/alpha-harness/app/src/governance.rs
  • rust_hft/alpha-harness/domain/src/lib.rs
  • rust_hft/alpha-harness/engine/src/formula_evaluator.rs
  • rust_hft/alpha-harness/engine/src/lib.rs
  • rust_hft/alpha-harness/store/src/lib.rs
🚧 Files skipped from review as they are similar to previous changes (4)
  • docs/superpowers/specs/2026-07-11-loop-engineer-production-hardening-design.md
  • rust_hft/alpha-harness/store/src/lib.rs
  • rust_hft/alpha-harness/domain/src/lib.rs
  • rust_hft/alpha-harness/engine/src/formula_evaluator.rs

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: ba4e7262d2

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

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