1.8 KiB
ML service standard
The ML service is a separate Python HTTP service. Its current role is an operational scaffold with health and readiness routes; there is no model-backed product endpoint yet.
Keep the service contract in api/ml/. The Go client uses backend/codegen/ogen-ml.yml and is consumed under backend/internal/adapter/secondary/ml/api/. Python model generation belongs to ml/codegen/pyproject.toml: datamodel-code-generator produces Pydantic v2 models from api/ml/openapi.bundle.yml in ml/src/lincodex_ml/api/models.py. Keep generator dependencies in ml/pyproject.toml and uv.lock; the codegen pyproject contains tool settings only. Health/readiness handlers import generated models instead of maintaining duplicate transport schemas.
Use make -C ml generate to bundle the contract and generate models. The root generation target passes API_PREPARED=1 after preparing the shared bundle. Use make -C ml check-generated to detect drift with the generator's --check mode without rewriting output. Do not edit generated models manually.
Readiness must describe whether the required model or inference runtime is available. Return not-ready while it is unavailable. Do not invent a successful result or label a fixture as a model response.
When inference is added, validate structured output, bound input and output size, apply timeouts, and preserve model and schema versions. Avoid logging resume text, contact details, credentials, or full prompts. Treat document contents and model output as untrusted data.
Use uv with the checked-in lockfile. Keep ordinary lint, type checks, and tests independent of external model downloads and GPU access. Model quality evaluation is a separate, reproducible task with documented data and limits.
All source comments and docstrings are in English.