Skip to content

fix(quant): harden forward shadow ledger, execution rules, portfolio accounting & allocator (Rounds 2-6) - #28

Merged
ZhuLinsen merged 1 commit into
mainfrom
fix/quant-execution-shadow-portfolio-and-allocator-rigor
Nov 22, 2026
Merged

ZhuLinsen merged 1 commit into
mainfrom
fix/quant-execution-shadow-portfolio-and-allocator-rigor

Conversation

@ZhuLinsen

Copy link
Copy Markdown
Owner

What

Rounds 2-6 of the AlphaEvo hardening & RSI audit program:

  • Round 2 (ShadowLedger replay & hash isolation): Bound commits and outcomes to strategy_hash + market + market_rules, preserved backward-compatible SHA-256 verification for pre-upgrade commits, strictly excluded is_replay outcomes from live promotion gates and CANARY/ACTIVE halt checks, prevented uncommitted orphan outcomes from qualifying when commit history exists, and enforced maturity-date stage_entered_as_of for CANARY dwell.
  • Round 3 (ShadowLedger concurrency, immutability, T+1/stops & benchmark alignment): Added re-entrant process+thread locking (RLock + fcntl.flock) across commits/verification/backfill/promotion, atomic mkstemp+fsync+os.replace writes, monotonic disk persistence with horizon_end_date cutoff views, MarketRuleChecker buy/stop/exit checks (including T+1 & gap-down open stop fills), wall-clock live commit causality (committed_at.date() + 1d), equal-weight CLI market proxy with open intraday return preservation + observed_count/return_count guards, covered-only excess averages, and late-arriving benchmark enrichment.
  • Round 4 (MarketRuleChecker & BacktestEngine): Added prior close fallback when prev_close is missing, 301/689 (20%) & 920 (30%) A-share boards, open-price limit checks for next_open/breakout_high, sellable same-day TP fallback when intraday stop hits limit-down, and preserved unclosed terminal TradeSignals (exit_price=None) when T+1/limit-down/suspension blocks force-close.
  • Round 5 (PortfolioBacktester): Enforced strict start-of-day causal ordering (open entries before closing same-day exits or MTM), equal slice sizing without geometric decay, true equity utilization metric, Day-1 drawdown anchored to initial_capital, and MTM valuation of unclosed terminal holdings when market_data is present.
  • Round 6 (RegimeAdaptiveAllocator): Zeroed inactive 0-signal strategies once active strategies exist, conserved budget cleanly in _apply_weight_cap, guarded _build_causal_market_proxy against NaT & multi-day suspension gaps, and unified per-position MTM across closed and open holdings.

Why

Addresses P0/P1 audit findings across forward shadow promotion integrity, historical execution lookahead, portfolio L0 gate accounting, and causal multi-strategy risk budgeting without modifying the frozen L0 Truth Kernel (src/alphaevo/truth/, src/alphaevo/evaluator/metrics.py).

Verification

  • ruff format --check src/ tests/unit/test_round2_to_6_quant_shadow_portfolio_rigor.py -> clean
  • ruff check -> All checks passed
  • mypy src/ -> 0 errors across 135 source files
  • pytest -q -> 1091 passed (including 7 comprehensive regression tests in tests/unit/test_round2_to_6_quant_shadow_portfolio_rigor.py)
  • git diff --name-only main -- src/alphaevo/truth/ src/alphaevo/evaluator/metrics.py -> empty (L0 untouched)
  • Three rounds of adversarial OpenAI Codex (gpt-6.2-sol) --sandbox read-only cross-model audits completed and all concrete P1/P2 findings resolved.

Risks

  • Legacy ledgers with completely missing commits.jsonl preserve backwards compatibility for unit tests directly injecting outcomes.jsonl; production ledgers always write commits.jsonl.
  • Wait for GitHub Actions CI checks before merging.

Research & educational software only. Not investment advice.

@ZhuLinsen
ZhuLinsen merged commit 2e8b55e into main Nov 22, 2026
7 checks passed
@ZhuLinsen
ZhuLinsen deleted the fix/quant-execution-shadow-portfolio-and-allocator-rigor branch November 22, 2026 06:23
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