Skip to content

Commit e0b36d5

Browse files
cdeustclaude
andcommitted
fix(ci): resolve 3 remaining test failures from the wiki autonomy turn
After the v3.17.0 prep the test suite still had three classes of failure on Linux CI. Each one is a real test/policy mismatch, not a flake: # tests_py/handlers/test_seed_project.py (3 tests) The handler refuses to operate on transient roots (``pytest-of-`` / ``/private/var/folders/`` / ``/var/folders/`` / ``.claude/worktrees/``) to keep test runs and worktree creation from polluting the wiki. The test fixture uses ``tmp_path`` which IS a transient root — so the handler returns ``seeded: False`` before the codepath under test ever runs. Added an autouse fixture at the module top that stubs ``is_transient_seed_root`` to return ``False`` for every test in the module. The tests are about the per-domain purge contract (issue #16), not the transient-root gate; the stub keeps them focused. # tests_py/handlers/test_open_visualization.py # (test_opens_browser_at_legacy_url_when_extras_missing) The test expected the handler to open a legacy URL when ``_prepare_layout`` returns ``igraph_missing``. That fallback path no longer exists — the user direction 2026-05-17 was that the graph build must NEVER block the MCP tool launch OR the interface load, so ``_prepare_layout`` is no longer called from ``handler()``. The handler now always opens ``?viz=tilemap``. Renamed the test to ``test_opens_browser_at_tilemap_url_unconditionally`` and rewrote it to assert the current behaviour: tilemap URL always opens, regardless of any (irrelevant) layout state. Kept the docstring explaining the history so the next reader knows why. # tests_py/core/test_wiki_sync_routing.py # (test_file_documentation_does_not_route_to_notes) Same policy clash as the two ``test_wiki_classifier.py`` tests I fixed in an earlier commit: ``codebase`` / ``code-reference`` tagged content used to route to ``reference/``; the 2026-05-17 policy moved those tags into ``_AUDIT_TAGS`` (Gate -1 rejection) so the wiki layer never re-accumulates per-file extractor dumps. The autonomous worker now produces curated structural pages instead. Renamed the test to ``test_file_documentation_is_rejected_from_wiki`` and assert ``build_from_memory`` returns None for this tag set. Lint + format clean; 18-test subset (the three previously-failing suites) passes locally on Python 3.10. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent c8d614b commit e0b36d5

3 files changed

Lines changed: 51 additions & 22 deletions

File tree

tests_py/core/test_wiki_sync_routing.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,15 @@ def test_each_new_page_gets_a_distinct_id() -> None:
165165
assert id_a != id_b
166166

167167

168-
def test_file_documentation_does_not_route_to_notes() -> None:
169-
"""Task #8 fix: pages tagged as code references must not land in notes/.
170-
171-
Before ADR-2244, file documentation produced by codebase_analyze
172-
ended up at notes/<domain>/<id>-file-*.md because the old
173-
_KIND_TO_DIR had no 'file' mapping. The classifier now marks the
174-
provenance as auto-generated and routes to reference/ via the
175-
modern kind.
168+
def test_file_documentation_is_rejected_from_wiki() -> None:
169+
"""Policy 2026-05-17 (superseded ADR-2244 Phase 6 admission):
170+
``codebase`` / ``code-reference`` tags mark per-file extractor
171+
output that bloats the wiki — they stay in PG memory only.
172+
Coverage of the codebase flows through the structural scope
173+
pages (architecture / services / api / data-flow / code-walkthrough
174+
per project) the autonomous worker authors — not via per-file
175+
auto-generated dumps. ``build_from_memory`` returns None so no
176+
wiki page is written.
176177
"""
177178
content = (
178179
"Decision: this module parses a single source file via tree-sitter "
@@ -186,10 +187,8 @@ def test_file_documentation_does_not_route_to_notes() -> None:
186187
tags=["code-reference", "codebase"],
187188
domain="cortex",
188189
)
189-
assert result is not None
190-
rel, md = result
191-
assert not rel.startswith("notes/"), (
192-
f"file-documentation still routing to notes/: {rel!r}"
190+
assert result is None, (
191+
"codebase/code-reference tagged content must be rejected from the "
192+
"wiki — it lives in PG memory only; the autonomous worker "
193+
"produces curated structural pages instead"
193194
)
194-
fm = _parse_frontmatter(md)
195-
assert fm["provenance"] == "auto-generated"

tests_py/handlers/test_open_visualization.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,15 @@ def test_opens_browser_at_tilemap_url(self):
9494
asyncio.run(handler({}))
9595
mock_open.assert_called_once_with("http://localhost:5555/?viz=tilemap")
9696

97-
def test_opens_browser_at_legacy_url_when_extras_missing(self):
98-
"""``viz-tile`` extras unavailable falls back to the legacy URL."""
97+
def test_opens_browser_at_tilemap_url_unconditionally(self):
98+
"""Handler always opens the tilemap URL — graph build happens on
99+
demand via the UI's Graph button, not on launch.
100+
101+
Previously a fallback path opened the legacy URL when
102+
``_prepare_layout`` reported ``igraph_missing``; that branch
103+
was removed when the on-launch layout precomputation was
104+
dropped (2026-05). The handler now returns immediately after
105+
opening ``?viz=tilemap`` regardless of any layout state."""
99106
with (
100107
patch(
101108
"mcp_server.handlers.open_visualization.launch_server",
@@ -104,11 +111,7 @@ def test_opens_browser_at_legacy_url_when_extras_missing(self):
104111
patch(
105112
"mcp_server.handlers.open_visualization.open_in_browser",
106113
) as mock_open,
107-
patch(
108-
"mcp_server.handlers.open_visualization._prepare_layout",
109-
return_value={"status": "error", "reason": "igraph_missing"},
110-
),
111114
):
112115
result = asyncio.run(handler({}))
113-
mock_open.assert_called_once_with("http://localhost:5555")
114-
assert "viz-tile" in result["message"]
116+
mock_open.assert_called_once_with("http://localhost:5555/?viz=tilemap")
117+
assert "tilemap" in result["message"]

tests_py/handlers/test_seed_project.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,37 @@
1313
import asyncio
1414
from pathlib import Path
1515

16+
import pytest
17+
1618
from mcp_server.handlers.seed_project import handler
1719
from mcp_server.infrastructure.memory_store import MemoryStore
1820

1921

22+
@pytest.fixture(autouse=True)
23+
def _allow_transient_seed_roots(monkeypatch):
24+
"""Disable the transient-root guard for this module's tests.
25+
26+
The handler refuses to operate on paths matching ``pytest-of-`` /
27+
``/private/var/folders/`` / ``/var/folders/`` so test runs and
28+
worktree creation never pollute the wiki. But this module's tests
29+
use ``tmp_path`` (which IS a transient root) by design — they're
30+
proving the per-domain purge contract, not validating the
31+
transient-root gate. Stub the predicate to ``False`` for the
32+
duration of each test so the handler proceeds into the codepath
33+
under test.
34+
"""
35+
monkeypatch.setattr(
36+
"mcp_server.handlers.seed_project_constants.is_transient_seed_root",
37+
lambda _path: False,
38+
)
39+
# Also patch the import name as seen by ``seed_project`` itself,
40+
# since the handler imports the predicate at function-call time.
41+
import mcp_server.handlers.seed_project as sp
42+
43+
if hasattr(sp, "is_transient_seed_root"):
44+
monkeypatch.setattr(sp, "is_transient_seed_root", lambda _path: False)
45+
46+
2047
def _make_repo(tmp_path: Path, name: str) -> Path:
2148
"""Build a minimal repo skeleton sufficient for seed_project to find content."""
2249
root = tmp_path / name

0 commit comments

Comments
 (0)