diff --git a/AGENTS.md b/AGENTS.md index ff091c1..75df867 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -38,6 +38,8 @@ Do not redesign accepted architecture unless the task explicitly asks for an arc - Keep scope limited to the task. - Do not opportunistically implement future tasks. - Update relevant contracts/docs when behavior changes. +- Add useful code comments/docstrings and record file or behavior changes in the relevant docs/progress log. +- After validation, push and merge the task branch into `main` before starting the next Task ID. ## Before finishing diff --git a/apps/api/src/ekp_api/main.py b/apps/api/src/ekp_api/main.py index a3be387..e8215ad 100644 --- a/apps/api/src/ekp_api/main.py +++ b/apps/api/src/ekp_api/main.py @@ -1,9 +1,10 @@ """FastAPI application entry point.""" -from ekp_core.config import Settings, get_settings from fastapi import FastAPI from pydantic import BaseModel +from ekp_core.config import Settings, get_settings + class HealthResponse(BaseModel): """Health endpoint response.""" diff --git a/docs/plans/PROGRESS.md b/docs/plans/PROGRESS.md index d008a8e..7579b4c 100644 --- a/docs/plans/PROGRESS.md +++ b/docs/plans/PROGRESS.md @@ -10,3 +10,13 @@ Next: DEMO-002 The full V1 backlog is deferred until the Demo scope is complete. See `docs/demo/DEMO_SCOPE.md` for the active task sequence. + +## Task records + +### DEMO-001 + +- Added the Python 3.12/uv toolchain, dependency lock, FastAPI application, + typed settings, health/OpenAPI endpoints, and runnable Make targets. +- Added deterministic unit, integration, and seed evaluation tests. +- Verified format, lint, strict type checking, tests, dependency lock, API + startup, health response, and versioned OpenAPI output. diff --git a/pyproject.toml b/pyproject.toml index cd2f521..4c644f9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,6 +33,9 @@ line-length = 100 [tool.ruff.lint] select = ["ASYNC", "B", "E4", "E7", "E9", "F", "I", "UP"] +[tool.ruff.lint.isort] +known-first-party = ["ekp_api", "ekp_core"] + [tool.mypy] python_version = "3.12" strict = true diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..79064b1 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,18 @@ +"""Shared pytest fixtures for deterministic test configuration.""" + +from pathlib import Path + +import pytest + +from ekp_core.config import Settings + + +@pytest.fixture +def isolated_settings_environment( + monkeypatch: pytest.MonkeyPatch, + tmp_path: Path, +) -> None: + """Prevent developer environment variables or .env files from changing tests.""" + monkeypatch.chdir(tmp_path) + for field_name in Settings.model_fields: + monkeypatch.delenv(field_name.upper(), raising=False) diff --git a/tests/integration/test_api_startup.py b/tests/integration/test_api_startup.py index a9d6293..266a0e9 100644 --- a/tests/integration/test_api_startup.py +++ b/tests/integration/test_api_startup.py @@ -1,11 +1,12 @@ """API startup and health checks.""" +from fastapi.testclient import TestClient + from ekp_api.main import create_app from ekp_core.config import Settings -from fastapi.testclient import TestClient -def test_health_endpoint_uses_supplied_settings() -> None: +def test_health_endpoint_uses_supplied_settings(isolated_settings_environment: None) -> None: settings = Settings( app_env="test", app_name="ekp-test", @@ -22,7 +23,7 @@ def test_health_endpoint_uses_supplied_settings() -> None: } -def test_openapi_is_versioned() -> None: +def test_openapi_is_versioned(isolated_settings_environment: None) -> None: settings = Settings(app_env="test") with TestClient(create_app(settings)) as client: diff --git a/tests/unit/test_config.py b/tests/unit/test_config.py index 6a4e7da..e6f676c 100644 --- a/tests/unit/test_config.py +++ b/tests/unit/test_config.py @@ -1,11 +1,12 @@ """Tests for typed application settings.""" import pytest -from ekp_core.config import Settings from pydantic import ValidationError +from ekp_core.config import Settings -def test_settings_have_demo_defaults() -> None: + +def test_settings_have_demo_defaults(isolated_settings_environment: None) -> None: settings = Settings() assert settings.app_env == "development" @@ -13,6 +14,6 @@ def test_settings_have_demo_defaults() -> None: assert settings.api_port == 8000 -def test_settings_reject_invalid_port() -> None: +def test_settings_reject_invalid_port(isolated_settings_environment: None) -> None: with pytest.raises(ValidationError): Settings(api_port=0)