Skip to content

Persist governed GP screening into an immutable CEX Factor Bank - #646

Merged
proerror77 merged 2 commits into
mainfrom
codex/agent-cex-gp-factor-bank-mission-599
Aug 3, 2026
Merged

proerror77 merged 2 commits into
mainfrom
codex/agent-cex-gp-factor-bank-mission-599

Conversation

@proerror77

@proerror77 proerror77 commented Aug 3, 2026

Copy link
Copy Markdown
Owner

Change contract

Extend the sole acceptance seam alpha-harness mission execute to derive and enforce the frozen governed GP policy, run GP only against label-free research context, audit every candidate attempt, and persist one typed create-once cex-factor-bank-v2 registry revision with evidence-bound orientation and structured rejection codes.

Issue relationship

Closes #599

Out of scope

MCTS subset search or formula generation; Ridge/CART baselines; continuous tuning; sealed-holdout opening; Paper, Shadow, LiveSmall, deployment, runtime activation, new databases or services, prediction-market evaluation, RL, or multi-agent runtime behavior.

Dependencies and merge order

Core PR #645, Determinism PR #647, Evidence PR #648, and canonical-hash PR #649 are merged. This PR is rebuilt directly on main@99589288cb3b79fd63891c4c99d3e52b87b95ad5 and is the final code contract for Issue #599.

Focused validation

  • execute_screens_gp_candidates_into_an_immutable_factor_bank — proves GP-only execution, Factor Bank v2 publication, immutable registry conflict rejection, and no MCTS receipt.
  • execute_records_duplicate_gp_attempts_with_a_typed_rejection — proves structured evaluated/duplicate rejection codes and that rejected candidates cannot enter entries.
  • execute_is_deterministic_and_ignores_holdout_only_values — proves chunked/resumed and uninterrupted execution produce identical Factor Bank semantic content, including after a holdout-only mutation.
  • execute_rejects_gp_policy_drift_before_screening — proves frozen-policy drift fails before persistence.
  • cargo +1.91 test -p alpha-domain -p alpha-engine -p alpha-harness --locked — 49 domain, 81 engine, and 129 harness tests passed; one credential-dependent LLM test ignored as designed.
  • Scoped Clippy with -D warnings, exact-package Rustfmt, git diff --check, and agent-worktree preflight — passed.
  • Final Standards and Issue Run controlled GP screening into an immutable CEX Factor Bank #599 Spec reviews found no hard or blocking findings.

Rollout and rollback

Research-only mission behavior; sealed holdout remains closed and no runtime authority is added. Roll back by reverting this PR; the already-merged domain/hash prerequisites remain inert without this producer path.

Scope exception

None. This layer changes 3 files with 560 insertions and remains below the repository split threshold.

Summary by CodeRabbit

  • New Features

    • Added governed genetic-programming mission runs with policy validation, resumable progress, and deterministic execution.
    • Mission reports now include verifiable references to research datasets and walk-forward partitions.
    • Added immutable factor-bank records containing candidate results, screening decisions, and evaluation evidence.
  • Improvements

    • Factor screening now reports specific rejection reasons across coverage, predictive performance, trading, capacity, and multiple-testing checks.
    • Added support for negative factor orientation and stronger validation against inconsistent or duplicate factor records.

@coderabbitai

coderabbitai Bot commented Aug 3, 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: 44 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: 5cf92787-acc8-4783-9ead-f4c3492d9139

📥 Commits

Reviewing files that changed from the base of the PR and between 6cf7ca6 and 181b17a.

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

Walkthrough

Changes

Governed GP mission and factor-bank construction

Layer / File(s) Summary
Factor evidence and rejection contracts
rust_hft/alpha-harness/domain/src/lib.rs
Evaluation evidence now derives typed rejection codes and positive or negative orientation. Factor-bank validation binds these values to evidence and rejects tampering.
Mission policy and research references
rust_hft/alpha-harness/app/src/mission.rs
Mission reports include hashed dataset and walk-forward references. Governed execution validates policy fields, seed, and budget before engine construction.
Governed GP execution and factor-bank persistence
rust_hft/alpha-harness/app/src/mission_runner.rs
The runner validates policy hashes, executes resumable GP missions, and registers immutable factor-bank revisions with candidate, screening, rejection, and evaluation data.
Execution validation and deterministic fixtures
rust_hft/alpha-harness/app/src/mission_runner.rs
Tests cover policy drift, duplicate attempts, factor-bank persistence, determinism, holdout isolation, and updated policy fixtures.

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

Possibly related issues

  • proerror77/monday#599 — Covers controlled GP screening and immutable Factor Bank persistence implemented by this PR.

Possibly related PRs

  • proerror77/monday#645 — Provides the governed GP policy, screening, factor-bank, and GeneticProgrammingEngine::new_governed functionality used here.
  • proerror77/monday#12 — Also hardens factor-evaluation evidence, rejection validation, and factor acceptance semantics.
  • proerror77/monday#46 — Also updates mission execution and evidence validation with canonical, hash-bound policy constraints.
🚥 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 clearly and concisely identifies persisting governed GP screening results in an immutable CEX Factor Bank.
Description check ✅ Passed The description covers every required template section with specific behavior, scope, dependencies, validation, rollout, and rollback 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/agent-cex-gp-factor-bank-mission-599

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: 9941631b5c

ℹ️ 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/app/src/mission_runner.rs
Comment thread rust_hft/alpha-harness/app/src/mission.rs Outdated
Comment thread rust_hft/alpha-harness/app/src/mission_runner.rs
@proerror77
proerror77 force-pushed the codex/agent-cex-gp-factor-bank-mission-599 branch from 9941631 to 079a1b8 Compare August 3, 2026 06:41
@proerror77
proerror77 changed the base branch from codex/agent-cex-gp-factor-bank-core-599 to codex/agent-cex-factor-bank-validation-599 August 3, 2026 06:41
@proerror77
proerror77 force-pushed the codex/agent-cex-factor-bank-validation-599 branch from 56dafbe to cb4db0a Compare August 3, 2026 07:03
@proerror77
proerror77 force-pushed the codex/agent-cex-gp-factor-bank-mission-599 branch from 079a1b8 to e95ff28 Compare August 3, 2026 07:04
@proerror77
proerror77 force-pushed the codex/agent-cex-factor-bank-validation-599 branch 2 times, most recently from 8a4c78c to 3f0d08e Compare August 3, 2026 07:35
Base automatically changed from codex/agent-cex-factor-bank-validation-599 to main August 3, 2026 07:47
@proerror77
proerror77 force-pushed the codex/agent-cex-gp-factor-bank-mission-599 branch from e95ff28 to 6cf7ca6 Compare August 3, 2026 08:13

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

🧹 Nitpick comments (3)
rust_hft/alpha-harness/domain/src/lib.rs (1)

1940-1959: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

ScreeningFailed is now unreachable for new revisions.

rejected_codes_are_bound accepts only derived gate codes when evidence exists, and only DuplicateCandidate, EvaluationFailed, or EngineFailure when evidence is absent. No path can now produce CexFactorRejectionCodeV1::ScreeningFailed. The test at Line 4398 confirms it is rejected.

If the variant is kept only for reading legacy v1 payloads, add a short comment that states this. Otherwise remove it.

🤖 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/domain/src/lib.rs` around lines 1940 - 1959, Document
that CexFactorRejectionCodeV1::ScreeningFailed is retained solely for reading
legacy v1 payloads, since rejected_codes_are_bound no longer accepts it for new
revisions. Add the comment next to the variant or its relevant compatibility
handling; if legacy deserialization is not required, remove the unused variant
instead.
rust_hft/alpha-harness/app/src/mission_runner.rs (2)

291-295: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Move the screening-policy check before the first store write.

The GP policy check at Line 167 runs before AlphaStore::open, so a drifted GP policy leaves no database. The screening-policy check runs after store.put_registry_revision for the mission and after the feature and dataset registration. A drifted screening policy therefore aborts the run with a partially populated alpha.duckdb and results directory.

The inputs to FormulaEvaluatorConfig::for_mission that matter here are search_budget.max_candidates and validator_spec, both taken from control_mission. Compute the same hash next to the GP policy check with FormulaEvaluatorConfig::for_trials(control_mission.spec.search.budget.max_candidates) and fail there.

♻️ Proposed fail-fast ordering
     gp_policy.validate_binding(&control_mission.spec.policies.gp)?;
+    if canonical_json_hash(&FormulaEvaluatorConfig::for_trials(
+        control_mission.spec.search.budget.max_candidates,
+    )?)? != control_mission.spec.policies.screening.content_sha256
+    {
+        bail!("Mission screening policy does not match the evaluator configuration");
+    }
     data_mission::write_json_atomic(&results_dir.join("gp-policy.json"), &gp_policy)?;

Then remove the later check at Lines 291-295.

🤖 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/mission_runner.rs` around lines 291 - 295,
Move the screening-policy validation from the post-registration section into the
pre-store validation block near the existing GP policy check in the mission
runner. Compute the expected hash using
FormulaEvaluatorConfig::for_trials(control_mission.spec.search.budget.max_candidates),
compare it with control_mission.spec.policies.screening.content_sha256, and fail
before AlphaStore::open or any writes; then remove the later
FormulaEvaluatorConfig::for_mission check.

474-484: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

Restrict the failure_explanation fallback to rejected attempts.

The fallback applies to every verdict. If a kept iteration carries a failure_explanation, rejection_details becomes non-empty. CexFactorBankRevisionV2::validate requires rejection_details.is_empty() for an accepted attempt, so the run then fails at bank construction.

Gate the fallback on the verdict.

♻️ Proposed guard
             .filter(|reasons| !reasons.is_empty())
             .or_else(|| {
+                if verdict == CexFactorScreeningVerdictV1::Accepted {
+                    return None;
+                }
                 iteration
                     .failure_explanation
                     .clone()
                     .map(|reason| vec![reason])
             })
🤖 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/mission_runner.rs` around lines 474 - 484,
Update the rejection_details construction to use iteration.failure_explanation
only when the verdict indicates a rejected attempt; accepted or kept iterations
must retain an empty fallback so CexFactorBankRevisionV2::validate can succeed.
Preserve the existing evaluation evidence handling and default-empty behavior.
🤖 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/app/src/mission_runner.rs`:
- Around line 1258-1262: Update the factor-bank assertion near the orientation
check to first require that the entries array contains at least one element,
then retain the existing assertion that every entry has positive orientation.
Use the parsed entries collection so both assertions validate the
accepted-candidate path.

---

Nitpick comments:
In `@rust_hft/alpha-harness/app/src/mission_runner.rs`:
- Around line 291-295: Move the screening-policy validation from the
post-registration section into the pre-store validation block near the existing
GP policy check in the mission runner. Compute the expected hash using
FormulaEvaluatorConfig::for_trials(control_mission.spec.search.budget.max_candidates),
compare it with control_mission.spec.policies.screening.content_sha256, and fail
before AlphaStore::open or any writes; then remove the later
FormulaEvaluatorConfig::for_mission check.
- Around line 474-484: Update the rejection_details construction to use
iteration.failure_explanation only when the verdict indicates a rejected
attempt; accepted or kept iterations must retain an empty fallback so
CexFactorBankRevisionV2::validate can succeed. Preserve the existing evaluation
evidence handling and default-empty behavior.

In `@rust_hft/alpha-harness/domain/src/lib.rs`:
- Around line 1940-1959: Document that CexFactorRejectionCodeV1::ScreeningFailed
is retained solely for reading legacy v1 payloads, since
rejected_codes_are_bound no longer accepts it for new revisions. Add the comment
next to the variant or its relevant compatibility handling; if legacy
deserialization is not required, remove the unused variant instead.
🪄 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 Plus

Run ID: 2595aef6-9420-41ca-800d-e042670e46f6

📥 Commits

Reviewing files that changed from the base of the PR and between 9958928 and 6cf7ca6.

📒 Files selected for processing (3)
  • rust_hft/alpha-harness/app/src/mission.rs
  • rust_hft/alpha-harness/app/src/mission_runner.rs
  • rust_hft/alpha-harness/domain/src/lib.rs

Comment thread rust_hft/alpha-harness/app/src/mission_runner.rs Outdated
The seed-7 fixture proposed an always-positive spread signal against
unrelated labels, so its orientation assertion passed vacuously with an
empty Factor Bank. Align the test-only imbalance signal and label so the
mission seam proves an accepted entry without weakening screening gates.

Refs #599
@proerror77
proerror77 merged commit a80e486 into main Aug 3, 2026
49 checks passed
@proerror77
proerror77 deleted the codex/agent-cex-gp-factor-bank-mission-599 branch August 3, 2026 08:36
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.

Run controlled GP screening into an immutable CEX Factor Bank

1 participant