Stop two harnesses from measuring each other's store
A scratch copy is one run's working store. The video harness defaults to bench/runs/video_audio and copy_store() copies straight over it, so a smoke run started while the full run was mid-ingest replaced the database under it: the full run's after-arm would have scored a store whose speech atoms had been swapped out, and the smoke itself died on "database is locked" inside text_index. Six harnesses share that copy path, so the claim lives in bench/scratch.py: a live pid in held_by refuses the path, a stale one is taken over, and the same process may re-copy per arm. The reviewer's smoke knob also measured nothing instead of saying so. With --limit the probe sample narrows to video only, and a small --probes strides past that modality entirely, so the run crashed in aggregate() after the ingest. probe_sample() now switches the arm off at --probes 0 and fails in half a second otherwise. The frozen-report guard had two holes found by running it: it compared cwd-relative parents, so an absolute path to the frozen file passed, and it refused the harness's own default destination once that file existed, which would have stopped the shipped run. It now compares resolved paths and refuses only committed evidence. Record fixes from review round 3: the round-2 line credited a reproduction to the wrong round and quoted a git log -S hit for a string that never existed in code; the suite counts now name the commit each was measured on (401 at83dfc14, 406 ateab6bd7, 410 atcf2de31, 411 at92237c8). Gates: pytest -q 418 passed; ruff clean; bench.filesize_check OK; mypy cold cache and pyright clean on the four touched files.
This commit is contained in:
5 files changed
+171
-16
No files matched your search
@@ -0,0 +1,31 @@
|
||||
"""A scratch copy is one run's working store; two runs on one path silently measure each other's data."""
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from bench import scratch
|
||||
|
||||
|
||||
def test_a_live_holder_refuses_the_same_scratch(tmp_path: Path) -> None:
|
||||
"""The collision I hit: a second run re-copied the store under a run that was ingesting into it."""
|
||||
if not Path("/proc/1").exists():
|
||||
pytest.skip("liveness is read from /proc")
|
||||
(tmp_path / scratch.HELD).write_text("1", encoding="utf-8")
|
||||
with pytest.raises(SystemExit, match="is held by pid 1"):
|
||||
scratch.claim(tmp_path)
|
||||
|
||||
|
||||
def test_a_stale_claim_is_taken_over(tmp_path: Path) -> None:
|
||||
"""A crashed run must not lock the scratch away forever."""
|
||||
(tmp_path / scratch.HELD).write_text("999999", encoding="utf-8")
|
||||
scratch.claim(tmp_path)
|
||||
assert (tmp_path / scratch.HELD).read_text(encoding="utf-8") == str(os.getpid())
|
||||
|
||||
|
||||
def test_one_run_may_copy_more_than_once(tmp_path: Path) -> None:
|
||||
"""Harnesses that score several arms re-copy on purpose; that is not a collision."""
|
||||
scratch.claim(tmp_path)
|
||||
scratch.claim(tmp_path)
|
||||
assert (tmp_path / scratch.HELD).read_text(encoding="utf-8") == str(os.getpid())
|
||||
Reference in new issue
Block a user