malkhut(spec): items 5-10 — manifold, actuals, OOD, query, book fidelity

Item 5 — PerformanceMatrix manifold:
  RegimeStrategyScore: added confidence, support_count, distance_to_nearest
  record() populates confidence from episode count (more evidence = more confidence)

Item 6 — ActualsLoader:
  ActualsSnapshot: 12-field frozen dataclass for live market data
  ActualsLoader: reads CH tables (obf_universe, exf_data, maras_fingerprint, etc.)
  Synthetic fallback when CH unavailable

Item 7 — OOD verdict in RiskGate:
  validate() now accepts daat_verdict parameter
  OUT_OF_DISTRIBUTION → veto action, fall back to doctrinal simple policy
  Backward compatible: default daat_verdict='KNOWN'

Item 8 — Manifold query (three-phase recommendation):
  1. DAAT classify live state (KNOWN/MARGINAL/OOD)
  2. If KNOWN: find nearest regime in PerformanceMatrix → best strategy
  3. If OOD: return doctrinal_simple fallback
  ManifoldRecommendation: strategy_id, confidence, regime, verdict, reason

Item 10 — Book fidelity gap:
  BookFidelityConfig: n_levels, aggregation_window, min_depth
  synthesize_book_from_params: power-law D(d)=amplitude*d^(1-alpha) → OrderBookState
  Bridges OBF 15B rows → MALKHUT finite Tuple[PriceLevel]

5 files, 282 insertions.
This commit is contained in:
Codex
2026-07-14 06:11:37 +02:00
parent 1f41be845b
commit 7ad123c4c1
5 changed files with 282 additions and 1 deletions

View File

@@ -147,7 +147,13 @@ class RegimeClassifier:
@dataclass
class RegimeStrategyScore:
"""Performance score for a strategy in a specific regime."""
"""Performance score for a strategy in a specific regime.
Manifold fields (for Mode 2 recommendation):
confidence: 0.0-1.0, how reliable is this score
support_count: how many evaluations produced this score
distance_to_nearest: distance to nearest other evaluated point
"""
strategy_id: str
regime: MarketRegime
score: float
@@ -156,6 +162,9 @@ class RegimeStrategyScore:
avg_drawdown_bps: float
avg_adverse_fill_ratio: float
last_updated_ns: int
confidence: float = 1.0
support_count: int = 1
distance_to_nearest: float = 0.0
class PerformanceMatrix:
@@ -208,6 +217,9 @@ class PerformanceMatrix:
avg_drawdown_bps=new_dd,
avg_adverse_fill_ratio=new_adverse,
last_updated_ns=time.time_ns(),
confidence=min(1.0, new_episodes / 10.0), # confidence grows with evidence
support_count=new_episodes,
distance_to_nearest=0.0, # computed lazily on query
)
self._strategy_regime_history[strategy_id].append(regime)