From 06c86e91a037c79b2c651548e10f39fc4c62d249 Mon Sep 17 00:00:00 2001 From: Codex Date: Wed, 15 Jul 2026 06:49:35 +0200 Subject: [PATCH] fix: recognize Dutch evolution questions --- backend/app/services/geo_assistant_service.py | 9 +++++++-- .../test_sprint202_temporal_metrics_and_ollama.py | 12 ++++++++++++ docs/CODEX_EXECUTION_LOG.md | 10 +++++++--- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/backend/app/services/geo_assistant_service.py b/backend/app/services/geo_assistant_service.py index 74136f07..0fc5425a 100644 --- a/backend/app/services/geo_assistant_service.py +++ b/backend/app/services/geo_assistant_service.py @@ -27,7 +27,7 @@ from app.services.vector_feature_service import VectorFeatureService class GeoAssistantService: HISTORY_KEYWORDS = ( "histor", - "evolutie", + "evolu", "verander", "trend", "vroeger", @@ -38,6 +38,11 @@ class GeoAssistantService: "gestegen", ) + @classmethod + def history_requested(cls, question: str) -> bool: + normalized = question.casefold() + return any(keyword in normalized for keyword in cls.HISTORY_KEYWORDS) + def __init__(self, settings: Settings | None = None): self.settings = settings or get_settings() @@ -272,7 +277,7 @@ class GeoAssistantService: temporal_series: list[AssistantTemporalSeries] = [] temporal_context: list[dict[str, Any]] = [] - include_history = any(keyword in payload.question.casefold() for keyword in self.HISTORY_KEYWORDS) + include_history = self.history_requested(payload.question) for key, observations in self._series(datasets): first = observations[0] last = observations[-1] diff --git a/backend/tests/test_sprint202_temporal_metrics_and_ollama.py b/backend/tests/test_sprint202_temporal_metrics_and_ollama.py index 3a6a894a..d8028630 100644 --- a/backend/tests/test_sprint202_temporal_metrics_and_ollama.py +++ b/backend/tests/test_sprint202_temporal_metrics_and_ollama.py @@ -86,6 +86,18 @@ def test_geo_assistant_rejects_model_that_is_not_installed(monkeypatch) -> None: assert exc_info.value.code == "OLLAMA_MODEL_UNAVAILABLE" +@pytest.mark.parametrize( + "question", + [ + "Hoe evolueerden bevolking en bosoppervlakte?", + "Toon de historische ontwikkeling van water.", + "Welke trend zien we sinds 2013?", + ], +) +def test_geo_assistant_recognizes_dutch_historical_questions(question: str) -> None: + assert GeoAssistantService.history_requested(question) is True + + def test_geo_assistant_sends_grounded_context_without_thinking_trace(monkeypatch) -> None: service = GeoAssistantService(ollama_settings()) project_id = uuid4() diff --git a/docs/CODEX_EXECUTION_LOG.md b/docs/CODEX_EXECUTION_LOG.md index fa1e496b..c5ffdec2 100644 --- a/docs/CODEX_EXECUTION_LOG.md +++ b/docs/CODEX_EXECUTION_LOG.md @@ -8389,11 +8389,15 @@ Validation evidence: - Focused temporal, source, Ollama, navigation and Unraid regression tests passed, including direct coverage for multi-metric history and DockerMan host mapping. -- Full readiness passed 612 backend tests, backend compilation, 91 documented +- Full readiness passed 615 backend tests, backend compilation, 91 documented API routes, one Alembic head, frontend TypeScript typecheck/build and all shell syntax gates. -- Local Docker validation was deferred to the live Tower deployment because - Docker is not installed on the Windows development host. +- Tower deployment passed the all-in-one container health check, live PostGIS + 3.6 migration/schema smoke and frontend/API proxy smoke. The container reached + host Ollama and exposed 10 installed models through the canonical API. +- A live historical question revealed that the Dutch verb `evolueerden` did + not activate history context. The intent stem was corrected to `evolu`, three + direct regression cases were added and full readiness reran successfully. Known limitations: - Water volume remains unavailable until a governed depth/bathymetry source is