fix: enforce internal embeddings contract

This commit is contained in:
2026-08-08 17:33:19 +02:00
parent 2911e008d1
commit c875fa52ce
5 changed files with 131 additions and 3 deletions
@@ -90,3 +90,60 @@ git diff --check
- the focused harness verification still emits two pre-existing warnings:
- `DeprecationWarning` from `testcontainers.postgres`
- `FutureWarning` because `resources` currently flows through the legacy config translation path
## Fix round 1 — 2026-08-08
### Findings addressed
- HIGH: external top-level `embeddings` remained an operational fallback and could still load
- MEDIUM: non-object embed JSON payloads escaped as raw `AttributeError`
### RED evidence
Command:
```bash
cd harness
./.venv/bin/pytest tests/test_internal_embeddings.py tests/test_config_resources.py tests/test_ollama_ensure.py -q
```
Observed before the fix:
- exit code `1`
- `2 failed, 36 passed, 2 warnings`
Representative failures:
- `AttributeError: 'list' object has no attribute 'get'` from `response.json()` returning a JSON array
- `Failed: DID NOT RAISE ConfigError` for top-level external `embeddings.provider=openai_compatible`
### GREEN evidence
Command:
```bash
cd harness
./.venv/bin/pytest tests/test_internal_embeddings.py tests/test_config_resources.py tests/test_ollama_ensure.py -q
```
Observed after the fix:
- exit code `0`
- `38 passed, 2 warnings`
Touched-file lint:
```bash
cd harness
./.venv/bin/ruff check tht/config.py tht/vectorstore/embeddings.py tests/test_internal_embeddings.py tests/test_config_resources.py
```
- exit code `0`
- `All checks passed!`
### Minimal fix
- validated the final active `cfg.embeddings` contract after config loading, so legacy top-level
embedding inputs now fail explicitly unless they exactly match the internal Ollama contract
- converted non-mapping embed JSON payloads into controlled `EmbeddingsError` failures with
sanitized diagnostics instead of raw attribute errors