test_build_or_refresh_reports_a_measured_duration

Tests › tests/test_mcp_server.py

passed Passed in the packaged run.

What this test is for

Why it exists

gh#9. An agent asked what refreshing cost had no way to find out — `build_or_refresh` returned no timing at all — so it had to estimate, and Q7 mark 7 and Q8 mark 5 missed 9 of 9 cells across every model tier. Q8 is the worst result in the whole matrix, and the losses were LARGEST for the strongest models: a capable model reasons confidently from whatever it is given.

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

Given

  1. _mcp, state = server
  2. repo = tmp_path / "repo"
6 more
  1. repo.mkdir()
  2. target = state.registry.register(str(repo))
  3. state.active = target
  4. Path(target.db_path).write_bytes(rich_db.read_bytes())
  5. monkeypatch.setattr( state, "_run_build", lambda *_a, **_k: pytest.fail("a current db must not rebuild") )
  6. result = await state.build_or_refresh(_FakeCtx())
→

When

  1. —
→

Then

  1. ✓ result["built"] is False
  2. ✓ isinstance(result["duration_ms"], int) holds
  3. ✓ result["duration_ms"] is at least 0

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 · 50 of 153 steps

… 2 earlier steps

callercallercallercallerclew/mcp_server/server.pyclew/mcp_server/server.pyclew/mcp_server/server.pyclew/mcp_server/server.pyopt (line 3019)opttry (line 2509)tryopt (line 2603)optindex3–4. _index_action → status3status +1 more5. build_or_refresh → _build_subject5_build_subject▶ test enters6. _build_subject → ensure_target6ensure_target7–8. ensure_target → _target_from_roots7_target_from_roots +1 more

… 9 steps between

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.pyother filesother filesother filesother filesother filesopt (line 352)optopt (line 169)optloop (line 169)loopopt (line 171)optopt (line 172)optloop (line 662)loopcatch (line 562)catchindex18. repo_indexes → target_for18target_for19. target_for → _safe_index_name19_safe_index_name20. target_for → state_home20state_home▶ test enters21. repo_indexes → target_for21target_for22. adopt → target_for22target_for23–24. adopt → _sync_tier123_sync_tier1 +1 more25–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–36. db_status → _options_meta35_options_meta +1 more37. _meta_section → meta_section37meta_section38. db_status → stated_options38stated_options39. db_status → read_build_signature39read_build_signature40–48. db_status → _source_drift40_source_drift +8 more49. db_status → list49list50–53. db_status → _diagnostics_meta50_diagnostics_meta +3 more54. db_status → code_identity54code_identity55–57. code_identity → source_fingerprint55source_fingerprint +2 more58. db_status → notices58notices59–60. notices → code_identity59code_identity +1 more61–63. _data_notice → _cost_clause61_cost_clause +2 more64–67. notices → _schema_notice64_schema_notice +3 more68–69. _build_subject → resolve_target68resolve_target +1 more

… 62 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/freshness.pyclew/mcp_server/freshness.pyclew/mcp_server/freshness.pyclew/mcp_server/freshness.pyclew/scope.pyclew/scope.pyclew/scope.pyclew/scope.pyopt (line 2549)optopt (line 2553)optopt (line 3032)optindex132. _offered_sub_indexes → derive_sub_indexes132derive_sub_indexes133. _offered_sub_indexes → list133list134. build_or_refresh → code_identity134code_identity▶ test enters135. build_or_refresh → stale_code_refusal135stale_code_refusal136. stale_code_refusal → code_identity136code_identity137–138. build_or_refresh → _build_lock137_build_lock +1 more139. _build_once → db_status139db_status140. build_or_refresh → adopt140adopt141–142. build_or_refresh → _activate_tier1141_activate_tier1 +1 more143. build_or_refresh → db_status143db_status144–145. _index_action → read_comments144read_comments +1 more

… 8 later steps

5 more

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

What it checks (3)

  1. assert result["built"] is False not attributed
  2. assert isinstance(result["duration_ms"], int) not attributed
  3. assert result["duration_ms"] >= 0 not attributed

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.

Requirements it verifies (3)

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

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