fix: reject unprovenanced ML artifacts
This commit is contained in:
@@ -8,6 +8,7 @@ from collections import defaultdict
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from scoring.policy import SCORE_BRACKETS, SCORE_VERSION, score_in_bracket
|
||||
from ml.artifacts import validate_ml_artifact
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@@ -117,11 +118,15 @@ def _compute_ath_series(price_lookup, dates):
|
||||
|
||||
|
||||
def _load_ml_weights():
|
||||
"""Load ML weights for ML-optimized scoring mode."""
|
||||
"""Load only schema/provenance-valid ML weights."""
|
||||
ml_path = _os.path.join(_os.path.dirname(_os.path.dirname(_os.path.abspath(__file__))), "config", "ml_weights.json")
|
||||
try:
|
||||
with open(ml_path) as f:
|
||||
data = _json.load(f)
|
||||
status = validate_ml_artifact(data)
|
||||
if not status["valid"]:
|
||||
log.error("Rejected invalid ML artifact: %s", ", ".join(status["errors"]))
|
||||
return {}
|
||||
return data.get("weights", {})
|
||||
except Exception:
|
||||
return {}
|
||||
|
||||
Reference in New Issue
Block a user