Applied findings from three parallel code reviews (reuse/quality/
efficiency) on all Phase 11 changes. Fixes that made the cut:
- src/rag/knowledge_base_kenya.py: import KnowledgeChunk from
knowledge_base.py instead of re-defining the same dataclass inline.
Both RAG modules now share one type.
- src/pipeline.py: stop reaching into src.recommendation_agent's
private _ACTIVE_REGION_CONFIG module global; read REGION_CONFIG[REGION]
from the public surface. Drops the leaky-abstraction warning from
the quality review.
- src/pipeline.py: self._dfl_actions was instance state that was
rebuilt every run() and only read once per optimize step. Replaced
with a local in _step_optimize, one fewer instance field to reason
about.
- src/policy/features.py: build_dp_features called _history_prices(history)
twice when spot<=0 (once for the spot fallback, once for rolling
stats). Cache the normalized history once at the top. Trivial, but
this is in the hot training loop (20,330 call…