HKUDS/Vibe-Trading · error · ValueError
cannot mark a model APPROVED from validation_status={current
Error message
cannot mark a model APPROVED from validation_status={current.value!r}; it must reach VALIDATED first What it means
validate_validation_status_transition enforces the state machine: a model artifact can only become APPROVED from VALIDATED (or stay APPROVED). Trying to jump from UNVALIDATED, IN_VALIDATION, or REJECTED straight to APPROVED raises ValueError. Called by register_artifact and update_artifact.
Source
Thrown at agent/src/strategy_store/models.py:233
The only hard rule: a model cannot be marked ``APPROVED`` unless it is
already ``VALIDATED`` (re-approving an already-``APPROVED`` model is a
harmless no-op transition). Every other transition is left to caller
discretion.
Args:
current: The model's validation status before the change.
new: The requested validation status.
Raises:
ValueError: if *new* is ``APPROVED`` while *current* is anything
other than ``VALIDATED`` or ``APPROVED``.
"""
if new is ValidationStatus.APPROVED and current not in (
ValidationStatus.VALIDATED,
ValidationStatus.APPROVED,
):
raise ValueError(
"cannot mark a model APPROVED from validation_status="
f"{current.value!r}; it must reach VALIDATED first"
)
def validate_model_registration(artifact: Artifact) -> None:
"""Validate that *artifact* carries the minimum model-registration fields.
A model registration without a stated intended use or a stated
limitation is, for governance purposes, not actually registered — so
both fields are required and must be non-blank.
Args:
artifact: The artifact/model record to validate.
Raises:
ValueError: if ``intended_use`` or ``limitations`` is missing or
consists only of whitespace.View on GitHub (pinned to 80ffdda44c)
Solutions
- First set status to VALIDATED (record the validation run/date), then a separate update to APPROVED
- If the model was already validated elsewhere, re-import it with VALIDATED status and then approve
- Never seed new artifacts with APPROVED in registration payloads
Example fix
# before
store.register_artifact(Artifact(name='m1', universe='u1', validation_status=ValidationStatus.APPROVED, ...))
# after
store.register_artifact(Artifact(name='m1', universe='u1', validation_status=ValidationStatus.VALIDATED, validation_date='2024-05-01', ...))
store.update_artifact('m1', Artifact(..., validation_status=ValidationStatus.APPROVED, ...)) Defensive patterns
Strategy: validation
Validate before calling
from agent.src.strategy_store.models import ValidationStatus
ORDER = ['unvalidated','in_validation','validated','approved']
def can_approve(current: ValidationStatus) -> bool:
return current in (ValidationStatus.VALIDATED, ValidationStatus.APPROVED) Type guard
def transition_allowed(current: ValidationStatus, new: ValidationStatus) -> bool:
return not (new is ValidationStatus.APPROVED and current not in (ValidationStatus.VALIDATED, ValidationStatus.APPROVED)) Try / catch
try:
store.update_artifact(name, updated)
except ValueError as e:
if 'APPROVED' in str(e): first persist VALIDATED with a validation_date, then retry the approve
else: raise Prevention
- Model the state machine explicitly in registration scripts
- Two-step promote: VALIDATED then APPROVED
- Never default new artifacts to APPROVED in config dumps
When it happens
Trigger: register_artifact(Artifact(..., validation_status=ValidationStatus.APPROVED)) on a brand-new record; update_artifact moving status from 'unvalidated' or 'rejected' to 'approved' in one step.
Common situations: Re-registering a previously approved model from a config dump without replaying its validation history; scripts that stamp APPROVED at import time; tests asserting the guard.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- invalid alpha_id
- alpha_id not found
- invalid period: {exc}
- too many running benches; wait for one to finish
- invalid job_id
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/e6564639cec6fc85.
Report an issue: GitHub.