The four layers
The packages
Rules
- The metric registry is the single source of predictor truth — serving layers import it, never duplicate it.
MetricContextis the lookahead firewall: metric functions only see data withperiod_end <= t - asof_lag.- Panels are batch artifacts — built on a schedule by
python -m market_api.cli build-panel --all, read back byget_panel(), never computed on the request path. - The REST layer maps endpoint → library function, converts exceptions to
HTTP codes (
LookupError → 404,ValueError → 400), and does nothing else. - Production code budget:
predictorsstays under 500 lines.