"""共享 fixture。""" from __future__ import annotations from pathlib import Path import pytest from cybergril.config import CharacterConfig, ModelsConfig, Settings from cybergril.memory import Store try: from cybergril.think.budget import CATEGORIES, BudgetConfig except ImportError: # r3 baseline probe runs these tests against older src trees from cybergril.think.budget import BudgetConfig CATEGORIES = ("dialogue", "life", "background", "semantic") def engineering_budget(**overrides) -> BudgetConfig: """Engineering caps for isolated tests: real mechanism, generous numbers. The product default is fail-closed (all request caps 0 = refuse); tests exercise the same acquire/settle path with plenty of headroom so the gate itself is what's under test, not the headroom. Against a pre-HEL-882 baseline source tree (r3 baseline probe) the extra fields don't exist and the old plain token config is used — behavior there predates the gate. """ requests = dict.fromkeys(CATEGORIES, 100_000) requests.update(overrides.pop("daily_requests", {})) try: return BudgetConfig(daily_tokens=10_000_000, daily_requests=requests, **overrides) except TypeError: return BudgetConfig(daily_tokens=10_000_000, **overrides) @pytest.fixture def repo_root() -> Path: return Path(__file__).resolve().parents[1] @pytest.fixture def settings(repo_root: Path) -> Settings: return Settings( models=ModelsConfig(), character=CharacterConfig(identity={"y": 2000, "m": 1, "d": 1, "h": 12}), db_path=repo_root / "test.db", ) @pytest.fixture def store(tmp_path: Path) -> Store: s = Store(tmp_path / "test.db") yield s s.close()