{"record":{"id":"a3f6444dafd8bcd4","repo":"HKUDS/Vibe-Trading","slug":"invalid-regime-self-regime-r-expected-one-of-r","errorCode":null,"errorMessage":"invalid regime {self.regime!r}; expected one of {REGIMES}","messagePattern":"invalid regime (.+?); expected one of (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/strategy_discovery/models.py","lineNumber":166,"sourceCode":"    cost_sensitive: bool = False\n    evidence_quality: str = QUALITY_INSUFFICIENT\n    warnings: tuple[str, ...] = ()\n    #: ISO date string (\"YYYY-MM-DD\") of the last harness verification.\n    last_verified: str = \"\"\n    #: Pipeline stage that produced this row; one of ``EVIDENCE_STAGES``.\n    #: Defaults to the weakest claim: a row that says nothing about how it was\n    #: produced must not read as though a backtest stood behind it.\n    evidence_stage: str = \"hypothesis\"\n    #: Reproducible artifact reference: the backtest run directory whose\n    #: ``artifacts/`` this row was computed from.\n    provenance: str = \"\"\n    #: JSON string naming the regime-labeling parameters (window, bear/bull\n    #: thresholds, Sharpe annualization) used when this row was computed.\n    regime_definition: str = \"\"\n\n    def __post_init__(self) -> None:\n        if self.regime not in REGIMES:\n            raise ValueError(\n                f\"invalid regime {self.regime!r}; expected one of {REGIMES}\"\n            )\n        if self.evidence_stage not in EVIDENCE_STAGES:\n            raise ValueError(\n                f\"invalid evidence_stage {self.evidence_stage!r}; \"\n                f\"expected one of {EVIDENCE_STAGES}\"\n            )\n        if self.evidence_stage in STAGES_REQUIRING_PROVENANCE and not self.provenance:\n            raise ValueError(\n                f\"evidence_stage {self.evidence_stage!r} claims a computed \"\n                f\"result, so provenance must name the run it was computed \"\n                f\"from; got an empty provenance for strategy \"\n                f\"{self.strategy_id!r} / regime {self.regime!r}\"\n            )\n\n\n@dataclass(frozen=True)\nclass StrategySummary:","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/strategy_discovery/models.py#L148-L184","documentation":"StrategyDiscovery models.py __post_init__ validates that the `regime` field of the evidence row is one of the module-level REGIMES constants. Any other string (typo, renamed label, new regime not in the enum) raises ValueError at dataclass construction time.","triggerScenarios":"Constructing the evidence dataclass with regime='neutral' when REGIMES only contains e.g. 'bull'/'bear', or loading rows produced by an older/newer pipeline whose regime labels differ.","commonSituations":"Version mismatch between the process that wrote evidence rows and the reader; typos or case differences ('Bull' vs 'bull'); adding a new regime label without updating the REGIMES constant.","solutions":["Check strategy_discovery.models.REGIMES and use one of those exact values","If you introduced a new regime, add it to REGIMES in the same change","If reading stored rows, regenerate/reload them with a matching pipeline version"],"exampleFix":"# before\nrow = Evidence(regime='neutral', ...)\n# after\nfrom agent.src.strategy_discovery.models import REGIMES\nrow = Evidence(regime='bear', ...)  # one of REGIMES","handlingStrategy":"validation","validationCode":"from agent.src.strategy_discovery.models import REGIMES\nif regime not in REGIMES:\n    raise KeyError(f'unknown regime {regime!r}; known: {REGIMES}')","typeGuard":"def is_valid_regime(r: str) -> bool:\n    from agent.src.strategy_discovery.models import REGIMES\n    return r in REGIMES","tryCatchPattern":"try:\n    row = Evidence(regime=regime, ...)\nexcept ValueError as e:\n    if 'invalid regime' in str(e): map/regenerate the row or skip it\n    else: raise","preventionTips":["Import REGIMES and use its members instead of string literals","Pin writer and reader to the same model version","Add a smoke test enumerating all stored regimes against REGIMES"],"tags":["python","validation","enum"],"backgroundTag":"enum-validation-failed","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}