Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

fix(mcp): stop searches waiting 30s for a readiness signal nothing tracks (#3115)

Raghav Chamadiyafcb843f59b22
diff --git a/packages/core/src/repowise/core/workspace/registry.py b/packages/core/src/repowise/core/workspace/registry.py
index 8a9639793..903da2500 100644
--- a/packages/core/src/repowise/core/workspace/registry.py
+++ b/packages/core/src/repowise/core/workspace/registry.py
@@ -36,7 +36,8 @@ class RepoContext:
fts: Any # FullTextSearch
vector_store: Any # LanceDB or InMemoryVectorStore
decision_store: Any # LanceDB or InMemoryVectorStore
- vector_store_ready: asyncio.Event = field(default_factory=asyncio.Event)
+ # None: readiness is not tracked, so searches do not wait for it.
+ vector_store_ready: asyncio.Event | None = field(default_factory=asyncio.Event)
_engine: Any = field(default=None, repr=False) # AsyncEngine, for dispose
diff --git a/packages/server/src/repowise/server/mcp_server/_helpers.py b/packages/server/src/repowise/server/mcp_server/_helpers.py
index 5d5dbf15b..ed7a44a0d 100644
--- a/packages/server/src/repowise/server/mcp_server/_helpers.py
+++ b/packages/server/src/repowise/server/mcp_server/_helpers.py
@@ -182,7 +182,7 @@ async def _resolve_repo_context(repo: str | None = None) -> Any:
fts=_state._fts,
vector_store=_state._vector_store,
decision_store=_state._decision_store,
- vector_store_ready=_state._vector_store_ready or __import__("asyncio").Event(),
+ vector_store_ready=_state._vector_store_ready,
_engine=None,
)
diff --git a/tests/unit/server/mcp/test_retrieval_leg_visibility.py b/tests/unit/server/mcp/test_retrieval_leg_visibility.py
index 7ae5be295..fa30856b6 100644
--- a/tests/unit/server/mcp/test_retrieval_leg_visibility.py
+++ b/tests/unit/server/mcp/test_retrieval_leg_visibility.py
@@ -20,7 +20,7 @@ import asyncio
import pytest
from repowise.server.mcp_server import _answer_pipeline as pipeline
-from repowise.server.mcp_server._helpers import _EMBED_TIMEOUT_ENV
+from repowise.server.mcp_server._helpers import _EMBED_TIMEOUT_ENV, _VECTOR_TIMEOUT_ENV
class _Store:
@@ -92,9 +92,10 @@ async def test_an_embed_timeout_is_named_and_does_not_fail_the_call(monkeypatch)
@pytest.mark.asyncio
-async def test_a_timeout_is_distinguished_from_an_error():
+async def test_a_timeout_is_distinguished_from_an_error(monkeypatch):
"""They want different responses. A timeout is a budget problem and may
pass on a retry; an error is a broken backend and will not."""
+ monkeypatch.setenv(_VECTOR_TIMEOUT_ENV, "0.05")
ctx = _Ctx(store=_Store(search_hangs=True))
await pipeline._safe_vector_search(ctx, "q")
assert pipeline.retrieval_legs()["vector"] == "timeout"