{"record":{"id":"1f9e1d83d9c2c136","repo":"HKUDS/Vibe-Trading","slug":"invalid-evidence-stage-self-evidence-stage-r-ex","errorCode":null,"errorMessage":"invalid evidence_stage {self.evidence_stage!r}; expected one of {EVIDENCE_STAGES}","messagePattern":"invalid evidence_stage (.+?); expected one of (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/strategy_discovery/models.py","lineNumber":170,"sourceCode":"    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:\n    \"\"\"Catalog entry surfaced by :meth:`StrategyDiscoveryFacade.list_strategies`.\n\n    ``source`` is ``\"alpha_zoo\"`` or ``\"sdm\"``. ``status`` mirrors the SDM\n    lifecycle state and is ``None`` for alpha-zoo entries, which have no","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/strategy_discovery/models.py#L152-L188","documentation":"__post_init__ validates that `evidence_stage` is one of the module-level EVIDENCE_STAGES constants. Any unrecognized stage string raises ValueError, guarding against typos and stale stage names from other pipeline versions.","triggerScenarios":"Constructing the dataclass with evidence_stage='preliminary' or 'FINAL' when the allowed set uses different exact strings (e.g. lowercase 'final').","commonSituations":"Pipeline version drift — rows written by an older stage-naming scheme; case or spelling mistakes; copy-pasting stage names from docs that are out of date.","solutions":["Inspect EVIDENCE_STAGES in agent/src/strategy_discovery/models.py and use an exact value","Upgrade/align writer and reader to the same model version","Add the new stage to EVIDENCE_STAGES if the vocabulary legitimately grew"],"exampleFix":"# before\nrow = Evidence(evidence_stage='candidate', ...)\n# after\nrow = Evidence(evidence_stage='backtested', ...)  # exact member of EVIDENCE_STAGES","handlingStrategy":"validation","validationCode":"from agent.src.strategy_discovery.models import EVIDENCE_STAGES\nif evidence_stage not in EVIDENCE_STAGES:\n    raise KeyError(f'unknown stage {evidence_stage!r}; known: {EVIDENCE_STAGES}')","typeGuard":"def is_valid_stage(s: str) -> bool:\n    from agent.src.strategy_discovery.models import EVIDENCE_STAGES\n    return s in EVIDENCE_STAGES","tryCatchPattern":"try:\n    Evidence(evidence_stage=stage, ...)\nexcept ValueError as e:\n    if 'invalid evidence_stage' in str(e): skip/re-map the row\n    else: raise","preventionTips":["Reference EVIDENCE_STAGES rather than hardcoding names","Re-validate stored data after model upgrades","Keep stage vocabulary changes backward-compatible or migrate rows"],"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"}