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
feat(search): give every result row one path field (#3019)
Raghav Chamadiya8ce1bac6feee
diff --git a/docs/agent/MCP_TOOLS.md b/docs/agent/MCP_TOOLS.mdindex 9be46ece7..f570a2ce7 100644--- a/docs/agent/MCP_TOOLS.md+++ b/docs/agent/MCP_TOOLS.md@@ -212,7 +212,7 @@ Hybrid search that routes by the shape of the query: identifiers search the symb| `page_type` | string | none | One page type, usually `file_page` or `module_page` || `repo` | string | default repo | Workspace repo alias, or `"all"` to search every repo |-**Key return fields:** `results` (symbol hits carry `symbol_id`, `file`, line bounds and `signature`, plus `symbols` (`name:line` of up to five other matches in that file, then `+N more`) when several matched; file hits carry `file`; concept hits carry `relevance_score`, `snippet` and `sources`), `candidates` (up to `limit` distinct openable file paths, best first). If your next move is a Read, read `candidates`: some `results` are pages that are not files.+**Key return fields:** `results` (every row that names a file carries it in `path`, and a row naming no file has no `path`; symbol hits carry `symbol_id`, line bounds and `signature`, plus `symbols` (`name:line` of up to five other matches in that file, then `+N more`) when several matched; concept hits carry `relevance_score`, `snippet` and `sources`; `file` on symbol and file hits is a deprecated alias of `path`, removed in the next minor release, and a page keeps `target_path` only where it differs from `path`), `candidates` (up to `limit` distinct openable file paths, best first). If your next move is a Read, read `candidates`: some `results` are pages that are not files.```search_codebase(query="GitIndexer index_repo")diff --git a/docs/reference/MCP_RESPONSE_FIELDS.md b/docs/reference/MCP_RESPONSE_FIELDS.mdindex d51785a13..962aee30c 100644--- a/docs/reference/MCP_RESPONSE_FIELDS.md+++ b/docs/reference/MCP_RESPONSE_FIELDS.md@@ -174,14 +174,17 @@ Opt-in blocks: `full_doc`, `ownership` (primary owner, bus factor, contributor c| Field | Meaning ||-------|---------|-| `results` | Ranked hits. Symbol hits: `type: "symbol"`, `symbol_id`, `name`, `kind`, `file`, `start_line`, `end_line`, `signature`, `next: "get_symbol"`. File hits: `type: "file"`, `page_id`, `file`, `title`, `next: "get_context"`. Concept hits: wiki pages with `relevance_score`, `snippet`, `target_path`, `sources` |+| `results` | Ranked hits. Symbol hits: `type: "symbol"`, `symbol_id`, `name`, `kind`, `path`, `start_line`, `end_line`, `signature`, `next: "get_symbol"`. File hits: `type: "file"`, `page_id`, `path`, `title`, `next: "get_context"`. Concept hits: wiki pages with `page_type`, `path` when the page names a file, `relevance_score`, `snippet`, `sources` |+| `path` | The repo-relative file a row names, openable as is. Absent when the row names no file (a module page's group key, an onboarding slot, the repo overview); never a page id |+| `file` | Deprecated alias of `path` on symbol and file hits (and on a `symbol_spotlight` page). Removed in the next minor release |+| `target_path` | On a page hit, kept only where it is not the same string as `path`: a page with no `path` keeps its group key, slot or repo name here. Where it is dropped, `page_id` stays || `symbols` | On a symbol hit outside `symbol` mode: up to five other matching symbols in the same file, as `name:line`, then a `+N more` entry counting the rest. Those matches share the row instead of taking slots of their own || `sources` | The retrievers that found a concept hit: `fts`, `vector`, or both. A hit found by `fts` alone has no semantic agreement || `candidates` | Up to `limit` distinct openable file paths, best first |Outside `mode="symbol"`, `limit` caps distinct files: hits are collapsed to one row per file, best row first, and the freed slots go to the next pages, then the next symbols. This includes concept mode, where a file page and a `symbol_spotlight` page of the same file are one row. `mode="symbol"` keeps one row per symbol, so overloads in one file each list.-Symbol hits rank by exact and qualified name match, query-token coverage, then graph centrality; non-test before test unless `kind="test"`. A `symbol_spotlight` page's `target_path` is a page id (`file.py::Symbol`); open its `file`.+Symbol hits rank by exact and qualified name match, query-token coverage, then graph centrality; non-test before test unless `kind="test"`. A `symbol_spotlight` page's id is `file.py::Symbol`; its `path` is the file.`results` ranks pages, and some pages are not files: a `module_page` is named by a group key that looks like a directory, an `scc_page` by a hash. `candidates` resolves symbol pages to their file, collapses several symbols of one file into one entry, skips pages that name no file, and backfills from below the result window. If the next move is a Read, read `candidates`. A hybrid query (prose around an identifier) drops pages that name no file (module, onboarding, overview, decision pages) from `results` without refilling their slots, unless `page_type` or `kind="doc"` asks for pages; concept mode keeps them. Decision records rank below file pages unless the query is why-shaped.diff --git a/packages/cli/src/repowise/cli/commands/search_cmd.py b/packages/cli/src/repowise/cli/commands/search_cmd.pyindex 15167007c..4490e5662 100644--- a/packages/cli/src/repowise/cli/commands/search_cmd.py+++ b/packages/cli/src/repowise/cli/commands/search_cmd.py@@ -103,19 +103,20 @@ def _project_result(item: dict, *, multi: bool) -> dict:"name": item.get("name") or "","qualified_name": item.get("qualified_name") or "","kind": item.get("kind") or "",- "path": item.get("file") or "",+ "path": item.get("path") or item.get("file") or "","line": item.get("start_line"),"symbol_id": item.get("symbol_id") or "",})elif kind == "file":- out.update({"title": item.get("title") or "", "path": item.get("file") or ""})+ path = item.get("path") or item.get("file") or ""+ out.update({"title": item.get("title") or "", "path": path})else:out.update({"title": item.get("title") or "","page_type": item.get("page_type") or "",- "path": item.get("target_path") or "",+ "path": item.get("path") or item.get("target_path") or "","snippet": item.get("snippet") or "",})diff --git a/packages/core/src/repowise/core/sessions/adapters/codex.py b/packages/core/src/repowise/core/sessions/adapters/codex.pyindex efcffa669..26486c014 100644--- a/packages/core/src/repowise/core/sessions/adapters/codex.py+++ b/packages/core/src/repowise/core/sessions/adapters/codex.py@@ -367,7 +367,7 @@ def _bind_first_file(tool: ToolUse, results: list[dict[str, str]]) -> None:if not isinstance(tool.input, dict) or tool.input.get("path"):returnfor result in results:- file_path = result.get("file") if isinstance(result, dict) else None+ file_path = (result.get("path") or result.get("file")) if isinstance(result, dict) else Noneif isinstance(file_path, str) and file_path:tool.input["path"] = file_pathreturn@@ -441,9 +441,13 @@ def _rewrite_search_output(output: Any) -> dict | None:continuematch = _RG_MATCH_RE.match(line)if match:- results.append({"file": match.group("path").replace("\\", "/")})+ path = match.group("path").replace("\\", "/")elif _looks_like_a_bare_path(line):- results.append({"file": line.replace("\\", "/")})+ path = line.replace("\\", "/")+ else:+ continue+ # Both keys, as search_codebase serves them while ``file`` is an alias.+ results.append({"path": path, "file": path})return {"result": {"results": results}}diff --git a/packages/core/src/repowise/core/sessions/miners/demand.py b/packages/core/src/repowise/core/sessions/miners/demand.pyindex e195d8e89..7b73034a2 100644--- a/packages/core/src/repowise/core/sessions/miners/demand.py+++ b/packages/core/src/repowise/core/sessions/miners/demand.py@@ -145,7 +145,12 @@ def _search_files(result: dict[str, Any]) -> list[str]:for item in result.get("results") or []:if not isinstance(item, dict):continue- hit = item.get("file") or item.get("target_path") or item.get("symbol_id")+ hit = (+ item.get("path")+ or item.get("file")+ or item.get("target_path")+ or item.get("symbol_id")+ )if isinstance(hit, str):files.append(hit)return filesdiff --git a/packages/server/src/repowise/server/mcp_server/_page_paths.py b/packages/server/src/repowise/server/mcp_server/_page_paths.pyindex 4c1a06882..39ab3573f 100644--- a/packages/server/src/repowise/server/mcp_server/_page_paths.py+++ b/packages/server/src/repowise/server/mcp_server/_page_paths.py@@ -67,13 +67,38 @@ def hit_file_path(hit: dict) -> str | None:it would silently lose a real file over a bookkeeping gap; so those fallback to whatever path they carry. An unrecognised type means the page washydrated and classified as naming no file, which is an answer, not a gap.++ A served row's ``path`` was written by :func:`add_row_paths` from this+ same resolution, so it is read first: the row may no longer carry the+ ``target_path`` it was resolved from."""+ if hit.get("path"):+ return hit["path"]if hit.get("page_type"):return file_path_of(hit.get("page_type"), hit.get("target_path"))raw = hit.get("file") or hit.get("target_path") or ""return raw.split("::", 1)[0].strip() or None+def add_row_paths(rows: list[dict]) -> list[dict]:+ """Give every row that names a file one ``path``, in place.++ The last step before a search response leaves. A row naming no file (a+ module page's group key, an onboarding slot) gets no ``path`` at all.+ Transition aliases until the next minor release: ``file`` stays where it+ was, and a page's ``target_path`` stays only where it is not the same+ string as ``path``.+ """+ for row in rows:+ path = hit_file_path(row)+ if not path:+ continue+ row["path"] = path+ if row.get("page_type") and row.get("target_path") == path:+ del row["target_path"]+ return rows++def file_candidates(hits: list[dict], *, limit: int) -> list[dict]:"""The distinct files *hits* resolve to, best first, one ``{path}`` each.diff --git a/packages/server/src/repowise/server/mcp_server/_savings/counterfactual.py b/packages/server/src/repowise/server/mcp_server/_savings/counterfactual.pyindex ad874470a..3c7be750d 100644--- a/packages/server/src/repowise/server/mcp_server/_savings/counterfactual.py+++ b/packages/server/src/repowise/server/mcp_server/_savings/counterfactual.py@@ -115,7 +115,13 @@ def _estimate_search_codebase(result: dict[str, Any]) -> int:results = result.get("results")if not isinstance(results, list):return 0- paths = {r["target_path"] for r in results if isinstance(r, dict) and r.get("target_path")}+ # ``path`` is on every row that names a file, symbol rows included, which+ # the old ``target_path`` read missed. Fallback for pre-``path`` payloads.+ paths = {+ r.get("path") or r.get("target_path")+ for r in results+ if isinstance(r, dict) and (r.get("path") or r.get("target_path"))+ }return len(paths) * SEARCH_FLOOR_PER_HITdiff --git a/packages/server/src/repowise/server/mcp_server/tool_search.py b/packages/server/src/repowise/server/mcp_server/tool_search.pyindex 60ac9995d..fb0446516 100644--- a/packages/server/src/repowise/server/mcp_server/tool_search.py+++ b/packages/server/src/repowise/server/mcp_server/tool_search.py@@ -39,7 +39,7 @@ from repowise.server.mcp_server._helpers import ()from repowise.server.mcp_server._meta import EXHAUSTIVE_SWEEP_HINTfrom repowise.server.mcp_server._meta import build_meta as _build_meta-from repowise.server.mcp_server._page_paths import file_candidates, hit_file_path+from repowise.server.mcp_server._page_paths import add_row_paths, file_candidates, hit_file_pathfrom repowise.server.mcp_server._prose_symbols import symbol_backed_pagesfrom repowise.server.mcp_server._query_shape import (_DECISION_DOWNWEIGHT,@@ -815,6 +815,7 @@ async def _federated_search(if candidates := file_candidates(all_results, limit=limit):response["candidates"] = candidates# Last, so nothing above has to know the field is on its way out.+ add_row_paths(output)_drop_derivable_page_ids(output)return response@@ -1080,7 +1081,9 @@ async def _structured_search()if grep_hint and not results:response["grep_hint"] = grep_hint- # Last, so nothing above has to know the field is on its way out.+ # Last, so nothing above has to know the field is on its way out. Paths+ # first, so a page whose target_path is dropped keeps its page_id.+ add_row_paths(results)_drop_derivable_page_ids(results)return response@@ -1116,14 +1119,14 @@ async def search_codebase(resolving an identifier to a symbol_id, or scoping get_context.mode="auto" (default) routes the query: identifier-shaped queries search- the indexed symbols (returns symbol_id/file/line bounds — pipe into+ the indexed symbols (returns symbol_id/path/line bounds — pipe intoget_symbol), path-shaped queries resolve files (pipe into get_context),and conceptual queries run wiki-semantic search. Mixed queries run hybrid:symbol hits first, then file-backed pages only. Decision records rankbelow file pages unless the query is why-shaped.- `candidates` lists up to `limit` distinct openable file paths, best- first: what to Read.+ Rows naming a file carry `path`; `candidates` is up to `limit`+ distinct files to Read, best first.Args:query: identifier, path, or natural language.@@ -1247,5 +1250,6 @@ async def search_codebase(response["grep_hint"] = grep_hintattach_ignored_arguments(response, ignored)# Last, so nothing above has to know the field is on its way out.+ add_row_paths(output)_drop_derivable_page_ids(output)return responsediff --git a/packages/types/src/chat.ts b/packages/types/src/chat.tsindex 37d03dbc0..6a4b8dddd 100644--- a/packages/types/src/chat.ts+++ b/packages/types/src/chat.ts@@ -388,6 +388,9 @@ export interface SearchResultsArtifactData {title: string;page_type: string;page_id?: string;+ /** Openable repo-relative file; absent when the hit names no file. */+ path?: string;+ /** Kept only where it differs from `path` or `path` is absent. */target_path?: string;snippet?: string;relevance_score?: number;diff --git a/tests/fixtures/mcp/tool_response_shapes.json b/tests/fixtures/mcp/tool_response_shapes.jsonindex 8165c6758..0fd549c8e 100644--- a/tests/fixtures/mcp/tool_response_shapes.json+++ b/tests/fixtures/mcp/tool_response_shapes.json@@ -2035,13 +2035,14 @@"results": [{"confidence_score": null,+ "page_id": null,"page_type": null,+ "path": null,"relevance_score": null,"snippet": null,"sources": [null],- "target_path": null,"title": null}]diff --git a/tests/unit/cli/test_search_collapse.py b/tests/unit/cli/test_search_collapse.pyindex 6802b8592..ed9559c9e 100644--- a/tests/unit/cli/test_search_collapse.py+++ b/tests/unit/cli/test_search_collapse.py@@ -293,6 +293,21 @@ def test_a_symbol_spotlight_hit_carries_the_openable_file_beside_its_page_id():assert row["file"] == "packages/cli/src/repowise/cli/output.py"+ "hit",+ [+ {**SYMBOL_HIT, "path": "served/sym.py", "file": "old/sym.py"},+ {**FILE_HIT, "path": "served/file.py", "file": "old/file.py"},+ {**PAGE_HIT, "path": "served/page.py", "target_path": "old/page.py"},+ ],+ ids=["symbol", "file", "page"],+)+def test_every_row_kind_prefers_the_served_path(hit):+ """``file`` and ``target_path`` are transition aliases of ``path``."""+ row = project({"results": [hit]}, "q", multi=False)["results"][0]+ assert row["path"].startswith("served/")++def test_a_plain_file_hit_does_not_carry_a_redundant_file_key():assert "file" not in project(CONCEPT_PAYLOAD, "q", multi=False)["results"][0]diff --git a/tests/unit/server/mcp/test_counterfactual.py b/tests/unit/server/mcp/test_counterfactual.pyindex 3926a33f2..6d43fb5ad 100644--- a/tests/unit/server/mcp/test_counterfactual.py+++ b/tests/unit/server/mcp/test_counterfactual.py@@ -37,6 +37,19 @@ def test_search_codebase_floors_per_distinct_cited_path() -> None:assert cf.replaced_tokens_for("search_codebase", result) == 2 * cf.SEARCH_FLOOR_PER_HIT+def test_search_codebase_counts_symbol_rows_by_path() -> None:+ """A symbol row has no target_path, so it used to earn nothing."""+ result = {+ "results": [+ {"type": "symbol", "path": "src/a.py", "file": "src/a.py"},+ {"page_type": "file_page", "path": "src/b.py"},+ {"page_type": "module_page", "target_path": "src"}, # pre-path payload shape+ ],+ "_meta": {},+ }+ assert cf.replaced_tokens_for("search_codebase", result) == 3 * cf.SEARCH_FLOOR_PER_HIT++def test_search_codebase_no_results_returns_zero() -> None:assert cf.replaced_tokens_for("search_codebase", {"results": [], "_meta": {}}) == 0diff --git a/tests/unit/server/mcp/test_search.py b/tests/unit/server/mcp/test_search.pyindex 2c1c1b642..9a7254902 100644--- a/tests/unit/server/mcp/test_search.py+++ b/tests/unit/server/mcp/test_search.py@@ -261,7 +261,7 @@ class TestDecisionDownweight:mcp_mod._vector_store.search = fake_searchresult = await search_codebase("sqlite store", limit=5, kind="implementation")- paths = [r["target_path"] for r in result["results"]]+ paths = [r["path"] for r in result["results"]]assert paths == ["src/auth/service.py"]@pytest.mark.asyncio@@ -443,7 +443,7 @@ class TestNoiseDemotion:mcp_mod._vector_store.search = fake_searchresult = await search_codebase("how does the auth service work")- paths = [r["target_path"] for r in result["results"]]+ paths = [r["path"] for r in result["results"]]assert paths[0] == "src/auth/service.py"assert "tests/unit/test_service.py" in paths # demoted, not dropped@@ -474,7 +474,7 @@ class TestNoiseDemotion:mcp_mod._vector_store.search = fake_searchresult = await search_codebase("how is the auth service tested")- assert result["results"][0]["target_path"] == "tests/unit/test_service.py"+ assert result["results"][0]["path"] == "tests/unit/test_service.py"class TestClassifyHitKind:@@ -1243,14 +1243,14 @@ class TestFusion:mcp_mod._fts.search = fake_ftsresult = await search_codebase("session cache layer", limit=10)- by_path = {r["target_path"]: r for r in result["results"]}+ by_path = {r["path"]: r for r in result["results"]}# All three surface — including the FTS-only page the old path dropped.assert {"src/both.py", "src/vec.py", "src/fts.py"} <= set(by_path)assert by_path["src/vec.py"]["sources"] == ["vector"]assert by_path["src/fts.py"]["sources"] == ["fts"]assert by_path["src/both.py"]["sources"] == ["fts", "vector"]# A page both retrievers rank #1 fuses to the top.- assert result["results"][0]["target_path"] == "src/both.py"+ assert result["results"][0]["path"] == "src/both.py"@pytest.mark.asyncioasync def test_vector_miss_falls_through_to_fts(self, setup_mcp):@@ -1274,7 +1274,7 @@ class TestFusion:mcp_mod._fts.search = fake_ftsresult = await search_codebase("session cache layer", limit=10)- by_path = {r["target_path"]: r for r in result["results"]}+ by_path = {r["path"]: r for r in result["results"]}assert by_path["src/fts_rescue.py"]["sources"] == ["fts"]@@ -1368,8 +1368,9 @@ class TestSearchCandidates:result = await search_codebase("how are requests issued", limit=10)hit = result["results"][0]- assert hit["target_path"] == "api/client.go"- assert hit["file"] == "api/client.go"+ assert hit["path"] == "api/client.go"+ assert "target_path" not in hit # same string as path+ assert hit["file"] == "api/client.go" # alias for one minor releaseassert hit["symbol_id"] == "api/client.go::HTTP"assert hit["file"] == "api/client.go"assert result["candidates"] == [{"path": "api/client.go"}]@@ -1695,6 +1696,8 @@ class TestDistinctFileWindow:ids = [r["symbol_id"] for r in res["results"]]assert ids[:2] == ["src/widget/core.py::Box.widget", "src/widget/core.py::widget"]assert all("symbols" not in r for r in res["results"])+ # Symbol rows serve path, with file as the transition alias.+ assert all(r["path"] == r["file"] == "src/widget/core.py" for r in res["results"][:2])@pytest.mark.asyncioasync def test_concept_window_serves_one_row_per_file(self, setup_mcp):@@ -1722,7 +1725,7 @@ class TestDistinctFileWindow:mcp_mod._vector_store.search = fake_searchres = await search_codebase("how are requests issued", mode="concept", limit=2)- assert [r["target_path"] for r in res["results"]] == ["api/client.go", "api/server.go"]+ assert [r["path"] for r in res["results"]] == ["api/client.go", "api/server.go"]class TestPathlessPagesInCodeLocationModes:@@ -1781,6 +1784,38 @@ class TestPathlessPagesInCodeLocationModes:"file_page",]+ @pytest.mark.asyncio+ async def test_concept_rows_carry_path_only_when_they_name_a_file(self, setup_mcp):+ """A pathless page keeps its key in target_path; a file page's moves to path."""+ from repowise.server.mcp_server import search_codebase++ await self._seed()+ res = await search_codebase("listing releases in order", mode="concept", limit=5)+ module, onboarding, file_page = res["results"]+ for pathless, key in ((module, "pkg/cmd/release"), (onboarding, "onboarding/how_it_works")):+ assert "path" not in pathless+ assert pathless["target_path"] == key+ assert file_page["path"] == "pkg/cmd/release/list.go"+ assert "target_path" not in file_page+ # Not derivable without target_path, so the id stays for citations.+ assert file_page["page_id"] == "file_page:pkg/cmd/release/list.go"++ @pytest.mark.asyncio+ async def test_federated_rows_carry_path(self, setup_mcp, monkeypatch):+ from repowise.server.mcp_server import search_codebase, tool_search++ await self._seed()+ ctx = await tool_search._resolve_repo_context(None)++ async def one_context():+ return [ctx]++ monkeypatch.setattr(tool_search, "_resolve_all_contexts", one_context)+ res = await search_codebase("listing releases in order", mode="concept", repo="all")+ by_type = {r["page_type"]: r for r in res["results"]}+ assert by_type["file_page"]["path"] == "pkg/cmd/release/list.go"+ assert "path" not in by_type["module_page"]+@pytest.mark.asyncioasync def test_an_empty_window_does_not_repeat_its_grep_hint(self, setup_mcp):import repowise.server.mcp_server as mcp_moddiff --git a/tests/unit/server/mcp/test_search_candidates.py b/tests/unit/server/mcp/test_search_candidates.pyindex 7aca4ad3e..caf5cb476 100644--- a/tests/unit/server/mcp/test_search_candidates.py+++ b/tests/unit/server/mcp/test_search_candidates.py@@ -16,6 +16,7 @@ not cost the caller a file.from __future__ import annotationsfrom repowise.server.mcp_server._page_paths import (+ add_row_paths,file_candidates,file_path_of,hit_file_path,@@ -74,6 +75,37 @@ class TestHitFilePath:assert hit_file_path(hit) is None+class TestAddRowPaths:+ """Every row naming a file gets one ``path``; the old fields stay as aliases."""++ def test_each_row_kind(self):+ symbol = {"type": "symbol", "symbol_id": "a.py::f", "file": "a.py"}+ file_row = {"type": "file", "page_id": "file_page:b.py", "file": "b.py"}+ file_page = {"page_type": "file_page", "target_path": "c.py"}+ spotlight = {+ "page_type": "symbol_spotlight",+ "target_path": "d.py",+ "file": "d.py",+ "symbol_id": "d.py::G",+ }+ module = _page("module_page", "pkg/cmd")+ unloaded = _page("file_page", "")+ add_row_paths([symbol, file_row, file_page, spotlight, module, unloaded])++ assert symbol["path"] == symbol["file"] == "a.py"+ assert file_row["path"] == file_row["file"] == "b.py"+ assert file_page == {"page_type": "file_page", "path": "c.py"}+ assert spotlight["path"] == spotlight["file"] == "d.py"+ assert "target_path" not in spotlight+ # Pathless rows keep their key in target_path and get no path.+ assert module == _page("module_page", "pkg/cmd")+ assert unloaded == _page("file_page", "")++ def test_a_served_row_still_resolves_after_its_target_path_is_dropped(self):+ row = add_row_paths([_page("file_page", "c.py")])[0]+ assert hit_file_path(row) == "c.py"++class TestFileCandidates:def test_pages_that_name_no_file_do_not_consume_a_slot(self):hits = [diff --git a/tests/unit/server/mcp/test_tombstones.py b/tests/unit/server/mcp/test_tombstones.pyindex be75c1d6e..bfda5781d 100644--- a/tests/unit/server/mcp/test_tombstones.py+++ b/tests/unit/server/mcp/test_tombstones.py@@ -106,11 +106,9 @@ async def test_search_drops_tombstoned_pages(setup_mcp, session, monkeypatch):mcp_mod._vector_store.search = fake_searchresult = await search_codebase("auth service")- # ``page_id`` is omitted from any result that can rebuild it from- # ``page_type`` + ``target_path``, which is every result whose Page row- # loaded. Reconstruct rather than read — the tombstone filter itself is- # unchanged and still keys on the id internally.- ids = [f"{r['page_type']}:{r['target_path']}" for r in result["results"]]+ # ``page_id`` is omitted only where ``page_type`` + ``target_path`` rebuild+ # it; a file page serves ``path`` instead of ``target_path`` and keeps it.+ ids = [r.get("page_id") or f"{r['page_type']}:{r['target_path']}" for r in result["results"]]assert "file_page:src/auth/service.py" not in idsassert "file_page:src/db/models.py" in idsdiff --git a/tests/unit/sessions/test_codex_adapter.py b/tests/unit/sessions/test_codex_adapter.pyindex 82e5c070a..39e4d216b 100644--- a/tests/unit/sessions/test_codex_adapter.py+++ b/tests/unit/sessions/test_codex_adapter.py@@ -11,7 +11,8 @@ from repowise.core.sessions.adapters.base import (INTENT_TOOL_CALLS,INTENT_TURNS,)-from repowise.core.sessions.adapters.codex import _normalize_tool_name+from repowise.core.sessions.adapters.codex import _bind_first_file, _normalize_tool_name+from repowise.core.sessions.events import ToolUsefrom repowise.core.sessions.miners.decisions import mine_eventsFIXTURE = Path(__file__).parent / "data" / "codex_session.jsonl"@@ -207,6 +208,12 @@ def test_normalize_handles_mcp_function_call_and_output(adapter: CodexAdapter) -assert call_event.tool_uses[0].input["path"] == "app.py"+def test_a_search_binds_its_served_path_over_the_file_alias() -> None:+ tool = ToolUse(id="c1", name="search_codebase", input={"query": "q"})+ _bind_first_file(tool, [{"path": "new.py", "file": "old.py"}])+ assert tool.input["path"] == "new.py"++def test_function_call_decision_gets_file_attribution(adapter: CodexAdapter) -> None:"""A `function_call` tool use must reach the decision miner like `custom_tool_call` does.@@ -310,7 +317,7 @@ def test_a_content_match_binds_the_path_not_the_matched_line(adapter: CodexAdaptassert event is not Noneresults = json.loads(event.tool_results[0].content)["result"]["results"]- assert results == [{"file": "src/app.py"}]+ assert results == [{"path": "src/app.py", "file": "src/app.py"}]def test_a_root_level_content_match_still_binds_its_path(adapter: CodexAdapter) -> None:@@ -324,7 +331,7 @@ def test_a_root_level_content_match_still_binds_its_path(adapter: CodexAdapter)assert event is not Noneresults = json.loads(event.tool_results[0].content)["result"]["results"]- assert results == [{"file": "app.py"}]+ assert results == [{"path": "app.py", "file": "app.py"}]assert call_event is not Noneassert call_event.tool_uses[0].input["path"] == "app.py"@@ -336,7 +343,7 @@ def test_a_bare_root_level_filename_is_kept(adapter: CodexAdapter) -> None:assert event is not Noneresults = json.loads(event.tool_results[0].content)["result"]["results"]- assert results == [{"file": "setup.py"}]+ assert results == [{"path": "setup.py", "file": "setup.py"}]def test_a_bare_prose_line_is_still_dropped(adapter: CodexAdapter) -> None:diff --git a/tests/unit/sessions/test_demand_miner.py b/tests/unit/sessions/test_demand_miner.pyindex 8e30dc3f8..fdd771a3a 100644--- a/tests/unit/sessions/test_demand_miner.py+++ b/tests/unit/sessions/test_demand_miner.py@@ -116,6 +116,19 @@ def test_search_attributes_to_hit_files_and_symbols():assert demand == {"pkg/a.py": 1, "pkg/b.py": 1, "pkg/c.py": 1}+def test_search_prefers_the_served_path():+ # ``file`` and ``target_path`` are aliases; ``path`` is the openable file.+ payload = {+ "results": [+ {"path": "pkg/a.py", "file": "pkg/old.py"},+ {"path": "pkg/b.py", "target_path": "pkg/other.py"},+ ]+ }+ events = [_search_call("s1"), _result("s1", payload)]+ demand = mine_events_demand(events, REPO_PREFIX)+ assert demand == {"pkg/a.py": 1, "pkg/b.py": 1}++def test_two_calls_accumulate():events = [_answer_call("a1"),