fix: reject unprovenanced ML artifacts

This commit is contained in:
Hermes Agent
2026-07-26 23:07:24 +00:00
parent 62bff348bf
commit eb8c01611c
6 changed files with 198 additions and 8 deletions
+6 -1
View File
@@ -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 {}