HKUDS/Vibe-Trading · error · ValueError

evidence_stage {self.evidence_stage!r} claims a computed res

Error message

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}

What it means

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.

Source

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

    #: 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
    lifecycle.
    """

    strategy_id: str
    name: str

View on GitHub (pinned to 80ffdda44c)

Solutions

  1. Set provenance to the identifier of the computing run (e.g. 'run:2024-05-01-alpha')
  2. If the row is genuinely not computed, use a stage not in STAGES_REQUIRING_PROVENANCE

Example fix

# before
Evidence(strategy_id='s1', regime='bull', evidence_stage='backtested', provenance='')
# after
Evidence(strategy_id='s1', regime='bull', evidence_stage='backtested', provenance='run=2024-05-01T10:00:00')
Defensive patterns

Strategy: validation

Validate before calling

from agent.src.strategy_discovery.models import STAGES_REQUIRING_PROVENANCE
if stage in STAGES_REQUIRING_PROVENANCE and not (provenance or '').strip():
    provenance = f'run={run_id}'  # or refuse to build the row

Type guard

def has_provenance_if_needed(stage: str, provenance: str) -> bool:
    from agent.src.strategy_discovery.models import STAGES_REQUIRING_PROVENANCE
    return stage not in STAGES_REQUIRING_PROVENANCE or bool(provenance and provenance.strip())

Try / catch

try:
    Evidence(..., evidence_stage=stage, provenance=provenance)
except ValueError as e:
    if 'provenance' in str(e): downgrade stage or attach run id and retry
    else: raise

Prevention

When it happens

Trigger: 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.

Common situations: Migrating hand-authored rows to computed stages; test fixtures that only set stage and metrics; refactors that drop the provenance field.

Understand the failure class

Background: "Missing required field" and "field is required" errors: why libraries reject payloads that omit mandatory fields — this error's family across 20 libraries.

Related errors


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