HKUDS/Vibe-Trading · error · ValueError

invalid evidence_stage {self.evidence_stage!r}; expected one

Error message

invalid evidence_stage {self.evidence_stage!r}; expected one of {EVIDENCE_STAGES}

What it means

__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.

Source

Thrown at agent/src/strategy_discovery/models.py:170

    last_verified: str = ""
    #: Pipeline stage that produced this row; one of ``EVIDENCE_STAGES``.
    #: Defaults to the weakest claim: a row that says nothing about how it was
    #: produced must not read as though a backtest stood behind it.
    evidence_stage: str = "hypothesis"
    #: Reproducible artifact reference: the backtest run directory whose
    #: ``artifacts/`` this row was computed from.
    provenance: str = ""
    #: JSON string naming the regime-labeling parameters (window, bear/bull
    #: thresholds, Sharpe annualization) used when this row was computed.
    regime_definition: str = ""

    def __post_init__(self) -> None:
        if self.regime not in REGIMES:
            raise ValueError(
                f"invalid regime {self.regime!r}; expected one of {REGIMES}"
            )
        if self.evidence_stage not in EVIDENCE_STAGES:
            raise ValueError(
                f"invalid evidence_stage {self.evidence_stage!r}; "
                f"expected one of {EVIDENCE_STAGES}"
            )
        if self.evidence_stage in STAGES_REQUIRING_PROVENANCE and not self.provenance:
            raise ValueError(
                f"evidence_stage {self.evidence_stage!r} claims a computed "
                f"result, so provenance must name the run it was computed "
                f"from; got an empty provenance for strategy "
                f"{self.strategy_id!r} / regime {self.regime!r}"
            )


@dataclass(frozen=True)
class StrategySummary:
    """Catalog entry surfaced by :meth:`StrategyDiscoveryFacade.list_strategies`.

    ``source`` is ``"alpha_zoo"`` or ``"sdm"``. ``status`` mirrors the SDM
    lifecycle state and is ``None`` for alpha-zoo entries, which have no

View on GitHub (pinned to 80ffdda44c)

Solutions

  1. Inspect EVIDENCE_STAGES in agent/src/strategy_discovery/models.py and use an exact value
  2. Upgrade/align writer and reader to the same model version
  3. Add the new stage to EVIDENCE_STAGES if the vocabulary legitimately grew

Example fix

# before
row = Evidence(evidence_stage='candidate', ...)
# after
row = Evidence(evidence_stage='backtested', ...)  # exact member of EVIDENCE_STAGES
Defensive patterns

Strategy: validation

Validate before calling

from agent.src.strategy_discovery.models import EVIDENCE_STAGES
if evidence_stage not in EVIDENCE_STAGES:
    raise KeyError(f'unknown stage {evidence_stage!r}; known: {EVIDENCE_STAGES}')

Type guard

def is_valid_stage(s: str) -> bool:
    from agent.src.strategy_discovery.models import EVIDENCE_STAGES
    return s in EVIDENCE_STAGES

Try / catch

try:
    Evidence(evidence_stage=stage, ...)
except ValueError as e:
    if 'invalid evidence_stage' in str(e): skip/re-map the row
    else: raise

Prevention

When it happens

Trigger: Constructing the dataclass with evidence_stage='preliminary' or 'FINAL' when the allowed set uses different exact strings (e.g. lowercase 'final').

Common situations: 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.

Related errors


AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28). Data as JSON: /api/errors/1f9e1d83d9c2c136. Report an issue: GitHub.