test_registering_after_an_unreadable_registry_does_not_destroy_it

Tests › tests/test_mcp_server.py

passed Passed in the packaged run.

What this test is for

Why it exists

THE LOSS SCENARIO END TO END, which neither of the two tests above covers on its own: read fails, `register` proceeds, and the single surviving entry becomes the whole registry. This asserts the new entry lands AND the previous content is still on disk to recover from.

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

Given

  1. home = tmp_path / "state"
  2. home.mkdir()
7 more
  1. damaged = '{"/previously/registered": {"slug": "prev-000000", "db_path": "/prev/db"}'
  2. (home / st.REGISTRY_NAME).write_text(damaged)
  3. reg = st.TargetRegistry(home)
  4. repo = tmp_path / "newly_registered"
  5. repo.mkdir()
  6. target = reg.register(repo)
  7. survivors = [ p.read_text(encoding="utf-8") for p in home.iterdir() if p.is_file() and p.name != st.REGISTRY_NAME ]
→

When

  1. —
→

Then

  1. ✓ [t.repo_path for t in reg.targets()] equals [target.repo_path]
  2. ✓ any("/previously/registered" in text for text in survivors) holds

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.

thread `clew-first-build-` — `_first_build_worker` (clew/mcp_server/server.py) · 1 of 142 steps

… 32 earlier steps

thread startthread startthread startthread startclew/mcp_server/server.pyclew/mcp_server/server.pyclew/mcp_server/server.pyclew/mcp_server/server.pyclew/scope.pyclew/scope.pyclew/scope.pyclew/scope.pyclew/mcp_server/state.pyclew/mcp_server/state.pyclew/mcp_server/state.pyclew/mcp_server/state.pytry (line 1664)tryopt (line 1666)optopt (line 352)opt_first_build_worker33. _first_build_worker → target_for33target_for34. target_for → _safe_index_name34_safe_index_name35. target_for → state_home35state_home▶ test enters36. _first_build_worker → _run_build36_run_build37. _run_build → nested_tree_cache37nested_tree_cache

… 105 later steps

4 more

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

What it checks (2)

  1. assert [t.repo_path for t in reg.targets()] == [target.repo_path], ( "the new registration must still succeed" ) not attributed
  2. assert any("/previously/registered" in text for text in survivors), ( "registering over an unreadable registry destroyed the only record of what it held" ) 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 (4)

requirementlinked byimplementers exercised
REQ-DDB-MCP-003catalogunknown
REQ-DDB-QUERY-006catalogunknown
REQ-DDB-QUERY-008catalogunknown
REQ-DDB-QUERY-009catalogunknown
Also reaches 1 requirement

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