crp.config¶
Auto-generated reference for the crp.config subpackage.
config¶
crp.config ¶
Unified Configuration - one optional crp.config.yaml governs everything (SPEC-037).
Implements the 5-layer configuration hierarchy required by SPEC-037 §3: Layer 1: Hardcoded defaults (this file) Layer 2: Environment variables (CRP_* prefix) Layer 3: Config file (crp.config.yaml) Layer 4: Client() init kwargs Layer 5: Runtime configure() call
The entire config is optional - every field has a default. The config hash (CRP-Config-Hash) is emitted when a config file is loaded.
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.