[loop-generated] [bug] test_cache_hit_skips_vlm times out on main (43s > 30s limit) #1336

Closed
opened 2026-03-24 02:36:43 +00:00 by Timmy · 2 comments
Owner

Bug

tests/sovereignty/test_sovereignty_loop.py::TestSovereignPerceive::test_cache_hit_skips_vlm times out consistently on main.

Evidence

43.24s call tests/sovereignty/test_sovereignty_loop.py::TestSovereignPerceive::test_cache_hit_skips_vlm
FAILED: Timeout (>30.0s) from pytest-timeout.

Analysis

This test is supposed to test a cache HIT (fast path) but runs for 43 seconds. Either:

  1. The mock is not properly short-circuiting the VLM call
  2. There is an unintended blocking I/O call
  3. The test needs a shorter timeout annotation

Files

  • tests/sovereignty/test_sovereignty_loop.py
  • src/timmy/sovereignty/ (perception cache logic)

Priority

High — this blocks CI green on main. 753 tests pass, only this 1 fails.

## Bug `tests/sovereignty/test_sovereignty_loop.py::TestSovereignPerceive::test_cache_hit_skips_vlm` times out consistently on main. ## Evidence ``` 43.24s call tests/sovereignty/test_sovereignty_loop.py::TestSovereignPerceive::test_cache_hit_skips_vlm FAILED: Timeout (>30.0s) from pytest-timeout. ``` ## Analysis This test is supposed to test a cache HIT (fast path) but runs for 43 seconds. Either: 1. The mock is not properly short-circuiting the VLM call 2. There is an unintended blocking I/O call 3. The test needs a shorter timeout annotation ## Files - `tests/sovereignty/test_sovereignty_loop.py` - `src/timmy/sovereignty/` (perception cache logic) ## Priority High — this blocks CI green on main. 753 tests pass, only this 1 fails.
kimi was assigned by Timmy 2026-03-24 02:36:43 +00:00
Author
Owner

Kimi Instructions

Files to investigate

  • tests/sovereignty/test_sovereignty_loop.py (line 16-37)
  • src/timmy/sovereignty/sovereignty_loop.py (the sovereign_perceive function)

What to do

  1. Run the failing test in isolation: tox -e unit -- tests/sovereignty/test_sovereignty_loop.py::TestSovereignPerceive::test_cache_hit_skips_vlm -v
  2. The test mocks are correct — AsyncMock for VLM, MagicMock for cache. The timeout suggests sovereign_perceive is doing something blocking that is not mocked.
  3. Look at sovereign_perceive() — find any I/O, network call, or heavy import that runs before the cache check.
  4. Fix by either:
    a. Adding missing mocks/patches in the test
    b. Adding @pytest.mark.timeout(10) if the function genuinely needs time
    c. Fixing the function itself if it has unnecessary blocking calls
  5. Verify: tox -e unit must pass (753+ pass, 0 fail)

Branch

fix/issue-1336-sovereignty-test-timeout

## Kimi Instructions ### Files to investigate - `tests/sovereignty/test_sovereignty_loop.py` (line 16-37) - `src/timmy/sovereignty/sovereignty_loop.py` (the `sovereign_perceive` function) ### What to do 1. Run the failing test in isolation: `tox -e unit -- tests/sovereignty/test_sovereignty_loop.py::TestSovereignPerceive::test_cache_hit_skips_vlm -v` 2. The test mocks are correct — AsyncMock for VLM, MagicMock for cache. The timeout suggests `sovereign_perceive` is doing something blocking that is not mocked. 3. Look at `sovereign_perceive()` — find any I/O, network call, or heavy import that runs before the cache check. 4. Fix by either: a. Adding missing mocks/patches in the test b. Adding `@pytest.mark.timeout(10)` if the function genuinely needs time c. Fixing the function itself if it has unnecessary blocking calls 5. Verify: `tox -e unit` must pass (753+ pass, 0 fail) ### Branch `fix/issue-1336-sovereignty-test-timeout`
Timmy closed this issue 2026-03-24 02:56:20 +00:00
Collaborator

PR #1356 created to fix this issue.

Summary of changes:

  • Added "cv2" to the stubbed modules list in tests/conftest.py

Root cause: perception_cache.py imports cv2 (OpenCV) at the module level. When tests run in parallel with pytest-xdist, the cv2 import can hang/deadlock, causing the 30-second timeout.

Fix: By stubbing cv2 in conftest.py, tests get a MagicMock instead of the real cv2, avoiding the import hang.

Verification: All 812 unit tests now pass (previously 1 failed with timeout).

PR #1356 created to fix this issue. **Summary of changes:** - Added `"cv2"` to the stubbed modules list in `tests/conftest.py` **Root cause:** `perception_cache.py` imports `cv2` (OpenCV) at the module level. When tests run in parallel with pytest-xdist, the cv2 import can hang/deadlock, causing the 30-second timeout. **Fix:** By stubbing cv2 in conftest.py, tests get a MagicMock instead of the real cv2, avoiding the import hang. **Verification:** All 812 unit tests now pass (previously 1 failed with timeout).
Sign in to join this conversation.
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Rockachopa/Timmy-time-dashboard#1336