Config API¶
The unified configuration object loads defaults, environment variables, crp.config.yaml, and runtime overrides into a single typed surface.
CRPConfig¶
crp.config.CRPConfig dataclass ¶
Unified CRP configuration - one object governs everything (SPEC-037).
Load from file::
config = CRPConfig.load("crp.config.yaml")
Or build programmatically::
config = CRPConfig()
config.set("safety.profile", "strict")
load(path='crp.config.yaml') classmethod ¶
Load from a YAML or JSON file. Falls back to defaults if file missing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | str | Path to the config file (YAML or JSON). | 'crp.config.yaml' |
Returns:
| Type | Description |
|---|---|
CRPConfig | A |
save(path=None) ¶
Persist current config to disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | str | None | Destination path. Defaults to the loaded source path or | None |
get(dotted_path, default=None) ¶
Read a value by dotted path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dotted_path | str | Dot-separated path such as | required |
default | Any | Value returned if the path does not exist. | None |
Returns:
| Type | Description |
|---|---|
Any | The stored value or |
set(dotted_path, value) ¶
Write a value by dotted path, creating intermediate dicts as needed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dotted_path | str | Dot-separated path such as | required |
value | Any | Value to store. | required |
layer_override(overrides) ¶
Return a new CRPConfig with runtime overrides applied (Layer 5).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
overrides | dict[str, Any] | Mapping of dotted paths to override values. | required |
Returns:
| Type | Description |
|---|---|
CRPConfig | A new immutable-style config instance. |
get_config_hash() ¶
Return deterministic hash for the CRP-Config-Hash header.
Returns:
| Type | Description |
|---|---|
str | A 32-character BLAKE2b hex digest of the canonical JSON config. |
to_dict() ¶
Export as a plain deep-copied dict.
to_yaml() ¶
Export as a YAML string (JSON fallback if PyYAML is unavailable).
to_json() ¶
Export as a pretty-printed JSON string.