From 0997eedb7d0fd2c829fd8db158aabd0523660ba6 Mon Sep 17 00:00:00 2001 From: Jer Miller Date: Fri, 17 Apr 2026 20:37:22 -0600 Subject: [PATCH] fix(tests): stabilize two pre-existing flakes under full-suite load MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two unrelated-to-shim-removal pre-existing flakes surfaced during baseline `make ci` verification and blocked the shim-removal lode. Both are test-only fixes. test_entity_intelligence was depending on a gitignored, shared tests/fixtures/journal/indexer/journal.sqlite whose contents were only populated if an earlier test happened to run scan_journal against that fixture first. Replaced the autouse fixture with the repo-standard journal_copy + scan_journal(..., full=True) pattern so each test builds its own deterministic index. test_cortex_client::test_wait_for_agents_missed_event_recovery had a race between unlinking {use_id}_active.jsonl and writing {use_id}.jsonl. Under make ci's coverage overhead, wait_for_uses() could observe the gap and return empty completed. Reordered the two ops so the terminal file exists before the active marker is removed — matches the real production invariant relied on by _find_use_file(). Co-authored-by: Codex --- tests/test_cortex_client.py | 2 +- tests/test_entity_intelligence.py | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/test_cortex_client.py b/tests/test_cortex_client.py index 34b228c0d..975f61b36 100644 --- a/tests/test_cortex_client.py +++ b/tests/test_cortex_client.py @@ -602,8 +602,8 @@ def test_wait_for_agents_missed_event_recovery(tmp_path, monkeypatch, caplog): def wait_and_complete(): # Wait a bit then "complete" the agent by renaming file time.sleep(0.3) - (unified_dir / f"{use_id}_active.jsonl").unlink() (unified_dir / f"{use_id}.jsonl").write_text('{"event": "finish"}\n') + (unified_dir / f"{use_id}_active.jsonl").unlink() completer = threading.Thread(target=wait_and_complete) completer.start() diff --git a/tests/test_entity_intelligence.py b/tests/test_entity_intelligence.py index 93eaf53dc..ff6cb88c8 100644 --- a/tests/test_entity_intelligence.py +++ b/tests/test_entity_intelligence.py @@ -1,21 +1,19 @@ # SPDX-License-Identifier: AGPL-3.0-only # Copyright (c) 2026 sol pbc -import os - import pytest from think.indexer.journal import ( get_entity_intelligence, get_entity_strength, + scan_journal, search_entities, ) @pytest.fixture(autouse=True) -def fixture_journal(): - os.environ["_SOLSTONE_JOURNAL_OVERRIDE"] = "tests/fixtures/journal" - yield +def indexed_journal(journal_copy): + scan_journal(str(journal_copy), full=True) class TestEntityStrength: -- 2.51.2