test_a_killed_holder_leaves_no_stale_lock

Tests › tests/test_buildlock.py

passed Passed in the packaged run.

What this test is for

Why it exists

WHY flock RATHER THAN AN O_EXCL LOCKFILE, proved rather than asserted. A lockfile needs a stale-lock story — a builder killed mid-run leaves the file, and every later process has to decide whether the holder still lives. Getting that wrong wedges a target permanently, which is exactly the class of failure this sequence of releases has been about.

Given

  1. db = tmp_path / "clew.db"
  2. acquired = multiprocessing.Value("i", 0)
2 more
  1. child = multiprocessing.Process(target=_hold, args=(str(db), acquired, 60.0))
  2. child.start()
→

When

  1. try: for _ in range(100): if acquired.value: break time.sleep(0.05) assert acquired.value == 1, "the child never acquired the lock — test would be vacuous" child.kill() child.join(timeout=10) ## Immediately acquirable. A short wait proves it is not merely the bound expiring. started = time.monotonic() with build_lock(db, wait_seconds=30.0) as held: assert held is True, ( "the lock was still unavailable after the holder was SIGKILLed — that is a stale " "lock, and it would wedge every later build of this target" ) assert time.monotonic() - started < 5.0, "acquisition after a kill should be immediate" finally: if child.is_alive(): # pragma: no cover child.kill() child.join()
→

Then

  1. —

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) · 2 of 142 steps

… 60 earlier steps

thread startthread startthread startthread startclew/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.pyother filesother filesother filesother filestry (line 3260)try_first_build_worker61. _run_build_walked → captured_output61captured_output62. _run_build_walked → build_lock62build_lock63. build_lock → _os_lock63_os_lock▶ test enters64. _os_lock → lock_path64lock_path65. _run_build_walked → db_status65db_status66. db_status → _options_meta66_options_meta

… 76 later steps

tests/test_buildlock.py:113 · its file's page

What it checks (3)

  1. assert acquired.value == 1, "the child never acquired the lock — test would be vacuous" not attributed
  2. assert held is True, ( "the lock was still unavailable after the holder was SIGKILLed — that is a stale " "lock, and it would wedge every later build of this target" ) not attributed
  3. assert time.monotonic() - started < 5.0, "acquisition after a kill should be immediate" not attributed

Where the product reaches it

No product flow reaches this code: no product entry point's flow calls any of the functions this test calls.

Call flow

test_a_killed_holder_leaves_no_stale_lock→build_lock

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_a_killed_holder_leaves_no_stale_lock · 3 checksbuild_lockREQ-DDB-INDEX-002 · measured
Also reaches 1 requirement

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