test_serve_runs_the_background_loop_beside_the_transport

Tests › tests/test_background_indexing.py

passed Passed in the packaged run.

What this test is for

Why it exists

THE WIRING. `keep_current` can be perfect and never run; this drives `serve` with a stand-in transport that returns only once a background pass has happened, and with the loop disabled asserts no pass happens at all.

Given

  1. —
→

When

  1. _mcp, state = build_server(st.TargetRegistry(tmp_path / "state"))
  2. passes: list[int] = []
  3. ran = anyio.Event()
7 more
  1. async def _pass() -> list[str]: passes.append(1) ran.set() return []
  2. state.refresh_touched = _pass
  3. async def _until_a_pass(_mcp: object) -> None: await ran.wait()
  4. with anyio.fail_after(5): await serve(_mcp, state, 0.01, _until_a_pass)
  5. passes.clear()
  6. async def _immediately(_mcp: object) -> None: await anyio.sleep(0.05)
  7. await serve(_mcp, state, 0, _immediately)
→

Then

  1. ✓ passes holds
  2. ✓ passes equals []

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

… 21 earlier steps

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.pyopt (line 2070)optloop (line 662)loopcatch (line 562)catchindex22. 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

… 118 later steps

1 more

tests/test_background_indexing.py:258 · its file's page

What it checks (2)

  1. assert passes, "an enabled loop must run beside the transport" not attributed
  2. assert passes == [], "interval 0 disables the loop" not attributed

Where the product reaches it

Call flow

test_serve_runs_the_background_loop_beside_the_transport→build_server→serve

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_serve_runs_the_background_loop_beside_the_transport · 2 checksbuild_serverREQ-DDB-MCP-001 · measuredserveREQ-DDB-MCP-004 · measuredservestart_if_enabledREQ-DDB-WIKI-032 · measuredserveattachREQ-DDB-WIKI-033 · measuredbuild_server_register_promptsREQ-DDB-WIKI-034 · measuredserveenabledREQ-DDB-WIKI-054 · measured
Also reaches 8 requirements

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