test_an_unbuilt_directory_target_refuses_instead_of_answering

Tests › tests/test_mcp_server.py

passed Passed in the packaged run.

What this test is for

Why it exists

THE SECOND HALF, and the one a naive fix breaks. An unregistered string that IS a directory must NOT raise `unknown target` — deriving a target for it is how a third-party repo gets indexed in the first place — but it must not silently answer from the DERIVED DEFAULT either. It has to refuse with the exact call that fixes it.

Verifies REQ-DDB-QUERY-006 REQ-DDB-QUERY-008 REQ-DDB-QUERY-009

Given

  1. registry = st.TargetRegistry(tmp_path / "state")
→

When

  1. _mcp, srv = build_server(registry)
  2. unbuilt = tmp_path / "never_indexed"
  3. unbuilt.mkdir()
2 more
  1. srv.answering(str(unbuilt))
  2. message = str(caught.value)
→

Then

  1. ✓ srv.resolve_target(str(unbuilt)).repo_path equals str(unbuilt)
  2. ✓ raises RuntimeError
  3. ✓ message contains "index(action='refresh'"
  4. ✓ message contains str(unbuilt)

What it exercises

The parts of the system's flows this test ran, measured by per-test coverage: lit steps ran in this test, dimmed ones did not, and ▶ marks where the test called in. Each title opens the whole flow with these steps lit.

Build, refresh and check the index · 16 of 153 steps

… 15 earlier steps

callercallercallercallercallerclew/mcp_server/server.pyclew/mcp_server/server.pyclew/mcp_server/server.pyclew/mcp_server/server.pyclew/mcp_server/server.pyclew/mcp_server/state.pyclew/mcp_server/state.pyclew/mcp_server/state.pyclew/mcp_server/state.pyclew/mcp_server/state.pyclew/wiki/themes/clew/static/web.jsclew/wiki/themes/clew/static/web.jsclew/wiki/themes/clew/static/web.jsclew/wiki/themes/clew/static/web.jsclew/wiki/themes/clew/static/web.jsclew/mcp_server/routing.pyclew/mcp_server/routing.pyclew/mcp_server/routing.pyclew/mcp_server/routing.pyclew/mcp_server/routing.pyclew/mcp_server/freshness.pyclew/mcp_server/freshness.pyclew/mcp_server/freshness.pyclew/mcp_server/freshness.pyclew/mcp_server/freshness.pyopt (line 352)optopt (line 169)optloop (line 169)loopopt (line 171)optopt (line 172)optopt (line 2070)optloop (line 662)loopcatch (line 562)catchindex16. ensure_target → adopt16adopt17. adopt → repo_indexes17repo_indexes18. repo_indexes → target_for18target_for19. target_for → _safe_index_name19_safe_index_name20. target_for → state_home20state_home21. repo_indexes → target_for21target_for22. adopt → target_for22target_for23. adopt → _sync_tier123_sync_tier124. _sync_tier1 → register_query_tools24register_query_tools▶ test enters25–29. register_query_tools → _add_tool25_add_tool +4 more30. _answering_with_refresh → refused30refused31. _answering_with_refresh → _take_context31_take_context32. _take_context → list32list33. register_query_tools → list33list34. adopt → db_status34db_status35. db_status → _options_meta35_options_meta

… 31 steps between

callercallercallercallerclew/mcp_server/server.pyclew/mcp_server/server.pyclew/mcp_server/server.pyclew/mcp_server/server.pyclew/mcp_server/state.pyclew/mcp_server/state.pyclew/mcp_server/state.pyclew/mcp_server/state.pyclew/wiki/themes/clew/static/web.jsclew/wiki/themes/clew/static/web.jsclew/wiki/themes/clew/static/web.jsclew/wiki/themes/clew/static/web.jsclew/mcp_server/routing.pyclew/mcp_server/routing.pyclew/mcp_server/routing.pyclew/mcp_server/routing.pyclew/mcp_server/freshness.pyclew/mcp_server/freshness.pyclew/mcp_server/freshness.pyclew/mcp_server/freshness.pyother filesother filesother filesother filesopt (line 1826)optopt (line 1874)optopt (line 1887)optopt (line 1904)optopt (line 1911)optopt (line 260)optindex67. notices → _code_notice67_code_notice68. _build_subject → resolve_target68resolve_target69. resolve_target → _indexes_for69_indexes_for▶ test enters70. _indexes_for → repo_indexes70repo_indexes71. _indexes_for → repo_indexes71repo_indexes72. resolve_target → list72list73. resolve_target → target_for73target_for74–75. resolve_target → unknown_target_error74unknown_target_error +1 more76. resolve_target → unbuilt_refusal76unbuilt_refusal77. unbuilt_refusal → no_index_message77no_index_message▶ test enters78–79. unbuilt_refusal → listed_names78listed_names +1 more80. unbuilt_refusal → describe_declaration80describe_declaration81. describe_declaration → _parsed_declaration81_parsed_declaration82. resolve_target → 82… 1 call not run

… 71 later steps

4 more

tests/test_mcp_server.py:3248 · its file's page

What it checks (3)

  1. assert srv.resolve_target(str(unbuilt)).repo_path == str(unbuilt) not attributed
  2. assert "index(action='refresh'" in message, "the refusal must carry the call that fixes it" not attributed
  3. assert str(unbuilt) in message not attributed

Where the product reaches it

Call flow

test_an_unbuilt_directory_target_refuses_instead_of_answering→build_server

What it reaches

Each row runs from this test, through the calls it makes, to the code a requirement names. If that code breaks, the test's checks are what should catch it. Reaching is not proving: a check only proves what it observes. No mutation records were given, so these rows say what the test REACHES.

test_an_unbuilt_directory_target_refuses_instead_of_answering · 3 checksbuild_serverREQ-DDB-MCP-001 · measuredbuild_server_refusal_as_tool_errorREQ-DDB-MCP-004 · measuredbuild_server_register_promptsREQ-DDB-WIKI-034 · measured

Requirements it verifies (3)

requirementlinked byimplementers exercised
REQ-DDB-QUERY-006catalogunknown
REQ-DDB-QUERY-008catalogunknown
REQ-DDB-QUERY-009catalogunknown
Also reaches 6 requirements

Its run touches their code; that is reach, not proof.