diff --git a/configs/caliper.sample.toml b/configs/caliper.sample.toml new file mode 100644 index 0000000..c6c22ab --- /dev/null +++ b/configs/caliper.sample.toml @@ -0,0 +1,39 @@ +# Caliper user configuration template (FR-11). +# +# Copy to `caliper.toml` at the repo root and edit. Version presets +# (configs/v1.toml, v2.toml, v3.toml) are merged UNDER this file, so values +# set here win — that is how you switch provider/model (e.g. to Ollama per +# assumption A2) without editing the committed presets. +# +# Paths, provider selection, and secrets are environment variables, not TOML +# (§11.2): CALIPER_PROVIDER, CALIPER_DB, CALIPER_CACHE_DIR, GEMINI_API_KEY... + +[answer] +# Fixed answerer — identical across V1/V2/V3 (FR-10). Override only when +# switching provider (a new fingerprint and re-run follows by design, FR-09). +model = "gemini-3.5-flash-lite" +temperature = 0.0 +seed = 42 +# Initial 0.35; re-verified once against V1 eval data, then frozen (§7.7, §9.7). +refusal_threshold = 0.35 +high_confidence_threshold = 0.60 +# SHA-256 of the frozen prompt template. Placeholder until T11 freezes the +# template file; changing it changes the fingerprint (§11.2). +prompt_template_sha256 = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + +[embeddings] +model = "gemini-embedding-001" +dimensions = 768 + +[chunking] +unit = "heading" # "heading" (V1) or "fixed" (V2/V3) +size_tokens = 800 +overlap_tokens = 0 + +[retrieval] +mode = "vector" # "vector" (V1/V2) or "hybrid_rrf" (V3) +vector_top_k = 5 +fts_top_k = 0 # must be 0 when mode = "vector" +rrf_k = 60 +rerank = "none" # "cross-encoder" (V3 only) +final_k = 5 diff --git a/configs/v1.toml b/configs/v1.toml new file mode 100644 index 0000000..cf5e033 --- /dev/null +++ b/configs/v1.toml @@ -0,0 +1,27 @@ +# V1 baseline preset — cosine-only retrieval over heading chunks (§9.7). +# All three presets share identical answer settings (FR-10 invariant). + +[answer] +model = "gemini-3.5-flash-lite" +temperature = 0.0 +seed = 42 +refusal_threshold = 0.35 # initial; re-verified once against V1 data, then frozen +high_confidence_threshold = 0.60 +prompt_template_sha256 = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" # placeholder until T11 + +[embeddings] +model = "gemini-embedding-001" +dimensions = 768 + +[chunking] +unit = "heading" +size_tokens = 800 +overlap_tokens = 0 + +[retrieval] +mode = "vector" +vector_top_k = 5 +fts_top_k = 0 +rrf_k = 60 +rerank = "none" +final_k = 5 diff --git a/configs/v2.toml b/configs/v2.toml new file mode 100644 index 0000000..bba6206 --- /dev/null +++ b/configs/v2.toml @@ -0,0 +1,27 @@ +# V2 preset — improved segmentation: fixed-size windows with overlap (§9.7). +# Only the chunking block differs from V1; retrieval and answerer unchanged. + +[answer] +model = "gemini-3.5-flash-lite" +temperature = 0.0 +seed = 42 +refusal_threshold = 0.35 # initial; re-verified once against V1 data, then frozen +high_confidence_threshold = 0.60 +prompt_template_sha256 = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" # placeholder until T11 + +[embeddings] +model = "gemini-embedding-001" +dimensions = 768 + +[chunking] +unit = "fixed" +size_tokens = 350 +overlap_tokens = 50 + +[retrieval] +mode = "vector" +vector_top_k = 5 +fts_top_k = 0 +rrf_k = 60 +rerank = "none" +final_k = 5 diff --git a/configs/v3.toml b/configs/v3.toml new file mode 100644 index 0000000..c8e6e98 --- /dev/null +++ b/configs/v3.toml @@ -0,0 +1,27 @@ +# V3 preset — improved retrieval/ranking: hybrid RRF fusion + cross-encoder +# rerank (§9.7, ADR-006/ADR-011). Chunking identical to V2; answerer unchanged. + +[answer] +model = "gemini-3.5-flash-lite" +temperature = 0.0 +seed = 42 +refusal_threshold = 0.35 # initial; re-verified once against V1 data, then frozen +high_confidence_threshold = 0.60 +prompt_template_sha256 = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" # placeholder until T11 + +[embeddings] +model = "gemini-embedding-001" +dimensions = 768 + +[chunking] +unit = "fixed" +size_tokens = 350 +overlap_tokens = 50 + +[retrieval] +mode = "hybrid_rrf" +vector_top_k = 20 +fts_top_k = 20 +rrf_k = 60 +rerank = "cross-encoder" # optional dependency group "rerank" (§5) +final_k = 5 diff --git a/docs/TASKS.md b/docs/TASKS.md index d35a8bd..0b24167 100644 --- a/docs/TASKS.md +++ b/docs/TASKS.md @@ -12,11 +12,12 @@ Statuses: ✅ done · 🔄 doing · ⬜ remaining · ✂️ cut (stretch only, p | ID | Commit(s) | Verified | |---|---|---| -| T01 | `c76a2bc` (tracker), `d0446f6` (scaffold) | `uv sync` OK (CPython 3.12.16); `uv run caliper --help` renders; `ruff check` + `ruff format --check` + `mypy` clean; 2 tests pass. *CI run on GitHub pending — first push.* | +| T01 | `c76a2bc` (tracker), `d0446f6` (scaffold) | `uv sync` OK (CPython 3.12.16); `uv run caliper --help` renders; `ruff check` + `ruff format --check` + `mypy` clean; 2 tests pass. CI green on push/PR and on `main` after PR #1 merge (run 43717112766). | +| T02 | `489c035` | `uv run pytest` — 38 passed (36 new config tests); `ruff check` + `ruff format --check` clean; `mypy` strict clean. Verified: user-over-preset deep merge; §9.7 contents binding for v1/v2/v3 + shared fixed answerer; fingerprint stable across reloads, differs across versions, and reacts to every binding-field change (parametrized, 17 fields); invalid configs rejected with key path. | ## Doing -_(none — next up: **T02**, pending review)_ +_(none — next up: **T03**, pending review; T04 is parallelizable with it per §14.3)_ ## Remaining @@ -84,3 +85,9 @@ _(none — next up: **T02**, pending review)_ - Max concurrency: 2 agents; ownership rules in ARCHITECTURE §6.3 keep parallel tasks disjoint. - Contract-touching tasks follow the shared-file protocol (§14.4): PR touches only the owned file + its tests, updates the binding §7–§9 section in the same change, and names dependent tasks. - Never edit `data/golden/questions.jsonl` after the first measured run; never commit `data/caliper.db`, `data/cache/`, `caliper.toml`, `.env`. + +### Decisions recorded during the build + +- **T02 — merge order (§11.2 ambiguity):** the version preset is loaded first and the user config is deep-merged *over* it (user wins on conflicts). Rationale: this is the only reading consistent with A2's fallback path ("flip `CALIPER_PROVIDER=ollama`" requires overriding `answer.model`/`embeddings.model`, which preset-wins would forbid since presets are committed). FR-10 comparability is not weakened: identity is enforced by the fingerprint gate (§7.8), computed from the resolved config, not by the merge order. +- **T02 — `answer.prompt_template_sha256`:** presets carry the SHA-256 of the empty string as a placeholder until T11 stores the frozen prompt template file; T11 must replace it in all four TOML files (and in `PROMPT_TEMPLATE_SHA256_PLACEHOLDER` in `config.py`'s default) — the change is fingerprint-visible by construction. +- **T02 — `high_confidence_threshold`:** not pinned in §9.7; initialized to 0.60 in all presets. To be re-verified alongside the refusal threshold at T16 before the V1 baseline run freezes it. diff --git a/src/caliper/config.py b/src/caliper/config.py new file mode 100644 index 0000000..dfd2b7b --- /dev/null +++ b/src/caliper/config.py @@ -0,0 +1,196 @@ +"""Configuration loading, merging, and fingerprinting (§7.1). + +Single definition of the config model and of the canonical fingerprint used +everywhere (§9.7 contents binding, §11.2 fingerprint scope). This module is a +leaf: it has no knowledge of the DB layout or providers, and performs no I/O +beyond reading TOML files (§7.1 "Must not"). + +Merge order (§11.2 ambiguity resolution, recorded in docs/TASKS.md Notes): +the version preset is merged first, then the user config is merged over it — +the user config wins on conflicts. This is what makes the A2 fallback path +("flip CALIPER_PROVIDER=ollama") workable without editing committed presets, +and it stays safe for FR-10 because comparability is enforced by the +fingerprint gate (§7.8), not by the merge order. +""" + +from __future__ import annotations + +import hashlib +import json +import tomllib +from collections.abc import Mapping +from pathlib import Path +from typing import Any, Literal + +from pydantic import BaseModel, ConfigDict, Field, ValidationError, model_validator + +# SHA-256 of the empty string: placeholder for the frozen prompt template's +# hash until T11 stores the real template file. Changing this value changes +# the fingerprint, so T11's replacement is fingerprint-visible by construction. +PROMPT_TEMPLATE_SHA256_PLACEHOLDER = ( + "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" +) + + +class ConfigError(ValueError): + """A config file is missing, unreadable, or invalid (§11.4). + + The message always names the offending key path. Mapped to the + `config_invalid` envelope code at the CLI/web edges (§9). + """ + + +class ChunkingConfig(BaseModel): + """Segmentation settings (§9.7). The 1,900-token cap matches §7.4.""" + + model_config = ConfigDict(frozen=True, extra="forbid") + + unit: Literal["heading", "fixed"] = "heading" + size_tokens: int = Field(default=800, ge=1, le=1900) + overlap_tokens: int = Field(default=0, ge=0) + + @model_validator(mode="after") + def _overlap_below_size(self) -> ChunkingConfig: + if self.overlap_tokens >= self.size_tokens: + # The ValueError message names the offending key path (§11.4); + # pydantic prefixes it with the section name in ValidationError.loc. + raise ValueError("chunking.overlap_tokens must be smaller than chunking.size_tokens") + return self + + +class RetrievalConfig(BaseModel): + """Search/ranking settings (§7.5, §9.7).""" + + model_config = ConfigDict(frozen=True, extra="forbid") + + mode: Literal["vector", "hybrid_rrf"] = "vector" + vector_top_k: int = Field(default=5, ge=1) + fts_top_k: int = Field(default=0, ge=0) + rrf_k: int = Field(default=60, ge=1) + rerank: Literal["none", "cross-encoder"] = "none" + final_k: int = Field(default=5, ge=1) + + @model_validator(mode="after") + def _mode_consistency(self) -> RetrievalConfig: + # Stated rule (§11.4): fts_top_k=0 iff mode="vector". + if self.mode == "vector" and self.fts_top_k != 0: + raise ValueError("retrieval.fts_top_k must be 0 when mode is 'vector'") + if self.mode == "hybrid_rrf" and self.fts_top_k == 0: + raise ValueError("retrieval.fts_top_k must be > 0 when mode is 'hybrid_rrf'") + # A reranker only makes sense over a fused candidate list (§7.5). + if self.rerank != "none" and self.mode != "hybrid_rrf": + raise ValueError("retrieval.rerank other than 'none' requires mode 'hybrid_rrf'") + return self + + +class AnswerConfig(BaseModel): + """Fixed answerer settings (§7.7, §9.7). Identical across V1–V3 (FR-10).""" + + model_config = ConfigDict(frozen=True, extra="forbid") + + model: str = "gemini-3.5-flash-lite" + temperature: float = Field(default=0.0, ge=0.0, le=2.0) + seed: int = Field(default=42, ge=0) + # Initial 0.35; re-verified once against V1 eval data, then frozen (§7.7, §9.7). + refusal_threshold: float = Field(default=0.35, ge=0.0, le=1.0) + high_confidence_threshold: float = Field(default=0.60, ge=0.0, le=1.0) + prompt_template_sha256: str = PROMPT_TEMPLATE_SHA256_PLACEHOLDER + + +class EmbeddingsConfig(BaseModel): + """Embedding model settings (§5, §9.7).""" + + model_config = ConfigDict(frozen=True, extra="forbid") + + model: str = "gemini-embedding-001" + dimensions: int = Field(default=768, ge=1) + + +class CaliperConfig(BaseModel): + """The full resolved Caliper configuration (§9.7). + + Contains only fingerprint-relevant fields; paths, provider selection, and + secrets are environment variables (§11.2) and live outside this model. + """ + + model_config = ConfigDict(frozen=True, extra="forbid") + + chunking: ChunkingConfig = ChunkingConfig() + retrieval: RetrievalConfig = RetrievalConfig() + answer: AnswerConfig = AnswerConfig() + embeddings: EmbeddingsConfig = EmbeddingsConfig() + + +def _read_toml(path: Path) -> dict[str, Any]: + if not path.is_file(): + raise ConfigError(f"config file not found: {path}") + try: + with path.open("rb") as fh: + return tomllib.load(fh) + except tomllib.TOMLDecodeError as exc: + raise ConfigError(f"invalid TOML in {path}: {exc}") from exc + + +def _deep_merge(base: dict[str, Any], override: Mapping[str, Any]) -> dict[str, Any]: + """Return a deep merge of `override` on top of `base` (override wins).""" + merged: dict[str, Any] = dict(base) + for key, value in override.items(): + if isinstance(value, Mapping) and isinstance(merged.get(key), dict): + merged[key] = _deep_merge(merged[key], value) + else: + merged[key] = value + return merged + + +def _format_validation_error(exc: ValidationError) -> str: + """Render pydantic errors as 'section.key: message' key paths (§11.4).""" + parts = [] + for err in exc.errors(): + loc = ".".join(str(piece) for piece in err["loc"]) + parts.append(f"{loc}: {err['msg']}") + return "; ".join(parts) + + +def load_config(user_path: Path, preset: Path) -> CaliperConfig: + """Load the user config and the version preset, resolve to concrete values. + + The preset is loaded first and the user config is merged over it (user + wins; see module docstring). Any unknown key, wrong type, or cross-field + violation raises ConfigError naming the offending key path (§11.4) before + any provider call could be made. + """ + preset_raw = _read_toml(preset) + user_raw = _read_toml(user_path) + merged = _deep_merge(preset_raw, user_raw) + try: + return CaliperConfig.model_validate(merged) + except ValidationError as exc: + raise ConfigError(f"invalid config: {_format_validation_error(exc)}") from exc + + +def fingerprint_payload(cfg: CaliperConfig) -> dict[str, Any]: + """The fingerprinted fields, per §11.2: model IDs, embedding model + + dimensions, prompt template text hash, temperature, seed, thresholds, + chunking, retrieval mode and k-values — deliberately excluding paths and + the API key (neither is representable in this model).""" + return { + "chunking": cfg.chunking.model_dump(), + "retrieval": cfg.retrieval.model_dump(), + "answer": cfg.answer.model_dump(), + "embeddings": cfg.embeddings.model_dump(), + } + + +def fingerprint(cfg: CaliperConfig) -> str: + """SHA-256 hex of the canonical JSON of the binding fields (§11.2). + + Stable across runs on identical inputs; changes on any binding-field + change, which by design starts a new index/eval identity (FR-09). + """ + canonical = json.dumps(fingerprint_payload(cfg), sort_keys=True, separators=(",", ":")) + return hashlib.sha256(canonical.encode("utf-8")).hexdigest() + + +def fp8(cfg: CaliperConfig) -> str: + """First 8 hex chars of the fingerprint — the per-fingerprint table suffix (§6.2).""" + return fingerprint(cfg)[:8] diff --git a/tests/unit/test_config.py b/tests/unit/test_config.py new file mode 100644 index 0000000..bed4ad5 --- /dev/null +++ b/tests/unit/test_config.py @@ -0,0 +1,232 @@ +"""T02 unit tests: config loading/merging and fingerprinting (§7.1, §9.7, §11.2, §11.4).""" + +import re +from pathlib import Path +from typing import Any + +import pytest + +from caliper.config import ( + CaliperConfig, + ConfigError, + fingerprint, + fingerprint_payload, + fp8, + load_config, +) + +REPO_ROOT = Path(__file__).resolve().parents[2] +CONFIGS = REPO_ROOT / "configs" + +# §9.7 binding contents, keyed by preset (answer/embeddings shared by all three). +_V1_TABLE: dict[str, Any] = { + "chunking": {"unit": "heading", "size_tokens": 800, "overlap_tokens": 0}, + "retrieval": { + "mode": "vector", + "vector_top_k": 5, + "fts_top_k": 0, + "rrf_k": 60, + "rerank": "none", + "final_k": 5, + }, +} +_V2_TABLE: dict[str, Any] = { + "chunking": {"unit": "fixed", "size_tokens": 350, "overlap_tokens": 50}, + "retrieval": { + "mode": "vector", + "vector_top_k": 5, + "fts_top_k": 0, + "rrf_k": 60, + "rerank": "none", + "final_k": 5, + }, +} +_V3_TABLE: dict[str, Any] = { + "chunking": {"unit": "fixed", "size_tokens": 350, "overlap_tokens": 50}, + "retrieval": { + "mode": "hybrid_rrf", + "vector_top_k": 20, + "fts_top_k": 20, + "rrf_k": 60, + "rerank": "cross-encoder", + "final_k": 5, + }, +} +_SHARED_TABLE: dict[str, Any] = { + "answer": { + "model": "gemini-3.5-flash-lite", + "temperature": 0.0, + "seed": 42, + "refusal_threshold": 0.35, + "high_confidence_threshold": 0.60, + }, + "embeddings": {"model": "gemini-embedding-001", "dimensions": 768}, +} +PRESET_TABLES: dict[str, dict[str, Any]] = {"v1": _V1_TABLE, "v2": _V2_TABLE, "v3": _V3_TABLE} + + +def _write_user(tmp_path: Path, toml_text: str) -> Path: + path = tmp_path / "user.toml" + path.write_text(toml_text, encoding="utf-8") + return path + + +def _load(tmp_path: Path, preset: str, user_toml: str = "") -> CaliperConfig: + return load_config(_write_user(tmp_path, user_toml), CONFIGS / f"{preset}.toml") + + +def _assert_matches_table(cfg: CaliperConfig, table: dict[str, Any]) -> None: + for section, values in table.items(): + sub = getattr(cfg, section) + for key, expected in values.items(): + assert getattr(sub, key) == expected, f"{section}.{key}" + + +# --- §9.7: preset contents binding ------------------------------------------- + + +@pytest.mark.parametrize("preset", ["v1", "v2", "v3"]) +def test_preset_matches_section_9_7_table(tmp_path: Path, preset: str) -> None: + cfg = _load(tmp_path, preset) + _assert_matches_table(cfg, {**PRESET_TABLES[preset], **_SHARED_TABLE}) + + +def test_presets_share_the_fixed_answerer(tmp_path: Path) -> None: + # FR-10 invariant: answer settings identical across V1/V2/V3. + answer_tables = [fingerprint_payload(_load(tmp_path, v))["answer"] for v in ("v1", "v2", "v3")] + assert answer_tables[0] == answer_tables[1] == answer_tables[2] + + +def test_sample_config_resolves_to_v1_values(tmp_path: Path) -> None: + cfg = load_config(CONFIGS / "caliper.sample.toml", CONFIGS / "v1.toml") + _assert_matches_table(cfg, {**_V1_TABLE, **_SHARED_TABLE}) + + +# --- merge semantics --------------------------------------------------------- + + +def test_user_config_merges_over_preset(tmp_path: Path) -> None: + user = '[answer]\nmodel = "qwen2.5:7b-instruct"\n' + cfg = _load(tmp_path, "v1", user) + assert cfg.answer.model == "qwen2.5:7b-instruct" + # Deep merge: sibling keys from the preset survive the override. + assert cfg.answer.seed == 42 + _assert_matches_table(cfg, {**_V1_TABLE, "embeddings": _SHARED_TABLE["embeddings"]}) + + +def test_merge_is_deep_not_section_replacing(tmp_path: Path) -> None: + user = "[retrieval]\nvector_top_k = 20\n" + cfg = _load(tmp_path, "v1", user) + assert cfg.retrieval.vector_top_k == 20 + assert cfg.retrieval.mode == "vector" + assert cfg.retrieval.final_k == 5 + + +# --- fingerprint (§11.2) ----------------------------------------------------- + + +def test_fingerprint_stable_across_reloads(tmp_path: Path) -> None: + a = _load(tmp_path, "v1") + b = _load(tmp_path, "v1") + assert fingerprint(a) == fingerprint(b) + assert len(fingerprint(a)) == 64 + + +def test_fingerprint_differs_across_versions(tmp_path: Path) -> None: + fps = {v: fingerprint(_load(tmp_path, v)) for v in ("v1", "v2", "v3")} + assert len(set(fps.values())) == 3 + + +@pytest.mark.parametrize( + ("section", "field", "value"), + [ + ("chunking", "unit", "fixed"), + ("chunking", "size_tokens", 400), + ("chunking", "overlap_tokens", 10), + ("retrieval", "mode", "hybrid_rrf"), + ("retrieval", "vector_top_k", 20), + ("retrieval", "fts_top_k", 20), + ("retrieval", "rrf_k", 61), + ("retrieval", "rerank", "cross-encoder"), + ("retrieval", "final_k", 7), + ("answer", "model", "other-model"), + ("answer", "temperature", 0.5), + ("answer", "seed", 43), + ("answer", "refusal_threshold", 0.4), + ("answer", "high_confidence_threshold", 0.7), + ("answer", "prompt_template_sha256", "0" * 64), + ("embeddings", "model", "nomic-embed-text"), + ("embeddings", "dimensions", 512), + ], +) +def test_fingerprint_changes_on_every_binding_field( + tmp_path: Path, section: str, field: str, value: Any +) -> None: + # model_copy bypasses validation on purpose: the fingerprint must react to + # every binding-field change, regardless of whether the combo is valid. + base = _load(tmp_path, "v1") + mutated_section = getattr(base, section).model_copy(update={field: value}) + mutated = base.model_copy(update={section: mutated_section}) + assert fingerprint(mutated) != fingerprint(base), f"{section}.{field}" + + +def test_fingerprint_payload_covers_exactly_the_binding_sections(tmp_path: Path) -> None: + payload = fingerprint_payload(_load(tmp_path, "v1")) + assert set(payload) == {"chunking", "retrieval", "answer", "embeddings"} + assert set(payload["answer"]) == { + "model", + "temperature", + "seed", + "refusal_threshold", + "high_confidence_threshold", + "prompt_template_sha256", + } + + +def test_fp8_is_first_8_hex_chars(tmp_path: Path) -> None: + cfg = _load(tmp_path, "v1") + assert fp8(cfg) == fingerprint(cfg)[:8] + assert re.fullmatch(r"[0-9a-f]{8}", fp8(cfg)) + + +# --- validation with key paths (§11.4) --------------------------------------- + + +def test_unknown_key_rejected_with_key_path(tmp_path: Path) -> None: + with pytest.raises(ConfigError, match=r"chunking\.units"): + _load(tmp_path, "v1", '[chunking]\nunits = "fixed"\n') + + +def test_wrong_type_rejected_with_key_path(tmp_path: Path) -> None: + with pytest.raises(ConfigError, match=r"answer\.temperature"): + _load(tmp_path, "v1", '[answer]\ntemperature = "hot"\n') + + +def test_fts_top_k_must_be_zero_in_vector_mode(tmp_path: Path) -> None: + with pytest.raises(ConfigError, match=r"retrieval\.fts_top_k"): + _load(tmp_path, "v1", "[retrieval]\nfts_top_k = 20\n") + + +def test_vector_mode_requires_zero_fts_top_k(tmp_path: Path) -> None: + with pytest.raises(ConfigError, match=r"retrieval\.fts_top_k"): + _load(tmp_path, "v3", '[retrieval]\nmode = "vector"\n') + + +def test_rerank_requires_hybrid_mode(tmp_path: Path) -> None: + with pytest.raises(ConfigError, match=r"retrieval\.rerank"): + _load(tmp_path, "v1", '[retrieval]\nrerank = "cross-encoder"\n') + + +def test_overlap_must_be_smaller_than_size(tmp_path: Path) -> None: + with pytest.raises(ConfigError, match=r"chunking\.overlap_tokens"): + _load(tmp_path, "v1", "[chunking]\noverlap_tokens = 800\n") + + +def test_missing_user_file_raises_config_error(tmp_path: Path) -> None: + with pytest.raises(ConfigError, match="config file not found"): + load_config(tmp_path / "missing.toml", CONFIGS / "v1.toml") + + +def test_missing_preset_file_raises_config_error(tmp_path: Path) -> None: + with pytest.raises(ConfigError, match="config file not found"): + load_config(_write_user(tmp_path, ""), tmp_path / "missing.toml")