Add benchmark results and tests for LSP graph builder and staged search

- Introduced a new benchmark results file for performance comparison on 2026-02-09.
- Added a test for LspGraphBuilder to ensure it does not expand nodes at maximum depth.
- Created a test for the staged search pipeline to validate fallback behavior when stage 1 returns empty results.
This commit is contained in:
catlog22
2026-02-09 21:43:13 +08:00
parent 4344e79e68
commit 362f354f1c
25 changed files with 2613 additions and 51 deletions

View File

@@ -0,0 +1,36 @@
from __future__ import annotations
import asyncio
from unittest.mock import AsyncMock
import pytest
from codexlens.hybrid_search.data_structures import CodeAssociationGraph, CodeSymbolNode, Range
from codexlens.lsp.lsp_graph_builder import LspGraphBuilder
@pytest.mark.asyncio
async def test_lsp_graph_builder_does_not_expand_at_max_depth() -> None:
"""Depth semantics: max_depth is the number of hops from seeds."""
builder = LspGraphBuilder(max_depth=1, max_nodes=10, max_concurrent=1, resolve_symbols=False)
bridge = AsyncMock()
bridge.get_references.side_effect = RuntimeError("should not call references")
bridge.get_call_hierarchy.side_effect = RuntimeError("should not call call hierarchy")
node = CodeSymbolNode(
id="x.py:foo:1",
name="foo",
kind="function",
file_path="x.py",
range=Range(start_line=1, start_character=1, end_line=1, end_character=1),
)
graph = CodeAssociationGraph()
visited: set[str] = set()
sem = asyncio.Semaphore(1)
# Seeds are depth=0. A node at depth==max_depth should not be expanded.
new_nodes = await builder._expand_node(node, 1, graph, bridge, visited, sem) # type: ignore[attr-defined]
assert new_nodes == []
assert node.id in visited