Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
fix(stats): one symbol count across status, dashboard, workspace and get_overview (#4367)
Raghav Chamadiya04b98f79fd0e
diff --git a/docs/reference/COMPUTED_GLOSSARY.md b/docs/reference/COMPUTED_GLOSSARY.mdindex f03a3a4ca..758495701 100644--- a/docs/reference/COMPUTED_GLOSSARY.md+++ b/docs/reference/COMPUTED_GLOSSARY.md@@ -72,6 +72,7 @@ workspace overlays, MCP responses, and CLI output.| Symbol node | Graph node for an extracted symbol. | `GraphBuilder.add_file()` | `{node_type: "symbol", kind: "function", name: "main"}` || External node | Node for third-party or unresolvable dependencies. | Import resolution paths | `external:react` || Synthetic module symbol | Symbol node for top-level calls in a file. | `GraphBuilder.add_file()` | `src/app.py::__module__` |+| Symbol count | The "symbols" figure on `repowise status`, the dashboard, workspace views and `get_overview`: one per distinct symbol id in the symbol index. An overload set counts once, and the synthetic module symbol is not counted. | `count_symbols()` | `76,924 symbols` || `defines` edge | File-to-symbol containment. | `GraphBuilder.add_file()` | `src/app.py -> src/app.py::main` || `imports` edge | File-to-file import relationship. | `GraphBuilder.build()` | `src/app.py -> src/settings.py` || `imported_names` edge payload | Names imported along an import edge. | `GraphBuilder.build()` | `["Settings", "load_config"]` |diff --git a/packages/cli/src/repowise/cli/commands/status_cmd.py b/packages/cli/src/repowise/cli/commands/status_cmd.pyindex 63b6a2c5a..feffdc1ff 100644--- a/packages/cli/src/repowise/cli/commands/status_cmd.py+++ b/packages/cli/src/repowise/cli/commands/status_cmd.py@@ -69,6 +69,7 @@ def _query_repo_counts(repo_path: Path) -> tuple[int, int]:create_session_factory,get_session,)+ from repowise.core.persistence.crud import count_symbolsfrom repowise.core.persistence.models import GraphNode, Repositoryurl = get_db_url_for_repo(repo_path)@@ -87,7 +88,6 @@ def _query_repo_counts(repo_path: Path) -> tuple[int, int]:if repo_id is None:return 0, 0- # Count file nodes and symbol nodesfile_count_result = await session.execute(sa_select(sa_func.count()).select_from(GraphNode)@@ -96,17 +96,9 @@ def _query_repo_counts(repo_path: Path) -> tuple[int, int]:GraphNode.node_type == "file",))- symbol_count_result = await session.execute(- sa_select(sa_func.count())- .select_from(GraphNode)- .where(- GraphNode.repository_id == repo_id,- GraphNode.node_type == "symbol",- )- )return (file_count_result.scalar_one(),- symbol_count_result.scalar_one(),+ await count_symbols(session, repo_id),)finally:await engine.dispose()diff --git a/packages/core/src/repowise/core/ingestion/graph/builder.py b/packages/core/src/repowise/core/ingestion/graph/builder.pyindex 71fb2a68d..5ddfb5680 100644--- a/packages/core/src/repowise/core/ingestion/graph/builder.py+++ b/packages/core/src/repowise/core/ingestion/graph/builder.py@@ -278,7 +278,7 @@ class GraphBuilder(MetricsMixin, ResolveMixin, EdgesMixin, SerializeMixin, Rehydpath,node_type="file",language=parsed.file_info.language,- symbol_count=len(parsed.symbols),+ symbol_count=parsed.symbol_count,has_error=bool(parsed.parse_errors),is_test=parsed.file_info.is_test,is_entry_point=parsed.file_info.is_entry_point,diff --git a/packages/core/src/repowise/core/ingestion/models.py b/packages/core/src/repowise/core/ingestion/models.pyindex e67bd5e29..e89a97761 100644--- a/packages/core/src/repowise/core/ingestion/models.py+++ b/packages/core/src/repowise/core/ingestion/models.py@@ -752,6 +752,12 @@ class ParsedFile:# resolution tiers. They become ``references`` edges, not ``calls``.references: list[CallSite] = field(default_factory=list)+ @property+ def symbol_count(self) -> int:+ """Distinct symbols. An overload set or a re-declaration shares one id,+ and the graph and ``wiki_symbols`` both store it once."""+ return len({sym.id for sym in self.symbols})+def symbol_id_language(parsed_files: dict[str, ParsedFile], symbol_id: str) -> str | None:"""Language of the file a symbol ID belongs to, or ``None`` if unparsed.diff --git a/packages/core/src/repowise/core/persistence/crud/external_systems.py b/packages/core/src/repowise/core/persistence/crud/external_systems.pyindex 96f66886d..21f89ad0e 100644--- a/packages/core/src/repowise/core/persistence/crud/external_systems.py+++ b/packages/core/src/repowise/core/persistence/crud/external_systems.py@@ -8,7 +8,7 @@ from __future__ import annotationsfrom typing import Any-from sqlalchemy import select+from sqlalchemy import func, selectfrom sqlalchemy.ext.asyncio import AsyncSessionfrom ...analysis.external_systems.links import (@@ -258,6 +258,28 @@ async def batch_upsert_symbols()+async def count_symbols_by_repo(session: AsyncSession) -> dict[str, int]:+ """Indexed symbols per repository: the figure every surface calls "symbols".++ One ``wiki_symbols`` row per symbol id, so an overload set counts once, and+ the graph's per-file ``__module__`` node is not a symbol.+ """+ rows = await session.execute(+ select(WikiSymbol.repository_id, func.count(WikiSymbol.id)).group_by(+ WikiSymbol.repository_id+ )+ )+ return {repo_id: int(n) for repo_id, n in rows.all()}+++async def count_symbols(session: AsyncSession, repository_id: str) -> int:+ """:func:`count_symbols_by_repo` for one repository."""+ n = await session.scalar(+ select(func.count(WikiSymbol.id)).where(WikiSymbol.repository_id == repository_id)+ )+ return int(n or 0)++# Chunk size for the scoped existence SELECT — stays under SQLite's# host-parameter limit when a wide catch-up update touches many files._SYMBOL_RECONCILE_CHUNK = 400diff --git a/packages/core/src/repowise/core/pipeline/_run/index.py b/packages/core/src/repowise/core/pipeline/_run/index.pyindex 108cf8073..c4d533828 100644--- a/packages/core/src/repowise/core/pipeline/_run/index.py+++ b/packages/core/src/repowise/core/pipeline/_run/index.py@@ -174,7 +174,7 @@ def _emit_index_summary(run: PipelineRun) -> None:progress.on_message("info",f"→ {len(run.parsed_files):,} files parsed · "- f"{sum(len(pf.symbols) for pf in run.parsed_files):,} symbols extracted",+ f"{sum(pf.symbol_count for pf in run.parsed_files):,} symbols extracted",)progress.on_message("info",diff --git a/packages/core/src/repowise/core/pipeline/orchestrator.py b/packages/core/src/repowise/core/pipeline/orchestrator.pyindex 25cdd4ff2..a0207cced 100644--- a/packages/core/src/repowise/core/pipeline/orchestrator.py+++ b/packages/core/src/repowise/core/pipeline/orchestrator.py@@ -317,7 +317,7 @@ def _build_result(run: PipelineRun) -> PipelineResult:file_infos = run.file_infosparsed_files = run.parsed_fileslanguages = {fi.language for fi in file_infos if hasattr(fi, "language") and fi.language}- symbol_count = sum(len(pf.symbols) for pf in parsed_files)+ symbol_count = sum(pf.symbol_count for pf in parsed_files)resume_controller = run.resume_controllerreturn PipelineResult(diff --git a/packages/core/src/repowise/core/stats_highlights.py b/packages/core/src/repowise/core/stats_highlights.pyindex 349cd0d51..a0d582f83 100644--- a/packages/core/src/repowise/core/stats_highlights.py+++ b/packages/core/src/repowise/core/stats_highlights.py@@ -147,20 +147,17 @@ def _ranked_languages(counts: Counter[str]) -> list[dict[str, Any]]:return [{"language": lang, "file_count": n} for lang, n in ranked]-def build_scale(file_nodes: Iterable[Row], metrics: Iterable[Row]) -> dict[str, Any]:+def build_scale(+ file_nodes: Iterable[Row], metrics: Iterable[Row], symbol_count: int+) -> dict[str, Any]:"""Counts and NLOC, plus the :func:`file_mix` languages and module count.``file_nodes`` are graph file nodes; external dependency nodes are dropped- so the file count describes the repo.+ so the file count describes the repo. ``symbol_count`` is+ ``crud.count_symbols``, the figure every other surface shows."""file_nodes = list(file_nodes)- file_count = 0- symbol_count = 0- for node in file_nodes:- if _is_external(node):- continue- file_count += 1- symbol_count += _int(node.get("symbol_count"))+ file_count = sum(1 for node in file_nodes if not _is_external(node))total_nloc = 0test_nloc = 0diff --git a/packages/core/src/repowise/core/workspace/update/repo.py b/packages/core/src/repowise/core/workspace/update/repo.pyindex 067a73709..f93c15def 100644--- a/packages/core/src/repowise/core/workspace/update/repo.py+++ b/packages/core/src/repowise/core/workspace/update/repo.py@@ -248,7 +248,7 @@ async def _incremental_repo_update(alias=alias,updated=True,file_count=file_count,- symbol_count=sum(len(pf.symbols) for pf in parsed_files),+ symbol_count=sum(pf.symbol_count for pf in parsed_files),kg_state=_export_kg_state(repo_path, alias, kg),working_tree_paths=working_tree_paths,git_history_refreshed=bool(full_git_summaries) and "Git persist" not in failed_steps,diff --git a/packages/server/src/repowise/server/mcp_server/tool_overview/workspace.py b/packages/server/src/repowise/server/mcp_server/tool_overview/workspace.pyindex 846982467..1a6016fba 100644--- a/packages/server/src/repowise/server/mcp_server/tool_overview/workspace.py+++ b/packages/server/src/repowise/server/mcp_server/tool_overview/workspace.py@@ -8,6 +8,7 @@ from sqlalchemy import func as sa_funcfrom sqlalchemy import selectfrom repowise.core.ingestion.languages.registry import REGISTRY+from repowise.core.persistence.crud import count_symbolsfrom repowise.core.persistence.crud.analysis.health.metrics import count_health_filesfrom repowise.core.persistence.database import get_sessionfrom repowise.core.persistence.models import GraphNode@@ -62,7 +63,7 @@ async def _repo_entry(ctx: Any, registry: Any) -> dict[str, Any]:"path": str(ctx.path),"summary": _lead_sentence(ov_content),"code_files": await _code_files(session, repo_obj.id),- "symbol_count": await _count_nodes(session, repo_obj.id, "symbol"),+ "symbol_count": await count_symbols(session, repo_obj.id),"is_default": registry is not None and ctx.alias == registry.get_default_alias(),}@@ -103,18 +104,6 @@ async def _code_files(session: Any, repository_id: str) -> int:return result.scalar_one()-async def _count_nodes(session: Any, repository_id: str, node_type: str) -> int:- result = await session.execute(- select(sa_func.count())- .select_from(GraphNode)- .where(- GraphNode.repository_id == repository_id,- GraphNode.node_type == node_type,- )- )- return result.scalar_one()--def _cross_repo_topology(repos_info: list[dict[str, Any]]) -> dict[str, Any]:"""Cross-repo summary and contracts; also tags each repo with the repos it depends on."""enricher = _enricher_with_data()diff --git a/packages/server/src/repowise/server/routers/_repo_summary.py b/packages/server/src/repowise/server/routers/_repo_summary.pyindex 9d5158da8..abad6a15b 100644--- a/packages/server/src/repowise/server/routers/_repo_summary.py+++ b/packages/server/src/repowise/server/routers/_repo_summary.py@@ -13,6 +13,7 @@ from sqlalchemy import case, func, selectfrom sqlalchemy.exc import SQLAlchemyErrorfrom sqlalchemy.ext.asyncio import AsyncSession+from repowise.core.persistence.crud import count_symbols_by_repofrom repowise.core.persistence.crud.analysis.shown import ungatedfrom repowise.core.persistence.models import (DeadCodeFinding,@@ -39,25 +40,22 @@ async def _file_figures(session: AsyncSession) -> _Figures:select(GraphNode.repository_id,func.count(GraphNode.id),- func.coalesce(func.sum(GraphNode.symbol_count), 0),_fresh_case(GraphNode.is_entry_point, True),).where(GraphNode.node_type == "file").group_by(GraphNode.repository_id))return [- (- repo_id,- {- "file_count": int(files or 0),- "symbol_count": int(symbols or 0),- "entry_point_count": int(entries or 0),- },- )- for repo_id, files, symbols, entries in result.all()+ (repo_id, {"file_count": int(files or 0), "entry_point_count": int(entries or 0)})+ for repo_id, files, entries in result.all()]+async def _symbol_figures(session: AsyncSession) -> _Figures:+ counts = await count_symbols_by_repo(session)+ return [(repo_id, {"symbol_count": n}) for repo_id, n in counts.items()]++async def _page_figures(session: AsyncSession) -> _Figures:# Documentation pages and the fresh subset. Never selects `content`.result = await session.execute(@@ -134,6 +132,7 @@ async def _health_figures(session: AsyncSession) -> _Figures:_SECTIONS = (_file_figures,+ _symbol_figures,_page_figures,_dead_export_figures,_hotspot_figures,diff --git a/packages/server/src/repowise/server/routers/repos.py b/packages/server/src/repowise/server/routers/repos.pyindex 408434b96..3ddde678d 100644--- a/packages/server/src/repowise/server/routers/repos.py+++ b/packages/server/src/repowise/server/routers/repos.py@@ -394,13 +394,7 @@ async def get_repo_stats(),0,)- symbol_count = int(- await _scalar_or(- session,- select(func.sum(GraphNode.symbol_count)).where(GraphNode.repository_id == repo_id),- 0,- )- )+ symbol_count = await crud.count_symbols(session, repo_id)entry_point_count = await _scalar_or(session,select(func.count(GraphNode.id)).where(diff --git a/packages/server/src/repowise/server/routers/stats.py b/packages/server/src/repowise/server/routers/stats.pyindex 649dac06b..7b9b5689d 100644--- a/packages/server/src/repowise/server/routers/stats.py+++ b/packages/server/src/repowise/server/routers/stats.py@@ -179,7 +179,6 @@ async def stats_highlights(select(GraphNode.node_id,GraphNode.language,- GraphNode.symbol_count,GraphNode.external_system_id,).where(GraphNode.repository_id == repo_id, GraphNode.node_type == "file"),)@@ -247,7 +246,7 @@ async def stats_highlights(index_size = await index_storage_bytes(repo.local_path)return {"repo": {"id": repo.id, "name": repo.name},- "scale": sh.build_scale(file_nodes, metrics),+ "scale": sh.build_scale(file_nodes, metrics, await crud.count_symbols(session, repo_id)),"origin": activity["origin"],"churn": sh.build_churn(totals),"rhythm": rhythm,diff --git a/packages/server/src/repowise/server/routers/workspace.py b/packages/server/src/repowise/server/routers/workspace.pyindex 27c1fa782..03fd1b67a 100644--- a/packages/server/src/repowise/server/routers/workspace.py+++ b/packages/server/src/repowise/server/routers/workspace.py@@ -162,8 +162,8 @@ def _query_repo_stats(db_path: Path) -> dict:row = c.execute("SELECT COUNT(*) FROM graph_nodes WHERE node_type = 'file'").fetchone()result["file_count"] = row[0] if row else 0- # symbol count- row = c.execute("SELECT COALESCE(SUM(symbol_count), 0) FROM graph_nodes").fetchone()+ # The raw-sqlite form of crud.count_symbols: one store per repo here.+ row = c.execute("SELECT COUNT(*) FROM wiki_symbols").fetchone()result["symbol_count"] = int(row[0]) if row else 0# page countdiff --git a/packages/server/src/repowise/server/services/overview_payload.py b/packages/server/src/repowise/server/services/overview_payload.pyindex 3be91fcf4..0cc49acab 100644--- a/packages/server/src/repowise/server/services/overview_payload.py+++ b/packages/server/src/repowise/server/services/overview_payload.py@@ -95,12 +95,7 @@ async def stat_strip(session: AsyncSession, repo_id: str) -> dict:GraphNode.repository_id == repo_id, GraphNode.node_type == "file"),)- symbol_count = int(- await session.scalar(- select(func.sum(GraphNode.symbol_count)).where(GraphNode.repository_id == repo_id)- )- or 0- )+ symbol_count = await crud.count_symbols(session, repo_id)entry_point_count = await _count(session,select(func.count(GraphNode.id)).where(diff --git a/tests/unit/ingestion/test_graph.py b/tests/unit/ingestion/test_graph.pyindex d8f3a93e0..a0a961598 100644--- a/tests/unit/ingestion/test_graph.py+++ b/tests/unit/ingestion/test_graph.py@@ -118,6 +118,17 @@ class TestAddFile:# 2 file nodes + 2 synthetic __module__ symbol nodesassert g.number_of_nodes() == 4+ def test_symbol_count_counts_an_overload_set_once(self) -> None:+ """Two overload signatures and the implementation share one id, one node."""+ b = GraphBuilder()+ parsed = _parsed("src/pages.ts", "typescript")+ parsed.symbols = [_sym("src/pages.ts", "get") for _ in range(3)]+ parsed.symbols.append(_sym("src/pages.ts", "put"))+ b.add_file(parsed)+ g = b.graph()+ assert g.nodes["src/pages.ts"]["symbol_count"] == 2+ assert parsed.symbol_count == 2+# ---------------------------------------------------------------------------# Docstring propagationdiff --git a/tests/unit/persistence/helpers.py b/tests/unit/persistence/helpers.pyindex 12515f6bc..513434b76 100644--- a/tests/unit/persistence/helpers.py+++ b/tests/unit/persistence/helpers.py@@ -6,7 +6,20 @@ from any test file without conftest import restrictions.from __future__ import annotations-from repowise.core.persistence.models import Repository+from repowise.core.persistence.models import Repository, WikiSymbol+++def make_wiki_symbol(repo_id: str, file_path: str, name: str, **overrides) -> WikiSymbol:+ """One symbol index row, the rows ``crud.count_symbols`` counts."""+ return WikiSymbol(+ repository_id=repo_id,+ file_path=file_path,+ symbol_id=f"{file_path}::{name}",+ name=name,+ qualified_name=name,+ kind="function",+ **overrides,+ )def make_repo_kwargs(**overrides) -> dict:diff --git a/tests/unit/server/test_overview_summary_golden.py b/tests/unit/server/test_overview_summary_golden.pyindex 62f7e3d10..077755a29 100644--- a/tests/unit/server/test_overview_summary_golden.py+++ b/tests/unit/server/test_overview_summary_golden.py@@ -23,6 +23,7 @@ from repowise.core.persistence.models import (GraphNode,HealthFileMetric,Page,+ WikiSymbol,)from tests.unit.server.conftest import (assert_payload_golden,@@ -60,6 +61,21 @@ async def _seed_index(session_factory, repo_id: str) -> None:created_at=_CLOCK,))+ # The symbol index the stat strip counts, matching each file's count.+ for j in range(i + 2):+ session.add(+ WikiSymbol(+ id=f"ws{i}_{j}",+ repository_id=repo_id,+ file_path=path,+ symbol_id=f"{path}::sym{j}",+ name=f"sym{j}",+ qualified_name=f"sym{j}",+ kind="function",+ created_at=_CLOCK,+ updated_at=_CLOCK,+ )+ )for i, (path, owner, hotspot, churn) in enumerate([("src/core.py", "Alice", True, 0.95),diff --git a/tests/unit/server/test_repos.py b/tests/unit/server/test_repos.pyindex 63ddaf4b9..90041cd0c 100644--- a/tests/unit/server/test_repos.py+++ b/tests/unit/server/test_repos.py@@ -213,28 +213,37 @@ async def test_stats_file_count_excludes_symbol_nodes(client: AsyncClient, sessi"""from repowise.core.persistence.crud import upsert_repositoryfrom repowise.core.persistence.models import GraphNode+ from tests.unit.persistence.helpers import make_wiki_symbolrepo = await upsert_repository(session, name="counts", local_path="/tmp/counts")for i in range(2):+ # The parser emitted an overload pair: 6 emissions, 5 distinct symbols.+ # The stored per-file figure of a pre-dedupe index still says 6.session.add(GraphNode(repository_id=repo.id,node_id=f"src/mod{i}.py",node_type="file",- symbol_count=5,+ symbol_count=6,))- for j in range(5):+ for name in [f"sym{j}" for j in range(5)] + ["__module__"]:session.add(GraphNode(repository_id=repo.id,- node_id=f"src/mod{i}.py::sym{j}",+ node_id=f"src/mod{i}.py::{name}",node_type="symbol",))+ session.add_all(make_wiki_symbol(repo.id, f"src/mod{i}.py", f"sym{j}") for j in range(5))await session.commit()data = (await client.get(f"/api/repos/{repo.id}/stats")).json()+ overview = (await client.get(f"/api/repos/{repo.id}/overview-summary")).json()+ symbols = (await client.get("/api/symbols", params={"repo_id": repo.id})).json()- assert data["file_count"] == 2 # not 12+ assert data["file_count"] == 2 # not 14+ # One figure, the symbol index's row count: not 12 symbol nodes, not 12 emissions.assert data["symbol_count"] == 10+ assert overview["stats"]["symbol_count"] == 10+ assert symbols["total"] == 10diff --git a/tests/unit/server/test_repos_router_paths.py b/tests/unit/server/test_repos_router_paths.pyindex 6c2ab4bf7..69509ee99 100644--- a/tests/unit/server/test_repos_router_paths.py+++ b/tests/unit/server/test_repos_router_paths.py@@ -26,6 +26,7 @@ from repowise.core.persistence.database import get_session, init_dbfrom repowise.core.persistence.models import GraphNode, HealthFileMetric, Repositoryfrom repowise.core.workspace.config import RepoEntry, WorkspaceConfigfrom repowise.server.routers import repos as repos_module+from tests.unit.persistence.helpers import make_wiki_symbolfrom tests.unit.server.conftest import create_test_repo@@ -406,6 +407,8 @@ async def test_stats_counts(client: AsyncClient, session) -> None:symbol_count=0,is_entry_point=True,),+ make_wiki_symbol(repo["id"], "a.py", "f"),+ make_wiki_symbol(repo["id"], "a.py", "g"),])await session.commit()diff --git a/tests/unit/server/test_repos_summary.py b/tests/unit/server/test_repos_summary.pyindex cae38b66b..74fdf2317 100644--- a/tests/unit/server/test_repos_summary.py+++ b/tests/unit/server/test_repos_summary.py@@ -22,7 +22,7 @@ from repowise.core.persistence.models import (GraphNode,HealthSnapshot,)-from tests.unit.persistence.helpers import make_page_kwargs+from tests.unit.persistence.helpers import make_page_kwargs, make_wiki_symbolasync def _register(client: AsyncClient, name: str) -> dict:@@ -51,16 +51,20 @@ async def _seed(session, repo_id: str, *, files: int, symbols_per_file: int = 3)))# Symbol nodes share the table with file nodes. They are what makes the- # unscoped count wrong, so every fixture carries some.- for j in range(symbols_per_file):+ # unscoped count wrong, so every fixture carries some, plus the per-file+ # synthetic `__module__` node, which is not a symbol.+ for name in [f"sym{j}" for j in range(symbols_per_file)] + ["__module__"]:session.add(GraphNode(repository_id=repo_id,- node_id=f"src/mod{i}.py::sym{j}",+ node_id=f"src/mod{i}.py::{name}",node_type="symbol",symbol_count=0,))+ session.add_all(+ make_wiki_symbol(repo_id, f"src/mod{i}.py", f"sym{j}") for j in range(symbols_per_file)+ )session.add(GitMetadata(repository_id=repo_id,@@ -133,8 +137,8 @@ async def test_file_count_excludes_symbol_nodes(client: AsyncClient, session) ->assert resp.status_code == 200row = resp.json()["repos"][0]- assert row["file_count"] == 4 # not 16- assert row["symbol_count"] == 12+ assert row["file_count"] == 4 # not 20+ assert row["symbol_count"] == 12 # not 16: `__module__` nodes are not symbolsassert row["entry_point_count"] == 1@@ -254,10 +258,10 @@ async def test_query_count_does_not_grow_with_repo_count(f"query count grew from {two_repos} (2 repos) to {six_repos} (6 repos) — ""something in the route is running per repository again")- # One repo list plus five grouped aggregates. Pinned so "flat" has a value:+ # One repo list plus six grouped aggregates. Pinned so "flat" has a value:# a change that merges or splits an aggregate should be a deliberate edit# here, not a silent drift.- assert six_repos == 6+ assert six_repos == 7async def _count_queries(client: AsyncClient, statements: list[str]) -> list[str]:diff --git a/tests/unit/server/test_stats_superlatives.py b/tests/unit/server/test_stats_superlatives.pyindex a1be968ad..44d8ea42b 100644--- a/tests/unit/server/test_stats_superlatives.py+++ b/tests/unit/server/test_stats_superlatives.py@@ -116,9 +116,9 @@ def test_scale_counts_code_languages_and_skips_external_nodes() -> None:{"nloc": 100, "module": "a", "is_test": False},{"nloc": 40, "module": "tests", "is_test": True},]- scale = build_scale(nodes, metrics)+ scale = build_scale(nodes, metrics, symbol_count=4)assert scale["file_count"] == 3- assert scale["symbol_count"] == 5+ assert scale["symbol_count"] == 4 # passed in, not the per-file sumassert scale["language_count"] == 2assert {lang["language"] for lang in scale["languages"]} == {"python", "typescript"}assert scale["total_nloc"] == 140diff --git a/tests/unit/server/test_workspace_router.py b/tests/unit/server/test_workspace_router.pyindex 5361f7c4a..d1f97c884 100644--- a/tests/unit/server/test_workspace_router.py+++ b/tests/unit/server/test_workspace_router.py@@ -247,6 +247,7 @@ def _create_workspace_repo_db(symbol_count INTEGER DEFAULT 0);CREATE TABLE wiki_pages (id TEXT PRIMARY KEY, confidence REAL);+ CREATE TABLE wiki_symbols (id TEXT PRIMARY KEY);CREATE TABLE git_metadata (id TEXT PRIMARY KEY,churn_percentile REAL,@@ -265,6 +266,7 @@ def _create_workspace_repo_db(('src/a.py::Foo', 'symbol', 'python', 0),('src/a.py::Foo.bar', 'symbol', 'python', 0),('src/b.py::baz', 'symbol', 'python', 0);+ INSERT INTO wiki_symbols (id) VALUES ('sym-foo'), ('sym-bar'), ('sym-baz');INSERT INTO wiki_pages (id, confidence) VALUES('page-a', 0.8),('page-b', 0.6);@@ -945,6 +947,7 @@ class TestQueryRepoStats:symbol_count INTEGER DEFAULT 0);CREATE TABLE wiki_pages (id TEXT PRIMARY KEY, confidence REAL);+ CREATE TABLE wiki_symbols (id TEXT PRIMARY KEY);CREATE TABLE git_metadata (id TEXT PRIMARY KEY,is_hotspot INTEGER NOT NULL DEFAULT 0,@@ -982,6 +985,15 @@ class TestQueryRepoStats:assert stats["hotspot_count"] == 2+ def test_symbol_count_is_the_symbol_index(self, tmp_path: Path) -> None:+ """The figure `/api/repos/{id}/stats` reports: symbol index rows, not+ the per-file emission counts (5 here)."""+ _create_workspace_repo_db(tmp_path, "backend")++ stats = workspace._query_repo_stats(tmp_path / "backend" / ".repowise" / "wiki.db")++ assert stats["symbol_count"] == 3+def test_hotspot_count_zero_when_no_hotspots(self, tmp_path: Path) -> None:db_path = tmp_path / ".repowise" / "wiki.db"self._make_wiki_db(db_path, rows=[(0, 0.99), (0, 0.80)])