1. Unit mismatch: KAMIS publishes KES per kg; pipeline expected per quintal
Result: SMS showed "Net: KES 14/qtl" for a maize farmer because the
optimizer subtracted per-quintal transport costs from a per-kg price.
Fix: normalize to KES/quintal at both KAMIS PriceRecord creation sites
(demo CSV reader and live API) via a named KG_TO_QUINTAL=100 constant.
2. CI bounds missing for 14d/30d horizons
Neon's price_forecasts rows had ci_lower/ci_upper NULL for 14d and 30d.
Root cause: pipeline.py:1075-1088 only copied ci_lower_7d/ci_upper_7d
into the dict sent to save_pipeline_run; the other four CI fields from
the PriceForecast dataclass were dropped. Fix: include all six CI keys.
3. Swahili SMS leaked the example greeting's name
FMR-K0003's SMS started "Habari Wanjiku, Owino Muriuki,". The translation
prompt said "start naturally, like 'Habari Wanjiku...'" — Claude copied
the example name verbatim before the real farmer's name. Fix: rewrite
the prompt to…
Makes the recommendation agent region-parameterized and renames the
India-specific output field recommendation_ta -> recommendation_local
(+ sibling local_language_code: 'ta' | 'sw').
- REGION_CONFIG dict keyed by region with 10 fields (region_name,
currency_symbol, market_type, local_language_name/code,
phone_country_code, local_greeting_example, typical_crops, etc.)
- SYSTEM_PROMPT + TRANSLATION_PROMPT parameterize via .format()
- Claude models unchanged: Sonnet for reasoning, Haiku for translation
- FarmerRecommendation dataclass: recommendation_ta -> recommendation_local
- Rule-based fallback is region-aware (currency, market terminology)
- Delivery SMS: phone country code + language-tagged local text
(+254..., 'SW:' prefix under Kenya; +91..., 'TA:' under India)
- src/api.py demo endpoint emits the new fields
- src/db.py: DB-schema-gap comment at SellRecommendation persistence
(local text lives in full_data JSONB; no dedicated column change)
Co-Authored-By: Claude Opus 4…
Clean up DPI commit: redundant state, dead field, stringly typing
Follow-up to 8a1097a addressing review findings:
src/dpi/models.py:
- Remove KCCRecord.interest_rate_pct — the field was set in the
simulator but never read anywhere in the codebase. Dead state.
- Add KCCRepaymentStatus = Literal["current", "overdue", "defaulted"]
type alias and use it on KCCRecord.repayment_status to catch
typos at type-check time.
src/dpi/simulator.py:
- Move config + src.geo imports from inside _generate_all to the
module top. There's no circular dependency — config never imports
from src.dpi — so the defensive late-binding was cargo cult.
- Drop the interest_rate_pct assignment in _make_kcc now that the
field is gone.
src/optimizer.py:
- CreditReadiness.kcc_headroom_rs is now a @property computed as
max(0, limit - outstanding) instead of a separately-stored field.
Prior shape created a sync risk where the three KCC fields could
drift out of agreement.
- Extract KCC utilization thresholds to named module-level constants
(KCC_UTILIZATION_HIGH_P…
Add DPI subsystem (Aadhaar + Land Records + KCC) and wire into credit readiness
Ports a focused three-service Digital Public Infrastructure layer from
Weather AI 2's pattern, adapted for Market Intelligence's credit
readiness product. Scope is deliberately narrower than WA2's six-service
aggregation — MI only needs the services that actually affect a
sell-timing + credit recommendation:
- AadhaarProfile -- identity + district + Tamil-script name
- LandRecord -- acreage, soil, irrigation, registered crops,
nearest mandi (computed at load time via haversine)
- KCCRecord -- real credit limit, outstanding, repayment status,
subsidized interest rate
Skipped on purpose: Soil Health Card (WA2 uses it for weather advisories;
MI doesn't need it), PM-KISAN (income support; not relevant to market
timing), PMFBY (crop insurance; MI isn't an insurance product).
src/dpi/models.py:
- Dataclasses with derived properties: FarmerProfile.total_area,
primary_crops, nearest_mandis, grows_commodity(), repayment_o…
P0: SPA catch-all returns 404 not None, recommendation_to_dict includes
farmer_id/name/tamil, demo sell options include drive_time_min/storage_cost.
P1: Pipeline forecasts use current_price_rs (matching frontend), model
metrics flattened (r2 not nested under metrics), seasonal_index added to
forecasts, StatusBadge handles active/partial, Forecast chart uses real
CI values not hardcoded scaling, division-by-zero guard added.
P2: Package name health→market-intelligence, health-domain artifacts in
docstrings/comments cleaned, Google Maps reference removed (uses haversine),
deprecated datetime.utcnow→now(timezone.utc), confidence clamped to 0.10+,
dist_bak deleted.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace health supply chain optimizer with market intelligence agent
Complete rewrite from health domain to post-harvest market intelligence
for Tamil Nadu smallholder farmers. Same 6-step pipeline architecture
(ingest → extract → reconcile → forecast → optimize → recommend),
new domain: conflicting mandi price data → reconciled prices →
sell-now-or-wait recommendations with credit readiness assessment.
Backend: 15 real Tamil Nadu mandis, 10 commodities, real Agmarknet API
(data.gov.in), eNAM scraper, NASA POWER weather, XGBoost price forecaster,
Claude agents with rule-based fallbacks, FAISS+BM25 RAG.
Frontend: 5 pages (Markets, Forecast, Sell Advisor, Pipeline, Data),
amber/saffron theme, Tamil Nadu map, Joyride tour, credit readiness UI.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Full-stack AI pipeline for health commodity forecasting and procurement optimization.
Backend: FastAPI + Claude agents for extraction, healing, reconciliation, demand forecasting, and procurement.
Frontend: React + Vite + Tailwind dashboard with guided tour.
CI: GitHub Actions for backend/frontend validation + weekly pipeline trigger.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>