From 2ffc167f1ab89b7cde484cd815da30e717db659b Mon Sep 17 00:00:00 2001 From: Jer Miller Date: Sat, 30 May 2026 15:13:57 -0600 Subject: [PATCH] test: drop ollama negative-invariant guards; fix voice-brain xdist race Two unrelated test-quality fixes batched. 1. Remove the "ollama must never come back" guards. Per founder: if we ever reintroduce ollama it will be a deliberate decision, so a test that fails on its return is wrong -- it encodes a point-in-time policy, not an invariant of every valid state (the same principle that retired the changelog test). Deleted tests/test_docs.py entirely (both tests were ollama-absence guards) and dropped the two `assert "ollama" not in PROVIDER_DEFAULTS/REGISTRY` lines from test_local.py, keeping its positive local-provider invariants. 2. Fix the test_voice_brain xdist flake (root-caused, not silenced). test_schedule_refresh_updates_instruction asserted on app.voice_brain_instruction immediately after future.result(). That attribute is set by the future's done-callback, but a concurrent.futures.Future notifies result() waiters BEFORE invoking done-callbacks -- so under xdist CPU starvation the runtime thread can lag and the assert reads the stale value. Reliable solo, flaky under load (the "1 failed, passes on rerun" we saw). Proven deterministically by lagging the callback 0.2s: result() returns ('session-3','New voice') while the immediate read is still '' (old assert FAILS), and a poll reads 'New voice' (new assert PASSES). Fix: poll for the side effect with a 1s deadline instead of racing it. make ci green (8255 passed). Co-Authored-By: Claude Opus 4.8 (1M context) --- tests/test_docs.py | 46 --------------------------------------- tests/test_local.py | 2 -- tests/test_voice_brain.py | 11 ++++++++++ 3 files changed, 11 insertions(+), 48 deletions(-) delete mode 100644 tests/test_docs.py diff --git a/tests/test_docs.py b/tests/test_docs.py deleted file mode 100644 index 9d2518af6..000000000 --- a/tests/test_docs.py +++ /dev/null @@ -1,46 +0,0 @@ -# SPDX-License-Identifier: AGPL-3.0-only -# Copyright (c) 2026 sol pbc - -from __future__ import annotations - -import subprocess -from pathlib import Path - - -def test_install_md_has_no_ollama_references() -> None: - # Negative invariant: the ollama -> "local provider" sweep stays done. - # Asserting on retired terminology is a rule that must always hold, not a - # prose snapshot. We deliberately do NOT pin the verbatim wording of the - # install copy (that's a checklist concern, not a test, and breaks on every - # legitimate copy edit) -- we assert only the load-bearing concepts survive. - text = Path("INSTALL.md").read_text(encoding="utf-8").lower() - - assert "ollama" not in text - assert "cogitate" in text - assert "no extra install step" in text - assert "local provider" in text - - -def test_ollama_grep_returns_zero_lines() -> None: - result = subprocess.run( - [ - "git", - "grep", - "-i", - "ollama", - "--", - # tests/ and docs/design/ legitimately retain the term: test - # fixtures simulate old log lines, and design records document the - # ollama -> local migration as history. CHANGELOG history likewise - # keeps the old term. Everywhere else, ollama must be fully gone. - ":!tests/", - ":!docs/design/", - ":!CHANGELOG.md", - ], - check=False, - capture_output=True, - text=True, - ) - - assert result.returncode == 1 - assert result.stdout == "" diff --git a/tests/test_local.py b/tests/test_local.py index 049ff81a1..1f591d9b5 100644 --- a/tests/test_local.py +++ b/tests/test_local.py @@ -55,9 +55,7 @@ def test_local_provider_defaults_and_registry(): assert PROVIDER_DEFAULTS["local"][TIER_PRO] == LOCAL_MODEL assert PROVIDER_DEFAULTS["local"][TIER_FLASH] == LOCAL_MODEL assert PROVIDER_DEFAULTS["local"][TIER_LITE] == LOCAL_MODEL - assert "ollama" not in PROVIDER_DEFAULTS assert PROVIDER_REGISTRY["local"] == "solstone.think.providers.local" - assert "ollama" not in PROVIDER_REGISTRY assert PROVIDER_METADATA["local"] == { "label": "Local (on-device)", "env_key": "", diff --git a/tests/test_voice_brain.py b/tests/test_voice_brain.py index 204805dab..697d82801 100644 --- a/tests/test_voice_brain.py +++ b/tests/test_voice_brain.py @@ -4,6 +4,7 @@ from __future__ import annotations import asyncio +import time from flask import Flask @@ -106,6 +107,16 @@ def test_schedule_refresh_updates_instruction(monkeypatch, journal_copy): try: future = brain.schedule_refresh(app, force=True) assert future.result(timeout=1.0) == ("session-3", "New voice") + # The app-state update runs in the future's done-callback. A + # concurrent.futures.Future notifies result() waiters *before* it + # invokes done-callbacks, so the callback may not have applied the + # instruction yet when result() returns -- poll for the side effect + # rather than racing it (this was an xdist-only flake under load). + deadline = time.monotonic() + 1.0 + while ( + app.voice_brain_instruction != "New voice" and time.monotonic() < deadline + ): + time.sleep(0.01) assert app.voice_brain_instruction == "New voice" finally: stop_voice_runtime(app) -- 2.51.2