{"record":{"id":"e82ea5772e4b19b4","repo":"HKUDS/Vibe-Trading","slug":"evidence-stage-self-evidence-stage-r-claims-a-co","errorCode":null,"errorMessage":"evidence_stage {self.evidence_stage!r} claims a computed result, so provenance must name the run it was computed from; got an empty provenance for strategy {self.strategy_id!r} / regime {self.regime!r}","messagePattern":"evidence_stage (.+?) claims a computed result, so provenance must name the run it was computed from; got an empty provenance for strategy (.+?) / regime (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/strategy_discovery/models.py","lineNumber":175,"sourceCode":"    #: 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\n    lifecycle.\n    \"\"\"\n\n    strategy_id: str\n    name: str","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/strategy_discovery/models.py#L157-L193","documentation":"Evidence rows whose evidence_stage is in STAGES_REQUIRING_PROVENANCE (i.e. stages claiming a computed result) must carry a non-empty `provenance` string naming the run that produced them. __post_init__ raises ValueError when provenance is empty/missing for such a stage, preventing computed numbers from appearing out of thin air.","triggerScenarios":"Building an evidence row with a computed stage (e.g. backtested) but provenance='' (the default), or forgetting to attach the run identifier when programmatically assembling rows.","commonSituations":"Migrating hand-authored rows to computed stages; test fixtures that only set stage and metrics; refactors that drop the provenance field.","solutions":["Set provenance to the identifier of the computing run (e.g. 'run:2024-05-01-alpha')","If the row is genuinely not computed, use a stage not in STAGES_REQUIRING_PROVENANCE"],"exampleFix":"# before\nEvidence(strategy_id='s1', regime='bull', evidence_stage='backtested', provenance='')\n# after\nEvidence(strategy_id='s1', regime='bull', evidence_stage='backtested', provenance='run=2024-05-01T10:00:00')","handlingStrategy":"validation","validationCode":"from agent.src.strategy_discovery.models import STAGES_REQUIRING_PROVENANCE\nif stage in STAGES_REQUIRING_PROVENANCE and not (provenance or '').strip():\n    provenance = f'run={run_id}'  # or refuse to build the row","typeGuard":"def has_provenance_if_needed(stage: str, provenance: str) -> bool:\n    from agent.src.strategy_discovery.models import STAGES_REQUIRING_PROVENANCE\n    return stage not in STAGES_REQUIRING_PROVENANCE or bool(provenance and provenance.strip())","tryCatchPattern":"try:\n    Evidence(..., evidence_stage=stage, provenance=provenance)\nexcept ValueError as e:\n    if 'provenance' in str(e): downgrade stage or attach run id and retry\n    else: raise","preventionTips":["Always stamp provenance from the computing run's identifier","Treat provenance as mandatory in fixtures for computed stages","Log a warning when building computed rows without a run context"],"tags":["python","provenance","validation","audit"],"backgroundTag":"missing-required-field","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}