fix(tests): T-7 — the unit suite is hermetic, the flake class is gone

Three flakes in one day, never a captured name — the name finally
came from a discriminating run instead of patience: pointing
OLLAMA_HOST at a dead port failed exactly eight tests, all in
tests/agents/test_tatlock_agent.py, all already marked integration,
all running in the unit gate anyway because make test excluded by
directory and they live outside the ignored directories. Eight tests
doing ~110 seconds of real LLM inference against the production
wrapper on every unit run, failing whenever the backend was
mid-deploy — which this week it constantly was.

The second coupling sat in the session init: conftest ran the real
health probes, an HTTP round trip to whatever answers behind
OLLAMA_HOST plus a real Anthropic API call whenever the dev .env
carries a key, so the cached backend globals followed the network of
the moment. The probes are stubbed to the deterministic local-first
state; tests needing other states patch the globals themselves, as
the selector tests always did.

make test now enforces -m "not integration" alongside the directory
ignores, and the acceptance is blunt: 679 passed in ~12 s, identical
against a dead backend and no API key — down from ~129 s of
infrastructure-coupled runtime. Both prongs mutation-checked: the
gate removed fails eight against a dead backend; the stub removed
fails the new session-globals test. T-8 files the orphaned
tests/integration directory that no make target runs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-13 11:29:10 +02:00
co-authored by Claude Fable 5
parent b62a6f4672
commit 8808880145
7 changed files with 83 additions and 4 deletions
+19
View File
@@ -0,0 +1,19 @@
"""
The suite's backend globals are stubbed, not probed (T-7).
`make test` promises "no external services". The session init used to
run the real health probes — an HTTP round trip to whatever answers
behind OLLAMA_HOST and a real Anthropic API call whenever the dev .env
carries a key — so the cached globals depended on live infrastructure,
and the suite flaked whenever the backend was mid-deploy. This test
discriminates: under the stub the globals are always the local-first
healthy state; under real probes they follow the network of the moment.
"""
from src.anthropic import model_selector
def test_session_globals_are_deterministic():
assert model_selector._ollama_available is True
assert model_selector._local_flavor == "boilerroom"
assert model_selector._claude_available is False