4.2 KiB
4.2 KiB
Task 4 Report — Narrow harness embedding configuration to internal Ollama
Status
Implemented on 2026-08-08 in /Users/mp/projects/ThothII/.worktrees/git-workspace-registry.
RED evidence
Command:
cd harness
./.venv/bin/pytest tests/test_internal_embeddings.py tests/test_config_resources.py -q
Observed before implementation:
- exit code
1 10 failed, 10 passed- failures proved the missing
OllamaInternalEmbeddingsclient and missing internal-only config validation
Representative failures:
ImportError: cannot import name 'OllamaInternalEmbeddings'AttributeError: 'EmbeddingsConfig' object has no attribute 'provider'- config tests
DID NOT RAISE ConfigErrorfor external provider, API key, and non-private base URL
GREEN evidence
Focused behavior suite:
cd harness
./.venv/bin/pytest tests/test_internal_embeddings.py tests/test_config_resources.py -q
- exit code
0 20 passed
Relevant harness verification:
cd harness
./.venv/bin/pytest tests/test_internal_embeddings.py tests/test_config_resources.py tests/test_ollama_ensure.py -q
- exit code
0 36 passed, 2 warnings
Changed-file lint:
cd harness
./.venv/bin/ruff check tht/config.py tht/config_compat.py tht/vectorstore/embeddings.py tht/cli/ollama_cmd.py tests/test_config_resources.py tests/test_internal_embeddings.py
- exit code
0 All checks passed!
Patch hygiene:
git diff --check
- exit code
0
What changed
- translated schema-v3
resources.embeddingsinto the harness-compatible embedding config view - validated the internal embedding contract only for that runtime-owned
resources.embeddingspath:- provider must be
ollama_internal - model must be
qwen3-embedding:0.6b - dimensions must be
1024 - base URL must be
http://embedding:11434or loopback HTTP on port11434 - extra fields like
api_keyare rejected
- provider must be
- replaced the active embed client with
OllamaInternalEmbeddings, using one bounded/api/embedrequest per batch - removed task/query prefix rewriting from the active embedding path
- validated response count, vector dimension, and finite numeric values before returning embeddings
- kept
tht ollama ensure --jsonstdout pristine while warming through the internal client
Self-review
- kept changes inside the brief-listed files
- preserved DWH and session-persistence behavior
- preserved the legacy
OllamaEmbeddingsimport path as an alias to avoid unrelated call-site churn
Concerns
- the focused harness verification still emits two pre-existing warnings:
DeprecationWarningfromtestcontainers.postgresFutureWarningbecauseresourcescurrently flows through the legacy config translation path
Fix round 1 — 2026-08-08
Findings addressed
- HIGH: external top-level
embeddingsremained an operational fallback and could still load - MEDIUM: non-object embed JSON payloads escaped as raw
AttributeError
RED evidence
Command:
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'fromresponse.json()returning a JSON arrayFailed: DID NOT RAISE ConfigErrorfor top-level externalembeddings.provider=openai_compatible
GREEN evidence
Command:
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:
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.embeddingscontract 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
EmbeddingsErrorfailures with sanitized diagnostics instead of raw attribute errors