T-68: Bug sweep (5 bugs: T-58, T-59, T-61, T-62, T-63)

This commit is contained in:
Studio 2026-11-27 20:14:25 -05:00
parent e440d8d5a0
commit 1692aba2fc
5 changed files with 800 additions and 30 deletions

View file

@ -270,7 +270,7 @@ Extends the existing 8-decimal Rust kernel (retiring legacy `f64` `BacktestEngin
### Validation suite, Trial Ledger & 6-Month Vault
- **Trial ledger (`trial_ledger` in PostgreSQL):** Groups trials deterministically by `(universe_market, horizon_bucket)` (`{US, CA, US_CA, FX} × {intraday, swing_1_10d, position_10d_plus}`) and stores each variant's out-of-warmup daily return/IC vector (`FLOAT4[]`) to compute Bailey & López de Prado **effective independent trials $\hat{N}$**, non-normal **Deflated Sharpe Ratio (DSR $\ge 0.95$)**, and **PBO ($\le 0.20$)** via CSCV ($S = 16$).
- **Trial ledger (`trial_ledger` in PostgreSQL):** Groups trials deterministically by `(universe_market, horizon_bucket)` (`{US_EQ, CA_EQ, US_CA_EQ, FX} × {intraday, swing_1_10d, position_10d_plus}`) and stores each variant's out-of-warmup daily return/IC vector (`FLOAT4[]`) to compute Bailey & López de Prado **effective independent trials $\hat{N}$**, non-normal **Deflated Sharpe Ratio (DSR $\ge 0.95$)**, and **PBO ($\le 0.20$)** via CSCV ($S = 16$).
- **Purged Walk-Forward & CPCV:** Replaces `labelHorizonMs = 0` with mandatory `purge = horizon + warmup` and `embargo = max(5d, 0.01 * T)`.
- **Post-2023 Recency Gate:** Post-2023 IC and Sharpe must be positive and $\ge 50\%$ of pre-2023 levels so decayed pre-LLM anomalies fail automatically.
- **Rolling 6-Month Air-Gapped Vault (`D10`):** Most recent 6 months (~126 trading days) fenced off from all research/MCP/marimo reads; evaluated **once** when **you** promote a `Validated` strategy toward `Paper` ($\le 10$ vault evaluations/year recorded in immutable `vault_evaluations`).

View file

@ -88,7 +88,7 @@ Computed on any synchronous screen/experiment return matrix $M \in \mathbb{R}^{T
### Vault Evaluations Schema (Append-Only)
Protected against `UPDATE`/`DELETE`/`TRUNCATE` by `reject_research_evidence_mutation()`. A `BEFORE INSERT` trigger requires `READ COMMITTED` transaction isolation (rejecting `REPEATABLE READ` and `SERIALIZABLE` so a waiting writer cannot evaluate the cap against a stale snapshot), forces `evaluated_at := now()` under a schema-scoped transaction advisory lock, and rejects inserts once 10 evaluations exist in the rolling 1-year window (`evaluated_at > now() - interval '1 year'`) on the target table (`TG_RELID`), paired with a statement-level `AFTER INSERT` check so multi-row inserts cannot bypass the cap:
Protected against `UPDATE`/`DELETE`/`TRUNCATE` by `reject_research_evidence_mutation()`. A `BEFORE INSERT` trigger requires `READ COMMITTED` or `READ UNCOMMITTED` transaction isolation (PostgreSQL treats `READ UNCOMMITTED` identically to `READ COMMITTED`, while rejecting `REPEATABLE READ` and `SERIALIZABLE` so a waiting writer cannot evaluate the cap against a stale snapshot), forces `evaluated_at := now()` under a schema-scoped transaction advisory lock, and rejects inserts once 10 evaluations exist in the rolling 1-year window (`evaluated_at > now() - interval '1 year'`) on the target table (`TG_RELID`), paired with a statement-level `AFTER INSERT` check so multi-row inserts cannot bypass the cap:
```sql
CREATE TABLE IF NOT EXISTS vault_evaluations (