"""Pytest fixtures for the P1 exit-criteria simulation (design ยง7.1 P1). The parent ``tests/conftest.py`` already puts the ``agent-team/`` project root on ``sys.path`` so ``agent_team`` (the committed foundation) imports cleanly. This sim-level conftest adds the local ``tests/sim`` directory to ``sys.path`` so the sibling :mod:`harness` module imports the same way under any pytest ``rootdir``/import mode, and exposes the shared fixtures the four exit-criteria tests build on. These fixtures construct the harness against the *real* committed foundation (the SQLite ``pending_questions`` ledger and the atomic, integrity-checked state store) rooted under a pytest ``tmp_path``, so every test gets an isolated, durable, on-disk pipeline and nothing touches live infrastructure. """ from __future__ import annotations import sys from pathlib import Path from typing import Iterator import pytest # Make the sibling ``harness`` module importable regardless of pytest's import # mode / rootdir (the parent conftest handles the ``agent_team`` package root). _SIM_DIR = Path(__file__).resolve().parent if str(_SIM_DIR) not in sys.path: sys.path.insert(0, str(_SIM_DIR)) from harness import ( # noqa: E402 (path injected above) PostFailingTransport, RecordingTransport, SimClock, SimPipeline, ) @pytest.fixture def clock() -> SimClock: """A fresh advanceable simulation clock starting at tick 0.""" return SimClock(start=0) @pytest.fixture def transport() -> RecordingTransport: """An in-memory recording transport (faithful Transport subclass, no Slack).""" return RecordingTransport(name="sim") @pytest.fixture def post_failing_transport() -> PostFailingTransport: """A transport whose first ``post_question`` raises (lost-post simulation).""" return PostFailingTransport(name="sim", fail_times=1) @pytest.fixture def pipeline( tmp_path: Path, clock: SimClock, transport: RecordingTransport ) -> Iterator[SimPipeline]: """A durable :class:`SimPipeline` rooted under an isolated ``tmp_path``. Backed by the real ``pending_questions`` SQLite ledger and the real atomic state store; teardown is the ``tmp_path`` cleanup pytest already does. """ yield SimPipeline(tmp_path / "state", clock=clock, transport=transport)