"""Workspace YAML loading — the single boundary for workspace configuration (spec D3). Reads workspaces/.yaml, expands ${VAR} from env, validates via the Config model (ported from the reference implementation). Future migration to a DB store would replace only this module. La struttura YAML rispecchia esattamente tht/config.py: database/rest o resources.dwh per il DWH, resources.vector/resources.embeddings per Qdrant/Ollama interni, più evidence ed execution. I vecchi campi vector_db e vector_rest restano solo per leggere fixture legacy durante la migrazione. """ from __future__ import annotations from pathlib import Path from tht.config import Config, ConfigError, load_config class WorkspaceError(Exception): """Errore di caricamento del workspace (file mancante, env var non definita, yaml invalido).""" def load_workspace(path: str | Path) -> Config: """Carica e valida un workspace YAML. Espande ${VAR} dall'ambiente; se una variabile referenziata manca, raises WorkspaceError. Delega a load_config (portato da the reference implementation) per la validazione del modello Config. """ path = Path(path) try: return load_config(path) except ConfigError as e: raise WorkspaceError(str(e)) from e