Expand description
Configuration resolution for Ralph, including global and project layers.
Responsibilities:
- Resolve configuration from multiple layers: global config, project config, and defaults.
- Load and parse config files (JSON with JSONC comment support via
load_layer). - Merge configuration layers via
ConfigLayerandapply_layer. - Validate configuration values (version, paths, numeric ranges, runner binaries).
- Resolve queue/done file paths and ID generation settings (prefix, width).
- Discover repository root via
.ralph/directory or.git/.
Not handled here:
- CLI argument parsing (see
crate::cli). - Queue operations like task CRUD (see
crate::queue). - Runner execution or agent invocation (see
crate::runner). - Prompt rendering or template processing (see
crate::prompts_internal). - Lock management (see
crate::lock).
Invariants/assumptions:
- Config version must be 1; unsupported versions are rejected.
- Paths are resolved relative to repo root unless absolute.
- Global config resolves from
~/.config/ralph/config.jsoncwith.jsonfallback. - Project config resolves from
.ralph/config.jsoncwith.jsonfallback. - Config layers are applied in this order: defaults, then global, then project (later layers override earlier ones).
save_layercreates parent directories automatically if needed.
Structs§
- Config
Layer - Resolved
- Resolved configuration including computed paths.
Functions§
- apply_
layer - Apply a config layer on top of a base config. Later layers override earlier ones using leaf-wise merge semantics.
- find_
repo_ root - Find the repository root starting from a given path.
- git_
ref_ invalid_ reason - Check if a string is a valid git branch name. Returns None if valid, or Some(reason) if invalid. Based on git’s check-ref-format rules:
- global_
config_ path - Get the path to the global config file.
- load_
layer - Load a config layer from a JSON/JSONC file.
- prefer_
jsonc_ then_ json - Resolve a JSON path with .json fallback.
- project_
config_ path - Get the path to the project config file for a given repo root.
- resolve_
done_ path - Resolve the done file path from config.
- resolve_
from_ cwd - Resolve configuration from the current working directory.
- resolve_
from_ cwd_ for_ doctor - Resolve config for the doctor command, skipping instruction_files validation. This allows doctor to diagnose and warn about missing files without failing early.
- resolve_
from_ cwd_ with_ profile - Resolve config with an optional profile selection.
- resolve_
id_ prefix - Resolve the queue ID prefix from config.
- resolve_
id_ width - Resolve the queue ID width from config.
- resolve_
queue_ path - Resolve the queue file path from config.
- save_
layer - Save a config layer to a JSON file. Automatically sets version to 1 if not specified and creates parent directories.
- validate_
agent_ binary_ paths - Validate that all configured binary paths are non-empty strings.
- validate_
agent_ patch - Validate an AgentConfig patch (used for base agent and profile agents).
- validate_
config - Validate the full configuration.
- validate_
queue_ done_ file_ override - Validate queue.done_file override (if specified, must be non-empty).
- validate_
queue_ file_ override - Validate queue.file override (if specified, must be non-empty).
- validate_
queue_ id_ prefix_ override - Validate queue.id_prefix override (if specified, must be non-empty after trim).
- validate_
queue_ id_ width_ override - Validate queue.id_width override (if specified, must be greater than 0).
- validate_
queue_ overrides - Validate all queue config overrides in a single call.