feat(api,ui): forecast explainability & driver attribution slice (#224)#231
Conversation
There was a problem hiding this comment.
Sorry @w7-mgfcode, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Adds the explainability vertical slice — rule-based driver attribution for baseline forecasts — closing #224.
app/features/explainability/slice:models,schemas,service,routes,explainers,reason_codes+ full test suite (unit + integration)./explain:POST /explain/forecast— explain an ad-hoc baseline h=1 forecast.GET /explain/runs/{run_id}— explain a registrymodel_run.GET /explain/jobs/{job_id}— explain a completedpredictjob.naive/seasonal_naive/moving_average);lightgbm/regression→ clean RFC 7807 400. Time-safe (reads only<= as_of_date).forecast_explanationtable (migrationf84258c4cb44) persists each explanation as an audit trail.ExplanationPanelcomponent +use-explanationshook, wired into the run-detail and forecast-visualization pages.Bundled fix —
fix(ui)(#230)The slice's dogfood surfaced a pre-existing, repo-wide bug:
api.tsonly treatedapplication/jsonas JSON, so RFC 7807application/problem+jsonerror bodies were never parsed and the raw JSON string leaked into everyErrorDisplay. Fixed here (one line + regression test) because theExplanationPanelerror UX depends on it. Root cause tracked in #230.Validation
ruff/mypy --strict/pyright --strict— clean.tsc --noEmit+lintclean./explorer/runs/{id}(full panel),/visualize/forecast(full panel for an explainable predict job), and the graceful neutral message for an unexplainable job.Notes
uv.lockhas an unrelated local version-string drift (0.2.8→0.2.14) left out of this PR.Closes #224.