fix(tests): isolate 4th polluter victim caught in live -n auto run
tests/test_teaching_queue.py::test_read_only_invariant hardcoded `project_root / "engine_state"` (the real shared dir) in its read-only- invariant snapshot, instead of reading `engine_state._DEFAULT_DIR` (the root-conftest autouse fixture's per-test isolated dir). Same bug pattern as test_workbench_replay.py::test_replay_leaves_no_trace, and this one was caught red-handed: a full `-n auto` fast-lane run failed with "Directory .../engine_state was mutated!" and passed cleanly in serial isolation, the exact order-dependent-flake signature this wave hunts. The other three snapshotted dirs (teaching/proposals, packs, contemplation/runs) have no equivalent per-test isolation idiom in the repo yet and are left as-is — this test's own hitl-queue commands don't write to them, so they were not implicated in the observed failure.
This commit is contained in:
parent
531d4aa0d1
commit
c0cc8c40c4
1 changed files with 12 additions and 1 deletions
|
|
@ -9,6 +9,7 @@ from unittest.mock import patch
|
|||
|
||||
import pytest
|
||||
|
||||
import engine_state
|
||||
from core.cli import main
|
||||
from teaching.discovery import DiscoveryCandidate, EvidencePointer
|
||||
from teaching.proposals import ProposalLog, ReplayEvidence, build_proposal
|
||||
|
|
@ -515,11 +516,21 @@ def snapshot_dir(directory: Path) -> dict[Path, bytes]:
|
|||
|
||||
|
||||
def test_read_only_invariant():
|
||||
"""Directories the hitl-queue commands must not mutate.
|
||||
|
||||
``engine_state`` is read via ``engine_state._DEFAULT_DIR`` (not a
|
||||
hardcoded ``project_root / "engine_state"``) because the root-conftest
|
||||
``_isolate_engine_state_default`` autouse fixture repoints it at a
|
||||
per-test tmp dir; a hardcoded real path would instead snapshot the
|
||||
shared repo dir and false-fail under ``-n auto`` whenever an unrelated
|
||||
concurrent worker wrote to it (observed: AssertionError on this exact
|
||||
directory under a full `-n auto` fast-lane run).
|
||||
"""
|
||||
project_root = Path(__file__).resolve().parent.parent
|
||||
dirs = [
|
||||
project_root / "teaching" / "proposals",
|
||||
project_root / "packs",
|
||||
project_root / "engine_state",
|
||||
Path(engine_state._DEFAULT_DIR),
|
||||
project_root / "contemplation" / "runs",
|
||||
]
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue