Classes
UnifiedConfigLoader
8
▼
Single loader for all config modes.
Precedence (lowest to highest):
1. DEFAULTS (nested struct…
UnifiedConfigLoader
8
▼
Single loader for all config modes.
Precedence (lowest to highest): 1. DEFAULTS (nested structure) 2. User config (single file or directory) 3. Environment overrides (optional) 4. Profile overrides (optional)
Methods
load
3
Config
▼
Load configuration from site root.
Auto-detects config mode:
- config/ dir…
load
3
Config
▼
def load(self, site_root: Path, environment: str | None = None, profile: str | None = None) -> Config
Load configuration from site root.
Auto-detects config mode:
- config/ directory exists → directory mode
- bengal.toml/yaml exists → single-file mode
- Neither → DEFAULTS only
Parameters
| Name | Type | Description |
|---|---|---|
site_root |
— |
Root directory of the site. |
environment |
— |
Environment name (auto-detected if None). Default:None
|
profile |
— |
Profile name (optional). Default:None
|
Returns
Config
Config object with structured access.
get_origin_tracker
0
ConfigWithOrigin | None
▼
Get the origin tracker instance if tracking is enabled.
get_origin_tracker
0
ConfigWithOrigin | None
▼
def get_origin_tracker(self) -> ConfigWithOrigin | None
Returns
ConfigWithOrigin | None
load_snapshot
3
ConfigSnapshot
▼
Load configuration and return a frozen ConfigSnapshot.
This is the preferred e…
load_snapshot
3
ConfigSnapshot
▼
def load_snapshot(self, site_root: Path, environment: str | None = None, profile: str | None = None) -> ConfigSnapshot
Load configuration and return a frozen ConfigSnapshot.
This is the preferred entry point for RFC: Snapshot-Enabled v2. Returns a frozen, typed configuration that is thread-safe by construction.
Parameters
| Name | Type | Description |
|---|---|---|
site_root |
— |
Root directory of the site. |
environment |
— |
Environment name (auto-detected if None). Default:None
|
profile |
— |
Profile name (optional). Default:None
|
Returns
ConfigSnapshot
Frozen ConfigSnapshot with typed sections.
Internal Methods 5 ▼
__init__
1
▼
Initialize the unified configuration loader.
__init__
1
▼
def __init__(self, track_origins: bool = False) -> None
Parameters
| Name | Type | Description |
|---|---|---|
track_origins |
— |
If True, track which file contributed each config key. Default:False
|
_default_config
0
dict[str, Any]
▼
Return a deep copy of DEFAULTS for single-file parity with directory loader.
_default_config
0
dict[str, Any]
▼
def _default_config(self) -> dict[str, Any]
Returns
dict[str, Any]
_find_config_file
1
Path | None
▼
Find single config file (bengal.toml, bengal.yaml, bengal.yml).
_find_config_file
1
Path | None
▼
def _find_config_file(self, site_root: Path) -> Path | None
Parameters
| Name | Type | Description |
|---|---|---|
site_root |
— |
Returns
Path | None
_load_file
1
dict[str, Any]
▼
Load a single config file (TOML or YAML).
_load_file
1
dict[str, Any]
▼
def _load_file(self, path: Path) -> dict[str, Any]
Parameters
| Name | Type | Description |
|---|---|---|
path |
— |
Returns
dict[str, Any]
_load_directory
1
dict[str, Any]
▼
Load all YAML files from config/_default/ directory.
_load_directory
1
dict[str, Any]
▼
def _load_directory(self, config_dir: Path) -> dict[str, Any]
Parameters
| Name | Type | Description |
|---|---|---|
config_dir |
— |
Returns
dict[str, Any]