Spaces:
Running
Running
Commit ·
26cb973
1
Parent(s): 2249d6a
fix replay evidence revalidation
Browse files
backend/app/services/alpha_strategy_factory.py
CHANGED
|
@@ -406,7 +406,7 @@ class AlphaStrategyFactory:
|
|
| 406 |
if validation is not None and (candidate.specification_json or {}).get("evidence_binding") != "hyperbolic_replay_v1":
|
| 407 |
return False
|
| 408 |
current_sample = len(AlphaStrategyFactory._candidate_replay_rows(db, candidate))
|
| 409 |
-
return validation is None or current_sample
|
| 410 |
|
| 411 |
@staticmethod
|
| 412 |
def _persist_folds(db: Session, candidate: StrategyCandidateVariant, evidence: dict) -> None:
|
|
|
|
| 406 |
if validation is not None and (candidate.specification_json or {}).get("evidence_binding") != "hyperbolic_replay_v1":
|
| 407 |
return False
|
| 408 |
current_sample = len(AlphaStrategyFactory._candidate_replay_rows(db, candidate))
|
| 409 |
+
return validation is None or current_sample != int(validation.sample_size or 0)
|
| 410 |
|
| 411 |
@staticmethod
|
| 412 |
def _persist_folds(db: Session, candidate: StrategyCandidateVariant, evidence: dict) -> None:
|
backend/tests/test_alpha_strategy_factory.py
CHANGED
|
@@ -292,9 +292,21 @@ def test_candidate_evidence_requires_the_exact_replay_timeframe_stack() -> None:
|
|
| 292 |
db.flush()
|
| 293 |
|
| 294 |
evidence = AlphaStrategyFactory._candidate_evidence(db, candidate)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 295 |
|
| 296 |
assert evidence["sample_size"] == 1
|
| 297 |
assert evidence["returns_r"] == [1.2]
|
|
|
|
| 298 |
|
| 299 |
|
| 300 |
def test_multi_family_factory_run_uses_bounded_index_key_and_preserves_full_selection() -> None:
|
|
|
|
| 292 |
db.flush()
|
| 293 |
|
| 294 |
evidence = AlphaStrategyFactory._candidate_evidence(db, candidate)
|
| 295 |
+
previous_validation = ReplayStrategyValidation(
|
| 296 |
+
setup_type="intraday_trend",
|
| 297 |
+
sample_size=2,
|
| 298 |
+
verdict="NEEDS_MORE_EVIDENCE",
|
| 299 |
+
explanation="Legacy validation counted an incompatible timeframe stack.",
|
| 300 |
+
)
|
| 301 |
+
db.add(previous_validation)
|
| 302 |
+
db.flush()
|
| 303 |
+
candidate.validation_id = previous_validation.id
|
| 304 |
+
db.flush()
|
| 305 |
+
requires_revalidation = AlphaStrategyFactory._has_new_evidence(db, candidate)
|
| 306 |
|
| 307 |
assert evidence["sample_size"] == 1
|
| 308 |
assert evidence["returns_r"] == [1.2]
|
| 309 |
+
assert requires_revalidation is True
|
| 310 |
|
| 311 |
|
| 312 |
def test_multi_family_factory_run_uses_bounded_index_key_and_preserves_full_selection() -> None:
|